From nobody Mon Feb 9 10:29:24 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=1676658009; cv=none; d=zohomail.com; s=zohoarc; b=lJw6Ogw5d0kRfwdvmmLS/YG5GMP88M9d7wq03jxbK1oFg9fopAHxeQeqYVO8L/FE8Hx7IZ498uo/EtsJk9ovs4GTBbjyjmFhziO1IJJKXID61/n+BfwNDnM0ropK+hhPfdlOL5DyLNNckNSBiEwkt9q3PeYz3Na9dzjORzn/uw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676658009; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=W+OszkX88/X+bbQpiSh5Z4BxrfPzxceBaTMMCh1MloY=; b=LaUK7PoP/5/qm/7gde8tNYHMKg5O0xGF+XswN41fR3uSTkSkKRgLwQiBQjdbQFKNaZUePkrNwscJzhKE0eAYwnYydZls3OALV7waM/gjQbT6BqzQABE7NQR4V0ullyXJ0SXnUJTaCtZxiAmmGB3YFgPUmW3S5CKko0OGZd+LcEg= 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 1676658009027366.8179326012049; Fri, 17 Feb 2023 10:20:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pT5Ke-0002cl-HF; Fri, 17 Feb 2023 13:19:40 -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 1pT5Kc-0002cG-T2 for qemu-devel@nongnu.org; Fri, 17 Feb 2023 13:19:38 -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 1pT5Ka-0003lB-TC for qemu-devel@nongnu.org; Fri, 17 Feb 2023 13:19:38 -0500 Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4PJKmT4Dqxz6J9Kp; Sat, 18 Feb 2023 02:17:45 +0800 (CST) Received: from SecurePC-101-06.china.huawei.com (10.122.247.231) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Fri, 17 Feb 2023 18:19:34 +0000 To: , Michael Tsirkin CC: Ben Widawsky , , , Ira Weiny , Gregory Price , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mike Maslenkin , Markus Armbruster , Dave Jiang , Subject: [PATCH 3/6] hw/cxl: Introduce cxl_device_get_timestamp() utility function Date: Fri, 17 Feb 2023 18:18:09 +0000 Message-ID: <20230217181812.26995-4-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230217181812.26995-1-Jonathan.Cameron@huawei.com> References: <20230217181812.26995-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.122.247.231] X-ClientProxiedBy: lhrpeml100004.china.huawei.com (7.191.162.219) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected 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: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, 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: 1676658010193100003 Content-Type: text/plain; charset="utf-8" From: Ira Weiny There are new users of this functionality coming shortly so factor it out from the GET_TIMESTAMP mailbox command handling. Signed-off-by: Ira Weiny Signed-off-by: Jonathan Cameron --- hw/cxl/cxl-device-utils.c | 15 +++++++++++++++ hw/cxl/cxl-mailbox-utils.c | 11 +---------- include/hw/cxl/cxl_device.h | 2 ++ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c index 4c5e88aaf5..86e1cea8ce 100644 --- a/hw/cxl/cxl-device-utils.c +++ b/hw/cxl/cxl-device-utils.c @@ -269,3 +269,18 @@ void cxl_device_register_init_common(CXLDeviceState *c= xl_dstate) =20 cxl_initialize_mailbox(cxl_dstate); } + +uint64_t cxl_device_get_timestamp(CXLDeviceState *cxl_dstate) +{ + uint64_t time, delta; + uint64_t final_time =3D 0; + + if (cxl_dstate->timestamp.set) { + /* Find the delta from the last time the host set the time. */ + time =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + delta =3D time - cxl_dstate->timestamp.last_set; + final_time =3D cxl_dstate->timestamp.host_set + delta; + } + + return final_time; +} diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 67aca3fd6c..580366ed2f 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -135,17 +135,8 @@ static CXLRetCode cmd_timestamp_get(struct cxl_cmd *cm= d, CXLDeviceState *cxl_dstate, uint16_t *len) { - uint64_t time, delta; - uint64_t final_time =3D 0; - - if (cxl_dstate->timestamp.set) { - /* First find the delta from the last time the host set the time. = */ - time =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - delta =3D time - cxl_dstate->timestamp.last_set; - final_time =3D cxl_dstate->timestamp.host_set + delta; - } + uint64_t final_time =3D cxl_device_get_timestamp(cxl_dstate); =20 - /* Then adjust the actual time */ stq_le_p(cmd->payload, final_time); *len =3D 8; =20 diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index b737c3699f..44fea2d649 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -315,4 +315,6 @@ MemTxResult cxl_type3_read(PCIDevice *d, hwaddr host_ad= dr, uint64_t *data, MemTxResult cxl_type3_write(PCIDevice *d, hwaddr host_addr, uint64_t data, unsigned size, MemTxAttrs attrs); =20 +uint64_t cxl_device_get_timestamp(CXLDeviceState *cxlds); + #endif --=20 2.37.2