[RFC v6 3/3] usb: phy: hold wakeupsource when USB is enumerated in peripheral mode

2014-11-11 Thread Kiran Kumar Raparthy
From: Todd Poynor 

usb: phy: hold wakeupsource when USB is enumerated in peripheral mode

Some systems require a mechanism to prevent system to enter into suspend
state when USB is connected and enumerated in peripheral mode.

This patch provides an interface to hold a wakeupsource to prevent suspend.
PHY drivers can use this interface when USB is connected and enumerated in
peripheral mode.

A timed wakeupsource is temporarily held on USB disconnect events, to allow
the rest of the system to react to the USB disconnection (dropping host
sessions, updating charger status, etc.) prior to re-allowing suspend.

Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: linux-ker...@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Android Kernel Team 
Cc: John Stultz 
Cc: Sumit Semwal 
Cc: Arve Hj�nnev�g 
Cc: Benoit Goby 
Signed-off-by: Todd Poynor 
[kiran: Added context to commit message, squished build fixes
from Benoit Goby and Arve Hjønnevåg, changed wakelocks usage
to wakeupsource, merged Todd's refactoring logic and simplified
the structures and code and addressed community feedback]
Signed-off-by: Kiran Raparthy 
---
 drivers/usb/phy/phy.c   | 29 +++--
 include/linux/usb/phy.h |  5 +
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index 2b1039e..b5c5fd3 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -329,6 +329,7 @@ int usb_add_phy(struct usb_phy *x, enum usb_phy_type type)
int ret = 0;
unsigned long   flags;
struct usb_phy  *phy;
+   char wsource_name[40];
 
if (x->type != USB_PHY_TYPE_UNDEFINED) {
dev_err(x->dev, "not accepting initialized PHY %s\n", x->label);
@@ -351,6 +352,10 @@ int usb_add_phy(struct usb_phy *x, enum usb_phy_type type)
x->type = type;
list_add_tail(&x->head, &phy_list);
 
+   snprintf(wsource_name, sizeof(wsource_name), "vbus-%s",
+   dev_name(x->dev));
+   wakeup_source_init(&x->wsource, wsource_name);
+
 out:
spin_unlock_irqrestore(&phy_lock, flags);
return ret;
@@ -402,6 +407,7 @@ void usb_remove_phy(struct usb_phy *x)
 
spin_lock_irqsave(&phy_lock, flags);
if (x) {
+   wakeup_source_trash(&x->wsource);
list_for_each_entry(phy_bind, &phy_bind_list, list)
if (phy_bind->phy == x)
phy_bind->phy = NULL;
@@ -446,13 +452,32 @@ int usb_bind_phy(const char *dev_name, u8 index,
 EXPORT_SYMBOL_GPL(usb_bind_phy);
 
 /**
- * usb_phy_set_event - set event to phy event
+ * usb_phy_set_event - set event to phy event and
+ * hold/temporarily hold wakeupsource
  * @x: the phy returned by usb_get_phy();
  *
- * This sets event to phy event
+ * This holds per-PHY wakeupsource/timed wakeupsource
  */
 void usb_phy_set_event(struct usb_phy *x, unsigned long event)
 {
+
x->last_event = event;
+
+   switch (event) {
+   case USB_EVENT_ENUMERATED:
+   __pm_stay_awake(&x->wsource);
+   break;
+
+   case USB_EVENT_NONE:
+   case USB_EVENT_ID:
+   case USB_EVENT_VBUS:
+   case USB_EVENT_CHARGER:
+   __pm_wakeup_event(&x->wsource,
+   msecs_to_jiffies(TEMPORARY_HOLD_TIME));
+   break;
+
+   default:
+   break;
+   }
 }
 EXPORT_SYMBOL_GPL(usb_phy_set_event);
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index 3c713ff..bc58fb8 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -12,6 +12,8 @@
 #include 
 #include 
 
+#define TEMPORARY_HOLD_TIME2000
+
 enum usb_phy_interface {
USBPHY_INTERFACE_MODE_UNKNOWN,
USBPHY_INTERFACE_MODE_UTMI,
@@ -89,6 +91,9 @@ struct usb_phy {
/* for notification of usb_phy_events */
struct atomic_notifier_head notifier;
 
+   /* wakeup source */
+   struct wakeup_sourcewsource;
+
/* to pass extra port status to the root hub */
u16 port_status;
u16 port_change;
-- 
1.8.2.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


[RFC v6 2/3] usb: phy: handle per-PHY connect and disconnect events

2014-11-11 Thread Kiran Kumar Raparthy
From: Todd Poynor 

usb: phy: handle per-PHY connect and disconnect events

When usb is connected and enumerated in device mode or when usb is
disconnected,call usb_phy_set_event from phy drivers to handle per-PHY event.

Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: linux-ker...@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Android Kernel Team 
Cc: John Stultz 
Cc: Sumit Semwal 
Cc: Arve Hj�nnev�g 
Cc: Benoit Goby 
Signed-off-by: Todd Poynor 
[kiran: Added context to commit message, squished build fixes
from Benoit Goby and Arve Hj�nnev�g, changed wakelocks usage
to wakeupsource, merged Todd's refactoring logic and simplified
the structures and code and addressed community feedback]
Signed-off-by: Kiran Raparthy 
---
 drivers/usb/phy/phy-ab8500-usb.c| 15 +++
 drivers/usb/phy/phy-gpio-vbus-usb.c |  2 ++
 drivers/usb/phy/phy-mv-usb.c|  2 ++
 drivers/usb/phy/phy-tahvo.c |  2 ++
 4 files changed, 21 insertions(+)

diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 11ab2c4..d79fa3e 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -447,6 +447,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb 
*ab,
event = UX500_MUSB_NONE;
/* Fallback to default B_IDLE as nothing is connected. */
ab->phy.state = OTG_STATE_B_IDLE;
+   usb_phy_set_event(&ab->phy, USB_EVENT_NONE);
break;
 
case USB_LINK_ACA_RID_C_NM_9540:
@@ -461,12 +462,14 @@ static int ab9540_usb_link_status_update(struct 
ab8500_usb *ab,
ab8500_usb_peri_phy_en(ab);
atomic_notifier_call_chain(&ab->phy.notifier,
UX500_MUSB_PREPARE, &ab->vbus_draw);
+   usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED);
}
if (ab->mode == USB_IDLE) {
ab->mode = USB_PERIPHERAL;
ab8500_usb_peri_phy_en(ab);
atomic_notifier_call_chain(&ab->phy.notifier,
UX500_MUSB_PREPARE, &ab->vbus_draw);
+   usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED);
}
if (event != UX500_MUSB_RIDC)
event = UX500_MUSB_VBUS;
@@ -502,6 +505,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb 
*ab,
event = UX500_MUSB_CHARGER;
atomic_notifier_call_chain(&ab->phy.notifier,
event, &ab->vbus_draw);
+   usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER);
break;
 
case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_9540:
@@ -526,6 +530,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb 
*ab,
ab->mode = USB_IDLE;
ab->phy.otg->default_a = false;
ab->vbus_draw = 0;
+   usb_phy_set_event(&ab->phy, USB_EVENT_NONE);
}
}
break;
@@ -585,6 +590,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb 
*ab,
 * is connected
 */
ab->phy.state = OTG_STATE_B_IDLE;
+   usb_phy_set_event(&ab->phy, USB_EVENT_NONE);
break;
 
case USB_LINK_ACA_RID_C_NM_8540:
@@ -598,6 +604,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb 
*ab,
ab8500_usb_peri_phy_en(ab);
atomic_notifier_call_chain(&ab->phy.notifier,
UX500_MUSB_PREPARE, &ab->vbus_draw);
+   usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED);
}
if (event != UX500_MUSB_RIDC)
event = UX500_MUSB_VBUS;
@@ -626,6 +633,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb 
*ab,
event = UX500_MUSB_CHARGER;
atomic_notifier_call_chain(&ab->phy.notifier,
event, &ab->vbus_draw);
+   usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER);
break;
 
case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_8540:
@@ -648,6 +656,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb 
*ab,
ab->mode = USB_IDLE;
ab->phy.otg->default_a = false;
ab->vbus_draw = 0;
+   usb_phy_set_event(&ab->phy, USB_EVENT_NONE);
}
break;
 
@@ -694,6 +703,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb 
*ab,
 * is connected
 */
ab->phy.state = OTG_STATE_B_IDLE;
+   usb_phy_set_event(&ab->phy, USB_EVENT_NONE);
break;
 
case USB_LINK_ACA_RID_C_NM_8505:

[RFC v6 1/3] usb: phy: introduce usb_phy_set_event interface

2014-11-11 Thread Kiran Kumar Raparthy
From: Todd Poynor 

usb: phy: introduce usb_phy_set_event interface

PHY drivers require a generic interface to handle per-PHY events.

usb_phy_set_event interface sets event to phy event.
PHY drivers call this interface for each phy event.

Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: linux-ker...@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Android Kernel Team 
Cc: John Stultz 
Cc: Sumit Semwal 
Cc: Arve Hj�nnev�g 
Cc: Benoit Goby 
Signed-off-by: Todd Poynor 
[kiran: Added context to commit message, squished build fixes
from Benoit Goby and Arve Hj�nnev�g, changed wakelocks usage
to wakeupsource, merged Todd's refactoring logic and simplified
the structures and code and addressed community feedback]
Signed-off-by: Kiran Raparthy 
---
 drivers/usb/phy/phy.c   | 12 
 include/linux/usb/phy.h |  5 +
 2 files changed, 17 insertions(+)

diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index 045cd30..2b1039e 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -444,3 +444,15 @@ int usb_bind_phy(const char *dev_name, u8 index,
return 0;
 }
 EXPORT_SYMBOL_GPL(usb_bind_phy);
+
+/**
+ * usb_phy_set_event - set event to phy event
+ * @x: the phy returned by usb_get_phy();
+ *
+ * This sets event to phy event
+ */
+void usb_phy_set_event(struct usb_phy *x, unsigned long event)
+{
+   x->last_event = event;
+}
+EXPORT_SYMBOL_GPL(usb_phy_set_event);
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index 353053a..3c713ff 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -210,6 +210,7 @@ extern void usb_put_phy(struct usb_phy *);
 extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x);
 extern int usb_bind_phy(const char *dev_name, u8 index,
const char *phy_dev_name);
+extern void usb_phy_set_event(struct usb_phy *x, unsigned long event);
 #else
 static inline struct usb_phy *usb_get_phy(enum usb_phy_type type)
 {
@@ -251,6 +252,10 @@ static inline int usb_bind_phy(const char *dev_name, u8 
index,
 {
return -EOPNOTSUPP;
 }
+
+static inline void usb_phy_set_event(struct usb_phy *x, unsigned long event)
+{
+}
 #endif
 
 static inline int
-- 
1.8.2.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 net-next 2/2] r8152: adjust rtl_start_rx

2014-11-11 Thread Hayes Wang
David Miller [mailto:da...@davemloft.net] 
> Sent: Wednesday, November 12, 2014 1:44 PM
[...]
> What do other USB network drivers do in similar situations?

According to the usbnet.c, it would make sure to submit the
number of min(10, RX_QLEN(dev)) rx buffers. If there are
not enough rx buffers, it schedule a tasklet for next try.

The brief flow is as following.
1. Call open().
   - schedule a tasklet.
2. Tasklet is called.
   if (dev->rxq.qlen < RX_QLEN(dev)) {
   - submit rx buffers util the number of
 min(10, RX_QLEN(dev)). If the error
 occurs, break the loop.
   - If the dev->rxq.qlen < RX_QLEN(dev),
 schedule the tasklet.
   }

Best Regards,
Hayes
--
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 for 3.18-rc4 to add OLIMEX ISP500 AVR Programmer

2014-11-11 Thread Lars Melin

On 2014-11-12 13:05, Lars Melin wrote:

On 2014-11-11 23:43, Sid Boyce wrote:

Results
---
root@sdrbox:~# lsusb
Bus 002 Device 004: ID 13fd:1840 Initio Corporation INIC-1608 SATA 
bridge

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 003: ID 15ba:000c Olimex Ltd.



git_OLIMEX_AVR_ISP500.diff


This patch adds support for the OLIMEX ISP500 AVR Programmer to kernel 3.18-rc4.
Signed off by: Sid Boyce (sbo...@blueyonder.co.uk)
Tested by: Sid Boyce (sbo...@blueyonder.co.uk)

diff --git a/a/drivers/usb/serial/ftdi_sio.c b/b/drivers/usb/serial/ftdi_sio.c
index 0dad8ce..7a471e8 100644
--- a/a/drivers/usb/serial/ftdi_sio.c
+++ b/b/drivers/usb/serial/ftdi_sio.c
@@ -770,6 +770,7 @@ static const struct usb_device_id id_table_combined[] = {
.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
{ USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_H_PID),
.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
+   { USB_DEVICE(OLIMEX_VID, OLIMEX_AVR_ISP500_ISO_PID) },
{ USB_DEVICE(FIC_VID, FIC_NEO1973_DEBUG_PID),
.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
{ USB_DEVICE(FTDI_VID, FTDI_OOCDLINK_PID),
diff --git a/a/drivers/usb/serial/ftdi_sio_ids.h 
b/b/drivers/usb/serial/ftdi_sio_ids.h
index 6786b70..78bfc30 100644
--- a/a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/b/drivers/usb/serial/ftdi_sio_ids.h
@@ -838,6 +838,7 @@
  /* Olimex */
  #define OLIMEX_VID0x15BA
  #define OLIMEX_ARM_USB_OCD_PID0x0003
+#define OLIMEX_AVR_ISP500_ISO_PID0x000B
  #define OLIMEX_ARM_USB_OCD_H_PID  0x002b
  
  /*



Did you really test this patch as indicated by your tested-by ?
How come the pid in your lsusb output doesn't match the pid you 
defined in the patch?


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


Re: [PATCH net-next 2/2] r8152: adjust rtl_start_rx

2014-11-11 Thread David Miller
From: Hayes Wang 
Date: Wed, 12 Nov 2014 05:23:03 +

> David Miller [mailto:da...@davemloft.net] 
>> Sent: Wednesday, November 12, 2014 1:13 PM
> [...]
>> I really want to know why you are spending so much effort on this.
>> 
>> Is there a real situation that happened very often, which you
>> diagnosed in detail, and therefore you want to address?
> 
> No. I just consider the possible situation and want to
> make the driver better. If you think this is unnecessary,
> I would remove it.

What do other USB network drivers do in similar situations?
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH net-next 2/2] r8152: adjust rtl_start_rx

2014-11-11 Thread Hayes Wang
David Miller [mailto:da...@davemloft.net] 
> Sent: Wednesday, November 12, 2014 1:13 PM
[...]
> I really want to know why you are spending so much effort on this.
> 
> Is there a real situation that happened very often, which you
> diagnosed in detail, and therefore you want to address?

No. I just consider the possible situation and want to
make the driver better. If you think this is unnecessary,
I would remove it.
 
Best Regards,
Hayes
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next 2/2] r8152: adjust rtl_start_rx

2014-11-11 Thread David Miller
From: Hayes Wang 
Date: Wed, 12 Nov 2014 05:07:40 +

> How about that when a error occurs, add the remaining rx
> to the list without submission? Then, the remianing rx
> could be re-submitted later, and the rtl_start_rx() could
> be completed as soon as possible.

I really want to know why you are spending so much effort on this.

Is there a real situation that happened very often, which you
diagnosed in detail, and therefore you want to address?
--
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: [net-next PATCH v3 0/5] Replace __skb_alloc_pages with simpler function

2014-11-11 Thread David Miller
From: Alexander Duyck 
Date: Tue, 11 Nov 2014 09:26:26 -0800

> This patch series replaces __skb_alloc_pages with a much simpler function,
> __dev_alloc_pages.  The main difference between the two is that
> __skb_alloc_pages had an sk_buff pointer that was being passed as NULL in
> call places where it was called.  In a couple of cases the NULL was passed
> by variable and this led to unnecessary code being run.
> 
> As such in order to simplify things the __dev_alloc_pages call only takes a
> mask and the page order being requested.  In addition it takes advantage of
> several behaviors already built into the page allocator so that it can just
> set GFP flags unconditionally.
> 
> v2: Renamed functions to dev_alloc_page(s) instead of netdev_alloc_page(s)
> Removed __GFP_COLD flag from usb code as it was redundant
> v3: Update patch descriptions and subjects to match changes in v2

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


RE: [PATCH net-next 2/2] r8152: adjust rtl_start_rx

2014-11-11 Thread Hayes Wang
David Miller [mailto:da...@davemloft.net] 
> Sent: Wednesday, November 12, 2014 10:51 AM
[...]
> Ok, but if we are looping here in rtl_start_rx() and r8152_submit_rx()
> fails due to a memory allocation failure, there is nothing which is
> going to make such a memory allocation succeed in the next iteration
> of the loop.
> 
> Unless you can prove that often it can succeed after an initial
> failure, this is just wasted work and in fact making it take longer
> for the system to reclaim memory when under pressure because these
> extra iterations are completely wasted cpu work.

How about that when a error occurs, add the remaining rx
to the list without submission? Then, the remianing rx
could be re-submitted later, and the rtl_start_rx() could
be completed as soon as possible.

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 0a30fd3..3273e3d 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1991,14 +1991,35 @@ static void rxdy_gated_en(struct r8152 *tp, bool enable)
 
 static int rtl_start_rx(struct r8152 *tp)
 {
+   struct list_head rx_queue;
int i, ret = 0;
 
INIT_LIST_HEAD(&tp->rx_done);
for (i = 0; i < RTL8152_MAX_RX; i++) {
INIT_LIST_HEAD(&tp->rx_info[i].list);
ret = r8152_submit_rx(tp, &tp->rx_info[i], GFP_KERNEL);
-   if (ret)
+   if (ret) {
+   i++;
break;
+   }
+   }
+
+   INIT_LIST_HEAD(&rx_queue);
+   for (; i < RTL8152_MAX_RX; i++) {
+   struct rx_agg *agg = &tp->rx_info[i];
+   struct urb *urb = agg->urb;
+
+   INIT_LIST_HEAD(&agg->list);
+   urb->actual_length = 0;
+   list_add_tail(&agg->list, &rx_queue);
+   }
+
+   if (!list_empty(&rx_queue)) {
+   unsigned long flags;
+
+   spin_lock_irqsave(&tp->rx_lock, flags);
+   list_splice_tail(&rx_queue, &tp->rx_done);
+   spin_unlock_irqrestore(&tp->rx_lock, flags);
}
 
return ret;
 
Best Regards,
Hayes
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next 2/2] r8152: adjust rtl_start_rx

2014-11-11 Thread David Miller
From: Hayes Wang 
Date: Mon, 10 Nov 2014 03:29:27 +

> The behavior is different for PCI(e) and USB ethernet device.
> The PCI nic could know the ring buffer by certain way, so
> the device could fill the data into the buffer one by one
> automatically. However, for usb nic, the driver has to
> indicate (i.e. submit) each buffer for each data. The device
> doesn't know what is the next buffer by itself. That is,
> the driver determines the order by which the data would be
> filled.
> 
> Therefore, when I try to submit 10 rx buffers and some of
> them fail, I could get the data depending on the order of
> the successful ones. Besides, the driver has to submit the
> buffer for next data continually, so the previous unsuccessful
> ones could be tried again for the same time.

Ok, but if we are looping here in rtl_start_rx() and r8152_submit_rx()
fails due to a memory allocation failure, there is nothing which is
going to make such a memory allocation succeed in the next iteration
of the loop.

Unless you can prove that often it can succeed after an initial
failure, this is just wasted work and in fact making it take longer
for the system to reclaim memory when under pressure because these
extra iterations are completely wasted cpu work.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH net-next 2/2] r8152: adjust rtl_start_rx

2014-11-11 Thread Hayes Wang
David Miller [mailto:da...@davemloft.net] 
> Sent: Saturday, November 08, 2014 12:35 AM
[...]
> Does this even work?
> 
> If you leave a hole in the ring, the device is going to stop there
> anyways.
> 
> So better to replenish the next time you call into this function
> rather than leaving gaps in your receive ring.

Excuse me. Is this still unacceptable?
Should I remove this patch for keeping the original flow?
 
Best Regards,
Hayes
--
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 v8 0/7] usb: add support for the generic PHY framework

2014-11-11 Thread Peter Chen
On Fri, Nov 07, 2014 at 12:08:52PM -0600, Felipe Balbi wrote:
> On Fri, Nov 07, 2014 at 12:08:20PM -0600, Felipe Balbi wrote:
> > Hi,
> > 
> > On Fri, Nov 07, 2014 at 01:33:25PM +, Peter Chen wrote:
> > > 
> > > 
> > >  
> > > > 
> > > > Antoine Tenart (7):
> > > >   usb: move the OTG state from the USB PHY to the OTG structure
> > > >   usb: rename phy to usb_phy in OTG
> > > >   usb: add support to the generic PHY framework in OTG
> > > >   usb: allow to supply the PHY in the drivers when using HCD
> > > >   usb: chipidea: rename transceiver and phy to usb_phy
> > > >   usb: chipidea: move usb_otg into struct ci_hdrc
> > > >   usb: chipidea: add support to the generic PHY framework
> > > > 
> > > 
> > > Hi Felipe,
> > > 
> > > I find you queue the patch 1st-4th and 7th in your next tree, how you 
> > > queue
> > > the 7th without queueing 5th and 6th, they have some relationships.
> > > 
> > > Will you queue 5th and 6th, or I queue them (5th- 7th) through my 
> > > chipidea patch set?
> > 
> > argh, somehow I missed them. I'll add both to my testing/next. Sorry for
> > the confusion. I thought I had them all.
> 
> oh, they don't apply.
> 

Oh, I know the reason why you can apply 7th, without apply 5th and 6th.
At your next tree, the 4th, 5th, and 6th patches were squashed, and
it becomes "4th" patches in this series.
The shortlog is: 
usb: allow to supply the PHY in the drivers when using HCD
commit id is:
"ef44cb4226d132146e44f8ea562a16b27ff61126"

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


RE: [PATCH net-next 2/2] r8152: adjust rtl_start_rx

2014-11-11 Thread Hayes Wang
David Miller [mailto:da...@davemloft.net] 
> Sent: Wednesday, November 12, 2014 10:20 AM
[...]
> I haven't had time to process your original reply, please be patient.

I am sorry for bothering you, and thanks for your reply.
 
Best Regards,
Hayes
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next 2/2] r8152: adjust rtl_start_rx

2014-11-11 Thread David Miller
From: Hayes Wang 
Date: Wed, 12 Nov 2014 01:45:08 +

> David Miller [mailto:da...@davemloft.net] 
>> Sent: Saturday, November 08, 2014 12:35 AM
> [...]
>> Does this even work?
>> 
>> If you leave a hole in the ring, the device is going to stop there
>> anyways.
>> 
>> So better to replenish the next time you call into this function
>> rather than leaving gaps in your receive ring.
> 
> Excuse me. Is this still unacceptable?
> Should I remove this patch for keeping the original flow?

I haven't had time to process your original reply, please be patient.
--
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 v8 0/7] usb: add support for the generic PHY framework

2014-11-11 Thread Peter Chen
On Fri, Nov 07, 2014 at 12:08:52PM -0600, Felipe Balbi wrote:
> On Fri, Nov 07, 2014 at 12:08:20PM -0600, Felipe Balbi wrote:
> > Hi,
> > 
> > On Fri, Nov 07, 2014 at 01:33:25PM +, Peter Chen wrote:
> > > 
> > > 
> > >  
> > > > 
> > > > Antoine Tenart (7):
> > > >   usb: move the OTG state from the USB PHY to the OTG structure
> > > >   usb: rename phy to usb_phy in OTG
> > > >   usb: add support to the generic PHY framework in OTG
> > > >   usb: allow to supply the PHY in the drivers when using HCD
> > > >   usb: chipidea: rename transceiver and phy to usb_phy
> > > >   usb: chipidea: move usb_otg into struct ci_hdrc
> > > >   usb: chipidea: add support to the generic PHY framework
> > > > 
> > > 
> > > Hi Felipe,
> > > 
> > > I find you queue the patch 1st-4th and 7th in your next tree, how you 
> > > queue
> > > the 7th without queueing 5th and 6th, they have some relationships.
> > > 
> > > Will you queue 5th and 6th, or I queue them (5th- 7th) through my 
> > > chipidea patch set?
> > 
> > argh, somehow I missed them. I'll add both to my testing/next. Sorry for
> > the confusion. I thought I had them all.
> 
> oh, they don't apply.
> 

Hi Felipe, I still not see Antoine's chipidea patch in your tree.
I assume you will do it soon.
And there are some coming chipidea patches (Antoine & me), I will do
further work based on it.

Peter
--
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 net-next v3 1/3] r8152: remove the duplicate init for the list of rx_done

2014-11-11 Thread Hayes Wang
The INIT_LIST_HEAD(&tp->rx_done) would be done in rtl_start_rx(),
so remove the unnecessary one in alloc_all_mem().

Signed-off-by: Hayes Wang 
---
 drivers/net/usb/r8152.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 66b139a..a300467 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1255,7 +1255,6 @@ static int alloc_all_mem(struct r8152 *tp)
 
spin_lock_init(&tp->rx_lock);
spin_lock_init(&tp->tx_lock);
-   INIT_LIST_HEAD(&tp->rx_done);
INIT_LIST_HEAD(&tp->tx_free);
skb_queue_head_init(&tp->tx_queue);
 
-- 
1.9.3

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


[PATCH net-next v3 0/3] Code adjustment

2014-11-11 Thread Hayes Wang
v3:
 Remove the test_bit for patch #2.

v2:
 Correct the spelling error for the comment of patch #3.

v1:
Adjust some codes to make them more reasonable.

Hayes Wang (3):
  r8152: remove the duplicate init for the list of rx_done
  r8152: clear the flag of SCHEDULE_TASKLET in tasklet
  r8152: check RTL8152_UNPLUG and netif_running before autoresume

 drivers/net/usb/r8152.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

-- 
1.9.3

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


[PATCH net-next v3 3/3] r8152: check RTL8152_UNPLUG and netif_running before autoresume

2014-11-11 Thread Hayes Wang
If the device is unplugged or !netif_running(), the workqueue
doesn't need to wake the device, and could return directly.

Signed-off-by: Hayes Wang 
---
 drivers/net/usb/r8152.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index ad9dd7d..0a30fd3 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -2857,15 +2857,18 @@ static void rtl_work_func_t(struct work_struct *work)
 {
struct r8152 *tp = container_of(work, struct r8152, schedule.work);
 
+   /* If the device is unplugged or !netif_running(), the workqueue
+* doesn't need to wake the device, and could return directly.
+*/
+   if (test_bit(RTL8152_UNPLUG, &tp->flags) || !netif_running(tp->netdev))
+   return;
+
if (usb_autopm_get_interface(tp->intf) < 0)
return;
 
if (!test_bit(WORK_ENABLE, &tp->flags))
goto out1;
 
-   if (test_bit(RTL8152_UNPLUG, &tp->flags))
-   goto out1;
-
if (!mutex_trylock(&tp->control)) {
schedule_delayed_work(&tp->schedule, 0);
goto out1;
-- 
1.9.3

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


[PATCH net-next v3 2/3] r8152: clear the flag of SCHEDULE_TASKLET in tasklet

2014-11-11 Thread Hayes Wang
Clear the flag of SCHEDULE_TASKLET in bottom_half() to avoid
re-schedule the tasklet again by workqueue.

Signed-off-by: Hayes Wang 
---
 drivers/net/usb/r8152.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index a300467..ad9dd7d 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1797,6 +1797,8 @@ static void bottom_half(unsigned long data)
if (!netif_carrier_ok(tp->netdev))
return;
 
+   clear_bit(SCHEDULE_TASKLET, &tp->flags);
+
rx_bottom(tp);
tx_bottom(tp);
 }
-- 
1.9.3

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


Re: [V2 PATCH 03/10] added media agnostic (MA) data structures and handling

2014-11-11 Thread steph
On Wed, Nov 12, 2014 at 10:14:38AM +0900, Greg KH wrote:
> On Tue, Nov 11, 2014 at 02:42:22PM -0800, Sean O. Stalley wrote:
> > On Tue, Nov 11, 2014 at 01:38:21PM +0900, Greg KH wrote:
> > > On Mon, Nov 10, 2014 at 06:09:34PM -0800, Stephanie Wallick wrote:
> > > Yes, I am holding you to a higher standard than staging code normally
> > > is, and yes, it is purely because of the company you work for.  But I
> > > only do that because your company knows how to do this stuff right, and
> > > you have access to the resources and talent to help make this code
> > > right.  Other people and companies do not have the kind of advantage
> > > that you do.
> > 
> > We know we are fortunate to work for a company with so much talent and
> > resources and we don't mind being held to a higher standard. We have been
> > receiving multiple requests for our host driver and wanted to make it
> > available as soon as possible for others to use. We thought putting our
> > host driver into staging would be a good way to release it, but realize now
> > that it was premature. 
> 
> Does the code even work?  The number of basic mistakes in it seems to
> imply that it doesn't, but I could be mistaken.
> 

What is there works, but not everything in the MA USB Spec has been implemented
yet. 

> > We won't resubmit the driver until a senior kernel developer has signed off 
> > on it.
> 
> Good, go kick some of them and get them to review the code, _after_ at
> least addressing the issues that the community has raised, you don't
> want to waste their time finding the same things we just did :)
> 

Will do! We will most definitely fix the issues raised by the community before
having anyone else review the code. We appreciate everyone's time and feedback
:)


Thanks,
Stephanie
--
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: [V2 PATCH 03/10] added media agnostic (MA) data structures and handling

2014-11-11 Thread Greg KH
On Tue, Nov 11, 2014 at 02:42:22PM -0800, Sean O. Stalley wrote:
> On Tue, Nov 11, 2014 at 01:38:21PM +0900, Greg KH wrote:
> > On Mon, Nov 10, 2014 at 06:09:34PM -0800, Stephanie Wallick wrote:
> > Intel has a whole group of very experienced Linux kernel developers who
> > will review code before you sent it out publicly.  Please take advantage
> > of them and run this all through them before resending this out again.
> > 
> > If you did run this code through that group, please let me know who it
> > was specifically that allowed this stuff to get through, and why they
> > didn't want their name on this code submission.  I need to have a strong
> > word with them...
> 
> We submitted the patches for internal review and got no objections to
> release. We will be more aggressive in seeking out feedback (and approval)
> before resubmitting any code.

Fair enough, it seems you took the only available path and submitted it
to the community, which was a good idea, sorry for the rant.  Thanks for
submitting it publicly and not just "waiting forever" like I have seen
some people do in the past.

> > Yes, I am holding you to a higher standard than staging code normally
> > is, and yes, it is purely because of the company you work for.  But I
> > only do that because your company knows how to do this stuff right, and
> > you have access to the resources and talent to help make this code
> > right.  Other people and companies do not have the kind of advantage
> > that you do.
> 
> We know we are fortunate to work for a company with so much talent and
> resources and we don't mind being held to a higher standard. We have been
> receiving multiple requests for our host driver and wanted to make it
> available as soon as possible for others to use. We thought putting our
> host driver into staging would be a good way to release it, but realize now
> that it was premature. 

Does the code even work?  The number of basic mistakes in it seems to
imply that it doesn't, but I could be mistaken.

> We won't resubmit the driver until a senior kernel developer has signed off 
> on it.

Good, go kick some of them and get them to review the code, _after_ at
least addressing the issues that the community has raised, you don't
want to waste their time finding the same things we just did :)

thanks,

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


Re: "asix: Don't reset PHY on if_up for ASIX 88772" breaks net on arndale platform

2014-11-11 Thread Ben Hutchings
On Tue, 2014-11-04 at 20:09 +, Charles Keepax wrote:
> On Tue, Nov 04, 2014 at 11:23:06AM +0100, Stam, Michel [FINT] wrote:
> > Hello Riku,
> > 
> > >Fixing a bug (ethtool support) must not cause breakage elsewhere (in
> > this case on arndale). This is now a regression of functionality from
> > 3.17.
> > >
> > >I think it would better to revert the change now and with less hurry
> > introduce a ethtool fix that doesn't break arndale.
> > 
> > I don't fully agree here; 
> > I would like to point out that this commit is a revert itself. Fixing
> > the armdale will then cause breakage in other implementations, such as
> > ours. Blankly reverting breaks other peoples' implementations.
> > 
> > The PHY reset is the thing that breaks ethtool support, so any fix that
> > appeases all would have to take existing PHY state into account. 
[...]
> --- a/drivers/net/usb/asix_devices.c
> +++ b/drivers/net/usb/asix_devices.c
> @@ -299,6 +299,7 @@ static int ax88772_reset(struct usbnet *dev)
>  {
> struct asix_data *data = (struct asix_data *)&dev->data;
> int ret, embd_phy;
> +   int reg;
> u16 rx_ctl;
> 
> ret = asix_write_gpio(dev,
> @@ -359,8 +360,10 @@ static int ax88772_reset(struct usbnet *dev)
> msleep(150);
> 
> asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
> -   asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
> -   ADVERTISE_ALL | ADVERTISE_CSMA);
> +   reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_ADVERTISE);
> +   if (!reg)
> +   reg = ADVERTISE_ALL | ADVERTISE_CSMA;
> +   asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, reg);
[...]

Why is there no sleep after setting the RESET bit?  Doesn't that make
the following register writes unreliable?

Ben.

-- 
Ben Hutchings
Experience is directly proportional to the value of equipment destroyed.
 - Carolyn Scheppner


signature.asc
Description: This is a digitally signed message part


Re: Patch for 3.18-rc4 to add OLIMEX ISP500 AVR Programmer

2014-11-11 Thread Sid Boyce

On 11/11/14 19:46, Johan Hovold wrote:

On Tue, Nov 11, 2014 at 04:43:52PM +, Sid Boyce wrote:

Results
---
root@sdrbox:~# lsusb
Bus 002 Device 004: ID 13fd:1840 Initio Corporation INIC-1608 SATA bridge
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 003: ID 15ba:000c Olimex Ltd.

The failure due to AtMega32 not attached.
root@sdrbox:~# avrdude -p m32 -F -c stk500v2 -P /dev/ttyACM1

avrdude: stk500v2_command(): warning: Command timed out
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0xc807c6
avrdude: Expected signature for ATmega32 is 1E 95 02

avrdude done.  Thank you.

I'm really not sure what I'm supposed to make of the above.

Care to submit the patch on a format that I can apply (i.e. with proper
subject and commit message and patch inline in body)? See
Documentation/SubmittingPatches for details.

Also why are you using an ACM node above? That's a different driver
(cdc-acm).

Could you provide "lsusb -v" output for your device as well?

Thanks,
Johan


root@sdrbox:~# lsusb
Bus 002 Device 004: ID 13fd:1840 Initio Corporation INIC-1608 SATA bridge
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 003: ID 15ba:000c Olimex Ltd.
Bus 004 Device 002: ID 195d:1009 Itron Technology iONE
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 004: ID 2341:0043 Arduino SA Uno R3 (CDC ACM)
Bus 001 Device 003: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 04f3:0103 Elan Microelectronics Corp. ActiveJet 
K-2024 Multimedia Keyboard

Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

I have done another patch, please let me know if it needs a cleanup.

Details from the original code for kernel 2.6.x which uses 
linux/smp_lock.h and no longer builds.

root@sdrbox:/b2/drivers/usb/serial# grep OLIMEX ftdi_sio.c
{ USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_PID),
{ USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_H_PID),
{ USB_DEVICE(OLIMEX_VID, OLIMEX_AVR_ISP500_ISO_PID) },
root@sdrbox:/b2/drivers/usb/serial# grep OLIMEX ftdi_sio_ids.h
#define OLIMEX_VID  0x15BA
#define OLIMEX_ARM_USB_OCD_PID  0x0003
#define OLIMEX_AVR_ISP500_ISO_PID0x000B
#define OLIMEX_ARM_USB_OCD_H_PID0x002b
Regards
Sid.

--
Sid Boyce ... Hamradio License G3VBV, Licensed Private Pilot
Emeritus IBM/Amdahl Mainframes and Sun/Fujitsu Servers Tech Support
Senior Staff Specialist, Cricket Coach
Microsoft Windows Free Zone - Linux used for all Computing Tasks

This patch adds support for the OLIMEX ISP500 AVR Programmer to kernel 3.18-rc4.
Signed off by: Sid Boyce (sbo...@blueyonder.co.uk)
Tested by: Sid Boyce (sbo...@blueyonder.co.uk)
---
drivers/usb/serial/ftdi_sio.c 1 +
drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h 1 +
2 files changed, 2 insertion(+)

INDEX: linux/drivers/usb/serial/ftdi_sio.c
diff -ur a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
--- a/drivers/usb/serial/ftdi_sio.c	2014-11-10 20:14:22.492905152 +
+++ b/drivers/usb/serial/ftdi_sio.c	2014-11-10 19:59:53.0 +
@@ -770,6 +770,7 @@
 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
 	{ USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_H_PID),
 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
+	{ USB_DEVICE(OLIMEX_VID, OLIMEX_AVR_ISP500_ISO_PID) },
 	{ USB_DEVICE(FIC_VID, FIC_NEO1973_DEBUG_PID),
 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
 	{ USB_DEVICE(FTDI_VID, FTDI_OOCDLINK_PID),

INDEX: linux/drivers/usb/serial/ftdi_sio_ids.h
diff -ur a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
--- a/drivers/usb/serial/ftdi_sio_ids.h	2014-11-10 20:14:33.411527535 +
+++ b/drivers/usb/serial/ftdi_sio_ids.h	2014-11-10 20:00:07.0 +
@@ -838,6 +838,7 @@
 /* Olimex */
 #define OLIMEX_VID			0x15BA
 #define OLIMEX_ARM_USB_OCD_PID		0x0003
+#define OLIMEX_AVR_ISP500_ISO_PID0x000B
 #define OLIMEX_ARM_USB_OCD_H_PID	0x002b
 
 /*


Re: [V2 PATCH 03/10] added media agnostic (MA) data structures and handling

2014-11-11 Thread Sean O. Stalley
On Tue, Nov 11, 2014 at 01:38:21PM +0900, Greg KH wrote:
> On Mon, Nov 10, 2014 at 06:09:34PM -0800, Stephanie Wallick wrote:
> Intel has a whole group of very experienced Linux kernel developers who
> will review code before you sent it out publicly.  Please take advantage
> of them and run this all through them before resending this out again.
> 
> If you did run this code through that group, please let me know who it
> was specifically that allowed this stuff to get through, and why they
> didn't want their name on this code submission.  I need to have a strong
> word with them...

We submitted the patches for internal review and got no objections to
release. We will be more aggressive in seeking out feedback (and approval)
before resubmitting any code.
 
> Yes, I am holding you to a higher standard than staging code normally
> is, and yes, it is purely because of the company you work for.  But I
> only do that because your company knows how to do this stuff right, and
> you have access to the resources and talent to help make this code
> right.  Other people and companies do not have the kind of advantage
> that you do.

We know we are fortunate to work for a company with so much talent and
resources and we don't mind being held to a higher standard. We have been
receiving multiple requests for our host driver and wanted to make it
available as soon as possible for others to use. We thought putting our
host driver into staging would be a good way to release it, but realize now
that it was premature. 

> Wasting community member's time (i.e. mine) by forcing _them_ to review
> stuff like this, is something that your company knows better than to do,
> as should you as well.
> 
> I want to see some more senior Intel kernel developer's signed-off-by
> lines on this code before I will ever consider accepting it for the
> kernel.  Please do not resend this code until that happens.
> 
> greg k-h

We apologize for wasting everyone's time and will certainly learn from this.
We won't resubmit the driver until a senior kernel developer has signed off on 
it.

Sincerely,
Sean O. Stalley
Stephanie S. Wallick
--
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] usbnet: smsc95xx: dereferencing NULL pointer

2014-11-11 Thread David Miller
From: Sudip Mukherjee 
Date: Tue, 11 Nov 2014 14:10:47 +0530

> we were dereferencing dev to initialize pdata. but just after that we
> have a BUG_ON(!dev). so we were basically dereferencing the pointer
> first and then tesing it for NULL.
> 
> Signed-off-by: Sudip Mukherjee 
> ---
> 
> change in v2: suspend_flags is initialised after pdata is initialised.
> v1 had a very silly but serious mistake of making pdata NULL, and trying
> to dereference it.
> sorry again for that.

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


Re: [PATCH 2/2] usb: musb: musb_cppi41: revert to old timer poll intervals

2014-11-11 Thread Sebastian Andrzej Siewior
On 11/11/2014 08:20 PM, Sebastian Reimers wrote:
> Hi Sebastian,
> Hi Daniel,
> 
> after some debugging the 25 microseconds loop only catches <1% of early_tx
> transfers (with your patch #1). Most of them are catched in the hrtimer 
> (incl. re-loop) 
> between 30-60 microseconds. Any debug code suggestions to get reliable 
> values? I`m
> not sure if my current affects timing.

protocol with trace_printk or measure max, min and avg with no output
and have a sysfs / debugfs file for output.

> With Daniels usb: musb: cppi41: tweak hrtimer
> values its better.
> The only negative is, that CPU usage is higher compared to PIO mode. 
> But maybe this is a restriction of DMA and smaller packet size.
> 
> cppi41_channel->total_len is 40 bytes.

It is higher because what happens now is very close to a busy loop. If
you take 40/10 => 4 so you setup your timer in 4us. There is the slack
of 20us but you see. And then you setup the next timer in 20us if I
remember correctly. Given the "normal" runtime of everything the system
has very little break between the reschedule.

You could measure the time with ktime_get() and compare the time you
need for setup DMA and "complete the DMA transfer" and compare it with
the time you need in PIO mode. Since it is "just" 40 bytes I would
assume that you might be better off without DMA. If so we could think
about rejecting DMA requests for transfers < x bytes and let PIO handle
it.

In USB-storage the protocol makes it possible to enqueue 16KiB as one
TX request where in PIO mode you would have to fill the FIFO 32 times.
You see the difference.

I've been browsing the manual and I don't see a possibility where I
could enqueue multiple DMA requests for one endpoint and then once the
first one completes, the next one would start on its own on the next
interval (in case of ISO). Then we could have relaxed poll interval ;)

> 48 kHz / 32 Bit - Stereo High Speed USB Host.

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


Status update on xhci controllers with broken streams

2014-11-11 Thread Hans de Goede
Hi All,

So when I send the patches to blacklist via xhci controllers with
a product-id of 3432, as well as asmedia 1042 xhci controllers,
I promised I would spend some quality time with both once I
actually got one of each in my hands, and see if I could come
up with a workaround rather then outrightly disabling streams on
them.

Long story short: The big hammer is here to stay.

Longer version:

Alexandre Oliva passed 2 via 3432 xhci controllers on to me
at Plumbers, I've ended up testing both of them:

1) Seems to work for a couple of seconds and then hard locks
the system without leaving any clues.

2) The second one which has identical pci info behaves differently
it completed the ep-config xhci command for enabling streaming with
an invalid a Context parameter is invalid error. I've tried several
things to get around this, including first removing endpoints and
then adding them, rather then doing the remove + add in one go,
but all to no avail.

I've bought an asmedia1042 using pci-e usb3 card from ebay, and
I've been testing that as well. When used with disk enclosures
with a nec uas to sata bridge, all urbs submitted to endpoints
with streams result in a stall error.  When using it with an
asm1051 or asm1053 based enclosure things work somewhat better,
except that as soon as we cancel an urb (e.g. a data urb
on a scsi error because of a not understood scsi command), we
get a mismatch on the expect dequeue address after the set_deq
command we issue after a stop endpoint on urb cancellation.

Things still seem to work after this error, but the combination
of this error + not working with non asm uas chipsets is a
deal-breaker.

So the best thing to do seems to just leave streams disabled,
and fallback to usb-storage on these controllers.

Regards,

Hans
--
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 for 3.18-rc4 to add OLIMEX ISP500 AVR Programmer

2014-11-11 Thread Johan Hovold
On Tue, Nov 11, 2014 at 04:43:52PM +, Sid Boyce wrote:
> Results
> ---
> root@sdrbox:~# lsusb
> Bus 002 Device 004: ID 13fd:1840 Initio Corporation INIC-1608 SATA bridge
> Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> Bus 004 Device 003: ID 15ba:000c Olimex Ltd.
> 
> The failure due to AtMega32 not attached.
> root@sdrbox:~# avrdude -p m32 -F -c stk500v2 -P /dev/ttyACM1
> 
> avrdude: stk500v2_command(): warning: Command timed out
> avrdude: initialization failed, rc=-1
> avrdude: AVR device initialized and ready to accept instructions
> avrdude: Device signature = 0xc807c6
> avrdude: Expected signature for ATmega32 is 1E 95 02
> 
> avrdude done.  Thank you.

I'm really not sure what I'm supposed to make of the above.

Care to submit the patch on a format that I can apply (i.e. with proper
subject and commit message and patch inline in body)? See
Documentation/SubmittingPatches for details.

Also why are you using an ACM node above? That's a different driver
(cdc-acm).

Could you provide "lsusb -v" output for your device as well?

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


Re: [PATCH 2/2] usb: musb: musb_cppi41: revert to old timer poll intervals

2014-11-11 Thread Sebastian Reimers
Hi Sebastian,
Hi Daniel,

after some debugging the 25 microseconds loop only catches <1% of early_tx
transfers (with your patch #1). Most of them are catched in the hrtimer (incl. 
re-loop) 
between 30-60 microseconds. Any debug code suggestions to get reliable values? 
I`m
not sure if my current affects timing.

With Daniels usb: musb: cppi41: tweak hrtimer
values its better.
The only negative is, that CPU usage is higher compared to PIO mode. 
But maybe this is a restriction of DMA and smaller packet size.

cppi41_channel->total_len is 40 bytes.

48 kHz / 32 Bit - Stereo High Speed USB Host.

--
Sebastian Reimers



--
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: Two questions about dwc2 driver

2014-11-11 Thread Paul Zimmerman
> From: linux-usb-ow...@vger.kernel.org 
> [mailto:linux-usb-ow...@vger.kernel.org] On Behalf Of Haibo Zhang
> Sent: Tuesday, November 11, 2014 6:37 AM
> 
> We know that dwc2 is the USB2.0 driver for DesignWare IP. But it only
> has host’s code without device’s code. So I have two questions:
> 1.   Will I develop or port the part of device’s code if I want to
> use dwc2 to support both host and device’s functions?

In the latest versions of the mainline kernel, the dwc2 driver supports
both host and device modes. Maybe you are using an older version of the
kernel where this wasn't true?

> 2.   Another question, I know that many chip companies use dwc2.
> How do they solve the question above?

See my previous answer. Also, many companies are using the Synopsys
vendor driver, which has been available for many years, before the dwc2
driver existed. If you are a Synopsys customer, you should have access
to that driver. There are also third parties who will sell you drivers
for the Synopsys controllers.

-- 
Paul

> If anyone has a similar experience or know well about this dwc2
> driver, please reply me.
> Any help will be greatly appreciated.
> 
> Thanks,
> 
> --
> 
> 
> *Zhang Haibo*

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

Re: [net-next PATCH v3 4/5] fm10k/igb/ixgbe: Replace __skb_alloc_page with dev_alloc_page

2014-11-11 Thread David Miller
From: Jeff Kirsher 
Date: Tue, 11 Nov 2014 09:56:34 -0800

> On Tue, 2014-11-11 at 12:48 -0500, David Miller wrote:
>> I think this entire series will need to go via my tree, because the
>> conversions are all required for patch #5 which removes the replaced
>> interface altogether.
> 
> That is fine Dave, I think I mentioned that during Alex's v1 of the
> series.  I was just letting Alex know that we were going to test his
> changes, but feel free to pull the entire series.
> 
> I will give you my ACK
> 
> Acked-by: Jeff Kirsher 

Great, thanks for the clarification.
--
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: [net-next PATCH v3 4/5] fm10k/igb/ixgbe: Replace __skb_alloc_page with dev_alloc_page

2014-11-11 Thread Jeff Kirsher
On Tue, 2014-11-11 at 12:48 -0500, David Miller wrote:
> From: Jeff Kirsher 
> Date: Tue, 11 Nov 2014 09:28:24 -0800
> 
> > On Tue, 2014-11-11 at 09:26 -0800, Alexander Duyck wrote:
> >> The Intel drivers were pretty much just using the plain vanilla GFP
> >> flags
> >> in their calls to __skb_alloc_page so this change makes it so that
> >> they use
> >> dev_alloc_page which just uses GFP_ATOMIC for the gfp_flags value.
> >> 
> >> Cc: Jeff Kirsher 
> >> Cc: Matthew Vick 
> >> Cc: Don Skidmore 
> >> Signed-off-by: Alexander Duyck 
> >> ---
> >>  drivers/net/ethernet/intel/fm10k/fm10k_main.c |2 +-
> >>  drivers/net/ethernet/intel/igb/igb_main.c |2 +-
> >>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |3 +--
> >>  3 files changed, 3 insertions(+), 4 deletions(-)
> > 
> > Thanks Alex, I will add the patch to my queue.
> 
> I think this entire series will need to go via my tree, because the
> conversions are all required for patch #5 which removes the replaced
> interface altogether.

That is fine Dave, I think I mentioned that during Alex's v1 of the
series.  I was just letting Alex know that we were going to test his
changes, but feel free to pull the entire series.

I will give you my ACK

Acked-by: Jeff Kirsher 


signature.asc
Description: This is a digitally signed message part


Re: [net-next PATCH v3 4/5] fm10k/igb/ixgbe: Replace __skb_alloc_page with dev_alloc_page

2014-11-11 Thread David Miller
From: Jeff Kirsher 
Date: Tue, 11 Nov 2014 09:28:24 -0800

> On Tue, 2014-11-11 at 09:26 -0800, Alexander Duyck wrote:
>> The Intel drivers were pretty much just using the plain vanilla GFP
>> flags
>> in their calls to __skb_alloc_page so this change makes it so that
>> they use
>> dev_alloc_page which just uses GFP_ATOMIC for the gfp_flags value.
>> 
>> Cc: Jeff Kirsher 
>> Cc: Matthew Vick 
>> Cc: Don Skidmore 
>> Signed-off-by: Alexander Duyck 
>> ---
>>  drivers/net/ethernet/intel/fm10k/fm10k_main.c |2 +-
>>  drivers/net/ethernet/intel/igb/igb_main.c |2 +-
>>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |3 +--
>>  3 files changed, 3 insertions(+), 4 deletions(-)
> 
> Thanks Alex, I will add the patch to my queue.

I think this entire series will need to go via my tree, because the
conversions are all required for patch #5 which removes the replaced
interface altogether.
--
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


[net-next PATCH v3 4/5] fm10k/igb/ixgbe: Replace __skb_alloc_page with dev_alloc_page

2014-11-11 Thread Alexander Duyck
The Intel drivers were pretty much just using the plain vanilla GFP flags
in their calls to __skb_alloc_page so this change makes it so that they use
dev_alloc_page which just uses GFP_ATOMIC for the gfp_flags value.

Cc: Jeff Kirsher 
Cc: Matthew Vick 
Cc: Don Skidmore 
Signed-off-by: Alexander Duyck 
---
 drivers/net/ethernet/intel/fm10k/fm10k_main.c |2 +-
 drivers/net/ethernet/intel/igb/igb_main.c |2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |3 +--
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c 
b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
index e645af4..73457ed 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
@@ -83,7 +83,7 @@ static bool fm10k_alloc_mapped_page(struct fm10k_ring 
*rx_ring,
return true;
 
/* alloc new page for storage */
-   page = alloc_page(GFP_ATOMIC | __GFP_COLD);
+   page = dev_alloc_page();
if (unlikely(!page)) {
rx_ring->rx_stats.alloc_failed++;
return false;
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
b/drivers/net/ethernet/intel/igb/igb_main.c
index a2d72a8..1e35fae 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -6988,7 +6988,7 @@ static bool igb_alloc_mapped_page(struct igb_ring 
*rx_ring,
return true;
 
/* alloc new page for storage */
-   page = __skb_alloc_page(GFP_ATOMIC | __GFP_COLD, NULL);
+   page = dev_alloc_page();
if (unlikely(!page)) {
rx_ring->rx_stats.alloc_failed++;
return false;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index d2df4e3..7405478 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -1440,8 +1440,7 @@ static bool ixgbe_alloc_mapped_page(struct ixgbe_ring 
*rx_ring,
 
/* alloc new page for storage */
if (likely(!page)) {
-   page = __skb_alloc_pages(GFP_ATOMIC | __GFP_COLD | __GFP_COMP,
-bi->skb, ixgbe_rx_pg_order(rx_ring));
+   page = dev_alloc_pages(ixgbe_rx_pg_order(rx_ring));
if (unlikely(!page)) {
rx_ring->rx_stats.alloc_rx_page_failed++;
return false;

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


[net-next PATCH v3 1/5] net: Add device Rx page allocation function

2014-11-11 Thread Alexander Duyck
This patch implements __dev_alloc_pages and __dev_alloc_page.  These are
meant to replace the __skb_alloc_pages and __skb_alloc_page functions.  The
reason for doing this is that it occurred to me that __skb_alloc_page is
supposed to be passed an sk_buff pointer, but it is NULL in all cases where
it is used.  Worse is that in the case of ixgbe it is passed NULL via the
sk_buff pointer in the rx_buffer info structure which means the compiler is
not correctly stripping it out.

The naming for these functions is based on dev_alloc_skb and __dev_alloc_skb.
There was originally a netdev_alloc_page, however that was passed a
net_device pointer and this function is not so I thought it best to follow
that naming scheme since that is the same difference between dev_alloc_skb
and netdev_alloc_skb.

In the case of anything greater than order 0 it is assumed that we want a
compound page so __GFP_COMP is set for all allocations as we expect a
compound page when assigning a page frag.

The other change in this patch is to exploit the behaviors of the page
allocator in how it handles flags.  So for example we can always set
__GFP_COMP and __GFP_MEMALLOC since they are ignored if they are not
applicable or are overridden by another flag.

Signed-off-by: Alexander Duyck 
---
 include/linux/skbuff.h |   48 
 1 file changed, 48 insertions(+)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 103fbe8..2e5221f 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2185,6 +2185,54 @@ static inline struct sk_buff 
*netdev_alloc_skb_ip_align(struct net_device *dev,
 }
 
 /**
+ * __dev_alloc_pages - allocate page for network Rx
+ * @gfp_mask: allocation priority. Set __GFP_NOMEMALLOC if not for network Rx
+ * @order: size of the allocation
+ *
+ * Allocate a new page.
+ *
+ * %NULL is returned if there is no free memory.
+*/
+static inline struct page *__dev_alloc_pages(gfp_t gfp_mask,
+unsigned int order)
+{
+   /* This piece of code contains several assumptions.
+* 1.  This is for device Rx, therefor a cold page is preferred.
+* 2.  The expectation is the user wants a compound page.
+* 3.  If requesting a order 0 page it will not be compound
+* due to the check to see if order has a value in prep_new_page
+* 4.  __GFP_MEMALLOC is ignored if __GFP_NOMEMALLOC is set due to
+* code in gfp_to_alloc_flags that should be enforcing this.
+*/
+   gfp_mask |= __GFP_COLD | __GFP_COMP | __GFP_MEMALLOC;
+
+   return alloc_pages_node(NUMA_NO_NODE, gfp_mask, order);
+}
+
+static inline struct page *dev_alloc_pages(unsigned int order)
+{
+   return __dev_alloc_pages(GFP_ATOMIC, order);
+}
+
+/**
+ * __dev_alloc_page - allocate a page for network Rx
+ * @gfp_mask: allocation priority. Set __GFP_NOMEMALLOC if not for network Rx
+ *
+ * Allocate a new page.
+ *
+ * %NULL is returned if there is no free memory.
+ */
+static inline struct page *__dev_alloc_page(gfp_t gfp_mask)
+{
+   return __dev_alloc_pages(gfp_mask, 0);
+}
+
+static inline struct page *dev_alloc_page(void)
+{
+   return __dev_alloc_page(GFP_ATOMIC);
+}
+
+/**
  * __skb_alloc_pages - allocate pages for ps-rx on a skb and preserve 
pfmemalloc data
  * @gfp_mask: alloc_pages_node mask. Set __GFP_NOMEMALLOC if not for 
network packet RX
  * @skb: skb to set pfmemalloc on if __GFP_MEMALLOC is used

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


[net-next PATCH v3 3/5] phonet: Replace calls to __skb_alloc_page with __dev_alloc_page

2014-11-11 Thread Alexander Duyck
Replace the calls to __skb_alloc_page that are passed NULL with calls to
__dev_alloc_page.

In addition remove __GFP_COLD flag from allocations as we only want it for
the Rx buffer which is taken care of by __dev_alloc_skb, not for any
secondary allocations such as the queue element transmit descriptors.

Cc: Oliver Neukum 
Cc: Felipe Balbi 
Signed-off-by: Alexander Duyck 
---
 drivers/net/usb/cdc-phonet.c   |6 +++---
 drivers/usb/gadget/function/f_phonet.c |6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/usb/cdc-phonet.c b/drivers/net/usb/cdc-phonet.c
index 2ec1500..415ce8b 100644
--- a/drivers/net/usb/cdc-phonet.c
+++ b/drivers/net/usb/cdc-phonet.c
@@ -130,7 +130,7 @@ static int rx_submit(struct usbpn_dev *pnd, struct urb 
*req, gfp_t gfp_flags)
struct page *page;
int err;
 
-   page = __skb_alloc_page(gfp_flags | __GFP_NOMEMALLOC, NULL);
+   page = __dev_alloc_page(gfp_flags | __GFP_NOMEMALLOC);
if (!page)
return -ENOMEM;
 
@@ -212,7 +212,7 @@ resubmit:
if (page)
put_page(page);
if (req)
-   rx_submit(pnd, req, GFP_ATOMIC | __GFP_COLD);
+   rx_submit(pnd, req, GFP_ATOMIC);
 }
 
 static int usbpn_close(struct net_device *dev);
@@ -231,7 +231,7 @@ static int usbpn_open(struct net_device *dev)
for (i = 0; i < rxq_size; i++) {
struct urb *req = usb_alloc_urb(0, GFP_KERNEL);
 
-   if (!req || rx_submit(pnd, req, GFP_KERNEL | __GFP_COLD)) {
+   if (!req || rx_submit(pnd, req, GFP_KERNEL)) {
usb_free_urb(req);
usbpn_close(dev);
return -ENOMEM;
diff --git a/drivers/usb/gadget/function/f_phonet.c 
b/drivers/usb/gadget/function/f_phonet.c
index b9cfc15..cde7397 100644
--- a/drivers/usb/gadget/function/f_phonet.c
+++ b/drivers/usb/gadget/function/f_phonet.c
@@ -303,7 +303,7 @@ pn_rx_submit(struct f_phonet *fp, struct usb_request *req, 
gfp_t gfp_flags)
struct page *page;
int err;
 
-   page = __skb_alloc_page(gfp_flags | __GFP_NOMEMALLOC, NULL);
+   page = __dev_alloc_page(gfp_flags | __GFP_NOMEMALLOC);
if (!page)
return -ENOMEM;
 
@@ -377,7 +377,7 @@ static void pn_rx_complete(struct usb_ep *ep, struct 
usb_request *req)
if (page)
put_page(page);
if (req)
-   pn_rx_submit(fp, req, GFP_ATOMIC | __GFP_COLD);
+   pn_rx_submit(fp, req, GFP_ATOMIC);
 }
 
 /*-*/
@@ -437,7 +437,7 @@ static int pn_set_alt(struct usb_function *f, unsigned 
intf, unsigned alt)
 
netif_carrier_on(dev);
for (i = 0; i < phonet_rxq_size; i++)
-   pn_rx_submit(fp, fp->out_reqv[i], GFP_ATOMIC | 
__GFP_COLD);
+   pn_rx_submit(fp, fp->out_reqv[i], GFP_ATOMIC);
}
spin_unlock(&port->lock);
return 0;

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


[net-next PATCH v3 0/5] Replace __skb_alloc_pages with simpler function

2014-11-11 Thread Alexander Duyck
This patch series replaces __skb_alloc_pages with a much simpler function,
__dev_alloc_pages.  The main difference between the two is that
__skb_alloc_pages had an sk_buff pointer that was being passed as NULL in
call places where it was called.  In a couple of cases the NULL was passed
by variable and this led to unnecessary code being run.

As such in order to simplify things the __dev_alloc_pages call only takes a
mask and the page order being requested.  In addition it takes advantage of
several behaviors already built into the page allocator so that it can just
set GFP flags unconditionally.

v2: Renamed functions to dev_alloc_page(s) instead of netdev_alloc_page(s)
Removed __GFP_COLD flag from usb code as it was redundant
v3: Update patch descriptions and subjects to match changes in v2

---

Alexander Duyck (5):
  net: Add device Rx page allocation function
  cxgb4/cxgb4vf: Replace __skb_alloc_page with __dev_alloc_page
  phonet: Replace calls to __skb_alloc_page with __dev_alloc_page
  fm10k/igb/ixgbe: Replace __skb_alloc_page with dev_alloc_page
  net: Remove __skb_alloc_page and __skb_alloc_pages


 drivers/net/ethernet/chelsio/cxgb4/sge.c  |6 +-
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c|7 ++-
 drivers/net/ethernet/intel/fm10k/fm10k_main.c |2 -
 drivers/net/ethernet/intel/igb/igb_main.c |2 -
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |3 -
 drivers/net/usb/cdc-phonet.c  |6 +-
 drivers/usb/gadget/function/f_phonet.c|6 +-
 include/linux/skbuff.h|   61 ++---
 8 files changed, 49 insertions(+), 44 deletions(-)

--
--
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: [net-next PATCH v2 4/5] fm10k/igb/ixgbe: Replace __skb_alloc_page with netdev_alloc_page

2014-11-11 Thread Alexander Duyck


On 11/11/2014 09:15 AM, Cong Wang wrote:

On Tue, Nov 11, 2014 at 9:11 AM, Alexander Duyck
 wrote:

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c 
b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
index e645af4..73457ed 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
@@ -83,7 +83,7 @@ static bool fm10k_alloc_mapped_page(struct fm10k_ring 
*rx_ring,
 return true;

 /* alloc new page for storage */
-   page = alloc_page(GFP_ATOMIC | __GFP_COLD);
+   page = dev_alloc_page();

Doesn't match $subject.


Yeah, I just noticed that.  I missed the patch title and comments when I 
was doing the replacement.


v3 on the way.

Thanks,

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


Re: [net-next PATCH v3 4/5] fm10k/igb/ixgbe: Replace __skb_alloc_page with dev_alloc_page

2014-11-11 Thread Jeff Kirsher
On Tue, 2014-11-11 at 09:26 -0800, Alexander Duyck wrote:
> The Intel drivers were pretty much just using the plain vanilla GFP
> flags
> in their calls to __skb_alloc_page so this change makes it so that
> they use
> dev_alloc_page which just uses GFP_ATOMIC for the gfp_flags value.
> 
> Cc: Jeff Kirsher 
> Cc: Matthew Vick 
> Cc: Don Skidmore 
> Signed-off-by: Alexander Duyck 
> ---
>  drivers/net/ethernet/intel/fm10k/fm10k_main.c |2 +-
>  drivers/net/ethernet/intel/igb/igb_main.c |2 +-
>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |3 +--
>  3 files changed, 3 insertions(+), 4 deletions(-)

Thanks Alex, I will add the patch to my queue.


signature.asc
Description: This is a digitally signed message part


[net-next PATCH v3 5/5] net: Remove __skb_alloc_page and __skb_alloc_pages

2014-11-11 Thread Alexander Duyck
Remove the two functions which are now dead code.

Signed-off-by: Alexander Duyck 
---
 include/linux/skbuff.h |   43 ---
 1 file changed, 43 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 2e5221f..73c370e 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2233,49 +2233,6 @@ static inline struct page *dev_alloc_page(void)
 }
 
 /**
- * __skb_alloc_pages - allocate pages for ps-rx on a skb and preserve 
pfmemalloc data
- * @gfp_mask: alloc_pages_node mask. Set __GFP_NOMEMALLOC if not for 
network packet RX
- * @skb: skb to set pfmemalloc on if __GFP_MEMALLOC is used
- * @order: size of the allocation
- *
- * Allocate a new page.
- *
- * %NULL is returned if there is no free memory.
-*/
-static inline struct page *__skb_alloc_pages(gfp_t gfp_mask,
- struct sk_buff *skb,
- unsigned int order)
-{
-   struct page *page;
-
-   gfp_mask |= __GFP_COLD;
-
-   if (!(gfp_mask & __GFP_NOMEMALLOC))
-   gfp_mask |= __GFP_MEMALLOC;
-
-   page = alloc_pages_node(NUMA_NO_NODE, gfp_mask, order);
-   if (skb && page && page->pfmemalloc)
-   skb->pfmemalloc = true;
-
-   return page;
-}
-
-/**
- * __skb_alloc_page - allocate a page for ps-rx for a given skb and 
preserve pfmemalloc data
- * @gfp_mask: alloc_pages_node mask. Set __GFP_NOMEMALLOC if not for 
network packet RX
- * @skb: skb to set pfmemalloc on if __GFP_MEMALLOC is used
- *
- * Allocate a new page.
- *
- * %NULL is returned if there is no free memory.
- */
-static inline struct page *__skb_alloc_page(gfp_t gfp_mask,
-struct sk_buff *skb)
-{
-   return __skb_alloc_pages(gfp_mask, skb, 0);
-}
-
-/**
  * skb_propagate_pfmemalloc - Propagate pfmemalloc if skb is allocated 
after RX page
  * @page: The page that was allocated from skb_alloc_page
  * @skb: The skb that may need pfmemalloc set

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


[net-next PATCH v3 2/5] cxgb4/cxgb4vf: Replace __skb_alloc_page with __dev_alloc_page

2014-11-11 Thread Alexander Duyck
Drop the bloated use of __skb_alloc_page and replace it with
__dev_alloc_page.  In addition update the one other spot that is
allocating a page so that it allocates with the correct flags.

Cc: Hariprasad S 
Cc: Casey Leedom 
Signed-off-by: Alexander Duyck 
---
 drivers/net/ethernet/chelsio/cxgb4/sge.c   |6 +++---
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c |7 ---
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index 5e1b314..20ee002 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -576,7 +576,7 @@ static unsigned int refill_fl(struct adapter *adap, struct 
sge_fl *q, int n,
__be64 *d = &q->desc[q->pidx];
struct rx_sw_desc *sd = &q->sdesc[q->pidx];
 
-   gfp |= __GFP_NOWARN | __GFP_COLD;
+   gfp |= __GFP_NOWARN;
 
if (s->fl_pg_order == 0)
goto alloc_small_pages;
@@ -585,7 +585,7 @@ static unsigned int refill_fl(struct adapter *adap, struct 
sge_fl *q, int n,
 * Prefer large buffers
 */
while (n) {
-   pg = alloc_pages(gfp | __GFP_COMP, s->fl_pg_order);
+   pg = __dev_alloc_pages(gfp, s->fl_pg_order);
if (unlikely(!pg)) {
q->large_alloc_failed++;
break;   /* fall back to single pages */
@@ -615,7 +615,7 @@ static unsigned int refill_fl(struct adapter *adap, struct 
sge_fl *q, int n,
 
 alloc_small_pages:
while (n--) {
-   pg = __skb_alloc_page(gfp, NULL);
+   pg = __dev_alloc_page(gfp);
if (unlikely(!pg)) {
q->alloc_failed++;
break;
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
index 85036e6..9df40df 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
@@ -602,6 +602,8 @@ static unsigned int refill_fl(struct adapter *adapter, 
struct sge_fl *fl,
 */
BUG_ON(fl->avail + n > fl->size - FL_PER_EQ_UNIT);
 
+   gfp |= __GFP_NOWARN;
+
/*
 * If we support large pages, prefer large buffers and fail over to
 * small pages if we can't allocate large pages to satisfy the refill.
@@ -612,8 +614,7 @@ static unsigned int refill_fl(struct adapter *adapter, 
struct sge_fl *fl,
goto alloc_small_pages;
 
while (n) {
-   page = alloc_pages(gfp | __GFP_COMP | __GFP_NOWARN,
-  FL_PG_ORDER);
+   page = __dev_alloc_pages(gfp, FL_PG_ORDER);
if (unlikely(!page)) {
/*
 * We've failed inour attempt to allocate a "large
@@ -657,7 +658,7 @@ static unsigned int refill_fl(struct adapter *adapter, 
struct sge_fl *fl,
 
 alloc_small_pages:
while (n--) {
-   page = __skb_alloc_page(gfp | __GFP_NOWARN, NULL);
+   page = __dev_alloc_page(gfp);
if (unlikely(!page)) {
fl->alloc_failed++;
break;

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


[PATCHv7 2/8] usb: dwc2: Move gadget probe function into platform code

2014-11-11 Thread dinguyen
From: Dinh Nguyen 

This patch will aggregate the probing of gadget/hcd driver into platform.c.
The gadget probe funtion is converted into gadget_init that is now only
responsible for gadget only initialization. All the gadget resources are now
handled by platform.c

Since the host workqueue will not get initialized if the driver is configured
for peripheral mode only. Thus we need to check for wq_otg before calling
queue_work().

Also, we move spin_lock_init to common location for both host and gadget that
is either in platform.c or pci.c.

We also move suspend/resume code to common platform code.

Lastly, move the "samsung,s3c6400-hsotg" binding into dwc2_of_match_table.

Signed-off-by: Dinh Nguyen 
Acked-by: Paul Zimmerman 
---
v7: Move the conversion to use pm_ops to a separate patch
v6: None
v5: Reworked by squashing the following commits into this one:
* [PATCHv4 02/12] usb: dwc2: move "samsung,s3c6400-hsotg" into common platform
* [PATCHv4 03/12] usb: dwc2: Update the gadget driver to use common dwc2_hsotg
  structure
* [PATCHv4 09/12] usb: dwc2: initialize the spin_lock for both host and gadget
* [PATCHv4 10/12] usb: dwc2: Add suspend/resume for gadget
* [PATCHv4 11/12] usb: dwc2: check that the host work queue is valid
Also use IS_ENABLED instead of #if defined
---
 drivers/usb/dwc2/core.h  | 33 +++
 drivers/usb/dwc2/core_intr.c |  8 ++--
 drivers/usb/dwc2/gadget.c| 99 ++--
 drivers/usb/dwc2/hcd.c   |  1 -
 drivers/usb/dwc2/hcd.h   | 10 -
 drivers/usb/dwc2/pci.c   |  1 +
 drivers/usb/dwc2/platform.c  | 28 +
 7 files changed, 88 insertions(+), 92 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 7bcdc10..4905d88 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -960,4 +960,37 @@ extern void dwc2_dump_global_registers(struct dwc2_hsotg 
*hsotg);
  */
 extern u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg);
 
+/* Gadget defines */
+#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || 
IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
+extern int s3c_hsotg_remove(struct dwc2_hsotg *hsotg);
+extern int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2);
+extern int s3c_hsotg_resume(struct dwc2_hsotg *dwc2);
+extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq);
+#else
+static inline int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
+{ return 0; }
+static inline int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2)
+{ return 0; }
+static inline int s3c_hsotg_resume(struct dwc2_hsotg *dwc2)
+{ return 0; }
+static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
+{ return 0; }
+#endif
+
+#if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
+extern int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg);
+extern void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg);
+extern void dwc2_hcd_start(struct dwc2_hsotg *hsotg);
+#else
+static inline void dwc2_set_all_params(struct dwc2_core_params *params, int 
value) {}
+static inline int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg)
+{ return 0; }
+static inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg) {}
+static inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) {}
+static inline void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) {}
+static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
+   const struct dwc2_core_params *params)
+{ return 0; }
+#endif
+
 #endif /* __DWC2_CORE_H__ */
diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index c93918b..b176c2f 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -287,9 +287,11 @@ static void dwc2_handle_conn_id_status_change_intr(struct 
dwc2_hsotg *hsotg)
 * Release lock before scheduling workq as it holds spinlock during
 * scheduling.
 */
-   spin_unlock(&hsotg->lock);
-   queue_work(hsotg->wq_otg, &hsotg->wf_otg);
-   spin_lock(&hsotg->lock);
+   if (hsotg->wq_otg) {
+   spin_unlock(&hsotg->lock);
+   queue_work(hsotg->wq_otg, &hsotg->wf_otg);
+   spin_lock(&hsotg->lock);
+   }
 
/* Clear interrupt */
writel(GINTSTS_CONIDSTSCHNG, hsotg->regs + GINTSTS);
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 5a24e95..9caea51 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3423,26 +3423,21 @@ static void s3c_hsotg_delete_debug(struct dwc2_hsotg 
*hsotg)
 }
 
 /**
- * s3c_hsotg_probe - probe function for hsotg driver
- * @pdev: The platform information for the driver
+ * dwc2_gadget_init - init function for gadget
+ * @dwc2: The data structure for the DWC2 driver.
+ * @irq: The IRQ number for the controller.
  */
-static int s3c_hsotg_probe(struct platform_device *pdev)
+int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
 {
-   struct s3c_hsotg_plat *plat = dev_get_platdata(&pdev->dev);
+   struct device *dev

Re: [net-next PATCH v2 4/5] fm10k/igb/ixgbe: Replace __skb_alloc_page with netdev_alloc_page

2014-11-11 Thread Cong Wang
On Tue, Nov 11, 2014 at 9:11 AM, Alexander Duyck
 wrote:
> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c 
> b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
> index e645af4..73457ed 100644
> --- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c
> +++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
> @@ -83,7 +83,7 @@ static bool fm10k_alloc_mapped_page(struct fm10k_ring 
> *rx_ring,
> return true;
>
> /* alloc new page for storage */
> -   page = alloc_page(GFP_ATOMIC | __GFP_COLD);
> +   page = dev_alloc_page();

Doesn't match $subject.
--
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


[PATCHv7 1/8] usb: dwc2: Update the gadget driver to use common dwc2_hsotg structure

2014-11-11 Thread dinguyen
From: Dinh Nguyen 

Adds the gadget data structure and appropriate data structure pointers
to the common dwc2_hsotg data structure. To keep the driver data
dereference code looking clean, the gadget variable declares are only available
for peripheral and dual-role mode. This is needed so that the dwc2_hsotg data
structure can be used by the hcd and gadget drivers.

Updates gadget.c to use the dwc2_hsotg data structure and gadget pointers
that have been moved into the common dwc2_hsotg structure.

Signed-off-by: Dinh Nguyen 
Signed-off-by: Paul Zimmerman 
---
v7: Addressed comments from Felipe Balbi on which variables should not be just
limited to gadget(phy, uphy, regulator_bulk_data_supplies, irq, clk,
debug_root, debug_file, and debug_fifo).
v6: None
v5: Keep the changes to mininum and maintain hcd and gadget driver to build
and work separately. Use IS_ENABLED() instead of #if defined
v3: Updated with paulz's suggestion to avoid double pointers.
v2: Left the function parameter name as 'hsotg' and just changed its type.
---
 drivers/usb/dwc2/core.h   | 155 --
 drivers/usb/dwc2/gadget.c | 146 +--
 2 files changed, 153 insertions(+), 148 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 55c90c5..7bcdc10 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -84,7 +84,7 @@ static const char * const s3c_hsotg_supply_names[] = {
  */
 #define EP0_MPS_LIMIT   64
 
-struct s3c_hsotg;
+struct dwc2_hsotg;
 struct s3c_hsotg_req;
 
 /**
@@ -130,7 +130,7 @@ struct s3c_hsotg_req;
 struct s3c_hsotg_ep {
struct usb_ep   ep;
struct list_headqueue;
-   struct s3c_hsotg*parent;
+   struct dwc2_hsotg   *parent;
struct s3c_hsotg_req*req;
struct dentry   *debugfs;
 
@@ -155,67 +155,6 @@ struct s3c_hsotg_ep {
 };
 
 /**
- * struct s3c_hsotg - driver state.
- * @dev: The parent device supplied to the probe function
- * @driver: USB gadget driver
- * @phy: The otg phy transceiver structure for phy control.
- * @uphy: The otg phy transceiver structure for old USB phy control.
- * @plat: The platform specific configuration data. This can be removed once
- * all SoCs support usb transceiver.
- * @regs: The memory area mapped for accessing registers.
- * @irq: The IRQ number we are using
- * @supplies: Definition of USB power supplies
- * @phyif: PHY interface width
- * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
- * @num_of_eps: Number of available EPs (excluding EP0)
- * @debug_root: root directrory for debugfs.
- * @debug_file: main status file for debugfs.
- * @debug_fifo: FIFO status file for debugfs.
- * @ep0_reply: Request used for ep0 reply.
- * @ep0_buff: Buffer for EP0 reply data, if needed.
- * @ctrl_buff: Buffer for EP0 control requests.
- * @ctrl_req: Request for EP0 control packets.
- * @setup: NAK management for EP0 SETUP
- * @last_rst: Time of last reset
- * @eps: The endpoints being supplied to the gadget framework
- */
-struct s3c_hsotg {
-   struct device*dev;
-   struct usb_gadget_driver *driver;
-   struct phy   *phy;
-   struct usb_phy   *uphy;
-   struct s3c_hsotg_plat*plat;
-
-   spinlock_t  lock;
-
-   void __iomem*regs;
-   int irq;
-   struct clk  *clk;
-
-   struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
-
-   u32 phyif;
-   int fifo_mem;
-   unsigned intdedicated_fifos:1;
-   unsigned char   num_of_eps;
-   u32 fifo_map;
-
-   struct dentry   *debug_root;
-   struct dentry   *debug_file;
-   struct dentry   *debug_fifo;
-
-   struct usb_request  *ep0_reply;
-   struct usb_request  *ctrl_req;
-   u8  ep0_buff[8];
-   u8  ctrl_buff[8];
-
-   struct usb_gadget   gadget;
-   unsigned intsetup;
-   unsigned long   last_rst;
-   struct s3c_hsotg_ep *eps;
-};
-
-/**
  * struct s3c_hsotg_req - data transfer request
  * @req: The USB gadget request
  * @queue: The list of requests for the endpoint this is queued for.
@@ -229,6 +168,7 @@ struct s3c_hsotg_req {
unsigned char   mapped;
 };
 
+#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || 
IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
 #define call_gadget(_hs, _entry) \
 do { \
if ((_hs)->gadget.speed != USB_SPEED_UNKNOWN && \
@@ -238,6 +178,9 @@ do { \
spin_lock(&_hs->lock); \
} \
 } while (0)
+#else
+#define call_gadget(_hs, _entry)   do {} while (0)
+#endif
 
 struct dwc2_hsotg;
 struct dwc2_host_chan;
@@ -495,11 +438,13 @@ struct dwc2_hw_params {
  * struct dwc2_hsotg - Holds the state

[PATCHv7 4/8] usb: dwc2: Initialize the USB core for peripheral mode

2014-11-11 Thread dinguyen
From: Dinh Nguyen 

Initialize the USB driver to peripheral mode when a B-Device connector
is attached.

Signed-off-by: Dinh Nguyen 
Acked-by: Paul Zimmerman 
---
v7: s3c_hsotg_core_init became s3c_hsotg_core_init_disconnected
v5: move the export of s3c_hsotg_core_init into this patch
---
 drivers/usb/dwc2/core.h   | 4 
 drivers/usb/dwc2/gadget.c | 4 ++--
 drivers/usb/dwc2/hcd.c| 2 ++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 4905d88..4710935 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -966,6 +966,8 @@ extern int s3c_hsotg_remove(struct dwc2_hsotg *hsotg);
 extern int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2);
 extern int s3c_hsotg_resume(struct dwc2_hsotg *dwc2);
 extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq);
+extern void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2);
+extern void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg);
 #else
 static inline int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
 { return 0; }
@@ -975,6 +977,8 @@ static inline int s3c_hsotg_resume(struct dwc2_hsotg *dwc2)
 { return 0; }
 static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
 { return 0; }
+static inline void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2) {}
+static inline void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg) {}
 #endif
 
 #if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 9caea51..ec85340 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2125,7 +2125,7 @@ static int s3c_hsotg_corereset(struct dwc2_hsotg *hsotg)
  *
  * Issue a soft reset to the core, and await the core finishing it.
  */
-static void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg)
+void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg)
 {
s3c_hsotg_corereset(hsotg);
 
@@ -2257,7 +2257,7 @@ static void s3c_hsotg_core_disconnect(struct dwc2_hsotg 
*hsotg)
__orr32(hsotg->regs + DCTL, DCTL_SFTDISCON);
 }
 
-static void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg)
+void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg)
 {
/* remove the soft-disconnect and let's go */
__bic32(hsotg->regs + DCTL, DCTL_SFTDISCON);
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 4a3cce0..fa60f4a 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -1371,6 +1371,8 @@ static void dwc2_conn_id_status_change(struct work_struct 
*work)
hsotg->op_state = OTG_STATE_B_PERIPHERAL;
dwc2_core_init(hsotg, false, -1);
dwc2_enable_global_interrupts(hsotg);
+   s3c_hsotg_core_init_disconnected(hsotg);
+   s3c_hsotg_core_connect(hsotg);
} else {
/* A-Device connector (Host Mode) */
dev_dbg(hsotg->dev, "connId A\n");
-- 
2.0.3

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


[PATCHv7 3/8] usb: dwc2: convert to use dev_pm_ops API

2014-11-11 Thread dinguyen
From: Dinh Nguyen 

Update suspend/resume to use dev_pm_ops API.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/platform.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index eeba8a4..b94867b 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -219,9 +219,9 @@ static int dwc2_driver_probe(struct platform_device *dev)
return retval;
 }
 
-static int dwc2_suspend(struct platform_device *dev, pm_message_t state)
+static int dwc2_suspend(struct device *dev)
 {
-   struct dwc2_hsotg *dwc2 = platform_get_drvdata(dev);
+   struct dwc2_hsotg *dwc2 = dev_get_drvdata(dev);
int ret = 0;
 
if (dwc2_is_device_mode(dwc2))
@@ -229,9 +229,9 @@ static int dwc2_suspend(struct platform_device *dev, 
pm_message_t state)
return ret;
 }
 
-static int dwc2_resume(struct platform_device *dev)
+static int dwc2_resume(struct device *dev)
 {
-   struct dwc2_hsotg *dwc2 = platform_get_drvdata(dev);
+   struct dwc2_hsotg *dwc2 = dev_get_drvdata(dev);
int ret = 0;
 
if (dwc2_is_device_mode(dwc2))
@@ -239,15 +239,18 @@ static int dwc2_resume(struct platform_device *dev)
return ret;
 }
 
+static const struct dev_pm_ops dwc2_dev_pm_ops = {
+   SET_SYSTEM_SLEEP_PM_OPS(dwc2_suspend, dwc2_resume)
+};
+
 static struct platform_driver dwc2_platform_driver = {
.driver = {
.name = dwc2_driver_name,
.of_match_table = dwc2_of_match_table,
+   .pm = &dwc2_dev_pm_ops,
},
.probe = dwc2_driver_probe,
.remove = dwc2_driver_remove,
-   .suspend = dwc2_suspend,
-   .resume = dwc2_resume,
 };
 
 module_platform_driver(dwc2_platform_driver);
-- 
2.0.3

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


[PATCHv7 5/8] usb: dwc2: Update common interrupt handler to call gadget interrupt handler

2014-11-11 Thread dinguyen
From: Dinh Nguyen 

Make dwc2_handle_common_intr call the gadget interrupt function when operating
in peripheral mode. Remove the spinlock functions in s3c_hsotg_irq as
dwc2_handle_common_intr() already has the spinlocks.

Move the registeration of the IRQ to common code for platform and PCI.

Remove duplicate interrupt conditions that was in gadget, as those are handled
by dwc2 common interrupt handler.

Signed-off-by: Dinh Nguyen 
---
v7: Use IRQF_SHARED
v5: remove individual devm_request_irq from gadget and hcd, and place a
single devm_request_irq in platform and pci.
v2: Keep interrupt handler for host and peripheral modes separate
---
 drivers/usb/dwc2/core.c | 10 --
 drivers/usb/dwc2/gadget.c   | 46 +++--
 drivers/usb/dwc2/pci.c  |  6 ++
 drivers/usb/dwc2/platform.c |  8 
 4 files changed, 17 insertions(+), 53 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index d926945..7605850b 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -458,16 +458,6 @@ int dwc2_core_init(struct dwc2_hsotg *hsotg, bool 
select_phy, int irq)
/* Clear the SRP success bit for FS-I2c */
hsotg->srp_success = 0;
 
-   if (irq >= 0) {
-   dev_dbg(hsotg->dev, "registering common handler for irq%d\n",
-   irq);
-   retval = devm_request_irq(hsotg->dev, irq,
- dwc2_handle_common_intr, IRQF_SHARED,
- dev_name(hsotg->dev), hsotg);
-   if (retval)
-   return retval;
-   }
-
/* Enable common interrupts */
dwc2_enable_common_interrupts(hsotg);
 
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index ec85340..37c7916 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2285,33 +2285,12 @@ irq_retry:
 
gintsts &= gintmsk;
 
-   if (gintsts & GINTSTS_OTGINT) {
-   u32 otgint = readl(hsotg->regs + GOTGINT);
-
-   dev_info(hsotg->dev, "OTGInt: %08x\n", otgint);
-
-   writel(otgint, hsotg->regs + GOTGINT);
-   }
-
-   if (gintsts & GINTSTS_SESSREQINT) {
-   dev_dbg(hsotg->dev, "%s: SessReqInt\n", __func__);
-   writel(GINTSTS_SESSREQINT, hsotg->regs + GINTSTS);
-   }
-
if (gintsts & GINTSTS_ENUMDONE) {
writel(GINTSTS_ENUMDONE, hsotg->regs + GINTSTS);
 
s3c_hsotg_irq_enumdone(hsotg);
}
 
-   if (gintsts & GINTSTS_CONIDSTSCHNG) {
-   dev_dbg(hsotg->dev, "ConIDStsChg (DSTS=0x%08x, GOTCTL=%08x)\n",
-   readl(hsotg->regs + DSTS),
-   readl(hsotg->regs + GOTGCTL));
-
-   writel(GINTSTS_CONIDSTSCHNG, hsotg->regs + GINTSTS);
-   }
-
if (gintsts & (GINTSTS_OEPINT | GINTSTS_IEPINT)) {
u32 daint = readl(hsotg->regs + DAINT);
u32 daintmsk = readl(hsotg->regs + DAINTMSK);
@@ -2392,25 +2371,6 @@ irq_retry:
s3c_hsotg_handle_rx(hsotg);
}
 
-   if (gintsts & GINTSTS_MODEMIS) {
-   dev_warn(hsotg->dev, "warning, mode mismatch triggered\n");
-   writel(GINTSTS_MODEMIS, hsotg->regs + GINTSTS);
-   }
-
-   if (gintsts & GINTSTS_USBSUSP) {
-   dev_info(hsotg->dev, "GINTSTS_USBSusp\n");
-   writel(GINTSTS_USBSUSP, hsotg->regs + GINTSTS);
-
-   call_gadget(hsotg, suspend);
-   }
-
-   if (gintsts & GINTSTS_WKUPINT) {
-   dev_info(hsotg->dev, "GINTSTS_WkUpIn\n");
-   writel(GINTSTS_WKUPINT, hsotg->regs + GINTSTS);
-
-   call_gadget(hsotg, resume);
-   }
-
if (gintsts & GINTSTS_ERLYSUSP) {
dev_dbg(hsotg->dev, "GINTSTS_ErlySusp\n");
writel(GINTSTS_ERLYSUSP, hsotg->regs + GINTSTS);
@@ -3510,14 +3470,14 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
s3c_hsotg_hw_cfg(hsotg);
s3c_hsotg_init(hsotg);
 
-   ret = devm_request_irq(dev, irq, s3c_hsotg_irq, 0,
-   dev_name(dev), hsotg);
+   ret = devm_request_irq(hsotg->dev, irq, s3c_hsotg_irq, IRQF_SHARED,
+   dev_name(hsotg->dev), hsotg);
if (ret < 0) {
s3c_hsotg_phy_disable(hsotg);
clk_disable_unprepare(hsotg->clk);
regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies),
   hsotg->supplies);
-   dev_err(dev, "cannot claim IRQ\n");
+   dev_err(dev, "cannot claim IRQ for gadget\n");
goto err_clk;
}
 
diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c
index 6d33ecf..a4e724b 100644
--- a/drivers/usb/dwc2/pci.c
+++ b/drivers/usb/dwc2/pci.c
@@ -141,6 +141,12 @@ static int dwc2_driver_probe(struct pci_dev *dev,
 
pci_set_m

[PATCHv7 6/8] usb: dwc2: gadget: Do not fail probe if there isn't a clock node

2014-11-11 Thread dinguyen
From: Dinh Nguyen 

Since the dwc2 hcd driver is currently not looking for a clock node during
init, we should not completely fail if there isn't a clock provided.
By assigning clk = NULL, this allows the driver, when configured for dual-role
mode, to be able to continue loading the host portion of the driver when
a clock node is not specified.

Signed-off-by: Dinh Nguyen 
---
v7: Reworked to use clk=NULL and remove the need to is IS_ERR(clk)
v6: none
v5: reworked to not access gadget functions from the hcd.
---
 drivers/usb/dwc2/gadget.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 37c7916..367689b 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3431,6 +3431,7 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
 
hsotg->clk = devm_clk_get(dev, "otg");
if (IS_ERR(hsotg->clk)) {
+   hsotg->clk = NULL;
dev_err(dev, "cannot get otg clock\n");
return PTR_ERR(hsotg->clk);
}
-- 
2.0.3

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


[net-next PATCH v2 5/5] net: Remove __skb_alloc_page and __skb_alloc_pages

2014-11-11 Thread Alexander Duyck
Remove the two functions which are now dead code.

Signed-off-by: Alexander Duyck 
---
 include/linux/skbuff.h |   43 ---
 1 file changed, 43 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 2e5221f..73c370e 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2233,49 +2233,6 @@ static inline struct page *dev_alloc_page(void)
 }
 
 /**
- * __skb_alloc_pages - allocate pages for ps-rx on a skb and preserve 
pfmemalloc data
- * @gfp_mask: alloc_pages_node mask. Set __GFP_NOMEMALLOC if not for 
network packet RX
- * @skb: skb to set pfmemalloc on if __GFP_MEMALLOC is used
- * @order: size of the allocation
- *
- * Allocate a new page.
- *
- * %NULL is returned if there is no free memory.
-*/
-static inline struct page *__skb_alloc_pages(gfp_t gfp_mask,
- struct sk_buff *skb,
- unsigned int order)
-{
-   struct page *page;
-
-   gfp_mask |= __GFP_COLD;
-
-   if (!(gfp_mask & __GFP_NOMEMALLOC))
-   gfp_mask |= __GFP_MEMALLOC;
-
-   page = alloc_pages_node(NUMA_NO_NODE, gfp_mask, order);
-   if (skb && page && page->pfmemalloc)
-   skb->pfmemalloc = true;
-
-   return page;
-}
-
-/**
- * __skb_alloc_page - allocate a page for ps-rx for a given skb and 
preserve pfmemalloc data
- * @gfp_mask: alloc_pages_node mask. Set __GFP_NOMEMALLOC if not for 
network packet RX
- * @skb: skb to set pfmemalloc on if __GFP_MEMALLOC is used
- *
- * Allocate a new page.
- *
- * %NULL is returned if there is no free memory.
- */
-static inline struct page *__skb_alloc_page(gfp_t gfp_mask,
-struct sk_buff *skb)
-{
-   return __skb_alloc_pages(gfp_mask, skb, 0);
-}
-
-/**
  * skb_propagate_pfmemalloc - Propagate pfmemalloc if skb is allocated 
after RX page
  * @page: The page that was allocated from skb_alloc_page
  * @skb: The skb that may need pfmemalloc set

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


[net-next PATCH v2 4/5] fm10k/igb/ixgbe: Replace __skb_alloc_page with netdev_alloc_page

2014-11-11 Thread Alexander Duyck
The Intel drivers were pretty much just using the plain vanilla GFP flags
in their calls to __skb_alloc_page so this change makes it so that they use
netdev_alloc_page which just uses GFP_ATOMIC for the gfp_flags value.

Cc: Jeff Kirsher 
Cc: Matthew Vick 
Cc: Don Skidmore 
Signed-off-by: Alexander Duyck 
---
 drivers/net/ethernet/intel/fm10k/fm10k_main.c |2 +-
 drivers/net/ethernet/intel/igb/igb_main.c |2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |3 +--
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c 
b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
index e645af4..73457ed 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
@@ -83,7 +83,7 @@ static bool fm10k_alloc_mapped_page(struct fm10k_ring 
*rx_ring,
return true;
 
/* alloc new page for storage */
-   page = alloc_page(GFP_ATOMIC | __GFP_COLD);
+   page = dev_alloc_page();
if (unlikely(!page)) {
rx_ring->rx_stats.alloc_failed++;
return false;
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
b/drivers/net/ethernet/intel/igb/igb_main.c
index a2d72a8..1e35fae 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -6988,7 +6988,7 @@ static bool igb_alloc_mapped_page(struct igb_ring 
*rx_ring,
return true;
 
/* alloc new page for storage */
-   page = __skb_alloc_page(GFP_ATOMIC | __GFP_COLD, NULL);
+   page = dev_alloc_page();
if (unlikely(!page)) {
rx_ring->rx_stats.alloc_failed++;
return false;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index d2df4e3..7405478 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -1440,8 +1440,7 @@ static bool ixgbe_alloc_mapped_page(struct ixgbe_ring 
*rx_ring,
 
/* alloc new page for storage */
if (likely(!page)) {
-   page = __skb_alloc_pages(GFP_ATOMIC | __GFP_COLD | __GFP_COMP,
-bi->skb, ixgbe_rx_pg_order(rx_ring));
+   page = dev_alloc_pages(ixgbe_rx_pg_order(rx_ring));
if (unlikely(!page)) {
rx_ring->rx_stats.alloc_rx_page_failed++;
return false;

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


[net-next PATCH v2 2/5] cxgb4/cxgb4vf: Replace __skb_alloc_page with __netdev_alloc_page

2014-11-11 Thread Alexander Duyck
Drop the bloated use of __skb_alloc_page and replace it with
__netdev_alloc_page.  In addition update the one other spot that is
allocating a page so that it allocates with the correct flags.

Cc: Hariprasad S 
Cc: Casey Leedom 
Signed-off-by: Alexander Duyck 
---
 drivers/net/ethernet/chelsio/cxgb4/sge.c   |6 +++---
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c |7 ---
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index 5e1b314..20ee002 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -576,7 +576,7 @@ static unsigned int refill_fl(struct adapter *adap, struct 
sge_fl *q, int n,
__be64 *d = &q->desc[q->pidx];
struct rx_sw_desc *sd = &q->sdesc[q->pidx];
 
-   gfp |= __GFP_NOWARN | __GFP_COLD;
+   gfp |= __GFP_NOWARN;
 
if (s->fl_pg_order == 0)
goto alloc_small_pages;
@@ -585,7 +585,7 @@ static unsigned int refill_fl(struct adapter *adap, struct 
sge_fl *q, int n,
 * Prefer large buffers
 */
while (n) {
-   pg = alloc_pages(gfp | __GFP_COMP, s->fl_pg_order);
+   pg = __dev_alloc_pages(gfp, s->fl_pg_order);
if (unlikely(!pg)) {
q->large_alloc_failed++;
break;   /* fall back to single pages */
@@ -615,7 +615,7 @@ static unsigned int refill_fl(struct adapter *adap, struct 
sge_fl *q, int n,
 
 alloc_small_pages:
while (n--) {
-   pg = __skb_alloc_page(gfp, NULL);
+   pg = __dev_alloc_page(gfp);
if (unlikely(!pg)) {
q->alloc_failed++;
break;
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
index 85036e6..9df40df 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
@@ -602,6 +602,8 @@ static unsigned int refill_fl(struct adapter *adapter, 
struct sge_fl *fl,
 */
BUG_ON(fl->avail + n > fl->size - FL_PER_EQ_UNIT);
 
+   gfp |= __GFP_NOWARN;
+
/*
 * If we support large pages, prefer large buffers and fail over to
 * small pages if we can't allocate large pages to satisfy the refill.
@@ -612,8 +614,7 @@ static unsigned int refill_fl(struct adapter *adapter, 
struct sge_fl *fl,
goto alloc_small_pages;
 
while (n) {
-   page = alloc_pages(gfp | __GFP_COMP | __GFP_NOWARN,
-  FL_PG_ORDER);
+   page = __dev_alloc_pages(gfp, FL_PG_ORDER);
if (unlikely(!page)) {
/*
 * We've failed inour attempt to allocate a "large
@@ -657,7 +658,7 @@ static unsigned int refill_fl(struct adapter *adapter, 
struct sge_fl *fl,
 
 alloc_small_pages:
while (n--) {
-   page = __skb_alloc_page(gfp | __GFP_NOWARN, NULL);
+   page = __dev_alloc_page(gfp);
if (unlikely(!page)) {
fl->alloc_failed++;
break;

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


[PATCHv7 8/8] usb: dwc2: Update Kconfig to support dual-role

2014-11-11 Thread dinguyen
From: Dinh Nguyen 

Update DWC2 kconfig and makefile to support dual-role mode. The platform
file will always get compiled for the case where the controller is directly
connected to the CPU. So for loadable modules, dwc2.ko is built for host,
peripheral, and dual-role mode. The PCI bus interface will be called
dwc2_pci.ko and the platform interface module will be called dwc2_platform.ko.

Signed-off-by: Dinh Nguyen 
Acked-by: Paul Zimmerman 
---
v7: None
v6: Correct notes for USB_DWC2_DUAL_ROLE and USB_DWC2_PERIPHERAL
Remove extra default for USB_DWC2_PLATFORM and make it a condition for
building dwc2_platform.ko. In addition USB_DWC2_PLATFORM and USB_DWC2_PCI
are now tristate.
v5: dwc2.ko for all modes along with dwc2_platform.ko and dwc2_pci.ko will
get built for kernel modules.
v3: Add USB_GADGET=y and USB_GADGET=USB_DWC2 for peripheral and dual-role
config options.
v2: Remove reference to dwc2_gadget
---
 drivers/usb/dwc2/Kconfig  | 66 ---
 drivers/usb/dwc2/Makefile | 32 +++
 2 files changed, 55 insertions(+), 43 deletions(-)

diff --git a/drivers/usb/dwc2/Kconfig b/drivers/usb/dwc2/Kconfig
index 4d02718..b323c4c 100644
--- a/drivers/usb/dwc2/Kconfig
+++ b/drivers/usb/dwc2/Kconfig
@@ -1,5 +1,5 @@
 config USB_DWC2
-   bool "DesignWare USB2 DRD Core Support"
+   tristate "DesignWare USB2 DRD Core Support"
depends on USB || USB_GADGET
help
  Say Y here if your system has a Dual Role Hi-Speed USB
@@ -10,49 +10,61 @@ config USB_DWC2
  bus interface module (if you have a PCI bus system) will be
  called dwc2_pci.ko, and the platform interface module (for
  controllers directly connected to the CPU) will be called
- dwc2_platform.ko. For gadget mode, there will be a single
- module called dwc2_gadget.ko.
-
- NOTE: The s3c-hsotg driver is now renamed to dwc2_gadget. The
- host and gadget drivers are still currently separate drivers.
- There are plans to merge the dwc2_gadget driver with the dwc2
- host driver in the near future to create a dual-role driver.
+ dwc2_platform.ko. For all modes(host, gadget and dual-role), there
+ will be an additional module named dwc2.ko.
 
 if USB_DWC2
 
+choice
+   bool "DWC2 Mode Selection"
+   default USB_DWC2_DUAL_ROLE if (USB && USB_GADGET)
+   default USB_DWC2_HOST if (USB && !USB_GADGET)
+   default USB_DWC2_PERIPHERAL if (!USB && USB_GADGET)
+
 config USB_DWC2_HOST
-   tristate "Host only mode"
+   bool "Host only mode"
depends on USB
help
  The Designware USB2.0 high-speed host controller
- integrated into many SoCs.
+ integrated into many SoCs. Select this option if you want the
+ driver to operate in Host-only mode.
 
-config USB_DWC2_PLATFORM
-   bool "DWC2 Platform"
-   depends on USB_DWC2_HOST
-   default USB_DWC2_HOST
+comment "Gadget/Dual-role mode requires USB Gadget support to be enabled"
+
+config USB_DWC2_PERIPHERAL
+   bool "Gadget only mode"
+   depends on USB_GADGET=y || USB_GADGET=USB_DWC2
+   help
+ The Designware USB2.0 high-speed gadget controller
+ integrated into many SoCs. Select this option if you want the
+ driver to operate in Peripheral-only mode. This option requires
+ USB_GADGET to be enabled.
+
+config USB_DWC2_DUAL_ROLE
+   bool "Dual Role mode"
+   depends on (USB=y || USB=USB_DWC2) && (USB_GADGET=y || 
USB_GADGET=USB_DWC2)
help
- The Designware USB2.0 platform interface module for
- controllers directly connected to the CPU. This is only
- used for host mode.
+ Select this option if you want the driver to work in a dual-role
+ mode. In this mode both host and gadget features are enabled, and
+ the role will be determined by the cable that gets plugged-in. This
+ option requires USB_GADGET to be enabled.
+endchoice
+
+config USB_DWC2_PLATFORM
+   tristate "DWC2 Platform"
+   default USB_DWC2_HOST || USB_DWC2_PERIPHERAL
+help
+  The Designware USB2.0 platform interface module for
+  controllers directly connected to the CPU.
 
 config USB_DWC2_PCI
-   bool "DWC2 PCI"
+   tristate "DWC2 PCI"
depends on USB_DWC2_HOST && PCI
default USB_DWC2_HOST
help
  The Designware USB2.0 PCI interface module for controllers
  connected to a PCI bus. This is only used for host mode.
 
-comment "Gadget mode requires USB Gadget support to be enabled"
-
-config USB_DWC2_PERIPHERAL
-   tristate "Gadget only mode"
-   depends on USB_GADGET
-   help
- The Designware USB2.0 high-speed gadget controller
- integrated into many SoCs.
-
 config USB_DWC2_DEBUG
bool "Enable Debugging Messages"
help
diff --git a/drivers/usb/dwc2/Makefile b/drivers/usb/d

[PATCHv7 7/8] usb: dwc2: move usb_disabled() call to host driver only

2014-11-11 Thread dinguyen
From: Dinh Nguyen 

Since platform.c will get built for both Host and Gadget, if we leave the
usb_disabled() call in platform.c, it results in the following build error
when (!USB && USB_GADGET) condition is met.

ERROR: "usb_disabled" [drivers/usb/dwc2/dwc2_platform.ko] undefined!

Since usb_disabled() is mostly used to disable USB host functionality, move
the call the host portion for the DWC2 driver.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/hcd.c  | 3 +++
 drivers/usb/dwc2/platform.c | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index fa60f4a..755e16b 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2780,6 +2780,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
int i, num_channels;
int retval;
 
+   if (usb_disabled())
+   return -ENODEV;
+
dev_dbg(hsotg->dev, "DWC OTG HCD INIT\n");
 
/* Detect config values from hardware */
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 3552602..57eb8a3 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -157,9 +157,6 @@ static int dwc2_driver_probe(struct platform_device *dev)
int retval;
int irq;
 
-   if (usb_disabled())
-   return -ENODEV;
-
match = of_match_device(dwc2_of_match_table, &dev->dev);
if (match && match->data) {
params = match->data;
-- 
2.0.3

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


[PATCHv7 0/8] usb: dwc2: Add support for dual-role

2014-11-11 Thread dinguyen
From: Dinh Nguyen 

Hello,

This is version 7 of the patch series that combines the dwc2 gadget and host
driver into a single dual role driver. Here are the main differences from V6:

- patch 1/8: Addressed Felipe's comment on which variables should not be just
  limited to gadget(phy, uphy, regulator_bulk_data_supplies, irq, clk,
  debug_root, debug_file, and debug_fifo).
- patch 2/8: Move conversion to use dev_pm_ops API to separate patch.
- patch 3/8: Convert to use dev_pm_ops API
- patch 4/8: Rebased to s3c_hsotg_core_init is now
  s3c_hsotg_core_init_disconnected(), followed by s3c_hsotg_core_connect().
- patch 5/8: Use IRQF_SHARED to have s3c_hsotg_irq handle gadget interrupts.
  Had to remove paulz's Acked-by for this patch, as it is not quite the same
  patch when his ack was given.
- patch 6/8: Assign clk=NULL if a clock is not provided.
- patch 7/8: Moved ahead of Kconfig/Makefile patch to avoid a build error when
  patch 8 is applied to dual-role.
- patch 8/8: none

For v7, the series is rebased on top of Felipe Balbi's tree on -next
branch. I thought this might be appropriate as there are dwc2 patches already
on this branch.

As usual, tested on SOCFPGA(host, gadget, and dual-role) and on Rpi-B
(host mode only).

I have pushed this series to a git repo to make it more convenient for people
to test/review.

git://git.rocketboards.org/linux-socfpga-next.git dwc2_dual_role_v7

Thanks,

Dinh Nguyen (8):
  usb: dwc2: Update the gadget driver to use common dwc2_hsotg structure
  usb: dwc2: Move gadget probe function into platform code
  usb: dwc2: convert to use dev_pm_ops API
  usb: dwc2: Initialize the USB core for peripheral mode
  usb: dwc2: Update common interrupt handler to call gadget interrupt
handler
  usb: dwc2: gadget: Do not fail probe if there isn't a clock node
  usb: dwc2: move usb_disabled() call to host driver only
  usb: dwc2: Update Kconfig to support dual-role

 drivers/usb/dwc2/Kconfig |  66 ++-
 drivers/usb/dwc2/Makefile|  32 ++---
 drivers/usb/dwc2/core.c  |  10 --
 drivers/usb/dwc2/core.h  | 192 ++
 drivers/usb/dwc2/core_intr.c |   8 +-
 drivers/usb/dwc2/gadget.c| 274 ++-
 drivers/usb/dwc2/hcd.c   |   6 +-
 drivers/usb/dwc2/hcd.h   |  10 --
 drivers/usb/dwc2/pci.c   |   7 ++
 drivers/usb/dwc2/platform.c  |  42 ++-
 10 files changed, 317 insertions(+), 330 deletions(-)

-- 
2.0.3

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


Re: xHCI bug

2014-11-11 Thread Mathias Nyman
On 10.11.2014 17:24, Felipe Balbi wrote:
> Hi,
> 
> On Fri, Nov 07, 2014 at 03:40:01PM +0200, Mathias Nyman wrote:
>> On 07.11.2014 00:25, Felipe Balbi wrote:
>>> On Thu, Nov 06, 2014 at 10:36:30AM -0600, Felipe Balbi wrote:
 On Thu, Nov 06, 2014 at 06:31:20PM +0200, Mathias Nyman wrote:
> On 05.11.2014 21:28, Felipe Balbi wrote:
>> Hi,
>>
>> On Tue, Oct 14, 2014 at 04:34:00PM +0300, Mathias Nyman wrote:
>> Could you try with xhci debugging enabled? (will probably produce a
>> lot of output)
>>
>> echo -n 'module xhci_hcd =p' > 
>> /sys/kernel/debug/dynamic_debug/control
>
> I'll try, sure.

 I used tracing otherwise the problem wouldn't show up. Attached you can
 find output:

 0b7e070de7b65de9f70805f4639b3e58  xhci-timeout-testusb.txt.gz

>>>
>>> Thanks, looks like we end up calling cleanup_halted_endpoint()  a lot.
>>> This will (try to) reset the endpoint and move to handle the next TD 
>>> (URB).
>>>
>>> This is called when we're processing contorl transfers and something 
>>> out of the ordinary happends (returned STALL, BABBLE, and some other 
>>> reasons)
>>>
>>> I need to dig a bit deeper to know what actually is going on. 
>>
>> any news here ? It's been almost a month.
>>
>
> While looking at this and other bugs I found races between reset 
> endpoint, reset device, and set dequeue pointer commands. 
> I suspect the loop in your logs is due to starting the endpoint ring too 
> early after reset. It restarts before we move
> past the problematic TD, and start executing it again.
>
> The logs don't show why the TD fails in the first place, but I got 
> another patch fixing other race issues which might help.
>
> Both patches are now in a "reset-rework" topic branch at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/mnyman/xhci.git reset-rework
>
> Its based on 3.18-rc2.
> I haven't still got or set up a usb device with gadget zero to test it 
> out myself

 I'll try to run it today or tomorrow.
>>>
>>> seems to be working so far. It has been running for at least a couple
>>> hours. I'll leave it running until Monday or Tuesday before giving you a
>>> Tested-by, though.
>>>
>>
>> Thanks, much appreciated. 
>> Sounds promising so far, hope it lasts over the weekend
> 
> Alright, it has been running for almost 4 days and failures so far:
> 
> [1]+ ./test.sh &
> # uptime 
>  15:20:15 up 3 days, 20:08,  1 user,  load average: 1.63, 1.84, 1.86
> 
> So, for both commits on reset-rework (see below), you can have my:
> 
> Tested-by: Felipe Balbi 
> 

Thanks alot, this is good news. 

-Mathias

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


[net-next PATCH v2 1/5] net: Add device Rx page allocation function

2014-11-11 Thread Alexander Duyck
This patch implements __dev_alloc_pages and __dev_alloc_page.  These are
meant to replace the __skb_alloc_pages and __skb_alloc_page functions.  The
reason for doing this is that it occurred to me that __skb_alloc_page is
supposed to be passed an sk_buff pointer, but it is NULL in all cases where
it is used.  Worse is that in the case of ixgbe it is passed NULL via the
sk_buff pointer in the rx_buffer info structure which means the compiler is
not correctly stripping it out.

The naming for these functions is based on dev_alloc_skb and __dev_alloc_skb.
There was originally a netdev_alloc_page, however that was passed a
net_device pointer and this function is not so I thought it best to follow
that naming scheme since that is the same difference between dev_alloc_skb
and netdev_alloc_skb.

In the case of anything greater than order 0 it is assumed that we want a
compound page so __GFP_COMP is set for all allocations as we expect a
compound page when assigning a page frag.

The other change in this patch is to exploit the behaviors of the page
allocator in how it handles flags.  So for example we can always set
__GFP_COMP and __GFP_MEMALLOC since they are ignored if they are not
applicable or are overridden by another flag.

Signed-off-by: Alexander Duyck 
---
 include/linux/skbuff.h |   48 
 1 file changed, 48 insertions(+)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 103fbe8..2e5221f 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2185,6 +2185,54 @@ static inline struct sk_buff 
*netdev_alloc_skb_ip_align(struct net_device *dev,
 }
 
 /**
+ * __dev_alloc_pages - allocate page for network Rx
+ * @gfp_mask: allocation priority. Set __GFP_NOMEMALLOC if not for network Rx
+ * @order: size of the allocation
+ *
+ * Allocate a new page.
+ *
+ * %NULL is returned if there is no free memory.
+*/
+static inline struct page *__dev_alloc_pages(gfp_t gfp_mask,
+unsigned int order)
+{
+   /* This piece of code contains several assumptions.
+* 1.  This is for device Rx, therefor a cold page is preferred.
+* 2.  The expectation is the user wants a compound page.
+* 3.  If requesting a order 0 page it will not be compound
+* due to the check to see if order has a value in prep_new_page
+* 4.  __GFP_MEMALLOC is ignored if __GFP_NOMEMALLOC is set due to
+* code in gfp_to_alloc_flags that should be enforcing this.
+*/
+   gfp_mask |= __GFP_COLD | __GFP_COMP | __GFP_MEMALLOC;
+
+   return alloc_pages_node(NUMA_NO_NODE, gfp_mask, order);
+}
+
+static inline struct page *dev_alloc_pages(unsigned int order)
+{
+   return __dev_alloc_pages(GFP_ATOMIC, order);
+}
+
+/**
+ * __dev_alloc_page - allocate a page for network Rx
+ * @gfp_mask: allocation priority. Set __GFP_NOMEMALLOC if not for network Rx
+ *
+ * Allocate a new page.
+ *
+ * %NULL is returned if there is no free memory.
+ */
+static inline struct page *__dev_alloc_page(gfp_t gfp_mask)
+{
+   return __dev_alloc_pages(gfp_mask, 0);
+}
+
+static inline struct page *dev_alloc_page(void)
+{
+   return __dev_alloc_page(GFP_ATOMIC);
+}
+
+/**
  * __skb_alloc_pages - allocate pages for ps-rx on a skb and preserve 
pfmemalloc data
  * @gfp_mask: alloc_pages_node mask. Set __GFP_NOMEMALLOC if not for 
network packet RX
  * @skb: skb to set pfmemalloc on if __GFP_MEMALLOC is used

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


[net-next PATCH v2 3/5] phonet: Replace calls to __skb_alloc_page with __netdev_alloc_page

2014-11-11 Thread Alexander Duyck
Replace the calls to __skb_alloc_page that are passed NULL with calls to
__netdev_alloc_page.

In addition remove __GFP_COLD flag from allocations as we only want it for
the Rx buffer which is taken care of by __dev_alloc_skb, not for any
secondary allocations such as the queue element transmit descriptors.

Cc: Oliver Neukum 
Cc: Felipe Balbi 
Signed-off-by: Alexander Duyck 
---
 drivers/net/usb/cdc-phonet.c   |6 +++---
 drivers/usb/gadget/function/f_phonet.c |6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/usb/cdc-phonet.c b/drivers/net/usb/cdc-phonet.c
index 2ec1500..415ce8b 100644
--- a/drivers/net/usb/cdc-phonet.c
+++ b/drivers/net/usb/cdc-phonet.c
@@ -130,7 +130,7 @@ static int rx_submit(struct usbpn_dev *pnd, struct urb 
*req, gfp_t gfp_flags)
struct page *page;
int err;
 
-   page = __skb_alloc_page(gfp_flags | __GFP_NOMEMALLOC, NULL);
+   page = __dev_alloc_page(gfp_flags | __GFP_NOMEMALLOC);
if (!page)
return -ENOMEM;
 
@@ -212,7 +212,7 @@ resubmit:
if (page)
put_page(page);
if (req)
-   rx_submit(pnd, req, GFP_ATOMIC | __GFP_COLD);
+   rx_submit(pnd, req, GFP_ATOMIC);
 }
 
 static int usbpn_close(struct net_device *dev);
@@ -231,7 +231,7 @@ static int usbpn_open(struct net_device *dev)
for (i = 0; i < rxq_size; i++) {
struct urb *req = usb_alloc_urb(0, GFP_KERNEL);
 
-   if (!req || rx_submit(pnd, req, GFP_KERNEL | __GFP_COLD)) {
+   if (!req || rx_submit(pnd, req, GFP_KERNEL)) {
usb_free_urb(req);
usbpn_close(dev);
return -ENOMEM;
diff --git a/drivers/usb/gadget/function/f_phonet.c 
b/drivers/usb/gadget/function/f_phonet.c
index b9cfc15..cde7397 100644
--- a/drivers/usb/gadget/function/f_phonet.c
+++ b/drivers/usb/gadget/function/f_phonet.c
@@ -303,7 +303,7 @@ pn_rx_submit(struct f_phonet *fp, struct usb_request *req, 
gfp_t gfp_flags)
struct page *page;
int err;
 
-   page = __skb_alloc_page(gfp_flags | __GFP_NOMEMALLOC, NULL);
+   page = __dev_alloc_page(gfp_flags | __GFP_NOMEMALLOC);
if (!page)
return -ENOMEM;
 
@@ -377,7 +377,7 @@ static void pn_rx_complete(struct usb_ep *ep, struct 
usb_request *req)
if (page)
put_page(page);
if (req)
-   pn_rx_submit(fp, req, GFP_ATOMIC | __GFP_COLD);
+   pn_rx_submit(fp, req, GFP_ATOMIC);
 }
 
 /*-*/
@@ -437,7 +437,7 @@ static int pn_set_alt(struct usb_function *f, unsigned 
intf, unsigned alt)
 
netif_carrier_on(dev);
for (i = 0; i < phonet_rxq_size; i++)
-   pn_rx_submit(fp, fp->out_reqv[i], GFP_ATOMIC | 
__GFP_COLD);
+   pn_rx_submit(fp, fp->out_reqv[i], GFP_ATOMIC);
}
spin_unlock(&port->lock);
return 0;

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


[net-next PATCH v2 0/5] Replace __skb_alloc_pages with simpler function

2014-11-11 Thread Alexander Duyck
This patch series replaces __skb_alloc_pages with a much simpler function,
__dev_alloc_pages.  The main difference between the two is that
__skb_alloc_pages had an sk_buff pointer that was being passed as NULL in
call places where it was called.  In a couple of cases the NULL was passed
by variable and this led to unnecessary code being run.

As such in order to simplify things the __dev_alloc_pages call only takes a
mask and the page order being requested.  In addition it takes advantage of
several behaviors already built into the page allocator so that it can just
set GFP flags unconditionally.

v2: Renamed functions to dev_alloc_page(s) instead of netdev_alloc_page(s)
Removed __GFP_COLD flag from usb code as it was redundant

---

Alexander Duyck (5):
  net: Add device Rx page allocation function
  cxgb4/cxgb4vf: Replace __skb_alloc_page with __netdev_alloc_page
  phonet: Replace calls to __skb_alloc_page with __netdev_alloc_page
  fm10k/igb/ixgbe: Replace __skb_alloc_page with netdev_alloc_page
  net: Remove __skb_alloc_page and __skb_alloc_pages


 drivers/net/ethernet/chelsio/cxgb4/sge.c  |6 +-
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c|7 ++-
 drivers/net/ethernet/intel/fm10k/fm10k_main.c |2 -
 drivers/net/ethernet/intel/igb/igb_main.c |2 -
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |3 -
 drivers/net/usb/cdc-phonet.c  |6 +-
 drivers/usb/gadget/function/f_phonet.c|6 +-
 include/linux/skbuff.h|   61 ++---
 8 files changed, 49 insertions(+), 44 deletions(-)

--
--
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 for 3.18-rc4 to add OLIMEX ISP500 AVR Programmer

2014-11-11 Thread Sid Boyce

Results
---
root@sdrbox:~# lsusb
Bus 002 Device 004: ID 13fd:1840 Initio Corporation INIC-1608 SATA bridge
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 003: ID 15ba:000c Olimex Ltd.

The failure due to AtMega32 not attached.
root@sdrbox:~# avrdude -p m32 -F -c stk500v2 -P /dev/ttyACM1

avrdude: stk500v2_command(): warning: Command timed out
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0xc807c6
avrdude: Expected signature for ATmega32 is 1E 95 02

avrdude done.  Thank you.
Regards ... Sid.

--
Sid Boyce ... Hamradio License G3VBV, Licensed Private Pilot
Emeritus IBM/Amdahl Mainframes and Sun/Fujitsu Servers Tech Support
Senior Staff Specialist, Cricket Coach
Microsoft Windows Free Zone - Linux used for all Computing Tasks


This patch adds support for the OLIMEX ISP500 AVR Programmer to kernel 3.18-rc4.
Signed off by: Sid Boyce (sbo...@blueyonder.co.uk)
Tested by: Sid Boyce (sbo...@blueyonder.co.uk)

diff --git a/a/drivers/usb/serial/ftdi_sio.c b/b/drivers/usb/serial/ftdi_sio.c
index 0dad8ce..7a471e8 100644
--- a/a/drivers/usb/serial/ftdi_sio.c
+++ b/b/drivers/usb/serial/ftdi_sio.c
@@ -770,6 +770,7 @@ static const struct usb_device_id id_table_combined[] = {
 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
 	{ USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_H_PID),
 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
+	{ USB_DEVICE(OLIMEX_VID, OLIMEX_AVR_ISP500_ISO_PID) },
 	{ USB_DEVICE(FIC_VID, FIC_NEO1973_DEBUG_PID),
 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
 	{ USB_DEVICE(FTDI_VID, FTDI_OOCDLINK_PID),
diff --git a/a/drivers/usb/serial/ftdi_sio_ids.h b/b/drivers/usb/serial/ftdi_sio_ids.h
index 6786b70..78bfc30 100644
--- a/a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/b/drivers/usb/serial/ftdi_sio_ids.h
@@ -838,6 +838,7 @@
 /* Olimex */
 #define OLIMEX_VID			0x15BA
 #define OLIMEX_ARM_USB_OCD_PID		0x0003
+#define OLIMEX_AVR_ISP500_ISO_PID0x000B
 #define OLIMEX_ARM_USB_OCD_H_PID	0x002b
 
 /*



Re: btusb_intr_complete returns -EPIPE

2014-11-11 Thread Alan Stern
On Tue, 11 Nov 2014, Naveen Kumar Parna wrote:

> I am really glad we reached to a conclusion on this.
> Thanks for all your help, without which I could not have seen this through.

You're welcome.

> Now I am confronted with many of these controllers in my lab, with
> this hardware issue.
> I am not sure I can find a better way than just to tell people to replace 
> them.

You could try contacting the manufacturer to see if they are aware of 
this problem and have any suggestions.

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: [V2 PATCH 01/10] added media agnostic (MA) USB HCD driver

2014-11-11 Thread Alan Stern
On Mon, 10 Nov 2014, Stephanie Wallick wrote:

> +static struct mausb_hcd mhcd;

Only one statically-allocated structure?  What if somebody wants to 
have more than one of these things in their system?

> +/**
> + * @maurb:   Media agnostic structure with URB to release.
> + * @status:  Status for URB that is getting released.
> + *
> + * Removes an URB from the queue, deletes the media agnostic information in
> + * the urb, and gives the URB back to the HCD. Caller must be holding the
> + * driver's spinlock.
> + */
> +void mausb_unlink_giveback_urb(struct mausb_urb *maurb, int status)
> +{
> + struct urb  *urb;
> + struct usb_hcd  *hcd;
> + struct api_context  *ctx = NULL;
> + unsigned long   irq_flags;
> +
> + hcd = mausb_hcd_to_usb_hcd(&mhcd);
> +
> + spin_lock_irqsave(&mhcd.giveback_lock, irq_flags);

Why do you need multiple spinlocks?  Isn't one lock sufficient?

> + if (!maurb) {
> + mausb_err(&mhcd, "%s: no maurb\n", __func__);
> + spin_unlock_irqrestore(&mhcd.giveback_lock, irq_flags);
> + return;
> + } else {
> + urb = maurb->urb;
> + ctx = urb->context;
> + }
> +
> + if (!urb) {
> + mausb_err(&mhcd, "%s: no urb\n", __func__);
> + mausb_internal_drop_maurb(maurb, &mhcd);
> + spin_unlock_irqrestore(&mhcd.giveback_lock, irq_flags);
> + return;
> + }
> +
> + mausb_dbg(&mhcd, "%s: returning urb with status %i\n", __func__, 
> status);
> +
> + usb_hcd_unlink_urb_from_ep(hcd, urb);
> + usb_hcd_giveback_urb(hcd, urb, status);

You must not call this function while holding any spinlocks.  What happens
if the URB's completion routine tries to resubmit?

> +
> + /* remove the mausb-specific data */
> + mausb_internal_drop_maurb(maurb, &mhcd);
> +
> + spin_unlock_irqrestore(&mhcd.giveback_lock, irq_flags);
> +}
> +
> +/**
> + * Adds an URB to the endpoint queue then calls the URB handler. URB is 
> wrapped
> + * in media agnostic structure before being enqueued.
> + */
> +static int mausb_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
> + gfp_t memflags)
> +{
> + int ret = 0;
> + struct mausb_urb*maurb;
> + struct mausb_host_ep*ep;
> + unsigned long   irq_flags;
> +
> + if (!hcd || !urb) {
> + pr_err("%s: no %s\n", __func__, (hcd ? "urb" : "USB hcd"));
> + }

This can never happen.  The USB core guarantees it; you don't need 
to check.

> + ep   = usb_to_ma_endpoint(urb->ep);
> +
> + if (!ep) {
> + mausb_err(&mhcd, "%s: no endpoint\n", __func__);
> + return -EINVAL;
> + }
> +
> + if (urb->status != -EINPROGRESS) {
> + mausb_err(&mhcd, "%s: urb already unlinked, status is %i\n",
> + __func__, urb->status);
> + return urb->status;
> + }

You also don't need to check this.

> + /* If the endpoint isn't activated, we can't enqueue anything. */
> + if (MAUSB_EP_HANDLE_UNASSIGNED == ep->ep_handle_state) {
> + mausb_err(&mhcd, "%s: endpoint handle unassigned\n", __func__);
> + return -EPIPE;
> + }
> +
> + if (USB_SPEED_FULL != urb->dev->speed) /* suppress checks */
> + ep->max_pkt = usb_endpoint_maxp(&urb->ep->desc);

What happens to full-speed devices?  Don't they have maxpacket values?

> +
> + /* initialize the maurb */
> + maurb = mausb_alloc_maurb(ep, memflags);
> + if (!maurb) {
> + mausb_err(&mhcd, "could not allocate memory for MA USB urb\n");
> + return -ENOMEM;
> + }
> +
> + /* set maurb member values */
> + maurb->urb = urb;
> + urb->hcpriv = maurb;
> +
> + /* submit urb to hcd and add to endpoint queue */
> + ret = usb_hcd_link_urb_to_ep(hcd, urb);

Read the kerneldoc for this function.  You must hold your private
spinlock when you call it.

> + if (ret < 0) {
> + mausb_err(&mhcd, "urb enqueue failed: error %d\n", ret);
> + usb_hcd_unlink_urb_from_ep(hcd, urb);
> + return ret;
> + }
> +
> + /* get usb device and increment reference counter */
> + if (!mhcd.udev) {
> + mhcd.udev = urb->dev;
> + usb_get_dev(mhcd.udev);
> + }

What happens if more than one device is in use at a time?

> +
> + /* add urb to queue list */
> + spin_lock_irqsave(&ep->ep_lock, irq_flags);
> + list_add_tail(&maurb->urb_list, &ep->urb_list);
> + spin_unlock_irqrestore(&ep->ep_lock, irq_flags);

Yet another class of spinlocks!

> + /* add urb to ma hcd urb list */
> + spin_lock_irqsave(&mhcd.urb_list_lock, irq_flags);

And another!  You really shouldn't need more than one lock.

> + list_add_tail(&maurb->ma_hcd_urb_list, &mhcd.enqueue_urb_list);
> + spin_unlock_irqrestore(&mhcd.urb_list_lock, irq_flags);
> +
> + /* send to MA

Re: [PATCHv2] phy: omap-usb2: Enable runtime PM of omap-usb2 phy properly

2014-11-11 Thread Enric Balletbo Serra
Hi all,

2014-11-04 0:29 GMT+01:00 Greg KH :
> On Mon, Nov 03, 2014 at 04:51:41PM +0530, Kishon Vijay Abraham I wrote:
>> Hi Greg,
>>
>> On Tuesday 07 October 2014 04:32 PM, Oussama Ghorbel wrote:
>> > The USB OTG port does not work since v3.16 on omap platform.
>> > This is a regression introduced by the commit
>> > eb82a3d846fa (phy: omap-usb2: Balance pm_runtime_enable() on probe failure
>> >  and remove).
>> > This because the call to pm_runtime_enable() function is moved after the
>> > call to devm_phy_create() function, which has side effect since later in
>> > the subsequent calls of devm_phy_create() there is a check with
>> > pm_runtime_enabled() to configure few things.
>>
>> This is the only fix for this -rc cycle in the PHY susbsystem. So can you 
>> take
>> this directly? Or else I can prepare a pull request. Let me know.
>>
>> Acked-by: Kishon Vijay Abraham I 
>
> I don't have this in my archives anymore, please resend so that I can
> apply it from an email.
>
> thanks,
>
> greg k-h

I'm trying to use the OTG port as HOST on OMAP3-based platform
(IGEPv2), I saw that this patch is already applied in kernel
3.18.0-rc4 so I expected it to work, but I've some problems. To
explain the situation let me propose some test cases.

The first tests I made were configuring the MUSB OTG as HOST only
mode,In this mode test case A fails and test case B and C succeed.

USB Mode Selection (HOST only mode)
Test case A) Boot the system :
mode : b_idle
vbus : Vbus off, timeout 1100 msec
1) Ground ID-pin
mode : a_idle
vbus : Vbus off, timeout 1100 msec
2) Plug pendrive
mode : a_idle
vbus : Vbus off, timeout 1100 msec
Failed: Pendrive is not detected.

Test case B) Boot with ID-pin grounded :
mode : a_idle
vbus : Vbus off, timeout 1100 msec
1) Plug pendrive
mode : a_host
vbus : Vbus off, timeout 1100 msec
Success: Pendrive is detected

Test case C) Boot with ID-pin grounded and pendrive
mode : a_host
vbus : Vbus off, timeout 1100 msec
Success: Pendrive is detected

The second tests I made were configuring the MUSB OTG as Dual Role
mode,In this mode all test cases failed.

MUSB Mode Selection (Dual Role mode)
Test case A) Boot the system :
mode : b_idle
vbus : Vbus off, timeout 1100 msec
1) Ground ID-pin:
mode : a_idle
mode : Vbus off, timeout 1100 msec
2) Plug pendrive
mode : a_idle
vbus : Vbus off, timeout 1100 msec
Failed: Pendrive is not detected.

Test case B) Boot with ID-pin grounded :
mode : b_idle
vbus : Vbus off, timeout 1100 msec
1) Plug pendrive
mode : b_idle
vbus : Vbus off, timeout 1100 msec
Failed: Pendrive is not detected.

Test case C) Boot with ID-pin grounded and pendrive
mode : b_idle
vbus : Vbus off, timeout 1100 msec
Failed: Pendrive is not detected.

I got the mode and vbus values from sysfs:

cat /sys/bus/platform/drivers/musb-hdrc/musb-hdrc.0.auto/mode
cat /sys/bus/platform/drivers/musb-hdrc/musb-hdrc.0.auto/vbus

Did anybody test these test cases ?

I'm a bit surprised with the vbus status because always reports Vbus
off, although pendrive is working. I'm missing something ?

Note that if you see at the mode transitions something looks wrong.
For example, in Dual Role Mode test case B and C the mode is b_idle
instead of a_idle.

Thanks,
   Enric
--
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: phy: fix twl4030 build regression

2014-11-11 Thread Felipe Balbi
On Tue, Nov 11, 2014 at 10:36:09AM +0100, Arnd Bergmann wrote:
> Recent changes to the common OTG handling broke building the twl4030
> OTG driver as found during an allmodconfig build of linux-next:
> 
> drivers/phy/phy-twl4030-usb.c: In function 'twl4030_set_peripheral':
> drivers/phy/phy-twl4030-usb.c:609:11: error: 'struct phy' has no member named 
> 'state'
> drivers/phy/phy-twl4030-usb.c: In function 'twl4030_usb_probe':
> drivers/phy/phy-twl4030-usb.c:679:12: warning: assignment from incompatible 
> pointer type
> 
> This applies the same changes that were done to the other phy drivers
> to get it to build cleanly.
> 
> Signed-off-by: Arnd Bergmann 
> Fixes: 19c1eac2685b6 ("usb: rename phy to usb_phy in OTG")
> Fixes: e47d92545c297 ("usb: move the OTG state from the USB PHY to the OTG 
> structure")

on my testing/next already:

commit 7e1bbeb4292783dcc079156b8fa08d66d17219e0
Author: Felipe Balbi 
Date:   Fri Nov 7 19:43:45 2014 -0600

usb: host: ohci: omap: fix build breakage

commit e47d925 (usb: move the OTG state
from the USB PHY to the OTG structure) moved
the OTG state field from struct usb_phy to
struct usb_otg but, even though I fixed many
other build breakages, I still missed one
on ohci-omap.c.

Fix the build breakage now.

drivers/usb/host/ohci-omap.c: In function ‘start_hnp’:
drivers/usb/host/ohci-omap.c:186:19: error: request for member ‘state’ in 
something not a structure or union
  hcd->usb_phy->otg.state = OTG_STATE_A_SUSPEND;

Signed-off-by: Felipe Balbi 

diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index cf89b4b1..3e5df5a 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -183,7 +183,7 @@ static void start_hnp(struct ohci_hcd *ohci)
otg_start_hnp(hcd->usb_phy->otg);
 
local_irq_save(flags);
-   hcd->usb_phy->otg.state = OTG_STATE_A_SUSPEND;
+   hcd->usb_phy->otg->state = OTG_STATE_A_SUSPEND;
writel (RH_PS_PSS, &ohci->regs->roothub.portstatus [port]);
l = omap_readl(OTG_CTRL);
l &= ~OTG_A_BUSREQ;

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: phy: fix twl4030 build regression

2014-11-11 Thread Felipe Balbi
On Tue, Nov 11, 2014 at 08:52:17AM -0600, Felipe Balbi wrote:
> On Tue, Nov 11, 2014 at 10:36:09AM +0100, Arnd Bergmann wrote:
> > Recent changes to the common OTG handling broke building the twl4030
> > OTG driver as found during an allmodconfig build of linux-next:
> > 
> > drivers/phy/phy-twl4030-usb.c: In function 'twl4030_set_peripheral':
> > drivers/phy/phy-twl4030-usb.c:609:11: error: 'struct phy' has no member 
> > named 'state'
> > drivers/phy/phy-twl4030-usb.c: In function 'twl4030_usb_probe':
> > drivers/phy/phy-twl4030-usb.c:679:12: warning: assignment from incompatible 
> > pointer type
> > 
> > This applies the same changes that were done to the other phy drivers
> > to get it to build cleanly.
> > 
> > Signed-off-by: Arnd Bergmann 
> > Fixes: 19c1eac2685b6 ("usb: rename phy to usb_phy in OTG")
> > Fixes: e47d92545c297 ("usb: move the OTG state from the USB PHY to the OTG 
> > structure")
> 
> on my testing/next already:
> 
> commit 7e1bbeb4292783dcc079156b8fa08d66d17219e0
> Author: Felipe Balbi 
> Date:   Fri Nov 7 19:43:45 2014 -0600
> 
> usb: host: ohci: omap: fix build breakage

wrong commit, here's the correct one:

commit 8b9ca2767b2d1ea405287e530da3a7b234120b95
Author: Felipe Balbi 
Date:   Fri Nov 7 09:06:04 2014 -0600

phy: twl4030: Fix build breakage

commit e47d925 (usb: move the OTG state
from the USB PHY to the OTG structure) moved
the OTG state field from struct usb_phy to
struct usb_otg but, even though I fixed many
other build breakages, I still missed one
on phy-twl4030-usb.c.

Fix the build breakage now.

While at that, also a build warning introduced
by the same commit.

Cc: Kishon Vijay Abraham I 
Cc: Antoine Tenart 
Signed-off-by: Felipe Balbi 

diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index 7b04bef..e2698d29 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -606,7 +606,7 @@ static int twl4030_set_peripheral(struct usb_otg *otg,
 
otg->gadget = gadget;
if (!gadget)
-   otg->phy->state = OTG_STATE_UNDEFINED;
+   otg->state = OTG_STATE_UNDEFINED;
 
return 0;
 }
@@ -618,7 +618,7 @@ static int twl4030_set_host(struct usb_otg *otg, struct 
usb_bus *host)
 
otg->host = host;
if (!host)
-   otg->phy->state = OTG_STATE_UNDEFINED;
+   otg->state = OTG_STATE_UNDEFINED;
 
return 0;
 }
@@ -676,7 +676,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
twl->phy.otg= otg;
twl->phy.type   = USB_PHY_TYPE_USB2;
 
-   otg->phy= &twl->phy;
+   otg->usb_phy= &twl->phy;
otg->set_host   = twl4030_set_host;
otg->set_peripheral = twl4030_set_peripheral;
 

-- 
balbi


signature.asc
Description: Digital signature


Two questions about dwc2 driver

2014-11-11 Thread Haibo Zhang
Hello,

We know that dwc2 is the USB2.0 driver for DesignWare IP. But it only
has host’s code
without device’s code. So I have two questions:
1.   Will I develop or port the part of device’s code if I want to
use dwc2 to support both
host and device’s functions?
2.   Another question, I know that many chip companies use dwc2.
How do they solve the
question above?

If anyone has a similar experience or know well about this dwc2
driver, please reply me.
Any help will be greatly appreciated.

Thanks,

-- 


*Zhang Haibo*
--
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


[no subject]

2014-11-11 Thread Haibo Zhang
Hello,

We know that dwc2 is the USB2.0 driver for DesignWare IP. But it only
has host’s code
without device’s code. So I have two questions:
1.   Will I develop or port the part of device’s code if I want to
use dwc2 to support both
host and device’s functions?
2.   Another question, I know that many chip companies use dwc2.
How do they solve the
question above?

If anyone has a similar experience or know well about this dwc2
driver, please reply me.
Any help will be greatly appreciated.

Thanks,

-- 


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


Re: [PATCH -next 1/2] seq_puts: Convert to return void and convert uses too.

2014-11-11 Thread Petr Mladek
On Mon 2014-11-10 10:58:56, Joe Perches wrote:
> diff --git a/ipc/util.c b/ipc/util.c
> index 106bed0..4f726b7 100644
> --- a/ipc/util.c
> +++ b/ipc/util.c
> @@ -837,8 +837,10 @@ static int sysvipc_proc_show(struct seq_file *s, void 
> *it)
>   struct ipc_proc_iter *iter = s->private;
>   struct ipc_proc_iface *iface = iter->iface;
>  
> - if (it == SEQ_START_TOKEN)
> - return seq_puts(s, iface->header);
> + if (it == SEQ_START_TOKEN) {
> + seq_puts(s, iface->header);
> + return seq_has_overflowed(s);

It should return 0. The overflow is detected by traverse() that is
called from seq_read(). If the overflow happens, the size of the
buffer is increased and show() is called again.

> + }
>  
>   return iface->show(s, it);

This should stay as is. It seems that the show() function might also
return negative value in case of some other failure. See the error
handling of "error = m->op->show(m, p);" in traverse() in fs/seq_file.c


The rest of the patch looks fine.

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


Re: [PATCH 1/1] x86: Surface Pro 3 Type Cover 3

2014-11-11 Thread Jiri Kosina
On Mon, 3 Nov 2014, Alan Wu wrote:

> Surface Pro 3 Type Cover that works with Ubuntu (and possibly Arch) from this 
> thread. Both trackpad and keyboard work after compiling my own kernel.
> http://ubuntuforums.org/showthread.php?t=2231207&page=2&s=44910e0c56047e4f93dfd9fea58121ef
> 
> Also includes Jarrad Whitaker's message which sources
> http://winaero.com/blog/how-to-install-linux-on-surface-pro-3/
> which he says is sourced from a Russian site
> 
> Signed-off-by: Alan Wu 

Applied, thanks.

-- 
Jiri Kosina
SUSE Labs
--
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: btusb_intr_complete returns -EPIPE

2014-11-11 Thread Naveen Kumar Parna
On Mon, Nov 10, 2014 at 10:26 PM, Alan Stern  wrote:
> On Mon, 10 Nov 2014, Naveen Kumar Parna wrote:
>
>> I am sorry for the late response.
>>
>> I applied the patch and here is the dmesg log:
>>
>> [  713.125709] ehci-pci :00:1a.0: split intr info2 42821c01 token
>> 80108d46 overlay token 80108d46
>> [  713.125796] ehci-pci :00:1a.0: split intr info2 42821c01 token
>> 80108d46 overlay token 80108d46
>> [  713.125853] hci4 urb 8800b89a7c00 status -32 count 0
>> [  713.125857] hci3 urb 8800b7399c00 status -32 count 0
>
>> Does it gives the reason for -32 status code?
>
> More or less.  The last (status) byte in the "token" values is 0x46,
> and the 0x04 status bit is documented in the EHCI spec as follows:
>
> Missed Micro-Frame. This bit is ignored unless the QH.EPS field
> indicates a full- or low-speed endpoint and the queue head is
> in the periodic list. This bit is set when the host controller
> detected that a host-induced hold-off caused the host
> controller to miss a required complete-split transaction. If the
> host controller sets this bit to a one, then it remains a one
> for the duration of thetransfer.
>
> This means the host controller is telling you it was unable to carry
> out the CSPLIT part of the transaction, which means it really is a
> hardware problem (and not a bad memory chip).  Either the controller
> isn't working right or else your system is somehow overloaded.
>
> The 0x42 bits indicate that the Queue Head was halted and a CSPLIT is
> pending (which we already knew).  The "halted" status bit is the reason
> why you got a -32 status code.
>
> Alan Stern
>

I am really glad we reached to a conclusion on this.
Thanks for all your help, without which I could not have seen this through.

Now I am confronted with many of these controllers in my lab, with
this hardware issue.
I am not sure I can find a better way than just to tell people to replace them.

Thanks,
Naveen
--
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: fix twl4030 build regression

2014-11-11 Thread Arnd Bergmann
Recent changes to the common OTG handling broke building the twl4030
OTG driver as found during an allmodconfig build of linux-next:

drivers/phy/phy-twl4030-usb.c: In function 'twl4030_set_peripheral':
drivers/phy/phy-twl4030-usb.c:609:11: error: 'struct phy' has no member named 
'state'
drivers/phy/phy-twl4030-usb.c: In function 'twl4030_usb_probe':
drivers/phy/phy-twl4030-usb.c:679:12: warning: assignment from incompatible 
pointer type

This applies the same changes that were done to the other phy drivers
to get it to build cleanly.

Signed-off-by: Arnd Bergmann 
Fixes: 19c1eac2685b6 ("usb: rename phy to usb_phy in OTG")
Fixes: e47d92545c297 ("usb: move the OTG state from the USB PHY to the OTG 
structure")
---

I have no idea if this is the correct fix, this is just a mechanical
conversion, so please review carefully.

diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index 7b04befd5271..e2698d29f436 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -606,7 +606,7 @@ static int twl4030_set_peripheral(struct usb_otg *otg,
 
otg->gadget = gadget;
if (!gadget)
-   otg->phy->state = OTG_STATE_UNDEFINED;
+   otg->state = OTG_STATE_UNDEFINED;
 
return 0;
 }
@@ -618,7 +618,7 @@ static int twl4030_set_host(struct usb_otg *otg, struct 
usb_bus *host)
 
otg->host = host;
if (!host)
-   otg->phy->state = OTG_STATE_UNDEFINED;
+   otg->state = OTG_STATE_UNDEFINED;
 
return 0;
 }
@@ -676,7 +676,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
twl->phy.otg= otg;
twl->phy.type   = USB_PHY_TYPE_USB2;
 
-   otg->phy= &twl->phy;
+   otg->usb_phy= &twl->phy;
otg->set_host   = twl4030_set_host;
otg->set_peripheral = twl4030_set_peripheral;
 

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


Re: [RFC v5] usb: phy: Hold wakeupsource when USB is enumerated in peripheral mode

2014-11-11 Thread Kishon Vijay Abraham I
Hi Felipe,

On Monday 10 November 2014 08:56 PM, Felipe Balbi wrote:
> Hi,
> 
> On Tue, Nov 04, 2014 at 03:30:54PM +0530, Kiran Kumar Raparthy wrote:
>> @@ -1469,6 +1484,7 @@ static int ab8500_usb_probe(struct platform_device 
>> *pdev)
>>  
>>  abx500_usb_link_status_update(ab);
>>  
>> +usb_phy_wsource_init(&ab->phy);
> 
> instead of adding this to all drivers, you can just it to
> usb_add_phy_dev() and conversely, to usb_remove_phy().

'usb_phy_wsource_init' seems specific to usb and when these drivers are adapted
to the generic PHY framework we can't add it to phy_create.

Should it be added in extcon instead?

Thanks
Kishon
--
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: [PATCHv4 2/6] phy: improved lookup method

2014-11-11 Thread Vivek Gautam
Hi Kishon,


On Tue, Nov 11, 2014 at 2:20 PM, Kishon Vijay Abraham I  wrote:
> Hi,
>
> On Tuesday 11 November 2014 02:07 PM, Vivek Gautam wrote:
>> On Tue, Nov 11, 2014 at 12:12 PM, Kishon Vijay Abraham I  
>> wrote:
>>> Hi,
>>>
>>> On Friday 31 October 2014 06:03 PM, Vivek Gautam wrote:
 Hi Heikki,


 On Fri, Oct 17, 2014 at 8:09 PM, Heikki Krogerus
  wrote:
> Removes the need for the phys to be aware of their users
> even when not using DT. The method is copied from clkdev.c.
>
> Signed-off-by: Heikki Krogerus 
> Tested-by: Vivek Gautam 
> ---
>  Documentation/phy.txt   |  66 ---
>  drivers/phy/phy-core.c  | 135 
> +++-
>  include/linux/phy/phy.h |  27 ++
>  3 files changed, 183 insertions(+), 45 deletions(-)
>
> diff --git a/Documentation/phy.txt b/Documentation/phy.txt
> index c6594af..8add515 100644
> --- a/Documentation/phy.txt
> +++ b/Documentation/phy.txt
> @@ -54,18 +54,14 @@ The PHY driver should create the PHY in order for 
> other peripheral controllers
>  to make use of it. The PHY framework provides 2 APIs to create the PHY.
>
>  struct phy *phy_create(struct device *dev, struct device_node *node,
> -  const struct phy_ops *ops,
> -  struct phy_init_data *init_data);
> +  const struct phy_ops *ops);
>  struct phy *devm_phy_create(struct device *dev, struct device_node *node,
> -   const struct phy_ops *ops,
> -   struct phy_init_data *init_data);
> +   const struct phy_ops *ops);
>
>  The PHY drivers can use one of the above 2 APIs to create the PHY by 
> passing
> -the device pointer, phy ops and init_data.
> +the device pointer and phy ops.
>  phy_ops is a set of function pointers for performing PHY operations such 
> as
> -init, exit, power_on and power_off. *init_data* is mandatory to get a 
> reference
> -to the PHY in the case of non-dt boot. See section *Board File 
> Initialization*
> -on how init_data should be used.
> +init, exit, power_on and power_off.
>
>  Inorder to dereference the private data (in phy_ops), the phy provider 
> driver
>  can use phy_set_drvdata() after creating the PHY and use 
> phy_get_drvdata() in
> @@ -137,42 +133,24 @@ There are exported APIs like phy_pm_runtime_get, 
> phy_pm_runtime_get_sync,
>  phy_pm_runtime_put, phy_pm_runtime_put_sync, phy_pm_runtime_allow and
>  phy_pm_runtime_forbid for performing PM operations.
>
> -8. Board File Initialization
> -
> -Certain board file initialization is necessary in order to get a 
> reference
> -to the PHY in the case of non-dt boot.
> -Say we have a single device that implements 3 PHYs that of USB, SATA and 
> PCIe,
> -then in the board file the following initialization should be done.
> -
> -struct phy_consumer consumers[] = {
> -   PHY_CONSUMER("dwc3.0", "usb"),
> -   PHY_CONSUMER("pcie.0", "pcie"),
> -   PHY_CONSUMER("sata.0", "sata"),
> -};
> -PHY_CONSUMER takes 2 parameters, first is the device name of the 
> controller
> -(PHY consumer) and second is the port name.
> -
> -struct phy_init_data init_data = {
> -   .consumers = consumers,
> -   .num_consumers = ARRAY_SIZE(consumers),
> -};
> -
> -static const struct platform_device pipe3_phy_dev = {
> -   .name = "pipe3-phy",
> -   .id = -1,
> -   .dev = {
> -   .platform_data = {
> -   .init_data = &init_data,
> -   },
> -   },
> -};
> -
> -then, while doing phy_create, the PHY driver should pass this init_data
> -   phy_create(dev, ops, pdata->init_data);
> -
> -and the controller driver (phy consumer) should pass the port name along 
> with
> -the device to get a reference to the PHY
> -   phy_get(dev, "pcie");
> +8. PHY Mappings
> +
> +In order to get reference to a PHY without help from DeviceTree, the 
> framework
> +offers lookups which can be compared to clkdev that allow clk structures 
> to be
> +bound to devices. A lookup can be made statically by directly registering
> +phy_lookup structure which contains the name of the PHY device, the name 
> of the
> +device which the PHY will be bind to and Connection ID string. 
> Alternatively a
> +lookup can be made during runtime when a handle to the struct phy already
> +exists.
> +
> +The framework offers the following APIs for registering and 
> unregistering the
> +lookups.
> +
> +void phy_register_lookup(struct phy_lookup *pl);
> +int phy_create_lookup(struct 

Re: [PATCHv4 2/6] phy: improved lookup method

2014-11-11 Thread Kishon Vijay Abraham I
Hi,

On Tuesday 11 November 2014 02:07 PM, Vivek Gautam wrote:
> On Tue, Nov 11, 2014 at 12:12 PM, Kishon Vijay Abraham I  
> wrote:
>> Hi,
>>
>> On Friday 31 October 2014 06:03 PM, Vivek Gautam wrote:
>>> Hi Heikki,
>>>
>>>
>>> On Fri, Oct 17, 2014 at 8:09 PM, Heikki Krogerus
>>>  wrote:
 Removes the need for the phys to be aware of their users
 even when not using DT. The method is copied from clkdev.c.

 Signed-off-by: Heikki Krogerus 
 Tested-by: Vivek Gautam 
 ---
  Documentation/phy.txt   |  66 ---
  drivers/phy/phy-core.c  | 135 
 +++-
  include/linux/phy/phy.h |  27 ++
  3 files changed, 183 insertions(+), 45 deletions(-)

 diff --git a/Documentation/phy.txt b/Documentation/phy.txt
 index c6594af..8add515 100644
 --- a/Documentation/phy.txt
 +++ b/Documentation/phy.txt
 @@ -54,18 +54,14 @@ The PHY driver should create the PHY in order for 
 other peripheral controllers
  to make use of it. The PHY framework provides 2 APIs to create the PHY.

  struct phy *phy_create(struct device *dev, struct device_node *node,
 -  const struct phy_ops *ops,
 -  struct phy_init_data *init_data);
 +  const struct phy_ops *ops);
  struct phy *devm_phy_create(struct device *dev, struct device_node *node,
 -   const struct phy_ops *ops,
 -   struct phy_init_data *init_data);
 +   const struct phy_ops *ops);

  The PHY drivers can use one of the above 2 APIs to create the PHY by 
 passing
 -the device pointer, phy ops and init_data.
 +the device pointer and phy ops.
  phy_ops is a set of function pointers for performing PHY operations such 
 as
 -init, exit, power_on and power_off. *init_data* is mandatory to get a 
 reference
 -to the PHY in the case of non-dt boot. See section *Board File 
 Initialization*
 -on how init_data should be used.
 +init, exit, power_on and power_off.

  Inorder to dereference the private data (in phy_ops), the phy provider 
 driver
  can use phy_set_drvdata() after creating the PHY and use 
 phy_get_drvdata() in
 @@ -137,42 +133,24 @@ There are exported APIs like phy_pm_runtime_get, 
 phy_pm_runtime_get_sync,
  phy_pm_runtime_put, phy_pm_runtime_put_sync, phy_pm_runtime_allow and
  phy_pm_runtime_forbid for performing PM operations.

 -8. Board File Initialization
 -
 -Certain board file initialization is necessary in order to get a reference
 -to the PHY in the case of non-dt boot.
 -Say we have a single device that implements 3 PHYs that of USB, SATA and 
 PCIe,
 -then in the board file the following initialization should be done.
 -
 -struct phy_consumer consumers[] = {
 -   PHY_CONSUMER("dwc3.0", "usb"),
 -   PHY_CONSUMER("pcie.0", "pcie"),
 -   PHY_CONSUMER("sata.0", "sata"),
 -};
 -PHY_CONSUMER takes 2 parameters, first is the device name of the 
 controller
 -(PHY consumer) and second is the port name.
 -
 -struct phy_init_data init_data = {
 -   .consumers = consumers,
 -   .num_consumers = ARRAY_SIZE(consumers),
 -};
 -
 -static const struct platform_device pipe3_phy_dev = {
 -   .name = "pipe3-phy",
 -   .id = -1,
 -   .dev = {
 -   .platform_data = {
 -   .init_data = &init_data,
 -   },
 -   },
 -};
 -
 -then, while doing phy_create, the PHY driver should pass this init_data
 -   phy_create(dev, ops, pdata->init_data);
 -
 -and the controller driver (phy consumer) should pass the port name along 
 with
 -the device to get a reference to the PHY
 -   phy_get(dev, "pcie");
 +8. PHY Mappings
 +
 +In order to get reference to a PHY without help from DeviceTree, the 
 framework
 +offers lookups which can be compared to clkdev that allow clk structures 
 to be
 +bound to devices. A lookup can be made statically by directly registering
 +phy_lookup structure which contains the name of the PHY device, the name 
 of the
 +device which the PHY will be bind to and Connection ID string. 
 Alternatively a
 +lookup can be made during runtime when a handle to the struct phy already
 +exists.
 +
 +The framework offers the following APIs for registering and unregistering 
 the
 +lookups.
 +
 +void phy_register_lookup(struct phy_lookup *pl);
 +int phy_create_lookup(struct phy *phy, const char *con_id, const char 
 *dev_id);
 +
 +void phy_unregister_lookup(struct phy_lookup *pl);
 +void phy_remove_lookup(struct phy *phy, const char *con_id, const char 
 *dev_

[PATCH v2] usbnet: smsc95xx: dereferencing NULL pointer

2014-11-11 Thread Sudip Mukherjee
we were dereferencing dev to initialize pdata. but just after that we
have a BUG_ON(!dev). so we were basically dereferencing the pointer
first and then tesing it for NULL.

Signed-off-by: Sudip Mukherjee 
---

change in v2: suspend_flags is initialised after pdata is initialised.
v1 had a very silly but serious mistake of making pdata NULL, and trying
to dereference it.
sorry again for that.

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

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index d07bf4c..26423ad 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -1670,12 +1670,14 @@ done:
 static int smsc95xx_resume(struct usb_interface *intf)
 {
struct usbnet *dev = usb_get_intfdata(intf);
-   struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
-   u8 suspend_flags = pdata->suspend_flags;
+   struct smsc95xx_priv *pdata;
+   u8 suspend_flags;
int ret;
u32 val;
 
BUG_ON(!dev);
+   pdata = (struct smsc95xx_priv *)(dev->data[0]);
+   suspend_flags = pdata->suspend_flags;
 
netdev_dbg(dev->net, "resume suspend_flags=0x%02x\n", suspend_flags);
 
-- 
1.8.1.2

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


Re: [PATCHv4 2/6] phy: improved lookup method

2014-11-11 Thread Vivek Gautam
On Tue, Nov 11, 2014 at 12:12 PM, Kishon Vijay Abraham I  wrote:
> Hi,
>
> On Friday 31 October 2014 06:03 PM, Vivek Gautam wrote:
>> Hi Heikki,
>>
>>
>> On Fri, Oct 17, 2014 at 8:09 PM, Heikki Krogerus
>>  wrote:
>>> Removes the need for the phys to be aware of their users
>>> even when not using DT. The method is copied from clkdev.c.
>>>
>>> Signed-off-by: Heikki Krogerus 
>>> Tested-by: Vivek Gautam 
>>> ---
>>>  Documentation/phy.txt   |  66 ---
>>>  drivers/phy/phy-core.c  | 135 
>>> +++-
>>>  include/linux/phy/phy.h |  27 ++
>>>  3 files changed, 183 insertions(+), 45 deletions(-)
>>>
>>> diff --git a/Documentation/phy.txt b/Documentation/phy.txt
>>> index c6594af..8add515 100644
>>> --- a/Documentation/phy.txt
>>> +++ b/Documentation/phy.txt
>>> @@ -54,18 +54,14 @@ The PHY driver should create the PHY in order for other 
>>> peripheral controllers
>>>  to make use of it. The PHY framework provides 2 APIs to create the PHY.
>>>
>>>  struct phy *phy_create(struct device *dev, struct device_node *node,
>>> -  const struct phy_ops *ops,
>>> -  struct phy_init_data *init_data);
>>> +  const struct phy_ops *ops);
>>>  struct phy *devm_phy_create(struct device *dev, struct device_node *node,
>>> -   const struct phy_ops *ops,
>>> -   struct phy_init_data *init_data);
>>> +   const struct phy_ops *ops);
>>>
>>>  The PHY drivers can use one of the above 2 APIs to create the PHY by 
>>> passing
>>> -the device pointer, phy ops and init_data.
>>> +the device pointer and phy ops.
>>>  phy_ops is a set of function pointers for performing PHY operations such as
>>> -init, exit, power_on and power_off. *init_data* is mandatory to get a 
>>> reference
>>> -to the PHY in the case of non-dt boot. See section *Board File 
>>> Initialization*
>>> -on how init_data should be used.
>>> +init, exit, power_on and power_off.
>>>
>>>  Inorder to dereference the private data (in phy_ops), the phy provider 
>>> driver
>>>  can use phy_set_drvdata() after creating the PHY and use phy_get_drvdata() 
>>> in
>>> @@ -137,42 +133,24 @@ There are exported APIs like phy_pm_runtime_get, 
>>> phy_pm_runtime_get_sync,
>>>  phy_pm_runtime_put, phy_pm_runtime_put_sync, phy_pm_runtime_allow and
>>>  phy_pm_runtime_forbid for performing PM operations.
>>>
>>> -8. Board File Initialization
>>> -
>>> -Certain board file initialization is necessary in order to get a reference
>>> -to the PHY in the case of non-dt boot.
>>> -Say we have a single device that implements 3 PHYs that of USB, SATA and 
>>> PCIe,
>>> -then in the board file the following initialization should be done.
>>> -
>>> -struct phy_consumer consumers[] = {
>>> -   PHY_CONSUMER("dwc3.0", "usb"),
>>> -   PHY_CONSUMER("pcie.0", "pcie"),
>>> -   PHY_CONSUMER("sata.0", "sata"),
>>> -};
>>> -PHY_CONSUMER takes 2 parameters, first is the device name of the controller
>>> -(PHY consumer) and second is the port name.
>>> -
>>> -struct phy_init_data init_data = {
>>> -   .consumers = consumers,
>>> -   .num_consumers = ARRAY_SIZE(consumers),
>>> -};
>>> -
>>> -static const struct platform_device pipe3_phy_dev = {
>>> -   .name = "pipe3-phy",
>>> -   .id = -1,
>>> -   .dev = {
>>> -   .platform_data = {
>>> -   .init_data = &init_data,
>>> -   },
>>> -   },
>>> -};
>>> -
>>> -then, while doing phy_create, the PHY driver should pass this init_data
>>> -   phy_create(dev, ops, pdata->init_data);
>>> -
>>> -and the controller driver (phy consumer) should pass the port name along 
>>> with
>>> -the device to get a reference to the PHY
>>> -   phy_get(dev, "pcie");
>>> +8. PHY Mappings
>>> +
>>> +In order to get reference to a PHY without help from DeviceTree, the 
>>> framework
>>> +offers lookups which can be compared to clkdev that allow clk structures 
>>> to be
>>> +bound to devices. A lookup can be made statically by directly registering
>>> +phy_lookup structure which contains the name of the PHY device, the name 
>>> of the
>>> +device which the PHY will be bind to and Connection ID string. 
>>> Alternatively a
>>> +lookup can be made during runtime when a handle to the struct phy already
>>> +exists.
>>> +
>>> +The framework offers the following APIs for registering and unregistering 
>>> the
>>> +lookups.
>>> +
>>> +void phy_register_lookup(struct phy_lookup *pl);
>>> +int phy_create_lookup(struct phy *phy, const char *con_id, const char 
>>> *dev_id);
>>> +
>>> +void phy_unregister_lookup(struct phy_lookup *pl);
>>> +void phy_remove_lookup(struct phy *phy, const char *con_id, const char 
>>> *dev_id);
>>>
>>>  9. DeviceTree Binding
>>>
>>> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
>>> index ff5eec5..c8d0f66 100644
>>> --- a/drivers/phy/phy-core.c
>>> +++ b/drivers/phy/phy-cor

Re: [net-next PATCH 4/5] fm10k/igb/ixgbe: Replace __skb_alloc_page with netdev_alloc_page

2014-11-11 Thread Jeff Kirsher
On Mon, 2014-11-10 at 11:52 -0800, Alexander Duyck wrote:
> The Intel drivers were pretty much just using the plain vanilla GFP
> flags
> in their calls to __skb_alloc_page so this change makes it so that
> they use
> netdev_alloc_page which just uses GFP_ATOMIC for the gfp_flags value.
> 
> Cc: Jeff Kirsher 
> Cc: Matthew Vick 
> Cc: Don Skidmore 
> Signed-off-by: Alexander Duyck 
> ---
>  drivers/net/ethernet/intel/fm10k/fm10k_main.c |2 +-
>  drivers/net/ethernet/intel/igb/igb_main.c |2 +-
>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |3 +--
>  3 files changed, 3 insertions(+), 4 deletions(-)

I know that this patch is dependent upon the changes in patch 01 of the
series, so I do not want to necessarily break up the series by having
Dave wait for us to test and ACK this patch internally.  But I will add
your patch to my queue so that I can get what testing I can on these
changes.

FWIW...
Acked-by: Jeff Kirsher 


signature.asc
Description: This is a digitally signed message part


Re: [PATCH] usb: misc: Add driver for ALVA Nanoface

2014-11-11 Thread Greg Kroah-Hartman
On Tue, Nov 11, 2014 at 09:17:03AM +0200, Lauri Niskanen wrote:
> On 11/11/14 09:07, Greg Kroah-Hartman wrote:
> >Any reason this can't be a simple userspace program that writes the
> >needed command to the device using libusb instead of being a kernel
> >driver?  This seems like overkill for a kernel driver to me.
> 
> You are probably right. It indeed should be possible to do this in
> userspace. I thought that having a kernel driver would still be benefical
> since it adds plug-and-play availability for all Linux users without having
> to deal with userspace driver programs.

You can do that by just providing a package that adds a udev rule to run
your program when the device is seen.

Yes, it's not as "easy" as being in the main kernel tree, but we do like
to keep things out of the kernel that don't have to be in the kernel.
We removed a number of drivers like this about 10 years go for that very
reaason.

> You are far more experienced with these things than me, so I am happy to let
> you make the decision about whether to have a kernel driver or not.

I think a userspace program would be best.

sorry,

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