Refactoring some mechanism in hbmdev: 1. Memory node on the hbmdev need to be offlined before poweroff the device. 2. Use AML code to trigger the hbmdev poweroff process
Zhang Zekun (3): soc: hisilicon: hisi_hbmdev: Notify the device in the ACPI soc: hisilicon: Don't poweroff if memblocks don't offlined arm64: config: Open the hbmdev related config
arch/arm64/configs/openeuler_defconfig | 5 ++-- drivers/acpi/osl.c | 1 - drivers/soc/hisilicon/hisi_hbmdev.c | 34 +++++++++----------------- 3 files changed, 14 insertions(+), 26 deletions(-)
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 zhangzekun11@huawei.com --- 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,
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 zhangzekun11@huawei.com --- 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; }
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 zhangzekun11@huawei.com --- 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 9b0bc98d975f..4dcf8c5293fe 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -6108,8 +6108,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
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/8908 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/L...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/8908 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/L...