Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1920067lqg; Mon, 4 Mar 2024 07:41:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV4/Qh0p+zhhMZC9lqSByEYC4DkiddNc+/bhhtqrQI2F4CqnOsXmYZNEGWZ3qoXOV1xDVm4gOz7aIZwtKTVkRqsZOtkP0ciX3gOJ8yC1g== X-Google-Smtp-Source: AGHT+IHbWlChJ7eI3hFeT7CNBUh+Wrvu0SVHZ9bwunJyv3c+Fl4ggF1m12iTOHmCNjRlkXSoIKza X-Received: by 2002:a0c:e48c:0:b0:690:667b:f4f3 with SMTP id n12-20020a0ce48c000000b00690667bf4f3mr6892276qvl.17.1709566860440; Mon, 04 Mar 2024 07:41:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566860; cv=pass; d=google.com; s=arc-20160816; b=FRfjBOG4kerbN3nACshqLNNRJL49vT0VVUWq3c5+p470pQihzVZs/nSc4RzzG/YQWz Hg/4rzQkEv2zxLSzh2kb4wBZnPL0ddk0PJF+oMZu//xu5Iza/xQeX2fdMQFRnuJNcLF7 cEJAeDR6zxLUCqYQfIv2w/nZv84cgLGp77DJuNOIzduKKhVSPibFqSdDItf0OktH0IBK gBgMW0ueI0PtPeoAkaGNeQGhTPQ22Am2GxjTlVDNxDNGDrDcvGW/iRruEMPYXdDtV5mp sYBTj22/1JT5I8e+D58ojOQREtpJ944qKaovOLnn8YXKCqGCUb+pTZIuXtcb38xOqEs7 3bxQ== 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=DaC56o2wBLHPxa2Ttp6Fja2dcIvmi8wc4P6dTqN62vk=; fh=16AwIsfnaBgs0S7h9TVOhyQqQjjaKNV4ZtY0tk57H5k=; b=G6jAVGXDTF6xIOobvZD1ucztbDEj99HeGy3QVHEKRrXHts8x8XQE0EmsTkN8sUlewj 7LayF5wdrPRhKk7bmQiftftbG3slvU+b+z2izjuapWPrH400bv7mJjSFO0A0fUB6SmNF WfYVWbSr1wYbPH9p2yPS56xxeFcLCIR8Rmhl2iNCgWD1HFwSUoKIs7iKSj7sN4SOqZwi 5zvXsJi8E+9bbhAMZ8T8C/v1q6Vl2TJC0q8N5xQFLyjRUlxwnfyKYqSdnvVDCfqO6iKr YwODYaiTlzW8toRyM5lVG+3y/vYWs0lHcvp2kkY/D0GLhIma9liPycrPWrUutmUuiVCY AzFA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=DYGTkPWE; 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-90853-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90853-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id hf12-20020a0562140e8c00b0069034ef01e2si9911669qvb.605.2024.03.04.07.41.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:41:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90853-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=DYGTkPWE; 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-90853-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90853-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 676611C2330D for ; Mon, 4 Mar 2024 15:40:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 635AA58206; Mon, 4 Mar 2024 15:36:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="DYGTkPWE" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 0320E56B98; Mon, 4 Mar 2024 15:36:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566599; cv=none; b=keAR3yNcssE+WO6XKCClRP2Kj+XFHTGuqmPS6ljWtWAa6zc5brmsAPuWIcU/e4Aom5ue5+OvSmU4XxZQBU7cStbGYFPprk1F23T5+/xSDa/e797UoDh8yTOyk6RCPiQ0SjslVi/GucINBsm4Z56BF6pEoWEhhrnzTOFzP6uCK3w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566599; c=relaxed/simple; bh=PuFPfR2lIZ+bkqMkJWaCoXVb8zQMzKhIXQuBGxgZ6Mw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DfwmF6mb913x9uh55jn+GJiZv8Dxyd7RGsW9Iop238NKNm4z0xbp0OiHmJOrTc3Kcm2DxhxEqDUkjHJmmHdyxv42BoELvWL1BKL+XCnPW3DJn+0emUdMszrkTUMI/3yit05jgdUqYTMUhVt1CIqOKlbOJpM36C+FlYg4oesn0hA= 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=DYGTkPWE; arc=none smtp.client-ip=217.70.183.201 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 771F61BF20B; Mon, 4 Mar 2024 15:36:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566595; 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=DaC56o2wBLHPxa2Ttp6Fja2dcIvmi8wc4P6dTqN62vk=; b=DYGTkPWEslLKG8HWGpJ11wN+i6/cmO4SQCQb8RAV5EJtc4xXnvBDg6XQ/AXZOu2gFCUsAG 2+t6wdveq+JnF/wbiAGysqVcbo4f5C9KpKqmamF7ZOEBhmiCTDHKT7ZHqlNSyc1gzZFl8J PU2u1fQ4dS6Fy6Lt3hhCCEJcMKNNrgp1PX53fvt/ufDHll2jicK16x89I2iVdXlIF/7fXB hTMI3Ggc4WoGOgLD3mrg+4KXl7r+jExKUw99Tbha9BIGIwc40Yz2vAHgF66nE0bOeLL2mz HS8lsbqZgkSVRWLF+kzb+jeVF54C6wzLxx+XEz/VVc9KzUZqddt0Ley+aYbBDA== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:57 +0100 Subject: [PATCH v4 14/18] 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-v4-14-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard , Siddharth Vadapalli 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 03b96798f858..9ca2ffca0bf9 100644 --- a/drivers/pci/controller/cadence/pcie-cadence.h +++ b/drivers/pci/controller/cadence/pcie-cadence.h @@ -515,10 +515,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