2
0

850-0002-PCI-aardvark-Fix-reading-MSI-interrupt-number.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. From a29a7d01cd778854e08108461cba321a63d98871 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <[email protected]>
  3. Date: Fri, 2 Jul 2021 16:39:47 +0200
  4. Subject: [PATCH] PCI: aardvark: Fix reading MSI interrupt number
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. In advk_pcie_handle_msi() the authors expect that when bit i in the W1C
  9. register PCIE_MSI_STATUS_REG is cleared, the PCIE_MSI_PAYLOAD_REG is
  10. updated to contain the MSI number corresponding to index i.
  11. Experiments show that this is not so, and instead PCIE_MSI_PAYLOAD_REG
  12. always contains the number of the last received MSI, overall.
  13. Do not read PCIE_MSI_PAYLOAD_REG register for determining MSI interrupt
  14. number. Since Aardvark already forbids more than 32 interrupts and uses
  15. own allocated hwirq numbers, the msi_idx already corresponds to the
  16. received MSI number.
  17. Fixes: 8c39d710363c ("PCI: aardvark: Add Aardvark PCI host controller driver")
  18. Signed-off-by: Pali Rohár <[email protected]>
  19. Signed-off-by: Marek Behún <[email protected]>
  20. ---
  21. drivers/pci/controller/pci-aardvark.c | 13 ++++++-------
  22. 1 file changed, 6 insertions(+), 7 deletions(-)
  23. --- a/drivers/pci/controller/pci-aardvark.c
  24. +++ b/drivers/pci/controller/pci-aardvark.c
  25. @@ -1391,7 +1391,7 @@ static void advk_pcie_remove_irq_domain(
  26. static void advk_pcie_handle_msi(struct advk_pcie *pcie)
  27. {
  28. u32 msi_val, msi_mask, msi_status, msi_idx;
  29. - u16 msi_data;
  30. + int virq;
  31. msi_mask = advk_readl(pcie, PCIE_MSI_MASK_REG);
  32. msi_val = advk_readl(pcie, PCIE_MSI_STATUS_REG);
  33. @@ -1401,13 +1401,12 @@ static void advk_pcie_handle_msi(struct
  34. if (!(BIT(msi_idx) & msi_status))
  35. continue;
  36. - /*
  37. - * msi_idx contains bits [4:0] of the msi_data and msi_data
  38. - * contains 16bit MSI interrupt number
  39. - */
  40. advk_writel(pcie, BIT(msi_idx), PCIE_MSI_STATUS_REG);
  41. - msi_data = advk_readl(pcie, PCIE_MSI_PAYLOAD_REG) & PCIE_MSI_DATA_MASK;
  42. - generic_handle_irq(msi_data);
  43. + virq = irq_find_mapping(pcie->msi_inner_domain, msi_idx);
  44. + if (virq)
  45. + generic_handle_irq(virq);
  46. + else
  47. + dev_err_ratelimited(&pcie->pdev->dev, "unexpected MSI 0x%02x\n", msi_idx);
  48. }
  49. advk_writel(pcie, PCIE_ISR0_MSI_INT_PENDING,