linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 6/7] ACPI/IORT: Don't set default coherent DMA mask
Date: Wed, 25 Jul 2018 16:27:47 +0100	[thread overview]
Message-ID: <20180725152747.GA5080@red-moon> (raw)
In-Reply-To: <3525869e8e7530128bf9718ae8af7d7564b3c684.1532382222.git.robin.murphy@arm.com>

On Mon, Jul 23, 2018 at 11:16:11PM +0100, Robin Murphy wrote:
> Now that we can track upstream DMA constraints properly with
> bus_dma_mask instead of trying (and failing) to maintain it in
> coherent_dma_mask, it doesn't make much sense for the firmware code to
> be touching the latter at all. It's merely papering over bugs wherein a
> driver has failed to call dma_set_coherent_mask() *and* the bus code has
> not initialised any default value.

Nit: I do not think the driver had a chance to probe and therefore call
dma_set_coherent_mask() before iort_dma_setup() is executed, right ?

Anyway, the patch makes perfect sense:

Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

> We don't really want to encourage more drivers coercing dma_mask so
> we'll continue to fix that up if necessary, but add a warning to help
> flush out any such buggy bus code that remains.
> 
> CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> CC: Hanjun Guo <hanjun.guo@linaro.org>
> CC: Sudeep Holla <sudeep.holla@arm.com>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>  drivers/acpi/arm64/iort.c | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
> index bc51cff5505e..08f26db2da7e 100644
> --- a/drivers/acpi/arm64/iort.c
> +++ b/drivers/acpi/arm64/iort.c
> @@ -978,20 +978,20 @@ void iort_dma_setup(struct device *dev, u64 *dma_addr, u64 *dma_size)
>  	int ret, msb;
>  
>  	/*
> -	 * Set default coherent_dma_mask to 32 bit.  Drivers are expected to
> -	 * setup the correct supported mask.
> +	 * If @dev is expected to be DMA-capable then the bus code that created
> +	 * it should have initialised its dma_mask pointer by this point. For
> +	 * now, we'll continue the legacy behaviour of coercing it to the
> +	 * coherent mask if not, but we'll no longer do so quietly.
>  	 */
> -	if (!dev->coherent_dma_mask)
> -		dev->coherent_dma_mask = DMA_BIT_MASK(32);
> -
> -	/*
> -	 * Set it to coherent_dma_mask by default if the architecture
> -	 * code has not set it.
> -	 */
> -	if (!dev->dma_mask)
> +	if (!dev->dma_mask) {
> +		dev_warn(dev, "DMA mask not set\n");
>  		dev->dma_mask = &dev->coherent_dma_mask;
> +	}
>  
> -	size = max(dev->coherent_dma_mask, dev->coherent_dma_mask + 1);
> +	if (dev->coherent_dma_mask)
> +		size = max(dev->coherent_dma_mask, dev->coherent_dma_mask + 1);
> +	else
> +		size = 1ULL << 32;
>  
>  	if (dev_is_pci(dev)) {
>  		ret = acpi_dma_get_range(dev, &dmaaddr, &offset, &size);
> -- 
> 2.17.1.dirty
> 

  reply	other threads:[~2018-07-25 15:27 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-23 22:16 [PATCH v2 0/7] Stop losing firmware-set DMA masks Robin Murphy
2018-07-23 22:16 ` [PATCH v2 1/7] ACPI/IORT: Support address size limit for root complexes Robin Murphy
2018-07-23 22:16 ` [PATCH v2 2/7] dma-mapping: Generalise dma_32bit_limit flag Robin Murphy
2018-07-25 11:29   ` Christoph Hellwig
2018-07-27 17:45   ` Grygorii Strashko
2018-07-27 20:11     ` Robin Murphy
2018-07-27 20:41       ` Grygorii Strashko
2018-07-23 22:16 ` [PATCH v2 3/7] ACPI/IORT: Set bus DMA mask as appropriate Robin Murphy
2018-07-25 11:29   ` Christoph Hellwig
2018-07-25 13:16   ` Lorenzo Pieralisi
2018-07-23 22:16 ` [PATCH v2 4/7] of/device: " Robin Murphy
2018-07-25 11:30   ` Christoph Hellwig
2018-07-23 22:16 ` [PATCH v2 5/7] iommu/dma: Respect bus DMA limit for IOVAs Robin Murphy
2018-07-26  8:58   ` Christoph Hellwig
2018-07-23 22:16 ` [PATCH v2 6/7] ACPI/IORT: Don't set default coherent DMA mask Robin Murphy
2018-07-25 15:27   ` Lorenzo Pieralisi [this message]
2018-07-25 15:43     ` Robin Murphy
2018-07-23 22:16 ` [PATCH v2 7/7] OF: " Robin Murphy
2018-07-26 23:52   ` Grygorii Strashko
2018-07-27  0:22     ` Grygorii Strashko
2018-07-27 11:36       ` Robin Murphy
2018-07-27 17:34         ` Grygorii Strashko
2018-07-27 19:46           ` Robin Murphy
2018-07-27 18:13         ` Russell King - ARM Linux
2018-07-27 18:45           ` Grygorii Strashko
2018-07-27 20:42             ` Robin Murphy
2018-07-27 19:29           ` Robin Murphy
2018-07-25 11:31 ` [PATCH v2 0/7] Stop losing firmware-set DMA masks Christoph Hellwig
2018-07-25 12:11   ` Joerg Roedel
2018-07-25 12:12   ` Robin Murphy
2018-07-25 12:17     ` Will Deacon
2018-07-25 13:58   ` Ard Biesheuvel
2018-07-26  9:00 ` Christoph Hellwig
2018-07-26 23:45 ` Grygorii Strashko
2018-07-27 10:55   ` Robin Murphy
2018-07-27 17:22     ` Grygorii Strashko
2018-07-29 12:32 ` Arnd Bergmann
2018-07-31 11:24   ` Robin Murphy
2018-08-06 10:01     ` Arnd Bergmann
2018-08-06 12:13       ` Christoph Hellwig
2018-08-06 12:13         ` Arnd Bergmann

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=20180725152747.GA5080@red-moon \
    --to=lorenzo.pieralisi@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).