linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: sunxi-ng: v3s: Fix incorrect number of hw_clks.
@ 2019-11-09 15:19 Tian Yunhao
  2019-11-11 12:39 ` Maxime Ripard
  0 siblings, 1 reply; 6+ messages in thread
From: Tian Yunhao @ 2019-11-09 15:19 UTC (permalink / raw)
  Cc: tian yunhao, Stephen Boyd, Michael Turquette, linux-kernel,
	Maxime Ripard, Chen-Yu Tsai, linux-clk, linux-arm-kernel,
	Icenowy Zheng

The hws field of sun8i_v3s_hw_clks has only 74
members. However, the number specified by CLK_NUMBER
is 77 (= CLK_I2S0 + 1). This leads to runtime segmentation
fault that is not always reproducible.

This patch adds a protective field [CLK_NUMBER] which ensures
ARRAY_SIZE(.hws) is always greater than .num, thus eliminates
this error.

Signed-off-by: Yunhao Tian <t123yh@outlook.com>
---
 drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
index 5c779eec454b..de7fce7f32e6 100644
--- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
@@ -617,6 +617,7 @@ static struct clk_hw_onecell_data sun8i_v3s_hw_clks = {
 		[CLK_AVS]		= &avs_clk.common.hw,
 		[CLK_MBUS]		= &mbus_clk.common.hw,
 		[CLK_MIPI_CSI]		= &mipi_csi_clk.common.hw,
+		[CLK_NUMBER]    = NULL,
 	},
 	.num	= CLK_NUMBER,
 };
@@ -699,6 +700,7 @@ static struct clk_hw_onecell_data sun8i_v3_hw_clks = {
 		[CLK_AVS]		= &avs_clk.common.hw,
 		[CLK_MBUS]		= &mbus_clk.common.hw,
 		[CLK_MIPI_CSI]		= &mipi_csi_clk.common.hw,
+		[CLK_NUMBER]    = NULL,
 	},
 	.num	= CLK_NUMBER,
 };
-- 
2.23.0


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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] clk: sunxi-ng: v3s: Fix incorrect number of hw_clks.
  2019-11-09 15:19 [PATCH] clk: sunxi-ng: v3s: Fix incorrect number of hw_clks Tian Yunhao
@ 2019-11-11 12:39 ` Maxime Ripard
  2019-11-12 12:59   ` Icenowy Zheng
  0 siblings, 1 reply; 6+ messages in thread
From: Maxime Ripard @ 2019-11-11 12:39 UTC (permalink / raw)
  To: Tian Yunhao
  Cc: Stephen Boyd, Michael Turquette, linux-kernel, Chen-Yu Tsai,
	linux-clk, linux-arm-kernel, Icenowy Zheng


[-- Attachment #1.1: Type: text/plain, Size: 1408 bytes --]

Hi,

Thanks for your patch

On Sat, Nov 09, 2019 at 03:19:09PM +0000, Tian Yunhao wrote:
> The hws field of sun8i_v3s_hw_clks has only 74
> members. However, the number specified by CLK_NUMBER
> is 77 (= CLK_I2S0 + 1). This leads to runtime segmentation
> fault that is not always reproducible.
>
> This patch adds a protective field [CLK_NUMBER] which ensures
> ARRAY_SIZE(.hws) is always greater than .num, thus eliminates
> this error.
>
> Signed-off-by: Yunhao Tian <t123yh@outlook.com>
> ---
>  drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
> index 5c779eec454b..de7fce7f32e6 100644
> --- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
> +++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
> @@ -617,6 +617,7 @@ static struct clk_hw_onecell_data sun8i_v3s_hw_clks = {
>  		[CLK_AVS]		= &avs_clk.common.hw,
>  		[CLK_MBUS]		= &mbus_clk.common.hw,
>  		[CLK_MIPI_CSI]		= &mipi_csi_clk.common.hw,
> +		[CLK_NUMBER]    = NULL,
>  	},
>  	.num	= CLK_NUMBER,
>  };
> @@ -699,6 +700,7 @@ static struct clk_hw_onecell_data sun8i_v3_hw_clks = {
>  		[CLK_AVS]		= &avs_clk.common.hw,
>  		[CLK_MBUS]		= &mbus_clk.common.hw,
>  		[CLK_MIPI_CSI]		= &mipi_csi_clk.common.hw,
> +		[CLK_NUMBER]    = NULL,
>  	},
>  	.num	= CLK_NUMBER,

I'd rather have the number of clocks (.num) being properly set.

Maxime

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] clk: sunxi-ng: v3s: Fix incorrect number of hw_clks.
  2019-11-11 12:39 ` Maxime Ripard
@ 2019-11-12 12:59   ` Icenowy Zheng
  2019-11-12 19:16     ` Maxime Ripard
  0 siblings, 1 reply; 6+ messages in thread
From: Icenowy Zheng @ 2019-11-12 12:59 UTC (permalink / raw)
  To: linux-arm-kernel, Maxime Ripard, Tian Yunhao
  Cc: Stephen Boyd, Michael Turquette, linux-kernel, Chen-Yu Tsai,
	linux-clk, linux-arm-kernel



于 2019年11月11日 GMT+08:00 下午8:39:36, Maxime Ripard <mripard@kernel.org> 写到:
>Hi,
>
>Thanks for your patch
>
>On Sat, Nov 09, 2019 at 03:19:09PM +0000, Tian Yunhao wrote:
>> The hws field of sun8i_v3s_hw_clks has only 74
>> members. However, the number specified by CLK_NUMBER
>> is 77 (= CLK_I2S0 + 1). This leads to runtime segmentation
>> fault that is not always reproducible.
>>
>> This patch adds a protective field [CLK_NUMBER] which ensures
>> ARRAY_SIZE(.hws) is always greater than .num, thus eliminates
>> this error.
>>
>> Signed-off-by: Yunhao Tian <t123yh@outlook.com>
>> ---
>>  drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
>b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
>> index 5c779eec454b..de7fce7f32e6 100644
>> --- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
>> +++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
>> @@ -617,6 +617,7 @@ static struct clk_hw_onecell_data
>sun8i_v3s_hw_clks = {
>>  		[CLK_AVS]		= &avs_clk.common.hw,
>>  		[CLK_MBUS]		= &mbus_clk.common.hw,
>>  		[CLK_MIPI_CSI]		= &mipi_csi_clk.common.hw,
>> +		[CLK_NUMBER]    = NULL,
>>  	},
>>  	.num	= CLK_NUMBER,
>>  };
>> @@ -699,6 +700,7 @@ static struct clk_hw_onecell_data
>sun8i_v3_hw_clks = {
>>  		[CLK_AVS]		= &avs_clk.common.hw,
>>  		[CLK_MBUS]		= &mbus_clk.common.hw,
>>  		[CLK_MIPI_CSI]		= &mipi_csi_clk.common.hw,
>> +		[CLK_NUMBER]    = NULL,
>>  	},
>>  	.num	= CLK_NUMBER,
>
>I'd rather have the number of clocks (.num) being properly set.

However the maximum clock indices number is different on V3s and V3, because
on V3s the last clock is missing.

Should we define CLK_NUMBER_V3S here?

>
>Maxime

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] clk: sunxi-ng: v3s: Fix incorrect number of hw_clks.
  2019-11-12 12:59   ` Icenowy Zheng
@ 2019-11-12 19:16     ` Maxime Ripard
  0 siblings, 0 replies; 6+ messages in thread
From: Maxime Ripard @ 2019-11-12 19:16 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Tian Yunhao, Stephen Boyd, Michael Turquette, linux-kernel,
	Chen-Yu Tsai, linux-clk, linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 2000 bytes --]

On Tue, Nov 12, 2019 at 08:59:56PM +0800, Icenowy Zheng wrote:
>
>
> 于 2019年11月11日 GMT+08:00 下午8:39:36, Maxime Ripard <mripard@kernel.org> 写到:
> >Hi,
> >
> >Thanks for your patch
> >
> >On Sat, Nov 09, 2019 at 03:19:09PM +0000, Tian Yunhao wrote:
> >> The hws field of sun8i_v3s_hw_clks has only 74
> >> members. However, the number specified by CLK_NUMBER
> >> is 77 (= CLK_I2S0 + 1). This leads to runtime segmentation
> >> fault that is not always reproducible.
> >>
> >> This patch adds a protective field [CLK_NUMBER] which ensures
> >> ARRAY_SIZE(.hws) is always greater than .num, thus eliminates
> >> this error.
> >>
> >> Signed-off-by: Yunhao Tian <t123yh@outlook.com>
> >> ---
> >>  drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 2 ++
> >>  1 file changed, 2 insertions(+)
> >>
> >> diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
> >b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
> >> index 5c779eec454b..de7fce7f32e6 100644
> >> --- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
> >> +++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
> >> @@ -617,6 +617,7 @@ static struct clk_hw_onecell_data
> >sun8i_v3s_hw_clks = {
> >>  		[CLK_AVS]		= &avs_clk.common.hw,
> >>  		[CLK_MBUS]		= &mbus_clk.common.hw,
> >>  		[CLK_MIPI_CSI]		= &mipi_csi_clk.common.hw,
> >> +		[CLK_NUMBER]    = NULL,
> >>  	},
> >>  	.num	= CLK_NUMBER,
> >>  };
> >> @@ -699,6 +700,7 @@ static struct clk_hw_onecell_data
> >sun8i_v3_hw_clks = {
> >>  		[CLK_AVS]		= &avs_clk.common.hw,
> >>  		[CLK_MBUS]		= &mbus_clk.common.hw,
> >>  		[CLK_MIPI_CSI]		= &mipi_csi_clk.common.hw,
> >> +		[CLK_NUMBER]    = NULL,
> >>  	},
> >>  	.num	= CLK_NUMBER,
> >
> >I'd rather have the number of clocks (.num) being properly set.
>
> However the maximum clock indices number is different on V3s and V3, because
> on V3s the last clock is missing.
>
> Should we define CLK_NUMBER_V3S here?

That, or we can just reference the last clock, we're not using
CLK_NUMBER anywhere else.

Maxime

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] clk: sunxi-ng: v3s: Fix incorrect number of hw_clks.
  2019-11-25 12:58 Yunhao Tian
@ 2019-11-28 17:44 ` Maxime Ripard
  0 siblings, 0 replies; 6+ messages in thread
From: Maxime Ripard @ 2019-11-28 17:44 UTC (permalink / raw)
  To: Yunhao Tian
  Cc: Stephen Boyd, Michael Turquette, linux-kernel, Chen-Yu Tsai,
	linux-clk, linux-arm-kernel, Icenowy Zheng


[-- Attachment #1.1: Type: text/plain, Size: 425 bytes --]

On Mon, Nov 25, 2019 at 08:58:32PM +0800, Yunhao Tian wrote:
> The hws field of sun8i_v3s_hw_clks has only 74
> members. However, the number specified by CLK_NUMBER
> is 77 (= CLK_I2S0 + 1). This leads to runtime segmentation
> fault that is not always reproducible.
>
> This patch fixes the problem by specifying correct clock number.
>
> Signed-off-by: Yunhao Tian <18373444@buaa.edu.cn>

Queued as a fix, thanks!
Maxime
>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] clk: sunxi-ng: v3s: Fix incorrect number of hw_clks.
@ 2019-11-25 12:58 Yunhao Tian
  2019-11-28 17:44 ` Maxime Ripard
  0 siblings, 1 reply; 6+ messages in thread
From: Yunhao Tian @ 2019-11-25 12:58 UTC (permalink / raw)
  Cc: Stephen Boyd, Michael Turquette, linux-kernel, Maxime Ripard,
	Chen-Yu Tsai, Yunhao Tian, linux-clk, linux-arm-kernel,
	Icenowy Zheng

The hws field of sun8i_v3s_hw_clks has only 74
members. However, the number specified by CLK_NUMBER
is 77 (= CLK_I2S0 + 1). This leads to runtime segmentation
fault that is not always reproducible.

This patch fixes the problem by specifying correct clock number.

Signed-off-by: Yunhao Tian <18373444@buaa.edu.cn>
---
 drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
index 5c779eec454b..0e36ca3bf3d5 100644
--- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
@@ -618,7 +618,7 @@ static struct clk_hw_onecell_data sun8i_v3s_hw_clks = {
 		[CLK_MBUS]		= &mbus_clk.common.hw,
 		[CLK_MIPI_CSI]		= &mipi_csi_clk.common.hw,
 	},
-	.num	= CLK_NUMBER,
+	.num	= CLK_PLL_DDR1 + 1,
 };
 
 static struct clk_hw_onecell_data sun8i_v3_hw_clks = {
@@ -700,7 +700,7 @@ static struct clk_hw_onecell_data sun8i_v3_hw_clks = {
 		[CLK_MBUS]		= &mbus_clk.common.hw,
 		[CLK_MIPI_CSI]		= &mipi_csi_clk.common.hw,
 	},
-	.num	= CLK_NUMBER,
+	.num	= CLK_I2S0 + 1,
 };
 
 static struct ccu_reset_map sun8i_v3s_ccu_resets[] = {
-- 
2.24.0


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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-11-28 17:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-09 15:19 [PATCH] clk: sunxi-ng: v3s: Fix incorrect number of hw_clks Tian Yunhao
2019-11-11 12:39 ` Maxime Ripard
2019-11-12 12:59   ` Icenowy Zheng
2019-11-12 19:16     ` Maxime Ripard
2019-11-25 12:58 Yunhao Tian
2019-11-28 17:44 ` Maxime Ripard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).