mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-27 06:34:11 +08:00
de61608acf
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>
73 lines
1.7 KiB
C
73 lines
1.7 KiB
C
/*
|
|
* OF helpers for DMA request / controller
|
|
*
|
|
* Based on of_gpio.h
|
|
*
|
|
* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
|
|
#ifndef __LINUX_OF_DMA_H
|
|
#define __LINUX_OF_DMA_H
|
|
|
|
#include <linux/of.h>
|
|
#include <linux/dmaengine.h>
|
|
|
|
struct device_node;
|
|
|
|
struct of_dma {
|
|
struct list_head of_dma_controllers;
|
|
struct device_node *of_node;
|
|
int of_dma_nbcells;
|
|
struct dma_chan *(*of_dma_xlate)
|
|
(struct of_phandle_args *, struct of_dma *);
|
|
void *of_dma_data;
|
|
};
|
|
|
|
struct of_dma_filter_info {
|
|
dma_cap_mask_t dma_cap;
|
|
dma_filter_fn filter_fn;
|
|
};
|
|
|
|
#ifdef CONFIG_OF
|
|
extern int of_dma_controller_register(struct device_node *np,
|
|
struct dma_chan *(*of_dma_xlate)
|
|
(struct of_phandle_args *, struct of_dma *),
|
|
void *data);
|
|
extern void of_dma_controller_free(struct device_node *np);
|
|
extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
|
|
const char *name);
|
|
extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
|
|
struct of_dma *ofdma);
|
|
#else
|
|
static inline int of_dma_controller_register(struct device_node *np,
|
|
struct dma_chan *(*of_dma_xlate)
|
|
(struct of_phandle_args *, struct of_dma *),
|
|
void *data)
|
|
{
|
|
return -ENODEV;
|
|
}
|
|
|
|
static inline void of_dma_controller_free(struct device_node *np)
|
|
{
|
|
}
|
|
|
|
static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
|
|
const char *name)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
static inline struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
|
|
struct of_dma *ofdma)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* __LINUX_OF_DMA_H */
|