From patchwork Wed May 11 06:40:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 9065401 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 0C697BF29F for ; Wed, 11 May 2016 06:41:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6E88C201C0 for ; Wed, 11 May 2016 06:41:12 +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 E538A201B9 for ; Wed, 11 May 2016 06:41:00 +0000 (UTC) Received: from localhost ([::1]:50717 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0NpM-0001Up-3u for patchwork-qemu-devel@patchwork.kernel.org; Wed, 11 May 2016 02:41:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0NpB-0001PV-In for qemu-devel@nongnu.org; Wed, 11 May 2016 02:40:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0Np5-0005pE-Al for qemu-devel@nongnu.org; Wed, 11 May 2016 02:40:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48702) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0Np5-0005p9-4v for qemu-devel@nongnu.org; Wed, 11 May 2016 02:40:43 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 AA5557F093; Wed, 11 May 2016 06:40:42 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-14-147.nay.redhat.com [10.66.14.147]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4B6eaeQ020229; Wed, 11 May 2016 02:40:40 -0400 From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 11 May 2016 14:40:31 +0800 Message-Id: <1462948831-931-2-git-send-email-peterx@redhat.com> In-Reply-To: <1462948831-931-1-git-send-email-peterx@redhat.com> References: <1462948831-931-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 11 May 2016 06:40:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] pci: fix requester id to be the one on root bus 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: rkrcmar@redhat.com, mst@redhat.com, peterx@redhat.com, alex.williamson@redhat.com, jan.kiszka@web.de, pbonzini@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 When there are devices under PCI bridge (or bridges), PCI requester ID should be the one that hooked on the root PCI bus, not the PCI device itself. Signed-off-by: Peter Xu --- hw/pci/msi.c | 2 +- hw/pci/pci.c | 9 +++++++++ include/hw/pci/pci.h | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/hw/pci/msi.c b/hw/pci/msi.c index e0e64c2..1719716 100644 --- a/hw/pci/msi.c +++ b/hw/pci/msi.c @@ -315,7 +315,7 @@ void msi_send_message(PCIDevice *dev, MSIMessage msg) { MemTxAttrs attrs = {}; - attrs.requester_id = pci_requester_id(dev); + attrs.requester_id = pci_requester_id_recursive(dev); address_space_stl_le(&dev->bus_master_as, msg.address, msg.data, attrs, NULL); } diff --git a/hw/pci/pci.c b/hw/pci/pci.c index bb605ef..c14299b 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2498,6 +2498,15 @@ PCIDevice *pci_get_function_0(PCIDevice *pci_dev) } } +uint16_t pci_requester_id_recursive(PCIDevice *dev) +{ + while (pci_bus_num(dev->bus)) { + /* This is not on root PCI bus, we find its parent */ + dev = dev->bus->parent_dev; + } + return pci_requester_id(dev); +} + static const TypeInfo pci_device_type_info = { .name = TYPE_PCI_DEVICE, .parent = TYPE_DEVICE, diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index ef6ba51..4cb5b50 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -776,4 +776,6 @@ extern const VMStateDescription vmstate_pci_device; .offset = vmstate_offset_pointer(_state, _field, PCIDevice), \ } +uint16_t pci_requester_id_recursive(PCIDevice *dev); + #endif