From patchwork Mon Oct 12 15:17:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcel Apfelbaum X-Patchwork-Id: 529173 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 74609140082 for ; Tue, 13 Oct 2015 02:18:48 +1100 (AEDT) Received: from localhost ([::1]:56070 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZlesA-0003tQ-EX for incoming@patchwork.ozlabs.org; Mon, 12 Oct 2015 11:18:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZlerQ-00038i-T3 for qemu-devel@nongnu.org; Mon, 12 Oct 2015 11:18:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZlerN-00056I-Ji for qemu-devel@nongnu.org; Mon, 12 Oct 2015 11:18:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39129) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZlerN-00056E-DR for qemu-devel@nongnu.org; Mon, 12 Oct 2015 11:17:57 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 048343091D2 for ; Mon, 12 Oct 2015 15:17:57 +0000 (UTC) Received: from work.redhat.com (vpn1-7-242.ams2.redhat.com [10.36.7.242]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9CFHtAX005636; Mon, 12 Oct 2015 11:17:55 -0400 From: Marcel Apfelbaum To: qemu-devel@nongnu.org Date: Mon, 12 Oct 2015 18:17:54 +0300 Message-Id: <1444663074-32617-1-git-send-email-marcel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: marcel@redhat.com, mst@redhat.com Subject: [Qemu-devel] [PATCH RFC] hw/virtio: Add PCIe capability to virtio devices 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 The virtio devices are converted to PCI-Express if they are plugged into a PCI-Express bus and the 'modern' protocol is enabled. Signed-off-by: Marcel Apfelbaum --- This is an RFC because all it does it adds the PCIe capability and nothing more. I post it early so I can get feedbacks on what is the best way to continue it. Any comments would be appreciated, Thanks, Marcel hw/virtio/virtio-pci.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 6703806..f7c93d9 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1591,6 +1591,17 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp) address_space_init(&proxy->modern_as, &proxy->modern_cfg, "virtio-pci-cfg-as"); + if (!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN) + && pci_bus_is_express(pci_dev->bus)) { + int pos = pci_add_capability(pci_dev, PCI_CAP_ID_EXP, 0, + PCI_EXP_VER2_SIZEOF); + + if (pos > 0) { + pci_dev->exp.exp_cap = pos; + pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS; + } + } + virtio_pci_bus_new(&proxy->bus, sizeof(proxy->bus), proxy); if (k->realize) { k->realize(proxy, errp);