linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Sowjanya Komatineni <skomatineni@nvidia.com>,
	Krishna Reddy <vdumpa@nvidia.com>,
	linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] mmc: sdhci: Properly set DMA mask
Date: Thu, 10 Jan 2019 11:59:11 +0100	[thread overview]
Message-ID: <20190110105911.GA32301@ulmo> (raw)
In-Reply-To: <20190104174354.GA18110@infradead.org>

[-- Attachment #1: Type: text/plain, Size: 1725 bytes --]

On Fri, Jan 04, 2019 at 09:43:54AM -0800, Christoph Hellwig wrote:
> > +	u64 dma_mask = dma_get_mask(dev);
> 
> This is not a driver API.  I think what you want is
> dma_get_required_mask to query the mask.  But in that case
> you still need to always actually set a mask in the driver as well.

That's slightly different from what I want to do here. The purpose of
this part of the patch is that when the SDHCI hardware supports only 32
bits of address space, then we want to prevent 64-bit addressing mode
from being used because it isn't useful.

So what we do want to check here is the DMA mask configured by the
driver (or the default set by the bus, or wherever it came from).
dma_get_required_mask() returns the DMA mask required to address all of
system memory. That would perhaps be a useful additional check, but it's
orthogonal to what I'm trying to do here.

Is there something else appropriate that I could use to query the DMA
mask set for a device?

Thierry

> Something like this patch:
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index a22e11a65658..36c61778d8f3 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -3500,6 +3500,13 @@ static int sdhci_set_dma_mask(struct sdhci_host *host)
>  	struct device *dev = mmc_dev(mmc);
>  	int ret = -EINVAL;
>  
> +	/*
> +	 * Systems that can't address more than 32-bits do not need to use
> +	 * 64-bit addressing mode, even if the device supports it.
> +	 */
> +	if (dma_get_required_mask(dev) <= DMA_BIT_MASK(32))
> +		host->flags &= ~SDHCI_USE_64_BIT_DMA;
> +
>  	if (host->quirks2 & SDHCI_QUIRK2_BROKEN_64_BIT_DMA)
>  		host->flags &= ~SDHCI_USE_64_BIT_DMA;
>  

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-01-10 10:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-04 10:47 [PATCH 1/2] mmc: sdhci: Properly set DMA mask Thierry Reding
2019-01-04 10:47 ` [PATCH 2/2] mmc: sdhci: tegra: Set DMA mask depending on generation Thierry Reding
2019-01-04 17:43 ` [PATCH 1/2] mmc: sdhci: Properly set DMA mask Christoph Hellwig
2019-01-10 10:59   ` Thierry Reding [this message]
2019-01-14 11:09     ` Christoph Hellwig
2019-01-10 14:11 ` Adrian Hunter
2019-01-10 16:01   ` Thierry Reding
2019-01-10 18:22     ` Hunter, Adrian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190110105911.GA32301@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=adrian.hunter@intel.com \
    --cc=hch@infradead.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=skomatineni@nvidia.com \
    --cc=ulf.hansson@linaro.org \
    --cc=vdumpa@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).