From: Marc Zyngier <maz@kernel.org> To: Frank Wunderlich <frank-w@public-files.de> Cc: Thomas Gleixner <tglx@linutronix.de>, Ryder Lee <ryder.lee@mediatek.com>, linux-mediatek@lists.infradead.org, Frank Wunderlich <linux@fw-web.de>, linux-kernel@vger.kernel.org, Matthias Brugger <matthias.bgg@gmail.com>, linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com> Subject: Re: Aw: Re: Re: [PATCH] pci: mediatek: fix warning in msi.h Date: Mon, 02 Nov 2020 13:58:12 +0000 [thread overview] Message-ID: <336d6588567949029c52ecfbb87660c1@kernel.org> (raw) In-Reply-To: <trinity-4313623b-1adf-4cc3-8b50-2d0593669995-1604318207058@3c-app-gmx-bap57> On 2020-11-02 11:56, Frank Wunderlich wrote: > looks good on bananapi-r2, no warning, pcie-card and hdd recognized Thanks for giving it a shot. Still needs a bit of tweaking, as I expect it to break configurations that select CONFIG_PCI_MSI_ARCH_FALLBACKS (we have to assume that MSIs can be handled until we hit the arch-specific stuff). There is also a small nit in the way we allow userspace to mess with this flag via sysfs, and similar restrictions should probably apply. Updated patch below. M. diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index d15c881e2e7e..5bb1306162c7 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -387,10 +387,20 @@ static ssize_t msi_bus_store(struct device *dev, struct device_attribute *attr, return count; } - if (val) + if (val) { + /* + * If there is no possibility for this bus to deal with + * MSIs, then allowing them to be requested would lead to + * the kernel complaining loudly. In this situation, don't + * let userspace mess things up. + */ + if (!pci_bus_is_msi_capable(subordinate)) + return -EINVAL; + subordinate->bus_flags &= ~PCI_BUS_FLAGS_NO_MSI; - else + } else { subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; + } dev_info(&subordinate->dev, "MSI/MSI-X %s for future drivers of devices on this bus\n", val ? "allowed" : "disallowed"); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 4289030b0fff..28861cc6435a 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -871,6 +871,8 @@ static void pci_set_bus_msi_domain(struct pci_bus *bus) d = pci_host_bridge_msi_domain(b); dev_set_msi_domain(&bus->dev, d); + if (!pci_bus_is_msi_capable(bus)) + bus->bus_flags |= PCI_BUS_FLAGS_NO_MSI; } static int pci_register_host_bridge(struct pci_host_bridge *bridge) diff --git a/include/linux/pci.h b/include/linux/pci.h index 22207a79762c..6aadb863dff4 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2333,6 +2333,12 @@ pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; } static inline bool pci_pr3_present(struct pci_dev *pdev) { return false; } #endif +static inline bool pci_bus_is_msi_capable(struct pci_bus *bus) +{ + return (IS_ENABLED(CONFIG_PCI_MSI_ARCH_FALLBACKS) || + dev_get_msi_domain(&bus->dev)); +} + #ifdef CONFIG_EEH static inline struct eeh_dev *pci_dev_to_eeh_dev(struct pci_dev *pdev) { -- Jazz is not dead. It just smells funny...
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org> To: Frank Wunderlich <frank-w@public-files.de> Cc: Ryder Lee <ryder.lee@mediatek.com>, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>, linux-mediatek@lists.infradead.org, Matthias Brugger <matthias.bgg@gmail.com>, Thomas Gleixner <tglx@linutronix.de>, Frank Wunderlich <linux@fw-web.de> Subject: Re: Aw: Re: Re: [PATCH] pci: mediatek: fix warning in msi.h Date: Mon, 02 Nov 2020 13:58:12 +0000 [thread overview] Message-ID: <336d6588567949029c52ecfbb87660c1@kernel.org> (raw) In-Reply-To: <trinity-4313623b-1adf-4cc3-8b50-2d0593669995-1604318207058@3c-app-gmx-bap57> On 2020-11-02 11:56, Frank Wunderlich wrote: > looks good on bananapi-r2, no warning, pcie-card and hdd recognized Thanks for giving it a shot. Still needs a bit of tweaking, as I expect it to break configurations that select CONFIG_PCI_MSI_ARCH_FALLBACKS (we have to assume that MSIs can be handled until we hit the arch-specific stuff). There is also a small nit in the way we allow userspace to mess with this flag via sysfs, and similar restrictions should probably apply. Updated patch below. M. diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index d15c881e2e7e..5bb1306162c7 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -387,10 +387,20 @@ static ssize_t msi_bus_store(struct device *dev, struct device_attribute *attr, return count; } - if (val) + if (val) { + /* + * If there is no possibility for this bus to deal with + * MSIs, then allowing them to be requested would lead to + * the kernel complaining loudly. In this situation, don't + * let userspace mess things up. + */ + if (!pci_bus_is_msi_capable(subordinate)) + return -EINVAL; + subordinate->bus_flags &= ~PCI_BUS_FLAGS_NO_MSI; - else + } else { subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; + } dev_info(&subordinate->dev, "MSI/MSI-X %s for future drivers of devices on this bus\n", val ? "allowed" : "disallowed"); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 4289030b0fff..28861cc6435a 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -871,6 +871,8 @@ static void pci_set_bus_msi_domain(struct pci_bus *bus) d = pci_host_bridge_msi_domain(b); dev_set_msi_domain(&bus->dev, d); + if (!pci_bus_is_msi_capable(bus)) + bus->bus_flags |= PCI_BUS_FLAGS_NO_MSI; } static int pci_register_host_bridge(struct pci_host_bridge *bridge) diff --git a/include/linux/pci.h b/include/linux/pci.h index 22207a79762c..6aadb863dff4 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2333,6 +2333,12 @@ pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; } static inline bool pci_pr3_present(struct pci_dev *pdev) { return false; } #endif +static inline bool pci_bus_is_msi_capable(struct pci_bus *bus) +{ + return (IS_ENABLED(CONFIG_PCI_MSI_ARCH_FALLBACKS) || + dev_get_msi_domain(&bus->dev)); +} + #ifdef CONFIG_EEH static inline struct eeh_dev *pci_dev_to_eeh_dev(struct pci_dev *pdev) { -- Jazz is not dead. It just smells funny... _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek
next prev parent reply other threads:[~2020-11-02 13:58 UTC|newest] Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-31 14:03 [PATCH] pci: mediatek: fix warning in msi.h Frank Wunderlich 2020-10-31 14:03 ` Frank Wunderlich 2020-10-31 21:49 ` Thomas Gleixner 2020-10-31 21:49 ` Thomas Gleixner 2020-11-01 9:25 ` Frank Wunderlich 2020-11-01 9:25 ` Frank Wunderlich 2020-11-01 11:17 ` Thomas Gleixner 2020-11-01 11:17 ` Thomas Gleixner 2020-11-01 11:43 ` Marc Zyngier 2020-11-01 11:43 ` Marc Zyngier 2020-11-01 15:58 ` Aw: " Frank Wunderlich 2020-11-01 15:58 ` Frank Wunderlich 2020-11-01 17:54 ` Ryder Lee 2020-11-01 17:54 ` Ryder Lee 2020-11-01 18:27 ` Aw: " Frank Wunderlich 2020-11-01 18:27 ` Frank Wunderlich 2020-11-01 21:47 ` Marc Zyngier 2020-11-01 21:47 ` Marc Zyngier 2020-11-01 22:27 ` Thomas Gleixner 2020-11-01 22:27 ` Thomas Gleixner 2020-11-02 11:30 ` Marc Zyngier 2020-11-02 11:30 ` Marc Zyngier 2020-11-02 11:56 ` Aw: " Frank Wunderlich 2020-11-02 11:56 ` Frank Wunderlich 2020-11-02 13:58 ` Marc Zyngier [this message] 2020-11-02 13:58 ` Marc Zyngier 2020-11-02 14:27 ` Aw: " Frank Wunderlich 2020-11-02 14:27 ` Frank Wunderlich 2020-11-02 16:16 ` Aw: " Thomas Gleixner 2020-11-02 16:16 ` Thomas Gleixner 2020-11-02 22:18 ` Thomas Gleixner 2020-11-02 22:18 ` Thomas Gleixner 2020-11-03 9:54 ` Marc Zyngier 2020-11-03 9:54 ` Marc Zyngier 2020-11-03 10:16 ` Thomas Gleixner 2020-11-03 10:16 ` Thomas Gleixner 2020-11-03 10:29 ` Marc Zyngier 2020-11-03 10:29 ` Marc Zyngier 2020-11-04 16:49 ` Aw: " Frank Wunderlich 2020-11-04 16:49 ` Frank Wunderlich 2020-11-04 23:14 ` Thomas Gleixner 2020-11-04 23:14 ` Thomas Gleixner 2020-11-05 9:20 ` Marc Zyngier 2020-11-05 9:20 ` Marc Zyngier 2020-11-05 13:59 ` Aw: " Frank Wunderlich 2020-11-05 13:59 ` Frank Wunderlich 2020-11-05 23:00 ` Aw: " Thomas Gleixner 2020-11-05 23:00 ` Thomas Gleixner 2020-11-06 9:43 ` Marc Zyngier 2020-11-06 9:43 ` Marc Zyngier 2020-11-21 16:12 ` Aw: " Frank Wunderlich 2020-11-21 16:12 ` Frank Wunderlich 2021-01-03 13:08 ` Frank Wunderlich 2021-01-03 13:08 ` Frank Wunderlich 2021-02-02 16:21 ` Frank Wunderlich 2021-02-02 16:21 ` Frank Wunderlich 2020-11-03 10:31 ` Aw: " Thomas Gleixner 2020-11-03 10:31 ` Thomas Gleixner 2020-11-03 11:41 ` Marc Zyngier 2020-11-03 11:41 ` Marc Zyngier 2020-11-03 14:23 ` Thomas Gleixner 2020-11-03 14:23 ` Thomas Gleixner
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=336d6588567949029c52ecfbb87660c1@kernel.org \ --to=maz@kernel.org \ --cc=bhelgaas@google.com \ --cc=frank-w@public-files.de \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mediatek@lists.infradead.org \ --cc=linux-pci@vger.kernel.org \ --cc=linux@fw-web.de \ --cc=matthias.bgg@gmail.com \ --cc=ryder.lee@mediatek.com \ --cc=tglx@linutronix.de \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.