]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit - include/linux/of_dma.h
dma:of: Use a mutex to protect the of_dma_list
authorLars-Peter Clausen <lars@metafoo.de>
Fri, 19 Apr 2013 09:42:14 +0000 (11:42 +0200)
committerVinod Koul <vinod.koul@intel.com>
Thu, 2 May 2013 16:20:38 +0000 (21:50 +0530)
commitde61608acf89779c8831aaa1428b6975d49d98c0
tree482bb0d77306ddf7f83050e2129885c89124e56f
parentf22eb1402244885126c4263eb36b857e4182dd6f
dma:of: Use a mutex to protect the of_dma_list

Currently the OF DMA code uses a spin lock to protect the of_dma_list from
concurrent access and a per controller reference count to protect the controller
from being freed while a request operation is in progress. If
of_dma_controller_free() is called for a controller who's reference count is not
zero it will return -EBUSY and not remove the controller. This is fine up until
here, but leaves the question what the caller of of_dma_controller_free() is
supposed to do if the controller couldn't be freed.  The only viable solution
for the caller is to spin on of_dma_controller_free() until it returns success.
E.g.

do {
ret = of_dma_controller_free(dev->of_node)
} while (ret != -EBUSY);

This is rather ugly and unnecessary and none of the current users of
of_dma_controller_free() check it's return value anyway. Instead protect the
list by a mutex. The mutex will be held as long as a request operation is in
progress. So if of_dma_controller_free() is called while a request operation is
in progress it will be put to sleep and only wake up once the request operation
has finished.

This means that it is no longer possible to register or unregister OF DMA
controllers from a context where it's not possible to sleep. But I doubt that
we'll ever need this.

Also rename of_dma_get_controller back to of_dma_find_controller.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
drivers/dma/of-dma.c
include/linux/of_dma.h