linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Martin Thierer <mthierer@gmail.com>
Cc: Alan Stern <stern@rowland.harvard.edu>, linux-usb@vger.kernel.org
Subject: Re: Data toggles not reset on "set configuration" for ports handled by "xhci_hcd" driver
Date: Mon, 24 Aug 2020 17:13:33 +0300	[thread overview]
Message-ID: <a66ea20a-5406-ed31-e607-08552598ed68@linux.intel.com> (raw)
In-Reply-To: <cbdfafed-b8d4-ca07-bde1-4598f5117f04@linux.intel.com>

On 24.8.2020 16.48, Mathias Nyman wrote:
> 
> Looks like libusb set_configuration could end up calling usb_reset_configuration() instead.
> If there are no changes it's possible usb_hcd_alloc_bandwidth() never gets called, and
> toggles never reset.
> 
> see drivers/usb/core/devio.c proc_setconfig()  
> 

Can you try the code below? It should force dropping and adding the endpoints
for the intrface(s) of that configuration, and xhci should reset the toggles.

Completely untested, it compiles :)

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 6197938dcc2d..4a1439b29918 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1554,19 +1554,9 @@ int usb_reset_configuration(struct usb_device *dev)
 		return -ENOMEM;
 	}
 	/* Make sure we have enough bandwidth for each alternate setting 0 */
-	for (i = 0; i < config->desc.bNumInterfaces; i++) {
-		struct usb_interface *intf = config->interface[i];
-		struct usb_host_interface *alt;
+	 /* TEST, drop and re-add endpoints to clear toggle */
+	retval = usb_hcd_alloc_bandwidth(dev, config, NULL, NULL);
 
-		alt = usb_altnum_to_altsetting(intf, 0);
-		if (!alt)
-			alt = &intf->altsetting[0];
-		if (alt != intf->cur_altsetting)
-			retval = usb_hcd_alloc_bandwidth(dev, NULL,
-					intf->cur_altsetting, alt);
-		if (retval < 0)
-			break;
-	}
 	/* If not, reinstate the old alternate settings */
 	if (retval < 0) {
 reset_old_alts:

  reply	other threads:[~2020-08-24 14:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-21 12:30 Data toggles not reset on "set configuration" for ports handled by "xhci_hcd" driver Martin Thierer
2020-08-21 16:03 ` Alan Stern
2020-08-21 16:34   ` Martin Thierer
2020-08-21 17:01     ` Alan Stern
2020-08-24 10:22       ` Mathias Nyman
2020-08-24 13:10         ` Martin Thierer
2020-08-24 13:48           ` Mathias Nyman
2020-08-24 14:13             ` Mathias Nyman [this message]
2020-08-25  8:00               ` Martin Thierer
2020-08-25 11:53                 ` Mathias Nyman
2020-08-25 15:10                   ` Alan Stern
2020-08-26  8:37                     ` Mathias Nyman
2020-08-26 14:37                       ` Alan Stern
2020-08-26  7:40                   ` Martin Thierer
2020-08-26  8:40                     ` Mathias Nyman
2020-08-28 13:10                       ` Mathias Nyman
2020-08-28 15:55                         ` Alan Stern
2020-08-31  6:37                           ` Mathias Nyman
2020-08-28 18:04                         ` Martin Thierer
2020-08-31  6:41                           ` Mathias Nyman
2020-08-31  9:35                             ` Martin Thierer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a66ea20a-5406-ed31-e607-08552598ed68@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=mthierer@gmail.com \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).