[GIT PULL] USB fixes for 5.3-rc2

2019-07-28 Thread Greg KH
The following changes since commit 5f9e832c137075045d15cd6899ab0505cfb2ca4b:

  Linus 5.3-rc1 (2019-07-21 14:05:38 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git tags/usb-5.3-rc2

for you to fetch changes up to d39b5bad8658d6d94cb2d98a44a7e159db4f5030:

  xhci: Fix crash if scatter gather is used with Immediate Data Transfer (IDT). 
(2019-07-25 11:26:42 +0200)


USB fixes for 5.3-rc2

Here are some small fixes for 5.3-rc2.  All of these resolve some
reported issues, some more than others :)

Included in here is:
- xhci fix for an annoying issue with odd devices
- reversion of some usb251xb patches that should not have been
  merged
- usb pci quirk additions and fixups
- usb storage fix
- usb host controller error test fix

All of these have been in linux-next with no reported issues.

Signed-off-by: Greg Kroah-Hartman 


Dan Carpenter (1):
  usb/hcd: Fix a NULL vs IS_ERR() bug in usb_hcd_setup_local_mem()

Lucas Stach (3):
  Revert "usb: usb251xb: Add US lanes inversion dts-bindings"
  Revert "usb: usb251xb: Add US port lanes inversion property"
  usb: usb251xb: Reallow swap-dx-lanes to apply to the upstream port

Mathias Nyman (1):
  xhci: Fix crash if scatter gather is used with Immediate Data Transfer 
(IDT).

Phong Tran (1):
  usb: wusbcore: fix unbalanced get/put cluster_id

Ryan Kennedy (2):
  usb: pci-quirks: Correct AMD PLL quirk detection
  usb: pci-quirks: Minor cleanup for AMD PLL quirk

Yoshihiro Shimoda (1):
  usb-storage: Add a limitation for blk_queue_max_hw_sectors()

 Documentation/devicetree/bindings/usb/usb251xb.txt |  6 +--
 drivers/usb/core/hcd.c |  4 +-
 drivers/usb/host/ehci-pci.c|  4 +-
 drivers/usb/host/hwa-hc.c  |  2 +-
 drivers/usb/host/ohci-pci.c|  2 +-
 drivers/usb/host/pci-quirks.c  | 45 +-
 drivers/usb/host/pci-quirks.h  |  2 +-
 drivers/usb/host/xhci-pci.c|  2 +-
 drivers/usb/host/xhci.h|  3 +-
 drivers/usb/misc/usb251xb.c| 15 
 drivers/usb/storage/scsiglue.c | 11 ++
 11 files changed, 57 insertions(+), 39 deletions(-)


Re: [PATCH AUTOSEL 5.1 054/141] usb: gadget: storage: Remove warning message

2019-07-28 Thread Sasha Levin

On Fri, Jul 19, 2019 at 05:27:31AM +, Thinh Nguyen wrote:

Hi Sasha,

Sasha Levin wrote:

From: EJ Hsu 

[ Upstream commit e70b3f5da00119e057b7faa557753fee7f786f17 ]

This change is to fix below warning message in following scenario:
usb_composite_setup_continue: Unexpected call

When system tried to enter suspend, the fsg_disable() will be called to
disable fsg driver and send a signal to fsg_main_thread. However, at
this point, the fsg_main_thread has already been frozen and can not
respond to this signal. So, this signal will be pended until
fsg_main_thread wakes up.

Once system resumes from suspend, fsg_main_thread will detect a signal
pended and do some corresponding action (in handle_exception()). Then,
host will send some setup requests (get descriptor, set configuration...)
to UDC driver trying to enumerate this device. During the handling of "set
configuration" request, it will try to sync up with fsg_main_thread by
sending a signal (which is the same as the signal sent by fsg_disable)
to it. In a similar manner, once the fsg_main_thread receives this
signal, it will call handle_exception() to handle the request.

However, if the fsg_main_thread wakes up from suspend a little late and
"set configuration" request from Host arrives a little earlier,
fsg_main_thread might come across the request from "set configuration"
when it handles the signal from fsg_disable(). In this case, it will
handle this request as well. So, when fsg_main_thread tries to handle
the signal sent from "set configuration" later, there will nothing left
to do and warning message "Unexpected call" is printed.

Acked-by: Alan Stern 
Signed-off-by: EJ Hsu 
Signed-off-by: Felipe Balbi 
Signed-off-by: Sasha Levin 
---
 drivers/usb/gadget/function/f_mass_storage.c | 21 ++--
 drivers/usb/gadget/function/storage_common.h |  1 +
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
b/drivers/usb/gadget/function/f_mass_storage.c
index 043f97ad8f22..982c3e89eb0d 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c



This patch may have issue. It was reverted upstream. Please don't queue
to stable.


I've dropped it, thanks!

--
Thanks,
Sasha


Re: [PATCH v2 1/2] usb: core: phy: add support for PHY calibration

2019-07-28 Thread Jochen Sprickerhof

Hi Marek,

thanks for working on this!

Tested on my XU4
Tested-by: Jochen Sprickerhof 

* Anand Moon  [2019-07-23 00:30]:

Hi Marek,

On Fri, 19 Jul 2019 at 13:43, Marek Szyprowski  wrote:


Some PHYs (for example Exynos5 USB3.0 DRD PHY) require calibration to be
done after every USB HCD reset. Generic PHY framework has been already
extended with phy_calibrate() function in commit 36914111e682 ("drivers:
phy: add calibrate method"). This patch adds support for it to generic
PHY handling code in USB HCD core.



Tested on my XU3 / XU4 / HC1
Tested-by: Anand Moon 



Signed-off-by: Marek Szyprowski 
---
 drivers/usb/core/hcd.c |  7 +++
 drivers/usb/core/phy.c | 21 +
 drivers/usb/core/phy.h |  1 +
 3 files changed, 29 insertions(+)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 88533938ce19..b89936c1df23 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2291,6 +2291,9 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t 
msg)
hcd->state = HC_STATE_RESUMING;
status = hcd->driver->bus_resume(hcd);
clear_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags);
+   if (status == 0)
+   status = usb_phy_roothub_calibrate(hcd->phy_roothub);
+
if (status == 0) {
struct usb_device *udev;
int port1;
@@ -2864,6 +2867,10 @@ int usb_add_hcd(struct usb_hcd *hcd,
}
hcd->rh_pollable = 1;

+   retval = usb_phy_roothub_calibrate(hcd->phy_roothub);
+   if (retval)
+   goto err_hcd_driver_setup;
+
/* NOTE: root hub and controller capabilities may not be the same */
if (device_can_wakeup(hcd->self.controller)
&& device_can_wakeup(&hcd->self.root_hub->dev))
diff --git a/drivers/usb/core/phy.c b/drivers/usb/core/phy.c
index 7580493b867a..fb1588e7c282 100644
--- a/drivers/usb/core/phy.c
+++ b/drivers/usb/core/phy.c
@@ -151,6 +151,27 @@ int usb_phy_roothub_set_mode(struct usb_phy_roothub 
*phy_roothub,
 }
 EXPORT_SYMBOL_GPL(usb_phy_roothub_set_mode);

+int usb_phy_roothub_calibrate(struct usb_phy_roothub *phy_roothub)
+{
+   struct usb_phy_roothub *roothub_entry;
+   struct list_head *head;
+   int err;
+
+   if (!phy_roothub)
+   return 0;
+
+   head = &phy_roothub->list;
+
+   list_for_each_entry(roothub_entry, head, list) {
+   err = phy_calibrate(roothub_entry->phy);
+   if (err)
+   return err;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(usb_phy_roothub_calibrate);
+
 int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub)
 {
struct usb_phy_roothub *roothub_entry;
diff --git a/drivers/usb/core/phy.h b/drivers/usb/core/phy.h
index dad564e2d2d4..20a267cd986b 100644
--- a/drivers/usb/core/phy.h
+++ b/drivers/usb/core/phy.h
@@ -18,6 +18,7 @@ int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub);

 int usb_phy_roothub_set_mode(struct usb_phy_roothub *phy_roothub,
 enum phy_mode mode);
+int usb_phy_roothub_calibrate(struct usb_phy_roothub *phy_roothub);
 int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub);
 void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub);

--
2.17.1





signature.asc
Description: PGP signature


Re: [PATCH v2 2/2] usb: dwc3: remove generic PHY calibrate() calls

2019-07-28 Thread Jochen Sprickerhof

Hi Marek,

Tested on my XU4
Tested-by: Jochen Sprickerhof 

* Anand Moon  [2019-07-23 00:30]:

Hi Marek,

On Fri, 19 Jul 2019 at 13:43, Marek Szyprowski  wrote:


Calls to USB2 generic PHY calibrate() method has been moved to HCD core,
which now successfully handles generic PHYs and their calibration after
every HCD reset. This fixes all the timing issues related to PHY
calibration done directly from DWC3 driver: incorrect operation after
system suspend/resume or USB3.0 detection failure when XHCI-plat driver
compiled as separate module.



Tested on my XU3 / XU4 / HC1
Tested-by: Anand Moon 



Signed-off-by: Marek Szyprowski 
---
 drivers/usb/dwc3/core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index c9bb93a2c81e..7dd6d419254d 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -168,7 +168,6 @@ static void __dwc3_set_mode(struct work_struct *work)
otg_set_vbus(dwc->usb2_phy->otg, true);
phy_set_mode(dwc->usb2_generic_phy, PHY_MODE_USB_HOST);
phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_HOST);
-   phy_calibrate(dwc->usb2_generic_phy);
}
break;
case DWC3_GCTL_PRTCAP_DEVICE:
@@ -1166,7 +1165,6 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
dev_err(dev, "failed to initialize host\n");
return ret;
}
-   phy_calibrate(dwc->usb2_generic_phy);
break;
case USB_DR_MODE_OTG:
INIT_WORK(&dwc->drd_work, __dwc3_set_mode);
--
2.17.1





signature.asc
Description: PGP signature


Re: [GIT PULL] USB fixes for 5.3-rc2

2019-07-28 Thread pr-tracker-bot
The pull request you sent on Sun, 28 Jul 2019 13:59:28 +0200:

> git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git tags/usb-5.3-rc2

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/29af915cabd4d51a2306008f84ee447f3a0d4e8f

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


[PATCH] usb: phy: ab8500-usb: Mark expected switch fall-throughs

2019-07-28 Thread Gustavo A. R. Silva
Mark switch cases where we are expecting to fall through.

This patch fixes the following warnings:

drivers/usb/phy/phy-ab8500-usb.c: In function 'ab8500_usb_link_status_update':
drivers/usb/phy/phy-ab8500-usb.c:424:9: warning: this statement may fall 
through [-Wimplicit-fallthrough=]
   event = UX500_MUSB_RIDB;
   ~~^
drivers/usb/phy/phy-ab8500-usb.c:425:2: note: here
  case USB_LINK_NOT_CONFIGURED_8500:
  ^~~~
drivers/usb/phy/phy-ab8500-usb.c:440:9: warning: this statement may fall 
through [-Wimplicit-fallthrough=]
   event = UX500_MUSB_RIDC;
   ~~^
drivers/usb/phy/phy-ab8500-usb.c:441:2: note: here
  case USB_LINK_STD_HOST_NC_8500:
  ^~~~
drivers/usb/phy/phy-ab8500-usb.c:459:9: warning: this statement may fall 
through [-Wimplicit-fallthrough=]
   event = UX500_MUSB_RIDA;
   ~~^
drivers/usb/phy/phy-ab8500-usb.c:460:2: note: here
  case USB_LINK_HM_IDGND_8500:
  ^~~~
drivers/usb/phy/phy-ab8500-usb.c: In function 'ab8505_usb_link_status_update':
drivers/usb/phy/phy-ab8500-usb.c:332:9: warning: this statement may fall 
through [-Wimplicit-fallthrough=]
   event = UX500_MUSB_RIDB;
   ~~^
drivers/usb/phy/phy-ab8500-usb.c:333:2: note: here
  case USB_LINK_NOT_CONFIGURED_8505:
  ^~~~
drivers/usb/phy/phy-ab8500-usb.c:352:9: warning: this statement may fall 
through [-Wimplicit-fallthrough=]
   event = UX500_MUSB_RIDC;
   ~~^
drivers/usb/phy/phy-ab8500-usb.c:353:2: note: here
  case USB_LINK_STD_HOST_NC_8505:
  ^~~~
drivers/usb/phy/phy-ab8500-usb.c:370:9: warning: this statement may fall 
through [-Wimplicit-fallthrough=]
   event = UX500_MUSB_RIDA;
   ~~^
drivers/usb/phy/phy-ab8500-usb.c:371:2: note: here
  case USB_LINK_HM_IDGND_8505:
  ^~~~

Reported-by: Stephen Rothwell 
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/usb/phy/phy-ab8500-usb.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index aaf363f19714..14b432982fd3 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -330,6 +330,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb 
*ab,
switch (lsts) {
case USB_LINK_ACA_RID_B_8505:
event = UX500_MUSB_RIDB;
+   /* Fall through */
case USB_LINK_NOT_CONFIGURED_8505:
case USB_LINK_RESERVED0_8505:
case USB_LINK_RESERVED1_8505:
@@ -350,6 +351,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb 
*ab,
 
case USB_LINK_ACA_RID_C_NM_8505:
event = UX500_MUSB_RIDC;
+   /* Fall through */
case USB_LINK_STD_HOST_NC_8505:
case USB_LINK_STD_HOST_C_NS_8505:
case USB_LINK_STD_HOST_C_S_8505:
@@ -368,6 +370,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb 
*ab,
case USB_LINK_ACA_RID_A_8505:
case USB_LINK_ACA_DOCK_CHGR_8505:
event = UX500_MUSB_RIDA;
+   /* Fall through */
case USB_LINK_HM_IDGND_8505:
if (ab->mode == USB_IDLE) {
ab->mode = USB_HOST;
@@ -422,6 +425,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb 
*ab,
switch (lsts) {
case USB_LINK_ACA_RID_B_8500:
event = UX500_MUSB_RIDB;
+   /* Fall through */
case USB_LINK_NOT_CONFIGURED_8500:
case USB_LINK_NOT_VALID_LINK_8500:
ab->mode = USB_IDLE;
@@ -438,6 +442,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb 
*ab,
case USB_LINK_ACA_RID_C_HS_8500:
case USB_LINK_ACA_RID_C_HS_CHIRP_8500:
event = UX500_MUSB_RIDC;
+   /* Fall through */
case USB_LINK_STD_HOST_NC_8500:
case USB_LINK_STD_HOST_C_NS_8500:
case USB_LINK_STD_HOST_C_S_8500:
@@ -457,6 +462,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb 
*ab,
 
case USB_LINK_ACA_RID_A_8500:
event = UX500_MUSB_RIDA;
+   /* Fall through */
case USB_LINK_HM_IDGND_8500:
if (ab->mode == USB_IDLE) {
ab->mode = USB_HOST;
-- 
2.22.0



[PATCH v1] usb: dwc3: remove the call trace of USBx_GFLADJ

2019-07-28 Thread Yinbo Zhu
layerscape board sometimes reported some usb call trace, that is due to
kernel sent LPM tokerns automatically when it has no pending transfers
and think that the link is idle enough to enter L1, which procedure will
ask usb register has a recovery,then kernel will compare USBx_GFLADJ and
set GFLADJ_30MHZ, GFLADJ_30MHZ_REG until GFLADJ_30MHZ is equal 0x20, if
the conditions were met then issue occur, but whatever the conditions
whether were met that usb is all need keep GFLADJ_30MHZ of value is 0x20
(xhci spec ask use GFLADJ_30MHZ to adjust any offset from clock source
that generates the clock that drives the SOF counter, 0x20 is default
value of it)That is normal logic, so need remove the call trace.

Signed-off-by: Yinbo Zhu 
---
 drivers/usb/dwc3/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 98bce85c29d0..a133d8490322 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -300,8 +300,7 @@ static void dwc3_frame_length_adjustment(struct dwc3 *dwc)
 
reg = dwc3_readl(dwc->regs, DWC3_GFLADJ);
dft = reg & DWC3_GFLADJ_30MHZ_MASK;
-   if (!dev_WARN_ONCE(dwc->dev, dft == dwc->fladj,
-   "request value same as default, ignoring\n")) {
+   if (dft != dwc->fladj) {
reg &= ~DWC3_GFLADJ_30MHZ_MASK;
reg |= DWC3_GFLADJ_30MHZ_SDBND_SEL | dwc->fladj;
dwc3_writel(dwc->regs, DWC3_GFLADJ, reg);
-- 
2.17.1