@@ -612,8 +612,8 @@ int xhci_check_args(struct usb_hcd *hcd, struct usb_device *udev,
612
612
}
613
613
614
614
static int xhci_configure_endpoint (struct xhci_hcd * xhci ,
615
- struct usb_device * udev , struct xhci_virt_device * virt_dev ,
616
- bool ctx_change );
615
+ struct usb_device * udev , struct xhci_command * command ,
616
+ bool ctx_change , bool must_succeed );
617
617
618
618
/*
619
619
* Full speed devices may have a max packet size greater than 8 bytes, but the
@@ -645,7 +645,8 @@ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id,
645
645
xhci_dbg (xhci , "Issuing evaluate context command.\n" );
646
646
647
647
/* Set up the modified control endpoint 0 */
648
- xhci_endpoint_copy (xhci , xhci -> devs [slot_id ], ep_index );
648
+ xhci_endpoint_copy (xhci , xhci -> devs [slot_id ]-> in_ctx ,
649
+ xhci -> devs [slot_id ]-> out_ctx , ep_index );
649
650
in_ctx = xhci -> devs [slot_id ]-> in_ctx ;
650
651
ep_ctx = xhci_get_ep_ctx (xhci , in_ctx , ep_index );
651
652
ep_ctx -> ep_info2 &= ~MAX_PACKET_MASK ;
@@ -664,8 +665,8 @@ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id,
664
665
xhci_dbg (xhci , "Slot %d output context\n" , slot_id );
665
666
xhci_dbg_ctx (xhci , out_ctx , ep_index );
666
667
667
- ret = xhci_configure_endpoint (xhci , urb -> dev ,
668
- xhci -> devs [ slot_id ], true );
668
+ ret = xhci_configure_endpoint (xhci , urb -> dev , NULL ,
669
+ true, false );
669
670
670
671
/* Clean up the input context for later use by bandwidth
671
672
* functions.
@@ -1038,11 +1039,11 @@ static void xhci_zero_in_ctx(struct xhci_hcd *xhci, struct xhci_virt_device *vir
1038
1039
}
1039
1040
1040
1041
static int xhci_configure_endpoint_result (struct xhci_hcd * xhci ,
1041
- struct usb_device * udev , struct xhci_virt_device * virt_dev )
1042
+ struct usb_device * udev , int * cmd_status )
1042
1043
{
1043
1044
int ret ;
1044
1045
1045
- switch (virt_dev -> cmd_status ) {
1046
+ switch (* cmd_status ) {
1046
1047
case COMP_ENOMEM :
1047
1048
dev_warn (& udev -> dev , "Not enough host controller resources "
1048
1049
"for new device state.\n" );
@@ -1068,19 +1069,20 @@ static int xhci_configure_endpoint_result(struct xhci_hcd *xhci,
1068
1069
break ;
1069
1070
default :
1070
1071
xhci_err (xhci , "ERROR: unexpected command completion "
1071
- "code 0x%x.\n" , virt_dev -> cmd_status );
1072
+ "code 0x%x.\n" , * cmd_status );
1072
1073
ret = - EINVAL ;
1073
1074
break ;
1074
1075
}
1075
1076
return ret ;
1076
1077
}
1077
1078
1078
1079
static int xhci_evaluate_context_result (struct xhci_hcd * xhci ,
1079
- struct usb_device * udev , struct xhci_virt_device * virt_dev )
1080
+ struct usb_device * udev , int * cmd_status )
1080
1081
{
1081
1082
int ret ;
1083
+ struct xhci_virt_device * virt_dev = xhci -> devs [udev -> slot_id ];
1082
1084
1083
- switch (virt_dev -> cmd_status ) {
1085
+ switch (* cmd_status ) {
1084
1086
case COMP_EINVAL :
1085
1087
dev_warn (& udev -> dev , "WARN: xHCI driver setup invalid evaluate "
1086
1088
"context command.\n" );
@@ -1101,7 +1103,7 @@ static int xhci_evaluate_context_result(struct xhci_hcd *xhci,
1101
1103
break ;
1102
1104
default :
1103
1105
xhci_err (xhci , "ERROR: unexpected command completion "
1104
- "code 0x%x.\n" , virt_dev -> cmd_status );
1106
+ "code 0x%x.\n" , * cmd_status );
1105
1107
ret = - EINVAL ;
1106
1108
break ;
1107
1109
}
@@ -1112,19 +1114,37 @@ static int xhci_evaluate_context_result(struct xhci_hcd *xhci,
1112
1114
* and wait for it to finish.
1113
1115
*/
1114
1116
static int xhci_configure_endpoint (struct xhci_hcd * xhci ,
1115
- struct usb_device * udev , struct xhci_virt_device * virt_dev ,
1116
- bool ctx_change )
1117
+ struct usb_device * udev ,
1118
+ struct xhci_command * command ,
1119
+ bool ctx_change , bool must_succeed )
1117
1120
{
1118
1121
int ret ;
1119
1122
int timeleft ;
1120
1123
unsigned long flags ;
1124
+ struct xhci_container_ctx * in_ctx ;
1125
+ struct completion * cmd_completion ;
1126
+ int * cmd_status ;
1127
+ struct xhci_virt_device * virt_dev ;
1121
1128
1122
1129
spin_lock_irqsave (& xhci -> lock , flags );
1130
+ virt_dev = xhci -> devs [udev -> slot_id ];
1131
+ if (command ) {
1132
+ in_ctx = command -> in_ctx ;
1133
+ cmd_completion = command -> completion ;
1134
+ cmd_status = & command -> status ;
1135
+ command -> command_trb = xhci -> cmd_ring -> enqueue ;
1136
+ list_add_tail (& command -> cmd_list , & virt_dev -> cmd_list );
1137
+ } else {
1138
+ in_ctx = virt_dev -> in_ctx ;
1139
+ cmd_completion = & virt_dev -> cmd_completion ;
1140
+ cmd_status = & virt_dev -> cmd_status ;
1141
+ }
1142
+
1123
1143
if (!ctx_change )
1124
- ret = xhci_queue_configure_endpoint (xhci , virt_dev -> in_ctx -> dma ,
1125
- udev -> slot_id );
1144
+ ret = xhci_queue_configure_endpoint (xhci , in_ctx -> dma ,
1145
+ udev -> slot_id , must_succeed );
1126
1146
else
1127
- ret = xhci_queue_evaluate_context (xhci , virt_dev -> in_ctx -> dma ,
1147
+ ret = xhci_queue_evaluate_context (xhci , in_ctx -> dma ,
1128
1148
udev -> slot_id );
1129
1149
if (ret < 0 ) {
1130
1150
spin_unlock_irqrestore (& xhci -> lock , flags );
@@ -1136,7 +1156,7 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci,
1136
1156
1137
1157
/* Wait for the configure endpoint command to complete */
1138
1158
timeleft = wait_for_completion_interruptible_timeout (
1139
- & virt_dev -> cmd_completion ,
1159
+ cmd_completion ,
1140
1160
USB_CTRL_SET_TIMEOUT );
1141
1161
if (timeleft <= 0 ) {
1142
1162
xhci_warn (xhci , "%s while waiting for %s command\n" ,
@@ -1149,8 +1169,8 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci,
1149
1169
}
1150
1170
1151
1171
if (!ctx_change )
1152
- return xhci_configure_endpoint_result (xhci , udev , virt_dev );
1153
- return xhci_evaluate_context_result (xhci , udev , virt_dev );
1172
+ return xhci_configure_endpoint_result (xhci , udev , cmd_status );
1173
+ return xhci_evaluate_context_result (xhci , udev , cmd_status );
1154
1174
}
1155
1175
1156
1176
/* Called after one or more calls to xhci_add_endpoint() or
@@ -1196,7 +1216,8 @@ int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
1196
1216
xhci_dbg_ctx (xhci , virt_dev -> in_ctx ,
1197
1217
LAST_CTX_TO_EP_NUM (slot_ctx -> dev_info ));
1198
1218
1199
- ret = xhci_configure_endpoint (xhci , udev , virt_dev , false);
1219
+ ret = xhci_configure_endpoint (xhci , udev , NULL ,
1220
+ false, false);
1200
1221
if (ret ) {
1201
1222
/* Callee should call reset_bandwidth() */
1202
1223
return ret ;
@@ -1248,19 +1269,19 @@ void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
1248
1269
}
1249
1270
1250
1271
static void xhci_setup_input_ctx_for_config_ep (struct xhci_hcd * xhci ,
1251
- unsigned int slot_id , u32 add_flags , u32 drop_flags )
1272
+ struct xhci_container_ctx * in_ctx ,
1273
+ struct xhci_container_ctx * out_ctx ,
1274
+ u32 add_flags , u32 drop_flags )
1252
1275
{
1253
1276
struct xhci_input_control_ctx * ctrl_ctx ;
1254
- ctrl_ctx = xhci_get_input_control_ctx (xhci ,
1255
- xhci -> devs [slot_id ]-> in_ctx );
1277
+ ctrl_ctx = xhci_get_input_control_ctx (xhci , in_ctx );
1256
1278
ctrl_ctx -> add_flags = add_flags ;
1257
1279
ctrl_ctx -> drop_flags = drop_flags ;
1258
- xhci_slot_copy (xhci , xhci -> devs [ slot_id ] );
1280
+ xhci_slot_copy (xhci , in_ctx , out_ctx );
1259
1281
ctrl_ctx -> add_flags |= SLOT_FLAG ;
1260
1282
1261
- xhci_dbg (xhci , "Slot ID %d Input Context:\n" , slot_id );
1262
- xhci_dbg_ctx (xhci , xhci -> devs [slot_id ]-> in_ctx ,
1263
- xhci_last_valid_endpoint (add_flags ));
1283
+ xhci_dbg (xhci , "Input Context:\n" );
1284
+ xhci_dbg_ctx (xhci , in_ctx , xhci_last_valid_endpoint (add_flags ));
1264
1285
}
1265
1286
1266
1287
void xhci_setup_input_ctx_for_quirk (struct xhci_hcd * xhci ,
@@ -1272,7 +1293,8 @@ void xhci_setup_input_ctx_for_quirk(struct xhci_hcd *xhci,
1272
1293
u32 added_ctxs ;
1273
1294
dma_addr_t addr ;
1274
1295
1275
- xhci_endpoint_copy (xhci , xhci -> devs [slot_id ], ep_index );
1296
+ xhci_endpoint_copy (xhci , xhci -> devs [slot_id ]-> in_ctx ,
1297
+ xhci -> devs [slot_id ]-> out_ctx , ep_index );
1276
1298
in_ctx = xhci -> devs [slot_id ]-> in_ctx ;
1277
1299
ep_ctx = xhci_get_ep_ctx (xhci , in_ctx , ep_index );
1278
1300
addr = xhci_trb_virt_to_dma (deq_state -> new_deq_seg ,
@@ -1288,8 +1310,8 @@ void xhci_setup_input_ctx_for_quirk(struct xhci_hcd *xhci,
1288
1310
ep_ctx -> deq = addr | deq_state -> new_cycle_state ;
1289
1311
1290
1312
added_ctxs = xhci_get_endpoint_flag_from_index (ep_index );
1291
- xhci_setup_input_ctx_for_config_ep (xhci , slot_id ,
1292
- added_ctxs , added_ctxs );
1313
+ xhci_setup_input_ctx_for_config_ep (xhci , xhci -> devs [ slot_id ] -> in_ctx ,
1314
+ xhci -> devs [ slot_id ] -> out_ctx , added_ctxs , added_ctxs );
1293
1315
}
1294
1316
1295
1317
void xhci_cleanup_stalled_ring (struct xhci_hcd * xhci ,
0 commit comments