On Thu, 26 Jun 2025 22:23:32 +0000 anisa.su...@gmail.com wrote: > From: Anisa Su <anisa...@samsung.com> > > FM DCD Management command 0x5604 implemented per CXL r3.2 Spec Section > 7.6.7.6.5
There are a few long lines in here check patch doesn't like. I tweaked as described inline whilst picking them up. > > Signed-off-by: Anisa Su <anisa...@samsung.com> > --- > hw/cxl/cxl-mailbox-utils.c | 106 ++++++++++++++++++++++++++++++++++++ > hw/mem/cxl_type3.c | 8 +-- > include/hw/cxl/cxl_device.h | 4 ++ > 3 files changed, 114 insertions(+), 4 deletions(-) > > diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c > index 382c41c025..787eeaa7b9 100644 > --- a/hw/cxl/cxl-mailbox-utils.c > +++ b/hw/cxl/cxl-mailbox-utils.c > +/* CXL r3.2 Section 7.6.7.6.5 Initiate Dynamic Capacity Add (Opcode 5604h) */ > +static CXLRetCode cmd_fm_initiate_dc_add(const struct cxl_cmd *cmd, > + uint8_t *payload_in, > + size_t len_in, > + uint8_t *payload_out, > + size_t *len_out, > + CXLCCI *cci) > +{ > + struct { > + uint16_t host_id; > + uint8_t selection_policy; > + uint8_t reg_num; > + uint64_t length; > + uint8_t tag[0x10]; > + uint32_t ext_count; > + CXLDCExtentRaw extents[]; > + } QEMU_PACKED *in = (void *)payload_in; > + CXLType3Dev *ct3d = CXL_TYPE3(cci->d); > + int i, rc; > + > + switch (in->selection_policy) { > + case CXL_EXTENT_SELECTION_POLICY_PRESCRIPTIVE: { > + /* Adding extents exceeds device's extent tracking ability. */ > + if (in->ext_count + ct3d->dc.total_extent_count > > + CXL_NUM_EXTENTS_SUPPORTED) { > + return CXL_MBOX_RESOURCES_EXHAUSTED; > + } > + > + g_autofree CXLUpdateDCExtentListInPl *list = > + g_malloc0(sizeof(*list) + > + in->ext_count * sizeof(*list->updated_entries)); > + > + convert_raw_extents(in->extents, list, in->ext_count); > + rc = cxl_detect_malformed_extent_list(ct3d, list); > + > + for (i = 0; i < in->ext_count; i++) { > + CXLDCExtentRaw ext = in->extents[i]; Using a pointer here avoids copying data for no particular reason. > + /* Check requested extents do not overlap with pending > extents. */ This is a touch long. I tweaked to end with ... pending ones. Given we are talking extents that should be clear. > + if > (cxl_extent_groups_overlaps_dpa_range(&ct3d->dc.extents_pending, This is the one case I'll leave as it is not nice to wrap it anywhere different. > + ext.start_dpa, > ext.len)) { wrapped this > + return CXL_MBOX_INVALID_EXTENT_LIST; > + } > + /* Check requested extents do not overlap with existing > extents. */ exiting ones. */ > + if (cxl_extents_overlaps_dpa_range(&ct3d->dc.extents, > + ext.start_dpa, ext.len)) { Wrapped this. > + return CXL_MBOX_INVALID_EXTENT_LIST; > + } > + } > + > + if (rc) { > + return rc; > + } > + > + CXLDCExtentGroup *group = NULL; > + for (i = 0; i < in->ext_count; i++) { Used CXLDCExtentRaw *ext = &in->extents[i]; > + group = cxl_insert_extent_to_extent_group(group, > + > in->extents[i].start_dpa, To shorten all these (similar to previous loop) > + in->extents[i].len, > + in->extents[i].tag, > + > in->extents[i].shared_seq); > + } > + > + cxl_extent_group_list_insert_tail(&ct3d->dc.extents_pending, > group); > + ct3d->dc.total_extent_count += in->ext_count; > + cxl_create_dc_event_records_for_extents(ct3d, > + DC_EVENT_ADD_CAPACITY, > + in->extents, > + in->ext_count); > + > + return CXL_MBOX_SUCCESS; > + } > + default: { > + qemu_log_mask(LOG_UNIMP, > + "CXL extent selection policy not supported.\n"); > + return CXL_MBOX_INVALID_INPUT; > + } > + } > +}