From patchwork Wed Aug 12 15:49:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ludovic Desroches X-Patchwork-Id: 7002911 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6F6519F358 for ; Wed, 12 Aug 2015 15:49:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D41420651 for ; Wed, 12 Aug 2015 15:48:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C1A2220637 for ; Wed, 12 Aug 2015 15:48:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932083AbbHLPs4 (ORCPT ); Wed, 12 Aug 2015 11:48:56 -0400 Received: from eusmtp01.atmel.com ([212.144.249.242]:19057 "EHLO eusmtp01.atmel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932065AbbHLPsz (ORCPT ); Wed, 12 Aug 2015 11:48:55 -0400 Received: from ibiza.corp.atmel.com (10.161.101.13) by eusmtp01.atmel.com (10.161.101.30) with Microsoft SMTP Server id 14.3.235.1; Wed, 12 Aug 2015 17:48:50 +0200 From: Ludovic Desroches To: CC: , , , , , , , Ludovic Desroches Subject: [PATCH] [wip] repair mci dma transfers for avr32 Date: Wed, 12 Aug 2015 17:49:08 +0200 Message-ID: <1439394548-1020-1-git-send-email-ludovic.desroches@atmel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1437998010-12036-1-git-send-email-andriy.shevchenko@linux.intel.com> References: <1437998010-12036-1-git-send-email-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Ludovic Desroches --- 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 #include +#include #include #include #include @@ -17,7 +18,6 @@ #include #include -#include #include #include @@ -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 #include #include #include @@ -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 #include #include -#include #include #include @@ -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 #include #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 -#include - -/** - * 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 */