diff mbox series

[RFC] soc: qcom: rpmpd: Allow RPMPD driver to be loaded as a module

Message ID 20200305054244.128950-1-john.stultz@linaro.org (mailing list archive)
State Superseded
Headers show
Series [RFC] soc: qcom: rpmpd: Allow RPMPD driver to be loaded as a module | expand

Commit Message

John Stultz March 5, 2020, 5:42 a.m. UTC
Allow the rpmpd driver to be loaded as a module.

Cc: Todd Kjos <tkjos@google.com>
Cc: Saravana Kannan <saravanak@google.com>
Cc: Andy Gross <agross@kernel.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: linux-arm-msm@vger.kernel.org
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 drivers/soc/qcom/Kconfig | 4 ++--
 drivers/soc/qcom/rpmpd.c | 5 ++++-
 2 files changed, 6 insertions(+), 3 deletions(-)

Comments

Bjorn Andersson March 5, 2020, 6:32 a.m. UTC | #1
On Wed 04 Mar 21:42 PST 2020, John Stultz wrote:

> Allow the rpmpd driver to be loaded as a module.
> 
> Cc: Todd Kjos <tkjos@google.com>
> Cc: Saravana Kannan <saravanak@google.com>
> Cc: Andy Gross <agross@kernel.org>
> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
> Cc: linux-arm-msm@vger.kernel.org
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> ---
>  drivers/soc/qcom/Kconfig | 4 ++--
>  drivers/soc/qcom/rpmpd.c | 5 ++++-
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
> index d0a73e76d563..af774555b9d2 100644
> --- a/drivers/soc/qcom/Kconfig
> +++ b/drivers/soc/qcom/Kconfig
> @@ -123,8 +123,8 @@ config QCOM_RPMHPD
>  	  for the voltage rail.
>  
>  config QCOM_RPMPD
> -	bool "Qualcomm RPM Power domain driver"
> -	depends on QCOM_SMD_RPM=y
> +	tristate "Qualcomm RPM Power domain driver"
> +	depends on QCOM_SMD_RPM
>  	help
>  	  QCOM RPM Power domain driver to support power-domains with
>  	  performance states. The driver communicates a performance state
> diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c
> index 2b1834c5609a..9c0834913f3f 100644
> --- a/drivers/soc/qcom/rpmpd.c
> +++ b/drivers/soc/qcom/rpmpd.c
> @@ -5,6 +5,7 @@
>  #include <linux/init.h>
>  #include <linux/kernel.h>
>  #include <linux/mutex.h>
> +#include <linux/module.h>
>  #include <linux/pm_domain.h>
>  #include <linux/of.h>
>  #include <linux/of_device.h>
> @@ -226,6 +227,7 @@ static const struct of_device_id rpmpd_match_table[] = {
>  	{ .compatible = "qcom,qcs404-rpmpd", .data = &qcs404_desc },
>  	{ }
>  };
> +MODULE_DEVICE_TABLE(of, rpmpd_match_table);
>  
>  static int rpmpd_send_enable(struct rpmpd *pd, bool enable)
>  {
> @@ -421,4 +423,5 @@ static int __init rpmpd_init(void)
>  {
>  	return platform_driver_register(&rpmpd_driver);
>  }
> -core_initcall(rpmpd_init);
> +module_init(rpmpd_init);

Can't you keep this as core_initcall(), for the times when its builtin?

Additionally I believe you should add a call to unregister the driver,
and drop the suppress_bind_attrs.

> +MODULE_LICENSE("GPL");

"GPL v2" per the SPDX?

Regards,
Bjorn

> -- 
> 2.17.1
>
Rajendra Nayak March 5, 2020, 6:37 a.m. UTC | #2
On 3/5/2020 11:12 AM, John Stultz wrote:
> Allow the rpmpd driver to be loaded as a module.

The last time I tried this [1], I hit a limitation with pm_genpd_remove not cleaning up things right,
is that solved now?

[1] https://lkml.org/lkml/2019/1/17/1043

> 
> Cc: Todd Kjos <tkjos@google.com>
> Cc: Saravana Kannan <saravanak@google.com>
> Cc: Andy Gross <agross@kernel.org>
> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
> Cc: linux-arm-msm@vger.kernel.org
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> ---
>   drivers/soc/qcom/Kconfig | 4 ++--
>   drivers/soc/qcom/rpmpd.c | 5 ++++-
>   2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
> index d0a73e76d563..af774555b9d2 100644
> --- a/drivers/soc/qcom/Kconfig
> +++ b/drivers/soc/qcom/Kconfig
> @@ -123,8 +123,8 @@ config QCOM_RPMHPD
>   	  for the voltage rail.
>   
>   config QCOM_RPMPD
> -	bool "Qualcomm RPM Power domain driver"
> -	depends on QCOM_SMD_RPM=y
> +	tristate "Qualcomm RPM Power domain driver"
> +	depends on QCOM_SMD_RPM
>   	help
>   	  QCOM RPM Power domain driver to support power-domains with
>   	  performance states. The driver communicates a performance state
> diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c
> index 2b1834c5609a..9c0834913f3f 100644
> --- a/drivers/soc/qcom/rpmpd.c
> +++ b/drivers/soc/qcom/rpmpd.c
> @@ -5,6 +5,7 @@
>   #include <linux/init.h>
>   #include <linux/kernel.h>
>   #include <linux/mutex.h>
> +#include <linux/module.h>
>   #include <linux/pm_domain.h>
>   #include <linux/of.h>
>   #include <linux/of_device.h>
> @@ -226,6 +227,7 @@ static const struct of_device_id rpmpd_match_table[] = {
>   	{ .compatible = "qcom,qcs404-rpmpd", .data = &qcs404_desc },
>   	{ }
>   };
> +MODULE_DEVICE_TABLE(of, rpmpd_match_table);
>   
>   static int rpmpd_send_enable(struct rpmpd *pd, bool enable)
>   {
> @@ -421,4 +423,5 @@ static int __init rpmpd_init(void)
>   {
>   	return platform_driver_register(&rpmpd_driver);
>   }
> -core_initcall(rpmpd_init);
> +module_init(rpmpd_init);
> +MODULE_LICENSE("GPL");
>
Rajendra Nayak March 5, 2020, 6:56 a.m. UTC | #3
>> -core_initcall(rpmpd_init);
>> +module_init(rpmpd_init);
> 
> Can't you keep this as core_initcall(), for the times when its builtin?
> 
> Additionally I believe you should add a call to unregister the driver,

and implement a .remove?

> and drop the suppress_bind_attrs.
> 
>> +MODULE_LICENSE("GPL");
> 
> "GPL v2" per the SPDX?
> 
> Regards,
> Bjorn
> 
>> -- 
>> 2.17.1
>>
John Stultz March 18, 2020, 7:36 p.m. UTC | #4
On Wed, Mar 4, 2020 at 10:32 PM Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> On Wed 04 Mar 21:42 PST 2020, John Stultz wrote:
>
> > Allow the rpmpd driver to be loaded as a module.
> >
...
> > diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c
> > index 2b1834c5609a..9c0834913f3f 100644
> > --- a/drivers/soc/qcom/rpmpd.c
> > +++ b/drivers/soc/qcom/rpmpd.c
> > @@ -5,6 +5,7 @@
> >  #include <linux/init.h>
> >  #include <linux/kernel.h>
> >  #include <linux/mutex.h>
> > +#include <linux/module.h>
> >  #include <linux/pm_domain.h>
> >  #include <linux/of.h>
> >  #include <linux/of_device.h>
> > @@ -226,6 +227,7 @@ static const struct of_device_id rpmpd_match_table[] = {
> >       { .compatible = "qcom,qcs404-rpmpd", .data = &qcs404_desc },
> >       { }
> >  };
> > +MODULE_DEVICE_TABLE(of, rpmpd_match_table);
> >
> >  static int rpmpd_send_enable(struct rpmpd *pd, bool enable)
> >  {
> > @@ -421,4 +423,5 @@ static int __init rpmpd_init(void)
> >  {
> >       return platform_driver_register(&rpmpd_driver);
> >  }
> > -core_initcall(rpmpd_init);
> > +module_init(rpmpd_init);
>
> Can't you keep this as core_initcall(), for the times when its builtin?

Sure!

> Additionally I believe you should add a call to unregister the driver,
> and drop the suppress_bind_attrs.

So, I sort of took the simple swing here as adding it as a module w/o
a unregister makes it a "permanent" module. It loads but cannot be
unloaded. I know this isn't ideal, but it's also a big improvement
over it being limited to it being required as a built-in.  I'll take a
look at it though to see if its workable to be removable.

> > +MODULE_LICENSE("GPL");
>
> "GPL v2" per the SPDX?

Ah. Thanks, fixed!

thanks again for the review
-john
John Stultz March 18, 2020, 7:38 p.m. UTC | #5
On Wed, Mar 4, 2020 at 10:37 PM Rajendra Nayak <rnayak@codeaurora.org> wrote:
>
>
> On 3/5/2020 11:12 AM, John Stultz wrote:
> > Allow the rpmpd driver to be loaded as a module.
>
> The last time I tried this [1], I hit a limitation with pm_genpd_remove not cleaning up things right,
> is that solved now?
>
> [1] https://lkml.org/lkml/2019/1/17/1043
>

As I mentioned to Bjorn, I'll dig into this a bit to see if its
doable, but having it being a permanent/unloadable module is still an
improvement from it being stuck as a built in only.

thanks
-john
diff mbox series

Patch

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index d0a73e76d563..af774555b9d2 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -123,8 +123,8 @@  config QCOM_RPMHPD
 	  for the voltage rail.
 
 config QCOM_RPMPD
-	bool "Qualcomm RPM Power domain driver"
-	depends on QCOM_SMD_RPM=y
+	tristate "Qualcomm RPM Power domain driver"
+	depends on QCOM_SMD_RPM
 	help
 	  QCOM RPM Power domain driver to support power-domains with
 	  performance states. The driver communicates a performance state
diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c
index 2b1834c5609a..9c0834913f3f 100644
--- a/drivers/soc/qcom/rpmpd.c
+++ b/drivers/soc/qcom/rpmpd.c
@@ -5,6 +5,7 @@ 
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/mutex.h>
+#include <linux/module.h>
 #include <linux/pm_domain.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -226,6 +227,7 @@  static const struct of_device_id rpmpd_match_table[] = {
 	{ .compatible = "qcom,qcs404-rpmpd", .data = &qcs404_desc },
 	{ }
 };
+MODULE_DEVICE_TABLE(of, rpmpd_match_table);
 
 static int rpmpd_send_enable(struct rpmpd *pd, bool enable)
 {
@@ -421,4 +423,5 @@  static int __init rpmpd_init(void)
 {
 	return platform_driver_register(&rpmpd_driver);
 }
-core_initcall(rpmpd_init);
+module_init(rpmpd_init);
+MODULE_LICENSE("GPL");