cxl/list: emit decoder locked status
Alison Schofield
maintainerPATCH 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
@@ -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
Alison Schofield
maintainerPATCH 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
@@ -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
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.
Signed-off-by Alison Schofield <[email protected]>
Quoted 18 lines
--- cxl/filter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)cxl/filter.c +2
-1@@ -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) {
Richard Cheng
Reviewed-byRe: [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
Signed-off-by Alison Schofield <[email protected]>Reviewed-by Dave Jiang <[email protected]>Quoted 18 lines
--- cxl/filter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)cxl/filter.c +2
-1@@ -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) {
Alison Schofield
maintainerRe: [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
Reviewed-by Richard Cheng <[email protected]>Best regards,
Richard Cheng.Quoted 23 lines
Quoted 1 line
Signed-off-by Alison Schofield <[email protected]>Reviewed-by Dave Jiang <[email protected]>Quoted 18 lines
--- cxl/filter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)cxl/filter.c +2
-1@@ -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) {
Re: [ndctl PATCH 2/2] cxl/list: list locked zero-sized decoders
In reply to Alison SchofieldQuoted 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
Signed-off-by Alison Schofield <[email protected]>--- cxl/filter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)cxl/filter.c +2
-1@@ -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
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.Signed-off-by Alison Schofield <[email protected]>
Quoted 21 lines
--- cxl/json.c | 6 ++++++ 1 file changed, 6 insertions(+)cxl/json.c +6
-0@@ -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);
Richard Cheng
Reviewed-byQuoted 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
Signed-off-by Alison Schofield <[email protected]>Reviewed-by Dave Jiang <[email protected]>
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@@ -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);
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
Signed-off-by Alison Schofield <[email protected]>--- cxl/json.c | 6 ++++++ 1 file changed, 6 insertions(+)cxl/json.c +6
-0@@ -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