mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chen Wang <unicorn_wang@outlook.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: kw@linux.com, u.kleine-koenig@baylibre.com,
	aou@eecs.berkeley.edu, arnd@arndb.de, bhelgaas@google.com,
	conor+dt@kernel.org, guoren@kernel.org, inochiama@outlook.com,
	krzk+dt@kernel.org, lee@kernel.org, lpieralisi@kernel.org,
	manivannan.sadhasivam@linaro.org, palmer@dabbelt.com,
	paul.walmsley@sifive.com, pbrobinson@gmail.com, robh@kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pci@vger.kernel.org, linux-riscv@lists.infradead.org,
	chao.wei@sophgo.com, xiaoguang.xing@sophgo.com,
	fengchun.li@sophgo.com
Subject: Re: [PATCH 2/5] PCI: sg2042: Add Sophgo SG2042 PCIe driver
Date: Mon, 2 Dec 2024 09:13:00 +0800	[thread overview]
Message-ID: <MAXPR01MB398467232518EDC15113B93BFE352@MAXPR01MB3984.INDPRD01.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20241129195000.GA2770247@bhelgaas>


On 2024/11/30 3:50, Bjorn Helgaas wrote:
> On Fri, Nov 29, 2024 at 05:51:39PM +0800, Chen Wang wrote:
>> On 2024/11/13 5:20, Bjorn Helgaas wrote:
>>> On Mon, Nov 11, 2024 at 01:59:56PM +0800, Chen Wang wrote:
>>>> From: Chen Wang <unicorn_wang@outlook.com>
>>>>
>>>> Add support for PCIe controller in SG2042 SoC. The controller
>>>> uses the Cadence PCIe core programmed by pcie-cadence*.c. The
>>>> PCIe controller will work in host mode only.
>>>> +++ b/drivers/pci/controller/cadence/Kconfig
>>>> @@ -67,4 +67,15 @@ config PCI_J721E_EP
>>>>    	  Say Y here if you want to support the TI J721E PCIe platform
>>>>    	  controller in endpoint mode. TI J721E PCIe controller uses Cadence PCIe
>>>>    	  core.
>>>> +
>>>> +config PCIE_SG2042
>>>> +	bool "Sophgo SG2042 PCIe controller (host mode)"
>>>> +	depends on ARCH_SOPHGO || COMPILE_TEST
>>>> +	depends on OF
>>>> +	select PCIE_CADENCE_HOST
>>>> +	help
>>>> +	  Say Y here if you want to support the Sophgo SG2042 PCIe platform
>>>> +	  controller in host mode. Sophgo SG2042 PCIe controller uses Cadence
>>>> +	  PCIe core.
>>> Reorder to keep these menu items in alphabetical order by vendor.
>> Sorry, I don't understand your question. I think the menu items in this
>> Kconfig file are already sorted alphabetically.
> Here's what menuconfig looks like after this patch:
>
>    [*] Cadence platform PCIe controller (host mode)
>    [*] Cadence platform PCIe controller (endpoint mode)
>    [*] TI J721E PCIe controller (host mode)
>    [*] TI J721E PCIe controller (endpoint mode)
>    [ ] Sophgo SG2042 PCIe controller (host mode) (NEW)
>
> "Sophgo" sorts *before* "TI".

I see what you mean. I thought we just had to make sure the item IDs in 
the Kconfig file were in alphabetical order.

I will make changes in the next version based on your suggestions.

>>>> +	if (pcie->link_id == 1) {
>>>> +		regmap_write(pcie->syscon, REG_LINK1_MSI_ADDR_LOW,
>>>> +			     lower_32_bits(pcie->msi_phys));
>>>> +		regmap_write(pcie->syscon, REG_LINK1_MSI_ADDR_HIGH,
>>>> +			     upper_32_bits(pcie->msi_phys));
>>>> +
>>>> +		regmap_read(pcie->syscon, REG_LINK1_MSI_ADDR_SIZE, &value);
>>>> +		value = (value & REG_LINK1_MSI_ADDR_SIZE_MASK) | MAX_MSI_IRQS;
>>>> +		regmap_write(pcie->syscon, REG_LINK1_MSI_ADDR_SIZE, value);
>>>> +	} else {
>>>> +		regmap_write(pcie->syscon, REG_LINK0_MSI_ADDR_LOW,
>>>> +			     lower_32_bits(pcie->msi_phys));
>>>> +		regmap_write(pcie->syscon, REG_LINK0_MSI_ADDR_HIGH,
>>>> +			     upper_32_bits(pcie->msi_phys));
>>>> +
>>>> +		regmap_read(pcie->syscon, REG_LINK0_MSI_ADDR_SIZE, &value);
>>>> +		value = (value & REG_LINK0_MSI_ADDR_SIZE_MASK) | (MAX_MSI_IRQS << 16);
>>>> +		regmap_write(pcie->syscon, REG_LINK0_MSI_ADDR_SIZE, value);
>>>> +	}
>>> Lot of pcie->link_id checking going on here.  Consider saving these
>>> offsets in the struct sg2042_pcie so you don't need to test
>>> everywhere.
>> Actually, there are not many places in the code to check link_id. If to add
>> storage information in struct sg2042_pcie, at least four  u32 are needed.
>> And this logic will only be called one time in the probe. So I think it is
>> better to keep the current method. What do you think?
> 1) I don't think "link_id" is a very good name since it appears to
> refer to one of two PCIe Root Ports.  mvebu uses "marvell,pcie-port"
> which looks like a similar usage, although unnecessarily
> Marvell-specific.  And arch/arm/boot/dts/marvell/armada-370-db.dts has
> separate stanzas for two Root Ports, without needing a property to
> distinguish them, which would be even better.  I'm not sure why
> arch/arm/boot/dts/marvell/armada-370.dtsi needs "marvell,pcie-port"
> even though it also has separate stanzas.
>
> 2) I think checking pcie->link_id is likely to be harder to maintain
> in the future, e.g., if a new chip adds more Root Ports, you'll have
> to touch each use.
>
> Bjorn

Thanks for your input. I looked at the Marvell solution you recommended. 
It seems that it is a relatively complex IP design to support mvebu, 
which can flexibly support the export of 1 to 4 variable root ports.
The Cadence IP used by SG2042 is much simpler, and it is fixed to export 
up to two root ports. So I plan to implement it in a simple way. 
Changing "link_id" to "pcie-port" will look better. The writing of link 
actually refers to the terminology in the Cadence manual, which is 
actually the concept of port.

By the way, there is no demand for scalability at present, because it is 
said that Sophgo currently only uses Cadence IP for the SG2042 SoC, and 
subsequent products should switch to solutions from other suppliers.

Any question please let me know.

Regards,

Chen



  reply	other threads:[~2024-12-02  1:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-11  5:59 [PATCH 0/5] Add PCIe support to Sophgo SG2042 SoC Chen Wang
2024-11-11  5:59 ` [PATCH 1/5] dt-bindings: pci: Add Sophgo SG2042 PCIe host Chen Wang
2024-11-12 15:59   ` Rob Herring
2024-11-14  2:51     ` Chen Wang
2024-11-11  5:59 ` [PATCH 2/5] PCI: sg2042: Add Sophgo SG2042 PCIe driver Chen Wang
2024-11-11 11:29   ` kernel test robot
2024-11-12 21:20   ` Bjorn Helgaas
2024-11-29  9:51     ` Chen Wang
2024-11-29 19:50       ` Bjorn Helgaas
2024-12-02  1:13         ` Chen Wang [this message]
2024-11-11  6:00 ` [PATCH 3/5] dt-bindings: mfd: syscon: Add sg2042 pcie ctrl compatible Chen Wang
2024-11-12 15:59   ` Rob Herring (Arm)
2024-11-11  6:00 ` [PATCH 4/5] riscv: sophgo: dts: add pcie controllers for SG2042 Chen Wang
2024-11-11  6:00 ` [PATCH 5/5] riscv: sophgo: dts: enable pcie for PioneerBox Chen Wang

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=MAXPR01MB398467232518EDC15113B93BFE352@MAXPR01MB3984.INDPRD01.PROD.OUTLOOK.COM \
    --to=unicorn_wang@outlook.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=arnd@arndb.de \
    --cc=bhelgaas@google.com \
    --cc=chao.wei@sophgo.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=fengchun.li@sophgo.com \
    --cc=guoren@kernel.org \
    --cc=helgaas@kernel.org \
    --cc=inochiama@outlook.com \
    --cc=krzk+dt@kernel.org \
    --cc=kw@linux.com \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=lpieralisi@kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=pbrobinson@gmail.com \
    --cc=robh@kernel.org \
    --cc=u.kleine-koenig@baylibre.com \
    --cc=xiaoguang.xing@sophgo.com \
    /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

all inboxes | Powered by JetHome®