Commit aec8298c authored by Shyam Sundar S K's avatar Shyam Sundar S K Committed by Hans de Goede

platform/x86/amd/pmf: Move out of BIOS SMN pair for driver probe

The current SMN index used for the driver probe seems to be meant
for the BIOS pair and there are potential concurrency problems that can
occur with an inopportune SMI.

It is been advised to use SMN_INDEX_0 instead of SMN_INDEX_2, which is
what amd_nb.c provides and this function has protections to ensure that
only one caller can use it at a time.

Fixes: da5ce22d ("platform/x86/amd/pmf: Add support for PMF core layer")
Co-developed-by: default avatarPatil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: default avatarPatil Rajesh Reddy <Patil.Reddy@amd.com>
Signed-off-by: default avatarShyam Sundar S K <Shyam-sundar.S-k@amd.com>
Link: https://lore.kernel.org/r/20230406164807.50969-4-Shyam-sundar.S-k@amd.comReviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 4f59630a
...@@ -7,6 +7,7 @@ config AMD_PMF ...@@ -7,6 +7,7 @@ config AMD_PMF
tristate "AMD Platform Management Framework" tristate "AMD Platform Management Framework"
depends on ACPI && PCI depends on ACPI && PCI
depends on POWER_SUPPLY depends on POWER_SUPPLY
depends on AMD_NB
select ACPI_PLATFORM_PROFILE select ACPI_PLATFORM_PROFILE
help help
This driver provides support for the AMD Platform Management Framework. This driver provides support for the AMD Platform Management Framework.
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
* Author: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> * Author: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
*/ */
#include <asm/amd_nb.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -22,8 +23,6 @@ ...@@ -22,8 +23,6 @@
#define AMD_PMF_REGISTER_ARGUMENT 0xA58 #define AMD_PMF_REGISTER_ARGUMENT 0xA58
/* Base address of SMU for mapping physical address to virtual address */ /* Base address of SMU for mapping physical address to virtual address */
#define AMD_PMF_SMU_INDEX_ADDRESS 0xB8
#define AMD_PMF_SMU_INDEX_DATA 0xBC
#define AMD_PMF_MAPPING_SIZE 0x01000 #define AMD_PMF_MAPPING_SIZE 0x01000
#define AMD_PMF_BASE_ADDR_OFFSET 0x10000 #define AMD_PMF_BASE_ADDR_OFFSET 0x10000
#define AMD_PMF_BASE_ADDR_LO 0x13B102E8 #define AMD_PMF_BASE_ADDR_LO 0x13B102E8
...@@ -348,30 +347,19 @@ static int amd_pmf_probe(struct platform_device *pdev) ...@@ -348,30 +347,19 @@ static int amd_pmf_probe(struct platform_device *pdev)
} }
dev->cpu_id = rdev->device; dev->cpu_id = rdev->device;
err = pci_write_config_dword(rdev, AMD_PMF_SMU_INDEX_ADDRESS, AMD_PMF_BASE_ADDR_LO);
if (err) {
dev_err(dev->dev, "error writing to 0x%x\n", AMD_PMF_SMU_INDEX_ADDRESS);
pci_dev_put(rdev);
return pcibios_err_to_errno(err);
}
err = pci_read_config_dword(rdev, AMD_PMF_SMU_INDEX_DATA, &val); err = amd_smn_read(0, AMD_PMF_BASE_ADDR_LO, &val);
if (err) { if (err) {
dev_err(dev->dev, "error in reading from 0x%x\n", AMD_PMF_BASE_ADDR_LO);
pci_dev_put(rdev); pci_dev_put(rdev);
return pcibios_err_to_errno(err); return pcibios_err_to_errno(err);
} }
base_addr_lo = val & AMD_PMF_BASE_ADDR_HI_MASK; base_addr_lo = val & AMD_PMF_BASE_ADDR_HI_MASK;
err = pci_write_config_dword(rdev, AMD_PMF_SMU_INDEX_ADDRESS, AMD_PMF_BASE_ADDR_HI); err = amd_smn_read(0, AMD_PMF_BASE_ADDR_HI, &val);
if (err) {
dev_err(dev->dev, "error writing to 0x%x\n", AMD_PMF_SMU_INDEX_ADDRESS);
pci_dev_put(rdev);
return pcibios_err_to_errno(err);
}
err = pci_read_config_dword(rdev, AMD_PMF_SMU_INDEX_DATA, &val);
if (err) { if (err) {
dev_err(dev->dev, "error in reading from 0x%x\n", AMD_PMF_BASE_ADDR_HI);
pci_dev_put(rdev); pci_dev_put(rdev);
return pcibios_err_to_errno(err); return pcibios_err_to_errno(err);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment