remoteproc: create vdev subdevice with specific dma memory pool
This patch creates a dedicated vdev subdevice for each vdev declared in firmware resource table and associates carveout named "vdev%dbuffer" (with %d vdev index in resource table) if any as dma coherent memory pool. Then vdev subdevice is used as parent for virtio device. Signed-off-by: Loic Pallardy <loic.pallardy@st.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:

committed by
Bjorn Andersson

orang tua
621eafdb0f
melakukan
086d08725d
@@ -17,7 +17,9 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/of_reserved_mem.h>
|
||||
#include <linux/remoteproc.h>
|
||||
#include <linux/virtio.h>
|
||||
#include <linux/virtio_config.h>
|
||||
@@ -328,10 +330,48 @@ static void rproc_virtio_dev_release(struct device *dev)
|
||||
int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id)
|
||||
{
|
||||
struct rproc *rproc = rvdev->rproc;
|
||||
struct device *dev = &rproc->dev;
|
||||
struct device *dev = &rvdev->dev;
|
||||
struct virtio_device *vdev = &rvdev->vdev;
|
||||
struct rproc_mem_entry *mem;
|
||||
int ret;
|
||||
|
||||
/* Try to find dedicated vdev buffer carveout */
|
||||
mem = rproc_find_carveout_by_name(rproc, "vdev%dbuffer", rvdev->index);
|
||||
if (mem) {
|
||||
phys_addr_t pa;
|
||||
|
||||
if (mem->of_resm_idx != -1) {
|
||||
struct device_node *np = rproc->dev.parent->of_node;
|
||||
|
||||
/* Associate reserved memory to vdev device */
|
||||
ret = of_reserved_mem_device_init_by_idx(dev, np,
|
||||
mem->of_resm_idx);
|
||||
if (ret) {
|
||||
dev_err(dev, "Can't associate reserved memory\n");
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
if (mem->va) {
|
||||
dev_warn(dev, "vdev %d buffer already mapped\n",
|
||||
rvdev->index);
|
||||
pa = rproc_va_to_pa(mem->va);
|
||||
} else {
|
||||
/* Use dma address as carveout no memmapped yet */
|
||||
pa = (phys_addr_t)mem->dma;
|
||||
}
|
||||
|
||||
/* Associate vdev buffer memory pool to vdev subdev */
|
||||
ret = dma_declare_coherent_memory(dev, pa,
|
||||
mem->da,
|
||||
mem->len,
|
||||
DMA_MEMORY_EXCLUSIVE);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "Failed to associate buffer\n");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vdev->id.device = id,
|
||||
vdev->config = &rproc_virtio_config_ops,
|
||||
vdev->dev.parent = dev;
|
||||
|
Reference in New Issue
Block a user