Re: [PATCH 2/2] usb: dwc2: gadget: Accept LPM token when TxFIFO is not empty

2018-10-30 Thread Sergei Shtylyov
Hello!

On 10/30/2018 03:26 PM, Artur Petrosyan wrote:

> To accept LPM token during ISOC transfers when TxFIFO
> is not empty.
> 
> Signed-off-by: Artur Petrosyan 
> Signed-off-by: Minas Harutyunyan 
> ---
>  drivers/usb/dwc2/gadget.c | 1 +
>  drivers/usb/dwc2/hw.h | 3 +++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index 6bd4054e894d..63d53619fd21 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -5026,6 +5026,7 @@ void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg)
>   val |= hsotg->params.lpm_clock_gating ? GLPMCFG_ENBLSLPM : 0;
>   val |= hsotg->params.hird_threshold << GLPMCFG_HIRD_THRES_SHIFT;
>   val |= hsotg->params.besl ? GLPMCFG_ENBESL : 0;
> + val |= GLPMCFG_RETRY_CNT_1;
>   dwc2_writel(hsotg, val, GLPMCFG);
>   dev_dbg(hsotg->dev, "GLPMCFG=0x%08x\n", dwc2_readl(hsotg, GLPMCFG));
>  
> diff --git a/drivers/usb/dwc2/hw.h b/drivers/usb/dwc2/hw.h
> index 2b1ea441b7d4..84d2b32f4831 100644
> --- a/drivers/usb/dwc2/hw.h
> +++ b/drivers/usb/dwc2/hw.h
> @@ -333,6 +333,9 @@
>  #define GLPMCFG_SNDLPM   BIT(24)
>  #define GLPMCFG_RETRY_CNT_MASK   (0x7 << 21)
>  #define GLPMCFG_RETRY_CNT_SHIFT  21
> +#define GLPMCFG_RETRY_CNT_0  21
> +#define GLPMCFG_RETRY_CNT_1  22
> +#define GLPMCFG_RETRY_CNT_2  23

   Not '(0|1|2 << 21)'?

[...]

MBR, Sergei


Re: [PATCH 2/3] net: ethernet: Remove dummy runtime PM callbacks from Renesas drivers

2018-10-24 Thread Sergei Shtylyov
Hello!

On 10/24/2018 04:51 PM, Jarkko Nikula wrote:

> Platform drivers don't need dummy runtime PM callbacks that just return
> success in order to have runtime PM happening. This has changed since
> following commits:
> 
> 05aa55dddb9e ("PM / Runtime: Lenient generic runtime pm callbacks")
> 543f2503a956 ("PM / platform_bus: Allow runtime PM by default")
> 8b313a38ecff ("PM / Platform: Use generic runtime PM callbacks directly")

   Wow, these are old! :-)

> Signed-off-by: Jarkko Nikula 
> ---
> Only build tested.

   Seems long overdue...

[...]

Reviewed-by: Sergei Shtylyov 

MBR, Sergei


Re: [PATCH v2 -next] usb: typec: remove set but not used variables 'snk_ma, flags'

2018-09-29 Thread Sergei Shtylyov

Hello!

On 9/29/2018 9:58 AM, YueHaibing wrote:


Fixes gcc '-Wunused-but-set-variable' warning:

drivers/usb/typec/tcpm/tcpm.c: In function 'tcpm_pd_select_pps_apdo':
drivers/usb/typec/tcpm/tcpm.c:2212:39: warning:
  variable 'snk_ma' set but not used [-Wunused-but-set-variable]

drivers/usb/typec/tcpm/tcpm.c: In function 'tcpm_pd_build_pps_request':
drivers/usb/typec/tcpm/tcpm.c:2405:37: warning:
  variable 'min_mv' set but not used [-Wunused-but-set-variable]


   The subject still doesn't match the description and the diff.


Signed-off-by: YueHaibing 

[...]

MBR, Sergei


Re: [PATCH] ALSA: usb-audio: ensure that cluster header size is enough

2018-09-22 Thread Sergei Shtylyov
Hello!

On 09/22/2018 04:38 PM, Dan Carpenter wrote:

> I think we need a check to make sure that "hc_header.wLength" is large
> enough for a struct struct uac3_cluster_header_descriptor.

   struct struct? :-)

> Fixes: 9a2fe9b801f5 ("ALSA: usb: initial USB Audio Device Class 3.0 support")
> Signed-off-by: Dan Carpenter 

[...]

MBR, Sergei


Re: [PATCH 2/3] usb: host: xhci: return -ESHUTDOWN when removing hcd

2018-09-21 Thread Sergei Shtylyov

On 9/21/2018 4:48 AM, Peter Chen wrote:


When we are removing HCD, the xhci_configure_endpoint may be timeout.
To get rid of timeout, we'd better return before issue command.
The related log message when removing HCD like below:

[66.736633] usb 3-1: USB disconnect, device number 2
[66.737003] hub 3-1:1.0: hub_ext_port_status failed (err = -71)
[66.737054] usb 3-1.1: USB disconnect, device number 3
[66.759910] xhci-hcd xhci-hcd.1.auto: remove, state 4
[66.765043] usb usb4: USB disconnect, device number 1
[66.770169] usb 4-1: USB disconnect, device number 2
[74.008294] xhci-hcd xhci-hcd.1.auto: Timeout while waiting for
configure endpoint command
[74.018737] xhci-hcd xhci-hcd.1.auto: USB bus 4 deregistered
[74.024446] xhci-hcd xhci-hcd.1.auto: remove, state 1
[74.029594] usb usb3: USB disconnect, device number 1
[74.062310] xhci-hcd xhci-hcd.1.auto: USB bus 3 deregistered

Signed-off-by: Peter Chen 
---
  drivers/usb/host/xhci.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 0420eefa647a..3113938063fd 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -2698,7 +2698,8 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci,
  
  	spin_lock_irqsave(>lock, flags);
  
-	if (xhci->xhc_state & XHCI_STATE_DYING) {

+   if (xhci->xhc_state & XHCI_STATE_DYING ||
+   xhci->xhc_state & XHCI_STATE_REMOVING) {


   Same comment as to the patch 3/3.


spin_unlock_irqrestore(>lock, flags);
return -ESHUTDOWN;
}


MBR, Sergei



Re: [PATCH 3/3] usb: host: xhci: return early for xhci_urb_dequeue when removing hcd

2018-09-21 Thread Sergei Shtylyov

On 9/21/2018 4:48 AM, Peter Chen wrote:


When we are removing hcd, the stop endpoint command may be timeout.
To eliminate the timeout, we'd better return early. The related log
for this timeout like below:

[31.208933] hub 3-1:1.0: hub_ext_port_status failed (err = -71)
[31.214972] usb 3-1-port2: cannot reset (err = -71)
[31.219962] usb 3-1-port2: cannot reset (err = -71)
[31.225069] usb 3-1-port2: cannot reset (err = -71)
[31.230018] usb 3-1-port2: Cannot enable. Maybe the USB cable is bad?
[31.236566] usb 3-1-port2: cannot disable (err = -71)
[31.241745] usb 3-1-port2: unable to enumerate USB device
[31.247255] usb 3-1-port2: cannot disable (err = -71)
[31.252422] hub 3-1:1.0: hub_ext_port_status failed (err = -71)
[31.258486] hub 3-1:1.0: hub_ext_port_status failed (err = -71)
[31.264518] hub 3-1:1.0: hub_ext_port_status failed (err = -71)
[31.270649] hub 3-1:1.0: hub_ext_port_status failed (err = -71)
[31.276723] hub 3-1:1.0: hub_ext_port_status failed (err = -71)
[31.282809] usb 3-1: USB disconnect, device number 2
[31.287859] usb 3-1.1: USB disconnect, device number 3
[31.293076] usb 3-1.1: unregistering device
[31.299292] xhci-hcd xhci-hcd.1.auto: remove, state 4
[31.304416] usb usb4: USB disconnect, device number 1
[31.309566] usb 4-1: USB disconnect, device number 2
[31.314589] usb 4-1: unregistering device
[31.316389] usb 3-1: unregistering device
[31.331131] usb usb4: unregistering device
[31.339809] xhci-hcd xhci-hcd.1.auto: USB bus 4 deregistered
[31.345534] xhci-hcd xhci-hcd.1.auto: remove, state 1
[31.350668] usb usb3: USB disconnect, device number 1
[36.407457] xhci-hcd xhci-hcd.1.auto: xHCI host not responding to stop endpoint 
command.
[36.423638] xhci-hcd xhci-hcd.1.auto: xHCI host controller not responding, 
assume dead
[36.436502] usb usb3: unregistering device
[36.445429] xhci-hcd xhci-hcd.1.auto: USB bus 3 deregistered

Signed-off-by: Peter Chen 
---
  drivers/usb/host/xhci.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 3113938063fd..1bcf27a9737d 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1601,7 +1601,8 @@ static int xhci_urb_dequeue(struct usb_hcd *hcd, struct 
urb *urb, int status)
goto err_giveback;
}
  
-	if (xhci->xhc_state & XHCI_STATE_HALTED) {

+   if (xhci->xhc_state & XHCI_STATE_HALTED ||
+   xhci->xhc_state & XHCI_STATE_REMOVING) {


   This way this line blends with the branch below, could you indent either 
with 2 tabs (I think it's the style preferred in the USB code) or starting the 
continuation line under xhci on the previous line.



xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
"HC halted, freeing TD manually.");
for (i = urb_priv->num_tds_done;



MBR, Sergei


Re: [PATCH] usb: musb: dsps: do not disable CPPI41 irq in driver teardown

2018-08-22 Thread Sergei Shtylyov
Hello!

On 08/21/2018 09:55 PM, Bin Liu wrote:

> TI AM335x CPPI41 module uses a single register bit for CPPI interrupts in

   It's CPPI 4.1. :-)

> both musb controllers. So disabling the CPPI irq in one musb driver breaks
> the other musb module.
> 
> Since musb is already disabled before tearing down dma controller in
> musb_remove(), it is safe to not disable CPPI irq in
> musb_dma_controller_destroy().
> 
> Fixes: 255348289f71 ("usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in DSPS")
> 

   Should be no empty line here...

> Cc: sta...@vger.kernel.org
> Signed-off-by: Bin Liu 
[...]

MBR, Sergei


Re: [PATCH 4/9] ALSA: usb-audio: use usb_fill_int_urb()

2018-06-20 Thread Sergei Shtylyov

Hello!

On 6/20/2018 12:55 AM, Sebastian Andrzej Siewior wrote:


Using usb_fill_int_urb() helps to find code which initializes an
URB. A grep for members of the struct (like ->complete) reveal lots
of other things, too.

data_ep_set_params() additionally sets urb->transfer_buffer_length which
was not the case earlier.
data_ep_set_params() and data_ep_set_params()


   These 2 are the same function?


ensure that syncinterval is
within the allowed range on HS/SS. The interval value seems to come from
snd_usb_parse_datainterval() which is bInterval - 1 and only in the rage 1 … 4.
So in order to keep the magic wokring I pass datainterval + 1.


   Working.


Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Signed-off-by: Sebastian Andrzej Siewior 

[...]

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


Re: [PATCH 3/3] usb: gadget: storage: Remove EXPORT_SYMBOL_GPL for kref_{put, get}

2018-06-14 Thread Sergei Shtylyov
Hello!

On 06/14/2018 12:23 PM, Jaejoong Kim wrote:

> Removing EXPORT_SYMBOL_GPL from kref_{put, get} since it is used

   I thought you removed the exports from the real kref_{get|put}(). :-)
Your patch subject and description are simply misleading the way they are
written.

> only in f_mass_storage
> 
> Signed-off-by: Jaejoong Kim 
> ---
>  drivers/usb/gadget/function/f_mass_storage.c | 6 ++
>  drivers/usb/gadget/function/f_mass_storage.h | 4 
>  2 files changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
> b/drivers/usb/gadget/function/f_mass_storage.c
> index b6e2930..ba0eb7e 100644
> --- a/drivers/usb/gadget/function/f_mass_storage.c
> +++ b/drivers/usb/gadget/function/f_mass_storage.c
> @@ -2558,17 +2558,15 @@ static void fsg_lun_release(struct device *dev)
>   /* Nothing needs to be done */
>  }
>  
> -void fsg_common_get(struct fsg_common *common)
> +static void __maybe_unused fsg_common_get(struct fsg_common *common)
>  {
>   kref_get(>ref);
>  }
> -EXPORT_SYMBOL_GPL(fsg_common_get);
>  
> -void fsg_common_put(struct fsg_common *common)
> +static void fsg_common_put(struct fsg_common *common)
>  {
>   kref_put(>ref, fsg_common_release);
>  }
> -EXPORT_SYMBOL_GPL(fsg_common_put);
>  
>  static struct fsg_common *fsg_common_setup(struct fsg_common *common)
>  {
[...]

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


Re: [PATCH 2/3] usb: dwc3: pci: Enable ULPI Refclk on platforms where the firmware doesnot

2018-06-07 Thread Sergei Shtylyov
Hello!

On 06/07/2018 01:38 PM, Hans de Goede wrote:

> On some Bay Trail (BYT) systems the firmware does not enable the
> ULPI Refclk.
> 
> This commit adds a helper which checks and if necessary enabled the Refclk
> and calls this helper for BYT machines.
> 
> Signed-off-by: Hans de Goede 
> ---
>  drivers/usb/dwc3/dwc3-pci.c | 34 ++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
> index 34b84d3bc7cf..65bc110388f3 100644
> --- a/drivers/usb/dwc3/dwc3-pci.c
> +++ b/drivers/usb/dwc3/dwc3-pci.c
[...]
> @@ -78,6 +81,34 @@ static struct gpiod_lookup_table platform_bytcr_gpios = {
>   },
>  };
>  
> +static void dwc3_pci_enable_ulpi_refclock(struct pci_dev *pci)
> +{
> + void __iomem*reg;
> + struct resource res;
> + struct device   *dev = >dev;
> + u32 value;
> +
> + res.start   = pci_resource_start(pci, 1);
> + res.end = pci_resource_end(pci, 1);
> + res.name= "dwc_usb3_bar1";
> + res.flags   = IORESOURCE_MEM;
> +
> + reg = devm_ioremap_resource(dev, );
> + if (IS_ERR(reg)) {
> + dev_err(dev, "cannot check GP_RWREG1 to assert ulpi 
> refclock\n");

   Eh?
   BTW, devm_ioremap_resource() prints the error cause already...

> + return;
> + }
> +
> + value = readl(reg + GP_RWREG1);
> + if (!(value & GP_RWREG1_ULPI_REFCLK_DISABLE))

   I guess that dev_err() belongs here...

> + return; /* ULPI refclk already enabled */
> +
> + dev_warn(dev, "ULPI refclock is disabled from the BIOS, enabling it\n");
> + value &= ~GP_RWREG1_ULPI_REFCLK_DISABLE;
> + writel(value, reg + GP_RWREG1);
> + msleep(100);
> +}
> +
>  static int dwc3_pci_quirks(struct dwc3_pci *dwc)
>  {
>   struct platform_device  *dwc3 = dwc->dwc3;
[...]

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


Re: [PATCH v2 1/3] usb: roles: intel_xhci: Always allow user control

2018-05-23 Thread Sergei Shtylyov
On 05/23/2018 05:37 PM, Heikki Krogerus wrote:

> Trying to determine the USB port type with this mux is very
> difficult. To simplify the situation, always allowing user

   s/allowing/allow/? Else the statement doesn't parse for me. :-)

> control, even if the port is USB Type-C port.
> 
> Signed-off-by: Heikki Krogerus 
[...]

MBR, Sergei

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


Re: [PATCH v2 3/3] usb: typec: fusb302: Fix debugfs issue

2018-05-23 Thread Sergei Shtylyov
Hello!

On 05/23/2018 05:37 PM, Heikki Krogerus wrote:

> Removing the "fusb302" debugfs directory when unloading
> the driver. That allows the driver to be loaded more then
> ones. The directory will not get actually removed until it

   s/ones/once/?

> is empty, so only after the last instance has been removed.
> 
> This fixes an issue where the driver can't be re-loaded if
> it has been unloaded as the "fusb302" debugfs directory
> already exists.
> 
> Fixes: 76f0c53d08b9 ("usb: typec: fusb302: Move out of staging")
> Signed-off-by: Heikki Krogerus 
[...]

MBR, Sergei

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


Re: [PATCH net-next v2 2/2] drivers: net: Remove device_node checks with of_mdiobus_register()

2018-05-16 Thread Sergei Shtylyov
Hello!

On 05/16/2018 02:56 AM, Florian Fainelli wrote:

> A number of drivers have the following pattern:
> 
> if (np)
>   of_mdiobus_register()
> else
>   mdiobus_register()
> 
> which the implementation of of_mdiobus_register() now takes care of.
> Remove that pattern in drivers that strictly adhere to it.
> 
> Signed-off-by: Florian Fainelli <f.faine...@gmail.com>
[...]

> diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
> index ac621f44237a..02e8982519ce 100644
> --- a/drivers/net/dsa/bcm_sf2.c
> +++ b/drivers/net/dsa/bcm_sf2.c
> @@ -450,12 +450,8 @@ static int bcm_sf2_mdio_register(struct dsa_switch *ds)
>   priv->slave_mii_bus->parent = ds->dev->parent;
>   priv->slave_mii_bus->phy_mask = ~priv->indir_phy_mask;
>  
> - if (dn)
> - err = of_mdiobus_register(priv->slave_mii_bus, dn);
> - else
> - err = mdiobus_register(priv->slave_mii_bus);
> -
> - if (err)
> + err = of_mdiobus_register(priv->slave_mii_bus, dn);
> + if (err && dn)

   of_node_put() checks for NULL.

>   of_node_put(dn);
>  
>   return err;
[...]
> diff --git a/drivers/net/ethernet/freescale/fec_main.c 
> b/drivers/net/ethernet/freescale/fec_main.c
> index d4604bc8eb5b..f3e43db0d6cb 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -2052,13 +2052,9 @@ static int fec_enet_mii_init(struct platform_device 
> *pdev)
>   fep->mii_bus->parent = >dev;
>  
>   node = of_get_child_by_name(pdev->dev.of_node, "mdio");
> - if (node) {
> - err = of_mdiobus_register(fep->mii_bus, node);
> + err = of_mdiobus_register(fep->mii_bus, node);
> + if (node)
>   of_node_put(node);

   Same comment here.

[...]
> diff --git a/drivers/net/ethernet/renesas/sh_eth.c 
> b/drivers/net/ethernet/renesas/sh_eth.c
> index 5970d9e5ddf1..8dd41e08a6c6 100644
> --- a/drivers/net/ethernet/renesas/sh_eth.c
> +++ b/drivers/net/ethernet/renesas/sh_eth.c
> @@ -3025,15 +3025,10 @@ static int sh_mdio_init(struct sh_eth_private *mdp,
>pdev->name, pdev->id);
>  
>   /* register MDIO bus */
> - if (dev->of_node) {
> - ret = of_mdiobus_register(mdp->mii_bus, dev->of_node);
> - } else {
> - if (pd->phy_irq > 0)
> - mdp->mii_bus->irq[pd->phy] = pd->phy_irq;
> -
> - ret = mdiobus_register(mdp->mii_bus);
> - }
> + if (pd->phy_irq > 0)
> + mdp->mii_bus->irq[pd->phy] = pd->phy_irq;
>  
> + ret = of_mdiobus_register(mdp->mii_bus, dev->of_node);
>   if (ret)
>   goto out_free_bus;
>  

   This part is:

Acked-by: Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>

[...]
> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
> index 91761436709a..8dff87ec6d99 100644
> --- a/drivers/net/usb/lan78xx.c
> +++ b/drivers/net/usb/lan78xx.c
> @@ -1843,12 +1843,9 @@ static int lan78xx_mdio_init(struct lan78xx_net *dev)
>   }
>  
>   node = of_get_child_by_name(dev->udev->dev.of_node, "mdio");
> - if (node) {
> - ret = of_mdiobus_register(dev->mdiobus, node);
> + ret = of_mdiobus_register(dev->mdiobus, node);
> + if (node)
>   of_node_put(node);

   of_node_put() checks for NULL, again...

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


Re: [PATCH 4/5] arm64: allwinner: h6: add USB3 device nodes

2018-05-08 Thread Sergei Shtylyov

Hello!

On 5/7/2018 6:18 PM, Icenowy Zheng wrote:


Allwinner H6 SoC features USB3 functionality, with a DWC3 controller and
a custom PHY.

Add device tree nodes for them.

Signed-off-by: Icenowy Zheng 
---
  arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 38 
  1 file changed, 38 insertions(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi 
b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
index c72da8cd9ef5..9564c938717c 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
@@ -174,6 +174,44 @@
status = "disabled";
};
  
+		usb3: usb@520 {


   I don't think  is allowed for a node having no "reg" prop...


+   compatible = "allwinner,sun50i-h6-dwc3";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+   clocks = < CLK_BUS_XHCI>;
+   clock-names = "bus";
+   resets = < RST_BUS_XHCI>;
+   reset-names = "bus";
+   status = "disabled";
+
+   dwc3: dwc3 {


   Contrariwise, need  here...


+   compatible = "snps,dwc3";
+   reg = <0x520 0x1>;
+   interrupts = ;
+   /*
+* According to Wink from Allwinner, the
+* USB3 port on H6 is not capable of OTG;
+* the datasheet doesn't mention OTG at all
+* either, so the dr_mode is default to
+* "host" here.
+*/
+   dr_mode = "host";
+   phys = <>;
+   phy-names = "usb3-phy";
+   status = "disabled";
+   };
+   };

[...]

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


Re: [PATCH v5 08/14] staging: typec: tcpci: register port before request irq

2018-05-03 Thread Sergei Shtylyov

On 5/3/2018 11:29 AM, Sergei Shtylyov wrote:


From: Peter Chen <peter.c...@nxp.com>

With that we can clear any pending events and the port is registered
so driver can be ready to handle typec events once we request irq.

Signed-off-by: Peter Chen <peter.c...@nxp.com>
Signed-off-by: Li Jun <jun...@nxp.com>
---
  drivers/staging/typec/tcpci.c | 15 +--
  1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index a21aaf5..139c2ab 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -537,24 +537,27 @@ static int tcpci_probe(struct i2c_client *client,
  if (IS_ERR(chip->data.regmap))
  return PTR_ERR(chip->data.regmap);
+    i2c_set_clientdata(client, chip);
+
  /* Disable chip interrupts before requesting irq */
  err = regmap_raw_write(chip->data.regmap, TCPC_ALERT_MASK, ,
 sizeof(u16));
  if (err < 0)
  return err;
+    chip->tcpci = tcpci_register_port(>dev, >data);
+    if (PTR_ERR_OR_ZERO(chip->tcpci))


    Is NULL an error indication too?


+    return PTR_ERR(chip->tcpci);


    If so, you'll return a success indication here.


   ... when chip->tcpci is NULL, I mean. Seems wrong...


+
  err = devm_request_threaded_irq(>dev, client->irq, NULL,
  _tcpci_irq,
  IRQF_ONESHOT | IRQF_TRIGGER_LOW,
  dev_name(>dev), chip);
-    if (err < 0)
+    if (err < 0) {
+    tcpci_unregister_port(chip->tcpci);
  return err;
+    }
-    chip->tcpci = tcpci_register_port(>dev, >data);
-    if (PTR_ERR_OR_ZERO(chip->tcpci))
-    return PTR_ERR(chip->tcpci);
-


   Ah, you're only moving the questionable code...


-    i2c_set_clientdata(client, chip);
  return 0;
  }


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


Re: [PATCH v5 08/14] staging: typec: tcpci: register port before request irq

2018-05-03 Thread Sergei Shtylyov

Hello!

On 5/3/2018 3:24 AM, Li Jun wrote:


From: Peter Chen 

With that we can clear any pending events and the port is registered
so driver can be ready to handle typec events once we request irq.

Signed-off-by: Peter Chen 
Signed-off-by: Li Jun 
---
  drivers/staging/typec/tcpci.c | 15 +--
  1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index a21aaf5..139c2ab 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -537,24 +537,27 @@ static int tcpci_probe(struct i2c_client *client,
if (IS_ERR(chip->data.regmap))
return PTR_ERR(chip->data.regmap);
  
+	i2c_set_clientdata(client, chip);

+
/* Disable chip interrupts before requesting irq */
err = regmap_raw_write(chip->data.regmap, TCPC_ALERT_MASK, ,
   sizeof(u16));
if (err < 0)
return err;
  
+	chip->tcpci = tcpci_register_port(>dev, >data);

+   if (PTR_ERR_OR_ZERO(chip->tcpci))


   Is NULL an error indication too?


+   return PTR_ERR(chip->tcpci);


   If so, you'll return a success indication here.


+
err = devm_request_threaded_irq(>dev, client->irq, NULL,
_tcpci_irq,
IRQF_ONESHOT | IRQF_TRIGGER_LOW,
dev_name(>dev), chip);
-   if (err < 0)
+   if (err < 0) {
+   tcpci_unregister_port(chip->tcpci);
return err;
+   }
  
-	chip->tcpci = tcpci_register_port(>dev, >data);

-   if (PTR_ERR_OR_ZERO(chip->tcpci))
-   return PTR_ERR(chip->tcpci);
-
-   i2c_set_clientdata(client, chip);
return 0;
  }
  


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


Re: [PATCH 2/2] usb: dwc2: fix isoc split in transfer with no data

2018-04-24 Thread Sergei Shtylyov

Hello!

On 4/24/2018 5:43 AM, William Wu wrote:


If isoc split in transfer with no data (the length of DATA0
packet is 0), we can't simply return immediately. Because the
DATA0 can be the first transaction or the second transaction for
the isoc split in transaction. If the DATA0 packet with on data

  ^^ no?


is in the first transaction, we can return immediately. But if
the the DATA0 packet with on data is in the second transaction


  One "the" too many. And that "on data" again... :-)


of isoc split in transaction sequence, we need to increase the
qtd->isoc_frame_index and giveback urb to device driver if needed,
otherwise, the MDATA packet will be lost.

A typical test case is that connect the dwc2 controller with an
usb hs Hub (GL852G-12), and plug an usb fs audio device (Plantronics
headset) into the downstream port of Hub. Then use the usb mic
to record, we can find noise when playback.

In the case, the isoc split in transaction sequence like this:

- SSPLIT IN transaction
- CSPLIT IN transaction
   - MDATA packet (176 bytes)
- CSPLIT IN transaction
   - DATA0 packet (0 byte)

This patch use both the length of DATA0 and qtd->isoc_split_offset
to check if the DATA0 is in the second transaction.

Signed-off-by: William Wu 

[...]

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


Re: [PATCH] usb:serial:optrion: fix dwm-158 3g modem interface

2018-04-23 Thread Sergei Shtylyov

Hello!

   s/optrion/option/ in the subject. And please add spaces after each colon.

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


Re: [PATCH v1 1/1] usb: core: Add quirk for HP v222w 16GB Mini

2018-04-14 Thread Sergei Shtylyov

Hello!

On 4/13/2018 8:40 PM, sathyanarayanan.kuppusw...@linux.intel.com wrote:


From: Kamil Lulko 

Add DELAY_INIT quirk to fix the following problem with HP
v222w 16GB Mini:

usb 1-3: unable to read config index 0 descriptor/start: -110
usb 1-3: can't read configurations, error -110
usb 1-3: can't set config #1, error -110

Signed-off-by: Kamil Lulko 
Signed-off-by: Kuppuswamy Sathyanarayanan 

---
  drivers/usb/core/quirks.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 54b019e..f2ef913 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -40,6 +40,9 @@ static const struct usb_device_id usb_quirk_list[] = {
{ USB_DEVICE(0x03f0, 0x0701), .driver_info =
USB_QUIRK_STRING_FETCH_255 },
  
+/* HP v222w 16GB Mini USB Drive */

+{ USB_DEVICE(0x03f0, 0x3f40), .driver_info = USB_QUIRK_DELAY_INIT },
+


   Please indent with tabs (as above and below), not spaces.


/* Creative SB Audigy 2 NX */
{ USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME },
  


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


Re: [PATCH] usbip: vhci_hcd: check rhport before using in vhci_hub_control()

2018-04-06 Thread Sergei Shtylyov

Hello!

On 4/6/2018 1:31 AM, Shuah Khan wrote:


Validate !rhport < 0 before using it to access port_status array.


   Why '!'?


Signed-off-by: Shuah Khan 
---
  drivers/usb/usbip/vhci_hcd.c | 13 +
  1 file changed, 13 insertions(+)

diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 20e3d4609583..d11f3f8dad40 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c

[...]

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


Re: [PATCH v2 1/1] usb: musb: gadget: misplaced out of bounds check

2018-03-20 Thread Sergei Shtylyov

Hello!

On 3/20/2018 5:27 AM, Heinrich Schuchardt wrote:


musb->endpoints[] has array size MUSB_C_NUM_EPS.
We must check array bounds before accessing the array and not afterwards.

Signed-off-by: Heinrich Schuchardt 
---
v2
Only the 4 low bits of epnum are relevant for indexing. 
---
  drivers/usb/musb/musb_gadget_ep0.c | 9 +++--
  1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/musb/musb_gadget_ep0.c 
b/drivers/usb/musb/musb_gadget_ep0.c
index 18da4873e52e..96b0fa12f729 100644
--- a/drivers/usb/musb/musb_gadget_ep0.c
+++ b/drivers/usb/musb/musb_gadget_ep0.c
@@ -89,15 +89,20 @@ static int service_tx_status_request(
}
  
  		is_in = epnum & USB_DIR_IN;

+   epnum &= 0x0f;
+   if (epnum >= MUSB_C_NUM_EPS) {
+   handled = -EINVAL;
+   break;
+   }
+
if (is_in) {
-   epnum &= 0x0f;
ep = >endpoints[epnum].ep_in;
} else {
ep = >endpoints[epnum].ep_out;
}


   Please remove the braces, they're not needed anymore.

[...]

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


Re: [PATCH] usb: Don't disable Latency tolerance Messaging (LTM) before port reset

2018-03-01 Thread Sergei Shtylyov
Hello!

On 03/01/2018 02:15 PM, Mathias Nyman wrote:

> Disabing Latency Tolerance Messaging before port reset is unnecessary.
> LTM is automatically disabled at port reset.
> 
> If host can't communicate with the device the LTM message will fail, and
> the hub driver will unnecessarily do a logical disconnect.
> Broken communication is ofter the reason for a reset in the first place.

   Often.

> Additionally we can't guarantee device is in a configured state,
> epecially in reset-resume case when root hub lost power.

   Especially.

> LTM can't be modified unless device is in a configured state.
> 
> Just remove LTM disabling before port reset.
> 
> Details about LTM and port reset in USB 3 specification:
> 
> USB 3 spec section 9.4.5
> "The LTM Enable field can be modified by the SetFeature() and
> ClearFeature() requests using the LTM_ENABLE feature selector.
> This field is reset to zero when the device is reset."
> 
> USB 3 spec section 9.4.1
> "The device shall process a Clear Feature (U1_Enable or U2_Enable or
> LTM_Enable) only if the device is in the configured state."
> 
> Signed-off-by: Mathias Nyman 
[...]

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


Re: [RFC PATCH] usb: musb: call pm_runtime_{get,put}_sync before reading vbus registers

2018-02-25 Thread Sergei Shtylyov

Hello!

On 2/24/2018 11:51 PM, Merlijn Wajer wrote:


Without pm_runtime_{get,put}_sync calls in place, reading
vbus status via /sys causes the following error:

Unhandled fault: external abort on non-linefetch (0x1028) at 0xfa0ab060
pgd = b333e822
[fa0ab060] *pgd=48011452(bad)

[] (musb_default_readb) from [] (musb_vbus_show+0x58/0xe4)
[] (musb_vbus_show) from [] (dev_attr_show+0x20/0x44)
[] (dev_attr_show) from [] (sysfs_kf_seq_show+0x80/0xdc)
[] (sysfs_kf_seq_show) from [] (seq_read+0x250/0x448)
[] (seq_read) from [] (__vfs_read+0x1c/0x118)
[] (__vfs_read) from [] (vfs_read+0x90/0x144)
[] (vfs_read) from [] (SyS_read+0x3c/0x74)
[] (SyS_read) from [] (ret_fast_syscall+0x0/0x54)

Solution was suggested by Tony Lindgren .

Signed-off-by: Merlijn Wajer 
---
  drivers/usb/musb/musb_core.c | 5 +
  1 file changed, 5 insertions(+)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index ea5013aa69e2..182611f76af3 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c

[...]

@@ -1767,6 +1769,9 @@ musb_vbus_show(struct device *dev, struct 
device_attribute *attr, char *buf)
vbus = 1;
else
vbus = 0;
+
+   pm_runtime_put_sync(dev);
+


   Empty line not needed here.


}
spin_unlock_irqrestore(>lock, flags);
  


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


Re: [PATCH 1/2] usb: gadget: udc: atmel: Use devm_ioremap_resource()

2018-01-22 Thread Sergei Shtylyov
On 01/22/2018 06:44 PM, Ladislav Michl wrote:

>>> As devm_ioremap_resource() checks for valid resource,
>>> make use of it instead of testing ourselves. As a bonus
>>> memory region is requested.
>>>
>>> Signed-off-by: Ladislav Michl 
>>> ---
>>>  drivers/usb/gadget/udc/atmel_usba_udc.c | 40 
>>> -
>>>  1 file changed, 19 insertions(+), 21 deletions(-)
>>>
>>> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
>>> b/drivers/usb/gadget/udc/atmel_usba_udc.c
>>> index 075eaaa8a408..403e06e7175f 100644
>>> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
>>> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
>> [...]
>>> @@ -2284,10 +2284,24 @@ static int usba_udc_probe(struct platform_device 
>>> *pdev)
>>> udc->gadget = usba_gadget_template;
>>> INIT_LIST_HEAD(>gadget.ep_list);
>>>  
>>> -   regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
>>> -   fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID);
>>> -   if (!regs || !fifo)
>>> -   return -ENXIO;
>>> +   res = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
>>> +   udc->regs = devm_ioremap_resource(>dev, res);
>>> +   if (IS_ERR(udc->regs)) {
>>> +   ret = PTR_ERR(udc->regs);
>>> +   dev_err(>dev, "Unable to map I/O memory: %d\n", ret);
>>
>>devm_ioremap_resource() prints out the error message.
> 
> It does, indeed. However I left both error messages here to distinguish
> between I/O and FIFO failures.

   Well, I'm seeing the successfully remapped resource being dumped below, so 
you can judge the probing progress by that message (and the resource dump done 
by devm_ioremap_resource())... but if you feel that not enough, OK, leave it as 
is...

>>> +   return ret;
>>> +   }
>>> +   dev_info(>dev, "MMIO registers at %pR mapped at %p\n",
>>> +res, udc->regs);
>>> +
>>> +   res = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID);
>>> +   udc->fifo = devm_ioremap_resource(>dev, res);
>>> +   if (IS_ERR(udc->fifo)) {
>>> +   ret = PTR_ERR(udc->fifo);
>>> +   dev_err(>dev, "Unable to map FIFO: %d\n", ret);
>>
>>Same comment here.
>>
>>> +   return ret;
>>> +   }
>>> +   dev_info(>dev, "FIFO at %pR mapped at %p\n", res, udc->fifo);
>>>  
>>> irq = platform_get_irq(pdev, 0);
>>> if (irq < 0)
>> [...]

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


Re: [PATCH 1/2] usb: gadget: udc: atmel: Use devm_ioremap_resource()

2018-01-22 Thread Sergei Shtylyov
Hello!

On 01/22/2018 06:21 PM, Ladislav Michl wrote:

> As devm_ioremap_resource() checks for valid resource,
> make use of it instead of testing ourselves. As a bonus
> memory region is requested.
> 
> Signed-off-by: Ladislav Michl 
> ---
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 40 
> -
>  1 file changed, 19 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 075eaaa8a408..403e06e7175f 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
[...]
> @@ -2284,10 +2284,24 @@ static int usba_udc_probe(struct platform_device 
> *pdev)
>   udc->gadget = usba_gadget_template;
>   INIT_LIST_HEAD(>gadget.ep_list);
>  
> - regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
> - fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID);
> - if (!regs || !fifo)
> - return -ENXIO;
> + res = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
> + udc->regs = devm_ioremap_resource(>dev, res);
> + if (IS_ERR(udc->regs)) {
> + ret = PTR_ERR(udc->regs);
> + dev_err(>dev, "Unable to map I/O memory: %d\n", ret);

   devm_ioremap_resource() prints out the error message.

> + return ret;
> + }
> + dev_info(>dev, "MMIO registers at %pR mapped at %p\n",
> +  res, udc->regs);
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID);
> + udc->fifo = devm_ioremap_resource(>dev, res);
> + if (IS_ERR(udc->fifo)) {
> + ret = PTR_ERR(udc->fifo);
> + dev_err(>dev, "Unable to map FIFO: %d\n", ret);

   Same comment here.

> + return ret;
> + }
> + dev_info(>dev, "FIFO at %pR mapped at %p\n", res, udc->fifo);
>  
>   irq = platform_get_irq(pdev, 0);
>   if (irq < 0)
[...]

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


Re: [PATCH v4] usb: uhci: Add clk support to uhci-platform

2018-01-16 Thread Sergei Shtylyov

Hello!

On 1/16/2018 12:53 AM, Benjamin Herrenschmidt wrote:


The Aspeed SoCs use uhci-platform. With the new dynamic clock
control framework, the corresponding IP block clock must be
properly enabled.

This is a simplified variant of what ehci-platform does, it
looks for *one* clock attached to the device, and if it's
there, enables it.

Signed-off-by: Benjamin Herrenschmidt 
Acked-by: Alan Stern 
---

v4. Remove unnecessary NULL checks

v3. Fix tab vs. spaces and probe error path

v2. Don't forget to git add latest changes :-) This adds the
  part where we turn the clock off when removing the driver.
---
   drivers/usb/host/uhci-hcd.h  |  3 +++
   drivers/usb/host/uhci-platform.c | 20 ++--
   2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h
index f1cc47292a59..7f9f33c8c232 100644
--- a/drivers/usb/host/uhci-hcd.h
+++ b/drivers/usb/host/uhci-hcd.h
@@ -4,6 +4,7 @@
   
   #include 

   #include 
+#include 
   
   #define usb_packetid(pipe)	(usb_pipein(pipe) ? USB_PID_IN : USB_PID_OUT)

   #define PIPE_DEVEP_MASK  0x0007ff00
@@ -447,6 +448,8 @@ struct uhci_hcd {
int total_load; /* Sum of array values */
short load[MAX_PHASE];  /* Periodic allocations */
   
+	struct clk *clk;			/* (optional) clock source */

+
/* Reset host controller */
void(*reset_hc) (struct uhci_hcd *uhci);
int (*check_and_reset_hc) (struct uhci_hcd *uhci);
diff --git a/drivers/usb/host/uhci-platform.c b/drivers/usb/host/uhci-platform.c
index 6cb16d4b2257..55c2d99bf7ec 100644
--- a/drivers/usb/host/uhci-platform.c
+++ b/drivers/usb/host/uhci-platform.c
@@ -89,6 +89,8 @@ static int uhci_hcd_platform_probe(struct platform_device 
*pdev)
if (!hcd)
return -ENOMEM;
   
+	uhci = hcd_to_uhci(hcd);

+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
hcd->regs = devm_ioremap_resource(>dev, res);
if (IS_ERR(hcd->regs)) {
@@ -98,8 +100,6 @@ static int uhci_hcd_platform_probe(struct platform_device 
*pdev)
hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res);
   
-	uhci = hcd_to_uhci(hcd);

-
uhci->regs = hcd->regs;
   
   	/* Grab some things from the device-tree */

@@ -119,6 +119,19 @@ static int uhci_hcd_platform_probe(struct platform_device 
*pdev)
 "Enabled Aspeed implementation workarounds\n");
}
}
+
+   /* Get and enable clock if any specified */
+   uhci->clk = devm_clk_get(>dev, NULL);
+   if (IS_ERR(uhci->clk)) {
+   ret = PTR_ERR(uhci->clk);
+   goto err_rmr;
+   }
+   ret = clk_prepare_enable(uhci->clk);
+   if (ret) {
+   dev_err(>dev, "Error couldn't enable clock (%d)\n", ret);
+   goto err_rmr;
+   }
+
ret = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_SHARED);
if (ret)
goto err_rmr;
@@ -127,6 +140,7 @@ static int uhci_hcd_platform_probe(struct platform_device 
*pdev)
return 0;
   
   err_rmr:

+   clk_disable_unprepare(uhci->clk);


  Really? You haven't enabled the clock before either *goto* above, why
disable it here?


If clk is NULL or an error, disable will do nothing. The only case


   The rule of thumb was that you don't pass the error pointers to APIs but 
indeed I'm now seeing the NULL check extended to the error pointers too...



would be if enable at failed but then disable will do nothing in that
case.


   Are you sure there'll be no WARN_ON() triggered by clk_disable() with the 
enable count == 0?



The above change was done at the suggestion of Alan. If you really


   I'd probably missed his mail.


prefer I could add a clk_put and clearing of "clk" in the error path of
clk_prepare_enable, but that's about it.

BTW. DO we really need to bike shed such a simple patch to death like
that ?


   It was not about bike shedding, just about the correctness...

[...]

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


Re: [PATCH v4] usb: uhci: Add clk support to uhci-platform

2018-01-15 Thread Sergei Shtylyov

Hello!

On 1/15/2018 1:59 AM, Benjamin Herrenschmidt wrote:


The Aspeed SoCs use uhci-platform. With the new dynamic clock
control framework, the corresponding IP block clock must be
properly enabled.

This is a simplified variant of what ehci-platform does, it
looks for *one* clock attached to the device, and if it's
there, enables it.

Signed-off-by: Benjamin Herrenschmidt 
Acked-by: Alan Stern 
---

v4. Remove unnecessary NULL checks

v3. Fix tab vs. spaces and probe error path

v2. Don't forget to git add latest changes :-) This adds the
 part where we turn the clock off when removing the driver.
---
  drivers/usb/host/uhci-hcd.h  |  3 +++
  drivers/usb/host/uhci-platform.c | 20 ++--
  2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h
index f1cc47292a59..7f9f33c8c232 100644
--- a/drivers/usb/host/uhci-hcd.h
+++ b/drivers/usb/host/uhci-hcd.h
@@ -4,6 +4,7 @@
  
  #include 

  #include 
+#include 
  
  #define usb_packetid(pipe)	(usb_pipein(pipe) ? USB_PID_IN : USB_PID_OUT)

  #define PIPE_DEVEP_MASK   0x0007ff00
@@ -447,6 +448,8 @@ struct uhci_hcd {
int total_load; /* Sum of array values */
short load[MAX_PHASE];  /* Periodic allocations */
  
+	struct clk *clk;			/* (optional) clock source */

+
/* Reset host controller */
void(*reset_hc) (struct uhci_hcd *uhci);
int (*check_and_reset_hc) (struct uhci_hcd *uhci);
diff --git a/drivers/usb/host/uhci-platform.c b/drivers/usb/host/uhci-platform.c
index 6cb16d4b2257..55c2d99bf7ec 100644
--- a/drivers/usb/host/uhci-platform.c
+++ b/drivers/usb/host/uhci-platform.c
@@ -89,6 +89,8 @@ static int uhci_hcd_platform_probe(struct platform_device 
*pdev)
if (!hcd)
return -ENOMEM;
  
+	uhci = hcd_to_uhci(hcd);

+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
hcd->regs = devm_ioremap_resource(>dev, res);
if (IS_ERR(hcd->regs)) {
@@ -98,8 +100,6 @@ static int uhci_hcd_platform_probe(struct platform_device 
*pdev)
hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res);
  
-	uhci = hcd_to_uhci(hcd);

-
uhci->regs = hcd->regs;
  
  	/* Grab some things from the device-tree */

@@ -119,6 +119,19 @@ static int uhci_hcd_platform_probe(struct platform_device 
*pdev)
 "Enabled Aspeed implementation workarounds\n");
}
}
+
+   /* Get and enable clock if any specified */
+   uhci->clk = devm_clk_get(>dev, NULL);
+   if (IS_ERR(uhci->clk)) {
+   ret = PTR_ERR(uhci->clk);
+   goto err_rmr;
+   }
+   ret = clk_prepare_enable(uhci->clk);
+   if (ret) {
+   dev_err(>dev, "Error couldn't enable clock (%d)\n", ret);
+   goto err_rmr;
+   }
+
ret = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_SHARED);
if (ret)
goto err_rmr;
@@ -127,6 +140,7 @@ static int uhci_hcd_platform_probe(struct platform_device 
*pdev)
return 0;
  
  err_rmr:

+   clk_disable_unprepare(uhci->clk);


Really? You haven't enabled the clock before either *goto* above, why 
disable it here?



usb_put_hcd(hcd);
  
  	return ret;

[...]

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


Re: [PATCH] usb: uhci: Add clk support to uhci-platform

2018-01-11 Thread Sergei Shtylyov

Hello!

On 1/12/2018 8:51 AM, Benjamin Herrenschmidt wrote:


The Aspeed SoCs use uhci-platform. With the new dynamic clock
control framework, the corresponding IP block clock must be
properly enabled.

This is a simplified variant of what ehci-platform does, it
looks for *one* clock attached to the device, and if it's
there, enables it.

Signed-off-by: Benjamin Herrenschmidt 

[...]

diff --git a/drivers/usb/host/uhci-platform.c b/drivers/usb/host/uhci-platform.c
index 6cb16d4b2257..7d959071f92b 100644
--- a/drivers/usb/host/uhci-platform.c
+++ b/drivers/usb/host/uhci-platform.c
@@ -119,6 +119,21 @@ static int uhci_hcd_platform_probe(struct platform_device 
*pdev)
 "Enabled Aspeed implementation workarounds\n");
}
}
+
+   /* Get and enable clock if any specified */
+   uhci->clk = devm_clk_get(>dev, NULL);
+if (IS_ERR(uhci->clk)) {
+ret = PTR_ERR(uhci->clk);
+goto err_rmr;
+}


   Indent with tabs as elsewhere, please.


+   if (uhci->clk) {
+   ret = clk_prepare_enable(uhci->clk);
+   if (ret) {
+   dev_err(>dev, "Error couldn't enable clock 
(%d)\n", ret);
+   goto err_rmr;
+   }
+}
+
ret = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_SHARED);
if (ret)
goto err_rmr;


[...]

MBR, Segei
--
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 13/15] usb: dwc3: Track DWC_usb31 VERSIONTYPE

2018-01-05 Thread Sergei Shtylyov

Hello!

On 1/5/2018 11:16 PM, Thinh Nguyen wrote:


Add a new variable to dwc3 structure to track VERSIONTYPE. The


   That's called field, not variable.


VERSIONTYPE is represented in ASCII in the 32-bit VERSIONTYPE register.
In DWC_usb31, sub releases for each version are tracked with VERSIONTYPE
such as "ea01" and "ea02".

Signed-off-by: Thinh Nguyen 

[...]

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


Re: [PATCH 3/3] ARM: dts: r7s72100: add USB device to device tree

2018-01-05 Thread Sergei Shtylyov

Hello!

On 1/4/2018 11:01 PM, Chris Brandt wrote:


Add USB device support.

Signed-off-by: Chris Brandt 
---
  arch/arm/boot/dts/r7s72100.dtsi | 20 
  1 file changed, 20 insertions(+)

diff --git a/arch/arm/boot/dts/r7s72100.dtsi b/arch/arm/boot/dts/r7s72100.dtsi
index ab9645a42eca..eb414e735185 100644
--- a/arch/arm/boot/dts/r7s72100.dtsi
+++ b/arch/arm/boot/dts/r7s72100.dtsi
@@ -667,4 +667,24 @@
power-domains = <_clocks>;
status = "disabled";
};
+
+   usbhs0: usbhs@e801 {


   The node names should be generic, i.e "usb@e801".


+   compatible = "renesas,usbhs-r7s72100";
+   reg = <0xe801 0x1A0>;


   Lowercase in the hex values, please be consistent...


+   interrupts = ;
+   clocks = <_clks R7S72100_CLK_USB0>;
+   renesas,buswait = <4>;
+   power-domains = <_clocks>;
+   status = "disabled";
+   };
+
+   usbhs1: usbhs@e8207000 {
+   compatible = "renesas,usbhs-r7s72100";
+   reg = <0xe8207000 0x1A0>;
+   interrupts = ;
+   clocks = <_clks R7S72100_CLK_USB1>;
+   renesas,buswait = <4>;
+   power-domains = <_clocks>;
+   status = "disabled";
+   };
  };


   The same comments for the 2nd device.

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


Re: [PATCH] usb: quirks: Add reset-resume quirk for QCA6174 Rome Bluetooth

2018-01-01 Thread Sergei Shtylyov

Hello!

On 12/31/2017 8:13 PM, Leif Liddy wrote:


This is a rework of reverted commit fd865802c66bc451dc515ed89360f84376ce1a56


   You need to also specify the commit summry enclosed in (""). Alos, 12 
digits of SHA1 is enough.



The issue is that some QCA Rome bluetooth controllers stop functioning upon 
resume from suspend.
These devices seem to be losing power during suspend. This patch will enable
reset_resume in usb core (instead of btusb) and will target the specific device 
0x0cf3:0xe300

Signed-off-by: Leif Liddy 

[...]

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


Re: [PATCH] USB: EHCI: don't reread PORTSC after disabling port power

2017-10-20 Thread Sergei Shtylyov

Hello!

On 10/20/2017 12:54 PM, Uwe Kleine-König wrote:


ehci_hub_control does the following related to overcurrent handling
(simplified):

temp = ehci_readl(ehci, status_reg);

if (temp & PORT_OCC) {
status |= USB_PORT_STAT_C_OVERCURRENT << 16;

if (temp & PORT_OC) {
ehci_port_power(ehci, wIndex, false);
temp = ehci_readl(ehci, status_reg);
}
}

if (temp & PORT_OC)
status |= USB_PORT_STAT_OVERCURRENT;

At least on my i.MX25 based machine rereading the PORTSC register after
port power was removed doesn't yield PORT_OC any more. The result is
that repeatedly changes related to over-current
(status |= USB_PORT_STAT_C_OVERCURRENT << 16) are reported, but
USB_PORT_STAT_OVERCURRENT doesn't toggle as expected and is always
unset. As a side effect the message

dev_err(_dev->dev, "over-current condition\n");

from drivers/usb/core/hub.c's port_event() never makes it to the user.

Rereading the value was introduced with the rationale:

I also think that the fact that we've cut off the port power
should be reflected in the result of GetPortStatus request
immediately, hence I'm adding a PORTSCn register readback after
write...


   The v1 of that patch just unset PORT_POWER, Alan then sugested to re-read 
the PORTSCn register and I agreed. :-)



As there are no further expected changes, just mask the PORT_POWER bit
instead of rereading the register.

An alternative would be to check for PORT_OC before checking for
PORT_OCC.

Fixes: 81463c1d7071 ("EHCI: only power off port if over-current is active")
Signed-off-by: Uwe Kleine-König 
---
  drivers/usb/host/ehci-hub.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index df169c8e7225..08f59654654b 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -1031,7 +1031,7 @@ int ehci_hub_control(
spin_unlock_irqrestore(>lock, flags);
ehci_port_power(ehci, wIndex, false);
spin_lock_irqsave(>lock, flags);
-   temp = ehci_readl(ehci, status_reg);
+   temp |= ~PORT_POWER;


   You surely meant '&='?

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


Re: [PATCH v2 2/2] dt-bindings: max3421: Add bindings documentation

2017-10-17 Thread Sergei Shtylyov

On 10/17/2017 12:22 AM, Jules Maselbas wrote:


Thanks Sergei,

Is it better if the documentation say:
"
Optional property:
  - interrupt-parent: the phandle of the associated interrupt controller.
"


   That should be enough.


or should I also add that "it may be inherited from the parent nodes."?

Jules Maselbas.


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


Re: [PATCH v2 2/2] dt-bindings: max3421: Add bindings documentation

2017-10-16 Thread Sergei Shtylyov

On 10/16/2017 12:04 PM, Sergei Shtylyov wrote:


Adds bindings documentation for the max3421 driver.

Signed-off-by: Jules Maselbas <jules.masel...@grenoble-inp.org>
---
  .../devicetree/bindings/usb/maxim,max3421.txt  | 24 
++

  1 file changed, 24 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/usb/maxim,max3421.txt

diff --git a/Documentation/devicetree/bindings/usb/maxim,max3421.txt 
b/Documentation/devicetree/bindings/usb/maxim,max3421.txt

new file mode 100644
index ..7536c3ab3e5a
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/maxim,max3421.txt
@@ -0,0 +1,24 @@
+Maxim Integrated SPI-based USB 2.0 host controller MAX3421E
+
+Required properties:
+ - compatible: "maxim,max3421"
+ - spi-max-frequency: maximum frequency for this device must not exceed 26 
MHz.

+ - reg: chip select number to which this device is connected.
+ - maxim,vbus-en-pin: 
+   GPOUTx is the number (1-8) of the GPOUT pin of MAX3421E to drive Vbus.
+   ACTIVE_LEVEL is 0 or 1.
+ - interrupt-parent: the phandle of the associated interrupt controller.


This is never a required prob, it may be inherited from the parent nodes.


  Prop, sorry. :-)

[...]

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


Re: [PATCH v2 2/2] dt-bindings: max3421: Add bindings documentation

2017-10-16 Thread Sergei Shtylyov

Hello!

On 10/16/2017 2:43 AM, Jules Maselbas wrote:


Adds bindings documentation for the max3421 driver.

Signed-off-by: Jules Maselbas 
---
  .../devicetree/bindings/usb/maxim,max3421.txt  | 24 ++
  1 file changed, 24 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/usb/maxim,max3421.txt

diff --git a/Documentation/devicetree/bindings/usb/maxim,max3421.txt 
b/Documentation/devicetree/bindings/usb/maxim,max3421.txt
new file mode 100644
index ..7536c3ab3e5a
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/maxim,max3421.txt
@@ -0,0 +1,24 @@
+Maxim Integrated SPI-based USB 2.0 host controller MAX3421E
+
+Required properties:
+ - compatible: "maxim,max3421"
+ - spi-max-frequency: maximum frequency for this device must not exceed 26 MHz.
+ - reg: chip select number to which this device is connected.
+ - maxim,vbus-en-pin: 
+   GPOUTx is the number (1-8) of the GPOUT pin of MAX3421E to drive Vbus.
+   ACTIVE_LEVEL is 0 or 1.
+ - interrupt-parent: the phandle of the associated interrupt controller.


   This is never a required prob, it may be inherited from the parent nodes.


+ - interrupts: the interuption line description for the interrupt controller.


   Interrupt.

[...]

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


Re: [PATCH 01/12] usb: mtu3: fix error return code in ssusb_gadget_init()

2017-09-30 Thread Sergei Shtylyov

Hello!

On 9/28/2017 3:17 AM, Chunfeng Yun wrote:


When fail to get irq number, platform_get_irq() may return


   Failing. IRQ. :-)


-EPROBE_DEFER, but we ignore it and always return -ENODEV,
so fix it.

Signed-off-by: Chunfeng Yun 
---
  drivers/usb/mtu3/mtu3_core.c |4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
index 99c65b0..9475798 100644
--- a/drivers/usb/mtu3/mtu3_core.c
+++ b/drivers/usb/mtu3/mtu3_core.c
@@ -774,9 +774,9 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
return -ENOMEM;
  
  	mtu->irq = platform_get_irq(pdev, 0);

-   if (mtu->irq <= 0) {
+   if (mtu->irq < 0) {


   This is good as the function no longer returns 0 on error. Even when it 
did, 0 could mean a valid IRQ as well...



dev_err(dev, "fail to get irq number\n");
-   return -ENODEV;
+   return mtu->irq;
}
dev_info(dev, "irq %d\n", mtu->irq);
  


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


Re: [PATCH] USB: gadgetfs: fix copy_to_user while holding spinlock

2017-09-21 Thread Sergei Shtylyov

Hello!

On 09/21/2017 11:12 PM, Alan Stern wrote:


The gadgetfs driver as a long-outstanding FIXME, regarding a call of


   s/as/has/?


copy_to_user() made while holding a spinlock.  This patch fixes the
issue by dropping the spinlock and using the dev->udc_usage mechanism
introduced by another recent patch to guard against status changes
while the lock isn't held.

Signed-off-by: Alan Stern 
Reported-by: Andrey Konovalov 
CC: 


[...]

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


Re: [PATCH v2 3/4] usb: musb: musb_cppi41: Configure the number of channels for DA8xx

2017-09-20 Thread Sergei Shtylyov

Hello!

On 9/20/2017 10:35 AM, Alexandre Bailon wrote:


Currently, the number of channels is set to 15 but in the case of DA8xx,
the number of channels is 4.
Update the driver to configure the number of channels at runtime.

Signed-off-by: Alexandre Bailon 
---
  drivers/usb/musb/musb_cppi41.c | 31 ++-
  1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index b2b1306c01cf..2d1468cccae0 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c

[...]

@@ -770,18 +776,33 @@ cppi41_dma_controller_create(struct musb *musb, void 
__iomem *base)
controller->tdown_reg = DA8XX_USB_TEARDOWN;
controller->autoreq_reg = DA8XX_USB_AUTOREQ;
controller->set_dma_mode = da8xx_set_dma_mode;
+   controller->num_channels = DA8XX_DMA_NUM_CHANNELS;
} else {
controller->tdown_reg = USB_TDOWN;
controller->autoreq_reg = USB_CTRL_AUTOREQ;
controller->set_dma_mode = cppi41_set_dma_mode;
+   controller->num_channels = MUSB_DMA_NUM_CHANNELS;
}
  
+	channel_size = controller->num_channels *

+   sizeof(struct cppi41_dma_channel);
+   controller->rx_channel = kzalloc(channel_size, GFP_KERNEL);
+   if (controller->rx_channel)


   How can this work? The NULL check is reversed.


+   goto rx_channel_alloc_fail;
+   controller->tx_channel = kzalloc(channel_size, GFP_KERNEL);
+   if (controller->tx_channel)


   Same here.


+   goto tx_channel_alloc_fail;
+
ret = cppi41_dma_controller_start(controller);
if (ret)
goto plat_get_fail;
return >controller;
  
  plat_get_fail:

+   kfree(controller->tx_channel);
+tx_channel_alloc_fail:
+   kfree(controller->rx_channel);
+rx_channel_alloc_fail:
kfree(controller);
  kzalloc_fail:
if (ret == -EPROBE_DEFER)



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


Re: [PATCH 7/8] xhci: set missing SuperSpeedPlus Link Protocol bit in roothub descriptor

2017-09-18 Thread Sergei Shtylyov

Hello!

  Only some grammar nits, could prolly be fixed when applying...

On 09/18/2017 05:39 PM, Mathias Nyman wrote:


A SuperSpeedPlus roothub needs to have the Link Protocol (LP) bit set in
the bmSublinkSpeedAttr[] entry of a SuperSpeedPlus descriptor.

If the xhci controller has an optional Protocol Speed ID (PSI) table then
that will be used as a base to create the roothub SuperSpeedPlus
descriptor.
The PSI table does not however necessary contain the LP bit so we need


   Necessarily.


to set it manually.

Check the psi speed and set LP bit if speed is 10Gbps or higher.
We're not setting it for 5 to 10Gbps as USB 3.1 specification always
mention SuperSpeedPlus for 10Gbps or higher, and some SSIC USB 3.0 speeds


   Mentions.


can be over 5Gbps, such as SSIC-G3B-L1 at 5830 Mbps

Cc:  # 4.6+
Signed-off-by: Mathias Nyman 

[...]

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


Re: [PATCH 3/5] staging: typec: pd: Document struct pd_message

2017-09-11 Thread Sergei Shtylyov

Hello.

On 9/10/2017 11:37 PM, Guenter Roeck wrote:


struct pd_message is the format of a PD message as seen on the wire.

Signed-off-by: Guenter Roeck 
---
  drivers/staging/typec/pd.h | 5 +
  1 file changed, 5 insertions(+)

diff --git a/drivers/staging/typec/pd.h b/drivers/staging/typec/pd.h
index 30b32ad72acd..42a10883a2cb 100644
--- a/drivers/staging/typec/pd.h
+++ b/drivers/staging/typec/pd.h
@@ -104,6 +104,11 @@ static inline unsigned int pd_header_msgid_le(__le16 
header)
  
  #define PD_MAX_PAYLOAD		7
  
+/*


   The kernel-doc comments (to which this comment looks alike) should start 
with /**.



+ * struct pd_message - PD message as seen on wire
+ * @header:PD message header
+ * @payload:   PD message payload
+ */
  struct pd_message {
__le16 header;
__le32 payload[PD_MAX_PAYLOAD];


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


Re: [PATCH RESEND v2 3/3] dt-bindings: mt8173-mtu3: add generic compatible and rename file

2017-08-29 Thread Sergei Shtylyov

Hello!

On 8/29/2017 12:20 PM, Chunfeng Yun wrote:


The mt8173-mtu3.txt actually holds the bindings for all mediatek
SoCs with usb3 DRD IP, so add a generic compatible and change the
name to mediatek,mtu3.txt.

Signed-off-by: Chunfeng Yun 
Acked-by: Rob Herring 
---
  .../usb/{mt8173-mtu3.txt => mediatek,mtu3.txt} |6 +-
  1 file changed, 5 insertions(+), 1 deletion(-)
  rename Documentation/devicetree/bindings/usb/{mt8173-mtu3.txt => 
mediatek,mtu3.txt} (92%)

diff --git a/Documentation/devicetree/bindings/usb/mt8173-mtu3.txt 
b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
similarity index 92%
rename from Documentation/devicetree/bindings/usb/mt8173-mtu3.txt
rename to Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
index b8ea394..722a029 100644
--- a/Documentation/devicetree/bindings/usb/mt8173-mtu3.txt
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
@@ -1,7 +1,11 @@
  The device node for Mediatek USB3.0 DRD controller
  
  Required properties:

- - compatible : should be "mediatek,mt8173-mtu3"
+ - compatible : should be "mediatek,soc-model-mtu3", "mediatek,mtu3",


   Worth enclosing soc-model in <>.


+   soc-model is the name of SoC, such as mt8173, mt2712 etc,
+   when using "mediatek,mtu3" compatible string, you need SoC specific
+   ones in addition, one of:
+   - "mediatek,mt8173-mtu3"
   - reg : specifies physical base address and size of the registers
   - reg-names: should be "mac" for device IP and "ippc" for IP port control
   - interrupts : interrupt used by the device IP


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


[PATCH] usb: common: use of_property_read_bool()

2017-08-20 Thread Sergei Shtylyov
Use more compact of_property_read_bool() calls for the boolean properties
instead  of of_find_property() calls  in of_usb_host_tpl_support() and
of_usb_update_otg_caps().

Signed-off-by: Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>

---
The patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo.

 drivers/usb/common/common.c |   11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

Index: usb/drivers/usb/common/common.c
===
--- usb.orig/drivers/usb/common/common.c
+++ usb/drivers/usb/common/common.c
@@ -190,10 +190,7 @@ EXPORT_SYMBOL_GPL(of_usb_get_dr_mode_by_
  */
 bool of_usb_host_tpl_support(struct device_node *np)
 {
-   if (of_find_property(np, "tpl-support", NULL))
-   return true;
-
-   return false;
+   return of_property_read_bool(np, "tpl-support");
 }
 EXPORT_SYMBOL_GPL(of_usb_host_tpl_support);
 
@@ -240,11 +237,11 @@ int of_usb_update_otg_caps(struct device
otg_caps->otg_rev = 0;
}
 
-   if (of_find_property(np, "hnp-disable", NULL))
+   if (of_property_read_bool(np, "hnp-disable"))
otg_caps->hnp_support = false;
-   if (of_find_property(np, "srp-disable", NULL))
+   if (of_property_read_bool(np, "srp-disable"))
otg_caps->srp_support = false;
-   if (of_find_property(np, "adp-disable", NULL) ||
+   if (of_property_read_bool(np, "adp-disable") ||
(otg_caps->otg_rev < 0x0200))
otg_caps->adp_support = false;
 

--
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 6/7] ARM: dts: stm32: Add USB FS support for STM32F746 MCU

2017-08-17 Thread Sergei Shtylyov

On 8/17/2017 12:33 PM, Amelie Delaunay wrote:


This patch adds the USB pins and nodes for USB FS core on STM32F746 SoC.

Signed-off-by: Amelie Delaunay 
---
  arch/arm/boot/dts/stm32f746.dtsi | 31 +++
  1 file changed, 31 insertions(+)

diff --git a/arch/arm/boot/dts/stm32f746.dtsi b/arch/arm/boot/dts/stm32f746.dtsi
index fcfe5a6..a9476ea 100644
--- a/arch/arm/boot/dts/stm32f746.dtsi
+++ b/arch/arm/boot/dts/stm32f746.dtsi
@@ -419,6 +419,28 @@
slew-rate = <2>;
};
};
+
+   usbotg_fs_pins_a: usbotg_fs@0 {


   Dashes are preferred to underlines in the node names.

[...]

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


Re: [PATCH 4/7] ARM: dts: stm32: Enable USB HS on stm32746g-eval

2017-08-17 Thread Sergei Shtylyov

Hello!

On 8/17/2017 12:33 PM, Amelie Delaunay wrote:


This patch enables USB HS on stm32746g-eval (Host mode).

Signed-off-by: Amelie Delaunay 
---
  arch/arm/boot/dts/stm32746g-eval.dts | 16 
  1 file changed, 16 insertions(+)

diff --git a/arch/arm/boot/dts/stm32746g-eval.dts 
b/arch/arm/boot/dts/stm32746g-eval.dts
index 69a9579..944501d 100644
--- a/arch/arm/boot/dts/stm32746g-eval.dts
+++ b/arch/arm/boot/dts/stm32746g-eval.dts
@@ -83,6 +83,13 @@
gpios = < 13 0>;
};
};
+
+   usbotg_hs_phy: usbphy {


   Name it "usb-phy" please, tpo be m,ore in line with the DT spec.

[...]

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


Re: [PATCH 2/2] usb: musb: musb_cppi41: Fix cppi41_set_dma_mode() for DA8xx

2017-08-15 Thread Sergei Shtylyov

On 8/13/2017 3:04 PM, Alexandre Bailon wrote:


The way to configure the DMA mode on DA8xx is different from DSPS.
Add a new function to configure DMA mode on DA8xx and use a callback
to call the right function based on the platform.

Signed-off-by: Alexandre Bailon 
---
  drivers/usb/musb/musb_cppi41.c | 40 +---
  1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index dbff0e0a4ff5..7284ec7ecff7 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -26,6 +26,7 @@
  
  #define MUSB_DMA_NUM_CHANNELS 15


   Perhaps this needs parametrizing too? DA8xx only has 4 channels IIRC...



+#define DA8XX_USB_MODE_REG 0x10


   Drop this _REG suffix please.


  #define DA8XX_USB_AUTOREQ_REG 0x14
  #define DA8XX_USB_TEARDOWN_REG0x1c
  

[...]

@@ -413,14 +444,15 @@ static bool cppi41_configure_channel(struct dma_channel 
*channel,
} else {
musb_writel(musb->ctrl_base,
RNDIS_REG(cppi41_channel->port_num), 0);
-   cppi41_set_dma_mode(cppi41_channel,
+   controller->set_dma_mode(cppi41_channel,
EP_MODE_DMA_TRANSPARENT);
cppi41_set_autoreq_mode(cppi41_channel,
EP_MODE_AUTOREQ_NONE);
}
} else {
/* fallback mode */
-   cppi41_set_dma_mode(cppi41_channel, EP_MODE_DMA_TRANSPARENT);
+   controller->set_dma_mode(cppi41_channel,
+   EP_MODE_DMA_TRANSPARENT);


   Inconsistent indentation -- you used 2 extra tabs above and 3 here.

[...]

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


Re: [PATCH 1/2] usb: musb: musb_cppi41: Fix the address of teardown and autoreq registers

2017-08-15 Thread Sergei Shtylyov

Hello!

On 8/13/2017 3:04 PM, Alexandre Bailon wrote:


The DA8xx and DSPS platforms don't use the same address for few registers.
On Da8xx, this is causing some issues (e.g. teardown that doesn't work).
Configure the address of the register during the init and use them instead
of constants.

Reported-by: nsek...@ti.com
Signed-off-by: Alexandre Bailon 
---
  drivers/usb/musb/musb_cppi41.c | 23 +++
  1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index ba255280a624..dbff0e0a4ff5 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -26,6 +26,9 @@
  
  #define MUSB_DMA_NUM_CHANNELS 15
  
+#define DA8XX_USB_AUTOREQ_REG	0x14

+#define DA8XX_USB_TEARDOWN_REG 0x1c


   Why these _REG suffixes suddenly?

[...]

   Other than that looks sane. Need my ACK?

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


Re: [PATCH] uas: Add US_FL_IGNORE_RESIDUE for Initio Copropration INIC-3069

2017-07-26 Thread Sergei Shtylyov

Hello!

On 7/26/2017 12:46 AM, Alan Swanson wrote:


Similar to commit d595259fbb7a7afed241b1afb2c4fe4b47de47fa for INIC-3169 in


   That's not how you cite a commit -- you should also specify the commit 
summary line enclosed in ("") (and 12-digit SHA1 would be enough).



unusual_devs.h but INIC-3069 already present in unusual_uas.h. Both in same
controller IC family.

Issue is that MakeMKV fails during key exchange with installed bluray drive
with following error:

002004: Error 'Scsi error - ILLEGAL REQUEST:COPY PROTECTION KEY EXCHANGE 
FAILURE - KEY NOT ESTABLISHED'
occurred while issuing SCSI command AD010..080002400 to device 'SG:dev_11:0'

Signed-off-by: Alan Swanson 

[...]

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


Re: [PATCH 1/4] usb: musb: add helper function musb_ep_xfertype_string

2017-07-18 Thread Sergei Shtylyov

Hello!

On 07/18/2017 06:13 PM, Bin Liu wrote:


Add helper function musb_ep_xfertype_string() to return the ep transfer
type string.

Signed-off-by: Bin Liu 


   Doesn't this belong to USB core? What's MUSB specific about it?


---
 drivers/usb/musb/musb_core.h   | 24 
 drivers/usb/musb/musb_gadget.c |  6 +-
 2 files changed, 25 insertions(+), 5 deletions(-)


WBR, Sergei

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


Re: [PATCH 1/4] usb: Add Aspeed SoC USB controllers to device-tree

2017-06-26 Thread Sergei Shtylyov

On 06/26/2017 05:46 PM, Benjamin Herrenschmidt wrote:


  arch/arm/boot/dts/aspeed-g4.dtsi | 15 +++
  arch/arm/boot/dts/aspeed-g5.dtsi | 22 ++
  2 files changed, 37 insertions(+)


If the patch only changes .dtsi files, the subject needs to be  smth like
"ARM: dts: aspeed: add USB controllers to device tree" -- this is not a USB
patch per se.


Hrm ok, doesn't matter much but I'll grant you that :)


   Note that I didn't invent the subject prefix "ARM: dts: " -- that's what's 
requested by the arm-soc people (Olof/Arnd/etc) on LAKML.



That said, I sent it to the USB list on purpose. It enables the use of
UHCI which will only work following a patch that is in usb-next, so to
avoid complicated sync between trees, it makes more sense to have this
patch in usb-next too.


   I figured it, let's see what Greg says...


Cheers,
Ben.


MBR, Sergei

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


Re: [PATCH 1/4] usb: Add Aspeed SoC USB controllers to device-tree

2017-06-26 Thread Sergei Shtylyov

Hello.

On 6/25/2017 11:18 PM, Benjamin Herrenschmidt wrote:


Now that the necessary tweaks for the Aspeed variant of UHCI
are supported, this adds the USB controllers to the DT
template of the AST24xx and AST25xx SoCs.

The EHCI works with the current unmodified driver.

This patch doesn't enable them by default on any board specific
.dts yet. This will be done when we have the necessary clock/reset
and pinmux support. In the meantime though, this will work if
u-boot configures things properly.

Signed-off-by: Benjamin Herrenschmidt 
---
  arch/arm/boot/dts/aspeed-g4.dtsi | 15 +++
  arch/arm/boot/dts/aspeed-g5.dtsi | 22 ++
  2 files changed, 37 insertions(+)


   If the patch only changes .dtsi files, the subject needs to be  smth like 
"ARM: dts: aspeed: add USB controllers to device tree" -- this is not a USB 
patch per se.


[...]

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


Re: [PATCH] ALSA: hda - Fix applying MSI dual-codec mobo quirk

2017-06-02 Thread Sergei Shtylyov

Hello!

On 6/1/2017 11:58 PM, Takashi Iwai wrote:


The previous commit [63691587f7b0: ALSA: hda - Apply dual-codec quirk
for MSI Z270-Gaming mobo] attempted to apply the existing dual-codec


   The standard way of citing a commit is: commit 63691587f7b0 ("ALSA: hda - 
Apply dual-codec quirk for MSI Z270-Gaming mobo"), just like in the Fixes: tag.



quirk for a MSI mobo.  But it turned out that this isn't applied
properly due to the MSI-vendor quirk before this entry.  I overlooked
such two MSI entries just because they were put in the wrong position,
although we have a list ordered by PCI SSID numbers.

This patch fixes it by rearranging the unordered entries.

Fixes: 63691587f7b0 ("ALSA: hda - Apply dual-codec quirk for MSI Z270-Gaming 
mobo")
Reported-by: Rudolf Schmidt 
Signed-off-by: Takashi Iwai 

[...]

MBR, Sergei

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


Re: [PATCH v2] usb:host:xhci AMD Promontory USB disable port support

2017-05-26 Thread Sergei Shtylyov

Hello!

On 5/26/2017 12:35 PM, Jiahau Chang wrote:


 There is some limitation for AMD Promontory xHCI host to disable USB port
 function. It will enable USB wake-up function then cause USB disable port
 feature to fail.  Workaround this issue on Promontory xHCI host is clear
 PORT_WAKE_BITS.

Signed-off-by: Jiahau Chang 
---
 drivers/usb/host/xhci-hub.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 51e408b..fa5ef22 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -1224,7 +1224,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, 
u16 wValue,
"actual port %d status  = 
0x%x\n",
wIndex, temp);
}
-else { 
+else {


   Unrelated whitespace change (and not even being enough here).


xhci_set_remote_wake_mask(xhci, port_array,
wIndex, wake_mask);
temp = readl(port_array[wIndex]);
@@ -1469,7 +1469,6 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
t2 |= PORT_WKOC_E | PORT_WKCONN_E;
t2 &= ~PORT_WKDISC_E;
}
-   


   Again.


if ((xhci->quirks & XHCI_U2_DISABLE_WAKE) && (hcd->speed 
< HCD_USB3))
t2 &= ~PORT_WAKE_BITS;
} else


   The real question is where's the related changes are? :-)

MBR, Sergei

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


Re: [PATCH v4 1/4] usb: usbip tool: Check the return of get_nports()

2017-05-22 Thread Sergei Shtylyov

Hello!

On 5/22/2017 11:41 AM, Yuyang Du wrote:


If we get nonpositive number of ports, there is no sense to
continue, then fail gracefully.

In addition, the commit 0775a9cbc694e8c72 ("usbip: vhci extension:
modifications to vhci driver") introduced configurable numbers of
controllers and ports, but we have a static port number maximum,
MAXNPORT. If exceeded, the idev array will be overflown. We fix
it by validating the nports to make sure the port number max is
not exceeded.

Reviewed-by: Krzysztof Opasiak 
Signed-off-by: Yuyang Du 
Acked-by: Shuah Khan 
---
 tools/usb/usbip/libsrc/vhci_driver.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/usb/usbip/libsrc/vhci_driver.c 
b/tools/usb/usbip/libsrc/vhci_driver.c
index f659c14..0a6d113 100644
--- a/tools/usb/usbip/libsrc/vhci_driver.c
+++ b/tools/usb/usbip/libsrc/vhci_driver.c
@@ -220,9 +220,17 @@ int usbip_vhci_driver_open(void)
}

vhci_driver->nports = get_nports();
-
dbg("available ports: %d", vhci_driver->nports);

+   if (vhci_driver->nports <= 0) {
+   err("no available ports");
+   goto err;
+   }
+   else if (vhci_driver->nports > MAXNPORT) {


} and *else if* should be on te same line. Not sure how I missed that in 
the 1st review, sorry about that...



+   err("port number exceeds %d", MAXNPORT);
+   goto err;
+   }
+
if (refresh_imported_device_list())
goto err;



MBR, Sergei

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


Re: [PATCH resend v3 1/4] usb: usbip tool: Check the return of get_nports()

2017-05-18 Thread Sergei Shtylyov

Hello!

On 05/18/2017 12:50 PM, Yuyang Du wrote:


From: Yuyang Du 

If we get nonpositive number of ports, there is no sense to


   Negative?


continue, then fail gracefully.

In addition, the commit 0775a9cbc694e8c72 ("usbip: vhci extension:
modifications to vhci driver") introduced configurable numbers of
controllers and ports, but we have a static port number maximum,
MAXNPORT. If exceeded, the idev array will be overflown. We fix
it by validating the nports to make sure the port number max is
not exceeded.

Reviewed-by: Krzysztof Opasiak 
Signed-off-by: Yuyang Du 
Acked-by: Shuah Khan 
---
 tools/usb/usbip/libsrc/vhci_driver.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/usb/usbip/libsrc/vhci_driver.c 
b/tools/usb/usbip/libsrc/vhci_driver.c
index f659c14..151580a 100644
--- a/tools/usb/usbip/libsrc/vhci_driver.c
+++ b/tools/usb/usbip/libsrc/vhci_driver.c
@@ -220,9 +220,17 @@ int usbip_vhci_driver_open(void)
}

vhci_driver->nports = get_nports();
-
dbg("available ports: %d", vhci_driver->nports);

+   if (vhci_driver->nports <=0) {


   Please add a space after <= too.

[...]

MBR, Sergei

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


Re: [PATCH] usb: musb: musb_cppi41: Update an error message

2017-05-02 Thread Sergei Shtylyov

On 05/02/2017 07:50 PM, Alexandre Bailon wrote:


If dma_request_slave_channel() failed to return a channel,
then the driver will print an error and request to defer probe.
Update the error message to explain we are defrering probe.

Signed-off-by: Alexandre Bailon 
---
  drivers/usb/musb/musb_cppi41.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index e7c8b1b..e6b9161 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -676,6 +676,7 @@ static int cppi41_dma_controller_start(struct
cppi41_dma_controller *controller)
  dc = dma_request_slave_channel(dev->parent, str);
  if (!dc) {
  dev_err(dev, "Failed to request %s.\n", str);
+dev_info(dev, "Deferring probe.\n");

Please merge the two lines above into one statement, using dev_info().

Well, if I merge the two lines, the patch won't pass checkpatch because the
string is too long.


   No, checkpatch.pl shouldn't complain about the strings passed to 
dev_info() and friends.


[...]

MBR, Sergei

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


Re: [PATCH v2] usb: gadget: gserial: check if console kthread exists

2017-04-29 Thread Sergei Shtylyov

Hello!

On 4/29/2017 4:26 PM, Bogdan Mirea wrote:


Check for bad pointer that may result because of kthread_create failure.
This check is needed since the gserial setup callback function
(gs_console_setup()) is only freeing the info->con_buf in case of
kthread_create failure which will result into bad info->console_thread
pointer.
Without checking info->console_thread pointer validity in the
gserial_console_exit() function, before calling kthread_stop(), the rmmod
will generate Kernel Oops.

Signed-off-by: Bogdan Mirea 
---
 drivers/usb/gadget/function/u_serial.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/u_serial.c 
b/drivers/usb/gadget/function/u_serial.c
index 4be1e7e..0f53b0b 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -1256,7 +1256,7 @@ static void gserial_console_exit(void)
struct gscons_info *info = _info;

unregister_console(_cons);
-   if (info->console_thread != NULL)
+   if (info->console_thread != NULL && !IS_ERR(info->console_thread))


   There is IS_ERR_OR_NULL() for that, no?


kthread_stop(info->console_thread);
gs_buf_free(>con_buf);
 }


MBR, Sergei

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


Re: [RFC] usb-phy-generic: Add support to SMSC USB3315

2017-04-19 Thread Sergei Shtylyov

On 04/19/2017 01:24 PM, Peter Senna Tschudin wrote:


We need the SMSC USB3315 clock and regulator to always be initialized.
We also need the PHY driver to take the PHY out of reset. This patch
extends the existing USB generic nop phy driver to include a new
initialization path.

A new compatible string "smsc,usb3315" is used to decide which
initialization path to use.

CC: Peter Chen 
CC: Stephen Boyd 
CC: Fabien Lahoudere 
Signed-off-by: Peter Senna Tschudin 
---

This is a follow-up of previous discussion:
  https://www.spinics.net/lists/linux-usb/msg146680.html

 drivers/usb/phy/phy-generic.c | 33 +
 drivers/usb/phy/phy-generic.h |  1 +
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index 89d6e7a..6ea9ce4 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c

[...]

@@ -216,18 +221,29 @@ static int nop_set_host(struct usb_otg *otg, struct 
usb_bus *host)
otg->host = host;
return 0;
 }


   Need empty line here.


+int smsc_usb3315_init(struct usb_phy_generic *nop)
+{
+   /*
+* If the gpio for controlling reset state is not available, try again
+* later
+*/
+   if(!nop->gpiod_reset)


   You hadn't run the patch thru scripts/checkpatch.pl before posting --
need space between *if* and (.

[...]

@@ -304,6 +320,12 @@ int usb_phy_gen_create_phy(struct device *dev, struct 
usb_phy_generic *nop,
nop->phy.otg->set_host= nop_set_host;
nop->phy.otg->set_peripheral  = nop_set_peripheral;

+   if(node && of_device_is_compatible(node, "smsc,usb3315")) {


   Same here.

[...]

MBR, Sergei


Thank you for the review Sergei! Should I send V2 of this RFC fixing
these issues or wait for comments on the validity of this approach?


   Wait, of course, if this is RFC...

WBR, Sergei

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


Re: [RFC] usb-phy-generic: Add support to SMSC USB3315

2017-04-19 Thread Sergei Shtylyov

Hello!

On 4/19/2017 9:14 AM, Peter Senna Tschudin wrote:


We need the SMSC USB3315 clock and regulator to always be initialized.
We also need the PHY driver to take the PHY out of reset. This patch
extends the existing USB generic nop phy driver to include a new
initialization path.

A new compatible string "smsc,usb3315" is used to decide which
initialization path to use.

CC: Peter Chen 
CC: Stephen Boyd 
CC: Fabien Lahoudere 
Signed-off-by: Peter Senna Tschudin 
---

This is a follow-up of previous discussion:
  https://www.spinics.net/lists/linux-usb/msg146680.html

 drivers/usb/phy/phy-generic.c | 33 +
 drivers/usb/phy/phy-generic.h |  1 +
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index 89d6e7a..6ea9ce4 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c

[...]

@@ -216,18 +221,29 @@ static int nop_set_host(struct usb_otg *otg, struct 
usb_bus *host)
otg->host = host;
return 0;
 }


   Need empty line here.


+int smsc_usb3315_init(struct usb_phy_generic *nop)
+{
+   /*
+* If the gpio for controlling reset state is not available, try again
+* later
+*/
+   if(!nop->gpiod_reset)


   You hadn't run the patch thru scripts/checkpatch.pl before posting -- need 
space between *if* and (.


[...]

@@ -304,6 +320,12 @@ int usb_phy_gen_create_phy(struct device *dev, struct 
usb_phy_generic *nop,
nop->phy.otg->set_host= nop_set_host;
nop->phy.otg->set_peripheral  = nop_set_peripheral;

+   if(node && of_device_is_compatible(node, "smsc,usb3315")) {


   Same here.

[...]

MBR, Sergei

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


Re: [PATCH] xhci: use correct flags for spin_lock_irqrestore() when setting port power

2017-04-13 Thread Sergei Shtylyov

Hello.

On 4/13/2017 9:48 AM, Mathias Nyman wrote:


commit a6ff6cbf1fab ("usb: xhci: Add helper function xhci_set_power_on().")
created a helper to control port power that needs to be called with
xhci->lock held and interrupts disabled.
It relased the lock with spin_unlock_irqerstore using a new zero flag


   "Released" and "irqrestore".


variable instead of the origial flag from spin_lock_irqsave.


   Original.


This regression triggered a static checker warning about bogus flags, and
a null pointer dereference on armada-385.

Fix it by passing a pointer to the correct flags and using it instead

Fixes: a6ff6cbf1fab ("usb: xhci: Add helper function xhci_set_power_on().")
Cc: Guoqing Zhang 
Signed-off-by: Mathias Nyman 

[...]

MBR, Sergei

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


Re: [PATCH] usb: dwc3: make macros safe to expression arguments

2017-04-06 Thread Sergei Shtylyov

Hello.

On 4/6/2017 1:17 PM, Felipe Balbi wrote:


From: Roger Quadros 

We must make sure that our macros are safe against expressions passed
as arguments. We have see one problem where GTXFIFOSIZ(n) was failling


   "Seen" and "failing".


when passed the expression (epnum >> 1) as argument. The problem was
caused by operator precedence between >> and *.

To make sure macros are safe, we just wrap argument with () when using
it.

Signed-off-by: Roger Quadros 
Signed-off-by: Felipe Balbi 
---

As discussed over IRC, Roger figured out what was the problem
with "Bryan's patch". It turns out that GTXFIFOSIZ() macro wasn't
safe against expression arguments.

Roger provided a patch, which I'm now sending to linux-usb in his
regard.

 drivers/usb/dwc3/core.h | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 459ecf3afa48..8a0fbcd99638 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h

[...]

@@ -460,7 +460,7 @@
 #define DWC3_DEPCMD_CMD(x) ((x) & 0xf)

 /* The EP number goes 0..31 so ep0 is always out and ep1 is always in */
-#define DWC3_DALEPENA_EP(n)BIT(n)
+#define DWC3_DALEPENA_EP(n)BIT((n))


   Why do we need double parens?

[...]

MBR, Sergei

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


Re: [PATCH] usb: dwc3: debugfs: downcase OTG on 'mode' file

2017-03-31 Thread Sergei Shtylyov

Hello.

On 03/31/2017 02:12 PM, Felipe Balbi wrote:


When writing, we expect the "otg" string. When showing, we return
"OTG". Let's downcase that word to avoid confusion.


   Lowercase, maybe?



Signed-off-by: Felipe Balbi 

[...]

MBR, Sergei

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


Re: [PATCH] ARM: davinci: Add the clock for the CPPI 4.1 DMA engine

2017-03-29 Thread Sergei Shtylyov

Hello!

On 03/29/2017 07:09 PM, Alexandre Bailon wrote:


The CPPI 4.1 DMA is sharing its clock with the USB OTG,
and most of the time, the clock will be enabled by USB.
But during the init of the DMA, USB is not enabled (waiting for DMA),
and then we must enable the clock before to do anything.


   s/to do/doing/.


Add the clock for the CPPI 4.1 DMA engine.

Note:
This patch is to apply instead of:
"ARM: davinci: Make the usb20 clock available to PM runtime"

Signed-off-by: Alexandre Bailon 
---
 arch/arm/mach-davinci/da830.c| 1 +
 arch/arm/mach-davinci/da850.c| 1 +
 arch/arm/mach-davinci/da8xx-dt.c | 2 ++
 3 files changed, 4 insertions(+)

diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index 073c458..ae4a8a5 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -413,6 +413,7 @@ static struct clk_lookup da830_clks[] = {
CLK("davinci-mcasp.1",NULL,   _clk),
CLK("davinci-mcasp.2",NULL,   _clk),
CLK("musb-da8xx", "usb20",  _clk),
+   CLK("cppi41-dmaengine",   NULL,   _clk),
CLK(NULL,   "aemif",  _clk),
CLK(NULL,   "aintc",  _clk),
CLK(NULL,   "secu_mgr",   _mgr_clk),
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index ccad2f9..9739aaa 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -560,6 +560,7 @@ static struct clk_lookup da850_clks[] = {
CLK("davinci-nand.0", "aemif",  _nand_clk),
CLK("ohci-da8xx", "usb11",  _clk),
CLK("musb-da8xx", "usb20",  _clk),
+   CLK("cppi41-dmaengine",   NULL,   _clk),
CLK("spi_davinci.0",  NULL,   _clk),
CLK("spi_davinci.1",  NULL,   _clk),
CLK("vpif",   NULL,   _clk),
diff --git a/arch/arm/mach-davinci/da8xx-dt.c b/arch/arm/mach-davinci/da8xx-dt.c
index e3cef50..5bf08ba 100644
--- a/arch/arm/mach-davinci/da8xx-dt.c
+++ b/arch/arm/mach-davinci/da8xx-dt.c
@@ -53,6 +53,8 @@ static struct of_dev_auxdata da850_auxdata_lookup[] 
__initdata = {
OF_DEV_AUXDATA("ti,da830-musb", 0x01e0, "musb-da8xx", NULL),
OF_DEV_AUXDATA("ti,da830-usb-phy", 0x01c1417c, "da8xx-usb-phy", NULL),
OF_DEV_AUXDATA("ti,da850-ahci", 0x01e18000, "ahci_da850", NULL),
+   OF_DEV_AUXDATA("ti,da830-cppi41", 0x01e01000, "cppi41-dma-engine",


   Not "cppi41-dmaengine"?

[...]

MBR, Sergei

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


Re: [PATCH] usb: gadget: udc: remove redundant initial assignments to the pointer 's'

2017-03-28 Thread Sergei Shtylyov

Hello!

On 3/28/2017 1:34 AM, Colin King wrote:


From: Colin Ian King 

The initial setting of pointer s to the driver name or to the literal
string "(none)" is redundant as later it is always set to point to
a different literal string before it is printed log.  Remove this


   Printed to log, perhaps?


redundant code.

Detected with CoverityScan, CID#1227032, CID#1227033 ("Unused Value")

Signed-off-by: Colin Ian King 

[...]

MBR, Sergei

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


Re: [PATCH 2/2] Documentation: ABI: testing: sysfs-class-net-qmi: add new qmap mux files description

2017-03-24 Thread Sergei Shtylyov

Hello!

On 03/24/2017 04:22 PM, Daniele Palmas wrote:


This patch updates the documentation related to the new files added for
qmap mux support.

Signed-off-by: Daniele Palmas 
---
 Documentation/ABI/testing/sysfs-class-net-qmi | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-net-qmi 
b/Documentation/ABI/testing/sysfs-class-net-qmi
index fa5a00b..5191dc3 100644
--- a/Documentation/ABI/testing/sysfs-class-net-qmi
+++ b/Documentation/ABI/testing/sysfs-class-net-qmi
@@ -21,3 +21,30 @@ Description:
is responsible for coordination of driver and firmware
link framing mode, changing this setting to 'Y' if the
firmware is configured for 'raw-ip' mode.
+
+What:  /sys/class/net//qmi/add_mux
+Date:  March 2017
+KernelVersion: 4.11
+Contact:   Bjørn Mork 
+Description:
+   Unsigned integer.
+
+   Write a number ranging from 1 to 127 to add a qmap mux
+   based network device, supported by recent Qualcomm based
+   modems.
+
+   The network device will be called qmimux.
+
+   Userspace is in charge of managing the qmux network device
+   activation and data stream setup  on them modem side by


   s/them/the/?


+   using the proper QMI protocol requests.

[...]

MBR, Sergei

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


Re: [PATCH] usb: gadget: dummy_hcd: Fix wrong port status macros in dummy_hub_control()

2017-03-20 Thread Sergei Shtylyov

Hello!

On 3/19/2017 11:23 PM, Yuyang Du wrote:


This fixes the commit: 1cd8fd2887e162ad3d06715 (usb: gadget: dummy_hcd:
add SuperSpeed support).


   It should be quoted as commit 1cd8fd2887e1 ("usb: gadget: dummy_hcd:
> add SuperSpeed support"). See Documentation/process/submitting-patches.rst, 
section 2.



Signed-off-by: Yuyang Du 

[...]

MBR, Sergei

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


Re: [PATCH v2 2/4] cdc-acm: fix possible invalid access when processing notification

2017-03-19 Thread Sergei Shtylyov

On 3/18/2017 9:52 PM, Tobias Herzog wrote:


Notifications may only be 8 bytes so long. Accessing the 9th and


   s/so//.
   "So long and thanks for all the fish!" :-)


10th byte of unimplemented/unknown notifications may be insecure.
Also check the length of known notifications before accessing anything
behind the 8th byte.

Signed-off-by: Tobias Herzog 

[...]

MBR, Sergei

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


Re: [PATCH v2] usb: xhci: bInterval quirk for TI TUSB73x0

2017-03-13 Thread Sergei Shtylyov

Hello!

On 3/13/2017 11:11 AM, Roger Quadros wrote:


As per [1] issue #4,
"The periodic EP scheduler always tries to schedule the EPs
that have large intervals (interval equal to or greater than
128 microframes) into different microframes. So it maintains
an internal counter and increments for each large interval
EP added. When the counter is greater than 128, the scheduler
rejects the new EP. So when the hub re-enumerated 128 times,
it triggers this condition."

This results in Bandwidth error when devices with periodic
endpoints (ISO/INT) having bInterval > 7 are plugged an


   s/an/and/.


unplugged several times on a TUSB73x0 xhci host.


   xHCI.


Workaround this issue by limiting the bInterval to 7
(i.e. interval to 6) for High-speed or faster periodic endpoints.

[1] - http://www.ti.com/lit/er/sllz076/sllz076.pdf

Signed-off-by: Roger Quadros 

[...]

MBR, Sergei

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


Re: [PATCH] usb: xhci: bInterval quirk for TI TUSB73x0

2017-03-09 Thread Sergei Shtylyov

Hello!

On 3/9/2017 11:47 AM, Roger Quadros wrote:


As per [1] issue #4,
"The periodic EP scheduler always tries to schedule the EPs
that have large intervals (interval equal to or greater than
128 microframes) into different microframes. So it maintains
an internal counter and increments for each large interval
EP added. When the counter is greater than 128, the scheduler
rejects the new EP. So when the hub re-enumerated 128 times,
it trigged this condition."


   Triggered.


This results in Bandwidth error when devices with periodic
endpoints (ISO/INT) having bInterval > 7 are plugged an
unplugged several times on a TUSB73x0 xhci host.

Workaround this issue by limiting the bInterval to 7
(i.e. interval to 6) for High-speed or faster periodic endpoints.

[1] - http://www.ti.com/lit/er/sllz076/sllz076.pdf

Signed-off-by: Roger Quadros 

[...]

MBR, Sergei

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


Re: [PATCH 11/29] drivers, media: convert cx88_core.refcount from atomic_t to refcount_t

2017-03-07 Thread Sergei Shtylyov

On 3/7/2017 10:52 AM, Reshetova, Elena wrote:


refcount_t type and corresponding API should be
used instead of atomic_t when the variable is used as
a reference counter. This allows to avoid accidental
refcounter overflows that might lead to use-after-free
situations.

Signed-off-by: Elena Reshetova 
Signed-off-by: Hans Liljestrand 
Signed-off-by: Kees Cook 
Signed-off-by: David Windsor 

[...]

diff --git a/drivers/media/pci/cx88/cx88.h b/drivers/media/pci/cx88/cx88.h
index 115414c..16c1313 100644
--- a/drivers/media/pci/cx88/cx88.h
+++ b/drivers/media/pci/cx88/cx88.h

[...]

@@ -339,7 +340,7 @@ struct cx8802_dev;

 struct cx88_core {
struct list_head   devlist;
-   atomic_t   refcount;
+   refcount_t   refcount;


Could you please keep the name aligned with above and below?


You mean "not aligned" to devlist, but with a shift like it was before?


   I mean aligned, like it was before. :-)


Sure, will fix. Is the patch ok otherwise?


   I haven't noticed anything else...


Best Regards,
Elena.

[...]

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


Re: [PATCH 11/29] drivers, media: convert cx88_core.refcount from atomic_t to refcount_t

2017-03-06 Thread Sergei Shtylyov

Hello.

On 03/06/2017 05:20 PM, Elena Reshetova wrote:


refcount_t type and corresponding API should be
used instead of atomic_t when the variable is used as
a reference counter. This allows to avoid accidental
refcounter overflows that might lead to use-after-free
situations.

Signed-off-by: Elena Reshetova 
Signed-off-by: Hans Liljestrand 
Signed-off-by: Kees Cook 
Signed-off-by: David Windsor 

[...]

diff --git a/drivers/media/pci/cx88/cx88.h b/drivers/media/pci/cx88/cx88.h
index 115414c..16c1313 100644
--- a/drivers/media/pci/cx88/cx88.h
+++ b/drivers/media/pci/cx88/cx88.h
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -339,7 +340,7 @@ struct cx8802_dev;

 struct cx88_core {
struct list_head   devlist;
-   atomic_t   refcount;
+   refcount_t   refcount;


   Could you please keep the name aligned with above and below?



/* board name */
intnr;



MBR, Sergei

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


Re: [PATCH v4 08/19] scsi: be2iscsi: Replace PCI pool old API

2017-03-03 Thread Sergei Shtylyov

On 3/1/2017 6:55 PM, Romain Perier wrote:


The PCI pool API is deprecated. This commits replaces the PCI pool old


   Commit.


API by the appropriated function with the DMA pool API.


   Appropriate perhaps?


Signed-off-by: Romain Perier 
Acked-by: Peter Senna Tschudin 
Tested-by: Peter Senna Tschudin 

[...]

MBR, Sergei

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


Re: [PATCH v4 09/19] scsi: csiostor: Replace PCI pool old API

2017-03-03 Thread Sergei Shtylyov

Hello!

On 3/1/2017 6:55 PM, Romain Perier wrote:


The PCI pool API is deprecated. This commits replaces the PCI pool old


   Commit.


API by the appropriated function with the DMA pool API. It also updates


   Appropriate perhaps?


the name of some variables and the content of comments, accordingly.

Signed-off-by: Romain Perier 
Reviewed-by: Peter Senna Tschudin 

[...]

MBR, Sergei

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


Re: [PATCH] usb: dwc2: Make sure we disconnect the gadget state

2017-03-03 Thread Sergei Shtylyov

Hello!

On 3/3/2017 2:36 AM, John Stultz wrote:


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


   Plugged. Perhaps could be fixed while applying...


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
Acked-by: John Youn 
Signed-off-by: John Stultz 

[...]

MBR, Sergei

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


Re: [PATCH] usb: musb: cppi41: don't check early-TX-interrupt for Isoch transfer

2017-03-02 Thread Sergei Shtylyov

Hello!

On 3/2/2017 5:52 AM, Bin Liu wrote:


The CPPI41 driver polls register to workaround the pre-mature TX


   It's CPPI 4.1. And "premature".


interrupt issue, but it causes audio playback underrun when triggered in
Isoch transfers.

Isoch doesn't do back-to-back transfers, the TX should be done by the
time the next transfer is scheduled. So skip this polling workaround for
Isoch transfer.

Fixes: a655f481d83d6 ("usb: musb: musb_cppi41: handle pre-mature TX complete 
interrupt")
Cc:  #4.1+
Reported-by: Alexandre Bailon 
Signed-off-by: Bin Liu 

[...]

MBR, Sergei

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


Re: [PATCH v3 7/8] arm64: dts: mt8173: move clock from phy node into port nodes

2017-02-22 Thread Sergei Shtylyov

On 2/22/2017 11:55 AM, Chunfeng Yun wrote:


there is a reference clock for each port, HighSpeed port is 48M,
and SuperSpeed port is 26M which usually comes from 26M oscillator
directly, but some SoCs is not. it is flexible to move it into port


   ... but on some SoCs does not?


node.

Signed-off-by: Chunfeng Yun 

[...]

MBR, Sergei

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


Re: [PATCH v3 4/8] phy: phy-mt65xx-usb3: move clock from phy node into port nodes

2017-02-22 Thread Sergei Shtylyov

Hello!

On 2/22/2017 11:55 AM, Chunfeng Yun wrote:


the reference clock of HighSpeed port is 48M which comes from PLL;
the reference clock of SuperSpeed port is 26M which usually comes
from 26M oscillator directly, but some SoCs are not, add it for


... but on some SoCs does not?


compatibility, and put them into port node for flexibility.

Signed-off-by: Chunfeng Yun 

[...]

MBR, Sergei

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


Re: [PATCH] lvs: fix race condition in disconnect handling

2017-02-20 Thread Sergei Shtylyov

On 02/20/2017 05:38 PM, Oliver Neukum wrote:


There is a small window during which the an URB may


   So the or an?


remain active after disconnect has returned. If in that case
already freed memory may be accessed and executed.

The fix is to poison the URB befotre the work is flushed.

Signed-off-by: Oliver Neukum 
---
 drivers/usb/misc/lvstest.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/misc/lvstest.c b/drivers/usb/misc/lvstest.c
index 7717651..e5d2500 100644
--- a/drivers/usb/misc/lvstest.c
+++ b/drivers/usb/misc/lvstest.c
@@ -429,6 +429,8 @@ static void lvs_rh_disconnect(struct usb_interface *intf)
struct lvs_rh *lvs = usb_get_intfdata(intf);

sysfs_remove_group(>dev.kobj, _attr_group);
+   usb_poison_urb(lvs->urb); /* used in scheduled work */
+   (lvs->urb);


   What?

[...]

MBR, Sergei

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


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

2017-02-14 Thread Sergei Shtylyov

Hello!

On 2/14/2017 5:27 AM, Lu Baolu wrote:


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;


   Why not:

if (!tsc_khz)
tsc_khz = cpu_khz;

   It's more clear IMHO.


+   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

[...]

MBR, Sergei

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


Re: [PATCH v3 1/3] lib/string: introduce ascii2utf16le() helper

2017-02-06 Thread Sergei Shtylyov

Hello!

On 02/06/2017 05:03 PM, Richard Leitner wrote:


For USB string descriptors we need to convert ASCII strings to UTF16-LE.
Therefore make a simple helper function (based on ascii2desc from
drivers/usb/core/hcd.c) for that purpose.

Signed-off-by: Richard Leitner 

[...]

diff --git a/lib/string.c b/lib/string.c
index ed83562..a113e3e 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -952,3 +952,29 @@ char *strreplace(char *s, char old, char new)
return s;
 }
 EXPORT_SYMBOL(strreplace);
+
+/**
+ * ascii2utf16le() - Helper routine for producing UTF-16LE string descriptors
+ * @s: Null-terminated ASCII (actually ISO-8859-1) string
+ * @buf: Buffer for UTF-16LE string
+ * @len: Length (in bytes; may be odd) of UTF-16LE buffer.
+ *
+ * Return: The number of bytes filled in: 2*strlen(s) or @len, whichever is 
less
+ */
+unsigned int ascii2utf16le(char const *s, u8 *buf, unsigned int len)
+{
+   unsigned int n, t = 2 * strlen(s);
+
+   if (len > t)
+   len = t;
+   n = len;
+   while (n--) {
+   t = (unsigned char)*s++;
+   *buf++ = t;
+   if (!n--)
+   break;
+   *buf++ = t >> 8;


   Isn't it always 0?


+   }
+   return len;
+}
+EXPORT_SYMBOL(ascii2utf16le);


MBR, Sergei

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


Re: [PATCH v4 4/5] usb: musb: musb_cppi41: Workaround DMA stall issue during teardown

2017-01-24 Thread Sergei Shtylyov

Hello.

On 1/24/2017 1:11 PM, Alexandre Bailon wrote:


The DMA may hung up if a teardown is initiated while an endpoint is still


   Hang up.


active (Advisory 2.3.27 of DA8xx errata).
To workaround this issue, add a delay before to initiate the teardown.

Signed-off-by: Alexandre Bailon 

[...]

MBR, Sergei

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


Re: [PATCH 25/37] xhci: Introduce helper to turn one TRB into a no-op

2017-01-20 Thread Sergei Shtylyov

On 01/20/2017 05:47 PM, Mathias Nyman wrote:


Useful for turning both transfer and command trbs
into no-ops

Signed-off-by: Mathias Nyman 
---
 drivers/usb/host/xhci-ring.c | 32 
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 8b78eee..699fc2d 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c

[...]

@@ -290,6 +305,9 @@ static struct xhci_command *xhci_next_queued_cmd(struct 
xhci_hcd *xhci)
cmd_list);
 }

+
+
+


   ???


 /*
  * Turn all commands on command ring with status set to "aborted" to no-op 
trbs.
  * If there are other commands waiting then restart the ring and kick the 
timer.

[...]

MBR, Sergei

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


Re: [PATCH 32/37] usb: host: xhci: remove newline from tracer

2017-01-20 Thread Sergei Shtylyov

Hello!

On 01/20/2017 05:47 PM, Mathias Nyman wrote:


From: Felipe Balbi 

If we add that newline, the output will like like the following:


   Look like. :-)


 kworker/2:1-42[002]    169.811435: xhci_address_ctx:
ctx_64=0, ctx_type=2, ctx_dma=@153fbd000, ctx_va=@880153fbd000

We would rather have that in a single line.

Signed-off-by: Felipe Balbi 
Signed-off-by: Mathias Nyman 

[...]

MBR, Sergei

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


Re: [PATCH v3 2/3] dmaengine: cppi41: Add support of DA8xx to CPPI 4.1

2017-01-19 Thread Sergei Shtylyov

On 01/19/2017 02:13 PM, Alexandre Bailon wrote:


The DA8xx has a CPPI 4.1 DMA controller.
This is add the glue layer required to make it work on DA8xx.

Signed-off-by: Alexandre Bailon 
---
 drivers/dma/Kconfig  |  6 +++---
 drivers/dma/cppi41.c | 24 
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 0d6a96e..03ae2a1 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -514,12 +514,12 @@ config TIMB_DMA
  Enable support for the Timberdale FPGA DMA engine.

 config TI_CPPI41
-   tristate "AM33xx CPPI41 DMA support"
-   depends on ARCH_OMAP
+   tristate "CPPI41 DMA support"


   Grr... CPPI 4.1, please.


+   depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX)
select DMA_ENGINE
help
  The Communications Port Programming Interface (CPPI) 4.1 DMA engine
- is currently used by the USB driver on AM335x platforms.
+ is currently used by the USB driver on AM335x and DA8xx platforms.

 config TI_DMA_CROSSBAR
bool
diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 9767b97..f6f2d84 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c

[...]

@@ -951,8 +965,18 @@ static const struct cppi_glue_infos am335x_usb_infos = {
.qmgr_num_pend = 5,
 };

+static const struct cppi_glue_infos da8xx_usb_infos = {
+   .isr = cppi41_irq,


   Isn't the ISR the same for all glues now?

[...]

MBR, Sergei

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


Re: [PATCH v3 5/5] usb: musb: da8xx: Add a primary support of PM runtime

2017-01-19 Thread Sergei Shtylyov

On 01/19/2017 05:08 PM, Alexandre Bailon wrote:


Currently, DA8xx doesn't support PM runtime.
In addition, the glue driver is managing the clock itself.
But the CPPI DMA needs to manage this clock too.
Add support to PM runtime and use the callback to enable / disable
the clock.


   I think this sentence is stale now


And because the CPPI 4.1 is a child of Da8xx USB,
it will be able to enable / disable the clock by using PM runtime.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c | 23 ++-
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 8c9850c..c4478c7 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c

[...]

@@ -377,11 +375,7 @@ static int da8xx_musb_init(struct musb *musb)

musb->mregs += DA8XX_MENTOR_CORE_OFFSET;

-   ret = clk_prepare_enable(glue->clk);
-   if (ret) {
-   dev_err(glue->dev, "failed to enable clock\n");
-   return ret;
-   }
+   pm_runtime_get_sync(musb->controller->parent);

/* Returns zero if e.g. not clocked */
rev = musb_readl(reg_base, DA8XX_USB_REVISION_REG);
@@ -424,7 +418,7 @@ static int da8xx_musb_init(struct musb *musb)
 err_phy_power_on:
phy_exit(glue->phy);
 fail:
-   clk_disable_unprepare(glue->clk);
+   pm_runtime_put_sync(musb->controller->parent);


   Not sure we need put_sync() here and below -- usually a simple put() is 
used...


[...]

MBR, Sergei

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


Re: [PATCH v3 3/5] usb: musb: Add support of CPPI 4.1 DMA controller to DA8xx

2017-01-19 Thread Sergei Shtylyov

On 01/19/2017 05:08 PM, Alexandre Bailon wrote:


Currently, only the PIO mode is supported.
This add support of CPPI 4.1 to DA8xx.
As the In DA8xx the CPPI 4.1 DMA is a part of the USB.
Create the CPPI 4.1 device as a child of USB.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/Kconfig |  4 ++--
 drivers/usb/musb/da8xx.c | 35 ++-
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 72a2a50..5506a9c 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -160,8 +160,8 @@ config USB_TI_CPPI_DMA
  Enable DMA transfers when TI CPPI DMA is available.

 config USB_TI_CPPI41_DMA
-   bool 'TI CPPI 4.1 (AM335x)'
-   depends on ARCH_OMAP && DMADEVICES
+   bool 'TI CPPI 4.1'
+   depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX) && DMADEVICES
select TI_CPPI41

 config USB_TUSB_OMAP_DMA
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index cd3d763..5f50a78 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c

[...]

@@ -457,12 +458,40 @@ static inline u8 get_vbus_power(struct device *dev)
return current_uA / 1000 / 2;
 }

+#ifdef CONFIG_USB_TI_CPPI41_DM


   CONFIG_USB_TI_CPPI41_DMA! :-)

[...]

MBR, Sergei

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


Re: [PATCH v3 4/4] dmaengine: cppi41: init_sched(): Get number of channels from DT

2017-01-19 Thread Sergei Shtylyov

On 1/19/2017 1:37 PM, Alexandre Bailon wrote:


Despite the driver is already using DT to get the number of channels,
init_sched() is using an hardcoded value to get it.
Use DT to get the number of channels.

Signed-off-by: Alexandre Bailon 
---
 drivers/dma/cppi41.c | 26 +++---
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 5a40653..9767b97 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c

[...]

@@ -832,7 +829,7 @@ static int init_descs(struct device *dev, struct cppi41_dd 
*cdd)
return 0;
 }

-static void init_sched(struct cppi41_dd *cdd)
+static void init_sched(struct device *dev, struct cppi41_dd *cdd)


   I don't see where 'dev' is used...


 {
unsigned ch;
unsigned word;
@@ -840,7 +837,7 @@ static void init_sched(struct cppi41_dd *cdd)

word = 0;
cppi_writel(0, cdd->sched_mem + DMA_SCHED_CTRL);
-   for (ch = 0; ch < 15 * 2; ch += 2) {
+   for (ch = 0; ch < cdd->n_chans; ch += 2) {

reg = SCHED_ENTRY0_CHAN(ch);
reg |= SCHED_ENTRY1_CHAN(ch) | SCHED_ENTRY1_IS_RX;
@@ -850,7 +847,7 @@ static void init_sched(struct cppi41_dd *cdd)
cppi_writel(reg, cdd->sched_mem + DMA_SCHED_WORD(word));
word++;
}
-   reg = 15 * 2 * 2 - 1;
+   reg = cdd->n_chans * 2 - 1;
reg |= DMA_SCHED_CTRL_EN;
cppi_writel(reg, cdd->sched_mem + DMA_SCHED_CTRL);
 }

[...]

MBR, Sergei

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


Re: [PATCH v3 1/3] usb: musb: dma: Add a DMA completion platform callback

2017-01-19 Thread Sergei Shtylyov

Hello!

On 1/19/2017 1:06 PM, Alexandre Bailon wrote:


Currently, the CPPI 4.1 driver is not completely generic and
only work on dsps. This is because of IRQ management.


   Works. DSPS.


Add a callback to dma_controller that could be invoked on DMA completion
to acknodlege the IRQ.


Acknowledge.


Signed-off-by: Alexandre Bailon 

[...]

diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h
index 46357e1..8bea0cd 100644
--- a/drivers/usb/musb/musb_dma.h
+++ b/drivers/usb/musb/musb_dma.h
@@ -181,10 +181,13 @@ dma_channel_status(struct dma_channel *c)
  * @channel_release: call this to release a DMA channel
  * @channel_abort: call this to abort a pending DMA transaction,
  * returning it to FREE (but allocated) state
+ * @platform_dma_callback: invoked on DMA completion, useful to run platform


   It's called just dma_callback below.


+ * code such IRQ acknowledgment.
  *
  * Controllers manage dma channels.
  */
 struct dma_controller {
+   struct musb *musb;


   You forgot to document this above.


struct dma_channel  *(*channel_alloc)(struct dma_controller *,
struct musb_hw_ep *, u8 is_tx);
void(*channel_release)(struct dma_channel *);
@@ -196,6 +199,7 @@ struct dma_controller {
int (*is_compatible)(struct dma_channel *channel,
u16 maxpacket,
void *buf, u32 length);
+   void(*dma_callback)(struct dma_controller *);
 };

 /* called after channel_program(), may indicate a fault */


MBR, Sergei

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


Re: [PATCH] dmaengine: cppi41: Fix oops in cppi41_runtime_resume

2017-01-13 Thread Sergei Shtylyov

Hello!

On 1/13/2017 12:30 AM, Tony Lindgren wrote:


Commit fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support")
together with recent MUSB changes allowed USB and DMA on BeagleBone to idle
when no cable is connected. But looks like few corner case issues still
remain.

Looks like just by repluging USB cable about ten or so times on BeagleBone


   Re-plugging.


when configured in USB peripheral mode we can get warnings and eventually
trigger an oops in cppi41 DMA:

WARNING: CPU: 0 PID: 14 at drivers/dma/cppi41.c:1154 cppi41_runtime_suspend+
x28/0x38 [cppi41]
...

WARNING: CPU: 0 PID: 14 at drivers/dma/cppi41.c:452
push_desc_queue+0x94/0x9c [cppi41]
...

Unable to handle kernel NULL pointer dereference at virtual
address 0104
pgd = c0004000
[0104] *pgd=
Internal error: Oops: 805 [#1] SMP ARM
...
[] (cppi41_runtime_resume [cppi41]) from []
(__rpm_callback+0xc0/0x214)
[] (__rpm_callback) from [] (rpm_callback+0x20/0x80)
[] (rpm_callback) from [] (rpm_resume+0x504/0x78c)
[] (rpm_resume) from [] (pm_runtime_work+0x60/0xa8)
[] (pm_runtime_work) from [] (process_one_work+0x2b4/0x808)

This is because of a race with PM runtime and cppi41_dma_issue_pending()
as reported by Alexandre Bailon <abai...@baylibre.com> in earlier
set of patches. Based on mailing list discussions we however came to the
conclusion that a different fix from Alexandre's fix is needed in order
to guarantee that DMA is really active when we try to use it.

To fix the issue, we need to add a driver specific flag as we otherwise
can have -EINPROGRESS state set by PM runtime and can't rely on


Runtime PM.


pm_runtime_active() to tell us when we can use the DMA.

For reference, this is also documented in Documentation/power/runtime_pm.txt
in the example at the end of the file as pointed out by Grygorii Strashko
<grygorii.stras...@ti.com>.

So let's fix the issue by introducing atomic_t active that gets toggled
in runtime_suspend() and runtime_resume(). And then let's replace the
pm_runtime_active() checks with atomic_read().

Note that we may also get transactions queued while in -EINPROGRESS
state. So we need to check for new elements in cppi41_runtime_resume()
by replacing list_for_each_entry_safe() with the commonly used test for
while (!list_empty(>pending)).

Fixes: fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support")
Cc: Andy Shevchenko <andy.shevche...@gmail.com>
Cc: Bin Liu <b-...@ti.com>
Cc: Grygorii Strashko <grygorii.stras...@ti.com>
Cc: Kevin Hilman <khil...@baylibre.com>
Cc: Patrick Titiano <ptiti...@baylibre.com>
Cc: Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>
Reported-by: Alexandre Bailon <abai...@baylibre.com>
Signed-off-by: Tony Lindgren <t...@atomide.com>
---
 drivers/dma/cppi41.c | 23 ++-
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c

[...]

@@ -320,7 +323,8 @@ static irqreturn_t cppi41_irq(int irq, void *data)
int error;

error = pm_runtime_get(cdd->ddev.dev);
-   if (error < 0)
+   if (((error != -EINPROGRESS) && error < 0) ||


   Hum, the innermost parens are inconsistent: around != but not around <.

[...]

MBR, Sergei

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


Re: [PATCH 09/11] dmaengine: cppi41: Fix a race between PM runtime and channel abort

2017-01-10 Thread Sergei Shtylyov

On 01/09/2017 07:06 PM, Alexandre Bailon wrote:


cppi41_dma_issue_pending() may be called while the device is runtime
suspended. In that case, the descritpor will be push to the pending


  "Descriptor" and "pushed".


list and then be queued to hardware queue.
But if cppi41_stop_chan() is called before the device got time to
resume, then the descriptor will remain in the pending list and be
queued to hardware queue after the teardown.
During the channel stop, check if there is a pendding descriptor


   Pending.


and if so, remove it.

Signed-off-by: Alexandre Bailon 

[...]

MBR, Sergei

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


Re: [PATCH 08/11] dmaengine: cppi41: Implement the glue for da8xx

2017-01-10 Thread Sergei Shtylyov

On 01/09/2017 07:06 PM, Alexandre Bailon wrote:


The da8xx has a cppi41 dma controller.


   It's called CPPI 4.1. :-)


This is add the glue layer required to make it work on da8xx,
as well some changes in driver (e.g to manage clock).

Signed-off-by: Alexandre Bailon 
---
 drivers/dma/cppi41.c | 95 
 1 file changed, 95 insertions(+)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 939398e..4318e53 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c

[...]

@@ -86,10 +87,19 @@

 #define USBSS_IRQ_PD_COMP  (1 <<  2)

+/* USB DA8XX */
+#define DA8XX_INTR_SRC_MASKED  0x38
+#define DA8XX_END_OF_INTR  0x3c
+
+#define DA8XX_QMGR_PENDING_MASK(0xf << 24)
+
+
+


   One empty line is enough.


 /* Packet Descriptor */
 #define PD2_ZERO_LENGTH(1 << 19)

 #define AM335X_CPPI41  0
+#define DA8XX_CPPI41   1

 struct cppi41_channel {
struct dma_chan chan;

[...]

@@ -366,6 +393,26 @@ static irqreturn_t am335x_cppi41_irq(int irq, void *data)
return cppi41_irq(cdd);
 }

+static irqreturn_t da8xx_cppi41_irq(int irq, void *data)
+{
+   struct cppi41_dd *cdd = data;
+   u32 status;
+   u32 usbss_status;
+
+   status = cppi_readl(cdd->qmgr_mem + QMGR_PEND(0));
+   if (status & DA8XX_QMGR_PENDING_MASK)
+   cppi41_irq(cdd);
+   else
+   return IRQ_NONE;


   Seems correct...


+
+   /* Re-assert IRQ if there no usb core interrupts pending */
+   usbss_status = cppi_readl(cdd->usbss_mem + DA8XX_INTR_SRC_MASKED);
+   if (!usbss_status)
+   cppi_writel(0, cdd->usbss_mem + DA8XX_END_OF_INTR);


   I don't understand this...


+
+   return IRQ_HANDLED;
+}
+
 static dma_cookie_t cppi41_tx_submit(struct dma_async_tx_descriptor *tx)
 {
dma_cookie_t cookie;

[...]

MBR, Sergei

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


Re: [PATCH 02/11] dmaengine: cppi41: Split out the interrupt handler

2017-01-10 Thread Sergei Shtylyov

Hello.

On 01/09/2017 07:06 PM, Alexandre Bailon wrote:


The current interrupt handler do some actions specifics to am335x.
These actions should be made by the platform interrupt handler.
Split out the interrupt handler in two:
one for the am335x platform and a generic one.

Signed-off-by: Alexandre Bailon 
---
 drivers/dma/cppi41.c | 24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 25ee71d..42744ed 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -284,18 +284,11 @@ static u32 cppi41_pop_desc(struct cppi41_dd *cdd, 
unsigned queue_num)
return desc;
 }

-static irqreturn_t cppi41_irq(int irq, void *data)
+static irqreturn_t cppi41_irq(struct cppi41_dd *cdd)
 {
-   struct cppi41_dd *cdd = data;
struct cppi41_channel *c;
-   u32 status;
int i;

-   status = cppi_readl(cdd->usbss_mem + USBSS_IRQ_STATUS);
-   if (!(status & USBSS_IRQ_PD_COMP))
-   return IRQ_NONE;
-   cppi_writel(status, cdd->usbss_mem + USBSS_IRQ_STATUS);
-


   I fail to understand why non-CPPI 4.1 regs are used here (and that 
positioning itself as an "abstract" CPPI 4.1 driver).


[...]

@@ -351,6 +344,19 @@ static irqreturn_t cppi41_irq(int irq, void *data)
return IRQ_HANDLED;
 }

+static irqreturn_t am335x_cppi41_irq(int irq, void *data)
+{
+   struct cppi41_dd *cdd = data;
+   u32 status;
+
+   status = cppi_readl(cdd->usbss_mem + USBSS_IRQ_STATUS);
+   if (!(status & USBSS_IRQ_PD_COMP))
+   return IRQ_NONE;
+   cppi_writel(status, cdd->usbss_mem + USBSS_IRQ_STATUS);
+
+   return cppi41_irq(cdd);
+}
+


   IMHO this stuff just needs to move to the MUSB glue.

[...]

MBR, Sergei

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


Re: [PATCH 01/11] dmaengine: cppi41: rename platform variables

2017-01-10 Thread Sergei Shtylyov

Hello!

On 01/09/2017 07:06 PM, Alexandre Bailon wrote:


Currently, only the am335x is supported by the driver.
Though the driver has a glue layer to support different platforms,
some platform variable names are not prefixed with the platform name.
To facilitate the addition of a new platform,
rename some variables owned by the am335x glue.

Currently, only the am335x is supported by the driver.
Though the driver provide a glue layer that should be used to support
another platforms. Rename variable specifics to the am335x glue.


   You are repeating yourself. :-)


Signed-off-by: Alexandre Bailon 

[...]

MBR, Sergei

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


Re: [PATCH 1/3] ARM: dts: da850: Add the cppi41 dma node

2017-01-10 Thread Sergei Shtylyov

On 01/10/2017 07:15 PM, David Lechner wrote:


This adds the device tree node for the cppi41 dma
used by the usb otg controller present in the da850 family of SoC's.

Signed-off-by: Alexandre Bailon 
---
 arch/arm/boot/dts/da850.dtsi | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
index 104155d..d6b406a 100644
--- a/arch/arm/boot/dts/da850.dtsi
+++ b/arch/arm/boot/dts/da850.dtsi
@@ -403,6 +403,22 @@
 phy-names = "usb-phy";
 status = "disabled";
 };
+cppi41dma: dma-controller@201000 {
+compatible = "ti,da8xx-cppi41";
+reg =  <0x20 0x1000


   I don't remember any DA8xx glue regs having to do with the CPPI 4.1...


+0x201000 0x1000
+0x202000 0x1000
+0x204000 0x4000>;
+reg-names = "glue", "controller",
+"scheduler", "queuemgr";
+interrupts = <58>;
+interrupt-names = "glue";
+#dma-cells = <2>;
+#dma-channels = <4>;
+#dma-requests = <256>;
+status = "disabled";


   Why disabled? It doesn't use any external pins...


Why enable it if musb node is not also enabled?


   Well, it's a good point.


[...]


MBR, Sergei

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


Re: [PATCH 13/21] usb: dwc2: Update parameter types

2017-01-10 Thread Sergei Shtylyov

On 01/10/2017 05:24 AM, John Youn wrote:


Update the param types to appropriately sized ints and bools.

Signed-off-by: John Youn 
---
 drivers/usb/dwc2/core.h | 52 -
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 7256b9f7097a..c6f62648ad97 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -452,50 +452,50 @@ enum dwc2_ep0_state {

[...]

-   int phy_utmi_width;
-   int phy_ulpi_ddr;
-   int phy_ulpi_ext_vbus;
+   u8 phy_utmi_width;
+   bool phy_ulpi_ddr;
+   bool phy_ulpi_ext_vbus;


   If it's *bool* now, shouyldn't tghe following be dropped?


 #define DWC2_PHY_ULPI_INTERNAL_VBUS0
 #define DWC2_PHY_ULPI_EXTERNAL_VBUS1

-   int i2c_enable;
-   int ulpi_fs_ls;
-   int host_support_fs_ls_low_power;
-   int host_ls_low_power_phy_clk;
+   bool i2c_enable;
+   bool ulpi_fs_ls;
+   bool host_support_fs_ls_low_power;
+   bool host_ls_low_power_phy_clk;
 #define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_48MHZ 0
 #define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_6MHZ  1


   Same question.

[...]

MBR, Sergei

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


Re: [PATCH] usb: dwc3-exynos fix unspecified suspend clk error handling

2017-01-10 Thread Sergei Shtylyov

Hello!

On 01/10/2017 05:21 AM, Shuah Khan wrote:


Fix dwc3_exynos_probe() to call clk_prepare_enable() only when suspend
clock is specified. Call clk_disable_unprepare() from remove and probe
error path only when susp_clk has been set from remove and probe error
paths.

Signed-off-by: Shuah Khan 
---
 drivers/usb/dwc3/dwc3-exynos.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index e27899b..f97a3d7 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -131,8 +131,8 @@ static int dwc3_exynos_probe(struct platform_device *pdev)
if (IS_ERR(exynos->susp_clk)) {
dev_info(dev, "no suspend clk specified\n");
exynos->susp_clk = NULL;
-   }
-   clk_prepare_enable(exynos->susp_clk);
+   } else
+   clk_prepare_enable(exynos->susp_clk);


   CodingStyle: need {} here as well since another branch has them.

[...]

MBR, Sergei

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


Re: [PATCH 1/4] usb: musb: da8xx: Use the right dma controller

2017-01-09 Thread Sergei Shtylyov

On 01/09/2017 09:43 PM, Tony Lindgren wrote:


da8xx driver is registering and using the cppi dma controller but actually,
the da8xx has a cppi41 dma controller.
Update the driver to register and use the cppi41 dma controller.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index e89708d..74dcc07 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -458,14 +458,14 @@ static inline u8 get_vbus_power(struct device *dev)
 }

 static const struct musb_platform_ops da8xx_ops = {
-   .quirks = MUSB_DMA_CPPI | MUSB_INDEXED_EP,


   Grr, MUSB_DMA_CPPI is certainly wrong! There's no CPPI 3.0 support for
DA8xx. Where have this come from?


+   .quirks = MUSB_DMA_CPPI41 | MUSB_INDEXED_EP,
.init   = da8xx_musb_init,
.exit   = da8xx_musb_exit,

.fifo_mode  = 2,
-#ifdef CONFIG_USB_TI_CPPI_DMA
-   .dma_init   = cppi_dma_controller_create,
-   .dma_exit   = cppi_dma_controller_destroy,


   Likewise, WTF?
   I suggest that you fix this crap in a separate commit, to be backported
to -stable if needed.


Probably came from my DMA patch 7f6283ed6fe8 ("usb: musb: Set up function


   Too bad I missed it back then. Then certainly this should be fixed in a 
separate patch. The first hunk was not a part of that commit, tho...



pointers for DMA"). At that point I thought da8xxx.c and davinci.c are just
separate attempts of the same driver.. Sorry the number of musb glue layers
is just too confusing.


   :-)


Tony


MBR, Sergei

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


Re: [PATCH 11/11] dmaengine: cppi41: Fix teardown warnings

2017-01-09 Thread Sergei Shtylyov

On 01/09/2017 07:06 PM, Alexandre Bailon wrote:


During the teardown of a RX channel, because there is only one
completion queue available for RX channel, descriptor of another
channel may be popped which will cause 2 warnings:
- the first one because we popped a wrong descriptor
  (neither the channel's descriptor, neither the teardown descriptor).


   Neither ... nor.


- the second one happen during the teardown of another channel,
  because we can't find the channel descriptor
  (that is, the one that caused the first warning).
Use the teardown queue as completion queue during the teardown.


   Hm, what's a teardown queue? I don't remember this documented...
memory fade is always possible tho... :-)


Note that fix doesn't fix all the teardown warnings:
I still get some when I run some corner case.

Signed-off-by: Alexandre Bailon 

[...]

MBR, Sergei

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


Re: [PATCH 4/4] usb: musb: musb_cppi41: Workaround dma stall issue during teardown

2017-01-09 Thread Sergei Shtylyov

Hello!

On 01/09/2017 07:39 PM, Alexandre Bailon wrote:


The dma may hung up if a teardown is initiated while an endpoint is still


   The DMA may hang up...


active (Advisory 2.3.27 of da8xx errata).
To workaround this issue, add a delay before to initiate the teardown.

Signed-off-by: Alexandre Bailon 

[...]

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index 1636385..8fdbc17 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -547,6 +547,10 @@ static int cppi41_dma_channel_abort(struct dma_channel 
*channel)
}
}

+   /* DA8xx Advisory 2.3.27: wait 250 ms before to start the teardown */
+   if (musb->io.quirks & MUSB_DA8XX)
+   mdelay(250);


   This is a horrible workaround, not even msleep()...

[...]

MBR, Sergei

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


Re: [PATCH 07/11] dt/bindings: da8xx-usb: Add binding for the cppi41 dma controller

2017-01-09 Thread Sergei Shtylyov

Hello!

On 01/09/2017 07:06 PM, Alexandre Bailon wrote:


DT binding for the TI DA8xx/OMAP-L1x/AM17xx/AM18xx cppi41 dma controller.


   It's called CPPI 4.1, not cppi41.
   Let me introduce myself: I was the author of the 1st CPPI 4.1 drivers 
(never merged).



Signed-off-by: Alexandre Bailon 
---
 .../devicetree/bindings/usb/da8xx-usb.txt  | 39 ++
 1 file changed, 39 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/da8xx-usb.txt 
b/Documentation/devicetree/bindings/usb/da8xx-usb.txt
index ccb844a..2a4d737 100644
--- a/Documentation/devicetree/bindings/usb/da8xx-usb.txt
+++ b/Documentation/devicetree/bindings/usb/da8xx-usb.txt
@@ -18,10 +18,26 @@ Required properties:

[...]

 Optional properties:
 
  - vbus-supply: Phandle to a regulator providing the USB bus power.

+DMA
+~~~
+- compatible: ti,da8xx-cppi41
+- reg: offset and length of the following register spaces: USBSS, USB


   I don't understand what you mean by USBSS and how it's related to CPPI 4.1.


+  CPPI DMA Controller, USB CPPI DMA Scheduler, USB Queue Manager


   I'd drop "USB" everywhere, the DMAC scheduler and queue manager are not a 
part of any USB logic.



+- reg-names: glue, controller, scheduler, queuemgr


   Quoted, maybe?


+- #dma-cells: should be set to 2. The first number represents the
+  endpoint number (0 … 3 for endpoints 1 … 4).


   Not sure why you need EPs here. Is that required by the DMA driver?
The DMA controller operates with channels...

[...]

MBR, Sergei

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


Re: [PATCH 1/4] usb: musb: da8xx: Use the right dma controller

2017-01-09 Thread Sergei Shtylyov

Hello!

On 01/09/2017 07:38 PM, Alexandre Bailon wrote:


da8xx driver is registering and using the cppi dma controller but actually,
the da8xx has a cppi41 dma controller.
Update the driver to register and use the cppi41 dma controller.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index e89708d..74dcc07 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -458,14 +458,14 @@ static inline u8 get_vbus_power(struct device *dev)
 }

 static const struct musb_platform_ops da8xx_ops = {
-   .quirks = MUSB_DMA_CPPI | MUSB_INDEXED_EP,


   Grr, MUSB_DMA_CPPI is certainly wrong! There's no CPPI 3.0 support for 
DA8xx. Where have this come from?



+   .quirks = MUSB_DMA_CPPI41 | MUSB_INDEXED_EP,
.init   = da8xx_musb_init,
.exit   = da8xx_musb_exit,

.fifo_mode  = 2,
-#ifdef CONFIG_USB_TI_CPPI_DMA
-   .dma_init   = cppi_dma_controller_create,
-   .dma_exit   = cppi_dma_controller_destroy,


   Likewise, WTF?
   I suggest that you fix this crap in a separate commit, to be backported to 
-stable if needed.


[...]

MBR, Sergei

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


  1   2   3   4   5   6   7   8   9   10   >