diff mbox series

[v2,2/2] cxl: Add decoders_committed sysfs attribute to cxl_port

Message ID 169723270125.66903.9705024211129163971.stgit@djiang5-mobl3
State Superseded
Headers show
Series [v2,1/2] cxl: Add cxl_decoders_committed() helper | expand

Commit Message

Dave Jiang Oct. 13, 2023, 9:31 p.m. UTC
This attribute allows cxl-cli to determine whether there are decoders
committed to a memdev.  This is only a snapshot of the state, and
doesn't offer any protection or serialization against a concurrent
disable-region operation.

Suggested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>

---
v2:
- Use cxl_region_rwsem to protect reading of decoder info. (Dan)
---
 drivers/cxl/core/port.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Comments

Jim Harris Oct. 13, 2023, 10:57 p.m. UTC | #1
On Oct 13, 2023, at 2:31 PM, Dave Jiang <dave.jiang@intel.com> wrote:

This attribute allows cxl-cli to determine whether there are decoders
committed to a memdev.  This is only a snapshot of the state, and
doesn't offer any protection or serialization against a concurrent
disable-region operation.

Suggested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>

---
v2:
- Use cxl_region_rwsem to protect reading of decoder info. (Dan)
---
drivers/cxl/core/port.c |   25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)

diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index fd1cc307759f..a448e1439b68 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -534,8 +534,33 @@ static void cxl_port_release(struct device *dev)
kfree(port);
}

+static ssize_t decoders_committed_show(struct device *dev,
+       struct device_attribute *attr, char *buf)
+{
+ struct cxl_port *port = to_cxl_port(dev);
+ int rc;
+
+ down_read(&cxl_region_rwsem);
+ rc = sysfs_emit(buf, "%d\n", cxl_decoders_committed(port));
+ up_read(&cxl_region_rwsem);
+
+ return rc;
+}
+
+static DEVICE_ATTR_RO(decoders_committed);
+
+static struct attribute *cxl_port_attrs[] = {
+ &dev_attr_decoders_committed.attr,
+ NULL,
+};
+
+static struct attribute_group cxl_port_attribute_group = {
+ .attrs = cxl_port_attrs,
+};
+
static const struct attribute_group *cxl_port_attribute_groups[] = {
&cxl_base_attribute_group,
+ &cxl_port_attribute_group,
NULL,
};



Reviewed-by: Jim Harris <jim.harris@samsung.com<mailto:jim.harris@samsung.com>>
Jim Harris Oct. 16, 2023, 3:55 p.m. UTC | #2
> On Oct 13, 2023, at 2:31 PM, Dave Jiang <dave.jiang@intel.com> wrote:
> 
> This attribute allows cxl-cli to determine whether there are decoders
> committed to a memdev.  This is only a snapshot of the state, and
> doesn't offer any protection or serialization against a concurrent
> disable-region operation.
> 
> Suggested-by: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> 
> ---
> v2:
> - Use cxl_region_rwsem to protect reading of decoder info. (Dan)
> ---
> drivers/cxl/core/port.c |   25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index fd1cc307759f..a448e1439b68 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -534,8 +534,33 @@ static void cxl_port_release(struct device *dev)
> kfree(port);
> }
> 
> +static ssize_t decoders_committed_show(struct device *dev,
> +       struct device_attribute *attr, char *buf)
> +{
> + struct cxl_port *port = to_cxl_port(dev);
> + int rc;
> +
> + down_read(&cxl_region_rwsem);
> + rc = sysfs_emit(buf, "%d\n", cxl_decoders_committed(port));
> + up_read(&cxl_region_rwsem);
> +
> + return rc;
> +}
> +
> +static DEVICE_ATTR_RO(decoders_committed);
> +
> +static struct attribute *cxl_port_attrs[] = {
> + &dev_attr_decoders_committed.attr,
> + NULL,
> +};
> +
> +static struct attribute_group cxl_port_attribute_group = {
> + .attrs = cxl_port_attrs,
> +};
> +
> static const struct attribute_group *cxl_port_attribute_groups[] = {
> &cxl_base_attribute_group,
> + &cxl_port_attribute_group,
> NULL,
> };
> 
> 
> 
> 

Let’s try to send it correctly this time.

Reviewed-by: Jim Harris <jim.harris@samsung.com <mailto:jim.harris@samsung.com>>
Jim Harris Oct. 16, 2023, 4 p.m. UTC | #3
> On Oct 13, 2023, at 2:31 PM, Dave Jiang <dave.jiang@intel.com> wrote:
> 
> This attribute allows cxl-cli to determine whether there are decoders
> committed to a memdev.  This is only a snapshot of the state, and
> doesn't offer any protection or serialization against a concurrent
> disable-region operation.
> 
> Suggested-by: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> 
> ---
> v2:
> - Use cxl_region_rwsem to protect reading of decoder info. (Dan)
> ---
> drivers/cxl/core/port.c |   25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index fd1cc307759f..a448e1439b68 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -534,8 +534,33 @@ static void cxl_port_release(struct device *dev)
> kfree(port);
> }
> 
> +static ssize_t decoders_committed_show(struct device *dev,
> +       struct device_attribute *attr, char *buf)
> +{
> + struct cxl_port *port = to_cxl_port(dev);
> + int rc;
> +
> + down_read(&cxl_region_rwsem);
> + rc = sysfs_emit(buf, "%d\n", cxl_decoders_committed(port));
> + up_read(&cxl_region_rwsem);
> +
> + return rc;
> +}
> +
> +static DEVICE_ATTR_RO(decoders_committed);
> +
> +static struct attribute *cxl_port_attrs[] = {
> + &dev_attr_decoders_committed.attr,
> + NULL,
> +};
> +
> +static struct attribute_group cxl_port_attribute_group = {
> + .attrs = cxl_port_attrs,
> +};
> +
> static const struct attribute_group *cxl_port_attribute_groups[] = {
> &cxl_base_attribute_group,
> + &cxl_port_attribute_group,
> NULL,
> };
> 

Third time’s a charm?

Reviewed-by: Jim Harris <jim.harris@samsung.com>
diff mbox series

Patch

diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index fd1cc307759f..a448e1439b68 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -534,8 +534,33 @@  static void cxl_port_release(struct device *dev)
 	kfree(port);
 }
 
+static ssize_t decoders_committed_show(struct device *dev,
+				       struct device_attribute *attr, char *buf)
+{
+	struct cxl_port *port = to_cxl_port(dev);
+	int rc;
+
+	down_read(&cxl_region_rwsem);
+	rc = sysfs_emit(buf, "%d\n", cxl_decoders_committed(port));
+	up_read(&cxl_region_rwsem);
+
+	return rc;
+}
+
+static DEVICE_ATTR_RO(decoders_committed);
+
+static struct attribute *cxl_port_attrs[] = {
+	&dev_attr_decoders_committed.attr,
+	NULL,
+};
+
+static struct attribute_group cxl_port_attribute_group = {
+	.attrs = cxl_port_attrs,
+};
+
 static const struct attribute_group *cxl_port_attribute_groups[] = {
 	&cxl_base_attribute_group,
+	&cxl_port_attribute_group,
 	NULL,
 };