@@ -225,7 +225,7 @@ static const char *cxl_mem_opcode_to_name(u16 opcode)
225225
226226/**
227227 * cxl_internal_send_cmd() - Kernel internal interface to send a mailbox command
228- * @mds: The driver data for the operation
228+ * @cxl_mbox: CXL mailbox context
229229 * @mbox_cmd: initialized command to execute
230230 *
231231 * Context: Any context.
@@ -241,10 +241,9 @@ static const char *cxl_mem_opcode_to_name(u16 opcode)
241241 * error. While this distinction can be useful for commands from userspace, the
242242 * kernel will only be able to use results when both are successful.
243243 */
244- int cxl_internal_send_cmd (struct cxl_memdev_state * mds ,
244+ int cxl_internal_send_cmd (struct cxl_mailbox * cxl_mbox ,
245245 struct cxl_mbox_cmd * mbox_cmd )
246246{
247- struct cxl_mailbox * cxl_mbox = & mds -> cxlds .cxl_mbox ;
248247 size_t out_size , min_out ;
249248 int rc ;
250249
@@ -689,7 +688,7 @@ static int cxl_xfer_log(struct cxl_memdev_state *mds, uuid_t *uuid,
689688 .payload_out = out ,
690689 };
691690
692- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
691+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
693692
694693 /*
695694 * 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 *
775774 /* At least the record number field must be valid */
776775 .min_out = 2 ,
777776 };
778- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
777+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
779778 if (rc < 0 ) {
780779 kvfree (ret );
781780 return ERR_PTR (rc );
@@ -964,7 +963,7 @@ static int cxl_clear_event_record(struct cxl_memdev_state *mds,
964963
965964 if (i == max_handles ) {
966965 payload -> nr_recs = i ;
967- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
966+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
968967 if (rc )
969968 goto free_pl ;
970969 i = 0 ;
@@ -975,7 +974,7 @@ static int cxl_clear_event_record(struct cxl_memdev_state *mds,
975974 if (i ) {
976975 payload -> nr_recs = i ;
977976 mbox_cmd .size_in = struct_size (payload , handles , i );
978- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
977+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
979978 if (rc )
980979 goto free_pl ;
981980 }
@@ -1009,7 +1008,7 @@ static void cxl_mem_get_records_log(struct cxl_memdev_state *mds,
10091008 .min_out = struct_size (payload , records , 0 ),
10101009 };
10111010
1012- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
1011+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
10131012 if (rc ) {
10141013 dev_err_ratelimited (dev ,
10151014 "Event log '%d': Failed to query event records : %d" ,
@@ -1080,6 +1079,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_mem_get_event_records, CXL);
10801079 */
10811080static int cxl_mem_get_partition_info (struct cxl_memdev_state * mds )
10821081{
1082+ struct cxl_mailbox * cxl_mbox = & mds -> cxlds .cxl_mbox ;
10831083 struct cxl_mbox_get_partition_info pi ;
10841084 struct cxl_mbox_cmd mbox_cmd ;
10851085 int rc ;
@@ -1089,7 +1089,7 @@ static int cxl_mem_get_partition_info(struct cxl_memdev_state *mds)
10891089 .size_out = sizeof (pi ),
10901090 .payload_out = & pi ,
10911091 };
1092- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
1092+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
10931093 if (rc )
10941094 return rc ;
10951095
@@ -1116,6 +1116,7 @@ static int cxl_mem_get_partition_info(struct cxl_memdev_state *mds)
11161116 */
11171117int cxl_dev_state_identify (struct cxl_memdev_state * mds )
11181118{
1119+ struct cxl_mailbox * cxl_mbox = & mds -> cxlds .cxl_mbox ;
11191120 /* See CXL 2.0 Table 175 Identify Memory Device Output Payload */
11201121 struct cxl_mbox_identify id ;
11211122 struct cxl_mbox_cmd mbox_cmd ;
@@ -1130,7 +1131,7 @@ int cxl_dev_state_identify(struct cxl_memdev_state *mds)
11301131 .size_out = sizeof (id ),
11311132 .payload_out = & id ,
11321133 };
1133- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
1134+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
11341135 if (rc < 0 )
11351136 return rc ;
11361137
@@ -1158,6 +1159,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_dev_state_identify, CXL);
11581159
11591160static int __cxl_mem_sanitize (struct cxl_memdev_state * mds , u16 cmd )
11601161{
1162+ struct cxl_mailbox * cxl_mbox = & mds -> cxlds .cxl_mbox ;
11611163 int rc ;
11621164 u32 sec_out = 0 ;
11631165 struct cxl_get_security_output {
@@ -1169,14 +1171,13 @@ static int __cxl_mem_sanitize(struct cxl_memdev_state *mds, u16 cmd)
11691171 .size_out = sizeof (out ),
11701172 };
11711173 struct cxl_mbox_cmd mbox_cmd = { .opcode = cmd };
1172- struct cxl_dev_state * cxlds = & mds -> cxlds ;
11731174
11741175 if (cmd != CXL_MBOX_OP_SANITIZE && cmd != CXL_MBOX_OP_SECURE_ERASE )
11751176 return - EINVAL ;
11761177
1177- rc = cxl_internal_send_cmd (mds , & sec_cmd );
1178+ rc = cxl_internal_send_cmd (cxl_mbox , & sec_cmd );
11781179 if (rc < 0 ) {
1179- dev_err (cxlds -> dev , "Failed to get security state : %d" , rc );
1180+ dev_err (cxl_mbox -> host , "Failed to get security state : %d" , rc );
11801181 return rc ;
11811182 }
11821183
@@ -1193,9 +1194,9 @@ static int __cxl_mem_sanitize(struct cxl_memdev_state *mds, u16 cmd)
11931194 sec_out & CXL_PMEM_SEC_STATE_LOCKED )
11941195 return - EINVAL ;
11951196
1196- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
1197+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
11971198 if (rc < 0 ) {
1198- dev_err (cxlds -> dev , "Failed to sanitize device : %d" , rc );
1199+ dev_err (cxl_mbox -> host , "Failed to sanitize device : %d" , rc );
11991200 return rc ;
12001201 }
12011202
@@ -1309,6 +1310,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_mem_create_range_info, CXL);
13091310
13101311int cxl_set_timestamp (struct cxl_memdev_state * mds )
13111312{
1313+ struct cxl_mailbox * cxl_mbox = & mds -> cxlds .cxl_mbox ;
13121314 struct cxl_mbox_cmd mbox_cmd ;
13131315 struct cxl_mbox_set_timestamp_in pi ;
13141316 int rc ;
@@ -1320,7 +1322,7 @@ int cxl_set_timestamp(struct cxl_memdev_state *mds)
13201322 .payload_in = & pi ,
13211323 };
13221324
1323- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
1325+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
13241326 /*
13251327 * Command is optional. Devices may have another way of providing
13261328 * 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,
13371339 struct cxl_region * cxlr )
13381340{
13391341 struct cxl_memdev_state * mds = to_cxl_memdev_state (cxlmd -> cxlds );
1340- struct cxl_mailbox * cxl_mbox = & mds -> cxlds . cxl_mbox ;
1342+ struct cxl_mailbox * cxl_mbox = & cxlmd -> cxlds -> cxl_mbox ;
13411343 struct cxl_mbox_poison_out * po ;
13421344 struct cxl_mbox_poison_in pi ;
13431345 int nr_records = 0 ;
@@ -1361,7 +1363,7 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,
13611363 .min_out = struct_size (po , record , 0 ),
13621364 };
13631365
1364- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
1366+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
13651367 if (rc )
13661368 break ;
13671369
0 commit comments