linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Becky Bruce <becky.bruce@freescale.com>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: [PATCH] powerpc: Add sync_*_for_* to dma_ops
Date: Tue, 18 Nov 2008 23:22:29 +1100	[thread overview]
Message-ID: <1227010949.7178.308.camel@pasglop> (raw)
In-Reply-To: <1226953165-19305-1-git-send-email-becky.bruce@freescale.com>


>  				dma_addr_t dma_address, size_t size,
>  				enum dma_data_direction direction,
>  				struct dma_attrs *attrs);
> +	void            (*sync_single_for_cpu)(struct device *hwdev,
> +				dma_addr_t dma_handle, size_t size,
> +				enum dma_data_direction direction);
> +	void            (*sync_single_for_device)(struct device *hwdev,
> +				dma_addr_t dma_handle, size_t size,
> +				enum dma_data_direction direction);
> +	void            (*sync_single_range_for_cpu)(struct device *hwdev,
> +				dma_addr_t dma_handle, unsigned long offset,
> +				size_t size,
> +				enum dma_data_direction direction);
> +	void            (*sync_single_range_for_device)(struct device *hwdev,
> +				dma_addr_t dma_handle, unsigned long offset,
> +				size_t size,
> +				enum dma_data_direction direction);

Can't we implement the first 2 using the next 2 and passing a 0 offset ?
I mean, we're going to go through a function pointer, it's not like
handling the offset was going to cost us something :-)

> +	void            (*sync_sg_for_cpu)(struct device *hwdev,
> +				struct scatterlist *sg, int nelems,
> +				enum dma_data_direction direction);
> +	void            (*sync_sg_for_device)(struct device *hwdev,
> +				struct scatterlist *sg, int nelems,
> +				enum dma_data_direction direction);
>  };
>  
>  /*
> @@ -286,42 +306,75 @@ static inline void dma_sync_single_for_cpu(struct device *dev,
>  		dma_addr_t dma_handle, size_t size,
>  		enum dma_data_direction direction)
>  {
> -	BUG_ON(direction == DMA_NONE);
> -	__dma_sync(bus_to_virt(dma_handle), size, direction);
> +	struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
> +
> +	BUG_ON(!dma_ops);
> +	if (dma_ops->sync_single_for_cpu != NULL)
> +		dma_ops->sync_single_for_cpu(dev, dma_handle, size,
> +					     direction);
>  }

 .../...

The only objection that comes to mind here is that generally, you know
that your platform is going to be coherent or not at compile time, and
you don't want the above at all when it is (or won't need swiotlb).

So maybe we could have a Kconfig trickery so that
CONFIG_PPC_DMA_NEED_SYNC_OPS is set when either non coherent DMA is
select'ed or swiotlb support is select'ed by one of the enabled
platform. So if I enable only powermac, I get neither and don't get the
bloody inlines :-)

Cheers,
Ben.

  reply	other threads:[~2008-11-18 12:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-17 20:19 [PATCH] powerpc: Add sync_*_for_* to dma_ops Becky Bruce
2008-11-18 12:22 ` Benjamin Herrenschmidt [this message]
2008-11-18 16:03   ` Becky Bruce
2008-11-18 16:57 ` Segher Boessenkool
2008-11-18 19:29   ` Becky Bruce

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=1227010949.7178.308.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=becky.bruce@freescale.com \
    --cc=linuxppc-dev@ozlabs.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).