mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Michal Nazarewicz" <mnazarewicz@google.com>
To: "Alan Stern" <stern@rowland.harvard.edu>
Cc: "Sergei Shtylyov" <sshtylyov@mvista.com>,
	"Felipe Balbi" <balbi@ti.com>,
	"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
	"Yang Rui Rui" <ruirui.r.yang@tieto.com>,
	"Greg Kroah-Hartman" <gregkh@suse.de>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCHv2] usb: gadget: get rid of USB_GADGET_DUALSPEED and USB_GADGET_SUPERSPEED
Date: Thu, 18 Aug 2011 22:13:09 +0200	[thread overview]
Message-ID: <op.v0fef7e2vgw7ix@mnazarewicz-glaptop> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1108181323360.1912-100000@iolanthe.rowland.org>

On Thu, 18 Aug 2011 19:27:21 +0200, Alan Stern <stern@rowland.harvard.edu>  
wrote:

> On Thu, 18 Aug 2011, Michal Nazarewicz wrote:
>
>> For the most part, usb_composite_probe() is called only once in module's
>> init function.  As far as I know, only g_ffs calls it several times.  So
>> in all cases expect for g_ffs, composite_driver.speed =
>> min(composite_driver.speed,
>> driver->max_speed) should have the same effect as composite_driver.speed
>> = driver->max_speed.
>>
>> > For example, if you have a composite gadget where one of the function
>> > drivers can handle SuperSpeed and the other can't go beyond high  
>> speed,
>> > the overall gadget must never run faster than high speed.
>>
>> Shouldn't that be dealt in usb_add_function()?  I cannot see any code  
>> that would do that here atm though.

> Maybe you're right.  But isn't that too late?  The UDC driver has to
> know the gadget driver's limitations before it can connect to the host.

usb_add_function() is called before usb_composite_probe() which only then
calls usb_gadget_probe_driver().

What's more, if I understand it correctly, comment in usb_add_function()
says that we support all the speeds usb_composite_driver structure claims
we do but then return different sets of functions depending on speed.  Ie.
if a function is only full speed and host requests high speed,  
configuration
will lack that function.  The comment in question is:

	/* We allow configurations that don't work at both speeds.
	 * If we run into a lowspeed Linux system, treat it the same
	 * as full speed ... it's the function drivers that will need
	 * to avoid bulk and ISO transfers. */

usb_add_function() then proceeds to set config->fullspeed,  
config->highspeed
and config->superspeed depending on what descriptors function provides.

Those are later used in config_desc() where it iterates over all
configurations checking which have functions supporting given speed:

	list_for_each_entry(c, &cdev->configs, list) {
		switch (speed) {
		case USB_SPEED_SUPER: if (!c->superspeed) continue; break;
		case USB_SPEED_HIGH: if (!c->highspeed) continue; break;
		default: if (!c->fullspeed) continue;
		}
		if (w_value == 0)
			return config_buf(c, speed, cdev->req->buf, type);
		w_value--;
	}

config_buf() at the same time, iterates over all functions and skips the  
ones
that do not provide descriptors for given speed:

	list_for_each_entry(f, &config->functions, list) {
		switch (speed) {
		case USB_SPEED_SUPER: descriptors = f->ss_descriptors; break;
		case USB_SPEED_HIGH: descriptors = f->hs_descriptors; break;
		default: descriptors = f->descriptors;
		}
		if (!descriptors)
			continue;
[...]
	}

So I think that your suggestion to use composite_driver.speed =
driver->max_speed was by all means correct.

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michal "mina86" Nazarewicz    (o o)
ooo +-----<email/xmpp: mnazarewicz@google.com>-----ooO--(_)--Ooo--

  reply	other threads:[~2011-08-18 20:13 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4E4B9D9C.2010607@linutronix.de>
2011-08-17 13:03 ` [PATCH] " Michal Nazarewicz
2011-08-17 14:20   ` Alan Stern
2011-08-17 14:27     ` Michal Nazarewicz
2011-08-17 14:47       ` Alan Stern
2011-08-17 15:07         ` Michal Nazarewicz
2011-08-17 16:25           ` Alan Stern
2011-08-17 14:36   ` Sergei Shtylyov
2011-08-17 14:45     ` Michal Nazarewicz
2011-08-17 15:33 ` [PATCHv2] " Michal Nazarewicz
2011-08-17 21:09   ` Alan Stern
2011-08-18 13:19     ` Michal Nazarewicz
2011-08-18 14:59       ` Alan Stern
2011-08-18 17:05         ` Michal Nazarewicz
2011-08-18 17:27           ` Alan Stern
2011-08-18 20:13             ` Michal Nazarewicz [this message]
2011-08-18 20:30               ` Alan Stern
2011-08-18 20:44                 ` Michal Nazarewicz
2011-08-19 10:53                 ` Michal Nazarewicz
2011-08-19 11:13                   ` Sebastian Andrzej Siewior
2011-08-19 12:14                     ` Michal Nazarewicz
2011-08-19 14:29                       ` Alan Stern
2011-08-19 14:38                         ` Michal Nazarewicz
2011-08-19 14:57                           ` Alan Stern
2011-08-19  2:02           ` Yang Rui Rui
2011-08-19 12:17             ` Michal Nazarewicz
2011-08-18  3:01   ` Yang Rui Rui
2011-08-18 11:57     ` Michal Nazarewicz
2011-08-18 13:24       ` Dave Young
2011-08-18 13:41         ` Michal Nazarewicz
2011-08-19 22:32   ` [PATCHv3 0/4] Figuring out speed refactorisation Michal Nazarewicz
2011-08-19 22:32     ` [PATCHv3 1/4] usb: Provide usb_device_speed_name() function Michal Nazarewicz
2011-08-19 23:15       ` Felipe Balbi
2011-08-22 14:53         ` Michal Nazarewicz
2011-08-19 22:33     ` [PATCHv3 2/4] usb: gadget: replace "is_dualspeed" with "max_speed" Michal Nazarewicz
2011-08-19 23:28       ` Felipe Balbi
2011-08-23 13:48         ` Michal Nazarewicz
2011-08-23 13:58           ` Felipe Balbi
2011-08-23 14:15             ` Michal Nazarewicz
2011-08-23 14:37               ` Alan Stern
2011-08-23 14:58                 ` Felipe Balbi
2011-08-23 15:07                   ` Michal Nazarewicz
2011-08-23 15:11                     ` Felipe Balbi
2011-08-23 15:26                       ` Michal Nazarewicz
2011-08-23 17:19                         ` Felipe Balbi
2011-08-23 18:44                           ` Michal Nazarewicz
2011-08-23 15:43                   ` Alan Stern
2011-08-23 17:21                     ` Felipe Balbi
2011-08-23 18:00                       ` Alan Stern
2011-08-23 19:05                         ` Michal Nazarewicz
2011-08-23 20:49                           ` Alan Stern
2011-08-24  8:56                             ` Felipe Balbi
2011-08-24 13:10                             ` Michal Nazarewicz
2011-08-24 14:31                               ` Alan Stern
2011-08-24 14:53                                 ` Michal Nazarewicz
2011-08-24 15:15                                   ` Alan Stern
2011-08-24 15:25                                     ` Michal Nazarewicz
2011-08-24 23:04                                       ` Felipe Balbi
2011-08-25 12:46                                         ` Michal Nazarewicz
2011-08-25 12:53                                           ` Felipe Balbi
2011-08-24 22:57                                 ` Felipe Balbi
2011-08-23 15:05               ` Felipe Balbi
2011-08-23 15:30                 ` Michal Nazarewicz
2011-08-19 22:33     ` [PATCHv3 3/4] usb: gadget: rename usb_gadget_driver::speed to max_speed Michal Nazarewicz
2011-08-19 23:31       ` Felipe Balbi
2011-08-20  2:34         ` Alan Stern
2011-08-22 10:42           ` Felipe Balbi
2011-08-19 22:33     ` [PATCHv3 4/4] usb: gadget: get rid of USB_GADGET_{DUAL,SUPER}SPEED Michal Nazarewicz
2011-08-20 13:41       ` Alan Stern
2011-08-22 14:51         ` Michal Nazarewicz
2011-08-22 15:03           ` Alan Stern

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=op.v0fef7e2vgw7ix@mnazarewicz-glaptop \
    --to=mnazarewicz@google.com \
    --cc=balbi@ti.com \
    --cc=bigeasy@linutronix.de \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=ruirui.r.yang@tieto.com \
    --cc=sshtylyov@mvista.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

all inboxes | Powered by JetHome®