diff mbox

[v1,1/1] mmc: atmel-mci: allow DMA transfers for AVR32

Message ID 1437998010-12036-1-git-send-email-andriy.shevchenko@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andy Shevchenko July 27, 2015, 11:53 a.m. UTC
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(-)

Comments

Arnd Bergmann July 27, 2015, 12:24 p.m. UTC | #1
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
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andy Shevchenko July 27, 2015, 2:45 p.m. UTC | #2
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
Ludovic Desroches Aug. 6, 2015, 7:01 a.m. UTC | #3
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
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Arnd Bergmann Aug. 6, 2015, 1:16 p.m. UTC | #4
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
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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