mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Huacai Chen <chenhc@lemote.com>, Christoph Hellwig <hch@lst.de>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Fuxin Zhang <zhangfx@lemote.com>,
	linux-kernel@vger.kernel.org,
	"James E . J . Bottomley" <jejb@linux.vnet.ibm.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH V6 1/3] dma-mapping: Introduce device_is_coherent() as a helper
Date: Thu, 21 Sep 2017 11:47:30 +0100	[thread overview]
Message-ID: <5e792b21-1d63-9200-b36a-c423385e2a2e@arm.com> (raw)
In-Reply-To: <1505811161-25246-1-git-send-email-chenhc@lemote.com>

On 19/09/17 09:52, Huacai Chen wrote:
> We will use device_is_coherent() as a helper function, which will be
> used in the next patch.
> 
> There is a MIPS-specific plat_device_is_coherent(), but we need a more
> generic solution, so add and use a new function pointer in dma_map_ops.

I think we're heading in the right direction with the series, but I
still don't like this patch. I can pretty much guarantee that driver
authors *will* abuse a generic device_is_coherent() API to mean "I can
skip other DMA API calls and just use virt_to_phys()".

I think it would be far better to allow architectures to provide their
own override of dma_get_cache_alignment(), and let the coherency detail
remain internal to the relevant arch implementations.

[...]
> @@ -697,6 +698,15 @@ static inline void *dma_zalloc_coherent(struct device *dev, size_t size,
>  }
>  
>  #ifdef CONFIG_HAS_DMA
> +static inline int device_is_coherent(struct device *dev)
> +{
> +	const struct dma_map_ops *ops = get_dma_ops(dev);
> +	if (ops && ops->device_is_coherent)
> +		return ops->device_is_coherent(dev);
> +	else
> +		return 1;    /* compatible behavior */

That is also quite scary - if someone now adds a new
dma_get_cache_alignemnt() call and dutifully passes a non-NULL device,
they will now get back an alignment of 1 on all non-coherent platforms
except MIPS: hello data corruption.

Robin.

> +}
> +
>  static inline int dma_get_cache_alignment(void)
>  {
>  #ifdef ARCH_DMA_MINALIGN
> 

  parent reply	other threads:[~2017-09-21 10:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-19  8:52 Huacai Chen
2017-09-19  8:52 ` [PATCH V6 2/3] dma-mapping: Rework dma_get_cache_alignment() function Huacai Chen
2017-09-19 15:02   ` Christoph Hellwig
2017-09-21  4:28     ` [PATCH V6 2/3] dma-mapping: Rework dma_get_cache_alignment()function 陈华才
2017-09-21 14:36       ` Christoph Hellwig
2017-09-19  8:52 ` [PATCH V6 3/3] scsi: Align block queue to dma_get_cache_alignment() Huacai Chen
2017-09-24  3:45   ` kbuild test robot
2017-09-21 10:47 ` Robin Murphy [this message]
2017-09-22  2:13   ` [PATCH V6 1/3] dma-mapping: Introduce device_is_coherent() as ahelper 陈华才
2017-09-22 13:44     ` Robin Murphy
2017-09-22 13:49       ` Christoph Hellwig

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=5e792b21-1d63-9200-b36a-c423385e2a2e@arm.com \
    --to=robin.murphy@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=chenhc@lemote.com \
    --cc=hch@lst.de \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=martin.petersen@oracle.com \
    --cc=stable@vger.kernel.org \
    --cc=zhangfx@lemote.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

all inboxes | Powered by JetHome®