From nobody Mon Apr 13 13:57:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1772799193; cv=none; d=zohomail.com; s=zohoarc; b=I61kVBkbn3VLhixGjGCLwTqyBLGTEwuv0y5GLalwXFkqShb8iyrX38dF54cLvjEmtE+gNE/uXriif41L21i7rhdG3//U9eyJ8Pr7PJfyUO2OIJIsup81KOUs5M2LIj3uicuvSsKi1gKYFQ6Ed6mJoC9g4RAallA9ntpRtMhoZbI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772799193; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=wW6R5tFxDHI7UjlPZfx/dk3UbiPRZdynItrGOMed6ZQ=; b=DxFXFYxv58YMEuOxnxZFiRZr0Q8q5ZhgL+JjxyUE2Jm0pN+F8p7Z8gEp+Z6z55ns3EQ7cYewR6f0dCJPH563nG+SxrMharXoRcuh6YRgvEcFikGui/nXeY4+wWi/UTQIkI18C4Z9CgI56FFAh1K4T8PplhltZlR3Wx5Tkcogb6w= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772799193793184.13280762433158; Fri, 6 Mar 2026 04:13:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyU3G-00068D-6R; Fri, 06 Mar 2026 07:13:06 -0500 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 1vyU3D-00067S-B1 for qemu-devel@nongnu.org; Fri, 06 Mar 2026 07:13:03 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyU3B-0007fh-M1 for qemu-devel@nongnu.org; Fri, 06 Mar 2026 07:13:03 -0500 Received: from mail.maildlp.com (unknown [172.18.224.150]) by frasgout.his.huawei.com (SkyGuard) with ESMTPS id 4fS4z955RczJ46ky; Fri, 6 Mar 2026 20:12:21 +0800 (CST) Received: from dubpeml500005.china.huawei.com (unknown [7.214.145.207]) by mail.maildlp.com (Postfix) with ESMTPS id AA4744056B; Fri, 6 Mar 2026 20:12:59 +0800 (CST) Received: from a2303103017.china.huawei.com (10.206.167.72) by dubpeml500005.china.huawei.com (7.214.145.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 6 Mar 2026 12:12:58 +0000 To: , , CC: , , , , , , , , , , , , , Subject: [PATCH v7 2/3] hw/cxl: Allow cxl_cfmws_find_device() to filter on whether interleaved paths are accepted Date: Fri, 6 Mar 2026 12:11:50 +0000 Message-ID: <20260306121151.883-3-alireza.sanaee@huawei.com> X-Mailer: git-send-email 2.51.0.windows.2 In-Reply-To: <20260306121151.883-1-alireza.sanaee@huawei.com> References: <20260306121151.883-1-alireza.sanaee@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.206.167.72] X-ClientProxiedBy: lhrpeml500010.china.huawei.com (7.191.174.240) To dubpeml500005.china.huawei.com (7.214.145.207) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=185.176.79.56; envelope-from=alireza.sanaee@huawei.com; helo=frasgout.his.huawei.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Alireza Sanaee From: Alireza Sanaee via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1772799195286154100 Content-Type: text/plain; charset="utf-8" Extend cxl_cfmws_find_device() with a parameter that filters on whether the address lies in an interleaved range. For now all callers accept interleave configurations so no functional changes. Reviewed-by: Li Zhijian Signed-off-by: Alireza Sanaee Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Tested-by: Gregory Price --- Thanks to Li for the tag. Change log: v6->v7: No change! hw/cxl/cxl-host.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c index a94b893e99..2dc9f77007 100644 --- a/hw/cxl/cxl-host.c +++ b/hw/cxl/cxl-host.c @@ -104,7 +104,7 @@ void cxl_fmws_link_targets(Error **errp) } =20 static bool cxl_hdm_find_target(uint32_t *cache_mem, hwaddr addr, - uint8_t *target) + uint8_t *target, bool *interleaved) { int hdm_inc =3D R_CXL_HDM_DECODER1_BASE_LO - R_CXL_HDM_DECODER0_BASE_L= O; unsigned int hdm_count; @@ -138,6 +138,11 @@ static bool cxl_hdm_find_target(uint32_t *cache_mem, h= waddr addr, found =3D true; ig_enc =3D FIELD_EX32(ctrl, CXL_HDM_DECODER0_CTRL, IG); iw_enc =3D FIELD_EX32(ctrl, CXL_HDM_DECODER0_CTRL, IW); + + if (interleaved) { + *interleaved =3D iw_enc !=3D 0; + } + target_idx =3D (addr / cxl_decode_ig(ig_enc)) % (1 << iw_enc); =20 if (target_idx < 4) { @@ -157,7 +162,8 @@ static bool cxl_hdm_find_target(uint32_t *cache_mem, hw= addr addr, return found; } =20 -static PCIDevice *cxl_cfmws_find_device(CXLFixedWindow *fw, hwaddr addr) +static PCIDevice *cxl_cfmws_find_device(CXLFixedWindow *fw, hwaddr addr, + bool allow_interleave) { CXLComponentState *hb_cstate, *usp_cstate; PCIHostState *hb; @@ -165,9 +171,13 @@ static PCIDevice *cxl_cfmws_find_device(CXLFixedWindow= *fw, hwaddr addr) int rb_index; uint32_t *cache_mem; uint8_t target; - bool target_found; + bool target_found, interleaved; PCIDevice *rp, *d; =20 + if ((fw->num_targets > 1) && !allow_interleave) { + return NULL; + } + rb_index =3D (addr / cxl_decode_ig(fw->enc_int_gran)) % fw->num_target= s; hb =3D PCI_HOST_BRIDGE(fw->target_hbs[rb_index]->cxl_host_bridge); if (!hb || !hb->bus || !pci_bus_is_cxl(hb->bus)) { @@ -187,11 +197,16 @@ static PCIDevice *cxl_cfmws_find_device(CXLFixedWindo= w *fw, hwaddr addr) =20 cache_mem =3D hb_cstate->crb.cache_mem_registers; =20 - target_found =3D cxl_hdm_find_target(cache_mem, addr, &target); + target_found =3D cxl_hdm_find_target(cache_mem, addr, &target, + &interleaved); if (!target_found) { return NULL; } =20 + if (interleaved && !allow_interleave) { + return NULL; + } + rp =3D pcie_find_port_by_pn(hb->bus, target); if (!rp) { return NULL; @@ -223,11 +238,15 @@ static PCIDevice *cxl_cfmws_find_device(CXLFixedWindo= w *fw, hwaddr addr) =20 cache_mem =3D usp_cstate->crb.cache_mem_registers; =20 - target_found =3D cxl_hdm_find_target(cache_mem, addr, &target); + target_found =3D cxl_hdm_find_target(cache_mem, addr, &target, &interl= eaved); if (!target_found) { return NULL; } =20 + if (interleaved && !allow_interleave) { + return NULL; + } + d =3D pcie_find_port_by_pn(&PCI_BRIDGE(d)->sec_bus, target); if (!d) { return NULL; @@ -251,7 +270,7 @@ static MemTxResult cxl_read_cfmws(void *opaque, hwaddr = addr, uint64_t *data, CXLFixedWindow *fw =3D opaque; PCIDevice *d; =20 - d =3D cxl_cfmws_find_device(fw, addr + fw->base); + d =3D cxl_cfmws_find_device(fw, addr + fw->base, true); if (d =3D=3D NULL) { *data =3D 0; /* Reads to invalid address return poison */ @@ -268,7 +287,7 @@ static MemTxResult cxl_write_cfmws(void *opaque, hwaddr= addr, CXLFixedWindow *fw =3D opaque; PCIDevice *d; =20 - d =3D cxl_cfmws_find_device(fw, addr + fw->base); + d =3D cxl_cfmws_find_device(fw, addr + fw->base, true); if (d =3D=3D NULL) { /* Writes to invalid address are silent */ return MEMTX_OK; --=20 2.43.0