From patchwork Sat Nov 27 01:20:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693785 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 8BD65C433FE for ; Sat, 27 Nov 2021 01:23:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=Wmbv+3vluB+oNHwdQl1iC/l5Yb+SOEqgvBXTxny5KME=; b=0IWh3X/oFQprGO VVaLrIoiBlpy2rew3oV42Noh/EE1K0/REUzh2apQ/CK5eAO7tVKIoryXzac53Zf6CsChMu7Kfq+4e QH+mlrAIwk8jp7lNX3p0LnYsW0Ne2bCwO0n+6bCyqpz7ukc+Akg4Hpd5TH/WjpWrzlyp6MvWicCsr vZPnjGKgzR67bjTp/Ctesd+sntvbb5e/8rKNch0XCTCKPzkZejWVgZOES3PgMop51S+IEJpUsP58M qPvjT1vi8mdcSFPMJA7nzruW6jZy2ychxLcZc2pR/3CEzKNU/mxavJMI4AYn85rfm6SyZYzivSi4T vOQ6S2U7hjBbajHJPCUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmPP-00CAon-2u; Sat, 27 Nov 2021 01:21:43 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmNu-00C8wx-9l for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:12 +0000 Message-ID: <20211126230523.982881381@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976009; 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=zYiY5ZPi1pZz8afAYKOwm16ZuL4LqgjWkvsJBEwudjQ=; b=M1tjHrTndu8R61ruqPPxHRbH/MFzK+4MZuu24Ba9vYTRXoJBPK2IhF7B9P8wk6Z6GSAndw hhzaBVBlrS/4b/FZdxL+tSORjlRFHNB9lCeVrekuxGq/AKWqB8yMs1RgdJj9caVTIbiOxO dKZk6lcqxWXtZ5cvcMF+ugv9LiwRSiJbAurrTxZCQuWko3tJYu8wtwX+zmBsY+rcIKfs0V 9aAOMmyBeq3og1AejqknOP25A/es5aSOo/r+4BnzW8pP1l6U5ics50rbznOaEoKgDPFyoq SchksTd37xFICKb08LjS1aVXjXoyiqZGS70qjG2BT4Nmsu/zml6zm9imhyHLXg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976009; 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=zYiY5ZPi1pZz8afAYKOwm16ZuL4LqgjWkvsJBEwudjQ=; b=g9xzySYfkWAe1zIh5oiCZl8nPQJyyVGd4F9KV7UJZMTHTijHvXy4Mk4JimFGqFV5uHru3a 4ifAv5P2mlc+JMCQ== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 01/37] device: Move MSI related data into a struct References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:08 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172010_699093_8340A350 X-CRM114-Status: GOOD ( 21.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The only unconditional part of MSI data in struct device is the irqdomain pointer. Everything else can be allocated on demand. Create a data structure and move the irqdomain pointer into it. The other MSI specific parts are going to be removed from struct device in later steps. Signed-off-by: Thomas Gleixner Cc: Greg Kroah-Hartman Cc: Will Deacon Cc: Santosh Shilimkar Cc: iommu@lists.linux-foundation.org Cc: dmaengine@vger.kernel.org Reviewed-by: Greg Kroah-Hartman --- drivers/base/platform-msi.c | 12 ++++++------ drivers/dma/ti/k3-udma.c | 4 ++-- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +- drivers/irqchip/irq-mvebu-icu.c | 6 +++--- drivers/soc/ti/k3-ringacc.c | 4 ++-- drivers/soc/ti/ti_sci_inta_msi.c | 2 +- include/linux/device.h | 19 +++++++++++++------ 7 files changed, 28 insertions(+), 21 deletions(-) --- a/drivers/base/platform-msi.c +++ b/drivers/base/platform-msi.c @@ -210,10 +210,10 @@ platform_msi_alloc_priv_data(struct devi * accordingly (which would impact the max number of MSI * capable devices). */ - if (!dev->msi_domain || !write_msi_msg || !nvec || nvec > MAX_DEV_MSIS) + if (!dev->msi.domain || !write_msi_msg || !nvec || nvec > MAX_DEV_MSIS) return ERR_PTR(-EINVAL); - if (dev->msi_domain->bus_token != DOMAIN_BUS_PLATFORM_MSI) { + if (dev->msi.domain->bus_token != DOMAIN_BUS_PLATFORM_MSI) { dev_err(dev, "Incompatible msi_domain, giving up\n"); return ERR_PTR(-EINVAL); } @@ -269,7 +269,7 @@ int platform_msi_domain_alloc_irqs(struc if (err) goto out_free_priv_data; - err = msi_domain_alloc_irqs(dev->msi_domain, dev, nvec); + err = msi_domain_alloc_irqs(dev->msi.domain, dev, nvec); if (err) goto out_free_desc; @@ -282,7 +282,7 @@ int platform_msi_domain_alloc_irqs(struc return 0; out_free_irqs: - msi_domain_free_irqs(dev->msi_domain, dev); + msi_domain_free_irqs(dev->msi.domain, dev); out_free_desc: platform_msi_free_descs(dev, 0, nvec); out_free_priv_data: @@ -306,7 +306,7 @@ void platform_msi_domain_free_irqs(struc platform_msi_free_priv_data(desc->platform.msi_priv_data); } - msi_domain_free_irqs(dev->msi_domain, dev); + msi_domain_free_irqs(dev->msi.domain, dev); platform_msi_free_descs(dev, 0, MAX_DEV_MSIS); } EXPORT_SYMBOL_GPL(platform_msi_domain_free_irqs); @@ -354,7 +354,7 @@ struct irq_domain * return NULL; data->host_data = host_data; - domain = irq_domain_create_hierarchy(dev->msi_domain, 0, + domain = irq_domain_create_hierarchy(dev->msi.domain, 0, is_tree ? 0 : nvec, dev->fwnode, ops, data); if (!domain) --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -5279,9 +5279,9 @@ static int udma_probe(struct platform_de if (IS_ERR(ud->ringacc)) return PTR_ERR(ud->ringacc); - dev->msi_domain = of_msi_get_domain(dev, dev->of_node, + dev->msi.domain = of_msi_get_domain(dev, dev->of_node, DOMAIN_BUS_TI_SCI_INTA_MSI); - if (!dev->msi_domain) { + if (!dev->msi.domain) { dev_err(dev, "Failed to get MSI domain\n"); return -EPROBE_DEFER; } --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3170,7 +3170,7 @@ static void arm_smmu_setup_msis(struct a if (!(smmu->features & ARM_SMMU_FEAT_MSI)) return; - if (!dev->msi_domain) { + if (!dev->msi.domain) { dev_info(smmu->dev, "msi_domain absent - falling back to wired irqs\n"); return; } --- a/drivers/irqchip/irq-mvebu-icu.c +++ b/drivers/irqchip/irq-mvebu-icu.c @@ -314,12 +314,12 @@ static int mvebu_icu_subset_probe(struct msi_data->subset_data = of_device_get_match_data(dev); } - dev->msi_domain = of_msi_get_domain(dev, dev->of_node, + dev->msi.domain = of_msi_get_domain(dev, dev->of_node, DOMAIN_BUS_PLATFORM_MSI); - if (!dev->msi_domain) + if (!dev->msi.domain) return -EPROBE_DEFER; - msi_parent_dn = irq_domain_get_of_node(dev->msi_domain); + msi_parent_dn = irq_domain_get_of_node(dev->msi.domain); if (!msi_parent_dn) return -ENODEV; --- a/drivers/soc/ti/k3-ringacc.c +++ b/drivers/soc/ti/k3-ringacc.c @@ -1356,9 +1356,9 @@ static int k3_ringacc_init(struct platfo struct resource *res; int ret, i; - dev->msi_domain = of_msi_get_domain(dev, dev->of_node, + dev->msi.domain = of_msi_get_domain(dev, dev->of_node, DOMAIN_BUS_TI_SCI_INTA_MSI); - if (!dev->msi_domain) { + if (!dev->msi.domain) { dev_err(dev, "Failed to get MSI domain\n"); return -EPROBE_DEFER; } --- a/drivers/soc/ti/ti_sci_inta_msi.c +++ b/drivers/soc/ti/ti_sci_inta_msi.c @@ -140,7 +140,7 @@ EXPORT_SYMBOL_GPL(ti_sci_inta_msi_domain void ti_sci_inta_msi_domain_free_irqs(struct device *dev) { - msi_domain_free_irqs(dev->msi_domain, dev); + msi_domain_free_irqs(dev->msi.domain, dev); ti_sci_inta_msi_free_descs(dev); } EXPORT_SYMBOL_GPL(ti_sci_inta_msi_domain_free_irqs); --- a/include/linux/device.h +++ b/include/linux/device.h @@ -372,6 +372,16 @@ struct dev_links_info { }; /** + * struct dev_msi_info - Device data related to MSI + * @domain: The MSI interrupt domain associated to the device + */ +struct dev_msi_info { +#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN + struct irq_domain *domain; +#endif +}; + +/** * struct device - The basic device structure * @parent: The device's "parent" device, the device to which it is attached. * In most cases, a parent device is some sort of bus or host @@ -409,7 +419,6 @@ struct dev_links_info { * See Documentation/driver-api/pin-control.rst for details. * @msi_lock: Lock to protect MSI mask cache and mask register * @msi_list: Hosts MSI descriptors - * @msi_domain: The generic MSI domain this device is using. * @numa_node: NUMA node this device is close to. * @dma_ops: DMA mapping operations for this device. * @dma_mask: Dma mask (if dma'ble device). @@ -501,12 +510,10 @@ struct device { struct em_perf_domain *em_pd; #endif -#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN - struct irq_domain *msi_domain; -#endif #ifdef CONFIG_PINCTRL struct dev_pin_info *pins; #endif + struct dev_msi_info msi; #ifdef CONFIG_GENERIC_MSI_IRQ raw_spinlock_t msi_lock; struct list_head msi_list; @@ -668,7 +675,7 @@ static inline void set_dev_node(struct d static inline struct irq_domain *dev_get_msi_domain(const struct device *dev) { #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN - return dev->msi_domain; + return dev->msi.domain; #else return NULL; #endif @@ -677,7 +684,7 @@ static inline struct irq_domain *dev_get static inline void dev_set_msi_domain(struct device *dev, struct irq_domain *d) { #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN - dev->msi_domain = d; + dev->msi.domain = d; #endif } From patchwork Sat Nov 27 01:20:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693786 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 CB8CBC433F5 for ; Sat, 27 Nov 2021 01:23:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=af+7jN8/PZhq0vBb/HK+4YOLQKzW4BMGBaoArTHm4Fk=; b=jDclm4eaeESzWq oZaEbYR86sm5N/9XrXiVbQEsBanqpDL6LMRj0WlOz33zxJA/OtrX4u/XpVjlZvft8Der9pAxiPGS5 3JsCWY7dmGp3+8eXgqw6VYy890goiQxojuJ5XRe2nmB+R4MlXGMuga47HksSAlVcQXTEiYqI2Sw8K ikyMqDnZQJiVVGB1ykWzNAmt2Rh3IIPEyvWpd2pzAKRM8/P4wZmi3MgUqBMJkwT23UQ4GjIv2ZPhs UoUhW45BOWr0L2aFN/eyBKoZGmq+5tl7TEJ6PJhg1ou8wg5+jQQxjrJiIzT1/XYirE6guIJ7QSiBO VYC1kQ9ORl2k0VVGkwzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmQ0-00CBLE-7o; Sat, 27 Nov 2021 01:22:21 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmNv-00C8zL-Sl for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:13 +0000 Message-ID: <20211126230524.045836616@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976010; 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=6M1tvQVxDKTLunwyY5ENMp/fgv1O4+f2pv6jOyEcyuQ=; b=YIryAC4L4I1Af3XL1vUUSJE61qVH2AguHzm/Ld5iXG1xUKbISfFXjbkwdlzXWEuDYkPiXG Dfgp77Wy/1LBi6u/Xv4EcGbJ06ckptO2WbYjTpug10iLz3RRg351f4uJKJo024UZO13AzF FtC47tnXWMBlU9MohdTfMwaKC8ZRhyCBDh0JZGQ7iBXItqDxfB+jP7XCVhVF6JEnWHN9C8 lDv6WkdQQ+B7eLtk9GAOZKUrcfKJtKrAJG9u4SBbh+mrj+DG+Oy6Vnbmk9ZaUxLdH9qRbf 0JUgIsJIk6t2s5t9rD2/PAmWE9RuOxWq2b7m/X3mJY8O0tGmCuZpSRopkhwF0g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976010; 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=6M1tvQVxDKTLunwyY5ENMp/fgv1O4+f2pv6jOyEcyuQ=; b=55nX1man+kpE+9l/RSMhAYpCJdsnYsFBBLV92Ozscq0/IQTjQpfArLDxN6QJuBxUrBzLXy 7GxQpxJjJ/zL68BA== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 02/37] device: Add device::msi_data pointer and struct msi_device_data References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:09 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172012_141247_4714616A X-CRM114-Status: GOOD ( 17.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Create struct msi_device_data and add a pointer of that type to struct dev_msi_info, which is part of struct device. Provide an allocator function which can be invoked from the MSI interrupt allocation code pathes. Signed-off-by: Thomas Gleixner Reviewed-by: Greg Kroah-Hartman --- include/linux/device.h | 5 +++++ include/linux/msi.h | 12 +++++++++++- kernel/irq/msi.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) --- a/include/linux/device.h +++ b/include/linux/device.h @@ -45,6 +45,7 @@ struct iommu_ops; struct iommu_group; struct dev_pin_info; struct dev_iommu; +struct msi_device_data; /** * struct subsys_interface - interfaces to device functions @@ -374,11 +375,15 @@ struct dev_links_info { /** * struct dev_msi_info - Device data related to MSI * @domain: The MSI interrupt domain associated to the device + * @data: Pointer to MSI device data */ struct dev_msi_info { #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN struct irq_domain *domain; #endif +#ifdef CONFIG_GENERIC_MSI_IRQ + struct msi_device_data *data; +#endif }; /** --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -2,6 +2,7 @@ #ifndef LINUX_MSI_H #define LINUX_MSI_H +#include #include #include @@ -170,6 +171,16 @@ struct msi_desc { }; }; +/** + * msi_device_data - MSI per device data + * @lock: Spinlock to protect register access + */ +struct msi_device_data { + raw_spinlock_t lock; +}; + +int msi_setup_device_data(struct device *dev); + /* 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) @@ -185,7 +196,6 @@ struct msi_desc { for (__irq = (desc)->irq; \ __irq < ((desc)->irq + (desc)->nvec_used); \ __irq++) - #ifdef CONFIG_IRQ_MSI_IOMMU static inline const void *msi_desc_get_iommu_cookie(struct msi_desc *desc) { --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -73,6 +73,39 @@ void get_cached_msi_msg(unsigned int irq } EXPORT_SYMBOL_GPL(get_cached_msi_msg); +static void msi_device_data_release(struct device *dev, void *res) +{ + WARN_ON_ONCE(!list_empty(&dev->msi_list)); + dev->msi.data = NULL; +} + +/** + * msi_setup_device_data - Setup MSI device data + * @dev: Device for which MSI device data should be set up + * + * Return: 0 on success, appropriate error code otherwise + * + * This can be called more than once for @dev. If the MSI device data is + * already allocated the call succeeds. The allocated memory is + * automatically released when the device is destroyed. + */ +int msi_setup_device_data(struct device *dev) +{ + struct msi_device_data *md; + + if (dev->msi.data) + return 0; + + md = devres_alloc(msi_device_data_release, sizeof(*md), GFP_KERNEL); + if (!md) + return -ENOMEM; + + raw_spin_lock_init(&md->lock); + dev->msi.data = md; + devres_add(dev, md); + return 0; +} + #ifdef CONFIG_SYSFS static ssize_t msi_mode_show(struct device *dev, struct device_attribute *attr, char *buf) From patchwork Sat Nov 27 01:20:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693787 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 951FAC43217 for ; Sat, 27 Nov 2021 01:24:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=GNJJqoZaim5yN0RdOx/+nxVjHC7DGfIvr4ihN0KP6p0=; b=k4VZ8i09Jp0E+9 UtyfT4aA4TduhsNv8Kf6B5TfqBbhhpn7/sCCbwD+q4BAnrgupuw6nS8rYODg/Uf884YhbalGbfIbL Cu8hYA1KHNfgL2CIFfs8R0pMJDFEdsnSIoECxYFGHhVoXpyr7c2iwnfuEoGLvTZPoizId4u/U7Bbo 0+eqyfs98pqTmTupztY0QXi1HMPNHMRXZnu/oy9ihdpKxa/6jtyN12lQeiRkjk0mEUHmOAgQCFzB/ 8lfQHweJkMjMcLm/rRzugktVERcelV6dQcA91UTzMou4xtDKZmS5klpxKVKC8VgQeD+R9hanMjrp1 NphStQnd88xP/lFZ9uTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmQJ-00CBZ9-2X; Sat, 27 Nov 2021 01:22:39 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmNx-00C92I-Bz for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:15 +0000 Message-ID: <20211126230524.112845775@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976012; 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=PN3ExRN1k42hfHq1uj98iHzkfSIuhUpOYD8o8PLDemE=; b=01xVLTHMPuXuTeYCxg++1loVxFY22XwJw5EINvUVSLR8b6vSaVnJ4Eu3iDunii/+YGqLM6 1drlMi0SdMVbvjgfsBIj/PC0bDlRQRAjJbK5kv8969+ScHcA2xWUiPoos8LQZuh/d5d6jO D4ZE4rS/9iuO7f9eC1ny9luoPcBYIsrAVb7FPZeswFUjFFtIZXaqBBRhGMZLS9/8GAr3AR er7pPeOso93vK8TDq62PmgRQUj0m+taEbDUNcx8zjRG0i4QrPGMjYK76RagxwJyeeMhyiP I1tFT/vQYHZYOcsSJT14z3970ncLT74pAvEx8q/OQY2M3Dhgv2UuT9sGxMkwXw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976012; 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=PN3ExRN1k42hfHq1uj98iHzkfSIuhUpOYD8o8PLDemE=; b=+xLyiosPdGZFZyXGwvjUBwEVY8q/I9iXLgSGR5i+pmeNwky76oEsuTtAiA8kT8N3t4LbfE qeYgv7hKS+NIrRAQ== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 03/37] PCI/MSI: Allocate MSI device data on first use References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:11 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172013_611559_8C585B7E X-CRM114-Status: GOOD ( 12.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allocate MSI device data on first use, i.e. when a PCI driver invokes one of the PCI/MSI enablement functions. Signed-off-by: Thomas Gleixner --- drivers/pci/msi/msi.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -889,10 +889,12 @@ static int __pci_enable_msi_range(struct /* deprecated, don't use */ int pci_enable_msi(struct pci_dev *dev) { - int rc = __pci_enable_msi_range(dev, 1, 1, NULL); - if (rc < 0) - return rc; - return 0; + int rc = msi_setup_device_data(&dev->dev); + + if (!rc) + rc = __pci_enable_msi_range(dev, 1, 1, NULL); + + return rc < 0 ? rc : 0; } EXPORT_SYMBOL(pci_enable_msi); @@ -947,7 +949,11 @@ static int __pci_enable_msix_range(struc int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, int minvec, int maxvec) { - return __pci_enable_msix_range(dev, entries, minvec, maxvec, NULL, 0); + int ret = msi_setup_device_data(&dev->dev); + + if (!ret) + ret = __pci_enable_msix_range(dev, entries, minvec, maxvec, NULL, 0); + return ret; } EXPORT_SYMBOL(pci_enable_msix_range); @@ -974,8 +980,12 @@ int pci_alloc_irq_vectors_affinity(struc struct irq_affinity *affd) { struct irq_affinity msi_default_affd = {0}; + int ret = msi_setup_device_data(&dev->dev); int nvecs = -ENOSPC; + if (ret) + return ret; + if (flags & PCI_IRQ_AFFINITY) { if (!affd) affd = &msi_default_affd; From patchwork Sat Nov 27 01:20:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693788 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 B9737C001B6 for ; Sat, 27 Nov 2021 01:25:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=5vbbcC0rB0pbN6hT36lDduVM8p6eF2pKkE7adtRwRe0=; b=VoSu0vco+q69XP R7HlilADLIvdeg6Ugb+fTQa3dYu6FyZSGQq4yQxUBdEaVleSIzaEBeUE2pvZHuTS/VYWCiYIekbY4 +51cYjc8pIqZvC35ATymXU36KuxW6AUDUcMd6LNd18TRNLNI/zE0UsjlNITRrl84k1nSw+3tf585T r538nP8u9FCqsP2kJiiSTZt9WftYAfI45Qvu/yMIRW04ydj6KKxRamh191bRyTUVqAG8gLE50kHj+ INbOnuXaTi8aOhHSV2cIyPWhwYWWxYq5+RwtgAxwrHAmQsx8Xq2DrAQMFgyZ8NVI2T4WIoL7XxoGf RmokY/pFtNSD4em/rQBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmQx-00CBxb-08; Sat, 27 Nov 2021 01:23:19 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmNz-00C94j-Aa for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:17 +0000 Message-ID: <20211126230524.173951799@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976013; 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=KQEQh1eEOaSazo6Y93s5vbUnfdxHtVwCI6okaSxjU/U=; b=vOf/lyTy9Uvmhdzml5O3C7qmhYgs45igzDfSxx9p/drTW4VD4VSEhQhVNKiZUAfNCJC30V e8dQfeYGka8ujhdMrin/sl62vtIrmrIzH00l67bof2S+Q3Z7Q8piEwzoezvFzBpT/UVwF9 Pf29t3lrcwYow+KPk9l0tBxP23ixAtq/6FqL/RBaICUbQyDjtFGxyYOVz+Sd2uZPVZ1Uz3 nclIsoqxq6pO5kZNm6idrPVjFDs/KgaaVEga7pC1jek22SyMs4baM3OacmLcoLv8zH2rfO Z9NON2r61HIbXOghsRUeQUkzUqIYhhlfiPaomHDPH3IfBdziy5prETd8nwUe2A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976013; 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=KQEQh1eEOaSazo6Y93s5vbUnfdxHtVwCI6okaSxjU/U=; b=f86YkWaUYpzObWEqjBLcBy9kuRvnNi405nX87dWtTERX9WPsxoSHwoDQWqHz9JSQ/8qoXh nNdFaAmaI4EFxYBQ== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 04/37] PCI/MSI: Use lock from msi_device_data References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:13 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172015_607134_66B6AB46 X-CRM114-Status: GOOD ( 10.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Remove the register lock from struct device and use the one in struct msi_device_data. Signed-off-by: Thomas Gleixner Reviewed-by: Greg Kroah-Hartman --- drivers/base/core.c | 1 - drivers/pci/msi/msi.c | 2 +- include/linux/device.h | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-) --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2875,7 +2875,6 @@ void device_initialize(struct device *de device_pm_init(dev); set_dev_node(dev, NUMA_NO_NODE); #ifdef CONFIG_GENERIC_MSI_IRQ - raw_spin_lock_init(&dev->msi_lock); INIT_LIST_HEAD(&dev->msi_list); #endif INIT_LIST_HEAD(&dev->links.consumers); --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -18,7 +18,7 @@ int pci_msi_ignore_mask; static noinline void pci_msi_update_mask(struct msi_desc *desc, u32 clear, u32 set) { - raw_spinlock_t *lock = &desc->dev->msi_lock; + raw_spinlock_t *lock = &desc->dev->msi.data->lock; unsigned long flags; if (!desc->pci.msi_attrib.can_mask) --- a/include/linux/device.h +++ b/include/linux/device.h @@ -422,7 +422,6 @@ struct dev_msi_info { * @em_pd: device's energy model performance domain * @pins: For device pin management. * See Documentation/driver-api/pin-control.rst for details. - * @msi_lock: Lock to protect MSI mask cache and mask register * @msi_list: Hosts MSI descriptors * @numa_node: NUMA node this device is close to. * @dma_ops: DMA mapping operations for this device. @@ -520,7 +519,6 @@ struct device { #endif struct dev_msi_info msi; #ifdef CONFIG_GENERIC_MSI_IRQ - raw_spinlock_t msi_lock; struct list_head msi_list; #endif #ifdef CONFIG_DMA_OPS From patchwork Sat Nov 27 01:20:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693789 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 13071C43217 for ; Sat, 27 Nov 2021 01:25:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=6dKU/SPrPygu8E26vXaNuvtEXIlpY0k2wNAPjLmyawg=; b=DNfyfp6N8TqgE/ yZntFlOo3tLlvqiZSg+DJZ2Ux4aQhAbnEMXw7/LPBv1ZIBUSXjT4Q+5r8iYbiraiZv2nNbgicT/7J 4H/U9V9W3hOm9Ln6gcE3RLDe9kl6JKu4e1IAw56dgCvqrkMwzQWLKgHWakF2mSXouVi6+2q1RAJgV PduDPVKmkDfdFsweKvDrG1tfmztmhLSWepPydIofV8LXxDKRbkIj4LDLqNX7Ru5TPx8CfqR0h5lhL Nwy0pJl6WnSeHTtlFks0EOyUMRNMjSj8kttlASzkRuyI6iki54oNxsaG1gC4CqONIrSRxNAkycoh9 MUx+j+tH7lG9kXECVOtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmQb-00CBi8-6W; Sat, 27 Nov 2021 01:22:57 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmO0-00C96R-LT for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:18 +0000 Message-ID: <20211126230524.236729743@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976015; 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=MsQMrlpTATaTMzIfF99P8uE12mWb1u9o9W8ziR/qOrU=; b=v+0MDRnHIZmUYh9muIDezvCL+GrBrMKFHLXhnXDbx/aIi2Wrrx2btpQc2pbAq708vAOooJ ObadXZFbvQQRZhMeKea1bFWMBR++d2Kee/VhqKH4WHWiniGjoIj/ZOXWd4n8EoZVQ82t2C nko5LxZWgMMymJUvjSUGyQm0rfeRyd5sFUXOKIVxxVcL0iLy3n3tVNdEZtgRf1hC78nAr2 bk9apjv2EpkYiMxr4EuHqAXH2Mf4K0ob8IkVlrkTIbQ+lNr0Z/0RN+LJkfsjRRlVaQBn7P Qr3lelca0UZiVpBnbQsaRtzf/2roo+7eVAdf5rYtyNBt7Xe9zdOlWr5n2eHbow== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976015; 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=MsQMrlpTATaTMzIfF99P8uE12mWb1u9o9W8ziR/qOrU=; b=xNoV+WZ/LZHW9aCCjR5qeNdZLfCaDUJ0rJxOsmXMnhAv7pGi4kmklBVoXkagTGMlO0Ex2g B8JBNqCfSLc9oTCw== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 05/37] platform-msi: Allocate MSI device data on first use References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:14 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172016_887263_6E560C79 X-CRM114-Status: GOOD ( 11.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allocate the MSI device data on first invocation of the allocation function for platform MSI private data. Signed-off-by: Thomas Gleixner --- drivers/base/platform-msi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/drivers/base/platform-msi.c +++ b/drivers/base/platform-msi.c @@ -204,6 +204,8 @@ platform_msi_alloc_priv_data(struct devi irq_write_msi_msg_t write_msi_msg) { struct platform_msi_priv_data *datap; + int err; + /* * Limit the number of interrupts to 2048 per device. Should we * need to bump this up, DEV_ID_SHIFT should be adjusted @@ -218,6 +220,10 @@ platform_msi_alloc_priv_data(struct devi return ERR_PTR(-EINVAL); } + err = msi_setup_device_data(dev); + if (err) + return ERR_PTR(err); + /* Already had a helping of MSI? Greed... */ if (!list_empty(dev_to_msi_list(dev))) return ERR_PTR(-EBUSY); @@ -229,7 +235,7 @@ platform_msi_alloc_priv_data(struct devi datap->devid = ida_simple_get(&platform_msi_devid_ida, 0, 1 << DEV_ID_SHIFT, GFP_KERNEL); if (datap->devid < 0) { - int err = datap->devid; + err = datap->devid; kfree(datap); return ERR_PTR(err); } From patchwork Sat Nov 27 01:20:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693790 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 5DDB6C433FE for ; Sat, 27 Nov 2021 01:26:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=qhJZu4X56aGwPOIi5/vjuoCW70qglYms/ZsilprIF08=; b=SOAjrOEHWL6b0E uSNjrjggrpYkNqR4TWt+Q7mpvT0/QdBtaS3VjH3uOy3wvLK7JSijU6aTX9cCYA5Fb4pY1BFxhVnfi KzA4meEF1SnhBaPD/8EDz56D8q4p8W2tPEDSaFVrFfTh04tEe+PNyBKUl47iG7I9APdYXC0zuuh2W 5HPKw12PwRUkLZoPDymucDbFhL9Y+RCizk7g6smA1F4aP2F+m4NqM8hAGewmn0e0E+XsaaHUtGNL5 Dm7CfTwV3xdCR4m0LgHqi8htEwbDqeIbR/3DHBLI8Fwgj8FaKKodYNtwxaA2e9I7CPh4JVQike32n t/aQwB7CDwftl2m5sKrQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmRh-00CCNd-GV; Sat, 27 Nov 2021 01:24:07 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmO2-00C98a-5K for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:20 +0000 Message-ID: <20211126230524.295122054@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976016; 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=Oh8EM+g3S/QfSPoDjrJmTy+Z80Zsw+m+X3NUsXacOTE=; b=qVZGDbNZ2EPWgWKeie9Lsg8SlBXlB0cdjwpWi66yeNG4DYIWMBeGOpSML8TzTYX+IBXTLC MytS9/7pPDvx+5uOdmMK7tsJf7Ty5rDTRSyLyz3rUILaGDpD78K/KinpA9spc//yXsu3gN es43eYzq8WxrwsxRBJzulVPjdWWxECSfHrNvVbIpbHXTO4du8HBL66WTL0tQYDkuwnrV1V PPHrx45+4UKv8DU+YAJ7euQ68e3XyTtqHvf2s+uztrRavCQ0DyLPUn8PCzZD6IvxFPHea8 bXkbZI3WH5L+7y2A9eEGs9xy4p0pSnnPxY75sPwFeTWsH96Mo6TP/W1vzRoDBw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976016; 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=Oh8EM+g3S/QfSPoDjrJmTy+Z80Zsw+m+X3NUsXacOTE=; b=xOkGJjLxWWpLTjyaY3a3wt1jNJ6brnrPkO+LEWpUUYBkEz0HM87BkrlRzK6xnt7ICAcZBo 9lh6ntzQZMTtE/BA== 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, Greg Kroah-Hartman , Stuart Yoder , Laurentiu Tudor , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 06/37] bus: fsl-mc-msi: Allocate MSI device data on first use References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:16 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172018_535810_8413E681 X-CRM114-Status: GOOD ( 10.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allocate the MSI device data on first invocation of the allocation function. Signed-off-by: Thomas Gleixner Cc: Stuart Yoder Cc: Laurentiu Tudor --- drivers/bus/fsl-mc/fsl-mc-msi.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) --- a/drivers/bus/fsl-mc/fsl-mc-msi.c +++ b/drivers/bus/fsl-mc/fsl-mc-msi.c @@ -253,6 +253,14 @@ int fsl_mc_msi_domain_alloc_irqs(struct struct irq_domain *msi_domain; int error; + msi_domain = dev_get_msi_domain(dev); + if (!msi_domain) + return -EINVAL; + + error = msi_setup_device_data(dev); + if (error) + return error; + if (!list_empty(dev_to_msi_list(dev))) return -EINVAL; @@ -260,12 +268,6 @@ int fsl_mc_msi_domain_alloc_irqs(struct if (error < 0) return error; - msi_domain = dev_get_msi_domain(dev); - if (!msi_domain) { - error = -EINVAL; - goto cleanup_msi_descs; - } - /* * NOTE: Calling this function will trigger the invocation of the * its_fsl_mc_msi_prepare() callback From patchwork Sat Nov 27 01:20:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693791 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 AB8AEC43219 for ; Sat, 27 Nov 2021 01:26:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=nofWJlK61/uKg9+rEAC2bDFLEk+Ha4l6t5zj/w+GZiI=; b=qm4Wt8STSVf9ZK jAi4YPJf6JM5fAU1ZIi/pkaebgZSrL1lTgA7FZN8moNJ2ujU+kd8wP5YOyQ4CEh+ykHq3W0o7erJI uZ8l/UZJZWMEerweQzh6RaK92afGmwkPEWn7JpIxjXhsAw54VH+7J/UM1W1HMHMafUVcsvHiMQ+Gp PzRQ9koy69g5DdaC1pVWrYggiqh/JCV6mEIu8oMwTfIDCZhkZ2VmigyvrgUATvYfDw2BDL9HVomSd 2jlqoDbbtwkdNbIbETx7qobeAeJ4KsY2MTVtTu0eyZt2bwFRGR4p2EPw5fqdMxrDsMYttOFYVOJ46 Ay/2wkhuXm9ViisobVmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmSL-00CCjX-Mx; Sat, 27 Nov 2021 01:24:46 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmO4-00C9B1-5W for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:21 +0000 Message-ID: <20211126230524.355599952@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976018; 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=eU/+MzcFFw4K2a/jF7MWe8bjN6ge/wr+X0hgqu8YCCQ=; b=37q0V1cbSuIIBymAUrmV6vNbD0AG9OhMRNskcj82I53q40Eo+MPVhg9OV3PPrI+vgf4Qae 00OY4DmpKexitvBVgwNQhbp9/fozZeZ+4BpSQZSm/65H82KVpqc+wm5XstEezuZy3aX7Ia ezIJIq/W39ScORxoxOeztywmxVN04GEwt0DIYoLqyVUSBJx2pMS2puOtcT6b+M9lKl02wW DDfqSCxmFBAl4spcZCo8BfS4fDaYnwnjJijv85HCTJ7v6gKzZLqwmYAU/qlu+OqhGxTzf0 ZrvZK5+NDO4xKKNbv8zZCSZ1r3cmU5PM767ECfySrY/+l7AM6FBdJZCNhWJbHQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976018; 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=eU/+MzcFFw4K2a/jF7MWe8bjN6ge/wr+X0hgqu8YCCQ=; b=rYicKTlUm2Sg+aAsLf2zZH11aPVNUVCcQpbGPeExh9jfY/pxFsA9qZS4IfVsfuUORtN6WK JmeK4LXSsAc/2cDQ== 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, Greg Kroah-Hartman , Nishanth Menon , Tero Kristo , Santosh Shilimkar , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 07/37] soc: ti: ti_sci_inta_msi: Allocate MSI device data on first use References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:17 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172020_407803_7EC41EED X-CRM114-Status: UNSURE ( 8.62 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allocate the MSI device data on first invocation of the allocation function. Signed-off-by: Thomas Gleixner Cc: Nishanth Menon Cc: Tero Kristo Cc: Santosh Shilimkar Cc: linux-arm-kernel@lists.infradead.org --- drivers/soc/ti/ti_sci_inta_msi.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/soc/ti/ti_sci_inta_msi.c +++ b/drivers/soc/ti/ti_sci_inta_msi.c @@ -120,6 +120,10 @@ int ti_sci_inta_msi_domain_alloc_irqs(st if (pdev->id < 0) return -ENODEV; + ret = msi_setup_device_data(dev); + if (ret) + return ret; + nvec = ti_sci_inta_msi_alloc_descs(dev, res); if (nvec <= 0) return nvec; From patchwork Sat Nov 27 01:20:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693792 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 CBABEC433FE for ; Sat, 27 Nov 2021 01:28:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=avBFGRZ2IFMAQf4jZ7Gnwx7hLvo8qt1nJFyRFIHQ2ac=; b=JuRyLwl+k79uFg IdRXzoHi+yfTq///6W8LVbGd7fQYT65WUC4G5IVSk5SxoDhzXgHOWbxupqpady9EB8QTA4ddYjspP 3K17qEcuuMgtQ+rWGXi6yOzQOnN5Eyo3npdg89pDMZhnvJvUoHUwYTf2F6a0JwH6OaFvhjlyTmpmI 6jPaYG+uU1YZAm5nYShldkUFZ34w+gWrxrhM9OyixiW02FuVz1I5AsSBNEGZi6dCogHkMmmytO24X PrqsQSkVnMYrabi9SSSDVLbdNj9iWiJN2YlARrq6LifKWkeF5O9jbgbJ5yFC7EbTV6LJL7Nm4A1WG R9+9h64SwYlijERYuH5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmTf-00CDhA-6z; Sat, 27 Nov 2021 01:26:07 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmO5-00C9DD-GH for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:23 +0000 Message-ID: <20211126230524.416227100@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976019; 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=gPGwhzABUUuyh4AiGm3N1S2AvFjbvgj2SBJATF8Ta9k=; b=WdVmBLKeAWl1+1lSoqsKhO2w+fOhv1MvCJ6ci17Sg7OATYDjpNIcuhOgShZzZK6Xx1Yab/ yMU75SvHg9kBpNiBMXZwdnkXrOXTqM+j6ppzmdMChmFHpTB0VvNJt5iXOD98BegOzqCQy0 AmUnoJnyJaAeTkB/Y6+po8HFhyFFZco8lBsqDmGuRIxCAY/rMOOayf6lVYPIbC69lOVbXT KUdFHn/xNH+76/UvkNj93p+5Hr+kfQHv4oEz4XD+UnwWQ2O9rCXTBhwBx70U7XqcNTzPgM yOTYdejiqIjyK3rGo5GJj6L9crWLyc57PrU5sGlMqs/bmRpzVz3nbeSOWpeEfw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976019; 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=gPGwhzABUUuyh4AiGm3N1S2AvFjbvgj2SBJATF8Ta9k=; b=SLT9/xH1Ns0jdgPZJpHOWuLECXuQ0rrfP2l18m8X3cB7t0Gp64qMvaYf8Z7blFrq0V76Ck BOUjXI1Fwlfv0wAw== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 08/37] genirq/msi: Provide msi_device_populate/destroy_sysfs() References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:19 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172021_903143_C57EDF6D X-CRM114-Status: GOOD ( 14.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add new allocation functions which can be activated by domain info flags. They store the groups pointer in struct msi_device_data. Signed-off-by: Thomas Gleixner --- include/linux/msi.h | 12 +++++++++++- kernel/irq/msi.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 3 deletions(-) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -174,9 +174,11 @@ struct msi_desc { /** * msi_device_data - MSI per device data * @lock: Spinlock to protect register access + * @attrs: Pointer to the sysfs attribute group */ struct msi_device_data { - raw_spinlock_t lock; + raw_spinlock_t lock; + const struct attribute_group **attrs; }; int msi_setup_device_data(struct device *dev); @@ -242,10 +244,16 @@ void pci_msi_mask_irq(struct irq_data *d void pci_msi_unmask_irq(struct irq_data *data); #ifdef CONFIG_SYSFS +int msi_device_populate_sysfs(struct device *dev); +void msi_device_destroy_sysfs(struct device *dev); + const struct attribute_group **msi_populate_sysfs(struct device *dev); void msi_destroy_sysfs(struct device *dev, const struct attribute_group **msi_irq_groups); #else +static inline int msi_device_populate_sysfs(struct device *dev) { return 0; } +static inline void msi_device_destroy_sysfs(struct device *dev) { } + static inline const struct attribute_group **msi_populate_sysfs(struct device *dev) { return NULL; @@ -393,6 +401,8 @@ enum { MSI_FLAG_MUST_REACTIVATE = (1 << 5), /* Is level-triggered capable, using two messages */ MSI_FLAG_LEVEL_CAPABLE = (1 << 6), + /* Populate sysfs on alloc() and destroy it on free() */ + MSI_FLAG_DEV_SYSFS = (1 << 7), }; int msi_domain_set_affinity(struct irq_data *data, const struct cpumask *mask, --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -214,6 +214,20 @@ const struct attribute_group **msi_popul } /** + * msi_device_populate_sysfs - Populate msi_irqs sysfs entries for a device + * @dev: The device(PCI, platform etc) which will get sysfs entries + */ +int msi_device_populate_sysfs(struct device *dev) +{ + const struct attribute_group **group = msi_populate_sysfs(dev); + + if (IS_ERR(group)) + return PTR_ERR(group); + dev->msi.data->attrs = group; + return 0; +} + +/** * msi_destroy_sysfs - Destroy msi_irqs sysfs entries for devices * @dev: The device(PCI, platform etc) who will remove sysfs entries * @msi_irq_groups: attribute_group for device msi_irqs entries @@ -239,6 +253,17 @@ void msi_destroy_sysfs(struct device *de kfree(msi_irq_groups); } } + +/** + * msi_device_destroy_sysfs - Destroy msi_irqs sysfs entries for a device + * @dev: The device(PCI, platform etc) for which to remove + * sysfs entries + */ +void msi_device_destroy_sysfs(struct device *dev) +{ + msi_destroy_sysfs(dev, dev->msi.data->attrs); + dev->msi.data->attrs = NULL; +} #endif #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN @@ -686,8 +711,19 @@ int msi_domain_alloc_irqs(struct irq_dom { struct msi_domain_info *info = domain->host_data; struct msi_domain_ops *ops = info->ops; + int ret; - return ops->domain_alloc_irqs(domain, dev, nvec); + ret = ops->domain_alloc_irqs(domain, dev, nvec); + if (ret) + return ret; + + if (!(info->flags & MSI_FLAG_DEV_SYSFS)) + return 0; + + ret = msi_device_populate_sysfs(dev); + if (ret) + msi_domain_free_irqs(domain, dev); + return ret; } void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev) @@ -726,7 +762,9 @@ void msi_domain_free_irqs(struct irq_dom struct msi_domain_info *info = domain->host_data; struct msi_domain_ops *ops = info->ops; - return ops->domain_free_irqs(domain, dev); + if (info->flags & MSI_FLAG_DEV_SYSFS) + msi_device_destroy_sysfs(dev); + ops->domain_free_irqs(domain, dev); } /** From patchwork Sat Nov 27 01:20:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693793 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 50418C433FE for ; Sat, 27 Nov 2021 01:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=C6Qr90aqeKPmHNWXZMNP9PVUWllyj4V3VVEuamsbGHs=; b=pyuNWZI//HmXC2 trSlwymU3/ypQphwjDYhtIH+jXgfVTAm2l+CCr8nRADoECO7kIomkWAkljEuyKcvHak04BQ58kudb kfFf9dCzIPN3qTeFXvJwNGtYvrWWCzixksv3o4gJqaCZW0VUaqTBjzEKrVp9Oo4d8gzNi0XwxbOQt Ppr5fV799DFGm24by0IL+mMgJxofKD3sBGxpod2qwAR57JZyM1DvGoSMFXCwoeA6JzKN2cKjQnxVb PSH+ecrDuToKGcLHoX+MLGWuriiOBaP88Mi1ih288pvpysB73zrQX9XgLt21rs1vItppwGtOU7Ia2 5HKRw/Vb8oVllE7yokNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmUL-00CDz5-GY; Sat, 27 Nov 2021 01:26:50 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmO7-00C9FK-2w for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:25 +0000 Message-ID: <20211126230524.478418625@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976021; 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=6Kf8uoDdfqcgp3MpzFvCoiTWQV1YmFn3oOwS+G3NmiU=; b=iWolB7GTQpESFLCRMVKgPs1KrxaKC2ow1tGQffcaDNv2F0xW3vx0KvkQyu9E3HoqpLbjwF a1DMLtRU5UQi+E6tXiG7XgZSenRjWBZ95EguzyhGqxM8+8j1umUpkDH563q1Yt15pe9KgW /7Jxt5orP58QzGcs9NGfHM2D7jy6vbZFC00c4OO6SMHMXlCTv97VIWnLj085ApIev+4lMm AzMxX8cGljCptpTHoj6VaH8H7zpAxG8rZl+SpEqQ0BhNzR6xvOZlrjhoboEFBMtQ5wcmxv QLLD+xUVD7tM30wav2yu47nC6rzmcxUaWTmvPTRzKZEbeEVH6dF/47vx12DYwg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976021; 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=6Kf8uoDdfqcgp3MpzFvCoiTWQV1YmFn3oOwS+G3NmiU=; b=0U7PCipwIXxPj9e5b6tNbyglTbNA/F6jyYdL9UjWoQb8at8gcc4eTSOpgaxNCw926RLOpS s+s7MXXsuD+XUuBw== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 09/37] PCI/MSI: Let the irq code handle sysfs groups References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:20 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172023_386049_0CD4E933 X-CRM114-Status: GOOD ( 14.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Set the domain info flag which makes the core code handle sysfs groups and put an explicit invocation into the legacy code. Signed-off-by: Thomas Gleixner --- drivers/pci/msi/irqdomain.c | 2 +- drivers/pci/msi/legacy.c | 6 +++++- drivers/pci/msi/msi.c | 23 ----------------------- include/linux/pci.h | 1 - 4 files changed, 6 insertions(+), 26 deletions(-) --- a/drivers/pci/msi/irqdomain.c +++ b/drivers/pci/msi/irqdomain.c @@ -159,7 +159,7 @@ struct irq_domain *pci_msi_create_irq_do if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS) pci_msi_domain_update_chip_ops(info); - info->flags |= MSI_FLAG_ACTIVATE_EARLY; + info->flags |= MSI_FLAG_ACTIVATE_EARLY | MSI_FLAG_DEV_SYSFS; if (IS_ENABLED(CONFIG_GENERIC_IRQ_RESERVATION_MODE)) info->flags |= MSI_FLAG_MUST_REACTIVATE; --- a/drivers/pci/msi/legacy.c +++ b/drivers/pci/msi/legacy.c @@ -71,10 +71,14 @@ int pci_msi_legacy_setup_msi_irqs(struct { int ret = arch_setup_msi_irqs(dev, nvec, type); - return pci_msi_setup_check_result(dev, type, ret); + ret = pci_msi_setup_check_result(dev, type, ret); + if (!ret) + ret = msi_device_populate_sysfs(&dev->dev); + return ret; } void pci_msi_legacy_teardown_msi_irqs(struct pci_dev *dev) { + msi_device_destroy_sysfs(&dev->dev); arch_teardown_msi_irqs(dev); } --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -233,11 +233,6 @@ static void free_msi_irqs(struct pci_dev for (i = 0; i < entry->nvec_used; i++) BUG_ON(irq_has_action(entry->irq + i)); - if (dev->msi_irq_groups) { - msi_destroy_sysfs(&dev->dev, dev->msi_irq_groups); - dev->msi_irq_groups = NULL; - } - pci_msi_teardown_msi_irqs(dev); list_for_each_entry_safe(entry, tmp, msi_list, list) { @@ -415,7 +410,6 @@ static int msi_verify_entries(struct pci static int msi_capability_init(struct pci_dev *dev, int nvec, struct irq_affinity *affd) { - const struct attribute_group **groups; struct msi_desc *entry; int ret; @@ -439,14 +433,6 @@ static int msi_capability_init(struct pc if (ret) goto err; - groups = msi_populate_sysfs(&dev->dev); - if (IS_ERR(groups)) { - ret = PTR_ERR(groups); - goto err; - } - - dev->msi_irq_groups = groups; - /* Set MSI enabled bits */ pci_intx_for_msi(dev, 0); pci_msi_set_enable(dev, 1); @@ -574,7 +560,6 @@ static void msix_mask_all(void __iomem * static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries, int nvec, struct irq_affinity *affd) { - const struct attribute_group **groups; void __iomem *base; int ret, tsize; u16 control; @@ -616,14 +601,6 @@ static int msix_capability_init(struct p msix_update_entries(dev, entries); - groups = msi_populate_sysfs(&dev->dev); - if (IS_ERR(groups)) { - ret = PTR_ERR(groups); - goto out_free; - } - - dev->msi_irq_groups = groups; - /* Set MSI-X enabled bits and unmask the function */ pci_intx_for_msi(dev, 0); dev->msix_enabled = 1; --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -474,7 +474,6 @@ struct pci_dev { #endif #ifdef CONFIG_PCI_MSI void __iomem *msix_base; - const struct attribute_group **msi_irq_groups; #endif struct pci_vpd vpd; #ifdef CONFIG_PCIE_DPC From patchwork Sat Nov 27 01:20:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693794 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 D9EA2C43217 for ; Sat, 27 Nov 2021 01:29:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=QZOF6UUWhysynl9O2S3ffbDsxBNvGAGIcbcpthUp2jQ=; b=u+McTS7BHSjkbJ ySdtCXFthskr5rsNjI3+fSO/2qmWHTaPVrnxnbVzjFMC/e0sT7Rp051nd8B0F7+q/1UTCg4CeQEYO M2kLyqu6sG04+RNy7Cn2zo3QwSB1seQ4PVYh1ZvN8Yx6VZ1K1OSbqUnAFosJWFEKhe6Dx9E3fHCRN 3Xuy0uUOKQ+obdvQ6iYQJa7REz6CW2Dku7mJfZDCUSUO+gELebwXzXeMilVQKJzKQXNHF83wer6Oa e0NyjttRXZ0JTJfjJCInRp5Wh8jQ1/88ckY8ojMfX6DlSVGQN74hsL8Ep/LsjH5erCqgRI4TR+vNd Bp9RXN0Au81nNZamO7MQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmUx-00CEIZ-EX; Sat, 27 Nov 2021 01:27:27 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmO8-00C9HE-Ou for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:27 +0000 Message-ID: <20211126230524.540744026@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976023; 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=gn8p+zMtjjrDzl8WaoyQn+U7cmDXCgk8UU3FdWlgcVs=; b=vMSQa0GYeGhY/pQ4O3tvUkTqJYLpCVkeC4y3u62zMn4FDrQJklj+STCq5BEfsBTu0s2M5V 99+bbp9ELyYr+aMYUNTAdckGT0s4QZGAhftfFq4vaT12BSiAiglPhl/pJu5pvfNLgaBuwd kVox6DN0xr4zl4AtTeFqpfMGZJvbL2W6KeeYSAHPC7rcosHlgznuyHpq+qngY0fR2pBV8y wPD/evKPzFPBWXS5apl2H0qjp00Uw+kLC/wlv1XDYLZ/+BW6uV9TDEz8KSPr9i+jd0lgrn q/9a9ase9H/VIUE6ZmkDWZr6RBhaPGzfXWma37ssvD7c1Lu+tHGbdZiNuploNg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976023; 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=gn8p+zMtjjrDzl8WaoyQn+U7cmDXCgk8UU3FdWlgcVs=; b=IV5GXmqv30WsdjaLssWUqwbUHWgEsyb8Y2Lk5LCM/xnsp5ZHKD4zFbZrnhqMuTkEm6CJyI K6bYpwodx7daw0Bg== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 10/37] platform-msi: Let the core code handle sysfs groups References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:22 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172025_039703_F5A01E04 X-CRM114-Status: GOOD ( 10.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Set the domain info flag and remove the local sysfs code. Signed-off-by: Thomas Gleixner --- drivers/base/platform-msi.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) --- a/drivers/base/platform-msi.c +++ b/drivers/base/platform-msi.c @@ -23,7 +23,6 @@ struct platform_msi_priv_data { struct device *dev; void *host_data; - const struct attribute_group **msi_irq_groups; msi_alloc_info_t arg; irq_write_msi_msg_t write_msg; int devid; @@ -191,6 +190,7 @@ struct irq_domain *platform_msi_create_i platform_msi_update_dom_ops(info); if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS) platform_msi_update_chip_ops(info); + info->flags |= MSI_FLAG_DEV_SYSFS; domain = msi_create_irq_domain(fwnode, info, parent); if (domain) @@ -279,16 +279,8 @@ int platform_msi_domain_alloc_irqs(struc if (err) goto out_free_desc; - priv_data->msi_irq_groups = msi_populate_sysfs(dev); - if (IS_ERR(priv_data->msi_irq_groups)) { - err = PTR_ERR(priv_data->msi_irq_groups); - goto out_free_irqs; - } - return 0; -out_free_irqs: - msi_domain_free_irqs(dev->msi.domain, dev); out_free_desc: platform_msi_free_descs(dev, 0, nvec); out_free_priv_data: @@ -308,7 +300,6 @@ void platform_msi_domain_free_irqs(struc struct msi_desc *desc; desc = first_msi_entry(dev); - msi_destroy_sysfs(dev, desc->platform.msi_priv_data->msi_irq_groups); platform_msi_free_priv_data(desc->platform.msi_priv_data); } From patchwork Sat Nov 27 01:20:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693795 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 3A194C433EF for ; Sat, 27 Nov 2021 01:30:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=ppWkhfICzlIG9vqAyNaCWQkxPfh313aadMjZps0j2Cs=; b=UVj6jqNDYT5Tb3 7JPb7+JnZoZSes45AEkhmXvSysYyOqKsgDbdPwrNdsTNmWocDFsSHvg7zFssti2rd/C1Kbg6SJYYl 9Ux6iw+VepHbQaWpHXEgOwrDfWVIBDfFbZy8WswUtkGh/Vskbu7BcrpOGbzQ088HKjl39MPHQmJaK aKw3cyRYa8hguVbBSHGbCqo5zv+t4dS7XxjCOAzj/gurrKnqtMu3WkrS7u5I/Cf10gQogy5eZCyPx yNu8MM83k41t8Z3wb3xVSkx90FtwFvYPyuhLIIcD0fSjGWpN7Z4/R166t2rQVj2CqctlaoqR4ds4Z HtAlH834UVHj3vJKNW3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmVy-00CErI-G9; Sat, 27 Nov 2021 01:28:31 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOA-00C9Kb-Ut for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:29 +0000 Message-ID: <20211126230524.600490756@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976025; 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=rnKORZE/4q0+dcWq5txOsnvSH8CsBB5Zw8/HocPRCso=; b=qS9f2NkK0r+z0LvL1ffdUS9y1b2C+JINxyh5UP9JUaDeY6E/gk5QARggKP8tASyvh7WAHK uKSx3IcQ4w62lyDAQU3WN7DKuXRvkAbRyJf515EEY96JIGudC49MgE4d1SLOlNiyNiI3cO /bx/sKu0dSlHMq7xqRFfFCc8FL4jAZMiCiTsnXuzFfc2lRvFJv26Wd+iK8hnckUseuxmsA DXLWJXAswomGH2z4c+rOvxNUwfFyD1TUJTQx1Myv9pLADZe4p42k4xxO+xTck+RUuxBUhc I3zdepkeBMxJil8A3xeFSEVuXowhQPmbvAuw9szDYTp9oAIm0t4ltlyagMr4zw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976025; 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=rnKORZE/4q0+dcWq5txOsnvSH8CsBB5Zw8/HocPRCso=; b=vhD3cmRCZH91LKAGRQEzR87rH9zcB4J0sfS6Lph75ZQBWWwci6udi8uV2PwOTRPb9ByuxQ gJmbrXCJzc5CZYAQ== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 11/37] genirq/msi: Remove the original sysfs interfaces References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:24 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172027_372228_1E51065C X-CRM114-Status: GOOD ( 14.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org No more users. Refactor the core code accordingly. Signed-off-by: Thomas Gleixner --- include/linux/msi.h | 12 ----------- kernel/irq/msi.c | 53 +++++++++++++++++++--------------------------------- 2 files changed, 20 insertions(+), 45 deletions(-) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -246,21 +246,9 @@ void pci_msi_unmask_irq(struct irq_data #ifdef CONFIG_SYSFS int msi_device_populate_sysfs(struct device *dev); void msi_device_destroy_sysfs(struct device *dev); - -const struct attribute_group **msi_populate_sysfs(struct device *dev); -void msi_destroy_sysfs(struct device *dev, - const struct attribute_group **msi_irq_groups); #else static inline int msi_device_populate_sysfs(struct device *dev) { return 0; } static inline void msi_device_destroy_sysfs(struct device *dev) { } - -static inline const struct attribute_group **msi_populate_sysfs(struct device *dev) -{ - return NULL; -} -static inline void msi_destroy_sysfs(struct device *dev, const struct attribute_group **msi_irq_groups) -{ -} #endif /* --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -132,12 +132,8 @@ static ssize_t msi_mode_show(struct devi /** * msi_populate_sysfs - Populate msi_irqs sysfs entries for devices * @dev: The device(PCI, platform etc) who will get sysfs entries - * - * Return attribute_group ** so that specific bus MSI can save it to - * somewhere during initilizing msi irqs. If devices has no MSI irq, - * return NULL; if it fails to populate sysfs, return ERR_PTR */ -const struct attribute_group **msi_populate_sysfs(struct device *dev) +static const struct attribute_group **msi_populate_sysfs(struct device *dev) { const struct attribute_group **msi_irq_groups; struct attribute **msi_attrs, *msi_attr; @@ -228,41 +224,32 @@ int msi_device_populate_sysfs(struct dev } /** - * msi_destroy_sysfs - Destroy msi_irqs sysfs entries for devices - * @dev: The device(PCI, platform etc) who will remove sysfs entries - * @msi_irq_groups: attribute_group for device msi_irqs entries - */ -void msi_destroy_sysfs(struct device *dev, const struct attribute_group **msi_irq_groups) -{ - struct device_attribute *dev_attr; - struct attribute **msi_attrs; - int count = 0; - - if (msi_irq_groups) { - sysfs_remove_groups(&dev->kobj, msi_irq_groups); - msi_attrs = msi_irq_groups[0]->attrs; - while (msi_attrs[count]) { - dev_attr = container_of(msi_attrs[count], - struct device_attribute, attr); - kfree(dev_attr->attr.name); - kfree(dev_attr); - ++count; - } - kfree(msi_attrs); - kfree(msi_irq_groups[0]); - kfree(msi_irq_groups); - } -} - -/** * msi_device_destroy_sysfs - Destroy msi_irqs sysfs entries for a device * @dev: The device(PCI, platform etc) for which to remove * sysfs entries */ void msi_device_destroy_sysfs(struct device *dev) { - msi_destroy_sysfs(dev, dev->msi.data->attrs); + const struct attribute_group **msi_irq_groups = dev->msi.data->attrs; + struct device_attribute *dev_attr; + struct attribute **msi_attrs; + int count = 0; + dev->msi.data->attrs = NULL; + if (!msi_irq_groups) + return; + + sysfs_remove_groups(&dev->kobj, msi_irq_groups); + msi_attrs = msi_irq_groups[0]->attrs; + while (msi_attrs[count]) { + dev_attr = container_of(msi_attrs[count], struct device_attribute, attr); + kfree(dev_attr->attr.name); + kfree(dev_attr); + ++count; + } + kfree(msi_attrs); + kfree(msi_irq_groups[0]); + kfree(msi_irq_groups); } #endif From patchwork Sat Nov 27 01:20:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693796 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 4AF84C433F5 for ; Sat, 27 Nov 2021 01:31:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=gHGmdeCMz9h9uDgCoxE/zOGQo9DwnXMjE6z3SG+J0BM=; b=iqRj/aUHFjjaZx 9k2L7bS472PlmqFnc2W14ucOKWORzOt5nfsDzFzF3fMrGGimOSmfoXPW7QrfWyCNolOnbf7CRDcoU M3XNu3S05NOatjNGKxHBxYy0KdsVqc+S7jcDDDi2c9qrFpUzx89IbceefU56bmRiWeFl13DqJcGGa nh3FLKfPBQm4Ywkp9OTYWMncmdQSROEWQvJLTIkTB0r/ltMy7F8qjr/i35kA50slAOY4dVD43Rqh6 TIAOnyVH3kEABWK7+BkSBSdaXA4i4ztYoPCh5PcuL1xwRG4TN/BG46Nd6yhbkaLRTHI/MUjJDzB7p lyUlrQvnR+WLwoMAXQgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmWi-00CFEp-6u; Sat, 27 Nov 2021 01:29:18 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOC-00C9N0-Uj for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:32 +0000 Message-ID: <20211126230524.661169696@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976027; 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=7645zM4jmr/sh6ufNFcrhF4sFIscYYINKeWaqJ1fetg=; b=IAGZg4nEuFV633zEHMYdJKOCg7bgw4YrAVFNJUrjZ6yJK/gpmDGk25/L6OOkCASCsXASNR WoD0h5u+OkB6oI/XU2UslSdkC5mxlRUYlai18Q/3KTqR9slgbNpd932hDu5FcUUAI4ThFu cuwZfRXgRESttb7cVw2IXItRIM7pgioliIXIAVKEuqUCTZmL1AeWTuVEoMBvJw8RGu0ZjL kEsObjfMyWDDaBJfcV9gZO4y6DiXQ/wZkSUrZVV5vbRKvgYcPUDoyA5QtEQYfd4VYZF18y MoKnB6dtm645MX86nUSGcnIC+S81YOgtr3B1CzkN6tsKsdahgnK2wNKN+SXUBQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976027; 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=7645zM4jmr/sh6ufNFcrhF4sFIscYYINKeWaqJ1fetg=; b=TLo9yqN9MqnxrgYUmD761QTMbiItfPBJoAiz5YYue8yjXytxOqW2NlXOECM+lmVUFx2gew elfrS7MJTlOqQCBg== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 12/37] platform-msi: Rename functions and clarify comments References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:26 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172029_425255_DC186551 X-CRM114-Status: GOOD ( 18.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org It's hard to distinguish what platform_msi_domain_alloc() and platform_msi_domain_alloc_irqs() are about. Make the distinction more explicit and add comments which explain the use cases properly. Signed-off-by: Thomas Gleixner --- drivers/base/platform-msi.c | 36 +++++++++++++++++++++--------------- drivers/irqchip/irq-mbigen.c | 4 ++-- drivers/irqchip/irq-mvebu-icu.c | 6 +++--- include/linux/msi.h | 8 ++++---- 4 files changed, 30 insertions(+), 24 deletions(-) --- a/drivers/base/platform-msi.c +++ b/drivers/base/platform-msi.c @@ -313,17 +313,18 @@ EXPORT_SYMBOL_GPL(platform_msi_domain_fr * a platform-msi domain * @domain: The platform-msi domain * - * Returns the private data provided when calling - * platform_msi_create_device_domain. + * Return: The private data provided when calling + * platform_msi_create_device_domain(). */ void *platform_msi_get_host_data(struct irq_domain *domain) { struct platform_msi_priv_data *data = domain->host_data; + return data->host_data; } /** - * __platform_msi_create_device_domain - Create a platform-msi domain + * __platform_msi_create_device_domain - Create a platform-msi device domain * * @dev: The device generating the MSIs * @nvec: The number of MSIs that need to be allocated @@ -332,7 +333,11 @@ void *platform_msi_get_host_data(struct * @ops: The hierarchy domain operations to use * @host_data: Private data associated to this domain * - * Returns an irqdomain for @nvec interrupts + * Return: An irqdomain for @nvec interrupts on success, NULL in case of error. + * + * This is for interrupt domains which stack on a platform-msi domain + * created by platform_msi_create_irq_domain(). @dev->msi.domain points to + * that platform-msi domain which is the parent for the new domain. */ struct irq_domain * __platform_msi_create_device_domain(struct device *dev, @@ -372,18 +377,19 @@ struct irq_domain * } /** - * platform_msi_domain_free - Free interrupts associated with a platform-msi - * domain + * platform_msi_device_domain_free - Free interrupts associated with a platform-msi + * device domain * - * @domain: The platform-msi domain + * @domain: The platform-msi device domain * @virq: The base irq from which to perform the free operation * @nvec: How many interrupts to free from @virq */ -void platform_msi_domain_free(struct irq_domain *domain, unsigned int virq, - unsigned int nvec) +void platform_msi_device_domain_free(struct irq_domain *domain, unsigned int virq, + unsigned int nvec) { struct platform_msi_priv_data *data = domain->host_data; struct msi_desc *desc, *tmp; + for_each_msi_entry_safe(desc, tmp, data->dev) { if (WARN_ON(!desc->irq || desc->nvec_used != 1)) return; @@ -397,10 +403,10 @@ void platform_msi_domain_free(struct irq } /** - * platform_msi_domain_alloc - Allocate interrupts associated with - * a platform-msi domain + * platform_msi_device_domain_alloc - Allocate interrupts associated with + * a platform-msi device domain * - * @domain: The platform-msi domain + * @domain: The platform-msi device domain * @virq: The base irq from which to perform the allocate operation * @nr_irqs: How many interrupts to free from @virq * @@ -408,8 +414,8 @@ void platform_msi_domain_free(struct irq * with irq_domain_mutex held (which can only be done as part of a * top-level interrupt allocation). */ -int platform_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, - unsigned int nr_irqs) +int platform_msi_device_domain_alloc(struct irq_domain *domain, unsigned int virq, + unsigned int nr_irqs) { struct platform_msi_priv_data *data = domain->host_data; int err; @@ -421,7 +427,7 @@ int platform_msi_domain_alloc(struct irq err = msi_domain_populate_irqs(domain->parent, data->dev, virq, nr_irqs, &data->arg); if (err) - platform_msi_domain_free(domain, virq, nr_irqs); + platform_msi_device_domain_free(domain, virq, nr_irqs); return err; } --- a/drivers/irqchip/irq-mbigen.c +++ b/drivers/irqchip/irq-mbigen.c @@ -207,7 +207,7 @@ static int mbigen_irq_domain_alloc(struc if (err) return err; - err = platform_msi_domain_alloc(domain, virq, nr_irqs); + err = platform_msi_device_domain_alloc(domain, virq, nr_irqs); if (err) return err; @@ -223,7 +223,7 @@ static int mbigen_irq_domain_alloc(struc static void mbigen_irq_domain_free(struct irq_domain *domain, unsigned int virq, unsigned int nr_irqs) { - platform_msi_domain_free(domain, virq, nr_irqs); + platform_msi_device_domain_free(domain, virq, nr_irqs); } static const struct irq_domain_ops mbigen_domain_ops = { --- a/drivers/irqchip/irq-mvebu-icu.c +++ b/drivers/irqchip/irq-mvebu-icu.c @@ -221,7 +221,7 @@ mvebu_icu_irq_domain_alloc(struct irq_do icu_irqd->icu_group = msi_data->subset_data->icu_group; icu_irqd->icu = icu; - err = platform_msi_domain_alloc(domain, virq, nr_irqs); + err = platform_msi_device_domain_alloc(domain, virq, nr_irqs); if (err) { dev_err(icu->dev, "failed to allocate ICU interrupt in parent domain\n"); goto free_irqd; @@ -245,7 +245,7 @@ mvebu_icu_irq_domain_alloc(struct irq_do return 0; free_msi: - platform_msi_domain_free(domain, virq, nr_irqs); + platform_msi_device_domain_free(domain, virq, nr_irqs); free_irqd: kfree(icu_irqd); return err; @@ -260,7 +260,7 @@ mvebu_icu_irq_domain_free(struct irq_dom kfree(icu_irqd); - platform_msi_domain_free(domain, virq, nr_irqs); + platform_msi_device_domain_free(domain, virq, nr_irqs); } static const struct irq_domain_ops mvebu_icu_domain_ops = { --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -432,10 +432,10 @@ struct irq_domain * #define platform_msi_create_device_tree_domain(dev, nvec, write, ops, data) \ __platform_msi_create_device_domain(dev, nvec, true, write, ops, data) -int platform_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, - unsigned int nr_irqs); -void platform_msi_domain_free(struct irq_domain *domain, unsigned int virq, - unsigned int nvec); +int platform_msi_device_domain_alloc(struct irq_domain *domain, unsigned int virq, + unsigned int nr_irqs); +void platform_msi_device_domain_free(struct irq_domain *domain, unsigned int virq, + unsigned int nvec); void *platform_msi_get_host_data(struct irq_domain *domain); #endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */ From patchwork Sat Nov 27 01:20:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693797 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 2B677C433EF for ; Sat, 27 Nov 2021 01:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=V8aiK5QtsswfPr4Id/eH6xYH2T3K8iU5M34B5XscF2I=; b=TFiNOt490JBckU 0Ycm6Zs+k82j435mSMjelAzBHwZ7zRsK5b2KhfvWiOwQ+2QH626yXMI5d63ureWbesXgn0KxOKA2g pmpbKzao1YEiBU4HEy7Am/P4QdLMqw4myvWjbU9xv6bcbMS9UDbOn9a2uZ1mrx7YSCRX1+5Y34kSG Mc1psDRJL/RugDhvv6JgdseMb/09F6nv6L6ZvynXHlz3YPpYzc3j/k6fINsl9VKYCTtmEqoc+IJIE ZF7A9cqNv7d43cT8onWTd8MpGZB8k94x5V0pRNVljVd6GGF5/KT7cx4WeAp9kEaXNMBawY75gJL9R wpFmkCIGGboZkmYyPbmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmXl-00CFmd-8l; Sat, 27 Nov 2021 01:30:22 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOE-00C9OG-Aj for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:34 +0000 Message-ID: <20211126230524.720574009@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976028; 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=AKZi5uNn4XVDZLoHv4Jql/2maJ3KbTWq3QeKTKNmToU=; b=tQVdRbr8D6QOJfSIL8hZc7D5jXtRi+sY2QGiJD8gR42VHfMeEqDEapCs/fw/GTwnDQINbv zmmukl2GtKQHqATBHyMgD/6/2dD88XZO3ahEUZclvxVnBWsDW3uUc4FC2Nj557AcFJIpQT MuBv5WqltOx1wX2ySEqJTC+ZEoF7SdT3DBaSzqLh4mab4k3SycwC66EhJ5lCoT2o8IZY0s iTNkYe96JQP86SeKQNml0k29YzeEH91Cz2hc7UXYq55jYwD65/mmljwUA/oMjimkLSC9yf 3Xp3rTSpB4spMaUdCw0TRdxgFxrswx4ggfR/QtWlQJMSvk1r1BwgNolCYoripQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976028; 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=AKZi5uNn4XVDZLoHv4Jql/2maJ3KbTWq3QeKTKNmToU=; b=+rNYfW2aRjdFV180ENWsip3NhnsSxMlLC7uqJRcxqbePjtqvf1Rb3Arh4z/ia+5zCnztsJ LYl8MG+mhSXFAyDg== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 13/37] platform-msi: Store platform private data pointer in msi_device_data References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:27 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172030_735581_4DA57B4E X-CRM114-Status: GOOD ( 19.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Storing the platform private data in a MSI descriptor is sloppy at best. The data belongs to the device and not to the descriptor. Add a pointer to struct msi_device_data and store the pointer there. Signed-off-by: Thomas Gleixner --- drivers/base/platform-msi.c | 79 +++++++++++++++++--------------------------- include/linux/msi.h | 5 +- 2 files changed, 35 insertions(+), 49 deletions(-) --- a/drivers/base/platform-msi.c +++ b/drivers/base/platform-msi.c @@ -38,9 +38,7 @@ static DEFINE_IDA(platform_msi_devid_ida */ static irq_hw_number_t platform_msi_calc_hwirq(struct msi_desc *desc) { - u32 devid; - - devid = desc->platform.msi_priv_data->devid; + u32 devid = desc->dev->msi.data->platform_data->devid; return (devid << (32 - DEV_ID_SHIFT)) | desc->platform.msi_index; } @@ -85,11 +83,8 @@ static void platform_msi_update_dom_ops( static void platform_msi_write_msg(struct irq_data *data, struct msi_msg *msg) { struct msi_desc *desc = irq_data_get_msi_desc(data); - struct platform_msi_priv_data *priv_data; - - priv_data = desc->platform.msi_priv_data; - priv_data->write_msg(desc, msg); + desc->dev->msi.data->platform_data->write_msg(desc, msg); } static void platform_msi_update_chip_ops(struct msi_domain_info *info) @@ -126,9 +121,7 @@ static void platform_msi_free_descs(stru } static int platform_msi_alloc_descs_with_irq(struct device *dev, int virq, - int nvec, - struct platform_msi_priv_data *data) - + int nvec) { struct msi_desc *desc; int i, base = 0; @@ -144,7 +137,6 @@ static int platform_msi_alloc_descs_with if (!desc) break; - desc->platform.msi_priv_data = data; desc->platform.msi_index = base + i; desc->irq = virq ? virq + i : 0; @@ -161,11 +153,9 @@ static int platform_msi_alloc_descs_with return 0; } -static int platform_msi_alloc_descs(struct device *dev, int nvec, - struct platform_msi_priv_data *data) - +static int platform_msi_alloc_descs(struct device *dev, int nvec) { - return platform_msi_alloc_descs_with_irq(dev, 0, nvec, data); + return platform_msi_alloc_descs_with_irq(dev, 0, nvec); } /** @@ -199,9 +189,8 @@ struct irq_domain *platform_msi_create_i return domain; } -static struct platform_msi_priv_data * -platform_msi_alloc_priv_data(struct device *dev, unsigned int nvec, - irq_write_msi_msg_t write_msi_msg) +static int platform_msi_alloc_priv_data(struct device *dev, unsigned int nvec, + irq_write_msi_msg_t write_msi_msg) { struct platform_msi_priv_data *datap; int err; @@ -213,41 +202,44 @@ platform_msi_alloc_priv_data(struct devi * capable devices). */ if (!dev->msi.domain || !write_msi_msg || !nvec || nvec > MAX_DEV_MSIS) - return ERR_PTR(-EINVAL); + return -EINVAL; if (dev->msi.domain->bus_token != DOMAIN_BUS_PLATFORM_MSI) { dev_err(dev, "Incompatible msi_domain, giving up\n"); - return ERR_PTR(-EINVAL); + return -EINVAL; } err = msi_setup_device_data(dev); if (err) - return ERR_PTR(err); + return err; - /* Already had a helping of MSI? Greed... */ - if (!list_empty(dev_to_msi_list(dev))) - return ERR_PTR(-EBUSY); + /* Already initialized? */ + if (dev->msi.data->platform_data) + return -EBUSY; datap = kzalloc(sizeof(*datap), GFP_KERNEL); if (!datap) - return ERR_PTR(-ENOMEM); + return -ENOMEM; datap->devid = ida_simple_get(&platform_msi_devid_ida, 0, 1 << DEV_ID_SHIFT, GFP_KERNEL); if (datap->devid < 0) { err = datap->devid; kfree(datap); - return ERR_PTR(err); + return err; } datap->write_msg = write_msi_msg; datap->dev = dev; - - return datap; + dev->msi.data->platform_data = datap; + return 0; } -static void platform_msi_free_priv_data(struct platform_msi_priv_data *data) +static void platform_msi_free_priv_data(struct device *dev) { + struct platform_msi_priv_data *data = dev->msi.data->platform_data; + + dev->msi.data->platform_data = NULL; ida_simple_remove(&platform_msi_devid_ida, data->devid); kfree(data); } @@ -264,14 +256,13 @@ static void platform_msi_free_priv_data( int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec, irq_write_msi_msg_t write_msi_msg) { - struct platform_msi_priv_data *priv_data; int err; - priv_data = platform_msi_alloc_priv_data(dev, nvec, write_msi_msg); - if (IS_ERR(priv_data)) - return PTR_ERR(priv_data); + err = platform_msi_alloc_priv_data(dev, nvec, write_msi_msg); + if (err) + return err; - err = platform_msi_alloc_descs(dev, nvec, priv_data); + err = platform_msi_alloc_descs(dev, nvec); if (err) goto out_free_priv_data; @@ -284,8 +275,7 @@ int platform_msi_domain_alloc_irqs(struc out_free_desc: platform_msi_free_descs(dev, 0, nvec); out_free_priv_data: - platform_msi_free_priv_data(priv_data); - + platform_msi_free_priv_data(dev); return err; } EXPORT_SYMBOL_GPL(platform_msi_domain_alloc_irqs); @@ -296,15 +286,9 @@ EXPORT_SYMBOL_GPL(platform_msi_domain_al */ void platform_msi_domain_free_irqs(struct device *dev) { - if (!list_empty(dev_to_msi_list(dev))) { - struct msi_desc *desc; - - desc = first_msi_entry(dev); - platform_msi_free_priv_data(desc->platform.msi_priv_data); - } - msi_domain_free_irqs(dev->msi.domain, dev); platform_msi_free_descs(dev, 0, MAX_DEV_MSIS); + platform_msi_free_priv_data(dev); } EXPORT_SYMBOL_GPL(platform_msi_domain_free_irqs); @@ -351,10 +335,11 @@ struct irq_domain * struct irq_domain *domain; int err; - data = platform_msi_alloc_priv_data(dev, nvec, write_msi_msg); - if (IS_ERR(data)) + err = platform_msi_alloc_priv_data(dev, nvec, write_msi_msg); + if (err) return NULL; + data = dev->msi.data->platform_data; data->host_data = host_data; domain = irq_domain_create_hierarchy(dev->msi.domain, 0, is_tree ? 0 : nvec, @@ -372,7 +357,7 @@ struct irq_domain * free_domain: irq_domain_remove(domain); free_priv: - platform_msi_free_priv_data(data); + platform_msi_free_priv_data(dev); return NULL; } @@ -420,7 +405,7 @@ int platform_msi_device_domain_alloc(str struct platform_msi_priv_data *data = domain->host_data; int err; - err = platform_msi_alloc_descs_with_irq(data->dev, virq, nr_irqs, data); + err = platform_msi_alloc_descs_with_irq(data->dev, virq, nr_irqs); if (err) return err; --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -56,6 +56,7 @@ struct irq_data; struct msi_desc; struct pci_dev; struct platform_msi_priv_data; + void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg); #ifdef CONFIG_GENERIC_MSI_IRQ void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg); @@ -106,11 +107,9 @@ struct pci_msi_desc { /** * platform_msi_desc - Platform device specific msi descriptor data - * @msi_priv_data: Pointer to platform private data * @msi_index: The index of the MSI descriptor for multi MSI */ struct platform_msi_desc { - struct platform_msi_priv_data *msi_priv_data; u16 msi_index; }; @@ -175,10 +174,12 @@ struct msi_desc { * msi_device_data - MSI per device data * @lock: Spinlock to protect register access * @attrs: Pointer to the sysfs attribute group + * @platform_data: Platform-MSI specific data */ struct msi_device_data { raw_spinlock_t lock; const struct attribute_group **attrs; + struct platform_msi_priv_data *platform_data; }; int msi_setup_device_data(struct device *dev); From patchwork Sat Nov 27 01:20:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693798 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 3D2D5C433F5 for ; Sat, 27 Nov 2021 01:33:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=c5vXQQpa0nY+Tjd0H+BDBKulH+lIICURhzOftTlo3zY=; b=W4ibuRfgjcZ9W6 178TkmNEoVYCOldIiaqeRiB+ZFrKyiBN9a8VksYCp2kUG34McayjpDEuRMGn8o2woEYGWH3aWGvdk l4b/eaIAasdL99O9PvEYcXv7irq3I8A17v/DsX6Dys+TqDt3od96XhKi4ovGA/AYODbCTualyS773 3DWWomcj99BWwR4ZXVpxRhnwzX4KiQr1Un/PAjhSWsmCLoEjarzruF9QoI83sIjpcvlxUrGQOd17W EqQv/Okkh9k/U4eeYv+5HL5bW/XimPd7eLy+Pz7teKTGGEHzEL+jq/9sd4wC32rpI64o0J50KGdax x339tjVhs5zLzxlXxizQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmYn-00CGDf-De; Sat, 27 Nov 2021 01:31:26 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOF-00C9QL-Jj for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:35 +0000 Message-ID: <20211126230524.778704986@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976030; 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=Ehi/wwF9q+UnZyXX27wliNOB9+x0r0rx0yUOBA3VcWA=; b=VTMtOkbqzmfdwZwSBeV1FD5w52HS+b6Mgrcwr6QflvuBj7vnE4RYJ5rfk7qUTp+bji6JcK cVF5asbiqIvHDtduDdJIVLWmIVbgaq4ZDaKaXvzsESAoYczDrJm1r9uU84ox0DXw2hgOWd v12BvM3GjC7FmjS2O5X26UVGzu4p++bPBOdwcy6pkI7nqcz9nxHWnLNfIWc36CYE5KfXcz ZHui/U+6dWfSZPfPp2tCvzujaLDyunWyL/85kPslmw2e9t7h551TfehRds9qz8pHN4Zasp Nl+4uuqVBbimdRkb8y6iysOMYBA7U92UU3CXWyKlYGoqa9HtUT7oEixfcn037w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976030; 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=Ehi/wwF9q+UnZyXX27wliNOB9+x0r0rx0yUOBA3VcWA=; b=i6NWrHDPAtxe6JmljqOrt1HMZj0MXlU06z+oRNVp0rjhliRvqguewklbZVYvPlSgSsUf7Q tlJFP458IFEstdCg== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 14/37] genirq/msi: Consolidate MSI descriptor data References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:29 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172031_872623_D8A99C29 X-CRM114-Status: UNSURE ( 8.33 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org All non PCI/MSI usage variants have data structures in struct msi_desc with only one member: xxx_index. PCI/MSI has a entry_nr member. Add a common msi_index member to struct msi_desc so all implementations can share it which allows further consolidation. Signed-off-by: Thomas Gleixner --- include/linux/msi.h | 2 ++ 1 file changed, 2 insertions(+) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -142,6 +142,7 @@ struct ti_sci_inta_msi_desc { * address or data changes * @write_msi_msg_data: Data parameter for the callback. * + * @msi_index: Index of the msi descriptor * @pci: [PCI] PCI speficic msi descriptor data * @platform: [platform] Platform device specific msi descriptor data * @fsl_mc: [fsl-mc] FSL MC device specific msi descriptor data @@ -162,6 +163,7 @@ struct msi_desc { void (*write_msi_msg)(struct msi_desc *entry, void *data); void *write_msi_msg_data; + u16 msi_index; union { struct pci_msi_desc pci; struct platform_msi_desc platform; From patchwork Sat Nov 27 01:20:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693799 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 3CBDAC433EF for ; Sat, 27 Nov 2021 01:34:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=UIxhHHZMu6CUrnmUx5DB9YYsamsY6y7K42hlTLJyvWU=; b=FvpV7ajz1ZbPcd sBz84baoCG1aDIreitYvcv1h2z12LO9kpT8W8jKRgYbEafT+JJAbB8BqhIwsyqsUWeCCDU+Vj749C 2G5Fsg/f7TtJI+Md52qz9qCzbuYDnd1rHgIyJWoicXgbCvgGs9nuizgknrLPP4D3cvTsTyiUnMzXQ REMHht0ZHiboJAIMkbZ91VI5u96AAgVJ358SsYc9tsot6g5Kx+dMnw7qOoY+YXstZ+3sJD6+L90Nk uA2/4dLP2xe6s1CuEa+XO40fHVIf4dijJMyNaFLaB54VZwVNlhGl0TrHaXggIdlWC6csnJ1TCaQNF 7pokzGcUWwMJcwgBC65Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmZo-00CGlx-Ad; Sat, 27 Nov 2021 01:32:29 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOH-00C9SJ-F3 for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:38 +0000 Message-ID: <20211126230524.836079461@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976031; 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=TCpLcJcKEr9vQJAndSlgt6Zl+zwocNthK8EqW5mdPdk=; b=jP5X4l7kLg2AMlPJYjk5rNAqGFWQHX3vrdY0+dGkHM2zsOY1qY2YQsYrfjHod9ulrnFZ4X mZDcFc2ru0rjXYteS60KTiF9wQZsaKD9v211D6U6oByb8eAqALTodKr+jtTAVfNdkV6ewG IO8f45/DNU0dL9I2u+JfMdhiuIzGEQW1mNsxTs7Gwmg2SWHSsVeyHHjxTzJjVXijKTu06M RK5MnXwO/AwLtNASoDja9CtJEvA5ug6hLmk+eMF+SARn34kK5byvSLLAt64N8TGpNqKf4A isqBw+gLoswggcFJnMid1XUFlnoFVmYSlbOBEFbh9OLwTcn2x2qvqQWKRisUhA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976031; 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=TCpLcJcKEr9vQJAndSlgt6Zl+zwocNthK8EqW5mdPdk=; b=rEniIYDkqiWz6b7vEEs0HJ3VnmpiJxp6MDGcjuEuTT8XfRgD95TxnHcUNrszKBwZ1FvCZr vrhbVeQOoFcSR+BA== 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, Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Santosh Shilimkar , Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 15/37] platform-msi: Use msi_desc::msi_index References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:31 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172033_910938_4EB30D2D X-CRM114-Status: GOOD ( 17.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the common msi_index member and get rid of the pointless wrapper struct. Signed-off-by: Thomas Gleixner Cc: linux-arm-kernel@lists.infradead.org Cc: iommu@lists.linux-foundation.org Cc: dmaengine@vger.kernel.org --- drivers/base/platform-msi.c | 10 +++++----- drivers/dma/qcom/hidma.c | 4 ++-- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 4 ++-- drivers/mailbox/bcm-flexrm-mailbox.c | 4 ++-- include/linux/msi.h | 10 ---------- 5 files changed, 11 insertions(+), 21 deletions(-) --- a/drivers/base/platform-msi.c +++ b/drivers/base/platform-msi.c @@ -40,7 +40,7 @@ static irq_hw_number_t platform_msi_calc { u32 devid = desc->dev->msi.data->platform_data->devid; - return (devid << (32 - DEV_ID_SHIFT)) | desc->platform.msi_index; + return (devid << (32 - DEV_ID_SHIFT)) | desc->msi_index; } static void platform_msi_set_desc(msi_alloc_info_t *arg, struct msi_desc *desc) @@ -112,8 +112,8 @@ static void platform_msi_free_descs(stru struct msi_desc *desc, *tmp; list_for_each_entry_safe(desc, tmp, dev_to_msi_list(dev), list) { - if (desc->platform.msi_index >= base && - desc->platform.msi_index < (base + nvec)) { + if (desc->msi_index >= base && + desc->msi_index < (base + nvec)) { list_del(&desc->list); free_msi_entry(desc); } @@ -129,7 +129,7 @@ static int platform_msi_alloc_descs_with if (!list_empty(dev_to_msi_list(dev))) { desc = list_last_entry(dev_to_msi_list(dev), struct msi_desc, list); - base = desc->platform.msi_index + 1; + base = desc->msi_index + 1; } for (i = 0; i < nvec; i++) { @@ -137,7 +137,7 @@ static int platform_msi_alloc_descs_with if (!desc) break; - desc->platform.msi_index = base + i; + desc->msi_index = base + i; desc->irq = virq ? virq + i : 0; list_add_tail(&desc->list, dev_to_msi_list(dev)); --- a/drivers/dma/qcom/hidma.c +++ b/drivers/dma/qcom/hidma.c @@ -666,7 +666,7 @@ static void hidma_write_msi_msg(struct m struct device *dev = msi_desc_to_dev(desc); struct hidma_dev *dmadev = dev_get_drvdata(dev); - if (!desc->platform.msi_index) { + if (!desc->msi_index) { writel(msg->address_lo, dmadev->dev_evca + 0x118); writel(msg->address_hi, dmadev->dev_evca + 0x11C); writel(msg->data, dmadev->dev_evca + 0x120); @@ -702,7 +702,7 @@ static int hidma_request_msi(struct hidm return rc; for_each_msi_entry(desc, &pdev->dev) { - if (!desc->platform.msi_index) + if (!desc->msi_index) dmadev->msi_virqbase = desc->irq; rc = devm_request_irq(&pdev->dev, desc->irq, --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3142,7 +3142,7 @@ static void arm_smmu_write_msi_msg(struc phys_addr_t doorbell; struct device *dev = msi_desc_to_dev(desc); struct arm_smmu_device *smmu = dev_get_drvdata(dev); - phys_addr_t *cfg = arm_smmu_msi_cfg[desc->platform.msi_index]; + phys_addr_t *cfg = arm_smmu_msi_cfg[desc->msi_index]; doorbell = (((u64)msg->address_hi) << 32) | msg->address_lo; doorbell &= MSI_CFG0_ADDR_MASK; @@ -3183,7 +3183,7 @@ static void arm_smmu_setup_msis(struct a } for_each_msi_entry(desc, dev) { - switch (desc->platform.msi_index) { + switch (desc->msi_index) { case EVTQ_MSI_INDEX: smmu->evtq.q.irq = desc->irq; break; --- a/drivers/mailbox/bcm-flexrm-mailbox.c +++ b/drivers/mailbox/bcm-flexrm-mailbox.c @@ -1484,7 +1484,7 @@ static void flexrm_mbox_msi_write(struct { struct device *dev = msi_desc_to_dev(desc); struct flexrm_mbox *mbox = dev_get_drvdata(dev); - struct flexrm_ring *ring = &mbox->rings[desc->platform.msi_index]; + struct flexrm_ring *ring = &mbox->rings[desc->msi_index]; /* Configure per-Ring MSI registers */ writel_relaxed(msg->address_lo, ring->regs + RING_MSI_ADDR_LS); @@ -1609,7 +1609,7 @@ static int flexrm_mbox_probe(struct plat /* Save alloced IRQ numbers for each ring */ for_each_msi_entry(desc, dev) { - ring = &mbox->rings[desc->platform.msi_index]; + ring = &mbox->rings[desc->msi_index]; ring->irq = desc->irq; } --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -106,14 +106,6 @@ struct pci_msi_desc { }; /** - * platform_msi_desc - Platform device specific msi descriptor data - * @msi_index: The index of the MSI descriptor for multi MSI - */ -struct platform_msi_desc { - u16 msi_index; -}; - -/** * fsl_mc_msi_desc - FSL-MC device specific msi descriptor data * @msi_index: The index of the MSI descriptor */ @@ -144,7 +136,6 @@ struct ti_sci_inta_msi_desc { * * @msi_index: Index of the msi descriptor * @pci: [PCI] PCI speficic msi descriptor data - * @platform: [platform] Platform device specific msi descriptor data * @fsl_mc: [fsl-mc] FSL MC device specific msi descriptor data * @inta: [INTA] TISCI based INTA specific msi descriptor data */ @@ -166,7 +157,6 @@ struct msi_desc { u16 msi_index; union { struct pci_msi_desc pci; - struct platform_msi_desc platform; struct fsl_mc_msi_desc fsl_mc; struct ti_sci_inta_msi_desc inta; }; From patchwork Sat Nov 27 01:20:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693800 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 EDCDBC433F5 for ; Sat, 27 Nov 2021 01:35:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=uzmY0L0GLPmX3A8bp8Zxt1A2z703AHWZ+jD5jLLMRuE=; b=I8qag6IUlgu43p LwULzJ77sU/xhTQwlNQJVB4MPEL0KKDCOgOP/dIeehKJP3fSzKOTtv6GEpc4p4DoBlYFHVLzVtP0C 5vDGp0Zs//AQaLaLKZyueTZLpYmxyYZSTgamyaZuH9i6Lr6nkCrqmOGfwZl9197htUw3px0OMjFC8 00bR7U6O8dsL0ZUbnI3mJ7FY53mZq6CdOy+mTXH7WKpnMeW/0OHW9OpNd24DhnhjjwWTZexj4IeaT E91dtlSms+bcvhUZ4v3YKuiKXpGmGRuQkpzX/+696/FAu1JI5BpoRTBzmBUYEiC1J2dYQEt4Y8fmb J1b5Ed+DBeuU+0xKNOYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmb0-00CHPx-Ms; Sat, 27 Nov 2021 01:33:43 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOI-00C9Ta-JQ for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:40 +0000 Message-ID: <20211126230524.897737278@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976033; 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=bB22Fj84OnFrRIG/bs67IiQdK7QkbC0Kd4+++76cDFQ=; b=dnyi6ZGO5rvUA2htl5juh5Q0my/6XQ4KZE0zQIoraFHvn5942Q98AvWmlactqt7BB9KHfX Sk/HHpNEqzO7fHqwqGmCI1Y4T42TM2DciedPwCnVobY8BwhOlVhpqp1WwyFzt17NaZ1v8K C2CI2q7A0L1Ri4/rRS2Yr+Z0u9QWUlewg7P9KfraUYNPRsBtc9gvDMpBokDzpaxU3PJg89 NeIUt1Z8bFTe0VWXLo4dMOt7od7lI7yG//10uohdINn4dl3Fbz719otFbCzhXcAkUVTNvN 1xeyMMcHfxL2bZlxsX8P3zeEowT/7MR3VVeaajYZ+tNjMG9SnluHwkTcZATNsw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976033; 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=bB22Fj84OnFrRIG/bs67IiQdK7QkbC0Kd4+++76cDFQ=; b=arnwtnXDSvpjG4t/Su03L3GWt+QLXvNHlG9AI/6oGMQu6t/37MW+YaEkYtrOWKzumSdZvi GxNFZXOrvRlXzmDg== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 16/37] bus: fsl-mc-msi: Use msi_desc::msi_index References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:32 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172034_860473_33474792 X-CRM114-Status: GOOD ( 13.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the common msi_index member and get rid of the pointless wrapper struct. Signed-off-by: Thomas Gleixner --- drivers/bus/fsl-mc/fsl-mc-allocator.c | 2 +- drivers/bus/fsl-mc/fsl-mc-msi.c | 6 +++--- include/linux/msi.h | 10 ---------- 3 files changed, 4 insertions(+), 14 deletions(-) --- a/drivers/bus/fsl-mc/fsl-mc-allocator.c +++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c @@ -393,7 +393,7 @@ int fsl_mc_populate_irq_pool(struct fsl_ } for_each_msi_entry(msi_desc, &mc_bus_dev->dev) { - mc_dev_irq = &irq_resources[msi_desc->fsl_mc.msi_index]; + mc_dev_irq = &irq_resources[msi_desc->msi_index]; mc_dev_irq->msi_desc = msi_desc; mc_dev_irq->resource.id = msi_desc->irq; } --- a/drivers/bus/fsl-mc/fsl-mc-msi.c +++ b/drivers/bus/fsl-mc/fsl-mc-msi.c @@ -29,7 +29,7 @@ static irq_hw_number_t fsl_mc_domain_cal * Make the base hwirq value for ICID*10000 so it is readable * as a decimal value in /proc/interrupts. */ - return (irq_hw_number_t)(desc->fsl_mc.msi_index + (dev->icid * 10000)); + return (irq_hw_number_t)(desc->msi_index + (dev->icid * 10000)); } static void fsl_mc_msi_set_desc(msi_alloc_info_t *arg, @@ -122,7 +122,7 @@ static void fsl_mc_msi_write_msg(struct struct fsl_mc_device *mc_bus_dev = to_fsl_mc_device(msi_desc->dev); struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev); struct fsl_mc_device_irq *mc_dev_irq = - &mc_bus->irq_resources[msi_desc->fsl_mc.msi_index]; + &mc_bus->irq_resources[msi_desc->msi_index]; msi_desc->msg = *msg; @@ -235,7 +235,7 @@ static int fsl_mc_msi_alloc_descs(struct goto cleanup_msi_descs; } - msi_desc->fsl_mc.msi_index = i; + msi_desc->msi_index = i; INIT_LIST_HEAD(&msi_desc->list); list_add_tail(&msi_desc->list, dev_to_msi_list(dev)); } --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -106,14 +106,6 @@ struct pci_msi_desc { }; /** - * fsl_mc_msi_desc - FSL-MC device specific msi descriptor data - * @msi_index: The index of the MSI descriptor - */ -struct fsl_mc_msi_desc { - u16 msi_index; -}; - -/** * ti_sci_inta_msi_desc - TISCI based INTA specific msi descriptor data * @dev_index: TISCI device index */ @@ -136,7 +128,6 @@ struct ti_sci_inta_msi_desc { * * @msi_index: Index of the msi descriptor * @pci: [PCI] PCI speficic msi descriptor data - * @fsl_mc: [fsl-mc] FSL MC device specific msi descriptor data * @inta: [INTA] TISCI based INTA specific msi descriptor data */ struct msi_desc { @@ -157,7 +148,6 @@ struct msi_desc { u16 msi_index; union { struct pci_msi_desc pci; - struct fsl_mc_msi_desc fsl_mc; struct ti_sci_inta_msi_desc inta; }; }; From patchwork Sat Nov 27 01:20:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693801 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 C3A41C433F5 for ; Sat, 27 Nov 2021 01:36:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=ctMGXWMx7k6XURChhgxHEUIFaNpAJXUU4Uucd9WjIMA=; b=xBGF2H4WJkiWgK KRZgzDSG/a+5zqxhfwvXrv2ZtyLB6eqfybLFD4hBLKodL3mcwMGY5FShE3GS/qm6/OLrxXY2gUw0/ 0TbpInLKVgB7NYEf7ihZE7MRr3CiBmxj5kRMuDKPdTQxGa71uRb4CG2j6ea+azrHDnyIxxRStPPvU owHUVTZk1Bf7MYZV+lzhbduuc+EGmytyNk4zh6QbXD/obhGSgcrQ45EvTpEUoqtiiGrk+HCrkLiBD 0Y1+rOjYz2YPwMADKZQkJ0ett4WTqtnZQfhtZSCabXyF5dKLCdzabwanA3sqFIRFXcIjrOJpwGGs1 s8kDMSXOqRhKG07GutSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmcF-00CHzp-L3; Sat, 27 Nov 2021 01:35:00 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOK-00C9W6-CO for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:42 +0000 Message-ID: <20211126230524.956623715@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976034; 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=E+zTAHs9Nymatzr+Yqyb5m4mctEau3gQEfp24M+P+yQ=; b=dNn3bIFVZIqnrwOPPKTgnM88lyYtiLqDmvkR5lSNVSeeEjjGt6gbGFuGbfknuaG+R38FNx Nx8jtTKn6Vvp7raIlHGVZy+J3IKkQAtKn3BjVW0xMPzVgwpAo/0g7A4AhyZ8AfYvVRT6mo 3ngjH31IDVKIlI1Tq5fZPCNQ+l40Y7Sm9CEygyO30SvWEl1ULXHyTwQzpRTLXTF8QG1A2T XwDOt3kUK5MD5unBT+hUGkXHSXKW0w3+iYUQRjYdmwyFmJNIhpINkW4p0KGj6RhNANcm5/ DmITJvsOJdnWOhLRI+bU6381SWHfBHZoZyqXNRRZ4x2SP1PzFyLGuKnTUYkxaw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976034; 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=E+zTAHs9Nymatzr+Yqyb5m4mctEau3gQEfp24M+P+yQ=; b=dgiaaASOxmK0tHaedOkd2xal+SVgOLvU5d9RNIBv3ZPi+Bw//6TY3s5FTKlFw7PWIxn7OS XohhinYHgn3UGLDw== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 17/37] soc: ti: ti_sci_inta_msi: Use msi_desc::msi_index References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:34 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172036_847201_A72C74D6 X-CRM114-Status: GOOD ( 13.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the common msi_index member and get rid of the pointless wrapper struct. Signed-off-by: Thomas Gleixner --- drivers/irqchip/irq-ti-sci-inta.c | 2 +- drivers/soc/ti/ti_sci_inta_msi.c | 6 +++--- include/linux/msi.h | 16 ++-------------- 3 files changed, 6 insertions(+), 18 deletions(-) --- a/drivers/irqchip/irq-ti-sci-inta.c +++ b/drivers/irqchip/irq-ti-sci-inta.c @@ -595,7 +595,7 @@ static void ti_sci_inta_msi_set_desc(msi struct platform_device *pdev = to_platform_device(desc->dev); arg->desc = desc; - arg->hwirq = TO_HWIRQ(pdev->id, desc->inta.dev_index); + arg->hwirq = TO_HWIRQ(pdev->id, desc->msi_index); } static struct msi_domain_ops ti_sci_inta_msi_ops = { --- a/drivers/soc/ti/ti_sci_inta_msi.c +++ b/drivers/soc/ti/ti_sci_inta_msi.c @@ -84,7 +84,7 @@ static int ti_sci_inta_msi_alloc_descs(s return -ENOMEM; } - msi_desc->inta.dev_index = res->desc[set].start + i; + msi_desc->msi_index = res->desc[set].start + i; INIT_LIST_HEAD(&msi_desc->list); list_add_tail(&msi_desc->list, dev_to_msi_list(dev)); count++; @@ -96,7 +96,7 @@ static int ti_sci_inta_msi_alloc_descs(s return -ENOMEM; } - msi_desc->inta.dev_index = res->desc[set].start_sec + i; + msi_desc->msi_index = res->desc[set].start_sec + i; INIT_LIST_HEAD(&msi_desc->list); list_add_tail(&msi_desc->list, dev_to_msi_list(dev)); count++; @@ -154,7 +154,7 @@ unsigned int ti_sci_inta_msi_get_virq(st struct msi_desc *desc; for_each_msi_entry(desc, dev) - if (desc->inta.dev_index == dev_index) + if (desc->msi_index == dev_index) return desc->irq; return -ENODEV; --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -106,14 +106,6 @@ struct pci_msi_desc { }; /** - * ti_sci_inta_msi_desc - TISCI based INTA specific msi descriptor data - * @dev_index: TISCI device index - */ -struct ti_sci_inta_msi_desc { - u16 dev_index; -}; - -/** * struct msi_desc - Descriptor structure for MSI based interrupts * @list: List head for management * @irq: The base interrupt number @@ -127,8 +119,7 @@ struct ti_sci_inta_msi_desc { * @write_msi_msg_data: Data parameter for the callback. * * @msi_index: Index of the msi descriptor - * @pci: [PCI] PCI speficic msi descriptor data - * @inta: [INTA] TISCI based INTA specific msi descriptor data + * @pci: PCI speficic msi descriptor data */ struct msi_desc { /* Shared device/bus type independent data */ @@ -146,10 +137,7 @@ struct msi_desc { void *write_msi_msg_data; u16 msi_index; - union { - struct pci_msi_desc pci; - struct ti_sci_inta_msi_desc inta; - }; + struct pci_msi_desc pci; }; /** From patchwork Sat Nov 27 01:20:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693802 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 054B1C433F5 for ; Sat, 27 Nov 2021 01:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=y2wstLvmOcaXV4xRJy354fCkFtposrWgb5WVaV11Gjw=; b=rQFMvsKrEXmF7z 4aFZdJO5e+UriCVD7ZSfesYiL412MNAqLkIV/tnd/3+wP8coamqTbWOLcV9A4f2SEwFI5RYmUpZvm gZyRb78Q1GcQiBJEyj9I8+JwWwohvJPphF9EXbBWxTTPiaj2jxLFzSBAdx6KUxBu7loZ10dKiKh0U 6oMErM7JK6lNu4FXbO37AExf/WkvaB63hwGYXDqMsdm95c6BQZxRjznuEyOg9jnyHjdMkW3rIfR59 YhXvte4FKqHWnGvBoalzwkgzopi6rzYXvVZ1RTUzK+70C7i3p8OeO66UIgS6NSwMJQsg/N/pmC4uw qvz4GMP4FNnEkTFUWvsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmdA-00CIL5-8e; Sat, 27 Nov 2021 01:35:56 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOM-00C9Xv-4z for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:45 +0000 Message-ID: <20211126230525.016223236@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976036; 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=fkSRZAFKOg49WRvcaWCK3eXzS4tUTHUaar/EP1a26n8=; b=BaAP7ZFHRr6LDKJ6ECi5DZwk9MCX3vw86fWdLWDXimT45ta8gg4+Emf11jo5B8dIRA0sg7 ly4JU1B6DGo67i7rv/efRxU4eCxjK1wZFjCMdPl/Xt0ztPHYV6pF4c7fS0tOB8OnrdFooM JKJUQGdZXAjUyiD9McrchguqbwOLI15MfUjVzlQwtS8IqwXRx66XeGCe/woKBa+BCEkGwN lc1SEdrxxe98/CCc5OoXFKghQWA7ch1nqlpN/wh8STsnSBxsdDtku8NCp7QcE2uWcR8+t7 PG2xcN9Pc0xA49cEyY9fOTWQFMvrrG2/B3m5YdOpOku1+J6z2a/1/nKcDIk6lg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976036; 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=fkSRZAFKOg49WRvcaWCK3eXzS4tUTHUaar/EP1a26n8=; b=n3NLXrUnIiVZ06B8SMasYjM5jUUN8ut8VQU8xaH2Nlufvi7CXtZ13q1AQ8NA/MzMttwCWg U1SxiFaIf3d1ynDA== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 18/37] PCI/MSI: Use msi_desc::msi_index References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:35 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172038_558796_384FAE44 X-CRM114-Status: GOOD ( 16.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The usage of msi_desc::pci::entry_nr is confusing at best. It's the index into the MSI[X] descriptor table. Use msi_desc::msi_index which is shared between all MSI incarnations instead of having a PCI specific storage for no value. Signed-off-by: Thomas Gleixner --- arch/powerpc/platforms/pseries/msi.c | 4 ++-- arch/x86/pci/xen.c | 2 +- drivers/pci/msi/irqdomain.c | 2 +- drivers/pci/msi/msi.c | 20 ++++++++------------ drivers/pci/xen-pcifront.c | 2 +- include/linux/msi.h | 2 -- 6 files changed, 13 insertions(+), 19 deletions(-) --- a/arch/powerpc/platforms/pseries/msi.c +++ b/arch/powerpc/platforms/pseries/msi.c @@ -332,7 +332,7 @@ static int check_msix_entries(struct pci expected = 0; for_each_pci_msi_entry(entry, pdev) { - if (entry->pci.msi_attrib.entry_nr != expected) { + if (entry->msi_index != expected) { pr_debug("rtas_msi: bad MSI-X entries.\n"); return -EINVAL; } @@ -580,7 +580,7 @@ static int pseries_irq_domain_alloc(stru int hwirq; int i, ret; - hwirq = rtas_query_irq_number(pci_get_pdn(pdev), desc->pci.msi_attrib.entry_nr); + hwirq = rtas_query_irq_number(pci_get_pdn(pdev), desc->msi_index); if (hwirq < 0) { dev_err(&pdev->dev, "Failed to query HW IRQ: %d\n", hwirq); return hwirq; --- a/arch/x86/pci/xen.c +++ b/arch/x86/pci/xen.c @@ -306,7 +306,7 @@ static int xen_initdom_setup_msi_irqs(st return -EINVAL; map_irq.table_base = pci_resource_start(dev, bir); - map_irq.entry_nr = msidesc->pci.msi_attrib.entry_nr; + map_irq.entry_nr = msidesc->msi_index; } ret = -EINVAL; --- a/drivers/pci/msi/irqdomain.c +++ b/drivers/pci/msi/irqdomain.c @@ -57,7 +57,7 @@ static irq_hw_number_t pci_msi_domain_ca { struct pci_dev *dev = msi_desc_to_pci_dev(desc); - return (irq_hw_number_t)desc->pci.msi_attrib.entry_nr | + return (irq_hw_number_t)desc->msi_index | pci_dev_id(dev) << 11 | (pci_domain_nr(dev->bus) & 0xFFFFFFFF) << 27; } --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -44,7 +44,7 @@ static inline void pci_msi_unmask(struct static inline void __iomem *pci_msix_desc_addr(struct msi_desc *desc) { - return desc->pci.mask_base + desc->pci.msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE; + return desc->pci.mask_base + desc->msi_index * PCI_MSIX_ENTRY_SIZE; } /* @@ -354,13 +354,10 @@ msi_setup_entry(struct pci_dev *dev, int if (dev->dev_flags & PCI_DEV_FLAGS_HAS_MSI_MASKING) control |= PCI_MSI_FLAGS_MASKBIT; - entry->pci.msi_attrib.is_msix = 0; - entry->pci.msi_attrib.is_64 = !!(control & PCI_MSI_FLAGS_64BIT); - entry->pci.msi_attrib.is_virtual = 0; - entry->pci.msi_attrib.entry_nr = 0; + entry->pci.msi_attrib.is_64 = !!(control & PCI_MSI_FLAGS_64BIT); entry->pci.msi_attrib.can_mask = !pci_msi_ignore_mask && !!(control & PCI_MSI_FLAGS_MASKBIT); - entry->pci.msi_attrib.default_irq = dev->irq; /* Save IOAPIC IRQ */ + entry->pci.msi_attrib.default_irq = dev->irq; entry->pci.msi_attrib.multi_cap = (control & PCI_MSI_FLAGS_QMASK) >> 1; entry->pci.msi_attrib.multiple = ilog2(__roundup_pow_of_two(nvec)); @@ -494,12 +491,11 @@ static int msix_setup_entries(struct pci entry->pci.msi_attrib.is_64 = 1; if (entries) - entry->pci.msi_attrib.entry_nr = entries[i].entry; + entry->msi_index = entries[i].entry; else - entry->pci.msi_attrib.entry_nr = i; + entry->msi_index = i; - entry->pci.msi_attrib.is_virtual = - entry->pci.msi_attrib.entry_nr >= vec_count; + entry->pci.msi_attrib.is_virtual = entry->msi_index >= vec_count; entry->pci.msi_attrib.can_mask = !pci_msi_ignore_mask && !entry->pci.msi_attrib.is_virtual; @@ -1025,7 +1021,7 @@ int pci_irq_vector(struct pci_dev *dev, struct msi_desc *entry; for_each_pci_msi_entry(entry, dev) { - if (entry->pci.msi_attrib.entry_nr == nr) + if (entry->msi_index == nr) return entry->irq; } WARN_ON_ONCE(1); @@ -1057,7 +1053,7 @@ const struct cpumask *pci_irq_get_affini struct msi_desc *entry; for_each_pci_msi_entry(entry, dev) { - if (entry->pci.msi_attrib.entry_nr == nr) + if (entry->msi_index == nr) return &entry->affinity->mask; } WARN_ON_ONCE(1); --- a/drivers/pci/xen-pcifront.c +++ b/drivers/pci/xen-pcifront.c @@ -263,7 +263,7 @@ static int pci_frontend_enable_msix(stru i = 0; for_each_pci_msi_entry(entry, dev) { - op.msix_entries[i].entry = entry->pci.msi_attrib.entry_nr; + op.msix_entries[i].entry = entry->msi_index; /* Vector is useless at this point. */ op.msix_entries[i].vector = -1; i++; --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -79,7 +79,6 @@ typedef void (*irq_write_msi_msg_t)(stru * @multi_cap: [PCI MSI/X] log2 num of messages supported * @can_mask: [PCI MSI/X] Masking supported? * @is_64: [PCI MSI/X] Address size: 0=32bit 1=64bit - * @entry_nr: [PCI MSI/X] Entry which is described by this descriptor * @default_irq:[PCI MSI/X] The default pre-assigned non-MSI irq * @mask_pos: [PCI MSI] Mask register position * @mask_base: [PCI MSI-X] Mask register base address @@ -96,7 +95,6 @@ struct pci_msi_desc { u8 can_mask : 1; u8 is_64 : 1; u8 is_virtual : 1; - u16 entry_nr; unsigned default_irq; } msi_attrib; union { From patchwork Sat Nov 27 01:20:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693803 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 5FEF1C433F5 for ; Sat, 27 Nov 2021 01:38:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=ypP9wvBiainKjONGV7tAOOkOl2GIeA3nl/7/4tsDuAw=; b=GsngYbhlBLWl8S SfS5axdAZXITukpM39TNazqWB/0XgLs9cHQyvrQd5Odqc6WfA9WIgfd0tmeG9kbnYj/e50shd//w+ PCVIgVvwvXaPYKw9VprPU7AoObbLq1uPWV5dKGfbp0suihpk42FVQL5CxC+cZl6GbMCi3+Cqr3DqM UA3jpOHD0LutOIv3qSo50IgueiUNBsTChoVu7TvYW0zSbhjzUTZqlenYKCjTo1CO3MN4saq1m5Am/ sScPr4+QSDokjEZGSLOr+9lFJvGBhu7jYyVIDGW3LYMtVvuWqAuDNsiM6aY517UN3gxIADrAxA1vt EowrrVFN26psSVi0NYOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmdx-00CIes-Ja; Sat, 27 Nov 2021 01:36:46 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmON-00C9ZW-FQ for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:45 +0000 Message-ID: <20211126230525.076279841@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976037; 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=gZLgk03W9BPqX4Y47drAtN3rUO/Oc3l0uTHU4EywtJI=; b=haWzMt4KR9DWFpGWdGE1l1s2+vs+6A08HfUC3wCsW3ct8bY8hzzw5Zksb1QAtSqqKXiTLV 90HL8F+IY3f388igePB9oG82ZtrhY+pUqOOsbCmR2UT/4VVzeLQMGXQ7XBpjTJVwJYV4gI WYrto37nJcH9GJjyMqoKYfnwaCKd3a9/AJtrxjeb2TiAS5tmTf34lQJzwzHb8XlIXVJWOr i65Z3V0NA6W4UMX3WRllvGzZNGYs2fwg6buB6N3fX2WBKGLJIFIaq0bn5EZ88rtrKujv++ Pb6chN5PsN34skBdrvROx5hCigMHTKQgd0gRtXaVoWnySgsBCrEuicXBelakSw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976038; 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=gZLgk03W9BPqX4Y47drAtN3rUO/Oc3l0uTHU4EywtJI=; b=pmIRurktZCqaSiTjEwau1BH/cen1Z4IWsZYOdf1qJ4Pt16qpjmgbTpo368LzRvhdZG1dgu sjE9naEhMlft7uAw== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 19/37] genirq/msi: Add msi_device_data::properties References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:37 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172039_969258_90CAD8D2 X-CRM114-Status: GOOD ( 12.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a properties field which allows core code to store information for easy retrieval in order to replace MSI descriptor fiddling. Signed-off-by: Thomas Gleixner --- include/linux/msi.h | 17 +++++++++++++++++ kernel/irq/msi.c | 12 ++++++++++++ 2 files changed, 29 insertions(+) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -4,6 +4,7 @@ #include #include +#include #include /* Dummy shadow structures if an architecture does not define them */ @@ -141,17 +142,33 @@ struct msi_desc { /** * msi_device_data - MSI per device data * @lock: Spinlock to protect register access + * @properties: MSI properties which are interesting to drivers * @attrs: Pointer to the sysfs attribute group * @platform_data: Platform-MSI specific data */ struct msi_device_data { raw_spinlock_t lock; + unsigned long properties; const struct attribute_group **attrs; struct platform_msi_priv_data *platform_data; }; int msi_setup_device_data(struct device *dev); +/* MSI device properties */ +#define MSI_PROP_PCI_MSI BIT(0) +#define MSI_PROP_PCI_MSIX BIT(1) +#define MSI_PROP_64BIT BIT(2) + +#ifdef CONFIG_GENERIC_MSI_IRQ +bool msi_device_has_property(struct device *dev, unsigned long prop); +#else +static inline bool msi_device_has_property(struct device *dev, unsigned long prop) +{ + return false; +} +#endif + /* 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) --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -60,6 +60,18 @@ void free_msi_entry(struct msi_desc *ent kfree(entry); } +/** + * msi_device_has_property - Check whether a device has a specific MSI property + * @dev: Pointer to the device which is queried + * @prop: Property to check for + */ +bool msi_device_has_property(struct device *dev, unsigned long prop) +{ + if (!dev->msi.data) + return false; + return !!(dev->msi.data->properties & prop); +} + void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg) { *msg = entry->msg; From patchwork Sat Nov 27 01:20:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693804 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 AD59AC433F5 for ; Sat, 27 Nov 2021 01:39:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=Hgavr4vEir/vR0597Gs3swjxmpgLooZN/XZ7TrRLxTM=; b=KdIwkKR3SodoNo bz1dM0GbzvnRqsQ5kxfgVzyVOUe43CIIAn4bwpCsLT0+FoNEtZ3VF5CQnGfCwY6edOjZR7K+Otqfs 9fz3G8dYCTsD8SJYMEQ8UCTqOIV4cprubsaLba1LDFtJRHZI4dle7A7BiJg4MM5xB+s9kQRz133r4 UUyZXxyO2YXBNCZSYrHZm4O0lkc2VxT2sfedajGHrUdUX/vaP0qgFVSa6YjBU5bt0Jcl5YkvbtnGo oWSl3cqIE7LX43bz6TjBNNSkx+y/tnZGUeCWpMA13cqkUaOExv2dHySl3hZ02hR7SJ1BFC03esO1s FO+WehSVUyT9l/XgjccQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmer-00CJ0I-VS; Sat, 27 Nov 2021 01:37:43 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOP-00C9bc-6V for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:46 +0000 Message-ID: <20211126230525.137299282@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976039; 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=ZWaHMo5/cxTSb8aCm3CN77ES3jPYHd9BeCyQKbhAf1Q=; b=UggVVv3f7QCjME5pjLx9J0hsxvfwEK88RAs5+In+TDQQ49/kKJE/4UBeSm9ZmjOA3ObLqP RsQuoCiENoW9YWD6uVKBIaFEfiXZtiUA08HDqEG1GpZjdIXrtx2v7bjgs5y6sTpxr2DQVA /dKkq3qcWWn1VZjG9liURMDeIHNbl/xUG3O/brsKYly5bzbVoe+4DfLAT2w+cOXQs188b9 U3cNtwx6+wWxxHiA4/bh4AnrsFJmkU3lZlUxoJ+pijTSavjP+DhwwYBqOLB/XscIqzEUw0 Ovy3cNm8ATuXUVs96hhg2BgomxXlWEh+swP3glYt48WR6vFYpyUno12lQdyhAw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976039; 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=ZWaHMo5/cxTSb8aCm3CN77ES3jPYHd9BeCyQKbhAf1Q=; b=KjHrEnrG0fpDzTmWoCzq7Si7jPR+/lr5hq4rxoNYcQ2Ul/fX9e3zQDEhrh98Csz5sTQmgO gbeMniPwqgDOT0Dg== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 20/37] PCI/MSI: Store properties in device::msi::data References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:39 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172041_503627_58AD4E92 X-CRM114-Status: UNSURE ( 8.67 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Store the properties which are interesting for various places so the MSI descriptor fiddling can be removed. Signed-off-by: Thomas Gleixner --- drivers/pci/msi/msi.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -244,6 +244,8 @@ static void free_msi_irqs(struct pci_dev iounmap(dev->msix_base); dev->msix_base = NULL; } + + dev->dev.msi.data->properties = 0; } static void pci_intx_for_msi(struct pci_dev *dev, int enable) @@ -372,6 +374,9 @@ msi_setup_entry(struct pci_dev *dev, int if (entry->pci.msi_attrib.can_mask) pci_read_config_dword(dev, entry->pci.mask_pos, &entry->pci.msi_mask); + dev->dev.msi.data->properties = MSI_PROP_PCI_MSI; + if (entry->pci.msi_attrib.is_64) + dev->dev.msi.data->properties |= MSI_PROP_64BIT; out: kfree(masks); return entry; @@ -514,6 +519,7 @@ static int msix_setup_entries(struct pci if (masks) curmsk++; } + dev->dev.msi.data->properties = MSI_PROP_PCI_MSIX | MSI_PROP_64BIT; ret = 0; out: kfree(masks); From patchwork Sat Nov 27 01:20:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693805 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 85DBBC433F5 for ; Sat, 27 Nov 2021 01:40:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=vp7bEgZW7YhdcyiD24AToIIAvhn79E9CywHWA6uW8uk=; b=wxr05tQfchEelb JlHPQIqMmRhBvy7rbEx4UJ67NMpjCqkK4Qbc1G/fWUCqW7/MvkN5tKTGSMFu22CptWYZd4VfvXPmA UiVZhQ9PoyLYVGNQOlmmIltQDS/na0/ljWH1JwgXdCGnpDfxU4+9gDTaMmUtFPUVhTkrCoisCQO0u mzk16Pu/D2EJgN6wySnDFOPKPvfTwLTH4+WpgcgDKaIHuICXtV+c/QbLxDvwNYHzj3CsCEhoAuXB6 sAB2+ScfLBAk8ggUDj1mmqPId6QLPN2cQLZt4/8qr1/LQMFJUNmTwu+4WZRk63VenmENobgkp78fE U/U7TPGB2v022peZs0Uw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmfg-00CJKt-9a; Sat, 27 Nov 2021 01:38:33 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOQ-00C9dG-Oq for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:48 +0000 Message-ID: <20211126230525.197675096@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976041; 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=NeV9ZGHBl4mFlIql3fyxuMisNGkK+XSuThKmqvqjQGM=; b=JAdE2RyoX9GtBaSz3XfMgQXg5A/NS53ylKtJBy2FYBJyRR/2c2hRujC6kQQas6U4aD2+0T il3kAe620gXBh2tpN4EztArqGj5lweEIUqb8We13lnntLKJ2lcpnNAcAC5uH92Ch1ZKNlI fjQRhNyNyY6ZsqqWWTl1FWcn4ovC2GHDlwRnfyPJJLW04kbvwPCAdV9M2WJs7hefUFlWM0 5vG0b/g9sOSsvEgjsesKxV8SovgfpPl9MvPf4AnofnGApRJwTg/w28qZ7O22hIzVNj+k7S mb3YrIWu0YqWSjergcbz3XCUAVtPFomnRPz05AE09yfiKfanEBIir+crizE+MQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976041; 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=NeV9ZGHBl4mFlIql3fyxuMisNGkK+XSuThKmqvqjQGM=; b=5sHfgyo6g4VSOtX0bdl9wuxhxIatjMau8XPLOklJTwt1QUazIyuZKEgfNEnoMLAykxpAxu wxnlzZgIUND/2IDw== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 21/37] x86/pci/XEN: Use device MSI properties References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:40 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172043_044242_1450F095 X-CRM114-Status: UNSURE ( 9.67 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org instead of fiddling with MSI descriptors. Signed-off-by: Thomas Gleixner --- arch/x86/pci/xen.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/arch/x86/pci/xen.c +++ b/arch/x86/pci/xen.c @@ -399,9 +399,7 @@ static void xen_teardown_msi_irqs(struct static void xen_pv_teardown_msi_irqs(struct pci_dev *dev) { - struct msi_desc *msidesc = first_pci_msi_entry(dev); - - if (msidesc->pci.msi_attrib.is_msix) + if (msi_device_has_property(&dev->dev, MSI_PROP_PCI_MSIX)) xen_pci_frontend_disable_msix(dev); else xen_pci_frontend_disable_msi(dev); @@ -417,7 +415,7 @@ static int xen_msi_domain_alloc_irqs(str if (WARN_ON_ONCE(!dev_is_pci(dev))) return -EINVAL; - if (first_msi_entry(dev)->pci.msi_attrib.is_msix) + if (msi_device_has_property(dev, MSI_PROP_PCI_MSIX)) type = PCI_CAP_ID_MSIX; else type = PCI_CAP_ID_MSI; From patchwork Sat Nov 27 01:20:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693806 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 E849BC433F5 for ; Sat, 27 Nov 2021 01:41:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=5tD0qXiKl1wZvDu3nu01Dy5j8hGtwDXvFcI7jf8FQ2Q=; b=16FjNEQrcMn7y9 8xc/KsZIrIUDKj56X2I4TXxBsbpXQ/HA0g+yKSQpPd9xe/vpEoDS8saR5z+MOkR6BB0CnYEIGQ5ln TpBjb4X4mwxduIsa/SrSxZqO91Q3/xSgYEsa6XMnguDzosZ+VVbExihh4tndDVQVOHc/dLh9qdlk2 82NzOljxdaEGTE1wpDSib2ozgJSwQsB6jZg8fNoBCVpe5/GHsudIBUXlZP8EorVAbMwRM+mbDl2si zarLZcZuNkepaAwIc3PLofzVUYtC9Iw5IKaSbaPqTpyG55V4qYVl1NwroueueNGeXj8qtT59XEBwc OzPRay7iR7yaQHQ3U0vw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmge-00CJlL-OR; Sat, 27 Nov 2021 01:39:33 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOS-00C9fb-4x for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:50 +0000 Message-ID: <20211126230525.256653991@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976042; 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=W0h8cFkpSlrjWKkacc77gmgmQ9hJjfO/HefW6QQlYnQ=; b=r4eal6rIfDIoamvlWEISLX+P71N4hhZWD6sAKPeFo0r/w9+NdyQL8mH9WU9ard2q78GBGM puSfzbYsc/CLTm4wMoatWZX8JGm4zcDz4aypqFRJVzPwpahZK4bLGm8GmHxqVRFswULQN0 vxOuVPmklXTu1Dt3I0tBOTNgRG0Sn42XfnNRTSfuGvZb5z0VAdT9OkLzq3IHXHIVqeB93p 6gSP3m2B7KtG9jwXFYWdBmrxG0dhkXKDqJjtZ7VFkiA3Wet92nFLuAj2ktppNDpf85Evr9 iBbS8mzN6/r/uRiEFpkV7cESINPLw2PRGvei1yfLXYzA9yftlrSnsJt6JFh6dA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976042; 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=W0h8cFkpSlrjWKkacc77gmgmQ9hJjfO/HefW6QQlYnQ=; b=exDXzbWNyzm8lpC8blE93+qo6A6+cBUS2GiuAcExzXacXAdgjQYexIMIGb0pS8kwazFa+i WxdkIBqLR1OS8LDw== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 22/37] x86/apic/msi: Use device MSI properties References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:42 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172044_458831_7AE46CEA X-CRM114-Status: GOOD ( 10.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org instead of fiddling with MSI descriptors. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/msi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) --- a/arch/x86/kernel/apic/msi.c +++ b/arch/x86/kernel/apic/msi.c @@ -160,11 +160,8 @@ static struct irq_chip pci_msi_controlle int pci_msi_prepare(struct irq_domain *domain, struct device *dev, int nvec, msi_alloc_info_t *arg) { - struct pci_dev *pdev = to_pci_dev(dev); - struct msi_desc *desc = first_pci_msi_entry(pdev); - init_irq_alloc_info(arg, NULL); - if (desc->pci.msi_attrib.is_msix) { + if (msi_device_has_property(dev, MSI_PROP_PCI_MSIX)) { arg->type = X86_IRQ_ALLOC_TYPE_PCI_MSIX; } else { arg->type = X86_IRQ_ALLOC_TYPE_PCI_MSI; From patchwork Sat Nov 27 01:20:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693807 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 03EE3C433F5 for ; Sat, 27 Nov 2021 01:42:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=E/Um7XmW60pZUm/WbO2jTSeXNePx1aCT1XzbtWfexrE=; b=sx5NsbnVRp4eU6 HNfKheTXrujQ6oSBVSrxSVJJvyVD0huqs8vGC7PtG+OS9MSTilA8YokF3X3Skqi8Oz3xiknY1d0sm 4RhkYfCKkrEcEkn+yStl4KnL5iiW1gLbakuThGwQ4CYYU5beuq6O24ZyDr69BU5r3O3SbVWcOaKrF ZslCFoNOPEloTRLdANvXkHfByDKLvfwxSs8pzIcXk1fCCvE9PFy8QnqHm0O8TeRS5OpALCh+cAYzh z1dvBOz9s8Ty7aYo/y7fmh5e14Wvcx42/SBzZ1LBuoSeYS5LkFc2VKlhjtVw+z7LhjIcq8TBe9z9t wWwojBvzDE4rZtq+me0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmi1-00CKMn-RU; Sat, 27 Nov 2021 01:40:58 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOT-00C9i1-NB for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:50 +0000 Message-ID: <20211126230525.315266344@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976044; 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=mgACjNybAkVsWjwjzkFX6HgLmpYiDt2Y2zyU/5gje7g=; b=iP27cgXidL5SLaulOXvp3cm7WgLUDh/d2/3RVGMWhEH8iyeN9TUZVAksT0NL4RhJev2i53 OLkkgEkTsJEqlOG2NXpaHuApkLe/S81+ELPfC/i0bdD/E75c9Hb5Pru4FxIvpOyk/iNrSm tfseRoetLanHz61s/4Ye9jxxWwhI7NatJfWDEUiBXwAHqSqxv8KbYzHcUUlqYe6x8DwMNi ZIVwu8ZO0VeUEliHiVPzWl/Fv9RUxyHMpe/TmzCwxQUK5ifSedBNr3GQ6wYrbJJi0nfOo6 GLUdTIrnEoYZcsmqJMYdKU5/XUJvUNYwB135GZJwzGUPU2qUXnnpQ1AslNfU7Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976044; 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=mgACjNybAkVsWjwjzkFX6HgLmpYiDt2Y2zyU/5gje7g=; b=xKPmNFPcGh3tszti3AasucXkI+se6p1kxMe76wgvqlQQ5D6zBqdFZYctozRU4F7+sEhBjb /av6nqPxzuVz9sCg== 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, Greg Kroah-Hartman , x86@kernel.org, Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 23/37] genirq/msi: Use device MSI properties References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:43 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172046_635278_642C3FCC X-CRM114-Status: UNSURE ( 8.62 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org instead of fiddling with MSI descriptors. Signed-off-by: Thomas Gleixner Cc: x86@kernel.org --- kernel/irq/msi.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -114,21 +114,8 @@ int msi_setup_device_data(struct device static ssize_t msi_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct msi_desc *entry; - bool is_msix = false; - unsigned long irq; - int retval; - - retval = kstrtoul(attr->attr.name, 10, &irq); - if (retval) - return retval; - - entry = irq_get_msi_desc(irq); - if (!entry) - return -ENODEV; - - if (dev_is_pci(dev)) - is_msix = entry->pci.msi_attrib.is_msix; + /* MSI vs. MSIX is per device not per interrupt */ + bool is_msix = msi_device_has_property(dev, MSI_PROP_PCI_MSIX); return sysfs_emit(buf, "%s\n", is_msix ? "msix" : "msi"); } From patchwork Sat Nov 27 01:20: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: 12693808 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 ADB1BC433F5 for ; Sat, 27 Nov 2021 01:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=KZq0aNsruh0PwI65+YvuzhanrjCA/AkdfcQiH1hGNDU=; b=WYqXKhi0jNTMbP ns6tgTDeAJ3vWFqR2xDO67S3dSP7bsSG5+/PjZRCjo17ELjISz7UJMkDlffxbLrq3SCwZ61AzFbcN vCRU2pt6pU38X1kLPpKoko8YtGKXYHe0F0Z3MGQ0YfV8p5dqdltiAQSF+wcZ8ApxX4f7ruvV5v4kM Plov8WFQRdymM8I0Dt7z92Y2O4DuJmn+fNaDgDpt68EVrucEqwqRHaIwzIQKn+Xp9wc88q1Cu4bJb FRkuesk14+5TS3elnH1zEX2EDSCNzVVNcN9sjjqXFWxnYhChbTPxE/a7wP0Tk4QS9rT+BgeytoWFw Lmn05diNky+pMBS9p8Qg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmjA-00CKvP-CQ; Sat, 27 Nov 2021 01:42:08 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOV-00C9je-DJ for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:52 +0000 Message-ID: <20211126230525.374699615@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976045; 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=G+kQoqkWvFJXcdz5PQCdFWimR12BfigYgz7Zbwfcs54=; b=a4IGUqXtXIwTCipeEaCK18NENo8ejWLO0RAVBMzwJd4vheCxJFL1u083PEtxGKZjYTpDXa kjIkdlz/Me+vDfIXTizASuoqgVKXXbjp05y7oakiEmGuw3/2un0MFaI1Y0b7EaSGzUdgiF gyN5B1u3cRhGUOObj98rlrrocAGjSCu2+NVv9Janv+epcZt2H6wEpPqA4frbcE+evuyirU EE16hmnNL546crv5bPO8fWnp45/znozW8kxsYEPVlOgYrU3wYQUl54HJALseiDrLgPlMQi nkl0LlcAjYLUfacIM3Xz5ufccSxVwgm9akbsqevUgaybsKVHfGP8te/8BvBw2w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976045; 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=G+kQoqkWvFJXcdz5PQCdFWimR12BfigYgz7Zbwfcs54=; b=lf9IuXXC/5triKpko28bR3F8ly/WAaUvo4XZUDmmDQUjFfB2wrlfPNfYASVPyKqWnEncGk /nZZx/GnJyyEWNBA== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 24/37] powerpc/cell/axon_msi: Use MSI device properties References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:45 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172047_679371_078D0EEA X-CRM114-Status: GOOD ( 10.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org instead of fiddling with MSI descriptors. Signed-off-by: Thomas Gleixner --- arch/powerpc/platforms/cell/axon_msi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/arch/powerpc/platforms/cell/axon_msi.c +++ b/arch/powerpc/platforms/cell/axon_msi.c @@ -199,7 +199,7 @@ static struct axon_msic *find_msi_transl static int setup_msi_msg_address(struct pci_dev *dev, struct msi_msg *msg) { struct device_node *dn; - struct msi_desc *entry; + bool is_64bit; int len; const u32 *prop; @@ -209,10 +209,10 @@ static int setup_msi_msg_address(struct return -ENODEV; } - entry = first_pci_msi_entry(dev); + is_64bit = msi_device_has_property(MSI_PROP_64BIT); for (; dn; dn = of_get_next_parent(dn)) { - if (entry->pci.msi_attrib.is_64) { + if (is_64bit) { prop = of_get_property(dn, "msi-address-64", &len); if (prop) break; From patchwork Sat Nov 27 01:20:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693809 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 75ED6C433F5 for ; Sat, 27 Nov 2021 01:45:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=nAuQwBSCd96sDNxtI+GB+fKdDY6Yi2xWmGiIoMcIrz0=; b=jCJB360RlDQWqe 4qGsmaGHnPn7Jqh51y9yh7R+JJR5VCLTuyC42R2VKiL2bbOlj+CR0REYGW8L9o5VWWaoivvo88wkG zNKy+3yAgQuLjBs5zSz+HOOsmo9OjXV5FSPzUnQjcHBbMh68kMBDNJOVXK+uMLWyejKvFyYt2MiOF n/RL5sqEHrdSbB5d4+Da6BDgpUl7rS3sFv2Yjkbapt/9Pm55QGJTNavSXNyvoYjFmR9KnIcByNZt0 XHrGpvvP/YDbEE/luRa37fBSlsY7ADn+kpRYFKVcj+ItGqD+rYRqw6NS/eBCaWywNTHJX1jTi+8uj EKJomEOoKsjsD/ntfGtA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmk6-00CLMK-MU; Sat, 27 Nov 2021 01:43:07 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOW-00C9lZ-Sg for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:52 +0000 Message-ID: <20211126230525.432148049@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976047; 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=R5e0O3/cPtKTz28swaAQpwxXJzIJ0KDZCypBX7NJJUs=; b=1n7oWPvlZf1xqG6Sw+LVHR6RbnhIdn409ZgeaAT3nQ/uTiEZJj8qbhGRo2Hp13JC71Sw14 B6R7uoa2QCejc2UUGcypq/q7tYpI6GAZazBi1svWlXijtjO8MDV9by/U//aLSEXrMBhmEo 1XHTnjiajvaAlTv3SSj52TxIywHy5rK0mPsVWCDObhAI8WzzYsjmKssz9Uf7QXmav9wkhd UpxZqVvs/0/Jwj7FYcWOU9N14DVD4Bp06tmK85PYK80Li1jzm1ftGL3RZXmqjlkoU+NuEN HcfU+b866/pCAgBCvtxw/YKfDOv70fzufvhPSc6g7RsL3S6nKzJPZfVJF4tR1A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976047; 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=R5e0O3/cPtKTz28swaAQpwxXJzIJ0KDZCypBX7NJJUs=; b=de/BHQTomYdNMV5p6IjuUEGKCvLrIts4BHniXnUr81HjSGHocBuvhsDv6/YQyr/xEO1owH t/ukPevbzOfZelBw== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 25/37] powerpc/pseries/msi: Use MSI device properties References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:46 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172049_153485_57C92E71 X-CRM114-Status: GOOD ( 10.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org instead of fiddling with MSI descriptors. Signed-off-by: Thomas Gleixner --- arch/powerpc/platforms/pseries/msi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/powerpc/platforms/pseries/msi.c +++ b/arch/powerpc/platforms/pseries/msi.c @@ -447,9 +447,9 @@ static int rtas_prepare_msi_irqs(struct static int pseries_msi_ops_prepare(struct irq_domain *domain, struct device *dev, int nvec, msi_alloc_info_t *arg) { + bool is_msix = msi_device_has_property(dev, MSI_PROP_PCI_MSIX); + int type = is_msix ? PCI_CAP_ID_MSIX : PCI_CAP_ID_MSI; struct pci_dev *pdev = to_pci_dev(dev); - struct msi_desc *desc = first_pci_msi_entry(pdev); - int type = desc->pci.msi_attrib.is_msix ? PCI_CAP_ID_MSIX : PCI_CAP_ID_MSI; return rtas_prepare_msi_irqs(pdev, nvec, type, arg); } From patchwork Sat Nov 27 01:20:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693810 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 9E39EC433EF for ; Sat, 27 Nov 2021 01:45:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=gnQubta/NQhor96VFSvB87yN9miV3s/NeVqwYIJgtNE=; b=1EbPFjJe5DL41h lGfimrovo1pkq/5ZAL80Em9JB4qE48s355vXQpnrjjd/mfrHuhpIQTEh3Xi2DBODoLlSf1sB4ekh3 J/E+xwS12CHyo7lkEl9vHRiz8T/miYg15weMPvN8Huhsz8ipSDP5/e1qMQjiDGkK5RE9em4GWgla0 3rHFzcEWlLnDEnTOfgrP37XgVekS3/jZCQNmfqnUmqqNpVruPx+gETIHcmdK/n3649gDhgNudjAJb LM2ZMik2NOEW84GggZfwUE8IQK985Te9hq06qW3Qt9I6kFcffnH5Km4Pa0xeCVU2XDWu6RC3HhGtq 53ogWZvyvCqVhHB8xu7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmkb-00CLb7-Cx; Sat, 27 Nov 2021 01:43:38 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOY-00C9nz-Ue for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:54 +0000 Message-ID: <20211126230525.491832071@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976049; 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=iaLCpiERLpuGITLjESnXqZksSqXjgw+jF1i/FwPrQ3E=; b=kcYlvqdpt98wpVF7Qtbik8L8AOo4OCpitlj1WpYPqo+Y9mz1x78EEZ7He5pgLtuIigvALI 1dcsghFKKbeeT47ziXOMVbVmaZLeN9gxU/gLWyLmtASdizLv2Vf78BctOMNAcw34ZDaqnh jmRNIzKC2YJqCujCBWAfzByFHacrIt1LGoOuUf7nvj6OJ0w7PyF0+3oEpfin8Fl9Xa6SHV dFrc/ZZehVhKNVpTk0XwhxCb/eniIRQ0MiRQ360AATCENk+dCdG9gEUdJqegeVSPISnY0G POzb0yLiNCnw68Rs+ZdweMmS3jxNp9s/h0lDFU4ZlXkx9kl+FGiEHnZwcGoM8Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976049; 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=iaLCpiERLpuGITLjESnXqZksSqXjgw+jF1i/FwPrQ3E=; b=CrtKgt88PsrcMd/EsUX+7UmHHwT9hagSD+g8Cz/HvkmLqq7Na4BfCjXff36gzHt+V+48cV uGMotbLDIzOQRSDw== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 26/37] PCI/MSI: Provide MSI_FLAG_MSIX_CONTIGUOUS References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:48 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172051_231122_ED613CDD X-CRM114-Status: GOOD ( 13.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Provide a domain info flag which makes the core code check for a contiguous MSI-X index on allocation. That's simpler than checking it at some other domain callback in architecture code. Signed-off-by: Thomas Gleixner --- drivers/pci/msi/irqdomain.c | 16 ++++++++++++++-- include/linux/msi.h | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) --- a/drivers/pci/msi/irqdomain.c +++ b/drivers/pci/msi/irqdomain.c @@ -89,9 +89,21 @@ static int pci_msi_domain_check_cap(stru if (pci_msi_desc_is_multi_msi(desc) && !(info->flags & MSI_FLAG_MULTI_PCI_MSI)) return 1; - else if (desc->pci.msi_attrib.is_msix && !(info->flags & MSI_FLAG_PCI_MSIX)) - return -ENOTSUPP; + if (desc->pci.msi_attrib.is_msix) { + if (!(info->flags & MSI_FLAG_PCI_MSIX)) + return -ENOTSUPP; + + if (info->flags & MSI_FLAG_MSIX_CONTIGUOUS) { + unsigned int idx = 0; + + /* Check for gaps in the entry indices */ + for_each_msi_entry(desc, dev) { + if (desc->msi_index != idx++) + return -ENOTSUPP; + } + } + } return 0; } --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -378,6 +378,8 @@ enum { MSI_FLAG_LEVEL_CAPABLE = (1 << 6), /* Populate sysfs on alloc() and destroy it on free() */ MSI_FLAG_DEV_SYSFS = (1 << 7), + /* MSI-X entries must be contiguous */ + MSI_FLAG_MSIX_CONTIGUOUS = (1 << 8), }; int msi_domain_set_affinity(struct irq_data *data, const struct cpumask *mask, From patchwork Sat Nov 27 01:20:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693811 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 3EED2C433EF for ; Sat, 27 Nov 2021 01:46:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=GZOomRxTiln95ab2gWsna+i+2hegZjhf3VNGFr0LzZw=; b=QJJORKS7vn95dy lqtqY3/Wu1N2Gsylycn5p4HUmhVUGPMbC1+tVaNRqOfHMIm/PLPyRNzGh7/SAxIoa9MVxBR0cH+GN HATeZt7lmDipSRhGX6D10U5RzaPqDw3W2wlvpIr12CCjDXNGwhvEE+HUmnipaCWHxpk6advGYSCrq G8io3eusWtlFAfgvKUf/qM1ZzSIc0kw8IBEroUISyDRv0MT6/tyPBXUOcTrEtp42w96/SQqM/39cC FkJPA6O1sK/A3WoD3sHEeWt4/kQIVHn2Asyt1Z/BvjwGCAgx9Tdc8zS9PUoYOaazpZ7sMxX60ub34 3yR6BJpaspa+Nw7eHi+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmlK-00CLrZ-0D; Sat, 27 Nov 2021 01:44:22 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOa-00C9pZ-1H for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:56 +0000 Message-ID: <20211126230525.548258086@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976050; 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=wJMUpNJgyC/5WRXAWU3ClvJ2/7JlSux0SjtaYWx+PkY=; b=aQ1pSGzf1xljCMjV+A0HzBdj533zrI8Sn8/x78I5JLlzyaGEt2oaQIsa1H+VK1HinYpueS +3myORcpC+LyitSb3vMrxPMq0DdPSeOmr+hwbfxW2AzPhxwb5L2zDvpDENXii3Eq3fARgs moKEGxluXefb305ZDtRjnMujpBvPT5xFMXT0JTPNbH3aMGBKzkStBUqVjhor692Rl+IOBE xCmjzF0+vA/27cY8FjGJpCndjmidTZiuHmk0dsQDSB89lO5FRMUDZPKROlJ/JjU+NGZTPd kT+u92mqPp823zt8fgiXmt8+iJowIP8MdiBGyRV6mE2PiuLN6I3OdDf/9GaWZg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976050; 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=wJMUpNJgyC/5WRXAWU3ClvJ2/7JlSux0SjtaYWx+PkY=; b=+khAQI9uNx8/zRgnV5rYXfaV6JyxSqTfzihC0RwrUHqKrPuQ+rUqH7qGte4yfUVdbfquwh jJs8fClZojrNxQDg== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 27/37] powerpc/pseries/msi: Let core code check for contiguous entries References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:50 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172052_309390_A54C2D8A X-CRM114-Status: GOOD ( 14.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Set the domain info flag and remove the check. Signed-off-by: Thomas Gleixner --- arch/powerpc/platforms/pseries/msi.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) --- a/arch/powerpc/platforms/pseries/msi.c +++ b/arch/powerpc/platforms/pseries/msi.c @@ -321,27 +321,6 @@ static int msi_quota_for_device(struct p return request; } -static int check_msix_entries(struct pci_dev *pdev) -{ - struct msi_desc *entry; - int expected; - - /* There's no way for us to express to firmware that we want - * a discontiguous, or non-zero based, range of MSI-X entries. - * So we must reject such requests. */ - - expected = 0; - for_each_pci_msi_entry(entry, pdev) { - if (entry->msi_index != expected) { - pr_debug("rtas_msi: bad MSI-X entries.\n"); - return -EINVAL; - } - expected++; - } - - return 0; -} - static void rtas_hack_32bit_msi_gen2(struct pci_dev *pdev) { u32 addr_hi, addr_lo; @@ -380,7 +359,7 @@ static int rtas_prepare_msi_irqs(struct if (quota && quota < nvec) return quota; - if (type == PCI_CAP_ID_MSIX && check_msix_entries(pdev)) + if (type == PCI_CAP_ID_MSIX) return -EINVAL; /* @@ -530,9 +509,16 @@ static struct irq_chip pseries_pci_msi_i .irq_write_msi_msg = pseries_msi_write_msg, }; + +/* + * Set MSI_FLAG_MSIX_CONTIGUOUS as there is no way to express to + * firmware to request a discontiguous or non-zero based range of + * MSI-X entries. Core code will reject such setup attempts. + */ static struct msi_domain_info pseries_msi_domain_info = { .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | - MSI_FLAG_MULTI_PCI_MSI | MSI_FLAG_PCI_MSIX), + MSI_FLAG_MULTI_PCI_MSI | MSI_FLAG_PCI_MSIX | + MSI_FLAG_MSIX_CONTIGUOUS), .ops = &pseries_pci_msi_domain_ops, .chip = &pseries_pci_msi_irq_chip, }; From patchwork Sat Nov 27 01:20:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693812 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 D9A6AC433EF for ; Sat, 27 Nov 2021 01:46:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=gpS3IeOFXDiz0xQ47W27QMS2JVbUXoKck8Nxo1N/Rjs=; b=RwToQczkd/eD4F 3IHTEUYSKlXfBvNMuUGyX/dLfTrO3vzsSmSL3YrYK74AR3GqxFjTqlkWHfRA75R8neHIUk4kTTh7y zcMiZZBB0vqoF7S6C5YaiFvg+7ZBxTdF+8yEZAcSChrunDX/3BvhsJKupZ4p3FbMszdEvxjzPP+/4 3kHN6qQJz/K96hRz8LZqX6yQtzHbXCiGWylI+HEIuq75bXyrxHJu40rK0ULoXeSBkWItVDWpndWR1 A8q+qGxRqAvKCl8UbLn7t1FgwMMo+CdnvCZFgdcZolYx6+kEcpcrHHC8SPMy9WPo8L4ZtX1aBBRdN B+7oy6t6ppua3BLRJygA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmm4-00CMBa-C5; Sat, 27 Nov 2021 01:45:08 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOc-00C9rq-6b for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:20:58 +0000 Message-ID: <20211126230525.603398433@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976052; 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=OStoQ1k4lhD67pt01NEuqrVFlk3DmZUUJiTL5O5hAPA=; b=2eIPTF3xTaHSNXBIoN6UqqgFfwD0fJ1X1T9rr9vQ/2LfENBf9x4679Mo2RuhP9n8o8RsID PnEAypAhi616GnVO+gsc2xOAtuWMr4zBjlVOnNOOtDv/TFaKyRNAdBMjxKS/4JHJVMVGoZ WM12EP6pWvV4ZsO7GlLDsIBUy/ezmXIF/1d3ZFPMW5x3TBf0XpZh+FYDE99NYyZWIvzYgi BIqUxvpeT1xK0s9B7mfKENI+tGzeDcNGN6l89hiOEFrHrMdVn8Hh5EnSM+v1FR2r2Ei4Jg 6CiJ/KP+dYdUGxvoPE9tL/6S+FTAN/FPTY7BQjlvqgOjLHOCqkbvJ4Ec+bDtIQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976052; 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=OStoQ1k4lhD67pt01NEuqrVFlk3DmZUUJiTL5O5hAPA=; b=F4GuDJS8gR6I0V15qge6xQbu7oE67MdRvXQDexFplNMXCIE/Lzm4ICs8dJd43R0NUCg4Ec uDsRCB20i1Lf70AQ== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 28/37] genirq/msi: Provide interface to retrieve Linux interrupt number References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:51 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172054_490239_E711429C X-CRM114-Status: GOOD ( 14.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This allows drivers to retrieve the Linux interrupt number instead of fiddling with MSI descriptors. msi_get_virq() returns the Linux interrupt number or 0, __msi_get_virq() has more detailed return codes so pci_irq_vector() can use it as well. Signed-off-by: Thomas Gleixner --- include/linux/msi.h | 16 ++++++++++++++++ kernel/irq/msi.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -169,6 +169,22 @@ static inline bool msi_device_has_proper } #endif +int __msi_get_virq(struct device *dev, unsigned int index); + +/** + * msi_get_virq - Return Linux interrupt number of a MSI interrupt + * @dev: Device to operate on + * @index: MSI interrupt index to look for (0-based) + * + * Return: The Linux interrupt number on success (> 0), 0 if not found + */ +static inline unsigned int msi_get_virq(struct device *dev, unsigned int index) +{ + int ret = __msi_get_virq(dev, index); + + return ret < 0 ? 0 : ret; +} + /* 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) --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -120,6 +120,44 @@ int msi_setup_device_data(struct device return 0; } +/** + * __msi_get_virq - Return Linux interrupt number of a MSI interrupt + * @dev: Device to operate on + * @index: MSI interrupt index to look for (0-based) + * + * Return: The Linux interrupt number on success (> 0) + * -ENODEV when the device is not using MSI + * -ENOENT if no such entry exists + */ +int __msi_get_virq(struct device *dev, unsigned int index) +{ + struct msi_desc *desc; + bool pcimsi; + + if (!dev->msi.data) + return -ENODEV; + + pcimsi = msi_device_has_property(dev, MSI_PROP_PCI_MSI); + + for_each_msi_entry(desc, dev) { + /* PCI-MSI has only one descriptor for multiple interrupts. */ + if (pcimsi) { + if (desc->irq && index < desc->nvec_used) + return desc->irq + index; + break; + } + + /* + * PCI-MSIX and platform MSI use a descriptor per + * interrupt. + */ + if (desc->msi_index == index) + return desc->irq; + } + return -ENOENT; +} +EXPORT_SYMBOL_GPL(__msi_get_virq); + #ifdef CONFIG_SYSFS static ssize_t msi_mode_show(struct device *dev, struct device_attribute *attr, char *buf) From patchwork Sat Nov 27 01:20:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693814 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 31C53C433FE for ; Sat, 27 Nov 2021 01:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=Pmg/xCXwIGCFfq/iNWQ6aahss9O3oNjKIrAZpFRN5HU=; b=kfQsysehd67rh2 A3NAo/roJPL667JfUVink2X+js4tbpeXZkx2jpjL4mzxA0bWxIkP9ArQuATolwdTm9YIDUT1BVSRD bPmxEPssY+8nWleaSnuteL8fYB+jjh8i9QrTdrgK+u3cVvySoT9cd8/uTHQ/uVQ9xd1YPysgJ/HCj ZwU4jFgEXMNFcQY/k/GIc+Uw2od/dunlIWd/G7qs8/kvn3O1mQ+TgA8FbvK/iOwUf27/XkeLs8WDk kfLYgEF6kFQZe1tT+PSFPv90kEfDaW+0p6i3E0SQoILPMFNVhfIi1ZvLt64r4TREIPm/bhMndi1dc nhVB2qD9NEBpP1jEe6Aw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmo3-00CMxQ-L2; Sat, 27 Nov 2021 01:47:12 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOd-00C9uV-Lx for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:21:00 +0000 Message-ID: <20211126230525.660206325@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976053; 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=jDw77Q4/ltoMqqyOm7bRFWOUZ2wme/igWfBiXxqo04E=; b=qcphe6heJuFhgeduvF2Reuv4MsRdWQoJvg2SS3EklVbtfQMCfMHepnA6aswHZvdCNm95JM ZJCqv8yvfhWXCo7kpdm0VoADVoyFe16/31gccfBww5+RFExnu8gp0atniaD79Qi3vDjbQM B5gEnUCbG7Qa7lbqxJ0yxhbiq2ncMH6xYARq59W2DoqThjv7anXdD9w7J/3Wlv23hDx8Yz toD0JJ62PtZRlhLFza6PCjm1YqhAqE6ewJ1sJP2ky4RQBZWSsTJMQv4c9KXKUsUPpmDJtm 2sBBQv12zQ1ocJDsjCrFoBod+HNM+8Kj49KY0bhQYTebAv0oebDz+XXdkGUDnQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976053; 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=jDw77Q4/ltoMqqyOm7bRFWOUZ2wme/igWfBiXxqo04E=; b=rxtvy30SOfVqYPnNL8Cg8Y3TzkF1flw2TNQolZOnFfTQrmh4C6E16aqDKf5J1vmsXVOdd6 srt6OU8S/yzbHDCQ== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 29/37] PCI/MSI: Use __msi_get_virq() in pci_get_vector() References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:53 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172055_970412_D5EC0033 X-CRM114-Status: GOOD ( 10.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use __msi_get_vector() and handle the return values to be compatible. No functional change intended. Signed-off-by: Thomas Gleixner --- drivers/pci/msi/msi.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -1023,28 +1023,13 @@ EXPORT_SYMBOL(pci_free_irq_vectors); */ int pci_irq_vector(struct pci_dev *dev, unsigned int nr) { - if (dev->msix_enabled) { - struct msi_desc *entry; + int irq = __msi_get_virq(&dev->dev, nr); - for_each_pci_msi_entry(entry, dev) { - if (entry->msi_index == nr) - return entry->irq; - } - WARN_ON_ONCE(1); - return -EINVAL; + switch (irq) { + case -ENODEV: return !nr ? dev->irq : -EINVAL; + case -ENOENT: return -EINVAL; } - - if (dev->msi_enabled) { - struct msi_desc *entry = first_pci_msi_entry(dev); - - if (WARN_ON_ONCE(nr >= entry->nvec_used)) - return -EINVAL; - } else { - if (WARN_ON_ONCE(nr > 0)) - return -EINVAL; - } - - return dev->irq + nr; + return irq; } EXPORT_SYMBOL(pci_irq_vector); From patchwork Sat Nov 27 01:20:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693813 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 6CFE3C433EF for ; Sat, 27 Nov 2021 01:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=IUXXqht/UpB6Vq3hgY7NcgDLND0k4ScFc36wluu6mVc=; b=h9NIzOzExDda3n 58oRpLcCrYytv388QCPCKwdjBoGR+E96dQZW3eNNA7je4Y/8VFKB1c+j4lkelYe7yS3ritleZA85h KQgw1FbQ6zOzknOxbXY93IQFtl86itwqQaqB5G/kQpJ+jnn60lqEwXp/LqsyVt5jqGx4t2dvEgpRS ofkj+UCaduwC0CotxUWlHKd4m9iuWQsz6rJyUdgm5UfcoHZHXeHeNpdu+JdW335S2rTCm80FjRMCa yyIYcv4LMXO/i+6oujATGoK0HoWNUdHYipLYEaSZfcTvUG0AR0dQN304CxKLtluLLD263W3iLmRqm hNcGuAzEffzpqG+ixoiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmn3-00CMZf-Qm; Sat, 27 Nov 2021 01:46:10 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOe-00C9wv-UX for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:21:00 +0000 Message-ID: <20211126230525.717286966@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976055; 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=lGMoGQDOkZmCsZ8FLKTWCWUkNfIx3jWYUDFtnIf5/U4=; b=n4VA8TjjZsXj/YLR8uW0WeKOoBPJSySmhK2nKGm0r3Wh2p8sTvTpHR5gWBRHDThXy+K+dz 6AiylyRSUXFPZE/Fj9Yu8hzexzr/5Vw2yAztW+xHXq/pg//du8RtZ7ybxjZR9dd4IuIcGB 4D4E2iaVOqQX0CJ9oXuAhH/CVRrwMhVZVs3EmaM0+PRy5adQKlMMIt8usJp8vrLp+5Cbms gPu4H/k1GfGipgFgV/AnmLnou76HJA9/K5tVVRdabCP22CHIUF0OIf2i0+dwhOgxSHMhyl /ra+9LpdeRyQrOdJsnXGdZ2nkJkpwi8CtVDani6kjk+GeBlx1cer13punBJygw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976055; 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=lGMoGQDOkZmCsZ8FLKTWCWUkNfIx3jWYUDFtnIf5/U4=; b=HXPwrcAtVW7VEWtyIJ2EKcLCItORCI9ek4u23jGiih1EjCqWeRibc3sijpeTPMTbglZvdM 3Vk2GrKWo1Ocw7BQ== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 30/37] PCI/MSI: Simplify pci_irq_get_affinity() References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:54 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172057_208470_A60DDADA X-CRM114-Status: GOOD ( 11.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Replace open coded MSI descriptor chasing and use the proper accessor functions instead. Signed-off-by: Thomas Gleixner --- drivers/pci/msi/msi.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -1040,26 +1040,20 @@ EXPORT_SYMBOL(pci_irq_vector); */ const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr) { - if (dev->msix_enabled) { - struct msi_desc *entry; + int irq = pci_irq_vector(dev, nr); + struct msi_desc *desc; - for_each_pci_msi_entry(entry, dev) { - if (entry->msi_index == nr) - return &entry->affinity->mask; - } - WARN_ON_ONCE(1); + if (WARN_ON_ONCE(irq <= 0)) return NULL; - } else if (dev->msi_enabled) { - struct msi_desc *entry = first_pci_msi_entry(dev); - if (WARN_ON_ONCE(!entry || !entry->affinity || - nr >= entry->nvec_used)) - return NULL; - - return &entry->affinity[nr].mask; - } else { + desc = irq_get_msi_desc(irq); + /* Non-MSI does not have the information handy */ + if (!desc) return cpu_possible_mask; - } + + if (WARN_ON_ONCE(!desc->affinity)) + return NULL; + return &desc->affinity[nr].mask; } EXPORT_SYMBOL(pci_irq_get_affinity); From patchwork Sat Nov 27 01:20:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693815 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 594B9C433F5 for ; Sat, 27 Nov 2021 01:49:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=lsjAVFdPE+mqL7KwBKeruMekLSMntWe+yqRBmqyz2Ew=; b=AjCXiDHJ855NfW nlBLisSo+nEV56mIm22Ui8sZ95KoaIalcSghLtW9dSCxDXeA2ryJK0rVrEjqZLw56ftqG2o9PpX9T jKEiV5dI9IK7+HKmAHLi75aQz/20rUMJkmYcprItObs+qPnNiuMMJk1RXhraDtVHEjq4SlQRDrL95 u0SfQ960yCXbK/l0PslrgPIn4I3Maif8lLo3EXUsXiggeO18dquMAzo8OWF9Z37pZIAmjBqNTcJSP BeSnWlxVFOTlwk6PtsHJhd5pDZ6MCKAZEykuDtF0yZ5h0ZGk18SUTeT7zWb1lZIki5VzbJVNpEUTw 9gSH1SSNrFU2eyzdGLmw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmoe-00CNB8-DQ; Sat, 27 Nov 2021 01:47:49 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOg-00C9yy-JS for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:21:01 +0000 Message-ID: <20211126230525.773495940@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976056; 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=eogXL9InvhL5Ge9dFq9uLhqM//0IPGCuEWm7SufDzqc=; b=myejIsKx/s4jFvxbjthVHIgoXavIjf+Gu8BIqtwZy6S3rEHed0lIoHCNCqdAxMVBXhvVci vmN+kGdRe+sE9E3ZatpiO5JsOF/PMMXs4jPElmCJC06B1TOjsVbxvEGbYJ7jv+XJxYoyiN ttCwX+1auhr2WBWDF6OvDIdgb0d2N19/D72UiwOSy4yUWIfuLlN+9SO+R/J4n+Hr9wXArS /NurND0itm1tiFe2q/oIF7SI7WjP/mwoc0y6gyh09Hise7nYaddoXvr9X6rzDHCzMFYUt3 ieZAaeBdidhneSXrTYpHQCI/95tA6A8/uKlXHnYAF4FrSwak2G1c2ECC0zgQsA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976056; 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=eogXL9InvhL5Ge9dFq9uLhqM//0IPGCuEWm7SufDzqc=; b=ATXrC1SHZ88bPId+XEhx4IACR3McZvO64MyVcdc0+Zzgmo10pbx/qEIh9qqoMo1dMeG7W9 1MX/Q39/iA8FOrDw== 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, Greg Kroah-Hartman , dmaengine@vger.kernel.org, Vinod Koul , Santosh Shilimkar , iommu@lists.linux-foundation.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 31/37] dmaengine: mv_xor_v2: Get rid of msi_desc abuse References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:56 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172058_878848_07A9776B X-CRM114-Status: GOOD ( 12.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Storing a pointer to the MSI descriptor just to keep track of the Linux interrupt number is daft. Use msi_get_virq() instead. Signed-off-by: Thomas Gleixner Cc: dmaengine@vger.kernel.org Cc: Vinod Koul --- drivers/dma/mv_xor_v2.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) --- a/drivers/dma/mv_xor_v2.c +++ b/drivers/dma/mv_xor_v2.c @@ -149,7 +149,7 @@ struct mv_xor_v2_descriptor { * @desc_size: HW descriptor size * @npendings: number of pending descriptors (for which tx_submit has * @hw_queue_idx: HW queue index - * @msi_desc: local interrupt descriptor information + * @irq: The Linux interrupt number * been called, but not yet issue_pending) */ struct mv_xor_v2_device { @@ -168,7 +168,7 @@ struct mv_xor_v2_device { int desc_size; unsigned int npendings; unsigned int hw_queue_idx; - struct msi_desc *msi_desc; + unsigned int irq; }; /** @@ -718,7 +718,6 @@ static int mv_xor_v2_probe(struct platfo int i, ret = 0; struct dma_device *dma_dev; struct mv_xor_v2_sw_desc *sw_desc; - struct msi_desc *msi_desc; BUILD_BUG_ON(sizeof(struct mv_xor_v2_descriptor) != MV_XOR_V2_EXT_DESC_SIZE); @@ -770,14 +769,9 @@ static int mv_xor_v2_probe(struct platfo if (ret) goto disable_clk; - msi_desc = first_msi_entry(&pdev->dev); - if (!msi_desc) { - ret = -ENODEV; - goto free_msi_irqs; - } - xor_dev->msi_desc = msi_desc; + xor_dev->irq = msi_get_virq(&pdev->dev, 0); - ret = devm_request_irq(&pdev->dev, msi_desc->irq, + ret = devm_request_irq(&pdev->dev, xor_dev->irq, mv_xor_v2_interrupt_handler, 0, dev_name(&pdev->dev), xor_dev); if (ret) @@ -892,7 +886,7 @@ static int mv_xor_v2_remove(struct platf xor_dev->desc_size * MV_XOR_V2_DESC_NUM, xor_dev->hw_desq_virt, xor_dev->hw_desq); - devm_free_irq(&pdev->dev, xor_dev->msi_desc->irq, xor_dev); + devm_free_irq(&pdev->dev, xor_dev->irq, xor_dev); platform_msi_domain_free_irqs(&pdev->dev); From patchwork Sat Nov 27 01:20:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693816 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 2BDE9C433EF for ; Sat, 27 Nov 2021 01:50:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=8uBDMAJdgwSNb34JKbztB/givrAP77qmxNhnlxFY2hk=; b=4UaM13glAMcRtB iZF1lVkqMrsalgufuKWDmb78RyCB1AitRgG0RWmYa+e1lTrc7kpsSKoHUVaE6tNtrSe3AhPMvoMGA LbPj51zX0menXpSx5/GWq97UPMzPzHiJz4qPkmaHHW/pYLhw9//7VAZAiWgVJc4oc50nA/HAXFmrP 9ygyc3z6laAglE1VSAPRykAETLpPuVbKHF2awhBLMqrAHqsLlLoL/J40P34tukhulJ4XEWdslBlZm j3WrEWhlcWrGy8JSaNfi6cEfhhzrta2NO3aRm/QynQUnmgPpWLxsbg8zJIP4eqIuaPo2Zs3foc0Kw ThGrD5wxueAUpntAurew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmpS-00CNbU-6U; Sat, 27 Nov 2021 01:48:38 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOi-00CA1j-1O for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:21:03 +0000 Message-ID: <20211126230525.829661122@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976058; 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=nmKGryDQWbwyJR1CDEm4vqqjiZhUfRsqcakAQiYvOSs=; b=YhC4ax0JuqcMYSQhKDn3Ph38Km/cPdPlkFtVPxTJPGUimR1ZvF05bDAovaVqynxIIAURmx K2J/rlmWVxGW74kqUz78kKLEMw5NsUFnFnbQXa1yPzXmY8yWzB1k1z5jTliW+d2y2DNk+I vPh/1f5HnZZDhbRL8RY7zIRWOMV7/sG9pN6/QgJAjkfV9qxQooK9arAAH+WMSBee/qM8WI mPE5jhIqXpTjg6P2iXnIsMmhVPZO26h8yEAPPaTglrVrPeTydVXiH847QmKaN4sR/d5gxk QsQ2KMLmugW8gW0wgiaOWk2JRMACFXEDWhmdb+Eaa7gTbv33Nbgmw3AIuIS3GQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976058; 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=nmKGryDQWbwyJR1CDEm4vqqjiZhUfRsqcakAQiYvOSs=; b=W4YTgPNJcdOOogkDY4ZgUfSeuuDVroUBe8w1sKXqNGcM+B0qz53QXT7nnfXiWVD0r2V8AN c5ibUMtzeNk9s1CQ== 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, Greg Kroah-Hartman , Mark Rutland , Will Deacon , linux-arm-kernel@lists.infradead.org, Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , x86@kernel.org, Vinod Koul , Sinan Kaya Subject: [patch 32/37] perf/smmuv3: Use msi_get_virq() References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:57 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172100_314734_873FA9FF X-CRM114-Status: UNSURE ( 9.97 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Let the core code fiddle with the MSI descriptor retrieval. Signed-off-by: Thomas Gleixner Cc: Mark Rutland Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org --- drivers/perf/arm_smmuv3_pmu.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) --- a/drivers/perf/arm_smmuv3_pmu.c +++ b/drivers/perf/arm_smmuv3_pmu.c @@ -684,7 +684,6 @@ static void smmu_pmu_write_msi_msg(struc static void smmu_pmu_setup_msi(struct smmu_pmu *pmu) { - struct msi_desc *desc; struct device *dev = pmu->dev; int ret; @@ -701,9 +700,7 @@ static void smmu_pmu_setup_msi(struct sm return; } - desc = first_msi_entry(dev); - if (desc) - pmu->irq = desc->irq; + pmu->irq = msi_get_virq(dev, 0); /* Add callback to free MSIs on teardown */ devm_add_action(dev, smmu_pmu_free_msis, dev); From patchwork Sat Nov 27 01:20:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693817 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 8B549C433F5 for ; Sat, 27 Nov 2021 01:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=wlYWoN1qrqMI2RYgnpjEfCMvTcReah1xIAA/7WTFTzc=; b=u4ZyUFYnIe7eLn aoYwDMkC1Kx0+MCv4ZPY0l6B5Hc3ACVaO45IHCI8AkDUu2zI6deJOBSdfMrA9/y1lG9K69DjUFJ68 iQO7R6UHA8zA+T6Cwarum0KM6JhF+95/swHqji/oyHoF30yVOxAWVnqpDlpM5N4ak2OcliZlx80jG y0o8C/BZpoQetj7otZZ2VEGNblKioalixUD3VA3QUWmdyx9pg12t0mLLVqqgmCtaWd6LGwQhiH05U 7iQjmavjla2Yt/AYlmwVSAElzJ/aSFyvR4Cc6j7c1q0gbljy41hTk6wsXKLJINdo+DkpwBBv7nNi/ Pd96SHdwz+PVF5nWXf3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmqF-00CO2O-F8; Sat, 27 Nov 2021 01:49:28 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOj-00CA48-NJ for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:21:04 +0000 Message-ID: <20211126230525.885757679@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976059; 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=95o7iVE7rds7rlpuNcpuaJBc/5SOakXF5BxxMijrxrA=; b=goaKF1wSA1+/7y4h5GqgpO4BbiSCRIyljd/sQQa2corbtU91bgRsrVxzIhvY5uyYT2Gjki 6DmtAAt51GAhwloe/4OwtpziZY/r7v5aHoZDvVfdJweh9RPR6IerYRy6OkOe7qUb1+z2fU ZaIf5OSd6AMRrtiJGGmTUHM33G8FEH7cx61vtE7+yOxGd6MKx3hBMGEwyC+TA7S3lUYAdm Q2VvuuZugzg/jskYqq0fU3g1UZi6aip/AxgS7F4IGU2Lgq1LIZ8eVpGw00SmFvhd1nJuTj MGGm81zCO2NrWertS4f0B2nDLDA4LSlJ6P46BjuLj9ojAXkRCZh60IWpbFYf9g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976059; 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=95o7iVE7rds7rlpuNcpuaJBc/5SOakXF5BxxMijrxrA=; b=uJPUFv51PJFviys6/lLVGdiN0T/4Zfhmlq4E06A1m7J/COhYnWZndOqiR/SH7DLJTsLxXh w+0PTNvaQSyItFBQ== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 33/37] iommu/arm-smmu-v3: Use msi_get_virq() References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:59 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172101_994391_4184E826 X-CRM114-Status: UNSURE ( 9.51 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Let the core code fiddle with the MSI descriptor retrieval. Signed-off-by: Thomas Gleixner Tested-by: Robin Murphy --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3154,7 +3154,6 @@ static void arm_smmu_write_msi_msg(struc static void arm_smmu_setup_msis(struct arm_smmu_device *smmu) { - struct msi_desc *desc; int ret, nvec = ARM_SMMU_MAX_MSIS; struct device *dev = smmu->dev; @@ -3182,21 +3181,9 @@ static void arm_smmu_setup_msis(struct a return; } - for_each_msi_entry(desc, dev) { - switch (desc->msi_index) { - case EVTQ_MSI_INDEX: - smmu->evtq.q.irq = desc->irq; - break; - case GERROR_MSI_INDEX: - smmu->gerr_irq = desc->irq; - break; - case PRIQ_MSI_INDEX: - smmu->priq.q.irq = desc->irq; - break; - default: /* Unknown */ - continue; - } - } + smmu->evtq.q.irq = msi_get_virq(dev, EVTQ_MSI_INDEX); + smmu->gerr_irq = msi_get_virq(dev, GERROR_MSI_INDEX); + smmu->priq.q.irq = msi_get_virq(dev, PRIQ_MSI_INDEX); /* Add callback to free MSIs on teardown */ devm_add_action(dev, arm_smmu_free_msis, dev); From patchwork Sat Nov 27 01:21:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693818 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 DBC7AC433EF for ; Sat, 27 Nov 2021 01:52:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=CqcCsh1LmpOaiilGXvYdtbyidkFY2hdo4Y9tJyoZjSA=; b=GC9I8ibcmaFdqe Z7Cv7WX98hGxBrIgme0AHlbRymh5xp0HqD4vGPQQ3cubdHkeq7ScQCjQOzYVHAMNmSBza06MSN7jF cXClhcRwWUa6XnSDtzlaM0xn7SMmPC6QjspVqqX27VGWfPmv6UVCCHV7ACpvD+oAeU2fJi6Z+pe7N YgC1Uv06eqnBjczWwxs0ztJ0E685Ze6oCixf6kK+YSTJGO03l9EbRDJBr1XaFNACZpatlxA8A7XPt PBXjqjQSlegQSRHKgm46CDMFWs6y3cjSU/ePF8XJ2uoAHyG/2/BUNInIrWNHByt20nZ12Ley7WiHk 1OUeIn0NdPs75kQATufw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmr4-00COMV-U6; Sat, 27 Nov 2021 01:50:19 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOl-00CA7O-W6 for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:21:06 +0000 Message-ID: <20211126230525.942768779@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976061; 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=p/qcF7fn4OxVhWuReK+wMgikFJMOqHr6o9RPZFmkX94=; b=itabOq2/goNmVeWHFB5h7LUlNokKCJwhxIqr2TNaqXG3rE+msDvgxF3R8d+lDMQdpFLFMB 2rvVZrnGq081hsY5QdIU8qQUR+To3tHna4hN0zbgKDRe26TS0apCiD1wKBPybv2NLvQ1a/ jA0wq+xDF/7BTVvOy7SzFYqYzOVwwz4O59fL4fmQfvywkIdw6RdHxwDugA0I2P+ohTzCH/ DszOAxkAAjMZ/U0A9nyPD2gEp8K6D3Z+7NgnuGuS9kvWeuiUZua5kcgjgMzJuSNbAQEkTu B1FubAjMmOJK1BcNvleDd2vf7jIIYRBftQir9TNTQwPabnrpSIpj7WCZOws6wQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976061; 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=p/qcF7fn4OxVhWuReK+wMgikFJMOqHr6o9RPZFmkX94=; b=p5ubsedSnSr6AcduksWDB4MJEZscofhI5yEISG/LcUOqL4vr2FI2SDc+JOX/1dXjavNAQK l3vnrVRpfKqxIqCA== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 34/37] mailbox: bcm-flexrm-mailbox: Rework MSI interrupt handling References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:21:01 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172104_267788_F4490547 X-CRM114-Status: GOOD ( 10.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org No point in retrieving the MSI descriptors. Just query the Linux interrupt number. Signed-off-by: Thomas Gleixner --- drivers/mailbox/bcm-flexrm-mailbox.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) --- a/drivers/mailbox/bcm-flexrm-mailbox.c +++ b/drivers/mailbox/bcm-flexrm-mailbox.c @@ -1497,7 +1497,6 @@ static int flexrm_mbox_probe(struct plat int index, ret = 0; void __iomem *regs; void __iomem *regs_end; - struct msi_desc *desc; struct resource *iomem; struct flexrm_ring *ring; struct flexrm_mbox *mbox; @@ -1608,10 +1607,8 @@ static int flexrm_mbox_probe(struct plat goto fail_destroy_cmpl_pool; /* Save alloced IRQ numbers for each ring */ - for_each_msi_entry(desc, dev) { - ring = &mbox->rings[desc->msi_index]; - ring->irq = desc->irq; - } + for (index = 0; index < mbox->num_rings; index++) + mbox->rings[index].irq = msi_get_virq(dev, index); /* Check availability of debugfs */ if (!debugfs_initialized()) From patchwork Sat Nov 27 01:21:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693819 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 3E980C433EF for ; Sat, 27 Nov 2021 01:52:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=x74/j3802b+oP8OhSBlGd72gGxNkuhi6Vf8B7iUScDE=; b=qXAg7HSHgA/AdO WUBrpi7+OnkLtZTgRAT3xU1fpqQVhRGAlUGOxYysyQoeh5DE9VKPnSeNDy53b85bu3eEZrLitE7XG cXOlMHoH1MfiwkcxLnnAR3v+ii6rQ0haf4mlMUtfRA556tW2MEgNHVGvfY+HdrOmmEj+r5u+xmmPb y3wKRbZLoUCzfpU2Vvy5hOn/+UZyoC/kFag1fVSyW9XdYGsy/anAk5xTni0Rdqmq3+SUlWPYp0XSu OoFCJrik6GlP6sgMaqlTlqJGbazmS+5TE+74UjTmxk/4YygTs1ykpp6QVezHGCx6FxVvJ3p+UNLAl 0N11gSuCLQG66aBf27fg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmrm-00COfh-1G; Sat, 27 Nov 2021 01:51:02 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOm-00CA8Z-QZ for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:21:08 +0000 Message-ID: <20211126230525.998430251@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976063; 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=lIJfdgdWXqPpzoX+GA8322PEONJgAj7Dsfk3jEgUh34=; b=cIJPIRHTYqu1EO5Rt8Fauw4xwn4X2GJg0mKwjSz655pKJkUJRTbuCUG/OywsMu5TXYfYQy /lICbrbJdWZyI067qDzJfGXnzi7QyLQMR8aO4XFunuVncL5xw3Jsk9GFx+om8UHTTEcptC 2/1/cJ4hoHhCSgD/l/YgDix+RSMOB3Z6Kuzig5ObesK3zKwbwYdU8CSXCztFxG7LhHmJlu Y+7beIWqygt1ClhQFDBNwX4J1DSu23A1DO9cz4DupbPhdgHD9HbUAiOxFMEN0VMJ3gu44y nVu8UDWODkE1WnYQIcWyTJGse0OplSmToAQy12Qna7YQSO97EKnsWGsfdYr0Cg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976063; 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=lIJfdgdWXqPpzoX+GA8322PEONJgAj7Dsfk3jEgUh34=; b=A6V2SaXvDCDPbEJ/IMuFEbN+Qjshk6gm56Vi0S1DiYCVz/Je3j4vZ3qep7SaEU7DlxeSyP KTFVKxqHTSTiySAw== 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, Greg Kroah-Hartman , Stuart Yoder , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 35/37] bus: fsl-mc: fsl-mc-allocator: Rework MSI handling References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:21:02 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172105_255896_1235AC18 X-CRM114-Status: GOOD ( 19.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Storing a pointer to the MSI descriptor just to track the Linux interrupt number is daft. Just store the interrupt number and be done with it. Signed-off-by: Thomas Gleixner Cc: Stuart Yoder --- drivers/bus/fsl-mc/dprc-driver.c | 8 ++++---- drivers/bus/fsl-mc/fsl-mc-allocator.c | 9 ++------- drivers/bus/fsl-mc/fsl-mc-msi.c | 6 +++--- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 4 ++-- drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c | 4 +--- drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 5 ++--- drivers/soc/fsl/dpio/dpio-driver.c | 8 ++++---- drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c | 4 ++-- include/linux/fsl/mc.h | 4 ++-- 9 files changed, 22 insertions(+), 30 deletions(-) --- a/drivers/bus/fsl-mc/dprc-driver.c +++ b/drivers/bus/fsl-mc/dprc-driver.c @@ -400,7 +400,7 @@ static irqreturn_t dprc_irq0_handler_thr struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); struct fsl_mc_io *mc_io = mc_dev->mc_io; - struct msi_desc *msi_desc = mc_dev->irqs[0]->msi_desc; + int irq = mc_dev->irqs[0]->virq; dev_dbg(dev, "DPRC IRQ %d triggered on CPU %u\n", irq_num, smp_processor_id()); @@ -409,7 +409,7 @@ static irqreturn_t dprc_irq0_handler_thr return IRQ_HANDLED; mutex_lock(&mc_bus->scan_mutex); - if (!msi_desc || msi_desc->irq != (u32)irq_num) + if (irq != (u32)irq_num) goto out; status = 0; @@ -521,7 +521,7 @@ static int register_dprc_irq_handler(str * function that programs the MSI physically in the device */ error = devm_request_threaded_irq(&mc_dev->dev, - irq->msi_desc->irq, + irq->virq, dprc_irq0_handler, dprc_irq0_handler_thread, IRQF_NO_SUSPEND | IRQF_ONESHOT, @@ -771,7 +771,7 @@ static void dprc_teardown_irq(struct fsl (void)disable_dprc_irq(mc_dev); - devm_free_irq(&mc_dev->dev, irq->msi_desc->irq, &mc_dev->dev); + devm_free_irq(&mc_dev->dev, irq->virq, &mc_dev->dev); fsl_mc_free_irqs(mc_dev); } --- a/drivers/bus/fsl-mc/fsl-mc-allocator.c +++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c @@ -350,7 +350,6 @@ int fsl_mc_populate_irq_pool(struct fsl_ unsigned int irq_count) { unsigned int i; - struct msi_desc *msi_desc; struct fsl_mc_device_irq *irq_resources; struct fsl_mc_device_irq *mc_dev_irq; int error; @@ -388,16 +387,12 @@ int fsl_mc_populate_irq_pool(struct fsl_ mc_dev_irq->resource.type = res_pool->type; mc_dev_irq->resource.data = mc_dev_irq; mc_dev_irq->resource.parent_pool = res_pool; + mc_dev_irq->virq = msi_get_virq(&mc_bus_dev->dev, i); + mc_dev_irq->resource.id = mc_dev_irq->virq; INIT_LIST_HEAD(&mc_dev_irq->resource.node); list_add_tail(&mc_dev_irq->resource.node, &res_pool->free_list); } - for_each_msi_entry(msi_desc, &mc_bus_dev->dev) { - mc_dev_irq = &irq_resources[msi_desc->msi_index]; - mc_dev_irq->msi_desc = msi_desc; - mc_dev_irq->resource.id = msi_desc->irq; - } - res_pool->max_count = irq_count; res_pool->free_count = irq_count; mc_bus->irq_resources = irq_resources; --- a/drivers/bus/fsl-mc/fsl-mc-msi.c +++ b/drivers/bus/fsl-mc/fsl-mc-msi.c @@ -58,11 +58,11 @@ static void fsl_mc_msi_update_dom_ops(st } static void __fsl_mc_msi_write_msg(struct fsl_mc_device *mc_bus_dev, - struct fsl_mc_device_irq *mc_dev_irq) + struct fsl_mc_device_irq *mc_dev_irq, + struct msi_desc *msi_desc) { int error; struct fsl_mc_device *owner_mc_dev = mc_dev_irq->mc_dev; - struct msi_desc *msi_desc = mc_dev_irq->msi_desc; struct dprc_irq_cfg irq_cfg; /* @@ -129,7 +129,7 @@ static void fsl_mc_msi_write_msg(struct /* * Program the MSI (paddr, value) pair in the device: */ - __fsl_mc_msi_write_msg(mc_bus_dev, mc_dev_irq); + __fsl_mc_msi_write_msg(mc_bus_dev, mc_dev_irq, msi_desc); } static void fsl_mc_msi_update_chip_ops(struct msi_domain_info *info) --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -4246,7 +4246,7 @@ static int dpaa2_eth_setup_irqs(struct f } irq = ls_dev->irqs[0]; - err = devm_request_threaded_irq(&ls_dev->dev, irq->msi_desc->irq, + err = devm_request_threaded_irq(&ls_dev->dev, irq->virq, NULL, dpni_irq0_handler_thread, IRQF_NO_SUSPEND | IRQF_ONESHOT, dev_name(&ls_dev->dev), &ls_dev->dev); @@ -4273,7 +4273,7 @@ static int dpaa2_eth_setup_irqs(struct f return 0; free_irq: - devm_free_irq(&ls_dev->dev, irq->msi_desc->irq, &ls_dev->dev); + devm_free_irq(&ls_dev->dev, irq->virq, &ls_dev->dev); free_mc_irq: fsl_mc_free_irqs(ls_dev); --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c @@ -129,7 +129,6 @@ static irqreturn_t dpaa2_ptp_irq_handler static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev) { struct device *dev = &mc_dev->dev; - struct fsl_mc_device_irq *irq; struct ptp_qoriq *ptp_qoriq; struct device_node *node; void __iomem *base; @@ -177,8 +176,7 @@ static int dpaa2_ptp_probe(struct fsl_mc goto err_unmap; } - irq = mc_dev->irqs[0]; - ptp_qoriq->irq = irq->msi_desc->irq; + ptp_qoriq->irq = mc_dev->irqs[0]->virq; err = request_threaded_irq(ptp_qoriq->irq, NULL, dpaa2_ptp_irq_handler_thread, --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -1553,8 +1553,7 @@ static int dpaa2_switch_setup_irqs(struc irq = sw_dev->irqs[DPSW_IRQ_INDEX_IF]; - err = devm_request_threaded_irq(dev, irq->msi_desc->irq, - NULL, + err = devm_request_threaded_irq(dev, irq->virq, NULL, dpaa2_switch_irq0_handler_thread, IRQF_NO_SUSPEND | IRQF_ONESHOT, dev_name(dev), dev); @@ -1580,7 +1579,7 @@ static int dpaa2_switch_setup_irqs(struc return 0; free_devm_irq: - devm_free_irq(dev, irq->msi_desc->irq, dev); + devm_free_irq(dev, irq->virq, dev); free_irq: fsl_mc_free_irqs(sw_dev); return err; --- a/drivers/soc/fsl/dpio/dpio-driver.c +++ b/drivers/soc/fsl/dpio/dpio-driver.c @@ -88,7 +88,7 @@ static void unregister_dpio_irq_handlers irq = dpio_dev->irqs[0]; /* clear the affinity hint */ - irq_set_affinity_hint(irq->msi_desc->irq, NULL); + irq_set_affinity_hint(irq->virq, NULL); } static int register_dpio_irq_handlers(struct fsl_mc_device *dpio_dev, int cpu) @@ -98,7 +98,7 @@ static int register_dpio_irq_handlers(st irq = dpio_dev->irqs[0]; error = devm_request_irq(&dpio_dev->dev, - irq->msi_desc->irq, + irq->virq, dpio_irq_handler, 0, dev_name(&dpio_dev->dev), @@ -111,10 +111,10 @@ static int register_dpio_irq_handlers(st } /* set the affinity hint */ - if (irq_set_affinity_hint(irq->msi_desc->irq, cpumask_of(cpu))) + if (irq_set_affinity_hint(irq->virq, cpumask_of(cpu))) dev_err(&dpio_dev->dev, "irq_set_affinity failed irq %d cpu %d\n", - irq->msi_desc->irq, cpu); + irq->virq, cpu); return 0; } --- a/drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c +++ b/drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c @@ -67,7 +67,7 @@ static int vfio_set_trigger(struct vfio_ int hwirq; int ret; - hwirq = vdev->mc_dev->irqs[index]->msi_desc->irq; + hwirq = vdev->mc_dev->irqs[index]->virq; if (irq->trigger) { free_irq(hwirq, irq); kfree(irq->name); @@ -137,7 +137,7 @@ static int vfio_fsl_mc_set_irq_trigger(s return vfio_set_trigger(vdev, index, fd); } - hwirq = vdev->mc_dev->irqs[index]->msi_desc->irq; + hwirq = vdev->mc_dev->irqs[index]->virq; irq = &vdev->mc_irqs[index]; --- a/include/linux/fsl/mc.h +++ b/include/linux/fsl/mc.h @@ -91,13 +91,13 @@ struct fsl_mc_resource { /** * struct fsl_mc_device_irq - MC object device message-based interrupt - * @msi_desc: pointer to MSI descriptor allocated by fsl_mc_msi_alloc_descs() + * @virq: Linux virtual interrupt number * @mc_dev: MC object device that owns this interrupt * @dev_irq_index: device-relative IRQ index * @resource: MC generic resource associated with the interrupt */ struct fsl_mc_device_irq { - struct msi_desc *msi_desc; + unsigned int virq; struct fsl_mc_device *mc_dev; u8 dev_irq_index; struct fsl_mc_resource resource; From patchwork Sat Nov 27 01:21:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693820 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 9F6EAC433EF for ; Sat, 27 Nov 2021 01:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=Wl/KhtmlZB4bQsr3SAX9ejK47MXDOa3wX4YtkVWea6M=; b=FIHvYcz91q/6UI euYTcqU912W0pXtBy+X3ynyq1SrGCFQTBQvBRHyHAqxryywIuNTSx2TdI3abQjgYh4PCKMuc8W1hM 7Sq79454kx+7Y/7ekDmfM/hCCs6FX8lAak6uh4SPqtUN9H1FWhQ56YzysBfV8D4E1DfWQynDk6Yfq pA0Vi4HWWDoNeGNCG3/dtthoA3Pc3C8wyaXJSnwyv9vl6pJoVmHjYBkej2dWv8o4qs5eXS1OjwRc4 ESMmaAMeqY30LtofyFvt/1UB0XmughPnlkuAUAns9h90r302v72CPjjlu4jByCyRjQ22PB3lv0wBv tsZxxYnUX0OGDpbrZ4/g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmsg-00CP1O-G2; Sat, 27 Nov 2021 01:51:59 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOo-00CABF-NJ for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:21:10 +0000 Message-ID: <20211126230526.055361768@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976064; 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=WWQWE9G0qlaU80ha+cNMAdUuPV31PLPDySvVFyYiVGo=; b=xUwSsNqAnUhHh5aYgCIQlCl8zSLf1RILNIO8kcuCPB4FGCVH4DU5+9C+Io5q6BY59jYPhK em5vg+Hld/GrFdb7sMTGdiNEFqacTa+TQ7RXnPU63d0pOYQqkpz+RDTwjfsLo10cZqg9UL qYAiCAcydY+f3nWLkUOxwg1DJkRnapC8pF6JAL3/85Trx3LyzmgXJff7BxGARqEfwzGVYm uBa1iAGskoWow+4plos7k+QLDLun5IHFbAHPl70dNActZYPWTFr6efMCwf3JD8Ww/exMlc mKvF9zM0tia1MLH5+6fBva5bKgeMaBZ+Bv5+xwvyfK9RtoEeK3Bm/FLg/vln+w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976064; 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=WWQWE9G0qlaU80ha+cNMAdUuPV31PLPDySvVFyYiVGo=; b=1ZZIOOBFZZrFjkiwh98RxAGL7tpchaBa0H0RxcUy3ED96fy23NgIE9SfOys1JamsiaQ5TL 1UkKMxv5UIAjvyBA== 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, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: [patch 36/37] soc: ti: ti_sci_inta_msi: Get rid of ti_sci_inta_msi_get_virq() References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:21:04 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172107_134904_4E22727B X-CRM114-Status: GOOD ( 14.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Just use the core function msi_get_virq(). Signed-off-by: Thomas Gleixner --- drivers/dma/ti/k3-udma-private.c | 6 ++---- drivers/dma/ti/k3-udma.c | 10 ++++------ drivers/soc/ti/k3-ringacc.c | 2 +- drivers/soc/ti/ti_sci_inta_msi.c | 12 ------------ include/linux/soc/ti/ti_sci_inta_msi.h | 1 - 5 files changed, 7 insertions(+), 24 deletions(-) --- a/drivers/dma/ti/k3-udma-private.c +++ b/drivers/dma/ti/k3-udma-private.c @@ -168,8 +168,7 @@ int xudma_pktdma_tflow_get_irq(struct ud { const struct udma_oes_offsets *oes = &ud->soc_data->oes; - return ti_sci_inta_msi_get_virq(ud->dev, udma_tflow_id + - oes->pktdma_tchan_flow); + return msi_get_virq(ud->dev, udma_tflow_id + oes->pktdma_tchan_flow); } EXPORT_SYMBOL(xudma_pktdma_tflow_get_irq); @@ -177,7 +176,6 @@ int xudma_pktdma_rflow_get_irq(struct ud { const struct udma_oes_offsets *oes = &ud->soc_data->oes; - return ti_sci_inta_msi_get_virq(ud->dev, udma_rflow_id + - oes->pktdma_rchan_flow); + return msi_get_virq(ud->dev, udma_rflow_id + oes->pktdma_rchan_flow); } EXPORT_SYMBOL(xudma_pktdma_rflow_get_irq); --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -2313,8 +2313,7 @@ static int udma_alloc_chan_resources(str /* Event from UDMA (TR events) only needed for slave TR mode channels */ if (is_slave_direction(uc->config.dir) && !uc->config.pkt_mode) { - uc->irq_num_udma = ti_sci_inta_msi_get_virq(ud->dev, - irq_udma_idx); + uc->irq_num_udma = msi_get_virq(ud->dev, irq_udma_idx); if (uc->irq_num_udma <= 0) { dev_err(ud->dev, "Failed to get udma irq (index: %u)\n", irq_udma_idx); @@ -2486,7 +2485,7 @@ static int bcdma_alloc_chan_resources(st uc->psil_paired = true; } - uc->irq_num_ring = ti_sci_inta_msi_get_virq(ud->dev, irq_ring_idx); + uc->irq_num_ring = msi_get_virq(ud->dev, irq_ring_idx); if (uc->irq_num_ring <= 0) { dev_err(ud->dev, "Failed to get ring irq (index: %u)\n", irq_ring_idx); @@ -2503,8 +2502,7 @@ static int bcdma_alloc_chan_resources(st /* Event from BCDMA (TR events) only needed for slave channels */ if (is_slave_direction(uc->config.dir)) { - uc->irq_num_udma = ti_sci_inta_msi_get_virq(ud->dev, - irq_udma_idx); + uc->irq_num_udma = msi_get_virq(ud->dev, irq_udma_idx); if (uc->irq_num_udma <= 0) { dev_err(ud->dev, "Failed to get bcdma irq (index: %u)\n", irq_udma_idx); @@ -2672,7 +2670,7 @@ static int pktdma_alloc_chan_resources(s uc->psil_paired = true; - uc->irq_num_ring = ti_sci_inta_msi_get_virq(ud->dev, irq_ring_idx); + uc->irq_num_ring = msi_get_virq(ud->dev, irq_ring_idx); if (uc->irq_num_ring <= 0) { dev_err(ud->dev, "Failed to get ring irq (index: %u)\n", irq_ring_idx); --- a/drivers/soc/ti/k3-ringacc.c +++ b/drivers/soc/ti/k3-ringacc.c @@ -647,7 +647,7 @@ int k3_ringacc_get_ring_irq_num(struct k if (!ring) return -EINVAL; - irq_num = ti_sci_inta_msi_get_virq(ring->parent->dev, ring->ring_id); + irq_num = msi_get_virq(ring->parent->dev, ring->ring_id); if (irq_num <= 0) irq_num = -EINVAL; return irq_num; --- a/drivers/soc/ti/ti_sci_inta_msi.c +++ b/drivers/soc/ti/ti_sci_inta_msi.c @@ -148,15 +148,3 @@ void ti_sci_inta_msi_domain_free_irqs(st ti_sci_inta_msi_free_descs(dev); } EXPORT_SYMBOL_GPL(ti_sci_inta_msi_domain_free_irqs); - -unsigned int ti_sci_inta_msi_get_virq(struct device *dev, u32 dev_index) -{ - struct msi_desc *desc; - - for_each_msi_entry(desc, dev) - if (desc->msi_index == dev_index) - return desc->irq; - - return -ENODEV; -} -EXPORT_SYMBOL_GPL(ti_sci_inta_msi_get_virq); --- a/include/linux/soc/ti/ti_sci_inta_msi.h +++ b/include/linux/soc/ti/ti_sci_inta_msi.h @@ -18,6 +18,5 @@ struct irq_domain struct irq_domain *parent); int ti_sci_inta_msi_domain_alloc_irqs(struct device *dev, struct ti_sci_resource *res); -unsigned int ti_sci_inta_msi_get_virq(struct device *dev, u32 index); void ti_sci_inta_msi_domain_free_irqs(struct device *dev); #endif /* __INCLUDE_LINUX_IRQCHIP_TI_SCI_INTA_H */ From patchwork Sat Nov 27 01:21:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12693821 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 44C26C433F5 for ; Sat, 27 Nov 2021 01:54:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=JoDY1ddE6g2ki0AsW59NhBGD8T5yjcLvYlalEACY4fE=; b=BrD618Npu++GIY 69ODffQTE/Em+VbjaTh3GJjGshHrOYhNJqNGna/NQKp9RZKKuxdagezpi1HDItJ2GTQnlw4UwCAYv 56TXBHem3QOtXDxmfYpwat+qhpR/wlCPAqb5QhwuGTE543fflh/n1lr3aPC5ux2HYXTPyDa1c7f8d dyTKbPRWCEq6QLGh03lWTLB1gBLLVVTzr/cfQSSz/ZTn2VozL8K/rVuyXAth0l5moq6r3S6IZPqiZ jjm/qT7ydGvIkRy8g6id74H9/YOAFNGIDyFvunHxvGeyUHZYEhe4kp0MbHMl5a5YlCXxprvv9A5vD hgKPG4Nb0MWJRilCusOQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmte-00CPOt-0E; Sat, 27 Nov 2021 01:52:58 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqmOq-00CADZ-0M for linux-arm-kernel@lists.infradead.org; Sat, 27 Nov 2021 01:21:11 +0000 Message-ID: <20211126230526.111397616@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976066; 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=t/L3bect6Otcyaj5o3pOpna8DPyPttA1iOCagOeFNh8=; b=uPVGIEZysuDFheLAvBLfc+Jubu4K+kqJiowq/57mk6FzMxJ3uWAZyEPOEfrRqntesLbzgB ZLIV/Mki40we1MaJOaEw4PJuN19pmujdZoE907RAhaC36FrJ7XigqxurbZoSzM1TZXZ4zQ n5Xwt3jzWxKXYCzV8CR2AQIVjokb1ctZlPPb92L0b3ELj4cF1sNV2gl9KLgiNqeYkycYpF uJNdPayzyxqDRwGilHzJoTqxwCj8zTYKXYxdx7PQ6TbHZt8LonyjKCEkBekluNXPyjfqBH Xptpv7EI5Kv6VGetsY+zwItYkI/2KdNAwod1polDssznrN+AWr8LUMqXWiYpPA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976066; 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=t/L3bect6Otcyaj5o3pOpna8DPyPttA1iOCagOeFNh8=; b=5GlBKX2jwhx+qkHdtSvbhhsoVE/Kwc8V/8tOf3y1uo87BiuMCpniEuDny/pl1Ro5kOW7Kr fkYICB6MZllCxjDg== 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, Greg Kroah-Hartman , Sinan Kaya , dmaengine@vger.kernel.org, Santosh Shilimkar , iommu@lists.linux-foundation.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon Subject: [patch 37/37] dmaengine: qcom_hidma: Cleanup MSI handling References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:21:05 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211126_172108_257541_790F628E X-CRM114-Status: GOOD ( 14.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There is no reason to walk the MSI descriptors to retrieve the interrupt number for a device. Use msi_get_virq() instead. Signed-off-by: Thomas Gleixner Cc: Sinan Kaya Cc: dmaengine@vger.kernel.org Acked-by: Sinan Kaya --- drivers/dma/qcom/hidma.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) --- a/drivers/dma/qcom/hidma.c +++ b/drivers/dma/qcom/hidma.c @@ -678,11 +678,13 @@ static void hidma_free_msis(struct hidma { #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN struct device *dev = dmadev->ddev.dev; - struct msi_desc *desc; + int i, virq; - /* free allocated MSI interrupts above */ - for_each_msi_entry(desc, dev) - devm_free_irq(dev, desc->irq, &dmadev->lldev); + for (i = 0; i < HIDMA_MSI_INTS; i++) { + virq = msi_get_virq(dev, i); + if (virq) + devm_free_irq(dev, virq, &dmadev->lldev); + } platform_msi_domain_free_irqs(dev); #endif @@ -692,45 +694,37 @@ static int hidma_request_msi(struct hidm struct platform_device *pdev) { #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN - int rc; - struct msi_desc *desc; - struct msi_desc *failed_desc = NULL; + int rc, i, virq; rc = platform_msi_domain_alloc_irqs(&pdev->dev, HIDMA_MSI_INTS, hidma_write_msi_msg); if (rc) return rc; - for_each_msi_entry(desc, &pdev->dev) { - if (!desc->msi_index) - dmadev->msi_virqbase = desc->irq; - - rc = devm_request_irq(&pdev->dev, desc->irq, + for (i = 0; i < HIDMA_MSI_INTS; i++) { + virq = msi_get_virq(&pdev->dev, i); + rc = devm_request_irq(&pdev->dev, virq, hidma_chirq_handler_msi, 0, "qcom-hidma-msi", &dmadev->lldev); - if (rc) { - failed_desc = desc; + if (rc) break; - } + if (!i) + dmadev->msi_virqbase = virq; } if (rc) { /* free allocated MSI interrupts above */ - for_each_msi_entry(desc, &pdev->dev) { - if (desc == failed_desc) - break; - devm_free_irq(&pdev->dev, desc->irq, - &dmadev->lldev); + for (--i; i >= 0; i--) { + virq = msi_get_virq(&pdev->dev, i); + devm_free_irq(&pdev->dev, virq, &dmadev->lldev); } + dev_warn(&pdev->dev, + "failed to request MSI irq, falling back to wired IRQ\n"); } else { /* Add callback to free MSIs on teardown */ hidma_ll_setup_irq(dmadev->lldev, true); - } - if (rc) - dev_warn(&pdev->dev, - "failed to request MSI irq, falling back to wired IRQ\n"); return rc; #else return -EINVAL;