mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 17:42:03 +02:00
platform/x86/amd/hsmp: Map the metric table with ioremap() and unmap it explicitly
The metric-table DRAM region is mapped with devm_ioremap(), which ties the mapping to the socket device's devres scope. An upcoming change lets the ACPI front-end share the socket array across sockets and run its own coordinated teardown, so the mapping can no longer be pinned to a single per-socket devres scope. Map it with plain ioremap() instead and add hsmp_unmap_metric_tbls(), which drops every socket's metric_tbl_addr mapping. The platform driver registers that helper with devm_add_action_or_reset() so the mappings are released on both remove and probe failure, while the socket array itself stays devm-managed. Signed-off-by: Muralidhara M K <muralidhara.mk@amd.com> Link: https://patch.msgid.link/20260723094656.3806028-3-muralidhara.mk@amd.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
parent
9c40a57258
commit
5622564fc6
|
|
@ -12,6 +12,7 @@
|
|||
#include <linux/acpi.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/rwsem.h>
|
||||
#include <linux/semaphore.h>
|
||||
#include <linux/sysfs.h>
|
||||
|
|
@ -423,6 +424,21 @@ ssize_t hsmp_metric_tbl_read(struct hsmp_socket *sock, char *buf, size_t size)
|
|||
}
|
||||
EXPORT_SYMBOL_NS_GPL(hsmp_metric_tbl_read, "AMD_HSMP");
|
||||
|
||||
void hsmp_unmap_metric_tbls(struct hsmp_plat_device *pdev)
|
||||
{
|
||||
struct hsmp_socket *sock;
|
||||
u16 i;
|
||||
|
||||
for (i = 0; i < pdev->num_sockets; i++) {
|
||||
sock = &pdev->sock[i];
|
||||
if (sock->metric_tbl_addr) {
|
||||
iounmap(sock->metric_tbl_addr);
|
||||
sock->metric_tbl_addr = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(hsmp_unmap_metric_tbls, "AMD_HSMP");
|
||||
|
||||
int hsmp_get_tbl_dram_base(u16 sock_ind)
|
||||
{
|
||||
struct hsmp_socket *sock = &hsmp_pdev.sock[sock_ind];
|
||||
|
|
@ -447,8 +463,7 @@ int hsmp_get_tbl_dram_base(u16 sock_ind)
|
|||
dev_err(sock->dev, "Invalid DRAM address for metric table\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
sock->metric_tbl_addr = devm_ioremap(sock->dev, dram_addr,
|
||||
sizeof(struct hsmp_metric_table));
|
||||
sock->metric_tbl_addr = ioremap(dram_addr, sizeof(struct hsmp_metric_table));
|
||||
if (!sock->metric_tbl_addr) {
|
||||
dev_err(sock->dev, "Failed to ioremap metric table addr\n");
|
||||
return -ENOMEM;
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg);
|
|||
void hsmp_misc_deregister(void);
|
||||
int hsmp_misc_register(struct device *dev);
|
||||
int hsmp_get_tbl_dram_base(u16 sock_ind);
|
||||
void hsmp_unmap_metric_tbls(struct hsmp_plat_device *pdev);
|
||||
ssize_t hsmp_metric_tbl_read(struct hsmp_socket *sock, char *buf, size_t size);
|
||||
struct hsmp_plat_device *get_hsmp_pdev(void);
|
||||
#if IS_ENABLED(CONFIG_HWMON)
|
||||
|
|
|
|||
|
|
@ -201,6 +201,19 @@ static int init_platform_device(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* The socket array is devm-managed and freed by the driver core, but the
|
||||
* metric-table DRAM regions are mapped with plain ioremap() during probe and
|
||||
* are therefore not covered by devres.
|
||||
*
|
||||
* Drop those mappings from a devres action so both remove and probe failure
|
||||
* unmap them exactly once, before the socket array they refer to is freed.
|
||||
*/
|
||||
static void hsmp_pltdrv_release(void *data)
|
||||
{
|
||||
hsmp_unmap_metric_tbls(hsmp_pdev);
|
||||
}
|
||||
|
||||
static int hsmp_pltdrv_probe(struct platform_device *pdev)
|
||||
{
|
||||
int ret;
|
||||
|
|
@ -211,6 +224,10 @@ static int hsmp_pltdrv_probe(struct platform_device *pdev)
|
|||
if (!hsmp_pdev->sock)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = devm_add_action_or_reset(&pdev->dev, hsmp_pltdrv_release, NULL);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = init_platform_device(&pdev->dev);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Failed to init HSMP mailbox\n");
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user