hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/usb/gadget/function/f_tcm.c
....@@ -392,12 +392,12 @@
392392
393393 fu->flags = USBG_IS_BOT;
394394
395
- config_ep_by_speed(gadget, f, fu->ep_in);
395
+ config_ep_by_speed_and_alt(gadget, f, fu->ep_in, USB_G_ALT_INT_BBB);
396396 ret = usb_ep_enable(fu->ep_in);
397397 if (ret)
398398 goto err_b_in;
399399
400
- config_ep_by_speed(gadget, f, fu->ep_out);
400
+ config_ep_by_speed_and_alt(gadget, f, fu->ep_out, USB_G_ALT_INT_BBB);
401401 ret = usb_ep_enable(fu->ep_out);
402402 if (ret)
403403 goto err_b_out;
....@@ -531,6 +531,7 @@
531531 stream->req_in->sg = se_cmd->t_data_sg;
532532 }
533533
534
+ stream->req_in->is_last = 1;
534535 stream->req_in->complete = uasp_status_data_cmpl;
535536 stream->req_in->length = se_cmd->data_length;
536537 stream->req_in->context = cmd;
....@@ -554,6 +555,7 @@
554555 */
555556 iu->len = cpu_to_be16(se_cmd->scsi_sense_length);
556557 iu->status = se_cmd->scsi_status;
558
+ stream->req_status->is_last = 1;
557559 stream->req_status->context = cmd;
558560 stream->req_status->length = se_cmd->scsi_sense_length + 16;
559561 stream->req_status->buf = iu;
....@@ -847,24 +849,24 @@
847849
848850 fu->flags = USBG_IS_UAS;
849851
850
- if (gadget->speed == USB_SPEED_SUPER)
852
+ if (gadget->speed >= USB_SPEED_SUPER)
851853 fu->flags |= USBG_USE_STREAMS;
852854
853
- config_ep_by_speed(gadget, f, fu->ep_in);
855
+ config_ep_by_speed_and_alt(gadget, f, fu->ep_in, USB_G_ALT_INT_UAS);
854856 ret = usb_ep_enable(fu->ep_in);
855857 if (ret)
856858 goto err_b_in;
857859
858
- config_ep_by_speed(gadget, f, fu->ep_out);
860
+ config_ep_by_speed_and_alt(gadget, f, fu->ep_out, USB_G_ALT_INT_UAS);
859861 ret = usb_ep_enable(fu->ep_out);
860862 if (ret)
861863 goto err_b_out;
862864
863
- config_ep_by_speed(gadget, f, fu->ep_cmd);
865
+ config_ep_by_speed_and_alt(gadget, f, fu->ep_cmd, USB_G_ALT_INT_UAS);
864866 ret = usb_ep_enable(fu->ep_cmd);
865867 if (ret)
866868 goto err_cmd;
867
- config_ep_by_speed(gadget, f, fu->ep_status);
869
+ config_ep_by_speed_and_alt(gadget, f, fu->ep_status, USB_G_ALT_INT_UAS);
868870 ret = usb_ep_enable(fu->ep_status);
869871 if (ret)
870872 goto err_status;
....@@ -992,6 +994,7 @@
992994 req->sg = se_cmd->t_data_sg;
993995 }
994996
997
+ req->is_last = 1;
995998 req->complete = usbg_data_write_cmpl;
996999 req->length = se_cmd->data_length;
9971000 req->context = cmd;
....@@ -1050,7 +1053,8 @@
10501053 transport_init_se_cmd(se_cmd,
10511054 tv_nexus->tvn_se_sess->se_tpg->se_tpg_tfo,
10521055 tv_nexus->tvn_se_sess, cmd->data_len, DMA_NONE,
1053
- cmd->prio_attr, cmd->sense_iu.sense);
1056
+ cmd->prio_attr, cmd->sense_iu.sense,
1057
+ cmd->unpacked_lun);
10541058 goto out;
10551059 }
10561060
....@@ -1147,7 +1151,7 @@
11471151 default:
11481152 pr_debug_once("Unsupported prio_attr: %02x.\n",
11491153 cmd_iu->prio_attr);
1150
- /* fall through */
1154
+ fallthrough;
11511155 case UAS_SIMPLE_TAG:
11521156 cmd->prio_attr = TCM_SIMPLE_TAG;
11531157 break;
....@@ -1180,7 +1184,8 @@
11801184 transport_init_se_cmd(se_cmd,
11811185 tv_nexus->tvn_se_sess->se_tpg->se_tpg_tfo,
11821186 tv_nexus->tvn_se_sess, cmd->data_len, DMA_NONE,
1183
- cmd->prio_attr, cmd->sense_iu.sense);
1187
+ cmd->prio_attr, cmd->sense_iu.sense,
1188
+ cmd->unpacked_lun);
11841189 goto out;
11851190 }
11861191
....@@ -1257,11 +1262,6 @@
12571262 return 0;
12581263 }
12591264
1260
-static char *usbg_get_fabric_name(void)
1261
-{
1262
- return "usb_gadget";
1263
-}
1264
-
12651265 static char *usbg_get_fabric_wwn(struct se_portal_group *se_tpg)
12661266 {
12671267 struct usbg_tpg *tpg = container_of(se_tpg,
....@@ -1294,14 +1294,6 @@
12941294 }
12951295
12961296 static u32 usbg_sess_get_index(struct se_session *se_sess)
1297
-{
1298
- return 0;
1299
-}
1300
-
1301
-/*
1302
- * XXX Error recovery: return != 0 if we expect writes. Dunno when that could be
1303
- */
1304
-static int usbg_write_pending_status(struct se_cmd *se_cmd)
13051297 {
13061298 return 0;
13071299 }
....@@ -1719,8 +1711,7 @@
17191711
17201712 static const struct target_core_fabric_ops usbg_ops = {
17211713 .module = THIS_MODULE,
1722
- .name = "usb_gadget",
1723
- .get_fabric_name = usbg_get_fabric_name,
1714
+ .fabric_name = "usb_gadget",
17241715 .tpg_get_wwn = usbg_get_fabric_wwn,
17251716 .tpg_get_tag = usbg_get_tag,
17261717 .tpg_check_demo_mode = usbg_check_true,
....@@ -1732,7 +1723,6 @@
17321723 .sess_get_index = usbg_sess_get_index,
17331724 .sess_get_initiator_sid = NULL,
17341725 .write_pending = usbg_send_write_request,
1735
- .write_pending_status = usbg_write_pending_status,
17361726 .set_default_node_attributes = usbg_set_default_node_attrs,
17371727 .get_cmd_state = usbg_get_cmd_state,
17381728 .queue_data_in = usbg_send_read_response,
....@@ -2110,6 +2100,16 @@
21102100 usb_composite_setup_continue(fu->function.config->cdev);
21112101 }
21122102
2103
+static int tcm_get_alt(struct usb_function *f, unsigned intf)
2104
+{
2105
+ if (intf == bot_intf_desc.bInterfaceNumber)
2106
+ return USB_G_ALT_INT_BBB;
2107
+ if (intf == uasp_intf_desc.bInterfaceNumber)
2108
+ return USB_G_ALT_INT_UAS;
2109
+
2110
+ return -EOPNOTSUPP;
2111
+}
2112
+
21132113 static int tcm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
21142114 {
21152115 struct f_uas *fu = to_f_uas(f);
....@@ -2317,6 +2317,7 @@
23172317 fu->function.bind = tcm_bind;
23182318 fu->function.unbind = tcm_unbind;
23192319 fu->function.set_alt = tcm_set_alt;
2320
+ fu->function.get_alt = tcm_get_alt;
23202321 fu->function.setup = tcm_setup;
23212322 fu->function.disable = tcm_disable;
23222323 fu->function.free_func = tcm_free;