s3c24xx: fix s3cmci DMA support
Subsystems (4)
cover s3c24xx: fix s3cmci DMA support
This series fixes DMA support for s3c24xx SoCs, now it's possible to use DMA with s3cmci driver. It was tested on rx1950 (s3c2442), h1940 (s3c2410) and freerunner (s3c2442), unfortunately s3cmci doesn't work with SDIO cards when DMA is enabled, but at least patch breaks nothing - sound works OK on freerunner, and it's still possible to use PIO.
PATCH 1/2 s3c24xx: DMA: don't use autoreload feature
Some integrated DMA-capable hardware doesn't like autoreload feature of s3c24xx DMA-engine, that's why s3cmci driver didn't work with DMA transfers enabled.
I rewrote DMA driver not to use autoreload feature and removed all pre-loading features. Buffer re-load is fast enought to perform it in IRQ handler, and anyway I don't see any reason to waste CPU cycles on waiting for buffer load. Driver is much simplier now, it was tested with s3cmci and s3c24xx-i2s drivers on s3c2442 and s3c2410 SoCs and works just nice.
--- arch/arm/mach-s3c2410/include/mach/dma.h | 17 +- arch/arm/plat-s3c24xx/dma.c | 442 +++++------------------------- 2 files changed, 75 insertions(+), 384 deletions(-)
arch/arm/mach-s3c2410/include/mach/dma.h +3 -14
@@ -79,28 +79,15 @@ enum s3c2410_dma_state {* * There are no buffers loaded (the channel should be inactive) * -* S3C2410_DMA_1LOADED -* -* There is one buffer loaded, however it has not been confirmed to be -* loaded by the DMA engine. This may be because the channel is not -* yet running, or the DMA driver decided that it was too costly to -* sit and wait for it to happen. -* * S3C2410_DMA_1RUNNING * -* The buffer has been confirmed running, and not finisged -* -* S3C2410_DMA_1LOADED_1RUNNING +* The buffer has been confirmed running, and not finished * -* There is a buffer waiting to be loaded by the DMA engine, and one -* currently running. */ enum s3c2410_dma_loadst {S3C2410_DMALOAD_NONE , -S3C2410_DMALOAD_1LOADED ,S3C2410_DMALOAD_1RUNNING , -S3C2410_DMALOAD_1LOADED_1RUNNING , };
@@ -129,6 +116,7 @@ struct s3c2410_dma_buf {dma_addr_t data;/* start of DMA data */ dma_addr_t ptr;/* where the DMA got to [1] */ void *id;/* client's id */ +unsigned int timestamp; };/* [1] is this updated for both recv/send modes? */
@@ -189,6 +177,7 @@ struct s3c2410_dma_chan {struct s3c2410_dma_buf *curr;/* current dma buffer */ struct s3c2410_dma_buf *next;/* next buffer to load */ struct s3c2410_dma_buf *end;/* end of queue */ +spinlock_t queue_lock;/* system device */ struct sys_device dev;
arch/arm/plat-s3c24xx/dma.c +72 -370
606 lines not on this page · raw message
Signature · 1 line
1.7.2.2
PATCH 1/2 s3c24xx: DMA: don't use autoreload feature
Quoted 10 lines · Vasily Khoruzhick
Some integrated DMA-capable hardware doesn't like autoreload feature of s3c24xx DMA-engine, that's why s3cmci driver didn't work with DMA transfers enabled.
I rewrote DMA driver not to use autoreload feature and removed all pre-loading features. Buffer re-load is fast enought to perform it in IRQ handler, and anyway I don't see any reason to waste CPU cycles on waiting for buffer load. Driver is much simplier now, it was tested with s3cmci and s3c24xx-i2s drivers on s3c2442 and s3c2410 SoCs and works just nice.
I found this really necessary, especially on systems where some drivers can keep the cpu irq load high, such as pio hard-discs.
Can this be changed to a flag that is set to control the behaviour on a per driver basis?
PATCH 1/2 s3c24xx: DMA: don't use autoreload feature
? ????????? ?? 8 ???????? 2010 02:37:00 ????? Ben Dooks ???????:
Quoted 12 lines · Vasily Khoruzhick
Quoted 10 lines
Some integrated DMA-capable hardware doesn't like autoreload feature of s3c24xx DMA-engine, that's why s3cmci driver didn't work with DMA transfers enabled.
I rewrote DMA driver not to use autoreload feature and removed all pre-loading features. Buffer re-load is fast enought to perform it in IRQ handler, and anyway I don't see any reason to waste CPU cycles on waiting for buffer load. Driver is much simplier now, it was tested with s3cmci and s3c24xx-i2s drivers on s3c2442 and s3c2410 SoCs and works just nice.
Quoted 5 lines
I found this really necessary, especially on systems where some drivers can keep the cpu irq load high, such as pio hard-discs.
Can this be changed to a flag that is set to control the behaviour on a per driver basis?
Well, that's not easy and result will be a bit complicated :) Your implementation has 4 states and actively uses autoreload flag, but when there's no autoreload/pre-loading there's only 2 states. Btw, all DMA-capable HW on S3C24xx has FIFO, so missing pre-loading should not give big impact, as HW can be fed from FIFO for some time. Can you test if this patch causes some problems on your HW with pio hard-discs?
Regards
Vasily
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100908/0e46a31b/attachment.sig>
cover s3c24xx: fix s3cmci DMA support
In reply to Vasily KhoruzhickQuoted 6 lines · Vasily Khoruzhick
This series fixes DMA support for s3c24xx SoCs, now it's possible to use DMA with s3cmci driver. It was tested on rx1950 (s3c2442), h1940 (s3c2410) and freerunner (s3c2442), unfortunately s3cmci doesn't work with SDIO cards when DMA is enabled, but at least patch breaks nothing - sound works OK on freerunner, and it's still possible to use PIO.
hmm, i've not got 1/2 of this?
PATCH 2/2 s3cmci: minor fixups
In reply to Vasily Khoruzhick- It's not necessary to start DMA op manually, as we have autostart feature enabled
- Restore prescaler before DMA operation, otherwise it takes ages to complete DMA op.
--- drivers/mmc/host/s3cmci.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/s3cmci.c +2 -2
@@ -1106,6 +1106,8 @@ static int s3cmci_prepare_dma(struct s3cmci_host *host, struct mmc_data *data)sg_dma_address (&data->sg[i]), sg_dma_len(&data->sg[i])); +/* Restore prescaler value */ +writel (host->prescaler, host->base +S3C2410_SDIPRE ); res =s3c2410_dma_enqueue (host->dma, host,sg_dma_address (&data->sg[i]),sg_dma_len (&data->sg[i]));
@@ -1116,8 +1118,6 @@ static int s3cmci_prepare_dma(struct s3cmci_host *host, struct mmc_data *data) } } -s3c2410_dma_ctrl (host->dma,S3C2410_DMAOP_START ); -return 0 ; }
Signature · 1 line
1.7.2.2
PATCH 2/2 s3cmci: minor fixups
Quoted 24 lines · Vasily Khoruzhick
- It's not necessary to start DMA op manually, as we have autostart feature enabled
- Restore prescaler before DMA operation, otherwise it takes ages to complete DMA op.Signed-off-by Vasily Khoruzhick <[email protected]>--- drivers/mmc/host/s3cmci.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/mmc/host/s3cmci.c +2
-0@@ -1106,6 +1106,8 @@ static int s3cmci_prepare_dma(struct s3cmci_host *host, struct mmc_data *data)sg_dma_address (&data->sg[i]), sg_dma_len(&data->sg[i])); +/* Restore prescaler value */ +writel (host->prescaler, host->base +S3C2410_SDIPRE ); res =s3c2410_dma_enqueue (host->dma, host,sg_dma_address (&data->sg[i]),sg_dma_len (&data->sg[i]));
drivers/mmc/host/s3cmci.c static int s3cmci_prepare_dma(struct s3cmci_host *host, struct mmc_data *data) · line 1122
Quoted 7 lines
drivers/mmc/host/s3cmci.c +0
-2@@ -1116,8 +1118,6 @@ static int s3cmci_prepare_dma(struct s3cmci_host *host, struct mmc_data *data) } } -s3c2410_dma_ctrl (host->dma,S3C2410_DMAOP_START ); -return 0 ; }
looks ok to me.