A question regarding OpenAMP RPMsg example
Hi, I'm currently porting OpenAMP virtio to Arduino platform:
https://github.com/stm32duino/Arduino_Core_STM32/pull/766
I would like to share one thing about the OpenAMP examples in CubeMP1.
Here is the implementation of MAILBOX_Poll:
int MAILBOX_Poll(struct virtio_device *vdev)
{
/* If we got an interrupt, ask for the corresponding virtqueue processing */
int ret = -1;
/* USER CODE BEGIN PRE_MAILBOX_POLL */
/* USER CODE END PRE_MAILBOX_POLL */
if (msg_received_ch1 == RX_BUF_FREE) {
/* USER CODE BEGIN MSG_CHANNEL1 */
/* USER CODE END MSG_CHANNEL1 */
OPENAMP_log_dbg("Running virt0 (ch_1 buf free)\r\n");
rproc_virtio_notified(vdev, VRING0_ID);
msg_received_ch1 = RX_NO_MSG;
ret = 0;
}
if (msg_received_ch2 == RX_NEW_MSG) {
/* USER CODE BEGIN MSG_CHANNEL2 */
/* USER CODE END MSG_CHANNEL2 */
OPENAMP_log_dbg("Running virt1 (ch_2 new msg)\r\n");
rproc_virtio_notified(vdev, VRING1_ID);
msg_received_ch2 = RX_NO_MSG;
/* The OpenAMP framework does not notify for free buf: do it here */
rproc_virtio_notified(NULL, VRING1_ID);
ret = 0;
}I found a weird piece of code:
/* The OpenAMP framework does not notify for free buf: do it here */
rproc_virtio_notified(NULL, VRING1_ID);Because rproc_virtio_notified(NULL) essentially do nothing because rproc_virtio_notified() will return a error code -EINVAL :
int rproc_virtio_notified(struct virtio_device *vdev, uint32_t notifyid)
{
unsigned int num_vrings, i;
struct virtio_vring_info *vring_info;
struct virtqueue *vq;
if (!vdev)
return -EINVAL;
/* We do nothing for vdev notification in this implementation */
if (vdev->index == notifyid)
return 0;
num_vrings = vdev->vrings_num;
for (i = 0; i < num_vrings; i++) {
vring_info = &vdev->vrings_info[i];
if (vring_info->notifyid == notifyid ||
notifyid == RSC_NOTIFY_ID_ANY) {
vq = vring_info->vq;
virtqueue_notification(vq);
}
}
return 0;
}Could anyone tell me any reasons to suggest people using this line from the examples? I believe that this line should be considered as a bug.
Thank you,
Bumsik Kim.
