From patchwork Tue Aug 2 17:23:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 9259419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EF2546077C for ; Tue, 2 Aug 2016 17:29:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD62928489 for ; Tue, 2 Aug 2016 17:29:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0971284A4; Tue, 2 Aug 2016 17:29:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4A7EE28489 for ; Tue, 2 Aug 2016 17:29:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bUdU2-00029J-17; Tue, 02 Aug 2016 17:28:02 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bUdQz-0006Xs-Ud for linux-arm-kernel@lists.infradead.org; Tue, 02 Aug 2016 17:24:57 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E3398636F9; Tue, 2 Aug 2016 17:24:33 +0000 (UTC) Received: from localhost.redhat.com (vpn1-7-179.ams2.redhat.com [10.36.7.179]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u72HNgIU017433; Tue, 2 Aug 2016 13:24:29 -0400 From: Eric Auger To: eric.auger@redhat.com, eric.auger.pro@gmail.com, christoffer.dall@linaro.org, marc.zyngier@arm.com, robin.murphy@arm.com, alex.williamson@redhat.com, will.deacon@arm.com, joro@8bytes.org, tglx@linutronix.de, jason@lakedaemon.net, linux-arm-kernel@lists.infradead.org Subject: [PATCH v12 09/11] genirq/msi: Introduce msi_desc flags Date: Tue, 2 Aug 2016 17:23:35 +0000 Message-Id: <1470158617-7022-10-git-send-email-eric.auger@redhat.com> In-Reply-To: <1470158617-7022-1-git-send-email-eric.auger@redhat.com> References: <1470158617-7022-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 02 Aug 2016 17:24:34 +0000 (UTC) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160802_102454_348749_6A98F601 X-CRM114-Status: GOOD ( 20.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: drjones@redhat.com, kvm@vger.kernel.org, Jean-Philippe.Brucker@arm.com, Manish.Jaggi@caviumnetworks.com, p.fedin@samsung.com, linux-kernel@vger.kernel.org, Bharat.Bhushan@freescale.com, iommu@lists.linux-foundation.org, pranav.sawargaonkar@gmail.com, dennis.chen@arm.com, robert.richter@caviumnetworks.com, yehuday@marvell.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This new flags member is meant to store additional information about the msi descriptor, starting with allocation status information. MSI_DESC_FLAG_ALLOCATED bit tells the associated base IRQ is allocated. This information is currently used at deallocation time. We also introduce MSI_DESC_FLAG_FUNCTIONAL telling the MSIs are functional. For the time being ALLOCATED and FUNCTIONAL are set at the same time but this is going to change in subsequent patch. Indeed in some situations some additional tasks need to be carried out for the MSI to be functional. For instance the MSI doorbell may need to be mapped in an IOMMU. FUNCTIONAL value already gets used when enumerating the usable MSIs in msix_capability_init. Signed-off-by: Eric Auger --- v12: new --- drivers/pci/msi.c | 2 +- include/linux/msi.h | 14 ++++++++++++++ kernel/irq/msi.c | 7 ++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index a080f44..d7733ea 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -793,7 +793,7 @@ out_avail: int avail = 0; for_each_pci_msi_entry(entry, dev) { - if (entry->irq != 0) + if (entry->flags & MSI_DESC_FLAG_FUNCTIONAL) avail++; } if (avail != 0) diff --git a/include/linux/msi.h b/include/linux/msi.h index 8b425c6..18f894f 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -47,6 +47,7 @@ struct fsl_mc_msi_desc { * @nvec_used: The number of vectors used * @dev: Pointer to the device which uses this descriptor * @msg: The last set MSI message cached for reuse + * @flags: flags to describe the MSI descriptor status or features * * @masked: [PCI MSI/X] Mask bits * @is_msix: [PCI MSI/X] True if MSI-X @@ -67,6 +68,7 @@ struct msi_desc { unsigned int nvec_used; struct device *dev; struct msi_msg msg; + u32 flags; union { /* PCI MSI/X specific data */ @@ -99,6 +101,18 @@ struct msi_desc { }; }; +/* Flags for msi_desc */ +enum { + /* the base IRQ is allocated */ + MSI_DESC_FLAG_ALLOCATED = (1 << 0), + /** + * the MSI is functional; in some cases the fact the base IRQ is + * allocated is not sufficient for the MSIs to be functional: for + * example the MSI doorbell(s) may need to be IOMMU mapped. + */ + MSI_DESC_FLAG_FUNCTIONAL = (1 << 1), +}; + /* Helpers to hide struct msi_desc implementation details */ #define msi_desc_to_dev(desc) ((desc)->dev) #define dev_to_msi_list(dev) (&(dev)->msi_list) diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index 72bf4d6..9b93766 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -361,6 +361,9 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, return ret; } + desc->flags |= MSI_DESC_FLAG_ALLOCATED; + desc->flags |= MSI_DESC_FLAG_FUNCTIONAL; + for (i = 0; i < desc->nvec_used; i++) irq_set_msi_desc_off(virq, i, desc); } @@ -395,9 +398,11 @@ void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev) * enough that there is no IRQ associated to this * entry. If that's the case, don't do anything. */ - if (desc->irq) { + if (desc->flags & MSI_DESC_FLAG_ALLOCATED) { irq_domain_free_irqs(desc->irq, desc->nvec_used); desc->irq = 0; + desc->flags &= ~MSI_DESC_FLAG_ALLOCATED; + desc->flags &= ~MSI_DESC_FLAG_FUNCTIONAL; } } }