linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: imx8m: Suppress bind attrs
@ 2019-11-18 22:28 Leonard Crestez
  2019-11-19  7:09 ` Uwe Kleine-König
  2019-11-19  9:11 ` Peng Fan
  0 siblings, 2 replies; 7+ messages in thread
From: Leonard Crestez @ 2019-11-18 22:28 UTC (permalink / raw)
  To: Stephen Boyd, Shawn Guo
  Cc: Michael Turquette, Jacky Bai, Anson Huang, Abel Vesa, Peng Fan,
	Dong Aisheng, Fabio Estevam, linux-clk, linux-arm-kernel,
	linux-imx, kernel

The clock drivers on imx8m series are registered as platform devices and
this opens the possibility of reloading the driver at runtime:

This doesn't actually work: clocks are never removed and attempting to
bind again results in registration errors and a crash.

Fix this by explicitly suppressing bind attrs like several other
drivers.

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>

---
No cc: stable because because there are likely many other opportunities
to crash the system by echoing random stuff in sysfs as root.

 drivers/clk/imx/clk-imx8mm.c | 1 +
 drivers/clk/imx/clk-imx8mn.c | 1 +
 drivers/clk/imx/clk-imx8mq.c | 1 +
 3 files changed, 3 insertions(+)

diff --git a/drivers/clk/imx/clk-imx8mm.c b/drivers/clk/imx/clk-imx8mm.c
index 9246e89bb5fd..3cb75ad4270d 100644
--- a/drivers/clk/imx/clk-imx8mm.c
+++ b/drivers/clk/imx/clk-imx8mm.c
@@ -619,9 +619,10 @@ MODULE_DEVICE_TABLE(of, imx8mm_clk_of_match);
 
 static struct platform_driver imx8mm_clk_driver = {
 	.probe = imx8mm_clocks_probe,
 	.driver = {
 		.name = "imx8mm-ccm",
+		.suppress_bind_attrs = true,
 		.of_match_table = of_match_ptr(imx8mm_clk_of_match),
 	},
 };
 module_platform_driver(imx8mm_clk_driver);
diff --git a/drivers/clk/imx/clk-imx8mn.c b/drivers/clk/imx/clk-imx8mn.c
index 4749beab9fc8..d16530430ac2 100644
--- a/drivers/clk/imx/clk-imx8mn.c
+++ b/drivers/clk/imx/clk-imx8mn.c
@@ -576,9 +576,10 @@ MODULE_DEVICE_TABLE(of, imx8mn_clk_of_match);
 
 static struct platform_driver imx8mn_clk_driver = {
 	.probe = imx8mn_clocks_probe,
 	.driver = {
 		.name = "imx8mn-ccm",
+		.suppress_bind_attrs = true,
 		.of_match_table = of_match_ptr(imx8mn_clk_of_match),
 	},
 };
 module_platform_driver(imx8mn_clk_driver);
diff --git a/drivers/clk/imx/clk-imx8mq.c b/drivers/clk/imx/clk-imx8mq.c
index c8ab86fcba7c..0e0f69e881bd 100644
--- a/drivers/clk/imx/clk-imx8mq.c
+++ b/drivers/clk/imx/clk-imx8mq.c
@@ -611,9 +611,10 @@ MODULE_DEVICE_TABLE(of, imx8mq_clk_of_match);
 
 static struct platform_driver imx8mq_clk_driver = {
 	.probe = imx8mq_clocks_probe,
 	.driver = {
 		.name = "imx8mq-ccm",
+		.suppress_bind_attrs = true,
 		.of_match_table = of_match_ptr(imx8mq_clk_of_match),
 	},
 };
 module_platform_driver(imx8mq_clk_driver);
-- 
2.17.1


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

* Re: [PATCH] clk: imx8m: Suppress bind attrs
  2019-11-18 22:28 [PATCH] clk: imx8m: Suppress bind attrs Leonard Crestez
@ 2019-11-19  7:09 ` Uwe Kleine-König
  2019-11-19 14:23   ` Leonard Crestez
  2019-11-19  9:11 ` Peng Fan
  1 sibling, 1 reply; 7+ messages in thread
From: Uwe Kleine-König @ 2019-11-19  7:09 UTC (permalink / raw)
  To: Leonard Crestez
  Cc: Stephen Boyd, Shawn Guo, Dong Aisheng, Peng Fan, Jacky Bai,
	Anson Huang, Michael Turquette, linux-imx, kernel, Fabio Estevam,
	linux-clk, linux-arm-kernel, Abel Vesa

On Tue, Nov 19, 2019 at 12:28:16AM +0200, Leonard Crestez wrote:
> The clock drivers on imx8m series are registered as platform devices and
> this opens the possibility of reloading the driver at runtime:
> 
> This doesn't actually work: clocks are never removed and attempting to
> bind again results in registration errors and a crash.
> 
> Fix this by explicitly suppressing bind attrs like several other
> drivers.
> 
> Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
> 
> ---
> No cc: stable because because there are likely many other opportunities
> to crash the system by echoing random stuff in sysfs as root.
> 
>  drivers/clk/imx/clk-imx8mm.c | 1 +
>  drivers/clk/imx/clk-imx8mn.c | 1 +
>  drivers/clk/imx/clk-imx8mq.c | 1 +
>  3 files changed, 3 insertions(+)
> 
> diff --git a/drivers/clk/imx/clk-imx8mm.c b/drivers/clk/imx/clk-imx8mm.c
> index 9246e89bb5fd..3cb75ad4270d 100644
> --- a/drivers/clk/imx/clk-imx8mm.c
> +++ b/drivers/clk/imx/clk-imx8mm.c
> @@ -619,9 +619,10 @@ MODULE_DEVICE_TABLE(of, imx8mm_clk_of_match);
>  
>  static struct platform_driver imx8mm_clk_driver = {
>  	.probe = imx8mm_clocks_probe,
>  	.driver = {
>  		.name = "imx8mm-ccm",
> +		.suppress_bind_attrs = true,

Maybe add a comment similar to the motivation in the commit log here?
(And of course in the other files, too.)

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

* RE: [PATCH] clk: imx8m: Suppress bind attrs
  2019-11-18 22:28 [PATCH] clk: imx8m: Suppress bind attrs Leonard Crestez
  2019-11-19  7:09 ` Uwe Kleine-König
@ 2019-11-19  9:11 ` Peng Fan
  1 sibling, 0 replies; 7+ messages in thread
From: Peng Fan @ 2019-11-19  9:11 UTC (permalink / raw)
  To: Leonard Crestez, Stephen Boyd, Shawn Guo
  Cc: Michael Turquette, Jacky Bai, Anson Huang, Abel Vesa,
	Aisheng Dong, Fabio Estevam, linux-clk, linux-arm-kernel,
	dl-linux-imx, kernel

> Subject: [PATCH] clk: imx8m: Suppress bind attrs
> 
> The clock drivers on imx8m series are registered as platform devices and this
> opens the possibility of reloading the driver at runtime:
> 
> This doesn't actually work: clocks are never removed and attempting to bind
> again results in registration errors and a crash.
> 
> Fix this by explicitly suppressing bind attrs like several other drivers.
> 
> Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>

Reviewed-by: Peng Fan <peng.fan@nxp.com>

> 
> ---
> No cc: stable because because there are likely many other opportunities to
> crash the system by echoing random stuff in sysfs as root.
> 
>  drivers/clk/imx/clk-imx8mm.c | 1 +
>  drivers/clk/imx/clk-imx8mn.c | 1 +
>  drivers/clk/imx/clk-imx8mq.c | 1 +
>  3 files changed, 3 insertions(+)
> 
> diff --git a/drivers/clk/imx/clk-imx8mm.c b/drivers/clk/imx/clk-imx8mm.c
> index 9246e89bb5fd..3cb75ad4270d 100644
> --- a/drivers/clk/imx/clk-imx8mm.c
> +++ b/drivers/clk/imx/clk-imx8mm.c
> @@ -619,9 +619,10 @@ MODULE_DEVICE_TABLE(of,
> imx8mm_clk_of_match);
> 
>  static struct platform_driver imx8mm_clk_driver = {
>  	.probe = imx8mm_clocks_probe,
>  	.driver = {
>  		.name = "imx8mm-ccm",
> +		.suppress_bind_attrs = true,
>  		.of_match_table = of_match_ptr(imx8mm_clk_of_match),
>  	},
>  };
>  module_platform_driver(imx8mm_clk_driver);
> diff --git a/drivers/clk/imx/clk-imx8mn.c b/drivers/clk/imx/clk-imx8mn.c
> index 4749beab9fc8..d16530430ac2 100644
> --- a/drivers/clk/imx/clk-imx8mn.c
> +++ b/drivers/clk/imx/clk-imx8mn.c
> @@ -576,9 +576,10 @@ MODULE_DEVICE_TABLE(of,
> imx8mn_clk_of_match);
> 
>  static struct platform_driver imx8mn_clk_driver = {
>  	.probe = imx8mn_clocks_probe,
>  	.driver = {
>  		.name = "imx8mn-ccm",
> +		.suppress_bind_attrs = true,
>  		.of_match_table = of_match_ptr(imx8mn_clk_of_match),
>  	},
>  };
>  module_platform_driver(imx8mn_clk_driver);
> diff --git a/drivers/clk/imx/clk-imx8mq.c b/drivers/clk/imx/clk-imx8mq.c
> index c8ab86fcba7c..0e0f69e881bd 100644
> --- a/drivers/clk/imx/clk-imx8mq.c
> +++ b/drivers/clk/imx/clk-imx8mq.c
> @@ -611,9 +611,10 @@ MODULE_DEVICE_TABLE(of,
> imx8mq_clk_of_match);
> 
>  static struct platform_driver imx8mq_clk_driver = {
>  	.probe = imx8mq_clocks_probe,
>  	.driver = {
>  		.name = "imx8mq-ccm",
> +		.suppress_bind_attrs = true,
>  		.of_match_table = of_match_ptr(imx8mq_clk_of_match),
>  	},
>  };
>  module_platform_driver(imx8mq_clk_driver);
> --
> 2.17.1


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

* Re: [PATCH] clk: imx8m: Suppress bind attrs
  2019-11-19  7:09 ` Uwe Kleine-König
@ 2019-11-19 14:23   ` Leonard Crestez
  2019-11-19 15:06     ` Uwe Kleine-König
  0 siblings, 1 reply; 7+ messages in thread
From: Leonard Crestez @ 2019-11-19 14:23 UTC (permalink / raw)
  To: Uwe Kleine-König, Stephen Boyd
  Cc: Shawn Guo, Aisheng Dong, Peng Fan, Jacky Bai, Anson Huang,
	Michael Turquette, dl-linux-imx, kernel, Fabio Estevam,
	linux-clk, linux-arm-kernel, Abel Vesa

On 2019-11-19 9:09 AM, Uwe Kleine-König wrote:
> On Tue, Nov 19, 2019 at 12:28:16AM +0200, Leonard Crestez wrote:
>> The clock drivers on imx8m series are registered as platform devices and
>> this opens the possibility of reloading the driver at runtime:
>>
>> This doesn't actually work: clocks are never removed and attempting to
>> bind again results in registration errors and a crash.
>>
>> Fix this by explicitly suppressing bind attrs like several other
>> drivers.
>>
>> Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
>>
>> ---
>> No cc: stable because because there are likely many other opportunities
>> to crash the system by echoing random stuff in sysfs as root.
>>
>>   drivers/clk/imx/clk-imx8mm.c | 1 +
>>   drivers/clk/imx/clk-imx8mn.c | 1 +
>>   drivers/clk/imx/clk-imx8mq.c | 1 +
>>   3 files changed, 3 insertions(+)
>>
>> diff --git a/drivers/clk/imx/clk-imx8mm.c b/drivers/clk/imx/clk-imx8mm.c
>> index 9246e89bb5fd..3cb75ad4270d 100644
>> --- a/drivers/clk/imx/clk-imx8mm.c
>> +++ b/drivers/clk/imx/clk-imx8mm.c
>> @@ -619,9 +619,10 @@ MODULE_DEVICE_TABLE(of, imx8mm_clk_of_match);
>>   
>>   static struct platform_driver imx8mm_clk_driver = {
>>   	.probe = imx8mm_clocks_probe,
>>   	.driver = {
>>   		.name = "imx8mm-ccm",
>> +		.suppress_bind_attrs = true,
> 
> Maybe add a comment similar to the motivation in the commit log here?
> (And of course in the other files, too.)

Is it really useful to say "disable feature X because it doesn't work" 
right before disabling the feature?

--
Regards,
Leonard

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

* Re: [PATCH] clk: imx8m: Suppress bind attrs
  2019-11-19 14:23   ` Leonard Crestez
@ 2019-11-19 15:06     ` Uwe Kleine-König
  0 siblings, 0 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2019-11-19 15:06 UTC (permalink / raw)
  To: Leonard Crestez
  Cc: Stephen Boyd, Aisheng Dong, Peng Fan, Jacky Bai, Anson Huang,
	Michael Turquette, dl-linux-imx, kernel, Fabio Estevam,
	Shawn Guo, linux-clk, linux-arm-kernel, Abel Vesa

On Tue, Nov 19, 2019 at 02:23:08PM +0000, Leonard Crestez wrote:
> On 2019-11-19 9:09 AM, Uwe Kleine-König wrote:
> > On Tue, Nov 19, 2019 at 12:28:16AM +0200, Leonard Crestez wrote:
> >> The clock drivers on imx8m series are registered as platform devices and
> >> this opens the possibility of reloading the driver at runtime:
> >>
> >> This doesn't actually work: clocks are never removed and attempting to
> >> bind again results in registration errors and a crash.
> >>
> >> Fix this by explicitly suppressing bind attrs like several other
> >> drivers.
> >>
> >> Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
> >>
> >> ---
> >> No cc: stable because because there are likely many other opportunities
> >> to crash the system by echoing random stuff in sysfs as root.
> >>
> >>   drivers/clk/imx/clk-imx8mm.c | 1 +
> >>   drivers/clk/imx/clk-imx8mn.c | 1 +
> >>   drivers/clk/imx/clk-imx8mq.c | 1 +
> >>   3 files changed, 3 insertions(+)
> >>
> >> diff --git a/drivers/clk/imx/clk-imx8mm.c b/drivers/clk/imx/clk-imx8mm.c
> >> index 9246e89bb5fd..3cb75ad4270d 100644
> >> --- a/drivers/clk/imx/clk-imx8mm.c
> >> +++ b/drivers/clk/imx/clk-imx8mm.c
> >> @@ -619,9 +619,10 @@ MODULE_DEVICE_TABLE(of, imx8mm_clk_of_match);
> >>   
> >>   static struct platform_driver imx8mm_clk_driver = {
> >>   	.probe = imx8mm_clocks_probe,
> >>   	.driver = {
> >>   		.name = "imx8mm-ccm",
> >> +		.suppress_bind_attrs = true,
> > 
> > Maybe add a comment similar to the motivation in the commit log here?
> > (And of course in the other files, too.)
> 
> Is it really useful to say "disable feature X because it doesn't work" 
> right before disabling the feature?

No, but something like:

	/*
	 * disable bind attributes because clocks are never removed and
	 * attempting to rebind results in errors and a crash.
	 */

would be helpful. This way someone wondering about why this is disabled
gets at least an idea what to look for when changing something in that
area or while using the imx driver as a template for the next clock
driver.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

* Re: [PATCH] clk: imx8m: Suppress bind attrs
  2019-11-21 13:52 Leonard Crestez
@ 2019-12-09  2:36 ` Shawn Guo
  0 siblings, 0 replies; 7+ messages in thread
From: Shawn Guo @ 2019-12-09  2:36 UTC (permalink / raw)
  To: Leonard Crestez
  Cc: Stephen Boyd, Uwe Kleine-König, Jacky Bai, Anson Huang,
	Abel Vesa, Michael Turquette, Dong Aisheng, Fabio Estevam,
	Peng Fan, linux-clk, kernel, linux-imx, linux-arm-kernel

On Thu, Nov 21, 2019 at 03:52:17PM +0200, Leonard Crestez wrote:
> The clock drivers on imx8m series are registered as platform devices and
> this opens the possibility of reloading the driver at runtime.
> 
> This doesn't actually work: clocks are never removed and attempting to
> bind again results in registration errors and a crash. Almost all
> devices depend on clocks anyway so rebinding is unlikely to ever be
> useful
> 
> Fix this by explicitly suppressing bind attrs like several other
> clock drivers.
> 
> Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
> Reviewed-by: Peng Fan <peng.fan@nxp.com>

Applied, thanks.

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

* [PATCH] clk: imx8m: Suppress bind attrs
@ 2019-11-21 13:52 Leonard Crestez
  2019-12-09  2:36 ` Shawn Guo
  0 siblings, 1 reply; 7+ messages in thread
From: Leonard Crestez @ 2019-11-21 13:52 UTC (permalink / raw)
  To: Stephen Boyd, Shawn Guo, Uwe Kleine-König
  Cc: Jacky Bai, Anson Huang, Abel Vesa, Michael Turquette,
	Dong Aisheng, Fabio Estevam, Peng Fan, linux-clk, kernel,
	linux-imx, linux-arm-kernel

The clock drivers on imx8m series are registered as platform devices and
this opens the possibility of reloading the driver at runtime.

This doesn't actually work: clocks are never removed and attempting to
bind again results in registration errors and a crash. Almost all
devices depend on clocks anyway so rebinding is unlikely to ever be
useful

Fix this by explicitly suppressing bind attrs like several other
clock drivers.

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>

---
No cc: stable because because there are likely many other opportunities
to crash the system by echoing random stuff in sysfs as root.

Changes since v1:
* Add source comments as well
Link to v1: https://patchwork.kernel.org/patch/11250389/

 drivers/clk/imx/clk-imx8mm.c | 5 +++++
 drivers/clk/imx/clk-imx8mn.c | 5 +++++
 drivers/clk/imx/clk-imx8mq.c | 5 +++++
 3 files changed, 15 insertions(+)

diff --git a/drivers/clk/imx/clk-imx8mm.c b/drivers/clk/imx/clk-imx8mm.c
index 030b15d7c0ce..ed3ce492151c 100644
--- a/drivers/clk/imx/clk-imx8mm.c
+++ b/drivers/clk/imx/clk-imx8mm.c
@@ -614,9 +614,14 @@ MODULE_DEVICE_TABLE(of, imx8mm_clk_of_match);
 
 static struct platform_driver imx8mm_clk_driver = {
 	.probe = imx8mm_clocks_probe,
 	.driver = {
 		.name = "imx8mm-ccm",
+		/*
+		 * Disable bind attributes: clocks are not removed and
+		 * reloading the driver will crash or break devices.
+		 */
+		.suppress_bind_attrs = true,
 		.of_match_table = of_match_ptr(imx8mm_clk_of_match),
 	},
 };
 module_platform_driver(imx8mm_clk_driver);
diff --git a/drivers/clk/imx/clk-imx8mn.c b/drivers/clk/imx/clk-imx8mn.c
index 9f5a5a56b45e..d95e282ff1fb 100644
--- a/drivers/clk/imx/clk-imx8mn.c
+++ b/drivers/clk/imx/clk-imx8mn.c
@@ -570,9 +570,14 @@ MODULE_DEVICE_TABLE(of, imx8mn_clk_of_match);
 
 static struct platform_driver imx8mn_clk_driver = {
 	.probe = imx8mn_clocks_probe,
 	.driver = {
 		.name = "imx8mn-ccm",
+		/*
+		 * Disable bind attributes: clocks are not removed and
+		 * reloading the driver will crash or break devices.
+		 */
+		.suppress_bind_attrs = true,
 		.of_match_table = of_match_ptr(imx8mn_clk_of_match),
 	},
 };
 module_platform_driver(imx8mn_clk_driver);
diff --git a/drivers/clk/imx/clk-imx8mq.c b/drivers/clk/imx/clk-imx8mq.c
index 5f10a606d836..2168fe6cf7e4 100644
--- a/drivers/clk/imx/clk-imx8mq.c
+++ b/drivers/clk/imx/clk-imx8mq.c
@@ -607,9 +607,14 @@ MODULE_DEVICE_TABLE(of, imx8mq_clk_of_match);
 
 static struct platform_driver imx8mq_clk_driver = {
 	.probe = imx8mq_clocks_probe,
 	.driver = {
 		.name = "imx8mq-ccm",
+		/*
+		 * Disable bind attributes: clocks are not removed and
+		 * reloading the driver will crash or break devices.
+		 */
+		.suppress_bind_attrs = true,
 		.of_match_table = of_match_ptr(imx8mq_clk_of_match),
 	},
 };
 module_platform_driver(imx8mq_clk_driver);
-- 
2.17.1


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

end of thread, other threads:[~2019-12-09  2:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18 22:28 [PATCH] clk: imx8m: Suppress bind attrs Leonard Crestez
2019-11-19  7:09 ` Uwe Kleine-König
2019-11-19 14:23   ` Leonard Crestez
2019-11-19 15:06     ` Uwe Kleine-König
2019-11-19  9:11 ` Peng Fan
2019-11-21 13:52 Leonard Crestez
2019-12-09  2:36 ` Shawn Guo

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).