From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D86A28C2B3 for ; Mon, 30 Jun 2025 17:06:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751303209; cv=none; b=g464gP/yHxiCVFTRWUysKxlePKXyrJIQyQRYjMJn0sGcv+pxR/DLD8bTKaZ2Xss7G9SoJqW+9/wNmRNIZ4PIoF0u+A9wwY0BSXLKm37czyc2x1MVQTZyeKOFusyM6JSx33EMqr7f50O9gy0775DwAMLDQYbBM5UZVJi217kV4P4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751303209; c=relaxed/simple; bh=NRovVznRHz6NX1kMr8bjZkOcuM4gCS9Fk7EaOvfc0wo=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WH3sudo50/v3zNJvl1GEbmoJjRspEe6Mq4EqYHBSOyxKrH9Yyuybm/CIDFl99S/kde09thVnn3viKhbjY4vzomuYeRgBbqDsQStzYIrcImAC0w4UcTCdcuGM1QKPv+fSoPXglxOUsIAP2ytbKAlxyMB9EjLHQN7FRXFjqiT6R4M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4bWCDV0hZxz6L5Qs; Tue, 1 Jul 2025 01:03:54 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id 2479A1402FC; Tue, 1 Jul 2025 01:06:42 +0800 (CST) Received: from localhost (10.122.19.247) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 30 Jun 2025 19:06:41 +0200 Date: Mon, 30 Jun 2025 18:06:40 +0100 From: Jonathan Cameron To: CC: , , , , , Anisa Su Subject: Re: [QEMU PATCH v4 10/10] cxl-mailbox-utils: 0x5605 - FMAPI Initiate DC Release Message-ID: <20250630180640.00001fad@huawei.com> In-Reply-To: <20250626222743.1766404-11-anisa.su887@gmail.com> References: <20250626222743.1766404-1-anisa.su887@gmail.com> <20250626222743.1766404-11-anisa.su887@gmail.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml500010.china.huawei.com (7.191.174.240) To frapeml500008.china.huawei.com (7.182.85.71) On Thu, 26 Jun 2025 22:23:33 +0000 anisa.su887@gmail.com wrote: > From: Anisa Su > > FM DCD Management command 0x5605 implemented per CXL r3.2 Spec Section 7.6.7.6.6 > > Signed-off-by: Anisa Su A few more long line related tweaks. > --- > hw/cxl/cxl-mailbox-utils.c | 79 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 79 insertions(+) > > diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c > index 787eeaa7b9..87f9535d46 100644 > --- a/hw/cxl/cxl-mailbox-utils.c > +++ b/hw/cxl/cxl-mailbox-utils.c > @@ -123,6 +123,7 @@ enum { > #define SET_DC_REGION_CONFIG 0x2 > #define GET_DC_REGION_EXTENT_LIST 0x3 > #define INITIATE_DC_ADD 0x4 > + #define INITIATE_DC_RELEASE 0x5 > }; > > /* CCI Message Format CXL r3.1 Figure 7-19 */ > @@ -3638,6 +3639,77 @@ static CXLRetCode cmd_fm_initiate_dc_add(const struct cxl_cmd *cmd, > } > } > > +#define CXL_EXTENT_REMOVAL_POLICY_MASK 0x0F > +#define CXL_FORCED_REMOVAL_MASK (1 << 4) > +/* CXL r3.2 Section 7.6.7.6.6 Initiate Dynamic Capacity Release (Opcode 5605h) */ Added a colon and wrapped after the number. > +static CXLRetCode cmd_fm_initiate_dc_release(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 flags; > + 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->flags & CXL_EXTENT_REMOVAL_POLICY_MASK) { > + case CXL_EXTENT_REMOVAL_POLICY_PRESCRIPTIVE: { > + CXLDCExtentList updated_list; > + uint32_t updated_list_size; > + 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); > + if (rc) { > + return rc; > + } > + > + /* Fail with Invalid PA if an extent is pending and Forced Removal /* * Fail... > + * flag not set > + */ > + if (!(in->flags & CXL_FORCED_REMOVAL_MASK)) { > + for (i = 0; i < in->ext_count; i++) { > + CXLDCExtentRaw ext = in->extents[i]; > + /* Check requested extents don't overlap with pending extents. */ Made this a multiline comment. > + if (cxl_extent_groups_overlaps_dpa_range(&ct3d->dc.extents_pending, This is quite a bit too far over so I just went with the ugly if (cxl_extent_groups_overlaps_dpa_range( &ct3d->dc.extents_pending, > + ext.start_dpa, ext.len)) { > + return CXL_MBOX_INVALID_PA; From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AAD1AC8302D for ; Mon, 30 Jun 2025 17:07:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uWHy3-000603-Tj; Mon, 30 Jun 2025 13:06:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uWHxx-0005zW-S4 for qemu-devel@nongnu.org; Mon, 30 Jun 2025 13:06:50 -0400 Received: from [185.176.79.56] (helo=frasgout.his.huawei.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uWHxw-0002cU-2C for qemu-devel@nongnu.org; Mon, 30 Jun 2025 13:06:49 -0400 Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4bWCDV0hZxz6L5Qs; Tue, 1 Jul 2025 01:03:54 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id 2479A1402FC; Tue, 1 Jul 2025 01:06:42 +0800 (CST) Received: from localhost (10.122.19.247) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 30 Jun 2025 19:06:41 +0200 Date: Mon, 30 Jun 2025 18:06:40 +0100 To: CC: , , , , , Anisa Su Subject: Re: [QEMU PATCH v4 10/10] cxl-mailbox-utils: 0x5605 - FMAPI Initiate DC Release Message-ID: <20250630180640.00001fad@huawei.com> In-Reply-To: <20250626222743.1766404-11-anisa.su887@gmail.com> References: <20250626222743.1766404-1-anisa.su887@gmail.com> <20250626222743.1766404-11-anisa.su887@gmail.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.122.19.247] X-ClientProxiedBy: lhrpeml500010.china.huawei.com (7.191.174.240) To frapeml500008.china.huawei.com (7.182.85.71) X-Host-Lookup-Failed: Reverse DNS lookup failed for 185.176.79.56 (deferred) Received-SPF: pass client-ip=185.176.79.56; envelope-from=jonathan.cameron@huawei.com; helo=frasgout.his.huawei.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.237, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Jonathan Cameron From: Jonathan Cameron via Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On Thu, 26 Jun 2025 22:23:33 +0000 anisa.su887@gmail.com wrote: > From: Anisa Su > > FM DCD Management command 0x5605 implemented per CXL r3.2 Spec Section 7.6.7.6.6 > > Signed-off-by: Anisa Su A few more long line related tweaks. > --- > hw/cxl/cxl-mailbox-utils.c | 79 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 79 insertions(+) > > diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c > index 787eeaa7b9..87f9535d46 100644 > --- a/hw/cxl/cxl-mailbox-utils.c > +++ b/hw/cxl/cxl-mailbox-utils.c > @@ -123,6 +123,7 @@ enum { > #define SET_DC_REGION_CONFIG 0x2 > #define GET_DC_REGION_EXTENT_LIST 0x3 > #define INITIATE_DC_ADD 0x4 > + #define INITIATE_DC_RELEASE 0x5 > }; > > /* CCI Message Format CXL r3.1 Figure 7-19 */ > @@ -3638,6 +3639,77 @@ static CXLRetCode cmd_fm_initiate_dc_add(const struct cxl_cmd *cmd, > } > } > > +#define CXL_EXTENT_REMOVAL_POLICY_MASK 0x0F > +#define CXL_FORCED_REMOVAL_MASK (1 << 4) > +/* CXL r3.2 Section 7.6.7.6.6 Initiate Dynamic Capacity Release (Opcode 5605h) */ Added a colon and wrapped after the number. > +static CXLRetCode cmd_fm_initiate_dc_release(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 flags; > + 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->flags & CXL_EXTENT_REMOVAL_POLICY_MASK) { > + case CXL_EXTENT_REMOVAL_POLICY_PRESCRIPTIVE: { > + CXLDCExtentList updated_list; > + uint32_t updated_list_size; > + 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); > + if (rc) { > + return rc; > + } > + > + /* Fail with Invalid PA if an extent is pending and Forced Removal /* * Fail... > + * flag not set > + */ > + if (!(in->flags & CXL_FORCED_REMOVAL_MASK)) { > + for (i = 0; i < in->ext_count; i++) { > + CXLDCExtentRaw ext = in->extents[i]; > + /* Check requested extents don't overlap with pending extents. */ Made this a multiline comment. > + if (cxl_extent_groups_overlaps_dpa_range(&ct3d->dc.extents_pending, This is quite a bit too far over so I just went with the ugly if (cxl_extent_groups_overlaps_dpa_range( &ct3d->dc.extents_pending, > + ext.start_dpa, ext.len)) { > + return CXL_MBOX_INVALID_PA;