From patchwork Fri Jul 27 16:52:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Garrett X-Patchwork-Id: 1250191 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 2A31EE009B for ; Fri, 27 Jul 2012 16:53:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752570Ab2G0Qwt (ORCPT ); Fri, 27 Jul 2012 12:52:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5786 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752449Ab2G0Qwr (ORCPT ); Fri, 27 Jul 2012 12:52:47 -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 (8.14.4/8.14.4) with ESMTP id q6RGqiI1023082 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 27 Jul 2012 12:52:44 -0400 Received: from cavan.codon.org.uk (ovpn-113-108.phx2.redhat.com [10.3.113.108]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q6RGqh19024614 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Fri, 27 Jul 2012 12:52:44 -0400 Received: from 209-6-41-104.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.41.104] helo=localhost.localdomain) by cavan.codon.org.uk with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1SunmK-0005Kw-2F; Fri, 27 Jul 2012 17:52:40 +0100 From: Matthew Garrett To: matt.fleming@intel.com Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-pci@vger.kernel.org, bhelgaas@google.com, Matthew Garrett Subject: [PATCH V2 3/4] PCI: Add support for non-BAR ROMs Date: Fri, 27 Jul 2012 12:52:13 -0400 Message-Id: <1343407934-459-3-git-send-email-mjg@redhat.com> In-Reply-To: <1343407934-459-1-git-send-email-mjg@redhat.com> References: <1343407934-459-1-git-send-email-mjg@redhat.com> X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 209.6.41.104 X-SA-Exim-Mail-From: mjg@redhat.com X-SA-Exim-Scanned: No (on cavan.codon.org.uk); SAEximRunCond expanded to false X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Platforms may provide their own mechanisms for obtaining ROMs. Add support for using data provided by the platform in that case. Signed-off-by: Matthew Garrett Tested-by: Seth Forshee --- drivers/pci/rom.c | 9 ++++++++- include/linux/pci.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c index 48ebdb2..f913ce3 100644 --- a/drivers/pci/rom.c +++ b/drivers/pci/rom.c @@ -126,6 +126,12 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size) /* primary video rom always starts here */ start = (loff_t)0xC0000; *size = 0x20000; /* cover C000:0 through E000:0 */ + /* + * Some devices may provide ROMs via a source other than the BAR + */ + } else if (pdev->rom && pdev->romlen) { + *size = pdev->romlen; + return (void __iomem *)phys_to_virt(pdev->rom); } else { if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_BIOS_COPY)) { @@ -219,7 +225,8 @@ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom) if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_BIOS_COPY)) return; - iounmap(rom); + if (!pdev->rom || !pdev->romlen) + iounmap(rom); /* Disable again before continuing, leave enabled if pci=rom */ if (!(res->flags & (IORESOURCE_ROM_ENABLE | IORESOURCE_ROM_SHADOW))) diff --git a/include/linux/pci.h b/include/linux/pci.h index 6a2625c..2668bb9 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -355,6 +355,8 @@ struct pci_dev { }; struct pci_ats *ats; /* Address Translation Service */ #endif + void *rom; /* Physical pointer to ROM if it's not from the BAR */ + size_t romlen; /* Length of ROM if it's not from the BAR */ }; static inline struct pci_dev *pci_physfn(struct pci_dev *dev)