2023-09-18 13:24:34

by Raag Jadav

[permalink] [raw]
Subject: [PATCH for-next v2 00/10] Fix symbol export for _SIMPLE_ variants of _PM_OPS()

Currently EXPORT_*_SIMPLE_DEV_PM_OPS() use EXPORT_*_DEV_PM_OPS() set of
macros to export dev_pm_ops symbol, which export the symbol in case
CONFIG_PM=y but don't take CONFIG_PM_SLEEP into consideration.

Since _SIMPLE_ variants of _PM_OPS() do not include runtime PM handles
and are only used in case CONFIG_PM_SLEEP=y, we should not be exporting
dev_pm_ops symbol for them in case CONFIG_PM_SLEEP=n.

This can be fixed by having two distinct set of export macros for both
_RUNTIME_ and _SIMPLE_ variants of _PM_OPS(), such that the export of
dev_pm_ops symbol used in each variant depends on CONFIG_PM and
CONFIG_PM_SLEEP respectively.

Changes since v1:
- Update drivers to new set of macros

Raag Jadav (10):
PM: Introduce export macros for _SIMPLE_ variants of _PM_OPS()
PM: Update EXPORT_*_DEV_PM_OPS() to EXPORT_*_RUNTIME_PM_OPS()
iio: accel: fxls8962af: convert to EXPORT_NS_GPL_RUNTIME_PM_OPS()
iio: gyro: fxas21002c: convert to EXPORT_NS_GPL_RUNTIME_PM_OPS()
iio: imu: inv_icm42600: convert to EXPORT_NS_GPL_RUNTIME_PM_OPS()
iio: imu: inv_mpu: convert to EXPORT_NS_GPL_RUNTIME_PM_OPS()
drm/imx/dcss: convert to EXPORT_GPL_RUNTIME_PM_OPS()
mfd: arizona: convert to EXPORT_GPL_RUNTIME_PM_OPS()
mfd: cs42l43: convert to EXPORT_NS_GPL_RUNTIME_PM_OPS()
ASoC: cs35l41: convert to EXPORT_GPL_RUNTIME_PM_OPS()

drivers/gpu/drm/imx/dcss/dcss-dev.c | 2 +-
drivers/iio/accel/fxls8962af-core.c | 2 +-
drivers/iio/gyro/fxas21002c_core.c | 2 +-
.../iio/imu/inv_icm42600/inv_icm42600_core.c | 2 +-
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 2 +-
drivers/mfd/arizona-core.c | 2 +-
drivers/mfd/cs42l43.c | 2 +-
include/linux/pm.h | 38 ++++++++++++-------
include/linux/pm_runtime.h | 13 +++++--
sound/soc/codecs/cs35l41.c | 2 +-
10 files changed, 41 insertions(+), 26 deletions(-)

--
2.17.1


2023-09-18 13:25:35

by Raag Jadav

[permalink] [raw]
Subject: [PATCH for-next v2 09/10] mfd: cs42l43: convert to EXPORT_NS_GPL_RUNTIME_PM_OPS()

With original macro being renamed to EXPORT_NS_GPL_RUNTIME_PM_OPS(),
use the new macro.

Signed-off-by: Raag Jadav <[email protected]>
---
drivers/mfd/cs42l43.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/cs42l43.c b/drivers/mfd/cs42l43.c
index 37b23e9bae82..b84adde9f89e 100644
--- a/drivers/mfd/cs42l43.c
+++ b/drivers/mfd/cs42l43.c
@@ -1177,7 +1177,7 @@ static int cs42l43_runtime_resume(struct device *dev)
return ret;
}

-EXPORT_NS_GPL_DEV_PM_OPS(cs42l43_pm_ops, MFD_CS42L43) = {
+EXPORT_NS_GPL_RUNTIME_PM_OPS(cs42l43_pm_ops, MFD_CS42L43) = {
SET_SYSTEM_SLEEP_PM_OPS(cs42l43_suspend, cs42l43_resume)
SET_RUNTIME_PM_OPS(cs42l43_runtime_suspend, cs42l43_runtime_resume, NULL)
};
--
2.17.1

2023-09-18 13:26:47

by Raag Jadav

[permalink] [raw]
Subject: [PATCH for-next v2 02/10] PM: Update EXPORT_*_DEV_PM_OPS() to EXPORT_*_RUNTIME_PM_OPS()

Rename EXPORT_*_DEV_PM_OPS() macros to EXPORT_*_RUNTIME_PM_OPS()
and while at it, move them to pm_runtime.h.
This is done in conjunction with the introduction of
EXPORT_*_SIMPLE_PM_OPS() set of macros, to make things less confusing.
This makes both _RUNTIME_ and _SIMPLE_ variants of export macros more
distinguishable and self explanatory.

Signed-off-by: Raag Jadav <[email protected]>
---
include/linux/pm.h | 5 -----
include/linux/pm_runtime.h | 13 +++++++++----
2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/linux/pm.h b/include/linux/pm.h
index 6e7ab6950ad1..9ab051f3a351 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -398,11 +398,6 @@ const struct dev_pm_ops name = { \
#define _EXPORT_SIMPLE_PM_OPS(name, license, ns) _PM_OPS(name, license, ns)
#endif

-#define EXPORT_DEV_PM_OPS(name) _EXPORT_RUNTIME_PM_OPS(name, "", "")
-#define EXPORT_GPL_DEV_PM_OPS(name) _EXPORT_RUNTIME_PM_OPS(name, "GPL", "")
-#define EXPORT_NS_DEV_PM_OPS(name, ns) _EXPORT_RUNTIME_PM_OPS(name, "", #ns)
-#define EXPORT_NS_GPL_DEV_PM_OPS(name, ns) _EXPORT_RUNTIME_PM_OPS(name, "GPL", #ns)
-
#define EXPORT_SIMPLE_PM_OPS(name) _EXPORT_SIMPLE_PM_OPS(name, "", "")
#define EXPORT_GPL_SIMPLE_PM_OPS(name) _EXPORT_SIMPLE_PM_OPS(name, "GPL", "")
#define EXPORT_NS_SIMPLE_PM_OPS(name, ns) _EXPORT_SIMPLE_PM_OPS(name, "", #ns)
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index 7c9b35448563..0b73b00bd59f 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -22,6 +22,11 @@
usage_count */
#define RPM_AUTO 0x08 /* Use autosuspend_delay */

+#define EXPORT_RUNTIME_PM_OPS(name) _EXPORT_RUNTIME_PM_OPS(name, "", "")
+#define EXPORT_GPL_RUNTIME_PM_OPS(name) _EXPORT_RUNTIME_PM_OPS(name, "GPL", "")
+#define EXPORT_NS_RUNTIME_PM_OPS(name, ns) _EXPORT_RUNTIME_PM_OPS(name, "", #ns)
+#define EXPORT_NS_GPL_RUNTIME_PM_OPS(name, ns) _EXPORT_RUNTIME_PM_OPS(name, "GPL", #ns)
+
/*
* Use this for defining a set of PM operations to be used in all situations
* (system suspend, hibernation or runtime PM).
@@ -40,19 +45,19 @@
resume_fn, idle_fn)

#define EXPORT_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
- EXPORT_DEV_PM_OPS(name) = { \
+ EXPORT_RUNTIME_PM_OPS(name) = { \
RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
}
#define EXPORT_GPL_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
- EXPORT_GPL_DEV_PM_OPS(name) = { \
+ EXPORT_GPL_RUNTIME_PM_OPS(name) = { \
RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
}
#define EXPORT_NS_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn, ns) \
- EXPORT_NS_DEV_PM_OPS(name, ns) = { \
+ EXPORT_NS_RUNTIME_PM_OPS(name, ns) = { \
RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
}
#define EXPORT_NS_GPL_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn, ns) \
- EXPORT_NS_GPL_DEV_PM_OPS(name, ns) = { \
+ EXPORT_NS_GPL_RUNTIME_PM_OPS(name, ns) = { \
RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
}

--
2.17.1

2023-09-18 13:31:20

by Raag Jadav

[permalink] [raw]
Subject: [PATCH for-next v2 10/10] ASoC: cs35l41: convert to EXPORT_GPL_RUNTIME_PM_OPS()

With original macro being renamed to EXPORT_GPL_RUNTIME_PM_OPS(),
use the new macro.

Signed-off-by: Raag Jadav <[email protected]>
---
sound/soc/codecs/cs35l41.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c
index 4bc64ba71cd6..651aeaa6a5c4 100644
--- a/sound/soc/codecs/cs35l41.c
+++ b/sound/soc/codecs/cs35l41.c
@@ -1454,7 +1454,7 @@ static int cs35l41_sys_resume(struct device *dev)
return 0;
}

-EXPORT_GPL_DEV_PM_OPS(cs35l41_pm_ops) = {
+EXPORT_GPL_RUNTIME_PM_OPS(cs35l41_pm_ops) = {
RUNTIME_PM_OPS(cs35l41_runtime_suspend, cs35l41_runtime_resume, NULL)

SYSTEM_SLEEP_PM_OPS(cs35l41_sys_suspend, cs35l41_sys_resume)
--
2.17.1

2023-09-18 16:15:52

by Raag Jadav

[permalink] [raw]
Subject: Re: [PATCH for-next v2 02/10] PM: Update EXPORT_*_DEV_PM_OPS() to EXPORT_*_RUNTIME_PM_OPS()

On Mon, Sep 18, 2023 at 10:20:29AM +0200, Paul Cercueil wrote:
> Le lundi 18 septembre 2023 ? 13:39 +0530, Raag Jadav a ?crit?:
> > Rename EXPORT_*_DEV_PM_OPS() macros to EXPORT_*_RUNTIME_PM_OPS()
> > and while at it, move them to pm_runtime.h.
> > This is done in conjunction with the introduction of
> > EXPORT_*_SIMPLE_PM_OPS() set of macros, to make things less
> > confusing.
> > This makes both _RUNTIME_ and _SIMPLE_ variants of export macros more
> > distinguishable and self explanatory.
>
> Well I don't really agree with this one. The EXPORT_*_DEV_PM_OPS() can
> be used with any callback you need, not just the typical runtime-PM
> callbacks. They are generic PM macros.

I agree on the usage part. But with the introduction of export macros for
_SIMPLE_ variants, current naming scheme would make things unnecessarily
confusing to the users in my opinion.

Perhaps we can have it simplified some other way?

Raag

2023-09-18 17:17:38

by Raag Jadav

[permalink] [raw]
Subject: [PATCH for-next v2 06/10] iio: imu: inv_mpu: convert to EXPORT_NS_GPL_RUNTIME_PM_OPS()

With original macro being renamed to EXPORT_NS_GPL_RUNTIME_PM_OPS(),
use the new macro.

Signed-off-by: Raag Jadav <[email protected]>
---
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 29f906c884bd..3872514538b7 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -1795,7 +1795,7 @@ static int inv_mpu_runtime_resume(struct device *dev)
return inv_mpu6050_set_power_itg(st, true);
}

-EXPORT_NS_GPL_DEV_PM_OPS(inv_mpu_pmops, IIO_MPU6050) = {
+EXPORT_NS_GPL_RUNTIME_PM_OPS(inv_mpu_pmops, IIO_MPU6050) = {
SYSTEM_SLEEP_PM_OPS(inv_mpu_suspend, inv_mpu_resume)
RUNTIME_PM_OPS(inv_mpu_runtime_suspend, inv_mpu_runtime_resume, NULL)
};
--
2.17.1

2023-09-18 19:29:20

by Paul Cercueil

[permalink] [raw]
Subject: Re: [PATCH for-next v2 02/10] PM: Update EXPORT_*_DEV_PM_OPS() to EXPORT_*_RUNTIME_PM_OPS()

Hi Raag,

Le lundi 18 septembre 2023 à 13:39 +0530, Raag Jadav a écrit :
> Rename EXPORT_*_DEV_PM_OPS() macros to EXPORT_*_RUNTIME_PM_OPS()
> and while at it, move them to pm_runtime.h.
> This is done in conjunction with the introduction of
> EXPORT_*_SIMPLE_PM_OPS() set of macros, to make things less
> confusing.
> This makes both _RUNTIME_ and _SIMPLE_ variants of export macros more
> distinguishable and self explanatory.

Well I don't really agree with this one. The EXPORT_*_DEV_PM_OPS() can
be used with any callback you need, not just the typical runtime-PM
callbacks. They are generic PM macros.

Cheers,
-Paul

>
> Signed-off-by: Raag Jadav <[email protected]>
> ---
>  include/linux/pm.h         |  5 -----
>  include/linux/pm_runtime.h | 13 +++++++++----
>  2 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/pm.h b/include/linux/pm.h
> index 6e7ab6950ad1..9ab051f3a351 100644
> --- a/include/linux/pm.h
> +++ b/include/linux/pm.h
> @@ -398,11 +398,6 @@ const struct dev_pm_ops name = { \
>  #define _EXPORT_SIMPLE_PM_OPS(name, license, ns)       _PM_OPS(name,
> license, ns)
>  #endif
>  
> -#define
> EXPORT_DEV_PM_OPS(name)                                _EXPORT_RUNTIM
> E_PM_OPS(name, "", "")
> -#define
> EXPORT_GPL_DEV_PM_OPS(name)                    _EXPORT_RUNTIME_PM_OPS
> (name, "GPL", "")
> -#define EXPORT_NS_DEV_PM_OPS(name,
> ns)                 _EXPORT_RUNTIME_PM_OPS(name, "", #ns)
> -#define EXPORT_NS_GPL_DEV_PM_OPS(name,
> ns)             _EXPORT_RUNTIME_PM_OPS(name, "GPL", #ns)
> -
>  #define
> EXPORT_SIMPLE_PM_OPS(name)                     _EXPORT_SIMPLE_PM_OPS(
> name, "", "")
>  #define
> EXPORT_GPL_SIMPLE_PM_OPS(name)                 _EXPORT_SIMPLE_PM_OPS(
> name, "GPL", "")
>  #define EXPORT_NS_SIMPLE_PM_OPS(name,
> ns)              _EXPORT_SIMPLE_PM_OPS(name, "", #ns)
> diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
> index 7c9b35448563..0b73b00bd59f 100644
> --- a/include/linux/pm_runtime.h
> +++ b/include/linux/pm_runtime.h
> @@ -22,6 +22,11 @@
>                                             usage_count */
>  #define RPM_AUTO               0x08    /* Use autosuspend_delay */
>  
> +#define
> EXPORT_RUNTIME_PM_OPS(name)                    _EXPORT_RUNTIME_PM_OPS
> (name, "", "")
> +#define
> EXPORT_GPL_RUNTIME_PM_OPS(name)                        _EXPORT_RUNTIM
> E_PM_OPS(name, "GPL", "")
> +#define EXPORT_NS_RUNTIME_PM_OPS(name,
> ns)             _EXPORT_RUNTIME_PM_OPS(name, "", #ns)
> +#define EXPORT_NS_GPL_RUNTIME_PM_OPS(name,
> ns)         _EXPORT_RUNTIME_PM_OPS(name, "GPL", #ns)
> +
>  /*
>   * Use this for defining a set of PM operations to be used in all
> situations
>   * (system suspend, hibernation or runtime PM).
> @@ -40,19 +45,19 @@
>                            resume_fn, idle_fn)
>  
>  #define EXPORT_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn,
> idle_fn) \
> -       EXPORT_DEV_PM_OPS(name) = { \
> +       EXPORT_RUNTIME_PM_OPS(name) = { \
>                 RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
>         }
>  #define EXPORT_GPL_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn,
> idle_fn) \
> -       EXPORT_GPL_DEV_PM_OPS(name) = { \
> +       EXPORT_GPL_RUNTIME_PM_OPS(name) = { \
>                 RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
>         }
>  #define EXPORT_NS_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn,
> idle_fn, ns) \
> -       EXPORT_NS_DEV_PM_OPS(name, ns) = { \
> +       EXPORT_NS_RUNTIME_PM_OPS(name, ns) = { \
>                 RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
>         }
>  #define EXPORT_NS_GPL_RUNTIME_DEV_PM_OPS(name, suspend_fn,
> resume_fn, idle_fn, ns) \
> -       EXPORT_NS_GPL_DEV_PM_OPS(name, ns) = { \
> +       EXPORT_NS_GPL_RUNTIME_PM_OPS(name, ns) = { \
>                 RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
>         }
>