From patchwork Thu Jan 4 16:23:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Koen Vandeputte X-Patchwork-Id: 855697 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="L3X3nC9h"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ncentric.com header.i=@ncentric.com header.b="nShAFm5e"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zCCzp5nR1z9sPk for ; Fri, 5 Jan 2018 03:33:58 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Message-Id: Date:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ilLsSo8/bZIVgvQFMGFuLdGEHlOqlaahV8csejCdg6I=; b=L3X3nC9h9UBYjp NTkjzKTIto3gummmE2+kFhDnTq1YAwZ/s45cv5z1RJmbqjU4lDlVyXCcaaRUGmdQCeINlJJjrCgF4 i/nCKZTGTmOUFd2TMB3400BEmqt6mEYhxMMfn8lGxAeBnpSljkQlwEaLlsG/8BK5O1X5ktsXWsIuH dnpr+El3sxqN0xDTF1lamd81tlPo/Adru9/ym9jHpi+P+U117LfY8C8H3Ru3Sw86dAuGGntVSGXRs 8Dr7DjOX2hWKQl1gnWlxgq8UxCB9/eDLgxL9LMoSHe6vg3ccR8ZvzB7b1UrVOL2SZXHwE+lFba2s2 cYxs+LMRFi6bq/y7DGhw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eX8Sd-00026Z-If; Thu, 04 Jan 2018 16:33:43 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eX8SV-0001s5-E2 for lede-dev@lists.infradead.org; Thu, 04 Jan 2018 16:33:40 +0000 Received: by mail-wm0-x244.google.com with SMTP id f140so4410107wmd.2 for ; Thu, 04 Jan 2018 08:33:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ncentric.com; s=google; h=from:to:cc:subject:date:message-id; bh=6e5kUNCnoGMWHJSwP4D+63hZV5MOe6tNRBgoHjRu+LU=; b=nShAFm5etuQMBHCHdz3yo/iVUy63uv+3m6Pq83MgxANlBM0tHZhINwq+/UQNjf0w2Y Uv43IemwtZ5JcfWe5aeXVaVG1CeKfTEEFNsaLY7WYi5NNDUSjIEwRhvZq3KlcNjdEJvp 25bVFM6rhZ6c0PIwS9hTWQwd5jBhdsnTvtvuQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6e5kUNCnoGMWHJSwP4D+63hZV5MOe6tNRBgoHjRu+LU=; b=NfqRcW4kPkbAhQsNjjg+CINw+Rttm5jIyUqWdhl8p6lk5DoTBUhh1R/3EPas+yvfZs XiVuOCaN7TA2BVoziCFFHXAWFmj4QwjNlowWyVGDYiMlazBbM59ymVEtlqPWFEgHuLM+ 8y+NvZjqO1tgBPH7SEKUXLGQym01sm1o2OiqYNPMftIR6EZUNMYV3jlHCIMdxQq1Yo8u U36h2KNR0R2j+Jr6uFG+BBBOSoNau7SwgioLomh6Xmtnw0Avy/FL2xVrcO6MyrdD+DwJ YG20W2z12WZTgoXuiLYyIzzj8te8s76w435susZC9DtUW1N8su7fXfgA9w7+99WG4xHd UDsQ== X-Gm-Message-State: AKGB3mIu2d9ikfYYozIA2hf3d8burd8XEoYoD0jWbSSdqfB94hXajz0U a5NTu3n8NX+BWVsuRA1Ea8zCMk0t4nY= X-Google-Smtp-Source: ACJfBoucJg6hgPs9fnsza8cLEaK8TWpSF3I7HMmmSX2B8UwiRv6+Ms8Qkah6Vls7EqOZ7vE8Akc4oQ== X-Received: by 10.80.177.22 with SMTP id k22mr152091edd.307.1515083602661; Thu, 04 Jan 2018 08:33:22 -0800 (PST) Received: from localhost.localdomain (d515300d8.static.telenet.be. [81.83.0.216]) by smtp.googlemail.com with ESMTPSA id w51sm2357272edd.84.2018.01.04.08.33.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jan 2018 08:33:21 -0800 (PST) From: Koen Vandeputte To: lede-dev@lists.infradead.org Date: Thu, 4 Jan 2018 17:23:17 +0100 Message-Id: <1515082997-31086-1-git-send-email-koen.vandeputte@ncentric.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180104_083335_612753_C747DD4E X-CRM114-Status: GOOD ( 15.20 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c09:0:0:0:244 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Subject: [LEDE-DEV] [PATCH v2] imx6: fix pcie scanning on boot X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tharvey@gateworks.com, Koen Vandeputte , nbd@nbd.name MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org By default, when the imx6 PCIe RC boots up, the subordinate is set equally to the secondary bus (1), and does not alter afterwards. This means that theoretically, the highest bus reachable downstream is bus 1. Before upstream commit a20c7f36bd3d ("PCI: Do not allocate more buses than available in parent"), the driver ignored the subord value and just allowed up to 0xff on each device downstream. This caused a lot of errors to be printed, as this is not logical according to spec. (but it worked ..) After this commit, the driver stopped scanning deeper when the last allocated busnr equals the subordinate of it's master, causing devices to be undiscovered (especially behind bridges), uncovering the impact of this bug. Before: 00:00.0 PCI bridge: Synopsys, Inc. Device abcd (rev 01) (prog-if 00 ... Bus: primary=00, secondary=01, subordinate=01, sec-latency=0 00:00.0 0604: 16c3:abcd (rev 01) 01:00.0 0604: 10b5:8604 (rev ba) ... stops after bus 1 ... After: 00:00.0 PCI bridge: Synopsys, Inc. Device abcd (rev 01) (prog-if 00 ... Bus: primary=00, secondary=01, subordinate=ff, sec-latency=0 00:00.0 0604: 16c3:abcd (rev 01) 01:00.0 0604: 10b5:8604 (rev ba) 02:01.0 0604: 10b5:8604 (rev ba) 02:04.0 0604: 10b5:8604 (rev ba) 02:05.0 0604: 10b5:8604 (rev ba) 03:00.0 0280: 168c:0033 (rev 01) 05:00.0 0280: 168c:0033 (rev 01) This upstream commit was introduced in kernel 4.9.71 Signed-off-by: Koen Vandeputte --- V2: Proper fix for the real rootcause kernel 4.4 is not affected .../patches-4.9/230-fix-pcie-enumeration.patch | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 target/linux/imx6/patches-4.9/230-fix-pcie-enumeration.patch diff --git a/target/linux/imx6/patches-4.9/230-fix-pcie-enumeration.patch b/target/linux/imx6/patches-4.9/230-fix-pcie-enumeration.patch new file mode 100644 index 000000000000..18f22347172b --- /dev/null +++ b/target/linux/imx6/patches-4.9/230-fix-pcie-enumeration.patch @@ -0,0 +1,73 @@ +By default, when the imx6 PCIe RC boots up, the subordinate is set +equally to the secondary bus (1), and does not alter afterwards. + +This means that theoretically, the highest bus reachable downstream is +bus 1. + +Before commit a20c7f36bd3d ("PCI: Do not allocate more buses than +available in parent"), the driver ignored the subord value and just +allowed up to 0xff on each device downstream. + +This caused a lot of errors to be printed, as this is not logical +according to spec. (but it worked ..) + +After this commit, the driver stopped scanning deeper when the last +allocated busnr equals the subordinate of it's master, causing devices +to be undiscovered (especially behind bridges), uncovering the impact of +this bug. + +Before: + +00:00.0 PCI bridge: Synopsys, Inc. Device abcd (rev 01) (prog-if 00 ... + Bus: primary=00, secondary=01, subordinate=01, sec-latency=0 + +00:00.0 0604: 16c3:abcd (rev 01) +01:00.0 0604: 10b5:8604 (rev ba) +... stops after bus 1 ... + +After: + +00:00.0 PCI bridge: Synopsys, Inc. Device abcd (rev 01) (prog-if 00 +... + Bus: primary=00, secondary=01, subordinate=ff, sec-latency=0 + +00:00.0 0604: 16c3:abcd (rev 01) +01:00.0 0604: 10b5:8604 (rev ba) +02:01.0 0604: 10b5:8604 (rev ba) +02:04.0 0604: 10b5:8604 (rev ba) +02:05.0 0604: 10b5:8604 (rev ba) +03:00.0 0280: 168c:0033 (rev 01) +05:00.0 0280: 168c:0033 (rev 01) + +Signed-off-by: Koen Vandeputte + +--- a/drivers/pci/host/pci-imx6.c ++++ b/drivers/pci/host/pci-imx6.c +@@ -64,6 +64,9 @@ struct imx6_pcie { + + #define PCIE_RC_LCSR 0x80 + ++#define PCIE_RC_BNR 0x18 ++#define PCIE_RC_BNR_MAX_SUBORDINATE (0xff << 16) ++ + /* PCIe Port Logic registers (memory-mapped) */ + #define PL_OFFSET 0x700 + #define PCIE_PL_PFLR (PL_OFFSET + 0x08) +@@ -488,6 +491,17 @@ static int imx6_pcie_establish_link(stru + int ret; + + /* ++ * By default, the subordinate is set equally to the secondary ++ * bus (0x01) when the RC boots. ++ * This means that theoretically, only bus 1 is reachable from the RC. ++ * Force the PCIe RC subordinate to 0xff, otherwise no downstream ++ * devices will be detected behind bus 1. ++ */ ++ tmp = dw_pcie_readl_rc(pp, PCIE_RC_BNR); ++ tmp |= PCIE_RC_BNR_MAX_SUBORDINATE; ++ dw_pcie_writel_rc(pp, PCIE_RC_BNR, tmp); ++ ++ /* + * Force Gen1 operation when starting the link. In case the link is + * started in Gen2 mode, there is a possibility the devices on the + * bus will not be detected at all. This happens with PCIe switches.