Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758979AbcCDP5d (ORCPT ); Fri, 4 Mar 2016 10:57:33 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:51723 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756841AbcCDP53 (ORCPT ); Fri, 4 Mar 2016 10:57:29 -0500 From: Arnd Bergmann To: Alexandre Courbot Cc: Ulf Hansson , Adrian Hunter , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, gnurou@gmail.com Subject: Re: [PATCH v3 1/3] mmc: sdhci: Set DMA mask when adding host Date: Fri, 04 Mar 2016 16:57:15 +0100 Message-ID: <2562091.6cJRuD3dK9@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <1457087925-992-2-git-send-email-acourbot@nvidia.com> References: <1457087925-992-1-git-send-email-acourbot@nvidia.com> <1457087925-992-2-git-send-email-acourbot@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:2tobEw3a1pJInzjtHLUXGVhPhlOqLXyKSbv4vT0jnpDPdSuKSrG GC41wtdjCT31IzAnsGivJH3TS5NaqjfNB38lFAv9uuhECtRR+MydaSC8/dx1izgr1aXlEI8 3SJxK53mMA/4SUQ9mTopr+8AvKtzyaPQ563XARqu32QKnjPvZap23/Vd3CiMqyLsJw8Sz1i GfcbnBr+08Z+XoB8VgxZA== X-UI-Out-Filterresults: notjunk:1;V01:K0:cfLjWifinTk=:67t1BE7z3gW+AtOevFaSFo 0pwInUq6OMvPWQm+Kup1CL3fEn8JHbbUYXAJjU5XLPzuG9DpHgWGHaIHs/VQ7LSxzyb07Wh+o mJvpGXOrz4qyyrp3nd06YaaJ08SG8JG/iOBaiCJap35WRyg7dfoi+3sIVcURffmmOjatKdjWE 9qP0jojBCfe5ORaXjtGbpngl9Xm74YiIMrSU8eoylj8OWiGQXLzJi6Q5KepLVj+0KOCFoHK9G pkn2YZ9nAfX512TXOJw2eW7Wd3mVZazt1jxZkwAOV9GeIA79uUqfo1ZrD1jKspokjzzUcYYsk 6R+FDTRBhONuzufOu9f5+0cCPlhvdD4pWqV4nZKBSGC9HiotWv8xGCL3LIbCAwRVaVBlNWKsd zl7PhA5yLUgx0S5zw9C2m9dM9WtFfTBZmzmLUe2vietDNU4UDFu180Ypb+ZK2h+yhuS+X+2Im SoZgRJKWRjdrhZSDQXpNFx8aIYptT2q+XuQXb2l2at2DDVCXUGqRB31DWfbh1gq8OOoa9p9zE 7p1CMpN++DNZp7JX1ypKvOZJLBt3LJSOcxQTSGRY2gUMjAfQqmOlCJScPQTgWAdG7/aS1+2Vu kn4+Ep6AKg/0ooTz9i+Sfph81L4SzVHhv1dyDmucn/GLrDKNHEEP4VR4WjL4ewYyNIJA+vgyj VcLZ9BBCvgVf8PUnQ1B+qjmSTa/XTqNloEeTCJSkBZt42q/4oeZXCtqlGm65vCWKIj2ru/ayE f4wryx0AA4CTvU46 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1524 Lines: 43 On Friday 04 March 2016 19:38:43 Alexandre Courbot wrote: > Set the DMA mask in sdhci_add_host() after we determined the > capabilities of the device. 64-bit devices in particular are given the > proper mask that ensures bounce buffers are not used. > > Also disable DMA if no proper DMA mask can be set, as the DMA-API > documentation specifies. > > Signed-off-by: Alexandre Courbot > --- > drivers/mmc/host/sdhci.c | 46 +++++++++++++++++++++++++++++++++++++++------- > 1 file changed, 39 insertions(+), 7 deletions(-) > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > index fd9139947fa3..00fb45ba6f39 100644 > --- a/drivers/mmc/host/sdhci.c > +++ b/drivers/mmc/host/sdhci.c > @@ -2857,6 +2857,34 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev, > > EXPORT_SYMBOL_GPL(sdhci_alloc_host); > > +static int sdhci_set_dma_mask(struct sdhci_host *host) > +{ > + struct mmc_host *mmc = host->mmc; > + struct device *dev = mmc_dev(mmc); > + int ret = -EINVAL; > + > + if (host->quirks2 & SDHCI_QUIRK2_BROKEN_64_BIT_DMA) > + host->flags &= ~SDHCI_USE_64_BIT_DMA; > + > + /* Try 64-bit mask if hardware is capable of it */ > + if (host->flags & SDHCI_USE_64_BIT_DMA) { > + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)); > + if (ret) > + pr_warn("%s: Failed to set 64-bit DMA mask.\n", > + mmc_hostname(mmc)); > + } > + I think you need to disable the SDHCI_USE_64_BIT_DMA flag when dma_set_mask_and_coherent() fails here. Otherwise looks good. Arnd