From patchwork Thu Jan 10 19:07:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Porter X-Patchwork-Id: 1961641 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by patchwork2.kernel.org (Postfix) with ESMTP id 404FCDF264 for ; Thu, 10 Jan 2013 19:07:27 +0000 (UTC) Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r0AJ3oSt003530; Thu, 10 Jan 2013 13:03:50 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r0AJ3orR027410; Thu, 10 Jan 2013 13:03:50 -0600 Received: from dlelxv23.itg.ti.com (172.17.1.198) by dfle72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.1.323.3; Thu, 10 Jan 2013 13:03:50 -0600 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id r0AJ3oma014248; Thu, 10 Jan 2013 13:03:50 -0600 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 3C9CC80628; Thu, 10 Jan 2013 13:03:50 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp52.itg.ti.com (dflp52.itg.ti.com [128.247.22.96]) by linux.omap.com (Postfix) with ESMTP id D65C080652 for ; Thu, 10 Jan 2013 13:02:39 -0600 (CST) Received: from red.ext.ti.com (red.ext.ti.com [192.94.93.37]) by dflp52.itg.ti.com (8.13.7/8.13.8) with ESMTP id r0AJ2dbA016867 for ; Thu, 10 Jan 2013 13:02:39 -0600 (CST) Received: from mail6.bemta12.messagelabs.com (mail6.bemta12.messagelabs.com [216.82.250.247]) by red.ext.ti.com (8.13.7/8.13.7) with ESMTP id r0AJ2dje003527 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 10 Jan 2013 13:02:39 -0600 Received: from [216.82.250.51:21523] by server-9.bemta-12.messagelabs.com id 3D/74-02160-F401FE05; Thu, 10 Jan 2013 19:02:39 +0000 X-Env-Sender: ohiomdp@gmail.com X-Msg-Ref: server-7.tower-108.messagelabs.com!1357844557!16564789!1 X-Originating-IP: [209.85.220.173] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.6.1.8; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8972 invoked from network); 10 Jan 2013 19:02:38 -0000 Received: from mail-vc0-f173.google.com (HELO mail-vc0-f173.google.com) (209.85.220.173) by server-7.tower-108.messagelabs.com with RC4-SHA encrypted SMTP; 10 Jan 2013 19:02:38 -0000 Received: by mail-vc0-f173.google.com with SMTP id f13so681163vcb.32 for ; Thu, 10 Jan 2013 11:02:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=88qvqol5J9MRgyZOQxFOJIDlzI60C9CxzKRyrTIP0Ys=; b=oJk1leBnOxHh3Yf0SRf1Xecz/w596YJDxgGLW5Y9y8f94F3LBiFn6QvnYdMC6jGQ5J fqudMwv5QSJeEj/tPHIMyf0hL97VEU5N1UWeoxHv4g3vcjlXV0bUEe0vkL6tF5RrUYsR pSTLF6x+NaWNZCbJVw4skID9SMHGGPHjk+ptweWqRdpgrDK0EHCUUXIz79bMEkKYWT5L +g9SqvofmNDNvjsrCAR6y6x2RwmmiHP6NsI0+igP48wdEtXU3vmJM4Lm6b3Vr45ySlta nXVOe6jJ8NnM/Yv3IwKcsX8v54eUMa0K7M6TPvtW1fh9SnDHKKblHAlYimRXaM/PLMaO HKfQ== X-Received: by 10.59.6.70 with SMTP id cs6mr92787279ved.60.1357844557117; Thu, 10 Jan 2013 11:02:37 -0800 (PST) Received: from beef.ohporter.com (cpe-24-166-64-7.neo.res.rr.com. [24.166.64.7]) by mx.google.com with ESMTPS id dx4sm902920vdb.16.2013.01.10.11.02.35 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Jan 2013 11:02:36 -0800 (PST) From: Matt Porter To: Vinod Koul Subject: [PATCH v2 3/3] mmc: davinci: get SG segment limits with dma_get_channel_caps() Date: Thu, 10 Jan 2013 14:07:06 -0500 Message-ID: <1357844826-30746-4-git-send-email-mporter@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1357844826-30746-1-git-send-email-mporter@ti.com> References: <1357844826-30746-1-git-send-email-mporter@ti.com> CC: Linux DaVinci Kernel List , Linux MMC List , Linux Kernel Mailing List , Grant Likely , Dan Williams , Chris Ball X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com Replace the hardcoded values used to set max_segs/max_seg_size with a dma_get_channel_caps() query to the dmaengine driver. Signed-off-by: Matt Porter --- drivers/mmc/host/davinci_mmc.c | 66 +++++++++-------------------- include/linux/platform_data/mmc-davinci.h | 3 -- 2 files changed, 21 insertions(+), 48 deletions(-) diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c index 2063677..17e186d 100644 --- a/drivers/mmc/host/davinci_mmc.c +++ b/drivers/mmc/host/davinci_mmc.c @@ -144,18 +144,6 @@ /* MMCSD Init clock in Hz in opendrain mode */ #define MMCSD_INIT_CLOCK 200000 -/* - * One scatterlist dma "segment" is at most MAX_CCNT rw_threshold units, - * and we handle up to MAX_NR_SG segments. MMC_BLOCK_BOUNCE kicks in only - * for drivers with max_segs == 1, making the segments bigger (64KB) - * than the page or two that's otherwise typical. nr_sg (passed from - * platform data) == 16 gives at least the same throughput boost, using - * EDMA transfer linkage instead of spending CPU time copying pages. - */ -#define MAX_CCNT ((1 << 16) - 1) - -#define MAX_NR_SG 16 - static unsigned rw_threshold = 32; module_param(rw_threshold, uint, S_IRUGO); MODULE_PARM_DESC(rw_threshold, @@ -216,8 +204,6 @@ struct mmc_davinci_host { u8 version; /* for ns in one cycle calculation */ unsigned ns_in_one_cycle; - /* Number of sg segments */ - u8 nr_sg; #ifdef CONFIG_CPU_FREQ struct notifier_block freq_transition; #endif @@ -421,16 +407,7 @@ static int mmc_davinci_send_dma_request(struct mmc_davinci_host *host, int ret = 0; if (host->data_dir == DAVINCI_MMC_DATADIR_WRITE) { - struct dma_slave_config dma_tx_conf = { - .direction = DMA_MEM_TO_DEV, - .dst_addr = host->mem_res->start + DAVINCI_MMCDXR, - .dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, - .dst_maxburst = - rw_threshold / DMA_SLAVE_BUSWIDTH_4_BYTES, - }; chan = host->dma_tx; - dmaengine_slave_config(host->dma_tx, &dma_tx_conf); - desc = dmaengine_prep_slave_sg(host->dma_tx, data->sg, host->sg_len, @@ -443,16 +420,7 @@ static int mmc_davinci_send_dma_request(struct mmc_davinci_host *host, goto out; } } else { - struct dma_slave_config dma_rx_conf = { - .direction = DMA_DEV_TO_MEM, - .src_addr = host->mem_res->start + DAVINCI_MMCDRR, - .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, - .src_maxburst = - rw_threshold / DMA_SLAVE_BUSWIDTH_4_BYTES, - }; chan = host->dma_rx; - dmaengine_slave_config(host->dma_rx, &dma_rx_conf); - desc = dmaengine_prep_slave_sg(host->dma_rx, data->sg, host->sg_len, @@ -1165,6 +1133,7 @@ static int __init davinci_mmcsd_probe(struct platform_device *pdev) struct resource *r, *mem = NULL; int ret = 0, irq = 0; size_t mem_size; + struct dmaengine_chan_caps *dma_chan_caps; /* REVISIT: when we're fully converted, fail if pdata is NULL */ @@ -1214,12 +1183,6 @@ static int __init davinci_mmcsd_probe(struct platform_device *pdev) init_mmcsd_host(host); - if (pdata->nr_sg) - host->nr_sg = pdata->nr_sg - 1; - - if (host->nr_sg > MAX_NR_SG || !host->nr_sg) - host->nr_sg = MAX_NR_SG; - host->use_dma = use_dma; host->mmc_irq = irq; host->sdio_irq = platform_get_irq(pdev, 1); @@ -1248,14 +1211,27 @@ static int __init davinci_mmcsd_probe(struct platform_device *pdev) mmc->caps |= pdata->caps; mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; - /* With no iommu coalescing pages, each phys_seg is a hw_seg. - * Each hw_seg uses one EDMA parameter RAM slot, always one - * channel and then usually some linked slots. - */ - mmc->max_segs = MAX_NR_SG; + { + struct dma_slave_config dma_txrx_conf = { + .src_addr = host->mem_res->start + DAVINCI_MMCDRR, + .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, + .src_maxburst = + rw_threshold / DMA_SLAVE_BUSWIDTH_4_BYTES, + .dst_addr = host->mem_res->start + DAVINCI_MMCDXR, + .dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, + .dst_maxburst = + rw_threshold / DMA_SLAVE_BUSWIDTH_4_BYTES, + }; + dmaengine_slave_config(host->dma_tx, &dma_txrx_conf); + dmaengine_slave_config(host->dma_rx, &dma_txrx_conf); + } - /* EDMA limit per hw segment (one or two MBytes) */ - mmc->max_seg_size = MAX_CCNT * rw_threshold; + /* Just check one channel for the DMA SG limits */ + dma_chan_caps = dma_get_channel_caps(host->dma_tx, DMA_MEM_TO_DEV); + if (dma_chan_caps) { + mmc->max_segs = dma_chan_caps->seg_nr; + mmc->max_seg_size = dma_chan_caps->seg_len; + } /* MMC/SD controller limits for multiblock requests */ mmc->max_blk_size = 4095; /* BLEN is 12 bits */ diff --git a/include/linux/platform_data/mmc-davinci.h b/include/linux/platform_data/mmc-davinci.h index 5ba6b22..6910209 100644 --- a/include/linux/platform_data/mmc-davinci.h +++ b/include/linux/platform_data/mmc-davinci.h @@ -25,9 +25,6 @@ struct davinci_mmc_config { /* Version of the MMC/SD controller */ u8 version; - - /* Number of sg segments */ - u8 nr_sg; }; void davinci_setup_mmc(int module, struct davinci_mmc_config *config);