Skip to contentSkip to conversation

cxl/list: emit decoder locked status

PATCH Applied Alison Schofield 3 participants 9 messages Jul 31 – Oct 24 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Alison Schofield

author maintainer
#0 lore raw

PATCH 1/2 cxl/list: emit decoder locked status

A committed zero-sized HDM decoder reports size 0, so 'cxl list' renders it identically to an ordinary unconfigured decoder ("state":
"disabled"). The locked attribute that distinguishes firmware-committed decoders is not included in the JSON output.

The library already reads the decoder's locked attribute and exports cxl_decoder_is_locked(); it was simply never emitted. Add a "locked" field to the decoder JSON, following the emit-only-when-true idiom used by the capability flags so existing output is unchanged for the common unlocked case.

---
 cxl/json.c | 6 ++++++
 1 file changed, 6 insertions(+)
cxl/json.c +6 -0
index a92548828582..2214f7027d91 100644
@@ -870,6 +870,12 @@ struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder,
 			json_object_object_add(jdecoder, "state", jobj);
 	}
 
+	if (cxl_decoder_is_locked(decoder)) {
+		jobj = json_object_new_boolean(true);
+		if (jobj)
+			json_object_object_add(jdecoder, "locked", jobj);
+	}
+
 	if (cxl_port_is_endpoint(port)) {
 		enum cxl_decoder_mode mode = cxl_decoder_get_mode(decoder);
 
Signature · 1 line
2.37.3
author maintainer
#1 lore raw

PATCH 2/2 cxl/list: list locked zero-sized decoders

'cxl list' hides zero-sized decoders unless --idle is given, assuming they are unconfigured idle slots. That assumption does not hold for locked HDM decoders, which may legitimately report size 0 while being committed by firmware.

Do not suppress locked zero-sized decoders from the default listing. Combined with the "locked" field in the decoder JSON, they are visible and distinguishable from idle, unlocked slots that remain hidden without --idle.

---
 cxl/filter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
cxl/filter.c +2 -1
index 5d634d3b2512..e6d45ac7b9e6 100644
@@ -847,7 +847,8 @@ static void walk_decoders(struct cxl_port *port, struct cxl_filter_params *p,
 		if (!util_cxl_decoder_filter_by_region(decoder,
 						       p->region_filter))
 			goto walk_children;
-		if (!p->idle && cxl_decoder_get_size(decoder) == 0)
+		if (!p->idle && cxl_decoder_get_size(decoder) == 0 &&
+		    !cxl_decoder_is_locked(decoder))
 			continue;
 		jdecoder = util_cxl_decoder_to_json(decoder, flags);
 		if (!decoder) {
Signature · 1 line
2.37.3
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [ndctl PATCH 2/2] cxl/list: list locked zero-sized decoders

Quoted 11 lines · Alison Schofield

'cxl list' hides zero-sized decoders unless --idle is given, assuming they are unconfigured idle slots. That assumption does not hold for locked HDM decoders, which may legitimately report size 0 while being committed by firmware.

Do not suppress locked zero-sized decoders from the default listing. Combined with the "locked" field in the decoder JSON, they are visible and distinguishable from idle, unlocked slots that remain hidden without --idle.

Quoted 18 lines
---
 cxl/filter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
cxl/filter.c +2 -1
index 5d634d3b2512..e6d45ac7b9e6 100644
@@ -847,7 +847,8 @@ static void walk_decoders(struct cxl_port *port, struct cxl_filter_params *p,
 		if (!util_cxl_decoder_filter_by_region(decoder,
 						       p->region_filter))
 			goto walk_children;
-		if (!p->idle && cxl_decoder_get_size(decoder) == 0)
+		if (!p->idle && cxl_decoder_get_size(decoder) == 0 &&
+		    !cxl_decoder_is_locked(decoder))
 			continue;
 		jdecoder = util_cxl_decoder_to_json(decoder, flags);
 		if (!decoder) {
Reviewed-by
#3 lore raw

Re: [ndctl PATCH 2/2] cxl/list: list locked zero-sized decoders

Quoted 8 lines · Dave Jiang
Quoted 5 lines · Alison Schofield

'cxl list' hides zero-sized decoders unless --idle is given, assuming they are unconfigured idle slots. That assumption does not hold for locked HDM decoders, which may legitimately report size 0 while being committed by firmware.

Quoted 5 lines
Quoted 5 lines

Do not suppress locked zero-sized decoders from the default listing. Combined with the "locked" field in the decoder JSON, they are visible and distinguishable from idle, unlocked slots that remain hidden without --idle.

Hi Alison,

patch looks good to me, just one small question,
what if the zero size decoder is programmed by userspace, not from FW.

in which case cxl_decoder_is_locked() won't return true, can we handle that situation ?

Best regards,
Richard Cheng.

Quoted 23 lines
Quoted 1 line
Quoted 18 lines
---
 cxl/filter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
cxl/filter.c +2 -1
index 5d634d3b2512..e6d45ac7b9e6 100644
@@ -847,7 +847,8 @@ static void walk_decoders(struct cxl_port *port, struct cxl_filter_params *p,
 		if (!util_cxl_decoder_filter_by_region(decoder,
 						       p->region_filter))
 			goto walk_children;
-		if (!p->idle && cxl_decoder_get_size(decoder) == 0)
+		if (!p->idle && cxl_decoder_get_size(decoder) == 0 &&
+		    !cxl_decoder_is_locked(decoder))
 			continue;
 		jdecoder = util_cxl_decoder_to_json(decoder, flags);
 		if (!decoder) {
author maintainer
#4 lore raw

Re: [ndctl PATCH 2/2] cxl/list: list locked zero-sized decoders

Quoted 15 lines · Richard Cheng
Quoted 8 lines · Dave Jiang
Quoted 5 lines · Alison Schofield

'cxl list' hides zero-sized decoders unless --idle is given, assuming they are unconfigured idle slots. That assumption does not hold for locked HDM decoders, which may legitimately report size 0 while being committed by firmware.

Quoted 5 lines
Quoted 5 lines

Do not suppress locked zero-sized decoders from the default listing. Combined with the "locked" field in the decoder JSON, they are visible and distinguishable from idle, unlocked slots that remain hidden without --idle.

Quoted 4 lines

Hi Alison,

patch looks good to me, just one small question,
what if the zero size decoder is programmed by userspace, not from FW.

I don't see a path to that happening. Userspace can't commit a zero-size decoder. Writing 0 to dpa_size just frees the allocation, and region attach rejects empty decoders, so a committed zero-size decoder can only come from firmware.

Quoted 3 lines

in which case cxl_decoder_is_locked() won't return true, can we handle that situation ?

More generally, an unlocked committed zero-size decoder looks identical to an idle slot in sysfs, so telling them apart would need a new kernel attribute.

I'm going to merge these patches as is, and as we discover new flavors and ways to list them we can add on.

Thanks for the reviews!

-- Alison

Quoted 28 lines

Best regards,
Richard Cheng.

Quoted 23 lines
Quoted 1 line
Quoted 18 lines
---
 cxl/filter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
cxl/filter.c +2 -1
index 5d634d3b2512..e6d45ac7b9e6 100644
@@ -847,7 +847,8 @@ static void walk_decoders(struct cxl_port *port, struct cxl_filter_params *p,
 		if (!util_cxl_decoder_filter_by_region(decoder,
 						       p->region_filter))
 			goto walk_children;
-		if (!p->idle && cxl_decoder_get_size(decoder) == 0)
+		if (!p->idle && cxl_decoder_get_size(decoder) == 0 &&
+		    !cxl_decoder_is_locked(decoder))
 			continue;
 		jdecoder = util_cxl_decoder_to_json(decoder, flags);
 		if (!decoder) {
author maintainer Applied
#5 lore raw

Re: [ndctl PATCH 2/2] cxl/list: list locked zero-sized decoders

In reply to Alison Schofield
Quoted 9 lines · Alison Schofield

'cxl list' hides zero-sized decoders unless --idle is given, assuming they are unconfigured idle slots. That assumption does not hold for locked HDM decoders, which may legitimately report size 0 while being committed by firmware.

Do not suppress locked zero-sized decoders from the default listing. Combined with the "locked" field in the decoder JSON, they are visible and distinguishable from idle, unlocked slots that remain hidden without --idle.

Applied to pending for NDCTL v86
https://github.com/pmem/ndctl/commit/e252f4cc0792

Quoted 23 lines
---
 cxl/filter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
cxl/filter.c +2 -1
index 5d634d3b2512..e6d45ac7b9e6 100644
@@ -847,7 +847,8 @@ static void walk_decoders(struct cxl_port *port, struct cxl_filter_params *p,
 		if (!util_cxl_decoder_filter_by_region(decoder,
 						       p->region_filter))
 			goto walk_children;
-		if (!p->idle && cxl_decoder_get_size(decoder) == 0)
+		if (!p->idle && cxl_decoder_get_size(decoder) == 0 &&
+		    !cxl_decoder_is_locked(decoder))
 			continue;
 		jdecoder = util_cxl_decoder_to_json(decoder, flags);
 		if (!decoder) {
Signature · 1 line
2.37.3
maintainer Reviewed-by on v1 1/2
#6 lore raw
In reply to Alison Schofield
Quoted 5 lines · Alison Schofield

A committed zero-sized HDM decoder reports size 0, so 'cxl list' renders it identically to an ordinary unconfigured decoder ("state":
"disabled"). The locked attribute that distinguishes firmware-committed decoders is not included in the JSON output.

Quoted 7 lines

The library already reads the decoder's locked attribute and exports cxl_decoder_is_locked(); it was simply never emitted. Add a "locked" field to the decoder JSON, following the emit-only-when-true idiom used by the capability flags so existing output is unchanged for the common unlocked case.

Quoted 21 lines
---
 cxl/json.c | 6 ++++++
 1 file changed, 6 insertions(+)
cxl/json.c +6 -0
index a92548828582..2214f7027d91 100644
@@ -870,6 +870,12 @@ struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder,
 			json_object_object_add(jdecoder, "state", jobj);
 	}
 
+	if (cxl_decoder_is_locked(decoder)) {
+		jobj = json_object_new_boolean(true);
+		if (jobj)
+			json_object_object_add(jdecoder, "locked", jobj);
+	}
+
 	if (cxl_port_is_endpoint(port)) {
 		enum cxl_decoder_mode mode = cxl_decoder_get_mode(decoder);
 
Reviewed-by
#7 lore raw
Quoted 14 lines · Dave Jiang
Quoted 11 lines · Alison Schofield

A committed zero-sized HDM decoder reports size 0, so 'cxl list' renders it identically to an ordinary unconfigured decoder ("state":
"disabled"). The locked attribute that distinguishes firmware-committed decoders is not included in the JSON output.

The library already reads the decoder's locked attribute and exports cxl_decoder_is_locked(); it was simply never emitted. Add a "locked" field to the decoder JSON, following the emit-only-when-true idiom used by the capability flags so existing output is unchanged for the common unlocked case.

Quoted 4 lines
Quoted 1 line

Thanks alot !

Best regards,
Richard Cheng.

Quoted 22 lines
Quoted 21 lines
---
 cxl/json.c | 6 ++++++
 1 file changed, 6 insertions(+)
cxl/json.c +6 -0
index a92548828582..2214f7027d91 100644
@@ -870,6 +870,12 @@ struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder,
 			json_object_object_add(jdecoder, "state", jobj);
 	}
 
+	if (cxl_decoder_is_locked(decoder)) {
+		jobj = json_object_new_boolean(true);
+		if (jobj)
+			json_object_object_add(jdecoder, "locked", jobj);
+	}
+
 	if (cxl_port_is_endpoint(port)) {
 		enum cxl_decoder_mode mode = cxl_decoder_get_mode(decoder);
 
author maintainer Applied
#8 lore raw
In reply to Alison Schofield
Quoted 10 lines · Alison Schofield

A committed zero-sized HDM decoder reports size 0, so 'cxl list' renders it identically to an ordinary unconfigured decoder ("state":
"disabled"). The locked attribute that distinguishes firmware-committed decoders is not included in the JSON output.

The library already reads the decoder's locked attribute and exports cxl_decoder_is_locked(); it was simply never emitted. Add a "locked" field to the decoder JSON, following the emit-only-when-true idiom used by the capability flags so existing output is unchanged for the common unlocked case.

Applied to pending for NDCTL v86
https://github.com/pmem/ndctl/commit/007acdd87f15

Quoted 26 lines
---
 cxl/json.c | 6 ++++++
 1 file changed, 6 insertions(+)
cxl/json.c +6 -0
index a92548828582..2214f7027d91 100644
@@ -870,6 +870,12 @@ struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder,
 			json_object_object_add(jdecoder, "state", jobj);
 	}
 
+	if (cxl_decoder_is_locked(decoder)) {
+		jobj = json_object_new_boolean(true);
+		if (jobj)
+			json_object_object_add(jdecoder, "locked", jobj);
+	}
+
 	if (cxl_port_is_endpoint(port)) {
 		enum cxl_decoder_mode mode = cxl_decoder_get_mode(decoder);
 
Signature · 1 line
2.37.3