From patchwork Fri Dec 20 16:00:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 13917063 Received: from skyblue.cherry.relay.mailchannels.net (skyblue.cherry.relay.mailchannels.net [23.83.223.167]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97DB51BD9C1 for ; Fri, 20 Dec 2024 16:38:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=23.83.223.167 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734712703; cv=pass; b=nbbxiOeUj6KStuoz+HBJgI8nHFN+nT+Nrte1StYXLO6ERZ/oY1ozkzS/4Vb2wPzlizijtjEJYumj30BifBxWJEpxkfi6ZrcPRz2nlYEjHwqNN0ZFpshK+3SwM+QNrZRr0GgLvZc8PYATmQ5slcYspV++tVZW0oozpSZzdDLr27o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734712703; c=relaxed/simple; bh=Efpg4p8u2xuzT4D+SVMo5m51G0AuQqpI2RIywE0g6S4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZApx1/3uuK/olANtj/jlAmjVS75d6QYsrIBt5F9SvztUVezwNaEQJxnF+wsc17V1MXJPGCmX86AtJCy1bsKnUEDg4cXIbGlUcwr6aTGDdNBYqTjEvsy/ftF+piooMviJi4yQ/mPc62RDX+jSfjI9NgWZ/P1smlF/5GoXGw7Ug9s= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net; spf=pass smtp.mailfrom=stgolabs.net; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b=ZdnRYYoS; arc=pass smtp.client-ip=23.83.223.167 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b="ZdnRYYoS" X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 8E51D7825D6; Fri, 20 Dec 2024 16:00:32 +0000 (UTC) Received: from pdx1-sub0-mail-a227.dreamhost.com (trex-6.trex.outbound.svc.cluster.local [100.103.151.188]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 3232A78142E; Fri, 20 Dec 2024 16:00:32 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1734710432; a=rsa-sha256; cv=none; b=NmNUDTA7/dYRBPU4jpgFwGGf8ENmCCtdDAnE2vtGk939/uuaB3Gf68zva1sd5pTlVMf/Qc PCqr/NjS2jJxNM9VXfkSNcRPqzSAjAwcn4Pqh78Zk9qsMqlUTS4/RzqJWBy36cNdxk9psc pXkUqRci+i2zv167myoG7gILFXnUWSpR1BfY1HkJ0jJBMboAtMzDVptrGOB3TXLW2SWyg+ RkqfWlFVHdt4ZQPi4qqU1bUOtNq5UrsrytvPVdmbUCHekzrscX0gMhiulN6lk5M1rw5V1z P8q9AMlradje4qnYeFFciD3JgsTTCmWC9aV/M8g6lFgscjLQAROUllErIOc+8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1734710432; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1ZQb0ZqlBuM5Rzz5ZXbTKtufcYiEwQv0eRm+Ift9zAQ=; b=aU6yyMnFyQUUAaDodzb77wgnaGjcmtgeg3XYAN3Jdnyi8u+/HWsQfnA77qOGHNJ6NZoglM KkBC/gIFSxG7sK6nKf1ThuiPMUyw6ibeOmgTW7FDJyJlVx51rEnKTmqFRUD7IVppeJM+Yn vjo0gTpEPptKevRN9pZivswHQRQW+ue6L+CpsMvY/xz4M+gwmg7YaCwm/oRr8sEeOoaK7S LcXBHp/rUIUcNqBSRq81VyPtqklfuMHARt7yx18CsQIvnm2/9htn0ojPfdRCpbKNnZpjT7 XnbkLA+QwDdRESt86IFcFZnxAKXqiu4p0ZHQU5Wq1+2UfIAUpOTBj22MKi8aQg== ARC-Authentication-Results: i=1; rspamd-7d788bbf85-g6lq9; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Shrill-Spot: 475b8a037fca168e_1734710432438_1033846240 X-MC-Loop-Signature: 1734710432438:2948546948 X-MC-Ingress-Time: 1734710432438 Received: from pdx1-sub0-mail-a227.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.103.151.188 (trex/7.0.2); Fri, 20 Dec 2024 16:00:32 +0000 Received: from localhost.localdomain (ip72-199-50-187.sd.sd.cox.net [72.199.50.187]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a227.dreamhost.com (Postfix) with ESMTPSA id 4YFBvz4KxmzCv; Fri, 20 Dec 2024 08:00:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1734710432; bh=1ZQb0ZqlBuM5Rzz5ZXbTKtufcYiEwQv0eRm+Ift9zAQ=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=ZdnRYYoSZ/fq4TNAiNloWHY8TZqAGZ6GBtfbWlyQU8FhlGfLBQfft2wkG8jlQ5mhT xzEpJSO8a2/XNMgsI6vnXMzqf2slltxAXsvbVnsQw1bXvWVlSbMqzxw1xIaGZgzess QunXTj4H371/yLsVAvw6hswwmixSC4t2QWSwNvy7lYA6TrWOAE0GWCunw7NNCenQtg FJCpG9dp777KF+bcZANk36edyb50GHEyamusEEIrhdk39JCVPCuEWbxRUuM2oqeaJG mxGJNL1SZPsY1zwG7DGRtzVx8qdzZw1eUqUmDJ8VeJpEHK8UFePBK8s272Fl0MHM85 93UAbk0FmLFfA== From: Davidlohr Bueso To: jonathan.cameron@huawei.com Cc: fan.ni@samsung.com, dan.j.williams@intel.com, a.manzanares@samsung.com, dave@stgolabs.net, linux-cxl@vger.kernel.org Subject: [PATCH 1/3] cxl: Fix mbox cmd enum order Date: Fri, 20 Dec 2024 08:00:24 -0800 Message-Id: <20241220160026.204055-2-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241220160026.204055-1-dave@stgolabs.net> References: <20241220160026.204055-1-dave@stgolabs.net> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move the out of place commands into their proper place. Signed-off-by: Davidlohr Bueso Reviewed-by: Fan Ni --- hw/cxl/cxl-mailbox-utils.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 9c7ea5bc35b8..f6f993e7bc4f 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -86,11 +86,6 @@ enum { #define GET_PARTITION_INFO 0x0 #define GET_LSA 0x2 #define SET_LSA 0x3 - SANITIZE = 0x44, - #define OVERWRITE 0x0 - #define SECURE_ERASE 0x1 - PERSISTENT_MEM = 0x45, - #define GET_SECURITY_STATE 0x0 MEDIA_AND_POISON = 0x43, #define GET_POISON_LIST 0x0 #define INJECT_POISON 0x1 @@ -98,6 +93,11 @@ enum { #define GET_SCAN_MEDIA_CAPABILITIES 0x3 #define SCAN_MEDIA 0x4 #define GET_SCAN_MEDIA_RESULTS 0x5 + SANITIZE = 0x44, + #define OVERWRITE 0x0 + #define SECURE_ERASE 0x1 + PERSISTENT_MEM = 0x45, + #define GET_SECURITY_STATE 0x0 DCD_CONFIG = 0x48, #define GET_DC_CONFIG 0x0 #define GET_DYN_CAP_EXT_LIST 0x1 From patchwork Fri Dec 20 16:00:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 13917062 Received: from cow.ash.relay.mailchannels.net (cow.ash.relay.mailchannels.net [23.83.222.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 552341BD9C1 for ; Fri, 20 Dec 2024 16:35:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=23.83.222.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734712547; cv=pass; b=B2mjFAr9scGDUGiMiJkEwxtbkNkTIH1xW59wavjlW8/muiGrH4LnzVyiidAg0Y3lwt5GPVn51jIunBq9q7/mPptnHnxHNBTYbk3jTkbA9h/lfANu3HRiYTFPniKZw760vrWRogNg1saj1gZPISpeboZ3DgdgoRCGL/WBskHYmhM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734712547; c=relaxed/simple; bh=7/0k3zlPdIIPEyAuemggOOTWNe5K1jGt79yneiZLZro=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gQcNvzFL/HGwUTpOclrk69+zaPeVt/s4BqNsUkjAv+ebLrse7rK2+kiQfyQr5xOWDQINGzHswj6tSSmbftnuRPAAL8rSfNs/yymKYRD5SjhvHYgYnfSWTDGGcZvMmF5KtB1Nvfjsq7NjcRVEyRc8lUaeLockmGTozt+KTD2PKyY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net; spf=pass smtp.mailfrom=stgolabs.net; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b=nYmq2Zn6; arc=pass smtp.client-ip=23.83.222.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b="nYmq2Zn6" X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 4A8B78A5660; Fri, 20 Dec 2024 16:00:33 +0000 (UTC) Received: from pdx1-sub0-mail-a227.dreamhost.com (trex-3.trex.outbound.svc.cluster.local [100.106.31.92]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id C95EF8A57E3; Fri, 20 Dec 2024 16:00:32 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1734710432; a=rsa-sha256; cv=none; b=0rIfRRrL032Zykyd0MLka7dpcT1GTVdPgRaJDYMr7KyahXYM4JvJfLPO9hokbLVoG76BBu 320KDd4p9p7RXk3nb3ebKRwPWFkuK27wxgB3xS1ufIYzpyF1/tAX7XMOoy0lamr6Dbg7aH UIwGzXvAgVPEbmDVh0TV/NdX7BlrIB/uF0gMBx5K7MNdJO74/0AXB2WhF6CFTTy3OuJd7E l6QWds9YfPMhF73mYGNB3Ei/J2wht83R9QKngLSwhreHh5MlYfUdZ87vJG5uberbFEOULU wq952MlUEwVDLL/vsSDZ1/xgG1AxkZEL1l9hx9D4153ajappTONEhYQcD+oWeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1734710432; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DsQjoTRE74IDjdNX6QiJDDO4vYhFj/8Q0CT2cCj/dfI=; b=w5m/dUgU5l+IPDAAji0bbUEg1kw8XGribO4ljM53tBDMsEj+auUM6OiSSK2djeJnP9kpKi c9CfGdppjzKqdgx5t/7SbI95lkUlLEg43gltEwPpEERBgDDKx6AdcxB+bM5ChFN1+R4BnK XqBcHXbpgW2qxg/802EDKc1fXPjL3IpoJPiP6hQXRFTXgAdPkLxOSrJZwqyo6/THU6dJ5x KAKQLhktrk+82nxJJVJn348HFdocTo5Eye4hQr7ppw3bXSJ41s0hM4w3zolbXXgyNJiSPO 9RZQGhoQzRB6auMXCgQol/HOrgjUjfjIYFGhVfgFKgtFy9DWUwh5NJKxVL/LvA== ARC-Authentication-Results: i=1; rspamd-56bf78cbd4-xt8j7; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Industry-Suffer: 6539ef50616dc8c5_1734710433064_1891154541 X-MC-Loop-Signature: 1734710433064:173551581 X-MC-Ingress-Time: 1734710433064 Received: from pdx1-sub0-mail-a227.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.106.31.92 (trex/7.0.2); Fri, 20 Dec 2024 16:00:33 +0000 Received: from localhost.localdomain (ip72-199-50-187.sd.sd.cox.net [72.199.50.187]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a227.dreamhost.com (Postfix) with ESMTPSA id 4YFBw01rMkzP4; Fri, 20 Dec 2024 08:00:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1734710432; bh=DsQjoTRE74IDjdNX6QiJDDO4vYhFj/8Q0CT2cCj/dfI=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=nYmq2Zn6zKDNoYE1NkWRxS9jvCZwNSC5BTp6p4HfRwGSCgXGSu1rY+JsdvXMVMFDn ugXv0BJ9kx+SfIT0pi2WymSwq6UyVzUnYUa8COOYs1kvghJVJKo1l3ymUT9xJ9flFY 1sgGneQVT4sbyAo9oxOqxz0JnNabEHKoulbCDeYjs1vCQat8/gBPgcO6N0n31CtKIs ny7K40ZwM0F4Xz/pcqAO49BMXRzG1Kb6yyGbzDXiBmcQGK2WRDrSIikvDrNCb+kXuv /Em0OJtH9N80csUKuYntZY1/UnB3+HqMrHcYLDZ1Gi+9Ae6FbwqwOESh5n9E2PAt50 5gboZbdKyJ2wQ== From: Davidlohr Bueso To: jonathan.cameron@huawei.com Cc: fan.ni@samsung.com, dan.j.williams@intel.com, a.manzanares@samsung.com, dave@stgolabs.net, linux-cxl@vger.kernel.org Subject: [PATCH 2/3] cxl: Support Get/Set Shutdown State commands Date: Fri, 20 Dec 2024 08:00:25 -0800 Message-Id: <20241220160026.204055-3-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241220160026.204055-1-dave@stgolabs.net> References: <20241220160026.204055-1-dave@stgolabs.net> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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; + + 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; + 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 */ From patchwork Fri Dec 20 16:00:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 13916960 Received: from skyblue.cherry.relay.mailchannels.net (skyblue.cherry.relay.mailchannels.net [23.83.223.167]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 779AC219A69 for ; Fri, 20 Dec 2024 16:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=23.83.223.167 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734710441; cv=pass; b=AtEHX14bqAGzFeB+cUwtsDABhcvcY2lQbBDpBEe+ICU0fhBF72xQMq8pBzMu/JCOCr4ZYkVYifB/LInsWaqYO5u1nvnzRkdoYyrNu2zTn004RWycSFgRdnriSVb85OLl8ksry+ez0WFvaMYPtl0fzdHLPIvMiVoaImuvFFG8yBk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734710441; c=relaxed/simple; bh=8/0QR5H/0ugk4v8OOMgePGi1P7spLl2HnKm8pyC8w1I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rnN/DJ2Gwie2g9xv8y7d7nyCoCGP04XyGzeIG6t1jU8qrui2BJoR3pNLHLVJ+So+43gr96PsdTTLUkU4KX4LbYuQPYUpB3k1WycqV24Vx0mWUbH9LCPSV10RjEv0PAG7CFf/byty3UROkfCXYnfWHv/utdMD1lrZItBEMVfoVgk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net; spf=pass smtp.mailfrom=stgolabs.net; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b=TRBm4wEL; arc=pass smtp.client-ip=23.83.223.167 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=stgolabs.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=stgolabs.net header.i=@stgolabs.net header.b="TRBm4wEL" X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id BCA48165851; Fri, 20 Dec 2024 16:00:33 +0000 (UTC) Received: from pdx1-sub0-mail-a227.dreamhost.com (trex-4.trex.outbound.svc.cluster.local [100.98.215.189]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 621F71655D0; Fri, 20 Dec 2024 16:00:33 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1734710433; a=rsa-sha256; cv=none; b=BB3XHZ17FDOuKTw4SgrH36nwGy3WXR9LCD05WDj9qw/YCWAQ3Bk2O4TKkpixHF0VwKoLoF krK/byMOZi+SMoxYJKvU2zTjv3NjG2c8CoFMkEYonSyG9/PvN5z6qnWjMqhQlzL6gqyMJk Pcnk4AaHICbbHGy3GTgfhQ8G7wn1tatf1+BdTQmqfaJxqRxBFaI5W3RwEZzStjMlYJKjx3 OEza9YlowtsSGP3FAQ1CghJ9XoFIXqNBSsjS0FF3h/gTDfxmsYCoJaIMpTeUbVDeP2WVz0 XndAz/n7AGPdQ3s1mPxAurLifbhwxjmf9AG3pChZ2wveybwdZUNXWF0bTvYzHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1734710433; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TPizwOQH8wCyHLTQDm0tGrZNM8iIbC+MwBmT1B8AqQ4=; b=c/4/n7R/4NHT6GM5awZVo5OOhu81PSpqYnwa5o03ucl4R5sr8pmRgduDTuWzcK1qYfyxJz lzaA/wMIyB37aVwSBteuEs4YfK6R5BSuvrq9koZq6TZy8aM9k6MDDHO4ftzBIBrk3mzWlw ZsfcjE1Z/CRtP/8h0Y3GTC032I9ZvgBrYiScmKFmAvIUYDMFCacnhJLz+e466z1jMDunLK /hcg3bB6onulsLz2xSsoSWrC++aY5yS5LTJyPa80n7WHjkPXI7MCCvHUWjZsieuSqxPfsB fi0j5iiejscceSxZH1JeGn/9ec4l5YoXnNh1JgDiuK7zBK57Lpj2spUXlpxToA== ARC-Authentication-Results: i=1; rspamd-56bf78cbd4-tsrbq; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Daffy-Harbor: 3c49838440615716_1734710433644_3144172135 X-MC-Loop-Signature: 1734710433644:956789053 X-MC-Ingress-Time: 1734710433644 Received: from pdx1-sub0-mail-a227.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.98.215.189 (trex/7.0.2); Fri, 20 Dec 2024 16:00:33 +0000 Received: from localhost.localdomain (ip72-199-50-187.sd.sd.cox.net [72.199.50.187]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a227.dreamhost.com (Postfix) with ESMTPSA id 4YFBw05v8BzCv; Fri, 20 Dec 2024 08:00:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1734710433; bh=TPizwOQH8wCyHLTQDm0tGrZNM8iIbC+MwBmT1B8AqQ4=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=TRBm4wELa3+rCyHCLsHUxUyCHt5b68SI25y02WVUUNbtpVBI0+V9WdnAOkyBLEUA2 wQUd3n8sT+8jhP/Ko+YCtDsZ2ghn/3cjBw2omnFwGpNfNOnOGp2NtzaBftA4Zy0Bf0 OB1scofMXs21cu+XyGlvB4Qr/wDWzyxFyKLOKXVj3+/RkJz80DVUK7X5et0mI6enV3 HwEo33QHvicrCxjH2dQy+cTJvyTKa5wUsU5J0tbgSPLDaGEEBaKTMxNHUGjXHDPfTX jRQwGiDV1tJv8sYMC1Hi+fjR7YXy3hcPAZohAEYsOPUSR18nrNIpPXIEbcWjUR3JI1 PnoKQU+oR5NBw== From: Davidlohr Bueso To: jonathan.cameron@huawei.com Cc: fan.ni@samsung.com, dan.j.williams@intel.com, a.manzanares@samsung.com, dave@stgolabs.net, linux-cxl@vger.kernel.org Subject: [PATCH 3/3] cxl/type3: Add 'dirty-shutdown' parameter Date: Fri, 20 Dec 2024 08:00:26 -0800 Message-Id: <20241220160026.204055-4-dave@stgolabs.net> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241220160026.204055-1-dave@stgolabs.net> References: <20241220160026.204055-1-dave@stgolabs.net> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a new parameter for type3 memory devices to set the dirty shutdown count to a specified value. This allows emulating failure paths and informing the admin of such event via the Get Health Info command. For example, upon a failed GPF, users can boot with dirty-shutdown=1 and with the cleared shutdown state, to emulate the hardware behavior. root@cxl:~# cxl list -m mem1 -H { "memdev":"mem1", "pmem_size":2147483648, "health":{ "maintenance_needed":false, "performance_degraded":false, "hw_replacement_needed":false, "media_normal":true, "media_not_ready":false, "media_persistence_lost":false, "media_data_lost":false, "media_powerloss_persistence_loss":false, "media_shutdown_persistence_loss":false, "media_persistence_loss_imminent":false, "media_powerloss_data_loss":false, "media_shutdown_data_loss":false, "media_data_loss_imminent":false, "ext_life_used":"normal", "ext_temperature":"normal", "ext_corrected_volatile":"normal", "ext_corrected_persistent":"normal", "life_used_percent":20, "temperature":30, "dirty_shutdowns":1, "volatile_errors":0, "pmem_errors":0 }, "serial":0, "host":"0000:0e:00.0" } Signed-off-by: Davidlohr Bueso --- hw/cxl/cxl-mailbox-utils.c | 32 ++++++++++++++++++++++++++++++++ hw/mem/cxl_type3.c | 1 + include/hw/cxl/cxl_device.h | 3 +++ 3 files changed, 36 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index ff1d3f50610c..85a58ab96bef 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -87,6 +87,7 @@ enum { #define GET_LSA 0x2 #define SET_LSA 0x3 HEALTH_INFO_ALERTS = 0x42, + #define GET_HEALTH_INFO 0x0 #define GET_SHUTDOWN_STATE 0x3 #define SET_SHUTDOWN_STATE 0x4 MEDIA_AND_POISON = 0x43, @@ -1724,6 +1725,35 @@ static CXLRetCode cmd_sanitize_overwrite(const struct cxl_cmd *cmd, return CXL_MBOX_BG_STARTED; } +/* CXL r3.2 Section 8.2.10.9.3.1: Get Shutdown State (Opcode 4200h) */ +static CXLRetCode cmd_health_get_health_info(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); + struct get_health_info_pl { + uint8_t health_status; + uint8_t media_status; + uint8_t additional_status; + uint8_t life_used; + uint16_t device_temperature; + uint32_t dirty_shutdown_count; + uint32_t corrected_volatile_error_count; + uint32_t corrected_persistent_error_count; + } QEMU_PACKED *out = (void *)payload_out; + + /* anything not set explicitly is considered under normal health */ + out->life_used = 20; + out->device_temperature = 30; + out->dirty_shutdown_count = ct3d->dirty_shutdown; + *len_out = sizeof(out); + + return CXL_MBOX_SUCCESS; +} + /* 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, @@ -2911,6 +2941,8 @@ 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_HEALTH_INFO] = { "HEALTH_INFO_ALERTS_GET_HEALTH_INFO", + cmd_health_get_health_info, 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", diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 5f365afb4dd1..e622eb9101ce 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1380,6 +1380,7 @@ static Property ct3_props[] = { TYPE_MEMORY_BACKEND, HostMemoryBackend *), DEFINE_PROP_LINK("lsa", CXLType3Dev, lsa, TYPE_MEMORY_BACKEND, HostMemoryBackend *), + DEFINE_PROP_UINT32("dirty-shutdown", CXLType3Dev, dirty_shutdown, 0), DEFINE_PROP_UINT64("sn", CXLType3Dev, sn, UI64_NULL), DEFINE_PROP_STRING("cdat", CXLType3Dev, cxl_cstate.cdat.filename), DEFINE_PROP_UINT8("num-dc-regions", CXLType3Dev, dc.num_regions, 0), diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 69e6330fe66d..f756e1a99f33 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -653,6 +653,9 @@ struct CXLType3Dev { uint8_t num_regions; /* 0-8 regions */ CXLDCRegion regions[DCD_MAX_NUM_REGION]; } dc; + + /* Dirty shutdown count */ + uint32_t dirty_shutdown; }; #define TYPE_CXL_TYPE3 "cxl-type3"