Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp2063915lqp; Tue, 16 Apr 2024 06:32:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWR06zP5f2gYAk7BTdJJdChPWSSQEaX5ndFHkD6wnXSxyu1IrFc2XiX3SowVgvBzRtXHJY0ORMHORWfP8pUJejD/HV3HvsEcp1MU4HLCw== X-Google-Smtp-Source: AGHT+IHl7326MPz6nMAUO5fNu3yQN/LlUjpiGRcE57OvcNuV5OLwpxXWscrpC/iH3kasWV3KsHJT X-Received: by 2002:a50:8e59:0:b0:56e:230b:853c with SMTP id 25-20020a508e59000000b0056e230b853cmr8165107edx.15.1713274323495; Tue, 16 Apr 2024 06:32:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713274323; cv=pass; d=google.com; s=arc-20160816; b=fEKRTVndCyJWsA3f5MrfLEPHbDrbg7Tpv71j8OLwMV08PFF51XeMJsUJ2HdZ2XxUnE rACL/lMaPQ2570IsxY/mobt8r3EOI7RXY3QDh+TeW8VFkSTiphs2EvDvrC66UlTaxmeT IydJ7IBgr8giPrB+AppBbql4H4tpikz2XETPZj33uwoN9btudA3eaScmVGQGwnQciCuf 5FPszLd4i5uCLw6Mw5/RjVMIVWrO7qcEX/rjjvf7xShw8zL8B95loNtZC0gI9+fW6iXo MlHKT23zNaEcDT6V1hdygPfI3nEdMRMb3achapE0G51o9xvgHazZUDF5mWQRsjQ/gHT/ WTrg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=miPb/e5NuKGB8qP7OIDdVZ0YjYkj1W+eBv5Jcf20cUo=; fh=+6o6d2KGt2ZTSidIuE8uz1q8yt3pK0TjTqozrmclSIs=; b=EGpooJuT67YwGqfAJK7I2rsRPCxlME/DesUZUgzv+6P9cKTfRbGTdQXk0MwTIIbkFB ob/s+AidC9b3ZRaO01yuehytY3jtBz5NOkg2HmeK88Zj1n7UlczgFZlOtHJVYo3HTXMp uND+Fp/cfZ9WKoEPeRWzbY+b8BowtzcqgK2X3gwbJBbRp6xqXzyd4ENNw51uw94DN9ac 2iX/59jpYzF0TGY5IaAXS2neP5FEeHP+O8dHGWNdpN+aKL8ahkykBx2jxXNnnCHzAfHI 40ILrbIEfrgu2paPQVesivr+6k6ftz6DdhlZ/3HExwC3EHMf1gG63MnP4zBOqi1XfOO0 BgjA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=muvG93MX; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-146884-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146884-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g13-20020a0564021ecd00b0056e1f5e3a15si5754806edg.183.2024.04.16.06.32.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 06:32:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146884-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=muvG93MX; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-146884-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146884-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 35A461F21486 for ; Tue, 16 Apr 2024 13:32:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 223F912F590; Tue, 16 Apr 2024 13:30:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="muvG93MX" Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97B4012D1E0; Tue, 16 Apr 2024 13:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713274223; cv=none; b=tW0XXf/DRkYuvwuioVWvKYWblCSGc/G4v+BkWGZwSA248nkc2tzZokG4+LD28MKxV7oGt9ClhtUamKqjBuDyXWrrUlMIrS/G2h0by62y0r7BAvDV7jBxxn71qS1Ywrs9L/Xm2EhF72dy35LMY4Zj97Kkt9GYVJn28YbZkh2rw8w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713274223; c=relaxed/simple; bh=jCHXzfxyA3cVRfcENK9qyg8NQxzPtrBSSYd3Ot8KwRo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fSjdxb2uG9dAsAs9xVGs4EXNymbzR9q2DjwlZHEPEEmqlnu792SIylVbENOPistNMUQnD/FNsWKkhTIIF0GlJEaOKKBZgFRYnDdo4PycJvLBS3yyNFc/wqnql+akomtSR3s6i1awuGGC3xrmHXs6Yk+ksjBW8lqSzfop4RBFSNQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=muvG93MX; arc=none smtp.client-ip=217.70.183.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 70D3740010; Tue, 16 Apr 2024 13:30:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713274218; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=miPb/e5NuKGB8qP7OIDdVZ0YjYkj1W+eBv5Jcf20cUo=; b=muvG93MXchdP5F7jPyPed9u75C1w/FOQ2FBCnZY7hO9a5kA/sfhPiU04mhOQXplIqojLTN 7SMAMRFS4ar5yR5TpJXG+gx5iVz/CEFJuvgJjGDU/FV+hPj8my4m4ywEADPJkN5soG6RPo /EwwjzoN86WziiSJD5rTw9OaHSXn5TrcD0krPZCP3AFP9VpBV+dv8krx9kDHoTHHOzI2OO sCP2FTGTakn+sPLwgfypG4pJEry4qKcO5d7C3m13OAihxmJrddx0MyujwddPCha8wD929K jNItLEWqpH+WYbxVHYZGz6e6mH/oNLvuextThyutnRaK0xgaYMAhkLQWKpLA9A== From: Thomas Richard Date: Tue, 16 Apr 2024 15:29:54 +0200 Subject: [PATCH v5 05/11] PCI: cadence: Extract link setup sequence from cdns_pcie_host_setup() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240102-j7200-pcie-s2r-v5-5-4b8c46711ded@bootlin.com> References: <20240102-j7200-pcie-s2r-v5-0-4b8c46711ded@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v5-0-4b8c46711ded@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Tony Lindgren , Aaro Koskinen , Janusz Krzysztofik , Vignesh R , Andi Shyti , Peter Rosin , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Siddharth Vadapalli Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com The function cdns_pcie_host_setup() mixes probe structure and link setup. The link setup must be done during the resume sequence. So extract it from cdns_pcie_host_setup() and create a dedicated function. Reviewed-by: Siddharth Vadapalli Signed-off-by: Thomas Richard --- drivers/pci/controller/cadence/pcie-cadence-host.c | 39 ++++++++++++++-------- drivers/pci/controller/cadence/pcie-cadence.h | 6 ++++ 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/drivers/pci/controller/cadence/pcie-cadence-host.c b/drivers/pci/controller/cadence/pcie-cadence-host.c index 5b14f7ee3c79..93d9922730af 100644 --- a/drivers/pci/controller/cadence/pcie-cadence-host.c +++ b/drivers/pci/controller/cadence/pcie-cadence-host.c @@ -497,6 +497,30 @@ static int cdns_pcie_host_init(struct device *dev, return cdns_pcie_host_init_address_translation(rc); } +int cdns_pcie_host_link_setup(struct cdns_pcie_rc *rc) +{ + struct cdns_pcie *pcie = &rc->pcie; + struct device *dev = rc->pcie.dev; + int ret; + + if (rc->quirk_detect_quiet_flag) + cdns_pcie_detect_quiet_min_delay_set(&rc->pcie); + + cdns_pcie_host_enable_ptm_response(pcie); + + ret = cdns_pcie_start_link(pcie); + if (ret) { + dev_err(dev, "Failed to start link\n"); + return ret; + } + + ret = cdns_pcie_host_start_link(rc); + if (ret) + dev_dbg(dev, "PCIe link never came up\n"); + + return 0; +} + int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) { struct device *dev = rc->pcie.dev; @@ -533,20 +557,9 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) return PTR_ERR(rc->cfg_base); rc->cfg_res = res; - if (rc->quirk_detect_quiet_flag) - cdns_pcie_detect_quiet_min_delay_set(&rc->pcie); - - cdns_pcie_host_enable_ptm_response(pcie); - - ret = cdns_pcie_start_link(pcie); - if (ret) { - dev_err(dev, "Failed to start link\n"); - return ret; - } - - ret = cdns_pcie_host_start_link(rc); + ret = cdns_pcie_host_link_setup(rc); if (ret) - dev_dbg(dev, "PCIe link never came up\n"); + return ret; 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 7a66a2f815dc..1d37d5f9f811 100644 --- a/drivers/pci/controller/cadence/pcie-cadence.h +++ b/drivers/pci/controller/cadence/pcie-cadence.h @@ -521,10 +521,16 @@ static inline bool cdns_pcie_link_up(struct cdns_pcie *pcie) } #ifdef CONFIG_PCIE_CADENCE_HOST +int cdns_pcie_host_link_setup(struct cdns_pcie_rc *rc); int cdns_pcie_host_setup(struct cdns_pcie_rc *rc); void __iomem *cdns_pci_map_bus(struct pci_bus *bus, unsigned int devfn, int where); #else +static inline int cdns_pcie_host_link_setup(struct cdns_pcie_rc *rc) +{ + return 0; +} + static inline int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) { return 0; -- 2.39.2