Remove the acls and memory topo support in hisi_hbmdev.
Set demand offlne in the sysfs.
v2: The "state" sysfs interface is duplicated with "status" interface, so remove the redundant one. The "hbm_memory" sysfs interface is unused because the acls and memory topology features has been removed.
Zhang Zekun (5): Revert "soc: hisilicon: hisi_hbmdev: Add hbm acls repair and query methods" Revert "soc: hisilicon: hisi_hbmdev: Provide extra memory topology information" soc: hisilicon: Setting the demand_offline in sysfs interface soc/hisilicon: Clean the hbmcache state show sysfs soc/hisilicon: Remove the memdev kobj
drivers/soc/hisilicon/Kconfig | 20 +- drivers/soc/hisilicon/hisi_hbmcache.c | 20 +- drivers/soc/hisilicon/hisi_hbmdev.c | 286 ++++---------------------- 3 files changed, 41 insertions(+), 285 deletions(-)
hulk inclusion category: freature bugzilla: https://gitee.com/openeuler/kernel/issues/IAKLPG
-----------------------------------------
This reverts commit 4b3a359dbd757d7be787bce99d221eb213ebb39d.
Signed-off-by: Zhang Zekun zhangzekun11@huawei.com --- drivers/soc/hisilicon/Kconfig | 11 --- drivers/soc/hisilicon/hisi_hbmdev.c | 134 ---------------------------- 2 files changed, 145 deletions(-)
diff --git a/drivers/soc/hisilicon/Kconfig b/drivers/soc/hisilicon/Kconfig index 90d8036ae658..c21612f0a52e 100644 --- a/drivers/soc/hisilicon/Kconfig +++ b/drivers/soc/hisilicon/Kconfig @@ -44,16 +44,6 @@ config HISI_HBMCACHE To compile the driver as a module, choose M here: the module will be called hisi_hbmcache.
-config HISI_HBMDEV_ACLS - bool "Add support for HISI ACLS repair" - depends on HISI_HBMDEV - help - Add ACLS support for hbm device, which can be used to query and - repair hardware error in HBM devices. This feature need to work with - hardware firmwares. - - If not sure say no. - config HISI_L3T tristate "Add support for l3t" depends on ARM64 && ACPI @@ -71,5 +61,4 @@ config HISI_L0 for user to alloc and lock memory
If not sure say no. - endmenu diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index 9fa464c94bbc..af487c439a90 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -11,7 +11,6 @@ #include <linux/node.h> #include <linux/arch_topology.h> #include <linux/memory_hotplug.h> -#include <linux/mm.h>
#include "hisi_internal.h"
@@ -26,9 +25,6 @@ struct cdev_node { struct memory_dev { struct kobject *memdev_kobj; struct kobject *topo_kobj; -#ifdef CONFIG_HISI_HBMDEV_ACLS - struct kobject *acls_kobj; -#endif struct cdev_node cdev_list; nodemask_t cluster_cpumask[MAX_NUMNODES]; }; @@ -89,134 +85,6 @@ static void memory_topo_init(void) kobject_put(mdev->topo_kobj); }
-#ifdef CONFIG_HISI_HBMDEV_ACLS -static struct acpi_device *paddr_to_acpi_device(u64 paddr) -{ - unsigned long pfn; - int nid; - - pfn = __phys_to_pfn(paddr); - if (!pfn_valid(pfn)) - return NULL; - - nid = pfn_to_nid(pfn); - if (nid < 0 && nid >= MAX_NUMNODES) - return NULL; - - return hotplug_mdev[nid]; -} - -static ssize_t acls_query_store(struct kobject *kobj, - struct kobj_attribute *attr, - const char *buf, size_t count) -{ - struct acpi_object_list arg_list; - struct acpi_device *adev; - union acpi_object obj; - acpi_status status; - u64 paddr, res; - - if (kstrtoull(buf, 16, &paddr)) - return -EINVAL; - - adev = paddr_to_acpi_device(paddr); - if (!adev) - return -EINVAL; - - obj.type = ACPI_TYPE_INTEGER; - obj.integer.value = paddr; - arg_list.count = 1; - arg_list.pointer = &obj; - - status = acpi_evaluate_integer(adev->handle, "AQRY", &arg_list, &res); - if (ACPI_FAILURE(status)) - return -ENODEV; - - /* AQRY will return a positive error code to represent error status */ - if (IS_ERR_VALUE(-res)) - return -res; - else if (res) - return -ENODEV; - - return count; -} - -static struct kobj_attribute acls_query_store_attribute = - __ATTR(acls_query, 0200, NULL, acls_query_store); - -static ssize_t acls_repair_store(struct kobject *kobj, - struct kobj_attribute *attr, - const char *buf, size_t count) -{ - struct acpi_object_list arg_list; - struct acpi_device *adev; - union acpi_object obj; - acpi_status status; - u64 paddr, res; - - if (kstrtoull(buf, 16, &paddr)) - return -EINVAL; - - adev = paddr_to_acpi_device(paddr); - if (!adev) - return -EINVAL; - - obj.type = ACPI_TYPE_INTEGER; - obj.integer.value = paddr; - arg_list.count = 1; - arg_list.pointer = &obj; - - status = acpi_evaluate_integer(adev->handle, "AREP", &arg_list, &res); - if (ACPI_FAILURE(status)) - return -ENODEV; - - /* AREP will return a positive error code to represent error status */ - if (IS_ERR_VALUE(-res)) - return -res; - else if (res) - return -ENODEV; - - return count; -} -static struct kobj_attribute acls_repair_store_attribute = - __ATTR(acls_repair, 0200, NULL, acls_repair_store); - -static struct attribute *acls_attrs[] = { - &acls_query_store_attribute.attr, - &acls_repair_store_attribute.attr, - NULL, -}; - -static struct attribute_group acls_attr_group = { - .attrs = acls_attrs, -}; - -static void acls_init(void) -{ - int ret = -ENOMEM; - - mdev->acls_kobj = kobject_create_and_add("acls", mdev->memdev_kobj); - if (!mdev->acls_kobj) - goto out; - - ret = sysfs_create_group(mdev->acls_kobj, &acls_attr_group); - if (ret) - kobject_put(mdev->acls_kobj); - -out: - if (ret) - pr_err("ACLS hot repair is not enabled\n"); -} - -static void acls_remove(void) -{ - kobject_put(mdev->acls_kobj); -} -#else -static void acls_init(void) {} -static void acls_remove(void) {} -#endif - static int get_pxm(struct acpi_device *acpi_device, void *arg) { acpi_handle handle = acpi_device->handle; @@ -404,7 +272,6 @@ static int __init mdev_init(void) }
memory_topo_init(); - acls_init(); return ret; } module_init(mdev_init); @@ -414,7 +281,6 @@ static void __exit mdev_exit(void) container_remove(); kobject_put(mdev->memdev_kobj); kobject_put(mdev->topo_kobj); - acls_remove(); kfree(mdev); } module_exit(mdev_exit);
hulk inclusion category: bugzilla bugzilla: https://gitee.com/openeuler/kernel/issues/IAKLPG
-----------------------------------------
This reverts commit a1390bb0654951846bb303807004923a50e7a0a6.
Signed-off-by: Zhang Zekun zhangzekun11@huawei.com --- drivers/soc/hisilicon/Kconfig | 9 ++--- drivers/soc/hisilicon/hisi_hbmdev.c | 61 ----------------------------- 2 files changed, 3 insertions(+), 67 deletions(-)
diff --git a/drivers/soc/hisilicon/Kconfig b/drivers/soc/hisilicon/Kconfig index c21612f0a52e..ec5be0b59f95 100644 --- a/drivers/soc/hisilicon/Kconfig +++ b/drivers/soc/hisilicon/Kconfig @@ -23,12 +23,9 @@ config HISI_HBMDEV depends on ACPI_HOTPLUG_MEMORY select ACPI_CONTAINER help - This driver add two extra supports for memory devices. The driver - provides methods for userpace to control the power of memory devices - in a container. Besides, it provides extra locality information - between cpus and memory devices for userspace, which can take - advantage of this functionality to select the closet memory device - to a certain cpu. + This driver add extra supports for memory devices. The driver + provides methods for userpace to control the power of memory + devices in a container.
To compile this driver as a module, choose M here: the module will be called hisi_hbmdev. diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index af487c439a90..e64748a0a21e 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -8,9 +8,6 @@ #include <linux/nodemask.h> #include <linux/acpi.h> #include <linux/container.h> -#include <linux/node.h> -#include <linux/arch_topology.h> -#include <linux/memory_hotplug.h>
#include "hisi_internal.h"
@@ -24,67 +21,11 @@ struct cdev_node {
struct memory_dev { struct kobject *memdev_kobj; - struct kobject *topo_kobj; struct cdev_node cdev_list; - nodemask_t cluster_cpumask[MAX_NUMNODES]; };
static struct memory_dev *mdev;
-static ssize_t memory_locality_show(struct kobject *kobj, - struct kobj_attribute *attr, - char *buf) -{ - int i, count = 0; - - for (i = 0; i < MAX_NUMNODES; i++) { - if (hotplug_mdev[i] != NULL && !nodes_empty(mdev->cluster_cpumask[i])) { - count += sysfs_emit_at(buf, count, "%d %*pbl\n", i, - nodemask_pr_args(&mdev->cluster_cpumask[i])); - } - } - - return count; -} - -static struct kobj_attribute memory_locality_attribute = - __ATTR(memory_locality, 0444, memory_locality_show, NULL); - -static void memory_topo_init(void) -{ - int ret, nid, cluster_id, cpu; - struct acpi_device *adev; - nodemask_t mask; - - for (nid = 0; nid < MAX_NUMNODES; nid++) { - if (!hotplug_mdev[nid]) - continue; - - adev = hotplug_mdev[nid]; - ret = fwnode_property_read_u32(acpi_fwnode_handle(adev), - "cluster-id", &cluster_id); - if (ret < 0) { - pr_debug("Failed to read cluster id\n"); - return; - } - - nodes_clear(mask); - for_each_possible_cpu(cpu) { - if (topology_cluster_id(cpu) == cluster_id) - node_set(cpu, mask); - } - mdev->cluster_cpumask[nid] = mask; - } - - mdev->topo_kobj = kobject_create_and_add("memory_topo", mdev->memdev_kobj); - if (!mdev->topo_kobj) - return; - - ret = sysfs_create_file(mdev->topo_kobj, &memory_locality_attribute.attr); - if (ret) - kobject_put(mdev->topo_kobj); -} - static int get_pxm(struct acpi_device *acpi_device, void *arg) { acpi_handle handle = acpi_device->handle; @@ -271,7 +212,6 @@ static int __init mdev_init(void) return -ENOMEM; }
- memory_topo_init(); return ret; } module_init(mdev_init); @@ -280,7 +220,6 @@ static void __exit mdev_exit(void) { container_remove(); kobject_put(mdev->memdev_kobj); - kobject_put(mdev->topo_kobj); kfree(mdev); } module_exit(mdev_exit);
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IAKLPG
------------------------------
Move the setting of demand_offline in sysfs interface, because there could be devices have not been attached to acpi_bus, If we set it in the probe phase, we might missing some pnp devices which is attached later.
Signed-off-by: Zhang Zekun zhangzekun11@huawei.com --- drivers/soc/hisilicon/hisi_hbmdev.c | 43 +++++++++++++++++------------ 1 file changed, 26 insertions(+), 17 deletions(-)
diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index e64748a0a21e..e8c5b8a55b7c 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -73,11 +73,36 @@ static int memdev_power_on(struct acpi_device *adev) return 0; }
+static int hbmdev_check(struct acpi_device *adev, void *arg) +{ + const char *hid = acpi_device_hid(adev); + + if (!strcmp(hid, ACPI_MEMORY_DEVICE_HID)) { + if (arg) { + bool *found = arg; + *found = true; + return -1; + } + + /* There might be devices have not attached */ + if (!adev->handler) + return 0; + + acpi_scan_lock_acquire(); + adev->handler->hotplug.demand_offline = true; + acpi_scan_lock_release(); + } + + return 0; +} + static int memdev_power_off(struct acpi_device *adev) { acpi_handle handle = adev->handle; acpi_status status;
+ acpi_dev_for_each_child(adev, hbmdev_check, NULL); + status = acpi_evaluate_object(handle, "_OFF", NULL, NULL); if (ACPI_FAILURE(status)) { return -ENODEV; @@ -110,21 +135,6 @@ static ssize_t state_store(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_WO(state);
-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 0; -} - static bool has_hbmdev(struct device *dev) { struct acpi_device *adev = ACPI_COMPANION(dev); @@ -134,8 +144,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_setup, &found); - + acpi_dev_for_each_child(adev, hbmdev_check, &found); return found; }
There is no need to provide a extra state_show sysfs to query the hbm_cache state, we can use the "status" sysfs interface to query the hbm_cache state.
Signed-off-by: Zhang Zekun zhangzekun11@huawei.com --- drivers/soc/hisilicon/hisi_hbmcache.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)
diff --git a/drivers/soc/hisilicon/hisi_hbmcache.c b/drivers/soc/hisilicon/hisi_hbmcache.c index 34121320742e..c3295a7919d1 100644 --- a/drivers/soc/hisilicon/hisi_hbmcache.c +++ b/drivers/soc/hisilicon/hisi_hbmcache.c @@ -38,25 +38,7 @@ static ssize_t state_store(struct device *d, struct device_attribute *attr,
return count; } - -static ssize_t state_show(struct device *d, struct device_attribute *attr, - char *buf) -{ - struct acpi_device *adev = ACPI_COMPANION(d); - unsigned long long sta = 0; - acpi_status status; - const char *output; - - status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta); - if (ACPI_FAILURE(status)) - return -EINVAL; - - output = (sta & 0x01) ? online_type_to_str[STATE_ONLINE] : - online_type_to_str[STATE_OFFLINE]; - - return sysfs_emit(buf, "%s\n", output); -} -static DEVICE_ATTR_RW(state); +static DEVICE_ATTR_WO(state);
static ssize_t socket_id_show(struct device *d, struct device_attribute *attr, char *buf)
From: Zhang Zekun zhagnzekun11@huawei.com
Since we have remove the memory topo and acls feature in hisi_hbmdev we no longer need to create sysfs. So, remove the sysfs interface.
Signed-off-by: Zhang Zekun zhangzekun11@huawei.com --- drivers/soc/hisilicon/hisi_hbmdev.c | 48 +++++++---------------------- 1 file changed, 11 insertions(+), 37 deletions(-)
diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index e8c5b8a55b7c..33e5f0d9dde0 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -19,12 +19,7 @@ struct cdev_node { struct list_head clist; };
-struct memory_dev { - struct kobject *memdev_kobj; - struct cdev_node cdev_list; -}; - -static struct memory_dev *mdev; +struct cdev_node cdev_list;
static int get_pxm(struct acpi_device *acpi_device, void *arg) { @@ -160,7 +155,7 @@ static int container_add(struct device *dev, void *data) return -ENOMEM;
cnode->dev = dev; - list_add_tail(&cnode->clist, &mdev->cdev_list.clist); + list_add_tail(&cnode->clist, &cdev_list.clist);
return 0; } @@ -169,7 +164,7 @@ static void container_remove(void) { struct cdev_node *cnode, *tmp;
- list_for_each_entry_safe(cnode, tmp, &mdev->cdev_list.clist, clist) { + list_for_each_entry_safe(cnode, tmp, &cdev_list.clist, clist) { device_remove_file(cnode->dev, &dev_attr_state); device_remove_file(cnode->dev, &dev_attr_pxms); list_del(&cnode->clist); @@ -181,17 +176,17 @@ static int container_init(void) { struct cdev_node *cnode;
- INIT_LIST_HEAD(&mdev->cdev_list.clist); + INIT_LIST_HEAD(&cdev_list.clist);
if (bus_for_each_dev(&container_subsys, NULL, NULL, container_add)) { container_remove(); return -ENOMEM; }
- if (list_empty(&mdev->cdev_list.clist)) + if (list_empty(&cdev_list.clist)) return -ENODEV;
- list_for_each_entry(cnode, &mdev->cdev_list.clist, clist) { + list_for_each_entry(cnode, &cdev_list.clist, clist) { device_create_file(cnode->dev, &dev_attr_state); device_create_file(cnode->dev, &dev_attr_pxms); } @@ -200,38 +195,17 @@ static int container_init(void) }
-static int __init mdev_init(void) +static int __init hbmdev_init(void) { - int ret; - - mdev = kzalloc(sizeof(struct memory_dev), GFP_KERNEL); - if (!mdev) - return -ENOMEM; - - ret = container_init(); - if (ret) { - kfree(mdev); - return ret; - } - - mdev->memdev_kobj = kobject_create_and_add("hbm_memory", kernel_kobj); - if (!mdev->memdev_kobj) { - container_remove(); - kfree(mdev); - return -ENOMEM; - } - - return ret; + return container_init(); } -module_init(mdev_init); +module_init(hbmdev_init);
-static void __exit mdev_exit(void) +static void __exit hbmdev_exit(void) { container_remove(); - kobject_put(mdev->memdev_kobj); - kfree(mdev); } -module_exit(mdev_exit); +module_exit(hbmdev_exit);
MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Zhang Zekun zhangzekun11@huawei.com");
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/10943 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/S...
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/10943 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/S...