Skip to contentSkip to conversation

PM / devfreq: rk3399_dmc: Add missing devfreq_event_disable_edev

PATCH In review Yangtao Li 2 participants 7 messages Dec 21, 2019 – Dec 22, 2019

Subsystems (3)
lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

PATCH 1/2 PM / devfreq: rk3399_dmc: Add missing devfreq_event_disable_edev

The probe process may fail, but the devfreq event device remains enabled. Call devfreq_event_disable_edev on the error return path.

---
 drivers/devfreq/rk3399_dmc.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/devfreq/rk3399_dmc.c +12 -5
index 2f1027c5b647..4f4e7c041888 100644
@@ -364,7 +364,8 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
 			if (res.a0) {
 				dev_err(dev, "Failed to set dram param: %ld\n",
 					res.a0);
-				return -EINVAL;
+				ret = -EINVAL;
+				goto err_disable_edev;
 			}
 		}
 	}
@@ -373,8 +374,10 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
 	if (node) {
 		data->regmap_pmu = syscon_node_to_regmap(node);
 		of_node_put(node);
-		if (IS_ERR(data->regmap_pmu))
-			return PTR_ERR(data->regmap_pmu);
+		if (IS_ERR(data->regmap_pmu)) {
+			ret = PTR_ERR(data->regmap_pmu);
+			goto err_disable_edev;
+		}
 	}
 
 	regmap_read(data->regmap_pmu, RK3399_PMUGRF_OS_REG2, &val);
@@ -392,7 +395,8 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
 		data->odt_dis_freq = data->timing.lpddr4_odt_dis_freq;
 		break;
 	default:
-		return -EINVAL;
+		ret = -EINVAL;
+		goto err_disable_edev;
 	};
 
 	arm_smccc_smc(ROCKCHIP_SIP_DRAM_FREQ, 0, 0,
@@ -426,7 +430,8 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
 	 */
 	if (dev_pm_opp_of_add_table(dev)) {
 		dev_err(dev, "Invalid operating-points in device tree.\n");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto err_disable_edev;
 	}
 
 	of_property_read_u32(np, "upthreshold",
@@ -464,6 +469,8 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
 
 	return 0;
 
+err_disable_edev:
+	devfreq_event_disable_edev(data->edev);
 err_free_opp:
 	dev_pm_opp_of_remove_table(&pdev->dev);
 	return ret;
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 2/2 PM / devfreq: exynos-bus: add missing exynos_bus_disable_edev in exynos_bus_profile_init

The exynos_bus_profile_init process may fail, but the devfreq event device remains enabled. Call devfreq_event_disable_edev on the error return path.

---
 drivers/devfreq/exynos-bus.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/devfreq/exynos-bus.c +5 -1
index 7f5917d59072..5e54eaf3cfc6 100644
@@ -335,10 +335,14 @@ static int exynos_bus_profile_init(struct exynos_bus *bus,
 	ret = exynos_bus_set_event(bus);
 	if (ret < 0) {
 		dev_err(dev, "failed to set event to devfreq-event devices\n");
-		return ret;
+		goto err_disable_edev;
 	}
 
 	return 0;
+
+err_disable_edev:
+	exynos_bus_disable_edev(bus);
+	return ret;
 }
 
 static int exynos_bus_profile_init_passive(struct exynos_bus *bus,
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 2/2] PM / devfreq: exynos-bus: add missing exynos_bus_disable_edev in exynos_bus_profile_init

Hi,

Please use capital letter for the first char of patch title and better to edit the patch title as following:
Actually, it is difficult to understand the role by only reading the function name. It depends on only this driver.
So, better to edit it as following because devfreq-event is standard name in linux kernel. I think it is easy to understand what the patch does.

- PM / devfreq: exynos-bus: Disable the devfreq-event device when failed

2019년 12월 22일 (일) 오전 3:21, Yangtao Li <[email protected]>님이 작성:

Quoted 14 lines

The exynos_bus_profile_init process may fail, but the devfreq event device remains enabled. Call devfreq_event_disable_edev on the error return path.

---
 drivers/devfreq/exynos-bus.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/devfreq/exynos-bus.c +0 -0
index 7f5917d59072..5e54eaf3cfc6 100644

drivers/devfreq/exynos-bus.c static int exynos_bus_profile_init(struct exynos_bus *bus, · line 343

Quoted 10 lines
drivers/devfreq/exynos-bus.c +3 -1
@@ -335,10 +335,14 @@ static int exynos_bus_profile_init(struct exynos_bus *bus,
        ret = exynos_bus_set_event(bus);
        if (ret < 0) {
                dev_err(dev, "failed to set event to devfreq-event devices\n");
-               return ret;
+               goto err_disable_edev;
        }
 
        return 0;
+
+err_disable_edev:

err_edev is enough instead of 'err_disable_edev'

drivers/devfreq/exynos-bus.c static int exynos_bus_profile_init(struct exynos_bus *bus, · line 344

Quoted 1 line
drivers/devfreq/exynos-bus.c +1 -0
+       exynos_bus_disable_edev(bus);

exynos_bus_disable_edev() has return value for detecting the error. Need to add following warning message.

if (ret < 0)

     dev_warn(dev, "failed to disable the devfreq-event devices\n");
Quoted 7 lines
drivers/devfreq/exynos-bus.c +1 -1
+       return ret;
 }
 
 static int exynos_bus_profile_init_passive(struct exynos_bus *bus,
--

2.17.1

--
Best Regards,
Chanwoo Choi

author
#3 lore raw

Re: [PATCH 2/2] PM / devfreq: exynos-bus: add missing exynos_bus_disable_edev in exynos_bus_profile_init

V2 has been sent.

Thx,
Yangtao

author
#4 lore raw

Re: [PATCH 2/2] PM / devfreq: exynos-bus: add missing exynos_bus_disable_edev in exynos_bus_profile_init

In reply to Chanwoo Choi
Quoted 42 lines · Chanwoo Choi

Hi,

Please use capital letter for the first char of patch title and better to edit the patch title as following:
Actually, it is difficult to understand the role by only reading the function name. It depends on only this driver.
So, better to edit it as following because devfreq-event is standard name in linux kernel. I think it is easy to understand what the patch does.

- PM / devfreq: exynos-bus: Disable the devfreq-event device when failed

2019년 12월 22일 (일) 오전 3:21, Yangtao Li <[email protected]>님이 작성:

Quoted 14 lines

The exynos_bus_profile_init process may fail, but the devfreq event device remains enabled. Call devfreq_event_disable_edev on the error return path.

---
 drivers/devfreq/exynos-bus.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/devfreq/exynos-bus.c +0 -0
index 7f5917d59072..5e54eaf3cfc6 100644

drivers/devfreq/exynos-bus.c static int exynos_bus_profile_init(struct exynos_bus *bus, · line 343

Quoted 10 lines
drivers/devfreq/exynos-bus.c +3 -1
@@ -335,10 +335,14 @@ static int exynos_bus_profile_init(struct exynos_bus *bus,
        ret = exynos_bus_set_event(bus);
        if (ret < 0) {
                dev_err(dev, "failed to set event to devfreq-event devices\n");
-               return ret;
+               goto err_disable_edev;
        }
 
        return 0;
+
+err_disable_edev:

err_edev is enough instead of 'err_disable_edev'

Quoted 7 lines

drivers/devfreq/exynos-bus.c static int exynos_bus_profile_init(struct exynos_bus *bus, · line 344

Quoted 1 line
drivers/devfreq/exynos-bus.c +1 -0
+       exynos_bus_disable_edev(bus);

exynos_bus_disable_edev() has return value for detecting the error. Need to add following warning message.

if (ret < 0)

     dev_warn(dev, "failed to disable the devfreq-event devices\n");

I'm not sure if it should be like this,
it may rewrite the above error code.

Yangtao

Quoted 14 lines
Quoted 9 lines
drivers/devfreq/exynos-bus.c +1 -1
+       return ret;
 }
 
 static int exynos_bus_profile_init_passive(struct exynos_bus *bus,
--

2.17.1

--
Best Regards,
Chanwoo Choi

#5 lore raw
In reply to Yangtao Li

Hi,

2019년 12월 22일 (일) 오전 3:21, Yangtao Li <[email protected]>님이 작성:

Quoted 14 lines

The probe process may fail, but the devfreq event device remains enabled. Call devfreq_event_disable_edev on the error return path.

---
 drivers/devfreq/rk3399_dmc.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/devfreq/rk3399_dmc.c +0 -0
index 2f1027c5b647..4f4e7c041888 100644

drivers/devfreq/rk3399_dmc.c static int rk3399_dmcfreq_probe(struct platform_device *pdev) · line 368

Quoted 6 lines
drivers/devfreq/rk3399_dmc.c +2 -1
@@ -364,7 +364,8 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
                        if (res.a0) {
                                dev_err(dev, "Failed to set dram param: %ld\n",
                                        res.a0);
-                               return -EINVAL;
+                               ret = -EINVAL;
+                               goto err_disable_edev;

After jumping err_disable_edev, it calls the dev_pm_opp_of_remove_table(). it is wrong. It doesn't need to remove the table.

drivers/devfreq/rk3399_dmc.c static int rk3399_dmcfreq_probe(struct platform_device *pdev) · line 379

Quoted 12 lines
drivers/devfreq/rk3399_dmc.c +3 -2
                        }
                }
        }
@@ -373,8 +374,10 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
        if (node) {
                data->regmap_pmu = syscon_node_to_regmap(node);
                of_node_put(node);
-               if (IS_ERR(data->regmap_pmu))
-                       return PTR_ERR(data->regmap_pmu);
+               if (IS_ERR(data->regmap_pmu)) {
+                       ret = PTR_ERR(data->regmap_pmu);
+                       goto err_disable_edev;

ditto.

After jumping err_disable_edev, it calls the dev_pm_opp_of_remove_table(). it is wrong. It doesn't need to remove the table.

drivers/devfreq/rk3399_dmc.c static int rk3399_dmcfreq_probe(struct platform_device *pdev) · line 399

Quoted 11 lines
drivers/devfreq/rk3399_dmc.c +3 -1
+               }
        }
 
        regmap_read(data->regmap_pmu, RK3399_PMUGRF_OS_REG2, &val);
@@ -392,7 +395,8 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
                data->odt_dis_freq = data->timing.lpddr4_odt_dis_freq;
                break;
        default:
-               return -EINVAL;
+               ret = -EINVAL;
+               goto err_disable_edev;

ditto.

drivers/devfreq/rk3399_dmc.c static int rk3399_dmcfreq_probe(struct platform_device *pdev) · line 434

Quoted 10 lines
drivers/devfreq/rk3399_dmc.c +2 -1
        };
 
        arm_smccc_smc(ROCKCHIP_SIP_DRAM_FREQ, 0, 0,
@@ -426,7 +430,8 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
         */
        if (dev_pm_opp_of_add_table(dev)) {
                dev_err(dev, "Invalid operating-points in device tree.\n");
-               return -EINVAL;
+               ret = -EINVAL;
+               goto err_disable_edev;

ditto.

drivers/devfreq/rk3399_dmc.c static int rk3399_dmcfreq_probe(struct platform_device *pdev) · line 473

Quoted 9 lines
drivers/devfreq/rk3399_dmc.c +2 -0
        }
 
        of_property_read_u32(np, "upthreshold",
@@ -464,6 +469,8 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev)
 
        return 0;
 
+err_disable_edev:
+       devfreq_event_disable_edev(data->edev);

It is wrong. It have to be called under dev_pm_opp_of_remove_table(). It ignores the sequence of exception handling.

Quoted 6 lines
drivers/devfreq/rk3399_dmc.c +0 -1
 err_free_opp:
        dev_pm_opp_of_remove_table(&pdev->dev);
        return ret;
--

2.17.1

Signature · 2 lines
Best Regards,
Chanwoo Choi