From patchwork Tue Feb 9 14:46:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Athani Nadeem Ladkhan X-Patchwork-Id: 12078363 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,URIBL_BLOCKED, 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 3D39BC433E0 for ; Tue, 9 Feb 2021 14:48:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 15A0A64E30 for ; Tue, 9 Feb 2021 14:48:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232060AbhBIOsu (ORCPT ); Tue, 9 Feb 2021 09:48:50 -0500 Received: from mx0b-0014ca01.pphosted.com ([208.86.201.193]:33584 "EHLO mx0a-0014ca01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232274AbhBIOst (ORCPT ); Tue, 9 Feb 2021 09:48:49 -0500 Received: from pps.filterd (m0042333.ppops.net [127.0.0.1]) by mx0b-0014ca01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 119EibSH020875; Tue, 9 Feb 2021 06:46:38 -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=dXYSEl0G00OdyADOwSkjnpNiSLWKVIbFkN7qbFkMRB0=; b=T3nJhvI5vZMA8kH12kD1rsbaT8xaHJl+458itQxsuwpselGsbaqiQgtcItsy4TcNz0v5 W+L+YUTgofhZ4tG0mLzVMA21PBcW/+KbzHQvN/2623oTTzwmfGcMz9qO2CYnd60/QXkg 7Dr1cVn602dd0FB4HhKjx30mIbxD22mdHU8bp4OK9sJjiV7g15nb5KllIT2SA97ayQXY rhgjbY82dCpyYlKQ9O6SQ3xji0kmmHeiv5Gqd0HnQYq5VIY1D9R60hoOIgH6HCwVCKKz BgMnlIs3aSQZ68bhURnz6wDJE348ISxsNAEB9ZBmiqhFk/TpLcGVzN+c7ITizk5nZFcW YA== Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by mx0b-0014ca01.pphosted.com with ESMTP id 36hrcw8sh9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Feb 2021 06:46:38 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UpbXW85zIYl/47bL4b6ieq7vQLMieJ5joeDW2sXiozyb8XKIaMiee/PbVmFkIwzJqaBgCW3I1x4wUlqeXqyZJN25spFOa96L+Dujo6orBhs6y0XgmJmEUfy8NX+HKBX3eHmC4pT6H2J1dq82pRrWA3bFpIUCpv3dKxiJz7l7jPzqJj0/lRWBZJ9HYKm1MXiyso2eMpqu5IlBCuxCmwwhWnASz0vRPe42O7YPVvr5loWw1fAy/K9gV9YoMMFHQyvRUyYTolixiNd5nJVnYnKnSeUQY80p+/JrJ9q/6wU0KblB7879uqwdqTEppz1tCWv1/w7/yihTT277oyQ1V2FibQ== 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=dXYSEl0G00OdyADOwSkjnpNiSLWKVIbFkN7qbFkMRB0=; b=B74g83PFjyZOj3OQsdVB0iBR5fNz9ECd+z8IuEaiCT9y6hzlsBuSM+hGS6XFYvauBvDYQBh2H/garg+z5WUMVZEuql2iks4thAeLSOZBiSKaFsFj/SSmmkqfVjT3DPJfqhilPUUxi8WYWp+SZ/K+/YL90BEK42KZzovNDhwWDDm2eo7bTpeWuI3e9cQMyPzlgqnwQ0JjWiV4a1etQBJaDnJuscyog4/6BXTgJN4BrKE4da7hGCHudl5jm9EUiDFw4SRXnE97y7eV4k4BUzYg8Akcq5vyDkUyrOTbVzGQxh/u7ghQ2g8y1Epb9AW9KMPkFWCPKgTBhDiLoqrvZjtfcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 64.207.220.244) 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=dXYSEl0G00OdyADOwSkjnpNiSLWKVIbFkN7qbFkMRB0=; b=Z2P0/KTPo0fIxg1c2OjxnxuqGqsC/Tzto6ied3XlZFmOjpYctiWB8nCOm4ayV0ay+SxoJkVSWENFbEf2Sh4aaaYe0OsrLS4J7boYhQXCdmDK3c9WqAQT0DLyHIR/tY3UTU0EEIAcOA4Sh9DRjztaufKnPKA4HQZeosZtAX2mB5U= Received: from BN9PR03CA0834.namprd03.prod.outlook.com (2603:10b6:408:13e::29) by BN6PR07MB2753.namprd07.prod.outlook.com (2603:10b6:404:40::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.20; Tue, 9 Feb 2021 14:46:34 +0000 Received: from BN8NAM12FT046.eop-nam12.prod.protection.outlook.com (2603:10b6:408:13e:cafe::8e) by BN9PR03CA0834.outlook.office365.com (2603:10b6:408:13e::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.20 via Frontend Transport; Tue, 9 Feb 2021 14:46:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 64.207.220.244) 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 64.207.220.244 as permitted sender) receiver=protection.outlook.com; client-ip=64.207.220.244; helo=wcmailrelayl01.cadence.com; Received: from wcmailrelayl01.cadence.com (64.207.220.244) by BN8NAM12FT046.mail.protection.outlook.com (10.13.183.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Tue, 9 Feb 2021 14:46:32 +0000 Received: from maileu3.global.cadence.com (maileu3.cadence.com [10.160.88.99]) by wcmailrelayl01.cadence.com (8.14.7/8.14.4) with ESMTP id 119EkRwG001420 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=OK); Tue, 9 Feb 2021 06:46:31 -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; Tue, 9 Feb 2021 15:46:27 +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; Tue, 9 Feb 2021 15:46:27 +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 119EkR5x026758; Tue, 9 Feb 2021 15:46:27 +0100 Received: (from nadeem@localhost) by vleu-orange.cadence.com (8.14.4/8.14.4/Submit) id 119EkR0c026757; Tue, 9 Feb 2021 15:46:27 +0100 From: Nadeem Athani To: , , , , , , CC: , , , Subject: [PATCH v8 1/2] PCI: cadence: Shifting of a function to support new code. Date: Tue, 9 Feb 2021 15:46:21 +0100 Message-ID: <20210209144622.26683-2-nadeem@cadence.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20210209144622.26683-1-nadeem@cadence.com> References: <20210209144622.26683-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: 3cd15bdb-9449-4edf-7d22-08d8cd097ddd X-MS-TrafficTypeDiagnostic: BN6PR07MB2753: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z7X5ziLKl5I/djQox6Zcw7NWAFXTsZ+ruB3oWK8qPbnM08ctCCnymAVgAJUUqj62oRK6c9oalHOiV2/9tTzbpaexXFYt44JsNxLG6UD42rQx3lQiW7QJeVeCuMnlmLocQrABYjlaQkvRwJyEcT71PnEedbbTtUEs9ExUgNTEzYFfKh/Xsyumsl9ljqgPNAqyvB1Ac8110h+jKqFW8qr5rIKtj8F0PIdpFIqWtU0W/bNK1R1i+5nL4Clu/oOGUa8H+Q7C1wCM4mjIgxY2QIqcoHMjbqIBuwa7T5Pyn+p0/FwexqMYXQ3S/KrM8pHgPsuMr32oxd3e0CSjHHrKLRt3ak6EaYidD3gd+5aoQxdGQO2QvjneIkHar1CvTOkvamRA0x9LOQIFG8dSWoNfkPHRbf6MoIvXO9ZjyL4P9tgCzM1bX+d9mUhDtlqAx0CwxNDXk8rXSFhLpY1goJan7fpeqaPNoJzY0x9pn/PFskUvETh0oEhGPtMQdzHrncfvyU/Iatv4ffhGMYocyyt+rSAPqNNDJixstmntiZwTfRLZir5bY8gb2QBzJmYYN0+4iR9AoQMc/Pso51MK1+E807T2FaE9SZEArXbPEO0sdhEqHhl4Fssgo+AULuG59bQ86BVkRbXmNAdRe+SocHgRsPu/kgdx+Bxizn7oLrJGAqTajlFaAl9IEL07HIIji4kQh+d0aWUo9Q5g3zlMNAuR93jCZlLC8YQOroB5qnh2g7OYvODBTMhnvH+XIGXCOP+DQekB X-Forefront-Antispam-Report: CIP:64.207.220.244;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:wcmailrelayl01.cadence.com;PTR:ErrorRetry;CAT:NONE;SFS:(4636009)(136003)(346002)(396003)(39860400002)(376002)(36092001)(46966006)(36840700001)(4326008)(70206006)(70586007)(8936002)(107886003)(54906003)(86362001)(2906002)(316002)(42186006)(34020700004)(36906005)(356005)(426003)(82310400003)(2616005)(47076005)(82740400003)(110136005)(8676002)(336012)(186003)(81166007)(6666004)(1076003)(36860700001)(5660300002)(478600001)(26005)(36756003)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2021 14:46:32.1533 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3cd15bdb-9449-4edf-7d22-08d8cd097ddd X-MS-Exchange-CrossTenant-Id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d36035c5-6ce6-4662-a3dc-e762e61ae4c9;Ip=[64.207.220.244];Helo=[wcmailrelayl01.cadence.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM12FT046.eop-nam12.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB2753 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.737 definitions=2021-02-09_03:2021-02-09,2021-02-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 lowpriorityscore=0 mlxscore=0 bulkscore=0 suspectscore=0 phishscore=0 impostorscore=0 adultscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102090077 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Moving the function cdns_pcie_host_wait_for_link() further up in the file, as it's going to be used by upcoming additional code in the driver. 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 Tue Feb 9 14:46:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Athani Nadeem Ladkhan X-Patchwork-Id: 12078359 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,URIBL_BLOCKED, 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 ED23DC43381 for ; Tue, 9 Feb 2021 14:48:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B379F64E30 for ; Tue, 9 Feb 2021 14:48:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232249AbhBIOr4 (ORCPT ); Tue, 9 Feb 2021 09:47:56 -0500 Received: from mx0a-0014ca01.pphosted.com ([208.84.65.235]:37370 "EHLO mx0a-0014ca01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232250AbhBIOro (ORCPT ); Tue, 9 Feb 2021 09:47:44 -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 119Ebot5014140; Tue, 9 Feb 2021 06:46:37 -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=zWrVEGuowaumsucHSvd+LQ+8x8BQqc6fHTRt9z1+hu4=; b=gSpuapw6gAq4fgph68/K6tR9LlulcP5HkyWat451qSBfm8L6zgITLyPUMSeom47h/zU1 +CBgWqWow0Md3J6soN2RoyzhnSdm7usTW6d07A2zdq+mmmm0otrsTooZDL6Qo8F2V2Tc TV1YQ9FlIFHAm1DV4hffwlO5dYEoVzTN+xY0233f24Pt6ZMlCXzH0RjVSyZ2AjzYS3Bo +51wWmAmq/YGfCqm/SYQmuWXNjomMyYStoij9WqAsutsCL8us3BJ5Jmw4m7KknQvyCN3 zDa9wZ/ehdlL29IOI85J6kM4ne3wqds+0XK1/n3kYwpCVLRjp+x07/xA2e4qxcLtOiyV og== Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2108.outbound.protection.outlook.com [104.47.55.108]) by mx0a-0014ca01.pphosted.com with ESMTP id 36hrku0ng8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Feb 2021 06:46:37 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QuDdmWCCg/qZ9jO0fwMdpTtM+TZYqKdVdEW6Eb98S/A3hfXb+ImHRowyD8J+Y/PB0JUQD4+k87/4n2t/59CXCNuhv2x5RjEoo6r2/jL0LYHHREFbBxtqXY38nC+TrtDnNgQNBqGjZjxEVswrmGOHTC46gx1B1fC1+RPv1E5l/wEIFUxVbWbFo+Sq+j+AMO7rJAucC+mUfKSe32cBksK/d3grwqtgBrNWWIJhBtKHrKqwtKtWPEbYTmQd26xvyEJZ1wOSnPyV1YWKWejU5XLXgPboG7jleWJ0mLfERvjnDJlYSM+MoT0HrwJSiydMskAfWXtZe7iM6lGM48Iw+d0/PQ== 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=zWrVEGuowaumsucHSvd+LQ+8x8BQqc6fHTRt9z1+hu4=; b=H63/uxl9FCHRyb2+AwZMSgFOTf3vad75mULOhH1x6JkVjyhTsmcaa8EYGTfz97bCqcR0R2Q3VFXwOHkyCtG5StFPuIlCLciAD9INFTBa6z1Yg6Jn3ysXpO0kUfjg3zbeR7zhOs98TTMudmiJbcLkMZIATewnqFltoFDKNU11Nx4jCP36M/CmmeRQNEDgCYisPgkLMlhO8kzlo7Lu20/mEsOPpa2QfOldtmNYN/IiAcnEBdaURpEoEHdK9GZF1d1XPV00LbcHD5MilwUjJoFptelPpEca0LzcSwwBQ2Ce/EYV+Xx7EcsTX8+Ji+6FzRlOxUMc2GmgS/n0aYDUqzGwNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 64.207.220.244) 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=zWrVEGuowaumsucHSvd+LQ+8x8BQqc6fHTRt9z1+hu4=; b=iYFw/VzAH71IT7liel9T8KFm/uGylGRehl7y4WzJKawQpGk8Q/iqa7S1z57BRsN7PQzAJQ+IUCsSILNSwCWI+hIvWEtqL1qebuevl+4DygDb8oN01iovvwQj7F/AfBJtk8X3HLrt8i2+qitADZqSwXqtoVvDALIaAm4DZvxlXD4= Received: from BN6PR16CA0025.namprd16.prod.outlook.com (2603:10b6:405:14::11) by SN6PR07MB7936.namprd07.prod.outlook.com (2603:10b6:805:ec::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.20; Tue, 9 Feb 2021 14:46:34 +0000 Received: from BN8NAM12FT004.eop-nam12.prod.protection.outlook.com (2603:10b6:405:14:cafe::21) by BN6PR16CA0025.outlook.office365.com (2603:10b6:405:14::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.26 via Frontend Transport; Tue, 9 Feb 2021 14:46:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 64.207.220.244) 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 64.207.220.244 as permitted sender) receiver=protection.outlook.com; client-ip=64.207.220.244; helo=wcmailrelayl01.cadence.com; Received: from wcmailrelayl01.cadence.com (64.207.220.244) by BN8NAM12FT004.mail.protection.outlook.com (10.13.183.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Tue, 9 Feb 2021 14:46:32 +0000 Received: from maileu3.global.cadence.com (maileu3.cadence.com [10.160.88.99]) by wcmailrelayl01.cadence.com (8.14.7/8.14.4) with ESMTP id 119EkRwH001420 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=OK); Tue, 9 Feb 2021 06:46:31 -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; Tue, 9 Feb 2021 15:46:28 +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; Tue, 9 Feb 2021 15:46:28 +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 119EkSd9026767; Tue, 9 Feb 2021 15:46:28 +0100 Received: (from nadeem@localhost) by vleu-orange.cadence.com (8.14.4/8.14.4/Submit) id 119EkSAg026766; Tue, 9 Feb 2021 15:46:28 +0100 From: Nadeem Athani To: , , , , , , CC: , , , Subject: [PATCH v8 2/2] PCI: cadence: Retrain Link to work around Gen2 training defect. Date: Tue, 9 Feb 2021 15:46:22 +0100 Message-ID: <20210209144622.26683-3-nadeem@cadence.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20210209144622.26683-1-nadeem@cadence.com> References: <20210209144622.26683-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: 618b385a-d044-4a92-a1fd-08d8cd097e38 X-MS-TrafficTypeDiagnostic: SN6PR07MB7936: 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: BWk+gpNNt0oHC+SDqTnULp9endJzsH9Z7/dQYXkgz8sFiZReMbFJkC2+oFhSRBrxxFmx1w/ST6RrQ4xe5sMcLKpRqsr7x3YxSkLwiDzCZztZ2dcH8SkirWe6F0b8V1bzK3yzG7kyRn8cK+mPx+Y+1/+966Taz6EiyzqykeNaHRqP4WDyJMXmPvvyF6HP+jjhSRWResFrzBhMkBMvJ2IzmuT2rNCb6hoOlEuqxzvxaAWxIZIrjApFBkP7IvNcOXfeNtLWdPVKbFtmeDEAeKgPTqdBPfaRKj5C58l2XuRuF5DvCfW+HOiiZZreIAVDHDEZBHrQ4hYpoVfzModnRtx5PhPIW2rAKRhgJ54bkkA3TmCfgn4XzG6umQ7jz1o7g7+Gxp3TgKg2yQXcBRMi0WpvMRYB4ZO0AMsE6E7IEHT17JK126nyrMASBCh7c8txGEG7e/2UrBiFpcFh/OD+Tfdia1WLQq0CaFienG4cW35snrbTXciYjDV54L7PqgevpXCNeI9hZceDM7Lm9ka4yPcmB/q6Sk7TtpLll2nvbtazY5AijRD4l8QvibEvo6jzzHEBqCO/vVVidoCK+1VjMsetO9kHSeVGBpkakTk97/85SLUaEqMZobpCC+zcbSw6SmGDMx9vwSuVt8dW/8iyf5GfyofyqglR6Gg3hUFNdNUdtKb5pr0LZ8tM6iwXxEm1pKpnaiwUOp349uZ25gP2yR5qm22pruS2KdXAIEfSE2Xnq316nd+VgPm5XWlWKwzXjAS+ X-Forefront-Antispam-Report: CIP:64.207.220.244;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:wcmailrelayl01.cadence.com;PTR:ErrorRetry;CAT:NONE;SFS:(4636009)(376002)(39860400002)(346002)(136003)(396003)(36092001)(36840700001)(46966006)(83380400001)(26005)(42186006)(107886003)(6666004)(82310400003)(2906002)(336012)(186003)(1076003)(81166007)(82740400003)(426003)(478600001)(2616005)(4326008)(34020700004)(8676002)(54906003)(36906005)(70586007)(86362001)(356005)(47076005)(36756003)(36860700001)(316002)(8936002)(5660300002)(110136005)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2021 14:46:32.7506 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 618b385a-d044-4a92-a1fd-08d8cd097e38 X-MS-Exchange-CrossTenant-Id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d36035c5-6ce6-4662-a3dc-e762e61ae4c9;Ip=[64.207.220.244];Helo=[wcmailrelayl01.cadence.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM12FT004.eop-nam12.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR07MB7936 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.737 definitions=2021-02-09_03:2021-02-09,2021-02-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 phishscore=0 adultscore=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 suspectscore=0 priorityscore=1501 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102090076 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 | 48 +++++++++++++++++++++- drivers/pci/controller/cadence/pcie-cadence.h | 11 ++++- 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c index dac1ac8a7615..849f1e416ea5 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..6f591d382578 100644 --- a/drivers/pci/controller/cadence/pcie-cadence-host.c +++ b/drivers/pci/controller/cadence/pcie-cadence-host.c @@ -94,6 +94,52 @@ static int cdns_pcie_host_wait_for_link(struct cdns_pcie *pcie) return -ETIMEDOUT; } +static int cdns_pcie_retrain(struct cdns_pcie *pcie) +{ + u32 lnk_cap_sls, pcie_cap_off = CDNS_PCIE_RP_CAP_OFFSET; + u16 lnk_stat, lnk_ctl; + int ret = 0; + + /* + * 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 ret; + + 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); + + ret = cdns_pcie_host_wait_for_link(pcie); + } + return ret; +} + +static int cdns_pcie_host_start_link(struct cdns_pcie_rc *rc) +{ + struct cdns_pcie *pcie = &rc->pcie; + int ret; + + ret = cdns_pcie_host_wait_for_link(pcie); + + /* + * Retrain link for Gen2 training defect + * if quirk flag is set. + */ + if (!ret && rc->quirk_retrain_flag) + ret = cdns_pcie_retrain(pcie); + + return ret; +} + static int cdns_pcie_host_init_root_port(struct cdns_pcie_rc *rc) { struct cdns_pcie *pcie = &rc->pcie; @@ -456,7 +502,7 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) return ret; } - ret = cdns_pcie_host_wait_for_link(pcie); + ret = cdns_pcie_host_start_link(rc); if (ret) dev_dbg(dev, "PCIe link never came up\n"); diff --git a/drivers/pci/controller/cadence/pcie-cadence.h b/drivers/pci/controller/cadence/pcie-cadence.h index 30eba6cafe2c..254d2570f8c9 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)