linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiaxun Yang <jiaxun.yang@flygoat.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: maz@kernel.org, Rob Herring <robh@kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Rob Herring <robh+dt@kernel.org>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Huacai Chen <chenhc@lemote.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Paul Burton <paulburton@kernel.org>,
	linux-pci@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org
Subject: Re: [PATCH v8 2/5] PCI: Add Loongson PCI Controller support
Date: Sat, 09 May 2020 01:28:24 +0800	[thread overview]
Message-ID: <2C23FC3E-6BBF-47EB-8EE6-89EAC5A28104@flygoat.com> (raw)
In-Reply-To: <20200508171730.GA77036@bjorn-Precision-5520>



于 2020年5月9日 GMT+08:00 上午1:17:30, Bjorn Helgaas <helgaas@kernel.org> 写到:
>On Fri, May 08, 2020 at 07:34:02PM +0800, Jiaxun Yang wrote:
>> This controller can be found on Loongson-2K SoC, Loongson-3
>> systems with RS780E/LS7A PCH.
>> 
>> The RS780E part of code was previously located at
>> arch/mips/pci/ops-loongson3.c and now it can use generic PCI
>> driver implementation.
>> 
>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>> Reviewed-by: Rob Herring <robh@kernel.org>
>
>> +static void system_bus_quirk(struct pci_dev *pdev)
>> +{
>> +	u16 tmp;
>> +
>> +	/* 
>> +	 * System buses on Loongson system contain garbage in BARs
>> +	 * but their decoding need to be enabled to ensure devices
>> +	 * under system buses are reachable. In most cases it should
>> +	 * be done by the firmware.
>
>This isn't a very satisfying explanation because devices that have
>decoding enabled can interfere with other devices in the system, and I
>can't tell whether that's a problem here.
>
>What happens when you turn on MEM/IO decoding below?  Does the device
>decode any address space?  How do we know what it is?  Is it related
>to the BAR contents?
>
>I'm a little dubious about the need for the PCI_COMMAND write because
>the previous version didn't do it (since it incorrectly wrote to
>PCI_STATUS), and I assume that version worked.

Hi,
Sorry, but that's all I can tell from the chips manual as I'm not a employee
of the vendor.

My assumption is these BAR contains the address of those system components
that already configured by firmware and we shouldn't touch it.

In fact according to my tests if we let Kernel probe these BAR then the
system will hang immediately.

Chip manual suggested OS to ensure decoding is enabled
so I'm doing like this. But without this system can also work.

Do you think I should drop it until figure out what was it actually doing?

>
>> +	pdev->mmio_always_on = 1;
>> +	pdev->non_compliant_bars = 1;
>> +	/* Enable MEM & IO Decoding */
>> +	pci_read_config_word(pdev, PCI_COMMAND, &tmp);
>> +	tmp |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
>> +	pci_write_config_word(pdev, PCI_COMMAND, tmp);
>
>
>> +}
>> +
>
>Omit this blank line.

Ack

>
>> +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
>> +			DEV_LS2K_APB, system_bus_quirk);
>> +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
>> +			DEV_LS7A_CONF, system_bus_quirk);
>> +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON,
>> +			DEV_LS7A_LPC, system_bus_quirk);
>> +
>> +static void loongson_mrrs_quirk(struct pci_dev *dev)
>> +{
>> +	struct pci_bus *bus = dev->bus;
>> +	struct pci_dev *bridge;
>> +	static const struct pci_device_id bridge_devids[] = {
>> +		{ PCI_VDEVICE(LOONGSON, DEV_PCIE_PORT_0) },
>> +		{ PCI_VDEVICE(LOONGSON, DEV_PCIE_PORT_1) },
>> +		{ PCI_VDEVICE(LOONGSON, DEV_PCIE_PORT_2) },
>> +		{ 0, },
>> +	};
>> +
>> +
>
>Remove one of these blank lines.

Ack

>
>> +	/* look for the matching bridge */
>> +	while (!pci_is_root_bus(bus)) {
>> +		bridge = bus->self;
>> +		bus = bus->parent;
>> +		/*
>> +		 * Some Loongson PCIe ports have a h/w limitation of
>> +		 * 256 bytes maximum read request size. They can't handle
>> +		 * anything larger than this. So force this limit on
>> +		 * any devices attached under these ports.
>> +		 */
>> +		if (pci_match_id(bridge_devids, bridge)) {
>> +			if (pcie_get_readrq(dev) > 256) {
>> +				pci_info(dev, "limiting MRRS to 256\n");
>> +				pcie_set_readrq(dev, 256);
>> +			}
>> +			break;
>> +		}
>> +	}
>> +}
>> +DECLARE_PCI_FIXUP_ENABLE(PCI_ANY_ID, PCI_ANY_ID, loongson_mrrs_quirk);
>
>> +void __iomem *pci_loongson_map_bus(struct pci_bus *bus, unsigned int devfn,
>> +			       int where)
>> +{
>> +	unsigned char busnum = bus->number;
>> +	struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
>> +	struct loongson_pci *priv =  pci_host_bridge_priv(bridge);
>> +
>> +	/*
>> +	 * Do not read more than one device on the bus other than
>> +	 * the host bridge.
>
>s/host bridge/root bus/ ?
>
>IIUC, the test below assumes the root bus is bus 0, which is not
>necessarily the case.  Many other .*_map_bus() implementations have
>similar tests for devices on the root bus:

Ack

>
>  al_pcie_map_bus(...)
>  {
>    if (bus->number == cfg->busr.start) {
>
>> +	if (priv->flags & FLAG_DEV_FIX && bus->primary != 0 &&
>> +		PCI_SLOT(devfn) > 0)
>> +		return NULL;

Thanks!

-- 
Jiaxun Yang

  reply	other threads:[~2020-05-08 17:29 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-27  6:05 [PATCH v6 0/5] Loongson PCI Generic Driver Jiaxun Yang
2020-04-27  6:05 ` [PATCH v6 1/5] PCI: Don't disable decoding when mmio_always_on is set Jiaxun Yang
2020-04-27  7:42   ` Philippe Mathieu-Daudé
2020-04-27  6:05 ` [PATCH v6 2/5] PCI: Add Loongson PCI Controller support Jiaxun Yang
2020-04-27  6:29   ` Huacai Chen
2020-04-27  6:46     ` Jiaxun Yang
2020-04-27  6:05 ` [PATCH v6 3/5] dt-bindings: Document Loongson PCI Host Controller Jiaxun Yang
2020-04-27  6:05 ` [PATCH v6 4/5] MIPS: DTS: Loongson64: Add PCI Controller Node Jiaxun Yang
2020-04-27  6:05 ` [PATCH v6 5/5] MIPS: Loongson64: Switch to generic PCI driver Jiaxun Yang
2020-04-28  1:14 ` [PATCH v7 0/5] Loongson PCI Generic Driver Jiaxun Yang
2020-04-28  1:14   ` [PATCH v7 1/5] PCI: Don't disable decoding when mmio_always_on is set Jiaxun Yang
2020-05-08 18:51     ` Bjorn Helgaas
2020-05-20 20:55     ` Rob Herring
2020-04-28  1:14   ` [PATCH v7 2/5] PCI: Add Loongson PCI Controller support Jiaxun Yang
2020-04-29 18:43     ` Rob Herring
2020-05-04 23:43     ` Bjorn Helgaas
2020-05-06  6:08       ` Jiaxun Yang
2020-04-28  1:14   ` [PATCH v7 3/5] dt-bindings: Document Loongson PCI Host Controller Jiaxun Yang
2020-04-28  1:14   ` [PATCH v7 4/5] MIPS: DTS: Loongson64: Add PCI Controller Node Jiaxun Yang
2020-04-28  1:14   ` [PATCH v7 5/5] MIPS: Loongson64: Switch to generic PCI driver Jiaxun Yang
2020-05-08 11:34 ` [PATCH v8 1/5] PCI: Don't disable decoding when mmio_always_on is set Jiaxun Yang
2020-05-08 11:34   ` [PATCH v8 2/5] PCI: Add Loongson PCI Controller support Jiaxun Yang
2020-05-08 17:17     ` Bjorn Helgaas
2020-05-08 17:28       ` Jiaxun Yang [this message]
2020-05-08 19:34         ` Bjorn Helgaas
2020-05-08 11:34   ` [PATCH v8 3/5] dt-bindings: Document Loongson PCI Host Controller Jiaxun Yang
2020-05-08 11:34   ` [PATCH v8 4/5] MIPS: DTS: Loongson64: Add PCI Controller Node Jiaxun Yang
2020-05-08 11:34   ` [PATCH v8 5/5] MIPS: Loongson64: Switch to generic PCI driver Jiaxun Yang
2020-05-08 22:04     ` Bjorn Helgaas
2020-05-12  7:43 ` [PATCH v9 1/5] PCI: Don't disable decoding when mmio_always_on is set Jiaxun Yang
2020-05-12  7:43   ` [PATCH v9 2/5] PCI: Add Loongson PCI Controller support Jiaxun Yang
2020-05-12 18:06     ` Bjorn Helgaas
2020-05-13  1:20       ` Jiaxun Yang
2020-05-13 15:05         ` Bjorn Helgaas
2020-05-12  7:43   ` [PATCH v9 3/5] dt-bindings: Document Loongson PCI Host Controller Jiaxun Yang
2020-05-12  7:43   ` [PATCH v9 4/5] MIPS: DTS: Loongson64: Add PCI Controller Node Jiaxun Yang
2020-05-12  7:43   ` [PATCH v9 5/5] MIPS: Loongson64: Switch to generic PCI driver Jiaxun Yang
2020-05-14 13:16 ` [PATCH v10 1/5] PCI: Don't disable decoding when mmio_always_on is set Jiaxun Yang
2020-05-14 13:16   ` [PATCH v10 2/5] PCI: Add Loongson PCI Controller support Jiaxun Yang
2020-05-20 11:57     ` Jiaxun Yang
2020-05-22 13:10       ` Lorenzo Pieralisi
2020-05-22 13:32         ` Jiaxun Yang
2020-05-22 13:40           ` Lorenzo Pieralisi
2020-05-22 14:27             ` Thomas Bogendoerfer
2020-05-22 14:27           ` Thomas Bogendoerfer
2020-05-26  9:10     ` Lorenzo Pieralisi
2020-05-14 13:16   ` [PATCH v10 3/5] dt-bindings: Document Loongson PCI Host Controller Jiaxun Yang
2020-05-14 13:16   ` [PATCH v10 4/5] MIPS: DTS: Loongson64: Add PCI Controller Node Jiaxun Yang
2020-05-22 14:25     ` Thomas Bogendoerfer
2020-05-14 13:16   ` [PATCH v10 5/5] MIPS: Loongson64: Switch to generic PCI driver Jiaxun Yang
2020-05-22 14:25     ` Thomas Bogendoerfer
2020-05-22 15:22       ` Lorenzo Pieralisi
2020-05-22 22:36         ` Thomas Bogendoerfer
2020-05-26  9:12           ` Lorenzo Pieralisi
2020-05-26  9:14             ` Jiaxun Yang
2020-05-27 11:34             ` Thomas Bogendoerfer
2020-05-26  9:21 ` [PATCH v11 0/5] Loongson Generic PCI v11 Jiaxun Yang
2020-05-26  9:21   ` [PATCH v11 1/5] PCI: Don't disable decoding when mmio_always_on is set Jiaxun Yang
2020-05-26  9:21   ` [PATCH v11 2/5] PCI: Add Loongson PCI Controller support Jiaxun Yang
2020-05-26  9:21   ` [PATCH v11 3/5] dt-bindings: Document Loongson PCI Host Controller Jiaxun Yang
2020-05-26  9:21   ` [PATCH v11 4/5] MIPS: DTS: Loongson64: Add PCI Controller Node Jiaxun Yang
2020-05-26  9:21   ` [PATCH v11 5/5] MIPS: Loongson64: Switch to generic PCI driver Jiaxun Yang
2020-05-27 11:35   ` [PATCH v11 0/5] Loongson Generic PCI v11 Thomas Bogendoerfer

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=2C23FC3E-6BBF-47EB-8EE6-89EAC5A28104@flygoat.com \
    --to=jiaxun.yang@flygoat.com \
    --cc=bhelgaas@google.com \
    --cc=chenhc@lemote.com \
    --cc=devicetree@vger.kernel.org \
    --cc=helgaas@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=maz@kernel.org \
    --cc=paulburton@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=robh@kernel.org \
    --cc=tsbogend@alpha.franken.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: 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;
as well as URLs for NNTP newsgroup(s).