From: Zhang Zekun <zhangzekun11@huawei.com> hulk inclusion category: feature bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 ----------------------------------------------------------- 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> Signed-off-by: Ziming Du <duziming2@huawei.com> --- arch/arm64/configs/openeuler_defconfig | 2 +- drivers/soc/hisilicon/Kconfig | 2 +- drivers/soc/hisilicon/hisi_hbmdev.c | 18 +++++++++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index d7a0daa041257..df37ee5c07853 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -6845,7 +6845,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 # end of Hisilicon SoC drivers # end of SOC (System On Chip) specific Drivers diff --git a/drivers/soc/hisilicon/Kconfig b/drivers/soc/hisilicon/Kconfig index 4d501a4c4c5b0..98f0e7d118dab 100644 --- a/drivers/soc/hisilicon/Kconfig +++ b/drivers/soc/hisilicon/Kconfig @@ -4,7 +4,7 @@ menu "Hisilicon SoC drivers" depends on ARCH_HISI || COMPILE_TEST config HISI_HBMDEV - tristate "add extra support for hbm memory device" + bool "add extra support for hbm memory device" depends on ACPI_HOTPLUG_MEMORY && ARCH_HISI select ACPI_CONTAINER help diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index 5c5f7c0a02410..778a9cc1450a8 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -255,9 +255,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; @@ -296,6 +295,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; @@ -308,7 +308,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: @@ -320,6 +325,7 @@ static ssize_t state_store(struct device *dev, struct device_attribute *attr, default: break; } + unlock_device_hotplug(); if (ret) return ret; @@ -392,10 +398,16 @@ static int container_init(void) return 0; } +static struct acpi_platform_list hbm_plat_info[] = { + {"HISI ", "HIP11 ", 0, ACPI_SIG_IORT, all_versions, NULL, 0}, + { } +}; static int __init mdev_init(void) { int ret; + if (acpi_match_platform_list(hbm_plat_info) < 0) + return 0; mdev = kzalloc(sizeof(struct memory_dev), GFP_KERNEL); if (!mdev) -- 2.43.0