Skip to content

Commit 47be1f3

Browse files
wyr-7arnopo
authored andcommitted
rpmsg_virtio.c: replace metal_cpu_yield to new libmetal API metal_yield
The CPU yield is not supported by all OSes/processors. If not supported, this causes a busy loop that monopolizes the CPU. Replace it with the new metal_yield, it would be managed at the OS level and dispatched to metal_cpu_yield, metal_sleep_usec, or others. Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
1 parent 3541b57 commit 47be1f3

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

lib/remoteproc/remoteproc_virtio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <openamp/remoteproc.h>
1313
#include <openamp/remoteproc_virtio.h>
1414
#include <openamp/virtqueue.h>
15-
#include <metal/cpu.h>
15+
#include <metal/sys.h>
1616
#include <metal/utilities.h>
1717
#include <metal/alloc.h>
1818

@@ -412,6 +412,6 @@ void rproc_virtio_wait_remote_ready(struct virtio_device *vdev)
412412
status = rproc_virtio_get_status(vdev);
413413
if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK)
414414
return;
415-
metal_cpu_yield();
415+
metal_yield();
416416
}
417417
}

lib/rpmsg/rpmsg_virtio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <metal/alloc.h>
1212
#include <metal/sleep.h>
13+
#include <metal/sys.h>
1314
#include <metal/utilities.h>
1415
#include <openamp/rpmsg_virtio.h>
1516
#include <openamp/virtqueue.h>
@@ -271,8 +272,7 @@ static int rpmsg_virtio_wait_remote_ready(struct rpmsg_virtio_device *rvdev)
271272
} else if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK) {
272273
return 0;
273274
}
274-
/* TODO: clarify metal_cpu_yield usage*/
275-
metal_cpu_yield();
275+
metal_yield();
276276
}
277277
}
278278

0 commit comments

Comments
 (0)