850-0011-PCI-aardvark-Fix-setting-MSI-address.patch 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. From fa73c200f181436eab859374657c53a73778d8ad Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <[email protected]>
  3. Date: Fri, 26 Mar 2021 17:35:44 +0100
  4. Subject: [PATCH] PCI: aardvark: Fix setting MSI address
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. MSI address for receiving MSI interrupts needs to be correctly set before
  9. enabling processing of MSI interrupts.
  10. Move code for setting PCIE_MSI_ADDR_LOW_REG and PCIE_MSI_ADDR_HIGH_REG
  11. from advk_pcie_init_msi_irq_domain() to advk_pcie_setup_hw(), before
  12. enabling PCIE_CORE_CTRL2_MSI_ENABLE.
  13. After this we can remove the now unused member msi_msg, which was used
  14. only for MSI doorbell address. MSI address can be any address which cannot
  15. be used to DMA to. So change it to the address of the main struct advk_pcie.
  16. Fixes: 8c39d710363c ("PCI: aardvark: Add Aardvark PCI host controller driver")
  17. Signed-off-by: Pali Rohár <[email protected]>
  18. Acked-by: Marc Zyngier <[email protected]>
  19. Signed-off-by: Marek Behún <[email protected]>
  20. Cc: [email protected] # f21a8b1b6837 ("PCI: aardvark: Move to MSI handling using generic MSI support")
  21. ---
  22. drivers/pci/controller/pci-aardvark.c | 21 +++++++++------------
  23. 1 file changed, 9 insertions(+), 12 deletions(-)
  24. --- a/drivers/pci/controller/pci-aardvark.c
  25. +++ b/drivers/pci/controller/pci-aardvark.c
  26. @@ -277,7 +277,6 @@ struct advk_pcie {
  27. raw_spinlock_t msi_irq_lock;
  28. DECLARE_BITMAP(msi_used, MSI_IRQ_NUM);
  29. struct mutex msi_used_lock;
  30. - u16 msi_msg;
  31. int link_gen;
  32. struct pci_bridge_emul bridge;
  33. struct gpio_desc *reset_gpio;
  34. @@ -472,6 +471,7 @@ static void advk_pcie_disable_ob_win(str
  35. static void advk_pcie_setup_hw(struct advk_pcie *pcie)
  36. {
  37. + phys_addr_t msi_addr;
  38. u32 reg;
  39. int i;
  40. @@ -560,6 +560,11 @@ static void advk_pcie_setup_hw(struct ad
  41. reg |= LANE_COUNT_1;
  42. advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG);
  43. + /* Set MSI address */
  44. + msi_addr = virt_to_phys(pcie);
  45. + advk_writel(pcie, lower_32_bits(msi_addr), PCIE_MSI_ADDR_LOW_REG);
  46. + advk_writel(pcie, upper_32_bits(msi_addr), PCIE_MSI_ADDR_HIGH_REG);
  47. +
  48. /* Enable MSI */
  49. reg = advk_readl(pcie, PCIE_CORE_CTRL2_REG);
  50. reg |= PCIE_CORE_CTRL2_MSI_ENABLE;
  51. @@ -1179,10 +1184,10 @@ static void advk_msi_irq_compose_msi_msg
  52. struct msi_msg *msg)
  53. {
  54. struct advk_pcie *pcie = irq_data_get_irq_chip_data(data);
  55. - phys_addr_t msi_msg = virt_to_phys(&pcie->msi_msg);
  56. + phys_addr_t msi_addr = virt_to_phys(pcie);
  57. - msg->address_lo = lower_32_bits(msi_msg);
  58. - msg->address_hi = upper_32_bits(msi_msg);
  59. + msg->address_lo = lower_32_bits(msi_addr);
  60. + msg->address_hi = upper_32_bits(msi_addr);
  61. msg->data = data->hwirq;
  62. }
  63. @@ -1341,18 +1346,10 @@ static struct msi_domain_info advk_msi_d
  64. static int advk_pcie_init_msi_irq_domain(struct advk_pcie *pcie)
  65. {
  66. struct device *dev = &pcie->pdev->dev;
  67. - phys_addr_t msi_msg_phys;
  68. raw_spin_lock_init(&pcie->msi_irq_lock);
  69. mutex_init(&pcie->msi_used_lock);
  70. - msi_msg_phys = virt_to_phys(&pcie->msi_msg);
  71. -
  72. - advk_writel(pcie, lower_32_bits(msi_msg_phys),
  73. - PCIE_MSI_ADDR_LOW_REG);
  74. - advk_writel(pcie, upper_32_bits(msi_msg_phys),
  75. - PCIE_MSI_ADDR_HIGH_REG);
  76. -
  77. pcie->msi_inner_domain =
  78. irq_domain_add_linear(NULL, MSI_IRQ_NUM,
  79. &advk_msi_domain_ops, pcie);