Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpmsg: set ept address to incease num when alloc from the bitmap #514

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/include/openamp/rpmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ struct rpmsg_device {

/** Table endpoint address allocation */
unsigned long bitmap[metal_bitmap_longs(RPMSG_ADDR_BMP_SIZE)];
unsigned int bitnext;

/** Mutex lock for RPMsg management */
metal_mutex_t lock;
Expand Down
7 changes: 4 additions & 3 deletions lib/rpmsg/rpmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
*
* @return A unique address
*/
static uint32_t rpmsg_get_address(unsigned long *bitmap, int size)
static uint32_t rpmsg_get_address(unsigned long *bitmap, unsigned int start, int size)
{
unsigned int addr = RPMSG_ADDR_ANY;
unsigned int nextbit;

nextbit = metal_bitmap_next_clear_bit(bitmap, 0, size);
nextbit = metal_bitmap_next_clear_bit(bitmap, start, size);
if (nextbit < (uint32_t)size) {
addr = RPMSG_RESERVED_ADDRESSES + nextbit;
metal_bitmap_set_bit(bitmap, nextbit);
Expand Down Expand Up @@ -277,11 +277,12 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,

metal_mutex_acquire(&rdev->lock);
if (src == RPMSG_ADDR_ANY) {
addr = rpmsg_get_address(rdev->bitmap, RPMSG_ADDR_BMP_SIZE);
addr = rpmsg_get_address(rdev->bitmap, rdev->bitnext, RPMSG_ADDR_BMP_SIZE);
if (addr == RPMSG_ADDR_ANY) {
status = RPMSG_ERR_ADDR;
goto ret_status;
}
rdev->bitnext = (addr + 1) % RPMSG_ADDR_BMP_SIZE;
} else if (src >= RPMSG_RESERVED_ADDRESSES) {
status = rpmsg_is_address_set(rdev->bitmap,
RPMSG_ADDR_BMP_SIZE, src);
Expand Down