From patchwork Mon Mar 4 15:35:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209612 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp272590rwb; Mon, 4 Mar 2024 07:43:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVLB+bJW8B/A0kelDjPudUwJMJrnQ/jvwpp5lQAXqSPJN4X8CRjgoD7nx/+pmy9q92hswKyV1d2KuETwlznJbq+nq7V6A== X-Google-Smtp-Source: AGHT+IENgAp2YYBSBf06njDsDg934BpMNiSRAhhUIzNn6uQxCyW9BbztHgLlzWeLW1yl7g3VAYar X-Received: by 2002:a05:6a00:1248:b0:6e5:2f97:bf43 with SMTP id u8-20020a056a00124800b006e52f97bf43mr8689955pfi.27.1709566986790; Mon, 04 Mar 2024 07:43:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566986; cv=pass; d=google.com; s=arc-20160816; b=UWCrt7HyXZAozmaY/sXG0FoM/kM8xqbC8N8em27e/4Mb+BZ4YffOtpKoAin95MBvb2 NZx2Kexc1S8kptIj7nTHjyDk8/JnWo5BGPXLvBniD4vpGvmEMNU3i8+vy3lDpKvhJCQO u6a1sW/G9MdTiH9g9swKkXbF/LiLHvVNYUEtq3NisTWz7I3JuWzrXdK6eO1/7Q0+FoJN 7NQt7NZ9HhhROhZfWMwHGsTZR23dEC9En3ovnloAVVgUH9DCbdf4gBKVl/DemtyjCjFj 4/cgL20l2LmMc88bNZaLluj3/U6f2B73Zi5bR4/lxm+wfYfZ3Tjk+vfWIF6sq+0WKUgk zHBQ== 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90853-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u20-20020a62d454000000b006e531ba990bsi8308845pfl.326.2024.03.04.07.43.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:43:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90853-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90853-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 826F52808BE for ; Mon, 4 Mar 2024 15:41:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5232E59171; Mon, 4 Mar 2024 15:36:42 +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 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=84?= =?utf-8?q?ski?= , 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792610913164267946 X-GMAIL-MSGID: 1792610913164267946 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;