All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Anisa Su <anisa.su887@gmail.com>
Cc: ALOK TIWARI <alok.a.tiwari@oracle.com>, <qemu-devel@nongnu.org>,
	<nifan.cxl@gmail.com>, <dave@stgolabs.net>,
	<linux-cxl@vger.kernel.org>
Subject: Re: [QEMU PATCH v3 8/9] cxl-mailbox-utils: 0x5604 - FMAPI Initiate DC Add
Date: Tue, 10 Jun 2025 16:17:09 +0100	[thread overview]
Message-ID: <20250610161709.000059f7@huawei.com> (raw)
In-Reply-To: <aEMly5F8kdziHWzO@deb-101020-bm01.eng.stellus.in>


> > > +/* 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);
> > > +    CXLUpdateDCExtentListInPl *list;
> > > +    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;
> > > +        }
> > > +
> > > +        list = calloc(1, (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];
> > > +             /* Check requested extents do not overlap with pending extents. */
> > > +            if (cxl_extent_groups_overlaps_dpa_range(&ct3d->dc.extents_pending,
> > > +                                                     ext.start_dpa, ext.len)) {
> > > +                return CXL_MBOX_INVALID_EXTENT_LIST;
> > > +            }
> > > +            /* Check requested extents do not overlap with existing extents. */
> > > +            if (cxl_extents_overlaps_dpa_range(&ct3d->dc.extents,
> > > +                                               ext.start_dpa, ext.len)) {
> > > +                return CXL_MBOX_INVALID_EXTENT_LIST;
> > > +            }
> > > +        }
> > > +
> > > +        if (rc) {
> > > +            return rc;  
> > 
> > is list free not require ?
> >   
> oh yeah it's definitely required :( that was dumb of me, same for the
> next patch.

Use a g_autofree marking for this probably given it is just
a local temp array I think.

> 
> Thanks for catching that!
> -Anisa
> > > +        }
> > > +
> > > +        cxl_mbox_dc_add_to_pending(ct3d, in->ext_count, in->extents);
> > > +        cxl_mbox_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;
> > > +    }
> > > +
> > > +    return CXL_MBOX_SUCCESS;  
> > 
> > CXL_MBOX_SUCCESS, this is unreachable
> >   
> > > +}
> > > +
> > >   static const struct cxl_cmd cxl_cmd_set[256][256] = {
> > >       [INFOSTAT][BACKGROUND_OPERATION_ABORT] = { "BACKGROUND_OPERATION_ABORT",
> > >           cmd_infostat_bg_op_abort, 0, 0 },
> > > @@ -3667,6 +3812,13 @@ static const struct cxl_cmd cxl_cmd_set_fm_dcd[256][256] = {
> > >            CXL_MBOX_IMMEDIATE_DATA_CHANGE) },
> > >       [FMAPI_DCD_MGMT][GET_DC_REGION_EXTENT_LIST] = { "GET_DC_REGION_EXTENT_LIST",
> > >           cmd_fm_get_dc_region_extent_list, 12, 0 },
> > > +    [FMAPI_DCD_MGMT][INITIATE_DC_ADD] = { "INIT_DC_ADD",
> > > +        cmd_fm_initiate_dc_add, ~0,
> > > +        (CXL_MBOX_CONFIG_CHANGE_COLD_RESET |
> > > +        CXL_MBOX_CONFIG_CHANGE_CONV_RESET |
> > > +        CXL_MBOX_CONFIG_CHANGE_CXL_RESET |
> > > +        CXL_MBOX_IMMEDIATE_CONFIG_CHANGE |
> > > +        CXL_MBOX_IMMEDIATE_DATA_CHANGE) },
> > >   };  
> > 
> > 
> > Thanks,
> > Alok  


WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron via <qemu-devel@nongnu.org>
To: Anisa Su <anisa.su887@gmail.com>
Cc: ALOK TIWARI <alok.a.tiwari@oracle.com>, <qemu-devel@nongnu.org>,
	<nifan.cxl@gmail.com>, <dave@stgolabs.net>,
	<linux-cxl@vger.kernel.org>
Subject: Re: [QEMU PATCH v3 8/9] cxl-mailbox-utils: 0x5604 - FMAPI Initiate DC Add
Date: Tue, 10 Jun 2025 16:17:09 +0100	[thread overview]
Message-ID: <20250610161709.000059f7@huawei.com> (raw)
In-Reply-To: <aEMly5F8kdziHWzO@deb-101020-bm01.eng.stellus.in>


> > > +/* 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);
> > > +    CXLUpdateDCExtentListInPl *list;
> > > +    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;
> > > +        }
> > > +
> > > +        list = calloc(1, (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];
> > > +             /* Check requested extents do not overlap with pending extents. */
> > > +            if (cxl_extent_groups_overlaps_dpa_range(&ct3d->dc.extents_pending,
> > > +                                                     ext.start_dpa, ext.len)) {
> > > +                return CXL_MBOX_INVALID_EXTENT_LIST;
> > > +            }
> > > +            /* Check requested extents do not overlap with existing extents. */
> > > +            if (cxl_extents_overlaps_dpa_range(&ct3d->dc.extents,
> > > +                                               ext.start_dpa, ext.len)) {
> > > +                return CXL_MBOX_INVALID_EXTENT_LIST;
> > > +            }
> > > +        }
> > > +
> > > +        if (rc) {
> > > +            return rc;  
> > 
> > is list free not require ?
> >   
> oh yeah it's definitely required :( that was dumb of me, same for the
> next patch.

Use a g_autofree marking for this probably given it is just
a local temp array I think.

> 
> Thanks for catching that!
> -Anisa
> > > +        }
> > > +
> > > +        cxl_mbox_dc_add_to_pending(ct3d, in->ext_count, in->extents);
> > > +        cxl_mbox_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;
> > > +    }
> > > +
> > > +    return CXL_MBOX_SUCCESS;  
> > 
> > CXL_MBOX_SUCCESS, this is unreachable
> >   
> > > +}
> > > +
> > >   static const struct cxl_cmd cxl_cmd_set[256][256] = {
> > >       [INFOSTAT][BACKGROUND_OPERATION_ABORT] = { "BACKGROUND_OPERATION_ABORT",
> > >           cmd_infostat_bg_op_abort, 0, 0 },
> > > @@ -3667,6 +3812,13 @@ static const struct cxl_cmd cxl_cmd_set_fm_dcd[256][256] = {
> > >            CXL_MBOX_IMMEDIATE_DATA_CHANGE) },
> > >       [FMAPI_DCD_MGMT][GET_DC_REGION_EXTENT_LIST] = { "GET_DC_REGION_EXTENT_LIST",
> > >           cmd_fm_get_dc_region_extent_list, 12, 0 },
> > > +    [FMAPI_DCD_MGMT][INITIATE_DC_ADD] = { "INIT_DC_ADD",
> > > +        cmd_fm_initiate_dc_add, ~0,
> > > +        (CXL_MBOX_CONFIG_CHANGE_COLD_RESET |
> > > +        CXL_MBOX_CONFIG_CHANGE_CONV_RESET |
> > > +        CXL_MBOX_CONFIG_CHANGE_CXL_RESET |
> > > +        CXL_MBOX_IMMEDIATE_CONFIG_CHANGE |
> > > +        CXL_MBOX_IMMEDIATE_DATA_CHANGE) },
> > >   };  
> > 
> > 
> > Thanks,
> > Alok  



  reply	other threads:[~2025-06-10 15:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-05 23:42 [QEMU PATCH v3 0/9] CXL: FMAPI DCD Management Commands 0x5600-0x5605 anisa.su887
2025-06-05 23:42 ` [QEMU PATCH v3 1/9] cxl-mailbox-utils: 0x5600 - FMAPI Get DCD Info anisa.su887
2025-06-05 23:42 ` [QEMU PATCH v3 2/9] cxl/type3: Add dsmas_flags to CXLDCRegion struct anisa.su887
2025-06-05 23:42 ` [QEMU PATCH v3 3/9] cxl-mailbox-utils: 0x5601 - FMAPI Get Host Region Config anisa.su887
2025-06-05 23:42 ` [QEMU PATCH v3 4/9] cxl_events.h: Move definition for dynamic_capacity_uuid and enum for DC event types anisa.su887
2025-06-05 23:42 ` [QEMU PATCH v3 5/9] hw/cxl_type3: Add DC Region bitmap lock anisa.su887
2025-06-05 23:42 ` [QEMU PATCH v3 6/9] cxl-mailbox-utils: 0x5602 - FMAPI Set DC Region Config anisa.su887
2025-06-06 16:27   ` Fan Ni
2025-06-10 15:09     ` Jonathan Cameron
2025-06-10 15:09       ` Jonathan Cameron via
2025-06-05 23:42 ` [QEMU PATCH v3 7/9] cxl-mailbox-utils: 0x5603 - FMAPI Get DC Region Extent Lists anisa.su887
2025-06-05 23:42 ` [QEMU PATCH v3 8/9] cxl-mailbox-utils: 0x5604 - FMAPI Initiate DC Add anisa.su887
2025-06-06 12:42   ` ALOK TIWARI
2025-06-06 17:30     ` Anisa Su
2025-06-10 15:17       ` Jonathan Cameron [this message]
2025-06-10 15:17         ` Jonathan Cameron via
2025-06-06 18:21   ` Fan Ni
2025-06-10 15:26     ` Jonathan Cameron
2025-06-10 15:26       ` Jonathan Cameron via
2025-06-05 23:42 ` [QEMU PATCH v3 9/9] cxl-mailbox-utils: 0x5605 - FMAPI Initiate DC Release anisa.su887
2025-06-06 12:55   ` ALOK TIWARI
2025-06-06 18:43   ` Fan Ni
2025-06-06 18:48     ` Fan Ni
2025-06-06 19:37       ` Anisa Su

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250610161709.000059f7@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=alok.a.tiwari@oracle.com \
    --cc=anisa.su887@gmail.com \
    --cc=dave@stgolabs.net \
    --cc=linux-cxl@vger.kernel.org \
    --cc=nifan.cxl@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.