sdio: move temporary buffer
RFC PATCH 1/1 sdio: move temporary buffer
Move the temporary buffer used by some sdio functions from sdio_func struct to the mmc_host struct and make it dma-safe.
---
There is no need to have this temporary buffer in every sdio_func, since all access to it are serialized by sdio_[claim/release]_host.
I also think it should be ____cacheline_aligned to make sure we have no data loss when doing dma syncing operations.
Comments welcome!
Regards
Marc
sdio-dma-tmpbuf-patch (against 2.6.24-rc5)
drivers/mmc/core/sdio_io.c | 20 ++++++++++++-------- include/linux/mmc/host.h | 3 +++ include/linux/mmc/sdio_func.h | 2 -- 3 files changed, 15 insertions(+), 10 deletions(-)
drivers/mmc/core/sdio_io.c +12 -8
@@ -389,18 +389,19 @@ unsigned short sdio_readw(struct sdio_func *func, unsigned int addr, int *err_ret) {int ret; +u8 *tmpbuf = func->card->host->tmpbuf;if (err_ret) *err_ret =0 ; - ret =sdio_memcpy_fromio (func, func->tmpbuf, addr,2 ); + ret =sdio_memcpy_fromio (func, tmpbuf, addr,2 );if (ret) {if (err_ret) *err_ret = ret;return 0xFFFF ; } -return le16_to_cpu (*(u16 *)func->tmpbuf); +return le16_to_cpu (*(u16 *)tmpbuf); }EXPORT_SYMBOL_GPL (sdio_readw);
@@ -419,10 +420,11 @@ void sdio_writew(struct sdio_func *func, unsigned short b, unsigned int addr, int *err_ret) {int ret; +u8 *tmpbuf = func->card->host->tmpbuf; - *(u16 *)func->tmpbuf =cpu_to_le16 (b); + *(u16 *)tmpbuf =cpu_to_le16 (b); - ret =sdio_memcpy_toio (func, addr, func->tmpbuf,2 ); + ret =sdio_memcpy_toio (func, addr, tmpbuf,2 );if (err_ret) *err_ret = ret; }
@@ -443,18 +445,19 @@ unsigned long sdio_readl(struct sdio_func *func, unsigned int addr, int *err_ret) {int ret; +u8 *tmpbuf = func->card->host->tmpbuf;if (err_ret) *err_ret =0 ; - ret =sdio_memcpy_fromio (func, func->tmpbuf, addr,4 ); + ret =sdio_memcpy_fromio (func, tmpbuf, addr,4 );if (ret) {if (err_ret) *err_ret = ret;return 0xFFFFFFFF ; } -return le32_to_cpu (*(u32 *)func->tmpbuf); +return le32_to_cpu (*(u32 *)tmpbuf); }EXPORT_SYMBOL_GPL (sdio_readl);
@@ -473,10 +476,11 @@ void sdio_writel(struct sdio_func *func, unsigned long b, unsigned int addr, int *err_ret) {int ret; +u8 *tmpbuf = func->card->host->tmpbuf; - *(u32 *)func->tmpbuf =cpu_to_le32 (b); + *(u32 *)tmpbuf =cpu_to_le32 (b); - ret =sdio_memcpy_toio (func, addr, func->tmpbuf,4 ); + ret =sdio_memcpy_toio (func, addr, tmpbuf,4 );if (err_ret) *err_ret = ret; }
include/linux/mmc/host.h +3 -0
@@ -139,6 +139,9 @@ struct mmc_host {struct led_trigger *led;/* activity led */ #endif +/* DMA:able scratch buffer */ +u8 tmpbuf[4 ]____cacheline_aligned ; +unsigned long private[0 ]____cacheline_aligned ; };
include/linux/mmc/sdio_func.h +0 -2
@@ -49,8 +49,6 @@ struct sdio_func {unsigned int state;/* function state */ #define SDIO_STATE_PRESENT (1<<0)/* present in sysfs */ -u8 tmpbuf[4 ];/* DMA:able scratch buffer */ -unsigned num_info;/* number of info strings */ const char **info;/* info strings */
Quoted 9 lines · On Wed, 19 Dec 2007 11:55:25 +0100 Marc Pignat <[email protected]> wrote:
Move the temporary buffer used by some sdio functions from
sdio_funcstruct to themmc_hoststruct and make it dma-safe.Signed-off-by Marc Pignat <[email protected]>---
There is no need to have this temporary buffer in every
sdio_func, since all access to it are serialized by sdio_[claim/release]_host.
I had some crazy idea about per function locking, but until that time this will do just fine.
Quoted 2 lines
I also think it should be
____cacheline_alignedto make sure we have no data loss when doing dma syncing operations.
This is still voodoo to me, so I'll have to take your word for it. :)
Quoted 3 lines
Comments welcome!
Looks good to me.
Rgds
Signature · 5 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org
Quoted 1 line · Pierre Ossman
On Wed, 19 Dec 2007 11:55:25 +0100
...
Quoted 1 line
This is still voodoo to me, so I'll have to take your word for it. :)
And almost voodoo to me... this is why I hope an ack from a DMA mentor!
Marc