Hi All
This patch series is bit of rework on my previous
patch series [0], where I failed to justify the code changes.
With this new series I have tried to improve the commit subject
and commit message.
Added new patchs are added to improve the PM suspend/resume and
added runtime power management support to exynos tmu driver.
[0] https://lore.kernel.org/lkml/CANAwSgS=08fVsqn95WHzSF71WTTyD2-=K2C6-BEz0tY0t6A1-g@mail.gmail.com/T/#m77e57120d230d57f34c29e1422d7fc5f5587ac30
Best Regards
-Anand
Anand Moon (6):
thermal: exynos: Enable core tmu hardware clk flag on exynos platform
thermal: exynos: Reorder the gpu clock initialization for exynos5420
SoC
thermal: exynos: Check before clk_disable_unprepare() not needed
thermal: exynos: fixed the efuse min/max value for exynos5422
thermal: exynos: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
thermal: exynos: Add runtime power management for tmu
drivers/thermal/samsung/exynos_tmu.c | 107 ++++++++++++++++-----------
1 file changed, 62 insertions(+), 45 deletions(-)
base-commit: ec7f49619d8ee13e108740c82f942cd401b989e9
--
2.36.1
All code in clk_disable_unprepare() already checks the clk ptr using
IS_ERR_OR_NULL so there is no need to check it again before calling it.
A lot of other drivers already rely on this behaviour, so it's safe
to do so here.
Cc: Bartlomiej Zolnierkiewicz <[email protected]>
Signed-off-by: Anand Moon <[email protected]>
---
v1: improve the commit message
---
drivers/thermal/samsung/exynos_tmu.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 1ef90dc52c08..58ff1b577c47 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -289,8 +289,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
mutex_lock(&data->lock);
clk_enable(data->clk);
- if (!IS_ERR(data->clk_sec))
- clk_enable(data->clk_sec);
+ clk_enable(data->clk_sec);
status = readb(data->base + EXYNOS_TMU_REG_STATUS);
if (!status) {
@@ -323,8 +322,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
err:
clk_disable(data->clk);
mutex_unlock(&data->lock);
- if (!IS_ERR(data->clk_sec))
- clk_disable(data->clk_sec);
+ clk_disable(data->clk_sec);
out:
return ret;
}
@@ -1119,8 +1117,7 @@ static int exynos_tmu_probe(struct platform_device *pdev)
err_thermal:
thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
err_clk_sec:
- if (!IS_ERR(data->clk_sec))
- clk_disable_unprepare(data->clk_sec);
+ clk_disable_unprepare(data->clk_sec);
err_sclk:
clk_disable_unprepare(data->sclk);
err_clk_apbif:
@@ -1142,8 +1139,7 @@ static int exynos_tmu_remove(struct platform_device *pdev)
clk_disable_unprepare(data->sclk);
clk_disable_unprepare(data->clk);
- if (!IS_ERR(data->clk_sec))
- clk_disable_unprepare(data->clk_sec);
+ clk_disable_unprepare(data->clk_sec);
if (!IS_ERR(data->regulator))
regulator_disable(data->regulator);
--
2.36.1
As per Exynos5422 user manaul e-Fuse range min~max range is 16~76.
if e-Fuse value is out of this range, then thermal sensor may not
sense thermal data properly.
Cc: Bartlomiej Zolnierkiewicz <[email protected]>
Signed-off-by: Anand Moon <[email protected]>
---
v1: Fix the commit message
---
drivers/thermal/samsung/exynos_tmu.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 58ff1b577c47..0faec0f16db6 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -926,12 +926,14 @@ static int exynos_map_dt_data(struct platform_device *pdev)
data->gain = 8;
data->reference_voltage = 16;
data->efuse_value = 55;
- if (data->soc != SOC_ARCH_EXYNOS5420 &&
- data->soc != SOC_ARCH_EXYNOS5420_TRIMINFO)
+ if (data->soc == SOC_ARCH_EXYNOS5420 &&
+ data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
+ data->min_efuse_value = 16;
+ data->max_efuse_value = 76;
+ } else {
data->min_efuse_value = 40;
- else
- data->min_efuse_value = 0;
- data->max_efuse_value = 100;
+ data->max_efuse_value = 100;
+ }
break;
case SOC_ARCH_EXYNOS5433:
data->tmu_set_trip_temp = exynos5433_tmu_set_trip_temp;
--
2.36.1
On 16/05/2022 12:42, kernel test robot wrote:
> Hi Anand,
>
> Thank you for the patch! Perhaps something to improve:
>
> [auto build test WARNING on ec7f49619d8ee13e108740c82f942cd401b989e9]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Anand-Moon/Exynos-Thermal-code-inprovement/20220515-144336
> base: ec7f49619d8ee13e108740c82f942cd401b989e9
> config: hexagon-randconfig-r033-20220516 (https://download.01.org/0day-ci/archive/20220516/[email protected]/config)
> compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 853fa8ee225edf2d0de94b0dcbd31bea916e825e)
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # https://github.com/intel-lab-lkp/linux/commit/eb50b0c2100fabd6d09b87abd11f52c5295512e8
> git remote add linux-review https://github.com/intel-lab-lkp/linux
> git fetch --no-tags linux-review Anand-Moon/Exynos-Thermal-code-inprovement/20220515-144336
> git checkout eb50b0c2100fabd6d09b87abd11f52c5295512e8
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/thermal/samsung/
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <[email protected]>
>
> All warnings (new ones prefixed by >>):
>
>>> drivers/thermal/samsung/exynos_tmu.c:929:40: warning: overlapping comparisons always evaluate to false [-Wtautological-overlap-compare]
> if (data->soc == SOC_ARCH_EXYNOS5420 &&
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
> 1 warning generated.
Ah, I did not notice it and it seems code was not compile-tested with W=1.
Anand, please be sure you compile your code with W=1...
Best regards,
Krzysztof
Use the newlly introduced pm_sleep_ptr() macro, and mark the
functions __maybe_unused. These functions can then be moved outside the
CONFIG_PM_SUSPEND block, and the compiler can then process them and
detect build failures independently of the config. If unused, they will
simply be discarded by the compiler.
Cc: Bartlomiej Zolnierkiewicz <[email protected]>
Signed-off-by: Anand Moon <[email protected]>
---
v1: new patch in this series.
---
drivers/thermal/samsung/exynos_tmu.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 0faec0f16db6..f8a527f19383 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -1149,15 +1149,14 @@ static int exynos_tmu_remove(struct platform_device *pdev)
return 0;
}
-#ifdef CONFIG_PM_SLEEP
-static int exynos_tmu_suspend(struct device *dev)
+static int __maybe_unused exynos_tmu_suspend(struct device *dev)
{
exynos_tmu_control(to_platform_device(dev), false);
return 0;
}
-static int exynos_tmu_resume(struct device *dev)
+static int __maybe_unused exynos_tmu_resume(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
@@ -1169,15 +1168,11 @@ static int exynos_tmu_resume(struct device *dev)
static SIMPLE_DEV_PM_OPS(exynos_tmu_pm,
exynos_tmu_suspend, exynos_tmu_resume);
-#define EXYNOS_TMU_PM (&exynos_tmu_pm)
-#else
-#define EXYNOS_TMU_PM NULL
-#endif
static struct platform_driver exynos_tmu_driver = {
.driver = {
.name = "exynos-tmu",
- .pm = EXYNOS_TMU_PM,
+ .pm = pm_sleep_ptr(&exynos_tmu_pm),
.of_match_table = exynos_tmu_match,
},
.probe = exynos_tmu_probe,
--
2.36.1
Hi Anand,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on ec7f49619d8ee13e108740c82f942cd401b989e9]
url: https://github.com/intel-lab-lkp/linux/commits/Anand-Moon/Exynos-Thermal-code-inprovement/20220515-144336
base: ec7f49619d8ee13e108740c82f942cd401b989e9
config: hexagon-randconfig-r033-20220516 (https://download.01.org/0day-ci/archive/20220516/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 853fa8ee225edf2d0de94b0dcbd31bea916e825e)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/eb50b0c2100fabd6d09b87abd11f52c5295512e8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Anand-Moon/Exynos-Thermal-code-inprovement/20220515-144336
git checkout eb50b0c2100fabd6d09b87abd11f52c5295512e8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/thermal/samsung/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
All warnings (new ones prefixed by >>):
>> drivers/thermal/samsung/exynos_tmu.c:929:40: warning: overlapping comparisons always evaluate to false [-Wtautological-overlap-compare]
if (data->soc == SOC_ARCH_EXYNOS5420 &&
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
1 warning generated.
vim +929 drivers/thermal/samsung/exynos_tmu.c
865
866 static int exynos_map_dt_data(struct platform_device *pdev)
867 {
868 struct exynos_tmu_data *data = platform_get_drvdata(pdev);
869 struct resource res;
870
871 if (!data || !pdev->dev.of_node)
872 return -ENODEV;
873
874 data->id = of_alias_get_id(pdev->dev.of_node, "tmuctrl");
875 if (data->id < 0)
876 data->id = 0;
877
878 data->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
879 if (data->irq <= 0) {
880 dev_err(&pdev->dev, "failed to get IRQ\n");
881 return -ENODEV;
882 }
883
884 if (of_address_to_resource(pdev->dev.of_node, 0, &res)) {
885 dev_err(&pdev->dev, "failed to get Resource 0\n");
886 return -ENODEV;
887 }
888
889 data->base = devm_ioremap(&pdev->dev, res.start, resource_size(&res));
890 if (!data->base) {
891 dev_err(&pdev->dev, "Failed to ioremap memory\n");
892 return -EADDRNOTAVAIL;
893 }
894
895 data->soc = (enum soc_type)of_device_get_match_data(&pdev->dev);
896
897 switch (data->soc) {
898 case SOC_ARCH_EXYNOS4210:
899 data->tmu_set_trip_temp = exynos4210_tmu_set_trip_temp;
900 data->tmu_set_trip_hyst = exynos4210_tmu_set_trip_hyst;
901 data->tmu_initialize = exynos4210_tmu_initialize;
902 data->tmu_control = exynos4210_tmu_control;
903 data->tmu_read = exynos4210_tmu_read;
904 data->tmu_clear_irqs = exynos4210_tmu_clear_irqs;
905 data->ntrip = 4;
906 data->gain = 15;
907 data->reference_voltage = 7;
908 data->efuse_value = 55;
909 data->min_efuse_value = 40;
910 data->max_efuse_value = 100;
911 break;
912 case SOC_ARCH_EXYNOS3250:
913 case SOC_ARCH_EXYNOS4412:
914 case SOC_ARCH_EXYNOS5250:
915 case SOC_ARCH_EXYNOS5260:
916 case SOC_ARCH_EXYNOS5420:
917 case SOC_ARCH_EXYNOS5420_TRIMINFO:
918 data->tmu_set_trip_temp = exynos4412_tmu_set_trip_temp;
919 data->tmu_set_trip_hyst = exynos4412_tmu_set_trip_hyst;
920 data->tmu_initialize = exynos4412_tmu_initialize;
921 data->tmu_control = exynos4210_tmu_control;
922 data->tmu_read = exynos4412_tmu_read;
923 data->tmu_set_emulation = exynos4412_tmu_set_emulation;
924 data->tmu_clear_irqs = exynos4210_tmu_clear_irqs;
925 data->ntrip = 4;
926 data->gain = 8;
927 data->reference_voltage = 16;
928 data->efuse_value = 55;
> 929 if (data->soc == SOC_ARCH_EXYNOS5420 &&
930 data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) {
931 data->min_efuse_value = 16;
932 data->max_efuse_value = 76;
933 } else {
934 data->min_efuse_value = 40;
935 data->max_efuse_value = 100;
936 }
937 break;
938 case SOC_ARCH_EXYNOS5433:
939 data->tmu_set_trip_temp = exynos5433_tmu_set_trip_temp;
940 data->tmu_set_trip_hyst = exynos5433_tmu_set_trip_hyst;
941 data->tmu_initialize = exynos5433_tmu_initialize;
942 data->tmu_control = exynos5433_tmu_control;
943 data->tmu_read = exynos4412_tmu_read;
944 data->tmu_set_emulation = exynos4412_tmu_set_emulation;
945 data->tmu_clear_irqs = exynos4210_tmu_clear_irqs;
946 data->ntrip = 8;
947 data->gain = 8;
948 if (res.start == EXYNOS5433_G3D_BASE)
949 data->reference_voltage = 23;
950 else
951 data->reference_voltage = 16;
952 data->efuse_value = 75;
953 data->min_efuse_value = 40;
954 data->max_efuse_value = 150;
955 break;
956 case SOC_ARCH_EXYNOS7:
957 data->tmu_set_trip_temp = exynos7_tmu_set_trip_temp;
958 data->tmu_set_trip_hyst = exynos7_tmu_set_trip_hyst;
959 data->tmu_initialize = exynos7_tmu_initialize;
960 data->tmu_control = exynos7_tmu_control;
961 data->tmu_read = exynos7_tmu_read;
962 data->tmu_set_emulation = exynos4412_tmu_set_emulation;
963 data->tmu_clear_irqs = exynos4210_tmu_clear_irqs;
964 data->ntrip = 8;
965 data->gain = 9;
966 data->reference_voltage = 17;
967 data->efuse_value = 75;
968 data->min_efuse_value = 15;
969 data->max_efuse_value = 100;
970 break;
971 default:
972 dev_err(&pdev->dev, "Platform not supported\n");
973 return -EINVAL;
974 }
975
976 data->cal_type = TYPE_ONE_POINT_TRIMMING;
977
978 /*
979 * Check if the TMU shares some registers and then try to map the
980 * memory of common registers.
981 */
982 if (data->soc != SOC_ARCH_EXYNOS5420_TRIMINFO)
983 return 0;
984
985 if (of_address_to_resource(pdev->dev.of_node, 1, &res)) {
986 dev_err(&pdev->dev, "failed to get Resource 1\n");
987 return -ENODEV;
988 }
989
990 data->base_second = devm_ioremap(&pdev->dev, res.start,
991 resource_size(&res));
992 if (!data->base_second) {
993 dev_err(&pdev->dev, "Failed to ioremap memory\n");
994 return -ENOMEM;
995 }
996
997 return 0;
998 }
999
--
0-DAY CI Kernel Test Service
https://01.org/lkp
Hi Krzysztof,
On Mon, 16 May 2022 at 16:14, Krzysztof Kozlowski <[email protected]> wrote:
>
> On 16/05/2022 12:42, kernel test robot wrote:
> > Hi Anand,
> >
> > Thank you for the patch! Perhaps something to improve:
> >
> > [auto build test WARNING on ec7f49619d8ee13e108740c82f942cd401b989e9]
> >
> > url: https://github.com/intel-lab-lkp/linux/commits/Anand-Moon/Exynos-Thermal-code-inprovement/20220515-144336
> > base: ec7f49619d8ee13e108740c82f942cd401b989e9
> > config: hexagon-randconfig-r033-20220516 (https://download.01.org/0day-ci/archive/20220516/[email protected]/config)
> > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 853fa8ee225edf2d0de94b0dcbd31bea916e825e)
> > reproduce (this is a W=1 build):
> > wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> > chmod +x ~/bin/make.cross
> > # https://github.com/intel-lab-lkp/linux/commit/eb50b0c2100fabd6d09b87abd11f52c5295512e8
> > git remote add linux-review https://github.com/intel-lab-lkp/linux
> > git fetch --no-tags linux-review Anand-Moon/Exynos-Thermal-code-inprovement/20220515-144336
> > git checkout eb50b0c2100fabd6d09b87abd11f52c5295512e8
> > # save the config file
> > mkdir build_dir && cp config build_dir/.config
> > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/thermal/samsung/
> >
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <[email protected]>
> >
> > All warnings (new ones prefixed by >>):
> >
> >>> drivers/thermal/samsung/exynos_tmu.c:929:40: warning: overlapping comparisons always evaluate to false [-Wtautological-overlap-compare]
> > if (data->soc == SOC_ARCH_EXYNOS5420 &&
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
> > 1 warning generated.
>
> Ah, I did not notice it and it seems code was not compile-tested with W=1.
>
> Anand, please be sure you compile your code with W=1...
>
Ok I will try to resolve this warning in the next version.
>
> Best regards,
> Krzysztof
Thanks & Regards
-Anand