From patchwork Thu Oct 1 06:00:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinath Mannam X-Patchwork-Id: 11810927 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D23AA6CB for ; Thu, 1 Oct 2020 06:01:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 989FE221E7 for ; Thu, 1 Oct 2020 06:01:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="J9cegQ27" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725960AbgJAGBO (ORCPT ); Thu, 1 Oct 2020 02:01:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725959AbgJAGBO (ORCPT ); Thu, 1 Oct 2020 02:01:14 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EEF7C0613D0 for ; Wed, 30 Sep 2020 23:01:14 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id u24so3198672pgi.1 for ; Wed, 30 Sep 2020 23:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n/EKXhfktXa8OD3A0+KlBuM2uKvfFs6/Sk7F67lxoIM=; b=J9cegQ27GhtaMCmVvEukmBJixsp27ubstP/U5uFHPQA0qAXwdYIt+Pmk9qG1fc8OtR mZL4wgEsbuCjkxaUBxWfCv6l9cbBMyjSAMyH211V7HkRclSmK5xD64mv3JI8k0fFuRj8 mV9+s0u91HfRt+b27GfXkE+qyInG1y8Z5XmiA= 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:in-reply-to :references; bh=n/EKXhfktXa8OD3A0+KlBuM2uKvfFs6/Sk7F67lxoIM=; b=Q5ylRgYo4ShBkLIKI7IKJmtRU8D9IA704OWtBTNQ7zcxObQazW0hNQIdpObb+wowPx tN3XcFrxDUhgFa7kM0kOYAuIcFuivadc+yhBc5TVCPvHT7wG7ncnEer9dk0C7DHY1g/4 zYT7qbunTa84Ny3SDPmL46xRvCCDPpQwKNvHZ7kr6M5rGNp9VJutcmzLDAeEDQLKtakY NY2frwTJW1SRNO/dcGGPHij+seO7tCT3Pe5Bmp+ldopTiZWFuDrppOvtEKumJ6jB9zuF PSE5UyKMvdeNONkxgVvz1JSkVWv48Xrvot1Xwbn+1SauovRKYsUv78kLR2Lh9pGBiYdR DlmQ== X-Gm-Message-State: AOAM530nFxUS2XLpQosn7FKM4XGwyGpTtTd9tpjY+CHS3nntDNLDWE1f HEX+YicYbmLCKOeGH9IzaPx67A== X-Google-Smtp-Source: ABdhPJwMOxEq67OVw9EpZDWFCHL+80TRYJXCJ4LW3yfGXNtJPqy9Altdc4qlVorZ1gdeJ4G7Ati9fg== X-Received: by 2002:a63:8c6:: with SMTP id 189mr4976473pgi.207.1601532073802; Wed, 30 Sep 2020 23:01:13 -0700 (PDT) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id l2sm4032112pjy.3.2020.09.30.23.01.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 23:01:13 -0700 (PDT) From: Srinath Mannam To: Lorenzo Pieralisi , Bjorn Helgaas , Ray Jui Cc: bcm-kernel-feedback-list@broadcom.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Bharat Gooty Subject: [PATCH v3 1/3] PCI: iproc: Fix out-of-bound array accesses Date: Thu, 1 Oct 2020 11:30:52 +0530 Message-Id: <20201001060054.6616-2-srinath.mannam@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201001060054.6616-1-srinath.mannam@broadcom.com> References: <20201001060054.6616-1-srinath.mannam@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Bharat Gooty Declare the full size array for all revisions of PAX register sets to avoid potentially out of bound access of the register array when they are being initialized in iproc_pcie_rev_init(). Fixes: 06324ede76cdf ("PCI: iproc: Improve core register population") Signed-off-by: Bharat Gooty --- drivers/pci/controller/pcie-iproc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c index 905e93808243..d901b9d392b8 100644 --- a/drivers/pci/controller/pcie-iproc.c +++ b/drivers/pci/controller/pcie-iproc.c @@ -307,7 +307,7 @@ enum iproc_pcie_reg { }; /* iProc PCIe PAXB BCMA registers */ -static const u16 iproc_pcie_reg_paxb_bcma[] = { +static const u16 iproc_pcie_reg_paxb_bcma[IPROC_PCIE_MAX_NUM_REG] = { [IPROC_PCIE_CLK_CTRL] = 0x000, [IPROC_PCIE_CFG_IND_ADDR] = 0x120, [IPROC_PCIE_CFG_IND_DATA] = 0x124, @@ -318,7 +318,7 @@ static const u16 iproc_pcie_reg_paxb_bcma[] = { }; /* iProc PCIe PAXB registers */ -static const u16 iproc_pcie_reg_paxb[] = { +static const u16 iproc_pcie_reg_paxb[IPROC_PCIE_MAX_NUM_REG] = { [IPROC_PCIE_CLK_CTRL] = 0x000, [IPROC_PCIE_CFG_IND_ADDR] = 0x120, [IPROC_PCIE_CFG_IND_DATA] = 0x124, @@ -334,7 +334,7 @@ static const u16 iproc_pcie_reg_paxb[] = { }; /* iProc PCIe PAXB v2 registers */ -static const u16 iproc_pcie_reg_paxb_v2[] = { +static const u16 iproc_pcie_reg_paxb_v2[IPROC_PCIE_MAX_NUM_REG] = { [IPROC_PCIE_CLK_CTRL] = 0x000, [IPROC_PCIE_CFG_IND_ADDR] = 0x120, [IPROC_PCIE_CFG_IND_DATA] = 0x124, @@ -363,7 +363,7 @@ static const u16 iproc_pcie_reg_paxb_v2[] = { }; /* iProc PCIe PAXC v1 registers */ -static const u16 iproc_pcie_reg_paxc[] = { +static const u16 iproc_pcie_reg_paxc[IPROC_PCIE_MAX_NUM_REG] = { [IPROC_PCIE_CLK_CTRL] = 0x000, [IPROC_PCIE_CFG_IND_ADDR] = 0x1f0, [IPROC_PCIE_CFG_IND_DATA] = 0x1f4, @@ -372,7 +372,7 @@ static const u16 iproc_pcie_reg_paxc[] = { }; /* iProc PCIe PAXC v2 registers */ -static const u16 iproc_pcie_reg_paxc_v2[] = { +static const u16 iproc_pcie_reg_paxc_v2[IPROC_PCIE_MAX_NUM_REG] = { [IPROC_PCIE_MSI_GIC_MODE] = 0x050, [IPROC_PCIE_MSI_BASE_ADDR] = 0x074, [IPROC_PCIE_MSI_WINDOW_SIZE] = 0x078, From patchwork Thu Oct 1 06:00:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinath Mannam X-Patchwork-Id: 11810929 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49DCD139A for ; Thu, 1 Oct 2020 06:01:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 20A7021D7D for ; Thu, 1 Oct 2020 06:01:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Hr4FGV6n" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730357AbgJAGBT (ORCPT ); Thu, 1 Oct 2020 02:01:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730301AbgJAGBS (ORCPT ); Thu, 1 Oct 2020 02:01:18 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 628ECC0613D0 for ; Wed, 30 Sep 2020 23:01:18 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id x123so3475305pfc.7 for ; Wed, 30 Sep 2020 23:01:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f/SkpM6tbRsXOCCJlOhKUcxkHsc04pd7BesYNpcz9ko=; b=Hr4FGV6nGqJjSbz4H0Au/5QtVJc9aDthW/u7I9wGVNI5HnDmdDfLkPjviw82XVFaV9 V4UOxi7Tf60XhgASsZR4CQDRH2ON/ayKFUd/jUc0XRiRrqK5ydEnO5LSL2C2GmJKA+l2 uuOniiF0PcrjIIHH9sEy+59CkvMtFKXh7CLO0= 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:in-reply-to :references; bh=f/SkpM6tbRsXOCCJlOhKUcxkHsc04pd7BesYNpcz9ko=; b=tFqfqC4OzIuUYHF9p+74FqcZVAq6DOfIxghE/u76qlfLAtTDZ7COaNcaIfKozPe8Gg k7g3gbBfaCmXc2S7SZ4Yb+fRGR0yOhTS07M0fxqAzhiEaW274GV08rxH8nlJN8qkYibl zLNT8yKyMonTTws377JE3GiHVVeEcIh3LQm9UOO+z/lhB0A6eUoQl1wL/XP6mjcQsDCj +W/wh9RExUIiyjWsUQwzFg6qPWcOOZE/covUHtgdIM0qugbvf4jrBNDrkZkM5sNlSdFo HMFOyR0aeknu8eLbFvG1B/kFNYkXgZ9pnQcpMJlZHV8uRY3TpB8vIiA+bjmjPJhEL6hj ux/A== X-Gm-Message-State: AOAM532LuZhsaL6VunYflrh4xYtds1CtwnT+IVIL6gl/S1+NH6Vmp2UA 95dcU8yVGsQ4rOzeTtXWZntFnQ== X-Google-Smtp-Source: ABdhPJxFndR3dwJs0uQsZn3nNsaM1j+1gfIn4Aj8SpyIqST2IsmV+tbPyVYjUBVypeLV9LvI4qpUug== X-Received: by 2002:a62:520e:0:b029:142:2501:3979 with SMTP id g14-20020a62520e0000b029014225013979mr1172795pfb.62.1601532077798; Wed, 30 Sep 2020 23:01:17 -0700 (PDT) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id l2sm4032112pjy.3.2020.09.30.23.01.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 23:01:17 -0700 (PDT) From: Srinath Mannam To: Lorenzo Pieralisi , Bjorn Helgaas , Ray Jui Cc: bcm-kernel-feedback-list@broadcom.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Roman Bacik , Srinath Mannam Subject: [PATCH v3 2/3] PCI: iproc: Invalidate correct PAXB inbound windows Date: Thu, 1 Oct 2020 11:30:53 +0530 Message-Id: <20201001060054.6616-3-srinath.mannam@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201001060054.6616-1-srinath.mannam@broadcom.com> References: <20201001060054.6616-1-srinath.mannam@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Roman Bacik Second stage bootloader prior to Linux boot may use all inbound windows including IARR1/IMAP1. We need to ensure all previous configuration of inbound windows are invalidated during the initialization stage of the Linux iProc PCIe driver. Add fix to define and invalidate IARR1/IMAP1 because it was missed in previous patch. Fixes: 9415743e4c8a ("PCI: iproc: Invalidate PAXB address mapping") Signed-off-by: Roman Bacik Signed-off-by: Srinath Mannam --- drivers/pci/controller/pcie-iproc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c index d901b9d392b8..cc5b7823edeb 100644 --- a/drivers/pci/controller/pcie-iproc.c +++ b/drivers/pci/controller/pcie-iproc.c @@ -192,8 +192,15 @@ static const struct iproc_pcie_ib_map paxb_v2_ib_map[] = { .imap_window_offset = 0x4, }, { - /* IARR1/IMAP1 (currently unused) */ - .type = IPROC_PCIE_IB_MAP_INVALID, + /* IARR1/IMAP1 */ + .type = IPROC_PCIE_IB_MAP_MEM, + .size_unit = SZ_1M, + .region_sizes = { 8 }, + .nr_sizes = 1, + .nr_windows = 8, + .imap_addr_offset = 0x4, + .imap_window_offset = 0x8, + }, { /* IARR2/IMAP2 */ @@ -351,6 +358,8 @@ static const u16 iproc_pcie_reg_paxb_v2[IPROC_PCIE_MAX_NUM_REG] = { [IPROC_PCIE_OMAP3] = 0xdf8, [IPROC_PCIE_IARR0] = 0xd00, [IPROC_PCIE_IMAP0] = 0xc00, + [IPROC_PCIE_IARR1] = 0xd08, + [IPROC_PCIE_IMAP1] = 0xd70, [IPROC_PCIE_IARR2] = 0xd10, [IPROC_PCIE_IMAP2] = 0xcc0, [IPROC_PCIE_IARR3] = 0xe00, From patchwork Thu Oct 1 06:00:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinath Mannam X-Patchwork-Id: 11810931 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3C6596CB for ; Thu, 1 Oct 2020 06:01:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1053D21D7D for ; Thu, 1 Oct 2020 06:01:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="dhx/8554" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730646AbgJAGBY (ORCPT ); Thu, 1 Oct 2020 02:01:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbgJAGBW (ORCPT ); Thu, 1 Oct 2020 02:01:22 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D468C061755 for ; Wed, 30 Sep 2020 23:01:22 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id w7so3492964pfi.4 for ; Wed, 30 Sep 2020 23:01:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XKniDKpGWozCfELydEqWMvqFyRW+NfHyXg+2i7qbqqg=; b=dhx/8554h34hwQVX55dDeA0n6onL+orcGNWROsIte/RfnpAvBWt2IQ9QbSKoS9Q6ZS kbcDXPRu2BswviYaM8KDc3va0CJgwk7P7ZIOVKYKO5rDvoiSm79gDLU+4oR1Pij79UM7 IIDD1pyVDvNf/dY/pRLZR9m0hxdNNT65RiRrM= 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:in-reply-to :references; bh=XKniDKpGWozCfELydEqWMvqFyRW+NfHyXg+2i7qbqqg=; b=P7/QLwmnWhdzuC4zweOaid27X5MXmGCWcjPPiMwSp9EsZI7fOc0+eK6+WBZ7ZY7pEl FXCz7B0HXvb+tagHR10wpOAZpx5gmS7+R0jxYoQrCa+j7tEklVWyUvovsUeeTgCKvisS Bt3nvL2jQ9/evErVRlS2ZhUwYa4nIEWBup0WhlbeUgSQ1L2dm1dfHIeYgaJdAVpLOG2i AppYLAEpLDxjoQ4JEky7UFNWXaI/KVwdiDOFaJ+UemDNHfyyVw4k2+wl0Ui5j70JvthG QXEHSk19d/qeUUo8oavhMzC6EnuQ6iV5covjlqMZ2HDrdLCTigaEsJHBVWLHb7xABDVP mcuw== X-Gm-Message-State: AOAM530FTDUNqTr86qRlXuJaTE72BuW3o1Y3dHi6LJFLCKt969tXelFB gQvRnOwgysRLiLwStbAE6O9ECQ== X-Google-Smtp-Source: ABdhPJwxM5L57TJZwmSnlRWv9mXMAi+RegGmDTyfFRPx7V+QrmL6rajMd24B+gMKgq1ovvMtJvJgsQ== X-Received: by 2002:a17:902:64c2:b029:d2:6356:867e with SMTP id y2-20020a17090264c2b02900d26356867emr5792617pli.32.1601532081551; Wed, 30 Sep 2020 23:01:21 -0700 (PDT) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id l2sm4032112pjy.3.2020.09.30.23.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 23:01:20 -0700 (PDT) From: Srinath Mannam To: Lorenzo Pieralisi , Bjorn Helgaas , Ray Jui Cc: bcm-kernel-feedback-list@broadcom.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Srinath Mannam Subject: [PATCH v3 3/3] PCI: iproc: Display PCIe Link information Date: Thu, 1 Oct 2020 11:30:54 +0530 Message-Id: <20201001060054.6616-4-srinath.mannam@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201001060054.6616-1-srinath.mannam@broadcom.com> References: <20201001060054.6616-1-srinath.mannam@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org After successful linkup more comprehensive information about PCIe link speed and link width will be displayed to the console. Signed-off-by: Srinath Mannam --- drivers/pci/controller/pcie-iproc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c index cc5b7823edeb..8ef2d1fe392c 100644 --- a/drivers/pci/controller/pcie-iproc.c +++ b/drivers/pci/controller/pcie-iproc.c @@ -1479,6 +1479,7 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) { struct device *dev; int ret; + struct pci_dev *pdev; struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie); dev = pcie->dev; @@ -1542,6 +1543,11 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) goto err_power_off_phy; } + for_each_pci_bridge(pdev, host->bus) { + if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT) + pcie_print_link_status(pdev); + } + return 0; err_power_off_phy: