[RFC, PATCH] sdio: move temporary buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Move the temporary buffer used by some sdio functions from sdio_func struct to
the mmc_host struct 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 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(-)

diff --git a/drivers/mmc/core/sdio_io.c b/drivers/mmc/core/sdio_io.c
index 625b92c..e48663e 100644
--- a/drivers/mmc/core/sdio_io.c
+++ b/drivers/mmc/core/sdio_io.c
@@ -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;
 }
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 125eee1..8edb796 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -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;
 };
 
diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h
index b050f4d..4a797a7 100644
--- a/include/linux/mmc/sdio_func.h
+++ b/include/linux/mmc/sdio_func.h
@@ -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 */
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux