mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
dmaengine: up-level reference counting to the module level
Simply, if a client wants any dmaengine channel then prevent all dmaengine modules from being removed. Once the clients are done re-enable module removal. Why?, beyond reducing complication: 1/ Tracking reference counts per-transaction in an efficient manner, as is currently done, requires a complicated scheme to avoid cache-line bouncing effects. 2/ Per-transaction ref-counting gives the false impression that a dma-driver can be gracefully removed ahead of its user (net, md, or dma-slave) 3/ None of the in-tree dma-drivers talk to hot pluggable hardware, but if such an engine were built one day we still would not need to notify clients of remove events. The driver can simply return NULL to a ->prep() request, something that is much easier for a client to handle. Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Maciej Sosnowski <maciej.sosnowski@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
07f2211e4f
commit
6f49a57aa5
8 changed files with 132 additions and 111 deletions
|
@ -165,7 +165,6 @@ struct dma_slave {
|
|||
*/
|
||||
|
||||
struct dma_chan_percpu {
|
||||
local_t refcount;
|
||||
/* stats */
|
||||
unsigned long memcpy_count;
|
||||
unsigned long bytes_transferred;
|
||||
|
@ -205,26 +204,6 @@ struct dma_chan {
|
|||
|
||||
void dma_chan_cleanup(struct kref *kref);
|
||||
|
||||
static inline void dma_chan_get(struct dma_chan *chan)
|
||||
{
|
||||
if (unlikely(chan->slow_ref))
|
||||
kref_get(&chan->refcount);
|
||||
else {
|
||||
local_inc(&(per_cpu_ptr(chan->local, get_cpu())->refcount));
|
||||
put_cpu();
|
||||
}
|
||||
}
|
||||
|
||||
static inline void dma_chan_put(struct dma_chan *chan)
|
||||
{
|
||||
if (unlikely(chan->slow_ref))
|
||||
kref_put(&chan->refcount, dma_chan_cleanup);
|
||||
else {
|
||||
local_dec(&(per_cpu_ptr(chan->local, get_cpu())->refcount));
|
||||
put_cpu();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* typedef dma_event_callback - function pointer to a DMA event callback
|
||||
* For each channel added to the system this routine is called for each client.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue