qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Baptiste Reynal <b.reynal@virtualopensystems.com>
To: kvmarm@lists.cs.columbia.edu, qemu-devel@nongnu.org
Cc: Alex Williamson <alex.williamson@redhat.com>,
	tech@virtualopensystems.com,
	Baptiste Reynal <b.reynal@virtualopensystems.com>
Subject: [Qemu-devel] [RFC PATCH v3 2/3] hw/vfio: amba device support
Date: Wed, 11 Feb 2015 17:22:02 +0100	[thread overview]
Message-ID: <1423671724-13167-3-git-send-email-b.reynal@virtualopensystems.com> (raw)
In-Reply-To: <1423671724-13167-1-git-send-email-b.reynal@virtualopensystems.com>

Add VFIO_DEVICE_TYPE_AMBA.
Differentiate amba and platform devices according to compatible string.

Signed-off-by: Baptiste Reynal <b.reynal@virtualopensystems.com>

---
v2 -> v3:
add amba flag check in vfio_populate_device
---
 hw/vfio/platform.c            | 20 +++++++++++++++-----
 include/hw/vfio/vfio-common.h |  1 +
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
index 4bc989c..04cd3dd 100644
--- a/hw/vfio/platform.c
+++ b/hw/vfio/platform.c
@@ -422,8 +422,9 @@ static int vfio_populate_device(VFIODevice *vbasedev)
     VFIOPlatformDevice *vdev =
         container_of(vbasedev, VFIOPlatformDevice, vbasedev);
 
-    if (!(vbasedev->flags & VFIO_DEVICE_FLAGS_PLATFORM)) {
-        error_report("vfio: Um, this isn't a platform device");
+    if (!(vbasedev->flags & (VFIO_DEVICE_FLAGS_PLATFORM |
+                    VFIO_DEVICE_FLAGS_AMBA))) {
+        error_report("vfio: Um, this isn't a platform neither an amba device");
         goto error;
     }
 
@@ -521,8 +522,13 @@ static int vfio_base_device_init(VFIODevice *vbasedev)
     }
 
     /* Check that the host device exists */
-    snprintf(path, sizeof(path), "/sys/bus/platform/devices/%s/",
-             vbasedev->name);
+    if (vbasedev->type == VFIO_DEVICE_TYPE_AMBA) {
+        snprintf(path, sizeof(path), "/sys/bus/amba/devices/%s/",
+                vbasedev->name);
+    } else {
+        snprintf(path, sizeof(path), "/sys/bus/platform/devices/%s/",
+                vbasedev->name);
+    }
 
     if (stat(path, &st) < 0) {
         error_report("vfio: error: no such host device: %s", path);
@@ -619,7 +625,11 @@ static void vfio_platform_realize(DeviceState *dev, Error **errp)
     VFIODevice *vbasedev = &vdev->vbasedev;
     int i, ret;
 
-    vbasedev->type = VFIO_DEVICE_TYPE_PLATFORM;
+    if (strstr(vdev->compat, "arm,primecell")) {
+        vbasedev->type = VFIO_DEVICE_TYPE_AMBA;
+    } else {
+        vbasedev->type = VFIO_DEVICE_TYPE_PLATFORM;
+    }
     vbasedev->ops = &vfio_platform_ops;
 
 #ifdef CONFIG_KVM
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
index b5af090..8ab880a 100644
--- a/include/hw/vfio/vfio-common.h
+++ b/include/hw/vfio/vfio-common.h
@@ -44,6 +44,7 @@
 enum {
     VFIO_DEVICE_TYPE_PCI = 0,
     VFIO_DEVICE_TYPE_PLATFORM = 1,
+    VFIO_DEVICE_TYPE_AMBA = 2,
 };
 
 typedef struct VFIORegion {
-- 
2.3.0

  parent reply	other threads:[~2015-02-11 16:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-11 16:22 [Qemu-devel] [RFC PATCH v3 0/3] VFIO support for AMBA devices Baptiste Reynal
2015-02-11 16:22 ` [Qemu-devel] [RFC PATCH v3 1/3] hw/vfio/sysbus-fdt: helper routines to create fdt nodes Baptiste Reynal
2015-02-11 16:22 ` Baptiste Reynal [this message]
2015-02-11 16:22 ` [Qemu-devel] [RFC PATCH v3 3/3] hw/vfio: add pl330 device support Baptiste Reynal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1423671724-13167-3-git-send-email-b.reynal@virtualopensystems.com \
    --to=b.reynal@virtualopensystems.com \
    --cc=alex.williamson@redhat.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=qemu-devel@nongnu.org \
    --cc=tech@virtualopensystems.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).