From patchwork Mon Dec 2 14:41:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Nie X-Patchwork-Id: 180611 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp43953ile; Mon, 2 Dec 2019 06:41:35 -0800 (PST) X-Google-Smtp-Source: APXvYqzjVBB8kChMxdb2Xcp/to9GHMBLyxmbcdCkGU9kw9keJzNzBaCAu9DdZdgQdNDzl4xWdLKH X-Received: by 2002:a17:906:27cb:: with SMTP id k11mr15202961ejc.301.1575297695104; Mon, 02 Dec 2019 06:41:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575297695; cv=none; d=google.com; s=arc-20160816; b=NMyw4q+XEzjL80fgu4+b09DqruI/32RUnCCQ8KqbEAQ02WBPgbqMY81bjTN70FLBKn +CXVHmMwT4jiDIRTNQude9YdUW7vJleDNci9J6+3yl64nmLGxzPHKyQ1HthfYAIlv6wK y4sXqV4uSdyyOFKl/R3fHnxI872XFpR1Cp09D9Yk6F4V573YuAZTkwoVq18oushpCY0H OhMhzg0NL8SKKKP94L0AQpjNA0qxawXz3NPSg2uoPgAxv7HGXUXULAT1KjgYogdhEuS8 AwSprCfpgPUb8oi49VmPUt5luKqILN5iJ8pBMWSXDbd0jpBUq2wwb9iU0sdJfRU0TtCK Ae4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature; bh=fNax18wcX7C+XdcgmNwyCdos/DnS6CZj6Krn7yJuSLo=; b=at2h4hX/aSTDNngEavXAMAoFTfzxExpms41zUI74R8kkR47JuhjVmxVRPLqvKBtxF6 n3HT7wzBmvktaIdh9RinBpaXWkgTU4W6vRtLaJWmxEseMDwsWx90Hrg6K5p0lMh8OE0e WRwLcfZkfniOdWi5fdK4O28OsYXuaZBVXQ2PdsI/HlQoNUF2iEt0H3llchIZHeA46X++ YKt9uhWJW9GtlKeHYKbRJvmo+/hH1isXgAFDo9f0fks7LekVQ0qnzJ3Ym0qBPUyMn/f/ +uQyLd5V2S32RtChQ1dxFLF6Cmq/gNcxHiWkU9fevOn3xIQmMfzW/fb2UHUNFo5Y/GN5 /1nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m5Uu3YHI; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k2si9723359edn.314.2019.12.02.06.41.34; Mon, 02 Dec 2019 06:41:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-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=@linaro.org header.s=google header.b=m5Uu3YHI; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727455AbfLBOle (ORCPT + 8 others); Mon, 2 Dec 2019 09:41:34 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:46110 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727362AbfLBOle (ORCPT ); Mon, 2 Dec 2019 09:41:34 -0500 Received: by mail-pg1-f194.google.com with SMTP id z124so2729535pgb.13 for ; Mon, 02 Dec 2019 06:41:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=fNax18wcX7C+XdcgmNwyCdos/DnS6CZj6Krn7yJuSLo=; b=m5Uu3YHIeYeg96UchN1ICA2XS9xrqWDvhzV8iBxlPBvWvJKjVqdt2c7R4dZ5nURmVS 6wFKRS/SwANUkaO5xasMyV8Dpp8ANEExTB1O5Q5WcCNm6KIfotVxT+L9tMW+Pp3f0WwI dNe3dkNPOit1wZwXsidSLLPxKPTiaRxSvBfe4GcjwZq8x6hLPV38mrabLVRYa0xVGbQx dDhT6aUTDMcoYAaHTGfODhPH3C9fkFsM+P8AgzaTaBZpoxcZu4xapFAKYy8J1ZqwGqyJ ccnbntgdYljcYcerWZzpJ5Wis9aBCBjOfiQEHjQDgJugGOCWrKxIGFoTCikL1xpDlr7C MnDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=fNax18wcX7C+XdcgmNwyCdos/DnS6CZj6Krn7yJuSLo=; b=cjDplySnIktFnBcQ4/HFq/Mgseoiy+NQyumDAoqja2wKjolEM+rjyOy8Tujc8sEfBL +Qlcm47UTD157/2nKjSsDoaK0r30d+jX4INvWDmEJo8Ev6QofSrpubkDcRFT5swoWXRs sJuGsLUAR1eaqVYOiKG9mv1q3yLIf+5/q3EgzEKZIAtffLeqyRxnR2CZ22DMwuDrhRiK uKeqPMUzAh2433pfuukzBHMpz85QCi2J0f9RIs/eXO8DS6qd48R5yot883HYQ7pEfQMN UNQZjthJXhCsd1fjRB33lBhxR1Hoi7Mz7wN8Q0Jww7kQpk0oFLFpa9zNf81AUXv2ans+ uHhQ== X-Gm-Message-State: APjAAAXU07q8oEZirKCf6dILhTkJR0xhYdmU/0byAPCVLjByqNdWGyfz MTKNGNo+UfJFrDDQCvAFzWkyXg== X-Received: by 2002:aa7:870c:: with SMTP id b12mr12542985pfo.82.1575297693583; Mon, 02 Dec 2019 06:41:33 -0800 (PST) Received: from localhost.localdomain (li519-153.members.linode.com. [66.175.222.153]) by smtp.gmail.com with ESMTPSA id f30sm33985090pga.20.2019.12.02.06.41.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 06:41:33 -0800 (PST) From: Jun Nie To: ulf.hansson@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, adrian.hunter@intel.com, linux-mmc@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 4/4] mmc: sdhci: Add DMA memory boundary workaround Date: Mon, 2 Dec 2019 22:41:04 +0800 Message-Id: <20191202144104.5069-5-jun.nie@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191202144104.5069-1-jun.nie@linaro.org> References: <20191202144104.5069-1-jun.nie@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org DMA memory cannot cross specific boundary for some SDHCI controller, such as DesignWare SDHCI controller. Add DMA memory boundary dt property and workaround the limitation. Signed-off-by: Jun Nie --- drivers/mmc/host/sdhci.c | 20 +++++++++++++++++++- drivers/mmc/host/sdhci.h | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index d8a6c1c91448..56c53fbadd9d 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -763,9 +763,25 @@ static void sdhci_adma_table_pre(struct sdhci_host *host, BUG_ON(len > 65536); /* tran, valid */ - if (len) + if (len) { + unsigned int boundary = host->dma_mem_boundary; + /* + * work around for buffer across mem boundary, split + * the buffer. + */ + if (boundary && + ((addr & (boundary - 1)) + len) > boundary) { + offset = boundary - (addr & (boundary - 1)); + __sdhci_adma_write_desc(host, &desc, + addr, offset, + ADMA2_TRAN_VALID); + addr += offset; + len -= offset; + } + __sdhci_adma_write_desc(host, &desc, addr, len, ADMA2_TRAN_VALID); + } /* * If this triggers then we have a calculation bug @@ -3634,6 +3650,8 @@ void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver, "sdhci-caps-mask", &dt_caps_mask); of_property_read_u64(mmc_dev(host->mmc)->of_node, "sdhci-caps", &dt_caps); + of_property_read_u32(mmc_dev(host->mmc)->of_node, + "sdhci-dma-mem-boundary", &host->dma_mem_boundary); if (of_property_read_u32(mmc_dev(host->mmc)->of_node, "sdhci-ctrl-hs400", &host->sdhci_ctrl_hs400)) diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index cac4d819f62c..954ac08c4fb0 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -608,6 +608,7 @@ struct sdhci_host { /* SDHCI_CTRL_HS400 value */ u32 sdhci_ctrl_hs400; + u32 dma_mem_boundary; unsigned long private[0] ____cacheline_aligned; };