Re: [PATCH v13 06/12] usb: xhci: use bus->sysdev for DMA configuration

2017-02-13 Thread Alexander Sverdlin
Hi!

On 11/02/17 02:27, Peter Chen wrote:
> For xhci-hcd platform device, all the DMA parameters are not
> configured properly, notably dma ops for dwc3 devices. So, set
> the dma for xhci from sysdev. sysdev is pointing to device that
> is known to the system firmware or hardware.
> 
> Cc: Baolin Wang 
> Cc: Vivek Gautam 
> Cc: Alexander Sverdlin 
> Cc: Mathias Nyman 
> 
> Signed-off-by: Arnd Bergmann 
> Signed-off-by: Sriram Dash 
> ---
> Hi, Baolin, Vivek and Alexander,
> I removed your tested-by tag due to add one change that adding sysdev
> for shared hcd too, if your test shows this change works for you or
> has no effect for you, please consider adding tested-by tag again,
> thanks.

This was exactly the missing/requiring part in your patch for my case.
I had to add it extra for the first test.
So, again, here is my
Tested-by: Alexander Sverdlin 

>  drivers/usb/host/xhci-mem.c  | 12 ++--
>  drivers/usb/host/xhci-plat.c | 35 +++
>  drivers/usb/host/xhci.c  | 15 +++
>  3 files changed, 44 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> index ba1853f4..032a702 100644
> --- a/drivers/usb/host/xhci-mem.c
> +++ b/drivers/usb/host/xhci-mem.c
> @@ -586,7 +586,7 @@ static void xhci_free_stream_ctx(struct xhci_hcd *xhci,
>   unsigned int num_stream_ctxs,
>   struct xhci_stream_ctx *stream_ctx, dma_addr_t dma)
>  {
> - struct device *dev = xhci_to_hcd(xhci)->self.controller;
> + struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
>   size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs;
>  
>   if (size > MEDIUM_STREAM_ARRAY_SIZE)
> @@ -614,7 +614,7 @@ static struct xhci_stream_ctx 
> *xhci_alloc_stream_ctx(struct xhci_hcd *xhci,
>   unsigned int num_stream_ctxs, dma_addr_t *dma,
>   gfp_t mem_flags)
>  {
> - struct device *dev = xhci_to_hcd(xhci)->self.controller;
> + struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
>   size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs;
>  
>   if (size > MEDIUM_STREAM_ARRAY_SIZE)
> @@ -1686,7 +1686,7 @@ void xhci_slot_copy(struct xhci_hcd *xhci,
>  static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
>  {
>   int i;
> - struct device *dev = xhci_to_hcd(xhci)->self.controller;
> + struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
>   int num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2);
>  
>   xhci_dbg_trace(xhci, trace_xhci_dbg_init,
> @@ -1758,7 +1758,7 @@ static void scratchpad_free(struct xhci_hcd *xhci)
>  {
>   int num_sp;
>   int i;
> - struct device *dev = xhci_to_hcd(xhci)->self.controller;
> + struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
>  
>   if (!xhci->scratchpad)
>   return;
> @@ -1831,7 +1831,7 @@ void xhci_free_command(struct xhci_hcd *xhci,
>  
>  void xhci_mem_cleanup(struct xhci_hcd *xhci)
>  {
> - struct device   *dev = xhci_to_hcd(xhci)->self.controller;
> + struct device   *dev = xhci_to_hcd(xhci)->self.sysdev;
>   int size;
>   int i, j, num_ports;
>  
> @@ -2373,7 +2373,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd 
> *xhci, gfp_t flags)
>  int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
>  {
>   dma_addr_t  dma;
> - struct device   *dev = xhci_to_hcd(xhci)->self.controller;
> + struct device   *dev = xhci_to_hcd(xhci)->self.sysdev;
>   unsigned intval, val2;
>   u64 val_64;
>   struct xhci_segment *seg;
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 6d33b42..4ecb3fd 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -14,6 +14,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -148,6 +149,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
>  {
>   const struct of_device_id *match;
>   const struct hc_driver  *driver;
> + struct device   *sysdev;
>   struct xhci_hcd *xhci;
>   struct resource *res;
>   struct usb_hcd  *hcd;
> @@ -164,22 +166,39 @@ static int xhci_plat_probe(struct platform_device *pdev)
>   if (irq < 0)
>   return -ENODEV;
>  
> + /*
> +  * sysdev must point to a device that is known to the system firmware
> +  * or PCI hardware. We handle these three cases here:
> +  * 1. xhci_plat comes from firmware
> +  * 2. xhci_plat is child of a device from firmware (dwc3-plat)
> +  * 3. xhci_plat is grandchild of a pci device (dwc3-pci)
> +  */
> + sysdev = &pdev->dev;
> + if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
> + sysdev = sysdev->parent;
> +#ifdef CONFIG_PCI
> + else if (sysdev->parent && sysdev->parent->parent &&
> +  sysdev->parent->parent->bus == &pci_bus_type)
> + s

[PATCH 1/1] extcon: ext-usb-gpio: do not enable USB as wakeup source by default

2017-02-13 Thread Peter Chen
Whether the USB port as a wakeup source should be determined by user,
but not enabled by default.

Signed-off-by: Peter Chen 
---
 drivers/extcon/extcon-usb-gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c
index a5e1882..66c749d 100644
--- a/drivers/extcon/extcon-usb-gpio.c
+++ b/drivers/extcon/extcon-usb-gpio.c
@@ -195,7 +195,7 @@ static int usb_extcon_probe(struct platform_device *pdev)
}
 
platform_set_drvdata(pdev, info);
-   device_init_wakeup(dev, true);
+   device_set_wakeup_capable(&pdev->dev, true);
 
/* Perform initial detection */
usb_extcon_detect_cable(&info->wq_detcable.work);
-- 
2.7.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: serial: ftdi_sio: add device ID for Microsemi/Arrow SF2PLUS Dev Kit

2017-02-13 Thread Johan Hovold
[+CC: linux-usb]

Always make sure to CC linux-usb for USB patches.

On Fri, Feb 10, 2017 at 05:16:12PM +0100, Marek Vasut wrote:
> This development kit has an FT4232 on it with a custom USB VID/PID.
> The FT4232 provides four UARTs, but only two are used. The UART 0
> is used by the FlashPro5 programmer and UART 2 is connected to the
> SmartFusion2 CortexM3 SoC UART port.

Don't you want to use the "jtag" quirk for this one then to prevent the
driver from binding to interface 0? Or do you still need this interface
to be accessible as a tty device?

> Note that the USB VID is registered to Actel according to Linux USB
> VID database, but that was acquired by Microsemi.
> 
> Signed-off-by: Marek Vasut 
> Cc: stable 
> Cc: Johan Hovold 
> ---
>  drivers/usb/serial/ftdi_sio.c |  1 +
>  drivers/usb/serial/ftdi_sio_ids.h | 10 ++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
> index c98cf10be5af..14f0fb34f655 100644
> --- a/drivers/usb/serial/ftdi_sio.c
> +++ b/drivers/usb/serial/ftdi_sio.c
> @@ -873,6 +873,7 @@ static const struct usb_device_id id_table_combined[] = {
>   { USB_DEVICE_AND_INTERFACE_INFO(MICROCHIP_VID, MICROCHIP_USB_BOARD_PID,
>   USB_CLASS_VENDOR_SPEC,
>   USB_SUBCLASS_VENDOR_SPEC, 0x00) },
> + { USB_DEVICE(ACTEL_VID, MICROSEMI_ARROW_SF2PLUS_BOARD_PID) },
>   { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) },
>   { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID),
>   .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
> diff --git a/drivers/usb/serial/ftdi_sio_ids.h 
> b/drivers/usb/serial/ftdi_sio_ids.h
> index 168ccb03ce08..a9d538d18344 100644
> --- a/drivers/usb/serial/ftdi_sio_ids.h
> +++ b/drivers/usb/serial/ftdi_sio_ids.h
> @@ -627,6 +627,16 @@
>  #define MICROCHIP_USB_BOARD_PID  0x000A /* CDC RS-232 Emulation Demo */
>  
>  /*
> + * Microsemi/Arrow SF2PLUS Dev Kit
> + *
> + * This board has an FT4232 on it which provides four UART ports.
> + * UART 0 is used by the FlashPro5 programmer, UART 2 is connected
> + * to the UART of an CortexM3 SoC-FPGA on the board.
> + */
> +#define ACTEL_VID0x1514
> +#define MICROSEMI_ARROW_SF2PLUS_BOARD_PID0x2008
> +

Please place this before the Olimex section to try to maintain some
order based on VID.

> +/*
>   * RATOC REX-USB60F
>   */
>  #define RATOC_VENDOR_ID  0x0584

Thanks,
Johan
--
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: How to resolve "Waited 2000ms for CONNECT" in system resuming?

2017-02-13 Thread Yoshihiro Shimoda
Hi Alan,

> From: Alan Stern
> Sent: Friday, February 10, 2017 12:28 AM
> 
> On Thu, 9 Feb 2017, Yoshihiro Shimoda wrote:
> 
> >
> > > From: Alan Stern
> > > Sent: Thursday, February 09, 2017 12:39 AM
> > > On Wed, 8 Feb 2017, Yoshihiro Shimoda wrote:

< snip >

> > I checked the ehci_handover_companion_ports().
> > If I used a USB full speed hub, the !udev->maxchild in
> > the persist_enabled_on_companion() was 0.
> > Then, ehci_handover_companion_ports() didn't call ehci_hub_control().
> > Is this expected behavior?
> >
> > static int persist_enabled_on_companion(struct usb_device *udev, void 
> > *unused)
> > {
> > return !udev->maxchild && udev->persist_enabled &&
> > udev->bus->root_hub->speed < USB_SPEED_HIGH;
> > }
> 
> Ah.  Yes, it is the desired behavior.  The idea is to skip switching
> the ports back to the companion if the only USB-1.1 devices with
> persist_enabled are hubs.  It doesn't matter if a hub gets disconnected
> temporarily and then reconnected.

Thank you for the detail. I got it.

> > If I used a USB full/low speed device, the ehci_handover_companion_ports()
> > called ehci_hub_control() and rans the following as well. However, OHCI 
> > didn't
> > detect the connection. So, I need to investigate this issue more.
> > if (status & PORT_OWNER)
> > ehci_writel(ehci, status | PORT_CSC, reg);
> 
> So the port _does_ get switched over to the companion controller, but
> for some unknown reason the companion controller doesn't detect the
> connection.  Perhaps this happens because
> ehci_handover_companion_ports() runs before the OHCI controller gets
> reinitialized -- I noticed this in the log you posted before.
> 
> Hmmm.  You're using platform drivers for OHCI and EHCI, not PCI,

Yes, I'm using platform drivers for OHCI and EHCI.

> right?  The resume_common() routine in drivers/usb/core/hcd-pci.c is
> careful to resume things in the correct order.  It contains this code:
> 
>   /*
>* Only EHCI controllers have to wait for their companions.
>* No locking is needed because PCI controller drivers do not
>* get unbound during system resume.
>*/
>   if (pci_dev->class == CL_EHCI && event != PM_EVENT_AUTO_RESUME)
>   for_each_companion(pci_dev, hcd,
>   ehci_wait_for_companions);
> 
> Probably the equivalent routine in the platform driver needs to do the
> same sort of thing.  This means it needs to know about companion
> controllers.

Thank you very much for this information!
If I added the following code, the issue disappeared:
 - The ehci-platform.c calls device_enable_async_suspend(hcd->self.controller)
   in ehci_platform_probe()
 - [This is a dirty code, but] hcd_bus_resume() calls device_pm_wait_for_dev(
   rhdev->bus->controller, ohci_dev)

I will consider how to implement such a code for [eo]hci-platform drivers.
Especially, like ehci_{pre,post}_add() for platform drivers are needed, I think.

Best regards,
Yoshihiro Shimoda

> 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] usb: misc: usbtest: remove redundant check on retval < 0

2017-02-13 Thread Peter Chen
On Sun, Feb 12, 2017 at 06:35:18PM +, Colin King wrote:
> From: Colin Ian King 
> 
> The check for retval being less than zero is always true since
> retval equal to -EPIPE at that point.  Replace the existing
> conditional with just return retval.
> 
> Detected with CoverityScan, CID#114349 ("Logically dead code")
> 
> Signed-off-by: Colin Ian King 
> ---
>  drivers/usb/misc/usbtest.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
> index 3525626..17c0810 100644
> --- a/drivers/usb/misc/usbtest.c
> +++ b/drivers/usb/misc/usbtest.c
> @@ -992,7 +992,7 @@ static int ch9_postconfig(struct usbtest_dev *dev)
>   dev_err(&iface->dev,
>   "hs dev qualifier --> %d\n",
>   retval);
> - return (retval < 0) ? retval : -EDOM;
> + return retval;
>   }
>   /* usb2.0 but not high-speed capable; fine */
>   } else if (retval != sizeof(struct usb_qualifier_descriptor)) {

Reviewed-by: Peter Chen 

-- 

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] USB: serial: upd78f0730: Add ID for EVAL-ADXL362Z

2017-02-13 Thread Johan Hovold
On Fri, Feb 10, 2017 at 02:53:42PM +0300, Maksim Salau wrote:
> The adaptor on Analog Devices EVAL-ADXL362Z development board is used
> to flash and debug firmware of on-board Renesas RL78/G13 MCU.
> 
> Signed-off-by: Maksim Salau 
> ---
> 
> I have no access to such board to test the change, but the VID/PID pair
> is found in same Windows driver package.
> The stock firmware uses baudrate 153600 bps.

That's fine, but you need to mention that you're also adding a new baud
rate in the commit message.

Thanks,
Johan
--
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: misc: usbtest: remove redundant check on retval < 0

2017-02-13 Thread Felipe Balbi

Hi,

Colin King  writes:
> From: Colin Ian King 
>
> The check for retval being less than zero is always true since
> retval equal to -EPIPE at that point.  Replace the existing
> conditional with just return retval.
>
> Detected with CoverityScan, CID#114349 ("Logically dead code")
>
> Signed-off-by: Colin Ian King 
> ---
>  drivers/usb/misc/usbtest.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
> index 3525626..17c0810 100644
> --- a/drivers/usb/misc/usbtest.c
> +++ b/drivers/usb/misc/usbtest.c
> @@ -992,7 +992,7 @@ static int ch9_postconfig(struct usbtest_dev *dev)
>   dev_err(&iface->dev,
>   "hs dev qualifier --> %d\n",
>   retval);
> - return (retval < 0) ? retval : -EDOM;
> + return retval;

you're changing return value here, are you sure there's nothing else
depending on this error?

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 1/2] fs: configfs: make qw_sign attribute symmetric

2017-02-13 Thread Felipe Balbi

Hi,

Stefan Agner  writes:
>>> On Thu, Feb 09, 2017 at 10:04:43AM -0800, Stefan Agner wrote:
 On 2017-02-01 08:59, Stefan Agner wrote:
 > On 2017-02-01 00:06, Greg KH wrote:
 >> On Tue, Jan 31, 2017 at 06:19:16PM -0800, Stefan Agner wrote:
 >>> Currently qw_sign requires UTF-8 character to set, but returns UTF-16
 >>> when read. This isn't obvious when simply using cat since the null
 >>> characters are not visible, but hexdump unveils the true string:
 >>>
 >>>   # echo MSFT100 > os_desc/qw_sign
 >>>   # hexdump -C os_desc/qw_sign
 >>>     4d 00 53 00 46 00 54 00  31 00 30 00 30 00
 >>> |M.S.F.T.1.0.0.|
 >>>
 >>> Make qw_sign symmetric by returning an UTF-8 string too. Also follow
 >>> common convention and add a new line at the end.
 >>
 >> Doesn't USB require that strings be in UTF-16?  So why have the kernel
 >> convert them?
 >
 > That is a discussion we should have had when the write side of this has
 > been added:
 >
 > static ssize_t os_desc_qw_sign_store(struct config_item *item, const
 > char *page,
 >   size_t len)
 > {
 >  struct gadget_info *gi = os_desc_item_to_gadget_info(item);
 >  int res, l;
 >
 >  l = min((int)len, OS_STRING_QW_SIGN_LEN >> 1);
 >  if (page[l - 1] == '\n')
 >  --l;
 >
 >  mutex_lock(&gi->lock);
 >  res = utf8s_to_utf16s(page, l,
 >UTF16_LITTLE_ENDIAN, (wchar_t *) gi->qw_sign,
 >OS_STRING_QW_SIGN_LEN);
 >  if (res > 0)
 >  res = len;
 >  mutex_unlock(&gi->lock);
 >
 >  return res;
 > }
 >
 >
 > The store function is definitely already in use today, e.g. this script
 > used for ev3dev:
 > https://github.com/ev3dev/ev3-systemd/blob/ev3dev-jessie/scripts/ev3-usb.sh
 >
 > Changing it to UTF-16 would break that script... So changing the store
 > part is the lesser of two evils.
 >
 > Regarding new line: Just following what other attributes are doing by
 > using the GS_STRINGS_R macro.

 Any comment on this? In my opinion especially this first patch really
 fixes a bug and should get applied... I can remove the newline if
 preferred.
>>>
>>> It's up to Felipe, give him a chance to catch up on patches...
>> 
>> I really don't know what to do here :-) Either way have the potential of
>> breaking userspace. Maybe returning UTF8 as in write is the lesser of
>> two evils.
>
> So far libusbg and libusbgx do not have support for OS Descriptors.
>
> I came across the issue while writing support for libusbgx (not upstream
> yet). And it is rather ugly to have to do it on the read side and not to
> do on the write side. It would also extend the dependencies of the
> library (I implemented a prototype using iconv).
>
> Also reading the old interface with UTF-8 does not crash the library, it
> just return only the first character (since the second character is
> \0...).

Okay, then let's go with your original patch. Can you resend once -rc1
is out?

-- 
balbi


signature.asc
Description: PGP signature


[PATCH v2] USB: serial: upd78f0730: Add ID for EVAL-ADXL362Z

2017-02-13 Thread Maksim Salau
The adaptor on Analog Devices EVAL-ADXL362Z development board is used
to flash and debug firmware of on-board Renesas RL78/G13 MCU.
Also added support of the 153600 baud rate, since the stock firmware
uses it.

Signed-off-by: Maksim Salau 
---
Changes in v2:
* mentioned additional baudrate in the commit message.

 drivers/usb/serial/upd78f0730.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/serial/upd78f0730.c b/drivers/usb/serial/upd78f0730.c
index 55b9a18..f1e6c07 100644
--- a/drivers/usb/serial/upd78f0730.c
+++ b/drivers/usb/serial/upd78f0730.c
@@ -17,7 +17,7 @@
  * - stop bits: 1 or 2
  * - parity: even, odd or none
  * - flow control: none
- * - baud rates: 0, 2400, 4800, 9600, 19200, 38400, 57600, 115200
+ * - baud rates: 0, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 153600
  * - signals: DTR, RTS and BREAK
  */
 
@@ -34,6 +34,7 @@
 static const struct usb_device_id id_table[] = {
{ USB_DEVICE(0x045B, 0x0212) }, /* YRPBRL78G13, YRPBRL78G14 */
{ USB_DEVICE(0x0409, 0x0063) }, /* V850ESJX3-STICK */
+   { USB_DEVICE(0x064B, 0x7825) }, /* Analog Devices EVAL-ADXL362Z-DB */
{}
 };
 
@@ -288,7 +289,7 @@ static speed_t upd78f0730_get_baud_rate(struct tty_struct 
*tty)
 {
const speed_t baud_rate = tty_get_baud_rate(tty);
const speed_t supported[] = {
-   0, 2400, 4800, 9600, 19200, 38400, 57600, 115200
+   0, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 153600
};
int i;
 
-- 
2.9.3

--
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 v13 00/12] power: add power sequence library

2017-02-13 Thread Rafael J. Wysocki
On Saturday, February 11, 2017 09:27:11 AM Peter Chen wrote:
> Hi all,
> 
> This is a follow-up for my last power sequence framework patch set [1].
> According to Rob Herring and Ulf Hansson's comments[2]. The kinds of
> power sequence instances will be added at postcore_initcall, the match
> criteria is compatible string first, if the compatible string is not
> matched between dts and library, it will try to use generic power sequence.
>
> The host driver just needs to call of_pwrseq_on/of_pwrseq_off
> if only one power sequence instance is needed, for more power sequences
> are used, using of_pwrseq_on_list/of_pwrseq_off_list instead (eg, USB hub 
> driver).
> 
> In future, if there are special power sequence requirements, the special
> power sequence library can be created.
> 
> This patch set is tested on i.mx6 sabresx evk using a dts change, I use
> two hot-plug devices to simulate this use case, the related binding
> change is updated at patch [1/6], The udoo board changes were tested
> using my last power sequence patch set.[3]
> 
> Except for hard-wired MMC and USB devices, I find the USB ULPI PHY also
> need to power on itself before it can be found by ULPI bus.
> 
> Changes for v13:
> - Add more design descriptions at design doc and fix one build error
>   introduced by v12 wrongly [Patch 2/12]
> - Add the last three dts patches which were forgotten at last series
> - Move the comment for usb_create_shared_hcd to correct place [Patch 3/12]
> - Add sysdev for shared hcd too for xhci-plat.c [Patch 6/12]
> 
> Rafael, if the first two power sequence patches are ok for you, would you 
> consider
> accept these first, the other USB patches can go through USB tree at 
> v4.12-rc1?

OK, I'll look at the [1-2/12] in the first place, but please give me some time
and stop sending new versions of the whole patchset continuously for the time
being.

Also I'm not going to take anything from this series without the Greg's consent,
just to be clear.

Thanks,
Rafael

--
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: serial: upd78f0730: Add ID for EVAL-ADXL362Z

2017-02-13 Thread Johan Hovold
On Mon, Feb 13, 2017 at 03:14:34PM +0300, Maksim Salau wrote:
> The adaptor on Analog Devices EVAL-ADXL362Z development board is used
> to flash and debug firmware of on-board Renesas RL78/G13 MCU.
> Also added support of the 153600 baud rate, since the stock firmware
> uses it.
> 
> Signed-off-by: Maksim Salau 
> ---
> Changes in v2:
> * mentioned additional baudrate in the commit message.

Now applied, thanks.

Johan
--
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: serial: upd78f0730: sort device ids

2017-02-13 Thread Johan Hovold
Sort the device ids by vendor id.

Signed-off-by: Johan Hovold 
---
 drivers/usb/serial/upd78f0730.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/serial/upd78f0730.c b/drivers/usb/serial/upd78f0730.c
index f1e6c07ffc81..a028dd2310c9 100644
--- a/drivers/usb/serial/upd78f0730.c
+++ b/drivers/usb/serial/upd78f0730.c
@@ -32,8 +32,8 @@
 #define DRIVER_AUTHOR "Maksim Salau "
 
 static const struct usb_device_id id_table[] = {
-   { USB_DEVICE(0x045B, 0x0212) }, /* YRPBRL78G13, YRPBRL78G14 */
{ USB_DEVICE(0x0409, 0x0063) }, /* V850ESJX3-STICK */
+   { USB_DEVICE(0x045B, 0x0212) }, /* YRPBRL78G13, YRPBRL78G14 */
{ USB_DEVICE(0x064B, 0x7825) }, /* Analog Devices EVAL-ADXL362Z-DB */
{}
 };
-- 
2.10.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


Re: [PATCH -next] usb: dwc2: Fix the error handling of dwc2_pci_probe()

2017-02-13 Thread Vardan Mikayelyan
On 2/7/2017 7:54 PM, Wei Yongjun wrote:
> From: Wei Yongjun 
>
> Fix the error handling of dwc2_pci_probe() to avoid resources leak.
>
> Signed-off-by: Wei Yongjun 
> ---
>  drivers/usb/dwc2/pci.c | 21 ++---
>  1 file changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c
> index fdeb8c7..58fc1bf 100644
> --- a/drivers/usb/dwc2/pci.c
> +++ b/drivers/usb/dwc2/pci.c
> @@ -124,7 +124,7 @@ static int dwc2_pci_probe(struct pci_dev *pci,
>   ret = platform_device_add_resources(dwc2, res, ARRAY_SIZE(res));
>   if (ret) {
>   dev_err(dev, "couldn't add resources to dwc2 device\n");
> - return ret;
> + goto err_device_put;
>   }
>
>   dwc2->dev.parent = dev;
> @@ -133,30 +133,37 @@ static int dwc2_pci_probe(struct pci_dev *pci,
>   if (IS_ERR(phy)) {
>   dev_err(dev, "error registering generic PHY (%ld)\n",
>   PTR_ERR(phy));
> - return PTR_ERR(phy);
> + ret = PTR_ERR(phy);
> + goto err_device_put;
>   }
>
>   ret = dwc2_pci_quirks(pci, dwc2);
>   if (ret)
> - goto err;
> + goto err_unregister;
>
>   ret = platform_device_add(dwc2);
>   if (ret) {
>   dev_err(dev, "failed to register dwc2 device\n");
> - goto err;
> + goto err_unregister;
>   }
>
>   glue = kzalloc(sizeof(*glue), GFP_KERNEL);
> - if (!glue)
> - return -ENOMEM;
> + if (!glue) {
> + ret = -ENOMEM;
> + goto err_device_del;
> + }
>
>   glue->phy = phy;
>   glue->dwc2 = dwc2;
>   pci_set_drvdata(pci, glue);
>
>   return 0;
> -err:
> +
> +err_device_del:
> + platform_device_del(dwc2);
> +err_unregister:
>   usb_phy_generic_unregister(phy);
> +err_device_put:
>   platform_device_put(dwc2);
>   return ret;
>  }
>
> --

Hi Wei Yongjun,

We have patch doing the same in our internal branch, please review it 
below. We will send it out after internal review/testing process.

usb: dwc2: pci: Fix error handling in dwc2_pci_probe

Move usb_phy_generic_register() function call to the top, to simplify
error handling.

Replace kzalloc() with devm_kzalloc().

After platform_device_add(), if we error out, we must do
platform_device_unregister(), which also does the put. So lets move
devm_kzalloc() to simplify error handling and avoid
calling of platform_device_unregister().

Change-Id: Ic183ee233f5dc622e9e6126c1bfd4890baee1f76
Signed-off-by: Vardan Mikayelyan 

diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c
index fdeb8c7..7696131 100644
--- a/drivers/usb/dwc2/pci.c
+++ b/drivers/usb/dwc2/pci.c
@@ -104,10 +104,17 @@ static int dwc2_pci_probe(struct pci_dev *pci,

 pci_set_master(pci);

+   phy = usb_phy_generic_register();
+   if (IS_ERR(phy)) {
+   dev_err(dev, "error registering generic PHY (%ld)\n",
+   PTR_ERR(phy));
+   return PTR_ERR(phy);
+   }
+
 dwc2 = platform_device_alloc("dwc2", PLATFORM_DEVID_AUTO);
 if (!dwc2) {
 dev_err(dev, "couldn't allocate dwc2 device\n");
-   return -ENOMEM;
+   goto err;
 }

 memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res));
@@ -124,32 +131,25 @@ static int dwc2_pci_probe(struct pci_dev *pci,
 ret = platform_device_add_resources(dwc2, res, ARRAY_SIZE(res));
 if (ret) {
 dev_err(dev, "couldn't add resources to dwc2 device\n");
-   return ret;
+   goto err;
 }

 dwc2->dev.parent = dev;

-   phy = usb_phy_generic_register();
-   if (IS_ERR(phy)) {
-   dev_err(dev, "error registering generic PHY (%ld)\n",
-   PTR_ERR(phy));
-   return PTR_ERR(phy);
-   }
-
 ret = dwc2_pci_quirks(pci, dwc2);
 if (ret)
 goto err;

+   glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL);
+   if (!glue)
+   goto err;
+
 ret = platform_device_add(dwc2);
 if (ret) {
 dev_err(dev, "failed to register dwc2 device\n");
 goto err;
 }

-   glue = kzalloc(sizeof(*glue), GFP_KERNEL);
-   if (!glue)
-   return -ENOMEM;
-
 glue->phy = phy;


Thanks,
Vardan.



--
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: serial: upd78f0730: sort device ids

2017-02-13 Thread Maksim Salau
> Sort the device ids by vendor id.
> 
> Signed-off-by: Johan Hovold 

Thanks for taking care of that. I didn't bothered about order
before your comment about ftd_sio driver.

Maksim.
--
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: gadget: legacy gadgets are optional

2017-02-13 Thread Romain Izard
When building without modules, it makes sense to configure the kernel to
only use configfs for USB Gadget drivers.

Mark the choice for legacy gadget drivers as optional.

Signed-off-by: Romain Izard 
cc:  # 4.9
---
 drivers/usb/gadget/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 8ad203296079..f3ee80ece682 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -460,6 +460,7 @@ config USB_CONFIGFS_F_TCM
 choice
tristate "USB Gadget Drivers"
default USB_ETH
+   optional
help
  A Linux "Gadget Driver" talks to the USB Peripheral Controller
  driver through the abstract "gadget" API.  Some other operating
-- 
2.9.3

--
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: serial: upd78f0730: sort device ids

2017-02-13 Thread Johan Hovold
On Mon, Feb 13, 2017 at 05:44:17PM +0300, Maksim Salau wrote:
> > Sort the device ids by vendor id.
> > 
> > Signed-off-by: Johan Hovold 
> 
> Thanks for taking care of that. I didn't bothered about order
> before your comment about ftd_sio driver.

Yeah, I didn't even notice it before either, but might as well keep it
sorted from the start, which tends to make it more obvious were to place
new entries. 

Johan
--
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] avoid use of freed pointer

2017-02-13 Thread Gustavo A. R. Silva
Hello,

This patch series addesses Coverity ID 1091172, which reports the
use of a freed pointer. udc_free_dma_chain() function was rewritten
in order to fix this issue.

Unnecessary 'ret_val' variable was removed and the function prototype
was modified.

Thanks

Gustavo A. R. Silva (2):
  usb: gadget: udc: avoid use of freed pointer
  usb: gadget: udc: remove unnecessary variable and update function
prototype

 drivers/usb/gadget/udc/amd5536udc.c | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

-- 
2.5.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 2/2] usb: gadget: udc: remove unnecessary variable and update function prototype

2017-02-13 Thread Gustavo A. R. Silva
Remove unnecessary variable and update function prototype.

Reviewed-by: Greg Kroah-Hartman 
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/usb/gadget/udc/amd5536udc.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/amd5536udc.c 
b/drivers/usb/gadget/udc/amd5536udc.c
index ded97a3..3f64a06 100644
--- a/drivers/usb/gadget/udc/amd5536udc.c
+++ b/drivers/usb/gadget/udc/amd5536udc.c
@@ -608,9 +608,8 @@ udc_alloc_request(struct usb_ep *usbep, gfp_t gfp)
 }
 
 /* frees pci pool descriptors of a DMA chain */
-static int udc_free_dma_chain(struct udc *dev, struct udc_request *req)
+static void udc_free_dma_chain(struct udc *dev, struct udc_request *req)
 {
-   int ret_val = 0;
struct udc_data_dma *td = req->td_data;
unsigned int i;
 
@@ -629,8 +628,6 @@ static int udc_free_dma_chain(struct udc *dev, struct 
udc_request *req)
td = NULL;
addr = addr_aux;
}
-
-   return ret_val;
 }
 
 /* Frees request packet, called by gadget driver */
-- 
2.5.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


Re: [PATCH v2] usb: gadget: udc: remove pointer dereference after free

2017-02-13 Thread Michal Nazarewicz
On Sat, Feb 11 2017, Gustavo A. R. Silva wrote:
> Remove pointer dereference after free and set pointer to NULL after free.
>
> Addresses-Coverity-ID: 1091173
> Signed-off-by: Gustavo A. R. Silva 

Acked-by: Michal Nazarewicz 

> ---
> Changes in v2:
>   Move pointer dereference before pci_pool_free()
>   Set pointer to NULL after free
>
>   drivers/usb/gadget/udc/pch_udc.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/udc/pch_udc.c  
> b/drivers/usb/gadget/udc/pch_udc.c
> index a97da64..73bb58f 100644
> --- a/drivers/usb/gadget/udc/pch_udc.c
> +++ b/drivers/usb/gadget/udc/pch_udc.c
> @@ -1522,8 +1522,9 @@ static void pch_udc_free_dma_chain(struct  
> pch_udc_dev *dev,
>   /* do not free first desc., will be done by free for request */
>   td = phys_to_virt(addr);
>   addr2 = (dma_addr_t)td->next;
> - pci_pool_free(dev->data_requests, td, addr);
>   td->next = 0x00;

Or just drop this.  pci_pool_free doesn’t care about contents of td.
It’s just a void* for it. 

> + pci_pool_free(dev->data_requests, td, addr);
> + td = NULL;

This isn’t necessary either.  td will get overwritten on next iteration
and once we’re done it’s not used again.

>   addr = addr2;
>   }
>   req->chain_len = 1;

-- 
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»
--
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/2] usb: gadget: udc: remove unnecessary variable and update function prototype

2017-02-13 Thread Michal Nazarewicz
On Mon, Feb 13 2017, Gustavo A. R. Silva wrote:
> Remove unnecessary variable and update function prototype.
>
> Reviewed-by: Greg Kroah-Hartman 
> Signed-off-by: Gustavo A. R. Silva 

Acked-by: Michal Nazarewicz 

> ---
>  drivers/usb/gadget/udc/amd5536udc.c | 5 +
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/amd5536udc.c 
> b/drivers/usb/gadget/udc/amd5536udc.c
> index ded97a3..3f64a06 100644
> --- a/drivers/usb/gadget/udc/amd5536udc.c
> +++ b/drivers/usb/gadget/udc/amd5536udc.c
> @@ -608,9 +608,8 @@ udc_alloc_request(struct usb_ep *usbep, gfp_t gfp)
>  }
>  
>  /* frees pci pool descriptors of a DMA chain */
> -static int udc_free_dma_chain(struct udc *dev, struct udc_request *req)
> +static void udc_free_dma_chain(struct udc *dev, struct udc_request *req)
>  {
> - int ret_val = 0;
>   struct udc_data_dma *td = req->td_data;
>   unsigned int i;
>  
> @@ -629,8 +628,6 @@ static int udc_free_dma_chain(struct udc *dev, struct 
> udc_request *req)
>   td = NULL;
>   addr = addr_aux;
>   }
> -
> - return ret_val;
>  }
>  
>  /* Frees request packet, called by gadget driver */
> -- 
> 2.5.0
>

-- 
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»
--
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 1/2] usb: gadget: udc: avoid use of freed pointer

2017-02-13 Thread Michal Nazarewicz
On Mon, Feb 13 2017, Gustavo A. R. Silva wrote:
> Rewrite udc_free_dma_chain() function to avoid use of pointer after free.
>
> Addresses-Coverity-ID: 1091172
> Reviewed-by: Greg Kroah-Hartman 
> Signed-off-by: Gustavo A. R. Silva 

Acked-by: Michal Nazarewicz 

> ---
>  drivers/usb/gadget/udc/amd5536udc.c | 20 +++-
>  1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/amd5536udc.c 
> b/drivers/usb/gadget/udc/amd5536udc.c
> index ea03ca7..ded97a3 100644
> --- a/drivers/usb/gadget/udc/amd5536udc.c
> +++ b/drivers/usb/gadget/udc/amd5536udc.c
> @@ -611,21 +611,23 @@ udc_alloc_request(struct usb_ep *usbep, gfp_t gfp)
>  static int udc_free_dma_chain(struct udc *dev, struct udc_request *req)
>  {
>   int ret_val = 0;
> - struct udc_data_dma *td;
> - struct udc_data_dma *td_last = NULL;
> + struct udc_data_dma *td = req->td_data;
>   unsigned int i;
>  
> + dma_addr_t addr_aux = 0x00;

Perhaps call it ‘addr_next’ or ‘next’?

> + dma_addr_t addr = (dma_addr_t)td->next;
> + td->next = 0x00;
> +
>   DBG(dev, "free chain req = %p\n", req);
>  
>   /* do not free first desc., will be done by free for request */
> - td_last = req->td_data;
> - td = phys_to_virt(td_last->next);
> -
>   for (i = 1; i < req->chain_len; i++) {
> - pci_pool_free(dev->data_requests, td,
> -   (dma_addr_t)td_last->next);
> - td_last = td;
> - td = phys_to_virt(td_last->next);
> + td = phys_to_virt(addr);
> + addr_aux = (dma_addr_t)td->next;
> + td->next = 0x00;

This is unnecessary.

> + pci_pool_free(dev->data_requests, td, addr);
> + td = NULL;

Ditto.

> + addr = addr_aux;
>   }
>  
>   return ret_val;
> -- 
> 2.5.0
>

-- 
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»
--
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/2] usb: gadget: udc: avoid use of freed pointer

2017-02-13 Thread Gustavo A. R. Silva
Rewrite udc_free_dma_chain() function to avoid use of pointer after free.

Addresses-Coverity-ID: 1091172
Reviewed-by: Greg Kroah-Hartman 
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/usb/gadget/udc/amd5536udc.c | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/udc/amd5536udc.c 
b/drivers/usb/gadget/udc/amd5536udc.c
index ea03ca7..ded97a3 100644
--- a/drivers/usb/gadget/udc/amd5536udc.c
+++ b/drivers/usb/gadget/udc/amd5536udc.c
@@ -611,21 +611,23 @@ udc_alloc_request(struct usb_ep *usbep, gfp_t gfp)
 static int udc_free_dma_chain(struct udc *dev, struct udc_request *req)
 {
int ret_val = 0;
-   struct udc_data_dma *td;
-   struct udc_data_dma *td_last = NULL;
+   struct udc_data_dma *td = req->td_data;
unsigned int i;
 
+   dma_addr_t addr_aux = 0x00;
+   dma_addr_t addr = (dma_addr_t)td->next;
+   td->next = 0x00;
+
DBG(dev, "free chain req = %p\n", req);
 
/* do not free first desc., will be done by free for request */
-   td_last = req->td_data;
-   td = phys_to_virt(td_last->next);
-
for (i = 1; i < req->chain_len; i++) {
-   pci_pool_free(dev->data_requests, td,
- (dma_addr_t)td_last->next);
-   td_last = td;
-   td = phys_to_virt(td_last->next);
+   td = phys_to_virt(addr);
+   addr_aux = (dma_addr_t)td->next;
+   td->next = 0x00;
+   pci_pool_free(dev->data_requests, td, addr);
+   td = NULL;
+   addr = addr_aux;
}
 
return ret_val;
-- 
2.5.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


RE: How to resolve "Waited 2000ms for CONNECT" in system resuming?

2017-02-13 Thread Alan Stern
On Mon, 13 Feb 2017, Yoshihiro Shimoda wrote:

> > Hmmm.  You're using platform drivers for OHCI and EHCI, not PCI,
> 
> Yes, I'm using platform drivers for OHCI and EHCI.
> 
> > right?  The resume_common() routine in drivers/usb/core/hcd-pci.c is
> > careful to resume things in the correct order.  It contains this code:
> > 
> > /*
> >  * Only EHCI controllers have to wait for their companions.
> >  * No locking is needed because PCI controller drivers do not
> >  * get unbound during system resume.
> >  */
> > if (pci_dev->class == CL_EHCI && event != PM_EVENT_AUTO_RESUME)
> > for_each_companion(pci_dev, hcd,
> > ehci_wait_for_companions);
> > 
> > Probably the equivalent routine in the platform driver needs to do the
> > same sort of thing.  This means it needs to know about companion
> > controllers.
> 
> Thank you very much for this information!
> If I added the following code, the issue disappeared:
>  - The ehci-platform.c calls device_enable_async_suspend(hcd->self.controller)
>in ehci_platform_probe()

We probably should do that in all the platform drivers anyway.

>  - [This is a dirty code, but] hcd_bus_resume() calls device_pm_wait_for_dev(
>rhdev->bus->controller, ohci_dev)
> 
> I will consider how to implement such a code for [eo]hci-platform drivers.
> Especially, like ehci_{pre,post}_add() for platform drivers are needed, I 
> think.

The key point is that the EHCI controller must be resumed _after_ its 
companion controllers.  In order to do this properly, the platform 
driver needs to know which other devices the companions are.

There's no way it can figure this out by itself; it has to be told by
the platform-specific code.

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] usb: misc: usbtest: remove redundant check on retval < 0

2017-02-13 Thread Alan Stern
On Mon, 13 Feb 2017, Felipe Balbi wrote:

> Hi,
> 
> Colin King  writes:
> > From: Colin Ian King 
> >
> > The check for retval being less than zero is always true since
> > retval equal to -EPIPE at that point.  Replace the existing
> > conditional with just return retval.
> >
> > Detected with CoverityScan, CID#114349 ("Logically dead code")
> >
> > Signed-off-by: Colin Ian King 
> > ---
> >  drivers/usb/misc/usbtest.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
> > index 3525626..17c0810 100644
> > --- a/drivers/usb/misc/usbtest.c
> > +++ b/drivers/usb/misc/usbtest.c
> > @@ -992,7 +992,7 @@ static int ch9_postconfig(struct usbtest_dev *dev)
> > dev_err(&iface->dev,
> > "hs dev qualifier --> %d\n",
> > retval);
> > -   return (retval < 0) ? retval : -EDOM;
> > +   return retval;
> 
> you're changing return value here, are you sure there's nothing else
> depending on this error?

I bet you didn't look at the original code.  :-)  Just before the start
of the patch there is:

if (retval == -EPIPE) {
...

So no, the patch does not change the return value.

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] usb: misc: usbtest: remove redundant check on retval < 0

2017-02-13 Thread Colin Ian King
On 13/02/17 10:45, Felipe Balbi wrote:
> 
> Hi,
> 
> Colin King  writes:
>> From: Colin Ian King 
>>
>> The check for retval being less than zero is always true since
>> retval equal to -EPIPE at that point.  Replace the existing
>> conditional with just return retval.
>>
>> Detected with CoverityScan, CID#114349 ("Logically dead code")
>>
>> Signed-off-by: Colin Ian King 
>> ---
>>  drivers/usb/misc/usbtest.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
>> index 3525626..17c0810 100644
>> --- a/drivers/usb/misc/usbtest.c
>> +++ b/drivers/usb/misc/usbtest.c
>> @@ -992,7 +992,7 @@ static int ch9_postconfig(struct usbtest_dev *dev)
>>  dev_err(&iface->dev,
>>  "hs dev qualifier --> %d\n",
>>  retval);
>> -return (retval < 0) ? retval : -EDOM;
>> +return retval;
> 
> you're changing return value here, are you sure there's nothing else
> depending on this error?
> 
The code in the current state will never return -EDOM and will always
return retval, so this change actually makes no functional change, it
just removes a redundant check.  So it's not going to make a jot of
difference to the current behaver.



signature.asc
Description: OpenPGP digital signature


USB- Kernel 4.4.0.-59 / -62 - Hardware (Sense) Errors without a reason

2017-02-13 Thread Mike
Hi, with the Kernel 4.4.0-59 i got after the startup, Hardware Error Messages 
for my external USB-HDDs. 
The internal HDD ist not affected. I checked all external HDDs via smartctl and 
did a short selftest which finished without error. 
The error came up after i switched from XUbuntu 14.04 to 16.04 with a clean 
installation.
The Bugtracker at redhat shows a similar issue: 
https://bugzilla.redhat.com/show_bug.cgi?id=1351305

Regards Mike

OS: Xubuntu 16.04 

Kernel:
-
Linux toshiba 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:36:54 UTC 2017 i686 
athlon i686 GNU/Linux
and
Linux toshiba 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:09:55 UTC 2017 i686 
athlon i686 GNU/Linux

dmesg:
-
[   40.110357] sd 9:0:0:0: [sdc] tag#0 FAILED Result: hostbyte=DID_ERROR 
driverbyte=DRIVER_SENSE
[   40.110369] sd 9:0:0:0: [sdc] tag#0 Sense Key : Hardware Error [current] 
[descriptor] 
[   40.110373] sd 9:0:0:0: [sdc] tag#0 Add. Sense: No additional sense 
information
[   40.110379] sd 9:0:0:0: [sdc] tag#0 CDB: ATA command pass through(16) 85 06 
2c 00 da 00 00 00 00 00 4f 00 c2 00 b0 00
[   40.366689] sd 10:0:0:0: [sdd] tag#0 FAILED Result: hostbyte=DID_ERROR 
driverbyte=DRIVER_SENSE
[   40.366699] sd 10:0:0:0: [sdd] tag#0 Sense Key : Hardware Error [current] 
[descriptor] 
[   40.366704] sd 10:0:0:0: [sdd] tag#0 Add. Sense: No additional sense 
information
[   40.366710] sd 10:0:0:0: [sdd] tag#0 CDB: ATA command pass through(16) 85 06 
2c 00 da 00 00 00 00 00 4f 00 c2 00 b0 00
--
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- Kernel 4.4.0.-59 / -62 - Hardware (Sense) Errors without a reason

2017-02-13 Thread Greg KH
On Mon, Feb 13, 2017 at 06:18:30PM +0100, Mike wrote:
> Hi, with the Kernel 4.4.0-59 i got after the startup, Hardware Error Messages 
> for my external USB-HDDs. 
> The internal HDD ist not affected. I checked all external HDDs via smartctl 
> and did a short selftest which finished without error. 
> The error came up after i switched from XUbuntu 14.04 to 16.04 with a clean 
> installation.
> The Bugtracker at redhat shows a similar issue: 
> https://bugzilla.redhat.com/show_bug.cgi?id=1351305
> 
> Regards Mike
> 
> OS: Xubuntu 16.04 
> 
> Kernel:
> -
> Linux toshiba 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:36:54 UTC 2017 
> i686 athlon i686 GNU/Linux
> and
> Linux toshiba 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:09:55 UTC 2017 
> i686 athlon i686 GNU/Linux

4.4 is very old, any chance you can try 4.9 and even better yet,
4.10-rc8?

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: [BUG] usb: gadget: Kernel oops with UVC USB gadget and configfs

2017-02-13 Thread Robert Jarzmik
Petr Cvek  writes:

> Dne 12.2.2017 v 13:02 Robert Jarzmik napsal(a):
> That's weird I even removed pxa_set_udc_info() from magician machine init and 
> it still fails.
> Host cable and/or actual camera is not required. It fails without them.
>
> So you binded pxa27x-udc as UDC controller (= activated it) and then rmmoded
> it and nobody complained?
No, that usecase actually fails. I think you could submit a proper patch with
the diff in [1], with which the pxa27x-udc unloading will work.

But it's not _your_ testcase, as per your provided callstack :
[ 2152.826529] [] (udc_bind_to_driver [udc_core]) from [] 
(usb_add_gadget_udc_release+0x138/0x21c [udc_core])
[ 2152.826731] [] (usb_add_gadget_udc_release [udc_core]) from 
[] (pxa_udc_probe+0x290/0x2fc [pxa27x_udc])
[ 2152.833554] [] (pxa_udc_probe [pxa27x_udc]) from [] 
(platform_drv_probe+0x38/0x84)
[ 2152.833602] [] (platform_drv_probe) from [] 
(driver_probe_device+0x1e0/0x3f4)

Your problem seems in the pxa_udc_probe(), which I would presume you're doing
for a second time, ie. after modprobe pxa27x_udc + bind UDC controller + rmmod
pxa27x_udc + modprobe pxa27x_udc.

I suspect that in this case, the problem is that the rmmod works while udc is
still bound to the composite. The lsmod seems to prove that the refcount is
still 0 while usb_f_uvc is is bound to pxa27x_udc.

[@Felipe and @Laurent]
I have no knowledge of usb_f_uvc, so would you tell me if binding usb_f_uvc to
pxa27_udc should have incremented the module refcount of pxa27x_udc or not ?

> Can you try v4.10? Or send me exact commit on what you tested it so I can test
> it too.
My top commit (not counting yours) is : 61c04572de40 ("Merge branch 'for-rc' of
git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux")

Cheers.

-- 
Robert

[1]
diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c 
b/drivers/usb/gadget/udc/pxa27x_udc.c
index 9fb103348b5d..a239eb836652 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.c
+++ b/drivers/usb/gadget/udc/pxa27x_udc.c
@@ -2512,7 +2512,8 @@ static int pxa_udc_remove(struct platform_device *_dev)
usb_del_gadget_udc(&udc->gadget);
pxa_cleanup_debugfs(udc);
 
-   usb_put_phy(udc->transceiver);
+   if (!IS_ERR(udc->transceiver))
+   usb_put_phy(udc->transceiver);
 
udc->transceiver = NULL;
the_controller = NULL;
--
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- Kernel 4.4.0.-59 / -62 - Hardware (Sense) Errors without a reason

2017-02-13 Thread Alan Stern
On Mon, 13 Feb 2017, Greg KH wrote:

> On Mon, Feb 13, 2017 at 06:18:30PM +0100, Mike wrote:
> > Hi, with the Kernel 4.4.0-59 i got after the startup, Hardware Error 
> > Messages for my external USB-HDDs. 
> > The internal HDD ist not affected. I checked all external HDDs via smartctl 
> > and did a short selftest which finished without error. 
> > The error came up after i switched from XUbuntu 14.04 to 16.04 with a clean 
> > installation.
> > The Bugtracker at redhat shows a similar issue: 
> > https://bugzilla.redhat.com/show_bug.cgi?id=1351305
> > 
> > Regards Mike
> > 
> > OS: Xubuntu 16.04 
> > 
> > Kernel:
> > -
> > Linux toshiba 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:36:54 UTC 2017 
> > i686 athlon i686 GNU/Linux
> > and
> > Linux toshiba 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:09:55 UTC 2017 
> > i686 athlon i686 GNU/Linux
> 
> 4.4 is very old, any chance you can try 4.9 and even better yet,
> 4.10-rc8?

See the comments at teh end of the RedHat Bugzilla entry referenced 
above.  IMO this is not a kernel problem, but a problem in the udisks2 
program.

More precisely, these errors have always occurred, but the kernel did 
not realize they were errors and did not report them until fairly 
recently.

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


[PATCH v7 4/5] usb: serial: add dbc debug device support to usb_debug

2017-02-13 Thread Lu Baolu
This patch adds dbc debug device support to the usb_debug driver.

Signed-off-by: Lu Baolu 
Acked-by: Johan Hovold 
---
 drivers/usb/serial/usb_debug.c | 28 +---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c
index ca2fa5b..92f7e5c 100644
--- a/drivers/usb/serial/usb_debug.c
+++ b/drivers/usb/serial/usb_debug.c
@@ -32,7 +32,18 @@ static const struct usb_device_id id_table[] = {
{ USB_DEVICE(0x0525, 0x127a) },
{ },
 };
-MODULE_DEVICE_TABLE(usb, id_table);
+
+static const struct usb_device_id dbc_id_table[] = {
+   { USB_DEVICE(0x1d6b, 0x0004) },
+   { },
+};
+
+static const struct usb_device_id id_table_combined[] = {
+   { USB_DEVICE(0x0525, 0x127a) },
+   { USB_DEVICE(0x1d6b, 0x0004) },
+   { },
+};
+MODULE_DEVICE_TABLE(usb, id_table_combined);
 
 /* This HW really does not support a serial break, so one will be
  * emulated when ever the break state is set to true.
@@ -71,9 +82,20 @@ static struct usb_serial_driver debug_device = {
.process_read_urb = usb_debug_process_read_urb,
 };
 
+static struct usb_serial_driver dbc_device = {
+   .driver = {
+   .owner =THIS_MODULE,
+   .name = "xhci_dbc",
+   },
+   .id_table = dbc_id_table,
+   .num_ports =1,
+   .break_ctl =usb_debug_break_ctl,
+   .process_read_urb = usb_debug_process_read_urb,
+};
+
 static struct usb_serial_driver * const serial_drivers[] = {
-   &debug_device, NULL
+   &debug_device, &dbc_device, NULL
 };
 
-module_usb_serial_driver(serial_drivers, id_table);
+module_usb_serial_driver(serial_drivers, id_table_combined);
 MODULE_LICENSE("GPL");
-- 
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 v7 5/5] usb: doc: add document for USB3 debug port usage

2017-02-13 Thread Lu Baolu
Add Documentation/usb/usb3-debug-port.rst. This document includes
the user guide for USB3 debug port.

Cc: linux-...@vger.kernel.org
Signed-off-by: Lu Baolu 
---
 Documentation/usb/usb3-debug-port.rst | 98 +++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/usb/usb3-debug-port.rst

diff --git a/Documentation/usb/usb3-debug-port.rst 
b/Documentation/usb/usb3-debug-port.rst
new file mode 100644
index 000..9eddb3a
--- /dev/null
+++ b/Documentation/usb/usb3-debug-port.rst
@@ -0,0 +1,98 @@
+===
+USB3 debug port
+===
+
+:Author: Lu Baolu 
+:Date: January 2017
+
+GENERAL
+===
+
+This is a HOWTO for using USB3 debug port on x86 systems.
+
+Before using any kernel debugging functionality based on USB3
+debug port, you need to check 1) whether debug port is supported
+by the xHCI host; 2) which port is used for debugging purposes
+(normally the first USB3 root port). You must have a USB 3.0
+super-speed A-to-A debugging cable to connect the debug target
+with a debug host. In this document, "debug target" stands for
+the system under debugging, and "debug host" stands for a
+stand-alone system that is able to talk to the debugging target
+through the USB3 debug port.
+
+EARLY PRINTK
+
+
+On the debug target system, you need to customize a debugging
+kernel with CONFIG_EARLY_PRINTK_USB_XDBC enabled. And, add
+below kernel boot parameter::
+
+   "earlyprintk=xdbc"
+
+If there are multiple xHCI controllers in the system, you can
+append a host contoller index to this kernel parameter. This
+index starts from 0.
+
+If you are going to use the "keep" option defined by the
+early printk framework to keep the boot console alive after
+early boot, you'd better add below kernel boot parameter::
+
+   "usbcore.autosuspend=-1"
+
+On the debug host side, you don't need to customize the kernel,
+but you'd better disable usb subsystem runtime power management
+by adding below kernel boot parameter::
+
+   "usbcore.autosuspend=-1"
+
+Before starting the debug target, you should connect the debug
+port on the debug target with a root port or port of any external
+hub on the debug host. The cable used to connect these two ports
+should be a USB 3.0 super-speed A-to-A debugging cable.
+
+During early boot of the debug target, DbC (xHCI debug engine for
+USB3 debug port) hardware will be detected and initialized. After
+initialization, the debug host should be able to enumerate the
+debug target as a debug device. The debug host will then bind the
+debug device with the usb_debug driver module and create the
+/dev/ttyUSB0 device.
+
+If the debug device enumeration goes smoothly, you should be able
+to see below kernel messages on the debug host::
+
+   # tail -f /var/log/kern.log
+   [ 1815.983374] usb 4-3: new SuperSpeed USB device number 4 using 
xhci_hcd
+   [ 1815.999595] usb 4-3: LPM exit latency is zeroed, disabling LPM.
+   [ 1815.999899] usb 4-3: New USB device found, idVendor=1d6b, 
idProduct=0004
+   [ 1815.02] usb 4-3: New USB device strings: Mfr=1, Product=2, 
SerialNumber=3
+   [ 1815.03] usb 4-3: Product: Remote GDB
+   [ 1815.04] usb 4-3: Manufacturer: Linux
+   [ 1815.05] usb 4-3: SerialNumber: 0001
+   [ 1816.000240] usb_debug 4-3:1.0: xhci_dbc converter detected
+   [ 1816.000360] usb 4-3: xhci_dbc converter now attached to ttyUSB0
+
+You can run below bash scripts on the debug host to read the kernel
+log sent from debug target.
+
+.. code-block:: sh
+
+   = start of bash scripts =
+   #!/bin/bash
+
+   while true ; do
+   while [ ! -d /sys/class/tty/ttyUSB0 ] ; do
+   :
+   done
+   cat /dev/ttyUSB0 >> xdbc.log
+   done
+   = end of bash scripts ===
+
+You should be able to see the early boot message in xdbc.log.
+
+If it doesn't work, please ask it on the 
+mailing list.
+
+Below USB hosts have been verified to work::
+
+   Intel Corporation Sunrise Point-H USB 3.0 xHCI Controller
+   Intel Corporation Wildcat Point-LP USB xHCI Controller
-- 
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 v7 3/5] x86: add support for earlyprintk via USB3 debug port

2017-02-13 Thread Lu Baolu
Add support for early printk by writing debug messages to the
USB3 debug port.   Users can use this type of early printk by
specifying kernel parameter of "earlyprintk=xdbc". This gives
users a chance of providing debug output.

The hardware for USB3 debug port requires DMA memory blocks.
This requires to delay setting up debugging hardware and
registering boot console until the memblocks are filled.

Cc: Ingo Molnar 
Cc: x...@kernel.org
Signed-off-by: Lu Baolu 
---
 Documentation/admin-guide/kernel-parameters.txt | 1 +
 arch/x86/kernel/early_printk.c  | 5 +
 arch/x86/kernel/setup.c | 4 
 3 files changed, 10 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index be7c0d9..4bf6138 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -988,6 +988,7 @@
earlyprintk=ttySn[,baudrate]
earlyprintk=dbgp[debugController#]
earlyprintk=pciserial,bus:device.function[,baudrate]
+   earlyprintk=xdbc[xhciController#]
 
earlyprintk is useful when the kernel crashes before
the normal console is initialized. It is not enabled by
diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
index 8a12199..0f08403 100644
--- a/arch/x86/kernel/early_printk.c
+++ b/arch/x86/kernel/early_printk.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -381,6 +382,10 @@ static int __init setup_early_printk(char *buf)
if (!strncmp(buf, "efi", 3))
early_console_register(&early_efi_console, keep);
 #endif
+#ifdef CONFIG_EARLY_PRINTK_USB_XDBC
+   if (!strncmp(buf, "xdbc", 4))
+   early_xdbc_parse_parameter(buf + 4);
+#endif
 
buf++;
}
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index aab7faa..10822b0 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -70,6 +70,7 @@
 #include 
 #include 
 
+#include 
 #include 
 
 #include 
@@ -1142,6 +1143,9 @@ void __init setup_arch(char **cmdline_p)
memblock_set_current_limit(ISA_END_ADDRESS);
memblock_x86_fill();
 
+   if (!early_xdbc_setup_hardware())
+   early_xdbc_register_console();
+
reserve_bios_regions();
 
if (efi_enabled(EFI_MEMMAP)) {
-- 
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 v7 0/5] usb: early: add support for early printk through USB3 debug port

2017-02-13 Thread Lu Baolu
xHCI debug capability (DbC) is an optional but standalone
functionality provided by an xHCI host controller. With DbC
hardware initialized, the system will present a debug device
through the USB3 debug port (normally the first USB3 port).
The debug device is fully compliant with the USB framework
and provides the equivalent of a very high performance (USB3)
full-duplex serial link between the debug host and target.
The DbC functionality is independent of xHCI host. There
isn't any precondition from xHCI host side for DbC to work.

This patch set adds support for early printk functionality
through a USB3 debug port by 1) initializing and enabling
the DbC hardware during early boot; 2) registering a boot
console to the system so that early printk messages can go
through the USB3 debug port. It also includes some lines
of changes in usb_debug driver so that it can be bound when
a USB3 debug device is enumerated.

---
Change log:
v6->v7:
  - add a new patch "[PATCH 1/5] x86: add simple udelay
calibration" to make udelay() work for early drivers.
  - [PATCH 2/5] usb: dbc: early driver for xhci debug capability
- add a kernel thread to handle error cases, such as cable
  unplugging.
- Fixed several code styles pointed out by Ingo.

v5->v6:
  - rebase the patches on top of the latest 4.10-rc4
  - run successfully in a 32-bit kernel
  - [PATCH 1/4]
- remove ugly linebreaks to make code more readable
- rename config names to make them consistency
- move sleep-able ioremap() out of the lock area
- rename reserved fields of register structures
- make the vertical tabulation of struct fields consistent
  - [PATCH 2/4]
- remove "#ifdef" in the generic code by creating proper
  wrappers in header file
  - [PATCH 3/4]
- refine the title and commit message
  - [PATCH 4/4]
- fix several typos and grammar errors in the document

v4->v5:
  - add raw_spin_lock to make xdbc_bulk_write() reentrant.

v3->v4:
  - Rename the document with .dst suffix.
  - Add the list of hardware that has been succesfuly
tested on in the document.

v2->v3:
  - Removed spinlock usage.
  - Removed work queue usage.
  - Refined the user guide document.

v1->v2:
  - Refactor the duplicate code in xdbc_early_start() and
xdbc_handle_external_reset().
  - Free resources when hardware not used any more.
  - Refine the user guide document.

Lu Baolu (5):
  x86: add simple udelay calibration
  usb: dbc: early driver for xhci debug capability
  x86: add support for earlyprintk via USB3 debug port
  usb: serial: add dbc debug device support to usb_debug
  usb: doc: add document for USB3 debug port usage

 Documentation/admin-guide/kernel-parameters.txt |1 +
 Documentation/usb/usb3-debug-port.rst   |   98 +++
 arch/x86/Kconfig.debug  |   17 +
 arch/x86/kernel/early_printk.c  |5 +
 arch/x86/kernel/setup.c |   26 +
 drivers/usb/Kconfig |3 +
 drivers/usb/Makefile|2 +-
 drivers/usb/early/Makefile  |1 +
 drivers/usb/early/xhci-dbc.c| 1026 +++
 drivers/usb/early/xhci-dbc.h|  210 +
 drivers/usb/serial/usb_debug.c  |   28 +-
 include/linux/usb/xhci-dbgp.h   |   29 +
 12 files changed, 1442 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/usb/usb3-debug-port.rst
 create mode 100644 drivers/usb/early/xhci-dbc.c
 create mode 100644 drivers/usb/early/xhci-dbc.h
 create mode 100644 include/linux/usb/xhci-dbgp.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


[PATCH v7 1/5] x86: add simple udelay calibration

2017-02-13 Thread Lu Baolu
Add a simple udelay calibration in x86 architecture-specific
boot-time initializations. This will get a workable estimate
for loops_per_jiffy. Hence, udelay() could be used after this
initialization.

Cc: Ingo Molnar 
Cc: x...@kernel.org
Signed-off-by: Lu Baolu 
---
 arch/x86/kernel/setup.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 4cfba94..aab7faa 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -835,6 +835,26 @@ dump_kernel_offset(struct notifier_block *self, unsigned 
long v, void *p)
return 0;
 }
 
+static void __init simple_udelay_calibration(void)
+{
+   unsigned int tsc_khz, cpu_khz;
+   unsigned long lpj;
+
+   if (!boot_cpu_has(X86_FEATURE_TSC))
+   return;
+
+   cpu_khz = x86_platform.calibrate_cpu();
+   tsc_khz = x86_platform.calibrate_tsc();
+
+   tsc_khz = tsc_khz ? : cpu_khz;
+   if (!tsc_khz)
+   return;
+
+   lpj = tsc_khz * 1000;
+   do_div(lpj, HZ);
+   loops_per_jiffy = lpj;
+}
+
 /*
  * Determine if we were loaded by an EFI loader.  If so, then we have also been
  * passed the efi memmap, systab, etc., so we should use these data structures
@@ -983,6 +1003,8 @@ void __init setup_arch(char **cmdline_p)
 */
x86_configure_nx();
 
+   simple_udelay_calibration();
+
parse_early_param();
 
 #ifdef CONFIG_MEMORY_HOTPLUG
-- 
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 v7 2/5] usb: dbc: early driver for xhci debug capability

2017-02-13 Thread Lu Baolu
xHCI debug capability (DbC) is an optional but standalone
functionality provided by an xHCI host controller. Software
learns this capability by walking through the extended
capability list of the host. xHCI specification describes
DbC in section 7.6.

This patch introduces the code to probe and initialize the
debug capability hardware during early boot. With hardware
initialized, the debug target (system on which this code is
running) will present a debug device through the debug port
(normally the first USB3 port). The debug device is fully
compliant with the USB framework and provides the equivalent
of a very high performance (USB3) full-duplex serial link
between the debug host and target. The DbC functionality is
independent of the xHCI host. There isn't any precondition
from the xHCI host side for the DbC to work.

This patch also includes bulk output and bulk input interfaces.
These interfaces could be used to implement early printk
bootconsole or hook to various system debuggers.

Cc: Mathias Nyman 
Signed-off-by: Lu Baolu 
---
 arch/x86/Kconfig.debug|   17 +
 drivers/usb/Kconfig   |3 +
 drivers/usb/Makefile  |2 +-
 drivers/usb/early/Makefile|1 +
 drivers/usb/early/xhci-dbc.c  | 1026 +
 drivers/usb/early/xhci-dbc.h  |  210 +
 include/linux/usb/xhci-dbgp.h |   29 ++
 7 files changed, 1287 insertions(+), 1 deletion(-)
 create mode 100644 drivers/usb/early/xhci-dbc.c
 create mode 100644 drivers/usb/early/xhci-dbc.h
 create mode 100644 include/linux/usb/xhci-dbgp.h

diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index 67eec55..2216256 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -5,6 +5,9 @@ config TRACE_IRQFLAGS_SUPPORT
 
 source "lib/Kconfig.debug"
 
+config EARLY_PRINTK_USB
+   bool
+
 config X86_VERBOSE_BOOTUP
bool "Enable verbose x86 bootup info messages"
default y
@@ -29,6 +32,7 @@ config EARLY_PRINTK
 config EARLY_PRINTK_DBGP
bool "Early printk via EHCI debug port"
depends on EARLY_PRINTK && PCI
+   select EARLY_PRINTK_USB
---help---
  Write kernel log output directly into the EHCI debug port.
 
@@ -48,6 +52,19 @@ config EARLY_PRINTK_EFI
  This is useful for kernel debugging when your machine crashes very
  early before the console code is initialized.
 
+config EARLY_PRINTK_USB_XDBC
+   bool "Early printk via the xHCI debug port"
+   depends on EARLY_PRINTK && PCI
+   select EARLY_PRINTK_USB
+   ---help---
+ Write kernel log output directly into the xHCI debug port.
+
+ This is useful for kernel debugging when your machine crashes very
+ early before the console code is initialized. For normal operation
+ it is not recommended because it looks ugly and doesn't cooperate
+ with klogd/syslogd or the X server. You should normally N here,
+ unless you want to debug such a crash.
+
 config X86_PTDUMP_CORE
def_bool n
 
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index fbe493d..9313fff 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -19,6 +19,9 @@ config USB_EHCI_BIG_ENDIAN_MMIO
 config USB_EHCI_BIG_ENDIAN_DESC
bool
 
+config USB_EARLY_PRINTK
+   bool
+
 menuconfig USB_SUPPORT
bool "USB support"
depends on HAS_IOMEM
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 7791af6..53d1356 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -49,7 +49,7 @@ obj-$(CONFIG_USB_MICROTEK)+= image/
 obj-$(CONFIG_USB_SERIAL)   += serial/
 
 obj-$(CONFIG_USB)  += misc/
-obj-$(CONFIG_EARLY_PRINTK_DBGP)+= early/
+obj-$(CONFIG_EARLY_PRINTK_USB) += early/
 
 obj-$(CONFIG_USB_ATM)  += atm/
 obj-$(CONFIG_USB_SPEEDTOUCH)   += atm/
diff --git a/drivers/usb/early/Makefile b/drivers/usb/early/Makefile
index 24bbe51..fcde228 100644
--- a/drivers/usb/early/Makefile
+++ b/drivers/usb/early/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_EARLY_PRINTK_DBGP) += ehci-dbgp.o
+obj-$(CONFIG_EARLY_PRINTK_USB_XDBC) += xhci-dbc.o
diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
new file mode 100644
index 000..3250172
--- /dev/null
+++ b/drivers/usb/early/xhci-dbc.c
@@ -0,0 +1,1026 @@
+/**
+ * xhci-dbc.c - xHCI debug capability early driver
+ *
+ * Copyright (C) 2016 Intel Corporation
+ *
+ * Author: Lu Baolu 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#define pr_fmt(fmt)KBUILD_MODNAME ":%s: " fmt, __func__
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../host/xhci.h"
+#include "xhci-dbc.h"
+
+static struct xdbc_state xdbc;
+static bool early_console_keep;
+
+#define XDBC_TR

RE: [PATCH -next] usb: dwc2: Fix the error handling of dwc2_pci_probe()

2017-02-13 Thread weiyongjun (A)
Hi Vardan,

> 
> We have patch doing the same in our internal branch, please review it
> below. We will send it out after internal review/testing process.
> 
> usb: dwc2: pci: Fix error handling in dwc2_pci_probe
> 
> Move usb_phy_generic_register() function call to the top, to simplify
> error handling.
> 
> Replace kzalloc() with devm_kzalloc().
> 
> After platform_device_add(), if we error out, we must do
> platform_device_unregister(), which also does the put. So lets move
> devm_kzalloc() to simplify error handling and avoid
> calling of platform_device_unregister().
> 
> Change-Id: Ic183ee233f5dc622e9e6126c1bfd4890baee1f76
> Signed-off-by: Vardan Mikayelyan 


Your patch is ok to me.


> 
> diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c
> index fdeb8c7..7696131 100644
> --- a/drivers/usb/dwc2/pci.c
> +++ b/drivers/usb/dwc2/pci.c
> @@ -104,10 +104,17 @@ static int dwc2_pci_probe(struct pci_dev *pci,
> 
>  pci_set_master(pci);
> 
> +   phy = usb_phy_generic_register();
> +   if (IS_ERR(phy)) {
> +   dev_err(dev, "error registering generic PHY (%ld)\n",
> +   PTR_ERR(phy));
> +   return PTR_ERR(phy);
> +   }
> +
>  dwc2 = platform_device_alloc("dwc2", PLATFORM_DEVID_AUTO);
>  if (!dwc2) {
>  dev_err(dev, "couldn't allocate dwc2 device\n");
> -   return -ENOMEM;
> +   goto err;
>  }
> 
>  memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res));
> @@ -124,32 +131,25 @@ static int dwc2_pci_probe(struct pci_dev *pci,
>  ret = platform_device_add_resources(dwc2, res, ARRAY_SIZE(res));
>  if (ret) {
>  dev_err(dev, "couldn't add resources to dwc2 device\n");
> -   return ret;
> +   goto err;
>  }
> 
>  dwc2->dev.parent = dev;
> 
> -   phy = usb_phy_generic_register();
> -   if (IS_ERR(phy)) {
> -   dev_err(dev, "error registering generic PHY (%ld)\n",
> -   PTR_ERR(phy));
> -   return PTR_ERR(phy);
> -   }
> -
>  ret = dwc2_pci_quirks(pci, dwc2);
>  if (ret)
>  goto err;
> 
> +   glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL);
> +   if (!glue)
> +   goto err;
> +
>  ret = platform_device_add(dwc2);
>  if (ret) {
>  dev_err(dev, "failed to register dwc2 device\n");
>  goto err;
>  }
> 
> -   glue = kzalloc(sizeof(*glue), GFP_KERNEL);
> -   if (!glue)
> -   return -ENOMEM;
> -
>  glue->phy = phy;
> 
> 
> Thanks,
> Vardan.
> 
> 

--
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: dwc2: Make sure we disconnect the gadget state

2017-02-13 Thread John Stultz
Just wanted to get some early feedback on this before I submit
it for real for the 4.12 timeframe. This is the last patch, that
isn't already queued, which I need to get hikey's USB working
properly.

Feedback would be greatly appreciated!

thanks
-john


I had seen some odd behavior with HiKey's usb-gadget interface
that I finally seemed to have chased down. Basically every other
time I pluged in the OTG port, the gadget interface would
properly initialize. The other times, I'd get a big WARN_ON
in dwc2_hsotg_init_fifo() about the fifo_map not being clear.

Ends up if we don't disconnect the gadget state, the fifo-map
doesn't get cleared properly, which causes WARN_ON messages and
also results in the device not properly being setup as a gadget
every other time the OTG port is connected.

So this patch adds a call to dwc2_hsotg_disconnect() in the
reset path so the state is properly cleared.

With it, the gadget interface initializes properly on every
plug in.

Cc: Wei Xu 
Cc: Guodong Xu 
Cc: Amit Pundir 
Cc: Rob Herring 
Cc: John Youn 
Cc: Douglas Anderson 
Cc: Chen Yu 
Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: linux-usb@vger.kernel.org
Signed-off-by: John Stultz 
---
 drivers/usb/dwc2/hcd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 90bd248..067202d 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -3266,6 +3266,7 @@ static void dwc2_conn_id_status_change(struct work_struct 
*work)
dwc2_core_init(hsotg, false);
dwc2_enable_global_interrupts(hsotg);
spin_lock_irqsave(&hsotg->lock, flags);
+   dwc2_hsotg_disconnect(hsotg);
dwc2_hsotg_core_init_disconnected(hsotg, false);
spin_unlock_irqrestore(&hsotg->lock, flags);
dwc2_hsotg_core_connect(hsotg);
-- 
2.7.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 v7 5/5] usb: doc: add document for USB3 debug port usage

2017-02-13 Thread Lu Baolu
Hi,

On 02/14/2017 11:45 AM, Peter Chen wrote:
> On Tue, Feb 14, 2017 at 10:27 AM, Lu Baolu  wrote:
>
>> Add Documentation/usb/usb3-debug-port.rst. This document includes
>> the user guide for USB3 debug port.
>>
>> Cc: linux-...@vger.kernel.org
>> Signed-off-by: Lu Baolu 
>> ---
>>  Documentation/usb/usb3-debug-port.rst | 98 ++
>> +
>>  1 file changed, 98 insertions(+)
>>  create mode 100644 Documentation/usb/usb3-debug-port.rst
>>
>> diff --git a/Documentation/usb/usb3-debug-port.rst
>> b/Documentation/usb/usb3-debug-port.rst
>> new file mode 100644
>> index 000..9eddb3a
>> --- /dev/null
>> +++ b/Documentation/usb/usb3-debug-port.rst
>> @@ -0,0 +1,98 @@
>> +===
>> +USB3 debug port
>> +===
>> +
>> +:Author: Lu Baolu 
>> +:Date: January 2017
>> +
>> +GENERAL
>> +===
>> +
>> +This is a HOWTO for using USB3 debug port on x86 systems.
>> +
>> +Before using any kernel debugging functionality based on USB3
>> +debug port, you need to check 1) whether debug port is supported
>> +by the xHCI host; 2) which port is used for debugging purposes
>> +(normally the first USB3 root port). You must have a USB 3.0
>> +super-speed A-to-A debugging cable to connect the debug target
>> +with a debug host. In this document, "debug target" stands for
>> +the system under debugging, and "debug host" stands for a
>> +stand-alone system that is able to talk to the debugging target
>> +through the USB3 debug port.
>> +
>> +EARLY PRINTK
>> +
>> +
>> +On the debug target system, you need to customize a debugging
>> +kernel with CONFIG_EARLY_PRINTK_USB_XDBC enabled. And, add
>> +below kernel boot parameter::
>> +
>> +   "earlyprintk=xdbc"
>> +
>> +If there are multiple xHCI controllers in the system, you can
>> +append a host contoller index to this kernel parameter. This
>> +index starts from 0.
>> +
>> +If you are going to use the "keep" option defined by the
>> +early printk framework to keep the boot console alive after
>> +early boot, you'd better add below kernel boot parameter::
>> +
>> +   "usbcore.autosuspend=-1"
>> +
>> +On the debug host side, you don't need to customize the kernel,
>> +but you'd better disable usb subsystem runtime power management
>> +by adding below kernel boot parameter::
>> +
>> +   "usbcore.autosuspend=-1"
>> +
>>
> Just curious, why autosuspend needs to be disabled for this function?

This implementation doesn't support suspend/resume yet.

Best regards,
Lu Baolu

>
> BR,
> 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] USB: serial: ftdi_sio: add device ID for Microsemi/Arrow SF2PLUS Dev Kit

2017-02-13 Thread Marek Vasut
On 02/13/2017 10:29 AM, Johan Hovold wrote:
> [+CC: linux-usb]
> 
> Always make sure to CC linux-usb for USB patches.

Got it

> On Fri, Feb 10, 2017 at 05:16:12PM +0100, Marek Vasut wrote:
>> This development kit has an FT4232 on it with a custom USB VID/PID.
>> The FT4232 provides four UARTs, but only two are used. The UART 0
>> is used by the FlashPro5 programmer and UART 2 is connected to the
>> SmartFusion2 CortexM3 SoC UART port.
> 
> Don't you want to use the "jtag" quirk for this one then to prevent the
> driver from binding to interface 0? Or do you still need this interface
> to be accessible as a tty device?

I will check that next week as I don't have access to the HW this week.

>> Note that the USB VID is registered to Actel according to Linux USB
>> VID database, but that was acquired by Microsemi.
>>
>> Signed-off-by: Marek Vasut 
>> Cc: stable 
>> Cc: Johan Hovold 
>> ---
>>  drivers/usb/serial/ftdi_sio.c |  1 +
>>  drivers/usb/serial/ftdi_sio_ids.h | 10 ++
>>  2 files changed, 11 insertions(+)
>>
>> diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
>> index c98cf10be5af..14f0fb34f655 100644
>> --- a/drivers/usb/serial/ftdi_sio.c
>> +++ b/drivers/usb/serial/ftdi_sio.c
>> @@ -873,6 +873,7 @@ static const struct usb_device_id id_table_combined[] = {
>>  { USB_DEVICE_AND_INTERFACE_INFO(MICROCHIP_VID, MICROCHIP_USB_BOARD_PID,
>>  USB_CLASS_VENDOR_SPEC,
>>  USB_SUBCLASS_VENDOR_SPEC, 0x00) },
>> +{ USB_DEVICE(ACTEL_VID, MICROSEMI_ARROW_SF2PLUS_BOARD_PID) },
>>  { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) },
>>  { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID),
>>  .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
>> diff --git a/drivers/usb/serial/ftdi_sio_ids.h 
>> b/drivers/usb/serial/ftdi_sio_ids.h
>> index 168ccb03ce08..a9d538d18344 100644
>> --- a/drivers/usb/serial/ftdi_sio_ids.h
>> +++ b/drivers/usb/serial/ftdi_sio_ids.h
>> @@ -627,6 +627,16 @@
>>  #define MICROCHIP_USB_BOARD_PID 0x000A /* CDC RS-232 Emulation Demo */
>>  
>>  /*
>> + * Microsemi/Arrow SF2PLUS Dev Kit
>> + *
>> + * This board has an FT4232 on it which provides four UART ports.
>> + * UART 0 is used by the FlashPro5 programmer, UART 2 is connected
>> + * to the UART of an CortexM3 SoC-FPGA on the board.
>> + */
>> +#define ACTEL_VID   0x1514
>> +#define MICROSEMI_ARROW_SF2PLUS_BOARD_PID   0x2008
>> +
> 
> Please place this before the Olimex section to try to maintain some
> order based on VID.

So ordering of the file is based on the VIDs , got it and done.

>> +/*
>>   * RATOC REX-USB60F
>>   */
>>  #define RATOC_VENDOR_ID 0x0584
> 
> Thanks,
> Johan
> 


-- 
Best regards,
Marek Vasut
--
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: gadget: udc: remove pointer dereference after free

2017-02-13 Thread Gustavo A. R. Silva

Hi Michal,

Quoting Michal Nazarewicz :


On Sat, Feb 11 2017, Gustavo A. R. Silva wrote:

Remove pointer dereference after free and set pointer to NULL after free.

Addresses-Coverity-ID: 1091173
Signed-off-by: Gustavo A. R. Silva 


Acked-by: Michal Nazarewicz 


---
Changes in v2:
  Move pointer dereference before pci_pool_free()
  Set pointer to NULL after free

  drivers/usb/gadget/udc/pch_udc.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/pch_udc.c
b/drivers/usb/gadget/udc/pch_udc.c
index a97da64..73bb58f 100644
--- a/drivers/usb/gadget/udc/pch_udc.c
+++ b/drivers/usb/gadget/udc/pch_udc.c
@@ -1522,8 +1522,9 @@ static void pch_udc_free_dma_chain(struct
pch_udc_dev *dev,
/* do not free first desc., will be done by free for request */
td = phys_to_virt(addr);
addr2 = (dma_addr_t)td->next;
-   pci_pool_free(dev->data_requests, td, addr);
td->next = 0x00;


Or just drop this.  pci_pool_free doesn’t care about contents of td.
It’s just a void* for it.


+   pci_pool_free(dev->data_requests, td, addr);
+   td = NULL;


This isn’t necessary either.  td will get overwritten on next iteration
and once we’re done it’s not used again.


addr = addr2;
}
req->chain_len = 1;




Thanks for your comments, I will send version 3 shortly.
--
Gustavo A. R. Silva




--
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 v3] usb: gadget: udc: remove pointer dereference after free

2017-02-13 Thread Gustavo A. R. Silva

Remove pointer dereference after free.

Addresses-Coverity-ID: 1091173
Acked-by: Michal Nazarewicz 
Signed-off-by: Gustavo A. R. Silva 
---
Changes in v2:
 Move pointer dereference before pci_pool_free()
 Set pointer to NULL after free

Changes in v3:
 Remove 'td->next = 0x00' inside for loop.
 Remove unnecessary pointer nullification after free.

 drivers/usb/gadget/udc/pch_udc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/pch_udc.c  
b/drivers/usb/gadget/udc/pch_udc.c

index a97da64..8a365aa 100644
--- a/drivers/usb/gadget/udc/pch_udc.c
+++ b/drivers/usb/gadget/udc/pch_udc.c
@@ -1523,7 +1523,6 @@ static void pch_udc_free_dma_chain(struct  
pch_udc_dev *dev,

td = phys_to_virt(addr);
addr2 = (dma_addr_t)td->next;
pci_pool_free(dev->data_requests, td, addr);
-   td->next = 0x00;
addr = addr2;
}
req->chain_len = 1;
--
2.5.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


Re: [PATCH v13 06/12] usb: xhci: use bus->sysdev for DMA configuration

2017-02-13 Thread Vivek Gautam



On 02/11/2017 06:57 AM, Peter Chen wrote:

From: Arnd Bergmann 

For xhci-hcd platform device, all the DMA parameters are not
configured properly, notably dma ops for dwc3 devices. So, set
the dma for xhci from sysdev. sysdev is pointing to device that
is known to the system firmware or hardware.

Cc: Baolin Wang 
Cc: Vivek Gautam 
Cc: Alexander Sverdlin 
Cc: Mathias Nyman 

Signed-off-by: Arnd Bergmann 
Signed-off-by: Sriram Dash 
---
Hi, Baolin, Vivek and Alexander,
I removed your tested-by tag due to add one change that adding sysdev
for shared hcd too, if your test shows this change works for you or
has no effect for you, please consider adding tested-by tag again,
thanks.


Works well with 4.10-rc8 branch merged with usb-next and the
set of phy patches for msm8996 and corresponding dt patches.

Tested-by: Vivek Gautam 

Thanks
Vivek


  drivers/usb/host/xhci-mem.c  | 12 ++--
  drivers/usb/host/xhci-plat.c | 35 +++
  drivers/usb/host/xhci.c  | 15 +++
  3 files changed, 44 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index ba1853f4..032a702 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -586,7 +586,7 @@ static void xhci_free_stream_ctx(struct xhci_hcd *xhci,
unsigned int num_stream_ctxs,
struct xhci_stream_ctx *stream_ctx, dma_addr_t dma)
  {
-   struct device *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs;
  
  	if (size > MEDIUM_STREAM_ARRAY_SIZE)

@@ -614,7 +614,7 @@ static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct 
xhci_hcd *xhci,
unsigned int num_stream_ctxs, dma_addr_t *dma,
gfp_t mem_flags)
  {
-   struct device *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs;
  
  	if (size > MEDIUM_STREAM_ARRAY_SIZE)

@@ -1686,7 +1686,7 @@ void xhci_slot_copy(struct xhci_hcd *xhci,
  static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
  {
int i;
-   struct device *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
int num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2);
  
  	xhci_dbg_trace(xhci, trace_xhci_dbg_init,

@@ -1758,7 +1758,7 @@ static void scratchpad_free(struct xhci_hcd *xhci)
  {
int num_sp;
int i;
-   struct device *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
  
  	if (!xhci->scratchpad)

return;
@@ -1831,7 +1831,7 @@ void xhci_free_command(struct xhci_hcd *xhci,
  
  void xhci_mem_cleanup(struct xhci_hcd *xhci)

  {
-   struct device   *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device   *dev = xhci_to_hcd(xhci)->self.sysdev;
int size;
int i, j, num_ports;
  
@@ -2373,7 +2373,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)

  int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
  {
dma_addr_t  dma;
-   struct device   *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device   *dev = xhci_to_hcd(xhci)->self.sysdev;
unsigned intval, val2;
u64 val_64;
struct xhci_segment *seg;
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 6d33b42..4ecb3fd 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -14,6 +14,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -148,6 +149,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
  {
const struct of_device_id *match;
const struct hc_driver  *driver;
+   struct device   *sysdev;
struct xhci_hcd *xhci;
struct resource *res;
struct usb_hcd  *hcd;
@@ -164,22 +166,39 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (irq < 0)
return -ENODEV;
  
+	/*

+* sysdev must point to a device that is known to the system firmware
+* or PCI hardware. We handle these three cases here:
+* 1. xhci_plat comes from firmware
+* 2. xhci_plat is child of a device from firmware (dwc3-plat)
+* 3. xhci_plat is grandchild of a pci device (dwc3-pci)
+*/
+   sysdev = &pdev->dev;
+   if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
+   sysdev = sysdev->parent;
+#ifdef CONFIG_PCI
+   else if (sysdev->parent && sysdev->parent->parent &&
+sysdev->parent->parent->bus == &pci_bus_type)
+   sysdev = sysdev->parent->parent;
+#endif
+
/* Try to set 64-bit DMA first */
-   if (!pdev->

UAS not working with JMS567 based disk enclosure

2017-02-13 Thread Jack Coulter
Hi,

I'm using an external multiple-disk enclosure (specifically a Hotway
H82-SU3S2), which from lsusb appears to use a JMS567 SATA-USB bridge:

> Bus 002 Device 002: ID 152d:0567 JMicron Technology Corp. / JMicron
> USA Technology Corp. JMS567 SATA 6Gb/s bridge


According to the manufacturer's product sheet [1] for this chip, it
supports the UAS protocol, but when connected to my system (running
kernel 4.9.8), it falls back to the older usb-storage driver:

> /:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
> |__ Port 3: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M


I had a look at uas-detect.h, specifically uas_use_uas_driver, but I
didn't see any of the warning messages within that function printed to
dmesg when the device is attached. I added some extra dev_warn calls
earlier in the function and determined that uas_find_uas_alt_setting is
returning a negative value. This prompted me to look at the output of
lsusb -v for this device:

> Bus 002 Device 002: ID 152d:0567 JMicron Technology Corp. / JMicron
> USA Technology Corp. JMS567 SATA 6Gb/s bridge
> Device Descriptor:
>   bLength18
>   bDescriptorType 1
>   bcdUSB   3.00
>   bDeviceClass0
>   bDeviceSubClass 0
>   bDeviceProtocol 0
>   bMaxPacketSize0 9
>   idVendor   0x152d JMicron Technology Corp. / JMicron USA
> Technology Corp.
>   idProduct  0x0567 JMS567 SATA 6Gb/s bridge
>   bcdDevice2.05
>   iManufacturer  10 JMicron
>   iProduct   11 USB to ATA/ATAPI Bridge
>   iSerial 5 152D00539000
>   bNumConfigurations  1
>   Configuration Descriptor:
> bLength 9
> bDescriptorType 2
> wTotalLength   44
> bNumInterfaces  1
> bConfigurationValue 1
> iConfiguration  0
> bmAttributes 0xc0
>   Self Powered
> MaxPower2mA
> Interface Descriptor:
>   bLength 9
>   bDescriptorType 4
>   bInterfaceNumber0
>   bAlternateSetting   0
>   bNumEndpoints   2
>   bInterfaceClass 8 Mass Storage
>   bInterfaceSubClass  6 SCSI
>   bInterfaceProtocol 80 Bulk-Only
>   iInterface  0
>   Endpoint Descriptor:
> bLength 7
> bDescriptorType 5
> bEndpointAddress 0x81  EP 1 IN
> bmAttributes2
>   Transfer TypeBulk
>   Synch Type   None
>   Usage Type   Data
> wMaxPacketSize 0x0400  1x 1024 bytes
> bInterval   0
> bMaxBurst  15
>   Endpoint Descriptor:
> bLength 7
> bDescriptorType 5
> bEndpointAddress 0x02  EP 2 OUT
> bmAttributes2
>   Transfer TypeBulk
>   Synch Type   None
>   Usage Type   Data
> wMaxPacketSize 0x0400  1x 1024 bytes
> bInterval   0
> bMaxBurst  15
> Binary Object Store Descriptor:
>   bLength 5
>   bDescriptorType15
>   wTotalLength   22
>   bNumDeviceCaps  2
>   USB 2.0 Extension Device Capability:
> bLength 7
> bDescriptorType16
> bDevCapabilityType  2
> bmAttributes   0x0002
>   HIRD Link Power Management (LPM) Supported
>   SuperSpeed USB Device Capability:
> bLength10
> bDescriptorType16
> bDevCapabilityType  3
> bmAttributes 0x00
> wSpeedsSupported   0x000e
>   Device can operate at Full Speed (12Mbps)
>   Device can operate at High Speed (480Mbps)
>   Device can operate at SuperSpeed (5Gbps)
> bFunctionalitySupport   1
>   Lowest fully-functional device speed is Full Speed (12Mbps)
> bU1DevExitLat  10 micro seconds
> bU2DevExitLat2047 micro seconds
> Device Status: 0x000d
>   Self Powered
>   U1 Enabled
>   U2 Enabled

It seems that it's lacking the interface descriptor for UAS, when I
compared it to the output from a different enclosure with which UAS
works correctly:

> Bus 002 Device 092: ID 174c:1351 ASMedia Technology Inc.
> Device Descriptor:
>   bLength18
>   bDescriptorType 1
>   bcdUSB   3.10
>   bDeviceClass0
>   bDeviceSubClass 0
>   bDeviceProtocol 0
>   bMaxPacketSize0 9
>   idVendor   0x174c ASMedia Technology Inc.
>   idProduct  0x1351
>   bcdDevice0.01
>   iManufacturer   2
>   iProduct3
>   iSerial 1
>   bNumConfigurations  1
>   Configuration Descriptor:
> bLength 9
> bDescriptorType 2
> wTotalLength   

RE: [PATCH v7 5/5] usb: doc: add document for USB3 debug port usage

2017-02-13 Thread Peter Chen
 
>
>On 02/14/2017 11:45 AM, Peter Chen wrote:
>> On Tue, Feb 14, 2017 at 10:27 AM, Lu Baolu  wrote:
>>
>>> Add Documentation/usb/usb3-debug-port.rst. This document includes the
>>> user guide for USB3 debug port.
>>>
>>> Cc: linux-...@vger.kernel.org
>>> Signed-off-by: Lu Baolu 
>>> ---
>>>  Documentation/usb/usb3-debug-port.rst | 98
>>> ++
>>> +
>>>  1 file changed, 98 insertions(+)
>>>  create mode 100644 Documentation/usb/usb3-debug-port.rst
>>>
>>> diff --git a/Documentation/usb/usb3-debug-port.rst
>>> b/Documentation/usb/usb3-debug-port.rst
>>> new file mode 100644
>>> index 000..9eddb3a
>>> --- /dev/null
>>> +++ b/Documentation/usb/usb3-debug-port.rst
>>> @@ -0,0 +1,98 @@
>>> +===
>>> +USB3 debug port
>>> +===
>>> +
>>> +:Author: Lu Baolu 
>>> +:Date: January 2017
>>> +
>>> +GENERAL
>>> +===
>>> +
>>> +This is a HOWTO for using USB3 debug port on x86 systems.
>>> +
>>> +Before using any kernel debugging functionality based on USB3 debug
>>> +port, you need to check 1) whether debug port is supported by the
>>> +xHCI host; 2) which port is used for debugging purposes (normally
>>> +the first USB3 root port). You must have a USB 3.0 super-speed
>>> +A-to-A debugging cable to connect the debug target with a debug
>>> +host. In this document, "debug target" stands for the system under
>>> +debugging, and "debug host" stands for a stand-alone system that is
>>> +able to talk to the debugging target through the USB3 debug port.
>>> +
>>> +EARLY PRINTK
>>> +
>>> +
>>> +On the debug target system, you need to customize a debugging kernel
>>> +with CONFIG_EARLY_PRINTK_USB_XDBC enabled. And, add below kernel
>>> +boot parameter::
>>> +
>>> +   "earlyprintk=xdbc"
>>> +
>>> +If there are multiple xHCI controllers in the system, you can append
>>> +a host contoller index to this kernel parameter. This index starts
>>> +from 0.
>>> +
>>> +If you are going to use the "keep" option defined by the early
>>> +printk framework to keep the boot console alive after early boot,
>>> +you'd better add below kernel boot parameter::
>>> +
>>> +   "usbcore.autosuspend=-1"
>>> +
>>> +On the debug host side, you don't need to customize the kernel, but
>>> +you'd better disable usb subsystem runtime power management by
>>> +adding below kernel boot parameter::
>>> +
>>> +   "usbcore.autosuspend=-1"
>>> +
>>>
>> Just curious, why autosuspend needs to be disabled for this function?
>
>This implementation doesn't support suspend/resume yet.
 
Why host side needs to disable it too?

Peter
N�r��yb�X��ǧv�^�)޺{.n�+{��^n�r���z���h�&���G���h�(�階�ݢj"���m��z�ޖ���f���h���~�m�

Re: [PATCH v7 5/5] usb: doc: add document for USB3 debug port usage

2017-02-13 Thread Lu Baolu
Hi,

On 02/14/2017 02:13 PM, Peter Chen wrote:
>  
>> On 02/14/2017 11:45 AM, Peter Chen wrote:
>>> On Tue, Feb 14, 2017 at 10:27 AM, Lu Baolu  wrote:
>>>
 Add Documentation/usb/usb3-debug-port.rst. This document includes the
 user guide for USB3 debug port.

 Cc: linux-...@vger.kernel.org
 Signed-off-by: Lu Baolu 
 ---
  Documentation/usb/usb3-debug-port.rst | 98
 ++
 +
  1 file changed, 98 insertions(+)
  create mode 100644 Documentation/usb/usb3-debug-port.rst

 diff --git a/Documentation/usb/usb3-debug-port.rst
 b/Documentation/usb/usb3-debug-port.rst
 new file mode 100644
 index 000..9eddb3a
 --- /dev/null
 +++ b/Documentation/usb/usb3-debug-port.rst
 @@ -0,0 +1,98 @@
 +===
 +USB3 debug port
 +===
 +
 +:Author: Lu Baolu 
 +:Date: January 2017
 +
 +GENERAL
 +===
 +
 +This is a HOWTO for using USB3 debug port on x86 systems.
 +
 +Before using any kernel debugging functionality based on USB3 debug
 +port, you need to check 1) whether debug port is supported by the
 +xHCI host; 2) which port is used for debugging purposes (normally
 +the first USB3 root port). You must have a USB 3.0 super-speed
 +A-to-A debugging cable to connect the debug target with a debug
 +host. In this document, "debug target" stands for the system under
 +debugging, and "debug host" stands for a stand-alone system that is
 +able to talk to the debugging target through the USB3 debug port.
 +
 +EARLY PRINTK
 +
 +
 +On the debug target system, you need to customize a debugging kernel
 +with CONFIG_EARLY_PRINTK_USB_XDBC enabled. And, add below kernel
 +boot parameter::
 +
 +   "earlyprintk=xdbc"
 +
 +If there are multiple xHCI controllers in the system, you can append
 +a host contoller index to this kernel parameter. This index starts
 +from 0.
 +
 +If you are going to use the "keep" option defined by the early
 +printk framework to keep the boot console alive after early boot,
 +you'd better add below kernel boot parameter::
 +
 +   "usbcore.autosuspend=-1"
 +
 +On the debug host side, you don't need to customize the kernel, but
 +you'd better disable usb subsystem runtime power management by
 +adding below kernel boot parameter::
 +
 +   "usbcore.autosuspend=-1"
 +

>>> Just curious, why autosuspend needs to be disabled for this function?
>> This implementation doesn't support suspend/resume yet.
>  
> Why host side needs to disable it too?

If host side runtime suspend/resume is enabled, it might ask the
debug device to suspend. This will cause the debug device dead.

The suspend/resume of the debug device depends on xhci driver.
I will make it happen in separated patches with more tests. It's in
my TODO list.

Best regards,
Lu Baolu
--
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