From patchwork Thu Jul 21 14:20:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vidya Sagar X-Patchwork-Id: 12925274 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5764CCA48A for ; Thu, 21 Jul 2022 14:23:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231451AbiGUOXH (ORCPT ); Thu, 21 Jul 2022 10:23:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231587AbiGUOWw (ORCPT ); Thu, 21 Jul 2022 10:22:52 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2074.outbound.protection.outlook.com [40.107.244.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 810F283F0C; Thu, 21 Jul 2022 07:22:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F2bl3/mUmFScOoLrA1GkSVVnlXGPU9WFoecq20uT5pqK12L8SvD07V+8nkjVceIVlnGPN4GPuIb9tKjSVr7/CFXzw9+lvtlJsoPN4JPpKTs+8ZuPV/ZZf0e4HXM0tSc9ANthoLoeKEysSEJPBIua3I4aEwFl/wnoQdwKPay7g7RHy7bcnhrR6LntEC17lmc0JAM8bZrJORleG1AcTmqgCMb1KBZBrCUCI16gyRwYT4IvH972BxGE8vYDMzDbeINwfqFEeDaZhZj1iteOek4UfNl14IJ9CXBvFX7NVFxPYk01O751RAl9+ql7vprsHqJRX8rkdojprcOMC0v/DnLBeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7ai+lkPtavPtAay0ufsgjLQXWbSYBffQIMMG1GTyHCc=; b=JWBFN+sJYRoHcQYOYKOsryCop+pFmrqmCPxCfSb5TX4Wa0MrEvZ4JE7MYt2APEgcGRpkq3mQQsxySMpTho6hFj/5R4xeVjQhHuGE19pv1xntyzUinL4WCS0B8XRk8/dQo4rpAxvJXR7ZqbLoNJliryDlz4MvE4DpmwKInn8Z6f9HTGCysq6uNv6qdocK9RyyLpGEzwcBQpNBB9vvVHHD22LxUJAX9isFNN/3LLIoFyVo9kwcLzWtXtVAdRwsbwATbpAPasXRzrt0EPnKwfVtpo8XEdqq83wv9cNxfzV2wdjFqNg3xKzcdzQ+sP0v8Swgy1BLhBXT78wn2d/ypfRDfA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7ai+lkPtavPtAay0ufsgjLQXWbSYBffQIMMG1GTyHCc=; b=XlUEfhUZuwfu7TpGfBP+TyM5abWN+77sy5R1H+T7l2ll3HmEYD3uPr28h8EDjKc0POmswY8MP2JgZH1vxFodkIQGxep9AHqjim7si5IMjkhZxO4klZQdVJr0tMoly3zRY833hGgbHfAG1Xz5t2xbxAeloSACIBYJUTjKtczhYqSZHN92oL9eykSMcmkAfrG2CIjLls8h8HlPqTddWNmojddZgx57Zlg3whLprNTyMBsr1Ic7GWWZqPx/5H9GQzdJceH4um+YI8zZdnshKgqEpA0xn2IOK0A3Vfn49ejpf3lEc0eN+0+ufpkUIbRA5vpXKd7WLgEu7Xnu+YafuARnWQ== Received: from DS7PR03CA0235.namprd03.prod.outlook.com (2603:10b6:5:3ba::30) by BN8PR12MB2996.namprd12.prod.outlook.com (2603:10b6:408:48::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.14; Thu, 21 Jul 2022 14:22:19 +0000 Received: from DM6NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3ba:cafe::65) by DS7PR03CA0235.outlook.office365.com (2603:10b6:5:3ba::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.24 via Frontend Transport; Thu, 21 Jul 2022 14:22:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.238) by DM6NAM11FT066.mail.protection.outlook.com (10.13.173.179) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5458.17 via Frontend Transport; Thu, 21 Jul 2022 14:22:18 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Thu, 21 Jul 2022 14:22:18 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Thu, 21 Jul 2022 07:22:17 -0700 Received: from vidyas-desktop.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Thu, 21 Jul 2022 07:22:13 -0700 From: Vidya Sagar To: , , , , , , , CC: , , , , , , , , , Subject: [PATCH V6 10/16] PCI: tegra194: Fix root port interrupt handling Date: Thu, 21 Jul 2022 19:50:46 +0530 Message-ID: <20220721142052.25971-11-vidyas@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220721142052.25971-1-vidyas@nvidia.com> References: <20220721142052.25971-1-vidyas@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 62d0099e-2952-4400-d988-08da6b246b39 X-MS-TrafficTypeDiagnostic: BN8PR12MB2996:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X+/X1fT/zpXiheEAum51TpSSbwwfshwnjiLHiQiuYIaoAn+iEw/fG6ZshCS5OEw9/aMJLPf3Aq3KdxcaRuuIt1UbEW0mGSaM6kRoCQx0yOcLd8aMB7hjlkwxPpOoSqDEze8QxAixUvxoe1smZbkA6lSE2XbIML9HGVSR6fZbXPaG3NheUcQc96lA3mEObgNAa1y3VPwzmHpL6e+kvPz98aKfDJhk72wFlW3oNKHhqCtaLl5WIPxTqB/YRH1Ei6sVv95FH/YGg/nvUZhcOCkiNEHj3Xlutj3k91gUG6ooU9zu5hsAnQ3nQZBPyTqfH1mRJSr2H+rGittno5KQkxpesob07i8sm9nqt4dIg/bfhBfyABYW4AM33zelCoOW4LmdmEa+B7zQy4wRk00LWSLV4cjLZbr3m6a2dMWWOxi5UTPQOpvE5mWPJwTiEnJazY11A583VioVCo+5560CR14wLuCjzEYMMvvuI9fBYWM7eoxj2nnO93PWam5ybvcZjRrrQ6q0Ew4UcruqYo1SpITzSIHG071lTrxIW9jSS5EWW4JNNq5jfcxBF+V362KRZm5Sgf5orz/i02OH1m1GNryIcR8cs/eOb6a+ZXjGsmB58YTCELLC2F1dawBtc9IvDdOQZVo3BjXDoD+VgHo7yo9lDxNKJ9MtXUCgzeBvEX7S62rXADO/svzUshiMmxfpFymbiHP25QHhT3MMN4V5IyGM+Hdxy4FthGuMcGvbnulQa5cmvwfCpbPObYORUbvSkZAgN5Fnx8WDJCc/sKB7dm5k/KnFj4dvPVtiIdv6Muc8YWpcYtsP8qij34N6URHRDtqsBzo4flj+Zh1XrZMN4DsBNbK6ASzHZDvvbLUEhRXp/zQ= X-Forefront-Antispam-Report: CIP:12.22.5.238;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230016)(4636009)(396003)(39860400002)(136003)(346002)(376002)(36840700001)(46966006)(40470700004)(70206006)(8936002)(110136005)(70586007)(54906003)(478600001)(40480700001)(40460700003)(4326008)(6666004)(316002)(5660300002)(41300700001)(7416002)(7696005)(2906002)(426003)(82310400005)(2616005)(81166007)(8676002)(47076005)(86362001)(36756003)(1076003)(36860700001)(186003)(83380400001)(356005)(336012)(82740400003)(26005)(2101003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2022 14:22:18.7200 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62d0099e-2952-4400-d988-08da6b246b39 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.238];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB2996 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org As part of root port interrupt handling, level-0 register is read first and based on the bits set in that, corresponding level-1 registers are read for further interrupt processing. Since both these values are currently read into the same 'val' variable, checking level-0 bits the second time around is happening on the 'val' variable value of level-1 register contents instead of freshly reading the level-0 value again. This is fixed by using different variables to store level-0 and level-1 registers contents. Fixes: 56e15a238d92 ("PCI: tegra: Add Tegra194 PCIe support") Signed-off-by: Vidya Sagar --- V6: * New addition in V6 based on Bjorn's review comment drivers/pci/controller/dwc/pcie-tegra194.c | 46 +++++++++++----------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c index 6f890453021d..23377425952a 100644 --- a/drivers/pci/controller/dwc/pcie-tegra194.c +++ b/drivers/pci/controller/dwc/pcie-tegra194.c @@ -338,15 +338,14 @@ static irqreturn_t tegra_pcie_rp_irq_handler(int irq, void *arg) struct tegra_pcie_dw *pcie = arg; struct dw_pcie *pci = &pcie->pci; struct pcie_port *pp = &pci->pp; - u32 val, tmp; + u32 val, status_l0, status_l1; u16 val_w; - val = appl_readl(pcie, APPL_INTR_STATUS_L0); - if (val & APPL_INTR_STATUS_L0_LINK_STATE_INT) { - val = appl_readl(pcie, APPL_INTR_STATUS_L1_0_0); - if (val & APPL_INTR_STATUS_L1_0_0_LINK_REQ_RST_NOT_CHGED) { - appl_writel(pcie, val, APPL_INTR_STATUS_L1_0_0); - + status_l0 = appl_readl(pcie, APPL_INTR_STATUS_L0); + if (status_l0 & APPL_INTR_STATUS_L0_LINK_STATE_INT) { + status_l1 = appl_readl(pcie, APPL_INTR_STATUS_L1_0_0); + appl_writel(pcie, status_l1, APPL_INTR_STATUS_L1_0_0); + if (status_l1 & APPL_INTR_STATUS_L1_0_0_LINK_REQ_RST_NOT_CHGED) { /* SBR & Surprise Link Down WAR */ val = appl_readl(pcie, APPL_CAR_RESET_OVRD); val &= ~APPL_CAR_RESET_OVRD_CYA_OVERRIDE_CORE_RST_N; @@ -362,15 +361,15 @@ static irqreturn_t tegra_pcie_rp_irq_handler(int irq, void *arg) } } - if (val & APPL_INTR_STATUS_L0_INT_INT) { - val = appl_readl(pcie, APPL_INTR_STATUS_L1_8_0); - if (val & APPL_INTR_STATUS_L1_8_0_AUTO_BW_INT_STS) { + if (status_l0 & APPL_INTR_STATUS_L0_INT_INT) { + status_l1 = appl_readl(pcie, APPL_INTR_STATUS_L1_8_0); + if (status_l1 & APPL_INTR_STATUS_L1_8_0_AUTO_BW_INT_STS) { appl_writel(pcie, APPL_INTR_STATUS_L1_8_0_AUTO_BW_INT_STS, APPL_INTR_STATUS_L1_8_0); apply_bad_link_workaround(pp); } - if (val & APPL_INTR_STATUS_L1_8_0_BW_MGT_INT_STS) { + if (status_l1 & APPL_INTR_STATUS_L1_8_0_BW_MGT_INT_STS) { appl_writel(pcie, APPL_INTR_STATUS_L1_8_0_BW_MGT_INT_STS, APPL_INTR_STATUS_L1_8_0); @@ -382,25 +381,24 @@ static irqreturn_t tegra_pcie_rp_irq_handler(int irq, void *arg) } } - val = appl_readl(pcie, APPL_INTR_STATUS_L0); - if (val & APPL_INTR_STATUS_L0_CDM_REG_CHK_INT) { - val = appl_readl(pcie, APPL_INTR_STATUS_L1_18); - tmp = dw_pcie_readl_dbi(pci, PCIE_PL_CHK_REG_CONTROL_STATUS); - if (val & APPL_INTR_STATUS_L1_18_CDM_REG_CHK_CMPLT) { + if (status_l0 & APPL_INTR_STATUS_L0_CDM_REG_CHK_INT) { + status_l1 = appl_readl(pcie, APPL_INTR_STATUS_L1_18); + val = dw_pcie_readl_dbi(pci, PCIE_PL_CHK_REG_CONTROL_STATUS); + if (status_l1 & APPL_INTR_STATUS_L1_18_CDM_REG_CHK_CMPLT) { dev_info(pci->dev, "CDM check complete\n"); - tmp |= PCIE_PL_CHK_REG_CHK_REG_COMPLETE; + val |= PCIE_PL_CHK_REG_CHK_REG_COMPLETE; } - if (val & APPL_INTR_STATUS_L1_18_CDM_REG_CHK_CMP_ERR) { + if (status_l1 & APPL_INTR_STATUS_L1_18_CDM_REG_CHK_CMP_ERR) { dev_err(pci->dev, "CDM comparison mismatch\n"); - tmp |= PCIE_PL_CHK_REG_CHK_REG_COMPARISON_ERROR; + val |= PCIE_PL_CHK_REG_CHK_REG_COMPARISON_ERROR; } - if (val & APPL_INTR_STATUS_L1_18_CDM_REG_CHK_LOGIC_ERR) { + if (status_l1 & APPL_INTR_STATUS_L1_18_CDM_REG_CHK_LOGIC_ERR) { dev_err(pci->dev, "CDM Logic error\n"); - tmp |= PCIE_PL_CHK_REG_CHK_REG_LOGIC_ERROR; + val |= PCIE_PL_CHK_REG_CHK_REG_LOGIC_ERROR; } - dw_pcie_writel_dbi(pci, PCIE_PL_CHK_REG_CONTROL_STATUS, tmp); - tmp = dw_pcie_readl_dbi(pci, PCIE_PL_CHK_REG_ERR_ADDR); - dev_err(pci->dev, "CDM Error Address Offset = 0x%08X\n", tmp); + dw_pcie_writel_dbi(pci, PCIE_PL_CHK_REG_CONTROL_STATUS, val); + val = dw_pcie_readl_dbi(pci, PCIE_PL_CHK_REG_ERR_ADDR); + dev_err(pci->dev, "CDM Error Address Offset = 0x%08X\n", val); } return IRQ_HANDLED;