hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IB78B0
-----------------------------------------------------------
Only support built in compile for hisi_hbmdev. We need to use lock_device_hotplug_sysfs() to prevent directly racing on acpi_scan_lock(), hbm memory can be time consumed during power on.
Signed-off-by: Zhang Zekun zhangzekun11@huawei.com --- arch/arm64/configs/openeuler_defconfig | 2 +- drivers/soc/hisilicon/Kconfig | 2 +- drivers/soc/hisilicon/hisi_hbmdev.c | 19 ++++++++++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index 4c117f2f55f1..dba4e3b2e79a 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -6117,7 +6117,7 @@ CONFIG_QCOM_KRYO_L2_ACCESSORS=y # Hisilicon SoC drivers # CONFIG_KUNPENG_HCCS=m -CONFIG_HISI_HBMDEV=m +CONFIG_HISI_HBMDEV=y CONFIG_HISI_HBMCACHE=m CONFIG_HISI_HBMDEV_ACLS=y CONFIG_HISI_L3T=m diff --git a/drivers/soc/hisilicon/Kconfig b/drivers/soc/hisilicon/Kconfig index 0e79de44a01f..2dc1a2060d30 100644 --- a/drivers/soc/hisilicon/Kconfig +++ b/drivers/soc/hisilicon/Kconfig @@ -19,7 +19,7 @@ config KUNPENG_HCCS health status and port information of HCCS on Kunpeng SoC.
config HISI_HBMDEV - tristate "add extra support for hbm memory device" + bool "add extra support for hbm memory device" depends on ACPI_HOTPLUG_MEMORY select ACPI_CONTAINER help diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index f09388a80009..4bf3a17fc2a8 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -59,9 +59,8 @@ static int memdev_power_on(struct acpi_device *adev) acpi_handle handle = adev->handle; acpi_status status;
- acpi_scan_lock_acquire(); + /* Power on and online the devices */ status = acpi_evaluate_object(handle, "_ON", NULL, NULL); - acpi_scan_lock_release(); if (ACPI_FAILURE(status)) { acpi_handle_warn(handle, "Power on failed (0x%x)\n", status); return -ENODEV; @@ -100,6 +99,7 @@ static int memdev_power_off(struct acpi_device *adev) acpi_dev_for_each_child(adev, hbmdev_check, NULL); acpi_scan_lock_release();
+ /* Eject the devices and power off */ status = acpi_evaluate_object(handle, "_OFF", NULL, NULL); if (ACPI_FAILURE(status)) { return -ENODEV; @@ -112,7 +112,12 @@ static ssize_t state_store(struct device *dev, struct device_attribute *attr, { struct acpi_device *adev = ACPI_COMPANION(dev); const int type = online_type_from_str(buf); - int ret = -EINVAL; + int ret; + + /* Disallow pending on the mutex to avoid potential hung task*/ + ret = lock_device_hotplug_sysfs(); + if (ret) + return ret;
switch (type) { case STATE_ONLINE: @@ -124,6 +129,7 @@ static ssize_t state_store(struct device *dev, struct device_attribute *attr, default: break; } + unlock_device_hotplug();
if (ret) return ret; @@ -196,9 +202,16 @@ static int container_init(void) return 0; }
+static struct acpi_platform_list kunpeng_hbm_plat_info[] = { + {"HISI ", "HIP11 ", 0, ACPI_SIG_IORT, all_versions, NULL, 0}, + { } +};
static int __init hbmdev_init(void) { + if (acpi_match_platform_list(kunpeng_hbm_plat_info) < 0) + return 0; + return container_init(); } module_init(hbmdev_init);