From patchwork Fri Feb 9 15:17:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 871499 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zdMl302P1z9s7M for ; Sat, 10 Feb 2018 04:39:43 +1100 (AEDT) Received: from localhost ([::1]:49365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekCeD-00028i-2u for incoming@patchwork.ozlabs.org; Fri, 09 Feb 2018 12:39:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekBDa-0007MB-MR for qemu-devel@nongnu.org; Fri, 09 Feb 2018 11:08:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekBDY-0001Ft-DJ for qemu-devel@nongnu.org; Fri, 09 Feb 2018 11:08:06 -0500 Received: from leibniz.telenet-ops.be ([2a02:1800:110:4::f00:d]:34040) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ekBDX-0001Es-VG for qemu-devel@nongnu.org; Fri, 09 Feb 2018 11:08:04 -0500 Received: from andre.telenet-ops.be (andre.telenet-ops.be [IPv6:2a02:1800:120:4::f00:15]) by leibniz.telenet-ops.be (Postfix) with ESMTPS id 3zdJwl3ZK2zMqgCS for ; Fri, 9 Feb 2018 16:32:55 +0100 (CET) Received: from ayla.of.borg ([84.194.111.163]) by andre.telenet-ops.be with bizsmtp id 8fHm1x02J3XaVaC01fHmfz; Fri, 09 Feb 2018 16:17:50 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1ekAQs-0003Rv-Mv; Fri, 09 Feb 2018 16:17:46 +0100 Received: from geert by ramsan with local (Exim 4.86_2) (envelope-from ) id 1ekAQs-0000lF-M2; Fri, 09 Feb 2018 16:17:46 +0100 From: Geert Uytterhoeven To: Peter Maydell , Alex Williamson Date: Fri, 9 Feb 2018 16:17:32 +0100 Message-Id: <1518189456-2873-2-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518189456-2873-1-git-send-email-geert+renesas@glider.be> References: <1518189456-2873-1-git-send-email-geert+renesas@glider.be> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a02:1800:110:4::f00:d X-Mailman-Approved-At: Fri, 09 Feb 2018 12:38:16 -0500 Subject: [Qemu-devel] [PATCH/RFC 1/5] vfio/platform: make the vfio-platform device non abstract X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Geert Uytterhoeven , Arnd Bergmann , Wolfram Sang , Magnus Damm , Alexander Graf , qemu-devel@nongnu.org, linux-renesas-soc@vger.kernel.org, Auger Eric , qemu-arm@nongnu.org, Laurent Pinchart , Xiao Feng Ren Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Auger Eric Up to now the vfio-platform device has been abstract and could not be instantiated. The integration of a new vfio platform device required to create a dummy derived device which only set the compatibility string. Following the few vfio-platform device integration we have seen the actual requested adaptation happens on device tree node creation (sysbus-fdt). So this patch removes the abstract setting and defines 2 new options, manufacturer and model that are used to build a compatibility string. This latter will be used to match the device tree node creation function sysbus-fdt does not support the instantiation of the vfio-platform device yet. Signed-off-by: Eric Auger [geert: Rebase, Set user_creatable=true] Signed-off-by: Geert Uytterhoeven --- hw/vfio/platform.c | 20 ++++++++++++++++++-- include/hw/vfio/vfio-platform.h | 2 ++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index 0d4bc0aae8891435..32bed1974e23c569 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -637,7 +637,20 @@ static void vfio_platform_realize(DeviceState *dev, Error **errp) VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(dev); SysBusDevice *sbdev = SYS_BUS_DEVICE(dev); VFIODevice *vbasedev = &vdev->vbasedev; - int i, ret; + int i, ret = -EINVAL; + + if (!vdev->compat) { + if (!vdev->model) { + error_setg(errp, "no usable compatible string"); + goto out; + } + if (!vdev->manufacturer) { + vdev->compat = g_strdup(vdev->model); + } else { + vdev->compat = g_strjoin(",", vdev->manufacturer, + vdev->model, NULL); + } + } vbasedev->type = VFIO_DEVICE_TYPE_PLATFORM; vbasedev->dev = dev; @@ -681,6 +694,8 @@ static const VMStateDescription vfio_platform_vmstate = { static Property vfio_platform_dev_properties[] = { DEFINE_PROP_STRING("host", VFIOPlatformDevice, vbasedev.name), DEFINE_PROP_STRING("sysfsdev", VFIOPlatformDevice, vbasedev.sysfsdev), + DEFINE_PROP_STRING("manufacturer", VFIOPlatformDevice, manufacturer), + DEFINE_PROP_STRING("model", VFIOPlatformDevice, model), DEFINE_PROP_BOOL("x-no-mmap", VFIOPlatformDevice, vbasedev.no_mmap, false), DEFINE_PROP_UINT32("mmap-timeout-ms", VFIOPlatformDevice, mmap_timeout, 1100), @@ -699,6 +714,8 @@ static void vfio_platform_class_init(ObjectClass *klass, void *data) dc->desc = "VFIO-based platform device assignment"; sbc->connect_irq_notifier = vfio_start_irqfd_injection; set_bit(DEVICE_CATEGORY_MISC, dc->categories); + /* Supported by TYPE_VIRT_MACHINE */ + dc->user_creatable = true; } static const TypeInfo vfio_platform_dev_info = { @@ -707,7 +724,6 @@ static const TypeInfo vfio_platform_dev_info = { .instance_size = sizeof(VFIOPlatformDevice), .class_init = vfio_platform_class_init, .class_size = sizeof(VFIOPlatformDeviceClass), - .abstract = true, }; static void register_vfio_platform_dev_type(void) diff --git a/include/hw/vfio/vfio-platform.h b/include/hw/vfio/vfio-platform.h index 9baaa2db09b84f3e..31b9a9800f7d9d00 100644 --- a/include/hw/vfio/vfio-platform.h +++ b/include/hw/vfio/vfio-platform.h @@ -55,6 +55,8 @@ typedef struct VFIOPlatformDevice { /* queue of pending IRQs */ QSIMPLEQ_HEAD(pending_intp_queue, VFIOINTp) pending_intp_queue; char *compat; /* compatibility string */ + char *manufacturer; /* manufacturer (1st part of the compatible property) */ + char *model; /* model (2d part of the compatible property) */ uint32_t mmap_timeout; /* delay to re-enable mmaps after interrupt */ QEMUTimer *mmap_timer; /* allows fast-path resume after IRQ hit */ QemuMutex intp_mutex; /* protect the intp_list IRQ state */