rpmsg: remote_device: virio ops: get/set actual vdev status
authorWendy Liang <jliang@xilinx.com>
Sun, 15 Jan 2017 07:03:39 +0000 (23:03 -0800)
committerWendy Liang <jliang@xilinx.com>
Fri, 3 Feb 2017 21:41:22 +0000 (13:41 -0800)
change get_status and set_status vdev operation to get/set the
actual virtio status from the resource table.

Signed-off-by: Wendy Liang <jliang@xilinx.com>
lib/rpmsg/remote_device.c

index d0828c7db51f754ed3d630faf4fe846e826a7a30..3d6a916f150840b746a8df3a7ef9f7ca7ac0326b 100644 (file)
 
 #include <string.h>
 #include "openamp/rpmsg.h"
+#include "openamp/remoteproc.h"
 #include "metal/utilities.h"
 #include "metal/alloc.h"
+#include "metal/atomic.h"
 
 /* Macro to initialize vring HW info */
 #define INIT_VRING_ALLOC_INFO(ring_info,vring_hw)                             \
@@ -467,14 +469,28 @@ int rpmsg_rdev_create_virtqueues(struct virtio_device *dev, int flags, int nvqs,
 
 unsigned char rpmsg_rdev_get_status(struct virtio_device *dev)
 {
-       (void)dev;
-       return 0;
+       struct hil_proc *proc = dev->device;
+       struct proc_vdev *pvdev = &proc->vdev;
+       struct fw_rsc_vdev *vdev_rsc = pvdev->vdev_info;
+
+       if (!vdev_rsc)
+               return -1;
+
+       return vdev_rsc->status;
 }
 
 void rpmsg_rdev_set_status(struct virtio_device *dev, unsigned char status)
 {
-       (void)dev;
-       (void)status;
+       struct hil_proc *proc = dev->device;
+       struct proc_vdev *pvdev = &proc->vdev;
+       struct fw_rsc_vdev *vdev_rsc = pvdev->vdev_info;
+
+       if (!vdev_rsc)
+               return;
+
+       vdev_rsc->status = status;
+
+       atomic_thread_fence(memory_order_seq_cst);
 }
 
 uint32_t rpmsg_rdev_get_feature(struct virtio_device *dev)