From patchwork Fri Jan 29 23:00:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shanker Donthineni X-Patchwork-Id: 8168711 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DA24CBEEE5 for ; Fri, 29 Jan 2016 23:19:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1718C20328 for ; Fri, 29 Jan 2016 23:19:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 68DA8201B9 for ; Fri, 29 Jan 2016 23:19:56 +0000 (UTC) Received: from localhost ([::1]:36894 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPIKZ-00073i-BU for patchwork-qemu-devel@patchwork.kernel.org; Fri, 29 Jan 2016 18:19:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPI1d-0001De-23 for qemu-devel@nongnu.org; Fri, 29 Jan 2016 18:00:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aPI1a-0008KC-BX for qemu-devel@nongnu.org; Fri, 29 Jan 2016 18:00:21 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:46739) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPI1a-0008K0-41 for qemu-devel@nongnu.org; Fri, 29 Jan 2016 18:00:18 -0500 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 9D12960499; Fri, 29 Jan 2016 23:00:17 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 90CB26044B; Fri, 29 Jan 2016 23:00:17 +0000 (UTC) Received: from shankerd-ubuntu.qualcomm.com (rrcs-67-52-129-61.west.biz.rr.com [67.52.129.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: shankerd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id E131160437; Fri, 29 Jan 2016 23:00:15 +0000 (UTC) From: Shanker Donthineni To: qemu-devel@nongnu.org Date: Fri, 29 Jan 2016 17:00:05 -0600 Message-Id: <1454108405-4822-3-git-send-email-shankerd@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454108405-4822-1-git-send-email-shankerd@codeaurora.org> References: <1454108405-4822-1-git-send-email-shankerd@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 198.145.29.96 X-Mailman-Approved-At: Fri, 29 Jan 2016 18:19:46 -0500 Cc: Peter Maydell , Christopher Covington , Vikram Sethi , Eric Auger , Kaya Sinan , Alex Williamson , Shanker Donthineni Subject: [Qemu-devel] [PATCH 2/2] hw/vfio/platform: Add Qualcomm Technologies, Inc HiDMA device support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Vikram Sethi This patch introduces a Qualcomm Technologies, Inc HiDMA device and allows the instantiation of the vfio-qcom-hidma device from the QEMU command line (-device vfio-qcom-hidma,host=""). A device tree node is created for the guest containing compat, dma-coherent, reg and interrupts properties. Signed-off-by: Vikram Sethi Signed-off-by: Shanker Donthineni --- hw/arm/sysbus-fdt.c | 2 ++ hw/vfio/Makefile.objs | 1 + hw/vfio/qcom-hidma.c | 57 +++++++++++++++++++++++++++++++++++++++ include/hw/vfio/vfio-qcom-hidma.h | 49 +++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+) create mode 100644 hw/vfio/qcom-hidma.c create mode 100644 include/hw/vfio/vfio-qcom-hidma.h diff --git a/hw/arm/sysbus-fdt.c b/hw/arm/sysbus-fdt.c index 6ee7af2..4a7419e 100644 --- a/hw/arm/sysbus-fdt.c +++ b/hw/arm/sysbus-fdt.c @@ -28,6 +28,7 @@ #include "sysemu/sysemu.h" #include "hw/vfio/vfio-platform.h" #include "hw/vfio/vfio-calxeda-xgmac.h" +#include "hw/vfio/vfio-qcom-hidma.h" #include "hw/arm/fdt.h" /* @@ -126,6 +127,7 @@ fail_reg: /* list of supported dynamic sysbus devices */ static const NodeCreationPair add_fdt_node_functions[] = { {TYPE_VFIO_CALXEDA_XGMAC, add_generic_platform_fdt_node}, + {TYPE_VFIO_QCOM_HIDMA, add_generic_platform_fdt_node}, {"", NULL}, /* last element */ }; diff --git a/hw/vfio/Makefile.objs b/hw/vfio/Makefile.objs index d324863..9bcb093 100644 --- a/hw/vfio/Makefile.objs +++ b/hw/vfio/Makefile.objs @@ -3,4 +3,5 @@ obj-$(CONFIG_SOFTMMU) += common.o obj-$(CONFIG_PCI) += pci.o pci-quirks.o obj-$(CONFIG_SOFTMMU) += platform.o obj-$(CONFIG_SOFTMMU) += calxeda-xgmac.o +obj-$(CONFIG_SOFTMMU) += qcom-hidma.o endif diff --git a/hw/vfio/qcom-hidma.c b/hw/vfio/qcom-hidma.c new file mode 100644 index 0000000..04acbd8 --- /dev/null +++ b/hw/vfio/qcom-hidma.c @@ -0,0 +1,57 @@ +/* + * Qualcomm Technologies, Inc VFIO HiDMA platform device + * + * Copyright (c) 2016, The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "hw/vfio/vfio-qcom-hidma.h" + +static void qcom_hidma_realize(DeviceState *dev, Error **errp) +{ + VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(dev); + VFIOQcomHidmaDeviceClass *k = VFIO_QCOM_HIDMA_DEVICE_GET_CLASS(dev); + + vdev->compat = g_strdup("qcom,hidma"); + + k->parent_realize(dev, errp); +} + +static const VMStateDescription vfio_platform_vmstate = { + .name = TYPE_VFIO_QCOM_HIDMA, + .unmigratable = 1, +}; + +static void vfio_qcom_hidma_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VFIOQcomHidmaDeviceClass *vcxc = VFIO_QCOM_HIDMA_DEVICE_CLASS(klass); + + vcxc->parent_realize = dc->realize; + dc->realize = qcom_hidma_realize; + dc->desc = "VFIO QCOM HIDMA"; +} + +static const TypeInfo vfio_qcom_hidma_dev_info = { + .name = TYPE_VFIO_QCOM_HIDMA, + .parent = TYPE_VFIO_PLATFORM, + .instance_size = sizeof(VFIOQcomHidmaDevice), + .class_init = vfio_qcom_hidma_class_init, + .class_size = sizeof(VFIOQcomHidmaDeviceClass), +}; + +static void register_qcom_hidma_dev_type(void) +{ + type_register_static(&vfio_qcom_hidma_dev_info); +} + +type_init(register_qcom_hidma_dev_type) diff --git a/include/hw/vfio/vfio-qcom-hidma.h b/include/hw/vfio/vfio-qcom-hidma.h new file mode 100644 index 0000000..a7cc8e6 --- /dev/null +++ b/include/hw/vfio/vfio-qcom-hidma.h @@ -0,0 +1,49 @@ +/* + * Qualcomm Technologies, Inc VFIO HiDMA platform device + * + * Copyright (c) 2016, The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef HW_VFIO_VFIO_QCOM_HIDMA_H +#define HW_VFIO_VFIO_QCOM_HIDMA_H + +#include "hw/vfio/vfio-platform.h" + +#define TYPE_VFIO_QCOM_HIDMA "vfio-qcom-hidma" + +/** + * This device exposes: + * - two MMIO regions corresponding to its register space + * - 1 IRQ + */ +typedef struct VFIOQcomHidmaDevice { + VFIOPlatformDevice vdev; +} VFIOQcomHidmaDevice; + +typedef struct VFIOQcomHidmaDeviceClass { + /*< private >*/ + VFIOPlatformDeviceClass parent_class; + /*< public >*/ + DeviceRealize parent_realize; +} VFIOQcomHidmaDeviceClass; + +#define VFIO_QCOM_HIDMA_DEVICE(obj) \ + OBJECT_CHECK(VFIOQcomHidmaDevice, (obj), TYPE_VFIO_QCOM_HIDMA) +#define VFIO_QCOM_HIDMA_DEVICE_CLASS(klass) \ + OBJECT_CLASS_CHECK(VFIOQcomHidmaDeviceClass, (klass), \ + TYPE_VFIO_QCOM_HIDMA) +#define VFIO_QCOM_HIDMA_DEVICE_GET_CLASS(obj) \ + OBJECT_GET_CLASS(VFIOQcomHidmaDeviceClass, (obj), \ + TYPE_VFIO_QCOM_HIDMA) + +#endif