From patchwork Wed Feb 17 23:45:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 8343871 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 30DDF9F372 for ; Wed, 17 Feb 2016 23:45:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AEC8B203FB for ; Wed, 17 Feb 2016 23:45:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F05C8203F7 for ; Wed, 17 Feb 2016 23:45:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423543AbcBQXpl (ORCPT ); Wed, 17 Feb 2016 18:45:41 -0500 Received: from mga02.intel.com ([134.134.136.20]:21584 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423083AbcBQXpl (ORCPT ); Wed, 17 Feb 2016 18:45:41 -0500 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP; 17 Feb 2016 15:45:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,463,1449561600"; d="scan'208";a="49795032" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.35]) by fmsmga004.fm.intel.com with ESMTP; 17 Feb 2016 15:45:40 -0800 Received: by tassilo.localdomain (Postfix, from userid 1000) id BC3A03029C7; Wed, 17 Feb 2016 15:45:39 -0800 (PST) From: Andi Kleen To: bhelgaas@google.com Cc: linux-kernel@vger.kernel.org, x86@kernel.org, linux-pci@vger.kernel.org, Andi Kleen Subject: [PATCH] x86, pci: Add quirk for unsizeable Broadwell EP bar Date: Wed, 17 Feb 2016 15:45:28 -0800 Message-Id: <1455752728-29958-1-git-send-email-andi@firstfloor.org> X-Mailer: git-send-email 2.5.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andi Kleen The Home Agent and PCU PCI devices in Broadwell-EP have a BAR that returns a non zero value when read, but is still not sizeable (because it doesn't exist). This causes several [Firmware error] messages at boot. It does not cause any functional problems, as the devices really have no BARs. Add a PCI quirk to shut off the messages. v2: Handle all BARs, not just BAR0 (Chaohong Guo) v3: Switch to patching bus ops Signed-off-by: Andi Kleen --- arch/x86/pci/fixup.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c index e585655..4fcb5d5 100644 --- a/arch/x86/pci/fixup.c +++ b/arch/x86/pci/fixup.c @@ -540,3 +540,48 @@ static void twinhead_reserve_killing_zone(struct pci_dev *dev) } } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x27B9, twinhead_reserve_killing_zone); + +/* + * Intel Broadwell EP. Prevent reading/updating BARs on Home Agent and PCU devices + * which are not real BARs, but still return non-null. + * This prevents a harmless warning message at boot. + */ + +static inline bool bdwep_bad_bars(unsigned devfn, int where) +{ + return ((PCI_SLOT(devfn) == 0x12 && PCI_FUNC(devfn) == 0) || + (PCI_SLOT(devfn) == 0x1e && PCI_FUNC(devfn) == 3)) && + where >= 0x10 && where <= 0x24; +} + +static int quirk_bdwep_bar_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value) +{ + if (bdwep_bad_bars(devfn, where)) { + *value = 0; + return 0; + } + + return raw_pci_read(pci_domain_nr(bus), bus->number, + devfn, where, size, value); +} + +static int quirk_bdwep_bar_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value) +{ + if (bdwep_bad_bars(devfn, where)) + return 0; + + return raw_pci_write(pci_domain_nr(bus), bus->number, + devfn, where, size, value); +} + +static struct pci_ops quirk_bdwep_bar_ops = { + .read = quirk_bdwep_bar_read, + .write = quirk_bdwep_bar_write, +}; + +static void pci_bdwep_bar(struct pci_dev *dev) +{ + pci_bus_set_ops(dev->bus, &quirk_bdwep_bar_ops); +} +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6fa0, pci_bdwep_bar); +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6fc0, pci_bdwep_bar);