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

2015-01-29 Thread Simon Horman
Hi Shimoda-san,

On Mon, Jan 19, 2015 at 12:53:17PM +0900, Yoshihiro Shimoda wrote:
 This patch adds dma_request_slave_channel_reason() calling to request
 dma slave channels for multiplatform environment.
 
 Signed-off-by: Yoshihiro Shimoda yoshihiro.shimoda...@renesas.com
 ---
  .../devicetree/bindings/usb/renesas_usbhs.txt  |2 ++
  drivers/usb/renesas_usbhs/fifo.c   |   11 ++-
  2 files changed, 12 insertions(+), 1 deletion(-)

I have observed what appears to be a regression caused by this
patch when booting a kernel built using shmobile_defconfig on the koelsch
and lager boards.

I noticed this problem while testing next-20150129.

I have provided boot logs at the end of this email.

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


Koelsch
---

Starting kernel ...

Booting Linux on physical CPU 0x0
Linux version 3.19.0-rc5-00129-gabd2dbf 
(ho...@ayumi.isobedori.kobe.vergenet.net) (gcc version 4.6.3 (GCC) ) #959 SMP 
Thu Jan 29 20:40:07 JST 2015
CPU: ARMv7 Processor [413fc0f2] revision 2 (ARMv7), cr=10c5307d
CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
Machine model: Koelsch
Ignoring memory block 0x2 - 0x24000
debug: ignoring loglevel setting.
Memory policy: Data cache writealloc
On node 0 totalpages: 262144
free_area_init_node: node 0, pgdat c0612a80, node_mem_map eeff9000
  Normal zone: 1520 pages used for memmap
  Normal zone: 0 pages reserved
  Normal zone: 194560 pages, LIFO batch:31
  HighMem zone: 67584 pages, LIFO batch:15
PERCPU: Embedded 7 pages/cpu @eefca000 s7552 r0 d21120 u32768
pcpu-alloc: s7552 r0 d21120 u32768 alloc=8*4096
pcpu-alloc: [0] 0 [0] 1 
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 260624
Kernel command line: ignore_loglevel rw root=/dev/nfs ip=dhcp
PID hash table entries: 4096 (order: 2, 16384 bytes)
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
Memory: 1032964K/1048576K available (4524K kernel code, 264K rwdata, 1128K 
rodata, 268K init, 191K bss, 15612K reserved, 0K cma-reserved, 270336K highmem)
Virtual kernel memory layout:
vector  : 0x - 0x1000   (   4 kB)
fixmap  : 0xffc0 - 0xfff0   (3072 kB)
vmalloc : 0xf000 - 0xff00   ( 240 MB)
lowmem  : 0xc000 - 0xef80   ( 760 MB)
pkmap   : 0xbfe0 - 0xc000   (   2 MB)
  .text : 0xc0008000 - 0xc058e024   (5657 kB)
  .init : 0xc058f000 - 0xc05d2000   ( 268 kB)
  .data : 0xc05d2000 - 0xc06143a0   ( 265 kB)
   .bss : 0xc06143a0 - 0xc064407c   ( 192 kB)
Hierarchical RCU implementation.
RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=2.
RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
NR_IRQS:16 nr_irqs:16 16
Architected cp15 timer(s) running at 10.00MHz (virt).
sched_clock: 56 bits at 10MHz, resolution 100ns, wraps every 3435973836800ns
Switching to timer-based delay loop, resolution 100ns
Console: colour dummy device 80x30
console [tty0] enabled
Calibrating delay loop (skipped), value calculated using timer frequency.. 
20.00 BogoMIPS (lpj=10)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
CPU: Testing write buffer coherency: ok
CPU0: update cpu_capacity 1024
CPU0: thread -1, cpu 0, socket 0, mpidr 8000
Setting 

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

2015-01-29 Thread yoshihiro shimoda
Hi Simon-san,

 -Original Message-
 From: Simon Horman [mailto:ho...@verge.net.au]
 Sent: Thursday, January 29, 2015 9:19 PM
 To: yoshihiro shimoda
 Cc: gre...@linuxfoundation.org; ba...@ti.com; robh...@kernel.org; 
 pawel.m...@arm.com; mark.rutl...@arm.com;
 ijc+devicet...@hellion.org.uk; ga...@codeaurora.org; 
 linux-usb@vger.kernel.org; linux...@vger.kernel.org
 Subject: Re: [PATCH 2/2] usb: renesas_usbhs: add support for requesting DT DMA
 
 Hi Shimoda-san,
 
 On Mon, Jan 19, 2015 at 12:53:17PM +0900, Yoshihiro Shimoda wrote:
  This patch adds dma_request_slave_channel_reason() calling to request
  dma slave channels for multiplatform environment.
 
  Signed-off-by: Yoshihiro Shimoda yoshihiro.shimoda...@renesas.com
  ---
   .../devicetree/bindings/usb/renesas_usbhs.txt  |2 ++
   drivers/usb/renesas_usbhs/fifo.c   |   11 ++-
   2 files changed, 12 insertions(+), 1 deletion(-)
 
 I have observed what appears to be a regression caused by this
 patch when booting a kernel built using shmobile_defconfig on the koelsch
 and lager boards.

Thank you for the point. I should have tested using shmobile_defconfig.
So, I will submit a patch to fix this issue.

Detail:
 - Since the defconfig doesn't enable CONFIG_GENERIC_PHY and 
CONFIG_PHY_RCAR_GEN2,
   the driver's probe failed.
 - Since we don't have dmac for usb at the moment if we use the defconfig,
   dma_request_slave_channel_reason() will fail with ERR_PTR(-ENODEV).
 - But, the current renesas_usbhs driver will keeps ERR_PTR(-ENODEV) in tx_chan 
and rx_chan.
   So, if the driver calls usbhs_dma_quit, the driver calls 
dma_release_channel() with
   wrong argument (ERR_PTR(-ENODEV)).
 - So, I will write a patch to set tx_chan and rx_chan to NULL in the 
usbhsf_dma_init_dt()
   if these values are IS_ERR.

Best regards,
Yoshihiro Shimoda

 I noticed this problem while testing next-20150129.
 
 I have provided boot logs at the end of this email.
 
 
  diff --git a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
 b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
  index b08c903..61b045b 100644
  --- a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
  +++ b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
  @@ -14,6 +14,8 @@ Optional properties:
   function should be enabled
 - phys: phandle + phy specifier pair
 - phy-names: must be usb
  +  - dmas: Must contain a list of references to DMA specifiers.
  +  - dma-names : Must contain a list of DMA names, tx or rx.
 
   Example:
  usbhs: usb@e659 {
  diff --git a/drivers/usb/renesas_usbhs/fifo.c 
  b/drivers/usb/renesas_usbhs/fifo.c
  index 48e31b9..4c086b1 100644
  --- a/drivers/usb/renesas_usbhs/fifo.c
  +++ b/drivers/usb/renesas_usbhs/fifo.c
  @@ -1069,12 +1069,21 @@ static void usbhsf_dma_init_pdev(struct usbhs_fifo 
  *fifo)
  fifo-rx_slave);
   }
 
  +static void usbhsf_dma_init_dt(struct device *dev, struct usbhs_fifo *fifo)
  +{
  +   fifo-tx_chan = dma_request_slave_channel_reason(dev, tx);
  +   fifo-rx_chan = dma_request_slave_channel_reason(dev, rx);
  +}
  +
   static void usbhsf_dma_init(struct usbhs_priv *priv,
  struct usbhs_fifo *fifo)
   {
  struct device *dev = usbhs_priv_to_dev(priv);
 
  -   usbhsf_dma_init_pdev(fifo);
  +   if (dev-of_node)
  +   usbhsf_dma_init_dt(dev, fifo);
  +   else
  +   usbhsf_dma_init_pdev(fifo);
 
  if (fifo-tx_chan || fifo-rx_chan)
  dev_dbg(dev, enable DMAEngine (%s%s%s)\n,
 
 
 Koelsch
 ---
 
 Starting kernel ...
 
 Booting Linux on physical CPU 0x0
 Linux version 3.19.0-rc5-00129-gabd2dbf 
 (ho...@ayumi.isobedori.kobe.vergenet.net) (gcc version 4.6.3 (GCC) ) #959 SMP
 Thu Jan 29 20:40:07 JST 2015
 CPU: ARMv7 Processor [413fc0f2] revision 2 (ARMv7), cr=10c5307d
 CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
 Machine model: Koelsch
 Ignoring memory block 0x2 - 0x24000
 debug: ignoring loglevel setting.
 Memory policy: Data cache writealloc
 On node 0 totalpages: 262144
 free_area_init_node: node 0, pgdat c0612a80, node_mem_map eeff9000
   Normal zone: 1520 pages used for memmap
   Normal zone: 0 pages reserved
   Normal zone: 194560 pages, LIFO batch:31
   HighMem zone: 67584 pages, LIFO batch:15
 PERCPU: Embedded 7 pages/cpu @eefca000 s7552 r0 d21120 u32768
 pcpu-alloc: s7552 r0 d21120 u32768 alloc=8*4096
 pcpu-alloc: [0] 0 [0] 1
 Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 260624
 Kernel command line: ignore_loglevel rw root=/dev/nfs ip=dhcp
 PID hash table entries: 4096 (order: 2, 16384 bytes)
 Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
 Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
 Memory: 1032964K/1048576K available (4524K kernel code, 264K rwdata, 1128K 
 rodata, 268K init, 191K bss, 15612K reserved,
 0K cma-reserved, 270336K highmem)
 Virtual kernel memory

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

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

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

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

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