platform/x86/amd: pmc: remove CONFIG_SUSPEND checks
PATCH 1/1 platform/x86/amd: pmc: remove CONFIG_SUSPEND checks
From: Arnd Bergmann <[email protected]>
The amd_pmc_write_stb() function was previously hidden in an ifdef to avoid a warning when CONFIG_SUSPEND is disabled, but now there is an additional caller:
drivers/platform/x86/amd/pmc.c: In function 'amd_pmc_stb_debugfs_open_v2':drivers/platform/x86/amd/pmc.c:256:8: error: implicit declaration of function 'amd_pmc_write_stb'; did you mean 'amd_pmc_read_stb'? [-Werror=implicit-function-declaration]
256 | ret = amd_pmc_write_stb(dev, AMD_PMC_STB_DUMMY_PC);
| ^~~~~~~~~~~~~~~~~
| amd_pmc_read_stbThere is now an easier way to handle this by using DEFINE_SIMPLE_DEV_PM_OPS() to replace all the #ifdefs, letting gcc drop any of the unused functions silently.
--- drivers/platform/x86/amd/pmc.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-)
drivers/platform/x86/amd/pmc.c +6 -19
@@ -171,9 +171,7 @@ MODULE_PARM_DESC(disable_workarounds, "Disable workarounds for platform bugs");static struct amd_pmc_dev pmc;static int amd_pmc_send_cmd (struct amd_pmc_dev *dev,u32 arg,u32 *data,u8 msg,bool ret);static int amd_pmc_read_stb (struct amd_pmc_dev *dev,u32 *buf); -#ifdef CONFIG_SUSPEND static int amd_pmc_write_stb (struct amd_pmc_dev *dev,u32 data); -#endif static inline u32 amd_pmc_reg_read (struct amd_pmc_dev *dev,int reg_offset) {
@@ -386,7 +384,6 @@ static int get_metrics_table(struct amd_pmc_dev *pdev, struct smu_metrics *tablereturn 0 ; } -#ifdef CONFIG_SUSPEND static void amd_pmc_validate_deepest (struct amd_pmc_dev *pdev) {struct smu_metrics table;
@@ -400,7 +397,6 @@ static void amd_pmc_validate_deepest(struct amd_pmc_dev *pdev)dev_dbg (pdev->dev,"Last suspend in deepest state for %lluus\n" , table.timein_s0i3_lastcapture); } -#endif static int amd_pmc_get_smu_version (struct amd_pmc_dev *dev) {
@@ -673,7 +669,6 @@ static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, u32 arg, u32 *data, u8 msg,return rc; } -#ifdef CONFIG_SUSPEND static int amd_pmc_get_os_hint (struct amd_pmc_dev *dev) {switch (dev->cpu_id) {
@@ -861,9 +856,7 @@ static int __maybe_unused amd_pmc_suspend_handler(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(amd_pmc_pm, amd_pmc_suspend_handler, NULL); - -#endif +static DEFINE_SIMPLE_DEV_PM_OPS(amd_pmc_pm, amd_pmc_suspend_handler, NULL);static const struct pci_device_id pmc_pci_ids[] = { {PCI_DEVICE (PCI_VENDOR_ID_AMD ,AMD_CPU_ID_PS ) },
@@ -905,7 +898,6 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)return 0 ; } -#ifdef CONFIG_SUSPEND static int amd_pmc_write_stb (struct amd_pmc_dev *dev,u32 data) {int err;
@@ -926,7 +918,6 @@ static int amd_pmc_write_stb(struct amd_pmc_dev *dev, u32 data)return 0 ; } -#endif static int amd_pmc_read_stb (struct amd_pmc_dev *dev,u32 *buf) {
@@ -1017,11 +1008,10 @@ static int amd_pmc_probe(struct platform_device *pdev) }platform_set_drvdata (pdev, dev); -#ifdef CONFIG_SUSPEND - err =acpi_register_lps0_dev (&amd_pmc_s2idle_dev_ops); +if (IS_ENABLED (CONFIG_SUSPEND )) + err =acpi_register_lps0_dev (&amd_pmc_s2idle_dev_ops);if (err)dev_warn (dev->dev,"failed to register LPS0 sleep handler, expect increased power consumption\n" ); -#endif amd_pmc_dbgfs_register (dev);return 0 ;
@@ -1035,9 +1025,8 @@ static int amd_pmc_remove(struct platform_device *pdev) {struct amd_pmc_dev *dev =platform_get_drvdata (pdev); -#ifdef CONFIG_SUSPEND -acpi_unregister_lps0_dev (&amd_pmc_s2idle_dev_ops); -#endif +if (IS_ENABLED (CONFIG_SUSPEND )) +acpi_unregister_lps0_dev (&amd_pmc_s2idle_dev_ops);amd_pmc_dbgfs_unregister (dev);pci_dev_put (dev->rdev);mutex_destroy (&dev->lock);
@@ -1061,9 +1050,7 @@ static struct platform_driver amd_pmc_driver = { .name = "amd_pmc", .acpi_match_table = amd_pmc_acpi_ids, .dev_groups = pmc_groups, -#ifdef CONFIG_SUSPEND - .pm = &amd_pmc_pm, -#endif + .pm = pm_sleep_ptr(&amd_pmc_pm), }, .probe = amd_pmc_probe, .remove = amd_pmc_remove,
Signature · 1 line
2.39.1
[Public]
Quoted 26 lines
-----Original Message-----
From: Arnd Bergmann <[email protected]>
Sent: Tuesday, February 14, 2023 09:25
To: S-k, Shyam-sundar <[email protected]>; Hans de Goede <[email protected]>; Mark Gross <[email protected]>
Cc: Arnd Bergmann <[email protected]>; Limonciello, Mario <[email protected]>; Nathan Chancellor <[email protected]>; Rafael J. Wysocki <[email protected]>; platform-driver- [email protected]; [email protected]
Subject: [PATCH] platform/x86/amd: pmc: removeCONFIG_SUSPENDchecksFrom: Arnd Bergmann <[email protected]>
The
amd_pmc_write_stb()function was previously hidden in an ifdef to avoid a warning whenCONFIG_SUSPENDis disabled, but now there is an additional caller:
drivers/platform/x86/amd/pmc.c: In function 'amd_pmc_stb_debugfs_open_v2':drivers/platform/x86/amd/pmc.c:256:8: error: implicit declaration of function 'amd_pmc_write_stb'; did you mean 'amd_pmc_read_stb'? [- Werror=implicit-function-declaration]256 | ret = amd_pmc_write_stb(dev, AMD_PMC_STB_DUMMY_PC); | ^~~~~~~~~~~~~~~~~ | amd_pmc_read_stb
Quoted 7 lines
There is now an easier way to handle this by using
DEFINE_SIMPLE_DEV_PM_OPS()
to replace all the #ifdefs, letting gcc drop any of the unused functions silently.Fixes b0d4bb973539 ("platform/x86/amd: pmc: Write dummy postcode intothe STB DRAM")
I suspect this is not an appropriate fixes tag. SIMPLE_DEV_PM_OPS only came in 8e60615e89321 ("platform/x86/amd: pmc: Disable IRQ1 wakeup for RN/CZN")
Quoted 125 lines
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/platform/x86/amd/pmc.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-)drivers/platform/x86/amd/pmc.c +0
-2@@ -171,9 +171,7 @@ MODULE_PARM_DESC(disable_workarounds, "Disable workarounds for platform bugs");static struct amd_pmc_dev pmc;static int amd_pmc_send_cmd (struct amd_pmc_dev *dev,u32 arg,u32 *data,u8 msg,bool ret);static int amd_pmc_read_stb (struct amd_pmc_dev *dev,u32 *buf); -#ifdef CONFIG_SUSPEND static int amd_pmc_write_stb (struct amd_pmc_dev *dev,u32 data); -#endif static inline u32 amd_pmc_reg_read(struct
amd_pmc_dev*dev, intreg_offset)
{drivers/platform/x86/amd/pmc.c +0
-1@@ -386,7 +384,6 @@ static int get_metrics_table(struct amd_pmc_dev *pdev, struct smu_metrics *tablereturn 0 ; } -#ifdef CONFIG_SUSPEND static void amd_pmc_validate_deepest (struct amd_pmc_dev *pdev) {drivers/platform/x86/amd/pmc.c +0
-1struct smu_metrics table;@@ -400,7 +397,6 @@ static void amd_pmc_validate_deepest(struct amd_pmc_dev *pdev) dev_dbg(pdev->dev, "Last suspend in deepest state for %lluus\n", table.timein_s0i3_lastcapture); } -#endif static int
amd_pmc_get_smu_version(struct amd_pmc_dev *dev){drivers/platform/x86/amd/pmc.c +0
-1@@ -673,7 +669,6 @@ static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, u32 arg, u32 *data, u8 msg, return rc; } -#ifdef CONFIG_SUSPEND static int amd_pmc_get_os_hint (struct amd_pmc_dev *dev) {drivers/platform/x86/amd/pmc.c +1
-3switch (dev->cpu_id) {@@ -861,9 +856,7 @@ static int __maybe_unused amd_pmc_suspend_handler(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(amd_pmc_pm, amd_pmc_suspend_handler, NULL); - -#endif +static DEFINE_SIMPLE_DEV_PM_OPS(amd_pmc_pm, amd_pmc_suspend_handler, NULL);static const struct
pci_device_idpmc_pci_ids[] = {drivers/platform/x86/amd/pmc.c +0
-1{ PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_PS) },@@ -905,7 +898,6 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)return 0 ; } -#ifdef CONFIG_SUSPEND static int amd_pmc_write_stb (struct amd_pmc_dev *dev,u32 data) {drivers/platform/x86/amd/pmc.c +0
-1int err;@@ -926,7 +918,6 @@ static int amd_pmc_write_stb(struct amd_pmc_dev *dev, u32 data)return 0 ; } -#endif static int amd_pmc_read_stb (struct amd_pmc_dev *dev,u32 *buf){
drivers/platform/x86/amd/pmc.c +2
-3@@ -1017,11 +1008,10 @@ static int amd_pmc_probe(struct platform_device *pdev) }platform_set_drvdata (pdev, dev); -#ifdef CONFIG_SUSPEND - err = acpi_register_lps0_dev(&amd_pmc_s2idle_dev_ops); +if (IS_ENABLED (CONFIG_SUSPEND )) + err =acpi_register_lps0_dev (&amd_pmc_s2idle_dev_ops);if (err) dev_warn(dev->dev, "failed to register LPS0 sleep handler, expect increased power consumption\n"); -#endifdrivers/platform/x86/amd/pmc.c +2
-3amd_pmc_dbgfs_register (dev);return 0 ;@@ -1035,9 +1025,8 @@ static int amd_pmc_remove(struct platform_device *pdev) {struct amd_pmc_dev *dev =platform_get_drvdata (pdev); -#ifdef CONFIG_SUSPEND -acpi_unregister_lps0_dev (&amd_pmc_s2idle_dev_ops); -#endif +if (IS_ENABLED (CONFIG_SUSPEND )) +acpi_unregister_lps0_dev (&amd_pmc_s2idle_dev_ops);amd_pmc_dbgfs_unregister (dev);pci_dev_put (dev->rdev);drivers/platform/x86/amd/pmc.c +1
-4mutex_destroy (&dev->lock);@@ -1061,9 +1050,7 @@ static struct platform_driver amd_pmc_driver = { .name = "amd_pmc", .acpi_match_table = amd_pmc_acpi_ids, .dev_groups = pmc_groups, -#ifdef CONFIG_SUSPEND - .pm = &amd_pmc_pm, -#endif + .pm = pm_sleep_ptr(&amd_pmc_pm), }, .probe = amd_pmc_probe, .remove = amd_pmc_remove, --2.39.1
Hans de Goede
AppliedHi Mario, Arnd,
Quoted 35 lines · Mario
[Public]
Quoted 31 lines
-----Original Message-----
From: Arnd Bergmann <[email protected]>
Sent: Tuesday, February 14, 2023 09:25
To: S-k, Shyam-sundar <[email protected]>; Hans de Goede <[email protected]>; Mark Gross <[email protected]>
Cc: Arnd Bergmann <[email protected]>; Limonciello, Mario <[email protected]>; Nathan Chancellor <[email protected]>; Rafael J. Wysocki <[email protected]>; platform-driver- [email protected]; [email protected]
Subject: [PATCH] platform/x86/amd: pmc: removeCONFIG_SUSPENDchecksFrom: Arnd Bergmann <[email protected]>
The
amd_pmc_write_stb()function was previously hidden in an ifdef to avoid a warning whenCONFIG_SUSPENDis disabled, but now there is an additional caller:
drivers/platform/x86/amd/pmc.c: In function 'amd_pmc_stb_debugfs_open_v2':drivers/platform/x86/amd/pmc.c:256:8: error: implicit declaration of function 'amd_pmc_write_stb'; did you mean 'amd_pmc_read_stb'? [- Werror=implicit-function-declaration]256 | ret = amd_pmc_write_stb(dev, AMD_PMC_STB_DUMMY_PC); | ^~~~~~~~~~~~~~~~~ | amd_pmc_read_stbThere is now an easier way to handle this by using
DEFINE_SIMPLE_DEV_PM_OPS()
to replace all the #ifdefs, letting gcc drop any of the unused functions silently.
Quoted 5 lines
Quoted 2 lines
Fixes b0d4bb973539 ("platform/x86/amd: pmc: Write dummy postcode intothe STB DRAM")
I suspect this is not an appropriate fixes tag.
SIMPLE_DEV_PM_OPSonly came in8e60615e89321("platform/x86/amd: pmc: Disable IRQ1 wakeup for RN/CZN")
That commit is older then the fixes commit Arnd points to,
Arnd's Fixes tag points to the commit causing the compile error Arnd hit, which is one of the last commits to drivers/platform/x86/amd/pmc.c .
So the Fixes tag seems fine to me.
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 I've squashed in one small fixup, see my inline comment below.
I'll rebase that branch once 6.3-rc1 is out and then push the rebased patch to the fixes branch and include it in my next 6.3 fixes pull-req to Linus.
Quoted 87 lines
Quoted 87 lines
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/platform/x86/amd/pmc.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-)drivers/platform/x86/amd/pmc.c +0
-2@@ -171,9 +171,7 @@ MODULE_PARM_DESC(disable_workarounds, "Disable workarounds for platform bugs");static struct amd_pmc_dev pmc;static int amd_pmc_send_cmd (struct amd_pmc_dev *dev,u32 arg,u32 *data,u8 msg,bool ret);static int amd_pmc_read_stb (struct amd_pmc_dev *dev,u32 *buf); -#ifdef CONFIG_SUSPEND static int amd_pmc_write_stb (struct amd_pmc_dev *dev,u32 data); -#endif static inline u32 amd_pmc_reg_read(struct
amd_pmc_dev*dev, intreg_offset)
{drivers/platform/x86/amd/pmc.c +0
-1@@ -386,7 +384,6 @@ static int get_metrics_table(struct amd_pmc_dev *pdev, struct smu_metrics *tablereturn 0 ; } -#ifdef CONFIG_SUSPEND static void amd_pmc_validate_deepest (struct amd_pmc_dev *pdev) {drivers/platform/x86/amd/pmc.c +0
-1struct smu_metrics table;@@ -400,7 +397,6 @@ static void amd_pmc_validate_deepest(struct amd_pmc_dev *pdev) dev_dbg(pdev->dev, "Last suspend in deepest state for %lluus\n", table.timein_s0i3_lastcapture); } -#endif static int
amd_pmc_get_smu_version(struct amd_pmc_dev *dev){drivers/platform/x86/amd/pmc.c +0
-1@@ -673,7 +669,6 @@ static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, u32 arg, u32 *data, u8 msg, return rc; } -#ifdef CONFIG_SUSPEND static int amd_pmc_get_os_hint (struct amd_pmc_dev *dev) {drivers/platform/x86/amd/pmc.c +1
-3switch (dev->cpu_id) {@@ -861,9 +856,7 @@ static int __maybe_unused amd_pmc_suspend_handler(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(amd_pmc_pm, amd_pmc_suspend_handler, NULL); - -#endif +static DEFINE_SIMPLE_DEV_PM_OPS(amd_pmc_pm, amd_pmc_suspend_handler, NULL);static const struct
pci_device_idpmc_pci_ids[] = {drivers/platform/x86/amd/pmc.c +0
-1{ PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_PS) },@@ -905,7 +898,6 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)return 0 ; } -#ifdef CONFIG_SUSPEND static int amd_pmc_write_stb (struct amd_pmc_dev *dev,u32 data) {drivers/platform/x86/amd/pmc.c +0
-1int err;@@ -926,7 +918,6 @@ static int amd_pmc_write_stb(struct amd_pmc_dev *dev, u32 data)return 0 ; } -#endif static int amd_pmc_read_stb (struct amd_pmc_dev *dev,u32 *buf){
drivers/platform/x86/amd/pmc.c +0
-0@@ -1017,11 +1008,10 @@ static int amd_pmc_probe(struct platform_device *pdev) }
Quoted 7 lines
drivers/platform/x86/amd/pmc.c static int amd_pmc_probe(struct platform_device *pdev)
Quoted 7 lines
drivers/platform/x86/amd/pmc.c +2
-2platform_set_drvdata (pdev, dev); -#ifdef CONFIG_SUSPEND - err =acpi_register_lps0_dev (&amd_pmc_s2idle_dev_ops); +if (IS_ENABLED (CONFIG_SUSPEND )) + err =acpi_register_lps0_dev (&amd_pmc_s2idle_dev_ops);if (err) dev_warn(dev->dev, "failed to register LPS0 sleep handler,
This will work since err is guaranteed to be 0 here, but IMHO it is cleaner to put the err check for the acpi_register_lps0_dev() check inside the if block.
I have fixed this up while applying the patch.
Regards,
Hans
Quoted 32 lines
Quoted 31 lines
drivers/platform/x86/amd/pmc.c +0
-1expect increased power consumption\n"); -#endif drivers/platform/x86/amd/pmc.c +2
-3amd_pmc_dbgfs_register (dev);return 0 ;@@ -1035,9 +1025,8 @@ static int amd_pmc_remove(struct platform_device *pdev) {struct amd_pmc_dev *dev =platform_get_drvdata (pdev); -#ifdef CONFIG_SUSPEND -acpi_unregister_lps0_dev (&amd_pmc_s2idle_dev_ops); -#endif +if (IS_ENABLED (CONFIG_SUSPEND )) +acpi_unregister_lps0_dev (&amd_pmc_s2idle_dev_ops);amd_pmc_dbgfs_unregister (dev);pci_dev_put (dev->rdev);drivers/platform/x86/amd/pmc.c +1
-4mutex_destroy (&dev->lock);@@ -1061,9 +1050,7 @@ static struct platform_driver amd_pmc_driver = { .name = "amd_pmc", .acpi_match_table = amd_pmc_acpi_ids, .dev_groups = pmc_groups, -#ifdef CONFIG_SUSPEND - .pm = &amd_pmc_pm, -#endif + .pm = pm_sleep_ptr(&amd_pmc_pm), }, .probe = amd_pmc_probe, .remove = amd_pmc_remove, --2.39.1