Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5620309imm; Mon, 27 Aug 2018 00:54:21 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYKaDUen1NaFpUrmTgEXD2jVcDiVyIeM8JsNElXCEH3PRfxNQHHQZLGTQqOVUP7BpiNgW4S X-Received: by 2002:a63:27c1:: with SMTP id n184-v6mr11169759pgn.298.1535356461864; Mon, 27 Aug 2018 00:54:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535356461; cv=none; d=google.com; s=arc-20160816; b=t6Vetxo0epKGsrGAGRY1grIXdXCUAFtxQw2mU8hzP8FXuQ/IZO0hMOIUuST8cyhDOd kBcPtCSVIU6aa5GHLy9By2zSAtm5AaD1SaZHiUsYU5ZJ6IaeZMmRdJgML1YEesOpQFEQ ock3lfgnS2iO9vPbwnHoW5fKzlsLysdsLlznlLPmHt/2BYZ3Sgpxi47+M7wgntnVfDZ2 nsGDahWmlz4xte+qKst2dW0zKMOi5nBwVZ/m9p8eDmdqbkkffYB2cDF9H/QJCM5jv0nH yBkb+Hca+f5lumrqg2nDBitilZ7cMNy0NtrTRBrCZep3loFTvjjhPJoS1MrIg+/8mGl8 eJEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=VsKirMMAbeZop9zyEh38wwWLeszhBqNQH+HIe1D4yXI=; b=hEJoKnvicdvTX1B1KS7/TYDIzOAT/bYesGFitUovuPVLv6NOL+IQUmRDm50wY/dlAV stpX4Il7t5cF2XuHkoK4Okp8AOv/seAXlRstnNrikcFqXRVycFnu/n+zf4Hut1DrXPdn kq3f/8qQ4HVOCAh872QyrpALs8MkTMOi4PGCbYnzcwTm9wSLdwQEGWVLTOoabe3yz+Cy Sslj8Qrf9/Su+93+aFaSG8B0juaCeA3gkHodpSVErkhVUEF8CFxcW9NKQJP0OPYiLzPV RHiggqyJqZE1iD4AICZ3gAadBHVsGkL6BiJnIdVp82iLLjWg84wxhih21bWBL7U3rYdR ZyBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=V1jSlrWM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e17-v6si3011779pgb.497.2018.08.27.00.54.06; Mon, 27 Aug 2018 00:54:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=V1jSlrWM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727345AbeH0Lia (ORCPT + 99 others); Mon, 27 Aug 2018 07:38:30 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:36603 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727101AbeH0Lia (ORCPT ); Mon, 27 Aug 2018 07:38:30 -0400 Received: by mail-lf1-f68.google.com with SMTP id c21-v6so11177264lfh.3; Mon, 27 Aug 2018 00:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=VsKirMMAbeZop9zyEh38wwWLeszhBqNQH+HIe1D4yXI=; b=V1jSlrWMl/nIV2Pna4i0VHZALtENmcS92GQhdzwRwo6S1lAF/hWohrCuaHme2IyHzR Xi92ZY2TDggAIVEhXBt8Jzga9i4rvrz61kY8hTMkiXlqBd21mI+I2YxuxVZ/tA0U1Rj+ KaUHbjjRahsd4clRLGzcDcDpYXZHRMAQgkjfYyroeexfjEJB9nkZAw5NWL5bk7ZO7qRX Hj4hltfvZh00fuuu2gkSaVYbgAQ0n3XFFeO4OPBHcqxjkCij+x5QntuqWEKTrMCRWwOk 7fnWlA9ZiCTv6i/MWn2mpqF+4AI0jhDXdE5XwNT0fpIcunFAwQA3CjIq8a+TchMUQhmr E+7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=VsKirMMAbeZop9zyEh38wwWLeszhBqNQH+HIe1D4yXI=; b=VI55zBeTARsillLg6KnEO4pw2s/Pnp2Iwb7Csqa4Uj4YWhxdktk0QdYIRAco6OVF3x 2OPa7nn+hhznFQPOWEUPoTwyLxrfgeGt0966cseVMpkCgqpVmpmrZcljbfoB4knHjnKR KMZtIAoXLq9+lK7ixRIBcUcasVLKuviDHfB1CjbP/5SUCO97CyDm2mqbTUHrGFZnOVwX wXtnaQevM3Z65Mb/UXn+ygqaJ2fismwxtAL9ZnsLcFqPIdmjAur1Yb9j8oxCloEwWMUv 4T3MC2UAH4lbrDzmfdmLWJtgokvZfSeRvuQjmv72RWtdZ2x2YstPOd2jlaN/JFG9fJLX dcTQ== X-Gm-Message-State: APzg51B73EUMJHi1fk0fksOCD/SUNiHgpJm6VLomhN2vy51PwQ1d2D9y XWEDKPIE05rgO0oYC6o47z4RI+9EuJpVa/dglLY= X-Received: by 2002:a19:115b:: with SMTP id g88-v6mr7466349lfi.57.1535356377252; Mon, 27 Aug 2018 00:52:57 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab3:6318:0:0:0:0:0 with HTTP; Mon, 27 Aug 2018 00:52:16 -0700 (PDT) In-Reply-To: References: <1535102428-20332-1-git-send-email-zhang.chunyan@linaro.org> <1535102428-20332-6-git-send-email-zhang.chunyan@linaro.org> From: Chunyan Zhang Date: Mon, 27 Aug 2018 15:52:16 +0800 Message-ID: Subject: Re: [PATCH V6 5/9] mmc: sdhci: Add 32-bit block count support for v4 mode To: Adrian Hunter Cc: Chunyan Zhang , Ulf Hansson , linux-mmc@vger.kernel.org, Linux Kernel Mailing List , Orson Zhai , Baolin Wang , Billows Wu , Jason Wu , Chunyan Zhang Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27 August 2018 at 15:07, Adrian Hunter wrote: > On 24/08/18 12:20, Chunyan Zhang wrote: >> Host Controller Version 4.10 re-defines SDMA System Address register >> as 32-bit Block Count for v4 mode, and SDMA uses ADMA System >> Address register (05Fh-058h) instead if v4 mode is enabled. Also >> when using 32-bit block count, 16-bit block count register need >> to be set to zero. >> >> Since using 32-bit Block Count would cause problems for auto-cmd23, >> it can be chosen via host->quirk2. >> >> Signed-off-by: Chunyan Zhang >> --- >> drivers/mmc/host/sdhci.c | 15 ++++++++++++++- >> drivers/mmc/host/sdhci.h | 3 +++ >> 2 files changed, 17 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c >> index 38d083c..05f9fff 100644 >> --- a/drivers/mmc/host/sdhci.c >> +++ b/drivers/mmc/host/sdhci.c >> @@ -1073,7 +1073,20 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) >> /* Set the DMA boundary value and block size */ >> sdhci_writew(host, SDHCI_MAKE_BLKSZ(host->sdma_boundary, data->blksz), >> SDHCI_BLOCK_SIZE); >> - sdhci_writew(host, data->blocks, SDHCI_BLOCK_COUNT); >> + >> + /* >> + * For Version 4.10 onwards, if v4 mode is enabled, 16-bit Block Count >> + * register need to be set to zero, 32-bit Block Count register would >> + * be selected. >> + */ >> + if (host->version >= SDHCI_SPEC_410 && host->v4_mode && >> + !(host->quirks2 & SDHCI_QUIRK2_BROKEN_32BIT_BLK_CNT)) { > > Because 32-bit block count is problematic but also not essential, I would > prefer to do the quirk the other way around. i.e. SDHCI_QUIRK2_USE_32BIT_BLK_CNT > > I would also add a comment to the definition of > SDHCI_QUIRK2_USE_32BIT_BLK_CNT, like: > > 32-bit block count may not support eMMC where upper bits of CMD23 are used > for other purposes. Consequently we support 16-bit block count by default. > Otherwise, SDHCI_QUIRK2_USE_32BIT_BLK_CNT can be selected to use 32-bit > block count. Ok, thanks Adrian! I will address the comments and also rebase the whole patchset to v4.19-rc1. > >> + if (sdhci_readw(host, SDHCI_BLOCK_COUNT)) >> + sdhci_writew(host, 0, SDHCI_BLOCK_COUNT); >> + sdhci_writew(host, data->blocks, SDHCI_32BIT_BLK_CNT); >> + } else { >> + sdhci_writew(host, data->blocks, SDHCI_BLOCK_COUNT); >> + } >> } >> >> static inline bool sdhci_auto_cmd12(struct sdhci_host *host, >> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h >> index f3b9ebc..0a1e25f 100644 >> --- a/drivers/mmc/host/sdhci.h >> +++ b/drivers/mmc/host/sdhci.h >> @@ -28,6 +28,7 @@ >> >> #define SDHCI_DMA_ADDRESS 0x00 >> #define SDHCI_ARGUMENT2 SDHCI_DMA_ADDRESS >> +#define SDHCI_32BIT_BLK_CNT SDHCI_DMA_ADDRESS >> >> #define SDHCI_BLOCK_SIZE 0x04 >> #define SDHCI_MAKE_BLKSZ(dma, blksz) (((dma & 0x7) << 12) | (blksz & 0xFFF)) >> @@ -462,6 +463,8 @@ struct sdhci_host { >> * obtainable timeout. >> */ >> #define SDHCI_QUIRK2_DISABLE_HW_TIMEOUT (1<<17) >> +/* Controller broken with using 32-bit block count in v4_mode */ >> +#define SDHCI_QUIRK2_BROKEN_32BIT_BLK_CNT (1<<18) >> >> int irq; /* Device IRQ */ >> void __iomem *ioaddr; /* Mapped address */ >> >