pwm: Fallback to the static lookup-list when acpi_pwm_get fails
PATCH 1/1 pwm: Fallback to the static lookup-list when acpi_pwm_get fails
Commit 4a6ef8e37c4d ("pwm: Add support referencing PWMs from ACPI") made pwm_get unconditionally return the acpi_pwm_get return value if the device passed to pwm_get has an ACPI fwnode.
But even if the passed in device has an ACPI fwnode, it does not necessarily have the necessary ACPI package defining its pwm bindings, especially since the binding / API of this ACPI package has only been introduced very recently.
Up until now X86/ACPI devices which use a separate pwm controller for controlling their LCD screen's backlight brightness have been relying on the static lookup-list to get their pwm.
pwm_get unconditionally returning the acpi_pwm_get return value breaks this, breaking backlight control on these devices.
This commit fixes this by making pwm_get fall back to the static lookup-list if acpi_pwm_get returns -ENOENT.
--- drivers/pwm/core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/pwm/core.c +5 -2
@@ -882,8 +882,11 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)return of_pwm_get (dev, dev->of_node, con_id);/* then lookup via ACPI */ -if (dev &&is_acpi_node (dev->fwnode)) -return acpi_pwm_get (dev->fwnode); +if (dev &&is_acpi_node (dev->fwnode)) { + pwm =acpi_pwm_get (dev->fwnode); +if (!IS_ERR (pwm) ||PTR_ERR (pwm) != -ENOENT ) +return pwm; + }/* * We look up the provider in the static table typically provided by
Signature · 1 line
2.21.0
Quoted 13 lines · Hans de Goede
Commit
4a6ef8e37c4d("pwm: Add support referencing PWMs from ACPI") madepwm_getunconditionally return theacpi_pwm_getreturn value if the device passed topwm_gethas an ACPI fwnode.But even if the passed in device has an ACPI fwnode, it does not necessarily have the necessary ACPI package defining its pwm bindings, especially since the binding / API of this ACPI package has only been introduced very recently.
Up until now X86/ACPI devices which use a separate pwm controller for controlling their LCD screen's backlight brightness have been relying on the static lookup-list to get their pwm.
Quoted 6 lines
pwm_getunconditionally returning theacpi_pwm_getreturn value breaks this, breaking backlight control on these devices.This commit fixes this by making
pwm_getfall back to the static lookup-list ifacpi_pwm_getreturns-ENOENT.
Perhaps, we may switch to swnode API instead of lookup tables in the future?
Quoted 30 lines
Reported-by [email protected]Fixes 4a6ef8e37c4d ("pwm: Add support referencing PWMs from ACPI")Cc Nikolaus Voss <[email protected]>Signed-off-by Hans de Goede <[email protected]>--- drivers/pwm/core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/pwm/core.c +5
-2@@ -882,8 +882,11 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)return of_pwm_get (dev, dev->of_node, con_id);/* then lookup via ACPI */ -if (dev &&is_acpi_node (dev->fwnode)) -return acpi_pwm_get (dev->fwnode); +if (dev &&is_acpi_node (dev->fwnode)) { + pwm =acpi_pwm_get (dev->fwnode); +if (!IS_ERR (pwm) ||PTR_ERR (pwm) != -ENOENT ) +return pwm; + }/* * We look up the provider in the static table typically provided by Signature · 1 line
2.21.0
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hi Hans,
Quoted 13 lines · Hans de Goede
Commit
4a6ef8e37c4d("pwm: Add support referencing PWMs from ACPI") madepwm_getunconditionally return theacpi_pwm_getreturn value if the device passed topwm_gethas an ACPI fwnode.But even if the passed in device has an ACPI fwnode, it does not necessarily have the necessary ACPI package defining its pwm bindings, especially since the binding / API of this ACPI package has only been introduced very recently.
Up until now X86/ACPI devices which use a separate pwm controller for controlling their LCD screen's backlight brightness have been relying on the static lookup-list to get their pwm.
Quoted 5 lines
pwm_getunconditionally returning theacpi_pwm_getreturn value breaks this, breaking backlight control on these devices.This commit fixes this by making
pwm_getfall back to the static lookup-list ifacpi_pwm_getreturns-ENOENT.
Ok, I didn't find any pwm_add_table() calls in the x86 directory, so I thought the fallback matching is only for non-DT/non-ACPI systems. If it is used for ACPI nodes without PWM controller binding, it maybe should apply to DT nodes without PWM controller binding, too?
It would be structurally cleaner as DT and ACPI handling was symmetrical.
Niko
Quoted 32 lines
Reported-by [email protected]Fixes 4a6ef8e37c4d ("pwm: Add support referencing PWMs from ACPI")Cc Nikolaus Voss <[email protected]>Signed-off-by Hans de Goede <[email protected]>---
drivers/pwm/core.c| 7 +++++--1 file changed, 5 insertions(+), 2 deletions(-)drivers/pwm/core.c +5
-3@@ -882,8 +882,11 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)return of_pwm_get (dev, dev->of_node, con_id);/* then lookup via ACPI */ -if (dev &&is_acpi_node (dev->fwnode)) -return acpi_pwm_get (dev->fwnode); +if (dev &&is_acpi_node (dev->fwnode)) { + pwm =acpi_pwm_get (dev->fwnode); +if (!IS_ERR (pwm) ||PTR_ERR (pwm) != -ENOENT ) +return pwm; + }/* * We look up the provider in the static table typically provided by -- 2.21.0
Hi,
Quoted 16 lines · Nikolaus Voss
Hi Hans,
Quoted 13 lines · Hans de Goede
Commit
4a6ef8e37c4d("pwm: Add support referencing PWMs from ACPI") madepwm_getunconditionally return theacpi_pwm_getreturn value if the device passed topwm_gethas an ACPI fwnode.But even if the passed in device has an ACPI fwnode, it does not necessarily have the necessary ACPI package defining its pwm bindings, especially since the binding / API of this ACPI package has only been introduced very recently.
Up until now X86/ACPI devices which use a separate pwm controller for controlling their LCD screen's backlight brightness have been relying on the static lookup-list to get their pwm.
Quoted 7 lines
Quoted 5 lines
pwm_getunconditionally returning theacpi_pwm_getreturn value breaks this, breaking backlight control on these devices.This commit fixes this by making
pwm_getfall back to the static lookup-list ifacpi_pwm_getreturns-ENOENT.Ok, I didn't find any
pwm_add_table()calls in the x86 directory, so I thought the fallback matching is only for non-DT/non-ACPI systems.
AFAIK only Bay Trail and Cherry Trail X86 systems use a separate (not integrated into the GPU) PWM controller, but there are a lot of these systems out there. I got a bug report for this pretty much the day rc1 was out :)
The pwm_add_table calls are done in drivers/acpi/acpi_lpss.c.
Quoted 3 lines
If it is used for ACPI nodes without PWM controller binding, it maybe should apply to DT nodes without PWM controller binding, too?
It would be structurally cleaner as DT and ACPI handling was symmetrical.
I'm fine with someone doing a follow up patch along this lines, but given that this is a serious regression in 5.3 I would like to move forward with my tested patch as is to fix the regression in 5.3.
Regards,
Hans
Quoted 31 lines
Quoted 31 lines
Reported-by [email protected]Fixes 4a6ef8e37c4d ("pwm: Add support referencing PWMs from ACPI")Cc Nikolaus Voss <[email protected]>Signed-off-by Hans de Goede <[email protected]>---
drivers/pwm/core.c| 7 +++++--1 file changed, 5 insertions(+), 2 deletions(-)drivers/pwm/core.c +5
-2@@ -882,8 +882,11 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id) return of_pwm_get(dev, dev->of_node, con_id); /* then lookup via ACPI */ - if (dev && is_acpi_node(dev->fwnode)) - return acpi_pwm_get(dev->fwnode); + if (dev && is_acpi_node(dev->fwnode)) { + pwm = acpi_pwm_get(dev->fwnode); + if (!IS_ERR(pwm) || PTR_ERR(pwm) != -ENOENT) + return pwm; + } /** We look up the provider in the static table typically provided by Signature · 1 line
2.21.0
Nikolaus Voss
Acked-byQuoted 34 lines · Hans de Goede
Hi,
Quoted 16 lines · Nikolaus Voss
Hi Hans,
Quoted 13 lines · Hans de Goede
Commit
4a6ef8e37c4d("pwm: Add support referencing PWMs from ACPI") madepwm_getunconditionally return theacpi_pwm_getreturn value if the device passed topwm_gethas an ACPI fwnode.But even if the passed in device has an ACPI fwnode, it does not necessarily have the necessary ACPI package defining its pwm bindings, especially since the binding / API of this ACPI package has only been introduced very recently.
Up until now X86/ACPI devices which use a separate pwm controller for controlling their LCD screen's backlight brightness have been relying on the static lookup-list to get their pwm.
Quoted 7 lines
Quoted 5 lines
pwm_getunconditionally returning theacpi_pwm_getreturn value breaks this, breaking backlight control on these devices.This commit fixes this by making
pwm_getfall back to the static lookup-list ifacpi_pwm_getreturns-ENOENT.Ok, I didn't find any
pwm_add_table()calls in the x86 directory, so I thought the fallback matching is only for non-DT/non-ACPI systems.AFAIK only Bay Trail and Cherry Trail X86 systems use a separate (not integrated into the GPU) PWM controller, but there are a lot of these systems out there. I got a bug report for this pretty much the day rc1 was out :)
The
pwm_add_tablecalls are done indrivers/acpi/acpi_lpss.c.
Quoted 7 lines
Quoted 3 lines
If it is used for ACPI nodes without PWM controller binding, it maybe should apply to DT nodes without PWM controller binding, too?
It would be structurally cleaner as DT and ACPI handling was symmetrical.
I'm fine with someone doing a follow up patch along this lines, but given that this is a serious regression in 5.3 I would like to move forward with my tested patch as is to fix the regression in 5.3.
Makes sense, thank you for the explanation.
Quoted 40 lines
Regards,
Hans
Quoted 32 lines
Quoted 32 lines
Reported-by [email protected]Fixes 4a6ef8e37c4d ("pwm: Add support referencing PWMs from ACPI")Cc Nikolaus Voss <[email protected]>Signed-off-by Hans de Goede <[email protected]>---
drivers/pwm/core.c| 7 +++++--1 file changed, 5 insertions(+), 2 deletions(-)drivers/pwm/core.c +5
-2@@ -882,8 +882,11 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id) return of_pwm_get(dev, dev->of_node, con_id); /* then lookup via ACPI */ - if (dev && is_acpi_node(dev->fwnode)) - return acpi_pwm_get(dev->fwnode); + if (dev && is_acpi_node(dev->fwnode)) { + pwm = acpi_pwm_get(dev->fwnode); + if (!IS_ERR(pwm) || PTR_ERR(pwm) != -ENOENT) + return pwm; + } /** We look up the provider in the static table typically provided by
Signature · 1 line
2.21.0
Thierry,
Ping? This fixes a somewhat serious regression in 5.3, can we please get this queued up for merging into 5.3 ?
Regards,
Hans
Quoted 47 lines · Hans de Goede
Commit
4a6ef8e37c4d("pwm: Add support referencing PWMs from ACPI") madepwm_getunconditionally return theacpi_pwm_getreturn value if the device passed topwm_gethas an ACPI fwnode.ThieerBut even if the passed in device has an ACPI fwnode, it does not necessarily have the necessary ACPI package defining its pwm bindings, especially since the binding / API of this ACPI package has only been introduced very recently.
Up until now X86/ACPI devices which use a separate pwm controller for controlling their LCD screen's backlight brightness have been relying on the static lookup-list to get their pwm.
pwm_getunconditionally returning theacpi_pwm_getreturn value breaks this, breaking backlight control on these devices.This commit fixes this by making
pwm_getfall back to the static lookup-list ifacpi_pwm_getreturns-ENOENT.Reported-by [email protected]Fixes 4a6ef8e37c4d ("pwm: Add support referencing PWMs from ACPI")Cc Nikolaus Voss <[email protected]>Signed-off-by Hans de Goede <[email protected]>--- drivers/pwm/core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/pwm/core.c +5
-2@@ -882,8 +882,11 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)return of_pwm_get (dev, dev->of_node, con_id);/* then lookup via ACPI */ -if (dev &&is_acpi_node (dev->fwnode)) -return acpi_pwm_get (dev->fwnode); +if (dev &&is_acpi_node (dev->fwnode)) { + pwm =acpi_pwm_get (dev->fwnode); +if (!IS_ERR (pwm) ||PTR_ERR (pwm) != -ENOENT ) +return pwm; + }/* * We look up the provider in the static table typically provided by
Quoted 4 lines · Hans de Goede
Thierry,
Ping? This fixes a somewhat serious regression in 5.3, can we please get this queued up for merging into 5.3 ?
I've pushed this out. Let's give it a day in linux-next and then I'll send out a PR for v5.3-rc4.
Thierry
Hi,
Quoted 8 lines · Thierry Reding
Quoted 4 lines · Hans de Goede
Thierry,
Ping? This fixes a somewhat serious regression in 5.3, can we please get this queued up for merging into 5.3 ?
I've pushed this out. Let's give it a day in linux-next and then I'll send out a PR for v5.3-rc4.
Great, thank you.
Regards,
Hans