From: adharmap@codeaurora.org (Abhijeet Dharmapurikar)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC 0/2] fix dma_map_sg not to do barriers for each buffer
Date: Thu, 11 Feb 2010 13:36:27 -0800 [thread overview]
Message-ID: <4B74785B.8040809@codeaurora.org> (raw)
In-Reply-To: <20100210235700.GD30854@n2100.arm.linux.org.uk>
> }
> @@ -363,7 +366,7 @@ static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
> * The device owns this memory once this call has completed. The CPU
> * can regain ownership by calling dma_unmap_page().
> */
> -static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
> +static inline dma_addr_t __dma_map_page(struct device *dev, struct page *page,
> unsigned long offset, size_t size, enum dma_data_direction dir)
> {
> BUG_ON(!valid_dma_direction(dir));
> @@ -373,6 +376,14 @@ static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
> return page_to_dma(dev, page) + offset;
> }
>
> +static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
> + unsigned long offset, size_t size, enum dma_data_direction dir)
> +{
> + dma_addr_t addr = __dma_map_page(page, offset, size, dir);
> + __dma_barrier(dir);
> + return addr;
> +}
> +
> /**
.
.
.
.
> /**
> * dma_map_sg - map a set of SG buffers for streaming mode DMA
> * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
> @@ -532,11 +539,14 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
> int i, j;
>
> for_each_sg(sg, s, nents, i) {
> - s->dma_address = dma_map_page(dev, sg_page(s), s->offset,
> + s->dma_address = __dma_map_page(dev, sg_page(s), s->offset,
> s->length, dir);
> if (dma_mapping_error(dev, s->dma_address))
> goto bad_mapping;
> }
> +
> + __dma_barrier(dir);
> +
> return nents;
>
> bad_mapping:
> @@ -564,6 +574,8 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
>
> for_each_sg(sg, s, nents, i)
> dma_unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir);
> +
> + __dma_barrier(dir);
> }
> EXPORT_SYMBOL(dma_unmap_sg);
dma_unmap_sg too could use indirection like dma_map_sg.
Thanks for the patch.
Abhijeet
next prev parent reply other threads:[~2010-02-11 21:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-10 20:37 [RFC 0/2] fix dma_map_sg not to do barriers for each buffer adharmap at codeaurora.org
2010-02-10 20:37 ` [PATCH 1/2] dma: define barrierless versions of map and unmap area adharmap at codeaurora.org
2010-02-10 20:37 ` [PATCH 2/2] dma: fix scatter-gather api to use barrierless map/unmap functions adharmap at codeaurora.org
2010-02-10 21:21 ` [RFC 0/2] fix dma_map_sg not to do barriers for each buffer Russell King - ARM Linux
2010-02-10 23:28 ` Abhijeet Dharmapurikar
2010-02-10 23:57 ` Russell King - ARM Linux
2010-02-11 21:36 ` Abhijeet Dharmapurikar [this message]
2010-02-11 10:45 ` Catalin Marinas
2010-02-11 10:53 ` Catalin Marinas
2010-02-11 11:01 ` Russell King - ARM Linux
2010-02-11 11:03 ` Catalin Marinas
2010-02-11 10:56 ` Russell King - ARM Linux
2010-02-11 19:13 ` Abhijeet Dharmapurikar
2010-02-10 21:27 ` Randy Dunlap
2010-02-10 22:40 ` Russell King - ARM Linux
2010-02-10 23:10 ` Abhijeet Dharmapurikar
2010-02-11 0:39 ` FUJITA Tomonori
2010-02-11 0:41 ` Randy Dunlap
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=4B74785B.8040809@codeaurora.org \
--to=adharmap@codeaurora.org \
--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).