From patchwork Thu Jan 18 21:00:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 125033 Delivered-To: patch@linaro.org Received: by 10.46.64.27 with SMTP id n27csp294701lja; Thu, 18 Jan 2018 13:01:20 -0800 (PST) X-Google-Smtp-Source: ACJfBotmpa93YDjKcIGUTaLF1OA2yG8fJ455ixmgfAG00iFXZOu/XIl+gn/8K7FrhkvujzsuRYlR X-Received: by 10.101.80.130 with SMTP id r2mr22759527pgp.107.1516309280477; Thu, 18 Jan 2018 13:01:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516309280; cv=none; d=google.com; s=arc-20160816; b=nUC18svVcRchgVHWRnLYwlegyPZSfPsemUYi+RgK4+GlswBikAS781wS72BioDOCq2 ohSCj8XxmpYpe0eMZsVacJuhZjIL3a6YNPbZiHdX2nsUEwTlSHgpcsAJbrfLVWNpWdCd t8UEr5kAe73oNVYQsC3KLzVwXvl0/UROGyZeQkBW442q6S/3KaDZMCDk6JLz0gzcZKpy ysFGeG+YBS7zogONmUiU73N2q3p1L/2jMJanPvyFrR6zNM0dPKiZ7IhrENmKPAj91CKq tXG0cCV9YXCZ0G0Yg85FDCS3NZFPJI3PIpKYBqrVG8R+33ryNPOxxU1HXx+n89PCnxgG zjXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=qoJWLICsRaAM7JpIpFFZZTGR77ULdnrWFPvXyhmCZpg=; b=CAB8g+SD0sqnZEMh0f1rZ2iU8vZFPuYZ9WSDDOMYfOYoGCbL0SbXb4pcUTgGLnOADl bwEE/uE5RMUsmjqg2FWTY6dBCL94hv0v506MslQdnkDeNBSJOpYfd/SFYV3an8TvdsUG f6OjhwvG0n8f4BjhYktc8lCru54zgv21dqK3dAntXh91KsFOtJ16PYuQeKyR7GE4WwGp HkgNFuMnDkDmUIoMfOaKYlflPwvgTOdCy89mHpoCWFamz424w4LvJ6V9ddGrhbiBsxxz oRyj2UrJhz74f+JvF61OAMA3/nByLGK4/tKzeMgB7lv1P0PjMubmigIGOgIFwmS5o037 ujLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=erYcNP2O; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c16si4933770pgu.706.2018.01.18.13.01.20; Thu, 18 Jan 2018 13:01:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=erYcNP2O; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754860AbeARVBS (ORCPT + 10 others); Thu, 18 Jan 2018 16:01:18 -0500 Received: from mail-by2nam01on0100.outbound.protection.outlook.com ([104.47.34.100]:31312 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753956AbeARVBP (ORCPT ); Thu, 18 Jan 2018 16:01:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=qoJWLICsRaAM7JpIpFFZZTGR77ULdnrWFPvXyhmCZpg=; b=erYcNP2OMu7cW615nlX9XFU0ayyS/9acK8V61D1JlWGF31LpCWtgdoCnsXX0Iitt6jT+w4ewWjdbVPCsSzcLWFaSGVdni6gtaJhvvg++k4yu1OAQDw9P0W+f9EqSPvh4m4HRP7cHTdf3MBv7tcA0d/J7CGl7a2uv4+xtYwiqc7c= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0805.namprd21.prod.outlook.com (10.167.105.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.428.7; Thu, 18 Jan 2018 21:01:13 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7%2]) with mapi id 15.20.0428.008; Thu, 18 Jan 2018 21:01:13 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Sumit Semwal , Bjorn Helgaas , Sasha Levin Subject: [added to the 4.1 stable tree] PCI: Add comments about ROM BAR updating Thread-Topic: [added to the 4.1 stable tree] PCI: Add comments about ROM BAR updating Thread-Index: AQHTkJ9P8frMQ6WxoUuLdfUExQa9ug== Date: Thu, 18 Jan 2018 21:00:02 +0000 Message-ID: <20180118205908.3220-75-alexander.levin@microsoft.com> References: <20180118205908.3220-1-alexander.levin@microsoft.com> In-Reply-To: <20180118205908.3220-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [167.220.98.9] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM5PR2101MB0805; 7:AQqWOYDVKFxqZA26AwHOxYVrG5+X1Gwuif/6nTQRm/URQqOL3Dc5r1pCl9hsS7I4PqveAu744TT4Te8Puj5mkqKRtwDcNzEAw8z2WxvqkWqGN4kRHgbrbWrI8b60vwdUBC6K2Mntzkf/xbr+77/9c/W7RfbrmrcNBVlnHqqqV12Z4v35uBbT+Itusuf2yfLI91x50S9rcu872x/fEaiy7GGL+zxhwz39HGmwF78uM/qHpynFNwu3Z68g/oiDsQae x-ms-office365-filtering-correlation-id: e4fe3d84-f118-4f45-73af-08d55eb69bc9 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534125)(4602075)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7193020); SRVR:DM5PR2101MB0805; x-ms-traffictypediagnostic: DM5PR2101MB0805: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(211936372134217)(153496737603132)(104084551191319); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(61425038)(6040495)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231046)(2400067)(944501161)(3002001)(6055026)(61426038)(61427038)(6041282)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011); SRVR:DM5PR2101MB0805; BCL:0; PCL:0; RULEID:(100000803126)(100110400120); SRVR:DM5PR2101MB0805; x-forefront-prvs: 05568D1FF7 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(39380400002)(366004)(376002)(346002)(396003)(189003)(199004)(2906002)(2900100001)(6512007)(86362001)(305945005)(97736004)(68736007)(10090500001)(2501003)(6666003)(7736002)(105586002)(5250100002)(2950100002)(5660300001)(6116002)(36756003)(6486002)(26005)(86612001)(54906003)(4326008)(3280700002)(3846002)(6346003)(6436002)(3660700001)(10290500003)(478600001)(107886003)(76176011)(66066001)(1076002)(81156014)(99286004)(81166006)(106356001)(6306002)(53936002)(102836004)(22452003)(110136005)(59450400001)(14454004)(316002)(575784001)(72206003)(25786009)(966005)(6506007)(8676002)(8936002)(22906009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB0805; H:DM5PR2101MB1032.namprd21.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: sUP4iqujaXHpNurPcz/lv06v0Ze9+uIfiXJo5MWjmEhxqclnb0jFbUivt6fxvEXxpztkd16Fsa4c4uLAWoMTDg== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4fe3d84-f118-4f45-73af-08d55eb69bc9 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jan 2018 21:00:03.0097 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0805 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sumit Semwal This patch has been added to the stable tree. If you have any objections, please let us know. -- 2.11.0 =============== [ Upstream commit 0b457dde3cf8b7c76a60f8e960f21bbd4abdc416 ] 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 Signed-off-by: Sasha Levin --- 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 eb0ad530dc43..3eea7fc5e1a2 100644 --- a/drivers/pci/rom.c +++ b/drivers/pci/rom.c @@ -31,6 +31,11 @@ int pci_enable_rom(struct pci_dev *pdev) if (!res->flags) return -1; + /* + * 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 3ec798ead2c9..b1b88bfaddc0 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -63,6 +63,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;