From: puneets <puneets@nvidia.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 2/2] usb: Add CONFIG to fetch string descriptor
Date: Thu, 1 Mar 2012 18:29:29 +0530 [thread overview]
Message-ID: <4F4F72B1.2020504@nvidia.com> (raw)
In-Reply-To: <201203011245.03596.marex@denx.de>
Hi Marek,
On Thursday 01 March 2012 05:15 PM, Marek Vasut wrote:
> Hi!
>
>> Hi Marek,
>>
>> On Thursday 01 March 2012 02:59 AM, Marek Vasut wrote:
>>>> Add "CONFIG_USB_STRING_FETCH" to fetch first string descriptor length
>>>> and then pass this length to fetch string descriptor.
>>>>
>>>> Signed-off-by: Puneet Saxena<puneets@nvidia.com>
>>>> ---
>>>>
>>>> Changes for V2:
>>>> - Change existing config by "CONFIG_USB_STRING_FETCH"
>>>>
>>>> Changes for V3:
>>>> - Removed extra new line
>>>> - Explained "CONFIG_USB_STRING_FETCH" in top level README
>>>>
>>>> README | 4 ++++
>>>> common/usb.c | 4 ++++
>>>> include/configs/tegra2-common.h | 2 ++
>>>> 3 files changed, 10 insertions(+), 0 deletions(-)
>>>>
>>>> diff --git a/README b/README
>>>> index 7adf7c7..c045a37 100644
>>>> --- a/README
>>>> +++ b/README
>>>>
>>>> @@ -1138,6 +1138,10 @@ The following options need to be configured:
>>>> CONFIG_USB_EHCI_TXFIFO_THRESH enables setting of the
>>>> txfilltuning field in the EHCI controller on reset.
>>>>
>>>> + CONFIG_USB_STRING_FETCH
>>>> + Enables settings to USB core to handle string issues which
>>>> + few devices can not handle.
>>>> +
>>>>
>>>> - USB Device:
>>>> Define the below if you wish to use the USB console.
>>>> Once firmware is rebuilt from a serial console issue the
>>>>
>>>> diff --git a/common/usb.c b/common/usb.c
>>>> index 191bc5b..a73cb60 100644
>>>> --- a/common/usb.c
>>>> +++ b/common/usb.c
>>>> @@ -658,9 +658,13 @@ static int usb_string_sub(struct usb_device *dev,
>>>> unsigned int langid, {
>>>>
>>>> int rc;
>>>>
>>>> +#ifdef CONFIG_USB_STRING_FETCH
>>> Shouldn't this be something like ... CONFIG_USB_AVOID_STRING_FETCH then?
>>>
>>> Anyway, how come some devices can't handle it? What happens then? What
>>> devices are those (exact type etc)?
>>>
>>> I believe the bug is deeper and adding extra config options can be
>>> avoided, what do you think?
>>>
>>> Thanks!
>>>
>>> M
>> It does not avoid string fetch.
> Well it does certainly not call usb_get_string()
>
Precisely, it avoids fetching string desc of 255 bytes. so better name
could be
"CONFIG_USB_AVOID_STRING_FETCH_255". Thanks for your comment.
>> I checked with few mass storage devices that they does not handle string
>> descriptor request correctly and so we get
>> start/stop Cache alignment error.
> Cache alignment error ? Wow, how's that actually related to SUB string fetching?
> Maybe we should manually realign the result then? I still don't really
> understand what you're seeing, sorry ... can you please elaborate?
>
The particular mass storage device is -
Vendor: Kingston Rev: PMAP Prod: DataTraveler 2.0
Type: Removable Hard Disk
Capacity: 1906.0 MB = 1.8 GB (3903488 x 512)
When code tries to read Manufacturing Id..prod id...etc..it passes cache
aligned buffer "tbuf" in
"usb_string()" @usb.c. Inside "usb_string_sub()", usb_get_string()
passes as default 255 bytes to fetch string
descriptor.
The code in "ehci_submit_async() " invalidates *partially* the passed
buffer though we pass aligned buffer and "STD_ASS"
is received. Though it should invalidate only the cached line which is
equal(~32) to string desc length.
If we give delay of 1 ms after handshake() the cache alignment warning
does not spew...but delay of 1 ms is not acceptable.
So I enabled the code to fetch first string desc length and then fetch
string desc fetch, in this way the issue is resolved.
It makes sense also to fetch string desc length and then actual string
desc....
Thanks,
Puneet
One way is, blacklist those devices by
>> vendor id/product id..
>> etc. This is done in Linux kernel. Plz see Message.c (drivers\usb\core)
>> Line: 722.
>> Blacklisting the device requires a framework to detect the
>> device...However this could be achieved
>> simply with this implementation.
> Sure, I see your intention, but I still don't get the problem, see above. Can
> you also tell me if there's particular device that's broken and which one is it
> (precise type etc)?
>
> Thanks a lot for your cooperation on this matter!
>
> M
>
>>>> + rc = -1;
>>>> +#else
>>>>
>>>> /* Try to read the string descriptor by asking for the maximum
>>>>
>>>> * possible number of bytes */
>>>>
>>>> rc = usb_get_string(dev, langid, index, buf, 255);
>>>>
>>>> +#endif
>>>>
>>>> /* If that failed try to read the descriptor length, then
>>>>
>>>> * ask for just that many bytes */
>>>>
>>>> diff --git a/include/configs/tegra2-common.h
>>>> b/include/configs/tegra2-common.h index 266d0e5..d20b49c 100644
>>>> --- a/include/configs/tegra2-common.h
>>>> +++ b/include/configs/tegra2-common.h
>>>> @@ -93,6 +93,8 @@
>>>>
>>>> #define CONFIG_USB_EHCI_TXFIFO_THRESH 10
>>>> #define CONFIG_EHCI_IS_TDI
>>>> #define CONFIG_EHCI_DCACHE
>>>>
>>>> +/* string descriptors must not be fetched using a 255-byte read */
>>>> +#define CONFIG_USB_STRING_FETCH
>>>>
>>>> /* include default commands */
>>>> #include<config_cmd_default.h>
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information. Any unauthorized review, use, disclosure or distribution
is prohibited. If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
next prev parent reply other threads:[~2012-03-01 12:59 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-17 10:50 [U-Boot] [PATCH] usb: align buffers at cache boundary Puneet Saxena
2012-02-17 17:23 ` Mike Frysinger
2012-02-23 14:25 ` [U-Boot] [PATCH 1/2] usb: align buffers at cacheline Puneet Saxena
2012-02-23 18:15 ` Mike Frysinger
2012-02-24 11:27 ` puneets
2012-02-24 12:42 ` Simon Glass
2012-02-27 15:36 ` [U-Boot] [PATCH v2 " Puneet Saxena
2012-02-27 16:49 ` Marek Vasut
2012-02-27 17:03 ` Simon Glass
2012-02-27 17:11 ` Marek Vasut
2012-02-27 17:27 ` Simon Glass
2012-02-29 14:21 ` [U-Boot] [PATCH v3 " Puneet Saxena
2012-02-29 21:35 ` Marek Vasut
2012-03-01 13:51 ` puneets
2012-03-01 18:38 ` Marek Vasut
2012-03-02 6:56 ` puneets
2012-03-02 10:43 ` Marek Vasut
2012-03-02 12:50 ` puneets
2012-03-02 12:58 ` Marek Vasut
2012-03-02 13:35 ` [U-Boot] [PATCH v4] " Puneet Saxena
2012-03-02 13:46 ` Marek Vasut
2012-03-02 14:00 ` puneets
2012-03-02 14:41 ` Marek Vasut
2012-03-02 15:21 ` puneets
2012-03-02 15:59 ` Marek Vasut
2012-03-02 16:45 ` Wolfgang Denk
2012-03-05 7:16 ` [U-Boot] [PATCH v5] " Puneet Saxena
2012-03-05 13:24 ` Eric Nelson
2012-03-05 13:35 ` Marek Vasut
2012-03-05 14:46 ` [U-Boot] [PATCH v8] " Puneet Saxena
2012-03-05 15:35 ` Marek Vasut
2012-03-05 18:18 ` Simon Glass
2012-03-06 0:36 ` Marek Vasut
2012-03-06 0:39 ` Marek Vasut
2012-03-06 7:00 ` puneets
2012-03-06 8:22 ` Marek Vasut
2012-03-06 3:07 ` Mike Frysinger
2012-03-07 7:12 ` puneets
2012-03-07 9:20 ` puneets
2012-03-07 22:06 ` Marek Vasut
2012-03-08 11:21 ` puneets
2012-03-08 14:12 ` Marek Vasut
2012-03-09 6:15 ` puneets
2012-03-09 12:03 ` Marek Vasut
2012-03-11 2:35 ` Mike Frysinger
2012-03-14 2:05 ` Marek Vasut
2012-03-16 4:39 ` Marek Vasut
2012-03-16 7:42 ` puneets
2012-03-16 8:52 ` Marek Vasut
2012-03-19 14:29 ` puneets
2012-03-19 14:43 ` Marek Vasut
2012-03-19 15:19 ` Tom Warren
2012-03-19 15:46 ` Marek Vasut
2012-04-02 15:59 ` Tom Warren
2012-04-02 16:11 ` Marek Vasut
2012-04-02 16:16 ` Tom Warren
2012-04-02 16:32 ` Marek Vasut
2012-04-03 6:05 ` puneets
2012-03-05 7:27 ` [U-Boot] [PATCH v6] " Puneet Saxena
2012-03-05 12:03 ` Marek Vasut
2012-03-05 12:21 ` [U-Boot] [PATCH v7] " Puneet Saxena
2012-03-05 12:41 ` Marek Vasut
2012-03-06 3:28 ` [U-Boot] [PATCH v4] " Mike Frysinger
2012-03-06 8:24 ` Marek Vasut
2012-03-06 16:42 ` Mike Frysinger
2012-02-29 14:21 ` [U-Boot] [PATCH v3 2/2] usb: Add CONFIG to fetch string descriptor Puneet Saxena
2012-02-29 21:29 ` Marek Vasut
2012-03-01 11:07 ` puneets
2012-03-01 11:45 ` Marek Vasut
2012-03-01 12:59 ` puneets [this message]
2012-03-01 13:13 ` Marek Vasut
2012-03-05 12:48 ` Marek Vasut
2012-03-05 13:14 ` puneets
2012-03-05 21:15 ` Marek Vasut
2012-02-28 9:34 ` [U-Boot] [PATCH v2 1/2] usb: align buffers at cacheline puneets
2012-02-29 21:38 ` Marek Vasut
2012-02-27 15:36 ` [U-Boot] [PATCH v2 2/2] usb: Add CONFIG to fetch string descriptor Puneet Saxena
2012-02-27 18:28 ` Mike Frysinger
2012-02-27 15:37 ` [U-Boot] [PATCH 1/2] usb: align buffers at cacheline puneets
2012-02-23 14:25 ` [U-Boot] [PATCH 2/2] usb: Add quirk "USB_QUIRK_STRING_FETCH_255" Puneet Saxena
2012-02-23 15:20 ` Tom Rini
2012-02-23 16:04 ` Tom Warren
2012-02-24 7:52 ` puneets
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=4F4F72B1.2020504@nvidia.com \
--to=puneets@nvidia.com \
--cc=u-boot@lists.denx.de \
/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