@@ -225,7 +225,7 @@ static const char *cxl_mem_opcode_to_name(u16 opcode)
225
225
226
226
/**
227
227
* 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
229
229
* @mbox_cmd: initialized command to execute
230
230
*
231
231
* Context: Any context.
@@ -241,10 +241,9 @@ static const char *cxl_mem_opcode_to_name(u16 opcode)
241
241
* error. While this distinction can be useful for commands from userspace, the
242
242
* kernel will only be able to use results when both are successful.
243
243
*/
244
- int cxl_internal_send_cmd (struct cxl_memdev_state * mds ,
244
+ int cxl_internal_send_cmd (struct cxl_mailbox * cxl_mbox ,
245
245
struct cxl_mbox_cmd * mbox_cmd )
246
246
{
247
- struct cxl_mailbox * cxl_mbox = & mds -> cxlds .cxl_mbox ;
248
247
size_t out_size , min_out ;
249
248
int rc ;
250
249
@@ -689,7 +688,7 @@ static int cxl_xfer_log(struct cxl_memdev_state *mds, uuid_t *uuid,
689
688
.payload_out = out ,
690
689
};
691
690
692
- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
691
+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
693
692
694
693
/*
695
694
* 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
774
/* At least the record number field must be valid */
776
775
.min_out = 2 ,
777
776
};
778
- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
777
+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
779
778
if (rc < 0 ) {
780
779
kvfree (ret );
781
780
return ERR_PTR (rc );
@@ -964,7 +963,7 @@ static int cxl_clear_event_record(struct cxl_memdev_state *mds,
964
963
965
964
if (i == max_handles ) {
966
965
payload -> nr_recs = i ;
967
- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
966
+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
968
967
if (rc )
969
968
goto free_pl ;
970
969
i = 0 ;
@@ -975,7 +974,7 @@ static int cxl_clear_event_record(struct cxl_memdev_state *mds,
975
974
if (i ) {
976
975
payload -> nr_recs = i ;
977
976
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 );
979
978
if (rc )
980
979
goto free_pl ;
981
980
}
@@ -1009,7 +1008,7 @@ static void cxl_mem_get_records_log(struct cxl_memdev_state *mds,
1009
1008
.min_out = struct_size (payload , records , 0 ),
1010
1009
};
1011
1010
1012
- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
1011
+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
1013
1012
if (rc ) {
1014
1013
dev_err_ratelimited (dev ,
1015
1014
"Event log '%d': Failed to query event records : %d" ,
@@ -1080,6 +1079,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_mem_get_event_records, CXL);
1080
1079
*/
1081
1080
static int cxl_mem_get_partition_info (struct cxl_memdev_state * mds )
1082
1081
{
1082
+ struct cxl_mailbox * cxl_mbox = & mds -> cxlds .cxl_mbox ;
1083
1083
struct cxl_mbox_get_partition_info pi ;
1084
1084
struct cxl_mbox_cmd mbox_cmd ;
1085
1085
int rc ;
@@ -1089,7 +1089,7 @@ static int cxl_mem_get_partition_info(struct cxl_memdev_state *mds)
1089
1089
.size_out = sizeof (pi ),
1090
1090
.payload_out = & pi ,
1091
1091
};
1092
- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
1092
+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
1093
1093
if (rc )
1094
1094
return rc ;
1095
1095
@@ -1116,6 +1116,7 @@ static int cxl_mem_get_partition_info(struct cxl_memdev_state *mds)
1116
1116
*/
1117
1117
int cxl_dev_state_identify (struct cxl_memdev_state * mds )
1118
1118
{
1119
+ struct cxl_mailbox * cxl_mbox = & mds -> cxlds .cxl_mbox ;
1119
1120
/* See CXL 2.0 Table 175 Identify Memory Device Output Payload */
1120
1121
struct cxl_mbox_identify id ;
1121
1122
struct cxl_mbox_cmd mbox_cmd ;
@@ -1130,7 +1131,7 @@ int cxl_dev_state_identify(struct cxl_memdev_state *mds)
1130
1131
.size_out = sizeof (id ),
1131
1132
.payload_out = & id ,
1132
1133
};
1133
- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
1134
+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
1134
1135
if (rc < 0 )
1135
1136
return rc ;
1136
1137
@@ -1158,6 +1159,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_dev_state_identify, CXL);
1158
1159
1159
1160
static int __cxl_mem_sanitize (struct cxl_memdev_state * mds , u16 cmd )
1160
1161
{
1162
+ struct cxl_mailbox * cxl_mbox = & mds -> cxlds .cxl_mbox ;
1161
1163
int rc ;
1162
1164
u32 sec_out = 0 ;
1163
1165
struct cxl_get_security_output {
@@ -1169,14 +1171,13 @@ static int __cxl_mem_sanitize(struct cxl_memdev_state *mds, u16 cmd)
1169
1171
.size_out = sizeof (out ),
1170
1172
};
1171
1173
struct cxl_mbox_cmd mbox_cmd = { .opcode = cmd };
1172
- struct cxl_dev_state * cxlds = & mds -> cxlds ;
1173
1174
1174
1175
if (cmd != CXL_MBOX_OP_SANITIZE && cmd != CXL_MBOX_OP_SECURE_ERASE )
1175
1176
return - EINVAL ;
1176
1177
1177
- rc = cxl_internal_send_cmd (mds , & sec_cmd );
1178
+ rc = cxl_internal_send_cmd (cxl_mbox , & sec_cmd );
1178
1179
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 );
1180
1181
return rc ;
1181
1182
}
1182
1183
@@ -1193,9 +1194,9 @@ static int __cxl_mem_sanitize(struct cxl_memdev_state *mds, u16 cmd)
1193
1194
sec_out & CXL_PMEM_SEC_STATE_LOCKED )
1194
1195
return - EINVAL ;
1195
1196
1196
- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
1197
+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
1197
1198
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 );
1199
1200
return rc ;
1200
1201
}
1201
1202
@@ -1309,6 +1310,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_mem_create_range_info, CXL);
1309
1310
1310
1311
int cxl_set_timestamp (struct cxl_memdev_state * mds )
1311
1312
{
1313
+ struct cxl_mailbox * cxl_mbox = & mds -> cxlds .cxl_mbox ;
1312
1314
struct cxl_mbox_cmd mbox_cmd ;
1313
1315
struct cxl_mbox_set_timestamp_in pi ;
1314
1316
int rc ;
@@ -1320,7 +1322,7 @@ int cxl_set_timestamp(struct cxl_memdev_state *mds)
1320
1322
.payload_in = & pi ,
1321
1323
};
1322
1324
1323
- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
1325
+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
1324
1326
/*
1325
1327
* Command is optional. Devices may have another way of providing
1326
1328
* 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
1339
struct cxl_region * cxlr )
1338
1340
{
1339
1341
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 ;
1341
1343
struct cxl_mbox_poison_out * po ;
1342
1344
struct cxl_mbox_poison_in pi ;
1343
1345
int nr_records = 0 ;
@@ -1361,7 +1363,7 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,
1361
1363
.min_out = struct_size (po , record , 0 ),
1362
1364
};
1363
1365
1364
- rc = cxl_internal_send_cmd (mds , & mbox_cmd );
1366
+ rc = cxl_internal_send_cmd (cxl_mbox , & mbox_cmd );
1365
1367
if (rc )
1366
1368
break ;
1367
1369
0 commit comments