[1/2] dmaengine: move module_/dma_device_put() after route free

Message ID 20191224050326.3481588-1-vkoul@kernel.org
State New
Headers show
Series
  • [1/2] dmaengine: move module_/dma_device_put() after route free
Related show

Commit Message

Vinod Koul Dec. 24, 2019, 5:03 a.m.
We call dma_device_put() and module_put() after invoking
.device_free_chan_resources callback, but we should also take care of
router devices and invoke this after .route_free callback. So move it
after .route_free

Signed-off-by: Vinod Koul <vkoul@kernel.org>

---
 drivers/dma/dmaengine.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.23.0

Comments

Logan Gunthorpe Dec. 25, 2019, 2:26 a.m. | #1
On 2019-12-23 10:03 p.m., Vinod Koul wrote:
> We call dma_device_put() and module_put() after invoking

> .device_free_chan_resources callback, but we should also take care of

> router devices and invoke this after .route_free callback. So move it

> after .route_free

> 

> Signed-off-by: Vinod Koul <vkoul@kernel.org>


Makes sense.

Reviewed-by: Logan Gunthorpe <logang@deltatee.com>


> ---

>  drivers/dma/dmaengine.c | 6 +++---

>  1 file changed, 3 insertions(+), 3 deletions(-)

> 

> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c

> index e316abe3672d..0505ea5b002f 100644

> --- a/drivers/dma/dmaengine.c

> +++ b/drivers/dma/dmaengine.c

> @@ -427,15 +427,15 @@ static void dma_chan_put(struct dma_chan *chan)

>  		chan->device->device_free_chan_resources(chan);

>  	}

>  

> -	dma_device_put(chan->device);

> -	module_put(dma_chan_to_owner(chan));

> -

>  	/* If the channel is used via a DMA request router, free the mapping */

>  	if (chan->router && chan->router->route_free) {

>  		chan->router->route_free(chan->router->dev, chan->route_data);

>  		chan->router = NULL;

>  		chan->route_data = NULL;

>  	}

> +

> +	dma_device_put(chan->device);

> +	module_put(dma_chan_to_owner(chan));

>  }

>  

>  enum dma_status dma_sync_wait(struct dma_chan *chan, dma_cookie_t cookie)

>

Patch

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index e316abe3672d..0505ea5b002f 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -427,15 +427,15 @@  static void dma_chan_put(struct dma_chan *chan)
 		chan->device->device_free_chan_resources(chan);
 	}
 
-	dma_device_put(chan->device);
-	module_put(dma_chan_to_owner(chan));
-
 	/* If the channel is used via a DMA request router, free the mapping */
 	if (chan->router && chan->router->route_free) {
 		chan->router->route_free(chan->router->dev, chan->route_data);
 		chan->router = NULL;
 		chan->route_data = NULL;
 	}
+
+	dma_device_put(chan->device);
+	module_put(dma_chan_to_owner(chan));
 }
 
 enum dma_status dma_sync_wait(struct dma_chan *chan, dma_cookie_t cookie)