[PATCH 0/3] dw_dmac: add PCI driver and move dw stuff to its own folder

2012-10-30 Thread Andy Shevchenko
This is split of the dw_dmac to support different platform devices with one
core driver. It uses platform_driver model and weak link to the parent driver.
The pros and cons are still under discussion here:
http://www.spinics.net/lists/kernel/msg1408495.html

Andy Shevchenko (2):
  dma: move dw_dmac driver to an own directory
  MAINTAINERS: add recently created files to dw_dmac section

Heikki Krogerus (1):
  dmaengine: dw_dmac: add PCI part of the driver

 MAINTAINERS |3 +-
 drivers/dma/Kconfig |9 +++
 drivers/dma/Makefile|2 +-
 drivers/dma/dw/Makefile |2 +
 drivers/dma/{ = dw}/dw_dmac.c  |2 +-
 drivers/dma/dw/dw_dmac_pci.c|  133 +++
 drivers/dma/{ = dw}/dw_dmac_regs.h |0
 7 files changed, 147 insertions(+), 4 deletions(-)
 create mode 100644 drivers/dma/dw/Makefile
 rename drivers/dma/{ = dw}/dw_dmac.c (99%)
 create mode 100644 drivers/dma/dw/dw_dmac_pci.c
 rename drivers/dma/{ = dw}/dw_dmac_regs.h (100%)

-- 
1.7.10.4

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


[PATCH 3/3] MAINTAINERS: add recently created files to dw_dmac section

2012-10-30 Thread Andy Shevchenko
The DesignWare DMAC driver is moved to an own directory. The patch updates
MAINTAINERS file accordingly.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 MAINTAINERS |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index a2a3434..edf99d0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6293,8 +6293,7 @@ SYNOPSYS DESIGNWARE DMAC DRIVER
 M: Viresh Kumar viresh.li...@gmail.com
 S: Maintained
 F: include/linux/dw_dmac.h
-F: drivers/dma/dw_dmac_regs.h
-F: drivers/dma/dw_dmac.c
+F: drivers/dma/dw/
 
 TIMEKEEPING, NTP
 M: John Stultz johns...@us.ibm.com
-- 
1.7.10.4

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


[PATCH 2/3] dma: move dw_dmac driver to an own directory

2012-10-30 Thread Andy Shevchenko
The dw_dmac driver contains multiple files. To make a management of them more
convenient move it to an own directory.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Reviewed-by: Felipe Balbi ba...@ti.com
Acked-by: Viresh Kumar viresh.ku...@linaro.org
---
 drivers/dma/Makefile|3 +--
 drivers/dma/dw/Makefile |2 ++
 drivers/dma/{ = dw}/dw_dmac.c  |2 +-
 drivers/dma/{ = dw}/dw_dmac_pci.c  |0
 drivers/dma/{ = dw}/dw_dmac_regs.h |0
 5 files changed, 4 insertions(+), 3 deletions(-)
 create mode 100644 drivers/dma/dw/Makefile
 rename drivers/dma/{ = dw}/dw_dmac.c (99%)
 rename drivers/dma/{ = dw}/dw_dmac_pci.c (100%)
 rename drivers/dma/{ = dw}/dw_dmac_regs.h (100%)

diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index 15eef5f..122a48a 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -11,8 +11,7 @@ obj-$(CONFIG_INTEL_IOP_ADMA) += iop-adma.o
 obj-$(CONFIG_FSL_DMA) += fsldma.o
 obj-$(CONFIG_MPC512X_DMA) += mpc512x_dma.o
 obj-$(CONFIG_MV_XOR) += mv_xor.o
-obj-$(CONFIG_DW_DMAC) += dw_dmac.o
-obj-$(CONFIG_DW_DMAC_PCI) += dw_dmac_pci.o
+obj-$(CONFIG_DW_DMAC) += dw/
 obj-$(CONFIG_AT_HDMAC) += at_hdmac.o
 obj-$(CONFIG_MX3_IPU) += ipu/
 obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o
diff --git a/drivers/dma/dw/Makefile b/drivers/dma/dw/Makefile
new file mode 100644
index 000..2edfb24
--- /dev/null
+++ b/drivers/dma/dw/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_DW_DMAC) += dw_dmac.o
+obj-$(CONFIG_DW_DMAC_PCI) += dw_dmac_pci.o
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw/dw_dmac.c
similarity index 99%
rename from drivers/dma/dw_dmac.c
rename to drivers/dma/dw/dw_dmac.c
index 2c8096d..29aa9d86 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw/dw_dmac.c
@@ -23,8 +23,8 @@
 #include linux/platform_device.h
 #include linux/slab.h
 
+#include ../dmaengine.h
 #include dw_dmac_regs.h
-#include dmaengine.h
 
 /*
  * This supports the Synopsys DesignWare AHB Central DMA Controller,
diff --git a/drivers/dma/dw_dmac_pci.c b/drivers/dma/dw/dw_dmac_pci.c
similarity index 100%
rename from drivers/dma/dw_dmac_pci.c
rename to drivers/dma/dw/dw_dmac_pci.c
diff --git a/drivers/dma/dw_dmac_regs.h b/drivers/dma/dw/dw_dmac_regs.h
similarity index 100%
rename from drivers/dma/dw_dmac_regs.h
rename to drivers/dma/dw/dw_dmac_regs.h
-- 
1.7.10.4

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


[PATCH 1/3] dmaengine: dw_dmac: add PCI part of the driver

2012-10-30 Thread Andy Shevchenko
From: Heikki Krogerus heikki.kroge...@linux.intel.com

This is the PCI part of the DesignWare DMAC driver. The controller is usually
used in the Intel hardware such as Medfield.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/dma/Kconfig   |9 +++
 drivers/dma/Makefile  |1 +
 drivers/dma/dw_dmac_pci.c |  133 +
 3 files changed, 143 insertions(+)
 create mode 100644 drivers/dma/dw_dmac_pci.c

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 6761cc8..ae706ca 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -100,6 +100,15 @@ config DW_DMAC_BIG_ENDIAN_IO
 
  If unsure, use the default setting.
 
+config DW_DMAC_PCI
+   tristate Synopsys DesignWare AHB DMA support (PCI bus)
+   depends on PCI
+   select DW_DMAC
+   help
+ Support the Synopsys DesignWare AHB DMA controller on the platfroms
+ that provide it as a PCI device. For example, Intel Medfield has
+ integrated this GPDMA controller.
+
 config AT_HDMAC
tristate Atmel AHB DMA support
depends on ARCH_AT91
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index 7428fea..15eef5f 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_FSL_DMA) += fsldma.o
 obj-$(CONFIG_MPC512X_DMA) += mpc512x_dma.o
 obj-$(CONFIG_MV_XOR) += mv_xor.o
 obj-$(CONFIG_DW_DMAC) += dw_dmac.o
+obj-$(CONFIG_DW_DMAC_PCI) += dw_dmac_pci.o
 obj-$(CONFIG_AT_HDMAC) += at_hdmac.o
 obj-$(CONFIG_MX3_IPU) += ipu/
 obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o
diff --git a/drivers/dma/dw_dmac_pci.c b/drivers/dma/dw_dmac_pci.c
new file mode 100644
index 000..043a963
--- /dev/null
+++ b/drivers/dma/dw_dmac_pci.c
@@ -0,0 +1,133 @@
+/*
+ * PCI driver for the Synopsys DesignWare DMA Controller
+ *
+ * Copyright (C) 2012 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/module.h
+#include linux/idr.h
+#include linux/pci.h
+#include linux/platform_device.h
+#include linux/dw_dmac.h
+
+static struct dw_dma_platform_data dw_pci_pdata = {
+   .is_private = 1,
+   .chan_allocation_order = CHAN_ALLOCATION_ASCENDING,
+   .chan_priority = CHAN_PRIORITY_ASCENDING,
+};
+
+static DEFINE_IDA(dw_pci_ida);
+
+static int __devinit dw_pci_probe(struct pci_dev *pdev,
+ const struct pci_device_id *pid)
+{
+   struct platform_device *pd;
+   struct resource r[2];
+   struct dw_dma_platform_data *driver = (void *)pid-driver_data;
+   int id, ret;
+
+   id = ida_simple_get(dw_pci_ida, 0, 0, GFP_KERNEL);
+   if (id  0)
+   return id;
+
+   ret = pci_enable_device(pdev);
+   if (ret)
+   goto put_id;
+
+   pci_set_power_state(pdev, PCI_D0);
+   pci_set_master(pdev);
+   pci_try_set_mwi(pdev);
+
+   ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+   if (ret)
+   goto err0;
+
+   ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+   if (ret)
+   goto err0;
+
+   pd = platform_device_alloc(dw_dmac, id);
+   if (!pd) {
+   dev_err(pdev-dev, can't allocate dw_dmac platform device\n);
+   ret = -ENOMEM;
+   goto err0;
+   }
+
+   memset(r, 0, sizeof(r));
+
+   r[0].start = pci_resource_start(pdev, 0);
+   r[0].end = pci_resource_end(pdev, 0);
+   r[0].flags = IORESOURCE_MEM;
+
+   r[1].start = pdev-irq;
+   r[1].flags = IORESOURCE_IRQ;
+
+   ret = platform_device_add_resources(pd, r, ARRAY_SIZE(r));
+   if (ret) {
+   dev_err(pdev-dev, can't add resources to platform device\n);
+   goto err1;
+   }
+
+   ret = platform_device_add_data(pd, driver, sizeof(*driver));
+   if (ret)
+   goto err1;
+
+   dma_set_coherent_mask(pd-dev, pdev-dev.coherent_dma_mask);
+   pd-dev.dma_mask = pdev-dev.dma_mask;
+   pd-dev.dma_parms = pdev-dev.dma_parms;
+   pd-dev.parent = pdev-dev;
+
+   pci_set_drvdata(pdev, pd);
+
+   ret = platform_device_add(pd);
+   if (ret) {
+   dev_err(pdev-dev, platform_device_add failed\n);
+   goto err1;
+   }
+
+   return 0;
+
+err1:
+   platform_device_put(pd);
+err0:
+   pci_disable_device(pdev);
+put_id:
+   ida_simple_remove(dw_pci_ida, id);
+   return ret;
+}
+
+static void __devexit dw_pci_remove(struct pci_dev *pdev)
+{
+   struct platform_device *pd = pci_get_drvdata(pdev);
+
+   platform_device_unregister(pd);
+   ida_simple_remove(dw_pci_ida, pd-id);
+   pci_set_drvdata(pdev, NULL);
+   pci_disable_device(pdev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(dw_pci_id_table

Re: [PATCHv3 5/7] dmaengine: dw_dmac: add PCI part of the driver

2012-10-30 Thread Andy Shevchenko
On Mon, 2012-10-08 at 18:57 +0530, Viresh Kumar wrote: 
 On 8 October 2012 18:16, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
  On Mon, 2012-10-08 at 16:19 +0530, Viresh Kumar wrote:
   First of all it will export IP-block relevant functions to the kernel
   namespace. I think it is not a good idea to pollute kernel more.
 
  So, few routines which are required to be called from probe,
  suspend/resume and exit would be made non-static... This is what you
  wanted to say? Hopefully most of the routines would still be declared
  static in the core file. So IMHO, the simplicity or clarity that new 
  approach
  gives has more advantages than this aspect.
  The probe (core part), remove, shutdown, suspend, and resume will be
  exported. Practically each generic function which will be used in
  drivers outside of core. Why do we need them in the kernel namespace?
 
 And these are generic kernel framework supporting routines, instead of
 routines that expose the hardware. Even then exposing them isn't that bad.
 
 I do agree, we must have as less routines in kernel namespace as possible.
 But not at the price of over complexity of stuff which isn't required.

I didn't see the complexity you are talking about. 

  That's why depends-on should not
  allow you to make core part as module alone...
  I couldn't get the issue completely. What's the problem in this approach?
 
  Why we need to do this if we could avoid it? I see nothing to prevent us
  to build parts as modules, or otherwise, or mixed style.
  In other words one approach provides weak dependency and the other -
  hard dependency between pieces of code.
 
 I agree that there are some parts of your approach which might be having
 few advantages. But it is actually adding more complexity without much
 need of it.

Sorry, still didn't get where it is (complexity) and in what part.

 Logically speaking, we never had two devices for the same
 dma controller.

What do you mean by this? Do we ever have the same IP block on different
buses at the same time? I think it's potentially possible.

 We are adding them just to have pci over platform.. Which
 would mean the system become more and more complex..


 So, during run time...
 - there will be two device-driver binding loops.. Once for pci and then for
   platform

Is this a real problem? We have dozens of the drivers on modern hw, part
of them by the way use proposed approach.

 - In suspend/resume... two devices will get into suspend, instead of one..

True. But it allows to keep a potential to have the same devices to be
attached to the different buses simultaneously.

 - There might be other frameworks in kernel.. which react on struct device
basis... they will get affected too..

I'm wondering if there any that affects us. I think you might know if
there was any example of it (in history?).

 - You have larger image size for pci case. as you compile platform too..

How much? I didn't check this, but I believe it will consume one page at
most.

 Just try to think from this perspective... we dont have two hardware devices
 in the system Ideally speaking there must be a struct device associated
 with a hardware device...

I'm sorry, but I'm still not fully convinced by those arguments. For me
it looks like both approaches have good and bad aspects on the similar
level.

Actually sdhci seems for me as a not good example. In the mmc code they
have already robust architecture (there is host controller, there is
core part, there is card part and so on...) and enough of -ops
structures. We have a simpler driver.

-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv3 5/7] dmaengine: dw_dmac: add PCI part of the driver

2012-10-30 Thread Andy Shevchenko
On Tue, Oct 30, 2012 at 5:19 PM, Viresh Kumar viresh.ku...@linaro.org wrote:
 On 30 October 2012 20:35, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
 On Mon, 2012-10-08 at 18:57 +0530, Viresh Kumar wrote:

 For me i don't agree with your approach. So, its a NACK.
Point taken.

 However if Arnd/Vinod or You can give me some strong points about
 your approach, i can consider it again :)
Fair enough.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] xhci: fix null-pointer dereference when destroying half-built segment rings

2012-11-01 Thread Andy Shevchenko
On Thu, Nov 1, 2012 at 9:47 PM, Julius Werner jwer...@chromium.org wrote:
 xhci_alloc_segments_for_ring() builds a list of xhci_segments and links
 the tail to head at the end (forming a ring). When it bails out for OOM
 reasons half-way through, it tries to destroy its half-built list with
 xhci_free_segments_for_ring(), even though it is not a ring yet. This
 causes a null-pointer dereference upon hitting the last element.

 Furthermore, one of its callers (xhci_ring_alloc()) mistakenly believes
 the output parameters to be valid upon this kind of OOM failure, and
 calls xhci_ring_free() on them. Since the (incomplete) list/ring should
 already be destroyed in that case, this would lead to a use after free.

 This patch fixes those issues by having xhci_alloc_segments_for_ring()
 destroy its half-built, non-circular list manually and destroying the
 invalid struct xhci_ring in xhci_ring_alloc() with a plain kfree().

 Signed-off-by: Julius Werner jwer...@chromium.org
 ---
  drivers/usb/host/xhci-mem.c |9 +++--
  1 files changed, 7 insertions(+), 2 deletions(-)

 diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
 index 487bc08..fb51c70 100644
 --- a/drivers/usb/host/xhci-mem.c
 +++ b/drivers/usb/host/xhci-mem.c
 @@ -205,7 +205,12 @@ static int xhci_alloc_segments_for_ring(struct xhci_hcd 
 *xhci,

 next = xhci_segment_alloc(xhci, cycle_state, flags);
 if (!next) {
 -   xhci_free_segments_for_ring(xhci, *first);
 +   prev = *first;
 +   while (prev) {
 +   next = prev-next;
 +   xhci_segment_free(xhci, prev);
 +   prev = next;
 +   }

Is it just
for (prev = *first; prev; prev = prev-next)
xhci_segment_free(xhci, prev);

?

 return -ENOMEM;
 }
 xhci_link_segments(xhci, prev, next, type);
 @@ -258,7 +263,7 @@ static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd 
 *xhci,
 return ring;

  fail:
 -   xhci_ring_free(xhci, ring);
 +   kfree(ring);
 return NULL;
  }

 --
 1.7.8.6

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



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3] dw_dmac: autoconfigure data_width or get it via platform data

2012-09-25 Thread Andy Shevchenko
Not all of the controllers support the 64 bit data width. Make it configurable
via platform data. The driver will try to get a value from the component
parameters, otherwise it will use the platform data.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
Since v2:
- sometimes memory-to-memory test is failed, that's why we need to choose
  minimum data portion between source and destination limits

 arch/arm/mach-spear13xx/spear13xx.c |2 ++
 arch/avr32/mach-at32ap/at32ap700x.c |2 ++
 drivers/dma/dw_dmac.c   |   47 ++-
 drivers/dma/dw_dmac_regs.h  |7 ++
 include/linux/dw_dmac.h |5 
 5 files changed, 57 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-spear13xx/spear13xx.c 
b/arch/arm/mach-spear13xx/spear13xx.c
index 9491137..5633d69 100644
--- a/arch/arm/mach-spear13xx/spear13xx.c
+++ b/arch/arm/mach-spear13xx/spear13xx.c
@@ -79,6 +79,8 @@ struct dw_dma_platform_data dmac_plat_data = {
.chan_allocation_order = CHAN_ALLOCATION_DESCENDING,
.chan_priority = CHAN_PRIORITY_DESCENDING,
.block_size = 4095U,
+   .nr_masters = 2,
+   .data_width = { 3, 3, 0, 0 },
 };
 
 void __init spear13xx_l2x0_init(void)
diff --git a/arch/avr32/mach-at32ap/at32ap700x.c 
b/arch/avr32/mach-at32ap/at32ap700x.c
index 2c4aefe..b323d8d 100644
--- a/arch/avr32/mach-at32ap/at32ap700x.c
+++ b/arch/avr32/mach-at32ap/at32ap700x.c
@@ -606,6 +606,8 @@ static void __init genclk_init_parent(struct clk *clk)
 static struct dw_dma_platform_data dw_dmac0_data = {
.nr_channels= 3,
.block_size = 4095U,
+   .nr_masters = 2,
+   .data_width = { 2, 2, 0, 0 },
 };
 
 static struct resource dw_dmac0_resource[] = {
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 4af9fad..33c46f0 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -38,12 +38,22 @@
  * which does not support descriptor writeback.
  */
 
+static inline unsigned int dwc_get_dms(struct dw_dma_slave *slave)
+{
+   return slave ? slave-dst_master : 0;
+}
+
+static inline unsigned int dwc_get_sms(struct dw_dma_slave *slave)
+{
+   return slave ? slave-src_master : 1;
+}
+
 #define DWC_DEFAULT_CTLLO(_chan) ({\
struct dw_dma_slave *__slave = (_chan-private);\
struct dw_dma_chan *_dwc = to_dw_dma_chan(_chan);   \
struct dma_slave_config *_sconfig = _dwc-dma_sconfig; \
-   int _dms = __slave ? __slave-dst_master : 0;   \
-   int _sms = __slave ? __slave-src_master : 1;   \
+   int _dms = dwc_get_dms(__slave);\
+   int _sms = dwc_get_sms(__slave);\
u8 _smsize = __slave ? _sconfig-src_maxburst : \
DW_DMA_MSIZE_16;\
u8 _dmsize = __slave ? _sconfig-dst_maxburst : \
@@ -633,6 +643,7 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, 
dma_addr_t src,
size_t len, unsigned long flags)
 {
struct dw_dma_chan  *dwc = to_dw_dma_chan(chan);
+   struct dw_dma_slave *dws = chan-private;
struct dw_desc  *desc;
struct dw_desc  *first;
struct dw_desc  *prev;
@@ -640,6 +651,7 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, 
dma_addr_t src,
size_t  offset;
unsigned intsrc_width;
unsigned intdst_width;
+   unsigned intdata_width;
u32 ctllo;
 
dev_vdbg(chan2dev(chan),
@@ -652,7 +664,11 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t 
dest, dma_addr_t src,
return NULL;
}
 
-   src_width = dst_width = dwc_fast_fls(src | dest | len);
+   data_width = min_t(unsigned int, dwc-dw-data_width[dwc_get_sms(dws)],
+dwc-dw-data_width[dwc_get_dms(dws)]);
+
+   src_width = dst_width = min_t(unsigned int, data_width,
+ dwc_fast_fls(src | dest | len));
 
ctllo = DWC_DEFAULT_CTLLO(chan)
| DWC_CTLL_DST_WIDTH(dst_width)
@@ -722,6 +738,7 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist 
*sgl,
dma_addr_t  reg;
unsigned intreg_width;
unsigned intmem_width;
+   unsigned intdata_width;
unsigned inti;
struct scatterlist  *sg;
size_t  total_len = 0;
@@ -745,6 +762,8 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist 
*sgl,
ctllo |= sconfig-device_fc ? DWC_CTLL_FC(DW_DMA_FC_P_M2P) :
DWC_CTLL_FC(DW_DMA_FC_D_M2P);
 
+   data_width = dwc-dw-data_width[dwc_get_sms(dws)];
+
for_each_sg(sgl

[PATCHv1 0/6] dw_dmac: split the driver and introduce PCI part

2012-09-25 Thread Andy Shevchenko
This patchset is dedicated to support different platform devices via the same
core driver. In our case the dw_dmac could be used as a PCI device, regular
embedded device or something else. This split allows to support the controller
connected to any bus by adding a little piece of code without duplicating a
core driver functionality.

Andy Shevchenko (2):
  MAINTAINERS: fix indentation for Viresh Kumar
  MAINTAINERS: add recently created files to dw_dmac section

Heikki Krogerus (4):
  dmaengine: dw_dmac: Remove clk API dependency
  dmaengine: dw_dmac: add driver for Atmel AT32
  dmaengine: dw_dmac: Add PCI part of the driver
  avr32: at32ap700x: rename DMA controller

 MAINTAINERS |   19 +++--
 arch/avr32/mach-at32ap/at32ap700x.c |   20 ++---
 drivers/dma/Kconfig |   19 -
 drivers/dma/Makefile|2 +
 drivers/dma/dw_dmac.c   |   41 ++
 drivers/dma/dw_dmac_at32.c  |  151 +++
 drivers/dma/dw_dmac_pci.c   |  130 ++
 drivers/dma/dw_dmac_regs.h  |1 -
 8 files changed, 327 insertions(+), 56 deletions(-)
 create mode 100644 drivers/dma/dw_dmac_at32.c
 create mode 100644 drivers/dma/dw_dmac_pci.c

-- 
1.7.10.4

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


[PATCHv1 3/6] dmaengine: dw_dmac: Add PCI part of the driver

2012-09-25 Thread Andy Shevchenko
From: Heikki Krogerus heikki.kroge...@linux.intel.com

This is the PCI part of the DesignWare DMAC driver. The controller is usually
used in the Intel hardware such as Medfield.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/dma/Kconfig|9 +++
 drivers/dma/Makefile   |1 +
 drivers/dma/dw_dmac_at32.c |1 +
 drivers/dma/dw_dmac_pci.c  |  130 
 4 files changed, 141 insertions(+)
 create mode 100644 drivers/dma/dw_dmac_pci.c

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index e47cc90..3850f8d 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -98,6 +98,15 @@ config DW_DMAC_AT32
  Support the Synopsys DesignWare AHB DMA controller in the chips
  such as the Atmel AT32ap7000.
 
+config DW_DMAC_PCI
+   tristate Synopsys DesignWare AHB DMA support (PCI bus)
+   depends on PCI
+   select DW_DMAC
+   help
+ Support the Synopsys DesignWare AHB DMA controller on the platfroms
+ that provide it as a PCI device. For example, Intel Medfield has
+ integrated this GPDMA controller.
+
 config AT_HDMAC
tristate Atmel AHB DMA support
depends on ARCH_AT91
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index d76020b..ae660ed 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_MPC512X_DMA) += mpc512x_dma.o
 obj-$(CONFIG_MV_XOR) += mv_xor.o
 obj-$(CONFIG_DW_DMAC) += dw_dmac.o
 obj-$(CONFIG_DW_DMAC_AT32) += dw_dmac_at32.o
+obj-$(CONFIG_DW_DMAC_PCI) += dw_dmac_pci.o
 obj-$(CONFIG_AT_HDMAC) += at_hdmac.o
 obj-$(CONFIG_MX3_IPU) += ipu/
 obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o
diff --git a/drivers/dma/dw_dmac_at32.c b/drivers/dma/dw_dmac_at32.c
index 7bc7ac4..5c9180e 100644
--- a/drivers/dma/dw_dmac_at32.c
+++ b/drivers/dma/dw_dmac_at32.c
@@ -12,6 +12,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+
 #include linux/module.h
 #include linux/platform_device.h
 #include linux/slab.h
diff --git a/drivers/dma/dw_dmac_pci.c b/drivers/dma/dw_dmac_pci.c
new file mode 100644
index 000..7490894
--- /dev/null
+++ b/drivers/dma/dw_dmac_pci.c
@@ -0,0 +1,130 @@
+/*
+ * PCI driver for the Synopsys DesignWare DMA Controller
+ *
+ * Copyright (C) 2012 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/module.h
+#include linux/pci.h
+#include linux/platform_device.h
+#include linux/dw_dmac.h
+
+#define DW_DRIVER_NAME dw_dmac_pci
+
+#define DRIVER(_is_private, _chan_order, _chan_pri)\
+   ((kernel_ulong_t)(struct dw_dma_platform_data) {   \
+   .is_private = (_is_private),\
+   .chan_allocation_order = (_chan_order), \
+   .chan_priority = (_chan_pri),   \
+   })
+
+static int __devinit dw_pci_probe(struct pci_dev *pdev,
+ const struct pci_device_id *id)
+{
+   struct platform_device  *pd;
+   struct resource r[2];
+   struct dw_dma_platform_data *driver = (void *)id-driver_data;
+   static int  instance;
+   int ret;
+
+   ret = pci_enable_device(pdev);
+   if (ret)
+   return ret;
+
+   pci_set_power_state(pdev, PCI_D0);
+   pci_set_master(pdev);
+   pci_try_set_mwi(pdev);
+
+   ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+   if (ret)
+   goto err0;
+
+   ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+   if (ret)
+   goto err0;
+
+   pd = platform_device_alloc(dw_dmac, instance);
+   if (!pd) {
+   dev_err(pdev-dev, can't allocate dw_dmac platform device\n);
+   ret = -ENOMEM;
+   goto err0;
+   }
+
+   memset(r, 0, sizeof(r));
+
+   r[0].start  = pci_resource_start(pdev, 0);
+   r[0].end= pci_resource_end(pdev, 0);
+   r[0].flags  = IORESOURCE_MEM;
+
+   r[1].start  = pdev-irq;
+   r[1].flags  = IORESOURCE_IRQ;
+
+   ret = platform_device_add_resources(pd, r, ARRAY_SIZE(r));
+   if (ret) {
+   dev_err(pdev-dev, can't add resources to platform device\n);
+   goto err1;
+   }
+
+   ret = platform_device_add_data(pd, driver, sizeof(*driver));
+   if (ret)
+   goto err1;
+
+   dma_set_coherent_mask(pd-dev, pdev-dev.coherent_dma_mask);
+   pd-dev.dma_mask = pdev-dev.dma_mask;
+   pd-dev.dma_parms = pdev-dev.dma_parms;
+   pd-dev.parent = pdev-dev;
+
+   pci_set_drvdata(pdev, pd);
+
+   ret

[PATCHv1 2/6] dmaengine: dw_dmac: add driver for Atmel AT32

2012-09-25 Thread Andy Shevchenko
From: Heikki Krogerus heikki.kroge...@linux.intel.com

This driver should be usable on all platforms that depend on clk API.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/dma/Kconfig|9 +++
 drivers/dma/Makefile   |1 +
 drivers/dma/dw_dmac.c  |   23 +--
 drivers/dma/dw_dmac_at32.c |  150 
 4 files changed, 162 insertions(+), 21 deletions(-)
 create mode 100644 drivers/dma/dw_dmac_at32.c

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index df32537..e47cc90 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -89,6 +89,15 @@ config DW_DMAC
  Support the Synopsys DesignWare AHB DMA controller.  This
  can be integrated in chips such as the Atmel AT32ap7000.
 
+config DW_DMAC_AT32
+   tristate Synopsys DesignWare AHB DMA support for Atmel
+   depends on HAVE_CLK
+   select DW_DMAC
+   default y if CPU_AT32AP7000
+   help
+ Support the Synopsys DesignWare AHB DMA controller in the chips
+ such as the Atmel AT32ap7000.
+
 config AT_HDMAC
tristate Atmel AHB DMA support
depends on ARCH_AT91
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index 7428fea..d76020b 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_FSL_DMA) += fsldma.o
 obj-$(CONFIG_MPC512X_DMA) += mpc512x_dma.o
 obj-$(CONFIG_MV_XOR) += mv_xor.o
 obj-$(CONFIG_DW_DMAC) += dw_dmac.o
+obj-$(CONFIG_DW_DMAC_AT32) += dw_dmac_at32.o
 obj-$(CONFIG_AT_HDMAC) += at_hdmac.o
 obj-$(CONFIG_MX3_IPU) += ipu/
 obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index d9344a7..9c8a500 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -18,7 +18,6 @@
 #include linux/init.h
 #include linux/interrupt.h
 #include linux/io.h
-#include linux/of.h
 #include linux/mm.h
 #include linux/module.h
 #include linux/platform_device.h
@@ -1681,35 +1680,17 @@ static const struct dev_pm_ops dw_dev_pm_ops = {
.poweroff_noirq = dw_suspend_noirq,
 };
 
-#ifdef CONFIG_OF
-static const struct of_device_id dw_dma_id_table[] = {
-   { .compatible = snps,dma-spear1340 },
-   {}
-};
-MODULE_DEVICE_TABLE(of, dw_dma_id_table);
-#endif
-
 static struct platform_driver dw_driver = {
+   .probe  = dw_probe,
.remove = __devexit_p(dw_remove),
.shutdown   = dw_shutdown,
.driver = {
.name   = dw_dmac,
.pm = dw_dev_pm_ops,
-   .of_match_table = of_match_ptr(dw_dma_id_table),
},
 };
 
-static int __init dw_init(void)
-{
-   return platform_driver_probe(dw_driver, dw_probe);
-}
-subsys_initcall(dw_init);
-
-static void __exit dw_exit(void)
-{
-   platform_driver_unregister(dw_driver);
-}
-module_exit(dw_exit);
+module_platform_driver(dw_driver);
 
 MODULE_LICENSE(GPL v2);
 MODULE_DESCRIPTION(Synopsys DesignWare DMA Controller driver);
diff --git a/drivers/dma/dw_dmac_at32.c b/drivers/dma/dw_dmac_at32.c
new file mode 100644
index 000..7bc7ac4
--- /dev/null
+++ b/drivers/dma/dw_dmac_at32.c
@@ -0,0 +1,150 @@
+/*
+ * Driver for the Synopsys DesignWare DMA Controller
+ *
+ * The driver is based on the excerpts from the original dw_dmac.c. That's why
+ * the same copyright holders are mentioned here as well.
+ *
+ * Copyright (C) 2007-2008 Atmel Corporation
+ * Copyright (C) 2010-2011 ST Microelectronics
+ * Copyright (C) 2012 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/slab.h
+#include linux/clk.h
+#include linux/of.h
+#include linux/dw_dmac.h
+
+struct dw_at32 {
+   struct platform_device  *pdev;
+   struct clk  *clk;
+};
+
+static int __init dw_at32_probe(struct platform_device *pdev)
+{
+   struct dw_at32  *at32;
+   struct platform_device  *pd;
+   struct dw_dma_platform_data *pdata = pdev-dev.platform_data;
+   static int  instance;
+   int ret;
+
+   at32 = devm_kzalloc(pdev-dev, sizeof(*at32), GFP_KERNEL);
+   if (!at32) {
+   dev_err(pdev-dev, can't allocate memory\n);
+   return -ENOMEM;
+   }
+
+   pd = platform_device_alloc(dw_dmac, instance);
+   if (!pd) {
+   dev_err(pdev-dev, can't allocate dw_dmac platform device\n);
+   return -ENOMEM;
+   }
+
+   platform_set_drvdata(pdev, at32);
+
+   pd-dev.parent = pdev-dev;
+   at32-pdev = pd;
+
+   at32-clk = devm_clk_get(pdev-dev, hclk);
+   if (IS_ERR(at32-clk)) {
+   dev_err(pdev-dev, failed to get clock\n

[PATCHv1 5/6] MAINTAINERS: fix indentation for Viresh Kumar

2012-09-25 Thread Andy Shevchenko
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Cc: Viresh Kumar viresh.li...@gmail.com
---
 MAINTAINERS |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 8fa0255..479a655 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -572,7 +572,7 @@ F:  drivers/net/appletalk/
 F: net/appletalk/
 
 ARASAN COMPACT FLASH PATA CONTROLLER
-M: Viresh Kumar viresh.li...@gmail.com
+M: Viresh Kumar viresh.li...@gmail.com
 L: linux-...@vger.kernel.org
 S: Maintained
 F: include/linux/pata_arasan_cf_data.h
@@ -6006,7 +6006,7 @@ S:Maintained
 F: drivers/tty/serial
 
 SYNOPSYS DESIGNWARE DMAC DRIVER
-M: Viresh Kumar viresh.li...@gmail.com
+M: Viresh Kumar viresh.li...@gmail.com
 S: Maintained
 F: include/linux/dw_dmac.h
 F: drivers/dma/dw_dmac_regs.h
@@ -6154,7 +6154,7 @@ S:Maintained
 F: drivers/mmc/host/sdhci-s3c.c
 
 SECURE DIGITAL HOST CONTROLLER INTERFACE (SDHCI) ST SPEAR DRIVER
-M: Viresh Kumar viresh.li...@gmail.com
+M: Viresh Kumar viresh.li...@gmail.com
 L: spear-de...@list.st.com
 L: linux-...@vger.kernel.org
 S: Maintained
@@ -6524,7 +6524,7 @@ S:Maintained
 F: include/linux/compiler.h
 
 SPEAR PLATFORM SUPPORT
-M: Viresh Kumar viresh.li...@gmail.com
+M: Viresh Kumar viresh.li...@gmail.com
 M: Shiraz Hashim shiraz.has...@st.com
 L: spear-de...@list.st.com
 L: linux-arm-ker...@lists.infradead.org (moderated for non-subscribers)
@@ -6533,7 +6533,7 @@ S:Maintained
 F: arch/arm/plat-spear/
 
 SPEAR13XX MACHINE SUPPORT
-M: Viresh Kumar viresh.li...@gmail.com
+M: Viresh Kumar viresh.li...@gmail.com
 M: Shiraz Hashim shiraz.has...@st.com
 L: spear-de...@list.st.com
 L: linux-arm-ker...@lists.infradead.org (moderated for non-subscribers)
@@ -6542,7 +6542,7 @@ S:Maintained
 F: arch/arm/mach-spear13xx/
 
 SPEAR3XX MACHINE SUPPORT
-M: Viresh Kumar viresh.li...@gmail.com
+M: Viresh Kumar viresh.li...@gmail.com
 M: Shiraz Hashim shiraz.has...@st.com
 L: spear-de...@list.st.com
 L: linux-arm-ker...@lists.infradead.org (moderated for non-subscribers)
@@ -6553,7 +6553,7 @@ F:arch/arm/mach-spear3xx/
 SPEAR6XX MACHINE SUPPORT
 M: Rajeev Kumar rajeev-dlh.ku...@st.com
 M: Shiraz Hashim shiraz.has...@st.com
-M: Viresh Kumar viresh.li...@gmail.com
+M: Viresh Kumar viresh.li...@gmail.com
 L: spear-de...@list.st.com
 L: linux-arm-ker...@lists.infradead.org (moderated for non-subscribers)
 W: http://www.st.com/spear
@@ -6561,7 +6561,7 @@ S:Maintained
 F: arch/arm/mach-spear6xx/
 
 SPEAR CLOCK FRAMEWORK SUPPORT
-M: Viresh Kumar viresh.li...@gmail.com
+M: Viresh Kumar viresh.li...@gmail.com
 L: spear-de...@list.st.com
 L: linux-arm-ker...@lists.infradead.org (moderated for non-subscribers)
 W: http://www.st.com/spear
-- 
1.7.10.4

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


[PATCHv1 6/6] MAINTAINERS: add recently created files to dw_dmac section

2012-09-25 Thread Andy Shevchenko
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 MAINTAINERS |3 +++
 1 file changed, 3 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 479a655..1a169f6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6007,10 +6007,13 @@ F:  drivers/tty/serial
 
 SYNOPSYS DESIGNWARE DMAC DRIVER
 M: Viresh Kumar viresh.li...@gmail.com
+M: Andy Shevchenko andriy.shevche...@linux.intel.com
 S: Maintained
 F: include/linux/dw_dmac.h
 F: drivers/dma/dw_dmac_regs.h
 F: drivers/dma/dw_dmac.c
+F: drivers/dma/dw_dmac_at32.c
+F: drivers/dma/dw_dmac_pci.c
 
 TIMEKEEPING, NTP
 M: John Stultz johns...@us.ibm.com
-- 
1.7.10.4

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


[PATCHv1 4/6] avr32: at32ap700x: rename DMA controller

2012-09-25 Thread Andy Shevchenko
From: Heikki Krogerus heikki.kroge...@linux.intel.com

There are no functional changes.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 arch/avr32/mach-at32ap/at32ap700x.c |   20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/avr32/mach-at32ap/at32ap700x.c 
b/arch/avr32/mach-at32ap/at32ap700x.c
index b323d8d..8ec75b0 100644
--- a/arch/avr32/mach-at32ap/at32ap700x.c
+++ b/arch/avr32/mach-at32ap/at32ap700x.c
@@ -603,19 +603,19 @@ static void __init genclk_init_parent(struct clk *clk)
clk-parent = parent;
 }
 
-static struct dw_dma_platform_data dw_dmac0_data = {
+static struct dw_dma_platform_data at32_dmac0_data = {
.nr_channels= 3,
.block_size = 4095U,
.nr_masters = 2,
.data_width = { 2, 2, 0, 0 },
 };
 
-static struct resource dw_dmac0_resource[] = {
+static struct resource at32_dmac0_resource[] = {
PBMEM(0xff20),
IRQ(2),
 };
-DEFINE_DEV_DATA(dw_dmac, 0);
-DEV_CLK(hclk, dw_dmac0, hsb, 10);
+DEFINE_DEV_DATA(at32_dmac, 0);
+DEV_CLK(hclk, at32_dmac0, hsb, 10);
 
 /* 
  *  System peripherals
@@ -831,7 +831,7 @@ static int __init system_device_init(void)
platform_device_register(at32_eic0_device);
platform_device_register(smc0_device);
platform_device_register(pdc_device);
-   platform_device_register(dw_dmac0_device);
+   platform_device_register(at32_dmac0_device);
 
platform_device_register(at32_tcb0_device);
platform_device_register(at32_tcb1_device);
@@ -1353,7 +1353,7 @@ at32_add_device_mci(unsigned int id, struct 
mci_platform_data *data)
if (!slave)
goto fail;
 
-   slave-sdata.dma_dev = dw_dmac0_device.dev;
+   slave-sdata.dma_dev = at32_dmac0_device.dev;
slave-sdata.cfg_hi = (DWC_CFGH_SRC_PER(0)
| DWC_CFGH_DST_PER(1));
slave-sdata.cfg_lo = ~(DWC_CFGL_HS_DST_POL
@@ -2047,7 +2047,7 @@ at32_add_device_ac97c(unsigned int id, struct 
ac97c_platform_data *data,
 
/* Check if DMA slave interface for capture should be configured. */
if (flags  AC97C_CAPTURE) {
-   rx_dws-dma_dev = dw_dmac0_device.dev;
+   rx_dws-dma_dev = at32_dmac0_device.dev;
rx_dws-cfg_hi = DWC_CFGH_SRC_PER(3);
rx_dws-cfg_lo = ~(DWC_CFGL_HS_DST_POL | DWC_CFGL_HS_SRC_POL);
rx_dws-src_master = 0;
@@ -2056,7 +2056,7 @@ at32_add_device_ac97c(unsigned int id, struct 
ac97c_platform_data *data,
 
/* Check if DMA slave interface for playback should be configured. */
if (flags  AC97C_PLAYBACK) {
-   tx_dws-dma_dev = dw_dmac0_device.dev;
+   tx_dws-dma_dev = at32_dmac0_device.dev;
tx_dws-cfg_hi = DWC_CFGH_DST_PER(4);
tx_dws-cfg_lo = ~(DWC_CFGL_HS_DST_POL | DWC_CFGL_HS_SRC_POL);
tx_dws-src_master = 0;
@@ -2129,7 +2129,7 @@ at32_add_device_abdac(unsigned int id, struct 
atmel_abdac_pdata *data)
 
dws = data-dws;
 
-   dws-dma_dev = dw_dmac0_device.dev;
+   dws-dma_dev = at32_dmac0_device.dev;
dws-cfg_hi = DWC_CFGH_DST_PER(2);
dws-cfg_lo = ~(DWC_CFGL_HS_DST_POL | DWC_CFGL_HS_SRC_POL);
dws-src_master = 0;
@@ -2219,7 +2219,7 @@ static __initdata struct clk *init_clocks[] = {
smc0_mck,
pdc_hclk,
pdc_pclk,
-   dw_dmac0_hclk,
+   at32_dmac0_hclk,
pico_clk,
pio0_mck,
pio1_mck,
-- 
1.7.10.4

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


[PATCHv1 1/6] dmaengine: dw_dmac: Remove clk API dependency

2012-09-25 Thread Andy Shevchenko
From: Heikki Krogerus heikki.kroge...@linux.intel.com

Not all platforms support clk API.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/dma/Kconfig|1 -
 drivers/dma/dw_dmac.c  |   18 +++---
 drivers/dma/dw_dmac_regs.h |1 -
 3 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 677cd6e..df32537 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -83,7 +83,6 @@ config INTEL_IOP_ADMA
 
 config DW_DMAC
tristate Synopsys DesignWare AHB DMA support
-   depends on HAVE_CLK
select DMA_ENGINE
default y if CPU_AT32AP7000
help
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 9316d03..d9344a7 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -1,9 +1,9 @@
 /*
- * Driver for the Synopsys DesignWare DMA Controller (aka DMACA on
- * AVR32 systems.)
+ * Core driver for the Synopsys DesignWare DMA Controller
  *
  * Copyright (C) 2007-2008 Atmel Corporation
  * Copyright (C) 2010-2011 ST Microelectronics
+ * Copyright (C) 2012 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -12,7 +12,6 @@
 #define VERBOSE_DEBUG
 #define DEBUG
 #include linux/bitops.h
-#include linux/clk.h
 #include linux/delay.h
 #include linux/dmaengine.h
 #include linux/dma-mapping.h
@@ -224,7 +223,6 @@ static inline void dwc_dump_chan_regs(struct dw_dma_chan 
*dwc)
channel_readl(dwc, CTL_LO));
 }
 
-
 static inline void dwc_chan_disable(struct dw_dma *dw, struct dw_dma_chan *dwc)
 {
channel_clear_bit(dw, CH_EN, dwc-mask);
@@ -1508,11 +1506,6 @@ static int __devinit dw_probe(struct platform_device 
*pdev)
if (!dw)
return -ENOMEM;
 
-   dw-clk = devm_clk_get(pdev-dev, hclk);
-   if (IS_ERR(dw-clk))
-   return PTR_ERR(dw-clk);
-   clk_prepare_enable(dw-clk);
-
dw-regs = regs;
 
/* get hardware configuration parameters */
@@ -1657,19 +1650,14 @@ static int __devexit dw_remove(struct platform_device 
*pdev)
 
 static void dw_shutdown(struct platform_device *pdev)
 {
-   struct dw_dma   *dw = platform_get_drvdata(pdev);
-
dw_dma_off(platform_get_drvdata(pdev));
-   clk_disable_unprepare(dw-clk);
 }
 
 static int dw_suspend_noirq(struct device *dev)
 {
struct platform_device *pdev = to_platform_device(dev);
-   struct dw_dma   *dw = platform_get_drvdata(pdev);
 
dw_dma_off(platform_get_drvdata(pdev));
-   clk_disable_unprepare(dw-clk);
 
return 0;
 }
@@ -1679,8 +1667,8 @@ static int dw_resume_noirq(struct device *dev)
struct platform_device *pdev = to_platform_device(dev);
struct dw_dma   *dw = platform_get_drvdata(pdev);
 
-   clk_prepare_enable(dw-clk);
dma_writel(dw, CFG, DW_CFG_DMA_EN);
+
return 0;
 }
 
diff --git a/drivers/dma/dw_dmac_regs.h b/drivers/dma/dw_dmac_regs.h
index ff39fa6..50e0b63 100644
--- a/drivers/dma/dw_dmac_regs.h
+++ b/drivers/dma/dw_dmac_regs.h
@@ -229,7 +229,6 @@ struct dw_dma {
struct dma_device   dma;
void __iomem*regs;
struct tasklet_struct   tasklet;
-   struct clk  *clk;
 
u8  all_chan_mask;
 
-- 
1.7.10.4

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


Re: [PATCHv1 6/6] MAINTAINERS: add recently created files to dw_dmac section

2012-09-25 Thread Andy Shevchenko
On Tue, 2012-09-25 at 06:19 -0700, Joe Perches wrote: 
 On Tue, 2012-09-25 at 15:13 +0300, Andy Shevchenko wrote:
  Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
 
 You also added yourself as a maintainer.
 Congrats/sympathies, etc...
Actually I prefer to be just a supporter, because I introduce few
additional files. But if I understood correctly, there is no way to
distinguish person statuses in one section.

  diff --git a/MAINTAINERS b/MAINTAINERS
 []
  @@ -6007,10 +6007,13 @@ F:  drivers/tty/serial
   
   SYNOPSYS DESIGNWARE DMAC DRIVER
   M: Viresh Kumar viresh.li...@gmail.com
  +M: Andy Shevchenko andriy.shevche...@linux.intel.com
   S: Maintained
   F: include/linux/dw_dmac.h
   F: drivers/dma/dw_dmac_regs.h
   F: drivers/dma/dw_dmac.c
  +F: drivers/dma/dw_dmac_at32.c
  +F: drivers/dma/dw_dmac_pci.c
 
 Perhaps these F: lines instead
 
 F:include/linux/dw_dmac.h
 F:drivers/dma/dw_dmac*
Might be. There is another idea to move them under drivers/dma/dw/
folder. So, Viresh, what do you think is better?

-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv1 6/6] MAINTAINERS: add recently created files to dw_dmac section

2012-09-26 Thread Andy Shevchenko
On Tue, 2012-09-25 at 09:57 -0700, Joe Perches wrote: 
 On Tue, 2012-09-25 at 16:37 +0300, Andy Shevchenko wrote:
  On Tue, 2012-09-25 at 06:19 -0700, Joe Perches wrote: 
   You also added yourself as a maintainer.
   Congrats/sympathies, etc...
  Actually I prefer to be just a supporter, because I introduce few
  additional files. But if I understood correctly, there is no way to
  distinguish person statuses in one section.

 True, the status refers to the section, not the person.

 Supported is a nominally higher level of stewardship
 than maintainer.  Supported is supposed to mean you get
 paid to look after the code.
Ah, thanks for explanation. Apparently I misunderstood the meaning of
that status. So, I meant one level more, than just a contributor.

 I think of these section blocks as one of the ways to
 get the appropriate people to look at patches and bug
 reports.
Okay, that what I was thinking to fit myself into.


-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv1 2/6] dmaengine: dw_dmac: add driver for Atmel AT32

2012-09-26 Thread Andy Shevchenko
On Wed, 2012-09-26 at 09:20 +0530, viresh kumar wrote: 
 On Tue, Sep 25, 2012 at 5:43 PM, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
  From: Heikki Krogerus heikki.kroge...@linux.intel.com
 
  This driver should be usable on all platforms that depend on clk API.
 
 This is not what you mentioned in subject :(

 
  Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
  Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
  ---
   drivers/dma/Kconfig|9 +++
   drivers/dma/Makefile   |1 +
   drivers/dma/dw_dmac.c  |   23 +--
   drivers/dma/dw_dmac_at32.c |  150 
  
 
 I don't agree with the naming used here. There is nothing AT32
 specific here. It is actively used
 by SPEAr. It should be named dw_dmac_platform.c or *pltfm.c

This separate driver makes no sense in case it is built properly without
CLK framework. Let me check this and leave comments at patch 1/6.

 
   4 files changed, 162 insertions(+), 21 deletions(-)
   create mode 100644 drivers/dma/dw_dmac_at32.c
 
  diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
  index df32537..e47cc90 100644
  --- a/drivers/dma/Kconfig
  +++ b/drivers/dma/Kconfig
  @@ -89,6 +89,15 @@ config DW_DMAC
Support the Synopsys DesignWare AHB DMA controller.  This
can be integrated in chips such as the Atmel AT32ap7000.
 
  +config DW_DMAC_AT32
  +   tristate Synopsys DesignWare AHB DMA support for Atmel
 
 :(
 
  +   depends on HAVE_CLK
 
 Even this is not a must for all users of platform driver. So can leave this.
 
  +   select DW_DMAC
  +   default y if CPU_AT32AP7000
  +   help
  + Support the Synopsys DesignWare AHB DMA controller in the chips
  + such as the Atmel AT32ap7000.
  +
   config AT_HDMAC
  tristate Atmel AHB DMA support
  depends on ARCH_AT91
 
  diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
  index d9344a7..9c8a500 100644
  --- a/drivers/dma/dw_dmac.c
  +++ b/drivers/dma/dw_dmac.c
  @@ -18,7 +18,6 @@
   #include linux/init.h
   #include linux/interrupt.h
   #include linux/io.h
  -#include linux/of.h
   #include linux/mm.h
   #include linux/module.h
   #include linux/platform_device.h
  @@ -1681,35 +1680,17 @@ static const struct dev_pm_ops dw_dev_pm_ops = {
  .poweroff_noirq = dw_suspend_noirq,
   };
 
  -#ifdef CONFIG_OF
  -static const struct of_device_id dw_dma_id_table[] = {
  -   { .compatible = snps,dma-spear1340 },
  -   {}
  -};
  -MODULE_DEVICE_TABLE(of, dw_dma_id_table);
  -#endif
  -
   static struct platform_driver dw_driver = {
  +   .probe  = dw_probe,
  .remove = __devexit_p(dw_remove),
  .shutdown   = dw_shutdown,
  .driver = {
  .name   = dw_dmac,
  .pm = dw_dev_pm_ops,
  -   .of_match_table = of_match_ptr(dw_dma_id_table),
  },
   };
 
  -static int __init dw_init(void)
  -{
  -   return platform_driver_probe(dw_driver, dw_probe);
  -}
  -subsys_initcall(dw_init);
  -
  -static void __exit dw_exit(void)
  -{
  -   platform_driver_unregister(dw_driver);
  -}
  -module_exit(dw_exit);
  +module_platform_driver(dw_driver);
 
 Shouldn't this be a separate patch?
 
 
   MODULE_LICENSE(GPL v2);
   MODULE_DESCRIPTION(Synopsys DesignWare DMA Controller driver);
  diff --git a/drivers/dma/dw_dmac_at32.c b/drivers/dma/dw_dmac_at32.c
  new file mode 100644
  index 000..7bc7ac4
  --- /dev/null
  +++ b/drivers/dma/dw_dmac_at32.c
  @@ -0,0 +1,150 @@
  +/*
  + * Driver for the Synopsys DesignWare DMA Controller
 
 How is this file different from dw_dmac.c?
 
  + *
  + * The driver is based on the excerpts from the original dw_dmac.c. That's 
  why
  + * the same copyright holders are mentioned here as well.
  + *
  + * Copyright (C) 2007-2008 Atmel Corporation
  + * Copyright (C) 2010-2011 ST Microelectronics
  + * Copyright (C) 2012 Intel Corporation
  + *
  + * This program is free software; you can redistribute it and/or modify
  + * it under the terms of the GNU General Public License version 2 as
  + * published by the Free Software Foundation.
  + */
  +#include linux/module.h
  +#include linux/platform_device.h
  +#include linux/slab.h
  +#include linux/clk.h
  +#include linux/of.h
  +#include linux/dw_dmac.h
  +
  +struct dw_at32 {
  +   struct platform_device  *pdev;
  +   struct clk  *clk;
  +};
  +
  +static int __init dw_at32_probe(struct platform_device *pdev)
  +{
  +   struct dw_at32  *at32;
  +   struct platform_device  *pd;
  +   struct dw_dma_platform_data *pdata = pdev-dev.platform_data;
  +   static int  instance;
  +   int ret;
  +
  +   at32 = devm_kzalloc(pdev-dev, sizeof(*at32), GFP_KERNEL);
  +   if (!at32) {
  +   dev_err(pdev-dev, can't allocate memory\n

Re: [PATCHv1 2/6] dmaengine: dw_dmac: add driver for Atmel AT32

2012-09-26 Thread Andy Shevchenko
On Wed, Sep 26, 2012 at 9:51 AM, viresh kumar viresh.ku...@linaro.org wrote:
 On Wed, Sep 26, 2012 at 12:17 PM, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:

 This separate driver makes no sense in case it is built properly without
 CLK framework. Let me check this and leave comments at patch 1/6.

 Following is the commit that introduced this change :)
Thanks for pointing to it


 commit 93abe8e4b13ae9a0428ce940a8a03ac72a7626f1
 Author: Viresh Kumar viresh.ku...@st.com
 Date:   Mon Jul 30 14:39:27 2012 -0700
A-ha, this explains: Heikki's patches are stamped as follows

commit 7c33a7ec5f1f68c1ab06eee7ff7118a7b62db5da
Author: Heikki Krogerus heikki.kroge...@linux.intel.com
Date:   Mon May 7 12:31:29 2012 +0300


 clk: add non CONFIG_HAVE_CLK routines

 Many drivers are shared between architectures that may or may not have
 HAVE_CLK selected for them.  To remove compilation errors for them we
 enclose clk_*() calls in these drivers within #ifdef CONFIG_HAVE_CLK,
 #endif.

 This patch removes the need of these CONFIG_HAVE_CLK statements, by
 introducing dummy routines when HAVE_CLK is not selected by platforms.
 So, definition of these routines will always be available.  These calls
 will return error for platforms that don't select HAVE_CLK.

 Signed-off-by: Viresh Kumar viresh.ku...@st.com
 Cc: Wolfram Sang w.s...@pengutronix.de
 Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
 Cc: Jeff Garzik jgar...@redhat.com
 Cc: Andrew Lunn and...@lunn.ch
 Cc: Bhupesh Sharma bhupesh.sha...@st.com
 Cc: Giuseppe Cavallaro peppe.cavall...@st.com
 Cc: Russell King r...@arm.linux.org.uk
 Cc: Mike Turquette mturque...@linaro.org
 Cc: Sergei Shtylyov sshtyl...@ru.mvista.com
 Cc: viresh kumar viresh.li...@gmail.com
 Signed-off-by: Andrew Morton a...@linux-foundation.org
 Signed-off-by: Linus Torvalds torva...@linux-foundation.org
 --
 To unsubscribe from this list: send the line unsubscribe linux-kernel in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv1 5/6] MAINTAINERS: fix indentation for Viresh Kumar

2012-09-26 Thread Andy Shevchenko
On Wed, 2012-09-26 at 09:06 +0530, viresh kumar wrote: 
 On Tue, Sep 25, 2012 at 5:43 PM, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
  Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
  Cc: Viresh Kumar viresh.li...@gmail.com
  ---
   MAINTAINERS |   16 
   1 file changed, 8 insertions(+), 8 deletions(-)
 
 Acked-by: Viresh Kumar viresh.ku...@linaro.org
 
 Though i am not sure if this patch should be part of the set.
Feel free to push it forward separately.
I do it because of patch 6/6.


-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv1 3/6] dmaengine: dw_dmac: Add PCI part of the driver

2012-09-26 Thread Andy Shevchenko
On Wed, 2012-09-26 at 09:30 +0530, viresh kumar wrote: 
 On Tue, Sep 25, 2012 at 5:43 PM, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
  diff --git a/drivers/dma/dw_dmac_at32.c b/drivers/dma/dw_dmac_at32.c
  index 7bc7ac4..5c9180e 100644
  --- a/drivers/dma/dw_dmac_at32.c
  +++ b/drivers/dma/dw_dmac_at32.c
  @@ -12,6 +12,7 @@
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
  +
 
 :(
Noticed and fixed already locally.
Perhaps it will be not needed accordingly to your comment about CLK
framework.

 
   #include linux/module.h
   #include linux/platform_device.h
   #include linux/slab.h
  diff --git a/drivers/dma/dw_dmac_pci.c b/drivers/dma/dw_dmac_pci.c
  new file mode 100644
  index 000..7490894
  --- /dev/null
  +++ b/drivers/dma/dw_dmac_pci.c
  @@ -0,0 +1,130 @@
  +/*
  + * PCI driver for the Synopsys DesignWare DMA Controller
  + *
  + * Copyright (C) 2012 Intel Corporation
  + *
  + * This program is free software; you can redistribute it and/or modify
  + * it under the terms of the GNU General Public License version 2 as
  + * published by the Free Software Foundation.
  + */
  +
  +#include linux/module.h
  +#include linux/pci.h
  +#include linux/platform_device.h
  +#include linux/dw_dmac.h
  +
  +#define DW_DRIVER_NAME dw_dmac_pci
  +
  +#define DRIVER(_is_private, _chan_order, _chan_pri)\
  +   ((kernel_ulong_t)(struct dw_dma_platform_data) {   \
  +   .is_private = (_is_private),\
  +   .chan_allocation_order = (_chan_order), \
  +   .chan_priority = (_chan_pri),   \
  +   })
 
 See if you can align \ at the end of every line in one column
Ok.

 
  +
  +static int __devinit dw_pci_probe(struct pci_dev *pdev,
  + const struct pci_device_id *id)
  +{
  +   struct platform_device  *pd;
 
 no need of multiple spaces before *pd.
 
  +   struct resource r[2];
  +   struct dw_dma_platform_data *driver = (void *)id-driver_data;
  +   static int  instance;
  +   int ret;
 
 for all above lines too
Ok for both comments.

 
  +
  +   ret = pci_enable_device(pdev);
  +   if (ret)
  +   return ret;
  +
  +   pci_set_power_state(pdev, PCI_D0);
  +   pci_set_master(pdev);
  +   pci_try_set_mwi(pdev);
  +
  +   ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
  +   if (ret)
  +   goto err0;
  +
  +   ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
  +   if (ret)
  +   goto err0;
  +
  +   pd = platform_device_alloc(dw_dmac, instance);
  +   if (!pd) {
  +   dev_err(pdev-dev, can't allocate dw_dmac platform 
  device\n);
  +   ret = -ENOMEM;
  +   goto err0;
  +   }
  +
  +   memset(r, 0, sizeof(r));
  +
  +   r[0].start  = pci_resource_start(pdev, 0);
  +   r[0].end= pci_resource_end(pdev, 0);
  +   r[0].flags  = IORESOURCE_MEM;
 
 ditto
 
  +
  +   r[1].start  = pdev-irq;
  +   r[1].flags  = IORESOURCE_IRQ;
 
 ditto
Ok.

 
  +   ret = platform_device_add_resources(pd, r, ARRAY_SIZE(r));
  +   if (ret) {
  +   dev_err(pdev-dev, can't add resources to platform 
  device\n);
  +   goto err1;
  +   }
  +
  +   ret = platform_device_add_data(pd, driver, sizeof(*driver));
  +   if (ret)
  +   goto err1;
  +
  +   dma_set_coherent_mask(pd-dev, pdev-dev.coherent_dma_mask);
  +   pd-dev.dma_mask = pdev-dev.dma_mask;
  +   pd-dev.dma_parms = pdev-dev.dma_parms;
  +   pd-dev.parent = pdev-dev;
  +
  +   pci_set_drvdata(pdev, pd);
  +
  +   ret = platform_device_add(pd);
  +   if (ret) {
  +   dev_err(pdev-dev, platform_device_add failed\n);
  +   goto err1;
  +   }
  +
  +   instance++;
  +   return 0;
  +
  +err1:
  +   pci_set_drvdata(pdev, NULL);
 
 Is this required?
Seems it's not.

  +   platform_device_put(pd);
  +err0:
  +   pci_disable_device(pdev);
  +
  +   return ret;
  +}
  +
  +static void __devexit dw_pci_remove(struct pci_dev *pdev)
  +{
  +   struct platform_device *pd = pci_get_drvdata(pdev);
  +
  +   platform_device_unregister(pd);
  +   pci_set_drvdata(pdev, NULL);
  +   pci_disable_device(pdev);
  +}
  +
  +static DEFINE_PCI_DEVICE_TABLE(dw_pci_id_table) = {
  +   { PCI_VDEVICE(INTEL, 0x0827), DRIVER(1, 0, 0) },
  +   { PCI_VDEVICE(INTEL, 0x0830), DRIVER(1, 0, 0) },
  +   { PCI_VDEVICE(INTEL, 0x0f06), DRIVER(1, 0, 0) },
  +   { 0, }
  +};
  +MODULE_DEVICE_TABLE(pci, dw_pci_id_table);
  +
  +static struct pci_driver dw_pci_driver = {
  +   .name   = DW_DRIVER_NAME,
  +   .id_table   = dw_pci_id_table,
  +   .probe

Re: [PATCHv1 1/6] dmaengine: dw_dmac: Remove clk API dependency

2012-09-26 Thread Andy Shevchenko
On Wed, 2012-09-26 at 09:12 +0530, viresh kumar wrote: 
 On Tue, Sep 25, 2012 at 5:43 PM, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
  From: Heikki Krogerus heikki.kroge...@linux.intel.com
  Not all platforms support clk API.

 But not these. There are dummy clk routines available now for platforms which
 don't support clk framework. So, even if your platform doesn't support clk
 framework, you should be able to compile your code.
I have tested without this patch. Works nicely.
I'm about to submit patch v2.


-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 0/4] dw_dmac: split the driver and introduce PCI part

2012-09-26 Thread Andy Shevchenko
This patchset is dedicated to support different platform devices via the same
core driver. In our case the dw_dmac could be used as a PCI device, regular
embedded device or something else. This split allows to support the controller
connected to any bus by adding a little piece of code without duplicating a
core driver functionality.

Since v1:
 - indentation fix in MAINTAINERS is droped away to separate patch (not related
   to this series)
 - CLK framework uses stubs for platforms w/o it, in the result it eliminates 3
   patches and produces 1
 - driver files are moved to an own folder

Andy Shevchenko (2):
  dma: move dw_dmac driver to an own directory
  MAINTAINERS: add recently created files to dw_dmac section

Heikki Krogerus (2):
  dmaengine: dw_dmac: convert to platform driver
  dmaengine: dw_dmac: Add PCI part of the driver

 MAINTAINERS   |4 +-
 drivers/dma/Kconfig   |   11 +-
 drivers/dma/Makefile  |2 +-
 drivers/dma/dw/Makefile   |2 +
 drivers/dma/dw/dw_dmac.c  | 1720 
 drivers/dma/dw/dw_dmac_pci.c  |  127 +++
 drivers/dma/dw/dw_dmac_regs.h |  294 +++
 drivers/dma/dw_dmac.c | 1727 -
 drivers/dma/dw_dmac_regs.h|  294 ---
 9 files changed, 2155 insertions(+), 2026 deletions(-)
 create mode 100644 drivers/dma/dw/Makefile
 create mode 100644 drivers/dma/dw/dw_dmac.c
 create mode 100644 drivers/dma/dw/dw_dmac_pci.c
 create mode 100644 drivers/dma/dw/dw_dmac_regs.h
 delete mode 100644 drivers/dma/dw_dmac.c
 delete mode 100644 drivers/dma/dw_dmac_regs.h

-- 
1.7.10.4

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


[PATCHv2 1/4] dmaengine: dw_dmac: convert to platform driver

2012-09-26 Thread Andy Shevchenko
From: Heikki Krogerus heikki.kroge...@linux.intel.com

This driver could be used on different platforms. Thus, we converted it to be
a platform driver. The HAVE_CLK dependency is dropped away as well.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/dma/Kconfig   |2 --
 drivers/dma/dw_dmac.c |   21 +++--
 2 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 677cd6e..75cdcb5 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -83,9 +83,7 @@ config INTEL_IOP_ADMA
 
 config DW_DMAC
tristate Synopsys DesignWare AHB DMA support
-   depends on HAVE_CLK
select DMA_ENGINE
-   default y if CPU_AT32AP7000
help
  Support the Synopsys DesignWare AHB DMA controller.  This
  can be integrated in chips such as the Atmel AT32ap7000.
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index c4b0eb3..9f0129d 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -1,14 +1,15 @@
 /*
- * Driver for the Synopsys DesignWare DMA Controller (aka DMACA on
- * AVR32 systems.)
+ * Core driver for the Synopsys DesignWare DMA Controller
  *
  * Copyright (C) 2007-2008 Atmel Corporation
  * Copyright (C) 2010-2011 ST Microelectronics
+ * Copyright (C) 2012 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+
 #include linux/bitops.h
 #include linux/clk.h
 #include linux/delay.h
@@ -222,7 +223,6 @@ static inline void dwc_dump_chan_regs(struct dw_dma_chan 
*dwc)
channel_readl(dwc, CTL_LO));
 }
 
-
 static inline void dwc_chan_disable(struct dw_dma *dw, struct dw_dma_chan *dwc)
 {
channel_clear_bit(dw, CH_EN, dwc-mask);
@@ -1679,6 +1679,7 @@ static int dw_resume_noirq(struct device *dev)
 
clk_prepare_enable(dw-clk);
dma_writel(dw, CFG, DW_CFG_DMA_EN);
+
return 0;
 }
 
@@ -1700,6 +1701,7 @@ MODULE_DEVICE_TABLE(of, dw_dma_id_table);
 #endif
 
 static struct platform_driver dw_driver = {
+   .probe  = dw_probe,
.remove = __devexit_p(dw_remove),
.shutdown   = dw_shutdown,
.driver = {
@@ -1709,18 +1711,9 @@ static struct platform_driver dw_driver = {
},
 };
 
-static int __init dw_init(void)
-{
-   return platform_driver_probe(dw_driver, dw_probe);
-}
-subsys_initcall(dw_init);
-
-static void __exit dw_exit(void)
-{
-   platform_driver_unregister(dw_driver);
-}
-module_exit(dw_exit);
+module_platform_driver(dw_driver);
 
+MODULE_ALIAS(platform:dw_dmac);
 MODULE_LICENSE(GPL v2);
 MODULE_DESCRIPTION(Synopsys DesignWare DMA Controller driver);
 MODULE_AUTHOR(Haavard Skinnemoen (Atmel));
-- 
1.7.10.4

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


[PATCHv2 4/4] MAINTAINERS: add recently created files to dw_dmac section

2012-09-26 Thread Andy Shevchenko
Append myself to mail subsection as well.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 MAINTAINERS |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 7dfd0eb..b87cbb1d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5999,10 +5999,10 @@ F:  drivers/tty/serial
 
 SYNOPSYS DESIGNWARE DMAC DRIVER
 M: Viresh Kumar viresh.li...@gmail.com
+M: Andy Shevchenko andriy.shevche...@linux.intel.com
 S: Maintained
 F: include/linux/dw_dmac.h
-F: drivers/dma/dw_dmac_regs.h
-F: drivers/dma/dw_dmac.c
+F: drivers/dma/dw/
 
 TIMEKEEPING, NTP
 M: John Stultz johns...@us.ibm.com
-- 
1.7.10.4

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


[PATCHv2 2/4] dmaengine: dw_dmac: Add PCI part of the driver

2012-09-26 Thread Andy Shevchenko
From: Heikki Krogerus heikki.kroge...@linux.intel.com

This is the PCI part of the DesignWare DMAC driver. The controller is usually
used in the Intel hardware such as Medfield.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/dma/Kconfig   |9 
 drivers/dma/Makefile  |1 +
 drivers/dma/dw_dmac_pci.c |  127 +
 3 files changed, 137 insertions(+)
 create mode 100644 drivers/dma/dw_dmac_pci.c

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 75cdcb5..fad6ed2 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -88,6 +88,15 @@ config DW_DMAC
  Support the Synopsys DesignWare AHB DMA controller.  This
  can be integrated in chips such as the Atmel AT32ap7000.
 
+config DW_DMAC_PCI
+   tristate Synopsys DesignWare AHB DMA support (PCI bus)
+   depends on PCI
+   select DW_DMAC
+   help
+ Support the Synopsys DesignWare AHB DMA controller on the platfroms
+ that provide it as a PCI device. For example, Intel Medfield has
+ integrated this GPDMA controller.
+
 config AT_HDMAC
tristate Atmel AHB DMA support
depends on ARCH_AT91
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index 7428fea..15eef5f 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_FSL_DMA) += fsldma.o
 obj-$(CONFIG_MPC512X_DMA) += mpc512x_dma.o
 obj-$(CONFIG_MV_XOR) += mv_xor.o
 obj-$(CONFIG_DW_DMAC) += dw_dmac.o
+obj-$(CONFIG_DW_DMAC_PCI) += dw_dmac_pci.o
 obj-$(CONFIG_AT_HDMAC) += at_hdmac.o
 obj-$(CONFIG_MX3_IPU) += ipu/
 obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o
diff --git a/drivers/dma/dw_dmac_pci.c b/drivers/dma/dw_dmac_pci.c
new file mode 100644
index 000..95570df
--- /dev/null
+++ b/drivers/dma/dw_dmac_pci.c
@@ -0,0 +1,127 @@
+/*
+ * PCI driver for the Synopsys DesignWare DMA Controller
+ *
+ * Copyright (C) 2012 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/module.h
+#include linux/pci.h
+#include linux/platform_device.h
+#include linux/dw_dmac.h
+
+#define DRIVER(_is_private, _chan_order, _chan_pri)\
+   ((kernel_ulong_t)(struct dw_dma_platform_data) {   \
+   .is_private = (_is_private),\
+   .chan_allocation_order = (_chan_order), \
+   .chan_priority = (_chan_pri),   \
+   })
+
+static int __devinit dw_pci_probe(struct pci_dev *pdev,
+ const struct pci_device_id *id)
+{
+   struct platform_device *pd;
+   struct resource r[2];
+   struct dw_dma_platform_data *driver = (void *)id-driver_data;
+   static int instance;
+   int ret;
+
+   ret = pci_enable_device(pdev);
+   if (ret)
+   return ret;
+
+   pci_set_power_state(pdev, PCI_D0);
+   pci_set_master(pdev);
+   pci_try_set_mwi(pdev);
+
+   ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+   if (ret)
+   goto err0;
+
+   ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+   if (ret)
+   goto err0;
+
+   pd = platform_device_alloc(dw_dmac, instance);
+   if (!pd) {
+   dev_err(pdev-dev, can't allocate dw_dmac platform device\n);
+   ret = -ENOMEM;
+   goto err0;
+   }
+
+   memset(r, 0, sizeof(r));
+
+   r[0].start = pci_resource_start(pdev, 0);
+   r[0].end = pci_resource_end(pdev, 0);
+   r[0].flags = IORESOURCE_MEM;
+
+   r[1].start = pdev-irq;
+   r[1].flags = IORESOURCE_IRQ;
+
+   ret = platform_device_add_resources(pd, r, ARRAY_SIZE(r));
+   if (ret) {
+   dev_err(pdev-dev, can't add resources to platform device\n);
+   goto err1;
+   }
+
+   ret = platform_device_add_data(pd, driver, sizeof(*driver));
+   if (ret)
+   goto err1;
+
+   dma_set_coherent_mask(pd-dev, pdev-dev.coherent_dma_mask);
+   pd-dev.dma_mask = pdev-dev.dma_mask;
+   pd-dev.dma_parms = pdev-dev.dma_parms;
+   pd-dev.parent = pdev-dev;
+
+   pci_set_drvdata(pdev, pd);
+
+   ret = platform_device_add(pd);
+   if (ret) {
+   dev_err(pdev-dev, platform_device_add failed\n);
+   goto err1;
+   }
+
+   instance++;
+   return 0;
+
+err1:
+   platform_device_put(pd);
+err0:
+   pci_disable_device(pdev);
+
+   return ret;
+}
+
+static void __devexit dw_pci_remove(struct pci_dev *pdev)
+{
+   struct platform_device *pd = pci_get_drvdata(pdev);
+
+   platform_device_unregister(pd);
+   pci_set_drvdata(pdev, NULL);
+   pci_disable_device(pdev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE

Re: [PATCHv2 4/4] MAINTAINERS: add recently created files to dw_dmac section

2012-09-26 Thread Andy Shevchenko
On Wed, Sep 26, 2012 at 5:48 PM, viresh kumar viresh.ku...@linaro.org wrote:
 On Wed, Sep 26, 2012 at 8:15 PM, viresh kumar viresh.ku...@linaro.org wrote:
  SYNOPSYS DESIGNWARE DMAC DRIVER
  M: Viresh Kumar viresh.li...@gmail.com
 +M: Andy Shevchenko andriy.shevche...@linux.intel.com
  S: Maintained
  F: include/linux/dw_dmac.h
 -F: drivers/dma/dw_dmac_regs.h
 -F: drivers/dma/dw_dmac.c
 +F: drivers/dma/dw/

 I can't see this change...

 Sorry didn't saw your 3rd patch... :(

 I don't know why, but when i get patches from you... they appear in
 the older threads..
 i.e. v2 comes as reply to v1, v3 as reply to v2... so becomes
 difficult to track them..

 You simply do git send-email *.patch?
Okay, I will send v3 as separate thread. (Usually I remove old
messages and don't see all of thread content)


-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv2 3/4] dma: move dw_dmac driver to an own directory

2012-09-26 Thread Andy Shevchenko
On Wed, Sep 26, 2012 at 5:53 PM, viresh kumar viresh.ku...@linaro.org wrote:
 On Wed, Sep 26, 2012 at 6:10 PM, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
 The dw_dmac driver contains multiple files. To make a managment of them more
 convenient move it to an own directory.

 git format-patch has a option -C or -M or both... that makes such
 changes easier to review.
 If you create patches with these options, we will not get such long
 patches for renames
 instead a single line will tell foo.c file is renamed as dw/foo.c

 So this patch will have only few lines after that.
It's never late to learn something new. Thanks!

 Please resend with that... as its impossible to review it currently.
Will be in v3.


-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv2 2/4] dmaengine: dw_dmac: Add PCI part of the driver

2012-09-26 Thread Andy Shevchenko
On Wed, Sep 26, 2012 at 5:33 PM, viresh kumar viresh.ku...@linaro.org wrote:
 Forgot earlier, please keep spear-devel in cc... They will be going to
 use dw_dmac driver :)
Oh, my bad. v3 will be Cc'ed there as well. Sorry.

 On Wed, Sep 26, 2012 at 6:10 PM, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
 diff --git a/drivers/dma/dw_dmac_pci.c b/drivers/dma/dw_dmac_pci.c
 +#include linux/module.h
 +#include linux/pci.h
 +#include linux/platform_device.h
 +#include linux/dw_dmac.h
 +
 +#define DRIVER(_is_private, _chan_order, _chan_pri)\
 +   ((kernel_ulong_t)(struct dw_dma_platform_data) {   \
 +   .is_private = (_is_private),\
 +   .chan_allocation_order = (_chan_order), \
 +   .chan_priority = (_chan_pri),   \

 I believe you don't need these braces around input variables on right side
 of =. Even if there is something complex passed.
Hmm... Have no idea if anyone will use robust stuff as a parameter to
that macro. I could remove them.


 Did you try to align \? Sorry can't see it in gmail :(
I checked - I have tabular indentation, that's why you see them at
different columns. In vi they look pretty well formated.

[snip]

 +   pd = platform_device_alloc(dw_dmac, instance);
 +   if (!pd) {
 +   dev_err(pdev-dev, can't allocate dw_dmac platform 
 device\n);
 +   ret = -ENOMEM;
 +   goto err0;
 +   }

 Is this the correct approach? I doubt... We are creating a platform
 device from a
 pci driver... Don't know if it can lead to some issues within kernel.

 Lets call the specialist for his comments  :)
 @Arnd: Can you please help us here?
This approach is used among different drivers in kernel. As first
example that comes to my mind you could consider chipidea USB driver
(drivers/usb/chipidea).


-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv2 1/4] dmaengine: dw_dmac: convert to platform driver

2012-09-26 Thread Andy Shevchenko
On Wed, Sep 26, 2012 at 5:13 PM, viresh kumar viresh.ku...@linaro.org wrote:
 On Wed, Sep 26, 2012 at 6:10 PM, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
 From: Heikki Krogerus heikki.kroge...@linux.intel.com

 This driver could be used on different platforms. Thus, we converted it to be
 a platform driver. The HAVE_CLK dependency is dropped away as well.

 Commit log and patch content don't match. :(
 We aren't converting it to a platform driver, it is already one.
Okay, any suggestion for this part?

 Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
 Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
 ---
  drivers/dma/Kconfig   |2 --
  drivers/dma/dw_dmac.c |   21 +++--
  2 files changed, 7 insertions(+), 16 deletions(-)

 diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
 index 677cd6e..75cdcb5 100644
 --- a/drivers/dma/Kconfig
 +++ b/drivers/dma/Kconfig
 @@ -83,9 +83,7 @@ config INTEL_IOP_ADMA

  config DW_DMAC
 tristate Synopsys DesignWare AHB DMA support
 -   depends on HAVE_CLK

 This matches subject.

 select DMA_ENGINE
 -   default y if CPU_AT32AP7000

 This doesn't. If you want this change, do this in a separate patch.
Will do separate patch. However this change doesn't interfere with
configuration on my side. So, might be better to keep that line to
have compatibility with older kernels?


 help
   Support the Synopsys DesignWare AHB DMA controller.  This
   can be integrated in chips such as the Atmel AT32ap7000.
 diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
 index c4b0eb3..9f0129d 100644
 --- a/drivers/dma/dw_dmac.c
 +++ b/drivers/dma/dw_dmac.c
 @@ -1,14 +1,15 @@
  /*
 - * Driver for the Synopsys DesignWare DMA Controller (aka DMACA on
 - * AVR32 systems.)
 + * Core driver for the Synopsys DesignWare DMA Controller
   *
   * Copyright (C) 2007-2008 Atmel Corporation
   * Copyright (C) 2010-2011 ST Microelectronics
 + * Copyright (C) 2012 Intel Corporation
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   */
 +
  #include linux/bitops.h
  #include linux/clk.h
  #include linux/delay.h
 @@ -222,7 +223,6 @@ static inline void dwc_dump_chan_regs(struct dw_dma_chan 
 *dwc)
 channel_readl(dwc, CTL_LO));
  }

 -

 Above + and - also don't belong to this patch
Separate patch? Will do.


  static inline void dwc_chan_disable(struct dw_dma *dw, struct dw_dma_chan 
 *dwc)
  {
 channel_clear_bit(dw, CH_EN, dwc-mask);
 @@ -1679,6 +1679,7 @@ static int dw_resume_noirq(struct device *dev)

 clk_prepare_enable(dw-clk);
 dma_writel(dw, CFG, DW_CFG_DMA_EN);
 +
 return 0;
  }

 @@ -1700,6 +1701,7 @@ MODULE_DEVICE_TABLE(of, dw_dma_id_table);
  #endif

  static struct platform_driver dw_driver = {
 +   .probe  = dw_probe,
 .remove = __devexit_p(dw_remove),
 .shutdown   = dw_shutdown,
 .driver = {
 @@ -1709,18 +1711,9 @@ static struct platform_driver dw_driver = {
 },
  };

 -static int __init dw_init(void)
 -{
 -   return platform_driver_probe(dw_driver, dw_probe);
 -}
 -subsys_initcall(dw_init);
 -
 -static void __exit dw_exit(void)
 -{
 -   platform_driver_unregister(dw_driver);
 -}
 -module_exit(dw_exit);
 +module_platform_driver(dw_driver);

 This should be a separate patch as well
Good. Will do.

 +MODULE_ALIAS(platform:dw_dmac);
  MODULE_LICENSE(GPL v2);
  MODULE_DESCRIPTION(Synopsys DesignWare DMA Controller driver);
  MODULE_AUTHOR(Haavard Skinnemoen (Atmel));

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv2 4/4] MAINTAINERS: add recently created files to dw_dmac section

2012-09-27 Thread Andy Shevchenko
On Wed, 2012-09-26 at 20:15 +0530, viresh kumar wrote: 
 On Wed, Sep 26, 2012 at 6:10 PM, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
  Append myself to mail subsection as well.
 
 Mail subsection? You are adding yourself as Maintainer of dw_dmac...
Yes and odd, accordingly to documentation:
Descriptions of section entries:
...
M: Mail patches to: FullName address@domain
...
S: Status, one of the following:
...
   Maintained:  Someone actually looks after it.

...
(subsection = section entry).

The status is applied to the section, but person. We discussed this with
Joe in previous messages.


 Do you really want that.
 I am asking this, because that's not the normal practice followed in kernel.
In current design of the MAINTAINERS database I don't see other way to
apply watch for the changes to the specific driver condition.

 This isn't done until unless, somebody has done a MAJOR modification
 to the driver.
Define the MAJOR (rhetorical) :-)


-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 3/7] dmaengine: dw_dmac: remove CLK dependency

2012-09-27 Thread Andy Shevchenko
From: Heikki Krogerus heikki.kroge...@linux.intel.com

This driver could be used on different platforms. Thus, the HAVE_CLK dependency
is dropped away.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/dma/Kconfig |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 677cd6e..df32537 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -83,7 +83,6 @@ config INTEL_IOP_ADMA
 
 config DW_DMAC
tristate Synopsys DesignWare AHB DMA support
-   depends on HAVE_CLK
select DMA_ENGINE
default y if CPU_AT32AP7000
help
-- 
1.7.10.4

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


[PATCHv3 7/7] MAINTAINERS: add recently created files to dw_dmac section

2012-09-27 Thread Andy Shevchenko
Append myself to the mail entry of the section as well.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 MAINTAINERS |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 7dfd0eb..b87cbb1d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5999,10 +5999,10 @@ F:  drivers/tty/serial
 
 SYNOPSYS DESIGNWARE DMAC DRIVER
 M: Viresh Kumar viresh.li...@gmail.com
+M: Andy Shevchenko andriy.shevche...@linux.intel.com
 S: Maintained
 F: include/linux/dw_dmac.h
-F: drivers/dma/dw_dmac_regs.h
-F: drivers/dma/dw_dmac.c
+F: drivers/dma/dw/
 
 TIMEKEEPING, NTP
 M: John Stultz johns...@us.ibm.com
-- 
1.7.10.4

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


[PATCHv3 0/7] dw_dmac: split the driver and introduce PCI part

2012-09-27 Thread Andy Shevchenko
This patchset is dedicated to support different platform devices via the same
core driver. In our case the dw_dmac could be used as a PCI device, regular
embedded device or something else. This split allows to support the controller
connected to any bus by adding a little piece of code without duplicating a
core driver functionality.

Since v2:
 - use git format-patch -C -M to avoid long useless patches
 - substitute DRIVER macro to a normal structure definition in the
   dw_dmac_pci.c
 - split patch 1/4 to few independent pieces with their own descriptions

Andy Shevchenko (2):
  dma: move dw_dmac driver to an own directory
  MAINTAINERS: add recently created files to dw_dmac section

Heikki Krogerus (5):
  dmaengine: dw_dmac: use helper macro module_platform_driver()
  dmaengine: dw_dmac: add module alias
  dmaengine: dw_dmac: remove CLK dependency
  dmaengine: dw_dmac: amend description and indentation
  dmaengine: dw_dmac: add PCI part of the driver

 MAINTAINERS |4 +-
 drivers/dma/Kconfig |   10 ++-
 drivers/dma/Makefile|2 +-
 drivers/dma/dw/Makefile |2 +
 drivers/dma/{ = dw}/dw_dmac.c  |   23 +++
 drivers/dma/dw/dw_dmac_pci.c|  126 +++
 drivers/dma/{ = dw}/dw_dmac_regs.h |0
 7 files changed, 148 insertions(+), 19 deletions(-)
 create mode 100644 drivers/dma/dw/Makefile
 rename drivers/dma/{ = dw}/dw_dmac.c (99%)
 create mode 100644 drivers/dma/dw/dw_dmac_pci.c
 rename drivers/dma/{ = dw}/dw_dmac_regs.h (100%)

-- 
1.7.10.4

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


[PATCHv3 1/7] dmaengine: dw_dmac: use helper macro module_platform_driver()

2012-09-27 Thread Andy Shevchenko
From: Heikki Krogerus heikki.kroge...@linux.intel.com

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/dma/dw_dmac.c |   13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index c4b0eb3..0b88ced 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -1700,6 +1700,7 @@ MODULE_DEVICE_TABLE(of, dw_dma_id_table);
 #endif
 
 static struct platform_driver dw_driver = {
+   .probe  = dw_probe,
.remove = __devexit_p(dw_remove),
.shutdown   = dw_shutdown,
.driver = {
@@ -1709,17 +1710,7 @@ static struct platform_driver dw_driver = {
},
 };
 
-static int __init dw_init(void)
-{
-   return platform_driver_probe(dw_driver, dw_probe);
-}
-subsys_initcall(dw_init);
-
-static void __exit dw_exit(void)
-{
-   platform_driver_unregister(dw_driver);
-}
-module_exit(dw_exit);
+module_platform_driver(dw_driver);
 
 MODULE_LICENSE(GPL v2);
 MODULE_DESCRIPTION(Synopsys DesignWare DMA Controller driver);
-- 
1.7.10.4

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


[PATCHv3 4/7] dmaengine: dw_dmac: amend description and indentation

2012-09-27 Thread Andy Shevchenko
From: Heikki Krogerus heikki.kroge...@linux.intel.com

The driver will be used as a core part for various implementations of the
DesignWare DMA device. The patch adjusts description on the top and corrects
paragraph indentation in few places across the code.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/dma/dw_dmac.c |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index bbb2a82..9f0129d 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -1,14 +1,15 @@
 /*
- * Driver for the Synopsys DesignWare DMA Controller (aka DMACA on
- * AVR32 systems.)
+ * Core driver for the Synopsys DesignWare DMA Controller
  *
  * Copyright (C) 2007-2008 Atmel Corporation
  * Copyright (C) 2010-2011 ST Microelectronics
+ * Copyright (C) 2012 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+
 #include linux/bitops.h
 #include linux/clk.h
 #include linux/delay.h
@@ -222,7 +223,6 @@ static inline void dwc_dump_chan_regs(struct dw_dma_chan 
*dwc)
channel_readl(dwc, CTL_LO));
 }
 
-
 static inline void dwc_chan_disable(struct dw_dma *dw, struct dw_dma_chan *dwc)
 {
channel_clear_bit(dw, CH_EN, dwc-mask);
@@ -1679,6 +1679,7 @@ static int dw_resume_noirq(struct device *dev)
 
clk_prepare_enable(dw-clk);
dma_writel(dw, CFG, DW_CFG_DMA_EN);
+
return 0;
 }
 
-- 
1.7.10.4

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


[PATCHv3 5/7] dmaengine: dw_dmac: add PCI part of the driver

2012-09-27 Thread Andy Shevchenko
From: Heikki Krogerus heikki.kroge...@linux.intel.com

This is the PCI part of the DesignWare DMAC driver. The controller is usually
used in the Intel hardware such as Medfield.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/dma/Kconfig   |9 
 drivers/dma/Makefile  |1 +
 drivers/dma/dw_dmac_pci.c |  126 +
 3 files changed, 136 insertions(+)
 create mode 100644 drivers/dma/dw_dmac_pci.c

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index df32537..a5c7f64 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -89,6 +89,15 @@ config DW_DMAC
  Support the Synopsys DesignWare AHB DMA controller.  This
  can be integrated in chips such as the Atmel AT32ap7000.
 
+config DW_DMAC_PCI
+   tristate Synopsys DesignWare AHB DMA support (PCI bus)
+   depends on PCI
+   select DW_DMAC
+   help
+ Support the Synopsys DesignWare AHB DMA controller on the platfroms
+ that provide it as a PCI device. For example, Intel Medfield has
+ integrated this GPDMA controller.
+
 config AT_HDMAC
tristate Atmel AHB DMA support
depends on ARCH_AT91
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index 7428fea..15eef5f 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_FSL_DMA) += fsldma.o
 obj-$(CONFIG_MPC512X_DMA) += mpc512x_dma.o
 obj-$(CONFIG_MV_XOR) += mv_xor.o
 obj-$(CONFIG_DW_DMAC) += dw_dmac.o
+obj-$(CONFIG_DW_DMAC_PCI) += dw_dmac_pci.o
 obj-$(CONFIG_AT_HDMAC) += at_hdmac.o
 obj-$(CONFIG_MX3_IPU) += ipu/
 obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o
diff --git a/drivers/dma/dw_dmac_pci.c b/drivers/dma/dw_dmac_pci.c
new file mode 100644
index 000..b7ad37f
--- /dev/null
+++ b/drivers/dma/dw_dmac_pci.c
@@ -0,0 +1,126 @@
+/*
+ * PCI driver for the Synopsys DesignWare DMA Controller
+ *
+ * Copyright (C) 2012 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/module.h
+#include linux/pci.h
+#include linux/platform_device.h
+#include linux/dw_dmac.h
+
+static struct dw_dma_platform_data pdata = {
+   .is_private = 1,
+   .chan_allocation_order = CHAN_ALLOCATION_ASCENDING,
+   .chan_priority = CHAN_PRIORITY_ASCENDING,
+};
+
+static int __devinit dw_pci_probe(struct pci_dev *pdev,
+ const struct pci_device_id *id)
+{
+   struct platform_device *pd;
+   struct resource r[2];
+   struct dw_dma_platform_data *driver = (void *)id-driver_data;
+   static int instance;
+   int ret;
+
+   ret = pci_enable_device(pdev);
+   if (ret)
+   return ret;
+
+   pci_set_power_state(pdev, PCI_D0);
+   pci_set_master(pdev);
+   pci_try_set_mwi(pdev);
+
+   ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+   if (ret)
+   goto err0;
+
+   ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+   if (ret)
+   goto err0;
+
+   pd = platform_device_alloc(dw_dmac, instance);
+   if (!pd) {
+   dev_err(pdev-dev, can't allocate dw_dmac platform device\n);
+   ret = -ENOMEM;
+   goto err0;
+   }
+
+   memset(r, 0, sizeof(r));
+
+   r[0].start = pci_resource_start(pdev, 0);
+   r[0].end = pci_resource_end(pdev, 0);
+   r[0].flags = IORESOURCE_MEM;
+
+   r[1].start = pdev-irq;
+   r[1].flags = IORESOURCE_IRQ;
+
+   ret = platform_device_add_resources(pd, r, ARRAY_SIZE(r));
+   if (ret) {
+   dev_err(pdev-dev, can't add resources to platform device\n);
+   goto err1;
+   }
+
+   ret = platform_device_add_data(pd, driver, sizeof(*driver));
+   if (ret)
+   goto err1;
+
+   dma_set_coherent_mask(pd-dev, pdev-dev.coherent_dma_mask);
+   pd-dev.dma_mask = pdev-dev.dma_mask;
+   pd-dev.dma_parms = pdev-dev.dma_parms;
+   pd-dev.parent = pdev-dev;
+
+   pci_set_drvdata(pdev, pd);
+
+   ret = platform_device_add(pd);
+   if (ret) {
+   dev_err(pdev-dev, platform_device_add failed\n);
+   goto err1;
+   }
+
+   instance++;
+   return 0;
+
+err1:
+   platform_device_put(pd);
+err0:
+   pci_disable_device(pdev);
+
+   return ret;
+}
+
+static void __devexit dw_pci_remove(struct pci_dev *pdev)
+{
+   struct platform_device *pd = pci_get_drvdata(pdev);
+
+   platform_device_unregister(pd);
+   pci_set_drvdata(pdev, NULL);
+   pci_disable_device(pdev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(dw_pci_id_table) = {
+   { PCI_VDEVICE(INTEL, 0x0827), (kernel_ulong_t)pdata },
+   { PCI_VDEVICE(INTEL, 0x0830), (kernel_ulong_t)pdata },
+   { PCI_VDEVICE

[PATCHv3 6/7] dma: move dw_dmac driver to an own directory

2012-09-27 Thread Andy Shevchenko
The dw_dmac driver contains multiple files. To make a managment of them more
convenient move it to an own directory.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/dma/Makefile|3 +--
 drivers/dma/dw/Makefile |2 ++
 drivers/dma/{ = dw}/dw_dmac.c  |2 +-
 drivers/dma/{ = dw}/dw_dmac_pci.c  |0
 drivers/dma/{ = dw}/dw_dmac_regs.h |0
 5 files changed, 4 insertions(+), 3 deletions(-)
 create mode 100644 drivers/dma/dw/Makefile
 rename drivers/dma/{ = dw}/dw_dmac.c (99%)
 rename drivers/dma/{ = dw}/dw_dmac_pci.c (100%)
 rename drivers/dma/{ = dw}/dw_dmac_regs.h (100%)

diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index 15eef5f..122a48a 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -11,8 +11,7 @@ obj-$(CONFIG_INTEL_IOP_ADMA) += iop-adma.o
 obj-$(CONFIG_FSL_DMA) += fsldma.o
 obj-$(CONFIG_MPC512X_DMA) += mpc512x_dma.o
 obj-$(CONFIG_MV_XOR) += mv_xor.o
-obj-$(CONFIG_DW_DMAC) += dw_dmac.o
-obj-$(CONFIG_DW_DMAC_PCI) += dw_dmac_pci.o
+obj-$(CONFIG_DW_DMAC) += dw/
 obj-$(CONFIG_AT_HDMAC) += at_hdmac.o
 obj-$(CONFIG_MX3_IPU) += ipu/
 obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o
diff --git a/drivers/dma/dw/Makefile b/drivers/dma/dw/Makefile
new file mode 100644
index 000..2edfb24
--- /dev/null
+++ b/drivers/dma/dw/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_DW_DMAC) += dw_dmac.o
+obj-$(CONFIG_DW_DMAC_PCI) += dw_dmac_pci.o
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw/dw_dmac.c
similarity index 99%
rename from drivers/dma/dw_dmac.c
rename to drivers/dma/dw/dw_dmac.c
index 9f0129d..fa0471a 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw/dw_dmac.c
@@ -24,8 +24,8 @@
 #include linux/platform_device.h
 #include linux/slab.h
 
+#include ../dmaengine.h
 #include dw_dmac_regs.h
-#include dmaengine.h
 
 /*
  * This supports the Synopsys DesignWare AHB Central DMA Controller,
diff --git a/drivers/dma/dw_dmac_pci.c b/drivers/dma/dw/dw_dmac_pci.c
similarity index 100%
rename from drivers/dma/dw_dmac_pci.c
rename to drivers/dma/dw/dw_dmac_pci.c
diff --git a/drivers/dma/dw_dmac_regs.h b/drivers/dma/dw/dw_dmac_regs.h
similarity index 100%
rename from drivers/dma/dw_dmac_regs.h
rename to drivers/dma/dw/dw_dmac_regs.h
-- 
1.7.10.4

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


[PATCHv3 2/7] dmaengine: dw_dmac: add module alias

2012-09-27 Thread Andy Shevchenko
From: Heikki Krogerus heikki.kroge...@linux.intel.com

It's good to have a quasistatic name for the platform driver.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/dma/dw_dmac.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 0b88ced..bbb2a82 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -1712,6 +1712,7 @@ static struct platform_driver dw_driver = {
 
 module_platform_driver(dw_driver);
 
+MODULE_ALIAS(platform:dw_dmac);
 MODULE_LICENSE(GPL v2);
 MODULE_DESCRIPTION(Synopsys DesignWare DMA Controller driver);
 MODULE_AUTHOR(Haavard Skinnemoen (Atmel));
-- 
1.7.10.4

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


Re: [PATCHv3 3/7] dmaengine: dw_dmac: remove CLK dependency

2012-09-27 Thread Andy Shevchenko
On Thu, Sep 27, 2012 at 10:42 AM, Felipe Balbi ba...@ti.com wrote:
 - depends on HAVE_CLK

 as is, this will break compilation of any arch which doesn't set
 HAVE_CLK.
As Viresh suggested and I checked it's not.
He wrote nice patch that adds stubs for such case.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv3 5/7] dmaengine: dw_dmac: add PCI part of the driver

2012-09-27 Thread Andy Shevchenko
On Thu, Sep 27, 2012 at 10:49 AM, Felipe Balbi ba...@ti.com wrote:
 On Thu, Sep 27, 2012 at 10:31:59AM +0300, Andy Shevchenko wrote:
 From: Heikki Krogerus heikki.kroge...@linux.intel.com

 This is the PCI part of the DesignWare DMAC driver. The controller is usually
 used in the Intel hardware such as Medfield.


 --- /dev/null
 +++ b/drivers/dma/dw_dmac_pci.c
 @@ -0,0 +1,126 @@
 +/*
 + * PCI driver for the Synopsys DesignWare DMA Controller
 + *
 + * Copyright (C) 2012 Intel Corporation
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */
 +
 +#include linux/module.h
 +#include linux/pci.h
 +#include linux/platform_device.h
 +#include linux/dw_dmac.h
 +
 +static struct dw_dma_platform_data pdata = {

 pdata looks like it wants a prefix.
Okay.

 + .is_private = 1,
 + .chan_allocation_order = CHAN_ALLOCATION_ASCENDING,
 + .chan_priority = CHAN_PRIORITY_ASCENDING,
 +};

 This is the same for all of the PCI IDs listed below, looks like it's
 best to just add it as platform_data of the dwc_dmac device directly,
 rather than passing a pointer to this via driver-data.
It potentially could be altered. I prefer to leave it as structure in
the pci driver.

 + static int instance;
 this could be a IDA instead.
Will look at it, thanks.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv3 7/7] MAINTAINERS: add recently created files to dw_dmac section

2012-09-27 Thread Andy Shevchenko
On Thu, Sep 27, 2012 at 10:51 AM, Felipe Balbi ba...@ti.com wrote:
 On Thu, Sep 27, 2012 at 10:32:01AM +0300, Andy Shevchenko wrote:
 Append myself to the mail entry of the section as well.

 Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
 ---
  MAINTAINERS |4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

 diff --git a/MAINTAINERS b/MAINTAINERS
 index 7dfd0eb..b87cbb1d 100644
 --- a/MAINTAINERS
 +++ b/MAINTAINERS
 @@ -5999,10 +5999,10 @@ F:drivers/tty/serial

  SYNOPSYS DESIGNWARE DMAC DRIVER
  M:   Viresh Kumar viresh.li...@gmail.com
 +M:   Andy Shevchenko andriy.shevche...@linux.intel.com

 this needs to be agreed with Viresh first, I guess. Not sure if it was
 done or not. If it was, sorry for the noise ;-)
Indeed, it's under discussion. I just have a talk with colleagues, and
they mostly convinced me in unnecessity of that change.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv3 4/7] dmaengine: dw_dmac: amend description and indentation

2012-09-27 Thread Andy Shevchenko
On Thu, Sep 27, 2012 at 11:19 AM, viresh kumar viresh.ku...@linaro.org wrote:
 On Thu, Sep 27, 2012 at 1:15 PM, Felipe Balbi ba...@ti.com wrote:
 On Thu, Sep 27, 2012 at 10:31:58AM +0300, Andy Shevchenko wrote:
 From: Heikki Krogerus heikki.kroge...@linux.intel.com

 The driver will be used as a core part for various implementations of the
 DesignWare DMA device. The patch adjusts description on the top and corrects
 paragraph indentation in few places across the code.

 Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
 Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
 ---
  drivers/dma/dw_dmac.c |7 ---
  1 file changed, 4 insertions(+), 3 deletions(-)

 diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
 index bbb2a82..9f0129d 100644
 --- a/drivers/dma/dw_dmac.c
 +++ b/drivers/dma/dw_dmac.c
 @@ -1,14 +1,15 @@
  /*
 - * Driver for the Synopsys DesignWare DMA Controller (aka DMACA on
 - * AVR32 systems.)
 + * Core driver for the Synopsys DesignWare DMA Controller
   *
   * Copyright (C) 2007-2008 Atmel Corporation
   * Copyright (C) 2010-2011 ST Microelectronics
 + * Copyright (C) 2012 Intel Corporation

 I'm not a lawyer, but I'm not sure the few changes done to this driver
 is enough for Intel to hold a copyright here... dunno, though.

 Neither do i :)
I only have one precedent where was a collision between two versions
of the as3645a driver.
In the result Nokia's version was modified accordingly to my comments
and few patches.

 @Vinod: Can we have some inputs from you here?
Agree, it's good to have an additional opinion here.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv3 5/7] dmaengine: dw_dmac: add PCI part of the driver

2012-09-27 Thread Andy Shevchenko
On Thu, 2012-09-27 at 14:14 +0530, Vinod Koul wrote: 
  +static int __devinit dw_pci_probe(struct pci_dev *pdev,
  + const struct pci_device_id *id)
  +{
 ...
  +
  +   pd = platform_device_alloc(dw_dmac, instance);
 Why can't the core driver library be agnostic. Why do we care if the
 device is platform, pci or something else. 
 There is nothing in dma API callbacks which driver implements that
 warrants it to be some device.
 
 You have already taken care of dma controller accesses be arch
 independent so I don't see a reason why this should be done?
I'm afraid I didn't get you comment.


-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv3] dw_dmac: autoconfigure data_width or get it via platform data

2012-09-27 Thread Andy Shevchenko
On Thu, 2012-09-27 at 16:03 +0530, Vinod Koul wrote: 
 On Thu, 2012-09-27 at 15:36 +0530, Vinod Koul wrote:
  On Tue, 2012-09-25 at 14:39 +0300, Andy Shevchenko wrote:
   Not all of the controllers support the 64 bit data width. Make it 
   configurable
   via platform data. The driver will try to get a value from the component
   parameters, otherwise it will use the platform data.
   
  What was this gen against, I can apply this.
  
 
 %s/can/can't
Against linux-next, last used was yesterday's version of it.


-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv3] dw_dmac: autoconfigure data_width or get it via platform data

2012-09-27 Thread Andy Shevchenko
On Thu, Sep 27, 2012 at 1:06 PM, Vinod Koul vinod.k...@linux.intel.com wrote:
 On Tue, 2012-09-25 at 14:39 +0300, Andy Shevchenko wrote:
 Not all of the controllers support the 64 bit data width. Make it 
 configurable
 via platform data. The driver will try to get a value from the component
 parameters, otherwise it will use the platform data.

 What was this gen against, I can apply this.
Just rebased to recent linux-next, no conflicts.
...
Applying: dw_dmac: mark dwc_dump_chan_regs as inline
Applying: dw_dmac: fill optional encoded parameters in register structure
Applying: dw_dmac: get number of channels from hardware if possible
Applying: dw_dmac: autoconfigure block_size or use platform data
Applying: dw_dmac: autoconfigure data_width or get it via platform data
Applying: dw_dmac: introduce software emulation of LLP transfers
...

Have you kept the order of the patches?



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 6/7] usb: core: reuse kbasename()

2012-10-03 Thread Andy Shevchenko
On Tue, Oct 2, 2012 at 6:00 PM, Andy Shevchenko
andriy.shevche...@linux.intel.com wrote:

 --- a/drivers/usb/core/file.c
 +++ b/drivers/usb/core/file.c

 @@ -200,14 +200,9 @@ int usb_register_dev(struct usb_interface *intf,

 /* create a usb class device for this usb interface */
 snprintf(name, sizeof(name), class_driver-name, minor - minor_base);
 -   temp = strrchr(name, '/');
 -   if (temp  (temp[1] != '\0'))
I have checked current linux-next, the drivers define .name in the
usb_class_driver structure as '...%d'.
So, what is the reason to check for trailing '/' here? Historical
reasons or there is a (broken/3rd party/etc) driver with it?

 -   ++temp;
 -   else
 -   temp = name;
 intf-usb_dev = device_create(usb_class-class, intf-dev,
   MKDEV(USB_MAJOR, minor), class_driver,
 - %s, temp);
 + %s, kbasename(name));



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 1/6] string: introduce helper to get base file name from given path

2012-10-03 Thread Andy Shevchenko
There are several places in the kernel that use functionality like basename(3)
with the exception: in case of '/foo/bar/' we expect to get an empty string.
Let's do it common helper for them.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 include/linux/string.h |   11 +++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index b917881..b09a342 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -147,5 +147,16 @@ static inline bool strstarts(const char *str, const char 
*prefix)
 
 extern size_t memweight(const void *ptr, size_t bytes);
 
+/**
+ * kbasename - return the last part of a pathname.
+ *
+ * @path: path to extract the filename from.
+ */
+static inline const char *kbasename(const char *path)
+{
+   const char *tail = strrchr(path, '/');
+   return tail ? tail + 1 : path;
+}
+
 #endif /* __KERNEL__ */
 #endif /* _LINUX_STRING_H_ */
-- 
1.7.10.4

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


[PATCHv2 3/6] staging: rts_pstor: reuse kbasename()

2012-10-03 Thread Andy Shevchenko
The custom filename function mostly repeats the kernel's kbasename. This patch
simplifies it. The updated filename() will not check for the '\' in the
filenames. It seems redundant in Linux.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Cc: YAMANE Toshiaki yamaneto...@gmail.com
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/rts_pstor/trace.h |   16 +++-
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rts_pstor/trace.h 
b/drivers/staging/rts_pstor/trace.h
index cf60a1b..59c5686 100644
--- a/drivers/staging/rts_pstor/trace.h
+++ b/drivers/staging/rts_pstor/trace.h
@@ -24,26 +24,16 @@
 #ifndef __REALTEK_RTSX_TRACE_H
 #define __REALTEK_RTSX_TRACE_H
 
+#include linux/string.h
+
 #define _MSG_TRACE
 
 #ifdef _MSG_TRACE
 static inline char *filename(char *path)
 {
-   char *ptr;
-
if (path == NULL)
return NULL;
-
-   ptr = path;
-
-   while (*ptr != '\0') {
-   if ((*ptr == '\\') || (*ptr == '/'))
-   path = ptr + 1;
-   
-   ptr++;
-   }
-
-   return path;
+   return kbasename(path);
 }
 
 #define TRACE_RET(chip, ret)   
\
-- 
1.7.10.4

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


[PATCHv2 4/6] mm: reuse kbasename() functionality

2012-10-03 Thread Andy Shevchenko
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Cc: linux...@kvack.org
---
 mm/memory.c |8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 0e3a516..6b101a2 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -58,6 +58,7 @@
 #include linux/elf.h
 #include linux/gfp.h
 #include linux/migrate.h
+#include linux/string.h
 
 #include asm/io.h
 #include asm/pgalloc.h
@@ -4034,15 +4035,12 @@ void print_vma_addr(char *prefix, unsigned long ip)
struct file *f = vma-vm_file;
char *buf = (char *)__get_free_page(GFP_KERNEL);
if (buf) {
-   char *p, *s;
+   char *p;
 
p = d_path(f-f_path, buf, PAGE_SIZE);
if (IS_ERR(p))
p = ?;
-   s = strrchr(p, '/');
-   if (s)
-   p = s+1;
-   printk(%s%s[%lx+%lx], prefix, p,
+   printk(%s%s[%lx+%lx], prefix, kbasename(p),
vma-vm_start,
vma-vm_end - vma-vm_start);
free_page((unsigned long)buf);
-- 
1.7.10.4

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


[PATCHv2 6/6] trace: reuse kbasename() functionality

2012-10-03 Thread Andy Shevchenko
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Cc: Steven Rostedt rost...@goodmis.org (maintainer:TRACING)
Cc: Frederic Weisbecker fweis...@gmail.com (maintainer:TRACING)
---
 kernel/trace/trace_uprobe.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 03003cd..a2b2fab 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -22,6 +22,7 @@
 #include linux/uaccess.h
 #include linux/uprobes.h
 #include linux/namei.h
+#include linux/string.h
 
 #include trace_probe.h
 
@@ -263,16 +264,15 @@ static int create_trace_uprobe(int argc, char **argv)
 
/* setup a probe */
if (!event) {
-   char *tail = strrchr(filename, '/');
+   char *tail;
char *ptr;
 
-   ptr = kstrdup((tail ? tail + 1 : filename), GFP_KERNEL);
+   tail = ptr = kstrdup(kbasename(filename), GFP_KERNEL);
if (!ptr) {
ret = -ENOMEM;
goto fail_address_parse;
}
 
-   tail = ptr;
ptr = strpbrk(tail, .-_);
if (ptr)
*ptr = '\0';
-- 
1.7.10.4

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


[PATCHv2 5/6] procfs: reuse kbasename() functionality

2012-10-03 Thread Andy Shevchenko
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 fs/proc/proc_devtree.c |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c
index df7dd08..3d9fd66 100644
--- a/fs/proc/proc_devtree.c
+++ b/fs/proc/proc_devtree.c
@@ -13,6 +13,7 @@
 #include linux/of.h
 #include linux/module.h
 #include linux/slab.h
+#include linux/string.h
 #include asm/prom.h
 #include asm/uaccess.h
 #include internal.h
@@ -195,11 +196,7 @@ void proc_device_tree_add_node(struct device_node *np,
set_node_proc_entry(np, de);
for (child = NULL; (child = of_get_next_child(np, child));) {
/* Use everything after the last slash, or the full name */
-   p = strrchr(child-full_name, '/');
-   if (!p)
-   p = child-full_name;
-   else
-   ++p;
+   p = kbasename(child-full_name);
 
if (duplicate_name(de, p))
p = fixup_name(np, de, p);
-- 
1.7.10.4

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


[PATCHv2 2/6] lib: dynamic_debug: reuse kbasename()

2012-10-03 Thread Andy Shevchenko
Remove the custom implementation of the functionality similar to kbasename().

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Cc: Jason Baron jba...@redhat.com
---
 lib/dynamic_debug.c |9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index e7f7d99..1db1fc6 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -62,13 +62,6 @@ static LIST_HEAD(ddebug_tables);
 static int verbose = 0;
 module_param(verbose, int, 0644);
 
-/* Return the last part of a pathname */
-static inline const char *basename(const char *path)
-{
-   const char *tail = strrchr(path, '/');
-   return tail ? tail+1 : path;
-}
-
 /* Return the path relative to source root */
 static inline const char *trim_prefix(const char *path)
 {
@@ -154,7 +147,7 @@ static int ddebug_change(const struct ddebug_query *query,
/* match against the source filename */
if (query-filename 
strcmp(query-filename, dp-filename) 
-   strcmp(query-filename, basename(dp-filename)) 
+   strcmp(query-filename, kbasename(dp-filename)) 
strcmp(query-filename, trim_prefix(dp-filename)))
continue;
 
-- 
1.7.10.4

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


[PATCHv2 0/6] lib/string: introduce kbasename helper

2012-10-03 Thread Andy Shevchenko
There are several places in kernel that duplicate code to get last part of the 
pathname.
This patchset introduces a helper.

Since v1:
 - fix changelog of the patch 1 - we are doing basname(3) alike helper
 - usb related patch temporary excluded from series (under discussion with
   Greg)

Andy Shevchenko (6):
  string: introduce helper to get base file name from given path
  lib: dynamic_debug: reuse kbasename()
  staging: rts_pstor: reuse kbasename()
  mm: reuse kbasename() functionality
  procfs: reuse kbasename() functionality
  trace: reuse kbasename() functionality

 drivers/staging/rts_pstor/trace.h |   16 +++-
 fs/proc/proc_devtree.c|7 ++-
 include/linux/string.h|   11 +++
 kernel/trace/trace_uprobe.c   |6 +++---
 lib/dynamic_debug.c   |9 +
 mm/memory.c   |8 +++-
 6 files changed, 23 insertions(+), 34 deletions(-)

-- 
1.7.10.4

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


[PATCHv2.5] trace: reuse kbasename() functionality

2012-10-03 Thread Andy Shevchenko
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Cc: Steven Rostedt rost...@goodmis.org
Cc: Frederic Weisbecker fweis...@gmail.com
---
 kernel/trace/trace_uprobe.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 03003cd..c7ba4f6 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -22,6 +22,7 @@
 #include linux/uaccess.h
 #include linux/uprobes.h
 #include linux/namei.h
+#include linux/string.h
 
 #include trace_probe.h
 
@@ -263,16 +264,15 @@ static int create_trace_uprobe(int argc, char **argv)
 
/* setup a probe */
if (!event) {
-   char *tail = strrchr(filename, '/');
+   char *tail;
char *ptr;
 
-   ptr = kstrdup((tail ? tail + 1 : filename), GFP_KERNEL);
-   if (!ptr) {
+   tail = kstrdup(kbasename(filename), GFP_KERNEL);
+   if (!tail) {
ret = -ENOMEM;
goto fail_address_parse;
}
 
-   tail = ptr;
ptr = strpbrk(tail, .-_);
if (ptr)
*ptr = '\0';
-- 
1.7.10.4

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


Re: [PATCHv3 5/7] dmaengine: dw_dmac: add PCI part of the driver

2012-10-03 Thread Andy Shevchenko
On Thu, Sep 27, 2012 at 1:32 PM, Vinod Koul vinod.k...@linux.intel.com wrote:
 On Thu, 2012-09-27 at 15:41 +0530, viresh kumar wrote:
 On Thu, Sep 27, 2012 at 3:31 PM, Vinod Koul vinod.k...@linux.intel.com 
 wrote:
  Let me try again.
 
  what does it take to do platform and PCI driver for this:
  1. make dma h/w access (read/write) platform independent. which you have
  already done
  2. Device registration: Create two probes, or use common probe.
  You smartly chose the second one BUT by creating another device.
  If you look closely at the probe then I would say it would be easy to
  create library for probe which can be used across both pci and platform
  driver probes. The probe library which initializes driver and registers
  with dmaengine needs device struct and resources can be provided by each
  probe.

 Or in other words... create three files
 - dw_dmac.c
 - dw_dmac-pltfm.c
 - dw_dmac-pci.c...

 Don't do anything specific to platform or pci in dw_dmac.c...
 Keep pltfm and pci files to smallest possible size, and keep as much of
 common part in dmac.c...

 Similar is done in drivers/mmc/host/sdhci*...
 Yes that IMHO would be simpler approach :)
Oh, thanks, I got the idea. Will implement soon.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/7] string: introduce helper to get base file name from given path

2012-10-04 Thread Andy Shevchenko
On Wed, 2012-10-03 at 14:39 -0400, Nick Bowler wrote: 
 On 2012-10-02 11:12 -0700, Greg KH wrote:
  On Tue, Oct 02, 2012 at 08:52:05PM +0300, Andy Shevchenko wrote:
   On Tue, Oct 2, 2012 at 8:34 PM, Greg KH gre...@linuxfoundation.org 
   wrote:

[...]

  Well, if you want your kbasename() function to work like the basename(3)
  function, you need to properly handle a trailing '/' character.
 
 Specifically, POSIX basename trims trailing '/' characters, so
 
   char foo[] = a/string/with/trailing/slashes///;
   basename(foo);
 
 results in a string that compares equal to slashes.  This implies that
 it must either modify the provided string or copy it somewhere else
 (POSIX admits either behaviour).
 
 On the other hand, GNU basename does not trim trailing '/' characters
 and returns the empty string in this case.  It's truly unfortunate that
 glibc contains two different functions called basename, but regardless,
 the behaviour of the function in this proposal is certainly not
 unprecedented.
I fixed the description of the patch in v2.

-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv2.5] trace: reuse kbasename() functionality

2012-10-05 Thread Andy Shevchenko
On Fri, Oct 5, 2012 at 7:49 PM, Steven Rostedt rost...@goodmis.org wrote:
 On Wed, 2012-10-03 at 11:53 +0300, Andy Shevchenko wrote:
 Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
 Cc: Steven Rostedt rost...@goodmis.org
 Cc: Frederic Weisbecker fweis...@gmail.com
 ---
  kernel/trace/trace_uprobe.c |8 
  1 file changed, 4 insertions(+), 4 deletions(-)

 diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
 index 03003cd..c7ba4f6 100644
 --- a/kernel/trace/trace_uprobe.c
 +++ b/kernel/trace/trace_uprobe.c
 @@ -22,6 +22,7 @@
  #include linux/uaccess.h
  #include linux/uprobes.h
  #include linux/namei.h
 +#include linux/string.h

  #include trace_probe.h

 @@ -263,16 +264,15 @@ static int create_trace_uprobe(int argc, char **argv)

   /* setup a probe */
   if (!event) {
 - char *tail = strrchr(filename, '/');
 + char *tail;
   char *ptr;

 - ptr = kstrdup((tail ? tail + 1 : filename), GFP_KERNEL);
 - if (!ptr) {
 + tail = kstrdup(kbasename(filename), GFP_KERNEL);

 I don't see kbasename() anywhere. Is this based off of other patches?
It's introduced by first patch in the series.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv2.5] trace: reuse kbasename() functionality

2012-10-05 Thread Andy Shevchenko
On Fri, Oct 5, 2012 at 8:12 PM, Steven Rostedt rost...@goodmis.org wrote:
 On Fri, 2012-10-05 at 20:02 +0300, Andy Shevchenko wrote:

  I don't see kbasename() anywhere. Is this based off of other patches?
 It's introduced by first patch in the series.
 Usually a series has the format of:

 [PATCH x/n] 

 Where x is the patch number and n is the total number of patches. I'm
 not sure what a v2.5 is. This is version 2 and a half?
Ah, it's an update to patch 6/6. You could see it by
Message-Id/In-Reply-To chains.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv3 5/7] dmaengine: dw_dmac: add PCI part of the driver

2012-10-08 Thread Andy Shevchenko
On Thu, 2012-09-27 at 15:41 +0530, viresh kumar wrote: 
 On Thu, Sep 27, 2012 at 3:31 PM, Vinod Koul vinod.k...@linux.intel.com 
 wrote:
  Let me try again.
 
  what does it take to do platform and PCI driver for this:
  1. make dma h/w access (read/write) platform independent. which you have
  already done
  2. Device registration: Create two probes, or use common probe.
  You smartly chose the second one BUT by creating another device.
  If you look closely at the probe then I would say it would be easy to
  create library for probe which can be used across both pci and platform
  driver probes. The probe library which initializes driver and registers
  with dmaengine needs device struct and resources can be provided by each
  probe.
 
 Or in other words... create three files
 - dw_dmac.c
 - dw_dmac-pltfm.c
 - dw_dmac-pci.c...
 
 Don't do anything specific to platform or pci in dw_dmac.c...
 Keep pltfm and pci files to smallest possible size, and keep as much of
 common part in dmac.c...
 
 Similar is done in drivers/mmc/host/sdhci*...

This approach has the significant differences to proposed before.

First of all it will export IP-block relevant functions to the kernel
namespace. I think it is not a good idea to pollute kernel more.
Moreover the API dependencies disallow transparent build and usage of
the drivers. For example, you can't built-in platform driver and leave
core part as a module. And there is at least one device, Intel Medfield,
where DMA controller is exposed as PCI device on fake PCI bus. In that
case the initialization sequence matters and the easier way is to
provide independent drivers for platform device. 


-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv3 5/7] dmaengine: dw_dmac: add PCI part of the driver

2012-10-08 Thread Andy Shevchenko
On Mon, 2012-10-08 at 16:19 +0530, Viresh Kumar wrote: 
 On 8 October 2012 15:47, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
  This approach has the significant differences to proposed before.
 
 I am afraid i didn't get your mail completely. Still i will try based on my
 understanding.
Ok, let me try again.

  First of all it will export IP-block relevant functions to the kernel
  namespace. I think it is not a good idea to pollute kernel more.
 
 So, few routines which are required to be called from probe,
 suspend/resume and exit would be made non-static... This is what you
 wanted to say? Hopefully most of the routines would still be declared
 static in the core file. So IMHO, the simplicity or clarity that new approach
 gives has more advantages than this aspect.
The probe (core part), remove, shutdown, suspend, and resume will be
exported. Practically each generic function which will be used in
drivers outside of core. Why do we need them in the kernel namespace?

  Moreover the API dependencies disallow transparent build and usage of
  the drivers. For example, you can't built-in platform driver and leave
  core part as a module.
 Obviously... Should be done this way only...
I could not agree. I don't see any reason why this is the only way.

 What if core driver isn't inserted
 and platform's probe is already called.
Nothing will happen in my case until user loads all necessary bits.

 That's why depends-on should not
 allow you to make core part as module alone...
 I couldn't get the issue completely. What's the problem in this approach?

Why we need to do this if we could avoid it? I see nothing to prevent us
to build parts as modules, or otherwise, or mixed style.
In other words one approach provides weak dependency and the other -
hard dependency between pieces of code.



-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH, resend] of: re-use kernel's kbasename()

2012-11-05 Thread Andy Shevchenko
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Acked-by: Grant Likely grant.lik...@secretlab.ca
Cc: Rob Herring rob.herr...@calxeda.com
---
 drivers/of/fdt.c |   10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 91a375f..0ca0f9e 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -486,14 +486,8 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
depth++;
pathp = (char *)p;
p = ALIGN(p + strlen(pathp) + 1, 4);
-   if ((*pathp) == '/') {
-   char *lp, *np;
-   for (lp = NULL, np = pathp; *np; np++)
-   if ((*np) == '/')
-   lp = np+1;
-   if (lp != NULL)
-   pathp = lp;
-   }
+   if (*pathp == '/')
+   pathp = kbasename(pathp);
rc = it(p, pathp, depth, data);
if (rc != 0)
break;
-- 
1.7.10.4

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


[PATCH] dw_dmac: call .probe after we have a device in place

2012-11-06 Thread Andy Shevchenko
If we don't yet have the platform device for the driver when it is being loaded
we fail to probe the driver. So instead of calling probe() directly we call
platform_driver_register(). It will call the probe() immediately if we have the
device but also makes the driver to work on platforms where the platform device
is created later.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/dma/dw_dmac.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 2c8096d..b0b301b 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -1829,6 +1829,7 @@ MODULE_DEVICE_TABLE(of, dw_dma_id_table);
 #endif
 
 static struct platform_driver dw_driver = {
+   .probe  = dw_probe,
.remove = __devexit_p(dw_remove),
.shutdown   = dw_shutdown,
.driver = {
@@ -1840,7 +1841,7 @@ static struct platform_driver dw_driver = {
 
 static int __init dw_init(void)
 {
-   return platform_driver_probe(dw_driver, dw_probe);
+   return platform_driver_register(dw_driver);
 }
 subsys_initcall(dw_init);
 
-- 
1.7.10.4

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


Re: [PATCH 2/4] dmaengine: dw_dmac: add module alias

2012-10-10 Thread Andy Shevchenko
On Tue, 2012-10-02 at 14:41 +0300, Andy Shevchenko wrote: 
 From: Heikki Krogerus heikki.kroge...@linux.intel.com
 
 It's good to have a quasistatic name for the platform driver.
Please, do not push this one.
It makes no sense now. Better we have it after a split.

 
 Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
 Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
 Reviewed-by: Felipe Balbi ba...@ti.com
 Acked-by: Viresh Kumar viresh.ku...@linaro.org
 ---
  drivers/dma/dw_dmac.c |1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
 index 0b88ced..bbb2a82 100644
 --- a/drivers/dma/dw_dmac.c
 +++ b/drivers/dma/dw_dmac.c
 @@ -1712,6 +1712,7 @@ static struct platform_driver dw_driver = {
  
  module_platform_driver(dw_driver);
  
 +MODULE_ALIAS(platform:dw_dmac);
  MODULE_LICENSE(GPL v2);
  MODULE_DESCRIPTION(Synopsys DesignWare DMA Controller driver);
  MODULE_AUTHOR(Haavard Skinnemoen (Atmel));

-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/4] dmaengine: dw_dmac: use helper macro module_platform_driver()

2012-10-10 Thread Andy Shevchenko
On Tue, 2012-10-02 at 14:41 +0300, Andy Shevchenko wrote: 
 From: Heikki Krogerus heikki.kroge...@linux.intel.com
 
 Since v3.2 we have nice macro to define the platform driver's init and exit
 calls. This patch simplifies the dw_dmac driver by using that macro.

Actually we can't do this. It will break initialization of some other
drivers.


 
 Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
 Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
 Reviewed-by: Felipe Balbi ba...@ti.com
 Acked-by: Viresh Kumar viresh.ku...@linaro.org
 ---
  drivers/dma/dw_dmac.c |   13 ++---
  1 file changed, 2 insertions(+), 11 deletions(-)
 
 diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
 index c4b0eb3..0b88ced 100644
 --- a/drivers/dma/dw_dmac.c
 +++ b/drivers/dma/dw_dmac.c
 @@ -1700,6 +1700,7 @@ MODULE_DEVICE_TABLE(of, dw_dma_id_table);
  #endif
  
  static struct platform_driver dw_driver = {
 + .probe  = dw_probe,
   .remove = __devexit_p(dw_remove),
   .shutdown   = dw_shutdown,
   .driver = {
 @@ -1709,17 +1710,7 @@ static struct platform_driver dw_driver = {
   },
  };
  
 -static int __init dw_init(void)
 -{
 - return platform_driver_probe(dw_driver, dw_probe);
 -}
 -subsys_initcall(dw_init);
 -
 -static void __exit dw_exit(void)
 -{
 - platform_driver_unregister(dw_driver);
 -}
 -module_exit(dw_exit);
 +module_platform_driver(dw_driver);
  
  MODULE_LICENSE(GPL v2);
  MODULE_DESCRIPTION(Synopsys DesignWare DMA Controller driver);

-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/4] dmaengine: dw_dmac: use helper macro module_platform_driver()

2012-10-10 Thread Andy Shevchenko
On Wed, Oct 10, 2012 at 12:08 PM, viresh kumar viresh.ku...@linaro.org wrote:
 On Wed, Oct 10, 2012 at 2:34 PM, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
 On Tue, 2012-10-02 at 14:41 +0300, Andy Shevchenko wrote:
 From: Heikki Krogerus heikki.kroge...@linux.intel.com

 Since v3.2 we have nice macro to define the platform driver's init and exit
 calls. This patch simplifies the dw_dmac driver by using that macro.

 Actually we can't do this. It will break initialization of some other
 drivers.

 why?

We have spi, i2c and hsuart devices connected to the DMA controller.
In case we would like to use DMA we have to have the dw_dmac loaded
before them. Currently we have spi driver on subsys_initcall level,
and Mika, who is developing it, will change to module_init_call level.
However, it will just hide the potential issue. He also tried to use
deferred module loading, but we don't know if it's good solution or
not, and that solution requires something to stop deferring at some
moment.

Might be we missed something and there is a better solution.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/4] dmaengine: dw_dmac: use helper macro module_platform_driver()

2012-10-10 Thread Andy Shevchenko
On Wed, Oct 10, 2012 at 3:40 PM, Felipe Balbi ba...@ti.com wrote:
 On Wed, Oct 10, 2012 at 12:21:04PM +0300, Andy Shevchenko wrote:
 On Wed, Oct 10, 2012 at 12:08 PM, viresh kumar viresh.ku...@linaro.org 
 wrote:
  On Wed, Oct 10, 2012 at 2:34 PM, Andy Shevchenko
  andriy.shevche...@linux.intel.com wrote:
  On Tue, 2012-10-02 at 14:41 +0300, Andy Shevchenko wrote:
  From: Heikki Krogerus heikki.kroge...@linux.intel.com
 
  Since v3.2 we have nice macro to define the platform driver's init and 
  exit
  calls. This patch simplifies the dw_dmac driver by using that macro.
 
  Actually we can't do this. It will break initialization of some other
  drivers.
 
  why?

 We have spi, i2c and hsuart devices connected to the DMA controller.
 In case we would like to use DMA we have to have the dw_dmac loaded
 before them. Currently we have spi driver on subsys_initcall level,
 and Mika, who is developing it, will change to module_init_call level.
 However, it will just hide the potential issue. He also tried to use
 deferred module loading, but we don't know if it's good solution or
 not, and that solution requires something to stop deferring at some
 moment.

 Might be we missed something and there is a better solution.

 if they can only work with DMA, they should return -EPROBE_DEFER so
 their probe() function can be called after DMA driver has finished
 probing.

They could work either with DMA or via PIO mode.
How does the driver know when to stop to return -EPROBE_DEFER?

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] dmaengine: dw_dmac: Enhance device tree support

2012-10-12 Thread Andy Shevchenko
/drivers/dma/dw_dmac_regs.h
 @@ -231,6 +231,10 @@ struct dw_dma {
   struct tasklet_struct   tasklet;
   struct clk  *clk;
  
 + /* slave information */
 + struct dw_dma_slave *sd;
 + unsigned intsd_count;
 +
   u8  all_chan_mask;
  
   /* hardware configuration */
 diff --git a/include/linux/dw_dmac.h b/include/linux/dw_dmac.h
 index 62a6190..4d1c8c3 100644
 --- a/include/linux/dw_dmac.h
 +++ b/include/linux/dw_dmac.h
 @@ -15,6 +15,26 @@
  #include linux/dmaengine.h
  
  /**
 + * struct dw_dma_slave - Controller-specific information about a slave
 + *
 + * @dma_dev: required DMA master device. Depricated.
 + * @bus_id: name of this device channel, not just a device name since
 + *  devices may have more than one channel e.g. foo_tx
 + * @cfg_hi: Platform-specific initializer for the CFG_HI register
 + * @cfg_lo: Platform-specific initializer for the CFG_LO register
 + * @src_master: src master for transfers on allocated channel.
 + * @dst_master: dest master for transfers on allocated channel.
 + */
 +struct dw_dma_slave {
 + struct device   *dma_dev;
 + const char  *bus_id;
 + u32 cfg_hi;
 + u32 cfg_lo;
 + u8  src_master;
 + u8  dst_master;
 +};
 +
 +/**
   * struct dw_dma_platform_data - Controller configuration parameters
   * @nr_channels: Number of channels supported by hardware (max 8)
   * @is_private: The device channels should be marked as private and not for
 @@ -25,6 +45,8 @@
   * @nr_masters: Number of AHB masters supported by the controller
   * @data_width: Maximum data width supported by hardware per AHB master
   *   (0 - 8bits, 1 - 16bits, ..., 5 - 256bits)
 + * @sd: slave specific data. Used for configuring channels
 + * @sd_count: count of slave data structures passed.
   */
  struct dw_dma_platform_data {
   unsigned intnr_channels;
 @@ -38,6 +60,9 @@ struct dw_dma_platform_data {
   unsigned short  block_size;
   unsigned char   nr_masters;
   unsigned char   data_width[4];
 +
 + struct dw_dma_slave *sd;
 + unsigned int sd_count;
  };
  
  /* bursts size */
 @@ -52,23 +77,6 @@ enum dw_dma_msize {
   DW_DMA_MSIZE_256,
  };
  
 -/**
 - * struct dw_dma_slave - Controller-specific information about a slave
 - *
 - * @dma_dev: required DMA master device
 - * @cfg_hi: Platform-specific initializer for the CFG_HI register
 - * @cfg_lo: Platform-specific initializer for the CFG_LO register
 - * @src_master: src master for transfers on allocated channel.
 - * @dst_master: dest master for transfers on allocated channel.
 - */
 -struct dw_dma_slave {
 - struct device   *dma_dev;
 - u32 cfg_hi;
 - u32 cfg_lo;
 - u8  src_master;
 - u8  dst_master;
 -};
 -
  /* Platform-configurable bits in CFG_HI */
  #define DWC_CFGH_FCMODE  (1  0)
  #define DWC_CFGH_FIFO_MODE   (1  1)
 @@ -106,5 +114,6 @@ void dw_dma_cyclic_stop(struct dma_chan *chan);
  dma_addr_t dw_dma_get_src_addr(struct dma_chan *chan);
  
  dma_addr_t dw_dma_get_dst_addr(struct dma_chan *chan);
 +bool dw_generic_filter(struct dma_chan *chan, void *param);
  
  #endif /* DW_DMAC_H */

-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] dmaengine: dw_dmac: Enhance device tree support

2012-10-12 Thread Andy Shevchenko
On Fri, Oct 12, 2012 at 11:34 AM, Viresh Kumar viresh.ku...@linaro.org wrote:
 On 12 October 2012 13:53, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
 On Fri, 2012-10-12 at 11:14 +0530, Viresh Kumar wrote:

 diff --git a/Documentation/devicetree/bindings/dma/snps-dma.txt 
 b/Documentation/devicetree/bindings/dma/snps-dma.txt
 @@ -14,4 +34,28 @@ Example:
   reg = 0xfc00 0x1000;
   interrupt-parent = vic1;
   interrupts = 12;
 +
 + nr_channels = 8;
 + chan_allocation_order = 1;
 + chan_priority = 1;
 + block_size = 0xfff;
 + nr_masters = 2;
 + data_width = 3 3 0 0;
 +
 + slave_info {
 + uart0-tx {
 + bus_id = uart0-tx;
 + cfg_hi = 0x4000;  /* 0x8  11 */
 + cfg_lo = 0;
 + src_master = 0;
 + dst_master = 1;
 + };
 + spi0-tx {
 + bus_id = spi0-tx;
 + cfg_hi = 0x2000;  /* 0x4  11 */
 + cfg_lo = 0;
 + src_master = 0;
 + dst_master = 0;
 + };
 + };
 Why do you locate slave information under DMA controller node? From my
 point of view the slave info belongs to corresponding device. For
 example, above sections belong to UART0 and SPI0.

 Consider one spi driver is used on 5 different platforms with
 different DMA controllers.
 So, 5 DMA drivers and so 5 DMA platform_data. Wherever we add this node, this
 data can't be processed by spi-driver, as we can't add DT processing routines
 for all DMA drivers in spi.

 The best place to process DT nodes is DW_DMAC driver, because it is
 dw_dmac's data.
 That's why i added them under DMA.
Fair enough.

 diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c

 +static struct dw_dma_platform_data *
 +__devinit dw_dma_parse_dt(struct platform_device *pdev)
 +{

 + for_each_child_of_node(sn, cn)
 + count++;
 Is there any other way to get amount of children?

 I tried my best to find one, referred to lots of drivers. And found
 this way in most of the places. ex: drivers/pinctrl/***
I understand your way of allocating memory, but what about using
linked list instead of array?

And one more thing. May be we could introduce backlink to the platform
data in the dw_dma structure instead of copying certain parameters?

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] dmaengine: dw_dmac: Enhance device tree support

2012-10-12 Thread Andy Shevchenko
On Fri, Oct 12, 2012 at 1:36 PM, viresh kumar viresh.ku...@linaro.org wrote:
 On Fri, Oct 12, 2012 at 1:53 PM, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
 On Fri, 2012-10-12 at 11:14 +0530, Viresh Kumar wrote:

 + while (++i  dw-sd_count) {
 + if (!strcmp(dw-sd[i].bus_id, param)) {
 + found = 1;
 + break;
 + }
 + }
 +
 + if (!found) {
 + last_dw = dw;
 + last_bus_id = param;
 + return false;
 Because of return here you could eliminate 'found' flag at all.
 how?

while (++i  dw-sd_count) {
   if (!strcmp(dw-sd[i].bus_id, param)) {
   chan-private = dw-sd[i];
   last_dw = NULL;
   last_bus_id = NULL;

   return true;
   }
   }

   last_dw = dw;
   last_bus_id = param;
   return false;

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] dmaengine: dw_dmac: Enhance device tree support

2012-10-12 Thread Andy Shevchenko
On Fri, Oct 12, 2012 at 2:01 PM, Viresh Kumar viresh.ku...@linaro.org wrote:
 On 12 October 2012 16:10, Andy Shevchenko andy.shevche...@gmail.com wrote:
 + if (!found) {
 + last_dw = dw;
 + last_bus_id = param;
 + return false;
 Because of return here you could eliminate 'found' flag at all.

 Here is the stuff copied from you ;)


 diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
 index a4ff04c..c24859e 100644
 --- a/drivers/dma/dw_dmac.c
 +++ b/drivers/dma/dw_dmac.c
 @@ -1184,7 +1184,7 @@ bool dw_generic_filter(struct dma_chan *chan, void 
 *param)
 struct dw_dma *dw = to_dw_dma(chan-device);
 static struct dw_dma *last_dw;
 static char *last_bus_id;
 -   int found = 0, i = -1;
 +   int i = -1;

 /*
  * dmaengine framework calls this routine for all channels of all dma
 @@ -1212,22 +1212,17 @@ bool dw_generic_filter(struct dma_chan *chan,
 void *param)

 while (++i  dw-sd_count) {
 if (!strcmp(dw-sd[i].bus_id, param)) {
 -   found = 1;
 -   break;
 -   }
 -   }
 +   chan-private = dw-sd[i];
 +   last_dw = NULL;
 +   last_bus_id = NULL;

 -   if (!found) {
 -   last_dw = dw;
 -   last_bus_id = param;
 -   return false;
 +   return true;
 +   }
 }

 -   chan-private = dw-sd[i];
 -   last_dw = NULL;
 -   last_bus_id = NULL;
 -
 -   return true;
 +   last_dw = dw;
 +   last_bus_id = param;
 +   return false;
  }
Yes, that what I refer to.

  EXPORT_SYMBOL(dw_generic_filter);
Could we change a name to be more precise, like dw_dma_generic_filter ?


-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] dmaengine: dw_dmac: Enhance device tree support

2012-10-12 Thread Andy Shevchenko
On Fri, 2012-10-12 at 11:14 +0530, Viresh Kumar wrote: 
 dw_dmac driver already supports device tree but it used to have its platform
 data passed the non-DT way.
Another portion of comments.

 diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c

 +static struct dw_dma_platform_data *
 +__devinit dw_dma_parse_dt(struct platform_device *pdev)
 +{
 + struct device_node *sn, *cn, *np = pdev-dev.of_node;
 + struct dw_dma_platform_data *pdata;
 + struct dw_dma_slave *sd;
 + u32 count, val, arr[4];
 +
 + if (!np) {
 + dev_err(pdev-dev, Missing DT data\n);
 + return NULL;
 + }
 +
 + pdata = devm_kzalloc(pdev-dev, sizeof(*pdata), GFP_KERNEL);
 + if (!pdata)
 + return NULL;
 +
 + if (of_property_read_u32(np, nr_channels, pdata-nr_channels))
 + return NULL;
 +
 + if (of_property_read_bool(np, is_private))
 + pdata-is_private = true;
 +
 + if (!of_property_read_u32(np, chan_allocation_order,
 + val))
Fits one line?

 + pdata-chan_allocation_order = (unsigned char)val;
do we really need explicit casting here?

 +
 + if (!of_property_read_u32(np, chan_priority, val))
 + pdata-chan_priority = (unsigned char)val;
ditto

 +
 + if (!of_property_read_u32(np, block_size, val))
 + pdata-block_size = (unsigned short)val;
ditto 
 +
 + if (!of_property_read_u32(np, nr_masters, val)) {
 + if (val  4)
I thought once that we might introduce constant like #define
DW_MAX_AHB_MASTERS 4. It seems a bit useless because hw is designed for
that number anyway, but maybe you have another opinion. 

 + return NULL;
 +
 + pdata-nr_masters = (unsigned char)val;
 + }
 +
 + if (!of_property_read_u32_array(np, data_width, arr,
 + pdata-nr_masters))
 + for (count = 0; count  pdata-nr_masters; count++)
 + pdata-data_width[count] = arr[count];
Ah, it would be nice to have of_property_read_u8_array and so on...

 +
 + /* parse slave data */
 + sn = of_find_node_by_name(np, slave_info);
 + if (!sn)
 + return pdata;
 +
 + count = 0;
 + /* calculate number of slaves */
 + for_each_child_of_node(sn, cn)
 + count++;

of.h: static inline int of_get_child_count(const struct device_node *np)


 +
 + if (!count)
 + return NULL;
 +
 + sd = devm_kzalloc(pdev-dev, sizeof(*sd) * count, GFP_KERNEL);
 + if (!sd)
 + return NULL;
 +
 + count = 0;
 + for_each_child_of_node(sn, cn) {
 + of_property_read_string(cn, bus_id, sd[count].bus_id);
 + of_property_read_u32(cn, cfg_hi, sd[count].cfg_hi);
 + of_property_read_u32(cn, cfg_lo, sd[count].cfg_lo);
 + if (!of_property_read_u32(cn, src_master, val))
 + sd[count].src_master = (u8)val;
Explicit casting?

 +
 + if (!of_property_read_u32(cn, dst_master, val))
 + sd[count].dst_master = (u8)val;
ditto 
 +
 + sd[count].dma_dev = pdev-dev;
 + count++;
 + }

what about to define sd as sd[0]; in the platform_data structure and
then use smth like following

struct ... *sd = pdata-sd;
for_each... {
sd-... = ;
sd++;
}

it will probably require to split this part in a separate function and
calculate count of slave_info children before pdata memory allocation.


 +
 + pdata-sd = sd;
 + pdata-sd_count = count;
 +
 + return pdata;
 +}

-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V2 2/3] dmaengine: dw_dmac: Enhance device tree support

2012-10-12 Thread Andy Shevchenko
On Fri, 2012-10-12 at 20:01 +0530, Viresh Kumar wrote:

 diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c

 @@ -1179,6 +1179,53 @@ static void dwc_free_chan_resources(struct dma_chan 
 *chan)
   dev_vdbg(chan2dev(chan), %s: done\n, __func__);
  }
  
 +bool dw_dma_generic_filter(struct dma_chan *chan, void *param)
 +{
 + struct dw_dma *dw = to_dw_dma(chan-device);
 + static struct dw_dma *last_dw;
 + static char *last_bus_id;
 + int i = -1;
 +
 + /*
 +  * dmaengine framework calls this routine for all channels of all dma
 +  * controller, until true is returned. If 'param' bus_id is not
 +  * registered with a dma controller (dw), then there is no need of
 +  * running below function for all channels of dw.
 +  *
 +  * This block of code does this by saving the parameters of last
 +  * failure. If dw and param are same, i.e. trying on same dw with
 +  * different channel, return false.
 +  */
 + if (last_dw) {
 + if ((last_bus_id == param)  (last_dw == dw))
 + return false;
 + }
Just came to my mind.
dw can't be NULL, can't it?
Then
if (last_dw) {
...
}
is unneeded.

Please, check twice my thought because it's a Friday evening.

 @@ -1462,6 +1509,91 @@ static void dw_dma_off(struct dw_dma *dw)
   dw-chan[i].initialized = false;
  }
  
 +#ifdef CONFIG_OF
 +static struct dw_dma_platform_data *
 +__devinit dw_dma_parse_dt(struct platform_device *pdev)
 +{
 + struct device_node *sn, *cn, *np = pdev-dev.of_node;
 + struct dw_dma_platform_data *pdata;
 + struct dw_dma_slave *sd;
 + u32 val, arr[4];
Let me weekend to think about naming. I really can't offer anything else
right now.


-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V2 2/3] dmaengine: dw_dmac: Enhance device tree support

2012-10-12 Thread Andy Shevchenko
On Fri, Oct 12, 2012 at 6:18 PM, Viresh Kumar viresh.ku...@linaro.org wrote:
 On 12 October 2012 20:28, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
 On Fri, 2012-10-12 at 20:01 +0530, Viresh Kumar wrote:

 + if (last_dw) {
 + if ((last_bus_id == param)  (last_dw == dw))
 + return false;
 + }
1. This is an equivalent of
if (last_dw  (last_bus_id == ... )  (last_dw == dw))
 return false;
2. In case dw is always non-NULL the last_dw == dw is false if last_dw is NULL.

Where am I wrong?

 You are already drunk.
Not yet, but tired.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] dw_dmac: absence of pdata isn't critical when autocfg is set

2012-11-12 Thread Andy Shevchenko
The patch allows to probe the device when platform data is absent and hardware
auto configuration is enabled. In that case the default platform data is used
where the channel allocation order is set to ascending, channel priority is set
to ascending, and private property is set to true.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/dma/dw_dmac.c |   15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 2c8096d..0ec5c84 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -1585,6 +1585,12 @@ dw_dma_parse_dt(struct platform_device *pdev)
 }
 #endif
 
+static struct dw_dma_platform_data dw_dma_pdata = {
+   .is_private = true,
+   .chan_allocation_order = CHAN_ALLOCATION_ASCENDING,
+   .chan_priority = CHAN_PRIORITY_ASCENDING,
+};
+
 static int __devinit dw_probe(struct platform_device *pdev)
 {
struct dw_dma_platform_data *pdata;
@@ -1604,9 +1610,6 @@ static int __devinit dw_probe(struct platform_device 
*pdev)
if (!pdata)
pdata = dw_dma_parse_dt(pdev);
 
-   if (!pdata || pdata-nr_channels  DW_DMA_MAX_NR_CHANNELS)
-   return -EINVAL;
-
io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!io)
return -EINVAL;
@@ -1622,6 +1625,12 @@ static int __devinit dw_probe(struct platform_device 
*pdev)
dw_params = dma_read_byaddr(regs, DW_PARAMS);
autocfg = dw_params  DW_PARAMS_EN  0x1;
 
+   if (!pdata  autocfg)
+   pdata = dw_dma_pdata;
+
+   if (!pdata || pdata-nr_channels  DW_DMA_MAX_NR_CHANNELS)
+   return -EINVAL;
+
if (autocfg)
nr_channels = (dw_params  DW_PARAMS_NR_CHAN  0x7) + 1;
else
-- 
1.7.10.4

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


Re: [PATCH] dw_dmac: absence of pdata isn't critical when autocfg is set

2012-11-12 Thread Andy Shevchenko
On Mon, 2012-11-12 at 19:24 +0530, viresh kumar wrote: 
 On Mon, Nov 12, 2012 at 4:53 PM, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
  diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
 
   static int __devinit dw_probe(struct platform_device *pdev)
   {
  struct dw_dma_platform_data *pdata;
  @@ -1604,9 +1610,6 @@ static int __devinit dw_probe(struct platform_device 
  *pdev)
  if (!pdata)
  pdata = dw_dma_parse_dt(pdev);
 
  -   if (!pdata || pdata-nr_channels  DW_DMA_MAX_NR_CHANNELS)
  -   return -EINVAL;
  -
  io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  if (!io)
  return -EINVAL;
  @@ -1622,6 +1625,12 @@ static int __devinit dw_probe(struct platform_device 
  *pdev)
  dw_params = dma_read_byaddr(regs, DW_PARAMS);
  autocfg = dw_params  DW_PARAMS_EN  0x1;
 
  +   if (!pdata  autocfg)
  +   pdata = dw_dma_pdata;
 
 Allocate it dynamically to support multiple controllers with different
 configuration
 in a SoC.

Like you did for device tree? No problem, but here is the question: what
the default values should be and where we can get them?


-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2] dw_dmac: absence of pdata isn't critical when autocfg is set

2012-11-12 Thread Andy Shevchenko
The patch allows to probe the device when platform data is absent and hardware
auto configuration is enabled. In that case the default platform data is used
where the channel allocation order is set to ascending, channel priority is set
to ascending, and private property is set to true.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
Since v1:
 - allocate memory for pdata dynamically

 drivers/dma/dw_dmac.c |   23 ---
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 2c8096d..a4a5c80 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -1600,13 +1600,6 @@ static int __devinit dw_probe(struct platform_device 
*pdev)
int err;
int i;
 
-   pdata = dev_get_platdata(pdev-dev);
-   if (!pdata)
-   pdata = dw_dma_parse_dt(pdev);
-
-   if (!pdata || pdata-nr_channels  DW_DMA_MAX_NR_CHANNELS)
-   return -EINVAL;
-
io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!io)
return -EINVAL;
@@ -1622,6 +1615,22 @@ static int __devinit dw_probe(struct platform_device 
*pdev)
dw_params = dma_read_byaddr(regs, DW_PARAMS);
autocfg = dw_params  DW_PARAMS_EN  0x1;
 
+   pdata = dev_get_platdata(pdev-dev);
+   if (!pdata)
+   pdata = dw_dma_parse_dt(pdev);
+
+   if (!pdata  autocfg) {
+   pdata = devm_kzalloc(pdev-dev, sizeof(*pdata), GFP_KERNEL);
+   if (!pdata)
+   return -ENOMEM;
+
+   /* Fill platform data with the default values */
+   pdata-is_private = true;
+   pdata-chan_allocation_order = CHAN_ALLOCATION_ASCENDING;
+   pdata-chan_priority = CHAN_PRIORITY_ASCENDING;
+   } else if (!pdata || pdata-nr_channels  DW_DMA_MAX_NR_CHANNELS)
+   return -EINVAL;
+
if (autocfg)
nr_channels = (dw_params  DW_PARAMS_NR_CHAN  0x7) + 1;
else
-- 
1.7.10.4

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


Re: [PATCH REGRESSION FIX] dw_dmac: make driver's endianness configurable

2012-10-14 Thread Andy Shevchenko
On Sun, Oct 14, 2012 at 10:54 AM, Hein Tibosch hein_tibo...@yahoo.es wrote:
 From: Hein Tibosch hein_tibo...@yahoo.es

 The dw_dmac was originally developed for avr32 to be used with the Synopsys
 DesignWare AHB DMA controller. Starting from 2.6.38, access to the device's 
 i/o
 memory was done with the little-endian readl/writel functions(1)

 This broke the driver for the avr32 platform, because it needs big (native)
 endian accessors.
 This patch makes the endianness configurable using 'DW_DMAC_BIG_ENDIAN_IO',
 which will default be true for AVR32

 I submitted this patch before(2) but then waited for Andy to finish other
 changes to the same module(3).

 (1) https://patchwork.kernel.org/patch/608211
 (2) https://lkml.org/lkml/2012/8/26/148
 (3) https://lkml.org/lkml/2012/9/21/173

 Signed-off-by: Hein Tibosch hein_tibo...@yahoo.es

 ---
  drivers/dma/Kconfig|   11 +++
  drivers/dma/dw_dmac_regs.h |   18 +-
  2 files changed, 24 insertions(+), 5 deletions(-)

 diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
 index 677cd6e..d4c1218 100644
 --- a/drivers/dma/Kconfig
 +++ b/drivers/dma/Kconfig
 @@ -90,6 +90,17 @@ config DW_DMAC
   Support the Synopsys DesignWare AHB DMA controller.  This
   can be integrated in chips such as the Atmel AT32ap7000.

 +config DW_DMAC_BIG_ENDIAN_IO
 +   bool Use big endian I/O register access
 +   default y if AVR32
 +   depends on DW_DMAC
 +   help
 + Say yes here to use big endian I/O access when reading and writing
 + to the DMA controller registers. This is needed on some platforms,
 + like the Atmel AVR32 architecture.
 +
 + If unsure, use the default setting.
 +
  config AT_HDMAC
 tristate Atmel AHB DMA support
 depends on ARCH_AT91
 diff --git a/drivers/dma/dw_dmac_regs.h b/drivers/dma/dw_dmac_regs.h
 index ff39fa6..8896559 100644
 --- a/drivers/dma/dw_dmac_regs.h
 +++ b/drivers/dma/dw_dmac_regs.h
 @@ -98,9 +98,17 @@ struct dw_dma_regs {
 u32 DW_PARAMS;
  };

 +#ifdef CONFIG_DW_DMAC_BIG_ENDIAN_IO
 +#define dma_readl_native ioread32be
 +#define dma_writel_native iowrite32be
 +#else
 +#define dma_readl_native readl
 +#define dma_writel_native writel
 +#endif
 +
  /* To access the registers in early stage of probe */
  #define dma_read_byaddr(addr, name) \
 -   readl((addr) + offsetof(struct dw_dma_regs, name))
 +   dma_readl_native((addr) + offsetof(struct dw_dma_regs, name))

  /* Bitfields in DW_PARAMS */
  #define DW_PARAMS_NR_CHAN  8   /* number of channels */
 @@ -216,9 +224,9 @@ __dwc_regs(struct dw_dma_chan *dwc)
  }

  #define channel_readl(dwc, name) \
 -   readl((__dwc_regs(dwc)-name))
 +   dma_readl_native((__dwc_regs(dwc)-name))
  #define channel_writel(dwc, name, val) \
 -   writel((val), (__dwc_regs(dwc)-name))
 +   dma_writel_native((val), (__dwc_regs(dwc)-name))

  static inline struct dw_dma_chan *to_dw_dma_chan(struct dma_chan *chan)
  {
 @@ -246,9 +254,9 @@ static inline struct dw_dma_regs __iomem 
 *__dw_regs(struct dw_dma *dw)
  }

  #define dma_readl(dw, name) \
 -   readl((__dw_regs(dw)-name))
 +   dma_readl_native((__dw_regs(dw)-name))
  #define dma_writel(dw, name, val) \
 -   writel((val), (__dw_regs(dw)-name))
 +   dma_writel_native((val), (__dw_regs(dw)-name))

  #define channel_set_bit(dw, reg, mask) \
 dma_writel(dw, reg, ((mask)  8) | (mask))
Why did you not change this one?


-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH REGRESSION FIX] dw_dmac: make driver's endianness configurable

2012-10-15 Thread Andy Shevchenko
On Mon, 2012-10-15 at 08:39 +0800, Hein Tibosch wrote: 
 Hi Andy,
 On 10/15/2012 4:08 AM, Andy Shevchenko wrote:
  On Sun, Oct 14, 2012 at 10:54 AM, Hein Tibosch hein_tibo...@yahoo.es 
  wrote:
  From: Hein Tibosch hein_tibo...@yahoo.es
 
  The dw_dmac was originally developed for avr32 to be used with the Synopsys
  DesignWare AHB DMA controller. Starting from 2.6.38, access to the 
  device's i/o
  snip
   #define dma_readl(dw, name) \
  -   readl((__dw_regs(dw)-name))
  +   dma_readl_native((__dw_regs(dw)-name))
   #define dma_writel(dw, name, val) \
  -   writel((val), (__dw_regs(dw)-name))
  +   dma_writel_native((val), (__dw_regs(dw)-name))
 
   #define channel_set_bit(dw, reg, mask) \
  dma_writel(dw, reg, ((mask)  8) | (mask))
  Why did you not change this one?
 
 Because dma_writel already calls dma_writel_native
Sure,
looks good for me.

-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V2 2/3] dmaengine: dw_dmac: Enhance device tree support

2012-10-15 Thread Andy Shevchenko
On Mon, 2012-10-15 at 08:59 +0530, Viresh Kumar wrote: 
 On 12 October 2012 20:28, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
  + if (last_dw) {
  + if ((last_bus_id == param)  (last_dw == dw))
  + return false;
  + }
  Just came to my mind.
  dw can't be NULL, can't it?
  Then
  if (last_dw) {
  ...
  }
  is unneeded.
 
 Fixup for this:
 
 diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
 index d72c26f..764c159 100644
 --- a/drivers/dma/dw_dmac.c
 +++ b/drivers/dma/dw_dmac.c
 @@ -1196,11 +1196,8 @@ bool dw_dma_generic_filter(struct dma_chan
 *chan, void *param)
  * failure. If dw and param are same, i.e. trying on same dw with
  * different channel, return false.
  */
 -   if (last_dw) {
 -   if ((last_bus_id == param)  (last_dw == dw))
 -   return false;
 -   }
 -
 +   if ((last_dw == dw)  (last_bus_id == param))
 +   return false;
 /*
  * Return true:
  * - If dw_dma's platform data is not filled with slave info, then all
Good.
So, have my 

Reviewed-by: Andy Shevchenko andriy.shevche...@linux.intel.com 

for this patch.


-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] dmatest: terminate all ongoing transfers before submitting new one

2012-10-16 Thread Andy Shevchenko
The following error messages come if we have software LLP emulation enabled and
enough threads running.

modprobe dmatest iterations=40
[  168.048601] dmatest: Started 1 threads using dma0chan0
[  168.054546] dmatest: Started 1 threads using dma0chan1
[  168.060441] dmatest: Started 1 threads using dma0chan2
[  168.066333] dmatest: Started 1 threads using dma0chan3
[  168.072250] dmatest: Started 1 threads using dma0chan4
[  168.078144] dmatest: Started 1 threads using dma0chan5
[  168.084057] dmatest: Started 1 threads using dma0chan6
[  168.089948] dmatest: Started 1 threads using dma0chan7
[  170.032962] dma0chan1-copy0: terminating after 40 tests, 0 failures (status 
0)
[  170.041274] dma0chan0-copy0: terminating after 40 tests, 0 failures (status 
0)
[  170.597559] dma0chan2-copy0: terminating after 40 tests, 0 failures (status 
0)
[  171.085059] dma0chan7-copy0: #0: test timed out
[  171.839710] dma0chan3-copy0: terminating after 40 tests, 0 failures (status 
0)
[  172.146071] dma0chan4-copy0: terminating after 40 tests, 0 failures (status 
0)
[  172.220802] dma0chan7-copy0: #1: got completion callback, but status is 'in 
progress'
[  172.242049] dma0chan7-copy0: #2: got completion callback, but status is 'in 
progress'
[  172.281063] dma0chan7-copy0: #3: got completion callback, but status is 'in 
progress'
[  172.400866] dma0chan7-copy0: #4: got completion callback, but status is 'in 
progress'
[  172.471799] dma0chan7-copy0: #5: got completion callback, but status is 'in 
progress'
[  172.613996] dma0chan7-copy0: #6: got completion callback, but status is 'in 
progress'
[  172.670286] dma0chan7-copy0: #7: got completion callback, but status is 'in 
progress'
[  172.750763] dma0chan7-copy0: #8: got completion callback, but status is 'in 
progress'
[  172.777452] dma0chan5-copy0: terminating after 40 tests, 0 failures (status 
0)
[  172.788740] dma0chan7-copy0: #9: got completion callback, but status is 'in 
progress'
[  172.845156] dma0chan7-copy0: #10: got completion callback, but status is 'in 
progress'
[  172.906593] dma0chan7-copy0: #11: got completion callback, but status is 'in 
progress'
[  173.181515] dma0chan6-copy0: terminating after 40 tests, 0 failures (status 
0)
[  173.512838] dma0chan7-copy0: terminating after 40 tests, 12 failures (status 
0)

The patch fixes dmatest module to stop any ongoing transfer before submitting
new one. Perhaps there is a better solution and driver logic needs to be fixed
as well.

After patch we will have

modprobe dmatest iterations=50
[   84.027375] dmatest: Started 1 threads using dma0chan0
[   84.033282] dmatest: Started 1 threads using dma0chan1
[   84.039182] dmatest: Started 1 threads using dma0chan2
[   84.045089] dmatest: Started 1 threads using dma0chan3
[   84.051003] dmatest: Started 1 threads using dma0chan4
[   84.056916] dmatest: Started 1 threads using dma0chan5
[   84.062828] dmatest: Started 1 threads using dma0chan6
[   84.068714] dmatest: Started 1 threads using dma0chan7
[   86.538284] dma0chan0-copy0: terminating after 50 tests, 0 failures (status 
0)
[   86.842221] dma0chan1-copy0: terminating after 50 tests, 0 failures (status 
0)
[   87.060460] dma0chan6-copy0: #0: test timed out
[   87.065614] dma0chan7-copy0: #0: test timed out
[   87.220321] dma0chan2-copy0: terminating after 50 tests, 0 failures (status 
0)
[   88.595061] dma0chan3-copy0: terminating after 50 tests, 0 failures (status 
0)
[   89.152170] dma0chan4-copy0: terminating after 50 tests, 0 failures (status 
0)
[   89.955059] dma0chan5-copy0: terminating after 50 tests, 0 failures (status 
0)
[   90.697073] dma0chan6-copy0: terminating after 50 tests, 1 failures (status 
0)
[   90.893422] dma0chan7-copy0: terminating after 50 tests, 1 failures (status 
0)

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/dma/dmatest.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 24225f0..583f882 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -399,6 +399,9 @@ static int dmatest_func(void *data)
continue;
}
 
+   /* Stop any ongoing transfers here */
+   chan-device-device_control(chan, DMA_TERMINATE_ALL, 0);
+
done.done = false;
tx-callback = dmatest_callback;
tx-callback_param = done;
-- 
1.7.10.4

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


Re: [PATCH] dmatest: terminate all ongoing transfers before submitting new one

2012-10-16 Thread Andy Shevchenko
On Tue, Oct 16, 2012 at 11:56 AM, viresh kumar viresh.ku...@linaro.org wrote:
 On Tue, Oct 16, 2012 at 2:15 PM, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
 The following error messages come if we have software LLP emulation enabled 
 and
 enough threads running.

 modprobe dmatest iterations=40
 [  168.048601] dmatest: Started 1 threads using dma0chan0
 [  168.054546] dmatest: Started 1 threads using dma0chan1
 [  168.060441] dmatest: Started 1 threads using dma0chan2
 [  168.066333] dmatest: Started 1 threads using dma0chan3
 [  168.072250] dmatest: Started 1 threads using dma0chan4
 [  168.078144] dmatest: Started 1 threads using dma0chan5
 [  168.084057] dmatest: Started 1 threads using dma0chan6
 [  168.089948] dmatest: Started 1 threads using dma0chan7
 [  170.032962] dma0chan1-copy0: terminating after 40 tests, 0 failures 
 (status 0)
 [  170.041274] dma0chan0-copy0: terminating after 40 tests, 0 failures 
 (status 0)
 [  170.597559] dma0chan2-copy0: terminating after 40 tests, 0 failures 
 (status 0)
 [  171.085059] dma0chan7-copy0: #0: test timed out
 [  171.839710] dma0chan3-copy0: terminating after 40 tests, 0 failures 
 (status 0)
 [  172.146071] dma0chan4-copy0: terminating after 40 tests, 0 failures 
 (status 0)
 [  172.220802] dma0chan7-copy0: #1: got completion callback, but status is 
 'in progress'
 [  172.242049] dma0chan7-copy0: #2: got completion callback, but status is 
 'in progress'
 [  172.281063] dma0chan7-copy0: #3: got completion callback, but status is 
 'in progress'
 [  172.400866] dma0chan7-copy0: #4: got completion callback, but status is 
 'in progress'
 [  172.471799] dma0chan7-copy0: #5: got completion callback, but status is 
 'in progress'
 [  172.613996] dma0chan7-copy0: #6: got completion callback, but status is 
 'in progress'
 [  172.670286] dma0chan7-copy0: #7: got completion callback, but status is 
 'in progress'
 [  172.750763] dma0chan7-copy0: #8: got completion callback, but status is 
 'in progress'
 [  172.777452] dma0chan5-copy0: terminating after 40 tests, 0 failures 
 (status 0)
 [  172.788740] dma0chan7-copy0: #9: got completion callback, but status is 
 'in progress'
 [  172.845156] dma0chan7-copy0: #10: got completion callback, but status is 
 'in progress'
 [  172.906593] dma0chan7-copy0: #11: got completion callback, but status is 
 'in progress'
 [  173.181515] dma0chan6-copy0: terminating after 40 tests, 0 failures 
 (status 0)
 [  173.512838] dma0chan7-copy0: terminating after 40 tests, 12 failures 
 (status 0)

 The patch fixes dmatest module to stop any ongoing transfer before submitting
 new one. Perhaps there is a better solution and driver logic needs to be 
 fixed
 as well.

 After patch we will have

 modprobe dmatest iterations=50
 [   84.027375] dmatest: Started 1 threads using dma0chan0
 [   84.033282] dmatest: Started 1 threads using dma0chan1
 [   84.039182] dmatest: Started 1 threads using dma0chan2
 [   84.045089] dmatest: Started 1 threads using dma0chan3
 [   84.051003] dmatest: Started 1 threads using dma0chan4
 [   84.056916] dmatest: Started 1 threads using dma0chan5
 [   84.062828] dmatest: Started 1 threads using dma0chan6
 [   84.068714] dmatest: Started 1 threads using dma0chan7
 [   86.538284] dma0chan0-copy0: terminating after 50 tests, 0 failures 
 (status 0)
 [   86.842221] dma0chan1-copy0: terminating after 50 tests, 0 failures 
 (status 0)
 [   87.060460] dma0chan6-copy0: #0: test timed out
 [   87.065614] dma0chan7-copy0: #0: test timed out
 [   87.220321] dma0chan2-copy0: terminating after 50 tests, 0 failures 
 (status 0)
 [   88.595061] dma0chan3-copy0: terminating after 50 tests, 0 failures 
 (status 0)
 [   89.152170] dma0chan4-copy0: terminating after 50 tests, 0 failures 
 (status 0)
 [   89.955059] dma0chan5-copy0: terminating after 50 tests, 0 failures 
 (status 0)
 [   90.697073] dma0chan6-copy0: terminating after 50 tests, 1 failures 
 (status 0)
 [   90.893422] dma0chan7-copy0: terminating after 50 tests, 1 failures 
 (status 0)

 You still have failures. :(
Sure, the point is we have no 'in progress' issues

 Can you try with a large timeout value for the module.
I tried and the failures were gone.

 We must get to the root cause of these failures. There may be something more
 serious which is getting hidden due to this call to terminate().
My understanding is that. The software LLP emulation runs several
transactions per active descriptor. Because of a huge load of the
CPU/DMA some transactions are not done within given timeout. The
dmatest supplies next block to transfer without doing anything for
previous one. Under some circumstances the new transfer is queued, and
immediately after this the callback function is called for _previous_
transfer. The check condition doesn't recognize which transfer called
the callback function.

Rough solution is proposed by current patch. Another solution is to
mark each transfer with id and check done flag and transfer id
together.

 Unless

Re: [PATCH] dmatest: terminate all ongoing transfers before submitting new one

2012-10-16 Thread Andy Shevchenko
On Tue, Oct 16, 2012 at 12:52 PM, Viresh Kumar viresh.ku...@linaro.org wrote:
 Also, the proposed solution might hide some other important errors. We may 
 need
 to terminate transfers when we found that an error is there in  last 
 transfers:
 I think it could be better than first solution, but what do you think
 about marking each transfer with corresponding id?

 But dma_test expects the transfer to finish within timeout. If it
 doesn't, then that's
 an error.

 So, for testing your s/w emulation, you must pass higher timeout. And
 terminating
 transfers for error case would be better, to make them timeout safe.

Yeah, seems the patch is not necessary.
In case of software emulation we just have a test passed much slow...

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 1/6] lib/string: introduce helper to get base file name from given path

2012-10-16 Thread Andy Shevchenko
There are several places in the kernel that use functionality like basename(3)
with an exception: in case of '/foo/bar/' we expect to get an empty string.
Let's do it common helper for them.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Cc: Jason Baron jba...@redhat.com
Cc: YAMANE Toshiaki yamaneto...@gmail.com
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: linux...@kvack.org
Cc: Steven Rostedt rost...@goodmis.org
Cc: Frederic Weisbecker fweis...@gmail.com
---
 include/linux/string.h |   11 +++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index 6301258..ac889c5 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -143,4 +143,15 @@ static inline bool strstarts(const char *str, const char 
*prefix)
 
 extern size_t memweight(const void *ptr, size_t bytes);
 
+/**
+ * kbasename - return the last part of a pathname.
+ *
+ * @path: path to extract the filename from.
+ */
+static inline const char *kbasename(const char *path)
+{
+   const char *tail = strrchr(path, '/');
+   return tail ? tail + 1 : path;
+}
+
 #endif /* _LINUX_STRING_H_ */
-- 
1.7.10.4

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


[PATCHv3 5/6] procfs: reuse kbasename() functionality

2012-10-16 Thread Andy Shevchenko
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 fs/proc/proc_devtree.c |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c
index df7dd08..3d9fd66 100644
--- a/fs/proc/proc_devtree.c
+++ b/fs/proc/proc_devtree.c
@@ -13,6 +13,7 @@
 #include linux/of.h
 #include linux/module.h
 #include linux/slab.h
+#include linux/string.h
 #include asm/prom.h
 #include asm/uaccess.h
 #include internal.h
@@ -195,11 +196,7 @@ void proc_device_tree_add_node(struct device_node *np,
set_node_proc_entry(np, de);
for (child = NULL; (child = of_get_next_child(np, child));) {
/* Use everything after the last slash, or the full name */
-   p = strrchr(child-full_name, '/');
-   if (!p)
-   p = child-full_name;
-   else
-   ++p;
+   p = kbasename(child-full_name);
 
if (duplicate_name(de, p))
p = fixup_name(np, de, p);
-- 
1.7.10.4

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


[PATCHv3 1/6] string: introduce helper to get base file name from given path

2012-10-16 Thread Andy Shevchenko
There are several places in the kernel that use functionality like basename(3)
with the exception: in case of '/foo/bar/' we expect to get an empty string.
Let's do it common helper for them.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 include/linux/string.h |   11 +++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index 6301258..ac889c5 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -143,4 +143,15 @@ static inline bool strstarts(const char *str, const char 
*prefix)
 
 extern size_t memweight(const void *ptr, size_t bytes);
 
+/**
+ * kbasename - return the last part of a pathname.
+ *
+ * @path: path to extract the filename from.
+ */
+static inline const char *kbasename(const char *path)
+{
+   const char *tail = strrchr(path, '/');
+   return tail ? tail + 1 : path;
+}
+
 #endif /* _LINUX_STRING_H_ */
-- 
1.7.10.4

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


[PATCHv3 6/6] trace: reuse kbasename() functionality

2012-10-16 Thread Andy Shevchenko
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Cc: Steven Rostedt rost...@goodmis.org
Cc: Frederic Weisbecker fweis...@gmail.com
---
 kernel/trace/trace_uprobe.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 03003cd..c7ba4f6 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -22,6 +22,7 @@
 #include linux/uaccess.h
 #include linux/uprobes.h
 #include linux/namei.h
+#include linux/string.h
 
 #include trace_probe.h
 
@@ -263,16 +264,15 @@ static int create_trace_uprobe(int argc, char **argv)
 
/* setup a probe */
if (!event) {
-   char *tail = strrchr(filename, '/');
+   char *tail;
char *ptr;
 
-   ptr = kstrdup((tail ? tail + 1 : filename), GFP_KERNEL);
-   if (!ptr) {
+   tail = kstrdup(kbasename(filename), GFP_KERNEL);
+   if (!tail) {
ret = -ENOMEM;
goto fail_address_parse;
}
 
-   tail = ptr;
ptr = strpbrk(tail, .-_);
if (ptr)
*ptr = '\0';
-- 
1.7.10.4

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


[PATCHv3 3/6] staging: rts_pstor: reuse kbasename()

2012-10-16 Thread Andy Shevchenko
The custom filename function mostly repeats the kernel's kbasename. This patch
simplifies it. The updated filename() will not check for the '\' in the
filenames. It seems redundant in Linux. The __FILE__ macro always defined if
we compile an existing file. Thus, NULL check is not needed there as well.

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Cc: YAMANE Toshiaki yamaneto...@gmail.com
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/rts_pstor/trace.h |   24 
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/rts_pstor/trace.h 
b/drivers/staging/rts_pstor/trace.h
index cf60a1b..bff99bf 100644
--- a/drivers/staging/rts_pstor/trace.h
+++ b/drivers/staging/rts_pstor/trace.h
@@ -24,31 +24,15 @@
 #ifndef __REALTEK_RTSX_TRACE_H
 #define __REALTEK_RTSX_TRACE_H
 
+#include linux/string.h
+
 #define _MSG_TRACE
 
 #ifdef _MSG_TRACE
-static inline char *filename(char *path)
-{
-   char *ptr;
-
-   if (path == NULL)
-   return NULL;
-
-   ptr = path;
-
-   while (*ptr != '\0') {
-   if ((*ptr == '\\') || (*ptr == '/'))
-   path = ptr + 1;
-   
-   ptr++;
-   }
-
-   return path;
-}
 
 #define TRACE_RET(chip, ret)   
\
 do {   
\
-   char *_file = filename(__FILE__);   
\
+   const char *_file = kbasename(__FILE__);
\
RTSX_DEBUGP([%s][%s]:[%d]\n, _file, __func__, __LINE__);  
\
(chip)-trace_msg[(chip)-msg_idx].line = (u16)(__LINE__);  
\
strncpy((chip)-trace_msg[(chip)-msg_idx].func, __func__, 
MSG_FUNC_LEN-1); \
@@ -64,7 +48,7 @@ do {  
\
 
 #define TRACE_GOTO(chip, label)
\
 do {   
\
-   char *_file = filename(__FILE__);   
\
+   const char *_file = kbasename(__FILE__);
\
RTSX_DEBUGP([%s][%s]:[%d]\n, _file, __func__, __LINE__);  
\
(chip)-trace_msg[(chip)-msg_idx].line = (u16)(__LINE__);  
\
strncpy((chip)-trace_msg[(chip)-msg_idx].func, __func__, 
MSG_FUNC_LEN-1); \
-- 
1.7.10.4

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


[PATCHv3 2/6] lib: dynamic_debug: reuse kbasename()

2012-10-16 Thread Andy Shevchenko
Remove the custom implementation of the functionality similar to kbasename().

Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Cc: Jason Baron jba...@redhat.com
---
 lib/dynamic_debug.c |9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index e7f7d99..1db1fc6 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -62,13 +62,6 @@ static LIST_HEAD(ddebug_tables);
 static int verbose = 0;
 module_param(verbose, int, 0644);
 
-/* Return the last part of a pathname */
-static inline const char *basename(const char *path)
-{
-   const char *tail = strrchr(path, '/');
-   return tail ? tail+1 : path;
-}
-
 /* Return the path relative to source root */
 static inline const char *trim_prefix(const char *path)
 {
@@ -154,7 +147,7 @@ static int ddebug_change(const struct ddebug_query *query,
/* match against the source filename */
if (query-filename 
strcmp(query-filename, dp-filename) 
-   strcmp(query-filename, basename(dp-filename)) 
+   strcmp(query-filename, kbasename(dp-filename)) 
strcmp(query-filename, trim_prefix(dp-filename)))
continue;
 
-- 
1.7.10.4

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


[PATCHv3 0/6] lib/string: introduce kbasename helper

2012-10-16 Thread Andy Shevchenko
There are several places in kernel that duplicate code to get last part of the
pathname. This patchset introduces a helper and few fixes.

Since v2:
- fixed Cc list in the patch 6/6 (trace: ...)
- update patch 3/6 (rts_pstor: ...) to not hide const qualifier
- send patch 1/1 to all people involved to the series
- rebase against recent linux-next
Since v1:
- fix changelog of the patch 1 - we are doing basename(3) alike helper
- usb related patch temporary excluded from series (under discussion with Greg)

Andy Shevchenko (6):
  lib/string: introduce helper to get base file name from given path
  lib: dynamic_debug: reuse kbasename()
  staging: rts_pstor: reuse kbasename()
  mm: reuse kbasename() functionality
  procfs: reuse kbasename() functionality
  trace: reuse kbasename() functionality

 drivers/staging/rts_pstor/trace.h |   24 
 fs/proc/proc_devtree.c|7 ++-
 include/linux/string.h|   11 +++
 kernel/trace/trace_uprobe.c   |8 
 lib/dynamic_debug.c   |9 +
 mm/memory.c   |8 +++-
 6 files changed, 25 insertions(+), 42 deletions(-)

-- 
1.7.10.4

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


[PATCHv3 4/6] mm: reuse kbasename() functionality

2012-10-16 Thread Andy Shevchenko
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Cc: linux...@kvack.org
---
 mm/memory.c |8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 5823f29..06158b7 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -58,6 +58,7 @@
 #include linux/elf.h
 #include linux/gfp.h
 #include linux/migrate.h
+#include linux/string.h
 
 #include asm/io.h
 #include asm/pgalloc.h
@@ -4034,15 +4035,12 @@ void print_vma_addr(char *prefix, unsigned long ip)
struct file *f = vma-vm_file;
char *buf = (char *)__get_free_page(GFP_KERNEL);
if (buf) {
-   char *p, *s;
+   char *p;
 
p = d_path(f-f_path, buf, PAGE_SIZE);
if (IS_ERR(p))
p = ?;
-   s = strrchr(p, '/');
-   if (s)
-   p = s+1;
-   printk(%s%s[%lx+%lx], prefix, p,
+   printk(%s%s[%lx+%lx], prefix, kbasename(p),
vma-vm_start,
vma-vm_end - vma-vm_start);
free_page((unsigned long)buf);
-- 
1.7.10.4

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


Re: [PATCH 6/7] usb: core: reuse kbasename()

2012-10-17 Thread Andy Shevchenko
On Wed, Oct 3, 2012 at 6:08 PM, Greg Kroah-Hartman
gre...@linuxfoundation.org wrote:
 On Wed, Oct 03, 2012 at 11:27:27AM +0300, Andy Shevchenko wrote:
 On Tue, Oct 2, 2012 at 6:00 PM, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:

  --- a/drivers/usb/core/file.c
  +++ b/drivers/usb/core/file.c

  @@ -200,14 +200,9 @@ int usb_register_dev(struct usb_interface *intf,
 
  /* create a usb class device for this usb interface */
  snprintf(name, sizeof(name), class_driver-name, minor - 
  minor_base);
  -   temp = strrchr(name, '/');
  -   if (temp  (temp[1] != '\0'))
 I have checked current linux-next, the drivers define .name in the
 usb_class_driver structure as '...%d'.
 So, what is the reason to check for trailing '/' here? Historical
 reasons or there is a (broken/3rd party/etc) driver with it?

 I really do not remember why it was done this way, sorry.  I have no
 problem not doing it anymore, as long as you are willing to fix any
 potential bugs that might pop up :)

Hmm... this series about cleaning up. The bugs might pop up in the
drivers that still using something like '/foo/bar/' for their names
here.
Anyway, I tried to dig into history and only what I found is the patch
http://www.kernel.org/pub/linux/kernel//people/akpm/patches/2.5/2.5.69/2.5.69-mm3/broken-out/linus.patch
that brings a piece of code. And it the same time it brings the same
piece to the tty layer. I suspect that this piece was copied and
pasted in few place.

Currently the device_create() call uses the name parameter as a
parameter of kobject. But kobject doesn't accept '/' in the names, it
changes it to '!'.
So, I think the way of treating a trailing slash in the usb code is redundant.

 And no, I don't worry about 3rd party drivers, that shouldn't be an
 issue at all here.

Fair enough


-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 0/4] dw_dmac: few cleanups to the driver

2012-10-17 Thread Andy Shevchenko
There are few cleanups to the driver which partialy acked and reviewed.

Since v1:
- patch 1/4 (use helper macro module_platform_driver()) is removed from the
  series: it brings issues rather than cleans up
- patch 2/4 (add module alias) is postponed

Andy Shevchenko (2):
  dw_dmac: change {dev_}printk() to corresponding macros
  dw_dmac: don't call platform_get_drvdata twice

Heikki Krogerus (2):
  dmaengine: dw_dmac: remove CLK dependency
  dmaengine: dw_dmac: amend description and indentation

 drivers/dma/Kconfig   |1 -
 drivers/dma/dw_dmac.c |   25 +++--
 2 files changed, 11 insertions(+), 15 deletions(-)

-- 
1.7.10.4

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


[PATCHv2 3/4] dw_dmac: change {dev_}printk() to corresponding macros

2012-10-17 Thread Andy Shevchenko
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
---
 drivers/dma/dw_dmac.c |   15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index c27c125..60b172a 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -456,9 +456,8 @@ static void dwc_scan_descriptors(struct dw_dma *dw, struct 
dw_dma_chan *dwc)
 
 static inline void dwc_dump_lli(struct dw_dma_chan *dwc, struct dw_lli *lli)
 {
-   dev_printk(KERN_CRIT, chan2dev(dwc-chan),
- desc: s0x%x d0x%x l0x%x c0x%x:%x\n,
-   lli-sar, lli-dar, lli-llp, lli-ctlhi, lli-ctllo);
+   dev_crit(chan2dev(dwc-chan),   desc: s0x%x d0x%x l0x%x c0x%x:%x\n,
+lli-sar, lli-dar, lli-llp, lli-ctlhi, lli-ctllo);
 }
 
 static void dwc_handle_error(struct dw_dma *dw, struct dw_dma_chan *dwc)
@@ -492,10 +491,8 @@ static void dwc_handle_error(struct dw_dma *dw, struct 
dw_dma_chan *dwc)
 * controller flagged an error instead of scribbling over
 * random memory locations.
 */
-   dev_printk(KERN_CRIT, chan2dev(dwc-chan),
-   Bad descriptor submitted for DMA!\n);
-   dev_printk(KERN_CRIT, chan2dev(dwc-chan),
- cookie: %d\n, bad_desc-txd.cookie);
+   dev_crit(chan2dev(dwc-chan), Bad descriptor submitted for DMA!\n);
+   dev_crit(chan2dev(dwc-chan),   cookie: %d\n, bad_desc-txd.cookie);
dwc_dump_lli(dwc, bad_desc-lli);
list_for_each_entry(child, bad_desc-tx_list, desc_node)
dwc_dump_lli(dwc, child-lli);
@@ -1625,8 +1622,8 @@ static int __devinit dw_probe(struct platform_device 
*pdev)
 
dma_writel(dw, CFG, DW_CFG_DMA_EN);
 
-   printk(KERN_INFO %s: DesignWare DMA Controller, %d channels\n,
-   dev_name(pdev-dev), nr_channels);
+   pr_info(%s: DesignWare DMA Controller, %d channels\n,
+   dev_name(pdev-dev), nr_channels);
 
dma_async_device_register(dw-dma);
 
-- 
1.7.10.4

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


[PATCHv2 2/4] dmaengine: dw_dmac: amend description and indentation

2012-10-17 Thread Andy Shevchenko
From: Heikki Krogerus heikki.kroge...@linux.intel.com

The driver will be used as a core part for various implementations of the
DesignWare DMA device. The patch adjusts description on the top and corrects
paragraph indentation in few places across the code.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Acked-by: Viresh Kumar viresh.ku...@linaro.org
---
 drivers/dma/dw_dmac.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index c4b0eb3..c27c125 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -1,6 +1,5 @@
 /*
- * Driver for the Synopsys DesignWare DMA Controller (aka DMACA on
- * AVR32 systems.)
+ * Core driver for the Synopsys DesignWare DMA Controller
  *
  * Copyright (C) 2007-2008 Atmel Corporation
  * Copyright (C) 2010-2011 ST Microelectronics
@@ -9,6 +8,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+
 #include linux/bitops.h
 #include linux/clk.h
 #include linux/delay.h
@@ -222,7 +222,6 @@ static inline void dwc_dump_chan_regs(struct dw_dma_chan 
*dwc)
channel_readl(dwc, CTL_LO));
 }
 
-
 static inline void dwc_chan_disable(struct dw_dma *dw, struct dw_dma_chan *dwc)
 {
channel_clear_bit(dw, CH_EN, dwc-mask);
@@ -1679,6 +1678,7 @@ static int dw_resume_noirq(struct device *dev)
 
clk_prepare_enable(dw-clk);
dma_writel(dw, CFG, DW_CFG_DMA_EN);
+
return 0;
 }
 
-- 
1.7.10.4

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


[PATCHv2 1/4] dmaengine: dw_dmac: remove CLK dependency

2012-10-17 Thread Andy Shevchenko
From: Heikki Krogerus heikki.kroge...@linux.intel.com

This driver could be used on different platforms. Thus, the HAVE_CLK dependency
is dropped away.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
Reviewed-by: Felipe Balbi ba...@ti.com
Acked-by: Viresh Kumar viresh.ku...@linaro.org
---
 drivers/dma/Kconfig |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 677cd6e..df32537 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -83,7 +83,6 @@ config INTEL_IOP_ADMA
 
 config DW_DMAC
tristate Synopsys DesignWare AHB DMA support
-   depends on HAVE_CLK
select DMA_ENGINE
default y if CPU_AT32AP7000
help
-- 
1.7.10.4

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


Re: [PATCHv2 3/4] dw_dmac: change {dev_}printk() to corresponding macros

2012-10-17 Thread Andy Shevchenko
On Wed, 2012-10-17 at 16:09 +0300, Felipe Balbi wrote: 
 Hi,
 
 On Wed, Oct 17, 2012 at 01:31:17PM +0300, Andy Shevchenko wrote:
  Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
  ---
   drivers/dma/dw_dmac.c |   15 ++-
   1 file changed, 6 insertions(+), 9 deletions(-)
  
  diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
  index c27c125..60b172a 100644
  --- a/drivers/dma/dw_dmac.c
  +++ b/drivers/dma/dw_dmac.c
  @@ -456,9 +456,8 @@ static void dwc_scan_descriptors(struct dw_dma *dw, 
  struct dw_dma_chan *dwc)
   
   static inline void dwc_dump_lli(struct dw_dma_chan *dwc, struct dw_lli 
  *lli)
   {
  -   dev_printk(KERN_CRIT, chan2dev(dwc-chan),
  - desc: s0x%x d0x%x l0x%x c0x%x:%x\n,
  -   lli-sar, lli-dar, lli-llp, lli-ctlhi, lli-ctllo);
  +   dev_crit(chan2dev(dwc-chan),   desc: s0x%x d0x%x l0x%x c0x%x:%x\n,
  +lli-sar, lli-dar, lli-llp, lli-ctlhi, lli-ctllo);
 
 is this really critical ? To me it looks more like a debugging message.
This one is used in two cases, where one is marked as error, another -
critical

 
   }
   
   static void dwc_handle_error(struct dw_dma *dw, struct dw_dma_chan *dwc)
  @@ -492,10 +491,8 @@ static void dwc_handle_error(struct dw_dma *dw, struct 
  dw_dma_chan *dwc)
   * controller flagged an error instead of scribbling over
   * random memory locations.
   */
  -   dev_printk(KERN_CRIT, chan2dev(dwc-chan),
  -   Bad descriptor submitted for DMA!\n);
  -   dev_printk(KERN_CRIT, chan2dev(dwc-chan),
  - cookie: %d\n, bad_desc-txd.cookie);
  +   dev_crit(chan2dev(dwc-chan), Bad descriptor submitted for DMA!\n);
  +   dev_crit(chan2dev(dwc-chan),   cookie: %d\n, bad_desc-txd.cookie);
 
 now this is critical, indeed. I would suggest using dev_WARN_ONCE() so
 that it's noisy enough to catch the failing user.
To this and upper comment, there is an explanation why it's critical. I
guess the WARN_ONCE is not good enough, for example if we have more than
one user making such noise.

 
  dwc_dump_lli(dwc, bad_desc-lli);
  list_for_each_entry(child, bad_desc-tx_list, desc_node)
  dwc_dump_lli(dwc, child-lli);
  @@ -1625,8 +1622,8 @@ static int __devinit dw_probe(struct platform_device 
  *pdev)
   
  dma_writel(dw, CFG, DW_CFG_DMA_EN);
   
  -   printk(KERN_INFO %s: DesignWare DMA Controller, %d channels\n,
  -   dev_name(pdev-dev), nr_channels);
  +   pr_info(%s: DesignWare DMA Controller, %d channels\n,
  +   dev_name(pdev-dev), nr_channels);
 
 you have a struct device available in platform_device, please use
 dev_info() or dev_dbg().
Agreed.


-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv2 3/4] dw_dmac: change {dev_}printk() to corresponding macros

2012-10-18 Thread Andy Shevchenko
On Wed, 2012-10-17 at 16:53 +0300, Felipe Balbi wrote: 
 On Wed, Oct 17, 2012 at 04:36:58PM +0300, Andy Shevchenko wrote:
  On Wed, 2012-10-17 at 16:09 +0300, Felipe Balbi wrote: 
   Hi,
   
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c

@@ -492,10 +491,8 @@ static void dwc_handle_error(struct dw_dma *dw, 
struct dw_dma_chan *dwc)
 * controller flagged an error instead of scribbling over
 * random memory locations.
 */
-   dev_printk(KERN_CRIT, chan2dev(dwc-chan),
-   Bad descriptor submitted for DMA!\n);
-   dev_printk(KERN_CRIT, chan2dev(dwc-chan),
- cookie: %d\n, bad_desc-txd.cookie);
+   dev_crit(chan2dev(dwc-chan), Bad descriptor submitted for 
DMA!\n);
+   dev_crit(chan2dev(dwc-chan),   cookie: %d\n, 
bad_desc-txd.cookie);
   
   now this is critical, indeed. I would suggest using dev_WARN_ONCE() so
   that it's noisy enough to catch the failing user.
  To this and upper comment, there is an explanation why it's critical. I
  guess the WARN_ONCE is not good enough, for example if we have more than
  one user making such noise.
 
 then use dev_WARN()
I can't see how dev_WARN could be more useful here than the dev_crit. In
current message we have channel and cookie to link back to the user.
What does WARN add meaningful?

-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv2 3/4] dw_dmac: change {dev_}printk() to corresponding macros

2012-10-18 Thread Andy Shevchenko
On Thu, 2012-10-18 at 13:34 +0300, Felipe Balbi wrote: 
 On Thu, Oct 18, 2012 at 11:15:31AM +0300, Andy Shevchenko wrote:
  On Wed, 2012-10-17 at 16:53 +0300, Felipe Balbi wrote: 
   On Wed, Oct 17, 2012 at 04:36:58PM +0300, Andy Shevchenko wrote:
On Wed, 2012-10-17 at 16:09 +0300, Felipe Balbi wrote: 

  diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c

  @@ -492,10 +491,8 @@ static void dwc_handle_error(struct dw_dma 
  *dw, struct dw_dma_chan *dwc)
   * controller flagged an error instead of scribbling over
   * random memory locations.
   */
  -   dev_printk(KERN_CRIT, chan2dev(dwc-chan),
  -   Bad descriptor submitted for DMA!\n);
  -   dev_printk(KERN_CRIT, chan2dev(dwc-chan),
  - cookie: %d\n, bad_desc-txd.cookie);
  +   dev_crit(chan2dev(dwc-chan), Bad descriptor submitted for 
  DMA!\n);
  +   dev_crit(chan2dev(dwc-chan),   cookie: %d\n, 
  bad_desc-txd.cookie);
 
 now this is critical, indeed. I would suggest using dev_WARN_ONCE() so
 that it's noisy enough to catch the failing user.
To this and upper comment, there is an explanation why it's critical. I
guess the WARN_ONCE is not good enough, for example if we have more than
one user making such noise.
   
   then use dev_WARN()
  I can't see how dev_WARN could be more useful here than the dev_crit. In
  current message we have channel and cookie to link back to the user.
  What does WARN add meaningful?
 
 a dump_stack()

How could it be useful? The dwc_handle_error is called from a tasklet
that is called from scheduler asynchronously. The tasklet is queued in
interrupt handler.


-- 
Andy Shevchenko andriy.shevche...@linux.intel.com
Intel Finland Oy
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCHv2 3/4] dw_dmac: change {dev_}printk() to corresponding macros

2012-10-18 Thread Andy Shevchenko
On Thu, Oct 18, 2012 at 4:59 PM, Felipe Balbi ba...@ti.com wrote:
 On Thu, Oct 18, 2012 at 02:09:43PM +0300, Andy Shevchenko wrote:
 On Thu, 2012-10-18 at 13:34 +0300, Felipe Balbi wrote:
  On Thu, Oct 18, 2012 at 11:15:31AM +0300, Andy Shevchenko wrote:
   On Wed, 2012-10-17 at 16:53 +0300, Felipe Balbi wrote:
On Wed, Oct 17, 2012 at 04:36:58PM +0300, Andy Shevchenko wrote:
 On Wed, 2012-10-17 at 16:09 +0300, Felipe Balbi wrote:

   diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c

   @@ -492,10 +491,8 @@ static void dwc_handle_error(struct dw_dma 
   *dw, struct dw_dma_chan *dwc)
  * controller flagged an error instead of scribbling over
  * random memory locations.
  */
   - dev_printk(KERN_CRIT, chan2dev(dwc-chan),
   - Bad descriptor submitted for DMA!\n);
   - dev_printk(KERN_CRIT, chan2dev(dwc-chan),
   -   cookie: %d\n, bad_desc-txd.cookie);
   + dev_crit(chan2dev(dwc-chan), Bad descriptor submitted for 
   DMA!\n);
   + dev_crit(chan2dev(dwc-chan),   cookie: %d\n, 
   bad_desc-txd.cookie);
 
  now this is critical, indeed. I would suggest using 
  dev_WARN_ONCE() so
  that it's noisy enough to catch the failing user.
 To this and upper comment, there is an explanation why it's 
 critical. I
 guess the WARN_ONCE is not good enough, for example if we have more 
 than
 one user making such noise.
   
then use dev_WARN()
   I can't see how dev_WARN could be more useful here than the dev_crit. In
   current message we have channel and cookie to link back to the user.
   What does WARN add meaningful?
 
  a dump_stack()

 How could it be useful? The dwc_handle_error is called from a tasklet
 that is called from scheduler asynchronously. The tasklet is queued in
 interrupt handler.

 even if it's not useful, it's a lot more verbose and more likely to get
 user's attention. If someone's passing broken DMA descriptor, it should
 be a really big fat warning so we can get user reports early enoough.

I will do separate patch for this. If Viresh and/or Vinoud is okay
with it, user will see fat message.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   6   7   8   9   10   >