On 2016/5/25 5:04, Bjorn Helgaas wrote:

On Wed, Apr 27, 2016 at 08:43:28PM +0800, Yongji Xie wrote:
On ARM HW the capability of IRQ remapping is abstracted on
MSI controller side. MSI_FLAG_IRQ_REMAPPING is used to advertise
this [1].

To have a universal flag to test this capability for different
archs on PCI side, we set PCI_BUS_FLAGS_MSI_REMAP for PCI buses
when MSI_FLAG_IRQ_REMAPPING is set.

[1] http://www.spinics.net/lists/kvm/msg130256.html

Signed-off-by: Yongji Xie <xyj...@linux.vnet.ibm.com>
---
  drivers/pci/msi.c   |   12 ++++++++++++
  drivers/pci/probe.c |    3 +++
  include/linux/msi.h |    6 +++++-
  3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index a080f44..1661cdf 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -1134,6 +1134,18 @@ void *msi_desc_to_pci_sysdata(struct msi_desc *desc)
  }
  EXPORT_SYMBOL_GPL(msi_desc_to_pci_sysdata);
+void pci_bus_check_msi_remapping(struct pci_bus *bus,
+                                struct irq_domain *domain)
+{
+#ifdef CONFIG_PCI_MSI_IRQ_DOMAIN
+       struct msi_domain_info *info;
+
+       info = msi_get_domain_info(domain);
+       if (info->flags & MSI_FLAG_IRQ_REMAPPING)
+               bus->bus_flags |= PCI_BUS_FLAGS_MSI_REMAP;
+#endif
+}
Functions named "check_foo" are a pet peeve of mine because the name
doesn't tell us anything about what the function *does*.  In this
case, we know it checks something about MSI remapping, but we don't
know whether we're checking whether it's enabled, disabled, or some
other property.

I'd prefer something like:

   int pci_bus_msi_isolated(struct pci_bus *bus, struct irq_domain *domain)
   {
     struct msi_domain_info *info;

     if (!domain)
       return 0;

     info = msi_get_domain_info(domain);
     if (info->flags & MSI_FLAG_IRQ_REMAPPING)
       return 1;

     return 0;
   }

   void pci_set_bus_msi_domain(struct pci_bus *bus)
   {
     ...
     if (b == bus && pci_bus_msi_isolated(bus, d))
       bus->bus_flags |= PCI_BUS_FLAGS_MSI_REMAP;

Yes. This looks more reasonable. Thank you!

Regards,
Yongji

Reply via email to