handle_vdev_rsc must return error if notifyid cannot be assigned

Updated handle_vdev_rsc to return error if a unique id cannot be assigned
Signed-off-by: Tammy Leino <tammy_leino@mentor.com>
This commit is contained in:
Tammy Leino
2022-09-26 08:14:35 -07:00
committed by Arnaud Pouliquen
parent e40eea8ff1
commit 03c80a1341

View File

@@ -7,6 +7,7 @@
*/
#include <metal/io.h>
#include <metal/utilities.h>
#include <openamp/rsc_table_parser.h>
static int handle_dummy_rsc(struct remoteproc *rproc, void *rsc);
@@ -126,7 +127,9 @@ int handle_vendor_rsc(struct remoteproc *rproc, void *rsc)
int handle_vdev_rsc(struct remoteproc *rproc, void *rsc)
{
struct fw_rsc_vdev *vdev_rsc = rsc;
unsigned int notifyid, i, num_vrings;
int i, num_vrings;
unsigned int notifyid;
struct fw_rsc_vdev_vring *vring_rsc;
/* only assign notification IDs but do not initialize vdev */
notifyid = vdev_rsc->notifyid;
@@ -134,6 +137,8 @@ int handle_vdev_rsc(struct remoteproc *rproc, void *rsc)
notifyid, notifyid + 1);
if (notifyid != RSC_NOTIFY_ID_ANY)
vdev_rsc->notifyid = notifyid;
else
return -RPROC_ERR_RSC_TAB_NP;
num_vrings = vdev_rsc->num_of_vrings;
for (i = 0; i < num_vrings; i++) {
@@ -146,9 +151,20 @@ int handle_vdev_rsc(struct remoteproc *rproc, void *rsc)
notifyid + 1);
if (notifyid != RSC_NOTIFY_ID_ANY)
vring_rsc->notifyid = notifyid;
else
goto err;
}
return 0;
err:
for (i--; i >= 0; i--) {
vring_rsc = &vdev_rsc->vring[i];
metal_bitmap_clear_bit(&rproc->bitmap, vring_rsc->notifyid);
}
metal_bitmap_clear_bit(&rproc->bitmap, vdev_rsc->notifyid);
return -RPROC_ERR_RSC_TAB_NP;
}
/**