All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: "Pali Rohár" <pali@kernel.org>
Cc: "Marek Behún" <kabel@kernel.org>,
	u-boot@lists.denx.de, "Marek Behún" <marek.behun@nic.cz>
Subject: Re: [PATCH u-boot-marvell 02/10] arm: mvebu: a38x: serdes: Move non-serdes PCIe code to pci_mvebu.c
Date: Mon, 29 Nov 2021 13:30:45 +0100	[thread overview]
Message-ID: <b210cfac-c130-1d43-205c-2c16d3bc8000@denx.de> (raw)
In-Reply-To: <20211129114701.evkol44t6l3rvdpf@pali>

Hi Pali,

On 11/29/21 12:47, Pali Rohár wrote:
> Hello!
> 
> On Monday 29 November 2021 10:22:58 Stefan Roese wrote:
>> On 11/29/21 10:06, Pali Rohár wrote:
>>
>> <snip>
>>
>>>>> After this DTS change, pci-mvebu.c will just replace value of current
>>>>> number of lanes (which is set to 4 by serdes code) to value from DTS,
>>>>> which is 4. Therefore there should be no change.
>>>>>
>>>>> Could you test whole patch series with above DTS change if it works
>>>>> properly on Theadorable board?
>>>>
>>>> Yes, I don't see any issues with this patchset applied plus this DT
>>>> patch on theadorable. The PCIe links are up and with the correct width.
>>>>
>>>> What I'm wondering is, when exactly does the PCIe RP start the link
>>>> establishment. In my case with AXP this is still in the AXP serdes code
>>>> of course. But in the A38x code, it should be in the PCIe controller
>>>> driver now AFAIU. I see that you configure the link width in the
>>>> controller and do some other configuration (address windows etc), but
>>>> at the end you "simply" wait for the link to come up via
>>>> mvebu_pcie_wait_for_link(). I would have expected here some special
>>>> command (config bit?) to the PCIe controller to start the link
>>>> establishment. So when exactly does the A38x start this action?
>>>
>>> That is interesting question... While I'm reading it again, I really do
>>> not know. Because you are right that mvebu_pcie_wait_for_link() is just
>>> waiting for a link and it "magically" comes up. I have tested it on A385
>>> and it is stable with different Compex Atheros cards which caused issues
>>> in past also on A3720.
>>
>> I would prefer, to fully understand when exactly the link establishment
>> is started. Since this is crucial for the setup of the controller that
>> needs to be done *before* the link starts to come up.
> 
> I try to dig as more information as possible and finally I find out that
> important information is available also in now removed, but originally
> public A38x documentation. Thankfully web archive has copy of it:
> 
> https://web.archive.org/web/20200420191927/https://www.marvell.com/content/dam/marvell/en/public-collateral/embedded-processors/marvell-embedded-processors-armada-38x-functional-specifications-2015-11.pdf
> 
>    17.3 Link Initialization
> 
>    In case the initialization fails and no link is established, the PHY
>    will keep on trying to initiate a link forever unless the port is
>    disabled. As long as the port is enabled, the PHY will continue trying
>    to establish a link; once the PHY identifies that a device is
>    connected to it, a link will be established.
> 
> PCIe port is enabled by bits in SoC Control 1 Register, which is done in
> U-Boot SerDes initialization code. This is IIRC SoC specific, and reason
> why every Armada SoC has own SerDes init code.
> 
> And looks like that due to "the PHY will keep on trying to initiate a
> link forever", the PCIe link comes up when pci-mvebu.c sets all required
> registers to correct values. E.g. set correct mode (RC vs endpoint),
> link width (x1 vs x4), etc...
> 
>> Could you perhaps try to remove some of the register configurations in
>> the MVEBU PCIe driver to see, if the link establishment relies on this
>> register to be written to (e.g. PCI_EXP_LNKCAP)?
> 
> First port on A385 is by default set to X4 width, other ports to X1
> width. Without updating LNKCAP to correct width, card in first PCIe port
> never initialize. And cards in other ports are initialized even before
> pci-mvebu.c starts configuration.

So the PCIe ports are now trying to establish the links, even when the
correct configuration is not yet done. This might work but sound far
from perfect to me IMHO.

> So seems that this matches above behavior. SerDes init code enabled all
> PCIe ports. Ports which are using default configuration (second, third)
> are immediately initialized and link is established. Port which requires
> additional configuration (first port, for switching from X4 to X1) just
> stay in that "keep on trying to initiate a link forever" state until
> pci-mvebu starts and set PCI_EXP_LNKCAP register, after which PHY try X1
> width and success. And seems that this is the reason why 100ms timeout
> is needed... As at this stage when pci-mvebu.c switches X4 to X1, init
> timeout as defined in PCIe spec (that 100ms) starts ticking. For other
> ports it starts ticking when serdes init code enables ports.
> 
> 
> I have looked into all PCIe registers which are present in functional
> spec, but it looks like that there is no pci-mvebu register which can
> turn of LTSSM and link training, like it is in other PCIe controllers.
> It looks like that only SoC-specific port enable bits are there.
> 
> It is starting to be bigger mess as before... Any suggestion how to
> continue with it?
> 
> We cannot (easily) move that code which flips PCIe bits in SoC Control 1
> Register from SerDes init code to pci-mvebu.c as this is outside of
> pci-mvebu.c address space and also it is different on every SoC.
> pci-mvebu.c registers are same on all Marvell SoCs, starting from Orion
> up to the A39x.

One idea would be, to use a "reset-controller" driver on the Armada
platforms, that is capable to at least reset and release the PCIe ports.
Via the SoC Control 1 reg on A38x and via the SoC Control Register
on AXP.

I just looked into some Linux PCIe DT bindings and found e.g. this in
the mediatek spec:

Documentation/devicetree/bindings/pci/mediatek-pcie.txt
...
Required properties for MT7623/MT2701:
...
- resets: Must contain an entry for each entry in reset-names.
   See ../reset/reset.txt for details.
- reset-names: Must be "pcie-rst0", "pcie-rst1", "pcie-rstN".. based on the
   number of root ports.
...
		resets = <&hifsys MT2701_HIFSYS_PCIE0_RST>,
			 <&hifsys MT2701_HIFSYS_PCIE1_RST>,
			 <&hifsys MT2701_HIFSYS_PCIE2_RST>;
		reset-names = "pcie-rst0", "pcie-rst1", "pcie-rst2";
		phys = <&pcie0_phy PHY_TYPE_PCIE>, <&pcie1_phy PHY_TYPE_PCIE>,
		       <&pcie2_phy PHY_TYPE_PCIE>;
		phy-names = "pcie-phy0", "pcie-phy1", "pcie-phy2";


And make sure in the serdes code keeps (or actively sets?) these PCIe
ports into the reset state. The PCIe driver would then release the ports
out of reset after their configuration.

Or is some other serdes code missing in between "get PCIe port out of
reset" and the MVEBU PCIe driver taking over the control?

What do you think? I might be missing something here.

Thanks,
Stefan

  reply	other threads:[~2021-11-29 12:31 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-11 15:35 [PATCH u-boot-marvell 00/10] PCI mvebu and aardvark changes Marek Behún
2021-11-11 15:35 ` [PATCH u-boot-marvell 01/10] pci: pci_mvebu: Wait 100ms for Link Up in mvebu_pcie_probe() Marek Behún
2021-11-12 13:59   ` Stefan Roese
2021-11-12 15:44     ` Pali Rohár
2021-11-12 16:07       ` Stefan Roese
2021-11-18 18:06     ` Pali Rohár
2021-11-11 15:35 ` [PATCH u-boot-marvell 02/10] arm: mvebu: a38x: serdes: Move non-serdes PCIe code to pci_mvebu.c Marek Behún
2021-11-12 14:01   ` Stefan Roese
2021-11-18 18:01     ` Pali Rohár
2021-11-19  6:55       ` Stefan Roese
2021-11-23 15:59         ` Pali Rohár
2021-11-29  7:46           ` Stefan Roese
2021-11-29  9:06             ` Pali Rohár
2021-11-29  9:22               ` Stefan Roese
2021-11-29 11:47                 ` Pali Rohár
2021-11-29 12:30                   ` Stefan Roese [this message]
2021-11-29 13:27                     ` Pali Rohár
2021-11-29 14:28                       ` Pali Rohár
2021-11-29 16:07                         ` Stefan Roese
2021-11-29 17:09                           ` Marek Behún
2021-12-10 11:07                             ` Pali Rohár
2021-12-10 14:23                           ` Pali Rohár
2021-12-13  7:36                             ` Stefan Roese
2021-12-13 10:28                               ` Pali Rohár
2021-11-11 15:35 ` [PATCH u-boot-marvell 03/10] pci: pci_mvebu: Move setup for BAR[0] where other BARs are setup Marek Behún
2021-11-12 14:02   ` Stefan Roese
2021-12-21  8:22   ` Stefan Roese
2021-11-11 15:35 ` [PATCH u-boot-marvell 04/10] pci: pci_mvebu: Replace MBUS_PCI_*_SIZE by resource_size() Marek Behún
2021-11-12 14:03   ` Stefan Roese
2021-12-21  8:23   ` Stefan Roese
2021-11-11 15:35 ` [PATCH u-boot-marvell 05/10] pci: pci_mvebu, pci_aardvark: Fix size of configuration cache Marek Behún
2021-11-12 14:04   ` Stefan Roese
2021-12-15 10:57   ` Stefan Roese
2021-11-11 15:35 ` [PATCH u-boot-marvell 06/10] pci: pci_mvebu: Do not allow setting ROM BAR on PCI Bridge Marek Behún
2021-11-12 14:05   ` Stefan Roese
2021-12-15 10:57   ` Stefan Roese
2021-11-11 15:35 ` [PATCH u-boot-marvell 07/10] pci: pci_mvebu: Fix PCIe MEM and IO resources assignment and mbus mapping Marek Behún
2021-11-12 14:18   ` Stefan Roese
2021-11-18 17:46     ` Pali Rohár
2021-11-19  6:27       ` Stefan Roese
2021-11-11 15:35 ` [PATCH u-boot-marvell 08/10] pci: pci_mvebu: Remove unused DECLARE_GLOBAL_DATA_PTR Marek Behún
2021-11-12 14:19   ` Stefan Roese
2021-12-21  8:23   ` Stefan Roese
2021-11-11 15:35 ` [PATCH u-boot-marvell 09/10] arm: a37xx: pci: Do not allow setting ROM BAR on PCI Bridge Marek Behún
2021-11-12 14:19   ` Stefan Roese
2021-11-11 15:35 ` [PATCH u-boot-marvell 10/10] arm: mvebu: turris_mox: Remove extra newline after module topology Marek Behún
2021-11-12 14:20   ` Stefan Roese
2021-12-21  8:23   ` Stefan Roese
2021-12-12 11:23 ` [PATCH u-boot-marvell 00/10] PCI mvebu and aardvark changes Pali Rohár
2021-12-13  7:41   ` Stefan Roese
2021-12-13 10:27     ` Pali Rohár
2021-12-15  8:10       ` Stefan Roese
2021-12-16 10:28         ` Pali Rohár
2021-12-18 13:53           ` Stefan Roese
2021-12-20 13:30             ` Pali Rohár
2021-12-21  8:19               ` Stefan Roese
2021-12-21 10:57                 ` Pali Rohár

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=b210cfac-c130-1d43-205c-2c16d3bc8000@denx.de \
    --to=sr@denx.de \
    --cc=kabel@kernel.org \
    --cc=marek.behun@nic.cz \
    --cc=pali@kernel.org \
    --cc=u-boot@lists.denx.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 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.