From patchwork Mon Dec 6 22:51:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12660407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C77B5C433EF for ; Mon, 6 Dec 2021 23:01:56 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.240328.416834 (Exim 4.92) (envelope-from ) id 1muMzU-00010O-TL; Mon, 06 Dec 2021 23:01:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 240328.416834; Mon, 06 Dec 2021 23:01:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1muMzU-00010H-Pm; Mon, 06 Dec 2021 23:01:48 +0000 Received: by outflank-mailman (input) for mailman id 240328; Mon, 06 Dec 2021 23:01:46 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1muMpn-0000Tb-71 for xen-devel@lists.xenproject.org; Mon, 06 Dec 2021 22:51:47 +0000 Received: from galois.linutronix.de (galois.linutronix.de [193.142.43.55]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 17075511-56e7-11ec-8a4d-196798b21f7b; Mon, 06 Dec 2021 23:51:46 +0100 (CET) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 17075511-56e7-11ec-8a4d-196798b21f7b Message-ID: <20211206210749.063705667@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1638831106; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=9e4EOcKKPduqUhpCF4p+2UUYlWyoniP7lkjFDtpqz3Y=; b=Y3Zk3CvhlchISCdf8dHPj4poyVu0qDQ568VEyVaToZAlNEqQi/S1x3gDaMvyVdtKEPlDeK gom1c1hZJ0+1FVRsN8FfMivDuckiCDX0hSqJocL2HBHr+t7Yk7CLCWJG34R78+WM0bTybW EOCNKInDl7y7WUoj3SW3ApdxCAnHdCzZtMeho1tEAjRiAo+SxRcaihs82O+dYDY7PO3p/+ XCkyrbnh37tVACqnHEPr1obQxu1CsvWACFBW84i4AJhSO3ZQXkpsI2o/SwVyuSRwP7Bw+h 6TRWEy6ZzgFoXF8vRrbJTv5ELeNAEME6EyTykOq4Aqm8xgRDNtUCA+FwM1sxvA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1638831106; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=9e4EOcKKPduqUhpCF4p+2UUYlWyoniP7lkjFDtpqz3Y=; b=AjrNQMXU7lGzUGrbWNCpXMglJn8ZwBKEcm1/D7OSmkwL48kKIquDrjBmMavN5yx36Y6jdl /30zlBFMrb57wTDA== From: Thomas Gleixner To: LKML Cc: Bjorn Helgaas , Marc Zygnier , Alex Williamson , Kevin Tian , Jason Gunthorpe , Megha Dey , Ashok Raj , linux-pci@vger.kernel.org, Cedric Le Goater , xen-devel@lists.xenproject.org, Juergen Gross , Greg Kroah-Hartman , Niklas Schnelle , linux-s390@vger.kernel.org, Heiko Carstens , Christian Borntraeger , Logan Gunthorpe , Jon Mason , Dave Jiang , Allen Hubbe , linux-ntb@googlegroups.com Subject: [patch V2 27/31] genirq/msi: Convert to new functions References: <20211206210600.123171746@linutronix.de> MIME-Version: 1.0 Date: Mon, 6 Dec 2021 23:51:45 +0100 (CET) Use the new iterator functions and add locking where required. Signed-off-by: Thomas Gleixner --- kernel/irq/msi.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -348,6 +348,7 @@ EXPORT_SYMBOL_GPL(msi_next_desc); unsigned int msi_get_virq(struct device *dev, unsigned int index) { struct msi_desc *desc; + unsigned int ret = 0; bool pcimsi; if (!dev->msi.data) @@ -355,11 +356,12 @@ unsigned int msi_get_virq(struct device pcimsi = msi_device_has_property(dev, MSI_PROP_PCI_MSI); - for_each_msi_entry(desc, dev) { + msi_lock_descs(dev); + msi_for_each_desc(desc, dev, MSI_DESC_ASSOCIATED) { /* PCI-MSI has only one descriptor for multiple interrupts. */ if (pcimsi) { - if (desc->irq && index < desc->nvec_used) - return desc->irq + index; + if (index < desc->nvec_used) + ret = desc->irq + index; break; } @@ -367,10 +369,13 @@ unsigned int msi_get_virq(struct device * PCI-MSIX and platform MSI use a descriptor per * interrupt. */ - if (desc->msi_index == index) - return desc->irq; + if (desc->msi_index == index) { + ret = desc->irq; + break; + } } - return 0; + msi_unlock_descs(dev); + return ret; } EXPORT_SYMBOL_GPL(msi_get_virq); @@ -401,7 +406,7 @@ static const struct attribute_group **ms int i; /* Determine how many msi entries we have */ - for_each_msi_entry(entry, dev) + msi_for_each_desc(entry, dev, MSI_DESC_ALL) num_msi += entry->nvec_used; if (!num_msi) return NULL; @@ -411,7 +416,7 @@ static const struct attribute_group **ms if (!msi_attrs) return ERR_PTR(-ENOMEM); - for_each_msi_entry(entry, dev) { + msi_for_each_desc(entry, dev, MSI_DESC_ALL) { for (i = 0; i < entry->nvec_used; i++) { msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL); if (!msi_dev_attr) @@ -831,7 +836,7 @@ static bool msi_check_reservation_mode(s * Checking the first MSI descriptor is sufficient. MSIX supports * masking and MSI does so when the can_mask attribute is set. */ - desc = first_msi_entry(dev); + desc = msi_first_desc(dev, MSI_DESC_ALL); return desc->pci.msi_attrib.is_msix || desc->pci.msi_attrib.can_mask; }