Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1653367 > unrolled thread

[PATCH 1/2] clk: bcm2835: Limit PCM clock to OSC and PLLD_PER

Started byPhil Elwell <phil@raspberrypi.org>
First post2017-05-30 18:30 +0200
Last post2017-06-01 10:50 +0200
Articles 7 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/2] clk: bcm2835: Limit PCM clock to OSC and PLLD_PER Phil Elwell <phil@raspberrypi.org> - 2017-05-30 18:30 +0200
    Re: [PATCH 1/2] clk: bcm2835: Limit PCM clock to OSC and PLLD_PER Stefan Wahren <stefan.wahren@i2se.com> - 2017-05-30 20:50 +0200
      Re: [PATCH 1/2] clk: bcm2835: Limit PCM clock to OSC and PLLD_PER Phil Elwell <phil@raspberrypi.org> - 2017-05-31 10:30 +0200
        Re: [PATCH 1/2] clk: bcm2835: Limit PCM clock to OSC and PLLD_PER Stefan Wahren <stefan.wahren@i2se.com> - 2017-05-31 11:10 +0200
    [PATCH v2 1/2] clk: bcm2835: Limit PCM clock to OSC and PLLD_PER Phil Elwell <phil@raspberrypi.org> - 2017-05-31 11:20 +0200
    Re: [PATCH 1/2] clk: bcm2835: Limit PCM clock to OSC and PLLD_PER Eric Anholt <eric@anholt.net> - 2017-05-31 23:30 +0200
      Re: [PATCH 1/2] clk: bcm2835: Limit PCM clock to OSC and PLLD_PER Phil Elwell <phil@raspberrypi.org> - 2017-06-01 10:50 +0200

#1653367 — [PATCH 1/2] clk: bcm2835: Limit PCM clock to OSC and PLLD_PER

FromPhil Elwell <phil@raspberrypi.org>
Date2017-05-30 18:30 +0200
Subject[PATCH 1/2] clk: bcm2835: Limit PCM clock to OSC and PLLD_PER
Message-ID<tMSbV-1dJ-37@gated-at.bofh.it>
Restrict clock sources for the PCM peripheral to the oscillator and
PLLD_PER because other source may have varying rates or be switched off.
Prevent other sources from being selected by replacing their names in
the list of potential parents with dummy entries (entry index is
significant).

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
---
 drivers/clk/bcm/clk-bcm2835.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index 0258538..facc346 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -1511,6 +1511,16 @@ struct bcm2835_clk_desc {
 	"pllh_aux",
 };
 
+static const char *const bcm2835_pcm_per_parents[] = {
+	"-",
+	"xosc",
+	"-",
+	"-",
+	"-",
+	"-",
+	"plld_per",
+};
+
 #define REGISTER_PER_CLK(...)	REGISTER_CLK(				\
 	.num_mux_parents = ARRAY_SIZE(bcm2835_clock_per_parents),	\
 	.parents = bcm2835_clock_per_parents,				\
@@ -2000,6 +2010,7 @@ struct bcm2835_clk_desc {
 		.int_bits = 12,
 		.frac_bits = 12,
 		.is_mash_clock = true,
+		.parents = bcm2835_pcm_per_parents,
 		.tcnt_mux = 23),
 	[BCM2835_CLOCK_PWM]	= REGISTER_PER_CLK(
 		.name = "pwm",
-- 
1.9.1

[toc] | [next] | [standalone]


#1653487

FromStefan Wahren <stefan.wahren@i2se.com>
Date2017-05-30 20:50 +0200
Message-ID<tMUno-2tM-9@gated-at.bofh.it>
In reply to#1653367
Hi Phil,

> Phil Elwell <phil@raspberrypi.org> hat am 30. Mai 2017 um 18:28 geschrieben:
> 
> 
> Restrict clock sources for the PCM peripheral to the oscillator and
> PLLD_PER because other source may have varying rates or be switched off.

> Prevent other sources from being selected by replacing their names in
> the list of potential parents with dummy entries (entry index is
> significant).

i like to have this as a comment above the definition of bcm2835_pcm_per_parents.

> 
> Signed-off-by: Phil Elwell <phil@raspberrypi.org>
> ---
>  drivers/clk/bcm/clk-bcm2835.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
> index 0258538..facc346 100644
> --- a/drivers/clk/bcm/clk-bcm2835.c
> +++ b/drivers/clk/bcm/clk-bcm2835.c
> @@ -1511,6 +1511,16 @@ struct bcm2835_clk_desc {
>  	"pllh_aux",
>  };
>
> +static const char *const bcm2835_pcm_per_parents[] = {

As mentioned above, there should be a comment like all the others. 

> +	"-",
> +	"xosc",
> +	"-",
> +	"-",
> +	"-",
> +	"-",
> +	"plld_per",
> +};

Is there a dummy entry for "pllh_aux" missing?

> +
>  #define REGISTER_PER_CLK(...)	REGISTER_CLK(				\
>  	.num_mux_parents = ARRAY_SIZE(bcm2835_clock_per_parents),	\
>  	.parents = bcm2835_clock_per_parents,				\
> @@ -2000,6 +2010,7 @@ struct bcm2835_clk_desc {
>  		.int_bits = 12,
>  		.frac_bits = 12,
>  		.is_mash_clock = true,
> +		.parents = bcm2835_pcm_per_parents,

This looks a little bit hacky to me. Not sure, but can we do something like this?

#define REGISTER_PCM_CLK(...)	REGISTER_CLK(				\
	.num_mux_parents = ARRAY_SIZE(bcm2835_pcm_per_parents),	\
	.parents = bcm2835_pcm_per_parents,				\
	__VA_ARGS__)

Regards
Stefan

>  		.tcnt_mux = 23),
>  	[BCM2835_CLOCK_PWM]	= REGISTER_PER_CLK(
>  		.name = "pwm",
> -- 
> 1.9.1
>

[toc] | [prev] | [next] | [standalone]


#1653972

FromPhil Elwell <phil@raspberrypi.org>
Date2017-05-31 10:30 +0200
Message-ID<tN7aV-2iQ-1@gated-at.bofh.it>
In reply to#1653487
Hi Stefan,

On 30/05/2017 19:41, Stefan Wahren wrote:
> Hi Phil,
> 
>> Phil Elwell <phil@raspberrypi.org> hat am 30. Mai 2017 um 18:28 geschrieben:
>>
>>
>> Restrict clock sources for the PCM peripheral to the oscillator and
>> PLLD_PER because other source may have varying rates or be switched off.
> 
>> Prevent other sources from being selected by replacing their names in
>> the list of potential parents with dummy entries (entry index is
>> significant).
> 
> i like to have this as a comment above the definition of bcm2835_pcm_per_parents.

Sure - good idea.

>>
>> Signed-off-by: Phil Elwell <phil@raspberrypi.org>
>> ---
>>  drivers/clk/bcm/clk-bcm2835.c | 11 +++++++++++
>>  1 file changed, 11 insertions(+)
>>
>> diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
>> index 0258538..facc346 100644
>> --- a/drivers/clk/bcm/clk-bcm2835.c
>> +++ b/drivers/clk/bcm/clk-bcm2835.c
>> @@ -1511,6 +1511,16 @@ struct bcm2835_clk_desc {
>>  	"pllh_aux",
>>  };
>>
>> +static const char *const bcm2835_pcm_per_parents[] = {
> 
> As mentioned above, there should be a comment like all the others.

Yes, will do.

>> +	"-",
>> +	"xosc",
>> +	"-",
>> +	"-",
>> +	"-",
>> +	"-",
>> +	"plld_per",
>> +};
> 
> Is there a dummy entry for "pllh_aux" missing?

Yes and no - adding it will cause an extra iteration around the loop, but 
perhaps it's less confusing. I'll add one.

>> +
>>  #define REGISTER_PER_CLK(...)	REGISTER_CLK(				\
>>  	.num_mux_parents = ARRAY_SIZE(bcm2835_clock_per_parents),	\
>>  	.parents = bcm2835_clock_per_parents,				\
>> @@ -2000,6 +2010,7 @@ struct bcm2835_clk_desc {
>>  		.int_bits = 12,
>>  		.frac_bits = 12,
>>  		.is_mash_clock = true,
>> +		.parents = bcm2835_pcm_per_parents,
> 
> This looks a little bit hacky to me. Not sure, but can we do something like this?
> 
> #define REGISTER_PCM_CLK(...)	REGISTER_CLK(				\
> 	.num_mux_parents = ARRAY_SIZE(bcm2835_pcm_per_parents),	\
> 	.parents = bcm2835_pcm_per_parents,				\
> 	__VA_ARGS__)

Of course - no problem.

Thanks for the feedback - it will be incorporated into V2.

Phil

[toc] | [prev] | [next] | [standalone]


#1654029

FromStefan Wahren <stefan.wahren@i2se.com>
Date2017-05-31 11:10 +0200
Message-ID<tN7NE-2Od-33@gated-at.bofh.it>
In reply to#1653972
Am 31.05.2017 um 10:28 schrieb Phil Elwell:
> Hi Stefan,
>
> On 30/05/2017 19:41, Stefan Wahren wrote:
>> Hi Phil,
>>
>>> Phil Elwell <phil@raspberrypi.org> hat am 30. Mai 2017 um 18:28 geschrieben:
>>>
>>>
>>> Restrict clock sources for the PCM peripheral to the oscillator and
>>> PLLD_PER because other source may have varying rates or be switched off.
>>> Prevent other sources from being selected by replacing their names in
>>> the list of potential parents with dummy entries (entry index is
>>> significant).
>> i like to have this as a comment above the definition of bcm2835_pcm_per_parents.
> Sure - good idea.
>
>>> Signed-off-by: Phil Elwell <phil@raspberrypi.org>
>>> ---
>>>  drivers/clk/bcm/clk-bcm2835.c | 11 +++++++++++
>>>  1 file changed, 11 insertions(+)
>>>
>>> diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
>>> index 0258538..facc346 100644
>>> --- a/drivers/clk/bcm/clk-bcm2835.c
>>> +++ b/drivers/clk/bcm/clk-bcm2835.c
>>> @@ -1511,6 +1511,16 @@ struct bcm2835_clk_desc {
>>>  	"pllh_aux",
>>>  };
>>>
>>> +static const char *const bcm2835_pcm_per_parents[] = {
>> As mentioned above, there should be a comment like all the others.
> Yes, will do.
>
>>> +	"-",
>>> +	"xosc",
>>> +	"-",
>>> +	"-",
>>> +	"-",
>>> +	"-",
>>> +	"plld_per",
>>> +};
>> Is there a dummy entry for "pllh_aux" missing?
> Yes and no - adding it will cause an extra iteration around the loop, but 
> perhaps it's less confusing. I'll add one.

In case you want to save an iteration, you could add short comment
instead of a dummy entry.

>
>>> +
>>>  #define REGISTER_PER_CLK(...)	REGISTER_CLK(				\
>>>  	.num_mux_parents = ARRAY_SIZE(bcm2835_clock_per_parents),	\
>>>  	.parents = bcm2835_clock_per_parents,				\
>>> @@ -2000,6 +2010,7 @@ struct bcm2835_clk_desc {
>>>  		.int_bits = 12,
>>>  		.frac_bits = 12,
>>>  		.is_mash_clock = true,
>>> +		.parents = bcm2835_pcm_per_parents,
>> This looks a little bit hacky to me. Not sure, but can we do something like this?
>>
>> #define REGISTER_PCM_CLK(...)	REGISTER_CLK(				\
>> 	.num_mux_parents = ARRAY_SIZE(bcm2835_pcm_per_parents),	\
>> 	.parents = bcm2835_pcm_per_parents,				\
>> 	__VA_ARGS__)
> Of course - no problem.
>
> Thanks for the feedback - it will be incorporated into V2.
>
> Phil

[toc] | [prev] | [next] | [standalone]


#1654032 — [PATCH v2 1/2] clk: bcm2835: Limit PCM clock to OSC and PLLD_PER

FromPhil Elwell <phil@raspberrypi.org>
Date2017-05-31 11:20 +0200
Subject[PATCH v2 1/2] clk: bcm2835: Limit PCM clock to OSC and PLLD_PER
Message-ID<tN7Xj-2RF-5@gated-at.bofh.it>
In reply to#1653367
Restrict clock sources for the PCM peripheral to the oscillator and
PLLD_PER because other source may have varying rates or be switched off.
Prevent other sources from being selected by replacing their names in
the list of potential parents with dummy entries (entry index is
significant).

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
---
 drivers/clk/bcm/clk-bcm2835.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index 0258538..81ecd4c 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -1516,6 +1516,31 @@ struct bcm2835_clk_desc {
 	.parents = bcm2835_clock_per_parents,				\
 	__VA_ARGS__)
 
+/*
+ * Restrict clock sources for the PCM peripheral to the oscillator and
+ * PLLD_PER because other source may have varying rates or be switched
+ * off.
+ *
+ * Prevent other sources from being selected by replacing their names in
+ * the list of potential parents with dummy entries (entry index is
+ * significant).
+ */
+static const char *const bcm2835_pcm_per_parents[] = {
+	"-",
+	"xosc",
+	"-",
+	"-",
+	"-",
+	"-",
+	"plld_per",
+	"-",
+};
+
+#define REGISTER_PCM_CLK(...)	REGISTER_CLK(				\
+	.num_mux_parents = ARRAY_SIZE(bcm2835_clock_pcm_per_parents),	\
+	.parents = bcm2835_clock_pcm_per_parents,			\
+	__VA_ARGS__)
+
 /* main vpu parent mux */
 static const char *const bcm2835_clock_vpu_parents[] = {
 	"gnd",
@@ -1993,7 +2018,7 @@ struct bcm2835_clk_desc {
 		.int_bits = 4,
 		.frac_bits = 8,
 		.tcnt_mux = 22),
-	[BCM2835_CLOCK_PCM]	= REGISTER_PER_CLK(
+	[BCM2835_CLOCK_PCM]	= REGISTER_PCM_CLK(
 		.name = "pcm",
 		.ctl_reg = CM_PCMCTL,
 		.div_reg = CM_PCMDIV,
-- 
1.9.1

[toc] | [prev] | [next] | [standalone]


#1654637

FromEric Anholt <eric@anholt.net>
Date2017-05-31 23:30 +0200
Message-ID<tNjlL-1UD-5@gated-at.bofh.it>
In reply to#1653367

[Multipart message — attachments visible in raw view] — view raw

Phil Elwell <phil@raspberrypi.org> writes:

> Restrict clock sources for the PCM peripheral to the oscillator and
> PLLD_PER because other source may have varying rates or be switched off.
> Prevent other sources from being selected by replacing their names in
> the list of potential parents with dummy entries (entry index is
> significant).

I might be up for giving my r-b on this, but first I'd like to check if
we can simplify even more.  Looking through this list:

static const char *const bcm2835_clock_per_parents[] = {
	"gnd",
	"xosc",
	"testdebug0",
	"testdebug1",
	"plla_per",
	"pllc_per",
	"plld_per",
	"pllh_aux",
};

PLLA is off and unused and we don't want any peripheral to turn it on
(unless we wanted PCM to do so, but we aren't doing that here).

PLLC's rate gets changed by the VPU and so it isn't reliable.
67615c588a059b731df9d019edc3c561d8006ec9 made it so that nobody uses it
that isn't using it by firmware setup, and EMMC is the only one that the
firmware is having use PLLC.  Would we be better off just having EMMC
always be on PLLD?  Or, we could special-case EMMC to be the only one to
use PLLC.

PLLD is stable.

PLLH should only be used as a parent by VEC (or HSM, assuming that
drm/vc4 rate-sets PLLH_PIX first, but I don't know of a reason for HSM
to not just be fractionally divided off of PLLD).  If you've got
firmware display in use, it may change rate or be disabled behind
Linux's back, so we don't want anything but Linux-controlled VEC to use
it.  We could special-case VEC to be the only one that had PLLH_AUX as
parent.

So, my proposal would be to basically make everything but VEC and maybe
EMMC use your new list, and drop the code in
67615c588a059b731df9d019edc3c561d8006ec9.  That said, if you want to do
this first for PCM and then extend it to the rest of the clock
consumers, I'm fine with that.

[toc] | [prev] | [next] | [standalone]


#1654935

FromPhil Elwell <phil@raspberrypi.org>
Date2017-06-01 10:50 +0200
Message-ID<tNtXP-fI-3@gated-at.bofh.it>
In reply to#1654637
On 31/05/2017 22:24, Eric Anholt wrote:
> Phil Elwell <phil@raspberrypi.org> writes:
> 
>> Restrict clock sources for the PCM peripheral to the oscillator and
>> PLLD_PER because other source may have varying rates or be switched off.
>> Prevent other sources from being selected by replacing their names in
>> the list of potential parents with dummy entries (entry index is
>> significant).
> 
> I might be up for giving my r-b on this, but first I'd like to check if
> we can simplify even more.  Looking through this list:
> 
> static const char *const bcm2835_clock_per_parents[] = {
> 	"gnd",
> 	"xosc",
> 	"testdebug0",
> 	"testdebug1",
> 	"plla_per",
> 	"pllc_per",
> 	"plld_per",
> 	"pllh_aux",
> };
> 
> PLLA is off and unused and we don't want any peripheral to turn it on
> (unless we wanted PCM to do so, but we aren't doing that here).
> 
> PLLC's rate gets changed by the VPU and so it isn't reliable.
> 67615c588a059b731df9d019edc3c561d8006ec9 made it so that nobody uses it
> that isn't using it by firmware setup, and EMMC is the only one that the
> firmware is having use PLLC.  Would we be better off just having EMMC
> always be on PLLD?  Or, we could special-case EMMC to be the only one to
> use PLLC.
> 
> PLLD is stable.
> 
> PLLH should only be used as a parent by VEC (or HSM, assuming that
> drm/vc4 rate-sets PLLH_PIX first, but I don't know of a reason for HSM
> to not just be fractionally divided off of PLLD).  If you've got
> firmware display in use, it may change rate or be disabled behind
> Linux's back, so we don't want anything but Linux-controlled VEC to use
> it.  We could special-case VEC to be the only one that had PLLH_AUX as
> parent.
> 
> So, my proposal would be to basically make everything but VEC and maybe
> EMMC use your new list, and drop the code in
> 67615c588a059b731df9d019edc3c561d8006ec9.  That said, if you want to do
> this first for PCM and then extend it to the rest of the clock
> consumers, I'm fine with that.

Thank, Eric. In the Linux spirit of doing things in small, incremental steps
(that and cowardice) I'd like to just restrict PCM for now. I'll add
your Reviewed-by to v3.

Phil

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web