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 ED0702264D4 for ; Mon, 14 Jul 2025 14:02:28 +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=1752501751; cv=none; b=T4XBhbRXmtzi6NKqq5JA/YlPoLwA7rtNF0hUnoJCN1yE59v9/tTRx6TGqIPSJ4PUlqRgzjNDHrlJB8g7aTr+VbY68EHUE38ns51MB6ScDVUB77OMNk9OP80IPmYGNfwwttIzO6VGVEgoID0bDpuW+jhyTwEotuz9iC5UtUirUSA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752501751; c=relaxed/simple; bh=7tzrHU3bUYWKvLGnnYrOPSB63uswlBPwrubxcfCd/YM=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uoG4hsKnwYyVitf8ndhGR0TN2fki5EjEbatdQaHh2PAWZR8D76kiVMhMxdK4BUphUlQLELhU1LznzMJtXSHISkaWPthCt+fDQf9Hw4TfxzdnBWY0fqdgw8kM2ccAEst3GRNIyYmCQkVdEeOtKOZyd+Xj2mZH+uH7XVSoC+omt5Y= 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.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4bgkWH6Ddvz6L5dP; Mon, 14 Jul 2025 22:01:15 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id 81282140370; Mon, 14 Jul 2025 22:02:20 +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, 14 Jul 2025 16:02:20 +0200 Date: Mon, 14 Jul 2025 15:02:18 +0100 From: Jonathan Cameron To: "Michael S. Tsirkin" CC: , Fan Ni , , , Anisa Su Subject: Re: [PATCH qemu 07/11] hw/cxl: mailbox-utils: 0x5602 - FMAPI Set DC Region Config Message-ID: <20250714150218.00006c95@huawei.com> In-Reply-To: <20250714052757-mutt-send-email-mst@kernel.org> References: <20250702160219.989731-1-Jonathan.Cameron@huawei.com> <20250702160219.989731-8-Jonathan.Cameron@huawei.com> <20250714052757-mutt-send-email-mst@kernel.org> 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="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: lhrpeml500011.china.huawei.com (7.191.174.215) To frapeml500008.china.huawei.com (7.182.85.71) On Mon, 14 Jul 2025 05:32:19 -0400 "Michael S. Tsirkin" wrote: > On Wed, Jul 02, 2025 at 05:02:13PM +0100, Jonathan Cameron wrote: > > From: Anisa Su > >=20 > > FM DCD Management command 0x5602 implemented per CXL r3.2 Spec Section = 7.6.7.6.3 > >=20 > > Reviewed-by: Fan Ni > > Signed-off-by: Anisa Su > > Signed-off-by: Jonathan Cameron > > diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c > > index bf1710b251..1fc453f70d 100644 > > --- a/hw/cxl/cxl-mailbox-utils.c > > +++ b/hw/cxl/cxl-mailbox-utils.c > > +/* CXL r3.2 section 7.6.7.6.3: Set Host DC Region Configuration (Opcod= e 5602) */ > > +static CXLRetCode cmd_fm_set_dc_region_config(const struct cxl_cmd *cm= d, > > + uint8_t *payload_in, > > + size_t len_in, > > + uint8_t *payload_out, > > + size_t *len_out, > > + CXLCCI *cci) > > +{ > > + struct { > > + uint8_t reg_id; > > + uint8_t rsvd[3]; > > + uint64_t block_sz; > > + uint8_t flags; > > + uint8_t rsvd2[3]; > > + } QEMU_PACKED *in =3D (void *)payload_in; > > + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); > > + CXLEventDynamicCapacity dcEvent =3D {}; > > + CXLDCRegion *region =3D &ct3d->dc.regions[in->reg_id]; > > + > > + /* > > + * CXL r3.2 7.6.7.6.3: Set DC Region Configuration > > + * This command shall fail with Unsupported when the Sanitize on R= elease > > + * field does not match the region=E2=80=99s configuration... and = the device > > + * does not support reconfiguration of the Sanitize on Release set= ting. > > + * > > + * Currently not reconfigurable, so always fail if sanitize bit (b= it 0) > > + * doesn't match. > > + */ > > + if ((in->flags & 0x1) !=3D (region->flags & 0x1)) { > > + return CXL_MBOX_UNSUPPORTED; > > + } > > + > > + if (in->reg_id >=3D DCD_MAX_NUM_REGION) { > > + return CXL_MBOX_UNSUPPORTED; > > + } > > + > > + /* Check that no extents are in the region being reconfigured */ > > + if (!bitmap_empty(region->blk_bitmap, region->len / region->block_= size)) { > > + return CXL_MBOX_UNSUPPORTED; > > + } > > + > > + /* Check that new block size is supported */ > > + if (!test_bit(BIT((int) log2(in->block_sz)), > > + ®ion->supported_blk_size_bitmask)) { > > + return CXL_MBOX_INVALID_INPUT; > > + } =20 >=20 > This does not work: test_bit works on unsigned long, while > supported_blk_size_bitmask is uint64_t. >=20 > Why so funky? what is wrong with: >=20 > if (!(BIT_ULL(log2(in->block_sz)) & region->supported_blk_size_bitmask)) >=20 > And BTW why cast to int here? Change looks fine to me, so I'll prepare an updated set with this and the missing semi colon. Anisa if you can have a look at this that would be great.=20 Sorry I seem to have missed Anisa off the cc for this! Jonathan