[PATCH v2 12/13] ARM: pxa: remove the DMA IO resources

2018-05-24 Thread Robert Jarzmik
As the last driver using the former mechanism to acquire the DMA
requestor line has be converted to the dma_slave_map, remove all these
resources from the PXA devices.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 arch/arm/mach-pxa/devices.c | 136 
 1 file changed, 136 deletions(-)

diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index 1e8915fc340d..5a16ea74e28a 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -60,16 +60,6 @@ static struct resource pxamci_resources[] = {
.end= IRQ_MMC,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   .start  = 21,
-   .end= 21,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   .start  = 22,
-   .end= 22,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 static u64 pxamci_dmamask = 0xUL;
@@ -407,16 +397,6 @@ static struct resource pxa_ir_resources[] = {
.end= 0x40700023,
.flags  = IORESOURCE_MEM,
},
-   [5] = {
-   .start  = 17,
-   .end= 17,
-   .flags  = IORESOURCE_DMA,
-   },
-   [6] = {
-   .start  = 18,
-   .end= 18,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa_device_ficp = {
@@ -545,18 +525,6 @@ static struct resource pxa25x_resource_ssp[] = {
.end= IRQ_SSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 13,
-   .end= 13,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 14,
-   .end= 14,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa25x_device_ssp = {
@@ -583,18 +551,6 @@ static struct resource pxa25x_resource_nssp[] = {
.end= IRQ_NSSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 15,
-   .end= 15,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 16,
-   .end= 16,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa25x_device_nssp = {
@@ -621,18 +577,6 @@ static struct resource pxa25x_resource_assp[] = {
.end= IRQ_ASSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 23,
-   .end= 23,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 24,
-   .end= 24,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa25x_device_assp = {
@@ -751,18 +695,6 @@ static struct resource pxa27x_resource_ssp1[] = {
.end= IRQ_SSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 13,
-   .end= 13,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 14,
-   .end= 14,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa27x_device_ssp1 = {
@@ -789,18 +721,6 @@ static struct resource pxa27x_resource_ssp2[] = {
.end= IRQ_SSP2,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 15,
-   .end= 15,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 16,
-   .end= 16,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa27x_device_ssp2 = {
@@ -827,18 +747,6 @@ static struct resource pxa27x_resource_ssp3[] = {
.end= IRQ_SSP3,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 66,
-   .end= 66,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 67,
-   .end= 67,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa27x_device_ssp3 = {
@@ -895,16 +803,6 @@ static struct resource pxa3xx_resources_mci2[] = {
.end= IRQ_MMC2,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   .start  = 93,
-   .end= 93,
-   .flags  = IORESOURCE_DMA,
-   },
-   

[PATCH v2 06/13] net: smc911x: remove the dmaengine compat need

2018-05-24 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc911x.c | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc911x.c 
b/drivers/net/ethernet/smsc/smc911x.c
index 05157442a980..4c3713bd5caa 100644
--- a/drivers/net/ethernet/smsc/smc911x.c
+++ b/drivers/net/ethernet/smsc/smc911x.c
@@ -74,7 +74,6 @@ static const char version[] =
 #include 
 
 #include 
-#include 
 
 #include 
 
@@ -1794,8 +1793,6 @@ static int smc911x_probe(struct net_device *dev)
unsigned long irq_flags;
 #ifdef SMC_USE_DMA
struct dma_slave_config config;
-   dma_cap_mask_t mask;
-   struct pxad_param param;
 #endif
 
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
@@ -1969,17 +1966,8 @@ static int smc911x_probe(struct net_device *dev)
 
 #ifdef SMC_USE_DMA
 
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = -1UL;
-
-   lp->rxdma =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "rx");
-   lp->txdma =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "tx");
+   lp->rxdma = dma_request_slave_channel(>dev, "rx");
+   lp->txdma = dma_request_slave_channel(>dev, "tx");
lp->rxdma_active = 0;
lp->txdma_active = 0;
 
-- 
2.11.0



[PATCH v2 02/13] ARM: pxa: add dma slave map

2018-05-24 Thread Robert Jarzmik
In order to remove the specific knowledge of the dma mapping from PXA
drivers, add a default slave map for pxa architectures.

This is the first step, and once all drivers are converted,
pxad_filter_fn() will be made static, and the DMA resources removed from
device.c.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Reported-by: Arnd Bergmann <a...@arndb.de>
---
Since v1: revamped the SSP part, split into pxa25.c, pxa27x.c and
  pxa3xx.c, and add pxa-i2s.
---
 arch/arm/mach-pxa/devices.c | 12 +++-
 arch/arm/mach-pxa/devices.h |  6 +-
 arch/arm/mach-pxa/pxa25x.c  | 41 -
 arch/arm/mach-pxa/pxa27x.c  | 42 +-
 arch/arm/mach-pxa/pxa3xx.c  | 44 +++-
 5 files changed, 132 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index d7c9a8476d57..1e8915fc340d 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -4,6 +4,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -1202,11 +1203,6 @@ void __init pxa2xx_set_spi_info(unsigned id, struct 
pxa2xx_spi_master *info)
platform_device_add(pd);
 }
 
-static struct mmp_dma_platdata pxa_dma_pdata = {
-   .dma_channels   = 0,
-   .nb_requestors  = 0,
-};
-
 static struct resource pxa_dma_resource[] = {
[0] = {
.start  = 0x4000,
@@ -1233,9 +1229,7 @@ static struct platform_device pxa2xx_pxa_dma = {
.resource   = pxa_dma_resource,
 };
 
-void __init pxa2xx_set_dmac_info(int nb_channels, int nb_requestors)
+void __init pxa2xx_set_dmac_info(struct mmp_dma_platdata *dma_pdata)
 {
-   pxa_dma_pdata.dma_channels = nb_channels;
-   pxa_dma_pdata.nb_requestors = nb_requestors;
-   pxa_register_device(_pxa_dma, _dma_pdata);
+   pxa_register_device(_pxa_dma, dma_pdata);
 }
diff --git a/arch/arm/mach-pxa/devices.h b/arch/arm/mach-pxa/devices.h
index 11263f7c455b..498b07bc6a3e 100644
--- a/arch/arm/mach-pxa/devices.h
+++ b/arch/arm/mach-pxa/devices.h
@@ -1,4 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#define PDMA_FILTER_PARAM(_prio, _requestor) (&(struct pxad_param) { \
+   .prio = PXAD_PRIO_##_prio, .drcmr = _requestor })
+struct mmp_dma_platdata;
+
 extern struct platform_device pxa_device_pmu;
 extern struct platform_device pxa_device_mci;
 extern struct platform_device pxa3xx_device_mci2;
@@ -55,7 +59,7 @@ extern struct platform_device pxa3xx_device_gpio;
 extern struct platform_device pxa93x_device_gpio;
 
 void __init pxa_register_device(struct platform_device *dev, void *data);
-void __init pxa2xx_set_dmac_info(int nb_channels, int nb_requestors);
+void __init pxa2xx_set_dmac_info(struct mmp_dma_platdata *dma_pdata);
 
 struct i2c_pxa_platform_data;
 extern void pxa_set_i2c_info(struct i2c_pxa_platform_data *info);
diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c
index ba431fad5c47..2d61de41a9d5 100644
--- a/arch/arm/mach-pxa/pxa25x.c
+++ b/arch/arm/mach-pxa/pxa25x.c
@@ -16,6 +16,8 @@
  * initialization stuff for PXA machines which can be overridden later if
  * need be.
  */
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -26,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -201,6 +204,42 @@ static struct platform_device *pxa25x_devices[] __initdata 
= {
_device_asoc_platform,
 };
 
+static const struct dma_slave_map pxa25x_slave_map[] = {
+   /* PXA25x, PXA27x and PXA3xx common entries */
+   { "pxa2xx-ac97", "pcm_pcm_mic_mono", PDMA_FILTER_PARAM(LOWEST, 8) },
+   { "pxa2xx-ac97", "pcm_pcm_aux_mono_in", PDMA_FILTER_PARAM(LOWEST, 9) },
+   { "pxa2xx-ac97", "pcm_pcm_aux_mono_out",
+ PDMA_FILTER_PARAM(LOWEST, 10) },
+   { "pxa2xx-ac97", "pcm_pcm_stereo_in", PDMA_FILTER_PARAM(LOWEST, 11) },
+   { "pxa2xx-ac97", "pcm_pcm_stereo_out", PDMA_FILTER_PARAM(LOWEST, 12) },
+   { "pxa-ssp-dai.1", "rx", PDMA_FILTER_PARAM(LOWEST, 13) },
+   { "pxa-ssp-dai.1", "tx", PDMA_FILTER_PARAM(LOWEST, 14) },
+   { "pxa-ssp-dai.2", "rx", PDMA_FILTER_PARAM(LOWEST, 15) },
+   { "pxa-ssp-dai.2", "tx", PDMA_FILTER_PARAM(LOWEST, 16) },
+   { "pxa2xx-ir", "rx", PDMA_FILTER_PARAM(LOWEST, 17) },
+   { "pxa2xx-ir", "tx", PDMA_FILTER_PARAM(LOWEST, 18) },
+   { "pxa2xx-mci.0", "rx", PDMA_FILTER_PARAM(LOWEST, 21) },
+   { "pxa2xx-mci.0", "tx", PDMA_FILTER_PARAM(LOWEST, 22) },
+   { "smc911x.0", "rx", PDMA_FILTER_PARAM(LOWEST, -1) },
+   { "smc911x.0", "tx", PDMA_FILTER_PARAM(LOWEST, -1) },
+   { "smc91x.0", "da

[PATCH v2 03/13] mmc: pxamci: remove the dmaengine compat need

2018-05-24 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Acked-by: Ulf Hansson <ulf.hans...@linaro.org>
---
 drivers/mmc/host/pxamci.c | 29 +++--
 1 file changed, 3 insertions(+), 26 deletions(-)

diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index c763b404510f..6c94474e36f4 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -24,7 +24,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -637,10 +636,8 @@ static int pxamci_probe(struct platform_device *pdev)
 {
struct mmc_host *mmc;
struct pxamci_host *host = NULL;
-   struct resource *r, *dmarx, *dmatx;
-   struct pxad_param param_rx, param_tx;
+   struct resource *r;
int ret, irq, gpio_cd = -1, gpio_ro = -1, gpio_power = -1;
-   dma_cap_mask_t mask;
 
ret = pxamci_of_init(pdev);
if (ret)
@@ -739,34 +736,14 @@ static int pxamci_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, mmc);
 
-   if (!pdev->dev.of_node) {
-   dmarx = platform_get_resource(pdev, IORESOURCE_DMA, 0);
-   dmatx = platform_get_resource(pdev, IORESOURCE_DMA, 1);
-   if (!dmarx || !dmatx) {
-   ret = -ENXIO;
-   goto out;
-   }
-   param_rx.prio = PXAD_PRIO_LOWEST;
-   param_rx.drcmr = dmarx->start;
-   param_tx.prio = PXAD_PRIO_LOWEST;
-   param_tx.drcmr = dmatx->start;
-   }
-
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-
-   host->dma_chan_rx =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-_rx, >dev, "rx");
+   host->dma_chan_rx = dma_request_slave_channel(>dev, "rx");
if (host->dma_chan_rx == NULL) {
dev_err(>dev, "unable to request rx dma channel\n");
ret = -ENODEV;
goto out;
}
 
-   host->dma_chan_tx =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-_tx,  >dev, "tx");
+   host->dma_chan_tx = dma_request_slave_channel(>dev, "tx");
if (host->dma_chan_tx == NULL) {
dev_err(>dev, "unable to request tx dma channel\n");
ret = -ENODEV;
-- 
2.11.0



[PATCH v2 11/13] dmaengine: pxa: make the filter function internal

2018-05-24 Thread Robert Jarzmik
As the pxa architecture and all its related drivers do not rely anymore
on the filter function, thanks to the slave map conversion, make
pxad_filter_fn() static, and remove it from the global namespace.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/dma/pxa_dma.c   |  5 ++---
 include/linux/dma/pxa-dma.h | 11 ---
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index 9505334f9c6e..a332ad1d7dfb 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -179,7 +179,7 @@ static unsigned int pxad_drcmr(unsigned int line)
return 0x1000 + line * 4;
 }
 
-bool pxad_filter_fn(struct dma_chan *chan, void *param);
+static bool pxad_filter_fn(struct dma_chan *chan, void *param);
 
 /*
  * Debug fs
@@ -1496,7 +1496,7 @@ static struct platform_driver pxad_driver = {
.remove = pxad_remove,
 };
 
-bool pxad_filter_fn(struct dma_chan *chan, void *param)
+static bool pxad_filter_fn(struct dma_chan *chan, void *param)
 {
struct pxad_chan *c = to_pxad_chan(chan);
struct pxad_param *p = param;
@@ -1509,7 +1509,6 @@ bool pxad_filter_fn(struct dma_chan *chan, void *param)
 
return true;
 }
-EXPORT_SYMBOL_GPL(pxad_filter_fn);
 
 module_platform_driver(pxad_driver);
 
diff --git a/include/linux/dma/pxa-dma.h b/include/linux/dma/pxa-dma.h
index 9fc594f69eff..fceb5df07097 100644
--- a/include/linux/dma/pxa-dma.h
+++ b/include/linux/dma/pxa-dma.h
@@ -23,15 +23,4 @@ struct pxad_param {
enum pxad_chan_prio prio;
 };
 
-struct dma_chan;
-
-#ifdef CONFIG_PXA_DMA
-bool pxad_filter_fn(struct dma_chan *chan, void *param);
-#else
-static inline bool pxad_filter_fn(struct dma_chan *chan, void *param)
-{
-   return false;
-}
-#endif
-
 #endif /* _PXA_DMA_H_ */
-- 
2.11.0



[PATCH v2 09/13] ata: pata_pxa: remove the dmaengine compat need

2018-05-24 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnier...@samsung.com>
---
 drivers/ata/pata_pxa.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c
index f6c46e9a4dc0..e8b6a2e464c9 100644
--- a/drivers/ata/pata_pxa.c
+++ b/drivers/ata/pata_pxa.c
@@ -25,7 +25,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -180,8 +179,6 @@ static int pxa_ata_probe(struct platform_device *pdev)
struct resource *irq_res;
struct pata_pxa_pdata *pdata = dev_get_platdata(>dev);
struct dma_slave_config config;
-   dma_cap_mask_t mask;
-   struct pxad_param param;
int ret = 0;
 
/*
@@ -278,10 +275,6 @@ static int pxa_ata_probe(struct platform_device *pdev)
 
ap->private_data = data;
 
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = pdata->dma_dreq;
memset(, 0, sizeof(config));
config.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
config.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
@@ -294,8 +287,7 @@ static int pxa_ata_probe(struct platform_device *pdev)
 * Request the DMA channel
 */
data->dma_chan =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "data");
+   dma_request_slave_channel(>dev, "data");
if (!data->dma_chan)
return -EBUSY;
ret = dmaengine_slave_config(data->dma_chan, );
-- 
2.11.0



[PATCH v2 10/13] dmaengine: pxa: document pxad_param

2018-05-24 Thread Robert Jarzmik
Add some documentation for the pxad_param structure, and describe the
contract behind the minimal required priority of a DMA channel.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 include/linux/dma/pxa-dma.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/include/linux/dma/pxa-dma.h b/include/linux/dma/pxa-dma.h
index e56ec7af4fd7..9fc594f69eff 100644
--- a/include/linux/dma/pxa-dma.h
+++ b/include/linux/dma/pxa-dma.h
@@ -9,6 +9,15 @@ enum pxad_chan_prio {
PXAD_PRIO_LOWEST,
 };
 
+/**
+ * struct pxad_param - dma channel request parameters
+ * @drcmr: requestor line number
+ * @prio: minimal mandatory priority of the channel
+ *
+ * If a requested channel is granted, its priority will be at least @prio,
+ * ie. if PXAD_PRIO_LOW is required, the requested channel will be either
+ * PXAD_PRIO_LOW, PXAD_PRIO_NORMAL or PXAD_PRIO_HIGHEST.
+ */
 struct pxad_param {
unsigned int drcmr;
enum pxad_chan_prio prio;
-- 
2.11.0



[PATCH v2 05/13] mtd: rawnand: marvell: remove the dmaengine compat need

2018-05-24 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Signed-off-by: Daniel Mack <dan...@zonque.org>
Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/mtd/nand/raw/marvell_nand.c | 17 +
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/mtd/nand/raw/marvell_nand.c 
b/drivers/mtd/nand/raw/marvell_nand.c
index 10e953218948..f9763be078ef 100644
--- a/drivers/mtd/nand/raw/marvell_nand.c
+++ b/drivers/mtd/nand/raw/marvell_nand.c
@@ -2613,8 +2613,6 @@ static int marvell_nfc_init_dma(struct marvell_nfc *nfc)
dev);
struct dma_slave_config config = {};
struct resource *r;
-   dma_cap_mask_t mask;
-   struct pxad_param param;
int ret;
 
if (!IS_ENABLED(CONFIG_PXA_DMA)) {
@@ -2627,20 +2625,7 @@ static int marvell_nfc_init_dma(struct marvell_nfc *nfc)
if (ret)
return ret;
 
-   r = platform_get_resource(pdev, IORESOURCE_DMA, 0);
-   if (!r) {
-   dev_err(nfc->dev, "No resource defined for data DMA\n");
-   return -ENXIO;
-   }
-
-   param.drcmr = r->start;
-   param.prio = PXAD_PRIO_LOWEST;
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   nfc->dma_chan =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, nfc->dev,
-"data");
+   nfc->dma_chan = dma_request_slave_channel(>dev, "data");
if (!nfc->dma_chan) {
dev_err(nfc->dev,
"Unable to request data DMA channel\n");
-- 
2.11.0



[PATCH v2 04/13] media: pxa_camera: remove the dmaengine compat need

2018-05-24 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Acked-by: Hans Verkuil <hans.verk...@cisco.com>
Acked-by: Mauro Carvalho Chehab <mchehab+sams...@kernel.org>
---
 drivers/media/platform/pxa_camera.c | 22 +++---
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/drivers/media/platform/pxa_camera.c 
b/drivers/media/platform/pxa_camera.c
index c71a00736541..4c82d1880753 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -2357,8 +2357,6 @@ static int pxa_camera_probe(struct platform_device *pdev)
.src_maxburst = 8,
.direction = DMA_DEV_TO_MEM,
};
-   dma_cap_mask_t mask;
-   struct pxad_param params;
char clk_name[V4L2_CLK_NAME_SIZE];
int irq;
int err = 0, i;
@@ -2432,34 +2430,20 @@ static int pxa_camera_probe(struct platform_device 
*pdev)
pcdev->base = base;
 
/* request dma */
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   dma_cap_set(DMA_PRIVATE, mask);
-
-   params.prio = 0;
-   params.drcmr = 68;
-   pcdev->dma_chans[0] =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "CI_Y");
+   pcdev->dma_chans[0] = dma_request_slave_channel(>dev, "CI_Y");
if (!pcdev->dma_chans[0]) {
dev_err(>dev, "Can't request DMA for Y\n");
return -ENODEV;
}
 
-   params.drcmr = 69;
-   pcdev->dma_chans[1] =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "CI_U");
+   pcdev->dma_chans[1] = dma_request_slave_channel(>dev, "CI_U");
if (!pcdev->dma_chans[1]) {
dev_err(>dev, "Can't request DMA for Y\n");
err = -ENODEV;
goto exit_free_dma_y;
}
 
-   params.drcmr = 70;
-   pcdev->dma_chans[2] =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "CI_V");
+   pcdev->dma_chans[2] = dma_request_slave_channel(>dev, "CI_V");
if (!pcdev->dma_chans[2]) {
dev_err(>dev, "Can't request DMA for V\n");
err = -ENODEV;
-- 
2.11.0



[PATCH v2 01/13] dmaengine: pxa: use a dma slave map

2018-05-24 Thread Robert Jarzmik
In order to remove the specific knowledge of the dma mapping from PXA
drivers, add a default slave map for pxa architectures.

This won't impact MMP architecture, but is aimed only at all PXA boards.

This is the first step, and once all drivers are converted,
pxad_filter_fn() will be made static, and the DMA resources removed from
device.c.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Reported-by: Arnd Bergmann <a...@arndb.de>
Acked-by: Vinod Koul <vk...@kernel.org>
---
 drivers/dma/pxa_dma.c | 10 +-
 include/linux/platform_data/mmp_dma.h |  4 
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index b53fb618bbf6..9505334f9c6e 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -179,6 +179,8 @@ static unsigned int pxad_drcmr(unsigned int line)
return 0x1000 + line * 4;
 }
 
+bool pxad_filter_fn(struct dma_chan *chan, void *param);
+
 /*
  * Debug fs
  */
@@ -1396,9 +1398,10 @@ static int pxad_probe(struct platform_device *op)
 {
struct pxad_device *pdev;
const struct of_device_id *of_id;
+   const struct dma_slave_map *slave_map = NULL;
struct mmp_dma_platdata *pdata = dev_get_platdata(>dev);
struct resource *iores;
-   int ret, dma_channels = 0, nb_requestors = 0;
+   int ret, dma_channels = 0, nb_requestors = 0, slave_map_cnt = 0;
const enum dma_slave_buswidth widths =
DMA_SLAVE_BUSWIDTH_1_BYTE   | DMA_SLAVE_BUSWIDTH_2_BYTES |
DMA_SLAVE_BUSWIDTH_4_BYTES;
@@ -1429,6 +1432,8 @@ static int pxad_probe(struct platform_device *op)
} else if (pdata && pdata->dma_channels) {
dma_channels = pdata->dma_channels;
nb_requestors = pdata->nb_requestors;
+   slave_map = pdata->slave_map;
+   slave_map_cnt = pdata->slave_map_cnt;
} else {
dma_channels = 32;  /* default 32 channel */
}
@@ -1440,6 +1445,9 @@ static int pxad_probe(struct platform_device *op)
pdev->slave.device_prep_dma_memcpy = pxad_prep_memcpy;
pdev->slave.device_prep_slave_sg = pxad_prep_slave_sg;
pdev->slave.device_prep_dma_cyclic = pxad_prep_dma_cyclic;
+   pdev->slave.filter.map = slave_map;
+   pdev->slave.filter.mapcnt = slave_map_cnt;
+   pdev->slave.filter.fn = pxad_filter_fn;
 
pdev->slave.copy_align = PDMA_ALIGNMENT;
pdev->slave.src_addr_widths = widths;
diff --git a/include/linux/platform_data/mmp_dma.h 
b/include/linux/platform_data/mmp_dma.h
index d1397c8ed94e..6397b9c8149a 100644
--- a/include/linux/platform_data/mmp_dma.h
+++ b/include/linux/platform_data/mmp_dma.h
@@ -12,9 +12,13 @@
 #ifndef MMP_DMA_H
 #define MMP_DMA_H
 
+struct dma_slave_map;
+
 struct mmp_dma_platdata {
int dma_channels;
int nb_requestors;
+   int slave_map_cnt;
+   const struct dma_slave_map *slave_map;
 };
 
 #endif /* MMP_DMA_H */
-- 
2.11.0



[PATCH v2 00/13] ARM: pxa: switch to DMA slave maps

2018-05-24 Thread Robert Jarzmik
This v1 cover letter is quoted in [1].

For maintainers the table below should help you focus on the patches targetted 
at you, and ignore the other noise.

The differences since v1 is by maintainers / topic / patch :
- Arnd and Daniel / PXA topic / 0002
  devices.c split into pxa25x.c, pxa27x.c and pxa3xx.c
- Boris and Daniel / MTD topic / 0005
  Review and ack of this one
- Arnd and netdev / NET topic / 0006 and 0007
  Arnd comment taken, review and ack of these one
- Mark and alsa-devel / ASoC topic / 0008
  Mark, I couldn't keep your former Ack because :
- I changed one line so that the cpu device provides the DMA
- I added pxa2xx-i2s which was forgotten
  Therefore I need a new ack
- Arnd and Daniel / SSP topic / 0013
  Review and ack of this one

Happy review.

--
Robert

Robert Jarzmik (13):
  dmaengine: pxa: use a dma slave map
  ARM: pxa: add dma slave map
  mmc: pxamci: remove the dmaengine compat need
  media: pxa_camera: remove the dmaengine compat need
  mtd: rawnand: marvell: remove the dmaengine compat need
  net: smc911x: remove the dmaengine compat need
  net: smc91x: remove the dmaengine compat need
  ASoC: pxa: remove the dmaengine compat need
  ata: pata_pxa: remove the dmaengine compat need
  dmaengine: pxa: document pxad_param
  dmaengine: pxa: make the filter function internal
  ARM: pxa: remove the DMA IO resources
  ARM: pxa: change SSP DMA channels allocation

 arch/arm/mach-pxa/devices.c   | 148 +-
 arch/arm/mach-pxa/devices.h   |   6 +-
 arch/arm/mach-pxa/pxa25x.c|  41 +-
 arch/arm/mach-pxa/pxa27x.c|  42 +-
 arch/arm/mach-pxa/pxa3xx.c|  44 +-
 arch/arm/plat-pxa/ssp.c   |  47 ---
 drivers/ata/pata_pxa.c|  10 +--
 drivers/dma/pxa_dma.c |  13 ++-
 drivers/media/platform/pxa_camera.c   |  22 +
 drivers/mmc/host/pxamci.c |  29 +--
 drivers/mtd/nand/raw/marvell_nand.c   |  17 +---
 drivers/net/ethernet/smsc/smc911x.c   |  16 +---
 drivers/net/ethernet/smsc/smc91x.c|  12 +--
 drivers/net/ethernet/smsc/smc91x.h|   1 -
 include/linux/dma/pxa-dma.h   |  20 +++--
 include/linux/platform_data/mmp_dma.h |   4 +
 include/linux/pxa2xx_ssp.h|   2 -
 sound/arm/pxa2xx-ac97.c   |  14 +---
 sound/arm/pxa2xx-pcm-lib.c|   6 +-
 sound/soc/pxa/pxa-ssp.c   |   5 +-
 sound/soc/pxa/pxa2xx-ac97.c   |  32 ++--
 sound/soc/pxa/pxa2xx-i2s.c|   6 +-
 22 files changed, 180 insertions(+), 357 deletions(-)

-- 
2.11.0

---
[1] Former v1 cover letter
This serie is aimed at removing the dmaengine slave compat use, and transfer
knowledge of the DMA requestors into architecture code.

This was discussed/advised by Arnd a couple of years back, it's almost time.

The serie is divided in 3 phasees :
 - phase 1 : patch 1/15 and patch 2/15
   => this is the preparation work
 - phase 2 : patches 3/15 .. 10/15
   => this is the switch of all the drivers
   => this one will require either an Ack of the maintainers or be taken by them
  once phase 1 is merged
 - phase 3 : patches 11/15
   => this is the last part, cleanup and removal of export of the DMA filter
  function

As this looks like a patch bomb, each maintainer expressing for his tree either
an Ack or "I want to take through my tree" will be spared in the next iterations
of this serie.

Several of these changes have been tested on actual hardware, including :
 - pxamci
 - pxa_camera
 - smc*
 - ASoC and SSP


[PATCH v2 08/13] ASoC: pxa: remove the dmaengine compat need

2018-05-24 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 sound/arm/pxa2xx-ac97.c | 14 ++
 sound/arm/pxa2xx-pcm-lib.c  |  6 +++---
 sound/soc/pxa/pxa2xx-ac97.c | 32 +---
 sound/soc/pxa/pxa2xx-i2s.c  |  6 ++
 4 files changed, 12 insertions(+), 46 deletions(-)

diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index 4bc244c40f80..236a63cdaf9f 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -63,28 +63,18 @@ static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
.reset  = pxa2xx_ac97_legacy_reset,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_out_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 12,
-};
-
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_out = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_out",
.maxburst   = 32,
-   .filter_data= _ac97_pcm_out_req,
-};
-
-static struct pxad_param pxa2xx_ac97_pcm_in_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 11,
 };
 
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_in = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_in",
.maxburst   = 32,
-   .filter_data= _ac97_pcm_in_req,
 };
 
 static struct snd_pcm *pxa2xx_ac97_pcm;
diff --git a/sound/arm/pxa2xx-pcm-lib.c b/sound/arm/pxa2xx-pcm-lib.c
index e8da3b8ee721..dcbe7ecc1835 100644
--- a/sound/arm/pxa2xx-pcm-lib.c
+++ b/sound/arm/pxa2xx-pcm-lib.c
@@ -125,9 +125,9 @@ int __pxa2xx_pcm_open(struct snd_pcm_substream *substream)
if (ret < 0)
return ret;
 
-   return snd_dmaengine_pcm_open_request_chan(substream,
-   pxad_filter_fn,
-   dma_params->filter_data);
+   return snd_dmaengine_pcm_open(
+   substream, dma_request_slave_channel(rtd->cpu_dai->dev,
+dma_params->chan_name));
 }
 EXPORT_SYMBOL(__pxa2xx_pcm_open);
 
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index 803818aabee9..1b41c0f2a8fb 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -68,61 +68,39 @@ static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
.reset  = pxa2xx_ac97_cold_reset,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_stereo_in_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 11,
-};
-
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_in = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_in",
.maxburst   = 32,
-   .filter_data= _ac97_pcm_stereo_in_req,
-};
-
-static struct pxad_param pxa2xx_ac97_pcm_stereo_out_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 12,
 };
 
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_out = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_out",
.maxburst   = 32,
-   .filter_data= _ac97_pcm_stereo_out_req,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_aux_mono_out_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 10,
-};
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_aux_mono_out = {
.addr   = __PREG(MODR),
.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .chan_name  = "pcm_aux_mono_out",
.maxburst   = 16,
-   .filter_data= _ac97_pcm_aux_mono_out_req,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_aux_mono_in_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 9,
-};
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_aux_mono_in = {
.addr   = __PREG(MODR),
.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .chan_name  = "pcm_aux_mono_in",
.maxburst   = 16,
-   .filter_data= _ac97_pcm_aux_mono_in_req,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_aux_mic_mono_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 8,
-};
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_mic_mono_in = {
.addr   = __PREG(MCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .chan_name  = "pcm_aux_mic_mono",
.maxburst   = 16,
-   .filter_data= _ac97_pcm_aux_mic_mono_req,
 };
 
 static int pxa2xx_ac97_hifi_startup(s

[PATCH v2 13/13] ARM: pxa: change SSP DMA channels allocation

2018-05-24 Thread Robert Jarzmik
Now the dma_slave_map is available for PXA architecture, switch the SSP
device to it.

This specifically means that :
- for platform data based machines, the DMA requestor channels are
  extracted from the slave map, where pxa-ssp-dai. is a 1-1 match to
  ssp., and the channels are either "rx" or "tx".

- for device tree platforms, the dma node should be hooked into the
  pxa2xx-ac97 or pxa-ssp-dai node.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
Since v1: Removed channel names from platform_data
---
 arch/arm/plat-pxa/ssp.c| 47 --
 include/linux/pxa2xx_ssp.h |  2 --
 sound/soc/pxa/pxa-ssp.c|  5 ++---
 3 files changed, 2 insertions(+), 52 deletions(-)

diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c
index ba13f793fbce..ed36dcab80f1 100644
--- a/arch/arm/plat-pxa/ssp.c
+++ b/arch/arm/plat-pxa/ssp.c
@@ -127,53 +127,6 @@ static int pxa_ssp_probe(struct platform_device *pdev)
if (IS_ERR(ssp->clk))
return PTR_ERR(ssp->clk);
 
-   if (dev->of_node) {
-   struct of_phandle_args dma_spec;
-   struct device_node *np = dev->of_node;
-   int ret;
-
-   /*
-* FIXME: we should allocate the DMA channel from this
-* context and pass the channel down to the ssp users.
-* For now, we lookup the rx and tx indices manually
-*/
-
-   /* rx */
-   ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells",
-0, _spec);
-
-   if (ret) {
-   dev_err(dev, "Can't parse dmas property\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_rx = dma_spec.args[0];
-   of_node_put(dma_spec.np);
-
-   /* tx */
-   ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells",
-1, _spec);
-   if (ret) {
-   dev_err(dev, "Can't parse dmas property\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_tx = dma_spec.args[0];
-   of_node_put(dma_spec.np);
-   } else {
-   res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
-   if (res == NULL) {
-   dev_err(dev, "no SSP RX DRCMR defined\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_rx = res->start;
-
-   res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
-   if (res == NULL) {
-   dev_err(dev, "no SSP TX DRCMR defined\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_tx = res->start;
-   }
-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) {
dev_err(dev, "no memory resource defined\n");
diff --git a/include/linux/pxa2xx_ssp.h b/include/linux/pxa2xx_ssp.h
index 8461b18e4608..03a7ca46735b 100644
--- a/include/linux/pxa2xx_ssp.h
+++ b/include/linux/pxa2xx_ssp.h
@@ -212,8 +212,6 @@ struct ssp_device {
int type;
int use_count;
int irq;
-   int drcmr_rx;
-   int drcmr_tx;
 
struct device_node  *of_node;
 };
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index 0291c7cb64eb..e09368d89bbc 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -104,9 +104,8 @@ static int pxa_ssp_startup(struct snd_pcm_substream 
*substream,
dma = kzalloc(sizeof(struct snd_dmaengine_dai_dma_data), GFP_KERNEL);
if (!dma)
return -ENOMEM;
-
-   dma->filter_data = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
-   >drcmr_tx : >drcmr_rx;
+   dma->chan_name = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
+   "tx" : "rx";
 
snd_soc_dai_set_dma_data(cpu_dai, substream, dma);
 
-- 
2.11.0



[PATCH v2 07/13] net: smc91x: remove the dmaengine compat need

2018-05-24 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc91x.c | 12 +---
 drivers/net/ethernet/smsc/smc91x.h |  1 -
 2 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index 080428762858..4c600f430f6d 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2018,18 +2018,8 @@ static int smc_probe(struct net_device *dev, void 
__iomem *ioaddr,
lp->cfg.flags |= SMC91X_USE_DMA;
 #  endif
if (lp->cfg.flags & SMC91X_USE_DMA) {
-   dma_cap_mask_t mask;
-   struct pxad_param param;
-
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = -1UL;
-
lp->dma_chan =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev,
-"data");
+   dma_request_slave_channel(lp->device, "data");
}
 #endif
 
diff --git a/drivers/net/ethernet/smsc/smc91x.h 
b/drivers/net/ethernet/smsc/smc91x.h
index b337ee97e0c0..a27352229fc2 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -301,7 +301,6 @@ struct smc_local {
  * as RX which can overrun memory and lose packets.
  */
 #include 
-#include 
 
 #ifdef SMC_insl
 #undef SMC_insl
-- 
2.11.0



Re: [PATCH 08/15] ASoC: pxa: remove the dmaengine compat need

2018-04-12 Thread Robert Jarzmik
Mark Brown <broo...@kernel.org> writes:

> On Mon, Apr 02, 2018 at 04:26:49PM +0200, Robert Jarzmik wrote:
>> As the pxa architecture switched towards the dmaengine slave map, the
>> old compatibility mechanism to acquire the dma requestor line number and
>> priority are not needed anymore.
>
> Acked-by: Mark Brown <broo...@kernel.org>
>
> If there's no dependency I'm happy to take this for 4.18.
Thanks for the ack.

The patches 1 and 2 are the dependency here, so I'd rather push it through my
tree once the review is complete.

Cheers.

-- 
Robert


Re: [PATCH 00/15] ARM: pxa: switch to DMA slave maps

2018-04-04 Thread Robert Jarzmik
Ulf Hansson <ulf.hans...@linaro.org> writes:

> On 2 April 2018 at 16:26, Robert Jarzmik <robert.jarz...@free.fr> wrote:
>> Hi,
>>
>> This serie is aimed at removing the dmaengine slave compat use, and transfer
>> knowledge of the DMA requestors into architecture code.
>> As this looks like a patch bomb, each maintainer expressing for his tree 
>> either
>> an Ack or "I want to take through my tree" will be spared in the next 
>> iterations
>> of this serie.
>
> Perhaps an option is to send this hole series as PR for 3.17 rc1, that
> would removed some churns and make this faster/easier? Well, if you
> receive the needed acks of course.
For 3.17-rc1 it looks a bit optimistic with the review time ... If I have all
acks, I'll queue it into my pxa tree. If at least one maintainer withholds his
ack, the end of the serie (phase 3) won't be applied until it is sorted out.

Cheers.

--
Robert


Re: [PATCH 02/15] ARM: pxa: add dma slave map

2018-04-03 Thread Robert Jarzmik
Arnd Bergmann  writes:

>> +   { "smc911x.0", "rx", PDMA_FILTER_PARAM(LOWEST, -1) },
>> +   { "smc911x.0", "tx", PDMA_FILTER_PARAM(LOWEST, -1) },
>> +   { "smc91x.0", "data", PDMA_FILTER_PARAM(LOWEST, -1) },
>
> This one is interesting, as you are dealing with an off-chip device,
> and the channel number is '-'1. How does this even work? Does it
> mean

This relies on pxa_dma, in which the "-1" for a requestor line means "no
requestor" or said in another way "always requesting". As a consequence, as soon
as the DMA descriptors are queued, the transfer begins, and it is supposed
implicitely that the FIFO output availability is at least as quick as the system
bus and the DMA size is perfectly fit for the FIFO available bytes.

This is what has been the underlying of DMA transfers of smc91x(x) on the PXA
platforms, where the smc91x(s) are directly wired on the system bus (the same
bus having DRAM, SRAM, IO-mapped devices).

>
>> +   /* PXA25x specific map */
>> +   { "pxa25x-ssp.0", "rx", PDMA_FILTER_PARAM(LOWEST, 13) },
>> +   { "pxa25x-ssp.0", "tx", PDMA_FILTER_PARAM(LOWEST, 14) },
>> +   { "pxa25x-nssp.1", "rx", PDMA_FILTER_PARAM(LOWEST, 15) },
>> +   { "pxa25x-nssp.1", "tx", PDMA_FILTER_PARAM(LOWEST, 16) },
>> +   { "pxa25x-nssp.2", "rx", PDMA_FILTER_PARAM(LOWEST, 23) },
>> +   { "pxa25x-nssp.2", "tx", PDMA_FILTER_PARAM(LOWEST, 24) },
>> +   { "pxa-pcm-audio", "nssp2_rx", PDMA_FILTER_PARAM(LOWEST, 15) },
>> +   { "pxa-pcm-audio", "nssp2_tx", PDMA_FILTER_PARAM(LOWEST, 16) },
>> +   { "pxa-pcm-audio", "nssp3_rx", PDMA_FILTER_PARAM(LOWEST, 23) },
>> +   { "pxa-pcm-audio", "nssp3_tx", PDMA_FILTER_PARAM(LOWEST, 24) },
>> +
>> +   /* PXA27x specific map */
>> +   { "pxa-pcm-audio", "ssp3_rx", PDMA_FILTER_PARAM(LOWEST, 66) },
>> +   { "pxa-pcm-audio", "ssp3_tx", PDMA_FILTER_PARAM(LOWEST, 67) },
>> +   { "pxa27x-camera.0", "CI_Y", PDMA_FILTER_PARAM(HIGHEST, 68) },
>> +   { "pxa27x-camera.0", "CI_U", PDMA_FILTER_PARAM(HIGHEST, 69) },
>> +   { "pxa27x-camera.0", "CI_V", PDMA_FILTER_PARAM(HIGHEST, 70) },
>> +
>> +   /* PXA3xx specific map */
>> +   { "pxa-pcm-audio", "ssp4_rx", PDMA_FILTER_PARAM(LOWEST, 2) },
>> +   { "pxa-pcm-audio", "ssp4_tx", PDMA_FILTER_PARAM(LOWEST, 3) },
>> +   { "pxa2xx-mci.1", "rx", PDMA_FILTER_PARAM(LOWEST, 93) },
>> +   { "pxa2xx-mci.1", "tx", PDMA_FILTER_PARAM(LOWEST, 94) },
>> +   { "pxa3xx-nand", "data", PDMA_FILTER_PARAM(LOWEST, 97) },
>> +   { "pxa2xx-mci.2", "rx", PDMA_FILTER_PARAM(LOWEST, 100) },
>> +   { "pxa2xx-mci.2", "tx", PDMA_FILTER_PARAM(LOWEST, 101) },
>> +};
>
> Since more than half the entries in here are chip specific, maybe it would be
> better to split that table into three and have a copy for each one in
> arch/arm/mach-pxa/pxa{25x.27x.3xx}.c?
Mmmh, today the split is :
 - 16 common entries
 - 10 pxa25x specific entries
 - 5 pxa27x specific entries
 - 7 pxa3xx specific entries
 => total of 38 lines

After the split we'll have :
 - 26 pxa25x specific entries
 - 21 pxa27x specific entries
 - 23 pxa3xx specific entries
 => total of 70 lines

That doubles the number of lines, not counting the declarations, and amending of
pxa2xx_set_dmac_info().

If you think it's worth it, what is the driving benefit behind ?

> Does that mean it's actually a memory-to-memory transfer with a device being
> on the external SRAM interface?
I'm taking this is the follow up to the "-1" question :0

Cheers.

-- 
Robert


[PATCH 05/15] mtd: nand: pxa3xx: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
From: Robert Jarzmik <robert.jarz...@renault.com>

As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/mtd/nand/pxa3xx_nand.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index d1979c7dbe7e..4a56a0aef5b1 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -1518,8 +1518,6 @@ static int pxa3xx_nand_init_buff(struct pxa3xx_nand_info 
*info)
 {
struct platform_device *pdev = info->pdev;
struct dma_slave_config config;
-   dma_cap_mask_t mask;
-   struct pxad_param param;
int ret;
 
info->data_buff = kmalloc(info->buf_size, GFP_KERNEL);
@@ -1533,13 +1531,7 @@ static int pxa3xx_nand_init_buff(struct pxa3xx_nand_info 
*info)
return ret;
 
sg_init_one(>sg, info->data_buff, info->buf_size);
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = info->drcmr_dat;
-   info->dma_chan = dma_request_slave_channel_compat(mask, pxad_filter_fn,
- , >dev,
- "data");
+   info->dma_chan = dma_request_slave_channel(>dev, "data");
if (!info->dma_chan) {
dev_err(>dev, "unable to request data dma channel\n");
return -ENODEV;
-- 
2.11.0



[PATCH 02/15] ARM: pxa: add dma slave map

2018-04-02 Thread Robert Jarzmik
In order to remove the specific knowledge of the dma mapping from PXA
drivers, add a default slave map for pxa architectures.

This is the first step, and once all drivers are converted,
pxad_filter_fn() will be made static, and the DMA resources removed from
device.c.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Reported-by: Arnd Bergmann <a...@arndb.de>
---
 arch/arm/mach-pxa/devices.c | 55 +
 1 file changed, 55 insertions(+)

diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index d7c9a8476d57..da67ebe9a7d5 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -4,6 +4,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
@@ -1202,9 +1204,62 @@ void __init pxa2xx_set_spi_info(unsigned id, struct 
pxa2xx_spi_master *info)
platform_device_add(pd);
 }
 
+#define PDMA_FILTER_PARAM(_prio, _requestor) (&(struct pxad_param) { \
+   .prio = PXAD_PRIO_##_prio, .drcmr = _requestor })
+
+static const struct dma_slave_map pxa_slave_map[] = {
+   /* PXA25x, PXA27x and PXA3xx common entries */
+   { "pxa-pcm-audio", "ac97_mic_mono", PDMA_FILTER_PARAM(LOWEST, 8) },
+   { "pxa-pcm-audio", "ac97_aux_mono_in", PDMA_FILTER_PARAM(LOWEST, 9) },
+   { "pxa-pcm-audio", "ac97_aux_mono_out", PDMA_FILTER_PARAM(LOWEST, 10) },
+   { "pxa-pcm-audio", "ac97_stereo_in", PDMA_FILTER_PARAM(LOWEST, 11) },
+   { "pxa-pcm-audio", "ac97_stereo_out", PDMA_FILTER_PARAM(LOWEST, 12) },
+   { "pxa-pcm-audio", "ssp1_rx", PDMA_FILTER_PARAM(LOWEST, 13) },
+   { "pxa-pcm-audio", "ssp1_tx", PDMA_FILTER_PARAM(LOWEST, 14) },
+   { "pxa-pcm-audio", "ssp2_rx", PDMA_FILTER_PARAM(LOWEST, 15) },
+   { "pxa-pcm-audio", "ssp2_tx", PDMA_FILTER_PARAM(LOWEST, 16) },
+   { "pxa2xx-ir", "rx", PDMA_FILTER_PARAM(LOWEST, 17) },
+   { "pxa2xx-ir", "tx", PDMA_FILTER_PARAM(LOWEST, 18) },
+   { "pxa2xx-mci.0", "rx", PDMA_FILTER_PARAM(LOWEST, 21) },
+   { "pxa2xx-mci.0", "tx", PDMA_FILTER_PARAM(LOWEST, 22) },
+   { "smc911x.0", "rx", PDMA_FILTER_PARAM(LOWEST, -1) },
+   { "smc911x.0", "tx", PDMA_FILTER_PARAM(LOWEST, -1) },
+   { "smc91x.0", "data", PDMA_FILTER_PARAM(LOWEST, -1) },
+
+   /* PXA25x specific map */
+   { "pxa25x-ssp.0", "rx", PDMA_FILTER_PARAM(LOWEST, 13) },
+   { "pxa25x-ssp.0", "tx", PDMA_FILTER_PARAM(LOWEST, 14) },
+   { "pxa25x-nssp.1", "rx", PDMA_FILTER_PARAM(LOWEST, 15) },
+   { "pxa25x-nssp.1", "tx", PDMA_FILTER_PARAM(LOWEST, 16) },
+   { "pxa25x-nssp.2", "rx", PDMA_FILTER_PARAM(LOWEST, 23) },
+   { "pxa25x-nssp.2", "tx", PDMA_FILTER_PARAM(LOWEST, 24) },
+   { "pxa-pcm-audio", "nssp2_rx", PDMA_FILTER_PARAM(LOWEST, 15) },
+   { "pxa-pcm-audio", "nssp2_tx", PDMA_FILTER_PARAM(LOWEST, 16) },
+   { "pxa-pcm-audio", "nssp3_rx", PDMA_FILTER_PARAM(LOWEST, 23) },
+   { "pxa-pcm-audio", "nssp3_tx", PDMA_FILTER_PARAM(LOWEST, 24) },
+
+   /* PXA27x specific map */
+   { "pxa-pcm-audio", "ssp3_rx", PDMA_FILTER_PARAM(LOWEST, 66) },
+   { "pxa-pcm-audio", "ssp3_tx", PDMA_FILTER_PARAM(LOWEST, 67) },
+   { "pxa27x-camera.0", "CI_Y", PDMA_FILTER_PARAM(HIGHEST, 68) },
+   { "pxa27x-camera.0", "CI_U", PDMA_FILTER_PARAM(HIGHEST, 69) },
+   { "pxa27x-camera.0", "CI_V", PDMA_FILTER_PARAM(HIGHEST, 70) },
+
+   /* PXA3xx specific map */
+   { "pxa-pcm-audio", "ssp4_rx", PDMA_FILTER_PARAM(LOWEST, 2) },
+   { "pxa-pcm-audio", "ssp4_tx", PDMA_FILTER_PARAM(LOWEST, 3) },
+   { "pxa2xx-mci.1", "rx", PDMA_FILTER_PARAM(LOWEST, 93) },
+   { "pxa2xx-mci.1", "tx", PDMA_FILTER_PARAM(LOWEST, 94) },
+   { "pxa3xx-nand", "data", PDMA_FILTER_PARAM(LOWEST, 97) },
+   { "pxa2xx-mci.2", "rx", PDMA_FILTER_PARAM(LOWEST, 100) },
+   { "pxa2xx-mci.2", "tx", PDMA_FILTER_PARAM(LOWEST, 101) },
+};
+
 static struct mmp_dma_platdata pxa_dma_pdata = {
.dma_channels   = 0,
.nb_requestors  = 0,
+   .slave_map  = pxa_slave_map,
+   .slave_map_cnt  = ARRAY_SIZE(pxa_slave_map),
 };
 
 static struct resource pxa_dma_resource[] = {
-- 
2.11.0



[PATCH 00/15] ARM: pxa: switch to DMA slave maps

2018-04-02 Thread Robert Jarzmik
Hi,

This serie is aimed at removing the dmaengine slave compat use, and transfer
knowledge of the DMA requestors into architecture code.

This was discussed/advised by Arnd a couple of years back, it's almost time.

The serie is divided in 3 phasees :
 - phase 1 : patch 1/15 and patch 2/15
   => this is the preparation work
 - phase 2 : patches 3/15 .. 10/15
   => this is the switch of all the drivers
   => this one will require either an Ack of the maintainers or be taken by them
  once phase 1 is merged
 - phase 3 : patches 11/15
   => this is the last part, cleanup and removal of export of the DMA filter
  function

As this looks like a patch bomb, each maintainer expressing for his tree either
an Ack or "I want to take through my tree" will be spared in the next iterations
of this serie.

Several of these changes have been tested on actual hardware, including :
 - pxamci
 - pxa_camera
 - smc*
 - ASoC and SSP

Happy review.

Robert Jarzmik (15):
  dmaengine: pxa: use a dma slave map
  ARM: pxa: add dma slave map
  mmc: pxamci: remove the dmaengine compat need
  media: pxa_camera: remove the dmaengine compat need
  mtd: nand: pxa3xx: remove the dmaengine compat need
  net: smc911x: remove the dmaengine compat need
  net: smc91x: remove the dmaengine compat need
  ASoC: pxa: remove the dmaengine compat need
  net: irda: pxaficp_ir: remove the dmaengine compat need
  ata: pata_pxa: remove the dmaengine compat need
  dmaengine: pxa: document pxad_param
  dmaengine: pxa: make the filter function internal
  ARM: pxa: remove the DMA IO resources
  ARM: pxa: change SSP devices allocation
  ARM: pxa: change SSP DMA channels allocation

 arch/arm/mach-pxa/devices.c   | 269 ++
 arch/arm/mach-pxa/devices.h   |  14 +-
 arch/arm/mach-pxa/include/mach/audio.h|  12 ++
 arch/arm/mach-pxa/pxa25x.c|   4 +-
 arch/arm/mach-pxa/pxa27x.c|   4 +-
 arch/arm/mach-pxa/pxa3xx.c|   5 +-
 arch/arm/plat-pxa/ssp.c   |  50 +-
 drivers/ata/pata_pxa.c|  10 +-
 drivers/dma/pxa_dma.c |  13 +-
 drivers/media/platform/pxa_camera.c   |  22 +--
 drivers/mmc/host/pxamci.c |  29 +---
 drivers/mtd/nand/pxa3xx_nand.c|  10 +-
 drivers/net/ethernet/smsc/smc911x.c   |  16 +-
 drivers/net/ethernet/smsc/smc91x.c|  12 +-
 drivers/net/ethernet/smsc/smc91x.h|   1 -
 drivers/staging/irda/drivers/pxaficp_ir.c |  14 +-
 include/linux/dma/pxa-dma.h   |  20 +--
 include/linux/platform_data/mmp_dma.h |   4 +
 include/linux/pxa2xx_ssp.h|   4 +-
 sound/arm/pxa2xx-ac97.c   |  14 +-
 sound/arm/pxa2xx-pcm-lib.c|   6 +-
 sound/soc/pxa/pxa-ssp.c   |   5 +-
 sound/soc/pxa/pxa2xx-ac97.c   |  32 +---
 23 files changed, 196 insertions(+), 374 deletions(-)

-- 
2.11.0



[PATCH 01/15] dmaengine: pxa: use a dma slave map

2018-04-02 Thread Robert Jarzmik
In order to remove the specific knowledge of the dma mapping from PXA
drivers, add a default slave map for pxa architectures.

This won't impact MMP architecture, but is aimed only at all PXA boards.

This is the first step, and once all drivers are converted,
pxad_filter_fn() will be made static, and the DMA resources removed from
device.c.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Reported-by: Arnd Bergmann <a...@arndb.de>
---
 drivers/dma/pxa_dma.c | 10 +-
 include/linux/platform_data/mmp_dma.h |  4 
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index b53fb618bbf6..9505334f9c6e 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -179,6 +179,8 @@ static unsigned int pxad_drcmr(unsigned int line)
return 0x1000 + line * 4;
 }
 
+bool pxad_filter_fn(struct dma_chan *chan, void *param);
+
 /*
  * Debug fs
  */
@@ -1396,9 +1398,10 @@ static int pxad_probe(struct platform_device *op)
 {
struct pxad_device *pdev;
const struct of_device_id *of_id;
+   const struct dma_slave_map *slave_map = NULL;
struct mmp_dma_platdata *pdata = dev_get_platdata(>dev);
struct resource *iores;
-   int ret, dma_channels = 0, nb_requestors = 0;
+   int ret, dma_channels = 0, nb_requestors = 0, slave_map_cnt = 0;
const enum dma_slave_buswidth widths =
DMA_SLAVE_BUSWIDTH_1_BYTE   | DMA_SLAVE_BUSWIDTH_2_BYTES |
DMA_SLAVE_BUSWIDTH_4_BYTES;
@@ -1429,6 +1432,8 @@ static int pxad_probe(struct platform_device *op)
} else if (pdata && pdata->dma_channels) {
dma_channels = pdata->dma_channels;
nb_requestors = pdata->nb_requestors;
+   slave_map = pdata->slave_map;
+   slave_map_cnt = pdata->slave_map_cnt;
} else {
dma_channels = 32;  /* default 32 channel */
}
@@ -1440,6 +1445,9 @@ static int pxad_probe(struct platform_device *op)
pdev->slave.device_prep_dma_memcpy = pxad_prep_memcpy;
pdev->slave.device_prep_slave_sg = pxad_prep_slave_sg;
pdev->slave.device_prep_dma_cyclic = pxad_prep_dma_cyclic;
+   pdev->slave.filter.map = slave_map;
+   pdev->slave.filter.mapcnt = slave_map_cnt;
+   pdev->slave.filter.fn = pxad_filter_fn;
 
pdev->slave.copy_align = PDMA_ALIGNMENT;
pdev->slave.src_addr_widths = widths;
diff --git a/include/linux/platform_data/mmp_dma.h 
b/include/linux/platform_data/mmp_dma.h
index d1397c8ed94e..6397b9c8149a 100644
--- a/include/linux/platform_data/mmp_dma.h
+++ b/include/linux/platform_data/mmp_dma.h
@@ -12,9 +12,13 @@
 #ifndef MMP_DMA_H
 #define MMP_DMA_H
 
+struct dma_slave_map;
+
 struct mmp_dma_platdata {
int dma_channels;
int nb_requestors;
+   int slave_map_cnt;
+   const struct dma_slave_map *slave_map;
 };
 
 #endif /* MMP_DMA_H */
-- 
2.11.0



[PATCH 03/15] mmc: pxamci: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/mmc/host/pxamci.c | 29 +++--
 1 file changed, 3 insertions(+), 26 deletions(-)

diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index c763b404510f..6c94474e36f4 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -24,7 +24,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -637,10 +636,8 @@ static int pxamci_probe(struct platform_device *pdev)
 {
struct mmc_host *mmc;
struct pxamci_host *host = NULL;
-   struct resource *r, *dmarx, *dmatx;
-   struct pxad_param param_rx, param_tx;
+   struct resource *r;
int ret, irq, gpio_cd = -1, gpio_ro = -1, gpio_power = -1;
-   dma_cap_mask_t mask;
 
ret = pxamci_of_init(pdev);
if (ret)
@@ -739,34 +736,14 @@ static int pxamci_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, mmc);
 
-   if (!pdev->dev.of_node) {
-   dmarx = platform_get_resource(pdev, IORESOURCE_DMA, 0);
-   dmatx = platform_get_resource(pdev, IORESOURCE_DMA, 1);
-   if (!dmarx || !dmatx) {
-   ret = -ENXIO;
-   goto out;
-   }
-   param_rx.prio = PXAD_PRIO_LOWEST;
-   param_rx.drcmr = dmarx->start;
-   param_tx.prio = PXAD_PRIO_LOWEST;
-   param_tx.drcmr = dmatx->start;
-   }
-
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-
-   host->dma_chan_rx =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-_rx, >dev, "rx");
+   host->dma_chan_rx = dma_request_slave_channel(>dev, "rx");
if (host->dma_chan_rx == NULL) {
dev_err(>dev, "unable to request rx dma channel\n");
ret = -ENODEV;
goto out;
}
 
-   host->dma_chan_tx =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-_tx,  >dev, "tx");
+   host->dma_chan_tx = dma_request_slave_channel(>dev, "tx");
if (host->dma_chan_tx == NULL) {
dev_err(>dev, "unable to request tx dma channel\n");
ret = -ENODEV;
-- 
2.11.0



[PATCH 04/15] media: pxa_camera: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
From: Robert Jarzmik <robert.jarz...@renault.com>

As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/media/platform/pxa_camera.c | 22 +++---
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/drivers/media/platform/pxa_camera.c 
b/drivers/media/platform/pxa_camera.c
index c71a00736541..4c82d1880753 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -2357,8 +2357,6 @@ static int pxa_camera_probe(struct platform_device *pdev)
.src_maxburst = 8,
.direction = DMA_DEV_TO_MEM,
};
-   dma_cap_mask_t mask;
-   struct pxad_param params;
char clk_name[V4L2_CLK_NAME_SIZE];
int irq;
int err = 0, i;
@@ -2432,34 +2430,20 @@ static int pxa_camera_probe(struct platform_device 
*pdev)
pcdev->base = base;
 
/* request dma */
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   dma_cap_set(DMA_PRIVATE, mask);
-
-   params.prio = 0;
-   params.drcmr = 68;
-   pcdev->dma_chans[0] =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "CI_Y");
+   pcdev->dma_chans[0] = dma_request_slave_channel(>dev, "CI_Y");
if (!pcdev->dma_chans[0]) {
dev_err(>dev, "Can't request DMA for Y\n");
return -ENODEV;
}
 
-   params.drcmr = 69;
-   pcdev->dma_chans[1] =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "CI_U");
+   pcdev->dma_chans[1] = dma_request_slave_channel(>dev, "CI_U");
if (!pcdev->dma_chans[1]) {
dev_err(>dev, "Can't request DMA for Y\n");
err = -ENODEV;
goto exit_free_dma_y;
}
 
-   params.drcmr = 70;
-   pcdev->dma_chans[2] =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "CI_V");
+   pcdev->dma_chans[2] = dma_request_slave_channel(>dev, "CI_V");
if (!pcdev->dma_chans[2]) {
dev_err(>dev, "Can't request DMA for V\n");
err = -ENODEV;
-- 
2.11.0



[PATCH 06/15] net: smc911x: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
From: Robert Jarzmik <robert.jarz...@renault.com>

As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc911x.c | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc911x.c 
b/drivers/net/ethernet/smsc/smc911x.c
index 05157442a980..4c3713bd5caa 100644
--- a/drivers/net/ethernet/smsc/smc911x.c
+++ b/drivers/net/ethernet/smsc/smc911x.c
@@ -74,7 +74,6 @@ static const char version[] =
 #include 
 
 #include 
-#include 
 
 #include 
 
@@ -1794,8 +1793,6 @@ static int smc911x_probe(struct net_device *dev)
unsigned long irq_flags;
 #ifdef SMC_USE_DMA
struct dma_slave_config config;
-   dma_cap_mask_t mask;
-   struct pxad_param param;
 #endif
 
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
@@ -1969,17 +1966,8 @@ static int smc911x_probe(struct net_device *dev)
 
 #ifdef SMC_USE_DMA
 
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = -1UL;
-
-   lp->rxdma =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "rx");
-   lp->txdma =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "tx");
+   lp->rxdma = dma_request_slave_channel(>dev, "rx");
+   lp->txdma = dma_request_slave_channel(>dev, "tx");
lp->rxdma_active = 0;
lp->txdma_active = 0;
 
-- 
2.11.0



[PATCH 08/15] ASoC: pxa: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 sound/arm/pxa2xx-ac97.c | 14 ++
 sound/arm/pxa2xx-pcm-lib.c  |  6 +++---
 sound/soc/pxa/pxa2xx-ac97.c | 32 +---
 3 files changed, 10 insertions(+), 42 deletions(-)

diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index 4bc244c40f80..236a63cdaf9f 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -63,28 +63,18 @@ static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
.reset  = pxa2xx_ac97_legacy_reset,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_out_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 12,
-};
-
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_out = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_out",
.maxburst   = 32,
-   .filter_data= _ac97_pcm_out_req,
-};
-
-static struct pxad_param pxa2xx_ac97_pcm_in_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 11,
 };
 
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_in = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_in",
.maxburst   = 32,
-   .filter_data= _ac97_pcm_in_req,
 };
 
 static struct snd_pcm *pxa2xx_ac97_pcm;
diff --git a/sound/arm/pxa2xx-pcm-lib.c b/sound/arm/pxa2xx-pcm-lib.c
index e8da3b8ee721..cbfaba60b79a 100644
--- a/sound/arm/pxa2xx-pcm-lib.c
+++ b/sound/arm/pxa2xx-pcm-lib.c
@@ -125,9 +125,9 @@ int __pxa2xx_pcm_open(struct snd_pcm_substream *substream)
if (ret < 0)
return ret;
 
-   return snd_dmaengine_pcm_open_request_chan(substream,
-   pxad_filter_fn,
-   dma_params->filter_data);
+   return snd_dmaengine_pcm_open(
+   substream, dma_request_slave_channel(rtd->platform->dev,
+dma_params->chan_name));
 }
 EXPORT_SYMBOL(__pxa2xx_pcm_open);
 
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index 803818aabee9..1b41c0f2a8fb 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -68,61 +68,39 @@ static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
.reset  = pxa2xx_ac97_cold_reset,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_stereo_in_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 11,
-};
-
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_in = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_in",
.maxburst   = 32,
-   .filter_data= _ac97_pcm_stereo_in_req,
-};
-
-static struct pxad_param pxa2xx_ac97_pcm_stereo_out_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 12,
 };
 
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_stereo_out = {
.addr   = __PREG(PCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
+   .chan_name  = "pcm_pcm_stereo_out",
.maxburst   = 32,
-   .filter_data= _ac97_pcm_stereo_out_req,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_aux_mono_out_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 10,
-};
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_aux_mono_out = {
.addr   = __PREG(MODR),
.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .chan_name  = "pcm_aux_mono_out",
.maxburst   = 16,
-   .filter_data= _ac97_pcm_aux_mono_out_req,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_aux_mono_in_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 9,
-};
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_aux_mono_in = {
.addr   = __PREG(MODR),
.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .chan_name  = "pcm_aux_mono_in",
.maxburst   = 16,
-   .filter_data= _ac97_pcm_aux_mono_in_req,
 };
 
-static struct pxad_param pxa2xx_ac97_pcm_aux_mic_mono_req = {
-   .prio = PXAD_PRIO_LOWEST,
-   .drcmr = 8,
-};
 static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_mic_mono_in = {
.addr   = __PREG(MCDR),
.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES,
+   .chan_name  = "pcm_aux_mic_mono",
.maxburst   = 16,
-   .filter_data= _ac97_pcm_aux_mic_mono_req,
 };
 
 static int pxa2xx_ac97_hifi_startup(struct snd_pcm_substream *substream,
-- 
2.11.0



[PATCH 07/15] net: smc91x: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
From: Robert Jarzmik <robert.jarz...@renault.com>

As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc91x.c | 12 +---
 drivers/net/ethernet/smsc/smc91x.h |  1 -
 2 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index 080428762858..4c600f430f6d 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2018,18 +2018,8 @@ static int smc_probe(struct net_device *dev, void 
__iomem *ioaddr,
lp->cfg.flags |= SMC91X_USE_DMA;
 #  endif
if (lp->cfg.flags & SMC91X_USE_DMA) {
-   dma_cap_mask_t mask;
-   struct pxad_param param;
-
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = -1UL;
-
lp->dma_chan =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev,
-"data");
+   dma_request_slave_channel(lp->device, "data");
}
 #endif
 
diff --git a/drivers/net/ethernet/smsc/smc91x.h 
b/drivers/net/ethernet/smsc/smc91x.h
index 08b17adf0a65..e849b6c2fa60 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -327,7 +327,6 @@ struct smc_local {
  * as RX which can overrun memory and lose packets.
  */
 #include 
-#include 
 
 #ifdef SMC_insl
 #undef SMC_insl
-- 
2.11.0



[PATCH 11/15] dmaengine: pxa: document pxad_param

2018-04-02 Thread Robert Jarzmik
Add some documentation for the pxad_param structure, and describe the
contract behind the minimal required priority of a DMA channel.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 include/linux/dma/pxa-dma.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/include/linux/dma/pxa-dma.h b/include/linux/dma/pxa-dma.h
index e56ec7af4fd7..9fc594f69eff 100644
--- a/include/linux/dma/pxa-dma.h
+++ b/include/linux/dma/pxa-dma.h
@@ -9,6 +9,15 @@ enum pxad_chan_prio {
PXAD_PRIO_LOWEST,
 };
 
+/**
+ * struct pxad_param - dma channel request parameters
+ * @drcmr: requestor line number
+ * @prio: minimal mandatory priority of the channel
+ *
+ * If a requested channel is granted, its priority will be at least @prio,
+ * ie. if PXAD_PRIO_LOW is required, the requested channel will be either
+ * PXAD_PRIO_LOW, PXAD_PRIO_NORMAL or PXAD_PRIO_HIGHEST.
+ */
 struct pxad_param {
unsigned int drcmr;
enum pxad_chan_prio prio;
-- 
2.11.0



[PATCH 10/15] ata: pata_pxa: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/ata/pata_pxa.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c
index f6c46e9a4dc0..e8b6a2e464c9 100644
--- a/drivers/ata/pata_pxa.c
+++ b/drivers/ata/pata_pxa.c
@@ -25,7 +25,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -180,8 +179,6 @@ static int pxa_ata_probe(struct platform_device *pdev)
struct resource *irq_res;
struct pata_pxa_pdata *pdata = dev_get_platdata(>dev);
struct dma_slave_config config;
-   dma_cap_mask_t mask;
-   struct pxad_param param;
int ret = 0;
 
/*
@@ -278,10 +275,6 @@ static int pxa_ata_probe(struct platform_device *pdev)
 
ap->private_data = data;
 
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
-   param.drcmr = pdata->dma_dreq;
memset(, 0, sizeof(config));
config.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
config.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
@@ -294,8 +287,7 @@ static int pxa_ata_probe(struct platform_device *pdev)
 * Request the DMA channel
 */
data->dma_chan =
-   dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "data");
+   dma_request_slave_channel(>dev, "data");
if (!data->dma_chan)
return -EBUSY;
ret = dmaengine_slave_config(data->dma_chan, );
-- 
2.11.0



[PATCH 12/15] dmaengine: pxa: make the filter function internal

2018-04-02 Thread Robert Jarzmik
As the pxa architecture and all its related drivers do not rely anymore
on the filter function, thanks to the slave map conversion, make
pxad_filter_fn() static, and remove it from the global namespace.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/dma/pxa_dma.c   |  5 ++---
 include/linux/dma/pxa-dma.h | 11 ---
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index 9505334f9c6e..a332ad1d7dfb 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -179,7 +179,7 @@ static unsigned int pxad_drcmr(unsigned int line)
return 0x1000 + line * 4;
 }
 
-bool pxad_filter_fn(struct dma_chan *chan, void *param);
+static bool pxad_filter_fn(struct dma_chan *chan, void *param);
 
 /*
  * Debug fs
@@ -1496,7 +1496,7 @@ static struct platform_driver pxad_driver = {
.remove = pxad_remove,
 };
 
-bool pxad_filter_fn(struct dma_chan *chan, void *param)
+static bool pxad_filter_fn(struct dma_chan *chan, void *param)
 {
struct pxad_chan *c = to_pxad_chan(chan);
struct pxad_param *p = param;
@@ -1509,7 +1509,6 @@ bool pxad_filter_fn(struct dma_chan *chan, void *param)
 
return true;
 }
-EXPORT_SYMBOL_GPL(pxad_filter_fn);
 
 module_platform_driver(pxad_driver);
 
diff --git a/include/linux/dma/pxa-dma.h b/include/linux/dma/pxa-dma.h
index 9fc594f69eff..fceb5df07097 100644
--- a/include/linux/dma/pxa-dma.h
+++ b/include/linux/dma/pxa-dma.h
@@ -23,15 +23,4 @@ struct pxad_param {
enum pxad_chan_prio prio;
 };
 
-struct dma_chan;
-
-#ifdef CONFIG_PXA_DMA
-bool pxad_filter_fn(struct dma_chan *chan, void *param);
-#else
-static inline bool pxad_filter_fn(struct dma_chan *chan, void *param)
-{
-   return false;
-}
-#endif
-
 #endif /* _PXA_DMA_H_ */
-- 
2.11.0



[PATCH 15/15] ARM: pxa: change SSP DMA channels allocation

2018-04-02 Thread Robert Jarzmik
Now the dma_slave_map is available for PXA architecture, switch the SSP
device to it.

This specifically means that :
- for platform data based machines, the DMA requestor channels are
  extracted from platform data and passed further to the SSP user,
  ie. usually the pxa-pcm-audio driver

- for device tree platforms, the dma node should be hooked into the
  pxa-pcm-audio node.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 arch/arm/plat-pxa/ssp.c| 50 +-
 include/linux/pxa2xx_ssp.h |  4 ++--
 sound/soc/pxa/pxa-ssp.c|  5 ++---
 3 files changed, 9 insertions(+), 50 deletions(-)

diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c
index ba13f793fbce..3457f01e3340 100644
--- a/arch/arm/plat-pxa/ssp.c
+++ b/arch/arm/plat-pxa/ssp.c
@@ -16,6 +16,7 @@
  *  Author: Liam Girdwood <liam.girdw...@wolfsonmicro.com>
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -116,6 +117,7 @@ static int pxa_ssp_probe(struct platform_device *pdev)
struct resource *res;
struct ssp_device *ssp;
struct device *dev = >dev;
+   struct pxa_ssp_info *info = dev_get_platdata(dev);
 
ssp = devm_kzalloc(dev, sizeof(struct ssp_device), GFP_KERNEL);
if (ssp == NULL)
@@ -127,51 +129,9 @@ static int pxa_ssp_probe(struct platform_device *pdev)
if (IS_ERR(ssp->clk))
return PTR_ERR(ssp->clk);
 
-   if (dev->of_node) {
-   struct of_phandle_args dma_spec;
-   struct device_node *np = dev->of_node;
-   int ret;
-
-   /*
-* FIXME: we should allocate the DMA channel from this
-* context and pass the channel down to the ssp users.
-* For now, we lookup the rx and tx indices manually
-*/
-
-   /* rx */
-   ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells",
-0, _spec);
-
-   if (ret) {
-   dev_err(dev, "Can't parse dmas property\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_rx = dma_spec.args[0];
-   of_node_put(dma_spec.np);
-
-   /* tx */
-   ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells",
-1, _spec);
-   if (ret) {
-   dev_err(dev, "Can't parse dmas property\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_tx = dma_spec.args[0];
-   of_node_put(dma_spec.np);
-   } else {
-   res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
-   if (res == NULL) {
-   dev_err(dev, "no SSP RX DRCMR defined\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_rx = res->start;
-
-   res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
-   if (res == NULL) {
-   dev_err(dev, "no SSP TX DRCMR defined\n");
-   return -ENODEV;
-   }
-   ssp->drcmr_tx = res->start;
+   if (!dev->of_node && info) {
+   ssp->dma_chan_rx = info->dma_chan_rx_name;
+   ssp->dma_chan_tx = info->dma_chan_tx_name;
}
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/include/linux/pxa2xx_ssp.h b/include/linux/pxa2xx_ssp.h
index 8461b18e4608..99c99d397e4d 100644
--- a/include/linux/pxa2xx_ssp.h
+++ b/include/linux/pxa2xx_ssp.h
@@ -212,9 +212,9 @@ struct ssp_device {
int type;
int use_count;
int irq;
-   int drcmr_rx;
-   int drcmr_tx;
 
+   const char  *dma_chan_rx;
+   const char  *dma_chan_tx;
struct device_node  *of_node;
 };
 
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index 0291c7cb64eb..a0189b88f1d2 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -104,9 +104,8 @@ static int pxa_ssp_startup(struct snd_pcm_substream 
*substream,
dma = kzalloc(sizeof(struct snd_dmaengine_dai_dma_data), GFP_KERNEL);
if (!dma)
return -ENOMEM;
-
-   dma->filter_data = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
-   >drcmr_tx : >drcmr_rx;
+   dma->chan_name = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
+   ssp->dma_chan_tx : ssp->dma_chan_rx;
 
snd_soc_dai_set_dma_data(cpu_dai, substream, dma);
 
-- 
2.11.0



[PATCH 14/15] ARM: pxa: change SSP devices allocation

2018-04-02 Thread Robert Jarzmik
In order to prepare for the dma_slave_map change for SSP DMA channels
allocation, the SSP platform devices will now include a platform data
structure which in turn selects which dma channel has to be used for
data transfers, especially the PCM ones.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 arch/arm/mach-pxa/devices.c| 78 +-
 arch/arm/mach-pxa/devices.h| 14 ++
 arch/arm/mach-pxa/include/mach/audio.h | 12 ++
 arch/arm/mach-pxa/pxa25x.c |  4 +-
 arch/arm/mach-pxa/pxa27x.c |  4 +-
 arch/arm/mach-pxa/pxa3xx.c |  5 +--
 6 files changed, 86 insertions(+), 31 deletions(-)

diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index c0b3c90fd67f..955d255dc4f4 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -481,6 +481,17 @@ void __init pxa_set_ac97_info(pxa2xx_audio_ops_t *ops)
pxa_register_device(_device_ac97, ops);
 }
 
+static struct pxa_ssp_info pxa_ssp_infos[] = {
+   { .dma_chan_rx_name = "ssp1_rx", .dma_chan_tx_name = "ssp1_tx", },
+   { .dma_chan_rx_name = "ssp1_rx", .dma_chan_tx_name = "ssp1_tx", },
+   { .dma_chan_rx_name = "ssp2_rx", .dma_chan_tx_name = "ssp2_tx", },
+   { .dma_chan_rx_name = "ssp2_rx", .dma_chan_tx_name = "ssp2_tx", },
+   { .dma_chan_rx_name = "ssp3_rx", .dma_chan_tx_name = "ssp3_tx", },
+   { .dma_chan_rx_name = "ssp3_rx", .dma_chan_tx_name = "ssp3_tx", },
+   { .dma_chan_rx_name = "ssp4_rx", .dma_chan_tx_name = "ssp4_tx", },
+   { .dma_chan_rx_name = "ssp4_rx", .dma_chan_tx_name = "ssp4_tx", },
+};
+
 #ifdef CONFIG_PXA25x
 
 static struct resource pxa25x_resource_pwm0[] = {
@@ -528,7 +539,7 @@ static struct resource pxa25x_resource_ssp[] = {
},
 };
 
-struct platform_device pxa25x_device_ssp = {
+static struct platform_device pxa25x_device_ssp = {
.name   = "pxa25x-ssp",
.id = 0,
.dev= {
@@ -554,7 +565,7 @@ static struct resource pxa25x_resource_nssp[] = {
},
 };
 
-struct platform_device pxa25x_device_nssp = {
+static struct platform_device pxa25x_device_nssp = {
.name   = "pxa25x-nssp",
.id = 1,
.dev= {
@@ -580,7 +591,7 @@ static struct resource pxa25x_resource_assp[] = {
},
 };
 
-struct platform_device pxa25x_device_assp = {
+static struct platform_device pxa25x_device_assp = {
/* ASSP is basically equivalent to NSSP */
.name   = "pxa25x-nssp",
.id = 2,
@@ -591,6 +602,22 @@ struct platform_device pxa25x_device_assp = {
.resource   = pxa25x_resource_assp,
.num_resources  = ARRAY_SIZE(pxa25x_resource_assp),
 };
+
+static struct platform_device *pxa25x_device_ssps[] = {
+   _device_ssp,
+   _device_nssp,
+   _device_assp,
+};
+
+void __init pxa25x_set_ssp_info(void)
+{
+   int ssp;
+
+   for (ssp = 0; ssp < ARRAY_SIZE(pxa25x_device_ssps); ssp++)
+   pxa_register_device(pxa25x_device_ssps[ssp],
+   _ssp_infos[ssp]);
+}
+
 #endif /* CONFIG_PXA25x */
 
 #if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
@@ -698,7 +725,7 @@ static struct resource pxa27x_resource_ssp1[] = {
},
 };
 
-struct platform_device pxa27x_device_ssp1 = {
+static struct platform_device pxa27x_device_ssp1 = {
.name   = "pxa27x-ssp",
.id = 0,
.dev= {
@@ -724,7 +751,7 @@ static struct resource pxa27x_resource_ssp2[] = {
},
 };
 
-struct platform_device pxa27x_device_ssp2 = {
+static struct platform_device pxa27x_device_ssp2 = {
.name   = "pxa27x-ssp",
.id = 1,
.dev= {
@@ -750,7 +777,7 @@ static struct resource pxa27x_resource_ssp3[] = {
},
 };
 
-struct platform_device pxa27x_device_ssp3 = {
+static struct platform_device pxa27x_device_ssp3 = {
.name   = "pxa27x-ssp",
.id = 2,
.dev= {
@@ -761,6 +788,21 @@ struct platform_device pxa27x_device_ssp3 = {
.num_resources  = ARRAY_SIZE(pxa27x_resource_ssp3),
 };
 
+static struct platform_device *pxa27x_device_ssps[] = {
+   _device_ssp1,
+   _device_ssp2,
+   _device_ssp3,
+};
+
+void __init pxa27x_set_ssp_info(void)
+{
+   int ssp;
+
+   for (ssp = 0; ssp < ARRAY_SIZE(pxa27x_device_ssps); ssp++)
+   pxa_register_device(pxa27x_device_ssps[ssp],
+   _ssp_infos[ssp]);
+}
+
 static struct resource pxa27x_resource_pwm0[] = {
[0] = {
.start  = 0x40b0,
@@ -951,7 +993,7 @@ static struct re

[PATCH 13/15] ARM: pxa: remove the DMA IO resources

2018-04-02 Thread Robert Jarzmik
As the last driver using the former mechanism to acquire the DMA
requestor line has be converted to the dma_slave_map, remove all these
resources from the PXA devices.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 arch/arm/mach-pxa/devices.c | 136 
 1 file changed, 136 deletions(-)

diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index da67ebe9a7d5..c0b3c90fd67f 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -61,16 +61,6 @@ static struct resource pxamci_resources[] = {
.end= IRQ_MMC,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   .start  = 21,
-   .end= 21,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   .start  = 22,
-   .end= 22,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 static u64 pxamci_dmamask = 0xUL;
@@ -408,16 +398,6 @@ static struct resource pxa_ir_resources[] = {
.end= 0x40700023,
.flags  = IORESOURCE_MEM,
},
-   [5] = {
-   .start  = 17,
-   .end= 17,
-   .flags  = IORESOURCE_DMA,
-   },
-   [6] = {
-   .start  = 18,
-   .end= 18,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa_device_ficp = {
@@ -546,18 +526,6 @@ static struct resource pxa25x_resource_ssp[] = {
.end= IRQ_SSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 13,
-   .end= 13,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 14,
-   .end= 14,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa25x_device_ssp = {
@@ -584,18 +552,6 @@ static struct resource pxa25x_resource_nssp[] = {
.end= IRQ_NSSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 15,
-   .end= 15,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 16,
-   .end= 16,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa25x_device_nssp = {
@@ -622,18 +578,6 @@ static struct resource pxa25x_resource_assp[] = {
.end= IRQ_ASSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 23,
-   .end= 23,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 24,
-   .end= 24,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa25x_device_assp = {
@@ -752,18 +696,6 @@ static struct resource pxa27x_resource_ssp1[] = {
.end= IRQ_SSP,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 13,
-   .end= 13,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 14,
-   .end= 14,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa27x_device_ssp1 = {
@@ -790,18 +722,6 @@ static struct resource pxa27x_resource_ssp2[] = {
.end= IRQ_SSP2,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 15,
-   .end= 15,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 16,
-   .end= 16,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa27x_device_ssp2 = {
@@ -828,18 +748,6 @@ static struct resource pxa27x_resource_ssp3[] = {
.end= IRQ_SSP3,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   /* DRCMR for RX */
-   .start  = 66,
-   .end= 66,
-   .flags  = IORESOURCE_DMA,
-   },
-   [3] = {
-   /* DRCMR for TX */
-   .start  = 67,
-   .end= 67,
-   .flags  = IORESOURCE_DMA,
-   },
 };
 
 struct platform_device pxa27x_device_ssp3 = {
@@ -896,16 +804,6 @@ static struct resource pxa3xx_resources_mci2[] = {
.end= IRQ_MMC2,
.flags  = IORESOURCE_IRQ,
},
-   [2] = {
-   .start  = 93,
-   .end= 93,
-   .flags  = IORESOURCE_DMA,
-   },
-   

[PATCH 09/15] net: irda: pxaficp_ir: remove the dmaengine compat need

2018-04-02 Thread Robert Jarzmik
As the pxa architecture switched towards the dmaengine slave map, the
old compatibility mechanism to acquire the dma requestor line number and
priority are not needed anymore.

This patch simplifies the dma resource acquisition, using the more
generic function dma_request_slave_channel().

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/staging/irda/drivers/pxaficp_ir.c | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/irda/drivers/pxaficp_ir.c 
b/drivers/staging/irda/drivers/pxaficp_ir.c
index 2ea00a6531f9..9dd6e21dc11e 100644
--- a/drivers/staging/irda/drivers/pxaficp_ir.c
+++ b/drivers/staging/irda/drivers/pxaficp_ir.c
@@ -20,7 +20,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -735,9 +734,7 @@ static void pxa_irda_shutdown(struct pxa_irda *si)
 static int pxa_irda_start(struct net_device *dev)
 {
struct pxa_irda *si = netdev_priv(dev);
-   dma_cap_mask_t mask;
struct dma_slave_config config;
-   struct pxad_param param;
int err;
 
si->speed = 9600;
@@ -757,9 +754,6 @@ static int pxa_irda_start(struct net_device *dev)
disable_irq(si->icp_irq);
 
err = -EBUSY;
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   param.prio = PXAD_PRIO_LOWEST;
 
memset(, 0, sizeof(config));
config.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
@@ -769,15 +763,11 @@ static int pxa_irda_start(struct net_device *dev)
config.src_maxburst = 32;
config.dst_maxburst = 32;
 
-   param.drcmr = si->drcmr_rx;
-   si->rxdma = dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "rx");
+   si->rxdma = dma_request_slave_channel(>dev, "rx");
if (!si->rxdma)
goto err_rx_dma;
 
-   param.drcmr = si->drcmr_tx;
-   si->txdma = dma_request_slave_channel_compat(mask, pxad_filter_fn,
-, >dev, "tx");
+   si->txdma = dma_request_slave_channel(>dev, "tx");
if (!si->txdma)
goto err_tx_dma;
 
-- 
2.11.0



Re: [PATCH v2] net: smsc: smc91x: use new api ethtool_{get|set}_link_ksettings

2017-03-05 Thread Robert Jarzmik
Philippe Reynes <trem...@gmail.com> writes:

> The ethtool api {get|set}_settings is deprecated.
> We move this driver to new api {get|set}_link_ksettings.
>
> As I don't have the hardware, I'd be very pleased if
> someone may test this patch.
>
> Signed-off-by: Philippe Reynes <trem...@gmail.com>
> ---
> Changelog:
> v2:
> - also update comment (feeback from Russel King)

Ok, I tested it, with :
ethtool -s eth0 duplex half autoneg off speed 10
ethtool eth0
   => see the changes
ping -f x.x.x.x
ethtool -s eth0 duplex full autoneg on
ethtool eth0
   => see the changes
ping -f x.x.x.x

This both with your patch and without, it works in both cases, and the former as
a smaller throughput, which makes me believe the patch is fine.

Tested-by: Robert Jarzmik <robert.jarz...@free.fr>

Cheers.

--
Robert


Re: [PATCH] net: smsc: smc91x: use new api ethtool_{get|set}_link_ksettings

2017-03-04 Thread Robert Jarzmik
Philippe Reynes  writes:

> The ethtool api {get|set}_settings is deprecated.
> We move this driver to new api {get|set}_link_ksettings.
>
> As I don't have the hardware, I'd be very pleased if
> someone may test this patch.
I have the hardware.

Do you want anything specific to be tested, like setting full/half duplex or
autoneg through ethtool, or just a driver probe/usage ?

Cheers.

-- 
Robert


[PATCH] net: smc91x: fix neponset breakage by pxa u16 writes

2016-10-19 Thread Robert Jarzmik
The patch isolating the u16 writes for pxa assumed all machine_is_*()
calls were removed, and therefore removed the mach-types.h include which
provided them.

Unfortunately 2 machine_is_*() remained in smc91x.c file including
smc91x.h from which the include was removed, triggering the error:
 drivers/net/ethernet/smsc/smc91x.c: In function ‘smc_drv_probe’:
 drivers/net/ethernet/smsc/smc91x.c:2380:2: error: implicit declaration
 of function ‘machine_is_assabet’
 [-Werror=implicit-function-declaration]
if (machine_is_assabet() && machine_has_neponset())

This adds back the wrongly removed include.

Fixes: d09d747ae4c2 ("net: smc91x: isolate u16 writes alignment workaround")
Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc91x.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/smsc/smc91x.h 
b/drivers/net/ethernet/smsc/smc91x.h
index 45e6b81a6a92..08b17adf0a65 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -63,6 +63,8 @@
 
 #if defined(CONFIG_ARM)
 
+#include 
+
 /* Now the bus width is specified in the platform data
  * pretend here to support all I/O access types
  */
-- 
2.1.4



Re: [linux-next:master 1436/1582] drivers/net/ethernet/smsc/smc91x.c:2378:6: error: implicit declaration of function 'machine_is_assabet'

2016-10-19 Thread Robert Jarzmik
David Miller  writes:

> Please send me a fixup follow-on patch.
>
> If changes are in my tree, they are part of the permanent record
> and won't be rebased out.
Ok, understood, I'm on it.

Thanks.

-- 
Robert


Re: [linux-next:master 1436/1582] drivers/net/ethernet/smsc/smc91x.c:2378:6: error: implicit declaration of function 'machine_is_assabet'

2016-10-19 Thread Robert Jarzmik
Hi David,

Here is a little mess I created with my former serie :
>drivers/net/ethernet/smsc/smc91x.c: In function 'smc_drv_probe':
>>> drivers/net/ethernet/smsc/smc91x.c:2378:6: error: implicit declaration of 
>>> function 'machine_is_assabet' [-Werror=implicit-function-declaration]
>  if (machine_is_assabet() && machine_has_neponset())
>  ^~
>cc1: some warnings being treated as errors
>
> vim +/machine_is_assabet +2378 drivers/net/ethernet/smsc/smc91x.c

The mess comes from the patch "net: smc91x: isolate u16 writes alignment
workaround", where I though I had removed all "machine_is_*()" calls, and I
didn't notice the machine_is_assabet() one.

The fix is to re-add the removed include in the wrong chunk in [1].

Now do you want :
 - another apart patch to fix the faulty one
 - a "fixup!" patch to fixup the commit in your next tree
 - or anything else

As I didn't compile assabet, my testers have missed this one. Please tell me
which way suits you to repair this commit.

Cheers.

--
Robert
[1]
@@ -63,8 +63,6 @@
 
 #if defined(CONFIG_ARM)
 
-#include 
-
 /* Now the bus width is specified in the platform data
  * pretend here to support all I/O access types
  */


[PATCH v3 3/4] net: smc91x: take into account half-word workaround

2016-10-17 Thread Robert Jarzmik
For device-tree builds, platforms such as mainstone, idp and stargate2
must have their u16 writes all aligned on 32 bit boundaries. This is
already enabled in platform data builds, and this patch adds it to
device-tree builds.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
Since v1: rename dt property to pxa-u16-align4
---
 drivers/net/ethernet/smsc/smc91x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index 705d99b2d947..65077c77082a 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2326,6 +2326,8 @@ static int smc_drv_probe(struct platform_device *pdev)
if (!device_property_read_u32(>dev, "reg-shift",
  ))
lp->io_shift = val;
+   lp->cfg.pxa_u16_align4 =
+   device_property_read_bool(>dev, "pxa-u16-align4");
}
 #endif
 
-- 
2.1.4



[PATCH v3 4/4] net: smsc91x: add u16 workaround for pxa platforms

2016-10-17 Thread Robert Jarzmik
Add a workaround for mainstone, idp and stargate2 boards, for u16 writes
which must be aligned on 32 bits addresses.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Cc: Jeremy Linton <jeremy.lin...@arm.com>
---
Since v1: rename dt property to pxa-u16-align4
  change the binding documentation file
---
 Documentation/devicetree/bindings/net/smsc-lan91c111.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/smsc-lan91c111.txt 
b/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
index e77e167593db..309e37eb7c7c 100644
--- a/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
+++ b/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
@@ -13,3 +13,5 @@ Optional properties:
   16-bit access only.
 - power-gpios: GPIO to control the PWRDWN pin
 - reset-gpios: GPIO to control the RESET pin
+- pxa-u16-align4 : Boolean, put in place the workaround the force all
+  u16 writes to be 32 bits aligned
-- 
2.1.4



[PATCH v3 2/4] net: smc91x: isolate u16 writes alignment workaround

2016-10-17 Thread Robert Jarzmik
Writes to u16 has a special handling on 3 PXA platforms, where the
hardware wiring forces these writes to be u32 aligned.

This patch isolates this handling for PXA platforms as before, but
enables this "workaround" to be set up dynamically, which will be the
case in device-tree build types.

This patch was tested on 2 PXA platforms : mainstone, which relies on
the workaround, and lubbock, which doesn't.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
--
Since v2: fixed arch/mn10300 case
  removed machine_is_*() calls
---
 arch/mn10300/unit-asb2303/include/unit/smc9.h |  2 +-
 drivers/net/ethernet/smsc/smc91x.c|  3 +-
 drivers/net/ethernet/smsc/smc91x.h| 82 ---
 3 files changed, 47 insertions(+), 40 deletions(-)

diff --git a/arch/mn10300/unit-asb2303/include/unit/smc9.h 
b/arch/mn10300/unit-asb2303/include/unit/smc9.h
index dd456e9c513f..dd4e2946438e 100644
--- a/arch/mn10300/unit-asb2303/include/unit/smc9.h
+++ b/arch/mn10300/unit-asb2303/include/unit/smc9.h
@@ -30,7 +30,7 @@
 
 #if SMC_CAN_USE_16BIT
 #define SMC_inw(a, r)  inw((unsigned long) ((a) + (r)))
-#define SMC_outw(v, a, r)  outw(v, (unsigned long) ((a) + (r)))
+#define SMC_outw(lp, v, a, r)  outw(v, (unsigned long) ((a) + (r)))
 #define SMC_insw(a, r, p, l)   insw((unsigned long) ((a) + (r)), (p), (l))
 #define SMC_outsw(a, r, p, l)  outsw((unsigned long) ((a) + (r)), (p), (l))
 #endif
diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index 9b4780f87863..705d99b2d947 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -602,7 +602,8 @@ static void smc_hardware_send_pkt(unsigned long data)
SMC_PUSH_DATA(lp, buf, len & ~1);
 
/* Send final ctl word with the last byte if there is one */
-   SMC_outw(((len & 1) ? (0x2000 | buf[len-1]) : 0), ioaddr, DATA_REG(lp));
+   SMC_outw(lp, ((len & 1) ? (0x2000 | buf[len - 1]) : 0), ioaddr,
+DATA_REG(lp));
 
/*
 * If THROTTLE_TX_PKTS is set, we stop the queue here. This will
diff --git a/drivers/net/ethernet/smsc/smc91x.h 
b/drivers/net/ethernet/smsc/smc91x.h
index ea8465467469..45e6b81a6a92 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -63,8 +63,6 @@
 
 #if defined(CONFIG_ARM)
 
-#include 
-
 /* Now the bus width is specified in the platform data
  * pretend here to support all I/O access types
  */
@@ -86,11 +84,11 @@
 
 #define SMC_inl(a, r)  readl((a) + (r))
 #define SMC_outb(v, a, r)  writeb(v, (a) + (r))
-#define SMC_outw(v, a, r)  \
+#define SMC_outw(lp, v, a, r)  \
do {\
unsigned int __v = v, __smc_r = r;  \
if (SMC_16BIT(lp))  \
-   __SMC_outw(__v, a, __smc_r);\
+   __SMC_outw(lp, __v, a, __smc_r);\
else if (SMC_8BIT(lp))  \
SMC_outw_b(__v, a, __smc_r);\
else\
@@ -107,10 +105,10 @@
 #define SMC_IRQ_FLAGS  (-1)/* from resource */
 
 /* We actually can't write halfwords properly if not word aligned */
-static inline void __SMC_outw(u16 val, void __iomem *ioaddr, int reg)
+static inline void _SMC_outw_align4(u16 val, void __iomem *ioaddr, int reg,
+   bool use_align4_workaround)
 {
-   if ((machine_is_mainstone() || machine_is_stargate2() ||
-machine_is_pxa_idp()) && reg & 2) {
+   if (use_align4_workaround) {
unsigned int v = val << 16;
v |= readl(ioaddr + (reg & ~2)) & 0x;
writel(v, ioaddr + (reg & ~2));
@@ -119,6 +117,12 @@ static inline void __SMC_outw(u16 val, void __iomem 
*ioaddr, int reg)
}
 }
 
+#define __SMC_outw(lp, v, a, r)
\
+   _SMC_outw_align4((v), (a), (r), \
+IS_BUILTIN(CONFIG_ARCH_PXA) && ((r) & 2) &&\
+(lp)->cfg.pxa_u16_align4)
+
+
 #elif  defined(CONFIG_SH_SH4202_MICRODEV)
 
 #define SMC_CAN_USE_8BIT   0
@@ -129,7 +133,7 @@ static inline void __SMC_outw(u16 val, void __iomem 
*ioaddr, int reg)
 #define SMC_inw(a, r)  inw((a) + (r) - 0xa000)
 #define SMC_inl(a, r)  inl((a) + (r) - 0xa000)
 #define SMC_outb(v, a, r)  outb(v, (a) + (r) - 0xa000)
-#define SMC_outw(v, a, r)  outw(v, (a) + (r) - 0xa000)
+#define SMC_outw(lp, v, a, r)  outw(v, (a) + (r) - 0xa

[PATCH v3 1/4] ARM: pxa: enhance smc91x platform data

2016-10-17 Thread Robert Jarzmik
Instead of having the smc91x driver relying on machine_is_*() calls,
provide this data through platform data, ie. idp, mainstone and
stargate.

This way, the driver doesn't need anymore machine_is_*() calls, which
wouldn't work anymore with a device-tree build.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 arch/arm/mach-pxa/idp.c   | 1 +
 arch/arm/mach-pxa/mainstone.c | 1 +
 arch/arm/mach-pxa/stargate2.c | 1 +
 include/linux/smc91x.h| 1 +
 4 files changed, 4 insertions(+)

diff --git a/arch/arm/mach-pxa/idp.c b/arch/arm/mach-pxa/idp.c
index 66070acaa888..d1db32b1a2c6 100644
--- a/arch/arm/mach-pxa/idp.c
+++ b/arch/arm/mach-pxa/idp.c
@@ -85,6 +85,7 @@ static struct resource smc91x_resources[] = {
 static struct smc91x_platdata smc91x_platdata = {
.flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
 SMC91X_USE_DMA | SMC91X_NOWAIT,
+   .pxa_u16_align4 = true,
 };
 
 static struct platform_device smc91x_device = {
diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index 40964069a17c..a2d851a3a546 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -140,6 +140,7 @@ static struct resource smc91x_resources[] = {
 static struct smc91x_platdata mainstone_smc91x_info = {
.flags  = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
  SMC91X_NOWAIT | SMC91X_USE_DMA,
+   .pxa_u16_align4 = true,
 };
 
 static struct platform_device smc91x_device = {
diff --git a/arch/arm/mach-pxa/stargate2.c b/arch/arm/mach-pxa/stargate2.c
index 702f4f14b708..7b6610e9dae4 100644
--- a/arch/arm/mach-pxa/stargate2.c
+++ b/arch/arm/mach-pxa/stargate2.c
@@ -673,6 +673,7 @@ static struct resource smc91x_resources[] = {
 static struct smc91x_platdata stargate2_smc91x_info = {
.flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT
| SMC91X_NOWAIT | SMC91X_USE_DMA,
+   .pxa_u16_align4 = true,
 };
 
 static struct platform_device smc91x_device = {
diff --git a/include/linux/smc91x.h b/include/linux/smc91x.h
index e302c447e057..129bc674dcf5 100644
--- a/include/linux/smc91x.h
+++ b/include/linux/smc91x.h
@@ -39,6 +39,7 @@ struct smc91x_platdata {
unsigned long flags;
unsigned char leda;
unsigned char ledb;
+   bool pxa_u16_align4;/* PXA buggy u16 writes on 4*n+2 addresses */
 };
 
 #endif /* __SMC91X_H__ */
-- 
2.1.4



[PATCH v3 0/4] support smc91x on mainstone and devicetree

2016-10-17 Thread Robert Jarzmik
This serie aims at bringing support to mainstone board on a device-tree based
build, as what is already in place for legacy mainstone.

The bulk of the mainstone "specific" behavior is that a u16 write doesn't work
on a address of the form 4*n + 2, while it works on 4*n.

The legacy workaround was in SMC_outw(), with calls to
machine_is_mainstone(). These calls don't work with a pxa27x-dt machine type,
which is used when a generic device-tree pxa27x machine is used to boot the
mainstone board.

Therefore, this serie enables the smc91c111 adapter of the mainstone board to
work on a device-tree build, exaclty as it's been working for years with the
legacy arch/arm/mach-pxa/mainstone.c definition.

As a sum up, this extends an existing mechanism to device-tree based pxa 
platforms.

Cheers.

--
Robert

Robert Jarzmik (4):
  ARM: pxa: enhance smc91x platform data
  net: smc91x: isolate u16 writes alignment workaround
  net: smc91x: take into account half-word workaround
  net: smsc91x: add u16 workaround for pxa platforms

 .../devicetree/bindings/net/smsc-lan91c111.txt |  2 +
 arch/arm/mach-pxa/idp.c|  1 +
 arch/arm/mach-pxa/mainstone.c  |  1 +
 arch/arm/mach-pxa/stargate2.c  |  1 +
 arch/mn10300/unit-asb2303/include/unit/smc9.h  |  2 +-
 drivers/net/ethernet/smsc/smc91x.c |  5 +-
 drivers/net/ethernet/smsc/smc91x.h | 82 --
 include/linux/smc91x.h |  1 +
 8 files changed, 55 insertions(+), 40 deletions(-)

-- 
2.1.4



Re: [PATCH v2 1/3] net: smc91x: isolate u16 writes alignment workaround

2016-10-16 Thread Robert Jarzmik
Robert Jarzmik <robert.jarz...@free.fr> writes:

> diff --git a/drivers/net/ethernet/smsc/smc91x.h 
> b/drivers/net/ethernet/smsc/smc91x.h
> index ea8465467469..dff165ed106d 100644
> --- a/drivers/net/ethernet/smsc/smc91x.h
> +++ b/drivers/net/ethernet/smsc/smc91x.h

And there is also the specific case of ARCH=MN10300, where I didn't see :
#include 

In which SMC_outw() is also defined ... sic.

So this is also to be fixed, thanks to kbuild test robot.

--
Robert


Re: [PATCH v2 1/3] net: smc91x: isolate u16 writes alignment workaround

2016-10-15 Thread Robert Jarzmik
Sorry David, I just noticed you weren't in the "To:" of this serie, but I won't
forget you for the v3 I need to release anyway
(https://lkml.org/lkml/2016/10/15/104).

Robert Jarzmik <robert.jarz...@free.fr> writes:
> + lp->half_word_align4 =
> + machine_is_mainstone() || machine_is_stargate2() ||
> + machine_is_pxa_idp();

Bah this one is not good enough.

First, machine_is_*() is not defined if CONFIG_ARM=n, and this part is not under
a #ifdef CONFIG_ARM.

Moreover, I think it is a good occasion to go further, and :
 - enhance smc91x_platdata and add a pxa_u16_align4 boolean
 - transform this statement into :
lp->half_word_align4 = lp->cfg.pxa_u16_align4

This will remove the machine_*() calls from the smc91x driver, which looks a
good move, doesn't it ?

Cheers.

--
Robert


[PATCH v2 3/3] net: smsc91x: add u16 workaround for pxa platforms

2016-10-15 Thread Robert Jarzmik
Add a workaround for mainstone, idp and stargate2 boards, for u16 writes
which must be aligned on 32 bits addresses.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Cc: Jeremy Linton <jeremy.lin...@arm.com>
---
Since v1: rename dt property to pxa-u16-align4
  change the binding documentation file
---
 Documentation/devicetree/bindings/net/smsc-lan91c111.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/smsc-lan91c111.txt 
b/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
index e77e167593db..309e37eb7c7c 100644
--- a/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
+++ b/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
@@ -13,3 +13,5 @@ Optional properties:
   16-bit access only.
 - power-gpios: GPIO to control the PWRDWN pin
 - reset-gpios: GPIO to control the RESET pin
+- pxa-u16-align4 : Boolean, put in place the workaround the force all
+  u16 writes to be 32 bits aligned
-- 
2.1.4



[PATCH v2 1/3] net: smc91x: isolate u16 writes alignment workaround

2016-10-15 Thread Robert Jarzmik
Writes to u16 has a special handling on 3 PXA platforms, where the
hardware wiring forces these writes to be u32 aligned.

This patch isolates this handling for PXA platforms as before, but
enables this "workaround" to be set up dynamically, which will be the
case in device-tree build types.

This patch was tested on 2 PXA platforms : mainstone, which relies on
the workaround, and lubbock, which doesn't.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc91x.c |  6 ++-
 drivers/net/ethernet/smsc/smc91x.h | 78 +-
 2 files changed, 48 insertions(+), 36 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index 9b4780f87863..5658c2b28ec8 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -602,7 +602,8 @@ static void smc_hardware_send_pkt(unsigned long data)
SMC_PUSH_DATA(lp, buf, len & ~1);
 
/* Send final ctl word with the last byte if there is one */
-   SMC_outw(((len & 1) ? (0x2000 | buf[len-1]) : 0), ioaddr, DATA_REG(lp));
+   SMC_outw(lp, ((len & 1) ? (0x2000 | buf[len-1]) : 0), ioaddr,
+DATA_REG(lp));
 
/*
 * If THROTTLE_TX_PKTS is set, we stop the queue here. This will
@@ -2282,6 +2283,9 @@ static int smc_drv_probe(struct platform_device *pdev)
goto out_free_netdev;
}
}
+   lp->half_word_align4 =
+   machine_is_mainstone() || machine_is_stargate2() ||
+   machine_is_pxa_idp();
 
 #if IS_BUILTIN(CONFIG_OF)
match = of_match_device(of_match_ptr(smc91x_match), >dev);
diff --git a/drivers/net/ethernet/smsc/smc91x.h 
b/drivers/net/ethernet/smsc/smc91x.h
index ea8465467469..dff165ed106d 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -86,11 +86,11 @@
 
 #define SMC_inl(a, r)  readl((a) + (r))
 #define SMC_outb(v, a, r)  writeb(v, (a) + (r))
-#define SMC_outw(v, a, r)  \
+#define SMC_outw(lp, v, a, r)  \
do {\
unsigned int __v = v, __smc_r = r;  \
if (SMC_16BIT(lp))  \
-   __SMC_outw(__v, a, __smc_r);\
+   __SMC_outw(lp, __v, a, __smc_r);\
else if (SMC_8BIT(lp))  \
SMC_outw_b(__v, a, __smc_r);\
else\
@@ -107,10 +107,10 @@
 #define SMC_IRQ_FLAGS  (-1)/* from resource */
 
 /* We actually can't write halfwords properly if not word aligned */
-static inline void __SMC_outw(u16 val, void __iomem *ioaddr, int reg)
+static inline void _SMC_outw_align4(u16 val, void __iomem *ioaddr, int reg,
+   bool use_align4_workaround)
 {
-   if ((machine_is_mainstone() || machine_is_stargate2() ||
-machine_is_pxa_idp()) && reg & 2) {
+   if (use_align4_workaround) {
unsigned int v = val << 16;
v |= readl(ioaddr + (reg & ~2)) & 0x;
writel(v, ioaddr + (reg & ~2));
@@ -119,6 +119,12 @@ static inline void __SMC_outw(u16 val, void __iomem 
*ioaddr, int reg)
}
 }
 
+#define __SMC_outw(lp, v, a, r)
\
+   _SMC_outw_align4((v), (a), (r), \
+IS_BUILTIN(CONFIG_ARCH_PXA) && ((r) & 2) &&\
+lp->half_word_align4)
+
+
 #elif  defined(CONFIG_SH_SH4202_MICRODEV)
 
 #define SMC_CAN_USE_8BIT   0
@@ -129,7 +135,7 @@ static inline void __SMC_outw(u16 val, void __iomem 
*ioaddr, int reg)
 #define SMC_inw(a, r)  inw((a) + (r) - 0xa000)
 #define SMC_inl(a, r)  inl((a) + (r) - 0xa000)
 #define SMC_outb(v, a, r)  outb(v, (a) + (r) - 0xa000)
-#define SMC_outw(v, a, r)  outw(v, (a) + (r) - 0xa000)
+#define SMC_outw(lp, v, a, r)  outw(v, (a) + (r) - 0xa000)
 #define SMC_outl(v, a, r)  outl(v, (a) + (r) - 0xa000)
 #define SMC_insl(a, r, p, l)   insl((a) + (r) - 0xa000, p, l)
 #define SMC_outsl(a, r, p, l)  outsl((a) + (r) - 0xa000, p, l)
@@ -147,7 +153,7 @@ static inline void __SMC_outw(u16 val, void __iomem 
*ioaddr, int reg)
 #define SMC_inb(a, r)  inb(((u32)a) + (r))
 #define SMC_inw(a, r)  inw(((u32)a) + (r))
 #define SMC_outb(v, a, r)  outb(v, ((u32)a) + (r))
-#define SMC_outw(v, a, r)  outw(v, ((u32)a) + (r))
+#define SMC_outw(lp, v, a, r)  outw(v, ((u32)a) + (r))
 #define SMC_insw(a, r, p, l) 

[PATCH v2 2/3] net: smc91x: take into account half-word workaround

2016-10-15 Thread Robert Jarzmik
For device-tree builds, platforms such as mainstone, idp and stargate2
must have their u16 writes all aligned on 32 bit boundaries. This is
already enabled in platform data builds, and this patch adds it to
device-tree builds.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
Since v1: rename dt property to pxa-u16-align4
---
 drivers/net/ethernet/smsc/smc91x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index 5658c2b28ec8..c14676805d06 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2329,6 +2329,8 @@ static int smc_drv_probe(struct platform_device *pdev)
if (!device_property_read_u32(>dev, "reg-shift",
  ))
lp->io_shift = val;
+   lp->half_word_align4 =
+   device_property_read_bool(>dev, "pxa-u16-align4");
}
 #endif
 
-- 
2.1.4



[PATCH v2 0/3] support smc91x on mainstone and devicetree

2016-10-15 Thread Robert Jarzmik
This serie aims at bringing support to mainstone board on a device-tree based
build, as what is already in place for legacy mainstone.

The bulk of the mainstone "specific" behavior is that a u16 write doesn't work
on a address of the form 4*n + 2, while it works on 4*n.

The legacy workaround was in SMC_outw(), with calls to
machine_is_mainstone(). These calls don't work with a pxa27x-dt machine type,
which is used when a generic device-tree pxa27x machine is used to boot the
mainstone board.

Therefore, this serie enables the smc91c111 adapter of the mainstone board to
work on a device-tree build, exaclty as it's been working for years with the
legacy arch/arm/mach-pxa/mainstone.c definition.

Cheers.

--
Robert

Robert Jarzmik (3):
  net: smc91x: isolate u16 writes alignment workaround
  net: smc91x: take into account half-word workaround
  net: smsc91x: add u16 workaround for pxa platforms

 .../devicetree/bindings/net/smsc-lan91c111.txt |  2 +
 drivers/net/ethernet/smsc/smc91x.c |  8 ++-
 drivers/net/ethernet/smsc/smc91x.h | 78 --
 3 files changed, 52 insertions(+), 36 deletions(-)

-- 
2.1.4



Re: [PATCH v2 1/3] net: smc91x: isolate u16 writes alignment workaround

2016-10-14 Thread Robert Jarzmik
David Miller <da...@davemloft.net> writes:

> From: Robert Jarzmik <robert.jarz...@free.fr>
> Date: Sun,  9 Oct 2016 22:33:45 +0200
>
>> Writes to u16 has a special handling on 3 PXA platforms, where the
>> hardware wiring forces these writes to be u32 aligned.
>> 
>> This patch isolates this handling for PXA platforms as before, but
>> enables this "workaround" to be set up dynamically, which will be the
>> case in device-tree build types.
>> 
>> This patch was tested on 2 PXA platforms : mainstone, which relies on
>> the workaround, and lubbock, which doesn't.
>> 
>> Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
>
> Please resubmit this patch series:
>
> 1) Respun against net-next, these don't currently apply cleanly there.
>
> 2) With a proper "[PATCH 0/3] ..." posting explaining at a high level
>what this patch series does, how it does it, and why it does it
>that way.

Sure, let me retest it after the rebase, and I'll post again.

Cheers.

-- 
Robert


Re: [PATCH v2 1/3] net: smc91x: isolate u16 writes alignment workaround

2016-10-10 Thread Robert Jarzmik
Andy Shevchenko  writes:

>> +#define SMC_outw(lp, v, a, r)  \
>> +   _SMC_outw_align4((v), (a), (r), \
>> +IS_BUILTIN(CONFIG_ARCH_PXA) && ((r) & 2) &&\
>> +lp->half_word_align4)
>
> Hmm... Isn't enough to have just (r) & 2 && lp->half_word_align4 ?

It wouldn't be equivalent to what we had before.

The point of the previous code was to compile out as much as possible of this
test. Therefore, at compilation time for omap1 boards, the compiler would
evaluate the test to 0, and never leave the workaround code compiled.

So it would be enough, but worse performance wise and not equivalent for non-pxa
boards, hence this test.

Cheers.

-- 
Robert


[PATCH v2 1/3] net: smc91x: isolate u16 writes alignment workaround

2016-10-09 Thread Robert Jarzmik
Writes to u16 has a special handling on 3 PXA platforms, where the
hardware wiring forces these writes to be u32 aligned.

This patch isolates this handling for PXA platforms as before, but
enables this "workaround" to be set up dynamically, which will be the
case in device-tree build types.

This patch was tested on 2 PXA platforms : mainstone, which relies on
the workaround, and lubbock, which doesn't.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc91x.c |  6 ++-
 drivers/net/ethernet/smsc/smc91x.h | 80 ++
 2 files changed, 52 insertions(+), 34 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index 77ad2a3f59db..b1f74e06d98e 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -602,7 +602,8 @@ static void smc_hardware_send_pkt(unsigned long data)
SMC_PUSH_DATA(lp, buf, len & ~1);
 
/* Send final ctl word with the last byte if there is one */
-   SMC_outw(((len & 1) ? (0x2000 | buf[len-1]) : 0), ioaddr, DATA_REG(lp));
+   SMC_outw(lp, ((len & 1) ? (0x2000 | buf[len-1]) : 0), ioaddr,
+DATA_REG(lp));
 
/*
 * If THROTTLE_TX_PKTS is set, we stop the queue here. This will
@@ -2276,6 +2277,9 @@ static int smc_drv_probe(struct platform_device *pdev)
memcpy(>cfg, pd, sizeof(lp->cfg));
lp->io_shift = SMC91X_IO_SHIFT(lp->cfg.flags);
}
+   lp->half_word_align4 =
+   machine_is_mainstone() || machine_is_stargate2() ||
+   machine_is_pxa_idp();
 
 #if IS_BUILTIN(CONFIG_OF)
match = of_match_device(of_match_ptr(smc91x_match), >dev);
diff --git a/drivers/net/ethernet/smsc/smc91x.h 
b/drivers/net/ethernet/smsc/smc91x.h
index 1a55c7976df0..2b7752db8635 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -66,10 +66,10 @@
 #define SMC_IRQ_FLAGS  (-1)/* from resource */
 
 /* We actually can't write halfwords properly if not word aligned */
-static inline void SMC_outw(u16 val, void __iomem *ioaddr, int reg)
+static inline void _SMC_outw_align4(u16 val, void __iomem *ioaddr, int reg,
+   bool use_align4_workaround)
 {
-   if ((machine_is_mainstone() || machine_is_stargate2() ||
-machine_is_pxa_idp()) && reg & 2) {
+   if (use_align4_workaround) {
unsigned int v = val << 16;
v |= readl(ioaddr + (reg & ~2)) & 0x;
writel(v, ioaddr + (reg & ~2));
@@ -78,6 +78,12 @@ static inline void SMC_outw(u16 val, void __iomem *ioaddr, 
int reg)
}
 }
 
+#define SMC_outw(lp, v, a, r)  \
+   _SMC_outw_align4((v), (a), (r), \
+IS_BUILTIN(CONFIG_ARCH_PXA) && ((r) & 2) &&\
+lp->half_word_align4)
+
+
 #elif  defined(CONFIG_SH_SH4202_MICRODEV)
 
 #define SMC_CAN_USE_8BIT   0
@@ -88,7 +94,8 @@ static inline void SMC_outw(u16 val, void __iomem *ioaddr, 
int reg)
 #define SMC_inw(a, r)  inw((a) + (r) - 0xa000)
 #define SMC_inl(a, r)  inl((a) + (r) - 0xa000)
 #define SMC_outb(v, a, r)  outb(v, (a) + (r) - 0xa000)
-#define SMC_outw(v, a, r)  outw(v, (a) + (r) - 0xa000)
+#define _SMC_outw(v, a, r) outw(v, (a) + (r) - 0xa000)
+#define SMC_outw(lp, v, a, r)  _SMC_outw((v), (a), (r))
 #define SMC_outl(v, a, r)  outl(v, (a) + (r) - 0xa000)
 #define SMC_insl(a, r, p, l)   insl((a) + (r) - 0xa000, p, l)
 #define SMC_outsl(a, r, p, l)  outsl((a) + (r) - 0xa000, p, l)
@@ -106,7 +113,8 @@ static inline void SMC_outw(u16 val, void __iomem *ioaddr, 
int reg)
 #define SMC_inb(a, r)  inb(((u32)a) + (r))
 #define SMC_inw(a, r)  inw(((u32)a) + (r))
 #define SMC_outb(v, a, r)  outb(v, ((u32)a) + (r))
-#define SMC_outw(v, a, r)  outw(v, ((u32)a) + (r))
+#define _SMC_outw(v, a, r) outw(v, ((u32)a) + (r))
+#define SMC_outw(lp, v, a, r)  _SMC_outw((v), (a), (r))
 #define SMC_insw(a, r, p, l)   insw(((u32)a) + (r), p, l)
 #define SMC_outsw(a, r, p, l)  outsw(((u32)a) + (r), p, l)
 
@@ -134,7 +142,8 @@ static inline void SMC_outw(u16 val, void __iomem *ioaddr, 
int reg)
 #define SMC_inw(a, r)   readw((a) + (r))
 #define SMC_inl(a, r)   readl((a) + (r))
 #define SMC_outb(v, a, r)   writeb(v, (a) + (r))
-#define SMC_outw(v, a, r)   writew(v, (a) + (r))
+#define _SMC_outw(v, a, r)   writew(v, (a) + (r))
+#define SMC_outw(lp, v, a, r)  _SMC_outw((v), (a), (r))
 #define SMC_outl(v, a, r)   writel(v, (a) + (r))
 #define SMC_insw(a, r, p, l)readsw((a) + (r), p, l)
 #define SMC_outsw(a, r, p, l)   writesw((a) + (r), p, l)
@@ -166,7 +175,8 @@ static inline void mcf_

[PATCH v2 2/3] net: smc91x: take into account half-word workaround

2016-10-09 Thread Robert Jarzmik
For device-tree builds, platforms such as mainstone, idp and stargate2
must have their u16 writes all aligned on 32 bit boundaries. This is
already enabled in platform data builds, and this patch adds it to
device-tree builds.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
Since v1: rename dt property to pxa-u16-align4
---
 drivers/net/ethernet/smsc/smc91x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index b1f74e06d98e..e2f151258b38 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2323,6 +2323,8 @@ static int smc_drv_probe(struct platform_device *pdev)
if (!device_property_read_u32(>dev, "reg-shift",
  ))
lp->io_shift = val;
+   lp->half_word_align4 =
+   device_property_read_bool(>dev, "pxa-u16-align4");
}
 #endif
 
-- 
2.1.4



[PATCH v2 3/3] net: smsc91x: add u16 workaround for pxa platforms

2016-10-09 Thread Robert Jarzmik
Add a workaround for mainstone, idp and stargate2 boards, for u16 writes
which must be aligned on 32 bits addresses.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Cc: Jeremy Linton <jeremy.lin...@arm.com>
---
Since v1: rename dt property to pxa-u16-align4
  change the binding documentation file
---
 Documentation/devicetree/bindings/net/smsc-lan91c111.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/smsc-lan91c111.txt 
b/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
index e77e167593db..309e37eb7c7c 100644
--- a/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
+++ b/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
@@ -13,3 +13,5 @@ Optional properties:
   16-bit access only.
 - power-gpios: GPIO to control the PWRDWN pin
 - reset-gpios: GPIO to control the RESET pin
+- pxa-u16-align4 : Boolean, put in place the workaround the force all
+  u16 writes to be 32 bits aligned
-- 
2.1.4



Re: [PATCH 3/3] net: smsc911x: add u16 workaround for pxa platforms

2016-10-06 Thread Robert Jarzmik
Robert Jarzmik <robert.jarz...@free.fr> writes:

> Mark Rutland <mark.rutl...@arm.com> writes:
>
>> On Mon, Oct 03, 2016 at 06:11:23PM +0200, Robert Jarzmik wrote:
>>> Mark Rutland <mark.rutl...@arm.com> writes:
>>> 
>>> reg-u16-align4 tells that a specific hardware doesn't support 16 bit writes 
>>> not
>>> being 32 bits aligned, or said differently that a "store" 16 bits wide on an
>>> address of the format 4*n + 2 deserves a special handling in the driver, 
>>> while a
>>> store 16 bits wide on an address of the format 4*n can follow the simple 
>>> casual
>>> case.
>>
>> If I've understood correctly, effectively the low 2 address lines to the
>> device are hard-wired to zero, e.g. a 16-bit access to 4*n + 2 would go
>> to 4*n + 0 on the device? Or is the failure case distinct from that?
> It is distinct.
>
> The "awful truth" is that an FPGA lies between the system bus and the
> smc91c111. And this FPGA cannot handle correctly the 4*n + 2 u16 writes.
>
>> Do we have other platforms where similar is true? e.g. u8 accesses
>> requiring 16-bit alignment?
>
> Not really, ie. not with a alignement requirement.
>
> But there are of course these ones are handled by reg-io-width and the
> SMC_USE_xxx_BITS flags as far as I understand it. These cases are when a
> platform declares SMC91X_USE_16BIT or SMC91X_USE_32BIT, but not 
> SMC91X_USE_8BIT,
> which would make me think of :
>  - CONFIG_SH_SH4202_MICRODEV,
>  - CONFIG_M32R
>  - several omap1 boards
>  - 1 sa1100 board
>  - several MMP and realview boards
>
> With all these platforms, each u8 access is replaced with a u16 access and a
> mask / shift + mask.

Or so what should I call this entry if reg-u16-align4 is not a good candidate ?

Cheers.

-- 
Robert


Re: [PATCH 3/3] net: smsc911x: add u16 workaround for pxa platforms

2016-10-03 Thread Robert Jarzmik
Mark Rutland <mark.rutl...@arm.com> writes:

> On Mon, Oct 03, 2016 at 06:11:23PM +0200, Robert Jarzmik wrote:
>> Mark Rutland <mark.rutl...@arm.com> writes:
>> 
>> reg-u16-align4 tells that a specific hardware doesn't support 16 bit writes 
>> not
>> being 32 bits aligned, or said differently that a "store" 16 bits wide on an
>> address of the format 4*n + 2 deserves a special handling in the driver, 
>> while a
>> store 16 bits wide on an address of the format 4*n can follow the simple 
>> casual
>> case.
>
> If I've understood correctly, effectively the low 2 address lines to the
> device are hard-wired to zero, e.g. a 16-bit access to 4*n + 2 would go
> to 4*n + 0 on the device? Or is the failure case distinct from that?
It is distinct.

The "awful truth" is that an FPGA lies between the system bus and the
smc91c111. And this FPGA cannot handle correctly the 4*n + 2 u16 writes.

> Do we have other platforms where similar is true? e.g. u8 accesses
> requiring 16-bit alignment?

Not really, ie. not with a alignement requirement.

But there are of course these ones are handled by reg-io-width and the
SMC_USE_xxx_BITS flags as far as I understand it. These cases are when a
platform declares SMC91X_USE_16BIT or SMC91X_USE_32BIT, but not SMC91X_USE_8BIT,
which would make me think of :
 - CONFIG_SH_SH4202_MICRODEV,
 - CONFIG_M32R
 - several omap1 boards
 - 1 sa1100 board
 - several MMP and realview boards

With all these platforms, each u8 access is replaced with a u16 access and a
mask / shift + mask.

Cheers.

-- 
Robert


Re: [PATCH 3/3] net: smsc911x: add u16 workaround for pxa platforms

2016-10-03 Thread Robert Jarzmik
Jeremy Linton <jeremy.lin...@arm.com> writes:

> Hi Robert,
>
> On 10/03/2016 04:05 AM, Robert Jarzmik wrote:
>> Add a workaround for mainstone, idp and stargate2 boards, for u16 writes
>> which must be aligned on 32 bits addresses.
>>
>> Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
>> ---
>>  Documentation/devicetree/bindings/net/smsc911x.txt | 2 ++
>>  1 file changed, 2 insertions(+)
>
> I think this might be the wrong doc file. I think you want the
> smsc-lan91c111.txt file.
Ah yes, thanks for spoting that.

Cheers.

--
Robert


Re: [PATCH 3/3] net: smsc911x: add u16 workaround for pxa platforms

2016-10-03 Thread Robert Jarzmik
Mark Rutland <mark.rutl...@arm.com> writes:

> On Mon, Oct 03, 2016 at 11:05:53AM +0200, Robert Jarzmik wrote:
>> Add a workaround for mainstone, idp and stargate2 boards, for u16 writes
>> which must be aligned on 32 bits addresses.
>> 
>> Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
>> ---
>>  Documentation/devicetree/bindings/net/smsc911x.txt | 2 ++
>>  1 file changed, 2 insertions(+)
>> 
>> diff --git a/Documentation/devicetree/bindings/net/smsc911x.txt 
>> b/Documentation/devicetree/bindings/net/smsc911x.txt
>> index 3fed3c124411..224965b7453c 100644
>> --- a/Documentation/devicetree/bindings/net/smsc911x.txt
>> +++ b/Documentation/devicetree/bindings/net/smsc911x.txt
>> @@ -13,6 +13,8 @@ Optional properties:
>>  - reg-io-width : Specify the size (in bytes) of the IO accesses that
>>should be performed on the device.  Valid value for SMSC LAN is
>>2 or 4.  If it's omitted or invalid, the size would be 2.
>> +- reg-u16-align4 : Boolean, put in place the workaround the force all
>> +   u16 writes to be 32 bits aligned
>
> This property name and description is confusing.
>
> How exactly does this differ from having reg-io-width = <4>, which is
> documented immediately above?

reg-io-width specifies the IO size, ie. how many data lines are physically
connected from the system bus to the lan adapter.

reg-u16-align4 tells that a specific hardware doesn't support 16 bit writes not
being 32 bits aligned, or said differently that a "store" 16 bits wide on an
address of the format 4*n + 2 deserves a special handling in the driver, while a
store 16 bits wide on an address of the format 4*n can follow the simple casual
case.

I'm pretty open to any name you might suggest, these 3 hardwares I know of are
really crazy, you can see them in patch 1/3, in the _SMC_outw_align4() function
...

Cheers.

--
Robert


[PATCH 1/3] net: smc91x: isolate u16 writes alignment workaround

2016-10-03 Thread Robert Jarzmik
Writes to u16 has a special handling on 3 PXA platforms, where the
hardware wiring forces these writes to be u32 aligned.

This patch isolates this handling for PXA platforms as before, but
enables this "workaround" to be set up dynamically, which will be the
case in device-tree build types.

This patch was tested on 2 PXA platforms : mainstone, which relies on
the workaround, and lubbock, which doesn't.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc91x.c |  6 ++-
 drivers/net/ethernet/smsc/smc91x.h | 80 ++
 2 files changed, 52 insertions(+), 34 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index 77ad2a3f59db..b1f74e06d98e 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -602,7 +602,8 @@ static void smc_hardware_send_pkt(unsigned long data)
SMC_PUSH_DATA(lp, buf, len & ~1);
 
/* Send final ctl word with the last byte if there is one */
-   SMC_outw(((len & 1) ? (0x2000 | buf[len-1]) : 0), ioaddr, DATA_REG(lp));
+   SMC_outw(lp, ((len & 1) ? (0x2000 | buf[len-1]) : 0), ioaddr,
+DATA_REG(lp));
 
/*
 * If THROTTLE_TX_PKTS is set, we stop the queue here. This will
@@ -2276,6 +2277,9 @@ static int smc_drv_probe(struct platform_device *pdev)
memcpy(>cfg, pd, sizeof(lp->cfg));
lp->io_shift = SMC91X_IO_SHIFT(lp->cfg.flags);
}
+   lp->half_word_align4 =
+   machine_is_mainstone() || machine_is_stargate2() ||
+   machine_is_pxa_idp();
 
 #if IS_BUILTIN(CONFIG_OF)
match = of_match_device(of_match_ptr(smc91x_match), >dev);
diff --git a/drivers/net/ethernet/smsc/smc91x.h 
b/drivers/net/ethernet/smsc/smc91x.h
index 1a55c7976df0..2b7752db8635 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -66,10 +66,10 @@
 #define SMC_IRQ_FLAGS  (-1)/* from resource */
 
 /* We actually can't write halfwords properly if not word aligned */
-static inline void SMC_outw(u16 val, void __iomem *ioaddr, int reg)
+static inline void _SMC_outw_align4(u16 val, void __iomem *ioaddr, int reg,
+   bool use_align4_workaround)
 {
-   if ((machine_is_mainstone() || machine_is_stargate2() ||
-machine_is_pxa_idp()) && reg & 2) {
+   if (use_align4_workaround) {
unsigned int v = val << 16;
v |= readl(ioaddr + (reg & ~2)) & 0x;
writel(v, ioaddr + (reg & ~2));
@@ -78,6 +78,12 @@ static inline void SMC_outw(u16 val, void __iomem *ioaddr, 
int reg)
}
 }
 
+#define SMC_outw(lp, v, a, r)  \
+   _SMC_outw_align4((v), (a), (r), \
+IS_BUILTIN(CONFIG_ARCH_PXA) && ((r) & 2) &&\
+lp->half_word_align4)
+
+
 #elif  defined(CONFIG_SH_SH4202_MICRODEV)
 
 #define SMC_CAN_USE_8BIT   0
@@ -88,7 +94,8 @@ static inline void SMC_outw(u16 val, void __iomem *ioaddr, 
int reg)
 #define SMC_inw(a, r)  inw((a) + (r) - 0xa000)
 #define SMC_inl(a, r)  inl((a) + (r) - 0xa000)
 #define SMC_outb(v, a, r)  outb(v, (a) + (r) - 0xa000)
-#define SMC_outw(v, a, r)  outw(v, (a) + (r) - 0xa000)
+#define _SMC_outw(v, a, r) outw(v, (a) + (r) - 0xa000)
+#define SMC_outw(lp, v, a, r)  _SMC_outw((v), (a), (r))
 #define SMC_outl(v, a, r)  outl(v, (a) + (r) - 0xa000)
 #define SMC_insl(a, r, p, l)   insl((a) + (r) - 0xa000, p, l)
 #define SMC_outsl(a, r, p, l)  outsl((a) + (r) - 0xa000, p, l)
@@ -106,7 +113,8 @@ static inline void SMC_outw(u16 val, void __iomem *ioaddr, 
int reg)
 #define SMC_inb(a, r)  inb(((u32)a) + (r))
 #define SMC_inw(a, r)  inw(((u32)a) + (r))
 #define SMC_outb(v, a, r)  outb(v, ((u32)a) + (r))
-#define SMC_outw(v, a, r)  outw(v, ((u32)a) + (r))
+#define _SMC_outw(v, a, r) outw(v, ((u32)a) + (r))
+#define SMC_outw(lp, v, a, r)  _SMC_outw((v), (a), (r))
 #define SMC_insw(a, r, p, l)   insw(((u32)a) + (r), p, l)
 #define SMC_outsw(a, r, p, l)  outsw(((u32)a) + (r), p, l)
 
@@ -134,7 +142,8 @@ static inline void SMC_outw(u16 val, void __iomem *ioaddr, 
int reg)
 #define SMC_inw(a, r)   readw((a) + (r))
 #define SMC_inl(a, r)   readl((a) + (r))
 #define SMC_outb(v, a, r)   writeb(v, (a) + (r))
-#define SMC_outw(v, a, r)   writew(v, (a) + (r))
+#define _SMC_outw(v, a, r)   writew(v, (a) + (r))
+#define SMC_outw(lp, v, a, r)  _SMC_outw((v), (a), (r))
 #define SMC_outl(v, a, r)   writel(v, (a) + (r))
 #define SMC_insw(a, r, p, l)readsw((a) + (r), p, l)
 #define SMC_outsw(a, r, p, l)   writesw((a) + (r), p, l)
@@ -166,7 +175,8 @@ static inline void mcf_

[PATCH 3/3] net: smsc911x: add u16 workaround for pxa platforms

2016-10-03 Thread Robert Jarzmik
Add a workaround for mainstone, idp and stargate2 boards, for u16 writes
which must be aligned on 32 bits addresses.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 Documentation/devicetree/bindings/net/smsc911x.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/smsc911x.txt 
b/Documentation/devicetree/bindings/net/smsc911x.txt
index 3fed3c124411..224965b7453c 100644
--- a/Documentation/devicetree/bindings/net/smsc911x.txt
+++ b/Documentation/devicetree/bindings/net/smsc911x.txt
@@ -13,6 +13,8 @@ Optional properties:
 - reg-io-width : Specify the size (in bytes) of the IO accesses that
   should be performed on the device.  Valid value for SMSC LAN is
   2 or 4.  If it's omitted or invalid, the size would be 2.
+- reg-u16-align4 : Boolean, put in place the workaround the force all
+  u16 writes to be 32 bits aligned
 - smsc,irq-active-high : Indicates the IRQ polarity is active-high
 - smsc,irq-push-pull : Indicates the IRQ type is push-pull
 - smsc,force-internal-phy : Forces SMSC LAN controller to use
-- 
2.1.4



[PATCH 2/3] net: smc91x: take into account half-word workaround

2016-10-03 Thread Robert Jarzmik
For device-tree builds, platforms such as mainstone, idp and stargate2
must have their u16 writes all aligned on 32 bit boundaries. This is
already enabled in platform data builds, and this patch adds it to
device-tree builds.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc91x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index b1f74e06d98e..b081d5ca88ce 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2323,6 +2323,8 @@ static int smc_drv_probe(struct platform_device *pdev)
if (!device_property_read_u32(>dev, "reg-shift",
  ))
lp->io_shift = val;
+   lp->half_word_align4 =
+   device_property_read_bool(>dev, "reg-u16-align4");
}
 #endif
 
-- 
2.1.4



[PATCH] net: smc91x: take into account register shift

2016-09-25 Thread Robert Jarzmik
This aligns smc91x with its cousin, namely smc911x.c.
This also allows the driver to run also in a device-tree based lubbock
board build, on which it was tested.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc91x.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index 726b80f45906..77ad2a3f59db 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2316,6 +2316,9 @@ static int smc_drv_probe(struct platform_device *pdev)
} else {
lp->cfg.flags |= SMC91X_USE_16BIT;
}
+   if (!device_property_read_u32(>dev, "reg-shift",
+ ))
+   lp->io_shift = val;
}
 #endif
 
-- 
2.1.4



Re: [PATCH v2] net: smc91x: fix SMC accesses

2016-08-27 Thread Robert Jarzmik
Russell King <rmk+ker...@armlinux.org.uk> writes:

> Commit b70661c70830 ("net: smc91x: use run-time configuration on all ARM
> machines") broke some ARM platforms through several mistakes.  Firstly,
> the access size must correspond to the following rule:
>
> (a) at least one of 16-bit or 8-bit access size must be supported
> (b) 32-bit accesses are optional, and may be enabled in addition to
> the above.
>
> Secondly, it provides no emulation of 16-bit accesses, instead blindly
> making 16-bit accesses even when the platform specifies that only 8-bit
> is supported.
>
> Reorganise smc91x.h so we can make use of the existing 16-bit access
> emulation already provided - if 16-bit accesses are supported, use
> 16-bit accesses directly, otherwise if 8-bit accesses are supported,
> use the provided 16-bit access emulation.  If neither, BUG().  This
> exactly reflects the driver behaviour prior to the commit being fixed.
>
> Since the conversion incorrectly cut down the available access sizes on
> several platforms, we also need to go through every platform and fix up
> the overly-restrictive access size: Arnd assumed that if a platform can
> perform 32-bit, 16-bit and 8-bit accesses, then only a 32-bit access
> size needed to be specified - not so, all available access sizes must
> be specified.
>
> This likely fixes some performance regressions in doing this: if a
> platform does not support 8-bit accesses, 8-bit accesses have been
> emulated by performing a 16-bit read-modify-write access.
>
> Tested on the Intel Assabet/Neponset platform, which supports only 8-bit
> accesses, which was broken by the original commit.
>
> Fixes: b70661c70830 ("net: smc91x: use run-time configuration on all ARM 
> machines")
> Signed-off-by: Russell King <rmk+ker...@armlinux.org.uk>
> ---
> Robert, this is the full patch - can I add your tested-by to this for
> the subset patch please?
Yes, I just retested it, so :
Tested-by: Robert Jarzmik <robert.jarz...@free.fr>

Cheers.

--
Robert


Re: [PATCH] smc91x: remove ARM hack for unaligned 16-bit writes

2016-08-27 Thread Robert Jarzmik
Russell King - ARM Linux <li...@armlinux.org.uk> writes:

> On Thu, Aug 25, 2016 at 08:02:35PM +0200, Robert Jarzmik wrote:
>> Arnd Bergmann <a...@arndb.de> writes:
>> 
>> > On Thursday, August 25, 2016 4:43:04 PM CEST Arnd Bergmann wrote:
>> >>  drivers/net/ethernet/smsc/smc91x.h | 50 
>> >> +++---
>> >>  1 file changed, 30 insertions(+), 20 deletions(-)
>> >> 
>> >> While this patch fixes one bug on Neponset, it probably doesn't address
>> >> the one that Russell ran into first, so this is for review only for now,
>> >> until the remaining problem(s) have been worked out.
>> >> 
>> >
>> > The comment should have been on another patch, my mistake. please
>> > see v2.
>> >
>> >Arnd
>> 
>> Hi Arnd,
>> 
>> I didn't review the patch thoroughly, but I launched your 2 patches in my pxa
>> little farm.
>> 
>> The result is that lubbock and mainstone are all right, but zylonite is 
>> broken
>> (ie. networkless). I removed then these 2 patches and zylonite worked again.
>> 
>> I have also an error message on the console on a "broken" zylonite :
>>   Changing smcs91x MAC address to 08:00:3e:26:0a:5b: ifconfig: SIOCSIFHWADDR:
>>   Device or resource busy
>> 
>> I reran the test twice (2 times with your patches, 2 times without), the 
>> result
>> looks consistent, ie. zylonite doesn't really like them.
>
> Please try the patch below.  I sent this to Will a few days ago, as
> he said (on irc) that he was also seeing problems on a platform he
> had, but I've yet to hear back.  I've not posted it yet because I
> haven't got around to writing a commit description for it.
>
> It does require that at least one of 8-bit or 16-bit accesses are
> supported, but I think that's already true.

Hi Russell,

With your patch :
 - lubbock, mainstone and zylonite boards are working correctly
   => ie. all my boards are working correctly

 - the message "ifconfig: SIOCSIFHWADDR: Device or resource busy" is still there
   => this message is here even without your patch, so it's rather not relevant
   => this message is triggered by an "/sbin/ifconfig eth0 hw ether
   08:00:3e:26:0a:5b" command

So from a PXA testing point of view it's all good, ie.
Tested-by: Robert Jarzmik <robert.jarz...@free.fr>

Cheers.

-- 
Robert


Re: [PATCH] smc91x: remove ARM hack for unaligned 16-bit writes

2016-08-25 Thread Robert Jarzmik
Arnd Bergmann  writes:

> On Thursday, August 25, 2016 4:43:04 PM CEST Arnd Bergmann wrote:
>>  drivers/net/ethernet/smsc/smc91x.h | 50 
>> +++---
>>  1 file changed, 30 insertions(+), 20 deletions(-)
>> 
>> While this patch fixes one bug on Neponset, it probably doesn't address
>> the one that Russell ran into first, so this is for review only for now,
>> until the remaining problem(s) have been worked out.
>> 
>
> The comment should have been on another patch, my mistake. please
> see v2.
>
>   Arnd

Hi Arnd,

I didn't review the patch thoroughly, but I launched your 2 patches in my pxa
little farm.

The result is that lubbock and mainstone are all right, but zylonite is broken
(ie. networkless). I removed then these 2 patches and zylonite worked again.

I have also an error message on the console on a "broken" zylonite :
  Changing smcs91x MAC address to 08:00:3e:26:0a:5b: ifconfig: SIOCSIFHWADDR:
  Device or resource busy

I reran the test twice (2 times with your patches, 2 times without), the result
looks consistent, ie. zylonite doesn't really like them.

Cheers.

-- 
Robert

PS: even if zylonite defconfig is not in the tree, it uses this driver, with :
CONFIG_SMC91X=y
...and...
static struct smc91x_platdata zylonite_smc91x_info = {
.flags  = SMC91X_USE_8BIT | SMC91X_USE_16BIT |
  SMC91X_NOWAIT | SMC91X_USE_DMA,
};


Re: [PATCH] dm9000: Fix irq trigger type setup on non-dt platforms

2016-08-09 Thread Robert Jarzmik
Sylwester Nawrocki <s.nawro...@samsung.com> writes:

> Commit b5a099c67a1c36b "net: ethernet: davicom: fix devicetree irq
> resource" causes an interrupt storm after the ethernet interface
> is activated on S3C24XX platform (ARM non-dt), due to the interrupt
> trigger type not being set properly.
>
> It seems, after adding parsing of IRQ flags in commit 7085a7401ba54e92b
> "drivers: platform: parse IRQ flags from resources", there is no path
> for non-dt platforms where irq_set_type callback could be invoked when
> we don't pass the trigger type flags to the request_irq() call.
>
> In case of a board where the regression is seen the interrupt trigger
> type flags are passed through a platform device's resource and it is
> not currently handled properly without passing the irq trigger type
> flags to the request_irq() call.  In case of OF an of_irq_get() call
> within platform_get_irq() function seems to be ensuring required irq_chip
> setup, but there is no equivalent code for non OF/ACPI platforms.
>
> This patch mostly restores irq trigger type setting code which has been
> removed in commit ("net: ethernet: davicom: fix devicetree irq resource").
>
> Fixes: b5a099c67a1c36b913 ("net: ethernet: davicom: fix devicetree irq 
> resource")
>
> Signed-off-by: Sylwester Nawrocki <s.nawro...@samsung.com>
> ---
>
> Perhaps instead the core could be configuring the irqchip automatically as it
> is done for OF/ACPI cases. I had doubts though if trying to make such changes
> for a bug fix patch was the right thing to do.
Hi Sylvester,

You're right, and I came to the same conclusion a bit earlier, in [1], but I
didn't notice my FAI didn't actually send the mail. Your analysis of the core in
non-OF/ACPI case is the reason I didn't post a patch for dm9000 ... I was
overconfident in finding a reason in irq core code within a couple of days.

Therefore:
Acked-by: Robert Jarzmik <robert.jarz...@free.fr>

And I can make a test for you on my cm-x300 board, even if your patch is very
alike the draft I had in my internal tree since then.

Cheers.

--
Robert

[1] Non-delivered mail, shame on me
From: Robert Jarzmik <robert.jarz...@free.fr>
To: Linus Walleij <linus.wall...@linaro.org>
Cc: linux-arm-ker...@lists.infradead.org, Thomas Gleixner <t...@linutronix.de>, 
linux-ker...@vger.kernel.org "David S. Miller" <da...@davemloft.net>
Subject: platform_get_irq and trigger types
X-URL: http://belgarath.falguerolles.org/
Date: Sat, 21 May 2016 11:16:09 +0200
Message-ID: <87y473hiue@belgarion.home>
User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.4 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain

Hi Linus,

I was bitten again by the rising/falling flags of interrupt flags.

The commit which triggered this "regression" (the wording regression is rather
incorrect so please don't take this as an incentive to revert) is :
   b5a099c67a1c ("net: ethernet: davicom: fix devicetree irq resource")

The exact context is that for platform type builds, the irq rising edge flag is
not activated in the irqchip, ie. in the gpio-pxa.c pxa_gpio_irq_type() is not
called. The board used for this test is arch/arm/mach-pxa/cm-x300.c (line 200).

Now I've started to add printks here and there, and from a first glance :
 - platform_get_irq() is correctly calling irqd_set_trigger_type()
 - but upon the request_irq() in drivers/net/ethernet/davicom/dm9000.c:1319,
   these flags are not taken into account
   => this is where commit b5a099c67a1c comes into play
   => re-adding irq_get_trigger_type(dev->irq) to the passed flags does solve 
the
  issue

I tried to ponder whether my commit was wrong, or if it's the gpio-pxa.c which
is wrong, or something else. My inner feeling is that dm9000.c code is now
correct, and that something else is happening that I don't understand.

I'm bringing this to your attention if you have an idea before I begin to dig
deeper, add printk() and go down to the problem.

Cheers.

-- 
Robert


Re: [PATCH] net: smc91x: ACPI Enable lan91x adapters

2016-06-26 Thread Robert Jarzmik
Jeremy Linton  writes:

> Enable lan91x adapters in some ARM machines and models
> when booted with an ACPI kernel.
>
> Signed-off-by: Jeremy Linton 

Hi Jeremy,

I launched your change in my Jenkins yesterday (on Linus's mainline, not
linux-next), and I got:

CC  drivers/net/ethernet/smsc/smc91x.o
drivers/net/ethernet/smsc/smc91x.c:2488:23: error: 'smsc91x_acpi_match' 
undeclared here (not in a function)
   .acpi_match_table = smsc91x_acpi_match,

This platform build is _not_ for an device tree platform,
ie. CONFIG_OF=n. You'll have to move some around it seems.


Cheers.

--
Robert


[PATCH v2] net: smc911x: convert pxa dma to dmaengine

2016-03-19 Thread Robert Jarzmik
Convert the dma transfers to be dmaengine based, now pxa has a dmaengine
slave driver. This makes this driver a bit more PXA agnostic.

The driver was only compile tested. The risk is quite small as no
current PXA platform I'm aware of is using smc911x driver.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Tested-by: Fabio Estevam <fabio.este...@nxp.com>
---
Since v1: added Fabio's Tested-by
---
 drivers/net/ethernet/smsc/smc911x.c | 85 -
 drivers/net/ethernet/smsc/smc911x.h | 63 ---
 2 files changed, 82 insertions(+), 66 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc911x.c 
b/drivers/net/ethernet/smsc/smc911x.c
index bd64eb982e52..3f5711061432 100644
--- a/drivers/net/ethernet/smsc/smc911x.c
+++ b/drivers/net/ethernet/smsc/smc911x.c
@@ -73,6 +73,9 @@ static const char version[] =
 #include 
 #include 
 
+#include 
+#include 
+
 #include 
 
 #include "smc911x.h"
@@ -1174,18 +1177,16 @@ static irqreturn_t smc911x_interrupt(int irq, void 
*dev_id)
 
 #ifdef SMC_USE_DMA
 static void
-smc911x_tx_dma_irq(int dma, void *data)
+smc911x_tx_dma_irq(void *data)
 {
-   struct net_device *dev = (struct net_device *)data;
-   struct smc911x_local *lp = netdev_priv(dev);
+   struct smc911x_local *lp = data;
+   struct net_device *dev = lp->netdev;
struct sk_buff *skb = lp->current_tx_skb;
unsigned long flags;
 
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
 
DBG(SMC_DEBUG_TX | SMC_DEBUG_DMA, dev, "TX DMA irq handler\n");
-   /* Clear the DMA interrupt sources */
-   SMC_DMA_ACK_IRQ(dev, dma);
BUG_ON(skb == NULL);
dma_unmap_single(NULL, tx_dmabuf, tx_dmalen, DMA_TO_DEVICE);
dev->trans_start = jiffies;
@@ -1208,18 +1209,16 @@ smc911x_tx_dma_irq(int dma, void *data)
"TX DMA irq completed\n");
 }
 static void
-smc911x_rx_dma_irq(int dma, void *data)
+smc911x_rx_dma_irq(void *data)
 {
-   struct net_device *dev = (struct net_device *)data;
-   struct smc911x_local *lp = netdev_priv(dev);
+   struct smc911x_local *lp = data;
+   struct net_device *dev = lp->netdev;
struct sk_buff *skb = lp->current_rx_skb;
unsigned long flags;
unsigned int pkts;
 
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
DBG(SMC_DEBUG_RX | SMC_DEBUG_DMA, dev, "RX DMA irq handler\n");
-   /* Clear the DMA interrupt sources */
-   SMC_DMA_ACK_IRQ(dev, dma);
dma_unmap_single(NULL, rx_dmabuf, rx_dmalen, DMA_FROM_DEVICE);
BUG_ON(skb == NULL);
lp->current_rx_skb = NULL;
@@ -1792,6 +1791,9 @@ static int smc911x_probe(struct net_device *dev)
unsigned int val, chip_id, revision;
const char *version_string;
unsigned long irq_flags;
+   struct dma_slave_config config;
+   dma_cap_mask_t mask;
+   struct pxad_param param;
 
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
 
@@ -1963,11 +1965,40 @@ static int smc911x_probe(struct net_device *dev)
goto err_out;
 
 #ifdef SMC_USE_DMA
-   lp->rxdma = SMC_DMA_REQUEST(dev, smc911x_rx_dma_irq);
-   lp->txdma = SMC_DMA_REQUEST(dev, smc911x_tx_dma_irq);
+
+   dma_cap_zero(mask);
+   dma_cap_set(DMA_SLAVE, mask);
+   param.prio = PXAD_PRIO_LOWEST;
+   param.drcmr = -1UL;
+
+   lp->rxdma =
+   dma_request_slave_channel_compat(mask, pxad_filter_fn,
+, >dev, "rx");
+   lp->txdma =
+   dma_request_slave_channel_compat(mask, pxad_filter_fn,
+, >dev, "tx");
lp->rxdma_active = 0;
lp->txdma_active = 0;
-   dev->dma = lp->rxdma;
+
+   memset(, 0, sizeof(config));
+   config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+   config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+   config.src_addr = lp->physaddr + RX_DATA_FIFO;
+   config.dst_addr = lp->physaddr + TX_DATA_FIFO;
+   config.src_maxburst = 32;
+   config.dst_maxburst = 32;
+   retval = dmaengine_slave_config(lp->rxdma, );
+   if (retval) {
+   dev_err(lp->dev, "dma rx channel configuration failed: %d\n",
+   retval);
+   goto err_out;
+   }
+   retval = dmaengine_slave_config(lp->txdma, );
+   if (retval) {
+   dev_err(lp->dev, "dma tx channel configuration failed: %d\n",
+   retval);
+   goto err_out;
+   }
 #endif
 
retval = register_netdev(dev);
@@ -1978,11 +2009,11 @@ static int smc911x_probe(struct net_device *dev)
dev->base_addr, dev->irq);
 
 #ifdef SMC_USE_DMA
-   if (lp->rxdma != -1)
-

Re: [PATCH] net: smc911x: convert pxa dma to dmaengine

2016-03-15 Thread Robert Jarzmik
Robert Jarzmik <robert.jarz...@free.fr> writes:

> Fabio Estevam <feste...@gmail.com> writes:
>> Tested-by: Fabio Estevam <fabio.este...@nxp.com>
>
> Thanks Fabio for the test.
>
> I also tried with a different different approach.
>
> I built the different platforms (imx v6, etc ...) :
>  - one version (a) on a vanilla v4.5-rc2
>  - one version (b) on a vaniall v4.5-rc2 + this patch
>
> For each of the builds, I took the preprocessed output of smc911x.c, and made 
> a
> diff between (a) and (b). The commands used were :
>  - building in [1]
>  - diffing in [2]
>
> The result is [3]. I conclude from [3] that the driver cannot break for non 
> PXA
> platforms.
>
> With Fabio's test and this demonstration, is enough to convince you to apply
> this patch David ?
Hi David,

Can you consider this patch now it is tested please ?

--
Robert


Re: [PATCH] net: smc911x: convert pxa dma to dmaengine

2016-03-03 Thread Robert Jarzmik
Fabio Estevam <feste...@gmail.com> writes:

> On Sat, Feb 20, 2016 at 12:48 PM, Robert Jarzmik <robert.jarz...@free.fr> 
> wrote:
>
>> Hello,
>>
>> I'll reping once more, to see if any of you could give this patch a try.
>> So far Hitoshi doesn't have the hardware anymore, so it leaves only Guennadi 
>> and
>> Fabio.
>>
>> If you could give it a try it would be great.
>>
>> For reference, the patch is here : https://lkml.org/lkml/2015/11/30/768
>
> I finally got access to a mx53ard board, applied your patch and
> managed to NFS boot without issues:
>
> [1.739281] smsc911x f400.lan9220 eth0: SMSC911x/921x
> identified at 0xe0a8, IRQ: 207
>
> Tested-by: Fabio Estevam <fabio.este...@nxp.com>

Thanks Fabio for the test.

I also tried with a different different approach.

I built the different platforms (imx v6, etc ...) :
 - one version (a) on a vanilla v4.5-rc2
 - one version (b) on a vaniall v4.5-rc2 + this patch

For each of the builds, I took the preprocessed output of smc911x.c, and made a
diff between (a) and (b). The commands used were :
 - building in [1]
 - diffing in [2]

The result is [3]. I conclude from [3] that the driver cannot break for non PXA
platforms.

With Fabio's test and this demonstration, is enough to convince you to apply
this patch David ?

Cheers.

--
Robert

[1] Building
arm-linux-gnueabi-gcc -Wp,-MD,drivers/net/ethernet/smsc/.smc911x.o.d  -nostdinc
-isystem /usr/lib/gcc/arm-linux-gnueabi/4.9/include -I./arch/arm/include
-Iarch/arm/include/generated/uapi -Iarch/arm/include/generated  -Iinclude
-I./arch/arm/include/uapi -Iarch/arm/include/generated/uapi -I./include/uapi
-Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__
-mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs
-fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
-Wno-format-security -std=gnu89 -fno-dwarf2-cfi-asm -fno-omit-frame-pointer
-mapcs -mno-sched-prolog -fno-ipa-sra -mabi=aapcs-linux -mno-thumb-interwork
-mfpu=vfp -marm -D__LINUX_ARM_ARCH__=6 -march=armv6k -mtune=arm1136j-s
-msoft-float -Uarm -fno-delete-null-pointer-checks -O2
--param=allow-store-data-races=0 -Wframe-larger-than=1024 -fno-stack-protector
-Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls
-fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign
-fno-strict-overflow -fconserve-stack -Werror=implicit-int
-Werror=strict-prototypes -Werror=date-time -DCC_HAVE_ASM_GOTO
-D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(smc911x)"
-D"KBUILD_MODNAME=KBUILD_STR(smc911x)" -E -o
drivers/net/ethernet/smsc/smc911x_with_rjk_patch.E
drivers/net/ethernet/smsc/smc911x.c

[2] Diffing
rj@belgarion:~/mio_linux/kernel$ diff -I "#.*" -u
 drivers/net/ethernet/smsc/smc911x_without_rjk_patch.E
 drivers/net/ethernet/smsc/smc911x_with_rjk_patch.E >
 drivers/net/ethernet/smsc/smc911x_sdiff.diff

[3] Result of diffing
--- drivers/net/ethernet/smsc/smc911x_without_rjk_patch.E   2016-02-21 
16:19:27.882425010 +0100
+++ drivers/net/ethernet/smsc/smc911x_with_rjk_patch.E  2016-02-21 
16:19:59.250424159 +0100
@@ -49141,6 +49141,34 @@
 
 
 
+# 1 "include/linux/dma/pxa-dma.h" 1
+
+
+
+enum pxad_chan_prio {
+ PXAD_PRIO_HIGHEST = 0,
+ PXAD_PRIO_NORMAL,
+ PXAD_PRIO_LOW,
+ PXAD_PRIO_LOWEST,
+};
+
+struct pxad_param {
+ unsigned int drcmr;
+ enum pxad_chan_prio prio;
+};
+
+struct dma_chan;
+
+
+
+
+static inline __attribute__((always_inline)) 
__attribute__((no_instrument_function)) bool pxad_filter_fn(struct dma_chan 
*chan, void *param)
+{
+ return false;
+}
+# 78 "drivers/net/ethernet/smsc/smc911x.c" 2
+
+
 
 # 1 "drivers/net/ethernet/smsc/smc911x.h" 1
 # 31 "drivers/net/ethernet/smsc/smc911x.h"
@@ -50670,6 +50698,9 @@
  unsigned int val, chip_id, revision;
  const char *version_string;
  unsigned long irq_flags;
+ struct dma_slave_config config;
+ dma_cap_mask_t mask;
+ struct pxad_param param;
 
  do { } while (0);


[PATCH v3] net: ethernet: davicom: fix devicetree irq resource

2016-02-20 Thread Robert Jarzmik
The dm9000 driver doesn't work in at least one device-tree
configuration, spitting an error message on irq resource :
[1.062495] dm9000 800.ethernet: insufficient resources
[1.068439] dm9000 800.ethernet: not found (-2).
[1.073451] dm9000: probe of 800.ethernet failed with error -2

The reason behind is that the interrupt might be provided by a gpio
controller, not probed when dm9000 is probed, and needing the probe
deferral mechanism to apply.

Currently, the interrupt is directly taken from resources. This patch
changes this to use the more generic platform_get_irq(), which handles
the deferral.

Moreover, since commit Fixes: 7085a7401ba5 ("drivers: platform: parse
IRQ flags from resources"), the interrupt trigger flags are honored in
platform_get_irq(), so remove the needless code in dm9000.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Acked-by: Marcel Ziswiler <mar...@ziswiler.com>
Cc: Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>
---
Since v1: comment style and requested irq test < 0
  David, you should know that Sergei is concerned with the
  subsystem prefix in the patch subject (too long for him).
Since v2: leak of the ethernet device
---
 drivers/net/ethernet/davicom/dm9000.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/davicom/dm9000.c 
b/drivers/net/ethernet/davicom/dm9000.c
index cf94b72dbacd..48d91941408d 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -128,7 +128,6 @@ struct board_info {
struct resource *data_res;
struct resource *addr_req;   /* resources requested */
struct resource *data_req;
-   struct resource *irq_res;
 
int  irq_wake;
 
@@ -1300,22 +1299,16 @@ static int
 dm9000_open(struct net_device *dev)
 {
struct board_info *db = netdev_priv(dev);
-   unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK;
 
if (netif_msg_ifup(db))
dev_dbg(db->dev, "enabling %s\n", dev->name);
 
-   /* If there is no IRQ type specified, default to something that
-* may work, and tell the user that this is a problem */
-
-   if (irqflags == IRQF_TRIGGER_NONE)
-   irqflags = irq_get_trigger_type(dev->irq);
-
-   if (irqflags == IRQF_TRIGGER_NONE)
+   /* If there is no IRQ type specified, tell the user that this is a
+* problem
+*/
+   if (irq_get_trigger_type(dev->irq) == IRQF_TRIGGER_NONE)
dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
 
-   irqflags |= IRQF_SHARED;
-
/* GPIO0 on pre-activate PHY, Reg 1F is not set by reset */
iow(db, DM9000_GPR, 0); /* REG_1F bit0 activate phyxcer */
mdelay(1); /* delay needs by DM9000B */
@@ -1323,7 +1316,8 @@ dm9000_open(struct net_device *dev)
/* Initialize DM9000 board */
dm9000_init_dm9000(dev);
 
-   if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev))
+   if (request_irq(dev->irq, dm9000_interrupt, IRQF_SHARED,
+   dev->name, dev))
return -EAGAIN;
/* Now that we have an interrupt handler hooked up we can unmask
 * our interrupts
@@ -1500,15 +1494,22 @@ dm9000_probe(struct platform_device *pdev)
 
db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-   db->irq_res  = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 
-   if (db->addr_res == NULL || db->data_res == NULL ||
-   db->irq_res == NULL) {
-   dev_err(db->dev, "insufficient resources\n");
+   if (!db->addr_res || !db->data_res) {
+   dev_err(db->dev, "insufficient resources addr=%p data=%p\n",
+   db->addr_res, db->data_res);
ret = -ENOENT;
goto out;
}
 
+   ndev->irq = platform_get_irq(pdev, 0);
+   if (ndev->irq < 0) {
+   dev_err(db->dev, "interrupt resource unavailable: %d\n",
+   ndev->irq);
+   ret = ndev->irq;
+   goto out;
+   }
+
db->irq_wake = platform_get_irq(pdev, 1);
if (db->irq_wake >= 0) {
dev_dbg(db->dev, "wakeup irq %d\n", db->irq_wake);
@@ -1570,7 +1571,6 @@ dm9000_probe(struct platform_device *pdev)
 
/* fill in parameters for net-dev structure */
ndev->base_addr = (unsigned long)db->io_addr;
-   ndev->irq   = db->irq_res->start;
 
/* ensure at least we have a default set of IO routines */
dm9000_set_io(db, iosize);
-- 
2.1.4



Re: [PATCH] net: smc911x: convert pxa dma to dmaengine

2016-02-20 Thread Robert Jarzmik
Hitoshi Mitake <mitake.hito...@gmail.com> writes:

> Hi Robert,
>
> On Sat, Feb 6, 2016 at 6:05 PM, Robert Jarzmik <robert.jarz...@free.fr> wrote:
> > Please just keep pinging people to properly test this.
> 
> Okay, let's have another try.
> 
> Hi Guennadi, Hitoshi, Fabio,
> 
> Could any of you try this patch to ensure your board is not broken please 
> ?
> I've re-added the patch at the end of this mail for easier handling.
> Normally no
> code path in non-PXA board is changed, so the test should be
> straightforward.
> 
> It's also available in : https://lkml.org/lkml/2015/11/30/768
> 
> You're the maintainers of the following boards using smc911x AFAIK:
> - sh2007: Guennadi and Hitoshi
>
> Really sorry, currently I don't have the board :(
> Do you have a working board that can be used for testing, Guennadi?
>
> Thanks,
> Hitoshi

Hello,

I'll reping once more, to see if any of you could give this patch a try.
So far Hitoshi doesn't have the hardware anymore, so it leaves only Guennadi and
Fabio.

If you could give it a try it would be great.

For reference, the patch is here : https://lkml.org/lkml/2015/11/30/768

Cheers.

--
Robert


Re: [PATCH v2] net: ethernet: davicom: fix devicetree irq resource

2016-02-07 Thread Robert Jarzmik
Sergei Shtylyov  writes:

>> Moreover, since commit Fixes: 7085a7401ba5 ("drivers: platform: parse
>
>Fixes: tag here?
Heuh no. It doesn't fix this commit, it uses a feature brought by this commit.

>> +if (irq_get_trigger_type(dev->irq) == IRQF_TRIGGER_NONE)
>>  dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
>>
>>  irqflags |= IRQF_SHARED;
>
>Why not just initialize to IRQF_SHARED?
>But actually you don't need this variable anymore.
Yeah, makes sense.

Cheers.

-- 
Robert


Re: [PATCH v2] net: ethernet: davicom: fix devicetree irq resource

2016-02-07 Thread Robert Jarzmik
Francois Romieu <rom...@fr.zoreil.com> writes:

> Robert Jarzmik <robert.jarz...@free.fr> :
> [...]
>> diff --git a/drivers/net/ethernet/davicom/dm9000.c 
>> b/drivers/net/ethernet/davicom/dm9000.c
>> index cf94b72dbacd..2bae5c8c1f85 100644
>> --- a/drivers/net/ethernet/davicom/dm9000.c
>> +++ b/drivers/net/ethernet/davicom/dm9000.c
> [...]
>> @@ -1500,15 +1496,21 @@ dm9000_probe(struct platform_device *pdev)
>>  
>>  db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>  db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
>> -db->irq_res  = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
>>  
>> -if (db->addr_res == NULL || db->data_res == NULL ||
>> -db->irq_res == NULL) {
>> -dev_err(db->dev, "insufficient resources\n");
>> +if (!db->addr_res || !db->data_res) {
>> +dev_err(db->dev, "insufficient resources addr=%p data=%p\n",
>> +db->addr_res, db->data_res);
>>  ret = -ENOENT;
>>  goto out;
>>  }
>>  
>> +ndev->irq = platform_get_irq(pdev, 0);
>> +if (ndev->irq < 0) {
>> +dev_err(db->dev, "interrupt resource unavailable: %d\n",
>> +ndev->irq);
>> +return ndev->irq;
>> +}
>> +
>
> Leak: please set 'ret = ndev->irq;' and proceed to the 'out' label.
Indeed, the etherdev, good catch.

> If you have some spare time, it would be nice to avoid db->irq_wake leak
> on probe failure or driver removal.
Sorry but not in this patch.

I suppose the right patch would be to use devm_*() in the probe function for
ioremaps and request_irqs, which would address this point.

Cheers.

-- 
Robert


[PATCH v2] net: ethernet: davicom: fix devicetree irq resource

2016-02-06 Thread Robert Jarzmik
The dm9000 driver doesn't work in at least one device-tree
configuration, spitting an error message on irq resource :
[1.062495] dm9000 800.ethernet: insufficient resources
[1.068439] dm9000 800.ethernet: not found (-2).
[1.073451] dm9000: probe of 800.ethernet failed with error -2

The reason behind is that the interrupt might be provided by a gpio
controller, not probed when dm9000 is probed, and needing the probe
deferral mechanism to apply.

Currently, the interrupt is directly taken from resources. This patch
changes this to use the more generic platform_get_irq(), which handles
the deferral.

Moreover, since commit Fixes: 7085a7401ba5 ("drivers: platform: parse
IRQ flags from resources"), the interrupt trigger flags are honored in
platform_get_irq(), so remove the needless code in dm9000.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Acked-by: Marcel Ziswiler <mar...@ziswiler.com>
Cc: Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>
---
Since v1: comment style and requested irq test < 0
  David, you should know that Sergei is concerned with the
  subsystem prefix in the patch subject (too long for him).
---
 drivers/net/ethernet/davicom/dm9000.c | 29 +++--
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/davicom/dm9000.c 
b/drivers/net/ethernet/davicom/dm9000.c
index cf94b72dbacd..2bae5c8c1f85 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -128,7 +128,6 @@ struct board_info {
struct resource *data_res;
struct resource *addr_req;   /* resources requested */
struct resource *data_req;
-   struct resource *irq_res;
 
int  irq_wake;
 
@@ -1300,18 +1299,15 @@ static int
 dm9000_open(struct net_device *dev)
 {
struct board_info *db = netdev_priv(dev);
-   unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK;
+   unsigned long irqflags = 0;
 
if (netif_msg_ifup(db))
dev_dbg(db->dev, "enabling %s\n", dev->name);
 
-   /* If there is no IRQ type specified, default to something that
-* may work, and tell the user that this is a problem */
-
-   if (irqflags == IRQF_TRIGGER_NONE)
-   irqflags = irq_get_trigger_type(dev->irq);
-
-   if (irqflags == IRQF_TRIGGER_NONE)
+   /* If there is no IRQ type specified, tell the user that this is a
+* problem
+*/
+   if (irq_get_trigger_type(dev->irq) == IRQF_TRIGGER_NONE)
dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
 
irqflags |= IRQF_SHARED;
@@ -1500,15 +1496,21 @@ dm9000_probe(struct platform_device *pdev)
 
db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-   db->irq_res  = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 
-   if (db->addr_res == NULL || db->data_res == NULL ||
-   db->irq_res == NULL) {
-   dev_err(db->dev, "insufficient resources\n");
+   if (!db->addr_res || !db->data_res) {
+   dev_err(db->dev, "insufficient resources addr=%p data=%p\n",
+   db->addr_res, db->data_res);
ret = -ENOENT;
goto out;
}
 
+   ndev->irq = platform_get_irq(pdev, 0);
+   if (ndev->irq < 0) {
+   dev_err(db->dev, "interrupt resource unavailable: %d\n",
+   ndev->irq);
+   return ndev->irq;
+   }
+
db->irq_wake = platform_get_irq(pdev, 1);
if (db->irq_wake >= 0) {
dev_dbg(db->dev, "wakeup irq %d\n", db->irq_wake);
@@ -1570,7 +1572,6 @@ dm9000_probe(struct platform_device *pdev)
 
/* fill in parameters for net-dev structure */
ndev->base_addr = (unsigned long)db->io_addr;
-   ndev->irq   = db->irq_res->start;
 
/* ensure at least we have a default set of IO routines */
dm9000_set_io(db, iosize);
-- 
2.1.4



[PATCH v2] net: smc91x: propagate irq return code

2016-02-06 Thread Robert Jarzmik
The smc91x driver doesn't honor the probe deferral mechanism when the
interrupt source is not yet available, such as one provided by a gpio
controller not probed.

Fix this by propagating the platform_get_irq() error code as the probe
return value.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Cc: Sergei Shtylyov <sergei.shtyl...@cogentembedded.com>
---
Since v1: change the irq test to < 0
---
 drivers/net/ethernet/smsc/smc91x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index 0e2fc1a844ab..db7db8ac4ca3 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2342,8 +2342,8 @@ static int smc_drv_probe(struct platform_device *pdev)
}
 
ndev->irq = platform_get_irq(pdev, 0);
-   if (ndev->irq <= 0) {
-   ret = -ENODEV;
+   if (ndev->irq < 0) {
+   ret = ndev->irq;
goto out_release_io;
}
/*
-- 
2.1.4



Re: [PATCH] net: smc911x: convert pxa dma to dmaengine

2016-02-06 Thread Robert Jarzmik
David Miller <da...@davemloft.net> writes:

> From: Robert Jarzmik <robert.jarz...@free.fr>
> Date: Fri, 05 Feb 2016 22:44:56 +0100
>
>> Apart from Alberto who answered he cannot test it by lack of hardware, the
>> others didn't answer.
>> 
>> So how can I move forward ? Would you want me to amend the KConfig to add a 
>> "&&
>> !ARCH_PXA" on the "depend" line ?
>
> Please just keep pinging people to properly test this.
Okay, let's have another try.

Hi Guennadi, Hitoshi, Fabio,

Could any of you try this patch to ensure your board is not broken please ?
I've re-added the patch at the end of this mail for easier handling. Normally no
code path in non-PXA board is changed, so the test should be straightforward.

It's also available in : https://lkml.org/lkml/2015/11/30/768

You're the maintainers of the following boards using smc911x AFAIK:
 - sh2007: Guennadi and Hitoshi
 - armadillo5x0: Alberto
 - imx v6 and imx v7: Fabio

Cheers.

-- 
Robert


---8<---
From: Robert Jarzmik <robert.jarz...@free.fr>
Subject: [PATCH] net: smc911x: convert pxa dma to dmaengine
To: "David S. Miller" <da...@davemloft.net>
Cc: netdev@vger.kernel.org, linux-ker...@vger.kernel.org, Robert Jarzmik 
<robert.jarz...@free.fr>
Date: Mon, 30 Nov 2015 22:40:28 +0100 (9 weeks, 4 days, 11 hours ago)
Message-Id: <1448919628-13273-1-git-send-email-robert.jarz...@free.fr>
X-Mailer: git-send-email 2.1.4

Convert the dma transfers to be dmaengine based, now pxa has a dmaengine
slave driver. This makes this driver a bit more PXA agnostic.

The driver was only compile tested. The risk is quite small as no
current PXA platform I'm aware of is using smc911x driver.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc911x.c | 85 -
 drivers/net/ethernet/smsc/smc911x.h | 63 ---
 2 files changed, 82 insertions(+), 66 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc911x.c 
b/drivers/net/ethernet/smsc/smc911x.c
index bd64eb982e52..3f5711061432 100644
--- a/drivers/net/ethernet/smsc/smc911x.c
+++ b/drivers/net/ethernet/smsc/smc911x.c
@@ -73,6 +73,9 @@ static const char version[] =
 #include 
 #include 
 
+#include 
+#include 
+
 #include 
 
 #include "smc911x.h"
@@ -1174,18 +1177,16 @@ static irqreturn_t smc911x_interrupt(int irq, void 
*dev_id)
 
 #ifdef SMC_USE_DMA
 static void
-smc911x_tx_dma_irq(int dma, void *data)
+smc911x_tx_dma_irq(void *data)
 {
-   struct net_device *dev = (struct net_device *)data;
-   struct smc911x_local *lp = netdev_priv(dev);
+   struct smc911x_local *lp = data;
+   struct net_device *dev = lp->netdev;
struct sk_buff *skb = lp->current_tx_skb;
unsigned long flags;
 
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
 
DBG(SMC_DEBUG_TX | SMC_DEBUG_DMA, dev, "TX DMA irq handler\n");
-   /* Clear the DMA interrupt sources */
-   SMC_DMA_ACK_IRQ(dev, dma);
BUG_ON(skb == NULL);
dma_unmap_single(NULL, tx_dmabuf, tx_dmalen, DMA_TO_DEVICE);
dev->trans_start = jiffies;
@@ -1208,18 +1209,16 @@ smc911x_tx_dma_irq(int dma, void *data)
"TX DMA irq completed\n");
 }
 static void
-smc911x_rx_dma_irq(int dma, void *data)
+smc911x_rx_dma_irq(void *data)
 {
-   struct net_device *dev = (struct net_device *)data;
-   struct smc911x_local *lp = netdev_priv(dev);
+   struct smc911x_local *lp = data;
+   struct net_device *dev = lp->netdev;
struct sk_buff *skb = lp->current_rx_skb;
unsigned long flags;
unsigned int pkts;
 
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
DBG(SMC_DEBUG_RX | SMC_DEBUG_DMA, dev, "RX DMA irq handler\n");
-   /* Clear the DMA interrupt sources */
-   SMC_DMA_ACK_IRQ(dev, dma);
dma_unmap_single(NULL, rx_dmabuf, rx_dmalen, DMA_FROM_DEVICE);
BUG_ON(skb == NULL);
lp->current_rx_skb = NULL;
@@ -1792,6 +1791,9 @@ static int smc911x_probe(struct net_device *dev)
unsigned int val, chip_id, revision;
const char *version_string;
unsigned long irq_flags;
+   struct dma_slave_config config;
+   dma_cap_mask_t mask;
+   struct pxad_param param;
 
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
 
@@ -1963,11 +1965,40 @@ static int smc911x_probe(struct net_device *dev)
goto err_out;
 
 #ifdef SMC_USE_DMA
-   lp->rxdma = SMC_DMA_REQUEST(dev, smc911x_rx_dma_irq);
-   lp->txdma = SMC_DMA_REQUEST(dev, smc911x_tx_dma_irq);
+
+   dma_cap_zero(mask);
+   dma_cap_set(DMA_SLAVE, mask);
+   param.prio = PXAD_PRIO_LOWEST;
+   param.drcmr = -1UL;
+
+   lp->rxdma =
+   dma_request_slave_channel_compat(mask, pxad_filter_fn,
+  

Re: [PATCH] net: smc911x: convert pxa dma to dmaengine

2016-02-05 Thread Robert Jarzmik
Robert Jarzmik <robert.jarz...@free.fr> writes:

> David Miller <da...@davemloft.net> writes:
>
>> From: Robert Jarzmik <robert.jarz...@free.fr>
>> Date: Mon, 30 Nov 2015 22:40:28 +0100
>>
>>> Convert the dma transfers to be dmaengine based, now pxa has a dmaengine
>>> slave driver. This makes this driver a bit more PXA agnostic.
>>> 
>>> The driver was only compile tested. The risk is quite small as no
>>> current PXA platform I'm aware of is using smc911x driver.
>>> 
>>> Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
>>
>> I've marked this 'deferred' in patchwork until someone tests
>> these changes and says they should be good on all platforms
>> this chip is used.
>
> Okay, so would any maintainer of non pxa boards give a feedback for this 
> patch ?
> The ones I have found are :
>  - sh2007: Guennadi and Hitoshi
>  - armadillo5x0: Alberto
>  - imx v6 and imx v7: Fabio
> I've added the patch at the end of this mail for easier handling.
>
> Now, if no maintainer gives it a test, what do we do, David ? I'm intending to
> remove "arch/arm/mach-pxa/include/mach/dma.h" in the near future, which will
> break this driver somehow (at least for PXA boards, even if none is identified
> so far).
> So could we agree on a deadline, and what you wish to do : either drop the 
> patch
> or apply, or something else.

Hi David,

Apart from Alberto who answered he cannot test it by lack of hardware, the
others didn't answer.

So how can I move forward ? Would you want me to amend the KConfig to add a "&&
!ARCH_PXA" on the "depend" line ?

Cheers.

-- 
Robert


Re: [PATCH] net: ethernet: davicom: fix devicetree irq resource

2016-02-04 Thread Robert Jarzmik
Sergei Shtylyov  writes:

> Hello.
>
>Your patch summary prefixes are too verbose, it was enough to say only
> "dm9000: ".
Well, I don't agree here. The subsystem should be fully specified, at least this
is something I require in pxa, something that is also required in sound/*, etc
... If David doesn't object, I'll keep it that way. As it's his tree, his
decision in the end, so let's have him decide.

>> -/* If there is no IRQ type specified, default to something that
>> - * may work, and tell the user that this is a problem */
>> -
>> -if (irqflags == IRQF_TRIGGER_NONE)
>> -irqflags = irq_get_trigger_type(dev->irq);
>> -
>> -if (irqflags == IRQF_TRIGGER_NONE)
>> +/* If there is no IRQ type specified, tell the user that this is a
>> + * problem */
>
>The networking code formats comments this way:
>
> /* foo
>  * bar
>  */
May I know where this is documented ?
I'm asking because I didn't find it, because I parsed drivers/net/*.c files, and
the standard kernel comment style was there, ie:
/*
 * foo
 * bar
 */

I was reusing the previous comment style, but I will change it for the standard
kernel style if you wish.

>>
>> +ndev->irq = platform_get_irq(pdev, 0);
>> +if (ndev->irq <= 0) {
>
>I don't recommend checking for 0 and returning early in this case -- 
> you'll signal a probe success this way. Either ignore 0 or return -E
> in this case. Unfortunately, platform_get_irq() is so sloppily coded now that 
> it
> *can* return 0 on error. :-(
Ah we had that discussion not very long ago, didn't we ? :)
And I think I'll reuse the "if (ndev->irq < 0) {" solution to be consistent with
myself.

Thanks for the review.

-- 
Robert


[PATCH] net: ethernet: davicom: fix devicetree irq resource

2016-02-03 Thread Robert Jarzmik
The dm9000 driver doesn't work in at least one device-tree
configuration, spitting an error message on irq resource :
[1.062495] dm9000 800.ethernet: insufficient resources
[1.068439] dm9000 800.ethernet: not found (-2).
[1.073451] dm9000: probe of 800.ethernet failed with error -2

The reason behind is that the interrupt might be provided by a gpio
controller, not probed when dm9000 is probed, and needing the probe
deferral mechanism to apply.

Currently, the interrupt is directly taken from resources. This patch
changes this to use the more generic platform_get_irq(), which handles
the deferral.

Moreover, since commit Fixes: 7085a7401ba5 ("drivers: platform: parse
IRQ flags from resources"), the interrupt trigger flags are honored in
platform_get_irq(), so remove the needless code in dm9000.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Acked-by: Marcel Ziswiler <mar...@ziswiler.com>
---
 drivers/net/ethernet/davicom/dm9000.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/davicom/dm9000.c 
b/drivers/net/ethernet/davicom/dm9000.c
index cf94b72dbacd..6c527bde9edb 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -128,7 +128,6 @@ struct board_info {
struct resource *data_res;
struct resource *addr_req;   /* resources requested */
struct resource *data_req;
-   struct resource *irq_res;
 
int  irq_wake;
 
@@ -1300,18 +1299,14 @@ static int
 dm9000_open(struct net_device *dev)
 {
struct board_info *db = netdev_priv(dev);
-   unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK;
+   unsigned long irqflags = 0;
 
if (netif_msg_ifup(db))
dev_dbg(db->dev, "enabling %s\n", dev->name);
 
-   /* If there is no IRQ type specified, default to something that
-* may work, and tell the user that this is a problem */
-
-   if (irqflags == IRQF_TRIGGER_NONE)
-   irqflags = irq_get_trigger_type(dev->irq);
-
-   if (irqflags == IRQF_TRIGGER_NONE)
+   /* If there is no IRQ type specified, tell the user that this is a
+* problem */
+   if (irq_get_trigger_type(dev->irq) == IRQF_TRIGGER_NONE)
dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
 
irqflags |= IRQF_SHARED;
@@ -1500,15 +1495,21 @@ dm9000_probe(struct platform_device *pdev)
 
db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-   db->irq_res  = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 
-   if (db->addr_res == NULL || db->data_res == NULL ||
-   db->irq_res == NULL) {
-   dev_err(db->dev, "insufficient resources\n");
+   if (db->addr_res == NULL || db->data_res == NULL) {
+   dev_err(db->dev, "insufficient resources addr=%p data=%p\n",
+   db->addr_res, db->data_res);
ret = -ENOENT;
goto out;
}
 
+   ndev->irq = platform_get_irq(pdev, 0);
+   if (ndev->irq <= 0) {
+   dev_err(db->dev, "interrupt resource unavailable: %d\n",
+   ndev->irq);
+   return ndev->irq;
+   }
+
db->irq_wake = platform_get_irq(pdev, 1);
if (db->irq_wake >= 0) {
dev_dbg(db->dev, "wakeup irq %d\n", db->irq_wake);
@@ -1570,7 +1571,6 @@ dm9000_probe(struct platform_device *pdev)
 
/* fill in parameters for net-dev structure */
ndev->base_addr = (unsigned long)db->io_addr;
-   ndev->irq   = db->irq_res->start;
 
/* ensure at least we have a default set of IO routines */
dm9000_set_io(db, iosize);
-- 
2.1.4



Re: [PATCH] net: smc91x: propagate irq return code

2016-02-01 Thread Robert Jarzmik
Sergei Shtylyov <sergei.shtyl...@cogentembedded.com> writes:

> On 02/01/2016 11:41 PM, Robert Jarzmik wrote:
>
>>>> The smc91x driver doesn't honor the probe deferral mechanism when the
>>>> interrupt source is not yet available, such as one provided by a gpio
>>>> controller not probed.
>
>>> What if 'ndev->irq' does equal 0?
>
>> That's not possible AFAIR.
>
>Possible if of_irq_get() returns 0 (and it will on failure!).
Ah good catch, didn't know that one.

>> And yet, that test now looks weird to me. I think I'll respin the patch with 
>> a
>> "if (ndev->irq < 0) {" instead of the "if (ndev->irq <= 0) {".
>
>Defeating Linus' PoV as a result... ;-)
Well, I'd rather face the wrath of others if I'm convinced the code is more
correct. And in this case you convinced me :)

-- 
Robert


Re: [PATCH] net: smc91x: propagate irq return code

2016-02-01 Thread Robert Jarzmik
Sergei Shtylyov <sergei.shtyl...@cogentembedded.com> writes:

> Hello.
>
> On 2/1/2016 1:46 AM, Robert Jarzmik wrote:
>
>> The smc91x driver doesn't honor the probe deferral mechanism when the
>> interrupt source is not yet available, such as one provided by a gpio
>> controller not probed.
>What if 'ndev->irq' does equal 0?
That's not possible AFAIR.

There was a discussion where Linus had stated that the irq is a cookie, and a 0
value is "no interrupt", expcepting for the single case of a PC and its timer
interrupt.

As we're not in that case, and up to my understanding, platform_get_irq() cannot
return a 0 value, only a strictly negative or positive one.

And yet, that test now looks weird to me. I think I'll respin the patch with a
"if (ndev->irq < 0) {" instead of the "if (ndev->irq <= 0) {".

Cheers.

-- 
Robert


[PATCH] net: smc91x: propagate irq return code

2016-01-31 Thread Robert Jarzmik
The smc91x driver doesn't honor the probe deferral mechanism when the
interrupt source is not yet available, such as one provided by a gpio
controller not probed.

Fix this by propagating the platform_get_irq() error code as the probe
return value.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc91x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index 0e2fc1a844ab..43ab7aa31a79 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2343,7 +2343,7 @@ static int smc_drv_probe(struct platform_device *pdev)
 
ndev->irq = platform_get_irq(pdev, 0);
if (ndev->irq <= 0) {
-   ret = -ENODEV;
+   ret = ndev->irq;
goto out_release_io;
}
/*
-- 
2.1.4



Re: [PATCH] net: smc911x: convert pxa dma to dmaengine

2015-12-03 Thread Robert Jarzmik
David Miller <da...@davemloft.net> writes:

> From: Robert Jarzmik <robert.jarz...@free.fr>
> Date: Mon, 30 Nov 2015 22:40:28 +0100
>
>> Convert the dma transfers to be dmaengine based, now pxa has a dmaengine
>> slave driver. This makes this driver a bit more PXA agnostic.
>> 
>> The driver was only compile tested. The risk is quite small as no
>> current PXA platform I'm aware of is using smc911x driver.
>> 
>> Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
>
> I've marked this 'deferred' in patchwork until someone tests
> these changes and says they should be good on all platforms
> this chip is used.

Okay, so would any maintainer of non pxa boards give a feedback for this patch ?
The ones I have found are :
 - sh2007: Guennadi and Hitoshi
 - armadillo5x0: Alberto
 - imx v6 and imx v7: Fabio
I've added the patch at the end of this mail for easier handling.

Now, if no maintainer gives it a test, what do we do, David ? I'm intending to
remove "arch/arm/mach-pxa/include/mach/dma.h" in the near future, which will
break this driver somehow (at least for PXA boards, even if none is identified
so far).
So could we agree on a deadline, and what you wish to do : either drop the patch
or apply, or something else.

Cheers.

-- 
Robert

--8>--
>From 9b7e996fe92d81d417f59a4eed92b3472594a2e8 Mon Sep 17 00:00:00 2001
From: Robert Jarzmik <robert.jarz...@free.fr>
Date: Thu, 10 Sep 2015 14:48:09 +0200
Subject: [PATCH] net: smc911x: convert pxa dma to dmaengine

Convert the dma transfers to be dmaengine based, now pxa has a dmaengine
slave driver. This makes this driver a bit more PXA agnostic.

The driver was only compile tested. The risk is quite small as no
current PXA platform I'm aware of is using smc911x driver.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc911x.c | 85 -
 drivers/net/ethernet/smsc/smc911x.h | 63 ---
 2 files changed, 82 insertions(+), 66 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc911x.c 
b/drivers/net/ethernet/smsc/smc911x.c
index bd64eb982e52..3f5711061432 100644
--- a/drivers/net/ethernet/smsc/smc911x.c
+++ b/drivers/net/ethernet/smsc/smc911x.c
@@ -73,6 +73,9 @@ static const char version[] =
 #include 
 #include 
 
+#include 
+#include 
+
 #include 
 
 #include "smc911x.h"
@@ -1174,18 +1177,16 @@ static irqreturn_t smc911x_interrupt(int irq, void 
*dev_id)
 
 #ifdef SMC_USE_DMA
 static void
-smc911x_tx_dma_irq(int dma, void *data)
+smc911x_tx_dma_irq(void *data)
 {
-   struct net_device *dev = (struct net_device *)data;
-   struct smc911x_local *lp = netdev_priv(dev);
+   struct smc911x_local *lp = data;
+   struct net_device *dev = lp->netdev;
struct sk_buff *skb = lp->current_tx_skb;
unsigned long flags;
 
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
 
DBG(SMC_DEBUG_TX | SMC_DEBUG_DMA, dev, "TX DMA irq handler\n");
-   /* Clear the DMA interrupt sources */
-   SMC_DMA_ACK_IRQ(dev, dma);
BUG_ON(skb == NULL);
dma_unmap_single(NULL, tx_dmabuf, tx_dmalen, DMA_TO_DEVICE);
dev->trans_start = jiffies;
@@ -1208,18 +1209,16 @@ smc911x_tx_dma_irq(int dma, void *data)
"TX DMA irq completed\n");
 }
 static void
-smc911x_rx_dma_irq(int dma, void *data)
+smc911x_rx_dma_irq(void *data)
 {
-   struct net_device *dev = (struct net_device *)data;
-   struct smc911x_local *lp = netdev_priv(dev);
+   struct smc911x_local *lp = data;
+   struct net_device *dev = lp->netdev;
struct sk_buff *skb = lp->current_rx_skb;
unsigned long flags;
unsigned int pkts;
 
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
DBG(SMC_DEBUG_RX | SMC_DEBUG_DMA, dev, "RX DMA irq handler\n");
-   /* Clear the DMA interrupt sources */
-   SMC_DMA_ACK_IRQ(dev, dma);
dma_unmap_single(NULL, rx_dmabuf, rx_dmalen, DMA_FROM_DEVICE);
BUG_ON(skb == NULL);
lp->current_rx_skb = NULL;
@@ -1792,6 +1791,9 @@ static int smc911x_probe(struct net_device *dev)
unsigned int val, chip_id, revision;
const char *version_string;
unsigned long irq_flags;
+   struct dma_slave_config config;
+   dma_cap_mask_t mask;
+   struct pxad_param param;
 
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
 
@@ -1963,11 +1965,40 @@ static int smc911x_probe(struct net_device *dev)
goto err_out;
 
 #ifdef SMC_USE_DMA
-   lp->rxdma = SMC_DMA_REQUEST(dev, smc911x_rx_dma_irq);
-   lp->txdma = SMC_DMA_REQUEST(dev, smc911x_tx_dma_irq);
+
+   dma_cap_zero(mask);
+   dma_cap_set(DMA_SLAVE, mask);
+   param.prio = PXAD_PRIO_LOWEST;
+   param.drcmr = -1UL;
+
+   lp->rxdma =
+

[PATCH] net: smc911x: convert pxa dma to dmaengine

2015-11-30 Thread Robert Jarzmik
Convert the dma transfers to be dmaengine based, now pxa has a dmaengine
slave driver. This makes this driver a bit more PXA agnostic.

The driver was only compile tested. The risk is quite small as no
current PXA platform I'm aware of is using smc911x driver.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/ethernet/smsc/smc911x.c | 85 -
 drivers/net/ethernet/smsc/smc911x.h | 63 ---
 2 files changed, 82 insertions(+), 66 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc911x.c 
b/drivers/net/ethernet/smsc/smc911x.c
index bd64eb982e52..3f5711061432 100644
--- a/drivers/net/ethernet/smsc/smc911x.c
+++ b/drivers/net/ethernet/smsc/smc911x.c
@@ -73,6 +73,9 @@ static const char version[] =
 #include 
 #include 
 
+#include 
+#include 
+
 #include 
 
 #include "smc911x.h"
@@ -1174,18 +1177,16 @@ static irqreturn_t smc911x_interrupt(int irq, void 
*dev_id)
 
 #ifdef SMC_USE_DMA
 static void
-smc911x_tx_dma_irq(int dma, void *data)
+smc911x_tx_dma_irq(void *data)
 {
-   struct net_device *dev = (struct net_device *)data;
-   struct smc911x_local *lp = netdev_priv(dev);
+   struct smc911x_local *lp = data;
+   struct net_device *dev = lp->netdev;
struct sk_buff *skb = lp->current_tx_skb;
unsigned long flags;
 
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
 
DBG(SMC_DEBUG_TX | SMC_DEBUG_DMA, dev, "TX DMA irq handler\n");
-   /* Clear the DMA interrupt sources */
-   SMC_DMA_ACK_IRQ(dev, dma);
BUG_ON(skb == NULL);
dma_unmap_single(NULL, tx_dmabuf, tx_dmalen, DMA_TO_DEVICE);
dev->trans_start = jiffies;
@@ -1208,18 +1209,16 @@ smc911x_tx_dma_irq(int dma, void *data)
"TX DMA irq completed\n");
 }
 static void
-smc911x_rx_dma_irq(int dma, void *data)
+smc911x_rx_dma_irq(void *data)
 {
-   struct net_device *dev = (struct net_device *)data;
-   struct smc911x_local *lp = netdev_priv(dev);
+   struct smc911x_local *lp = data;
+   struct net_device *dev = lp->netdev;
struct sk_buff *skb = lp->current_rx_skb;
unsigned long flags;
unsigned int pkts;
 
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
DBG(SMC_DEBUG_RX | SMC_DEBUG_DMA, dev, "RX DMA irq handler\n");
-   /* Clear the DMA interrupt sources */
-   SMC_DMA_ACK_IRQ(dev, dma);
dma_unmap_single(NULL, rx_dmabuf, rx_dmalen, DMA_FROM_DEVICE);
BUG_ON(skb == NULL);
lp->current_rx_skb = NULL;
@@ -1792,6 +1791,9 @@ static int smc911x_probe(struct net_device *dev)
unsigned int val, chip_id, revision;
const char *version_string;
unsigned long irq_flags;
+   struct dma_slave_config config;
+   dma_cap_mask_t mask;
+   struct pxad_param param;
 
DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__);
 
@@ -1963,11 +1965,40 @@ static int smc911x_probe(struct net_device *dev)
goto err_out;
 
 #ifdef SMC_USE_DMA
-   lp->rxdma = SMC_DMA_REQUEST(dev, smc911x_rx_dma_irq);
-   lp->txdma = SMC_DMA_REQUEST(dev, smc911x_tx_dma_irq);
+
+   dma_cap_zero(mask);
+   dma_cap_set(DMA_SLAVE, mask);
+   param.prio = PXAD_PRIO_LOWEST;
+   param.drcmr = -1UL;
+
+   lp->rxdma =
+   dma_request_slave_channel_compat(mask, pxad_filter_fn,
+, >dev, "rx");
+   lp->txdma =
+   dma_request_slave_channel_compat(mask, pxad_filter_fn,
+, >dev, "tx");
lp->rxdma_active = 0;
lp->txdma_active = 0;
-   dev->dma = lp->rxdma;
+
+   memset(, 0, sizeof(config));
+   config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+   config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+   config.src_addr = lp->physaddr + RX_DATA_FIFO;
+   config.dst_addr = lp->physaddr + TX_DATA_FIFO;
+   config.src_maxburst = 32;
+   config.dst_maxburst = 32;
+   retval = dmaengine_slave_config(lp->rxdma, );
+   if (retval) {
+   dev_err(lp->dev, "dma rx channel configuration failed: %d\n",
+   retval);
+   goto err_out;
+   }
+   retval = dmaengine_slave_config(lp->txdma, );
+   if (retval) {
+   dev_err(lp->dev, "dma tx channel configuration failed: %d\n",
+   retval);
+   goto err_out;
+   }
 #endif
 
retval = register_netdev(dev);
@@ -1978,11 +2009,11 @@ static int smc911x_probe(struct net_device *dev)
dev->base_addr, dev->irq);
 
 #ifdef SMC_USE_DMA
-   if (lp->rxdma != -1)
-   pr_cont(" RXDMA %d", lp->rxdma);
+   if (lp->rxdma)

[PATCH v3 3/3] net: irda: pxaficp_ir: dmaengine conversion

2015-09-26 Thread Robert Jarzmik
Convert pxaficp_ir to dmaengine. As pxa architecture is shifting from
raw DMA registers access to pxa_dma dmaengine driver, convert this
driver to dmaengine.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Tested-by: Petr Cvek <petr.c...@tul.cz>
---
Since v1: removed mach/dma.h include, which is the goal
---
 drivers/net/irda/pxaficp_ir.c | 149 +-
 1 file changed, 102 insertions(+), 47 deletions(-)

diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index 05a668216a0f..6e8f616be48e 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -19,6 +19,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 
@@ -27,7 +30,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #undef __REG
 #define __REG(x) ((x) & 0x)
@@ -146,8 +148,12 @@ struct pxa_irda {
dma_addr_t  dma_rx_buff_phy;
dma_addr_t  dma_tx_buff_phy;
unsigned intdma_tx_buff_len;
-   int txdma;
-   int rxdma;
+   struct dma_chan *txdma;
+   struct dma_chan *rxdma;
+   dma_cookie_trx_cookie;
+   dma_cookie_ttx_cookie;
+   int drcmr_rx;
+   int drcmr_tx;
 
int uart_irq;
int icp_irq;
@@ -165,6 +171,8 @@ struct pxa_irda {
struct clk  *cur_clk;
 };
 
+static int pxa_irda_set_speed(struct pxa_irda *si, int speed);
+
 static inline void pxa_irda_disable_clk(struct pxa_irda *si)
 {
if (si->cur_clk)
@@ -188,22 +196,41 @@ static inline void pxa_irda_enable_sirclk(struct pxa_irda 
*si)
 #define IS_FIR(si) ((si)->speed >= 400)
 #define IRDA_FRAME_SIZE_LIMIT  2047
 
+static void pxa_irda_fir_dma_rx_irq(void *data);
+static void pxa_irda_fir_dma_tx_irq(void *data);
+
 inline static void pxa_irda_fir_dma_rx_start(struct pxa_irda *si)
 {
-   DCSR(si->rxdma)  = DCSR_NODESC;
-   DSADR(si->rxdma) = (unsigned long)si->irda_base + ICDR;
-   DTADR(si->rxdma) = si->dma_rx_buff_phy;
-   DCMD(si->rxdma) = DCMD_INCTRGADDR | DCMD_FLOWSRC |  DCMD_WIDTH1 | 
DCMD_BURST32 | IRDA_FRAME_SIZE_LIMIT;
-   DCSR(si->rxdma) |= DCSR_RUN;
+   struct dma_async_tx_descriptor *tx;
+
+   tx = dmaengine_prep_slave_single(si->rxdma, si->dma_rx_buff_phy,
+IRDA_FRAME_SIZE_LIMIT, DMA_FROM_DEVICE,
+DMA_PREP_INTERRUPT);
+   if (!tx) {
+   dev_err(si->dev, "prep_slave_sg() failed\n");
+   return;
+   }
+   tx->callback = pxa_irda_fir_dma_rx_irq;
+   tx->callback_param = si;
+   si->rx_cookie = dmaengine_submit(tx);
+   dma_async_issue_pending(si->rxdma);
 }
 
 inline static void pxa_irda_fir_dma_tx_start(struct pxa_irda *si)
 {
-   DCSR(si->txdma)  = DCSR_NODESC;
-   DSADR(si->txdma) = si->dma_tx_buff_phy;
-   DTADR(si->txdma) = (unsigned long)si->irda_base + ICDR;
-   DCMD(si->txdma) = DCMD_INCSRCADDR | DCMD_FLOWTRG |  DCMD_ENDIRQEN | 
DCMD_WIDTH1 | DCMD_BURST32 | si->dma_tx_buff_len;
-   DCSR(si->txdma) |= DCSR_RUN;
+   struct dma_async_tx_descriptor *tx;
+
+   tx = dmaengine_prep_slave_single(si->txdma, si->dma_tx_buff_phy,
+si->dma_tx_buff_len, DMA_TO_DEVICE,
+DMA_PREP_INTERRUPT);
+   if (!tx) {
+   dev_err(si->dev, "prep_slave_sg() failed\n");
+   return;
+   }
+   tx->callback = pxa_irda_fir_dma_tx_irq;
+   tx->callback_param = si;
+   si->tx_cookie = dmaengine_submit(tx);
+   dma_async_issue_pending(si->rxdma);
 }
 
 /*
@@ -242,7 +269,7 @@ static int pxa_irda_set_speed(struct pxa_irda *si, int 
speed)
 
if (IS_FIR(si)) {
/* stop RX DMA */
-   DCSR(si->rxdma) &= ~DCSR_RUN;
+   dmaengine_terminate_all(si->rxdma);
/* disable FICP */
ficp_writel(si, 0, ICCR0);
pxa_irda_disable_clk(si);
@@ -388,30 +415,27 @@ static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id)
 }
 
 /* FIR Receive DMA interrupt handler */
-static void pxa_irda_fir_dma_rx_irq(int channel, void *data)
+static void pxa_irda_fir_dma_rx_irq(void *data)
 {
-   int dcsr = DCSR(channel);
-
-   DCSR(channel) = dcsr & ~DCSR_RUN;
+   struct net_device *dev = data;
+   struct pxa_irda *si = netdev_priv(dev);
 
-   printk(KERN_DEBUG "pxa_ir: fir rx dma bus error %#x\n", dcsr);
+   dmaengine_terminate_all(si->rxdma);
+   netdev_dbg(dev, "pxa_ir: fir rx dm

[PATCH v3 2/3] net: irda: pxaficp_ir: convert to readl and writel

2015-09-26 Thread Robert Jarzmik
Convert the pxa IRDA driver to readl and writel primitives, and remove
another set of direct registers access. This leaves only the DMA
registers access, which will be dealt with dmaengine conversion.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Tested-by: Petr Cvek <petr.c...@tul.cz>
---
Since v1: modified __REG macro to cope with STIER, ST* registers
---
 drivers/net/irda/pxaficp_ir.c | 210 +-
 1 file changed, 126 insertions(+), 84 deletions(-)

diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index 6a81d3d1b312..05a668216a0f 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -29,15 +29,16 @@
 
 #include 
 #include 
+#undef __REG
+#define __REG(x) ((x) & 0x)
 #include 
 
-#define FICP   __REG(0x4080)  /* Start of FICP area */
-#define ICCR0  __REG(0x4080)  /* ICP Control Register 0 */
-#define ICCR1  __REG(0x4084)  /* ICP Control Register 1 */
-#define ICCR2  __REG(0x4088)  /* ICP Control Register 2 */
-#define ICDR   __REG(0x408c)  /* ICP Data Register */
-#define ICSR0  __REG(0x40800014)  /* ICP Status Register 0 */
-#define ICSR1  __REG(0x40800018)  /* ICP Status Register 1 */
+#define ICCR0  0x  /* ICP Control Register 0 */
+#define ICCR1  0x0004  /* ICP Control Register 1 */
+#define ICCR2  0x0008  /* ICP Control Register 2 */
+#define ICDR   0x000c  /* ICP Data Register */
+#define ICSR0  0x0014  /* ICP Status Register 0 */
+#define ICSR1  0x0018  /* ICP Status Register 1 */
 
 #define ICCR0_AME  (1 << 7)/* Address match enable */
 #define ICCR0_TIE  (1 << 6)/* Transmit FIFO interrupt enable */
@@ -55,9 +56,7 @@
 #define ICCR2_TRIG_16   (1 << 0)   /*  >= 16 bytes */
 #define ICCR2_TRIG_32   (2 << 0)   /*  >= 32 bytes */
 
-#ifdef CONFIG_PXA27x
 #define ICSR0_EOC  (1 << 6)/* DMA End of Descriptor Chain */
-#endif
 #define ICSR0_FRE  (1 << 5)/* Framing error */
 #define ICSR0_RFS  (1 << 4)/* Receive FIFO service request */
 #define ICSR0_TFS  (1 << 3)/* Transnit FIFO service request */
@@ -98,11 +97,50 @@
 IrSR_RCVEIR_UART_MODE | \
 IrSR_XMITIR_IR_MODE)
 
+/* macros for registers read/write */
+#define ficp_writel(irda, val, off)\
+   do {\
+   dev_vdbg(irda->dev, \
+"%s():%d ficp_writel(0x%x, %s)\n", \
+__func__, __LINE__, (val), #off);  \
+   writel_relaxed((val), (irda)->irda_base + (off));   \
+   } while (0)
+
+#define ficp_readl(irda, off)  \
+   ({  \
+   unsigned int _v;\
+   _v = readl_relaxed((irda)->irda_base + (off));  \
+   dev_vdbg(irda->dev, \
+"%s():%d ficp_readl(%s): 0x%x\n",  \
+__func__, __LINE__, #off, _v); \
+   _v; \
+   })
+
+#define stuart_writel(irda, val, off)  \
+   do {\
+   dev_vdbg(irda->dev, \
+"%s():%d stuart_writel(0x%x, %s)\n",   \
+__func__, __LINE__, (val), #off);  \
+   writel_relaxed((val), (irda)->stuart_base + (off)); \
+   } while (0)
+
+#define stuart_readl(irda, off)
\
+   ({  \
+   unsigned int _v;\
+   _v = readl_relaxed((irda)->stuart_base + (off));\
+   dev_vdbg(irda->dev, \
+"%s():%d stuart_readl(%s): 0x%x\n",\
+__func__, __LINE__, #off, _v); \
+   _v; \
+   })
+
 struct pxa_irda {
int speed;
int newspeed;
unsigned long long  last_clk;
 
+   void __iomem*stuart_base;
+   void __iomem*irda_base;
unsigned char   *

[PATCH v3 1/3] net: irda: pxaficp_ir: use sched_clock() for time management

2015-09-26 Thread Robert Jarzmik
Instead of using directly the OS timer through direct register access,
use the standard sched_clock(), which will end up in OSCR reading
anyway.

This is a first step for direct access register removal and machine
specific code removal from this driver.

This commit changes the behavior, as previously the minimum turnaround
time was counted in 76ns steps, while with this patch it is counted in
microsecond steps. The strictly equal formula would have been :
while ((sched_clock() - si->last_clk) * 76 < mtt)

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
Since v2: fixed clock calculation as pointed out by David
---
 drivers/net/irda/pxaficp_ir.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index 100454662e4b..6a81d3d1b312 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -29,7 +29,6 @@
 
 #include 
 #include 
-#include 
 #include 
 
 #define FICP   __REG(0x4080)  /* Start of FICP area */
@@ -102,7 +101,7 @@
 struct pxa_irda {
int speed;
int newspeed;
-   unsigned long   last_oscr;
+   unsigned long long  last_clk;
 
unsigned char   *dma_rx_buff;
unsigned char   *dma_tx_buff;
@@ -292,7 +291,7 @@ static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id)
}
lsr = STLSR;
}
-   si->last_oscr = readl_relaxed(OSCR);
+   si->last_clk = sched_clock();
break;
 
case 0x04: /* Received Data Available */
@@ -303,7 +302,7 @@ static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id)
dev->stats.rx_bytes++;
async_unwrap_char(dev, >stats, >rx_buff, STRBR);
} while (STLSR & LSR_DR);
-   si->last_oscr = readl_relaxed(OSCR);
+   si->last_clk = sched_clock();
break;
 
case 0x02: /* Transmit FIFO Data Request */
@@ -319,7 +318,7 @@ static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id)
 /* We need to ensure that the transmitter has 
finished. */
while ((STLSR & LSR_TEMT) == 0)
cpu_relax();
-   si->last_oscr = readl_relaxed(OSCR);
+   si->last_clk = sched_clock();
 
/*
* Ok, we've finished transmitting.  Now enable
@@ -373,7 +372,7 @@ static void pxa_irda_fir_dma_tx_irq(int channel, void *data)
 
while (ICSR1 & ICSR1_TBY)
cpu_relax();
-   si->last_oscr = readl_relaxed(OSCR);
+   si->last_clk = sched_clock();
 
/*
 * HACK: It looks like the TBY bit is dropped too soon.
@@ -473,8 +472,8 @@ static irqreturn_t pxa_irda_fir_irq(int irq, void *dev_id)
 
/* stop RX DMA */
DCSR(si->rxdma) &= ~DCSR_RUN;
-   si->last_oscr = readl_relaxed(OSCR);
icsr0 = ICSR0;
+   si->last_clk = sched_clock();
 
if (icsr0 & (ICSR0_FRE | ICSR0_RAB)) {
if (icsr0 & ICSR0_FRE) {
@@ -549,7 +548,7 @@ static int pxa_irda_hard_xmit(struct sk_buff *skb, struct 
net_device *dev)
skb_copy_from_linear_data(skb, si->dma_tx_buff, skb->len);
 
if (mtt)
-   while ((unsigned)(readl_relaxed(OSCR) - 
si->last_oscr)/4 < mtt)
+   while ((sched_clock() - si->last_clk) * 1000 < mtt)
cpu_relax();
 
/* stop RX DMA,  disable FICP */
-- 
2.1.4

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


Re: [PATCH v2 1/3] net: irda: pxaficp_ir: use sched_clock() for time management

2015-09-22 Thread Robert Jarzmik
David Miller <da...@davemloft.net> writes:

> From: Robert Jarzmik <robert.jarz...@free.fr>
> Date: Fri, 18 Sep 2015 18:36:56 +0200
>
>> Which brings me to wonder which is the more correct :
>>  (a) replace to reproduce the same calculation
>>  Previously mtt was compared to a difference of 76ns steps (as 307ns / 4 
>> =
>>  76ns):
>>  while ((sched_clock() - si->last_clk) * 76 < mtt)
>> 
>>  (b) change the calculation assuming mtt is in microseconds :
>>  while ((sched_clock() - si->last_clk) * 1000 < mtt)
>> 
>> I have no IRDA protocol knowledge so unless someone points me to the correct
>> calculation I'll try my luck with (b).
>
> "a" would be "safer" and less likely to break anything, although as
> you say "b" might be more correct.
Indeed.

Well, let me try (b) then. I'll add in the commit message the timings change,
and if anybody complains a regression pops out, I'll provide a patch to fallback
to (a).

Cheers.

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


Re: [PATCH v2 1/3] net: irda: pxaficp_ir: use sched_clock() for time management

2015-09-18 Thread Robert Jarzmik
David Miller  writes:

>> My understanding is that the flow will be :
>>  sched_clock()
>>rd->read_sched_clock() (cyc_to_ns() transformed for return)
>>  pxa_read_sched_clock()
>>readl_relaxed(OSCR)
>> 
>> I didn't see any timings issue, as the flow looks equivalent to the 
>> readl(OSCR),
>> but I might have overlooked something.
>
> Of course it's different, because sched_clock() converts the value read
> from OSCR into nanoseconds, which is obviously different from using the
> OSCR register value directly.
>
> You're therefore feeding different values into this IRDA code.
Ah yes, I see it.
Which brings me to wonder which is the more correct :
 (a) replace to reproduce the same calculation
 Previously mtt was compared to a difference of 76ns steps (as 307ns / 4 =
 76ns):
 while ((sched_clock() - si->last_clk) * 76 < mtt)

 (b) change the calculation assuming mtt is in microseconds :
 while ((sched_clock() - si->last_clk) * 1000 < mtt)

I have no IRDA protocol knowledge so unless someone points me to the correct
calculation I'll try my luck with (b).

Cheers.

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


Re: [PATCH] net: smc91x: convert pxa dma to dmaengine

2015-09-16 Thread Robert Jarzmik
David Miller <da...@davemloft.net> writes:

> From: Robert Jarzmik <robert.jarz...@free.fr>
> Date: Thu, 10 Sep 2015 21:26:04 +0200
>
>> Convert the dma transfers to be dmaengine based, now pxa has a dmaengine
>> slave driver. This makes this driver a bit more PXA agnostic.
>> 
>> The driver was tested on pxa27x (mainstone) and pxa310 (zylonite),
>> ie. only pxa platforms.
>> 
>> Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
>> Cc: Russell King <li...@arm.linux.org.uk>
>> Cc: Arnd Bergmann <a...@arndb.de>
>> ---
>> This has potential to break other platform such as Neponset, Idp,
>> halibut and qsd8x50, so I added Russell and Arnd as they were discussing
>> smc91x support last February.
>

> Is someone testing whether such platforms break or not?  I'm waiting for
> that before I consider applying this patch.

My understanding is that Russell is the only one left testing them, or at least
he was the only one complaining about a breakage lately on neponset.

I can wait several weeks for Russell to have a bit of time to try : I know it
will compile correctly at least for neponset, and I know almost all the code is
under #ifdef CONFIG_ARCH_PXA. And still I would feel far more comfortable if it
was tested, just as you.

Cheers.

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


Re: [PATCH v2 1/3] net: irda: pxaficp_ir: use sched_clock() for time management

2015-09-16 Thread Robert Jarzmik
David Miller <da...@davemloft.net> writes:

> From: Robert Jarzmik <robert.jarz...@free.fr>
> Date: Sat, 12 Sep 2015 13:45:22 +0200
>
>> Instead of using directly the OS timer through direct register access,
>> use the standard sched_clock(), which will end up in OSCR reading
>> anyway.
>> 
>> This is a first step for direct access register removal and machine
>> specific code removal from this driver.
>> 
>> Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
>
> What is the granularity of the OSCR register?
It's 307ns (ie. 3.25MHz clock).

> If it is not nanoseconds, then you need to adjust calculations
> such as this one:
Tell me if the 307ns requires something I should adjust.

My understanding is that the flow will be :
 sched_clock()
   rd->read_sched_clock() (cyc_to_ns() transformed for return)
 pxa_read_sched_clock()
   readl_relaxed(OSCR)

I didn't see any timings issue, as the flow looks equivalent to the readl(OSCR),
but I might have overlooked something.

Cheers.

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


Re: [PATCH 2/3] net: irda: pxaficp_ir: convert to readl and writel

2015-09-12 Thread Robert Jarzmik
Petr Cvek  writes:

 And it is true I have not tested the rootfs special case, where drivers 
 are not
 yet initialized (and more specifically gpio and interrupt chip). Your 
 backtrace
 should tell me if you fall into this category of issues ... but I digress, 
 this
 has no link with pxaficp.
>>>
>>> Should I start new thread? (same bug can be present in the FICP too)
>> Yes, this pxamci bothers me, it deserves a thread.
>
> Will start soon.
And I think I see your problem now :
  (a) there is a regression from the commit 8c8fe97b2b8a, for which the fix is
  here: https://lkml.org/lkml/2015/9/6/112
  (b) for gpio expanders, another fix is here :
  https://lkml.org/lkml/2015/9/12/62

The regression is on dmaengine, that's where the thread belongs I think, at
least if that fixes your issue.

>>> but STIER is not just an offset, but full register address:
>>> 
>>> __REG(0x4074)
>>>
>>> So the definition should be changed, unless there is another patch I did not
>>> received (in that case, send me full patchset again please) :-).
>> Agreed, this is a bug in this patch. With this fix, is the pxaficp working 
>> or do
>> you need a bit more time to experiment ?
>
> I have tried with a nasty hack (use only lower part of address, it should 
> equal with reg offset):
>   #undef __REG
>   -#define __REG(x) (x)
>   +#define __REG(x) (x & 0x)
>
> and it seems to work. The module inits and I am able to see IrDA traffic and
> ping other machine. FIR mode (mostly impacted by DMA) is still untested as
> magician unfortunately supports only SIR mode.
Okay, I'll add a fix in the next iteration, thanks for finding this.

Cheers.

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


[PATCH v2 3/3] net: irda: pxaficp_ir: dmaengine conversion

2015-09-12 Thread Robert Jarzmik
Convert pxaficp_ir to dmaengine. As pxa architecture is shifting from
raw DMA registers access to pxa_dma dmaengine driver, convert this
driver to dmaengine.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
Since v1: removed mach/dma.h include, which is the goal
---
 drivers/net/irda/pxaficp_ir.c | 149 +-
 1 file changed, 102 insertions(+), 47 deletions(-)

diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index 4a2b3f71e4a8..c0b80548a43d 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -19,6 +19,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 
@@ -27,7 +30,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #undef __REG
 #define __REG(x) ((x) & 0x)
@@ -146,8 +148,12 @@ struct pxa_irda {
dma_addr_t  dma_rx_buff_phy;
dma_addr_t  dma_tx_buff_phy;
unsigned intdma_tx_buff_len;
-   int txdma;
-   int rxdma;
+   struct dma_chan *txdma;
+   struct dma_chan *rxdma;
+   dma_cookie_trx_cookie;
+   dma_cookie_ttx_cookie;
+   int drcmr_rx;
+   int drcmr_tx;
 
int uart_irq;
int icp_irq;
@@ -165,6 +171,8 @@ struct pxa_irda {
struct clk  *cur_clk;
 };
 
+static int pxa_irda_set_speed(struct pxa_irda *si, int speed);
+
 static inline void pxa_irda_disable_clk(struct pxa_irda *si)
 {
if (si->cur_clk)
@@ -188,22 +196,41 @@ static inline void pxa_irda_enable_sirclk(struct pxa_irda 
*si)
 #define IS_FIR(si) ((si)->speed >= 400)
 #define IRDA_FRAME_SIZE_LIMIT  2047
 
+static void pxa_irda_fir_dma_rx_irq(void *data);
+static void pxa_irda_fir_dma_tx_irq(void *data);
+
 inline static void pxa_irda_fir_dma_rx_start(struct pxa_irda *si)
 {
-   DCSR(si->rxdma)  = DCSR_NODESC;
-   DSADR(si->rxdma) = (unsigned long)si->irda_base + ICDR;
-   DTADR(si->rxdma) = si->dma_rx_buff_phy;
-   DCMD(si->rxdma) = DCMD_INCTRGADDR | DCMD_FLOWSRC |  DCMD_WIDTH1 | 
DCMD_BURST32 | IRDA_FRAME_SIZE_LIMIT;
-   DCSR(si->rxdma) |= DCSR_RUN;
+   struct dma_async_tx_descriptor *tx;
+
+   tx = dmaengine_prep_slave_single(si->rxdma, si->dma_rx_buff_phy,
+IRDA_FRAME_SIZE_LIMIT, DMA_FROM_DEVICE,
+DMA_PREP_INTERRUPT);
+   if (!tx) {
+   dev_err(si->dev, "prep_slave_sg() failed\n");
+   return;
+   }
+   tx->callback = pxa_irda_fir_dma_rx_irq;
+   tx->callback_param = si;
+   si->rx_cookie = dmaengine_submit(tx);
+   dma_async_issue_pending(si->rxdma);
 }
 
 inline static void pxa_irda_fir_dma_tx_start(struct pxa_irda *si)
 {
-   DCSR(si->txdma)  = DCSR_NODESC;
-   DSADR(si->txdma) = si->dma_tx_buff_phy;
-   DTADR(si->txdma) = (unsigned long)si->irda_base + ICDR;
-   DCMD(si->txdma) = DCMD_INCSRCADDR | DCMD_FLOWTRG |  DCMD_ENDIRQEN | 
DCMD_WIDTH1 | DCMD_BURST32 | si->dma_tx_buff_len;
-   DCSR(si->txdma) |= DCSR_RUN;
+   struct dma_async_tx_descriptor *tx;
+
+   tx = dmaengine_prep_slave_single(si->txdma, si->dma_tx_buff_phy,
+si->dma_tx_buff_len, DMA_TO_DEVICE,
+DMA_PREP_INTERRUPT);
+   if (!tx) {
+   dev_err(si->dev, "prep_slave_sg() failed\n");
+   return;
+   }
+   tx->callback = pxa_irda_fir_dma_tx_irq;
+   tx->callback_param = si;
+   si->tx_cookie = dmaengine_submit(tx);
+   dma_async_issue_pending(si->rxdma);
 }
 
 /*
@@ -242,7 +269,7 @@ static int pxa_irda_set_speed(struct pxa_irda *si, int 
speed)
 
if (IS_FIR(si)) {
/* stop RX DMA */
-   DCSR(si->rxdma) &= ~DCSR_RUN;
+   dmaengine_terminate_all(si->rxdma);
/* disable FICP */
ficp_writel(si, 0, ICCR0);
pxa_irda_disable_clk(si);
@@ -388,30 +415,27 @@ static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id)
 }
 
 /* FIR Receive DMA interrupt handler */
-static void pxa_irda_fir_dma_rx_irq(int channel, void *data)
+static void pxa_irda_fir_dma_rx_irq(void *data)
 {
-   int dcsr = DCSR(channel);
-
-   DCSR(channel) = dcsr & ~DCSR_RUN;
+   struct net_device *dev = data;
+   struct pxa_irda *si = netdev_priv(dev);
 
-   printk(KERN_DEBUG "pxa_ir: fir rx dma bus error %#x\n", dcsr);
+   dmaengine_terminate_all(si->rxdma);
+   netdev_dbg(dev, "pxa_ir: fir rx dma bus error\n");
 }
 
 /* FIR Transmit DMA

[PATCH v2 2/3] net: irda: pxaficp_ir: convert to readl and writel

2015-09-12 Thread Robert Jarzmik
Convert the pxa IRDA driver to readl and writel primitives, and remove
another set of direct registers access. This leaves only the DMA
registers access, which will be dealt with dmaengine conversion.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
Since v1: modified __REG macro to cope with STIER, ST* registers
---
 drivers/net/irda/pxaficp_ir.c | 210 +-
 1 file changed, 126 insertions(+), 84 deletions(-)

diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index b1794998c68e..4a2b3f71e4a8 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -29,15 +29,16 @@
 
 #include 
 #include 
+#undef __REG
+#define __REG(x) ((x) & 0x)
 #include 
 
-#define FICP   __REG(0x4080)  /* Start of FICP area */
-#define ICCR0  __REG(0x4080)  /* ICP Control Register 0 */
-#define ICCR1  __REG(0x4084)  /* ICP Control Register 1 */
-#define ICCR2  __REG(0x4088)  /* ICP Control Register 2 */
-#define ICDR   __REG(0x408c)  /* ICP Data Register */
-#define ICSR0  __REG(0x40800014)  /* ICP Status Register 0 */
-#define ICSR1  __REG(0x40800018)  /* ICP Status Register 1 */
+#define ICCR0  0x  /* ICP Control Register 0 */
+#define ICCR1  0x0004  /* ICP Control Register 1 */
+#define ICCR2  0x0008  /* ICP Control Register 2 */
+#define ICDR   0x000c  /* ICP Data Register */
+#define ICSR0  0x0014  /* ICP Status Register 0 */
+#define ICSR1  0x0018  /* ICP Status Register 1 */
 
 #define ICCR0_AME  (1 << 7)/* Address match enable */
 #define ICCR0_TIE  (1 << 6)/* Transmit FIFO interrupt enable */
@@ -55,9 +56,7 @@
 #define ICCR2_TRIG_16   (1 << 0)   /*  >= 16 bytes */
 #define ICCR2_TRIG_32   (2 << 0)   /*  >= 32 bytes */
 
-#ifdef CONFIG_PXA27x
 #define ICSR0_EOC  (1 << 6)/* DMA End of Descriptor Chain */
-#endif
 #define ICSR0_FRE  (1 << 5)/* Framing error */
 #define ICSR0_RFS  (1 << 4)/* Receive FIFO service request */
 #define ICSR0_TFS  (1 << 3)/* Transnit FIFO service request */
@@ -98,11 +97,50 @@
 IrSR_RCVEIR_UART_MODE | \
 IrSR_XMITIR_IR_MODE)
 
+/* macros for registers read/write */
+#define ficp_writel(irda, val, off)\
+   do {\
+   dev_vdbg(irda->dev, \
+"%s():%d ficp_writel(0x%x, %s)\n", \
+__func__, __LINE__, (val), #off);  \
+   writel_relaxed((val), (irda)->irda_base + (off));   \
+   } while (0)
+
+#define ficp_readl(irda, off)  \
+   ({  \
+   unsigned int _v;\
+   _v = readl_relaxed((irda)->irda_base + (off));  \
+   dev_vdbg(irda->dev, \
+"%s():%d ficp_readl(%s): 0x%x\n",  \
+__func__, __LINE__, #off, _v); \
+   _v; \
+   })
+
+#define stuart_writel(irda, val, off)  \
+   do {\
+   dev_vdbg(irda->dev, \
+"%s():%d stuart_writel(0x%x, %s)\n",   \
+__func__, __LINE__, (val), #off);  \
+   writel_relaxed((val), (irda)->stuart_base + (off)); \
+   } while (0)
+
+#define stuart_readl(irda, off)
\
+   ({  \
+   unsigned int _v;\
+   _v = readl_relaxed((irda)->stuart_base + (off));\
+   dev_vdbg(irda->dev, \
+"%s():%d stuart_readl(%s): 0x%x\n",\
+__func__, __LINE__, #off, _v); \
+   _v; \
+   })
+
 struct pxa_irda {
int speed;
int newspeed;
unsigned long long  last_clk;
 
+   void __iomem*stuart_base;
+   void __iomem*irda_base;
unsigned char   *dma_rx_buff;
unsigned char   *dm

[PATCH v2 1/3] net: irda: pxaficp_ir: use sched_clock() for time management

2015-09-12 Thread Robert Jarzmik
Instead of using directly the OS timer through direct register access,
use the standard sched_clock(), which will end up in OSCR reading
anyway.

This is a first step for direct access register removal and machine
specific code removal from this driver.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 drivers/net/irda/pxaficp_ir.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index 100454662e4b..b1794998c68e 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -29,7 +29,6 @@
 
 #include 
 #include 
-#include 
 #include 
 
 #define FICP   __REG(0x4080)  /* Start of FICP area */
@@ -102,7 +101,7 @@
 struct pxa_irda {
int speed;
int newspeed;
-   unsigned long   last_oscr;
+   unsigned long long  last_clk;
 
unsigned char   *dma_rx_buff;
unsigned char   *dma_tx_buff;
@@ -292,7 +291,7 @@ static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id)
}
lsr = STLSR;
}
-   si->last_oscr = readl_relaxed(OSCR);
+   si->last_clk = sched_clock();
break;
 
case 0x04: /* Received Data Available */
@@ -303,7 +302,7 @@ static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id)
dev->stats.rx_bytes++;
async_unwrap_char(dev, >stats, >rx_buff, STRBR);
} while (STLSR & LSR_DR);
-   si->last_oscr = readl_relaxed(OSCR);
+   si->last_clk = sched_clock();
break;
 
case 0x02: /* Transmit FIFO Data Request */
@@ -319,7 +318,7 @@ static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id)
 /* We need to ensure that the transmitter has 
finished. */
while ((STLSR & LSR_TEMT) == 0)
cpu_relax();
-   si->last_oscr = readl_relaxed(OSCR);
+   si->last_clk = sched_clock();
 
/*
* Ok, we've finished transmitting.  Now enable
@@ -373,7 +372,7 @@ static void pxa_irda_fir_dma_tx_irq(int channel, void *data)
 
while (ICSR1 & ICSR1_TBY)
cpu_relax();
-   si->last_oscr = readl_relaxed(OSCR);
+   si->last_clk = sched_clock();
 
/*
 * HACK: It looks like the TBY bit is dropped too soon.
@@ -473,8 +472,8 @@ static irqreturn_t pxa_irda_fir_irq(int irq, void *dev_id)
 
/* stop RX DMA */
DCSR(si->rxdma) &= ~DCSR_RUN;
-   si->last_oscr = readl_relaxed(OSCR);
icsr0 = ICSR0;
+   si->last_clk = sched_clock();
 
if (icsr0 & (ICSR0_FRE | ICSR0_RAB)) {
if (icsr0 & ICSR0_FRE) {
@@ -549,7 +548,7 @@ static int pxa_irda_hard_xmit(struct sk_buff *skb, struct 
net_device *dev)
skb_copy_from_linear_data(skb, si->dma_tx_buff, skb->len);
 
if (mtt)
-   while ((unsigned)(readl_relaxed(OSCR) - 
si->last_oscr)/4 < mtt)
+   while ((sched_clock() - si->last_clk) / 4 < mtt)
cpu_relax();
 
/* stop RX DMA,  disable FICP */
-- 
2.1.4

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


Re: [PATCH 2/3] net: irda: pxaficp_ir: convert to readl and writel

2015-09-11 Thread Robert Jarzmik
Petr Cvek  writes:

>> Should have been posted to linux arm kernel mailing list, unless my mailer
>> failed ...
>> 
> Searching for:
>
>   "ARM: pxa: add resources to pxaficp_ir"
>
> did not found anything, same was for "ficp" in the 
> linux-arm-kernel/netdev/linux-kernel
> mailing list archive.
Ah ok, I'll resend it then.

>>> BTW This patch required update of my kernel repo. It seems that my:
>>>
>>> magician.c patches + ficp patch + new dma engine
>>>
>>> does not work for me at all. Kernel throws some panic about interrupts and 
>>> then
>>> it ends in an infinite stack dumping loop. Fault occurs before rootfs is
>>> mounted, so probably around MMC init (with removed SD card it fails normally
>>> with no rootfs found error).
>> Could you send me (privately) the stack you're getting please. This is 
>> something
>> I'd like to catch up early in the -rc releases.
>
> Well this will be problem as I cannot save anything to an SD card after and
> during the failure.  Only viable interfaces would be earlycon on an infraport
> or high speed camera on LCD :-).
Ah just as on my mioa701. I ended up soldering a JTAG cable :)

> But I was able to revert this commit:
>
>   6464b71409511939efce1ae4fb4ec6e3483b11b2mmc: pxamci: switch 
> over to dmaengine use
>
> and after that I am able to boot.
Okay. I'll try to reproduce this failure then. If I fail, well, before using the
JTAG cable, I used another trick: I was taking a movie from the LCD with a
smartphone, and it worked. It was an horrible thing to decrypt ... Let's hope
I'll be lucky on one of my platforms.

>> Now with your stack, could you also give me the upstream commit id of the 
>> tip of
>> the tree you're using (before your patches) please ?
>
> It is probably irelevant now, but for complete information:
>
> Discovered on my working repo: mainline 
> b8889c4fc6ba03e289cec6a4d692f6f080a55e53
> Still present on fresh downloaded: linux-next
> 22dc312d56ba077db27a9798b340e7d161f1df05
Ok, thanks.

>> And it is true I have not tested the rootfs special case, where drivers are 
>> not
>> yet initialized (and more specifically gpio and interrupt chip). Your 
>> backtrace
>> should tell me if you fall into this category of issues ... but I digress, 
>> this
>> has no link with pxaficp.
>
> Should I start new thread? (same bug can be present in the FICP too)
Yes, this pxamci bothers me, it deserves a thread.

> I will try to configure an initrd rootfs this should create more ways to save
> kernel log.
Great idea.

>
> Anyway after mmc dma revert I was still not able to start FICP. There is an 
> error:
>
>   Unable to handle kernel paging request at virtual address 32e4
>
> from pxa_irda_startup() and it seems it is caused by register definitions. 
> For example:
>
>   writel_relaxed((val), (irda)->stuart_base + (off));
>
> is called by
>
>   stuart_writel(si, 0, STIER);
>
> but STIER is not just an offset, but full register address:
>   
>   __REG(0x4074)
>
> So the definition should be changed, unless there is another patch I did not
> received (in that case, send me full patchset again please) :-).
Agreed, this is a bug in this patch. With this fix, is the pxaficp working or do
you need a bit more time to experiment ?

Cheers.

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


Re: [PATCH 2/3] net: irda: pxaficp_ir: convert to readl and writel

2015-09-10 Thread Robert Jarzmik
Petr Cvek <petr.c...@tul.cz> writes:

> Dne 9.9.2015 v 08:25 Robert Jarzmik napsal(a):
>> Petr Cvek <petr.c...@tul.cz> writes:
>> 
>>> Dne 8.9.2015 v 22:24 Petr Cvek napsal(a):
>>>>
>>>> Did you defined resources somewhere? Actual resources are in
>>>> "pxa_ir_resources" variable at:
>> I have them in patch [1], which is exactly the patch you have made yourself.
>
> Is there a mailing list for this specific patch? It seems I did not get any
> mail with it.
Should have been posted to linux arm kernel mailing list, unless my mailer
failed ...

> BTW This patch required update of my kernel repo. It seems that my:
>
>   magician.c patches + ficp patch + new dma engine
>
> does not work for me at all. Kernel throws some panic about interrupts and 
> then
> it ends in an infinite stack dumping loop. Fault occurs before rootfs is
> mounted, so probably around MMC init (with removed SD card it fails normally
> with no rootfs found error).
Could you send me (privately) the stack you're getting please. This is something
I'd like to catch up early in the -rc releases.

> Is it required to change something in the mach-pxa machine specific files?
Nope. As long as CONFIG_PXA_DMA is set, it's alright. Building on top of
linux-next of the future v4.3-rc1 would be better, as the dmaengine support
should be consistent across drivers/dma and arch/arm/mach-pxa in there.

> Which hardware was used for testing new dma engine implementation? Notably MMC
> driver part, probably commit:
Mioa701 (pxa270), cm-x300 (pxa310), zylonite (pxa310). The MMC was specificaly
tested on mioa701, on top of linux-next a week ago (about the day v4.2 was 
released).

Now with your stack, could you also give me the upstream commit id of the tip of
the tree you're using (before your patches) please ?

And it is true I have not tested the rootfs special case, where drivers are not
yet initialized (and more specifically gpio and interrupt chip). Your backtrace
should tell me if you fall into this category of issues ... but I digress, this
has no link with pxaficp.

Cheers.

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


[PATCH] net: smc91x: convert pxa dma to dmaengine

2015-09-10 Thread Robert Jarzmik
Convert the dma transfers to be dmaengine based, now pxa has a dmaengine
slave driver. This makes this driver a bit more PXA agnostic.

The driver was tested on pxa27x (mainstone) and pxa310 (zylonite),
ie. only pxa platforms.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
Cc: Russell King <li...@arm.linux.org.uk>
Cc: Arnd Bergmann <a...@arndb.de>
---
This has potential to break other platform such as Neponset, Idp,
halibut and qsd8x50, so I added Russell and Arnd as they were discussing
smc91x support last February.
---
 drivers/net/ethernet/smsc/smc91x.c | 29 +++
 drivers/net/ethernet/smsc/smc91x.h | 99 +-
 2 files changed, 84 insertions(+), 44 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc91x.c 
b/drivers/net/ethernet/smsc/smc91x.c
index 630f0b7800e4..0e2fc1a844ab 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2018,10 +2018,18 @@ static int smc_probe(struct net_device *dev, void 
__iomem *ioaddr,
lp->cfg.flags |= SMC91X_USE_DMA;
 #  endif
if (lp->cfg.flags & SMC91X_USE_DMA) {
-   int dma = pxa_request_dma(dev->name, DMA_PRIO_LOW,
- smc_pxa_dma_irq, NULL);
-   if (dma >= 0)
-   dev->dma = dma;
+   dma_cap_mask_t mask;
+   struct pxad_param param;
+
+   dma_cap_zero(mask);
+   dma_cap_set(DMA_SLAVE, mask);
+   param.prio = PXAD_PRIO_LOWEST;
+   param.drcmr = -1UL;
+
+   lp->dma_chan =
+   dma_request_slave_channel_compat(mask, pxad_filter_fn,
+, >dev,
+"data");
}
 #endif
 
@@ -2032,8 +2040,8 @@ static int smc_probe(struct net_device *dev, void __iomem 
*ioaddr,
version_string, revision_register & 0x0f,
lp->base, dev->irq);
 
-   if (dev->dma != (unsigned char)-1)
-   pr_cont(" DMA %d", dev->dma);
+   if (lp->dma_chan)
+   pr_cont(" DMA %p", lp->dma_chan);
 
pr_cont("%s%s\n",
lp->cfg.flags & SMC91X_NOWAIT ? " [nowait]" : "",
@@ -2058,8 +2066,8 @@ static int smc_probe(struct net_device *dev, void __iomem 
*ioaddr,
 
 err_out:
 #ifdef CONFIG_ARCH_PXA
-   if (retval && dev->dma != (unsigned char)-1)
-   pxa_free_dma(dev->dma);
+   if (retval && lp->dma_chan)
+   dma_release_channel(lp->dma_chan);
 #endif
return retval;
 }
@@ -2370,6 +2378,7 @@ static int smc_drv_probe(struct platform_device *pdev)
struct smc_local *lp = netdev_priv(ndev);
lp->device = >dev;
lp->physaddr = res->start;
+
}
 #endif
 
@@ -2406,8 +2415,8 @@ static int smc_drv_remove(struct platform_device *pdev)
free_irq(ndev->irq, ndev);
 
 #ifdef CONFIG_ARCH_PXA
-   if (ndev->dma != (unsigned char)-1)
-   pxa_free_dma(ndev->dma);
+   if (lp->dma_chan)
+   dma_release_channel(lp->dma_chan);
 #endif
iounmap(lp->base);
 
diff --git a/drivers/net/ethernet/smsc/smc91x.h 
b/drivers/net/ethernet/smsc/smc91x.h
index 3a18501d1068..a3c129e1e40a 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -33,6 +33,7 @@
 #ifndef _SMC91X_H_
 #define _SMC91X_H_
 
+#include 
 #include 
 
 /*
@@ -244,6 +245,7 @@ struct smc_local {
u_long physaddr;
struct device *device;
 #endif
+   struct dma_chan *dma_chan;
void __iomem *base;
void __iomem *datacs;
 
@@ -265,21 +267,47 @@ struct smc_local {
  * as RX which can overrun memory and lose packets.
  */
 #include 
-#include 
+#include 
 
 #ifdef SMC_insl
 #undef SMC_insl
 #define SMC_insl(a, r, p, l) \
smc_pxa_dma_insl(a, lp, r, dev->dma, p, l)
 static inline void
+smc_pxa_dma_inpump(struct smc_local *lp, u_char *buf, int len)
+{
+   dma_addr_t dmabuf;
+   struct dma_async_tx_descriptor *tx;
+   dma_cookie_t cookie;
+   enum dma_status status;
+   struct dma_tx_state state;
+
+   dmabuf = dma_map_single(lp->device, buf, len, DMA_FROM_DEVICE);
+   tx = dmaengine_prep_slave_single(lp->dma_chan, dmabuf, len,
+DMA_DEV_TO_MEM, 0);
+   if (tx) {
+   cookie = dmaengine_submit(tx);
+   dma_async_issue_pending(lp->dma_chan);
+   do {
+   status = dmaengine_tx_status(lp->dma_chan, cookie,
+);
+   cpu_relax();
+   } 

Re: [PATCH 2/3] net: irda: pxaficp_ir: convert to readl and writel

2015-09-09 Thread Robert Jarzmik
Petr Cvek <petr.c...@tul.cz> writes:

> Dne 8.9.2015 v 22:24 Petr Cvek napsal(a):
>> 
>> Did you defined resources somewhere? Actual resources are in
>> "pxa_ir_resources" variable at:
I have them in patch [1], which is exactly the patch you have made yourself.

> I tried to add following patch for new resources, but now it fails with:
>
> [  141.534545] pxa2xx-ir pxa2xx-ir: can't request region for resource [mem 
> 0x4070-0x40700100]
> [  141.534574] pxa2xx-ir pxa2xx-ir: resource stuart not defined
> [  141.534656] pxa2xx-ir: probe of pxa2xx-ir failed with error -16
>
> That's because STUART is allocated by normal UART driver at:
>
>   http://lxr.free-electrons.com/source/arch/arm/mach-pxa/devices.c#L244
>
> So somehow there must be configuration for STUART used with FICP and STUART
> alone (probably can be used for normal UART).
That's because you have to remove from magician.c:
pxa_set_stuart_info(NULL);

Cheers.

--
Robert

[1]
>From ea242c5b1c4dcdf2a99ea604ee542ded5e6384b9 Mon Sep 17 00:00:00 2001
From: Robert Jarzmik <robert.jarz...@free.fr>
Date: Sat, 29 Aug 2015 00:37:51 +0200
Subject: [PATCH] ARM: pxa: add resources to pxaficp_ir

Add io memory and dma requestor lines to the irda pxa device. This is
part of the conversion of pxaficp_ir to dmaengine, and to shrink its
adherence to 'mach' includes.

Signed-off-by: Robert Jarzmik <robert.jarz...@free.fr>
---
 arch/arm/mach-pxa/devices.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index e6ce669b54af..6d5ab8199536 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -395,6 +395,26 @@ static struct resource pxa_ir_resources[] = {
.end= IRQ_ICP,
.flags  = IORESOURCE_IRQ,
},
+   [3] = {
+   .start  = 0x4080,
+   .end= 0x4080001b,
+   .flags  = IORESOURCE_MEM,
+   },
+   [4] = {
+   .start  = 0x4070,
+   .end= 0x40700023,
+   .flags  = IORESOURCE_MEM,
+   },
+   [5] = {
+   .start  = 17,
+   .end= 17,
+   .flags  = IORESOURCE_DMA,
+   },
+   [6] = {
+   .start  = 18,
+   .end= 18,
+   .flags  = IORESOURCE_DMA,
+   },
 };
 
 struct platform_device pxa_device_ficp = {
-- 
2.1.4

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


  1   2   >