mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-11-23 10:06:28 +08:00
cxl: Fix sysfs export of qos_class for memdev
Current implementation exports only to /sys/bus/cxl/devices/.../memN/qos_class. With both ram and pmem exposed, the second registered sysfs attribute is rejected as duplicate. It's not possible to create qos_class under the dev_groups via the driver due to the ram and pmem sysfs sub-directories already created by the device sysfs groups. Move the ram and pmem qos_class to the device sysfs groups and add a call to sysfs_update() after the perf data are validated so the qos_class can be visible. The end results should be /sys/bus/cxl/devices/.../memN/ram/qos_class and /sys/bus/cxl/devices/.../memN/pmem/qos_class. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/20240206190431.1810289-4-dave.jiang@intel.com Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
10cb393d76
commit
cc214417f0
@ -382,6 +382,7 @@ void cxl_endpoint_parse_cdat(struct cxl_port *port)
|
||||
|
||||
cxl_memdev_set_qos_class(cxlds, dsmas_xa);
|
||||
cxl_qos_class_verify(cxlmd);
|
||||
cxl_memdev_update_perf(cxlmd);
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(cxl_endpoint_parse_cdat, CXL);
|
||||
|
||||
|
@ -447,13 +447,41 @@ static struct attribute *cxl_memdev_attributes[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static ssize_t pmem_qos_class_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
|
||||
struct cxl_dev_state *cxlds = cxlmd->cxlds;
|
||||
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlds);
|
||||
|
||||
return sysfs_emit(buf, "%d\n", mds->pmem_perf.qos_class);
|
||||
}
|
||||
|
||||
static struct device_attribute dev_attr_pmem_qos_class =
|
||||
__ATTR(qos_class, 0444, pmem_qos_class_show, NULL);
|
||||
|
||||
static struct attribute *cxl_memdev_pmem_attributes[] = {
|
||||
&dev_attr_pmem_size.attr,
|
||||
&dev_attr_pmem_qos_class.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static ssize_t ram_qos_class_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
|
||||
struct cxl_dev_state *cxlds = cxlmd->cxlds;
|
||||
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlds);
|
||||
|
||||
return sysfs_emit(buf, "%d\n", mds->ram_perf.qos_class);
|
||||
}
|
||||
|
||||
static struct device_attribute dev_attr_ram_qos_class =
|
||||
__ATTR(qos_class, 0444, ram_qos_class_show, NULL);
|
||||
|
||||
static struct attribute *cxl_memdev_ram_attributes[] = {
|
||||
&dev_attr_ram_size.attr,
|
||||
&dev_attr_ram_qos_class.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
@ -477,14 +505,42 @@ static struct attribute_group cxl_memdev_attribute_group = {
|
||||
.is_visible = cxl_memdev_visible,
|
||||
};
|
||||
|
||||
static umode_t cxl_ram_visible(struct kobject *kobj, struct attribute *a, int n)
|
||||
{
|
||||
struct device *dev = kobj_to_dev(kobj);
|
||||
struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
|
||||
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds);
|
||||
|
||||
if (a == &dev_attr_ram_qos_class.attr)
|
||||
if (mds->ram_perf.qos_class == CXL_QOS_CLASS_INVALID)
|
||||
return 0;
|
||||
|
||||
return a->mode;
|
||||
}
|
||||
|
||||
static struct attribute_group cxl_memdev_ram_attribute_group = {
|
||||
.name = "ram",
|
||||
.attrs = cxl_memdev_ram_attributes,
|
||||
.is_visible = cxl_ram_visible,
|
||||
};
|
||||
|
||||
static umode_t cxl_pmem_visible(struct kobject *kobj, struct attribute *a, int n)
|
||||
{
|
||||
struct device *dev = kobj_to_dev(kobj);
|
||||
struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
|
||||
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds);
|
||||
|
||||
if (a == &dev_attr_pmem_qos_class.attr)
|
||||
if (mds->pmem_perf.qos_class == CXL_QOS_CLASS_INVALID)
|
||||
return 0;
|
||||
|
||||
return a->mode;
|
||||
}
|
||||
|
||||
static struct attribute_group cxl_memdev_pmem_attribute_group = {
|
||||
.name = "pmem",
|
||||
.attrs = cxl_memdev_pmem_attributes,
|
||||
.is_visible = cxl_pmem_visible,
|
||||
};
|
||||
|
||||
static umode_t cxl_memdev_security_visible(struct kobject *kobj,
|
||||
@ -519,6 +575,13 @@ static const struct attribute_group *cxl_memdev_attribute_groups[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
void cxl_memdev_update_perf(struct cxl_memdev *cxlmd)
|
||||
{
|
||||
sysfs_update_group(&cxlmd->dev.kobj, &cxl_memdev_ram_attribute_group);
|
||||
sysfs_update_group(&cxlmd->dev.kobj, &cxl_memdev_pmem_attribute_group);
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(cxl_memdev_update_perf, CXL);
|
||||
|
||||
static const struct device_type cxl_memdev_type = {
|
||||
.name = "cxl_memdev",
|
||||
.release = cxl_memdev_release,
|
||||
|
@ -880,6 +880,8 @@ void cxl_switch_parse_cdat(struct cxl_port *port);
|
||||
int cxl_endpoint_get_perf_coordinates(struct cxl_port *port,
|
||||
struct access_coordinate *coord);
|
||||
|
||||
void cxl_memdev_update_perf(struct cxl_memdev *cxlmd);
|
||||
|
||||
/*
|
||||
* Unit test builds overrides this to __weak, find the 'strong' version
|
||||
* of these symbols in tools/testing/cxl/.
|
||||
|
@ -215,32 +215,6 @@ static ssize_t trigger_poison_list_store(struct device *dev,
|
||||
}
|
||||
static DEVICE_ATTR_WO(trigger_poison_list);
|
||||
|
||||
static ssize_t ram_qos_class_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
|
||||
struct cxl_dev_state *cxlds = cxlmd->cxlds;
|
||||
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlds);
|
||||
|
||||
return sysfs_emit(buf, "%d\n", mds->ram_perf.qos_class);
|
||||
}
|
||||
|
||||
static struct device_attribute dev_attr_ram_qos_class =
|
||||
__ATTR(qos_class, 0444, ram_qos_class_show, NULL);
|
||||
|
||||
static ssize_t pmem_qos_class_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
|
||||
struct cxl_dev_state *cxlds = cxlmd->cxlds;
|
||||
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlds);
|
||||
|
||||
return sysfs_emit(buf, "%d\n", mds->pmem_perf.qos_class);
|
||||
}
|
||||
|
||||
static struct device_attribute dev_attr_pmem_qos_class =
|
||||
__ATTR(qos_class, 0444, pmem_qos_class_show, NULL);
|
||||
|
||||
static umode_t cxl_mem_visible(struct kobject *kobj, struct attribute *a, int n)
|
||||
{
|
||||
struct device *dev = kobj_to_dev(kobj);
|
||||
@ -252,21 +226,11 @@ static umode_t cxl_mem_visible(struct kobject *kobj, struct attribute *a, int n)
|
||||
mds->poison.enabled_cmds))
|
||||
return 0;
|
||||
|
||||
if (a == &dev_attr_pmem_qos_class.attr)
|
||||
if (mds->pmem_perf.qos_class == CXL_QOS_CLASS_INVALID)
|
||||
return 0;
|
||||
|
||||
if (a == &dev_attr_ram_qos_class.attr)
|
||||
if (mds->ram_perf.qos_class == CXL_QOS_CLASS_INVALID)
|
||||
return 0;
|
||||
|
||||
return a->mode;
|
||||
}
|
||||
|
||||
static struct attribute *cxl_mem_attrs[] = {
|
||||
&dev_attr_trigger_poison_list.attr,
|
||||
&dev_attr_ram_qos_class.attr,
|
||||
&dev_attr_pmem_qos_class.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user