From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: <qemu-devel@nongnu.org>, Michael Tsirkin <mst@redhat.com>,
Fan Ni <fan.ni@samsung.com>
Cc: linux-cxl@vger.kernel.org, linuxarm@huawei.com,
"Ira Weiny" <ira.weiny@intel.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Dave Jiang" <dave.jiang@intel.com>
Subject: [PATCH v2 2/6] hw/cxl: Introduce cxl_device_get_timestamp() utility function
Date: Mon, 27 Feb 2023 17:03:07 +0000 [thread overview]
Message-ID: <20230227170311.20054-3-Jonathan.Cameron@huawei.com> (raw)
In-Reply-To: <20230227170311.20054-1-Jonathan.Cameron@huawei.com>
From: Ira Weiny <ira.weiny@intel.com>
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 <ira.weiny@intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
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 *cxl_dstate)
cxl_initialize_mailbox(cxl_dstate);
}
+
+uint64_t cxl_device_get_timestamp(CXLDeviceState *cxl_dstate)
+{
+ uint64_t time, delta;
+ uint64_t final_time = 0;
+
+ if (cxl_dstate->timestamp.set) {
+ /* Find the delta from the last time the host set the time. */
+ time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
+ delta = time - cxl_dstate->timestamp.last_set;
+ final_time = 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 7b2aef0d67..702e16ca20 100644
--- a/hw/cxl/cxl-mailbox-utils.c
+++ b/hw/cxl/cxl-mailbox-utils.c
@@ -163,17 +163,8 @@ static CXLRetCode cmd_timestamp_get(struct cxl_cmd *cmd,
CXLDeviceState *cxl_dstate,
uint16_t *len)
{
- uint64_t time, delta;
- uint64_t final_time = 0;
-
- if (cxl_dstate->timestamp.set) {
- /* First find the delta from the last time the host set the time. */
- time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
- delta = time - cxl_dstate->timestamp.last_set;
- final_time = cxl_dstate->timestamp.host_set + delta;
- }
+ uint64_t final_time = cxl_device_get_timestamp(cxl_dstate);
- /* Then adjust the actual time */
stq_le_p(cmd->payload, final_time);
*len = 8;
diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h
index edb9791bab..02befda0f6 100644
--- a/include/hw/cxl/cxl_device.h
+++ b/include/hw/cxl/cxl_device.h
@@ -287,4 +287,6 @@ MemTxResult cxl_type3_read(PCIDevice *d, hwaddr host_addr, uint64_t *data,
MemTxResult cxl_type3_write(PCIDevice *d, hwaddr host_addr, uint64_t data,
unsigned size, MemTxAttrs attrs);
+uint64_t cxl_device_get_timestamp(CXLDeviceState *cxlds);
+
#endif
--
2.37.2
next prev parent reply other threads:[~2023-02-27 17:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-27 17:03 [PATCH v2 0/6] hw/cxl: Poison get, inject, clear Jonathan Cameron
2023-02-27 17:03 ` [PATCH v2 1/6] hw/cxl: rename mailbox return code type from ret_code to CXLRetCode Jonathan Cameron
2023-03-01 22:49 ` Fan Ni
2023-02-27 17:03 ` Jonathan Cameron [this message]
2023-03-01 23:08 ` [PATCH v2 2/6] hw/cxl: Introduce cxl_device_get_timestamp() utility function Fan Ni
2023-02-27 17:03 ` [PATCH v2 3/6] bswap: Add the ability to store to an unaligned 24 bit field Jonathan Cameron
2023-03-01 23:31 ` Fan Ni
2023-02-27 17:03 ` [PATCH v2 4/6] hw/cxl: QMP based poison injection support Jonathan Cameron
2023-03-02 1:35 ` Michael S. Tsirkin
2023-02-27 17:03 ` [PATCH v2 5/6] hw/cxl: Add poison injection via the mailbox Jonathan Cameron
2023-02-27 17:03 ` [PATCH v2 6/6] hw/cxl: Add clear poison mailbox command support Jonathan Cameron
2023-03-02 1:15 ` [PATCH v2 0/6] hw/cxl: Poison get, inject, clear Alison Schofield
2023-03-02 9:49 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230227170311.20054-3-Jonathan.Cameron@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=dave.jiang@intel.com \
--cc=fan.ni@samsung.com \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=mst@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox