From patchwork Tue Sep 15 13:45:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinath Mannam X-Patchwork-Id: 11778461 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 7202C6CA for ; Wed, 16 Sep 2020 00:26:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3DE952078D for ; Wed, 16 Sep 2020 00:26:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="CnIPnbee" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726749AbgIPA0r (ORCPT ); Tue, 15 Sep 2020 20:26:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726810AbgIOOI2 (ORCPT ); Tue, 15 Sep 2020 10:08:28 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 525E3C0611C1 for ; Tue, 15 Sep 2020 06:46:16 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id e4so1373269pln.10 for ; Tue, 15 Sep 2020 06:46:16 -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=cdgo8gcr3yR5N+Dt3Xu3fyRafdoq6RtuY7MnOM9virM=; b=CnIPnbeegGCLMjvV+Ttrb9jnBV8d4g+3XEzFqqI9X4Aghu8tpkBVcG3p5uMt5R2ZAd u2nkvfVIrw2o1PoO3qi0fQy7d1TFoyU6yodsXUMq5rUBdlEThEiZxkHoI3p1evRL4Tp5 jQ2+6DoK9BcWRYZ7Yyk9O2wsiQaBnmlQee96E= 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=cdgo8gcr3yR5N+Dt3Xu3fyRafdoq6RtuY7MnOM9virM=; b=m4Jq2TOBmDQZwnnSCuly/R185GGBBTpWhMS2d8sA9jaYs92+4uhtH9ZvQptul3tTKY cczP9YByzGqSbtqrfPvHtup1xfzvjceBNPf3a7eVqjQ9+NP9VDi0cqaT1MecJ62lKMUP 1HOgLRFfmGsEFZi5qt0Ir1udWqR6xG4sW0U/NxI6ESuBxErERgY8ODkpswmMfPnWW30D NXpDSmq6BTrqdGBOQzr1B3IP9RwvxTOhsccnUsUsDpb2QZovx/Cs5fJLIWJuQs9GgqPA h2suf5X+0W1N24DIGlunjOKlzgdwj2v+DAEQXXw/naMz9jkYZEF/dPvhkHlWGUZfUge/ bInA== X-Gm-Message-State: AOAM5307If+XtAPFy0AhZYEGdy6iAk3L/zlLJnKMZG1D7QvuY7bnSRw8 UhmiH5flF5FpxiWOg97S4EgiNg== X-Google-Smtp-Source: ABdhPJwmupdPJkXxq/Xvz8pxucXHnT0qli4TU7cgSEMHSMSOmquu4nXVAEisl1KN+Su+p8HYGgitZw== X-Received: by 2002:a17:902:d693:b029:d1:bb0f:5f9d with SMTP id v19-20020a170902d693b02900d1bb0f5f9dmr14884498ply.30.1600177575714; Tue, 15 Sep 2020 06:46:15 -0700 (PDT) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id jz6sm12471478pjb.22.2020.09.15.06.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 06:46:15 -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 v2 1/3] PCI: iproc: fix out of bound array access Date: Tue, 15 Sep 2020 19:15:39 +0530 Message-Id: <20200915134541.14711-2-srinath.mannam@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200915134541.14711-1-srinath.mannam@broadcom.com> References: <20200915134541.14711-1-srinath.mannam@broadcom.com> Sender: linux-pci-owner@vger.kernel.org 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 the 'iproc_pcie_rev_init' function. 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 Tue Sep 15 13:45:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinath Mannam X-Patchwork-Id: 11776715 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 B9B1F59D for ; Tue, 15 Sep 2020 14:03:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F4AD22207 for ; Tue, 15 Sep 2020 14:03:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="TkOrTnS/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726255AbgION6r (ORCPT ); Tue, 15 Sep 2020 09:58:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726749AbgIONxg (ORCPT ); Tue, 15 Sep 2020 09:53:36 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 994A1C061A86 for ; Tue, 15 Sep 2020 06:46:19 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id gf14so1733944pjb.5 for ; Tue, 15 Sep 2020 06:46:19 -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=PL538uCf4O1rvxMafK+xno0ava7nNmchjlBFnDOvCxs=; b=TkOrTnS/RYGwioOfQxWLY+brMGn5tlgGufygSBn6z37VCQDSeDaqtHZkRl2tGlQc4Y bvLUXPpnZNP069g52vrzZIRyMQXhWhES3Yw7x16m/yn2ABkt5aguMt6zvAqrqecXM9gC CB1MoJOeqv1+VyBIo3HNSBivadVQh8hg/UsQw= 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=PL538uCf4O1rvxMafK+xno0ava7nNmchjlBFnDOvCxs=; b=qt9pIIXfcnsZ9U1jLSYRhbgHRDCv7817RQj4iQ3AzURazp6bpOzc8etDuCiCEKS/NH JzH2pPZ2HVg/i3XLLFqK0ubAw4RHiECmiSy8HeciR6DQdwE7sD4BuN1n4YAjOWH29p0T u+vlckT/vm1n0CSB/0vMi3Kbv+sUHCRaONZjWOkKgO4wFGHbazjhdGGKKQrT9fvnHlU3 hGa4sGYqwpbnbcu54MB70Jr3f5O64OQdbhu8mRvdUhzSNZY+iqJRRsWJXQLO5QshvFck 5XU32jdz6wvl+HKqsZcaIC0qfvUyZtgoWx1nO2kk+x7nayDf170yUW79zi/olJkMy5NQ R1kw== X-Gm-Message-State: AOAM532tGiKL7e2Ix7k3nxJK80IzYVuxFu2O6nR3gPd09FCQJp3k1Bog vRS+OIkT+sB7vWM98jCpKYJujA== X-Google-Smtp-Source: ABdhPJwNbBXknbEj3cP0la5qIjQxFssxA2A+fWq8qa9gVHPn4tU4U1Cile235ZEU6vSs0aZbOU/Yog== X-Received: by 2002:a17:902:9308:b029:d1:9bd3:6775 with SMTP id bc8-20020a1709029308b02900d19bd36775mr18753679plb.26.1600177579026; Tue, 15 Sep 2020 06:46:19 -0700 (PDT) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id jz6sm12471478pjb.22.2020.09.15.06.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 06:46:18 -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 v2 2/3] PCI: iproc: fix invalidating PAXB address mapping Date: Tue, 15 Sep 2020 19:15:40 +0530 Message-Id: <20200915134541.14711-3-srinath.mannam@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200915134541.14711-1-srinath.mannam@broadcom.com> References: <20200915134541.14711-1-srinath.mannam@broadcom.com> Sender: linux-pci-owner@vger.kernel.org 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 Tue Sep 15 13:45:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinath Mannam X-Patchwork-Id: 11776733 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 298DB6CA for ; Tue, 15 Sep 2020 14:12:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0670821D7D for ; Tue, 15 Sep 2020 14:12:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="FE/uY5xZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726783AbgIOOMW (ORCPT ); Tue, 15 Sep 2020 10:12:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726815AbgIOOI2 (ORCPT ); Tue, 15 Sep 2020 10:08:28 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B398FC0611C2 for ; Tue, 15 Sep 2020 06:46:22 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id a9so1803282pjg.1 for ; Tue, 15 Sep 2020 06:46: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=rgoatpPEep+AjT30Mye6VvozNsyBb0uBUKnSsty40P0=; b=FE/uY5xZIO2hyih0TY8Kk+GNLuKbNHwGhwfJlJlTn0x25KvEKzKwPIXhtT1FiH82ky RvvXicGvXhRegmv+6a3/aG9rthMjIg5O5vM+D2AsADTOl5CvyKHgcY7xwaMiUw5qckDt gBSrWdy4AdPAUh+T4wM1AjGZfJ21HHvWZCVio= 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=rgoatpPEep+AjT30Mye6VvozNsyBb0uBUKnSsty40P0=; b=WUb+SD8AJCygLS9KFatt4b3h1K6yL9uc32d6UH8yw/H/HlZUJtEeM0TAGYJODix38c m5z9ZAmZ4SbP7p3nsjvwTRcs1lmLCqFV8wQtvgbzO3S2fpqKRPXyztP+/EZo1djVWKsa XeuOZVpfk6brRroZdYaNn6vyi1lcfmLXRLaRL4h1u+lvgYFgigYfh9VpwYRk2ncCxlWK pDjVP508mTYkuLF63ROnzuztxunJaQtmpY66fnqVvizPXr2h9OaTLAhh65Em/ziqngbX iwrAPBpT1AC8YOVNcKTZlt8s4eEN2tbhB5TxB0B2MtwONhD9fYJOtmI1FeF7qspJ2X2l 9o6Q== X-Gm-Message-State: AOAM531kA77k906QKjMaRmVCu/2C//9L9FcoTWp545+23PuFGHju6wn/ aMM+UOxKQbIFJ06lSi+rPyVTHg== X-Google-Smtp-Source: ABdhPJxYK1MAcd2/B7aGqsEyn9aiL4htZpxzgynwGVzaM1yHVH97Hv0zf4MumRJTswkc/O3h4l46Pw== X-Received: by 2002:a17:902:fe0b:b029:d1:9bd3:6e20 with SMTP id g11-20020a170902fe0bb02900d19bd36e20mr19833487plj.31.1600177582178; Tue, 15 Sep 2020 06:46:22 -0700 (PDT) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id jz6sm12471478pjb.22.2020.09.15.06.46.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 06:46:21 -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 v2 3/3] PCI: iproc: Display PCIe Link information Date: Tue, 15 Sep 2020 19:15:41 +0530 Message-Id: <20200915134541.14711-4-srinath.mannam@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200915134541.14711-1-srinath.mannam@broadcom.com> References: <20200915134541.14711-1-srinath.mannam@broadcom.com> Sender: linux-pci-owner@vger.kernel.org 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: