dmaengine: Remove a useless mutex
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 6 Feb 2022 09:47:45 +0000 (10:47 +0100)
committerVinod Koul <vkoul@kernel.org>
Mon, 11 Apr 2022 14:22:40 +0000 (19:52 +0530)
According to lib/idr.c,
   The IDA handles its own locking.  It is safe to call any of the IDA
   functions without synchronisation in your code.

so the 'chan_mutex' mutex can just be removed.
It is here only to protect some ida_alloc()/ida_free() calls.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/7180452c1d77b039e27b6f9418e0e7d9dd33c431.1644140845.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/dmaengine.c
include/linux/dmaengine.h

index 2cfa845..e80feee 100644 (file)
@@ -1053,9 +1053,7 @@ static int __dma_async_device_channel_register(struct dma_device *device,
         * When the chan_id is a negative value, we are dynamically adding
         * the channel. Otherwise we are static enumerating.
         */
-       mutex_lock(&device->chan_mutex);
        chan->chan_id = ida_alloc(&device->chan_ida, GFP_KERNEL);
-       mutex_unlock(&device->chan_mutex);
        if (chan->chan_id < 0) {
                pr_err("%s: unable to alloc ida for chan: %d\n",
                       __func__, chan->chan_id);
@@ -1078,9 +1076,7 @@ static int __dma_async_device_channel_register(struct dma_device *device,
        return 0;
 
  err_out_ida:
-       mutex_lock(&device->chan_mutex);
        ida_free(&device->chan_ida, chan->chan_id);
-       mutex_unlock(&device->chan_mutex);
  err_free_dev:
        kfree(chan->dev);
  err_free_local:
@@ -1113,9 +1109,7 @@ static void __dma_async_device_channel_unregister(struct dma_device *device,
        device->chancnt--;
        chan->dev->chan = NULL;
        mutex_unlock(&dma_list_mutex);
-       mutex_lock(&device->chan_mutex);
        ida_free(&device->chan_ida, chan->chan_id);
-       mutex_unlock(&device->chan_mutex);
        device_unregister(&chan->dev->device);
        free_percpu(chan->local);
 }
@@ -1250,7 +1244,6 @@ int dma_async_device_register(struct dma_device *device)
        if (rc != 0)
                return rc;
 
-       mutex_init(&device->chan_mutex);
        ida_init(&device->chan_ida);
 
        /* represent channels in sysfs. Probably want devs too */
index 842d4f7..6db9e03 100644 (file)
@@ -870,7 +870,6 @@ struct dma_device {
        struct device *dev;
        struct module *owner;
        struct ida chan_ida;
-       struct mutex chan_mutex;        /* to protect chan_ida */
 
        u32 src_addr_widths;
        u32 dst_addr_widths;