platform/x86: thinkpad_acpi: Fix registration of tpacpi platform driver
PATCH v2 1/1 platform/x86: thinkpad_acpi: Fix registration of tpacpi platform driver
When reviewing and testing the recent platform profile changes I had missed that they prevent the tpacpi platform driver from registering. This error is seen in the kernel logs, and the various tpacpi entries are not created:
[ 7550.642171] platform thinkpad_acpi: Resources present before probing
This happens because devm_platform_profile_register() is called before tpacpi_pdev probes (thanks to Kurt Borja for identifying root cause)
For now revert back to the old platform_profile_register to fix the issue. Will work on re-implementing this later as more testing is needed for full solution.
Tested on X1 Carbon G12.
---
Changes in v2:
Modified approach to instead revert to old platform_profile_register
method. Will revisit using devm_ version in the future as more testing needed.
drivers/platform/x86/thinkpad_acpi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +8 -2
@@ -10646,8 +10646,8 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) "DYTC version %d: thermal mode available\n", dytc_version);/* Create platform_profile structure and register */ - tpacpi_pprof =devm_platform_profile_register (&tpacpi_pdev->dev,"thinkpad-acpi" , -NULL , &dytc_profile_ops); + tpacpi_pprof =platform_profile_register (&tpacpi_pdev->dev,"thinkpad-acpi-profile" , +NULL , &dytc_profile_ops);/* * If for some reason platform_profiles aren't enabled * don't quit terminally.
@@ -10665,8 +10665,14 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)return 0 ; } +static void dytc_profile_exit (void ) +{ +platform_profile_remove (tpacpi_pprof); +} +static struct ibm_struct dytc_profile_driver_data = { .name ="dytc-profile" , + .exit = dytc_profile_exit, };/*************************************************************************
Signature · 1 line
2.48.1
Quoted 4 lines · Mark Pearson
When reviewing and testing the recent platform profile changes I had missed that they prevent the tpacpi platform driver from registering. This error is seen in the kernel logs, and the various tpacpi entries are not created:
Quoted 8 lines
[ 7550.642171] platform thinkpad_acpi: Resources present before probingThis happens because
devm_platform_profile_register()is called beforetpacpi_pdevprobes (thanks to Kurt Borja for identifying root cause)For now revert back to the old
platform_profile_registerto fix the issue. Will work on re-implementing this later as more testing is needed for full solution.
If you don't mind I can work on this patch on the for-next branch, so we may use devm_ on the next release cycle to avoid merge conflicts.
Quoted 6 lines
Tested on X1 Carbon G12.
Fixes 31658c916fa6 ("platform/x86: thinkpad_acpi: Use devm_platform_profile_register()")Signed-off-by Mark Pearson <[email protected]>
Quoted 39 lines
---
Changes in v2:
Modified approach to instead revert to oldplatform_profile_register
method. Will revisit usingdevm_version in the future as more testing needed.drivers/platform/x86/thinkpad_acpi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/platform/x86/thinkpad_acpi.c +8
-2@@ -10646,8 +10646,8 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) "DYTC version %d: thermal mode available\n", dytc_version);/* Create platform_profile structure and register */ - tpacpi_pprof =devm_platform_profile_register (&tpacpi_pdev->dev,"thinkpad-acpi" , -NULL , &dytc_profile_ops); + tpacpi_pprof =platform_profile_register (&tpacpi_pdev->dev,"thinkpad-acpi-profile" , +NULL , &dytc_profile_ops);/* * If for some reason platform_profiles aren't enabled * don't quit terminally. @@ -10665,8 +10665,14 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)return 0 ; } +static void dytc_profile_exit (void ) +{ +platform_profile_remove (tpacpi_pprof); +} +static struct ibm_struct dytc_profile_driver_data = { .name ="dytc-profile" , + .exit = dytc_profile_exit, };/*************************************************************************
Hi Kurt,
Quoted 10 lines · Kurt Borja
Quoted 9 lines · Mark Pearson
When reviewing and testing the recent platform profile changes I had missed that they prevent the tpacpi platform driver from registering. This error is seen in the kernel logs, and the various tpacpi entries are not created:
[ 7550.642171] platform thinkpad_acpi: Resources present before probingThis happens because
devm_platform_profile_register()is called beforetpacpi_pdevprobes (thanks to Kurt Borja for identifying root cause)
Quoted 7 lines
Quoted 3 lines
For now revert back to the old
platform_profile_registerto fix the issue. Will work on re-implementing this later as more testing is needed for full solution.If you don't mind I can work on this patch on the for-next branch, so we may use
devm_on the next release cycle to avoid merge conflicts.
For sure :) Holler if you need anything.
Quoted 8 lines
Quoted 6 lines
Tested on X1 Carbon G12.
Fixes 31658c916fa6 ("platform/x86: thinkpad_acpi: Use devm_platform_profile_register()")Signed-off-by Mark Pearson <[email protected]>Reviewed-by Kurt Borja <[email protected]>
Thanks for the review
Mark
Quoted 40 lines
Quoted 40 lines
---
Changes in v2:
Modified approach to instead revert to oldplatform_profile_register
method. Will revisit usingdevm_version in the future as more testing needed.drivers/platform/x86/thinkpad_acpi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/platform/x86/thinkpad_acpi.c +8
-2@@ -10646,8 +10646,8 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) "DYTC version %d: thermal mode available\n", dytc_version);/* Create platform_profile structure and register */ - tpacpi_pprof =devm_platform_profile_register (&tpacpi_pdev->dev,"thinkpad-acpi" , -NULL , &dytc_profile_ops); + tpacpi_pprof =platform_profile_register (&tpacpi_pdev->dev,"thinkpad-acpi-profile" , +NULL , &dytc_profile_ops);/* * If for some reason platform_profiles aren't enabled * don't quit terminally. @@ -10665,8 +10665,14 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)return 0 ; } +static void dytc_profile_exit (void ) +{ +platform_profile_remove (tpacpi_pprof); +} +static struct ibm_struct dytc_profile_driver_data = { .name ="dytc-profile" , + .exit = dytc_profile_exit, };/*************************************************************************
Quoted 43 lines · Mark Pearson
When reviewing and testing the recent platform profile changes I had missed that they prevent the tpacpi platform driver from registering. This error is seen in the kernel logs, and the various tpacpi entries are not created:
[ 7550.642171] platform thinkpad_acpi: Resources present before probingThis happens because
devm_platform_profile_register()is called beforetpacpi_pdevprobes (thanks to Kurt Borja for identifying root cause)For now revert back to the old
platform_profile_registerto fix the issue. Will work on re-implementing this later as more testing is needed for full solution.Tested on X1 Carbon G12.
Fixes 31658c916fa6 ("platform/x86: thinkpad_acpi: Use devm_platform_profile_register()")Signed-off-by Mark Pearson <[email protected]>---
Changes in v2:
Modified approach to instead revert to oldplatform_profile_register
method. Will revisit usingdevm_version in the future as more testing needed.drivers/platform/x86/thinkpad_acpi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/platform/x86/thinkpad_acpi.c +2
-2@@ -10646,8 +10646,8 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) "DYTC version %d: thermal mode available\n", dytc_version);/* Create platform_profile structure and register */ - tpacpi_pprof =devm_platform_profile_register (&tpacpi_pdev->dev,"thinkpad-acpi" , -NULL , &dytc_profile_ops); + tpacpi_pprof =platform_profile_register (&tpacpi_pdev->dev,"thinkpad-acpi-profile" , +NULL , &dytc_profile_ops);/* * If for some reason platform_profiles aren't enabled * don't quit terminally.
drivers/platform/x86/thinkpad_acpi.c static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) · line 10670
Quoted 6 lines
drivers/platform/x86/thinkpad_acpi.c +3
-0@@ -10665,8 +10665,14 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)return 0 ; } +static void dytc_profile_exit (void ) +{ +platform_profile_remove (tpacpi_pprof);
I just noticed this will be called even if platform_profile_register() fails, as the comment suggests.
We need to check for IS_ERR_OR_NULL() before unregistering.
Signature · 1 line
~ Kurt
Quoted 8 lines
drivers/platform/x86/thinkpad_acpi.c +3
-0+} +static struct ibm_struct dytc_profile_driver_data = { .name ="dytc-profile" , + .exit = dytc_profile_exit, };/*************************************************************************
Hi Kurt
Quoted 47 lines · Kurt Borja
Quoted 46 lines · Mark Pearson
When reviewing and testing the recent platform profile changes I had missed that they prevent the tpacpi platform driver from registering. This error is seen in the kernel logs, and the various tpacpi entries are not created:
[ 7550.642171] platform thinkpad_acpi: Resources present before probingThis happens because
devm_platform_profile_register()is called beforetpacpi_pdevprobes (thanks to Kurt Borja for identifying root cause)For now revert back to the old
platform_profile_registerto fix the issue. Will work on re-implementing this later as more testing is needed for full solution.Tested on X1 Carbon G12.
Fixes 31658c916fa6 ("platform/x86: thinkpad_acpi: Use devm_platform_profile_register()")Signed-off-by Mark Pearson <[email protected]>---
Changes in v2:
Modified approach to instead revert to oldplatform_profile_register
method. Will revisit usingdevm_version in the future as more testing needed.drivers/platform/x86/thinkpad_acpi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/platform/x86/thinkpad_acpi.c +2
-2@@ -10646,8 +10646,8 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) "DYTC version %d: thermal mode available\n", dytc_version);/* Create platform_profile structure and register */ - tpacpi_pprof =devm_platform_profile_register (&tpacpi_pdev->dev,"thinkpad-acpi" , -NULL , &dytc_profile_ops); + tpacpi_pprof =platform_profile_register (&tpacpi_pdev->dev,"thinkpad-acpi-profile" , +NULL , &dytc_profile_ops);/* * If for some reason platform_profiles aren't enabled * don't quit terminally. @@ -10665,8 +10665,14 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)return 0 ; }
Quoted 8 lines
drivers/platform/x86/thinkpad_acpi.c static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) · line 10670
Quoted 3 lines
drivers/platform/x86/thinkpad_acpi.c +3
-0+static void dytc_profile_exit (void ) +{ +platform_profile_remove (tpacpi_pprof);I just noticed this will be called even if
platform_profile_register()fails, as the comment suggests.We need to check for
IS_ERR_OR_NULL()before unregistering.
Agreed - will add.
Thanks
Mark