From 9c0bbeee61f6aac34e3e0eed3e46638f86367ebe Mon Sep 17 00:00:00 2001 From: Zhang Zekun Date: Tue, 11 Jun 2024 10:19:26 +0800 Subject: [PATCH 1/3] soc: hisilicon: hisi_hbmdev: Notify the device in the ACPI hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I9W022 ---------------------------------- Move the hbm power off logic to ACPI. The hotplugable devices can be ejected by receiving Notify 0x3, so there is no need to call acpi_hotplug_schedule in driver. Signed-off-by: Zhang Zekun --- drivers/acpi/osl.c | 1 - drivers/soc/hisilicon/hisi_hbmdev.c | 26 ++++++-------------------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index b11c74f229a5..0418febc5cf2 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -1188,7 +1188,6 @@ acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src) } return AE_OK; } -EXPORT_SYMBOL_GPL(acpi_hotplug_schedule); bool acpi_queue_hotplug_work(struct work_struct *work) { diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index a9cc78bde81b..1d0364c7f4fc 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -264,30 +264,16 @@ static int memdev_power_on(struct acpi_device *adev) return 0; } -static int eject_device(struct acpi_device *acpi_device, void *not_used) +static int memdev_power_off(struct acpi_device *adev) { - acpi_object_type unused; + acpi_handle handle = adev->handle; acpi_status status; - status = acpi_get_type(acpi_device->handle, &unused); - if (ACPI_FAILURE(status) || !acpi_device->flags.ejectable) + status = acpi_evaluate_object(handle, "_OFF", NULL, NULL); + if (ACPI_FAILURE(status)) { return -ENODEV; - - get_device(&acpi_device->dev); - status = acpi_hotplug_schedule(acpi_device, ACPI_OST_EC_OSPM_EJECT); - if (ACPI_SUCCESS(status)) - return 0; - - put_device(&acpi_device->dev); - acpi_evaluate_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT, - ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL); - - return status == AE_NO_MEMORY ? -ENOMEM : -EAGAIN; -} - -static int memdev_power_off(struct acpi_device *adev) -{ - return acpi_dev_for_each_child(adev, eject_device, NULL); + } + return 0; } static ssize_t state_store(struct device *dev, struct device_attribute *attr, -- Gitee From 6f2b4e587ed4df77c20e9a3169bca939df2ee733 Mon Sep 17 00:00:00 2001 From: Zhang Zekun Date: Tue, 11 Jun 2024 10:19:27 +0800 Subject: [PATCH 2/3] soc: hisilicon: Don't poweroff if memblocks don't offlined hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9W022 ------------------------------------ We can not determine which physical_node can be offlined. There could be pages pinned by user space. when we try to offline a memblock on which has already pinned pages, we will fall into a loop to migrate these pinned pages. Fixes: 039ec3f73992 ("soc: hisilicon: hisi_hbmdev: Add power domain control methods") Signed-off-by: Zhang Zekun --- drivers/soc/hisilicon/hisi_hbmdev.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index 1d0364c7f4fc..9fa464c94bbc 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -301,14 +301,16 @@ static ssize_t state_store(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_WO(state); -static int hbmdev_find(struct acpi_device *adev, void *arg) +static int hbmdev_setup(struct acpi_device *adev, void *arg) { const char *hid = acpi_device_hid(adev); bool *found = arg; if (!strcmp(hid, ACPI_MEMORY_DEVICE_HID)) { + acpi_scan_lock_acquire(); + adev->handler->hotplug.demand_offline = true; + acpi_scan_lock_release(); *found = true; - return -1; } return 0; @@ -323,7 +325,7 @@ static bool has_hbmdev(struct device *dev) if (strcmp(hid, ACPI_GENERIC_CONTAINER_DEVICE_HID)) return found; - acpi_dev_for_each_child(adev, hbmdev_find, &found); + acpi_dev_for_each_child(adev, hbmdev_setup, &found); return found; } -- Gitee From 2ae741c4f4c43369716d8ba23130ae93cce0c4eb Mon Sep 17 00:00:00 2001 From: Zhang Zekun Date: Tue, 11 Jun 2024 10:19:28 +0800 Subject: [PATCH 3/3] arm64: config: Open the hbmdev related config hulk inclusion category: category bugzilla: https://gitee.com/openeuler/kernel/issues/I9W022 -------------------------------------------- Open the hbmdev related config, add support for kunpeng hbm related drivers. Signed-off-by: Zhang Zekun --- arch/arm64/configs/openeuler_defconfig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index d2aa35d4d3cd..60251e461e90 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -6109,8 +6109,9 @@ CONFIG_QCOM_KRYO_L2_ACCESSORS=y # Hisilicon SoC drivers # CONFIG_KUNPENG_HCCS=m -# CONFIG_HISI_HBMDEV is not set -# CONFIG_HISI_HBMCACHE is not set +CONFIG_HISI_HBMDEV=m +CONFIG_HISI_HBMCACHE=m +CONFIG_HISI_HBMDEV_ACLS=y CONFIG_HISI_L3T=m CONFIG_HISI_L0=m # end of Hisilicon SoC drivers -- Gitee