HID: i2c: Call acpi_device_fix_up_power for ACPI-enumerated devices
PATCH 1/1 HID: i2c: Call acpi_device_fix_up_power for ACPI-enumerated devices
ACPI devices which do not have a _PSC method are assumed to have been put in D0 by the BIOS, but for touchscreens that is not always true, so call acpi_device_fix_up_power to explicitly put devices without a _PSC method into D0 state.
This fixes the SIS0817 i2c-hid touchscreen on a Peaq C1010 2-in-1 device failing to probe with a "hid_descr_cmd failed" error.
--- drivers/hid/i2c-hid/i2c-hid.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/hid/i2c-hid/i2c-hid.c +13 -0
@@ -960,6 +960,15 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,return 0 ; } +static void i2c_hid_acpi_fix_up_power (struct device *dev) +{ +acpi_handle handle =ACPI_HANDLE (dev); +struct acpi_device *adev; + +if (handle &&acpi_bus_get_device (handle, &adev) ==0 ) +acpi_device_fix_up_power (adev); +} +static const struct acpi_device_id i2c_hid_acpi_match[] = { {"ACPI0C50" ,0 }, {"PNP0C50" ,0 },
@@ -972,6 +981,8 @@ static inline int i2c_hid_acpi_pdata(struct i2c_client *client, {return -ENODEV ; } + +static inline void i2c_hid_acpi_fix_up_power (struct device *dev) {}#endif #ifdef CONFIG_OF
@@ -1070,6 +1081,8 @@ static int i2c_hid_probe(struct i2c_client *client,if (ret <0 ) goto err; +i2c_hid_acpi_fix_up_power (&client->dev); +pm_runtime_get_noresume (&client->dev);pm_runtime_set_active (&client->dev);pm_runtime_enable (&client->dev);
Signature · 1 line
2.12.2
Hi Hans,
Quoted 18 lines · Hans de Goede
ACPI devices which do not have a
_PSCmethod are assumed to have been put in D0 by the BIOS, but for touchscreens that is not always true, so callacpi_device_fix_up_powerto explicitly put devices without a_PSCmethod into D0 state.This fixes the SIS0817 i2c-hid touchscreen on a Peaq C1010 2-in-1 device failing to probe with a "
hid_descr_cmdfailed" error.Signed-off-by Hans de Goede <[email protected]>--- drivers/hid/i2c-hid/i2c-hid.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/hid/i2c-hid/i2c-hid.c +0
-0
drivers/hid/i2c-hid/i2c-hid.c static int i2c_hid_acpi_pdata(struct i2c_client *client, · line 969
Quoted 10 lines
drivers/hid/i2c-hid/i2c-hid.c +7
-0@@ -960,6 +960,15 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,return 0 ; } +static void i2c_hid_acpi_fix_up_power (struct device *dev) +{ +acpi_handle handle =ACPI_HANDLE (dev); +struct acpi_device *adev; + +if (handle &&acpi_bus_get_device (handle, &adev) ==0 ) +acpi_device_fix_up_power (adev);
I am wondering if this is not something that should be handled by acpi-core or i2c-core. Looks like something pretty generic.
Also, isn't this also needed on resume (or reset_resume)?
Cheers,
Benjamin
Quoted 26 lines
drivers/hid/i2c-hid/i2c-hid.c +6
-0+} +static const struct acpi_device_id i2c_hid_acpi_match[] = { {"ACPI0C50" ,0 }, {"PNP0C50" ,0 },@@ -972,6 +981,8 @@ static inline int i2c_hid_acpi_pdata(struct i2c_client *client, {return -ENODEV ; } + +static inline void i2c_hid_acpi_fix_up_power (struct device *dev) {}#endif #ifdef CONFIG_OF @@ -1070,6 +1081,8 @@ static int i2c_hid_probe(struct i2c_client *client,if (ret <0 ) goto err; +i2c_hid_acpi_fix_up_power (&client->dev); +pm_runtime_get_noresume (&client->dev);pm_runtime_set_active (&client->dev);pm_runtime_enable (&client->dev);Signature · 1 line
2.12.2
Hi,
Quoted 24 lines · Benjamin Tissoires
Hi Hans,
Quoted 21 lines · Hans de Goede
ACPI devices which do not have a
_PSCmethod are assumed to have been put in D0 by the BIOS, but for touchscreens that is not always true, so callacpi_device_fix_up_powerto explicitly put devices without a_PSCmethod into D0 state.This fixes the SIS0817 i2c-hid touchscreen on a Peaq C1010 2-in-1 device failing to probe with a "
hid_descr_cmdfailed" error.Signed-off-by Hans de Goede <[email protected]>--- drivers/hid/i2c-hid/i2c-hid.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/hid/i2c-hid/i2c-hid.c +0
-0@@ -960,6 +960,15 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,return 0 ; }
Quoted 10 lines
drivers/hid/i2c-hid/i2c-hid.c static int i2c_hid_acpi_pdata(struct i2c_client *client, · line 969
Quoted 7 lines
drivers/hid/i2c-hid/i2c-hid.c +7
-0+static void i2c_hid_acpi_fix_up_power (struct device *dev) +{ +acpi_handle handle =ACPI_HANDLE (dev); +struct acpi_device *adev; + +if (handle &&acpi_bus_get_device (handle, &adev) ==0 ) +acpi_device_fix_up_power (adev);I am wondering if this is not something that should be handled by acpi-core or i2c-core. Looks like something pretty generic.
The acpi-core deliberately does not do this, as unconditionally doing this for all devices is known to break things on some platforms, see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7cd8407
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b9e95fc65eded
So calling this is something which needs to be done an a device-by-device (usually actually on a driver-by-driver) basis.
I don't expect this to cause any problems for i2c-hid devices
(as the above commits shown once it was done for all ACPI enumerated devices) and it is necessary for some i2c-hid devices.
Quoted 1 line
Also, isn't this also needed on resume (or
reset_resume)?
After a suspend the device is in D3, so we will always execute _PS0 to put it back in D0. This is about devices without a _PSC method (which allows querying the actual state) being in D3 on boot, rather then the expected (and assumed) D0. Note that for devices with a _PSC method calling acpi_device_fix_up_power() is a nop.
Regards,
Hans
Quoted 26 lines
Quoted 26 lines
drivers/hid/i2c-hid/i2c-hid.c +6
-0+} +static const struct acpi_device_id i2c_hid_acpi_match[] = { {"ACPI0C50" ,0 }, {"PNP0C50" ,0 },@@ -972,6 +981,8 @@ static inline int i2c_hid_acpi_pdata(struct i2c_client *client, {return -ENODEV ; } + +static inline void i2c_hid_acpi_fix_up_power (struct device *dev) {}#endif #ifdef CONFIG_OF @@ -1070,6 +1081,8 @@ static int i2c_hid_probe(struct i2c_client *client,if (ret <0 ) goto err; +i2c_hid_acpi_fix_up_power (&client->dev); +pm_runtime_get_noresume (&client->dev);pm_runtime_set_active (&client->dev);pm_runtime_enable (&client->dev);Signature · 1 line
2.12.2
Benjamin Tissoires
Acked-byQuoted 51 lines · Hans de Goede
Hi,
Quoted 25 lines · Benjamin Tissoires
Hi Hans,
Quoted 22 lines · Hans de Goede
ACPI devices which do not have a
_PSCmethod are assumed to have been put in D0 by the BIOS, but for touchscreens that is not always true, so callacpi_device_fix_up_powerto explicitly put devices without a_PSCmethod into D0 state.This fixes the SIS0817 i2c-hid touchscreen on a Peaq C1010 2-in-1 device failing to probe with a "
hid_descr_cmdfailed" error.Signed-off-by Hans de Goede <[email protected]>--- drivers/hid/i2c-hid/i2c-hid.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/hid/i2c-hid/i2c-hid.c +2
-0@@ -960,6 +960,15 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,return 0 ; } +static void i2c_hid_acpi_fix_up_power (struct device *dev) +{Quoted 8 lines
drivers/hid/i2c-hid/i2c-hid.c static int i2c_hid_acpi_pdata(struct i2c_client *client, · line 969
Quoted 5 lines
drivers/hid/i2c-hid/i2c-hid.c +5
-0+acpi_handle handle =ACPI_HANDLE (dev); +struct acpi_device *adev; + +if (handle &&acpi_bus_get_device (handle, &adev) ==0 ) +acpi_device_fix_up_power (adev);I am wondering if this is not something that should be handled by acpi-core or i2c-core. Looks like something pretty generic.
The acpi-core deliberately does not do this, as unconditionally doing this for all devices is known to break things on some platforms, see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7cd8407
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b9e95fc65ededSo calling this is something which needs to be done an a device-by-device (usually actually on a driver-by-driver) basis.
I don't expect this to cause any problems for i2c-hid devices
(as the above commits shown once it was done for all ACPI enumerated devices) and it is necessary for some i2c-hid devices.
Quoted 8 lines
Quoted 1 line
Also, isn't this also needed on resume (or
reset_resume)?After a suspend the device is in D3, so we will always execute
_PS0to put it back in D0. This is about devices without a_PSCmethod (which allows querying the actual state) being in D3 on boot, rather then the expected (and assumed) D0. Note that for devices with a_PSCmethod callingacpi_device_fix_up_power()is a nop.
Thanks for the extensive explanations.
Maybe we can add this to the commit message for future reference?
Cheers,
Benjamin
Quoted 28 lines
Regards,
Hans
Quoted 24 lines
Quoted 24 lines
drivers/hid/i2c-hid/i2c-hid.c +6
-0+} +static const struct acpi_device_id i2c_hid_acpi_match[] = { {"ACPI0C50" ,0 }, {"PNP0C50" ,0 },@@ -972,6 +981,8 @@ static inline int i2c_hid_acpi_pdata(struct i2c_client *client, {return -ENODEV ; } + +static inline void i2c_hid_acpi_fix_up_power (struct device *dev) {}#endif #ifdef CONFIG_OF @@ -1070,6 +1081,8 @@ static int i2c_hid_probe(struct i2c_client *client,if (ret <0 ) goto err; +i2c_hid_acpi_fix_up_power (&client->dev); +pm_runtime_get_noresume (&client->dev);pm_runtime_set_active (&client->dev);pm_runtime_enable (&client->dev);Signature · 1 line
2.12.2
Hi,
Quoted 61 lines · Benjamin Tissoires
Quoted 51 lines · Hans de Goede
Hi,
Quoted 25 lines · Benjamin Tissoires
Hi Hans,
Quoted 22 lines · Hans de Goede
ACPI devices which do not have a
_PSCmethod are assumed to have been put in D0 by the BIOS, but for touchscreens that is not always true, so callacpi_device_fix_up_powerto explicitly put devices without a_PSCmethod into D0 state.This fixes the SIS0817 i2c-hid touchscreen on a Peaq C1010 2-in-1 device failing to probe with a "
hid_descr_cmdfailed" error.Signed-off-by Hans de Goede <[email protected]>--- drivers/hid/i2c-hid/i2c-hid.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/hid/i2c-hid/i2c-hid.c +2
-0@@ -960,6 +960,15 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,return 0 ; } +static void i2c_hid_acpi_fix_up_power (struct device *dev) +{Quoted 8 lines
drivers/hid/i2c-hid/i2c-hid.c static int i2c_hid_acpi_pdata(struct i2c_client *client, · line 969
Quoted 5 lines
drivers/hid/i2c-hid/i2c-hid.c +5
-0+acpi_handle handle =ACPI_HANDLE (dev); +struct acpi_device *adev; + +if (handle &&acpi_bus_get_device (handle, &adev) ==0 ) +acpi_device_fix_up_power (adev);I am wondering if this is not something that should be handled by acpi-core or i2c-core. Looks like something pretty generic.
The acpi-core deliberately does not do this, as unconditionally doing this for all devices is known to break things on some platforms, see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7cd8407
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b9e95fc65ededSo calling this is something which needs to be done an a device-by-device (usually actually on a driver-by-driver) basis.
I don't expect this to cause any problems for i2c-hid devices
(as the above commits shown once it was done for all ACPI enumerated devices) and it is necessary for some i2c-hid devices.Quoted 8 lines
Quoted 1 line
Also, isn't this also needed on resume (or
reset_resume)?After a suspend the device is in D3, so we will always execute
_PS0to put it back in D0. This is about devices without a_PSCmethod (which allows querying the actual state) being in D3 on boot, rather then the expected (and assumed) D0. Note that for devices with a_PSCmethod callingacpi_device_fix_up_power()is a nop.
Quoted 3 lines
Thanks for the extensive explanations.
Thank you.
Quoted 1 line
Maybe we can add this to the commit message for future reference?
Ok, I'm about to send a v2 with an improved commit msg:
"For ACPI devices which do not have a _PSC method, the ACPI subsys cannot query their initial state at boot, so these devices are assumed to have been put in D0 by the BIOS, but for touchscreens that is not always true.
This commit adds a call to acpi_device_fix_up_power to explicitly put devices without a _PSC method into D0 state (for devices with a _PSC method it is a nop). Note we only need to do this on probe, after a resume the ACPI subsys knows the device is in D3 and will properly put it in D0.
This fixes the SIS0817 i2c-hid touchscreen on a Peaq C1010 2-in-1 device failing to probe with a "hid_descr_cmd failed" error."
Regards,
Hans
Quoted 32 lines
Cheers,
BenjaminQuoted 28 lines
Regards,
Hans
Quoted 24 lines
Quoted 24 lines
drivers/hid/i2c-hid/i2c-hid.c +6
-0+} +static const struct acpi_device_id i2c_hid_acpi_match[] = { {"ACPI0C50" ,0 }, {"PNP0C50" ,0 },@@ -972,6 +981,8 @@ static inline int i2c_hid_acpi_pdata(struct i2c_client *client, {return -ENODEV ; } + +static inline void i2c_hid_acpi_fix_up_power (struct device *dev) {}#endif #ifdef CONFIG_OF @@ -1070,6 +1081,8 @@ static int i2c_hid_probe(struct i2c_client *client,if (ret <0 ) goto err; +i2c_hid_acpi_fix_up_power (&client->dev); +pm_runtime_get_noresume (&client->dev);pm_runtime_set_active (&client->dev);pm_runtime_enable (&client->dev);Signature · 1 line
2.12.2
Quoted 78 lines · Hans de Goede
Hi,
Quoted 61 lines · Benjamin Tissoires
Quoted 51 lines · Hans de Goede
Hi,
Quoted 25 lines · Benjamin Tissoires
Hi Hans,
Quoted 22 lines · Hans de Goede
ACPI devices which do not have a
_PSCmethod are assumed to have been put in D0 by the BIOS, but for touchscreens that is not always true, so callacpi_device_fix_up_powerto explicitly put devices without a_PSCmethod into D0 state.This fixes the SIS0817 i2c-hid touchscreen on a Peaq C1010 2-in-1 device failing to probe with a "
hid_descr_cmdfailed" error.Signed-off-by Hans de Goede <[email protected]>--- drivers/hid/i2c-hid/i2c-hid.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/hid/i2c-hid/i2c-hid.c +2
-0@@ -960,6 +960,15 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,return 0 ; } +static void i2c_hid_acpi_fix_up_power (struct device *dev) +{Quoted 8 lines
drivers/hid/i2c-hid/i2c-hid.c static int i2c_hid_acpi_pdata(struct i2c_client *client, · line 969
Quoted 5 lines
drivers/hid/i2c-hid/i2c-hid.c +5
-0+acpi_handle handle =ACPI_HANDLE (dev); +struct acpi_device *adev; + +if (handle &&acpi_bus_get_device (handle, &adev) ==0 ) +acpi_device_fix_up_power (adev);I am wondering if this is not something that should be handled by acpi-core or i2c-core. Looks like something pretty generic.
The acpi-core deliberately does not do this, as unconditionally doing this for all devices is known to break things on some platforms, see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7cd8407
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b9e95fc65ededSo calling this is something which needs to be done an a device-by-device (usually actually on a driver-by-driver) basis.
I don't expect this to cause any problems for i2c-hid devices
(as the above commits shown once it was done for all ACPI enumerated devices) and it is necessary for some i2c-hid devices.Quoted 8 lines
Quoted 1 line
Also, isn't this also needed on resume (or
reset_resume)?After a suspend the device is in D3, so we will always execute
_PS0to put it back in D0. This is about devices without a_PSCmethod (which allows querying the actual state) being in D3 on boot, rather then the expected (and assumed) D0. Note that for devices with a_PSCmethod callingacpi_device_fix_up_power()is a nop.Quoted 3 lines
Thanks for the extensive explanations.
Thank you.
Quoted 1 line
Maybe we can add this to the commit message for future reference?
Ok, I'm about to send a v2 with an improved commit msg:
"For ACPI devices which do not have a
_PSCmethod, the ACPI subsys cannot query their initial state at boot, so these devices are assumed to have been put in D0 by the BIOS, but for touchscreens that is not always true.
Quoted 8 lines
This commit adds a call to
acpi_device_fix_up_powerto explicitly put devices without a_PSCmethod into D0 state (for devices with a_PSCmethod it is a nop). Note we only need to do this on probe, after a resume the ACPI subsys knows the device is in D3 and will properly put it in D0.This fixes the SIS0817 i2c-hid touchscreen on a Peaq C1010 2-in-1 device failing to probe with a "
hid_descr_cmdfailed" error."
Works for me.
Thanks for the quick respin.
Cheers,
Benjamin
Quoted 38 lines
Regards,
Hans
Quoted 32 lines
Cheers,
BenjaminQuoted 28 lines
Regards,
Hans
Quoted 24 lines
Quoted 24 lines
drivers/hid/i2c-hid/i2c-hid.c +6
-0+} +static const struct acpi_device_id i2c_hid_acpi_match[] = { {"ACPI0C50" ,0 }, {"PNP0C50" ,0 },@@ -972,6 +981,8 @@ static inline int i2c_hid_acpi_pdata(struct i2c_client *client, {return -ENODEV ; } + +static inline void i2c_hid_acpi_fix_up_power (struct device *dev) {}#endif #ifdef CONFIG_OF @@ -1070,6 +1081,8 @@ static int i2c_hid_probe(struct i2c_client *client,if (ret <0 ) goto err; +i2c_hid_acpi_fix_up_power (&client->dev); +pm_runtime_get_noresume (&client->dev);pm_runtime_set_active (&client->dev);pm_runtime_enable (&client->dev);Signature · 1 line
2.12.2