mbox series

[v3,0/6] rockchip DWC PCIe improvements

Message ID 20231027145422.40265-1-nks@flawful.org
Headers show
Series rockchip DWC PCIe improvements | expand

Message

Niklas Cassel Oct. 27, 2023, 2:54 p.m. UTC
From: Niklas Cassel <niklas.cassel@wdc.com>

Hello,

This series adds the iATU region to all rockchip DWC PCIe compatibles,
such that the driver can properly runtime detect all inbound iATU and
outbound iATUs. (The actual number of inbound/outbound iATUs differ,
but can be up to 16 inbound iATUs and 16 outbound iATUs.)

It also adds the interrupts for the eDMA on rk3588, such that the embedded
DMA controller is properly detected, and can be used to offload data
transfers.

We also remove unused device tree properties num-ib-windows/num-ob-windows
that are unsed by the code. (Instead the driver depends on the iATU region
being specified in the device tree.)


Changes since v2:
-Added patch to drop unused properties num-{ib,ob}-windows.
-Added patch that adds atu reg also for rk3568.
-Make atu reg mandatory (since both rk3568 and rk3588 defines it).
-Include eDMA region in iATU region, as suggested by snps,dw-pcie.yaml.


Kind regards,
Niklas

Niklas Cassel (6):
  dt-bindings: PCI: dwc: rockchip: Add mandatory atu reg
  dt-bindings: PCI: dwc: rockchip: Add optional dma interrupts
  arm64: dts: rockchip: drop unused properties num-{ib,ob}-windows
  arm64: dts: rockchip: add missing mandatory rk3568 PCIe atu reg
  arm64: dts: rockchip: add missing mandatory rk3588 PCIe atu reg
  arm64: dts: rockchip: add missing rk3588 PCIe eDMA interrupts

 .../bindings/pci/rockchip-dw-pcie.yaml        | 29 +++++++++++++++---
 .../boot/dts/rockchip/rk3568-nanopi-r5s.dts   |  2 --
 arch/arm64/boot/dts/rockchip/rk3568.dtsi      | 18 +++++------
 arch/arm64/boot/dts/rockchip/rk356x.dtsi      |  9 +++---
 arch/arm64/boot/dts/rockchip/rk3588.dtsi      | 30 ++++++++++++-------
 arch/arm64/boot/dts/rockchip/rk3588s.dtsi     | 14 +++++----
 6 files changed, 64 insertions(+), 38 deletions(-)

Comments

Niklas Cassel Oct. 28, 2023, 12:11 p.m. UTC | #1
On Fri, Oct 27, 2023 at 12:03:15PM -0500, Rob Herring wrote:
> On Fri, Oct 27, 2023 at 11:15 AM Niklas Cassel <Niklas.Cassel@wdc.com> wrote:
> >
> > Hello Rob,
> >
> > On Fri, Oct 27, 2023 at 10:58:28AM -0500, Rob Herring wrote:
> > > On Fri, Oct 27, 2023 at 9:56 AM Niklas Cassel <nks@flawful.org> wrote:
> > > >
> > > > From: Niklas Cassel <niklas.cassel@wdc.com>
> > > >
> > > > Even though rockchip-dw-pcie.yaml inherits snps,dw-pcie.yaml
> > > > using:
> > > >
> > > > allOf:
> > > >   - $ref: /schemas/pci/snps,dw-pcie.yaml#
> > > >
> > > > and snps,dw-pcie.yaml does have the atu reg defined, in order to be
> > > > able to use this reg, while still making sure 'make CHECK_DTBS=y'
> > > > pass, we need to add this reg to rockchip-dw-pcie.yaml.
> > > >
> > > > All compatible strings (rockchip,rk3568-pcie and rockchip,rk3588-pcie)
> > > > should have this reg.
> > > >
> > > > The regs in the example are updated to actually match pcie3x2 on rk3568.
> > >
> > > Breaking compatibility on these platforms is okay because ...?
> >
> > I don't follow, could you please elaborate?
> 
> A DT which was valid without 'atu' region is now not valid with this
> change. If I'm reading this schema with the change, then not having
> 'atu' is an error and the OS can treat it as an error. If it does,
> then it wouldn't work with existing DTs. You cannot add new required
> properties or required entries.
> 
> If you can say no users of the affected platforms care (e.g. only you
> have a board) or the binding is not yet in use, then it's fine. But
> you have to state that justification. I suspect that is not the case
> here.

FWIW, I had "atu" as optional in v2 of this series.

Since I made the effort in v3 to add "atu" to all the existing users of the
rockchip binding, I thought that marking it required in the rockchip binding
would help ensure that any future rockchip platform does not forget to add
"atu".

I know that DT has to be backwards compatible, but the device driver works
fine with a DT that lacks "atu" (even though you will not be able to detect
all iATUs), so an old DT would still work.

But yes, running make CHECK_DTBS=y with the new binding, would not pass for
an old DT.

I get your point, you can never add a required property or entries to an
existing compatible (this is in use).


If we look at snps,dw-pcie.yaml, "atu" is optional, so that correlates to
the device driver being able to work without "atu" specified.

Since the rockchip driver doesn't get "atu" itself, but relies on the common
code to get it, it should obviously be optional also for the rockchip binding.

I guess my problem is that I just want to inherit the entry from the common
binding...

Is there no DT keyword to extend an existing binding, so that you inherit all
the properties/entries from that common binding, while still allowing you to
define (or overload) additional properties/entries?

Even if there is no way to inherit all properties/entries from a common binding,
it would be nice to be able to inherit a specific property/entry using a
"inherit" keyword, such that you get the same definition (optional/required) as
the parent binding.


Kind regards,
Niklas
Rob Herring Oct. 30, 2023, 5:39 p.m. UTC | #2
On Sat, Oct 28, 2023 at 12:11:02PM +0000, Niklas Cassel wrote:
> On Fri, Oct 27, 2023 at 12:03:15PM -0500, Rob Herring wrote:
> > On Fri, Oct 27, 2023 at 11:15 AM Niklas Cassel <Niklas.Cassel@wdc.com> wrote:
> > >
> > > Hello Rob,
> > >
> > > On Fri, Oct 27, 2023 at 10:58:28AM -0500, Rob Herring wrote:
> > > > On Fri, Oct 27, 2023 at 9:56 AM Niklas Cassel <nks@flawful.org> wrote:
> > > > >
> > > > > From: Niklas Cassel <niklas.cassel@wdc.com>
> > > > >
> > > > > Even though rockchip-dw-pcie.yaml inherits snps,dw-pcie.yaml
> > > > > using:
> > > > >
> > > > > allOf:
> > > > >   - $ref: /schemas/pci/snps,dw-pcie.yaml#
> > > > >
> > > > > and snps,dw-pcie.yaml does have the atu reg defined, in order to be
> > > > > able to use this reg, while still making sure 'make CHECK_DTBS=y'
> > > > > pass, we need to add this reg to rockchip-dw-pcie.yaml.
> > > > >
> > > > > All compatible strings (rockchip,rk3568-pcie and rockchip,rk3588-pcie)
> > > > > should have this reg.
> > > > >
> > > > > The regs in the example are updated to actually match pcie3x2 on rk3568.
> > > >
> > > > Breaking compatibility on these platforms is okay because ...?
> > >
> > > I don't follow, could you please elaborate?
> > 
> > A DT which was valid without 'atu' region is now not valid with this
> > change. If I'm reading this schema with the change, then not having
> > 'atu' is an error and the OS can treat it as an error. If it does,
> > then it wouldn't work with existing DTs. You cannot add new required
> > properties or required entries.
> > 
> > If you can say no users of the affected platforms care (e.g. only you
> > have a board) or the binding is not yet in use, then it's fine. But
> > you have to state that justification. I suspect that is not the case
> > here.
> 
> FWIW, I had "atu" as optional in v2 of this series.

Right, that was "correct".

> Since I made the effort in v3 to add "atu" to all the existing users of the
> rockchip binding, I thought that marking it required in the rockchip binding
> would help ensure that any future rockchip platform does not forget to add
> "atu".

It would nice to test both this kind of thing and compatibility. The 
only way I know of to do that is with 'deprecated' keyword which still 
needs support in dtschema to remove all the deprecated schemas (which 
would then cause warnings). That's not hard, I just haven't done it 
yet.

To use 'deprecated' here, you could do something like this:

items:
  - ...
  - ...
  - ...
  - ...
allOf:
  - deprecated: true
    minItems: 3

However, that would also not work because we implicitly add 'minItems: 
4', but that could be fixed.

For 'required', we'd need a 'oneOf' with 2 lists of required properties 
which is kind of ugly.


> I know that DT has to be backwards compatible, but the device driver works
> fine with a DT that lacks "atu" (even though you will not be able to detect
> all iATUs), so an old DT would still work.
> 
> But yes, running make CHECK_DTBS=y with the new binding, would not pass for
> an old DT.
> 
> I get your point, you can never add a required property or entries to an
> existing compatible (this is in use).

We may test for this at some point. I want to be able to test for ABI 
breaks rather than catch them in reviews. Right now I'm just kicking 
around ideas in my head on how to do that...


> If we look at snps,dw-pcie.yaml, "atu" is optional, so that correlates to
> the device driver being able to work without "atu" specified.
> 
> Since the rockchip driver doesn't get "atu" itself, but relies on the common
> code to get it, it should obviously be optional also for the rockchip binding.

The way this binding works is snps,dw-pcie.yaml defines the set of 
common properties. The SoC specific binding still has to define which 
ones it uses. It's some duplication, but there's not really any way 
around it on these licensed IPs unless the bindings are complete up 
front.

> I guess my problem is that I just want to inherit the entry from the common
> binding...
> 
> Is there no DT keyword to extend an existing binding, so that you inherit all
> the properties/entries from that common binding, while still allowing you to
> define (or overload) additional properties/entries?
> 
> Even if there is no way to inherit all properties/entries from a common binding,
> it would be nice to be able to inherit a specific property/entry using a
> "inherit" keyword, such that you get the same definition (optional/required) as
> the parent binding.

The only way to inherit is via a $ref. We can only add more constraints 
to a parent/referenced binding.

You could have a $ref to 
"snps,dw-pcie.yaml#/properties/reg-names/items/oneOf/3" to get the 4th 
reg-name in the list of common properties. I wouldn't recommend doing 
that because I think it will be fragile and difficult to maintain.

Rob
Rob Herring Oct. 30, 2023, 5:40 p.m. UTC | #3
On Fri, 27 Oct 2023 16:54:14 +0200, Niklas Cassel wrote:
> From: Niklas Cassel <niklas.cassel@wdc.com>
> 
> Even though rockchip-dw-pcie.yaml inherits snps,dw-pcie.yaml
> using:
> 
> allOf:
>   - $ref: /schemas/pci/snps,dw-pcie.yaml#
> 
> and snps,dw-pcie.yaml does have the dma interrupts defined, in order to be
> able to use these interrupts, while still making sure 'make CHECK_DTBS=y'
> pass, we need to add these interrupts to rockchip-dw-pcie.yaml.
> 
> These dedicated interrupts for the eDMA are not always wired to all the
> PCIe controllers on the same SoC. In other words, even for a specific
> compatible, e.g. rockchip,rk3588-pcie, these dedicated eDMA interrupts
> may or may not be wired.
> 
> Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
> ---
>  .../bindings/pci/rockchip-dw-pcie.yaml         | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 

Reviewed-by: Rob Herring <robh@kernel.org>
Serge Semin Oct. 31, 2023, 1:10 a.m. UTC | #4
On Fri, Oct 27, 2023 at 04:54:14PM +0200, Niklas Cassel wrote:
> From: Niklas Cassel <niklas.cassel@wdc.com>
> 
> Even though rockchip-dw-pcie.yaml inherits snps,dw-pcie.yaml
> using:
> 
> allOf:
>   - $ref: /schemas/pci/snps,dw-pcie.yaml#
> 
> and snps,dw-pcie.yaml does have the dma interrupts defined, in order to be
> able to use these interrupts, while still making sure 'make CHECK_DTBS=y'
> pass, we need to add these interrupts to rockchip-dw-pcie.yaml.
> 
> These dedicated interrupts for the eDMA are not always wired to all the
> PCIe controllers on the same SoC. In other words, even for a specific
> compatible, e.g. rockchip,rk3588-pcie, these dedicated eDMA interrupts
> may or may not be wired.
> 
> Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
> ---
>  .../bindings/pci/rockchip-dw-pcie.yaml         | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/pci/rockchip-dw-pcie.yaml b/Documentation/devicetree/bindings/pci/rockchip-dw-pcie.yaml
> index 6ca87ff4ae20..7ad6e1283784 100644
> --- a/Documentation/devicetree/bindings/pci/rockchip-dw-pcie.yaml
> +++ b/Documentation/devicetree/bindings/pci/rockchip-dw-pcie.yaml
> @@ -63,6 +63,7 @@ properties:
>        - const: pipe
>  
>    interrupts:
> +    minItems: 5
>      items:
>        - description:
>            Combined system interrupt, which is used to signal the following
> @@ -86,14 +87,31 @@ properties:
>            interrupts - aer_rc_err, aer_rc_err_msi, rx_cpl_timeout,
>            tx_cpl_timeout, cor_err_sent, nf_err_sent, f_err_sent, cor_err_rx,
>            nf_err_rx, f_err_rx, radm_qoverflow
> +      - description:
> +          Indicates that the eDMA Tx/Rx transfer is complete or that an
> +          error has occurred on the corresponding channel.
> +      - description:
> +          Indicates that the eDMA Tx/Rx transfer is complete or that an
> +          error has occurred on the corresponding channel.
> +      - description:
> +          Indicates that the eDMA Tx/Rx transfer is complete or that an
> +          error has occurred on the corresponding channel.
> +      - description:
> +          Indicates that the eDMA Tx/Rx transfer is complete or that an
> +          error has occurred on the corresponding channel.
>  
>    interrupt-names:
> +    minItems: 5
>      items:
>        - const: sys
>        - const: pmc
>        - const: msg
>        - const: legacy
>        - const: err

> +      - const: dma0
> +      - const: dma1
> +      - const: dma2
> +      - const: dma3

No. As you said yourself here
https://lore.kernel.org/linux-pci/ZTl1ZsHvk3DDHWsm@x1-carbon/
and in the response to my last message in v2, which for some reason
hasn't got to the lore archive:

On Fri, Oct 27, 2023 at 05:51:14PM +0200, Niklas Cassel wrote:
> However, e.g. rk3568 only has one channel for reads and one for writes.
> (Now this SoC doesn't have dedicated IRQs for the eDMA, but let's pretend
> that it did.)
> 
> So for rk3568, it would then instead be:
> dma0: wr0
> dma1: rd0
> dma2: <unused>
> dma3: <unused>

rk3568 doesn't have IRQs supplied in a normal way, as separate
signals.  Instead they are combined in the 'sys' IRQ. So you should
define the IRQs constraint being device-specific by using for example
the "allOf: if-else" pattern.

-Serge(y)

>  
>    legacy-interrupt-controller:
>      description: Interrupt controller node for handling legacy PCI interrupts.
> -- 
> 2.41.0
>