mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-18 22:34:48 +00:00
9743a3b62d
In the current implementation of the OF DMA helpers, read-copy-update (RCU) linked lists are being used for storing and accessing the DMA controller data. This part of implementation is based upon V2 of the DMA helpers by Nicolas [1]. During a recent review of RCU, it became apparent that the code is missing the required rcu_read_lock()/unlock() calls as well as synchronisation calls before freeing any memory protected by RCU. Having looked into adding the appropriate RCU calls to protect the DMA data it became apparent that with the current DMA helper implementation, using RCU is not as attractive as it may have been before. The main reasons being that ... 1. We need to protect the DMA data around calls to the xlate function. 2. The of_dma_simple_xlate() function calls the DMA engine function dma_request_channel() which employs a mutex and so could sleep. 3. The RCU read-side critical sections must not sleep and so we cannot hold an RCU read lock around the xlate function. Therefore, instead of using RCU, an alternative for this use-case is to employ a simple spinlock inconjunction with a usage count variable to keep track of how many current users of the DMA data structure there are. With this implementation, the DMA data cannot be freed until all current users of the DMA data are finished. This patch is based upon the DMA helpers fix for potential deadlock [2]. [1] http://article.gmane.org/gmane.linux.ports.arm.omap/73622 [2] http://marc.info/?l=linux-arm-kernel&m=134859982520984&w=2 Signed-off-by: Jon Hunter <jon-hunter@ti.com> Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
74 lines
1.7 KiB
C
74 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;
|
|
int use_count;
|
|
};
|
|
|
|
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 int of_dma_controller_free(struct device_node *np);
|
|
extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
|
|
char *name);
|
|
extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
|
|
struct of_dma *ofdma);
|
|
#else
|
|
static 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 int of_dma_controller_free(struct device_node *np)
|
|
{
|
|
}
|
|
|
|
static struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
|
|
char *name)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
static 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 */
|