[PATCH] usb: gadget: atmel: remove useless include

2015-08-10 Thread Alexandre Belloni
Definitions from linux/platform_data/atmel.h are not used, remove the
include.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 4095cce05e6a..548192f77dcb 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -22,7 +22,6 @@
 #include linux/usb/gadget.h
 #include linux/usb/atmel_usba_udc.h
 #include linux/delay.h
-#include linux/platform_data/atmel.h
 #include linux/of.h
 #include linux/of_gpio.h
 
-- 
2.1.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 3/8][v2]usb:fsl:otg: Add support to add/remove usb host driver

2015-08-10 Thread Felipe Balbi
On Fri, Aug 07, 2015 at 04:33:33PM -0400, Alan Stern wrote:
 On Wed, 15 Jul 2015, Ramneek Mehresh wrote:
 
  Add workqueue to add/remove host driver (outside
  interrupt context) upon each id change.
  
  Signed-off-by: Li Yang le...@freescale.com
  Signed-off-by: Ramneek Mehresh ramneek.mehr...@freescale.com
  ---
   drivers/usb/host/ehci-fsl.c | 83 
  ++---
   drivers/usb/host/ehci-fsl.h | 20 +++
   2 files changed, 84 insertions(+), 19 deletions(-)
  
  diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
  index 5352e74..81e4bf5 100644
  --- a/drivers/usb/host/ehci-fsl.c
  +++ b/drivers/usb/host/ehci-fsl.c
  @@ -44,6 +44,34 @@
   
   static struct hc_driver __read_mostly fsl_ehci_hc_driver;
   
  +#if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)
 
 You've got these #if lines all over the place.  They look ugly and make
 the code hard to read.  Consider removing them.  Or even if you can't
 remove them entirely, removing most of them would help.
 
 Also, instead of testing both CONFIG_FSL_USB2_OTG and
 CONFIG_FSL_USB2_OTG_MODULE, how about testing a single symbol?  For 
 example:
 
 #if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)
 #define CHANGE_HCD 1
 #else
 #define CHANGE_HCD 0
 #endif
 
 Then all you need later on is #if CHANGE_HCD.  Or if it's inside a 
 code block, just if (CHANGE_HCD).

what about IS_ENABLED() ?

if (IS_ENABLED(CONFIG_FSL_USB2_OTG)) {
foo();
} else {
bar();
}

-- 
balbi


signature.asc
Description: Digital signature


Re: [ANNOUNCE] tree closed for v4.3 merge window

2015-08-10 Thread Felipe Balbi
On Fri, Aug 07, 2015 at 02:30:45PM -0700, Tim Bird wrote:
 On Thu, Aug 6, 2015 at 9:40 AM, Felipe Balbi ba...@ti.com wrote:
  Hi folks,
 
  if your patches aren't in my tree yet, it's too late, sorry.
 
  We have a total of 145 non-merge commits, here's dirstat:
 
  $ git diff --dirstat next ^cbfe8fa6cd67 | sort -rn
21.0% drivers/usb/gadget/udc/
19.9% drivers/usb/musb/
12.9% drivers/usb/phy/
11.7% drivers/usb/gadget/legacy/
 7.8% drivers/usb/gadget/
 6.1% drivers/usb/gadget/function/
 5.7% drivers/usb/dwc3/
 5.0% include/linux/usb/
 4.0% drivers/usb/
 3.1% Documentation/devicetree/bindings/usb/
 
  My tree will soak a bit on linux-next to catch any further build
  regressions (I couldn't find anything missing after the recent 4 patches
  I sent) and next week a pull request will be sent to Greg.
 
  Please, avoid sending patches until v4.3-rc1 is tagged as that goes a
  long way towards keeping my sanity ;-)
 
 I'm not sure I understand.  What about discussion of USB patches for
 the next release?
 Can we send RFC patches amongst ourselves to the linux-usb list?

nobody can prevent you from sending, it's just that for the most part, I
won't look as frequently at patches ;-)

-- 
balbi


signature.asc
Description: Digital signature


[PATCH] usb: gadget: at91_udc: move at91_udc_data in at91_udc.h

2015-08-10 Thread Alexandre Belloni
struct at91_udc_data is now only used inside the driver, move it to its
include.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/usb/gadget/udc/at91_udc.h   | 8 
 include/linux/platform_data/atmel.h | 9 -
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/udc/at91_udc.h 
b/drivers/usb/gadget/udc/at91_udc.h
index 2679c8b217cc..0a433e6b346b 100644
--- a/drivers/usb/gadget/udc/at91_udc.h
+++ b/drivers/usb/gadget/udc/at91_udc.h
@@ -112,6 +112,14 @@ struct at91_udc_caps {
void (*pullup)(struct at91_udc *udc, int is_on);
 };
 
+struct at91_udc_data {
+   int vbus_pin;   /* high == host powering us */
+   u8  vbus_active_low;/* vbus polarity */
+   u8  vbus_polled;/* Use polling, not interrupt */
+   int pullup_pin; /* active == D+ pulled up */
+   u8  pullup_active_low;  /* true == pullup_pin is active low */
+};
+
 /*
  * driver is non-SMP, and just blocks IRQs whenever it needs
  * access protection for chip registers or driver state
diff --git a/include/linux/platform_data/atmel.h 
b/include/linux/platform_data/atmel.h
index 4b452c6a2f7b..2d67e466c51b 100644
--- a/include/linux/platform_data/atmel.h
+++ b/include/linux/platform_data/atmel.h
@@ -25,15 +25,6 @@
  */
 #define ATMEL_MAX_UART 7
 
- /* USB Device */
-struct at91_udc_data {
-   int vbus_pin;   /* high == host powering us */
-   u8  vbus_active_low;/* vbus polarity */
-   u8  vbus_polled;/* Use polling, not interrupt */
-   int pullup_pin; /* active == D+ pulled up */
-   u8  pullup_active_low;  /* true == pullup_pin is active low */
-};
-
  /* Compact Flash */
 struct at91_cf_data {
int irq_pin;/* I/O IRQ */
-- 
2.1.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 3/8][v2]usb:fsl:otg: Add support to add/remove usb host driver

2015-08-10 Thread Ramneek Mehresh


 -Original Message-
 From: Alan Stern [mailto:st...@rowland.harvard.edu]
 Sent: Monday, August 10, 2015 8:14 PM
 To: Mehresh Ramneek-B31383
 Cc: linux-ker...@vger.kernel.org; ba...@ti.com;
 gre...@linuxfoundation.org; linux-usb@vger.kernel.org; Li Yang-Leo-R58472
 Subject: RE: [PATCH 3/8][v2]usb:fsl:otg: Add support to add/remove usb
 host driver
 
 On Mon, 10 Aug 2015, Ramneek Mehresh wrote:
 
   Also, what is the reason for calling usb_hcd_resume_root_hub()?  It
 won't
   do anything, because it will run before the scheduled work, so there
 won't
   be a root hub for it to resume.
  
  Well, you're right...it's not a surety that usb_hcd_resume_root_hub() will
 run after
  scheduled work...i'll move it inside do_change_hcd() after usb_add_hcd().
 Thanks.
 
 You're missing the point.  There's no reason ever to call
 usb_hcd_resume_root_hub() immediately after usb_add_hcd().  The hub
 driver does everything necessary when the root hub is registered.
 Resuming it (if it is suspended at that point) won't accomplish
 anything because all the important work has just been done.
 
 Now, if you _weren't_ calling usb_add_hcd() (for example if host.is_otg
 were 0) then it might make sense to call usb_hcd_resume_root_hub() --
 although I don't see why you would need to.
 
 Alan Stern
Understood...let me check this once again. Thanks.

--
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: [xhci] __list_add triggers BUG while processing xhci_queue_slot_control

2015-08-10 Thread Greg KH
On Mon, Aug 10, 2015 at 08:47:05AM +0200, Torsten Hilbrich wrote:
 Hello,
 
 I got the following stack trace when booting a 3.19.4 kernel

3.19.y is long obsolete, please move to a supported kernel for us to
be able to help you out.  Does this happen with 4.1.y?

 (with grsecurity enabled, but this should not be related here),

Note, grsecurity makes some interesting changes in parts of the USB
core code, all of which have no value and might cause bugs.  So always
try a non-grsec kernel if you have USB issues.

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 3/8][v2]usb:fsl:otg: Add support to add/remove usb host driver

2015-08-10 Thread Fabio Estevam
On Mon, Aug 10, 2015 at 12:35 PM, Ramneek Mehresh
ramneek.mehr...@freescale.com wrote:

 Understood...let me check this once again. Thanks.

Why don't use the chipidea driver instead?
--
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 RESEND] usbhid: Fix the check for HID_RESET_PENDING in hid_io_error

2015-08-10 Thread Don Zickus
It was reported that after 10-20 reboots, a usb keyboard plugged
into a docking station would not work unless it was replugged in.

Using usbmon, it turns out the interrupt URBs were streaming with
callback errors of -71 for some reason.  The hid-core.c::hid_io_error was
supposed to retry and then reset, but the reset wasn't really happening.

The check for HID_NO_BANDWIDTH was inverted.  Fix was simple.

Tested by reporter and locally by me by unplugging a keyboard halfway until I
could recreate a stream of errors but no disconnect.

Signed-off-by: Don Zickus dzic...@redhat.com
---

I mistyped the usb mailing list address, so this patch never made it there.
Resending with the correct address.  Sorry for the spam.



 drivers/hid/usbhid/hid-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index b37d944..9935a64 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -164,7 +164,7 @@ static void hid_io_error(struct hid_device *hid)
if (time_after(jiffies, usbhid-stop_retry)) {
 
/* Retries failed, so do a port reset unless we lack bandwidth*/
-   if (test_bit(HID_NO_BANDWIDTH, usbhid-iofl)
+   if (!test_bit(HID_NO_BANDWIDTH, usbhid-iofl)
  !test_and_set_bit(HID_RESET_PENDING, usbhid-iofl)) {
 
schedule_work(usbhid-reset_work);
-- 
1.8.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 3/8][v2]usb:fsl:otg: Add support to add/remove usb host driver

2015-08-10 Thread Alan Stern
On Mon, 10 Aug 2015, Ramneek Mehresh wrote:

  Also, what is the reason for calling usb_hcd_resume_root_hub()?  It won't
  do anything, because it will run before the scheduled work, so there won't
  be a root hub for it to resume.
  
 Well, you're right...it's not a surety that usb_hcd_resume_root_hub() will 
 run after
 scheduled work...i'll move it inside do_change_hcd() after usb_add_hcd(). 
 Thanks.

You're missing the point.  There's no reason ever to call 
usb_hcd_resume_root_hub() immediately after usb_add_hcd().  The hub 
driver does everything necessary when the root hub is registered.  
Resuming it (if it is suspended at that point) won't accomplish 
anything because all the important work has just been done.

Now, if you _weren't_ calling usb_add_hcd() (for example if host.is_otg
were 0) then it might make sense to call usb_hcd_resume_root_hub() --
although I don't see why you would need to.

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: [ANNOUNCE] tree closed for v4.3 merge window

2015-08-10 Thread Tim Bird
On Mon, Aug 10, 2015 at 7:34 AM, Felipe Balbi ba...@ti.com wrote:
 On Fri, Aug 07, 2015 at 02:30:45PM -0700, Tim Bird wrote:
 On Thu, Aug 6, 2015 at 9:40 AM, Felipe Balbi ba...@ti.com wrote:
  Hi folks,
 
  if your patches aren't in my tree yet, it's too late, sorry.
 
  We have a total of 145 non-merge commits, here's dirstat:
 
  $ git diff --dirstat next ^cbfe8fa6cd67 | sort -rn
21.0% drivers/usb/gadget/udc/
19.9% drivers/usb/musb/
12.9% drivers/usb/phy/
11.7% drivers/usb/gadget/legacy/
 7.8% drivers/usb/gadget/
 6.1% drivers/usb/gadget/function/
 5.7% drivers/usb/dwc3/
 5.0% include/linux/usb/
 4.0% drivers/usb/
 3.1% Documentation/devicetree/bindings/usb/
 
  My tree will soak a bit on linux-next to catch any further build
  regressions (I couldn't find anything missing after the recent 4 patches
  I sent) and next week a pull request will be sent to Greg.
 
  Please, avoid sending patches until v4.3-rc1 is tagged as that goes a
  long way towards keeping my sanity ;-)

 I'm not sure I understand.  What about discussion of USB patches for
 the next release?
 Can we send RFC patches amongst ourselves to the linux-usb list?

 nobody can prevent you from sending, it's just that for the most part, I
 won't look as frequently at patches ;-)

OK. Thanks.

BTW - I do find these types of here's when to send for better
results messages helpful.  That is, if there are indeed better times
to send patches, it's good to know about them.  Of course it would be
even nicer if patches could be accepted any time and queued, but we
live in the real world and I realize that maintainers time is finite.
:-)

 -- Tim Bird
Senior Software Engineer, Sony Mobile
Architecture Group Chair, CE Workgroup, Linux Foundation
--
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] Revert usb: chipidea: usbmisc_imx: delete clock information

2015-08-10 Thread Fabio Estevam
On Thu, Jul 2, 2015 at 5:40 AM, Peter Chen peter.c...@freescale.com wrote:

 Sorry, I can't accept it, and it will remain the clock on, and break
 runtime pm feature.

 In fact, the core and non-core use the same clocks, and at imx27, it
 may need two or three clocks to let the controller work for imx27.
 I can accept handle three clocks like below at ci_hdrc_imx.c to fix
 this issue.

 arch/arm/boot/dts/imx25.dtsi
 clocks = clks 9, clks 70, clks 8;
 clock-names = ipg, ahb, per;

Do you mean something like this? (I know I should not break existing
dtb's, but just want to make sure I got your idea):

diff --git a/arch/arm/boot/dts/imx27.dtsi b/arch/arm/boot/dts/imx27.dtsi
index feb9d34..e74aa3c 100644
--- a/arch/arm/boot/dts/imx27.dtsi
+++ b/arch/arm/boot/dts/imx27.dtsi
@@ -515,7 +515,10 @@
#index-cells = 1;
compatible = fsl,imx27-usbmisc;
reg = 0x10024600 0x200;
-   clocks = clks IMX27_CLK_USB_AHB_GATE;
+   clocks = clks IMX27_CLK_IPG,
+clks IMX27_CLK_USB_AHB_GATE,
+clks IMX27_CLK_USB_DIV;
+   clock-names = ipg, ahb, per;
};

sahara2: sahara@10025000 {
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c
b/drivers/usb/chipidea/ci_hdrc_imx.c
index 389f0e0..a2b8cd0 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -65,6 +65,8 @@ struct ci_hdrc_imx_data {
struct usb_phy *phy;
struct platform_device *ci_pdev;
struct clk *clk;
+   struct clk *per;
+   struct clk *ahb;
struct imx_usbmisc_data *usbmisc_data;
bool supports_runtime_pm;
bool in_lpm;
@@ -141,13 +143,27 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
if (IS_ERR(data-usbmisc_data))
return PTR_ERR(data-usbmisc_data);

-   data-clk = devm_clk_get(pdev-dev, NULL);
+   data-clk = devm_clk_get(pdev-dev, ipg);
if (IS_ERR(data-clk)) {
dev_err(pdev-dev,
-   Failed to get clock, err=%ld\n, PTR_ERR(data-clk));
+   Failed to get ipg clock, err=%ld\n,
PTR_ERR(data-clk));
return PTR_ERR(data-clk);
}

+   data-per = devm_clk_get(pdev-dev, per);
+   if (IS_ERR(data-per)) {
+   dev_err(pdev-dev,
+   Failed to get per clock, err=%ld\n,
PTR_ERR(data-per));
+   return PTR_ERR(data-per);
+   }
+
+   data-ahb = devm_clk_get(pdev-dev, ahb);
+   if (IS_ERR(data-ahb)) {
+   dev_err(pdev-dev,
+   Failed to get ahb clock, err=%ld\n,
PTR_ERR(data-ahb));
+   return PTR_ERR(data-ahb);
+   }
+
ret = clk_prepare_enable(data-clk);
if (ret) {
dev_err(pdev-dev,
@@ -155,6 +171,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
return ret;
}

+   clk_prepare_enable(data-per);
+   clk_prepare_enable(data-ahb);
+
data-phy = devm_usb_get_phy_by_phandle(pdev-dev, fsl,usbphy, 0);
if (IS_ERR(data-phy)) {
ret = PTR_ERR(data-phy);

This fails as:

imx_usb 10024000.usb: Failed to get ipg clock, err=-2
imx_usb: probe of 10024000.usb failed with error -2
--
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 v1] usb: dwc2: reset AHB hclk domain before init

2015-08-10 Thread Yunzhi Li
We initiate dwc2 usb controller in BIOS, when kernel driver
start-up we should reset AHB hclk domain to reset all AHB
interface registers to default. Without this the FIFO value
setting might be incorrect because calculating FIFO size need the
power-on value of GRXFSIZ/GNPTXFSIZ/HPTXFSIZ registers.

This patch could avoid warnning massage like in rk3288 platform:
[2.074764] dwc2 ff58.usb: 256 invalid for
host_perio_tx_fifo_size. Check HW configuration.

Signed-off-by: Yunzhi Li l...@rock-chips.com

---

 drivers/usb/dwc2/platform.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 9093530..3da21ab 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -42,6 +42,7 @@
 #include linux/of_device.h
 #include linux/mutex.h
 #include linux/platform_device.h
+#include linux/reset.h
 
 #include linux/usb/of.h
 
@@ -165,6 +166,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
struct resource *res;
struct phy *phy;
struct usb_phy *uphy;
+   struct reset_control *rst;
int retval;
int irq;
 
@@ -189,6 +191,16 @@ static int dwc2_driver_probe(struct platform_device *dev)
 
hsotg-dev = dev-dev;
 
+   /* AHB hclk domain reset, set all AHB interface registers to default */
+   rst = devm_reset_control_get_optional(dev-dev, ahb_reset);
+   if (IS_ERR(rst)) {
+   dev_dbg(dev-dev, Can't get dwc2 AHB reset\n);
+   } else {
+   reset_control_assert(rst);
+   udelay(5);
+   reset_control_deassert(rst);
+   }
+
/*
 * Use reasonable defaults so platforms don't have to provide these.
 */
-- 
2.0.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


[PATCHv2] Input: xpad - Fix double URB submission races

2015-08-10 Thread Laura Abbott
The xpad driver has several races with respect to URB submission which
make it easy to end up with submission while active:

[ cut here ]
WARNING: CPU: 3 PID: 3563 at drivers/usb/core/urb.c:339
usb_submit_urb+0x2ad/0x5a0()
URB 8804078ac240 submitted while active
Modules linked in: fuse xt_CHECKSUM ipt_MASQUERADE nf_nat_masquerade_ipv4 tun
nf_conntrack_netbios_ns nf_conntrack_broadcast ip6t_rpfilter ip6t_REJECT
nf_reject_ipv6 xt_conntrack ebtable_nat ebtable_broute bridge ebtable_filter
ebtables ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6
ip6table_mangle ip6table_security ip6table_raw ip6table_filter ip6_tables
iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack
iptable_mangle iptable_security iptable_raw bnep xpadsnd_hda_codec_realtek
snd_hda_codec_hdmi snd_hda_codec_generic snd_hda_intel snd_hda_codec
snd_hda_core snd_hwdep snd_seq intel_rapl iosf_mbi snd_seq_device
x86_pkg_temp_thermal coretemp snd_pcm kvm uvcvideo iTCO_wdt iTCO_vendor_support
iwlwifi videobuf2_vmalloc videobuf2_core videobuf2_memops
v4l2_common btusb videodev btrtl btbcm thinkpad_acpi snd_timer btintel
mei_me rtsx_pci_ms cfg80211 bluetooth pcspkr mei media memstick joydev snd
tpm_tis shpchp ie31200_edac i2c_i801 tpm lpc_ich edac_core nfsd rfkill wmi
soundcore auth_rpcgss nfs_acl lockd grace sunrpc binfmt_misc dm_crypt i915 8021q
garp stp llc mrp i2c_algo_bit drm_kms_helper drm rtsx_pci_sdmmc mmc_core e1000e
crct10dif_pclmul crc32_pclmul crc32c_intel rtsx_pci ghash_clmulni_intel
ptp serio_raw pps_core mfd_core video
CPU: 3 PID: 3563 Comm: led_test.sh Not tainted 4.2.0-rc4-xpad+ #14
Hardware name: LENOVO 20BFS0EC00/20BFS0EC00, BIOS GMET62WW (2.10 )
03/19/2014
 17a45bc6 8800c9a0fbd8 81758a11
 8800c9a0fc30 8800c9a0fc18 8109b656
0002 8804078ac240 00d0 8800c9806d60
Call Trace:
[81758a11] dump_stack+0x45/0x57
[8109b656] warn_slowpath_common+0x86/0xc0
[8109b6e5] warn_slowpath_fmt+0x55/0x70
[8120f218] ? do_truncate+0x88/0xc0
[815427fd] usb_submit_urb+0x2ad/0x5a0
[81230df4] ? mntput+0x24/0x40
[8121b667] ? terminate_walk+0xc7/0xe0
[a0430877] xpad_send_led_command+0xc7/0x110 [xpad]
[a04308d5] xpad_led_set+0x15/0x20 [xpad]
[815f9678] led_set_brightness+0x88/0xc0
[815f9b0e] brightness_store+0x7e/0xc0
[814b7478] dev_attr_store+0x18/0x30
[8128bba7] sysfs_kf_write+0x37/0x40
[8128b15d] kernfs_fop_write+0x11d/0x170
[81210d17] __vfs_write+0x37/0x100
[81213b28] ? __sb_start_write+0x58/0x110
[813124dd] ? security_file_permission+0x3d/0xc0
[81211696] vfs_write+0xa6/0x1a0
[8120e93a] ? filp_close+0x5a/0x80
[81212385] SyS_write+0x55/0xc0
[8175f0ae] entry_SYSCALL_64_fastpath+0x12/0x71
---[ end trace f573b768c94a66d6 ]---

This is easily reproducible with

while true; do
for i in $(seq 0 5); do
echo $i  /sys/class/leds/xpad0/subsystem/xpad0/brightness
done
done

xpad_send_led_command attempts to protect against races by locking
around usb_submit_urb. This is not sufficent since usb_submit_urb
is asynchronous; the urb is considered to be in use until the callback
(xpad_irq_out) returns appropriately. Additionally, there is no
protection at all in xpad_play_effect which uses the same urb. Fix this
by creating a queue for urb submission. This will serialize requests to
ensure only one is submitted at a time.

Signed-off-by: Laura Abbott labb...@fedoraproject.org
---
v2: Created a proper queue for events instead of just dropping them
---
 drivers/input/joystick/xpad.c | 273 ++
 1 file changed, 194 insertions(+), 79 deletions(-)

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index f8850f9..e94cc49 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -100,6 +100,9 @@
 #define XTYPE_XBOXONE 3
 #define XTYPE_UNKNOWN 4
 
+#define OUT_IRQ_SUBMITTED  0
+#define OUT_IRQ_QUEUE_EMPTY1
+
 static bool dpad_to_buttons;
 module_param(dpad_to_buttons, bool, S_IRUGO);
 MODULE_PARM_DESC(dpad_to_buttons, Map D-PAD to buttons rather than axes for 
unknown pads);
@@ -334,7 +337,9 @@ struct usb_xpad {
struct urb *irq_out;/* urb for interrupt out report */
unsigned char *odata;   /* output data */
dma_addr_t odata_dma;
-   struct mutex odata_mutex;
+   unsigned long odata_flags;
+   spinlock_t queue_lock;
+   struct list_head odata_queue;   /* queue of commands */
 
 #if defined(CONFIG_JOYSTICK_XPAD_LEDS)
struct xpad_led *led;
@@ -347,6 +352,94 @@ struct usb_xpad {
unsigned long led_no;   /* led to lit on xbox360 controllers */
 };
 
+struct xpad_queue_item {
+   char odata[XPAD_PKT_LEN];
+   int transfer_length;
+   

Re: [PATCH] Revert usb: chipidea: usbmisc_imx: delete clock information

2015-08-10 Thread Fabio Estevam
On Mon, Aug 10, 2015 at 9:39 PM, Peter Chen peter.c...@freescale.com wrote:

 I would like to have an API like is_need_three_clks to distinguish
 one clk vs three clk cases, I will have a patch for it, would you
 help to test when the patch is ready?

Sure, I will be glad to test it on my mx27pdk.

Thanks
--
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] Revert usb: chipidea: usbmisc_imx: delete clock information

2015-08-10 Thread Peter Chen
On Mon, Aug 10, 2015 at 06:08:16PM -0300, Fabio Estevam wrote:
 On Thu, Jul 2, 2015 at 5:40 AM, Peter Chen peter.c...@freescale.com wrote:
 
  Sorry, I can't accept it, and it will remain the clock on, and break
  runtime pm feature.
 
  In fact, the core and non-core use the same clocks, and at imx27, it
  may need two or three clocks to let the controller work for imx27.
  I can accept handle three clocks like below at ci_hdrc_imx.c to fix
  this issue.
 
  arch/arm/boot/dts/imx25.dtsi
  clocks = clks 9, clks 70, clks 8;
  clock-names = ipg, ahb, per;
 
 Do you mean something like this? (I know I should not break existing
 dtb's, but just want to make sure I got your idea):
 
 diff --git a/arch/arm/boot/dts/imx27.dtsi b/arch/arm/boot/dts/imx27.dtsi
 index feb9d34..e74aa3c 100644
 --- a/arch/arm/boot/dts/imx27.dtsi
 +++ b/arch/arm/boot/dts/imx27.dtsi
 @@ -515,7 +515,10 @@
 #index-cells = 1;
 compatible = fsl,imx27-usbmisc;
 reg = 0x10024600 0x200;
 -   clocks = clks IMX27_CLK_USB_AHB_GATE;
 +   clocks = clks IMX27_CLK_IPG,
 +clks IMX27_CLK_USB_AHB_GATE,
 +clks IMX27_CLK_USB_DIV;
 +   clock-names = ipg, ahb, per;
 };

No, at this clock diff information at controller's entry.

 
 sahara2: sahara@10025000 {
 diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c
 b/drivers/usb/chipidea/ci_hdrc_imx.c
 index 389f0e0..a2b8cd0 100644
 --- a/drivers/usb/chipidea/ci_hdrc_imx.c
 +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
 @@ -65,6 +65,8 @@ struct ci_hdrc_imx_data {
 struct usb_phy *phy;
 struct platform_device *ci_pdev;
 struct clk *clk;
 +   struct clk *per;
 +   struct clk *ahb;
 struct imx_usbmisc_data *usbmisc_data;
 bool supports_runtime_pm;
 bool in_lpm;
 @@ -141,13 +143,27 @@ static int ci_hdrc_imx_probe(struct platform_device 
 *pdev)
 if (IS_ERR(data-usbmisc_data))
 return PTR_ERR(data-usbmisc_data);
 
 -   data-clk = devm_clk_get(pdev-dev, NULL);
 +   data-clk = devm_clk_get(pdev-dev, ipg);
 if (IS_ERR(data-clk)) {
 dev_err(pdev-dev,
 -   Failed to get clock, err=%ld\n, PTR_ERR(data-clk));
 +   Failed to get ipg clock, err=%ld\n,
 PTR_ERR(data-clk));
 return PTR_ERR(data-clk);
 }
 
 +   data-per = devm_clk_get(pdev-dev, per);
 +   if (IS_ERR(data-per)) {
 +   dev_err(pdev-dev,
 +   Failed to get per clock, err=%ld\n,
 PTR_ERR(data-per));
 +   return PTR_ERR(data-per);
 +   }
 +
 +   data-ahb = devm_clk_get(pdev-dev, ahb);
 +   if (IS_ERR(data-ahb)) {
 +   dev_err(pdev-dev,
 +   Failed to get ahb clock, err=%ld\n,
 PTR_ERR(data-ahb));
 +   return PTR_ERR(data-ahb);
 +   }
 +
 ret = clk_prepare_enable(data-clk);
 if (ret) {
 dev_err(pdev-dev,
 @@ -155,6 +171,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
 return ret;
 }
 
 +   clk_prepare_enable(data-per);
 +   clk_prepare_enable(data-ahb);
 +
 data-phy = devm_usb_get_phy_by_phandle(pdev-dev, fsl,usbphy, 0);
 if (IS_ERR(data-phy)) {
 ret = PTR_ERR(data-phy);
 
 This fails as:
 
 imx_usb 10024000.usb: Failed to get ipg clock, err=-2
 imx_usb: probe of 10024000.usb failed with error -2

I would like to have an API like is_need_three_clks to distinguish
one clk vs three clk cases, I will have a patch for it, would you
help to test when the patch is ready?

-- 

Best Regards,
Peter Chen
--
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 3/8][v2]usb:fsl:otg: Add support to add/remove usb host driver

2015-08-10 Thread Ramneek Mehresh


 -Original Message-
 From: Alan Stern [mailto:st...@rowland.harvard.edu]
 Sent: Saturday, August 08, 2015 2:04 AM
 To: Mehresh Ramneek-B31383
 Cc: linux-ker...@vger.kernel.org; ba...@ti.com;
 gre...@linuxfoundation.org; linux-usb@vger.kernel.org; Li Yang-Leo-R58472
 Subject: Re: [PATCH 3/8][v2]usb:fsl:otg: Add support to add/remove usb
 host driver
 
 On Wed, 15 Jul 2015, Ramneek Mehresh wrote:
 
  Add workqueue to add/remove host driver (outside interrupt context)
  upon each id change.
 
  Signed-off-by: Li Yang le...@freescale.com
  Signed-off-by: Ramneek Mehresh ramneek.mehr...@freescale.com
  ---
   drivers/usb/host/ehci-fsl.c | 83
  ++---
   drivers/usb/host/ehci-fsl.h | 20 +++
   2 files changed, 84 insertions(+), 19 deletions(-)
 
  diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
  index 5352e74..81e4bf5 100644
  --- a/drivers/usb/host/ehci-fsl.c
  +++ b/drivers/usb/host/ehci-fsl.c
  @@ -44,6 +44,34 @@
 
   static struct hc_driver __read_mostly fsl_ehci_hc_driver;
 
  +#if defined(CONFIG_FSL_USB2_OTG) ||
  +defined(CONFIG_FSL_USB2_OTG_MODULE)
 
 You've got these #if lines all over the place.  They look ugly and make the
 code hard to read.  Consider removing them.  Or even if you can't remove
 them entirely, removing most of them would help.
 
 Also, instead of testing both CONFIG_FSL_USB2_OTG and
 CONFIG_FSL_USB2_OTG_MODULE, how about testing a single symbol?  For
 example:
 
 #if defined(CONFIG_FSL_USB2_OTG) ||
 defined(CONFIG_FSL_USB2_OTG_MODULE)
 #define CHANGE_HCD 1
 #else
 #define CHANGE_HCD 0
 #endif
 
 Then all you need later on is #if CHANGE_HCD.  Or if it's inside a code 
 block,
 just if (CHANGE_HCD).
 
Ok, let me see what can be done to minimize these macros. Thanks

  +static struct ehci_fsl *hcd_to_ehci_fsl(struct usb_hcd *hcd) {
  +   return (struct ehci_fsl *)hcd_to_ehci(hcd)-priv; }
  +
  +static void do_change_hcd(struct work_struct *work) {
  +   struct ehci_fsl *ehci_fsl = container_of(work, struct ehci_fsl,
  +   change_hcd_work);
  +   struct usb_hcd *hcd = ehci_fsl-hcd;
  +   void __iomem *non_ehci = hcd-regs;
  +   int retval;
  +
  +   if (ehci_fsl-hcd_add  !ehci_fsl-have_hcd) {
  +   writel(USBMODE_CM_HOST, non_ehci +
 FSL_SOC_USB_USBMODE);
  +   /* host, gadget and otg share same int line */
  +   retval = usb_add_hcd(hcd, hcd-irq, IRQF_SHARED);
  +   if (retval == 0)
  +   ehci_fsl-have_hcd = 1;
  +   } else if (!ehci_fsl-hcd_add  ehci_fsl-have_hcd) {
  +   usb_remove_hcd(hcd);
  +   ehci_fsl-have_hcd = 0;
 
 Don't you have to turn off the USBMODE_CM_HOST bit here?  It looks
 strange to turn it on above but not turn it off again.
 
USBMODE bit defines mode for the controller. It gets auto cleared when 
controller is 
reset in host/gadget driver. After resetting, it's mandatory to write this bit 
once to define
controller's mode. 
  +   }
  +}
  +#endif
 
 
   static int ehci_fsl_drv_suspend(struct device *dev)  {
  struct usb_hcd *hcd = dev_get_drvdata(dev);
  -   struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);
  void __iomem *non_ehci = hcd-regs;
  +#if defined(CONFIG_FSL_USB2_OTG) ||
 defined(CONFIG_FSL_USB2_OTG_MODULE)
  +   struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);
  +   struct usb_bus host = hcd-self;
  +#endif
  +
 
  if (of_device_is_compatible(dev-parent-of_node,
  fsl,mpc5121-usb2-dr)) {
  return ehci_fsl_mpc512x_drv_suspend(dev);
  }
 
  +#if defined(CONFIG_FSL_USB2_OTG) ||
 defined(CONFIG_FSL_USB2_OTG_MODULE)
  +   if (host.is_otg) {
  +   /* remove hcd */
  +   ehci_fsl-hcd_add = 0;
  +   schedule_work(ehci_fsl-change_hcd_work);
  +   host.is_otg = 0;
 
 Why do you set host.is_otg to 0 here?  Why not do it in the work routine?
Well, it can be done there also. I just wanted to keep host-bus house-keeping 
out
of otg role-changing specific workqueue (where host driver is 
brought-up/shut-down). 
 
  +   return 0;
  +   }
  +#endif
  +
  ehci_prepare_ports_for_controller_suspend(hcd_to_ehci(hcd),
  device_may_wakeup(dev));
  if (!fsl_deep_sleep())
  @@ -540,15 +571,29 @@ static int ehci_fsl_drv_suspend(struct device
  *dev)  static int ehci_fsl_drv_resume(struct device *dev)  {
  struct usb_hcd *hcd = dev_get_drvdata(dev);
  -   struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);
  struct ehci_hcd *ehci = hcd_to_ehci(hcd);
  void __iomem *non_ehci = hcd-regs;
  +#if defined(CONFIG_FSL_USB2_OTG) ||
 defined(CONFIG_FSL_USB2_OTG_MODULE)
  +   struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);
  +   struct usb_bus host = hcd-self;
  +#endif
 
  if (of_device_is_compatible(dev-parent-of_node,
  fsl,mpc5121-usb2-dr)) {
  return ehci_fsl_mpc512x_drv_resume(dev);
  }
 
  +#if 

Re: Add commit 3f2cee73b650 (USB: usbfs: allow URBs to be reaped after disconnection) to -stable

2015-08-10 Thread Luis Henriques
On Fri, Jul 31, 2015 at 10:56:20AM -0400, Alan Stern wrote:
 Greg:
 
 The $SUBJECT commit was added in the 4.0 kernel, but I forgot to mark 
 it for inclusion in the -stable kernels.  The problem it fixes is a 
 nasty one, affecting people who use libusb: When a device is 
 disconnected while a libusb transfer is in progress, libusb never 
 receives a completion notification for the transfer.  This can result 
 in a hang or a segmentation error, depending on how the userspace 
 program tries to cope.
 
 The patch may require some context adjustment before it will apply to 
 the longterm -stable trees, but I think it should be added.
 
 Alan Stern
 
 --
 To unsubscribe from this list: send the line unsubscribe stable in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

Queuing it for the 3.16 kernel as well.  Thanks!

Cheers,
--
Luís
--
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


[xhci] __list_add triggers BUG while processing xhci_queue_slot_control

2015-08-10 Thread Torsten Hilbrich
Hello,

I got the following stack trace when booting a 3.19.4 kernel (with
grsecurity enabled, but this should not be related here), possible at
the moment when the xhci driver was initially processing the USB devices:

kernel BUG at lib/list_debug.c:39
Workqueue;: usb_hub_wq hub_event

__list_add
queue_command
xhci_queue_slot_control
xhci_alloc_dev
usb_alloc_dev
hub_event
process_one_work

The complete screenshot with all information can be found at
http://picpaste.com/pics/IMG_20150805_072836-LAhi91tT.1439187381.jpg

The system is a Lenovo T450s docked within a Lenovo Ultra Dock docking
station. Attached are two external USB3 hubs (no devices attached
there). USB devices attached during boot were a keyboard and a mouse,
both attached to the docking unit. The error was not yet reproducible.

The error seems to indicate that the xhci-cmd_list got modified while
the list_add operation was taking place. I already checked the xhci code
and apart from some shutdown handling didn't find any place, were the
list was modified without taking the xhci-lock.

Any idea, what might be the concurrent user causing this problem?

Thanks for any input,

Torsten
--
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 4/9] usb: host: ehci-st: Simplify return statement

2015-08-10 Thread Maxime Coquelin

Hi Saurabh,

On 08/04/2015 04:02 PM, Karajgaonkar, Saurabh (S.) wrote:

From: Saurabh Karajgaonkar skara...@visteon.com

Replace redundant variable use in return statement.

Signed-off-by: Saurabh Karajgaonkar skara...@visteon.com
---
  drivers/usb/host/ehci-st.c | 7 +--
  1 file changed, 1 insertion(+), 6 deletions(-)




Acked-by: Maxime Coquelin maxime.coque...@st.com

Thanks!
Maxime
--
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 v6 1/2] usb: make xhci platform driver use 64 bit or 32 bit DMA

2015-08-10 Thread Duc Dang
The xhci platform driver needs to work on systems that
either only support 64-bit DMA or only support 32-bit DMA.
Attempt to set a coherent dma mask for 64-bit DMA, and
attempt again with 32-bit DMA if that fails.

[dhdang: regenerate the patch over 4.2-rc5 and address new comments]
Signed-off-by: Mark Langsdorf mlang...@redhat.com
Tested-by: Mark Salter msal...@redhat.com
Signed-off-by: Duc Dang dhd...@apm.com

---
Changes from v5:
-Change comment
-Assign dma_mask to coherent_dma_mask if dma_mask is NULL
to make sure dma_set_mask_and_coherent does not fail prematurely.

Changes from v4:
-None

Changes from v3:
-Re-generate the patch over 4.2-rc5
-No code change.

Changes from v2:
-None

Changes from v1:
-Consolidated to use dma_set_mask_and_coherent
-Got rid of the check against sizeof(dma_addr_t)

 drivers/usb/host/xhci-plat.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 890ad9d..5d1b84b 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -93,14 +93,18 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (irq  0)
return -ENODEV;
 
-   /* Initialize dma_mask and coherent_dma_mask to 32-bits */
-   ret = dma_set_coherent_mask(pdev-dev, DMA_BIT_MASK(32));
-   if (ret)
-   return ret;
+   /*
+* Try setting dma_mask and coherent_dma_mask to 64 bits,
+* then try 32 bits
+*/
if (!pdev-dev.dma_mask)
pdev-dev.dma_mask = pdev-dev.coherent_dma_mask;
-   else
-   dma_set_mask(pdev-dev, DMA_BIT_MASK(32));
+   ret = dma_set_mask_and_coherent(pdev-dev, DMA_BIT_MASK(64));
+   if (ret) {
+   ret = dma_set_mask_and_coherent(pdev-dev, DMA_BIT_MASK(32));
+   if (ret)
+   return ret;
+   }
 
hcd = usb_create_hcd(driver, pdev-dev, dev_name(pdev-dev));
if (!hcd)
-- 
1.9.1

--
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 v6 2/2] usb: Add support for ACPI identification to xhci-platform

2015-08-10 Thread Duc Dang
Provide the methods to let ACPI identify the need to use
xhci-platform. Change the Kconfig files so the
xhci-plat.o file is selectable during kernel config.

This has been tested on an ARM64 machine with platform XHCI, an
x86_64 machine with XHCI, and an x86_64 machine without XHCI.
There were no regressions or error messages on the machines
without platform XHCI.

[dhdang: regenerate the patch over 4.2-rc5 and address new comments]
Signed-off-by: Mark Langsdorf mlang...@redhat.com
Signed-off-by: Duc Dang dhd...@apm.com

---
Change from v5:
Change comment to XHCI-compliant USB Controller as
PNP0D10 ID is not X-Gene specific

Changes from v4:
Remove #ifdef CONFIG_ACPI

Changes from v3:
Regenerate the patch over 4.2-rc5
No code change

Changes from v2
Replaced tristate with a boolean as the driver doesn't
compile as a module
Correct --help-- to ---help---

Changes from v1
Renamed from add support for APM X-Gene to xhci-platform
Removed changes to arm64/Kconfig
Made CONFIG_USB_XHCI_PLATFORM a user selectable config option

 drivers/usb/host/Kconfig | 7 ++-
 drivers/usb/host/xhci-plat.c | 9 +
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 8afc3c1..96231ee 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -32,7 +32,12 @@ config USB_XHCI_PCI
default y
 
 config USB_XHCI_PLATFORM
-   tristate
+   tristate xHCI platform driver support
+   ---help---
+ Say 'Y' to enable the support for the xHCI host controller
+ as a platform device. Many ARM SoCs provide USB this way.
+
+ If unsure, say 'Y'.
 
 config USB_XHCI_MVEBU
tristate xHCI support for Marvell Armada 375/38x
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 5d1b84b..7ec2d31 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -19,6 +19,7 @@
 #include linux/usb/phy.h
 #include linux/slab.h
 #include linux/usb/xhci_pdriver.h
+#include linux/acpi.h
 
 #include xhci.h
 #include xhci-mvebu.h
@@ -266,6 +267,13 @@ static const struct of_device_id usb_xhci_of_match[] = {
 MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
 #endif
 
+static const struct acpi_device_id usb_xhci_acpi_match[] = {
+   /* XHCI-compliant USB Controller */
+   { PNP0D10, },
+   { }
+};
+MODULE_DEVICE_TABLE(acpi, usb_xhci_acpi_match);
+
 static struct platform_driver usb_xhci_driver = {
.probe  = xhci_plat_probe,
.remove = xhci_plat_remove,
@@ -273,6 +281,7 @@ static struct platform_driver usb_xhci_driver = {
.name = xhci-hcd,
.pm = DEV_PM_OPS,
.of_match_table = of_match_ptr(usb_xhci_of_match),
+   .acpi_match_table = ACPI_PTR(usb_xhci_acpi_match),
},
 };
 MODULE_ALIAS(platform:xhci-hcd);
-- 
1.9.1

--
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: [xhci] __list_add triggers BUG while processing xhci_queue_slot_control

2015-08-10 Thread Mathias Nyman
On 10.08.2015 09:47, Torsten Hilbrich wrote:
 Hello,

Hi

 
 I got the following stack trace when booting a 3.19.4 kernel (with
 grsecurity enabled, but this should not be related here), possible at
 the moment when the xhci driver was initially processing the USB devices:
 
 kernel BUG at lib/list_debug.c:39
 Workqueue;: usb_hub_wq hub_event
 
 __list_add
 queue_command
 xhci_queue_slot_control
 xhci_alloc_dev
 usb_alloc_dev
 hub_event
 process_one_work
 
 The complete screenshot with all information can be found at
 http://picpaste.com/pics/IMG_20150805_072836-LAhi91tT.1439187381.jpg
 
 The system is a Lenovo T450s docked within a Lenovo Ultra Dock docking
 station. Attached are two external USB3 hubs (no devices attached
 there). USB devices attached during boot were a keyboard and a mouse,
 both attached to the docking unit. The error was not yet reproducible.
 
 The error seems to indicate that the xhci-cmd_list got modified while
 the list_add operation was taking place. I already checked the xhci code
 and apart from some shutdown handling didn't find any place, were the
 list was modified without taking the xhci-lock.
 
 Any idea, what might be the concurrent user causing this problem?
 

This looks like one of the issues that could be caused by the usb address mutex
change around 3.18.
The address mutex was changed from global to per USB bus.

As xhci handles both a USB2 and a USB3 bus, and uses the same command queue for 
both
buses it caused simiar problems, but most of them were fixed in fixed in patch:

commit a00918d0521df1c7a2ec9143142a3ea998c8526d
usb: host: xhci: add mutex for non-thread-safe data

I quickly checked 3.19.4, but couldn't find the patch in there.

-Mathias
--
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]USB:OHCI: BugFix:Proper handling of ed_rm_list to handle race condition between usb_kill_urb() and finish_unlinks()

2015-08-10 Thread AMAN DEEP
There is a race condition between 
 finish_unlinks-finish_urb() function and 
 usb_kill_urb() in ohci controller case. The finish_urb 
 calls spin_unlock(ohci-lock) before 
 usb_hcd_giveback_urb() function call, then if during 
 this time, usb_kill_urb is called for another endpoint,
   then new ed will be added to ed_rm_list at beginning 
 for unlink. and ed_rm_list will point to newly added 
 ed.

When finish_urb() is completed in finish_unlinks() and
ed-td_list becomes empty as in below code (in finish_unlinks() function)
if (list_empty(ed-td_list)) {
*last = ed-ed_next;
ed-ed_next = NULL;
} else if (ohci-rh_state == OHCI_RH_RUNNING) {
*last = ed-ed_next;
ed-ed_next = NULL;
ed_schedule(ohci, ed);
}
*last = ed-ed_next will make ed_rm_list to point to ed-ed_next and
previously added ed by usb_kill_urb will be left unreferenced by
ed_rm_list. This causes usb_kill_urb() hang forever waiting for
finish_unlink to remove added ed from ed_rm_list.

The main reason for hang in this race condtion is addition and removal
of ed from ed_rm_list in the beginning during usb_kill_urb and later last*
is modified in finish_unlinks().
As suggested by Alan Stern, the solution for proper handling of
ohci-ed_rm_list is to remove ed from the ed_rm_list before finishing
any URBs. Then at the end, we can add ed back to the list if necessary.
This properly handle the updated ohci-ed_rm_list in
usb_kill_urb().

Fixes:977dcfdc6031(USB:OHCI:don't lose track of EDs when a
controller dies)

Acked-by: Alan Stern st...@rowland.harvard.edu

Signed-off-by: Aman Deep aman.d...@samsung.com
CC: sta...@vger.kernel.org
---
 drivers/usb/host/ohci-q.c |   17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index d029bbe..da878f3 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -1017,6 +1017,8 @@ skip_ed:
 * have modified this list.  normally it's just prepending
 * entries (which we'd ignore), but paranoia won't hurt.
 */
+   *last = ed-ed_next;
+   ed-ed_next = NULL;
modified = 0;
 
/* unlink urbs as requested, but rescan the list after
@@ -1075,21 +1077,22 @@ rescan_this:
goto rescan_this;
 
/*
-* If no TDs are queued, take ED off the ed_rm_list.
+* If no TDs are queued, ED is now idle.
 * Otherwise, if the HC is running, reschedule.
-* If not, leave it on the list for further dequeues.
+* If the HC isn't running, add ED back to the
+* start of the list for later processing.
 */
if (list_empty(ed-td_list)) {
-   *last = ed-ed_next;
-   ed-ed_next = NULL;
ed-state = ED_IDLE;
list_del(ed-in_use_list);
} else if (ohci-rh_state == OHCI_RH_RUNNING) {
-   *last = ed-ed_next;
-   ed-ed_next = NULL;
ed_schedule(ohci, ed);
} else {
-   last = ed-ed_next;
+   ed-ed_next = ohci-ed_rm_list;
+   ohci-ed_rm_list = ed;
+   /* Don't loop on the same ED */
+   if (last == ohci-ed_rm_list)
+   last = ed-ed_next;
}
 
if (modified)
-- 
1.7.9.5


[PATCH] usb: endpoint: convert spaces to tabs

2015-08-10 Thread Kris Borer
Fix one occurrence of the checkpatch error:

ERROR: code indent should use tabs where possible

Signed-off-by: Kris Borer kbo...@gmail.com
---
 drivers/usb/core/endpoint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 39a2402..101983b 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -51,7 +51,7 @@ static ssize_t wMaxPacketSize_show(struct device *dev,
 {
struct ep_device *ep = to_ep_device(dev);
return sprintf(buf, %04x\n,
-   usb_endpoint_maxp(ep-desc)  0x07ff);
+   usb_endpoint_maxp(ep-desc)  0x07ff);
 }
 static DEVICE_ATTR_RO(wMaxPacketSize);
 
-- 
1.9.1

--
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/4] USB: host: ohci-at91: move at91_usbh_data definition in c file

2015-08-10 Thread Alexandre Belloni
Move struct at91_usbh_data back in ohci-at91.c as this is the only user
left after switching all at91 platforms to DT only.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/usb/host/ohci-at91.c| 11 +++
 include/linux/platform_data/atmel.h | 12 
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 15df00cceed9..72dc4f9e2a0f 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -36,6 +36,17 @@
 #define hcd_to_ohci_at91_priv(h) \
((struct ohci_at91_priv *)hcd_to_ohci(h)-priv)
 
+#define AT91_MAX_USBH_PORTS3
+struct at91_usbh_data {
+   int vbus_pin[AT91_MAX_USBH_PORTS];  /* port power-control pin */
+   int overcurrent_pin[AT91_MAX_USBH_PORTS];
+   u8 ports;   /* number of ports on root hub 
*/
+   u8 overcurrent_supported;
+   u8 vbus_pin_active_low[AT91_MAX_USBH_PORTS];
+   u8 overcurrent_status[AT91_MAX_USBH_PORTS];
+   u8 overcurrent_changed[AT91_MAX_USBH_PORTS];
+};
+
 struct ohci_at91_priv {
struct clk *iclk;
struct clk *fclk;
diff --git a/include/linux/platform_data/atmel.h 
b/include/linux/platform_data/atmel.h
index 4b452c6a2f7b..527a85c61924 100644
--- a/include/linux/platform_data/atmel.h
+++ b/include/linux/platform_data/atmel.h
@@ -46,18 +46,6 @@ struct at91_cf_data {
 #define AT91_IDE_SWAP_A0_A20x02
 };
 
- /* USB Host */
-#define AT91_MAX_USBH_PORTS3
-struct at91_usbh_data {
-   int vbus_pin[AT91_MAX_USBH_PORTS];  /* port power-control 
pin */
-   int overcurrent_pin[AT91_MAX_USBH_PORTS];
-   u8  ports;  /* number of ports on 
root hub */
-   u8  overcurrent_supported;
-   u8  vbus_pin_active_low[AT91_MAX_USBH_PORTS];
-   u8  overcurrent_status[AT91_MAX_USBH_PORTS];
-   u8  overcurrent_changed[AT91_MAX_USBH_PORTS];
-};
-
  /* NAND / SmartMedia */
 struct atmel_nand_data {
int enable_pin; /* chip enable */
-- 
2.1.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 3/4] USB: host: ohci-at91: merge ohci_at91_of_init in ohci_hcd_at91_drv_probe

2015-08-10 Thread Alexandre Belloni
As device tree support is now mandatory, merge ohci_at91_of_init() in
ohci_hcd_at91_drv_probe().

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/usb/host/ohci-at91.c | 145 +++
 1 file changed, 63 insertions(+), 82 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 8e17d5ba26c6..cdd91c551c7b 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -449,16 +449,17 @@ static const struct of_device_id at91_ohci_dt_ids[] = {
 
 MODULE_DEVICE_TABLE(of, at91_ohci_dt_ids);
 
-static int ohci_at91_of_init(struct platform_device *pdev)
+/*-*/
+
+static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
 {
struct device_node *np = pdev-dev.of_node;
-   int i, gpio, ret;
-   enum of_gpio_flags flags;
struct at91_usbh_data   *pdata;
-   u32 ports;
-
-   if (!np)
-   return 0;
+   int i;
+   int gpio;
+   int ret;
+   enum of_gpio_flags  flags;
+   u32 ports;
 
/* Right now device-tree probed devices don't get dma_mask set.
 * Since shared usb code relies on it, set it here for now.
@@ -489,89 +490,69 @@ static int ohci_at91_of_init(struct platform_device *pdev)
 
pdev-dev.platform_data = pdata;
 
-   return 0;
-}
-
-/*-*/
-
-static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
-{
-   struct at91_usbh_data   *pdata;
-   int i;
-   int gpio;
-   int ret;
-
-   ret = ohci_at91_of_init(pdev);
-   if (ret)
-   return ret;
+   at91_for_each_port(i) {
+   /*
+* do not configure PIO if not in relation with
+* real USB port on board
+*/
+   if (i = pdata-ports) {
+   pdata-vbus_pin[i] = -EINVAL;
+   pdata-overcurrent_pin[i] = -EINVAL;
+   break;
+   }
 
-   pdata = dev_get_platdata(pdev-dev);
+   if (!gpio_is_valid(pdata-vbus_pin[i]))
+   continue;
+   gpio = pdata-vbus_pin[i];
 
-   if (pdata) {
-   at91_for_each_port(i) {
-   /*
-* do not configure PIO if not in relation with
-* real USB port on board
-*/
-   if (i = pdata-ports) {
-   pdata-vbus_pin[i] = -EINVAL;
-   pdata-overcurrent_pin[i] = -EINVAL;
-   break;
-   }
+   ret = gpio_request(gpio, ohci_vbus);
+   if (ret) {
+   dev_err(pdev-dev,
+   can't request vbus gpio %d\n, gpio);
+   continue;
+   }
+   ret = gpio_direction_output(gpio,
+   !pdata-vbus_pin_active_low[i]);
+   if (ret) {
+   dev_err(pdev-dev,
+   can't put vbus gpio %d as output %d\n,
+   gpio, !pdata-vbus_pin_active_low[i]);
+   gpio_free(gpio);
+   continue;
+   }
 
-   if (!gpio_is_valid(pdata-vbus_pin[i]))
-   continue;
-   gpio = pdata-vbus_pin[i];
+   ohci_at91_usb_set_power(pdata, i, 1);
+   }
 
-   ret = gpio_request(gpio, ohci_vbus);
-   if (ret) {
-   dev_err(pdev-dev,
-   can't request vbus gpio %d\n, gpio);
-   continue;
-   }
-   ret = gpio_direction_output(gpio,
-   !pdata-vbus_pin_active_low[i]);
-   if (ret) {
-   dev_err(pdev-dev,
-   can't put vbus gpio %d as output %d\n,
-   gpio, !pdata-vbus_pin_active_low[i]);
-   gpio_free(gpio);
-   continue;
-   }
+   at91_for_each_port(i) {
+   if (!gpio_is_valid(pdata-overcurrent_pin[i]))
+   continue;
+   gpio = pdata-overcurrent_pin[i];
 
-   ohci_at91_usb_set_power(pdata, i, 1);
+   ret = gpio_request(gpio, ohci_overcurrent);
+   if (ret) {
+   dev_err(pdev-dev,
+   

[PATCH 0/4] USB: host: ohci-at91: cleanups

2015-08-10 Thread Alexandre Belloni
Hi,

Here are a few cleanups for ohci-at91. This is the fallout of AT91 now being DT
only.

Alexandre Belloni (4):
  USB: host: ohci-at91: move at91_usbh_data definition in c file
  USB: host: ohci-at91: depend on OF
  USB: host: ohci-at91: merge ohci_at91_of_init in
ohci_hcd_at91_drv_probe
  USB: host: ohci-at91: merge loops in ohci_hcd_at91_drv_probe

 drivers/usb/host/Kconfig|   8 +-
 drivers/usb/host/ohci-at91.c| 179 
 include/linux/platform_data/atmel.h |  12 ---
 3 files changed, 85 insertions(+), 114 deletions(-)

-- 
2.1.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 4/4] USB: host: ohci-at91: merge loops in ohci_hcd_at91_drv_probe

2015-08-10 Thread Alexandre Belloni
ohci_hcd_at91_drv_probe() has four at91_for_each_port. They can be merged
into two loops without changing the driver behaviour.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/usb/host/ohci-at91.c | 34 --
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index cdd91c551c7b..342ffd140122 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -477,33 +477,21 @@ static int ohci_hcd_at91_drv_probe(struct platform_device 
*pdev)
pdata-ports = ports;
 
at91_for_each_port(i) {
-   gpio = of_get_named_gpio_flags(np, atmel,vbus-gpio, i, 
flags);
-   pdata-vbus_pin[i] = gpio;
-   if (!gpio_is_valid(gpio))
-   continue;
-   pdata-vbus_pin_active_low[i] = flags  OF_GPIO_ACTIVE_LOW;
-   }
-
-   at91_for_each_port(i)
-   pdata-overcurrent_pin[i] =
-   of_get_named_gpio_flags(np, atmel,oc-gpio, i, flags);
-
-   pdev-dev.platform_data = pdata;
-
-   at91_for_each_port(i) {
/*
 * do not configure PIO if not in relation with
 * real USB port on board
 */
if (i = pdata-ports) {
pdata-vbus_pin[i] = -EINVAL;
-   pdata-overcurrent_pin[i] = -EINVAL;
-   break;
+   continue;
}
 
-   if (!gpio_is_valid(pdata-vbus_pin[i]))
+   gpio = of_get_named_gpio_flags(np, atmel,vbus-gpio, i,
+  flags);
+   pdata-vbus_pin[i] = gpio;
+   if (!gpio_is_valid(gpio))
continue;
-   gpio = pdata-vbus_pin[i];
+   pdata-vbus_pin_active_low[i] = flags  OF_GPIO_ACTIVE_LOW;
 
ret = gpio_request(gpio, ohci_vbus);
if (ret) {
@@ -525,6 +513,14 @@ static int ohci_hcd_at91_drv_probe(struct platform_device 
*pdev)
}
 
at91_for_each_port(i) {
+   if (i = pdata-ports) {
+   pdata-overcurrent_pin[i] = -EINVAL;
+   continue;
+   }
+
+   pdata-overcurrent_pin[i] =
+   of_get_named_gpio_flags(np, atmel,oc-gpio, i, flags);
+
if (!gpio_is_valid(pdata-overcurrent_pin[i]))
continue;
gpio = pdata-overcurrent_pin[i];
@@ -556,6 +552,8 @@ static int ohci_hcd_at91_drv_probe(struct platform_device 
*pdev)
}
}
 
+   pdev-dev.platform_data = pdata;
+
device_init_wakeup(pdev-dev, 1);
return usb_hcd_at91_probe(ohci_at91_hc_driver, pdev);
 }
-- 
2.1.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/4] USB: host: ohci-at91: depend on OF

2015-08-10 Thread Alexandre Belloni
Make the driver depend on CONFIG_OF and remove the now useless #ifdef

Also, fix the Kconfig indentation.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/usb/host/Kconfig | 8 
 drivers/usb/host/ohci-at91.c | 9 +
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 8afc3c1efdab..7ef56faf09bb 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -441,10 +441,10 @@ config USB_OHCI_HCD_PXA27X
  PXA27x/PXA3xx chips.
 
 config USB_OHCI_HCD_AT91
-tristate Support for Atmel on-chip OHCI USB controller
-depends on USB_OHCI_HCD  ARCH_AT91
-default y
----help---
+   tristate Support for Atmel on-chip OHCI USB controller
+   depends on USB_OHCI_HCD  ARCH_AT91  OF
+   default y
+   ---help---
   Enables support for the on-chip OHCI controller on
   Atmel chips.
 
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 72dc4f9e2a0f..8e17d5ba26c6 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -442,7 +442,6 @@ static irqreturn_t ohci_hcd_at91_overcurrent_irq(int irq, 
void *data)
return IRQ_HANDLED;
 }
 
-#ifdef CONFIG_OF
 static const struct of_device_id at91_ohci_dt_ids[] = {
{ .compatible = atmel,at91rm9200-ohci },
{ /* sentinel */ }
@@ -492,12 +491,6 @@ static int ohci_at91_of_init(struct platform_device *pdev)
 
return 0;
 }
-#else
-static int ohci_at91_of_init(struct platform_device *pdev)
-{
-   return 0;
-}
-#endif
 
 /*-*/
 
@@ -684,7 +677,7 @@ static struct platform_driver ohci_hcd_at91_driver = {
.driver = {
.name   = at91_ohci,
.pm = ohci_hcd_at91_pm_ops,
-   .of_match_table = of_match_ptr(at91_ohci_dt_ids),
+   .of_match_table = at91_ohci_dt_ids,
},
 };
 
-- 
2.1.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