Skip to content

Commit 077ee5f

Browse files
shijujose4davejiang
authored andcommitted
cxl/edac: Add support for PERFORM_MAINTENANCE command
Add support for PERFORM_MAINTENANCE command. CXL spec 3.2 section 8.2.10.7.1 describes the Perform Maintenance command. This command requests the device to execute the maintenance operation specified by the maintenance operation class and the maintenance operation subclass. Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Signed-off-by: Shiju Jose <[email protected]> Reviewed-by: Alison Schofield <[email protected]> Acked-by: Dan Williams <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Dave Jiang <[email protected]>
1 parent 85fb6a1 commit 077ee5f

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

drivers/cxl/core/edac.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,55 @@ static int cxl_memdev_ecs_init(struct cxl_memdev *cxlmd,
813813
return 0;
814814
}
815815

816+
/*
817+
* Perform Maintenance CXL 3.2 Spec 8.2.10.7.1
818+
*/
819+
820+
/*
821+
* Perform Maintenance input payload
822+
* CXL rev 3.2 section 8.2.10.7.1 Table 8-117
823+
*/
824+
struct cxl_mbox_maintenance_hdr {
825+
u8 op_class;
826+
u8 op_subclass;
827+
} __packed;
828+
829+
static int cxl_perform_maintenance(struct cxl_mailbox *cxl_mbox, u8 class,
830+
u8 subclass, void *data_in,
831+
size_t data_in_size)
832+
{
833+
struct cxl_memdev_maintenance_pi {
834+
struct cxl_mbox_maintenance_hdr hdr;
835+
u8 data[];
836+
} __packed;
837+
struct cxl_mbox_cmd mbox_cmd;
838+
size_t hdr_size;
839+
840+
struct cxl_memdev_maintenance_pi *pi __free(kvfree) =
841+
kvzalloc(cxl_mbox->payload_size, GFP_KERNEL);
842+
if (!pi)
843+
return -ENOMEM;
844+
845+
pi->hdr.op_class = class;
846+
pi->hdr.op_subclass = subclass;
847+
hdr_size = sizeof(pi->hdr);
848+
/*
849+
* Check minimum mbox payload size is available for
850+
* the maintenance data transfer.
851+
*/
852+
if (hdr_size + data_in_size > cxl_mbox->payload_size)
853+
return -ENOMEM;
854+
855+
memcpy(pi->data, data_in, data_in_size);
856+
mbox_cmd = (struct cxl_mbox_cmd){
857+
.opcode = CXL_MBOX_OP_DO_MAINTENANCE,
858+
.size_in = hdr_size + data_in_size,
859+
.payload_in = pi,
860+
};
861+
862+
return cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
863+
}
864+
816865
int devm_cxl_memdev_edac_register(struct cxl_memdev *cxlmd)
817866
{
818867
struct edac_dev_feature ras_features[CXL_NR_EDAC_DEV_FEATURES];

drivers/cxl/cxlmem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ enum cxl_opcode {
531531
CXL_MBOX_OP_GET_SUPPORTED_FEATURES = 0x0500,
532532
CXL_MBOX_OP_GET_FEATURE = 0x0501,
533533
CXL_MBOX_OP_SET_FEATURE = 0x0502,
534+
CXL_MBOX_OP_DO_MAINTENANCE = 0x0600,
534535
CXL_MBOX_OP_IDENTIFY = 0x4000,
535536
CXL_MBOX_OP_GET_PARTITION_INFO = 0x4100,
536537
CXL_MBOX_OP_SET_PARTITION_INFO = 0x4101,

0 commit comments

Comments
 (0)