Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6938674imm; Tue, 28 Aug 2018 03:50:30 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaSTHFukyF+JP+FAryrs3jP+HVVyDOA0bmoJ5PweggRTsX/EQbI+LelyGo/APLPgVUCeRBM X-Received: by 2002:a63:5fc8:: with SMTP id t191-v6mr975684pgb.183.1535453430169; Tue, 28 Aug 2018 03:50:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535453430; cv=none; d=google.com; s=arc-20160816; b=k45zAxIunLWMBuYGErjsjyKE8Nlp+UGcrn9Hv+s0tCi1dKP6W8xRJCKbT856iLypg/ S/e1emvrNwMaheB/yY+yMc4qf0N6YIjrrCw1p/krnrluFhjJTu75na+jzoLRxQ008j2A xjKg+abVwBxcyAk1Z7QmuFjtHatE6M7zyFqUJce0tM+Ei4Cug+PW0qYhXVf23XNbdyfP 2m9htN4VB5glanxt6wMRnno627dXWiVUuXpGZp5HfG5tCXjgPkxWXvcrJ+I9tZAqXZsz C1F7qP8pJ4Xia+L3ukkQ2l9pDsvIzueAcr+Cyo9hXvakiD2ug+IAB0+YSb7F+fm2LIZd qOHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=Ln5y1Yo+gYULXTCibbrqQP+NAWMsdUSnY22QQBXV7YM=; b=jZVYq0SFGpYx7mEWtmSbKfQvBXIBSOJCuGRCjhMwxLTI4kSRtzHeUu9MGl2DEotNa+ La55mrv6aDhBRAz+5AszyKKvoVu4PhIOUOg/x2o5HgKdK1GIsKFvXVQSAAK4fVCUoKJ+ Vam33Iduayh9Ei2X4CVX86IKQFHBTQniWVxShTuvebAwkv/pQ3dhOe9oWhnvPQymOQOV 3Jkk8fThRQYyLzxuNUGQTPyevgxz4Ooabdx+2U/HmVN8mSMGngLO7+ybAXjwhRUtGlk4 6SXOkxfFjl5+grS9H0GkQCcYnt1V3ZWsPc4Sk8O1XXM3YpjcR9cqM8c1YrUJAVue6mZs w7lA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t67-v6si642596pfd.364.2018.08.28.03.50.14; Tue, 28 Aug 2018 03:50:30 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727599AbeH1OkJ (ORCPT + 99 others); Tue, 28 Aug 2018 10:40:09 -0400 Received: from mga07.intel.com ([134.134.136.100]:13454 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727192AbeH1OkJ (ORCPT ); Tue, 28 Aug 2018 10:40:09 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Aug 2018 03:49:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,299,1531810800"; d="scan'208";a="258666035" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.98]) ([10.237.72.98]) by fmsmga006.fm.intel.com with ESMTP; 28 Aug 2018 03:48:53 -0700 Subject: Re: [PATCH v6 3/3] mmc: sdhci-of-dwcmshc: solve 128MB DMA boundary limitation To: Jisheng Zhang , Ulf Hansson Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20180828174534.00fb5e24@xhacker.debian> <20180828174814.40dfa48f@xhacker.debian> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <6f1f9655-7fe4-a25c-c981-5027fa444334@intel.com> Date: Tue, 28 Aug 2018 13:47:12 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180828174814.40dfa48f@xhacker.debian> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/08/18 12:48, Jisheng Zhang wrote: > When using DMA, if the DMA addr spans 128MB boundary, we have to split > the DMA transfer into two so that each one doesn't exceed the boundary. > > Signed-off-by: Jisheng Zhang Acked-by: Adrian Hunter > --- > drivers/mmc/host/sdhci-of-dwcmshc.c | 39 +++++++++++++++++++++++++++++ > 1 file changed, 39 insertions(+) > > diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c > index 1b7cd144fb01..a5137845a1c7 100644 > --- a/drivers/mmc/host/sdhci-of-dwcmshc.c > +++ b/drivers/mmc/host/sdhci-of-dwcmshc.c > @@ -8,21 +8,51 @@ > */ > > #include > +#include > +#include > #include > #include > +#include > > #include "sdhci-pltfm.h" > > +#define BOUNDARY_OK(addr, len) \ > + ((addr | (SZ_128M - 1)) == ((addr + len - 1) | (SZ_128M - 1))) > + > struct dwcmshc_priv { > struct clk *bus_clk; > }; > > +/* > + * If DMA addr spans 128MB boundary, we split the DMA transfer into two > + * so that each DMA transfer doesn't exceed the boundary. > + */ > +static void dwcmshc_adma_write_desc(struct sdhci_host *host, void **desc, > + dma_addr_t addr, int len, unsigned int cmd) > +{ > + int tmplen, offset; > + > + if (likely(!len || BOUNDARY_OK(addr, len))) { > + sdhci_adma_write_desc(host, desc, addr, len, cmd); > + return; > + } > + > + offset = addr & (SZ_128M - 1); > + tmplen = SZ_128M - offset; > + sdhci_adma_write_desc(host, desc, addr, tmplen, cmd); > + > + addr += tmplen; > + len -= tmplen; > + sdhci_adma_write_desc(host, desc, addr, len, cmd); > +} > + > static const struct sdhci_ops sdhci_dwcmshc_ops = { > .set_clock = sdhci_set_clock, > .set_bus_width = sdhci_set_bus_width, > .set_uhs_signaling = sdhci_set_uhs_signaling, > .get_max_clock = sdhci_pltfm_clk_get_max_clock, > .reset = sdhci_reset, > + .adma_write_desc = dwcmshc_adma_write_desc, > }; > > static const struct sdhci_pltfm_data sdhci_dwcmshc_pdata = { > @@ -36,12 +66,21 @@ static int dwcmshc_probe(struct platform_device *pdev) > struct sdhci_host *host; > struct dwcmshc_priv *priv; > int err; > + u32 extra; > > host = sdhci_pltfm_init(pdev, &sdhci_dwcmshc_pdata, > sizeof(struct dwcmshc_priv)); > if (IS_ERR(host)) > return PTR_ERR(host); > > + /* > + * extra adma table cnt for cross 128M boundary handling. > + */ > + extra = DIV_ROUND_UP_ULL(dma_get_required_mask(&pdev->dev), SZ_128M); > + if (extra > SDHCI_MAX_SEGS) > + extra = SDHCI_MAX_SEGS; > + host->adma_table_cnt += extra; > + > pltfm_host = sdhci_priv(host); > priv = sdhci_pltfm_priv(pltfm_host); > >