PCI/MSI: Getting rid of msi_controller, and other cleanups
Subsystems (12)
v3 cover PCI/MSI: Getting rid of msi_controller, and other cleanups
This is a respin of the series described at [1].
* From v2 [2]:
- Fixed the Xilinx driver, thanks to Bharat for testing it
- Dropped the no_msi attribute, and solely rely on msi_domain, which has the same effect for the only platform that was using it.
- Fixed compilation on architectures that do not select the generic MSI support
* From v1:
- Extracted the changes dealing with the MSI capture address for rcar and xilinx and moved them to separate patches
- Changed the rcar code to cope with c4e0fec2f7ee ("PCI: rcar: Always allocate MSI addresses in 32bit space")
- Fixed rcar resume code
- Reworked commit messages
- Rebased onto v5.12-rc4
- Collected Acks, and TBs, with thanks.
[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]
Marc Zyngier (13):
PCI: tegra: Convert to MSI domains
PCI: rcar: Don't allocate extra memory for the MSI capture address
PCI: rcar: Convert to MSI domains
PCI: xilinx: Don't allocate extra memory for the MSI capture address
PCI: xilinx: Convert to MSI domains
PCI: hv: Drop msi_controller structure
PCI/MSI: Drop use of msi_controller from core code PCI/MSI: Kill msi_controller structure
PCI/MSI: Kill default_teardown_msi_irqs()
PCI/MSI: Let PCI host bridges declare their reliance on MSI domains PCI/MSI: Make pci_host_common_probe() declare its reliance on MSI
domains
PCI/MSI: Document the various ways of ending up with NO_MSI
PCI: Refactor HT advertising of NO_MSI flag
Thomas Gleixner (1):
PCI: mediatek: Advertise lack of built-in MSI handling
drivers/pci/controller/Kconfig | 4 +- drivers/pci/controller/pci-host-common.c | 1 + drivers/pci/controller/pci-hyperv.c | 4 - drivers/pci/controller/pci-tegra.c | 343 ++++++++++++---------- drivers/pci/controller/pcie-mediatek.c | 4 + drivers/pci/controller/pcie-rcar-host.c | 356 +++++++++++------------ drivers/pci/controller/pcie-xilinx.c | 246 +++++++--------- drivers/pci/msi.c | 45 +-- drivers/pci/probe.c | 4 +- drivers/pci/quirks.c | 15 +- include/linux/msi.h | 17 +- include/linux/pci.h | 3 +- 12 files changed, 484 insertions(+), 558 deletions(-)
Signature · 1 line
2.29.2
PATCH v3 1/14 PCI: tegra: Convert to MSI domains
In anticipation of the removal of the msi_controller structure, convert the Tegra host controller driver to MSI domains.
We end-up with the usual two domain structure, the top one being a generic PCI/MSI domain, the bottom one being Tegra-specific and handling the actual HW interrupt allocation.
While at it, convert the normal interrupt handler to a chained handler, handle the controller's MSI IRQ edge triggered, support multiple MSIs per device and use the AFI_MSI_EN_VEC* registers to provide MSI masking.
--- drivers/pci/controller/Kconfig | 1 - drivers/pci/controller/pci-tegra.c | 343 ++++++++++++++++------------- 2 files changed, 185 insertions(+), 159 deletions(-)
drivers/pci/controller/Kconfig +0 -1
@@ -41,7 +41,6 @@ config PCI_TEGRA bool "NVIDIA Tegra PCIe controller" depends on ARCH_TEGRA || COMPILE_TEST depends on PCI_MSI_IRQ_DOMAIN - select PCI_MSI_ARCH_FALLBACKS help Say Y here if you want support for the PCIe host controller found on NVIDIA Tegra SoCs.
drivers/pci/controller/pci-tegra.c +185 -158
489 lines not on this page · raw message
Signature · 7 lines
2.29.2 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Jon Hunter
maintainerRe: [PATCH v3 01/14] PCI: tegra: Convert to MSI domains
Hi Marc,
Quoted 7 lines · Marc Zyngier
In anticipation of the removal of the
msi_controllerstructure, convert the Tegra host controller driver to MSI domains.We end-up with the usual two domain structure, the top one being a generic PCI/MSI domain, the bottom one being Tegra-specific and handling the actual HW interrupt allocation.
Quoted 8 lines
While at it, convert the normal interrupt handler to a chained handler, handle the controller's MSI IRQ edge triggered, support multiple MSIs per device and use the AFI_MSI_EN_VEC* registers to provide MSI masking.
Acked-by Bjorn Helgaas <[email protected]>[[email protected]: fix, clean up and address TODOs from Marc's draft]Signed-off-by Thierry Reding <[email protected]>Signed-off-by Marc Zyngier <[email protected]>
This change is breaking a suspend test that we are running on Tegra124 Jetson-TK1. The Tegra124 Jetson TK1 uses a PCI based ethernet device ...
$ lspci 00:02.0 PCI bridge: NVIDIA Corporation TegraK1 PCIe x1 Bridge (rev a1) 01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0c)
After resuming from suspend, networking is no longer working. The reason why this breaks our suspend test is because that setup is using NFS for the rootfs. I am looking into it, but if anyone has any thoughts please let me know.
Jon
Signature · 1 line
nvpublic
Jon Hunter
maintainerRe: [PATCH v3 01/14] PCI: tegra: Convert to MSI domains
Quoted 28 lines · Jon Hunter
Hi Marc,
Quoted 7 lines · Marc Zyngier
In anticipation of the removal of the
msi_controllerstructure, convert the Tegra host controller driver to MSI domains.We end-up with the usual two domain structure, the top one being a generic PCI/MSI domain, the bottom one being Tegra-specific and handling the actual HW interrupt allocation.
Quoted 8 lines
While at it, convert the normal interrupt handler to a chained handler, handle the controller's MSI IRQ edge triggered, support multiple MSIs per device and use the AFI_MSI_EN_VEC* registers to provide MSI masking.
Acked-by Bjorn Helgaas <[email protected]>[[email protected]: fix, clean up and address TODOs from Marc's draft]Signed-off-by Thierry Reding <[email protected]>Signed-off-by Marc Zyngier <[email protected]>This change is breaking a suspend test that we are running on Tegra124 Jetson-TK1. The Tegra124 Jetson TK1 uses a PCI based ethernet device ...
$ lspci 00:02.0 PCI bridge: NVIDIA Corporation TegraK1 PCIe x1 Bridge (rev a1) 01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0c)
Quoted 4 lines
After resuming from suspend, networking is no longer working. The reason why this breaks our suspend test is because that setup is using NFS for the rootfs. I am looking into it, but if anyone has any thoughts please let me know.
So the following does appear to fix it ...
(quoted diff) +0 -0
b/drivers/pci/controller/pci-tegra.c
index eaba7b2fab4a..558f02e0693d 100644
drivers/pci/controller/pci-tegra.c +0 -0
@@ -1802,13 +1802,17 @@ static void tegra_pcie_enable_msi(struct
tegra_pcie *pcie)
{
const struct tegra_pcie_soc *soc = pcie->soc;
struct tegra_msi *msi = &pcie->msi;- u32 reg;
+ u32 i, reg;
afi_writel(pcie, msi->phys >> soc->msi_base_shift,
AFI_MSI_FPCI_BAR_ST);
afi_writel(pcie, msi->phys, AFI_MSI_AXI_BAR_ST);
/* this register is in 4K increments */
afi_writel(pcie, 1, AFI_MSI_BAR_SZ);+ /* enable all MSI vectors */
+ for (i = 0; i < 8; i++)
+ afi_writel(pcie, 0xffffffff, AFI_MSI_EN_VEC(i));
+
/* and unmask the MSI interrupt */
reg = afi_readl(pcie, AFI_INTR_MASK);
reg |= AFI_INTR_MASK_MSI_MASK;@@ -1837,13 +1841,17 @@ static void tegra_pcie_msi_teardown(struct tegra_pcie *pcie)
static int tegra_pcie_disable_msi(struct tegra_pcie *pcie) {
- u32 value;
+ u32 i, value;
/* mask the MSI interrupt */
value = afi_readl(pcie, AFI_INTR_MASK);
value &= ~AFI_INTR_MASK_MSI_MASK;
afi_writel(pcie, value, AFI_INTR_MASK);+ /* disable all MSI vectors */
+ for (i = 0; i < 8; i++)
+ afi_writel(pcie, 0, AFI_MSI_EN_VEC(i));
+
return 0;
}
Any reason why that code was removed?
Thanks
Jon
Signature · 1 line
nvpublic
Re: [PATCH v3 01/14] PCI: tegra: Convert to MSI domains
Hi Jon,
Quoted 86 lines · Jon Hunter
Quoted 28 lines · Jon Hunter
Hi Marc,
Quoted 7 lines · Marc Zyngier
In anticipation of the removal of the
msi_controllerstructure, convert the Tegra host controller driver to MSI domains.We end-up with the usual two domain structure, the top one being a generic PCI/MSI domain, the bottom one being Tegra-specific and handling the actual HW interrupt allocation.
Quoted 8 lines
While at it, convert the normal interrupt handler to a chained handler, handle the controller's MSI IRQ edge triggered, support multiple MSIs per device and use the AFI_MSI_EN_VEC* registers to provide MSI masking.
Acked-by Bjorn Helgaas <[email protected]>[[email protected]: fix, clean up and address TODOs from Marc's draft]Signed-off-by Thierry Reding <[email protected]>Signed-off-by Marc Zyngier <[email protected]>This change is breaking a suspend test that we are running on Tegra124 Jetson-TK1. The Tegra124 Jetson TK1 uses a PCI based ethernet device ...
$ lspci 00:02.0 PCI bridge: NVIDIA Corporation TegraK1 PCIe x1 Bridge (rev a1) 01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0c)Quoted 4 lines
After resuming from suspend, networking is no longer working. The reason why this breaks our suspend test is because that setup is using NFS for the rootfs. I am looking into it, but if anyone has any thoughts please let me know.
So the following does appear to fix it ...
drivers/pci/controller/pci-tegra.c +5
-1@@ -1802,13 +1802,17 @@ static void tegra_pcie_enable_msi(struct tegra_pcie *pcie) {const struct tegra_pcie_soc *soc = pcie->soc;struct tegra_msi *msi = &pcie->msi; -u32 reg; +u32 i, reg;afi_writel (pcie, msi->phys >> soc->msi_base_shift,AFI_MSI_FPCI_BAR_ST );afi_writel (pcie, msi->phys,AFI_MSI_AXI_BAR_ST );/* this register is in 4K increments */ afi_writel (pcie,1 ,AFI_MSI_BAR_SZ ); +/* enable all MSI vectors */ +for (i =0 ; i <8 ; i++) +afi_writel (pcie,0xffffffff ,AFI_MSI_EN_VEC (i)); +/* and unmask the MSI interrupt */ reg = afi_readl(pcie, AFI_INTR_MASK); reg |= AFI_INTR_MASK_MSI_MASK;drivers/pci/controller/pci-tegra.c +5
-1@@ -1837,13 +1841,17 @@ static void tegra_pcie_msi_teardown(struct tegra_pcie *pcie)static int tegra_pcie_disable_msi (struct tegra_pcie *pcie) { -u32 value; +u32 i, value;/* mask the MSI interrupt */ value =afi_readl (pcie,AFI_INTR_MASK ); value &= ~AFI_INTR_MASK_MSI_MASK ;afi_writel (pcie, value,AFI_INTR_MASK ); +/* disable all MSI vectors */ +for (i =0 ; i <8 ; i++) +afi_writel (pcie,0 ,AFI_MSI_EN_VEC (i)); +return 0 ; }
Quoted 1 line
Any reason why that code was removed?
Two reasons spring to mind: it obviously wasn't tested enough, and part of the above code isn't quite right. You can't just blindly enable all MSIs, irrespective of what has been actually enabled.
The following should hopefully cure it (compile tested only). Please let me know.
M.
drivers/pci/controller/pci-tegra.c +7 -1
@@ -1802,13 +1802,19 @@ static void tegra_pcie_enable_msi(struct tegra_pcie *pcie) {const struct tegra_pcie_soc *soc = pcie->soc;struct tegra_msi *msi = &pcie->msi; -u32 reg; +u32 reg, msi_state[INT_PCI_MSI_NR /32 ]; +int i;afi_writel (pcie, msi->phys >> soc->msi_base_shift,AFI_MSI_FPCI_BAR_ST );afi_writel (pcie, msi->phys,AFI_MSI_AXI_BAR_ST );/* this register is in 4K increments */ afi_writel (pcie,1 ,AFI_MSI_BAR_SZ ); +/* Restore the MSI allocation state */ +bitmap_to_arr32 (msi_state, msi->used,INT_PCI_MSI_NR ); +for (i =0 ; i <ARRAY_SIZE (msi_state); i++) +afi_writel (pcie, msi_state[i],AFI_MSI_EN_VEC (i)); +/* and unmask the MSI interrupt */ reg =afi_readl (pcie,AFI_INTR_MASK ); reg |=AFI_INTR_MASK_MSI_MASK ;
Signature · 6 lines
Without deviation from the norm, progress is not possible. _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 01/14] PCI: tegra: Convert to MSI domains
Hi Marc,
On 20/04/2021 09:39, Marc Zyngier wrote:
...
Quoted 21 lines
The following should hopefully cure it (compile tested only). Please let me know.
M.drivers/pci/controller/pci-tegra.c +2
-1@@ -1802,13 +1802,19 @@ static void tegra_pcie_enable_msi(struct tegra_pcie *pcie) {const struct tegra_pcie_soc *soc = pcie->soc;struct tegra_msi *msi = &pcie->msi; -u32 reg; +u32 reg, msi_state[INT_PCI_MSI_NR /32 ]; +int i;afi_writel (pcie, msi->phys >> soc->msi_base_shift,AFI_MSI_FPCI_BAR_ST );afi_writel (pcie, msi->phys,AFI_MSI_AXI_BAR_ST );/* this register is in 4K increments */
drivers/pci/controller/pci-tegra.c static void tegra_pcie_enable_msi(struct tegra_pcie *pcie) · line 1820
Quoted 10 lines
drivers/pci/controller/pci-tegra.c +5
-0afi_writel (pcie,1 ,AFI_MSI_BAR_SZ ); +/* Restore the MSI allocation state */ +bitmap_to_arr32 (msi_state, msi->used,INT_PCI_MSI_NR ); +for (i =0 ; i <ARRAY_SIZE (msi_state); i++) +afi_writel (pcie, msi_state[i],AFI_MSI_EN_VEC (i)); +/* and unmask the MSI interrupt */ reg =afi_readl (pcie,AFI_INTR_MASK ); reg |=AFI_INTR_MASK_MSI_MASK ;
Thanks, that does fix it indeed!
Cheers
Jon
Signature · 1 line
nvpublic
PATCH v3 2/14 PCI: rcar: Don't allocate extra memory for the MSI capture address
In reply to Marc ZyngierA long cargo-culted behaviour of PCI drivers is to allocate memory to obtain an address that is fed to the controller as the MSI capture address (i.e. the MSI doorbell).
But there is no actual requirement for this address to be RAM. All it needs to be is a suitable aligned address that will *not* be DMA'd to.
Since the rcar platform already has a requirement that this address should be in the first 4GB of the physical address space, use the controller's own base address as the capture address.
--- drivers/pci/controller/pcie-rcar-host.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/pci/controller/pcie-rcar-host.c +7 -11
@@ -36,7 +36,6 @@ struct rcar_msi {DECLARE_BITMAP (used,INT_PCI_MSI_NR );struct irq_domain *domain;struct msi_controller chip; -unsigned long pages;struct mutex lock;int irq1;int irq2;
@@ -680,14 +679,15 @@ static void rcar_pcie_unmap_msi(struct rcar_pcie_host *host)static void rcar_pcie_hw_enable_msi (struct rcar_pcie_host *host) {struct rcar_pcie *pcie = &host->pcie; -struct rcar_msi *msi = &host->msi; -unsigned long base; +struct device *dev = pcie->dev; +struct resource res; -/* setup MSI data target */ - base =virt_to_phys ((void *)msi->pages); +if (WARN_ON (of_address_to_resource (dev->of_node,0 , &res))) +return ; -rcar_pci_write_reg (pcie,lower_32_bits (base) |MSIFE ,PCIEMSIALR ); -rcar_pci_write_reg (pcie,upper_32_bits (base),PCIEMSIAUR ); +/* setup MSI data target */ +rcar_pci_write_reg (pcie,lower_32_bits (res.start) |MSIFE ,PCIEMSIALR ); +rcar_pci_write_reg (pcie,upper_32_bits (res.start),PCIEMSIAUR );/* enable all MSI interrupts */ rcar_pci_write_reg (pcie,0xffffffff ,PCIEMSIIER );
@@ -735,7 +735,6 @@ static int rcar_pcie_enable_msi(struct rcar_pcie_host *host) }/* setup MSI data target */ - msi->pages =__get_free_pages (GFP_KERNEL |GFP_DMA32 ,0 );rcar_pcie_hw_enable_msi (host);return 0 ;
@@ -748,7 +747,6 @@ static int rcar_pcie_enable_msi(struct rcar_pcie_host *host)static void rcar_pcie_teardown_msi (struct rcar_pcie_host *host) {struct rcar_pcie *pcie = &host->pcie; -struct rcar_msi *msi = &host->msi;/* Disable all MSI interrupts */ rcar_pci_write_reg (pcie,0 ,PCIEMSIIER );
@@ -756,8 +754,6 @@ static void rcar_pcie_teardown_msi(struct rcar_pcie_host *host)/* Disable address decoding of the MSI interrupt, MSIFE */ rcar_pci_write_reg (pcie,0 ,PCIEMSIALR ); -free_pages (msi->pages,0 ); -rcar_pcie_unmap_msi (host); }
Signature · 7 lines
2.29.2 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 02/14] PCI: rcar: Don't allocate extra memory for the MSI capture address
Quoted 8 lines · Marc Zyngier
A long cargo-culted behaviour of PCI drivers is to allocate memory to obtain an address that is fed to the controller as the MSI capture address (i.e. the MSI doorbell).
But there is no actual requirement for this address to be RAM. All it needs to be is a suitable aligned address that will *not* be DMA'd to.
Quoted 8 lines
Since the rcar platform already has a requirement that this address should be in the first 4GB of the physical address space, use the controller's own base address as the capture address.
Signed-off-by Marc Zyngier <[email protected]>--- drivers/pci/controller/pcie-rcar-host.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
Marek, Yoshihiro,
can you test this patch please and report back ? It is not fundamental for the rest of the series (ie the rest of the series does not depend on it) and we can still merge the series without it but it would be good if you can review and test anyway.
I'd like to merge this series into -next shortly.
Thanks,
Lorenzo
Quoted 62 lines
drivers/pci/controller/pcie-rcar-host.c +7
-11@@ -36,7 +36,6 @@ struct rcar_msi {DECLARE_BITMAP (used,INT_PCI_MSI_NR );struct irq_domain *domain;struct msi_controller chip; -unsigned long pages;struct mutex lock;int irq1;int irq2;@@ -680,14 +679,15 @@ static void rcar_pcie_unmap_msi(struct rcar_pcie_host *host)static void rcar_pcie_hw_enable_msi (struct rcar_pcie_host *host) {struct rcar_pcie *pcie = &host->pcie; -struct rcar_msi *msi = &host->msi; -unsigned long base; +struct device *dev = pcie->dev; +struct resource res; -/* setup MSI data target */ - base =virt_to_phys ((void *)msi->pages); +if (WARN_ON (of_address_to_resource (dev->of_node,0 , &res))) +return ; -rcar_pci_write_reg (pcie,lower_32_bits (base) |MSIFE ,PCIEMSIALR ); -rcar_pci_write_reg (pcie,upper_32_bits (base),PCIEMSIAUR ); +/* setup MSI data target */ +rcar_pci_write_reg (pcie,lower_32_bits (res.start) |MSIFE ,PCIEMSIALR ); +rcar_pci_write_reg (pcie,upper_32_bits (res.start),PCIEMSIAUR );/* enable all MSI interrupts */ rcar_pci_write_reg (pcie,0xffffffff ,PCIEMSIIER );@@ -735,7 +735,6 @@ static int rcar_pcie_enable_msi(struct rcar_pcie_host *host) }/* setup MSI data target */ - msi->pages =__get_free_pages (GFP_KERNEL |GFP_DMA32 ,0 );rcar_pcie_hw_enable_msi (host);return 0 ;@@ -748,7 +747,6 @@ static int rcar_pcie_enable_msi(struct rcar_pcie_host *host)static void rcar_pcie_teardown_msi (struct rcar_pcie_host *host) {struct rcar_pcie *pcie = &host->pcie; -struct rcar_msi *msi = &host->msi;/* Disable all MSI interrupts */ rcar_pci_write_reg (pcie,0 ,PCIEMSIIER );@@ -756,8 +754,6 @@ static void rcar_pcie_teardown_msi(struct rcar_pcie_host *host)/* Disable address decoding of the MSI interrupt, MSIFE */ rcar_pci_write_reg (pcie,0 ,PCIEMSIALR ); -free_pages (msi->pages,0 ); -rcar_pcie_unmap_msi (host); }Signature · 1 line
2.29.2
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
RE: [PATCH v3 02/14] PCI: rcar: Don't allocate extra memory for the MSI capture address
Hi Lorenzo, Marc,
Quoted 20 lines
From: Lorenzo Pieralisi, Sent: Wednesday, March 31, 2021 12:29 AM
Quoted 8 lines · Marc Zyngier
A long cargo-culted behaviour of PCI drivers is to allocate memory to obtain an address that is fed to the controller as the MSI capture address (i.e. the MSI doorbell).
But there is no actual requirement for this address to be RAM. All it needs to be is a suitable aligned address that will *not* be DMA'd to.
Quoted 8 lines
Since the rcar platform already has a requirement that this address should be in the first 4GB of the physical address space, use the controller's own base address as the capture address.
Signed-off-by Marc Zyngier <[email protected]>--- drivers/pci/controller/pcie-rcar-host.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
Quoted 6 lines
Marek, Yoshihiro,
can you test this patch please and report back ? It is not fundamental for the rest of the series (ie the rest of the series does not depend on it) and we can still merge the series without it but it would be good if you can review and test anyway.
I reviewed and tested this patch and it worked correctly. So,
Best regards,
Yoshihiro Shimoda
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH v3 3/14 PCI: rcar: Convert to MSI domains
In reply to Marc ZyngierIn anticipation of the removal of the msi_controller structure, convert the Rcar host controller driver to MSI domains.
We end-up with the usual two domain structure, the top one being a generic PCI/MSI domain, the bottom one being Rcar-specific and handling the actual HW interrupt allocation.
--- drivers/pci/controller/Kconfig | 1 - drivers/pci/controller/pcie-rcar-host.c | 352 ++++++++++++------------ 2 files changed, 170 insertions(+), 183 deletions(-)
drivers/pci/controller/Kconfig +0 -1
@@ -58,7 +58,6 @@ config PCIE_RCAR_HOST bool "Renesas R-Car PCIe host controller" depends on ARCH_RENESAS || COMPILE_TEST depends on PCI_MSI_IRQ_DOMAIN - select PCI_MSI_ARCH_FALLBACKS help Say Y here if you want PCIe controller support on R-Car SoCs in host mode.
drivers/pci/controller/pcie-rcar-host.c +170 -182
474 lines not on this page · raw message
Signature · 1 line
2.29.2
Re: [PATCH v3 03/14] PCI: rcar: Convert to MSI domains
On Tue, Mar 30, 2021 at 04:11:34PM +0100, Marc Zyngier wrote:
[...]
drivers/pci/controller/pcie-rcar-host.c static irqreturn_t rcar_pcie_msi_irq(int irq, void *data) · line 580
Quoted 11 lines
drivers/pci/controller/pcie-rcar-host.c +7
-3+static void rcar_compose_msi_msg (struct irq_data *data,struct msi_msg *msg) +{ +struct rcar_msi *msi =irq_data_get_irq_chip_data (data); +unsigned long pa =virt_to_phys (msi); - hwirq =rcar_msi_alloc_region (msi, nvec); -if (hwirq <0 ) -return -ENOSPC ; +/* Use the msi structure as the PA for the MSI doorbell */ + msg->address_lo =lower_32_bits (pa); + msg->address_hi =upper_32_bits (pa);
I don't think this change is aligned with the previous patch (is it ?), the PA address we are using here is different from the one programmed into the controller registers - either that or I am missing something, please let me know.
Thanks,
Lorenzo
Quoted 261 lines
drivers/pci/controller/pcie-rcar-host.c +99
-87+ msg->data = data->hwirq; +} - irq =irq_find_mapping (msi->domain, hwirq); -if (!irq) -return -ENOSPC ; +static struct irq_chip rcar_msi_bottom_chip = { + .name ="Rcar MSI" , + .irq_ack = rcar_msi_irq_ack, + .irq_mask = rcar_msi_irq_mask, + .irq_unmask = rcar_msi_irq_unmask, + .irq_set_affinity = rcar_msi_set_affinity, + .irq_compose_msi_msg = rcar_compose_msi_msg, +}; -for (i =0 ; i < nvec; i++) { -/* -* irq_create_mapping() called from rcar_pcie_probe() pre- -* allocates descs, so there is no need to allocate descs here. -* We can therefore assume that if irq_find_mapping() above -* returns non-zero, then the descs are also successfully -* allocated. -*/ -if (irq_set_msi_desc_off (irq, i, desc)) { -/* TODO: clear */ -return -EINVAL ; - } - } +static int rcar_msi_domain_alloc (struct irq_domain *domain,unsigned int virq, +unsigned int nr_irqs,void *args) +{ +struct rcar_msi *msi = domain->host_data; +unsigned int i; +int hwirq; + +mutex_lock (&msi->map_lock); - desc->nvec_used = nvec; - desc->msi_attrib.multiple =order_base_2 (nvec); + hwirq =bitmap_find_free_region (msi->used,INT_PCI_MSI_NR ,order_base_2 (nr_irqs)); - msg.address_lo =rcar_pci_read_reg (pcie,PCIEMSIALR ) & ~MSIFE ; - msg.address_hi =rcar_pci_read_reg (pcie,PCIEMSIAUR ); - msg.data = hwirq; +mutex_unlock (&msi->map_lock); + +if (hwirq <0 ) +return -ENOSPC ; -pci_write_msi_msg (irq, &msg); +for (i =0 ; i < nr_irqs; i++) +irq_domain_set_info (domain, virq + i, hwirq + i, + &rcar_msi_bottom_chip, domain->host_data, + handle_edge_irq,NULL ,NULL );return 0 ; } -static void rcar_msi_teardown_irq (struct msi_controller *chip,unsigned int irq) +static void rcar_msi_domain_free (struct irq_domain *domain,unsigned int virq, +unsigned int nr_irqs) { -struct rcar_msi *msi =to_rcar_msi (chip); -struct irq_data *d =irq_get_irq_data (irq); +struct irq_data *d =irq_domain_get_irq_data (domain, virq); +struct rcar_msi *msi = domain->host_data; -rcar_msi_free (msi, d->hwirq); -} - -static struct irq_chip rcar_msi_irq_chip = { - .name ="R-Car PCIe MSI" , - .irq_enable = pci_msi_unmask_irq, - .irq_disable = pci_msi_mask_irq, - .irq_mask = pci_msi_mask_irq, - .irq_unmask = pci_msi_unmask_irq, -}; +mutex_lock (&msi->map_lock); -static int rcar_msi_map (struct irq_domain *domain,unsigned int irq, -irq_hw_number_t hwirq) -{ -irq_set_chip_and_handler (irq, &rcar_msi_irq_chip, handle_simple_irq); -irq_set_chip_data (irq, domain->host_data); +bitmap_release_region (msi->used, d->hwirq,order_base_2 (nr_irqs)); -return 0 ; +mutex_unlock (&msi->map_lock); } -static const struct irq_domain_ops msi_domain_ops = { - .map = rcar_msi_map, +static const struct irq_domain_ops rcar_msi_domain_ops = { + .alloc = rcar_msi_domain_alloc, + .free = rcar_msi_domain_free, +}; + +static struct msi_domain_info rcar_msi_info = { + .flags = (MSI_FLAG_USE_DEF_DOM_OPS |MSI_FLAG_USE_DEF_CHIP_OPS | +MSI_FLAG_MULTI_PCI_MSI ), + .chip = &rcar_msi_top_chip, }; -static void rcar_pcie_unmap_msi (struct rcar_pcie_host *host) +static int rcar_allocate_domains (struct rcar_msi *msi) { -struct rcar_msi *msi = &host->msi; -int i, irq; +struct rcar_pcie *pcie = &msi_to_host (msi)->pcie; +struct fwnode_handle *fwnode =dev_fwnode (pcie->dev); +struct irq_domain *parent; + + parent =irq_domain_create_linear (fwnode,INT_PCI_MSI_NR , + &rcar_msi_domain_ops, msi); +if (!parent) { +dev_err (pcie->dev,"failed to create IRQ domain\n" ); +return -ENOMEM ; + } +irq_domain_update_bus_token (parent,DOMAIN_BUS_NEXUS ); -for (i =0 ; i <INT_PCI_MSI_NR ; i++) { - irq =irq_find_mapping (msi->domain, i); -if (irq >0 ) -irq_dispose_mapping (irq); + msi->domain =pci_msi_create_irq_domain (fwnode, &rcar_msi_info, parent); +if (!msi->domain) { +dev_err (pcie->dev,"failed to create MSI domain\n" ); +irq_domain_remove (parent); +return -ENOMEM ; } -irq_domain_remove (msi->domain); +return 0 ; } -static void rcar_pcie_hw_enable_msi (struct rcar_pcie_host *host) +static void rcar_free_domains (struct rcar_msi *msi) { -struct rcar_pcie *pcie = &host->pcie; -struct device *dev = pcie->dev; -struct resource res; +struct irq_domain *parent = msi->domain->parent; -if (WARN_ON (of_address_to_resource (dev->of_node,0 , &res))) -return ; - -/* setup MSI data target */ -rcar_pci_write_reg (pcie,lower_32_bits (res.start) |MSIFE ,PCIEMSIALR ); -rcar_pci_write_reg (pcie,upper_32_bits (res.start),PCIEMSIAUR ); - -/* enable all MSI interrupts */ -rcar_pci_write_reg (pcie,0xffffffff ,PCIEMSIIER ); +irq_domain_remove (msi->domain); +irq_domain_remove (parent); }static int rcar_pcie_enable_msi (struct rcar_pcie_host *host)@@ -698,29 +675,24 @@ static int rcar_pcie_enable_msi(struct rcar_pcie_host *host)struct rcar_pcie *pcie = &host->pcie;struct device *dev = pcie->dev;struct rcar_msi *msi = &host->msi; -int err, i; - -mutex_init (&msi->lock); +struct resource res; +int err; - msi->chip.dev = dev; - msi->chip.setup_irq = rcar_msi_setup_irq; - msi->chip.setup_irqs = rcar_msi_setup_irqs; - msi->chip.teardown_irq = rcar_msi_teardown_irq; +mutex_init (&msi->map_lock); +spin_lock_init (&msi->mask_lock); - msi->domain =irq_domain_add_linear (dev->of_node,INT_PCI_MSI_NR , - &msi_domain_ops, &msi->chip); -if (!msi->domain) { -dev_err (dev,"failed to create IRQ domain\n" ); -return -ENOMEM ; - } + err =of_address_to_resource (dev->of_node,0 , &res); +if (err) +return err; -for (i =0 ; i <INT_PCI_MSI_NR ; i++) -irq_create_mapping (msi->domain, i); + err =rcar_allocate_domains (msi); +if (err) +return err;/* Two irqs are for MSI, but they are also used for non-MSI irqs */ err =devm_request_irq (dev, msi->irq1, rcar_pcie_msi_irq,IRQF_SHARED |IRQF_NO_THREAD , - rcar_msi_irq_chip.name, host); + rcar_msi_bottom_chip.name, host);if (err <0 ) {dev_err (dev,"failed to request IRQ: %d\n" , err); goto err;@@ -728,19 +700,26 @@ static int rcar_pcie_enable_msi(struct rcar_pcie_host *host) err =devm_request_irq (dev, msi->irq2, rcar_pcie_msi_irq,IRQF_SHARED |IRQF_NO_THREAD , - rcar_msi_irq_chip.name, host); + rcar_msi_bottom_chip.name, host);if (err <0 ) {dev_err (dev,"failed to request IRQ: %d\n" , err); goto err; } -/* setup MSI data target */ -rcar_pcie_hw_enable_msi (host); +/* disable all MSIs */ +rcar_pci_write_reg (pcie,0 ,PCIEMSIIER ); + +/* +* Setup MSI data target using RC base address address, which +* is guaranteed to be in the low 32bit range on any RCar HW. +*/ +rcar_pci_write_reg (pcie,lower_32_bits (res.start) |MSIFE ,PCIEMSIALR ); +rcar_pci_write_reg (pcie,upper_32_bits (res.start),PCIEMSIAUR );return 0 ; err: -rcar_pcie_unmap_msi (host); +rcar_free_domains (msi);return err; }@@ -754,7 +733,7 @@ static void rcar_pcie_teardown_msi(struct rcar_pcie_host *host)/* Disable address decoding of the MSI interrupt, MSIFE */ rcar_pci_write_reg (pcie,0 ,PCIEMSIALR ); -rcar_pcie_unmap_msi (host); +rcar_free_domains (&host->msi); }static int rcar_pcie_get_resources (struct rcar_pcie_host *host)@@ -1007,8 +986,17 @@ static int __maybe_unused rcar_pcie_resume(struct device *dev)dev_info (dev,"PCIe x%d: link up\n" , (data >>20 ) &0x3f );/* Enable MSI */ -if (IS_ENABLED (CONFIG_PCI_MSI )) -rcar_pcie_hw_enable_msi (host); +if (IS_ENABLED (CONFIG_PCI_MSI )) { +struct resource res; +u32 val; + +of_address_to_resource (dev->of_node,0 , &res); +rcar_pci_write_reg (pcie,upper_32_bits (res.start),PCIEMSIAUR ); +rcar_pci_write_reg (pcie,lower_32_bits (res.start) |MSIFE ,PCIEMSIALR ); + +bitmap_to_arr32 (&val, host->msi.used,INT_PCI_MSI_NR ); +rcar_pci_write_reg (pcie, val,PCIEMSIIER ); + }rcar_pcie_hw_enable (host);Signature · 1 line
2.29.2
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 03/14] PCI: rcar: Convert to MSI domains
Quoted 10 lines · Lorenzo Pieralisi
On Tue, Mar 30, 2021 at 04:11:34PM +0100, Marc Zyngier wrote:
[...]
Quoted 5 lines
(quoted diff) +4
-0+static void rcar_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) +{ + struct rcar_msi *msi = irq_data_get_irq_chip_data(data); + unsigned long pa = virt_to_phys(msi);
Quoted 11 lines
Review
Quoted 6 lines
(quoted diff) +3
-3- hwirq = rcar_msi_alloc_region(msi, nvec); - if (hwirq < 0) - return -ENOSPC; + /* Use the msi structure as the PA for the MSI doorbell */ + msg->address_lo = lower_32_bits(pa); + msg->address_hi = upper_32_bits(pa);I don't think this change is aligned with the previous patch (is it ?), the PA address we are using here is different from the one programmed into the controller registers - either that or I am missing something, please let me know.
Err. You are right. This looks like a bad case of broken conflict resolution on my part.
The following snippet should fix it. Let me know if you want me to resend the whole thing or whether you are OK with applying this by hand.
Thanks,
M.
drivers/pci/controller/pcie-rcar-host.c +3 -4
@@ -573,11 +573,10 @@ static int rcar_msi_set_affinity(struct irq_data *d, const struct cpumask *mask,static void rcar_compose_msi_msg (struct irq_data *data,struct msi_msg *msg) {struct rcar_msi *msi =irq_data_get_irq_chip_data (data); -unsigned long pa =virt_to_phys (msi); +struct rcar_pcie *pcie = &msi_to_host (msi)->pcie; -/* Use the msi structure as the PA for the MSI doorbell */ - msg->address_lo =lower_32_bits (pa); - msg->address_hi =upper_32_bits (pa); + msg->address_lo =rcar_pci_read_reg (pcie,PCIEMSIALR ) & ~MSIFE ; + msg->address_hi =rcar_pci_read_reg (pcie,PCIEMSIAUR ); msg->data = data->hwirq; }
Signature · 6 lines
Without deviation from the norm, progress is not possible. _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v3 03/14] PCI: rcar: Convert to MSI domains
Quoted 24 lines · Marc Zyngier
Quoted 10 lines · Lorenzo Pieralisi
On Tue, Mar 30, 2021 at 04:11:34PM +0100, Marc Zyngier wrote:
[...]
Quoted 5 lines
(quoted diff) +4
-0+static void rcar_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) +{ + struct rcar_msi *msi = irq_data_get_irq_chip_data(data); + unsigned long pa = virt_to_phys(msi);Quoted 11 lines
Review
Quoted 6 lines
(quoted diff) +3
-3- hwirq = rcar_msi_alloc_region(msi, nvec); - if (hwirq < 0) - return -ENOSPC; + /* Use the msi structure as the PA for the MSI doorbell */ + msg->address_lo = lower_32_bits(pa); + msg->address_hi = upper_32_bits(pa);I don't think this change is aligned with the previous patch (is it ?), the PA address we are using here is different from the one programmed into the controller registers - either that or I am missing something, please let me know.
Quoted 6 lines
Err. You are right. This looks like a bad case of broken conflict resolution on my part.
The following snippet should fix it. Let me know if you want me to resend the whole thing or whether you are OK with applying this by hand.
I will apply it and merge the whole series into -next, thanks for implementing it !
Lorenzo
Quoted 26 lines
Thanks,
M.drivers/pci/controller/pcie-rcar-host.c +3
-4@@ -573,11 +573,10 @@ static int rcar_msi_set_affinity(struct irq_data *d, const struct cpumask *mask,static void rcar_compose_msi_msg (struct irq_data *data,struct msi_msg *msg) {struct rcar_msi *msi =irq_data_get_irq_chip_data (data); -unsigned long pa =virt_to_phys (msi); +struct rcar_pcie *pcie = &msi_to_host (msi)->pcie; -/* Use the msi structure as the PA for the MSI doorbell */ - msg->address_lo =lower_32_bits (pa); - msg->address_hi =upper_32_bits (pa); + msg->address_lo =rcar_pci_read_reg (pcie,PCIEMSIALR ) & ~MSIFE ; + msg->address_hi =rcar_pci_read_reg (pcie,PCIEMSIAUR ); msg->data = data->hwirq; }Signature · 2 lines
-- Without deviation from the norm, progress is not possible.
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH v3 4/14 PCI: xilinx: Don't allocate extra memory for the MSI capture address
In reply to Marc ZyngierA long cargo-culted behaviour of PCI drivers is to allocate memory to obtain an address that is fed to the controller as the MSI capture address (i.e. the MSI doorbell).
But there is no actual requirement for this address to be RAM. All it needs to be is a suitable aligned address that will *not* be DMA'd to.
Use the physical address of the 'port' data structure as the MSI capture address, aligned on a 4K boundary.
--- drivers/pci/controller/pcie-xilinx.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/pci/controller/pcie-xilinx.c +6 -12
@@ -94,7 +94,6 @@* struct xilinx_pcie_port - PCIe port information * @reg_base: IO Mapped Register Base * @irq: Interrupt number -* @msi_pages: MSI pages * @dev: Device pointer * @msi_domain: MSI IRQ domain pointer * @leg_domain: Legacy IRQ domain pointer
@@ -103,7 +102,6 @@struct xilinx_pcie_port {void __iomem *reg_base;u32 irq; -unsigned long msi_pages;struct device *dev;struct irq_domain *msi_domain;struct irq_domain *leg_domain;
@@ -274,10 +272,10 @@ static int xilinx_pcie_msi_setup_irq(struct msi_controller *chip,irq_set_msi_desc (irq, desc); - msg_addr =virt_to_phys ((void *)port->msi_pages); + msg_addr =ALIGN_DOWN (virt_to_phys (port),SZ_4K ); - msg.address_hi =0 ; - msg.address_lo = msg_addr; + msg.address_hi =upper_32_bits (msg_addr); + msg.address_lo =lower_32_bits (msg_addr); msg.data = irq;pci_write_msi_msg (irq, &msg);
@@ -330,13 +328,9 @@ static int xilinx_pcie_enable_msi(struct xilinx_pcie_port *port) {phys_addr_t msg_addr; - port->msi_pages =__get_free_pages (GFP_KERNEL ,0 ); -if (!port->msi_pages) -return -ENOMEM ; - - msg_addr =virt_to_phys ((void *)port->msi_pages); -pcie_write (port,0x0 ,XILINX_PCIE_REG_MSIBASE1 ); -pcie_write (port, msg_addr,XILINX_PCIE_REG_MSIBASE2 ); + msg_addr =ALIGN_DOWN (virt_to_phys (port),SZ_4K ); +pcie_write (port,upper_32_bits (msg_addr),XILINX_PCIE_REG_MSIBASE1 ); +pcie_write (port,lower_32_bits (msg_addr),XILINX_PCIE_REG_MSIBASE2 );return 0 ; }
Signature · 1 line
2.29.2
PATCH v3 5/14 PCI: xilinx: Convert to MSI domains
In reply to Marc ZyngierIn anticipation of the removal of the msi_controller structure, convert the ancient xilinx host controller driver to MSI domains.
We end-up with the usual two domain structure, the top one being a generic PCI/MSI domain, the bottom one being xilinx-specific and handling the actual HW interrupt allocation.
This allows us to fix some of the most appaling MSI programming, where the message programmed in the device is the virtual IRQ number instead of the allocated vector number. The allocator is also made safe with a mutex. This should allow support for MultiMSI, but I decided not to even try, since I cannot test it.
--- drivers/pci/controller/Kconfig | 2 +- drivers/pci/controller/pcie-xilinx.c | 242 ++++++++++++--------------- 2 files changed, 106 insertions(+), 138 deletions(-)
drivers/pci/controller/Kconfig +1 -1
@@ -86,7 +86,7 @@ config PCI_HOST_GENERIC config PCIE_XILINX bool "Xilinx AXI PCIe host bridge support" depends on OF || COMPILE_TEST - select PCI_MSI_ARCH_FALLBACKS + depends on PCI_MSI_IRQ_DOMAIN help Say 'Y' here if you want kernel to support the Xilinx AXI PCIe Host Bridge driver.
drivers/pci/controller/pcie-xilinx.c +105 -137
365 lines not on this page · raw message
Signature · 1 line
2.29.2
PATCH v3 6/14 PCI: hv: Drop msi_controller structure
In reply to Marc ZyngierThe Hyper-V PCI driver still makes use of a msi_controller structure, but it looks more like a distant leftover than anything actually useful, since it is initialised to 0 and never used for anything.
Just remove it.
--- drivers/pci/controller/pci-hyperv.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/pci/controller/pci-hyperv.c +0 -4
@@ -473,7 +473,6 @@ struct hv_pcibus_device {struct list_head dr_list;struct msi_domain_info msi_info; -struct msi_controller msi_chip;struct irq_domain *irq_domain;spinlock_t retarget_msi_interrupt_lock;
@@ -1866,9 +1865,6 @@ static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus)if (!hbus->pci_bus)return -ENODEV ; - hbus->pci_bus->msi = &hbus->msi_chip; - hbus->pci_bus->msi->dev = &hbus->hdev->device; -pci_lock_rescan_remove ();pci_scan_child_bus (hbus->pci_bus);hv_pci_assign_numa_node (hbus);
Signature · 1 line
2.29.2
PATCH v3 7/14 PCI/MSI: Drop use of msi_controller from core code
In reply to Marc ZyngierAs there is no driver using msi_controller, we can now safely remove its use from the PCI probe code.
--- drivers/pci/msi.c | 23 +---------------------- drivers/pci/probe.c | 2 -- include/linux/pci.h | 2 -- 3 files changed, 1 insertion(+), 26 deletions(-)
drivers/pci/msi.c +1 -22
@@ -64,39 +64,18 @@ static void pci_msi_teardown_msi_irqs(struct pci_dev *dev)/* Arch hooks */ int __weak arch_setup_msi_irq (struct pci_dev *dev,struct msi_desc *desc) { -struct msi_controller *chip = dev->bus->msi; -int err; - -if (!chip || !chip->setup_irq) -return -EINVAL ; - - err = chip->setup_irq (chip, dev, desc); -if (err <0 ) -return err; - -irq_set_chip_data (desc->irq, chip); - -return 0 ; +return -EINVAL ; }void __weak arch_teardown_msi_irq (unsigned int irq) { -struct msi_controller *chip =irq_get_chip_data (irq); - -if (!chip || !chip->teardown_irq) -return ; - - chip->teardown_irq (chip, irq); }int __weak arch_setup_msi_irqs (struct pci_dev *dev,int nvec,int type) { -struct msi_controller *chip = dev->bus->msi;struct msi_desc *entry;int ret; -if (chip && chip->setup_irqs) -return chip->setup_irqs (chip, dev, nvec, type);/* * If an architecture wants to support multiple MSI, it needs to * override arch_setup_msi_irqs()
drivers/pci/probe.c +0 -2
@@ -895,7 +895,6 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)/* Temporarily move resources off the list */ list_splice_init (&bridge->windows, &resources); bus->sysdata = bridge->sysdata; - bus->msi = bridge->msi; bus->ops = bridge->ops; bus->number = bus->busn_res.start = bridge->busnr;#ifdef CONFIG_PCI_DOMAINS_GENERIC
@@ -1053,7 +1052,6 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,return NULL ; child->parent = parent; - child->msi = parent->msi; child->sysdata = parent->sysdata; child->bus_flags = parent->bus_flags;
include/linux/pci.h +0 -2
@@ -540,7 +540,6 @@ struct pci_host_bridge {int (*map_irq)(const struct pci_dev *,u8 ,u8 );void (*release_fn)(struct pci_host_bridge *);void *release_data; -struct msi_controller *msi; unsigned int ignore_reset_delay:1; /* For entire hierarchy */ unsigned int no_ext_tags:1; /* No Extended Tags */ unsigned int native_aer:1; /* OS may use PCIe AER */
@@ -621,7 +620,6 @@ struct pci_bus {struct resource busn_res;/* Bus numbers routed to this bus */ struct pci_ops *ops;/* Configuration access functions */ -struct msi_controller *msi;/* MSI controller */ void *sysdata;/* Hook for sys-specific extension */ struct proc_dir_entry *procdir;/* Directory entry in /proc/bus/pci */
Signature · 1 line
2.29.2
PATCH v3 8/14 PCI/MSI: Kill msi_controller structure
In reply to Marc Zyngiermsi_controller had a good, long life as the abstraction for a driver providing MSIs to PCI devices. But it has been replaced in all drivers by the more expressive generic MSI framework.
Farewell, struct msi_controller.
--- include/linux/msi.h | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
include/linux/msi.h +1 -15
@@ -240,8 +240,7 @@ void pci_msi_unmask_irq(struct irq_data *data);/* * The arch hooks to setup up msi irqs. Default functions are implemented * as weak symbols so that they /can/ be overriden by architecture specific -* code if needed. These hooks must be enabled by the architecture or by -* drivers which depend on them via msi_controller based MSI handling. +* code if needed. These hooks can only be enabled by the architecture. * * If CONFIG_PCI_MSI_ARCH_FALLBACKS is not selected they are replaced by * stubs with warnings.
@@ -272,19 +271,6 @@ static inline void arch_teardown_msi_irqs(struct pci_dev *dev)void arch_restore_msi_irqs (struct pci_dev *dev);void default_restore_msi_irqs (struct pci_dev *dev); -struct msi_controller { -struct module *owner; -struct device *dev; -struct device_node *of_node; -struct list_head list; - -int (*setup_irq)(struct msi_controller *chip,struct pci_dev *dev, -struct msi_desc *desc); -int (*setup_irqs)(struct msi_controller *chip,struct pci_dev *dev, -int nvec,int type); -void (*teardown_irq)(struct msi_controller *chip,unsigned int irq); -}; -#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN #include <linux/irqhandler.h>
Signature · 1 line
2.29.2
PATCH v3 9/14 PCI/MSI: Kill default_teardown_msi_irqs()
In reply to Marc ZyngierIt doesn't have any caller left.
--- drivers/pci/msi.c | 11 +---------- include/linux/msi.h | 1 - 2 files changed, 1 insertion(+), 11 deletions(-)
drivers/pci/msi.c +1 -10
@@ -94,11 +94,7 @@ int __weak arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)return 0 ; } -/* -* We have a default implementation available as a separate non-weak -* function, as it is used by the Xen x86 PCI code -*/ -void default_teardown_msi_irqs (struct pci_dev *dev) +void __weak arch_teardown_msi_irqs (struct pci_dev *dev) {int i;struct msi_desc *entry;
@@ -108,11 +104,6 @@ void default_teardown_msi_irqs(struct pci_dev *dev)for (i =0 ; i < entry->nvec_used; i++) arch_teardown_msi_irq(entry->irq + i); } - -void __weak arch_teardown_msi_irqs (struct pci_dev *dev) -{ -return default_teardown_msi_irqs (dev); -}#endif /* CONFIG_PCI_MSI_ARCH_FALLBACKS */ static void default_restore_msi_irq (struct pci_dev *dev,int irq)
include/linux/msi.h +0 -1
@@ -250,7 +250,6 @@ 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); -void default_teardown_msi_irqs (struct pci_dev *dev);#else static inline int arch_setup_msi_irqs (struct pci_dev *dev,int nvec,int type) {
Signature · 1 line
2.29.2
PATCH v3 10/14 PCI/MSI: Let PCI host bridges declare their reliance on MSI domains
In reply to Marc ZyngierThere is a whole class of host bridges that cannot know whether MSIs will be provided or not, as they rely on other blocks to provide the MSI functionnality, using MSI domains. This is the case for example on systems that use the ARM GIC architecture.
Introduce a new attribute ('msi_domain') indicating that implicit dependency, and use this property to set the NO_MSI flag when no MSI domain is found at probe time.
--- drivers/pci/probe.c | 2 ++ include/linux/pci.h | 1 + 2 files changed, 3 insertions(+)
drivers/pci/probe.c +2 -0
@@ -925,6 +925,8 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)device_enable_async_suspend (bus->bridge);pci_set_bus_of_node (bus);pci_set_bus_msi_domain (bus); +if (bridge->msi_domain && !dev_get_msi_domain (&bus->dev)) + bus->bus_flags |=PCI_BUS_FLAGS_NO_MSI ;if (!parent)set_dev_node (bus->bridge,pcibus_to_node (bus));
include/linux/pci.h +1 -0
@@ -550,6 +550,7 @@ struct pci_host_bridge { unsigned int native_dpc:1; /* OS may use PCIe DPC */ unsigned int preserve_config:1; /* Preserve FW resource setup */ unsigned int size_windows:1; /* Enable root bus sizing */ + unsigned int msi_domain:1; /* Bridge wants MSI domain *//* Resource alignment requirements */ resource_size_t (*align_resource)(struct pci_dev *dev,
Signature · 7 lines
2.29.2 _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH v3 11/14 PCI/MSI: Make pci_host_common_probe() declare its reliance on MSI domains
In reply to Marc ZyngierThe generic PCI host driver relies on MSI domains for MSIs to be provided to its end-points. Make this dependency explicit.
This cures the warnings occuring on arm/arm64 VMs when booted with PCI virtio devices and no MSI controller (no GICv3 ITS, for example).
It is likely that other drivers will need to express the same dependency.
--- drivers/pci/controller/pci-host-common.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/controller/pci-host-common.c +1 -0
@@ -79,6 +79,7 @@ int pci_host_common_probe(struct platform_device *pdev) bridge->sysdata = cfg; bridge->ops = (struct pci_ops *)&ops->pci_ops; + bridge->msi_domain = true;return pci_host_probe (bridge); }
Signature · 1 line
2.29.2
PATCH v3 12/14 PCI: mediatek: Advertise lack of built-in MSI handling
In reply to Marc ZyngierFrom: Thomas Gleixner <[email protected]>
Some Mediatek host bridges cannot handle MSIs, which is sad. This also results in an ugly warning at device probe time, as the core PCI code wasn't told that MSIs were not available.
Advertise this fact to the rest of the core PCI code by using the 'msi_domain' attribute, which still opens the possibility for another block to provide the MSI functionnality.
--- drivers/pci/controller/pcie-mediatek.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/pci/controller/pcie-mediatek.c +4 -0
@@ -143,6 +143,7 @@ struct mtk_pcie_port;* struct mtk_pcie_soc - differentiate between host generations * @need_fix_class_id: whether this host's class ID needed to be fixed or not * @need_fix_device_id: whether this host's device ID needed to be fixed or not +* @no_msi: Bridge has no MSI support, and relies on an external block * @device_id: device ID which this host need to be fixed * @ops: pointer to configuration access functions * @startup: pointer to controller setting functions
@@ -151,6 +152,7 @@ struct mtk_pcie_port;struct mtk_pcie_soc {bool need_fix_class_id;bool need_fix_device_id; +bool no_msi;unsigned int device_id;struct pci_ops *ops;int (*startup)(struct mtk_pcie_port *port);
@@ -1087,6 +1089,7 @@ static int mtk_pcie_probe(struct platform_device *pdev) host->ops = pcie->soc->ops; host->sysdata = pcie; + host->msi_domain = pcie->soc->no_msi; err =pci_host_probe (host);if (err)
@@ -1176,6 +1179,7 @@ static const struct dev_pm_ops mtk_pcie_pm_ops = { };static const struct mtk_pcie_soc mtk_pcie_soc_v1 = { + .no_msi = true, .ops = &mtk_pcie_ops, .startup = mtk_pcie_startup_port, };
Signature · 1 line
2.29.2
PATCH v3 13/14 PCI/MSI: Document the various ways of ending up with NO_MSI
In reply to Marc ZyngierWe have now three ways of ending up with NO_MSI being set. Document them.
--- drivers/pci/msi.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/pci/msi.c +9 -2
@@ -871,8 +871,15 @@ static int pci_msi_supported(struct pci_dev *dev, int nvec)* Any bridge which does NOT route MSI transactions from its * secondary bus to its primary bus must set NO_MSI flag on * the secondary pci_bus. -* We expect only arch-specific PCI host bus controller driver -* or quirks for specific PCI bridges to be setting NO_MSI. +* +* The NO_MSI flag can either be set directly by: +* - arch-specific PCI host bus controller drivers (deprecated) +* - quirks for specific PCI bridges +* +* or indirectly by platform-specific PCI host bridge drivers by +* advertising the 'msi_domain' property, which results in +* the NO_MSI flag when no MSI domain is found for this bridge +* at probe time. */ for (bus = dev->bus; bus; bus = bus->parent)if (bus->bus_flags &PCI_BUS_FLAGS_NO_MSI )
Signature · 1 line
2.29.2
Re: [PATCH v3 13/14] PCI/MSI: Document the various ways of ending up with NO_MSI
Hi,
Quoted 18 lines · Marc Zyngier
We have now three ways of ending up with
NO_MSIbeing set. Document them.Acked-by Bjorn Helgaas <[email protected]>Signed-off-by Marc Zyngier <[email protected]>--- drivers/pci/msi.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)drivers/pci/msi.c +0
-1@@ -871,8 +871,15 @@ static int pci_msi_supported(struct pci_dev *dev, int nvec)* Any bridge which does NOT route MSI transactions from its * secondary bus to its primary bus must set NO_MSI flag on * the secondary pci_bus. -* We expect only arch-specific PCI host bus controller driver
drivers/pci/msi.c static int pci_msi_supported(struct pci_dev *dev, int nvec) · line 882
Quoted 10 lines
drivers/pci/msi.c +9
-1-* or quirks for specific PCI bridges to be setting NO_MSI. +* +* The NO_MSI flag can either be set directly by: +* - arch-specific PCI host bus controller drivers (deprecated) +* - quirks for specific PCI bridges +* +* or indirectly by platform-specific PCI host bridge drivers by +* advertising the 'msi_domain' property, which results in +* the NO_MSI flag when no MSI domain is found for this bridge +* at probe time.
I have an ACPI machine with a gicv2 (no m), and a MSI region that isn't described by ACPI because its non-standard. In the past this tended to work because PCIe device drivers would fall back to legacy pci intx silently. But, with 5.13, it seems this series now triggers the WARN_ON_ONCE() in arch_setup_msi_irq, because duh, no MSI support.
Everything of course continues to work, it just gets this ugly splat on bootup telling me basically the machine doesn't support MSIs. So, I considered a few patches, including just basically setting nomsi if gicv2 && acpi, or eek a host bridge quirk.
None of these seem great, so how can this be fixed?
Thanks,
Quoted 4 lines
drivers/pci/msi.c +0
-0*/ for (bus = dev->bus; bus; bus = bus->parent)if (bus->bus_flags &PCI_BUS_FLAGS_NO_MSI )
Re: [PATCH v3 13/14] PCI/MSI: Document the various ways of ending up with NO_MSI
Hi Jeremy,
Quoted 31 lines · Jeremy Linton
Hi,
Quoted 26 lines · Marc Zyngier
We have now three ways of ending up with
NO_MSIbeing set. Document them.Acked-by Bjorn Helgaas <[email protected]>Signed-off-by Marc Zyngier <[email protected]>--- drivers/pci/msi.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)drivers/pci/msi.c +7
-2@@ -871,8 +871,15 @@ static int pci_msi_supported(struct pci_dev *dev, int nvec)* Any bridge which does NOT route MSI transactions from its * secondary bus to its primary bus must set NO_MSI flag on * the secondary pci_bus. -* We expect only arch-specific PCI host bus controller driver -* or quirks for specific PCI bridges to be setting NO_MSI. +* +* The NO_MSI flag can either be set directly by: +* - arch-specific PCI host bus controller drivers (deprecated) +* - quirks for specific PCI bridges +* +* or indirectly by platform-specific PCI host bridge drivers by +* advertising the 'msi_domain' property, which results in
Quoted 8 lines
drivers/pci/msi.c static int pci_msi_supported(struct pci_dev *dev, int nvec) · line 882
Quoted 2 lines
drivers/pci/msi.c +2
-0+* the NO_MSI flag when no MSI domain is found for this bridge +* at probe time. I have an ACPI machine with a gicv2 (no m), and a MSI region that isn't described by ACPI because its non-standard. In the past this tended to work because PCIe device drivers would fall back to legacy pci intx silently. But, with 5.13, it seems this series now triggers the
WARN_ON_ONCE()inarch_setup_msi_irq, because duh, no MSI support.
This is nothing new, and you could get the exact same warning if you didn't have legacy drivers compiled in (any of the 3 drivers that were fixed in this series).
This series now makes sure you definitely know about this issue. And look, it worked! :-)
Quoted 6 lines
Everything of course continues to work, it just gets this ugly splat on bootup telling me basically the machine doesn't support MSIs. So, I considered a few patches, including just basically setting nomsi if gicv2 && acpi, or eek a host bridge quirk.
None of these seem great, so how can this be fixed?
The host bridge quirk seems the most likely route to address this, but you could just as well advertise msi_domain in the ACPI PCI path, *and* check for IORT mappings in pci_register_host_bridge(), similarly to what Jean-Philippe has proposed for DT in [1].
Thanks,
M.
[1] https://lore.kernel.org/r/[email protected]
Signature · 1 line
Without deviation from the norm, progress is not possible.
PATCH v3 14/14 PCI: Refactor HT advertising of NO_MSI flag
In reply to Marc ZyngierThe few quirks that deal with NO_MSI tend to be copy-paste heavy. Refactor them so that the hierarchy of conditions is slightly cleaner.
--- drivers/pci/quirks.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/pci/quirks.c +4 -11
@@ -2585,10 +2585,8 @@ static int msi_ht_cap_enabled(struct pci_dev *dev)/* Check the HyperTransport MSI mapping to know whether MSI is enabled or not */ static void quirk_msi_ht_cap (struct pci_dev *dev) { -if (dev->subordinate && !msi_ht_cap_enabled (dev)) { -pci_warn (dev,"MSI quirk detected; subordinate MSI disabled\n" ); - dev->subordinate->bus_flags |=PCI_BUS_FLAGS_NO_MSI ; - } +if (!msi_ht_cap_enabled (dev)) +quirk_disable_msi (dev); }DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_SERVERWORKS ,PCI_DEVICE_ID_SERVERWORKS_HT2000_PCIE , quirk_msi_ht_cap);
@@ -2601,9 +2599,6 @@ static void quirk_nvidia_ck804_msi_ht_cap(struct pci_dev *dev) {struct pci_dev *pdev; -if (!dev->subordinate) -return ; -/* * Check HT MSI cap on this chipset and the root one. A single one * having MSI is enough to be sure that MSI is supported.
@@ -2611,10 +2606,8 @@ static void quirk_nvidia_ck804_msi_ht_cap(struct pci_dev *dev) pdev =pci_get_slot (dev->bus,0 );if (!pdev)return ; -if (!msi_ht_cap_enabled (dev) && !msi_ht_cap_enabled (pdev)) { -pci_warn (dev,"MSI quirk detected; subordinate MSI disabled\n" ); - dev->subordinate->bus_flags |=PCI_BUS_FLAGS_NO_MSI ; - } +if (!msi_ht_cap_enabled (pdev)) +quirk_msi_ht_cap (dev);pci_dev_put (pdev); } DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE,
Signature · 1 line
2.29.2
Quoted 10 lines · Marc Zyngier
This is a respin of the series described at [1].
* From v2 [2]:
- Fixed the Xilinx driver, thanks to Bharat for testing it
- Dropped theno_msiattribute, and solely rely onmsi_domain, which has the same effect for the only platform that was using it.
- Fixed compilation on architectures that do not select the generic MSI support[...]
I have applied it to pci/msi and should be moved into -next shortly for further testing/visibility, thanks a lot for putting it together.
[01/14] PCI: tegra: Convert to MSI domains
https://git.kernel.org/lpieralisi/pci/c/973a28677e [02/14] PCI: rcar: Don't allocate extra memory for the MSI capture address https://git.kernel.org/lpieralisi/pci/c/c244dc15dc [03/14] PCI: rcar: Convert to MSI domains https://git.kernel.org/lpieralisi/pci/c/516286287d [04/14] PCI: xilinx: Don't allocate extra memory for the MSI capture address https://git.kernel.org/lpieralisi/pci/c/cc8cf90738 [05/14] PCI: xilinx: Convert to MSI domains https://git.kernel.org/lpieralisi/pci/c/b66873599e [06/14] PCI: hv: Drop msi_controller structure https://git.kernel.org/lpieralisi/pci/c/65b131816a [07/14] PCI/MSI: Drop use of msi_controller from core code https://git.kernel.org/lpieralisi/pci/c/54729d2a7a [08/14] PCI/MSI: Kill msi_controller structure https://git.kernel.org/lpieralisi/pci/c/27278a3fac [09/14] PCI/MSI: Kill default_teardown_msi_irqs() https://git.kernel.org/lpieralisi/pci/c/f68f571db9 [10/14] PCI/MSI: Let PCI host bridges declare their reliance on MSI domains https://git.kernel.org/lpieralisi/pci/c/419150a4ff [11/14] PCI/MSI: Make pci_host_common_probe() declare its reliance on MSI domains https://git.kernel.org/lpieralisi/pci/c/98be0634c8 [12/14] PCI: mediatek: Advertise lack of built-in MSI handling https://git.kernel.org/lpieralisi/pci/c/77cbd88c90 [13/14] PCI/MSI: Document the various ways of ending up with NO_MSI https://git.kernel.org/lpieralisi/pci/c/44ec480daf [14/14] PCI: Refactor HT advertising of NO_MSI flag https://git.kernel.org/lpieralisi/pci/c/18d56e5afe
Thanks,
Lorenzo
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Quoted 11 lines · Lorenzo Pieralisi
Quoted 9 lines · Marc Zyngier
This is a respin of the series described at [1].
* From v2 [2]:
- Fixed the Xilinx driver, thanks to Bharat for testing it
- Dropped theno_msiattribute, and solely rely onmsi_domain, which has the same effect for the only platform that was using it.
- Fixed compilation on architectures that do not select the generic MSI support
Quoted 4 lines
Quoted 1 line
[...]
I have applied it to pci/msi and should be moved into -next shortly for further testing/visibility, thanks a lot for putting it together.
Thanks Lorenzo.
M.
Signature · 6 lines
Without deviation from the norm, progress is not possible. _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek