]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
platform/x86/amd/pmc: Move STB block into amd_pmc_s2d_init()
authorShyam Sundar S K <Shyam-sundar.S-k@amd.com>
Fri, 8 Nov 2024 07:08:13 +0000 (12:38 +0530)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 2 Dec 2024 17:31:35 +0000 (19:31 +0200)
Transfer the support for STB-related file operations to the
amd_pmc_s2d_init() function, thereby consolidating the STB and S2D
(Spill to DRAM) functionality in one location. Also, relocate the
call to amd_pmc_s2d_init() to occur after the creation of the
"amd_pmc" debugfs directory. This ensures that the driver's root debugfs
directory is established beforehand.

For older platforms that supported S2D, exit immediately after creating
debugfs. These platforms may not support the PMFW messages available on
newer platforms. This adjustment is necessary due to the relocation of
debugfs creation into amd_pmc_s2d_init().

Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Co-developed-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Link: https://lore.kernel.org/r/20241108070822.3912689-2-Shyam-sundar.S-k@amd.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/amd/pmc/pmc.c

index 26b878ee519181467b8bc5620a1c1bf54ee54de8..edd61020fa9afa5d02609d083895362e33b8c0d4 100644 (file)
@@ -648,15 +648,6 @@ static void amd_pmc_dbgfs_register(struct amd_pmc_dev *dev)
                            &s0ix_stats_fops);
        debugfs_create_file("amd_pmc_idlemask", 0644, dev->dbgfs_dir, dev,
                            &amd_pmc_idlemask_fops);
-       /* Enable STB only when the module_param is set */
-       if (enable_stb) {
-               if (amd_pmc_is_stb_supported(dev))
-                       debugfs_create_file("stb_read", 0644, dev->dbgfs_dir, dev,
-                                           &amd_pmc_stb_debugfs_fops_v2);
-               else
-                       debugfs_create_file("stb_read", 0644, dev->dbgfs_dir, dev,
-                                           &amd_pmc_stb_debugfs_fops);
-       }
 }
 
 static void amd_pmc_dump_registers(struct amd_pmc_dev *dev)
@@ -982,6 +973,18 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
        u32 size = 0;
        int ret;
 
+       if (!enable_stb)
+               return 0;
+
+       if (amd_pmc_is_stb_supported(dev)) {
+               debugfs_create_file("stb_read", 0644, dev->dbgfs_dir, dev,
+                                   &amd_pmc_stb_debugfs_fops_v2);
+       } else {
+               debugfs_create_file("stb_read", 0644, dev->dbgfs_dir, dev,
+                                   &amd_pmc_stb_debugfs_fops);
+               return 0;
+       }
+
        /* Spill to DRAM feature uses separate SMU message port */
        dev->msg_port = 1;
 
@@ -1100,12 +1103,6 @@ static int amd_pmc_probe(struct platform_device *pdev)
        /* Get num of IP blocks within the SoC */
        amd_pmc_get_ip_info(dev);
 
-       if (enable_stb && amd_pmc_is_stb_supported(dev)) {
-               err = amd_pmc_s2d_init(dev);
-               if (err)
-                       goto err_pci_dev_put;
-       }
-
        platform_set_drvdata(pdev, dev);
        if (IS_ENABLED(CONFIG_SUSPEND)) {
                err = acpi_register_lps0_dev(&amd_pmc_s2idle_dev_ops);
@@ -1116,6 +1113,10 @@ static int amd_pmc_probe(struct platform_device *pdev)
        }
 
        amd_pmc_dbgfs_register(dev);
+       err = amd_pmc_s2d_init(dev);
+       if (err)
+               goto err_pci_dev_put;
+
        if (IS_ENABLED(CONFIG_AMD_MP2_STB))
                amd_mp2_stb_init(dev);
        pm_report_max_hw_sleep(U64_MAX);