From patchwork Sun Aug 15 19:57:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduard - Gabriel Munteanu X-Patchwork-Id: 61760 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 6E16EB70B4 for ; Mon, 16 Aug 2010 06:29:45 +1000 (EST) Received: from localhost ([127.0.0.1]:52695 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Okjpt-0004fM-Pq for incoming@patchwork.ozlabs.org; Sun, 15 Aug 2010 16:29:41 -0400 Received: from [140.186.70.92] (port=55980 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OkjlW-0002l1-8o for qemu-devel@nongnu.org; Sun, 15 Aug 2010 16:25:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OkjNx-0001q6-Rp for qemu-devel@nongnu.org; Sun, 15 Aug 2010 16:00:50 -0400 Received: from mail-fx0-f45.google.com ([209.85.161.45]:54649) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OkjNx-0001pt-M8 for qemu-devel@nongnu.org; Sun, 15 Aug 2010 16:00:49 -0400 Received: by fxm7 with SMTP id 7so2803599fxm.4 for ; Sun, 15 Aug 2010 13:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:cc:subject :date:message-id:x-mailer; bh=xPc4HSeNWIyQ/O2uurkLcFv1lkpArrpyrQdwN9/taAc=; b=r5VPMko1jYKP37kVtU1e7f6XuDeN7Hfjqgur82gUL2Kh02hJRIQb07eD2wNmtQs0Np u9xgP1etWjL+ocy+Bs3YkQoCQJkRE8NLkZUhj6Y+opha4jdsqA2bw0l+PBUjcFdtWAo7 P+IunE+Tf8QNYT0Y7GGK+2zsTubxv4O8D87EE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer; b=lgT6dxU41f9Mou3uVQg+EIaPRgaQrM8CNmDUu/iR4CgeXr8zUeEQZwYdKlj8ZgiXFZ T6M02H1zi5c05Mdm4jyJvP+D1mT8SMAdJ6Nf3Rc0TvOKk0PClF4yxjErGtp5KTYbssZ0 5GoehAFf+RSXWzfVWFPG0UiAtDVULzu4wKXnk= Received: by 10.223.108.137 with SMTP id f9mr4436546fap.3.1281902448845; Sun, 15 Aug 2010 13:00:48 -0700 (PDT) Received: from localhost.localdomain ([178.138.32.54]) by mx.google.com with ESMTPS id e17sm536426faa.15.2010.08.15.13.00.42 (version=SSLv3 cipher=RC4-MD5); Sun, 15 Aug 2010 13:00:48 -0700 (PDT) From: Eduard - Gabriel Munteanu To: joro@8bytes.org Date: Sun, 15 Aug 2010 22:57:26 +0300 Message-Id: <1281902247-5151-1-git-send-email-eduard.munteanu@linux360.ro> X-Mailer: git-send-email 1.7.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: kvm@vger.kernel.org, seabios@seabios.org, qemu-devel@nongnu.org, blauwirbel@gmail.com, paul@codesourcery.com, Eduard - Gabriel Munteanu , avi@redhat.com Subject: [Qemu-devel] [PATCH 1/2] Split region allocation code from pci_bios_init_device() 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 pci_bios_alloc() can be used to allocate space in the PCI region for other purposes. This is needed by the AMD IOMMU support code. Signed-off-by: Eduard - Gabriel Munteanu --- src/pciinit.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/pciinit.c b/src/pciinit.c index 0556ee2..bfc669f 100644 --- a/src/pciinit.c +++ b/src/pciinit.c @@ -75,6 +75,16 @@ static void pci_bios_init_bridges(u16 bdf) } } +static inline u32 pci_bios_alloc(u32 *region, u32 size) +{ + u32 ret; + + ret = ALIGN(*region, size); + *region = ret + size; + + return ret; +} + static void pci_bios_init_device(u16 bdf) { int class; @@ -146,14 +156,13 @@ static void pci_bios_init_device(u16 bdf) pci_config_writel(bdf, ofs, old); if (val != 0) { - u32 size = (~(val & mask)) + 1; + u32 base, size = (~(val & mask)) + 1; if (val & PCI_BASE_ADDRESS_SPACE_IO) paddr = &pci_bios_io_addr; else paddr = &pci_bios_mem_addr; - *paddr = ALIGN(*paddr, size); - pci_set_io_region_addr(bdf, i, *paddr); - *paddr += size; + base = pci_bios_alloc(paddr, size); + pci_set_io_region_addr(bdf, i, base); } } break;