From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:51589 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752306AbcK2FES (ORCPT ); Tue, 29 Nov 2016 00:04:18 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uAT4wVwM072088 for ; Tue, 29 Nov 2016 00:03:54 -0500 Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140]) by mx0b-001b2d01.pphosted.com with ESMTP id 2712rw2m78-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 29 Nov 2016 00:03:54 -0500 Received: from localhost by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 29 Nov 2016 15:03:51 +1000 Received: from d23relay09.au.ibm.com (d23relay09.au.ibm.com [9.185.63.181]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 6AC962BB0045 for ; Tue, 29 Nov 2016 16:03:49 +1100 (EST) Received: from d23av06.au.ibm.com (d23av06.au.ibm.com [9.190.235.151]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uAT53nwm5177656 for ; Tue, 29 Nov 2016 16:03:49 +1100 Received: from d23av06.au.ibm.com (localhost [127.0.0.1]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id uAT53m1o026945 for ; Tue, 29 Nov 2016 16:03:49 +1100 Date: Tue, 29 Nov 2016 16:05:10 +1100 From: Gavin Shan To: Bjorn Helgaas Cc: Gavin Shan , clsoto@us.ibm.com, benh@kernel.crashing.org, linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au Subject: Re: [PATCH v4 7/7] PCI: Add comments about ROM BAR updating Reply-To: Gavin Shan References: <20161129035218.21453.93986.stgit@bhelgaas-glaptop.roam.corp.google.com> <20161129041648.21453.94596.stgit@bhelgaas-glaptop.roam.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <20161129041648.21453.94596.stgit@bhelgaas-glaptop.roam.corp.google.com> Message-Id: <20161129050510.GA23688@gwshan> Sender: linux-pci-owner@vger.kernel.org List-ID: On Mon, Nov 28, 2016 at 10:16:48PM -0600, Bjorn Helgaas wrote: >pci_update_resource() updates a hardware BAR so its address matches the >kernel's struct resource UNLESS it's a disabled ROM BAR. We only update >those when we enable the ROM. > >It's not obvious from the code why ROM BARs should be handled specially. >Apparently there are Matrox devices with defective ROM BARs that read as >zero when disabled. That means that if pci_enable_rom() reads the disabled >BAR, sets PCI_ROM_ADDRESS_ENABLE (without re-inserting the address), and >writes it back, it would enable the ROM at address zero. > >Add comments and references to explain why we can't make the code look more >rational. > >The code changes are from 755528c860b0 ("Ignore disabled ROM resources at >setup") and 8085ce084c0f ("[PATCH] Fix PCI ROM mapping"). > >Link: https://lkml.org/lkml/2005/8/30/138 >Signed-off-by: Bjorn Helgaas Reviewed-by: Gavin Shan >--- > drivers/pci/rom.c | 5 +++++ > drivers/pci/setup-res.c | 6 ++++++ > 2 files changed, 11 insertions(+) > >diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c >index 06663d3..b6edb18 100644 >--- a/drivers/pci/rom.c >+++ b/drivers/pci/rom.c >@@ -35,6 +35,11 @@ int pci_enable_rom(struct pci_dev *pdev) > if (res->flags & IORESOURCE_ROM_SHADOW) > return 0; > >+ /* >+ * Ideally pci_update_resource() would update the ROM BAR address, >+ * and we would only set the enable bit here. But apparently some >+ * devices have buggy ROM BARs that read as zero when disabled. >+ */ > pcibios_resource_to_bus(pdev->bus, ®ion, res); > pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_addr); > rom_addr &= ~PCI_ROM_ADDRESS_MASK; >diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c >index 09bdff7..57d7041 100644 >--- a/drivers/pci/setup-res.c >+++ b/drivers/pci/setup-res.c >@@ -67,6 +67,12 @@ static void pci_std_update_resource(struct pci_dev *dev, int resno) > if (resno < PCI_ROM_RESOURCE) { > reg = PCI_BASE_ADDRESS_0 + 4 * resno; > } else if (resno == PCI_ROM_RESOURCE) { >+ >+ /* >+ * Apparently some Matrox devices have ROM BARs that read >+ * as zero when disabled, so don't update ROM BARs unless >+ * they're enabled. See https://lkml.org/lkml/2005/8/30/138. >+ */ > if (!(res->flags & IORESOURCE_ROM_ENABLE)) > return; > > >-- >To unsubscribe from this list: send the line "unsubscribe linux-pci" in >the body of a message to majordomo@vger.kernel.org >More majordomo info at http://vger.kernel.org/majordomo-info.html >