platform/x86: thinkpad_acpi: Fix Embedded Controller access on X380 Yoga
PATCH 1/1 platform/x86: thinkpad_acpi: Fix Embedded Controller access on X380 Yoga
On the X380 Yoga, the ECRD and ECWR ACPI objects cannot be used for accessing the Embedded Controller: instead of a method that reads from the EC's memory, ECRD is the name of a location in high memory. This meant that trying to call them would fail with the following message:
ACPI: \_SB.PCI0.LPCB.EC.ECRD: 1 arguments were passed to a non-method ACPI object (RegionField)
With this commit, it is now possible to access the EC and read temperature and fan speed information. Note that while writes to the HFSP register do go through (as indicated by subsequent reads showing the new value), the fan does not actually change its speed.
--- drivers/platform/x86/thinkpad_acpi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/platform/x86/thinkpad_acpi.c +16 -0
@@ -11699,6 +11699,7 @@ static int __init thinkpad_acpi_module_init(void) {const struct dmi_system_id *dmi_id;int ret, i; +acpi_object_type obj_type; tpacpi_lifecycle =TPACPI_LIFE_INIT ;
@@ -11724,6 +11725,21 @@ static int __init thinkpad_acpi_module_init(void)TPACPI_ACPIHANDLE_INIT (ecrd);TPACPI_ACPIHANDLE_INIT (ecwr); +/* +* Quirk: in some models (e.g. X380 Yoga), an object named ECRD +* exists, but it is a register, not a method. +*/ +if (ecrd_handle) { +acpi_get_type (ecrd_handle, &obj_type); +if (obj_type !=ACPI_TYPE_METHOD ) + ecrd_handle =NULL ; + } +if (ecwr_handle) { +acpi_get_type (ecwr_handle, &obj_type); +if (obj_type !=ACPI_TYPE_METHOD ) + ecwr_handle =NULL ; + } + tpacpi_wq =create_singlethread_workqueue (TPACPI_WORKQUEUE_NAME );if (!tpacpi_wq) {thinkpad_acpi_module_exit ();
Signature · 1 line
2.40.0
Hi,
Quoted 8 lines · Daniel Bertalan
On the X380 Yoga, the
ECRDandECWRACPI objects cannot be used for accessing the Embedded Controller: instead of a method that reads from the EC's memory,ECRDis the name of a location in high memory. This meant that trying to call them would fail with the following message:ACPI: \_SB.PCI0.LPCB.EC.ECRD: 1 arguments were passed to a non-method ACPI object (RegionField)
Quoted 6 lines
With this commit, it is now possible to access the EC and read temperature and fan speed information. Note that while writes to the HFSP register do go through (as indicated by subsequent reads showing the new value), the fan does not actually change its speed.
Signed-off-by Daniel Bertalan <[email protected]>
Interestig, this looks like a pretty clean solution to me.
Mark Pearson, do you have any remarks on this ?
Regards,
Hans
Quoted 38 lines
--- drivers/platform/x86/thinkpad_acpi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/platform/x86/thinkpad_acpi.c +16
-0@@ -11699,6 +11699,7 @@ static int __init thinkpad_acpi_module_init(void) {const struct dmi_system_id *dmi_id;int ret, i; +acpi_object_type obj_type; tpacpi_lifecycle =TPACPI_LIFE_INIT ;@@ -11724,6 +11725,21 @@ static int __init thinkpad_acpi_module_init(void)TPACPI_ACPIHANDLE_INIT (ecrd);TPACPI_ACPIHANDLE_INIT (ecwr); +/* +* Quirk: in some models (e.g. X380 Yoga), an object named ECRD +* exists, but it is a register, not a method. +*/ +if (ecrd_handle) { +acpi_get_type (ecrd_handle, &obj_type); +if (obj_type !=ACPI_TYPE_METHOD ) + ecrd_handle =NULL ; + } +if (ecwr_handle) { +acpi_get_type (ecwr_handle, &obj_type); +if (obj_type !=ACPI_TYPE_METHOD ) + ecwr_handle =NULL ; + } + tpacpi_wq =create_singlethread_workqueue (TPACPI_WORKQUEUE_NAME );if (!tpacpi_wq) {thinkpad_acpi_module_exit ();
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi,
Quoted 19 lines · Liav Albani
Quoted 17 lines · Hans de Goede
Hi,
Quoted 14 lines · Daniel Bertalan
On the X380 Yoga, the
ECRDandECWRACPI objects cannot be used for accessing the Embedded Controller: instead of a method that reads from the EC's memory,ECRDis the name of a location in high memory. This meant that trying to call them would fail with the following message:ACPI: \_SB.PCI0.LPCB.EC.ECRD: 1 arguments were passed to a non-method ACPI object (RegionField)
With this commit, it is now possible to access the EC and read temperature and fan speed information. Note that while writes to the HFSP register do go through (as indicated by subsequent reads showing the new value), the fan does not actually change its speed.
Signed-off-by Daniel Bertalan <[email protected]>
Quoted 8 lines
Quoted 1 line
Interestig, this looks like a pretty clean solution to me.
Daniel and I have looked in the DSDT ASL code and found a bunch of registers in high physical memory location (which is an ACPI OpRegion), and one of the registers had a bit called ECRD.
However, there were many other registers that might be interesting as well, the problem is the short names in the ASL code (so we only see abbreviations essentially).While I do agree that adding this code is indeed a clean solution, if you (people that are dealing with Thinkpad laptops) know about cleaner way to access the embedded controller, I think it's preferable, because this way Daniel might be able to trigger the fan on that laptop so it will actually spin and will dissipate-out heat from the system, without the relying on the embedded controller to get into some sort of thermal state and then to trigger the fan.
Have you tried falling back to the ec_read() and ec_write() helpers exported by the ACPI EC code ?
The "first_ec" pointer used by these functions is exported too, so you could try modifying thinkpad_acpi to use ec_read() and ec_write() as fallback when first_ec is set (and the quirk added by this patch triggers).
Regards,
Hans
Quoted 45 lines
Quoted 45 lines
Mark Pearson, do you have any remarks on this ?
Regards,
Hans
Quoted 38 lines
--- drivers/platform/x86/thinkpad_acpi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/platform/x86/thinkpad_acpi.c +16
-0@@ -11699,6 +11699,7 @@ static int __init thinkpad_acpi_module_init(void) {const struct dmi_system_id *dmi_id;int ret, i; +acpi_object_type obj_type; tpacpi_lifecycle =TPACPI_LIFE_INIT ;@@ -11724,6 +11725,21 @@ static int __init thinkpad_acpi_module_init(void)TPACPI_ACPIHANDLE_INIT (ecrd);TPACPI_ACPIHANDLE_INIT (ecwr); +/* +* Quirk: in some models (e.g. X380 Yoga), an object named ECRD +* exists, but it is a register, not a method. +*/ +if (ecrd_handle) { +acpi_get_type (ecrd_handle, &obj_type); +if (obj_type !=ACPI_TYPE_METHOD ) + ecrd_handle =NULL ; + } +if (ecwr_handle) { +acpi_get_type (ecwr_handle, &obj_type); +if (obj_type !=ACPI_TYPE_METHOD ) + ecwr_handle =NULL ; + } + tpacpi_wq =create_singlethread_workqueue (TPACPI_WORKQUEUE_NAME );if (!tpacpi_wq) {thinkpad_acpi_module_exit ();
Hi,
Quoted 33 lines · Hans de Goede
Hi,
Quoted 19 lines · Liav Albani
Quoted 17 lines · Hans de Goede
Hi,
Quoted 13 lines · Daniel Bertalan
On the X380 Yoga, the
ECRDandECWRACPI objects cannot be used for accessing the Embedded Controller: instead of a method that reads from the EC's memory,ECRDis the name of a location in high memory. This meant that trying to call them would fail with the following message:ACPI: \_SB.PCI0.LPCB.EC.ECRD: 1 arguments were passed to a non-method ACPI object (RegionField)
With this commit, it is now possible to access the EC and read temperature and fan speed information. Note that while writes to the HFSP register do go through (as indicated by subsequent reads showing the new value), the fan does not actually change its speed.
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Daniel Bertalan [email protected]Interestig, this looks like a pretty clean solution to me.
Daniel and I have looked in the DSDT ASL code and found a bunch of registers in high physical memory location (which is an ACPI OpRegion), and one of the registers had a bit called ECRD.
However, there were many other registers that might be interesting as well, the problem is the short names in the ASL code (so we only see abbreviations essentially).While I do agree that adding this code is indeed a clean solution, if you (people that are dealing with Thinkpad laptops) know about cleaner way to access the embedded controller, I think it's preferable, because this way Daniel might be able to trigger the fan on that laptop so it will actually spin and will dissipate-out heat from the system, without the relying on the embedded controller to get into some sort of thermal state and then to trigger the fan.
Quoted 7 lines
Have you tried falling back to the
ec_read()andec_write()helpers exported by the ACPI EC code ?The "
first_ec" pointer used by these functions is exported too, so you could try modifyingthinkpad_acpito useec_read()andec_write()as fallback whenfirst_ecis set (and the quirk added by this patch triggers).
This is basically what my patch does. If the ECRD/ECWR method handles are NULL, thinkpad_acpi's acpi_ec_{read,write} functions fall back to the regular ACPI EC helpers you mentioned.
Speaking of which, does anyone know why these private helper functions exist in the first place? The code seems to use them interchangeably. Even in the fan control code, there are places where the regular EC helpers are called directly. Can we get away with always doing that?
Back to the issue at hand, is there someone we could ask if the X380Y even supports manual fan control in the first place? My debugging efforts are starting to look like a wild goose chase.
The thermal sensors and fan PWM readings now work, which is better than nothing, but it would be good to get to the bottom of this.
All the best,
Daniel
Quoted 49 lines
Regards,
Hans
Quoted 44 lines
Quoted 44 lines
Mark Pearson, do you have any remarks on this ?
Regards,
Hans
Quoted 38 lines
---
drivers/platform/x86/thinkpad_acpi.c| 16 ++++++++++++++++1 file changed, 16 insertions(+)drivers/platform/x86/thinkpad_acpi.c +16
-0@@ -11699,6 +11699,7 @@ static int __init thinkpad_acpi_module_init(void) {const struct dmi_system_id *dmi_id;int ret, i; +acpi_object_type obj_type; tpacpi_lifecycle =TPACPI_LIFE_INIT ;@@ -11724,6 +11725,21 @@ static int __init thinkpad_acpi_module_init(void)TPACPI_ACPIHANDLE_INIT (ecrd);TPACPI_ACPIHANDLE_INIT (ecwr); +/* +* Quirk: in some models (e.g. X380 Yoga), an object named ECRD +* exists, but it is a register, not a method. +*/ +if (ecrd_handle) { +acpi_get_type (ecrd_handle, &obj_type); +if (obj_type !=ACPI_TYPE_METHOD ) + ecrd_handle =NULL ; + } +if (ecwr_handle) { +acpi_get_type (ecwr_handle, &obj_type); +if (obj_type !=ACPI_TYPE_METHOD ) + ecwr_handle =NULL ; + } + tpacpi_wq =create_singlethread_workqueue (TPACPI_WORKQUEUE_NAME );if (!tpacpi_wq) {thinkpad_acpi_module_exit ();
Hi,
Quoted 40 lines · Daniel Bertalan
Hi,
Quoted 36 lines · Hans de Goede
Hi,
Quoted 19 lines · Liav Albani
Quoted 17 lines · Hans de Goede
Hi,
Quoted 13 lines · Daniel Bertalan
On the X380 Yoga, the
ECRDandECWRACPI objects cannot be used for accessing the Embedded Controller: instead of a method that reads from the EC's memory,ECRDis the name of a location in high memory. This meant that trying to call them would fail with the following message:ACPI: \_SB.PCI0.LPCB.EC.ECRD: 1 arguments were passed to a non-method ACPI object (RegionField)
With this commit, it is now possible to access the EC and read temperature and fan speed information. Note that while writes to the HFSP register do go through (as indicated by subsequent reads showing the new value), the fan does not actually change its speed.
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Daniel Bertalan [email protected]Interestig, this looks like a pretty clean solution to me.
Daniel and I have looked in the DSDT ASL code and found a bunch of registers in high physical memory location (which is an ACPI OpRegion), and one of the registers had a bit called ECRD.
However, there were many other registers that might be interesting as well, the problem is the short names in the ASL code (so we only see abbreviations essentially).While I do agree that adding this code is indeed a clean solution, if you (people that are dealing with Thinkpad laptops) know about cleaner way to access the embedded controller, I think it's preferable, because this way Daniel might be able to trigger the fan on that laptop so it will actually spin and will dissipate-out heat from the system, without the relying on the embedded controller to get into some sort of thermal state and then to trigger the fan.
Have you tried falling back to the
ec_read()andec_write()helpers exported by the ACPI EC code ?
Quoted 8 lines
Quoted 4 lines
The "
first_ec" pointer used by these functions is exported too, so you could try modifyingthinkpad_acpito useec_read()andec_write()as fallback whenfirst_ecis set (and the quirk added by this patch triggers).This is basically what my patch does. If the ECRD/ECWR method handles are NULL, thinkpad_acpi's acpi_ec_{read,write} functions fall back to the regular ACPI EC helpers you mentioned.
Ah I did not realize that. Ok that sounds good to me.
I'll go and apply the patch then. To be on the save side I'm going to only add this to -next, so that it gets some testing before showing up in stable series. Once 6.4-rc1 is out you can then send it to [email protected] to get it backported.
Quoted 4 lines
Speaking of which, does anyone know why these private helper functions exist in the first place? The code seems to use them interchangeably. Even in the fan control code, there are places where the regular EC helpers are called directly. Can we get away with always doing that?
I assume that on some older models there is no standard ACPI EC device in the ACPI tables, so there only ECRD/ECWR work. I guess that code-paths which directly call ec_read() / ec_write() are only used on newer models. But this does indeed seem inconsistent.
Quoted 6 lines
Back to the issue at hand, is there someone we could ask if the X380Y even supports manual fan control in the first place? My debugging efforts are starting to look like a wild goose chase.
The thermal sensors and fan PWM readings now work, which is better than nothing, but it would be good to get to the bottom of this.
Mark Pearson from Lenovo can hopefully help answer this, but I know that he is quite busy atm. Hopefully Mark will get back to you when he has some more bandwidth.
Regards,
Hans
Quoted 39 lines
Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
---
drivers/platform/x86/thinkpad_acpi.c| 16 ++++++++++++++++1 file changed, 16 insertions(+)drivers/platform/x86/thinkpad_acpi.c +16
-0@@ -11699,6 +11699,7 @@ static int __init thinkpad_acpi_module_init(void) {const struct dmi_system_id *dmi_id;int ret, i; +acpi_object_type obj_type; tpacpi_lifecycle =TPACPI_LIFE_INIT ;@@ -11724,6 +11725,21 @@ static int __init thinkpad_acpi_module_init(void)TPACPI_ACPIHANDLE_INIT (ecrd);TPACPI_ACPIHANDLE_INIT (ecwr); +/* +* Quirk: in some models (e.g. X380 Yoga), an object named ECRD +* exists, but it is a register, not a method. +*/ +if (ecrd_handle) { +acpi_get_type (ecrd_handle, &obj_type); +if (obj_type !=ACPI_TYPE_METHOD ) + ecrd_handle =NULL ; + } +if (ecwr_handle) { +acpi_get_type (ecwr_handle, &obj_type); +if (obj_type !=ACPI_TYPE_METHOD ) + ecwr_handle =NULL ; + } + tpacpi_wq =create_singlethread_workqueue (TPACPI_WORKQUEUE_NAME );if (!tpacpi_wq) {thinkpad_acpi_module_exit ();
Quoted 73 lines · Hans de Goede
Hi,
Quoted 40 lines · Daniel Bertalan
Hi,
Quoted 36 lines · Hans de Goede
Hi,
Quoted 19 lines · Liav Albani
Quoted 17 lines · Hans de Goede
Hi,
Quoted 13 lines · Daniel Bertalan
On the X380 Yoga, the
ECRDandECWRACPI objects cannot be used for accessing the Embedded Controller: instead of a method that reads from the EC's memory,ECRDis the name of a location in high memory. This meant that trying to call them would fail with the following message:ACPI: \_SB.PCI0.LPCB.EC.ECRD: 1 arguments were passed to a non-method ACPI object (RegionField)
With this commit, it is now possible to access the EC and read temperature and fan speed information. Note that while writes to the HFSP register do go through (as indicated by subsequent reads showing the new value), the fan does not actually change its speed.
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Daniel Bertalan [email protected]Interestig, this looks like a pretty clean solution to me.
Daniel and I have looked in the DSDT ASL code and found a bunch of registers in high physical memory location (which is an ACPI OpRegion), and one of the registers had a bit called ECRD.
However, there were many other registers that might be interesting as well, the problem is the short names in the ASL code (so we only see abbreviations essentially).While I do agree that adding this code is indeed a clean solution, if you (people that are dealing with Thinkpad laptops) know about cleaner way to access the embedded controller, I think it's preferable, because this way Daniel might be able to trigger the fan on that laptop so it will actually spin and will dissipate-out heat from the system, without the relying on the embedded controller to get into some sort of thermal state and then to trigger the fan.
Have you tried falling back to the
ec_read()andec_write()helpers exported by the ACPI EC code ?Quoted 8 lines
Quoted 4 lines
The "
first_ec" pointer used by these functions is exported too, so you could try modifyingthinkpad_acpito useec_read()andec_write()as fallback whenfirst_ecis set (and the quirk added by this patch triggers).This is basically what my patch does. If the ECRD/ECWR method handles are NULL, thinkpad_acpi's acpi_ec_{read,write} functions fall back to the regular ACPI EC helpers you mentioned.
Ah I did not realize that. Ok that sounds good to me.
I'll go and apply the patch then. To be on the save side I'm going to only add this to -next, so that it gets some testing before showing up in stable series. Once 6.4-rc1 is out you can then send it to [email protected] to get it backported.
Quoted 4 lines
Speaking of which, does anyone know why these private helper functions exist in the first place? The code seems to use them interchangeably. Even in the fan control code, there are places where the regular EC helpers are called directly. Can we get away with always doing that?
I assume that on some older models there is no standard ACPI EC device in the ACPI tables, so there only ECRD/ECWR work. I guess that code-paths which directly call
ec_read()/ec_write()are only used on newer models. But this does indeed seem inconsistent.Quoted 4 lines
Back to the issue at hand, is there someone we could ask if the X380Y even supports manual fan control in the first place? My debugging efforts are starting to look like a wild goose chase.
Quoted 7 lines
Quoted 2 lines
The thermal sensors and fan PWM readings now work, which is better than nothing, but it would be good to get to the bottom of this.
Mark Pearson from Lenovo can hopefully help answer this, but I know that he is quite busy atm. Hopefully Mark will get back to you when he has some more bandwidth.
Apologies - I thought I had already replied to thread, but seems I hadn't.
I'm checking with the FW team and will see what I can find out. It may take a little while, especially as this is an older platform and the question is a bit more non-standard than normal. Internal ticket is LO-2411
Thanks!
Mark
A message that is not in the archive (sent off-list or not yet received): TYZPR03MB59945171347BC248412EBEE6BD9D9@TYZPR03MB5994.apcprd03.prod.outlook.com
Quoted 76 lines
Subject: [External] Re: [ibm-acpi-devel] [PATCH] platform/x86:
thinkpad_acpi: Fix Embedded Controller access on X380 YogaHi,
Quoted 40 lines · Daniel Bertalan
Hi,
Quoted 36 lines · Hans de Goede
Hi,
Quoted 19 lines · Liav Albani
Quoted 17 lines · Hans de Goede
Hi,
Quoted 13 lines · Daniel Bertalan
On the X380 Yoga, the
ECRDandECWRACPI objects cannot be used for accessing the Embedded Controller: instead of a method that reads from the EC's memory,ECRDis the name of a location in high memory. This meant that trying to call them would fail with the following message:ACPI: \_SB.PCI0.LPCB.EC.ECRD: 1 arguments were passed to a non-method ACPI object (RegionField)
With this commit, it is now possible to access the EC and read temperature and fan speed information. Note that while writes to the HFSP register do go through (as indicated by subsequent reads showing the new value), the fan does not actually change its speed.
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Daniel Bertalan [email protected]Interestig, this looks like a pretty clean solution to me.
Daniel and I have looked in the DSDT ASL code and found a bunch of registers in high physical memory location (which is an ACPI OpRegion), and one of the registers had a bit called ECRD.
However, there were many other registers that might be interesting as well, the problem is the short names in the ASL code (so we only see abbreviations essentially).While I do agree that adding this code is indeed a clean solution, if you (people that are dealing with Thinkpad laptops) know about cleaner way to access the embedded controller, I think it's preferable, because this way Daniel might be able to trigger the fan on that laptop so it will actually spin and will dissipate-out heat from the system, without the relying on the embedded controller to get into some sort of thermal state and then to trigger the fan.
Have you tried falling back to the
ec_read()andec_write()helpers exported by the ACPI EC code ?Quoted 8 lines
Quoted 4 lines
The "
first_ec" pointer used by these functions is exported too, so you could try modifyingthinkpad_acpito useec_read()andec_write()as fallback whenfirst_ecis set (and the quirk added by this patch triggers).This is basically what my patch does. If the ECRD/ECWR method handles are NULL, thinkpad_acpi's acpi_ec_{read,write} functions fall back to the regular ACPI EC helpers you mentioned.
Ah I did not realize that. Ok that sounds good to me.
I'll go and apply the patch then. To be on the save side I'm going to only add this to -next, so that it gets some testing before showing up in stable series. Once 6.4-rc1 is out you can then send it to [email protected] to get it backported.
Quoted 4 lines
Speaking of which, does anyone know why these private helper functions exist in the first place? The code seems to use them interchangeably. Even in the fan control code, there are places where the regular EC helpers are called directly. Can we get away with always doing that?
I assume that on some older models there is no standard ACPI EC device in the ACPI tables, so there only ECRD/ECWR work. I guess that code-paths which directly call
ec_read()/ec_write()are only used on newer models. But this does indeed seem inconsistent.Quoted 4 lines
Back to the issue at hand, is there someone we could ask if the X380Y even supports manual fan control in the first place? My debugging efforts are starting to look like a wild goose chase.
Quoted 7 lines
Quoted 2 lines
The thermal sensors and fan PWM readings now work, which is better than nothing, but it would be good to get to the bottom of this.
Mark Pearson from Lenovo can hopefully help answer this, but I know that he is quite busy atm. Hopefully Mark will get back to you when he has some more bandwidth.
Sorry for the slow reply on this one.
I checked with the FW team and they confirmed on the x380 Yoga that the implementation is unique and not using the ECRD/WCWR ACPI methods. They didn't say why...but it's not expected to be something done again.
I had missed the question about fan control so didn't ask about that. Is there a reason you need to change the fans? It's generally not recommended as it can violate temperature specs and leads to all sorts of issues.
I don't know if the fact this is a one off makes this a better candidate as a quirk? To reduce the risk of breaking something on other platforms? But the code changes looked sensible to me.
I'll aim to do some builds with it in and test it on a few platforms - but I'm travelling next week so this week (and almost certainly the week after) are a bit hectic.
Thanks
Mark
Hi,
Quoted 85 lines · Mark Pearson
Quoted 76 lines
Subject: [External] Re: [ibm-acpi-devel] [PATCH] platform/x86:
thinkpad_acpi: Fix Embedded Controller access on X380 YogaHi,
Quoted 40 lines · Daniel Bertalan
Hi,
Quoted 36 lines · Hans de Goede
Hi,
Quoted 19 lines · Liav Albani
Quoted 17 lines · Hans de Goede
Hi,
Quoted 13 lines · Daniel Bertalan
On the X380 Yoga, the
ECRDandECWRACPI objects cannot be used for accessing the Embedded Controller: instead of a method that reads from the EC's memory,ECRDis the name of a location in high memory. This meant that trying to call them would fail with the following message:ACPI: \_SB.PCI0.LPCB.EC.ECRD: 1 arguments were passed to a non-method ACPI object (RegionField)
With this commit, it is now possible to access the EC and read temperature and fan speed information. Note that while writes to the HFSP register do go through (as indicated by subsequent reads showing the new value), the fan does not actually change its speed.
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Daniel Bertalan [email protected]Interestig, this looks like a pretty clean solution to me.
Daniel and I have looked in the DSDT ASL code and found a bunch of registers in high physical memory location (which is an ACPI OpRegion), and one of the registers had a bit called ECRD.
However, there were many other registers that might be interesting as well, the problem is the short names in the ASL code (so we only see abbreviations essentially).While I do agree that adding this code is indeed a clean solution, if you (people that are dealing with Thinkpad laptops) know about cleaner way to access the embedded controller, I think it's preferable, because this way Daniel might be able to trigger the fan on that laptop so it will actually spin and will dissipate-out heat from the system, without the relying on the embedded controller to get into some sort of thermal state and then to trigger the fan.
Have you tried falling back to the
ec_read()andec_write()helpers exported by the ACPI EC code ?Quoted 8 lines
Quoted 4 lines
The "
first_ec" pointer used by these functions is exported too, so you could try modifyingthinkpad_acpito useec_read()andec_write()as fallback whenfirst_ecis set (and the quirk added by this patch triggers).This is basically what my patch does. If the ECRD/ECWR method handles are NULL, thinkpad_acpi's acpi_ec_{read,write} functions fall back to the regular ACPI EC helpers you mentioned.
Ah I did not realize that. Ok that sounds good to me.
I'll go and apply the patch then. To be on the save side I'm going to only add this to -next, so that it gets some testing before showing up in stable series. Once 6.4-rc1 is out you can then send it to [email protected] to get it backported.
Quoted 4 lines
Speaking of which, does anyone know why these private helper functions exist in the first place? The code seems to use them interchangeably. Even in the fan control code, there are places where the regular EC helpers are called directly. Can we get away with always doing that?
I assume that on some older models there is no standard ACPI EC device in the ACPI tables, so there only ECRD/ECWR work. I guess that code-paths which directly call
ec_read()/ec_write()are only used on newer models. But this does indeed seem inconsistent.Quoted 4 lines
Back to the issue at hand, is there someone we could ask if the X380Y even supports manual fan control in the first place? My debugging efforts are starting to look like a wild goose chase.
Quoted 7 lines
Quoted 2 lines
The thermal sensors and fan PWM readings now work, which is better than nothing, but it would be good to get to the bottom of this.
Mark Pearson from Lenovo can hopefully help answer this, but I know that he is quite busy atm. Hopefully Mark will get back to you when he has some more bandwidth.
Sorry for the slow reply on this one.
Quoted 7 lines
I checked with the FW team and they confirmed on the x380 Yoga that the implementation is unique and not using the ECRD/WCWR ACPI methods. They didn't say why...but it's not expected to be something done again.
I had missed the question about fan control so didn't ask about that. Is there a reason you need to change the fans? It's generally not recommended as it can violate temperature specs and leads to all sorts of issues.
I don't know if the fact this is a one off makes this a better candidate as a quirk? To reduce the risk of breaking something on other platforms? But the code changes looked sensible to me.
I'll aim to do some builds with it in and test it on a few platforms - but I'm travelling next week so this week (and almost certainly the week after) are a bit hectic.
I just remembered that making thinkpad_acpi fan-control actually requires passing a module-parameter, because as said generally speaking leaving the fan on auto mode is best.
I wonder if that parameter was set when testing on the X380 ? I guess it was set since the actual register was inspected and the changes were visible there, right ?
Regards,
Hans
Hi Mark and Hans,
please see my reply inline.
Quoted 6 lines · Hans de Goede
Quoted 4 lines · Mark Pearson
Sorry for the slow reply on this one.
I checked with the FW team and they confirmed on the x380 Yoga that the implementation is unique and not using the ECRD/WCWR ACPI methods. They didn't say why...but it's not expected to be something done again.
Thank you and the FW team for the quick reply! As a first time kernel hacker, I find my experience top-notch :)
Quoted 1 line
Quoted 1 line
I had missed the question about fan control so didn't ask about that. Is there a reason you need to change the fans? It's generally not recommended as it can violate temperature specs and leads to all sorts of issues.
My end goal is to hopefully get a bit more performance out of my machine by making the fan kick in earlier using Thinkfan.
I have been doing a lot of compile-heavy development lately on my X380 Yoga, and I noticed that the CPU will throttle down to around 1.4 GHz at full load. This might just be normal for such a small ultrabook, but I want to get the most out of it, as I'm likely going to be stuck with this laptop for my first year of CS studies.
Additionally, I remember the fans being louder at full load back when I used Windows. With this patch, I can see that the highest it gets is 4800 RPM. My memory might just be wrong though, and if so, I apologize for wasting your time.
I have set "Adaptive Thermal Management" to "Maximize Performance" in the BIOS, but I don't see a significant improvement.
Quoted 3 lines
Quoted 3 lines
I don't know if the fact this is a one off makes this a better candidate as a quirk? To reduce the risk of breaking something on other platforms? But the code changes looked sensible to me.
I'll aim to do some builds with it in and test it on a few platforms - but I'm travelling next week so this week (and almost certainly the week after) are a bit hectic.
Thank you again. In no way is this patch urgent, so feel free to take your time.
Quoted 10 lines
I just remembered that making
thinkpad_acpifan-control actually requires passing a module-parameter, because as said generally speaking leaving the fan on auto mode is best.I wonder if that parameter was set when testing on the X380 ? I guess it was set since the actual register was inspected and the changes were visible there, right ?
This is correct, I did set fan_control=1 for my testing. Writes to /proc/acpi/ibm/fan are rejected otherwise.
Quoted 4 lines
Regards,
Hans
Regards,
Daniel
Hi,
Quoted 8 lines · Daniel Bertalan
On the X380 Yoga, the
ECRDandECWRACPI objects cannot be used for accessing the Embedded Controller: instead of a method that reads from the EC's memory,ECRDis the name of a location in high memory. This meant that trying to call them would fail with the following message:ACPI: \_SB.PCI0.LPCB.EC.ECRD: 1 arguments were passed to a non-method ACPI object (RegionField)
Quoted 6 lines
With this commit, it is now possible to access the EC and read temperature and fan speed information. Note that while writes to the HFSP register do go through (as indicated by subsequent reads showing the new value), the fan does not actually change its speed.
Signed-off-by Daniel Bertalan <[email protected]>
Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.
Regards,
Hans
Quoted 38 lines
--- drivers/platform/x86/thinkpad_acpi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/platform/x86/thinkpad_acpi.c +16
-0@@ -11699,6 +11699,7 @@ static int __init thinkpad_acpi_module_init(void) {const struct dmi_system_id *dmi_id;int ret, i; +acpi_object_type obj_type; tpacpi_lifecycle =TPACPI_LIFE_INIT ;@@ -11724,6 +11725,21 @@ static int __init thinkpad_acpi_module_init(void)TPACPI_ACPIHANDLE_INIT (ecrd);TPACPI_ACPIHANDLE_INIT (ecwr); +/* +* Quirk: in some models (e.g. X380 Yoga), an object named ECRD +* exists, but it is a register, not a method. +*/ +if (ecrd_handle) { +acpi_get_type (ecrd_handle, &obj_type); +if (obj_type !=ACPI_TYPE_METHOD ) + ecrd_handle =NULL ; + } +if (ecwr_handle) { +acpi_get_type (ecwr_handle, &obj_type); +if (obj_type !=ACPI_TYPE_METHOD ) + ecwr_handle =NULL ; + } + tpacpi_wq =create_singlethread_workqueue (TPACPI_WORKQUEUE_NAME );if (!tpacpi_wq) {thinkpad_acpi_module_exit ();