From patchwork Mon Dec 28 14:05:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Athani Nadeem Ladkhan X-Patchwork-Id: 11991287 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B70A6C433E6 for ; Mon, 28 Dec 2020 15:14:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D41722472 for ; Mon, 28 Dec 2020 15:14:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438554AbgL1PNp (ORCPT ); Mon, 28 Dec 2020 10:13:45 -0500 Received: from mx0a-0014ca01.pphosted.com ([208.84.65.235]:10826 "EHLO mx0a-0014ca01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438251AbgL1OGw (ORCPT ); Mon, 28 Dec 2020 09:06:52 -0500 Received: from pps.filterd (m0042385.ppops.net [127.0.0.1]) by mx0a-0014ca01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BSDvc4i004305; Mon, 28 Dec 2020 06:05:40 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=proofpoint; bh=pCs8ZIWLbAqar7nQCRBh7v2ZcsGi82HUlYAsqpWpDFI=; b=jufdAzaVoE44SxIDnckSoI+qTM6uSuWoHnJr90OXPvQI8kZ5ADuVJwm5wSq+SKaa5h4/ ofeLj9S+doE4azOkPIPGEUeiBk6VUYsmbITfXnJ9vc8ZsjZgd6lFvEZlAMYGu3SUyoq3 jQIB5H0LObOQcUsOQ+W4+pJQY0RYArR9Cki6RuqolPEFo8c5HwecChfOOCwI0Ftoqahr UpANO2RsNy6IgUvSzQ6wH/r/ef3ZyZ4zOVEoBLm4Iu6WsBVAPL7Bt2iqisCHsqJ+XErb xnVjt/Aef91gethQ8cx+ikTZ0FwN00Y+uxWndmpOVbWogsYo9itpfhouSSvRgoabytMc Eg== Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by mx0a-0014ca01.pphosted.com with ESMTP id 35p2m1be5q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Dec 2020 06:05:40 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j3KMYQQLk1vvatrSqpjva9LFG1dMat13nttLdis2gs3qDwnJP9PMtc7Ma2C0aGoT2TTgNsh2alSKx0xXORdfyIxdunDT7YRVN/ANkR9p8UhVZbJgDAPLxT6qqJd0UtEDbkRnm2bdXZeR4QV0aTxWUCyaJVAwTJ+o7xaUbcrwFzGuqPJsU75swAgR/e+Wn1JBcH3npSTSYbzytKTx/VVqw9DokGuP9RcAmVhXuOCNZgFrz5qQeobk9ZzeXdy0fxaB2rTPcAZMwarxzutfNiBjtOu5AK+8Q0gyKzvaxdv/QBZPCGfHpbUNY1/Mpqj4GaboMT3GI+6Rn0HDNcjDBzCG3A== 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-SenderADCheck; bh=pCs8ZIWLbAqar7nQCRBh7v2ZcsGi82HUlYAsqpWpDFI=; b=mw2K2gSKxhUQM+vmkLlq3WopaYK/uhiyhbpKsOptoyEW307tBioGa7yQqXA89MIhBYWrdqQXjLpFtCprKo9OYzMbEqiqgWS/2s86bHeYwUVpbWwyTpY9KpR5zPVqDKvbB80/gBHUZ9srwkuDk0m2b0DDTyGOuu0x4fLjLlAo1C84BcWMA7G0P3W7PgOhcsH0q/thAnfhZMAEXKRTvs740las99qwvPjv1FWA3ylWNiff58RvL+uXERALLgXDZ//jsz9GQAHCLM8r4+JrMOdhueR6k3Y4hw2L7JqNeKvhQ+2Vd3rNDPts2NYaKRw9cUdjPdbx1zRecIB2EmLnzohkrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 199.43.4.23) smtp.rcpttodomain=google.com smtp.mailfrom=cadence.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=cadence.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pCs8ZIWLbAqar7nQCRBh7v2ZcsGi82HUlYAsqpWpDFI=; b=NuzZSO/NcRdpBuT9otPj4Clt4uba1s+z1Ja7WRl42aW1SAQpBdmqWNCaJviLmg+7UPHDcwrzzJ4t1uTG+R7ZGZhqLR8KbwQpHaYkv8fLk5C7AdQpq5hzeWO+0/zwrrSELT974f2vyf/jATO8jKotRL2ZR+4CFHee14YCllo4jhg= Received: from DM6PR06CA0052.namprd06.prod.outlook.com (2603:10b6:5:54::29) by CY4PR0701MB3620.namprd07.prod.outlook.com (2603:10b6:910:90::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.28; Mon, 28 Dec 2020 14:05:37 +0000 Received: from DM6NAM12FT062.eop-nam12.prod.protection.outlook.com (2603:10b6:5:54:cafe::e5) by DM6PR06CA0052.outlook.office365.com (2603:10b6:5:54::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.27 via Frontend Transport; Mon, 28 Dec 2020 14:05:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 199.43.4.23) smtp.mailfrom=cadence.com; google.com; dkim=none (message not signed) header.d=none;google.com; dmarc=pass action=none header.from=cadence.com; Received-SPF: Pass (protection.outlook.com: domain of cadence.com designates 199.43.4.23 as permitted sender) receiver=protection.outlook.com; client-ip=199.43.4.23; helo=rmmaillnx1.cadence.com; Received: from rmmaillnx1.cadence.com (199.43.4.23) by DM6NAM12FT062.mail.protection.outlook.com (10.13.178.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.20 via Frontend Transport; Mon, 28 Dec 2020 14:05:36 +0000 Received: from maileu3.global.cadence.com (maileu3.cadence.com [10.160.88.99]) by rmmaillnx1.cadence.com (8.14.4/8.14.4) with ESMTP id 0BSE5XBO030293 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Dec 2020 09:05:34 -0500 X-CrossPremisesHeadersFilteredBySendConnector: maileu3.global.cadence.com Received: from maileu3.global.cadence.com (10.160.88.99) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 28 Dec 2020 15:05:32 +0100 Received: from vleu-orange.cadence.com (10.160.88.83) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Mon, 28 Dec 2020 15:05:32 +0100 Received: from vleu-orange.cadence.com (localhost.localdomain [127.0.0.1]) by vleu-orange.cadence.com (8.14.4/8.14.4) with ESMTP id 0BSE5Wg9014705; Mon, 28 Dec 2020 15:05:32 +0100 Received: (from nadeem@localhost) by vleu-orange.cadence.com (8.14.4/8.14.4/Submit) id 0BSE5W1Q014704; Mon, 28 Dec 2020 15:05:32 +0100 From: Nadeem Athani To: , , , , , , , , CC: , , , Subject: [PATCH v6 1/2] PCI: cadence: Retrain Link to work around Gen2 training defect. Date: Mon, 28 Dec 2020 15:05:09 +0100 Message-ID: <20201228140510.14641-2-nadeem@cadence.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20201228140510.14641-1-nadeem@cadence.com> References: <20201228140510.14641-1-nadeem@cadence.com> MIME-Version: 1.0 X-OrganizationHeadersPreserved: maileu3.global.cadence.com X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 641dfbfa-2c7a-4148-1d25-08d8ab39a6aa X-MS-TrafficTypeDiagnostic: CY4PR0701MB3620: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AlxBixrAS0rWOitHZI2GwSRal9BuCPZgCwYcdDWu93xAufONczQgqX1k4NqS5ogdMXrBHQPnYVOP8RbahktTgdV94MbRmF4fggFlJ2CIO/dYub4b3wb/Y1/DmliTHw8pi7Glw7/aAhPjMZ6CNFrXMXLkOA3Ka7GlREjm5M4TTJXSVS7lggHC+4KiNR3TeofD1OGimrvUUt0e0g5QslXJ3rsD3ldyWXbmD0yTSfP1uLTqakFGqTp7vzzd6eHNc60Y9PbKzqfLM+44bHUWgqe+OrarYb1Pz+zzwb1ymYHK4LhyCIaoQAKFJDLOHL0JZ7XDJnt4uF6w6mfAa/MTznyLXENBCQshvdpBq/5sbdgvmIgV6lXPTAi5JbNCM4nPX9RtnYvMX69fiirHYTDUKb31p26zUusvQpaekPerhZB7lao4zpImZS1oQlff5DgUpt40UfJ4HPEAm1sbnOhfNFEdSsn3HouZuGrTBrQhltBhDUCDZzTA/5DGynaoVYRyY46AZil3iO6CXDaMXc0WJW9JBA== X-Forefront-Antispam-Report: CIP:199.43.4.23;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:rmmaillnx1.cadence.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(396003)(136003)(346002)(376002)(39860400002)(36092001)(46966006)(2906002)(42186006)(86362001)(70586007)(4326008)(47076005)(36756003)(107886003)(2616005)(70206006)(54906003)(110136005)(82740400003)(83380400001)(81166007)(426003)(26005)(336012)(8936002)(1076003)(5660300002)(478600001)(316002)(6666004)(8676002)(186003)(356005)(82310400003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2020 14:05:36.9837 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 641dfbfa-2c7a-4148-1d25-08d8ab39a6aa X-MS-Exchange-CrossTenant-Id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d36035c5-6ce6-4662-a3dc-e762e61ae4c9;Ip=[199.43.4.23];Helo=[rmmaillnx1.cadence.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM12FT062.eop-nam12.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR0701MB3620 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-28_11:2020-12-28,2020-12-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 malwarescore=0 spamscore=0 adultscore=0 clxscore=1015 mlxlogscore=999 mlxscore=0 phishscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012280088 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Moving the function above to remove compilation error. No changes in function. Signed-off-by: Nadeem Athani --- drivers/pci/controller/cadence/pcie-cadence-host.c | 33 +++++++++++----------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/pci/controller/cadence/pcie-cadence-host.c b/drivers/pci/controller/cadence/pcie-cadence-host.c index 811c1cb2e8de..9f7aa718c8d4 100644 --- a/drivers/pci/controller/cadence/pcie-cadence-host.c +++ b/drivers/pci/controller/cadence/pcie-cadence-host.c @@ -77,6 +77,22 @@ static struct pci_ops cdns_pcie_host_ops = { .write = pci_generic_config_write, }; +static int cdns_pcie_host_wait_for_link(struct cdns_pcie *pcie) +{ + struct device *dev = pcie->dev; + int retries; + + /* Check if the link is up or not */ + for (retries = 0; retries < LINK_WAIT_MAX_RETRIES; retries++) { + if (cdns_pcie_link_up(pcie)) { + dev_info(dev, "Link up\n"); + return 0; + } + usleep_range(LINK_WAIT_USLEEP_MIN, LINK_WAIT_USLEEP_MAX); + } + + return -ETIMEDOUT; +} static int cdns_pcie_host_init_root_port(struct cdns_pcie_rc *rc) { @@ -398,23 +414,6 @@ static int cdns_pcie_host_init(struct device *dev, return cdns_pcie_host_init_address_translation(rc); } -static int cdns_pcie_host_wait_for_link(struct cdns_pcie *pcie) -{ - struct device *dev = pcie->dev; - int retries; - - /* Check if the link is up or not */ - for (retries = 0; retries < LINK_WAIT_MAX_RETRIES; retries++) { - if (cdns_pcie_link_up(pcie)) { - dev_info(dev, "Link up\n"); - return 0; - } - usleep_range(LINK_WAIT_USLEEP_MIN, LINK_WAIT_USLEEP_MAX); - } - - return -ETIMEDOUT; -} - int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) { struct device *dev = rc->pcie.dev; From patchwork Mon Dec 28 14:05:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Athani Nadeem Ladkhan X-Patchwork-Id: 11991289 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A423FC433E0 for ; Mon, 28 Dec 2020 15:14:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6BB80223E8 for ; Mon, 28 Dec 2020 15:14:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2441085AbgL1PNp (ORCPT ); Mon, 28 Dec 2020 10:13:45 -0500 Received: from mx0a-0014ca01.pphosted.com ([208.84.65.235]:12532 "EHLO mx0a-0014ca01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438238AbgL1OGw (ORCPT ); Mon, 28 Dec 2020 09:06:52 -0500 Received: from pps.filterd (m0042385.ppops.net [127.0.0.1]) by mx0a-0014ca01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BSDw5YA005243; Mon, 28 Dec 2020 06:05:45 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=proofpoint; bh=z1GryEBqElrFTcJ32x+asL3miwc0Qe7PF6X9kDiz/KE=; b=SJGi0MZnbRPcZU0JO4oXLr1PALmaZNfh651IekYZIF1+mvVKapsKhRHy1F/8IjRZtYJd zFAwzJNbRJYTs4PVyJ7z7eoLsDb+8LJ/YZN4jmPRnVkBQzDulAaf7byA2KChDm/HrvRP 5S+4AyJVUHbgQqV5aimmq9lfzpTwiIIKC9JE/VPU8GsoOl0urdtFC1suzUni2b+84Zs0 Yds3mzTdt7vsFbh1IJ9koOVmSkYmvZmGnVtmJHGplDBmJcX3eg7LoegIUyWr/ACUVAyK V6Tkwq1cwPumjsYmxyBh4/mqe0Rasxt2zNMXrdD4N6zPVATlw+dtgD+iyb+2OMIzZTTD ig== Received: from nam04-sn1-obe.outbound.protection.outlook.com (mail-sn1nam04lp2054.outbound.protection.outlook.com [104.47.44.54]) by mx0a-0014ca01.pphosted.com with ESMTP id 35p2m1be5u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Dec 2020 06:05:44 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=addzTBiTw23KBUBh5G6JB9fePQkpjhCIk9Nhq5zy0aX46c3q5/ZSxgfDRuDLlYbMVY7vBcwlxZpB8mnFiqNn0x7xo6DQ9L5ZqRCe8Nf/3nvzi7ozoS1EzotEMZkc8Ul22gE6+wLM1otNBcf1hlNoXuPGmCeWPg/bq6L1DNooaotyByVRRUzsEwF0CAn+YYnJJvLgi4RIiKGTyJB6tZakMnTAd6BmvP5Kn67JR/coHqa/RT52orX4TF3BUGDcWOZj3ujtFL5R6D7InytlDzHaYu77E4LKm6F40oxvoFlOSshbWbStq96oiFq6aniKqKcnwFyvujXW/VVAbYSFsl+jHA== 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-SenderADCheck; bh=z1GryEBqElrFTcJ32x+asL3miwc0Qe7PF6X9kDiz/KE=; b=ky9bohYmU9ddQ/K3+uTyKhh2gCtJVphlmQnXYf9Lfy7+XrJnHb/Vj6W2698DkjR6IaJWFaViivxf+YnshkY2xGTk66T5Ps3NWtP2rKuwSZDNeXgBUbchBNFLxBDFFb2W7qvZ47rI2nNi777VvQ/Dylt+l+J+BU9mmgul/hvh59Hl82R8LSoWwzInpj2FJnA/sNaMWVdE4PaTHqhiLbIPtSG9nC/B5iHHoxPzrrtNaxHmzT+bgpnQGL1gzChWCu0eXRgqA04/mevd+p/2ba06hwEm0udjg1VAwdxWsiaTjjEgCdnkCs/WL15TS7iMo2ClLPoymKJIetFj6YWg2Wt7rA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 158.140.1.147) smtp.rcpttodomain=google.com smtp.mailfrom=cadence.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=cadence.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z1GryEBqElrFTcJ32x+asL3miwc0Qe7PF6X9kDiz/KE=; b=wxD/IFOvxP3ABPm6wjcoZGNEOkIb8r1Iyfo3IqpZw10xZ6DNziPYroo+Otl/FOc6OlUgwZlOW1t7FcXb3FR80LBrryT6s2DXr42FLHflQ73Tuwg3Ho6zEJX8rxT5nLJ2oqZQ14m+Gh5PAmEypX2ihtHHjlr+nkjoDz807j9WjPk= Received: from MWHPR04CA0037.namprd04.prod.outlook.com (2603:10b6:300:ee::23) by BYAPR07MB4598.namprd07.prod.outlook.com (2603:10b6:a02:f2::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.30; Mon, 28 Dec 2020 14:05:41 +0000 Received: from MW2NAM12FT040.eop-nam12.prod.protection.outlook.com (2603:10b6:300:ee:cafe::ef) by MWHPR04CA0037.outlook.office365.com (2603:10b6:300:ee::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.27 via Frontend Transport; Mon, 28 Dec 2020 14:05:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 158.140.1.147) smtp.mailfrom=cadence.com; google.com; dkim=none (message not signed) header.d=none;google.com; dmarc=pass action=none header.from=cadence.com; Received-SPF: Pass (protection.outlook.com: domain of cadence.com designates 158.140.1.147 as permitted sender) receiver=protection.outlook.com; client-ip=158.140.1.147; helo=sjmaillnx1.cadence.com; Received: from sjmaillnx1.cadence.com (158.140.1.147) by MW2NAM12FT040.mail.protection.outlook.com (10.13.180.228) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.20 via Frontend Transport; Mon, 28 Dec 2020 14:05:40 +0000 Received: from maileu3.global.cadence.com (maileu3.cadence.com [10.160.88.99]) by sjmaillnx1.cadence.com (8.14.4/8.14.4) with ESMTP id 0BSE5biS023739 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Dec 2020 06:05:39 -0800 X-CrossPremisesHeadersFilteredBySendConnector: maileu3.global.cadence.com Received: from maileu3.global.cadence.com (10.160.88.99) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 28 Dec 2020 15:05:37 +0100 Received: from vleu-orange.cadence.com (10.160.88.83) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Mon, 28 Dec 2020 15:05:37 +0100 Received: from vleu-orange.cadence.com (localhost.localdomain [127.0.0.1]) by vleu-orange.cadence.com (8.14.4/8.14.4) with ESMTP id 0BSE5aDW014710; Mon, 28 Dec 2020 15:05:36 +0100 Received: (from nadeem@localhost) by vleu-orange.cadence.com (8.14.4/8.14.4/Submit) id 0BSE5adl014709; Mon, 28 Dec 2020 15:05:36 +0100 From: Nadeem Athani To: , , , , , , , , CC: , , , Subject: [PATCH v6 2/2] PCI: cadence: Retrain Link to work around Gen2 training defect. Date: Mon, 28 Dec 2020 15:05:10 +0100 Message-ID: <20201228140510.14641-3-nadeem@cadence.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20201228140510.14641-1-nadeem@cadence.com> References: <20201228140510.14641-1-nadeem@cadence.com> MIME-Version: 1.0 X-OrganizationHeadersPreserved: maileu3.global.cadence.com X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ed00e75e-0987-4606-b12a-08d8ab39a88f X-MS-TrafficTypeDiagnostic: BYAPR07MB4598: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2043; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dQ+Y/UyW8HBgEzVMhD81J3vj9vFPjkq+Ps9Vhp4yGrCVSe/PKkEyLJA5LGc6QR5cVWtQcL1QCPIj5w3cfd3cQNvuaRjD0SiAo1omxoCFZ+YNmYwD2uYJ/v2eD2kElsqodYZmZRStaClmn95p+U7HqOSxFsIU00Dcc83I1dXfOfcOWeJal8wzvdZcotNvy0eFGe9B/Pn/jsSqylWItNZdP+vclw8McSvl0q+w6hbVbs0E+UZhV7EdCGm53Fneih5EX9rxtA94vlWel7uLu+dPZGPAJfbWjrpcdnjHw173k4Ff0Xyz+Vx5vLFFyGCnnb8NHTne8ENvZm7Nhv+A0Fg0IxupD6V+sVBzKtxdJwAW9oMcVQJZpVojXKuSdKUhef8FFTRgcfIWOmZZjp10ixjkwHJvSlufDzKjHwPcfG6423/iqoFM54OSvDU213TD7+/gX7pzDigFq5dhNGxvvFWzIjD4zhyWgkMET1G1+SQGoLgmtSPkzl09F/pnrLzO7n+XNzdnRV/KxTXG9CvIBv1MjQ== X-Forefront-Antispam-Report: CIP:158.140.1.147;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:sjmaillnx1.cadence.com;PTR:unknown.Cadence.COM;CAT:NONE;SFS:(4636009)(346002)(396003)(136003)(376002)(39860400002)(36092001)(46966006)(7636003)(83380400001)(36756003)(6666004)(1076003)(356005)(36906005)(107886003)(186003)(478600001)(4326008)(82310400003)(70586007)(426003)(336012)(2906002)(8936002)(316002)(110136005)(8676002)(47076005)(54906003)(5660300002)(70206006)(86362001)(42186006)(2616005)(26005)(82740400003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2020 14:05:40.1850 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ed00e75e-0987-4606-b12a-08d8ab39a88f X-MS-Exchange-CrossTenant-Id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d36035c5-6ce6-4662-a3dc-e762e61ae4c9;Ip=[158.140.1.147];Helo=[sjmaillnx1.cadence.com] X-MS-Exchange-CrossTenant-AuthSource: MW2NAM12FT040.eop-nam12.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR07MB4598 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-28_11:2020-12-28,2020-12-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 malwarescore=0 spamscore=0 adultscore=0 clxscore=1015 mlxlogscore=999 mlxscore=0 phishscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012280088 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Cadence controller will not initiate autonomous speed change if strapped as Gen2. The Retrain Link bit is set as quirk to enable this speed change. Signed-off-by: Nadeem Athani --- drivers/pci/controller/cadence/pci-j721e.c | 3 ++ drivers/pci/controller/cadence/pcie-cadence-host.c | 32 ++++++++++++++++++++++ drivers/pci/controller/cadence/pcie-cadence.h | 11 +++++++- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c index dac1ac8a7615..23a30be207a5 100644 --- a/drivers/pci/controller/cadence/pci-j721e.c +++ b/drivers/pci/controller/cadence/pci-j721e.c @@ -64,6 +64,7 @@ enum j721e_pcie_mode { struct j721e_pcie_data { enum j721e_pcie_mode mode; + bool quirk_retrain_flag; }; static inline u32 j721e_pcie_user_readl(struct j721e_pcie *pcie, u32 offset) @@ -280,6 +281,7 @@ static struct pci_ops cdns_ti_pcie_host_ops = { static const struct j721e_pcie_data j721e_pcie_rc_data = { .mode = PCI_MODE_RC, + .quirk_retrain_flag = true, }; static const struct j721e_pcie_data j721e_pcie_ep_data = { @@ -388,6 +390,7 @@ static int j721e_pcie_probe(struct platform_device *pdev) bridge->ops = &cdns_ti_pcie_host_ops; rc = pci_host_bridge_priv(bridge); + rc->quirk_retrain_flag = data->quirk_retrain_flag; cdns_pcie = &rc->pcie; cdns_pcie->dev = dev; diff --git a/drivers/pci/controller/cadence/pcie-cadence-host.c b/drivers/pci/controller/cadence/pcie-cadence-host.c index 9f7aa718c8d4..9d730c10083b 100644 --- a/drivers/pci/controller/cadence/pcie-cadence-host.c +++ b/drivers/pci/controller/cadence/pcie-cadence-host.c @@ -94,6 +94,34 @@ static int cdns_pcie_host_wait_for_link(struct cdns_pcie *pcie) return -ETIMEDOUT; } +static void cdns_pcie_retrain(struct cdns_pcie *pcie) +{ + u32 lnk_cap_sls, pcie_cap_off = CDNS_PCIE_RP_CAP_OFFSET; + u16 lnk_stat, lnk_ctl; + + /* + * Set retrain bit if current speed is 2.5 GB/s, + * but the PCIe root port support is > 2.5 GB/s. + */ + + lnk_cap_sls = cdns_pcie_readl(pcie, (CDNS_PCIE_RP_BASE + pcie_cap_off + + PCI_EXP_LNKCAP)); + if ((lnk_cap_sls & PCI_EXP_LNKCAP_SLS) <= PCI_EXP_LNKCAP_SLS_2_5GB) + return; + + lnk_stat = cdns_pcie_rp_readw(pcie, pcie_cap_off + PCI_EXP_LNKSTA); + if ((lnk_stat & PCI_EXP_LNKSTA_CLS) == PCI_EXP_LNKSTA_CLS_2_5GB) { + lnk_ctl = cdns_pcie_rp_readw(pcie, + pcie_cap_off + PCI_EXP_LNKCTL); + lnk_ctl |= PCI_EXP_LNKCTL_RL; + cdns_pcie_rp_writew(pcie, pcie_cap_off + PCI_EXP_LNKCTL, + lnk_ctl); + + if (cdns_pcie_host_wait_for_link(pcie)) + return; + } +} + static int cdns_pcie_host_init_root_port(struct cdns_pcie_rc *rc) { struct cdns_pcie *pcie = &rc->pcie; @@ -459,6 +487,10 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) ret = cdns_pcie_host_wait_for_link(pcie); if (ret) dev_dbg(dev, "PCIe link never came up\n"); + else { + if (rc->quirk_retrain_flag) + cdns_pcie_retrain(pcie); + } for (bar = RP_BAR0; bar <= RP_NO_BAR; bar++) rc->avail_ib_bar[bar] = true; diff --git a/drivers/pci/controller/cadence/pcie-cadence.h b/drivers/pci/controller/cadence/pcie-cadence.h index 30eba6cafe2c..0f29128a5d0a 100644 --- a/drivers/pci/controller/cadence/pcie-cadence.h +++ b/drivers/pci/controller/cadence/pcie-cadence.h @@ -119,7 +119,7 @@ * Root Port Registers (PCI configuration space for the root port function) */ #define CDNS_PCIE_RP_BASE 0x00200000 - +#define CDNS_PCIE_RP_CAP_OFFSET 0xc0 /* * Address Translation Registers @@ -291,6 +291,7 @@ struct cdns_pcie { * @device_id: PCI device ID * @avail_ib_bar: Satus of RP_BAR0, RP_BAR1 and RP_NO_BAR if it's free or * available + * @quirk_retrain_flag: Retrain link as quirk for PCIe Gen2 */ struct cdns_pcie_rc { struct cdns_pcie pcie; @@ -299,6 +300,7 @@ struct cdns_pcie_rc { u32 vendor_id; u32 device_id; bool avail_ib_bar[CDNS_PCIE_RP_MAX_IB]; + bool quirk_retrain_flag; }; /** @@ -414,6 +416,13 @@ static inline void cdns_pcie_rp_writew(struct cdns_pcie *pcie, cdns_pcie_write_sz(addr, 0x2, value); } +static inline u16 cdns_pcie_rp_readw(struct cdns_pcie *pcie, u32 reg) +{ + void __iomem *addr = pcie->reg_base + CDNS_PCIE_RP_BASE + reg; + + return cdns_pcie_read_sz(addr, 0x2); +} + /* Endpoint Function register access */ static inline void cdns_pcie_ep_fn_writeb(struct cdns_pcie *pcie, u8 fn, u32 reg, u8 value)