* [PATCH v1 1/1] mmc: atmel-mci: allow DMA transfers for AVR32
@ 2015-07-27 11:53 Andy Shevchenko
2015-07-27 12:24 ` Arnd Bergmann
2015-08-12 15:49 ` [PATCH] [wip] repair mci dma transfers for avr32 Ludovic Desroches
0 siblings, 2 replies; 8+ messages in thread
From: Andy Shevchenko @ 2015-07-27 11:53 UTC (permalink / raw)
To: Ludovic Desroches, Ulf Hansson, linux-mmc; +Cc: Andy Shevchenko
The commit ecb89f2f5f3e (mmc: atmel-mci: remove compat for non DT board when
requesting dma chan) removes compat transfer which breaks DMA
support for ATNGW100. This patch returns back that functionality.
Cc: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/mmc/host/atmel-mci.c | 49 +++++++++++++++++++++++++++++++++++++++++---
1 file changed, 46 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 9a39e0b..70865be 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -2277,12 +2277,55 @@ static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
mmc_free_host(slot->mmc);
}
-static int atmci_configure_dma(struct atmel_mci *host)
+static bool atmci_filter(struct dma_chan *chan, void *pdata)
{
+ struct mci_platform_data *sl_pdata = pdata;
+ struct mci_dma_data *sl;
+
+ if (!sl_pdata)
+ return false;
+
+ sl = sl_pdata->dma_slave;
+ if (sl && find_slave_dev(sl) == chan->device->dev) {
+ chan->private = slave_data_ptr(sl);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+static int atmci_dma_request_channel(struct atmel_mci *host)
+{
+ struct mci_platform_data *pdata;
+ dma_cap_mask_t mask;
+
host->dma.chan = dma_request_slave_channel_reason(&host->pdev->dev,
"rxtx");
- if (IS_ERR(host->dma.chan))
- return PTR_ERR(host->dma.chan);
+ if (!IS_ERR(host->dma.chan))
+ return 0;
+
+ if (PTR_ERR(host->dma.chan) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+
+ pdata = host->pdev->dev.platform_data;
+
+ dma_cap_zero(mask);
+ dma_cap_set(DMA_SLAVE, mask);
+
+ host->dma.chan = dma_request_channel(mask, atmci_filter, pdata);
+ if (!host->dma.chan)
+ return -ENODEV;
+
+ return 0;
+}
+
+static int atmci_configure_dma(struct atmel_mci *host)
+{
+ int ret;
+
+ ret = atmci_dma_request_channel(host);
+ if (ret)
+ return ret;
dev_info(&host->pdev->dev, "using %s for DMA transfers\n",
dma_chan_name(host->dma.chan));
--
2.4.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/1] mmc: atmel-mci: allow DMA transfers for AVR32
2015-07-27 11:53 [PATCH v1 1/1] mmc: atmel-mci: allow DMA transfers for AVR32 Andy Shevchenko
@ 2015-07-27 12:24 ` Arnd Bergmann
2015-07-27 14:45 ` Andy Shevchenko
2015-08-12 15:49 ` [PATCH] [wip] repair mci dma transfers for avr32 Ludovic Desroches
1 sibling, 1 reply; 8+ messages in thread
From: Arnd Bergmann @ 2015-07-27 12:24 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Ludovic Desroches, Ulf Hansson, linux-mmc
On Monday 27 July 2015 14:53:30 you wrote:
> The commit ecb89f2f5f3e (mmc: atmel-mci: remove compat for non DT board when
> requesting dma chan) removes compat transfer which breaks DMA
> support for ATNGW100. This patch returns back that functionality.
>
> Cc: Ludovic Desroches <ludovic.desroches@atmel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
How about moving that filter function into arch/avr32 to make the
mmc driver independent of the underlying dma engine implementation
at the same time?
Arnd
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/1] mmc: atmel-mci: allow DMA transfers for AVR32
2015-07-27 12:24 ` Arnd Bergmann
@ 2015-07-27 14:45 ` Andy Shevchenko
2015-08-06 7:01 ` Ludovic Desroches
0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2015-07-27 14:45 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: Ludovic Desroches, Ulf Hansson, linux-mmc
On Mon, 2015-07-27 at 14:24 +0200, Arnd Bergmann wrote:
> On Monday 27 July 2015 14:53:30 you wrote:
> > The commit ecb89f2f5f3e (mmc: atmel-mci: remove compat for non DT
> > board when
> > requesting dma chan) removes compat transfer which breaks DMA
> > support for ATNGW100. This patch returns back that functionality.
> >
> > Cc: Ludovic Desroches <ludovic.desroches@atmel.com>
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> >
>
> How about moving that filter function into arch/avr32 to make the
> mmc driver independent of the underlying dma engine implementation
> at the same time?
It might be a good idea, but I'm neither an expert in avr32 nor have
time right now to do this better. Consider this a bug report with a
work around which works for me. I can test any better solution someone
proposes.
>
> Arnd
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/1] mmc: atmel-mci: allow DMA transfers for AVR32
2015-07-27 14:45 ` Andy Shevchenko
@ 2015-08-06 7:01 ` Ludovic Desroches
2015-08-06 13:16 ` Arnd Bergmann
0 siblings, 1 reply; 8+ messages in thread
From: Ludovic Desroches @ 2015-08-06 7:01 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Arnd Bergmann, Ludovic Desroches, Ulf Hansson, linux-mmc
Hi Andy,
Your patch does a bit more than reverting commit ecb89f2f5f3e. I will
split it in order to see well which previous patches have been reverted.
On Mon, Jul 27, 2015 at 05:45:34PM +0300, Andy Shevchenko wrote:
> On Mon, 2015-07-27 at 14:24 +0200, Arnd Bergmann wrote:
> > On Monday 27 July 2015 14:53:30 you wrote:
> > > The commit ecb89f2f5f3e (mmc: atmel-mci: remove compat for non DT
> > > board when
> > > requesting dma chan) removes compat transfer which breaks DMA
> > > support for ATNGW100. This patch returns back that functionality.
> > >
> > > Cc: Ludovic Desroches <ludovic.desroches@atmel.com>
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > >
> >
> > How about moving that filter function into arch/avr32 to make the
> > mmc driver independent of the underlying dma engine implementation
> > at the same time?
It would be great to not keep code which becomes architecture dependant.
If we can move the filter function somewhere in arch/avr32, we will have
to revert commit fda1b26 and use dma_request_slave_channel_compat.
I had a look to the arch/avr32 directory but I don't know where to put
this kind of stuff.
>
> It might be a good idea, but I'm neither an expert in avr32 nor have
> time right now to do this better. Consider this a bug report with a
> work around which works for me. I can test any better solution someone
> proposes.
Regards
Ludovic
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/1] mmc: atmel-mci: allow DMA transfers for AVR32
2015-08-06 7:01 ` Ludovic Desroches
@ 2015-08-06 13:16 ` Arnd Bergmann
0 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2015-08-06 13:16 UTC (permalink / raw)
To: Ludovic Desroches; +Cc: Andy Shevchenko, Ulf Hansson, linux-mmc
On Thursday 06 August 2015 09:01:56 Ludovic Desroches wrote:
> Hi Andy,
>
> Your patch does a bit more than reverting commit ecb89f2f5f3e. I will
> split it in order to see well which previous patches have been reverted.
>
> On Mon, Jul 27, 2015 at 05:45:34PM +0300, Andy Shevchenko wrote:
> > On Mon, 2015-07-27 at 14:24 +0200, Arnd Bergmann wrote:
> > > On Monday 27 July 2015 14:53:30 you wrote:
> > > > The commit ecb89f2f5f3e (mmc: atmel-mci: remove compat for non DT
> > > > board when
> > > > requesting dma chan) removes compat transfer which breaks DMA
> > > > support for ATNGW100. This patch returns back that functionality.
> > > >
> > > > Cc: Ludovic Desroches <ludovic.desroches@atmel.com>
> > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > > >
> > >
> > > How about moving that filter function into arch/avr32 to make the
> > > mmc driver independent of the underlying dma engine implementation
> > > at the same time?
>
> It would be great to not keep code which becomes architecture dependant.
> If we can move the filter function somewhere in arch/avr32, we will have
> to revert commit fda1b26 and use dma_request_slave_channel_compat.
>
> I had a look to the arch/avr32 directory but I don't know where to put
> this kind of stuff.
Next to the at32_add_device_mci() function, with a pointer to the filter
function added to struct mci_platform_data, and the mci_dma_data
structure replaced with a void pointer after moving the definition
to the same place.
Arnd
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] [wip] repair mci dma transfers for avr32
2015-07-27 11:53 [PATCH v1 1/1] mmc: atmel-mci: allow DMA transfers for AVR32 Andy Shevchenko
2015-07-27 12:24 ` Arnd Bergmann
@ 2015-08-12 15:49 ` Ludovic Desroches
2015-08-12 16:51 ` Andy Shevchenko
2016-01-11 8:54 ` Andy Shevchenko
1 sibling, 2 replies; 8+ messages in thread
From: Ludovic Desroches @ 2015-08-12 15:49 UTC (permalink / raw)
To: linux-mmc
Cc: ulf.hansson, andriy.shevchenko, arnd, hskinnemoen, egtvedt,
nicolas.ferre, alexandre.belloni, Ludovic Desroches
Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
Hi,
Here is a rough draft to fix the regression. I have only compiled it. I will
update all the boards later.
I have removed the mci_dma_data since it is no more used for ARM platforms.
arch/avr32/boards/atngw100/setup.c | 1 +
arch/avr32/mach-at32ap/at32ap700x.c | 31 +++++++++++++++++++++--------
arch/avr32/mach-at32ap/include/mach/board.h | 2 ++
drivers/mmc/host/atmel-mci.c | 16 +++++++++++++--
include/linux/atmel-mci.h | 2 ++
include/linux/platform_data/mmc-atmel-mci.h | 22 --------------------
6 files changed, 42 insertions(+), 32 deletions(-)
delete mode 100644 include/linux/platform_data/mmc-atmel-mci.h
diff --git a/arch/avr32/boards/atngw100/setup.c b/arch/avr32/boards/atngw100/setup.c
index afeae89..8b4f3d1 100644
--- a/arch/avr32/boards/atngw100/setup.c
+++ b/arch/avr32/boards/atngw100/setup.c
@@ -131,6 +131,7 @@ static struct mci_platform_data __initdata mci0_data = {
.wp_pin = GPIO_PIN_PE(0),
#endif
},
+ .dma_filter = &atmci_filter,
};
static struct usba_platform_data atngw100_usba_data __initdata = {
diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
index 1d8b147..8c6f77e 100644
--- a/arch/avr32/mach-at32ap/at32ap700x.c
+++ b/arch/avr32/mach-at32ap/at32ap700x.c
@@ -7,6 +7,7 @@
*/
#include <linux/clk.h>
#include <linux/delay.h>
+#include <linux/dmaengine.h>
#include <linux/platform_data/dma-dw.h>
#include <linux/fb.h>
#include <linux/init.h>
@@ -17,7 +18,6 @@
#include <linux/spi/spi.h>
#include <linux/usb/atmel_usba_udc.h>
-#include <linux/platform_data/mmc-atmel-mci.h>
#include <linux/atmel-mci.h>
#include <asm/io.h>
@@ -1332,7 +1332,7 @@ struct platform_device *__init
at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
{
struct platform_device *pdev;
- struct mci_dma_data *slave;
+ struct dw_dma_slave *slave;
u32 pioa_mask;
u32 piob_mask;
@@ -1351,15 +1351,15 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
ARRAY_SIZE(atmel_mci0_resource)))
goto fail;
- slave = kzalloc(sizeof(struct mci_dma_data), GFP_KERNEL);
+ slave = kzalloc(sizeof(*slave), GFP_KERNEL);
if (!slave)
goto fail;
- slave->sdata.dma_dev = &dw_dmac0_device.dev;
- slave->sdata.src_id = 0;
- slave->sdata.dst_id = 1;
- slave->sdata.src_master = 1;
- slave->sdata.dst_master = 0;
+ slave->dma_dev = &dw_dmac0_device.dev;
+ slave->src_id = 0;
+ slave->dst_id = 1;
+ slave->src_master = 1;
+ slave->dst_master = 0;
data->dma_slave = slave;
@@ -1435,6 +1435,21 @@ fail:
return NULL;
}
+bool atmci_filter(struct dma_chan *chan, void *pdata)
+{
+ struct dw_dma_slave *sl_pdata = pdata;
+
+ if (!sl_pdata)
+ return false;
+
+ if (sl_pdata->dma_dev == chan->device->dev) {
+ chan->private = sl_pdata;
+ return true;
+ } else {
+ return false;
+ }
+}
+
/* --------------------------------------------------------------------
* LCDC
* -------------------------------------------------------------------- */
diff --git a/arch/avr32/mach-at32ap/include/mach/board.h b/arch/avr32/mach-at32ap/include/mach/board.h
index f1a316d..e6f9e56 100644
--- a/arch/avr32/mach-at32ap/include/mach/board.h
+++ b/arch/avr32/mach-at32ap/include/mach/board.h
@@ -4,6 +4,7 @@
#ifndef __ASM_ARCH_BOARD_H
#define __ASM_ARCH_BOARD_H
+#include <linux/dmaengine.h>
#include <linux/types.h>
#include <linux/serial.h>
#include <linux/platform_data/macb.h>
@@ -86,6 +87,7 @@ struct platform_device *at32_add_device_twi(unsigned int id,
struct mci_platform_data;
struct platform_device *
at32_add_device_mci(unsigned int id, struct mci_platform_data *data);
+bool atmci_filter(struct dma_chan *chan, void *pdata);
struct ac97c_platform_data;
struct platform_device *
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 9a39e0b..1d80135 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -30,7 +30,6 @@
#include <linux/stat.h>
#include <linux/types.h>
#include <linux/platform_data/atmel.h>
-#include <linux/platform_data/mmc-atmel-mci.h>
#include <linux/mmc/host.h>
#include <linux/mmc/sdio.h>
@@ -2281,8 +2280,21 @@ static int atmci_configure_dma(struct atmel_mci *host)
{
host->dma.chan = dma_request_slave_channel_reason(&host->pdev->dev,
"rxtx");
- if (IS_ERR(host->dma.chan))
+ if (IS_ERR(host->dma.chan) == -ENODEV) {
+ dma_cap_mask_t mask;
+ struct mci_platform_data *pdata = host->pdev->dev.platform_data;
+ /* */
+ dma_cap_zero(mask);
+ dma_cap_set(DMA_SLAVE, mask);
+
+ host->dma.chan = dma_request_channel(mask,
+ pdata->dma_filter,
+ pdata->dma_slave);
+ if (!host->dma.chan)
+ return -ENODEV;
+ } else {
return PTR_ERR(host->dma.chan);
+ }
dev_info(&host->pdev->dev, "using %s for DMA transfers\n",
dma_chan_name(host->dma.chan));
diff --git a/include/linux/atmel-mci.h b/include/linux/atmel-mci.h
index 9177947..fe5d72f 100644
--- a/include/linux/atmel-mci.h
+++ b/include/linux/atmel-mci.h
@@ -1,6 +1,7 @@
#ifndef __LINUX_ATMEL_MCI_H
#define __LINUX_ATMEL_MCI_H
+#include <linux/dmaengine.h>
#include <linux/types.h>
#define ATMCI_MAX_NR_SLOTS 2
@@ -38,6 +39,7 @@ struct mci_slot_pdata {
struct mci_platform_data {
struct mci_dma_data *dma_slave;
struct mci_slot_pdata slot[ATMCI_MAX_NR_SLOTS];
+ bool (*dma_filter) (struct dma_chan *chan, void *pdata);
};
#endif /* __LINUX_ATMEL_MCI_H */
diff --git a/include/linux/platform_data/mmc-atmel-mci.h b/include/linux/platform_data/mmc-atmel-mci.h
deleted file mode 100644
index 399a2d5..0000000
--- a/include/linux/platform_data/mmc-atmel-mci.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef __MMC_ATMEL_MCI_H
-#define __MMC_ATMEL_MCI_H
-
-#include <linux/platform_data/dma-atmel.h>
-#include <linux/platform_data/dma-dw.h>
-
-/**
- * struct mci_dma_data - DMA data for MCI interface
- */
-struct mci_dma_data {
-#ifdef CONFIG_ARM
- struct at_dma_slave sdata;
-#else
- struct dw_dma_slave sdata;
-#endif
-};
-
-/* accessor macros */
-#define slave_data_ptr(s) (&(s)->sdata)
-#define find_slave_dev(s) ((s)->sdata.dma_dev)
-
-#endif /* __MMC_ATMEL_MCI_H */
--
2.5.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] [wip] repair mci dma transfers for avr32
2015-08-12 15:49 ` [PATCH] [wip] repair mci dma transfers for avr32 Ludovic Desroches
@ 2015-08-12 16:51 ` Andy Shevchenko
2016-01-11 8:54 ` Andy Shevchenko
1 sibling, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2015-08-12 16:51 UTC (permalink / raw)
To: Ludovic Desroches, linux-mmc
Cc: ulf.hansson, arnd, hskinnemoen, egtvedt, nicolas.ferre,
alexandre.belloni
On Wed, 2015-08-12 at 17:49 +0200, Ludovic Desroches wrote:
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>
> Hi,
>
> Here is a rough draft to fix the regression. I have only compiled it.
> I will
> update all the boards later.
>
> I have removed the mci_dma_data since it is no more used for ARM
> platforms.
I will test it later, though few comments below.
>
> arch/avr32/boards/atngw100/setup.c | 1 +
> arch/avr32/mach-at32ap/at32ap700x.c | 31
> +++++++++++++++++++++--------
> arch/avr32/mach-at32ap/include/mach/board.h | 2 ++
> drivers/mmc/host/atmel-mci.c | 16 +++++++++++++--
> include/linux/atmel-mci.h | 2 ++
> include/linux/platform_data/mmc-atmel-mci.h | 22 -------------------
> -
> 6 files changed, 42 insertions(+), 32 deletions(-)
> delete mode 100644 include/linux/platform_data/mmc-atmel-mci.h
>
> diff --git a/arch/avr32/boards/atngw100/setup.c
> b/arch/avr32/boards/atngw100/setup.c
> index afeae89..8b4f3d1 100644
> --- a/arch/avr32/boards/atngw100/setup.c
> +++ b/arch/avr32/boards/atngw100/setup.c
> @@ -131,6 +131,7 @@ static struct mci_platform_data __initdata
> mci0_data = {
> .wp_pin = GPIO_PIN_PE(0),
> #endif
> },
> + .dma_filter = &atmci_filter,
> };
>
> static struct usba_platform_data atngw100_usba_data __initdata = {
> diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach
> -at32ap/at32ap700x.c
> index 1d8b147..8c6f77e 100644
> --- a/arch/avr32/mach-at32ap/at32ap700x.c
> +++ b/arch/avr32/mach-at32ap/at32ap700x.c
> @@ -7,6 +7,7 @@
> */
> #include <linux/clk.h>
> #include <linux/delay.h>
> +#include <linux/dmaengine.h>
> #include <linux/platform_data/dma-dw.h>
> #include <linux/fb.h>
> #include <linux/init.h>
> @@ -17,7 +18,6 @@
> #include <linux/spi/spi.h>
> #include <linux/usb/atmel_usba_udc.h>
>
> -#include <linux/platform_data/mmc-atmel-mci.h>
> #include <linux/atmel-mci.h>
>
> #include <asm/io.h>
> @@ -1332,7 +1332,7 @@ struct platform_device *__init
> at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
> {
> struct platform_device *pdev;
> - struct mci_dma_data *slave;
> + struct dw_dma_slave *slave;
> u32 pioa_mask;
> u32 piob_mask;
>
> @@ -1351,15 +1351,15 @@ at32_add_device_mci(unsigned int id, struct
> mci_platform_data *data)
> ARRAY_SIZE(atmel_mci0_resource)))
> goto fail;
>
> - slave = kzalloc(sizeof(struct mci_dma_data), GFP_KERNEL);
> + slave = kzalloc(sizeof(*slave), GFP_KERNEL);
> if (!slave)
> goto fail;
>
> - slave->sdata.dma_dev = &dw_dmac0_device.dev;
> - slave->sdata.src_id = 0;
> - slave->sdata.dst_id = 1;
> - slave->sdata.src_master = 1;
> - slave->sdata.dst_master = 0;
> + slave->dma_dev = &dw_dmac0_device.dev;
> + slave->src_id = 0;
> + slave->dst_id = 1;
> + slave->src_master = 1;
> + slave->dst_master = 0;
>
> data->dma_slave = slave;
>
> @@ -1435,6 +1435,21 @@ fail:
> return NULL;
> }
>
> +bool atmci_filter(struct dma_chan *chan, void *pdata)
> +{
> + struct dw_dma_slave *sl_pdata = pdata;
I would prefer dws name for struct dw_dma_slave here.
> + if (!sl_pdata)
> + return false;
> +
> + if (sl_pdata->dma_dev == chan->device->dev) {
> + chan->private = sl_pdata;
> + return true;
> + } else {
> + return false;
> + }
> +}
> +
> /* -----------------------------------------------------------------
> ---
> * LCDC
> * -----------------------------------------------------------------
> --- */
> diff --git a/arch/avr32/mach-at32ap/include/mach/board.h
> b/arch/avr32/mach-at32ap/include/mach/board.h
> index f1a316d..e6f9e56 100644
> --- a/arch/avr32/mach-at32ap/include/mach/board.h
> +++ b/arch/avr32/mach-at32ap/include/mach/board.h
> @@ -4,6 +4,7 @@
> #ifndef __ASM_ARCH_BOARD_H
> #define __ASM_ARCH_BOARD_H
>
> +#include <linux/dmaengine.h>
> #include <linux/types.h>
> #include <linux/serial.h>
> #include <linux/platform_data/macb.h>
> @@ -86,6 +87,7 @@ struct platform_device
> *at32_add_device_twi(unsigned int id,
> struct mci_platform_data;
> struct platform_device *
> at32_add_device_mci(unsigned int id, struct mci_platform_data
> *data);
> +bool atmci_filter(struct dma_chan *chan, void *pdata);
Maybe at32_mci_filter() ?
>
> struct ac97c_platform_data;
> struct platform_device *
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel
> -mci.c
> index 9a39e0b..1d80135 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -30,7 +30,6 @@
> #include <linux/stat.h>
> #include <linux/types.h>
> #include <linux/platform_data/atmel.h>
> -#include <linux/platform_data/mmc-atmel-mci.h>
>
> #include <linux/mmc/host.h>
> #include <linux/mmc/sdio.h>
> @@ -2281,8 +2280,21 @@ static int atmci_configure_dma(struct
> atmel_mci *host)
> {
> host->dma.chan = dma_request_slave_channel_reason(&host
> ->pdev->dev,
> "rxtx");
> - if (IS_ERR(host->dma.chan))
> + if (IS_ERR(host->dma.chan) == -ENODEV) {
IS_ERR() returns boolean. It wouldn't be comparable with -Exxx.
> + dma_cap_mask_t mask;
> + struct mci_platform_data *pdata = host->pdev
> ->dev.platform_data;
> + /* */
> + dma_cap_zero(mask);
> + dma_cap_set(DMA_SLAVE, mask);
> +
> + host->dma.chan = dma_request_channel(mask,
> + pdata
> ->dma_filter,
> + pdata
> ->dma_slave);
> + if (!host->dma.chan)
> + return -ENODEV;
> + } else {
> return PTR_ERR(host->dma.chan);
> + }
>
> dev_info(&host->pdev->dev, "using %s for DMA transfers\n",
> dma_chan_name(host->dma.chan));
> diff --git a/include/linux/atmel-mci.h b/include/linux/atmel-mci.h
> index 9177947..fe5d72f 100644
> --- a/include/linux/atmel-mci.h
> +++ b/include/linux/atmel-mci.h
> @@ -1,6 +1,7 @@
> #ifndef __LINUX_ATMEL_MCI_H
> #define __LINUX_ATMEL_MCI_H
>
> +#include <linux/dmaengine.h>
You need only struct dma_chan. Why not
struct dma_chan;
?
> #include <linux/types.h>
>
> #define ATMCI_MAX_NR_SLOTS 2
> @@ -38,6 +39,7 @@ struct mci_slot_pdata {
> struct mci_platform_data {
> struct mci_dma_data *dma_slave;
Should be above line left?
> struct mci_slot_pdata slot[ATMCI_MAX_NR_SLOTS];
> + bool (*dma_filter) (struct dma_chan *chan, void
> *pdata);
> };
>
> #endif /* __LINUX_ATMEL_MCI_H */
> diff --git a/include/linux/platform_data/mmc-atmel-mci.h
> b/include/linux/platform_data/mmc-atmel-mci.h
> deleted file mode 100644
> index 399a2d5..0000000
> --- a/include/linux/platform_data/mmc-atmel-mci.h
> +++ /dev/null
> @@ -1,22 +0,0 @@
> -#ifndef __MMC_ATMEL_MCI_H
> -#define __MMC_ATMEL_MCI_H
> -
> -#include <linux/platform_data/dma-atmel.h>
> -#include <linux/platform_data/dma-dw.h>
> -
> -/**
> - * struct mci_dma_data - DMA data for MCI interface
> - */
> -struct mci_dma_data {
> -#ifdef CONFIG_ARM
> - struct at_dma_slave sdata;
> -#else
> - struct dw_dma_slave sdata;
> -#endif
> -};
> -
> -/* accessor macros */
> -#define slave_data_ptr(s) (&(s)->sdata)
> -#define find_slave_dev(s) ((s)->sdata.dma_dev)
> -
> -#endif /* __MMC_ATMEL_MCI_H */
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] [wip] repair mci dma transfers for avr32
2015-08-12 15:49 ` [PATCH] [wip] repair mci dma transfers for avr32 Ludovic Desroches
2015-08-12 16:51 ` Andy Shevchenko
@ 2016-01-11 8:54 ` Andy Shevchenko
1 sibling, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2016-01-11 8:54 UTC (permalink / raw)
To: Ludovic Desroches, linux-mmc, Måns Rullgård
Cc: ulf.hansson, arnd, hskinnemoen, egtvedt, nicolas.ferre,
alexandre.belloni
+Måns
On Wed, 2015-08-12 at 17:49 +0200, Ludovic Desroches wrote:
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>
> Hi,
>
> Here is a rough draft to fix the regression. I have only compiled it.
> I will
> update all the boards later.
>
> I have removed the mci_dma_data since it is no more used for ARM
> platforms.
Sorry for really late answer, but seems Måns fixed the issue. He has a
board to test as well.
>
> arch/avr32/boards/atngw100/setup.c | 1 +
> arch/avr32/mach-at32ap/at32ap700x.c | 31
> +++++++++++++++++++++--------
> arch/avr32/mach-at32ap/include/mach/board.h | 2 ++
> drivers/mmc/host/atmel-mci.c | 16 +++++++++++++--
> include/linux/atmel-mci.h | 2 ++
> include/linux/platform_data/mmc-atmel-mci.h | 22 -----------------
> ---
> 6 files changed, 42 insertions(+), 32 deletions(-)
> delete mode 100644 include/linux/platform_data/mmc-atmel-mci.h
>
> diff --git a/arch/avr32/boards/atngw100/setup.c
> b/arch/avr32/boards/atngw100/setup.c
> index afeae89..8b4f3d1 100644
> --- a/arch/avr32/boards/atngw100/setup.c
> +++ b/arch/avr32/boards/atngw100/setup.c
> @@ -131,6 +131,7 @@ static struct mci_platform_data __initdata
> mci0_data = {
> .wp_pin = GPIO_PIN_PE(0),
> #endif
> },
> + .dma_filter = &atmci_filter,
> };
>
> static struct usba_platform_data atngw100_usba_data __initdata = {
> diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-
> at32ap/at32ap700x.c
> index 1d8b147..8c6f77e 100644
> --- a/arch/avr32/mach-at32ap/at32ap700x.c
> +++ b/arch/avr32/mach-at32ap/at32ap700x.c
> @@ -7,6 +7,7 @@
> */
> #include <linux/clk.h>
> #include <linux/delay.h>
> +#include <linux/dmaengine.h>
> #include <linux/platform_data/dma-dw.h>
> #include <linux/fb.h>
> #include <linux/init.h>
> @@ -17,7 +18,6 @@
> #include <linux/spi/spi.h>
> #include <linux/usb/atmel_usba_udc.h>
>
> -#include <linux/platform_data/mmc-atmel-mci.h>
> #include <linux/atmel-mci.h>
>
> #include <asm/io.h>
> @@ -1332,7 +1332,7 @@ struct platform_device *__init
> at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
> {
> struct platform_device *pdev;
> - struct mci_dma_data *slave;
> + struct dw_dma_slave *slave;
> u32 pioa_mask;
> u32 piob_mask;
>
> @@ -1351,15 +1351,15 @@ at32_add_device_mci(unsigned int id, struct
> mci_platform_data *data)
> ARRAY_SIZE(atmel_mci0_resource)))
> goto fail;
>
> - slave = kzalloc(sizeof(struct mci_dma_data), GFP_KERNEL);
> + slave = kzalloc(sizeof(*slave), GFP_KERNEL);
> if (!slave)
> goto fail;
>
> - slave->sdata.dma_dev = &dw_dmac0_device.dev;
> - slave->sdata.src_id = 0;
> - slave->sdata.dst_id = 1;
> - slave->sdata.src_master = 1;
> - slave->sdata.dst_master = 0;
> + slave->dma_dev = &dw_dmac0_device.dev;
> + slave->src_id = 0;
> + slave->dst_id = 1;
> + slave->src_master = 1;
> + slave->dst_master = 0;
>
> data->dma_slave = slave;
>
> @@ -1435,6 +1435,21 @@ fail:
> return NULL;
> }
>
> +bool atmci_filter(struct dma_chan *chan, void *pdata)
> +{
> + struct dw_dma_slave *sl_pdata = pdata;
> +
> + if (!sl_pdata)
> + return false;
> +
> + if (sl_pdata->dma_dev == chan->device->dev) {
> + chan->private = sl_pdata;
> + return true;
> + } else {
> + return false;
> + }
> +}
> +
> /* ---------------------------------------------------------------
> -----
> * LCDC
> * ---------------------------------------------------------------
> ----- */
> diff --git a/arch/avr32/mach-at32ap/include/mach/board.h
> b/arch/avr32/mach-at32ap/include/mach/board.h
> index f1a316d..e6f9e56 100644
> --- a/arch/avr32/mach-at32ap/include/mach/board.h
> +++ b/arch/avr32/mach-at32ap/include/mach/board.h
> @@ -4,6 +4,7 @@
> #ifndef __ASM_ARCH_BOARD_H
> #define __ASM_ARCH_BOARD_H
>
> +#include <linux/dmaengine.h>
> #include <linux/types.h>
> #include <linux/serial.h>
> #include <linux/platform_data/macb.h>
> @@ -86,6 +87,7 @@ struct platform_device
> *at32_add_device_twi(unsigned int id,
> struct mci_platform_data;
> struct platform_device *
> at32_add_device_mci(unsigned int id, struct mci_platform_data
> *data);
> +bool atmci_filter(struct dma_chan *chan, void *pdata);
>
> struct ac97c_platform_data;
> struct platform_device *
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-
> mci.c
> index 9a39e0b..1d80135 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -30,7 +30,6 @@
> #include <linux/stat.h>
> #include <linux/types.h>
> #include <linux/platform_data/atmel.h>
> -#include <linux/platform_data/mmc-atmel-mci.h>
>
> #include <linux/mmc/host.h>
> #include <linux/mmc/sdio.h>
> @@ -2281,8 +2280,21 @@ static int atmci_configure_dma(struct
> atmel_mci *host)
> {
> host->dma.chan = dma_request_slave_channel_reason(&host-
> >pdev->dev,
> "rxtx");
> - if (IS_ERR(host->dma.chan))
> + if (IS_ERR(host->dma.chan) == -ENODEV) {
> + dma_cap_mask_t mask;
> + struct mci_platform_data *pdata = host->pdev-
> >dev.platform_data;
> + /* */
> + dma_cap_zero(mask);
> + dma_cap_set(DMA_SLAVE, mask);
> +
> + host->dma.chan = dma_request_channel(mask,
> + pdata-
> >dma_filter,
> + pdata-
> >dma_slave);
> + if (!host->dma.chan)
> + return -ENODEV;
> + } else {
> return PTR_ERR(host->dma.chan);
> + }
>
> dev_info(&host->pdev->dev, "using %s for DMA transfers\n",
> dma_chan_name(host->dma.chan));
> diff --git a/include/linux/atmel-mci.h b/include/linux/atmel-mci.h
> index 9177947..fe5d72f 100644
> --- a/include/linux/atmel-mci.h
> +++ b/include/linux/atmel-mci.h
> @@ -1,6 +1,7 @@
> #ifndef __LINUX_ATMEL_MCI_H
> #define __LINUX_ATMEL_MCI_H
>
> +#include <linux/dmaengine.h>
> #include <linux/types.h>
>
> #define ATMCI_MAX_NR_SLOTS 2
> @@ -38,6 +39,7 @@ struct mci_slot_pdata {
> struct mci_platform_data {
> struct mci_dma_data *dma_slave;
> struct mci_slot_pdata slot[ATMCI_MAX_NR_SLOTS];
> + bool (*dma_filter) (struct dma_chan *chan, void
> *pdata);
> };
>
> #endif /* __LINUX_ATMEL_MCI_H */
> diff --git a/include/linux/platform_data/mmc-atmel-mci.h
> b/include/linux/platform_data/mmc-atmel-mci.h
> deleted file mode 100644
> index 399a2d5..0000000
> --- a/include/linux/platform_data/mmc-atmel-mci.h
> +++ /dev/null
> @@ -1,22 +0,0 @@
> -#ifndef __MMC_ATMEL_MCI_H
> -#define __MMC_ATMEL_MCI_H
> -
> -#include <linux/platform_data/dma-atmel.h>
> -#include <linux/platform_data/dma-dw.h>
> -
> -/**
> - * struct mci_dma_data - DMA data for MCI interface
> - */
> -struct mci_dma_data {
> -#ifdef CONFIG_ARM
> - struct at_dma_slave sdata;
> -#else
> - struct dw_dma_slave sdata;
> -#endif
> -};
> -
> -/* accessor macros */
> -#define slave_data_ptr(s) (&(s)->sdata)
> -#define find_slave_dev(s) ((s)->sdata.dma_dev)
> -
> -#endif /* __MMC_ATMEL_MCI_H */
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-01-11 8:54 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-27 11:53 [PATCH v1 1/1] mmc: atmel-mci: allow DMA transfers for AVR32 Andy Shevchenko
2015-07-27 12:24 ` Arnd Bergmann
2015-07-27 14:45 ` Andy Shevchenko
2015-08-06 7:01 ` Ludovic Desroches
2015-08-06 13:16 ` Arnd Bergmann
2015-08-12 15:49 ` [PATCH] [wip] repair mci dma transfers for avr32 Ludovic Desroches
2015-08-12 16:51 ` Andy Shevchenko
2016-01-11 8:54 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).