platform/x86/amd/pmf: Force load driver on older supported platforms
authorShyam Sundar S K <Shyam-sundar.S-k@amd.com>
Tue, 2 Aug 2022 15:11:48 +0000 (20:41 +0530)
committerHans de Goede <hdegoede@redhat.com>
Mon, 15 Aug 2022 11:23:38 +0000 (13:23 +0200)
Some of the older platforms with _HID "AMDI0100" PMF driver can be force
loaded by interested users but only for experimental purposes.

Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Link: https://lore.kernel.org/r/20220802151149.2123699-11-Shyam-sundar.S-k@amd.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/amd/pmf/core.c

index 228fe24..e46d63a 100644 (file)
@@ -39,6 +39,7 @@
 #define AMD_PMF_RESULT_FAILED                0xFF
 
 /* List of supported CPU ids */
+#define AMD_CPU_ID_RMB                 0x14b5
 #define AMD_CPU_ID_PS                  0x14e8
 
 #define PMF_MSG_DELAY_MIN_US           50
@@ -52,6 +53,11 @@ static int metrics_table_loop_ms = 1000;
 module_param(metrics_table_loop_ms, int, 0644);
 MODULE_PARM_DESC(metrics_table_loop_ms, "Metrics Table sample size time (default = 1000ms)");
 
+/* Force load on supported older platforms */
+static bool force_load;
+module_param(force_load, bool, 0444);
+MODULE_PARM_DESC(force_load, "Force load this driver on supported older platforms (experimental)");
+
 static int current_power_limits_show(struct seq_file *seq, void *unused)
 {
        struct amd_pmf_dev *dev = seq->private;
@@ -208,6 +214,7 @@ out_unlock:
 }
 
 static const struct pci_device_id pmf_pci_ids[] = {
+       { PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_RMB) },
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_PS) },
        { }
 };
@@ -265,6 +272,7 @@ static void amd_pmf_deinit_features(struct amd_pmf_dev *dev)
 }
 
 static const struct acpi_device_id amd_pmf_acpi_ids[] = {
+       {"AMDI0100", 0x100},
        {"AMDI0102", 0},
        { }
 };
@@ -272,6 +280,7 @@ MODULE_DEVICE_TABLE(acpi, amd_pmf_acpi_ids);
 
 static int amd_pmf_probe(struct platform_device *pdev)
 {
+       const struct acpi_device_id *id;
        struct amd_pmf_dev *dev;
        struct pci_dev *rdev;
        u32 base_addr_lo;
@@ -280,6 +289,13 @@ static int amd_pmf_probe(struct platform_device *pdev)
        u32 val;
        int err;
 
+       id = acpi_match_device(amd_pmf_acpi_ids, &pdev->dev);
+       if (!id)
+               return -ENODEV;
+
+       if (id->driver_data == 0x100 && !force_load)
+               return -ENODEV;
+
        dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
        if (!dev)
                return -ENOMEM;