linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: config_ep_by_speed_and_alt instead config_ep_by_speed.
@ 2020-09-17  7:58 Pawel Laszczak
  2020-09-18  1:58 ` Peter Chen
  0 siblings, 1 reply; 2+ messages in thread
From: Pawel Laszczak @ 2020-09-17  7:58 UTC (permalink / raw)
  To: balbi, gregkh
  Cc: jpawar, christophe.jaillet, sudhakar.panneerselvam, gustavoars,
	pawell, Thinh.Nguyen, linux-usb, linux-kernel, kurahul

This patch replace config_ep_by_speed with config_ep_by_speed_and_alt.
This change allows to select proper usb_ss_ep_comp_descriptor for each
stream capable endpoints.

f_tcm function for SS use array of headers for both  BOT/UAS alternate
setting:

static struct usb_descriptor_header *uasp_ss_function_desc[] = {
        (struct usb_descriptor_header *) &bot_intf_desc,
        (struct usb_descriptor_header *) &uasp_ss_bi_desc,
        (struct usb_descriptor_header *) &bot_bi_ep_comp_desc,
        (struct usb_descriptor_header *) &uasp_ss_bo_desc,
        (struct usb_descriptor_header *) &bot_bo_ep_comp_desc,

        (struct usb_descriptor_header *) &uasp_intf_desc,
        (struct usb_descriptor_header *) &uasp_ss_bi_desc,
        (struct usb_descriptor_header *) &uasp_bi_ep_comp_desc,
        (struct usb_descriptor_header *) &uasp_bi_pipe_desc,
        (struct usb_descriptor_header *) &uasp_ss_bo_desc,
        (struct usb_descriptor_header *) &uasp_bo_ep_comp_desc,
        (struct usb_descriptor_header *) &uasp_bo_pipe_desc,
        (struct usb_descriptor_header *) &uasp_ss_status_desc,
        (struct usb_descriptor_header *) &uasp_status_in_ep_comp_desc,
        (struct usb_descriptor_header *) &uasp_status_pipe_desc,
        (struct usb_descriptor_header *) &uasp_ss_cmd_desc,
        (struct usb_descriptor_header *) &uasp_cmd_comp_desc,
        (struct usb_descriptor_header *) &uasp_cmd_pipe_desc,
        NULL,
};

The first 5 descriptors are associated with BOT alternate setting,
and others are associated  with UAS.

During handling UAS alternate setting f_tcm driver invokes
config_ep_by_speed and this function sets incorrect companion endpoint
descriptor in usb_ep object.

Instead setting ep->comp_desc to uasp_bi_ep_comp_desc function in this
case set ep->comp_desc to bot_uasp_ss_bi_desc.

And in result it uses the descriptor from BOT alternate setting
instead UAS.

Finally, it causes that controller driver during enabling endpoints
detect that just enabled endpoint for bot.

Signed-off-by: Jayshri Pawar <jpawar@cadence.com>
Signed-off-by: Pawel Laszczak <pawell@cadence.com>
---
 drivers/usb/gadget/function/f_tcm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c
index 184165e27908..410fa89eae8f 100644
--- a/drivers/usb/gadget/function/f_tcm.c
+++ b/drivers/usb/gadget/function/f_tcm.c
@@ -392,12 +392,12 @@ static void bot_set_alt(struct f_uas *fu)
 
 	fu->flags = USBG_IS_BOT;
 
-	config_ep_by_speed(gadget, f, fu->ep_in);
+	config_ep_by_speed_and_alt(gadget, f, fu->ep_in, USB_G_ALT_INT_BBB);
 	ret = usb_ep_enable(fu->ep_in);
 	if (ret)
 		goto err_b_in;
 
-	config_ep_by_speed(gadget, f, fu->ep_out);
+	config_ep_by_speed_and_alt(gadget, f, fu->ep_out, USB_G_ALT_INT_BBB);
 	ret = usb_ep_enable(fu->ep_out);
 	if (ret)
 		goto err_b_out;
@@ -852,21 +852,21 @@ static void uasp_set_alt(struct f_uas *fu)
 	if (gadget->speed >= USB_SPEED_SUPER)
 		fu->flags |= USBG_USE_STREAMS;
 
-	config_ep_by_speed(gadget, f, fu->ep_in);
+	config_ep_by_speed_and_alt(gadget, f, fu->ep_in, USB_G_ALT_INT_UAS);
 	ret = usb_ep_enable(fu->ep_in);
 	if (ret)
 		goto err_b_in;
 
-	config_ep_by_speed(gadget, f, fu->ep_out);
+	config_ep_by_speed_and_alt(gadget, f, fu->ep_out, USB_G_ALT_INT_UAS);
 	ret = usb_ep_enable(fu->ep_out);
 	if (ret)
 		goto err_b_out;
 
-	config_ep_by_speed(gadget, f, fu->ep_cmd);
+	config_ep_by_speed_and_alt(gadget, f, fu->ep_cmd, USB_G_ALT_INT_UAS);
 	ret = usb_ep_enable(fu->ep_cmd);
 	if (ret)
 		goto err_cmd;
-	config_ep_by_speed(gadget, f, fu->ep_status);
+	config_ep_by_speed_and_alt(gadget, f, fu->ep_status, USB_G_ALT_INT_UAS);
 	ret = usb_ep_enable(fu->ep_status);
 	if (ret)
 		goto err_status;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] usb: gadget: config_ep_by_speed_and_alt instead config_ep_by_speed.
  2020-09-17  7:58 [PATCH] usb: gadget: config_ep_by_speed_and_alt instead config_ep_by_speed Pawel Laszczak
@ 2020-09-18  1:58 ` Peter Chen
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Chen @ 2020-09-18  1:58 UTC (permalink / raw)
  To: Pawel Laszczak, balbi, gregkh
  Cc: jpawar, christophe.jaillet, sudhakar.panneerselvam, gustavoars,
	Thinh.Nguyen, linux-usb, linux-kernel, kurahul

 
> Subject: [PATCH] usb: gadget: config_ep_by_speed_and_alt instead
> config_ep_by_speed.
> 

Typo, you may indicate use config_ep_by_speed_and_alt instead of config_ep_by_speed

> This patch replace config_ep_by_speed with config_ep_by_speed_and_alt.
> This change allows to select proper usb_ss_ep_comp_descriptor for each
> stream capable endpoints.
> 
> f_tcm function for SS use array of headers for both  BOT/UAS alternate
> setting:
> 

Delete space before "BOT/UAS"

> static struct usb_descriptor_header *uasp_ss_function_desc[] = {
>         (struct usb_descriptor_header *) &bot_intf_desc,
>         (struct usb_descriptor_header *) &uasp_ss_bi_desc,
>         (struct usb_descriptor_header *) &bot_bi_ep_comp_desc,
>         (struct usb_descriptor_header *) &uasp_ss_bo_desc,
>         (struct usb_descriptor_header *) &bot_bo_ep_comp_desc,
> 
>         (struct usb_descriptor_header *) &uasp_intf_desc,
>         (struct usb_descriptor_header *) &uasp_ss_bi_desc,
>         (struct usb_descriptor_header *) &uasp_bi_ep_comp_desc,
>         (struct usb_descriptor_header *) &uasp_bi_pipe_desc,
>         (struct usb_descriptor_header *) &uasp_ss_bo_desc,
>         (struct usb_descriptor_header *) &uasp_bo_ep_comp_desc,
>         (struct usb_descriptor_header *) &uasp_bo_pipe_desc,
>         (struct usb_descriptor_header *) &uasp_ss_status_desc,
>         (struct usb_descriptor_header *) &uasp_status_in_ep_comp_desc,
>         (struct usb_descriptor_header *) &uasp_status_pipe_desc,
>         (struct usb_descriptor_header *) &uasp_ss_cmd_desc,
>         (struct usb_descriptor_header *) &uasp_cmd_comp_desc,
>         (struct usb_descriptor_header *) &uasp_cmd_pipe_desc,
>         NULL,
> };
> 
> The first 5 descriptors are associated with BOT alternate setting, and others
> are associated  with UAS.
> 

delete space before "with UAS"

After fixing above typo, you could add my:

Reviewed-by: Peter Chen <peter.chen@nxp.com>

Peter

> During handling UAS alternate setting f_tcm driver invokes
> config_ep_by_speed and this function sets incorrect companion endpoint
> descriptor in usb_ep object.
> 
> Instead setting ep->comp_desc to uasp_bi_ep_comp_desc function in this case
> set ep->comp_desc to bot_uasp_ss_bi_desc.
> 
> And in result it uses the descriptor from BOT alternate setting instead UAS.
> 
> Finally, it causes that controller driver during enabling endpoints detect that
> just enabled endpoint for bot.
> 
> Signed-off-by: Jayshri Pawar <jpawar@cadence.com>
> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
> ---
>  drivers/usb/gadget/function/f_tcm.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/f_tcm.c
> b/drivers/usb/gadget/function/f_tcm.c
> index 184165e27908..410fa89eae8f 100644
> --- a/drivers/usb/gadget/function/f_tcm.c
> +++ b/drivers/usb/gadget/function/f_tcm.c
> @@ -392,12 +392,12 @@ static void bot_set_alt(struct f_uas *fu)
> 
>  	fu->flags = USBG_IS_BOT;
> 
> -	config_ep_by_speed(gadget, f, fu->ep_in);
> +	config_ep_by_speed_and_alt(gadget, f, fu->ep_in, USB_G_ALT_INT_BBB);
>  	ret = usb_ep_enable(fu->ep_in);
>  	if (ret)
>  		goto err_b_in;
> 
> -	config_ep_by_speed(gadget, f, fu->ep_out);
> +	config_ep_by_speed_and_alt(gadget, f, fu->ep_out,
> USB_G_ALT_INT_BBB);
>  	ret = usb_ep_enable(fu->ep_out);
>  	if (ret)
>  		goto err_b_out;
> @@ -852,21 +852,21 @@ static void uasp_set_alt(struct f_uas *fu)
>  	if (gadget->speed >= USB_SPEED_SUPER)
>  		fu->flags |= USBG_USE_STREAMS;
> 
> -	config_ep_by_speed(gadget, f, fu->ep_in);
> +	config_ep_by_speed_and_alt(gadget, f, fu->ep_in, USB_G_ALT_INT_UAS);
>  	ret = usb_ep_enable(fu->ep_in);
>  	if (ret)
>  		goto err_b_in;
> 
> -	config_ep_by_speed(gadget, f, fu->ep_out);
> +	config_ep_by_speed_and_alt(gadget, f, fu->ep_out,
> USB_G_ALT_INT_UAS);
>  	ret = usb_ep_enable(fu->ep_out);
>  	if (ret)
>  		goto err_b_out;
> 
> -	config_ep_by_speed(gadget, f, fu->ep_cmd);
> +	config_ep_by_speed_and_alt(gadget, f, fu->ep_cmd,
> USB_G_ALT_INT_UAS);
>  	ret = usb_ep_enable(fu->ep_cmd);
>  	if (ret)
>  		goto err_cmd;
> -	config_ep_by_speed(gadget, f, fu->ep_status);
> +	config_ep_by_speed_and_alt(gadget, f, fu->ep_status,
> +USB_G_ALT_INT_UAS);
>  	ret = usb_ep_enable(fu->ep_status);
>  	if (ret)
>  		goto err_status;
> --
> 2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-18  1:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17  7:58 [PATCH] usb: gadget: config_ep_by_speed_and_alt instead config_ep_by_speed Pawel Laszczak
2020-09-18  1:58 ` Peter Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).