@@ -271,12 +271,10 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i)
/*
* Assign an rproc-wide unique index for this vring
- * TODO: assign a notifyid for rvdev updates as well
- * TODO: support predefined notifyids (via resource table)
*/
ret = rproc_idr_alloc(rproc, rvring, RPROC_IDR_VRING, 0, 0);
if (ret < 0) {
- dev_err(dev, "idr_alloc failed: %d\n", ret);
+ dev_err(dev, "rvfing idr_alloc failed: %d\n", ret);
dma_free_coherent(dev->parent, size, va, dma);
return ret;
}
@@ -361,6 +361,8 @@ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id)
struct device *dev = &rproc->dev;
struct virtio_device *vdev = &rvdev->vdev;
int ret;
+ int idr_start, idr_end;
+ struct fw_rsc_vdev *rsc;
vdev->id.device = id,
vdev->config = &rproc_virtio_config_ops,
@@ -381,6 +383,27 @@ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id)
/* Reference the vdev and vring allocations */
kref_get(&rvdev->refcount);
+ /*
+ * Assign an rproc-wide unique index for this rvdev
+ */
+ rsc = (void *)rproc->table_ptr + rvdev->rsc_offset;
+ idr_start = 0;
+ idr_end = 0;
+ if (rsc->notifyid != FW_RSC_ADDR_ANY) {
+ if (!idr_find(&rproc->notifyids, rsc->notifyid)) {
+ idr_start = rsc->notifyid;
+ idr_end = idr_start + 1;
+ }
+ }
+
+ ret = rproc_idr_alloc(rproc, rvdev, RPROC_IDR_VDEV,
+ idr_start, idr_end);
+ if (ret < 0) {
+ dev_err(dev, "rvdev idr_alloc failed: %d\n", ret);
+ return ret;
+ }
+ rsc->notifyid = ret;
+
ret = register_virtio_device(vdev);
if (ret) {
put_device(&rproc->dev);
@@ -402,5 +425,11 @@ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id)
*/
void rproc_remove_virtio_dev(struct rproc_vdev *rvdev)
{
+ struct rproc *rproc = rvdev->rproc;
+ struct fw_rsc_vdev *rsc;
+
+ rsc = (void *)rproc->table_ptr + rvdev->rsc_offset;
+ rproc_idr_remove(rproc, rsc->notifyid);
+
unregister_virtio_device(&rvdev->vdev);
}