Re: [PATCH 1/7] phy: exynos-usb2: add vbus regulator support

2015-09-30 Thread Marek Szyprowski

Hello,

On 2015-08-27 11:54, Kishon Vijay Abraham I wrote:

On Tuesday 25 August 2015 11:42 AM, Krzysztof Kozlowski wrote:

On 25.08.2015 14:47, Marek Szyprowski wrote:

Hello,

On 2015-08-21 14:44, Kishon Vijay Abraham I wrote:

On Friday 21 August 2015 06:08 PM, Marek Szyprowski wrote:

Exynos USB2 PHY has separate power supply, which is usually provided by
VBUS regulator. This patch adds support for it. VBUS regulator is
optional, to keep compatibility with boards, which have VBUS provided
from some always-on power source.

Signed-off-by: Marek Szyprowski 
---
   .../devicetree/bindings/phy/samsung-phy.txt|  3 +++
   drivers/phy/phy-samsung-usb2.c | 25
--
   drivers/phy/phy-samsung-usb2.h |  2 ++
   3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt
b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index 60c6f2a633e0..0289d3b07853 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -44,6 +44,9 @@ Required properties:
   - the "ref" clock is used to get the rate of the clock provided
to the
 PHY module
   +Optional properties:
+- vbus-supply: power-supply phandle for vbus power source

how about using phy-supply?

I wanted to make it a bit more descriptive (vbus-supply is rather self
explaining name)
and keep it in line with Exynos usb3-drd phy, which already supports
vbus-supply.
If you think that this is a bad idea, a will use phy-supply then.

This is actually supply for VBUS, not for the phy. Using phy-supply
would work fine and reduce the size of code... but would be rather a
hacky-use of phy and it could be misleading.

I don't have strong feeling about this, both ideas have its advantages.
If I had to choose than I would like to use vbus-supply because of its
correctness with real-world (this is a VBUS after all).

Alright.. lets use vbus-supply then.


Could you take this patch to -next then? I would like to have all needed 
pieces
merged to v4.4 to finally get USB gadget stuff working again on Trats2 
boards.


Best regards
--
Marek Szyprowski, PhD
Samsung R Institute Poland

--
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 01/32] usb: dwc2: host: don't clear hprt0 status bits when exiting hibernation

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

When entering hibernation hprt0 must be read using dwc2_read_hprt0().
Otherwise, any set hprt0 status bits will be cleared when restoring
hprt0 on exit from hibernation.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index fc0521a..0bfc987 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -78,7 +78,7 @@ static int dwc2_backup_host_registers(struct dwc2_hsotg 
*hsotg)
for (i = 0; i < hsotg->core_params->host_channels; ++i)
hr->hcintmsk[i] = dwc2_readl(hsotg->regs + HCINTMSK(i));
 
-   hr->hprt0 = dwc2_readl(hsotg->regs + HPRT0);
+   hr->hprt0 = dwc2_read_hprt0(hsotg);
hr->hfir = dwc2_readl(hsotg->regs + HFIR);
hr->valid = true;
 
-- 
2.3.3

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


[PATCH v4 00/32] usb: dwc2: various bug fixes

2015-09-30 Thread Mian Yousaf Kaukab
Hi,
This series consists of various bug fixes for both host and gadget
sides. All patches are verified on dwc2 v3.0a with dedicated fifos.
It would be good to get some Tested-bys for other platforms.

It is based on testing/next branch in Felipe's git.

Hi Felipe,
I see that you have already applied some of the patches from this series.
Can you please take the whole series again? as patches have been modified
after comments from Sergei Shtylyov.

Thank you,

Best regards,
Yousaf

History:
v4:
 - Fix comments from Sergei Shtylyov
 
v3:
 - Fix comment from Sergei Shtylyov
 - Rebase to latest testing/next
 
v2:
 - Rebase to latest testing/next
 - Fix lock issue found by John Youn when calling
   dwc2_hsotg_core_init_disconnected() from dwc2_conn_id_status_change()
 - Fix comments from John Youn
 - Fix comments from Doug Anderson

v1:
 - Fix following comments from David Cohen (received on an internal
   list):
- Fix build when "usb: dwc2: host: create a function to handle-
  port_resume" is applied.
- Take spin locks within if statements in "usb: dwc2: host: enter-
  hibernation during bus suspend"
- Remove extra 100us delay in "usb: dwc2: host: enter-
  hibernation during bus suspend"
- Fix spelling mistakes in "usb: dwc2: host: update hcd and-
  lx_state during start/stop callbacks"
- Change dev_warn to dev_dbg in "usb: dwc2: host: reset frame-
   number after suspend"
- Change mdelay to usleep_range in "usb: dwc2: host: wait 3ms for-
  controller stabilization"
 - Fix comments from Sergei Shtylyov

Gregory Herrero (22):
  usb: dwc2: host: don't clear hprt0 status bits when exiting
hibernation
  usb: dwc2: host: create a function to handle port_resume
  usb: dwc2: host: add flag to reflect bus state
  usb: dwc2: host: enter hibernation during bus suspend
  usb: dwc2: host: update hcd and lx_state during start/stop callbacks
  usb: dwc2: host: avoid resetting lx_state to L3 during disconnect
  usb: dwc2: host: ignore wakeup interrupt if hibernation supported
  usb: dwc2: host: resume only if bus is suspended
  usb: dwc2: host: reset frame number after suspend
  usb: dwc2: host: disconnect hcd prior stopping it
  usb: dwc2: host: disable interrupt during stop
  usb: dwc2: host: clear pending interrupts prior hibernation
  usb: dwc2: host: wait 3ms for controller stabilization
  usb: dwc2: host: correctly dump urb isochronous descriptors
  usb: dwc2: host: use correct frame number during qh init
  usb: dwc2: host: kill remaining urbs using -ECONNRESET status
  usb: dwc2: gadget: ensure lx_state corresponds to current state
  usb: dwc2: gadget: don't modify pullup state in host mode
  usb: dwc2: gadget: set op_state in vbus_session call
  usb: dwc2: gadget: abort core init if core_reset fails
  usb: dwc2: gadget: unmask idstschng interrupt only if controller
supports it
  usb: dwc2: gadget: exit hibernation before power down

Mian Yousaf Kaukab (10):
  usb: dwc2: host: add disconnect interrupt to host only interrupts
  usb: dwc2: gadget: initialize op_state for peripheral only
configuration
  usb: dwc2: force dr_mode in case of configuration mismatch
  usb: dwc2: gadget: ignore stall check for ep0
  usb: dwc2: gadget: print complete setup packet
  usb: dwc2: gadget: stop current transfer on dequeue
  usb: dwc2: gadget: kill ep0 requests before reinitializing core
  usb: dwc2: gadget: only reset core after addressed state
  usb: dwc2: gadget: handle reset interrupt before endpoint interrupts
  usb: dwc2: exit hibernation on session request

 drivers/usb/dwc2/core.c  |  14 ++-
 drivers/usb/dwc2/core.h  |   3 +-
 drivers/usb/dwc2/core_intr.c |  29 --
 drivers/usb/dwc2/gadget.c| 210 ++-
 drivers/usb/dwc2/hcd.c   | 209 --
 drivers/usb/dwc2/hcd_queue.c |  10 +++
 drivers/usb/dwc2/platform.c  |  11 +++
 7 files changed, 385 insertions(+), 101 deletions(-)

-- 
2.3.3

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


[PATCH v4 03/32] usb: dwc2: host: add flag to reflect bus state

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

lx_state must be used to reflect controller power state only and not
bus state. Thus add a flag to track state during bus suspend.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/core.h | 1 +
 drivers/usb/dwc2/hcd.c  | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index a130e38..27e6fbf 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -765,6 +765,7 @@ struct dwc2_hsotg {
u16 frame_usecs[8];
u16 frame_number;
u16 periodic_qh_count;
+   bool bus_suspended;
 
 #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
 #define FRAME_NUM_ARRAY_SIZE 1000
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index b929087..6dfa143 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -1425,6 +1425,7 @@ static void dwc2_wakeup_detected(unsigned long data)
dev_dbg(hsotg->dev, "Clear Resume: HPRT0=%0x\n",
dwc2_readl(hsotg->regs + HPRT0));
 
+   hsotg->bus_suspended = false;
dwc2_hcd_rem_wakeup(hsotg);
 
/* Change to L0 state */
@@ -1461,8 +1462,7 @@ static void dwc2_port_suspend(struct dwc2_hsotg *hsotg, 
u16 windex)
hprt0 |= HPRT0_SUSP;
dwc2_writel(hprt0, hsotg->regs + HPRT0);
 
-   /* Update lx_state */
-   hsotg->lx_state = DWC2_L2;
+   hsotg->bus_suspended = true;
 
/* Suspend the Phy Clock */
pcgctl = dwc2_readl(hsotg->regs + PCGCTL);
@@ -1510,6 +1510,7 @@ static void dwc2_port_resume(struct dwc2_hsotg *hsotg)
hprt0 = dwc2_read_hprt0(hsotg);
hprt0 &= ~(HPRT0_RES | HPRT0_SUSP);
dwc2_writel(hprt0, hsotg->regs + HPRT0);
+   hsotg->bus_suspended = false;
spin_unlock_irqrestore(>lock, flags);
 }
 
-- 
2.3.3

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


[PATCH v4 04/32] usb: dwc2: host: enter hibernation during bus suspend

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

Disable controller power and enter hibernation when usb bus is
suspended. A phy driver is required to disable the power of the
controller and detect remote-wakeup or disconnection since the
controller will not be able to detect these in this state.

Once the phy driver detects bus activity, it must call
usb_hcd_resume_root_hub.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/hcd.c | 140 -
 1 file changed, 128 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 6dfa143..15adc7d 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -1464,11 +1464,17 @@ static void dwc2_port_suspend(struct dwc2_hsotg *hsotg, 
u16 windex)
 
hsotg->bus_suspended = true;
 
-   /* Suspend the Phy Clock */
-   pcgctl = dwc2_readl(hsotg->regs + PCGCTL);
-   pcgctl |= PCGCTL_STOPPCLK;
-   dwc2_writel(pcgctl, hsotg->regs + PCGCTL);
-   udelay(10);
+   /*
+* If hibernation is supported, Phy clock will be suspended
+* after registers are backuped.
+*/
+   if (!hsotg->core_params->hibernation) {
+   /* Suspend the Phy Clock */
+   pcgctl = dwc2_readl(hsotg->regs + PCGCTL);
+   pcgctl |= PCGCTL_STOPPCLK;
+   dwc2_writel(pcgctl, hsotg->regs + PCGCTL);
+   udelay(10);
+   }
 
/* For HNP the bus must be suspended for at least 200ms */
if (dwc2_host_is_b_hnp_enabled(hsotg)) {
@@ -1491,11 +1497,16 @@ static void dwc2_port_resume(struct dwc2_hsotg *hsotg)
u32 hprt0;
u32 pcgctl;
 
-   /* Resume the Phy Clock */
-   pcgctl = dwc2_readl(hsotg->regs + PCGCTL);
-   pcgctl &= ~PCGCTL_STOPPCLK;
-   dwc2_writel(pcgctl, hsotg->regs + PCGCTL);
-   usleep_range(2, 4);
+   /*
+* If hibernation is supported, Phy clock is already resumed
+* after registers restore.
+*/
+   if (!hsotg->core_params->hibernation) {
+   pcgctl = dwc2_readl(hsotg->regs + PCGCTL);
+   pcgctl &= ~PCGCTL_STOPPCLK;
+   dwc2_writel(pcgctl, hsotg->regs + PCGCTL);
+   usleep_range(2, 4);
+   }
 
spin_lock_irqsave(>lock, flags);
hprt0 = dwc2_read_hprt0(hsotg);
@@ -2347,17 +2358,122 @@ static void _dwc2_hcd_stop(struct usb_hcd *hcd)
 static int _dwc2_hcd_suspend(struct usb_hcd *hcd)
 {
struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd);
+   unsigned long flags;
+   int ret = 0;
+   u32 hprt0;
+
+   spin_lock_irqsave(>lock, flags);
+
+   if (hsotg->lx_state != DWC2_L0)
+   goto unlock;
+
+   if (!HCD_HW_ACCESSIBLE(hcd))
+   goto unlock;
+
+   if (!hsotg->core_params->hibernation)
+   goto skip_power_saving;
+
+   /*
+* Drive USB suspend and disable port Power
+* if usb bus is not suspended.
+*/
+   if (!hsotg->bus_suspended) {
+   hprt0 = dwc2_read_hprt0(hsotg);
+   hprt0 |= HPRT0_SUSP;
+   hprt0 &= ~HPRT0_PWR;
+   dwc2_writel(hprt0, hsotg->regs + HPRT0);
+   }
+
+   /* Enter hibernation */
+   ret = dwc2_enter_hibernation(hsotg);
+   if (ret) {
+   if (ret != -ENOTSUPP)
+   dev_err(hsotg->dev,
+   "enter hibernation failed\n");
+   goto skip_power_saving;
+   }
+
+   /* Ask phy to be suspended */
+   if (!IS_ERR_OR_NULL(hsotg->uphy)) {
+   spin_unlock_irqrestore(>lock, flags);
+   usb_phy_set_suspend(hsotg->uphy, true);
+   spin_lock_irqsave(>lock, flags);
+   }
+
+   /* After entering hibernation, hardware is no more accessible */
+   clear_bit(HCD_FLAG_HW_ACCESSIBLE, >flags);
 
+skip_power_saving:
hsotg->lx_state = DWC2_L2;
-   return 0;
+unlock:
+   spin_unlock_irqrestore(>lock, flags);
+
+   return ret;
 }
 
 static int _dwc2_hcd_resume(struct usb_hcd *hcd)
 {
struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd);
+   unsigned long flags;
+   int ret = 0;
+
+   spin_lock_irqsave(>lock, flags);
+
+   if (hsotg->lx_state != DWC2_L2)
+   goto unlock;
+
+   if (!hsotg->core_params->hibernation) {
+   hsotg->lx_state = DWC2_L0;
+   goto unlock;
+   }
+
+   /*
+* Set HW accessible bit before powering on the controller
+* since an interrupt may rise.
+*/
+   set_bit(HCD_FLAG_HW_ACCESSIBLE, >flags);
+
+   /*
+* Enable power if not already done.

[PATCH v4 02/32] usb: dwc2: host: create a function to handle port_resume

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

port resume sequence may be used in different places. Create a
function to handle it. Make hprt0 read-modify-write atomic and
clear HPRT0_SUSP for both writes as it is a "read, write-set,
and self-clear (R_WS_SC)" bit. Since the lock is released
between the writes, read hprt0 again.

Since the phy clock is stopped in dwc2_port_suspend(), enable it
here and remove the PCGCTL write from dwc2_hcd_hub_control()

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/hcd.c | 40 ++--
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 1595d70..b929087 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -1484,6 +1484,35 @@ static void dwc2_port_suspend(struct dwc2_hsotg *hsotg, 
u16 windex)
}
 }
 
+/* Must NOT be called with interrupt disabled or spinlock held */
+static void dwc2_port_resume(struct dwc2_hsotg *hsotg)
+{
+   unsigned long flags;
+   u32 hprt0;
+   u32 pcgctl;
+
+   /* Resume the Phy Clock */
+   pcgctl = dwc2_readl(hsotg->regs + PCGCTL);
+   pcgctl &= ~PCGCTL_STOPPCLK;
+   dwc2_writel(pcgctl, hsotg->regs + PCGCTL);
+   usleep_range(2, 4);
+
+   spin_lock_irqsave(>lock, flags);
+   hprt0 = dwc2_read_hprt0(hsotg);
+   hprt0 |= HPRT0_RES;
+   hprt0 &= ~HPRT0_SUSP;
+   dwc2_writel(hprt0, hsotg->regs + HPRT0);
+   spin_unlock_irqrestore(>lock, flags);
+
+   msleep(USB_RESUME_TIMEOUT);
+
+   spin_lock_irqsave(>lock, flags);
+   hprt0 = dwc2_read_hprt0(hsotg);
+   hprt0 &= ~(HPRT0_RES | HPRT0_SUSP);
+   dwc2_writel(hprt0, hsotg->regs + HPRT0);
+   spin_unlock_irqrestore(>lock, flags);
+}
+
 /* Handles hub class-specific requests */
 static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq,
u16 wvalue, u16 windex, char *buf, u16 wlength)
@@ -1529,17 +1558,8 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg 
*hsotg, u16 typereq,
case USB_PORT_FEAT_SUSPEND:
dev_dbg(hsotg->dev,
"ClearPortFeature USB_PORT_FEAT_SUSPEND\n");
-   dwc2_writel(0, hsotg->regs + PCGCTL);
-   usleep_range(2, 4);
 
-   hprt0 = dwc2_read_hprt0(hsotg);
-   hprt0 |= HPRT0_RES;
-   dwc2_writel(hprt0, hsotg->regs + HPRT0);
-   hprt0 &= ~HPRT0_SUSP;
-   msleep(USB_RESUME_TIMEOUT);
-
-   hprt0 &= ~HPRT0_RES;
-   dwc2_writel(hprt0, hsotg->regs + HPRT0);
+   dwc2_port_resume(hsotg);
break;
 
case USB_PORT_FEAT_POWER:
-- 
2.3.3

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


[PATCH v4 08/32] usb: dwc2: host: resume only if bus is suspended

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

Port can be resumed in bus_resume callback.
In this case, there is no need to drive resume a second time
when hcd ask for it.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/hcd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index f5fc13b..76692b5 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -1571,7 +1571,8 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, 
u16 typereq,
dev_dbg(hsotg->dev,
"ClearPortFeature USB_PORT_FEAT_SUSPEND\n");
 
-   dwc2_port_resume(hsotg);
+   if (hsotg->bus_suspended)
+   dwc2_port_resume(hsotg);
break;
 
case USB_PORT_FEAT_POWER:
-- 
2.3.3

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


[PATCH v4 09/32] usb: dwc2: host: reset frame number after suspend

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

Frame number is reset in hardware after exiting hibernation.
Thus, reset frame_number and ensure qh are queued with correct
sched_frame.

Otherwise, qh->sched_frame may be too high compared to
current frame number (which is 0). This can delay addition of qh in
the list of transfers until frame number reaches qh->sched_frame.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/core.c  | 1 +
 drivers/usb/dwc2/hcd_queue.c | 7 +++
 2 files changed, 8 insertions(+)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 0bfc987..f5c3120 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -116,6 +116,7 @@ static int dwc2_restore_host_registers(struct dwc2_hsotg 
*hsotg)
 
dwc2_writel(hr->hprt0, hsotg->regs + HPRT0);
dwc2_writel(hr->hfir, hsotg->regs + HFIR);
+   hsotg->frame_number = 0;
 
return 0;
 }
diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c
index 712977f..294fe28 100644
--- a/drivers/usb/dwc2/hcd_queue.c
+++ b/drivers/usb/dwc2/hcd_queue.c
@@ -583,6 +583,13 @@ int dwc2_hcd_qh_add(struct dwc2_hsotg *hsotg, struct 
dwc2_qh *qh)
/* QH already in a schedule */
return 0;
 
+   if (!dwc2_frame_num_le(qh->sched_frame, hsotg->frame_number) &&
+   !hsotg->frame_number) {
+   dev_dbg(hsotg->dev, "reset frame number counter\n");
+   qh->sched_frame = dwc2_frame_num_inc(hsotg->frame_number,
+   SCHEDULE_SLOP);
+   }
+
/* Add the new QH to the appropriate schedule */
if (dwc2_qh_is_non_per(qh)) {
/* Always start in inactive schedule */
-- 
2.3.3

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


[PATCH v4 14/32] usb: dwc2: host: wait 3ms for controller stabilization

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

Some high speed mass storage devices fail to enumerate with following
error:

Cannot enable port %i.  Maybe the USB cable is bad?

This happens only when the device is plugged while the controller
is in hibernation state. After exiting hibernation, the controller
detects the device as a low speed device and fail to enumerate it.

Problem occurs only if HPRT0.PWR bit is programmed in a too short
delay after exiting hibernation. Dumping hprt register in
_dwc2_hcd_resume() directly after dwc2_exit_hibernation() shows that
HPRT0.LNSTS (D+/D- level) becomes valid approximately 2ms after
exiting hibernation.

Since dwc2_exit_hibernation() is called from atomic context, keep the
delay out of this function.

Delay value is experimental and not mentioned in Synopsys
documentation. To be on the safe side 3ms delay is used.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/hcd.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 844bf83..30dc21d 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2472,6 +2472,9 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd)
spin_unlock_irqrestore(>lock, flags);
dwc2_port_resume(hsotg);
} else {
+   /* Wait for controller to correctly update D+/D- level */
+   usleep_range(3000, 5000);
+
/*
 * Clear Port Enable and Port Status changes.
 * Enable Port Power.
@@ -2479,7 +2482,7 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd)
dwc2_writel(HPRT0_PWR | HPRT0_CONNDET |
HPRT0_ENACHG, hsotg->regs + HPRT0);
/* Wait for controller to detect Port Connect */
-   mdelay(5);
+   usleep_range(5000, 7000);
}
 
return ret;
-- 
2.3.3

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


[PATCH v4 11/32] usb: dwc2: host: add disconnect interrupt to host only interrupts

2015-09-30 Thread Mian Yousaf Kaukab
GINTSTS.DisconnInt is host only interrupt and should be disable after
dwc2_disable_host_interrupts is called.

Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index f5c3120..c5e0a45 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -857,7 +857,8 @@ void dwc2_enable_host_interrupts(struct dwc2_hsotg *hsotg)
 
/* Enable host mode interrupts without disturbing common interrupts */
intmsk = dwc2_readl(hsotg->regs + GINTMSK);
-   intmsk |= GINTSTS_DISCONNINT | GINTSTS_PRTINT | GINTSTS_HCHINT;
+   intmsk |= GINTSTS_DISCONNINT | GINTSTS_PRTINT | GINTSTS_HCHINT |
+   GINTSTS_DISCONNINT;
dwc2_writel(intmsk, hsotg->regs + GINTMSK);
 }
 
@@ -872,7 +873,7 @@ void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg)
 
/* Disable host mode interrupts without disturbing common interrupts */
intmsk &= ~(GINTSTS_SOF | GINTSTS_PRTINT | GINTSTS_HCHINT |
-   GINTSTS_PTXFEMP | GINTSTS_NPTXFEMP);
+   GINTSTS_PTXFEMP | GINTSTS_NPTXFEMP | GINTSTS_DISCONNINT);
dwc2_writel(intmsk, hsotg->regs + GINTMSK);
 }
 
-- 
2.3.3

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


[PATCH v4 13/32] usb: dwc2: host: clear pending interrupts prior hibernation

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

If an interrupt rises during hibernation process, dwc2 will assert
interrupt line to interrupt controller. If interrupt is level
sensitive, interrupt handler will be called in a loop because dwc2
will not be able to clear it while controller is hibernated.
Thus, clear all controller interrupts before hibernation entry.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/core.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index c5e0a45..bf5e951 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -398,6 +398,12 @@ int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg)
}
}
 
+   /*
+* Clear any pending interrupts since dwc2 will not be able to
+* clear them after entering hibernation.
+*/
+   dwc2_writel(0x, hsotg->regs + GINTSTS);
+
/* Put the controller in low power state */
pcgcctl = dwc2_readl(hsotg->regs + PCGCTL);
 
-- 
2.3.3

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


[PATCH v4 12/32] usb: dwc2: host: disable interrupt during stop

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

Disable host interrupts before synchronising dwc2 irq.
So that interrupts are not generated once controller is stopped.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/hcd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 5acdeaf..844bf83 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2350,6 +2350,9 @@ static void _dwc2_hcd_stop(struct usb_hcd *hcd)
struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd);
unsigned long flags;
 
+   /* Turn off all host-specific interrupts */
+   dwc2_disable_host_interrupts(hsotg);
+
/* Wait for interrupt processing to finish */
synchronize_irq(hcd->irq);
 
-- 
2.3.3

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


[PATCH v4 15/32] usb: dwc2: host: correctly dump urb isochronous descriptors

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

Print urb->iso_frame_desc.status after it has been updated using
dwc2_hcd_urb_get_iso_desc_status().

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/hcd.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 30dc21d..882be25 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2227,11 +2227,6 @@ void dwc2_host_complete(struct dwc2_hsotg *hsotg, struct 
dwc2_qtd *qtd,
 usb_pipein(urb->pipe) ? "IN" : "OUT", status,
 urb->actual_length);
 
-   if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS && dbg_perio()) {
-   for (i = 0; i < urb->number_of_packets; i++)
-   dev_vdbg(hsotg->dev, " ISO Desc %d status %d\n",
-i, urb->iso_frame_desc[i].status);
-   }
 
if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
urb->error_count = dwc2_hcd_urb_get_error_count(qtd->urb);
@@ -2244,6 +2239,12 @@ void dwc2_host_complete(struct dwc2_hsotg *hsotg, struct 
dwc2_qtd *qtd,
}
}
 
+   if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS && dbg_perio()) {
+   for (i = 0; i < urb->number_of_packets; i++)
+   dev_vdbg(hsotg->dev, " ISO Desc %d status %d\n",
+i, urb->iso_frame_desc[i].status);
+   }
+
urb->status = status;
if (!status) {
if ((urb->transfer_flags & URB_SHORT_NOT_OK) &&
-- 
2.3.3

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


[PATCH v4 06/32] usb: dwc2: host: avoid resetting lx_state to L3 during disconnect

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

When a device is disconnected, lx_state must not be changed since the
device may be disconnected whereas controller is still powered.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/core_intr.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index a6b1613..3275310 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -387,9 +387,6 @@ static void dwc2_handle_disconnect_intr(struct dwc2_hsotg 
*hsotg)
if (hsotg->op_state == OTG_STATE_A_HOST)
dwc2_hcd_disconnect(hsotg);
 
-   /* Change to L3 (OFF) state */
-   hsotg->lx_state = DWC2_L3;
-
dwc2_writel(GINTSTS_DISCONNINT, hsotg->regs + GINTSTS);
 }
 
-- 
2.3.3

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


[PATCH v4 07/32] usb: dwc2: host: ignore wakeup interrupt if hibernation supported

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

If hibernation is supported, resume of devices will be handled in
bus_resume callback.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/core_intr.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index 3275310..d8a5400 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -356,6 +356,10 @@ static void dwc2_handle_wakeup_detected_intr(struct 
dwc2_hsotg *hsotg)
/* Change to L0 state */
hsotg->lx_state = DWC2_L0;
} else {
+   if (hsotg->core_params->hibernation) {
+   dwc2_writel(GINTSTS_WKUPINT, hsotg->regs + GINTSTS);
+   return;
+   }
if (hsotg->lx_state != DWC2_L1) {
u32 pcgcctl = dwc2_readl(hsotg->regs + PCGCTL);
 
-- 
2.3.3

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


[PATCH v4 05/32] usb: dwc2: host: update hcd and lx_state during start/stop callbacks

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

During hcd initialization, hardware accessible flag and lx_state must
be reset to the working state since controller is powered at this stage.

Same logic applied for stop callback.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/hcd.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 15adc7d..f5fc13b 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2318,8 +2318,9 @@ static int _dwc2_hcd_start(struct usb_hcd *hcd)
dev_dbg(hsotg->dev, "DWC OTG HCD START\n");
 
spin_lock_irqsave(>lock, flags);
-
+   hsotg->lx_state = DWC2_L0;
hcd->state = HC_STATE_RUNNING;
+   set_bit(HCD_FLAG_HW_ACCESSIBLE, >flags);
 
if (dwc2_is_device_mode(hsotg)) {
spin_unlock_irqrestore(>lock, flags);
@@ -2350,6 +2351,9 @@ static void _dwc2_hcd_stop(struct usb_hcd *hcd)
 
spin_lock_irqsave(>lock, flags);
dwc2_hcd_stop(hsotg);
+   hsotg->lx_state = DWC2_L3;
+   hcd->state = HC_STATE_HALT;
+   clear_bit(HCD_FLAG_HW_ACCESSIBLE, >flags);
spin_unlock_irqrestore(>lock, flags);
 
usleep_range(1000, 3000);
-- 
2.3.3

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


[PATCH v4 16/32] usb: dwc2: host: use correct frame number during qh init

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

On first qh initialization, hsotg->frame_number is not corresponding
to reality. So read it from host controller to get correct value.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/hcd_queue.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c
index 294fe28..d9b3a6f 100644
--- a/drivers/usb/dwc2/hcd_queue.c
+++ b/drivers/usb/dwc2/hcd_queue.c
@@ -106,6 +106,9 @@ static void dwc2_qh_init(struct dwc2_hsotg *hsotg, struct 
dwc2_qh *qh,
USB_SPEED_HIGH : dev_speed, qh->ep_is_in,
qh->ep_type == USB_ENDPOINT_XFER_ISOC,
bytecount));
+
+   /* Ensure frame_number corresponds to the reality */
+   hsotg->frame_number = dwc2_hcd_get_frame_number(hsotg);
/* Start in a slightly future (micro)frame */
qh->sched_frame = dwc2_frame_num_inc(hsotg->frame_number,
 SCHEDULE_SLOP);
-- 
2.3.3

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


[PATCH v4 18/32] usb: dwc2: gadget: ensure lx_state corresponds to current state

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

Correctly update lx_state on gadget connection and disconnection.
When usb cable is disconnected, lx_state must be updated to L3 as
controller could be in power off state.
When usb cable is connected, lx_state must be updated to L0 as
controller is powered.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/gadget.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 12ac879..e4a4b18 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2185,6 +2185,7 @@ void dwc2_hsotg_disconnect(struct dwc2_hsotg *hsotg)
}
 
call_gadget(hsotg, disconnect);
+   hsotg->lx_state = DWC2_L3;
 }
 
 /**
@@ -2411,6 +2412,7 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg 
*hsotg,
mdelay(3);
 
hsotg->last_rst = jiffies;
+   hsotg->lx_state = DWC2_L0;
 }
 
 static void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg)
@@ -2510,7 +2512,6 @@ irq_retry:
kill_all_requests(hsotg, hsotg->eps_out[0],
  -ECONNRESET);
 
-   hsotg->lx_state = DWC2_L0;
dwc2_hsotg_core_init_disconnected(hsotg, true);
}
}
@@ -3149,10 +3150,9 @@ static int dwc2_hsotg_vbus_session(struct usb_gadget 
*gadget, int is_active)
 * If controller is hibernated, it must exit from hibernation
 * before being initialized
 */
-   if (hsotg->lx_state == DWC2_L2) {
+   if (hsotg->lx_state == DWC2_L2)
dwc2_exit_hibernation(hsotg, false);
-   hsotg->lx_state = DWC2_L0;
-   }
+
/* Kill any ep0 requests as controller will be reinitialized */
kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET);
dwc2_hsotg_core_init_disconnected(hsotg, false);
-- 
2.3.3

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


[PATCH v4 10/32] usb: dwc2: host: disconnect hcd prior stopping it

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

In case controller is asked to stop while devices are connected,
disconnect all devices and clean up before stopping.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/hcd.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 76692b5..5acdeaf 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2350,7 +2350,12 @@ static void _dwc2_hcd_stop(struct usb_hcd *hcd)
struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd);
unsigned long flags;
 
+   /* Wait for interrupt processing to finish */
+   synchronize_irq(hcd->irq);
+
spin_lock_irqsave(>lock, flags);
+   /* Ensure hcd is disconnected */
+   dwc2_hcd_disconnect(hsotg);
dwc2_hcd_stop(hsotg);
hsotg->lx_state = DWC2_L3;
hcd->state = HC_STATE_HALT;
-- 
2.3.3

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


[PATCH v4 23/32] usb: dwc2: gadget: abort core init if core_reset fails

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

No point of continue with initialization if core is not in a sane
state.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/gadget.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index fd080b8..ac1beb5 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2283,7 +2283,8 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg 
*hsotg,
u32 val;
 
if (!is_usb_reset)
-   dwc2_hsotg_corereset(hsotg);
+   if (dwc2_hsotg_corereset(hsotg))
+   return;
 
/*
 * we must now enable ep0 ready for host detection and then
-- 
2.3.3

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


[PATCH v4 30/32] usb: dwc2: gadget: exit hibernation before power down

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

When disconnecting cable, controller will detect a suspend condition
and enter partial power down. If vbus_session is called by the phy
driver during hibernation, make sure controller exit hibernation
before it is accessed.

Signed-off-by: Jianqiang Tang 
Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/gadget.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 3363fa5..50d86d2 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3229,14 +3229,15 @@ static int dwc2_hsotg_vbus_session(struct usb_gadget 
*gadget, int is_active)
dev_dbg(hsotg->dev, "%s: is_active: %d\n", __func__, is_active);
spin_lock_irqsave(>lock, flags);
 
+   /*
+* If controller is hibernated, it must exit from hibernation
+* before being initialized / de-initialized
+*/
+   if (hsotg->lx_state == DWC2_L2)
+   dwc2_exit_hibernation(hsotg, false);
+
if (is_active) {
hsotg->op_state = OTG_STATE_B_PERIPHERAL;
-   /*
-* If controller is hibernated, it must exit from hibernation
-* before being initialized
-*/
-   if (hsotg->lx_state == DWC2_L2)
-   dwc2_exit_hibernation(hsotg, false);
 
dwc2_hsotg_core_init_disconnected(hsotg, false);
if (hsotg->enabled)
-- 
2.3.3

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


[PATCH v4 24/32] usb: dwc2: gadget: ignore stall check for ep0

2015-09-30 Thread Mian Yousaf Kaukab
dwc2_hsotg_start_req starts a request only if endpoint is not stalled.
Ignore this check for ep0 as core will clear DOEPCTL0.Stall after
sending stall handshake. Prepare instead for receiving next setup
packet.

Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index ac1beb5..56b7424 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -552,7 +552,7 @@ static void dwc2_hsotg_start_req(struct dwc2_hsotg *hsotg,
/* If endpoint is stalled, we will restart request later */
ctrl = dwc2_readl(hsotg->regs + epctrl_reg);
 
-   if (ctrl & DXEPCTL_STALL) {
+   if (index && ctrl & DXEPCTL_STALL) {
dev_warn(hsotg->dev, "%s: ep%d is stalled\n", __func__, index);
return;
}
-- 
2.3.3

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


[PATCH v4 25/32] usb: dwc2: gadget: print complete setup packet

2015-09-30 Thread Mian Yousaf Kaukab
wIndex field was missing. Also print in natural order instead of
Req first, so that its easier to compare for example against
bus analyzer logs.

Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/gadget.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 56b7424..6cd6bf9 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1202,9 +1202,10 @@ static void dwc2_hsotg_process_control(struct dwc2_hsotg 
*hsotg,
int ret = 0;
u32 dcfg;
 
-   dev_dbg(hsotg->dev, "ctrl Req=%02x, Type=%02x, V=%04x, L=%04x\n",
-ctrl->bRequest, ctrl->bRequestType,
-ctrl->wValue, ctrl->wLength);
+   dev_dbg(hsotg->dev,
+   "ctrl Type=%02x, Req=%02x, V=%04x, I=%04x, L=%04x\n",
+   ctrl->bRequestType, ctrl->bRequest, ctrl->wValue,
+   ctrl->wIndex, ctrl->wLength);
 
if (ctrl->wLength == 0) {
ep0->dir_in = 1;
-- 
2.3.3

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


[PATCH v4 26/32] usb: dwc2: gadget: stop current transfer on dequeue

2015-09-30 Thread Mian Yousaf Kaukab
If the request being dequeued is already started, disable endpoint
to stop the transfer and then call dwc2_hsotg_complete_request().
Endpoint will be re-enabled on next call to dwc2_hsotg_start_req().

Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/gadget.c | 77 +++
 1 file changed, 77 insertions(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 6cd6bf9..2d0bba7 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2822,6 +2822,79 @@ static bool on_list(struct dwc2_hsotg_ep *ep, struct 
dwc2_hsotg_req *test)
return false;
 }
 
+static int dwc2_hsotg_wait_bit_set(struct dwc2_hsotg *hs_otg, u32 reg,
+   u32 bit, u32 timeout)
+{
+   u32 i;
+
+   for (i = 0; i < timeout; i++) {
+   if (dwc2_readl(hs_otg->regs + reg) & bit)
+   return 0;
+   udelay(1);
+   }
+
+   return -ETIMEDOUT;
+}
+
+static void dwc2_hsotg_ep_stop_xfr(struct dwc2_hsotg *hsotg,
+   struct dwc2_hsotg_ep *hs_ep)
+{
+   u32 epctrl_reg;
+   u32 epint_reg;
+
+   epctrl_reg = hs_ep->dir_in ? DIEPCTL(hs_ep->index) :
+   DOEPCTL(hs_ep->index);
+   epint_reg = hs_ep->dir_in ? DIEPINT(hs_ep->index) :
+   DOEPINT(hs_ep->index);
+
+   dev_dbg(hsotg->dev, "%s: stopping transfer on %s\n", __func__,
+   hs_ep->name);
+   if (hs_ep->dir_in) {
+   __orr32(hsotg->regs + epctrl_reg, DXEPCTL_SNAK);
+   /* Wait for Nak effect */
+   if (dwc2_hsotg_wait_bit_set(hsotg, epint_reg,
+   DXEPINT_INEPNAKEFF, 100))
+   dev_warn(hsotg->dev,
+   "%s: timeout DIEPINT.NAKEFF\n", __func__);
+   } else {
+   /* Clear any pending nak effect interrupt */
+   dwc2_writel(GINTSTS_GINNAKEFF, hsotg->regs + GINTSTS);
+
+   __orr32(hsotg->regs + DCTL, DCTL_SGNPINNAK);
+
+   /* Wait for global nak to take effect */
+   if (dwc2_hsotg_wait_bit_set(hsotg, GINTSTS,
+   GINTSTS_GINNAKEFF, 100))
+   dev_warn(hsotg->dev,
+   "%s: timeout GINTSTS.GINNAKEFF\n", __func__);
+   }
+
+   /* Disable ep */
+   __orr32(hsotg->regs + epctrl_reg, DXEPCTL_EPDIS | DXEPCTL_SNAK);
+
+   /* Wait for ep to be disabled */
+   if (dwc2_hsotg_wait_bit_set(hsotg, epint_reg, DXEPINT_EPDISBLD, 100))
+   dev_warn(hsotg->dev,
+   "%s: timeout DOEPCTL.EPDisable\n", __func__);
+
+   if (hs_ep->dir_in) {
+   if (hsotg->dedicated_fifos) {
+   dwc2_writel(GRSTCTL_TXFNUM(hs_ep->fifo_index) |
+   GRSTCTL_TXFFLSH, hsotg->regs + GRSTCTL);
+   /* Wait for fifo flush */
+   if (dwc2_hsotg_wait_bit_set(hsotg, GRSTCTL,
+   GRSTCTL_TXFFLSH, 100))
+   dev_warn(hsotg->dev,
+   "%s: timeout flushing fifos\n",
+   __func__);
+   }
+   /* TODO: Flush shared tx fifo */
+   } else {
+   /* Remove global NAKs */
+   __bic32(hsotg->regs + DCTL, DCTL_SGNPINNAK);
+   }
+}
+
 /**
  * dwc2_hsotg_ep_dequeue - dequeue given endpoint
  * @ep: The endpoint to dequeue.
@@ -2843,6 +2916,10 @@ static int dwc2_hsotg_ep_dequeue(struct usb_ep *ep, 
struct usb_request *req)
return -EINVAL;
}
 
+   /* Dequeue already started request */
+   if (req == _ep->req->req)
+   dwc2_hsotg_ep_stop_xfr(hs, hs_ep);
+
dwc2_hsotg_complete_request(hs, hs_ep, hs_req, -ECONNRESET);
spin_unlock_irqrestore(>lock, flags);
 
-- 
2.3.3

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


[PATCH v4 19/32] usb: dwc2: gadget: initialize op_state for peripheral only configuration

2015-09-30 Thread Mian Yousaf Kaukab
ID status change interrupt will not be handled in peripheral only
configuration. So initialize op_state during gadget init.

Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/gadget.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index e4a4b18..df8d599 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3447,6 +3447,8 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
hsotg->gadget.name = dev_name(dev);
if (hsotg->dr_mode == USB_DR_MODE_OTG)
hsotg->gadget.is_otg = 1;
+   else if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL)
+   hsotg->op_state = OTG_STATE_B_PERIPHERAL;
 
/*
 * Force Device mode before initialization.
-- 
2.3.3

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


[PATCH v4 20/32] usb: dwc2: force dr_mode in case of configuration mismatch

2015-09-30 Thread Mian Yousaf Kaukab
If dual role configuration is not selected, check and force dr_mode
based on the selected configuration.

Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/platform.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index ed7a78e..a62514f 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -368,6 +368,17 @@ static int dwc2_driver_probe(struct platform_device *dev)
(unsigned long)res->start, hsotg->regs);
 
hsotg->dr_mode = usb_get_dr_mode(>dev);
+   if (IS_ENABLED(CONFIG_USB_DWC2_HOST) &&
+   hsotg->dr_mode != USB_DR_MODE_HOST) {
+   hsotg->dr_mode = USB_DR_MODE_HOST;
+   dev_warn(hsotg->dev,
+   "Configuration mismatch. Forcing host mode\n");
+   } else if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) &&
+   hsotg->dr_mode != USB_DR_MODE_PERIPHERAL) {
+   hsotg->dr_mode = USB_DR_MODE_PERIPHERAL;
+   dev_warn(hsotg->dev,
+   "Configuration mismatch. Forcing peripheral mode\n");
+   }
 
retval = dwc2_lowlevel_hw_init(hsotg);
if (retval)
-- 
2.3.3

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


[PATCH v4 17/32] usb: dwc2: host: kill remaining urbs using -ECONNRESET status

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

On a disconnect, dwc2 will kill all remaining urbs from qh list.
urbs are given back to hcd with -ETIMEDOUT status.
Some usb device driver, like mass storage, will unlink all urbs
using usb_hcd_unlink_urb when receiving a negative status different
from -ECONNRESET.
The following flow will then happen:
dwc2_hcd_disconnect()
-> dwc2_kill_all_urbs() try to kill first pending urb.
-> dwc2_host_complete(-ETIMEDOUT)
-> usb_hcd_giveback_urb(-ETIMEDOUT)
-> sg_complete()
-> usb_unlink_urb()
-> usb_put_dev(urb->dev)
-> dwc2_kill_all_urbs() try to kill next pending urb.
-> dwc2_host_complete(-ETIMEDOUT)
-> usb_hcd_giveback_urb(-ETIMEDOUT)
-> NULL pointer dereferencing because urb->dev has been freed for all
urbs of this device.

The root cause of this NULL pointer is to call call usb_unlink_urb()
while we are killing all urbs. To avoid this return urb with
-ECONNRESET status

This issue usually happens while removing mass storage device during
transfer.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/hcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 882be25..f97e9e9 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -134,7 +134,7 @@ static void dwc2_kill_urbs_in_qh_list(struct dwc2_hsotg 
*hsotg,
list_for_each_entry_safe(qh, qh_tmp, qh_list, qh_list_entry) {
list_for_each_entry_safe(qtd, qtd_tmp, >qtd_list,
 qtd_list_entry) {
-   dwc2_host_complete(hsotg, qtd, -ETIMEDOUT);
+   dwc2_host_complete(hsotg, qtd, -ECONNRESET);
dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh);
}
}
-- 
2.3.3

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


[PATCH v4 21/32] usb: dwc2: gadget: don't modify pullup state in host mode

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

Modifying the pullup state during host mode trig a new enumeration
of attached device. Thus, avoid modifying pullup in host mode.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/gadget.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index df8d599..c9a839e 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3116,7 +3116,14 @@ static int dwc2_hsotg_pullup(struct usb_gadget *gadget, 
int is_on)
struct dwc2_hsotg *hsotg = to_hsotg(gadget);
unsigned long flags = 0;
 
-   dev_dbg(hsotg->dev, "%s: is_on: %d\n", __func__, is_on);
+   dev_dbg(hsotg->dev, "%s: is_on: %d, op_state: %d\n", __func__, is_on,
+   hsotg->op_state);
+
+   /* Don't modify pullup state while in host mode */
+   if (hsotg->op_state != OTG_STATE_B_PERIPHERAL) {
+   hsotg->enabled = is_on;
+   return 0;
+   }
 
mutex_lock(>init_mutex);
spin_lock_irqsave(>lock, flags);
-- 
2.3.3

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


[PATCH v4 27/32] usb: dwc2: gadget: kill ep0 requests before reinitializing core

2015-09-30 Thread Mian Yousaf Kaukab
Make sure there are no requests pending on ep0 before reinitializing
core. Otherwise, dwc2_hsotg_enqueue_setup will fail afterwards.

Also, take hsotg->lock before calling
dwc2_hsotg_core_init_disconnected() from dwc2_conn_id_status_change()
as dwc2_hsotg_complete_request() expect lock to be held.

Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/gadget.c | 8 +++-
 drivers/usb/dwc2/hcd.c| 3 +++
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 2d0bba7..eee2b43 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2283,6 +2283,9 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg 
*hsotg,
 {
u32 val;
 
+   /* Kill any ep0 requests as controller will be reinitialized */
+   kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET);
+
if (!is_usb_reset)
if (dwc2_hsotg_corereset(hsotg))
return;
@@ -2511,9 +2514,6 @@ irq_retry:
if (time_after(jiffies, hsotg->last_rst +
   msecs_to_jiffies(200))) {
 
-   kill_all_requests(hsotg, hsotg->eps_out[0],
- -ECONNRESET);
-
dwc2_hsotg_core_init_disconnected(hsotg, true);
}
}
@@ -3240,8 +3240,6 @@ static int dwc2_hsotg_vbus_session(struct usb_gadget 
*gadget, int is_active)
if (hsotg->lx_state == DWC2_L2)
dwc2_exit_hibernation(hsotg, false);
 
-   /* Kill any ep0 requests as controller will be reinitialized */
-   kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET);
dwc2_hsotg_core_init_disconnected(hsotg, false);
if (hsotg->enabled)
dwc2_hsotg_core_connect(hsotg);
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index f97e9e9..95aefe5 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -1355,6 +1355,7 @@ static void dwc2_conn_id_status_change(struct work_struct 
*work)
wf_otg);
u32 count = 0;
u32 gotgctl;
+   unsigned long flags;
 
dev_dbg(hsotg->dev, "%s()\n", __func__);
 
@@ -1382,7 +1383,9 @@ static void dwc2_conn_id_status_change(struct work_struct 
*work)
hsotg->op_state = OTG_STATE_B_PERIPHERAL;
dwc2_core_init(hsotg, false, -1);
dwc2_enable_global_interrupts(hsotg);
+   spin_lock_irqsave(>lock, flags);
dwc2_hsotg_core_init_disconnected(hsotg, false);
+   spin_unlock_irqrestore(>lock, flags);
dwc2_hsotg_core_connect(hsotg);
} else {
/* A-Device connector (Host Mode) */
-- 
2.3.3

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


[PATCH v4 32/32] usb: dwc2: exit hibernation on session request

2015-09-30 Thread Mian Yousaf Kaukab
Controller enters hibernation through suspend interrupt on
disconnection. On connection, session request interrupt is generated.
dwc2 must exit hibernation and restore state from this interrupt
before continuing.

In host mode, exit from hibernation is handled by bus_resume function.

Signed-off-by: Mian Yousaf Kaukab 
Signed-off-by: Gregory Herrero 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/core_intr.c | 22 +-
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index d8a5400..27daa42 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -313,16 +313,28 @@ static void dwc2_handle_conn_id_status_change_intr(struct 
dwc2_hsotg *hsotg)
  */
 static void dwc2_handle_session_req_intr(struct dwc2_hsotg *hsotg)
 {
-   dev_dbg(hsotg->dev, "++Session Request Interrupt++\n");
+   int ret;
+
+   dev_dbg(hsotg->dev, "Session request interrupt - lx_state=%d\n",
+   hsotg->lx_state);
 
/* Clear interrupt */
dwc2_writel(GINTSTS_SESSREQINT, hsotg->regs + GINTSTS);
 
-   /*
-* Report disconnect if there is any previous session established
-*/
-   if (dwc2_is_device_mode(hsotg))
+   if (dwc2_is_device_mode(hsotg)) {
+   if (hsotg->lx_state == DWC2_L2) {
+   ret = dwc2_exit_hibernation(hsotg, true);
+   if (ret && (ret != -ENOTSUPP))
+   dev_err(hsotg->dev,
+   "exit hibernation failed\n");
+   }
+
+   /*
+* Report disconnect if there is any previous session
+* established
+*/
dwc2_hsotg_disconnect(hsotg);
+   }
 }
 
 /*
-- 
2.3.3

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


[PATCH v4 28/32] usb: dwc2: gadget: only reset core after addressed state

2015-09-30 Thread Mian Yousaf Kaukab
There is a 200ms guard period to avoid unnecessary resets of the dwc2
ip. This delay sometimes prove to be too large when usbcv is run with
an ehci host. dwc2 only needs to be reset after addressed state.
Change the logic to reset ip after addressed state.

Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/core.h   |  2 --
 drivers/usb/dwc2/gadget.c | 11 +++
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 27e6fbf..8c56054 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -688,7 +688,6 @@ struct dwc2_hregs_backup {
  * @ctrl_req:   Request for EP0 control packets.
  * @ep0_state:  EP0 control transfers state
  * @test_mode:  USB test mode requested by the host
- * @last_rst:   Time of last reset
  * @eps:The endpoints being supplied to the gadget framework
  * @g_using_dma:  Indicate if dma usage is enabled
  * @g_rx_fifo_sz: Contains rx fifo size value
@@ -832,7 +831,6 @@ struct dwc2_hsotg {
struct usb_gadget gadget;
unsigned int enabled:1;
unsigned int connected:1;
-   unsigned long last_rst;
struct dwc2_hsotg_ep *eps_in[MAX_EPS_CHANNELS];
struct dwc2_hsotg_ep *eps_out[MAX_EPS_CHANNELS];
u32 g_using_dma;
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index eee2b43..25ef200 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2416,7 +2416,6 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg 
*hsotg,
/* must be at-least 3ms to allow bus to see disconnect */
mdelay(3);
 
-   hsotg->last_rst = jiffies;
hsotg->lx_state = DWC2_L0;
 }
 
@@ -2500,6 +2499,7 @@ irq_retry:
if (gintsts & (GINTSTS_USBRST | GINTSTS_RESETDET)) {
 
u32 usb_status = dwc2_readl(hsotg->regs + GOTGCTL);
+   u32 connected = hsotg->connected;
 
dev_dbg(hsotg->dev, "%s: USBRst\n", __func__);
dev_dbg(hsotg->dev, "GNPTXSTS=%08x\n",
@@ -2510,13 +2510,8 @@ irq_retry:
/* Report disconnection if it is not already done. */
dwc2_hsotg_disconnect(hsotg);
 
-   if (usb_status & GOTGCTL_BSESVLD) {
-   if (time_after(jiffies, hsotg->last_rst +
-  msecs_to_jiffies(200))) {
-
-   dwc2_hsotg_core_init_disconnected(hsotg, true);
-   }
-   }
+   if (usb_status & GOTGCTL_BSESVLD && connected)
+   dwc2_hsotg_core_init_disconnected(hsotg, true);
}
 
/* check both FIFOs */
-- 
2.3.3

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


[PATCH v4 22/32] usb: dwc2: gadget: set op_state in vbus_session call

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

Some device may have external id pin control enabled, so op_state
will not be set on id pin interrupt change.
Thus, ensure op_state is set to peripheral during vbus detection.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/gadget.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index c9a839e..fd080b8 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3153,6 +3153,7 @@ static int dwc2_hsotg_vbus_session(struct usb_gadget 
*gadget, int is_active)
spin_lock_irqsave(>lock, flags);
 
if (is_active) {
+   hsotg->op_state = OTG_STATE_B_PERIPHERAL;
/*
 * If controller is hibernated, it must exit from hibernation
 * before being initialized
-- 
2.3.3

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


[PATCH v4 31/32] usb: dwc2: gadget: handle reset interrupt before endpoint interrupts

2015-09-30 Thread Mian Yousaf Kaukab
If system is loaded, reset, enum-done and setup interrupts can occur
at the same time. Current interrupt handling sequence will handle
setup packet's interrupt before handling reset interrupt. Which will
break the enumeration process. Correct sequence is to handle reset,
enum-done and then any other endpoint interrupts.

Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/gadget.c | 60 +++
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 50d86d2..d9bcea0 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2456,6 +2456,36 @@ irq_retry:
 
gintsts &= gintmsk;
 
+   if (gintsts & GINTSTS_RESETDET) {
+   dev_dbg(hsotg->dev, "%s: USBRstDet\n", __func__);
+
+   dwc2_writel(GINTSTS_RESETDET, hsotg->regs + GINTSTS);
+
+   /* This event must be used only if controller is suspended */
+   if (hsotg->lx_state == DWC2_L2) {
+   dwc2_exit_hibernation(hsotg, true);
+   hsotg->lx_state = DWC2_L0;
+   }
+   }
+
+   if (gintsts & (GINTSTS_USBRST | GINTSTS_RESETDET)) {
+
+   u32 usb_status = dwc2_readl(hsotg->regs + GOTGCTL);
+   u32 connected = hsotg->connected;
+
+   dev_dbg(hsotg->dev, "%s: USBRst\n", __func__);
+   dev_dbg(hsotg->dev, "GNPTXSTS=%08x\n",
+   dwc2_readl(hsotg->regs + GNPTXSTS));
+
+   dwc2_writel(GINTSTS_USBRST, hsotg->regs + GINTSTS);
+
+   /* Report disconnection if it is not already done. */
+   dwc2_hsotg_disconnect(hsotg);
+
+   if (usb_status & GOTGCTL_BSESVLD && connected)
+   dwc2_hsotg_core_init_disconnected(hsotg, true);
+   }
+
if (gintsts & GINTSTS_ENUMDONE) {
dwc2_writel(GINTSTS_ENUMDONE, hsotg->regs + GINTSTS);
 
@@ -2487,36 +2517,6 @@ irq_retry:
}
}
 
-   if (gintsts & GINTSTS_RESETDET) {
-   dev_dbg(hsotg->dev, "%s: USBRstDet\n", __func__);
-
-   dwc2_writel(GINTSTS_RESETDET, hsotg->regs + GINTSTS);
-
-   /* This event must be used only if controller is suspended */
-   if (hsotg->lx_state == DWC2_L2) {
-   dwc2_exit_hibernation(hsotg, true);
-   hsotg->lx_state = DWC2_L0;
-   }
-   }
-
-   if (gintsts & (GINTSTS_USBRST | GINTSTS_RESETDET)) {
-
-   u32 usb_status = dwc2_readl(hsotg->regs + GOTGCTL);
-   u32 connected = hsotg->connected;
-
-   dev_dbg(hsotg->dev, "%s: USBRst\n", __func__);
-   dev_dbg(hsotg->dev, "GNPTXSTS=%08x\n",
-   dwc2_readl(hsotg->regs + GNPTXSTS));
-
-   dwc2_writel(GINTSTS_USBRST, hsotg->regs + GINTSTS);
-
-   /* Report disconnection if it is not already done. */
-   dwc2_hsotg_disconnect(hsotg);
-
-   if (usb_status & GOTGCTL_BSESVLD && connected)
-   dwc2_hsotg_core_init_disconnected(hsotg, true);
-   }
-
/* check both FIFOs */
 
if (gintsts & GINTSTS_NPTXFEMP) {
-- 
2.3.3

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


[PATCH v4 29/32] usb: dwc2: gadget: unmask idstschng interrupt only if controller supports it

2015-09-30 Thread Mian Yousaf Kaukab
From: Gregory Herrero 

idstschng interrupt should not be used when id pin control is
external. This is already handled on dwc2 host part. Fix it on gadget
part as well.

Signed-off-by: Gregory Herrero 
Signed-off-by: Mian Yousaf Kaukab 
Tested-by: Robert Baldyga 
Tested-by: Dinh Nguyen 
Tested-by: John Youn 
Acked-by: John Youn 
---
 drivers/usb/dwc2/gadget.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 25ef200..3363fa5 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2281,6 +2281,7 @@ static int dwc2_hsotg_corereset(struct dwc2_hsotg *hsotg)
 void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,
bool is_usb_reset)
 {
+   u32 intmsk;
u32 val;
 
/* Kill any ep0 requests as controller will be reinitialized */
@@ -2312,14 +2313,16 @@ void dwc2_hsotg_core_init_disconnected(struct 
dwc2_hsotg *hsotg,
 
/* Clear any pending interrupts */
dwc2_writel(0x, hsotg->regs + GINTSTS);
-
-   dwc2_writel(GINTSTS_ERLYSUSP | GINTSTS_SESSREQINT |
+   intmsk = GINTSTS_ERLYSUSP | GINTSTS_SESSREQINT |
GINTSTS_GOUTNAKEFF | GINTSTS_GINNAKEFF |
-   GINTSTS_CONIDSTSCHNG | GINTSTS_USBRST |
-   GINTSTS_RESETDET | GINTSTS_ENUMDONE |
-   GINTSTS_OTGINT | GINTSTS_USBSUSP |
-   GINTSTS_WKUPINT,
-   hsotg->regs + GINTMSK);
+   GINTSTS_USBRST | GINTSTS_RESETDET |
+   GINTSTS_ENUMDONE | GINTSTS_OTGINT |
+   GINTSTS_USBSUSP | GINTSTS_WKUPINT;
+
+   if (hsotg->core_params->external_id_pin_ctl <= 0)
+   intmsk |= GINTSTS_CONIDSTSCHNG;
+
+   dwc2_writel(intmsk, hsotg->regs + GINTMSK);
 
if (using_dma(hsotg))
dwc2_writel(GAHBCFG_GLBL_INTR_EN | GAHBCFG_DMA_EN |
-- 
2.3.3

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


[PATCH] net: usb: asix: Fix crash on skb alloc failure

2015-09-30 Thread David B. Robins
If asix_rx_fixup_internal() fails to allocate rx->ax_skb, it will return
but not clear rx->size. rx points to driver private data. A later call
assumes that nonzero size means ax_skb was allocated and passes a null
ax_skb to skb_put. Changed allocation failure return to clear size first.

Found testing board with AX88772B devices.

Signed-off-by: David B. Robins 
---
 drivers/net/usb/asix_common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index 75d6f26..079069a 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -91,8 +91,10 @@ int asix_rx_fixup_internal(struct usbnet *dev, struct 
sk_buff *skb,
}
rx->ax_skb = netdev_alloc_skb_ip_align(dev->net,
   rx->size);
-   if (!rx->ax_skb)
+   if (!rx->ax_skb) {
+   rx->size = 0;
return 0;
+   }
}
 
if (rx->size > dev->net->mtu + ETH_HLEN + VLAN_HLEN) {
-- 
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 v8 0/3] usb: xhci-platform: Configure 64-bit DMA mask if the platform is capable

2015-09-30 Thread Duc Dang
On Thu, Sep 17, 2015 at 11:19 AM, Duc Dang  wrote:
> The xhci platform driver does not work with system that only supports
> 64-bit DMA as it requests 32-bit DMA mask during driver initialization.
> This patch set addresses this issue and also adds XHCI-compliant USB
> Controller ACPI identification into xhci-platform driver.

Hi Greg, Mathias,

Arnd already ack-ed the first patch, please let me know if you have
more comment on this set?

>
> Changes from v7:
> - Only use dma_coerce_mask_and_coherent when
> dma_mask is NULL
> - Check the controller DMA capability and configure
> 32-bit dma_mask if it only supports 32-bit DMA
> - Patches is generated over v4.3-rc1
>
> Changes from v6:
> -Add WARN_ON if dma_mask is NULL
> -Use dma_coerce_mask_and_coherent to assign
> dma_mask and coherent_dma_mask
>
> Change from v5:
> -Change comment to "XHCI-compliant USB Controller" as
> "PNP0D10" ID is not X-Gene specific
> -Change comment
> -Assign dma_mask to coherent_dma_mask if dma_mask is NULL
> to make sure dma_set_mask_and_coherent does not fail prematurely.
>
> Changes from v4:
> -Remove #ifdef CONFIG_ACPI
> -Change comment
> -Assign dma_mask to coherent_dma_mask if dma_mask is NULL
> to make sure dma_set_mask_and_coherent does not fail prematurely.
>
> Changes from v3:
> -Regenerate the patch over 4.2-rc5
> -No code change
>
> Changes from v2
> -Replaced tristate with a boolean as the driver doesn't
> compile as a module
> -Correct --help-- to ---help---
>
> Changes from v1
> -Consolidated to use dma_set_mask_and_coherent
> -Got rid of the check against sizeof(dma_addr_t)
> -Renamed from "add support for APM X-Gene to xhci-platform"
> -Removed changes to arm64/Kconfig
> -Made CONFIG_USB_XHCI_PLATFORM a user selectable config option
>
>  drivers/usb/host/xhci-plat.c | 29 ++---
>  drivers/usb/host/xhci.c  | 10 ++
>  2 files changed, 32 insertions(+), 7 deletions(-)
>
> --
> 1.9.1
>

Regards,
Duc Dang.
--
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] HID: hiddev: fix returned errno code in hiddev_connect()

2015-09-30 Thread Jiri Kosina
On Wed, 30 Sep 2015, Luis de Bethencourt wrote:

> The driver is using -1 instead of the -ENOMEM defined macro to specify
> that a buffer allocation failed. Since the error number is propagated,
> the caller will get a -EPERM which is the wrong error condition.

Generally I agree that the more specific errno, the better.

But I am not really sure where you are seeing the bug (mapping to -EPERM) 
in this case? I think the only caller of hiddev_connect() should be 
hid_connect(), and the only thing that guy cares about whether individual 
callbacks succeed or fail, so that it sets hdev->clamed flags accordingly.

Could you please be more specific about the -EPERM mapping you are talking 
about?

Thanks,

-- 
Jiri Kosina
SUSE Labs

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


[PATCH v7 0/2] Allow USB devices to remain runtime-suspended when sleeping

2015-09-30 Thread Tomeu Vizoso
Hi,

this is v7 of an attempt to make it easier for devices to remain in
runtime PM when the system goes to sleep, mainly to reduce the time
spent resuming devices.

For this, we interpret the absence of all PM callback implementations as
it being safe to do direct_complete, so their ancestors aren't prevented
from remaining runtime-suspended.

Additionally, the prepare() callback of USB devices will return 1 if
runtime PM is enabled and the current wakeup settings are correct.

With these changes, a uvcvideo device (for example) stays in runtime
suspend when the system goes to sleep and is left in that state when the
system resumes, not delaying it unnecessarily.

Thanks,

Tomeu

Changes in v7:
- Reduce indentation by adding a label in device_prepare()

Changes in v6:
- Add stub for !CONFIG_PM.
- Move implementation of device_check_pm_callbacks to power/main.c as it
  doesn't belong to CONFIG_PM_SLEEP.
- Take dev->power.lock before modifying flag.

Changes in v5:
- Check for all dev_pm_ops instances associated to a device, updating a
  no_pm_callbacks flag at the times when that could change.

Tomeu Vizoso (2):
  PM / sleep: Go direct_complete if driver has no callbacks
  USB / PM: Allow USB devices to remain runtime-suspended when sleeping

 drivers/base/dd.c   |  3 +++
 drivers/base/power/common.c | 27 +++
 drivers/base/power/domain.c |  5 +
 drivers/base/power/main.c   |  8 
 drivers/base/power/power.h  |  6 ++
 drivers/usb/core/port.c |  6 ++
 drivers/usb/core/usb.c  | 11 ++-
 include/linux/pm.h  |  1 +
 8 files changed, 66 insertions(+), 1 deletion(-)

-- 
2.4.3

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


[PATCH] HID: hiddev: fix returned errno code in hiddev_connect()

2015-09-30 Thread Luis de Bethencourt
The driver is using -1 instead of the -ENOMEM defined macro to specify
that a buffer allocation failed. Since the error number is propagated,
the caller will get a -EPERM which is the wrong error condition.

Also, the smatch tool complains with the following warning:
hiddev_connect() warn: returning -1 instead of -ENOMEM is sloppy

Signed-off-by: Luis de Bethencourt 
---
 drivers/hid/usbhid/hiddev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 2f1ddca..c5290ff 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -894,7 +894,7 @@ int hiddev_connect(struct hid_device *hid, unsigned int 
force)
}
 
if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL)))
-   return -1;
+   return -ENOMEM;
 
init_waitqueue_head(>wait);
INIT_LIST_HEAD(>list);
-- 
2.5.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] HID: hiddev: fix returned errno code in hiddev_connect()

2015-09-30 Thread Sudip Mukherjee
On Wed, Sep 30, 2015 at 10:56:26AM +0100, Luis de Bethencourt wrote:
> On 30/09/15 10:52, Luis de Bethencourt wrote:
> > The driver is using -1 instead of the -ENOMEM defined macro to specify
> > that a buffer allocation failed. Since the error number is propagated,
> > the caller will get a -EPERM which is the wrong error condition.
> > 
> > Also, the smatch tool complains with the following warning:
> > hiddev_connect() warn: returning -1 instead of -ENOMEM is sloppy
> > 
> > Signed-off-by: Luis de Bethencourt 
> > ---
> >  drivers/hid/usbhid/hiddev.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
> > index 2f1ddca..c5290ff 100644
> > --- a/drivers/hid/usbhid/hiddev.c
> > +++ b/drivers/hid/usbhid/hiddev.c
> > @@ -894,7 +894,7 @@ int hiddev_connect(struct hid_device *hid, unsigned int 
> > force)
> > }
> >  
> > if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL)))
> > -   return -1;
> > +   return -ENOMEM;
> >  
> > init_waitqueue_head(>wait);
> > INIT_LIST_HEAD(>list);
> > 
> 
> Hello,
> 
> I got an "Undelivered Mail Returned to Sender" from Jiri Kosina's
> ji...@kernel.com email address. This email is listed multiple times
> in the MAINTAINERS file, does he have a new address to update this
> file?
Its ji...@kernel.org

regards
sudip
--
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] HID: hiddev: fix returned errno code in hiddev_connect()

2015-09-30 Thread Luis de Bethencourt
On 30/09/15 10:52, Luis de Bethencourt wrote:
> The driver is using -1 instead of the -ENOMEM defined macro to specify
> that a buffer allocation failed. Since the error number is propagated,
> the caller will get a -EPERM which is the wrong error condition.
> 
> Also, the smatch tool complains with the following warning:
> hiddev_connect() warn: returning -1 instead of -ENOMEM is sloppy
> 
> Signed-off-by: Luis de Bethencourt 
> ---
>  drivers/hid/usbhid/hiddev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
> index 2f1ddca..c5290ff 100644
> --- a/drivers/hid/usbhid/hiddev.c
> +++ b/drivers/hid/usbhid/hiddev.c
> @@ -894,7 +894,7 @@ int hiddev_connect(struct hid_device *hid, unsigned int 
> force)
>   }
>  
>   if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL)))
> - return -1;
> + return -ENOMEM;
>  
>   init_waitqueue_head(>wait);
>   INIT_LIST_HEAD(>list);
> 

Hello,

I got an "Undelivered Mail Returned to Sender" from Jiri Kosina's
ji...@kernel.com email address. This email is listed multiple times
in the MAINTAINERS file, does he have a new address to update this
file?

Thanks,
Luis
--
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] HID: hiddev: fix returned errno code in hiddev_connect()

2015-09-30 Thread Luis de Bethencourt
On 30/09/15 11:04, Sudip Mukherjee wrote:
> On Wed, Sep 30, 2015 at 10:56:26AM +0100, Luis de Bethencourt wrote:
>> On 30/09/15 10:52, Luis de Bethencourt wrote:
>>> The driver is using -1 instead of the -ENOMEM defined macro to specify
>>> that a buffer allocation failed. Since the error number is propagated,
>>> the caller will get a -EPERM which is the wrong error condition.
>>>
>>> Also, the smatch tool complains with the following warning:
>>> hiddev_connect() warn: returning -1 instead of -ENOMEM is sloppy
>>>
>>> Signed-off-by: Luis de Bethencourt 
>>> ---
>>>  drivers/hid/usbhid/hiddev.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
>>> index 2f1ddca..c5290ff 100644
>>> --- a/drivers/hid/usbhid/hiddev.c
>>> +++ b/drivers/hid/usbhid/hiddev.c
>>> @@ -894,7 +894,7 @@ int hiddev_connect(struct hid_device *hid, unsigned int 
>>> force)
>>> }
>>>  
>>> if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL)))
>>> -   return -1;
>>> +   return -ENOMEM;
>>>  
>>> init_waitqueue_head(>wait);
>>> INIT_LIST_HEAD(>list);
>>>
>>
>> Hello,
>>
>> I got an "Undelivered Mail Returned to Sender" from Jiri Kosina's
>> ji...@kernel.com email address. This email is listed multiple times
>> in the MAINTAINERS file, does he have a new address to update this
>> file?
> Its ji...@kernel.org
> 
> regards
> sudip
> 

Hi Sudip,

*facepalm* My mistake, yes.

Sorry,
Luis
--
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 v7 2/2] USB / PM: Allow USB devices to remain runtime-suspended when sleeping

2015-09-30 Thread Tomeu Vizoso
Have dev_pm_ops.prepare return 1 for USB devices and ports so that USB
devices can remain runtime-suspended when the system goes to a sleep
state, if their wakeup state is correct and they have runtime PM enabled.

Signed-off-by: Tomeu Vizoso 
---


 drivers/usb/core/port.c |  6 ++
 drivers/usb/core/usb.c  | 11 ++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 210618319f10..f49707d73b5a 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -168,12 +168,18 @@ static int usb_port_runtime_suspend(struct device *dev)
 
return retval;
 }
+
+static int usb_port_prepare(struct device *dev)
+{
+   return 1;
+}
 #endif
 
 static const struct dev_pm_ops usb_port_pm_ops = {
 #ifdef CONFIG_PM
.runtime_suspend =  usb_port_runtime_suspend,
.runtime_resume =   usb_port_runtime_resume,
+   .prepare =  usb_port_prepare,
 #endif
 };
 
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 8d5b2f4113cd..cf4dde11db1c 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -316,7 +316,16 @@ static int usb_dev_uevent(struct device *dev, struct 
kobj_uevent_env *env)
 
 static int usb_dev_prepare(struct device *dev)
 {
-   return 0;   /* Implement eventually? */
+   struct usb_device *udev = to_usb_device(dev);
+
+   if (!pm_runtime_enabled(dev))
+   return 0;
+
+   /* Return 0 if the current wakeup setting is wrong, otherwise 1 */
+   if (udev->do_remote_wakeup != device_may_wakeup(dev))
+   return 0;
+
+   return 1;
 }
 
 static void usb_dev_complete(struct device *dev)
-- 
2.4.3

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


Re: [PATCH v2 02/12] usb: gadget: amd5536udc: fix error path

2015-09-30 Thread Sudip Mukherjee
On Tue, Sep 22, 2015 at 10:19:46AM -0500, Felipe Balbi wrote:
> On Tue, Sep 22, 2015 at 08:29:52PM +0530, Sudip Mukherjee wrote:
> > On Tue, Sep 22, 2015 at 08:12:29PM +0530, Sudip Mukherjee wrote:
> > > On Tue, Sep 22, 2015 at 09:37:45AM -0500, Felipe Balbi wrote:
> > > > On Tue, Sep 22, 2015 at 06:54:27PM +0530, Sudip Mukherjee wrote:
> > > > > Handle the error properly instead of calling the pci remove function.
> > > > > 
> > > > > Signed-off-by: Sudip Mukherjee 
> > > > 
> > > > this doesn't apply. Where did you rebase this series ? Please rebase on 
> > > > my
> > > > testing/next
> > > This was done on next-20150922. I will rebase on your tree.
> > Looks like today is a day of confusion for me.
> > I asked you to discard my v1 as I saw some part of the change was done
> > by:  6527cc27761a ("usb: gadget: amd5536udc: fix error handling in 
> > udc_pci_probe()")
> > 
> > But now I dont see that patch in your testing/next , but I can see that
> > patch in next-20150922. Confused. :(
> > Now?
> 
> heh, let's wait a bit then, seems like I need to wait for -rc3 and merge that
> in my testing/next.
Hi Felipe,
A gentle reminder. This series was waiting for -rc3 to be merged.

regards
sudip
--
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: Problems with printk logs and my driver

2015-09-30 Thread Austin S Hemmelgarn

On 2015-09-29 18:11, Eric Curtin wrote:

On 25 September 2015 at 16:45, Austin S Hemmelgarn  wrote:

On 2015-09-25 08:02, Jiri Kosina wrote:


On Fri, 25 Sep 2015, Felipe Tonello wrote:


Maybe a better description on Kconfig and/or comments on source code
it's enough.



I personally find the current Kconfig description:

===
config USB_KBD
  tristate "USB HIDBP Keyboard (simple Boot) support"
  depends on USB && INPUT
  ---help---
Say Y here only if you are absolutely sure that you don't want
to use the generic HID driver for your USB keyboard and prefer
to use the keyboard in its limited Boot Protocol mode instead.

This is almost certainly not what you want.  This is mostly
useful for embedded applications or simple keyboards.

To compile this driver as a module, choose M here: the
module will be called usbkbd.

If even remotely unsure, say N.
===

shouldn't leave anyone dounting, but people are getting confused again and
again nevertheless.


For some reason there seem to be a lot of people who go to configure there
own kernel and don't read the help text (I understand if you've been
building your own Linux kernel's for years and actually understand what a
Kconfig option is really asking, but most people who I've heard of doing
this have never built a kernel before in their life).

On the other hand, can anyone think of any real reason to use this outside
of embedded systems?  I know there are a lot of distros that build this and
the USB HIDBP mouse support as modules, but I have yet to hear/find any
reports of hardware that _only_ works with this driver and not the generic
HID driver.  If this is the case, it might make sense to make this depend on
EXPERT or at least remove the bit about 'simple keyboards'.



As regards renaming usbkbd.c, @Austin there are some reasons why you would
not read the Kconfig. As a beginner, I didn't even configure this part or
read the help text as I used the configuration that comes with Fedora, I
don't know if that's a valid excuse or not though. I'll leave you guys
decide, you're the experts!

As regards the issue with my capslock led I'm still looking into it.

Personally, I would not ever advocate not reading the help text for an 
option (although in some cases it's pretty un-helpful, especially for 
some staging drivers).


Your case is one of the common ones, and it's not a bad place to start, 
but you have to keep in mind that most distro's turn on a huge amount of 
stuff that more than 90% of people aren't ever going to need (for 
example, I'm pretty sure Ubuntu still builds a module for SLIP, which 
has been an essentially dead technology for more than a decade now). 
For anyone starting from a distro's kconfig, I'd suggest at least:
a. Turn off CONFIG_EXPERT unless you intend to actually try and 
understand the options it enables (most distro's turn this on for some 
of the fine tuning features it enables, most regular people don't 
actually need it).
b. Go through using menuconfig, and turn off stuff under the drivers 
menu that you know you will never need (and take the time to use stuff 
like lspci and lsusb to figure out what actually need).
c. Read the help text before trying to change anything, and if you don't 
understand it after that, look it up online, and even then be careful 
changing it.
d. If you intend on actually using it with a particular distro, don't 
turn off too much outside of the drivers menu, other stuff can cause 
things to fail in unusual ways, and you often won't get a great amount 
of help from the distro maintainers when using a custom kernel.


The real problem is when people just read the option name and think they 
understand it when they don't really (or just don't think about the 
implications), and then wonder why something stops working suddenly 
(like one guy I know who was building a kernel for a server, and thought 
he could just disable everything under the 'Graphics' menu, then 
wondered why he didn't get console output on his monitor).




smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PATCH v11] Added forgotten parameter description for authorized attribute in usb.h

2015-09-30 Thread Stefan Koch
Hi

what does this error mean?

Should I correct it?

Best regards

Stefan

Am Dienstag, den 29.09.2015, 10:42 +0800 schrieb kbuild test robot:
> Hi Stefan,
> 
> [auto build test results on v4.3-rc3 -- if it's inappropriate base, please 
> ignore]
> 
> reproduce: make htmldocs
> 
> All warnings (new ones prefixed by >>):
> 
> >> include/linux/usb.h:188: warning: Excess struct/union/enum/typedef member 
> >> 'authorized' description in 'usb_interface'
> 
> vim +188 include/linux/usb.h
> 
> 165fe97e Craig W. Nadler  2007-06-15  172  
> b724ae77 Alan Stern   2005-10-24  173 int minor;  
> /* minor number this interface is
> b724ae77 Alan Stern   2005-10-24  174 
>  * bound to */
> ^1da177e Linus Torvalds   2005-04-16  175 enum 
> usb_interface_condition condition; /* state of binding */
> 7e61559f Alan Stern   2007-11-06  176 unsigned 
> sysfs_files_created:1; /* the sysfs attributes exist */
> 3b23dd6f Alan Stern   2008-12-05  177 unsigned 
> ep_devs_created:1; /* endpoint "devices" exist */
> 352d0263 Alan Stern   2008-10-29  178 unsigned 
> unregistering:1;   /* unregistration is in progress */
> 645daaab Alan Stern   2006-08-30  179 unsigned 
> needs_remote_wakeup:1; /* driver requires remote wakeup */
> 55151d7d Alan Stern   2008-08-12  180 unsigned 
> needs_altsetting0:1;   /* switch to altsetting 0 is pending */
> 78d9a487 Alan Stern   2008-06-23  181 unsigned 
> needs_binding:1;   /* needs delayed unbind/rebind */
> 04a723ea Sarah Sharp  2010-01-06  182 unsigned 
> resetting_device:1;/* true: bandwidth alloc after reset */
> 4d064c08 Alan Stern   2006-07-01  183  
> ^1da177e Linus Torvalds   2005-04-16  184 struct device dev;  
> /* interface specific device info */
> 969ab2ee Greg Kroah-Hartman   2008-01-30  185 struct device *usb_dev;
> ccf5b801 Alan Stern   2009-06-29  186 atomic_t pm_usage_cnt;  
> /* usage counter for autosuspend */
> dc023dce Inaky Perez-Gonzalez 2008-11-13  187 struct work_struct 
> reset_ws;/* for resets in atomic context */
> ^1da177e Linus Torvalds   2005-04-16 @188  };
> ^1da177e Linus Torvalds   2005-04-16  189  #define
> to_usb_interface(d) container_of(d, struct usb_interface, dev)
> ^1da177e Linus Torvalds   2005-04-16  190  
> ^1da177e Linus Torvalds   2005-04-16  191  static inline void 
> *usb_get_intfdata(struct usb_interface *intf)
> ^1da177e Linus Torvalds   2005-04-16  192  {
> ^1da177e Linus Torvalds   2005-04-16  193 return 
> dev_get_drvdata(>dev);
> ^1da177e Linus Torvalds   2005-04-16  194  }
> ^1da177e Linus Torvalds   2005-04-16  195  
> ^1da177e Linus Torvalds   2005-04-16  196  static inline void 
> usb_set_intfdata(struct usb_interface *intf, void *data)
> 
> :: The code at line 188 was first introduced by commit
> :: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2
> 
> :: TO: Linus Torvalds 
> :: CC: Linus Torvalds 
> 
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation


--
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: Issues with USB Bluetooth Dongle

2015-09-30 Thread Greg KH
On Wed, Sep 30, 2015 at 09:06:45PM +0530, Anil Nair wrote:
> Hi All,
> 
> I have a USB Bluetooth Dongle it detects but i am unable to use it,
> Cannot pair with any mobile device or send any file.
> 
> I am using "Ubuntu 14.04 64-bit" with kernel version "3.13.0-65-generic"
> 
> Here is the output of dmesg,
> 
> [ 2920.744043] usb 3-1: new full-speed USB device number 3 using uhci_hcd
> [ 2920.985498] usb 3-1: New USB device found, idVendor=0a12, idProduct=0001
> [ 2920.985504] usb 3-1: New USB device strings: Mfr=1, Product=2, 
> SerialNumber=0
> [ 2920.985507] usb 3-1: Product: Bluetooth V2.0 Dongle
> [ 2920.985510] usb 3-1: Manufacturer: Bluetooth v2.0
> [ 2921.818696] usbcore: registered new interface driver btusb
> 
> And lsusb,
> 
> Bus 003 Device 003: ID 0a12:0001 Cambridge Silicon Radio, Ltd
> Bluetooth Dongle (HCI mode)
> 
> Please let me know if any more information is needed.
> 
> I wanted to know what is the issue with the device.

I would suggest asking this on the bluetooth mailing list, as it seems
the USB portion of everything is working just fine.

good luck!

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


Re: [PATCH v11] Added forgotten parameter description for authorized attribute in usb.h

2015-09-30 Thread Greg KH
On Wed, Sep 30, 2015 at 11:51:15PM +0200, Stefan Koch wrote:
> Hi
> 
> what does this error mean?
> 
> Should I correct it?

You already did :)

I think it was an error as the test-bot ran your patch against a "clean"
tree, not my usb tree.  All should be good now that I have merged your
patch into my tree.

thanks,

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


[UVC][4.x][USB] Logitech QuickCam 9000 - Stability problems device disconnects/fails to reset

2015-09-30 Thread Shawn Starr
Hello kernel devs,

I've been noticing stability problems with my USB webcam, it used to be just 
bogus volume warning notice but now I have to unplug/plugin, unplug and 
sometimes it works, sometimes not. It seems to work less now.

It used to be lesser of a problem in eariler 4.x but now in 4.2/4.3 it's become 
very unstable in use. The device will sometimes be force disconnected by the 
USB bus Both USB 2.x/USB 3.x bus device ports.

Below is kernel msgs of failure:

Thanks,
Shawn

[  107.510683] usb 1-1: reset high-speed USB device number 2 using xhci_hcd
[ 1558.485719] usb 1-1: reset high-speed USB device number 2 using xhci_hcd
[22996.495603] usb 1-1: reset high-speed USB device number 2 using xhci_hcd
[23015.964902] usb 1-1: reset high-speed USB device number 2 using xhci_hcd
[23017.886591] restoring control ----0101/10/5
[23023.282498] usb 1-1: reset high-speed USB device number 2 using xhci_hcd
[23035.010933] usb 1-1: USB disconnect, device number 2
[23046.412316] usb 1-1: new high-speed USB device number 5 using xhci_hcd
[23046.711073] usb 1-1: New USB device found, idVendor=046d, idProduct=0990
[23046.711426] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=2
[23046.711780] usb 1-1: SerialNumber: B4261720
[23046.712415] uvcvideo: Found UVC 1.00 device  (046d:0990)
[23046.744959] input: UVC Camera (046d:0990) as 
/devices/pci:00/:00:14.0/usb1/1-1/1-1:1.0/input/input24
[23047.138076] usb 1-1: Warning! Unlikely big volume range (=3072), cval->res 
is probably wrong.
[23047.138504] usb 1-1: [5] FU [Mic Capture Volume] ch = 1, val = 4608/7680/1
[23055.241577] usb 1-1: reset high-speed USB device number 5 using xhci_hcd
[23074.561834] usb 1-1: reset high-speed USB device number 5 using xhci_hcd
[23089.251001] usb 1-1: reset high-speed USB device number 5 using xhci_hcd
[23089.544931] restoring control ----0101/10/5
[23094.823168] uvcvideo: Failed to set UVC probe control : -110 (exp. 26).
[23104.003182] usb 1-1: reset high-speed USB device number 5 using xhci_hcd
[23104.297038] restoring control ----0101/10/5
[23115.198761] usb 1-1: reset high-speed USB device number 5 using xhci_hcd
[23117.118523] restoring control ----0101/10/5
[23137.491620] usb 1-1: reset high-speed USB device number 5 using xhci_hcd
[23139.411020] restoring control ----0101/10/5
[23146.809652] usb 1-1: reset high-speed USB device number 5 using xhci_hcd
[23161.863901] usb 1-1: USB disconnect, device number 5
[23166.711888] usb 1-2: new high-speed USB device number 6 using xhci_hcd
[23167.010096] usb 1-2: New USB device found, idVendor=046d, idProduct=0990
[23167.010432] usb 1-2: New USB device strings: Mfr=0, Product=0, 
SerialNumber=2 
[23167.010777] usb 1-2: SerialNumber: B4261720
[23167.011452] uvcvideo: Found UVC 1.00 device  (046d:0990)
[23167.044467] input: UVC Camera (046d:0990) as 
/devices/pci:00/:00:14.0/usb1/1-2/1-2:1.0/input/input25
[23167.437046] usb 1-2: Warning! Unlikely big volume range (=3072), cval->res 
is probably wrong.
[23167.437468] usb 1-2: [5] FU [Mic Capture Volume] ch = 1, val = 4608/7680/1
[23180.400229] usb 1-2: reset high-speed USB device number 6 using xhci_hcd
[23182.319743] restoring control ----0101/10/5
[23189.733146] usb 1-2: reset high-speed USB device number 6 using xhci_hcd
[23204.787522] usb 1-2: USB disconnect, device number 6
[23217.185055] usb 1-2: new high-speed USB device number 7 using xhci_hcd
[23217.482873] usb 1-2: New USB device found, idVendor=046d, idProduct=0990
[23217.483215] usb 1-2: New USB device strings: Mfr=0, Product=0, SerialNumber=2
[23217.483570] usb 1-2: SerialNumber: B4261720
[23217.484210] uvcvideo: Found UVC 1.00 device  (046d:0990)
[23217.516471] input: UVC Camera (046d:0990) as 
/devices/pci:00/:00:14.0/usb1/1-2/1-2:1.0/input/input26
[23217.908525] usb 1-2: Warning! Unlikely big volume range (=3072), cval->res 
is probably wrong.
[23217.908948] usb 1-2: [5] FU [Mic Capture Volume] ch = 1, val = 4608/7680/1
[23234.440066] usb 1-2: reset high-speed USB device number 7 using xhci_hcd
[23240.010115] uvcvideo: Failed to set UVC probe control : -110 (exp. 26).
[23247.331979] usb 1-2: reset high-speed USB device number 7 using xhci_hcd
[23247.627113] restoring control ----0101/10/5
[23262.752322] usb 1-2: reset high-speed USB device number 7 using xhci_hcd
[23264.672678] restoring control ----0101/10/5
[23271.261131] usb 1-2: reset high-speed USB device number 7 using xhci_hcd
[23281.899397] usb 1-2: USB disconnect, device number 7
[23309.462489] usb 1-2: new high-speed USB device number 8 using xhci_hcd
[23309.760538] usb 1-2: New USB device found, idVendor=046d, idProduct=0990
[23309.760872] usb 1-2: New USB device strings: Mfr=0, Product=0, SerialNumber=2
[23309.761220] usb 1-2: SerialNumber: B4261720

Re: [PATCH 02/23] usb-gadget: use per-attribute show and store methods

2015-09-30 Thread Felipe Balbi
On Mon, Sep 28, 2015 at 03:35:14PM +0200, Christoph Hellwig wrote:
> On Sun, Sep 27, 2015 at 10:50:53AM -0500, Felipe Balbi wrote:
> > this (and the other helper below) could be macros just fine.
> 
> They could, but they shouldn't.  Inlines are always preferable over
> function-like macros.

says who ? And why ?

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 00/16] ARM: at91: PMC driver rework

2015-09-30 Thread Alexandre Belloni
Stephen, all,

Please disregard 01/16 and 02/16 as they are already in clk-next.

On 30/09/2015 at 18:10:53 +0200, Alexandre Belloni wrote :
> Hi,
> 
> This patch set is a cleanup that properly separate drivers needing to access 
> the
> PMC (PM and USB) from the clock driver by exposing the PMC as a syscon.
> 
> This also allows to implement a fix for preempt-rt. Currently, at91 platform 
> are
> crashing when using preempt-rt because the irq handler are transformed in
> threaded irq handler but at the time the pmc registers its clocks, it is not
> possible to creat threads, leading to a NULL pointer dereference in the 
> kernel.
> 
> The new infrastructure uses polling until it is late enough to register 
> threaded
> irqs.
> 
> :w
> Cc: Felipe Balbi 
> Cc: linux-usb@vger.kernel.org
> 
> Alexandre Belloni (13):
>   clk: at91: utmi: use pmc_read when the at91_pmc is available
>   clk: at91: system: don't try to free_irq when there is no IRQ
>   ARM: at91/dt: use syscon for PMC
>   clk: at91: clk-main: factorize irq handling
>   clk: at91: make IRQ optional and register them later
>   clk: at91: pmc: merge at91_pmc_init in atmel_pmc_probe
>   clk: at91: pmc: move pmc structures to C file
>   ARM: at91: pm: simply call at91_pm_init
>   ARM: at91: pm: find and remap the pmc
>   ARM: at91: pm: move idle functions to pm.c
>   ARM: at91: remove useless includes and function prototypes
>   usb: gadget: atmel: access the PMC using regmap
>   clk: at91: pmc: drop at91_pmc_base
> 
> Boris Brezillon (3):
>   clk: at91: make use of syscon to share PMC registers in several
> drivers
>   clk: at91: make use of syscon/regmap internally
>   clk: at91: only enable available IRQs
> 
>  arch/arm/boot/dts/at91rm9200.dtsi   |   2 +-
>  arch/arm/boot/dts/at91sam9260.dtsi  |   2 +-
>  arch/arm/boot/dts/at91sam9261.dtsi  |   2 +-
>  arch/arm/boot/dts/at91sam9263.dtsi  |   2 +-
>  arch/arm/boot/dts/at91sam9g45.dtsi  |   2 +-
>  arch/arm/boot/dts/at91sam9n12.dtsi  |   2 +-
>  arch/arm/boot/dts/at91sam9rl.dtsi   |   2 +-
>  arch/arm/boot/dts/at91sam9x5.dtsi   |   2 +-
>  arch/arm/boot/dts/sama5d2.dtsi  |   2 +-
>  arch/arm/boot/dts/sama5d3.dtsi  |   2 +-
>  arch/arm/boot/dts/sama5d4.dtsi  |   2 +-
>  arch/arm/mach-at91/Kconfig  |   1 +
>  arch/arm/mach-at91/at91rm9200.c |   2 -
>  arch/arm/mach-at91/at91sam9.c   |   2 -
>  arch/arm/mach-at91/generic.h|  13 +-
>  arch/arm/mach-at91/pm.c |  69 +-
>  arch/arm/mach-at91/sama5.c  |   2 +-
>  drivers/clk/at91/clk-h32mx.c|  33 ++-
>  drivers/clk/at91/clk-main.c | 403 
> +++-
>  drivers/clk/at91/clk-master.c   | 134 +++
>  drivers/clk/at91/clk-peripheral.c   | 131 +++
>  drivers/clk/at91/clk-pll.c  | 190 +--
>  drivers/clk/at91/clk-plldiv.c   |  42 ++--
>  drivers/clk/at91/clk-programmable.c |  92 
>  drivers/clk/at91/clk-slow.c |  27 ++-
>  drivers/clk/at91/clk-smd.c  |  54 +++--
>  drivers/clk/at91/clk-system.c   | 128 ++
>  drivers/clk/at91/clk-usb.c  | 121 +-
>  drivers/clk/at91/clk-utmi.c | 116 +
>  drivers/clk/at91/pmc.c  | 300 ++--
>  drivers/clk/at91/pmc.h  |  93 +---
>  drivers/usb/gadget/udc/atmel_usba_udc.c |  20 +-
>  drivers/usb/gadget/udc/atmel_usba_udc.h |   2 +
>  include/linux/clk/at91_pmc.h|  12 -
>  34 files changed, 1059 insertions(+), 950 deletions(-)
> 
> -- 
> 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 2/3] usb: gadget: at91_udc: mention proper dependency

2015-09-30 Thread Sudip Mukherjee
On Wed, Sep 30, 2015 at 11:04:54AM -0500, Felipe Balbi wrote:
> On Wed, Sep 23, 2015 at 09:22:48PM +0530, Sudip Mukherjee wrote:
> > On Mon, Sep 21, 2015 at 04:40:57PM +0530, Sudip Mukherjee wrote:
> > > On Sun, Sep 20, 2015 at 11:15:28AM -0500, Felipe Balbi wrote:
> > > > On Sat, Sep 19, 2015 at 10:42:58PM +0530, Sudip Mukherjee wrote:
> > > > > While building allmodconfig on avr32 the build failed with the error:
> > > > > "at91_pmc_base" [drivers/usb/gadget/udc/atmel_usba_udc.ko] undefined!
> > > > > 
> > > > > On checking the code it turned out that if CONFIG_OF is defined then 
> > > > > it
> > > > > is using at91_pmc_read() which is using at91_pmc_base. And unless
> > > > > COMMON_CLK_AT91 is defined we donot have at91_pmc_base. And
> > > > > COMMON_CLK_AT91 is available with AT91 architecture.
> > > > > Mention the dependency such that this driver builds with avr32 only if
> > > > > OF is not enabled.
> > > > > 
> > > > > Signed-off-by: Sudip Mukherjee 
> > > > > ---
> > > > > 
> > > > > Tested build with at91_dt_defconfig and allmodconfig of avr32. Build 
> > > > > log
> > > > > at:
> > > > > https://travis-ci.org/sudipm-mukherjee/parport/builds/81168845
> > > > > 
> > > > >  drivers/usb/gadget/udc/Kconfig | 2 +-
> > > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > 
> > > > > diff --git a/drivers/usb/gadget/udc/Kconfig 
> > > > > b/drivers/usb/gadget/udc/Kconfig
> > > > > index 9a3a6b0..cdbff54 100644
> > > > > --- a/drivers/usb/gadget/udc/Kconfig
> > > > > +++ b/drivers/usb/gadget/udc/Kconfig
> > > > > @@ -55,7 +55,7 @@ config USB_LPC32XX
> > > > >  
> > > > >  config USB_ATMEL_USBA
> > > > >   tristate "Atmel USBA"
> > > > > - depends on AVR32 || ARCH_AT91
> > > > > + depends on ((AVR32 && !OF) || ARCH_AT91)
> > > > 
> > > > any chance you can add || COMPILE_TEST here ? I'd like to make
> > > > sure this builds on my end too.
> > > With "depends on ((AVR32 && !OF) || ARCH_AT91 || COMPILE_TEST)"
> > > normal allmodconfig builiding for x86_64 failed with:
> > > 
> > > drivers/usb/gadget/udc/atmel_usba_udc.c: In function ‘usba_start’:
> > > drivers/usb/gadget/udc/atmel_usba_udc.c:1783:25: error: 
> > > ‘USBA_ENABLE_MASK’ undeclared (first use in this function)
> > >   usba_writel(udc, CTRL, USBA_ENABLE_MASK);
> > >  ^
> > > drivers/usb/gadget/udc/atmel_usba_udc.c: In function ‘usba_stop’:
> > > drivers/usb/gadget/udc/atmel_usba_udc.c:1800:25: error: 
> > > ‘USBA_DISABLE_MASK’ undeclared (first use in this function)
> > >   usba_writel(udc, CTRL, USBA_DISABLE_MASK);
> > >  ^
> > > 
> > > Looks like USBA_DISABLE_MASK and USBA_ENABLE_MASK is defined under
> > > #if defined(CONFIG_AVR32). :(
> > Can i check anything else here? Like I said with COMPILE_TEST
> > allmodconfig on x86_64 is failing.
> 
> then keep it as is, but it would be nice to get that sorted out
> so I can do compile tests on my end too.

Maybe Nicolas can give some idea. Adding Nicolas Ferre to CC.

regards
sudip
--
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 00/32] usb: dwc2: various bug fixes

2015-09-30 Thread Felipe Balbi
On Tue, Sep 29, 2015 at 12:07:58PM +0200, Mian Yousaf Kaukab wrote:
> Hi,
> This series consists of various bug fixes for both host and gadget
> sides. All patches are verified on dwc2 v3.0a with dedicated fifos.
> It would be good to get some Tested-bys for other platforms.
> 
> It is based on testing/next branch in Felipe's git.
> 
> Thank you,
> 
> Best regards,
> Yousaf
> 
> History:
> v3:
>  - Fix comment from Sergei Shtylyov
>  - Rebase to latest testing/next

are you sure ? Because I already had up to "intialize op_state for peripheral
only" applied. I'll skip all patches until that one and try to apply.

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH v3 20/32] usb: dwc2: force dr_mode in case of configuration mismatch

2015-09-30 Thread Felipe Balbi
On Tue, Sep 29, 2015 at 09:58:56PM +0300, Sergei Shtylyov wrote:
> On 09/29/2015 01:08 PM, Mian Yousaf Kaukab wrote:
> 
> >If dual role configuration is not selected, check and force dr_mode
> >based on the selected configuration.
> >
> >Signed-off-by: Mian Yousaf Kaukab 
> >Tested-by: Robert Baldyga 
> >Tested-by: Dinh Nguyen 
> >Tested-by: John Youn 
> >Acked-by: John Youn 
> >---
> >  drivers/usb/dwc2/platform.c | 11 +++
> >  1 file changed, 11 insertions(+)
> >
> >diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
> >index ed7a78e..0945e21 100644
> >--- a/drivers/usb/dwc2/platform.c
> >+++ b/drivers/usb/dwc2/platform.c
> >@@ -368,6 +368,17 @@ static int dwc2_driver_probe(struct platform_device 
> >*dev)
> > (unsigned long)res->start, hsotg->regs);
> >
> > hsotg->dr_mode = usb_get_dr_mode(>dev);
> >+if (IS_ENABLED(CONFIG_USB_DWC2_HOST) &&
> >+hsotg->dr_mode != USB_DR_MODE_HOST) {
> 
>Please indent with 2 tabs, so that it's easier on the eyes, not blending
> with the following...

fixed both myself

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 15/16] usb: gadget: atmel: access the PMC using regmap

2015-09-30 Thread Felipe Balbi
On Wed, Sep 30, 2015 at 06:11:08PM +0200, Alexandre Belloni wrote:
> Use regmap to access the PMC to avoid using at91_pmc_read and
> at91_pmc_write.
> 
> Signed-off-by: Alexandre Belloni 

can I take this through my tree or does it have any dependences with the rest of
the series ?

cheers

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 02/23] usb-gadget: use per-attribute show and store methods

2015-09-30 Thread Felipe Balbi
On Wed, Sep 30, 2015 at 12:20:46PM -0400, Tejun Heo wrote:
> On Wed, Sep 30, 2015 at 11:19:25AM -0500, Felipe Balbi wrote:
> > On Mon, Sep 28, 2015 at 03:35:14PM +0200, Christoph Hellwig wrote:
> > > On Sun, Sep 27, 2015 at 10:50:53AM -0500, Felipe Balbi wrote:
> > > > this (and the other helper below) could be macros just fine.
> > > 
> > > They could, but they shouldn't.  Inlines are always preferable over
> > > function-like macros.
> > 
> > says who ? And why ?
> 
> Documentation/CodingStyle

container_of() is type-safe, what is an inline function bringing as benefit ?

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 2/3] usb: gadget: at91_udc: mention proper dependency

2015-09-30 Thread Nicolas Ferre
Le 30/09/2015 18:24, Sudip Mukherjee a écrit :
> On Wed, Sep 30, 2015 at 11:04:54AM -0500, Felipe Balbi wrote:
>> On Wed, Sep 23, 2015 at 09:22:48PM +0530, Sudip Mukherjee wrote:
>>> On Mon, Sep 21, 2015 at 04:40:57PM +0530, Sudip Mukherjee wrote:
 On Sun, Sep 20, 2015 at 11:15:28AM -0500, Felipe Balbi wrote:
> On Sat, Sep 19, 2015 at 10:42:58PM +0530, Sudip Mukherjee wrote:
>> While building allmodconfig on avr32 the build failed with the error:
>> "at91_pmc_base" [drivers/usb/gadget/udc/atmel_usba_udc.ko] undefined!
>>
>> On checking the code it turned out that if CONFIG_OF is defined then it
>> is using at91_pmc_read() which is using at91_pmc_base. And unless
>> COMMON_CLK_AT91 is defined we donot have at91_pmc_base. And
>> COMMON_CLK_AT91 is available with AT91 architecture.
>> Mention the dependency such that this driver builds with avr32 only if
>> OF is not enabled.
>>
>> Signed-off-by: Sudip Mukherjee 
>> ---
>>
>> Tested build with at91_dt_defconfig and allmodconfig of avr32. Build log
>> at:
>> https://travis-ci.org/sudipm-mukherjee/parport/builds/81168845
>>
>>  drivers/usb/gadget/udc/Kconfig | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/gadget/udc/Kconfig 
>> b/drivers/usb/gadget/udc/Kconfig
>> index 9a3a6b0..cdbff54 100644
>> --- a/drivers/usb/gadget/udc/Kconfig
>> +++ b/drivers/usb/gadget/udc/Kconfig
>> @@ -55,7 +55,7 @@ config USB_LPC32XX
>>  
>>  config USB_ATMEL_USBA
>>  tristate "Atmel USBA"
>> -depends on AVR32 || ARCH_AT91
>> +depends on ((AVR32 && !OF) || ARCH_AT91)
>
> any chance you can add || COMPILE_TEST here ? I'd like to make
> sure this builds on my end too.
 With "depends on ((AVR32 && !OF) || ARCH_AT91 || COMPILE_TEST)"
 normal allmodconfig builiding for x86_64 failed with:

 drivers/usb/gadget/udc/atmel_usba_udc.c: In function ‘usba_start’:
 drivers/usb/gadget/udc/atmel_usba_udc.c:1783:25: error: ‘USBA_ENABLE_MASK’ 
 undeclared (first use in this function)
   usba_writel(udc, CTRL, USBA_ENABLE_MASK);
  ^
 drivers/usb/gadget/udc/atmel_usba_udc.c: In function ‘usba_stop’:
 drivers/usb/gadget/udc/atmel_usba_udc.c:1800:25: error: 
 ‘USBA_DISABLE_MASK’ undeclared (first use in this function)
   usba_writel(udc, CTRL, USBA_DISABLE_MASK);
  ^

 Looks like USBA_DISABLE_MASK and USBA_ENABLE_MASK is defined under
 #if defined(CONFIG_AVR32). :(
>>> Can i check anything else here? Like I said with COMPILE_TEST
>>> allmodconfig on x86_64 is failing.
>>
>> then keep it as is, but it would be nice to get that sorted out
>> so I can do compile tests on my end too.
> 
> Maybe Nicolas can give some idea. Adding Nicolas Ferre to CC.

Hi,

I'm thinking about something like this:

8<--
--- a/drivers/usb/gadget/udc/atmel_usba_udc.h
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
@@ -46,10 +46,10 @@
 #if defined(CONFIG_AVR32)
 #define USBA_ENABLE_MASK   USBA_EN_USBA
 #define USBA_DISABLE_MASK  0
-#elif defined(CONFIG_ARCH_AT91)
+#else
 #define USBA_ENABLE_MASK   (USBA_EN_USBA | USBA_PULLD_DIS)
 #define USBA_DISABLE_MASK  USBA_DETACH
-#endif /* CONFIG_ARCH_AT91 */
+#endif
 
 /* Bitfields in FNUM */
 #define USBA_MICRO_FRAME_NUM_OFFSET0

it can be sensible and will all to compile with the COMPILE_TEST directive.

Bye,
-- 
Nicolas Ferre
--
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/23] usb-gadget: use per-attribute show and store methods

2015-09-30 Thread Tejun Heo
On Wed, Sep 30, 2015 at 11:32:19AM -0500, Felipe Balbi wrote:
> On Wed, Sep 30, 2015 at 12:20:46PM -0400, Tejun Heo wrote:
> > On Wed, Sep 30, 2015 at 11:19:25AM -0500, Felipe Balbi wrote:
> > > On Mon, Sep 28, 2015 at 03:35:14PM +0200, Christoph Hellwig wrote:
> > > > On Sun, Sep 27, 2015 at 10:50:53AM -0500, Felipe Balbi wrote:
> > > > > this (and the other helper below) could be macros just fine.
> > > > 
> > > > They could, but they shouldn't.  Inlines are always preferable over
> > > > function-like macros.
> > > 
> > > says who ? And why ?
> > 
> > Documentation/CodingStyle
> 
> container_of() is type-safe, what is an inline function bringing as benefit ?

It's a general preference.  Because there's enough benefit to going
with inline functions and there's extra benefit to be gained from
having consistent style of code and documentation, as a general rule,
we prefer inline functions over macros.  If you have specific
technical arguments why macro is better, sure; otherwise, follow the
conventions for consistency if for nothing else.

-- 
tejun
--
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 15/16] usb: gadget: atmel: access the PMC using regmap

2015-09-30 Thread Nicolas Ferre
Le 30/09/2015 18:31, Felipe Balbi a écrit :
> On Wed, Sep 30, 2015 at 06:11:08PM +0200, Alexandre Belloni wrote:
>> Use regmap to access the PMC to avoid using at91_pmc_read and
>> at91_pmc_write.
>>
>> Signed-off-by: Alexandre Belloni 
> 
> can I take this through my tree or does it have any dependences with the rest 
> of
> the series ?

Hi Felipe,

Well, I have the feeling that these changes would require the regmap to
be in place before using it. So yes, it has a strong dependency with the
rest of the series (and DT modifications like the 06/16 patch actually).

So, I think that Alexandre would agree with me that we should take the
whole series with us through the arm-soc tree. An alternative would be
to delay the inclusion of the USB part a little bit...

Thanks for the heads-up Felipe, Bye,
-- 
Nicolas Ferre
--
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/23] usb-gadget: use per-attribute show and store methods

2015-09-30 Thread Felipe Balbi
On Wed, Sep 30, 2015 at 12:35:38PM -0400, Tejun Heo wrote:
> On Wed, Sep 30, 2015 at 11:32:19AM -0500, Felipe Balbi wrote:
> > On Wed, Sep 30, 2015 at 12:20:46PM -0400, Tejun Heo wrote:
> > > On Wed, Sep 30, 2015 at 11:19:25AM -0500, Felipe Balbi wrote:
> > > > On Mon, Sep 28, 2015 at 03:35:14PM +0200, Christoph Hellwig wrote:
> > > > > On Sun, Sep 27, 2015 at 10:50:53AM -0500, Felipe Balbi wrote:
> > > > > > this (and the other helper below) could be macros just fine.
> > > > > 
> > > > > They could, but they shouldn't.  Inlines are always preferable over
> > > > > function-like macros.
> > > > 
> > > > says who ? And why ?
> > > 
> > > Documentation/CodingStyle
> > 
> > container_of() is type-safe, what is an inline function bringing as benefit 
> > ?
> 
> It's a general preference.  Because there's enough benefit to going
> with inline functions and there's extra benefit to be gained from
> having consistent style of code and documentation, as a general rule,
> we prefer inline functions over macros.  If you have specific
> technical arguments why macro is better, sure; otherwise, follow the
> conventions for consistency if for nothing else.

$ git grep -e "define.*container_of"  | wc -l
1003

Seems like there are *ton* of uses of container_of() wrapped within a simple
macro. What convention are you talking about, again ?

And again, what benefit is an inline function bringing in this specific
case ? As for a technical reason, we know the macro definition will be
copied Verbatim into the caller body. GCC might decide to not inline
those helpers (unlikely, but could).

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 15/16] usb: gadget: atmel: access the PMC using regmap

2015-09-30 Thread Felipe Balbi
On Wed, Sep 30, 2015 at 06:39:03PM +0200, Nicolas Ferre wrote:
> Le 30/09/2015 18:31, Felipe Balbi a écrit :
> > On Wed, Sep 30, 2015 at 06:11:08PM +0200, Alexandre Belloni wrote:
> >> Use regmap to access the PMC to avoid using at91_pmc_read and
> >> at91_pmc_write.
> >>
> >> Signed-off-by: Alexandre Belloni 
> > 
> > can I take this through my tree or does it have any dependences with the 
> > rest of
> > the series ?
> 
> Hi Felipe,
> 
> Well, I have the feeling that these changes would require the regmap to
> be in place before using it. So yes, it has a strong dependency with the
> rest of the series (and DT modifications like the 06/16 patch actually).
> 
> So, I think that Alexandre would agree with me that we should take the
> whole series with us through the arm-soc tree. An alternative would be
> to delay the inclusion of the USB part a little bit...
> 
> Thanks for the heads-up Felipe, Bye,

hey no problem. I have no objections to $subject:

Acked-by: Felipe Balbi 

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 2/3] usb: gadget: at91_udc: mention proper dependency

2015-09-30 Thread Felipe Balbi
On Wed, Sep 23, 2015 at 09:22:48PM +0530, Sudip Mukherjee wrote:
> On Mon, Sep 21, 2015 at 04:40:57PM +0530, Sudip Mukherjee wrote:
> > On Sun, Sep 20, 2015 at 11:15:28AM -0500, Felipe Balbi wrote:
> > > On Sat, Sep 19, 2015 at 10:42:58PM +0530, Sudip Mukherjee wrote:
> > > > While building allmodconfig on avr32 the build failed with the error:
> > > > "at91_pmc_base" [drivers/usb/gadget/udc/atmel_usba_udc.ko] undefined!
> > > > 
> > > > On checking the code it turned out that if CONFIG_OF is defined then it
> > > > is using at91_pmc_read() which is using at91_pmc_base. And unless
> > > > COMMON_CLK_AT91 is defined we donot have at91_pmc_base. And
> > > > COMMON_CLK_AT91 is available with AT91 architecture.
> > > > Mention the dependency such that this driver builds with avr32 only if
> > > > OF is not enabled.
> > > > 
> > > > Signed-off-by: Sudip Mukherjee 
> > > > ---
> > > > 
> > > > Tested build with at91_dt_defconfig and allmodconfig of avr32. Build log
> > > > at:
> > > > https://travis-ci.org/sudipm-mukherjee/parport/builds/81168845
> > > > 
> > > >  drivers/usb/gadget/udc/Kconfig | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/drivers/usb/gadget/udc/Kconfig 
> > > > b/drivers/usb/gadget/udc/Kconfig
> > > > index 9a3a6b0..cdbff54 100644
> > > > --- a/drivers/usb/gadget/udc/Kconfig
> > > > +++ b/drivers/usb/gadget/udc/Kconfig
> > > > @@ -55,7 +55,7 @@ config USB_LPC32XX
> > > >  
> > > >  config USB_ATMEL_USBA
> > > > tristate "Atmel USBA"
> > > > -   depends on AVR32 || ARCH_AT91
> > > > +   depends on ((AVR32 && !OF) || ARCH_AT91)
> > > 
> > > any chance you can add || COMPILE_TEST here ? I'd like to make
> > > sure this builds on my end too.
> > With "depends on ((AVR32 && !OF) || ARCH_AT91 || COMPILE_TEST)"
> > normal allmodconfig builiding for x86_64 failed with:
> > 
> > drivers/usb/gadget/udc/atmel_usba_udc.c: In function ‘usba_start’:
> > drivers/usb/gadget/udc/atmel_usba_udc.c:1783:25: error: ‘USBA_ENABLE_MASK’ 
> > undeclared (first use in this function)
> >   usba_writel(udc, CTRL, USBA_ENABLE_MASK);
> >  ^
> > drivers/usb/gadget/udc/atmel_usba_udc.c: In function ‘usba_stop’:
> > drivers/usb/gadget/udc/atmel_usba_udc.c:1800:25: error: ‘USBA_DISABLE_MASK’ 
> > undeclared (first use in this function)
> >   usba_writel(udc, CTRL, USBA_DISABLE_MASK);
> >  ^
> > 
> > Looks like USBA_DISABLE_MASK and USBA_ENABLE_MASK is defined under
> > #if defined(CONFIG_AVR32). :(
> Can i check anything else here? Like I said with COMPILE_TEST
> allmodconfig on x86_64 is failing.

then keep it as is, but it would be nice to get that sorted out
so I can do compile tests on my end too.

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH v2 20/32] usb: dwc2: force dr_mode in case of configuration mismatch

2015-09-30 Thread Felipe Balbi
On Tue, Sep 29, 2015 at 10:07:56AM +, Kaukab, Yousaf wrote:
> > -Original Message-
> > From: Felipe Balbi [mailto:ba...@ti.com]
> > Sent: Monday, September 28, 2015 10:43 PM
> > To: Kaukab, Yousaf
> > Cc: linux-usb@vger.kernel.org; ba...@ti.com; john.y...@synopsys.com;
> > Herrero, Gregory; he...@sntech.de; diand...@chromium.org;
> > r.bald...@samsung.com; dingu...@opensource.altera.com;
> > zhangfei@linaro.org; sergei.shtyl...@cogentembedded.com;
> > david.a.co...@linux.intel.com
> > Subject: Re: [PATCH v2 20/32] usb: dwc2: force dr_mode in case of
> > configuration mismatch
> > 
> > On Tue, Sep 22, 2015 at 03:16:56PM +0200, Mian Yousaf Kaukab wrote:
> > > If dual role configuration is not selected, check and force dr_mode
> > > based on the selected configuration.
> > >
> > > Signed-off-by: Mian Yousaf Kaukab 
> > > Tested-by: Robert Baldyga 
> > 
> > this failed to apply. Please rebase on testing/next
> 
> Ok I will rebase the whole series.

Thanks

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH v3 1/2] usb: gadget: loopback: fix: Don't share qlen and buflen between instances

2015-09-30 Thread Felipe Balbi
On Thu, Sep 24, 2015 at 07:10:53PM +0200, Krzysztof Opasiak wrote:
> 
> 
> On 09/24/2015 06:51 PM, Felipe Balbi wrote:
> >On Thu, Sep 24, 2015 at 05:19:12PM +0200, Robert Baldyga wrote:
> >>On 09/22/2015 08:40 PM, Krzysztof Opasiak wrote:
> >>>Each instance of loopback function may have different qlen
> >>>and buflen attributes values. When linking function to
> >>>configuration those values had been assigned to global
> >>>variables. Linking other instance to config overwrites those
> >>>values.
> >>>
> >>>This commit moves those values to f_loopback structure
> >>>to avoid overwriting. Now each function has its own instance
> >>>of those values.
> >>>
> >>>Cc:  # 3.10+
> >>>Signed-off-by: Krzysztof Opasiak 
> >>
> >>Reviewed-by: Robert Baldyga 
> >
> >doesn't seem to fit stable IMO. Care to explain why you think we need
> >to backport this to v3.10+ ?
> >
> 
> Let's consider following set of commands:
> 
> cd $CFS_ROOT/usb_gadget
> mkdir g1
> cd g1
> mkdir functions/SourceSink.1
> mkdir functions/SourceSink.2
> echo 1024 > functions/SourceSink.1/buflen
> echo 512 > functions/SourceSink.2/buflen
> mkdir configs/c.1
> ln -s functions/SourceSink.1 configs/c.1/
> ln -s functions/SourceSink.2 configs/c.1/
> echo $UDC > UDC
> 
> You assume that after executing this script you will get two instances of
> SourceSink functions and one of them will alloc requests buffers which has
> 1024 and second one which has only 512.
> 
> Unfortunately due to using global variables both of them are going to alloc
> only 512 bytes for each request. The same situation is with qlen. All
> instances are going to use attributes values from the last one in the
> system, even if they are in multiple gadgets.

that's all fine and dandy, but it's still a new requirement. It fits easily
into "has never worked before" category. If it was something which really
regressed, IOW we used to support it but some other commit broke it, then
I'd agree.

> In my opinion second patch in this series is much more important as it makes
> loopback function working again after almost year of being only /dev/null
> and /dev/zero. But that one should to go only to 3.18.

ok

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH v3 2/2] usb: gadget: loopback: Fix looping back logic implementation

2015-09-30 Thread Felipe Balbi
On Tue, Sep 22, 2015 at 08:40:23PM +0200, Krzysztof Opasiak wrote:
> Since:
> 
> commit e0857ce58e8658657f5f12fe25272b93cfeb16aa

this should be something like:

Since commit e0857ce58e86 ("  ")

> ("usb: gadget: loopback: don't queue requests to bogus endpoints")
> 
> Loopback function is not realy working as that commit removed
> all looping back logic. After that commit ep-out works like
> /dev/null and ep-in works like /dev/zero.
> 
> This commit fix this issue by allocating set of out requests
> and set of in requests but each out req shares buffer with
> one in req:
> 
> out_req->buf ---> buf <--- in_req.buf
> out_req->context <---> in_req.context
> 
> The completion routine simply  enqueue the suitable req in
> an oposite direction.
> 
> Cc:  # 3.18+

missing Fixes: e0857ce58e86 ("...")

I'll fix both while applying, but make sure to make this proper
next time.

> Signed-off-by: Krzysztof Opasiak 
> ---
> Changes since v2:
> - fix requests context assignment
> 
> Changes since v1:
> - add missing usb_ep_free_request() in complete() callback
> ---
>  drivers/usb/gadget/function/f_loopback.c |  131 
> +-
>  1 file changed, 92 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/f_loopback.c 
> b/drivers/usb/gadget/function/f_loopback.c
> index e4bfed4..c369554 100644
> --- a/drivers/usb/gadget/function/f_loopback.c
> +++ b/drivers/usb/gadget/function/f_loopback.c
> @@ -245,22 +245,38 @@ static void loopback_complete(struct usb_ep *ep, struct 
> usb_request *req)
>   int status = req->status;
>  
>   switch (status) {
> -
>   case 0: /* normal completion? */
>   if (ep == loop->out_ep) {
> - req->zero = (req->actual < req->length);
> - req->length = req->actual;
> + /*
> +  * We received some data from the host so let's
> +  * queue it so host can read the from our in ep
> +  */
> + struct usb_request *in_req = req->context;
> +
> + in_req->zero = (req->actual < req->length);
> + in_req->length = req->actual;
> + ep = loop->in_ep;
> + req = in_req;
> + } else {
> + /*
> +  * We have just looped back a bunch of data
> +  * to host. Now let's wait for some more data.
> +  */
> + req = req->context;
> + ep = loop->out_ep;
>   }
>  
> - /* queue the buffer for some later OUT packet */
> - req->length = loop->buflen;
> + /* queue the buffer back to host or for next bunch of data */
>   status = usb_ep_queue(ep, req, GFP_ATOMIC);
> - if (status == 0)
> + if (status == 0) {
>   return;
> + } else {
> + ERROR(cdev, "Unable to loop back buffer to %s: %d\n",
> +   ep->name, status);
> + goto free_req;
> + }
>  
>   /* "should never get here" */
> - /* FALLTHROUGH */
> -
>   default:
>   ERROR(cdev, "%s loop complete --> %d, %d/%d\n", ep->name,
>   status, req->actual, req->length);
> @@ -274,6 +290,10 @@ static void loopback_complete(struct usb_ep *ep, struct 
> usb_request *req)
>   case -ECONNABORTED: /* hardware forced ep reset */
>   case -ECONNRESET:   /* request dequeued */
>   case -ESHUTDOWN:/* disconnect from host */
> +free_req:
> + usb_ep_free_request(ep == loop->in_ep ?
> + loop->out_ep : loop->in_ep,
> + req->context);
>   free_ep_req(ep, req);
>   return;
>   }
> @@ -295,50 +315,72 @@ static inline struct usb_request 
> *lb_alloc_ep_req(struct usb_ep *ep, int len)
>   return alloc_ep_req(ep, len, loop->buflen);
>  }
>  
> -static int enable_endpoint(struct usb_composite_dev *cdev, struct f_loopback 
> *loop,
> - struct usb_ep *ep)
> +static int alloc_requests(struct usb_composite_dev *cdev,
> +   struct f_loopback *loop)
>  {
> - struct usb_request  *req;
> - unsignedi;
> - int result;
> -
> - /*
> -  * one endpoint writes data back IN to the host while another endpoint
> -  * just reads OUT packets
> -  */
> - result = config_ep_by_speed(cdev->gadget, &(loop->function), ep);
> - if (result)
> - goto fail0;
> - result = usb_ep_enable(ep);
> - if (result < 0)
> - goto fail0;
> - 

[PATCH 00/16] ARM: at91: PMC driver rework

2015-09-30 Thread Alexandre Belloni
Hi,

This patch set is a cleanup that properly separate drivers needing to access the
PMC (PM and USB) from the clock driver by exposing the PMC as a syscon.

This also allows to implement a fix for preempt-rt. Currently, at91 platform are
crashing when using preempt-rt because the irq handler are transformed in
threaded irq handler but at the time the pmc registers its clocks, it is not
possible to creat threads, leading to a NULL pointer dereference in the kernel.

The new infrastructure uses polling until it is late enough to register threaded
irqs.

:w
Cc: Felipe Balbi 
Cc: linux-usb@vger.kernel.org

Alexandre Belloni (13):
  clk: at91: utmi: use pmc_read when the at91_pmc is available
  clk: at91: system: don't try to free_irq when there is no IRQ
  ARM: at91/dt: use syscon for PMC
  clk: at91: clk-main: factorize irq handling
  clk: at91: make IRQ optional and register them later
  clk: at91: pmc: merge at91_pmc_init in atmel_pmc_probe
  clk: at91: pmc: move pmc structures to C file
  ARM: at91: pm: simply call at91_pm_init
  ARM: at91: pm: find and remap the pmc
  ARM: at91: pm: move idle functions to pm.c
  ARM: at91: remove useless includes and function prototypes
  usb: gadget: atmel: access the PMC using regmap
  clk: at91: pmc: drop at91_pmc_base

Boris Brezillon (3):
  clk: at91: make use of syscon to share PMC registers in several
drivers
  clk: at91: make use of syscon/regmap internally
  clk: at91: only enable available IRQs

 arch/arm/boot/dts/at91rm9200.dtsi   |   2 +-
 arch/arm/boot/dts/at91sam9260.dtsi  |   2 +-
 arch/arm/boot/dts/at91sam9261.dtsi  |   2 +-
 arch/arm/boot/dts/at91sam9263.dtsi  |   2 +-
 arch/arm/boot/dts/at91sam9g45.dtsi  |   2 +-
 arch/arm/boot/dts/at91sam9n12.dtsi  |   2 +-
 arch/arm/boot/dts/at91sam9rl.dtsi   |   2 +-
 arch/arm/boot/dts/at91sam9x5.dtsi   |   2 +-
 arch/arm/boot/dts/sama5d2.dtsi  |   2 +-
 arch/arm/boot/dts/sama5d3.dtsi  |   2 +-
 arch/arm/boot/dts/sama5d4.dtsi  |   2 +-
 arch/arm/mach-at91/Kconfig  |   1 +
 arch/arm/mach-at91/at91rm9200.c |   2 -
 arch/arm/mach-at91/at91sam9.c   |   2 -
 arch/arm/mach-at91/generic.h|  13 +-
 arch/arm/mach-at91/pm.c |  69 +-
 arch/arm/mach-at91/sama5.c  |   2 +-
 drivers/clk/at91/clk-h32mx.c|  33 ++-
 drivers/clk/at91/clk-main.c | 403 +++-
 drivers/clk/at91/clk-master.c   | 134 +++
 drivers/clk/at91/clk-peripheral.c   | 131 +++
 drivers/clk/at91/clk-pll.c  | 190 +--
 drivers/clk/at91/clk-plldiv.c   |  42 ++--
 drivers/clk/at91/clk-programmable.c |  92 
 drivers/clk/at91/clk-slow.c |  27 ++-
 drivers/clk/at91/clk-smd.c  |  54 +++--
 drivers/clk/at91/clk-system.c   | 128 ++
 drivers/clk/at91/clk-usb.c  | 121 +-
 drivers/clk/at91/clk-utmi.c | 116 +
 drivers/clk/at91/pmc.c  | 300 ++--
 drivers/clk/at91/pmc.h  |  93 +---
 drivers/usb/gadget/udc/atmel_usba_udc.c |  20 +-
 drivers/usb/gadget/udc/atmel_usba_udc.h |   2 +
 include/linux/clk/at91_pmc.h|  12 -
 34 files changed, 1059 insertions(+), 950 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 15/16] usb: gadget: atmel: access the PMC using regmap

2015-09-30 Thread Alexandre Belloni
Use regmap to access the PMC to avoid using at91_pmc_read and
at91_pmc_write.

Signed-off-by: Alexandre Belloni 
---
Cc: Felipe Balbi 
Cc: linux-usb@vger.kernel.org
 drivers/usb/gadget/udc/atmel_usba_udc.c | 20 ++--
 drivers/usb/gadget/udc/atmel_usba_udc.h |  2 ++
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 3dfada8d6061..40977cd832af 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -17,7 +17,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1888,20 +1890,15 @@ static int atmel_usba_stop(struct usb_gadget *gadget)
 #ifdef CONFIG_OF
 static void at91sam9rl_toggle_bias(struct usba_udc *udc, int is_on)
 {
-   unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR);
-
-   if (is_on)
-   at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
-   else
-   at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
+   regmap_update_bits(udc->pmc, AT91_CKGR_UCKR, AT91_PMC_BIASEN,
+  is_on ? AT91_PMC_BIASEN : 0);
 }
 
 static void at91sam9g45_pulse_bias(struct usba_udc *udc)
 {
-   unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR);
-
-   at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
-   at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
+   regmap_update_bits(udc->pmc, AT91_CKGR_UCKR, AT91_PMC_BIASEN, 0);
+   regmap_update_bits(udc->pmc, AT91_CKGR_UCKR, AT91_PMC_BIASEN,
+  AT91_PMC_BIASEN);
 }
 
 static const struct usba_udc_errata at91sam9rl_errata = {
@@ -1938,6 +1935,9 @@ static struct usba_ep * atmel_udc_of_init(struct 
platform_device *pdev,
return ERR_PTR(-EINVAL);
 
udc->errata = match->data;
+   udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9g45-pmc");
+   if (udc->errata && IS_ERR(udc->pmc))
+   return ERR_CAST(udc->pmc);
 
udc->num_ep = 0;
 
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h 
b/drivers/usb/gadget/udc/atmel_usba_udc.h
index ea448a344767..3e1c9d589dfa 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.h
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
@@ -354,6 +354,8 @@ struct usba_udc {
struct dentry *debugfs_root;
struct dentry *debugfs_regs;
 #endif
+
+   struct regmap *pmc;
 };
 
 static inline struct usba_ep *to_usba_ep(struct usb_ep *ep)
-- 
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: [PATCH v3 2/2] usb: gadget: loopback: Fix looping back logic implementation

2015-09-30 Thread Felipe Balbi
On Wed, Sep 30, 2015 at 11:11:52AM -0500, Felipe Balbi wrote:
> On Tue, Sep 22, 2015 at 08:40:23PM +0200, Krzysztof Opasiak wrote:
> > Since:
> > 
> > commit e0857ce58e8658657f5f12fe25272b93cfeb16aa
> 
> this should be something like:
> 
> Since commit e0857ce58e86 ("  ")
> 
> > ("usb: gadget: loopback: don't queue requests to bogus endpoints")
> > 
> > Loopback function is not realy working as that commit removed
> > all looping back logic. After that commit ep-out works like
> > /dev/null and ep-in works like /dev/zero.
> > 
> > This commit fix this issue by allocating set of out requests
> > and set of in requests but each out req shares buffer with
> > one in req:
> > 
> > out_req->buf ---> buf <--- in_req.buf
> > out_req->context <---> in_req.context
> > 
> > The completion routine simply  enqueue the suitable req in
> > an oposite direction.
> > 
> > Cc:  # 3.18+
> 
> missing Fixes: e0857ce58e86 ("...")
> 
> I'll fix both while applying, but make sure to make this proper
> next time.

actually fails to apply to v4.3-rc3, please rebase.

-- 
balbi


signature.asc
Description: PGP signature


Re: [RFC PATCH 1/2] usb: doc: Add bindings for ULPI platform driver

2015-09-30 Thread Felipe Balbi
On Thu, Sep 24, 2015 at 11:18:01AM -0500, Rob Herring wrote:
> On Thu, Sep 24, 2015 at 4:26 AM, Subbaraya Sundeep Bhatta
>  wrote:
> > Hi Peter,
> >
> >> -Original Message-
> >> From: Peter Chen [mailto:peter.c...@freescale.com]
> >> Sent: Thursday, September 24, 2015 2:41 PM
> >> To: Subbaraya Sundeep Bhatta
> >> Cc: ba...@ti.com; devicet...@vger.kernel.org; kis...@ti.com;
> >> gre...@linuxfoundation.org; linux-usb@vger.kernel.org; linux-
> >> ker...@vger.kernel.org; Punnaiah Choudary Kalluri; Subbaraya Sundeep 
> >> Bhatta;
> >> linux-arm-ker...@lists.infradead.org
> >> Subject: Re: [RFC PATCH 1/2] usb: doc: Add bindings for ULPI platform 
> >> driver
> >>
> >> On Wed, Sep 23, 2015 at 06:24:01PM +0530, Subbaraya Sundeep Bhatta
> >> wrote:
> >> > This patch adds binding doc info for generic ULPI PHYs platform
> >> > driver.
> >> >
> >> > Signed-off-by: Subbaraya Sundeep Bhatta 
> >> > ---
> >> >  .../devicetree/bindings/usb/ulpi-platform-phy.txt  |   34
> >> 
> >> >  1 files changed, 34 insertions(+), 0 deletions(-)  create mode 100644
> >> > Documentation/devicetree/bindings/usb/ulpi-platform-phy.txt
> >> >
> >> > diff --git
> >> > a/Documentation/devicetree/bindings/usb/ulpi-platform-phy.txt
> >> > b/Documentation/devicetree/bindings/usb/ulpi-platform-phy.txt
> >> > new file mode 100644
> >> > index 000..7b8cbb4
> >> > --- /dev/null
> >> > +++ b/Documentation/devicetree/bindings/usb/ulpi-platform-phy.txt
> >> > @@ -0,0 +1,34 @@
> >> > +Platform driver for generic ULPI PHYs
> >> > +
> >> > +Required properties:
> >> > +- compatible   : Should be "ulpi-phy"
> >> > +- reg  : Physical base address and size of the USB
> >> > + controller registers map to which this PHY
> >> > + is connected.
> >> > +- view-port: Should contain viewport register offset of 
> >> > the
> >> > + USB controller to which this PHY is connected 
> >> > Optional
> >> > +properties:
> >> > +- drv-vbus : required if turning VBUS on/off has to be driven
> >> > + by writing to PHY. This feature depends on board
> >> > + design.
> >> > +
> >> > +Example:
> >> > +Below example shows the PHY binding for Chipidea USB controller which
> >> > +has ulpi viewport register at 0x0170
> >> > +
> >> > +   usb_phy0: phy0 {
> >> > +   compatible = "ulpi-phy";
> >> > +   reg = <0xe0002000 0x1000>;
> >> > +   view-port = <0x0170>;
> >> > +   drv-vbus;
> >> > +   };
> >> > +
> >> > +   usb0: usb@e0002000 {
> >> > +compatible = "chipidea,usb2";
> >> > +interrupt-parent = <>;
> >> > +interrupts = <0 21 4>;
> >> > +reg = <0xe0002000 0x1000>;
> >>
> >> Although just call devm_ioremap twice for the same register region does not
> >> cause any errors, I am not sure if it will has other potential problems. 
> >> Cc: arm
> >> list.
> >
> > Yes Peter I was also in doubt to call devm_ioremap twice for same register 
> > region.
> > devm_ioremap_resource complained hence modified to devm_ioremap. Thanks for
> > adding arm-list.
> 
> Don't put overlapping resources in the DT. Having 2 drivers accessing
> the same registers is not a clean or safe design.

thanks, saves me the trouble of saying the same thing.

Bottom line, if devm_ioremap_resource() fails, you're wrong. Just fix
your driver and move on.

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 02/23] usb-gadget: use per-attribute show and store methods

2015-09-30 Thread Tejun Heo
On Wed, Sep 30, 2015 at 11:19:25AM -0500, Felipe Balbi wrote:
> On Mon, Sep 28, 2015 at 03:35:14PM +0200, Christoph Hellwig wrote:
> > On Sun, Sep 27, 2015 at 10:50:53AM -0500, Felipe Balbi wrote:
> > > this (and the other helper below) could be macros just fine.
> > 
> > They could, but they shouldn't.  Inlines are always preferable over
> > function-like macros.
> 
> says who ? And why ?

Documentation/CodingStyle

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


Issues with USB Bluetooth Dongle

2015-09-30 Thread Anil Nair
Hi All,

I have a USB Bluetooth Dongle it detects but i am unable to use it,
Cannot pair with any mobile device or send any file.

I am using "Ubuntu 14.04 64-bit" with kernel version "3.13.0-65-generic"

Here is the output of dmesg,

[ 2920.744043] usb 3-1: new full-speed USB device number 3 using uhci_hcd
[ 2920.985498] usb 3-1: New USB device found, idVendor=0a12, idProduct=0001
[ 2920.985504] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 2920.985507] usb 3-1: Product: Bluetooth V2.0 Dongle
[ 2920.985510] usb 3-1: Manufacturer: Bluetooth v2.0
[ 2921.818696] usbcore: registered new interface driver btusb

And lsusb,

Bus 003 Device 003: ID 0a12:0001 Cambridge Silicon Radio, Ltd
Bluetooth Dongle (HCI mode)

Please let me know if any more information is needed.

I wanted to know what is the issue with the device.

Thanking You,

--
Regards,
Anil Nair
--
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: at91_udc: mention proper dependency

2015-09-30 Thread Sudip Mukherjee
On Wed, Sep 30, 2015 at 06:34:28PM +0200, Nicolas Ferre wrote:
> Le 30/09/2015 18:24, Sudip Mukherjee a écrit :
> > On Wed, Sep 30, 2015 at 11:04:54AM -0500, Felipe Balbi wrote:
> >> On Wed, Sep 23, 2015 at 09:22:48PM +0530, Sudip Mukherjee wrote:
> >>> On Mon, Sep 21, 2015 at 04:40:57PM +0530, Sudip Mukherjee wrote:
>  On Sun, Sep 20, 2015 at 11:15:28AM -0500, Felipe Balbi wrote:
> > On Sat, Sep 19, 2015 at 10:42:58PM +0530, Sudip Mukherjee wrote:
> >> While building allmodconfig on avr32 the build failed with the error:
> >> "at91_pmc_base" [drivers/usb/gadget/udc/atmel_usba_udc.ko] undefined!
> >>
> >> On checking the code it turned out that if CONFIG_OF is defined then it
> >> is using at91_pmc_read() which is using at91_pmc_base. And unless
> >> COMMON_CLK_AT91 is defined we donot have at91_pmc_base. And
> >> COMMON_CLK_AT91 is available with AT91 architecture.
> >> Mention the dependency such that this driver builds with avr32 only if
> >> OF is not enabled.
> >>
> >> Signed-off-by: Sudip Mukherjee 
> >> ---
> >>
> >> Tested build with at91_dt_defconfig and allmodconfig of avr32. Build 
> >> log
> >> at:
> >> https://travis-ci.org/sudipm-mukherjee/parport/builds/81168845
> >>
> >>  drivers/usb/gadget/udc/Kconfig | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/usb/gadget/udc/Kconfig 
> >> b/drivers/usb/gadget/udc/Kconfig
> >> index 9a3a6b0..cdbff54 100644
> >> --- a/drivers/usb/gadget/udc/Kconfig
> >> +++ b/drivers/usb/gadget/udc/Kconfig
> >> @@ -55,7 +55,7 @@ config USB_LPC32XX
> >>  
> >>  config USB_ATMEL_USBA
> >>tristate "Atmel USBA"
> >> -  depends on AVR32 || ARCH_AT91
> >> +  depends on ((AVR32 && !OF) || ARCH_AT91)
> >
> > any chance you can add || COMPILE_TEST here ? I'd like to make
> > sure this builds on my end too.
>  With "depends on ((AVR32 && !OF) || ARCH_AT91 || COMPILE_TEST)"
>  normal allmodconfig builiding for x86_64 failed with:
> 
>  drivers/usb/gadget/udc/atmel_usba_udc.c: In function ‘usba_start’:
>  drivers/usb/gadget/udc/atmel_usba_udc.c:1783:25: error: 
>  ‘USBA_ENABLE_MASK’ undeclared (first use in this function)
>    usba_writel(udc, CTRL, USBA_ENABLE_MASK);
>   ^
>  drivers/usb/gadget/udc/atmel_usba_udc.c: In function ‘usba_stop’:
>  drivers/usb/gadget/udc/atmel_usba_udc.c:1800:25: error: 
>  ‘USBA_DISABLE_MASK’ undeclared (first use in this function)
>    usba_writel(udc, CTRL, USBA_DISABLE_MASK);
>   ^
> 
>  Looks like USBA_DISABLE_MASK and USBA_ENABLE_MASK is defined under
>  #if defined(CONFIG_AVR32). :(
> >>> Can i check anything else here? Like I said with COMPILE_TEST
> >>> allmodconfig on x86_64 is failing.
> >>
> >> then keep it as is, but it would be nice to get that sorted out
> >> so I can do compile tests on my end too.
> > 
> > Maybe Nicolas can give some idea. Adding Nicolas Ferre to CC.
> 
> Hi,
> 
> I'm thinking about something like this:
> 
> 8<--
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.h
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
> @@ -46,10 +46,10 @@
>  #if defined(CONFIG_AVR32)
>  #define USBA_ENABLE_MASK   USBA_EN_USBA
>  #define USBA_DISABLE_MASK  0
> -#elif defined(CONFIG_ARCH_AT91)
> +#else
>  #define USBA_ENABLE_MASK   (USBA_EN_USBA | 
> USBA_PULLD_DIS)
>  #define USBA_DISABLE_MASK  USBA_DETACH
> -#endif /* CONFIG_ARCH_AT91 */
> +#endif
>  
>  /* Bitfields in FNUM */
>  #define USBA_MICRO_FRAME_NUM_OFFSET0
> 
> it can be sensible and will all to compile with the COMPILE_TEST directive.

Thanks. Will test tomorrow. And my original patch of depending on
((AVR32 && !OF) || ARCH_AT91), is that correct?
Sorry that I missed ccing you while sending the patch. We should not
always depend on getmaintainer.pl.

regards
sudip
--
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/23] usb-gadget: use per-attribute show and store methods

2015-09-30 Thread Tejun Heo
On Wed, Sep 30, 2015 at 11:43:01AM -0500, Felipe Balbi wrote:
> Seems like there are *ton* of uses of container_of() wrapped within a simple
> macro. What convention are you talking about, again ?

The convention of using inline functions over macros when possible.
We don't do that all the time but that's where we wanna be in general.

> And again, what benefit is an inline function bringing in this specific
> case ? As for a technical reason, we know the macro definition will be
> copied Verbatim into the caller body. GCC might decide to not inline
> those helpers (unlikely, but could).

That's really grasping at straws.  Let's not go there.

For simple stuff like container_of(), a more valid reason would be
"it's shorter and sweeter and AFAICS doesn't have any known downsides
of using macros" but this ultimately is a bike-shedding problem.

You asked where and why we said we prefer inline functions so that's
the answer (aside from individual technical advantages).  It's not an
absolute rule but we're better off if we try to keep things consistent
if possible.  As for this specific case, I don't know.  I might do the
macro too just because it's less typing and I don't really care but at
the same time I'd just switch to inline if somebody points it out.

-- 
tejun
--
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 15/16] usb: gadget: atmel: access the PMC using regmap

2015-09-30 Thread Alexandre Belloni
Hi,

On 30/09/2015 at 11:31:02 -0500, Felipe Balbi wrote :
> On Wed, Sep 30, 2015 at 06:11:08PM +0200, Alexandre Belloni wrote:
> > Use regmap to access the PMC to avoid using at91_pmc_read and
> > at91_pmc_write.
> > 
> > Signed-off-by: Alexandre Belloni 
> 
> can I take this through my tree or does it have any dependences with the rest 
> of
> the series ?
> 

This actually depend on the DT change. I'd say that we can safely assume
that the DT change will land in the next kernel version so you could
take that patch in your tree.

Nicolas, what is your opinion?

-- 
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 15/16] usb: gadget: atmel: access the PMC using regmap

2015-09-30 Thread Alexandre Belloni
On 30/09/2015 at 18:59:17 +0200, Alexandre Belloni wrote :
> Hi,
> 
> On 30/09/2015 at 11:31:02 -0500, Felipe Balbi wrote :
> > On Wed, Sep 30, 2015 at 06:11:08PM +0200, Alexandre Belloni wrote:
> > > Use regmap to access the PMC to avoid using at91_pmc_read and
> > > at91_pmc_write.
> > > 
> > > Signed-off-by: Alexandre Belloni 
> > 
> > can I take this through my tree or does it have any dependences with the 
> > rest of
> > the series ?
> > 
> 
> This actually depend on the DT change. I'd say that we can safely assume
> that the DT change will land in the next kernel version so you could
> take that patch in your tree.
> 
> Nicolas, what is your opinion?
> 

Ok, I'm late to the battle :)

-- 
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 2/3] usb: gadget: at91_udc: mention proper dependency

2015-09-30 Thread Nicolas Ferre
Le 30/09/2015 18:53, Sudip Mukherjee a écrit :
> On Wed, Sep 30, 2015 at 06:34:28PM +0200, Nicolas Ferre wrote:
>> Le 30/09/2015 18:24, Sudip Mukherjee a écrit :
>>> On Wed, Sep 30, 2015 at 11:04:54AM -0500, Felipe Balbi wrote:
 On Wed, Sep 23, 2015 at 09:22:48PM +0530, Sudip Mukherjee wrote:
> On Mon, Sep 21, 2015 at 04:40:57PM +0530, Sudip Mukherjee wrote:
>> On Sun, Sep 20, 2015 at 11:15:28AM -0500, Felipe Balbi wrote:
>>> On Sat, Sep 19, 2015 at 10:42:58PM +0530, Sudip Mukherjee wrote:
 While building allmodconfig on avr32 the build failed with the error:
 "at91_pmc_base" [drivers/usb/gadget/udc/atmel_usba_udc.ko] undefined!

 On checking the code it turned out that if CONFIG_OF is defined then it
 is using at91_pmc_read() which is using at91_pmc_base. And unless
 COMMON_CLK_AT91 is defined we donot have at91_pmc_base. And
 COMMON_CLK_AT91 is available with AT91 architecture.
 Mention the dependency such that this driver builds with avr32 only if
 OF is not enabled.

 Signed-off-by: Sudip Mukherjee 
 ---

 Tested build with at91_dt_defconfig and allmodconfig of avr32. Build 
 log
 at:
 https://travis-ci.org/sudipm-mukherjee/parport/builds/81168845

  drivers/usb/gadget/udc/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/drivers/usb/gadget/udc/Kconfig 
 b/drivers/usb/gadget/udc/Kconfig
 index 9a3a6b0..cdbff54 100644
 --- a/drivers/usb/gadget/udc/Kconfig
 +++ b/drivers/usb/gadget/udc/Kconfig
 @@ -55,7 +55,7 @@ config USB_LPC32XX
  
  config USB_ATMEL_USBA
tristate "Atmel USBA"
 -  depends on AVR32 || ARCH_AT91
 +  depends on ((AVR32 && !OF) || ARCH_AT91)
>>>
>>> any chance you can add || COMPILE_TEST here ? I'd like to make
>>> sure this builds on my end too.
>> With "depends on ((AVR32 && !OF) || ARCH_AT91 || COMPILE_TEST)"
>> normal allmodconfig builiding for x86_64 failed with:
>>
>> drivers/usb/gadget/udc/atmel_usba_udc.c: In function ‘usba_start’:
>> drivers/usb/gadget/udc/atmel_usba_udc.c:1783:25: error: 
>> ‘USBA_ENABLE_MASK’ undeclared (first use in this function)
>>   usba_writel(udc, CTRL, USBA_ENABLE_MASK);
>>  ^
>> drivers/usb/gadget/udc/atmel_usba_udc.c: In function ‘usba_stop’:
>> drivers/usb/gadget/udc/atmel_usba_udc.c:1800:25: error: 
>> ‘USBA_DISABLE_MASK’ undeclared (first use in this function)
>>   usba_writel(udc, CTRL, USBA_DISABLE_MASK);
>>  ^
>>
>> Looks like USBA_DISABLE_MASK and USBA_ENABLE_MASK is defined under
>> #if defined(CONFIG_AVR32). :(
> Can i check anything else here? Like I said with COMPILE_TEST
> allmodconfig on x86_64 is failing.

 then keep it as is, but it would be nice to get that sorted out
 so I can do compile tests on my end too.
>>>
>>> Maybe Nicolas can give some idea. Adding Nicolas Ferre to CC.
>>
>> Hi,
>>
>> I'm thinking about something like this:
>>
>> 8<--
>> --- a/drivers/usb/gadget/udc/atmel_usba_udc.h
>> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
>> @@ -46,10 +46,10 @@
>>  #if defined(CONFIG_AVR32)
>>  #define USBA_ENABLE_MASK   USBA_EN_USBA
>>  #define USBA_DISABLE_MASK  0
>> -#elif defined(CONFIG_ARCH_AT91)
>> +#else
>>  #define USBA_ENABLE_MASK   (USBA_EN_USBA | 
>> USBA_PULLD_DIS)
>>  #define USBA_DISABLE_MASK  USBA_DETACH
>> -#endif /* CONFIG_ARCH_AT91 */
>> +#endif
>>  
>>  /* Bitfields in FNUM */
>>  #define USBA_MICRO_FRAME_NUM_OFFSET0
>>
>> it can be sensible and will all to compile with the COMPILE_TEST directive.
> 
> Thanks. Will test tomorrow. And my original patch of depending on
> ((AVR32 && !OF) || ARCH_AT91), is that correct?

Sounds good to me.

> Sorry that I missed ccing you while sending the patch. We should not
> always depend on getmaintainer.pl.

Well, I'm marked as maintainer for this drivers actually and
get_maintainer.pl shouldn't lie this time...

Bye,
-- 
Nicolas Ferre
--
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