diff mbox series

[2/2] hack-5.15: add Aquantia PHY hwmon temperature clamp patch

Message ID 20230217235652.2184875-3-mrkiko.rs@gmail.com
State New
Headers show
Series ipq807x: ZyXEL NBG7815: add fan support | expand

Commit Message

Enrico Mioso Feb. 17, 2023, 11:56 p.m. UTC
This is needed to avoid failures in the thermal subsystem while using this
driver via hwmon subsystem.

CC: Andre Valentin <avalentin@marcant.net>
CC: Karol Przybylski <karol.przybylski@esm-technology.pl>
Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
---
 ...-clamp-temperature-value-in-aqr_hwmo.patch | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 target/linux/generic/hack-5.15/726-net-phy-aquantia-clamp-temperature-value-in-aqr_hwmo.patch

Comments

Robert Marko Feb. 18, 2023, 11:45 a.m. UTC | #1
On Sat, 18 Feb 2023 at 00:58, Enrico Mioso <mrkiko.rs@gmail.com> wrote:
>
> This is needed to avoid failures in the thermal subsystem while using this
> driver via hwmon subsystem.

This should be submitted upstream, we have enough hacks already and
you will get proper feedback from Guenter rather fast whether this is a bug
in hwmon or the driver needs fixups.

Regards,
Robert
>
> CC: Andre Valentin <avalentin@marcant.net>
> CC: Karol Przybylski <karol.przybylski@esm-technology.pl>
> Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
> ---
>  ...-clamp-temperature-value-in-aqr_hwmo.patch | 30 +++++++++++++++++++
>  1 file changed, 30 insertions(+)
>  create mode 100644 target/linux/generic/hack-5.15/726-net-phy-aquantia-clamp-temperature-value-in-aqr_hwmo.patch
>
> diff --git a/target/linux/generic/hack-5.15/726-net-phy-aquantia-clamp-temperature-value-in-aqr_hwmo.patch b/target/linux/generic/hack-5.15/726-net-phy-aquantia-clamp-temperature-value-in-aqr_hwmo.patch
> new file mode 100644
> index 0000000000..36f0b37130
> --- /dev/null
> +++ b/target/linux/generic/hack-5.15/726-net-phy-aquantia-clamp-temperature-value-in-aqr_hwmo.patch
> @@ -0,0 +1,30 @@
> +From 7bfceb1036d2ccda7b8e1e177e834c1cea9f0858 Mon Sep 17 00:00:00 2001
> +From: Enrico Mioso <mrkiko.rs@gmail.com>
> +Date: Sat, 18 Feb 2023 00:27:55 +0100
> +Subject: [PATCH] net: phy: aquantia: clamp temperature value in aqr_hwmon_set
> +
> +This patch is still under evaluation and is not guaranteed to be correct,
> +therefore it is submitted here in hack form. :)
> +
> +Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
> +---
> + drivers/net/phy/aquantia_hwmon.c | 3 +--
> + 1 file changed, 1 insertion(+), 2 deletions(-)
> +
> +diff --git a/drivers/net/phy/aquantia_hwmon.c b/drivers/net/phy/aquantia_hwmon.c
> +index 19c4c280a6cd..6444055e720c 100644
> +--- a/drivers/net/phy/aquantia_hwmon.c
> ++++ b/drivers/net/phy/aquantia_hwmon.c
> +@@ -70,8 +70,7 @@ static int aqr_hwmon_set(struct phy_device *phydev, int reg, long value)
> + {
> +       int temp;
> +
> +-      if (value >= 128000 || value < -128000)
> +-              return -ERANGE;
> ++      clamp_val(value, -128000, 128000);
> +
> +       temp = value * 256 / 1000;
> +
> +--
> +2.39.2
> +
> --
> 2.39.2
>
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Enrico Mioso Feb. 18, 2023, 8:47 p.m. UTC | #2
On Sat, 18 Feb 2023, Robert Marko wrote:

> Date: Sat, 18 Feb 2023 12:45:34
> From: Robert Marko <robimarko@gmail.com>
> To: Enrico Mioso <mrkiko.rs@gmail.com>
> Cc: openwrt-devel@lists.openwrt.org, Andre Valentin <avalentin@marcant.net>,
>     Karol Przybylski <karol.przybylski@esm-technology.pl>
> Subject: Re: [PATCH 2/2] hack-5.15: add Aquantia PHY hwmon temperature clamp
>     patch
> 
> On Sat, 18 Feb 2023 at 00:58, Enrico Mioso <mrkiko.rs@gmail.com> wrote:
>>
>> This is needed to avoid failures in the thermal subsystem while using this
>> driver via hwmon subsystem.
>
> This should be submitted upstream, we have enough hacks already and
> you will get proper feedback from Guenter rather fast whether this is a bug
> in hwmon or the driver needs fixups.

Thanks for your review and feedback!

I am in the process of discussing this change upstream; the problem seems not to be related to hwmon core, but my approach of clamping the value is not going to be accepted either.
I'm being asked to simply change the -ERANGE returned value to -EINVAL, so I will do it independently of this openwrt patch.

But I am supposed to set max a min limits directly to reasonable values.
I have no clear idea yet on where to set them in DTS, any help or hint would be very apreciated.

Enrico
>
> Regards,
> Robert
>>
>> CC: Andre Valentin <avalentin@marcant.net>
>> CC: Karol Przybylski <karol.przybylski@esm-technology.pl>
>> Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
>> ---
>>  ...-clamp-temperature-value-in-aqr_hwmo.patch | 30 +++++++++++++++++++
>>  1 file changed, 30 insertions(+)
>>  create mode 100644 target/linux/generic/hack-5.15/726-net-phy-aquantia-clamp-temperature-value-in-aqr_hwmo.patch
>>
>> diff --git a/target/linux/generic/hack-5.15/726-net-phy-aquantia-clamp-temperature-value-in-aqr_hwmo.patch b/target/linux/generic/hack-5.15/726-net-phy-aquantia-clamp-temperature-value-in-aqr_hwmo.patch
>> new file mode 100644
>> index 0000000000..36f0b37130
>> --- /dev/null
>> +++ b/target/linux/generic/hack-5.15/726-net-phy-aquantia-clamp-temperature-value-in-aqr_hwmo.patch
>> @@ -0,0 +1,30 @@
>> +From 7bfceb1036d2ccda7b8e1e177e834c1cea9f0858 Mon Sep 17 00:00:00 2001
>> +From: Enrico Mioso <mrkiko.rs@gmail.com>
>> +Date: Sat, 18 Feb 2023 00:27:55 +0100
>> +Subject: [PATCH] net: phy: aquantia: clamp temperature value in aqr_hwmon_set
>> +
>> +This patch is still under evaluation and is not guaranteed to be correct,
>> +therefore it is submitted here in hack form. :)
>> +
>> +Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
>> +---
>> + drivers/net/phy/aquantia_hwmon.c | 3 +--
>> + 1 file changed, 1 insertion(+), 2 deletions(-)
>> +
>> +diff --git a/drivers/net/phy/aquantia_hwmon.c b/drivers/net/phy/aquantia_hwmon.c
>> +index 19c4c280a6cd..6444055e720c 100644
>> +--- a/drivers/net/phy/aquantia_hwmon.c
>> ++++ b/drivers/net/phy/aquantia_hwmon.c
>> +@@ -70,8 +70,7 @@ static int aqr_hwmon_set(struct phy_device *phydev, int reg, long value)
>> + {
>> +       int temp;
>> +
>> +-      if (value >= 128000 || value < -128000)
>> +-              return -ERANGE;
>> ++      clamp_val(value, -128000, 128000);
>> +
>> +       temp = value * 256 / 1000;
>> +
>> +--
>> +2.39.2
>> +
>> --
>> 2.39.2
>>
>>
>> _______________________________________________
>> openwrt-devel mailing list
>> openwrt-devel@lists.openwrt.org
>> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
>
Robert Marko Feb. 19, 2023, 11:02 a.m. UTC | #3
On Sat, 18 Feb 2023 at 21:47, Enrico Mioso <mrkiko.rs@gmail.com> wrote:
>
>
>
>
> On Sat, 18 Feb 2023, Robert Marko wrote:
>
> > Date: Sat, 18 Feb 2023 12:45:34
> > From: Robert Marko <robimarko@gmail.com>
> > To: Enrico Mioso <mrkiko.rs@gmail.com>
> > Cc: openwrt-devel@lists.openwrt.org, Andre Valentin <avalentin@marcant.net>,
> >     Karol Przybylski <karol.przybylski@esm-technology.pl>
> > Subject: Re: [PATCH 2/2] hack-5.15: add Aquantia PHY hwmon temperature clamp
> >     patch
> >
> > On Sat, 18 Feb 2023 at 00:58, Enrico Mioso <mrkiko.rs@gmail.com> wrote:
> >>
> >> This is needed to avoid failures in the thermal subsystem while using this
> >> driver via hwmon subsystem.
> >
> > This should be submitted upstream, we have enough hacks already and
> > you will get proper feedback from Guenter rather fast whether this is a bug
> > in hwmon or the driver needs fixups.
>
> Thanks for your review and feedback!
>
> I am in the process of discussing this change upstream; the problem seems not to be related to hwmon core, but my approach of clamping the value is not going to be accepted either.
> I'm being asked to simply change the -ERANGE returned value to -EINVAL, so I will do it independently of this openwrt patch.

Perfect, I see that Andrew chimed in as well.
Realistically it should probably be clamped to -40 to 108 as that is
what the industrial models are rated at.

>
> But I am supposed to set max a min limits directly to reasonable values.
> I have no clear idea yet on where to set them in DTS, any help or hint would be very apreciated.

I am not sure if it's possible via DTS or only via sysfs.

Regards,
Robert
>
> Enrico
> >
> > Regards,
> > Robert
> >>
> >> CC: Andre Valentin <avalentin@marcant.net>
> >> CC: Karol Przybylski <karol.przybylski@esm-technology.pl>
> >> Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
> >> ---
> >>  ...-clamp-temperature-value-in-aqr_hwmo.patch | 30 +++++++++++++++++++
> >>  1 file changed, 30 insertions(+)
> >>  create mode 100644 target/linux/generic/hack-5.15/726-net-phy-aquantia-clamp-temperature-value-in-aqr_hwmo.patch
> >>
> >> diff --git a/target/linux/generic/hack-5.15/726-net-phy-aquantia-clamp-temperature-value-in-aqr_hwmo.patch b/target/linux/generic/hack-5.15/726-net-phy-aquantia-clamp-temperature-value-in-aqr_hwmo.patch
> >> new file mode 100644
> >> index 0000000000..36f0b37130
> >> --- /dev/null
> >> +++ b/target/linux/generic/hack-5.15/726-net-phy-aquantia-clamp-temperature-value-in-aqr_hwmo.patch
> >> @@ -0,0 +1,30 @@
> >> +From 7bfceb1036d2ccda7b8e1e177e834c1cea9f0858 Mon Sep 17 00:00:00 2001
> >> +From: Enrico Mioso <mrkiko.rs@gmail.com>
> >> +Date: Sat, 18 Feb 2023 00:27:55 +0100
> >> +Subject: [PATCH] net: phy: aquantia: clamp temperature value in aqr_hwmon_set
> >> +
> >> +This patch is still under evaluation and is not guaranteed to be correct,
> >> +therefore it is submitted here in hack form. :)
> >> +
> >> +Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
> >> +---
> >> + drivers/net/phy/aquantia_hwmon.c | 3 +--
> >> + 1 file changed, 1 insertion(+), 2 deletions(-)
> >> +
> >> +diff --git a/drivers/net/phy/aquantia_hwmon.c b/drivers/net/phy/aquantia_hwmon.c
> >> +index 19c4c280a6cd..6444055e720c 100644
> >> +--- a/drivers/net/phy/aquantia_hwmon.c
> >> ++++ b/drivers/net/phy/aquantia_hwmon.c
> >> +@@ -70,8 +70,7 @@ static int aqr_hwmon_set(struct phy_device *phydev, int reg, long value)
> >> + {
> >> +       int temp;
> >> +
> >> +-      if (value >= 128000 || value < -128000)
> >> +-              return -ERANGE;
> >> ++      clamp_val(value, -128000, 128000);
> >> +
> >> +       temp = value * 256 / 1000;
> >> +
> >> +--
> >> +2.39.2
> >> +
> >> --
> >> 2.39.2
> >>
> >>
> >> _______________________________________________
> >> openwrt-devel mailing list
> >> openwrt-devel@lists.openwrt.org
> >> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
> >
diff mbox series

Patch

diff --git a/target/linux/generic/hack-5.15/726-net-phy-aquantia-clamp-temperature-value-in-aqr_hwmo.patch b/target/linux/generic/hack-5.15/726-net-phy-aquantia-clamp-temperature-value-in-aqr_hwmo.patch
new file mode 100644
index 0000000000..36f0b37130
--- /dev/null
+++ b/target/linux/generic/hack-5.15/726-net-phy-aquantia-clamp-temperature-value-in-aqr_hwmo.patch
@@ -0,0 +1,30 @@ 
+From 7bfceb1036d2ccda7b8e1e177e834c1cea9f0858 Mon Sep 17 00:00:00 2001
+From: Enrico Mioso <mrkiko.rs@gmail.com>
+Date: Sat, 18 Feb 2023 00:27:55 +0100
+Subject: [PATCH] net: phy: aquantia: clamp temperature value in aqr_hwmon_set
+
+This patch is still under evaluation and is not guaranteed to be correct,
+therefore it is submitted here in hack form. :)
+
+Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
+---
+ drivers/net/phy/aquantia_hwmon.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/drivers/net/phy/aquantia_hwmon.c b/drivers/net/phy/aquantia_hwmon.c
+index 19c4c280a6cd..6444055e720c 100644
+--- a/drivers/net/phy/aquantia_hwmon.c
++++ b/drivers/net/phy/aquantia_hwmon.c
+@@ -70,8 +70,7 @@ static int aqr_hwmon_set(struct phy_device *phydev, int reg, long value)
+ {
+ 	int temp;
+ 
+-	if (value >= 128000 || value < -128000)
+-		return -ERANGE;
++	clamp_val(value, -128000, 128000);
+ 
+ 	temp = value * 256 / 1000;
+ 
+-- 
+2.39.2
+