From nobody Fri May 3 11:22:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487684890281850.1739863033517; Tue, 21 Feb 2017 05:48:10 -0800 (PST) Received: from localhost ([::1]:45191 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgAnX-0000aW-W3 for importer@patchew.org; Tue, 21 Feb 2017 08:48:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgAKx-0006YK-Np for qemu-devel@nongnu.org; Tue, 21 Feb 2017 08:18:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgAKw-0003Yi-Q8 for qemu-devel@nongnu.org; Tue, 21 Feb 2017 08:18:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58766) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgAKu-0003XE-2q; Tue, 21 Feb 2017 08:18:32 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1F5B78047A; Tue, 21 Feb 2017 13:18:32 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-95.ams2.redhat.com [10.36.116.95]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1LDIPH7028228; Tue, 21 Feb 2017 08:18:29 -0500 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, peter.maydell@linaro.org, alex.williamson@redhat.com, qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Tue, 21 Feb 2017 14:18:19 +0100 Message-Id: <1487683100-16013-2-git-send-email-eric.auger@redhat.com> In-Reply-To: <1487683100-16013-1-git-send-email-eric.auger@redhat.com> References: <1487683100-16013-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 21 Feb 2017 13:18:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/2] 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: okaya@codeaurora.org, pelcan@codeaurora.org, vikrams@codeaurora.org, shankerd@codeaurora.org, agraf@suse.de Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- hw/vfio/platform.c | 18 ++++++++++++++++-- include/hw/vfio/vfio-platform.h | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index a4663c9..73c0489 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -637,7 +637,20 @@ static void vfio_platform_realize(DeviceState *dev, Er= ror **errp) VFIOPlatformDevice *vdev =3D VFIO_PLATFORM_DEVICE(dev); SysBusDevice *sbdev =3D SYS_BUS_DEVICE(dev); VFIODevice *vbasedev =3D &vdev->vbasedev; - int i, ret; + int i, ret =3D -EINVAL; + + if (!vdev->compat) { + if (!vdev->model) { + error_setg(errp, "no usable compatible string"); + goto out; + } + if (!vdev->manufacturer) { + vdev->compat =3D g_strdup(vdev->model); + } else { + vdev->compat =3D g_strjoin(",", vdev->manufacturer, + vdev->model, NULL); + } + } =20 vbasedev->type =3D VFIO_DEVICE_TYPE_PLATFORM; vbasedev->ops =3D &vfio_platform_ops; @@ -678,6 +691,8 @@ static const VMStateDescription vfio_platform_vmstate = =3D { static Property vfio_platform_dev_properties[] =3D { 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, fa= lse), DEFINE_PROP_UINT32("mmap-timeout-ms", VFIOPlatformDevice, mmap_timeout, 1100), @@ -704,7 +719,6 @@ static const TypeInfo vfio_platform_dev_info =3D { .instance_size =3D sizeof(VFIOPlatformDevice), .class_init =3D vfio_platform_class_init, .class_size =3D sizeof(VFIOPlatformDeviceClass), - .abstract =3D true, }; =20 static void register_vfio_platform_dev_type(void) diff --git a/include/hw/vfio/vfio-platform.h b/include/hw/vfio/vfio-platfor= m.h index 9baaa2db..31b9a98 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 proper= ty) */ + 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 */ --=20 2.5.5 From nobody Fri May 3 11:22:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487684516903869.9100290138283; Tue, 21 Feb 2017 05:41:56 -0800 (PST) Received: from localhost ([::1]:45026 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgAhW-00033i-Iy for importer@patchew.org; Tue, 21 Feb 2017 08:41:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60289) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgAL0-0006cF-Vm for qemu-devel@nongnu.org; Tue, 21 Feb 2017 08:18:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgAKz-0003Zq-St for qemu-devel@nongnu.org; Tue, 21 Feb 2017 08:18:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46130) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgAKw-0003YQ-T3; Tue, 21 Feb 2017 08:18:35 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0BDD213590; Tue, 21 Feb 2017 13:18:35 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-95.ams2.redhat.com [10.36.116.95]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1LDIPH8028228; Tue, 21 Feb 2017 08:18:32 -0500 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, peter.maydell@linaro.org, alex.williamson@redhat.com, qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Tue, 21 Feb 2017 14:18:20 +0100 Message-Id: <1487683100-16013-3-git-send-email-eric.auger@redhat.com> In-Reply-To: <1487683100-16013-1-git-send-email-eric.auger@redhat.com> References: <1487683100-16013-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 21 Feb 2017 13:18:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] hw/arm/sysbus-fdt: Allow device matching with compat string 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: okaya@codeaurora.org, pelcan@codeaurora.org, vikrams@codeaurora.org, shankerd@codeaurora.org, agraf@suse.de Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Up to now we have relied on the device type to identify a device tree node creation function. Since we would like the VFIO-PLATFORM device to be instantiable with different compatibility strings we introduce the capability to specialize the node creation depending on a manufacturer/model combo. NodeCreationPair is renamed into BindingEntry. The struct is enhanced with manufacturer, model and match_fn() fields. We introduce a new matching function adapted to vfio-platform generic device. From now on, the AMD XGBE can be instantiated with either manner, ie: -device vfio-amd-xgbe,host=3De0900000.xgmac or new option line: -device vfio-platform,host=3De0900000.xgmac,manufacturer=3Damd,model=3Dxgbe= -seattle-v1a Signed-off-by: Eric Auger --- hw/arm/sysbus-fdt.c | 59 +++++++++++++++++++++++++++++++++++++++++--------= ---- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/hw/arm/sysbus-fdt.c b/hw/arm/sysbus-fdt.c index d68e3dc..a0539e1 100644 --- a/hw/arm/sysbus-fdt.c +++ b/hw/arm/sysbus-fdt.c @@ -58,11 +58,14 @@ typedef struct PlatformBusFDTNotifierParams { ARMPlatformBusFDTParams *fdt_params; } PlatformBusFDTNotifierParams; =20 -/* struct that associates a device type name and a node creation function = */ -typedef struct NodeCreationPair { +/* struct that allows to match a device and create its FDT node */ +typedef struct BindingEntry { const char *typename; - int (*add_fdt_node_fn)(SysBusDevice *sbdev, void *opaque); -} NodeCreationPair; + const char *manufacturer; + const char *model; + int (*add_fn)(SysBusDevice *sbdev, void *opaque); + bool (*match_fn)(SysBusDevice *sbdev, const struct BindingEntry *combo= ); +} BindingEntry; =20 /* helpers */ =20 @@ -415,13 +418,42 @@ static int add_amd_xgbe_fdt_node(SysBusDevice *sbdev,= void *opaque) =20 #endif /* CONFIG_LINUX */ =20 -/* list of supported dynamic sysbus devices */ -static const NodeCreationPair add_fdt_node_functions[] =3D { +/* Device type based matching */ +static bool type_match(SysBusDevice *sbdev, const BindingEntry *entry) +{ + return !strcmp(object_get_typename(OBJECT(sbdev)), entry->typename); +} + +/* manufacturer/model matching */ +static bool vfio_platform_match(SysBusDevice *sbdev, + const BindingEntry *entry) +{ + VFIOPlatformDevice *vdev =3D VFIO_PLATFORM_DEVICE(sbdev); + + if (strcmp(entry->model, vdev->model)) { + return false; + } + + if (entry->manufacturer) { + if (!vdev->manufacturer) { + return false; + } + return !strcmp(entry->manufacturer, vdev->manufacturer); + } + return true; +} + +#define TYPE_BINDING(type, add_fn) {(type), NULL, NULL, (add_fn), type_mat= ch} +#define VFIO_PLATFORM_BINDING(manuf, model, add_fn) \ + {TYPE_VFIO_PLATFORM, (manuf), (model), (add_fn), vfio_platform_match} + +/* list of supported dynamic sysbus bindings */ +static const BindingEntry bindings[] =3D { #ifdef CONFIG_LINUX - {TYPE_VFIO_CALXEDA_XGMAC, add_calxeda_midway_xgmac_fdt_node}, - {TYPE_VFIO_AMD_XGBE, add_amd_xgbe_fdt_node}, + TYPE_BINDING(TYPE_VFIO_CALXEDA_XGMAC, add_calxeda_midway_xgmac_fdt_nod= e), + TYPE_BINDING(TYPE_VFIO_AMD_XGBE, add_amd_xgbe_fdt_node), + VFIO_PLATFORM_BINDING("amd", "xgbe-seattle-v1a", add_amd_xgbe_fdt_node= ), #endif - {"", NULL}, /* last element */ }; =20 /* Generic Code */ @@ -440,10 +472,11 @@ static void add_fdt_node(SysBusDevice *sbdev, void *o= paque) { int i, ret; =20 - for (i =3D 0; i < ARRAY_SIZE(add_fdt_node_functions); i++) { - if (!strcmp(object_get_typename(OBJECT(sbdev)), - add_fdt_node_functions[i].typename)) { - ret =3D add_fdt_node_functions[i].add_fdt_node_fn(sbdev, opaqu= e); + for (i =3D 0; i < ARRAY_SIZE(bindings); i++) { + const BindingEntry *iter =3D &bindings[i]; + + if (iter->match_fn(sbdev, iter)) { + ret =3D iter->add_fn(sbdev, opaque); assert(!ret); return; } --=20 2.5.5