From: Jonathan Cameron via <qemu-devel@nongnu.org>
To: Arpit Kumar <arpit1.kumar@samsung.com>
Cc: <qemu-devel@nongnu.org>, <gost.dev@samsung.com>,
<linux-cxl@vger.kernel.org>, <nifan.cxl@gmail.com>,
<dave@stgolabs.net>, <vishak.g@samsung.com>,
<krish.reddy@samsung.com>, <a.manzanares@samsung.com>,
<alok.rathore@samsung.com>
Subject: Re: [PATCH 3/3] hw/cxl/cxl-mailbox-utils.c: Added support for Populate Log (Opcode 0404h) as background operation
Date: Tue, 4 Feb 2025 10:58:29 +0000 [thread overview]
Message-ID: <20250204105829.00001c47@huawei.com> (raw)
In-Reply-To: <20250203055950.2126627-4-arpit1.kumar@samsung.com>
On Mon, 3 Feb 2025 11:29:50 +0530
Arpit Kumar <arpit1.kumar@samsung.com> wrote:
> Signed-off-by: Arpit Kumar <arpit1.kumar@samsung.com>
> Reviewed-by: Alok Rathore <alok.rathore@samsung.com>
> Reviewed-by: Krishna Kanth Reddy <krish.reddy@samsung.com>
Likewise, the CEL isn't a dynamic thing. Asking to populate
it makes little sense so the log capability should always
say this is not supported.
I suspect you had this running with a different log and flipped
to CEL for purposes of up streaming?
Anyhow, choose something else. Maybe component state dump or ECS log?
> ---
> hw/cxl/cxl-mailbox-utils.c | 95 +++++++++++++++++++++++++++++++++++++
> include/hw/cxl/cxl_device.h | 2 +
> 2 files changed, 97 insertions(+)
>
> diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
> index 5fd7f850c4..115c2dc66b 100644
> --- a/hw/cxl/cxl-mailbox-utils.c
> +++ b/hw/cxl/cxl-mailbox-utils.c
> @@ -78,6 +78,7 @@ enum {
> #define GET_LOG 0x1
> #define GET_LOG_CAPABILITIES 0x2
> #define CLEAR_LOG 0x3
> + #define POPULATE_LOG 0x4
> FEATURES = 0x05,
> #define GET_SUPPORTED 0x0
> #define GET_FEATURE 0x1
> @@ -1149,6 +1150,94 @@ static CXLRetCode cmd_logs_clear_log(const struct cxl_cmd *cmd,
> return CXL_MBOX_SUCCESS;
> }
>
> +static void cxl_rebuild_cel(CXLCCI *cci);
> +
> +static int get_populate_duration(uint32_t total_mem)
> +{
> + int secs = 0;
> +
> + if (total_mem <= 512) {
> + secs = 4;
> + } else if (total_mem <= 1024) {
> + secs = 8;
> + } else if (total_mem <= 2 * 1024) {
> + secs = 15;
> + } else if (total_mem <= 4 * 1024) {
> + secs = 30;
> + } else if (total_mem <= 8 * 1024) {
> + secs = 60;
> + } else if (total_mem <= 16 * 1024) {
> + secs = 2 * 60;
> + } else if (total_mem <= 32 * 1024) {
> + secs = 4 * 60;
> + } else if (total_mem <= 64 * 1024) {
> + secs = 8 * 60;
> + } else if (total_mem <= 128 * 1024) {
> + secs = 15 * 60;
> + } else if (total_mem <= 256 * 1024) {
> + secs = 30 * 60;
> + } else if (total_mem <= 512 * 1024) {
> + secs = 60 * 60;
> + } else if (total_mem <= 1024 * 1024) {
> + secs = 120 * 60;
> + } else {
> + secs = 240 * 60; /* max 4 hrs */
> + }
> +
> + return secs;
> +}
> +
> +/* CXL r3.1 Section 8.2.9.5.5: Populate log (Opcode 0404h) */
> +static CXLRetCode cmd_logs_populate_log(const struct cxl_cmd *cmd,
> + uint8_t *payload_in,
> + size_t len_in,
> + uint8_t *payload_out,
> + size_t *len_out,
> + CXLCCI *cci)
> +{
> + int32_t cap_id;
> + uint32_t total_mem = 0;
> + int secs = 0;
> + struct {
> + QemuUUID uuid;
> + } QEMU_PACKED QEMU_ALIGNED(8) * populate_log = (void *)payload_in;
> +
> + cap_id = valid_log_check(&populate_log->uuid, cci);
> + if (cap_id == -1) {
> + return CXL_MBOX_INVALID_LOG;
> + }
> +
> + if (cci->supported_log_cap[cap_id].param_flags.populate_log_supported) {
> + switch (cap_id) {
> + case CEL:
Similar to before, a callback to fill the log inside the cap entry
is probably going to be the most extensible way to do this rather
than using an ID and a switch statement that gets steadily more
complex and doesn't easily allow for different device emulation to
make different choices on what to fill with (e.g. faking component
state dump for a type 3 vs a type 2 device - once supported in qemu).
> + cci->log = CEL;
> + total_mem = (1 << 16) * sizeof(struct cel_log);
> + secs = get_populate_duration(total_mem >> 20);
Why would the CEL be based on memory size?
> + goto start_bg;
> + break;
> + default:
> + return CXL_MBOX_UNSUPPORTED;
> + }
> + }
> + return CXL_MBOX_UNSUPPORTED;
> +
> +start_bg:
> + cci->bg.runtime = secs * 1000UL;
> + *len_out = 0;
> + return CXL_MBOX_BG_STARTED;
> +}
> +
> +static void __do_populate(CXLCCI *cci)
> +{
> + switch (cci->log) {
> + case CEL:
> + cxl_rebuild_cel(cci);
> + break;
> + default:
> + break;
> + }
> +}
> +
> /* CXL r3.1 section 8.2.9.6: Features */
> /*
> * Get Supported Features output payload
> @@ -2918,6 +3007,9 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = {
> cmd_logs_get_log_capabilities, 0x10, 0 },
> [LOGS][CLEAR_LOG] = { "LOGS_CLEAR_LOG", cmd_logs_clear_log, 0x10,
> CXL_MBOX_IMMEDIATE_LOG_CHANGE},
> + [LOGS][POPULATE_LOG] = { "LOGS_POPULATE_LOG", cmd_logs_populate_log, 0x10,
> + (CXL_MBOX_IMMEDIATE_LOG_CHANGE |
> + CXL_MBOX_BACKGROUND_OPERATION)},
> [FEATURES][GET_SUPPORTED] = { "FEATURES_GET_SUPPORTED",
> cmd_features_get_supported, 0x8, 0 },
> [FEATURES][GET_FEATURE] = { "FEATURES_GET_FEATURE",
> @@ -3098,6 +3190,9 @@ static void bg_timercb(void *opaque)
> case 0x0201: /* fw transfer */
> __do_firmware_xfer(cci);
> break;
> + case 0x0404: /* populate_ log */
> + __do_populate(cci);
> + break;
> case 0x4400: /* sanitize */
> {
> CXLType3Dev *ct3d = CXL_TYPE3(cci->d);
> diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h
> index e7cb99a1d2..d90d0d4a8f 100644
> --- a/include/hw/cxl/cxl_device.h
> +++ b/include/hw/cxl/cxl_device.h
> @@ -230,6 +230,8 @@ typedef struct CXLCCI {
> } cel_log[1 << 16];
> size_t cel_size;
>
> + enum Logs log;
> +
> /* get log capabilities */
> CXLLogCapabilities supported_log_cap[MAX_LOG_TYPE];
>
next prev parent reply other threads:[~2025-02-04 10:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20250203060050epcas5p38f556047edbdedd98b6ac2d1d496a3dc@epcas5p3.samsung.com>
2025-02-03 5:59 ` [PATCH 0/3] CXL CCI Log Commands implementation Arpit Kumar
[not found] ` <CGME20250203060051epcas5p350b7b24d3b5fcff25bc30e1acccd8121@epcas5p3.samsung.com>
2025-02-03 5:59 ` [PATCH 1/3] hw/cxl/cxl-mailbox-utils.c: Added support for Get Log Capabilities (Opcode 0402h) Arpit Kumar
2025-02-04 10:28 ` Jonathan Cameron via
2025-02-12 11:30 ` Arpit Kumar
2025-02-12 17:15 ` Jonathan Cameron via
[not found] ` <CGME20250203060053epcas5p137fe4cbd5661afdfd2602dbc7facdcb9@epcas5p1.samsung.com>
2025-02-03 5:59 ` [PATCH 2/3] hw/cxl/cxl-mailbox-utils.c: Added support for Clear Log (Opcode 0403h) Arpit Kumar
2025-02-04 10:53 ` Jonathan Cameron via
2025-02-12 11:37 ` Arpit Kumar
[not found] ` <CGME20250203060055epcas5p4a7889ddf3b73b10f8b9b41778375ce63@epcas5p4.samsung.com>
2025-02-03 5:59 ` [PATCH 3/3] hw/cxl/cxl-mailbox-utils.c: Added support for Populate Log (Opcode 0404h) as background operation Arpit Kumar
2025-02-04 10:58 ` Jonathan Cameron via [this message]
2025-02-12 11:45 ` Arpit Kumar
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=20250204105829.00001c47@huawei.com \
--to=qemu-devel@nongnu.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=a.manzanares@samsung.com \
--cc=alok.rathore@samsung.com \
--cc=arpit1.kumar@samsung.com \
--cc=dave@stgolabs.net \
--cc=gost.dev@samsung.com \
--cc=krish.reddy@samsung.com \
--cc=linux-cxl@vger.kernel.org \
--cc=nifan.cxl@gmail.com \
--cc=vishak.g@samsung.com \
/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;
as well as URLs for NNTP newsgroup(s).