From patchwork Thu Oct 13 00:04:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timothy Pearson X-Patchwork-Id: 681505 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3svWG547Wcz9s9N for ; Thu, 13 Oct 2016 11:05:33 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=raptorengineering.com header.i=@raptorengineering.com header.b=fLV2Q2nF; dkim-atps=neutral Received: from [127.0.0.1] (helo=ra.coresystems.de) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1buTVj-0003zV-N5; Thu, 13 Oct 2016 02:04:35 +0200 Received: from mail.rptsys.com ([192.119.205.245]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1buTVa-0003yW-3b for flashrom@flashrom.org; Thu, 13 Oct 2016 02:04:33 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 19376641014 for ; Wed, 12 Oct 2016 19:04:18 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id u2OH-4s25M68 for ; Wed, 12 Oct 2016 19:04:17 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 3EA596410DD for ; Wed, 12 Oct 2016 19:04:17 -0500 (CDT) DKIM-Filter: OpenDKIM Filter v2.9.2 mail.rptsys.com 3EA596410DD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1476317057; bh=4HhIgyx6VPQvmsqyALTBRzR8gb6M+mI8SHeMsJraat8=; h=Date:From:To:Message-ID:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding; b=fLV2Q2nF8R7vruJmjQJMZddcMSWpI5uUl1AAQ9dbw+MvV5pNTCxaqANVHpEBZmNqe a8B4PP8zZrFhSDZzhOUKJr0W7Tt9mBzfrrSqW13B2HK9xNQKckOdqcsifrPB295FXU 75rdz0PiwcunHdN6UReUZdSq/nmIGa3fZl0v11Gs= X-Virus-Scanned: amavisd-new at rptsys.com Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id JMGorYhDgGci for ; Wed, 12 Oct 2016 19:04:17 -0500 (CDT) Received: from vali.starlink.edu (vali.starlink.edu [192.168.3.21]) by mail.rptsys.com (Postfix) with ESMTP id 06BD2641014 for ; Wed, 12 Oct 2016 19:04:17 -0500 (CDT) Date: Wed, 12 Oct 2016 19:04:16 -0500 (CDT) From: Timothy Pearson To: flashrom@flashrom.org Message-ID: <1018126846.101912.1476317056958.JavaMail.zimbra@raptorengineeringinc.com> MIME-Version: 1.0 X-Mailer: Zimbra 8.5.0_GA_3042 (ZimbraWebClient - FF3.6 (Linux)/8.5.0_GA_3042) Thread-Topic: Obtain correct virtual address for 32-bit BARs on PPC Thread-Index: 4BnJAZ3t1/Z0/xwQND23Fk7R2rIY+g== X-Spam-Score: -6.6 (------) Subject: [flashrom] [PATCH 1/4] Obtain correct virtual address for 32-bit BARs on PPC X-BeenThere: flashrom@flashrom.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: flashrom discussion and development mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: flashrom-bounces@flashrom.org Sender: "flashrom" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff PowerPC systems have the ability to map 32-bit BARs into 64-bit host windows. Reading the BAR directly from the hardware is insufficient on these machines; use the libpci deb->base_addr[x] mechanism instead. --- pcidev.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pcidev.c b/pcidev.c index 2c78063..34b948b 100644 --- a/pcidev.c +++ b/pcidev.c @@ -37,11 +37,13 @@ enum pci_bartype { uintptr_t pcidev_readbar(struct pci_dev *dev, int bar) { uint64_t addr; - uint32_t upperaddr; uint8_t headertype; uint16_t supported_cycles; enum pci_bartype bartype = TYPE_UNKNOWN; +#ifndef __PPC64__ + uint32_t upperaddr; +#endif headertype = pci_read_byte(dev, PCI_HEADER_TYPE) & 0x7f; msg_pspew("PCI header type 0x%02x\n", headertype); @@ -97,6 +99,12 @@ uintptr_t pcidev_readbar(struct pci_dev *dev, int bar) switch (bartype) { case TYPE_MEMBAR: msg_pdbg("MEM"); +#ifdef __PPC64__ + /* PowerPC is able to translate 32-bit BARs into 64-bit host windows. + * Use the dev->base_addr[x] mechanism to handle mapping. + */ + addr = dev->base_addr[(bar - 0x10) / 0x4] & PCI_BASE_ADDRESS_MEM_MASK; +#else if (!(supported_cycles & PCI_COMMAND_MEMORY)) { msg_perr("MEM BAR access requested, but device has MEM space accesses disabled.\n"); /* TODO: Abort here? */ @@ -122,6 +130,7 @@ uintptr_t pcidev_readbar(struct pci_dev *dev, int bar) } } addr &= PCI_BASE_ADDRESS_MEM_MASK; +#endif break; case TYPE_IOBAR: msg_pdbg("I/O\n");