linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Ian.Campbell@citrix.com (Ian Campbell)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 3/6] xen/arm: introduce xen_is_dma_coherent
Date: Fri, 24 Oct 2014 10:25:23 +0100	[thread overview]
Message-ID: <1414142723.15687.24.camel@citrix.com> (raw)
In-Reply-To: <1414085246-16160-3-git-send-email-stefano.stabellini@eu.citrix.com>

On Thu, 2014-10-23 at 18:27 +0100, Stefano Stabellini wrote:
> Introduce a utility function to check whether a device is dma coherent.
> The current implementation is suboptimal. Let's rework it later in
> common arch/arm code.
> 
> Use it to figure out whether we need to issue cache maintenance
> operations instead of checking on the existence of a particular dma_ops
> function for the device.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

As well as refactoring this also changes the nature of the test, making
it tighter AFAICT. Perhaps it is the same because you happen to know
that arm_coherent_dma_ops is the only possible one which doesn't set the
hooks you were checking before.

Either way this should be mentioned in the commit log. With that done:

Acked-by: Ian Campbell <ian.campbell@citrix.com>

> 
> ---
> 
> Changes in v5:
> - introduce xen_is_dma_coherent as a xen specific function;
> - call xen_is_dma_coherent instead of is_dma_coherent.
> ---
>  arch/arm/include/asm/xen/page-coherent.h |    5 +++++
>  arch/arm/xen/mm32.c                      |    6 +++---
>  2 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/include/asm/xen/page-coherent.h b/arch/arm/include/asm/xen/page-coherent.h
> index e8275ea..6f0f882 100644
> --- a/arch/arm/include/asm/xen/page-coherent.h
> +++ b/arch/arm/include/asm/xen/page-coherent.h
> @@ -5,6 +5,11 @@
>  #include <linux/dma-attrs.h>
>  #include <linux/dma-mapping.h>
>  
> +static inline bool xen_is_dma_coherent(struct device *dev)
> +{
> +    return (__generic_dma_ops(dev) == &arm_coherent_dma_ops);
> +}
> + 
>  static inline void *xen_alloc_coherent_pages(struct device *hwdev, size_t size,
>  		dma_addr_t *dma_handle, gfp_t flags,
>  		struct dma_attrs *attrs)
> diff --git a/arch/arm/xen/mm32.c b/arch/arm/xen/mm32.c
> index 6153d61..6c0224e 100644
> --- a/arch/arm/xen/mm32.c
> +++ b/arch/arm/xen/mm32.c
> @@ -76,7 +76,7 @@ void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
>  		struct dma_attrs *attrs)
>  
>  {
> -	if (!__generic_dma_ops(hwdev)->unmap_page)
> +	if (xen_is_dma_coherent(hwdev))
>  		return;
>  	if (dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
>  		return;
> @@ -87,7 +87,7 @@ void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle,
>  void xen_dma_sync_single_for_cpu(struct device *hwdev,
>  		dma_addr_t handle, size_t size, enum dma_data_direction dir)
>  {
> -	if (!__generic_dma_ops(hwdev)->sync_single_for_cpu)
> +	if (xen_is_dma_coherent(hwdev))
>  		return;
>  	__xen_dma_page_dev_to_cpu(hwdev, handle, size, dir);
>  }
> @@ -95,7 +95,7 @@ void xen_dma_sync_single_for_cpu(struct device *hwdev,
>  void xen_dma_sync_single_for_device(struct device *hwdev,
>  		dma_addr_t handle, size_t size, enum dma_data_direction dir)
>  {
> -	if (!__generic_dma_ops(hwdev)->sync_single_for_device)
> +	if (xen_is_dma_coherent(hwdev))
>  		return;
>  	__xen_dma_page_cpu_to_dev(hwdev, handle, size, dir);
>  }

  reply	other threads:[~2014-10-24  9:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-23 17:26 [PATCH v5 0/6] introduce GNTTABOP_cache_flush Stefano Stabellini
2014-10-23 17:27 ` [PATCH v5 1/6] xen/arm: remove handling of XENFEAT_grant_map_identity Stefano Stabellini
2014-10-23 17:27 ` [PATCH v5 2/6] xen/arm: remove outer_*_range call Stefano Stabellini
2014-10-24  9:23   ` Ian Campbell
2014-10-23 17:27 ` [PATCH v5 3/6] xen/arm: introduce xen_is_dma_coherent Stefano Stabellini
2014-10-24  9:25   ` Ian Campbell [this message]
2014-10-23 17:27 ` [PATCH v5 4/6] xen/arm/arm64: merge xen/mm32.c into xen/mm.c Stefano Stabellini
2014-10-24  9:28   ` Ian Campbell
2014-10-23 17:27 ` [PATCH v5 5/6] xen/arm/arm64: introduce xen_arch_need_swiotlb Stefano Stabellini
2014-10-24  9:30   ` Ian Campbell
2014-10-23 17:27 ` [PATCH v5 6/6] xen/arm: introduce GNTTABOP_cache_flush Stefano Stabellini

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=1414142723.15687.24.camel@citrix.com \
    --to=ian.campbell@citrix.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).