Re: [PATCH] xhci: tegra: mbox registers address in"soc" data

2019-09-02 Thread Thierry Reding
On Mon, Sep 02, 2019 at 11:54:45AM +0800, JC Kuo wrote:
> Tegra194 XUSB host controller has rearranged mailbox registers. This
> commit makes mailbox registers address a part of "soc" data so that
> xhci-tegra driver can be used for Tegra194.
> 
> Signed-off-by: JC Kuo 
> ---
>  drivers/usb/host/xhci-tegra.c | 51 ++-
>  1 file changed, 39 insertions(+), 12 deletions(-)

I'd perhaps reformulate the subject a little to be something like:

xhci: tegra: Parameterize mailbox register addresses

Two other minor comments below.

> diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
> index dafc65911fc0..b92a03bbbd2c 100644
> --- a/drivers/usb/host/xhci-tegra.c
> +++ b/drivers/usb/host/xhci-tegra.c
> @@ -146,6 +146,13 @@ struct tegra_xusb_phy_type {
>   unsigned int num;
>  };
>  
> +struct tega_xusb_mbox_regs {
> + u32 cmd;
> + u32 data_in;
> + u32 data_out;
> + u32 owner;
> +};

Perhaps make these unsigned int (or unsigned long). Making these
explicitly sized variables suggests (at least to me) that they are
register values, whereas they really are offsets. So I prefer to use
"unsized" types to distinguish between register offsets and values.

> +
>  struct tegra_xusb_soc {
>   const char *firmware;
>   const char * const *supply_names;
> @@ -160,6 +167,8 @@ struct tegra_xusb_soc {
>   } usb2, ulpi, hsic, usb3;
>   } ports;
>  
> + struct tega_xusb_mbox_regs mbox;
> +
>   bool scale_ss_clock;
>   bool has_ipfs;
>  };
> @@ -395,15 +404,15 @@ static int tegra_xusb_mbox_send(struct tegra_xusb 
> *tegra,
>* ACK/NAK messages.
>*/
>   if (!(msg->cmd == MBOX_CMD_ACK || msg->cmd == MBOX_CMD_NAK)) {
> - value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_OWNER);
> + value = fpci_readl(tegra, tegra->soc->mbox.owner);
>   if (value != MBOX_OWNER_NONE) {
>   dev_err(tegra->dev, "mailbox is busy\n");
>   return -EBUSY;
>   }
>  
> - fpci_writel(tegra, MBOX_OWNER_SW, XUSB_CFG_ARU_MBOX_OWNER);
> + fpci_writel(tegra, MBOX_OWNER_SW, tegra->soc->mbox.owner);
>  
> - value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_OWNER);
> + value = fpci_readl(tegra, tegra->soc->mbox.owner);
>   if (value != MBOX_OWNER_SW) {
>   dev_err(tegra->dev, "failed to acquire mailbox\n");
>   return -EBUSY;
> @@ -413,17 +422,17 @@ static int tegra_xusb_mbox_send(struct tegra_xusb 
> *tegra,
>   }
>  
>   value = tegra_xusb_mbox_pack(msg);
> - fpci_writel(tegra, value, XUSB_CFG_ARU_MBOX_DATA_IN);
> + fpci_writel(tegra, value, tegra->soc->mbox.data_in);
>  
> - value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_CMD);
> + value = fpci_readl(tegra, tegra->soc->mbox.cmd);
>   value |= MBOX_INT_EN | MBOX_DEST_FALC;
> - fpci_writel(tegra, value, XUSB_CFG_ARU_MBOX_CMD);
> + fpci_writel(tegra, value, tegra->soc->mbox.cmd);
>  
>   if (wait_for_idle) {
>   unsigned long timeout = jiffies + msecs_to_jiffies(250);
>  
>   while (time_before(jiffies, timeout)) {
> - value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_OWNER);
> + value = fpci_readl(tegra, tegra->soc->mbox.owner);
>   if (value == MBOX_OWNER_NONE)
>   break;
>  
> @@ -431,7 +440,7 @@ static int tegra_xusb_mbox_send(struct tegra_xusb *tegra,
>   }
>  
>   if (time_after(jiffies, timeout))
> - value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_OWNER);
> + value = fpci_readl(tegra, tegra->soc->mbox.owner);
>  
>   if (value != MBOX_OWNER_NONE)
>   return -ETIMEDOUT;
> @@ -598,16 +607,16 @@ static irqreturn_t tegra_xusb_mbox_thread(int irq, void 
> *data)
>  
>   mutex_lock(&tegra->lock);
>  
> - value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_DATA_OUT);
> + value = fpci_readl(tegra, tegra->soc->mbox.data_out);
>   tegra_xusb_mbox_unpack(&msg, value);
>  
> - value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_CMD);
> + value = fpci_readl(tegra, tegra->soc->mbox.cmd);
>   value &= ~MBOX_DEST_SMI;
> - fpci_writel(tegra, value, XUSB_CFG_ARU_MBOX_CMD);
> + fpci_writel(tegra, value, tegra->soc->mbox.cmd);
>  
>   /* clear mailbox owner if no ACK/NAK is required */
>   if (!tegra_xusb_mbox_cmd_requires_ack(msg.cmd))
> - fpci_writel(tegra, MBOX_OWNER_NONE, XUSB_CFG_ARU_MBOX_OWNER);
> + fpci_writel(tegra, MBOX_OWNER_NONE, tegra->soc->mbox.owner);
>  
>   tegra_xusb_mbox_handle(tegra, &msg);
>  
> @@ -1365,6 +1374,12 @@ static const struct tegra_xusb_soc tegra124_soc = {
>   },
>   .scale_ss_clock = true,
>   .has_ipfs = true,
> + .mbox = {
> + .cmd = XUSB_CFG_ARU_MBOX_CMD,
> + .data_in

Re: [PATCH] xhci: tegra: mbox registers address in"soc" data

2019-09-02 Thread JC Kuo
Thanks for review. I will modify accordingly and submit again.

On 9/2/19 3:57 PM, Thierry Reding wrote:
> On Mon, Sep 02, 2019 at 11:54:45AM +0800, JC Kuo wrote:
>> Tegra194 XUSB host controller has rearranged mailbox registers. This
>> commit makes mailbox registers address a part of "soc" data so that
>> xhci-tegra driver can be used for Tegra194.
>>
>> Signed-off-by: JC Kuo 
>> ---
>>  drivers/usb/host/xhci-tegra.c | 51 ++-
>>  1 file changed, 39 insertions(+), 12 deletions(-)
> 
> I'd perhaps reformulate the subject a little to be something like:
> 
>   xhci: tegra: Parameterize mailbox register addresses
> 
> Two other minor comments below.
> 
>> diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
>> index dafc65911fc0..b92a03bbbd2c 100644
>> --- a/drivers/usb/host/xhci-tegra.c
>> +++ b/drivers/usb/host/xhci-tegra.c
>> @@ -146,6 +146,13 @@ struct tegra_xusb_phy_type {
>>  unsigned int num;
>>  };
>>  
>> +struct tega_xusb_mbox_regs {
>> +u32 cmd;
>> +u32 data_in;
>> +u32 data_out;
>> +u32 owner;
>> +};
> 
> Perhaps make these unsigned int (or unsigned long). Making these
> explicitly sized variables suggests (at least to me) that they are
> register values, whereas they really are offsets. So I prefer to use
> "unsized" types to distinguish between register offsets and values.
> 
>> +
>>  struct tegra_xusb_soc {
>>  const char *firmware;
>>  const char * const *supply_names;
>> @@ -160,6 +167,8 @@ struct tegra_xusb_soc {
>>  } usb2, ulpi, hsic, usb3;
>>  } ports;
>>  
>> +struct tega_xusb_mbox_regs mbox;
>> +
>>  bool scale_ss_clock;
>>  bool has_ipfs;
>>  };
>> @@ -395,15 +404,15 @@ static int tegra_xusb_mbox_send(struct tegra_xusb 
>> *tegra,
>>   * ACK/NAK messages.
>>   */
>>  if (!(msg->cmd == MBOX_CMD_ACK || msg->cmd == MBOX_CMD_NAK)) {
>> -value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_OWNER);
>> +value = fpci_readl(tegra, tegra->soc->mbox.owner);
>>  if (value != MBOX_OWNER_NONE) {
>>  dev_err(tegra->dev, "mailbox is busy\n");
>>  return -EBUSY;
>>  }
>>  
>> -fpci_writel(tegra, MBOX_OWNER_SW, XUSB_CFG_ARU_MBOX_OWNER);
>> +fpci_writel(tegra, MBOX_OWNER_SW, tegra->soc->mbox.owner);
>>  
>> -value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_OWNER);
>> +value = fpci_readl(tegra, tegra->soc->mbox.owner);
>>  if (value != MBOX_OWNER_SW) {
>>  dev_err(tegra->dev, "failed to acquire mailbox\n");
>>  return -EBUSY;
>> @@ -413,17 +422,17 @@ static int tegra_xusb_mbox_send(struct tegra_xusb 
>> *tegra,
>>  }
>>  
>>  value = tegra_xusb_mbox_pack(msg);
>> -fpci_writel(tegra, value, XUSB_CFG_ARU_MBOX_DATA_IN);
>> +fpci_writel(tegra, value, tegra->soc->mbox.data_in);
>>  
>> -value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_CMD);
>> +value = fpci_readl(tegra, tegra->soc->mbox.cmd);
>>  value |= MBOX_INT_EN | MBOX_DEST_FALC;
>> -fpci_writel(tegra, value, XUSB_CFG_ARU_MBOX_CMD);
>> +fpci_writel(tegra, value, tegra->soc->mbox.cmd);
>>  
>>  if (wait_for_idle) {
>>  unsigned long timeout = jiffies + msecs_to_jiffies(250);
>>  
>>  while (time_before(jiffies, timeout)) {
>> -value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_OWNER);
>> +value = fpci_readl(tegra, tegra->soc->mbox.owner);
>>  if (value == MBOX_OWNER_NONE)
>>  break;
>>  
>> @@ -431,7 +440,7 @@ static int tegra_xusb_mbox_send(struct tegra_xusb *tegra,
>>  }
>>  
>>  if (time_after(jiffies, timeout))
>> -value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_OWNER);
>> +value = fpci_readl(tegra, tegra->soc->mbox.owner);
>>  
>>  if (value != MBOX_OWNER_NONE)
>>  return -ETIMEDOUT;
>> @@ -598,16 +607,16 @@ static irqreturn_t tegra_xusb_mbox_thread(int irq, 
>> void *data)
>>  
>>  mutex_lock(&tegra->lock);
>>  
>> -value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_DATA_OUT);
>> +value = fpci_readl(tegra, tegra->soc->mbox.data_out);
>>  tegra_xusb_mbox_unpack(&msg, value);
>>  
>> -value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_CMD);
>> +value = fpci_readl(tegra, tegra->soc->mbox.cmd);
>>  value &= ~MBOX_DEST_SMI;
>> -fpci_writel(tegra, value, XUSB_CFG_ARU_MBOX_CMD);
>> +fpci_writel(tegra, value, tegra->soc->mbox.cmd);
>>  
>>  /* clear mailbox owner if no ACK/NAK is required */
>>  if (!tegra_xusb_mbox_cmd_requires_ack(msg.cmd))
>> -fpci_writel(tegra, MBOX_OWNER_NONE, XUSB_CFG_ARU_MBOX_OWNER);
>> +fpci_writel(tegra, MBOX_OWNER_NONE, tegra->soc->mbox.owner);
>>  
>>  tegra_xusb_mbox_handle(tegra, &msg);
>>  
>> @@ -1365,6 +1374,12 @@ static const struct tegra_xusb_so

[PATCH] xhci: tegra: Parameterize mailbox register addresses

2019-09-02 Thread JC Kuo
Tegra194 XUSB host controller has rearranged mailbox registers. This
commit makes mailbox registers address a part of "soc" data so that
xhci-tegra driver can be used for Tegra194.

Signed-off-by: JC Kuo 
---
 drivers/usb/host/xhci-tegra.c | 58 +--
 1 file changed, 42 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
index dafc65911fc0..247b08ca49ee 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -42,19 +42,18 @@
 #define XUSB_CFG_CSB_BASE_ADDR 0x800
 
 /* FPCI mailbox registers */
-#define XUSB_CFG_ARU_MBOX_CMD  0x0e4
+/* XUSB_CFG_ARU_MBOX_CMD */
 #define  MBOX_DEST_FALCBIT(27)
 #define  MBOX_DEST_PME BIT(28)
 #define  MBOX_DEST_SMI BIT(29)
 #define  MBOX_DEST_XHCIBIT(30)
 #define  MBOX_INT_EN   BIT(31)
-#define XUSB_CFG_ARU_MBOX_DATA_IN  0x0e8
+/* XUSB_CFG_ARU_MBOX_DATA_IN and XUSB_CFG_ARU_MBOX_DATA_OUT */
 #define  CMD_DATA_SHIFT0
 #define  CMD_DATA_MASK 0xff
 #define  CMD_TYPE_SHIFT24
 #define  CMD_TYPE_MASK 0xff
-#define XUSB_CFG_ARU_MBOX_DATA_OUT 0x0ec
-#define XUSB_CFG_ARU_MBOX_OWNER0x0f0
+/* XUSB_CFG_ARU_MBOX_OWNER */
 #define  MBOX_OWNER_NONE   0
 #define  MBOX_OWNER_FW 1
 #define  MBOX_OWNER_SW 2
@@ -146,6 +145,13 @@ struct tegra_xusb_phy_type {
unsigned int num;
 };
 
+struct tega_xusb_mbox_regs {
+   unsigned int cmd;
+   unsigned int data_in;
+   unsigned int data_out;
+   unsigned int owner;
+};
+
 struct tegra_xusb_soc {
const char *firmware;
const char * const *supply_names;
@@ -160,6 +166,8 @@ struct tegra_xusb_soc {
} usb2, ulpi, hsic, usb3;
} ports;
 
+   struct tega_xusb_mbox_regs mbox;
+
bool scale_ss_clock;
bool has_ipfs;
 };
@@ -395,15 +403,15 @@ static int tegra_xusb_mbox_send(struct tegra_xusb *tegra,
 * ACK/NAK messages.
 */
if (!(msg->cmd == MBOX_CMD_ACK || msg->cmd == MBOX_CMD_NAK)) {
-   value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_OWNER);
+   value = fpci_readl(tegra, tegra->soc->mbox.owner);
if (value != MBOX_OWNER_NONE) {
dev_err(tegra->dev, "mailbox is busy\n");
return -EBUSY;
}
 
-   fpci_writel(tegra, MBOX_OWNER_SW, XUSB_CFG_ARU_MBOX_OWNER);
+   fpci_writel(tegra, MBOX_OWNER_SW, tegra->soc->mbox.owner);
 
-   value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_OWNER);
+   value = fpci_readl(tegra, tegra->soc->mbox.owner);
if (value != MBOX_OWNER_SW) {
dev_err(tegra->dev, "failed to acquire mailbox\n");
return -EBUSY;
@@ -413,17 +421,17 @@ static int tegra_xusb_mbox_send(struct tegra_xusb *tegra,
}
 
value = tegra_xusb_mbox_pack(msg);
-   fpci_writel(tegra, value, XUSB_CFG_ARU_MBOX_DATA_IN);
+   fpci_writel(tegra, value, tegra->soc->mbox.data_in);
 
-   value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_CMD);
+   value = fpci_readl(tegra, tegra->soc->mbox.cmd);
value |= MBOX_INT_EN | MBOX_DEST_FALC;
-   fpci_writel(tegra, value, XUSB_CFG_ARU_MBOX_CMD);
+   fpci_writel(tegra, value, tegra->soc->mbox.cmd);
 
if (wait_for_idle) {
unsigned long timeout = jiffies + msecs_to_jiffies(250);
 
while (time_before(jiffies, timeout)) {
-   value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_OWNER);
+   value = fpci_readl(tegra, tegra->soc->mbox.owner);
if (value == MBOX_OWNER_NONE)
break;
 
@@ -431,7 +439,7 @@ static int tegra_xusb_mbox_send(struct tegra_xusb *tegra,
}
 
if (time_after(jiffies, timeout))
-   value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_OWNER);
+   value = fpci_readl(tegra, tegra->soc->mbox.owner);
 
if (value != MBOX_OWNER_NONE)
return -ETIMEDOUT;
@@ -598,16 +606,16 @@ static irqreturn_t tegra_xusb_mbox_thread(int irq, void 
*data)
 
mutex_lock(&tegra->lock);
 
-   value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_DATA_OUT);
+   value = fpci_readl(tegra, tegra->soc->mbox.data_out);
tegra_xusb_mbox_unpack(&msg, value);
 
-   value = fpci_readl(tegra, XUSB_CFG_ARU_MBOX_CMD);
+   value = fpci_readl(tegra, tegra->soc->mbox.cmd);
value &= ~MBOX_DEST_SMI;
-   fpci_writel(tegra, value, XUSB_CFG_ARU_MBOX_CMD);
+   fpci_writel(tegra, value

Re: [PATCH 0/4] musb host improvments mostly for omap2430 glue

2019-09-02 Thread Pavel Machek
Hi!

> So I ended up cleaning up omap2430 glue layer a bit for host mode with the
> various reproducable errors I was seeing docking droid4 to a lapdock. There
> are a few fixes, and then we end up removing all the devctl register tinkering
> for omap2430 glue layer.

I should have your recent patches up-to [PATCH] power: supply:
cpcap-charger: Enable vbus boost voltage applied to linux-next, -0830.

So... to get usb host to work even with stock kernel, I need a hub and
external power... and "right" cable between phone and hub.

When I plugged/unplugged it several times, I got

### usb unplug:
musb-hdrc.0.auto: musb_set_peripheral: already in peripheral mode: 80
musb-hdrc.0.auto: musb_set_peripheral: already in peripheral mode: 80
ub0: stop stats: rx/tx 0/0, errs 0/0
l3_init_cm:clk:0040:0: failed to disable
l3_init_cm:clk:00c0:0: failed to disable
### usb plug produces nothing
### usb unplug:
musb-hdrc.0.auto: musb_set_peripheral: already in peripheral mode: 80
musb-hdrc.0.auto: musb_set_peripheral: already in peripheral mode: 80

Hmm. I did it two more times, and now machine rebooted, and USB was
powered from the phone for a while (3.6V).

And I reproduced the crash on the next boot.

Is there anything I may be missing in .config?

Best regards,
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH 1/3] net: cdc_ncm: add get/set ethernet address functions

2019-09-02 Thread Oliver Neukum
Am Freitag, den 30.08.2019, 19:37 + schrieb
charles.h...@dellteam.com:
> This patch adds support for pushing a MAC address out to USB based
> ethernet controllers driven by cdc_ncm.  With this change, ifconfig can
> now set the device's MAC address.  For example, the Dell Universal Dock
> D6000 is driven by cdc_ncm.  The D6000 can now have its MAC address set
> by ifconfig, as it can be done in Windows.  This was tested with a D6000
> using ifconfig on an x86 based chromebook, where iproute2 is not
> available.

> +/* Provide method to push MAC address to the USB device's ethernet 
> controller.
> + */
> +int cdc_ncm_set_mac_addr(struct net_device *net, void *p)
> +{
> + struct usbnet *dev = netdev_priv(net);
> +
> + /* Try to push the MAC address out to the device.  Ignore any errors,
> +  * to be compatible with prior versions of this source.
> +  */
> + cdc_ncm_set_ethernet_address(dev, (struct sockaddr *)p);

You are throwing away error reports.

Regards
Oliver



Re: [PATCH 0/4] musb host improvments mostly for omap2430 glue

2019-09-02 Thread Pavel Machek
On Mon 2019-09-02 11:23:44, Pavel Machek wrote:
> Hi!
> 
> > So I ended up cleaning up omap2430 glue layer a bit for host mode with the
> > various reproducable errors I was seeing docking droid4 to a lapdock. There
> > are a few fixes, and then we end up removing all the devctl register 
> > tinkering
> > for omap2430 glue layer.
> 
> I should have your recent patches up-to [PATCH] power: supply:
> cpcap-charger: Enable vbus boost voltage applied to linux-next, -0830.
> 
> So... to get usb host to work even with stock kernel, I need a hub and
> external power... and "right" cable between phone and hub.
> 
> When I plugged/unplugged it several times, I got
> 
> ### usb unplug:
> musb-hdrc.0.auto: musb_set_peripheral: already in peripheral mode: 80
> musb-hdrc.0.auto: musb_set_peripheral: already in peripheral mode: 80
> ub0: stop stats: rx/tx 0/0, errs 0/0
> l3_init_cm:clk:0040:0: failed to disable
> l3_init_cm:clk:00c0:0: failed to disable
> ### usb plug produces nothing
> ### usb unplug:
> musb-hdrc.0.auto: musb_set_peripheral: already in peripheral mode: 80
> musb-hdrc.0.auto: musb_set_peripheral: already in peripheral mode: 80
> 
> Hmm. I did it two more times, and now machine rebooted, and USB was
> powered from the phone for a while (3.6V).
> 
> And I reproduced the crash on the next boot.
> 
> Is there anything I may be missing in .config?

Hmm. I guess CONFIG_USB_MUSB_DUAL_ROLE=y might be useful.

And now... if I unplug/replug the usb after the boot, USB hub and
mouse are recognized. Good!

Less than minute later:

mmusb-hdrc.0.auto: Babble
USB disconnect

I unplug, replug usb (not at the phone, between hub and dongle, and
green LED indincating charging starts blinking rapidly.

cpcap-core spi0.0: EOT timed out.

I try plug/replug, and now green led is on.

I unplug replug at the phone, and get bunch more of messages:

musm _set_peripheral: already in peripheral mode: 99
musm _set_peripheral: already in peripheral mode: 81
musm _set_peripheral: already in peripheral mode: 81

musb_set_host: could not set host: 99
musb_set_host: could not set host: 99
musb_set_host: could not set host: 99
musb_set_host: could not set host: 99
musb_set_host: could not set host: 99
musb_set_host: could not set host: 99
musb_set_host: could not set host: 99
musb_set_host: could not set host: 99

Unplug/replug at host, and again, hub+mouse is detected.

I unplug power connected to one of USB hub's ports... and find out
that phone was _not_ powering it.

Ok... so something somehow works sometimes :-).

Pavel
-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany


signature.asc
Description: Digital signature


Re: [PATCH 3/3] net: cdc_ncm: Add ACPI MAC address pass through functionality

2019-09-02 Thread Oliver Neukum
Am Freitag, den 30.08.2019, 19:38 + schrieb
charles.h...@dellteam.com:
> This change adds support to cdc_ncm for ACPI MAC address pass through
> functionality that also exists in the Realtek r8152 driver.  This is in
> support of Dell's Universal Dock D6000, to give it the same feature
> capability as is currently available in Windows and advertized on Dell's
> product web site.
> 
> Signed-off-by: Charles Hyde 
> Cc: Mario Limonciello 
> Cc: Oliver Neukum 
> Cc: Rafael J. Wysocki 
> Cc: Len Brown 
> Cc: linux-usb@vger.kernel.org
> Cc: linux-a...@vger.kernel.org
> ---
>  drivers/net/usb/cdc_ncm.c | 67 +--
>  1 file changed, 64 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
> index 85093579612f..11a04dc2298d 100644
> --- a/drivers/net/usb/cdc_ncm.c
> +++ b/drivers/net/usb/cdc_ncm.c
> @@ -52,6 +52,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #if IS_ENABLED(CONFIG_USB_NET_CDC_MBIM)
>  static bool prefer_mbim = true;
> @@ -984,11 +985,30 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct 
> usb_interface *intf, u8 data_
>   usb_set_intfdata(ctx->control, dev);
>  
>   if (ctx->ether_desc) {
> - temp = usbnet_get_ethernet_addr(dev, 
> ctx->ether_desc->iMACAddress);
> + struct sockaddr sa;
> +
> + temp = cdc_ncm_get_ethernet_address(dev, ctx);
>   if (temp) {
>   dev_dbg(&intf->dev, "failed to get mac address\n");
>   goto error2;
>   }
> +
> + /* Check for a Dell Universal Dock D6000 before checking if
> +  * ACPI supports MAC address pass through.
> +  */
> + if (!strstr(dev->udev->product, "D6000"))
> + goto skip_acpi_mapt_in_bind;
> +
> + if (get_acpi_mac_passthru(sa.sa_data) != 0)
> + goto skip_acpi_mapt_in_bind;
> +
> + if (memcmp(dev->net->dev_addr, sa.sa_data, ETH_ALEN) == 0)
> + goto skip_acpi_mapt_in_bind;
> +
> + if (cdc_ncm_set_ethernet_address(dev, &sa) == 0)
> + memcpy(dev->net->dev_addr, sa.sa_data, ETH_ALEN);
> +
> +skip_acpi_mapt_in_bind:
>   dev_info(&intf->dev, "MAC-Address: %pM\n", dev->net->dev_addr);
>   }
>  
> @@ -1716,6 +1736,47 @@ static void cdc_ncm_status(struct usbnet *dev, struct 
> urb *urb)
>   }
>  }
>  
> +static int cdc_ncm_resume(struct usb_interface *intf)
> +{
> + struct usbnet *dev = usb_get_intfdata(intf);
> + struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
> + int ret;
> +
> + ret = usbnet_resume(intf);
> + if (ret != 0)
> + goto error2;
> +
> + if (ctx->ether_desc) {
> + struct sockaddr sa;
> +
> + if (cdc_ncm_get_ethernet_address(dev, ctx)) {
> + dev_dbg(&intf->dev, "failed to get mac address\n");
> + goto error2;
> + }
> +
> + /* Check for a Dell Universal Dock D6000 before checking if
> +  * ACPI supports MAC address pass through.
> +  */
> + if (!strstr(dev->udev->product, "D6000"))
> + goto skip_acpi_mapt_in_resume;

This is too ugly. Use a flag for the need to restore the MAC.
And have you consider the case somebody triggers a reset through
usbfs? It looks to me like you should encapsulate the restoration
of the MAC and also use it in post_reset()

Regards
Oliver



Re: Lacie Rugged USB3-FW does not work with UAS

2019-09-02 Thread Oliver Neukum
Am Donnerstag, den 29.08.2019, 20:33 +0200 schrieb Julian Sikorski:

Hi,

this is a relief. If necessary we can blacklist the new device.
Howevera, as that costs performance, I would appriciate if
you take first try out an alternative approach.

> [  362.230833] usb 2-4: New USB device found, idVendor=059f, 
> idProduct=1061, bcdDevice= 0.01
> [  362.230837] usb 2-4: New USB device strings: Mfr=2, Product=3, 
> SerialNumber=1
> [  362.230839] usb 2-4: Product: Rugged USB3-FW
> [  362.230841] usb 2-4: Manufacturer: LaCie
> [  362.230842] usb 2-4: SerialNumber: 157f928920fa
> [  362.270100] scsi host12: uas
> [  362.270720] scsi 12:0:0:0: Direct-Access LaCieRugged FW USB3 
>   051E PQ: 0 ANSI: 6
> [  362.271472] sd 12:0:0:0: Attached scsi generic sg1 type 0
> [  362.280344] sd 12:0:0:0: [sdb] 1953525168 512-byte logical blocks: 
> (1.00 TB/932 GiB)
> [  362.280422] sd 12:0:0:0: [sdb] Write Protect is off
> [  362.280423] sd 12:0:0:0: [sdb] Mode Sense: 43 00 00 00
> [  362.280544] sd 12:0:0:0: [sdb] Write cache: enabled, read cache: 
> enabled, doesn't support DPO or FUA

This means that at least the earliest commandos did get through.

> [  392.672691] sd 12:0:0:0: tag#29 uas_eh_abort_handler 0 uas-tag 1 
> inflight: IN
> [  392.672697] sd 12:0:0:0: tag#29 CDB: Report supported operation codes 
> a3 0c 01 12 00 00 00 00 02 00 00 00
> [  392.678304] scsi host12: uas_eh_device_reset_handler start
> [  392.800099] usb 2-4: reset SuperSpeed Gen 1 USB device number 3 using 
> xhci_hcd
> [  392.848154] scsi host12: uas_eh_device_reset_handler success
> [  422.875443] scsi host12: uas_eh_device_reset_handler start
> [  422.875650] sd 12:0:0:0: tag#16 uas_zap_pending 0 uas-tag 1 inflight:
> [  422.875654] sd 12:0:0:0: tag#16 CDB: Report supported operation codes 
> a3 0c 01 12 00 00 00 00 02 00 00 00
> [  422.997556] usb 2-4: reset SuperSpeed Gen 1 USB device number 3 using 
> xhci_hcd
> [  423.046525] scsi host12: uas_eh_device_reset_handler success
> [  431.853505] usb 2-4: USB disconnect, device number 3
> [  431.903459] sd 12:0:0:0: [sdb] Optimal transfer size 33553920 bytes
> [  432.064456] sd 12:0:0:0: [sdb] Read Capacity(16) failed: Result: 
> hostbyte=DID_ERROR driverbyte=DRIVER_OK

Read Capacity(16) failed

> [  432.064459] sd 12:0:0:0: [sdb] Sense not available.
> [  432.184595] sd 12:0:0:0: [sdb] Read Capacity(10) failed: Result: 
> hostbyte=DID_ERROR driverbyte=DRIVER_OK

Read Capacity(10) failed

There is a chance that this device can deal only with Read Capacity(10)
and crashes on Read Capacity(16). One difference between Usb-storage
and UAS is the order in which the 10 and 16 versions are tried.
The attached patches introduce a quirk to reverse the order
for this particular device under UAS. Could you try them?

Regards
Oliver
From 883355951a23d3c4b3c14ca0540972739ae6ffb2 Mon Sep 17 00:00:00 2001
From: Oliver Neukum 
Date: Mon, 2 Sep 2019 13:28:39 +0200
Subject: [PATCH 1/2] uas: honor flag to avoid CAPACITY16

Copy the support over from usb-storage

Signed-off-by: Oliver Neukum 
---
 drivers/usb/storage/uas.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 68b1cb0f84e5..a8bd5ff5a4b9 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -854,6 +854,10 @@ static int uas_slave_configure(struct scsi_device *sdev)
 		sdev->wce_default_on = 1;
 	}
 
+	/* Some devices cannot handle READ_CAPACITY_16 */
+	if (devinfo->flags & US_FL_NO_READ_CAPACITY_16)
+		sdev->no_read_capacity_16 = 1;
+
 	/*
 	 * Some disks return the total number of blocks in response
 	 * to READ CAPACITY rather than the highest block number.
-- 
2.16.4

From 115389ff678cae7cb636ac7e520f06e5182cd353 Mon Sep 17 00:00:00 2001
From: Oliver Neukum 
Date: Mon, 2 Sep 2019 13:30:00 +0200
Subject: [PATCH 2/2] uas: quirk for LaCie Rugged USB 3

No. CAPACITY16 for these devices.

Signed-off-by: Oliver Neukum 
---
 drivers/usb/storage/unusual_devs.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index ea0d27a94afe..643bba41291e 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -806,6 +806,12 @@ UNUSUAL_DEV(  0x059f, 0x0651, 0x, 0x,
 		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
 		US_FL_NO_WP_DETECT ),
 
+UNUSUAL_DEV(  0x059f, 0x103e, 0x0002, 0x0002,
+		"LaCie",
+		"Rugged USB 3",
+		USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+		US_FL_NO_READ_CAPACITY_16 ),
+
 /*
  * Submitted by Joel Bourquard 
  * Some versions of this device need the SubClass and Protocol overrides
-- 
2.16.4



Re: [PATCH 0/4] musb host improvments mostly for omap2430 glue

2019-09-02 Thread Tony Lindgren
* Pavel Machek  [190902 09:44]:
> On Mon 2019-09-02 11:23:44, Pavel Machek wrote:
> Hmm. I guess CONFIG_USB_MUSB_DUAL_ROLE=y might be useful.
> 
> And now... if I unplug/replug the usb after the boot, USB hub and
> mouse are recognized. Good!
> 
> Less than minute later:
> 
> mmusb-hdrc.0.auto: Babble
> USB disconnect

The babble is most likely caused by some kind of signaling issue.

> I unplug, replug usb (not at the phone, between hub and dongle, and
> green LED indincating charging starts blinking rapidly.
> 
> cpcap-core spi0.0: EOT timed out.
> 
> I try plug/replug, and now green led is on.
> 
> I unplug replug at the phone, and get bunch more of messages:
> 
> musm _set_peripheral: already in peripheral mode: 99
> musm _set_peripheral: already in peripheral mode: 81
> musm _set_peripheral: already in peripheral mode: 81
> 
> musb_set_host: could not set host: 99
> musb_set_host: could not set host: 99
> musb_set_host: could not set host: 99
> musb_set_host: could not set host: 99
> musb_set_host: could not set host: 99
> musb_set_host: could not set host: 99
> musb_set_host: could not set host: 99
> musb_set_host: could not set host: 99
> 
> Unplug/replug at host, and again, hub+mouse is detected.
> 
> I unplug power connected to one of USB hub's ports... and find out
> that phone was _not_ powering it.
> 
> Ok... so something somehow works sometimes :-).

My guess is you're missing a USB micro-B cable with ID pin
grounded, with that things should just work automagically.

So no need for hubs feeding back VBUS and no need to
try to force host mode via sysfs unlike on n900.

Regards,

Tony


Re: [GIT PULL] USB changes for v5.4 merge window

2019-09-02 Thread Greg Kroah-Hartman
On Fri, Aug 30, 2019 at 12:14:28PM +0300, Felipe Balbi wrote:
> 
> Hi Greg,
> 
> Here's my pull request for the next merge window. The biggest chunk is
> the addition of Cadence USB3 DRD Driver which, finally, compiles on x86,
> ARM and ARM64 without any issues. I haven't gotten any failure reports
> from 0-day either.
> 
> Relevant changes have been testing on platforms I have access to. Most
> importantly the generalization of the dwc3 control request decoders
> didn't cause any visible regressions that I could trigger.
> 
> Let me know if you want anything to be changed.
> 
> cheers
> 
>   
> < New Driver >
>   
> \   ^__^
>  \  (oo)\___
> (__)\   )\/\
> ||w |
> || ||
> 
> The following changes since commit e21a712a9685488f5ce80495b37b9fdbe96c230d:
> 
>   Linux 5.3-rc3 (2019-08-04 18:40:12 -0700)
> 
> are available in the Git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
> tags/usb-for-v5.4
> 
> for you to fetch changes up to 18a93cd38be3e69ac5b067c570a78a369b79e31d:
> 
>   usb: gadget: net2280: Add workaround for AB chip Errata 11 (2019-08-30 
> 09:27:33 +0300)
> 
> 
> USB: Changes for v5.4 merge window
> 
> With only 45 non-merge commits, we have a small merge window from the
> Gadget perspective.
> 
> The biggest change here is the addition of the Cadence USB3 DRD
> Driver. All other changes are small, non-critical fixes or smaller new
> features like the improvement to BESL handling in dwc3.
> 
> Signed-off-by: Felipe Balbi 

Pulled and pushed out, thanks.

greg k-h


Re: Lacie Rugged USB3-FW does not work with UAS

2019-09-02 Thread Julian Sikorski

W dniu 02.09.2019 o 13:42, Oliver Neukum pisze:

Am Donnerstag, den 29.08.2019, 20:33 +0200 schrieb Julian Sikorski:

Hi,

this is a relief. If necessary we can blacklist the new device.
Howevera, as that costs performance, I would appriciate if
you take first try out an alternative approach.


[  362.230833] usb 2-4: New USB device found, idVendor=059f,
idProduct=1061, bcdDevice= 0.01
[  362.230837] usb 2-4: New USB device strings: Mfr=2, Product=3,
SerialNumber=1
[  362.230839] usb 2-4: Product: Rugged USB3-FW
[  362.230841] usb 2-4: Manufacturer: LaCie
[  362.230842] usb 2-4: SerialNumber: 157f928920fa
[  362.270100] scsi host12: uas
[  362.270720] scsi 12:0:0:0: Direct-Access LaCieRugged FW USB3
   051E PQ: 0 ANSI: 6
[  362.271472] sd 12:0:0:0: Attached scsi generic sg1 type 0
[  362.280344] sd 12:0:0:0: [sdb] 1953525168 512-byte logical blocks:
(1.00 TB/932 GiB)
[  362.280422] sd 12:0:0:0: [sdb] Write Protect is off
[  362.280423] sd 12:0:0:0: [sdb] Mode Sense: 43 00 00 00
[  362.280544] sd 12:0:0:0: [sdb] Write cache: enabled, read cache:
enabled, doesn't support DPO or FUA


This means that at least the earliest commandos did get through.


[  392.672691] sd 12:0:0:0: tag#29 uas_eh_abort_handler 0 uas-tag 1
inflight: IN
[  392.672697] sd 12:0:0:0: tag#29 CDB: Report supported operation codes
a3 0c 01 12 00 00 00 00 02 00 00 00
[  392.678304] scsi host12: uas_eh_device_reset_handler start
[  392.800099] usb 2-4: reset SuperSpeed Gen 1 USB device number 3 using
xhci_hcd
[  392.848154] scsi host12: uas_eh_device_reset_handler success
[  422.875443] scsi host12: uas_eh_device_reset_handler start
[  422.875650] sd 12:0:0:0: tag#16 uas_zap_pending 0 uas-tag 1 inflight:
[  422.875654] sd 12:0:0:0: tag#16 CDB: Report supported operation codes
a3 0c 01 12 00 00 00 00 02 00 00 00
[  422.997556] usb 2-4: reset SuperSpeed Gen 1 USB device number 3 using
xhci_hcd
[  423.046525] scsi host12: uas_eh_device_reset_handler success
[  431.853505] usb 2-4: USB disconnect, device number 3
[  431.903459] sd 12:0:0:0: [sdb] Optimal transfer size 33553920 bytes
[  432.064456] sd 12:0:0:0: [sdb] Read Capacity(16) failed: Result:
hostbyte=DID_ERROR driverbyte=DRIVER_OK


Read Capacity(16) failed


[  432.064459] sd 12:0:0:0: [sdb] Sense not available.
[  432.184595] sd 12:0:0:0: [sdb] Read Capacity(10) failed: Result:
hostbyte=DID_ERROR driverbyte=DRIVER_OK


Read Capacity(10) failed

There is a chance that this device can deal only with Read Capacity(10)
and crashes on Read Capacity(16). One difference between Usb-storage
and UAS is the order in which the 10 and 16 versions are tried.
The attached patches introduce a quirk to reverse the order
for this particular device under UAS. Could you try them?

Regards
Oliver



Hi,

thanks for the patch! It appears that we got the drives confused, the 
one needing quirks is 059f:1061. Unfortunately, even after hand-editing 
the patch to match (attached for confirmation), uas is still not 
working. The dmesg log is unchanged:


[   67.925435] usb 2-4: new SuperSpeed Gen 1 USB device number 2 using 
xhci_hcd
[   67.947738] usb 2-4: New USB device found, idVendor=059f, 
idProduct=1061, bcdDevice= 0.01
[   67.947739] usb 2-4: New USB device strings: Mfr=2, Product=3, 
SerialNumber=1

[   67.947740] usb 2-4: Product: Rugged USB3-FW
[   67.947741] usb 2-4: Manufacturer: LaCie
[   67.947742] usb 2-4: SerialNumber: 157f928920fa
[   67.978140] usbcore: registered new interface driver usb-storage
[   68.007356] scsi host12: uas
[   68.007520] usbcore: registered new interface driver uas
[   68.007781] scsi 12:0:0:0: Direct-Access LaCieRugged FW USB3 
 051E PQ: 0 ANSI: 6

[   68.008589] sd 12:0:0:0: Attached scsi generic sg1 type 0
[   68.017457] sd 12:0:0:0: [sdb] 1953525168 512-byte logical blocks: 
(1.00 TB/932 GiB)

[   68.017540] sd 12:0:0:0: [sdb] Write Protect is off
[   68.017542] sd 12:0:0:0: [sdb] Mode Sense: 43 00 00 00
[   68.017693] sd 12:0:0:0: [sdb] Write cache: enabled, read cache: 
enabled, doesn't support DPO or FUA
[   98.221259] sd 12:0:0:0: tag#7 uas_eh_abort_handler 0 uas-tag 1 
inflight: IN
[   98.221264] sd 12:0:0:0: tag#7 CDB: Report supported operation codes 
a3 0c 01 12 00 00 00 00 02 00 00 00

[   98.226869] scsi host12: uas_eh_device_reset_handler start
[   98.348671] usb 2-4: reset SuperSpeed Gen 1 USB device number 2 using 
xhci_hcd

[   98.397136] scsi host12: uas_eh_device_reset_handler success
[  128.428023] scsi host12: uas_eh_device_reset_handler start
[  128.428224] sd 12:0:0:0: tag#4 uas_zap_pending 0 uas-tag 1 inflight:
[  128.428228] sd 12:0:0:0: tag#4 CDB: Report supported operation codes 
a3 0c 01 12 00 00 00 00 02 00 00 00
[  128.549805] usb 2-4: reset SuperSpeed Gen 1 USB device number 2 using 
xhci_hcd

[  128.597949] scsi host12: uas_eh_device_reset_handler success
[  158.632176] scsi host12: uas_eh_device_reset_handler start
[  158.632382] sd 12:0:0:0: tag#5 uas_zap_pending 0 uas-tag 1 infli