All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Zapolskiy <vz@mleia.com>
To: Robin Murphy <robin.murphy@arm.com>, Arnd Bergmann <arnd@arndb.de>
Cc: Kuldeep Singh <singh.kuldeep87k@gmail.com>,
	Olof Johansson <olof@lixom.net>, SoC Team <soc@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	DTML <devicetree@vger.kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties
Date: Mon, 14 Mar 2022 14:34:46 +0200	[thread overview]
Message-ID: <4a7e3d0e-f804-74a5-ef5b-206404eb9b61@mleia.com> (raw)
In-Reply-To: <faea4c0c-e20b-c043-6f74-95af8177e8bd@arm.com>

On 3/14/22 2:20 PM, Robin Murphy wrote:
> On 2022-03-14 11:50, Vladimir Zapolskiy wrote:
>> On 3/14/22 1:43 PM, Robin Murphy wrote:
>>> On 2022-03-11 14:07, Vladimir Zapolskiy wrote:
>>>> On 3/11/22 3:38 PM, Arnd Bergmann wrote:
>>>>> On Fri, Mar 11, 2022 at 2:20 PM Vladimir Zapolskiy <vz@mleia.com>
>>>>> wrote:
>>>>>>
>>>>>> On 3/11/22 11:38 AM, Kuldeep Singh wrote:
>>>>>>> PL022 binding require two clocks to be defined but lpc platform
>>>>>>> doesn't
>>>>>>> comply with bindings and define only one clock i.e apb_pclk.
>>>>>>>
>>>>>>> Update spi clocks and clocks-names property by adding appropriate
>>>>>>> clock
>>>>>>> reference to make it compliant with bindings.
>>>>>>>
>>>>>>> CC: Vladimir Zapolskiy <vz@mleia.com>
>>>>>>> Signed-off-by: Kuldeep Singh <singh.kuldeep87k@gmail.com>
>>>>>>> ---
>>>>>>> v2:
>>>>>>> - New patch with similar changeset
>>>>>>> - Send to soc ML
>>>>>>>
>>>>>>>      arch/arm/boot/dts/lpc32xx.dtsi | 8 ++++----
>>>>>>>      1 file changed, 4 insertions(+), 4 deletions(-)
>>>>>>>
>>>>>>> diff --git a/arch/arm/boot/dts/lpc32xx.dtsi
>>>>>>> b/arch/arm/boot/dts/lpc32xx.dtsi
>>>>>>> index c87066d6c995..30958e02d5e2 100644
>>>>>>> --- a/arch/arm/boot/dts/lpc32xx.dtsi
>>>>>>> +++ b/arch/arm/boot/dts/lpc32xx.dtsi
>>>>>>> @@ -178,8 +178,8 @@ ssp0: spi@20084000 {
>>>>>>>                                  compatible = "arm,pl022",
>>>>>>> "arm,primecell";
>>>>>>>                                  reg = <0x20084000 0x1000>;
>>>>>>>                                  interrupts = <20
>>>>>>> IRQ_TYPE_LEVEL_HIGH>;
>>>>>>> -                             clocks = <&clk LPC32XX_CLK_SSP0>;
>>>>>>> -                             clock-names = "apb_pclk";
>>>>>>> +                             clocks = <&clk LPC32XX_CLK_SSP0>,
>>>>>>> <&clk LPC32XX_CLK_SSP0>;
>>>>>>> +                             clock-names = "sspclk", "apb_pclk";
>>>>>>
>>>>>> In fact I'm uncertain if it is the right change, could it happen that
>>>>>> the commit
>>>>>> cc0f6e96c4fd ("spi: dt-bindings: Convert Arm pl022 to json-schema")
>>>>>> sets a wrong
>>>>>> schema pattern?
>>>>>
>>>>> Good pointm this doesn't quite seem right: it is unlikely that the
>>>>> same clock
>>>>> is used for both the SPI bus and the APB bus.
>>>>>
>>>>>> Apparently just one clock is wanted on all observed platforms and
>>>>>> cases, this
>>>>>> is implicitly confirmed by clock handling in the
>>>>>> drivers/spi/spi-pl022.c :
>>>>>>
>>>>>>            pl022->clk = devm_clk_get(&adev->dev, NULL);
>>>>>>
>>>>>> So, I would vote to fix the device tree bindings schema.
>>>>>
>>>>> Isn't this just using the wrong name? The name of the macro
>>>>> LPC32XX_CLK_SSP0 might indicate that this is indeed the SPI clock
>>>>> rather than the APB clock, so we only need to change clock-names
>>>>> property here and leave it unchanged otherwise.
>>>>
>>>> Yes, the name is wrong, here I'm ready to take the blame:
>>>>
>>>> Fixes: 93898eb775e5 ("arm: dts: lpc32xx: add clock properties to device
>>>> nodes")
>>>>
>>>> Noteworthy the commit above presets the same clock name to other
>>>> PrimeCell
>>>> controllers, namely pl110 (LCD), pl080 (DMA), pl175 (EMC) and pl18x
>>>> (SD),
>>>> plus this one pl022 (SSP), and all but SSP and SD are AHB slaves in
>>>> fact.
>>>>
>>>> On LPC32xx the bus clock source and function clock source for SSP is
>>>> HCLK.
>>>>
>>>> My guess is that the misnamed "apb_pclk" migrated into the schema from
>>>> the lpc32xx.dtsi, so I'd suggest, unless some platform really needs it,
>>>> firstly fix the schema by removing "apb_pclk" clock. It will leave
>>>> just one
>>>> clock, so "clock-names" property can be set as optional, and the drop
>>>> the property from the lpc32xx.dtsi.
>>>
>>> No, "apb_pclk" is part of the common AMBA binding, and is required by
>>> the "arm,primecell" compatible. You won't (usually) find it referenced
>>> in drivers because it's dealt with by amba_get_enable_pclk() via
>>> amba_probe().
>>>
>>
>> Thank you, it explains, why "apb_pclk" is required for all PrimeCell
>> controllers on the SoC. Nevertheless, in commit 93898eb775e5 it was
>> misidentified with the sspclk clock, the latter one is the only clock
>> explicitly utilized by the driver in 2015 and till today. Fixes in dts
>> files should be preceded by a fix in the driver.
> 
> There's nothing to fix in the driver, though. In fact it can only be
> working today because the Linux driver isn't very strict and simply
> assumes that the first clock entry is SSPCLK *without* considering its
> name (other consumers of the binding might be stricter; I don't know),

Here I'm a bit ignorant, would it be totally reliable to assume that
clk_get(dev, NULL) gets the first clock from the list, and will it never
happen that one day it takes e.g. the last entry?

I'm kind of surprised that the asked fix in the driver meets such a
resistance.

> and because presumably the HCLK happens to be enabled already anyway.

Yes, that's the case here.

> Changing the driver behaviour would only stand to cause functional
> regressions.
> 
> There are effectively two bugs in the DTS here, firstly that it only has
> one clock entry when it should have two, and secondly that the clock
> entry which *is* present has the wrong name (or the wrong clock
> specifier, depending on how you look at it). Kuldeep's patch merely
> fixes the first one by fully describing the way it's currently working
> in practice, so it's really just a choice of whether to treat "respect
> the binding" and "describe the hardware correctly" as separate issues
> and have a follow-up patch to correctly reference HCLK as the second
> clock, or whether they're trivial enough to squash together.
> 

The two problems in the DTS are not argued, the chosen way to correct them
is questionable though. Well, I won't object to see it split into two
changes, but please send them at least in one series then, so that it
won't be left forgotten.

--
Best wishes,
Vladimir

WARNING: multiple messages have this Message-ID (diff)
From: Vladimir Zapolskiy <vz@mleia.com>
To: Robin Murphy <robin.murphy@arm.com>, Arnd Bergmann <arnd@arndb.de>
Cc: Kuldeep Singh <singh.kuldeep87k@gmail.com>,
	Olof Johansson <olof@lixom.net>, SoC Team <soc@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	DTML <devicetree@vger.kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 3/3] ARM: dts: lpc32xx: Update spi clock properties
Date: Mon, 14 Mar 2022 14:34:46 +0200	[thread overview]
Message-ID: <4a7e3d0e-f804-74a5-ef5b-206404eb9b61@mleia.com> (raw)
In-Reply-To: <faea4c0c-e20b-c043-6f74-95af8177e8bd@arm.com>

On 3/14/22 2:20 PM, Robin Murphy wrote:
> On 2022-03-14 11:50, Vladimir Zapolskiy wrote:
>> On 3/14/22 1:43 PM, Robin Murphy wrote:
>>> On 2022-03-11 14:07, Vladimir Zapolskiy wrote:
>>>> On 3/11/22 3:38 PM, Arnd Bergmann wrote:
>>>>> On Fri, Mar 11, 2022 at 2:20 PM Vladimir Zapolskiy <vz@mleia.com>
>>>>> wrote:
>>>>>>
>>>>>> On 3/11/22 11:38 AM, Kuldeep Singh wrote:
>>>>>>> PL022 binding require two clocks to be defined but lpc platform
>>>>>>> doesn't
>>>>>>> comply with bindings and define only one clock i.e apb_pclk.
>>>>>>>
>>>>>>> Update spi clocks and clocks-names property by adding appropriate
>>>>>>> clock
>>>>>>> reference to make it compliant with bindings.
>>>>>>>
>>>>>>> CC: Vladimir Zapolskiy <vz@mleia.com>
>>>>>>> Signed-off-by: Kuldeep Singh <singh.kuldeep87k@gmail.com>
>>>>>>> ---
>>>>>>> v2:
>>>>>>> - New patch with similar changeset
>>>>>>> - Send to soc ML
>>>>>>>
>>>>>>>      arch/arm/boot/dts/lpc32xx.dtsi | 8 ++++----
>>>>>>>      1 file changed, 4 insertions(+), 4 deletions(-)
>>>>>>>
>>>>>>> diff --git a/arch/arm/boot/dts/lpc32xx.dtsi
>>>>>>> b/arch/arm/boot/dts/lpc32xx.dtsi
>>>>>>> index c87066d6c995..30958e02d5e2 100644
>>>>>>> --- a/arch/arm/boot/dts/lpc32xx.dtsi
>>>>>>> +++ b/arch/arm/boot/dts/lpc32xx.dtsi
>>>>>>> @@ -178,8 +178,8 @@ ssp0: spi@20084000 {
>>>>>>>                                  compatible = "arm,pl022",
>>>>>>> "arm,primecell";
>>>>>>>                                  reg = <0x20084000 0x1000>;
>>>>>>>                                  interrupts = <20
>>>>>>> IRQ_TYPE_LEVEL_HIGH>;
>>>>>>> -                             clocks = <&clk LPC32XX_CLK_SSP0>;
>>>>>>> -                             clock-names = "apb_pclk";
>>>>>>> +                             clocks = <&clk LPC32XX_CLK_SSP0>,
>>>>>>> <&clk LPC32XX_CLK_SSP0>;
>>>>>>> +                             clock-names = "sspclk", "apb_pclk";
>>>>>>
>>>>>> In fact I'm uncertain if it is the right change, could it happen that
>>>>>> the commit
>>>>>> cc0f6e96c4fd ("spi: dt-bindings: Convert Arm pl022 to json-schema")
>>>>>> sets a wrong
>>>>>> schema pattern?
>>>>>
>>>>> Good pointm this doesn't quite seem right: it is unlikely that the
>>>>> same clock
>>>>> is used for both the SPI bus and the APB bus.
>>>>>
>>>>>> Apparently just one clock is wanted on all observed platforms and
>>>>>> cases, this
>>>>>> is implicitly confirmed by clock handling in the
>>>>>> drivers/spi/spi-pl022.c :
>>>>>>
>>>>>>            pl022->clk = devm_clk_get(&adev->dev, NULL);
>>>>>>
>>>>>> So, I would vote to fix the device tree bindings schema.
>>>>>
>>>>> Isn't this just using the wrong name? The name of the macro
>>>>> LPC32XX_CLK_SSP0 might indicate that this is indeed the SPI clock
>>>>> rather than the APB clock, so we only need to change clock-names
>>>>> property here and leave it unchanged otherwise.
>>>>
>>>> Yes, the name is wrong, here I'm ready to take the blame:
>>>>
>>>> Fixes: 93898eb775e5 ("arm: dts: lpc32xx: add clock properties to device
>>>> nodes")
>>>>
>>>> Noteworthy the commit above presets the same clock name to other
>>>> PrimeCell
>>>> controllers, namely pl110 (LCD), pl080 (DMA), pl175 (EMC) and pl18x
>>>> (SD),
>>>> plus this one pl022 (SSP), and all but SSP and SD are AHB slaves in
>>>> fact.
>>>>
>>>> On LPC32xx the bus clock source and function clock source for SSP is
>>>> HCLK.
>>>>
>>>> My guess is that the misnamed "apb_pclk" migrated into the schema from
>>>> the lpc32xx.dtsi, so I'd suggest, unless some platform really needs it,
>>>> firstly fix the schema by removing "apb_pclk" clock. It will leave
>>>> just one
>>>> clock, so "clock-names" property can be set as optional, and the drop
>>>> the property from the lpc32xx.dtsi.
>>>
>>> No, "apb_pclk" is part of the common AMBA binding, and is required by
>>> the "arm,primecell" compatible. You won't (usually) find it referenced
>>> in drivers because it's dealt with by amba_get_enable_pclk() via
>>> amba_probe().
>>>
>>
>> Thank you, it explains, why "apb_pclk" is required for all PrimeCell
>> controllers on the SoC. Nevertheless, in commit 93898eb775e5 it was
>> misidentified with the sspclk clock, the latter one is the only clock
>> explicitly utilized by the driver in 2015 and till today. Fixes in dts
>> files should be preceded by a fix in the driver.
> 
> There's nothing to fix in the driver, though. In fact it can only be
> working today because the Linux driver isn't very strict and simply
> assumes that the first clock entry is SSPCLK *without* considering its
> name (other consumers of the binding might be stricter; I don't know),

Here I'm a bit ignorant, would it be totally reliable to assume that
clk_get(dev, NULL) gets the first clock from the list, and will it never
happen that one day it takes e.g. the last entry?

I'm kind of surprised that the asked fix in the driver meets such a
resistance.

> and because presumably the HCLK happens to be enabled already anyway.

Yes, that's the case here.

> Changing the driver behaviour would only stand to cause functional
> regressions.
> 
> There are effectively two bugs in the DTS here, firstly that it only has
> one clock entry when it should have two, and secondly that the clock
> entry which *is* present has the wrong name (or the wrong clock
> specifier, depending on how you look at it). Kuldeep's patch merely
> fixes the first one by fully describing the way it's currently working
> in practice, so it's really just a choice of whether to treat "respect
> the binding" and "describe the hardware correctly" as separate issues
> and have a follow-up patch to correctly reference HCLK as the second
> clock, or whether they're trivial enough to squash together.
> 

The two problems in the DTS are not argued, the chosen way to correct them
is questionable though. Well, I won't object to see it split into two
changes, but please send them at least in one series then, so that it
won't be left forgotten.

--
Best wishes,
Vladimir

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2022-03-14 12:49 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11  9:37 [PATCH v2 0/3] PL022 DT fixes for seattle, lg and lpc platform Kuldeep Singh
2022-03-11  9:37 ` Kuldeep Singh
2022-03-11  9:37 ` [PATCH v2 1/3] arm64: dts: seattle: Update spi clock properties Kuldeep Singh
2022-03-11  9:37   ` Kuldeep Singh
2022-03-11  9:37 ` [PATCH v2 2/3] arm64: dts: lg131x: " Kuldeep Singh
2022-03-11  9:37   ` Kuldeep Singh
2022-03-11  9:38 ` [PATCH v2 3/3] ARM: dts: lpc32xx: " Kuldeep Singh
2022-03-11  9:38   ` Kuldeep Singh
2022-03-11 13:20   ` Vladimir Zapolskiy
2022-03-11 13:20     ` Vladimir Zapolskiy
2022-03-11 13:38     ` Arnd Bergmann
2022-03-11 13:38       ` Arnd Bergmann
2022-03-11 14:07       ` Vladimir Zapolskiy
2022-03-11 14:07         ` Vladimir Zapolskiy
2022-03-11 14:33         ` Krzysztof Kozlowski
2022-03-11 14:33           ` Krzysztof Kozlowski
2022-03-11 21:26           ` Vladimir Zapolskiy
2022-03-11 21:26             ` Vladimir Zapolskiy
2022-03-12 10:23             ` Krzysztof Kozlowski
2022-03-12 10:23               ` Krzysztof Kozlowski
2022-03-12 12:26               ` Vladimir Zapolskiy
2022-03-12 12:26                 ` Vladimir Zapolskiy
2022-03-14 11:43         ` Robin Murphy
2022-03-14 11:43           ` Robin Murphy
2022-03-14 11:50           ` Vladimir Zapolskiy
2022-03-14 11:50             ` Vladimir Zapolskiy
2022-03-14 12:20             ` Robin Murphy
2022-03-14 12:20               ` Robin Murphy
2022-03-14 12:32               ` Arnd Bergmann
2022-03-14 12:32                 ` Arnd Bergmann
2022-03-14 17:55                 ` Robin Murphy
2022-03-14 17:55                   ` Robin Murphy
2022-03-14 12:34               ` Vladimir Zapolskiy [this message]
2022-03-14 12:34                 ` Vladimir Zapolskiy
2022-03-27  2:57                 ` Trevor Woerner
2022-03-27 16:27                   ` Vladimir Zapolskiy
2022-03-27 16:27                     ` Vladimir Zapolskiy
2022-03-27 18:32                     ` Trevor Woerner
2022-03-27 18:32                       ` Trevor Woerner
2022-03-11 10:50 ` [PATCH v2 0/3] PL022 DT fixes for seattle, lg and lpc platform patchwork-bot+linux-soc

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=4a7e3d0e-f804-74a5-ef5b-206404eb9b61@mleia.com \
    --to=vz@mleia.com \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olof@lixom.net \
    --cc=robh+dt@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=singh.kuldeep87k@gmail.com \
    --cc=soc@kernel.org \
    /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.