Re: [PATCH v2] usb: musb: sunxi: Explicitly release USB PHY on exit

2017-10-16 Thread Bin Liu
On Mon, Oct 16, 2017 at 11:54:27PM +1100, Jonathan Liu wrote:
> On 16 October 2017 at 23:49, Bin Liu  wrote:
> > On Mon, Oct 16, 2017 at 04:13:51PM +1100, Jonathan Liu wrote:
> >> On 10 October 2017 at 14:22, Bin Liu  wrote:
> >> > On Tue, Oct 10, 2017 at 01:45:25PM +1100, Jonathan Liu wrote:
> >> >> This fixes a kernel oops when unloading the driver due to usb_put_phy
> >> >> being called after usb_phy_generic_unregister when the device is
> >> >> detached. Calling usb_phy_generic_unregister causes x->dev->driver to
> >> >> be NULL in usb_put_phy and results in a NULL pointer dereference.
> >> >>
> >> >> Cc: sta...@vger.kernel.org # v4.3+
> >> >> Signed-off-by: Jonathan Liu 
> >> >> ---
> >> >> Changes for v2:
> >> >>  - Use devm_usb_put_phy instead of usb_put_phy
> >> >>
> >> >>  drivers/usb/musb/sunxi.c | 2 ++
> >> >>  1 file changed, 2 insertions(+)
> >> >>
> >> >> diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c
> >> >> index c9a09b5bb6e5..dc353e24d53c 100644
> >> >> --- a/drivers/usb/musb/sunxi.c
> >> >> +++ b/drivers/usb/musb/sunxi.c
> >> >> @@ -297,6 +297,8 @@ static int sunxi_musb_exit(struct musb *musb)
> >> >>   if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, >flags))
> >> >>   sunxi_sram_release(musb->controller->parent);
> >> >>
> >> >> + devm_usb_put_phy(glue->dev, glue->xceiv);
> >> >> +
> >> >>   return 0;
> >> >>  }
> >> >
> >> >
> >>
> >> > Applied. Thanks.
> >> > -Bin.
> >>
> >> Which repository was it applied to?
> >
> > I don't have a public repo (yet), but the patch has been sent to Greg,
> > so it should be merged into the next -rc.
> >
> > Regards,
> > -Bin.
> 
> The MAINTAINERS file has
> git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git listed as
> the tree for drivers/usb/musb/. I guess that should be updated.

I will create a patch for it. Thanks for reporting this.

Regards,
-Bin.
--
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] ARM: dts: r8a7743: Add xhci support to SoC dtsi

2017-10-16 Thread Yoshihiro Shimoda
Hi Biju-san,

IIUC, when we submitted a patch for dts[i] file,
we don't need to submit such a patch to usb maintainers.

> From: Biju Das, Sent: Monday, October 16, 2017 7:13 PM
> 
> From: Fabrizio Castro 
> 
> Add node for xhci. Boards DT files will enable it if needed.
> 
> Signed-off-by: Fabrizio Castro 
> ---
>  arch/arm/boot/dts/r8a7743.dtsi | 20 
>  1 file changed, 20 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/r8a7743.dtsi b/arch/arm/boot/dts/r8a7743.dtsi
> index 699c040..386bf07 100644
> --- a/arch/arm/boot/dts/r8a7743.dtsi
> +++ b/arch/arm/boot/dts/r8a7743.dtsi
> @@ -931,6 +931,26 @@
>   status = "disabled";
>   };
> 
> + /*
> +  * pci1 and xhci share the same phy, therefore only one of them
> +  * can be active at any one time. If both of them are enabled,
> +  * a race condition will determine who'll control the phy.
> +  * A firmware file is needed by the xhci driver in order for
> +  * USB 3.0 to work properly.
> +  */
> + xhci: usb@ee00 {
> + compatible = "renesas,xhci-r8a7743",
> +  "renesas,rcar-gen2-xhci";
> + reg = <0 0xee00 0 0xc00>;
> + interrupts = ;
> + clocks = < CPG_MOD 328>;
> + power-domains = < R8A7743_PD_ALWAYS_ON>;
> + resets = < 328>;
> + phys = < 1>;
> + phy-names = "usb";
> + status = "disabled";
> + };
> +
>   sdhi0: sd@ee10 {
>   compatible = "renesas,sdhi-r8a7743";
>   reg = <0 0xee10 0 0x328>;

It seems good to me. So,

Reviewed-by: Yoshihiro Shimoda 

Best regards,
Yoshihiro Shimoda

> --
> 1.9.1

--
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 07/58] net/usb/usbnet: Convert timers to use timer_setup()

2017-10-16 Thread Kees Cook
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly. Since the callback is called from
both a timer and a tasklet, adjust the tasklet to pass the timer address
too. When tasklets have their .data field removed, this can be refactored
to call a central function after resolving the correct container_of() for a
separate callback function for timer and tasklet.

Cc: Oliver Neukum 
Cc: net...@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Signed-off-by: Kees Cook 
---
 drivers/net/usb/usbnet.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 6510e5cc1817..80348b6a8646 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1509,9 +1509,9 @@ static int rx_alloc_submit(struct usbnet *dev, gfp_t 
flags)
 
 // tasklet (work deferred from completions, in_irq) or timer
 
-static void usbnet_bh (unsigned long param)
+static void usbnet_bh (struct timer_list *t)
 {
-   struct usbnet   *dev = (struct usbnet *) param;
+   struct usbnet   *dev = from_timer(dev, t, delay);
struct sk_buff  *skb;
struct skb_data *entry;
 
@@ -1694,13 +1694,11 @@ usbnet_probe (struct usb_interface *udev, const struct 
usb_device_id *prod)
skb_queue_head_init (>txq);
skb_queue_head_init (>done);
skb_queue_head_init(>rxq_pause);
-   dev->bh.func = usbnet_bh;
-   dev->bh.data = (unsigned long) dev;
+   dev->bh.func = (void (*)(unsigned long))usbnet_bh;
+   dev->bh.data = (unsigned long)>delay;
INIT_WORK (>kevent, usbnet_deferred_kevent);
init_usb_anchor(>deferred);
-   dev->delay.function = usbnet_bh;
-   dev->delay.data = (unsigned long) dev;
-   init_timer (>delay);
+   timer_setup(>delay, usbnet_bh, 0);
mutex_init (>phy_mutex);
mutex_init(>interrupt_mutex);
dev->interrupt_count = 0;
-- 
2.7.4

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


[PATCH 48/58] net: usb: Convert timers to use timer_setup()

2017-10-16 Thread Kees Cook
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Woojung Huh 
Cc: Microchip Linux Driver Support 
Cc: "David S. Miller" 
Cc: Ben Hutchings 
Cc: Philippe Reynes 
Cc: Jarod Wilson 
Cc: Arvind Yadav 
Cc: "Bjørn Mork" 
Cc: "Stefan Brüns" 
Cc: Alexey Dobriyan 
Cc: Greg Ungerer 
Cc: linux-usb@vger.kernel.org
Cc: net...@vger.kernel.org
Signed-off-by: Kees Cook 
---
 drivers/net/usb/catc.c   |  6 +++---
 drivers/net/usb/lan78xx.c| 10 +++---
 drivers/net/usb/sierra_net.c | 12 
 3 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/drivers/net/usb/catc.c b/drivers/net/usb/catc.c
index aeb62e17d19d..18d36dff97ea 100644
--- a/drivers/net/usb/catc.c
+++ b/drivers/net/usb/catc.c
@@ -611,9 +611,9 @@ static void catc_stats_done(struct catc *catc, struct 
ctrl_queue *q)
catc->stats_vals[index >> 1] = data;
 }
 
-static void catc_stats_timer(unsigned long data)
+static void catc_stats_timer(struct timer_list *t)
 {
-   struct catc *catc = (void *) data;
+   struct catc *catc = from_timer(catc, t, timer);
int i;
 
for (i = 0; i < 8; i++)
@@ -805,7 +805,7 @@ static int catc_probe(struct usb_interface *intf, const 
struct usb_device_id *id
spin_lock_init(>tx_lock);
spin_lock_init(>ctrl_lock);
 
-   setup_timer(>timer, catc_stats_timer, (long)catc);
+   timer_setup(>timer, catc_stats_timer, 0);
 
catc->ctrl_urb = usb_alloc_urb(0, GFP_KERNEL);
catc->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 0161f77641fa..94c7804903c4 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -3516,11 +3516,9 @@ static const struct net_device_ops lan78xx_netdev_ops = {
.ndo_vlan_rx_kill_vid   = lan78xx_vlan_rx_kill_vid,
 };
 
-static void lan78xx_stat_monitor(unsigned long param)
+static void lan78xx_stat_monitor(struct timer_list *t)
 {
-   struct lan78xx_net *dev;
-
-   dev = (struct lan78xx_net *)param;
+   struct lan78xx_net *dev = from_timer(dev, t, stat_monitor);
 
lan78xx_defer_kevent(dev, EVENT_STAT_UPDATE);
 }
@@ -3571,10 +3569,8 @@ static int lan78xx_probe(struct usb_interface *intf,
netdev->watchdog_timeo = TX_TIMEOUT_JIFFIES;
netdev->ethtool_ops = _ethtool_ops;
 
-   dev->stat_monitor.function = lan78xx_stat_monitor;
-   dev->stat_monitor.data = (unsigned long)dev;
dev->delta = 1;
-   init_timer(>stat_monitor);
+   timer_setup(>stat_monitor, lan78xx_stat_monitor, 0);
 
mutex_init(>stats.access_lock);
 
diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
index 2110ab3513f0..c43087e06696 100644
--- a/drivers/net/usb/sierra_net.c
+++ b/drivers/net/usb/sierra_net.c
@@ -189,9 +189,6 @@ struct lsi_umts_dual {
 #define SIERRA_NET_LSI_UMTS_DS_STATUS_LEN \
(SIERRA_NET_LSI_UMTS_DS_LEN - SIERRA_NET_LSI_COMMON_LEN)
 
-/* Forward definitions */
-static void sierra_sync_timer(unsigned long syncdata);
-
 /* Our own net device operations structure */
 static const struct net_device_ops sierra_net_device_ops = {
.ndo_open   = usbnet_open,
@@ -475,8 +472,6 @@ static void sierra_net_dosync(struct usbnet *dev)
"Send SYNC failed, status %d\n", status);
 
/* Now, start a timer and make sure we get the Restart Indication */
-   priv->sync_timer.function = sierra_sync_timer;
-   priv->sync_timer.data = (unsigned long) dev;
priv->sync_timer.expires = jiffies + SIERRA_NET_SYNCDELAY;
add_timer(>sync_timer);
 }
@@ -593,9 +588,10 @@ static void sierra_net_defer_kevent(struct usbnet *dev, 
int work)
 /*
  * Sync Retransmit Timer Handler. On expiry, kick the work queue
  */
-static void sierra_sync_timer(unsigned long syncdata)
+static void sierra_sync_timer(struct timer_list *t)
 {
-   struct usbnet *dev = (struct usbnet *)syncdata;
+   struct sierra_net_data *priv = from_timer(priv, t, sync_timer);
+   struct usbnet *dev = priv->usbnet;
 
dev_dbg(>udev->dev, "%s", __func__);
/* Kick the tasklet */
@@ -752,7 +748,7 @@ static int sierra_net_bind(struct usbnet *dev, struct 
usb_interface *intf)
INIT_WORK(>sierra_net_kevent, sierra_net_kevent);
 
/* Only need to do this once */
-   init_timer(>sync_timer);
+   timer_setup(>sync_timer, sierra_sync_timer, 0);
 
/* verify fw attributes */
status = sierra_net_get_fw_attr(dev, );
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of 

Re: [PATCH v2 09/15] ACPI: configfs: make config_item_type const

2017-10-16 Thread Rafael J. Wysocki
On Monday, October 16, 2017 5:18:48 PM CEST Bhumika Goyal wrote:
> Make these structures const as they are either passed to the functions
> having the argument as const or stored as a reference in the "ci_type"
> const field of a config_item structure.
> 
> Done using Coccienlle.
> 
> Signed-off-by: Bhumika Goyal 
> ---
> * Changes in v2- Combine all the followup patches and the constification
> patches into a series.
> 
>  drivers/acpi/acpi_configfs.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/acpi/acpi_configfs.c b/drivers/acpi/acpi_configfs.c
> index 853bc7f..b588503 100644
> --- a/drivers/acpi/acpi_configfs.c
> +++ b/drivers/acpi/acpi_configfs.c
> @@ -204,7 +204,7 @@ struct configfs_attribute *acpi_table_attrs[] = {
>   NULL,
>  };
>  
> -static struct config_item_type acpi_table_type = {
> +static const struct config_item_type acpi_table_type = {
>   .ct_owner = THIS_MODULE,
>   .ct_bin_attrs = acpi_table_bin_attrs,
>   .ct_attrs = acpi_table_attrs,
> @@ -237,12 +237,12 @@ struct configfs_group_operations acpi_table_group_ops = 
> {
>   .drop_item = acpi_table_drop_item,
>  };
>  
> -static struct config_item_type acpi_tables_type = {
> +static const struct config_item_type acpi_tables_type = {
>   .ct_owner = THIS_MODULE,
>   .ct_group_ops = _table_group_ops,
>  };
>  
> -static struct config_item_type acpi_root_group_type = {
> +static const struct config_item_type acpi_root_group_type = {
>   .ct_owner = THIS_MODULE,
>  };
>  
> 

Acked-by: Rafael J. Wysocki 


--
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: phy: Convert timers to use timer_setup()

2017-10-16 Thread Kees Cook
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: linux-usb@vger.kernel.org
Signed-off-by: Kees Cook 
---
 drivers/usb/phy/phy-mv-usb.c | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index 0e315694adc9..fc9ed047d25d 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -87,9 +87,10 @@ static void mv_otg_run_state_machine(struct mv_otg *mvotg,
queue_delayed_work(mvotg->qwork, >work, delay);
 }
 
-static void mv_otg_timer_await_bcon(unsigned long data)
+static void mv_otg_timer_await_bcon(struct timer_list *t)
 {
-   struct mv_otg *mvotg = (struct mv_otg *) data;
+   struct mv_otg *mvotg = from_timer(mvotg, t,
+ otg_ctrl.timer[A_WAIT_BCON_TIMER]);
 
mvotg->otg_ctrl.a_wait_bcon_timeout = 1;
 
@@ -117,8 +118,7 @@ static int mv_otg_cancel_timer(struct mv_otg *mvotg, 
unsigned int id)
 }
 
 static int mv_otg_set_timer(struct mv_otg *mvotg, unsigned int id,
-   unsigned long interval,
-   void (*callback) (unsigned long))
+   unsigned long interval)
 {
struct timer_list *timer;
 
@@ -131,9 +131,6 @@ static int mv_otg_set_timer(struct mv_otg *mvotg, unsigned 
int id,
return -EBUSY;
}
 
-   init_timer(timer);
-   timer->data = (unsigned long) mvotg;
-   timer->function = callback;
timer->expires = jiffies + interval;
add_timer(timer);
 
@@ -459,8 +456,7 @@ static void mv_otg_work(struct work_struct *work)
if (old_state != OTG_STATE_A_HOST)
mv_otg_start_host(mvotg, 1);
mv_otg_set_timer(mvotg, A_WAIT_BCON_TIMER,
-T_A_WAIT_BCON,
-mv_otg_timer_await_bcon);
+T_A_WAIT_BCON);
/*
 * Now, we directly enter A_HOST. So set b_conn = 1
 * here. In fact, it need host driver to notify us.
@@ -722,7 +718,8 @@ static int mv_otg_probe(struct platform_device *pdev)
otg->set_vbus = mv_otg_set_vbus;
 
for (i = 0; i < OTG_TIMER_NUM; i++)
-   init_timer(>otg_ctrl.timer[i]);
+   timer_setup(>otg_ctrl.timer[i],
+   mv_otg_timer_await_bcon, 0);
 
r = platform_get_resource_byname(mvotg->pdev,
 IORESOURCE_MEM, "phyregs");
-- 
2.7.4


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


[PATCH] usb/gadget/snps_udc_core: Convert timers to use timer_setup()

2017-10-16 Thread Kees Cook
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

If the probe fails, udc_remove() will not be called, so there is no
reason to make del_timer_sync() calls conditional. As a result, use of
the .data field can be dropped, in support of making removing this field
entirely from struct timer_list.

Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: Raviteja Garimella 
Cc: Michal Nazarewicz 
Cc: "Gustavo A. R. Silva" 
Cc: linux-usb@vger.kernel.org
Signed-off-by: Kees Cook 
---
 drivers/usb/gadget/udc/snps_udc_core.c | 19 ++-
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/gadget/udc/snps_udc_core.c 
b/drivers/usb/gadget/udc/snps_udc_core.c
index 47df99dbaef4..2f5e788dd978 100644
--- a/drivers/usb/gadget/udc/snps_udc_core.c
+++ b/drivers/usb/gadget/udc/snps_udc_core.c
@@ -1733,7 +1733,7 @@ static void udc_soft_reset(struct udc *dev)
 }
 
 /* RDE timer callback to set RDE bit */
-static void udc_timer_function(unsigned long v)
+static void udc_timer_function(struct timer_list *unused)
 {
u32 tmp;
 
@@ -1813,7 +1813,7 @@ static void udc_handle_halt_state(struct udc_ep *ep)
 }
 
 /* Stall timer callback to poll S bit and set it again after */
-static void udc_pollstall_timer_function(unsigned long v)
+static void udc_pollstall_timer_function(struct timer_list *unused)
 {
struct udc_ep *ep;
int halted = 0;
@@ -3067,14 +3067,12 @@ void udc_remove(struct udc *dev)
stop_timer++;
if (timer_pending(_timer))
wait_for_completion(_exit);
-   if (udc_timer.data)
-   del_timer_sync(_timer);
+   del_timer_sync(_timer);
/* remove pollstall timer */
stop_pollstall_timer++;
if (timer_pending(_pollstall_timer))
wait_for_completion(_pollstall_exit);
-   if (udc_pollstall_timer.data)
-   del_timer_sync(_pollstall_timer);
+   del_timer_sync(_pollstall_timer);
udc = NULL;
 }
 EXPORT_SYMBOL_GPL(udc_remove);
@@ -3164,10 +3162,6 @@ int udc_probe(struct udc *dev)
u32 reg;
int retval;
 
-   /* mark timer as not initialized */
-   udc_timer.data = 0;
-   udc_pollstall_timer.data = 0;
-
/* device struct setup */
dev->gadget.ops = _ops;
 
@@ -3207,9 +3201,8 @@ int udc_probe(struct udc *dev)
goto finished;
 
/* timer init */
-   setup_timer(_timer, udc_timer_function, 1);
-   /* timer pollstall init */
-   setup_timer(_pollstall_timer, udc_pollstall_timer_function, 1);
+   timer_setup(_timer, udc_timer_function, 0);
+   timer_setup(_pollstall_timer, udc_pollstall_timer_function, 0);
 
/* set SD */
reg = readl(>regs->ctl);
-- 
2.7.4


-- 
Kees Cook
Pixel Security
--
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: isp1301-omap: Convert timers to use timer_setup()

2017-10-16 Thread Kees Cook
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: linux-usb@vger.kernel.org
Cc: linux-o...@vger.kernel.org
Signed-off-by: Kees Cook 
Acked-by: Tony Lindgren 
---
 drivers/usb/phy/phy-isp1301-omap.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/phy-isp1301-omap.c 
b/drivers/usb/phy/phy-isp1301-omap.c
index 8a07ce63b92d..00bcc6c6db17 100644
--- a/drivers/usb/phy/phy-isp1301-omap.c
+++ b/drivers/usb/phy/phy-isp1301-omap.c
@@ -1183,9 +1183,11 @@ static irqreturn_t isp1301_irq(int irq, void *isp)
return IRQ_HANDLED;
 }
 
-static void isp1301_timer(unsigned long _isp)
+static void isp1301_timer(struct timer_list *t)
 {
-   isp1301_defer_work((void *)_isp, WORK_TIMER);
+   struct isp1301 *isp = from_timer(isp, t, timer);
+
+   isp1301_defer_work(isp, WORK_TIMER);
 }
 
 /*-*/
@@ -1506,7 +1508,7 @@ isp1301_probe(struct i2c_client *i2c, const struct 
i2c_device_id *id)
}
 
INIT_WORK(>work, isp1301_work);
-   setup_timer(>timer, isp1301_timer, (unsigned long)isp);
+   timer_setup(>timer, isp1301_timer, 0);
 
i2c_set_clientdata(i2c, isp);
isp->client = i2c;
-- 
2.7.4


-- 
Kees Cook
Pixel Security
--
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] xhci: Convert timers to use timer_setup()

2017-10-16 Thread Kees Cook
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Mathias Nyman 
Cc: Greg Kroah-Hartman 
Cc: linux-usb@vger.kernel.org
Signed-off-by: Kees Cook 
---
 drivers/usb/host/xhci-mem.c  | 4 ++--
 drivers/usb/host/xhci-ring.c | 9 +++--
 drivers/usb/host/xhci.h  | 2 +-
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index b81a2317420b..795219a397d3 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -800,8 +800,8 @@ void xhci_free_stream_info(struct xhci_hcd *xhci,
 static void xhci_init_endpoint_timer(struct xhci_hcd *xhci,
struct xhci_virt_ep *ep)
 {
-   setup_timer(>stop_cmd_timer, xhci_stop_endpoint_command_watchdog,
-   (unsigned long)ep);
+   timer_setup(>stop_cmd_timer, xhci_stop_endpoint_command_watchdog,
+   0);
ep->xhci = xhci;
 }
 
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 4764121ba2b1..e35eed16c842 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -947,15 +947,12 @@ void xhci_hc_died(struct xhci_hcd *xhci)
  * Instead we use a combination of that flag and checking if a new timer is
  * pending.
  */
-void xhci_stop_endpoint_command_watchdog(unsigned long arg)
+void xhci_stop_endpoint_command_watchdog(struct timer_list *t)
 {
-   struct xhci_hcd *xhci;
-   struct xhci_virt_ep *ep;
+   struct xhci_virt_ep *ep = from_timer(ep, t, stop_cmd_timer);
+   struct xhci_hcd *xhci = ep->xhci;
unsigned long flags;
 
-   ep = (struct xhci_virt_ep *) arg;
-   xhci = ep->xhci;
-
spin_lock_irqsave(>lock, flags);
 
/* bail out if cmd completed but raced with stop ep watchdog timer.*/
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index b966cd878351..86df906aec46 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -2076,7 +2076,7 @@ void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci,
struct xhci_dequeue_state *deq_state);
 void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci, unsigned int ep_index,
unsigned int stream_id, struct xhci_td *td);
-void xhci_stop_endpoint_command_watchdog(unsigned long arg);
+void xhci_stop_endpoint_command_watchdog(struct timer_list *t);
 void xhci_handle_command_timeout(struct work_struct *work);
 
 void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id,
-- 
2.7.4


-- 
Kees Cook
Pixel Security
--
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: [RESEND x2][PATCH 0/3] dwc2 fixes for edge cases on hikey

2017-10-16 Thread John Stultz
On Mon, Oct 16, 2017 at 1:36 AM, Minas Harutyunyan
 wrote:
> On b-plug disconnect should asserted GOTGINT.SesEndDet interrupt.
> According previously sent by you register dump (GHWCFG2 = 0x23affc70)
> your core OTG_MODE=0.
> Bellow fragment from programming guide on Device disconnect:
>
> "7.3Device Disconnection
> The device session ends when the USB cable is disconnected or if the
> VBUS is switched off by the Host. The
> device disconnect flow varies depending on the value of the OTG_MODE
> configuration parameter.
>
> When OTG_MODE = 0,1, or 3
> When OTG_MODE is set to 0,1, or 3, the device disconnect flow is as follows:
> 1. When the USB cable is unplugged or when the VBUS is switched off by
> the Host, the Device core
> trigger GINTSTS.OTGInt [bit 2] interrupt bit.
> 2. When the device application detects GINTSTS.OTGInt interrupt, it
> checks that the
> GOTGINT.SesEndDet (Session End Detected) bit is set to 1’b1."
>
> So, you should receive and handle "Session End Detected". In function
> dwc2_handle_otg_intr() on this interrupt (in device mode) calling
> dwc2_hsotg_disconnect() function. By adding your patch "[PATCH 3/3] usb:
> dwc2: Fix UDC state tracking" state changed to not attached as required.


So, on the HiKey board (using 4.14-rc5 + Vardan's patch), I'm not
seeing the GOTGINT_SES_END_DET in dwc2_handle_otg_intr() when I remove
the USB OTG cable.

In fact, I'm not seeing any calls to dwc2_handle_otg_intr()... which
seems... odd maybe?  Any clues as to what might be going wrong then?

thanks
-john
--
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 Jules Maselbas
Thanks Sergei,

Is it better if the documentation say:
"
Optional property:
 - interrupt-parent: the phandle of the associated interrupt controller.
"
or should I also add that "it may be inherited from the parent nodes."?

Jules Maselbas.

- Mail original -
De: "Sergei Shtylyov" 
À: "Jules Maselbas" , 
gre...@linuxfoundation.org
Cc: "julia lawall" , r...@kernel.org, "mark rutland" 
, devicet...@vger.kernel.org, linux-usb@vger.kernel.org
Envoyé: Lundi 16 Octobre 2017 22:21:53
Objet: Re: [PATCH v2 2/2] dt-bindings: max3421: Add bindings documentation

On 10/16/2017 12:04 PM, Sergei Shtylyov 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.

   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: usb: dwc2: NMI watchdog: BUG: soft lockup - CPU#0 stuck for 146s

2017-10-16 Thread Julius Werner
> d9a14b00 339317035 C Ii:1:004:1 -32:1 0
> d9a14b00 339317049 S Ii:1:004:1 -115:1 10 <
> d9a14b00 339318040 C Ii:1:004:1 -32:1 0
> d9a14b00 339318057 S Ii:1:004:1 -115:1 10 <
> d9a14b00 339319042 C Ii:1:004:1 -32:1 0
> d9a14b00 339319056 S Ii:1:004:1 -115:1 10 <
> d9a14b00 339329551 C Ii:1:004:1 -32:1 0
> d9a14b00 339329571 S Ii:1:004:1 -115:1 10 <
> d9a14b00 339330586 C Ii:1:004:1 -32:1 0
> d9a14b00 339330601 S Ii:1:004:1 -115:1 10 <
> d9a14b00 339331035 C Ii:1:004:1 -32:1 0

Sorry for necromancing an old thread, but I just happened to read
through this and thought someone might care:

If I read that right, the usbmon output shows that the interrupt
endpoint is stalled (keeps returning -EPIPE). A STALL is a special
device-side USB condition that tells the host something is wrong and
will persist until cleared manually. It seems that the driver isn't
prepared for this (see
drivers/usb/serial/pl2303.c#pl2303_read_int_callback) and just keeps
resubmitting the URB, so it will stall again as fast as the endpoint
allows it to. This may be the reason why you get so many transfers
that it overwhelms the CPU.

A fix would be to catch -EPIPE in that function and handle it
explicitly (with either a CLEAR_STALL to the endpoint or a full USB
reset... would have to look at the documentation for PL2303 to see
what the stall actually means and how you're supposed to treat it).
--
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 
---
  .../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] usb: hub: Allow reset retry for USB2 devices on connect bounce

2017-10-16 Thread Alan Stern
On Mon, 16 Oct 2017, Mathias Nyman wrote:

> If the connect status change is set during reset signaling, but
> the status remains connected just retry port reset.
> 
> This solves an issue with connecting a 90W HP Thunderbolt 3 dock
> with a Lenovo Carbon x1 (5th generation) which causes a 30min loop
> of a high speed device being re-discovererd before usb ports starts
> working.
> 
> [...]
> [ 389.023845] usb 3-1: new high-speed USB device number 55 using xhci_hcd
> [ 389.491841] usb 3-1: new high-speed USB device number 56 using xhci_hcd
> [ 389.959928] usb 3-1: new high-speed USB device number 57 using xhci_hcd
> [...]
> 
> This is caused by a high speed device that doesn't successfully go to the
> enabled state after the second port reset. Instead the connection bounces
> (connected, with connect status change), bailing out completely from
> enumeration just to restart from scratch.
> 
> Link: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1716332
> 
> Cc: Stable 
> Signed-off-by: Mathias Nyman 
> ---
>  drivers/usb/core/hub.c | 10 +++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index 41eaf0b..3461347 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -2710,13 +2710,13 @@ static int hub_port_wait_reset(struct usb_hub *hub, 
> int port1,
>   if (!(portstatus & USB_PORT_STAT_CONNECTION))
>   return -ENOTCONN;
>  
> - /* bomb out completely if the connection bounced.  A USB 3.0
> -  * connection may bounce if multiple warm resets were issued,
> + /* Retry if connect change is set but status is still connected.
> +  * A USB 3.0 connection may bounce if multiple warm resets were issued,
>* but the device may have successfully re-connected. Ignore it.
>*/
>   if (!hub_is_superspeed(hub->hdev) &&
>   (portchange & USB_PORT_STAT_C_CONNECTION))
> - return -ENOTCONN;
> + return -EAGAIN;
>  
>   if (!(portstatus & USB_PORT_STAT_ENABLE))
>   return -EBUSY;
> @@ -2789,6 +2789,10 @@ static int hub_port_reset(struct usb_hub *hub, int 
> port1,
>   dev_dbg(hub->intfdev,
>   "port_wait_reset: err = %d\n",
>   status);
> + /* USB2 connection bounced, but remains connected */
> + if (status == -EAGAIN)
> + usb_clear_port_feature(hub->hdev, port1,
> + USB_PORT_FEAT_C_CONNECTION);

There's something very awkward about issuing this call here.  For one
thing, we don't really know at this point that the C_CONNECTION port
status bit is set; we only know that the reset needs to be retried.  
For another, about 14 lines lower down the routine already clears that
status bit anyway (although not for the USB-2.0 case).

In fact, it's awkward that we issue a bunch of unconditional
Clear-Port-Feature calls just below this point, without knowing whether
the corresponding status bits are set.  Ideally, hub_port_wait_reset() 
would return its portstatus and portchange values.  Or it would clear 
the extra status bits by itself.  Maybe that can all be cleaned up in a 
later patch.

Also, does this fully solve the problem?  I can see that it would 
prevent the lengthy repeated rediscoveries, but wouldn't it also 
prevent the device from working at all after the first few resets 
failed?

Alan Stern

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


Re: [PATCH 4.14 REGRESSION fix] USB: devio: Revert "USB: devio: Don't corrupt user memory"

2017-10-16 Thread Alan Stern
On Mon, 16 Oct 2017, Hans de Goede wrote:

> Taking the uurb->buffer_length userspace passes in as a maximum for the
> actual urbs transfer_buffer_length causes 2 serious issues:
> 
> 1) It breaks isochronous support for all userspace apps using libusb,
>as existing libusb versions pass in 0 for uurb->buffer_length,
>relying on the kernel using the lenghts of the usbdevfs_iso_packet_desc
>descriptors passed in added together as buffer length.
> 
>This for example causes redirection of USB audio and Webcam's into
>virtual machines using qemu-kvm to no longer work. This is a userspace
>ABI break and as such must be reverted.
> 
>Note that the original commit does not protect other users / the
>kernels memory, it only stops the userspace process making the call
>from shooting itself in the foot.

Okay, breaking userspace is reason enough all by itself to revert this
change.  I didn't realize that libusb sets the buffer_length to 0 for
isochronous URBs.

> 2) It may cause the kernel to program host controllers to DMA over random
>memory. Just as the devio code used to only look at the iso_packet_desc
>lenghts, the host drivers do the same, relying on the submitter of the
>urbs to make sure the entire buffer is large enough and not checking
>transfer_buffer_length.
> 
>But the "USB: devio: Don't corrupt user memory" commit now takes the
>userspace provided uurb->buffer_length for the buffer-size while copying
>over the user-provided iso_packet_desc lengths 1:1, allowing the user
>to specify a small buffer size while programming the host controller to
>dma a lot more data.

Wow!  You're right, of course.  I don't know what I was thinking when I 
reviewed that patch.

>(Atleast the ohci, uhci, xhci and fhci drivers do not check
> transfer_buffer_length for isoc transfers.)
> 
> This reverts commit fa1ed74eb1c2 ("USB: devio: Don't corrupt user memory")
> fixing both these issues.
> 
> Cc: Dan Carpenter 
> Cc: Alan Stern 
> Cc: Greg Kroah-Hartman 
> Cc: sta...@vger.kernel.org
> Signed-off-by: Hans de Goede 
> ---
>  drivers/usb/core/devio.c | 6 +-
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
> index 4664e543cf2f..e9326f31db8d 100644
> --- a/drivers/usb/core/devio.c
> +++ b/drivers/usb/core/devio.c
> @@ -1576,11 +1576,7 @@ static int proc_do_submiturb(struct usb_dev_state *ps, 
> struct usbdevfs_urb *uurb
>   totlen += isopkt[u].length;
>   }
>   u *= sizeof(struct usb_iso_packet_descriptor);
> - if (totlen <= uurb->buffer_length)
> - uurb->buffer_length = totlen;
> - else
> - WARN_ONCE(1, "uurb->buffer_length is too short %d vs 
> %d",
> -   totlen, uurb->buffer_length);
> + uurb->buffer_length = totlen;
>   break;
>  
>   default:

For what it's worth:

Acked-by: Alan Stern 

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


Re: [PATCH v2 04/15] iio: make function argument and some structures const

2017-10-16 Thread Jonathan Cameron


On 16 October 2017 16:18:43 BST, Bhumika Goyal  wrote:
>Make the argument of the functions iio_sw{d/t}_group_init_type_name
>const
>as they are only passed to the function config_group_init_type_name
>having
>the argument as const.
>
>Make the config_item_type structures const as they are either passed to
>the functions having the argument as const or they are
>stored in the const "ci_type" field of a config_item structure.
>
>Signed-off-by: Bhumika Goyal 
Acked-by: Jonathan Cameron 
>---
>* Changes in v2- Combine all the followup patches and the
>constification
>patches into a series.
>
> drivers/iio/dummy/iio_simple_dummy.c   | 2 +-
> drivers/iio/industrialio-configfs.c| 2 +-
> drivers/iio/industrialio-sw-device.c   | 6 +++---
> drivers/iio/industrialio-sw-trigger.c  | 6 +++---
> drivers/iio/trigger/iio-trig-hrtimer.c | 2 +-
> drivers/iio/trigger/iio-trig-loop.c| 2 +-
> include/linux/iio/sw_device.h  | 2 +-
> include/linux/iio/sw_trigger.h | 2 +-
> 8 files changed, 12 insertions(+), 12 deletions(-)
>
>diff --git a/drivers/iio/dummy/iio_simple_dummy.c
>b/drivers/iio/dummy/iio_simple_dummy.c
>index a45d01e..6205247 100644
>--- a/drivers/iio/dummy/iio_simple_dummy.c
>+++ b/drivers/iio/dummy/iio_simple_dummy.c
>@@ -26,7 +26,7 @@
> #include 
> #include "iio_simple_dummy.h"
> 
>-static struct config_item_type iio_dummy_type = {
>+static const struct config_item_type iio_dummy_type = {
>   .ct_owner = THIS_MODULE,
> };
> 
>diff --git a/drivers/iio/industrialio-configfs.c
>b/drivers/iio/industrialio-configfs.c
>index 45ce2bc..5a0aae1 100644
>--- a/drivers/iio/industrialio-configfs.c
>+++ b/drivers/iio/industrialio-configfs.c
>@@ -17,7 +17,7 @@
> #include 
> #include 
> 
>-static struct config_item_type iio_root_group_type = {
>+static const struct config_item_type iio_root_group_type = {
>   .ct_owner   = THIS_MODULE,
> };
> 
>diff --git a/drivers/iio/industrialio-sw-device.c
>b/drivers/iio/industrialio-sw-device.c
>index 81b49cf..90df97c 100644
>--- a/drivers/iio/industrialio-sw-device.c
>+++ b/drivers/iio/industrialio-sw-device.c
>@@ -19,9 +19,9 @@
> #include 
> 
> static struct config_group *iio_devices_group;
>-static struct config_item_type iio_device_type_group_type;
>+static const struct config_item_type iio_device_type_group_type;
> 
>-static struct config_item_type iio_devices_group_type = {
>+static const struct config_item_type iio_devices_group_type = {
>   .ct_owner = THIS_MODULE,
> };
> 
>@@ -156,7 +156,7 @@ static void device_drop_group(struct config_group
>*group,
>   .drop_item  = _drop_group,
> };
> 
>-static struct config_item_type iio_device_type_group_type = {
>+static const struct config_item_type iio_device_type_group_type = {
>   .ct_group_ops = _ops,
>   .ct_owner   = THIS_MODULE,
> };
>diff --git a/drivers/iio/industrialio-sw-trigger.c
>b/drivers/iio/industrialio-sw-trigger.c
>index 8d24fb1..bc6b7fb 100644
>--- a/drivers/iio/industrialio-sw-trigger.c
>+++ b/drivers/iio/industrialio-sw-trigger.c
>@@ -19,9 +19,9 @@
> #include 
> 
> static struct config_group *iio_triggers_group;
>-static struct config_item_type iio_trigger_type_group_type;
>+static const struct config_item_type iio_trigger_type_group_type;
> 
>-static struct config_item_type iio_triggers_group_type = {
>+static const struct config_item_type iio_triggers_group_type = {
>   .ct_owner = THIS_MODULE,
> };
> 
>@@ -156,7 +156,7 @@ static void trigger_drop_group(struct config_group
>*group,
>   .drop_item  = _drop_group,
> };
> 
>-static struct config_item_type iio_trigger_type_group_type = {
>+static const struct config_item_type iio_trigger_type_group_type = {
>   .ct_group_ops = _ops,
>   .ct_owner   = THIS_MODULE,
> };
>diff --git a/drivers/iio/trigger/iio-trig-hrtimer.c
>b/drivers/iio/trigger/iio-trig-hrtimer.c
>index 3ee9216..7accd01 100644
>--- a/drivers/iio/trigger/iio-trig-hrtimer.c
>+++ b/drivers/iio/trigger/iio-trig-hrtimer.c
>@@ -30,7 +30,7 @@ struct iio_hrtimer_info {
>   ktime_t period;
> };
> 
>-static struct config_item_type iio_hrtimer_type = {
>+static const struct config_item_type iio_hrtimer_type = {
>   .ct_owner = THIS_MODULE,
> };
> 
>diff --git a/drivers/iio/trigger/iio-trig-loop.c
>b/drivers/iio/trigger/iio-trig-loop.c
>index b4b02db..94a90e0 100644
>--- a/drivers/iio/trigger/iio-trig-loop.c
>+++ b/drivers/iio/trigger/iio-trig-loop.c
>@@ -36,7 +36,7 @@ struct iio_loop_info {
>   struct task_struct *task;
> };
> 
>-static struct config_item_type iio_loop_type = {
>+static const struct config_item_type iio_loop_type = {
>   .ct_owner = THIS_MODULE,
> };
> 
>diff --git a/include/linux/iio/sw_device.h
>b/include/linux/iio/sw_device.h
>index fa79319..8642b91 100644
>--- a/include/linux/iio/sw_device.h
>+++ b/include/linux/iio/sw_device.h
>@@ -60,7 +60,7 @@ struct iio_sw_device *to_iio_sw_device(struct
>config_item *item)
> static inline
> 

Re: [PATCH v2 06/15] PCI: endpoint: make config_item_type const

2017-10-16 Thread Bjorn Helgaas
On Mon, Oct 16, 2017 at 05:18:45PM +0200, Bhumika Goyal wrote:
> Make config_item_type structures const as they are either passed to a
> function having the argument as const or stored in the const "ci_type"
> field of a config_item structure.
> 
> Done using Coccinelle.
> 
> Signed-off-by: Bhumika Goyal 

Acked-by: Bjorn Helgaas 

Please apply this along with the rest of the series, since it depends
on an earlier patch in the series.

> ---
> * Changes in v2- Combine all the followup patches and the constification
> patches into a series.
> 
>  drivers/pci/endpoint/pci-ep-cfs.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pci/endpoint/pci-ep-cfs.c 
> b/drivers/pci/endpoint/pci-ep-cfs.c
> index 424fdd6..4f74386 100644
> --- a/drivers/pci/endpoint/pci-ep-cfs.c
> +++ b/drivers/pci/endpoint/pci-ep-cfs.c
> @@ -150,7 +150,7 @@ static void pci_epc_epf_unlink(struct config_item 
> *epc_item,
>   .drop_link  = pci_epc_epf_unlink,
>  };
>  
> -static struct config_item_type pci_epc_type = {
> +static const struct config_item_type pci_epc_type = {
>   .ct_item_ops= _epc_item_ops,
>   .ct_attrs   = pci_epc_attrs,
>   .ct_owner   = THIS_MODULE,
> @@ -361,7 +361,7 @@ static void pci_epf_release(struct config_item *item)
>   .release= pci_epf_release,
>  };
>  
> -static struct config_item_type pci_epf_type = {
> +static const struct config_item_type pci_epf_type = {
>   .ct_item_ops= _epf_ops,
>   .ct_attrs   = pci_epf_attrs,
>   .ct_owner   = THIS_MODULE,
> @@ -400,7 +400,7 @@ static void pci_epf_drop(struct config_group *group, 
> struct config_item *item)
>   .drop_item  = _epf_drop,
>  };
>  
> -static struct config_item_type pci_epf_group_type = {
> +static const struct config_item_type pci_epf_group_type = {
>   .ct_group_ops   = _epf_group_ops,
>   .ct_owner   = THIS_MODULE,
>  };
> @@ -428,15 +428,15 @@ void pci_ep_cfs_remove_epf_group(struct config_group 
> *group)
>  }
>  EXPORT_SYMBOL(pci_ep_cfs_remove_epf_group);
>  
> -static struct config_item_type pci_functions_type = {
> +static const struct config_item_type pci_functions_type = {
>   .ct_owner   = THIS_MODULE,
>  };
>  
> -static struct config_item_type pci_controllers_type = {
> +static const struct config_item_type pci_controllers_type = {
>   .ct_owner   = THIS_MODULE,
>  };
>  
> -static struct config_item_type pci_ep_type = {
> +static const struct config_item_type pci_ep_type = {
>   .ct_owner   = THIS_MODULE,
>  };
>  
> -- 
> 1.9.1
> 
--
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: disable erroneous overcurrent condition

2017-10-16 Thread Marek Vasut
On 10/16/2017 03:57 PM, Dinh Nguyen wrote:
> For the case where an external VBUS is used, we should enable the external
> VBUS comparator in the driver. This would prevent an unnecessary
> overcurrent error which would then disable the host port.
> 
> This patch uses the standard 'disable-over-current' binding to allow of the
> option of disabling the over-current condition.
> 
> Signed-off-by: Dinh Nguyen 

Reviewed-by: Marek Vasut 

Similar patch was in U-Boot for two years now and it does the trick indeed.

> ---
>  drivers/usb/dwc2/core.h   | 4 
>  drivers/usb/dwc2/hcd.c| 5 +
>  drivers/usb/dwc2/params.c | 3 +++
>  3 files changed, 12 insertions(+)
> 
> diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
> index 8367d4f9..730d7eb 100644
> --- a/drivers/usb/dwc2/core.h
> +++ b/drivers/usb/dwc2/core.h
> @@ -395,6 +395,9 @@ enum dwc2_ep0_state {
>   *   (default when phy_type is UTMI+ or ULPI)
>   *   1 - 6 MHz
>   *   (default when phy_type is Full Speed)
> + * @oc_disable:  Flag to disable overcurrent condition.
> + *   0 - Allow overcurrent condition to get detected
> + *   1 - Disable overcurrent condtion to get detected
>   * @ts_dline:   Enable Term Select Dline pulsing
>   *   0 - No (default)
>   *   1 - Yes
> @@ -492,6 +495,7 @@ struct dwc2_core_params {
>   bool dma_desc_fs_enable;
>   bool host_support_fs_ls_low_power;
>   bool host_ls_low_power_phy_clk;
> + bool oc_disable;
>  
>   u8 host_channels;
>   u16 host_rx_fifo_size;
> diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
> index c263114..5e20336 100644
> --- a/drivers/usb/dwc2/hcd.c
> +++ b/drivers/usb/dwc2/hcd.c
> @@ -213,6 +213,11 @@ static int dwc2_hs_phy_init(struct dwc2_hsotg *hsotg, 
> bool select_phy)
>   usbcfg &= ~(GUSBCFG_PHYIF16 | GUSBCFG_DDRSEL);
>   if (hsotg->params.phy_ulpi_ddr)
>   usbcfg |= GUSBCFG_DDRSEL;
> +
> + /* Set external VBUS indicator as needed. */
> + if (hsotg->params.oc_disable)
> + usbcfg |= (GUSBCFG_ULPI_INT_VBUS_IND |
> +GUSBCFG_INDICATORPASSTHROUGH);
>   break;
>   case DWC2_PHY_TYPE_PARAM_UTMI:
>   /* UTMI+ interface */
> diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
> index a3ffe97..39e02cd 100644
> --- a/drivers/usb/dwc2/params.c
> +++ b/drivers/usb/dwc2/params.c
> @@ -335,6 +335,9 @@ static void dwc2_get_device_properties(struct dwc2_hsotg 
> *hsotg)
>  num);
>   }
>   }
> +
> + if (of_find_property(hsotg->dev->of_node, "disable-over-current", NULL))
> + p->oc_disable = true;
>  }
>  
>  static void dwc2_check_param_otg_cap(struct dwc2_hsotg *hsotg)
> 


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


Re: [PATCHv2 0/7] Add support for USB OTG on STM32F7

2017-10-16 Thread Alexandre Torgue

Hi Amélie,

On 08/28/2017 04:20 PM, Amelie Delaunay wrote:

The STM32F7 MCU family embeds two DWC2 USB OTG cores. One core is USB
OTG FS and the other is USB OTG HS. The USB FS core only works with its
internal phy whilst the USB HS core can work in HS with external ULPI phy
or in FS/LS with the on-chip FS phy.

Amelie Delaunay (7):
   dt-bindings: usb: Document the STM32F7 DWC2 USB OTG HS core binding
   usb: dwc2: add support for STM32F7 USB OTG HS
   ARM: dts: stm32: Add USB HS support for STM32F746 MCU
   ARM: dts: stm32: Enable USB HS on stm32746g-eval
   ARM: dts: stm32: Enable USB HS on stm32f746-disco
   ARM: dts: stm32: Add USB FS support for STM32F746 MCU
   ARM: dts: stm32: Enable USB FS on stm32f746-disco

  Documentation/devicetree/bindings/usb/dwc2.txt |  2 +
  arch/arm/boot/dts/stm32746g-eval.dts   | 16 ++
  arch/arm/boot/dts/stm32f746-disco.dts  | 30 ++
  arch/arm/boot/dts/stm32f746.dtsi   | 80 ++
  drivers/usb/dwc2/params.c  | 11 
  5 files changed, 139 insertions(+)



Patches 3 to 7 applied on stm32-dt-for-v4.15 branch.
Currently USB stack is not enabled by default (and will not be). If you 
plan to use USB don't forget to create a reserved memory region for DMA 
pool (as DMA and caches are not friends on cortex-M7) in devicetree.
Reserved memory region for DMA pool support will be added in stm32F7 and 
stm32H7 devicetree as soon series "ARM: NOMMU: MPU updates" from 
Vladimir Murzin will be merged.


Regards
Alex
--
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 v2 01/15] configfs: make ci_type field, some pointers and function arguments const

2017-10-16 Thread Bhumika Goyal
The ci_type field of the config_item structure do not modify the fields
of the config_item_type structure it points to. And the other pointers
initialized with ci_type do not modify the fields as well.
So, make the ci_type field and the pointers initialized with ci_type
as const.

Make the struct config_item_type *type function argument of functions
config_{item/group}_init_type_name const as the argument in both the
functions is only stored in the ci_type field of a config_item structure
which is now made const.
Make the argument of configfs_register_default_group const as it is
only passed to the argument of the function config_group_init_type_name
which is now const.

Signed-off-by: Bhumika Goyal 
---
* Changes in v2- Combine all the followup patches and the constification
patches into a series.

 fs/configfs/dir.c| 10 +-
 fs/configfs/item.c   |  6 +++---
 fs/configfs/symlink.c|  4 ++--
 include/linux/configfs.h |  8 
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 56fb261..577cff2 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -584,7 +584,7 @@ static void detach_attrs(struct config_item * item)
 
 static int populate_attrs(struct config_item *item)
 {
-   struct config_item_type *t = item->ci_type;
+   const struct config_item_type *t = item->ci_type;
struct configfs_attribute *attr;
struct configfs_bin_attribute *bin_attr;
int error = 0;
@@ -901,7 +901,7 @@ static void configfs_detach_group(struct config_item *item)
 static void client_disconnect_notify(struct config_item *parent_item,
 struct config_item *item)
 {
-   struct config_item_type *type;
+   const struct config_item_type *type;
 
type = parent_item->ci_type;
BUG_ON(!type);
@@ -920,7 +920,7 @@ static void client_disconnect_notify(struct config_item 
*parent_item,
 static void client_drop_item(struct config_item *parent_item,
 struct config_item *item)
 {
-   struct config_item_type *type;
+   const struct config_item_type *type;
 
type = parent_item->ci_type;
BUG_ON(!type);
@@ -1260,7 +1260,7 @@ static int configfs_mkdir(struct inode *dir, struct 
dentry *dentry, umode_t mode
struct config_item *parent_item;
struct configfs_subsystem *subsys;
struct configfs_dirent *sd;
-   struct config_item_type *type;
+   const struct config_item_type *type;
struct module *subsys_owner = NULL, *new_item_owner = NULL;
char *name;
 
@@ -1810,7 +1810,7 @@ void configfs_unregister_group(struct config_group *group)
 struct config_group *
 configfs_register_default_group(struct config_group *parent_group,
const char *name,
-   struct config_item_type *item_type)
+   const struct config_item_type *item_type)
 {
int ret;
struct config_group *group;
diff --git a/fs/configfs/item.c b/fs/configfs/item.c
index a66f662..88f266e 100644
--- a/fs/configfs/item.c
+++ b/fs/configfs/item.c
@@ -113,7 +113,7 @@ int config_item_set_name(struct config_item *item, const 
char *fmt, ...)
 
 void config_item_init_type_name(struct config_item *item,
const char *name,
-   struct config_item_type *type)
+   const struct config_item_type *type)
 {
config_item_set_name(item, "%s", name);
item->ci_type = type;
@@ -122,7 +122,7 @@ void config_item_init_type_name(struct config_item *item,
 EXPORT_SYMBOL(config_item_init_type_name);
 
 void config_group_init_type_name(struct config_group *group, const char *name,
-struct config_item_type *type)
+const struct config_item_type *type)
 {
config_item_set_name(>cg_item, "%s", name);
group->cg_item.ci_type = type;
@@ -148,7 +148,7 @@ struct config_item *config_item_get_unless_zero(struct 
config_item *item)
 
 static void config_item_cleanup(struct config_item *item)
 {
-   struct config_item_type *t = item->ci_type;
+   const struct config_item_type *t = item->ci_type;
struct config_group *s = item->ci_group;
struct config_item *parent = item->ci_parent;
 
diff --git a/fs/configfs/symlink.c b/fs/configfs/symlink.c
index c8aabba..78ffc26 100644
--- a/fs/configfs/symlink.c
+++ b/fs/configfs/symlink.c
@@ -138,7 +138,7 @@ int configfs_symlink(struct inode *dir, struct dentry 
*dentry, const char *symna
struct configfs_dirent *sd;
struct config_item *parent_item;
struct config_item *target_item = NULL;
-   struct config_item_type *type;
+   const struct config_item_type *type;
 
sd = dentry->d_parent->d_fsdata;
/*
@@ -186,7 +186,7 @@ int configfs_unlink(struct inode *dir, struct dentry 
*dentry)

[PATCH v2 02/15] usb: gadget: make config_item_type structures const

2017-10-16 Thread Bhumika Goyal
Make these structures const as they are only passed to the const
argument of the functions config_{group/item}_init_type_name.

Signed-off-by: Bhumika Goyal 
---
* Changes in v2- Combine all the followup patches and the constification
patches into a series.

 drivers/usb/gadget/function/f_acm.c  |  2 +-
 drivers/usb/gadget/function/f_ecm.c  |  2 +-
 drivers/usb/gadget/function/f_eem.c  |  2 +-
 drivers/usb/gadget/function/f_fs.c   |  2 +-
 drivers/usb/gadget/function/f_hid.c  |  2 +-
 drivers/usb/gadget/function/f_loopback.c |  2 +-
 drivers/usb/gadget/function/f_mass_storage.c |  4 +--
 drivers/usb/gadget/function/f_midi.c |  2 +-
 drivers/usb/gadget/function/f_ncm.c  |  2 +-
 drivers/usb/gadget/function/f_obex.c |  2 +-
 drivers/usb/gadget/function/f_phonet.c   |  2 +-
 drivers/usb/gadget/function/f_printer.c  |  2 +-
 drivers/usb/gadget/function/f_rndis.c|  2 +-
 drivers/usb/gadget/function/f_serial.c   |  2 +-
 drivers/usb/gadget/function/f_sourcesink.c   |  2 +-
 drivers/usb/gadget/function/f_subset.c   |  2 +-
 drivers/usb/gadget/function/f_tcm.c  |  2 +-
 drivers/usb/gadget/function/f_uac1.c |  2 +-
 drivers/usb/gadget/function/f_uac1_legacy.c  |  2 +-
 drivers/usb/gadget/function/f_uac2.c |  2 +-
 drivers/usb/gadget/function/uvc_configfs.c   | 50 ++--
 21 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/drivers/usb/gadget/function/f_acm.c 
b/drivers/usb/gadget/function/f_acm.c
index 5e3828d..8680af4 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -786,7 +786,7 @@ static ssize_t f_acm_port_num_show(struct config_item 
*item, char *page)
NULL,
 };
 
-static struct config_item_type acm_func_type = {
+static const struct config_item_type acm_func_type = {
.ct_item_ops= _item_ops,
.ct_attrs   = acm_attrs,
.ct_owner   = THIS_MODULE,
diff --git a/drivers/usb/gadget/function/f_ecm.c 
b/drivers/usb/gadget/function/f_ecm.c
index 4c488d1..9657e19 100644
--- a/drivers/usb/gadget/function/f_ecm.c
+++ b/drivers/usb/gadget/function/f_ecm.c
@@ -845,7 +845,7 @@ static inline struct f_ecm_opts *to_f_ecm_opts(struct 
config_item *item)
NULL,
 };
 
-static struct config_item_type ecm_func_type = {
+static const struct config_item_type ecm_func_type = {
.ct_item_ops= _item_ops,
.ct_attrs   = ecm_attrs,
.ct_owner   = THIS_MODULE,
diff --git a/drivers/usb/gadget/function/f_eem.c 
b/drivers/usb/gadget/function/f_eem.c
index 007ec6e..5e5d164 100644
--- a/drivers/usb/gadget/function/f_eem.c
+++ b/drivers/usb/gadget/function/f_eem.c
@@ -556,7 +556,7 @@ static inline struct f_eem_opts *to_f_eem_opts(struct 
config_item *item)
NULL,
 };
 
-static struct config_item_type eem_func_type = {
+static const struct config_item_type eem_func_type = {
.ct_item_ops= _item_ops,
.ct_attrs   = eem_attrs,
.ct_owner   = THIS_MODULE,
diff --git a/drivers/usb/gadget/function/f_fs.c 
b/drivers/usb/gadget/function/f_fs.c
index 8b34258..5362fc4 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -3385,7 +3385,7 @@ static void ffs_attr_release(struct config_item *item)
.release= ffs_attr_release,
 };
 
-static struct config_item_type ffs_func_type = {
+static const struct config_item_type ffs_func_type = {
.ct_item_ops= _item_ops,
.ct_owner   = THIS_MODULE,
 };
diff --git a/drivers/usb/gadget/function/f_hid.c 
b/drivers/usb/gadget/function/f_hid.c
index d8e359e..6993cb8 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -992,7 +992,7 @@ static ssize_t f_hid_opts_dev_show(struct config_item 
*item, char *page)
NULL,
 };
 
-static struct config_item_type hid_func_type = {
+static const struct config_item_type hid_func_type = {
.ct_item_ops= _item_ops,
.ct_attrs   = hid_attrs,
.ct_owner   = THIS_MODULE,
diff --git a/drivers/usb/gadget/function/f_loopback.c 
b/drivers/usb/gadget/function/f_loopback.c
index e700938..9311f8c 100644
--- a/drivers/usb/gadget/function/f_loopback.c
+++ b/drivers/usb/gadget/function/f_loopback.c
@@ -556,7 +556,7 @@ static ssize_t f_lb_opts_bulk_buflen_store(struct 
config_item *item,
NULL,
 };
 
-static struct config_item_type lb_func_type = {
+static const struct config_item_type lb_func_type = {
.ct_item_ops= _item_ops,
.ct_attrs   = lb_attrs,
.ct_owner   = THIS_MODULE,
diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
b/drivers/usb/gadget/function/f_mass_storage.c
index 5153e29..a538be3 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -3140,7 +3140,7 @@ static ssize_t 

[PATCH v2 04/15] iio: make function argument and some structures const

2017-10-16 Thread Bhumika Goyal
Make the argument of the functions iio_sw{d/t}_group_init_type_name const
as they are only passed to the function config_group_init_type_name having
the argument as const.

Make the config_item_type structures const as they are either passed to
the functions having the argument as const or they are
stored in the const "ci_type" field of a config_item structure.

Signed-off-by: Bhumika Goyal 
---
* Changes in v2- Combine all the followup patches and the constification
patches into a series.

 drivers/iio/dummy/iio_simple_dummy.c   | 2 +-
 drivers/iio/industrialio-configfs.c| 2 +-
 drivers/iio/industrialio-sw-device.c   | 6 +++---
 drivers/iio/industrialio-sw-trigger.c  | 6 +++---
 drivers/iio/trigger/iio-trig-hrtimer.c | 2 +-
 drivers/iio/trigger/iio-trig-loop.c| 2 +-
 include/linux/iio/sw_device.h  | 2 +-
 include/linux/iio/sw_trigger.h | 2 +-
 8 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/iio/dummy/iio_simple_dummy.c 
b/drivers/iio/dummy/iio_simple_dummy.c
index a45d01e..6205247 100644
--- a/drivers/iio/dummy/iio_simple_dummy.c
+++ b/drivers/iio/dummy/iio_simple_dummy.c
@@ -26,7 +26,7 @@
 #include 
 #include "iio_simple_dummy.h"
 
-static struct config_item_type iio_dummy_type = {
+static const struct config_item_type iio_dummy_type = {
.ct_owner = THIS_MODULE,
 };
 
diff --git a/drivers/iio/industrialio-configfs.c 
b/drivers/iio/industrialio-configfs.c
index 45ce2bc..5a0aae1 100644
--- a/drivers/iio/industrialio-configfs.c
+++ b/drivers/iio/industrialio-configfs.c
@@ -17,7 +17,7 @@
 #include 
 #include 
 
-static struct config_item_type iio_root_group_type = {
+static const struct config_item_type iio_root_group_type = {
.ct_owner   = THIS_MODULE,
 };
 
diff --git a/drivers/iio/industrialio-sw-device.c 
b/drivers/iio/industrialio-sw-device.c
index 81b49cf..90df97c 100644
--- a/drivers/iio/industrialio-sw-device.c
+++ b/drivers/iio/industrialio-sw-device.c
@@ -19,9 +19,9 @@
 #include 
 
 static struct config_group *iio_devices_group;
-static struct config_item_type iio_device_type_group_type;
+static const struct config_item_type iio_device_type_group_type;
 
-static struct config_item_type iio_devices_group_type = {
+static const struct config_item_type iio_devices_group_type = {
.ct_owner = THIS_MODULE,
 };
 
@@ -156,7 +156,7 @@ static void device_drop_group(struct config_group *group,
.drop_item  = _drop_group,
 };
 
-static struct config_item_type iio_device_type_group_type = {
+static const struct config_item_type iio_device_type_group_type = {
.ct_group_ops = _ops,
.ct_owner   = THIS_MODULE,
 };
diff --git a/drivers/iio/industrialio-sw-trigger.c 
b/drivers/iio/industrialio-sw-trigger.c
index 8d24fb1..bc6b7fb 100644
--- a/drivers/iio/industrialio-sw-trigger.c
+++ b/drivers/iio/industrialio-sw-trigger.c
@@ -19,9 +19,9 @@
 #include 
 
 static struct config_group *iio_triggers_group;
-static struct config_item_type iio_trigger_type_group_type;
+static const struct config_item_type iio_trigger_type_group_type;
 
-static struct config_item_type iio_triggers_group_type = {
+static const struct config_item_type iio_triggers_group_type = {
.ct_owner = THIS_MODULE,
 };
 
@@ -156,7 +156,7 @@ static void trigger_drop_group(struct config_group *group,
.drop_item  = _drop_group,
 };
 
-static struct config_item_type iio_trigger_type_group_type = {
+static const struct config_item_type iio_trigger_type_group_type = {
.ct_group_ops = _ops,
.ct_owner   = THIS_MODULE,
 };
diff --git a/drivers/iio/trigger/iio-trig-hrtimer.c 
b/drivers/iio/trigger/iio-trig-hrtimer.c
index 3ee9216..7accd01 100644
--- a/drivers/iio/trigger/iio-trig-hrtimer.c
+++ b/drivers/iio/trigger/iio-trig-hrtimer.c
@@ -30,7 +30,7 @@ struct iio_hrtimer_info {
ktime_t period;
 };
 
-static struct config_item_type iio_hrtimer_type = {
+static const struct config_item_type iio_hrtimer_type = {
.ct_owner = THIS_MODULE,
 };
 
diff --git a/drivers/iio/trigger/iio-trig-loop.c 
b/drivers/iio/trigger/iio-trig-loop.c
index b4b02db..94a90e0 100644
--- a/drivers/iio/trigger/iio-trig-loop.c
+++ b/drivers/iio/trigger/iio-trig-loop.c
@@ -36,7 +36,7 @@ struct iio_loop_info {
struct task_struct *task;
 };
 
-static struct config_item_type iio_loop_type = {
+static const struct config_item_type iio_loop_type = {
.ct_owner = THIS_MODULE,
 };
 
diff --git a/include/linux/iio/sw_device.h b/include/linux/iio/sw_device.h
index fa79319..8642b91 100644
--- a/include/linux/iio/sw_device.h
+++ b/include/linux/iio/sw_device.h
@@ -60,7 +60,7 @@ struct iio_sw_device *to_iio_sw_device(struct config_item 
*item)
 static inline
 void iio_swd_group_init_type_name(struct iio_sw_device *d,
  const char *name,
- struct config_item_type *type)
+ const struct config_item_type *type)
 {
 #if 

[PATCH v2 05/15] ocfs2/cluster: make config_item_type const

2017-10-16 Thread Bhumika Goyal
Make these structures const as they are either passed to the functions
having the argument as const or stored as a reference in the "ci_type"
const field of a config_item structure.

Done using Coccinelle.

Signed-off-by: Bhumika Goyal 
---
* Changes in v2- Combine all the followup patches and the constification
patches into a series.

 fs/ocfs2/cluster/heartbeat.c   | 4 ++--
 fs/ocfs2/cluster/nodemanager.c | 8 
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index d020604..ea8c551 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -2025,7 +2025,7 @@ static ssize_t o2hb_region_pid_show(struct config_item 
*item, char *page)
.release= o2hb_region_release,
 };
 
-static struct config_item_type o2hb_region_type = {
+static const struct config_item_type o2hb_region_type = {
.ct_item_ops= _region_item_ops,
.ct_attrs   = o2hb_region_attrs,
.ct_owner   = THIS_MODULE,
@@ -2310,7 +2310,7 @@ static ssize_t o2hb_heartbeat_group_mode_store(struct 
config_item *item,
.drop_item  = o2hb_heartbeat_group_drop_item,
 };
 
-static struct config_item_type o2hb_heartbeat_group_type = {
+static const struct config_item_type o2hb_heartbeat_group_type = {
.ct_group_ops   = _heartbeat_group_group_ops,
.ct_attrs   = o2hb_heartbeat_group_attrs,
.ct_owner   = THIS_MODULE,
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
index b17d180..a51200e 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -378,7 +378,7 @@ static ssize_t o2nm_node_local_store(struct config_item 
*item, const char *page,
.release= o2nm_node_release,
 };
 
-static struct config_item_type o2nm_node_type = {
+static const struct config_item_type o2nm_node_type = {
.ct_item_ops= _node_item_ops,
.ct_attrs   = o2nm_node_attrs,
.ct_owner   = THIS_MODULE,
@@ -619,7 +619,7 @@ static void o2nm_node_group_drop_item(struct config_group 
*group,
.drop_item  = o2nm_node_group_drop_item,
 };
 
-static struct config_item_type o2nm_node_group_type = {
+static const struct config_item_type o2nm_node_group_type = {
.ct_group_ops   = _node_group_group_ops,
.ct_owner   = THIS_MODULE,
 };
@@ -637,7 +637,7 @@ static void o2nm_cluster_release(struct config_item *item)
.release= o2nm_cluster_release,
 };
 
-static struct config_item_type o2nm_cluster_type = {
+static const struct config_item_type o2nm_cluster_type = {
.ct_item_ops= _cluster_item_ops,
.ct_attrs   = o2nm_cluster_attrs,
.ct_owner   = THIS_MODULE,
@@ -722,7 +722,7 @@ static void o2nm_cluster_group_drop_item(struct 
config_group *group, struct conf
.drop_item  = o2nm_cluster_group_drop_item,
 };
 
-static struct config_item_type o2nm_cluster_group_type = {
+static const struct config_item_type o2nm_cluster_group_type = {
.ct_group_ops   = _cluster_group_group_ops,
.ct_owner   = THIS_MODULE,
 };
-- 
1.9.1

--
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 v2 07/15] usb: gadget: configfs: make config_item_type const

2017-10-16 Thread Bhumika Goyal
Make config_item_type structures const as they are either passed to a
function having the argument as const or stored in the const "ci_type"
field of a config_item structure.

Done using Coccinelle.

Signed-off-by: Bhumika Goyal 
---
* Changes in v2- Combine all the followup patches and the constification
patches into a series.

 drivers/usb/gadget/configfs.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index aeb9f3c..9d18b99 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -505,13 +505,13 @@ static ssize_t 
gadget_config_desc_bmAttributes_store(struct config_item *item,
NULL,
 };
 
-static struct config_item_type gadget_config_type = {
+static const struct config_item_type gadget_config_type = {
.ct_item_ops= _config_item_ops,
.ct_attrs   = gadget_config_attrs,
.ct_owner   = THIS_MODULE,
 };
 
-static struct config_item_type gadget_root_type = {
+static const struct config_item_type gadget_root_type = {
.ct_item_ops= _root_item_ops,
.ct_attrs   = gadget_root_attrs,
.ct_owner   = THIS_MODULE,
@@ -593,7 +593,7 @@ static void function_drop(
.drop_item  = _drop,
 };
 
-static struct config_item_type functions_type = {
+static const struct config_item_type functions_type = {
.ct_group_ops   = _ops,
.ct_owner   = THIS_MODULE,
 };
@@ -694,7 +694,7 @@ static void config_desc_drop(
.drop_item  = _desc_drop,
 };
 
-static struct config_item_type config_desc_type = {
+static const struct config_item_type config_desc_type = {
.ct_group_ops   = _desc_ops,
.ct_owner   = THIS_MODULE,
 };
@@ -1476,7 +1476,7 @@ static void gadgets_drop(struct config_group *group, 
struct config_item *item)
.drop_item  = _drop,
 };
 
-static struct config_item_type gadgets_type = {
+static const struct config_item_type gadgets_type = {
.ct_group_ops   = _ops,
.ct_owner   = THIS_MODULE,
 };
-- 
1.9.1

--
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 v2 08/15] nvmet: make config_item_type const

2017-10-16 Thread Bhumika Goyal
Make config_item_type structures const as they are either passed to a
function having the argument as const or used inside an if statement or
stored in the const "ci_type" field of a config_item structure.

Done using Coccinelle

Signed-off-by: Bhumika Goyal 
---
* Changes in v2- Combine all the followup patches and the constification
patches into a series.

 drivers/nvme/target/configfs.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index b6aeb1d..e6b2d2a 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -20,8 +20,8 @@
 
 #include "nvmet.h"
 
-static struct config_item_type nvmet_host_type;
-static struct config_item_type nvmet_subsys_type;
+static const struct config_item_type nvmet_host_type;
+static const struct config_item_type nvmet_subsys_type;
 
 /*
  * nvmet_port Generic ConfigFS definitions.
@@ -425,7 +425,7 @@ static void nvmet_ns_release(struct config_item *item)
.release= nvmet_ns_release,
 };
 
-static struct config_item_type nvmet_ns_type = {
+static const struct config_item_type nvmet_ns_type = {
.ct_item_ops= _ns_item_ops,
.ct_attrs   = nvmet_ns_attrs,
.ct_owner   = THIS_MODULE,
@@ -464,7 +464,7 @@ static struct config_group *nvmet_ns_make(struct 
config_group *group,
.make_group = nvmet_ns_make,
 };
 
-static struct config_item_type nvmet_namespaces_type = {
+static const struct config_item_type nvmet_namespaces_type = {
.ct_group_ops   = _namespaces_group_ops,
.ct_owner   = THIS_MODULE,
 };
@@ -540,7 +540,7 @@ static void nvmet_port_subsys_drop_link(struct config_item 
*parent,
.drop_link  = nvmet_port_subsys_drop_link,
 };
 
-static struct config_item_type nvmet_port_subsys_type = {
+static const struct config_item_type nvmet_port_subsys_type = {
.ct_item_ops= _port_subsys_item_ops,
.ct_owner   = THIS_MODULE,
 };
@@ -613,7 +613,7 @@ static void nvmet_allowed_hosts_drop_link(struct 
config_item *parent,
.drop_link  = nvmet_allowed_hosts_drop_link,
 };
 
-static struct config_item_type nvmet_allowed_hosts_type = {
+static const struct config_item_type nvmet_allowed_hosts_type = {
.ct_item_ops= _allowed_hosts_item_ops,
.ct_owner   = THIS_MODULE,
 };
@@ -729,7 +729,7 @@ static void nvmet_subsys_release(struct config_item *item)
.release= nvmet_subsys_release,
 };
 
-static struct config_item_type nvmet_subsys_type = {
+static const struct config_item_type nvmet_subsys_type = {
.ct_item_ops= _subsys_item_ops,
.ct_attrs   = nvmet_subsys_attrs,
.ct_owner   = THIS_MODULE,
@@ -767,7 +767,7 @@ static struct config_group *nvmet_subsys_make(struct 
config_group *group,
.make_group = nvmet_subsys_make,
 };
 
-static struct config_item_type nvmet_subsystems_type = {
+static const struct config_item_type nvmet_subsystems_type = {
.ct_group_ops   = _subsystems_group_ops,
.ct_owner   = THIS_MODULE,
 };
@@ -827,7 +827,7 @@ static void nvmet_referral_release(struct config_item *item)
.release= nvmet_referral_release,
 };
 
-static struct config_item_type nvmet_referral_type = {
+static const struct config_item_type nvmet_referral_type = {
.ct_owner   = THIS_MODULE,
.ct_attrs   = nvmet_referral_attrs,
.ct_item_ops= _referral_item_ops,
@@ -852,7 +852,7 @@ static struct config_group *nvmet_referral_make(
.make_group = nvmet_referral_make,
 };
 
-static struct config_item_type nvmet_referrals_type = {
+static const struct config_item_type nvmet_referrals_type = {
.ct_owner   = THIS_MODULE,
.ct_group_ops   = _referral_group_ops,
 };
@@ -880,7 +880,7 @@ static void nvmet_port_release(struct config_item *item)
.release= nvmet_port_release,
 };
 
-static struct config_item_type nvmet_port_type = {
+static const struct config_item_type nvmet_port_type = {
.ct_attrs   = nvmet_port_attrs,
.ct_item_ops= _port_item_ops,
.ct_owner   = THIS_MODULE,
@@ -921,7 +921,7 @@ static struct config_group *nvmet_ports_make(struct 
config_group *group,
.make_group = nvmet_ports_make,
 };
 
-static struct config_item_type nvmet_ports_type = {
+static const struct config_item_type nvmet_ports_type = {
.ct_group_ops   = _ports_group_ops,
.ct_owner   = THIS_MODULE,
 };
@@ -940,7 +940,7 @@ static void nvmet_host_release(struct config_item *item)
.release= nvmet_host_release,
 };
 
-static struct config_item_type 

[PATCH v2 06/15] PCI: endpoint: make config_item_type const

2017-10-16 Thread Bhumika Goyal
Make config_item_type structures const as they are either passed to a
function having the argument as const or stored in the const "ci_type"
field of a config_item structure.

Done using Coccinelle.

Signed-off-by: Bhumika Goyal 
---
* Changes in v2- Combine all the followup patches and the constification
patches into a series.

 drivers/pci/endpoint/pci-ep-cfs.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/endpoint/pci-ep-cfs.c 
b/drivers/pci/endpoint/pci-ep-cfs.c
index 424fdd6..4f74386 100644
--- a/drivers/pci/endpoint/pci-ep-cfs.c
+++ b/drivers/pci/endpoint/pci-ep-cfs.c
@@ -150,7 +150,7 @@ static void pci_epc_epf_unlink(struct config_item *epc_item,
.drop_link  = pci_epc_epf_unlink,
 };
 
-static struct config_item_type pci_epc_type = {
+static const struct config_item_type pci_epc_type = {
.ct_item_ops= _epc_item_ops,
.ct_attrs   = pci_epc_attrs,
.ct_owner   = THIS_MODULE,
@@ -361,7 +361,7 @@ static void pci_epf_release(struct config_item *item)
.release= pci_epf_release,
 };
 
-static struct config_item_type pci_epf_type = {
+static const struct config_item_type pci_epf_type = {
.ct_item_ops= _epf_ops,
.ct_attrs   = pci_epf_attrs,
.ct_owner   = THIS_MODULE,
@@ -400,7 +400,7 @@ static void pci_epf_drop(struct config_group *group, struct 
config_item *item)
.drop_item  = _epf_drop,
 };
 
-static struct config_item_type pci_epf_group_type = {
+static const struct config_item_type pci_epf_group_type = {
.ct_group_ops   = _epf_group_ops,
.ct_owner   = THIS_MODULE,
 };
@@ -428,15 +428,15 @@ void pci_ep_cfs_remove_epf_group(struct config_group 
*group)
 }
 EXPORT_SYMBOL(pci_ep_cfs_remove_epf_group);
 
-static struct config_item_type pci_functions_type = {
+static const struct config_item_type pci_functions_type = {
.ct_owner   = THIS_MODULE,
 };
 
-static struct config_item_type pci_controllers_type = {
+static const struct config_item_type pci_controllers_type = {
.ct_owner   = THIS_MODULE,
 };
 
-static struct config_item_type pci_ep_type = {
+static const struct config_item_type pci_ep_type = {
.ct_owner   = THIS_MODULE,
 };
 
-- 
1.9.1

--
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 v2 09/15] ACPI: configfs: make config_item_type const

2017-10-16 Thread Bhumika Goyal
Make these structures const as they are either passed to the functions
having the argument as const or stored as a reference in the "ci_type"
const field of a config_item structure.

Done using Coccienlle.

Signed-off-by: Bhumika Goyal 
---
* Changes in v2- Combine all the followup patches and the constification
patches into a series.

 drivers/acpi/acpi_configfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/acpi_configfs.c b/drivers/acpi/acpi_configfs.c
index 853bc7f..b588503 100644
--- a/drivers/acpi/acpi_configfs.c
+++ b/drivers/acpi/acpi_configfs.c
@@ -204,7 +204,7 @@ struct configfs_attribute *acpi_table_attrs[] = {
NULL,
 };
 
-static struct config_item_type acpi_table_type = {
+static const struct config_item_type acpi_table_type = {
.ct_owner = THIS_MODULE,
.ct_bin_attrs = acpi_table_bin_attrs,
.ct_attrs = acpi_table_attrs,
@@ -237,12 +237,12 @@ struct configfs_group_operations acpi_table_group_ops = {
.drop_item = acpi_table_drop_item,
 };
 
-static struct config_item_type acpi_tables_type = {
+static const struct config_item_type acpi_tables_type = {
.ct_owner = THIS_MODULE,
.ct_group_ops = _table_group_ops,
 };
 
-static struct config_item_type acpi_root_group_type = {
+static const struct config_item_type acpi_root_group_type = {
.ct_owner = THIS_MODULE,
 };
 
-- 
1.9.1

--
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 v2 10/15] nullb: make config_item_type const

2017-10-16 Thread Bhumika Goyal
Make these structures const as they are either passed to the functions
having the argument as const or stored as a reference in the "ci_type"
const field of a config_item structure.

Done using Coccienlle.

Signed-off-by: Bhumika Goyal 
---
* Changes in v2- Combine all the followup patches and the constification
patches into a series.

 drivers/block/null_blk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index bf2c8ca..46b6008 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -480,7 +480,7 @@ static void nullb_device_release(struct config_item *item)
.release= nullb_device_release,
 };
 
-static struct config_item_type nullb_device_type = {
+static const struct config_item_type nullb_device_type = {
.ct_item_ops= _device_ops,
.ct_attrs   = nullb_device_attrs,
.ct_owner   = THIS_MODULE,
@@ -532,7 +532,7 @@ static ssize_t memb_group_features_show(struct config_item 
*item, char *page)
.drop_item  = nullb_group_drop_item,
 };
 
-static struct config_item_type nullb_group_type = {
+static const struct config_item_type nullb_group_type = {
.ct_group_ops   = _group_ops,
.ct_attrs   = nullb_group_attrs,
.ct_owner   = THIS_MODULE,
-- 
1.9.1

--
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 v2 12/15] RDMA/cma: make config_item_type const

2017-10-16 Thread Bhumika Goyal
Make these structures const as they are either passed to the functions
having the argument as const or stored as a reference in the "ci_type"
const field of a config_item structure.

Signed-off-by: Bhumika Goyal 
---
* Changes in v2- Combine all the followup patches and the constification
patches into a series.

 drivers/infiniband/core/cma_configfs.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/core/cma_configfs.c 
b/drivers/infiniband/core/cma_configfs.c
index 54076a3..31dfee0 100644
--- a/drivers/infiniband/core/cma_configfs.c
+++ b/drivers/infiniband/core/cma_configfs.c
@@ -186,7 +186,7 @@ static ssize_t default_roce_tos_store(struct config_item 
*item,
NULL,
 };
 
-static struct config_item_type cma_port_group_type = {
+static const struct config_item_type cma_port_group_type = {
.ct_attrs   = cma_configfs_attributes,
.ct_owner   = THIS_MODULE
 };
@@ -263,7 +263,7 @@ static void release_cma_ports_group(struct config_item  
*item)
.release = release_cma_ports_group
 };
 
-static struct config_item_type cma_ports_group_type = {
+static const struct config_item_type cma_ports_group_type = {
.ct_item_ops= _ports_item_ops,
.ct_owner   = THIS_MODULE
 };
@@ -272,7 +272,7 @@ static void release_cma_ports_group(struct config_item  
*item)
.release = release_cma_dev
 };
 
-static struct config_item_type cma_device_group_type = {
+static const struct config_item_type cma_device_group_type = {
.ct_item_ops= _device_item_ops,
.ct_owner   = THIS_MODULE
 };
@@ -323,7 +323,7 @@ static struct config_group *make_cma_dev(struct 
config_group *group,
.make_group = make_cma_dev,
 };
 
-static struct config_item_type cma_subsys_type = {
+static const struct config_item_type cma_subsys_type = {
.ct_group_ops   = _subsys_group_ops,
.ct_owner   = THIS_MODULE,
 };
-- 
1.9.1

--
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 v2 11/15] stm class: make config_item_type const

2017-10-16 Thread Bhumika Goyal
Make config_item_type structures const as they are either passed to a
function having the argument as const or used inside a if statement or
stored in the const "ci_type" field of a config_item structure.

Done using Coccinelle.

Signed-off-by: Bhumika Goyal 
---
* Changes in v2- Combine all the followup patches and the constification
patches into a series.

 drivers/hwtracing/stm/policy.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/hwtracing/stm/policy.c b/drivers/hwtracing/stm/policy.c
index 6c0ae29..33e9a1b 100644
--- a/drivers/hwtracing/stm/policy.c
+++ b/drivers/hwtracing/stm/policy.c
@@ -187,8 +187,8 @@ static void stp_policy_node_release(struct config_item 
*item)
NULL,
 };
 
-static struct config_item_type stp_policy_type;
-static struct config_item_type stp_policy_node_type;
+static const struct config_item_type stp_policy_type;
+static const struct config_item_type stp_policy_node_type;
 
 static struct config_group *
 stp_policy_node_make(struct config_group *group, const char *name)
@@ -236,7 +236,7 @@ static void stp_policy_node_release(struct config_item 
*item)
.drop_item  = stp_policy_node_drop,
 };
 
-static struct config_item_type stp_policy_node_type = {
+static const struct config_item_type stp_policy_node_type = {
.ct_item_ops= _policy_node_item_ops,
.ct_group_ops   = _policy_node_group_ops,
.ct_attrs   = stp_policy_node_attrs,
@@ -311,7 +311,7 @@ static void stp_policy_release(struct config_item *item)
.make_group = stp_policy_node_make,
 };
 
-static struct config_item_type stp_policy_type = {
+static const struct config_item_type stp_policy_type = {
.ct_item_ops= _policy_item_ops,
.ct_group_ops   = _policy_group_ops,
.ct_attrs   = stp_policy_attrs,
@@ -380,7 +380,7 @@ static void stp_policy_release(struct config_item *item)
.make_group = stp_policies_make,
 };
 
-static struct config_item_type stp_policies_type = {
+static const struct config_item_type stp_policies_type = {
.ct_group_ops   = _policies_group_ops,
.ct_owner   = THIS_MODULE,
 };
-- 
1.9.1

--
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 v2 14/15] dlm: make config_item_type const

2017-10-16 Thread Bhumika Goyal
Make config_item_type structures const as they are either passed to a
function having the argument as const or stored in the const "ci_type"
field of a config_item structure.

Done using Coccinelle.

Signed-off-by: Bhumika Goyal 
---
* Changes in v2- Combine all the followup patches and the constification
patches into a series.

 fs/dlm/config.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/dlm/config.c b/fs/dlm/config.c
index 7211e82..1270551 100644
--- a/fs/dlm/config.c
+++ b/fs/dlm/config.c
@@ -282,44 +282,44 @@ struct dlm_node {
.release = release_node,
 };
 
-static struct config_item_type clusters_type = {
+static const struct config_item_type clusters_type = {
.ct_group_ops = _ops,
.ct_owner = THIS_MODULE,
 };
 
-static struct config_item_type cluster_type = {
+static const struct config_item_type cluster_type = {
.ct_item_ops = _ops,
.ct_attrs = cluster_attrs,
.ct_owner = THIS_MODULE,
 };
 
-static struct config_item_type spaces_type = {
+static const struct config_item_type spaces_type = {
.ct_group_ops = _ops,
.ct_owner = THIS_MODULE,
 };
 
-static struct config_item_type space_type = {
+static const struct config_item_type space_type = {
.ct_item_ops = _ops,
.ct_owner = THIS_MODULE,
 };
 
-static struct config_item_type comms_type = {
+static const struct config_item_type comms_type = {
.ct_group_ops = _ops,
.ct_owner = THIS_MODULE,
 };
 
-static struct config_item_type comm_type = {
+static const struct config_item_type comm_type = {
.ct_item_ops = _ops,
.ct_attrs = comm_attrs,
.ct_owner = THIS_MODULE,
 };
 
-static struct config_item_type nodes_type = {
+static const struct config_item_type nodes_type = {
.ct_group_ops = _ops,
.ct_owner = THIS_MODULE,
 };
 
-static struct config_item_type node_type = {
+static const struct config_item_type node_type = {
.ct_item_ops = _ops,
.ct_attrs = node_attrs,
.ct_owner = THIS_MODULE,
-- 
1.9.1

--
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 v2 15/15] configfs: make config_item_type const

2017-10-16 Thread Bhumika Goyal
Make config_item_type structures const as they are either passed to a
function having the argument as const or stored in the const "ci_type"
field of a config_item structure.

Done using Coccinelle.

Signed-off-by: Bhumika Goyal 
---
* Changes in v2- Combine all the followup patches and the constification
patches into a series.

 samples/configfs/configfs_sample.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/samples/configfs/configfs_sample.c 
b/samples/configfs/configfs_sample.c
index 1ea3311..004a4e2 100644
--- a/samples/configfs/configfs_sample.c
+++ b/samples/configfs/configfs_sample.c
@@ -115,7 +115,7 @@ static ssize_t childless_description_show(struct 
config_item *item, char *page)
NULL,
 };
 
-static struct config_item_type childless_type = {
+static const struct config_item_type childless_type = {
.ct_attrs   = childless_attrs,
.ct_owner   = THIS_MODULE,
 };
@@ -193,7 +193,7 @@ static void simple_child_release(struct config_item *item)
.release= simple_child_release,
 };
 
-static struct config_item_type simple_child_type = {
+static const struct config_item_type simple_child_type = {
.ct_item_ops= _child_item_ops,
.ct_attrs   = simple_child_attrs,
.ct_owner   = THIS_MODULE,
@@ -261,7 +261,7 @@ static void simple_children_release(struct config_item 
*item)
.make_item  = simple_children_make_item,
 };
 
-static struct config_item_type simple_children_type = {
+static const struct config_item_type simple_children_type = {
.ct_item_ops= _children_item_ops,
.ct_group_ops   = _children_group_ops,
.ct_attrs   = simple_children_attrs,
@@ -331,7 +331,7 @@ static ssize_t group_children_description_show(struct 
config_item *item,
.make_group = group_children_make_group,
 };
 
-static struct config_item_type group_children_type = {
+static const struct config_item_type group_children_type = {
.ct_group_ops   = _children_group_ops,
.ct_attrs   = group_children_attrs,
.ct_owner   = THIS_MODULE,
-- 
1.9.1

--
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 v2 13/15] netconsole: make config_item_type const

2017-10-16 Thread Bhumika Goyal
Make these structures const as they are either passed to the functions
having the argument as const or stored as a reference in the "ci_type"
const field of a config_item structure.

Done using Coccienlle.

Signed-off-by: Bhumika Goyal 
---
* Changes in v2- Combine all the followup patches and the constification
patches into a series.

 drivers/net/netconsole.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 0e27920..be9aa36 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -616,7 +616,7 @@ static void netconsole_target_release(struct config_item 
*item)
.release= netconsole_target_release,
 };
 
-static struct config_item_type netconsole_target_type = {
+static const struct config_item_type netconsole_target_type = {
.ct_attrs   = netconsole_target_attrs,
.ct_item_ops= _target_item_ops,
.ct_owner   = THIS_MODULE,
@@ -682,7 +682,7 @@ static void drop_netconsole_target(struct config_group 
*group,
.drop_item  = drop_netconsole_target,
 };
 
-static struct config_item_type netconsole_subsys_type = {
+static const struct config_item_type netconsole_subsys_type = {
.ct_group_ops   = _subsys_group_ops,
.ct_owner   = THIS_MODULE,
 };
-- 
1.9.1

--
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 v2 00/15] make structure field, function arguments and structures const

2017-10-16 Thread Bhumika Goyal
Make the ci_type field and some function arguments as const. After this
change, make config_item_type structures as const.

* Changes in v2- Combine all the followup patches and the constification
patches into a series.

Bhumika Goyal (15):
  configfs: make ci_type field, some pointers and function arguments
const
  usb: gadget: make config_item_type structures const
  target: make config_item_type const
  iio: make function argument and some structures const
  ocfs2/cluster: make config_item_type const
  PCI: endpoint: make config_item_type const
  usb: gadget: configfs: make config_item_type const
  nvmet: make config_item_type const
  ACPI: configfs: make config_item_type const
  nullb: make config_item_type const
  stm class: make config_item_type const
  RDMA/cma: make config_item_type const
  netconsole: make config_item_type const
  dlm: make config_item_type const
  configfs: make config_item_type const

 drivers/acpi/acpi_configfs.c |  6 ++--
 drivers/block/null_blk.c |  4 +--
 drivers/hwtracing/stm/policy.c   | 10 +++---
 drivers/iio/dummy/iio_simple_dummy.c |  2 +-
 drivers/iio/industrialio-configfs.c  |  2 +-
 drivers/iio/industrialio-sw-device.c |  6 ++--
 drivers/iio/industrialio-sw-trigger.c|  6 ++--
 drivers/iio/trigger/iio-trig-hrtimer.c   |  2 +-
 drivers/iio/trigger/iio-trig-loop.c  |  2 +-
 drivers/infiniband/core/cma_configfs.c   |  8 ++---
 drivers/net/netconsole.c |  4 +--
 drivers/nvme/target/configfs.c   | 30 -
 drivers/pci/endpoint/pci-ep-cfs.c| 12 +++
 drivers/target/iscsi/iscsi_target_stat.c | 12 +++
 drivers/target/target_core_configfs.c| 14 
 drivers/target/target_core_stat.c| 16 -
 drivers/usb/gadget/configfs.c| 10 +++---
 drivers/usb/gadget/function/f_acm.c  |  2 +-
 drivers/usb/gadget/function/f_ecm.c  |  2 +-
 drivers/usb/gadget/function/f_eem.c  |  2 +-
 drivers/usb/gadget/function/f_fs.c   |  2 +-
 drivers/usb/gadget/function/f_hid.c  |  2 +-
 drivers/usb/gadget/function/f_loopback.c |  2 +-
 drivers/usb/gadget/function/f_mass_storage.c |  4 +--
 drivers/usb/gadget/function/f_midi.c |  2 +-
 drivers/usb/gadget/function/f_ncm.c  |  2 +-
 drivers/usb/gadget/function/f_obex.c |  2 +-
 drivers/usb/gadget/function/f_phonet.c   |  2 +-
 drivers/usb/gadget/function/f_printer.c  |  2 +-
 drivers/usb/gadget/function/f_rndis.c|  2 +-
 drivers/usb/gadget/function/f_serial.c   |  2 +-
 drivers/usb/gadget/function/f_sourcesink.c   |  2 +-
 drivers/usb/gadget/function/f_subset.c   |  2 +-
 drivers/usb/gadget/function/f_tcm.c  |  2 +-
 drivers/usb/gadget/function/f_uac1.c |  2 +-
 drivers/usb/gadget/function/f_uac1_legacy.c  |  2 +-
 drivers/usb/gadget/function/f_uac2.c |  2 +-
 drivers/usb/gadget/function/uvc_configfs.c   | 50 ++--
 fs/configfs/dir.c| 10 +++---
 fs/configfs/item.c   |  6 ++--
 fs/configfs/symlink.c|  4 +--
 fs/dlm/config.c  | 16 -
 fs/ocfs2/cluster/heartbeat.c |  4 +--
 fs/ocfs2/cluster/nodemanager.c   |  8 ++---
 include/linux/configfs.h |  8 ++---
 include/linux/iio/sw_device.h|  2 +-
 include/linux/iio/sw_trigger.h   |  2 +-
 include/target/iscsi/iscsi_target_stat.h | 12 +++
 samples/configfs/configfs_sample.c   |  8 ++---
 49 files changed, 159 insertions(+), 159 deletions(-)

-- 
1.9.1

--
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 v2 03/15] target: make config_item_type const

2017-10-16 Thread Bhumika Goyal
Make these structures const as they are either passed to the functions
having the argument as const or stored as a reference in the "ci_type"
const field of a config_item structure.

Done using Coccinelle.

Signed-off-by: Bhumika Goyal 
---
* Changes in v2- Combine all the followup patches and the constification
patches into a series.

 drivers/target/iscsi/iscsi_target_stat.c | 12 ++--
 drivers/target/target_core_configfs.c| 14 +++---
 drivers/target/target_core_stat.c| 16 
 include/target/iscsi/iscsi_target_stat.h | 12 ++--
 4 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_stat.c 
b/drivers/target/iscsi/iscsi_target_stat.c
index 411cb26..df0a398 100644
--- a/drivers/target/iscsi/iscsi_target_stat.c
+++ b/drivers/target/iscsi/iscsi_target_stat.c
@@ -187,7 +187,7 @@ static ssize_t iscsi_stat_instance_version_show(struct 
config_item *item,
NULL,
 };
 
-struct config_item_type iscsi_stat_instance_cit = {
+const struct config_item_type iscsi_stat_instance_cit = {
.ct_attrs   = iscsi_stat_instance_attrs,
.ct_owner   = THIS_MODULE,
 };
@@ -249,7 +249,7 @@ static ssize_t 
iscsi_stat_sess_err_format_errors_show(struct config_item *item,
NULL,
 };
 
-struct config_item_type iscsi_stat_sess_err_cit = {
+const struct config_item_type iscsi_stat_sess_err_cit = {
.ct_attrs   = iscsi_stat_sess_err_attrs,
.ct_owner   = THIS_MODULE,
 };
@@ -390,7 +390,7 @@ static ssize_t 
iscsi_stat_tgt_attr_fail_intr_addr_show(struct config_item *item,
NULL,
 };
 
-struct config_item_type iscsi_stat_tgt_attr_cit = {
+const struct config_item_type iscsi_stat_tgt_attr_cit = {
.ct_attrs   = iscsi_stat_tgt_attr_attrs,
.ct_owner   = THIS_MODULE,
 };
@@ -522,7 +522,7 @@ static ssize_t iscsi_stat_login_negotiate_fails_show(struct 
config_item *item,
NULL,
 };
 
-struct config_item_type iscsi_stat_login_cit = {
+const struct config_item_type iscsi_stat_login_cit = {
.ct_attrs   = iscsi_stat_login_stats_attrs,
.ct_owner   = THIS_MODULE,
 };
@@ -579,7 +579,7 @@ static ssize_t 
iscsi_stat_logout_abnormal_logouts_show(struct config_item *item,
NULL,
 };
 
-struct config_item_type iscsi_stat_logout_cit = {
+const struct config_item_type iscsi_stat_logout_cit = {
.ct_attrs   = iscsi_stat_logout_stats_attrs,
.ct_owner   = THIS_MODULE,
 };
@@ -801,7 +801,7 @@ static ssize_t iscsi_stat_sess_conn_timeout_errors_show(
NULL,
 };
 
-struct config_item_type iscsi_stat_sess_cit = {
+const struct config_item_type iscsi_stat_sess_cit = {
.ct_attrs   = iscsi_stat_sess_stats_attrs,
.ct_owner   = THIS_MODULE,
 };
diff --git a/drivers/target/target_core_configfs.c 
b/drivers/target/target_core_configfs.c
index 7e87d95..bd87cc2 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -307,7 +307,7 @@ static void target_core_deregister_fabric(
 /*
  * Provides Fabrics Groups and Item Attributes for /sys/kernel/config/target/
  */
-static struct config_item_type target_core_fabrics_item = {
+static const struct config_item_type target_core_fabrics_item = {
.ct_group_ops   = _core_fabric_group_ops,
.ct_attrs   = target_core_fabric_item_attrs,
.ct_owner   = THIS_MODULE,
@@ -2376,7 +2376,7 @@ static void target_core_alua_lu_gp_release(struct 
config_item *item)
.release= target_core_alua_lu_gp_release,
 };
 
-static struct config_item_type target_core_alua_lu_gp_cit = {
+static const struct config_item_type target_core_alua_lu_gp_cit = {
.ct_item_ops= _core_alua_lu_gp_ops,
.ct_attrs   = target_core_alua_lu_gp_attrs,
.ct_owner   = THIS_MODULE,
@@ -2434,7 +2434,7 @@ static void target_core_alua_drop_lu_gp(
.drop_item  = _core_alua_drop_lu_gp,
 };
 
-static struct config_item_type target_core_alua_lu_gps_cit = {
+static const struct config_item_type target_core_alua_lu_gps_cit = {
.ct_item_ops= NULL,
.ct_group_ops   = _core_alua_lu_gps_group_ops,
.ct_owner   = THIS_MODULE,
@@ -2813,7 +2813,7 @@ static void target_core_alua_tg_pt_gp_release(struct 
config_item *item)
.release= target_core_alua_tg_pt_gp_release,
 };
 
-static struct config_item_type target_core_alua_tg_pt_gp_cit = {
+static const struct config_item_type target_core_alua_tg_pt_gp_cit = {
.ct_item_ops= _core_alua_tg_pt_gp_ops,
.ct_attrs   = target_core_alua_tg_pt_gp_attrs,
.ct_owner   = THIS_MODULE,
@@ -2884,7 +2884,7 @@ static void target_core_alua_drop_tg_pt_gp(
  * core/alua/lu_gps and 

Re: dwc2 - ChHltd set, but reason is unknown

2017-10-16 Thread Anders Montonen

On Mon, 16 Oct 2017, Minas Harutyunyan wrote:

On 10/16/2017 12:12 PM, Anders Montonen wrote:

On Mon, 16 Oct 2017, Minas Harutyunyan wrote:

On 10/10/2017 4:35 PM, Anders Montonen wrote:

On Mon, 9 Oct 2017, Minas Harutyunyan wrote:

On 10/9/2017 5:15 PM, Anders Montonen wrote:



We have a custom Altera Cyclone V SoCFPGA board, where connecting a
particular brand of USB memory sticks produces and enless stream of
console errors messages until it is removed from the system.

Could you please provide log with enabled VERBOSE debug messages.

I uploaded a log to 
.

Hi Anders,
1. Lot of "Transaction Error--" seen in log related to mentioned by you
mass storage device (addr=4 and addr=5).
2. In log seen 2 additional devices with addresses 2 and 3 (Control
transfers). Could you please elaborate what kind of devices? Did you
connected any hub to dwc2 root hub? Or any internal to board hub's
connected to dwc2?

Thanks for taking a look at this. As I mentioned in the original post, the
dwc2 root hub is connected to a Microchip LAN9152 combined USB
hub/Ethernet MAC. This is a fixed (PCB trace) connection.


Hi,
Could you please also send register dump.


I made two dumps, before inserting the USB stick and with the memory stick 
inserted.


Before:
GOTGCTL = 0x002c0001
GOTGINT = 0x
GAHBCFG = 0x0027
GUSBCFG = 0x21101710
GRSTCTL = 0x8000
GINTSTS = 0x04200021
GINTMSK = 0xf300080e
GRXSTSR = 0x3ea8c000
GRXSTSP = 0x3ea8c000
GRXFSIZ = 0x0214
GNPTXFSIZ = 0x01000214
GNPTXSTS = 0x08080100
GI2CCTL = 0x
GPVNDCTL = 0x
GGPIO = 0x
GUID = 0x12345678
GSNPSID = 0x4f54293a
GHWCFG1 = 0x
GHWCFG2 = 0x238ffc90
GHWCFG3 = 0x1f8002e8
GHWCFG4 = 0xfe0f0020
GLPMCFG = 0x
GPWRDN = 0x
GDFIFOCFG = 0x06142000
ADPCTL = 0x
HPTXFSIZ = 0x03000314
DPTXFSIZN(1) = 0x03000314
DPTXFSIZN(2) = 0x03000314
DPTXFSIZN(3) = 0x03000314
DPTXFSIZN(4) = 0x03000314
DPTXFSIZN(5) = 0x03000314
DPTXFSIZN(6) = 0x03000314
DPTXFSIZN(7) = 0x03000314
DPTXFSIZN(8) = 0x03000314
DPTXFSIZN(9) = 0x03000314
DPTXFSIZN(10) = 0x03000314
DPTXFSIZN(11) = 0x03000314
DPTXFSIZN(12) = 0x03000314
DPTXFSIZN(13) = 0x03000314
DPTXFSIZN(14) = 0x03000314
DPTXFSIZN(15) = 0x03000314
DCFG = 0x
DCTL = 0x
DSTS = 0x00018c02
DIEPMSK = 0x
DOEPMSK = 0x
DAINT = 0x
DAINTMSK = 0x
DTKNQR1 = 0x
DTKNQR2 = 0x
DTKNQR3 = 0x0c100020
DTKNQR4 = 0x
DVBUSDIS = 0x00011d4b
DVBUSPULSE = 0x05b8
DIEPCTL(0) = 0x00d00040
DIEPCTL(1) = 0x00d08040
DIEPCTL(2) = 0x00d00040
DIEPCTL(3) = 0x00d00040
DIEPCTL(4) = 0x00d08040
DIEPCTL(5) = 0x00d00040
DIEPCTL(6) = 0x00d00040
DIEPCTL(7) = 0x00d00040
DIEPCTL(8) = 0x00dc9810
DIEPCTL(9) = 0x00d00040
DIEPCTL(10) = 0x00d08040
DIEPCTL(11) = 0x00d00040
DIEPCTL(12) = 0x00dc9810
DIEPCTL(13) = 0x00d00040
DIEPCTL(14) = 0x00d08040
DIEPCTL(15) = 0x20dc9810
DOEPCTL(0) = 0x00d00040
DOEPCTL(1) = 0x00d08040
DOEPCTL(2) = 0x00d00040
DOEPCTL(3) = 0x00d00040
DOEPCTL(4) = 0x00d08040
DOEPCTL(5) = 0x00d00040
DOEPCTL(6) = 0x00d00040
DOEPCTL(7) = 0x00d00040
DOEPCTL(8) = 0x00dc9810
DOEPCTL(9) = 0x00d00040
DOEPCTL(10) = 0x00d08040
DOEPCTL(11) = 0x00d00040
DOEPCTL(12) = 0x00dc9810
DOEPCTL(13) = 0x00d00040
DOEPCTL(14) = 0x00d08040
DOEPCTL(15) = 0x20dc9810
DIEPINT(0) = 0x0080
DIEPINT(1) = 0x
DIEPINT(2) = 0x
DIEPINT(3) = 0x
DIEPINT(4) = 0x
DIEPINT(5) = 0x
DIEPINT(6) = 0x
DIEPINT(7) = 0x
DIEPINT(8) = 0x0002
DIEPINT(9) = 0x
DIEPINT(10) = 0x
DIEPINT(11) = 0x
DIEPINT(12) = 0x
DIEPINT(13) = 0x
DIEPINT(14) = 0x
DIEPINT(15) = 0x
DOEPINT(0) = 0x
DOEPINT(1) = 0x
DOEPINT(2) = 0x
DOEPINT(3) = 0x
DOEPINT(4) = 0x
DOEPINT(5) = 0x
DOEPINT(6) = 0x
DOEPINT(7) = 0x
DOEPINT(8) = 0x0002
DOEPINT(9) = 0x
DOEPINT(10) = 0x
DOEPINT(11) = 0x
DOEPINT(12) = 0x
DOEPINT(13) = 0x
DOEPINT(14) = 0x
DOEPINT(15) = 0x
DIEPTSIZ(0) = 0x0004
DIEPTSIZ(1) = 0x803c
DIEPTSIZ(2) = 0x
DIEPTSIZ(3) = 0x2008
DIEPTSIZ(4) = 0x803c
DIEPTSIZ(5) = 0x
DIEPTSIZ(6) = 0x
DIEPTSIZ(7) = 0x2008
DIEPTSIZ(8) = 0x80080010
DIEPTSIZ(9) = 0x2008
DIEPTSIZ(10) = 0x803c
DIEPTSIZ(11) = 0x
DIEPTSIZ(12) = 0x80080010
DIEPTSIZ(13) = 0x2008
DIEPTSIZ(14) = 0x8040
DIEPTSIZ(15) = 0x80080010
DOEPTSIZ(0) = 0x0004
DOEPTSIZ(1) = 

[PATCH 4.14 REGRESSION fix] USB: devio: Revert "USB: devio: Don't corrupt user memory"

2017-10-16 Thread Hans de Goede
Taking the uurb->buffer_length userspace passes in as a maximum for the
actual urbs transfer_buffer_length causes 2 serious issues:

1) It breaks isochronous support for all userspace apps using libusb,
   as existing libusb versions pass in 0 for uurb->buffer_length,
   relying on the kernel using the lenghts of the usbdevfs_iso_packet_desc
   descriptors passed in added together as buffer length.

   This for example causes redirection of USB audio and Webcam's into
   virtual machines using qemu-kvm to no longer work. This is a userspace
   ABI break and as such must be reverted.

   Note that the original commit does not protect other users / the
   kernels memory, it only stops the userspace process making the call
   from shooting itself in the foot.

2) It may cause the kernel to program host controllers to DMA over random
   memory. Just as the devio code used to only look at the iso_packet_desc
   lenghts, the host drivers do the same, relying on the submitter of the
   urbs to make sure the entire buffer is large enough and not checking
   transfer_buffer_length.

   But the "USB: devio: Don't corrupt user memory" commit now takes the
   userspace provided uurb->buffer_length for the buffer-size while copying
   over the user-provided iso_packet_desc lengths 1:1, allowing the user
   to specify a small buffer size while programming the host controller to
   dma a lot more data.

   (Atleast the ohci, uhci, xhci and fhci drivers do not check
transfer_buffer_length for isoc transfers.)

This reverts commit fa1ed74eb1c2 ("USB: devio: Don't corrupt user memory")
fixing both these issues.

Cc: Dan Carpenter 
Cc: Alan Stern 
Cc: Greg Kroah-Hartman 
Cc: sta...@vger.kernel.org
Signed-off-by: Hans de Goede 
---
 drivers/usb/core/devio.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 4664e543cf2f..e9326f31db8d 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1576,11 +1576,7 @@ static int proc_do_submiturb(struct usb_dev_state *ps, 
struct usbdevfs_urb *uurb
totlen += isopkt[u].length;
}
u *= sizeof(struct usb_iso_packet_descriptor);
-   if (totlen <= uurb->buffer_length)
-   uurb->buffer_length = totlen;
-   else
-   WARN_ONCE(1, "uurb->buffer_length is too short %d vs 
%d",
- totlen, uurb->buffer_length);
+   uurb->buffer_length = totlen;
break;
 
default:
-- 
2.14.2

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


[PATCH] usb: dwc2: disable erroneous overcurrent condition

2017-10-16 Thread Dinh Nguyen
For the case where an external VBUS is used, we should enable the external
VBUS comparator in the driver. This would prevent an unnecessary
overcurrent error which would then disable the host port.

This patch uses the standard 'disable-over-current' binding to allow of the
option of disabling the over-current condition.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/core.h   | 4 
 drivers/usb/dwc2/hcd.c| 5 +
 drivers/usb/dwc2/params.c | 3 +++
 3 files changed, 12 insertions(+)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 8367d4f9..730d7eb 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -395,6 +395,9 @@ enum dwc2_ep0_state {
  *   (default when phy_type is UTMI+ or ULPI)
  *   1 - 6 MHz
  *   (default when phy_type is Full Speed)
+ * @oc_disable:Flag to disable overcurrent condition.
+ * 0 - Allow overcurrent condition to get detected
+ * 1 - Disable overcurrent condtion to get detected
  * @ts_dline:   Enable Term Select Dline pulsing
  *   0 - No (default)
  *   1 - Yes
@@ -492,6 +495,7 @@ struct dwc2_core_params {
bool dma_desc_fs_enable;
bool host_support_fs_ls_low_power;
bool host_ls_low_power_phy_clk;
+   bool oc_disable;
 
u8 host_channels;
u16 host_rx_fifo_size;
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index c263114..5e20336 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -213,6 +213,11 @@ static int dwc2_hs_phy_init(struct dwc2_hsotg *hsotg, bool 
select_phy)
usbcfg &= ~(GUSBCFG_PHYIF16 | GUSBCFG_DDRSEL);
if (hsotg->params.phy_ulpi_ddr)
usbcfg |= GUSBCFG_DDRSEL;
+
+   /* Set external VBUS indicator as needed. */
+   if (hsotg->params.oc_disable)
+   usbcfg |= (GUSBCFG_ULPI_INT_VBUS_IND |
+  GUSBCFG_INDICATORPASSTHROUGH);
break;
case DWC2_PHY_TYPE_PARAM_UTMI:
/* UTMI+ interface */
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index a3ffe97..39e02cd 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -335,6 +335,9 @@ static void dwc2_get_device_properties(struct dwc2_hsotg 
*hsotg)
   num);
}
}
+
+   if (of_find_property(hsotg->dev->of_node, "disable-over-current", NULL))
+   p->oc_disable = true;
 }
 
 static void dwc2_check_param_otg_cap(struct dwc2_hsotg *hsotg)
-- 
2.7.4

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


[PATCH] usb: hub: Allow reset retry for USB2 devices on connect bounce

2017-10-16 Thread Mathias Nyman
If the connect status change is set during reset signaling, but
the status remains connected just retry port reset.

This solves an issue with connecting a 90W HP Thunderbolt 3 dock
with a Lenovo Carbon x1 (5th generation) which causes a 30min loop
of a high speed device being re-discovererd before usb ports starts
working.

[...]
[ 389.023845] usb 3-1: new high-speed USB device number 55 using xhci_hcd
[ 389.491841] usb 3-1: new high-speed USB device number 56 using xhci_hcd
[ 389.959928] usb 3-1: new high-speed USB device number 57 using xhci_hcd
[...]

This is caused by a high speed device that doesn't successfully go to the
enabled state after the second port reset. Instead the connection bounces
(connected, with connect status change), bailing out completely from
enumeration just to restart from scratch.

Link: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1716332

Cc: Stable 
Signed-off-by: Mathias Nyman 
---
 drivers/usb/core/hub.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 41eaf0b..3461347 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2710,13 +2710,13 @@ static int hub_port_wait_reset(struct usb_hub *hub, int 
port1,
if (!(portstatus & USB_PORT_STAT_CONNECTION))
return -ENOTCONN;
 
-   /* bomb out completely if the connection bounced.  A USB 3.0
-* connection may bounce if multiple warm resets were issued,
+   /* Retry if connect change is set but status is still connected.
+* A USB 3.0 connection may bounce if multiple warm resets were issued,
 * but the device may have successfully re-connected. Ignore it.
 */
if (!hub_is_superspeed(hub->hdev) &&
(portchange & USB_PORT_STAT_C_CONNECTION))
-   return -ENOTCONN;
+   return -EAGAIN;
 
if (!(portstatus & USB_PORT_STAT_ENABLE))
return -EBUSY;
@@ -2789,6 +2789,10 @@ static int hub_port_reset(struct usb_hub *hub, int port1,
dev_dbg(hub->intfdev,
"port_wait_reset: err = %d\n",
status);
+   /* USB2 connection bounced, but remains connected */
+   if (status == -EAGAIN)
+   usb_clear_port_feature(hub->hdev, port1,
+   USB_PORT_FEAT_C_CONNECTION);
}
 
/* Check for disconnect or reset */
-- 
2.7.4

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


Re: VL805 xHCI DMA read faults

2017-10-16 Thread Hao Wei Tee
On 16/10/2017 20:23, Robin Murphy wrote:
> Is your VL805 on the motherboard or an add-on card? One other possibly
> important difference that comes to mind is that on my arm64 system Linux
> is the only agent to ever touch the xHCI - UEFI doesn't even try to
> probe it. It seems likely that a full-featured PC firmware might have
> been more hands-on, especially if the controller is on-board.

Ah, right, I probably should have mentioned that -- it's on a Gigabyte
H61M-S2P rev 3. The H61 chipset doesn't have USB 3.0, of course, so Gigabyte
tacked on this VIA VL805.

> It seems noteworthy that these RMRRs are within about 10MB of the
> faulting address...
> 
> ...and that correspondingly for this to be a Linux-allocated IOVA would
> mean over 540MB having been mapped for DMA already, which seems somewhat
> less likely than it being some leftover physical address from firmware.
> 
> Can you try instrumenting xhci_segment_alloc() to get an idea of what
> the actual DMA addresses of the various queues are at this point?
> 
> Robin.

Will do.

-- 
Hao Wei
--
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: musb: sunxi: Explicitly release USB PHY on exit

2017-10-16 Thread Jonathan Liu
On 16 October 2017 at 23:49, Bin Liu  wrote:
> On Mon, Oct 16, 2017 at 04:13:51PM +1100, Jonathan Liu wrote:
>> On 10 October 2017 at 14:22, Bin Liu  wrote:
>> > On Tue, Oct 10, 2017 at 01:45:25PM +1100, Jonathan Liu wrote:
>> >> This fixes a kernel oops when unloading the driver due to usb_put_phy
>> >> being called after usb_phy_generic_unregister when the device is
>> >> detached. Calling usb_phy_generic_unregister causes x->dev->driver to
>> >> be NULL in usb_put_phy and results in a NULL pointer dereference.
>> >>
>> >> Cc: sta...@vger.kernel.org # v4.3+
>> >> Signed-off-by: Jonathan Liu 
>> >> ---
>> >> Changes for v2:
>> >>  - Use devm_usb_put_phy instead of usb_put_phy
>> >>
>> >>  drivers/usb/musb/sunxi.c | 2 ++
>> >>  1 file changed, 2 insertions(+)
>> >>
>> >> diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c
>> >> index c9a09b5bb6e5..dc353e24d53c 100644
>> >> --- a/drivers/usb/musb/sunxi.c
>> >> +++ b/drivers/usb/musb/sunxi.c
>> >> @@ -297,6 +297,8 @@ static int sunxi_musb_exit(struct musb *musb)
>> >>   if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, >flags))
>> >>   sunxi_sram_release(musb->controller->parent);
>> >>
>> >> + devm_usb_put_phy(glue->dev, glue->xceiv);
>> >> +
>> >>   return 0;
>> >>  }
>> >
>> >
>>
>> > Applied. Thanks.
>> > -Bin.
>>
>> Which repository was it applied to?
>
> I don't have a public repo (yet), but the patch has been sent to Greg,
> so it should be merged into the next -rc.
>
> Regards,
> -Bin.

The MAINTAINERS file has
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git listed as
the tree for drivers/usb/musb/. I guess that should be updated.

Regards,
Jonathan
--
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: musb: sunxi: Explicitly release USB PHY on exit

2017-10-16 Thread Bin Liu
On Mon, Oct 16, 2017 at 04:13:51PM +1100, Jonathan Liu wrote:
> On 10 October 2017 at 14:22, Bin Liu  wrote:
> > On Tue, Oct 10, 2017 at 01:45:25PM +1100, Jonathan Liu wrote:
> >> This fixes a kernel oops when unloading the driver due to usb_put_phy
> >> being called after usb_phy_generic_unregister when the device is
> >> detached. Calling usb_phy_generic_unregister causes x->dev->driver to
> >> be NULL in usb_put_phy and results in a NULL pointer dereference.
> >>
> >> Cc: sta...@vger.kernel.org # v4.3+
> >> Signed-off-by: Jonathan Liu 
> >> ---
> >> Changes for v2:
> >>  - Use devm_usb_put_phy instead of usb_put_phy
> >>
> >>  drivers/usb/musb/sunxi.c | 2 ++
> >>  1 file changed, 2 insertions(+)
> >>
> >> diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c
> >> index c9a09b5bb6e5..dc353e24d53c 100644
> >> --- a/drivers/usb/musb/sunxi.c
> >> +++ b/drivers/usb/musb/sunxi.c
> >> @@ -297,6 +297,8 @@ static int sunxi_musb_exit(struct musb *musb)
> >>   if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, >flags))
> >>   sunxi_sram_release(musb->controller->parent);
> >>
> >> + devm_usb_put_phy(glue->dev, glue->xceiv);
> >> +
> >>   return 0;
> >>  }
> >
> >
> 
> > Applied. Thanks.
> > -Bin.
> 
> Which repository was it applied to?

I don't have a public repo (yet), but the patch has been sent to Greg,
so it should be merged into the next -rc.

Regards,
-Bin.
--
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: VL805 xHCI DMA read faults

2017-10-16 Thread Robin Murphy
On 16/10/17 12:54, Hao Wei Tee wrote:
> On 12/10/2017 21:36, Mathias Nyman wrote:
>> You could try booting with xhci_hcd.dyndbg=+p added to the kernel command 
>> line.
> 
> I can't find anything relevant... Hmm.

Is your VL805 on the motherboard or an add-on card? One other possibly
important difference that comes to mind is that on my arm64 system Linux
is the only agent to ever touch the xHCI - UEFI doesn't even try to
probe it. It seems likely that a full-featured PC firmware might have
been more hands-on, especially if the controller is on-board.

> Command line: BOOT_IMAGE=/boot/vmlinuz-linux root=... rw intel_iommu=on 
> xhci_hcd.dyndbg=+p
> ACPI: DMAR 0xDE2C20E0 78 (v01 INTEL  SNB  0001 INTL 
> 0001)
> DMAR: IOMMU enabled
> DMAR: Host address width 36
> DMAR: DRHD base: 0x00fed9 flags: 0x1
> DMAR: dmar0: reg_base_addr fed9 ver 1:0 cap c9008020660262 ecap f0105a
> DMAR: RMRR base: 0x00dec75000 end: 0x00dec83fff
> DMAR-IR: IOAPIC id 2 under DRHD base  0xfed9 IOMMU 0
> DMAR-IR: HPET id 0 under DRHD base 0xfed9
> DMAR-IR: Queued invalidation will be enabled to support x2apic and 
> Intr-remapping.
> DMAR-IR: Enabled IRQ remapping in x2apic mode
> DMAR: No ATSR found
> DMAR: dmar0: Using Queued invalidation
> DMAR: Setting RMRR:
> DMAR: Setting identity map for device :00:1a.0 [0xdec75000 - 0xdec83fff]
> DMAR: Setting identity map for device :00:1d.0 [0xdec75000 - 0xdec83fff]

It seems noteworthy that these RMRRs are within about 10MB of the
faulting address...

> DMAR: Prepare 0-16MiB unity mapping for LPC
> DMAR: Setting identity map for device :00:1f.0 [0x0 - 0xff]
> DMAR: Intel(R) Virtualization Technology for Directed I/O
> ...
> iommu: Adding device :03:00.0 to group 11
> ...
> xhci_hcd :03:00.0: xHCI Host Controller
> xhci_hcd :03:00.0: new USB bus registered, assigned bus number 2
> xhci_hcd :03:00.0: xHCI capability registers at c3ed00c99000:
> xhci_hcd :03:00.0: CAPLENGTH AND HCIVERSION 0x120:
> xhci_hcd :03:00.0: CAPLENGTH: 0x20
> xhci_hcd :03:00.0: HCIVERSION: 0x100
> xhci_hcd :03:00.0: HCSPARAMS 1: 0x5000420
> xhci_hcd :03:00.0:   Max device slots: 32
> xhci_hcd :03:00.0:   Max interrupters: 4
> xhci_hcd :03:00.0:   Max ports: 5
> xhci_hcd :03:00.0: HCSPARAMS 2: 0xfc31
> xhci_hcd :03:00.0:   Isoc scheduling threshold: 1
> xhci_hcd :03:00.0:   Maximum allowed segments in event ring: 3
> xhci_hcd :03:00.0: HCSPARAMS 3 0xe70004:
> xhci_hcd :03:00.0:   Worst case U1 device exit latency: 4
> xhci_hcd :03:00.0:   Worst case U2 device exit latency: 231
> xhci_hcd :03:00.0: HCC PARAMS 0x2841eb:
> xhci_hcd :03:00.0:   HC generates 64 bit addresses
> xhci_hcd :03:00.0:   HC hasn't Contiguous Frame ID Capability
> xhci_hcd :03:00.0:   HC can't generate Stopped - Short Package event
> xhci_hcd :03:00.0:   FIXME: more HCCPARAMS debugging
> xhci_hcd :03:00.0: RTSOFF 0x200:
> xhci_hcd :03:00.0: xHCI operational registers at c3ed00c99020:
> xhci_hcd :03:00.0: USBCMD 0x0:
> xhci_hcd :03:00.0:   HC is being stopped
> xhci_hcd :03:00.0:   HC has finished hard reset
> xhci_hcd :03:00.0:   Event Interrupts disabled
> xhci_hcd :03:00.0:   Host System Error Interrupts disabled
> xhci_hcd :03:00.0:   HC has finished light reset
> xhci_hcd :03:00.0: USBSTS 0x1:
> xhci_hcd :03:00.0:   Event ring is empty
> xhci_hcd :03:00.0:   No Host System Error
> xhci_hcd :03:00.0:   HC is halted
> xhci_hcd :03:00.0: c3ed00c99420 port status reg = 0x4ee1
> xhci_hcd :03:00.0: c3ed00c99424 port power reg = 0x0
> xhci_hcd :03:00.0: c3ed00c99428 port link reg = 0x0
> xhci_hcd :03:00.0: c3ed00c9942c port reserved reg = 0x0
> xhci_hcd :03:00.0: c3ed00c99430 port status reg = 0x2a0
> xhci_hcd :03:00.0: c3ed00c99434 port power reg = 0x0
> xhci_hcd :03:00.0: c3ed00c99438 port link reg = 0x0
> xhci_hcd :03:00.0: c3ed00c9943c port reserved reg = 0x0
> xhci_hcd :03:00.0: c3ed00c99440 port status reg = 0x2a0
> xhci_hcd :03:00.0: c3ed00c99444 port power reg = 0x0
> xhci_hcd :03:00.0: c3ed00c99448 port link reg = 0x0
> xhci_hcd :03:00.0: c3ed00c9944c port reserved reg = 0x0
> xhci_hcd :03:00.0: c3ed00c99450 port status reg = 0x2a0
> xhci_hcd :03:00.0: c3ed00c99454 port power reg = 0x0
> xhci_hcd :03:00.0: c3ed00c99458 port link reg = 0x0
> xhci_hcd :03:00.0: c3ed00c9945c port reserved reg = 0x0
> xhci_hcd :03:00.0: c3ed00c99460 port status reg = 0x2a0
> xhci_hcd :03:00.0: c3ed00c99464 port power reg = 0x0
> xhci_hcd :03:00.0: c3ed00c99468 port link reg = 0x0
> xhci_hcd :03:00.0: c3ed00c9946c port reserved reg = 0x0
> xhci_hcd :03:00.0: QUIRK: Resetting on resume
> xhci_hcd :03:00.0: // Halt the HC
> xhci_hcd :03:00.0: Resetting HCD
> xhci_hcd 

Re: VL805 xHCI DMA read faults

2017-10-16 Thread Hao Wei Tee
On 12/10/2017 21:36, Mathias Nyman wrote:
> You could try booting with xhci_hcd.dyndbg=+p added to the kernel command 
> line.

I can't find anything relevant... Hmm.

Command line: BOOT_IMAGE=/boot/vmlinuz-linux root=... rw intel_iommu=on 
xhci_hcd.dyndbg=+p
ACPI: DMAR 0xDE2C20E0 78 (v01 INTEL  SNB  0001 INTL 
0001)
DMAR: IOMMU enabled
DMAR: Host address width 36
DMAR: DRHD base: 0x00fed9 flags: 0x1
DMAR: dmar0: reg_base_addr fed9 ver 1:0 cap c9008020660262 ecap f0105a
DMAR: RMRR base: 0x00dec75000 end: 0x00dec83fff
DMAR-IR: IOAPIC id 2 under DRHD base  0xfed9 IOMMU 0
DMAR-IR: HPET id 0 under DRHD base 0xfed9
DMAR-IR: Queued invalidation will be enabled to support x2apic and 
Intr-remapping.
DMAR-IR: Enabled IRQ remapping in x2apic mode
DMAR: No ATSR found
DMAR: dmar0: Using Queued invalidation
DMAR: Setting RMRR:
DMAR: Setting identity map for device :00:1a.0 [0xdec75000 - 0xdec83fff]
DMAR: Setting identity map for device :00:1d.0 [0xdec75000 - 0xdec83fff]
DMAR: Prepare 0-16MiB unity mapping for LPC
DMAR: Setting identity map for device :00:1f.0 [0x0 - 0xff]
DMAR: Intel(R) Virtualization Technology for Directed I/O
...
iommu: Adding device :03:00.0 to group 11
...
xhci_hcd :03:00.0: xHCI Host Controller
xhci_hcd :03:00.0: new USB bus registered, assigned bus number 2
xhci_hcd :03:00.0: xHCI capability registers at c3ed00c99000:
xhci_hcd :03:00.0: CAPLENGTH AND HCIVERSION 0x120:
xhci_hcd :03:00.0: CAPLENGTH: 0x20
xhci_hcd :03:00.0: HCIVERSION: 0x100
xhci_hcd :03:00.0: HCSPARAMS 1: 0x5000420
xhci_hcd :03:00.0:   Max device slots: 32
xhci_hcd :03:00.0:   Max interrupters: 4
xhci_hcd :03:00.0:   Max ports: 5
xhci_hcd :03:00.0: HCSPARAMS 2: 0xfc31
xhci_hcd :03:00.0:   Isoc scheduling threshold: 1
xhci_hcd :03:00.0:   Maximum allowed segments in event ring: 3
xhci_hcd :03:00.0: HCSPARAMS 3 0xe70004:
xhci_hcd :03:00.0:   Worst case U1 device exit latency: 4
xhci_hcd :03:00.0:   Worst case U2 device exit latency: 231
xhci_hcd :03:00.0: HCC PARAMS 0x2841eb:
xhci_hcd :03:00.0:   HC generates 64 bit addresses
xhci_hcd :03:00.0:   HC hasn't Contiguous Frame ID Capability
xhci_hcd :03:00.0:   HC can't generate Stopped - Short Package event
xhci_hcd :03:00.0:   FIXME: more HCCPARAMS debugging
xhci_hcd :03:00.0: RTSOFF 0x200:
xhci_hcd :03:00.0: xHCI operational registers at c3ed00c99020:
xhci_hcd :03:00.0: USBCMD 0x0:
xhci_hcd :03:00.0:   HC is being stopped
xhci_hcd :03:00.0:   HC has finished hard reset
xhci_hcd :03:00.0:   Event Interrupts disabled
xhci_hcd :03:00.0:   Host System Error Interrupts disabled
xhci_hcd :03:00.0:   HC has finished light reset
xhci_hcd :03:00.0: USBSTS 0x1:
xhci_hcd :03:00.0:   Event ring is empty
xhci_hcd :03:00.0:   No Host System Error
xhci_hcd :03:00.0:   HC is halted
xhci_hcd :03:00.0: c3ed00c99420 port status reg = 0x4ee1
xhci_hcd :03:00.0: c3ed00c99424 port power reg = 0x0
xhci_hcd :03:00.0: c3ed00c99428 port link reg = 0x0
xhci_hcd :03:00.0: c3ed00c9942c port reserved reg = 0x0
xhci_hcd :03:00.0: c3ed00c99430 port status reg = 0x2a0
xhci_hcd :03:00.0: c3ed00c99434 port power reg = 0x0
xhci_hcd :03:00.0: c3ed00c99438 port link reg = 0x0
xhci_hcd :03:00.0: c3ed00c9943c port reserved reg = 0x0
xhci_hcd :03:00.0: c3ed00c99440 port status reg = 0x2a0
xhci_hcd :03:00.0: c3ed00c99444 port power reg = 0x0
xhci_hcd :03:00.0: c3ed00c99448 port link reg = 0x0
xhci_hcd :03:00.0: c3ed00c9944c port reserved reg = 0x0
xhci_hcd :03:00.0: c3ed00c99450 port status reg = 0x2a0
xhci_hcd :03:00.0: c3ed00c99454 port power reg = 0x0
xhci_hcd :03:00.0: c3ed00c99458 port link reg = 0x0
xhci_hcd :03:00.0: c3ed00c9945c port reserved reg = 0x0
xhci_hcd :03:00.0: c3ed00c99460 port status reg = 0x2a0
xhci_hcd :03:00.0: c3ed00c99464 port power reg = 0x0
xhci_hcd :03:00.0: c3ed00c99468 port link reg = 0x0
xhci_hcd :03:00.0: c3ed00c9946c port reserved reg = 0x0
xhci_hcd :03:00.0: QUIRK: Resetting on resume
xhci_hcd :03:00.0: // Halt the HC
xhci_hcd :03:00.0: Resetting HCD
xhci_hcd :03:00.0: // Reset the HC
DMAR: DRHD: handling fault status reg 3
DMAR: [DMA Read] Request device [03:00.0] fault addr de28a000 [fault reason 01] 
Present bit in root entry is clear
...
xhci_hcd :03:00.0: can't setup: -110
xhci_hcd :03:00.0: USB bus 2 deregistered
xhci_hcd :03:00.0: init :03:00.0 fail, -110
xhci_hcd: probe of :03:00.0 failed with error -110

-- 
Hao Wei
--
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: cdc_acm: Add quirk for Elatec TWN3

2017-10-16 Thread Oliver Neukum
Am Mittwoch, den 11.10.2017, 11:10 +0300 schrieb Maksim Salau:
> Elatec TWN3 has the union descriptor on data interface. This results in
> failure to bind the device to the driver with the following log:
>   usb 1-1.2: new full speed USB device using streamplug-ehci and address 4
>   usb 1-1.2: New USB device found, idVendor=09d8, idProduct=0320
>   usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
>   usb 1-1.2: Product: RFID Device (COM)
>   usb 1-1.2: Manufacturer: OEM
>   cdc_acm 1-1.2:1.0: Zero length descriptor references
>   cdc_acm: probe of 1-1.2:1.0 failed with error -22
> 
> Adding the NO_UNION_NORMAL quirk for the device fixes the issue.
> 
> Signed-off-by: Maksim Salau 
Acked-by: Oliver Neukum 
--
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: xhci_hcd 0000:00:14.0: WARN Event TRB for slot 1 ep 2 with no TDs queued?

2017-10-16 Thread Mathias Nyman

On 13.10.2017 14:46, Yaroslav Isakov wrote:

Hello, Mathias! Did you get a chance to look into this bug?


Other things came up and this got a bit delayed.
Attached is a patch to test

-Mathias


2017-07-20 19:15 GMT+03:00 Yaroslav Isakov :

Yes, I can definitely test the patch

2017-07-20 19:16 GMT+03:00 Mathias Nyman :

On 20.07.2017 18:07, Yaroslav Isakov wrote:


Here it is

2017-07-20 18:06 GMT+03:00 Mathias Nyman :


On 20.07.2017 17:43, Yaroslav Isakov wrote:



Hello everyone! I saw this thread some months ago, but do not know how
to properly reply to it. I have the same problem, and it's just not
few messages - it was about 40k messages in 10 minutes. No functional
of my USB device (which is CCID USB token) is broken, just enormous
amount of spam in the logs. I'm on 4.12 kernel, but I've seen this
error on 4.11 and 4.9. Could this problem be caused by a bug in e.g.
libusb, not a device itself?
--




I'd start by looking at xhci, can you take xhci traces of this?

mount -t debugfs none /sys/kernel/debug
echo 81920 > /sys/kernel/debug/tracing/buffer_size_kb
echo 1 > /sys/kernel/debug/tracing/events/xhci-hcd/enable

and then send me the content of
/sys/kernel/debug/tracing/trace

I'll be away for a couple of weeks, so next response might take some time

-Mathias




Think I found something.   (details mostly for myself in to remember this)
A short transfer response on a bulk in transfer which is not the last TRB of
a TD

According to specs xhci will issue short transfer events both on the short
TRB, _and_
on the last TRB of the TD in case any previous TRB in the TD was short
(see xhci 4.11.3.1)

After the first short transfer event the driver fast forward past this TD.
(and the last TRB)
when we get the second short transfer event there are no TRBs queued and you
see the
warning.

Warning should be harmless in this case, but annoying.
If I write a patch can you try it out?

As a reference, a snippet when log when a 65556 byte transfer is queued,
split into 5 pieces (TRBS),
and we get short transfer events for first and last TRB

* A URB asking for 65556 bytes is queues:
2369.450362: xhci_urb_enqueue: ep1in-bulk: urb 8801398f6540 pipe
3221258880 slot 1 length 0/65556 sgs 5/5 stream 0 flags 00040200
* split into 5 pieces ( TRBs at 0x0002169cb520, ..530, ..540, ..550 and
..560)
2369.450363: xhci_queue_trb: BULK: Buffer 00010a7dc000 length 16384 TD
size 31 intr 0 type 'Normal' flags b:i:i:C:s:I:e:C
2369.450363: xhci_inc_enq: BULK 88021726c780: enq
0x0002169cb530(0x0002169cb000) deq
0x0002169cb520(0x0002169cb000) segs 2 stream 0 free_trbs 508 bounce
6\
2369.450363: xhci_queue_trb: BULK: Buffer 00011e97 length 16384 TD
size 31 intr 0 type 'Normal' flags b:i:i:C:s:I:e:c
2369.450363: xhci_inc_enq: BULK 88021726c780: enq
0x0002169cb540(0x0002169cb000) deq
0x0002169cb520(0x0002169cb000) segs 2 stream 0 free_trbs 507 bounce
6\
2369.450363: xhci_queue_trb: BULK: Buffer 0001b63ac000 length 16384 TD
size 31 intr 0 type 'Normal' flags b:i:i:C:s:I:e:c
2369.450363: xhci_inc_enq: BULK 88021726c780: enq
0x0002169cb550(0x0002169cb000) deq
0x0002169cb520(0x0002169cb000) segs 2 stream 0 free_trbs 506 bounce
6\
2369.450364: xhci_queue_trb: BULK: Buffer 00010a7ac000 length 16384 TD
size 1 intr 0 type 'Normal' flags b:i:i:C:s:I:e:c
2369.450364: xhci_inc_enq: BULK 88021726c780: enq
0x0002169cb560(0x0002169cb000) deq
0x0002169cb520(0x0002169cb000) segs 2 stream 0 free_trbs 505 bounce
6\
2369.450364: xhci_queue_trb: BULK: Buffer 0001a26adf40 length 20 TD size
0 intr 0 type 'Normal' flags b:i:I:c:s:I:e:c
2369.450364: xhci_inc_enq: BULK 88021726c780: enq
0x0002169cb570(0x0002169cb000) deq
0x0002169cb520(0x0002169cb000) segs 2 stream 0 free_trbs 504 bounce
6\
* short packet event for first TRB at ..520
2369.450505: xhci_handle_event: EVENT: TRB 0002169cb520 status 'Short
Packet' len 16334 slot 1 ep 3 type 'Transfer Event' flags e:c
2369.450506: xhci_handle_transfer: BULK: Buffer 00010a7dc000 length
16384 TD size 31 intr 0 type 'Normal' flags b:i:i:C:s:I:e:c
* fast forward past this TD, move dequeue to ..570)
2369.450506: xhci_inc_deq: BULK 88021726c780: enq
0x0002169cb570(0x0002169cb000) deq
0x0002169cb530(0x0002169cb000) segs 2 stream 0 free_trbs 505 bounce
6\
2369.450506: xhci_inc_deq: BULK 88021726c780: enq
0x0002169cb570(0x0002169cb000) deq
0x0002169cb540(0x0002169cb000) segs 2 stream 0 free_trbs 506 bounce
6\
2369.450506: xhci_inc_deq: BULK 88021726c780: enq
0x0002169cb570(0x0002169cb000) deq
0x0002169cb550(0x0002169cb000) segs 2 stream 0 free_trbs 507 bounce
6\
2369.450506: xhci_inc_deq: BULK 88021726c780: enq
0x0002169cb570(0x0002169cb000) deq
0x0002169cb560(0x0002169cb000) segs 2 stream 0 free_trbs 508 bounce
6\

[PATCH 2/2] ARM: dts: r8a7743: Add xhci support to SoC dtsi

2017-10-16 Thread Biju Das
From: Fabrizio Castro 

Add node for xhci. Boards DT files will enable it if needed.

Signed-off-by: Fabrizio Castro 
---
 arch/arm/boot/dts/r8a7743.dtsi | 20 
 1 file changed, 20 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7743.dtsi b/arch/arm/boot/dts/r8a7743.dtsi
index 699c040..386bf07 100644
--- a/arch/arm/boot/dts/r8a7743.dtsi
+++ b/arch/arm/boot/dts/r8a7743.dtsi
@@ -931,6 +931,26 @@
status = "disabled";
};
 
+   /*
+* pci1 and xhci share the same phy, therefore only one of them
+* can be active at any one time. If both of them are enabled,
+* a race condition will determine who'll control the phy.
+* A firmware file is needed by the xhci driver in order for
+* USB 3.0 to work properly.
+*/
+   xhci: usb@ee00 {
+   compatible = "renesas,xhci-r8a7743",
+"renesas,rcar-gen2-xhci";
+   reg = <0 0xee00 0 0xc00>;
+   interrupts = ;
+   clocks = < CPG_MOD 328>;
+   power-domains = < R8A7743_PD_ALWAYS_ON>;
+   resets = < 328>;
+   phys = < 1>;
+   phy-names = "usb";
+   status = "disabled";
+   };
+
sdhi0: sd@ee10 {
compatible = "renesas,sdhi-r8a7743";
reg = <0 0xee10 0 0x328>;
-- 
1.9.1

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


[PATCH 1/2] dt-bindings: usb-xhci: Document r8a7743 support

2017-10-16 Thread Biju Das
From: Fabrizio Castro 

Document r8a7743 xhci support. The driver will use the fallback
compatible string "renesas,rcar-gen2-xhci", therefore no driver
change is needed.

Signed-off-by: Fabrizio Castro 
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 2d80b60..4125d02 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -7,12 +7,14 @@ Required properties:
 - "marvell,armada3700-xhci" for Armada 37xx SoCs
 - "marvell,armada-375-xhci" for Armada 375 SoCs
 - "marvell,armada-380-xhci" for Armada 38x SoCs
+- "renesas,xhci-r8a7743" for r8a7743 SoC
 - "renesas,xhci-r8a7790" for r8a7790 SoC
 - "renesas,xhci-r8a7791" for r8a7791 SoC
 - "renesas,xhci-r8a7793" for r8a7793 SoC
 - "renesas,xhci-r8a7795" for r8a7795 SoC
 - "renesas,xhci-r8a7796" for r8a7796 SoC
-- "renesas,rcar-gen2-xhci" for a generic R-Car Gen2 compatible device
+- "renesas,rcar-gen2-xhci" for a generic R-Car Gen2 or RZ/G1 compatible
+  device
 - "renesas,rcar-gen3-xhci" for a generic R-Car Gen3 compatible device
 - "xhci-platform" (deprecated)
 
-- 
1.9.1

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


[PATCH 0/2] Add XHCI support

2017-10-16 Thread Biju Das
Hello,

This series aims to add USB XHCI support for iWave RZ/G1M (R8A7743) board.
This series has been tested against renesas-dev tag 20171013-v4.14-rc4.

Regards,

Fabrizio Castro (2):
  dt-bindings: usb-xhci: Document r8a7743 support
  ARM: dts: r8a7743: Add xhci support to SoC dtsi

 Documentation/devicetree/bindings/usb/usb-xhci.txt |  4 +++-
 arch/arm/boot/dts/r8a7743.dtsi | 20 
 2 files changed, 23 insertions(+), 1 deletion(-)

-- 
1.9.1

--
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: [RESEND x2][PATCH 0/3] dwc2 fixes for edge cases on hikey

2017-10-16 Thread Minas Harutyunyan
On 10/12/2017 10:06 PM, John Stultz wrote:
> On Thu, Oct 12, 2017 at 12:59 AM, Minas Harutyunyan
>  wrote:
>>
>> 1. Vardan's patch fixing issue when dwc2 switched from host to device
>> mode. It's allow to make functional device after reconnecting without
>> tracking UDC state.
> 
> While I'm sure Vardan's patch is useful, I worry that its resolving a
> different issue then what I'm trying to address, as it doesn't seem to
> help the problems I'm seeing.
> 
>> 2. I suppose that your patch "[RESEND x2][PATCH 1/3] usb: dwc2: Improve
>> gadget state disconnection handling" not a good way to set correct UDC
>> state. You added calling device mode functions dwc2_hsotg_disconnect()
>> and dwc2_hsotg_core_init_disconnected() while core in Host mode and as
>> result additional unwanted "mode mismatch" interrupts will be asserted.
> 
> Apologies, I'm not sure I'm understanding you here. Forgive me if I'm
> misinterpreting your feedback.
> 
> So, the "usb: dwc2: Improve gadget state disconnection handling" isn't
> itself doing the UDC state handling.
> 
> Personally I see it as improving a previously applied fix
> (dad3f793f20f - usb: dwc2: Make sure we disconnect the gadget state).
>   So instead of calling dwc2_hsotg_disconnect() in
> dwc2_conn_id_status_change() when transitioning INTO device/B mode,
> which was added due to earlier problems with state tracking (as when
> we unplug the gadget cable, nothing else triggers the hsotg_disconnect
> code), I'm instead suggesting we call dwc2_hsotg_disconnect() when we
> transition into host/A mode.
> 
> This only allows us to do proper UDC state handling later, since we
> properly run the disconnect code for device when we switch into host
> mode.
> 
> If I'm understanding you, you seem to be objecting to this, as calling
> dwc2_hsotg_disconnect() while we are transitioning to host mode can
> cause "mode mismatch" interrupts. I've not seen this in practice with
> this patch, but you know the logic better and it could be possible.
> 
> Now, I'm of course open to other approaches, but it seems that we need
> *something* to call dwc2_hsotg_disconnect() when the otg cable is
> removed (which currently just doesn't happen). The earlier patch
> calling dwc2_hsotg_disconnect() when we are entering device/B mode
> avoids the state tracking warnings but, doesn't seem correct (nor does
> it allow for things like proper UDC state handling).
> 
>> 3. Function dwc2_conn_id_status_change() called when connector ID status
>> changed. This interrupt asserted only when A-plug connected or
>> disconnected. Connecting/disconnecting B-plug doesn't assert this interrupt.
> 
> Ok. What I'm seeing may be somewhat hardware specific then, as on
> HiKey, we have a switch that enables a on-board USB hub when the OTG
> plug is removed.  This may be the root of the issue, but I guess I'm
> at a loss for how things should be handled here.
> 
> When the b-plug is disconnected, we need to do something to signal to
> the core that we aren't connected, no?
> 
> And it seems that your point that the conn_id_status_change logic only
> runs on the A-plug connect/disconnect mirrors the usage for the B plug
> (ie: if A is disconnected, we enter B mode, thus if A is connected,
> shouldn't we disable/disconnect B mode?). I suspect there's something
> more subtle to your statement though, so if you could expand a bit so
> I could better understand I'd appreciate it.
> 
> thanks
> -john
> 
Hi John Stultz,

On b-plug disconnect should asserted GOTGINT.SesEndDet interrupt.
According previously sent by you register dump (GHWCFG2 = 0x23affc70) 
your core OTG_MODE=0.
Bellow fragment from programming guide on Device disconnect:

"7.3Device Disconnection
The device session ends when the USB cable is disconnected or if the 
VBUS is switched off by the Host. The
device disconnect flow varies depending on the value of the OTG_MODE 
configuration parameter.

When OTG_MODE = 0,1, or 3
When OTG_MODE is set to 0,1, or 3, the device disconnect flow is as follows:
1. When the USB cable is unplugged or when the VBUS is switched off by 
the Host, the Device core
trigger GINTSTS.OTGInt [bit 2] interrupt bit.
2. When the device application detects GINTSTS.OTGInt interrupt, it 
checks that the
GOTGINT.SesEndDet (Session End Detected) bit is set to 1’b1."

So, you should receive and handle "Session End Detected". In function 
dwc2_handle_otg_intr() on this interrupt (in device mode) calling 
dwc2_hsotg_disconnect() function. By adding your patch "[PATCH 3/3] usb: 
dwc2: Fix UDC state tracking" state changed to not attached as required.

Thanks,
Minas

--
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: dwc2 - ChHltd set, but reason is unknown

2017-10-16 Thread Minas Harutyunyan
On 10/16/2017 12:12 PM, Anders Montonen wrote:
> On Mon, 16 Oct 2017, Minas Harutyunyan wrote:
>> On 10/10/2017 4:35 PM, Anders Montonen wrote:
>>> On Mon, 9 Oct 2017, Minas Harutyunyan wrote:
 On 10/9/2017 5:15 PM, Anders Montonen wrote:
>>>
> We have a custom Altera Cyclone V SoCFPGA board, where connecting a
> particular brand of USB memory sticks produces and enless stream of
> console errors messages until it is removed from the system.
 Could you please provide log with enabled VERBOSE debug messages.
>>> I uploaded a log to 
>>> .
>> Hi Anders,
>> 1. Lot of "Transaction Error--" seen in log related to mentioned by you
>> mass storage device (addr=4 and addr=5).
>> 2. In log seen 2 additional devices with addresses 2 and 3 (Control
>> transfers). Could you please elaborate what kind of devices? Did you
>> connected any hub to dwc2 root hub? Or any internal to board hub's
>> connected to dwc2?
> 
> Hi,
> 
> Thanks for taking a look at this. As I mentioned in the original post, the
> dwc2 root hub is connected to a Microchip LAN9152 combined USB
> hub/Ethernet MAC. This is a fixed (PCB trace) connection.
> 
> 
> Regards,
> Anders Montonen
> 

Hi,
Could you please also send register dump.
Thanks,
Minas

--
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: dwc2 - ChHltd set, but reason is unknown

2017-10-16 Thread Anders Montonen

On Mon, 16 Oct 2017, Minas Harutyunyan wrote:

On 10/10/2017 4:35 PM, Anders Montonen wrote:

On Mon, 9 Oct 2017, Minas Harutyunyan wrote:

On 10/9/2017 5:15 PM, Anders Montonen wrote:



We have a custom Altera Cyclone V SoCFPGA board, where connecting a
particular brand of USB memory sticks produces and enless stream of
console errors messages until it is removed from the system.

Could you please provide log with enabled VERBOSE debug messages.

I uploaded a log to 
.

Hi Anders,
1. Lot of "Transaction Error--" seen in log related to mentioned by you
mass storage device (addr=4 and addr=5).
2. In log seen 2 additional devices with addresses 2 and 3 (Control
transfers). Could you please elaborate what kind of devices? Did you
connected any hub to dwc2 root hub? Or any internal to board hub's
connected to dwc2?


Hi,

Thanks for taking a look at this. As I mentioned in the original post, the 
dwc2 root hub is connected to a Microchip LAN9152 combined USB 
hub/Ethernet MAC. This is a fixed (PCB trace) connection.



Regards,
Anders Montonen
--
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: dwc2 - ChHltd set, but reason is unknown

2017-10-16 Thread Minas Harutyunyan
On 10/10/2017 4:35 PM, Anders Montonen wrote:
> Hi,
> 
> On Mon, 9 Oct 2017, Minas Harutyunyan wrote:
>> On 10/9/2017 5:15 PM, Anders Montonen wrote:
> 
>>> We have a custom Altera Cyclone V SoCFPGA board, where connecting a
>>> particular brand of USB memory sticks produces and enless stream of
>>> console errors messages until it is removed from the system.
>> Could you please provide log with enabled VERBOSE debug messages.
> 
> I uploaded a log to 
> .
> 
> Regards,
> Anders
> 
Hi Anders,
1. Lot of "Transaction Error--" seen in log related to mentioned by you 
mass storage device (addr=4 and addr=5).
2. In log seen 2 additional devices with addresses 2 and 3 (Control 
transfers). Could you please elaborate what kind of devices? Did you 
connected any hub to dwc2 root hub? Or any internal to board hub's 
connected to dwc2?
Thanks,
Minas


--
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