From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: <fan.ni@samsung.com>, <dan.j.williams@intel.com>,
<a.manzanares@samsung.com>, <linux-cxl@vger.kernel.org>
Subject: Re: [PATCH 2/3] cxl: Support Get/Set Shutdown State commands
Date: Mon, 23 Dec 2024 20:01:19 +0000 [thread overview]
Message-ID: <20241223200119.000050f7@huawei.com> (raw)
In-Reply-To: <20241220160026.204055-3-dave@stgolabs.net>
On Fri, 20 Dec 2024 08:00:25 -0800
Davidlohr Bueso <dave@stgolabs.net> wrote:
> As per the latest spec, add mailbox commands 4203h and 4204h.
> While upon reboot this operation is obviously a nop (flag is
> cleared but the dirty shutdown count is not increased), it
> can still serve to test some basic paths.
>
> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
Hi Davidlohr,,
Some trivial stuff inline.
Thanks,
Jonathan
> ---
> hw/cxl/cxl-mailbox-utils.c | 49 +++++++++++++++++++++++++++++++++++++
> include/hw/cxl/cxl_device.h | 2 ++
> 2 files changed, 51 insertions(+)
>
> diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
> index f6f993e7bc4f..ff1d3f50610c 100644
> --- a/hw/cxl/cxl-mailbox-utils.c
> +++ b/hw/cxl/cxl-mailbox-utils.c
> @@ -86,6 +86,9 @@ enum {
> #define GET_PARTITION_INFO 0x0
> #define GET_LSA 0x2
> #define SET_LSA 0x3
> + HEALTH_INFO_ALERTS = 0x42,
> + #define GET_SHUTDOWN_STATE 0x3
> + #define SET_SHUTDOWN_STATE 0x4
> MEDIA_AND_POISON = 0x43,
> #define GET_POISON_LIST 0x0
> #define INJECT_POISON 0x1
> @@ -1721,6 +1724,48 @@ static CXLRetCode cmd_sanitize_overwrite(const struct cxl_cmd *cmd,
> return CXL_MBOX_BG_STARTED;
> }
>
> +/* CXL r3.2 Section 8.2.10.9.3.4: Get Shutdown State (Opcode 4203h) */
> +static CXLRetCode cmd_health_get_shutdown_state(const struct cxl_cmd *cmd,
> + uint8_t *payload_in,
> + size_t len_in,
> + uint8_t *payload_out,
> + size_t *len_out,
> + CXLCCI *cci)
> +{
> + CXLType3Dev *ct3d = CXL_TYPE3(cci->d);
> + CXLDeviceState *cxl_dstate = &ct3d->cxl_dstate;
> + struct get_shutdown_state_pl {
> + uint8_t state;
> + } QEMU_PACKED;
> + struct get_shutdown_state_pl *out = (void *)payload_out;
We only need the (void *) for unnamed types. Where we know the type
might as well get it right. E.g. see cmd_events_set_interrupt_policy.
Mind you, not much point in keeping the type named here.
struct {
uint8_t state;
} QEMU_PACKED = (void *)payload_out;
> +
> + out->state = cxl_dstate->shutdown_state;
> + *len_out = sizeof(out);
> +
> + return CXL_MBOX_SUCCESS;
> +}
> +
> +/* CXL r3.2 Section 8.2.10.9.3.5: Set Shutdown State (Opcode 4204h) */
> +static CXLRetCode cmd_health_set_shutdown_state(const struct cxl_cmd *cmd,
> + uint8_t *payload_in,
> + size_t len_in,
> + uint8_t *payload_out,
> + size_t *len_out,
> + CXLCCI *cci)
> +{
> + CXLType3Dev *ct3d = CXL_TYPE3(cci->d);
> + CXLDeviceState *cxl_dstate = &ct3d->cxl_dstate;
> + struct set_shutdown_state_pl {
> + uint8_t state;
> + } QEMU_PACKED;
As above. Naming the type isn't that useful and if you want
to should cast to that not a void *
> + struct set_shutdown_state_pl *in = (void *)payload_in;
> +
> + cxl_dstate->shutdown_state = in->state;
> + *len_out = 0;
> +
> + return CXL_MBOX_SUCCESS;
> +}
> +
> static CXLRetCode cmd_get_security_state(const struct cxl_cmd *cmd,
> uint8_t *payload_in,
> size_t len_in,
> @@ -2866,6 +2911,10 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = {
> CXL_MBOX_BACKGROUND_OPERATION_ABORT)},
> [PERSISTENT_MEM][GET_SECURITY_STATE] = { "GET_SECURITY_STATE",
> cmd_get_security_state, 0, 0 },
> + [HEALTH_INFO_ALERTS][GET_SHUTDOWN_STATE] = { "HEALTH_INFO_ALERTS_GET_SHUTDOWN_STATE",
> + cmd_health_get_shutdown_state, 0, 0 },
> + [HEALTH_INFO_ALERTS][SET_SHUTDOWN_STATE] = { "HEALTH_INFO_ALERTS_SET_SHUTDOWN_STATE",
> + cmd_health_set_shutdown_state, 1, 0 },
> [MEDIA_AND_POISON][GET_POISON_LIST] = { "MEDIA_AND_POISON_GET_POISON_LIST",
> cmd_media_get_poison_list, 16, 0 },
> [MEDIA_AND_POISON][INJECT_POISON] = { "MEDIA_AND_POISON_INJECT_POISON",
> diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h
> index a64739be25e9..69e6330fe66d 100644
> --- a/include/hw/cxl/cxl_device.h
> +++ b/include/hw/cxl/cxl_device.h
> @@ -292,6 +292,8 @@ typedef struct cxl_device_state {
> CPMUState cpmu[CXL_NUM_CPMU_INSTANCES];
> CHMUState chmu[1];
> CXLEventLog event_logs[CXL_EVENT_TYPE_MAX];
> +
> + uint8_t shutdown_state;
> } CXLDeviceState;
>
> /* Initialize the register block for a device */
next prev parent reply other threads:[~2024-12-23 20:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-20 16:00 [PATCH -qemu 0/3] hw/cxl: Support dirty shutdown Davidlohr Bueso
2024-12-20 16:00 ` [PATCH 1/3] cxl: Fix mbox cmd enum order Davidlohr Bueso
2024-12-21 19:05 ` Fan Ni
2024-12-20 16:00 ` [PATCH 2/3] cxl: Support Get/Set Shutdown State commands Davidlohr Bueso
2024-12-21 19:18 ` Fan Ni
2024-12-23 19:57 ` Jonathan Cameron
2024-12-23 20:01 ` Jonathan Cameron [this message]
2024-12-20 16:00 ` [PATCH 3/3] cxl/type3: Add 'dirty-shutdown' parameter Davidlohr Bueso
2024-12-23 20:08 ` 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=20241223200119.000050f7@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=a.manzanares@samsung.com \
--cc=dan.j.williams@intel.com \
--cc=dave@stgolabs.net \
--cc=fan.ni@samsung.com \
--cc=linux-cxl@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.