remoteproc_virtio.c (03ab8e6297acd1bc0eedaa050e2a1635c576fd11) remoteproc_virtio.c (c2a052a4a949df53f50a5024843432d2234cb824)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Remote processor messaging transport (OMAP platform-specific bits)
4 *
5 * Copyright (C) 2011 Texas Instruments, Inc.
6 * Copyright (C) 2011 Google, Inc.
7 *
8 * Ohad Ben-Cohen <ohad@wizery.com>

--- 73 unchanged lines hidden (view full) ---

82 struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
83 struct rproc *rproc = vdev_to_rproc(vdev);
84 struct device *dev = &rproc->dev;
85 struct rproc_mem_entry *mem;
86 struct rproc_vring *rvring;
87 struct fw_rsc_vdev *rsc;
88 struct virtqueue *vq;
89 void *addr;
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Remote processor messaging transport (OMAP platform-specific bits)
4 *
5 * Copyright (C) 2011 Texas Instruments, Inc.
6 * Copyright (C) 2011 Google, Inc.
7 *
8 * Ohad Ben-Cohen <ohad@wizery.com>

--- 73 unchanged lines hidden (view full) ---

82 struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
83 struct rproc *rproc = vdev_to_rproc(vdev);
84 struct device *dev = &rproc->dev;
85 struct rproc_mem_entry *mem;
86 struct rproc_vring *rvring;
87 struct fw_rsc_vdev *rsc;
88 struct virtqueue *vq;
89 void *addr;
90 int len, size;
90 int num, size;
91
92 /* we're temporarily limited to two virtqueues per rvdev */
93 if (id >= ARRAY_SIZE(rvdev->vring))
94 return ERR_PTR(-EINVAL);
95
96 if (!name)
97 return NULL;
98
99 /* Search allocated memory region by name */
100 mem = rproc_find_carveout_by_name(rproc, "vdev%dvring%d", rvdev->index,
101 id);
102 if (!mem || !mem->va)
103 return ERR_PTR(-ENOMEM);
104
105 rvring = &rvdev->vring[id];
106 addr = mem->va;
91
92 /* we're temporarily limited to two virtqueues per rvdev */
93 if (id >= ARRAY_SIZE(rvdev->vring))
94 return ERR_PTR(-EINVAL);
95
96 if (!name)
97 return NULL;
98
99 /* Search allocated memory region by name */
100 mem = rproc_find_carveout_by_name(rproc, "vdev%dvring%d", rvdev->index,
101 id);
102 if (!mem || !mem->va)
103 return ERR_PTR(-ENOMEM);
104
105 rvring = &rvdev->vring[id];
106 addr = mem->va;
107 len = rvring->len;
107 num = rvring->num;
108
109 /* zero vring */
108
109 /* zero vring */
110 size = vring_size(len, rvring->align);
110 size = vring_size(num, rvring->align);
111 memset(addr, 0, size);
112
113 dev_dbg(dev, "vring%d: va %pK qsz %d notifyid %d\n",
111 memset(addr, 0, size);
112
113 dev_dbg(dev, "vring%d: va %pK qsz %d notifyid %d\n",
114 id, addr, len, rvring->notifyid);
114 id, addr, num, rvring->notifyid);
115
116 /*
117 * Create the new vq, and tell virtio we're not interested in
118 * the 'weak' smp barriers, since we're talking with a real device.
119 */
115
116 /*
117 * Create the new vq, and tell virtio we're not interested in
118 * the 'weak' smp barriers, since we're talking with a real device.
119 */
120 vq = vring_new_virtqueue(id, len, rvring->align, vdev, false, ctx,
120 vq = vring_new_virtqueue(id, num, rvring->align, vdev, false, ctx,
121 addr, rproc_virtio_notify, callback, name);
122 if (!vq) {
123 dev_err(dev, "vring_new_virtqueue %s failed\n", name);
124 rproc_free_vring(rvring);
125 return ERR_PTR(-ENOMEM);
126 }
127
128 rvring->vq = vq;

--- 328 unchanged lines hidden ---
121 addr, rproc_virtio_notify, callback, name);
122 if (!vq) {
123 dev_err(dev, "vring_new_virtqueue %s failed\n", name);
124 rproc_free_vring(rvring);
125 return ERR_PTR(-ENOMEM);
126 }
127
128 rvring->vq = vq;

--- 328 unchanged lines hidden ---