Commit b5209da3 authored by Dave Jiang's avatar Dave Jiang

cxl: Convert cxl_internal_send_cmd() to use 'struct cxl_mailbox' as input

With the CXL mailbox context split out, cxl_internal_send_cmd() can take
'struct cxl_mailbox' as an input parameter rather than
'struct memdev_dev_state'. Change input parameter for
cxl_internal_send_cmd() and fixup all impacted call sites.
Reviewed-by: default avatarFan Ni <fan.ni@samsung.com>
Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: default avatarAlison Schofield <alison.schofield@intel.com>
Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
Link: https://patch.msgid.link/20240905223711.1990186-4-dave.jiang@intel.comSigned-off-by: default avatarDave Jiang <dave.jiang@intel.com>
parent 8d8081ce
...@@ -225,7 +225,7 @@ static const char *cxl_mem_opcode_to_name(u16 opcode) ...@@ -225,7 +225,7 @@ static const char *cxl_mem_opcode_to_name(u16 opcode)
/** /**
* cxl_internal_send_cmd() - Kernel internal interface to send a mailbox command * cxl_internal_send_cmd() - Kernel internal interface to send a mailbox command
* @mds: The driver data for the operation * @cxl_mbox: CXL mailbox context
* @mbox_cmd: initialized command to execute * @mbox_cmd: initialized command to execute
* *
* Context: Any context. * Context: Any context.
...@@ -241,10 +241,9 @@ static const char *cxl_mem_opcode_to_name(u16 opcode) ...@@ -241,10 +241,9 @@ static const char *cxl_mem_opcode_to_name(u16 opcode)
* error. While this distinction can be useful for commands from userspace, the * error. While this distinction can be useful for commands from userspace, the
* kernel will only be able to use results when both are successful. * kernel will only be able to use results when both are successful.
*/ */
int cxl_internal_send_cmd(struct cxl_memdev_state *mds, int cxl_internal_send_cmd(struct cxl_mailbox *cxl_mbox,
struct cxl_mbox_cmd *mbox_cmd) struct cxl_mbox_cmd *mbox_cmd)
{ {
struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox;
size_t out_size, min_out; size_t out_size, min_out;
int rc; int rc;
...@@ -689,7 +688,7 @@ static int cxl_xfer_log(struct cxl_memdev_state *mds, uuid_t *uuid, ...@@ -689,7 +688,7 @@ static int cxl_xfer_log(struct cxl_memdev_state *mds, uuid_t *uuid,
.payload_out = out, .payload_out = out,
}; };
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
/* /*
* The output payload length that indicates the number * The output payload length that indicates the number
...@@ -775,7 +774,7 @@ static struct cxl_mbox_get_supported_logs *cxl_get_gsl(struct cxl_memdev_state * ...@@ -775,7 +774,7 @@ static struct cxl_mbox_get_supported_logs *cxl_get_gsl(struct cxl_memdev_state *
/* At least the record number field must be valid */ /* At least the record number field must be valid */
.min_out = 2, .min_out = 2,
}; };
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc < 0) { if (rc < 0) {
kvfree(ret); kvfree(ret);
return ERR_PTR(rc); return ERR_PTR(rc);
...@@ -964,7 +963,7 @@ static int cxl_clear_event_record(struct cxl_memdev_state *mds, ...@@ -964,7 +963,7 @@ static int cxl_clear_event_record(struct cxl_memdev_state *mds,
if (i == max_handles) { if (i == max_handles) {
payload->nr_recs = i; payload->nr_recs = i;
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc) if (rc)
goto free_pl; goto free_pl;
i = 0; i = 0;
...@@ -975,7 +974,7 @@ static int cxl_clear_event_record(struct cxl_memdev_state *mds, ...@@ -975,7 +974,7 @@ static int cxl_clear_event_record(struct cxl_memdev_state *mds,
if (i) { if (i) {
payload->nr_recs = i; payload->nr_recs = i;
mbox_cmd.size_in = struct_size(payload, handles, i); mbox_cmd.size_in = struct_size(payload, handles, i);
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc) if (rc)
goto free_pl; goto free_pl;
} }
...@@ -1009,7 +1008,7 @@ static void cxl_mem_get_records_log(struct cxl_memdev_state *mds, ...@@ -1009,7 +1008,7 @@ static void cxl_mem_get_records_log(struct cxl_memdev_state *mds,
.min_out = struct_size(payload, records, 0), .min_out = struct_size(payload, records, 0),
}; };
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc) { if (rc) {
dev_err_ratelimited(dev, dev_err_ratelimited(dev,
"Event log '%d': Failed to query event records : %d", "Event log '%d': Failed to query event records : %d",
...@@ -1080,6 +1079,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_mem_get_event_records, CXL); ...@@ -1080,6 +1079,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_mem_get_event_records, CXL);
*/ */
static int cxl_mem_get_partition_info(struct cxl_memdev_state *mds) static int cxl_mem_get_partition_info(struct cxl_memdev_state *mds)
{ {
struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox;
struct cxl_mbox_get_partition_info pi; struct cxl_mbox_get_partition_info pi;
struct cxl_mbox_cmd mbox_cmd; struct cxl_mbox_cmd mbox_cmd;
int rc; int rc;
...@@ -1089,7 +1089,7 @@ static int cxl_mem_get_partition_info(struct cxl_memdev_state *mds) ...@@ -1089,7 +1089,7 @@ static int cxl_mem_get_partition_info(struct cxl_memdev_state *mds)
.size_out = sizeof(pi), .size_out = sizeof(pi),
.payload_out = &pi, .payload_out = &pi,
}; };
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc) if (rc)
return rc; return rc;
...@@ -1116,6 +1116,7 @@ static int cxl_mem_get_partition_info(struct cxl_memdev_state *mds) ...@@ -1116,6 +1116,7 @@ static int cxl_mem_get_partition_info(struct cxl_memdev_state *mds)
*/ */
int cxl_dev_state_identify(struct cxl_memdev_state *mds) int cxl_dev_state_identify(struct cxl_memdev_state *mds)
{ {
struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox;
/* See CXL 2.0 Table 175 Identify Memory Device Output Payload */ /* See CXL 2.0 Table 175 Identify Memory Device Output Payload */
struct cxl_mbox_identify id; struct cxl_mbox_identify id;
struct cxl_mbox_cmd mbox_cmd; struct cxl_mbox_cmd mbox_cmd;
...@@ -1130,7 +1131,7 @@ int cxl_dev_state_identify(struct cxl_memdev_state *mds) ...@@ -1130,7 +1131,7 @@ int cxl_dev_state_identify(struct cxl_memdev_state *mds)
.size_out = sizeof(id), .size_out = sizeof(id),
.payload_out = &id, .payload_out = &id,
}; };
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc < 0) if (rc < 0)
return rc; return rc;
...@@ -1158,6 +1159,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_dev_state_identify, CXL); ...@@ -1158,6 +1159,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_dev_state_identify, CXL);
static int __cxl_mem_sanitize(struct cxl_memdev_state *mds, u16 cmd) static int __cxl_mem_sanitize(struct cxl_memdev_state *mds, u16 cmd)
{ {
struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox;
int rc; int rc;
u32 sec_out = 0; u32 sec_out = 0;
struct cxl_get_security_output { struct cxl_get_security_output {
...@@ -1169,14 +1171,13 @@ static int __cxl_mem_sanitize(struct cxl_memdev_state *mds, u16 cmd) ...@@ -1169,14 +1171,13 @@ static int __cxl_mem_sanitize(struct cxl_memdev_state *mds, u16 cmd)
.size_out = sizeof(out), .size_out = sizeof(out),
}; };
struct cxl_mbox_cmd mbox_cmd = { .opcode = cmd }; struct cxl_mbox_cmd mbox_cmd = { .opcode = cmd };
struct cxl_dev_state *cxlds = &mds->cxlds;
if (cmd != CXL_MBOX_OP_SANITIZE && cmd != CXL_MBOX_OP_SECURE_ERASE) if (cmd != CXL_MBOX_OP_SANITIZE && cmd != CXL_MBOX_OP_SECURE_ERASE)
return -EINVAL; return -EINVAL;
rc = cxl_internal_send_cmd(mds, &sec_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &sec_cmd);
if (rc < 0) { if (rc < 0) {
dev_err(cxlds->dev, "Failed to get security state : %d", rc); dev_err(cxl_mbox->host, "Failed to get security state : %d", rc);
return rc; return rc;
} }
...@@ -1193,9 +1194,9 @@ static int __cxl_mem_sanitize(struct cxl_memdev_state *mds, u16 cmd) ...@@ -1193,9 +1194,9 @@ static int __cxl_mem_sanitize(struct cxl_memdev_state *mds, u16 cmd)
sec_out & CXL_PMEM_SEC_STATE_LOCKED) sec_out & CXL_PMEM_SEC_STATE_LOCKED)
return -EINVAL; return -EINVAL;
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc < 0) { if (rc < 0) {
dev_err(cxlds->dev, "Failed to sanitize device : %d", rc); dev_err(cxl_mbox->host, "Failed to sanitize device : %d", rc);
return rc; return rc;
} }
...@@ -1309,6 +1310,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_mem_create_range_info, CXL); ...@@ -1309,6 +1310,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_mem_create_range_info, CXL);
int cxl_set_timestamp(struct cxl_memdev_state *mds) int cxl_set_timestamp(struct cxl_memdev_state *mds)
{ {
struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox;
struct cxl_mbox_cmd mbox_cmd; struct cxl_mbox_cmd mbox_cmd;
struct cxl_mbox_set_timestamp_in pi; struct cxl_mbox_set_timestamp_in pi;
int rc; int rc;
...@@ -1320,7 +1322,7 @@ int cxl_set_timestamp(struct cxl_memdev_state *mds) ...@@ -1320,7 +1322,7 @@ int cxl_set_timestamp(struct cxl_memdev_state *mds)
.payload_in = &pi, .payload_in = &pi,
}; };
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
/* /*
* Command is optional. Devices may have another way of providing * Command is optional. Devices may have another way of providing
* a timestamp, or may return all 0s in timestamp fields. * a timestamp, or may return all 0s in timestamp fields.
...@@ -1337,7 +1339,7 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len, ...@@ -1337,7 +1339,7 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,
struct cxl_region *cxlr) struct cxl_region *cxlr)
{ {
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds); struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds);
struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox; struct cxl_mailbox *cxl_mbox = &cxlmd->cxlds->cxl_mbox;
struct cxl_mbox_poison_out *po; struct cxl_mbox_poison_out *po;
struct cxl_mbox_poison_in pi; struct cxl_mbox_poison_in pi;
int nr_records = 0; int nr_records = 0;
...@@ -1361,7 +1363,7 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len, ...@@ -1361,7 +1363,7 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,
.min_out = struct_size(po, record, 0), .min_out = struct_size(po, record, 0),
}; };
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc) if (rc)
break; break;
......
...@@ -278,7 +278,7 @@ static int cxl_validate_poison_dpa(struct cxl_memdev *cxlmd, u64 dpa) ...@@ -278,7 +278,7 @@ static int cxl_validate_poison_dpa(struct cxl_memdev *cxlmd, u64 dpa)
int cxl_inject_poison(struct cxl_memdev *cxlmd, u64 dpa) int cxl_inject_poison(struct cxl_memdev *cxlmd, u64 dpa)
{ {
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds); struct cxl_mailbox *cxl_mbox = &cxlmd->cxlds->cxl_mbox;
struct cxl_mbox_inject_poison inject; struct cxl_mbox_inject_poison inject;
struct cxl_poison_record record; struct cxl_poison_record record;
struct cxl_mbox_cmd mbox_cmd; struct cxl_mbox_cmd mbox_cmd;
...@@ -308,13 +308,13 @@ int cxl_inject_poison(struct cxl_memdev *cxlmd, u64 dpa) ...@@ -308,13 +308,13 @@ int cxl_inject_poison(struct cxl_memdev *cxlmd, u64 dpa)
.size_in = sizeof(inject), .size_in = sizeof(inject),
.payload_in = &inject, .payload_in = &inject,
}; };
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc) if (rc)
goto out; goto out;
cxlr = cxl_dpa_to_region(cxlmd, dpa); cxlr = cxl_dpa_to_region(cxlmd, dpa);
if (cxlr) if (cxlr)
dev_warn_once(mds->cxlds.dev, dev_warn_once(cxl_mbox->host,
"poison inject dpa:%#llx region: %s\n", dpa, "poison inject dpa:%#llx region: %s\n", dpa,
dev_name(&cxlr->dev)); dev_name(&cxlr->dev));
...@@ -333,7 +333,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_inject_poison, CXL); ...@@ -333,7 +333,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_inject_poison, CXL);
int cxl_clear_poison(struct cxl_memdev *cxlmd, u64 dpa) int cxl_clear_poison(struct cxl_memdev *cxlmd, u64 dpa)
{ {
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds); struct cxl_mailbox *cxl_mbox = &cxlmd->cxlds->cxl_mbox;
struct cxl_mbox_clear_poison clear; struct cxl_mbox_clear_poison clear;
struct cxl_poison_record record; struct cxl_poison_record record;
struct cxl_mbox_cmd mbox_cmd; struct cxl_mbox_cmd mbox_cmd;
...@@ -372,13 +372,13 @@ int cxl_clear_poison(struct cxl_memdev *cxlmd, u64 dpa) ...@@ -372,13 +372,13 @@ int cxl_clear_poison(struct cxl_memdev *cxlmd, u64 dpa)
.payload_in = &clear, .payload_in = &clear,
}; };
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc) if (rc)
goto out; goto out;
cxlr = cxl_dpa_to_region(cxlmd, dpa); cxlr = cxl_dpa_to_region(cxlmd, dpa);
if (cxlr) if (cxlr)
dev_warn_once(mds->cxlds.dev, dev_warn_once(cxl_mbox->host,
"poison clear dpa:%#llx region: %s\n", dpa, "poison clear dpa:%#llx region: %s\n", dpa,
dev_name(&cxlr->dev)); dev_name(&cxlr->dev));
...@@ -715,6 +715,7 @@ static int cxl_memdev_release_file(struct inode *inode, struct file *file) ...@@ -715,6 +715,7 @@ static int cxl_memdev_release_file(struct inode *inode, struct file *file)
*/ */
static int cxl_mem_get_fw_info(struct cxl_memdev_state *mds) static int cxl_mem_get_fw_info(struct cxl_memdev_state *mds)
{ {
struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox;
struct cxl_mbox_get_fw_info info; struct cxl_mbox_get_fw_info info;
struct cxl_mbox_cmd mbox_cmd; struct cxl_mbox_cmd mbox_cmd;
int rc; int rc;
...@@ -725,7 +726,7 @@ static int cxl_mem_get_fw_info(struct cxl_memdev_state *mds) ...@@ -725,7 +726,7 @@ static int cxl_mem_get_fw_info(struct cxl_memdev_state *mds)
.payload_out = &info, .payload_out = &info,
}; };
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc < 0) if (rc < 0)
return rc; return rc;
...@@ -749,6 +750,7 @@ static int cxl_mem_get_fw_info(struct cxl_memdev_state *mds) ...@@ -749,6 +750,7 @@ static int cxl_mem_get_fw_info(struct cxl_memdev_state *mds)
*/ */
static int cxl_mem_activate_fw(struct cxl_memdev_state *mds, int slot) static int cxl_mem_activate_fw(struct cxl_memdev_state *mds, int slot)
{ {
struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox;
struct cxl_mbox_activate_fw activate; struct cxl_mbox_activate_fw activate;
struct cxl_mbox_cmd mbox_cmd; struct cxl_mbox_cmd mbox_cmd;
...@@ -765,7 +767,7 @@ static int cxl_mem_activate_fw(struct cxl_memdev_state *mds, int slot) ...@@ -765,7 +767,7 @@ static int cxl_mem_activate_fw(struct cxl_memdev_state *mds, int slot)
activate.action = CXL_FW_ACTIVATE_OFFLINE; activate.action = CXL_FW_ACTIVATE_OFFLINE;
activate.slot = slot; activate.slot = slot;
return cxl_internal_send_cmd(mds, &mbox_cmd); return cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
} }
/** /**
...@@ -780,6 +782,7 @@ static int cxl_mem_activate_fw(struct cxl_memdev_state *mds, int slot) ...@@ -780,6 +782,7 @@ static int cxl_mem_activate_fw(struct cxl_memdev_state *mds, int slot)
*/ */
static int cxl_mem_abort_fw_xfer(struct cxl_memdev_state *mds) static int cxl_mem_abort_fw_xfer(struct cxl_memdev_state *mds)
{ {
struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox;
struct cxl_mbox_transfer_fw *transfer; struct cxl_mbox_transfer_fw *transfer;
struct cxl_mbox_cmd mbox_cmd; struct cxl_mbox_cmd mbox_cmd;
int rc; int rc;
...@@ -799,7 +802,7 @@ static int cxl_mem_abort_fw_xfer(struct cxl_memdev_state *mds) ...@@ -799,7 +802,7 @@ static int cxl_mem_abort_fw_xfer(struct cxl_memdev_state *mds)
transfer->action = CXL_FW_TRANSFER_ACTION_ABORT; transfer->action = CXL_FW_TRANSFER_ACTION_ABORT;
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
kfree(transfer); kfree(transfer);
return rc; return rc;
} }
...@@ -924,7 +927,7 @@ static enum fw_upload_err cxl_fw_write(struct fw_upload *fwl, const u8 *data, ...@@ -924,7 +927,7 @@ static enum fw_upload_err cxl_fw_write(struct fw_upload *fwl, const u8 *data,
.poll_count = 30, .poll_count = 30,
}; };
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc < 0) { if (rc < 0) {
rc = FW_UPLOAD_ERR_RW_ERROR; rc = FW_UPLOAD_ERR_RW_ERROR;
goto out_free; goto out_free;
......
...@@ -811,7 +811,7 @@ enum { ...@@ -811,7 +811,7 @@ enum {
CXL_PMEM_SEC_PASS_USER, CXL_PMEM_SEC_PASS_USER,
}; };
int cxl_internal_send_cmd(struct cxl_memdev_state *mds, int cxl_internal_send_cmd(struct cxl_mailbox *cxl_mbox,
struct cxl_mbox_cmd *cmd); struct cxl_mbox_cmd *cmd);
int cxl_dev_state_identify(struct cxl_memdev_state *mds); int cxl_dev_state_identify(struct cxl_memdev_state *mds);
int cxl_await_media_ready(struct cxl_dev_state *cxlds); int cxl_await_media_ready(struct cxl_dev_state *cxlds);
......
...@@ -655,6 +655,7 @@ static int cxl_event_req_irq(struct cxl_dev_state *cxlds, u8 setting) ...@@ -655,6 +655,7 @@ static int cxl_event_req_irq(struct cxl_dev_state *cxlds, u8 setting)
static int cxl_event_get_int_policy(struct cxl_memdev_state *mds, static int cxl_event_get_int_policy(struct cxl_memdev_state *mds,
struct cxl_event_interrupt_policy *policy) struct cxl_event_interrupt_policy *policy)
{ {
struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox;
struct cxl_mbox_cmd mbox_cmd = { struct cxl_mbox_cmd mbox_cmd = {
.opcode = CXL_MBOX_OP_GET_EVT_INT_POLICY, .opcode = CXL_MBOX_OP_GET_EVT_INT_POLICY,
.payload_out = policy, .payload_out = policy,
...@@ -662,7 +663,7 @@ static int cxl_event_get_int_policy(struct cxl_memdev_state *mds, ...@@ -662,7 +663,7 @@ static int cxl_event_get_int_policy(struct cxl_memdev_state *mds,
}; };
int rc; int rc;
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc < 0) if (rc < 0)
dev_err(mds->cxlds.dev, dev_err(mds->cxlds.dev,
"Failed to get event interrupt policy : %d", rc); "Failed to get event interrupt policy : %d", rc);
...@@ -673,6 +674,7 @@ static int cxl_event_get_int_policy(struct cxl_memdev_state *mds, ...@@ -673,6 +674,7 @@ static int cxl_event_get_int_policy(struct cxl_memdev_state *mds,
static int cxl_event_config_msgnums(struct cxl_memdev_state *mds, static int cxl_event_config_msgnums(struct cxl_memdev_state *mds,
struct cxl_event_interrupt_policy *policy) struct cxl_event_interrupt_policy *policy)
{ {
struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox;
struct cxl_mbox_cmd mbox_cmd; struct cxl_mbox_cmd mbox_cmd;
int rc; int rc;
...@@ -689,7 +691,7 @@ static int cxl_event_config_msgnums(struct cxl_memdev_state *mds, ...@@ -689,7 +691,7 @@ static int cxl_event_config_msgnums(struct cxl_memdev_state *mds,
.size_in = sizeof(*policy), .size_in = sizeof(*policy),
}; };
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc < 0) { if (rc < 0) {
dev_err(mds->cxlds.dev, "Failed to set event interrupt policy : %d", dev_err(mds->cxlds.dev, "Failed to set event interrupt policy : %d",
rc); rc);
......
...@@ -120,6 +120,7 @@ static int cxl_pmem_get_config_data(struct cxl_memdev_state *mds, ...@@ -120,6 +120,7 @@ static int cxl_pmem_get_config_data(struct cxl_memdev_state *mds,
struct nd_cmd_get_config_data_hdr *cmd, struct nd_cmd_get_config_data_hdr *cmd,
unsigned int buf_len) unsigned int buf_len)
{ {
struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox;
struct cxl_mbox_get_lsa get_lsa; struct cxl_mbox_get_lsa get_lsa;
struct cxl_mbox_cmd mbox_cmd; struct cxl_mbox_cmd mbox_cmd;
int rc; int rc;
...@@ -141,7 +142,7 @@ static int cxl_pmem_get_config_data(struct cxl_memdev_state *mds, ...@@ -141,7 +142,7 @@ static int cxl_pmem_get_config_data(struct cxl_memdev_state *mds,
.payload_out = cmd->out_buf, .payload_out = cmd->out_buf,
}; };
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
cmd->status = 0; cmd->status = 0;
return rc; return rc;
...@@ -151,6 +152,7 @@ static int cxl_pmem_set_config_data(struct cxl_memdev_state *mds, ...@@ -151,6 +152,7 @@ static int cxl_pmem_set_config_data(struct cxl_memdev_state *mds,
struct nd_cmd_set_config_hdr *cmd, struct nd_cmd_set_config_hdr *cmd,
unsigned int buf_len) unsigned int buf_len)
{ {
struct cxl_mailbox *cxl_mbox = &mds->cxlds.cxl_mbox;
struct cxl_mbox_set_lsa *set_lsa; struct cxl_mbox_set_lsa *set_lsa;
struct cxl_mbox_cmd mbox_cmd; struct cxl_mbox_cmd mbox_cmd;
int rc; int rc;
...@@ -177,7 +179,7 @@ static int cxl_pmem_set_config_data(struct cxl_memdev_state *mds, ...@@ -177,7 +179,7 @@ static int cxl_pmem_set_config_data(struct cxl_memdev_state *mds,
.size_in = struct_size(set_lsa, data, cmd->in_length), .size_in = struct_size(set_lsa, data, cmd->in_length),
}; };
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
/* /*
* Set "firmware" status (4-packed bytes at the end of the input * Set "firmware" status (4-packed bytes at the end of the input
......
...@@ -14,6 +14,7 @@ static unsigned long cxl_pmem_get_security_flags(struct nvdimm *nvdimm, ...@@ -14,6 +14,7 @@ static unsigned long cxl_pmem_get_security_flags(struct nvdimm *nvdimm,
{ {
struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm); struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm);
struct cxl_memdev *cxlmd = cxl_nvd->cxlmd; struct cxl_memdev *cxlmd = cxl_nvd->cxlmd;
struct cxl_mailbox *cxl_mbox = &cxlmd->cxlds->cxl_mbox;
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds); struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds);
unsigned long security_flags = 0; unsigned long security_flags = 0;
struct cxl_get_security_output { struct cxl_get_security_output {
...@@ -29,7 +30,7 @@ static unsigned long cxl_pmem_get_security_flags(struct nvdimm *nvdimm, ...@@ -29,7 +30,7 @@ static unsigned long cxl_pmem_get_security_flags(struct nvdimm *nvdimm,
.payload_out = &out, .payload_out = &out,
}; };
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc < 0) if (rc < 0)
return 0; return 0;
...@@ -70,7 +71,7 @@ static int cxl_pmem_security_change_key(struct nvdimm *nvdimm, ...@@ -70,7 +71,7 @@ static int cxl_pmem_security_change_key(struct nvdimm *nvdimm,
{ {
struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm); struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm);
struct cxl_memdev *cxlmd = cxl_nvd->cxlmd; struct cxl_memdev *cxlmd = cxl_nvd->cxlmd;
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds); struct cxl_mailbox *cxl_mbox = &cxlmd->cxlds->cxl_mbox;
struct cxl_mbox_cmd mbox_cmd; struct cxl_mbox_cmd mbox_cmd;
struct cxl_set_pass set_pass; struct cxl_set_pass set_pass;
...@@ -87,7 +88,7 @@ static int cxl_pmem_security_change_key(struct nvdimm *nvdimm, ...@@ -87,7 +88,7 @@ static int cxl_pmem_security_change_key(struct nvdimm *nvdimm,
.payload_in = &set_pass, .payload_in = &set_pass,
}; };
return cxl_internal_send_cmd(mds, &mbox_cmd); return cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
} }
static int __cxl_pmem_security_disable(struct nvdimm *nvdimm, static int __cxl_pmem_security_disable(struct nvdimm *nvdimm,
...@@ -96,7 +97,7 @@ static int __cxl_pmem_security_disable(struct nvdimm *nvdimm, ...@@ -96,7 +97,7 @@ static int __cxl_pmem_security_disable(struct nvdimm *nvdimm,
{ {
struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm); struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm);
struct cxl_memdev *cxlmd = cxl_nvd->cxlmd; struct cxl_memdev *cxlmd = cxl_nvd->cxlmd;
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds); struct cxl_mailbox *cxl_mbox = &cxlmd->cxlds->cxl_mbox;
struct cxl_disable_pass dis_pass; struct cxl_disable_pass dis_pass;
struct cxl_mbox_cmd mbox_cmd; struct cxl_mbox_cmd mbox_cmd;
...@@ -112,7 +113,7 @@ static int __cxl_pmem_security_disable(struct nvdimm *nvdimm, ...@@ -112,7 +113,7 @@ static int __cxl_pmem_security_disable(struct nvdimm *nvdimm,
.payload_in = &dis_pass, .payload_in = &dis_pass,
}; };
return cxl_internal_send_cmd(mds, &mbox_cmd); return cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
} }
static int cxl_pmem_security_disable(struct nvdimm *nvdimm, static int cxl_pmem_security_disable(struct nvdimm *nvdimm,
...@@ -131,12 +132,12 @@ static int cxl_pmem_security_freeze(struct nvdimm *nvdimm) ...@@ -131,12 +132,12 @@ static int cxl_pmem_security_freeze(struct nvdimm *nvdimm)
{ {
struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm); struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm);
struct cxl_memdev *cxlmd = cxl_nvd->cxlmd; struct cxl_memdev *cxlmd = cxl_nvd->cxlmd;
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds); struct cxl_mailbox *cxl_mbox = &cxlmd->cxlds->cxl_mbox;
struct cxl_mbox_cmd mbox_cmd = { struct cxl_mbox_cmd mbox_cmd = {
.opcode = CXL_MBOX_OP_FREEZE_SECURITY, .opcode = CXL_MBOX_OP_FREEZE_SECURITY,
}; };
return cxl_internal_send_cmd(mds, &mbox_cmd); return cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
} }
static int cxl_pmem_security_unlock(struct nvdimm *nvdimm, static int cxl_pmem_security_unlock(struct nvdimm *nvdimm,
...@@ -144,7 +145,7 @@ static int cxl_pmem_security_unlock(struct nvdimm *nvdimm, ...@@ -144,7 +145,7 @@ static int cxl_pmem_security_unlock(struct nvdimm *nvdimm,
{ {
struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm); struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm);
struct cxl_memdev *cxlmd = cxl_nvd->cxlmd; struct cxl_memdev *cxlmd = cxl_nvd->cxlmd;
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds); struct cxl_mailbox *cxl_mbox = &cxlmd->cxlds->cxl_mbox;
u8 pass[NVDIMM_PASSPHRASE_LEN]; u8 pass[NVDIMM_PASSPHRASE_LEN];
struct cxl_mbox_cmd mbox_cmd; struct cxl_mbox_cmd mbox_cmd;
int rc; int rc;
...@@ -156,7 +157,7 @@ static int cxl_pmem_security_unlock(struct nvdimm *nvdimm, ...@@ -156,7 +157,7 @@ static int cxl_pmem_security_unlock(struct nvdimm *nvdimm,
.payload_in = pass, .payload_in = pass,
}; };
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc < 0) if (rc < 0)
return rc; return rc;
...@@ -169,7 +170,7 @@ static int cxl_pmem_security_passphrase_erase(struct nvdimm *nvdimm, ...@@ -169,7 +170,7 @@ static int cxl_pmem_security_passphrase_erase(struct nvdimm *nvdimm,
{ {
struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm); struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm);
struct cxl_memdev *cxlmd = cxl_nvd->cxlmd; struct cxl_memdev *cxlmd = cxl_nvd->cxlmd;
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds); struct cxl_mailbox *cxl_mbox = &cxlmd->cxlds->cxl_mbox;
struct cxl_mbox_cmd mbox_cmd; struct cxl_mbox_cmd mbox_cmd;
struct cxl_pass_erase erase; struct cxl_pass_erase erase;
int rc; int rc;
...@@ -185,7 +186,7 @@ static int cxl_pmem_security_passphrase_erase(struct nvdimm *nvdimm, ...@@ -185,7 +186,7 @@ static int cxl_pmem_security_passphrase_erase(struct nvdimm *nvdimm,
.payload_in = &erase, .payload_in = &erase,
}; };
rc = cxl_internal_send_cmd(mds, &mbox_cmd); rc = cxl_internal_send_cmd(cxl_mbox, &mbox_cmd);
if (rc < 0) if (rc < 0)
return rc; return rc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment