From patchwork Mon Nov 27 10:28:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 119663 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp45464qgn; Mon, 27 Nov 2017 02:29:07 -0800 (PST) X-Received: by 10.25.20.77 with SMTP id k74mr11027601lfi.80.1511778547034; Mon, 27 Nov 2017 02:29:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511778547; cv=none; d=google.com; s=arc-20160816; b=CnBekGIW+FSS+AmzqWZN2sbuwak9adWOZhsM9RPoWH+N7n053wtKLz8rir+vntzKoQ 9RbQru4BAFBQ4WhJTxNeDH7PcSJ16aUjKBHWE1ll3QtuE/OnEbBNl0uaNzKnCOhDMqlf mIrVtZQcqy+ofxOjRo0/AghPpfoJCzcpAHHhpR0qwc0ElBC3mdlzY34/Zr0eQ0pNJhMx 8aOsjflGxK8a24dDEVFYcK7IL8Z3/gDvKCFUTL+B3OkZaql0jjyCQoAQpELgKey5yAfR HMO7g9tfdn2b/i8NBQAblRXWDtYTXOSLxUZdlyYASCMxEPhHTIGlPh+56QUVdjiTE3It Y57g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=ALwDvPcUbqyUyhpQ3kQ4hMyTLs1i0qVU2Qied8ZNsXk=; b=j4dxvSVoEopOVMEMR8jJVc4oR3/q//Za8o1RUnnCa/1aGOs4rG69qxl96QvO00uvUQ WDQAVsWSCOhA9WNwmMdrs1loCFhaEQZqDW9vqMqB5fpuyCajKK0Q33IQuNujiShgN0PM ftcfSUQbH92YAg1ow1IS5LVNFTHeVLmPEYM/P33/Zqn2rTCzh7vvKRzmhNWIoaoXVy2c x6GNDfz7OatbhM4R22mkDEChX+6zFVu7ufK7qb4mLWoqg+mIxoY0eKOFRRDbzqqvu2a5 FlN4JAIWSjNBV9P5WIJullir7pY9A4pGf/BBDdAH0rPWfyVr1gEc52szy3pknTI82nXP 0p8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DngZRThd; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id h83sor3793874ljf.39.2017.11.27.02.29.06 for (Google Transport Security); Mon, 27 Nov 2017 02:29:06 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DngZRThd; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=ALwDvPcUbqyUyhpQ3kQ4hMyTLs1i0qVU2Qied8ZNsXk=; b=DngZRThdwXMYV61ghCeOv8FNZ7a9rn5NDMchn+KbHM9U29a9tNVxTP3Gr2GhKzmAoo paTgck/+dUHZotvLq52riXlodwr5RsFKFkY5UyTkHOde2nurH59DLBsw8uiHpZ4WrXpn 0Aj/E9UlkxTWOrcrwVASsOuuw8ZrLB5+tLOtI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ALwDvPcUbqyUyhpQ3kQ4hMyTLs1i0qVU2Qied8ZNsXk=; b=gJxl2jveV1B4OWkDB+QNnMe7po3kshrIdANlSKClUtA6BYP7N59ECdyybQ7XPOmJdv tHPaiNdtCmXouZTQ7kNwSHmNHxFhtduX3Uufg/suIJMZUNJXj+PuPzVXjNpgAFb7oEa8 TmB+3UGfPxUlXNWh3s8Mf1G/eMoHWviuGcuolS8a9b2t1lkk1j0I+UVkLbJre3ryKMlY /CSj21JpkwyGk6t9UgayfzXeJG52+UNcV/ckXoTS6+70E8Yip1qc95NB5F9VxY00lEOL zTTGunzGkp1DvRjfCEA2mheh9g5bfj0UfZ5WWYTckW3/q54kaZDEG3CgCExdhFsE55/8 ZsAw== X-Gm-Message-State: AJaThX5Mx1E8JvR4BrkKo/wpn69HYRTvjrBRNLBCVLDUsZNKY322O+4i MC40loCx8xfWwtHiM4a9+hq092jV X-Google-Smtp-Source: AGs4zMadHYFrIqdUQ2uQmjMIiawXIOBOu1DZv/rJRRR0jGpTaUd/z4Je/LiQX9cr07djRdoLETmpeg== X-Received: by 10.46.17.18 with SMTP id f18mr13147561lje.167.1511778546368; Mon, 27 Nov 2017 02:29:06 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id l85sm5973457lje.72.2017.11.27.02.29.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Nov 2017 02:29:05 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Adrian Hunter , Linus Walleij Cc: Ulf Hansson , Linus , Yoshihiro Shimoda , Geert Uytterhoeven , Konrad Rzeszutek Wilk , Jiri Slaby , "# v4 . 14+" Subject: [PATCH] mmc: sdhci: Avoid swiotlb buffer being full Date: Mon, 27 Nov 2017 11:28:50 +0100 Message-Id: <1511778530-6761-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 The commit de3ee99b097d ("mmc: Delete bounce buffer handling") deletes the bounce buffer handling, but also causes the max_req_size for sdhci to be increased, in case when max_segs == 1. This causes errors for sdhci-pci Ricoh variant, about the swiotlb buffer to become full. Fix the issue, by taking IO_TLB_SEGSIZE and IO_TLB_SHIFT into account when deciding the max_req_size for sdhci. Reported-by: Jiri Slaby Fixes: de3ee99b097d ("mmc: Delete bounce buffer handling") Cc: # v4.14+ Signed-off-by: Ulf Hansson Tested-by: Jiri Slaby --- drivers/mmc/host/sdhci.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) -- 2.7.4 Acked-by: Adrian Hunter diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 2f14334..e9290a3 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -3651,22 +3652,29 @@ int sdhci_setup_host(struct sdhci_host *host) spin_lock_init(&host->lock); /* + * Maximum number of sectors in one transfer. Limited by SDMA boundary + * size (512KiB). Note some tuning modes impose a 4MiB limit, but this + * is less anyway. + */ + mmc->max_req_size = 524288; + + /* * Maximum number of segments. Depends on if the hardware * can do scatter/gather or not. */ - if (host->flags & SDHCI_USE_ADMA) + if (host->flags & SDHCI_USE_ADMA) { mmc->max_segs = SDHCI_MAX_SEGS; - else if (host->flags & SDHCI_USE_SDMA) + } else if (host->flags & SDHCI_USE_SDMA) { mmc->max_segs = 1; - else /* PIO */ + if (swiotlb_max_segment()) { + unsigned int max_req_size = (1 << IO_TLB_SHIFT) * + IO_TLB_SEGSIZE; + mmc->max_req_size = min(mmc->max_req_size, + max_req_size); + } + } else { /* PIO */ mmc->max_segs = SDHCI_MAX_SEGS; - - /* - * Maximum number of sectors in one transfer. Limited by SDMA boundary - * size (512KiB). Note some tuning modes impose a 4MiB limit, but this - * is less anyway. - */ - mmc->max_req_size = 524288; + } /* * Maximum segment size. Could be one segment with the maximum number