Skip to content

Commit

Permalink
remoteproc: allow end is 0 in notify id allocation
Browse files Browse the repository at this point in the history
remoteproc notify id allocation should also consider
input end is 0 case. As max=0 is not allowed in the
libmetal bitmap util to search for next available bit.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Signed-off-by: Wendy Liang <wendy.liang@xilinx.com>
  • Loading branch information
xiaoxiang781216 authored and Wendy Liang committed Jan 16, 2019
1 parent c79d17f commit 67ddf36
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
10 changes: 7 additions & 3 deletions lib/remoteproc/remoteproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,12 +841,16 @@ unsigned int remoteproc_allocate_id(struct remoteproc *rproc,

if (start == RSC_NOTIFY_ID_ANY)
start = 0;
if (end == RSC_NOTIFY_ID_ANY)
if (end == 0)
end = METAL_BITS_PER_ULONG;
notifyid = metal_bitmap_next_set_bit(&rproc->bitmap,
start, end);

notifyid = metal_bitmap_next_clear_bit(&rproc->bitmap,
start, end);
if (notifyid != end)
metal_bitmap_set_bit(&rproc->bitmap, notifyid);
else
notifyid = RSC_NOTIFY_ID_ANY;

return notifyid;
}

Expand Down
16 changes: 7 additions & 9 deletions lib/remoteproc/rsc_table_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,22 @@ int handle_vdev_rsc(struct remoteproc *rproc, void *rsc)

/* only assign notification IDs but do not initialize vdev */
notifyid = vdev_rsc->notifyid;
if (notifyid == RSC_NOTIFY_ID_ANY) {
notifyid = remoteproc_allocate_id(rproc,
notifyid, notifyid + 1);
notifyid = remoteproc_allocate_id(rproc,
notifyid, notifyid + 1);
if (notifyid != RSC_NOTIFY_ID_ANY)
vdev_rsc->notifyid = notifyid;
}

num_vrings = vdev_rsc->num_of_vrings;
for (i = 0; i < num_vrings; i++) {
struct fw_rsc_vdev_vring *vring_rsc;

vring_rsc = &vdev_rsc->vring[i];
notifyid = vring_rsc->notifyid;
if (notifyid == RSC_NOTIFY_ID_ANY) {
notifyid = remoteproc_allocate_id(rproc,
notifyid,
notifyid + 1);
notifyid = remoteproc_allocate_id(rproc,
notifyid,
notifyid + 1);
if (notifyid != RSC_NOTIFY_ID_ANY)
vdev_rsc->notifyid = notifyid;
}
}

return 0;
Expand Down

0 comments on commit 67ddf36

Please sign in to comment.