genirq/msi, PCI/MSI: Spring cleaning - Part 2
Subsystems (30)
v3 cover genirq/msi, PCI/MSI: Spring cleaning - Part 2
This is the second part of [PCI]MSI refactoring which aims to provide the ability of expanding MSI-X vectors after enabling MSI-X.
This is based on the first part of this work which can be found here:
https://lore.kernel.org/r/[email protected]
and has been applied to:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/msi
This second part has the following important changes:
1) Cleanup of the MSI related data in struct device
struct device contains at the moment various MSI related parts. Some of them (the irq domain pointer) cannot be moved out, but the rest can be allocated on first use. This is in preparation of adding more per device MSI data later on.
2) Consolidation of sysfs handling
As a first step this moves the sysfs pointer from struct msi_desc into the new per device MSI data structure where it belongs.
Later changes will cleanup this code further, but that's not possible at this point.
3) Use PCI device properties instead of looking up MSI descriptors and analysing their data.
4) Provide a function to retrieve the Linux interrupt number for a given MSI index similar to pci_irq_vector() and cleanup all open coded variants.
It's also available from git:
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git msi-v3-part-2
Part 3 of this effort is available on top
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git msi-v3-part-3
Part 3 is not going to be reposted as there is no change vs. V2.
V2 of part 2 can be found here:
https://lore.kernel.org/r/[email protected]
Changes versus V2:
- Use PCI device properties instead of creating a new set - Jason
- Picked up Reviewed/Tested/Acked-by tags as appropriate
Thanks,
tglx
--- arch/powerpc/platforms/cell/axon_msi.c | 5 arch/powerpc/platforms/pseries/msi.c | 38 +--- arch/x86/kernel/apic/msi.c | 5 arch/x86/pci/xen.c | 11 - drivers/base/platform-msi.c | 152 ++++++++----------- 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 | 26 +-- drivers/dma/mv_xor_v2.c | 16 -- drivers/dma/qcom/hidma.c | 44 ++--- drivers/dma/ti/k3-udma-private.c | 6 drivers/dma/ti/k3-udma.c | 14 - drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 23 -- drivers/irqchip/irq-mbigen.c | 4 drivers/irqchip/irq-mvebu-icu.c | 12 - drivers/irqchip/irq-ti-sci-inta.c | 2 drivers/mailbox/bcm-flexrm-mailbox.c | 9 - 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/pci/msi/irqdomain.c | 20 ++ drivers/pci/msi/legacy.c | 6 drivers/pci/msi/msi.c | 133 ++++++---------- drivers/pci/xen-pcifront.c | 2 drivers/perf/arm_smmuv3_pmu.c | 5 drivers/soc/fsl/dpio/dpio-driver.c | 8 - drivers/soc/ti/k3-ringacc.c | 6 drivers/soc/ti/ti_sci_inta_msi.c | 22 -- drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c | 4 include/linux/device.h | 25 ++- include/linux/fsl/mc.h | 4 include/linux/msi.h | 95 ++++-------- include/linux/pci.h | 1 include/linux/soc/ti/ti_sci_inta_msi.h | 1 kernel/irq/msi.c | 158 +++++++++++++++----- 35 files changed, 429 insertions(+), 458 deletions(-)
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH v3 1/35 PCI/MSI: Set pci_dev::msi[x]_enabled early
There are quite some places which retrieve the first MSI descriptor to evaluate whether the setup is for MSI or MSI-X. That's required because pci_dev::msi[x]_enabled is only set when the setup completed successfully.
There is no real reason why msi[x]_enabled can't be set at the beginning of the setup sequence and cleared in case of a failure.
Implement that so the MSI descriptor evaluations can be converted to simple property queries.
---
V3: New patch
--- drivers/pci/msi/msi.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/pci/msi/msi.c +17 -6
@@ -421,11 +421,18 @@ static int msi_capability_init(struct pcstruct msi_desc *entry;int ret; -pci_msi_set_enable (dev,0 );/* Disable MSI during set up */ +/* +* Disable MSI during setup in the hardware, but mark it enabled +* so that setup code can evaluate it. +*/ +pci_msi_set_enable (dev,0 ); + dev->msi_enabled =1 ; entry =msi_setup_entry (dev, nvec, affd); -if (!entry) -return -ENOMEM ; +if (!entry) { + ret = -ENOMEM ; + goto fail; + }/* All MSIs are unmasked by default; mask them all */ pci_msi_mask (entry,msi_multi_mask (entry));
@@ -452,7 +459,6 @@ static int msi_capability_init(struct pc/* Set MSI enabled bits */ pci_intx_for_msi (dev,0 );pci_msi_set_enable (dev,1 ); - dev->msi_enabled =1 ;pcibios_free_irq (dev); dev->irq = entry->irq;
@@ -461,6 +467,8 @@ static int msi_capability_init(struct pc err:pci_msi_unmask (entry,msi_multi_mask (entry));free_msi_irqs (dev); +fail: + dev->msi_enabled =0 ;return ret; }
@@ -589,6 +597,9 @@ static int msix_capability_init(struct ppci_msix_clear_and_set_ctrl (dev,0 ,PCI_MSIX_FLAGS_MASKALL |PCI_MSIX_FLAGS_ENABLE ); +/* Mark it enabled so setup functions can query it */ + dev->msix_enabled =1 ; +pci_read_config_word (dev, dev->msix_cap +PCI_MSIX_FLAGS , &control);/* Request & Map MSI-X table region */ tsize =msix_table_size (control);
@@ -626,9 +637,8 @@ static int msix_capability_init(struct p dev->msi_irq_groups = groups; -/* Set MSI-X enabled bits and unmask the function */ +/* Disable INTX and unmask MSI-X */ pci_intx_for_msi (dev,0 ); - dev->msix_enabled =1 ;pci_msix_clear_and_set_ctrl (dev,PCI_MSIX_FLAGS_MASKALL ,0 );pcibios_free_irq (dev);
@@ -638,6 +648,7 @@ static int msix_capability_init(struct pfree_msi_irqs (dev); out_disable: + dev->msix_enabled =0 ;pci_msix_clear_and_set_ctrl (dev,PCI_MSIX_FLAGS_ENABLE ,0 );return ret;
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [patch V3 01/35] PCI/MSI: Set pci_dev::msi[x]_enabled early
Quoted 10 lines · Thomas Gleixner
There are quite some places which retrieve the first MSI descriptor to evaluate whether the setup is for MSI or MSI-X. That's required because pci_dev::msi[x]_enabled is only set when the setup completed successfully.
There is no real reason why msi[x]_enabled can't be set at the beginning of the setup sequence and cleared in case of a failure.
Implement that so the MSI descriptor evaluations can be converted to simple property queries.
Quoted 6 lines
Signed-off-by Thomas Gleixner <[email protected]>---
V3: New patch--- drivers/pci/msi/msi.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
Jason
[tip: irq/msi] PCI/MSI: Set pci_dev::msi[x]_enabled early
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: c7ecb95ca6a80b29af0f41cc28c58e542637fbc6 Gitweb: https://git.kernel.org/tip/c7ecb95ca6a80b29af0f41cc28c58e542637fbc6 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:18:44 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:37 +01:00
PCI/MSI: Set pci_dev::msi[x]_enabled early
There are quite some places which retrieve the first MSI descriptor to evaluate whether the setup is for MSI or MSI-X. That's required because pci_dev::msi[x]_enabled is only set when the setup completed successfully.
There is no real reason why msi[x]_enabled can't be set at the beginning of the setup sequence and cleared in case of a failure.
Implement that so the MSI descriptor evaluations can be converted to simple property queries.
--- drivers/pci/msi/msi.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/pci/msi/msi.c +17 -6
@@ -421,11 +421,18 @@ static int msi_capability_init(struct pci_dev *dev, int nvec,struct msi_desc *entry;int ret; -pci_msi_set_enable (dev,0 );/* Disable MSI during set up */ +/* +* Disable MSI during setup in the hardware, but mark it enabled +* so that setup code can evaluate it. +*/ +pci_msi_set_enable (dev,0 ); + dev->msi_enabled =1 ; entry =msi_setup_entry (dev, nvec, affd); -if (!entry) -return -ENOMEM ; +if (!entry) { + ret = -ENOMEM ; + goto fail; + }/* All MSIs are unmasked by default; mask them all */ pci_msi_mask (entry,msi_multi_mask (entry));
@@ -452,7 +459,6 @@ static int msi_capability_init(struct pci_dev *dev, int nvec,/* Set MSI enabled bits */ pci_intx_for_msi (dev,0 );pci_msi_set_enable (dev,1 ); - dev->msi_enabled =1 ;pcibios_free_irq (dev); dev->irq = entry->irq;
@@ -461,6 +467,8 @@ static int msi_capability_init(struct pci_dev *dev, int nvec, err:pci_msi_unmask (entry,msi_multi_mask (entry));free_msi_irqs (dev); +fail: + dev->msi_enabled =0 ;return ret; }
@@ -589,6 +597,9 @@ static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,pci_msix_clear_and_set_ctrl (dev,0 ,PCI_MSIX_FLAGS_MASKALL |PCI_MSIX_FLAGS_ENABLE ); +/* Mark it enabled so setup functions can query it */ + dev->msix_enabled =1 ; +pci_read_config_word (dev, dev->msix_cap +PCI_MSIX_FLAGS , &control);/* Request & Map MSI-X table region */ tsize =msix_table_size (control);
@@ -623,9 +634,8 @@ static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries, dev->msi_irq_groups = groups; -/* Set MSI-X enabled bits and unmask the function */ +/* Disable INTX */ pci_intx_for_msi (dev,0 ); - dev->msix_enabled =1 ;/* * Ensure that all table entries are masked to prevent
@@ -645,6 +655,7 @@ out_free:free_msi_irqs (dev); out_disable: + dev->msix_enabled =0 ;pci_msix_clear_and_set_ctrl (dev,PCI_MSIX_FLAGS_MASKALL |PCI_MSIX_FLAGS_ENABLE ,0 );return ret;
PATCH v3 2/35 x86/pci/XEN: Use PCI device property
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
instead of fiddling with MSI descriptors.
---
V3: Use pci_dev->msix_enabled.
--- arch/x86/pci/xen.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
arch/x86/pci/xen.c +2 -7
@@ -399,9 +399,7 @@ static void xen_teardown_msi_irqs(structstatic 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 (dev->msix_enabled)xen_pci_frontend_disable_msix (dev);else xen_pci_frontend_disable_msi (dev);
@@ -417,10 +415,7 @@ static int xen_msi_domain_alloc_irqs(strif (WARN_ON_ONCE (!dev_is_pci (dev)))return -EINVAL ; -if (first_msi_entry (dev)->pci.msi_attrib.is_msix) - type =PCI_CAP_ID_MSIX ; -else - type =PCI_CAP_ID_MSI ; + type =to_pci_dev (dev)->msix_enabled ?PCI_CAP_ID_MSIX :PCI_CAP_ID_MSI ;return xen_msi_ops.setup_msi_irqs (to_pci_dev (dev), nvec, type); }
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [patch V3 02/35] x86/pci/XEN: Use PCI device property
Quoted 4 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
instead of fiddling with MSI descriptors.
Quoted 8 lines
Signed-off-by Thomas Gleixner <[email protected]>Cc Juergen Gross <[email protected]>---
V3: Usepci_dev->msix_enabled.--- arch/x86/pci/xen.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
Jason
[tip: irq/msi] x86/pci/XEN: Use PCI device property
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 0bcfade920804d597888e4181bc315a3c500280d Gitweb: https://git.kernel.org/tip/0bcfade920804d597888e4181bc315a3c500280d Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:18:46 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:37 +01:00
x86/pci/XEN: Use PCI device property
instead of fiddling with MSI descriptors.
--- arch/x86/pci/xen.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
arch/x86/pci/xen.c +2 -7
@@ -399,9 +399,7 @@ static void xen_teardown_msi_irqs(struct pci_dev *dev)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 (dev->msix_enabled)xen_pci_frontend_disable_msix (dev);else xen_pci_frontend_disable_msi (dev);
@@ -417,10 +415,7 @@ static int xen_msi_domain_alloc_irqs(struct irq_domain *domain,if (WARN_ON_ONCE (!dev_is_pci (dev)))return -EINVAL ; -if (first_msi_entry (dev)->pci.msi_attrib.is_msix) - type =PCI_CAP_ID_MSIX ; -else - type =PCI_CAP_ID_MSI ; + type =to_pci_dev (dev)->msix_enabled ?PCI_CAP_ID_MSIX :PCI_CAP_ID_MSI ;return xen_msi_ops.setup_msi_irqs (to_pci_dev (dev), nvec, type); }
PATCH v3 3/35 x86/apic/msi: Use PCI device MSI property
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
instead of fiddling with MSI descriptors.
---
V3: Use pci_dev->msix_enabled - Jason
--- arch/x86/kernel/apic/msi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/x86/kernel/apic/msi.c +1 -4
@@ -160,11 +160,8 @@ static struct irq_chip pci_msi_controlleint 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 (to_pci_dev (dev)->msix_enabled) { arg->type =X86_IRQ_ALLOC_TYPE_PCI_MSIX ; }else { arg->type =X86_IRQ_ALLOC_TYPE_PCI_MSI ;
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [patch V3 03/35] x86/apic/msi: Use PCI device MSI property
Quoted 5 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
instead of fiddling with MSI descriptors.
Signed-off-by Thomas Gleixner <[email protected]>
Re: [patch V3 03/35] x86/apic/msi: Use PCI device MSI property
In reply to Thomas GleixnerQuoted 10 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
instead of fiddling with MSI descriptors.
Signed-off-by Thomas Gleixner <[email protected]>---
V3: Usepci_dev->msix_enabled- Jason--- arch/x86/kernel/apic/msi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Jason
[tip: irq/msi] x86/apic/msi: Use PCI device MSI property
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: b3f82364117a0b7f666ce023195b636c4803c46c Gitweb: https://git.kernel.org/tip/b3f82364117a0b7f666ce023195b636c4803c46c Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:18:47 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:37 +01:00
x86/apic/msi: Use PCI device MSI property
instead of fiddling with MSI descriptors.
--- arch/x86/kernel/apic/msi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/x86/kernel/apic/msi.c +1 -4
@@ -160,11 +160,8 @@ static struct irq_chip pci_msi_controller = {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 (to_pci_dev (dev)->msix_enabled) { arg->type =X86_IRQ_ALLOC_TYPE_PCI_MSIX ; }else { arg->type =X86_IRQ_ALLOC_TYPE_PCI_MSI ;
PATCH v3 4/35 genirq/msi: Use PCI device property
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
to determine whether this is MSI or MSIX instead of consulting MSI descriptors.
---
V2: Use PCI device property - Jason
--- kernel/irq/msi.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
kernel/irq/msi.c +2 -15
@@ -77,21 +77,8 @@ EXPORT_SYMBOL_GPL(get_cached_msi_msg);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 =dev_is_pci (dev) ?to_pci_dev (dev)->msix_enabled : false;return sysfs_emit (buf,"%s\n" , is_msix ?"msix" :"msi" ); }
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [patch V3 04/35] genirq/msi: Use PCI device property
Quoted 11 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
to determine whether this is MSI or MSIX instead of consulting MSI descriptors.
Signed-off-by Thomas Gleixner <[email protected]>---
V2: Use PCI device property - Jason--- kernel/irq/msi.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
Jason
[tip: irq/msi] genirq/msi: Use PCI device property
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 6ef7f771de0182141ef1a0863f27b12963e1d184 Gitweb: https://git.kernel.org/tip/6ef7f771de0182141ef1a0863f27b12963e1d184 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:18:49 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:37 +01:00
genirq/msi: Use PCI device property
to determine whether this is MSI or MSIX instead of consulting MSI descriptors.
--- kernel/irq/msi.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
kernel/irq/msi.c +2 -15
@@ -77,21 +77,8 @@ EXPORT_SYMBOL_GPL(get_cached_msi_msg);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 =dev_is_pci (dev) ?to_pci_dev (dev)->msix_enabled : false;return sysfs_emit (buf,"%s\n" , is_msix ?"msix" :"msi" ); }
PATCH v3 5/35 powerpc/cell/axon_msi: Use PCI device property
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
instead of fiddling with MSI descriptors.
---
V3: Use pci_dev property - Jason
V2: Invoke the function with the correct number of arguments - Andy
--- arch/powerpc/platforms/cell/axon_msi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/powerpc/platforms/cell/axon_msi.c +1 -4
@@ -199,7 +199,6 @@ static struct axon_msic *find_msi_translstatic int setup_msi_msg_address (struct pci_dev *dev,struct msi_msg *msg) {struct device_node *dn; -struct msi_desc *entry;int len;const u32 *prop;
@@ -209,10 +208,8 @@ static int setup_msi_msg_address(structreturn -ENODEV ; } - entry =first_pci_msi_entry (dev); -for (; dn; dn =of_get_next_parent (dn)) { -if (entry->pci.msi_attrib.is_64) { +if (!dev->no_64bit_msi) { prop =of_get_property (dn,"msi-address-64" , &len);if (prop)break ;
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [patch V3 05/35] powerpc/cell/axon_msi: Use PCI device property
Quoted 11 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
instead of fiddling with MSI descriptors.
Signed-off-by Thomas Gleixner <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Michael Ellerman <[email protected]>Cc Benjamin Herrenschmidt <[email protected]>---
Re: [patch V3 05/35] powerpc/cell/axon_msi: Use PCI device property
In reply to Thomas GleixnerQuoted 9 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
instead of fiddling with MSI descriptors.
Signed-off-by Thomas Gleixner <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Michael Ellerman <[email protected]>Cc Benjamin Herrenschmidt <[email protected]>
Quoted 6 lines
---
V3: Usepci_devproperty - Jason
V2: Invoke the function with the correct number of arguments - Andy--- arch/powerpc/platforms/cell/axon_msi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Jason
[tip: irq/msi] powerpc/cell/axon_msi: Use PCI device property
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: d8a530578b166f3ec55d453b8b4b49599bd39884 Gitweb: https://git.kernel.org/tip/d8a530578b166f3ec55d453b8b4b49599bd39884 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:18:51 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:38 +01:00
powerpc/cell/axon_msi: Use PCI device property
instead of fiddling with MSI descriptors.
--- arch/powerpc/platforms/cell/axon_msi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/powerpc/platforms/cell/axon_msi.c +1 -4
@@ -199,7 +199,6 @@ out_error:static int setup_msi_msg_address (struct pci_dev *dev,struct msi_msg *msg) {struct device_node *dn; -struct msi_desc *entry;int len;const u32 *prop;
@@ -209,10 +208,8 @@ static int setup_msi_msg_address(struct pci_dev *dev, struct msi_msg *msg)return -ENODEV ; } - entry =first_pci_msi_entry (dev); -for (; dn; dn =of_get_next_parent (dn)) { -if (entry->pci.msi_attrib.is_64) { +if (!dev->no_64bit_msi) { prop =of_get_property (dn,"msi-address-64" , &len);if (prop)break ;
PATCH v3 6/35 powerpc/pseries/msi: Use PCI device properties
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
instead of fiddling with MSI descriptors.
---
V3: Use pci_dev->msix_enabled - Jason
--- arch/powerpc/platforms/pseries/msi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/powerpc/platforms/pseries/msi.c +1 -2
@@ -448,8 +448,7 @@ static int pseries_msi_ops_prepare(struc int nvec, msi_alloc_info_t *arg) { 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 ; +int type = pdev->msix_enabled ?PCI_CAP_ID_MSIX :PCI_CAP_ID_MSI ;return rtas_prepare_msi_irqs (pdev, nvec, type, arg); }
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [patch V3 06/35] powerpc/pseries/msi: Use PCI device properties
Quoted 4 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
instead of fiddling with MSI descriptors.
Quoted 8 lines
Signed-off-by Thomas Gleixner <[email protected]>Cc Michael Ellerman <[email protected]>---
V3: Usepci_dev->msix_enabled- Jason--- arch/powerpc/platforms/pseries/msi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/powerpc/platforms/pseries/msi.c static int pseries_msi_ops_prepare(struc · line 451
Quoted 9 lines
arch/powerpc/platforms/pseries/msi.c +1
-2@@ -448,8 +448,7 @@ static int pseries_msi_ops_prepare(struc int nvec, msi_alloc_info_t *arg) { 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 ; +int type = pdev->msix_enabled ?PCI_CAP_ID_MSIX :PCI_CAP_ID_MSI ;
Long term it probably makes sense to change the msi_domain_ops so that it has PCI versions of the ops to use in places like this that hard assume PCI is the only kind of MSI at all.
If the non-PCI op isn't provided then things like IMS would be denied
- and the PCI op can directly pass in a pci_dev * so we don't have all these to_pci_devs() in drivers.
Jason
[tip: irq/msi] powerpc/pseries/msi: Use PCI device properties
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: ed1533b5810141aceed2c2a3f13a17736f40e7fa Gitweb: https://git.kernel.org/tip/ed1533b5810141aceed2c2a3f13a17736f40e7fa Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:18:52 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:38 +01:00
powerpc/pseries/msi: Use PCI device properties
instead of fiddling with MSI descriptors.
--- arch/powerpc/platforms/pseries/msi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/powerpc/platforms/pseries/msi.c +1 -2
@@ -448,8 +448,7 @@ static int pseries_msi_ops_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); -int type = desc->pci.msi_attrib.is_msix ?PCI_CAP_ID_MSIX :PCI_CAP_ID_MSI ; +int type = pdev->msix_enabled ?PCI_CAP_ID_MSIX :PCI_CAP_ID_MSI ;return rtas_prepare_msi_irqs (pdev, nvec, type, arg); }
PATCH v3 7/35 device: Move MSI related data into a struct
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
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.
--- 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 | 20 ++++++++++++++------ 7 files changed, 29 insertions(+), 21 deletions(-)
drivers/base/platform-msi.c +6 -6
@@ -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(strucif (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(strucreturn 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(strucplatform_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)
drivers/dma/ti/k3-udma.c +2 -2
@@ -5279,9 +5279,9 @@ static int udma_probe(struct platform_deif (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 ; }
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +1 -1
@@ -3170,7 +3170,7 @@ static void arm_smmu_setup_msis(struct aif (!(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 ; }
drivers/irqchip/irq-mvebu-icu.c +3 -3
@@ -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 ;
drivers/soc/ti/k3-ringacc.c +2 -2
@@ -1356,9 +1356,9 @@ static int k3_ringacc_init(struct platfostruct 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 ; }
drivers/soc/ti/ti_sci_inta_msi.c +1 -1
@@ -140,7 +140,7 @@ EXPORT_SYMBOL_GPL(ti_sci_inta_msi_domainvoid 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);
include/linux/device.h +14 -6
@@ -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
@@ -407,8 +417,8 @@ struct dev_links_info {* @em_pd: device's energy model performance domain * @pins: For device pin management. * See Documentation/driver-api/pin-control.rst for details. +* @msi: MSI related data * @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).
@@ -500,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 struct list_head msi_list;#endif
@@ -666,7 +674,7 @@ static inline void set_dev_node(struct dstatic 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
@@ -675,7 +683,7 @@ static inline struct irq_domain *dev_getstatic 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 }
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [patch V3 07/35] device: Move MSI related data into a struct
Quoted 11 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
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 <[email protected]>Reviewed-by Greg Kroah-Hartman <[email protected]>Reviewed-by Jason Gunthorpe <[email protected]>
[tip: irq/msi] device: Move MSI related data into a struct
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 34fff62827b254f8a43633cc878deb04bf11297c Gitweb: https://git.kernel.org/tip/34fff62827b254f8a43633cc878deb04bf11297c Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:18:54 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:38 +01:00
device: Move MSI related data into a struct
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.
--- 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 | 20 ++++++++++++++------ 7 files changed, 29 insertions(+), 21 deletions(-)
drivers/base/platform-msi.c +6 -6
@@ -210,10 +210,10 @@ platform_msi_alloc_priv_data(struct device *dev, unsigned int nvec,* 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(struct device *dev, unsigned int nvec,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(struct device *dev, unsigned int nvec,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(struct device *dev)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 @@ __platform_msi_create_device_domain(struct device *dev,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)
drivers/dma/ti/k3-udma.c +2 -2
@@ -5279,9 +5279,9 @@ static int udma_probe(struct platform_device *pdev)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 ; }
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +1 -1
@@ -3170,7 +3170,7 @@ static void arm_smmu_setup_msis(struct arm_smmu_device *smmu)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 ; }
drivers/irqchip/irq-mvebu-icu.c +3 -3
@@ -314,12 +314,12 @@ static int mvebu_icu_subset_probe(struct platform_device *pdev) 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 ;
drivers/soc/ti/k3-ringacc.c +2 -2
@@ -1356,9 +1356,9 @@ static int k3_ringacc_init(struct platform_device *pdev,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 ; }
drivers/soc/ti/ti_sci_inta_msi.c +1 -1
@@ -140,7 +140,7 @@ EXPORT_SYMBOL_GPL(ti_sci_inta_msi_domain_alloc_irqs);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);
include/linux/device.h +14 -6
@@ -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
@@ -407,8 +417,8 @@ struct dev_links_info {* @em_pd: device's energy model performance domain * @pins: For device pin management. * See Documentation/driver-api/pin-control.rst for details. +* @msi: MSI related data * @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).
@@ -500,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 struct list_head msi_list;#endif
@@ -666,7 +674,7 @@ static inline void set_dev_node(struct device *dev, int node)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
@@ -675,7 +683,7 @@ static inline struct irq_domain *dev_get_msi_domain(const struct device *dev)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 }
PATCH v3 8/35 device: Add device:: Msi_data pointer and struct msi_device_data
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
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.
Add a properties field to the data structure as a first member so the allocation size is not zero bytes. The field will be uses later on.
--- include/linux/device.h | 5 +++++ include/linux/msi.h | 18 ++++++++++++++++++ kernel/irq/msi.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+)
include/linux/device.h +5 -0
@@ -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 };/**
include/linux/msi.h +18 -0
@@ -171,6 +171,16 @@ struct msi_desc { }; }; +/** +* msi_device_data - MSI per device data +* @properties: MSI properties which are interesting to drivers +*/ +struct msi_device_data { +unsigned long properties; +}; + +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)
@@ -233,10 +243,16 @@ void pci_msi_mask_irq(struct irq_data *dvoid 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 ;
@@ -384,6 +400,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,
kernel/irq/msi.c +32 -0
@@ -73,6 +73,38 @@ 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 ; + + 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)
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] device: Add device:: Msi_data pointer and struct msi_device_data
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 013bd8e543c2c777b586cf033c588ea82bd502db Gitweb: https://git.kernel.org/tip/013bd8e543c2c777b586cf033c588ea82bd502db Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:18:55 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:38 +01:00
device: Add device:: Msi_data pointer and struct msi_device_data
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.
Add a properties field to the data structure as a first member so the allocation size is not zero bytes. The field will be uses later on.
--- include/linux/device.h | 5 +++++ include/linux/msi.h | 18 ++++++++++++++++++ kernel/irq/msi.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+)
include/linux/device.h +5 -0
@@ -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 };/**
include/linux/msi.h +18 -0
@@ -171,6 +171,16 @@ struct msi_desc { }; }; +/** +* msi_device_data - MSI per device data +* @properties: MSI properties which are interesting to drivers +*/ +struct msi_device_data { +unsigned long properties; +}; + +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)
@@ -233,10 +243,16 @@ void pci_msi_mask_irq(struct irq_data *data);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 ;
@@ -384,6 +400,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,
kernel/irq/msi.c +32 -0
@@ -73,6 +73,38 @@ void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg) }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 ; + + 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)
PATCH v3 9/35 PCI/MSI: Allocate MSI device data on first use
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Allocate MSI device data on first use, i.e. when a PCI driver invokes one of the PCI/MSI enablement functions.
--- drivers/pci/msi/msi.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/pci/msi/msi.c +15 -5
@@ -900,10 +900,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);
@@ -958,7 +960,11 @@ static int __pci_enable_msix_range(strucint 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);
@@ -985,8 +991,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;
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH v4 1/1 PCI/MSI: Decouple MSI[-X] disable from pcim_release()
The MSI core will introduce runtime allocation of MSI related data. This data will be devres managed and has to be set up before enabling PCI/MSI[-X]. This would introduce an ordering issue vs. pcim_release().
The setup order is:
pcim_enable_device()
devres_alloc(pcim_release...); ... pci_irq_alloc() msi_setup_device_data() devres_alloc(msi_device_data_release, ...)
and once the device is released these release functions are invoked in the opposite order:
msi_device_data_release()
...
pcim_release()
pci_disable_msi[x]()which is obviously wrong, because pci_disable_msi[x]() requires the MSI data to be available to tear down the MSI[-X] interrupts.
Remove the MSI[-X] teardown from pcim_release() and add an explicit action to be installed on the attempt of enabling PCI/MSI[-X].
This allows the MSI core data allocation to be ordered correctly in a subsequent step.
---
V4: New patch
--- drivers/pci/msi/msi.c | 33 +++++++++++++++++++++++++++++++++ drivers/pci/pci.c | 5 ----- include/linux/pci.h | 3 ++- 3 files changed, 35 insertions(+), 6 deletions(-)
drivers/pci/msi/msi.c +33 -0
@@ -341,6 +341,31 @@ void pci_restore_msi_state(struct pci_de }EXPORT_SYMBOL_GPL (pci_restore_msi_state); +static void pcim_msi_release (void *pcidev) +{ +struct pci_dev *dev = pcidev; + + dev->is_msi_managed = false; +pci_free_irq_vectors (dev); +} + +/* +* Needs to be separate from pcim_release to prevent an ordering problem +* vs. msi_device_data_release() in the MSI core code. +*/ +static int pcim_setup_msi_release (struct pci_dev *dev) +{ +int ret; + +if (!pci_is_managed (dev) || dev->is_msi_managed) +return 0 ; + + ret =devm_add_action (&dev->dev, pcim_msi_release, dev); +if (!ret) + dev->is_msi_managed = true; +return ret; +} +static struct msi_desc *msi_setup_entry (struct pci_dev *dev,int nvec,struct irq_affinity *affd) {
@@ -884,6 +909,10 @@ static int __pci_enable_msi_range(structif (nvec > maxvec) nvec = maxvec; + rc =pcim_setup_msi_release (dev); +if (rc) +return rc; +for (;;) {if (affd) { nvec =irq_calc_affinity_vectors (minvec, nvec, affd);
@@ -927,6 +956,10 @@ static int __pci_enable_msix_range(strucif (WARN_ON_ONCE (dev->msix_enabled))return -EINVAL ; + rc =pcim_setup_msi_release (dev); +if (rc) +return rc; +for (;;) {if (affd) { nvec =irq_calc_affinity_vectors (minvec, nvec, affd);
drivers/pci/pci.c +0 -5
@@ -2024,11 +2024,6 @@ static void pcim_release(struct device *struct pci_devres *this = res;int i; -if (dev->msi_enabled) -pci_disable_msi (dev); -if (dev->msix_enabled) -pci_disable_msix (dev); -for (i =0 ; i <DEVICE_COUNT_RESOURCE ; i++)if (this->region_mask & (1 << i))pci_release_region (dev, i);
include/linux/pci.h +2 -1
@@ -425,7 +425,8 @@ struct pci_dev { unsigned int ats_enabled:1; /* Address Translation Svc */ unsigned int pasid_enabled:1; /* Process Address Space ID */ unsigned int pri_enabled:1; /* Page Request Interface */ - unsigned int is_managed:1; + unsigned int is_managed:1; /* Managed via devres */ + unsigned int is_msi_managed:1; /* MSI release via devres installed */ unsigned int needs_freset:1; /* Requires fundamental reset */ unsigned int state_saved:1; unsigned int is_physfn:1;
PATCH v4 1/1 PCI/MSI: Allocate MSI device data on first use
Allocate MSI device data on first use, i.e. when a PCI driver invokes one of the PCI/MSI enablement functions.
Add a wrapper function to ensure that the ordering vs. pcim_msi_release() is correct.
---
V4: Adopted to ensure devres ordering
--- drivers/pci/msi/msi.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/pci/msi/msi.c +15 -2
@@ -366,6 +366,19 @@ static int pcim_setup_msi_release(structreturn ret; } +/* +* Ordering vs. devres: msi device data has to be installed first so that +* pcim_msi_release() is invoked before it on device release. +*/ +static int pci_setup_msi_context (struct pci_dev *dev) +{ +int ret =msi_setup_device_data (&dev->dev); + +if (!ret) + ret =pcim_setup_msi_release (dev); +return ret; +} +static struct msi_desc *msi_setup_entry (struct pci_dev *dev,int nvec,struct irq_affinity *affd) {
@@ -909,7 +922,7 @@ static int __pci_enable_msi_range(structif (nvec > maxvec) nvec = maxvec; - rc =pcim_setup_msi_release (dev); + rc =pci_setup_msi_context (dev);if (rc)return rc;
@@ -956,7 +969,7 @@ static int __pci_enable_msix_range(strucif (WARN_ON_ONCE (dev->msix_enabled))return -EINVAL ; - rc =pcim_setup_msi_release (dev); + rc =pci_setup_msi_context (dev);if (rc)return rc;
Re: [patch V4 09-02/35] PCI/MSI: Allocate MSI device data on first use
Quoted 7 lines · Thomas Gleixner
Allocate MSI device data on first use, i.e. when a PCI driver invokes one of the PCI/MSI enablement functions.
Add a wrapper function to ensure that the ordering vs.
pcim_msi_release()is correct.Signed-off-by Thomas Gleixner <[email protected]>
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] PCI/MSI: Allocate MSI device data on first use
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 93296cd1325d1d9afede60202d8833011c9001f2 Gitweb: https://git.kernel.org/tip/93296cd1325d1d9afede60202d8833011c9001f2 Author: Thomas Gleixner <[email protected]> AuthorDate: Wed, 15 Dec 2021 18:19:49 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:38 +01:00
PCI/MSI: Allocate MSI device data on first use
Allocate MSI device data on first use, i.e. when a PCI driver invokes one of the PCI/MSI enablement functions.
Add a wrapper function to ensure that the ordering vs. pcim_msi_release() is correct.
--- drivers/pci/msi/msi.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/pci/msi/msi.c +15 -2
@@ -366,6 +366,19 @@ static int pcim_setup_msi_release(struct pci_dev *dev)return ret; } +/* +* Ordering vs. devres: msi device data has to be installed first so that +* pcim_msi_release() is invoked before it on device release. +*/ +static int pci_setup_msi_context (struct pci_dev *dev) +{ +int ret =msi_setup_device_data (&dev->dev); + +if (!ret) + ret =pcim_setup_msi_release (dev); +return ret; +} +static struct msi_desc *msi_setup_entry (struct pci_dev *dev,int nvec,struct irq_affinity *affd) {
@@ -909,7 +922,7 @@ static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,if (nvec > maxvec) nvec = maxvec; - rc =pcim_setup_msi_release (dev); + rc =pci_setup_msi_context (dev);if (rc)return rc;
@@ -956,7 +969,7 @@ static int __pci_enable_msix_range(struct pci_dev *dev,if (WARN_ON_ONCE (dev->msix_enabled))return -EINVAL ; - rc =pcim_setup_msi_release (dev); + rc =pci_setup_msi_context (dev);if (rc)return rc;
Re: [patch V4 09-01/35] PCI/MSI: Decouple MSI[-X] disable from pcim_release()
In reply to Thomas GleixnerQuoted 27 lines · Thomas Gleixner
The MSI core will introduce runtime allocation of MSI related data. This data will be devres managed and has to be set up before enabling PCI/MSI[-X]. This would introduce an ordering issue vs.
pcim_release().The setup order is:
pcim_enable_device() devres_alloc(pcim_release...); ... pci_irq_alloc() msi_setup_device_data() devres_alloc(msi_device_data_release, ...)and once the device is released these release functions are invoked in the opposite order:
msi_device_data_release() ... pcim_release() pci_disable_msi[x]()which is obviously wrong, because pci_disable_msi[x]() requires the MSI data to be available to tear down the MSI[-X] interrupts.
Remove the MSI[-X] teardown from
pcim_release()and add an explicit action to be installed on the attempt of enabling PCI/MSI[-X].
Quoted 7 lines
This allows the MSI core data allocation to be ordered correctly in a subsequent step.
Reported-by Nishanth Menon <[email protected]>Signed-off-by Thomas Gleixner <[email protected]>---
V4: New patch
[tip: irq/msi] PCI/MSI: Decouple MSI[-X] disable from pcim_release()
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 3f35d2cf9fbc656db82579d849cc69c373b1ad0d Gitweb: https://git.kernel.org/tip/3f35d2cf9fbc656db82579d849cc69c373b1ad0d Author: Thomas Gleixner <[email protected]> AuthorDate: Wed, 15 Dec 2021 18:16:44 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:38 +01:00
PCI/MSI: Decouple MSI[-X] disable from pcim_release()
The MSI core will introduce runtime allocation of MSI related data. This data will be devres managed and has to be set up before enabling PCI/MSI[-X]. This would introduce an ordering issue vs. pcim_release().
The setup order is:
pcim_enable_device()
devres_alloc(pcim_release...); ... pci_irq_alloc() msi_setup_device_data() devres_alloc(msi_device_data_release, ...)
and once the device is released these release functions are invoked in the opposite order:
msi_device_data_release()
...
pcim_release()
pci_disable_msi[x]()which is obviously wrong, because pci_disable_msi[x]() requires the MSI data to be available to tear down the MSI[-X] interrupts.
Remove the MSI[-X] teardown from pcim_release() and add an explicit action to be installed on the attempt of enabling PCI/MSI[-X].
This allows the MSI core data allocation to be ordered correctly in a subsequent step.
--- drivers/pci/msi/msi.c | 33 +++++++++++++++++++++++++++++++++ drivers/pci/pci.c | 5 ----- include/linux/pci.h | 3 ++- 3 files changed, 35 insertions(+), 6 deletions(-)
drivers/pci/msi/msi.c +33 -0
@@ -341,6 +341,31 @@ void pci_restore_msi_state(struct pci_dev *dev) }EXPORT_SYMBOL_GPL (pci_restore_msi_state); +static void pcim_msi_release (void *pcidev) +{ +struct pci_dev *dev = pcidev; + + dev->is_msi_managed = false; +pci_free_irq_vectors (dev); +} + +/* +* Needs to be separate from pcim_release to prevent an ordering problem +* vs. msi_device_data_release() in the MSI core code. +*/ +static int pcim_setup_msi_release (struct pci_dev *dev) +{ +int ret; + +if (!pci_is_managed (dev) || dev->is_msi_managed) +return 0 ; + + ret =devm_add_action (&dev->dev, pcim_msi_release, dev); +if (!ret) + dev->is_msi_managed = true; +return ret; +} +static struct msi_desc *msi_setup_entry (struct pci_dev *dev,int nvec,struct irq_affinity *affd) {
@@ -884,6 +909,10 @@ static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,if (nvec > maxvec) nvec = maxvec; + rc =pcim_setup_msi_release (dev); +if (rc) +return rc; +for (;;) {if (affd) { nvec =irq_calc_affinity_vectors (minvec, nvec, affd);
@@ -927,6 +956,10 @@ static int __pci_enable_msix_range(struct pci_dev *dev,if (WARN_ON_ONCE (dev->msix_enabled))return -EINVAL ; + rc =pcim_setup_msi_release (dev); +if (rc) +return rc; +for (;;) {if (affd) { nvec =irq_calc_affinity_vectors (minvec, nvec, affd);
drivers/pci/pci.c +0 -5
@@ -2024,11 +2024,6 @@ static void pcim_release(struct device *gendev, void *res)struct pci_devres *this = res;int i; -if (dev->msi_enabled) -pci_disable_msi (dev); -if (dev->msix_enabled) -pci_disable_msix (dev); -for (i =0 ; i <DEVICE_COUNT_RESOURCE ; i++)if (this->region_mask & (1 << i))pci_release_region (dev, i);
include/linux/pci.h +2 -1
@@ -425,7 +425,8 @@ struct pci_dev { unsigned int ats_enabled:1; /* Address Translation Svc */ unsigned int pasid_enabled:1; /* Process Address Space ID */ unsigned int pri_enabled:1; /* Page Request Interface */ - unsigned int is_managed:1; + unsigned int is_managed:1; /* Managed via devres */ + unsigned int is_msi_managed:1; /* MSI release via devres installed */ unsigned int needs_freset:1; /* Requires fundamental reset */ unsigned int state_saved:1; unsigned int is_physfn:1;
PATCH v3 10/35 platform-msi: Allocate MSI device data on first use
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Allocate the MSI device data on first invocation of the allocation function for platform MSI private data.
--- drivers/base/platform-msi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/base/platform-msi.c +7 -1
@@ -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 devireturn 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); }
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] platform-msi: Allocate MSI device data on first use
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 077aeadb6cacdee79acff3deb1b31581584fdb9c Gitweb: https://git.kernel.org/tip/077aeadb6cacdee79acff3deb1b31581584fdb9c Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:18:58 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:38 +01:00
platform-msi: Allocate MSI device data on first use
Allocate the MSI device data on first invocation of the allocation function for platform MSI private data.
--- drivers/base/platform-msi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/base/platform-msi.c +7 -1
@@ -204,6 +204,8 @@ 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; +/* * 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 device *dev, unsigned int nvec,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 device *dev, unsigned int nvec, 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); }
PATCH v3 11/35 bus: fsl-mc-msi: Allocate MSI device data on first use
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Allocate the MSI device data on first invocation of the allocation function.
--- drivers/bus/fsl-mc/fsl-mc-msi.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/bus/fsl-mc/fsl-mc-msi.c +8 -6
@@ -253,6 +253,14 @@ int fsl_mc_msi_domain_alloc_irqs(structstruct 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(structif (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
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] bus: fsl-mc-msi: Allocate MSI device data on first use
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 86ca622628d3941835138f2f89e69ed63f7f50fe Gitweb: https://git.kernel.org/tip/86ca622628d3941835138f2f89e69ed63f7f50fe Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:00 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:38 +01:00
bus: fsl-mc-msi: Allocate MSI device data on first use
Allocate the MSI device data on first invocation of the allocation function.
--- drivers/bus/fsl-mc/fsl-mc-msi.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/bus/fsl-mc/fsl-mc-msi.c +8 -6
@@ -253,6 +253,14 @@ int fsl_mc_msi_domain_alloc_irqs(struct device *dev,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 device *dev,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
PATCH v3 12/35 soc: ti: ti_sci_inta_msi: Allocate MSI device data on first use
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Allocate the MSI device data on first invocation of the allocation function.
--- drivers/soc/ti/ti_sci_inta_msi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/soc/ti/ti_sci_inta_msi.c +4 -0
@@ -120,6 +120,10 @@ int ti_sci_inta_msi_domain_alloc_irqs(stif (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;
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [patch V3 12/35] soc: ti: ti_sci_inta_msi: Allocate MSI device data on first use
Quoted 5 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
Allocate the MSI device data on first invocation of the allocation function.
Quoted 7 lines
Signed-off-by Thomas Gleixner <[email protected]>Reviewed-by Greg Kroah-Hartman <[email protected]>Reviewed-by Jason Gunthorpe <[email protected]>Cc Nishanth Menon <[email protected]>Cc Tero Kristo <[email protected]>Cc Santosh Shilimkar <[email protected]>
Re: [patch V3 12/35] soc: ti: ti_sci_inta_msi: Allocate MSI device data on first use
In reply to Thomas GleixnerQuoted 11 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
Allocate the MSI device data on first invocation of the allocation function.
Signed-off-by Thomas Gleixner <[email protected]>Reviewed-by Greg Kroah-Hartman <[email protected]>Reviewed-by Jason Gunthorpe <[email protected]>Cc Nishanth Menon <[email protected]>Cc Tero Kristo <[email protected]>Cc Santosh Shilimkar <[email protected]>
Signature · 3 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D)/Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
[tip: irq/msi] soc: ti: ti_sci_inta_msi: Allocate MSI device data on first use
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 686073e9f8466de259971f1acd81b19a39e2162b Gitweb: https://git.kernel.org/tip/686073e9f8466de259971f1acd81b19a39e2162b Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:01 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:39 +01:00
soc: ti: ti_sci_inta_msi: Allocate MSI device data on first use
Allocate the MSI device data on first invocation of the allocation function.
--- drivers/soc/ti/ti_sci_inta_msi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/soc/ti/ti_sci_inta_msi.c +4 -0
@@ -120,6 +120,10 @@ int ti_sci_inta_msi_domain_alloc_irqs(struct device *dev,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;
PATCH v3 13/35 genirq/msi: Provide msi_device_populate/destroy_sysfs()
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Add new allocation functions which can be activated by domain info flags. They store the groups pointer in struct msi_device_data.
--- include/linux/msi.h | 4 ++++ kernel/irq/msi.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-)
include/linux/msi.h +4 -0
@@ -56,6 +56,8 @@ struct irq_data;struct msi_desc ;struct pci_dev ;struct platform_msi_priv_data ; +struct attribute_group ; +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);
@@ -174,9 +176,11 @@ struct msi_desc {/** * msi_device_data - MSI per device data * @properties: MSI properties which are interesting to drivers +* @attrs: Pointer to the sysfs attribute group */ struct msi_device_data {unsigned long properties; +const struct attribute_group **attrs; };int msi_setup_device_data (struct device *dev);
kernel/irq/msi.c +40 -2
67 lines not on this page · raw message
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] genirq/msi: Provide msi_device_populate/destroy_sysfs()
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: bf6e054e0e3fbc9614355b760e18c8a14f952a4e Gitweb: https://git.kernel.org/tip/bf6e054e0e3fbc9614355b760e18c8a14f952a4e Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:03 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:39 +01:00
genirq/msi: Provide msi_device_populate/destroy_sysfs()
Add new allocation functions which can be activated by domain info flags. They store the groups pointer in struct msi_device_data.
--- include/linux/msi.h | 4 ++++ kernel/irq/msi.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-)
include/linux/msi.h +4 -0
@@ -56,6 +56,8 @@ struct irq_data;struct msi_desc ;struct pci_dev ;struct platform_msi_priv_data ; +struct attribute_group ; +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);
@@ -174,9 +176,11 @@ struct msi_desc {/** * msi_device_data - MSI per device data * @properties: MSI properties which are interesting to drivers +* @attrs: Pointer to the sysfs attribute group */ struct msi_device_data {unsigned long properties; +const struct attribute_group **attrs; };int msi_setup_device_data (struct device *dev);
kernel/irq/msi.c +40 -2
67 lines not on this page · raw message
PATCH v3 14/35 PCI/MSI: Let the irq code handle sysfs groups
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Set the domain info flag which makes the core code handle sysfs groups and put an explicit invocation into the legacy code.
--- 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(-)
drivers/pci/msi/irqdomain.c +1 -1
@@ -159,7 +159,7 @@ struct irq_domain *pci_msi_create_irq_doif (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 ;
drivers/pci/msi/legacy.c +5 -1
@@ -70,10 +70,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); }
drivers/pci/msi/msi.c +0 -23
@@ -233,11 +233,6 @@ static void free_msi_irqs(struct pci_devfor (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) {
@@ -417,7 +412,6 @@ static int msi_verify_entries(struct pcistatic 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;
@@ -448,14 +442,6 @@ static int msi_capability_init(struct pcif (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 );
@@ -584,7 +570,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;
@@ -629,14 +614,6 @@ static int msix_capability_init(struct pmsix_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; -/* Disable INTX and unmask MSI-X */ pci_intx_for_msi (dev,0 );pci_msix_clear_and_set_ctrl (dev,PCI_MSIX_FLAGS_MASKALL ,0 );
include/linux/pci.h +0 -1
@@ -475,7 +475,6 @@ struct pci_dev {#ifdef CONFIG_PCI_MSI void __iomem *msix_base;raw_spinlock_t msi_lock; -const struct attribute_group **msi_irq_groups;#endif struct pci_vpd vpd;#ifdef CONFIG_PCIE_DPC
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] PCI/MSI: Let the irq code handle sysfs groups
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: ffd84485e6beb9cad3e5a133d88201b995298c33 Gitweb: https://git.kernel.org/tip/ffd84485e6beb9cad3e5a133d88201b995298c33 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:05 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:39 +01:00
PCI/MSI: Let the irq code handle sysfs groups
Set the domain info flag which makes the core code handle sysfs groups and put an explicit invocation into the legacy code.
--- 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(-)
drivers/pci/msi/irqdomain.c +1 -1
@@ -159,7 +159,7 @@ struct irq_domain *pci_msi_create_irq_domain(struct fwnode_handle *fwnode,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 ;
drivers/pci/msi/legacy.c +5 -1
@@ -70,10 +70,14 @@ int pci_msi_legacy_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) {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); }
drivers/pci/msi/msi.c +0 -23
@@ -233,11 +233,6 @@ static void free_msi_irqs(struct pci_dev *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) {
@@ -455,7 +450,6 @@ static int msi_verify_entries(struct pci_dev *dev)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;
@@ -486,14 +480,6 @@ static int msi_capability_init(struct pci_dev *dev, int nvec,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 );
@@ -622,7 +608,6 @@ static void msix_mask_all(void __iomem *base, int tsize)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;
@@ -664,14 +649,6 @@ static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,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; -/* Disable INTX */ pci_intx_for_msi (dev,0 );
include/linux/pci.h +0 -1
@@ -476,7 +476,6 @@ struct pci_dev {#ifdef CONFIG_PCI_MSI void __iomem *msix_base;raw_spinlock_t msi_lock; -const struct attribute_group **msi_irq_groups;#endif struct pci_vpd vpd;#ifdef CONFIG_PCIE_DPC
PATCH v3 15/35 platform-msi: Let the core code handle sysfs groups
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Set the domain info flag and remove the local sysfs code.
--- drivers/base/platform-msi.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/base/platform-msi.c +1 -10
@@ -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_iplatform_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(strucif (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(strucstruct 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); }
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] platform-msi: Let the core code handle sysfs groups
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 25ce693ef7ea766c10d2f3e5da373ca25af09196 Gitweb: https://git.kernel.org/tip/25ce693ef7ea766c10d2f3e5da373ca25af09196 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:06 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:39 +01:00
platform-msi: Let the core code handle sysfs groups
Set the domain info flag and remove the local sysfs code.
--- drivers/base/platform-msi.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/base/platform-msi.c +1 -10
@@ -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_irq_domain(struct fwnode_handle *fwnode,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(struct device *dev, unsigned int nvec,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(struct device *dev)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); }
PATCH v3 16/35 genirq/msi: Remove the original sysfs interfaces
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
No more users. Refactor the core code accordingly and move the global interface under CONFIG_PCI_MSI_ARCH_FALLBACKS.
--- include/linux/msi.h | 29 +++++++--------------------- kernel/irq/msi.c | 53 +++++++++++++++++++--------------------------------- 2 files changed, 28 insertions(+), 54 deletions(-)
include/linux/msi.h +8 -21
@@ -246,26 +246,6 @@ void __pci_write_msi_msg(struct msi_descvoid pci_msi_mask_irq (struct irq_data *data);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 ; -} -static inline void msi_destroy_sysfs (struct device *dev,const struct attribute_group **msi_irq_groups) -{ -} -#endif -/* * The arch hooks to setup up msi irqs. Default functions are implemented * as weak symbols so that they /can/ be overriden by architecture specific
@@ -279,7 +259,14 @@ int arch_setup_msi_irq(struct pci_dev *dvoid arch_teardown_msi_irq (unsigned int irq);int arch_setup_msi_irqs (struct pci_dev *dev,int nvec,int type);void arch_teardown_msi_irqs (struct pci_dev *dev); -#endif +#ifdef CONFIG_SYSFS +int msi_device_populate_sysfs (struct device *dev); +void msi_device_destroy_sysfs (struct device *dev); +#else /* CONFIG_SYSFS */ +static inline int msi_device_populate_sysfs (struct device *dev) {return 0 ; } +static inline void msi_device_destroy_sysfs (struct device *dev) { } +#endif /* !CONFIG_SYSFS */ +#endif /* CONFIG_PCI_MSI_ARCH_FALLBACKS */ /* * The restore hook is still available even for fully irq domain based
kernel/irq/msi.c +20 -33
73 lines not on this page · raw message
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] genirq/msi: Remove the original sysfs interfaces
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 24cff375fdb663c2238f06693a067b9219596fdc Gitweb: https://git.kernel.org/tip/24cff375fdb663c2238f06693a067b9219596fdc Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:08 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:39 +01:00
genirq/msi: Remove the original sysfs interfaces
No more users. Refactor the core code accordingly and move the global interface under CONFIG_PCI_MSI_ARCH_FALLBACKS.
--- include/linux/msi.h | 18 ++------------- kernel/irq/msi.c | 53 ++++++++++++++++---------------------------- 2 files changed, 23 insertions(+), 48 deletions(-)
include/linux/msi.h +3 -15
@@ -249,22 +249,10 @@ 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 +#else /* CONFIG_SYSFS */ 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 +#endif /* !CONFIG_SYSFS */ /* * The arch hooks to setup up msi irqs. Default functions are implemented
@@ -279,7 +267,7 @@ int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc);void arch_teardown_msi_irq (unsigned int irq);int arch_setup_msi_irqs (struct pci_dev *dev,int nvec,int type);void arch_teardown_msi_irqs (struct pci_dev *dev); -#endif +#endif /* CONFIG_PCI_MSI_ARCH_FALLBACKS */ /* * The restore hook is still available even for fully irq domain based
kernel/irq/msi.c +20 -33
73 lines not on this page · raw message
PATCH v3 17/35 platform-msi: Rename functions and clarify comments
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
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.
--- 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(-)
drivers/base/platform-msi.c +21 -15
@@ -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; }
drivers/irqchip/irq-mbigen.c +2 -2
@@ -207,7 +207,7 @@ static int mbigen_irq_domain_alloc(strucif (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(strucstatic 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 = {
drivers/irqchip/irq-mvebu-icu.c +3 -3
@@ -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_doreturn 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_domkfree (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 = {
include/linux/msi.h +4 -4
@@ -434,10 +434,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 */
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] platform-msi: Rename functions and clarify comments
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 9835cec6d557b0bff3d48bd91cd0484aba59386c Gitweb: https://git.kernel.org/tip/9835cec6d557b0bff3d48bd91cd0484aba59386c Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:09 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:39 +01:00
platform-msi: Rename functions and clarify comments
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.
--- 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(-)
drivers/base/platform-msi.c +21 -15
@@ -313,17 +313,18 @@ EXPORT_SYMBOL_GPL(platform_msi_domain_free_irqs);* 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 irq_domain *domain)* @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 @@ free_priv: }/** -* 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_domain *domain, unsigned int virq, }/** -* 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_domain *domain, unsigned int virq,* 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_domain *domain, unsigned int virq, 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; }
drivers/irqchip/irq-mbigen.c +2 -2
@@ -207,7 +207,7 @@ static int mbigen_irq_domain_alloc(struct irq_domain *domain,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(struct irq_domain *domain,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 = {
drivers/irqchip/irq-mvebu-icu.c +3 -3
@@ -221,7 +221,7 @@ mvebu_icu_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, 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_domain *domain, unsigned int virq,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_domain *domain, unsigned int virq,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 = {
include/linux/msi.h +4 -4
@@ -435,10 +435,10 @@ __platform_msi_create_device_domain(struct device *dev,#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 */
PATCH v3 18/35 platform-msi: Store platform private data pointer in msi_device_data
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
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.
--- drivers/base/platform-msi.c | 79 +++++++++++++++++--------------------------- include/linux/msi.h | 4 +- 2 files changed, 34 insertions(+), 49 deletions(-)
drivers/base/platform-msi.c +32 -47
@@ -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_withif (!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_withreturn 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_ireturn 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(strstruct 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;
include/linux/msi.h +2 -2
@@ -108,11 +108,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; };
@@ -177,10 +175,12 @@ struct msi_desc {* msi_device_data - MSI per device data * @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 {unsigned long properties;const struct attribute_group **attrs; +struct platform_msi_priv_data *platform_data; };int msi_setup_device_data (struct device *dev);
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] platform-msi: Store platform private data pointer in msi_device_data
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: fc22e7dbcdb3e06a3d3ce05fc91c6a2345411f9b Gitweb: https://git.kernel.org/tip/fc22e7dbcdb3e06a3d3ce05fc91c6a2345411f9b Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:11 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:39 +01:00
platform-msi: Store platform private data pointer in msi_device_data
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.
--- drivers/base/platform-msi.c | 79 ++++++++++++++---------------------- include/linux/msi.h | 4 +- 2 files changed, 34 insertions(+), 49 deletions(-)
drivers/base/platform-msi.c +32 -47
@@ -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(struct msi_domain_info *info)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(struct device *dev, int base, int nvec) }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_irq(struct device *dev, int virq,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_irq(struct device *dev, int virq,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_irq_domain(struct fwnode_handle *fwnode,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 device *dev, unsigned int nvec,* 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(struct platform_msi_priv_data *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(struct device *dev, unsigned int nvec, 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_alloc_irqs);*/ 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 @@ __platform_msi_create_device_domain(struct device *dev,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 @@ __platform_msi_create_device_domain(struct device *dev, 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(struct irq_domain *domain, unsigned int virstruct 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;
include/linux/msi.h +2 -2
@@ -108,11 +108,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; };
@@ -177,10 +175,12 @@ struct msi_desc {* msi_device_data - MSI per device data * @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 {unsigned long properties;const struct attribute_group **attrs; +struct platform_msi_priv_data *platform_data; };int msi_setup_device_data (struct device *dev);
PATCH v3 19/35 genirq/msi: Consolidate MSI descriptor data
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
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.
--- include/linux/msi.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/msi.h +2 -0
@@ -143,6 +143,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
@@ -163,6 +164,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;
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] genirq/msi: Consolidate MSI descriptor data
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 20c6d424cfe641659c9a025db8a8608701b27246 Gitweb: https://git.kernel.org/tip/20c6d424cfe641659c9a025db8a8608701b27246 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:12 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:40 +01:00
genirq/msi: Consolidate MSI descriptor data
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.
--- include/linux/msi.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/msi.h +2 -0
@@ -143,6 +143,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
@@ -163,6 +164,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;
PATCH v3 20/35 platform-msi: Use msi_desc::msi_index
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Use the common msi_index member and get rid of the pointless wrapper struct.
--- 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(-)
drivers/base/platform-msi.c +5 -5
@@ -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(strustruct 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_withif (!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_withif (!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));
drivers/dma/qcom/hidma.c +2 -2
@@ -666,7 +666,7 @@ static void hidma_write_msi_msg(struct mstruct 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 hidmreturn 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,
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +2 -2
@@ -3142,7 +3142,7 @@ static void arm_smmu_write_msi_msg(strucphys_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 ;
drivers/mailbox/bcm-flexrm-mailbox.c +2 -2
@@ -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; }
include/linux/msi.h +0 -10
@@ -107,14 +107,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 */
@@ -145,7 +137,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 */
@@ -167,7 +158,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; };
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] platform-msi: Use msi_desc::msi_index
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: dba27c7fa36f468e7eb29b216879f8c33bf0955d Gitweb: https://git.kernel.org/tip/dba27c7fa36f468e7eb29b216879f8c33bf0955d Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:14 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:40 +01:00
platform-msi: Use msi_desc::msi_index
Use the common msi_index member and get rid of the pointless wrapper struct.
--- 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(-)
drivers/base/platform-msi.c +5 -5
@@ -40,7 +40,7 @@ static irq_hw_number_t platform_msi_calc_hwirq(struct msi_desc *desc) {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(struct device *dev, int base, int nvec)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_irq(struct device *dev, int virq,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_irq(struct device *dev, int virq,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));
drivers/dma/qcom/hidma.c +2 -2
@@ -666,7 +666,7 @@ static void hidma_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg)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 hidma_dev *dmadev,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,
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +2 -2
@@ -3142,7 +3142,7 @@ static void arm_smmu_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg)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 arm_smmu_device *smmu) }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 ;
drivers/mailbox/bcm-flexrm-mailbox.c +2 -2
@@ -1484,7 +1484,7 @@ static void flexrm_mbox_msi_write(struct msi_desc *desc, struct msi_msg *msg) {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 platform_device *pdev)/* 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; }
include/linux/msi.h +0 -10
@@ -107,14 +107,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 */
@@ -145,7 +137,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 */
@@ -167,7 +158,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; };
PATCH v3 21/35 bus: fsl-mc-msi: Use msi_desc::msi_index
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Use the common msi_index member and get rid of the pointless wrapper struct.
--- 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(-)
drivers/bus/fsl-mc/fsl-mc-allocator.c +1 -1
@@ -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; }
drivers/bus/fsl-mc/fsl-mc-msi.c +3 -3
@@ -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(structstruct 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)); }
include/linux/msi.h +0 -10
@@ -107,14 +107,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 */
@@ -137,7 +129,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 {
@@ -158,7 +149,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; }; };
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] bus: fsl-mc-msi: Use msi_desc::msi_index
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 78ee9fb4b8b126ed84a819a6e1732fd3039b525a Gitweb: https://git.kernel.org/tip/78ee9fb4b8b126ed84a819a6e1732fd3039b525a Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:15 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:40 +01:00
bus: fsl-mc-msi: Use msi_desc::msi_index
Use the common msi_index member and get rid of the pointless wrapper struct.
--- 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(-)
drivers/bus/fsl-mc/fsl-mc-allocator.c +1 -1
@@ -393,7 +393,7 @@ int fsl_mc_populate_irq_pool(struct fsl_mc_device *mc_bus_dev, }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; }
drivers/bus/fsl-mc/fsl-mc-msi.c +3 -3
@@ -29,7 +29,7 @@ static irq_hw_number_t fsl_mc_domain_calc_hwirq(struct fsl_mc_device *dev,* 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 irq_data *irq_data,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 device *dev, unsigned int irq_count) 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)); }
include/linux/msi.h +0 -10
@@ -107,14 +107,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 */
@@ -137,7 +129,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 {
@@ -158,7 +149,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; }; };
PATCH v3 22/35 soc: ti: ti_sci_inta_msi: Use msi_desc::msi_index
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Use the common msi_index member and get rid of the pointless wrapper struct.
--- 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(-)
drivers/irqchip/irq-ti-sci-inta.c +1 -1
@@ -595,7 +595,7 @@ static void ti_sci_inta_msi_set_desc(msistruct 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 = {
drivers/soc/ti/ti_sci_inta_msi.c +3 -3
@@ -84,7 +84,7 @@ static int ti_sci_inta_msi_alloc_descs(sreturn -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(sreturn -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(ststruct 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 ;
include/linux/msi.h +2 -14
@@ -107,14 +107,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
@@ -128,8 +120,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 specific msi descriptor data */ struct msi_desc {/* Shared device/bus type independent data */
@@ -147,10 +138,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; };/**
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [patch V3 22/35] soc: ti: ti_sci_inta_msi: Use msi_desc::msi_index
Quoted 4 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
Use the common
msi_indexmember and get rid of the pointless wrapper struct.
Quoted 8 lines
Signed-off-by Thomas Gleixner <[email protected]>Reviewed-by Greg Kroah-Hartman <[email protected]>Reviewed-by Jason Gunthorpe <[email protected]>Cc Nishanth Menon <[email protected]>Cc Tero Kristo <[email protected]>Cc Santosh Shilimkar <[email protected]>Cc Thomas Gleixner <[email protected]>
Signature · 3 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D)/Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
[tip: irq/msi] soc: ti: ti_sci_inta_msi: Use msi_desc::msi_index
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 0f18095871fc59c89a281caf6f18538cf9e50fbf Gitweb: https://git.kernel.org/tip/0f18095871fc59c89a281caf6f18538cf9e50fbf Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:17 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:40 +01:00
soc: ti: ti_sci_inta_msi: Use msi_desc::msi_index
Use the common msi_index member and get rid of the pointless wrapper struct.
--- 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(-)
drivers/irqchip/irq-ti-sci-inta.c +1 -1
@@ -595,7 +595,7 @@ static void ti_sci_inta_msi_set_desc(msi_alloc_info_t *arg,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 = {
drivers/soc/ti/ti_sci_inta_msi.c +3 -3
@@ -84,7 +84,7 @@ static int ti_sci_inta_msi_alloc_descs(struct device *dev,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(struct device *dev,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(struct device *dev, u32 dev_index)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 ;
include/linux/msi.h +2 -14
@@ -107,14 +107,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
@@ -128,8 +120,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 specific msi descriptor data */ struct msi_desc {/* Shared device/bus type independent data */
@@ -147,10 +138,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; };/**
PATCH v3 23/35 PCI/MSI: Use msi_desc::msi_index
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
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.
--- 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(-)
arch/powerpc/platforms/pseries/msi.c +2 -2
@@ -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 ; }
@@ -579,7 +579,7 @@ static int pseries_irq_domain_alloc(struint 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;
arch/x86/pci/xen.c +1 -1
@@ -306,7 +306,7 @@ static int xen_initdom_setup_msi_irqs(streturn -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 ;
drivers/pci/msi/irqdomain.c +1 -1
@@ -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 ; }
drivers/pci/msi/msi.c +8 -12
@@ -44,7 +44,7 @@ static inline void pci_msi_unmask(structstatic 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 ; }/*
@@ -356,13 +356,10 @@ msi_setup_entry(struct pci_dev *dev, intif (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));
@@ -504,12 +501,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;
@@ -1045,7 +1041,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 );
@@ -1084,7 +1080,7 @@ const struct cpumask *pci_irq_get_affinistruct 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 );
drivers/pci/xen-pcifront.c +1 -1
@@ -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++;
include/linux/msi.h +0 -2
@@ -80,7 +80,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
@@ -97,7 +96,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 {
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] PCI/MSI: Use msi_desc::msi_index
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 173ffad79d177d9a91fbf3be6bf67ca81e0f765a Gitweb: https://git.kernel.org/tip/173ffad79d177d9a91fbf3be6bf67ca81e0f765a Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:18 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:40 +01:00
PCI/MSI: Use msi_desc::msi_index
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.
--- 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(-)
arch/powerpc/platforms/pseries/msi.c +2 -2
@@ -332,7 +332,7 @@ static int check_msix_entries(struct pci_dev *pdev) 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 ; }
@@ -579,7 +579,7 @@ static int pseries_irq_domain_alloc(struct irq_domain *domain, unsigned int virqint 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;
arch/x86/pci/xen.c +1 -1
@@ -306,7 +306,7 @@ static int xen_initdom_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)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 ;
drivers/pci/msi/irqdomain.c +1 -1
@@ -57,7 +57,7 @@ static irq_hw_number_t pci_msi_domain_calc_hwirq(struct msi_desc *desc) {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 ; }
drivers/pci/msi/msi.c +8 -12
@@ -44,7 +44,7 @@ static inline void pci_msi_unmask(struct msi_desc *desc, u32 mask)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 ; }/*
@@ -394,13 +394,10 @@ msi_setup_entry(struct pci_dev *dev, int nvec, struct irq_affinity *affd)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));
@@ -542,12 +539,11 @@ static int msix_setup_entries(struct pci_dev *dev, void __iomem *base, 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;
@@ -1088,7 +1084,7 @@ int pci_irq_vector(struct pci_dev *dev, unsigned int nr)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 );
@@ -1127,7 +1123,7 @@ const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr)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 );
drivers/pci/xen-pcifront.c +1 -1
@@ -263,7 +263,7 @@ static int pci_frontend_enable_msix(struct pci_dev *dev, 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++;
include/linux/msi.h +0 -2
@@ -80,7 +80,6 @@ typedef void (*irq_write_msi_msg_t)(struct msi_desc *desc,* @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
@@ -97,7 +96,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 {
PATCH v3 24/35 PCI/MSI: Provide MSI_FLAG_MSIX_CONTIGUOUS
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
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.
--- drivers/pci/msi/irqdomain.c | 16 ++++++++++++++-- include/linux/msi.h | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-)
drivers/pci/msi/irqdomain.c +14 -2
@@ -89,9 +89,21 @@ static int pci_msi_domain_check_cap(struif (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 ; }
include/linux/msi.h +2 -0
@@ -361,6 +361,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,
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] PCI/MSI: Provide MSI_FLAG_MSIX_CONTIGUOUS
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 7a823443e9b4ed1ff4a3026d184f09d23fd6d9c9 Gitweb: https://git.kernel.org/tip/7a823443e9b4ed1ff4a3026d184f09d23fd6d9c9 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:20 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:40 +01:00
PCI/MSI: Provide MSI_FLAG_MSIX_CONTIGUOUS
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.
--- drivers/pci/msi/irqdomain.c | 16 ++++++++++++++-- include/linux/msi.h | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-)
drivers/pci/msi/irqdomain.c +14 -2
@@ -89,9 +89,21 @@ static int pci_msi_domain_check_cap(struct irq_domain *domain,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 ; }
include/linux/msi.h +2 -0
@@ -362,6 +362,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,
PATCH v3 25/35 powerpc/pseries/msi: Let core code check for contiguous entries
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Set the domain info flag and remove the check.
---
V2: Remove it completely - Cedric
--- arch/powerpc/platforms/pseries/msi.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-)
arch/powerpc/platforms/pseries/msi.c +8 -25
@@ -321,27 +321,6 @@ static int msi_quota_for_device(struct preturn 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,9 +359,6 @@ static int rtas_prepare_msi_irqs(structif (quota && quota < nvec)return quota; -if (type ==PCI_CAP_ID_MSIX &&check_msix_entries (pdev)) -return -EINVAL ; -/* * Firmware currently refuse any non power of two allocation * so we round up if the quota will allow it.
@@ -529,9 +505,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, };
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [patch V3 25/35] powerpc/pseries/msi: Let core code check for contiguous entries
Quoted 11 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
Set the domain info flag and remove the check.
Signed-off-by Thomas Gleixner <[email protected]>Reviewed-by Greg Kroah-Hartman <[email protected]>Cc Michael Ellerman <[email protected]>Cc Benjamin Herrenschmidt <[email protected]>Cc "Cédric Le Goater" <[email protected]>
Quoted 5 lines
---
V2: Remove it completely - Cedric--- arch/powerpc/platforms/pseries/msi.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-)
Jason
[tip: irq/msi] powerpc/pseries/msi: Let core code check for contiguous entries
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 651b39c48813acac2b77850014390f4062a4835d Gitweb: https://git.kernel.org/tip/651b39c48813acac2b77850014390f4062a4835d Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:22 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:40 +01:00
powerpc/pseries/msi: Let core code check for contiguous entries
Set the domain info flag and remove the check.
--- arch/powerpc/platforms/pseries/msi.c | 33 ++++++--------------------- 1 file changed, 8 insertions(+), 25 deletions(-)
arch/powerpc/platforms/pseries/msi.c +8 -25
@@ -321,27 +321,6 @@ out: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,9 +359,6 @@ static int rtas_prepare_msi_irqs(struct pci_dev *pdev, int nvec_in, int type,if (quota && quota < nvec)return quota; -if (type ==PCI_CAP_ID_MSIX &&check_msix_entries (pdev)) -return -EINVAL ; -/* * Firmware currently refuse any non power of two allocation * so we round up if the quota will allow it.
@@ -529,9 +505,16 @@ static struct irq_chip pseries_pci_msi_irq_chip = { .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, };
PATCH v3 26/35 genirq/msi: Provide interface to retrieve Linux interrupt number
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
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 in case that there is no entry for the given MSI index.
---
V2: Simplify the implementation and let PCI deal with the PCI specialities - Marc
--- include/linux/msi.h | 2 ++ kernel/irq/msi.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+)
include/linux/msi.h +2 -0
@@ -153,6 +153,8 @@ struct msi_device_data {int msi_setup_device_data (struct device *dev); +unsigned int msi_get_virq (struct device *dev,unsigned int index); +/* 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)
kernel/irq/msi.c +36 -0
@@ -105,6 +105,42 @@ int msi_setup_device_data(struct devicereturn 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), 0 if not found +*/ +unsigned int msi_get_virq (struct device *dev,unsigned int index) +{ +struct msi_desc *desc; +bool pcimsi; + +if (!dev->msi.data) +return 0 ; + + pcimsi =dev_is_pci (dev) ?to_pci_dev (dev)->msi_enabled : false; + +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 0 ; +} +EXPORT_SYMBOL_GPL (msi_get_virq); +#ifdef CONFIG_SYSFS static ssize_t msi_mode_show (struct device *dev,struct device_attribute *attr,char *buf)
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [patch V3 26/35] genirq/msi: Provide interface to retrieve Linux interrupt number
Quoted 8 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
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 in case that there is no entry for the given MSI index.
Quoted 8 lines
Signed-off-by Thomas Gleixner <[email protected]>Reviewed-by Greg Kroah-Hartman <[email protected]>---
V2: Simplify the implementation and let PCI deal with the PCI specialities - Marc--- include/linux/msi.h | 2 ++ kernel/irq/msi.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+)
Jason
[tip: irq/msi] genirq/msi: Provide interface to retrieve Linux interrupt number
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: cf15f43acaad31dabb2646cef170a506a1d663eb Gitweb: https://git.kernel.org/tip/cf15f43acaad31dabb2646cef170a506a1d663eb Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:23 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:40 +01:00
genirq/msi: Provide interface to retrieve Linux interrupt number
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 in case that there is no entry for the given MSI index.
--- include/linux/msi.h | 2 ++ kernel/irq/msi.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+)
include/linux/msi.h +2 -0
@@ -153,6 +153,8 @@ struct msi_device_data {int msi_setup_device_data (struct device *dev); +unsigned int msi_get_virq (struct device *dev,unsigned int index); +/* 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)
kernel/irq/msi.c +36 -0
@@ -105,6 +105,42 @@ int msi_setup_device_data(struct device *dev)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), 0 if not found +*/ +unsigned int msi_get_virq (struct device *dev,unsigned int index) +{ +struct msi_desc *desc; +bool pcimsi; + +if (!dev->msi.data) +return 0 ; + + pcimsi =dev_is_pci (dev) ?to_pci_dev (dev)->msi_enabled : false; + +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 0 ; +} +EXPORT_SYMBOL_GPL (msi_get_virq); +#ifdef CONFIG_SYSFS static ssize_t msi_mode_show (struct device *dev,struct device_attribute *attr,char *buf)
PATCH v3 27/35 PCI/MSI: Use __msi_get_virq() in pci_get_vector()
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Use msi_get_vector() and handle the return value to be compatible.
No functional change intended.
---
V2: Handle the INTx case directly instead of trying to be overly smart - Marc
--- drivers/pci/msi/msi.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-)
drivers/pci/msi/msi.c +5 -20
@@ -1037,28 +1037,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; +unsigned int irq; -for_each_pci_msi_entry (entry, dev) { -if (entry->msi_index == nr) -return entry->irq; - } -WARN_ON_ONCE (1 ); -return -EINVAL ; - } +if (!dev->msi_enabled && !dev->msix_enabled) +return !nr ? dev->irq : -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; + irq =msi_get_virq (&dev->dev, nr); +return irq ? irq : -EINVAL ; }EXPORT_SYMBOL (pci_irq_vector);
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [patch V3 27/35] PCI/MSI: Use __msi_get_virq() in pci_get_vector()
Quoted 6 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
Use
msi_get_vector()and handle the return value to be compatible.No functional change intended.
Quoted 7 lines
Signed-off-by Thomas Gleixner <[email protected]>Reviewed-by Greg Kroah-Hartman <[email protected]>---
V2: Handle the INTx case directly instead of trying to be overly smart - Marc--- drivers/pci/msi/msi.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-)
Jason
[tip: irq/msi] PCI/MSI: Use msi_get_virq() in pci_get_vector()
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 82ff8e6b78fc4587a4255301f0a283506daf11b6 Gitweb: https://git.kernel.org/tip/82ff8e6b78fc4587a4255301f0a283506daf11b6 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:25 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:41 +01:00
PCI/MSI: Use msi_get_virq() in pci_get_vector()
Use msi_get_vector() and handle the return value to be compatible.
No functional change intended.
--- drivers/pci/msi/msi.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-)
drivers/pci/msi/msi.c +5 -20
@@ -1080,28 +1080,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; - -for_each_pci_msi_entry (entry, dev) { -if (entry->msi_index == nr) -return entry->irq; - } -WARN_ON_ONCE (1 ); -return -EINVAL ; - } +unsigned int irq; -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 ; - } +if (!dev->msi_enabled && !dev->msix_enabled) +return !nr ? dev->irq : -EINVAL ; -return dev->irq + nr; + irq =msi_get_virq (&dev->dev, nr); +return irq ? irq : -EINVAL ; }EXPORT_SYMBOL (pci_irq_vector);
PATCH v3 28/35 PCI/MSI: Simplify pci_irq_get_affinity()
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Replace open coded MSI descriptor chasing and use the proper accessor functions instead.
--- drivers/pci/msi/msi.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)
drivers/pci/msi/msi.c +10 -16
@@ -1061,26 +1061,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);
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] PCI/MSI: Simplify pci_irq_get_affinity()
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: f48235900182d64537c6e8f8dc0932b57a1a0638 Gitweb: https://git.kernel.org/tip/f48235900182d64537c6e8f8dc0932b57a1a0638 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:26 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:41 +01:00
PCI/MSI: Simplify pci_irq_get_affinity()
Replace open coded MSI descriptor chasing and use the proper accessor functions instead.
--- drivers/pci/msi/msi.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)
drivers/pci/msi/msi.c +10 -16
@@ -1104,26 +1104,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);
Re: [patch V3 28/35] PCI/MSI: Simplify pci_irq_get_affinity()
In reply to Thomas GleixnerHi Thomas,
Quoted 8 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
Replace open coded MSI descriptor chasing and use the proper accessor functions instead.
Signed-off-by Thomas Gleixner <[email protected]>Reviewed-by Greg Kroah-Hartman <[email protected]>Reviewed-by Jason Gunthorpe <[email protected]>
Apologies if this has already been reported somewhere else or already fixed, I did a search of all of lore and did not see anything similar to it and I did not see any new commits in -tip around this.
I just bisected a boot failure on my AMD test desktop to this patch as commit f48235900182 ("PCI/MSI: Simplify pci_irq_get_affinity()") in -next. It looks like there is a problem with the NVMe drive after this change according to the logs. Given that the hard drive is not getting mounted for journald to write logs to, I am not really sure how to get them from the machine so I have at least taken a picture of what I see on my screen; open to ideas on that front!
Please let me know what information I can provide to make debugging this easier and I am more than happy to apply and test patches as needed.
Cheers,
Nathan
Re: [patch V3 28/35] PCI/MSI: Simplify pci_irq_get_affinity()
Quoted 8 lines · Nathan Chancellor
On Fri, Dec 10, 2021 at 11:19:26PM +0100, Thomas Gleixner wrote:
I just bisected a boot failure on my AMD test desktop to this patch as commitf48235900182("PCI/MSI: Simplifypci_irq_get_affinity()") in -next. It looks like there is a problem with the NVMe drive after this change according to the logs. Given that the hard drive is not getting mounted for journald to write logs to, I am not really sure how to get them from the machine so I have at least taken a picture of what I see on my screen; open to ideas on that front!
Bah. Fix below.
Thanks,
tglx
---
drivers/pci/msi/msi.c +5 -2
@@ -1100,7 +1100,7 @@ EXPORT_SYMBOL(pci_irq_vector);*/ const struct cpumask *pci_irq_get_affinity (struct pci_dev *dev,int nr) { -int irq =pci_irq_vector (dev, nr); +int idx, irq =pci_irq_vector (dev, nr);struct msi_desc *desc;if (WARN_ON_ONCE (irq <=0 ))
@@ -1113,7 +1113,10 @@ const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr)if (WARN_ON_ONCE (!desc->affinity))return NULL ; -return &desc->affinity[nr].mask; + +/* MSI has a mask array in the descriptor. */ + idx = dev->msi_enabled ? nr :0 ; +return &desc->affinity[idx].mask; }EXPORT_SYMBOL (pci_irq_get_affinity);
Nathan Chancellor
Tested-byRe: [patch V3 28/35] PCI/MSI: Simplify pci_irq_get_affinity()
Quoted 11 lines · Thomas Gleixner
Quoted 8 lines · Nathan Chancellor
On Fri, Dec 10, 2021 at 11:19:26PM +0100, Thomas Gleixner wrote:
I just bisected a boot failure on my AMD test desktop to this patch as commitf48235900182("PCI/MSI: Simplifypci_irq_get_affinity()") in -next. It looks like there is a problem with the NVMe drive after this change according to the logs. Given that the hard drive is not getting mounted for journald to write logs to, I am not really sure how to get them from the machine so I have at least taken a picture of what I see on my screen; open to ideas on that front!Bah. Fix below.
Quoted 30 lines
Thanks,
tglx
---drivers/pci/msi/msi.c +5
-2@@ -1100,7 +1100,7 @@ EXPORT_SYMBOL(pci_irq_vector);*/ const struct cpumask *pci_irq_get_affinity (struct pci_dev *dev,int nr) { -int irq =pci_irq_vector (dev, nr); +int idx, irq =pci_irq_vector (dev, nr);struct msi_desc *desc;if (WARN_ON_ONCE (irq <=0 ))@@ -1113,7 +1113,10 @@ const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr)if (WARN_ON_ONCE (!desc->affinity))return NULL ; -return &desc->affinity[nr].mask; + +/* MSI has a mask array in the descriptor. */ + idx = dev->msi_enabled ? nr :0 ; +return &desc->affinity[idx].mask; }EXPORT_SYMBOL (pci_irq_get_affinity);
[tip: irq/msi] PCI/MSI: Unbreak pci_irq_get_affinity()
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: d558285413ea2f934ab90223ba908c30c5113aee Gitweb: https://git.kernel.org/tip/d558285413ea2f934ab90223ba908c30c5113aee Author: Thomas Gleixner <[email protected]> AuthorDate: Sat, 18 Dec 2021 11:25:14 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Sat, 18 Dec 2021 20:33:21 +01:00
PCI/MSI: Unbreak pci_irq_get_affinity()
The recent cleanup of pci_irq_get_affinity() broke the function for PCI/MSI-X and indices > 0. Only the MSI descriptor for PCI/MSI has more than one affinity mask which can be retrieved via the MSI index.
PCI/MSI-X has one descriptor per vector and each has a single affinity mask.
Use index 0 when accessing the affinity mask in the MSI descriptor when MSI-X is enabled.
--- drivers/pci/msi/msi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/pci/msi/msi.c +8 -2
@@ -1100,7 +1100,7 @@ EXPORT_SYMBOL(pci_irq_vector);*/ const struct cpumask *pci_irq_get_affinity (struct pci_dev *dev,int nr) { -int irq =pci_irq_vector (dev, nr); +int idx, irq =pci_irq_vector (dev, nr);struct msi_desc *desc;if (WARN_ON_ONCE (irq <=0 ))
@@ -1113,7 +1113,13 @@ const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr)if (WARN_ON_ONCE (!desc->affinity))return NULL ; -return &desc->affinity[nr].mask; + +/* +* MSI has a mask array in the descriptor. +* MSI-X has a single mask. +*/ + idx = dev->msi_enabled ? nr :0 ; +return &desc->affinity[idx].mask; }EXPORT_SYMBOL (pci_irq_get_affinity);
Cédric Le Goater
Tested-byRe: [patch V3 28/35] PCI/MSI: Simplify pci_irq_get_affinity()
In reply to Thomas GleixnerQuoted 11 lines · Thomas Gleixner
Quoted 8 lines · Nathan Chancellor
On Fri, Dec 10, 2021 at 11:19:26PM +0100, Thomas Gleixner wrote:
I just bisected a boot failure on my AMD test desktop to this patch as commitf48235900182("PCI/MSI: Simplifypci_irq_get_affinity()") in -next. It looks like there is a problem with the NVMe drive after this change according to the logs. Given that the hard drive is not getting mounted for journald to write logs to, I am not really sure how to get them from the machine so I have at least taken a picture of what I see on my screen; open to ideas on that front!Bah. Fix below.
That's a fix for the issue I was seeing on pseries with NVMe.
Thanks,
C.
Quoted 20 lines
Thanks,
tglx
---drivers/pci/msi/msi.c +1
-1@@ -1100,7 +1100,7 @@ EXPORT_SYMBOL(pci_irq_vector);*/ const struct cpumask *pci_irq_get_affinity (struct pci_dev *dev,int nr) { -int irq =pci_irq_vector (dev, nr); +int idx, irq =pci_irq_vector (dev, nr);struct msi_desc *desc;if (WARN_ON_ONCE (irq <=0 ))@@ -1113,7 +1113,10 @@ const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr)
drivers/pci/msi/msi.c const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr) · line 1122
Quoted 10 lines
drivers/pci/msi/msi.c +4
-1if (WARN_ON_ONCE (!desc->affinity))return NULL ; -return &desc->affinity[nr].mask; + +/* MSI has a mask array in the descriptor. */ + idx = dev->msi_enabled ? nr :0 ; +return &desc->affinity[idx].mask; }EXPORT_SYMBOL (pci_irq_get_affinity);
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [patch V3 28/35] PCI/MSI: Simplify pci_irq_get_affinity()
Quoted 11 lines · Cédric Le Goater
Quoted 10 lines · Thomas Gleixner
Quoted 8 lines · Nathan Chancellor
On Fri, Dec 10, 2021 at 11:19:26PM +0100, Thomas Gleixner wrote:
I just bisected a boot failure on my AMD test desktop to this patch as commitf48235900182("PCI/MSI: Simplifypci_irq_get_affinity()") in -next. It looks like there is a problem with the NVMe drive after this change according to the logs. Given that the hard drive is not getting mounted for journald to write logs to, I am not really sure how to get them from the machine so I have at least taken a picture of what I see on my screen; open to ideas on that front!
Quoted 5 lines
Quoted 1 line
Bah. Fix below.
That's a fix for the issue I was seeing on pseries with NVMe.
Tested-by Cédric Le Goater <[email protected]>
I had a faint memory that I've seen that issue before, but couldn't find the mail in those massive threads.
Thanks for confirming!
tglx
Re: [patch V3 28/35] PCI/MSI: Simplify pci_irq_get_affinity()
In reply to Thomas GleixnerQuoted 8 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
Replace open coded MSI descriptor chasing and use the proper accessor functions instead.
Signed-off-by Thomas Gleixner <[email protected]>Reviewed-by Greg Kroah-Hartman <[email protected]>Reviewed-by Jason Gunthorpe <[email protected]>
This patch results in the following runtime warning when booting x86 (32 bit) nosmp images from NVME in qemu.
[ 14.825482] nvme nvme0: 1/0/0 default/read/poll queues ILLOPC: ca7c6d10: 0f 0b [ 14.826188] ------------[ cut here ]------------ [ 14.826307] WARNING: CPU: 0 PID: 7 at drivers/pci/msi/msi.c:1114 pci_irq_get_affinity+0x80/0x90 [ 14.826455] Modules linked in: [ 14.826640] CPU: 0 PID: 7 Comm: kworker/u2:0 Not tainted 5.17.0-rc1-00419-g1d2d8baaf053 #1 [ 14.826797] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014 [ 14.827132] Workqueue: nvme-reset-wq nvme_reset_work [ 14.827336] EIP: pci_irq_get_affinity+0x80/0x90 [ 14.827452] Code: e8 d5 30 af ff 85 c0 75 bd 90 0f 0b 31 c0 5b 5e 5d c3 8d b4 26 00 00 00 00 90 5b b8 24 32 7e cb 5e 5d c3 8d b4 26 00 00 00 00 <0f> 0b eb e0 8d b4 26 00 00 00 00 8d 74 26 00 90 55 89 e5 57 56 53 [ 14.827717] EAX: 00000000 EBX: c18ba000 ECX: 00000000 EDX: c297c210 [ 14.827816] ESI: 00000001 EDI: c18ba000 EBP: c1247e24 ESP: c1247e1c [ 14.827924] DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068 EFLAGS: 00000246 [ 14.828110] CR0: 80050033 CR2: ffda9000 CR3: 0b8ad000 CR4: 000006d0 [ 14.828268] Call Trace: [ 14.828554] blk_mq_pci_map_queues+0x26/0x70 [ 14.828710] nvme_pci_map_queues+0x75/0xc0 [ 14.828808] blk_mq_update_queue_map+0x86/0xa0 [ 14.828891] blk_mq_alloc_tag_set+0xf3/0x390 [ 14.828965] ? nvme_wait_freeze+0x3d/0x50 [ 14.829137] nvme_reset_work+0xd02/0x1120 [ 14.829269] ? lock_acquire+0xc3/0x290 [ 14.829435] process_one_work+0x1ed/0x490 [ 14.829569] worker_thread+0x15e/0x3c0 [ 14.829665] kthread+0xd3/0x100 [ 14.829729] ? process_one_work+0x490/0x490 [ 14.829799] ? kthread_complete_and_exit+0x20/0x20 [ 14.829890] ret_from_fork+0x1c/0x28
Bisect results below.
#regzbot introduced: f48235900182d6
Guenter
---
# bad: [e783362eb54cd99b2cac8b3a9aeac942e6f6ac07] Linux 5.17-rc1
# good: [df0cc57e057f18e44dac8e6c18aba47ab53202f9] Linux 5.16
git bisect start 'v5.17-rc1' 'v5.16'
# good: [fef8dfaea9d6c444b6c2174b3a2b0fca4d226c5e] Merge tag 'regulator-v5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
git bisect good fef8dfaea9d6c444b6c2174b3a2b0fca4d226c5e
# bad: [3ceff4ea07410763d5d4cccd60349bf7691e7e61] Merge tag 'sound-5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
git bisect bad 3ceff4ea07410763d5d4cccd60349bf7691e7e61
# good: [57ea81971b7296b42fc77424af44c5915d3d4ae2] Merge tag 'usb-5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
git bisect good 57ea81971b7296b42fc77424af44c5915d3d4ae2
# bad: [feb7a43de5ef625ad74097d8fd3481d5dbc06a59] Merge tag 'irq-msi-2022-01-13' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
git bisect bad feb7a43de5ef625ad74097d8fd3481d5dbc06a59
# good: [ce990f1de0bc6ff3de43d385e0985efa980fba24] Merge tag 'for-linus-5.17-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
git bisect good ce990f1de0bc6ff3de43d385e0985efa980fba24
# good: [4afd2a9355a9deb16ea42b896820dacf49843a8f] Merge branches 'clk-ingenic' and 'clk-mediatek' into clk-next
git bisect good 4afd2a9355a9deb16ea42b896820dacf49843a8f
# good: [455e73a07f6e288b0061dfcf4fcf54fa9fe06458] Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
git bisect good 455e73a07f6e288b0061dfcf4fcf54fa9fe06458
# bad: [f2948df5f87a722591499da60ab91c611422f755] x86/pci/xen: Use msi_for_each_desc()
git bisect bad f2948df5f87a722591499da60ab91c611422f755
# good: [93296cd1325d1d9afede60202d8833011c9001f2] PCI/MSI: Allocate MSI device data on first use
git bisect good 93296cd1325d1d9afede60202d8833011c9001f2
# good: [82ff8e6b78fc4587a4255301f0a283506daf11b6] PCI/MSI: Use msi_get_virq() in pci_get_vector()
git bisect good 82ff8e6b78fc4587a4255301f0a283506daf11b6
# bad: [125282cd4f33ecd53a24ae4807409da0e5e90fd4] genirq/msi: Move descriptor list to struct msi_device_data
git bisect bad 125282cd4f33ecd53a24ae4807409da0e5e90fd4
# bad: [065afdc9c521f05c53f226dabe5dda2d30294d65] iommu/arm-smmu-v3: Use msi_get_virq()
git bisect bad 065afdc9c521f05c53f226dabe5dda2d30294d65
# bad: [f6632bb2c1454b857adcd131320379ec16fd8666] dmaengine: mv_xor_v2: Get rid of msi_desc abuse
git bisect bad f6632bb2c1454b857adcd131320379ec16fd8666
# bad: [f48235900182d64537c6e8f8dc0932b57a1a0638] PCI/MSI: Simplify pci_irq_get_affinity()
git bisect bad f48235900182d64537c6e8f8dc0932b57a1a0638
# first bad commit: [f48235900182d64537c6e8f8dc0932b57a1a0638] PCI/MSI: Simplify pci_irq_get_affinity()
Re: [patch V3 28/35] PCI/MSI: Simplify pci_irq_get_affinity()
Quoted 8 lines · Guenter Roeck
On Fri, Dec 10, 2021 at 11:19:26PM +0100, Thomas Gleixner wrote:
This patch results in the following runtime warning when booting x86 (32 bit) nosmp images from NVME in qemu.[ 14.825482] nvme nvme0: 1/0/0 default/read/poll queues ILLOPC: ca7c6d10: 0f 0b [ 14.826188] ------------[ cut here ]------------ [ 14.826307] WARNING: CPU: 0 PID: 7 at drivers/pci/msi/msi.c:1114 pci_irq_get_affinity+0x80/0x90
This complains about msi_desc->affinity being NULL.
Quoted 2 lines
git bisect bad
f48235900182d64537c6e8f8dc0932b57a1a0638# first bad commit: [f48235900182d64537c6e8f8dc0932b57a1a0638] PCI/MSI: Simplify pci_irq_get_affinity()
Hrm. Can you please provide dmesg and /proc/interrupts from a kernel before that commit?
Thanks,
tglx
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [patch V3 28/35] PCI/MSI: Simplify pci_irq_get_affinity()
Quoted 10 lines · Thomas Gleixner
Quoted 8 lines · Guenter Roeck
On Fri, Dec 10, 2021 at 11:19:26PM +0100, Thomas Gleixner wrote:
This patch results in the following runtime warning when booting x86 (32 bit) nosmp images from NVME in qemu.[ 14.825482] nvme nvme0: 1/0/0 default/read/poll queues ILLOPC: ca7c6d10: 0f 0b [ 14.826188] ------------[ cut here ]------------ [ 14.826307] WARNING: CPU: 0 PID: 7 at drivers/pci/msi/msi.c:1114 pci_irq_get_affinity+0x80/0x90
Quoted 8 lines
This complains about
msi_desc->affinitybeing NULL.Quoted 2 lines
git bisect bad
f48235900182d64537c6e8f8dc0932b57a1a0638# first bad commit: [f48235900182d64537c6e8f8dc0932b57a1a0638] PCI/MSI: Simplify pci_irq_get_affinity()Hrm. Can you please provide dmesg and
/proc/interruptsfrom a kernel before that commit?
Sure. Please see http://server.roeck-us.net/qemu/x86/.
The logs are generated with with v5.16.4.
Guenter
Re: [patch V3 28/35] PCI/MSI: Simplify pci_irq_get_affinity()
Guenter,
Quoted 2 lines · Guenter Roeck
Sure. Please see http://server.roeck-us.net/qemu/x86/.
The logs are generated with with v5.16.4.
thanks for providing the data. It definitely helped me to leave the state of not seeing the wood for the trees. Fix below.
Thanks,
tglx
---
Subject: PCI/MSI: Remove bogus warning in pci_irq_get_affinity()
From: Thomas Gleixner <[email protected]>
Date: Mon, 31 Jan 2022 22:02:46 +0100
The recent overhaul of pci_irq_get_affinity() introduced a regression when pci_irq_get_affinity() is called for an MSI-X interrupt which was not allocated with affinity descriptor information.
The original code just returned a NULL pointer in that case, but the rework added a WARN_ON() under the assumption that the corresponding WARN_ON() in the MSI case can be applied to MSI-X as well.
In fact the MSI warning in the original code does not make sense either because it's legitimate to invoke pci_irq_get_affinity() for a MSI interrupt which was not allocated with affinity descriptor information.
Remove it and just return NULL as the original code did.
--- drivers/pci/msi/msi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/msi/msi.c +2 -1
@@ -1111,7 +1111,8 @@ const struct cpumask *pci_irq_get_affiniif (!desc)return cpu_possible_mask; -if (WARN_ON_ONCE (!desc->affinity)) +/* MSI[X] interrupts can be allocated without affinity descriptor */ +if (!desc->affinity)return NULL ;/*
[tip: irq/urgent] PCI/MSI: Remove bogus warning in pci_irq_get_affinity()
The following commit has been merged into the irq/urgent branch of tip:
The following commit has been merged into the irq/urgent branch of tip:
Commit-ID: dd7f5a11ac5a6f733f422dc22b4d145d3260304e Gitweb: https://git.kernel.org/tip/dd7f5a11ac5a6f733f422dc22b4d145d3260304e Author: Thomas Gleixner <[email protected]> AuthorDate: Mon, 31 Jan 2022 22:02:46 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Fri, 04 Feb 2022 09:54:20 +01:00
PCI/MSI: Remove bogus warning in pci_irq_get_affinity()
The recent overhaul of pci_irq_get_affinity() introduced a regression when pci_irq_get_affinity() is called for an MSI-X interrupt which was not allocated with affinity descriptor information.
The original code just returned a NULL pointer in that case, but the rework added a WARN_ON() under the assumption that the corresponding WARN_ON() in the MSI case can be applied to MSI-X as well.
In fact the MSI warning in the original code does not make sense either because it's legitimate to invoke pci_irq_get_affinity() for a MSI interrupt which was not allocated with affinity descriptor information.
Remove it and just return NULL as the original code did.
--- drivers/pci/msi/msi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/msi/msi.c +2 -1
@@ -1111,7 +1111,8 @@ const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr)if (!desc)return cpu_possible_mask; -if (WARN_ON_ONCE (!desc->affinity)) +/* MSI[X] interrupts can be allocated without affinity descriptor */ +if (!desc->affinity)return NULL ;/*
Re: [tip: irq/urgent] PCI/MSI: Remove bogus warning in pci_irq_get_affinity()
[stripped the CC list to avoid spamming people, we all get enough mail]
Thx for fixing the regression. Sadly the fix didn't link to all places where the issue was reported using "Link:" tags, as explained by both Documentation/process/submitting-patches.rst and Documentation/process/5.Posting.rst
Please consider placing them in the future, at least one tool is relying on the presence of such links: my regression tracking bot 'regzbot', which using them to automatically detect patch posting and commits fixing tracked regressions -- which makes my my life as the Linux kernel's regression tracker a lot easier, as otherwise I have to tell regzbot about fixes manually:
#regzbot fixed-by: dd7f5a11ac5a6f733f422dc22b
tia!
Ciao, Thorsten
Quoted 48 lines · On 04.02.22 09:57, tip-bot2 for Thomas Gleixner wrote:
The following commit has been merged into the irq/urgent branch of tip:
Commit-ID: dd7f5a11ac5a6f733f422dc22b4d145d3260304e Gitweb: https://git.kernel.org/tip/dd7f5a11ac5a6f733f422dc22b4d145d3260304e Author: Thomas Gleixner <[email protected]> AuthorDate: Mon, 31 Jan 2022 22:02:46 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Fri, 04 Feb 2022 09:54:20 +01:00PCI/MSI: Remove bogus warning in
pci_irq_get_affinity()The recent overhaul of
pci_irq_get_affinity()introduced a regression whenpci_irq_get_affinity()is called for an MSI-X interrupt which was not allocated with affinity descriptor information.The original code just returned a NULL pointer in that case, but the rework added a
WARN_ON()under the assumption that the correspondingWARN_ON()in the MSI case can be applied to MSI-X as well.In fact the MSI warning in the original code does not make sense either because it's legitimate to invoke
pci_irq_get_affinity()for a MSI interrupt which was not allocated with affinity descriptor information.Remove it and just return NULL as the original code did.
Fixes f48235900182 ("PCI/MSI: Simplify pci_irq_get_affinity()")Reported-by Guenter Roeck <[email protected]>Signed-off-by Thomas Gleixner <[email protected]>--- drivers/pci/msi/msi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/pci/msi/msi.c +2
-1@@ -1111,7 +1111,8 @@ const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr)if (!desc)return cpu_possible_mask; -if (WARN_ON_ONCE (!desc->affinity)) +/* MSI[X] interrupts can be allocated without affinity descriptor */ +if (!desc->affinity)return NULL ;/*
PATCH v3 29/35 dmaengine: mv_xor_v2: Get rid of msi_desc abuse
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Storing a pointer to the MSI descriptor just to keep track of the Linux interrupt number is daft. Use msi_get_virq() instead.
--- drivers/dma/mv_xor_v2.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/dma/mv_xor_v2.c +5 -11
@@ -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 platfoint 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 platfoif (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);
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [patch V3 29/35] dmaengine: mv_xor_v2: Get rid of msi_desc abuse
Quoted 4 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
Storing a pointer to the MSI descriptor just to keep track of the Linux interrupt number is daft. Use
msi_get_virq()instead.
Signature · 1 line
~Vinod
[tip: irq/msi] dmaengine: mv_xor_v2: Get rid of msi_desc abuse
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: f6632bb2c1454b857adcd131320379ec16fd8666 Gitweb: https://git.kernel.org/tip/f6632bb2c1454b857adcd131320379ec16fd8666 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:28 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:41 +01:00
dmaengine: mv_xor_v2: Get rid of msi_desc abuse
Storing a pointer to the MSI descriptor just to keep track of the Linux interrupt number is daft. Use msi_get_virq() instead.
--- drivers/dma/mv_xor_v2.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/dma/mv_xor_v2.c +5 -11
@@ -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 platform_device *pdev)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 platform_device *pdev)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 platform_device *pdev) 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);
PATCH v3 30/35 perf/smmuv3: Use msi_get_virq()
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Let the core code fiddle with the MSI descriptor retrieval.
--- drivers/perf/arm_smmuv3_pmu.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/perf/arm_smmuv3_pmu.c +1 -4
@@ -684,7 +684,6 @@ static void smmu_pmu_write_msi_msg(strucstatic 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 smreturn ; } - 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);
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] perf/smmuv3: Use msi_get_virq()
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 848456705565da8de0fac4f6487f2a04813f60cc Gitweb: https://git.kernel.org/tip/848456705565da8de0fac4f6487f2a04813f60cc Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:29 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:41 +01:00
perf/smmuv3: Use msi_get_virq()
Let the core code fiddle with the MSI descriptor retrieval.
--- drivers/perf/arm_smmuv3_pmu.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/perf/arm_smmuv3_pmu.c +1 -4
@@ -684,7 +684,6 @@ static void smmu_pmu_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg)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 smmu_pmu *pmu)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);
PATCH v3 31/35 iommu/arm-smmu-v3: Use msi_get_virq()
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Let the core code fiddle with the MSI descriptor retrieval.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +3 -16
@@ -3154,7 +3154,6 @@ static void arm_smmu_write_msi_msg(strucstatic 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 areturn ; } -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);
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] iommu/arm-smmu-v3: Use msi_get_virq()
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 065afdc9c521f05c53f226dabe5dda2d30294d65 Gitweb: https://git.kernel.org/tip/065afdc9c521f05c53f226dabe5dda2d30294d65 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:31 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:41 +01:00
iommu/arm-smmu-v3: Use msi_get_virq()
Let the core code fiddle with the MSI descriptor retrieval.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +3 -16
@@ -3154,7 +3154,6 @@ static void arm_smmu_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg)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 arm_smmu_device *smmu)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);
PATCH v3 32/35 mailbox: bcm-flexrm-mailbox: Rework MSI interrupt handling
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
No point in retrieving the MSI descriptors. Just query the Linux interrupt number.
--- drivers/mailbox/bcm-flexrm-mailbox.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/mailbox/bcm-flexrm-mailbox.c +2 -5
@@ -1497,7 +1497,6 @@ static int flexrm_mbox_probe(struct platint 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 ())
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] mailbox: bcm-flexrm-mailbox: Rework MSI interrupt handling
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: d722e9a51178d42b07555a9420d286dad3341d61 Gitweb: https://git.kernel.org/tip/d722e9a51178d42b07555a9420d286dad3341d61 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:32 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:41 +01:00
mailbox: bcm-flexrm-mailbox: Rework MSI interrupt handling
No point in retrieving the MSI descriptors. Just query the Linux interrupt number.
--- drivers/mailbox/bcm-flexrm-mailbox.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/mailbox/bcm-flexrm-mailbox.c +2 -5
@@ -1497,7 +1497,6 @@ static int flexrm_mbox_probe(struct platform_device *pdev)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 platform_device *pdev) 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 ())
PATCH v3 33/35 bus: fsl-mc: fsl-mc-allocator: Rework MSI handling
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
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.
--- 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(-)
drivers/bus/fsl-mc/dprc-driver.c +4 -4
@@ -400,7 +400,7 @@ static irqreturn_t dprc_irq0_handler_thrstruct 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_thrreturn 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); }
drivers/bus/fsl-mc/fsl-mc-allocator.c +2 -7
@@ -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;
drivers/bus/fsl-mc/fsl-mc-msi.c +3 -3
@@ -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)
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +2 -2
@@ -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 freturn 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);
drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c +1 -3
@@ -129,7 +129,6 @@ static irqreturn_t dpaa2_ptp_irq_handlerstatic 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,
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +2 -3
@@ -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(strucreturn 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;
drivers/soc/fsl/dpio/dpio-driver.c +4 -4
@@ -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 ; }
drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c +2 -2
@@ -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(sreturn 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];
include/linux/fsl/mc.h +2 -2
@@ -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;
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
[tip: irq/msi] bus: fsl-mc: fsl-mc-allocator: Rework MSI handling
The following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: d86a6d47bcc6b41fe2a4e13313d66a772d00382f Gitweb: https://git.kernel.org/tip/d86a6d47bcc6b41fe2a4e13313d66a772d00382f Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:34 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:41 +01:00
bus: fsl-mc: fsl-mc-allocator: Rework MSI handling
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.
--- 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(-)
drivers/bus/fsl-mc/dprc-driver.c +4 -4
@@ -400,7 +400,7 @@ static irqreturn_t dprc_irq0_handler_thread(int irq_num, void *arg)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_thread(int irq_num, void *arg)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(struct fsl_mc_device *mc_dev)* 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_mc_device *mc_dev) (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); }
drivers/bus/fsl-mc/fsl-mc-allocator.c +2 -7
@@ -350,7 +350,6 @@ int fsl_mc_populate_irq_pool(struct fsl_mc_device *mc_bus_dev, 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_device *mc_bus_dev, 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;
drivers/bus/fsl-mc/fsl-mc-msi.c +3 -3
@@ -58,11 +58,11 @@ static void fsl_mc_msi_update_dom_ops(struct msi_domain_info *info) }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 irq_data *irq_data,/* * 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)
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +2 -2
@@ -4246,7 +4246,7 @@ static int dpaa2_eth_setup_irqs(struct fsl_mc_device *ls_dev) } 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 fsl_mc_device *ls_dev)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);
drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c +1 -3
@@ -129,7 +129,6 @@ static irqreturn_t dpaa2_ptp_irq_handler_thread(int irq, void *priv)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_device *mc_dev) 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,
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +2 -3
@@ -1553,8 +1553,7 @@ static int dpaa2_switch_setup_irqs(struct fsl_mc_device *sw_dev) 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(struct fsl_mc_device *sw_dev)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;
drivers/soc/fsl/dpio/dpio-driver.c +4 -4
@@ -88,7 +88,7 @@ static void unregister_dpio_irq_handlers(struct fsl_mc_device *dpio_dev) 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(struct fsl_mc_device *dpio_dev, int cpu) 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(struct fsl_mc_device *dpio_dev, int cpu) }/* 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 ; }
drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c +2 -2
@@ -67,7 +67,7 @@ static int vfio_set_trigger(struct vfio_fsl_mc_device *vdev,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(struct vfio_fsl_mc_device *vdev,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];
include/linux/fsl/mc.h +2 -2
@@ -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;
PATCH v3 34/35 soc: ti: ti_sci_inta_msi: Get rid of ti_sci_inta_msi_get_virq()
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Just use the core function msi_get_virq().
--- 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(-)
drivers/dma/ti/k3-udma-private.c +2 -4
@@ -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);
drivers/dma/ti/k3-udma.c +4 -6
@@ -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);
drivers/soc/ti/k3-ringacc.c +1 -1
@@ -647,7 +647,7 @@ int k3_ringacc_get_ring_irq_num(struct kif (!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;
drivers/soc/ti/ti_sci_inta_msi.c +0 -12
@@ -148,15 +148,3 @@ void ti_sci_inta_msi_domain_free_irqs(stti_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);
include/linux/soc/ti/ti_sci_inta_msi.h +0 -1
@@ -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 */
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [patch V3 34/35] soc: ti: ti_sci_inta_msi: Get rid of ti_sci_inta_msi_get_virq()
Quoted 11 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
Just use the core function
msi_get_virq().Signed-off-by Thomas Gleixner <[email protected]>Reviewed-by Greg Kroah-Hartman <[email protected]>Reviewed-by Jason Gunthorpe <[email protected]>Cc Peter Ujfalusi <[email protected]>Cc Vinod Koul <[email protected]>
Re: [patch V3 34/35] soc: ti: ti_sci_inta_msi: Get rid of ti_sci_inta_msi_get_virq()
In reply to Thomas GleixnerQuoted 3 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
Just use the core function
msi_get_virq().
Signature · 1 line
~Vinod
Re: [patch V3 34/35] soc: ti: ti_sci_inta_msi: Get rid of ti_sci_inta_msi_get_virq()
In reply to Thomas GleixnerQuoted 10 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
Just use the core function
msi_get_virq().Signed-off-by Thomas Gleixner <[email protected]>Reviewed-by Greg Kroah-Hartman <[email protected]>Reviewed-by Jason Gunthorpe <[email protected]>Cc Peter Ujfalusi <[email protected]>Cc Vinod Koul <[email protected]>
Signature · 3 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D)/Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
[tip: irq/msi] soc: ti: ti_sci_inta_msi: Get rid of ti_sci_inta_msi_get_virq()
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 89e0032ec201f76c86d6e3e6f94574dfb8e39b71 Gitweb: https://git.kernel.org/tip/89e0032ec201f76c86d6e3e6f94574dfb8e39b71 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:35 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:41 +01:00
soc: ti: ti_sci_inta_msi: Get rid of ti_sci_inta_msi_get_virq()
Just use the core function msi_get_virq().
--- 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(-)
drivers/dma/ti/k3-udma-private.c +2 -4
@@ -168,8 +168,7 @@ int xudma_pktdma_tflow_get_irq(struct udma_dev *ud, int udma_tflow_id) {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 udma_dev *ud, int udma_rflow_id) {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);
drivers/dma/ti/k3-udma.c +4 -6
@@ -2313,8 +2313,7 @@ static int udma_alloc_chan_resources(struct dma_chan *chan)/* 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(struct dma_chan *chan) 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(struct dma_chan *chan)/* 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(struct dma_chan *chan) 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);
drivers/soc/ti/k3-ringacc.c +1 -1
@@ -647,7 +647,7 @@ int k3_ringacc_get_ring_irq_num(struct k3_ring *ring)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;
drivers/soc/ti/ti_sci_inta_msi.c +0 -12
@@ -148,15 +148,3 @@ void ti_sci_inta_msi_domain_free_irqs(struct device *dev)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);
include/linux/soc/ti/ti_sci_inta_msi.h +0 -1
@@ -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 */
PATCH v3 35/35 dmaengine: qcom_hidma: Cleanup MSI handling
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
There is no reason to walk the MSI descriptors to retrieve the interrupt number for a device. Use msi_get_virq() instead.
--- drivers/dma/qcom/hidma.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-)
drivers/dma/qcom/hidma.c +18 -24
@@ -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 ;
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [patch V3 35/35] dmaengine: qcom_hidma: Cleanup MSI handling
Quoted 4 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
There is no reason to walk the MSI descriptors to retrieve the interrupt number for a device. Use
msi_get_virq()instead.
Signature · 1 line
~Vinod
[tip: irq/msi] dmaengine: qcom_hidma: Cleanup MSI handling
In reply to Thomas GleixnerThe following commit has been merged into the irq/msi branch of tip:
The following commit has been merged into the irq/msi branch of tip:
Commit-ID: 1900c962e2dcfacec894558eb34971bdc9c67443 Gitweb: https://git.kernel.org/tip/1900c962e2dcfacec894558eb34971bdc9c67443 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 10 Dec 2021 23:19:37 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 16 Dec 2021 22:16:42 +01:00
dmaengine: qcom_hidma: Cleanup MSI handling
There is no reason to walk the MSI descriptors to retrieve the interrupt number for a device. Use msi_get_virq() instead.
--- drivers/dma/qcom/hidma.c | 42 ++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 24 deletions(-)
drivers/dma/qcom/hidma.c +18 -24
@@ -678,11 +678,13 @@ static void hidma_free_msis(struct hidma_dev *dmadev) {#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 hidma_dev *dmadev, 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 ;
Nishanth Menon
maintainerOn 23:18-20211210, Thomas Gleixner wrote:
[...]
Quoted 4 lines
It's also available from git:
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.gitmsi-v3-part-2
[...]
Quoted 7 lines
--- drivers/dma/ti/k3-udma-private.c | 6 drivers/dma/ti/k3-udma.c | 14 - drivers/irqchip/irq-ti-sci-inta.c | 2 drivers/soc/ti/k3-ringacc.c | 6 drivers/soc/ti/ti_sci_inta_msi.c | 22 -- include/linux/soc/ti/ti_sci_inta_msi.h | 1
Also while testing on TI K3 platforms, I noticed:
msi_device_data_release/msi_device_destroy_sysfs in am64xx-evm / j7200
[1] https://gist.github.com/nmenon/36899c7819681026cfe1ef185fb95f33#file-am64xx-evm-txt-L1018
[2] https://gist.github.com/nmenon/36899c7819681026cfe1ef185fb95f33#file-j7200-evm-txt-L1076
Which is not present in vanilla v5.16-rc4
v5.16-rc4:
https://gist.github.com/nmenon/1aee3f0a7da47d5e9dcb7336b32a70cb
msi-v3-part-2:
https://gist.github.com/nmenon/36899c7819681026cfe1ef185fb95f33
(.config https://gist.github.com/nmenon/ec6f95303828abf16a64022d8e3a269f)
Vs:
next-20211208:
https://gist.github.com/nmenon/f5ca3558bd5c1fbe62dc5ceb420b536e
Signature · 3 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D)/Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
Quoted 4 lines · Nishanth Menon
On 23:18-20211210, Thomas Gleixner wrote:
Also while testing on TI K3 platforms, I noticed:msi_device_data_release/msi_device_destroy_sysfs in am64xx-evm / j7200
The warning complains about a device being released with MSI descriptors still attached to the device. This was added by:
5b012cede0f7 ("device: Add device::msi_data pointer and struct msi_device_data")
That's not a regression caused by this commit. The warning is just exposing an already existing problem in the iwlwifi driver, which seems to do:
probe()
setup_pci_msi[x]_interrupts()
start_drv()
if (try_to_load_firmware() == FAIL)
device_release_driver()
...
msi_device_data_release()
WARN()Thanks,
tglx
Nishanth Menon
maintainerQuoted 15 lines · Thomas Gleixner
Quoted 4 lines · Nishanth Menon
On 23:18-20211210, Thomas Gleixner wrote:
Also while testing on TI K3 platforms, I noticed:msi_device_data_release/msi_device_destroy_sysfs in am64xx-evm / j7200
The warning complains about a device being released with MSI descriptors still attached to the device. This was added by:
5b012cede0f7("device: Adddevice::msi_datapointer and structmsi_device_data")That's not a regression caused by this commit. The warning is just exposing an already existing problem in the iwlwifi driver, which seems to do:
Quoted 9 lines
probe()
setup_pci_msi[x]_interrupts()
start_drv()
if (try_to_load_firmware() == FAIL)
device_release_driver()
...
msi_device_data_release()
WARN()Agreed that the warning is fine, the null pointer exception that follows
[1] [2] it however does'nt look right and it can be trivially fixed with the following fixup for ee90787487bc ("genirq/msi: Provide msi_device_populate/destroy_sysfs()") below, with that the log looks like [3] - the warn is good, the null pointer exception and resultant crash could be avoided (not saying this is the best solution):
kernel/irq/msi.c +4 -1
@@ -252,11 +252,14 @@ int msi_device_populate_sysfs(struct device *dev)*/ void msi_device_destroy_sysfs (struct device *dev) { -const struct attribute_group **msi_irq_groups = dev->msi.data->attrs; +const struct attribute_group **msi_irq_groups;struct device_attribute *dev_attr;struct attribute **msi_attrs;int count =0 ; +if (!dev->msi.data) +return ; + msi_irq_groups = dev->msi.data->attrs; dev->msi.data->attrs =NULL ;if (!msi_irq_groups)return ;
[1] https://gist.github.com/nmenon/36899c7819681026cfe1ef185fb95f33#file-am64xx-evm-txt-L1049
[2] https://gist.github.com/nmenon/36899c7819681026cfe1ef185fb95f33#file-j7200-evm-txt-L1111
[3] https://gist.github.com/nmenon/575afe7d04463026a7e420a76c2c1c5b
https://gist.github.com/nmenon/575afe7d04463026a7e420a76c2c1c5b#file-am64xx-evm-txt-L1018 https://gist.github.com/nmenon/575afe7d04463026a7e420a76c2c1c5b#file-j7200-evm-txt-L1053
Signature · 7 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D)/Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 7 lines · Nishanth Menon
On 10:41-20211214, Thomas Gleixner wrote:
Agreed that the warning is fine, the null pointer exception that follows
[1] [2] it however does'nt look right and it can be trivially fixed with the following fixup foree90787487bc("genirq/msi: Provide msi_device_populate/destroy_sysfs()") below, with that the log looks like [3] - the warn is good, the null pointer exception and resultant crash could be avoided (not saying this is the best solution):
Aaargh.
[ 13.478122] Call trace: [ 13.509042] msi_device_destroy_sysfs+0x18/0x88 [ 13.509058] msi_domain_free_irqs+0x34/0x58 [ 13.509064] pci_msi_teardown_msi_irqs+0x30/0x3c [ 13.509072] free_msi_irqs+0x78/0xd4 [ 13.509077] pci_disable_msix+0x138/0x164 [ 13.529930] pcim_release+0x70/0x238 [ 13.529942] devres_release_all+0x9c/0xfc [ 13.529951] device_release_driver_internal+0x1a0/0x244 [ 13.542725] device_release_driver+0x18/0x24 [ 13.542741] iwl_req_fw_callback+0x1a28/0x1ddc [iwlwifi] [ 13.552308] request_firmware_work_func+0x50/0x9c [ 13.552320] process_one_work+0x194/0x25c
That's not a driver problem, that's an ordering issue vs. the devres muck. Let me go back to the drawing board. Sigh...
Thanks,
tglx
Quoted 16 lines · Thomas Gleixner
Quoted 1 line · Nishanth Menon
On 10:41-20211214, Thomas Gleixner wrote:
[ 13.478122] Call trace: [ 13.509042] msi_device_destroy_sysfs+0x18/0x88 [ 13.509058] msi_domain_free_irqs+0x34/0x58 [ 13.509064] pci_msi_teardown_msi_irqs+0x30/0x3c [ 13.509072] free_msi_irqs+0x78/0xd4 [ 13.509077] pci_disable_msix+0x138/0x164 [ 13.529930] pcim_release+0x70/0x238 [ 13.529942] devres_release_all+0x9c/0xfc [ 13.529951] device_release_driver_internal+0x1a0/0x244 [ 13.542725] device_release_driver+0x18/0x24 [ 13.542741] iwl_req_fw_callback+0x1a28/0x1ddc [iwlwifi] [ 13.552308] request_firmware_work_func+0x50/0x9c [ 13.552320] process_one_work+0x194/0x25c
Quoted 2 lines
That's not a driver problem, that's an ordering issue vs. the devres muck. Let me go back to the drawing board. Sigh...
Which is pretty obvious why:
pcim_enable_device()
devres_alloc(pcim_release...);
...
pci_irq_alloc()
msi_setup_device_data()
devres_alloc(msi_device_data_release, ...)and once the device is released:
msi_device_data_release()
...
pcim_release()
pci_disable_msi[x]()Groan....
Nishanth,
Quoted 6 lines · Thomas Gleixner
msi_device_data_release() ... pcim_release() pci_disable_msi[x]()Groan....
I think I managed to distangle this. Can you please give:
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git msi-v4-part-2
and/or the full pile:
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git msi-v4-part-3
a test ride?
Thanks,
tglx
Nishanth Menon
maintainerQuoted 8 lines · Thomas Gleixner
Nishanth,
Quoted 5 lines · Thomas Gleixner
msi_device_data_release() ... pcim_release() pci_disable_msi[x]()
Quoted 5 lines
Quoted 1 line
Groan....
I think I managed to distangle this. Can you please give:
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.gitmsi-v4-part-2
Umm.. I am not entirely sure what is going on.. but all kinds of weird corruption seems to occur with msi-v4-part-2 that does'nt seem to be present in v5.16-rc5. (I use NFS since ethernet in K3 platforms use inta/intr and dma that is impacted by this series).
I will try and rebase your patches on v5.16-rc4 to be sure as well and report back later today once i get some time.
[1] https://gist.github.com/nmenon/a66e022926c4c15313c45d44313d860c msi-v4-part-2
[2] https://gist.github.com/nmenon/43085664d69ad846d596e76a06ed0656 v5.16-rc5
Signature · 7 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Nishanth,
Quoted 11 lines · Nishanth Menon
Quoted 3 lines · Thomas Gleixner
I think I managed to distangle this. Can you please give:
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.gitmsi-v4-part-2Umm.. I am not entirely sure what is going on.. but all kinds of weird corruption seems to occur with msi-v4-part-2 that does'nt seem to be present in v5.16-rc5. (I use NFS since ethernet in K3 platforms use inta/intr and dma that is impacted by this series).
Quoted 5 lines
I will try and rebase your patches on v5.16-rc4 to be sure as well and report back later today once i get some time.
[1] https://gist.github.com/nmenon/a66e022926c4c15313c45d44313d860c msi-v4-part-2
[2] https://gist.github.com/nmenon/43085664d69ad846d596e76a06ed0656 v5.16-rc5
thanks for trying. I'll have a look again with brain awake tomorrow morning.
Thanks,
tglx
Quoted 4 lines · Thomas Gleixner
On Tue, Dec 14 2021 at 14:56, Nishanth Menon wrote:
thanks for trying. I'll have a look again with brain awake tomorrow morning.
Morning was busy with other things, but I found what my sleepy brain managed to do wrong yesterday evening.
Let me reintegrate the pile and I'll send you an update.
Thanks,
tglx
Quoted 10 lines · Thomas Gleixner
Quoted 4 lines · Thomas Gleixner
On Tue, Dec 14 2021 at 14:56, Nishanth Menon wrote:
thanks for trying. I'll have a look again with brain awake tomorrow morning.
Morning was busy with other things, but I found what my sleepy brain managed to do wrong yesterday evening.
Let me reintegrate the pile and I'll send you an update.
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git msi-v4.1-part-2
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git msi-v4.2-part-3
That should cure the problem.
Quoted 1 line · Thomas Gleixner
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git msi-v4.1-part-2
[...]
Quoted 1 line
That should cure the problem.
And it sure does. Thanks for looking closer and providing a fix.
https://gist.github.com/nmenon/9862a1c31b17fd6dfe0a30c54d396187
(msi-v4.1-part-2) looks clean
Also while I had detected pointer corruption in the previous v4
https://gist.github.com/nmenon/ce4d12f460db5cd511185c047d5d35d0
Running it again on v4.1 does indicate the fix is in place.
https://gist.github.com/nmenon/3231fbb0faa1b9c827b40d1ae6160626
please feel free to add:
Signature · 7 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D)/Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Hi Thomas,
Quoted 1 line · Thomas Gleixner
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git msi-v4.2-part-3
As you helped offline, summarizing the details on part3 of the series:
I was seeing failure[1] of NFS(DMA) on all TI K3 platforms:
[ 1.013258] ti-bcdma 485c0100.dma-controller: Number of rings: 68 [ 1.019963] ti-bcdma 485c0100.dma-controller: Failed to allocate IRQs -28 [ 1.026938] ti-bcdma 485c0100.dma-controller: Failed to allocate MSI interrupts
Rationale as you explained:
"
-28 is ENOSPC, which is returned when the interrupt allocation in the
MSI domain fails. Fix below.
"
Which turned out to be the fixup[2] you suggested and I confirm that fixes the problem for me.
With the fixup in place:
for part 3 of the series as well.
Thanks once again for your help. Hope we can roll in the fixes for part3.
[1] https://gist.github.com/nmenon/5971ab27aa626c022e276cc946e4b6c3
[2]
drivers/soc/ti/ti_sci_inta_msi.c +1 -0
@@ -68,6 +68,7 @@ static int ti_sci_inta_msi_alloc_descs(sint set, i, count =0 ;memset (&msi_desc,0 ,sizeof (msi_desc)); + msi_desc.nvec_used =1 ;for (set =0 ; set < res->sets; set++) {for (i =0 ; i < res->desc[set].num; i++, count++) {
Signature · 7 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D)/Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Nishanth,
Quoted 3 lines · Nishanth Menon
On 17:35-20211215, Thomas Gleixner wrote:
Thanks once again for your help. Hope we can roll in the fixes for part3.
Sure, it's only the one-liner for ti sci. Got it folded already.
Thanks for your help and testing!
tglx
Michael Kelley (LINUX)
Tested-byFrom: Thomas Gleixner <[email protected]> Sent: Wednesday, December 15, 2021 8:36 AM
Quoted 12 lines · Thomas Gleixner
Quoted 10 lines · Thomas Gleixner
Quoted 4 lines · Nishanth Menon
thanks for trying. I'll have a look again with brain awake tomorrow morning.
Morning was busy with other things, but I found what my sleepy brain managed to do wrong yesterday evening.
Quoted 6 lines
Quoted 1 line
Let me reintegrate the pile and I'll send you an update.
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git msi-v4.1-part-2 git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git msi-v4.2-part-3That should cure the problem.
Tested the msi-v4.2-part-3 tag in two different Azure/Hyper-V VMs. One is a Generation 1 VM that has legacy PCI devices and one is a Generation 2
VM with no legacy PCI devices. Tested hot add and remove of Mellanox
CX-3 and CX-4 SR-IOV NIC virtual functions that are directly mapped into the VM. Also tested local NVMe devices directly mapped into one of the VMs.
No issues encountered. So for Azure/Hyper-V specifically,