From nobody Sat Nov 15 20:33:56 2025 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=1748430575; cv=none; d=zohomail.com; s=zohoarc; b=kSw+indfI4pi2jVB5Ph+mdb9mnh8B/VbzFCqc1rDaInfvCIqt+lQ5BOOKGZWwe4yzsL+HFyW7r8RmrH7rDrjLw13nqQt/b5VlXbFuxNHmEhYtyXmjxzvVx7rzO3mEcYfrpRySK2FbWjH7WeZaXlnoY3QCUrVXvQwxDgcrOsN5GY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748430575; 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=cgOl71680Xojc5Eopuv8FJklsF3nu5m1aQfGWKZ3l+M=; b=Fv6SVHoucUV4QdzMlQWO6N/RP4zRZ9p/B5w8nOnOapKdJdcOFOoA9gR2PGgFd+pmFAo2QL5xC3J6zI4tCqT7wzOZCreIwxGwlOPZqD/F1HHuQFxMWXCi+sZIJgHFr9SoKh0kYgenShwkre600Jm10kpyRWpa143KmfPd+7iYh0c= 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 1748430575304246.549260488174; Wed, 28 May 2025 04:09:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKEeo-0004w6-SF; Wed, 28 May 2025 07:09:14 -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 1uKEej-0004kf-3X; Wed, 28 May 2025 07:09:09 -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 1uKEeg-0001cQ-Ba; Wed, 28 May 2025 07:09:08 -0400 Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4b6mwB5C5Fz6M4sd; Wed, 28 May 2025 19:08:58 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id 3CD2214034D; Wed, 28 May 2025 19:09:01 +0800 (CST) Received: from SecurePC-101-06.china.huawei.com (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; Wed, 28 May 2025 13:09:00 +0200 To: , Fan Ni , Peter Maydell , CC: , , , Yuquan Wang , Itaru Kitayama , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alireza Sanaee Subject: [PATCH v14 3/5] hw/cxl-host: Allow split of establishing memory address and mmio setup. Date: Wed, 28 May 2025 12:07:24 +0100 Message-ID: <20250528110726.226389-4-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250528110726.226389-1-Jonathan.Cameron@huawei.com> References: <20250528110726.226389-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.122.19.247] X-ClientProxiedBy: lhrpeml100004.china.huawei.com (7.191.162.219) 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 (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=jonathan.cameron@huawei.com; helo=frasgout.his.huawei.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 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.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1748430577316116600 Content-Type: text/plain; charset="utf-8" On arm/virt the memory map is set up before any devices are brought up. To enable this provide split functions to establish the fw->base and later to actually map it. Signed-off-by: Jonathan Cameron --- v14: Update wrt to changes in previous patch. Add a do_cfwms_set_memmap_and_update_mmio() utility function to reduce code duplication. (Zhijian) --- include/hw/cxl/cxl_host.h | 2 ++ hw/cxl/cxl-host-stubs.c | 2 ++ hw/cxl/cxl-host.c | 43 +++++++++++++++++++++++++++++++++++---- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/include/hw/cxl/cxl_host.h b/include/hw/cxl/cxl_host.h index 6dce2cde07..aee9d573d6 100644 --- a/include/hw/cxl/cxl_host.h +++ b/include/hw/cxl/cxl_host.h @@ -16,6 +16,8 @@ void cxl_machine_init(Object *obj, CXLState *state); void cxl_fmws_link_targets(Error **errp); void cxl_hook_up_pxb_registers(PCIBus *bus, CXLState *state, Error **errp); +hwaddr cxl_fmws_set_memmap(hwaddr base, hwaddr max_addr); +void cxl_fmws_update_mmio(void); hwaddr cxl_fmws_set_memmap_and_update_mmio(hwaddr base, hwaddr max_addr); GSList *cxl_fmws_get_all_sorted(void); =20 diff --git a/hw/cxl/cxl-host-stubs.c b/hw/cxl/cxl-host-stubs.c index 13eb6bf6a4..d9e38618d6 100644 --- a/hw/cxl/cxl-host-stubs.c +++ b/hw/cxl/cxl-host-stubs.c @@ -11,6 +11,8 @@ void cxl_fmws_link_targets(Error **errp) {}; void cxl_machine_init(Object *obj, CXLState *state) {}; void cxl_hook_up_pxb_registers(PCIBus *bus, CXLState *state, Error **errp)= {}; +hwaddr cxl_fmws_set_memmap(hwaddr base, hwaddr max_addr) { return base; }; +void cxl_fmws_update_mmio(void) {}; hwaddr cxl_fmws_set_memmap_and_update_mmio(hwaddr base, hwaddr max_addr) { return base; diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c index 016a4fdc6a..a1b9980035 100644 --- a/hw/cxl/cxl-host.c +++ b/hw/cxl/cxl-host.c @@ -378,11 +378,14 @@ void cxl_hook_up_pxb_registers(PCIBus *bus, CXLState = *state, Error **errp) } } =20 -static void cxl_fmws_update(CXLFixedWindow *fw, hwaddr *base, hwaddr max_a= ddr) +static void cxl_fmws_update(CXLFixedWindow *fw, hwaddr *base, hwaddr max_a= ddr, + bool update_mmio) { if (*base + fw->size <=3D max_addr) { fw->base =3D *base; - sysbus_mmio_map(SYS_BUS_DEVICE(fw), 0, fw->base); + if (update_mmio) { + sysbus_mmio_map(SYS_BUS_DEVICE(fw), 0, fw->base); + } *base +=3D fw->size; } } @@ -421,19 +424,51 @@ GSList *cxl_fmws_get_all_sorted(void) return g_slist_sort_with_data(cxl_fmws_get_all(), cfmws_cmp, NULL); } =20 -hwaddr cxl_fmws_set_memmap_and_update_mmio(hwaddr base, hwaddr max_addr) +static hwaddr do_cxl_fmws_set_memmap_and_update_mmio(hwaddr base, + hwaddr max_addr, + bool update_mmio) { GSList *cfmws_list, *iter; =20 cfmws_list =3D cxl_fmws_get_all_sorted(); for (iter =3D cfmws_list; iter; iter =3D iter->next) { - cxl_fmws_update(CXL_FMW(iter->data), &base, max_addr); + cxl_fmws_update(CXL_FMW(iter->data), &base, max_addr, update_mmio); } g_slist_free(cfmws_list); =20 return base; } =20 +hwaddr cxl_fmws_set_memmap(hwaddr base, hwaddr max_addr) +{ + return do_cxl_fmws_set_memmap_and_update_mmio(base, max_addr, false); +} + +hwaddr cxl_fmws_set_memmap_and_update_mmio(hwaddr base, hwaddr max_addr) +{ + return do_cxl_fmws_set_memmap_and_update_mmio(base, max_addr, true); +} + +static int cxl_fmws_mmio_map(Object *obj, void *opaque) +{ + struct CXLFixedWindow *fw; + + if (!object_dynamic_cast(obj, TYPE_CXL_FMW)) { + return 0; + } + fw =3D CXL_FMW(obj); + sysbus_mmio_map(SYS_BUS_DEVICE(fw), 0, fw->base); + + return 0; +} + +void cxl_fmws_update_mmio(void) +{ + /* Ordering is not required for this */ + object_child_foreach_recursive(object_get_root(), cxl_fmws_mmio_map, + NULL); +} + static void cxl_fmw_realize(DeviceState *dev, Error **errp) { CXLFixedWindow *fw =3D CXL_FMW(dev); --=20 2.48.1