Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Huacai Chen <chenhuacai@loongson.cn>
Cc: "Bjorn Helgaas" <bhelgaas@google.com>,
	"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Rob Herring" <robh@kernel.org>,
	loongarch@lists.linux.dev, linux-pci@vger.kernel.org,
	"Jianmin Lv" <lvjianmin@loongson.cn>,
	"Xuefeng Li" <lixuefeng@loongson.cn>,
	"Huacai Chen" <chenhuacai@gmail.com>,
	"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
	stable@vger.kernel.org, "Sheng Wu" <wusheng@loongson.cn>
Subject: Re: [PATCH] PCI: loongson: Add LS7A MSI enablement quirk
Date: Tue, 9 Jul 2024 16:24:14 -0500	[thread overview]
Message-ID: <20240709212414.GA195866@bhelgaas> (raw)
In-Reply-To: <20240612065315.2048110-1-chenhuacai@loongson.cn>

On Wed, Jun 12, 2024 at 02:53:15PM +0800, Huacai Chen wrote:
> LS7A chipset can be used as a downstream bridge which connected to a
> high-level host bridge. In this case DEV_LS7A_PCIE_PORT5 is used as the
> upward port. We should always enable MSI caps of this port, otherwise
> downstream devices cannot use MSI.

Can you clarify this topology a bit?  Since DEV_LS7A_PCIE_PORT5
apparently has a class of PCI_CLASS_BRIDGE_HOST, I guess that in PCIe
terms, it is basically a PCI host bridge (Root Complex, if you prefer)
that is materialized as a PCI Endpoint?

I'm curious about what's going on here because the normal PCI MSI
support should set PCI_MSI_FLAGS_ENABLE since it's completely
specified by the spec, which says it controls whether *this function*
can use MSI.

But in this case PCI_MSI_FLAGS_ENABLE seems to have non-architected
behavior of controlling MSI from *other* devices below this host
bridge?  That's a little bit weird too because MSI looks like DMA to
any bridges upstream from the device that is using MSI, and the Bus
Master Enable bit in those bridges controls whether they forward those
MSI DMA accesses upstream.  And of course the PCI core should already
make sure those bridges have Bus Master Enable set when downstream
devices use MSI.

> Cc: <stable@vger.kernel.org>
> Signed-off-by: Sheng Wu <wusheng@loongson.cn>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> ---
>  drivers/pci/controller/pci-loongson.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/pci/controller/pci-loongson.c b/drivers/pci/controller/pci-loongson.c
> index 8b34ccff073a..ffc581605834 100644
> --- a/drivers/pci/controller/pci-loongson.c
> +++ b/drivers/pci/controller/pci-loongson.c
> @@ -163,6 +163,18 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON,
>  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON,
>  			DEV_LS7A_HDMI, loongson_pci_pin_quirk);
>  
> +static void loongson_pci_msi_quirk(struct pci_dev *dev)
> +{
> +	u16 val, class = dev->class >> 8;
> +
> +	if (class == PCI_CLASS_BRIDGE_HOST) {
> +		pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &val);
> +		val |= PCI_MSI_FLAGS_ENABLE;
> +		pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, val);
> +	}
> +}
> +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, DEV_LS7A_PCIE_PORT5, loongson_pci_msi_quirk);
> +
>  static struct loongson_pci *pci_bus_to_loongson_pci(struct pci_bus *bus)
>  {
>  	struct pci_config_window *cfg;
> -- 
> 2.43.0
> 

  parent reply	other threads:[~2024-07-09 21:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-12  6:53 [PATCH] PCI: loongson: Add LS7A MSI enablement quirk Huacai Chen
2024-07-06  3:07 ` Krzysztof Wilczyński
2024-07-06  3:09   ` Krzysztof Wilczyński
2024-07-09 21:24 ` Bjorn Helgaas [this message]
2024-07-10  3:04   ` Huacai Chen
2024-07-10 19:48     ` Bjorn Helgaas
2024-07-18 13:01       ` Huacai Chen
2024-07-18 23:03         ` Bjorn Helgaas
2024-07-19  6:23           ` Huacai Chen

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=20240709212414.GA195866@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=chenhuacai@gmail.com \
    --cc=chenhuacai@loongson.cn \
    --cc=jiaxun.yang@flygoat.com \
    --cc=kw@linux.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --cc=loongarch@lists.linux.dev \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=lvjianmin@loongson.cn \
    --cc=robh@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=wusheng@loongson.cn \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox