[PATCH net-next] drivers: net: Remove unnecessary semicolon

2019-03-01 Thread Yue Haibing
From: YueHaibing 

drivers/net/dsa/mt7530.c:649:3-4: Unneeded semicolon
drivers/net/ethernet/cisco/enic/enic_clsf.c:35:2-3: Unneeded semicolon
drivers/net/ethernet/faraday/ftgmac100.c:1640:2-3: Unneeded semicolon
drivers/net/ethernet/mediatek/mtk_eth_soc.c:229:2-3: Unneeded semicolon
drivers/net/usb/sr9700.c:437:2-3: Unneeded semicolon

Remove unneeded semicolon.

Generated by: scripts/coccinelle/misc/semicolon.cocci

Signed-off-by: YueHaibing 
---
 drivers/net/dsa/mt7530.c| 2 +-
 drivers/net/ethernet/cisco/enic/enic_clsf.c | 3 ++-
 drivers/net/ethernet/faraday/ftgmac100.c| 2 +-
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +-
 drivers/net/usb/sr9700.c| 2 +-
 5 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index 0390c5e..7357b4f 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -646,7 +646,7 @@ static void mt7530_adjust_link(struct dsa_switch *ds, int 
port,
case SPEED_100:
mcr |= PMCR_FORCE_SPEED_100;
break;
-   };
+   }
 
if (phydev->link)
mcr |= PMCR_FORCE_LNK;
diff --git a/drivers/net/ethernet/cisco/enic/enic_clsf.c 
b/drivers/net/ethernet/cisco/enic/enic_clsf.c
index 99038df..9900993 100644
--- a/drivers/net/ethernet/cisco/enic/enic_clsf.c
+++ b/drivers/net/ethernet/cisco/enic/enic_clsf.c
@@ -32,7 +32,8 @@ int enic_addfltr_5t(struct enic *enic, struct flow_keys 
*keys, u16 rq)
break;
default:
return -EPROTONOSUPPORT;
-   };
+   }
+
data.type = FILTER_IPV4_5TUPLE;
data.u.ipv4.src_addr = ntohl(keys->addrs.v4addrs.src);
data.u.ipv4.dst_addr = ntohl(keys->addrs.v4addrs.dst);
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c 
b/drivers/net/ethernet/faraday/ftgmac100.c
index 3e5e971..b17b79e 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1637,7 +1637,7 @@ static int ftgmac100_setup_mdio(struct net_device *netdev)
reg = ioread32(priv->base + FTGMAC100_OFFSET_REVR);
reg &= ~FTGMAC100_REVR_NEW_MDIO_INTERFACE;
iowrite32(reg, priv->base + FTGMAC100_OFFSET_REVR);
-   };
+   }
 
/* Get PHY mode from device-tree */
if (np) {
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c 
b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 94d4663..549d364 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -226,7 +226,7 @@ static void mtk_phy_link_adjust(struct net_device *dev)
case SPEED_100:
mcr |= MAC_MCR_SPEED_100;
break;
-   };
+   }
 
if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_GMAC1_TRGMII) &&
!mac->id && !mac->trgmii)
diff --git a/drivers/net/usb/sr9700.c b/drivers/net/usb/sr9700.c
index 6ac232e..e04c8054 100644
--- a/drivers/net/usb/sr9700.c
+++ b/drivers/net/usb/sr9700.c
@@ -434,7 +434,7 @@ static int sr9700_rx_fixup(struct usbnet *dev, struct 
sk_buff *skb)
usbnet_skb_return(dev, sr_skb);
 
skb_pull(skb, len + SR_RX_OVERHEAD);
-   };
+   }
 
return 0;
 }
-- 
2.7.0




Re: [PATCH] usb: xhci: Support running urb giveback in tasklet context

2019-03-01 Thread Suwan Kim
Hi Mathias,

On Thu, Feb 28, 2019 at 11:18:58AM +0200, Mathias Nyman wrote:
> Hi
> 
> On 19.2.2019 17.41, Suwan Kim wrote:
> > Patch "USB: HCD: support giveback of URB in tasklet context"
> > introduced giveback of urb in tasklet context. [1] This patch was
> > applied to ehci but not xhci. [2] It significantly reduces the hard
> > irq time of xhci. Especially for the uvc driver, the hard irq including
> > the uvc complete function runs quite long (about 300-350us in my
> > Thinkpad s440 laptop with webcam) but applying this patch reduces
> > the hard irq time of xhci to about 18-30us.
> 
> Sorry about the late reply.
> Can you recall any reason why this wasn't applied to xhci back then?

Ming Lei who is the author of the giveback-tasklet patch in usb core
worked with Alan stern when he was working on the patch, and he only
replaced giveback of ehci. I don't know why he didn't replace xhci.
After some time, somebody asked him why this patch did not apply to
xhci. And there was no apparent reason.[1] IMO, no one seems
interested in xhci...

> xhci is doing a lot in hard interrupt context, and reducing that would
> be a good idea. Another option to look at is using threaded interrupts
> for xhci.

When the giveback-tasklet patch was working, the author experimented
with comparing threaded interrupt and tasklet. At that time, tasklet
showed better performance than threaded interrupt.[2]

> We might however be opening a can of worms with this, the impact is unknown.
> 
> How much testing was done with URB return in tasklet for SS devices?
> 
> Would be nice to test this out on a bit wider audience before applying it.

Unfortunately, SS devices I have are only usb mass storage devices.
When I tested with a USB mass storage device, both xhci with tasklet
and without tasklet(urb complete in hard IRQ) showed similar performance.

[USB-mass storage TEST]

 - Testbed is i5-7600 and two mass storage devices (usb flash memory,
   external hard drive) are used.
   Test is executed 10 times and figure out the average speed

 - dd if=/dev/sdN of=/dev/null iflag=direct bs=1G count=1
 - device1 : Sandisk Ultra Flair USB 3.0 32GB
 - device2 : WD My Passport 2TB (external hard drive)

 - xhci without tasklet
- device1 - 129.727MB/s
- device2 - 103.667MB/s

 - xhci with tasklet
- device1 - 103.2MB/s
- device2 - 103.692MB/s

I have only one high-speed isochronous type device that is built-in
webcam in my laptop (Thinkpad s440, i5-4210U) In this case, it is
difficult to measure the performance. So i checked the overrun/underrun
event in xhci. Until now, no overrun/underrun event has occurred
in actual use.

Regards

Suwan Kim


Re: [PATCH] usb: xhci: Support running urb giveback in tasklet context

2019-03-01 Thread Suwan Kim
I forgot to add links... sorry!

[1], https://marc.info/?l=linux-usb&m=139523715802919&w=2
[2], https://marc.info/?l=linux-usb&m=137109031822092&w=2


RE: Bus noise periodically causes ci_hdrc IRQ lockup

2019-03-01 Thread Peter Chen
 
> On 2/28/19 1:57 AM, Peter Chen wrote:
> >
> >>> Let me summary your observation:
> >>> - bind/unbind ci_hdrc device can recover connection
> >>> - Reset HUB can't recover, and will go the previous error state
> >>> after reset
> >>>
> >>>   From the register, we do see something abnormal, and the RX is
> >>> waiting the SYNC Field. We need to see the dp/dm status to know if
> >>> HUB is wrong, eg, sending data exceed 20us (larger than 1024 bytes)
> >>>
>  I will continue looking into probing Dm/Dp.  You would like me to
>  do this
>  *while* the failure occurs, or after?
> 
> >>> After the error occurs.
> >>>
> >>> Peter
> >>>
> >> Hi Peter,
> >>
> >> That summary is accurate.
> >>
> >> I soldered some leads onto the host/hub connection and hooked up to
> oscilloscope.
> >> The findings were interesting:
> >>
> >> Directly after failure:
> >> 0x020CA060 @ 0x2: 0x0064
> >> PORTSC reg: 18001a05
> >> Dm line: 150 mV
> >> Dp line: 0 V
> >> After failure, hub reset asserted:
> >> 0x020CA060 @ 0x2: 0x0024
> >> PORTSC reg: 18001205
> >> Dm line: 0 V
> >> Dp line: 0 V
> >> After failure, hub reset released:
> >> 0x020CA060 @ 0x2: 0x0064
> >> PORTSC reg: 18001a05
> >> Dm line: 150 mV
> >> Dp line: 0 V
> >>
> >> It seems strange that it would switch between those voltages -- could
> >> the hub and host be trying to write different values at the same time?
> >>
> > HUB and host are impossible to send the data together.
> >
> >> I have noticed something new happening (maybe as a result of hooking
> >> up the probe?).
> >> A couple times now after initial failure, the device has changed states 
> >> later.
> >> In this state the Linux USB devices appear to 'wake up' and start throwing 
> >> errors.
> >>
> >>  (failure occurs)
> >> [  227.323636] smsc95xx 1-1.4.1:1.0 eth1: Failed to read reg index
> >> 0x0114: -
> >> 110 [  227.323659] smsc95xx 1-1.4.1:1.0 eth1: Error reading
> >> MII_ACCESS [  227.323677] smsc95xx 1-1.4.1:1.0 eth1: MII is busy in
> >> smsc95xx_mdio_read [  227.323694] smsc95xx 1-1.4.1:1.0 eth1: Failed to read
> MII_BMSR
> >>  (no errors for 25 minutes, then something changes) [ 1752.092896] 
> >> uvcvideo:
> >> Non-zero status (-71) in video completion handler.
> >> [ 1752.124744] uvcvideo: Non-zero status (-71) in video completion handler.
> >> [ 1752.124866] usb 1-1.4: clear tt 3 (91c1) error -71
> >>  ...lots of errors...
> >>
> >> Registers:
> >> 0x020CA060 @ 0x1: 0x
> >> 0x020CA060 @ 0x2: 0x00140060
> >> 0x020CA060 @ 0x3: 0x10801110
> >> 0x020CA060 @ 0x4: 0x00010001
> >> 0x020CA060 @ 0x5: 0x01011101
> >> 0x020CA060 @ 0x6: 0x0101
> >> 0x020CA060 @ 0x7: 0x06200010 (changing)
> >> 0x020CA060 @ 0x8: 0x1101
> >> PORTSC reg: steady at 10001801
> >> Dm line: steady at 3 V
> >> Dp line: steady at 0 V
> >>
> >> And after that, when I reset the hub it returns to normal operation.
> >>
> >> ...lots of errors...
> >> [ 1977.285844] usb 1-1.4: clear tt 3 (91c1) error -71
> >>  (hub reset asserted)
> >> [ 1977.309718] usb 1-1: USB disconnect, device number 2
> >>  (hub reset released)
> >> [ 2088.226453] usb 1-1: new high-speed USB device number 29 using
> >> ci_hdrc
> >>
> >> Let me know what you think of this,
> >>
> > It seems you record DM/DP opposite, please confirm it.
> I checked and yes, they were opposite.
> > Besides,
> > - Do you observe this USB issue at specific board or some boards?
> 
> I have observed it in two different boards in this specific setup, and in two 
> other
> machines in the field (not in my possession).
> 
> > - After connecting probe, sometimes the reset HUB can recover, and
> > somethings can't?
> It looks like attaching the probe makes the data lines much more sensitive to
> interference.  When I run the welder again after the initial failure, the 
> state changes
> as shown in the 2nd earlier log. I have reproduced this again, see below link 
> - log #5.
> > - When HUB's reset is asserted, does the register dump and measure are like
> below (can't recover situation):
> > 0x020CA060 @ 0x1: 0x7B2C
> > 0x020CA060 @ 0x2: 0x0024
> > 0x020CA060 @ 0x3: 0x108401C0 (still changes on every read)
> > 0x020CA060 @ 0x4: 0x00010001
> > 0x020CA060 @ 0x5: 0x01011101
> > 0x020CA060 @ 0x6: 0x0101
> > 0x020CA060 @ 0x7: 0x05300010
> > 0x020CA060 @ 0x8: 0x8101
> > PORTSC reg: 18001205
> > Dm line: 0 V
> > Dp line: 0 V
> That's correct.
> > Besides, I need your whole kernel log with and without using probe,
> > your original kernel log at github is ok (but need to let me access).
> > I need to know if bus reset and bus suspend occur during the whole process.
> >
> > My guesses are:
> > First log: the HUB enters FS with unknown reason, it adds its 1.5 Kohm
> > (minimum can be 900ohm) @3.3V, and the host is 45ohm, so the host sees
> > it is ~150mV. The host controller is stuck at HS rxactive state at this 
> > situation
> forever.
> > Second log: the 

Re: [PATCH] usb: xhci: Support running urb giveback in tasklet context

2019-03-01 Thread Suwan Kim
There is typo.. sorry again

in [USB-mass storge TEST]
 - xhci with tasklet
- device1 - 130.2MB/s (not 103.2MS/s!)
- device2 - 103.692MB/s


Re: [PATCH 4/8] dt-bindings: usb: dwc3: Add Amlogic G12A DWC3 Glue Bindings

2019-03-01 Thread Neil Armstrong
On 28/02/2019 17:29, Rob Herring wrote:
> On Tue, Feb 12, 2019 at 04:14:09PM +0100, Neil Armstrong wrote:
>> Adds the bindings for the Amlogic G12A USB Glue HW.
>>
>> The Amlogic G12A SoC Family embeds 2 USB Controllers :
>> - a DWC3 IP configured as Host for USB2 and USB3
>> - a DWC2 IP configured as Peripheral USB2 Only
>>
>> A glue connects these both controllers to 2 USB2 PHYs,
>> and optionnally to an USB3+PCIE Combo PHY shared with the PCIE controller.
>>
>> The Glue configures the UTMI 8bit interfaces for the USB2 PHYs, including
>> routing of the OTG PHY between the DWC3 and DWC2 controllers, and
>> setups the on-chip OTG mode selection for this PHY.
>>
>> The PHYs are children of the Glue node since the Glue controls the interface
>> with the PHY, not the DWC3 controller.
>>
>> The PHY interconnect is handled into ports subnodes, which eases describing
>> which PHY is enabled (like the USB3 shared PHY) and futures layouts on
>> derivatives of the G12A Family.
>>
>> Signed-off-by: Neil Armstrong 
>> ---
>>  .../devicetree/bindings/usb/amlogic,dwc3.txt  | 109 ++
>>  1 file changed, 109 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/usb/amlogic,dwc3.txt 
>> b/Documentation/devicetree/bindings/usb/amlogic,dwc3.txt
>> index 9a8b631904fd..c7c4726ef10d 100644
>> --- a/Documentation/devicetree/bindings/usb/amlogic,dwc3.txt
>> +++ b/Documentation/devicetree/bindings/usb/amlogic,dwc3.txt
>> @@ -40,3 +40,112 @@ Example device nodes:
>>  phy-names = "usb2-phy", "usb3-phy";
>>  };
>>  };
>> +
>> +Amlogic Meson G12A DWC3 USB SoC Controller Glue
>> +
>> +The Amlogic G12A embeds a DWC3 USB IP Core configured for USB2 and USB3
>> +in host-only mode, and a DWC2 IP Core configured for USB2 peripheral mode
>> +only.
>> +
>> +A glue connects the DWC3 core to USB2 PHYs and optionnaly to an USB3 PHY.
>> +
>> +One of the USB2 PHY can be re-routed in peripheral mode to a DWC2 USB IP.
>> +
>> +The DWC3 Glue controls the PHY routing and power, an interrupt line is
>> +connected to the Glue to serve as OTG ID change detection.
>> +
>> +Required properties:
>> +- compatible:   Should be "amlogic,meson-g12a-usb-ctrl"
>> +- clocks:   a handle for the "USB" clock
>> +- clock-names:  must be "usb"
>> +- resets:   a handle for the shared "USB" reset line
>> +- reset-names:  must be "usb"
> 
> -name for a single entry is pointless.
> 
>> +- reg:  The base address and length of the registers
>> +- interrupts:   the interrupt specifier for the OTG detection
>> +
>> +Required child nodes:
>> +
>> +USB Ports are described as child 'port' nodes grouped under a 'ports' node,
>> +with #address-cells, #size-cells specified.
>> +
>> +Each 'port' sub-node identifies a possible USB Port served by an USB PHY
>> +identified by the 'phy' property as decribed in ../phy/phy-bindings.txt
>> +
>> +Each 'port' is identified by a reg property to number the port.
>> +
>> +The following table lists for each supported model the port number
>> +corresponding to each PHY serving a physical USB Port.
>> +
>> + FamilyPort 0 Port 1Port 2Port 3Port 4
>> +---
>> + G12A  USBHOST_A  USBOTG_B  Reserved  Reserved  USB3_0
>> +
>> +A child node must exist to represent the core DWC3 IP block. The name of
>> +the node is not important. The content of the node is defined in dwc3.txt.
>> +
>> +A child node must exist to represent the core DWC2 IP block. The name of
>> +the node is not important. The content of the node is defined in dwc2.txt.
>> +
>> +PHY documentation is provided in the following places:
>> +- Documentation/devicetree/bindings/phy/meson-g12a-usb2-phy.txt
>> +- Documentation/devicetree/bindings/phy/meson-g12a-usb3-pcie-phy.txt
>> +
>> +
>> +Example device nodes:
>> +usb: usb@ffe09000 {
>> +compatible = "amlogic,meson-g12a-usb-ctrl";
>> +reg = <0x0 0xffe09000 0x0 0xa0>;
>> +interrupts = ;
>> +#address-cells = <2>;
>> +#size-cells = <2>;
>> +ranges;
>> +
>> +clocks = <&clkc CLKID_USB>;
>> +clock-names = "usb";
>> +resets = <&reset RESET_USB>;
>> +reset-names = "usb";
>> +
>> +ports {
>> +#address-cells = <1>;
>> +#size-cells = <0>;
>> +
>> +/* USB2 Port 0 */
>> +usb20: port@0 {
>> +reg = <0>;
>> +phys = <&usb2_phy0>;
> 
> 'ports' and 'port' are reserved for the graph binding. Don't use it for 
> your own thing.
> 
> Can't you just make 'phys' a list using 0 phandle if you need to skip 
> entries.

Yep, finally this would be simpler.

> 
>> +   

[PATCH 0/4] Add USB-HOST support to cat874

2019-03-01 Thread Fabrizio Castro
While trying to add USB-HOST support to the cat874 board,
it came up that of_usb_get_dr_mode_by_phy was selecting
the wrong DT node to use for dr_mode.
Also, drivers/phy/renesas/phy-rcar-gen3-usb2.c was registering
IRQs, no matter the dr_mode.

This series adds all that is required to add USB-HOST support
to the cat874 board, and also removes the hsusb from Draak's DT
as not necessary anymore.

Thanks,
Fab

Fabrizio Castro (4):
  usb: common: Consider only available nodes for dr_mode
  phy: renesas: rcar-gen3-usb2: No need to request IRQ for non-OTG
  arm64: dts: renesas: r8a774c0-cat874: Add USB-HOST support
  arm64: dts: renesas: r8a77995: draak: Remove hsusb node

 arch/arm64/boot/dts/renesas/r8a774c0-cat874.dts | 15 ++
 arch/arm64/boot/dts/renesas/r8a77995-draak.dts  |  5 -
 drivers/phy/renesas/phy-rcar-gen3-usb2.c| 26 -
 drivers/usb/common/common.c |  2 ++
 4 files changed, 30 insertions(+), 18 deletions(-)

-- 
2.7.4



[PATCH 1/4] usb: common: Consider only available nodes for dr_mode

2019-03-01 Thread Fabrizio Castro
There are cases where multiple device tree nodes point to the
same phy node by means of the "phys" property, but we should
only consider those nodes that are marked as available rather
than just any node.

Fixes: 98bfb3946695 ("usb: of: add an api to get dr_mode by the phy node")
Cc: sta...@vger.kernel.org # v4.4+
Signed-off-by: Fabrizio Castro 
---
 drivers/usb/common/common.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index 48277bb..73c8e65 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -145,6 +145,8 @@ enum usb_dr_mode of_usb_get_dr_mode_by_phy(struct 
device_node *np, int arg0)
 
do {
controller = of_find_node_with_property(controller, "phys");
+   if (!of_device_is_available(controller))
+   continue;
index = 0;
do {
if (arg0 == -1) {
-- 
2.7.4



Re: [PATCH] wusb: Remove unnecessary static function ckhdid_printf

2019-03-01 Thread Louis Taylor
On Thu, Feb 28, 2019 at 08:38:16PM -0800, Joe Perches wrote:
> This static inline is unnecessary and can be removed
> by using the vsprintf %ph extension.
> 
> This reduces overall object size by more than 2K.
> 
> Signed-off-by: Joe Perches 
> ---
>  drivers/usb/wusbcore/cbaf.c   | 15 ---
>  drivers/usb/wusbcore/dev-sysfs.c  |  5 ++---
>  drivers/usb/wusbcore/devconnect.c |  2 +-
>  drivers/usb/wusbcore/wusbhc.c |  6 +-
>  include/linux/usb/wusb.h  | 16 
>  5 files changed, 8 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/usb/wusbcore/cbaf.c b/drivers/usb/wusbcore/cbaf.c
> index 28c5c1e1..af77064c7456 100644
> --- a/drivers/usb/wusbcore/cbaf.c
> +++ b/drivers/usb/wusbcore/cbaf.c
> @@ -302,10 +302,8 @@ static ssize_t cbaf_wusb_chid_show(struct device *dev,
>  {
>   struct usb_interface *iface = to_usb_interface(dev);
>   struct cbaf *cbaf = usb_get_intfdata(iface);
> - char pr_chid[WUSB_CKHDID_STRSIZE];
>  
> - ckhdid_printf(pr_chid, sizeof(pr_chid), &cbaf->chid);
> - return scnprintf(buf, PAGE_SIZE, "%s\n", pr_chid);
> + return sprintf(buf, "%16ph\n", cbaf->chid.data);
>  }
>  
>  static ssize_t cbaf_wusb_chid_store(struct device *dev,
> @@ -415,10 +413,8 @@ static ssize_t cbaf_wusb_cdid_show(struct device *dev,
>  {
>   struct usb_interface *iface = to_usb_interface(dev);
>   struct cbaf *cbaf = usb_get_intfdata(iface);
> - char pr_cdid[WUSB_CKHDID_STRSIZE];
>  
> - ckhdid_printf(pr_cdid, sizeof(pr_cdid), &cbaf->cdid);
> - return scnprintf(buf, PAGE_SIZE, "%s\n", pr_cdid);
> + return sprintf(buf, "%16ph\n", cbaf->cdid.data);
>  }
>  
>  static ssize_t cbaf_wusb_cdid_store(struct device *dev,
> @@ -503,7 +499,6 @@ static int cbaf_cc_upload(struct cbaf *cbaf)
>   int result;
>   struct device *dev = &cbaf->usb_iface->dev;
>   struct wusb_cbaf_cc_data *ccd;
> - char pr_cdid[WUSB_CKHDID_STRSIZE];
>  
>   ccd =  cbaf->buffer;
>   *ccd = cbaf_cc_data_defaults;
> @@ -513,10 +508,8 @@ static int cbaf_cc_upload(struct cbaf *cbaf)
>   ccd->BandGroups = cpu_to_le16(cbaf->host_band_groups);
>  
>   dev_dbg(dev, "Trying to upload CC:\n");
> - ckhdid_printf(pr_cdid, sizeof(pr_cdid), &ccd->CHID);
> - dev_dbg(dev, "  CHID   %s\n", pr_cdid);
> - ckhdid_printf(pr_cdid, sizeof(pr_cdid), &ccd->CDID);
> - dev_dbg(dev, "  CDID   %s\n", pr_cdid);
> + dev_dbg(dev, "  CHID   %16ph\n", ccd->CHID.data);
> + dev_dbg(dev, "  CDID   %16ph\n", ccd->CDID.data);
>   dev_dbg(dev, "  Bandgroups 0x%04x\n", cbaf->host_band_groups);
>  
>   result = usb_control_msg(
> diff --git a/drivers/usb/wusbcore/dev-sysfs.c 
> b/drivers/usb/wusbcore/dev-sysfs.c
> index 85a1acf3a729..67b0a4c412b2 100644
> --- a/drivers/usb/wusbcore/dev-sysfs.c
> +++ b/drivers/usb/wusbcore/dev-sysfs.c
> @@ -50,10 +50,9 @@ static ssize_t wusb_cdid_show(struct device *dev,
>   wusb_dev = wusb_dev_get_by_usb_dev(to_usb_device(dev));
>   if (wusb_dev == NULL)
>   return -ENODEV;
> - result = ckhdid_printf(buf, PAGE_SIZE, &wusb_dev->cdid);
> - strcat(buf, "\n");
> + result = sprintf(buf, "%16ph\n", wusb_dev->cdid.data);
>   wusb_dev_put(wusb_dev);
> - return result + 1;
> + return result;
>  }
>  static DEVICE_ATTR_RO(wusb_cdid);
>  
> diff --git a/drivers/usb/wusbcore/devconnect.c 
> b/drivers/usb/wusbcore/devconnect.c
> index fcb06aef2675..a93837d57d53 100644
> --- a/drivers/usb/wusbcore/devconnect.c
> +++ b/drivers/usb/wusbcore/devconnect.c
> @@ -532,7 +532,7 @@ static void wusbhc_handle_dn_connect(struct wusbhc 
> *wusbhc,
>   }
>  
>   dnc = container_of(dn_hdr, struct wusb_dn_connect, hdr);
> - ckhdid_printf(pr_cdid, sizeof(pr_cdid), &dnc->CDID);
> + sprintf(pr_cdid, "%16ph", dnc->CDID.data);
>   dev_info(dev, "DN CONNECT: device %s @ %x (%s) wants to %s\n",
>pr_cdid,
>wusb_dn_connect_prev_dev_addr(dnc),
> diff --git a/drivers/usb/wusbcore/wusbhc.c b/drivers/usb/wusbcore/wusbhc.c
> index e5ba6140c1ba..d0b404d258e8 100644
> --- a/drivers/usb/wusbcore/wusbhc.c
> +++ b/drivers/usb/wusbcore/wusbhc.c
> @@ -80,17 +80,13 @@ static ssize_t wusb_chid_show(struct device *dev,
>  {
>   struct wusbhc *wusbhc = usbhc_dev_to_wusbhc(dev);
>   const struct wusb_ckhdid *chid;
> - ssize_t result = 0;
>  
>   if (wusbhc->wuie_host_info != NULL)
>   chid = &wusbhc->wuie_host_info->CHID;
>   else
>   chid = &wusb_ckhdid_zero;
>  
> - result += ckhdid_printf(buf, PAGE_SIZE, chid);
> - result += sprintf(buf + result, "\n");
> -
> - return result;
> + return sprintf(buf, "%16ph\n", chid->data);
>  }
>  
>  /*
> diff --git a/include/linux/usb/wusb.h b/include/linux/usb/wusb.h
> index 9e4a3213f2c2..65adee629106 100644
> --- a/include/linux/usb/wusb.h
> +++ b/include/linux/usb/wusb.h
> @@ -236,22 +236,6 @@ enum {
>   WUSB_TRUST_TIMEOUT_MS = 4000,   /* [

RE: [PATCH] dt-bindings: usb-xhci: Add r8a774c0 support

2019-03-01 Thread Fabrizio Castro
Hello Greg,

I am sorry to bother you.
Do you think you take this patch?

Thanks,
Fab

> From: Fabrizio Castro 
> Sent: 13 December 2018 20:21
> Subject: [PATCH] dt-bindings: usb-xhci: Add r8a774c0 support
> 
> Document RZ/G2E (R8A774C0) SoC bindings.
> 
> Signed-off-by: Fabrizio Castro 
> ---
>  Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
> b/Documentation/devicetree/bindings/usb/usb-xhci.txt
> index fea8b15..97400e8 100644
> --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
> +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
> @@ -10,6 +10,7 @@ Required properties:
>  - "renesas,xhci-r8a7743" for r8a7743 SoC
>  - "renesas,xhci-r8a7744" for r8a7744 SoC
>  - "renesas,xhci-r8a774a1" for r8a774a1 SoC
> +- "renesas,xhci-r8a774c0" for r8a774c0 SoC
>  - "renesas,xhci-r8a7790" for r8a7790 SoC
>  - "renesas,xhci-r8a7791" for r8a7791 SoC
>  - "renesas,xhci-r8a7793" for r8a7793 SoC
> --
> 2.7.4



[PATCH] usb: core: make default autosuspend delay configurable

2019-03-01 Thread Mans Rullgard
Make the default autosuspend delay configurable at build time.
This is useful for systems that require a non-standard value as
it avoids relying on the command line being properly set.

Signed-off-by: Mans Rullgard 
---
 drivers/usb/core/Kconfig | 8 
 drivers/usb/core/usb.c   | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index 4d75d9a80001..38ed837538c4 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -90,3 +90,11 @@ config USB_LEDS_TRIGGER_USBPORT
  This driver allows LEDs to be controlled by USB events. Enabling this
  trigger allows specifying list of USB ports that should turn on LED
  when some USB device gets connected.
+
+config USB_AUTOSUSPEND_DELAY
+   int "Default autosuspend delay"
+   depends on USB
+   default 2
+   help
+ The default autosuspend delay in seconds.  Can be overridden
+ with the usbcore.autosuspend command line or module parameter.
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 4ebfbd737905..52e749386c1c 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -65,8 +65,8 @@ int usb_disabled(void)
 EXPORT_SYMBOL_GPL(usb_disabled);
 
 #ifdef CONFIG_PM
-static int usb_autosuspend_delay = 2;  /* Default delay value,
-* in seconds */
+/* Default delay value, in seconds */
+static int usb_autosuspend_delay = CONFIG_USB_AUTOSUSPEND_DELAY;
 module_param_named(autosuspend, usb_autosuspend_delay, int, 0644);
 MODULE_PARM_DESC(autosuspend, "default autosuspend delay");
 
-- 
2.20.1



Re: [PATCH] soc: sunxi: Fix missing dependency on REGMAP_MMIO

2019-03-01 Thread Maxime Ripard
On Thu, Feb 28, 2019 at 08:20:44PM -0600, Samuel Holland wrote:
> When enabling ARCH_SUNXI from allnoconfig, SUNXI_SRAM is enabled, but
> not REGMAP_MMIO, so the kernel fails to link with an undefined reference
> to __devm_regmap_init_mmio_clk. Select REGMAP_MMIO, as suggested in
> drivers/base/regmap/Kconfig.
> 
> This creates the following dependency loop:
> 
>   drivers/of/Kconfig:68:symbol OF_IRQ depends on IRQ_DOMAIN
>   kernel/irq/Kconfig:63:symbol IRQ_DOMAIN is selected by 
> REGMAP
>   drivers/base/regmap/Kconfig:7:symbol REGMAP default is visible 
> depending on REGMAP_MMIO
>   drivers/base/regmap/Kconfig:39:   symbol REGMAP_MMIO is selected by 
> SUNXI_SRAM
>   drivers/soc/sunxi/Kconfig:4:  symbol SUNXI_SRAM is selected by 
> USB_MUSB_SUNXI
>   drivers/usb/musb/Kconfig:63:  symbol USB_MUSB_SUNXI depends on 
> GENERIC_PHY
>   drivers/phy/Kconfig:7:symbol GENERIC_PHY is selected by 
> PHY_BCM_NS_USB3
>   drivers/phy/broadcom/Kconfig:29:  symbol PHY_BCM_NS_USB3 depends on 
> MDIO_BUS
>   drivers/net/phy/Kconfig:12:   symbol MDIO_BUS default is visible 
> depending on PHYLIB
>   drivers/net/phy/Kconfig:181:  symbol PHYLIB is selected by 
> ARC_EMAC_CORE
>   drivers/net/ethernet/arc/Kconfig:18:  symbol ARC_EMAC_CORE is selected by 
> ARC_EMAC
>   drivers/net/ethernet/arc/Kconfig:24:  symbol ARC_EMAC depends on OF_IRQ
> 
> To fix the circular dependency, make USB_MUSB_SUNXI select GENERIC_PHY
> instead of depending on it. This matches the use of GENERIC_PHY by all
> but two other drivers.
> 
> Signed-off-by: Samuel Holland 

I assume it would go through the USB tree.

Acked-by: Maxime Ripard 

Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


signature.asc
Description: PGP signature


Re: [PATCH] dt-bindings: usb-xhci: Add r8a774c0 support

2019-03-01 Thread Greg Kroah-Hartman
On Fri, Mar 01, 2019 at 11:25:33AM +, Fabrizio Castro wrote:
> Hello Greg,
> 
> I am sorry to bother you.
> Do you think you take this patch?

device tree bindings need an ack from the DT maintainers before I can
take them.  Also, this is for xhci, the xhci maintainer is responsible
for those, not me :)

thanks,

greg k-h


Re: [PATCH] usb: introduce usb_ep_type_string() function

2019-03-01 Thread Greg Kroah-Hartman
On Fri, Mar 01, 2019 at 02:58:23PM +0800, Chunfeng Yun wrote:
> In some places, the code prints a human-readable USB endpoint
> transfer type (e.g. "bulk"). This involves a switch statement
> sometimes wrapped around in ({ ... }) block leading to code
> repetition.
> To make this scenario easier, here introduces usb_ep_type_string()
> function, which returns a human-readable name of provided
> endpoint type.
> It also changes a few places switch was used to use this
> new function.
> 
> Signed-off-by: Chunfeng Yun 
> ---
>  drivers/usb/common/common.c  | 16 
>  drivers/usb/core/endpoint.c  | 18 ++
>  drivers/usb/core/hcd.c   | 17 ++---
>  drivers/usb/dwc3/debugfs.c   | 23 ---
>  drivers/usb/gadget/udc/aspeed-vhub/epn.c |  6 +-
>  drivers/usb/gadget/udc/dummy_hcd.c   | 16 +---
>  drivers/usb/host/xhci-trace.h| 19 ++-
>  include/linux/usb/ch9.h  |  8 
>  8 files changed, 36 insertions(+), 87 deletions(-)
> 
> diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
> index 48277bbc15e4..2174dd9ec176 100644
> --- a/drivers/usb/common/common.c
> +++ b/drivers/usb/common/common.c
> @@ -16,6 +16,22 @@
>  #include 
>  #include 
>  
> +static const char *const ep_type_names[] = {
> + [USB_ENDPOINT_XFER_CONTROL] = "ctrl",
> + [USB_ENDPOINT_XFER_ISOC] = "isoc",
> + [USB_ENDPOINT_XFER_BULK] = "bulk",
> + [USB_ENDPOINT_XFER_INT] = "intr",
> +};
> +
> +const char *usb_ep_type_string(int ep_type)
> +{
> + if (ep_type < 0 || ep_type >= ARRAY_SIZE(ep_type_names))
> + return "unknown";
> +
> + return ep_type_names[ep_type];
> +}
> +EXPORT_SYMBOL_GPL(usb_ep_type_string);
> +
>  const char *usb_otg_state_string(enum usb_otg_state state)
>  {
>   static const char *const names[] = {
> diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
> index 1c2c04079676..afa43f9a47b2 100644
> --- a/drivers/usb/core/endpoint.c
> +++ b/drivers/usb/core/endpoint.c
> @@ -60,23 +60,9 @@ static ssize_t type_show(struct device *dev, struct 
> device_attribute *attr,
>char *buf)
>  {
>   struct ep_device *ep = to_ep_device(dev);
> - char *type = "unknown";
> + int ep_type = usb_endpoint_type(ep->desc);
>  
> - switch (usb_endpoint_type(ep->desc)) {
> - case USB_ENDPOINT_XFER_CONTROL:
> - type = "Control";
> - break;
> - case USB_ENDPOINT_XFER_ISOC:
> - type = "Isoc";
> - break;
> - case USB_ENDPOINT_XFER_BULK:
> - type = "Bulk";
> - break;
> - case USB_ENDPOINT_XFER_INT:
> - type = "Interrupt";
> - break;
> - }
> - return sprintf(buf, "%s\n", type);
> + return sprintf(buf, "%s\n", usb_ep_type_string(ep_type));

You just changed a user/kernel API here, the strings are now different
from what they used to be :(

That's not ok, odds are you will break tools if you do this.

>  }
>  static DEVICE_ATTR_RO(type);
>  
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index 015b126ce455..193ee92b2fdb 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -1875,23 +1875,10 @@ void usb_hcd_flush_endpoint(struct usb_device *udev,
>   /* kick hcd */
>   unlink1(hcd, urb, -ESHUTDOWN);
>   dev_dbg (hcd->self.controller,
> - "shutdown urb %pK ep%d%s%s\n",
> + "shutdown urb %pK ep%d%s-%s\n",
>   urb, usb_endpoint_num(&ep->desc),
>   is_in ? "in" : "out",
> - ({  char *s;
> -
> -  switch (usb_endpoint_type(&ep->desc)) {
> -  case USB_ENDPOINT_XFER_CONTROL:
> - s = ""; break;
> -  case USB_ENDPOINT_XFER_BULK:
> - s = "-bulk"; break;
> -  case USB_ENDPOINT_XFER_INT:
> - s = "-intr"; break;
> -  default:
> - s = "-iso"; break;
> - };
> - s;
> - }));
> + usb_ep_type_string(usb_endpoint_type(&ep->desc)));

You also changed the message here for control endpoints, but that's not
a big deal, it's ok.

>   usb_put_urb (urb);
>  
>   /* list contents may have changed */
> diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
> index 1c792710348f..d9e2a63835fe 100644
> --- a/drivers/usb/dwc3/debugfs.c
> +++ b/drivers/usb/dwc3/debugfs.c
> @@ -750,28 +750,13 @@ static int dwc3_transfer_type_show(struct seq_file *s, 
> void *unused)
>   unsigned long   flags;
>  
>   

Re: [PATCH] usb: core: make default autosuspend delay configurable

2019-03-01 Thread Greg Kroah-Hartman
On Fri, Mar 01, 2019 at 02:26:46PM +, Mans Rullgard wrote:
> Make the default autosuspend delay configurable at build time.
> This is useful for systems that require a non-standard value as
> it avoids relying on the command line being properly set.
> 
> Signed-off-by: Mans Rullgard 
> ---
>  drivers/usb/core/Kconfig | 8 
>  drivers/usb/core/usb.c   | 4 ++--
>  2 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
> index 4d75d9a80001..38ed837538c4 100644
> --- a/drivers/usb/core/Kconfig
> +++ b/drivers/usb/core/Kconfig
> @@ -90,3 +90,11 @@ config USB_LEDS_TRIGGER_USBPORT
> This driver allows LEDs to be controlled by USB events. Enabling this
> trigger allows specifying list of USB ports that should turn on LED
> when some USB device gets connected.
> +
> +config USB_AUTOSUSPEND_DELAY
> + int "Default autosuspend delay"
> + depends on USB
> + default 2
> + help
> +   The default autosuspend delay in seconds.  Can be overridden
> +   with the usbcore.autosuspend command line or module parameter.

As everyone is suddenly going to be hit with this for a new kernel
upate, you might want to put something in here that says:
The default value Linux has always had is 2 seconds.  Change
this value if you want a different delay timeframe and can not
modify the command line or module parameter option.

to make people a lot more comfortable with this change.

thanks,

greg k-h


RE: [PATCH] dt-bindings: usb-xhci: Add r8a774c0 support

2019-03-01 Thread Fabrizio Castro
Hello Greg,

Thank you for your reply!

> From: Greg Kroah-Hartman 
> Sent: 01 March 2019 16:16
> To: Fabrizio Castro 
> Cc: linux-usb@vger.kernel.org; devicet...@vger.kernel.org; 
> linux-ker...@vger.kernel.org; Simon Horman ;
> Geert Uytterhoeven ; Chris Paterson 
> ; Biju Das
> ; linux-renesas-...@vger.kernel.org; Rob Herring 
> ; Mark Rutland
> 
> Subject: Re: [PATCH] dt-bindings: usb-xhci: Add r8a774c0 support
> 
> On Fri, Mar 01, 2019 at 11:25:33AM +, Fabrizio Castro wrote:
> > Hello Greg,
> >
> > I am sorry to bother you.
> > Do you think you take this patch?
> 
> device tree bindings need an ack from the DT maintainers before I can
> take them.  Also, this is for xhci, the xhci maintainer is responsible
> for those, not me :)

I am so sorry.

The patch has been reviewed by Geert Uytterhoeven, Simon Horman, and Rob 
Herring already.

Mathias, are you the one taking the patches for 
Documentation/devicetree/bindings/usb/usb-xhci.txt now?

Thanks,
Fab

> 
> thanks,
> 
> greg k-h


[PATCH v2] usb: core: make default autosuspend delay configurable

2019-03-01 Thread Mans Rullgard
Make the default autosuspend delay configurable at build time.
This is useful for systems that require a non-standard value as
it avoids relying on the command line being properly set.

Signed-off-by: Mans Rullgard 
---
Changes in v2:
- add explanatory text to Kconfig help
---
 drivers/usb/core/Kconfig | 12 
 drivers/usb/core/usb.c   |  4 ++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index 4d75d9a80001..cd91006e3f84 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -90,3 +90,15 @@ config USB_LEDS_TRIGGER_USBPORT
  This driver allows LEDs to be controlled by USB events. Enabling this
  trigger allows specifying list of USB ports that should turn on LED
  when some USB device gets connected.
+
+config USB_AUTOSUSPEND_DELAY
+   int "Default autosuspend delay"
+   depends on USB
+   default 2
+   help
+ The default autosuspend delay in seconds.  Can be overridden
+ with the usbcore.autosuspend command line or module parameter.
+
+ The default value Linux has always had is 2 seconds.  Change
+ this value if you want a different delay and cannot modify
+ the command line or module parameter.
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 4ebfbd737905..52e749386c1c 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -65,8 +65,8 @@ int usb_disabled(void)
 EXPORT_SYMBOL_GPL(usb_disabled);
 
 #ifdef CONFIG_PM
-static int usb_autosuspend_delay = 2;  /* Default delay value,
-* in seconds */
+/* Default delay value, in seconds */
+static int usb_autosuspend_delay = CONFIG_USB_AUTOSUSPEND_DELAY;
 module_param_named(autosuspend, usb_autosuspend_delay, int, 0644);
 MODULE_PARM_DESC(autosuspend, "default autosuspend delay");
 
-- 
2.20.1



Re: [PATCH v2] usb: core: make default autosuspend delay configurable

2019-03-01 Thread Greg Kroah-Hartman
On Fri, Mar 01, 2019 at 04:43:20PM +, Mans Rullgard wrote:
> Make the default autosuspend delay configurable at build time.
> This is useful for systems that require a non-standard value as
> it avoids relying on the command line being properly set.
> 
> Signed-off-by: Mans Rullgard 
> ---
> Changes in v2:
> - add explanatory text to Kconfig help

Much nicer, thanks!

greg k-h


[PATCH] USB: usb.h: tweak struct urb to remove wasted space

2019-03-01 Thread Greg Kroah-Hartman
By moving one field around in 'struct urb' we reduce the size of the
structure by 8 bytes.

Before the patch on x86_64 the overall size of the structure as reported
by pahole was:
/* size: 192, cachelines: 3, members: 30 */
/* sum members: 184, holes: 2, sum holes: 8 */
After the patch we now have:
/* size: 184, cachelines: 3, members: 30 */
/* last cacheline: 56 bytes */

Signed-off-by: Greg Kroah-Hartman 
---
 include/linux/usb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/usb.h b/include/linux/usb.h
index 5e49e82c4368..4229eb74bd2c 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1545,10 +1545,10 @@ typedef void (*usb_complete_t)(struct urb *);
 struct urb {
/* private: usb core and host controller only fields in the urb */
struct kref kref;   /* reference count of the URB */
+   int unlinked;   /* unlink error code */
void *hcpriv;   /* private data for host controller */
atomic_t use_count; /* concurrent submissions counter */
atomic_t reject;/* submissions will fail */
-   int unlinked;   /* unlink error code */
 
/* public: documented fields in the urb that can be used by drivers */
struct list_head urb_list;  /* list head for use by the urb's
-- 
2.21.0



Re: [PATCH] wusb: Remove unnecessary static function ckhdid_printf

2019-03-01 Thread Nick Desaulniers
On Thu, Feb 28, 2019 at 8:38 PM Joe Perches  wrote:
>
> This static inline is unnecessary and can be removed
> by using the vsprintf %ph extension.
>
> This reduces overall object size by more than 2K.
>
> Signed-off-by: Joe Perches 

Deserves a reported by tag from (https://lkml.org/lkml/2019/2/28/1138)
Reported-by: Louis Taylor 

> ---
>  drivers/usb/wusbcore/cbaf.c   | 15 ---
>  drivers/usb/wusbcore/dev-sysfs.c  |  5 ++---
>  drivers/usb/wusbcore/devconnect.c |  2 +-
>  drivers/usb/wusbcore/wusbhc.c |  6 +-
>  include/linux/usb/wusb.h  | 16 
>  5 files changed, 8 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/usb/wusbcore/cbaf.c b/drivers/usb/wusbcore/cbaf.c
> index 28c5c1e1..af77064c7456 100644
> --- a/drivers/usb/wusbcore/cbaf.c
> +++ b/drivers/usb/wusbcore/cbaf.c
> @@ -302,10 +302,8 @@ static ssize_t cbaf_wusb_chid_show(struct device *dev,
>  {
> struct usb_interface *iface = to_usb_interface(dev);
> struct cbaf *cbaf = usb_get_intfdata(iface);
> -   char pr_chid[WUSB_CKHDID_STRSIZE];
>
> -   ckhdid_printf(pr_chid, sizeof(pr_chid), &cbaf->chid);
> -   return scnprintf(buf, PAGE_SIZE, "%s\n", pr_chid);
> +   return sprintf(buf, "%16ph\n", cbaf->chid.data);
>  }
>
>  static ssize_t cbaf_wusb_chid_store(struct device *dev,
> @@ -415,10 +413,8 @@ static ssize_t cbaf_wusb_cdid_show(struct device *dev,
>  {
> struct usb_interface *iface = to_usb_interface(dev);
> struct cbaf *cbaf = usb_get_intfdata(iface);
> -   char pr_cdid[WUSB_CKHDID_STRSIZE];
>
> -   ckhdid_printf(pr_cdid, sizeof(pr_cdid), &cbaf->cdid);
> -   return scnprintf(buf, PAGE_SIZE, "%s\n", pr_cdid);
> +   return sprintf(buf, "%16ph\n", cbaf->cdid.data);
>  }

Great simplification overall.  If you wanted to push further,
cbaf_wusb_c{h|d}id_show() are basically (almost) the same function
now.  They probably could share more code.  Everything else looks
good, thanks for the patch.
Reviewed-by: Nick Desaulniers 

>
>  static ssize_t cbaf_wusb_cdid_store(struct device *dev,
> @@ -503,7 +499,6 @@ static int cbaf_cc_upload(struct cbaf *cbaf)
> int result;
> struct device *dev = &cbaf->usb_iface->dev;
> struct wusb_cbaf_cc_data *ccd;
> -   char pr_cdid[WUSB_CKHDID_STRSIZE];
>
> ccd =  cbaf->buffer;
> *ccd = cbaf_cc_data_defaults;
> @@ -513,10 +508,8 @@ static int cbaf_cc_upload(struct cbaf *cbaf)
> ccd->BandGroups = cpu_to_le16(cbaf->host_band_groups);
>
> dev_dbg(dev, "Trying to upload CC:\n");
> -   ckhdid_printf(pr_cdid, sizeof(pr_cdid), &ccd->CHID);
> -   dev_dbg(dev, "  CHID   %s\n", pr_cdid);
> -   ckhdid_printf(pr_cdid, sizeof(pr_cdid), &ccd->CDID);
> -   dev_dbg(dev, "  CDID   %s\n", pr_cdid);
> +   dev_dbg(dev, "  CHID   %16ph\n", ccd->CHID.data);
> +   dev_dbg(dev, "  CDID   %16ph\n", ccd->CDID.data);
> dev_dbg(dev, "  Bandgroups 0x%04x\n", cbaf->host_band_groups);
>
> result = usb_control_msg(
> diff --git a/drivers/usb/wusbcore/dev-sysfs.c 
> b/drivers/usb/wusbcore/dev-sysfs.c
> index 85a1acf3a729..67b0a4c412b2 100644
> --- a/drivers/usb/wusbcore/dev-sysfs.c
> +++ b/drivers/usb/wusbcore/dev-sysfs.c
> @@ -50,10 +50,9 @@ static ssize_t wusb_cdid_show(struct device *dev,
> wusb_dev = wusb_dev_get_by_usb_dev(to_usb_device(dev));
> if (wusb_dev == NULL)
> return -ENODEV;
> -   result = ckhdid_printf(buf, PAGE_SIZE, &wusb_dev->cdid);
> -   strcat(buf, "\n");
> +   result = sprintf(buf, "%16ph\n", wusb_dev->cdid.data);
> wusb_dev_put(wusb_dev);
> -   return result + 1;
> +   return result;
>  }
>  static DEVICE_ATTR_RO(wusb_cdid);
>
> diff --git a/drivers/usb/wusbcore/devconnect.c 
> b/drivers/usb/wusbcore/devconnect.c
> index fcb06aef2675..a93837d57d53 100644
> --- a/drivers/usb/wusbcore/devconnect.c
> +++ b/drivers/usb/wusbcore/devconnect.c
> @@ -532,7 +532,7 @@ static void wusbhc_handle_dn_connect(struct wusbhc 
> *wusbhc,
> }
>
> dnc = container_of(dn_hdr, struct wusb_dn_connect, hdr);
> -   ckhdid_printf(pr_cdid, sizeof(pr_cdid), &dnc->CDID);
> +   sprintf(pr_cdid, "%16ph", dnc->CDID.data);
> dev_info(dev, "DN CONNECT: device %s @ %x (%s) wants to %s\n",
>  pr_cdid,
>  wusb_dn_connect_prev_dev_addr(dnc),
> diff --git a/drivers/usb/wusbcore/wusbhc.c b/drivers/usb/wusbcore/wusbhc.c
> index e5ba6140c1ba..d0b404d258e8 100644
> --- a/drivers/usb/wusbcore/wusbhc.c
> +++ b/drivers/usb/wusbcore/wusbhc.c
> @@ -80,17 +80,13 @@ static ssize_t wusb_chid_show(struct device *dev,
>  {
> struct wusbhc *wusbhc = usbhc_dev_to_wusbhc(dev);
> const struct wusb_ckhdid *chid;
> -   ssize_t result = 0;
>
> if (wusbhc->wuie_host_info != NULL)
> chid = &wusbhc->wuie_host_info->CHID;
> else
> chid = &wusb_ckhdid_zero;
>
> -   result +=

Re: [PATCH net-next] drivers: net: Remove unnecessary semicolon

2019-03-01 Thread Sean Wang
On Fri, 2019-03-01 at 16:09 +0800, Yue Haibing wrote:
> From: YueHaibing 
> 
> drivers/net/dsa/mt7530.c:649:3-4: Unneeded semicolon
> drivers/net/ethernet/cisco/enic/enic_clsf.c:35:2-3: Unneeded semicolon
> drivers/net/ethernet/faraday/ftgmac100.c:1640:2-3: Unneeded semicolon
> drivers/net/ethernet/mediatek/mtk_eth_soc.c:229:2-3: Unneeded semicolon
> drivers/net/usb/sr9700.c:437:2-3: Unneeded semicolon
> 
> Remove unneeded semicolon.
> 
> Generated by: scripts/coccinelle/misc/semicolon.cocci
> 

Acked-by: Sean Wang  for mt7530 and mtk_eth_soc 

thanks!

> Signed-off-by: YueHaibing 
> ---
>  drivers/net/dsa/mt7530.c| 2 +-
>  drivers/net/ethernet/cisco/enic/enic_clsf.c | 3 ++-
>  drivers/net/ethernet/faraday/ftgmac100.c| 2 +-
>  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +-
>  drivers/net/usb/sr9700.c| 2 +-
>  5 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index 0390c5e..7357b4f 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
> @@ -646,7 +646,7 @@ static void mt7530_adjust_link(struct dsa_switch *ds, int 
> port,
>   case SPEED_100:
>   mcr |= PMCR_FORCE_SPEED_100;
>   break;
> - };
> + }
>  
>   if (phydev->link)
>   mcr |= PMCR_FORCE_LNK;
> diff --git a/drivers/net/ethernet/cisco/enic/enic_clsf.c 
> b/drivers/net/ethernet/cisco/enic/enic_clsf.c
> index 99038df..9900993 100644
> --- a/drivers/net/ethernet/cisco/enic/enic_clsf.c
> +++ b/drivers/net/ethernet/cisco/enic/enic_clsf.c
> @@ -32,7 +32,8 @@ int enic_addfltr_5t(struct enic *enic, struct flow_keys 
> *keys, u16 rq)
>   break;
>   default:
>   return -EPROTONOSUPPORT;
> - };
> + }
> +
>   data.type = FILTER_IPV4_5TUPLE;
>   data.u.ipv4.src_addr = ntohl(keys->addrs.v4addrs.src);
>   data.u.ipv4.dst_addr = ntohl(keys->addrs.v4addrs.dst);
> diff --git a/drivers/net/ethernet/faraday/ftgmac100.c 
> b/drivers/net/ethernet/faraday/ftgmac100.c
> index 3e5e971..b17b79e 100644
> --- a/drivers/net/ethernet/faraday/ftgmac100.c
> +++ b/drivers/net/ethernet/faraday/ftgmac100.c
> @@ -1637,7 +1637,7 @@ static int ftgmac100_setup_mdio(struct net_device 
> *netdev)
>   reg = ioread32(priv->base + FTGMAC100_OFFSET_REVR);
>   reg &= ~FTGMAC100_REVR_NEW_MDIO_INTERFACE;
>   iowrite32(reg, priv->base + FTGMAC100_OFFSET_REVR);
> - };
> + }
>  
>   /* Get PHY mode from device-tree */
>   if (np) {
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c 
> b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index 94d4663..549d364 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -226,7 +226,7 @@ static void mtk_phy_link_adjust(struct net_device *dev)
>   case SPEED_100:
>   mcr |= MAC_MCR_SPEED_100;
>   break;
> - };
> + }
>  
>   if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_GMAC1_TRGMII) &&
>   !mac->id && !mac->trgmii)
> diff --git a/drivers/net/usb/sr9700.c b/drivers/net/usb/sr9700.c
> index 6ac232e..e04c8054 100644
> --- a/drivers/net/usb/sr9700.c
> +++ b/drivers/net/usb/sr9700.c
> @@ -434,7 +434,7 @@ static int sr9700_rx_fixup(struct usbnet *dev, struct 
> sk_buff *skb)
>   usbnet_skb_return(dev, sr_skb);
>  
>   skb_pull(skb, len + SR_RX_OVERHEAD);
> - };
> + }
>  
>   return 0;
>  }




Re: [PATCH] usb: dwc2: suppress confusing warnings on BCM2835

2019-03-01 Thread Stefan Wahren
Hi Minas,

sorry for the delay, i was too busy with other issues.

> Minas Harutyunyan  hat am 21. Februar 2019 um 
> 08:34 geschrieben:
> 
> 
> Hi Stefan,
> 
> On 2/19/2019 10:23 PM, Stefan Wahren wrote:
> > According to the BCM2835 datasheet the used Synopsys IP isn't a LPM-capable
> > core. So disable these features and suppress these confusing warnings:
> > 
> > dwc2 3f98.usb: dwc2_check_params: Invalid parameter lpm=1
> > dwc2 3f98.usb: dwc2_check_params: Invalid parameter lpm_clock_gating=1
> > dwc2 3f98.usb: dwc2_check_params: Invalid parameter besl=1
> > dwc2 3f98.usb: dwc2_check_params: Invalid parameter hird_threshold_en=1
> > 
> > Signed-off-by: Stefan Wahren 
> > ---
> >   drivers/usb/dwc2/params.c | 4 
> >   1 file changed, 4 insertions(+)
> > 
> > diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
> > index 24ff5f2..a158abb 100644
> > --- a/drivers/usb/dwc2/params.c
> > +++ b/drivers/usb/dwc2/params.c
> > @@ -47,6 +47,10 @@ static void dwc2_set_bcm_params(struct dwc2_hsotg *hsotg)
> > p->max_transfer_size = 65535;
> > p->max_packet_count = 511;
> > p->ahbcfg = 0x10;
> > +   p->lpm = false;
> > +   p->lpm_clock_gating = false;
> > +   p->besl = false;
> > +   p->hird_threshold_en = false;
> >   }
> >   
> >   static void dwc2_set_his_params(struct dwc2_hsotg *hsotg)
> > 
> 
> What about to apply below patch:

yes, this is a more general solution.

Tested-by: Stefan Wahren 

> 
> 
> diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
> index c1912627a032..6b86aa42f003 100644
> --- a/drivers/usb/dwc2/params.c
> +++ b/drivers/usb/dwc2/params.c
> @@ -303,11 +303,17 @@ static void dwc2_set_default_params(struct 
> dwc2_hsotg *hsotg)
>  p->reload_ctl = (hw->snpsid >= DWC2_CORE_REV_2_92a);
>  p->uframe_sched = true;
>  p->external_id_pin_ctl = false;
> -   p->lpm = true;
> -   p->lpm_clock_gating = true;
> -   p->besl = true;
> -   p->hird_threshold_en = true;
> -   p->hird_threshold = 4;
> +   p->lpm = hw->lpm_mode;
> +   if (p->lpm) {
> +   p->lpm_clock_gating = true;
> +   p->besl = true;
> +   p->hird_threshold_en = true;
> +   p->hird_threshold = 4;
> +   } else {
> +   p->lpm_clock_gating = false;
> +   p->besl = false;
> +   p->hird_threshold_en = false;
> +   }
>  p->ipg_isoc_en = false;
>  p->service_interval = false;
>  p->max_packet_count = hw->max_packet_count;
> 
> 
> 
> Thanks,
> Minas
> 
> ___
> linux-arm-kernel mailing list
> linux-arm-ker...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel


Re: [PATCH] USB: usb.h: tweak struct urb to remove wasted space

2019-03-01 Thread Oliver Neukum
On Fr, 2019-03-01 at 18:22 +0100, Greg Kroah-Hartman wrote:
> By moving one field around in 'struct urb' we reduce the size of the
> structure by 8 bytes.

If you are going for this I have to ask why unlink and status
are full size ints anyway.

Regards
Oliver



Re: [PATCH] wusb: Remove unnecessary static function ckhdid_printf

2019-03-01 Thread Greg KH
On Fri, Mar 01, 2019 at 10:18:32AM -0800, Nick Desaulniers wrote:
> On Thu, Feb 28, 2019 at 8:38 PM Joe Perches  wrote:
> >
> > This static inline is unnecessary and can be removed
> > by using the vsprintf %ph extension.
> >
> > This reduces overall object size by more than 2K.
> >
> > Signed-off-by: Joe Perches 
> 
> Deserves a reported by tag from (https://lkml.org/lkml/2019/2/28/1138)
> Reported-by: Louis Taylor 

Good idea, will go add that...


Re: [PATCH v2 08/10] hikey960: Support usb functionality of Hikey960

2019-03-01 Thread Chen Yu
Hi Chunfeng Yun,

On 2019/2/22 15:32, Chunfeng Yun wrote:
> On Tue, 2019-02-19 at 11:20 +0800, Chen Yu wrote:
>> Hi,
>>
>> On 2019/2/19 10:50, Chunfeng Yun wrote:
 +  if (ret)
 +  hisi_hikey_usb->typec_vbus_enable_val = 1;
 +
 +  hisi_hikey_usb->typec_vbus = devm_gpiod_get(dev, "typec-vbus",
 +  hisi_hikey_usb->typec_vbus_enable_val ?
 +  GPIOD_OUT_LOW : GPIOD_OUT_HIGH);
 +  if (!hisi_hikey_usb->typec_vbus)
 +  return -ENOENT;
 +  else if (IS_ERR(hisi_hikey_usb->typec_vbus))
 +  return PTR_ERR(hisi_hikey_usb->typec_vbus);
 +
 +  gpiod_direction_output(hisi_hikey_usb->typec_vbus,
 +  !hisi_hikey_usb->typec_vbus_enable_val);
>>> maybe a simple way if use fixed regulator?
>>>
>> The hardware of the Hikey960 board has been fixed, and the type-c
>> port can act as UFP. So it is better to close the vbus when Hikey960
>> connect to host(e.g PC).
> I guess you misunderstand what I mean?
> Please refer to bindings/regulator/fixed-regulator.txt
> If you control vbus by gpio, you can use fixed-regulator, it will be
> easy to make compatible with other cases, think about using a LDO to
> control vbus
Sorry for misunderstanding the fixed-regulator and thanks for your advice!
I have read bindings/regulator/fixed-regulator.txt and I think it is enough
to use gpiod API right now.
 +
 +  hisi_hikey_usb->otg_switch = devm_gpiod_get(dev, "otg-switch", 
 GPIOD_IN);
 +  if (!hisi_hikey_usb->otg_switch)
 +  return -ENOENT;
 +  else if (IS_ERR(hisi_hikey_usb->otg_switch))
 +  return PTR_ERR(hisi_hikey_usb->otg_switch);
 +
 +  gpiod_direction_output(hisi_hikey_usb->otg_switch, USB_SWITCH_TO_HUB);
 +
 +  /* hub-vdd33-en is optional */
 +  hisi_hikey_usb->hub_vbus = devm_gpiod_get(dev, "hub-vdd33-en",
 +  GPIOD_OUT_LOW);
 +  if (IS_ERR(hisi_hikey_usb->hub_vbus))
 +  return PTR_ERR(hisi_hikey_usb->hub_vbus);
 +
 +  gpiod_direction_output(hisi_hikey_usb->hub_vbus, HUB_VBUS_POWER_ON);
>>> ditto
 +
 +  hisi_hikey_usb->role_sw = usb_role_switch_get(dev);
 +  if (!hisi_hikey_usb->role_sw)
 +  return -EPROBE_DEFER;
 +  else if (IS_ERR(hisi_hikey_usb->role_sw))
 +  return PTR_ERR(hisi_hikey_usb->role_sw);
 +
>>
>> Thanks
>> Yu Chen
>>
> 

Thanks
Yu Chen



[BUG] ASIX AX88179 USB 3.0 Ethernet NICs not sending/receiving frames

2019-03-01 Thread Bradley Chapman

All,

I am trying to get an ASIX AX88179 USB 3.0 dual Ethernet NIC dongle to 
work on an SFF system running Linux 4.20.13. The NICs are properly 
detected and named eth3 and eth4 by udev and I can configure and 
administer them like any other NIC, but neither interface is able to 
fully establish a link beat and exchange Ethernet frames with any 
attached device.


I checked to see if the drivers were still maintained and it appears, 
according to https://github.com/FreddyXin/ax88179_178a, that the drivers 
were last maintained in February 2013. As far as I can tell, I've 
selected all the right Kconfig options for my kernel; I do see some 
stuff under CONFIG_GENERIC_PHY and CONFIG_PHYLIB that might be relevant 
but the documentation is inconsistent.


lsusb -v -t:

/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
|__ Port 2: Dev 2, If 0, Class=hub, Driver=hub/4p, 5000M
|__ Port 1: Dev 3, If 0, Class=vend., Driver=ax88179_178a, 5000M
|__ Port 2: Dev 4, If 0, Class=vend., Driver=ax88179_178a, 5000M

lspci:

04:00.0 USB controller: ASMedia Technology Inc. ASM1042 SuperSpeed USB 
Host Controller


Kconfig:

CONFIG_USB_NET_AX8817X=y
CONFIG_USB_NET_AX88179_178A=y

dmesg snippets:

[0.367286] xhci_hcd :04:00.0: xHCI Host Controller
[0.367289] xhci_hcd :04:00.0: new USB bus registered, assigned 
bus number 3
[0.473915] xhci_hcd :04:00.0: hcc params 0x0200f180 hci version 
0x96 quirks 0x0008

[0.474405] xhci_hcd :04:00.0: xHCI Host Controller
[0.474407] xhci_hcd :04:00.0: new USB bus registered, assigned 
bus number 4

[0.474409] xhci_hcd :04:00.0: Host supports USB 3.0  SuperSpeed
[0.474443] usb usb4: We don't know the algorithms for LPM for this 
host, disabling LPM.

[0.474551] hub 4-0:1.0: USB hub found
[0.474561] hub 4-0:1.0: 2 ports detected
[1.202211] usb 4-2: new SuperSpeed Gen 1 USB device number 2 using 
xhci_hcd

[1.371725] hub 4-2:1.0: USB hub found
[1.371939] hub 4-2:1.0: 4 ports detected
[1.818569] usb 4-2.1: new SuperSpeed Gen 1 USB device number 3 using 
xhci_hcd
[2.525608] ax88179_178a 4-2.1:1.0 eth1: register 'ax88179_178a' at 
usb-:04:00.0-2.1, ASIX AX88179 USB 3.0 Gigabit Ethernet, 
00:0a:cd:2f:24:c9
[2.647403] usb 4-2.2: new SuperSpeed Gen 1 USB device number 4 using 
xhci_hcd
[3.285773] ax88179_178a 4-2.2:1.0 eth3: register 'ax88179_178a' at 
usb-:04:00.0-2.2, ASIX AX88179 USB 3.0 Gigabit Ethernet, 
00:0a:cd:2f:24:c8

[3.294077] ax88179_178a 4-2.2:1.0 eth4: renamed from eth3
[3.310712] ax88179_178a 4-2.1:1.0 eth3: renamed from eth1
[9.887256] ax88179_178a 4-2.1:1.0 eth3: Failed to read reg index 
0x: -110
[   15.007258] ax88179_178a 4-2.1:1.0 eth3: Failed to read reg index 
0x0001: -110
[   20.127228] ax88179_178a 4-2.1:1.0 eth3: Failed to read reg index 
0x0009: -110

[ 1431.076463] IPv6: ADDRCONF(NETDEV_UP): eth3: link is not ready
[ 1436.253354] ax88179_178a 4-2.1:1.0 eth3: Failed to read reg index 
0x: -110
[ 1441.373148] ax88179_178a 4-2.1:1.0 eth3: Failed to read reg index 
0x0001: -110
[ 1446.493014] ax88179_178a 4-2.1:1.0 eth3: Failed to read reg index 
0x0009: -110

[ 1648.735215] ax88179_178a 4-2.1:1.0 eth3: ax88179 - Link status is: 1
[ 1648.742353] IPv6: ADDRCONF(NETDEV_CHANGE): eth3: link becomes ready
[ 1958.264142] ax88179_178a 4-2.1:1.0 eth3: ax88179 - Link status is: 0
[ 1967.224863] ax88179_178a 4-2.1:1.0 eth3: ax88179 - Link status is: 1
[ 1972.293726] ax88179_178a 4-2.1:1.0 eth3: Failed to write reg index 
0x0002: -110

[ 1995.259117] ax88179_178a 4-2.1:1.0 eth3: ax88179 - Link status is: 1
[ 1997.892589] ax88179_178a 4-2.1:1.0 eth3: Failed to read reg index 
0x: -110
[ 2003.012309] ax88179_178a 4-2.1:1.0 eth3: Failed to write reg index 
0x0002: -110
[ 2008.132053] ax88179_178a 4-2.1:1.0 eth3: Failed to write reg index 
0x0002: -110

[ 2032.126090] ax88179_178a 4-2.1:1.0 eth3: ax88179 - Link status is: 1
[ 2171.196246] ax88179_178a 4-2.1:1.0 eth3: Failed to read reg index 
0x0002: -110
[ 2176.315997] ax88179_178a 4-2.1:1.0 eth3: Failed to write reg index 
0x0002: -110

[ 2182.038412] IPv6: ADDRCONF(NETDEV_UP): eth3: link is not ready

The dmesg implies that either the driver or the NICs themselves are not 
able to get a link beat with the connected device (a TP-Link gigabit 
switch).  I tried to interrogate the PHY on each NIC with mii-diag and 
got the following:


Basic registers of MII PHY #3:         .
  No MII transceiver present!.

I checked with ethtool and it returned the following info about each NIC:

ethtool:

Settings for eth3:
Supported ports: [ TP MII ]
Supported link modes:   10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Advertised link modes:  Not reported