From patchwork Fri Oct 2 19:30:57 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 34878 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 77711B7BBD for ; Sat, 3 Oct 2009 05:31:48 +1000 (EST) Received: from localhost ([127.0.0.1]:54707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mtnqz-0003Xd-FW for incoming@patchwork.ozlabs.org; Fri, 02 Oct 2009 15:31:45 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MtnqM-0003U2-Er for qemu-devel@nongnu.org; Fri, 02 Oct 2009 15:31:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MtnqJ-0003Sa-0D for qemu-devel@nongnu.org; Fri, 02 Oct 2009 15:31:06 -0400 Received: from [199.232.76.173] (port=34430 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MtnqI-0003SV-P2 for qemu-devel@nongnu.org; Fri, 02 Oct 2009 15:31:02 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:60021) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MtnqI-0000YG-Ab for qemu-devel@nongnu.org; Fri, 02 Oct 2009 15:31:02 -0400 Received: from ls (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id 8ECAE49D03; Sat, 3 Oct 2009 04:30:57 +0900 (JST) Received: (nullmailer pid 18294 invoked by uid 20675); Fri, 02 Oct 2009 19:30:57 -0000 Date: Sat, 3 Oct 2009 04:30:57 +0900 From: Isaku Yamahata To: Gerd Hoffmann Subject: Re: [Qemu-devel] [PATCH 00/25] pci: various pci clean up and pci express support. V2 Message-ID: <20091002193057.GB24813%yamahata@valinux.co.jp> References: <1254479517-25845-1-git-send-email-yamahata@valinux.co.jp> <4AC5FE5A.8000901@redhat.com> <4AC60331.20604@redhat.com> Mime-Version: 1.0 Content-Disposition: inline In-Reply-To: <4AC60331.20604@redhat.com> User-Agent: Mutt/1.5.6i X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: qemu-devel@nongnu.org X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Thank you for testing. Does the following patch helps? diff --git a/hw/pci.c b/hw/pci.c index 24aaba0..d562410 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -812,10 +812,15 @@ static uint32_t pci_data_read_common(PCIDevice *pci_dev, static inline PCIDevice *pci_addr_to_dev(PCIBus *bus, uint32_t addr) { - int bus_num = (addr >> 16) & 0xff; - unsigned int devfn = (addr >> 8) & 0xff; + uint8_t bus_num = (addr >> 16) & 0xff; + uint8_t devfn = (addr >> 8) & 0xff; + PCIBus *s = pci_find_bus(bus, bus_num); - return pci_find_device(bus, bus_num, PCI_SLOT(devfn), PCI_FUNC(devfn)); + if (!s) { + return NULL; + } + + return pci_find_device(s, bus_num, PCI_SLOT(devfn), PCI_FUNC(devfn)); } static inline uint32_t pci_addr_to_config(uint32_t addr)