diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-04-19 05:42:14 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2013-05-02 12:20:38 -0400 |
commit | de61608acf89779c8831aaa1428b6975d49d98c0 (patch) | |
tree | 482bb0d77306ddf7f83050e2129885c89124e56f /include/linux/of_dma.h | |
parent | f22eb1402244885126c4263eb36b857e4182dd6f (diff) |
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>
Diffstat (limited to 'include/linux/of_dma.h')
-rw-r--r-- | include/linux/of_dma.h | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/include/linux/of_dma.h b/include/linux/of_dma.h index ce6a8ab3d2bb..364dda734877 100644 --- a/include/linux/of_dma.h +++ b/include/linux/of_dma.h | |||
@@ -25,7 +25,6 @@ struct of_dma { | |||
25 | struct dma_chan *(*of_dma_xlate) | 25 | struct dma_chan *(*of_dma_xlate) |
26 | (struct of_phandle_args *, struct of_dma *); | 26 | (struct of_phandle_args *, struct of_dma *); |
27 | void *of_dma_data; | 27 | void *of_dma_data; |
28 | int use_count; | ||
29 | }; | 28 | }; |
30 | 29 | ||
31 | struct of_dma_filter_info { | 30 | struct of_dma_filter_info { |
@@ -38,7 +37,7 @@ extern int of_dma_controller_register(struct device_node *np, | |||
38 | struct dma_chan *(*of_dma_xlate) | 37 | struct dma_chan *(*of_dma_xlate) |
39 | (struct of_phandle_args *, struct of_dma *), | 38 | (struct of_phandle_args *, struct of_dma *), |
40 | void *data); | 39 | void *data); |
41 | extern int of_dma_controller_free(struct device_node *np); | 40 | extern void of_dma_controller_free(struct device_node *np); |
42 | extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np, | 41 | extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np, |
43 | const char *name); | 42 | const char *name); |
44 | extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec, | 43 | extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec, |
@@ -52,9 +51,8 @@ static inline int of_dma_controller_register(struct device_node *np, | |||
52 | return -ENODEV; | 51 | return -ENODEV; |
53 | } | 52 | } |
54 | 53 | ||
55 | static inline int of_dma_controller_free(struct device_node *np) | 54 | static inline void of_dma_controller_free(struct device_node *np) |
56 | { | 55 | { |
57 | return -ENODEV; | ||
58 | } | 56 | } |
59 | 57 | ||
60 | static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np, | 58 | static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np, |