[PATCH v2 5/5] xhci: add a quirk for device disconnection errata for Synopsis Designware USB3 core

2015-01-18 Thread Sneeker Yeh
This issue is defined by a three-way race at disconnect, between
1) Class driver interrupt endpoint resheduling attempts if the ISR gave an ep
   error event due to device detach (it would try 3 times)
2) Disconnect interrupt on PORTSC_CSC, which is cleared by hub thread
   asynchronously
3) The hardware IP was configured in silicon with
   - DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1
   - Synopsys IP version is < 3.00a
The IP will auto-suspend itself on device detach with some phy-specific interval
after CSC is cleared by 2)

If 2) and 3) complete before 1), the interrupts it expects will not be generated
by the autosuspended IP, leading to a deadlock. Even later disconnection
procedure would detect that corresponding urb is still in-progress and issue a
ep stop command, auto-suspended IP still won't respond to that command.

this defect would result in this when device detached:
---
[   99.603544] usb 4-1: USB disconnect, device number 2
[  104.615254] xhci-hcd xhci-hcd.0.auto: xHCI host not responding to stop 
endpoint command.
[  104.623362] xhci-hcd xhci-hcd.0.auto: Assuming host is dying, halting host.
[  104.653261] xhci-hcd xhci-hcd.0.auto: Host not halted after 16000 
microseconds.
[  104.660584] xhci-hcd xhci-hcd.0.auto: Non-responsive xHCI host is not 
halting.
[  104.667817] xhci-hcd xhci-hcd.0.auto: Completing active URBs anyway.
[  104.674198] xhci-hcd xhci-hcd.0.auto: HC died; cleaning up
--
As a result, when device detached, we desired to postpone "PORTCSC clear" behind
"disable slot". it's found that all executed ep command related to disconnetion,
are executed before "disable slot".

Signed-off-by: Sneeker Yeh 
---
 drivers/usb/host/xhci-hub.c |4 
 drivers/usb/host/xhci.c |   29 +
 drivers/usb/host/xhci.h |   24 
 3 files changed, 57 insertions(+)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index a7865c4..3b8f7fc 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -368,6 +368,10 @@ static void xhci_clear_port_change_bit(struct xhci_hcd 
*xhci, u16 wValue,
port_change_bit = "warm(BH) reset";
break;
case USB_PORT_FEAT_C_CONNECTION:
+   if ((xhci->quirks & XHCI_DISCONNECT_QUIRK) &&
+   !(readl(addr) & PORT_CONNECT))
+   return;
+
status = PORT_CSC;
port_change_bit = "connect";
break;
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index c50d8d2..aa8e02a 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3584,6 +3584,33 @@ command_cleanup:
return ret;
 }
 
+static void xhci_try_to_clear_csc(struct usb_hcd *hcd, int dev_port_num)
+{
+   int max_ports;
+   struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+   __le32 __iomem **port_array;
+   u32 status;
+
+   /* print debug info */
+   if (hcd->speed == HCD_USB3) {
+   max_ports = xhci->num_usb3_ports;
+   port_array = xhci->usb3_ports;
+   } else {
+   max_ports = xhci->num_usb2_ports;
+   port_array = xhci->usb2_ports;
+   }
+
+   if (dev_port_num > max_ports) {
+   xhci_err(xhci, "%s() port number invalid", __func__);
+   return;
+   }
+   status = readl(port_array[dev_port_num - 1]);
+
+   /* write 1 to clear */
+   if (!(status & PORT_CONNECT) && (status & PORT_CSC))
+   writel(status & PORT_CSC, port_array[0]);
+}
+
 /*
  * At this point, the struct usb_device is about to go away, the device has
  * disconnected, and all traffic has been stopped and the endpoints have been
@@ -3649,6 +3676,8 @@ void xhci_free_dev(struct usb_hcd *hcd, struct usb_device 
*udev)
xhci_ring_cmd_db(xhci);
spin_unlock_irqrestore(&xhci->lock, flags);
 
+   if (xhci->quirks & XHCI_DISCONNECT_QUIRK)
+   xhci_try_to_clear_csc(hcd, udev->portnum);
/*
 * Event command completion handler will free any data structures
 * associated with the slot.  XXX Can free sleep?
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index cc7c5bb..65a65cc 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1560,6 +1560,30 @@ struct xhci_hcd {
 #define XHCI_SPURIOUS_WAKEUP   (1 << 18)
 /* For controllers with a broken beyond repair streams implementation */
 #define XHCI_BROKEN_STREAMS(1 << 19)
+/*
+ * This issue is defined by a three-way race at disconnect in Synopsis USB3 IP,
+ * between
+ * 1) Class driver interrupt endpoint resheduling attempts if the ISR gave an 
ep
+ *error event due to device detach (it would try 3 times)
+ * 2) Disconnect interrupt on PORTSC_CSC, which is cleared by hub thread
+ *asynchronously
+ * 3) The hardware IP was configured in silicon with
+

[PATCH v2 4/5] xhci: Platform: Set Synopsis device disconnection quirk based on platform data

2015-01-18 Thread Sneeker Yeh
If an xhci platform has Synopsis device disconnection errata then enable
XHCI_DISCONNECT_QUIRK quirk flag.

Signed-off-by: Sneeker Yeh 
---
 drivers/usb/host/xhci-plat.c |3 +++
 include/linux/usb/xhci_pdriver.h |4 
 2 files changed, 7 insertions(+)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 08d402b..40beb95 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -147,6 +147,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
if ((node && of_property_read_bool(node, "usb3-lpm-capable")) ||
(pdata && pdata->usb3_lpm_capable))
xhci->quirks |= XHCI_LPM_SUPPORT;
+
+   if (pdata && pdata->delay_portcsc_clear)
+   xhci->quirks |= XHCI_DISCONNECT_QUIRK;
/*
 * Set the xHCI pointer before xhci_plat_setup() (aka hcd_driver.reset)
 * is called by usb_add_hcd().
diff --git a/include/linux/usb/xhci_pdriver.h b/include/linux/usb/xhci_pdriver.h
index 376654b..a37a3a5 100644
--- a/include/linux/usb/xhci_pdriver.h
+++ b/include/linux/usb/xhci_pdriver.h
@@ -18,10 +18,14 @@
  *
  * @usb3_lpm_capable:  determines if this xhci platform supports USB3
  * LPM capability
+ * @delay_portcsc_clear:   determines if Synopsis USB3 core has errata in
+ * "DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1" hardware
+ * configuration.
  *
  */
 struct usb_xhci_pdata {
unsignedusb3_lpm_capable:1;
+   unsigneddelay_portcsc_clear:1;
 };
 
 #endif /* __USB_CORE_XHCI_PDRIVER_H */
-- 
1.7.9.5

--
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 0/7] r8152: adjust the code

2015-01-18 Thread Hayes Wang
Code adjustment.

Hayes Wang (7):
  r8152: adjust rx_bottom
  r8152: adjust lpm timer
  r8152: check linking status with netif_carrier_ok
  r8152: check RTL8152_UNPLUG for rtl8152_close
  r8152: adjust the link feed for hw_features
  r8152: replace get_protocol with vlan_get_protocol
  r8152: use BIT macro

 drivers/net/usb/r8152.c | 99 +++--
 1 file changed, 46 insertions(+), 53 deletions(-)

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


[PATCH net-next 1/7] r8152: adjust rx_bottom

2015-01-18 Thread Hayes Wang
If a error occurs when submitting rx, skip the remaining submissions
and try to submit them again next time.

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

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 2e22442..78a8917 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1655,7 +1655,7 @@ static int rx_bottom(struct r8152 *tp, int budget)
 {
unsigned long flags;
struct list_head *cursor, *next, rx_queue;
-   int work_done = 0;
+   int ret = 0, work_done = 0;
 
if (!skb_queue_empty(&tp->rx_queue)) {
while (work_done < budget) {
@@ -1746,7 +1746,18 @@ find_next_rx:
}
 
 submit:
-   r8152_submit_rx(tp, agg, GFP_ATOMIC);
+   if (!ret) {
+   ret = r8152_submit_rx(tp, agg, GFP_ATOMIC);
+   } else {
+   urb->actual_length = 0;
+   list_add_tail(&agg->list, next);
+   }
+   }
+
+   if (!list_empty(&rx_queue)) {
+   spin_lock_irqsave(&tp->rx_lock, flags);
+   list_splice_tail(&rx_queue, &tp->rx_done);
+   spin_unlock_irqrestore(&tp->rx_lock, flags);
}
 
 out1:
-- 
2.1.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


[PATCH net-next 4/7] r8152: check RTL8152_UNPLUG for rtl8152_close

2015-01-18 Thread Hayes Wang
It is unnecessary to accress the hw register if the device is unplugged.

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

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 21f853f..9be642e 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -3064,7 +3064,7 @@ static int rtl8152_close(struct net_device *netdev)
netif_stop_queue(netdev);
 
res = usb_autopm_get_interface(tp->intf);
-   if (res < 0) {
+   if (res < 0 || test_bit(RTL8152_UNPLUG, &tp->flags)) {
rtl_drop_queued_tx(tp);
rtl_stop_rx(tp);
} else {
-- 
2.1.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


[PATCH net-next 2/7] r8152: adjust lpm timer

2015-01-18 Thread Hayes Wang
Set LPM timer to 500us, except for RTL_VER_04 which doesn't link at
USB 3.0.

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

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 78a8917..3ee9d06 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -3274,10 +3274,10 @@ static void r8153_init(struct r8152 *tp)
 
ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_LPM_CTRL);
ocp_data &= ~LPM_TIMER_MASK;
-   if (tp->udev->speed == USB_SPEED_SUPER)
-   ocp_data |= LPM_TIMER_500US;
-   else
+   if (tp->version == RTL_VER_04 && tp->udev->speed != USB_SPEED_SUPER)
ocp_data |= LPM_TIMER_500MS;
+   else
+   ocp_data |= LPM_TIMER_500US;
ocp_write_byte(tp, MCU_TYPE_USB, USB_LPM_CTRL, ocp_data);
 
ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_AFE_CTRL2);
-- 
2.1.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


[PATCH net-next 3/7] r8152: check linking status with netif_carrier_ok

2015-01-18 Thread Hayes Wang
Replace (tp->speed & LINK_STATUS) with netif_carrier_ok().

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

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 3ee9d06..21f853f 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -581,7 +581,6 @@ struct r8152 {
u16 ocp_base;
u8 *intr_buff;
u8 version;
-   u8 speed;
 };
 
 enum rtl_version {
@@ -1169,12 +1168,12 @@ static void intr_callback(struct urb *urb)
 
d = urb->transfer_buffer;
if (INTR_LINK & __le16_to_cpu(d[0])) {
-   if (!(tp->speed & LINK_STATUS)) {
+   if (!netif_carrier_ok(tp->netdev)) {
set_bit(RTL8152_LINK_CHG, &tp->flags);
schedule_delayed_work(&tp->schedule, 0);
}
} else {
-   if (tp->speed & LINK_STATUS) {
+   if (netif_carrier_ok(tp->netdev)) {
set_bit(RTL8152_LINK_CHG, &tp->flags);
schedule_delayed_work(&tp->schedule, 0);
}
@@ -1906,7 +1905,7 @@ static void rtl8152_set_rx_mode(struct net_device *netdev)
 {
struct r8152 *tp = netdev_priv(netdev);
 
-   if (tp->speed & LINK_STATUS) {
+   if (netif_carrier_ok(netdev)) {
set_bit(RTL8152_SET_RX_MODE, &tp->flags);
schedule_delayed_work(&tp->schedule, 0);
}
@@ -2936,21 +2935,20 @@ static void set_carrier(struct r8152 *tp)
speed = rtl8152_get_speed(tp);
 
if (speed & LINK_STATUS) {
-   if (!(tp->speed & LINK_STATUS)) {
+   if (!netif_carrier_ok(netdev)) {
tp->rtl_ops.enable(tp);
set_bit(RTL8152_SET_RX_MODE, &tp->flags);
netif_carrier_on(netdev);
rtl_start_rx(tp);
}
} else {
-   if (tp->speed & LINK_STATUS) {
+   if (netif_carrier_ok(netdev)) {
netif_carrier_off(netdev);
napi_disable(&tp->napi);
tp->rtl_ops.disable(tp);
napi_enable(&tp->napi);
}
}
-   tp->speed = speed;
 }
 
 static void rtl_work_func_t(struct work_struct *work)
@@ -2982,7 +2980,7 @@ static void rtl_work_func_t(struct work_struct *work)
 
/* don't schedule napi before linking */
if (test_bit(SCHEDULE_NAPI, &tp->flags) &&
-   (tp->speed & LINK_STATUS)) {
+   netif_carrier_ok(tp->netdev)) {
clear_bit(SCHEDULE_NAPI, &tp->flags);
napi_schedule(&tp->napi);
}
@@ -3005,8 +3003,7 @@ static int rtl8152_open(struct net_device *netdev)
if (res)
goto out;
 
-   /* set speed to 0 to avoid autoresume try to submit rx */
-   tp->speed = 0;
+   netif_carrier_off(netdev);
 
res = usb_autopm_get_interface(tp->intf);
if (res < 0) {
@@ -3023,7 +3020,7 @@ static int rtl8152_open(struct net_device *netdev)
cancel_delayed_work_sync(&tp->schedule);
 
/* disable the tx/rx, if the workqueue has enabled them. */
-   if (tp->speed & LINK_STATUS)
+   if (netif_carrier_ok(netdev))
tp->rtl_ops.disable(tp);
}
 
@@ -3032,7 +3029,6 @@ static int rtl8152_open(struct net_device *netdev)
rtl8152_set_speed(tp, AUTONEG_ENABLE,
  tp->mii.supports_gmii ? SPEED_1000 : SPEED_100,
  DUPLEX_FULL);
-   tp->speed = 0;
netif_carrier_off(netdev);
netif_start_queue(netdev);
set_bit(WORK_ENABLE, &tp->flags);
@@ -3358,7 +3354,7 @@ static int rtl8152_resume(struct usb_interface *intf)
rtl_runtime_suspend_enable(tp, false);
clear_bit(SELECTIVE_SUSPEND, &tp->flags);
set_bit(WORK_ENABLE, &tp->flags);
-   if (tp->speed & LINK_STATUS)
+   if (netif_carrier_ok(tp->netdev))
rtl_start_rx(tp);
} else {
tp->rtl_ops.up(tp);
@@ -3366,7 +3362,6 @@ static int rtl8152_resume(struct usb_interface *intf)
  tp->mii.supports_gmii ?
  SPEED_1000 : SPEED_100,
  DUPLEX_FULL);
-   tp->speed = 0;
netif_carrier_off(tp->netdev);
set_bit(WORK_ENABLE, &tp->flags);
}
-- 
2.1.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


[PATCH net-next 6/7] r8152: replace get_protocol with vlan_get_protocol

2015-01-18 Thread Hayes Wang
vlan_get_protocol() has been defined and use it to replace
get_protocol().

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

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index f66ffbd..46440ed 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1342,18 +1342,6 @@ static struct tx_agg *r8152_get_tx_agg(struct r8152 *tp)
return agg;
 }
 
-static inline __be16 get_protocol(struct sk_buff *skb)
-{
-   __be16 protocol;
-
-   if (skb->protocol == htons(ETH_P_8021Q))
-   protocol = vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
-   else
-   protocol = skb->protocol;
-
-   return protocol;
-}
-
 /* r8152_csum_workaround()
  * The hw limites the value the transport offset. When the offset is out of the
  * range, calculate the checksum by sw.
@@ -1459,7 +1447,7 @@ static int r8152_tx_csum(struct r8152 *tp, struct tx_desc 
*desc,
goto unavailable;
}
 
-   switch (get_protocol(skb)) {
+   switch (vlan_get_protocol(skb)) {
case htons(ETH_P_IP):
opts1 |= GTSENDV4;
break;
@@ -1490,7 +1478,7 @@ static int r8152_tx_csum(struct r8152 *tp, struct tx_desc 
*desc,
goto unavailable;
}
 
-   switch (get_protocol(skb)) {
+   switch (vlan_get_protocol(skb)) {
case htons(ETH_P_IP):
opts2 |= IPV4_CS;
ip_protocol = ip_hdr(skb)->protocol;
-- 
2.1.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


[PATCH net-next 5/7] r8152: adjust the link feed for hw_features

2015-01-18 Thread Hayes Wang
Keep NETIF_F_HW_VLAN_CTAG_RX and NETIF_F_HW_VLAN_CTAG_TX at the
same line.

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

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 9be642e..f66ffbd 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -3926,8 +3926,7 @@ static int rtl8152_probe(struct usb_interface *intf,
netdev->hw_features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_SG |
  NETIF_F_TSO | NETIF_F_FRAGLIST |
  NETIF_F_IPV6_CSUM | NETIF_F_TSO6 |
- NETIF_F_HW_VLAN_CTAG_RX |
- NETIF_F_HW_VLAN_CTAG_TX;
+ NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_TX;
netdev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO |
NETIF_F_HIGHDMA | NETIF_F_FRAGLIST |
NETIF_F_IPV6_CSUM | NETIF_F_TSO6;
-- 
2.1.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


[PATCH net-next 7/7] r8152: use BIT macro

2015-01-18 Thread Hayes Wang
Use BIT macro to replace (1 << bits).

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

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 46440ed..c3a0224 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -489,16 +489,16 @@ struct rx_desc {
 #define RX_LEN_MASK0x7fff
 
__le32 opts2;
-#define RD_UDP_CS  (1 << 23)
-#define RD_TCP_CS  (1 << 22)
-#define RD_IPV6_CS (1 << 20)
-#define RD_IPV4_CS (1 << 19)
+#define RD_UDP_CS  BIT(23)
+#define RD_TCP_CS  BIT(22)
+#define RD_IPV6_CS BIT(20)
+#define RD_IPV4_CS BIT(19)
 
__le32 opts3;
-#define IPF(1 << 23) /* IP checksum fail */
-#define UDPF   (1 << 22) /* UDP checksum fail */
-#define TCPF   (1 << 21) /* TCP checksum fail */
-#define RX_VLAN_TAG(1 << 16)
+#define IPFBIT(23) /* IP checksum fail */
+#define UDPF   BIT(22) /* UDP checksum fail */
+#define TCPF   BIT(21) /* TCP checksum fail */
+#define RX_VLAN_TAGBIT(16)
 
__le32 opts4;
__le32 opts5;
@@ -507,24 +507,24 @@ struct rx_desc {
 
 struct tx_desc {
__le32 opts1;
-#define TX_FS  (1 << 31) /* First segment of a packet */
-#define TX_LS  (1 << 30) /* Final segment of a packet */
-#define GTSENDV4   (1 << 28)
-#define GTSENDV6   (1 << 27)
+#define TX_FS  BIT(31) /* First segment of a packet */
+#define TX_LS  BIT(30) /* Final segment of a packet */
+#define GTSENDV4   BIT(28)
+#define GTSENDV6   BIT(27)
 #define GTTCPHO_SHIFT  18
 #define GTTCPHO_MAX0x7fU
 #define TX_LEN_MAX 0x3U
 
__le32 opts2;
-#define UDP_CS (1 << 31) /* Calculate UDP/IP checksum */
-#define TCP_CS (1 << 30) /* Calculate TCP/IP checksum */
-#define IPV4_CS(1 << 29) /* Calculate IPv4 checksum */
-#define IPV6_CS(1 << 28) /* Calculate IPv6 checksum */
+#define UDP_CS BIT(31) /* Calculate UDP/IP checksum */
+#define TCP_CS BIT(30) /* Calculate TCP/IP checksum */
+#define IPV4_CSBIT(29) /* Calculate IPv4 checksum */
+#define IPV6_CSBIT(28) /* Calculate IPv6 checksum */
 #define MSS_SHIFT  17
 #define MSS_MAX0x7ffU
 #define TCPHO_SHIFT17
 #define TCPHO_MAX  0x7ffU
-#define TX_VLAN_TAG(1 << 16)
+#define TX_VLAN_TAGBIT(16)
 };
 
 struct r8152;
-- 
2.1.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


Re: query on DWC3

2015-01-18 Thread sundeep subbaraya
Hi Felipe,

On Thu, Jan 8, 2015 at 10:27 PM, Felipe Balbi  wrote:
> Hi,
>
> On Tue, Jan 06, 2015 at 12:39:55PM +0530, sundeep subbaraya wrote:
>> >> On Sun, Dec 14, 2014 at 08:39:18AM +0530, sundeep subbaraya wrote:
>> >> > Hi Paul,
>> >> >
>> >> > As per my understanding, for BULK OUT we do queue a request with 512
>> >> > bytes length since we do not
>> >>
>> >> sometimes we _do_ know the size. In case of Mass Storage, we _know_ that
>> >> the first bulk out transfer will be 31-bytes (CBW), if we were to start
>> >> a 31-byte transfer, we would't receive anything.
>> >>
>> >> > know the length of the transfer Host is going to send. For Control OUT
>> >> > we know the length in wLength of
>> >> > Setup packet, hence I assumed there is no difference in programming
>> >> > model of Control IN and OUT.
>> >>
>> >> there is _no_ difference. It's just that it was agreed that for anything
>> >> other than control ep, the function drivers would take care of it. See
>> >> the uses of quirk_ep_out_aligned_size.
>>
>> got it..:)
>>
>> >
>> > btw, why are you reimplementing the driver when there's a perfectly good
>> > driver to use in mainline kernel ?
>>
>> I am writing a bare metal driver and it didn't work without alignment
>> check mentioned above.
>
> just make sure you don't copy GPL code into your bare metal driver,
> otherwise your bare metal driver will be GPL by definition. Also, since

I didn't copy linux code. I have gone through dwc3 driver while
writing udc-xilinx.c
and now it is helping me to understand dwc3 controller quickly.:)

> you're not using Linux at all, you should be asking support from
> Synopsys instead, not the Linux USB mailing list.

Sure will ask support from Synopsis.

Thanks,
Sundeep

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


[PATCH 1/2] usb: renesas_usbhs: add usbhsf_dma_init_pdev() function

2015-01-18 Thread Yoshihiro Shimoda
To add support for requesting DT DMA in the future, this patch adds
usbhsf_dma_init_pdev() function.

Signed-off-by: Yoshihiro Shimoda 
---
 drivers/usb/renesas_usbhs/fifo.c |   12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index f46271c..48e31b9 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -1054,10 +1054,8 @@ static void usbhsf_dma_quit(struct usbhs_priv *priv, 
struct usbhs_fifo *fifo)
fifo->rx_chan = NULL;
 }
 
-static void usbhsf_dma_init(struct usbhs_priv *priv,
-   struct usbhs_fifo *fifo)
+static void usbhsf_dma_init_pdev(struct usbhs_fifo *fifo)
 {
-   struct device *dev = usbhs_priv_to_dev(priv);
dma_cap_mask_t mask;
 
dma_cap_zero(mask);
@@ -1069,6 +1067,14 @@ static void usbhsf_dma_init(struct usbhs_priv *priv,
dma_cap_set(DMA_SLAVE, mask);
fifo->rx_chan = dma_request_channel(mask, usbhsf_dma_filter,
&fifo->rx_slave);
+}
+
+static void usbhsf_dma_init(struct usbhs_priv *priv,
+   struct usbhs_fifo *fifo)
+{
+   struct device *dev = usbhs_priv_to_dev(priv);
+
+   usbhsf_dma_init_pdev(fifo);
 
if (fifo->tx_chan || fifo->rx_chan)
dev_dbg(dev, "enable DMAEngine (%s%s%s)\n",
-- 
1.7.9.5

--
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 2/2] usb: renesas_usbhs: add support for requesting DT DMA

2015-01-18 Thread Yoshihiro Shimoda
This patch adds dma_request_slave_channel_reason() calling to request
dma slave channels for multiplatform environment.

Signed-off-by: Yoshihiro Shimoda 
---
 .../devicetree/bindings/usb/renesas_usbhs.txt  |2 ++
 drivers/usb/renesas_usbhs/fifo.c   |   11 ++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt 
b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
index b08c903..61b045b 100644
--- a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
+++ b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
@@ -14,6 +14,8 @@ Optional properties:
 function should be enabled
   - phys: phandle + phy specifier pair
   - phy-names: must be "usb"
+  - dmas: Must contain a list of references to DMA specifiers.
+  - dma-names : Must contain a list of DMA names, "tx" or "rx".
 
 Example:
usbhs: usb@e659 {
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 48e31b9..4c086b1 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -1069,12 +1069,21 @@ static void usbhsf_dma_init_pdev(struct usbhs_fifo 
*fifo)
&fifo->rx_slave);
 }
 
+static void usbhsf_dma_init_dt(struct device *dev, struct usbhs_fifo *fifo)
+{
+   fifo->tx_chan = dma_request_slave_channel_reason(dev, "tx");
+   fifo->rx_chan = dma_request_slave_channel_reason(dev, "rx");
+}
+
 static void usbhsf_dma_init(struct usbhs_priv *priv,
struct usbhs_fifo *fifo)
 {
struct device *dev = usbhs_priv_to_dev(priv);
 
-   usbhsf_dma_init_pdev(fifo);
+   if (dev->of_node)
+   usbhsf_dma_init_dt(dev, fifo);
+   else
+   usbhsf_dma_init_pdev(fifo);
 
if (fifo->tx_chan || fifo->rx_chan)
dev_dbg(dev, "enable DMAEngine (%s%s%s)\n",
-- 
1.7.9.5

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


[PATCH 0/2] usb: renesas_usbhs: add support for requesting DT DMA

2015-01-18 Thread Yoshihiro Shimoda
This patch series is based on Felipe's usb.git / testing/next branch.
(commit id = 05cf6e00b8ff2b80c8b2d1e69f07cdd6c830efe0)

Yoshihiro Shimoda (2):
  usb: renesas_usbhs: add usbhsf_dma_init_pdev() function
  usb: renesas_usbhs: add support for requesting DT DMA

 .../devicetree/bindings/usb/renesas_usbhs.txt  |2 ++
 drivers/usb/renesas_usbhs/fifo.c   |   21 +---
 2 files changed, 20 insertions(+), 3 deletions(-)

-- 
1.7.9.5

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


Re: [PATCH v3 1/3] usb: udc: add usb_gadget_find_udc

2015-01-18 Thread Peter Chen
On Fri, Jan 16, 2015 at 10:15:45AM -0600, Felipe Balbi wrote:
> On Fri, Jan 16, 2015 at 11:05:07AM -0500, Alan Stern wrote:
> > On Fri, 16 Jan 2015, Peter Chen wrote:
> > 
> > > This is an internal API, and is used to find corresponding udc according
> > > to gadget.
> > > 
> > > Signed-off-by: Peter Chen 
> > > ---
> > >  drivers/usb/gadget/udc/udc-core.c | 51 
> > > ---
> > >  1 file changed, 26 insertions(+), 25 deletions(-)
> > > 
> > > diff --git a/drivers/usb/gadget/udc/udc-core.c 
> > > b/drivers/usb/gadget/udc/udc-core.c
> > > index e31d574..36c58c9 100644
> > > --- a/drivers/usb/gadget/udc/udc-core.c
> > > +++ b/drivers/usb/gadget/udc/udc-core.c
> > > @@ -52,6 +52,25 @@ static DEFINE_MUTEX(udc_lock);
> > >  
> > >  /* 
> > > - 
> > > */
> > >  
> > > +static struct usb_udc *usb_gadget_find_udc(struct usb_gadget *gadget)
> > > +{
> > > + struct usb_udc  *udc = NULL;
> > > +
> > > + mutex_lock(&udc_lock);
> > > + list_for_each_entry(udc, &udc_list, list)
> > > + if (udc->gadget == gadget)
> > > + goto found;
> > > + mutex_unlock(&udc_lock);
> > > + dev_err(gadget->dev.parent, "gadget not registered.\n");
> > > +
> > > + return NULL;
> > > +
> > > +found:
> > > + mutex_unlock(&udc_lock);
> > > + return udc;
> > > +}
> > 
> > An idea just struck me...  Instead of looping through all the udc's to
> > find the right one, why not simply store a pointer to the udc in struct
> > usb_gadget?
> > 

We still have code to find usb_gadget_driver to iterate udc_list, it
is better to change all, we need to have solution to consolidate
struct usb_udc, struct usb_gadget, and struct usb_gadget_drver.
I have no good solution now.

> > Also, it looks like there's a bug in usb_add_gadget_udc_release() in 
> > udc-core.c.  The error pathway (between err3 and err2) does not undo 
> > the
> > 
> > ret = device_register(&gadget->dev);
> > 
> > call.  There's a put_device() call but no device_del().
> 
> good point :-) Do you want to send a patch for that ?
> 

It looks like there is another issue in error pathway, the
put_device(&udc->dev) at err3 should be moved to err4 since
the get_device is called at device_add.

-- 

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


[PATCH 1/1] usb: serial: Fintek F81232 driver improvement

2015-01-18 Thread Peter Hung
The original driver completed with TX function, but RX/MSR/MCR/LSR is not
workable with this driver. So we rewrite it to make this device workable.

This patch is tested with PassMark BurnInTest with Cycle-to-115200 +
MCR/MSR check for 15mins & checked with Suspend-To-RAM/DISK

Signed-off-by: Peter Hung 
---
 drivers/usb/serial/f81232.c | 528 
 1 file changed, 440 insertions(+), 88 deletions(-)

diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index c5dc233..5ae6bc9 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -23,9 +23,16 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+
+#define FINTEK_MAGIC 'F'
+#define FINTEK_GET_ID  _IOR(FINTEK_MAGIC, 3, int)
+#define FINTEK_VENDOR_ID   0x1934
+#define FINTEK_DEVICE_ID   0x0706  /* RS232 1 port */
 
 static const struct usb_device_id id_table[] = {
-   { USB_DEVICE(0x1934, 0x0706) },
+   { USB_DEVICE(FINTEK_VENDOR_ID, FINTEK_DEVICE_ID) },
{ } /* Terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, id_table);
@@ -37,30 +44,257 @@ MODULE_DEVICE_TABLE(usb, id_table);
 #define UART_STATE_TRANSIENT_MASK  0x74
 #define UART_DCD   0x01
 #define UART_DSR   0x02
-#define UART_BREAK_ERROR   0x04
 #define UART_RING  0x08
-#define UART_FRAME_ERROR   0x10
-#define UART_PARITY_ERROR  0x20
-#define UART_OVERRUN_ERROR 0x40
 #define UART_CTS   0x80
 
+
+#define UART_BREAK_ERROR   0x10
+#define UART_FRAME_ERROR   0x08
+#define UART_PARITY_ERROR  0x04
+#define UART_OVERRUN_ERROR 0x02
+
+
+#define  SERIAL_EVEN_PARITY (UART_LCR_PARITY | UART_LCR_EPAR)
+
+
+#define REGISTER_REQUEST 0xA0
+#define F81232_USB_TIMEOUT 1000
+#define F81232_USB_RETRY 20
+
+
+#define SERIAL_BASE_ADDRESS   ((__u16)0x0120)
+#define RECEIVE_BUFFER_REGISTER((__u16)(0x00) + SERIAL_BASE_ADDRESS)
+#define TRANSMIT_HOLDING_REGISTER  ((__u16)(0x00) + SERIAL_BASE_ADDRESS)
+#define INTERRUPT_ENABLE_REGISTER  ((__u16)(0x01) + SERIAL_BASE_ADDRESS)
+#define INTERRUPT_IDENT_REGISTER   ((__u16)(0x02) + SERIAL_BASE_ADDRESS)
+#define FIFO_CONTROL_REGISTER  ((__u16)(0x02) + SERIAL_BASE_ADDRESS)
+#define LINE_CONTROL_REGISTER  ((__u16)(0x03) + SERIAL_BASE_ADDRESS)
+#define MODEM_CONTROL_REGISTER ((__u16)(0x04) + SERIAL_BASE_ADDRESS)
+#define LINE_STATUS_REGISTER   ((__u16)(0x05) + SERIAL_BASE_ADDRESS)
+#define MODEM_STATUS_REGISTER  ((__u16)(0x06) + SERIAL_BASE_ADDRESS)
+
+static int m_enable_debug;
+
+module_param(m_enable_debug, int, S_IRUGO);
+MODULE_PARM_DESC(m_enable_debug, "Debugging mode enabled or not");
+
+#define LOG_MESSAGE(x, y, ...) \
+   printk(x  y, ##__VA_ARGS__)
+
+#define LOG_DEBUG_MESSAGE(level, y, ...)   \
+   do { if (unlikely(m_enable_debug))  \
+   printk(level  y, ##__VA_ARGS__); } while (0)
+
+
 struct f81232_private {
spinlock_t lock;
-   u8 line_control;
-   u8 line_status;
+   u8 modem_control;
+   u8 modem_status;
+   struct usb_device *dev;
+
+   struct work_struct int_worker;
+   struct usb_serial_port *port;
 };
 
-static void f81232_update_line_status(struct usb_serial_port *port,
- unsigned char *data,
- unsigned int actual_length)
+
+static inline int calc_baud_divisor(u32 baudrate)
 {
-   /*
-* FIXME: Update port->icount, and call
-*
-*  wake_up_interruptible(&port->port.delta_msr_wait);
-*
-*on MSR changes.
-*/
+   u32 divisor, rem;
+
+   divisor = 115200L / baudrate;
+   rem = 115200L % baudrate;
+
+   /* Round to nearest divisor */
+   if (((rem * 2) >= baudrate) && (baudrate != 110))
+   divisor++;
+
+   return divisor;
+}
+
+
+static inline int f81232_get_register(struct usb_device *dev,
+   u16 reg, u8 *data)
+{
+   int status;
+   int i = 0;
+timeout_get_repeat:
+
+   status = usb_control_msg(dev,
+usb_rcvctrlpipe(dev, 0),
+REGISTER_REQUEST,
+0xc0,
+reg,
+0,
+data,
+sizeof(*data),
+F81232_USB_TIMEOUT);
+   if (status < 0) {
+   i++;
+
+   if (i < F81232_USB_RETRY) {
+   mdelay(1);
+   goto timeout_get_repeat;
+   }
+   }
+   return status;
+}
+
+
+static inline int f81232_set_register(struct usb_device *dev,
+   u16 reg, u8 data)
+{
+   int status;
+   int i = 0;
+
+timeout_set_repeat:
+   status = 0;
+
+   status = usb_control_msg(dev,
+

Re: [PATCH v3 3/3] usb: udc: add usb_udc_activation_handler

2015-01-18 Thread Peter Chen
On Fri, Jan 16, 2015 at 11:11:56AM -0500, Alan Stern wrote:
> On Fri, 16 Jan 2015, Peter Chen wrote:
> 
> > During this API, the deactivation count will be update, and it
> > will try to connect or disconnect gadget. It can be used to
> > enable functions for gadget.
> > 
> > Signed-off-by: Peter Chen 
> > ---
> >  drivers/usb/gadget/udc/udc-core.c | 28 +++-
> >  include/linux/usb/gadget.h|  5 +
> >  2 files changed, 32 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/gadget/udc/udc-core.c 
> > b/drivers/usb/gadget/udc/udc-core.c
> > index 9396a86..86d4d19 100644
> > --- a/drivers/usb/gadget/udc/udc-core.c
> > +++ b/drivers/usb/gadget/udc/udc-core.c
> > @@ -37,6 +37,7 @@
> >   * @list - for use by the udc class driver
> >   * @vbus - for udcs who care about vbus status, this value is real vbus 
> > status;
> >   * for udcs who do not care about vbus status, this value is always true
> > + * @deactivations - the deactivation count to connect or disconnect gadget
> 
> How will this field get initialized?
> 

Thanks, Alan.

The function driver will be deactivated default, the patch likes below:

http://permalink.gmane.org/gmane.linux.usb.general/112747

(Call usb_udc_activation_handler instead of usb_function_deactivate)

The function driver can activate itself at the .bind or on the demand.

http://permalink.gmane.org/gmane.linux.usb.general/112748
http://permalink.gmane.org/gmane.linux.usb.general/112752

> Aside from that question, patches 2 and 3 look good.
> 
> Alan Stern
> 

-- 

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


Re: [PATCHv2 2/2] USB: host: ohci_at91: Stop/start USB PLL for all sleep modes

2015-01-18 Thread Alexandre Belloni
On 17/01/2015 at 16:36:35 +0100, Sylvain Rochet wrote :
> Disable/unprepare clocks without testing the sleep target_state, removed
> the at91_suspend_entering_slow_clock() call (which is only a
> target_state == PM_SUSPEND_MEM).
> 
> Other kind of suspend now benefit from the power save induced by this
> PLL deactivation. The resume penalty is about 500 us, which is not
> negligible but acceptable considering the amount of power we are saving.
> 
> Signed-off-by: Sylvain Rochet 
> Reported-by: Boris Brezillon 
Acked-by: Alexandre Belloni 

> ---
>  drivers/usb/host/ohci-at91.c | 25 +
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
> index dc9e4e6..f0da734 100644
> --- a/drivers/usb/host/ohci-at91.c
> +++ b/drivers/usb/host/ohci-at91.c
> @@ -49,6 +49,8 @@ extern int usb_disabled(void);
>  
>  static void at91_start_clock(void)
>  {
> + if (clocked)
> + return;
>   if (IS_ENABLED(CONFIG_COMMON_CLK)) {
>   clk_set_rate(uclk, 4800);
>   clk_prepare_enable(uclk);
> @@ -61,6 +63,8 @@ static void at91_start_clock(void)
>  
>  static void at91_stop_clock(void)
>  {
> + if (!clocked)
> + return;
>   clk_disable_unprepare(fclk);
>   clk_disable_unprepare(iclk);
>   clk_disable_unprepare(hclk);
> @@ -615,16 +619,14 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, 
> pm_message_t mesg)
>*
>* REVISIT: some boards will be able to turn VBUS off...
>*/
> - if (at91_suspend_entering_slow_clock()) {
> - ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
> - ohci->hc_control &= OHCI_CTRL_RWC;
> - ohci_writel(ohci, ohci->hc_control, &ohci->regs->control);
> - ohci->rh_state = OHCI_RH_HALTED;
> -
> - /* flush the writes */
> - (void) ohci_readl (ohci, &ohci->regs->control);
> - at91_stop_clock();
> - }
> + ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
> + ohci->hc_control &= OHCI_CTRL_RWC;
> + ohci_writel(ohci, ohci->hc_control, &ohci->regs->control);
> + ohci->rh_state = OHCI_RH_HALTED;
> +
> + /* flush the writes */
> + (void) ohci_readl (ohci, &ohci->regs->control);
> + at91_stop_clock();
>  
>   return ret;
>  }
> @@ -636,8 +638,7 @@ static int ohci_hcd_at91_drv_resume(struct 
> platform_device *pdev)
>   if (device_may_wakeup(&pdev->dev))
>   disable_irq_wake(hcd->irq);
>  
> - if (!clocked)
> - at91_start_clock();
> + at91_start_clock();
>  
>   ohci_resume(hcd, false);
>   return 0;
> -- 
> 2.1.4
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] usb: gadget: uvc: comments for iterating over streaming hierarchy

2015-01-18 Thread Laurent Pinchart
Hi Andrzej,

Thank you for the patch.

On Friday 16 January 2015 15:14:28 Andrzej Pietrasiewicz wrote:
> The purpose of the functions and their parametrs might not be obvious
> to the reader, so explain it.
> 
> Signed-off-by: Andrzej Pietrasiewicz 
>
> ---
>  drivers/usb/gadget/function/uvc_configfs.c | 34 +++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/drivers/usb/gadget/function/uvc_configfs.c
> b/drivers/usb/gadget/function/uvc_configfs.c index 49f25e8..6fd40c5 100644
> --- a/drivers/usb/gadget/function/uvc_configfs.c
> +++ b/drivers/usb/gadget/function/uvc_configfs.c
> @@ -1918,6 +1918,25 @@ enum uvcg_strm_type {
>   UVCG_FRAME
>  };
> 
> +/*
> + * Iterate over a hierarchy of streaming descriptors' config items.
> + * The items are created by the user with configfs.
> + *
> + * It "processes" the header pointed to by @priv1, then for each format
> + * that follows the header "processes" the format itself and then for
> + * each frame inside a format "processes" the frame.
> + *
> + * As a "processing" function the @fun is used.
> + *
> + * __uvcg_iter_strm_cls() is used in two context: first, to calculate
> + * the amount of memory needed for an array of streaming descriptors
> + * and second, to actually fill the array.
> + *
> + * @priv1: an "in" parameter

As the priv1 argument is always a struct uvcg_streaming_header *, wouldn't it 
be more explicit to use that type instead of void *, with a proper name for 
the argument ?

> + * @priv2: an "inout" parameter (the caller might want to see the changes
> to it)
> + * @priv3: an "inout" parameter (the caller might want to see the changes
> to it)
> + * @fun: callback function for processing each level of the hierarchy
> + */
>  static int __uvcg_iter_strm_cls(void *priv1, void *priv2, void *priv3,
>   int (*fun)(void *, void *, void *, int, enum uvcg_strm_type type))
>  {
> @@ -1951,6 +1970,14 @@ static int __uvcg_iter_strm_cls(void *priv1, void
> *priv2, void *priv3, return ret;
>  }
> 
> +/*
> + * Count how many bytes are needed for an array of streaming descriptors.
> + *
> + * @priv1: pointer to a header, format or frame
> + * @priv2: inout parameter, accumulated size of the array
> + * @priv3: inout parameter, accumulated number of the array elements
> + * @n: unused, this function's prototype must match @fun in
> __uvcg_iter_strm_cls + */
>  static int __uvcg_cnt_strm(void *priv1, void *priv2, void *priv3, int n,
>  enum uvcg_strm_type type)
>  {
> @@ -2000,6 +2027,13 @@ static int __uvcg_cnt_strm(void *priv1, void *priv2,
> void *priv3, int n, return 0;
>  }
> 
> +/*
> + * Fill an array of streaming descriptors.
> + *
> + * @priv1: pointer to a header, format or frame
> + * @priv2: inout parameter, pointer into a block of memory
> + * @priv3: inout parameter, pointer to a 2-dimensional array
> + */
>  static int __uvcg_fill_strm(void *priv1, void *priv2, void *priv3, int n,
>   enum uvcg_strm_type type)
>  {

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH 2/3] usb: gadget: uvc: preserve the address passed to kfree()

2015-01-18 Thread Laurent Pinchart
Hi Andrzej,

Thank you for the patch.

On Friday 16 January 2015 15:14:27 Andrzej Pietrasiewicz wrote:
> __uvcg_fill_strm() called from __uvcg_iter_stream_cls()
> might have advanced the "data" even if __uvcg_iter_stream_cls()
> returns an error, so use a backup copy as an argument to kfree().
> 
> Signed-off-by: Andrzej Pietrasiewicz 

Acked-by: Laurent Pinchart 

> ---
>  drivers/usb/gadget/function/uvc_configfs.c | 10 +++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/uvc_configfs.c
> b/drivers/usb/gadget/function/uvc_configfs.c index cc2a613..49f25e8 100644
> --- a/drivers/usb/gadget/function/uvc_configfs.c
> +++ b/drivers/usb/gadget/function/uvc_configfs.c
> @@ -2086,7 +2086,7 @@ static int uvcg_streaming_class_allow_link(struct
> config_item *src, struct mutex *su_mutex =
> &src->ci_group->cg_subsys->su_mutex;
>   struct uvc_descriptor_header ***class_array, **cl_arr;
>   struct uvcg_streaming_header *target_hdr;
> - void *data;
> + void *data, *data_save;
>   size_t size = 0, count = 0;
>   int ret = -EINVAL;
> 
> @@ -2119,7 +2119,7 @@ static int uvcg_streaming_class_allow_link(struct
> config_item *src, goto unlock;
>   }
> 
> - data = kzalloc(size, GFP_KERNEL);
> + data = data_save = kzalloc(size, GFP_KERNEL);
>   if (!data) {
>   kfree(*class_array);
>   *class_array = NULL;
> @@ -2132,7 +2132,11 @@ static int uvcg_streaming_class_allow_link(struct
> config_item *src, if (ret) {
>   kfree(*class_array);
>   *class_array = NULL;
> - kfree(data);
> + /*
> +  * __uvcg_fill_strm() called from __uvcg_iter_stream_cls()
> +  * might have advanced the "data", so use a backup copy
> +  */
> + kfree(data_save);
>   goto unlock;
>   }
>   *cl_arr = (struct uvc_descriptor_header *)&opts->uvc_color_matching;

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH 1/3] Revert "usb: gadget: uvc: cleanup __uvcg_fill_strm()"

2015-01-18 Thread Laurent Pinchart
Hi Andrzej,

Thank you for the patch.

On Friday 16 January 2015 15:14:26 Andrzej Pietrasiewicz wrote:
> This reverts commit c0b53cb16250 ("usb: gadget: uvc: cleanup
> __uvcg_fill_strm()").

I can't find that commit in Linus' master, next/master or Felipe's next 
branch. If the patch hasn't been applied there's no need to revert it :-)

> __uvcg_fill_stream() during its execution uses priv2 as a pointer
> to a pointer, because it advances the current position by the amount
> of data taken by each processed descriptor and the advanced position
> should be visible outside this function, so that the next time it is
> called, the current position corresponds to the place where it was
> the last time rather than again at the beginning of some block of data.
> In other words priv2 is an "out" parameter.
> 
> Signed-off-by: Andrzej Pietrasiewicz 
> ---
>  drivers/usb/gadget/function/uvc_configfs.c | 39 +-
>  1 file changed, 20 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/uvc_configfs.c
> b/drivers/usb/gadget/function/uvc_configfs.c index 8a6cd61..cc2a613 100644
> --- a/drivers/usb/gadget/function/uvc_configfs.c
> +++ b/drivers/usb/gadget/function/uvc_configfs.c
> @@ -2000,27 +2000,28 @@ static int __uvcg_cnt_strm(void *priv1, void *priv2,
> void *priv3, int n, return 0;
>  }
> 
> -static int __uvcg_fill_strm(void *priv1, void *dest, void *priv3, int n,
> +static int __uvcg_fill_strm(void *priv1, void *priv2, void *priv3, int n,
>   enum uvcg_strm_type type)
>  {
> + void **dest = priv2;
>   struct uvc_descriptor_header ***array = priv3;
>   size_t sz;
> 
> - **array = dest;
> + **array = *dest;
>   ++*array;
> 
>   switch (type) {
>   case UVCG_HEADER: {
> - struct uvc_input_header_descriptor *ihdr = dest;
> + struct uvc_input_header_descriptor *ihdr = *dest;
>   struct uvcg_streaming_header *h = priv1;
>   struct uvcg_format_ptr *f;
> 
> - memcpy(dest, &h->desc, sizeof(h->desc));
> - dest += sizeof(h->desc);
> + memcpy(*dest, &h->desc, sizeof(h->desc));
> + *dest += sizeof(h->desc);
>   sz = UVCG_STREAMING_CONTROL_SIZE;
>   list_for_each_entry(f, &h->formats, entry) {
> - memcpy(dest, f->fmt->bmaControls, sz);
> - dest += sz;
> + memcpy(*dest, f->fmt->bmaControls, sz);
> + *dest += sz;
>   }
>   ihdr->bLength = sizeof(h->desc) + h->num_fmt * sz;
>   ihdr->bNumFormats = h->num_fmt;
> @@ -2030,22 +2031,22 @@ static int __uvcg_fill_strm(void *priv1, void *dest,
> void *priv3, int n, struct uvcg_format *fmt = priv1;
> 
>   if (fmt->type == UVCG_UNCOMPRESSED) {
> - struct uvc_format_uncompressed *unc = dest;
> + struct uvc_format_uncompressed *unc = *dest;
>   struct uvcg_uncompressed *u =
>   container_of(fmt, struct uvcg_uncompressed,
>fmt);
> 
> - memcpy(dest, &u->desc, sizeof(u->desc));
> - dest += sizeof(u->desc);
> + memcpy(*dest, &u->desc, sizeof(u->desc));
> + *dest += sizeof(u->desc);
>   unc->bNumFrameDescriptors = fmt->num_frames;
>   unc->bFormatIndex = n + 1;
>   } else if (fmt->type == UVCG_MJPEG) {
> - struct uvc_format_mjpeg *mjp = dest;
> + struct uvc_format_mjpeg *mjp = *dest;
>   struct uvcg_mjpeg *m =
>   container_of(fmt, struct uvcg_mjpeg, fmt);
> 
> - memcpy(dest, &m->desc, sizeof(m->desc));
> - dest += sizeof(m->desc);
> + memcpy(*dest, &m->desc, sizeof(m->desc));
> + *dest += sizeof(m->desc);
>   mjp->bNumFrameDescriptors = fmt->num_frames;
>   mjp->bFormatIndex = n + 1;
>   } else {
> @@ -2055,15 +2056,15 @@ static int __uvcg_fill_strm(void *priv1, void *dest,
> void *priv3, int n, break;
>   case UVCG_FRAME: {
>   struct uvcg_frame *frm = priv1;
> - struct uvc_descriptor_header *h = dest;
> + struct uvc_descriptor_header *h = *dest;
> 
>   sz = sizeof(frm->frame);
> - memcpy(dest, &frm->frame, sz);
> - dest += sz;
> + memcpy(*dest, &frm->frame, sz);
> + *dest += sz;
>   sz = frm->frame.b_frame_interval_type *
>   sizeof(*frm->dw_frame_interval);
> - memcpy(dest, frm->dw_frame_interval, sz);
> - dest += sz;
> + memcpy(*dest, frm->dw_frame_interval, sz);
> + *dest += sz;
>   i

Re: [patch 6/6] usb: gadget: uvc: cleanup UVCG_FRAME_ATTR macro

2015-01-18 Thread Laurent Pinchart
Hi Dan,

Thank you for the patch.

On Thursday 15 January 2015 00:06:35 Dan Carpenter wrote:
> 1) Change "conv" an "vnoc" to "to_cpu_endian" to "to_little_endian".
> 2) No need to check the "limit" because that is already handled in
>kstrtoXX so delete that parameter along with the check.
> 3) By using a "bits" parameter, we can combine the "uxx" parameter and
>the "str2u" parameters.
> 4) The kstrtou##bits() conversion does not need to be done under the
>mutex so move it to the start of the function.
> 5) Change the name of "identity_conv" to "noop_conversion".
> 
> Signed-off-by: Dan Carpenter 

Acked-by: Laurent Pinchart 

> ---
> This file has a couple pages of Sparse endian warnings.
> http://lwn.net/Articles/205624/
> It's hard to review the static checker warnings when there are so many.
> 
> diff --git a/drivers/usb/gadget/function/uvc_configfs.c
> b/drivers/usb/gadget/function/uvc_configfs.c index a0443a2..87beb8c 100644
> --- a/drivers/usb/gadget/function/uvc_configfs.c
> +++ b/drivers/usb/gadget/function/uvc_configfs.c
> @@ -1032,7 +1032,7 @@ static struct configfs_item_operations
> uvcg_frame_item_ops = { .store_attribute  = uvcg_frame_attr_store,
>  };
> 
> -#define UVCG_FRAME_ATTR(cname, aname, conv, str2u, uxx, vnoc, limit) \
> +#define UVCG_FRAME_ATTR(cname, aname, to_cpu_endian, to_little_endian,
> bits) \ static ssize_t uvcg_frame_##cname##_show(struct uvcg_frame *f, char
> *page)\ { 
> \
>   struct f_uvc_opts *opts;\
> @@ -1046,7 +1046,7 @@ static ssize_t uvcg_frame_##cname##_show(struct
> uvcg_frame *f, char *page)\ opts = to_f_uvc_opts(opts_item);  
> \
>   \
>   mutex_lock(&opts->lock);\
> - result = sprintf(page, "%d\n", conv(f->frame.cname));   \
> + result = sprintf(page, "%d\n", to_cpu_endian(f->frame.cname));  \
>   mutex_unlock(&opts->lock);  \
>   \
>   mutex_unlock(su_mutex); \
> @@ -1061,7 +1061,11 @@ static ssize_t  uvcg_frame_##cname##_store(struct
> uvcg_frame *f,\ struct uvcg_format *fmt;  
> \
>   struct mutex *su_mutex = &f->item.ci_group->cg_subsys->su_mutex;\
>   int ret;\
> - uxx num;\
> + u##bits num;\
> + \
> + ret = kstrtou##bits(page, 0, &num); \
> + if (ret)\
> + return ret; \
>   \
>   mutex_lock(su_mutex); /* for navigating configfs hierarchy */   \
>   \
> @@ -1075,15 +1079,7 @@ static ssize_t  uvcg_frame_##cname##_store(struct
> uvcg_frame *f,\ goto end; 
> \
>   }   \
>   \
> - ret = str2u(page, 0, &num); \
> - if (ret)\
> - goto end;   \
> - \
> - if (num > limit) {  \
> - ret = -EINVAL;  \
> - goto end;   \
> - }   \
> - f->frame.cname = vnoc(num); \
> + f->frame.cname = to_little_endian(num); \
>   ret = len;  \
>  end: \
>   mutex_unlock(&opts->lock);  \
> @@ -1097,24 +1093,20 @@ static struct uvcg_frame_attribute
> 
\
>   uvcg_frame_##cname##_show,  \
>   uvcg_frame_##cname##_store)
> 
> -#define identity_conv(x) (x)
> +#define noop_conversion(x) (x)
> 
> -UVCG_FRAME_ATTR(bm_capabilities, bmCapabilities, identity_conv, kstrtou8,
> u8, - identity_conv, 0xFF);
> -UVCG_FRAME_ATTR(w_width, wWidth, le16_to_cpu, kstrtou16, u

Re: [patch 4/6] usb: gadget: uvc: memory leak in uvcg_frame_make()

2015-01-18 Thread Laurent Pinchart
Hi Dan,

Thank you for the patch.

On Thursday 15 January 2015 00:03:08 Dan Carpenter wrote:
> We need to add a kfree(h) on an error path.
> 
> Signed-off-by: Dan Carpenter 

Acked-by: Laurent Pinchart 

> diff --git a/drivers/usb/gadget/function/uvc_configfs.c
> b/drivers/usb/gadget/function/uvc_configfs.c index 738d68f..1af2686 100644
> --- a/drivers/usb/gadget/function/uvc_configfs.c
> +++ b/drivers/usb/gadget/function/uvc_configfs.c
> @@ -1300,6 +1300,7 @@ static struct config_item *uvcg_frame_make(struct
> config_group *group, h->fmt_type = UVCG_MJPEG;
>   } else {
>   mutex_unlock(&opts->lock);
> + kfree(h);
>   return ERR_PTR(-EINVAL);
>   }
>   ++fmt->num_frames;

-- 
Regards,

Laurent Pinchart

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


Re: [patch 3/6] usb: gadget: uvc: remove an impossible condition

2015-01-18 Thread Laurent Pinchart
Hi Dan,

Thank you for the patch.

On Thursday 15 January 2015 00:02:18 Dan Carpenter wrote:
> "num" is a u32 so "(num > 0x)" is never true.  Also the range
> is already checked in kstrtou32().
> 
> Signed-off-by: Dan Carpenter 

Acked-by: Laurent Pinchart 

> diff --git a/drivers/usb/gadget/function/uvc_configfs.c
> b/drivers/usb/gadget/function/uvc_configfs.c index 2bd0688..738d68f 100644
> --- a/drivers/usb/gadget/function/uvc_configfs.c
> +++ b/drivers/usb/gadget/function/uvc_configfs.c
> @@ -1156,8 +1156,6 @@ static inline int __uvcg_fill_frm_intrv(char *buf,
> void *priv) ret = kstrtou32(buf, 0, &num);
>   if (ret)
>   return ret;
> - if (num > 0x)
> - return -EINVAL;
> 
>   interv = priv;
>   **interv = cpu_to_le32(num);

-- 
Regards,

Laurent Pinchart

--
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/6] usb: gadget: uvc: fix some error codes

2015-01-18 Thread Laurent Pinchart
Hi Dan,

Thank you for the patch.

On Wednesday 14 January 2015 23:59:48 Dan Carpenter wrote:
> We're basically saying ERR_CAST(NULL) and PTR_ERR(NULL) here, which is
> nonsensical.
> 
> Signed-off-by: Dan Carpenter 

Acked-by: Laurent Pinchart 

> diff --git a/drivers/usb/gadget/function/uvc_configfs.c
> b/drivers/usb/gadget/function/uvc_configfs.c index 33d92ab..d112c99 100644
> --- a/drivers/usb/gadget/function/uvc_configfs.c
> +++ b/drivers/usb/gadget/function/uvc_configfs.c
> @@ -148,7 +148,7 @@ static struct config_item
> *uvcg_control_header_make(struct config_group *group,
> 
>   h = kzalloc(sizeof(*h), GFP_KERNEL);
>   if (!h)
> - return ERR_CAST(h);
> + return ERR_PTR(-ENOMEM);
> 
>   h->desc.bLength = UVC_DT_HEADER_SIZE(1);
>   h->desc.bDescriptorType = USB_DT_CS_INTERFACE;
> @@ -840,7 +840,7 @@ static int uvcg_streaming_header_allow_link(struct
> config_item *src,
> 
>   format_ptr = kzalloc(sizeof(*format_ptr), GFP_KERNEL);
>   if (!format_ptr) {
> - ret = PTR_ERR(format_ptr);
> + ret = -ENOMEM;
>   goto out;
>   }
>   ret = 0;
> @@ -960,7 +960,7 @@ static struct config_item
> 
>   h = kzalloc(sizeof(*h), GFP_KERNEL);
>   if (!h)
> - return ERR_CAST(h);
> + return ERR_PTR(-ENOMEM);
> 
>   INIT_LIST_HEAD(&h->formats);
>   h->desc.bDescriptorType = USB_DT_CS_INTERFACE;
> @@ -1278,7 +1278,7 @@ static struct config_item *uvcg_frame_make(struct
> config_group *group,
> 
>   h = kzalloc(sizeof(*h), GFP_KERNEL);
>   if (!h)
> - return ERR_CAST(h);
> + return ERR_PTR(-ENOMEM);
> 
>   h->frame.b_descriptor_type  = USB_DT_CS_INTERFACE;
>   h->frame.b_frame_index  = 1;
> @@ -1563,7 +1563,7 @@ static struct config_group
> *uvcg_uncompressed_make(struct config_group *group,
> 
>   h = kzalloc(sizeof(*h), GFP_KERNEL);
>   if (!h)
> - return ERR_CAST(h);
> + return ERR_PTR(-ENOMEM);
> 
>   h->desc.bLength = UVC_DT_FORMAT_UNCOMPRESSED_SIZE;
>   h->desc.bDescriptorType = USB_DT_CS_INTERFACE;
> @@ -1772,7 +1772,7 @@ static struct config_group *uvcg_mjpeg_make(struct
> config_group *group,
> 
>   h = kzalloc(sizeof(*h), GFP_KERNEL);
>   if (!h)
> - return ERR_CAST(h);
> + return ERR_PTR(-ENOMEM);
> 
>   h->desc.bLength = UVC_DT_FORMAT_MJPEG_SIZE;
>   h->desc.bDescriptorType = USB_DT_CS_INTERFACE;
> @@ -2124,7 +2124,7 @@ static int uvcg_streaming_class_allow_link(struct
> config_item *src, count += 2; /* color_matching, NULL */
>   *class_array = kcalloc(count, sizeof(void *), GFP_KERNEL);
>   if (!*class_array) {
> - ret = PTR_ERR(*class_array);
> + ret = -ENOMEM;
>   goto unlock;
>   }

-- 
Regards,

Laurent Pinchart

--
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 23/23] wusbcore: rh: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare numbers to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/wusbcore/rh.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: usb/drivers/usb/wusbcore/rh.c
===
--- usb.orig/drivers/usb/wusbcore/rh.c
+++ usb/drivers/usb/wusbcore/rh.c
@@ -185,9 +185,9 @@ static int wusbhc_rh_get_hub_descr(struc
descr->bDescriptorType = 0x29;  /* HUB type */
descr->bNbrPorts = wusbhc->ports_max;
descr->wHubCharacteristics = cpu_to_le16(
-   0x00/* All ports power at once */
+   HUB_CHAR_COMMON_LPSM/* All ports power at once */
| 0x00  /* not part of compound device */
-   | 0x10  /* No overcurrent protection */
+   | HUB_CHAR_NO_OCPM  /* No overcurrent protection */
| 0x00  /* 8 FS think time FIXME ?? */
| 0x00);/* No port indicators */
descr->bPwrOn2PwrGood = 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


[PATCH 22/23] usbip: vhci_hcd: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare number  to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/usbip/vhci_hcd.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: usb/drivers/usb/usbip/vhci_hcd.c
===
--- usb.orig/drivers/usb/usbip/vhci_hcd.c
+++ usb/drivers/usb/usbip/vhci_hcd.c
@@ -218,7 +218,8 @@ static inline void hub_descriptor(struct
memset(desc, 0, sizeof(*desc));
desc->bDescriptorType = 0x29;
desc->bDescLength = 9;
-   desc->wHubCharacteristics = (__constant_cpu_to_le16(0x0001));
+   desc->wHubCharacteristics = __constant_cpu_to_le16(
+   HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_COMMON_OCPM);
desc->bNbrPorts = VHCI_NPORTS;
desc->u.hs.DeviceRemovable[0] = 0xff;
desc->u.hs.DeviceRemovable[1] = 0xff;

--
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 21/23] renesas_usbhs: mod_host: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare number  to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/renesas_usbhs/mod_host.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: usb/drivers/usb/renesas_usbhs/mod_host.c
===
--- usb.orig/drivers/usb/renesas_usbhs/mod_host.c
+++ usb/drivers/usb/renesas_usbhs/mod_host.c
@@ -1234,7 +1234,8 @@ static int __usbhsh_hub_get_status(struc
desc->bNbrPorts = roothub_id;
desc->bDescLength   = 9;
desc->bPwrOn2PwrGood= 0;
-   desc->wHubCharacteristics   = cpu_to_le16(0x0011);
+   desc->wHubCharacteristics   =
+   cpu_to_le16(HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_NO_OCPM);
desc->u.hs.DeviceRemovable[0]   = (roothub_id << 1);
desc->u.hs.DeviceRemovable[1]   = ~0;
dev_dbg(dev, "%s :: GetHubDescriptor\n", __func__);

--
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 20/23] musb_virthub: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare numbers to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/musb/musb_virthub.c |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

Index: usb/drivers/usb/musb/musb_virthub.c
===
--- usb.orig/drivers/usb/musb/musb_virthub.c
+++ usb/drivers/usb/musb/musb_virthub.c
@@ -349,9 +349,10 @@ int musb_hub_control(
desc->bDescriptorType = 0x29;
desc->bNbrPorts = 1;
desc->wHubCharacteristics = cpu_to_le16(
- 0x0001/* per-port power switching */
-   | 0x0010/* no overcurrent reporting */
-   );
+ HUB_CHAR_INDV_PORT_LPSM /* per-port power switching */
+
+   | HUB_CHAR_NO_OCPM  /* no overcurrent reporting */
+   );
desc->bPwrOn2PwrGood = 5;   /* msec/2 */
desc->bHubContrCurrent = 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


[PATCH 19/23] dummy_hcd: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare numbers to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/gadget/udc/dummy_hcd.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Index: usb/drivers/usb/gadget/udc/dummy_hcd.c
===
--- usb.orig/drivers/usb/gadget/udc/dummy_hcd.c
+++ usb/drivers/usb/gadget/udc/dummy_hcd.c
@@ -1924,7 +1924,9 @@ ss_hub_descriptor(struct usb_hub_descrip
memset(desc, 0, sizeof *desc);
desc->bDescriptorType = 0x2a;
desc->bDescLength = 12;
-   desc->wHubCharacteristics = cpu_to_le16(0x0001);
+   desc->wHubCharacteristics = cpu_to_le16(
+   HUB_CHAR_INDV_PORT_LPSM |
+   HUB_CHAR_COMMON_OCPM);
desc->bNbrPorts = 1;
desc->u.ss.bHubHdrDecLat = 0x04; /* Worst case: 0.4 micro sec*/
desc->u.ss.DeviceRemovable = 0x;
@@ -1935,7 +1937,9 @@ static inline void hub_descriptor(struct
memset(desc, 0, sizeof *desc);
desc->bDescriptorType = 0x29;
desc->bDescLength = 9;
-   desc->wHubCharacteristics = cpu_to_le16(0x0001);
+   desc->wHubCharacteristics = cpu_to_le16(
+   HUB_CHAR_INDV_PORT_LPSM |
+   HUB_CHAR_COMMON_OCPM);
desc->bNbrPorts = 1;
desc->u.hs.DeviceRemovable[0] = 0xff;
desc->u.hs.DeviceRemovable[1] = 0xff;

--
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 18/23] dwc2: hcd: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare number  to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/dwc2/hcd.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: usb/drivers/usb/dwc2/hcd.c
===
--- usb.orig/drivers/usb/dwc2/hcd.c
+++ usb/drivers/usb/dwc2/hcd.c
@@ -1622,7 +1622,9 @@ static int dwc2_hcd_hub_control(struct d
hub_desc->bDescLength = 9;
hub_desc->bDescriptorType = 0x29;
hub_desc->bNbrPorts = 1;
-   hub_desc->wHubCharacteristics = cpu_to_le16(0x08);
+   hub_desc->wHubCharacteristics =
+   cpu_to_le16(HUB_CHAR_COMMON_LPSM |
+   HUB_CHAR_INDV_PORT_OCPM);
hub_desc->bPwrOn2PwrGood = 1;
hub_desc->bHubContrCurrent = 0;
hub_desc->u.hs.DeviceRemovable[0] = 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


[PATCH 17/23] uhci-hub: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare number  to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/host/uhci-hub.c |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Index: usb/drivers/usb/host/uhci-hub.c
===
--- usb.orig/drivers/usb/host/uhci-hub.c
+++ usb/drivers/usb/host/uhci-hub.c
@@ -17,8 +17,9 @@ static const __u8 root_hub_hub_des[] =
0x09,   /*  __u8  bLength; */
0x29,   /*  __u8  bDescriptorType; Hub-descriptor */
0x02,   /*  __u8  bNbrPorts; */
-   0x0a,   /* __u16  wHubCharacteristics; */
-   0x00,   /*   (per-port OC, no power switching) */
+   HUB_CHAR_NO_LPSM |  /* __u16  wHubCharacteristics; */
+   HUB_CHAR_INDV_PORT_OCPM, /* (per-port OC, no power switching) */
+   0x00,
0x01,   /*  __u8  bPwrOn2pwrGood; 2ms */
0x00,   /*  __u8  bHubContrCurrent; 0 mA */
0x00,   /*  __u8  DeviceRemovable; *** 7 Ports max */

--
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 16/23] u132-hcd: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare numbers to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/host/u132-hcd.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

Index: usb/drivers/usb/host/u132-hcd.c
===
--- usb.orig/drivers/usb/host/u132-hcd.c
+++ usb/drivers/usb/host/u132-hcd.c
@@ -2590,15 +2590,15 @@ static int u132_roothub_descriptor(struc
desc->bNbrPorts = u132->num_ports;
temp = 1 + (u132->num_ports / 8);
desc->bDescLength = 7 + 2 * temp;
-   temp = 0;
+   temp = HUB_CHAR_COMMON_LPSM | HUB_CHAR_COMMON_OCPM;
if (rh_a & RH_A_NPS)
-   temp |= 0x0002;
+   temp |= HUB_CHAR_NO_LPSM;
if (rh_a & RH_A_PSM)
-   temp |= 0x0001;
+   temp |= HUB_CHAR_INDV_PORT_LPSM;
if (rh_a & RH_A_NOCP)
-   temp |= 0x0010;
+   temp |= HUB_CHAR_NO_OCPM;
else if (rh_a & RH_A_OCPM)
-   temp |= 0x0008;
+   temp |= HUB_CHAR_INDV_PORT_OCPM;
desc->wHubCharacteristics = cpu_to_le16(temp);
retval = u132_read_pcimem(u132, roothub.b, &rh_b);
if (retval)

--
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 15/23] sl811-hcd: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare numbers to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/host/sl811-hcd.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: usb/drivers/usb/host/sl811-hcd.c
===
--- usb.orig/drivers/usb/host/sl811-hcd.c
+++ usb/drivers/usb/host/sl811-hcd.c
@@ -1103,12 +1103,12 @@ sl811h_hub_descriptor (
desc->bPwrOn2PwrGood = sl811->board->potpg;
if (!desc->bPwrOn2PwrGood)
desc->bPwrOn2PwrGood = 10;
-   temp = 0x0001;
+   temp = HUB_CHAR_INDV_PORT_LPSM;
} else
-   temp = 0x0002;
+   temp = HUB_CHAR_NO_LPSM;
 
/* no overcurrent errors detection/handling */
-   temp |= 0x0010;
+   temp |= HUB_CHAR_NO_OCPM;
 
desc->wHubCharacteristics = cpu_to_le16(temp);
 

--
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 14/23] r8a66597-hcd: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare number  to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/host/r8a66597-hcd.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: usb/drivers/usb/host/r8a66597-hcd.c
===
--- usb.orig/drivers/usb/host/r8a66597-hcd.c
+++ usb/drivers/usb/host/r8a66597-hcd.c
@@ -2141,7 +2141,8 @@ static void r8a66597_hub_descriptor(stru
desc->bNbrPorts = r8a66597->max_root_hub;
desc->bDescLength = 9;
desc->bPwrOn2PwrGood = 0;
-   desc->wHubCharacteristics = cpu_to_le16(0x0011);
+   desc->wHubCharacteristics =
+   cpu_to_le16(HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_NO_OCPM);
desc->u.hs.DeviceRemovable[0] =
((1 << r8a66597->max_root_hub) - 1) << 1;
desc->u.hs.DeviceRemovable[1] = ~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


[PATCH 13/23] oxu210hp-hcd: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare numbers to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/host/oxu210hp-hcd.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: usb/drivers/usb/host/oxu210hp-hcd.c
===
--- usb.orig/drivers/usb/host/oxu210hp-hcd.c
+++ usb/drivers/usb/host/oxu210hp-hcd.c
@@ -457,11 +457,11 @@ static void ehci_hub_descriptor(struct o
memset(&desc->u.hs.DeviceRemovable[0], 0, temp);
memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
 
-   temp = 0x0008;  /* per-port overcurrent reporting */
+   temp = HUB_CHAR_INDV_PORT_OCPM; /* per-port overcurrent reporting */
if (HCS_PPC(oxu->hcs_params))
-   temp |= 0x0001; /* per-port power control */
+   temp |= HUB_CHAR_INDV_PORT_LPSM; /* per-port power control */
else
-   temp |= 0x0002; /* no power switching */
+   temp |= HUB_CHAR_NO_LPSM; /* no power switching */
desc->wHubCharacteristics = (__force __u16)cpu_to_le16(temp);
 }
 

--
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 12/23] ohci-s3c2410: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare numbers to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

While at it, stop setting already set HUB_CHAR_INDV_PORT_LPSM once again.

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/host/ohci-s3c2410.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: usb/drivers/usb/host/ohci-s3c2410.c
===
--- usb.orig/drivers/usb/host/ohci-s3c2410.c
+++ usb/drivers/usb/host/ohci-s3c2410.c
@@ -249,14 +249,14 @@ static int ohci_s3c2410_hub_control(
 */
 
desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM);
-   desc->wHubCharacteristics |= cpu_to_le16(0x0001);
+   desc->wHubCharacteristics |= cpu_to_le16(
+   HUB_CHAR_INDV_PORT_LPSM);
 
if (info->enable_oc) {
desc->wHubCharacteristics &= ~cpu_to_le16(
HUB_CHAR_OCPM);
desc->wHubCharacteristics |=  cpu_to_le16(
-   0x0008 |
-   0x0001);
+   HUB_CHAR_INDV_PORT_OCPM);
}
 
dev_dbg(hcd->self.controller, "wHubCharacteristics after 
0x%04x\n",

--
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 11/23] ohci-hub: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare numbers to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

While at it, fix the indentation.

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/host/ohci-hub.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

Index: usb/drivers/usb/host/ohci-hub.c
===
--- usb.orig/drivers/usb/host/ohci-hub.c
+++ usb/drivers/usb/host/ohci-hub.c
@@ -544,15 +544,15 @@ ohci_hub_descriptor (
temp = 1 + (ohci->num_ports / 8);
desc->bDescLength = 7 + 2 * temp;
 
-   temp = 0;
+   temp = HUB_CHAR_COMMON_LPSM | HUB_CHAR_COMMON_OCPM;
if (rh & RH_A_NPS)  /* no power switching? */
-   temp |= 0x0002;
+   temp |= HUB_CHAR_NO_LPSM;
if (rh & RH_A_PSM)  /* per-port power switching? */
-   temp |= 0x0001;
+   temp |= HUB_CHAR_INDV_PORT_LPSM;
if (rh & RH_A_NOCP) /* no overcurrent reporting? */
-   temp |= 0x0010;
+   temp |= HUB_CHAR_NO_OCPM;
else if (rh & RH_A_OCPM)/* per-port overcurrent reporting? */
-   temp |= 0x0008;
+   temp |= HUB_CHAR_INDV_PORT_OCPM;
desc->wHubCharacteristics = cpu_to_le16(temp);
 
/* ports removable, and usb 1.0 legacy PortPwrCtrlMask */

--
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 10/23] ohci-at91: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare numbers to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

While at it, stop setting already set HUB_CHAR_INDV_PORT_LPSM once again.

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/host/ohci-at91.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

Index: usb/drivers/usb/host/ohci-at91.c
===
--- usb.orig/drivers/usb/host/ohci-at91.c
+++ usb/drivers/usb/host/ohci-at91.c
@@ -347,11 +347,13 @@ static int ohci_at91_hub_control(struct
 */
 
desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM);
-   desc->wHubCharacteristics |= cpu_to_le16(0x0001);
+   desc->wHubCharacteristics |=
+   cpu_to_le16(HUB_CHAR_INDV_PORT_LPSM);
 
if (pdata->overcurrent_supported) {
desc->wHubCharacteristics &= 
~cpu_to_le16(HUB_CHAR_OCPM);
-   desc->wHubCharacteristics |=  
cpu_to_le16(0x0008|0x0001);
+   desc->wHubCharacteristics |=
+   cpu_to_le16(HUB_CHAR_INDV_PORT_OCPM);
}
 
dev_dbg(hcd->self.controller, "wHubCharacteristics after 
0x%04x\n",

--
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 09/23] max3421-hcd: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare number  to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/host/max3421-hcd.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: usb/drivers/usb/host/max3421-hcd.c
===
--- usb.orig/drivers/usb/host/max3421-hcd.c
+++ usb/drivers/usb/host/max3421-hcd.c
@@ -1661,7 +1661,8 @@ hub_descriptor(struct usb_hub_descriptor
 */
desc->bDescriptorType = 0x29;   /* hub descriptor */
desc->bDescLength = 9;
-   desc->wHubCharacteristics = cpu_to_le16(0x0001);
+   desc->wHubCharacteristics = cpu_to_le16(HUB_CHAR_INDV_PORT_LPSM |
+   HUB_CHAR_COMMON_OCPM);
desc->bNbrPorts = 1;
 }
 

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


[PATCH 08/23] isp1760-hcd: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare numbers to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/host/isp1760-hcd.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: usb/drivers/usb/host/isp1760-hcd.c
===
--- usb.orig/drivers/usb/host/isp1760-hcd.c
+++ usb/drivers/usb/host/isp1760-hcd.c
@@ -1796,13 +1796,13 @@ static void isp1760_hub_descriptor(struc
memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
 
/* per-port overcurrent reporting */
-   temp = 0x0008;
+   temp = HUB_CHAR_INDV_PORT_OCPM;
if (HCS_PPC(priv->hcs_params))
/* per-port power control */
-   temp |= 0x0001;
+   temp |= HUB_CHAR_INDV_PORT_LPSM;
else
/* no power switching */
-   temp |= 0x0002;
+   temp |= HUB_CHAR_NO_LPSM;
desc->wHubCharacteristics = cpu_to_le16(temp);
 }
 

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


[PATCH 07/23] isp1362-hcd: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare numbers to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

While at it, avoid duplicate computation when calling DBG().

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/host/isp1362-hcd.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Index: usb/drivers/usb/host/isp1362-hcd.c
===
--- usb.orig/drivers/usb/host/isp1362-hcd.c
+++ usb/drivers/usb/host/isp1362-hcd.c
@@ -1543,8 +1543,12 @@ static void isp1362_hub_descriptor(struc
desc->bHubContrCurrent = 0;
desc->bNbrPorts = reg & 0x3;
/* Power switching, device type, overcurrent. */
-   desc->wHubCharacteristics = cpu_to_le16((reg >> 8) & 0x1f);
-   DBG(0, "%s: hubcharacteristics = %02x\n", __func__, cpu_to_le16((reg >> 
8) & 0x1f));
+   desc->wHubCharacteristics = cpu_to_le16((reg >> 8) &
+   (HUB_CHAR_LPSM |
+HUB_CHAR_COMPOUND |
+HUB_CHAR_OCPM));
+   DBG(0, "%s: hubcharacteristics = %02x\n", __func__,
+   desc->wHubCharacteristics);
desc->bPwrOn2PwrGood = (reg >> 24) & 0xff;
/* ports removable, and legacy PortPwrCtrlMask */
desc->u.hs.DeviceRemovable[0] = desc->bNbrPorts == 1 ? 1 << 1 : 3 << 1;

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


[PATCH 06/23] isp116x-hcd: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare number  to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/host/isp116x-hcd.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

Index: usb/drivers/usb/host/isp116x-hcd.c
===
--- usb.orig/drivers/usb/host/isp116x-hcd.c
+++ usb/drivers/usb/host/isp116x-hcd.c
@@ -948,7 +948,10 @@ static void isp116x_hub_descriptor(struc
desc->bHubContrCurrent = 0;
desc->bNbrPorts = (u8) (reg & 0x3);
/* Power switching, device type, overcurrent. */
-   desc->wHubCharacteristics = cpu_to_le16((u16) ((reg >> 8) & 0x1f));
+   desc->wHubCharacteristics = cpu_to_le16((u16) ((reg >> 8) &
+  (HUB_CHAR_LPSM |
+   HUB_CHAR_COMPOUND |
+   HUB_CHAR_OCPM)));
desc->bPwrOn2PwrGood = (u8) ((reg >> 24) & 0xff);
/* ports removable, and legacy PortPwrCtrlMask */
desc->u.hs.DeviceRemovable[0] = 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


[PATCH 05/23] imx21-hcd: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare numbers to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/host/imx21-hcd.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Index: usb/drivers/usb/host/imx21-hcd.c
===
--- usb.orig/drivers/usb/host/imx21-hcd.c
+++ usb/drivers/usb/host/imx21-hcd.c
@@ -1482,9 +1482,8 @@ static int get_hub_descriptor(struct usb
desc->bDescLength = 9;
desc->bPwrOn2PwrGood = 0;
desc->wHubCharacteristics = (__force __u16) cpu_to_le16(
-   0x0002 |/* No power switching */
-   0x0010 |/* No over current protection */
-   0);
+   HUB_CHAR_NO_LPSM |  /* No power switching */
+   HUB_CHAR_NO_OCPM);  /* No over current protection */
 
desc->u.hs.DeviceRemovable[0] = 1 << 1;
desc->u.hs.DeviceRemovable[1] = ~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


[PATCH 04/23] fusbh200-hcd: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare numbers to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/host/fusbh200-hcd.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: usb/drivers/usb/host/fusbh200-hcd.c
===
--- usb.orig/drivers/usb/host/fusbh200-hcd.c
+++ usb/drivers/usb/host/fusbh200-hcd.c
@@ -1479,8 +1479,8 @@ fusbh200_hub_descriptor (
memset(&desc->u.hs.DeviceRemovable[0], 0, temp);
memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
 
-   temp = 0x0008;  /* per-port overcurrent reporting */
-   temp |= 0x0002; /* no power switching */
+   temp = HUB_CHAR_INDV_PORT_OCPM; /* per-port overcurrent reporting */
+   temp |= HUB_CHAR_NO_LPSM;   /* no power switching */
desc->wHubCharacteristics = cpu_to_le16(temp);
 }
 

--
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 03/23] fotg210-hcd: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare numbers to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/host/fotg210-hcd.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: usb/drivers/usb/host/fotg210-hcd.c
===
--- usb.orig/drivers/usb/host/fotg210-hcd.c
+++ usb/drivers/usb/host/fotg210-hcd.c
@@ -1521,8 +1521,8 @@ fotg210_hub_descriptor(
memset(&desc->u.hs.DeviceRemovable[0], 0, temp);
memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
 
-   temp = 0x0008;  /* per-port overcurrent reporting */
-   temp |= 0x0002; /* no power switching */
+   temp = HUB_CHAR_INDV_PORT_OCPM; /* per-port overcurrent reporting */
+   temp |= HUB_CHAR_NO_LPSM;   /* no power switching */
desc->wHubCharacteristics = cpu_to_le16(temp);
 }
 

--
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 02/23] fhci-hub: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare number  to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/host/fhci-hub.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: usb/drivers/usb/host/fhci-hub.c
===
--- usb.orig/drivers/usb/host/fhci-hub.c
+++ usb/drivers/usb/host/fhci-hub.c
@@ -32,7 +32,7 @@ static u8 root_hub_des[] = {
0x09, /* blength */
0x29, /* bDescriptorType;hub-descriptor */
0x01, /* bNbrPorts */
-   0x11, /* wHubCharacteristics */
+   HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_NO_OCPM, /* wHubCharacteristics */
0x00, /* per-port power, no overcurrent */
0x01, /* bPwrOn2pwrGood;2ms */
0x00, /* bHubContrCurrent;0mA */

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


[PATCHv5 6/6] USB: host: ohci-at91: usb_hcd_at91_probe(), remove useless stack initialisation

2015-01-18 Thread Sylvain Rochet
struct usb_hcd *hcd = NULL;
...
hcd = usb_create_hcd(driver, dev, "at91");

This patch remove *hcd useless initialisation

Signed-off-by: Sylvain Rochet 
---
 drivers/usb/host/ohci-at91.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index e1d0a75..bb53231 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -146,7 +146,7 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
struct at91_usbh_data *board;
struct ohci_hcd *ohci;
int retval;
-   struct usb_hcd *hcd = NULL;
+   struct usb_hcd *hcd;
struct ohci_at91_priv *ohci_at91;
struct device *dev = &pdev->dev;
struct resource *res;
-- 
2.1.4

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


[PATCHv5 2/6] USB: host: ohci-at91: Use struct dev_pm_ops instead of struct platform_driver

2015-01-18 Thread Sylvain Rochet
This patch replace struct platform_driver.{resume,suspend} PM bindings
to a new struct dev_pm_ops.

Signed-off-by: Sylvain Rochet 
---
 drivers/usb/host/ohci-at91.c | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index dc9e4e6..65e7836 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -593,11 +593,11 @@ static int ohci_hcd_at91_drv_remove(struct 
platform_device *pdev)
 #ifdef CONFIG_PM
 
 static int
-ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg)
+ohci_hcd_at91_drv_suspend(struct device *dev)
 {
-   struct usb_hcd  *hcd = platform_get_drvdata(pdev);
+   struct usb_hcd  *hcd = dev_get_drvdata(dev);
struct ohci_hcd *ohci = hcd_to_ohci(hcd);
-   booldo_wakeup = device_may_wakeup(&pdev->dev);
+   booldo_wakeup = device_may_wakeup(dev);
int ret;
 
if (do_wakeup)
@@ -629,11 +629,11 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, 
pm_message_t mesg)
return ret;
 }
 
-static int ohci_hcd_at91_drv_resume(struct platform_device *pdev)
+static int ohci_hcd_at91_drv_resume(struct device *dev)
 {
-   struct usb_hcd  *hcd = platform_get_drvdata(pdev);
+   struct usb_hcd  *hcd = dev_get_drvdata(dev);
 
-   if (device_may_wakeup(&pdev->dev))
+   if (device_may_wakeup(dev))
disable_irq_wake(hcd->irq);
 
if (!clocked)
@@ -642,19 +642,18 @@ static int ohci_hcd_at91_drv_resume(struct 
platform_device *pdev)
ohci_resume(hcd, false);
return 0;
 }
-#else
-#define ohci_hcd_at91_drv_suspend NULL
-#define ohci_hcd_at91_drv_resume  NULL
 #endif
 
+static SIMPLE_DEV_PM_OPS(ohci_hcd_at91_pm_ops, ohci_hcd_at91_drv_suspend,
+   ohci_hcd_at91_drv_resume);
+
 static struct platform_driver ohci_hcd_at91_driver = {
.probe  = ohci_hcd_at91_drv_probe,
.remove = ohci_hcd_at91_drv_remove,
.shutdown   = usb_hcd_platform_shutdown,
-   .suspend= ohci_hcd_at91_drv_suspend,
-   .resume = ohci_hcd_at91_drv_resume,
.driver = {
.name   = "at91_ohci",
+   .pm = &ohci_hcd_at91_pm_ops,
.of_match_table = of_match_ptr(at91_ohci_dt_ids),
},
 };
-- 
2.1.4

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


[PATCHv5 4/6] USB: host: ohci-at91: Fix wake-up support

2015-01-18 Thread Sylvain Rochet
This device needs to be continuously clocked to provide wake up support,
previously, if STANDBY target were chosen the device were
enable_irq_wake()-prepared and clock still active and if MEM target were
chosen the device were also enable_irq_wake()-prepared but not clocked
anymore, which is wrong.

Now, if STANDBY target is chosen the device is still clocked with wake
up support enabled, which were the previous default and if MEM target is
chosen the device is declocked with wake up support disabled.

Signed-off-by: Sylvain Rochet 
---
 drivers/usb/host/ohci-at91.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 65e7836..2738352 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -49,6 +49,8 @@ extern int usb_disabled(void);
 
 static void at91_start_clock(void)
 {
+   if (clocked)
+   return;
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
clk_set_rate(uclk, 4800);
clk_prepare_enable(uclk);
@@ -61,6 +63,8 @@ static void at91_start_clock(void)
 
 static void at91_stop_clock(void)
 {
+   if (!clocked)
+   return;
clk_disable_unprepare(fclk);
clk_disable_unprepare(iclk);
clk_disable_unprepare(hclk);
@@ -597,15 +601,20 @@ ohci_hcd_at91_drv_suspend(struct device *dev)
 {
struct usb_hcd  *hcd = dev_get_drvdata(dev);
struct ohci_hcd *ohci = hcd_to_ohci(hcd);
-   booldo_wakeup = device_may_wakeup(dev);
+   booldo_wakeup;
int ret;
 
+   if (at91_suspend_entering_slow_clock())
+   device_init_wakeup(dev, 0);
+
+   do_wakeup = device_may_wakeup(dev);
if (do_wakeup)
enable_irq_wake(hcd->irq);
 
ret = ohci_suspend(hcd, do_wakeup);
if (ret) {
-   disable_irq_wake(hcd->irq);
+   if (do_wakeup)
+   disable_irq_wake(hcd->irq);
return ret;
}
/*
@@ -615,7 +624,7 @@ ohci_hcd_at91_drv_suspend(struct device *dev)
 *
 * REVISIT: some boards will be able to turn VBUS off...
 */
-   if (at91_suspend_entering_slow_clock()) {
+   if (!do_wakeup) {
ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
ohci->hc_control &= OHCI_CTRL_RWC;
ohci_writel(ohci, ohci->hc_control, &ohci->regs->control);
@@ -635,9 +644,9 @@ static int ohci_hcd_at91_drv_resume(struct device *dev)
 
if (device_may_wakeup(dev))
disable_irq_wake(hcd->irq);
+   device_init_wakeup(dev, 1);
 
-   if (!clocked)
-   at91_start_clock();
+   at91_start_clock();
 
ohci_resume(hcd, false);
return 0;
-- 
2.1.4

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


[PATCHv5 0/6] USB: host: Atmel OHCI and EHCI drivers improvements

2015-01-18 Thread Sylvain Rochet
USB: host: Atmel OHCI and EHCI drivers improvements

Suspend/resume support for EHCI.
struct dev_pm_ops for OHCI.
Removed global variables from both.
Fixed OHCI wake up support for STANDBY(wake-up enabled) and MEM(wake-up 
disabled) sleep targets.

Changes since v4:
  * Re-add at91_suspend_entering_slow_clock() to OHCI, we can't naively
remove this one, this device needs to be continuously clocked to
provide wake up support.
The removal of at91_suspend_entering_slow_clock() actually lighted up
an issue on wake up support, which is now fixed.

Changes since v3:
  * Using struct dev_pm_ops instead of static struct platform_driver
resume and suspend bindings for both EHCI and OHCI
  * Fixed inconsistency in patch subjects, _ intead of - for file names
  * Patch cleaning with the help of checkpatch.pl, fixed lines over
80 characters

Changes since v2:
  * Added patchs from an other submission, because this series
depended on this one
* EHCI: Move global variables to private struct
* OHCI: Move global variables to private struct
  * Using ohci->priv and ehci->priv instead of hcd->hcd_priv,
which were not the right way to do that

Changes since v1:
  * Don't use at91_suspend_entering_slow_clock() on EHCI,
we are trying to get read of this of this function
  * Removed at91_suspend_entering_slow_clock() from OHCI

Sylvain Rochet (6):
  USB: host: ehci-atmel: Add suspend/resume support
  USB: host: ohci-at91: Use struct dev_pm_ops instead of struct
platform_driver
  USB: host: ehci-atmel: Move global variables to private struct
  USB: host: ohci-at91: Fix wake-up support
  USB: host: ohci-at91: Move global variables to private struct
  USB: host: ohci-at91: usb_hcd_at91_probe(), remove useless stack
initialisation

 drivers/usb/host/ehci-atmel.c | 102 ++-
 drivers/usb/host/ohci-at91.c  | 120 +-
 2 files changed, 150 insertions(+), 72 deletions(-)

-- 
2.1.4

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


[PATCH 01/23] ehci-hub: use HUB_CHAR_*

2015-01-18 Thread Sergei Shtylyov
Fix  using the  bare numbers to set the 'wHubCharacteristics' field of the Hub
Descriptor while the values are #define'd in .

Signed-off-by: Sergei Shtylyov 

---
 drivers/usb/host/ehci-hub.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: usb/drivers/usb/host/ehci-hub.c
===
--- usb.orig/drivers/usb/host/ehci-hub.c
+++ usb/drivers/usb/host/ehci-hub.c
@@ -700,15 +700,15 @@ ehci_hub_descriptor (
memset(&desc->u.hs.DeviceRemovable[0], 0, temp);
memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
 
-   temp = 0x0008;  /* per-port overcurrent reporting */
+   temp = HUB_CHAR_INDV_PORT_OCPM; /* per-port overcurrent reporting */
if (HCS_PPC (ehci->hcs_params))
-   temp |= 0x0001; /* per-port power control */
+   temp |= HUB_CHAR_INDV_PORT_LPSM; /* per-port power control */
else
-   temp |= 0x0002; /* no power switching */
+   temp |= HUB_CHAR_NO_LPSM; /* no power switching */
 #if 0
 // re-enable when we support USB_PORT_FEAT_INDICATOR below.
if (HCS_INDICATOR (ehci->hcs_params))
-   temp |= 0x0080; /* per-port indicators (LEDs) */
+   temp |= HUB_CHAR_PORTIND; /* per-port indicators (LEDs) */
 #endif
desc->wHubCharacteristics = cpu_to_le16(temp);
 }

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


[PATCHv5 3/6] USB: host: ehci-atmel: Move global variables to private struct

2015-01-18 Thread Sylvain Rochet
This patch move Atmel EHCI global variables (clocks ptr and clocked
boolean) to private struct atmel_ehci_priv, stored in ehci->priv.

Signed-off-by: Sylvain Rochet 
---
 drivers/usb/host/ehci-atmel.c | 79 +++
 1 file changed, 50 insertions(+), 29 deletions(-)

diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 5a15e3d..663f790 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -27,48 +27,66 @@
 #define DRIVER_DESC "EHCI Atmel driver"
 
 static const char hcd_name[] = "ehci-atmel";
-static struct hc_driver __read_mostly ehci_atmel_hc_driver;
 
 /* interface and function clocks */
-static struct clk *iclk, *fclk, *uclk;
-static int clocked;
+#define hcd_to_atmel_ehci_priv(h) \
+   ((struct atmel_ehci_priv *)hcd_to_ehci(h)->priv)
+
+struct atmel_ehci_priv {
+   struct clk *iclk;
+   struct clk *fclk;
+   struct clk *uclk;
+   bool clocked;
+};
+
+static struct hc_driver __read_mostly ehci_atmel_hc_driver;
+
+static const struct ehci_driver_overrides ehci_atmel_drv_overrides __initconst 
= {
+   .extra_priv_size = sizeof(struct atmel_ehci_priv),
+};
 
 /*-*/
 
-static void atmel_start_clock(void)
+static void atmel_start_clock(struct atmel_ehci_priv *atmel_ehci)
 {
-   if (clocked)
+   if (atmel_ehci->clocked)
return;
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
-   clk_set_rate(uclk, 4800);
-   clk_prepare_enable(uclk);
+   clk_set_rate(atmel_ehci->uclk, 4800);
+   clk_prepare_enable(atmel_ehci->uclk);
}
-   clk_prepare_enable(iclk);
-   clk_prepare_enable(fclk);
-   clocked = 1;
+   clk_prepare_enable(atmel_ehci->iclk);
+   clk_prepare_enable(atmel_ehci->fclk);
+   atmel_ehci->clocked = true;
 }
 
-static void atmel_stop_clock(void)
+static void atmel_stop_clock(struct atmel_ehci_priv *atmel_ehci)
 {
-   if (!clocked)
+   if (!atmel_ehci->clocked)
return;
-   clk_disable_unprepare(fclk);
-   clk_disable_unprepare(iclk);
+   clk_disable_unprepare(atmel_ehci->fclk);
+   clk_disable_unprepare(atmel_ehci->iclk);
if (IS_ENABLED(CONFIG_COMMON_CLK))
-   clk_disable_unprepare(uclk);
-   clocked = 0;
+   clk_disable_unprepare(atmel_ehci->uclk);
+   atmel_ehci->clocked = false;
 }
 
 static void atmel_start_ehci(struct platform_device *pdev)
 {
+   struct usb_hcd *hcd = platform_get_drvdata(pdev);
+   struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
+
dev_dbg(&pdev->dev, "start\n");
-   atmel_start_clock();
+   atmel_start_clock(atmel_ehci);
 }
 
 static void atmel_stop_ehci(struct platform_device *pdev)
 {
+   struct usb_hcd *hcd = platform_get_drvdata(pdev);
+   struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
+
dev_dbg(&pdev->dev, "stop\n");
-   atmel_stop_clock();
+   atmel_stop_clock(atmel_ehci);
 }
 
 /*-*/
@@ -79,6 +97,7 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev)
const struct hc_driver *driver = &ehci_atmel_hc_driver;
struct resource *res;
struct ehci_hcd *ehci;
+   struct atmel_ehci_priv *atmel_ehci;
int irq;
int retval;
 
@@ -109,6 +128,7 @@ static int ehci_atmel_drv_probe(struct platform_device 
*pdev)
retval = -ENOMEM;
goto fail_create_hcd;
}
+   atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
hcd->regs = devm_ioremap_resource(&pdev->dev, res);
@@ -120,23 +140,23 @@ static int ehci_atmel_drv_probe(struct platform_device 
*pdev)
hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res);
 
-   iclk = devm_clk_get(&pdev->dev, "ehci_clk");
-   if (IS_ERR(iclk)) {
+   atmel_ehci->iclk = devm_clk_get(&pdev->dev, "ehci_clk");
+   if (IS_ERR(atmel_ehci->iclk)) {
dev_err(&pdev->dev, "Error getting interface clock\n");
retval = -ENOENT;
goto fail_request_resource;
}
-   fclk = devm_clk_get(&pdev->dev, "uhpck");
-   if (IS_ERR(fclk)) {
+   atmel_ehci->fclk = devm_clk_get(&pdev->dev, "uhpck");
+   if (IS_ERR(atmel_ehci->fclk)) {
dev_err(&pdev->dev, "Error getting function clock\n");
retval = -ENOENT;
goto fail_request_resource;
}
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
-   uclk = devm_clk_get(&pdev->dev, "usb_clk");
-   if (IS_ERR(uclk)) {
+   atmel_ehci->uclk = devm_clk_get(&pdev->dev, "usb_clk");
+   if (IS_ERR(atmel_ehci->uclk)) {
dev_err(&pdev->dev, "failed to get uclk\

[PATCHv5 1/6] USB: host: ehci-atmel: Add suspend/resume support

2015-01-18 Thread Sylvain Rochet
This patch add suspend/resume support for Atmel EHCI, mostly
about disabling and unpreparing clocks so USB PLL is stopped
before entering sleep state.

Signed-off-by: Sylvain Rochet 
---
 drivers/usb/host/ehci-atmel.c | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 56a8850..5a15e3d 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -37,6 +37,8 @@ static int clocked;
 
 static void atmel_start_clock(void)
 {
+   if (clocked)
+   return;
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
clk_set_rate(uclk, 4800);
clk_prepare_enable(uclk);
@@ -48,6 +50,8 @@ static void atmel_start_clock(void)
 
 static void atmel_stop_clock(void)
 {
+   if (!clocked)
+   return;
clk_disable_unprepare(fclk);
clk_disable_unprepare(iclk);
if (IS_ENABLED(CONFIG_COMMON_CLK))
@@ -174,6 +178,29 @@ static int ehci_atmel_drv_remove(struct platform_device 
*pdev)
return 0;
 }
 
+#ifdef CONFIG_PM
+static int ehci_atmel_drv_suspend(struct device *dev)
+{
+   struct usb_hcd *hcd = dev_get_drvdata(dev);
+   int ret;
+
+   ret = ehci_suspend(hcd, false);
+   if (ret)
+   return ret;
+
+   atmel_stop_clock();
+   return 0;
+}
+
+static int ehci_atmel_drv_resume(struct device *dev)
+{
+   struct usb_hcd *hcd = dev_get_drvdata(dev);
+
+   atmel_start_clock();
+   return ehci_resume(hcd, false);
+}
+#endif
+
 #ifdef CONFIG_OF
 static const struct of_device_id atmel_ehci_dt_ids[] = {
{ .compatible = "atmel,at91sam9g45-ehci" },
@@ -183,12 +210,16 @@ static const struct of_device_id atmel_ehci_dt_ids[] = {
 MODULE_DEVICE_TABLE(of, atmel_ehci_dt_ids);
 #endif
 
+static SIMPLE_DEV_PM_OPS(ehci_atmel_pm_ops, ehci_atmel_drv_suspend,
+   ehci_atmel_drv_resume);
+
 static struct platform_driver ehci_atmel_driver = {
.probe  = ehci_atmel_drv_probe,
.remove = ehci_atmel_drv_remove,
.shutdown   = usb_hcd_platform_shutdown,
.driver = {
.name   = "atmel-ehci",
+   .pm = &ehci_atmel_pm_ops,
.of_match_table = of_match_ptr(atmel_ehci_dt_ids),
},
 };
-- 
2.1.4

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


[PATCHv5 5/6] USB: host: ohci-at91: Move global variables to private struct

2015-01-18 Thread Sylvain Rochet
This patch move AT91 OHCI global variables (clocks ptr and clocked
boolean) to private struct ohci_at91_priv, stored in ohci->priv.

Signed-off-by: Sylvain Rochet 
---
 drivers/usb/host/ohci-at91.c | 86 ++--
 1 file changed, 52 insertions(+), 34 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 2738352..e1d0a75 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -33,7 +33,16 @@
for ((index) = 0; (index) < AT91_MAX_USBH_PORTS; (index)++)
 
 /* interface, function and usb clocks; sometimes also an AHB clock */
-static struct clk *iclk, *fclk, *uclk, *hclk;
+#define hcd_to_ohci_at91_priv(h) \
+   ((struct ohci_at91_priv *)hcd_to_ohci(h)->priv)
+
+struct ohci_at91_priv {
+   struct clk *iclk;
+   struct clk *fclk;
+   struct clk *uclk;
+   struct clk *hclk;
+   bool clocked;
+};
 /* interface and function clocks; sometimes also an AHB clock */
 
 #define DRIVER_DESC "OHCI Atmel driver"
@@ -41,49 +50,53 @@ static struct clk *iclk, *fclk, *uclk, *hclk;
 static const char hcd_name[] = "ohci-atmel";
 
 static struct hc_driver __read_mostly ohci_at91_hc_driver;
-static int clocked;
+
+static const struct ohci_driver_overrides ohci_at91_drv_overrides __initconst 
= {
+   .extra_priv_size = sizeof(struct ohci_at91_priv),
+};
 
 extern int usb_disabled(void);
 
 /*-*/
 
-static void at91_start_clock(void)
+static void at91_start_clock(struct ohci_at91_priv *ohci_at91)
 {
-   if (clocked)
+   if (ohci_at91->clocked)
return;
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
-   clk_set_rate(uclk, 4800);
-   clk_prepare_enable(uclk);
+   clk_set_rate(ohci_at91->uclk, 4800);
+   clk_prepare_enable(ohci_at91->uclk);
}
-   clk_prepare_enable(hclk);
-   clk_prepare_enable(iclk);
-   clk_prepare_enable(fclk);
-   clocked = 1;
+   clk_prepare_enable(ohci_at91->hclk);
+   clk_prepare_enable(ohci_at91->iclk);
+   clk_prepare_enable(ohci_at91->fclk);
+   ohci_at91->clocked = true;
 }
 
-static void at91_stop_clock(void)
+static void at91_stop_clock(struct ohci_at91_priv *ohci_at91)
 {
-   if (!clocked)
+   if (!ohci_at91->clocked)
return;
-   clk_disable_unprepare(fclk);
-   clk_disable_unprepare(iclk);
-   clk_disable_unprepare(hclk);
+   clk_disable_unprepare(ohci_at91->fclk);
+   clk_disable_unprepare(ohci_at91->iclk);
+   clk_disable_unprepare(ohci_at91->hclk);
if (IS_ENABLED(CONFIG_COMMON_CLK))
-   clk_disable_unprepare(uclk);
-   clocked = 0;
+   clk_disable_unprepare(ohci_at91->uclk);
+   ohci_at91->clocked = false;
 }
 
 static void at91_start_hc(struct platform_device *pdev)
 {
struct usb_hcd *hcd = platform_get_drvdata(pdev);
struct ohci_regs __iomem *regs = hcd->regs;
+   struct ohci_at91_priv *ohci_at91 = hcd_to_ohci_at91_priv(hcd);
 
dev_dbg(&pdev->dev, "start\n");
 
/*
 * Start the USB clocks.
 */
-   at91_start_clock();
+   at91_start_clock(ohci_at91);
 
/*
 * The USB host controller must remain in reset.
@@ -95,6 +108,7 @@ static void at91_stop_hc(struct platform_device *pdev)
 {
struct usb_hcd *hcd = platform_get_drvdata(pdev);
struct ohci_regs __iomem *regs = hcd->regs;
+   struct ohci_at91_priv *ohci_at91 = hcd_to_ohci_at91_priv(hcd);
 
dev_dbg(&pdev->dev, "stop\n");
 
@@ -106,7 +120,7 @@ static void at91_stop_hc(struct platform_device *pdev)
/*
 * Stop the USB clocks.
 */
-   at91_stop_clock();
+   at91_stop_clock(ohci_at91);
 }
 
 
@@ -133,6 +147,7 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
struct ohci_hcd *ohci;
int retval;
struct usb_hcd *hcd = NULL;
+   struct ohci_at91_priv *ohci_at91;
struct device *dev = &pdev->dev;
struct resource *res;
int irq;
@@ -146,6 +161,7 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
hcd = usb_create_hcd(driver, dev, "at91");
if (!hcd)
return -ENOMEM;
+   ohci_at91 = hcd_to_ohci_at91_priv(hcd);
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
hcd->regs = devm_ioremap_resource(dev, res);
@@ -156,29 +172,29 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res);
 
-   iclk = devm_clk_get(dev, "ohci_clk");
-   if (IS_ERR(iclk)) {
+   ohci_at91->iclk = devm_clk_get(dev, "ohci_clk");
+   if (IS_ERR(ohci_at91->iclk)) {
dev_err(dev, "failed to get ohci_clk\n");
-   retval = PTR_ERR(iclk);
+   retval = PTR_ERR(ohci_at91->iclk);
   

[PATCH 00/23] Use USB_CHAR_* in the host drivers

2015-01-18 Thread Sergei Shtylyov
Hello.

   Here's a set of 23 patches against the 'usb-next' branch of Greg KH's
'usb.git' repo plus 2 FHCI patches I posted a week ago. It's to replace the
use of the hex numbers where the USB_CHAR_* #define's should have been used.

[01/23] ehci-hub: use HUB_CHAR_*
[02/23] fhci-hub: use HUB_CHAR_*
[03/23] fotg210-hcd: use HUB_CHAR_*
[04/23] fusbh200-hcd: use HUB_CHAR_*
[05/23] imx21-hcd: use HUB_CHAR_*
[06/23] isp116x-hcd: use HUB_CHAR_*
[07/23] isp1362-hcd: use HUB_CHAR_*
[08/23] isp1760-hcd: use HUB_CHAR_*
[09/23] max3421-hcd: use HUB_CHAR_*
[10/23] ohci-at91: use HUB_CHAR_*
[11/23] ohci-hub: use HUB_CHAR_*
[12/23] ohci-s3c2410: use HUB_CHAR_*
[13/23] oxu210hp-hcd: use HUB_CHAR_*
[14/23] r8a66597-hcd: use HUB_CHAR_*
[15/23] sl811-hcd: use HUB_CHAR_*
[16/23] u132-hcd: use HUB_CHAR_*
[17/23] uhci-hub: use HUB_CHAR_*
[18/23] dwc2: hcd: use HUB_CHAR_*
[19/23] dummy_hcd: use HUB_CHAR_*
[20/23] musb_virthub: use HUB_CHAR_*
[21/23] renesas_usbhs: mod_host: use HUB_CHAR_*
[22/23] usbip: vhci_hcd: use HUB_CHAR_*
[23/23] wusbcore: rh: use HUB_CHAR_*

WBR, Sergei

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


Re: Suspected (out of tree) HCI issue

2015-01-18 Thread Vincent Pelletier
Hello,

(please keep me cc'ed, I'm not subscribed)

On Thu, 27 Nov 2014 13:00:28 -0500 (EST), Alan Stern
 wrote:
> If your hardware resembles, say, the DWC2 hardware then maybe the DWC2 
> driver (drivers/usb/dwc2/) can be made to work with it.

I've worked on this and have a functional USB port using dwc2.

Attached is the largest patch involved, and likely the only one touching
dwc2 (the rest is board-specific and not polished enough yet).
Could I get feedback on it ?

I didn't test this exact patch, as OpenWRT is on 3.14.28 and this
patch is against linux-stable current master
(eaa27f34e91a14cdceed26ed6c6793ec1d186115 linux 3.19-rc4).

Going further: The hardware I'm testing this on has 2 ports, each on a
different HCI "core" of the same device (it seems they share some
registers). As far as I can see, dwc2 actually handles a single core,
and one port is indeed not functional. Is there some work in progress on
this topic ? Or any idea on how it should be done ?

Regards,
-- 
Vincent Pelletier
>From 38b036a3854935a8a2b948ed02d3ec6ead732cba Mon Sep 17 00:00:00 2001
Message-Id: <38b036a3854935a8a2b948ed02d3ec6ead732cba.1421618396.git.plr.vinc...@gmail.com>
From: Vincent Pelletier 
Date: Sun, 18 Jan 2015 22:34:38 +0100
Subject: usb: dwc2: add big-endian support

Tested on TP-Link TD-W8970 (MIPS) with OpenWRT.
As the change is very repetitive it should be easier to review the way it
was generated:
$EDITOR core.h
sed -i "s/\/dwc2_readl/g" *.c hcd.h hw.h
sed -i "s/\/dwc2_writel/g" *.c hcd.h hw.h

Dmesg extract:
[9.16] dwc2 1e101000.ifxhcd: DWC OTG Controller
[9.16] dwc2 1e101000.ifxhcd: new USB bus registered, assigned bus number 1
[9.168000] dwc2 1e101000.ifxhcd: irq 62, io mem 0x
[9.176000] dwc2 1e101000.ifxhcd: Hardware does not support descriptor DMA mode -
[9.176000] dwc2 1e101000.ifxhcd: falling back to buffer DMA mode.

Signed-off-by: Vincent Pelletier 
---
 drivers/usb/dwc2/core.c  | 340 +--
 drivers/usb/dwc2/core.h  |  10 ++
 drivers/usb/dwc2/core_intr.c |  72 -
 drivers/usb/dwc2/gadget.c| 310 +++
 drivers/usb/dwc2/hcd.c   | 144 +-
 drivers/usb/dwc2/hcd.h   |  14 +-
 drivers/usb/dwc2/hcd_ddma.c  |  10 +-
 drivers/usb/dwc2/hcd_intr.c  |  82 +--
 drivers/usb/dwc2/hcd_queue.c |  10 +-
 9 files changed, 501 insertions(+), 491 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 7605850b..ba32dc8 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -67,10 +67,10 @@ static void dwc2_enable_common_interrupts(struct dwc2_hsotg *hsotg)
 	u32 intmsk;
 
 	/* Clear any pending OTG Interrupts */
-	writel(0x, hsotg->regs + GOTGINT);
+	dwc2_writel(0x, hsotg->regs + GOTGINT);
 
 	/* Clear any pending interrupts */
-	writel(0x, hsotg->regs + GINTSTS);
+	dwc2_writel(0x, hsotg->regs + GINTSTS);
 
 	/* Enable the interrupts in the GINTMSK */
 	intmsk = GINTSTS_MODEMIS | GINTSTS_OTGINT;
@@ -81,7 +81,7 @@ static void dwc2_enable_common_interrupts(struct dwc2_hsotg *hsotg)
 	intmsk |= GINTSTS_CONIDSTSCHNG | GINTSTS_WKUPINT | GINTSTS_USBSUSP |
 		  GINTSTS_SESSREQINT;
 
-	writel(intmsk, hsotg->regs + GINTMSK);
+	dwc2_writel(intmsk, hsotg->regs + GINTMSK);
 }
 
 /*
@@ -104,10 +104,10 @@ static void dwc2_init_fs_ls_pclk_sel(struct dwc2_hsotg *hsotg)
 	}
 
 	dev_dbg(hsotg->dev, "Initializing HCFG.FSLSPClkSel to %08x\n", val);
-	hcfg = readl(hsotg->regs + HCFG);
+	hcfg = dwc2_readl(hsotg->regs + HCFG);
 	hcfg &= ~HCFG_FSLSPCLKSEL_MASK;
 	hcfg |= val << HCFG_FSLSPCLKSEL_SHIFT;
-	writel(hcfg, hsotg->regs + HCFG);
+	dwc2_writel(hcfg, hsotg->regs + HCFG);
 }
 
 /*
@@ -125,7 +125,7 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg)
 	/* Wait for AHB master IDLE state */
 	do {
 		usleep_range(2, 4);
-		greset = readl(hsotg->regs + GRSTCTL);
+		greset = dwc2_readl(hsotg->regs + GRSTCTL);
 		if (++count > 50) {
 			dev_warn(hsotg->dev,
  "%s() HANG! AHB Idle GRSTCTL=%0x\n",
@@ -137,10 +137,10 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg)
 	/* Core Soft Reset */
 	count = 0;
 	greset |= GRSTCTL_CSFTRST;
-	writel(greset, hsotg->regs + GRSTCTL);
+	dwc2_writel(greset, hsotg->regs + GRSTCTL);
 	do {
 		usleep_range(2, 4);
-		greset = readl(hsotg->regs + GRSTCTL);
+		greset = dwc2_readl(hsotg->regs + GRSTCTL);
 		if (++count > 50) {
 			dev_warn(hsotg->dev,
  "%s() HANG! Soft Reset GRSTCTL=%0x\n",
@@ -150,20 +150,20 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg)
 	} while (greset & GRSTCTL_CSFTRST);
 
 	if (hsotg->dr_mode == USB_DR_MODE_HOST) {
-		gusbcfg = readl(hsotg->regs + GUSBCFG);
+		gusbcfg = dwc2_readl(hsotg->regs + GUSBCFG);
 		gusbcfg &= ~GUSBCFG_FORCEDEVMODE;
 		gusbcfg |= GUSBCFG_FORCEHOSTMODE;
-		writel(gusbcfg, hsotg->regs + GUSBCFG);
+		dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG);
 	} else if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) {
-		g

Re: [PATCHv4 3/6] USB: host: ohci-at91: Stop/start USB PLL for all sleep modes

2015-01-18 Thread Sylvain Rochet
Hello,

On Sun, Jan 18, 2015 at 08:36:03PM +0100, Sylvain Rochet wrote:
> Disable/unprepare clocks without testing the sleep target_state, removed
> the at91_suspend_entering_slow_clock() call (which is only a
> target_state == PM_SUSPEND_MEM).
> 
> Other kind of suspend now benefit from the power save induced by this
> PLL deactivation. The resume penalty is about 500 us, which is not
> negligible but acceptable considering the amount of power we are saving.

Well, this patch actually lights up a previous issue on wake up support.

This device needs to be continuously clocked to provide wake up support, 
previously, if STANDBY target were chosen the device were 
enable_irq_wake-prepared and clock still active and if MEM target were 
chosen the device were also enable_irq_wake-prepared but not clocked 
anymore, which is wrong, but not so wrong.

This patch actually breaks wake up support for STANDBY sleep target. I 
am going to propose a v5 which reinitiate at91_suspend_entering_slow_clock()
and fix wake up support on this driver.

Sylvain
--
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 001/001] usbhid: Fix initialisation and force effect modifications for the Microsoft Sidewinder Force Feedback Pro 2 joystick

2015-01-18 Thread Alan Stern
On Sun, 18 Jan 2015, Jim Keir wrote:

> From: Jim Keir 
> Signed-off-by: Jim Keir 
> 
> Currently the SWFF2 driver fails during initialisation, making the force
> capability of the joystick unusable. Further, there is a long-standing
> bug in the same driver where commands to update force parameters are
> addressed to the last-created force effect instead of the specified one,
> making it impossible to modify effects after their creation.
> 
> Three bugs are addressed:
> 
> 1) The FF2 driver (usbhid/hid-pidff.c) sends commands to the stick
> during ff_init. However, this is called inside a block where
> driver_input_lock is locked, so the results of these initial commands
> are discarded. This one is the "killer", without this nothing else works.
> 
> ff_init issues commands using "hid_hw_request". This eventually goes to
> hid_input_report, which returns -EBUSY because driver_input_lock is
> locked. The change is to delay the ff_init call in hid-core.c until
> after this lock has been released.
> 
> 2) The usbhid driver ignores an endpoint stall when sending control
> commands, causing the first few commands of the hid-pidff.c
> initialisation to get lost.
> 
> usbhid/hid-core.c has been modified by copying lines into "hid_ctrl"
> from the "hid_irq_in" function in the same file.
> 
> 3) The FF2 driver (usbhid/hid-pidff.c) does not set the effect ID when
> uploading an effect. The result is that the initial upload works but
> subsequent uploads to modify effect parameters are all directed at the
> last-created effect.
> 
> The targeted effect ID must be passed back to the device when effect
> parameters are changed. This is done at the start of
> "pidff_set_condition_report", "pidff_set_periodic_report" etc. based on
> the value of "pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0]".
> However, this value is only ever set during pidff_request_effect_upload.
> The result is stored in "pidff->pid_id[effect->id]" at the end of
> pid_upload_effect, for later use. However, if an effect is modified and
> re-sent then this identifier is not being copied back from
> pidff->pid_id[effect->id] before sending the command to the device. The
> fix is to do this at the start of pidff_upload_effect.
> 
> This patch taken against kernel 3.13.0

Three different changes should be split up into three different 
patches.  Also, you should test the patch by running it through 
checkpatch.pl before submitting it.

Regardless of those things, the second change (stall response to
control messages) is wrong for several reasons.

> diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
> index 029965e..5d34dd7 100644
> --- a/drivers/hid/usbhid/hid-core.c
> +++ b/drivers/hid/usbhid/hid-core.c
> @@ -505,7 +505,12 @@ static void hid_ctrl(struct urb *urb)
>   case -EPROTO:/* protocol error or unplug */
>   case -ECONNRESET:/* unlink */
>   case -ENOENT:
> +break;
>   case -EPIPE:/* report not available */
> +usbhid_mark_busy(usbhid);
> +clear_bit(HID_IN_RUNNING, &usbhid->iofl);

This is wrong.  The interrupt-IN endpoint is still running, because it 
is unaffected by an error on the control endpoint.

> +set_bit(HID_CLEAR_HALT, &usbhid->iofl);

This makes no sense.  Stalls on a control endpoint do not need a
clear-halt because the endpoint does not halt.  In any case, this flag
tells the driver to clear a halt condition on the interrupt-IN 
endpoint, not on the control endpoint.

> +schedule_work(&usbhid->reset_work);
>   break;
>   default:/* error */
>   hid_warn(urb->dev, "ctrl urb status %d received\n", status);

In general, there isn't much you can do about a control stall.  It 
means the device did not understand or does not support the request it 
received.  You can't force the device to respond to a request it 
doesn't understand; all you can do is report that the transfer failed.  
Which is what the driver currently does.

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


Control message failures kill entire XHCI stack

2015-01-18 Thread Devin Heitmueller
Hello,

I'm debugging some issues on a couple of different USB TV tuners which
boil down to the following error:

xhci_hcd :00:14.0: xHCI host not responding to stop endpoint command.

This is followed by the XHCI driver disconnecting *all* USB devices
from the controller.

I've done a bit of debugging, and the root of the issue appears to be
an intermittent control message timing out, and then the call to
usb_kill_urb() that occurs inside of usb_control_msg() when the
timeout expires is what causes the disconnect.  Specifically, it would
appear that xhci_urb_dequeue tries to stop the endpoint using
xhci_queue_stop_endpoint(), the command gets queued but the IRQ never
fires to perform the TRB_STOP_RING completion code. The function
xhci_stop_endpoint_command_watchdog() fires after five seconds, which
tears down the entire driver.

Below is the dmesg output with the xhci_hcd debugging enabled.  The
dump_stack() call is something I added (i.e. it's not an OOPS) so I
could see which code path was making the usb_kill_urb() call that was
failing.  Note that the caller is using usb_control_msg() with 1000ms
timeout, and we can see from the timestamps that the timer expires
which is what causes the call to usb_kill_urb().

I would imagine that explicitly killing URBs is a pretty uncommon task
for control endpoint messages (compared to ISOC or BULK endpoints
where it's done regularly).  Is it possible a exception case has been
missed?

Independent of the usb_kill_urb() killing the entire stack, I still
don't really understand yet why the control message failed in the
first place.  This is a well-exercised code path in the au0828 driver
(related to I2C transfers) and I've never seen this when using the
EHCI driver.  My assumption is that either the HCD is getting sick
which is causing both the control message to fail as well as putting
it into an inconsistent state such that we never get the TRB_STOP_RING
IRQ, or we've got two separate bugs - the control message failing for
some "legitimate" reason (i.e. I screwed something up in my au0828
driver), followed by the usb_kill_urb() error simply not handling
killing of URBs on a control endpoint (which causes the entire stack
to go down).

Thoughts/suggestions/recommendations are welcome.

Thanks in advance,

Devin

Jan 18 14:04:05 devin-MacBookPro kernel: [ 9119.647249] au0828:
au0828_writereg(0x0100, 0x00)
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.645091] xhci_hcd
:00:14.0: Cancel URB 8802543c36c0, dev 1, ep 0x0, starting at
offset 0x25c358940
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.645365] djh dequeue
pending=0 ep_index=0
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.645632] CPU: 1 PID:
2782 Comm: tvtime Tainted: P   OE  3.18.0-rc4djh+ #33
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.645921] Hardware name:
Apple Inc. MacBookPro11,1/Mac-189A3D4F975D5FFC, BIOS
MBP111.88Z.0138.B11.1408291433 08/29/2014
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.646236]
88025b9b 88023ea2f9d8 817445c1 
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.646570]
8802543c36c0 88023ea2fa58 a0080b2e 00025c358940
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.646909]
88023ea2fa48 3ea2fa18 88023e8a22a0 
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.647256] Call Trace:
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.647605]
[] dump_stack+0x46/0x58
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.647981]
[] xhci_urb_dequeue+0x28e/0x420 [xhci_hcd]
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.648357]
[] unlink1+0x2d/0x130
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.648743]
[] ? internal_add_timer+0xb0/0xb0
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.649133]
[] ? get_device+0x17/0x30
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.649526]
[] usb_hcd_unlink_urb+0x5d/0xf0
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.649928]
[] usb_kill_urb+0x3a/0xa0
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.650334]
[] ? wake_up_state+0x20/0x20
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.650746]
[] usb_start_wait_urb+0xc8/0x150
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.651166]
[] ? __kmalloc+0x55/0x190
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.651586]
[] usb_control_msg+0xc5/0x110
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.652011]
[] au0828_writereg+0x79/0xf0 [au0828]
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.652447]
[] ? try_to_del_timer_sync+0x4f/0x70
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.652894]
[] au0828_analog_stream_disable+0x29/0x50 [au0828]
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.653354]
[] vidioc_streamoff+0xd9/0x1c0 [au0828]
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.653823]
[] v4l_streamoff+0x1a/0x20 [videodev]
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.654298]
[] __video_do_ioctl+0x274/0x2f0 [videodev]
Jan 18 14:04:06 devin-MacBookPro kernel: [ 9120.654786]
[] ? commit_charge+0x1f/0x80
Jan 18 14:04:06 dev

Re: Fatal Exception on device when Hotsyncing Palm in linux

2015-01-18 Thread Oliver Neukum
On Sat, 2015-01-17 at 00:06 +0100, Henri Manson wrote:
> I figured out how to get debug output, enclosed the results. How can I
> get usbserial debug output on Ubuntu 9.04? It appears it wasn't a
> module yet back then.
> 
> out-crash: debug output form Ubuntu 14.04.1 which causes the Palm m505 to 
> crash
> out: debug output form Ubuntu 9.04 which works fine
> 
> probe string on 9.04 and 14.04 is different:
> 
> 9.04:
> [  640.784916] usb 2-2: palm_os_4_probe - length = 20, data = 01 00 00
> 00 63 6e 79 73 02 00 00 00 00 03 f3 5c 05 03 00 03
> 
> 14.04.1:
> [ 1685.194594] usb 8-2: palm_os_4_probe - length = 20, data = 01 00 00
> 00 63 6e 79 73 02 00 00 00 01 36 00 5c 00 00 00 09

This comes from the device. The crashing log shows the machine sending
AT
in a very inefficient manner. You could get a usbmon trace for the older
kernel and the newer kernel. That should serve almost as well for this
purpose.

Regards
Oliver


--
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: [PATCHv3 1/5] USB: host: ehci_atmel: Add suspend/resume support

2015-01-18 Thread Sergei Shtylyov

Hello.

On 01/18/2015 01:49 AM, Sylvain Rochet wrote:


There's little inconsistency in your patch subjects: you're using
'_' but the files you're modifying are named using '-'...



Indeed.



@@ -187,6 +217,8 @@ static struct platform_driver ehci_atmel_driver = {
.probe  = ehci_atmel_drv_probe,
.remove = ehci_atmel_drv_remove,
.shutdown   = usb_hcd_platform_shutdown,
+   .suspend= ehci_atmel_drv_suspend,
+   .resume = ehci_atmel_drv_resume,


I think you should use 'struct dev_pm_ops' now.


   I'm not sure but perhaps scripts/checkpatch.pl would complain about the 
old-style PM methods... should check.



This way ?



static int ehci_atmel_drv_suspend(struct device *dev)
{
struct usb_hcd *hcd = dev_get_drvdata(dev);
(...)


static SIMPLE_DEV_PM_OPS(ehci_atmel_pm_ops, ehci_atmel_drv_suspend, 
ehci_atmel_drv_resume);

(...)
.driver = {
.pm = &ehci_atmel_pm_ops,
}
(...)


   Yes, probably.


Should I send a v4 or can I send this change separately on top of the
previous change ?


   v4 please.


Sylvain


WBR, Sergei

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


Re: [PATCHv3 0/5] USB: host: Atmel OHCI and EHCI drivers improvements

2015-01-18 Thread Sylvain Rochet
Hello Alan,

On Sun, Jan 18, 2015 at 12:20:49PM -0500, Alan Stern wrote:
> On Sat, 17 Jan 2015, Sylvain Rochet wrote:
> 
> > Sylvain Rochet (5):
> >   USB: host: ehci_atmel: Add suspend/resume support
> >   USB: host: ohci_at91: Stop/start USB PLL for all sleep modes
> >   USB: host: ehci_atmel: Move global variables to private struct
> >   USB: host: ohci_at91: Move global variables to private struct
> >   USB: host: ohci_at91: usb_hcd_at91_probe(), remove useless stack
> > initialisation
> > 
> >  drivers/usb/host/ehci-atmel.c | 102 
> > +++--
> >  drivers/usb/host/ohci-at91.c  | 104 
> > +-
> >  2 files changed, 138 insertions(+), 68 deletions(-)
> 
> These patches look pretty good to me.  Have you run them through 
> checkpatch.pl?

Just did, fixed some lines over 80 characters + Sergei suggestion about 
using struct dev_pm_ops instead of struct platform_driver.{resume,suspend}.

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


[PATCHv4 0/6] USB: host: Atmel OHCI and EHCI drivers improvements

2015-01-18 Thread Sylvain Rochet
Suspend/resume support for EHCI.
struct dev_pm_ops for OHCI.
PLL stop for all sleep modes for OHCI.
Removed global variables from both.
Removed at91_suspend_entering_slow_clock() from both.

Changes since v3:
  * Using struct dev_pm_ops instead of static struct platform_driver
resume and suspend bindings for both EHCI and OHCI
  * Fixed inconsistency in patch subjects, _ intead of - for file names
  * Patch cleaning with the help of checkpatch.pl, fixed lines over
80 characters

Changes since v2:
  * Added patchs from an other submission, because this series
depended on this one
* EHCI: Move global variables to private struct
* OHCI: Move global variables to private struct
  * Using ohci->priv and ehci->priv instead of hcd->hcd_priv,
which were not the right way to do that

Changes since v1:
  * Don't use at91_suspend_entering_slow_clock() on EHCI,
we are trying to get read of this of this function
  * Removed at91_suspend_entering_slow_clock() from OHCI

Sylvain Rochet (6):
  USB: host: ehci-atmel: Add suspend/resume support
  USB: host: ohci-at91: Use struct dev_pm_ops instead of struct
platform_driver
  USB: host: ohci-at91: Stop/start USB PLL for all sleep modes
  USB: host: ehci-atmel: Move global variables to private struct
  USB: host: ohci-at91: Move global variables to private struct
  USB: host: ohci-at91: usb_hcd_at91_probe(), remove useless stack
initialisation

 drivers/usb/host/ehci-atmel.c | 102 +-
 drivers/usb/host/ohci-at91.c  | 126 --
 2 files changed, 149 insertions(+), 79 deletions(-)

-- 
2.1.4

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


[PATCHv4 3/6] USB: host: ohci-at91: Stop/start USB PLL for all sleep modes

2015-01-18 Thread Sylvain Rochet
Disable/unprepare clocks without testing the sleep target_state, removed
the at91_suspend_entering_slow_clock() call (which is only a
target_state == PM_SUSPEND_MEM).

Other kind of suspend now benefit from the power save induced by this
PLL deactivation. The resume penalty is about 500 us, which is not
negligible but acceptable considering the amount of power we are saving.

Signed-off-by: Sylvain Rochet 
Reported-by: Boris Brezillon 
---
 drivers/usb/host/ohci-at91.c | 25 +
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 65e7836..79e343e 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -49,6 +49,8 @@ extern int usb_disabled(void);
 
 static void at91_start_clock(void)
 {
+   if (clocked)
+   return;
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
clk_set_rate(uclk, 4800);
clk_prepare_enable(uclk);
@@ -61,6 +63,8 @@ static void at91_start_clock(void)
 
 static void at91_stop_clock(void)
 {
+   if (!clocked)
+   return;
clk_disable_unprepare(fclk);
clk_disable_unprepare(iclk);
clk_disable_unprepare(hclk);
@@ -615,16 +619,14 @@ ohci_hcd_at91_drv_suspend(struct device *dev)
 *
 * REVISIT: some boards will be able to turn VBUS off...
 */
-   if (at91_suspend_entering_slow_clock()) {
-   ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
-   ohci->hc_control &= OHCI_CTRL_RWC;
-   ohci_writel(ohci, ohci->hc_control, &ohci->regs->control);
-   ohci->rh_state = OHCI_RH_HALTED;
-
-   /* flush the writes */
-   (void) ohci_readl (ohci, &ohci->regs->control);
-   at91_stop_clock();
-   }
+   ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
+   ohci->hc_control &= OHCI_CTRL_RWC;
+   ohci_writel(ohci, ohci->hc_control, &ohci->regs->control);
+   ohci->rh_state = OHCI_RH_HALTED;
+
+   /* flush the writes */
+   (void) ohci_readl (ohci, &ohci->regs->control);
+   at91_stop_clock();
 
return ret;
 }
@@ -636,8 +638,7 @@ static int ohci_hcd_at91_drv_resume(struct device *dev)
if (device_may_wakeup(dev))
disable_irq_wake(hcd->irq);
 
-   if (!clocked)
-   at91_start_clock();
+   at91_start_clock();
 
ohci_resume(hcd, false);
return 0;
-- 
2.1.4

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


[PATCHv4 5/6] USB: host: ohci-at91: Move global variables to private struct

2015-01-18 Thread Sylvain Rochet
This patch move AT91 OHCI global variables (clocks ptr and clocked
boolean) to private struct ohci_at91_priv, stored in ohci->priv.

Signed-off-by: Sylvain Rochet 
---
 drivers/usb/host/ohci-at91.c | 86 ++--
 1 file changed, 52 insertions(+), 34 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 79e343e..2e50d3b 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -33,7 +33,16 @@
for ((index) = 0; (index) < AT91_MAX_USBH_PORTS; (index)++)
 
 /* interface, function and usb clocks; sometimes also an AHB clock */
-static struct clk *iclk, *fclk, *uclk, *hclk;
+#define hcd_to_ohci_at91_priv(h) \
+   ((struct ohci_at91_priv *)hcd_to_ohci(h)->priv)
+
+struct ohci_at91_priv {
+   struct clk *iclk;
+   struct clk *fclk;
+   struct clk *uclk;
+   struct clk *hclk;
+   bool clocked;
+};
 /* interface and function clocks; sometimes also an AHB clock */
 
 #define DRIVER_DESC "OHCI Atmel driver"
@@ -41,49 +50,53 @@ static struct clk *iclk, *fclk, *uclk, *hclk;
 static const char hcd_name[] = "ohci-atmel";
 
 static struct hc_driver __read_mostly ohci_at91_hc_driver;
-static int clocked;
+
+static const struct ohci_driver_overrides ohci_at91_drv_overrides __initconst 
= {
+   .extra_priv_size = sizeof(struct ohci_at91_priv),
+};
 
 extern int usb_disabled(void);
 
 /*-*/
 
-static void at91_start_clock(void)
+static void at91_start_clock(struct ohci_at91_priv *ohci_at91)
 {
-   if (clocked)
+   if (ohci_at91->clocked)
return;
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
-   clk_set_rate(uclk, 4800);
-   clk_prepare_enable(uclk);
+   clk_set_rate(ohci_at91->uclk, 4800);
+   clk_prepare_enable(ohci_at91->uclk);
}
-   clk_prepare_enable(hclk);
-   clk_prepare_enable(iclk);
-   clk_prepare_enable(fclk);
-   clocked = 1;
+   clk_prepare_enable(ohci_at91->hclk);
+   clk_prepare_enable(ohci_at91->iclk);
+   clk_prepare_enable(ohci_at91->fclk);
+   ohci_at91->clocked = true;
 }
 
-static void at91_stop_clock(void)
+static void at91_stop_clock(struct ohci_at91_priv *ohci_at91)
 {
-   if (!clocked)
+   if (!ohci_at91->clocked)
return;
-   clk_disable_unprepare(fclk);
-   clk_disable_unprepare(iclk);
-   clk_disable_unprepare(hclk);
+   clk_disable_unprepare(ohci_at91->fclk);
+   clk_disable_unprepare(ohci_at91->iclk);
+   clk_disable_unprepare(ohci_at91->hclk);
if (IS_ENABLED(CONFIG_COMMON_CLK))
-   clk_disable_unprepare(uclk);
-   clocked = 0;
+   clk_disable_unprepare(ohci_at91->uclk);
+   ohci_at91->clocked = false;
 }
 
 static void at91_start_hc(struct platform_device *pdev)
 {
struct usb_hcd *hcd = platform_get_drvdata(pdev);
struct ohci_regs __iomem *regs = hcd->regs;
+   struct ohci_at91_priv *ohci_at91 = hcd_to_ohci_at91_priv(hcd);
 
dev_dbg(&pdev->dev, "start\n");
 
/*
 * Start the USB clocks.
 */
-   at91_start_clock();
+   at91_start_clock(ohci_at91);
 
/*
 * The USB host controller must remain in reset.
@@ -95,6 +108,7 @@ static void at91_stop_hc(struct platform_device *pdev)
 {
struct usb_hcd *hcd = platform_get_drvdata(pdev);
struct ohci_regs __iomem *regs = hcd->regs;
+   struct ohci_at91_priv *ohci_at91 = hcd_to_ohci_at91_priv(hcd);
 
dev_dbg(&pdev->dev, "stop\n");
 
@@ -106,7 +120,7 @@ static void at91_stop_hc(struct platform_device *pdev)
/*
 * Stop the USB clocks.
 */
-   at91_stop_clock();
+   at91_stop_clock(ohci_at91);
 }
 
 
@@ -133,6 +147,7 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
struct ohci_hcd *ohci;
int retval;
struct usb_hcd *hcd = NULL;
+   struct ohci_at91_priv *ohci_at91;
struct device *dev = &pdev->dev;
struct resource *res;
int irq;
@@ -146,6 +161,7 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
hcd = usb_create_hcd(driver, dev, "at91");
if (!hcd)
return -ENOMEM;
+   ohci_at91 = hcd_to_ohci_at91_priv(hcd);
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
hcd->regs = devm_ioremap_resource(dev, res);
@@ -156,29 +172,29 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res);
 
-   iclk = devm_clk_get(dev, "ohci_clk");
-   if (IS_ERR(iclk)) {
+   ohci_at91->iclk = devm_clk_get(dev, "ohci_clk");
+   if (IS_ERR(ohci_at91->iclk)) {
dev_err(dev, "failed to get ohci_clk\n");
-   retval = PTR_ERR(iclk);
+   retval = PTR_ERR(ohci_at91->iclk);
   

[PATCHv4 6/6] USB: host: ohci-at91: usb_hcd_at91_probe(), remove useless stack initialisation

2015-01-18 Thread Sylvain Rochet
struct usb_hcd *hcd = NULL;
...
hcd = usb_create_hcd(driver, dev, "at91");

This patch remove *hcd useless initialisation

Signed-off-by: Sylvain Rochet 
---
 drivers/usb/host/ohci-at91.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 2e50d3b..8edc5df 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -146,7 +146,7 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
struct at91_usbh_data *board;
struct ohci_hcd *ohci;
int retval;
-   struct usb_hcd *hcd = NULL;
+   struct usb_hcd *hcd;
struct ohci_at91_priv *ohci_at91;
struct device *dev = &pdev->dev;
struct resource *res;
-- 
2.1.4

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


[PATCHv4 1/6] USB: host: ehci-atmel: Add suspend/resume support

2015-01-18 Thread Sylvain Rochet
This patch add suspend/resume support for Atmel EHCI, mostly
about disabling and unpreparing clocks so USB PLL is stopped
before entering sleep state.

Signed-off-by: Sylvain Rochet 
---
 drivers/usb/host/ehci-atmel.c | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 56a8850..5a15e3d 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -37,6 +37,8 @@ static int clocked;
 
 static void atmel_start_clock(void)
 {
+   if (clocked)
+   return;
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
clk_set_rate(uclk, 4800);
clk_prepare_enable(uclk);
@@ -48,6 +50,8 @@ static void atmel_start_clock(void)
 
 static void atmel_stop_clock(void)
 {
+   if (!clocked)
+   return;
clk_disable_unprepare(fclk);
clk_disable_unprepare(iclk);
if (IS_ENABLED(CONFIG_COMMON_CLK))
@@ -174,6 +178,29 @@ static int ehci_atmel_drv_remove(struct platform_device 
*pdev)
return 0;
 }
 
+#ifdef CONFIG_PM
+static int ehci_atmel_drv_suspend(struct device *dev)
+{
+   struct usb_hcd *hcd = dev_get_drvdata(dev);
+   int ret;
+
+   ret = ehci_suspend(hcd, false);
+   if (ret)
+   return ret;
+
+   atmel_stop_clock();
+   return 0;
+}
+
+static int ehci_atmel_drv_resume(struct device *dev)
+{
+   struct usb_hcd *hcd = dev_get_drvdata(dev);
+
+   atmel_start_clock();
+   return ehci_resume(hcd, false);
+}
+#endif
+
 #ifdef CONFIG_OF
 static const struct of_device_id atmel_ehci_dt_ids[] = {
{ .compatible = "atmel,at91sam9g45-ehci" },
@@ -183,12 +210,16 @@ static const struct of_device_id atmel_ehci_dt_ids[] = {
 MODULE_DEVICE_TABLE(of, atmel_ehci_dt_ids);
 #endif
 
+static SIMPLE_DEV_PM_OPS(ehci_atmel_pm_ops, ehci_atmel_drv_suspend,
+   ehci_atmel_drv_resume);
+
 static struct platform_driver ehci_atmel_driver = {
.probe  = ehci_atmel_drv_probe,
.remove = ehci_atmel_drv_remove,
.shutdown   = usb_hcd_platform_shutdown,
.driver = {
.name   = "atmel-ehci",
+   .pm = &ehci_atmel_pm_ops,
.of_match_table = of_match_ptr(atmel_ehci_dt_ids),
},
 };
-- 
2.1.4

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


[PATCHv4 2/6] USB: host: ohci-at91: Use struct dev_pm_ops instead of struct platform_driver

2015-01-18 Thread Sylvain Rochet
This patch replace struct platform_driver.{resume,suspend} PM bindings
to a new struct dev_pm_ops.

Signed-off-by: Sylvain Rochet 
---
 drivers/usb/host/ohci-at91.c | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index dc9e4e6..65e7836 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -593,11 +593,11 @@ static int ohci_hcd_at91_drv_remove(struct 
platform_device *pdev)
 #ifdef CONFIG_PM
 
 static int
-ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg)
+ohci_hcd_at91_drv_suspend(struct device *dev)
 {
-   struct usb_hcd  *hcd = platform_get_drvdata(pdev);
+   struct usb_hcd  *hcd = dev_get_drvdata(dev);
struct ohci_hcd *ohci = hcd_to_ohci(hcd);
-   booldo_wakeup = device_may_wakeup(&pdev->dev);
+   booldo_wakeup = device_may_wakeup(dev);
int ret;
 
if (do_wakeup)
@@ -629,11 +629,11 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, 
pm_message_t mesg)
return ret;
 }
 
-static int ohci_hcd_at91_drv_resume(struct platform_device *pdev)
+static int ohci_hcd_at91_drv_resume(struct device *dev)
 {
-   struct usb_hcd  *hcd = platform_get_drvdata(pdev);
+   struct usb_hcd  *hcd = dev_get_drvdata(dev);
 
-   if (device_may_wakeup(&pdev->dev))
+   if (device_may_wakeup(dev))
disable_irq_wake(hcd->irq);
 
if (!clocked)
@@ -642,19 +642,18 @@ static int ohci_hcd_at91_drv_resume(struct 
platform_device *pdev)
ohci_resume(hcd, false);
return 0;
 }
-#else
-#define ohci_hcd_at91_drv_suspend NULL
-#define ohci_hcd_at91_drv_resume  NULL
 #endif
 
+static SIMPLE_DEV_PM_OPS(ohci_hcd_at91_pm_ops, ohci_hcd_at91_drv_suspend,
+   ohci_hcd_at91_drv_resume);
+
 static struct platform_driver ohci_hcd_at91_driver = {
.probe  = ohci_hcd_at91_drv_probe,
.remove = ohci_hcd_at91_drv_remove,
.shutdown   = usb_hcd_platform_shutdown,
-   .suspend= ohci_hcd_at91_drv_suspend,
-   .resume = ohci_hcd_at91_drv_resume,
.driver = {
.name   = "at91_ohci",
+   .pm = &ohci_hcd_at91_pm_ops,
.of_match_table = of_match_ptr(at91_ohci_dt_ids),
},
 };
-- 
2.1.4

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


[PATCHv4 4/6] USB: host: ehci-atmel: Move global variables to private struct

2015-01-18 Thread Sylvain Rochet
This patch move Atmel EHCI global variables (clocks ptr and clocked
boolean) to private struct atmel_ehci_priv, stored in ehci->priv.

Signed-off-by: Sylvain Rochet 
---
 drivers/usb/host/ehci-atmel.c | 79 +++
 1 file changed, 50 insertions(+), 29 deletions(-)

diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 5a15e3d..663f790 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -27,48 +27,66 @@
 #define DRIVER_DESC "EHCI Atmel driver"
 
 static const char hcd_name[] = "ehci-atmel";
-static struct hc_driver __read_mostly ehci_atmel_hc_driver;
 
 /* interface and function clocks */
-static struct clk *iclk, *fclk, *uclk;
-static int clocked;
+#define hcd_to_atmel_ehci_priv(h) \
+   ((struct atmel_ehci_priv *)hcd_to_ehci(h)->priv)
+
+struct atmel_ehci_priv {
+   struct clk *iclk;
+   struct clk *fclk;
+   struct clk *uclk;
+   bool clocked;
+};
+
+static struct hc_driver __read_mostly ehci_atmel_hc_driver;
+
+static const struct ehci_driver_overrides ehci_atmel_drv_overrides __initconst 
= {
+   .extra_priv_size = sizeof(struct atmel_ehci_priv),
+};
 
 /*-*/
 
-static void atmel_start_clock(void)
+static void atmel_start_clock(struct atmel_ehci_priv *atmel_ehci)
 {
-   if (clocked)
+   if (atmel_ehci->clocked)
return;
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
-   clk_set_rate(uclk, 4800);
-   clk_prepare_enable(uclk);
+   clk_set_rate(atmel_ehci->uclk, 4800);
+   clk_prepare_enable(atmel_ehci->uclk);
}
-   clk_prepare_enable(iclk);
-   clk_prepare_enable(fclk);
-   clocked = 1;
+   clk_prepare_enable(atmel_ehci->iclk);
+   clk_prepare_enable(atmel_ehci->fclk);
+   atmel_ehci->clocked = true;
 }
 
-static void atmel_stop_clock(void)
+static void atmel_stop_clock(struct atmel_ehci_priv *atmel_ehci)
 {
-   if (!clocked)
+   if (!atmel_ehci->clocked)
return;
-   clk_disable_unprepare(fclk);
-   clk_disable_unprepare(iclk);
+   clk_disable_unprepare(atmel_ehci->fclk);
+   clk_disable_unprepare(atmel_ehci->iclk);
if (IS_ENABLED(CONFIG_COMMON_CLK))
-   clk_disable_unprepare(uclk);
-   clocked = 0;
+   clk_disable_unprepare(atmel_ehci->uclk);
+   atmel_ehci->clocked = false;
 }
 
 static void atmel_start_ehci(struct platform_device *pdev)
 {
+   struct usb_hcd *hcd = platform_get_drvdata(pdev);
+   struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
+
dev_dbg(&pdev->dev, "start\n");
-   atmel_start_clock();
+   atmel_start_clock(atmel_ehci);
 }
 
 static void atmel_stop_ehci(struct platform_device *pdev)
 {
+   struct usb_hcd *hcd = platform_get_drvdata(pdev);
+   struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
+
dev_dbg(&pdev->dev, "stop\n");
-   atmel_stop_clock();
+   atmel_stop_clock(atmel_ehci);
 }
 
 /*-*/
@@ -79,6 +97,7 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev)
const struct hc_driver *driver = &ehci_atmel_hc_driver;
struct resource *res;
struct ehci_hcd *ehci;
+   struct atmel_ehci_priv *atmel_ehci;
int irq;
int retval;
 
@@ -109,6 +128,7 @@ static int ehci_atmel_drv_probe(struct platform_device 
*pdev)
retval = -ENOMEM;
goto fail_create_hcd;
}
+   atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
hcd->regs = devm_ioremap_resource(&pdev->dev, res);
@@ -120,23 +140,23 @@ static int ehci_atmel_drv_probe(struct platform_device 
*pdev)
hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res);
 
-   iclk = devm_clk_get(&pdev->dev, "ehci_clk");
-   if (IS_ERR(iclk)) {
+   atmel_ehci->iclk = devm_clk_get(&pdev->dev, "ehci_clk");
+   if (IS_ERR(atmel_ehci->iclk)) {
dev_err(&pdev->dev, "Error getting interface clock\n");
retval = -ENOENT;
goto fail_request_resource;
}
-   fclk = devm_clk_get(&pdev->dev, "uhpck");
-   if (IS_ERR(fclk)) {
+   atmel_ehci->fclk = devm_clk_get(&pdev->dev, "uhpck");
+   if (IS_ERR(atmel_ehci->fclk)) {
dev_err(&pdev->dev, "Error getting function clock\n");
retval = -ENOENT;
goto fail_request_resource;
}
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
-   uclk = devm_clk_get(&pdev->dev, "usb_clk");
-   if (IS_ERR(uclk)) {
+   atmel_ehci->uclk = devm_clk_get(&pdev->dev, "usb_clk");
+   if (IS_ERR(atmel_ehci->uclk)) {
dev_err(&pdev->dev, "failed to get uclk\

Re: [PATCH v2 3/4] mfd: dln2: add start/stop RX URBs helpers

2015-01-18 Thread Lee Jones
On Tue, 16 Dec 2014, Octavian Purdila wrote:

> This is in preparation for adding suspend / resume support.

Please re-submit this set with the Acks you have received.

Also draft a cover-letter with the current status of set, what you
need next etc.

> Signed-off-by: Octavian Purdila 
> ---
>  drivers/mfd/dln2.c | 51 +--
>  1 file changed, 41 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
> index 6d49685..75358d2 100644
> --- a/drivers/mfd/dln2.c
> +++ b/drivers/mfd/dln2.c
> @@ -587,12 +587,19 @@ static void dln2_free_rx_urbs(struct dln2_dev *dln2)
>   int i;
>  
>   for (i = 0; i < DLN2_MAX_URBS; i++) {
> - usb_kill_urb(dln2->rx_urb[i]);
>   usb_free_urb(dln2->rx_urb[i]);
>   kfree(dln2->rx_buf[i]);
>   }
>  }
>  
> +static void dln2_stop_rx_urbs(struct dln2_dev *dln2)
> +{
> + int i;
> +
> + for (i = 0; i < DLN2_MAX_URBS; i++)
> + usb_kill_urb(dln2->rx_urb[i]);
> +}
> +
>  static void dln2_free(struct dln2_dev *dln2)
>  {
>   dln2_free_rx_urbs(dln2);
> @@ -604,9 +611,7 @@ static int dln2_setup_rx_urbs(struct dln2_dev *dln2,
> struct usb_host_interface *hostif)
>  {
>   int i;
> - int ret;
>   const int rx_max_size = DLN2_RX_BUF_SIZE;
> - struct device *dev = &dln2->interface->dev;
>  
>   for (i = 0; i < DLN2_MAX_URBS; i++) {
>   dln2->rx_buf[i] = kmalloc(rx_max_size, GFP_KERNEL);
> @@ -621,7 +626,19 @@ static int dln2_setup_rx_urbs(struct dln2_dev *dln2,
> usb_rcvbulkpipe(dln2->usb_dev, dln2->ep_in),
> dln2->rx_buf[i], rx_max_size, dln2_rx, dln2);
>  
> - ret = usb_submit_urb(dln2->rx_urb[i], GFP_KERNEL);
> + }
> +
> + return 0;
> +}
> +
> +static int dln2_start_rx_urbs(struct dln2_dev *dln2, gfp_t gfp)
> +{
> + struct device *dev = &dln2->interface->dev;
> + int ret;
> + int i;
> +
> + for (i = 0; i < DLN2_MAX_URBS; i++) {
> + ret = usb_submit_urb(dln2->rx_urb[i], gfp);
>   if (ret < 0) {
>   dev_err(dev, "failed to submit RX URB: %d\n", ret);
>   return ret;
> @@ -665,9 +682,8 @@ static const struct mfd_cell dln2_devs[] = {
>   },
>  };
>  
> -static void dln2_disconnect(struct usb_interface *interface)
> +static void dln2_stop(struct dln2_dev *dln2)
>  {
> - struct dln2_dev *dln2 = usb_get_intfdata(interface);
>   int i, j;
>  
>   /* don't allow starting new transfers */
> @@ -696,6 +712,14 @@ static void dln2_disconnect(struct usb_interface 
> *interface)
>   /* wait for transfers to end */
>   wait_event(dln2->disconnect_wq, !dln2->active_transfers);
>  
> + dln2_stop_rx_urbs(dln2);
> +}
> +static void dln2_disconnect(struct usb_interface *interface)
> +{
> + struct dln2_dev *dln2 = usb_get_intfdata(interface);
> +
> + dln2_stop(dln2);
> +
>   mfd_remove_devices(&interface->dev);
>  
>   dln2_free(dln2);
> @@ -738,23 +762,30 @@ static int dln2_probe(struct usb_interface *interface,
>  
>   ret = dln2_setup_rx_urbs(dln2, hostif);
>   if (ret)
> - goto out_cleanup;
> + goto out_free;
> +
> + ret = dln2_start_rx_urbs(dln2, GFP_KERNEL);
> + if (ret)
> + goto out_stop_rx;
>  
>   ret = dln2_hw_init(dln2);
>   if (ret < 0) {
>   dev_err(dev, "failed to initialize hardware\n");
> - goto out_cleanup;
> + goto out_stop_rx;
>   }
>  
>   ret = mfd_add_hotplug_devices(dev, dln2_devs, ARRAY_SIZE(dln2_devs));
>   if (ret != 0) {
>   dev_err(dev, "failed to add mfd devices to core\n");
> - goto out_cleanup;
> + goto out_stop_rx;
>   }
>  
>   return 0;
>  
> -out_cleanup:
> +out_stop_rx:
> + dln2_stop_rx_urbs(dln2);
> +
> +out_free:
>   dln2_free(dln2);
>  
>   return ret;

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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: gadget: atmel_usba_udc: Enable/disable USB PLL on Vbus change

2015-01-18 Thread Boris Brezillon
On Sun, 18 Jan 2015 15:51:21 +0100
Sylvain Rochet  wrote:

> Prepare_enable on rising edge, disable_unprepare on falling edge. Reduce
> power consumption if USB PLL is not already necessary for OHCI or EHCI.
> If USB host is not connected we can sleep with USB PLL stopped.
> 
> This driver does not support suspend/resume yet, not suspending if we
> are still attached to an USB host is fine for what I need, this patch
> allow suspending with USB PLL stopped when USB device is not currently
> used.
> 
> Signed-off-by: Sylvain Rochet 
> ---
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 95 
> -
>  drivers/usb/gadget/udc/atmel_usba_udc.h |  4 ++
>  2 files changed, 73 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index e207d75..986677b 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -315,6 +315,38 @@ static inline void usba_cleanup_debugfs(struct usba_udc 
> *udc)
>  }
>  #endif
>  

[...]

>  
>   if (gpio_is_valid(udc->vbus_pin)) {
>   if (!devm_gpio_request(&pdev->dev, udc->vbus_pin, 
> "atmel_usba_udc")) {
> - ret = devm_request_irq(&pdev->dev,
> - gpio_to_irq(udc->vbus_pin),
> - usba_vbus_irq, 0,
> + ret = devm_request_threaded_irq(&pdev->dev,
> + gpio_to_irq(udc->vbus_pin), NULL,
> + usba_vbus_irq_thread, IRQF_NO_SUSPEND | 
> IRQF_ONESHOT,

You should drop the IRQF_NO_SUSPEND flag. If you want to wakeup on VBUS
change you should use enable_irq_wake instead.



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
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


[PATCHv3 0/2] USB: gadget: atmel_usba_udc: Enable/disable USB PLL on Vbus change

2015-01-18 Thread Sylvain Rochet
Prepare_enable on rising edge, disable_unprepare on falling edge. Reduce
power consumption if USB PLL is not already necessary for OHCI or EHCI.
If USB host is not connected we can sleep with USB PLL stopped.

This driver does not support suspend/resume yet, not suspending if we
are still attached to an USB host is fine for what I need, this patch
allow suspending with USB PLL stopped when USB device is not currently
used.

Changes since v2:
  * Use spin_lock_irqsave/unlock_irqrestore instead of spin_lock/unlock in
threaded interrupt because we are not in irq context anymore
  * Removed useless and probably harmful IRQF_NO_SUSPEND from
devm_request_threaded_irq() flags

Changes since v1:
  * Using a threaded irq and mutex instead of spinclock as suggested
  * Moved a silently fixed bug in a separate patch (1/2)

Sylvain Rochet (2):
  USB: gadget: atmel_usba_udc: Fixed vbus_prev initial state
  USB: gadget: atmel_usba_udc: Enable/disable USB PLL on Vbus change

 drivers/usb/gadget/udc/atmel_usba_udc.c | 98 -
 drivers/usb/gadget/udc/atmel_usba_udc.h |  4 ++
 2 files changed, 76 insertions(+), 26 deletions(-)

-- 
2.1.4

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


[PATCHv3 1/2] USB: gadget: atmel_usba_udc: Fixed vbus_prev initial state

2015-01-18 Thread Sylvain Rochet
If vbus gpio is high at init, we should set vbus_prev to true
accordingly to the current vbus state. Without that, we skip the first
vbus interrupt because the saved vbus state is not consistent.

Signed-off-by: Sylvain Rochet 
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index ce88237..e207d75 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -1791,6 +1791,8 @@ static int atmel_usba_start(struct usb_gadget *gadget,
toggle_bias(1);
usba_writel(udc, CTRL, USBA_ENABLE_MASK);
usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
+
+   udc->vbus_prev = 1;
}
spin_unlock_irqrestore(&udc->lock, flags);
 
-- 
2.1.4

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


[PATCHv3 2/2] USB: gadget: atmel_usba_udc: Enable/disable USB PLL on Vbus change

2015-01-18 Thread Sylvain Rochet
Prepare_enable on rising edge, disable_unprepare on falling edge. Reduce
power consumption if USB PLL is not already necessary for OHCI or EHCI.
If USB host is not connected we can sleep with USB PLL stopped.

This driver does not support suspend/resume yet, not suspending if we
are still attached to an USB host is fine for what I need, this patch
allow suspending with USB PLL stopped when USB device is not currently
used.

Signed-off-by: Sylvain Rochet 
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 96 -
 drivers/usb/gadget/udc/atmel_usba_udc.h |  4 ++
 2 files changed, 74 insertions(+), 26 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index e207d75..9cce50a 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -315,6 +315,38 @@ static inline void usba_cleanup_debugfs(struct usba_udc 
*udc)
 }
 #endif
 
+static int start_clock(struct usba_udc *udc)
+{
+   int ret;
+
+   if (udc->clocked)
+   return 0;
+
+   ret = clk_prepare_enable(udc->pclk);
+   if (ret)
+   return ret;
+   ret = clk_prepare_enable(udc->hclk);
+   if (ret) {
+   clk_disable_unprepare(udc->pclk);
+   return ret;
+   }
+
+   udc->clocked = true;
+   return ret;
+}
+
+static int stop_clock(struct usba_udc *udc)
+{
+   if (!udc->clocked)
+   return 0;
+
+   clk_disable_unprepare(udc->hclk);
+   clk_disable_unprepare(udc->pclk);
+
+   udc->clocked = false;
+   return 0;
+}
+
 static int vbus_is_present(struct usba_udc *udc)
 {
if (gpio_is_valid(udc->vbus_pin))
@@ -1719,42 +1751,56 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
return IRQ_HANDLED;
 }
 
-static irqreturn_t usba_vbus_irq(int irq, void *devid)
+static irqreturn_t usba_vbus_irq_thread(int irq, void *devid)
 {
struct usba_udc *udc = devid;
int vbus;
+   int ret;
+   unsigned long flags;
 
/* debounce */
udelay(10);
 
-   spin_lock(&udc->lock);
+   mutex_lock(&udc->vbus_mutex);
 
/* May happen if Vbus pin toggles during probe() */
-   if (!udc->driver)
+   spin_lock_irqsave(&udc->lock, flags);
+   if (!udc->driver) {
+   spin_unlock_irqrestore(&udc->lock, flags);
goto out;
+   }
+   spin_unlock_irqrestore(&udc->lock, flags);
 
vbus = vbus_is_present(udc);
if (vbus != udc->vbus_prev) {
if (vbus) {
+   ret = start_clock(udc);
+   if (ret)
+   goto out;
+
+   spin_lock_irqsave(&udc->lock, flags);
toggle_bias(1);
usba_writel(udc, CTRL, USBA_ENABLE_MASK);
usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
+   spin_unlock_irqrestore(&udc->lock, flags);
} else {
+   spin_lock_irqsave(&udc->lock, flags);
udc->gadget.speed = USB_SPEED_UNKNOWN;
reset_all_endpoints(udc);
toggle_bias(0);
usba_writel(udc, CTRL, USBA_DISABLE_MASK);
-   if (udc->driver->disconnect) {
-   spin_unlock(&udc->lock);
+   spin_unlock_irqrestore(&udc->lock, flags);
+
+   stop_clock(udc);
+
+   if (udc->driver->disconnect)
udc->driver->disconnect(&udc->gadget);
-   spin_lock(&udc->lock);
-   }
}
udc->vbus_prev = vbus;
}
 
 out:
-   spin_unlock(&udc->lock);
+   mutex_unlock(&udc->vbus_mutex);
 
return IRQ_HANDLED;
 }
@@ -1762,7 +1808,7 @@ out:
 static int atmel_usba_start(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
 {
-   int ret;
+   int ret = 0;
struct usba_udc *udc = container_of(gadget, struct usba_udc, gadget);
unsigned long flags;
 
@@ -1772,31 +1818,29 @@ static int atmel_usba_start(struct usb_gadget *gadget,
udc->driver = driver;
spin_unlock_irqrestore(&udc->lock, flags);
 
-   ret = clk_prepare_enable(udc->pclk);
-   if (ret)
-   return ret;
-   ret = clk_prepare_enable(udc->hclk);
-   if (ret) {
-   clk_disable_unprepare(udc->pclk);
-   return ret;
-   }
-
+   mutex_lock(&udc->vbus_mutex);
udc->vbus_prev = 0;
if (gpio_is_valid(udc->vbus_pin))
enable_irq(gpio_to_irq(udc->vbus_pin));
 
/* If Vbus is present, enable the controller and wait for reset */
-   spin_lock_irqsave(&udc->lock, flags);
if (vbus_is_present(udc) && udc->vbus_prev == 0) {
+   ret = start_clock(ud

[PATCH 001/001] usbhid: Fix initialisation and force effect modifications for the Microsoft Sidewinder Force Feedback Pro 2 joystick

2015-01-18 Thread Jim Keir

From: Jim Keir 
Signed-off-by: Jim Keir 

Currently the SWFF2 driver fails during initialisation, making the force
capability of the joystick unusable. Further, there is a long-standing
bug in the same driver where commands to update force parameters are
addressed to the last-created force effect instead of the specified one,
making it impossible to modify effects after their creation.

Three bugs are addressed:

1) The FF2 driver (usbhid/hid-pidff.c) sends commands to the stick
during ff_init. However, this is called inside a block where
driver_input_lock is locked, so the results of these initial commands
are discarded. This one is the "killer", without this nothing else works.

ff_init issues commands using "hid_hw_request". This eventually goes to
hid_input_report, which returns -EBUSY because driver_input_lock is
locked. The change is to delay the ff_init call in hid-core.c until
after this lock has been released.

2) The usbhid driver ignores an endpoint stall when sending control
commands, causing the first few commands of the hid-pidff.c
initialisation to get lost.

usbhid/hid-core.c has been modified by copying lines into "hid_ctrl"
from the "hid_irq_in" function in the same file.

3) The FF2 driver (usbhid/hid-pidff.c) does not set the effect ID when
uploading an effect. The result is that the initial upload works but
subsequent uploads to modify effect parameters are all directed at the
last-created effect.

The targeted effect ID must be passed back to the device when effect
parameters are changed. This is done at the start of
"pidff_set_condition_report", "pidff_set_periodic_report" etc. based on
the value of "pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0]".
However, this value is only ever set during pidff_request_effect_upload.
The result is stored in "pidff->pid_id[effect->id]" at the end of
pid_upload_effect, for later use. However, if an effect is modified and
re-sent then this identifier is not being copied back from
pidff->pid_id[effect->id] before sending the command to the device. The
fix is to do this at the start of pidff_upload_effect.

This patch taken against kernel 3.13.0

---

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 905e40a..a608ee6 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1546,9 +1546,8 @@ int hid_connect(struct hid_device *hdev, unsigned int 
connect_mask)
 return -ENODEV;
 }

-if ((hdev->claimed & HID_CLAIMED_INPUT) &&
-(connect_mask & HID_CONNECT_FF) && hdev->ff_init)
-hdev->ff_init(hdev);
+/* Removed ff_init() call from here. It does device I/O but this
+ * is blocked because driver_input_lock is currently locked. */

 len = 0;
 if (hdev->claimed & HID_CLAIMED_INPUT)
@@ -2029,6 +2028,13 @@ static int hid_device_probe(struct device *dev)
 unlock:
 if (!hdev->io_started)
 up(&hdev->driver_input_lock);
+
+if ((hdev->claimed & HID_CLAIMED_INPUT) && hdev->ff_init) {
+/* Late init of PID force-feedback drivers moved to after
+ * unlock of driver_input_lock */
+hdev->ff_init(hdev);
+}
+
 unlock_driver_lock:
 up(&hdev->driver_lock);
 return ret;
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 029965e..5d34dd7 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -505,7 +505,12 @@ static void hid_ctrl(struct urb *urb)
 case -EPROTO:/* protocol error or unplug */
 case -ECONNRESET:/* unlink */
 case -ENOENT:
+break;
 case -EPIPE:/* report not available */
+usbhid_mark_busy(usbhid);
+clear_bit(HID_IN_RUNNING, &usbhid->iofl);
+set_bit(HID_CLEAR_HALT, &usbhid->iofl);
+schedule_work(&usbhid->reset_work);
 break;
 default:/* error */
 hid_warn(urb->dev, "ctrl urb status %d received\n", status);
diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c
index 10b6167..3f8ea63 100644
--- a/drivers/hid/usbhid/hid-pidff.c
+++ b/drivers/hid/usbhid/hid-pidff.c
@@ -568,6 +568,13 @@ static int pidff_upload_effect(struct input_dev *dev, 
struct ff_effect *effect,
 int type_id;
 int error;

+pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0] = 0;
+
+if (old && effect) {
+pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0] =
+pidff->pid_id[effect->id];
+}
+
 switch (effect->type) {
 case FF_CONSTANT:
 if (!old) {
@@ -701,10 +708,14 @@ static int pidff_upload_effect(struct input_dev *dev, 
struct ff_effect *effect,
 return -EINVAL;
 }

-if (!old)
+if (!old) {
 pidff->pid_id[effect->id] =
 pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0];

+hid_dbg(pidff->hid, "Created new effect of type 0x%02x with h/w ID %d, 
driver ID %d\n",
+effect->type, pidff->pid_id[effect->id], effect->id);
+}
+
 hid_dbg(pidff->hid, "uploaded\n");

 return 0;

Re: [PATCHv3 0/5] USB: host: Atmel OHCI and EHCI drivers improvements

2015-01-18 Thread Alan Stern
On Sat, 17 Jan 2015, Sylvain Rochet wrote:

> Sylvain Rochet (5):
>   USB: host: ehci_atmel: Add suspend/resume support
>   USB: host: ohci_at91: Stop/start USB PLL for all sleep modes
>   USB: host: ehci_atmel: Move global variables to private struct
>   USB: host: ohci_at91: Move global variables to private struct
>   USB: host: ohci_at91: usb_hcd_at91_probe(), remove useless stack
> initialisation
> 
>  drivers/usb/host/ehci-atmel.c | 102 +++--
>  drivers/usb/host/ohci-at91.c  | 104 
> +-
>  2 files changed, 138 insertions(+), 68 deletions(-)

These patches look pretty good to me.  Have you run them through 
checkpatch.pl?

Alan Stern

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


Re: [PATCH 2/2] Add HCS_PPC when getting root hub status

2015-01-18 Thread Alan Stern
On Sun, 18 Jan 2015, Chechun Kuo wrote:

> for some platform ehci controller, it is possible there is no port power 
> control capability in the root hub.
> And we add port power control determination when getting root hub port status.

Why do you need to do this?  Doesn't the current code always give the 
right result?

Alan Stern

> Signed-off-by: Chechun Kuo 
> ---
>  drivers/usb/host/ehci-hub.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
> index 5728829..1923984 100644
> --- a/drivers/usb/host/ehci-hub.c
> +++ b/drivers/usb/host/ehci-hub.c
> @@ -1118,7 +1118,7 @@ int ehci_hub_control(
>   status |= USB_PORT_STAT_OVERCURRENT;
>   if (temp & PORT_RESET)
>   status |= USB_PORT_STAT_RESET;
> - if (temp & PORT_POWER)
> + if (HCS_PPC(ehci->hcs_params) && (temp & PORT_POWER))
>   status |= USB_PORT_STAT_POWER;
>   if (test_bit(wIndex, &ehci->port_c_suspend))
>   status |= USB_PORT_STAT_C_SUSPEND << 16;
> 

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


Re: [PATCH 1/2] Add hub port switchable when checking port power

2015-01-18 Thread Alan Stern
On Sun, 18 Jan 2015, Chechun Kuo wrote:

> In check_port_resume_type, we will check port power status to determine 
> whether the status should change to -ENODEV.
> If all ports power control of the hub are handled at once, the port power 
> status may not represent the real case and cause resume fail.
> At this patch, we add hub_is_port_power_switchable as well as checking the 
> port power.

I don't understand the reason for this patch.

Are you saying that the PORT POWER bit in the port status will be wrong 
(that is, will be 0) if the hub doesn't support power switching?  
According to section 11.24.2.7.1.6 of the USB-2 spec:

This bit is implemented on all ports whether or not actual
port power switching devices are present.

So why is this patch needed?  Does it fix any real problems?

Alan Stern

> Signed-off-by: Chechun Kuo 
> ---
>  drivers/usb/core/hub.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index b649fef..a50b257 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -2904,7 +2904,8 @@ static int check_port_resume_type(struct usb_device 
> *udev,
>   }
>   /* Is the device still present? */
>   else if (status || port_is_suspended(hub, portstatus) ||
> - !port_is_power_on(hub, portstatus) ||
> + (hub_is_port_power_switchable(hub)
> + && !port_is_power_on(hub, portstatus)) ||
>   !(portstatus & USB_PORT_STAT_CONNECTION)) {
>   if (status >= 0)
>   status = -ENODEV;
> 

--
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: gadget: atmel_usba_udc: Enable/disable USB PLL on Vbus change

2015-01-18 Thread Boris Brezillon
On Sun, 18 Jan 2015 15:51:21 +0100
Sylvain Rochet  wrote:

> Prepare_enable on rising edge, disable_unprepare on falling edge. Reduce
> power consumption if USB PLL is not already necessary for OHCI or EHCI.
> If USB host is not connected we can sleep with USB PLL stopped.
> 
> This driver does not support suspend/resume yet, not suspending if we
> are still attached to an USB host is fine for what I need, this patch
> allow suspending with USB PLL stopped when USB device is not currently
> used.
> 
> Signed-off-by: Sylvain Rochet 
> ---
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 95 
> -
>  drivers/usb/gadget/udc/atmel_usba_udc.h |  4 ++
>  2 files changed, 73 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index e207d75..986677b 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -315,6 +315,38 @@ static inline void usba_cleanup_debugfs(struct usba_udc 
> *udc)
>  }
>  #endif
>  
> +static int start_clock(struct usba_udc *udc)
> +{
> + int ret;
> +
> + if (udc->clocked)
> + return 0;
> +
> + ret = clk_prepare_enable(udc->pclk);
> + if (ret)
> + return ret;
> + ret = clk_prepare_enable(udc->hclk);
> + if (ret) {
> + clk_disable_unprepare(udc->pclk);
> + return ret;
> + }
> +
> + udc->clocked = true;
> + return ret;
> +}
> +
> +static int stop_clock(struct usba_udc *udc)
> +{
> + if (!udc->clocked)
> + return 0;
> +
> + clk_disable_unprepare(udc->hclk);
> + clk_disable_unprepare(udc->pclk);
> +
> + udc->clocked = false;
> + return 0;
> +}
> +
>  static int vbus_is_present(struct usba_udc *udc)
>  {
>   if (gpio_is_valid(udc->vbus_pin))
> @@ -1719,42 +1751,55 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
>   return IRQ_HANDLED;
>  }
>  
> -static irqreturn_t usba_vbus_irq(int irq, void *devid)
> +static irqreturn_t usba_vbus_irq_thread(int irq, void *devid)
>  {
>   struct usba_udc *udc = devid;
>   int vbus;
> + int ret;
>  
>   /* debounce */
>   udelay(10);
>  
> - spin_lock(&udc->lock);
> + mutex_lock(&udc->vbus_mutex);
>  
>   /* May happen if Vbus pin toggles during probe() */
> - if (!udc->driver)
> + spin_lock(&udc->lock);

Since this lock is taken in irq context (usba_udc_irq) and this
handler is not called in irq context anymore you should use
spin_lock_irqsave/unlock_irqrestore here.

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
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: Difference between run time and normal suspend

2015-01-18 Thread Alan Stern
On Sun, 18 Jan 2015, vichy wrote:

> after tracing the source, I only can find the ehci_suspend is called
> when system hibernate/suspend.
> rpm_suspend use below method to find out suspend callback
> if (dev->pm_domain)
> callback = dev->pm_domain->ops.runtime_suspend;
> else if (dev->type && dev->type->pm)
> callback = dev->type->pm->runtime_suspend;
> else if (dev->class && dev->class->pm)
> callback = dev->class->pm->runtime_suspend;
> else if (dev->bus && dev->bus->pm)
> callback = dev->bus->pm->runtime_suspend;
> else
> callback = NULL;
> 
> ehci_suspend doesn't register any one of above function.

ehci_pci_init() in ehci_pci.c stores ehci_suspend in
ehci_pci_hc_driver.pci_suspend.  That pointer is called by
suspend_common() in hcd-pci.c, which is called by both
hcd_pci_suspend() and hcd_pci_runtime_suspend().

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: hard lockup with USB3380

2015-01-18 Thread Paul Jones
Ricardo,

I think I figured out the problem: my 3380 was running in legacy adapter mode.
I am now capable of connecting both g_mass_storage and g_ether without any 
kernel panics after ensuring the 3380 is in enhanced adapter mode.

My only concern is the speed from my Mac to Linux:
- g_ether: scp transfer 42Mb/s 
- g_mass_storage: dd bs=64k 116Mb/s (backed by SSD storage)
For comparison, a direct gigabit connection allows between 90 and 95Mb/s using 
scp between the machines.
Local writes on the linux side using dd is around 480Mb/s (on the same SSD 
storage).

Any ideas on how to achieve a higher performance?

Regards,
Paul.

On 25 Nov 2014, at 16:30, Paul Jones  wrote:

> Ricardo,
> 
> Unfortunately your latest change gives similar results, cycling errors in the 
> log:
> [  201.287706] [ cut here ]
> [  201.288328] WARNING: CPU: 3 PID: 1500 at 
> drivers/usb/gadget/udc/net2280.c:816 start_dma+0x153/0x160 [net2280]()
> [  201.288991] Modules linked in: g_mass_storage usb_f_mass_storage 
> libcomposite configfs net2280 udc_core snd_hda_codec_hdmi joydev hid_generic 
> usbhid hid i915 intel_rapl x86_pkg_temp_thermal intel_powerclamp 
> snd_hda_codec_realtek coretemp kvm_intel snd_hda_codec_generic kvm 
> snd_hda_intel eeepc_wmi asus_wmi snd_hda_controller rfcomm snd_seq_midi bnep 
> snd_seq_midi_event bluetooth sparse_keymap snd_hda_codec crct10dif_pclmul 
> snd_rawmidi snd_hwdep crc32_pclmul snd_pcm ghash_clmulni_intel aesni_intel 
> aes_x86_64 drm_kms_helper lrw gf128mul glue_helper ablk_helper cryptd snd_seq 
> mei_me mei serio_raw drm lpc_ich video mac_hid tpm_infineon wmi 
> snd_seq_device snd_timer snd parport_pc i2c_algo_bit soundcore ppdev lp 
> parport e1000e psmouse r8169 ahci libahci mii ptp pps_core
> [  201.292574] CPU: 3 PID: 1500 Comm: file-storage Tainted: GW  
> 3.17.0-rc5+ #2
> [  201.293277] Hardware name: ASUS All Series/Q87T, BIOS 0215 09/06/2013
> [  201.293976]  0009 8803f1d8fd28 81746707 
> 
> [  201.294689]  8803f1d8fd60 8106c93d 8803efc26478 
> 8800ce317100
> [  201.295398]  c90005b9c1a0 8800ce317168 8803efc26320 
> 8803f1d8fd70
> [  201.296109] Call Trace:
> [  201.296815]  [] dump_stack+0x45/0x56
> [  201.297524]  [] warn_slowpath_common+0x7d/0xa0
> [  201.298218]  [] warn_slowpath_null+0x1a/0x20
> [  201.298891]  [] start_dma+0x153/0x160 [net2280]
> [  201.299554]  [] net2280_queue+0x2db/0x480 [net2280]
> [  201.300209]  [] start_transfer.isra.32+0x71/0xe0 
> [usb_f_mass_storage]
> [  201.300851]  [] start_out_transfer+0x3e/0x80 
> [usb_f_mass_storage]
> [  201.301474]  [] fsg_main_thread+0x207/0x17f0 
> [usb_f_mass_storage]
> [  201.302069]  [] ? __schedule+0x37a/0x830
> [  201.302607]  [] ? handle_exception+0x460/0x460 
> [usb_f_mass_storage]
> [  201.303200]  [] kthread+0xd2/0xf0
> [  201.303776]  [] ? kthread_create_on_node+0x180/0x180
> [  201.304328]  [] ret_from_fork+0x7c/0xb0
> [  201.304973]  [] ? kthread_create_on_node+0x180/0x180
> [  201.305486] ---[ end trace a7f3e86a1a37203b ]—
> Followed by:
> [  263.311338] net2280 :01:00.0: The dmastat return = 5002!!
> [  263.409818] g_mass_storage gadget: super-speed config #1: Linux 
> File-Backed Storage
> 
> as long as you have ideas, I’ll be more than happy to try them :)
> 
> Paul.
> 
> On 25 Nov 2014, at 15:59, Ricardo Ribalda Delgado  
> wrote:
> 
>> One last try :)
>> 
>> Instead of:
>> 
>> if (likely(t & BIT(FIFO_EMPTY))) {
>> 
>> have this:
>> 
>> if ( t & BIT(NAK_OUT_PACKETS)){
>>  count = readl(&ep->dma->dmacount);
>>  count &= DMA_BYTE_COUNT_MASK;
>>  break;
>> }
>> 
>> if (likely(t & BIT(FIFO_EMPTY))) {
>> 
>> 
>> 
>> On Tue, Nov 25, 2014 at 3:54 PM, Paul Jones  wrote:
>>> Ricardo,
>>> 
>>> it no longer locks up but if I try to write to the drive, I get cycles of:
>>> [ 2334.127653] [ cut here ]
>>> [ 2334.128318] WARNING: CPU: 0 PID: 2140 at 
>>> drivers/usb/gadget/udc/net2280.c:816 start_dma+0x153/0x160 [net2280]()
>>> [ 2334.129105] Modules linked in: g_mass_storage usb_f_mass_storage 
>>> libcomposite configfs net2280 udc_core snd_hda_codec_hdmi i915 rfcomm bnep 
>>> bluetooth snd_hda_codec_realtek snd_hda_codec_generic intel_rapl 
>>> x86_pkg_temp_thermal snd_hda_intel intel_powerclamp coretemp 
>>> snd_hda_controller kvm_intel snd_hda_codec kvm drm_kms_helper snd_hwdep 
>>> snd_pcm drm snd_seq_midi joydev snd_seq_midi_event snd_rawmidi hid_generic 
>>> snd_seq eeepc_wmi asus_wmi sparse_keymap crct10dif_pclmul usbhid 
>>> crc32_pclmul ghash_clmulni_intel aesni_intel snd_seq_device snd_timer 
>>> aes_x86_64 hid lrw gf128mul glue_helper snd ablk_helper mei_me mei cryptd 
>>> serio_raw lpc_ich i2c_algo_bit wmi soundcore video tpm_infineon mac_hid 
>>> parport_pc ppdev lp parport e1000e psmouse r8169 ahci ptp libahci mii 
>>> pps_core
>>> [ 2334.132731] CPU: 0 PID: 2140 Comm: file-storage Tainted: GW  
>>> 3.17.0-rc5+ #2
>>> [ 2334.133438] Hardware 

[PATCH v4 09/11] usb: storage: adjust module reference for scsi host

2015-01-18 Thread Akinobu Mita
The unusual usb storage drivers (ums-alauda, ums-cypress, ...) depend
on usb-storage module.  The module reference of these scsi host is
initialized to usb-storage's one.  Because these drivers use
usb_stor_probe1() which is defined in usb-storage module and calls
scsi_host_alloc().  So these drivers can be unloaded even if the scsi
device is being accessed.

This fixes it by converting usb_stor_probe1() into macro so that these
drivers can pass their correct module reference through
__scsi_host_alloc().

Signed-off-by: Akinobu Mita 
Cc: Matthew Dharm 
Cc: Greg Kroah-Hartman 
Cc: Alan Stern 
Cc: Christoph Hellwig 
Cc: "James E.J. Bottomley" 
Cc: linux-usb@vger.kernel.org
Cc: usb-stor...@lists.one-eyed-alien.net
Cc: linux-s...@vger.kernel.org
---
 drivers/usb/storage/scsiglue.c | 3 ---
 drivers/usb/storage/usb.c  | 9 +
 drivers/usb/storage/usb.h  | 7 +--
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 0e400f3..04fab36 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -587,9 +587,6 @@ struct scsi_host_template usb_stor_host_template = {
 
/* sysfs device attributes */
.sdev_attrs =   sysfs_device_attr_list,
-
-   /* module management */
-   .module =   THIS_MODULE
 };
 
 /* To Report "Illegal Request: Invalid Field in CDB */
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index d468d02..768413f0 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -911,10 +911,11 @@ static unsigned int usb_stor_sg_tablesize(struct 
usb_interface *intf)
 }
 
 /* First part of general USB mass-storage probing */
-int usb_stor_probe1(struct us_data **pus,
+int __usb_stor_probe1(struct us_data **pus,
struct usb_interface *intf,
const struct usb_device_id *id,
-   struct us_unusual_dev *unusual_dev)
+   struct us_unusual_dev *unusual_dev,
+   struct module *owner)
 {
struct Scsi_Host *host;
struct us_data *us;
@@ -926,7 +927,7 @@ int usb_stor_probe1(struct us_data **pus,
 * Ask the SCSI layer to allocate a host structure, with extra
 * space at the end for our private us_data structure.
 */
-   host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us));
+   host = __scsi_host_alloc(&usb_stor_host_template, sizeof(*us), owner);
if (!host) {
dev_warn(&intf->dev, "Unable to allocate the scsi host\n");
return -ENOMEM;
@@ -969,7 +970,7 @@ BadDevice:
release_everything(us);
return result;
 }
-EXPORT_SYMBOL_GPL(usb_stor_probe1);
+EXPORT_SYMBOL_GPL(__usb_stor_probe1);
 
 /* Second part of general USB mass-storage probing */
 int usb_stor_probe2(struct us_data *us)
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index 307e339..0cb74ba 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -194,10 +194,13 @@ extern int usb_stor_reset_resume(struct usb_interface 
*iface);
 extern int usb_stor_pre_reset(struct usb_interface *iface);
 extern int usb_stor_post_reset(struct usb_interface *iface);
 
-extern int usb_stor_probe1(struct us_data **pus,
+extern int __usb_stor_probe1(struct us_data **pus,
struct usb_interface *intf,
const struct usb_device_id *id,
-   struct us_unusual_dev *unusual_dev);
+   struct us_unusual_dev *unusual_dev,
+   struct module *owner);
+#define usb_stor_probe1(pus, intf, id, unusual_dev) \
+   __usb_stor_probe1(pus, intf, id, unusual_dev, THIS_MODULE)
 extern int usb_stor_probe2(struct us_data *us);
 extern void usb_stor_disconnect(struct usb_interface *intf);
 
-- 
1.9.1

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


[PATCH v4 07/11] scsi: move module reference from scsi_host_template to Scsi_Host

2015-01-18 Thread Akinobu Mita
While accessing a scsi_device, the use count of the underlying LLDD
module is incremented.  The module reference is retrieved through
.module field of struct scsi_host_template.

This mapping between scsi_device and underlying LLDD module works well
except some drivers which consist with the core driver and the actual
LLDDs and scsi_host_template is defined in the core driver.  In these
cases, the actual LLDDs can be unloaded even if the scsi_device is
being accessed.

This moves owner module reference from struct scsi_host_template to
struct Scsi_Host, and it is passed through scsi_host_alloc().  Some
drivers which have the module reference mismatch problem described above
can pass their correct module reference by using __scsi_host_alloc()
which takes module reference argument.

Sub drivers of esp_scsi (mac_esp, am53c974, sun_esp, jazz_esp, sun3x_esp)
use a single scsi_host_template defined in esp_scsi module, so these
had module reference mismatch problem, but this change implicitly fixes
it.  Because sub drivers directly call scsi_host_alloc() and THIS_MODULE
is used for the module reference instead of scsi_host_template->module.

Signed-off-by: Akinobu Mita 
Cc: Vinayak Holikatti 
Cc: Dolev Raviv 
Cc: Sujit Reddy Thumma 
Cc: Subhash Jadavani 
Cc: Matthew Dharm 
Cc: Greg Kroah-Hartman 
Cc: Alan Stern 
Cc: "David S. Miller" 
Cc: Hannes Reinecke 
Cc: Tejun Heo 
Cc: Hans de Goede 
Cc: Mike Christie 
Cc: Karen Xie 
Cc: Robert Love 
Cc: Christoph Hellwig 
Cc: "James E.J. Bottomley" 
Cc: open-is...@googlegroups.com
Cc: fcoe-de...@open-fcoe.org
Cc: linux-...@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: usb-stor...@lists.one-eyed-alien.net
Cc: linux-s...@vger.kernel.org
---
 drivers/ata/libata-scsi.c |  2 +-
 drivers/scsi/53c700.c |  2 +-
 drivers/scsi/hosts.c  | 11 +++
 drivers/scsi/libfc/fc_lport.c |  2 +-
 drivers/scsi/libfc/fc_npiv.c  |  3 +--
 drivers/scsi/libiscsi.c   |  2 +-
 drivers/scsi/scsi.c   |  4 ++--
 include/scsi/scsi_host.h  |  8 +++-
 8 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index e364e86..20a963c 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3643,7 +3643,7 @@ int ata_scsi_add_hosts(struct ata_host *host, struct 
scsi_host_template *sht)
struct Scsi_Host *shost;
 
rc = -ENOMEM;
-   shost = scsi_host_alloc(sht, sizeof(struct ata_port *));
+   shost = __scsi_host_alloc(sht, sizeof(ap), host->module);
if (!shost)
goto err_alloc;
 
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index e70fd05..a5777f8 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -333,7 +333,7 @@ __NCR_700_detect(struct scsi_host_template *tpnt,
if(tpnt->proc_name == NULL)
tpnt->proc_name = "53c700";
 
-   host = scsi_host_alloc(tpnt, 4);
+   host = __scsi_host_alloc(tpnt, sizeof(hostdata), owner);
if (!host)
return NULL;
memset(hostdata->slots, 0, sizeof(struct NCR_700_command_slot)
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index eb324f1..90c109e 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -354,9 +354,10 @@ static struct device_type scsi_host_type = {
 };
 
 /**
- * scsi_host_alloc - register a scsi host adapter instance.
+ * __scsi_host_alloc - register a scsi host adapter instance.
  * @sht:   pointer to scsi host template
  * @privsize:  extra bytes to allocate for driver
+ * @owner: module which will be the owner of the scsi host
  *
  * Note:
  * Allocate a new Scsi_Host and perform basic initialization.
@@ -366,7 +367,8 @@ static struct device_type scsi_host_type = {
  * Return value:
  * Pointer to a new Scsi_Host
  **/
-struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
+struct Scsi_Host *__scsi_host_alloc(struct scsi_host_template *sht,
+   int privsize, struct module *owner)
 {
struct Scsi_Host *shost;
gfp_t gfp_mask = GFP_KERNEL;
@@ -411,6 +413,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template 
*sht, int privsize)
 */
shost->max_cmd_len = 12;
shost->hostt = sht;
+   shost->module = owner;
shost->this_id = sht->this_id;
shost->can_queue = sht->can_queue;
shost->sg_tablesize = sht->sg_tablesize;
@@ -497,12 +500,12 @@ struct Scsi_Host *scsi_host_alloc(struct 
scsi_host_template *sht, int privsize)
kfree(shost);
return NULL;
 }
-EXPORT_SYMBOL(scsi_host_alloc);
+EXPORT_SYMBOL(__scsi_host_alloc);
 
 struct Scsi_Host *__scsi_register(struct scsi_host_template *sht, int privsize,
  struct module *owner)
 {
-   struct Scsi_Host *shost = scsi_host_alloc(sht, privsize);
+   struct Scsi_Host *shost = __scsi_host_alloc(sht, privsize, owner);

[PATCH v4 00/11] scsi: fix module reference mismatch for scsi host

2015-01-18 Thread Akinobu Mita
While accessing a scsi_device, the use count of the underlying LLDD
module is incremented.  The module reference is retrieved through
.module field of struct scsi_host_template.

This mapping between scsi_device and underlying LLDD module works well
except some drivers which consist with the core driver and the actual
LLDDs and scsi_host_template is defined in the core driver.  In these
cases, the actual LLDDs can be unloaded even if the scsi_device is
being accessed.

This patch series fixes the module reference mismatch problem for
ufs, usb-storage, esp_scsi, ahci_platform, and pata_platform drivers
by moving owner module reference field from struct scsi_host_template
to struct Scsi_Host and allowing the LLDDs to set their correct module
reference.

* v4:
- Patch series is almost rewritten as module reference field in
  struct scsi_host_template has been unused anymore.  So Acked-by: and
  Reviewed-by: tags that have been received are deleted.

* v3:
- Add fix for ESP SCSI drivers

* v2:
- Pass correct module reference to usb_stor_probe1() instead of touching
  all ums-* drivers, suggested by Alan Stern

Akinobu Mita (11):
  ata: prepare to move module reference from scsi_host_template to
Scsi_Host
  iscsi: prepare to move module reference from scsi_host_template to
Scsi_Host
  cxgbi: prepare to move module reference from scsi_host_template to
Scsi_Host
  libfc: prepare to move module reference from scsi_host_template to
Scsi_Host
  53c700: prepare move module reference from scsi_host_template to
Scsi_Host
  scsi: legacy: prepare to move module reference from scsi_host_template
to Scsi_Host
  scsi: move module reference from scsi_host_template to Scsi_Host
  scsi: ufs: adjust module reference for scsi host
  usb: storage: adjust module reference for scsi host
  ata: ahci_platform: adjust module reference for scsi host
  ata: pata_of_platform: adjust module reference for scsi host

 drivers/ata/libahci_platform.c | 14 +-
 drivers/ata/libata-core.c  | 22 ---
 drivers/ata/libata-scsi.c  |  2 +-
 drivers/ata/libata-sff.c   | 61 +++---
 drivers/ata/pata_platform.c| 18 +++--
 drivers/scsi/53c700.c  |  9 ---
 drivers/scsi/53c700.h  |  7 +++--
 drivers/scsi/cxgbi/libcxgbi.c  |  8 +++---
 drivers/scsi/cxgbi/libcxgbi.h  |  6 +++--
 drivers/scsi/hosts.c   | 16 ++-
 drivers/scsi/libfc/fc_lport.c  | 26 ++
 drivers/scsi/libfc/fc_npiv.c   |  2 +-
 drivers/scsi/libiscsi.c| 12 +
 drivers/scsi/scsi.c|  4 +--
 drivers/scsi/ufs/ufshcd.c  | 13 -
 drivers/scsi/ufs/ufshcd.h  |  5 +++-
 drivers/usb/storage/scsiglue.c |  3 ---
 drivers/usb/storage/usb.c  |  9 ---
 drivers/usb/storage/usb.h  |  7 +++--
 include/linux/ahci_platform.h  |  9 ---
 include/linux/ata_platform.h   | 16 ++-
 include/linux/libata.h | 52 ---
 include/scsi/libfc.h   | 27 +++
 include/scsi/libiscsi.h|  9 ---
 include/scsi/scsi_host.h   | 13 +++--
 25 files changed, 224 insertions(+), 146 deletions(-)

Cc: Vinayak Holikatti 
Cc: Dolev Raviv 
Cc: Sujit Reddy Thumma 
Cc: Subhash Jadavani 
Cc: Matthew Dharm 
Cc: Greg Kroah-Hartman 
Cc: Alan Stern 
Cc: "David S. Miller" 
Cc: Hannes Reinecke 
Cc: Tejun Heo 
Cc: Hans de Goede 
Cc: Mike Christie 
Cc: Karen Xie 
Cc: Robert Love 
Cc: Christoph Hellwig 
Cc: "James E.J. Bottomley" 
Cc: open-is...@googlegroups.com
Cc: fcoe-de...@open-fcoe.org
Cc: linux-...@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: usb-stor...@lists.one-eyed-alien.net
Cc: linux-s...@vger.kernel.org
-- 
1.9.1

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


[PATCH 2/2] USB: gadget: atmel_usba_udc: Enable/disable USB PLL on Vbus change

2015-01-18 Thread Sylvain Rochet
Prepare_enable on rising edge, disable_unprepare on falling edge. Reduce
power consumption if USB PLL is not already necessary for OHCI or EHCI.
If USB host is not connected we can sleep with USB PLL stopped.

This driver does not support suspend/resume yet, not suspending if we
are still attached to an USB host is fine for what I need, this patch
allow suspending with USB PLL stopped when USB device is not currently
used.

Signed-off-by: Sylvain Rochet 
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 95 -
 drivers/usb/gadget/udc/atmel_usba_udc.h |  4 ++
 2 files changed, 73 insertions(+), 26 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index e207d75..986677b 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -315,6 +315,38 @@ static inline void usba_cleanup_debugfs(struct usba_udc 
*udc)
 }
 #endif
 
+static int start_clock(struct usba_udc *udc)
+{
+   int ret;
+
+   if (udc->clocked)
+   return 0;
+
+   ret = clk_prepare_enable(udc->pclk);
+   if (ret)
+   return ret;
+   ret = clk_prepare_enable(udc->hclk);
+   if (ret) {
+   clk_disable_unprepare(udc->pclk);
+   return ret;
+   }
+
+   udc->clocked = true;
+   return ret;
+}
+
+static int stop_clock(struct usba_udc *udc)
+{
+   if (!udc->clocked)
+   return 0;
+
+   clk_disable_unprepare(udc->hclk);
+   clk_disable_unprepare(udc->pclk);
+
+   udc->clocked = false;
+   return 0;
+}
+
 static int vbus_is_present(struct usba_udc *udc)
 {
if (gpio_is_valid(udc->vbus_pin))
@@ -1719,42 +1751,55 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
return IRQ_HANDLED;
 }
 
-static irqreturn_t usba_vbus_irq(int irq, void *devid)
+static irqreturn_t usba_vbus_irq_thread(int irq, void *devid)
 {
struct usba_udc *udc = devid;
int vbus;
+   int ret;
 
/* debounce */
udelay(10);
 
-   spin_lock(&udc->lock);
+   mutex_lock(&udc->vbus_mutex);
 
/* May happen if Vbus pin toggles during probe() */
-   if (!udc->driver)
+   spin_lock(&udc->lock);
+   if (!udc->driver) {
+   spin_unlock(&udc->lock);
goto out;
+   }
+   spin_unlock(&udc->lock);
 
vbus = vbus_is_present(udc);
if (vbus != udc->vbus_prev) {
if (vbus) {
+   ret = start_clock(udc);
+   if (ret)
+   goto out;
+
+   spin_lock(&udc->lock);
toggle_bias(1);
usba_writel(udc, CTRL, USBA_ENABLE_MASK);
usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
+   spin_unlock(&udc->lock);
} else {
+   spin_lock(&udc->lock);
udc->gadget.speed = USB_SPEED_UNKNOWN;
reset_all_endpoints(udc);
toggle_bias(0);
usba_writel(udc, CTRL, USBA_DISABLE_MASK);
-   if (udc->driver->disconnect) {
-   spin_unlock(&udc->lock);
+   spin_unlock(&udc->lock);
+
+   stop_clock(udc);
+
+   if (udc->driver->disconnect)
udc->driver->disconnect(&udc->gadget);
-   spin_lock(&udc->lock);
-   }
}
udc->vbus_prev = vbus;
}
 
 out:
-   spin_unlock(&udc->lock);
+   mutex_unlock(&udc->vbus_mutex);
 
return IRQ_HANDLED;
 }
@@ -1762,7 +1807,7 @@ out:
 static int atmel_usba_start(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
 {
-   int ret;
+   int ret = 0;
struct usba_udc *udc = container_of(gadget, struct usba_udc, gadget);
unsigned long flags;
 
@@ -1772,31 +1817,29 @@ static int atmel_usba_start(struct usb_gadget *gadget,
udc->driver = driver;
spin_unlock_irqrestore(&udc->lock, flags);
 
-   ret = clk_prepare_enable(udc->pclk);
-   if (ret)
-   return ret;
-   ret = clk_prepare_enable(udc->hclk);
-   if (ret) {
-   clk_disable_unprepare(udc->pclk);
-   return ret;
-   }
-
+   mutex_lock(&udc->vbus_mutex);
udc->vbus_prev = 0;
if (gpio_is_valid(udc->vbus_pin))
enable_irq(gpio_to_irq(udc->vbus_pin));
 
/* If Vbus is present, enable the controller and wait for reset */
-   spin_lock_irqsave(&udc->lock, flags);
if (vbus_is_present(udc) && udc->vbus_prev == 0) {
+   ret = start_clock(udc);
+   if (ret)
+   goto out;
+
+   spin_lock_irqsave(&udc->lock, flags);
toggle_bias

[PATCHv2 1/2] USB: gadget: atmel_usba_udc: Fixed vbus_prev initial state

2015-01-18 Thread Sylvain Rochet
If vbus gpio is high at init, we should set vbus_prev to true
accordingly to the current vbus state. Without that, we skip the first
vbus interrupt because the saved vbus state is not consistent.

Signed-off-by: Sylvain Rochet 
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index ce88237..e207d75 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -1791,6 +1791,8 @@ static int atmel_usba_start(struct usb_gadget *gadget,
toggle_bias(1);
usba_writel(udc, CTRL, USBA_ENABLE_MASK);
usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
+
+   udc->vbus_prev = 1;
}
spin_unlock_irqrestore(&udc->lock, flags);
 
-- 
2.1.4

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


[PATCHv2 0/2] USB: gadget: atmel_usba_udc: Enable/disable USB PLL on Vbus change

2015-01-18 Thread Sylvain Rochet
Prepare_enable on rising edge, disable_unprepare on falling edge. Reduce
power consumption if USB PLL is not already necessary for OHCI or EHCI.
If USB host is not connected we can sleep with USB PLL stopped.

This driver does not support suspend/resume yet, not suspending if we
are still attached to an USB host is fine for what I need, this patch
allow suspending with USB PLL stopped when USB device is not currently
used.

Change since v1:
  * Using a threaded irq and mutex instead of spinclock as suggested
  * Moved a silently fixed bug in a separate patch (1/2)

Sylvain Rochet (2):
  USB: gadget: atmel_usba_udc: Fixed vbus_prev initial state
  USB: gadget: atmel_usba_udc: Enable/disable USB PLL on Vbus change

 drivers/usb/gadget/udc/atmel_usba_udc.c | 97 -
 drivers/usb/gadget/udc/atmel_usba_udc.h |  4 ++
 2 files changed, 75 insertions(+), 26 deletions(-)

-- 
2.1.4

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


Re: Difference between run time and normal suspend

2015-01-18 Thread vichy
>> Is 3rd situation you mentioned above the function will be called is
>> hcd->bus_suspend?
>
> hcd->bus_suspend will be called first, and shortly afterward
> ehci->suspend will be called (if this is an EHCI controller).
>
>> > Fourthly, you should realize that "controller itself will also be put
>> > into runtime suspend" means the controller itself will be put into
>> > runtime suspend.
>> is 4th situation you mentioned above the function will be called is
>> ehci_suspend, (take ehci for example)?
>
> Yes.
after tracing the source, I only can find the ehci_suspend is called
when system hibernate/suspend.
rpm_suspend use below method to find out suspend callback
if (dev->pm_domain)
callback = dev->pm_domain->ops.runtime_suspend;
else if (dev->type && dev->type->pm)
callback = dev->type->pm->runtime_suspend;
else if (dev->class && dev->class->pm)
callback = dev->class->pm->runtime_suspend;
else if (dev->bus && dev->bus->pm)
callback = dev->bus->pm->runtime_suspend;
else
callback = NULL;

ehci_suspend doesn't register any one of above function.

>
>> but ehci_supend is called when system is going to suspend/hibernate,
>> or it will be called even in runtime suspend?
>
> Both.
>
>> BTW, when I turn off the led on the keyboard, the keyboard can
>> successfully go to runtime suspend.
>
> Good.
>
>> Would you mind to let us know how you find out the problem from mon files?
>> Is it due there is no remote wake control message on the mon file?
>
> The usbmon trace showed that the interrupt URB for one of the HID
> interfaces was cancelled (indicating that the interface had been
> suspended) but the interrupt URB for the other HID interface was not
> cancelled (indicating that the interface had failed to suspend).
>
> Reading the source code for the usbhid driver showed that there are
> only a few reasons for failing to suspend an interface, and one of
> those reasons was if an LED was illuminated.

Sincerely appreciate your kind help,
--
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 2/2] Add HCS_PPC when getting root hub status

2015-01-18 Thread Chechun Kuo
for some platform ehci controller, it is possible there is no port power 
control capability in the root hub.
And we add port power control determination when getting root hub port status.

Signed-off-by: Chechun Kuo 
---
 drivers/usb/host/ehci-hub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 5728829..1923984 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -1118,7 +1118,7 @@ int ehci_hub_control(
status |= USB_PORT_STAT_OVERCURRENT;
if (temp & PORT_RESET)
status |= USB_PORT_STAT_RESET;
-   if (temp & PORT_POWER)
+   if (HCS_PPC(ehci->hcs_params) && (temp & PORT_POWER))
status |= USB_PORT_STAT_POWER;
if (test_bit(wIndex, &ehci->port_c_suspend))
status |= USB_PORT_STAT_C_SUSPEND << 16;
-- 
1.9.1

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


[PATCH 1/2] Add hub port switchable when checking port power

2015-01-18 Thread Chechun Kuo
In check_port_resume_type, we will check port power status to determine whether 
the status should change to -ENODEV.
If all ports power control of the hub are handled at once, the port power 
status may not represent the real case and cause resume fail.
At this patch, we add hub_is_port_power_switchable as well as checking the port 
power.

Signed-off-by: Chechun Kuo 
---
 drivers/usb/core/hub.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index b649fef..a50b257 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2904,7 +2904,8 @@ static int check_port_resume_type(struct usb_device *udev,
}
/* Is the device still present? */
else if (status || port_is_suspended(hub, portstatus) ||
-   !port_is_power_on(hub, portstatus) ||
+   (hub_is_port_power_switchable(hub)
+   && !port_is_power_on(hub, portstatus)) ||
!(portstatus & USB_PORT_STAT_CONNECTION)) {
if (status >= 0)
status = -ENODEV;
-- 
1.9.1

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


Re: [PATCH 01/12] mfd: syscon: Add atmel-matrix registers definition

2015-01-18 Thread Boris Brezillon
Hi Lee,

On Sun, 18 Jan 2015 12:52:59 +
Lee Jones  wrote:

> On Wed, 14 Jan 2015, Alexandre Belloni wrote:
> 
> > From: Boris Brezillon 
> > 
> > AT91 SoCs have a memory range reserved for internal bus configuration.
> > Expose those registers so that drivers can make use of the matrix syscon
> > declared in at91 DTs.
> > 
> > Signed-off-by: Boris Brezillon 
> > Acked-by: Lee Jones 
> > ---
> >  include/linux/mfd/syscon/atmel-matrix.h | 117 
> > 
> >  1 file changed, 117 insertions(+)
> >  create mode 100644 include/linux/mfd/syscon/atmel-matrix.h
> 
> Applied, thanks.

Actually Nicolas took all the patches in his tree and already sent a PR
to the arm-soc maintainers [1].

Best Regards,

Boris

[1]https://lkml.org/lkml/2015/1/15/542

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
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 03/12] mfd: syscon: Add atmel-smc registers definition

2015-01-18 Thread Lee Jones
On Wed, 14 Jan 2015, Alexandre Belloni wrote:

> From: Boris Brezillon 
> 
> Atmel AT91 SoCs have a memory range reserved for SMC (Static Memory
> Controller) configuration.
> Expose those registers so that drivers can make use of the smc syscon
> declared in at91 DTs.
> 
> Signed-off-by: Boris Brezillon 
> Acked-by: Lee Jones 
> ---
>  include/linux/mfd/syscon/atmel-smc.h | 173 
> +++
>  1 file changed, 173 insertions(+)
>  create mode 100644 include/linux/mfd/syscon/atmel-smc.h

Applied, thanks.
 
> diff --git a/include/linux/mfd/syscon/atmel-smc.h 
> b/include/linux/mfd/syscon/atmel-smc.h
> new file mode 100644
> index ..be6ebe64eebe
> --- /dev/null
> +++ b/include/linux/mfd/syscon/atmel-smc.h
> @@ -0,0 +1,173 @@
> +/*
> + * Atmel SMC (Static Memory Controller) register offsets and bit definitions.
> + *
> + * Copyright (C) 2014 Atmel
> + * Copyright (C) 2014 Free Electrons
> + *
> + * Author: Boris Brezillon 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#ifndef _LINUX_MFD_SYSCON_ATMEL_SMC_H_
> +#define _LINUX_MFD_SYSCON_ATMEL_SMC_H_
> +
> +#include 
> +#include 
> +
> +#define AT91SAM9_SMC_GENERIC 0x00
> +#define AT91SAM9_SMC_GENERIC_BLK_SZ  0x10
> +
> +#define SAMA5_SMC_GENERIC0x600
> +#define SAMA5_SMC_GENERIC_BLK_SZ 0x14
> +
> +#define AT91SAM9_SMC_SETUP(o)((o) + 0x00)
> +#define AT91SAM9_SMC_NWESETUP(x) (x)
> +#define AT91SAM9_SMC_NCS_WRSETUP(x)  ((x) << 8)
> +#define AT91SAM9_SMC_NRDSETUP(x) ((x) << 16)
> +#define AT91SAM9_SMC_NCS_NRDSETUP(x) ((x) << 24)
> +
> +#define AT91SAM9_SMC_PULSE(o)((o) + 0x04)
> +#define AT91SAM9_SMC_NWEPULSE(x) (x)
> +#define AT91SAM9_SMC_NCS_WRPULSE(x)  ((x) << 8)
> +#define AT91SAM9_SMC_NRDPULSE(x) ((x) << 16)
> +#define AT91SAM9_SMC_NCS_NRDPULSE(x) ((x) << 24)
> +
> +#define AT91SAM9_SMC_CYCLE(o)((o) + 0x08)
> +#define AT91SAM9_SMC_NWECYCLE(x) (x)
> +#define AT91SAM9_SMC_NRDCYCLE(x) ((x) << 16)
> +
> +#define AT91SAM9_SMC_MODE(o) ((o) + 0x0c)
> +#define SAMA5_SMC_MODE(o)((o) + 0x10)
> +#define AT91_SMC_READMODEBIT(0)
> +#define AT91_SMC_READMODE_NCS(0 << 0)
> +#define AT91_SMC_READMODE_NRD(1 << 0)
> +#define AT91_SMC_WRITEMODE   BIT(1)
> +#define AT91_SMC_WRITEMODE_NCS   (0 << 1)
> +#define AT91_SMC_WRITEMODE_NWE   (1 << 1)
> +#define AT91_SMC_EXNWMODEGENMASK(5, 4)
> +#define AT91_SMC_EXNWMODE_DISABLE(0 << 4)
> +#define AT91_SMC_EXNWMODE_FROZEN (2 << 4)
> +#define AT91_SMC_EXNWMODE_READY  (3 << 4)
> +#define AT91_SMC_BAT BIT(8)
> +#define AT91_SMC_BAT_SELECT  (0 << 8)
> +#define AT91_SMC_BAT_WRITE   (1 << 8)
> +#define AT91_SMC_DBW GENMASK(13, 12)
> +#define AT91_SMC_DBW_8   (0 << 12)
> +#define AT91_SMC_DBW_16  (1 << 12)
> +#define AT91_SMC_DBW_32  (2 << 12)
> +#define AT91_SMC_TDF GENMASK(19, 16)
> +#define AT91_SMC_TDF_(x) x) - 1) << 16) & AT91_SMC_TDF)
> +#define AT91_SMC_TDF_MAX 16
> +#define AT91_SMC_TDFMODE_OPTIMIZED   BIT(20)
> +#define AT91_SMC_PMENBIT(24)
> +#define AT91_SMC_PS  GENMASK(29, 28)
> +#define AT91_SMC_PS_4(0 << 28)
> +#define AT91_SMC_PS_8(1 << 28)
> +#define AT91_SMC_PS_16   (2 << 28)
> +#define AT91_SMC_PS_32   (3 << 28)
> +
> +
> +/*
> + * This function converts a setup timing expressed in nanoseconds into an
> + * encoded value that can be written in the SMC_SETUP register.
> + *
> + * The following formula is described in atmel datasheets (section
> + * "SMC Setup Register"):
> + *
> + * setup length = (128* SETUP[5] + SETUP[4:0])
> + *
> + * where setup length is the timing expressed in cycles.
> + */
> +static inline u32 at91sam9_smc_setup_ns_to_cycles(unsigned int clk_rate,
> +   u32 timing_ns)
> +{
> + u32 clk_period = DIV_ROUND_UP(NSEC_PER_SEC, clk_rate);
> + u32 coded_cycles = 0;
> + u32 cycles;
> +
> + cycles = DIV_ROUND_UP(timing_ns, clk_period);
> + if (cycles / 32) {
> + coded_cycles |= 1 << 5;
> + if (cycles < 128)
> + cycles = 0;
> + }
> +
> + coded_cycles |= cycles % 32;
> +
> + return coded_cycles;
> +}
> +
> +/*
> + * This function converts a pulse timing expressed in nanoseconds into an
> + * encoded value that can be written in the SMC_PULSE register.
> + *
> + * The following formula is described in atmel datasheets (section
> + * "SMC Pulse Register"):
> + *
> + * pulse length = (256* PULSE[6] + PUL

Re: [PATCH 04/12] mfd: syscon: Add Atmel SMC binding doc

2015-01-18 Thread Lee Jones
On Wed, 14 Jan 2015, Alexandre Belloni wrote:

> From: Boris Brezillon 
> 
> The SMC registers are used to configure Atmel EBI (External Bus Interface)
> to interface with standard memory devices (NAND, NOR, SRAM or specialized
> devices like FPGAs).
> 
> Declare this memory region as a syscon, so that different drivers can
> configure the SMC interface (mostly timing configuration) according to
> their need.
> 
> Signed-off-by: Boris Brezillon 
> Acked-by: Lee Jones 
> ---
>  Documentation/devicetree/bindings/mfd/atmel-smc.txt | 19 +++
>  1 file changed, 19 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/atmel-smc.txt

Applied, thanks.
 
> diff --git a/Documentation/devicetree/bindings/mfd/atmel-smc.txt 
> b/Documentation/devicetree/bindings/mfd/atmel-smc.txt
> new file mode 100644
> index ..26eeed373934
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/atmel-smc.txt
> @@ -0,0 +1,19 @@
> +* Device tree bindings for Atmel SMC (Static Memory Controller)
> +
> +The SMC registers are used to configure Atmel EBI (External Bus Interface)
> +to interface with standard memory devices (NAND, NOR, SRAM or specialized
> +devices like FPGAs).
> +
> +Required properties:
> +- compatible:Should be one of the following
> + "atmel,at91sam9260-smc", "syscon"
> + "atmel,sama5d3-smc", "syscon"
> +- reg:   Contains offset/length value of the SMC memory
> + region.
> +
> +Example:
> +
> +smc: smc@c000 {
> + compatible = "atmel,sama5d3-smc", "syscon";
> + reg = <0xc000 0x1000>;
> +};

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/12] mfd: syscon: Add Atmel Matrix bus DT binding documentation

2015-01-18 Thread Lee Jones
On Wed, 14 Jan 2015, Alexandre Belloni wrote:

> From: Boris Brezillon 
> 
> The Matrix registers are provided to configure internal bus behavior on
> at91 SoCs.
> Some registers might be accessed by several drivers (e.g. to configure
> external memory bus timings), hence we declare this register set as a
> syscon device.
> 
> Signed-off-by: Boris Brezillon 
> Acked-by: Lee Jones 
> ---
>  .../devicetree/bindings/mfd/atmel-matrix.txt   | 24 
> ++
>  1 file changed, 24 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/atmel-matrix.txt

Applied, thanks.
 
> diff --git a/Documentation/devicetree/bindings/mfd/atmel-matrix.txt 
> b/Documentation/devicetree/bindings/mfd/atmel-matrix.txt
> new file mode 100644
> index ..e3ef50ca02a5
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/atmel-matrix.txt
> @@ -0,0 +1,24 @@
> +* Device tree bindings for Atmel Bus Matrix
> +
> +The Bus Matrix registers are used to configure Atmel SoCs internal bus
> +behavior (master/slave priorities, undefined burst length type, ...)
> +
> +Required properties:
> +- compatible:Should be one of the following
> + "atmel,at91sam9260-matrix", "syscon"
> + "atmel,at91sam9261-matrix", "syscon"
> + "atmel,at91sam9263-matrix", "syscon"
> + "atmel,at91sam9rl-matrix", "syscon"
> + "atmel,at91sam9g45-matrix", "syscon"
> + "atmel,at91sam9n12-matrix", "syscon"
> + "atmel,at91sam9x5-matrix", "syscon"
> + "atmel,sama5d3-matrix", "syscon"
> +- reg:   Contains offset/length value of the Bus Matrix
> + memory region.
> +
> +Example:
> +
> +matrix: matrix@ec00 {
> + compatible = "atmel,sama5d3-matrix", "syscon";
> + reg = <0xec00 0x200>;
> +};

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/12] mfd: syscon: Add atmel-matrix registers definition

2015-01-18 Thread Lee Jones
On Wed, 14 Jan 2015, Alexandre Belloni wrote:

> From: Boris Brezillon 
> 
> AT91 SoCs have a memory range reserved for internal bus configuration.
> Expose those registers so that drivers can make use of the matrix syscon
> declared in at91 DTs.
> 
> Signed-off-by: Boris Brezillon 
> Acked-by: Lee Jones 
> ---
>  include/linux/mfd/syscon/atmel-matrix.h | 117 
> 
>  1 file changed, 117 insertions(+)
>  create mode 100644 include/linux/mfd/syscon/atmel-matrix.h

Applied, thanks.

> diff --git a/include/linux/mfd/syscon/atmel-matrix.h 
> b/include/linux/mfd/syscon/atmel-matrix.h
> new file mode 100644
> index ..8293c3e2a82a
> --- /dev/null
> +++ b/include/linux/mfd/syscon/atmel-matrix.h
> @@ -0,0 +1,117 @@
> +/*
> + *  Copyright (C) 2014 Atmel Corporation.
> + *
> + * Memory Controllers (MATRIX, EBI) - System peripherals registers.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#ifndef _LINUX_MFD_SYSCON_ATMEL_MATRIX_H
> +#define _LINUX_MFD_SYSCON_ATMEL_MATRIX_H
> +
> +#define AT91SAM9260_MATRIX_MCFG  0x00
> +#define AT91SAM9260_MATRIX_SCFG  0x40
> +#define AT91SAM9260_MATRIX_PRS   0x80
> +#define AT91SAM9260_MATRIX_MRCR  0x100
> +#define AT91SAM9260_MATRIX_EBICSA0x11c
> +
> +#define AT91SAM9261_MATRIX_MRCR  0x0
> +#define AT91SAM9261_MATRIX_SCFG  0x4
> +#define AT91SAM9261_MATRIX_TCR   0x24
> +#define AT91SAM9261_MATRIX_EBICSA0x30
> +#define AT91SAM9261_MATRIX_USBPUCR   0x34
> +
> +#define AT91SAM9263_MATRIX_MCFG  0x00
> +#define AT91SAM9263_MATRIX_SCFG  0x40
> +#define AT91SAM9263_MATRIX_PRS   0x80
> +#define AT91SAM9263_MATRIX_MRCR  0x100
> +#define AT91SAM9263_MATRIX_TCR   0x114
> +#define AT91SAM9263_MATRIX_EBI0CSA   0x120
> +#define AT91SAM9263_MATRIX_EBI1CSA   0x124
> +
> +#define AT91SAM9RL_MATRIX_MCFG   0x00
> +#define AT91SAM9RL_MATRIX_SCFG   0x40
> +#define AT91SAM9RL_MATRIX_PRS0x80
> +#define AT91SAM9RL_MATRIX_MRCR   0x100
> +#define AT91SAM9RL_MATRIX_TCR0x114
> +#define AT91SAM9RL_MATRIX_EBICSA 0x120
> +
> +#define AT91SAM9G45_MATRIX_MCFG  0x00
> +#define AT91SAM9G45_MATRIX_SCFG  0x40
> +#define AT91SAM9G45_MATRIX_PRS   0x80
> +#define AT91SAM9G45_MATRIX_MRCR  0x100
> +#define AT91SAM9G45_MATRIX_TCR   0x110
> +#define AT91SAM9G45_MATRIX_DDRMPR0x118
> +#define AT91SAM9G45_MATRIX_EBICSA0x128
> +
> +#define AT91SAM9N12_MATRIX_MCFG  0x00
> +#define AT91SAM9N12_MATRIX_SCFG  0x40
> +#define AT91SAM9N12_MATRIX_PRS   0x80
> +#define AT91SAM9N12_MATRIX_MRCR  0x100
> +#define AT91SAM9N12_MATRIX_EBICSA0x118
> +
> +#define AT91SAM9X5_MATRIX_MCFG   0x00
> +#define AT91SAM9X5_MATRIX_SCFG   0x40
> +#define AT91SAM9X5_MATRIX_PRS0x80
> +#define AT91SAM9X5_MATRIX_MRCR   0x100
> +#define AT91SAM9X5_MATRIX_EBICSA 0x120
> +
> +#define SAMA5D3_MATRIX_MCFG  0x00
> +#define SAMA5D3_MATRIX_SCFG  0x40
> +#define SAMA5D3_MATRIX_PRS   0x80
> +#define SAMA5D3_MATRIX_MRCR  0x100
> +
> +#define AT91_MATRIX_MCFG(o, x)   ((o) + ((x) * 0x4))
> +#define AT91_MATRIX_ULBT GENMASK(2, 0)
> +#define AT91_MATRIX_ULBT_INFINITE(0 << 0)
> +#define AT91_MATRIX_ULBT_SINGLE  (1 << 0)
> +#define AT91_MATRIX_ULBT_FOUR(2 << 0)
> +#define AT91_MATRIX_ULBT_EIGHT   (3 << 0)
> +#define AT91_MATRIX_ULBT_SIXTEEN (4 << 0)
> +
> +#define AT91_MATRIX_SCFG(o, x)   ((o) + ((x) * 0x4))
> +#define AT91_MATRIX_SLOT_CYCLE   GENMASK(7,  0)
> +#define AT91_MATRIX_DEFMSTR_TYPE GENMASK(17, 16)
> +#define AT91_MATRIX_DEFMSTR_TYPE_NONE(0 << 16)
> +#define AT91_MATRIX_DEFMSTR_TYPE_LAST(1 << 16)
> +#define AT91_MATRIX_DEFMSTR_TYPE_FIXED   (2 << 16)
> +#define AT91_MATRIX_FIXED_DEFMSTRGENMASK(20, 18)
> +#define AT91_MATRIX_ARBT GENMASK(25, 24)
> +#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24)
> +#define AT91_MATRIX_ARBT_FIXED_PRIORITY  (1 << 24)
> +
> +#

Re: Fatal Exception on device when Hotsyncing Palm in linux

2015-01-18 Thread Henri Manson
Ubuntu 9.04:
Linux ubuntu 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC
2009 i686 GNU/Linux

Ubuntu 10.04.4:
Linux ubuntu 2.6.32-38-generic #83-Ubuntu SMP Wed Jan 4 11:13:04 UTC
2012 i686 GNU/Linux


On Fri, Jan 16, 2015 at 12:24 PM, Johan Hovold  wrote:
> On Thu, Jan 15, 2015 at 12:00:28AM +0100, Henri Manson wrote:
>> I own a Palm m505 and a while ago a developed programs using SuperWaba
>> and uploaded them using pilot-xfer. Using Ubuntu 14.04 I tried
>> Hotsyncing on the device but now the devices shows a dialog box
>> containing 'Fatal Exception' and then hangs.
>> I figured out using VirtualBox and old Ubuntu ISO images that
>> hotsyncing goes well in Ubuntu 9.04 and fatal exceptions start
>> occurring as early as Ubuntu 10.04.
>
> What kernel versions does this correspond to?
>
> 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: [PATCHv3 1/5] USB: host: ehci_atmel: Add suspend/resume support

2015-01-18 Thread Boris Brezillon
Hi Sylvain,

On Sat, 17 Jan 2015 23:49:00 +0100
Sylvain Rochet  wrote:

> Hi Sergei,
> 
> 
> On Sun, Jan 18, 2015 at 01:22:38AM +0300, Sergei Shtylyov wrote:
> > 
> >There's little inconsistency in your patch subjects: you're using
> > '_' but the files you're modifying are named using '-'...
> 
> Indeed.
> 
> 
> > >@@ -187,6 +217,8 @@ static struct platform_driver ehci_atmel_driver = {
> > >   .probe  = ehci_atmel_drv_probe,
> > >   .remove = ehci_atmel_drv_remove,
> > >   .shutdown   = usb_hcd_platform_shutdown,
> > >+  .suspend= ehci_atmel_drv_suspend,
> > >+  .resume = ehci_atmel_drv_resume,
> > 
> >I think you should use 'struct dev_pm_ops' now.
> 
> This way ?
> 
> static int ehci_atmel_drv_suspend(struct device *dev)
> {
>   struct usb_hcd *hcd = dev_get_drvdata(dev);
> (...)
> 
> 
> static SIMPLE_DEV_PM_OPS(ehci_atmel_pm_ops, ehci_atmel_drv_suspend, 
> ehci_atmel_drv_resume);
> 
> (...)
>   .driver = {
>   .pm = &ehci_atmel_pm_ops,
>   }
> (...)
> 
> 
> Should I send a v4 or can I send this change separately on top of the 
> previous change ?

I think it's better to send a v4 reworking this patch (you'll have to
change your commit subject anyway ;-)).

Best Regards,

Boris


-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
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