Introduce devm_pm_opp_* API
Subsystems (20)
v2 cover Introduce devm_pm_opp_* API
This series adds resource-managed OPP API helpers and makes drivers to use them.
Changelog:
v2: - This is a continuation of the work that was started by Yangtao Li.
Apparently Yangtao doesn't have time to finish it, so I (Dmitry Osipenko) picked up the effort since these patches are wanted by the NVIDIA Tegra voltage-scaling series that I'm working on.
- Fixed the double put of OPP resources.
- Dropped all patches that are unrelated to OPP API. I also dropped the Tegra memory patch since it doesn't apply now and because I plan to switch all Tegra drivers soon to a common tegra-specific OPP helper that will use the resource-managed OPP API anyways.
- Squashed couple patches into a single ones since there was no good reason to separate them.
- Added acks that were given to a couple of v1 patches.
Yangtao Li (14):
opp: Add devres wrapper for dev_pm_opp_set_clkname
opp: Add devres wrapper for dev_pm_opp_set_regulators
opp: Add devres wrapper for dev_pm_opp_set_supported_hw
opp: Add devres wrapper for dev_pm_opp_of_add_table
opp: Add devres wrapper for dev_pm_opp_register_notifier
serial: qcom_geni_serial: Convert to use resource-managed OPP API
spi: spi-geni-qcom: Convert to use resource-managed OPP API
spi: spi-qcom-qspi: Convert to use resource-managed OPP API
mmc: sdhci-msm: Convert to use resource-managed OPP API drm/msm: Convert to use resource-managed OPP API drm/lima: Convert to use resource-managed OPP API drm/panfrost: Convert to use resource-managed OPP API
media: venus: Convert to use resource-managed OPP API
memory: samsung: exynos5422-dmc: Convert to use resource-managed OPP
API
drivers/gpu/drm/lima/lima_devfreq.c | 43 ++--- drivers/gpu/drm/lima/lima_devfreq.h | 2 - drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 2 +- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 2 +- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 2 +- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 24 ++- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 2 - drivers/gpu/drm/msm/dp/dp_ctrl.c | 31 +--- drivers/gpu/drm/msm/dp/dp_ctrl.h | 1 - drivers/gpu/drm/msm/dp/dp_display.c | 5 +- drivers/gpu/drm/msm/dsi/dsi_host.c | 14 +- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 33 +--- drivers/gpu/drm/panfrost/panfrost_devfreq.h | 1 - .../media/platform/qcom/venus/pm_helpers.c | 18 +-- drivers/memory/samsung/exynos5422-dmc.c | 13 +- drivers/mmc/host/sdhci-msm.c | 20 +-- drivers/opp/core.c | 151 ++++++++++++++++++ drivers/opp/of.c | 36 +++++ drivers/spi/spi-geni-qcom.c | 17 +- drivers/spi/spi-qcom-qspi.c | 19 +-- drivers/tty/serial/qcom_geni_serial.c | 24 ++- include/linux/pm_opp.h | 34 ++++ include/linux/qcom-geni-se.h | 2 - 23 files changed, 300 insertions(+), 196 deletions(-)
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 1/14 opp: Add devres wrapper for dev_pm_opp_set_clkname
From: Yangtao Li <[email protected]>
Add devres wrapper for dev_pm_opp_set_clkname() to simplify drivers code.
--- drivers/opp/core.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 42 insertions(+)
drivers/opp/core.c +36 -0
@@ -2119,6 +2119,42 @@ void dev_pm_opp_put_clkname(struct opp_table *opp_table) }EXPORT_SYMBOL_GPL (dev_pm_opp_put_clkname); +static void devm_pm_opp_clkname_release (void *data) +{ +dev_pm_opp_put_clkname (data); +} + +/** +* devm_pm_opp_set_clkname() - Set clk name for the device +* @dev: Device for which clk name is being set. +* @name: Clk name. +* +* In order to support OPP switching, OPP layer needs to get pointer to the +* clock for the device. Simple cases work fine without using this routine (i.e. +* by passing connection-id as NULL), but for a device with multiple clocks +* available, the OPP core needs to know the exact name of the clk to use. +* +* This must be called before any OPPs are initialized for the device. +* +* The opp_table structure will be freed after the device is destroyed. +*/ +struct opp_table *devm_pm_opp_set_clkname (struct device *dev,const char *name) +{ +struct opp_table *opp_table; +int err; + + opp_table =dev_pm_opp_set_clkname (dev, name); +if (IS_ERR (opp_table)) +return opp_table; + + err =devm_add_action_or_reset (dev, devm_pm_opp_clkname_release, opp_table); +if (err) + opp_table =ERR_PTR (err); + +return opp_table; +} +EXPORT_SYMBOL_GPL (devm_pm_opp_set_clkname); +/** * dev_pm_opp_register_set_opp_helper() - Register custom set OPP helper * @dev: Device for which the helper is getting registered.
include/linux/pm_opp.h +6 -0
@@ -150,6 +150,7 @@ struct opp_table *dev_pm_opp_set_regulators(struct device *dev, const char * convoid dev_pm_opp_put_regulators (struct opp_table *opp_table);struct opp_table *dev_pm_opp_set_clkname (struct device *dev,const char *name);void dev_pm_opp_put_clkname (struct opp_table *opp_table); +struct opp_table *devm_pm_opp_set_clkname (struct device *dev,const char *name);struct opp_table *dev_pm_opp_register_set_opp_helper (struct device *dev,int (*set_opp)(struct dev_pm_set_opp_data *data));void dev_pm_opp_unregister_set_opp_helper (struct opp_table *opp_table);struct opp_table *devm_pm_opp_register_set_opp_helper (struct device *dev,int (*set_opp)(struct dev_pm_set_opp_data *data));
@@ -355,6 +356,11 @@ static inline struct opp_table *dev_pm_opp_set_clkname(struct device *dev, conststatic inline void dev_pm_opp_put_clkname (struct opp_table *opp_table) {} +static inline struct opp_table *devm_pm_opp_set_clkname (struct device *dev,const char *name) +{ +return ERR_PTR (-EOPNOTSUPP ); +} +static inline struct opp_table *dev_pm_opp_attach_genpd (struct device *dev,const char **names,struct device ***virt_devs) {return ERR_PTR (-EOPNOTSUPP );
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 01/14] opp: Add devres wrapper for dev_pm_opp_set_clkname
Quoted 5 lines · Dmitry Osipenko
drivers/opp/core.c +5
-0+struct opp_table *devm_pm_opp_set_clkname (struct device *dev,const char *name) +{ +struct opp_table *opp_table; +int err; +
drivers/opp/core.c void dev_pm_opp_put_clkname(struct opp_table *opp_table) · line 2155
Quoted 10 lines
drivers/opp/core.c +10
-0+ opp_table =dev_pm_opp_set_clkname (dev, name); +if (IS_ERR (opp_table)) +return opp_table; + + err =devm_add_action_or_reset (dev, devm_pm_opp_clkname_release, opp_table); +if (err) + opp_table =ERR_PTR (err); + +return opp_table; +}
I wonder if we still need to return opp_table from here, or a simple integer is fine.. The callers shouldn't be required to use the OPP table directly anymore I believe and so better simplify the return part of this and all other routines you are adding here..
If there is a user which needs the opp_table, let it use the regular non-devm variant.
Signature · 5 lines
viresh _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 01/14] opp: Add devres wrapper for dev_pm_opp_set_clkname
Quoted 14 lines · Viresh Kumar
Quoted 12 lines · Dmitry Osipenko
drivers/opp/core.c +12
-0+struct opp_table *devm_pm_opp_set_clkname (struct device *dev,const char *name) +{ +struct opp_table *opp_table; +int err; + + opp_table =dev_pm_opp_set_clkname (dev, name); +if (IS_ERR (opp_table)) +return opp_table; + + err =devm_add_action_or_reset (dev, devm_pm_opp_clkname_release, opp_table); +if (err) + opp_table =ERR_PTR (err);
Quoted 8 lines
drivers/opp/core.c void dev_pm_opp_put_clkname(struct opp_table *opp_table) · line 2155
Quoted 3 lines
drivers/opp/core.c +3
-0+ +return opp_table; +}I wonder if we still need to return
opp_tablefrom here, or a simple integer is fine.. The callers shouldn't be required to use the OPP table directly anymore I believe and so better simplify the return part of this and all other routines you are adding here..
Yes, please. I was thinking along the same lines, when I reviewed the mmc patch (patch9).
Quoted 3 lines
If there is a user which needs the
opp_table, let it use the regular non-devm variant.
Kind regards
Uffe
Re: [PATCH v2 01/14] opp: Add devres wrapper for dev_pm_opp_set_clkname
12.03.2021 13:36, Ulf Hansson пишет:
Quoted 24 lines · Viresh Kumar
Quoted 14 lines · Dmitry Osipenko
Quoted 12 lines
drivers/opp/core.c +12
-0+struct opp_table *devm_pm_opp_set_clkname (struct device *dev,const char *name) +{ +struct opp_table *opp_table; +int err; + + opp_table =dev_pm_opp_set_clkname (dev, name); +if (IS_ERR (opp_table)) +return opp_table; + + err =devm_add_action_or_reset (dev, devm_pm_opp_clkname_release, opp_table); +if (err) + opp_table =ERR_PTR (err);Quoted 8 lines
drivers/opp/core.c void dev_pm_opp_put_clkname(struct opp_table *opp_table) · line 2155
Quoted 3 lines
drivers/opp/core.c +3
-0+ +return opp_table; +}I wonder if we still need to return
opp_tablefrom here, or a simple integer is fine.. The callers shouldn't be required to use the OPP table directly anymore I believe and so better simplify the return part of this and all other routines you are adding here..
Quoted 6 lines
Yes, please. I was thinking along the same lines, when I reviewed the mmc patch (patch9).
Quoted 3 lines
If there is a user which needs the
opp_table, let it use the regular non-devm variant.
Indeed, that's a very good suggestion! The opp_table isn't needed by the devm users, I'll change it in v3, thanks!
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 2/14 opp: Add devres wrapper for dev_pm_opp_set_regulators
In reply to Dmitry OsipenkoFrom: Yangtao Li <[email protected]>
Add devres wrapper for dev_pm_opp_set_regulators() to simplify drivers code.
--- drivers/opp/core.c | 39 +++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 8 ++++++++ 2 files changed, 47 insertions(+)
drivers/opp/core.c +39 -0
@@ -2047,6 +2047,45 @@ void dev_pm_opp_put_regulators(struct opp_table *opp_table) }EXPORT_SYMBOL_GPL (dev_pm_opp_put_regulators); +static void devm_pm_opp_regulators_release (void *data) +{ +dev_pm_opp_put_regulators (data); +} + +/** +* devm_pm_opp_set_regulators() - Set regulator names for the device +* @dev: Device for which regulator name is being set. +* @names: Array of pointers to the names of the regulator. +* @count: Number of regulators. +* +* In order to support OPP switching, OPP layer needs to know the name of the +* device's regulators, as the core would be required to switch voltages as +* well. +* +* This must be called before any OPPs are initialized for the device. +* +* The opp_table structure will be freed after the device is destroyed. +*/ +struct opp_table *devm_pm_opp_set_regulators (struct device *dev, +const char *const names[], +unsigned int count) +{ +struct opp_table *opp_table; +int err; + + opp_table =dev_pm_opp_set_regulators (dev, names, count); +if (IS_ERR (opp_table)) +return opp_table; + + err =devm_add_action_or_reset (dev, devm_pm_opp_regulators_release, + opp_table); +if (err) + opp_table =ERR_PTR (err); + +return opp_table; +} +EXPORT_SYMBOL_GPL (devm_pm_opp_set_regulators); +/** * dev_pm_opp_set_clkname() - Set clk name for the device * @dev: Device for which clk name is being set.
include/linux/pm_opp.h +8 -0
@@ -148,6 +148,7 @@ struct opp_table *dev_pm_opp_set_prop_name(struct device *dev, const char *name)void dev_pm_opp_put_prop_name (struct opp_table *opp_table);struct opp_table *dev_pm_opp_set_regulators (struct device *dev,const char *const names[],unsigned int count);void dev_pm_opp_put_regulators (struct opp_table *opp_table); +struct opp_table *devm_pm_opp_set_regulators (struct device *dev,const char *const names[],unsigned int count);struct opp_table *dev_pm_opp_set_clkname (struct device *dev,const char *name);void dev_pm_opp_put_clkname (struct opp_table *opp_table);struct opp_table *devm_pm_opp_set_clkname (struct device *dev,const char *name);
@@ -349,6 +350,13 @@ static inline struct opp_table *dev_pm_opp_set_regulators(struct device *dev, costatic inline void dev_pm_opp_put_regulators (struct opp_table *opp_table) {} +static inline struct opp_table *devm_pm_opp_set_regulators (struct device *dev, +const char *const names[], +unsigned int count) +{ +return ERR_PTR (-EOPNOTSUPP ); +} +static inline struct opp_table *dev_pm_opp_set_clkname (struct device *dev,const char *name) {return ERR_PTR (-EOPNOTSUPP );
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 3/14 opp: Add devres wrapper for dev_pm_opp_set_supported_hw
In reply to Dmitry OsipenkoFrom: Yangtao Li <[email protected]>
Add devres wrapper for dev_pm_opp_set_supported_hw() to simplify driver code.
--- drivers/opp/core.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 8 ++++++++ 2 files changed, 46 insertions(+)
drivers/opp/core.c +38 -0
@@ -1857,6 +1857,44 @@ void dev_pm_opp_put_supported_hw(struct opp_table *opp_table) }EXPORT_SYMBOL_GPL (dev_pm_opp_put_supported_hw); +static void devm_pm_opp_supported_hw_release (void *data) +{ +dev_pm_opp_put_supported_hw (data); +} + +/** +* devm_pm_opp_set_supported_hw() - Set supported platforms +* @dev: Device for which supported-hw has to be set. +* @versions: Array of hierarchy of versions to match. +* @count: Number of elements in the array. +* +* This is required only for the V2 bindings, and it enables a platform to +* specify the hierarchy of versions it supports. OPP layer will then enable +* OPPs, which are available for those versions, based on its 'opp-supported-hw' +* property. +* +* The opp_table structure will be freed after the device is destroyed. +*/ +struct opp_table *devm_pm_opp_set_supported_hw (struct device *dev, +const u32 *versions, +unsigned int count) +{ +struct opp_table *opp_table; +int err; + + opp_table =dev_pm_opp_set_supported_hw (dev, versions, count); +if (IS_ERR (opp_table)) +return opp_table; + + err =devm_add_action_or_reset (dev, devm_pm_opp_supported_hw_release, + opp_table); +if (err) + opp_table =ERR_PTR (err); + +return opp_table; +} +EXPORT_SYMBOL_GPL (devm_pm_opp_set_supported_hw); +/** * dev_pm_opp_set_prop_name() - Set prop-extn name * @dev: Device for which the prop-name has to be set.
include/linux/pm_opp.h +8 -0
@@ -144,6 +144,7 @@ int dev_pm_opp_unregister_notifier(struct device *dev, struct notifier_block *nbstruct opp_table *dev_pm_opp_set_supported_hw (struct device *dev,const u32 *versions,unsigned int count);void dev_pm_opp_put_supported_hw (struct opp_table *opp_table); +struct opp_table *devm_pm_opp_set_supported_hw (struct device *dev,const u32 *versions,unsigned int count);struct opp_table *dev_pm_opp_set_prop_name (struct device *dev,const char *name);void dev_pm_opp_put_prop_name (struct opp_table *opp_table);struct opp_table *dev_pm_opp_set_regulators (struct device *dev,const char *const names[],unsigned int count);
@@ -321,6 +322,13 @@ static inline struct opp_table *dev_pm_opp_set_supported_hw(struct device *dev,static inline void dev_pm_opp_put_supported_hw (struct opp_table *opp_table) {} +static inline struct opp_table *devm_pm_opp_set_supported_hw (struct device *dev, +const u32 *versions, +unsigned int count) +{ +return ERR_PTR (-EOPNOTSUPP ); +} +static inline struct opp_table *dev_pm_opp_register_set_opp_helper (struct device *dev,int (*set_opp)(struct dev_pm_set_opp_data *data)) {
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 4/14 opp: Add devres wrapper for dev_pm_opp_of_add_table
In reply to Dmitry OsipenkoFrom: Yangtao Li <[email protected]>
Add devres wrapper for dev_pm_opp_of_add_table() to simplify driver code.
--- drivers/opp/of.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 42 insertions(+)
drivers/opp/of.c +36 -0
@@ -1104,6 +1104,42 @@ static int _of_add_table_indexed(struct device *dev, int index, bool getclk)return ret; } +static void devm_pm_opp_of_table_release (void *data) +{ +dev_pm_opp_of_remove_table (data); +} + +/** +* devm_pm_opp_of_add_table() - Initialize opp table from device tree +* @dev: device pointer used to lookup OPP table. +* +* Register the initial OPP table with the OPP library for given device. +* +* The opp_table structure will be freed after the device is destroyed. +* +* Return: +* 0 On success OR +* Duplicate OPPs (both freq and volt are same) and opp->available +* -EEXIST Freq are same and volt are different OR +* Duplicate OPPs (both freq and volt are same) and !opp->available +* -ENOMEM Memory allocation failure +* -ENODEV when 'operating-points' property is not found or is invalid data +* in device node. +* -ENODATA when empty 'operating-points' property is found +* -EINVAL when invalid entries are found in opp-v2 table +*/ +int devm_pm_opp_of_add_table (struct device *dev) +{ +int ret; + + ret =dev_pm_opp_of_add_table (dev); +if (ret) +return ret; + +return devm_add_action_or_reset (dev, devm_pm_opp_of_table_release, dev); +} +EXPORT_SYMBOL_GPL (devm_pm_opp_of_add_table); +/** * dev_pm_opp_of_add_table() - Initialize opp table from device tree * @dev: device pointer used to lookup OPP table.
include/linux/pm_opp.h +6 -0
@@ -441,6 +441,7 @@ int dev_pm_opp_of_add_table(struct device *dev);int dev_pm_opp_of_add_table_indexed (struct device *dev,int index);int dev_pm_opp_of_add_table_noclk (struct device *dev,int index);void dev_pm_opp_of_remove_table (struct device *dev); +int devm_pm_opp_of_add_table (struct device *dev);int dev_pm_opp_of_cpumask_add_table (const struct cpumask *cpumask);void dev_pm_opp_of_cpumask_remove_table (const struct cpumask *cpumask);int dev_pm_opp_of_get_sharing_cpus (struct device *cpu_dev,struct cpumask *cpumask);
@@ -473,6 +474,11 @@ static inline void dev_pm_opp_of_remove_table(struct device *dev) { } +static inline int devm_pm_opp_of_add_table (struct device *dev) +{ +return -EOPNOTSUPP ; +} +static inline int dev_pm_opp_of_cpumask_add_table (const struct cpumask *cpumask) {return -EOPNOTSUPP ;
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 5/14 opp: Add devres wrapper for dev_pm_opp_register_notifier
In reply to Dmitry OsipenkoFrom: Yangtao Li <[email protected]>
Add devres wrapper for dev_pm_opp_register_notifier() to simplify driver code.
--- drivers/opp/core.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 44 insertions(+)
drivers/opp/core.c +38 -0
@@ -2899,6 +2899,44 @@ int dev_pm_opp_unregister_notifier(struct device *dev, }EXPORT_SYMBOL (dev_pm_opp_unregister_notifier); +static void devm_pm_opp_notifier_release (struct device *dev,void *res) +{ +struct notifier_block *nb = *(struct notifier_block **)res; + +WARN_ON (dev_pm_opp_unregister_notifier (dev, nb)); +} + +/** +* devm_pm_opp_register_notifier() - Register OPP notifier for the device +* @dev: Device for which notifier needs to be registered +* @nb: Notifier block to be registered +* +* Return: 0 on success or a negative error value. +* +* The notifier will be unregistered after the device is destroyed. +*/ +int devm_pm_opp_register_notifier (struct device *dev,struct notifier_block *nb) +{ +struct notifier_block **ptr; +int ret; + + ptr =devres_alloc (devm_pm_opp_notifier_release,sizeof (*ptr),GFP_KERNEL ); +if (!ptr) +return -ENOMEM ; + + ret =dev_pm_opp_register_notifier (dev, nb); +if (ret) { +devres_free (ptr); +return ret; + } + + *ptr = nb; +devres_add (dev, ptr); + +return 0 ; +} +EXPORT_SYMBOL (devm_pm_opp_register_notifier); +/** * dev_pm_opp_remove_table() - Free all OPPs associated with the device * @dev: device pointer used to lookup OPP table.
include/linux/pm_opp.h +6 -0
@@ -141,6 +141,7 @@ int dev_pm_opp_disable(struct device *dev, unsigned long freq);int dev_pm_opp_register_notifier (struct device *dev,struct notifier_block *nb);int dev_pm_opp_unregister_notifier (struct device *dev,struct notifier_block *nb); +int devm_pm_opp_register_notifier (struct device *dev,struct notifier_block *nb);struct opp_table *dev_pm_opp_set_supported_hw (struct device *dev,const u32 *versions,unsigned int count);void dev_pm_opp_put_supported_hw (struct opp_table *opp_table);
@@ -313,6 +314,11 @@ static inline int dev_pm_opp_unregister_notifier(struct device *dev, struct notireturn -EOPNOTSUPP ; } +static inline int devm_pm_opp_register_notifier (struct device *dev,struct notifier_block *nb) +{ +return -EOPNOTSUPP ; +} +static inline struct opp_table *dev_pm_opp_set_supported_hw (struct device *dev,const u32 *versions,unsigned int count)
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 05/14] opp: Add devres wrapper for dev_pm_opp_register_notifier
Quoted 11 lines · Dmitry Osipenko
From: Yangtao Li <[email protected]>
Add devres wrapper for
dev_pm_opp_register_notifier()to simplify driver code.Signed-off-by Yangtao Li <[email protected]>Signed-off-by Dmitry Osipenko <[email protected]>--- drivers/opp/core.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 44 insertions(+)
As I said in the previous version, I am not sure if we need this patch at all. This has only one user.
Signature · 5 lines
viresh _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 05/14] opp: Add devres wrapper for dev_pm_opp_register_notifier
12.03.2021 08:26, Viresh Kumar пишет:
Quoted 13 lines · Dmitry Osipenko
Quoted 11 lines
From: Yangtao Li <[email protected]>
Add devres wrapper for
dev_pm_opp_register_notifier()to simplify driver code.Signed-off-by Yangtao Li <[email protected]>Signed-off-by Dmitry Osipenko <[email protected]>--- drivers/opp/core.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 44 insertions(+)
Quoted 3 lines
As I said in the previous version, I am not sure if we need this patch at all. This has only one user.
I'll drop this patch in v3, thanks.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 6/14 serial: qcom_geni_serial: Convert to use resource-managed OPP API
In reply to Dmitry OsipenkoFrom: Yangtao Li <[email protected]>
Use resource-managed OPP API to simplify code.
--- drivers/tty/serial/qcom_geni_serial.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)
drivers/tty/serial/qcom_geni_serial.c +9 -15
@@ -1352,6 +1352,7 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)int irq;bool console = false;struct uart_driver *drv; +struct opp_table *opp_table;if (of_device_is_compatible (pdev->dev.of_node,"qcom,geni-debug-uart" )) console = true;
@@ -1433,14 +1434,14 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)if (of_property_read_bool (pdev->dev.of_node,"cts-rts-swap" )) port->cts_rts_swap = true; - port->se.opp_table =dev_pm_opp_set_clkname (&pdev->dev,"se" ); -if (IS_ERR (port->se.opp_table)) -return PTR_ERR (port->se.opp_table); + opp_table =devm_pm_opp_set_clkname (&pdev->dev,"se" ); +if (IS_ERR (opp_table)) +return PTR_ERR (opp_table);/* OPP table is optional */ - ret =dev_pm_opp_of_add_table (&pdev->dev); + ret =devm_pm_opp_of_add_table (&pdev->dev);if (ret && ret != -ENODEV ) {dev_err (&pdev->dev,"invalid OPP table in device tree\n" ); - goto put_clkname; +return ret; } port->private_data.drv = drv;
@@ -1450,7 +1451,7 @@ static int qcom_geni_serial_probe(struct platform_device *pdev) ret =uart_add_one_port (drv, uport);if (ret) - goto err; +return ret;irq_set_status_flags (uport->irq,IRQ_NOAUTOEN ); ret = devm_request_irq(uport->dev, uport->irq, qcom_geni_serial_isr,
@@ -1458,7 +1459,7 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)if (ret) {dev_err (uport->dev,"Failed to get IRQ ret %d\n" , ret);uart_remove_one_port (drv, uport); - goto err; +return ret; }/*
@@ -1475,16 +1476,11 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)if (ret) {device_init_wakeup (&pdev->dev, false);uart_remove_one_port (drv, uport); - goto err; +return ret; } }return 0 ; -err: -dev_pm_opp_of_remove_table (&pdev->dev); -put_clkname: -dev_pm_opp_put_clkname (port->se.opp_table); -return ret; }static int qcom_geni_serial_remove (struct platform_device *pdev)
@@ -1492,8 +1488,6 @@ static int qcom_geni_serial_remove(struct platform_device *pdev)struct qcom_geni_serial_port *port =platform_get_drvdata (pdev);struct uart_driver *drv = port->private_data.drv; -dev_pm_opp_of_remove_table (&pdev->dev); -dev_pm_opp_put_clkname (port->se.opp_table);dev_pm_clear_wake_irq (&pdev->dev);device_init_wakeup (&pdev->dev, false);uart_remove_one_port (drv, &port->uport);
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 7/14 spi: spi-geni-qcom: Convert to use resource-managed OPP API
In reply to Dmitry OsipenkoFrom: Yangtao Li <[email protected]>
Use resource-managed OPP API to simplify code.
--- drivers/spi/spi-geni-qcom.c | 17 +++++++---------- include/linux/qcom-geni-se.h | 2 -- 2 files changed, 7 insertions(+), 12 deletions(-)
drivers/spi/spi-geni-qcom.c +7 -10
@@ -666,6 +666,7 @@ static int spi_geni_probe(struct platform_device *pdev)void __iomem *base;struct clk *clk;struct device *dev = &pdev->dev; +struct opp_table *opp_table; irq =platform_get_irq (pdev,0 );if (irq <0 )
@@ -691,14 +692,15 @@ static int spi_geni_probe(struct platform_device *pdev) mas->se.wrapper =dev_get_drvdata (dev->parent); mas->se.base = base; mas->se.clk = clk; - mas->se.opp_table =dev_pm_opp_set_clkname (&pdev->dev,"se" ); -if (IS_ERR (mas->se.opp_table)) -return PTR_ERR (mas->se.opp_table); + + opp_table =devm_pm_opp_set_clkname (&pdev->dev,"se" ); +if (IS_ERR (opp_table)) +return PTR_ERR (opp_table);/* OPP table is optional */ - ret =dev_pm_opp_of_add_table (&pdev->dev); + ret =devm_pm_opp_of_add_table (&pdev->dev);if (ret && ret != -ENODEV ) {dev_err (&pdev->dev,"invalid OPP table in device tree\n" ); - goto put_clkname; +return ret; } spi->bus_num =-1 ;
@@ -750,9 +752,6 @@ static int spi_geni_probe(struct platform_device *pdev)free_irq (mas->irq, spi); spi_geni_probe_runtime_disable:pm_runtime_disable (dev); -dev_pm_opp_of_remove_table (&pdev->dev); -put_clkname: -dev_pm_opp_put_clkname (mas->se.opp_table);return ret; }
@@ -766,8 +765,6 @@ static int spi_geni_remove(struct platform_device *pdev)free_irq (mas->irq, spi);pm_runtime_disable (&pdev->dev); -dev_pm_opp_of_remove_table (&pdev->dev); -dev_pm_opp_put_clkname (mas->se.opp_table);return 0 ; }
include/linux/qcom-geni-se.h +0 -2
@@ -47,7 +47,6 @@ struct geni_icc_path {* @num_clk_levels: Number of valid clock levels in clk_perf_tbl * @clk_perf_tbl: Table of clock frequency input to serial engine clock * @icc_paths: Array of ICC paths for SE -* @opp_table: Pointer to the OPP table */ struct geni_se {void __iomem *base;
@@ -57,7 +56,6 @@ struct geni_se {unsigned int num_clk_levels;unsigned long *clk_perf_tbl;struct geni_icc_path icc_paths[3 ]; -struct opp_table *opp_table; };/* Common SE registers */
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Mark Brown
maintainerRe: [PATCH v2 07/14] spi: spi-geni-qcom: Convert to use resource-managed OPP API
Quoted 1 line · Dmitry Osipenko
Acked-by Mark brown <[email protected]>
Typo there.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 07/14] spi: spi-geni-qcom: Convert to use resource-managed OPP API
11.03.2021 22:44, Mark Brown пишет:
Quoted 6 lines · Dmitry Osipenko
Quoted 2 lines
Acked-by Mark brown <[email protected]>Typo there.
Good catch! Although, that should be a patchwork fault since it auto-added acks when I downloaded v1 patches and I haven't changed them. I'll fix it in v3 or, if there won't be anything else to improve, then maybe Viresh could fix it up while applying patches.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 8/14 spi: spi-qcom-qspi: Convert to use resource-managed OPP API
In reply to Dmitry OsipenkoFrom: Yangtao Li <[email protected]>
Use resource-managed OPP API to simplify code.
--- drivers/spi/spi-qcom-qspi.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
drivers/spi/spi-qcom-qspi.c +6 -13
@@ -142,7 +142,6 @@ struct qcom_qspi {struct clk_bulk_data *clks;struct qspi_xfer xfer;struct icc_path *icc_path_cpu_to_qspi; -struct opp_table *opp_table;unsigned long last_speed;/* Lock to protect data accessed by IRQs */ spinlock_t lock;
@@ -459,6 +458,7 @@ static int qcom_qspi_probe(struct platform_device *pdev)struct device *dev;struct spi_master *master;struct qcom_qspi *ctrl; +struct opp_table *opp_table; dev = &pdev->dev;
@@ -530,14 +530,14 @@ static int qcom_qspi_probe(struct platform_device *pdev) master->handle_err = qcom_qspi_handle_err; master->auto_runtime_pm = true; - ctrl->opp_table =dev_pm_opp_set_clkname (&pdev->dev,"core" ); -if (IS_ERR (ctrl->opp_table)) -return PTR_ERR (ctrl->opp_table); + opp_table =devm_pm_opp_set_clkname (&pdev->dev,"core" ); +if (IS_ERR (opp_table)) +return PTR_ERR (opp_table);/* OPP table is optional */ - ret =dev_pm_opp_of_add_table (&pdev->dev); + ret =devm_pm_opp_of_add_table (&pdev->dev);if (ret && ret != -ENODEV ) {dev_err (&pdev->dev,"invalid OPP table in device tree\n" ); - goto exit_probe_put_clkname; +return ret; }pm_runtime_use_autosuspend (dev);
@@ -549,10 +549,6 @@ static int qcom_qspi_probe(struct platform_device *pdev)return 0 ;pm_runtime_disable (dev); -dev_pm_opp_of_remove_table (&pdev->dev); - -exit_probe_put_clkname: -dev_pm_opp_put_clkname (ctrl->opp_table);return ret; }
@@ -560,14 +556,11 @@ static int qcom_qspi_probe(struct platform_device *pdev)static int qcom_qspi_remove (struct platform_device *pdev) {struct spi_master *master =platform_get_drvdata (pdev); -struct qcom_qspi *ctrl =spi_master_get_devdata (master);/* Unregister _before_ disabling pm_runtime() so we stop transfers */ spi_unregister_master (master);pm_runtime_disable (&pdev->dev); -dev_pm_opp_of_remove_table (&pdev->dev); -dev_pm_opp_put_clkname (ctrl->opp_table);return 0 ; }
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 9/14 mmc: sdhci-msm: Convert to use resource-managed OPP API
In reply to Dmitry OsipenkoFrom: Yangtao Li <[email protected]>
Use resource-managed OPP API to simplify code.
--- drivers/mmc/host/sdhci-msm.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
drivers/mmc/host/sdhci-msm.c +7 -13
@@ -264,7 +264,6 @@ struct sdhci_msm_host {struct clk_bulk_data bulk_clks[5 ];unsigned long clk_rate;struct mmc_host *mmc; -struct opp_table *opp_table;bool use_14lpp_dll_reset;bool tuning_done;bool calibration_done;
@@ -2483,6 +2482,7 @@ static int sdhci_msm_probe(struct platform_device *pdev)const struct sdhci_msm_offset *msm_offset;const struct sdhci_msm_variant_info *var_info;struct device_node *node = pdev->dev.of_node; +struct opp_table *opp_table; host =sdhci_pltfm_init (pdev, &sdhci_msm_pdata,sizeof (*msm_host));if (IS_ERR (host))
@@ -2551,17 +2551,17 @@ static int sdhci_msm_probe(struct platform_device *pdev)if (ret) goto bus_clk_disable; - msm_host->opp_table =dev_pm_opp_set_clkname (&pdev->dev,"core" ); -if (IS_ERR (msm_host->opp_table)) { - ret =PTR_ERR (msm_host->opp_table); + opp_table =devm_pm_opp_set_clkname (&pdev->dev,"core" ); +if (IS_ERR (opp_table)) { + ret =PTR_ERR (opp_table); goto bus_clk_disable; }/* OPP table is optional */ - ret =dev_pm_opp_of_add_table (&pdev->dev); + ret =devm_pm_opp_of_add_table (&pdev->dev);if (ret && ret != -ENODEV ) {dev_err (&pdev->dev,"Invalid OPP table in Device tree\n" ); - goto opp_put_clkname; + goto bus_clk_disable; }/* Vote for maximum clock rate for maximum performance */
@@ -2587,7 +2587,7 @@ static int sdhci_msm_probe(struct platform_device *pdev) ret =clk_bulk_prepare_enable (ARRAY_SIZE (msm_host->bulk_clks), msm_host->bulk_clks);if (ret) - goto opp_cleanup; + goto bus_clk_disable;/* * xo clock is needed for FLL feature of cm_dll.
@@ -2732,10 +2732,6 @@ static int sdhci_msm_probe(struct platform_device *pdev) clk_disable:clk_bulk_disable_unprepare (ARRAY_SIZE (msm_host->bulk_clks), msm_host->bulk_clks); -opp_cleanup: -dev_pm_opp_of_remove_table (&pdev->dev); -opp_put_clkname: -dev_pm_opp_put_clkname (msm_host->opp_table); bus_clk_disable:if (!IS_ERR (msm_host->bus_clk))clk_disable_unprepare (msm_host->bus_clk);
@@ -2754,8 +2750,6 @@ static int sdhci_msm_remove(struct platform_device *pdev)sdhci_remove_host (host, dead); -dev_pm_opp_of_remove_table (&pdev->dev); -dev_pm_opp_put_clkname (msm_host->opp_table);pm_runtime_get_sync (&pdev->dev);pm_runtime_disable (&pdev->dev);pm_runtime_put_noidle (&pdev->dev);
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 10/14 drm/msm: Convert to use resource-managed OPP API
In reply to Dmitry OsipenkoFrom: Yangtao Li <[email protected]>
Use resource-managed OPP API to simplify code.
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 2 +- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 2 +- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 2 +- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 24 +++++++------------ drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 2 -- drivers/gpu/drm/msm/dp/dp_ctrl.c | 31 ++++++------------------- drivers/gpu/drm/msm/dp/dp_ctrl.h | 1 - drivers/gpu/drm/msm/dp/dp_display.c | 5 +--- drivers/gpu/drm/msm/dsi/dsi_host.c | 14 ++++------- 9 files changed, 25 insertions(+), 58 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +1 -1
@@ -1705,7 +1705,7 @@ static void check_speed_bin(struct device *dev)nvmem_cell_put (cell); } -dev_pm_opp_set_supported_hw (dev, &val,1 ); +devm_pm_opp_set_supported_hw (dev, &val,1 ); }struct msm_gpu *a5xx_gpu_init (struct drm_device *dev)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +1 -1
@@ -1340,7 +1340,7 @@ static int a6xx_gmu_pwrlevels_probe(struct a6xx_gmu *gmu)* The GMU handles its own frequency switching so build a list of * available frequencies to send during initialization */ - ret =dev_pm_opp_of_add_table (gmu->dev); + ret =devm_pm_opp_of_add_table (gmu->dev);if (ret) {DRM_DEV_ERROR (gmu->dev,"Unable to set the OPP table for the GMU\n" );return ret;
drivers/gpu/drm/msm/adreno/adreno_gpu.c +1 -1
@@ -841,7 +841,7 @@ static void adreno_get_pwrlevels(struct device *dev,if (!of_find_property (dev->of_node,"operating-points-v2" ,NULL )) ret =adreno_get_legacy_pwrlevels (dev);else { - ret =dev_pm_opp_of_add_table (dev); + ret =devm_pm_opp_of_add_table (dev);if (ret)DRM_DEV_ERROR (dev,"Unable to set the OPP table\n" ); }
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +9 -15
@@ -1082,27 +1082,28 @@ static int dpu_bind(struct device *dev, struct device *master, void *data)struct msm_drm_private *priv = ddev->dev_private;struct dpu_kms *dpu_kms;struct dss_module_power *mp; +struct opp_table *opp_table;int ret =0 ; dpu_kms =devm_kzalloc (&pdev->dev,sizeof (*dpu_kms),GFP_KERNEL );if (!dpu_kms)return -ENOMEM ; - dpu_kms->opp_table =dev_pm_opp_set_clkname (dev,"core" ); -if (IS_ERR (dpu_kms->opp_table)) -return PTR_ERR (dpu_kms->opp_table); + opp_table =devm_pm_opp_set_clkname (dev,"core" ); +if (IS_ERR (opp_table)) +return PTR_ERR (opp_table);/* OPP table is optional */ - ret =dev_pm_opp_of_add_table (dev); + ret =devm_pm_opp_of_add_table (dev);if (ret && ret != -ENODEV ) {dev_err (dev,"invalid OPP table in device tree\n" ); - goto put_clkname; +return ret; } mp = &dpu_kms->mp; ret =msm_dss_parse_clock (pdev, mp);if (ret) {DPU_ERROR ("failed to parse clocks, ret=%d\n" , ret); - goto err; +return ret; }platform_set_drvdata (pdev, dpu_kms);
@@ -1110,7 +1111,7 @@ static int dpu_bind(struct device *dev, struct device *master, void *data) ret =msm_kms_init (&dpu_kms->base, &kms_funcs);if (ret) {DPU_ERROR ("failed to init kms, ret=%d\n" , ret); - goto err; +return ret; } dpu_kms->dev = ddev; dpu_kms->pdev = pdev;
@@ -1119,11 +1120,7 @@ static int dpu_bind(struct device *dev, struct device *master, void *data) dpu_kms->rpm_enabled = true; priv->kms = &dpu_kms->base; -return ret; -err: -dev_pm_opp_of_remove_table (dev); -put_clkname: -dev_pm_opp_put_clkname (dpu_kms->opp_table); +return ret; }
@@ -1139,9 +1136,6 @@ static void dpu_unbind(struct device *dev, struct device *master, void *data)if (dpu_kms->rpm_enabled)pm_runtime_disable (&pdev->dev); - -dev_pm_opp_of_remove_table (dev); -dev_pm_opp_put_clkname (dpu_kms->opp_table); }static const struct component_ops dpu_ops = {
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +0 -2
@@ -130,8 +130,6 @@ struct dpu_kms {struct platform_device *pdev;bool rpm_enabled; -struct opp_table *opp_table; -struct dss_module_power mp;/* reference count bandwidth requests, so we know when we can
drivers/gpu/drm/msm/dp/dp_ctrl.c +7 -24
@@ -77,8 +77,6 @@ struct dp_ctrl_private {struct dp_parser *parser;struct dp_catalog *catalog; -struct opp_table *opp_table; -struct completion idle_comp;struct completion video_comp; };
@@ -1872,6 +1870,7 @@ struct dp_ctrl *dp_ctrl_get(struct device *dev, struct dp_link *link, struct dp_parser *parser) {struct dp_ctrl_private *ctrl; +struct opp_table *opp_table;int ret; if (!dev || !panel || !aux ||
@@ -1886,20 +1885,17 @@ struct dp_ctrl *dp_ctrl_get(struct device *dev, struct dp_link *link,return ERR_PTR (-ENOMEM ); } - ctrl->opp_table =dev_pm_opp_set_clkname (dev,"ctrl_link" ); -if (IS_ERR (ctrl->opp_table)) { + opp_table =devm_pm_opp_set_clkname (dev,"ctrl_link" ); +if (IS_ERR (opp_table)) {dev_err (dev,"invalid DP OPP table in device tree\n" ); -/* caller do PTR_ERR(ctrl->opp_table) */ -return (struct dp_ctrl *)ctrl->opp_table; +/* caller do PTR_ERR(opp_table) */ +return (struct dp_ctrl *)opp_table; }/* OPP table is optional */ - ret =dev_pm_opp_of_add_table (dev); -if (ret) { + ret =devm_pm_opp_of_add_table (dev); +if (ret)dev_err (dev,"failed to add DP OPP table\n" ); -dev_pm_opp_put_clkname (ctrl->opp_table); - ctrl->opp_table =NULL ; - }init_completion (&ctrl->idle_comp);init_completion (&ctrl->video_comp);
@@ -1915,16 +1911,3 @@ struct dp_ctrl *dp_ctrl_get(struct device *dev, struct dp_link *link,return &ctrl->dp_ctrl; } - -void dp_ctrl_put (struct dp_ctrl *dp_ctrl) -{ -struct dp_ctrl_private *ctrl; - - ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); - -if (ctrl->opp_table) { -dev_pm_opp_of_remove_table (ctrl->dev); -dev_pm_opp_put_clkname (ctrl->opp_table); - ctrl->opp_table =NULL ; - } -}
drivers/gpu/drm/msm/dp/dp_ctrl.h +0 -1
@@ -31,6 +31,5 @@ struct dp_ctrl *dp_ctrl_get(struct device *dev, struct dp_link *link, struct dp_panel *panel, struct drm_dp_aux *aux, struct dp_power *power, struct dp_catalog *catalog, struct dp_parser *parser); -void dp_ctrl_put (struct dp_ctrl *dp_ctrl);#endif /* _DP_CTRL_H_ */
drivers/gpu/drm/msm/dp/dp_display.c +1 -4
@@ -720,7 +720,6 @@ static int dp_irq_hpd_handle(struct dp_display_private *dp, u32 data)static void dp_display_deinit_sub_modules (struct dp_display_private *dp) {dp_debug_put (dp->debug); -dp_ctrl_put (dp->ctrl);dp_panel_put (dp->panel);dp_aux_put (dp->aux);dp_audio_put (dp->audio);
@@ -814,13 +813,11 @@ static int dp_init_sub_modules(struct dp_display_private *dp) rc =PTR_ERR (dp->audio);pr_err ("failed to initialize audio, rc = %d\n" , rc); dp->audio =NULL ; - goto error_audio; + goto error_ctrl; }return rc; -error_audio: -dp_ctrl_put (dp->ctrl); error_ctrl:dp_panel_put (dp->panel); error_link:
drivers/gpu/drm/msm/dsi/dsi_host.c +5 -9
@@ -113,8 +113,6 @@ struct msm_dsi_host {struct clk *pixel_clk_src;struct clk *byte_intf_clk; -struct opp_table *opp_table; -u32 byte_clk_rate;u32 pixel_clk_rate;u32 esc_clk_rate;
@@ -1822,6 +1820,7 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi) {struct msm_dsi_host *msm_host =NULL ;struct platform_device *pdev = msm_dsi->pdev; +struct opp_table *opp_table;int ret; msm_host =devm_kzalloc (&pdev->dev,sizeof (*msm_host),GFP_KERNEL );
@@ -1886,14 +1885,13 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi) goto fail; } - msm_host->opp_table =dev_pm_opp_set_clkname (&pdev->dev,"byte" ); -if (IS_ERR (msm_host->opp_table)) -return PTR_ERR (msm_host->opp_table); + opp_table =devm_pm_opp_set_clkname (&pdev->dev,"byte" ); +if (IS_ERR (opp_table)) +return PTR_ERR (opp_table);/* OPP table is optional */ - ret =dev_pm_opp_of_add_table (&pdev->dev); + ret =devm_pm_opp_of_add_table (&pdev->dev);if (ret && ret != -ENODEV ) {dev_err (&pdev->dev,"invalid OPP table in device tree\n" ); -dev_pm_opp_put_clkname (msm_host->opp_table);return ret; }
@@ -1932,8 +1930,6 @@ void msm_dsi_host_destroy(struct mipi_dsi_host *host)mutex_destroy (&msm_host->cmd_mutex);mutex_destroy (&msm_host->dev_mutex); -dev_pm_opp_of_remove_table (&msm_host->pdev->dev); -dev_pm_opp_put_clkname (msm_host->opp_table);pm_runtime_disable (&msm_host->pdev->dev); }
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 11/14 drm/lima: Convert to use resource-managed OPP API
In reply to Dmitry OsipenkoFrom: Yangtao Li <[email protected]>
Use resource-managed OPP API to simplify code.
--- drivers/gpu/drm/lima/lima_devfreq.c | 43 ++++++++--------------------- drivers/gpu/drm/lima/lima_devfreq.h | 2 -- 2 files changed, 11 insertions(+), 34 deletions(-)
drivers/gpu/drm/lima/lima_devfreq.c +11 -32
@@ -99,13 +99,6 @@ void lima_devfreq_fini(struct lima_device *ldev)devm_devfreq_remove_device (ldev->dev, devfreq->devfreq); devfreq->devfreq =NULL ; } - -dev_pm_opp_of_remove_table (ldev->dev); - -dev_pm_opp_put_regulators (devfreq->regulators_opp_table); -dev_pm_opp_put_clkname (devfreq->clkname_opp_table); - devfreq->regulators_opp_table =NULL ; - devfreq->clkname_opp_table =NULL ; }int lima_devfreq_init (struct lima_device *ldev)
@@ -125,40 +118,31 @@ int lima_devfreq_init(struct lima_device *ldev)spin_lock_init (&ldevfreq->lock); - opp_table =dev_pm_opp_set_clkname (dev,"core" ); -if (IS_ERR (opp_table)) { - ret =PTR_ERR (opp_table); - goto err_fini; - } - - ldevfreq->clkname_opp_table = opp_table; + opp_table =devm_pm_opp_set_clkname (dev,"core" ); +if (IS_ERR (opp_table)) +return PTR_ERR (opp_table); - opp_table =dev_pm_opp_set_regulators (dev, - (const char *[]){"mali" }, -1 ); + opp_table =devm_pm_opp_set_regulators (dev, (const char *[]){"mali" }, +1 );if (IS_ERR (opp_table)) { ret =PTR_ERR (opp_table);/* Continue if the optional regulator is missing */ if (ret != -ENODEV ) - goto err_fini; - }else { - ldevfreq->regulators_opp_table = opp_table; +return ret; } - ret =dev_pm_opp_of_add_table (dev); + ret =devm_pm_opp_of_add_table (dev);if (ret) - goto err_fini; +return ret;lima_devfreq_reset (ldevfreq); cur_freq =clk_get_rate (ldev->clk_gpu); opp =devfreq_recommended_opp (dev, &cur_freq,0 ); -if (IS_ERR (opp)) { - ret =PTR_ERR (opp); - goto err_fini; - } +if (IS_ERR (opp)) +return PTR_ERR (opp); lima_devfreq_profile.initial_freq = cur_freq;dev_pm_opp_put (opp);
@@ -167,8 +151,7 @@ int lima_devfreq_init(struct lima_device *ldev) DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL);if (IS_ERR (devfreq)) {dev_err (dev,"Couldn't initialize GPU devfreq\n" ); - ret =PTR_ERR (devfreq); - goto err_fini; +return PTR_ERR (devfreq); } ldevfreq->devfreq = devfreq;
@@ -180,10 +163,6 @@ int lima_devfreq_init(struct lima_device *ldev) ldevfreq->cooling = cooling;return 0 ; - -err_fini: -lima_devfreq_fini (ldev); -return ret; }void lima_devfreq_record_busy (struct lima_devfreq *devfreq)
drivers/gpu/drm/lima/lima_devfreq.h +0 -2
@@ -15,8 +15,6 @@ struct lima_device;struct lima_devfreq {struct devfreq *devfreq; -struct opp_table *clkname_opp_table; -struct opp_table *regulators_opp_table;struct thermal_cooling_device *cooling;ktime_t busy_time;
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 12/14 drm/panfrost: Convert to use resource-managed OPP API
In reply to Dmitry OsipenkoFrom: Yangtao Li <[email protected]>
Use resource-managed OPP API to simplify code.
--- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 33 +++++---------------- drivers/gpu/drm/panfrost/panfrost_devfreq.h | 1 - 2 files changed, 8 insertions(+), 26 deletions(-)
drivers/gpu/drm/panfrost/panfrost_devfreq.c +8 -25
@@ -93,25 +93,23 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)struct thermal_cooling_device *cooling;struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; - opp_table =dev_pm_opp_set_regulators (dev, pfdev->comp->supply_names, - pfdev->comp->num_supplies); + opp_table =devm_pm_opp_set_regulators (dev, pfdev->comp->supply_names, + pfdev->comp->num_supplies);if (IS_ERR (opp_table)) { ret =PTR_ERR (opp_table);/* Continue if the optional regulator is missing */ if (ret != -ENODEV ) {DRM_DEV_ERROR (dev,"Couldn't set OPP regulators\n" ); - goto err_fini; +return ret; } - }else { - pfdevfreq->regulators_opp_table = opp_table; } - ret =dev_pm_opp_of_add_table (dev); + ret =devm_pm_opp_of_add_table (dev);if (ret) {/* Optional, continue without devfreq */ if (ret == -ENODEV ) ret =0 ; - goto err_fini; +return ret; } pfdevfreq->opp_of_table_added = true;
@@ -122,10 +120,8 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) cur_freq =clk_get_rate (pfdev->clock); opp =devfreq_recommended_opp (dev, &cur_freq,0 ); -if (IS_ERR (opp)) { - ret =PTR_ERR (opp); - goto err_fini; - } +if (IS_ERR (opp)) +return PTR_ERR (opp); panfrost_devfreq_profile.initial_freq = cur_freq;dev_pm_opp_put (opp);
@@ -134,8 +130,7 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL);if (IS_ERR (devfreq)) {DRM_DEV_ERROR (dev,"Couldn't initialize GPU devfreq\n" ); - ret =PTR_ERR (devfreq); - goto err_fini; +return PTR_ERR (devfreq); } pfdevfreq->devfreq = devfreq;
@@ -146,10 +141,6 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) pfdevfreq->cooling = cooling;return 0 ; - -err_fini: -panfrost_devfreq_fini (pfdev); -return ret; }void panfrost_devfreq_fini (struct panfrost_device *pfdev)
@@ -160,14 +151,6 @@ void panfrost_devfreq_fini(struct panfrost_device *pfdev)devfreq_cooling_unregister (pfdevfreq->cooling); pfdevfreq->cooling =NULL ; } - -if (pfdevfreq->opp_of_table_added) { -dev_pm_opp_of_remove_table (&pfdev->pdev->dev); - pfdevfreq->opp_of_table_added = false; - } - -dev_pm_opp_put_regulators (pfdevfreq->regulators_opp_table); - pfdevfreq->regulators_opp_table =NULL ; }void panfrost_devfreq_resume (struct panfrost_device *pfdev)
drivers/gpu/drm/panfrost/panfrost_devfreq.h +0 -1
@@ -15,7 +15,6 @@ struct panfrost_device;struct panfrost_devfreq {struct devfreq *devfreq; -struct opp_table *regulators_opp_table;struct thermal_cooling_device *cooling;bool opp_of_table_added;
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 13/14 media: venus: Convert to use resource-managed OPP API
In reply to Dmitry OsipenkoFrom: Yangtao Li <[email protected]>
Use resource-managed OPP API to simplify code.
--- drivers/media/platform/qcom/venus/pm_helpers.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
drivers/media/platform/qcom/venus/pm_helpers.c +3 -15
@@ -860,45 +860,33 @@ static int core_get_v4(struct device *dev)if (legacy_binding)return 0 ; - core->opp_table =dev_pm_opp_set_clkname (dev,"core" ); + core->opp_table =devm_pm_opp_set_clkname (dev,"core" );if (IS_ERR (core->opp_table))return PTR_ERR (core->opp_table);if (core->res->opp_pmdomain) { - ret =dev_pm_opp_of_add_table (dev); + ret =devm_pm_opp_of_add_table (dev);if (!ret) { core->has_opp_table = true; }else if (ret != -ENODEV ) {dev_err (dev,"invalid OPP table in device tree\n" ); -dev_pm_opp_put_clkname (core->opp_table);return ret; } } ret =vcodec_domains_get (dev); -if (ret) { -if (core->has_opp_table) -dev_pm_opp_of_remove_table (dev); -dev_pm_opp_put_clkname (core->opp_table); +if (ret)return ret; - }return 0 ; }static void core_put_v4 (struct device *dev) { -struct venus_core *core =dev_get_drvdata (dev); -if (legacy_binding)return ;vcodec_domains_put (dev); - -if (core->has_opp_table) -dev_pm_opp_of_remove_table (dev); -dev_pm_opp_put_clkname (core->opp_table); - }static int core_power_v4 (struct device *dev,int on)
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 14/14 memory: samsung: exynos5422-dmc: Convert to use resource-managed OPP API
In reply to Dmitry OsipenkoFrom: Yangtao Li <[email protected]>
Use resource-managed API to simplify code.
--- drivers/memory/samsung/exynos5422-dmc.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/memory/samsung/exynos5422-dmc.c +3 -10
@@ -343,7 +343,7 @@ static int exynos5_init_freq_table(struct exynos5_dmc *dmc,int idx;unsigned long freq; - ret =dev_pm_opp_of_add_table (dmc->dev); + ret =devm_pm_opp_of_add_table (dmc->dev);if (ret <0 ) {dev_err (dmc->dev,"Failed to get OPP table\n" );return ret;
@@ -354,7 +354,7 @@ static int exynos5_init_freq_table(struct exynos5_dmc *dmc, dmc->opp =devm_kmalloc_array (dmc->dev, dmc->opp_count,sizeof (struct dmc_opp_table ),GFP_KERNEL );if (!dmc->opp) - goto err_opp; +return -ENOMEM ; idx = dmc->opp_count -1 ;for (i =0 , freq =ULONG_MAX ; i < dmc->opp_count; i++, freq--) {
@@ -362,7 +362,7 @@ static int exynos5_init_freq_table(struct exynos5_dmc *dmc, opp =dev_pm_opp_find_freq_floor (dmc->dev, &freq);if (IS_ERR (opp)) - goto err_opp; +return PTR_ERR (opp); dmc->opp[idx - i].freq_hz = freq; dmc->opp[idx - i].volt_uv =dev_pm_opp_get_voltage (opp);
@@ -371,11 +371,6 @@ static int exynos5_init_freq_table(struct exynos5_dmc *dmc, }return 0 ; - -err_opp: -dev_pm_opp_of_remove_table (dmc->dev); - -return -EINVAL ; }/**
@@ -1567,8 +1562,6 @@ static int exynos5_dmc_remove(struct platform_device *pdev)clk_disable_unprepare (dmc->mout_bpll);clk_disable_unprepare (dmc->fout_bpll); -dev_pm_opp_remove_table (dmc->dev); -return 0 ; }
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel