* [PATCH for -rc] dmaengine: i.MX SDMA fixes
@ 2010-12-06 10:09 Sascha Hauer
2010-12-06 10:09 ` [PATCH 1/2] dmaengine i.MX SDMA: initialize on module_init Sascha Hauer
2010-12-06 10:09 ` [PATCH 2/2] dmaengine i.MX SDMA: protect channel0 Sascha Hauer
0 siblings, 2 replies; 6+ messages in thread
From: Sascha Hauer @ 2010-12-06 10:09 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
The following series contains some fixes for the i.MX SDMA driver. Please
consider them for -rc.
Sascha
The following changes since commit 771f8bc71c31c6bd103cdec283012253f352ab1c:
Merge branch 'slab/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/penberg/slab-2.6 (2010-12-05 16:45:02 -0800)
are available in the git repository at:
git://git.pengutronix.de/git/imx/linux-2.6.git sdma-fixes
Sascha Hauer (2):
dmaengine i.MX SDMA: initialize on module_init
dmaengine i.MX SDMA: protect channel0
drivers/dma/imx-sdma.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 1/2] dmaengine i.MX SDMA: initialize on module_init 2010-12-06 10:09 [PATCH for -rc] dmaengine: i.MX SDMA fixes Sascha Hauer @ 2010-12-06 10:09 ` Sascha Hauer 2010-12-07 23:31 ` Dan Williams 2010-12-06 10:09 ` [PATCH 2/2] dmaengine i.MX SDMA: protect channel0 Sascha Hauer 1 sibling, 1 reply; 6+ messages in thread From: Sascha Hauer @ 2010-12-06 10:09 UTC (permalink / raw) To: linux-arm-kernel The firmware framework gets initialized during fs_initcall time, so we are not allowed to call request_firmware earlier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> --- drivers/dma/imx-sdma.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 0834323..01c4a5f 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -1385,7 +1385,7 @@ static int __init sdma_module_init(void) { return platform_driver_probe(&sdma_driver, sdma_probe); } -subsys_initcall(sdma_module_init); +module_init(sdma_module_init); MODULE_AUTHOR("Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>"); MODULE_DESCRIPTION("i.MX SDMA driver"); -- 1.7.2.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/2] dmaengine i.MX SDMA: initialize on module_init 2010-12-06 10:09 ` [PATCH 1/2] dmaengine i.MX SDMA: initialize on module_init Sascha Hauer @ 2010-12-07 23:31 ` Dan Williams 0 siblings, 0 replies; 6+ messages in thread From: Dan Williams @ 2010-12-07 23:31 UTC (permalink / raw) To: linux-arm-kernel On Mon, Dec 6, 2010 at 2:09 AM, Sascha Hauer <s.hauer@pengutronix.de> wrote: > The firmware framework gets initialized during fs_initcall time, so > we are not allowed to call request_firmware earlier. > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> > --- Applied. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] dmaengine i.MX SDMA: protect channel0 2010-12-06 10:09 [PATCH for -rc] dmaengine: i.MX SDMA fixes Sascha Hauer 2010-12-06 10:09 ` [PATCH 1/2] dmaengine i.MX SDMA: initialize on module_init Sascha Hauer @ 2010-12-06 10:09 ` Sascha Hauer 2010-12-07 23:50 ` Dan Williams 1 sibling, 1 reply; 6+ messages in thread From: Sascha Hauer @ 2010-12-06 10:09 UTC (permalink / raw) To: linux-arm-kernel Channel 0 of the SDMA engine is a shared resource used by the other channels, thus we have to protect it with a mutex. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> --- drivers/dma/imx-sdma.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 01c4a5f..b1f5947 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -355,6 +355,7 @@ struct sdma_engine { struct dma_device dma_device; struct clk *clk; struct sdma_script_start_addrs *script_addrs; + struct mutex channel0_mutex; }; #define SDMA_H_CONFIG_DSPDMA (1 << 12) /* indicates if the DSPDMA is used */ @@ -437,6 +438,8 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size, if (!buf_virt) return -ENOMEM; + mutex_lock(&sdma->channel0_mutex); + bd0->mode.command = C0_SETPM; bd0->mode.status = BD_DONE | BD_INTR | BD_WRAP | BD_EXTD; bd0->mode.count = size / 2; @@ -447,6 +450,8 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size, ret = sdma_run_channel(&sdma->channel[0]); + mutex_unlock(&sdma->channel0_mutex); + dma_free_coherent(NULL, size, buf_virt, buf_phys); return ret; @@ -684,6 +689,8 @@ static int sdma_load_context(struct sdma_channel *sdmac) context->gReg[6] = sdmac->shp_addr; context->gReg[7] = sdmac->watermark_level; + mutex_lock(&sdma->channel0_mutex); + bd0->mode.command = C0_SETDM; bd0->mode.status = BD_DONE | BD_INTR | BD_WRAP | BD_EXTD; bd0->mode.count = sizeof(*context) / 4; @@ -692,6 +699,8 @@ static int sdma_load_context(struct sdma_channel *sdmac) ret = sdma_run_channel(&sdma->channel[0]); + mutex_unlock(&sdma->channel0_mutex); + return ret; } @@ -1297,6 +1306,8 @@ static int __init sdma_probe(struct platform_device *pdev) sdma->version = pdata->sdma_version; + mutex_init(&sdma->channel0_mutex); + INIT_LIST_HEAD(&sdma->dma_device.channels); /* Initialize channel parameters */ for (i = 0; i < MAX_DMA_CHANNELS; i++) { -- 1.7.2.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] dmaengine i.MX SDMA: protect channel0 2010-12-06 10:09 ` [PATCH 2/2] dmaengine i.MX SDMA: protect channel0 Sascha Hauer @ 2010-12-07 23:50 ` Dan Williams 2010-12-09 14:50 ` Sascha Hauer 0 siblings, 1 reply; 6+ messages in thread From: Dan Williams @ 2010-12-07 23:50 UTC (permalink / raw) To: linux-arm-kernel On Mon, Dec 6, 2010 at 2:09 AM, Sascha Hauer <s.hauer@pengutronix.de> wrote: > Channel 0 of the SDMA engine is a shared resource used by the > other channels, thus we have to protect it with a mutex. > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> > --- This one is not making sense to me... > ?drivers/dma/imx-sdma.c | ? 11 +++++++++++ > ?1 files changed, 11 insertions(+), 0 deletions(-) > > diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c > index 01c4a5f..b1f5947 100644 > --- a/drivers/dma/imx-sdma.c > +++ b/drivers/dma/imx-sdma.c > @@ -355,6 +355,7 @@ struct sdma_engine { > ? ? ? ?struct dma_device ? ? ? ? ? ? ? dma_device; > ? ? ? ?struct clk ? ? ? ? ? ? ? ? ? ? ?*clk; > ? ? ? ?struct sdma_script_start_addrs ?*script_addrs; > + ? ? ? struct mutex ? ? ? ? ? ? ? ? ? ?channel0_mutex; > ?}; > > ?#define SDMA_H_CONFIG_DSPDMA ? (1 << 12) /* indicates if the DSPDMA is used */ > @@ -437,6 +438,8 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size, > ? ? ? ?if (!buf_virt) > ? ? ? ? ? ? ? ?return -ENOMEM; > > + ? ? ? mutex_lock(&sdma->channel0_mutex); > + > ? ? ? ?bd0->mode.command = C0_SETPM; > ? ? ? ?bd0->mode.status = BD_DONE | BD_INTR | BD_WRAP | BD_EXTD; > ? ? ? ?bd0->mode.count = size / 2; > @@ -447,6 +450,8 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size, > > ? ? ? ?ret = sdma_run_channel(&sdma->channel[0]); > > + ? ? ? mutex_unlock(&sdma->channel0_mutex); > + In sdma_load_script() what data structure are we protecting at single threaded init time prior to registering channels? > ? ? ? ?dma_free_coherent(NULL, size, buf_virt, buf_phys); > > ? ? ? ?return ret; > @@ -684,6 +689,8 @@ static int sdma_load_context(struct sdma_channel *sdmac) > ? ? ? ?context->gReg[6] = sdmac->shp_addr; > ? ? ? ?context->gReg[7] = sdmac->watermark_level; > > + ? ? ? mutex_lock(&sdma->channel0_mutex); > + > ? ? ? ?bd0->mode.command = C0_SETDM; > ? ? ? ?bd0->mode.status = BD_DONE | BD_INTR | BD_WRAP | BD_EXTD; > ? ? ? ?bd0->mode.count = sizeof(*context) / 4; > @@ -692,6 +699,8 @@ static int sdma_load_context(struct sdma_channel *sdmac) > > ? ? ? ?ret = sdma_run_channel(&sdma->channel[0]); > > + ? ? ? mutex_unlock(&sdma->channel0_mutex); > + This sdma_load_context() is called from various ->prep() contexts. What guarantees are there that we can sleep in these contexts? At least ->prep_memcpy() might be called in a atomic context. I have been assuming the same for all prep routines across archs. -- Dan ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] dmaengine i.MX SDMA: protect channel0 2010-12-07 23:50 ` Dan Williams @ 2010-12-09 14:50 ` Sascha Hauer 0 siblings, 0 replies; 6+ messages in thread From: Sascha Hauer @ 2010-12-09 14:50 UTC (permalink / raw) To: linux-arm-kernel On Tue, Dec 07, 2010 at 03:50:33PM -0800, Dan Williams wrote: > On Mon, Dec 6, 2010 at 2:09 AM, Sascha Hauer <s.hauer@pengutronix.de> wrote: > > Channel 0 of the SDMA engine is a shared resource used by the > > other channels, thus we have to protect it with a mutex. > > > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> > > --- > > This one is not making sense to me... > > > ?drivers/dma/imx-sdma.c | ? 11 +++++++++++ > > ?1 files changed, 11 insertions(+), 0 deletions(-) > > > > diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c > > index 01c4a5f..b1f5947 100644 > > --- a/drivers/dma/imx-sdma.c > > +++ b/drivers/dma/imx-sdma.c > > @@ -355,6 +355,7 @@ struct sdma_engine { > > ? ? ? ?struct dma_device ? ? ? ? ? ? ? dma_device; > > ? ? ? ?struct clk ? ? ? ? ? ? ? ? ? ? ?*clk; > > ? ? ? ?struct sdma_script_start_addrs ?*script_addrs; > > + ? ? ? struct mutex ? ? ? ? ? ? ? ? ? ?channel0_mutex; > > ?}; > > > > ?#define SDMA_H_CONFIG_DSPDMA ? (1 << 12) /* indicates if the DSPDMA is used */ > > @@ -437,6 +438,8 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size, > > ? ? ? ?if (!buf_virt) > > ? ? ? ? ? ? ? ?return -ENOMEM; > > > > + ? ? ? mutex_lock(&sdma->channel0_mutex); > > + > > ? ? ? ?bd0->mode.command = C0_SETPM; > > ? ? ? ?bd0->mode.status = BD_DONE | BD_INTR | BD_WRAP | BD_EXTD; > > ? ? ? ?bd0->mode.count = size / 2; > > @@ -447,6 +450,8 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size, > > > > ? ? ? ?ret = sdma_run_channel(&sdma->channel[0]); > > > > + ? ? ? mutex_unlock(&sdma->channel0_mutex); > > + > > In sdma_load_script() what data structure are we protecting at single > threaded init time prior to registering channels? At the moment the lock in sdma_load_script is not needed, but I have a patch in the queue using request_firmware_nowait instead of request_firmware, so the firmware might come in after initialization (The SDMA does not really depend on the firmware, it can just offer more features when it is available) > > > ? ? ? ?dma_free_coherent(NULL, size, buf_virt, buf_phys); > > > > ? ? ? ?return ret; > > > @@ -684,6 +689,8 @@ static int sdma_load_context(struct sdma_channel *sdmac) > > ? ? ? ?context->gReg[6] = sdmac->shp_addr; > > ? ? ? ?context->gReg[7] = sdmac->watermark_level; > > > > + ? ? ? mutex_lock(&sdma->channel0_mutex); > > + > > ? ? ? ?bd0->mode.command = C0_SETDM; > > ? ? ? ?bd0->mode.status = BD_DONE | BD_INTR | BD_WRAP | BD_EXTD; > > ? ? ? ?bd0->mode.count = sizeof(*context) / 4; > > @@ -692,6 +699,8 @@ static int sdma_load_context(struct sdma_channel *sdmac) > > > > ? ? ? ?ret = sdma_run_channel(&sdma->channel[0]); > > > > + ? ? ? mutex_unlock(&sdma->channel0_mutex); > > + > > This sdma_load_context() is called from various ->prep() contexts. > What guarantees are there that we can sleep in these contexts? At > least ->prep_memcpy() might be called in a atomic context. I have > been assuming the same for all prep routines across archs. Currently it is only called from non interrupt context. Fact is that we need some kind of locking because channel 0 is used by the other channels. I just made a check and it shows running channel 0 only takes about 6us, so a spinlock might be a better weapon here. So forget this patch for now and I'll send an updated one using a spinlock (and no completion interrupt for channel 0). Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-12-09 14:50 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-12-06 10:09 [PATCH for -rc] dmaengine: i.MX SDMA fixes Sascha Hauer 2010-12-06 10:09 ` [PATCH 1/2] dmaengine i.MX SDMA: initialize on module_init Sascha Hauer 2010-12-07 23:31 ` Dan Williams 2010-12-06 10:09 ` [PATCH 2/2] dmaengine i.MX SDMA: protect channel0 Sascha Hauer 2010-12-07 23:50 ` Dan Williams 2010-12-09 14:50 ` Sascha Hauer
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).