From patchwork Wed Nov 12 22:10:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 5292031 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 34777C11AC for ; Wed, 12 Nov 2014 22:10:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F7B4201F5 for ; Wed, 12 Nov 2014 22:10:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A96AA201E4 for ; Wed, 12 Nov 2014 22:10:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752273AbaKLWK2 (ORCPT ); Wed, 12 Nov 2014 17:10:28 -0500 Received: from vps0.lunn.ch ([178.209.37.122]:59565 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752155AbaKLWK1 (ORCPT ); Wed, 12 Nov 2014 17:10:27 -0500 Received: from lunn by vps0.lunn.ch with local (Exim 4.80) (envelope-from ) id 1Xog79-0000Uy-QM; Wed, 12 Nov 2014 23:10:11 +0100 From: Andrew Lunn To: chris@printf.net Cc: linux-mmc@vger.kernel.org, linux ARM , Thomas Petazzoni , Andrew Lunn Subject: [PATCH] mmc: mvsdio: Work around broken TX DMA Date: Wed, 12 Nov 2014 23:10:08 +0100 Message-Id: <1415830208-1888-1-git-send-email-andrew@lunn.ch> X-Mailer: git-send-email 1.7.10.4 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 In order to use the mvsdio driver for sdio, it has been necessary to use a module parameter to disable DMA so to force PIO is used. It is then possible to use wireless LAN devices like mwifiex found on topkick and mirabox. However, accessing an MMC SD card does work with DMA. Investigation has shown that MMC block device accesses are always aligned to 64 byte boundaries, where as transfers from mwifiex are rarely more than word aligned. It has also been determined that card to host transfers work with DMA for SDIO devices, but host to card transfers with DMA have problems. This patch extends the current checks for buffers which are not word aligned or multiple of words. All host to card transfers which are not 64 byte aligned are now also performed via PIO. This should not affect the performance of SD cards, but allow sdio devices to work out of the box, and they are likely to be more efficient since DMA will be used for card to host transfers. Tested on mirabox for wifi via mwifiex Tested on 370 RD for file systems on an SD card. Signed-off-by: Andrew Lunn --- drivers/mmc/host/mvsdio.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/mvsdio.c b/drivers/mmc/host/mvsdio.c index 6b4c5ad3b393..4f8618f4522d 100644 --- a/drivers/mmc/host/mvsdio.c +++ b/drivers/mmc/host/mvsdio.c @@ -111,10 +111,15 @@ static int mvsd_setup_data(struct mvsd_host *host, struct mmc_data *data) mvsd_write(MVSD_BLK_COUNT, data->blocks); mvsd_write(MVSD_BLK_SIZE, data->blksz); - if (nodma || (data->blksz | data->sg->offset) & 3) { + if (nodma || (data->blksz | data->sg->offset) & 3 || + ((!(data->flags & MMC_DATA_READ) && data->sg->offset & 0x3f))) { /* * We cannot do DMA on a buffer which offset or size * is not aligned on a 4-byte boundary. + * + * It also appears the host to card DMA can corrupt + * data when the buffer is not aligned on a 64 byte + * boundary. */ host->pio_size = data->blocks * data->blksz; host->pio_ptr = sg_virt(data->sg);