lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a25ea57b-4529-4a4c-9e0b-ccd85b0457d6@ti.com>
Date: Wed, 17 Jan 2024 16:17:59 +0530
From: Siddharth Vadapalli <s-vadapalli@...com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
CC: <bhelgaas@...gle.com>, <lpieralisi@...nel.org>, <kw@...ux.com>,
        <robh@...nel.org>, <krzysztof.kozlowski+dt@...aro.org>,
        <conor+dt@...nel.org>, <linux-pci@...r.kernel.org>,
        <devicetree@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <linux-arm-kernel@...ts.infradead.org>, <vigneshr@...com>,
        <afd@...com>, <srk@...com>, <s-vadapalli@...com>
Subject: Re: [PATCH 1/3] dt-bindings: PCI: ti,j721e-pci-*: Fix check for
 num-lanes

Hello Krzysztof,

On 17/01/24 16:04, Krzysztof Kozlowski wrote:
> On 17/01/2024 11:25, Siddharth Vadapalli wrote:
>> The existing implementation for validating the "num-lanes" property
>> based on the compatible(s) doesn't enforce it. Fix it by updating the
>> checks to handle both single-compatible and multi-compatible cases.
>>
>> Fixes: b3ba0f6e82cb ("dt-bindings: PCI: ti,j721e-pci-*: Add checks for num-lanes")
>> Fixes: adc14d44d7cb ("dt-bindings: PCI: ti,j721e-pci-*: Add j784s4-pci-* compatible strings")
>> Signed-off-by: Siddharth Vadapalli <s-vadapalli@...com>
>> ---
>>  .../bindings/pci/ti,j721e-pci-ep.yaml         | 26 ++++++++++++++-----
>>  .../bindings/pci/ti,j721e-pci-host.yaml       | 26 ++++++++++++++-----
>>  2 files changed, 38 insertions(+), 14 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/pci/ti,j721e-pci-ep.yaml b/Documentation/devicetree/bindings/pci/ti,j721e-pci-ep.yaml
>> index 97f2579ea908..278e0892f8ac 100644
>> --- a/Documentation/devicetree/bindings/pci/ti,j721e-pci-ep.yaml
>> +++ b/Documentation/devicetree/bindings/pci/ti,j721e-pci-ep.yaml
>> @@ -68,8 +68,9 @@ allOf:
>>    - if:
>>        properties:
>>          compatible:
> 
> Missing contains:, instead of your change.

I did try the "contains" approach before determining that the implementation in
this patch is more suitable. Please consider the following:

For AM64 SoC the primary compatible is "ti,am64-pcie-ep" and fallback compatible
is "ti,j721e-pcie-ep". For J7200 SoC the primary compatible is
"ti,j7200-pcie-ep" while the fallback compatible is again "ti,j721e-pcie-ep".

Therefore, the device-tree nodes for AM64 and J7200 look like:

AM64:
    compatible = "ti,am64-pcie-ep", "ti,j721e-pcie-ep";
    ...
    num-lanes = 1;

J7200:
    compatible = "ti,j7200-pcie-ep", "ti,j721e-pcie-ep";
    ...
    num-lanes = 4;

This implies that when the check for "num-lanes" is performed on the device-tree
node for PCIe in J7200, the fallback compatible of "ti,j721e-pcie-ep" within the
AM64's "compatible: contains:" check will match the schema and it will check the
existing "num-lanes" being described as "const: 1" against the value in J7200's
PCIe node resulting in a warning. Therefore, using "contains" will result in
errors if the check has to be performed for device-tree nodes with fallback
compatibles. The "items" based approach I have used in this patch ensures that
the schema matches *only* when both the primary and fallback compatible are
present in the device-tree node.

> 
>> -          enum:
>> -            - ti,am64-pcie-ep
>> +          items:
>> +            - const: ti,am64-pcie-ep
>> +            - const: ti,j721e-pcie-ep
> 
>>      then:
>>        properties:
>>          num-lanes:
>> @@ -78,9 +79,9 @@ allOf:
>>    - if:
>>        properties:
>>          compatible:
>> -          enum:
>> -            - ti,j7200-pcie-ep
>> -            - ti,j721e-pcie-ep
>> +          items:
>> +            - const: ti,j7200-pcie-ep
>> +            - const: ti,j721e-pcie-ep
> 
> "Ditto

Same explanation as above.

> 
>>      then:
>>        properties:
>>          num-lanes:
>> @@ -90,8 +91,19 @@ allOf:
>>    - if:
>>        properties:
>>          compatible:
>> -          enum:
>> -            - ti,j784s4-pcie-ep
>> +          items:
>> +            - const: ti,j721e-pcie-ep
>> +    then:
>> +      properties:
>> +        num-lanes:
>> +          minimum: 1
>> +          maximum: 4
>> +
>> +  - if:
>> +      properties:
>> +        compatible:
>> +          items:
>> +            - const: ti,j784s4-pcie-ep
> 
> Why? Previous code was correct.

Though I used "patience diff", for some reason the addition of
"ti,j721e-pcie-ep" in the check has been treated as the removal of
"ti,j784s4-pcie-ep" first followed by adding the same later for generating the
diff in this patch. The diff above is equivalent to the addition of:

  - if:
      properties:
        compatible:
          items:
            - const: ti,j721e-pcie-ep
    then:
      properties:
        num-lanes:
          minimum: 1
          maximum: 4

-- 
Regards,
Siddharth.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ