Re: [PATCH] OMAP: USB : Fix the EHCI enumeration and core retention issue

2012-07-11 Thread Munegowda, Keshava
On Wed, Jul 11, 2012 at 7:53 PM, Kevin Hilman  wrote:
> "Munegowda, Keshava"  writes:
>
>> On Wed, Jul 11, 2012 at 3:59 PM, Samuel Ortiz  wrote:
>>> Hi Keshava, Kevin,
>>>
>>> On Fri, Jul 06, 2012 at 05:29:00PM +0530, Munegowda, Keshava wrote:
 Samuel
   I have sent that patch to disable the ehci in
 omap2plus_defconfig; after merging that
 please merge this patch too. This will fix the crashes in during boot
 with NFS in beagleXM
>>> I'm going to apply and push this patch for 3.5, and the defconfig patch can 
>>> be
>>> pushed through Tony's tree.
>>> Kevin, could you please ACK it ?
>>>
>>> Cheers,
>>> Samuel.
>>>
>>
>> Thanks Samuel
>>
>> Kevin,
>> need your ack for this.
>
> You never answered earlier questions from myself or Russ Dill about the
> more targetted patches from Russ:
>
>ARM: OMAP: USB: Fixup ehci_hcd_omap_probe error path
>Fix OMAP EHCI suspend/resume failure (i693) '354ab856' causes
>
> Also, your current $SUBJECT patch is large and not well
> described. e.g. what is "not correct" and why.  Why does it fix the
> problems mentioned?  The original changelog mentions the "core retention
> issue" but this patch does nothing to address that.  If you want an Ack
> from me, especially because I'm not an expert in this IP, you'll have to
> describe things in a way that I can understand.
>
> IMO, at this point of the dev cycle (trying to stabilize v3.5), the full
> cleanup/fix of this feature will need to be done for v3.6.  For v3.5, I
> think the two patches from Russ Dill should be merged.   They are
> targetted fixes and very well described.
>
> Kevin
>


Hi Kevin
The usb2 host of omap3/4/5 silicons has the following ips

1. UHH   (  /drivers/mfd/omap-usb-host.c ) -- platform driver
2. TLL( /drivers/mfd/omap-usb-host.c )
3. ehci( /drivers/usb/host/ehci-omap.c)  - platform driver
4. ohci ( /drivers/usb/host/ohci-omap3.c ) - platform drivers

The 3 platform drivers exists to make the ehci/ohci functional.

The  UHH-TLL or usb host core driver is the parent platform driver of
ehci and ohci.
This parent driver doe the clock enable/disable which common for both
ehci and ohci.
takes care of common port setting and clocks during suspend and resume
and ensures
that there is no overwrites by ehci and ohci platform drivers.

The commit id  354ab8567ae3107a8cbe7228c3181990ba598aac titled
"Fix OMAP EHCI suspend/resume failure (i693)" was handling the clocks in
the ehci driver it self, instead it should be handled by usb host core
driver  as per above
explanation. so, the UHH-TLL Driver should handle the changes done by
354ab8567ae3107a8cbe7228c3181990ba598aac.


hence this patch removes the changed done by the commit id
354ab8567ae3107a8cbe7228c3181990ba598aac

suppose if this patch is not included, then it will cause the
following two problems

1.  crash during the system boot
   - observed in beagle xm , with NFS file system
   the Ethernet is through
ehci driver , since the ehci ports clocks are not handled properly
 by this commit id
354ab8567ae3107a8cbe7228c3181990ba598aac,  it leads to crash

2. crash during suspend/resume
  - observed in beagle xm with ram fs
 if the ehci is driver is included
and if it tries to suspend it leads to crash

regards
keshava
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: usb sound issue ...

2012-07-11 Thread Andiry Xu

On 07/12/2012 01:47 AM, Dr. Ing. Dieter Jurzitza wrote:

Dear Sarah,
dear Andiry,
as I do not know wheter or not attachements to emails are tolerated in the
mailing list, I send this directly to you - please advise if I'd send that
somewhere else.
Please find attached the result of dmesg after logout - login. According to
your request, I activated both CONFIG_USB_DEBUG and
CONFIG_USB_XHCI_HCD_DEBUGGING.
Let me know if you need anything more than this  thanks again,



The dmesg is catched with test patch applied, right?

[274418.776800] xhci_hcd :00:14.0: xhci_drop_endpoint called for 
udev 880327d80800
[274418.776804] xhci_hcd :00:14.0: drop ep 0x3, slot id 1, new drop 
flags = 0x40, new add flags = 0x0, new slot info = 0x810
[274418.776807] xhci_hcd :00:14.0: xhci_check_bandwidth called for 
udev 880327d80800

[274418.776808] xhci_hcd :00:14.0: New Input Control Context:
[274418.776811] xhci_hcd :00:14.0: @880037c2b000 (virt) 
@37c2b000 (dma) 0x40 - drop flags
[274418.776813] xhci_hcd :00:14.0: @880037c2b004 (virt) 
@37c2b004 (dma) 0x01 - add flags
[274418.776815] xhci_hcd :00:14.0: @880037c2b008 (virt) 
@37c2b008 (dma) 0x00 - rsvd2[0]
[274418.776817] xhci_hcd :00:14.0: @880037c2b00c (virt) 
@37c2b00c (dma) 0x00 - rsvd2[1]
[274418.776819] xhci_hcd :00:14.0: @880037c2b010 (virt) 
@37c2b010 (dma) 0x00 - rsvd2[2]
[274418.776822] xhci_hcd :00:14.0: @880037c2b014 (virt) 
@37c2b014 (dma) 0x00 - rsvd2[3]
[274418.776824] xhci_hcd :00:14.0: @880037c2b018 (virt) 
@37c2b018 (dma) 0x00 - rsvd2[4]
[274418.776826] xhci_hcd :00:14.0: @880037c2b01c (virt) 
@37c2b01c (dma) 0x00 - rsvd2[5]

[274418.776828] xhci_hcd :00:14.0: Slot Context:
[274418.776830] xhci_hcd :00:14.0: @880037c2b020 (virt) 
@37c2b020 (dma) 0x810 - dev_info
[274418.776840] xhci_hcd :00:14.0: @880037c2b024 (virt) 
@37c2b024 (dma) 0x04 - dev_info2
[274418.776842] xhci_hcd :00:14.0: @880037c2b028 (virt) 
@37c2b028 (dma) 0x00 - tt_info
[274418.776844] xhci_hcd :00:14.0: @880037c2b02c (virt) 
@37c2b02c (dma) 0x00 - dev_state
[274418.776846] xhci_hcd :00:14.0: @880037c2b030 (virt) 
@37c2b030 (dma) 0x00 - rsvd[0]
[274418.776848] xhci_hcd :00:14.0: @880037c2b034 (virt) 
@37c2b034 (dma) 0x00 - rsvd[1]
[274418.776850] xhci_hcd :00:14.0: @880037c2b038 (virt) 
@37c2b038 (dma) 0x00 - rsvd[2]
[274418.776852] xhci_hcd :00:14.0: @880037c2b03c (virt) 
@37c2b03c (dma) 0x00 - rsvd[3]

[274418.776854] xhci_hcd :00:14.0: Endpoint 00 Context:
[274418.776856] xhci_hcd :00:14.0: @880037c2b040 (virt) 
@37c2b040 (dma) 0x01 - ep_info
[274418.776858] xhci_hcd :00:14.0: @880037c2b044 (virt) 
@37c2b044 (dma) 0x080026 - ep_info2
[274418.776860] xhci_hcd :00:14.0: @880037c2b048 (virt) 
@37c2b048 (dma) 0x37739801 - deq
[274418.776862] xhci_hcd :00:14.0: @880037c2b050 (virt) 
@37c2b050 (dma) 0x00 - tx_info
[274418.776864] xhci_hcd :00:14.0: @880037c2b054 (virt) 
@37c2b054 (dma) 0x00 - rsvd[0]
[274418.776866] xhci_hcd :00:14.0: @880037c2b058 (virt) 
@37c2b058 (dma) 0x00 - rsvd[1]
[274418.776868] xhci_hcd :00:14.0: @880037c2b05c (virt) 
@37c2b05c (dma) 0x00 - rsvd[2]

[274418.776870] xhci_hcd :00:14.0: Adding 0 ep ctxs, 3 now active.
[274418.776873] xhci_hcd :00:14.0: Recalculating BW for rootport 4
[274418.776876] xhci_hcd :00:14.0: Final bandwidth: 44, Limit: 1285, 
Reserved: 129, Available: 86 percent

[274418.776878] xhci_hcd :00:14.0: // Ding dong!
[274418.776881] xhci_hcd :00:14.0: Signal while waiting for 
configure endpoint command


Here the config ep command is interrupted(why?)

[274418.776883] xhci_hcd :00:14.0: xhci_reset_bandwidth called for 
udev 880327d80800

[274418.776886] usb 3-4: Not enough bandwidth for altsetting 0

usb_set_interface failed.

[274418.776932] xhci_hcd :00:14.0: Completed config ep cmd

Here the config ep command is completed, and the ep is disabled.

[274418.834168] [fglrx] IRQ 50 Disabled
[274419.224007] fglrx_pci :01:00.0: irq 50 for MSI/MSI-X
[274419.224339] [fglrx] Firegl kernel thread PID: 17485
[274419.224458] [fglrx] Firegl kernel thread PID: 17486
[274419.224576] [fglrx] Firegl kernel thread PID: 17487
[274419.224646] [fglrx] IRQ 50 Enabled
[274419.297830] [fglrx] Gart USWC size:1280 M.
[274419.297832] [fglrx] Gart cacheable size:508 M.
[274419.297835] [fglrx] Reserved FB block: Shared offset:0, size:100
[274419.297836] [fglrx] Reserved FB block: Unshared offset:f8fd000, 
size:403000
[274419.297837] [fglrx] Reserved FB block: Unshared offset:3ffee000, 
size:12000
[274429.635112] xhci_hcd :00:14.0: xhci_drop_endpoint called for 
udev 880327d80800
[274429.635116] xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called 
with disabled ep 8803e0363880


Here software wants to set interface again

Re: xhci_hcd: external drive not initialised if already connected during restart or cold boot

2012-07-11 Thread Andiry Xu

On 07/12/2012 10:53 AM, Matt Causey wrote:

On Wed, Jul 11, 2012 at 11:03 AM, Matt Causey  wrote:

On Wed, Jul 11, 2012 at 10:12 AM, Matt Causey  wrote:

On Tue, Jul 10, 2012 at 10:55 PM, Andiry Xu  wrote:

On 07/11/2012 01:56 AM, Matt wrote:


Lee Harris   writes:




Hi Sarah

Whenever I restart or coldboot, my external drive (3.5 sata in a USB3
enclosure) is not detected / initialised correctly. fdisk -l does not
show the drive at all.
I have found that I have to:
turn it off ( or disconnect the usb cable)
modprobe -r xhci_hcd
modprobe xhci_hcd
and then turn it on. It is then found and initialised.




I'm having this same issue.  Does anyone have any ideas?



Can you post the bootup dmesg with device connected and CONFIG_USB_DEBUG and
CONFIG_USB_XHCI_HCD_DEBUGGING enabled?

Thanks,
Andiry




Some more background...I've got another OS image that runs Linux
2.6.32-33-generic (Ubuntu 10.4 LTS) - and that OS on this hardware
works as expected.  I've also tested Linux 3.2.22 and it fails in the
same way on my system.

Upon more digging, what I'm finding is that if I leave my device
disconnected from the USB3 port when I boot the system, and the
connect the device after the system has booted fully, the device works
correctly.  The problem occurs when a device is connected to the USB3
port, and I simply boot the system.  The dmesg below is from the test
system that has the problem.  My configuration is also included as an
attachment, in case that's helpful.

dmesg:


...


xhci_hcd :05:00.0: PCI INT A ->  GSI 19 (level, low) ->  IRQ 19
xhci_hcd :05:00.0: setting latency timer to 64
xhci_hcd :05:00.0: xHCI Host Controller
drivers/usb/core/inode.c: creating file '003'
xhci_hcd :05:00.0: new USB bus registered, assigned bus number 3
xhci_hcd :05:00.0: xHCI capability registers at f806:
xhci_hcd :05:00.0: CAPLENGTH AND HCIVERSION 0x960020:
xhci_hcd :05:00.0: CAPLENGTH: 0x20
xhci_hcd :05:00.0: HCIVERSION: 0x96
xhci_hcd :05:00.0: HCSPARAMS 1: 0x4000840
xhci_hcd :05:00.0:   Max device slots: 64
xhci_hcd :05:00.0:   Max interrupters: 8
xhci_hcd :05:00.0:   Max ports: 4
xhci_hcd :05:00.0: HCSPARAMS 2: 0xcf1
xhci_hcd :05:00.0:   Isoc scheduling threshold: 1
xhci_hcd :05:00.0:   Maximum allowed segments in event ring: 15
xhci_hcd :05:00.0: HCSPARAMS 3 0x7ff000a:
xhci_hcd :05:00.0:   Worst case U1 device exit latency: 10
xhci_hcd :05:00.0:   Worst case U2 device exit latency: 2047
xhci_hcd :05:00.0: HCC PARAMS 0x270f06d:
xhci_hcd :05:00.0:   HC generates 64 bit addresses
xhci_hcd :05:00.0:   FIXME: more HCCPARAMS debugging
xhci_hcd :05:00.0: RTSOFF 0x4a0:
xhci_hcd :05:00.0: xHCI operational registers at f8060020:
xhci_hcd :05:00.0: USBCMD 0x0:
xhci_hcd :05:00.0:   HC is being stopped
xhci_hcd :05:00.0:   HC has finished hard reset
xhci_hcd :05:00.0:   Event Interrupts disabled
xhci_hcd :05:00.0:   Host System Error Interrupts disabled
xhci_hcd :05:00.0:   HC has finished light reset
xhci_hcd :05:00.0: USBSTS 0x0:
xhci_hcd :05:00.0:   Event ring is empty
xhci_hcd :05:00.0:   No Host System Error
xhci_hcd :05:00.0:   HC is running
xhci_hcd :05:00.0: f8060420 port status reg = 0x2a0
xhci_hcd :05:00.0: f8060424 port power reg = 0x0
xhci_hcd :05:00.0: f8060428 port link reg = 0x0
xhci_hcd :05:00.0: f806042c port reserved reg = 0x0
xhci_hcd :05:00.0: f8060430 port status reg = 0xa03


Here the device is connected.


xhci_hcd :05:00.0: f8060434 port power reg = 0x0
xhci_hcd :05:00.0: f8060438 port link reg = 0x0
xhci_hcd :05:00.0: f806043c port reserved reg = 0x0
xhci_hcd :05:00.0: f8060440 port status reg = 0x2a0
xhci_hcd :05:00.0: f8060444 port power reg = 0x0
xhci_hcd :05:00.0: f8060448 port link reg = 0x0
xhci_hcd :05:00.0: f806044c port reserved reg = 0x0
xhci_hcd :05:00.0: f8060450 port status reg = 0x2a0
xhci_hcd :05:00.0: f8060454 port power reg = 0x0
xhci_hcd :05:00.0: f8060458 port link reg = 0x0
xhci_hcd :05:00.0: f806045c port reserved reg = 0x0
xhci_hcd :05:00.0: // Halt the HC
xhci_hcd :05:00.0: `MEM_WRITE_DWORD(3'b000, 32'hf8060020, 32'h0, 4'hf);
xhci_hcd :05:00.0: can't setup


This is where the error occurs. The host controller is not halted.


xhci_hcd :05:00.0: USB bus 3 deregistered
xhci_hcd :05:00.0: PCI INT A disabled
xhci_hcd :05:00.0: init :05:00.0 fail, -110
xhci_hcd: probe of :05:00.0 failed with error -110


...





Hello again, everyone!

OK apologies again for replying to my own stinking posting...but I've
made some progress and wanted to note it here for those hapless souls
wandering through the internets later.

You'll notice that the kernel configuration I posted earlier is almost
entirely monolithic.  I had assumed that I could just say
CONFIG_USB_XHCI_HCD=y and be done for enabling xHCI.  Well Sarah
mentioned here: http://sarah.thesharps.us/2009-06-09-13-30.c

[PATCH 1/2 v2] USB: dwc3-exynos: Add support for device tree

2012-07-11 Thread Vivek Gautam
This patch adds support to parse probe data for
dwc3 driver for exynos using device tree

Signed-off-by: Praveen Paneri 
Signed-off-by: Vivek Gautam 

diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index d190301..9ae91b7 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "core.h"
 
@@ -30,6 +31,8 @@ struct dwc3_exynos {
struct clk  *clk;
 };
 
+static u64 dwc3_exynos_dma_mask = DMA_BIT_MASK(32);
+
 static int __devinit dwc3_exynos_probe(struct platform_device *pdev)
 {
struct dwc3_exynos_data *pdata = pdev->dev.platform_data;
@@ -46,6 +49,16 @@ static int __devinit dwc3_exynos_probe(struct 
platform_device *pdev)
goto err0;
}
 
+   /*
+* Right now device-tree probed devices don't get dma_mask set.
+* Since shared usb code relies on it, set it here for now.
+* Once we move to full device tree support this will vanish off.
+*/
+   if (!pdev->dev.dma_mask)
+   pdev->dev.dma_mask = &dwc3_exynos_dma_mask;
+   if (!pdev->dev.coherent_dma_mask)
+   pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+
platform_set_drvdata(pdev, exynos);
 
devid = dwc3_get_device_id();
@@ -135,11 +148,20 @@ static int __devexit dwc3_exynos_remove(struct 
platform_device *pdev)
return 0;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id exynos_xhci_match[] = {
+   { .compatible = "samsung,exynos-xhci" },
+   {},
+};
+MODULE_DEVICE_TABLE(of, exynos_xhci_match);
+#endif
+
 static struct platform_driver dwc3_exynos_driver = {
.probe  = dwc3_exynos_probe,
.remove = __devexit_p(dwc3_exynos_remove),
.driver = {
.name   = "exynos-dwc3",
+   .of_match_table = of_match_ptr(exynos_xhci_match),
},
 };
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2 v2] USB: dwc3-exynos: Add vbus setup function to the exynos dwc3 glue layer

2012-07-11 Thread Vivek Gautam
From: Abhilash Kesavan 

This patch retrieves and configures the vbus control gpio via
the device tree. The suspend/resume callbacks will be later
modified for vbus control.

Signed-off-by: Abhilash Kesavan 
Signed-off-by: Vivek Gautam 

diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index 9ae91b7..5dd87c1 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "core.h"
 
@@ -31,6 +32,28 @@ struct dwc3_exynos {
struct clk  *clk;
 };
 
+static int dwc3_setup_vbus_gpio(struct platform_device *pdev)
+{
+   int err;
+   int gpio;
+
+   if (!pdev->dev.of_node)
+   return 0;
+
+   gpio = of_get_named_gpio(pdev->dev.of_node,
+   "samsung,vbus-gpio", 0);
+   if (!gpio_is_valid(gpio))
+   return 0;
+
+   err = gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, "dwc3_vbus_gpio");
+   if (err) {
+   dev_err(&pdev->dev, "can't request dwc3 vbus gpio %d", gpio);
+   return err;
+   }
+
+   return err;
+}
+
 static u64 dwc3_exynos_dma_mask = DMA_BIT_MASK(32);
 
 static int __devinit dwc3_exynos_probe(struct platform_device *pdev)
@@ -59,6 +82,8 @@ static int __devinit dwc3_exynos_probe(struct platform_device 
*pdev)
if (!pdev->dev.coherent_dma_mask)
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
 
+   dwc3_setup_vbus_gpio(pdev);
+
platform_set_drvdata(pdev, exynos);
 
devid = dwc3_get_device_id();
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2 v2] USB: host: Add Device tree support for dwc3-exynos

2012-07-11 Thread Vivek Gautam
Changes from v1:
1) Added comment to explain inclusion of dma_mask through pdata.
2) Replaced gpio_request() with gpio_request_one()
3) Removed gpio_set_value()

This patchset is based and tested on 3.5 rc5.

Abhilash Kesavan (1):
  USB: dwc3-exynos: Add vbus setup function to the exynos dwc3 glue
layer

Vivek Gautam (1):
  USB: dwc3-exynos: Add support for device tree

 drivers/usb/dwc3/dwc3-exynos.c |   47 
 1 files changed, 47 insertions(+), 0 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3 v2] USB: ehci-s5p: Add vbus setup function to the s5p ehci glue layer

2012-07-11 Thread Vivek Gautam
From: Abhilash Kesavan 

This patch retrieves and configures the vbus control gpio via
the device tree. The suspend/resume callbacks will be later
modified for vbus control.

Signed-off-by: Abhilash Kesavan 
Signed-off-by: Vivek Gautam 

diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
index 52d0049..9f9870c 100644
--- a/drivers/usb/host/ehci-s5p.c
+++ b/drivers/usb/host/ehci-s5p.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -64,6 +65,28 @@ static const struct hc_driver s5p_ehci_hc_driver = {
.clear_tt_buffer_complete   = ehci_clear_tt_buffer_complete,
 };
 
+static int s5p_ehci_setup_gpio(struct platform_device *pdev)
+{
+   int err;
+   int gpio;
+
+   if (!pdev->dev.of_node)
+   return 0;
+
+   gpio = of_get_named_gpio(pdev->dev.of_node,
+   "samsung,vbus-gpio", 0);
+   if (!gpio_is_valid(gpio))
+   return 0;
+
+   err = gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, "ehci_vbus_gpio");
+   if (err) {
+   dev_err(&pdev->dev, "can't request ehci vbus gpio %d", gpio);
+   return err;
+   }
+
+   return err;
+}
+
 static u64 ehci_s5p_dma_mask = DMA_BIT_MASK(32);
 
 static int __devinit s5p_ehci_probe(struct platform_device *pdev)
@@ -92,6 +115,8 @@ static int __devinit s5p_ehci_probe(struct platform_device 
*pdev)
if (!pdev->dev.coherent_dma_mask)
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
 
+   s5p_ehci_setup_gpio(pdev);
+
s5p_ehci = kzalloc(sizeof(struct s5p_ehci_hcd), GFP_KERNEL);
if (!s5p_ehci)
return -ENOMEM;
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3 v2] USB: ohci-exynos: Add support for device tree

2012-07-11 Thread Vivek Gautam
This patch adds support to parse probe data for
ohci driver for exynos using device tree.

Signed-off-by: Thomas Abraham 
Signed-off-by: Abhilash Kesavan 
Signed-off-by: Vivek Gautam 

diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index 2909621..c4ad60f 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -12,6 +12,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -71,6 +72,8 @@ static const struct hc_driver exynos_ohci_hc_driver = {
.start_port_reset   = ohci_start_port_reset,
 };
 
+static u64 ohci_exynos_dma_mask = DMA_BIT_MASK(32);
+
 static int __devinit exynos_ohci_probe(struct platform_device *pdev)
 {
struct exynos4_ohci_platdata *pdata;
@@ -87,6 +90,16 @@ static int __devinit exynos_ohci_probe(struct 
platform_device *pdev)
return -EINVAL;
}
 
+   /*
+* Right now device-tree probed devices don't get dma_mask set.
+* Since shared usb code relies on it, set it here for now.
+* Once we move to full device tree support this will vanish off.
+*/
+   if (!pdev->dev.dma_mask)
+   pdev->dev.dma_mask = &ohci_exynos_dma_mask;
+   if (!pdev->dev.coherent_dma_mask)
+   pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+
exynos_ohci = kzalloc(sizeof(struct exynos_ohci_hcd), GFP_KERNEL);
if (!exynos_ohci)
return -ENOMEM;
@@ -258,6 +271,14 @@ static const struct dev_pm_ops exynos_ohci_pm_ops = {
.resume = exynos_ohci_resume,
 };
 
+#ifdef CONFIG_OF
+static const struct of_device_id exynos_ohci_match[] = {
+   { .compatible = "samsung,exynos-ohci" },
+   {},
+};
+MODULE_DEVICE_TABLE(of, exynos_ohci_match);
+#endif
+
 static struct platform_driver exynos_ohci_driver = {
.probe  = exynos_ohci_probe,
.remove = __devexit_p(exynos_ohci_remove),
@@ -266,6 +287,7 @@ static struct platform_driver exynos_ohci_driver = {
.name   = "exynos-ohci",
.owner  = THIS_MODULE,
.pm = &exynos_ohci_pm_ops,
+   .of_match_table = of_match_ptr(exynos_ohci_match),
}
 };
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3 v2] USB: ehci-s5p: Add support for device tree

2012-07-11 Thread Vivek Gautam
This patch adds support to parse probe data for
ehci driver for exynos using device tree

Signed-off-by: Thomas Abraham 
Signed-off-by: Abhilash Kesavan 
Signed-off-by: Vivek Gautam 

diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
index c474cec..52d0049 100644
--- a/drivers/usb/host/ehci-s5p.c
+++ b/drivers/usb/host/ehci-s5p.c
@@ -13,6 +13,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -63,6 +64,8 @@ static const struct hc_driver s5p_ehci_hc_driver = {
.clear_tt_buffer_complete   = ehci_clear_tt_buffer_complete,
 };
 
+static u64 ehci_s5p_dma_mask = DMA_BIT_MASK(32);
+
 static int __devinit s5p_ehci_probe(struct platform_device *pdev)
 {
struct s5p_ehci_platdata *pdata;
@@ -79,6 +82,16 @@ static int __devinit s5p_ehci_probe(struct platform_device 
*pdev)
return -EINVAL;
}
 
+   /*
+* Right now device-tree probed devices don't get dma_mask set.
+* Since shared usb code relies on it, set it here for now.
+* Once we move to full device tree support this will vanish off.
+*/
+   if (!pdev->dev.dma_mask)
+   pdev->dev.dma_mask = &ehci_s5p_dma_mask;
+   if (!pdev->dev.coherent_dma_mask)
+   pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+
s5p_ehci = kzalloc(sizeof(struct s5p_ehci_hcd), GFP_KERNEL);
if (!s5p_ehci)
return -ENOMEM;
@@ -298,6 +311,14 @@ static int s5p_ehci_resume(struct device *dev)
 #define s5p_ehci_resumeNULL
 #endif
 
+#ifdef CONFIG_OF
+static const struct of_device_id exynos_ehci_match[] = {
+   { .compatible = "samsung,exynos-ehci" },
+   {},
+};
+MODULE_DEVICE_TABLE(of, exynos_ehci_match);
+#endif
+
 static const struct dev_pm_ops s5p_ehci_pm_ops = {
.suspend= s5p_ehci_suspend,
.resume = s5p_ehci_resume,
@@ -311,6 +332,7 @@ static struct platform_driver s5p_ehci_driver = {
.name   = "s5p-ehci",
.owner  = THIS_MODULE,
.pm = &s5p_ehci_pm_ops,
+   .of_match_table = of_match_ptr(exynos_ehci_match),
}
 };
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3 v2] USB: host: Add Device tree support for ohci-exynos & ehci-s5p

2012-07-11 Thread Vivek Gautam
From: Ajay Kumar 

Changes from v1:
1) Added comment to explain inclusion of dma_mask through pdata.
2) Replaced gpio_request() with gpio_request_one()
3) Removed gpio_set_value()

This patchset is based and tested on 3.5 rc5.
Abhilash Kesavan (1):
  USB: ehci-s5p: Add vbus setup function to the s5p ehci glue layer

Vivek Gautam (2):
  USB: ohci-exynos: Add support for device tree
  USB: ehci-s5p: Add support for device tree

 drivers/usb/host/ehci-s5p.c|   47 
 drivers/usb/host/ohci-exynos.c |   22 ++
 2 files changed, 69 insertions(+), 0 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] usb/host/ehci-hub: Fix the issue EG20T USB host controller has long resuming time, when pen drive is attached.

2012-07-11 Thread Tomoya MORINAGA
Intel EG20T USB host controller does not send SOF in resuming time after 
suspending, if the FLR bit was not cleared. When pen drive is attached, the 
controller has a long resuming time to try re-connect it. This patch clear the 
FLR bit in suspending time for fixing the issue.

Signed-off-by: Tomoya MORINAGA 
---
v2: Update comments from Alan Stern
Add patch description
Always clear the STS_FLR flag.
---
 drivers/usb/host/ehci-hub.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index fc9e7cc..818a2f1 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -318,6 +318,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
ehci_readl(ehci, &ehci->regs->intr_enable);
 
ehci->next_statechange = jiffies + msecs_to_jiffies(10);
+   ehci_writel(ehci, STS_FLR, &ehci->regs->status);
spin_unlock_irq (&ehci->lock);
 
/* ehci_work() may have re-enabled the watchdog timer, which we do not
-- 
1.7.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mceusb: Add Twisted Melon USB IDs

2012-07-11 Thread Mark Lord
Add USB identifiers for MCE compatible I/R transceivers from Twisted Melon.

Signed-off-by: Mark Lord 
---
Mauro, please queue this up for inclusion in linux-3.6.
Patch is also attached to bypass emailer mangling.
Thanks.

--- linux-3.5-rc6/drivers/media/rc/mceusb.c 2012-07-07 20:23:56.0 
-0400
+++ new/drivers/media/rc/mceusb.c   2012-07-11 18:44:03.113727658 -0400
@@ -199,6 +199,7 @@
 #define VENDOR_REALTEK 0x0bda
 #define VENDOR_TIVO0x105a
 #define VENDOR_CONEXANT0x0572
+#define VENDOR_TWISTEDMELON0x2596

 enum mceusb_model_type {
MCE_GEN2 = 0,   /* Most boards */
@@ -391,6 +392,12 @@
/* Conexant Hybrid TV RDU253S Polaris */
{ USB_DEVICE(VENDOR_CONEXANT, 0x58a5),
  .driver_info = CX_HYBRID_TV },
+   /* Twisted Melon Inc. - Manta Mini Receiver */
+   { USB_DEVICE(VENDOR_TWISTEDMELON, 0x8008) },
+   /* Twisted Melon Inc. - Manta Pico Receiver */
+   { USB_DEVICE(VENDOR_TWISTEDMELON, 0x8016) },
+   /* Twisted Melon Inc. - Manta Transceiver */
+   { USB_DEVICE(VENDOR_TWISTEDMELON, 0x8042) },
/* Terminating entry */
{ }
 };
Add USB identifiers for MCE compatible I/R transceivers from Twisted Melon.

Signed-off-by: Mark Lord 
---
Mauro, please queue this up for inclusion in linux-3.6.
Thanks.

--- linux-3.5-rc6/drivers/media/rc/mceusb.c	2012-07-07 20:23:56.0 -0400
+++ new/drivers/media/rc/mceusb.c	2012-07-11 18:44:03.113727658 -0400
@@ -199,6 +199,7 @@
 #define VENDOR_REALTEK		0x0bda
 #define VENDOR_TIVO		0x105a
 #define VENDOR_CONEXANT		0x0572
+#define VENDOR_TWISTEDMELON	0x2596
 
 enum mceusb_model_type {
 	MCE_GEN2 = 0,		/* Most boards */
@@ -391,6 +392,12 @@
 	/* Conexant Hybrid TV RDU253S Polaris */
 	{ USB_DEVICE(VENDOR_CONEXANT, 0x58a5),
 	  .driver_info = CX_HYBRID_TV },
+	/* Twisted Melon Inc. - Manta Mini Receiver */
+	{ USB_DEVICE(VENDOR_TWISTEDMELON, 0x8008) },
+	/* Twisted Melon Inc. - Manta Pico Receiver */
+	{ USB_DEVICE(VENDOR_TWISTEDMELON, 0x8016) },
+	/* Twisted Melon Inc. - Manta Transceiver */
+	{ USB_DEVICE(VENDOR_TWISTEDMELON, 0x8042) },
 	/* Terminating entry */
 	{ }
 };


Re: Can anyone tell me whether there is specific (or general) Linux driver support for these Digi USB-Serial Converters ?

2012-07-11 Thread simon
Hi Richard,

> 1. Edgeport/4s MEI Isolated - 4 RS-232/422/485 serial DB-9 software
> selectable with galvanic isolation (Part # 301-1000-95)
> http://www.digi.com/products/model?mid=2690

I have a version very similar to this (5787-01/301-1000-04, without
the isolation I guess) and it is 'plug and play' under linux.


You might also be interested to know that these units can be switched
between RS232/RS422 modes with IOCTLs, which is described a little here:

http://www.spinics.net/lists/linux-usb/msg43355.html
http://www.digipedia.pl/usenet/thread/19505/8698/

Simon

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Can anyone tell me whether there is specific (or general) Linux driver support for these Digi USB-Serial Converters ?

2012-07-11 Thread Greg KH
On Thu, Jul 12, 2012 at 05:25:58AM +1000, Richard McLean wrote:
> I am particularly interested in the following models of Digi USB-Serial port 
> adapter :
> 
> 1. Edgeport/4s MEI Isolated - 4 RS-232/422/485 serial DB-9 software
> selectable with galvanic isolation (Part # 301-1000-95)
> http://www.digi.com/products/model?mid=2690
> 
> 2. Edgeport/2c - 2 RS-232 serial DB-9, captive 2-meter cable (Part # 
> 301-1003-10)
> http://www.digi.com/products/model?mid=249

What we need in order to determine this specifically is what is the
vendor / product ids of these devices.  You can get that if you plug one
into a computer and look it up (different operating systems have
different ways of doing it, use 'lsusb' on Linux to determine this.)

At first glance, I would think that yes, we do support it, but we need
the device ids to be certain.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Can anyone tell me whether there is specific (or general) Linux driver support for these Digi USB-Serial Converters ?

2012-07-11 Thread Christopher Harvey
On Thu, Jul 12, 2012 at 05:25:58AM +1000, Richard McLean wrote:
> What I need is advice regarding a suitable USB-Serial port adapter, as my 
> Linux laptop does not have a serial port.
> 
> There are further constraints in the system - it would be very desirable to 
> have a USB-Serial port adapter with "medical grade galvanic isolation on its 
> serial lines".
> 
> As far as I can see, only Digi has this.
> 
> I am particularly interested in the following models of Digi USB-Serial port 
> adapter :
> 
> 1. Edgeport/4s MEI Isolated - 4 RS-232/422/485 serial DB-9 software 
> selectable with galvanic isolation (Part # 301-1000-95)
> http://www.digi.com/products/model?mid=2690
> 
> 2. Edgeport/2c - 2 RS-232 serial DB-9, captive 2-meter cable (Part # 
> 301-1003-10)
> http://www.digi.com/products/model?mid=249
> 
> (the former has the proper electrical isolation for "production use" while 
> the latter does not, though it is more compact and will be used for 
> development where the monitoring equipment is not connected to a patient)
> 
> Can anyone tell me whether these two USB-Serial port adapters are supported 
> by Ubuntu Linux 12.04 ?
> (The Digi datasheet for these products says "Driver support provided by Linux 
> USB maintainers" in reference to Linux Support)
> (The Ubuntu website says that the 12.04 LTS Release ships with the Ubuntu 
> 3.2.0-23.36 kernel which is based on the v3.2.14 upstream stable Linux kernel)
> 
> Are there specific drivers required or is there an applicable generic driver, 
> and would I have to find this and install it, or is it built into the kernel ?

I don't think there is a generic driver for usb<->serial converters. I
don't think the USB standard defines these devices.

> 
> Could I expect relative smooth sailing from a driver/hardware compatibility 
> perspective ?

Once you have a driver they are simple to use. I've never had problems
with FTDI or Prolific. Haven't used any others.

Here is the list from the kernel:

--- USB Serial Converter support
  USB Serial Console device support
  Functions for loading firmware on EZUSB chips
  USB Generic Serial Driver
  USB AIRcable Bluetooth Dongle Driver
  USB ARK Micro 3116 USB Serial Driver
  USB Belkin and Peracom Single Port Serial Driver
  USB Winchiphead CH341 Single Port Serial Driver
  USB ConnectTech WhiteHEAT Serial Driver
  USB Digi International AccelePort USB Serial Driver
  USB CP210x family of UART Bridge Controllers
  USB Cypress M8 USB Serial Driver
  USB Empeg empeg-car Mark I/II Driver
  USB FTDI Single Port Serial Driver
  USB Fundamental Software Dongle Driver
  USB Handspring Visor / Palm m50x / Sony Clie Driver
  USB PocketPC PDA Driver
  USB IR Dongle Serial Driver
  USB Inside Out Edgeport Serial Driver
  USB Inside Out Edgeport Serial Driver (TI devices)
  USB Garmin GPS driver
  USB IPWireless (3G UMTS TDD) Driver
  USB Infinity USB Unlimited Phoenix Driver
  USB Keyspan PDA Single Port Serial Driver
  USB Keyspan USA-xxx Serial Driver
  USB KL5KUSB105 (Palmconnect) Driver
  USB KOBIL chipcard reader
  USB MCT Single Port Serial Driver
  USB Moschip 7720 Serial Driver
  USB Moschip 7840/7820 USB Serial Driver
  USB Motorola Phone modem driver
  USB Navman GPS device
  USB Prolific 2303 Single Port Serial Driver
  USB Ours Technology Inc. OTi-6858 USB To RS232 Bridge Controller
  USB Qualcomm Auxiliary Serial Port Driver
  USB Qualcomm Serial modem
  USB SPCP8x5 USB To Serial Driver
  USB HP4x Calculators support
  USB Safe Serial (Encapsulated) Driver
  USB Siemens MPI driver
  USB Sierra Wireless Driver
  USB Symbol Barcode driver (serial mode)
  USB TI 3410/5052 Serial Driver
  USB REINER SCT cyberJack pinpad/e-com chipcard reader
  USB Xircom / Entregra Single Port Serial Driver
  USB driver for GSM and CDMA modems
  USB ZyXEL omni.net LCD Plus Driver
  USB Opticon Barcode driver (serial mode)
  USB ViVOpay serial interface driver
  ZIO Motherboard USB serial interface driver
  USB Quatech SSU-100 Single Port Serial Driver

there could be other drivers floating around not included with the
kernel. (stick to the ones in the kernel if you can)

-Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Can anyone tell me whether there is specific (or general) Linux driver support for these Digi USB-Serial Converters ?

2012-07-11 Thread Richard McLean
Hi All,

This is my first post on this list, and I am a relative newcomer to Linux, so 
please excuse me if any of my questions seem a bit "basic"...

I'm an Anaesthetist from Australia (the Americans on the list would call that 
an Anaesthesiologist) so programming is more of a hobby than a job.

I am trying to develop some software to pull down information from a piece of 
patient monitoring equipment in the operating room to a laptop running Ubuntu 
Linux 12.04.

The patient monitor speaks to the external world over a RS-232 Serial Port.

I have information about the protocols and formats etc. to communicate with 
this device.

What I need is advice regarding a suitable USB-Serial port adapter, as my Linux 
laptop does not have a serial port.

There are further constraints in the system - it would be very desirable to 
have a USB-Serial port adapter with "medical grade galvanic isolation on its 
serial lines".

As far as I can see, only Digi has this.

I am particularly interested in the following models of Digi USB-Serial port 
adapter :

1. Edgeport/4s MEI Isolated - 4 RS-232/422/485 serial DB-9 software selectable 
with galvanic isolation (Part # 301-1000-95)
http://www.digi.com/products/model?mid=2690

2. Edgeport/2c - 2 RS-232 serial DB-9, captive 2-meter cable (Part # 
301-1003-10)
http://www.digi.com/products/model?mid=249

(the former has the proper electrical isolation for "production use" while the 
latter does not, though it is more compact and will be used for development 
where the monitoring equipment is not connected to a patient)

Can anyone tell me whether these two USB-Serial port adapters are supported by 
Ubuntu Linux 12.04 ?
(The Digi datasheet for these products says "Driver support provided by Linux 
USB maintainers" in reference to Linux Support)
(The Ubuntu website says that the 12.04 LTS Release ships with the Ubuntu 
3.2.0-23.36 kernel which is based on the v3.2.14 upstream stable Linux kernel)

Are there specific drivers required or is there an applicable generic driver, 
and would I have to find this and install it, or is it built into the kernel ?

Could I expect relative smooth sailing from a driver/hardware compatibility 
perspective ?

Thanks in advance for any advice.

Richard--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RESEND 3/3] usb: storage: update usb devices for write cache quirk in quirk list.

2012-07-11 Thread Amit Sahrawat
Hi James,
Please have a look at the patchset and share your opinion.
If there is anything more to it - please let us know.

Thanks & Regards,
Amit Sahrawat


On Sun, Jul 8, 2012 at 8:35 AM, Namjae Jeon  wrote:
> From: Namjae Jeon 
>
> Update information of Seagate Portable HDD and WD My Passport HDD in
> quirk list.
>
> Signed-off-by: Namjae Jeon 
> Signed-off-by: Pankaj Kumar 
> Signed-off-by: Amit Sahrawat 
> Acked-by: Alan Stern 
> ---
>  drivers/usb/storage/unusual_devs.h |   12 
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/usb/storage/unusual_devs.h 
> b/drivers/usb/storage/unusual_devs.h
> index 1719886..62a31be 100644
> --- a/drivers/usb/storage/unusual_devs.h
> +++ b/drivers/usb/storage/unusual_devs.h
> @@ -1267,6 +1267,12 @@ UNUSUAL_DEV( 0x0af0, 0xd357, 0x, 0x,
> USB_SC_DEVICE, USB_PR_DEVICE, NULL,
> 0 ),
>
> +/* Reported by Namjae Jeon  */
> +UNUSUAL_DEV(0x0bc2, 0x2300, 0x, 0x,
> +   "Seagate",
> +   "Portable HDD",
> +   USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_WRITE_CACHE),
> +
>  /* Reported by Ben Efros  */
>  UNUSUAL_DEV( 0x0bc2, 0x3010, 0x, 0x,
> "Seagate",
> @@ -1468,6 +1474,12 @@ UNUSUAL_DEV(  0x1058, 0x0704, 0x, 0x,
> USB_SC_DEVICE, USB_PR_DEVICE, NULL,
> US_FL_SANE_SENSE),
>
> +/* Reported by Namjae Jeon  */
> +UNUSUAL_DEV(0x1058, 0x070a, 0x, 0x,
> +   "Western Digital",
> +   "My Passport HDD",
> +   USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_WRITE_CACHE),
> +
>  /* Reported by Fabio Venturi 
>   * The device reports a vendor-specific bDeviceClass.
>   */
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC/PATCH v2] usb: dwc3: Introduce OTG driver for dwc3

2012-07-11 Thread Ido Shayevitz
This is first release of otg driver for the dwc3 Synopsys USB3 core.
The otg driver implements the otg final state machine and control the
activation of the device controller or host controller.

In this first implementation, only simple DRD mode is implemented,
determine if A or B device according to the ID pin as reflected in the
OSTS.ConIDSts field.

Signed-off-by: Ido Shayevitz 

---
 drivers/usb/dwc3/Kconfig |6 +-
 drivers/usb/dwc3/Makefile|2 +
 drivers/usb/dwc3/core.c  |   15 +-
 drivers/usb/dwc3/core.h  |   51 -
 drivers/usb/dwc3/dwc3_otg.c  |  512 ++
 drivers/usb/dwc3/dwc3_otg.h  |   38 +++
 drivers/usb/dwc3/gadget.c|   63 +
 drivers/usb/host/xhci-plat.c |   21 ++
 drivers/usb/host/xhci.c  |   13 +-
 9 files changed, 708 insertions(+), 13 deletions(-)
 create mode 100644 drivers/usb/dwc3/dwc3_otg.c
 create mode 100644 drivers/usb/dwc3/dwc3_otg.h

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index d13c60f..0cc108d 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -1,9 +1,9 @@
 config USB_DWC3
tristate "DesignWare USB3 DRD Core Support"
-   depends on (USB && USB_GADGET)
+   depends on (USB || USB_GADGET)
select USB_OTG_UTILS
-   select USB_GADGET_DUALSPEED
-   select USB_GADGET_SUPERSPEED
+   select USB_GADGET_DUALSPEED if USB_GADGET
+   select USB_GADGET_SUPERSPEED if USB_GADGET
select USB_XHCI_PLATFORM if USB_SUPPORT && USB_XHCI_HCD
help
  Say Y or M here if your system has a Dual Role SuperSpeed
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index d441fe4..ffb3f55 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -1,11 +1,13 @@
 ccflags-$(CONFIG_USB_DWC3_DEBUG)   := -DDEBUG
 ccflags-$(CONFIG_USB_DWC3_VERBOSE) += -DVERBOSE_DEBUG
+ccflags-y += -Idrivers/usb/host
 
 obj-$(CONFIG_USB_DWC3) += dwc3.o
 
 dwc3-y := core.o
 dwc3-y += host.o
 dwc3-y += gadget.o ep0.o
+dwc3-y += dwc3_otg.o
 
 ifneq ($(CONFIG_DEBUG_FS),)
dwc3-y  += debugfs.o
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index c34452a..5343e39 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -517,15 +517,24 @@ static int __devinit dwc3_probe(struct platform_device 
*pdev)
break;
case DWC3_MODE_DRD:
dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
+   ret = dwc3_otg_init(dwc);
+   if (ret) {
+   dev_err(dev, "failed to initialize otg\n");
+   goto err1;
+   }
+
ret = dwc3_host_init(dwc);
if (ret) {
dev_err(dev, "failed to initialize host\n");
+   dwc3_otg_exit(dwc);
goto err1;
}
 
ret = dwc3_gadget_init(dwc);
if (ret) {
dev_err(dev, "failed to initialize gadget\n");
+   dwc3_host_exit(dwc);
+   dwc3_otg_exit(dwc);
goto err1;
}
break;
@@ -554,8 +563,9 @@ err2:
dwc3_host_exit(dwc);
break;
case DWC3_MODE_DRD:
-   dwc3_host_exit(dwc);
dwc3_gadget_exit(dwc);
+   dwc3_host_exit(dwc);
+   dwc3_otg_exit(dwc);
break;
default:
/* do nothing */
@@ -588,8 +598,9 @@ static int __devexit dwc3_remove(struct platform_device 
*pdev)
dwc3_host_exit(dwc);
break;
case DWC3_MODE_DRD:
-   dwc3_host_exit(dwc);
dwc3_gadget_exit(dwc);
+   dwc3_host_exit(dwc);
+   dwc3_otg_exit(dwc);
break;
default:
/* do nothing */
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 151eca8..793758b 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -50,6 +50,8 @@
 #include 
 #include 
 
+#include "dwc3_otg.h"
+
 /* Global constants */
 #define DWC3_EP0_BOUNCE_SIZE   512
 #define DWC3_ENDPOINTS_NUM 32
@@ -152,8 +154,9 @@
 /* OTG Registers */
 #define DWC3_OCFG  0xcc00
 #define DWC3_OCTL  0xcc04
-#define DWC3_OEVTEN0xcc08
-#define DWC3_OSTS  0xcc0C
+#define DWC3_OEVT  0xcc08
+#define DWC3_OEVTEN0xcc0c
+#define DWC3_OSTS  0xcc10
 
 /* Bit fields */
 
@@ -203,6 +206,9 @@
 #define DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(n)   (((n) & (0x0f << 13)) >> 13)
 #define DWC3_MAX_HIBER_SCRATCHBUFS 15
 
+/* Global HWPARAMS6 Register */
+#define DWC3_GHWPARAMS6_SRP_SUPPORT(1 << 10)
+
 /* Device 

Re: Logitech USB keyboard arbitrarily gets unresponsive

2012-07-11 Thread Alan Stern
On Wed, 11 Jul 2012, Paul Menzel wrote:

> Dear Alan,
> 
> 
> as always thank you very much for answering to my problem reports.
> 
> 
> Am Mittwoch, den 04.07.2012, 21:25 -0400 schrieb Alan Stern:
> > On Thu, 5 Jul 2012, Paul Menzel wrote:
> 
> > > an USB Logitech keyboard
> > > 
> > > Bus 004 Device 003: ID 046d:c30f Logitech, Inc. Logicool 
> > > HID-Compliant Keyboard (106 key)
> > > 
> > > arbitrarily gets unresponsive on my system and stays this way.
> > > 
> > > I am working in X and suddenly nothing entered to the keyboard has an
> > > effect. I cannot switch to a virtual terminal with Ctrl + Alt + F, n
> > > ∈ ℕ, but the LEDs of the keyboard are still lighted. The USB mouse keeps
> > > working though.
> > > 
> > > After plugging it out and back in it works again.
> > > 
> > > The distribution is Debian Sid/unstable with Linux 3.2 and it happened
> > > with two mainboards, the ASUS M2A-VM [1] and ASRock A780FullHD [2].
> > 
> > Is the keyboard attached to an xHCI controller or something else (EHCI, 
> > UHCI, or OHCI)?
> 
> It is directly plugged into the mainboard which only supports USB 2.
> Does that answer the question? If not, how do I find out?

It says in the dmesg log when you plug in the keyboard:

[ 7381.444185] usb 4-1: new low-speed USB device number 3 using ohci_hcd

So the answer is OHCI.

> Please find the acquired logs attached. I did the following.
> 
> 1. Keyboard unresponsive
> 2. log in with SSH
> 3. follow `Documentation/usb/usbmon.txt`
> 4. capture the traces
> 
> $ sudo cat /sys/kernel/debug/usb/usbmon/4u > 
> /tmp/20120711--usbmon.out-hang-random-presses
> $ sudo cat /sys/kernel/debug/usb/usbmon/4u > 
> /tmp/20120711--usbmon.out.hang-before-unplug--asdf-return
> $ sudo cat /sys/kernel/debug/usb/usbmon/4u > 
> /tmp/20120711--usbmon.out.unplug-replug
> $ sudo cat /sys/kernel/debug/usb/usbmon/4u > 
> /tmp/20120711--usbmon.out.after-replug--asdf-return

Very good.

> It looks like data is received.

Not only is data received; the very same data is received in both 
cases.  Therefore the keyboard is working correctly.

>  So could it be an X (evdev)(?) problem?

Maybe.  You could test this.  The next time the same thing happens, do 
a network login as root and run the command "chvt 2".  This will change 
from the graphics screen to the vt2 text console.  See if the keyboard 
works then.

In theory the problem could be something really stupid.  For example, 
typing a control-S in an xterm window (or at a text console) will 
suppress output to the screen until you type control-Q.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/6] USB: serial: Changes to conform with checkpatch.

2012-07-11 Thread Michal Nazarewicz

On Wed, 11 Jul 2012 16:10:14 +0200, Ben Minerds  wrote:

Removed various checkpatch.sh warnings and errors.


You've meant chekpatch.pl, right?


Split patch by warning/error type.
Corrected line wraps in emails.

Signed-off-by: Ben Minerds 


This 0/6 also confuses me -- like Greg have said the 0/n mail should not
contain any diff, just a summary -- but all the other patches look good
to me as they are only whitespace changes -- if only there was a diff
tool that understood C and compared stream of C tokens rather then a plain
text file.

--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 25/25] USB: EHCI: resolve some unlikely races

2012-07-11 Thread Alan Stern
This patch (as1589) resolves some unlikely races involving system
shutdown or controller death in ehci-hcd:

Shutdown races with both root-hub resume and controller
resume.

Controller death races with root-hub suspend.

A new bitflag is added to indicate that the controller has been shut
down (whether for system shutdown or because it died).  Tests are
added in the suspend and resume pathways to avoid reactivating the
controller after any sort of shutdown.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c |   20 +++-
 drivers/usb/host/ehci-hub.c |   27 +++
 drivers/usb/host/ehci.h |1 +
 3 files changed, 43 insertions(+), 5 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -118,6 +118,7 @@ struct ehci_hcd {   /* one per controlle
boolneed_rescan:1;
boolintr_unlinking:1;
boolasync_unlinking:1;
+   boolshutdown:1;
struct ehci_qh  *qh_scan_next;
 
/* async schedule support */
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -343,6 +343,7 @@ static void ehci_shutdown(struct usb_hcd
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
 
spin_lock_irq(&ehci->lock);
+   ehci->shutdown = true;
ehci->rh_state = EHCI_RH_STOPPING;
ehci->enabled_hrtimer_events = 0;
spin_unlock_irq(&ehci->lock);
@@ -823,6 +824,7 @@ dead:
usb_hc_died(hcd);
 
/* Don't let the controller do anything more */
+   ehci->shutdown = true;
ehci->rh_state = EHCI_RH_STOPPING;
ehci->command &= ~(CMD_RUN | CMD_ASE | CMD_PSE);
ehci_writel(ehci, ehci->command, &ehci->regs->command);
@@ -1129,6 +1131,9 @@ static int __maybe_unused ehci_resume(st
/* Mark hardware accessible again as we are back to full power by now */
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
 
+   if (ehci->shutdown)
+   return 0;   /* Controller is dead */
+
/*
 * If CF is still set and we aren't resuming from hibernation
 * then we maintained suspend power.
@@ -1139,10 +1144,17 @@ static int __maybe_unused ehci_resume(st
int mask = INTR_MASK;
 
ehci_prepare_ports_for_controller_resume(ehci);
+
+   spin_lock_irq(&ehci->lock);
+   if (ehci->shutdown)
+   goto skip;
+
if (!hcd->self.root_hub->do_remote_wakeup)
mask &= ~STS_PCD;
ehci_writel(ehci, mask, &ehci->regs->intr_enable);
ehci_readl(ehci, &ehci->regs->intr_enable);
+ skip:
+   spin_unlock_irq(&ehci->lock);
return 0;
}
 
@@ -1154,14 +1166,20 @@ static int __maybe_unused ehci_resume(st
(void) ehci_halt(ehci);
(void) ehci_reset(ehci);
 
+   spin_lock_irq(&ehci->lock);
+   if (ehci->shutdown)
+   goto skip;
+
ehci_writel(ehci, ehci->command, &ehci->regs->command);
ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag);
ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */
 
+   ehci->rh_state = EHCI_RH_SUSPENDED;
+   spin_unlock_irq(&ehci->lock);
+
/* here we "know" root ports should always stay powered */
ehci_port_power(ehci, 1);
 
-   ehci->rh_state = EHCI_RH_SUSPENDED;
return 1;
 }
 
Index: usb-3.4/drivers/usb/host/ehci-hub.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hub.c
+++ usb-3.4/drivers/usb/host/ehci-hub.c
@@ -221,6 +221,8 @@ static int ehci_bus_suspend (struct usb_
ehci_quiesce(ehci);
 
spin_lock_irq (&ehci->lock);
+   if (ehci->rh_state < EHCI_RH_RUNNING)
+   goto done;
 
/* Once the controller is stopped, port resumes that are already
 * in progress won't complete.  Hence if remote wakeup is enabled
@@ -306,6 +308,10 @@ static int ehci_bus_suspend (struct usb_
ehci_halt (ehci);
 
spin_lock_irq(&ehci->lock);
+   if (ehci->enabled_hrtimer_events & BIT(EHCI_HRTIMER_POLL_DEAD))
+   ehci_handle_controller_death(ehci);
+   if (ehci->rh_state != EHCI_RH_RUNNING)
+   goto done;
ehci->rh_state = EHCI_RH_SUSPENDED;
 
end_unlink_async(ehci);
@@ -320,6 +326,7 @@ static int ehci_bus_suspend (struct usb_
ehci_writel(ehci, mask, &ehci->regs->intr_enable);
ehci_readl(ehci, &ehci->regs->intr_enable);
 
+ done:
ehci->next_statecha

[PATCH 24/25] USB: EHCI: fix up locking

2012-07-11 Thread Alan Stern
This patch (as1588) adjusts the locking in ehci-hcd's various halt,
shutdown, and suspend/resume pathways.  We want to hold the spinlock
while writing device registers and accessing shared variables, but not
while polling in a loop.

In addition, there's no need to call ehci_work() at times when no URBs
can be active, i.e., in ehci_stop() and ehci_bus_suspend().

Finally, ehci_adjust_port_wakeup_flags() is called only in situations
where interrupts are enabled; therefore it can use spin_lock_irq
rather than spin_lock_irqsave.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c   |   48 --
 drivers/usb/host/ehci-hub.c   |   41 +--
 drivers/usb/host/ehci-tegra.c |5 +---
 3 files changed, 64 insertions(+), 30 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -167,21 +167,24 @@ static int tdi_in_host_mode (struct ehci
return (tmp & 3) == USBMODE_CM_HC;
 }
 
-/* force HC to halt state from unknown (EHCI spec section 2.3) */
+/*
+ * Force HC to halt state from unknown (EHCI spec section 2.3).
+ * Must be called with interrupts enabled and the lock not held.
+ */
 static int ehci_halt (struct ehci_hcd *ehci)
 {
-   u32 temp = ehci_readl(ehci, &ehci->regs->status);
+   u32 temp;
+
+   spin_lock_irq(&ehci->lock);
 
/* disable any irqs left enabled by previous code */
ehci_writel(ehci, 0, &ehci->regs->intr_enable);
 
-   if (ehci_is_TDI(ehci) && tdi_in_host_mode(ehci) == 0) {
+   if (ehci_is_TDI(ehci) && !tdi_in_host_mode(ehci)) {
+   spin_unlock_irq(&ehci->lock);
return 0;
}
 
-   if ((temp & STS_HALT) != 0)
-   return 0;
-
/*
 * This routine gets called during probe before ehci->command
 * has been initialized, so we can't rely on its value.
@@ -190,7 +193,11 @@ static int ehci_halt (struct ehci_hcd *e
temp = ehci_readl(ehci, &ehci->regs->command);
temp &= ~(CMD_RUN | CMD_IAAD);
ehci_writel(ehci, temp, &ehci->regs->command);
-   return handshake (ehci, &ehci->regs->status,
+
+   spin_unlock_irq(&ehci->lock);
+   synchronize_irq(ehci_to_hcd(ehci)->irq);
+
+   return handshake(ehci, &ehci->regs->status,
  STS_HALT, STS_HALT, 16 * 125);
 }
 
@@ -210,7 +217,10 @@ static void tdi_reset (struct ehci_hcd *
ehci_writel(ehci, tmp, &ehci->regs->usbmode);
 }
 
-/* reset a non-running (STS_HALT == 1) controller */
+/*
+ * Reset a non-running (STS_HALT == 1) controller.
+ * Must be called with interrupts enabled and the lock not held.
+ */
 static int ehci_reset (struct ehci_hcd *ehci)
 {
int retval;
@@ -248,7 +258,10 @@ static int ehci_reset (struct ehci_hcd *
return retval;
 }
 
-/* idle the controller (from running) */
+/*
+ * Idle the controller (turn off the schedules).
+ * Must be called with interrupts enabled and the lock not held.
+ */
 static void ehci_quiesce (struct ehci_hcd *ehci)
 {
u32 temp;
@@ -261,8 +274,10 @@ static void ehci_quiesce (struct ehci_hc
handshake(ehci, &ehci->regs->status, STS_ASS | STS_PSS, temp, 16 * 125);
 
/* then disable anything that's still active */
+   spin_lock_irq(&ehci->lock);
ehci->command &= ~(CMD_ASE | CMD_PSE);
ehci_writel(ehci, ehci->command, &ehci->regs->command);
+   spin_unlock_irq(&ehci->lock);
 
/* hardware can take 16 microframes to turn off ... */
handshake(ehci, &ehci->regs->status, STS_ASS | STS_PSS, 0, 16 * 125);
@@ -301,11 +316,14 @@ static void ehci_turn_off_all_ports(stru
 
 /*
  * Halt HC, turn off all ports, and let the BIOS use the companion controllers.
- * Should be called with ehci->lock held.
+ * Must be called with interrupts enabled and the lock not held.
  */
 static void ehci_silence_controller(struct ehci_hcd *ehci)
 {
ehci_halt(ehci);
+
+   spin_lock_irq(&ehci->lock);
+   ehci->rh_state = EHCI_RH_HALTED;
ehci_turn_off_all_ports(ehci);
 
/* make BIOS/etc use companion controller during reboot */
@@ -313,6 +331,7 @@ static void ehci_silence_controller(stru
 
/* unblock posted writes */
ehci_readl(ehci, &ehci->regs->configured_flag);
+   spin_unlock_irq(&ehci->lock);
 }
 
 /* ehci_shutdown kick in for silicon on any bus (not just pci, etc).
@@ -325,10 +344,11 @@ static void ehci_shutdown(struct usb_hcd
 
spin_lock_irq(&ehci->lock);
ehci->rh_state = EHCI_RH_STOPPING;
-   ehci_silence_controller(ehci);
ehci->enabled_hrtimer_events = 0;
spin_unlock_irq(&ehci->lock);
 
+   ehci_silence_controller(ehci);
+
hrtimer_cancel(&ehci->hrtimer);
 }
 
@@ -400,11 +420,11 @@ static void ehci_stop (struct usb_hcd *h
 
spin_lock_irq(&ehci->l

[PATCH 23/25] USB: EHCI: simplify isochronous scanning

2012-07-11 Thread Alan Stern
This patch (as1587) simplifies ehci-hcd's scan_isoc() routine by
eliminating some local variables, declaring boolean-valued values as
bool rather than unsigned, changing variable names to make more sense,
and so on.

The logic at the end of the routine is cut down significantly.  The
scanning doesn't have to catch up all the way to where the hardware
is; it merely has to catch up to where the hardware was when the last
interrupt occurred.  If the hardware has made more progress since then
and issued another interrupt, a rescan will catch up to it.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c   |3 -
 drivers/usb/host/ehci-sched.c |  114 ++
 drivers/usb/host/ehci.h   |6 +-
 3 files changed, 32 insertions(+), 91 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -141,19 +141,19 @@ struct ehci_hcd { /* one per controlle
struct ehci_qh  *intr_unlink;
struct ehci_qh  *intr_unlink_last;
unsignedintr_unlink_cycle;
-   int next_uframe;/* scan periodic, start here */
+   unsignednow_frame;  /* frame from HC hardware */
+   unsignednext_frame; /* scan periodic, start here */
unsignedintr_count; /* intr activity count */
unsignedisoc_count; /* isoc activity count */
unsignedperiodic_count; /* periodic activity count */
unsigneduframe_periodic_max; /* max periodic time per 
uframe */
 
 
-   /* list of itds & sitds completed while clock_frame was still active */
+   /* list of itds & sitds completed while now_frame was still active */
struct list_headcached_itd_list;
struct ehci_itd *last_itd_to_free;
struct list_headcached_sitd_list;
struct ehci_sitd*last_sitd_to_free;
-   unsignedclock_frame;
 
/* per root hub port */
unsigned long   reset_done [EHCI_MAX_ROOT_PORTS];
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -488,9 +488,6 @@ static int ehci_init(struct usb_hcd *hcd
else// N microframes cached
ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params);
 
-   ehci->next_uframe = -1;
-   ehci->clock_frame = -1;
-
/*
 * dedicate a qh for the async ring head, since we couldn't unlink
 * a 'real' qh without stopping the async schedule [4.8].  use it
Index: usb-3.4/drivers/usb/host/ehci-sched.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-sched.c
+++ usb-3.4/drivers/usb/host/ehci-sched.c
@@ -497,8 +497,6 @@ static void disable_periodic(struct ehci
if (--ehci->periodic_count)
return;
 
-   ehci->next_uframe = -1; /* the periodic schedule is empty */
-
/* Don't turn off the schedule until PSS is 1 */
ehci_poll_PSS(ehci);
 }
@@ -1220,7 +1218,7 @@ itd_urb_transaction (
if (likely(!list_empty(&stream->free_list))) {
itd = list_first_entry(&stream->free_list,
struct ehci_itd, itd_list);
-   if (itd->frame == ehci->clock_frame)
+   if (itd->frame == ehci->now_frame)
goto alloc_itd;
list_del (&itd->itd_list);
itd_dma = itd->itd_dma;
@@ -1492,7 +1490,7 @@ iso_stream_schedule (
 
/* Make sure scan_isoc() sees these */
if (ehci->isoc_count == 0)
-   ehci->next_uframe = now;
+   ehci->next_frame = now >> 3;
return 0;
 
  fail:
@@ -1666,11 +1664,8 @@ static void itd_link_urb(
  * (b) only this endpoint's completions submit URBs.  It seems some silicon
  * corrupts things if you reuse completed descriptors very quickly...
  */
-static unsigned
-itd_complete (
-   struct ehci_hcd *ehci,
-   struct ehci_itd *itd
-) {
+static bool itd_complete(struct ehci_hcd *ehci, struct ehci_itd *itd)
+{
struct urb  *urb = itd->urb;
struct usb_iso_packet_descriptor*desc;
u32 t;
@@ -1678,7 +1673,7 @@ itd_complete (
int urb_index = -1;
struct ehci_iso_stream  *stream = itd->stream;
struct usb_device   *dev;
-   unsignedretval = false;
+   bool 

[PATCH 22/25] USB: EHCI: use hrtimer for the I/O watchdog

2012-07-11 Thread Alan Stern
This patch (as1586) replaces the kernel timer used by ehci-hcd as an
I/O watchdog with an hrtimer event.

Unlike in the current code, the watchdog event is now always enabled
whenever any isochronous URBs are active.  This will prevent bugs
caused by the periodic schedule wrapping around with no completion
interrupts; the watchdog handler is guaranteed to scan the isochronous
transfers at least once during each iteration of the schedule.  The
extra overhead will be negligible: one timer interrupt every 100 ms.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c   |   47 --
 drivers/usb/host/ehci-hub.c   |5 
 drivers/usb/host/ehci-q.c |1 
 drivers/usb/host/ehci-sched.c |3 --
 drivers/usb/host/ehci-timer.c |   21 ++
 drivers/usb/host/ehci.h   |   13 ---
 6 files changed, 25 insertions(+), 65 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -88,6 +88,7 @@ enum ehci_hrtimer_event {
EHCI_HRTIMER_IAA_WATCHDOG,  /* Handle lost IAA interrupts */
EHCI_HRTIMER_DISABLE_PERIODIC,  /* Wait to disable periodic sched */
EHCI_HRTIMER_DISABLE_ASYNC, /* Wait to disable async sched */
+   EHCI_HRTIMER_IO_WATCHDOG,   /* Check for missing IRQs */
EHCI_HRTIMER_NUM_EVENTS /* Must come last */
 };
 #define EHCI_HRTIMER_NO_EVENT  99
@@ -177,8 +178,6 @@ struct ehci_hcd {   /* one per controlle
struct dma_pool *itd_pool;  /* itd per iso urb */
struct dma_pool *sitd_pool; /* sitd per split iso urb */
 
-   struct timer_list   watchdog;
-   unsigned long   actions;
unsignedrandom_frame;
unsigned long   next_statechange;
ktime_t last_periodic_enable;
@@ -235,16 +234,6 @@ static inline struct usb_hcd *ehci_to_hc
return container_of ((void *) ehci, struct usb_hcd, hcd_priv);
 }
 
-enum ehci_timer_action {
-   TIMER_IO_WATCHDOG,
-};
-
-static inline void
-timer_action_done (struct ehci_hcd *ehci, enum ehci_timer_action action)
-{
-   clear_bit (action, &ehci->actions);
-}
-
 /*-*/
 
 #include 
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -93,8 +93,6 @@ static const char hcd_name [] = "ehci_hc
  */
 #defineEHCI_TUNE_FLS   1   /* (medium) 512-frame schedule 
*/
 
-#define EHCI_IO_JIFFIES(HZ/10) /* io watchdog > 
irq_thresh */
-
 /* Initial IRQ latency:  faster than hw default */
 static int log2_irq_thresh = 0;// 0 to 6
 module_param (log2_irq_thresh, int, S_IRUGO);
@@ -125,25 +123,6 @@ MODULE_PARM_DESC(hird, "host initiated r
 
 /*-*/
 
-static void
-timer_action(struct ehci_hcd *ehci, enum ehci_timer_action action)
-{
-   if (!test_and_set_bit(action, &ehci->actions)) {
-   unsigned long t;
-
-   switch (action) {
-   case TIMER_IO_WATCHDOG:
-   if (!ehci->need_io_watchdog)
-   return;
-   t = EHCI_IO_JIFFIES;
-   break;
-   }
-   mod_timer(&ehci->watchdog, t + jiffies);
-   }
-}
-
-/*-*/
-
 /*
  * handshake - spin reading hc until handshake completes or fails
  * @ptr: address of hc register to be read
@@ -307,19 +286,6 @@ static void end_unlink_intr(struct ehci_
 
 /*-*/
 
-static void ehci_watchdog(unsigned long param)
-{
-   struct ehci_hcd *ehci = (struct ehci_hcd *) param;
-   unsigned long   flags;
-
-   spin_lock_irqsave(&ehci->lock, flags);
-
-   /* ehci could run by timer, without IRQs ... */
-   ehci_work (ehci);
-
-   spin_unlock_irqrestore (&ehci->lock, flags);
-}
-
 /* On some systems, leaving remote wakeup enabled prevents system shutdown.
  * The firmware seems to think that powering off is a wakeup event!
  * This routine turns off remote wakeup and everything else, on all ports.
@@ -357,8 +323,6 @@ static void ehci_shutdown(struct usb_hcd
 {
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
 
-   del_timer_sync(&ehci->watchdog);
-
spin_lock_irq(&ehci->lock);
ehci->rh_state = EHCI_RH_STOPPING;
ehci_silence_controller(ehci);
@@ -394,8 +358,6 @@ static void ehci_port_power (struct ehci
  */
 static void ehci_work (struct ehci_hcd *ehci)
 {
-   timer_

[PATCH 21/25] USB: EHCI: always scan each interrupt QH

2012-07-11 Thread Alan Stern
This patch (as1585) fixes a bug in ehci-hcd's scheme for scanning
interrupt QHs.

Currently a single routine takes care of scanning everything on the
periodic schedule.  Whenever an interrupt occurs, it scans all
isochronous and interrupt URBs scheduled for frames that have elapsed
since the last scan.

This has two disadvantages.  The first is relatively minor: An
interrupt QH is likely to end up getting scanned multiple times,
particularly if the last scan was not fairly recent.  (The current
code avoids this by maintaining a periodic_stamp in each interrupt
QH.)

The second is more serious.  The periodic schedule wraps around.  If
the last scan occurred during frame N, and the next scan occurs when
the schedule has gone through an entire cycle and is back at frame N,
the scanning code won't look at any frames other than N.  Consequently
it won't see any QHs that completed during frame N-1 or earlier.

The patch replaces the entire frame-based approach for scanning
interrupt QHs with a new routine using a list-based approach, the same
as for async QHs.  This has a slight disadvantage, because it means
that all interrupt QHs have to be scanned every time.  But it is more
robust than the current approach.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c   |7 ++-
 drivers/usb/host/ehci-q.c |3 -
 drivers/usb/host/ehci-sched.c |   96 +-
 drivers/usb/host/ehci-timer.c |7 ---
 drivers/usb/host/ehci.h   |8 ++-
 5 files changed, 71 insertions(+), 50 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -117,6 +117,7 @@ struct ehci_hcd {   /* one per controlle
boolneed_rescan:1;
boolintr_unlinking:1;
boolasync_unlinking:1;
+   struct ehci_qh  *qh_scan_next;
 
/* async schedule support */
struct ehci_qh  *async;
@@ -124,7 +125,6 @@ struct ehci_hcd {   /* one per controlle
struct ehci_qh  *async_unlink;
struct ehci_qh  *async_unlink_last;
struct ehci_qh  *async_iaa;
-   struct ehci_qh  *qh_scan_next;
unsignedasync_unlink_cycle;
unsignedasync_count;/* async activity count */
 
@@ -133,6 +133,7 @@ struct ehci_hcd {   /* one per controlle
unsignedperiodic_size;
__hc32  *periodic;  /* hw periodic table */
dma_addr_t  periodic_dma;
+   struct list_headintr_qh_list;
unsignedi_thresh;   /* uframes HC might cache */
 
union ehci_shadow   *pshadow;   /* mirror hw periodic table */
@@ -140,6 +141,8 @@ struct ehci_hcd {   /* one per controlle
struct ehci_qh  *intr_unlink_last;
unsignedintr_unlink_cycle;
int next_uframe;/* scan periodic, start here */
+   unsignedintr_count; /* intr activity count */
+   unsignedisoc_count; /* isoc activity count */
unsignedperiodic_count; /* periodic activity count */
unsigneduframe_periodic_max; /* max periodic time per 
uframe */
 
@@ -176,7 +179,6 @@ struct ehci_hcd {   /* one per controlle
 
struct timer_list   watchdog;
unsigned long   actions;
-   unsignedperiodic_stamp;
unsignedrandom_frame;
unsigned long   next_statechange;
ktime_t last_periodic_enable;
@@ -381,11 +383,11 @@ struct ehci_qh {
dma_addr_t  qh_dma; /* address of qh */
union ehci_shadow   qh_next;/* ptr to qh; or periodic */
struct list_headqtd_list;   /* sw qtd list */
+   struct list_headintr_node;  /* list of intr QHs */
struct ehci_qtd *dummy;
struct ehci_qh  *unlink_next;   /* next on unlink list */
 
unsignedunlink_cycle;
-   unsignedstamp;
 
u8  needs_rescan;   /* Dequeue during giveback */
u8  qh_state;
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -410,8 +410,10 @@ static void ehci_work (struct ehci_hcd *
ehci->need_rescan = false;
if (ehci->async_count)
scan_async(ehci);
-   if (ehci->next_uframe != -1)
-   scan_periodic (ehci);
+   if (ehci->intr_count > 0)
+   

[PATCH 20/25] USB: EHCI: don't lose events during a scan

2012-07-11 Thread Alan Stern
This patch (as1584) fixes a minor bug that has been present in
ehci-hcd since the beginning.

Scanning the schedules for URB completions is single-threaded.  If a
completion interrupt occurs while an URB is being given back, the
interrupt handler realizes that a scan is in progress on another CPU
and avoids starting a new one.

This means that completion events can be lost.  If an URB completes
after it has been scanned but while a scan is still in progress, the
driver won't notice and won't rescan the completed URB.

The patch fixes the problem by adding a new flag to indicate that
another scan is needed after the current scan is done.  The flag gets
set whenever a completion interrupt occurs while a scan is in
progress.  The rescan will see the completion, thus preventing it from
getting lost.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c |   13 ++---
 drivers/usb/host/ehci.h |3 ++-
 2 files changed, 12 insertions(+), 4 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -113,7 +113,8 @@ struct ehci_hcd {   /* one per controlle
enum ehci_rh_state  rh_state;
 
/* general schedule support */
-   unsignedscanning:1;
+   boolscanning:1;
+   boolneed_rescan:1;
boolintr_unlinking:1;
boolasync_unlinking:1;
 
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -400,14 +400,21 @@ static void ehci_work (struct ehci_hcd *
 * it reports urb completions.  this flag guards against bogus
 * attempts at re-entrant schedule scanning.
 */
-   if (ehci->scanning)
+   if (ehci->scanning) {
+   ehci->need_rescan = true;
return;
-   ehci->scanning = 1;
+   }
+   ehci->scanning = true;
+
+ rescan:
+   ehci->need_rescan = false;
if (ehci->async_count)
scan_async(ehci);
if (ehci->next_uframe != -1)
scan_periodic (ehci);
-   ehci->scanning = 0;
+   if (ehci->need_rescan)
+   goto rescan;
+   ehci->scanning = false;
 
/* the IO watchdog guards against hardware or driver bugs that
 * misplace IRQs, and should let us run completely without IRQs.


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 19/25] USB: EHCI: use hrtimer for unlinking empty async QHs

2012-07-11 Thread Alan Stern
This patch (as1583) changes ehci-hcd to use an hrtimer event for
unlinking empty (unused) async QHs instead of using a kernel timer.

The check for empty QHs is moved to a new routine, where it doesn't
require going through an entire scan of both the async and periodic
schedules.  And it can unlink multiple QHs at once, unlike the current
code.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c   |   16 
 drivers/usb/host/ehci-hub.c   |1 
 drivers/usb/host/ehci-q.c |   78 --
 drivers/usb/host/ehci-timer.c |2 +
 drivers/usb/host/ehci.h   |4 +-
 5 files changed, 59 insertions(+), 42 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -84,6 +84,7 @@ enum ehci_hrtimer_event {
EHCI_HRTIMER_POLL_DEAD, /* Wait for dead controller to stop */
EHCI_HRTIMER_UNLINK_INTR,   /* Wait for interrupt QH unlink */
EHCI_HRTIMER_FREE_ITDS, /* Wait for unused iTDs and siTDs */
+   EHCI_HRTIMER_ASYNC_UNLINKS, /* Unlink empty async QHs */
EHCI_HRTIMER_IAA_WATCHDOG,  /* Handle lost IAA interrupts */
EHCI_HRTIMER_DISABLE_PERIODIC,  /* Wait to disable periodic sched */
EHCI_HRTIMER_DISABLE_ASYNC, /* Wait to disable async sched */
@@ -123,6 +124,7 @@ struct ehci_hcd {   /* one per controlle
struct ehci_qh  *async_unlink_last;
struct ehci_qh  *async_iaa;
struct ehci_qh  *qh_scan_next;
+   unsignedasync_unlink_cycle;
unsignedasync_count;/* async activity count */
 
/* periodic schedule support */
@@ -232,7 +234,6 @@ static inline struct usb_hcd *ehci_to_hc
 
 enum ehci_timer_action {
TIMER_IO_WATCHDOG,
-   TIMER_ASYNC_SHRINK,
 };
 
 static inline void
@@ -382,7 +383,6 @@ struct ehci_qh {
struct ehci_qtd *dummy;
struct ehci_qh  *unlink_next;   /* next on unlink list */
 
-   unsigned long   unlink_time;
unsignedunlink_cycle;
unsignedstamp;
 
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -94,8 +94,6 @@ static const char hcd_name [] = "ehci_hc
 #defineEHCI_TUNE_FLS   1   /* (medium) 512-frame schedule 
*/
 
 #define EHCI_IO_JIFFIES(HZ/10) /* io watchdog > 
irq_thresh */
-#define EHCI_SHRINK_JIFFIES(DIV_ROUND_UP(HZ, 200) + 1)
-   /* 5-ms async qh unlink delay */
 
 /* Initial IRQ latency:  faster than hw default */
 static int log2_irq_thresh = 0;// 0 to 6
@@ -130,15 +128,6 @@ MODULE_PARM_DESC(hird, "host initiated r
 static void
 timer_action(struct ehci_hcd *ehci, enum ehci_timer_action action)
 {
-   /* Don't override timeouts which shrink or (later) disable
-* the async ring; just the I/O watchdog.  Note that if a
-* SHRINK were pending, OFF would never be requested.
-*/
-   if (timer_pending(&ehci->watchdog)
-   && (BIT(TIMER_ASYNC_SHRINK)
-   & ehci->actions))
-   return;
-
if (!test_and_set_bit(action, &ehci->actions)) {
unsigned long t;
 
@@ -148,10 +137,6 @@ timer_action(struct ehci_hcd *ehci, enum
return;
t = EHCI_IO_JIFFIES;
break;
-   /* case TIMER_ASYNC_SHRINK: */
-   default:
-   t = EHCI_SHRINK_JIFFIES;
-   break;
}
mod_timer(&ehci->watchdog, t + jiffies);
}
@@ -307,6 +292,7 @@ static void ehci_quiesce (struct ehci_hc
 /*-*/
 
 static void end_unlink_async(struct ehci_hcd *ehci);
+static void unlink_empty_async(struct ehci_hcd *ehci);
 static void ehci_work(struct ehci_hcd *ehci);
 static void start_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh);
 static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh);
Index: usb-3.4/drivers/usb/host/ehci-q.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-q.c
+++ usb-3.4/drivers/usb/host/ehci-q.c
@@ -1205,7 +1205,7 @@ static void start_iaa_cycle(struct ehci_
end_unlink_async(ehci);
 
/* Otherwise start a new IAA cycle */
-   } else {
+   } else if (likely(ehci->rh_state == EHCI_RH_RUNNING)) {
/* Make sure the unlinks are all visible to the hardware */
wmb();
 
@@ -1253,6 +1253,39 @@ stat

[PATCH 18/25] USB: EHCI: unlink multiple async QHs together

2012-07-11 Thread Alan Stern
This patch (as1582) changes ehci-hcd's strategy for unlinking async
QHs.  Currently the driver never unlinks more than one QH at a time.
This can be inefficient and cause unnecessary delays, since a QH
cannot be reused while it is waiting to be unlinked.

The new strategy unlinks all the waiting QHs at once.  In practice the
improvement won't be very big, because it's somewhat uncommon to have
two or more QHs waiting to be unlinked at any time.  But it does
happen, and in any case, doing things this way makes more sense IMO.

The change requires the async unlinking code to be refactored
slightly.  Now in addition to the routines for starting and ending an
unlink, there are new routines for unlinking a single QH and starting
an IAA cycle.  This approach is needed because there are two separate
paths for unlinking async QHs:

When a transfer error occurs or an URB is cancelled, the QH
must be unlinked right away;

When a QH has been idle sufficiently long, it is unlinked
to avoid consuming DMA bandwidth uselessly.

In the first case we want the unlink to proceed as quickly as
possible, whereas in the second case we can afford to batch several
QHs together and unlink them all at once.  Hence the division of
labor.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c   |   35 +
 drivers/usb/host/ehci-hub.c   |3 
 drivers/usb/host/ehci-q.c |  149 +-
 drivers/usb/host/ehci-timer.c |3 
 drivers/usb/host/ehci.h   |2 
 5 files changed, 98 insertions(+), 94 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -114,12 +114,14 @@ struct ehci_hcd { /* one per controlle
/* general schedule support */
unsignedscanning:1;
boolintr_unlinking:1;
+   boolasync_unlinking:1;
 
/* async schedule support */
struct ehci_qh  *async;
struct ehci_qh  *dummy; /* For AMD quirk use */
struct ehci_qh  *async_unlink;
struct ehci_qh  *async_unlink_last;
+   struct ehci_qh  *async_iaa;
struct ehci_qh  *qh_scan_next;
unsignedasync_count;/* async activity count */
 
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -795,7 +795,7 @@ static irqreturn_t ehci_irq (struct usb_
/* guard against (alleged) silicon errata */
if (cmd & CMD_IAAD)
ehci_dbg(ehci, "IAA with IAAD still set?\n");
-   if (ehci->async_unlink) {
+   if (ehci->async_iaa) {
COUNT(ehci->stats.iaa);
end_unlink_async(ehci);
} else
@@ -926,33 +926,6 @@ static int ehci_urb_enqueue (
}
 }
 
-static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
-{
-   /* failfast */
-   if (ehci->rh_state < EHCI_RH_RUNNING && ehci->async_unlink)
-   end_unlink_async(ehci);
-
-   /* If the QH isn't linked then there's nothing we can do
-* unless we were called during a giveback, in which case
-* qh_completions() has to deal with it.
-*/
-   if (qh->qh_state != QH_STATE_LINKED) {
-   if (qh->qh_state == QH_STATE_COMPLETING)
-   qh->needs_rescan = 1;
-   return;
-   }
-
-   /* defer till later if busy */
-   if (ehci->async_unlink) {
-   qh->qh_state = QH_STATE_UNLINK_WAIT;
-   ehci->async_unlink_last->unlink_next = qh;
-   ehci->async_unlink_last = qh;
-
-   /* start IAA cycle */
-   } else
-   start_unlink_async (ehci, qh);
-}
-
 /* remove from hardware lists
  * completions normally happen asynchronously
  */
@@ -979,7 +952,7 @@ static int ehci_urb_dequeue(struct usb_h
switch (qh->qh_state) {
case QH_STATE_LINKED:
case QH_STATE_COMPLETING:
-   unlink_async(ehci, qh);
+   start_unlink_async(ehci, qh);
break;
case QH_STATE_UNLINK:
case QH_STATE_UNLINK_WAIT:
@@ -1070,7 +1043,7 @@ rescan:
 * may already be unlinked.
 */
if (tmp)
-   unlink_async(ehci, qh);
+   start_unlink_async(ehci, qh);
/* FALL THROUGH */
case QH_STATE_UNLINK:   /* wait for hw to finish? */
case QH_STATE_UNLINK_WAIT:
@@ -1133,7 +1106,7 @@ ehci_endpoint_reset(struct usb_hcd *hcd,
 * re-linki

[PATCH 17/25] USB: EHCI: use hrtimer for the IAA watchdog

2012-07-11 Thread Alan Stern
This patch (as1581) replaces the iaa_watchdog kernel timer used by
ehci-hcd with an hrtimer event, in keeping with the general conversion
to high-res timers.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c   |   66 --
 drivers/usb/host/ehci-hub.c   |1 
 drivers/usb/host/ehci-q.c |4 --
 drivers/usb/host/ehci-timer.c |   45 
 drivers/usb/host/ehci.h   |   16 --
 5 files changed, 61 insertions(+), 71 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -84,6 +84,7 @@ enum ehci_hrtimer_event {
EHCI_HRTIMER_POLL_DEAD, /* Wait for dead controller to stop */
EHCI_HRTIMER_UNLINK_INTR,   /* Wait for interrupt QH unlink */
EHCI_HRTIMER_FREE_ITDS, /* Wait for unused iTDs and siTDs */
+   EHCI_HRTIMER_IAA_WATCHDOG,  /* Handle lost IAA interrupts */
EHCI_HRTIMER_DISABLE_PERIODIC,  /* Wait to disable periodic sched */
EHCI_HRTIMER_DISABLE_ASYNC, /* Wait to disable async sched */
EHCI_HRTIMER_NUM_EVENTS /* Must come last */
@@ -168,7 +169,6 @@ struct ehci_hcd {   /* one per controlle
struct dma_pool *itd_pool;  /* itd per iso urb */
struct dma_pool *sitd_pool; /* sitd per split iso urb */
 
-   struct timer_list   iaa_watchdog;
struct timer_list   watchdog;
unsigned long   actions;
unsignedperiodic_stamp;
@@ -228,20 +228,6 @@ static inline struct usb_hcd *ehci_to_hc
return container_of ((void *) ehci, struct usb_hcd, hcd_priv);
 }
 
-
-static inline void
-iaa_watchdog_start(struct ehci_hcd *ehci)
-{
-   WARN_ON(timer_pending(&ehci->iaa_watchdog));
-   mod_timer(&ehci->iaa_watchdog,
-   jiffies + msecs_to_jiffies(EHCI_IAA_MSECS));
-}
-
-static inline void iaa_watchdog_done(struct ehci_hcd *ehci)
-{
-   del_timer(&ehci->iaa_watchdog);
-}
-
 enum ehci_timer_action {
TIMER_IO_WATCHDOG,
TIMER_ASYNC_SHRINK,
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -93,7 +93,6 @@ static const char hcd_name [] = "ehci_hc
  */
 #defineEHCI_TUNE_FLS   1   /* (medium) 512-frame schedule 
*/
 
-#define EHCI_IAA_MSECS 10  /* arbitrary */
 #define EHCI_IO_JIFFIES(HZ/10) /* io watchdog > 
irq_thresh */
 #define EHCI_SHRINK_JIFFIES(DIV_ROUND_UP(HZ, 200) + 1)
/* 5-ms async qh unlink delay */
@@ -322,51 +321,6 @@ static void end_unlink_intr(struct ehci_
 
 /*-*/
 
-static void ehci_iaa_watchdog(unsigned long param)
-{
-   struct ehci_hcd *ehci = (struct ehci_hcd *) param;
-   unsigned long   flags;
-
-   spin_lock_irqsave (&ehci->lock, flags);
-
-   /* Lost IAA irqs wedge things badly; seen first with a vt8235.
-* So we need this watchdog, but must protect it against both
-* (a) SMP races against real IAA firing and retriggering, and
-* (b) clean HC shutdown, when IAA watchdog was pending.
-*/
-   if (ehci->async_unlink
-   && !timer_pending(&ehci->iaa_watchdog)
-   && ehci->rh_state == EHCI_RH_RUNNING) {
-   u32 cmd, status;
-
-   /* If we get here, IAA is *REALLY* late.  It's barely
-* conceivable that the system is so busy that CMD_IAAD
-* is still legitimately set, so let's be sure it's
-* clear before we read STS_IAA.  (The HC should clear
-* CMD_IAAD when it sets STS_IAA.)
-*/
-   cmd = ehci_readl(ehci, &ehci->regs->command);
-
-   /* If IAA is set here it either legitimately triggered
-* before we cleared IAAD above (but _way_ late, so we'll
-* still count it as lost) ... or a silicon erratum:
-* - VIA seems to set IAA without triggering the IRQ;
-* - IAAD potentially cleared without setting IAA.
-*/
-   status = ehci_readl(ehci, &ehci->regs->status);
-   if ((status & STS_IAA) || !(cmd & CMD_IAAD)) {
-   COUNT (ehci->stats.lost_iaa);
-   ehci_writel(ehci, STS_IAA, &ehci->regs->status);
-   }
-
-   ehci_vdbg(ehci, "IAA watchdog: status %x cmd %x\n",
-   status, cmd);
-   end_unlink_async(ehci);
-   }
-
-   spin_unlock_irqrestore(&ehci->lock, flags);
-}
-
 s

[PATCH 16/25] USB: EHCI: don't refcount iso_stream structures

2012-07-11 Thread Alan Stern
This patch (as1580) makes ehci_iso_stream structures behave more like
QHs, in that they will remain allocated until their isochronous
endpoint is disabled.  This will come in useful in the future, when
periodic bandwidth gets allocated as an altsetting is installed rather
than on-the-fly.

For now, the change to the ehci_iso_stream lifetimes means that each
structure is always deallocated at exactly one spot in
ehci_endpoint_disable() and never used again.  As a result, it is no
longer necessary to use reference counting on these things, and the
patch removes it.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c   |   12 +++--
 drivers/usb/host/ehci-sched.c |   53 --
 drivers/usb/host/ehci.h   |3 --
 3 files changed, 16 insertions(+), 52 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -386,7 +386,7 @@ struct ehci_qh_hw {
 } __attribute__ ((aligned(32)));
 
 struct ehci_qh {
-   struct ehci_qh_hw   *hw;
+   struct ehci_qh_hw   *hw;/* Must come first */
/* the rest is HCD-private */
dma_addr_t  qh_dma; /* address of qh */
union ehci_shadow   qh_next;/* ptr to qh; or periodic */
@@ -453,7 +453,6 @@ struct ehci_iso_stream {
/* first field matches ehci_hq, but is NULL */
struct ehci_qh_hw   *hw;
 
-   u32 refcount;
u8  bEndpointAddress;
u8  highspeed;
struct list_headtd_list;/* queued itds/sitds */
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -1085,8 +1085,14 @@ rescan:
 * accelerate iso completions ... so spin a while.
 */
if (qh->hw == NULL) {
-   ehci_vdbg (ehci, "iso delay\n");
-   goto idle_timeout;
+   struct ehci_iso_stream  *stream = ep->hcpriv;
+
+   if (!list_empty(&stream->td_list))
+   goto idle_timeout;
+
+   /* BUG_ON(!list_empty(&stream->free_list)); */
+   kfree(stream);
+   goto done;
}
 
if (ehci->rh_state < EHCI_RH_RUNNING)
@@ -1127,8 +1133,8 @@ idle_timeout:
list_empty (&qh->qtd_list) ? "" : "(has tds)");
break;
}
+ done:
ep->hcpriv = NULL;
-done:
spin_unlock_irqrestore (&ehci->lock, flags);
 }
 
Index: usb-3.4/drivers/usb/host/ehci-sched.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-sched.c
+++ usb-3.4/drivers/usb/host/ehci-sched.c
@@ -934,7 +934,6 @@ iso_stream_alloc (gfp_t mem_flags)
INIT_LIST_HEAD(&stream->td_list);
INIT_LIST_HEAD(&stream->free_list);
stream->next_uframe = -1;
-   stream->refcount = 1;
}
return stream;
 }
@@ -1034,32 +1033,6 @@ iso_stream_init (
stream->maxp = maxp;
 }
 
-static void
-iso_stream_put(struct ehci_hcd *ehci, struct ehci_iso_stream *stream)
-{
-   stream->refcount--;
-
-   /* free whenever just a dev->ep reference remains.
-* not like a QH -- no persistent state (toggle, halt)
-*/
-   if (stream->refcount == 1) {
-   // BUG_ON (!list_empty(&stream->td_list));
-
-   if (stream->ep)
-   stream->ep->hcpriv = NULL;
-
-   kfree(stream);
-   }
-}
-
-static inline struct ehci_iso_stream *
-iso_stream_get (struct ehci_iso_stream *stream)
-{
-   if (likely (stream != NULL))
-   stream->refcount++;
-   return stream;
-}
-
 static struct ehci_iso_stream *
 iso_stream_find (struct ehci_hcd *ehci, struct urb *urb)
 {
@@ -1080,7 +1053,6 @@ iso_stream_find (struct ehci_hcd *ehci,
if (unlikely (stream == NULL)) {
stream = iso_stream_alloc(GFP_ATOMIC);
if (likely (stream != NULL)) {
-   /* dev->ep owns the initial refcount */
ep->hcpriv = stream;
stream->ep = ep;
iso_stream_init(ehci, stream, urb->dev, urb->pipe,
@@ -1095,9 +1067,6 @@ iso_stream_find (struct ehci_hcd *ehci,
stream = NULL;
}
 
-   /* caller guarantees an eventual matching iso_stream_put */
-   stream = iso_stream_get (stream);
-
spin_unlock_irqrestore (&ehci->lock, flags);
return stream;
 }
@@ -1611,7 +1580,7 @@ static void itd_link_urb(
itd = list_entry (iso_sched->td_list.next,
struct ehci_itd, itd_list);
list_move_tail (

[PATCH 15/25] USB: EHCI: use hrtimer for (s)iTD deallocation

2012-07-11 Thread Alan Stern
This patch (as1579) adds an hrtimer event to handle deallocation of
iTDs and siTDs in ehci-hcd.

Because of the frame-oriented approach used by the EHCI periodic
schedule, the hardware can continue to access the Transfer Descriptor
for isochronous (or split-isochronous) transactions for up to a
millisecond after the transaction completes.  The iTD (or siTD) must
not be reused before then.

The strategy currently used involves putting completed iTDs on a list
of cached entries and every so often returning them to the endpoint's
free list.  The new strategy reduces overhead by putting completed
iTDs back on the free list immediately, although they are not reused
until it is safe to do so.

When the isochronous endpoint stops (its queue becomes empty), the
iTDs on its free list get moved to a global list, from which they will
be deallocated after a minimum of 2 ms.  This delay is what the new
hrtimer event is for.

Overall this may not be a tremendous improvement over the current
code, but to me it seems a lot more clear and logical.  In addition,
it removes the need for each iTD to keep a reference to the
ehci_iso_stream it belongs to, since the iTD never needs to be moved
back to the stream's free list from the global list.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c   |1 
 drivers/usb/host/ehci-hub.c   |1 
 drivers/usb/host/ehci-mem.c   |1 
 drivers/usb/host/ehci-sched.c |  137 +++---
 drivers/usb/host/ehci-timer.c |   50 ++-
 drivers/usb/host/ehci.h   |5 -
 6 files changed, 90 insertions(+), 105 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -83,6 +83,7 @@ enum ehci_hrtimer_event {
EHCI_HRTIMER_POLL_PSS,  /* Poll for periodic schedule off */
EHCI_HRTIMER_POLL_DEAD, /* Wait for dead controller to stop */
EHCI_HRTIMER_UNLINK_INTR,   /* Wait for interrupt QH unlink */
+   EHCI_HRTIMER_FREE_ITDS, /* Wait for unused iTDs and siTDs */
EHCI_HRTIMER_DISABLE_PERIODIC,  /* Wait to disable periodic sched */
EHCI_HRTIMER_DISABLE_ASYNC, /* Wait to disable async sched */
EHCI_HRTIMER_NUM_EVENTS /* Must come last */
@@ -139,7 +140,9 @@ struct ehci_hcd {   /* one per controlle
 
/* list of itds & sitds completed while clock_frame was still active */
struct list_headcached_itd_list;
+   struct ehci_itd *last_itd_to_free;
struct list_headcached_sitd_list;
+   struct ehci_sitd*last_sitd_to_free;
unsignedclock_frame;
 
/* per root hub port */
@@ -250,8 +253,6 @@ timer_action_done (struct ehci_hcd *ehci
clear_bit (action, &ehci->actions);
 }
 
-static void free_cached_lists(struct ehci_hcd *ehci);
-
 /*-*/
 
 #include 
Index: usb-3.4/drivers/usb/host/ehci-sched.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-sched.c
+++ usb-3.4/drivers/usb/host/ehci-sched.c
@@ -1045,31 +1045,6 @@ iso_stream_put(struct ehci_hcd *ehci, st
if (stream->refcount == 1) {
// BUG_ON (!list_empty(&stream->td_list));
 
-   while (!list_empty (&stream->free_list)) {
-   struct list_head*entry;
-
-   entry = stream->free_list.next;
-   list_del (entry);
-
-   /* knows about ITD vs SITD */
-   if (stream->highspeed) {
-   struct ehci_itd *itd;
-
-   itd = list_entry (entry, struct ehci_itd,
-   itd_list);
-   dma_pool_free (ehci->itd_pool, itd,
-   itd->itd_dma);
-   } else {
-   struct ehci_sitd*sitd;
-
-   sitd = list_entry (entry, struct ehci_sitd,
-   sitd_list);
-   dma_pool_free (ehci->sitd_pool, sitd,
-   sitd->sitd_dma);
-   }
-   }
-
-   stream->bEndpointAddress &= 0x0f;
if (stream->ep)
stream->ep->hcpriv = NULL;
 
@@ -1230,17 +1205,19 @@ itd_urb_transaction (
spin_lock_irqsave (&ehci->lock, flags);
for (i = 0; i < num_itds; i++) {
 
-   /* free_list.next might be cache-hot ... but maybe
-* the HC caches it too. avoid that issue for now.
+   /*
+* Use iTDs from the free list, but not iTDs that may
+  

[PATCH 14/25] USB: EHCI: use hrtimer for controller death

2012-07-11 Thread Alan Stern
This patch (as1578) adds an hrtimer event to handle the death of an
EHCI controller.  When a controller dies, it doesn't necessarily stop
running right away.  The new event polls at 1-ms intervals to see when
all activity has safely stopped.  This replaces a busy-wait polling
loop in the current code.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c   |   20 ++--
 drivers/usb/host/ehci-timer.c |   26 ++
 drivers/usb/host/ehci.h   |2 ++
 3 files changed, 38 insertions(+), 10 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -81,6 +81,7 @@ enum ehci_rh_state {
 enum ehci_hrtimer_event {
EHCI_HRTIMER_POLL_ASS,  /* Poll for async schedule off */
EHCI_HRTIMER_POLL_PSS,  /* Poll for periodic schedule off */
+   EHCI_HRTIMER_POLL_DEAD, /* Wait for dead controller to stop */
EHCI_HRTIMER_UNLINK_INTR,   /* Wait for interrupt QH unlink */
EHCI_HRTIMER_DISABLE_PERIODIC,  /* Wait to disable periodic sched */
EHCI_HRTIMER_DISABLE_ASYNC, /* Wait to disable async sched */
@@ -97,6 +98,7 @@ struct ehci_hcd { /* one per controlle
 
int PSS_poll_count;
int ASS_poll_count;
+   int died_poll_count;
 
/* glue to PCI and HCD framework */
struct ehci_caps __iomem *caps;
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -888,20 +888,20 @@ static irqreturn_t ehci_irq (struct usb_
/* PCI errors [4.15.2.4] */
if (unlikely ((status & STS_FATAL) != 0)) {
ehci_err(ehci, "fatal error\n");
-   ehci->rh_state = EHCI_RH_STOPPING;
dbg_cmd(ehci, "fatal", cmd);
dbg_status(ehci, "fatal", status);
-   ehci_halt(ehci);
 dead:
-   ehci->enabled_hrtimer_events = 0;
-   hrtimer_try_to_cancel(&ehci->hrtimer);
-   ehci_reset(ehci);
-   ehci_writel(ehci, 0, &ehci->regs->configured_flag);
usb_hc_died(hcd);
-   /* generic layer kills/unlinks all urbs, then
-* uses ehci_stop to clean up the rest
-*/
-   bh = 1;
+
+   /* Don't let the controller do anything more */
+   ehci->rh_state = EHCI_RH_STOPPING;
+   ehci->command &= ~(CMD_RUN | CMD_ASE | CMD_PSE);
+   ehci_writel(ehci, ehci->command, &ehci->regs->command);
+   ehci_writel(ehci, 0, &ehci->regs->intr_enable);
+   ehci_handle_controller_death(ehci);
+
+   /* Handle completions when the controller stops */
+   bh = 0;
}
 
if (bh)
Index: usb-3.4/drivers/usb/host/ehci-timer.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-timer.c
+++ usb-3.4/drivers/usb/host/ehci-timer.c
@@ -69,6 +69,7 @@ static void ehci_clear_command_bit(struc
 static unsigned event_delays_ns[] = {
1 * NSEC_PER_MSEC,  /* EHCI_HRTIMER_POLL_ASS */
1 * NSEC_PER_MSEC,  /* EHCI_HRTIMER_POLL_PSS */
+   1 * NSEC_PER_MSEC,  /* EHCI_HRTIMER_POLL_DEAD */
1125 * NSEC_PER_USEC,   /* EHCI_HRTIMER_UNLINK_INTR */
10 * NSEC_PER_MSEC, /* EHCI_HRTIMER_DISABLE_PERIODIC */
15 * NSEC_PER_MSEC, /* EHCI_HRTIMER_DISABLE_ASYNC */
@@ -193,6 +194,30 @@ static void ehci_disable_PSE(struct ehci
 }
 
 
+/* Poll the STS_HALT status bit; see when a dead controller stops */
+static void ehci_handle_controller_death(struct ehci_hcd *ehci)
+{
+   if (!(ehci_readl(ehci, &ehci->regs->status) & STS_HALT)) {
+
+   /* Give up after a few milliseconds */
+   if (ehci->died_poll_count++ < 5) {
+   /* Try again later */
+   ehci_enable_event(ehci, EHCI_HRTIMER_POLL_DEAD, true);
+   return;
+   }
+   ehci_warn(ehci, "Waited too long for the controller to stop, 
giving up\n");
+   }
+
+   /* Clean up the mess */
+   ehci->rh_state = EHCI_RH_HALTED;
+   ehci_writel(ehci, 0, &ehci->regs->configured_flag);
+   ehci_writel(ehci, 0, &ehci->regs->intr_enable);
+   ehci_work(ehci);
+
+   /* Not in process context, so don't try to reset the controller */
+}
+
+
 /* Handle unlinked interrupt QHs once they are gone from the hardware */
 static void ehci_handle_intr_unlinks(struct ehci_hcd *ehci)
 {
@@ -233,6 +258,7 @@ static void ehci_handle_intr_unlinks(str
 static void (*event_handlers[])(struct ehci_hcd *) = {
ehci_poll_ASS,  /* EHCI_HRTIMER_POLL

[PATCH 13/25] USB: EHCI: use hrtimer for interrupt QH unlink

2012-07-11 Thread Alan Stern
This patch (as1577) adds hrtimer support for unlinking interrupt QHs
in ehci-hcd.  The current code relies on a fixed delay of either 2 or
55 us, which is not always adequate and in any case is totally bogus.
Thanks to internal caching, the EHCI hardware may continue to access
an interrupt QH for more than a millisecond after it has been unlinked.

In fact, the EHCI spec doesn't say how long to wait before using an
unlinked interrupt QH.  The patch sets the delay to 9 microframes
minimum, which ought to be adequate.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c   |6 ++-
 drivers/usb/host/ehci-hub.c   |1 
 drivers/usb/host/ehci-sched.c |   71 +++---
 drivers/usb/host/ehci-timer.c |   34 
 drivers/usb/host/ehci.h   |   10 +
 5 files changed, 94 insertions(+), 28 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -81,6 +81,7 @@ enum ehci_rh_state {
 enum ehci_hrtimer_event {
EHCI_HRTIMER_POLL_ASS,  /* Poll for async schedule off */
EHCI_HRTIMER_POLL_PSS,  /* Poll for periodic schedule off */
+   EHCI_HRTIMER_UNLINK_INTR,   /* Wait for interrupt QH unlink */
EHCI_HRTIMER_DISABLE_PERIODIC,  /* Wait to disable periodic sched */
EHCI_HRTIMER_DISABLE_ASYNC, /* Wait to disable async sched */
EHCI_HRTIMER_NUM_EVENTS /* Must come last */
@@ -106,13 +107,16 @@ struct ehci_hcd { /* one per controlle
spinlock_t  lock;
enum ehci_rh_state  rh_state;
 
+   /* general schedule support */
+   unsignedscanning:1;
+   boolintr_unlinking:1;
+
/* async schedule support */
struct ehci_qh  *async;
struct ehci_qh  *dummy; /* For AMD quirk use */
struct ehci_qh  *async_unlink;
struct ehci_qh  *async_unlink_last;
struct ehci_qh  *qh_scan_next;
-   unsignedscanning : 1;
unsignedasync_count;/* async activity count */
 
/* periodic schedule support */
@@ -123,6 +127,9 @@ struct ehci_hcd {   /* one per controlle
unsignedi_thresh;   /* uframes HC might cache */
 
union ehci_shadow   *pshadow;   /* mirror hw periodic table */
+   struct ehci_qh  *intr_unlink;
+   struct ehci_qh  *intr_unlink_last;
+   unsignedintr_unlink_cycle;
int next_uframe;/* scan periodic, start here */
unsignedperiodic_count; /* periodic activity count */
unsigneduframe_periodic_max; /* max periodic time per 
uframe */
@@ -385,6 +392,7 @@ struct ehci_qh {
struct ehci_qh  *unlink_next;   /* next on unlink list */
 
unsigned long   unlink_time;
+   unsignedunlink_cycle;
unsignedstamp;
 
u8  needs_rescan;   /* Dequeue during giveback */
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -309,6 +309,8 @@ static void ehci_quiesce (struct ehci_hc
 
 static void end_unlink_async(struct ehci_hcd *ehci);
 static void ehci_work(struct ehci_hcd *ehci);
+static void start_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh);
+static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh);
 
 #include "ehci-timer.c"
 #include "ehci-hub.c"
@@ -1034,7 +1036,7 @@ static int ehci_urb_dequeue(struct usb_h
switch (qh->qh_state) {
case QH_STATE_LINKED:
case QH_STATE_COMPLETING:
-   intr_deschedule (ehci, qh);
+   start_unlink_intr(ehci, qh);
break;
case QH_STATE_IDLE:
qh_completions (ehci, qh);
@@ -1164,7 +1166,7 @@ ehci_endpoint_reset(struct usb_hcd *hcd,
if (eptype == USB_ENDPOINT_XFER_BULK)
unlink_async(ehci, qh);
else
-   intr_deschedule(ehci, qh);
+   start_unlink_intr(ehci, qh);
}
}
spin_unlock_irqrestore(&ehci->lock, flags);
Index: usb-3.4/drivers/usb/host/ehci-hub.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hub.c
+++ usb-3.4/drivers/usb/host/ehci-hub.c
@@ -302,6 +302,7 @@ static int ehci_bus_suspend (struct usb_
 
if (ehci->async_unlink)
end_unlink_async(ehci);
+   ehci_handle_intr_un

[PATCH 12/25] USB: EHCI: use hrtimer for async schedule

2012-07-11 Thread Alan Stern
This patch (as1576) adds hrtimer support for managing ehci-hcd's
async schedule.  Just as with the earlier change to the periodic
schedule management, two new hrtimer events take care of everything.

One event polls at 1-ms intervals to see when the Asynchronous
Schedule Status (ASS) flag matches the Asynchronous Schedule Enable
(ASE) value; the schedule's state must not be changed until it does.
The other event delays for 15 ms after the async schedule becomes
empty before turning it off.

The new events replace a busy-wait poll and a kernel timer usage.
They also replace the rather illogical method currently used for
indicating the async schedule should be turned off: attempting to
unlink the dedicated QH at the head of the async list.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c   |   13 +---
 drivers/usb/host/ehci-q.c |   68 ++
 drivers/usb/host/ehci-timer.c |   49 ++
 drivers/usb/host/ehci.h   |5 ++-
 4 files changed, 86 insertions(+), 49 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -79,8 +79,10 @@ enum ehci_rh_state {
  * ehci-timer.c) in parallel with this list.
  */
 enum ehci_hrtimer_event {
+   EHCI_HRTIMER_POLL_ASS,  /* Poll for async schedule off */
EHCI_HRTIMER_POLL_PSS,  /* Poll for periodic schedule off */
EHCI_HRTIMER_DISABLE_PERIODIC,  /* Wait to disable periodic sched */
+   EHCI_HRTIMER_DISABLE_ASYNC, /* Wait to disable async sched */
EHCI_HRTIMER_NUM_EVENTS /* Must come last */
 };
 #define EHCI_HRTIMER_NO_EVENT  99
@@ -93,6 +95,7 @@ struct ehci_hcd { /* one per controlle
struct hrtimer  hrtimer;
 
int PSS_poll_count;
+   int ASS_poll_count;
 
/* glue to PCI and HCD framework */
struct ehci_caps __iomem *caps;
@@ -110,6 +113,7 @@ struct ehci_hcd {   /* one per controlle
struct ehci_qh  *async_unlink_last;
struct ehci_qh  *qh_scan_next;
unsignedscanning : 1;
+   unsignedasync_count;/* async activity count */
 
/* periodic schedule support */
 #defineDEFAULT_I_TDPS  1024/* some HCs can do less 
*/
@@ -229,7 +233,6 @@ static inline void iaa_watchdog_done(str
 enum ehci_timer_action {
TIMER_IO_WATCHDOG,
TIMER_ASYNC_SHRINK,
-   TIMER_ASYNC_OFF,
 };
 
 static inline void
Index: usb-3.4/drivers/usb/host/ehci-timer.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-timer.c
+++ usb-3.4/drivers/usb/host/ehci-timer.c
@@ -67,8 +67,10 @@ static void ehci_clear_command_bit(struc
  * the event types indexed by enum ehci_hrtimer_event in ehci.h.
  */
 static unsigned event_delays_ns[] = {
+   1 * NSEC_PER_MSEC,  /* EHCI_HRTIMER_POLL_ASS */
1 * NSEC_PER_MSEC,  /* EHCI_HRTIMER_POLL_PSS */
10 * NSEC_PER_MSEC, /* EHCI_HRTIMER_DISABLE_PERIODIC */
+   15 * NSEC_PER_MSEC, /* EHCI_HRTIMER_DISABLE_ASYNC */
 };
 
 /* Enable a pending hrtimer event */
@@ -91,6 +93,51 @@ static void ehci_enable_event(struct ehc
 }
 
 
+/* Poll the STS_ASS status bit; see when it agrees with CMD_ASE */
+static void ehci_poll_ASS(struct ehci_hcd *ehci)
+{
+   unsignedactual, want;
+
+   /* Don't enable anything if the controller isn't running (e.g., died) */
+   if (ehci->rh_state != EHCI_RH_RUNNING)
+   return;
+
+   want = (ehci->command & CMD_ASE) ? STS_ASS : 0;
+   actual = ehci_readl(ehci, &ehci->regs->status) & STS_ASS;
+
+   if (want != actual) {
+
+   /* Poll again later, but give up after about 20 ms */
+   if (ehci->ASS_poll_count++ < 20) {
+   ehci_enable_event(ehci, EHCI_HRTIMER_POLL_ASS, true);
+   return;
+   }
+   ehci_warn(ehci, "Waited too long for the async schedule status, 
giving up\n");
+   }
+   ehci->ASS_poll_count = 0;
+
+   /* The status is up-to-date; restart or stop the schedule as needed */
+   if (want == 0) {/* Stopped */
+   if (ehci->async_count > 0)
+   ehci_set_command_bit(ehci, CMD_ASE);
+
+   } else {/* Running */
+   if (ehci->async_count == 0) {
+
+   /* Turn off the schedule after a while */
+   ehci_enable_event(ehci, EHCI_HRTIMER_DISABLE_ASYNC,
+   true);
+   }
+   }
+}
+
+/* Turn off the async schedule after a brief delay */
+static void ehci_disable_ASE(struct ehci_hcd *ehci)
+{
+   ehci_clear_command_bit(ehci, CMD_ASE);

[PATCH 11/25] USB: EHCI: remove PS3 status polling

2012-07-11 Thread Alan Stern
This patch (as1575) removes special code added for status polling of
the EHCI controller in PS3 systems.  While the controller is running,
the polling is now carried out by an hrtimer handler.  When the
controller is suspending or stopping, we use the same polling routine
as the old code -- but in neither case do we need to conclude that the
controller has died if the polling goes on for too long.

As a result the entire handshake_on_error_set_halt() routine is now
unused, so it is removed from the driver.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c |   69 +---
 1 file changed, 2 insertions(+), 67 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -235,68 +235,6 @@ static int ehci_halt (struct ehci_hcd *e
  STS_HALT, STS_HALT, 16 * 125);
 }
 
-#if defined(CONFIG_USB_SUSPEND) && defined(CONFIG_PPC_PS3)
-
-/*
- * The EHCI controller of the Cell Super Companion Chip used in the
- * PS3 will stop the root hub after all root hub ports are suspended.
- * When in this condition handshake will return -ETIMEDOUT.  The
- * STS_HLT bit will not be set, so inspection of the frame index is
- * used here to test for the condition.  If the condition is found
- * return success to allow the USB suspend to complete.
- */
-
-static int handshake_for_broken_root_hub(struct ehci_hcd *ehci,
-void __iomem *ptr, u32 mask, u32 done,
-int usec)
-{
-   unsigned int old_index;
-   int error;
-
-   if (!firmware_has_feature(FW_FEATURE_PS3_LV1))
-   return -ETIMEDOUT;
-
-   old_index = ehci_read_frame_index(ehci);
-
-   error = handshake(ehci, ptr, mask, done, usec);
-
-   if (error == -ETIMEDOUT && ehci_read_frame_index(ehci) == old_index)
-   return 0;
-
-   return error;
-}
-
-#else
-
-static int handshake_for_broken_root_hub(struct ehci_hcd *ehci,
-void __iomem *ptr, u32 mask, u32 done,
-int usec)
-{
-   return -ETIMEDOUT;
-}
-
-#endif
-
-static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem 
*ptr,
-  u32 mask, u32 done, int usec)
-{
-   int error;
-
-   error = handshake(ehci, ptr, mask, done, usec);
-   if (error == -ETIMEDOUT)
-   error = handshake_for_broken_root_hub(ehci, ptr, mask, done,
- usec);
-
-   if (error) {
-   ehci_halt(ehci);
-   ehci->rh_state = EHCI_RH_HALTED;
-   ehci_err(ehci, "force halt; handshake %p %08x %08x -> %d\n",
-   ptr, mask, done, error);
-   }
-
-   return error;
-}
-
 /* put TDI/ARC silicon into EHCI mode */
 static void tdi_reset (struct ehci_hcd *ehci)
 {
@@ -361,17 +299,14 @@ static void ehci_quiesce (struct ehci_hc
 
/* wait for any schedule enables/disables to take effect */
temp = (ehci->command << 10) & (STS_ASS | STS_PSS);
-   if (handshake_on_error_set_halt(ehci, &ehci->regs->status,
-   STS_ASS | STS_PSS, temp, 16 * 125))
-   return;
+   handshake(ehci, &ehci->regs->status, STS_ASS | STS_PSS, temp, 16 * 125);
 
/* then disable anything that's still active */
ehci->command &= ~(CMD_ASE | CMD_PSE);
ehci_writel(ehci, ehci->command, &ehci->regs->command);
 
/* hardware can take 16 microframes to turn off ... */
-   handshake_on_error_set_halt(ehci, &ehci->regs->status,
-   STS_ASS | STS_PSS, 0, 16 * 125);
+   handshake(ehci, &ehci->regs->status, STS_ASS | STS_PSS, 0, 16 * 125);
 }
 
 /*-*/


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/25] USB: EHCI: return void instead of 0

2012-07-11 Thread Alan Stern
This patch (as1574) changes the return type of multiple functions in
ehci-sched.c from int to void.  The values they return are now always
0, so there's no reason for them to return any value at all.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-sched.c |   34 ++
 1 file changed, 14 insertions(+), 20 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci-sched.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-sched.c
+++ usb-3.4/drivers/usb/host/ehci-sched.c
@@ -479,29 +479,27 @@ static int tt_no_collision (
 
 /*-*/
 
-static int enable_periodic (struct ehci_hcd *ehci)
+static void enable_periodic(struct ehci_hcd *ehci)
 {
if (ehci->periodic_count++)
-   return 0;
+   return;
 
/* Stop waiting to turn off the periodic schedule */
ehci->enabled_hrtimer_events &= ~BIT(EHCI_HRTIMER_DISABLE_PERIODIC);
 
/* Don't start the schedule until PSS is 0 */
ehci_poll_PSS(ehci);
-   return 0;
 }
 
-static int disable_periodic (struct ehci_hcd *ehci)
+static void disable_periodic(struct ehci_hcd *ehci)
 {
if (--ehci->periodic_count)
-   return 0;
+   return;
 
ehci->next_uframe = -1; /* the periodic schedule is empty */
 
/* Don't turn off the schedule until PSS is 1 */
ehci_poll_PSS(ehci);
-   return 0;
 }
 
 /*-*/
@@ -512,7 +510,7 @@ static int disable_periodic (struct ehci
  * this just links in a qh; caller guarantees uframe masks are set right.
  * no FSTN support (yet; ehci 0.96+)
  */
-static int qh_link_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh)
+static void qh_link_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh)
 {
unsignedi;
unsignedperiod = qh->period;
@@ -572,10 +570,10 @@ static int qh_link_periodic (struct ehci
: (qh->usecs * 8);
 
/* maybe enable periodic schedule processing */
-   return enable_periodic(ehci);
+   enable_periodic(ehci);
 }
 
-static int qh_unlink_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh)
+static void qh_unlink_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh)
 {
unsignedi;
unsignedperiod;
@@ -608,8 +606,6 @@ static int qh_unlink_periodic(struct ehc
/* qh->qh_next still "live" to HC */
qh->qh_state = QH_STATE_UNLINK;
qh->qh_next.ptr = NULL;
-
-   return 0;
 }
 
 static void intr_deschedule (struct ehci_hcd *ehci, struct ehci_qh *qh)
@@ -843,7 +839,7 @@ static int qh_schedule(struct ehci_hcd *
ehci_dbg (ehci, "reused qh %p schedule\n", qh);
 
/* stuff into the periodic schedule */
-   status = qh_link_periodic (ehci, qh);
+   qh_link_periodic(ehci, qh);
 done:
return status;
 }
@@ -1574,8 +1570,7 @@ itd_link (struct ehci_hcd *ehci, unsigne
 }
 
 /* fit urb's itds into the selected schedule slot; activate as needed */
-static int
-itd_link_urb (
+static void itd_link_urb(
struct ehci_hcd *ehci,
struct urb  *urb,
unsignedmod,
@@ -1646,7 +1641,7 @@ itd_link_urb (
urb->hcpriv = NULL;
 
timer_action (ehci, TIMER_IO_WATCHDOG);
-   return enable_periodic(ehci);
+   enable_periodic(ehci);
 }
 
 #defineISO_ERRS (EHCI_ISOC_BUF_ERR | EHCI_ISOC_BABBLE | 
EHCI_ISOC_XACTERR)
@@ -1726,7 +1721,7 @@ itd_complete (
ehci_urb_done(ehci, urb, 0);
retval = true;
urb = NULL;
-   (void) disable_periodic(ehci);
+   disable_periodic(ehci);
ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--;
 
if (ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs == 0) {
@@ -1993,8 +1988,7 @@ sitd_link (struct ehci_hcd *ehci, unsign
 }
 
 /* fit urb's sitds into the selected schedule slot; activate as needed */
-static int
-sitd_link_urb (
+static void sitd_link_urb(
struct ehci_hcd *ehci,
struct urb  *urb,
unsignedmod,
@@ -2056,7 +2050,7 @@ sitd_link_urb (
urb->hcpriv = NULL;
 
timer_action (ehci, TIMER_IO_WATCHDOG);
-   return enable_periodic(ehci);
+   enable_periodic(ehci);
 }
 
 /*-*/
@@ -2122,7 +2116,7 @@ sitd_complete (
ehci_urb_done(ehci, urb, 0);
retval = true;
urb = NULL;
-   (void) disable_periodic(ehci);
+   disable_periodic(ehci);
ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--;
 
if (ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs == 0) {


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 9/25] USB: EHCI: use hrtimer for the periodic schedule

2012-07-11 Thread Alan Stern
This patch (as1573) adds hrtimer support for managing ehci-hcd's
periodic schedule.  There are two issues to deal with.

First, the schedule's state (on or off) must not be changed until the
hardware status has caught up with the current command.  This is
handled by an hrtimer event that polls at 1-ms intervals to see when
the Periodic Schedule Status (PSS) flag matches the Periodic Schedule
Enable (PSE) value.

Second, the schedule should not be turned off as soon as it becomes
empty.  Turning the schedule on and off takes time, so we want to wait
until the schedule has been empty for a suitable period before turning
it off.  This is handled by an hrtimer event that gets set to expire
10 ms after the periodic schedule becomes empty.

The existing code polls (for up to 1125 us and with interrupts
disabled!) to check the status, and doesn't implement a delay before
turning off the schedule.  Furthermore, if the polling fails then the
driver decides that the controller has died.  This has caused problems
for several people; some controllers can take 10 ms or more to turn
off their periodic schedules.

This patch fixes these issues.  It also makes the "broken_periodic"
workaround unnecessary; there is no longer any danger of turning off
the periodic schedule after it has been on for less than 1 ms.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c   |2 -
 drivers/usb/host/ehci-pci.c   |4 --
 drivers/usb/host/ehci-sched.c |   69 +++-
 drivers/usb/host/ehci-timer.c |   80 ++
 drivers/usb/host/ehci.h   |7 ++-
 5 files changed, 101 insertions(+), 61 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -79,6 +79,8 @@ enum ehci_rh_state {
  * ehci-timer.c) in parallel with this list.
  */
 enum ehci_hrtimer_event {
+   EHCI_HRTIMER_POLL_PSS,  /* Poll for periodic schedule off */
+   EHCI_HRTIMER_DISABLE_PERIODIC,  /* Wait to disable periodic sched */
EHCI_HRTIMER_NUM_EVENTS /* Must come last */
 };
 #define EHCI_HRTIMER_NO_EVENT  99
@@ -90,6 +92,8 @@ struct ehci_hcd { /* one per controlle
ktime_t hr_timeouts[EHCI_HRTIMER_NUM_EVENTS];
struct hrtimer  hrtimer;
 
+   int PSS_poll_count;
+
/* glue to PCI and HCD framework */
struct ehci_caps __iomem *caps;
struct ehci_regs __iomem *regs;
@@ -116,7 +120,7 @@ struct ehci_hcd {   /* one per controlle
 
union ehci_shadow   *pshadow;   /* mirror hw periodic table */
int next_uframe;/* scan periodic, start here */
-   unsignedperiodic_sched; /* periodic activity count */
+   unsignedperiodic_count; /* periodic activity count */
unsigneduframe_periodic_max; /* max periodic time per 
uframe */
 
 
@@ -165,7 +169,6 @@ struct ehci_hcd {   /* one per controlle
unsignedbig_endian_capbase:1;
unsignedhas_amcc_usb23:1;
unsignedneed_io_watchdog:1;
-   unsignedbroken_periodic:1;
unsignedamd_pll_fix:1;
unsignedfs_i_thresh:1;  /* Intel iso scheduling */
unsigneduse_dummy_qh:1; /* AMD Frame List table quirk*/
Index: usb-3.4/drivers/usb/host/ehci-pci.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-pci.c
+++ usb-3.4/drivers/usb/host/ehci-pci.c
@@ -104,10 +104,6 @@ static int ehci_pci_setup(struct usb_hcd
break;
case PCI_VENDOR_ID_INTEL:
ehci->fs_i_thresh = 1;
-   if (pdev->device == 0x27cc) {
-   ehci->broken_periodic = 1;
-   ehci_info(ehci, "using broken periodic workaround\n");
-   }
if (pdev->device == PCI_DEVICE_ID_INTEL_CE4100_USB)
hcd->has_tt = 1;
break;
Index: usb-3.4/drivers/usb/host/ehci-timer.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-timer.c
+++ usb-3.4/drivers/usb/host/ehci-timer.c
@@ -16,6 +16,28 @@
 
 /*-*/
 
+/* Set a bit in the USBCMD register */
+static void ehci_set_command_bit(struct ehci_hcd *ehci, u32 bit)
+{
+   ehci->command |= bit;
+   ehci_writel(ehci, ehci->command, &ehci->regs->command);
+
+   /* unblock posted write */
+   ehci_readl(ehci, &ehci->regs->command);
+}
+
+/* Clear a bit in the USBCMD register */
+static void ehci_clear_command_bit(struct ehci_hcd *ehci, u32 bit)
+{
+   ehci->command &= ~bit;
+ 

[PATCH 8/25] USB: EHCI: introduce high-res timer

2012-07-11 Thread Alan Stern
This patch (as1572) begins the conversion of ehci-hcd over to using
high-resolution timers rather than old-fashioned low-resolution kernel
timers.  This reduces overhead caused by timer roundoff on systems
where HZ is smaller than 1000.  Also, the new timer framework
introduced here is much more logical and easily extended than the
ad-hoc approach ehci-hcd currently uses for timers.

An hrtimer structure is added to ehci_hcd, along with a bitflag array
and an array of ktime_t values, to keep track of which timing events
are pending and what their expiration times are.

Only the infrastructure for the timing operations is added in this
patch.  Later patches will add routines for handling each of the
various timing events the driver needs.  In some cases the new hrtimer
handlers will replace the existing handlers for ehci-hcd's kernel
timers; as this happens the old timers will be removed.  In other
cases the new timing events will replace busy-wait loops.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c   |   15 +
 drivers/usb/host/ehci-hub.c   |3 +
 drivers/usb/host/ehci-timer.c |  106 ++
 drivers/usb/host/ehci.h   |   16 ++
 4 files changed, 138 insertions(+), 2 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -73,7 +73,23 @@ enum ehci_rh_state {
EHCI_RH_STOPPING
 };
 
+/*
+ * Timer events, ordered by increasing delay length.
+ * Always update event_delays_ns[] and event_handlers[] (defined in
+ * ehci-timer.c) in parallel with this list.
+ */
+enum ehci_hrtimer_event {
+   EHCI_HRTIMER_NUM_EVENTS /* Must come last */
+};
+#define EHCI_HRTIMER_NO_EVENT  99
+
 struct ehci_hcd {  /* one per controller */
+   /* timing support */
+   enum ehci_hrtimer_event next_hrtimer_event;
+   unsignedenabled_hrtimer_events;
+   ktime_t hr_timeouts[EHCI_HRTIMER_NUM_EVENTS];
+   struct hrtimer  hrtimer;
+
/* glue to PCI and HCD framework */
struct ehci_caps __iomem *caps;
struct ehci_regs __iomem *regs;
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -30,8 +30,7 @@
 #include 
 #include 
 #include 
-#include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -380,6 +379,7 @@ static void ehci_quiesce (struct ehci_hc
 static void end_unlink_async(struct ehci_hcd *ehci);
 static void ehci_work(struct ehci_hcd *ehci);
 
+#include "ehci-timer.c"
 #include "ehci-hub.c"
 #include "ehci-lpm.c"
 #include "ehci-mem.c"
@@ -494,7 +494,10 @@ static void ehci_shutdown(struct usb_hcd
spin_lock_irq(&ehci->lock);
ehci->rh_state = EHCI_RH_STOPPING;
ehci_silence_controller(ehci);
+   ehci->enabled_hrtimer_events = 0;
spin_unlock_irq(&ehci->lock);
+
+   hrtimer_cancel(&ehci->hrtimer);
 }
 
 static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
@@ -561,12 +564,14 @@ static void ehci_stop (struct usb_hcd *h
del_timer_sync(&ehci->iaa_watchdog);
 
spin_lock_irq(&ehci->lock);
+   ehci->enabled_hrtimer_events = 0;
ehci_quiesce(ehci);
 
ehci_silence_controller(ehci);
ehci_reset (ehci);
spin_unlock_irq(&ehci->lock);
 
+   hrtimer_cancel(&ehci->hrtimer);
remove_sysfs_files(ehci);
remove_debug_files (ehci);
 
@@ -615,6 +620,10 @@ static int ehci_init(struct usb_hcd *hcd
ehci->iaa_watchdog.function = ehci_iaa_watchdog;
ehci->iaa_watchdog.data = (unsigned long) ehci;
 
+   hrtimer_init(&ehci->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
+   ehci->hrtimer.function = ehci_hrtimer_func;
+   ehci->next_hrtimer_event = EHCI_HRTIMER_NO_EVENT;
+
hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params);
 
/*
@@ -954,6 +963,8 @@ static irqreturn_t ehci_irq (struct usb_
dbg_status(ehci, "fatal", status);
ehci_halt(ehci);
 dead:
+   ehci->enabled_hrtimer_events = 0;
+   hrtimer_try_to_cancel(&ehci->hrtimer);
ehci_reset(ehci);
ehci_writel(ehci, 0, &ehci->regs->configured_flag);
usb_hc_died(hcd);
Index: usb-3.4/drivers/usb/host/ehci-hub.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hub.c
+++ usb-3.4/drivers/usb/host/ehci-hub.c
@@ -311,12 +311,15 @@ static int ehci_bus_suspend (struct usb_
ehci_readl(ehci, &ehci->regs->intr_enable);
 
ehci->next_statechange = jiffies + msecs_to_jiffies(10);
+   ehci->enabled_hrtimer_events = 0;
+   ehci->next_hrtimer_event = EHCI_HRTIMER_NO_EVENT;
spin_unlock_irq (&ehci->lock);
 

[PATCH 7/25] USB: EHCI: add new root-hub state: STOPPING

2012-07-11 Thread Alan Stern
This patch (as1571) adds a new state for ehci-hcd's root hubs:
EHCI_RH_STOPPING.  This value is used at times when the root hub is
being stopped and we don't know whether or not the hardware has
finished all its DMA yet.

Although the purpose may not be apparent, this distinction will come
in useful later on.  Future patches will avoid actions that depend on
the root hub being operational (like turning on the async or periodic
schedules) when they see the state is EHCI_RH_STOPPING.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-dbg.c   |2 ++
 drivers/usb/host/ehci-hcd.c   |   13 ++---
 drivers/usb/host/ehci-hub.c   |3 +--
 drivers/usb/host/ehci-q.c |8 
 drivers/usb/host/ehci-sched.c |8 
 drivers/usb/host/ehci.h   |7 ++-
 6 files changed, 23 insertions(+), 18 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -62,10 +62,15 @@ struct ehci_stats {
 
 #defineEHCI_MAX_ROOT_PORTS 15  /* see HCS_N_PORTS */
 
+/*
+ * ehci_rh_state values of EHCI_RH_RUNNING or above mean that the
+ * controller may be doing DMA.  Lower values mean there's no DMA.
+ */
 enum ehci_rh_state {
EHCI_RH_HALTED,
EHCI_RH_SUSPENDED,
-   EHCI_RH_RUNNING
+   EHCI_RH_RUNNING,
+   EHCI_RH_STOPPING
 };
 
 struct ehci_hcd {  /* one per controller */
Index: usb-3.4/drivers/usb/host/ehci-dbg.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-dbg.c
+++ usb-3.4/drivers/usb/host/ehci-dbg.c
@@ -706,6 +706,8 @@ static const char *rh_state_string(struc
return "suspended";
case EHCI_RH_RUNNING:
return "running";
+   case EHCI_RH_STOPPING:
+   return "stopping";
}
return "?";
 }
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -357,10 +357,8 @@ static void ehci_quiesce (struct ehci_hc
 {
u32 temp;
 
-#ifdef DEBUG
if (ehci->rh_state != EHCI_RH_RUNNING)
-   BUG ();
-#endif
+   return;
 
/* wait for any schedule enables/disables to take effect */
temp = (ehci->command << 10) & (STS_ASS | STS_PSS);
@@ -494,6 +492,7 @@ static void ehci_shutdown(struct usb_hcd
del_timer_sync(&ehci->iaa_watchdog);
 
spin_lock_irq(&ehci->lock);
+   ehci->rh_state = EHCI_RH_STOPPING;
ehci_silence_controller(ehci);
spin_unlock_irq(&ehci->lock);
 }
@@ -562,8 +561,7 @@ static void ehci_stop (struct usb_hcd *h
del_timer_sync(&ehci->iaa_watchdog);
 
spin_lock_irq(&ehci->lock);
-   if (ehci->rh_state == EHCI_RH_RUNNING)
-   ehci_quiesce (ehci);
+   ehci_quiesce(ehci);
 
ehci_silence_controller(ehci);
ehci_reset (ehci);
@@ -951,6 +949,7 @@ static irqreturn_t ehci_irq (struct usb_
/* PCI errors [4.15.2.4] */
if (unlikely ((status & STS_FATAL) != 0)) {
ehci_err(ehci, "fatal error\n");
+   ehci->rh_state = EHCI_RH_STOPPING;
dbg_cmd(ehci, "fatal", cmd);
dbg_status(ehci, "fatal", status);
ehci_halt(ehci);
@@ -1026,7 +1025,7 @@ static int ehci_urb_enqueue (
 static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
 {
/* failfast */
-   if (ehci->rh_state != EHCI_RH_RUNNING && ehci->async_unlink)
+   if (ehci->rh_state < EHCI_RH_RUNNING && ehci->async_unlink)
end_unlink_async(ehci);
 
/* If the QH isn't linked then there's nothing we can do
@@ -1148,7 +1147,7 @@ rescan:
goto idle_timeout;
}
 
-   if (ehci->rh_state != EHCI_RH_RUNNING)
+   if (ehci->rh_state < EHCI_RH_RUNNING)
qh->qh_state = QH_STATE_IDLE;
switch (qh->qh_state) {
case QH_STATE_LINKED:
Index: usb-3.4/drivers/usb/host/ehci-hub.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hub.c
+++ usb-3.4/drivers/usb/host/ehci-hub.c
@@ -227,8 +227,7 @@ static int ehci_bus_suspend (struct usb_
}
 
/* stop schedules, clean any completed work */
-   if (ehci->rh_state == EHCI_RH_RUNNING)
-   ehci_quiesce (ehci);
+   ehci_quiesce(ehci);
ehci_work(ehci);
 
/* Unlike other USB host controller types, EHCI doesn't have
Index: usb-3.4/drivers/usb/host/ehci-q.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-q.c
+++ usb-3.4/drivers/usb/host/ehci-q.c
@@ -433,7 +433,7 @@ qh_completions (struct ehci_hcd *ehci, s
 
/* stop scanning when we reach qtds the hc is using */

[PATCH 6/25] USB: EHCI: add pointer to end of async-unlink list

2012-07-11 Thread Alan Stern
This patch (as1570) adds a pointer for the end of ehci-hcd's
async-unlink list.  The list (which is actually a queue) is singly
linked, so having a pointer to its end makes adding new entries easier
-- there's no longer any need to scan through the whole list.

In principle it could be changed to a standard doubly-linked list.  It
turns out that doing so actually makes the code less clear, so I'm
leaving it as is.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c |9 ++---
 drivers/usb/host/ehci-q.c   |2 ++
 drivers/usb/host/ehci.h |1 +
 3 files changed, 5 insertions(+), 7 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -82,6 +82,7 @@ struct ehci_hcd { /* one per controlle
struct ehci_qh  *async;
struct ehci_qh  *dummy; /* For AMD quirk use */
struct ehci_qh  *async_unlink;
+   struct ehci_qh  *async_unlink_last;
struct ehci_qh  *qh_scan_next;
unsignedscanning : 1;
 
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -1041,14 +1041,9 @@ static void unlink_async (struct ehci_hc
 
/* defer till later if busy */
if (ehci->async_unlink) {
-   struct ehci_qh  *last;
-
-   for (last = ehci->async_unlink;
-   last->unlink_next;
-   last = last->unlink_next)
-   continue;
qh->qh_state = QH_STATE_UNLINK_WAIT;
-   last->unlink_next = qh;
+   ehci->async_unlink_last->unlink_next = qh;
+   ehci->async_unlink_last = qh;
 
/* start IAA cycle */
} else
Index: usb-3.4/drivers/usb/host/ehci-q.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-q.c
+++ usb-3.4/drivers/usb/host/ehci-q.c
@@ -1227,6 +1227,8 @@ static void start_unlink_async (struct e
 
qh->qh_state = QH_STATE_UNLINK;
ehci->async_unlink = qh;
+   if (!qh->unlink_next)
+   ehci->async_unlink_last = qh;
 
prev = ehci->async;
while (prev->qh_next.qh != qh)


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/25] USB: EHCI: rename "reclaim"

2012-07-11 Thread Alan Stern
This patch (as1569) renames the ehci->reclaim list in ehci-hcd.  The
word "reclaim" is used in the EHCI specification to mean something
quite different, and "unlink_next" is more descriptive of the list's
purpose anyway.

Similarly, the "reclaim" field in the ehci_stats structure is renamed
"iaa", which is more meaningful (to experts, anyway) and is a better
match for the "lost_iaa" field.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-dbg.c |   16 +---
 drivers/usb/host/ehci-hcd.c |   25 -
 drivers/usb/host/ehci-hub.c |2 +-
 drivers/usb/host/ehci-q.c   |   22 +++---
 drivers/usb/host/ehci.h |   10 +-
 5 files changed, 38 insertions(+), 37 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -42,7 +42,7 @@ struct ehci_stats {
/* irq usage */
unsigned long   normal;
unsigned long   error;
-   unsigned long   reclaim;
+   unsigned long   iaa;
unsigned long   lost_iaa;
 
/* termination of urbs from core */
@@ -51,7 +51,7 @@ struct ehci_stats {
 };
 
 /* ehci_hcd->lock guards shared data against other CPUs:
- *   ehci_hcd: async, reclaim, periodic (and shadow), ...
+ *   ehci_hcd: async, unlink, periodic (and shadow), ...
  *   usb_host_endpoint: hcpriv
  *   ehci_qh:  qh_next, qtd_list
  *   ehci_qtd: qtd_list
@@ -81,7 +81,7 @@ struct ehci_hcd { /* one per controlle
/* async schedule support */
struct ehci_qh  *async;
struct ehci_qh  *dummy; /* For AMD quirk use */
-   struct ehci_qh  *reclaim;
+   struct ehci_qh  *async_unlink;
struct ehci_qh  *qh_scan_next;
unsignedscanning : 1;
 
@@ -354,7 +354,7 @@ struct ehci_qh {
union ehci_shadow   qh_next;/* ptr to qh; or periodic */
struct list_headqtd_list;   /* sw qtd list */
struct ehci_qtd *dummy;
-   struct ehci_qh  *reclaim;   /* next to reclaim */
+   struct ehci_qh  *unlink_next;   /* next on unlink list */
 
unsigned long   unlink_time;
unsignedstamp;
@@ -364,7 +364,7 @@ struct ehci_qh {
 #defineQH_STATE_LINKED 1   /* HC sees this */
 #defineQH_STATE_UNLINK 2   /* HC may still see 
this */
 #defineQH_STATE_IDLE   3   /* HC doesn't see this 
*/
-#defineQH_STATE_UNLINK_WAIT4   /* LINKED and on 
reclaim q */
+#defineQH_STATE_UNLINK_WAIT4   /* LINKED and on unlink 
q */
 #defineQH_STATE_COMPLETING 5   /* don't touch 
token.HALT */
 
u8  xacterrs;   /* XactErr retry counter */
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -403,7 +403,7 @@ static void ehci_iaa_watchdog(unsigned l
 * (a) SMP races against real IAA firing and retriggering, and
 * (b) clean HC shutdown, when IAA watchdog was pending.
 */
-   if (ehci->reclaim
+   if (ehci->async_unlink
&& !timer_pending(&ehci->iaa_watchdog)
&& ehci->rh_state == EHCI_RH_RUNNING) {
u32 cmd, status;
@@ -583,8 +583,8 @@ static void ehci_stop (struct usb_hcd *h
usb_amd_dev_put();
 
 #ifdef EHCI_STATS
-   ehci_dbg (ehci, "irq normal %ld err %ld reclaim %ld (lost %ld)\n",
-   ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim,
+   ehci_dbg(ehci, "irq normal %ld err %ld iaa %ld (lost %ld)\n",
+   ehci->stats.normal, ehci->stats.error, ehci->stats.iaa,
ehci->stats.lost_iaa);
ehci_dbg (ehci, "complete %ld unlink %ld\n",
ehci->stats.complete, ehci->stats.unlink);
@@ -651,7 +651,6 @@ static int ehci_init(struct usb_hcd *hcd
else// N microframes cached
ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params);
 
-   ehci->reclaim = NULL;
ehci->next_uframe = -1;
ehci->clock_frame = -1;
 
@@ -896,11 +895,11 @@ static irqreturn_t ehci_irq (struct usb_
/* guard against (alleged) silicon errata */
if (cmd & CMD_IAAD)
ehci_dbg(ehci, "IAA with IAAD still set?\n");
-   if (ehci->reclaim) {
-   COUNT(ehci->stats.reclaim);
+   if (ehci->async_unlink) {
+   COUNT(ehci->stats.iaa);
end_unlink_async(ehci);
} else
- 

[PATCH 4/25] USB: EHCI: add symbolic constants for QHs

2012-07-11 Thread Alan Stern
This patch (as1568) introduces symbolic constants for some of the
less-frequently used bitfields in the QH structure.  This makes the
code a little easier to read and understand.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-dbg.c |6 +++---
 drivers/usb/host/ehci-hcd.c |2 +-
 drivers/usb/host/ehci-q.c   |   12 ++--
 drivers/usb/host/ehci.h |8 +++-
 4 files changed, 17 insertions(+), 11 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -324,7 +324,13 @@ union ehci_shadow {
 struct ehci_qh_hw {
__hc32  hw_next;/* see EHCI 3.6.1 */
__hc32  hw_info1;   /* see EHCI 3.6.2 */
-#defineQH_HEAD 0x8000
+#defineQH_CONTROL_EP   (1 << 27)   /* FS/LS control endpoint */
+#defineQH_HEAD (1 << 15)   /* Head of async reclamation 
list */
+#defineQH_TOGGLE_CTL   (1 << 14)   /* Data toggle control */
+#defineQH_HIGH_SPEED   (2 << 12)   /* Endpoint speed */
+#defineQH_LOW_SPEED(1 << 12)
+#defineQH_FULL_SPEED   (0 << 12)
+#defineQH_INACTIVATE   (1 << 7)/* Inactivate on next 
transaction */
__hc32  hw_info2;/* see EHCI 3.6.2 */
 #defineQH_SMASK0x00ff
 #defineQH_CMASK0xff00
Index: usb-3.4/drivers/usb/host/ehci-dbg.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-dbg.c
+++ usb-3.4/drivers/usb/host/ehci-dbg.c
@@ -404,9 +404,9 @@ struct debug_buffer {
 
 #define speed_char(info1) ({ char tmp; \
switch (info1 & (3 << 12)) { \
-   case 0 << 12: tmp = 'f'; break; \
-   case 1 << 12: tmp = 'l'; break; \
-   case 2 << 12: tmp = 'h'; break; \
+   case QH_FULL_SPEED: tmp = 'f'; break; \
+   case QH_LOW_SPEED:  tmp = 'l'; break; \
+   case QH_HIGH_SPEED: tmp = 'h'; break; \
default: tmp = '?'; break; \
}; tmp; })
 
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -667,7 +667,7 @@ static int ehci_init(struct usb_hcd *hcd
hw->hw_next = QH_NEXT(ehci, ehci->async->qh_dma);
hw->hw_info1 = cpu_to_hc32(ehci, QH_HEAD);
 #if defined(CONFIG_PPC_PS3)
-   hw->hw_info1 |= cpu_to_hc32(ehci, (1 << 7));/* I = 1 */
+   hw->hw_info1 |= cpu_to_hc32(ehci, QH_INACTIVATE);
 #endif
hw->hw_token = cpu_to_hc32(ehci, QTD_STS_HALT);
hw->hw_qtd_next = EHCI_LIST_END(ehci);
Index: usb-3.4/drivers/usb/host/ehci-q.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-q.c
+++ usb-3.4/drivers/usb/host/ehci-q.c
@@ -100,7 +100,7 @@ qh_update (struct ehci_hcd *ehci, struct
 * and set the pseudo-toggle in udev. Only usb_clear_halt() will
 * ever clear it.
 */
-   if (!(hw->hw_info1 & cpu_to_hc32(ehci, 1 << 14))) {
+   if (!(hw->hw_info1 & cpu_to_hc32(ehci, QH_TOGGLE_CTL))) {
unsignedis_out, epnum;
 
is_out = qh->is_out;
@@ -886,7 +886,7 @@ qh_make (
/* using TT? */
switch (urb->dev->speed) {
case USB_SPEED_LOW:
-   info1 |= (1 << 12); /* EPS "low" */
+   info1 |= QH_LOW_SPEED;
/* FALL THROUGH */
 
case USB_SPEED_FULL:
@@ -894,8 +894,8 @@ qh_make (
if (type != PIPE_INTERRUPT)
info1 |= (EHCI_TUNE_RL_TT << 28);
if (type == PIPE_CONTROL) {
-   info1 |= (1 << 27); /* for TT */
-   info1 |= 1 << 14;   /* toggle from qtd */
+   info1 |= QH_CONTROL_EP; /* for TT */
+   info1 |= QH_TOGGLE_CTL; /* toggle from qtd */
}
info1 |= maxp << 16;
 
@@ -920,11 +920,11 @@ qh_make (
break;
 
case USB_SPEED_HIGH:/* no TT involved */
-   info1 |= (2 << 12); /* EPS "high" */
+   info1 |= QH_HIGH_SPEED;
if (type == PIPE_CONTROL) {
info1 |= (EHCI_TUNE_RL_HS << 28);
info1 |= 64 << 16;  /* usb2 fixed maxpacket */
-   info1 |= 1 << 14;   /* toggle from qtd */
+   info1 |= QH_TOGGLE_CTL; /* toggle from qtd */
info2 |= (EHCI_TUNE_MULT_HS << 30);
} else if (type == PIPE_BULK) {
info1 |= (EHCI_TUNE_RL_HS << 28);


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the bod

[PATCH 3/25] USB: EHCI: don't refcount QHs

2012-07-11 Thread Alan Stern
This patch (as1567) removes ehci-hcd's reference counting of QH
structures.  It's not necessary to refcount these things because they
always get deallocated at exactly one spot in ehci_endpoint_disable()
(except for two special QHs, ehci->async and ehci->dummy) and are
never used again.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c   |2 +-
 drivers/usb/host/ehci-mem.c   |   24 +++-
 drivers/usb/host/ehci-q.c |   12 +++-
 drivers/usb/host/ehci-sched.c |5 +
 drivers/usb/host/ehci.h   |9 -
 5 files changed, 8 insertions(+), 44 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci.h
===
--- usb-3.4.orig/drivers/usb/host/ehci.h
+++ usb-3.4/drivers/usb/host/ehci.h
@@ -350,16 +350,7 @@ struct ehci_qh {
struct ehci_qtd *dummy;
struct ehci_qh  *reclaim;   /* next to reclaim */
 
-   struct ehci_hcd *ehci;
unsigned long   unlink_time;
-
-   /*
-* Do NOT use atomic operations for QH refcounting. On some CPUs
-* (PPC7448 for example), atomic operations cannot be performed on
-* memory that is cache-inhibited (i.e. being used for DMA).
-* Spinlocks are used to protect all QH fields.
-*/
-   u32 refcount;
unsignedstamp;
 
u8  needs_rescan;   /* Dequeue during giveback */
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -1179,7 +1179,7 @@ idle_timeout:
if (qh->clearing_tt)
goto idle_timeout;
if (list_empty (&qh->qtd_list)) {
-   qh_put (qh);
+   qh_destroy(ehci, qh);
break;
}
/* else FALL THROUGH */
Index: usb-3.4/drivers/usb/host/ehci-mem.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-mem.c
+++ usb-3.4/drivers/usb/host/ehci-mem.c
@@ -64,10 +64,8 @@ static inline void ehci_qtd_free (struct
 }
 
 
-static void qh_destroy(struct ehci_qh *qh)
+static void qh_destroy(struct ehci_hcd *ehci, struct ehci_qh *qh)
 {
-   struct ehci_hcd *ehci = qh->ehci;
-
/* clean qtds first, and know this is not linked */
if (!list_empty (&qh->qtd_list) || qh->qh_next.ptr) {
ehci_dbg (ehci, "unused qh not empty!\n");
@@ -92,8 +90,6 @@ static struct ehci_qh *ehci_qh_alloc (st
if (!qh->hw)
goto fail;
memset(qh->hw, 0, sizeof *qh->hw);
-   qh->refcount = 1;
-   qh->ehci = ehci;
qh->qh_dma = dma;
// INIT_LIST_HEAD (&qh->qh_list);
INIT_LIST_HEAD (&qh->qtd_list);
@@ -113,20 +109,6 @@ fail:
return NULL;
 }
 
-/* to share a qh (cpu threads, or hc) */
-static inline struct ehci_qh *qh_get (struct ehci_qh *qh)
-{
-   WARN_ON(!qh->refcount);
-   qh->refcount++;
-   return qh;
-}
-
-static inline void qh_put (struct ehci_qh *qh)
-{
-   if (!--qh->refcount)
-   qh_destroy(qh);
-}
-
 /*-*/
 
 /* The queue heads and transfer descriptors are managed from pools tied
@@ -138,11 +120,11 @@ static void ehci_mem_cleanup (struct ehc
 {
free_cached_lists(ehci);
if (ehci->async)
-   qh_put (ehci->async);
+   qh_destroy(ehci, ehci->async);
ehci->async = NULL;
 
if (ehci->dummy)
-   qh_put(ehci->dummy);
+   qh_destroy(ehci, ehci->dummy);
ehci->dummy = NULL;
 
/* DMA consistent memory and pools */
Index: usb-3.4/drivers/usb/host/ehci-q.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-q.c
+++ usb-3.4/drivers/usb/host/ehci-q.c
@@ -265,7 +265,6 @@ __acquires(ehci->lock)
/* ... update hc-wide periodic stats (for usbfs) */
ehci_to_hcd(ehci)->self.bandwidth_int_reqs--;
}
-   qh_put (qh);
}
 
if (unlikely(urb->unlinked)) {
@@ -946,7 +945,7 @@ qh_make (
ehci_dbg(ehci, "bogus dev %p speed %d\n", urb->dev,
urb->dev->speed);
 done:
-   qh_put (qh);
+   qh_destroy(ehci, qh);
return NULL;
}
 
@@ -1003,7 +1002,6 @@ static void qh_link_async (struct ehci_h
head->qh_next.qh = qh;
head->hw->hw_next = dma;
 
-   qh_get(qh);
qh->xacterrs = 0;
qh->qh_state = QH_STATE_LINKED;
/* qtd completions reported later by interrupt */
@@ -1090,7 +1088,7 @@ static struct ehci_qh *qh_append_tds (
wmb ();
du

[PATCH 2/25] USB: EHCI: remove unneeded suspend/resume code

2012-07-11 Thread Alan Stern
This patch (as1566) removes the code in ehci-hcd's resume routines
which tries to restart or cancel any transfers left active while the
root hub or controller was asleep.  This code isn't necessary, because
all URBs are terminated before the root hub is suspended.

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c |7 ---
 drivers/usb/host/ehci-hub.c |   13 +
 2 files changed, 1 insertion(+), 19 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci-hub.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hub.c
+++ usb-3.4/drivers/usb/host/ehci-hub.c
@@ -424,23 +424,12 @@ static int ehci_bus_resume (struct usb_h
ehci_vdbg (ehci, "resumed port %d\n", i + 1);
}
}
-   (void) ehci_readl(ehci, &ehci->regs->command);
-
-   /* maybe re-activate the schedule(s) */
-   temp = 0;
-   if (ehci->async->qh_next.qh)
-   temp |= CMD_ASE;
-   if (ehci->periodic_sched)
-   temp |= CMD_PSE;
-   if (temp) {
-   ehci->command |= temp;
-   ehci_writel(ehci, ehci->command, &ehci->regs->command);
-   }
 
ehci->next_statechange = jiffies + msecs_to_jiffies(5);
 
/* Now we can safely re-enable irqs */
ehci_writel(ehci, INTR_MASK, &ehci->regs->intr_enable);
+   (void) ehci_readl(ehci, &ehci->regs->intr_enable);
 
spin_unlock_irq (&ehci->lock);
ehci_handover_companion_ports(ehci);
Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -1312,13 +1312,6 @@ static int __maybe_unused ehci_resume(st
(void) ehci_halt(ehci);
(void) ehci_reset(ehci);
 
-   /* emptying the schedule aborts any urbs */
-   spin_lock_irq(&ehci->lock);
-   if (ehci->reclaim)
-   end_unlink_async(ehci);
-   ehci_work(ehci);
-   spin_unlock_irq(&ehci->lock);
-
ehci_writel(ehci, ehci->command, &ehci->regs->command);
ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag);
ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/25] USB: EHCI: initialize data before resetting hardware

2012-07-11 Thread Alan Stern
Currently, EHCI initialization turns off the controller (in case it
was left running by the firmware) before setting up the ehci_hcd data
structure.  This patch (as1565) reverses that order.

Although it doesn't matter now, it will matter later on when future
additions to ehci_halt() will want to acquire a spinlock that gets
initialized by ehci_init().

Signed-off-by: Alan Stern 

---

 drivers/usb/host/ehci-hcd.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: usb-3.4/drivers/usb/host/ehci-hcd.c
===
--- usb-3.4.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.4/drivers/usb/host/ehci-hcd.c
@@ -823,12 +823,12 @@ static int ehci_setup(struct usb_hcd *hc
 
ehci->sbrn = HCD_USB2;
 
-   retval = ehci_halt(ehci);
+   /* data structure init */
+   retval = ehci_init(hcd);
if (retval)
return retval;
 
-   /* data structure init */
-   retval = ehci_init(hcd);
+   retval = ehci_halt(ehci);
if (retval)
return retval;
 


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/25] USB: EHCI changes

2012-07-11 Thread Alan Stern
Greg:

The following lengthy series contains a set of changes and enhancements 
to ehci-hcd.  The most notable changes include moving from regular 
kernel timers to high-resolution timers, and getting rid of long 
polling loops with interrupts disabled.

Other changes include removal of unnecessary code, adding symbolic
constants, renaming a few fields, general cleanups, checking for a few
unlikely races, not assuming the controller has died when a state
change takes longer than expected, unlinking multiple async QHs
together, unlinking interrput QHs correctly, and so on...

The end result will be (I hope!) a better behaved driver.

Alan Stern


 drivers/usb/host/ehci-dbg.c   |   24 -
 drivers/usb/host/ehci-hcd.c   |  457 +++-
 drivers/usb/host/ehci-hub.c   |  101 ---
 drivers/usb/host/ehci-mem.c   |   25 -
 drivers/usb/host/ehci-pci.c   |4 
 drivers/usb/host/ehci-q.c |  359 ++---
 drivers/usb/host/ehci-sched.c |  590 +++---
 drivers/usb/host/ehci-tegra.c |5 
 drivers/usb/host/ehci-timer.c |  423 +-
 drivers/usb/host/ehci.h   |  136 +
 10 files changed, 1139 insertions(+), 985 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: 3.4.4: disabling irq

2012-07-11 Thread Alan Stern
On Wed, 11 Jul 2012, Udo van den Heuvel wrote:

> New occurrence:
> 
> Jul 11 16:45:26 box3 kernel: irq 18: nobody cared (try booting with the
> "irqpoll" option)
> Jul 11 16:45:26 box3 kernel: Pid: 1465, comm: irq/18-ohci_hcd Not
> tainted 3.4.4 #3

> Any clues and/or updates?

Didn't you see the message I posted on Monday?

http://marc.info/?l=linux-usb&m=134186054713868&w=2

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/6] USB: serial: Changes to conform with checkpatch.

2012-07-11 Thread Greg KH
On Thu, Jul 12, 2012 at 12:10:14AM +1000, Ben Minerds wrote:
> Removed various checkpatch.sh warnings and errors. 
> Split patch by warning/error type.
> Corrected line wraps in emails.
> 
> Signed-off-by: Ben Minerds 
> ---
>  drivers/usb/serial/keyspan.c |  106 
> +-
>  1 files changed, 53 insertions(+), 53 deletions(-)

I don't understand, is this 0/6 patch a "real" patch that should be
applied, or is it just a summary of the 1-6 patches all together?

Normally the 0/6 email is a text summary, and maybe the diffstat of the
whole patchset.  But not a patch itself with a signed-off-by line.

confused,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: host: xhci: Compliance Mode port recovery

2012-07-11 Thread 'Greg KH'
On Tue, Jul 10, 2012 at 05:32:35PM -0500, Alexis Cortes wrote:
> Hi Sarah & Greg,
> 
> I made another patch for this issue following your recommendations. The only
> thing that is left is the way the patch is going to be implemented on the
> kernel (module parameter, sysfs...), which is still in discussion. The
> changes I made for this patch are as follows:
> 
> * Changed #define COMP_MODE_RCVRY_TIMEOUT 2 by #define COMP_MODE_RCVRY_MSECS
> 2000.
> * Timer implemented as a Slack Timer.
> * Stop and Restart the timer when the host is suspended.
> * Let the USB core handle the warm reset.
> * Stop timer when all ports have entered U0.

That's a much nicer version, thanks.

Few minor corrections below:

> [PATCH] usb: host: xhci: Compliance Mode Port Recovery

Better subject: "Fix compliance mode on SN65LVPE502CP hardware"?

As this is a fix for broken hardware, right?

> + } else {
> + /* If CAS bit isn't set but the Port is already at
> +  * Compliance Mode, fake a connection so the USB core
> +  * notices the Compliance state and resets the port

Add "This resolves an issue with the..." describing the hardware
problem?

> + xhci_dbg(xhci, "Compliance Mode
> Recovery Timer "
> +"Deleted. All USB3
> ports have "
> +"entered U0 at least
> once.\n");

Keep the string all on one line.

> +/*Compliance Mode Recovery Patch*/

Why is this comment needed?

> +static void compliance_mode_rcvry(unsigned long arg)

Vowels are free, please use them :)

> +{
> + struct xhci_hcd *xhci;
> + struct usb_hcd *hcd;
> + u32 temp;
> + int i;
> +
> + xhci = (struct xhci_hcd *) arg;

No space needed before "arg".

> +
> + for (i = 0; i < xhci->num_usb3_ports; i++) {
> + temp = xhci_readl(xhci, xhci->usb3_ports[i]);
> + if ((temp & PORT_PLS_MASK) == USB_SS_PORT_LS_COMP_MOD) {
> + /* Compliance Mode Detected. Letting USB Core handle
> +  * the Warm Reset */

Multi-line comments are usually in this form:
/*
 * Compliance Mode Detected. Letting USB Core handle
 * the Warm Reset.
 */

> + xhci_dbg(xhci, "Compliance Mode Detected on port %d!
> "
> + "Attempting recovery routine.\n", i

Don't spread strings across lines, it makes it harder to grep for them.

> +static void compliance_mode_rcvry_timer_init(struct xhci_hcd *xhci)
> +{
> + xhci->port_status_u0 = 0;
> + init_timer(&xhci->comp_mode_rcvry_timer);
> + xhci->comp_mode_rcvry_timer.data = (unsigned long) xhci;
> + xhci->comp_mode_rcvry_timer.function = compliance_mode_rcvry;
> + xhci->comp_mode_rcvry_timer.expires = jiffies +
> + msecs_to_jiffies(COMP_MODE_RCVRY_MSECS);
> + set_timer_slack(&xhci->comp_mode_rcvry_timer, HZ);

That seems like a pretty strict slack time.  Can't you make it much
larger?  Like at least COMP_MODE_RCVRY_MSECS?  You don't need a precise
timer here at all, so give it as much room to be delayed as possible.

> + add_timer(&xhci->comp_mode_rcvry_timer);
> + xhci_dbg(xhci, "Compliance Mode Recovery Timer Initialized.\n");
> +}
> +
>  /*
>   * Initialize memory for HCD and xHC (one-time init).
>   *
> @@ -420,6 +464,9 @@ int xhci_init(struct usb_hcd *hcd)
>   retval = xhci_mem_init(xhci, GFP_KERNEL);
>   xhci_dbg(xhci, "Finished xhci_init\n");
>  
> + /* Initializing Compliance Mode Recovery Data */
> + compliance_mode_rcvry_timer_init(xhci);

There's really no way we can detect this based on the hardware on the
system?  Firmware version number?  PCI ids?  DMI strings?  BIOS
versions?  Hardware platform types?  Processor types?  Something?
Anything?

What did Microsoft say in your proposal to them to add this timer for
every Windows system using xhci?

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH -v2] USB: add USB_VENDOR_AND_INTERFACE_INFO() macro

2012-07-11 Thread Henrik Rydberg
On Tue, Jul 10, 2012 at 07:10:06PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan 
> 
> A lot of Broadcom Bluetooth devices provides vendor specific interface
> class and we are getting flooded by patches adding new device support.
> This change will help us enable support for any other Broadcom with vendor
> specific device that arrives in the future.
> 
> Only the product id changes for those devices, so this macro would be
> perfect for us:
> 
> { USB_VENDOR_AND_INTERFACE_INFO(0x0a5c, 0xff, 0x01, 0x01) }
> 
> Signed-off-by: Marcel Holtmann 
> Signed-off-by: Gustavo Padovan 
> ---

Thank you, Gustavo, this patch made me happy.

Henrik
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: 3.4.4: disabling irq

2012-07-11 Thread Udo van den Heuvel
On 2012-07-09 15:54, Clemens Ladisch wrote:
> (forwarded to linux-usb)
> 
> Udo van den Heuvel wrote:
>>
>> One moment the box is runing OK.
>> One moment the 3.4.4 kernel decides to disable an interrupt.
>> Why?
>>
>> Jul  8 07:43:49 box3 ntpd[5067]: parse: convert_rawdcf: INCOMPLETE DATA - 
>> time code only has 1 bits
>> Jul  8 07:44:53 box3 kernel: irq 18: nobody cared (try booting with the 
>> "irqpoll" option)
>> Jul  8 07:44:53 box3 kernel: Pid: 1501, comm: irq/18-ohci_hcd Tainted: G 
>>W3.4.4 #1
>> Jul  8 07:44:53 box3 kernel: Call Trace:
>> Jul  8 07:44:53 box3 kernel: [] ? 
>> __report_bad_irq+0x36/0xd0
>> Jul  8 07:44:53 box3 kernel: [] ? 
>> note_interrupt+0x1cf/0x220
>> Jul  8 07:44:53 box3 kernel: [] ? irq_thread_fn+0x40/0x40
>> Jul  8 07:44:53 box3 kernel: [] ? irq_thread+0x13d/0x180
>> Jul  8 07:44:53 box3 kernel: [] ? 
>> wake_threads_waitq+0x50/0x50
>> Jul  8 07:44:53 box3 kernel: [] ? kthread+0x85/0x90
>> Jul  8 07:44:53 box3 kernel: [] ? 
>> kernel_thread_helper+0x4/0x10
>> Jul  8 07:44:53 box3 kernel: [] ? 
>> kthread_freezable_should_stop+0x50/0x50
>> Jul  8 07:44:53 box3 kernel: [] ? gs_change+0xb/0xb
>> Jul  8 07:44:53 box3 kernel: handlers:
>> Jul  8 07:44:53 box3 kernel: [] 
>> irq_default_primary_handler threaded [] usb_hcd_irq
>> Jul  8 07:44:53 box3 kernel: [] 
>> irq_default_primary_handler threaded [] usb_hcd_irq
>> Jul  8 07:44:53 box3 kernel: [] 
>> irq_default_primary_handler threaded [] usb_hcd_irq
>> Jul  8 07:44:53 box3 kernel: Disabling IRQ #18
>> Jul  8 07:44:53 box3 kernel: pwc: Iso frame 0 has error -114
>> Jul  8 07:44:53 box3 kernel: pwc: Iso frame 1 has error -18
>> Jul  8 07:44:53 box3 kernel: pwc: Iso frame 2 has error -18
>> Jul  8 07:44:53 box3 kernel: pwc: Iso frame 3 has error -18
>> Jul  8 07:44:53 box3 kernel: pwc: Iso frame 4 has error -18
>> Jul  8 07:44:53 box3 kernel: pwc: Iso frame 5 has error -18
>> (etc; many more of the pwc messages)

New occurrence:

Jul 11 16:45:26 box3 kernel: irq 18: nobody cared (try booting with the
"irqpoll" option)
Jul 11 16:45:26 box3 kernel: Pid: 1465, comm: irq/18-ohci_hcd Not
tainted 3.4.4 #3
Jul 11 16:45:26 box3 kernel: Call Trace:
Jul 11 16:45:26 box3 kernel: [] ?
__report_bad_irq+0x36/0xd0
Jul 11 16:45:26 box3 kernel: [] ?
note_interrupt+0x1cf/0x220
Jul 11 16:45:26 box3 kernel: [] ? irq_thread_fn+0x40/0x40
Jul 11 16:45:26 box3 kernel: [] ? irq_thread+0x13d/0x180
Jul 11 16:45:26 box3 kernel: [] ?
wake_threads_waitq+0x50/0x50
Jul 11 16:45:26 box3 kernel: [] ? kthread+0x85/0x90
Jul 11 16:45:26 box3 kernel: [] ?
kernel_thread_helper+0x4/0x10
Jul 11 16:45:26 box3 kernel: [] ?
kthread_freezable_should_stop+0x50/0x50
Jul 11 16:45:26 box3 kernel: [] ? gs_change+0xb/0xb
Jul 11 16:45:26 box3 kernel: handlers:
Jul 11 16:45:26 box3 kernel: []
irq_default_primary_handler threaded [] usb_hcd_irq
Jul 11 16:45:26 box3 kernel: []
irq_default_primary_handler threaded [] usb_hcd_irq
Jul 11 16:45:26 box3 kernel: []
irq_default_primary_handler threaded [] usb_hcd_irq
Jul 11 16:45:26 box3 kernel: Disabling IRQ #18
Jul 11 16:45:26 box3 kernel: pwc: Iso frame 0 has error -18
Jul 11 16:45:26 box3 kernel: pwc: Iso frame 1 has error -18
(etc)


Any clues and/or updates?


Udo
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb/host/ehci-hub: Fix the issue EG20T USB host controller has long resuming time, when pen drive is attached.

2012-07-11 Thread Alan Stern
On Wed, 11 Jul 2012, Tomoya MORINAGA wrote:

> 
> Signed-off-by: Tomoya MORINAGA 

There's no patch description.  What is the cause of the problem and how
does the patch fix it?

> ---
>  drivers/usb/host/ehci-hub.c |4 
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
> index fc9e7cc..d596d0f 100644
> --- a/drivers/usb/host/ehci-hub.c
> +++ b/drivers/usb/host/ehci-hub.c
> @@ -207,6 +207,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
>   int port;
>   int mask;
>   int changed;
> + int temp;
>  
>   ehci_dbg(ehci, "suspend root hub\n");
>  
> @@ -324,6 +325,9 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
>* want, and so we must delete any pending watchdog timer events.
>*/
>   del_timer_sync(&ehci->watchdog);
> + temp = ehci_readl(ehci, &ehci->regs->status);
> + if (temp & STS_FLR)
> + ehci_writel(ehci, STS_FLR, &ehci->regs->status);
>   return 0;

Operations like this should be done while holding the spinlock.

Also, why do you need the ehci_readl and the test?  You could always 
clear the STS_FLR flag.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] OMAP: USB : Fix the EHCI enumeration and core retention issue

2012-07-11 Thread Kevin Hilman
"Munegowda, Keshava"  writes:

> On Wed, Jul 11, 2012 at 3:59 PM, Samuel Ortiz  wrote:
>> Hi Keshava, Kevin,
>>
>> On Fri, Jul 06, 2012 at 05:29:00PM +0530, Munegowda, Keshava wrote:
>>> Samuel
>>>   I have sent that patch to disable the ehci in
>>> omap2plus_defconfig; after merging that
>>> please merge this patch too. This will fix the crashes in during boot
>>> with NFS in beagleXM
>> I'm going to apply and push this patch for 3.5, and the defconfig patch can 
>> be
>> pushed through Tony's tree.
>> Kevin, could you please ACK it ?
>>
>> Cheers,
>> Samuel.
>>
>
> Thanks Samuel
>
> Kevin,
> need your ack for this.

You never answered earlier questions from myself or Russ Dill about the
more targetted patches from Russ:

   ARM: OMAP: USB: Fixup ehci_hcd_omap_probe error path
   Fix OMAP EHCI suspend/resume failure (i693) '354ab856' causes

Also, your current $SUBJECT patch is large and not well
described. e.g. what is "not correct" and why.  Why does it fix the
problems mentioned?  The original changelog mentions the "core retention
issue" but this patch does nothing to address that.  If you want an Ack
from me, especially because I'm not an expert in this IP, you'll have to
describe things in a way that I can understand.

IMO, at this point of the dev cycle (trying to stabilize v3.5), the full
cleanup/fix of this feature will need to be done for v3.6.  For v3.5, I
think the two patches from Russ Dill should be merged.   They are
targetted fixes and very well described.

Kevin

> The commit id 354ab8567ae3107a8cbe7228c3181990ba598aac titled
> "Fix OMAP EHCI suspend/resume failure (i693)",
> is handling the clocks in ehci driver which is not correct,
> it will be through the usb host driver ( /mfd/omap-usb_host.c )  exporting
> APIs to ehci driver to handler the port clocks.
>
> for now, this patch is necessary to remove the
>  commit id 354ab8567ae3107a8cbe7228c3181990ba598aac titled
> "Fix OMAP EHCI suspend/resume failure (i693)",
>
> regards
> keshava
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/6] USB: serial: Removed unrequired parentheses.

2012-07-11 Thread Ben Minerds
Changes to conform with checkpatch.sh script. - return is not a 
function, parentheses not required. Removed 1 checkpatch.sh error.

Signed-off-by: Ben Minerds 
---
 drivers/usb/serial/keyspan.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index f205e9b..ccb24e6 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -1240,7 +1240,7 @@ static int keyspan_fake_startup(struct usb_serial *serial)
 
if (request_ihex_firmware(&fw, fw_name, &serial->dev->dev)) {
dev_err(&serial->dev->dev, "Required keyspan firmware image 
(%s) unavailable.\n", fw_name);
-   return(1);
+   return 1;
}
 
dbg("Uploading Keyspan %s firmware.", fw_name);
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/6] USB: serial: Removed trailing whitespace.

2012-07-11 Thread Ben Minerds
Changes to conform with checkpatch.sh script. - trailing whitespace. 
Removed 1 checkpatch.sh error.

Signed-off-by: Ben Minerds 
---
 drivers/usb/serial/keyspan.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 50494f4..f205e9b 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -559,7 +559,7 @@ static void usa28_instat_callback(struct urb *urb)
 
if (old_dcd_state != p_priv->dcd_state && old_dcd_state) {
tty = tty_port_tty_get(&port->port);
-   if (tty && !C_CLOCAL(tty)) 
+   if (tty && !C_CLOCAL(tty))
tty_hangup(tty);
tty_kref_put(tty);
}
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/6] USB: serial: Fixed space near open parenthesis.

2012-07-11 Thread Ben Minerds
Changes to conform with checkpatch.sh script. - space near open 
parenthesis '('. Removed 2 checkpatch.sh errors.

Signed-off-by: Ben Minerds 
---
 drivers/usb/serial/keyspan.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index f980d7d..50494f4 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -557,7 +557,7 @@ static void usa28_instat_callback(struct urb *urb)
p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
p_priv->ri_state = ((msg->ri) ? 1 : 0);
 
-   if( old_dcd_state != p_priv->dcd_state && old_dcd_state) {
+   if (old_dcd_state != p_priv->dcd_state && old_dcd_state) {
tty = tty_port_tty_get(&port->port);
if (tty && !C_CLOCAL(tty)) 
tty_hangup(tty);
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/6] USB: serial: Fixed space around equals.

2012-07-11 Thread Ben Minerds
Changes to conform with checkpatch.sh script. - space around '='.
Removed 1 checkpatch.sh error.

Signed-off-by: Ben Minerds 
---
 drivers/usb/serial/keyspan.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 4389736..f980d7d 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -474,7 +474,7 @@ static void usa28_indat_callback(struct urb *urb)
p_priv = usb_get_serial_port_data(port);
data = urb->transfer_buffer;
 
-   tty =tty_port_tty_get(&port->port);
+   tty = tty_port_tty_get(&port->port);
if (tty && urb->actual_length) {
tty_insert_flip_string(tty, data, urb->actual_length);
tty_flip_buffer_push(tty);
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/6] USB: serial: Fix spacing around conditional.

2012-07-11 Thread Ben Minerds
Changes to conform with checkpatch.sh script. - spaces around '?' 
and ':'.Removed 14 checkpatch.sh errors.

Signed-off-by: Ben Minerds 
---
 drivers/usb/serial/keyspan.c |   18 +-
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 23cc8ec..4389736 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -176,7 +176,7 @@ static void keyspan_set_termios(struct tty_struct *tty,
tty_encode_baud_rate(tty, baud_rate, baud_rate);
/* set CTS/RTS handshake etc. */
p_priv->cflag = cflag;
-   p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none;
+   p_priv->flow_control = (cflag & CRTSCTS) ? flow_cts : flow_none;
 
/* Mark/Space not supported */
tty->termios->c_cflag &= ~CMSPAR;
@@ -1102,7 +1102,7 @@ static int keyspan_open(struct tty_struct *tty, struct 
usb_serial_port *port)
}
/* set CTS/RTS handshake etc. */
p_priv->cflag = cflag;
-   p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none;
+   p_priv->flow_control = (cflag & CRTSCTS) ? flow_cts : flow_none;
 
keyspan_send_setup(port, 1);
/* mdelay(100); */
@@ -1709,7 +1709,7 @@ static int keyspan_usa26_send_setup(struct usb_serial 
*serial,
msg.setPrescaler = 0xff;
}
 
-   msg.lcr = (p_priv->cflag & CSTOPB)? STOPBITS_678_2: STOPBITS_5678_1;
+   msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
switch (p_priv->cflag & CSIZE) {
case CS5:
msg.lcr |= USA_DATABITS_5;
@@ -1726,7 +1726,7 @@ static int keyspan_usa26_send_setup(struct usb_serial 
*serial,
}
if (p_priv->cflag & PARENB) {
/* note USA_PARITY_NONE == 0 */
-   msg.lcr |= (p_priv->cflag & PARODD)?
+   msg.lcr |= (p_priv->cflag & PARODD) ?
USA_PARITY_ODD : USA_PARITY_EVEN;
}
msg.setLcr = 0xff;
@@ -1994,7 +1994,7 @@ static int keyspan_usa49_send_setup(struct usb_serial 
*serial,
/* msg.setPrescaler = 0xff; */
}
 
-   msg.lcr = (p_priv->cflag & CSTOPB)? STOPBITS_678_2: STOPBITS_5678_1;
+   msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
switch (p_priv->cflag & CSIZE) {
case CS5:
msg.lcr |= USA_DATABITS_5;
@@ -2011,7 +2011,7 @@ static int keyspan_usa49_send_setup(struct usb_serial 
*serial,
}
if (p_priv->cflag & PARENB) {
/* note USA_PARITY_NONE == 0 */
-   msg.lcr |= (p_priv->cflag & PARODD)?
+   msg.lcr |= (p_priv->cflag & PARODD) ?
USA_PARITY_ODD : USA_PARITY_EVEN;
}
msg.setLcr = 0xff;
@@ -2178,7 +2178,7 @@ static int keyspan_usa90_send_setup(struct usb_serial 
*serial,
msg.txMode = TXMODE_BYHAND;
}
 
-   msg.lcr = (p_priv->cflag & CSTOPB)? STOPBITS_678_2: STOPBITS_5678_1;
+   msg.lcr = (p_priv->cflag & CSTOPB) ? STOPBITS_678_2 : STOPBITS_5678_1;
switch (p_priv->cflag & CSIZE) {
case CS5:
msg.lcr |= USA_DATABITS_5;
@@ -2195,7 +2195,7 @@ static int keyspan_usa90_send_setup(struct usb_serial 
*serial,
}
if (p_priv->cflag & PARENB) {
/* note USA_PARITY_NONE == 0 */
-   msg.lcr |= (p_priv->cflag & PARODD)?
+   msg.lcr |= (p_priv->cflag & PARODD) ?
USA_PARITY_ODD : USA_PARITY_EVEN;
}
if (p_priv->old_cflag != p_priv->cflag) {
@@ -2322,7 +2322,7 @@ static int keyspan_usa67_send_setup(struct usb_serial 
*serial,
}
if (p_priv->cflag & PARENB) {
/* note USA_PARITY_NONE == 0 */
-   msg.lcr |= (p_priv->cflag & PARODD)?
+   msg.lcr |= (p_priv->cflag & PARODD) ?
USA_PARITY_ODD : USA_PARITY_EVEN;
}
msg.setLcr = 0xff;
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/6] USB: serial: Removed space before tabs.

2012-07-11 Thread Ben Minerds
Changes to conform with checkpatch.sh script. - no space before tabs. 
Removed 52 checkpatch.sh warnings.

Signed-off-by: Ben Minerds 
---
 drivers/usb/serial/keyspan.c |  106 +-
 1 files changed, 53 insertions(+), 53 deletions(-)

diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index a1b9924..23cc8ec 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -135,7 +135,7 @@ module_usb_serial_driver(serial_drivers, 
keyspan_ids_combined);
 static void keyspan_break_ctl(struct tty_struct *tty, int break_state)
 {
struct usb_serial_port *port = tty->driver_data;
-   struct keyspan_port_private *p_priv;
+   struct keyspan_port_private *p_priv;
 
p_priv = usb_get_serial_port_data(port);
 
@@ -152,9 +152,9 @@ static void keyspan_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios)
 {
int baud_rate, device_port;
-   struct keyspan_port_private *p_priv;
+   struct keyspan_port_private *p_priv;
const struct keyspan_device_details *d_details;
-   unsigned intcflag;
+   unsigned intcflag;
 
p_priv = usb_get_serial_port_data(port);
d_details = p_priv->device_details;
@@ -223,12 +223,12 @@ static int keyspan_tiocmset(struct tty_struct *tty,
 static int keyspan_write(struct tty_struct *tty,
struct usb_serial_port *port, const unsigned char *buf, int count)
 {
-   struct keyspan_port_private *p_priv;
+   struct keyspan_port_private *p_priv;
const struct keyspan_device_details *d_details;
int flip;
-   int left, todo;
+   int left, todo;
struct urb  *this_urb;
-   int err, maxDataLen, dataOffset;
+   int err, maxDataLen, dataOffset;
 
p_priv = usb_get_serial_port_data(port);
d_details = p_priv->device_details;
@@ -299,7 +299,7 @@ static void usa26_indat_callback(struct urb *urb)
int endpoint;
struct usb_serial_port  *port;
struct tty_struct   *tty;
-   unsigned char   *data = urb->transfer_buffer;
+   unsigned char   *data = urb->transfer_buffer;
int status = urb->status;
 
endpoint = usb_pipeendpoint(urb->pipe);
@@ -382,11 +382,11 @@ static void   usa26_outcont_callback(struct urb *urb)
 
 static voidusa26_instat_callback(struct urb *urb)
 {
-   unsigned char   *data = urb->transfer_buffer;
+   unsigned char   *data = urb->transfer_buffer;
struct keyspan_usa26_portStatusMessage  *msg;
struct usb_serial   *serial;
struct usb_serial_port  *port;
-   struct keyspan_port_private *p_priv;
+   struct keyspan_port_private *p_priv;
struct tty_struct   *tty;
int old_dcd_state, err;
int status = urb->status;
@@ -514,11 +514,11 @@ static void   usa28_outcont_callback(struct urb *urb)
 static voidusa28_instat_callback(struct urb *urb)
 {
int err;
-   unsigned char   *data = urb->transfer_buffer;
+   unsigned char   *data = urb->transfer_buffer;
struct keyspan_usa28_portStatusMessage  *msg;
struct usb_serial   *serial;
struct usb_serial_port  *port;
-   struct keyspan_port_private *p_priv;
+   struct keyspan_port_private *p_priv;
struct tty_struct   *tty;
int old_dcd_state;
int status = urb->status;
@@ -602,11 +602,11 @@ static void   usa49_glocont_callback(struct urb *urb)
 static voidusa49_instat_callback(struct urb *urb)
 {
int err;
-   unsigned char   *data = urb->transfer_buffer;
+   unsigned char   *data = urb->transfer_buffer;
struct keyspan_usa49_portStatusMessage  *msg;
struct usb_serial   *serial;
struct usb_serial_port  *port;
-   struct keyspan_port_private *p_priv;
+   struct keyspan_port_private *p_priv;
int old_dcd_state;
int status = urb->status;
 
@@ -670,7 +670,7 @@ static void usa49_indat_callback(struct urb *urb)
int endpoint;
struct usb_serial_port  *port;
struct tty_struct   *tty;
-   unsigned char   *data = urb->transfer_buffer;
+   unsigned char   *data = urb->trans

[PATCH 0/6] USB: serial: Changes to conform with checkpatch.

2012-07-11 Thread Ben Minerds
Removed various checkpatch.sh warnings and errors. 
Split patch by warning/error type.
Corrected line wraps in emails.

Signed-off-by: Ben Minerds 
---
 drivers/usb/serial/keyspan.c |  106 +-
 1 files changed, 53 insertions(+), 53 deletions(-)

diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index a1b9924..23cc8ec 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -135,7 +135,7 @@ module_usb_serial_driver(serial_drivers, 
keyspan_ids_combined);
 static void keyspan_break_ctl(struct tty_struct *tty, int break_state)
 {
struct usb_serial_port *port = tty->driver_data;
-   struct keyspan_port_private *p_priv;
+   struct keyspan_port_private *p_priv;
 
p_priv = usb_get_serial_port_data(port);
 
@@ -152,9 +152,9 @@ static void keyspan_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios)
 {
int baud_rate, device_port;
-   struct keyspan_port_private *p_priv;
+   struct keyspan_port_private *p_priv;
const struct keyspan_device_details *d_details;
-   unsigned intcflag;
+   unsigned intcflag;
 
p_priv = usb_get_serial_port_data(port);
d_details = p_priv->device_details;
@@ -223,12 +223,12 @@ static int keyspan_tiocmset(struct tty_struct *tty,
 static int keyspan_write(struct tty_struct *tty,
struct usb_serial_port *port, const unsigned char *buf, int count)
 {
-   struct keyspan_port_private *p_priv;
+   struct keyspan_port_private *p_priv;
const struct keyspan_device_details *d_details;
int flip;
-   int left, todo;
+   int left, todo;
struct urb  *this_urb;
-   int err, maxDataLen, dataOffset;
+   int err, maxDataLen, dataOffset;
 
p_priv = usb_get_serial_port_data(port);
d_details = p_priv->device_details;
@@ -299,7 +299,7 @@ static void usa26_indat_callback(struct urb *urb)
int endpoint;
struct usb_serial_port  *port;
struct tty_struct   *tty;
-   unsigned char   *data = urb->transfer_buffer;
+   unsigned char   *data = urb->transfer_buffer;
int status = urb->status;
 
endpoint = usb_pipeendpoint(urb->pipe);
@@ -382,11 +382,11 @@ static void   usa26_outcont_callback(struct urb *urb)
 
 static voidusa26_instat_callback(struct urb *urb)
 {
-   unsigned char   *data = urb->transfer_buffer;
+   unsigned char   *data = urb->transfer_buffer;
struct keyspan_usa26_portStatusMessage  *msg;
struct usb_serial   *serial;
struct usb_serial_port  *port;
-   struct keyspan_port_private *p_priv;
+   struct keyspan_port_private *p_priv;
struct tty_struct   *tty;
int old_dcd_state, err;
int status = urb->status;
@@ -514,11 +514,11 @@ static void   usa28_outcont_callback(struct urb *urb)
 static voidusa28_instat_callback(struct urb *urb)
 {
int err;
-   unsigned char   *data = urb->transfer_buffer;
+   unsigned char   *data = urb->transfer_buffer;
struct keyspan_usa28_portStatusMessage  *msg;
struct usb_serial   *serial;
struct usb_serial_port  *port;
-   struct keyspan_port_private *p_priv;
+   struct keyspan_port_private *p_priv;
struct tty_struct   *tty;
int old_dcd_state;
int status = urb->status;
@@ -602,11 +602,11 @@ static void   usa49_glocont_callback(struct urb *urb)
 static voidusa49_instat_callback(struct urb *urb)
 {
int err;
-   unsigned char   *data = urb->transfer_buffer;
+   unsigned char   *data = urb->transfer_buffer;
struct keyspan_usa49_portStatusMessage  *msg;
struct usb_serial   *serial;
struct usb_serial_port  *port;
-   struct keyspan_port_private *p_priv;
+   struct keyspan_port_private *p_priv;
int old_dcd_state;
int status = urb->status;
 
@@ -670,7 +670,7 @@ static void usa49_indat_callback(struct urb *urb)
int endpoint;
struct usb_serial_port  *port;
struct tty_struct   *tty;
-   unsigned char   *data = urb->transfer_buffer;
+   unsigned char   *data

[GIT PATCH] USB bug fixes for 3.5-rc6

2012-07-11 Thread Greg KH
The following changes since commit 6887a4131da3adaab011613776d865f4bcfb5678:

  Linux 3.5-rc5 (2012-06-30 16:08:57 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/ tags/usb-3.5-rc6

for you to fetch changes up to dbf0e4c7257f8d684ec1a3c919853464293de66e:

  PCI: EHCI: fix crash during suspend on ASUS computers (2012-07-10 09:52:05 
-0700)


USB fixes for 3.5-rc6

Here are a few fixes and new device ids for the 3.5-rc6 tree.

The PCI changes resolve a long-standing issue with resuming some EHCI
controllers.  It has been acked by the PCI maintainer, and he asked for it to
go through my USB tree instead of his.

The xhci patches also resolve a number of reported issues.

Signed-off-by: Greg Kroah-Hartman 


Alan Stern (1):
  PCI: EHCI: fix crash during suspend on ASUS computers

Bjørn Mork (2):
  USB: option: add ZTE MF60
  USB: cdc-wdm: fix lockup on error in wdm_read

Gaosen Zhang (1):
  USB: option: Add MEDIATEK product ids

Greg Kroah-Hartman (1):
  Merge tag 'for-usb-linus-2012-07-02' of 
git://git.kernel.org/.../sarah/xhci into usb-linus

Johan Hovold (1):
  USB: metro-usb: fix tty_flip_buffer_push use

Sarah Sharp (1):
  xhci: Fix hang on back-to-back Set TR Deq Ptr commands.

Stanislaw Ledwon (1):
  usb: Add support for root hub port status CAS

 drivers/pci/pci-driver.c   | 12 
 drivers/pci/pci.c  |  5 -
 drivers/pci/quirks.c   | 26 -
 drivers/usb/class/cdc-wdm.c|  2 ++
 drivers/usb/core/hub.c | 18 +
 drivers/usb/host/xhci-hub.c| 44 --
 drivers/usb/host/xhci-ring.c   | 11 +++
 drivers/usb/host/xhci.h|  6 +-
 drivers/usb/serial/metro-usb.c |  8 
 drivers/usb/serial/option.c| 26 +
 include/linux/pci.h|  2 --
 11 files changed, 104 insertions(+), 56 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] USB: add USB_VENDOR_AND_INTERFACE_INFO() macro

2012-07-11 Thread Greg Kroah-Hartman
On Wed, Jul 11, 2012 at 10:36:46AM +0200, Bjørn Mork wrote:
> Greg Kroah-Hartman  writes:
> > On Tue, Jul 10, 2012 at 06:51:03PM -0300, Gustavo Padovan wrote:
> >
> >> { USB_VENDOR_AND_INTERFACE_INFO(0x0a5c, 0xff, 0x01, 0x01) }
> >
> > Two entries in the cdc_wdm driver can also be converted to use this
> > interface.  Do you want to send a patch doing that, or do you want me to
> > do it?
> 
> Only if you decide to take this change in 3.4 and 3.5.  Those entries
> are gone in 3.6.

Ah, the joys of looking at the wrong branch in git :)

Nevermind...

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V8 1/8] usb: make usb port a real device

2012-07-11 Thread Greg KH
On Wed, Jul 11, 2012 at 07:47:37AM -0400, Sarah Sharp wrote:
> Hi Greg,
> 
> Looks like no one has objected to these patches in a couple days.
> Do you want to queue these up, or should I send you a pull request?

I have already discussed with Lan privately when I will be able to
review these patches next, as he has already contacted me about them.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] OMAP: USB : Fix the EHCI enumeration and core retention issue

2012-07-11 Thread Munegowda, Keshava
On Wed, Jul 11, 2012 at 3:59 PM, Samuel Ortiz  wrote:
> Hi Keshava, Kevin,
>
> On Fri, Jul 06, 2012 at 05:29:00PM +0530, Munegowda, Keshava wrote:
>> Samuel
>>   I have sent that patch to disable the ehci in
>> omap2plus_defconfig; after merging that
>> please merge this patch too. This will fix the crashes in during boot
>> with NFS in beagleXM
> I'm going to apply and push this patch for 3.5, and the defconfig patch can be
> pushed through Tony's tree.
> Kevin, could you please ACK it ?
>
> Cheers,
> Samuel.
>

Thanks Samuel

Kevin,
need your ack for this.
The commit id 354ab8567ae3107a8cbe7228c3181990ba598aac titled
"Fix OMAP EHCI suspend/resume failure (i693)",
is handling the clocks in ehci driver which is not correct,
it will be through the usb host driver ( /mfd/omap-usb_host.c )  exporting
APIs to ehci driver to handler the port clocks.

for now, this patch is necessary to remove the
 commit id 354ab8567ae3107a8cbe7228c3181990ba598aac titled
"Fix OMAP EHCI suspend/resume failure (i693)",

regards
keshava
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/3] arm: omap: hwmod: add new memory resource for usb phy control

2012-07-11 Thread Sergei Shtylyov

Hello.

On 11-07-2012 14:29, Damodar Santhapuri wrote:


From: Ajay Kumar Gupta 



Added usb_ctrl0 and usb_ctrl1 base address as new memory resources
which will be used at am335x musb driver glue layer to turn on or
off builin PHY untill we have a separate system control module
driver.



Signed-off-by: Ajay Kumar Gupta 
Singed-off-by: Damodar Santhapuri 
---
Changes from v0:
Reordered the layout based on Kishon's comment on not using
platform_get_resources_by_name.



  arch/arm/mach-omap2/omap_hwmod_33xx_data.c |   12 
  1 files changed, 12 insertions(+), 0 deletions(-)



diff --git a/arch/arm/mach-omap2/omap_hwmod_33xx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
index df888fe..ec9e9df 100644
--- a/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
@@ -3269,11 +3269,23 @@ static struct omap_hwmod_addr_space 
am33xx_usbss_addr_space[] = {
.flags  = ADDR_TYPE_RT
},
{
+   .name   = "usb_ctrl0",
+   .pa_start   = 0x44E10620,
+   .pa_end = 0x44E10624,


  Not 0x44E10623?


+   .flags  = ADDR_TYPE_RT
+   },
+   {
.name   = "musb1",
.pa_start   = 0x47401800,
.pa_end = 0x47401800 + SZ_2K - 1,
.flags  = ADDR_TYPE_RT
},
+   {
+   .name   = "usb_ctrl1",
+   .pa_start   = 0x44E10628,
+   .pa_end = 0x44E1062c,


   Not 0x44E1062B?

WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: twl6030-usb: variable otg not declared in twl6030_usbotg_irq() in linux-next

2012-07-11 Thread Sergei Shtylyov

Hello.

On 10-07-2012 10:32, Gerard Snitselaar wrote:


commit ff9cce82 added back 2 lines that were removed by commit
c83a8542


   Please also specify the summaries of those 2 commits in parens.


causing build of twl6030-usb to get an error due to otg being
referenced, but not declared. This patch removes those 2 lines again
to restore intent of commit c83a8542.



Signed-off-by: Gerard Snitselaar 


WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: chipidea: cleanup dma_pool if udc_start() fails

2012-07-11 Thread Richard Zhao
From: Marc Kleine-Budde 

If udc_start() fails the qh_pool dma-pool cannot be closed because
it's still in use. This patch factors out the dma_pool_free() loop
into destroy_eps() and calls it in the error path of udc_start(),
too.

Signed-off-by: Marc Kleine-Budde 
Signed-off-by: Richard Zhao 
---
 drivers/usb/chipidea/udc.c |   23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index c7a032a..9029985 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1484,6 +1484,17 @@ static int init_eps(struct ci13xxx *ci)
return retval;
 }
 
+static void destroy_eps(struct ci13xxx *ci)
+{
+   int i;
+
+   for (i = 0; i < ci->hw_ep_max; i++) {
+   struct ci13xxx_ep *mEp = &ci->ci13xxx_ep[i];
+
+   dma_pool_free(ci->qh_pool, mEp->qh.ptr, mEp->qh.dma);
+   }
+}
+
 /**
  * ci13xxx_start: register a gadget driver
  * @gadget: our gadget
@@ -1691,7 +1702,7 @@ static int udc_start(struct ci13xxx *ci)
if (ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
if (ci->transceiver == NULL) {
retval = -ENODEV;
-   goto free_pools;
+   goto destroy_eps;
}
}
 
@@ -1742,6 +1753,8 @@ unreg_device:
 put_transceiver:
if (!IS_ERR_OR_NULL(ci->transceiver) && ci->global_phy)
usb_put_phy(ci->transceiver);
+destroy_eps:
+   destroy_eps(ci);
 free_pools:
dma_pool_destroy(ci->td_pool);
 free_qh_pool:
@@ -1756,18 +1769,12 @@ free_qh_pool:
  */
 static void udc_stop(struct ci13xxx *ci)
 {
-   int i;
-
if (ci == NULL)
return;
 
usb_del_gadget_udc(&ci->gadget);
 
-   for (i = 0; i < ci->hw_ep_max; i++) {
-   struct ci13xxx_ep *mEp = &ci->ci13xxx_ep[i];
-
-   dma_pool_free(ci->qh_pool, mEp->qh.ptr, mEp->qh.dma);
-   }
+   destroy_eps(ci);
 
dma_pool_destroy(ci->td_pool);
dma_pool_destroy(ci->qh_pool);
-- 
1.7.9.5


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC/PATCH] usb: dwc3: Introduce OTG driver for dwc3

2012-07-11 Thread Ido Shayevitz
This is first release of otg driver for the dwc3 Synopsys USB3 core.
The otg driver implements the otg final state machine and control the
activation of the device controller or host controller.

In this first implementation, only simple DRD mode is implemented,
determine if A or B device according to the ID pin as reflected in the
OSTS.ConIDSts field.

Signed-off-by: Ido Shayevitz 

---
 drivers/usb/dwc3/Kconfig |6 +-
 drivers/usb/dwc3/Makefile|2 +
 drivers/usb/dwc3/core.c  |   15 +-
 drivers/usb/dwc3/core.h  |   51 -
 drivers/usb/dwc3/dwc3_otg.c  |  512 ++
 drivers/usb/dwc3/dwc3_otg.h  |   38 +++
 drivers/usb/dwc3/gadget.c|   63 +
 drivers/usb/host/xhci-plat.c |   21 ++
 drivers/usb/host/xhci.c  |   13 +-
 9 files changed, 708 insertions(+), 13 deletions(-)
 create mode 100644 drivers/usb/dwc3/dwc3_otg.c
 create mode 100644 drivers/usb/dwc3/dwc3_otg.h

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index d13c60f..0cc108d 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -1,9 +1,9 @@
 config USB_DWC3
tristate "DesignWare USB3 DRD Core Support"
-   depends on (USB && USB_GADGET)
+   depends on (USB || USB_GADGET)
select USB_OTG_UTILS
-   select USB_GADGET_DUALSPEED
-   select USB_GADGET_SUPERSPEED
+   select USB_GADGET_DUALSPEED if USB_GADGET
+   select USB_GADGET_SUPERSPEED if USB_GADGET
select USB_XHCI_PLATFORM if USB_SUPPORT && USB_XHCI_HCD
help
  Say Y or M here if your system has a Dual Role SuperSpeed
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index d441fe4..ffb3f55 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -1,11 +1,13 @@
 ccflags-$(CONFIG_USB_DWC3_DEBUG)   := -DDEBUG
 ccflags-$(CONFIG_USB_DWC3_VERBOSE) += -DVERBOSE_DEBUG
+ccflags-y += -Idrivers/usb/host
 
 obj-$(CONFIG_USB_DWC3) += dwc3.o
 
 dwc3-y := core.o
 dwc3-y += host.o
 dwc3-y += gadget.o ep0.o
+dwc3-y += dwc3_otg.o
 
 ifneq ($(CONFIG_DEBUG_FS),)
dwc3-y  += debugfs.o
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index c34452a..5343e39 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -517,15 +517,24 @@ static int __devinit dwc3_probe(struct platform_device 
*pdev)
break;
case DWC3_MODE_DRD:
dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
+   ret = dwc3_otg_init(dwc);
+   if (ret) {
+   dev_err(dev, "failed to initialize otg\n");
+   goto err1;
+   }
+
ret = dwc3_host_init(dwc);
if (ret) {
dev_err(dev, "failed to initialize host\n");
+   dwc3_otg_exit(dwc);
goto err1;
}
 
ret = dwc3_gadget_init(dwc);
if (ret) {
dev_err(dev, "failed to initialize gadget\n");
+   dwc3_host_exit(dwc);
+   dwc3_otg_exit(dwc);
goto err1;
}
break;
@@ -554,8 +563,9 @@ err2:
dwc3_host_exit(dwc);
break;
case DWC3_MODE_DRD:
-   dwc3_host_exit(dwc);
dwc3_gadget_exit(dwc);
+   dwc3_host_exit(dwc);
+   dwc3_otg_exit(dwc);
break;
default:
/* do nothing */
@@ -588,8 +598,9 @@ static int __devexit dwc3_remove(struct platform_device 
*pdev)
dwc3_host_exit(dwc);
break;
case DWC3_MODE_DRD:
-   dwc3_host_exit(dwc);
dwc3_gadget_exit(dwc);
+   dwc3_host_exit(dwc);
+   dwc3_otg_exit(dwc);
break;
default:
/* do nothing */
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 151eca8..793758b 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -50,6 +50,8 @@
 #include 
 #include 
 
+#include "dwc3_otg.h"
+
 /* Global constants */
 #define DWC3_EP0_BOUNCE_SIZE   512
 #define DWC3_ENDPOINTS_NUM 32
@@ -152,8 +154,9 @@
 /* OTG Registers */
 #define DWC3_OCFG  0xcc00
 #define DWC3_OCTL  0xcc04
-#define DWC3_OEVTEN0xcc08
-#define DWC3_OSTS  0xcc0C
+#define DWC3_OEVT  0xcc08
+#define DWC3_OEVTEN0xcc0c
+#define DWC3_OSTS  0xcc10
 
 /* Bit fields */
 
@@ -203,6 +206,9 @@
 #define DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(n)   (((n) & (0x0f << 13)) >> 13)
 #define DWC3_MAX_HIBER_SCRATCHBUFS 15
 
+/* Global HWPARAMS6 Register */
+#define DWC3_GHWPARAMS6_SRP_SUPPORT(1 << 10)
+
 /* Device 

Re: [PATCH V8 1/8] usb: make usb port a real device

2012-07-11 Thread Sarah Sharp
Hi Greg,

Looks like no one has objected to these patches in a couple days.
Do you want to queue these up, or should I send you a pull request?

Sarah Sharp

On Sun, Jul 08, 2012 at 10:23:00PM +0800, Lan Tianyu wrote:
> Change since v7: update Documentation/ABI and fix dev_err() show pattern
> 
> Change since v4: remove struct usb_port->udev member since it is not used.
> 
> This patch is to make usb port a real device under usb hub interface.
> Move port_owner to struct usb_port.
> 
> Acked-by: Alan Stern 
> Signed-off-by: Lan Tianyu 
> ---
>  Documentation/ABI/testing/sysfs-bus-usb |7 +++
>  drivers/usb/core/hub.c  |   91 
> +--
>  2 files changed, 82 insertions(+), 16 deletions(-)
> 
> diff --git a/Documentation/ABI/testing/sysfs-bus-usb 
> b/Documentation/ABI/testing/sysfs-bus-usb
> index 6df4e6f..d5bb5be 100644
> --- a/Documentation/ABI/testing/sysfs-bus-usb
> +++ b/Documentation/ABI/testing/sysfs-bus-usb
> @@ -208,3 +208,10 @@ Description:
>   such as ACPI. This file will read either "removable" or
>   "fixed" if the information is available, and "unknown"
>   otherwise.
> +
> +What:/sys/bus/usb/devices/.../(hub interface)/portX
> +Date:July 2012
> +Contact: Lan Tianyu 
> +Description:
> + The /sys/bus/usb/devices/.../(hub interface)/portX
> + is usb port device's sysfs directory.
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index 4cc8dc9..a59e509 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -37,6 +37,11 @@
>  #endif
>  #endif
>  
> +struct usb_port {
> + struct device dev;
> + struct dev_state *port_owner;
> +};
> +
>  struct usb_hub {
>   struct device   *intfdev;   /* the "interface" device */
>   struct usb_device   *hdev;
> @@ -81,7 +86,11 @@ struct usb_hub {
>   u8  indicator[USB_MAXCHILDREN];
>   struct delayed_work leds;
>   struct delayed_work init_work;
> - struct dev_state**port_owners;
> + struct usb_port **ports;
> +};
> +
> +struct device_type usb_port_device_type = {
> + .name = "usb_port",
>  };
>  
>  static inline int hub_is_superspeed(struct usb_device *hdev)
> @@ -154,6 +163,8 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem);
>  #define HUB_DEBOUNCE_STEP  25
>  #define HUB_DEBOUNCE_STABLE   100
>  
> +#define to_usb_port(_dev) \
> + container_of(_dev, struct usb_port, dev)
>  
>  static int usb_reset_and_verify_device(struct usb_device *udev);
>  
> @@ -1220,6 +1231,48 @@ static int hub_post_reset(struct usb_interface *intf)
>   return 0;
>  }
>  
> +static void usb_port_device_release(struct device *dev)
> +{
> + struct usb_port *port_dev = to_usb_port(dev);
> +
> + kfree(port_dev);
> +}
> +
> +static void usb_hub_remove_port_device(struct usb_hub *hub,
> +int port1)
> +{
> + device_unregister(&hub->ports[port1 - 1]->dev);
> +}
> +
> +static int usb_hub_create_port_device(struct usb_hub *hub,
> +   int port1)
> +{
> + struct usb_port *port_dev = NULL;
> + int retval;
> +
> + port_dev = kzalloc(sizeof(*port_dev), GFP_KERNEL);
> + if (!port_dev) {
> + retval = -ENOMEM;
> + goto exit;
> + }
> +
> + hub->ports[port1 - 1] = port_dev;
> + port_dev->dev.parent = hub->intfdev;
> + port_dev->dev.type = &usb_port_device_type;
> + port_dev->dev.release = usb_port_device_release;
> + dev_set_name(&port_dev->dev, "port%d", port1);
> +
> + retval = device_register(&port_dev->dev);
> + if (retval)
> + goto error_register;
> + return 0;
> +
> +error_register:
> + put_device(&port_dev->dev);
> +exit:
> + return retval;
> +}
> +
>  static int hub_configure(struct usb_hub *hub,
>   struct usb_endpoint_descriptor *endpoint)
>  {
> @@ -1229,7 +1282,7 @@ static int hub_configure(struct usb_hub *hub,
>   u16 hubstatus, hubchange;
>   u16 wHubCharacteristics;
>   unsigned int pipe;
> - int maxp, ret;
> + int maxp, ret, i;
>   char *message = "out of memory";
>  
>   hub->buffer = kmalloc(sizeof(*hub->buffer), GFP_KERNEL);
> @@ -1271,9 +1324,9 @@ static int hub_configure(struct usb_hub *hub,
>  
>   hdev->children = kzalloc(hdev->maxchild *
>   sizeof(struct usb_device *), GFP_KERNEL);
> - hub->port_owners = kzalloc(hdev->maxchild * sizeof(struct dev_state *),
> - GFP_KERNEL);
> - if (!hdev->children || !hub->port_owners) {
> + hub->ports = kzalloc(hdev->maxchild * sizeof(struct usb_port *),
> +  GFP_KERNEL);
> + if (!hdev->children || !hub->ports) {
>   ret = -ENOMEM;
>   goto fail;
>   }
> @@ -1482,6 +1535,11 @@ static int hub_configure(struct usb_hub *hub,
>   if

Re: usb sound issue - any ideas?

2012-07-11 Thread Sarah Sharp
On Wed, Jul 11, 2012 at 11:04:05AM +0800, Andiry Xu wrote:
> On 07/11/2012 03:37 AM, Dr. Ing. Dieter Jurzitza wrote:
> >Dear listmembers,
> >dear Sarah, dear Andiry,
> >Andiry's suggestion (uncomment the return 0 - statement) fixed my issue, the
> >usb soundcard remains active after a login-logout; however, as I understood
> >Sarah's comment this is no more than a plaster on the problem.
> >
> >So, I am willing to do more testing - but I depend on your inputs as I am
> >lacking the required programming skills to actually understand what's
> >happening within the driver.
> >
> >Please let me know what you'd suggest to do next ...
> >
> >Thank you very much,
> >take care
> >
> >
> 
> Hi Dieter,
> 
> Thanks for the test.
> 
> Sarah,
> 
> I don't know why you regard it as an invalid fix and think the
> disabled endpoint is abnormal.

All endpoints should go into the enabled state when the USB core changes
the alternate interface setting.

A disabled endpoint means the xHCI driver has never enabled an endpoint,
which AFAICT could only happen if the USB core thinks one alternate
interface is installed, but the xHCI hardware thinks another alternate
interface is installed.

So I'm concerned that there is a deeper issue here, namely that the USB
core is attempting to drop an endpoint that was never part of the
alternate interface setting that was originally installed.

Or perhaps the host controller simply erroneously never moves the
endpoint to the enabled state after the Configure Endpoint command.

Either way, I would like to know why we're seeing the disabled endpoint,
which is why I would like to see full dmesg from the time the device is
plugged in, with both CONFIG_USB_DEBUG and CONFIG_USB_XHCI_HCD_DEBUGGING
turned on.

> See xHCI spec 4.6.6:
> 
> ==
> For each endpoint indicated by a Drop Context flag = '1':
> 
>   If the Output Endpoint Context is not in the Disabled state:
>   The endpoint related resources are subtracted from the  Resource
> Required variable.
>   If the endpoint is periodic, then the bandwidth assigned to the
> endpoint is subtracted from the bandwidth Required variable.
> 
>   else // Output Endpoint Context is in the Disabled state:
>   Do nothing
> ==
> 
> 
> Please note this is host controller behavior description, so "Do
> nothing" means the host will do nothing with a Disabled endpoint
> with drop flag = 1. It does not mean software should ignore the drop
> request and return -EINVAL for SET_INTERFACE request.
> 
> And - Spec says what it should do with Disabled endpoint situation,
> that implies the situation is expected - and also valid.

Valid, but troubling.

Sarah Sharp
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/7] USB: Add a sysfs file to show LTM capabilities.

2012-07-11 Thread Sarah Sharp
USB 3.0 devices can optionally support Latency Tolerance Messaging
(LTM).  Add a new sysfs file in the device directory to show whether a
device is LTM capable.  This file will be present for both USB 2.0 and
USB 3.0 devices.

Signed-off-by: Sarah Sharp 
---
 Documentation/ABI/testing/sysfs-bus-usb |   12 
 drivers/usb/core/hub.c  |7 ---
 drivers/usb/core/sysfs.c|   10 ++
 include/linux/usb.h |8 
 4 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-usb 
b/Documentation/ABI/testing/sysfs-bus-usb
index 6df4e6f..5f75f8f 100644
--- a/Documentation/ABI/testing/sysfs-bus-usb
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -208,3 +208,15 @@ Description:
such as ACPI. This file will read either "removable" or
"fixed" if the information is available, and "unknown"
otherwise.
+
+What:  /sys/bus/usb/devices/.../ltm_capable
+Date:  July 2012
+Contact:   Sarah Sharp 
+Description:
+   USB 3.0 devices may optionally support Latency Tolerance
+   Messaging (LTM).  They indicate their support by setting a bit
+   in the bmAttributes field of their SuperSpeed BOS descriptors.
+   If that bit is set for the device, ltm_capable will read "yes".
+   If the device doesn't support LTM, the file will read "no".
+   The file will be present for all speeds of USB devices, and will
+   always read "no" for USB 1.1 and USB 2.0 devices.
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index b5bd6bd..d739f96 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2610,13 +2610,6 @@ static int check_port_resume_type(struct usb_device 
*udev,
return status;
 }
 
-static bool usb_device_supports_ltm(struct usb_device *udev)
-{
-   if (udev->speed != USB_SPEED_SUPER || !udev->bos || !udev->bos->ss_cap)
-   return false;
-   return udev->bos->ss_cap->bmAttributes & USB_LTM_SUPPORT;
-}
-
 int usb_disable_ltm(struct usb_device *udev)
 {
struct usb_hcd *hcd = bus_to_hcd(udev->bus);
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 777f03c..682e825 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -253,6 +253,15 @@ show_removable(struct device *dev, struct device_attribute 
*attr, char *buf)
 }
 static DEVICE_ATTR(removable, S_IRUGO, show_removable, NULL);
 
+static ssize_t
+show_ltm_capable(struct device *dev, struct device_attribute *attr, char *buf)
+{
+   if (usb_device_supports_ltm(to_usb_device(dev)))
+   return sprintf(buf, "%s\n", "yes");
+   return sprintf(buf, "%s\n", "no");
+}
+static DEVICE_ATTR(ltm_capable, S_IRUGO, show_ltm_capable, NULL);
+
 #ifdef CONFIG_PM
 
 static ssize_t
@@ -649,6 +658,7 @@ static struct attribute *dev_attrs[] = {
&dev_attr_authorized.attr,
&dev_attr_remove.attr,
&dev_attr_removable.attr,
+   &dev_attr_ltm_capable.attr,
NULL,
 };
 static struct attribute_group dev_attr_grp = {
diff --git a/include/linux/usb.h b/include/linux/usb.h
index f29831b..f8506ed 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -636,6 +636,14 @@ extern void usb_unlocked_enable_lpm(struct usb_device 
*udev);
 extern int usb_disable_ltm(struct usb_device *udev);
 extern void usb_enable_ltm(struct usb_device *udev);
 
+static inline bool usb_device_supports_ltm(struct usb_device *udev)
+{
+   if (udev->speed != USB_SPEED_SUPER || !udev->bos || !udev->bos->ss_cap)
+   return false;
+   return udev->bos->ss_cap->bmAttributes & USB_LTM_SUPPORT;
+}
+
+
 /*-*/
 
 /* for drivers using iso endpoints */
-- 
1.7.9

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/7] USB: Enable Latency Tolerance Messaging (LTM).

2012-07-11 Thread Sarah Sharp
USB 3.0 devices may optionally support a new feature called Latency
Tolerance Messaging.  If both the xHCI host controller and the device
support LTM, it should be turned on in order to give the system hardware
a better clue about the latency tolerance values of its PCI devices.

Once a Set Feature request to enable LTM is received, the USB 3.0 device
will begin to send LTM updates as its buffers fill or empty, and it can
tolerate more or less latency.

The USB 3.0 spec, section C.4.2 says that LTM should be disabled just
before the device is placed into suspend.  Then the device will send an
updated LTM notification, so that the system doesn't think it should
remain in an active state in order to satisfy the latency requirements
of the suspended device.

The Set and Clear Feature LTM enable command can only be sent to a
configured device.  The device will respond with an error if that
command is sent while it is in the Default or Addressed state.  Make
sure to check udev->actconfig in usb_enable_ltm() and usb_disable_ltm(),
and don't send those commands when the device is unconfigured.

LTM should be enabled once a new configuration is installed in
usb_set_configuration().  If we end up sending duplicate Set Feature LTM
Enable commands on a switch from one installed configuration to another
configuration, that should be harmless.

Make sure that LTM is disabled before the device is unconfigured in
usb_disable_device().  If no drivers are bound to the device, it doesn't
make sense to allow the device to control the latency tolerance of the
xHCI host controller.

Signed-off-by: Sarah Sharp 
---
 drivers/usb/core/hub.c |   87 +---
 drivers/usb/core/message.c |3 ++
 include/linux/usb.h|3 ++
 3 files changed, 87 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 5c31d2c..b5bd6bd 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2610,6 +2610,57 @@ static int check_port_resume_type(struct usb_device 
*udev,
return status;
 }
 
+static bool usb_device_supports_ltm(struct usb_device *udev)
+{
+   if (udev->speed != USB_SPEED_SUPER || !udev->bos || !udev->bos->ss_cap)
+   return false;
+   return udev->bos->ss_cap->bmAttributes & USB_LTM_SUPPORT;
+}
+
+int usb_disable_ltm(struct usb_device *udev)
+{
+   struct usb_hcd *hcd = bus_to_hcd(udev->bus);
+
+   /* Check if the roothub and device supports LTM. */
+   if (!usb_device_supports_ltm(hcd->self.root_hub) ||
+   !usb_device_supports_ltm(udev))
+   return 0;
+
+   /* Clear Feature LTM Enable can only be sent if the device is
+* configured.
+*/
+   if (!udev->actconfig)
+   return 0;
+
+   return usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
+   USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE,
+   USB_DEVICE_LTM_ENABLE, 0, NULL, 0,
+   USB_CTRL_SET_TIMEOUT);
+}
+EXPORT_SYMBOL_GPL(usb_disable_ltm);
+
+void usb_enable_ltm(struct usb_device *udev)
+{
+   struct usb_hcd *hcd = bus_to_hcd(udev->bus);
+
+   /* Check if the roothub and device supports LTM. */
+   if (!usb_device_supports_ltm(hcd->self.root_hub) ||
+   !usb_device_supports_ltm(udev))
+   return;
+
+   /* Set Feature LTM Enable can only be sent if the device is
+* configured.
+*/
+   if (!udev->actconfig)
+   return;
+
+   usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
+   USB_REQ_SET_FEATURE, USB_RECIP_DEVICE,
+   USB_DEVICE_LTM_ENABLE, 0, NULL, 0,
+   USB_CTRL_SET_TIMEOUT);
+}
+EXPORT_SYMBOL_GPL(usb_enable_ltm);
+
 #ifdef CONFIG_USB_SUSPEND
 
 /*
@@ -2705,6 +2756,11 @@ int usb_port_suspend(struct usb_device *udev, 
pm_message_t msg)
if (udev->usb2_hw_lpm_enabled == 1)
usb_set_usb2_hardware_lpm(udev, 0);
 
+   if (usb_disable_ltm(udev)) {
+   dev_err(&udev->dev, "%s Failed to disable LTM before 
suspend\n.",
+   __func__);
+   return -ENOMEM;
+   }
if (usb_unlocked_disable_lpm(udev)) {
dev_err(&udev->dev, "%s Failed to disable LPM before 
suspend\n.",
__func__);
@@ -2734,7 +2790,8 @@ int usb_port_suspend(struct usb_device *udev, 
pm_message_t msg)
if (udev->usb2_hw_lpm_capable == 1)
usb_set_usb2_hardware_lpm(udev, 1);
 
-   /* Try to enable USB3 LPM again */
+   /* Try to enable USB3 LTM and LPM again */
+   usb_enable_ltm(udev);
usb_unlocked_enable_lpm(udev);
 
/* System sleep transitions should never fail */
@@ -2935,7 +2992,8 @@ int usb_port_resume(struct usb_device *udev, pm_message_t 
msg)
if (udev->usb2_hw_lpm_cap

[PATCH 5/7] xhci: Export Latency Tolerance Messaging capabilities.

2012-07-11 Thread Sarah Sharp
Some xHCI host controllers may have optional support for Latency
Tolerance Messaging (LTM).  This allows USB 3.0 devices that support LTM
to pass information about how much latency they can tolerate to the xHC.
A PCI xHCI host will use this information to update the PCI Latency
Tolerance Request (LTR) info.  The goal of this is to gather latency
information for the system, to enable hardware-driven C states, and the
shutting down of PLLs.

Signed-off-by: Sarah Sharp 
---
 drivers/usb/host/xhci-hub.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 2732ef6..6d21030 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -508,12 +508,18 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, 
u16 wValue,
if (hcd->speed != HCD_USB3)
goto error;
 
+   /* Set the U1 and U2 exit latencies. */
memcpy(buf, &usb_bos_descriptor,
USB_DT_BOS_SIZE + USB_DT_USB_SS_CAP_SIZE);
temp = xhci_readl(xhci, &xhci->cap_regs->hcs_params3);
buf[12] = HCS_U1_LATENCY(temp);
put_unaligned_le16(HCS_U2_LATENCY(temp), &buf[13]);
 
+   /* Indicate whether the host has LTM support. */
+   temp = xhci_readl(xhci, &xhci->cap_regs->hcc_params);
+   if (HCC_LTC(temp))
+   buf[8] |= USB_LTM_SUPPORT;
+
spin_unlock_irqrestore(&xhci->lock, flags);
return USB_DT_BOS_SIZE + USB_DT_USB_SS_CAP_SIZE;
case GetPortStatus:
-- 
1.7.9

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/7] USB: Remove unused LPM variable.

2012-07-11 Thread Sarah Sharp
hub_initiated_lpm_disable_count is not used by any code, so remove it.

This commit should be backported to kernels as old as 3.5, that contain
the commit 8306095fd2c1100e8244c09bf560f97aca5a311d "USB: Disable USB
3.0 LPM in critical sections."

Signed-off-by: Sarah Sharp 
Cc: sta...@vger.kernel.org
---
 include/linux/usb.h |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/include/linux/usb.h b/include/linux/usb.h
index d4f9de1..dea2f0d 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -561,7 +561,6 @@ struct usb_device {
struct usb3_lpm_parameters u1_params;
struct usb3_lpm_parameters u2_params;
unsigned lpm_disable_count;
-   unsigned hub_initiated_lpm_disable_count;
 };
 #defineto_usb_device(d) container_of(d, struct usb_device, dev)
 
-- 
1.7.9

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/7] USB: Fix LPM disable count mismatch on driver unbind.

2012-07-11 Thread Sarah Sharp
When a user runs `echo 0 > bConfigurationValue` for a USB 3.0 device,
usb_disable_device() is called.  This function disables all drivers,
deallocates interfaces, and sets the device configuration value to 0
(unconfigured).

With the new scheme to ensure that unconfigured devices have LPM
disabled, usb_disable_device() must call usb_unlocked_disable_lpm() once
it unconfigures the device.

This commit should be backported to kernels as old as 3.5, that contain
the commit 8306095fd2c1100e8244c09bf560f97aca5a311d "USB: Disable USB
3.0 LPM in critical sections."

Signed-off-by: Sarah Sharp 
Cc: sta...@vger.kernel.org
---
 drivers/usb/core/message.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 3723904..c0877b7 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1174,6 +1174,7 @@ void usb_disable_device(struct usb_device *dev, int 
skip_ep0)
put_device(&dev->actconfig->interface[i]->dev);
dev->actconfig->interface[i] = NULL;
}
+   usb_unlocked_disable_lpm(dev);
dev->actconfig = NULL;
if (dev->state == USB_STATE_CONFIGURED)
usb_set_device_state(dev, USB_STATE_ADDRESS);
-- 
1.7.9

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/7] USB: Disable LPM while the device is unconfigured.

2012-07-11 Thread Sarah Sharp
The USB 3.0 Set/Clear Feature U1/U2 Enable cannot be sent to a device in
the Default or Addressed state.  It can only be sent to a configured
device.  Change the USB core to initialize the LPM disable count to 1
(disabled), which reflects this limitation.

Change usb_set_configuration() to ensure that if the device is
unconfigured on entry, usb_lpm_disable() is not called.  This avoids
sending the Clear Feature U1/U2 when the device is in the Addressed
state.  When usb_set_configuration() exits with a successfully installed
configuration, usb_lpm_enable() will be called.

Once the new configuration is installed, make sure
usb_set_configuration() only calls usb_enable_lpm() if the device moved
to the Configured state.  If we have unconfigured the device by sending
it a Set Configuration for config 0, don't enable LPM.

This commit should be backported to kernels as old as 3.5, that contain
the commit 8306095fd2c1100e8244c09bf560f97aca5a311d "USB: Disable USB
3.0 LPM in critical sections."

Signed-off-by: Sarah Sharp 
Cc: sta...@vger.kernel.org
---
 drivers/usb/core/message.c |7 ---
 drivers/usb/core/usb.c |1 +
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 8b9d669..3723904 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1792,14 +1792,15 @@ free_interfaces:
 * installed, so that the xHCI driver can recalculate the U1/U2
 * timeouts.
 */
-   if (usb_disable_lpm(dev)) {
+   if (dev->actconfig && usb_disable_lpm(dev)) {
dev_err(&dev->dev, "%s Failed to disable LPM\n.", __func__);
mutex_unlock(hcd->bandwidth_mutex);
return -ENOMEM;
}
ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL);
if (ret < 0) {
-   usb_enable_lpm(dev);
+   if (dev->actconfig)
+   usb_enable_lpm(dev);
mutex_unlock(hcd->bandwidth_mutex);
usb_autosuspend_device(dev);
goto free_interfaces;
@@ -1819,7 +1820,7 @@ free_interfaces:
if (!cp) {
usb_set_device_state(dev, USB_STATE_ADDRESS);
usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
-   usb_enable_lpm(dev);
+   /* Leave LPM disabled while the device is unconfigured. */
mutex_unlock(hcd->bandwidth_mutex);
usb_autosuspend_device(dev);
goto free_interfaces;
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 25d0c61..cd8fb44 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -396,6 +396,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
dev->dev.dma_mask = bus->controller->dma_mask;
set_dev_node(&dev->dev, dev_to_node(bus->controller));
dev->state = USB_STATE_ATTACHED;
+   dev->lpm_disable_count = 1;
atomic_set(&dev->urbnum, 0);
 
INIT_LIST_HEAD(&dev->ep0.urb_list);
-- 
1.7.9

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Pull Request] LPM fixes and LTM patches for 3.6

2012-07-11 Thread Sarah Sharp
The following changes since commit 1a49e2ac9651df7349867a5cf44e2c83de1046af:

  EHCI: centralize controller initialization (2012-07-09 13:35:05 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci.git 
for-usb-next-2012-07-11

for you to fetch changes up to 024f117c2f3c4bb5df6e6696b709e0f3ed7e5dbb:

  USB: Add a sysfs file to show LTM capabilities. (2012-07-11 07:06:48 -0400)


USB: Link PM fixes and Latency Tolerance Messaging

Hi Greg,

Here's four bug fix patches for Link PM (LPM), which are marked for
3.5-stable.  There's also three patches that turn on Latency Tolerance
Messaging (LTM) for xHCI host controllers and USB 3.0 devices that support
this low power feature.

Please queue for 3.6.

Sarah Sharp


Sarah Sharp (7):
  USB: Fix LPM disable/enable during device reset.
  USB: Disable LPM while the device is unconfigured.
  USB: Fix LPM disable count mismatch on driver unbind.
  USB: Remove unused LPM variable.
  xhci: Export Latency Tolerance Messaging capabilities.
  USB: Enable Latency Tolerance Messaging (LTM).
  USB: Add a sysfs file to show LTM capabilities.

 Documentation/ABI/testing/sysfs-bus-usb |   12 
 drivers/usb/core/hub.c  |  100 +-
 drivers/usb/core/message.c  |   11 +++-
 drivers/usb/core/sysfs.c|   10 +++
 drivers/usb/core/usb.c  |1 +
 drivers/usb/host/xhci-hub.c |6 ++
 include/linux/usb.h |   12 -
 7 files changed, 131 insertions(+), 21 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/7] USB: Fix LPM disable/enable during device reset.

2012-07-11 Thread Sarah Sharp
The USB 3.0 specification says that sending a Set Feature or Clear
Feature for U1/U2 Enable is not a valid request when the device is in
the Default or Addressed state.  It is only valid when the device is in
the Configured state.

The original LPM patch attempted to disable LPM after the device had
been reset by hub_port_init(), before it had the configuration
reinstalled.  The TI hub I tested with did not fail the Clear Feature
U1/U2 Enable request that khubd sent while it was in the addressed
state, which is why I didn't catch it.

Move the LPM disable before the device reset, so that we can send the
Clear Feature U1/U2 Enable successfully, and balance the LPM disable
count.

Also delete any calls to usb_enable_lpm() on error paths that lead to
re-enumeration.  The calls will fail because the device isn't
configured, and it's not useful to balance the LPM disable count because
the usb_device is about to be destroyed before re-enumeration.

Fix the early exit path ("done" label) to call usb_enable_lpm() to
balance the LPM disable count.

Note that calling usb_reset_and_verify_device() with an unconfigured
device may fail on the first call to usb_disable_lpm().  That's because
the LPM disable count is initialized to 0 (LPM enabled), and
usb_disable_lpm() will attempt to send a Clear Feature U1/U2 request to
a device in the Addressed state.  The next patch will fix that.

This commit should be backported to kernels as old as 3.5, that contain
the commit 8306095fd2c1100e8244c09bf560f97aca5a311d "USB: Disable USB
3.0 LPM in critical sections."

Signed-off-by: Sarah Sharp 
Cc: sta...@vger.kernel.org
---
 drivers/usb/core/hub.c |   26 --
 1 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 4cc8dc9..5c31d2c 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4673,6 +4673,16 @@ static int usb_reset_and_verify_device(struct usb_device 
*udev)
}
parent_hub = hdev_to_hub(parent_hdev);
 
+   /* Disable LPM while we reset the device and reinstall the alt settings.
+* Device-initiated LPM settings, and system exit latency settings are
+* cleared when the device is reset, so we have to set them up again.
+*/
+   ret = usb_unlocked_disable_lpm(udev);
+   if (ret) {
+   dev_err(&udev->dev, "%s Failed to disable LPM\n.", __func__);
+   goto re_enumerate;
+   }
+
set_bit(port1, parent_hub->busy_bits);
for (i = 0; i < SET_CONFIG_TRIES; ++i) {
 
@@ -4700,22 +4710,11 @@ static int usb_reset_and_verify_device(struct 
usb_device *udev)
goto done;
 
mutex_lock(hcd->bandwidth_mutex);
-   /* Disable LPM while we reset the device and reinstall the alt settings.
-* Device-initiated LPM settings, and system exit latency settings are
-* cleared when the device is reset, so we have to set them up again.
-*/
-   ret = usb_disable_lpm(udev);
-   if (ret) {
-   dev_err(&udev->dev, "%s Failed to disable LPM\n.", __func__);
-   mutex_unlock(hcd->bandwidth_mutex);
-   goto done;
-   }
ret = usb_hcd_alloc_bandwidth(udev, udev->actconfig, NULL, NULL);
if (ret < 0) {
dev_warn(&udev->dev,
"Busted HC?  Not enough HCD resources for "
"old configuration.\n");
-   usb_enable_lpm(udev);
mutex_unlock(hcd->bandwidth_mutex);
goto re_enumerate;
}
@@ -4727,7 +4726,6 @@ static int usb_reset_and_verify_device(struct usb_device 
*udev)
dev_err(&udev->dev,
"can't restore configuration #%d (error=%d)\n",
udev->actconfig->desc.bConfigurationValue, ret);
-   usb_enable_lpm(udev);
mutex_unlock(hcd->bandwidth_mutex);
goto re_enumerate;
}
@@ -4766,17 +4764,17 @@ static int usb_reset_and_verify_device(struct 
usb_device *udev)
desc->bInterfaceNumber,
desc->bAlternateSetting,
ret);
-   usb_unlocked_enable_lpm(udev);
goto re_enumerate;
}
}
 
+done:
/* Now that the alt settings are re-installed, enable LPM. */
usb_unlocked_enable_lpm(udev);
-done:
return 0;
  
 re_enumerate:
+   /* LPM state doesn't matter when we're about to destroy the device. */
hub_port_logical_disconnect(parent_hub, port1);
return -ENODEV;
 }
-- 
1.7.9

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH v2 2/3] usb: musb: dsps: add phy control logic to glue

2012-07-11 Thread Gupta, Ajay Kumar
Hi,
> On Wed, Jul 11, 2012 at 3:59 PM, Damodar Santhapuri 
> wrote:
> > From: Ajay Kumar Gupta 
> >
> > AM335x uses NOP transceiver driver and need to enable builtin PHY
> > by writing into usb_ctrl register available in system control
> > module register space. This is being added at musb glue driver
> > layer untill a separate system control module driver is available.
> >
> > Signed-off-by: Ajay Kumar Gupta 
> > Signed-off-by: Damodar Santhapuri 
> > ---
> > Changes from v0:
> > - Used platform_get_resource() instead of
> platform_get_resource_byname()
> > based on Kishon's comment.
> >
> >  arch/arm/mach-omap2/board-ti8168evm.c   |1 -
> >  arch/arm/mach-omap2/omap_phy_internal.c |   35 
> >  arch/arm/plat-omap/include/plat/usb.h   |5 +-
> >  drivers/usb/musb/musb_dsps.c|   87
> +--
> >  4 files changed, 73 insertions(+), 55 deletions(-)
> >
> > diff --git a/arch/arm/mach-omap2/board-ti8168evm.c b/arch/arm/mach-
> omap2/board-ti8168evm.c
> > index d4c8392..0c7c098 100644
> > --- a/arch/arm/mach-omap2/board-ti8168evm.c
> > +++ b/arch/arm/mach-omap2/board-ti8168evm.c
> > @@ -26,7 +26,6 @@
> >  #include 
> >
> >  static struct omap_musb_board_data musb_board_data = {
> > -   .set_phy_power  = ti81xx_musb_phy_power,
> > .interface_type = MUSB_INTERFACE_ULPI,
> > .mode   = MUSB_OTG,
> > .power  = 500,
> > diff --git a/arch/arm/mach-omap2/omap_phy_internal.c b/arch/arm/mach-
> omap2/omap_phy_internal.c
> > index d52651a..d80bb16 100644
> > --- a/arch/arm/mach-omap2/omap_phy_internal.c
> > +++ b/arch/arm/mach-omap2/omap_phy_internal.c
> > @@ -254,38 +254,3 @@ void am35x_set_mode(u8 musb_mode)
> >
> > omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
> >  }
> > -
> > -void ti81xx_musb_phy_power(u8 on)
> > -{
> > -   void __iomem *scm_base = NULL;
> > -   u32 usbphycfg;
> > -
> > -   scm_base = ioremap(TI81XX_SCM_BASE, SZ_2K);
> > -   if (!scm_base) {
> > -   pr_err("system control module ioremap failed\n");
> > -   return;
> > -   }
> > -
> > -   usbphycfg = __raw_readl(scm_base + USBCTRL0);
> > -
> > -   if (on) {
> > -   if (cpu_is_ti816x()) {
> > -   usbphycfg |= TI816X_USBPHY0_NORMAL_MODE;
> > -   usbphycfg &= ~TI816X_USBPHY_REFCLK_OSC;
> > -   } else if (cpu_is_ti814x()) {
> > -   usbphycfg &= ~(USBPHY_CM_PWRDN |
> USBPHY_OTG_PWRDN
> > -   | USBPHY_DPINPUT | USBPHY_DMINPUT);
> > -   usbphycfg |= (USBPHY_OTGVDET_EN |
> USBPHY_OTGSESSEND_EN
> > -   | USBPHY_DPOPBUFCTL |
> USBPHY_DMOPBUFCTL);
> > -   }
> > -   } else {
> > -   if (cpu_is_ti816x())
> > -   usbphycfg &= ~TI816X_USBPHY0_NORMAL_MODE;
> > -   else if (cpu_is_ti814x())
> > -   usbphycfg |= USBPHY_CM_PWRDN |
> USBPHY_OTG_PWRDN;
> > -
> > -   }
> > -   __raw_writel(usbphycfg, scm_base + USBCTRL0);
> > -
> > -   iounmap(scm_base);
> > -}
> > diff --git a/arch/arm/plat-omap/include/plat/usb.h b/arch/arm/plat-
> omap/include/plat/usb.h
> > index 548a4c8..c2aa4ae 100644
> > --- a/arch/arm/plat-omap/include/plat/usb.h
> > +++ b/arch/arm/plat-omap/include/plat/usb.h
> > @@ -95,7 +95,6 @@ extern void am35x_musb_reset(void);
> >  extern void am35x_musb_phy_power(u8 on);
> >  extern void am35x_musb_clear_irq(void);
> >  extern void am35x_set_mode(u8 musb_mode);
> > -extern void ti81xx_musb_phy_power(u8 on);
> >
> >  /* AM35x */
> >  /* USB 2.0 PHY Control */
> > @@ -120,8 +119,8 @@ extern void ti81xx_musb_phy_power(u8 on);
> >  #define CONF2_DATPOL   (1 << 1)
> >
> >  /* TI81XX specific definitions */
> > -#define USBCTRL0   0x620
> > -#define USBSTAT0   0x624
> > +#define MUSB_USBSS_REV_816X0x9
> > +#define MUSB_USBSS_REV_814X0xb
> >
> >  /* TI816X PHY controls bits */
> >  #define TI816X_USBPHY0_NORMAL_MODE (1 << 0)
> > diff --git a/drivers/usb/musb/musb_dsps.c
> b/drivers/usb/musb/musb_dsps.c
> > index 494772f..72eda64 100644
> > --- a/drivers/usb/musb/musb_dsps.c
> > +++ b/drivers/usb/musb/musb_dsps.c
> > @@ -115,9 +115,46 @@ struct dsps_glue {
> > struct platform_device *musb;   /* child musb pdev */
> > const struct dsps_musb_wrapper *wrp; /* wrapper register
> offsets */
> > struct timer_list timer;/* otg_workaround timer */
> > +   u32 __iomem *usb_ctrl;
> > +   u8  usbss_rev;
> >  };
> >
> >  /**
> > + * musb_dsps_phy_control - phy on/off
> > + * @glue: struct dsps_glue *
> > + * @on: flag for phy to be switched on or off
> > + *
> > + * This is to enable the PHY using usb_ctrl register in system
> control
> > + * module space.
> > + *
> > + * XXX: This function will be removed once we have a seperate driver
> for
> > + * control module
> > + */
> > +static voi

Re: [PATCH v2 2/3] usb: musb: dsps: add phy control logic to glue

2012-07-11 Thread ABRAHAM, KISHON VIJAY
Hi,

On Wed, Jul 11, 2012 at 3:59 PM, Damodar Santhapuri  wrote:
> From: Ajay Kumar Gupta 
>
> AM335x uses NOP transceiver driver and need to enable builtin PHY
> by writing into usb_ctrl register available in system control
> module register space. This is being added at musb glue driver
> layer untill a separate system control module driver is available.
>
> Signed-off-by: Ajay Kumar Gupta 
> Signed-off-by: Damodar Santhapuri 
> ---
> Changes from v0:
> - Used platform_get_resource() instead of 
> platform_get_resource_byname()
> based on Kishon's comment.
>
>  arch/arm/mach-omap2/board-ti8168evm.c   |1 -
>  arch/arm/mach-omap2/omap_phy_internal.c |   35 
>  arch/arm/plat-omap/include/plat/usb.h   |5 +-
>  drivers/usb/musb/musb_dsps.c|   87 
> +--
>  4 files changed, 73 insertions(+), 55 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/board-ti8168evm.c 
> b/arch/arm/mach-omap2/board-ti8168evm.c
> index d4c8392..0c7c098 100644
> --- a/arch/arm/mach-omap2/board-ti8168evm.c
> +++ b/arch/arm/mach-omap2/board-ti8168evm.c
> @@ -26,7 +26,6 @@
>  #include 
>
>  static struct omap_musb_board_data musb_board_data = {
> -   .set_phy_power  = ti81xx_musb_phy_power,
> .interface_type = MUSB_INTERFACE_ULPI,
> .mode   = MUSB_OTG,
> .power  = 500,
> diff --git a/arch/arm/mach-omap2/omap_phy_internal.c 
> b/arch/arm/mach-omap2/omap_phy_internal.c
> index d52651a..d80bb16 100644
> --- a/arch/arm/mach-omap2/omap_phy_internal.c
> +++ b/arch/arm/mach-omap2/omap_phy_internal.c
> @@ -254,38 +254,3 @@ void am35x_set_mode(u8 musb_mode)
>
> omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
>  }
> -
> -void ti81xx_musb_phy_power(u8 on)
> -{
> -   void __iomem *scm_base = NULL;
> -   u32 usbphycfg;
> -
> -   scm_base = ioremap(TI81XX_SCM_BASE, SZ_2K);
> -   if (!scm_base) {
> -   pr_err("system control module ioremap failed\n");
> -   return;
> -   }
> -
> -   usbphycfg = __raw_readl(scm_base + USBCTRL0);
> -
> -   if (on) {
> -   if (cpu_is_ti816x()) {
> -   usbphycfg |= TI816X_USBPHY0_NORMAL_MODE;
> -   usbphycfg &= ~TI816X_USBPHY_REFCLK_OSC;
> -   } else if (cpu_is_ti814x()) {
> -   usbphycfg &= ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN
> -   | USBPHY_DPINPUT | USBPHY_DMINPUT);
> -   usbphycfg |= (USBPHY_OTGVDET_EN | USBPHY_OTGSESSEND_EN
> -   | USBPHY_DPOPBUFCTL | USBPHY_DMOPBUFCTL);
> -   }
> -   } else {
> -   if (cpu_is_ti816x())
> -   usbphycfg &= ~TI816X_USBPHY0_NORMAL_MODE;
> -   else if (cpu_is_ti814x())
> -   usbphycfg |= USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN;
> -
> -   }
> -   __raw_writel(usbphycfg, scm_base + USBCTRL0);
> -
> -   iounmap(scm_base);
> -}
> diff --git a/arch/arm/plat-omap/include/plat/usb.h 
> b/arch/arm/plat-omap/include/plat/usb.h
> index 548a4c8..c2aa4ae 100644
> --- a/arch/arm/plat-omap/include/plat/usb.h
> +++ b/arch/arm/plat-omap/include/plat/usb.h
> @@ -95,7 +95,6 @@ extern void am35x_musb_reset(void);
>  extern void am35x_musb_phy_power(u8 on);
>  extern void am35x_musb_clear_irq(void);
>  extern void am35x_set_mode(u8 musb_mode);
> -extern void ti81xx_musb_phy_power(u8 on);
>
>  /* AM35x */
>  /* USB 2.0 PHY Control */
> @@ -120,8 +119,8 @@ extern void ti81xx_musb_phy_power(u8 on);
>  #define CONF2_DATPOL   (1 << 1)
>
>  /* TI81XX specific definitions */
> -#define USBCTRL0   0x620
> -#define USBSTAT0   0x624
> +#define MUSB_USBSS_REV_816X0x9
> +#define MUSB_USBSS_REV_814X0xb
>
>  /* TI816X PHY controls bits */
>  #define TI816X_USBPHY0_NORMAL_MODE (1 << 0)
> diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
> index 494772f..72eda64 100644
> --- a/drivers/usb/musb/musb_dsps.c
> +++ b/drivers/usb/musb/musb_dsps.c
> @@ -115,9 +115,46 @@ struct dsps_glue {
> struct platform_device *musb;   /* child musb pdev */
> const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */
> struct timer_list timer;/* otg_workaround timer */
> +   u32 __iomem *usb_ctrl;
> +   u8  usbss_rev;
>  };
>
>  /**
> + * musb_dsps_phy_control - phy on/off
> + * @glue: struct dsps_glue *
> + * @on: flag for phy to be switched on or off
> + *
> + * This is to enable the PHY using usb_ctrl register in system control
> + * module space.
> + *
> + * XXX: This function will be removed once we have a seperate driver for
> + * control module
> + */
> +static void musb_dsps_phy_control(struct dsps_glue *glue, u8 on)

I think this function should be added in your transceiver driver. I
don't see glue as an appropriate place for this.
> +{
> +   u32 usbphycfg;
> +
> +   usbphycfg = __raw_readl(glue->usb_ctrl);
> +

[PATCH v2 2/3] usb: musb: dsps: add phy control logic to glue

2012-07-11 Thread Damodar Santhapuri
From: Ajay Kumar Gupta 

AM335x uses NOP transceiver driver and need to enable builtin PHY
by writing into usb_ctrl register available in system control
module register space. This is being added at musb glue driver
layer untill a separate system control module driver is available.

Signed-off-by: Ajay Kumar Gupta 
Signed-off-by: Damodar Santhapuri 
---
Changes from v0:
- Used platform_get_resource() instead of platform_get_resource_byname()
based on Kishon's comment.

 arch/arm/mach-omap2/board-ti8168evm.c   |1 -
 arch/arm/mach-omap2/omap_phy_internal.c |   35 
 arch/arm/plat-omap/include/plat/usb.h   |5 +-
 drivers/usb/musb/musb_dsps.c|   87 +--
 4 files changed, 73 insertions(+), 55 deletions(-)

diff --git a/arch/arm/mach-omap2/board-ti8168evm.c 
b/arch/arm/mach-omap2/board-ti8168evm.c
index d4c8392..0c7c098 100644
--- a/arch/arm/mach-omap2/board-ti8168evm.c
+++ b/arch/arm/mach-omap2/board-ti8168evm.c
@@ -26,7 +26,6 @@
 #include 
 
 static struct omap_musb_board_data musb_board_data = {
-   .set_phy_power  = ti81xx_musb_phy_power,
.interface_type = MUSB_INTERFACE_ULPI,
.mode   = MUSB_OTG,
.power  = 500,
diff --git a/arch/arm/mach-omap2/omap_phy_internal.c 
b/arch/arm/mach-omap2/omap_phy_internal.c
index d52651a..d80bb16 100644
--- a/arch/arm/mach-omap2/omap_phy_internal.c
+++ b/arch/arm/mach-omap2/omap_phy_internal.c
@@ -254,38 +254,3 @@ void am35x_set_mode(u8 musb_mode)
 
omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
 }
-
-void ti81xx_musb_phy_power(u8 on)
-{
-   void __iomem *scm_base = NULL;
-   u32 usbphycfg;
-
-   scm_base = ioremap(TI81XX_SCM_BASE, SZ_2K);
-   if (!scm_base) {
-   pr_err("system control module ioremap failed\n");
-   return;
-   }
-
-   usbphycfg = __raw_readl(scm_base + USBCTRL0);
-
-   if (on) {
-   if (cpu_is_ti816x()) {
-   usbphycfg |= TI816X_USBPHY0_NORMAL_MODE;
-   usbphycfg &= ~TI816X_USBPHY_REFCLK_OSC;
-   } else if (cpu_is_ti814x()) {
-   usbphycfg &= ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN
-   | USBPHY_DPINPUT | USBPHY_DMINPUT);
-   usbphycfg |= (USBPHY_OTGVDET_EN | USBPHY_OTGSESSEND_EN
-   | USBPHY_DPOPBUFCTL | USBPHY_DMOPBUFCTL);
-   }
-   } else {
-   if (cpu_is_ti816x())
-   usbphycfg &= ~TI816X_USBPHY0_NORMAL_MODE;
-   else if (cpu_is_ti814x())
-   usbphycfg |= USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN;
-
-   }
-   __raw_writel(usbphycfg, scm_base + USBCTRL0);
-
-   iounmap(scm_base);
-}
diff --git a/arch/arm/plat-omap/include/plat/usb.h 
b/arch/arm/plat-omap/include/plat/usb.h
index 548a4c8..c2aa4ae 100644
--- a/arch/arm/plat-omap/include/plat/usb.h
+++ b/arch/arm/plat-omap/include/plat/usb.h
@@ -95,7 +95,6 @@ extern void am35x_musb_reset(void);
 extern void am35x_musb_phy_power(u8 on);
 extern void am35x_musb_clear_irq(void);
 extern void am35x_set_mode(u8 musb_mode);
-extern void ti81xx_musb_phy_power(u8 on);
 
 /* AM35x */
 /* USB 2.0 PHY Control */
@@ -120,8 +119,8 @@ extern void ti81xx_musb_phy_power(u8 on);
 #define CONF2_DATPOL   (1 << 1)
 
 /* TI81XX specific definitions */
-#define USBCTRL0   0x620
-#define USBSTAT0   0x624
+#define MUSB_USBSS_REV_816X0x9
+#define MUSB_USBSS_REV_814X0xb
 
 /* TI816X PHY controls bits */
 #define TI816X_USBPHY0_NORMAL_MODE (1 << 0)
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 494772f..72eda64 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -115,9 +115,46 @@ struct dsps_glue {
struct platform_device *musb;   /* child musb pdev */
const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */
struct timer_list timer;/* otg_workaround timer */
+   u32 __iomem *usb_ctrl;
+   u8  usbss_rev;
 };
 
 /**
+ * musb_dsps_phy_control - phy on/off
+ * @glue: struct dsps_glue *
+ * @on: flag for phy to be switched on or off
+ *
+ * This is to enable the PHY using usb_ctrl register in system control
+ * module space.
+ *
+ * XXX: This function will be removed once we have a seperate driver for
+ * control module
+ */
+static void musb_dsps_phy_control(struct dsps_glue *glue, u8 on)
+{
+   u32 usbphycfg;
+
+   usbphycfg = __raw_readl(glue->usb_ctrl);
+
+   if (on) {
+   if (glue->usbss_rev == MUSB_USBSS_REV_816X) {
+   usbphycfg |= TI816X_USBPHY0_NORMAL_MODE;
+   usbphycfg &= ~TI816X_USBPHY_REFCLK_OSC;
+   } else if (glue->usbss_rev == MUSB_USBSS_REV_814X) {
+   usbphycfg &= ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN
+   | USBPHY_DPINPUT | USBPHY_DMINPUT);
+   

[PATCH v2 3/3] usb: musb: dsps: enable phy control for am335x

2012-07-11 Thread Damodar Santhapuri
From: Ajay Kumar Gupta 

Enabled the phy control logic for am335x also based on usbss
revision register.

Signed-off-by: Ajay Kumar Gupta 
Signed-off-by: Damodar Santhapuri 
---
 arch/arm/plat-omap/include/plat/usb.h |1 +
 drivers/usb/musb/musb_dsps.c  |   17 +++--
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/usb.h 
b/arch/arm/plat-omap/include/plat/usb.h
index c2aa4ae..6459b10 100644
--- a/arch/arm/plat-omap/include/plat/usb.h
+++ b/arch/arm/plat-omap/include/plat/usb.h
@@ -121,6 +121,7 @@ extern void am35x_set_mode(u8 musb_mode);
 /* TI81XX specific definitions */
 #define MUSB_USBSS_REV_816X0x9
 #define MUSB_USBSS_REV_814X0xb
+#define MUSB_USBSS_REV_33XX0xd
 
 /* TI816X PHY controls bits */
 #define TI816X_USBPHY0_NORMAL_MODE (1 << 0)
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 72eda64..46b07cc 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -140,16 +140,21 @@ static void musb_dsps_phy_control(struct dsps_glue *glue, 
u8 on)
if (glue->usbss_rev == MUSB_USBSS_REV_816X) {
usbphycfg |= TI816X_USBPHY0_NORMAL_MODE;
usbphycfg &= ~TI816X_USBPHY_REFCLK_OSC;
-   } else if (glue->usbss_rev == MUSB_USBSS_REV_814X) {
-   usbphycfg &= ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN
-   | USBPHY_DPINPUT | USBPHY_DMINPUT);
-   usbphycfg |= (USBPHY_OTGVDET_EN | USBPHY_OTGSESSEND_EN
-   | USBPHY_DPOPBUFCTL | USBPHY_DMOPBUFCTL);
+   } else if (glue->usbss_rev == MUSB_USBSS_REV_814X ||
+   glue->usbss_rev == MUSB_USBSS_REV_33XX) {
+   usbphycfg &= ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN);
+   usbphycfg |= USBPHY_OTGVDET_EN | USBPHY_OTGSESSEND_EN;
+   if (glue->usbss_rev == MUSB_USBSS_REV_814X) {
+   usbphycfg &= ~(USBPHY_DPINPUT | USBPHY_DMINPUT);
+   usbphycfg |= USBPHY_DPOPBUFCTL
+   | USBPHY_DMOPBUFCTL;
+   }
}
} else {
if (glue->usbss_rev == MUSB_USBSS_REV_816X)
usbphycfg &= ~TI816X_USBPHY0_NORMAL_MODE;
-   else if (glue->usbss_rev == MUSB_USBSS_REV_814X)
+   else if (glue->usbss_rev == MUSB_USBSS_REV_814X ||
+   glue->usbss_rev == MUSB_USBSS_REV_33XX)
usbphycfg |= USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN;
}
__raw_writel(usbphycfg, glue->usb_ctrl);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/3] arm: omap: hwmod: add new memory resource for usb phy control

2012-07-11 Thread Damodar Santhapuri
From: Ajay Kumar Gupta 

Added usb_ctrl0 and usb_ctrl1 base address as new memory resources
which will be used at am335x musb driver glue layer to turn on or
off builin PHY untill we have a separate system control module
driver.

Signed-off-by: Ajay Kumar Gupta 
Singed-off-by: Damodar Santhapuri 
---
Changes from v0:
Reordered the layout based on Kishon's comment on not using
platform_get_resources_by_name.

 arch/arm/mach-omap2/omap_hwmod_33xx_data.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod_33xx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
index df888fe..ec9e9df 100644
--- a/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
@@ -3269,11 +3269,23 @@ static struct omap_hwmod_addr_space 
am33xx_usbss_addr_space[] = {
.flags  = ADDR_TYPE_RT
},
{
+   .name   = "usb_ctrl0",
+   .pa_start   = 0x44E10620,
+   .pa_end = 0x44E10624,
+   .flags  = ADDR_TYPE_RT
+   },
+   {
.name   = "musb1",
.pa_start   = 0x47401800,
.pa_end = 0x47401800 + SZ_2K - 1,
.flags  = ADDR_TYPE_RT
},
+   {
+   .name   = "usb_ctrl1",
+   .pa_start   = 0x44E10628,
+   .pa_end = 0x44E1062c,
+   .flags  = ADDR_TYPE_RT
+   },
{ }
 };
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] OMAP: USB : Fix the EHCI enumeration and core retention issue

2012-07-11 Thread Samuel Ortiz
Hi Keshava, Kevin,

On Fri, Jul 06, 2012 at 05:29:00PM +0530, Munegowda, Keshava wrote:
> Samuel
>   I have sent that patch to disable the ehci in
> omap2plus_defconfig; after merging that
> please merge this patch too. This will fix the crashes in during boot
> with NFS in beagleXM
I'm going to apply and push this patch for 3.5, and the defconfig patch can be
pushed through Tony's tree.
Kevin, could you please ACK it ?

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFT 2/2] net: qmi_wwan: add ZTE MF821D

2012-07-11 Thread Bjørn Mork
Sold by O2 (telefonica germany) under the name "LTE4G"

Cc: Thomas Schäfer 
Signed-off-by: Bjørn Mork 
---
 drivers/net/usb/qmi_wwan.c |9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 3767a12..e01cbf3 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -494,6 +494,15 @@ static const struct usb_device_id products[] = {
.bInterfaceProtocol = 0xff,
.driver_info= (unsigned long)&qmi_wwan_force_int4,
},
+   {   /* ZTE MF821D */
+   .match_flags= USB_DEVICE_ID_MATCH_DEVICE | 
USB_DEVICE_ID_MATCH_INT_INFO,
+   .idVendor   = 0x19d2,
+   .idProduct  = 0x0326,
+   .bInterfaceClass= 0xff,
+   .bInterfaceSubClass = 0xff,
+   .bInterfaceProtocol = 0xff,
+   .driver_info= (unsigned long)&qmi_wwan_force_int4,
+   },
{   /* Sierra Wireless MC77xx in QMI mode */
.match_flags= USB_DEVICE_ID_MATCH_DEVICE | 
USB_DEVICE_ID_MATCH_INT_INFO,
.idVendor   = 0x1199,
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFT 1/2] USB: option: add ZTE MF821D

2012-07-11 Thread Bjørn Mork
Sold by O2 (telefonica germany) under the name "LTE4G"

Cc: Thomas Schäfer 
Signed-off-by: Bjørn Mork 
---
 drivers/usb/serial/option.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 417ab1b..46cee56 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -936,6 +936,8 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 
0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 
0xff),
  .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
+   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0326, 0xff, 0xff, 
0xff),
+ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 
0xff),
  .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 
0xff),
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: infos about device ZTE MF821D 2G,3G,4G/LTE usb-modem/networkcard

2012-07-11 Thread Bjørn Mork
Hello Thomas,

could you verify these?  They should both apply cleanly to the current mainline 
(v3.5-rc6+).


Bjørn

Bjørn Mork (2):
  USB: option: add ZTE MF821D
  net: qmi_wwan: add ZTE MF821D

 drivers/net/usb/qmi_wwan.c  |9 +
 drivers/usb/serial/option.c |2 ++
 2 files changed, 11 insertions(+)

-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] USB: add USB_VENDOR_AND_INTERFACE_INFO() macro

2012-07-11 Thread Bjørn Mork
Greg Kroah-Hartman  writes:
> On Tue, Jul 10, 2012 at 06:51:03PM -0300, Gustavo Padovan wrote:
>
>> { USB_VENDOR_AND_INTERFACE_INFO(0x0a5c, 0xff, 0x01, 0x01) }
>
> Two entries in the cdc_wdm driver can also be converted to use this
> interface.  Do you want to send a patch doing that, or do you want me to
> do it?

Only if you decide to take this change in 3.4 and 3.5.  Those entries
are gone in 3.6.



Bjørn
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 1/1] Input: xpad - Handle all variations of Mad Catz Beat Pad

2012-07-11 Thread Dmitry Torokhov
On Wed, Jul 11, 2012 at 02:02:19PM +0700, Yuri Khan wrote:
> * Add this device to usbhid ignore list
> 
> Signed-off-by: Yuri Khan 
> Acked-by: Jiri Kosina 

Applied, thank you Yuri.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1] usb: host: Fix possible kernel crash

2012-07-11 Thread Venu Byravarasu

On Tuesday 10 July 2012 08:15 PM, gre...@linuxfoundation.org wrote:

On Tue, Jul 10, 2012 at 09:56:39AM +0530, Venu Byravarasu wrote:

Thanks Alan for your comments.

On Monday 09 July 2012 08:04 PM, Alan Stern wrote:

On Mon, 9 Jul 2012, Venu Byravarasu wrote:


In functions itd_complete &  sitd_complete, a pointer
by name stream may get dereferenced after freeing it, when
iso_stream_put is called with stream->refcount = 2.

I don't understand the problem.  Did you actually see this happen or is
it only theoretical?

Yes it is a theoretical problem, as complained by Coverity.


/* for each uframe with a packet */
for (uframe = 0; uframe < 8; uframe++) {
@@ -1783,7 +1784,8 @@ itd_complete (
dev->devpath, stream->bEndpointAddress & 0x0f,
(stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out");
}
-   iso_stream_put (ehci, stream);
+   stream_ref_count = stream->refcount;
+   iso_stream_put(ehci, stream);
This iso_stream_put removes the reference held by the URB.  Before it
is called, stream->refcount must be >= 3:

refcount is set to 1 when the stream is created;

each active URB holds a reference;

each itd holds a reference.

So after the call, the refcount value must be >= 2 and the stream could
not have been deallocated.


  done:
itd->urb = NULL;
@@ -1797,7 +1799,7 @@ done:
 * Move it to a safe place until a new frame starts.
 */
list_move(&itd->itd_list, &ehci->cached_itd_list);
-   if (stream->refcount == 2) {
+   if (stream_ref_count == 3) {

Therefore this seems unnecessary.

As per the logic you explained above, this change is not needed.
However coverity was complaining as below:

/kernel/drivers/usb/host/ehci-sched.c 1777 USE_AFTER_FREE
Dereferencing freed pointer "stream"

Hence to pacify coverity, this change is done.

Why are you trying to "pacify" coverity, when the tool is wrong in this
case?  Go poke the owners of that tool to get it to stop emitting this
false warning.  Don't paper over it in the kernel.  Especially for a
tool that none of us can run on our own.

greg k-h

Thanks Greg for your comments.
In fact coverity team also mentioned this as one of the false positives.
Also as Alan mentioned that he'll be taking care of it in a different 
way, will stop working on this patch.


Thanks,
Venu

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 2/3] usb: musb: dsps: add phy control logic to glue

2012-07-11 Thread Gupta, Ajay Kumar
Hi,
> > > >> On Mon, Jul 9, 2012 at 7:18 PM, Damodar Santhapuri
> 
[...]
> > > >> Avoid getting resource by name.. With dt, you wont be able to do
> > > >> those..
> > > >
> > > > When we are completely on DT then this would anyways go and we
> can
> > > > get these resource data for each usb port from DT APIs.
> > >
> > > Even with dt, you will still get the resources using
> > > platform_get_resource() API's.. So why not have it that way from
> the
> > > beginning itself..
> >
> > Ok got it. We will post an updated patch.
> 
> Plalform_get_resource api works fine if we hardcode 3rd argument to
> 3+id for usb_cntrl register Since dsps_create_musb_pdev calls for each
> wrp->instances.
> 
> static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8
> id)
> {
>   
>   
> /* get memory resource for usb control register */
> res = platform_get_resource(pdev, IORESOURCE_MEM, 3+id);
> dev_err(dev,"Damodar :usb ctrl%d res=%x\n",id,res->start);
> if (!res) {
> dev_err(dev, "%s get mem resource failed\n", res_name);
> ret = -ENODEV;
> goto err0;
> }
> 
> }

You can place the memory resources as 
{{usbss, .}, {musb0, .}, {usb0_ctrl, .}, {musb1, .}, {usb1_ctrl, .}}

and then use index as "2 * id + 2" to get the usbX_ctrl base address.

Ajay
> 
> Damodar.
> >
> > Ajay
> > >
> > > Thanks
> > > Kishon
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1] usb: host: Fix possible kernel crash

2012-07-11 Thread Venu Byravarasu

On Tuesday 10 July 2012 08:39 PM, Alan Stern wrote:

On Tue, 10 Jul 2012, Venu Byravarasu wrote:


Thanks Alan for your comments.

On Monday 09 July 2012 08:04 PM, Alan Stern wrote:

On Mon, 9 Jul 2012, Venu Byravarasu wrote:


In functions itd_complete &  sitd_complete, a pointer
by name stream may get dereferenced after freeing it, when
iso_stream_put is called with stream->refcount = 2.

I don't understand the problem.  Did you actually see this happen or is
it only theoretical?

Yes it is a theoretical problem, as complained by Coverity.
As per the logic you explained above, this change is not needed.
However coverity was complaining as below:

/kernel/drivers/usb/host/ehci-sched.c 1777 USE_AFTER_FREE Dereferencing
freed pointer "stream"

Hence to pacify coverity, this change is done.
Please let me know if you see any other better way to handle it.

This seems to be a false positive from Coverity.

In any case, I'm about to submit some patches which get rid of the
reference counting entirely.  So let's not worry about this.

Alan Stern


Thanks Alan for taking care of it, in your future patch.




--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1] usb: host: Fix possible kernel crash

2012-07-11 Thread Venu Byravarasu

On Tuesday 10 July 2012 10:05 PM, Scan Subscription wrote:

Hi Greg/Venu/Alan and others,

The defect discussed in this thread was found in 2006, and was marked in 
Coverity Scan as false positive - intentional ( by linux developer or coverity 
admin that we don't know)...

As a general rule,
1. what was discussed with some of the Linux folks, Focus on NEW defects...
2. Do NOT fix anything that is already marked as Intentional /False Positive


For any defects found by Covierty Scan there could be potential 3 actions
1. Review and Fix the defect
2. Mark it as Intentional in Coverity Scan, and it will not appear as Defect in 
the future
3. Contact Coverity Scan-admin, if you would like to understand it more why it 
was flagged as defect.

• As we all know, inherent in the technology foundation, static analysis will 
report some false positives. We put a lot of effort into our product to drive 
this rate to a very low, acceptable limit (commonly between 5% and 25%)
• In order to address FPs, the SCAN part of our product offers a triage process 
that utilizes a persistent database based on defect hashing. This gives 
developers the option to declare a defect as FP and then never have to look at 
it again.

For instance, 3 weeks ago, Coverity reported 7 new defects introduced based on 
recent code changes,  and as we can see in the various threads almost 
everything was fixed and committed by maintainer.
But a  week after that, out of 6 new defects reported based on latest code 
change, 1 was ignored stating False positive, Intentional...

I hope this clarifies the issue that was discussed here.


Thanks for your detailed mail.



Thanks

Coverity Scan-admin scan-ad...@coverity.com
Dakshesh Vyas | Technical Manager - SCAN
Coverity | 185 Berry Street | Suite 6500, Lobby 3 | San Francisco, CA  94107
Office: 415.935.2957 | dv...@coverity.com



From: linux-kernel-ow...@vger.kernel.org [linux-kernel-ow...@vger.kernel.org] 
On Behalf Of gre...@linuxfoundation.org [gre...@linuxfoundation.org]
Sent: Tuesday, July 10, 2012 7:45 AM
To: Venu Byravarasu
Cc: Alan Stern; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org
Subject: Re: [PATCH v1] usb: host: Fix possible kernel crash

On Tue, Jul 10, 2012 at 09:56:39AM +0530, Venu Byravarasu wrote:

Thanks Alan for your comments.

On Monday 09 July 2012 08:04 PM, Alan Stern wrote:

On Mon, 9 Jul 2012, Venu Byravarasu wrote:


In functions itd_complete &  sitd_complete, a pointer
by name stream may get dereferenced after freeing it, when
iso_stream_put is called with stream->refcount = 2.

I don't understand the problem.  Did you actually see this happen or is
it only theoretical?

Yes it is a theoretical problem, as complained by Coverity.


 /* for each uframe with a packet */
 for (uframe = 0; uframe < 8; uframe++) {
@@ -1783,7 +1784,8 @@ itd_complete (
 dev->devpath, stream->bEndpointAddress & 0x0f,
 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out");
 }
-iso_stream_put (ehci, stream);
+stream_ref_count = stream->refcount;
+iso_stream_put(ehci, stream);
This iso_stream_put removes the reference held by the URB.  Before it
is called, stream->refcount must be >= 3:

 refcount is set to 1 when the stream is created;

 each active URB holds a reference;

 each itd holds a reference.

So after the call, the refcount value must be >= 2 and the stream could
not have been deallocated.


  done:
itd->urb = NULL;
@@ -1797,7 +1799,7 @@ done:
 * Move it to a safe place until a new frame starts.
 */
list_move(&itd->itd_list, &ehci->cached_itd_list);
-   if (stream->refcount == 2) {
+   if (stream_ref_count == 3) {

Therefore this seems unnecessary.

As per the logic you explained above, this change is not needed.
However coverity was complaining as below:

/kernel/drivers/usb/host/ehci-sched.c 1777 USE_AFTER_FREE
Dereferencing freed pointer "stream"

Hence to pacify coverity, this change is done.

Why are you trying to "pacify" coverity, when the tool is wrong in this
case?  Go poke the owners of that tool to get it to stop emitting this
false warning.  Don't paper over it in the kernel.  Especially for a
tool that none of us can run on our own.

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 1/1] Input: xpad - Handle all variations of Mad Catz Beat Pad

2012-07-11 Thread Yuri Khan
* Add this device to usbhid ignore list

Signed-off-by: Yuri Khan 
Acked-by: Jiri Kosina 
---
 drivers/hid/hid-core.c|1 +
 drivers/hid/hid-ids.h |3 +++
 drivers/input/joystick/xpad.c |1 +
 3 files changed, 5 insertions(+)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 6ac0286..1540934 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1995,6 +1995,7 @@ static const struct hid_device_id hid_ignore_list[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) },
{ HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) },
{ HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) },
+   { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_BEATPAD) 
},
{ HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) },
{ HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) },
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index d1cdd2d..43c3d75 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -518,6 +518,9 @@
 #define USB_DEVICE_ID_CRYSTALTOUCH 0x0006
 #define USB_DEVICE_ID_CRYSTALTOUCH_DUAL0x0007
 
+#define USB_VENDOR_ID_MADCATZ  0x0738
+#define USB_DEVICE_ID_MADCATZ_BEATPAD  0x4540
+
 #define USB_VENDOR_ID_MCC  0x09db
 #define USB_DEVICE_ID_MCC_PMD1024LS0x0076
 #define USB_DEVICE_ID_MCC_PMD1208LS0x007a
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index ee16fb6..16974ef 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -238,6 +238,7 @@ static struct usb_device_id xpad_table [] = {
XPAD_XBOX360_VENDOR(0x045e),/* Microsoft X-Box 360 
controllers */
XPAD_XBOX360_VENDOR(0x046d),/* Logitech X-Box 360 style 
controllers */
XPAD_XBOX360_VENDOR(0x0738),/* Mad Catz X-Box 360 
controllers */
+   { USB_DEVICE(0x0738, 0x4540) }, /* Mad Catz Beat Pad */
XPAD_XBOX360_VENDOR(0x0e6f),/* 0x0e6f X-Box 360 controllers 
*/
XPAD_XBOX360_VENDOR(0x12ab),/* X-Box 360 dance pads */
XPAD_XBOX360_VENDOR(0x1430),/* RedOctane X-Box 360 
controllers */
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html