From patchwork Thu Mar 26 07:07:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinath Mannam X-Patchwork-Id: 11459419 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 2724615AB for ; Thu, 26 Mar 2020 07:08:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F08D220772 for ; Thu, 26 Mar 2020 07:08:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="NkGvO6uY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726270AbgCZHII (ORCPT ); Thu, 26 Mar 2020 03:08:08 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:34585 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726332AbgCZHIF (ORCPT ); Thu, 26 Mar 2020 03:08:05 -0400 Received: by mail-wr1-f67.google.com with SMTP id 65so6439762wrl.1 for ; Thu, 26 Mar 2020 00:08:04 -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=afg8dNB66EeO23R6bSZJHyegs9ORKcUpXptgDs7UTws=; b=NkGvO6uYSAMxMcb9P0RAg0D3yHckMsjCJgy81OSyDdL8EF5sHoZxsihiKBUJYqIQO0 FkmG1UfasybW7KR8tmBkKkkF3pTqzVP3/mgrEq2721W34udH76Kg/t0NKLtbP6vyBlpc 0zMeDxmnwXlItGBygP6bdmXi34qI8MUNpDSm0= 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=afg8dNB66EeO23R6bSZJHyegs9ORKcUpXptgDs7UTws=; b=b2Rx8/FlxmUG2lFtG9KjMSLBQoDdJTPQvfKQMEKqtPjRi0pGkuW4MItodiuTzETIuV Z1ufmRVCzCeMqQ+m+vVliBGk7DHDbou39BlcdLXSZzh18wlgQ6o/Ra29dV52KPRJv4K5 vgZJL5TM0F1oa4VtBJTQMVn+EB3+66iyGhAkaEy2WR3uj6Jt4kQfoTFW64tMGMPxb3ct 9jSH5G/0GGuy56O4EGo08CJ+om05QCa+oqWf/2PN9lsy6lT4a+MV2T5kKN2Etux5/8YP mcFkQyktFWe64IQLEYcpjAUUl+F32XS8mGePsYPjStP/WvVPwpd5aUR+GWYlL5js1NCH /DOw== X-Gm-Message-State: ANhLgQ0Zy5vZ/aM3c94Xu8VxgHPk5Eo3FJgVrxead6b4+8xcn+I10Mlc 95YvyEy5t9UXgbauHEOoK91Zpg== X-Google-Smtp-Source: ADFU+vs4AXz8FI0fPBQ54wsPqGouqEqXUvwleEGkLy2ntX9wK7IYngl27SxZG3aUl2DSzFShBbL0tA== X-Received: by 2002:adf:e68b:: with SMTP id r11mr7161551wrm.138.1585206483395; Thu, 26 Mar 2020 00:08:03 -0700 (PDT) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id u8sm2129446wrn.69.2020.03.26.00.07.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Mar 2020 00:08:02 -0700 (PDT) From: Srinath Mannam To: Lorenzo Pieralisi , Bjorn Helgaas , Florian Fainelli , Ray Jui , Andrew Murray 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 1/3] PCI: iproc: fix out of bound array access Date: Thu, 26 Mar 2020 12:37:25 +0530 Message-Id: <1585206447-1363-2-git-send-email-srinath.mannam@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1585206447-1363-1-git-send-email-srinath.mannam@broadcom.com> References: <1585206447-1363-1-git-send-email-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 0a468c7..6972ca4 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 Mar 26 07:07:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinath Mannam X-Patchwork-Id: 11459421 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 8BCF8913 for ; Thu, 26 Mar 2020 07:08:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 61002208FE for ; Thu, 26 Mar 2020 07:08:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="efWdxf0x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727732AbgCZHII (ORCPT ); Thu, 26 Mar 2020 03:08:08 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:40741 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727685AbgCZHII (ORCPT ); Thu, 26 Mar 2020 03:08:08 -0400 Received: by mail-wm1-f65.google.com with SMTP id a81so5765241wmf.5 for ; Thu, 26 Mar 2020 00:08:08 -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=jPRrwsRUkZnW1BFu5Zfyz0cjxU3qvYq6Y7T8MRQYSdQ=; b=efWdxf0xIIzGwlTo3B7F4lTNocP3UhjzgR/Sd9/0GFBKhpHka8s/Y9kODVon2GS7vJ pq9EHgDW6S9M0akfRcUHx/NMcDKKRj6juykMcA7D3uVqJmxsJ+efqUgMmf6D0sjPFBmO kqALyIdMWtBPhTz/J0uQ2VxJsTEyd22LRi0eI= 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=jPRrwsRUkZnW1BFu5Zfyz0cjxU3qvYq6Y7T8MRQYSdQ=; b=LLX5T2Nx9Ww0W1MyGe/mqbyRUdmP8NpniauAomfPM13yZJvz7yeHA7pk/W6pDErk2o Tqy8Di8NQYV9Eu6tQW0IPGBtfGGelIpAtsQuZ85YayXXKIlmUyHlJgND24UrIptRCRB7 MIskBqQOa8tS7tSvIW2ynIvFdawZwum8fe/CaRQyaWiYfIiwmDtt8bbEXR2EfTFKMDb6 Pr1j3UfQrhojy6gG05Q2timwd7joVuR1jQTyNs1DgdAQDaJGNY4yQI5ZydfGEUP27DFd AJEdmEaSPVuhCEJhMnc6qQZhODBpCFAkkMYf1OqvN5LOYeymtOZEviFTjsDjpv2Fd3Lk sABA== X-Gm-Message-State: ANhLgQ0pVNrB1LqE5Ylb/+uqWbmte/PXkLmn5oeAxhjfAqJ3gBv08vL4 YKQKEKqt3fSAyGQL+XF0YMLF3Q== X-Google-Smtp-Source: ADFU+vuUW1y4Zx4fXihxBF7h/Mv+t1RFz2WFLCdyXsWOwZrkM3bG2jv3jmghxHL5EtVY9/HxmunywA== X-Received: by 2002:a1c:7d08:: with SMTP id y8mr1529567wmc.67.1585206487385; Thu, 26 Mar 2020 00:08:07 -0700 (PDT) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id u8sm2129446wrn.69.2020.03.26.00.08.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Mar 2020 00:08:06 -0700 (PDT) From: Srinath Mannam To: Lorenzo Pieralisi , Bjorn Helgaas , Florian Fainelli , Ray Jui , Andrew Murray 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 Subject: [PATCH 2/3] PCI: iproc: fix invalidating PAXB address mapping Date: Thu, 26 Mar 2020 12:37:26 +0530 Message-Id: <1585206447-1363-3-git-send-email-srinath.mannam@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1585206447-1363-1-git-send-email-srinath.mannam@broadcom.com> References: <1585206447-1363-1-git-send-email-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 invalidate IARR1/IMAP1 because it was missed in previous patch. Fixes: 9415743e4c8a ("PCI: iproc: Invalidate PAXB address mapping") Signed-off-by: Roman Bacik --- drivers/pci/controller/pcie-iproc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c index 6972ca4..e7f0d58 100644 --- a/drivers/pci/controller/pcie-iproc.c +++ b/drivers/pci/controller/pcie-iproc.c @@ -351,6 +351,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 Mar 26 07:07:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinath Mannam X-Patchwork-Id: 11459423 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 A43B9913 for ; Thu, 26 Mar 2020 07:08:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 78E802082D for ; Thu, 26 Mar 2020 07:08:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Giw12tZA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727688AbgCZHIN (ORCPT ); Thu, 26 Mar 2020 03:08:13 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:55583 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727815AbgCZHIM (ORCPT ); Thu, 26 Mar 2020 03:08:12 -0400 Received: by mail-wm1-f66.google.com with SMTP id z5so5296547wml.5 for ; Thu, 26 Mar 2020 00:08:12 -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=usE/ys/z8ZrEvebTD5q/zOIViwN/Qr3bNxaYZNYeDg8=; b=Giw12tZAymXDFbxQpbLEzz6w7r0O1eeZFHByJRUEwF4s3fssUnmfVK37HovY8MSG8g aB0CYd0nDge3IebAXKcKCn8DL9FO01QrQqv4ZQkSxBXz+3/jUAxHH7CjlMq4PusOsrRa AIAUX+paTRcoYbFPrM7u3LFEUrqEoZNo+GqDI= 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=usE/ys/z8ZrEvebTD5q/zOIViwN/Qr3bNxaYZNYeDg8=; b=TrClFuNndGwGxaYkRSjOTeW5KbU2WfYhD87qMjnuqF9HUq3eYyAyBPYYw4FPGEiKEt JJu1ldYph2hGFAFmJnYUau6PCfnWsPYoC+76S22TOhs92tAX6sdRyXg/FCYOcJ1+U6mg BYwRSox0tS7ZgGEGpb9O8UNFx+mOrzMc9yiPrjbL5GDjd4Q80JgHneUBkFXyW8yNHTGF D4nsIrg0mrmO3jbBdgHrEQmmeAxzSV3PmwdKLpexdg4ZVGenZIFtSD2GEjEZ8xc5DtsZ FzfoAc+oGyxrBYcs9Hr+F93LmzQx7gNOVyr+D+HtlbT+m2P1gBq7ZSz+GGOgKNnT45Mq rMkQ== X-Gm-Message-State: ANhLgQ3TxCyQ2Rfr6ZBiAOkWNctIRXW9DQJ+nYaBI74rDUDaqYpfZjWK ozJBJZKOtzWXIRFX90CFc7If2A== X-Google-Smtp-Source: ADFU+vtzb9hNfI+ksv6e+V0DXN1iXSfAh7FZDOiwNKmj5UxnWCz/9VDiia75rLzG0tKw11MssM2Gsw== X-Received: by 2002:a1c:8090:: with SMTP id b138mr1644314wmd.55.1585206491567; Thu, 26 Mar 2020 00:08:11 -0700 (PDT) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id u8sm2129446wrn.69.2020.03.26.00.08.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Mar 2020 00:08:10 -0700 (PDT) From: Srinath Mannam To: Lorenzo Pieralisi , Bjorn Helgaas , Florian Fainelli , Ray Jui , Andrew Murray 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 3/3] PCI: iproc: Display PCIe Link information Date: Thu, 26 Mar 2020 12:37:27 +0530 Message-Id: <1585206447-1363-4-git-send-email-srinath.mannam@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1585206447-1363-1-git-send-email-srinath.mannam@broadcom.com> References: <1585206447-1363-1-git-send-email-srinath.mannam@broadcom.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Add more comprehensive information to show PCIe link speed and link width to the console. Signed-off-by: Srinath Mannam --- drivers/pci/controller/pcie-iproc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c index e7f0d58..ed41357 100644 --- a/drivers/pci/controller/pcie-iproc.c +++ b/drivers/pci/controller/pcie-iproc.c @@ -823,6 +823,8 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie) #define PCI_TARGET_LINK_SPEED_MASK 0xf #define PCI_TARGET_LINK_SPEED_GEN2 0x2 #define PCI_TARGET_LINK_SPEED_GEN1 0x1 +#define PCI_TARGET_LINK_WIDTH_MASK 0x3f +#define PCI_TARGET_LINK_WIDTH_OFFSET 0x4 iproc_pci_raw_config_read32(pcie, 0, IPROC_PCI_EXP_CAP + PCI_EXP_LNKCTL2, 4, &link_ctrl); @@ -843,7 +845,14 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie) } } - dev_info(dev, "link: %s\n", link_is_active ? "UP" : "DOWN"); + if (link_is_active) { + dev_info(dev, "link UP @ Speed Gen-%d and width-x%d\n", + link_status & PCI_TARGET_LINK_SPEED_MASK, + (link_status >> PCI_TARGET_LINK_WIDTH_OFFSET) & + PCI_TARGET_LINK_WIDTH_MASK); + } else { + dev_info(dev, "link DOWN\n"); + } return link_is_active ? 0 : -ENODEV; }