Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2153374ybm; Thu, 23 May 2019 12:14:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCdz7rFoK7ek2XnWGtAXqwvplz3c9dHGYAoRKy3/KS0tpE5ikuQ9XNq8Z6ZpnlLPgSgDIF X-Received: by 2002:a17:902:3143:: with SMTP id w61mr92814291plb.292.1558638859131; Thu, 23 May 2019 12:14:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558638859; cv=none; d=google.com; s=arc-20160816; b=WinUo4NYrJvuNhFoUT+BxYhdBJaT/uPdr4KeywLrCQYt287Wut6nFlYz2ZnQ4sgr8p nYxezXyBpPaUJage7xDRhq1Hljkl3+PokI+kuw+jXT0cWsDAuP0N5iGA6QURQon9e4Y1 dbPVIZT4aN8ylrxLxMxr552Wvj6jaNssOY7zD58/8vKQHw8gEHwslFgkYJhgbpt6AO2A qK84BSqzYvGp+oCFfjCxeNt6CdVae1dBquamIVtKjfA0y5HRdfpCSscqlaWQzy2Gt/PJ O1CyKBL/SMRHQg8mFTCFobosUAhbZNskwkk2F/5pdUY1FqlVHBE5y9ArmghH4d9XLt8J TlQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hD3M5r/QUZposn6odhc5ykjnqtETJZMKDwi9rYCpY6U=; b=BYn+3ftJg6Mzxf4/cJIvbstz3SEVTqy4Lz+hyjoH5mM/fsqGD70ywxg5gtUCwepeuD 3/FnTAnnYMZSWf74EwA5WVve2XxwTPGbA0r3x9eXsHaZuYLsQheK1UzLkC/hzhDUADy0 hF2jPdtUmmMAkO9OCQtWIUGufm9Uzurp4OYEHcwqGIZLmhFvSuPaAqSE7CFbc0vQCHjW +qH5pGF/VziDOJ9BnhyFVar2nhHhGTCmWPQVrSbFhmqq3LGIWj23fkWW7PWP67fNST8l sRbYR7SHwSsIV3wZ5HRgDC9icEiEBc2ky7ggG2v+bKIqFryQF8RvWEEwTtK8klC8CB1h /3Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=H8DArxlt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f8si303616pfh.200.2019.05.23.12.14.04; Thu, 23 May 2019 12:14:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=H8DArxlt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731746AbfEWTMh (ORCPT + 99 others); Thu, 23 May 2019 15:12:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:46336 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731662AbfEWTMe (ORCPT ); Thu, 23 May 2019 15:12:34 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4902620863; Thu, 23 May 2019 19:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558638753; bh=uXz03w78aA3rYqMCK+FEZpxXyWqYSb745R7NBDYLeu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H8DArxltmN+CGyKeApgCnM0fupShfccQt4DfmtFNilq2ts4FnqlqpWBWpbTQEuMNr /QxZBJotRYjrWMp3hYzlUQwTnyb1cERNb8/oqINWVXaHTcXpYt6BbHftuPnnmMLwOZ CrHUskCcgEbNskFK5MWgb3MOCYhxdX7qdAviqWdk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Stefan=20M=C3=A4tje?= , Bjorn Helgaas , Andy Shevchenko Subject: [PATCH 4.14 52/77] PCI: Work around Pericom PCIe-to-PCI bridge Retrain Link erratum Date: Thu, 23 May 2019 21:06:10 +0200 Message-Id: <20190523181727.245765389@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523181719.982121681@linuxfoundation.org> References: <20190523181719.982121681@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Mätje commit 4ec73791a64bab25cabf16a6067ee478692e506d upstream. Due to an erratum in some Pericom PCIe-to-PCI bridges in reverse mode (conventional PCI on primary side, PCIe on downstream side), the Retrain Link bit needs to be cleared manually to allow the link training to complete successfully. If it is not cleared manually, the link training is continuously restarted and no devices below the PCI-to-PCIe bridge can be accessed. That means drivers for devices below the bridge will be loaded but won't work and may even crash because the driver is only reading 0xffff. See the Pericom Errata Sheet PI7C9X111SLB_errata_rev1.2_102711.pdf for details. Devices known as affected so far are: PI7C9X110, PI7C9X111SL, PI7C9X130. Add a new flag, clear_retrain_link, in struct pci_dev. Quirks for affected devices set this bit. Note that pcie_retrain_link() lives in aspm.c because that's currently the only place we use it, but this erratum is not specific to ASPM, and we may retrain links for other reasons in the future. Signed-off-by: Stefan Mätje [bhelgaas: apply regardless of CONFIG_PCIEASPM] Signed-off-by: Bjorn Helgaas Reviewed-by: Andy Shevchenko CC: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/pci/pcie/aspm.c | 9 +++++++++ drivers/pci/quirks.c | 17 +++++++++++++++++ include/linux/pci.h | 2 ++ 3 files changed, 28 insertions(+) --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -220,6 +220,15 @@ static bool pcie_retrain_link(struct pci pcie_capability_read_word(parent, PCI_EXP_LNKCTL, ®16); reg16 |= PCI_EXP_LNKCTL_RL; pcie_capability_write_word(parent, PCI_EXP_LNKCTL, reg16); + if (parent->clear_retrain_link) { + /* + * Due to an erratum in some devices the Retrain Link bit + * needs to be cleared again manually to allow the link + * training to succeed. + */ + reg16 &= ~PCI_EXP_LNKCTL_RL; + pcie_capability_write_word(parent, PCI_EXP_LNKCTL, reg16); + } /* Wait for link training end. Break out after waiting for timeout */ start_jiffies = jiffies; --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -2085,6 +2085,23 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_IN DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10f4, quirk_disable_aspm_l0s); DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1508, quirk_disable_aspm_l0s); +/* + * Some Pericom PCIe-to-PCI bridges in reverse mode need the PCIe Retrain + * Link bit cleared after starting the link retrain process to allow this + * process to finish. + * + * Affected devices: PI7C9X110, PI7C9X111SL, PI7C9X130. See also the + * Pericom Errata Sheet PI7C9X111SLB_errata_rev1.2_102711.pdf. + */ +static void quirk_enable_clear_retrain_link(struct pci_dev *dev) +{ + dev->clear_retrain_link = 1; + pci_info(dev, "Enable PCIe Retrain Link quirk\n"); +} +DECLARE_PCI_FIXUP_HEADER(0x12d8, 0xe110, quirk_enable_clear_retrain_link); +DECLARE_PCI_FIXUP_HEADER(0x12d8, 0xe111, quirk_enable_clear_retrain_link); +DECLARE_PCI_FIXUP_HEADER(0x12d8, 0xe130, quirk_enable_clear_retrain_link); + static void fixup_rev1_53c810(struct pci_dev *dev) { u32 class = dev->class; --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -350,6 +350,8 @@ struct pci_dev { unsigned int hotplug_user_indicators:1; /* SlotCtl indicators controlled exclusively by user sysfs */ + unsigned int clear_retrain_link:1; /* Need to clear Retrain Link + bit manually */ unsigned int d3_delay; /* D3->D0 transition time in ms */ unsigned int d3cold_delay; /* D3cold->D0 transition time in ms */