From patchwork Wed Jun 25 02:17:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiejun Chen X-Patchwork-Id: 363809 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 46F681400A7 for ; Wed, 25 Jun 2014 12:22:42 +1000 (EST) Received: from localhost ([::1]:34724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzcrA-000161-GD for incoming@patchwork.ozlabs.org; Tue, 24 Jun 2014 22:22:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wzcnv-0004W1-12 for qemu-devel@nongnu.org; Tue, 24 Jun 2014 22:19:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wzcnn-0005cA-UB for qemu-devel@nongnu.org; Tue, 24 Jun 2014 22:19:18 -0400 Received: from mga11.intel.com ([192.55.52.93]:60928) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wzcnn-0005ba-Om for qemu-devel@nongnu.org; Tue, 24 Jun 2014 22:19:11 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 24 Jun 2014 19:19:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,542,1400050800"; d="scan'208";a="560524755" Received: from tchen0-linux.bj.intel.com ([10.238.154.58]) by fmsmga002.fm.intel.com with ESMTP; 24 Jun 2014 19:19:08 -0700 From: Tiejun Chen To: pbonzini@redhat.com, anthony.perard@citrix.com, stefano.stabellini@eu.citrix.com, mst@redhat.com, Kelly.Zytaruk@amd.com Date: Wed, 25 Jun 2014 10:17:18 +0800 Message-Id: <1403662641-28526-3-git-send-email-tiejun.chen@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1403662641-28526-1-git-send-email-tiejun.chen@intel.com> References: <1403662641-28526-1-git-send-email-tiejun.chen@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.93 Cc: peter.maydell@linaro.org, xen-devel@lists.xensource.com, allen.m.kay@intel.com, qemu-devel@nongnu.org, anthony@codemonkey.ws, yang.z.zhang@intel.com Subject: [Qemu-devel] [v5][PATCH 2/5] xen, gfx passthrough: create pseudo intel isa bridge 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org ISA bridge is needed since Intel gfx drive will probe with Dev31:Fun0 to make graphics device passthrough work well for VMM, that only need to expose this pseudo ISA bridge to let driver know the real hardware underneath. The original patch is from Allen Kay Signed-off-by: Yang Zhang Signed-off-by: Tiejun Chen Cc: Allen Kay --- v5: * Don't set this ISA class property, instead, just fake this ISA bridge with 00:1f.0. v4: * Remove some unnecessary "return" in void foo(). v3: * Fix some typos. * Improve some return paths. v2: * Nothing is changed. hw/xen/xen_pt_graphics.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/hw/xen/xen_pt_graphics.c b/hw/xen/xen_pt_graphics.c index 461e526..974b7e9 100644 --- a/hw/xen/xen_pt_graphics.c +++ b/hw/xen/xen_pt_graphics.c @@ -230,3 +230,64 @@ out: g_free(bios); return rc; } + +static uint32_t isa_bridge_read_config(PCIDevice *d, uint32_t addr, int len) +{ + return pci_default_read_config(d, addr, len); +} + +static void isa_bridge_write_config(PCIDevice *d, uint32_t addr, uint32_t v, + int len) +{ + pci_default_write_config(d, addr, v, len); +} + +static void isa_bridge_class_init(ObjectClass *klass, void *data) +{ + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + + k->config_read = isa_bridge_read_config; + k->config_write = isa_bridge_write_config; +}; + +typedef struct { + PCIDevice dev; +} ISABridgeState; + +static TypeInfo isa_bridge_info = { + .name = "pseudo-intel-pch-isa-bridge", + .parent = TYPE_PCI_DEVICE, + .instance_size = sizeof(ISABridgeState), + .class_init = isa_bridge_class_init, +}; + +static void xen_pt_graphics_register_types(void) +{ + type_register_static(&isa_bridge_info); +} + +type_init(xen_pt_graphics_register_types) + +static int create_pseudo_pch_isa_bridge(PCIBus *bus, XenHostPCIDevice *hdev) +{ + struct PCIDevice *dev; + + char rid; + + /* We havt to use a simple PCI device to fake this ISA bridge + * to avoid making some confusion to BIOS and ACPI. + */ + dev = pci_create(bus, PCI_DEVFN(0x1f, 0), "pseudo-intel-pch-isa-bridge"); + + qdev_init_nofail(&dev->qdev); + + pci_config_set_vendor_id(dev->config, hdev->vendor_id); + pci_config_set_device_id(dev->config, hdev->device_id); + + xen_host_pci_get_block(hdev, PCI_REVISION_ID, (uint8_t *)&rid, 1); + + pci_config_set_revision(dev->config, rid); + + XEN_PT_LOG(dev, "The pseudo Intel PCH ISA bridge created.\n"); + return 0; +}