From df0c766ecef850a1dfd0bb0f36dbfcb93a9c37ad Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Tue, 1 Jun 2010 13:21:31 +0200 Subject: [PATCH 14/45] DMAENGINE: ste_dma40: only write phy channel config first time We only need to write the configuration to a physical channel if it is free, else it is already written. Signed-off-by: Jonas Aaberg Signed-off-by: Linus Walleij --- drivers/dma/ste_dma40.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 4618d6c..1cd1ff7 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -1211,9 +1211,9 @@ out: } static int d40_config_chan(struct d40_chan *d40c, - struct stedma40_chan_cfg *info) + struct stedma40_chan_cfg *info, + bool is_free_phy) { - /* Fill in basic CFG register values */ d40_phy_cfg(&d40c->dma_cfg, &d40c->src_def_cfg, &d40c->dst_def_cfg, d40c->log_num != D40_PHY_CHAN); @@ -1230,8 +1230,14 @@ static int d40_config_chan(struct d40_chan *d40c, d40c->dma_cfg.dst_dev_type * 32 + 16; } - /* Write channel configuration to the DMA */ - return d40_config_write(d40c); + /* + * Only write channel configuration to the DMA if the physical + * resource is free. In case of multiple logical channels + * on the same physical resource, only the first write is necessary. + */ + if (is_free_phy) + return d40_config_write(d40c); + return 0; } static int d40_config_memcpy(struct d40_chan *d40c) @@ -1691,7 +1697,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan) unsigned long flags; struct d40_chan *d40c = container_of(chan, struct d40_chan, chan); - + bool is_free_phy; spin_lock_irqsave(&d40c->lock, flags); d40c->completed = chan->cookie = 1; @@ -1705,6 +1711,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan) if (err) goto err_alloc; } + is_free_phy = (d40c->phy_chan == NULL); err = d40_allocate_channel(d40c); if (err) { @@ -1713,7 +1720,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan) goto err_alloc; } - err = d40_config_chan(d40c, &d40c->dma_cfg); + err = d40_config_chan(d40c, &d40c->dma_cfg, is_free_phy); if (err) { dev_err(&d40c->chan.dev->device, "[%s] Failed to configure channel\n", -- 1.6.3.3