Per CXL 4.0 Table 8-331, the Discovery operation "returns a list of
all Media Operations that the device supports, with the exception of
the Discovery operation (Class=0, Subclass=0)."
Filter out Discovery entries when building the output list and adjust
total_supported_operations accordingly.
Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
---
hw/cxl/cxl-mailbox-utils.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
index 71a012121c87..6932db963788 100644
--- a/hw/cxl/cxl-mailbox-utils.c
+++ b/hw/cxl/cxl-mailbox-utils.c
@@ -2593,7 +2593,7 @@ static CXLRetCode media_operations_discovery(uint8_t *payload_in,
} QEMU_PACKED *media_op_in_disc_pl = (void *)payload_in;
struct media_op_discovery_out_pl *media_out_pl =
(struct media_op_discovery_out_pl *)payload_out;
- int total = ARRAY_SIZE(media_op_matrix);
+ int total = ARRAY_SIZE(media_op_matrix) - 1; /* exclude Discovery */
int num_ops, start_index, i;
int count = 0;
@@ -2619,10 +2619,12 @@ static CXLRetCode media_operations_discovery(uint8_t *payload_in,
num_ops = MIN(num_ops, total - start_index);
for (i = 0; i < num_ops; i++) {
+ int idx = start_index + i + 1; /* skip Discovery (first entry) */
+
media_out_pl->entry[count].media_op_class =
- media_op_matrix[start_index + i].media_op_class;
+ media_op_matrix[idx].media_op_class;
media_out_pl->entry[count].media_op_subclass =
- media_op_matrix[start_index + i].media_op_subclass;
+ media_op_matrix[idx].media_op_subclass;
count++;
}
--
2.39.5
On Wed, 18 Mar 2026 11:55:08 -0700
Davidlohr Bueso <dave@stgolabs.net> wrote:
> Per CXL 4.0 Table 8-331, the Discovery operation "returns a list of
> all Media Operations that the device supports, with the exception of
> the Discovery operation (Class=0, Subclass=0)."
>
> Filter out Discovery entries when building the output list and adjust
> total_supported_operations accordingly.
>
> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
Both could do with a fixes tag.
> ---
> hw/cxl/cxl-mailbox-utils.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
> index 71a012121c87..6932db963788 100644
> --- a/hw/cxl/cxl-mailbox-utils.c
> +++ b/hw/cxl/cxl-mailbox-utils.c
> @@ -2593,7 +2593,7 @@ static CXLRetCode media_operations_discovery(uint8_t *payload_in,
> } QEMU_PACKED *media_op_in_disc_pl = (void *)payload_in;
> struct media_op_discovery_out_pl *media_out_pl =
> (struct media_op_discovery_out_pl *)payload_out;
> - int total = ARRAY_SIZE(media_op_matrix);
> + int total = ARRAY_SIZE(media_op_matrix) - 1; /* exclude Discovery */
> int num_ops, start_index, i;
> int count = 0;
>
> @@ -2619,10 +2619,12 @@ static CXLRetCode media_operations_discovery(uint8_t *payload_in,
>
> num_ops = MIN(num_ops, total - start_index);
> for (i = 0; i < num_ops; i++) {
> + int idx = start_index + i + 1; /* skip Discovery (first entry) */
> +
> media_out_pl->entry[count].media_op_class =
> - media_op_matrix[start_index + i].media_op_class;
> + media_op_matrix[idx].media_op_class;
> media_out_pl->entry[count].media_op_subclass =
> - media_op_matrix[start_index + i].media_op_subclass;
> + media_op_matrix[idx].media_op_subclass;
Indent comment follows through.
Otherwise LGTM.
I'll queue it up locally but if you want to send a new version and with mst@redhat.com
in the to, given it's fixes and where we are in the cycle they may get picked up sooner.
If you do that,
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
for both patches
Whilst I don't think anything else I have queued touches this code, make sure
you base on upstream qemu.
Thanks,
Jonathan
> count++;
> }
>
© 2016 - 2026 Red Hat, Inc.