From patchwork Tue Jul 5 15:14:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Per Forlin X-Patchwork-Id: 945712 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p65FGLjg021335 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 5 Jul 2011 15:16:42 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qe7LI-000671-CH; Tue, 05 Jul 2011 15:15:17 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qe7LH-0004pW-VW; Tue, 05 Jul 2011 15:15:15 +0000 Received: from mail-bw0-f49.google.com ([209.85.214.49]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qe7LE-0004pE-Jp for linux-arm-kernel@lists.infradead.org; Tue, 05 Jul 2011 15:15:13 +0000 Received: by bwf12 with SMTP id 12so6253612bwf.36 for ; Tue, 05 Jul 2011 08:15:08 -0700 (PDT) Received: by 10.204.57.82 with SMTP id b18mr120595bkh.95.1309878908174; Tue, 05 Jul 2011 08:15:08 -0700 (PDT) Received: from localhost.localdomain (c-3c7b71d5.029-82-6c756e10.cust.bredbandsbolaget.se [213.113.123.60]) by mx.google.com with ESMTPS id l24sm6636763bkw.3.2011.07.05.08.15.01 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Jul 2011 08:15:07 -0700 (PDT) From: Per Forlin To: linaro-dev@lists.linaro.org, Nicolas Pitre , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, linux-doc@vger.kernel.org, Venkatraman S , Linus Walleij , Kyungmin Park , Arnd Bergmann , Sourav Poddar , Chris Ball Subject: [PATCH] mmc: documentation of mmc non-blocking request usage and design. Date: Tue, 5 Jul 2011 17:14:54 +0200 Message-Id: <1309878894-2700-1-git-send-email-per.forlin@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110705_111512_941817_98911C7C X-CRM114-Status: GOOD ( 22.76 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.49 listed in list.dnswl.org] Cc: Randy Dunlap , Per Forlin X-BeenThere: linux-arm-kernel@lists.infradead.org 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: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 05 Jul 2011 15:16:42 +0000 (UTC) Documentation about the background and the design of mmc non-blocking. Host driver guide lines to minimize request preparation over head. Signed-off-by: Per Forlin --- Documentation/mmc/00-INDEX | 2 + Documentation/mmc/mmc-async-req.txt | 85 +++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 0 deletions(-) create mode 100644 Documentation/mmc/mmc-async-req.txt diff --git a/Documentation/mmc/00-INDEX b/Documentation/mmc/00-INDEX index 93dd7a7..11bc2cf 100644 --- a/Documentation/mmc/00-INDEX +++ b/Documentation/mmc/00-INDEX @@ -4,3 +4,5 @@ mmc-dev-attrs.txt - info on SD and MMC device attributes mmc-dev-parts.txt - info on SD and MMC device partitions +mmc-async-req.txt + - info on mmc asynchronous request diff --git a/Documentation/mmc/mmc-async-req.txt b/Documentation/mmc/mmc-async-req.txt new file mode 100644 index 0000000..d139a51 --- /dev/null +++ b/Documentation/mmc/mmc-async-req.txt @@ -0,0 +1,85 @@ +Rationale +========= + +How significant is the cache maintenance over head? +It depends, fast eMMC and multiple cache levels with speculative cache pre-fetch +makes the cache overhead relatively significant. If the DMA preparations +for the next request is done in parallel to the current transfer +the DMA preparation overhead would not affect the MMC performance. +The intention of non-blocking (asynchronous) mmc requests is to minimize the +time between a mmc request ends and another mmc request begins. +Using mmc_wait_for_req() the MMC controller is idle when dma_map_sg and +dma_unmap_sg is processing. Using non-blocking mmc request makes it +possible to prepare the caches for next job in parallel to an active +mmc request. + +MMC block driver +================ + +The issue_rw_rq() in the mmc block driver is made non-blocking. +The increase in throughput is proportional to the time it takes to +prepare (major part of preparations is dma_map_sg and dma_unmap_sg) +a request and how fast the memory is. The faster the MMC/SD is +the more significant the prepare request time becomes. Roughly the expected +performance gain is 5% for large writes and 10% on large reads on a L2 cache +platform. In power save mode, when clocks run on a lower frequency, the DMA +preparation may cost even more. As long as these slower preparations are run +in parallel to the transfer performance wont be affected. + +Details on measurements from IOZone and mmc_test +================================================ + +https://wiki.linaro.org/WorkingGroups/Kernel/Specs/StoragePerfMMC-async-req + +MMC core API extension +====================== + +There is one new public function mmc_start_req() +Is starts a new MMC command request for a host. The function isn't +truely non-blocking. If there is on ongoing async request it waits +for completion of that request and starts the new one and return. It +Doesn't wait for the new request to complete. If there is no ongoing +request it starts the new request and returns immediately. + +MMC host extensions +=================== + +There are two optional hooks pre_req() and post_req() that the host driver +may implement in order to move work to before and after the actual mmc_request +function is called. In the DMA case pre_req() may do dma_map_sg() and prepare +the dma descriptor, and post_req runs the dma_unmap_sg. + +Optimize for the first request +============================== + +The first request in a series of requests can't be prepared in parallel to the +previous transfer, since there is no previous request. +The argument is_first_req in pre_req() indicates that there is no previous +request. The host driver may optimize for this scenario to minimize +the performance loss. A way to optimize for this is to split the current +request in two chunks, prepare the first chunk and start the request, +and finally prepare the second chunk and start the transfer. + +Pseudocode to handle is_first_req scenario with minimal prepare over head: +if (is_first_req && req->size > threshold) + /* start MMC transfer for the complete transfer size */ + mmc_start_command(MMC_CMD_TRANSFER_FULL_SIZE) + + /* + * Begin to prepare DMA while cmd is being processed by MMC. + * The first chunk of the request should take the same time + * to prepare as the "MMC process command time". + * If prepare time exceeds MMC cmd time + * the transfer is delayed, guesstimate max 4k as first chunk size. + */ + prepare_1st_chunk_for_dma(req) + /* flush pending desc to the DMAC (dmaengine.h) */ + dma_issue_pending(req->dma_desc); + + prepare_2st_chunk_for_dma(req) + /* + * The second issue_pending should be called before MMC runs out + * of the first chunk. If the MMC runs out of the first data chunk before + * this call, the transfer is delayed. + */ + dma_issue_pending(req->dma_desc);