Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp172520lqe; Wed, 27 Mar 2024 02:16:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVYx71C5R1KP5/oVa8Q6M+Ujn7D7FA/MebSbE+6lAJU1ri15SIGgQBJaRkJs6ZXUeE7vSRBKtZQ2P8BXUCBYH2Qx8EkVlLcxguaOUogIA== X-Google-Smtp-Source: AGHT+IH8ufkE3R1OHQBDUFUsq4uePmLm9kOrodA7Cmw34vh7I3Su6wOHlrq6bW/6qJsemD4qfMDZ X-Received: by 2002:a50:d489:0:b0:56b:dfe7:ea5a with SMTP id s9-20020a50d489000000b0056bdfe7ea5amr2501418edi.17.1711530977157; Wed, 27 Mar 2024 02:16:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711530977; cv=pass; d=google.com; s=arc-20160816; b=bGRkK3pDjg5LpcT/yyFHgLMUydyT9xQMVVmgqCyUKqn5JX6do4tTZ8r1xclNo5NAeK COfvQkvFtfYSjBWVRbVIGwfzvBwPS38ybWBtIumQY4k9qyCfjEBym/aVUSzlg9SoWvjU TgL/pvwHcMI9cSpz3tMcDNvwYuy1pL5tLJjaGdBCGng4pAFq70y+vX4xiNUWfyna9vvq 7zxAnfYdx74pUXFNN1y1QFUMdRu8sX1/2LDqOV1t9jN/1DFWB00H7x47fAais3skzMM0 i3fS1hcUrSrnZGexuqBK8wVqQJO1hkwq5C7AlsR35XqiAMtNIKZ3ackFse7qszA9h7f4 ap8w== 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=+w8+XZFFVZD9serrdKw4v46iT3fU34iMoHh0wJblC08=; fh=Xy9wYD2yZwNxzUnQYGCV6soBTPm1UkiSMjdv1Ct/P9M=; b=N9QYz97Iumv94xuelO4lWCBKLmBYyGgOucLRDeWHM52oMUiwZUs8piGuRXyrZvcIi7 EAsxS+EHB0RoNpKv+djmijvk7jT1xaTIt8/qP2mO4pZDCe7GwxjZPwZAQjqggzEO7OVu xruGLeN4g9dJPDG8nHF42KE9t7khbLJmHBW0VLNL0Ubg54EOqwFWUJ+sycXGhz3/NUgU JYCM5be5/RIDMd5zp+z8EYpny3qgRp0zAw+wsWPNnxNqJgPQzsV7TWOq2mK6NdkGKudX 0beSH4NVRlrfKypzxLoaOXCIvnj/Kn9y6d3auvc4hejKphRQ2PZA1wHbNBFLxKD7Otv/ zRRA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F+fNR5jH; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-120599-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120599-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m18-20020a509992000000b00563f6984908si4545734edb.517.2024.03.27.02.16.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 02:16:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120599-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=@linaro.org header.s=google header.b=F+fNR5jH; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-120599-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120599-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 A69BA1F2C135 for ; Wed, 27 Mar 2024 09:16:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 343CD4503C; Wed, 27 Mar 2024 09:15:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="F+fNR5jH" Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1AD514D5A3 for ; Wed, 27 Mar 2024 09:15:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711530905; cv=none; b=sB+DENp7nifV6rRGhCawfvyjdGVCOrROoce0RtKI4Di0J4dwwJ8UYkb7RI6V9P7wRqyLwzefa0lUVwbMRw7K6nDbpVCs39PovJYqzTJ2zv2jFrMe/wb5WGYy3E8yRVj1V4cW+J7tA2L++ZSb7DnA7O7eDdLvGJXaQJF/V4PUPgw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711530905; c=relaxed/simple; bh=cYPmZhMWF9JrrdBXi4xoNK400WwuLP3vEJRvgS89ChI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=k+VL1hwYjskaP/dqZK2RwbcftiwUjtScrOGFN3GuNPbhsa2MBhJhI0XY0AnmkP2BGx/3qbIjKfwQmMKhxMUCB+fyfonxRVr4BHNeXgvaAYy5DzmGfF8u4BVaCncP69L3NuoEUzThP8DmNNkS/n/XsRRZoEI7wp/6wZSGe70FLB0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=F+fNR5jH; arc=none smtp.client-ip=209.85.161.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-5a4789684abso3664125eaf.0 for ; Wed, 27 Mar 2024 02:15:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711530901; x=1712135701; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=+w8+XZFFVZD9serrdKw4v46iT3fU34iMoHh0wJblC08=; b=F+fNR5jHGXqI7iB0nQg/3p6UgQ7b+L4ynULXLf6YKN412YlOWs0tnjyqkb9Jsh539b xTOhQzN38cbp0Equqe0p9fU7gTOGme8YvemGDFyQ7QzEJtfFJjlr6azq5i7Bx0Z/4LKq Ko8Ot6ZbQlf7YQM7CBWR6M44WPWW9ml4cQS+o2fmi3ZfAX/6ad8KmcBxd4TOAworNn44 TGaUL+ShidfgbtV4KkayFd5pvLR6G676oitlfDvsVv9tJkMEslOpJ8J1KoSbsNP/u2xW A3TcznUfQm0j00t4k6EpwsudSoMhfhyT33nu0WQ0j7b/0+u574POIQh1QwTmKwu1wpRN fEqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711530901; x=1712135701; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+w8+XZFFVZD9serrdKw4v46iT3fU34iMoHh0wJblC08=; b=BzNaVc17yPRfqX/+OR/vUySjcSYDSWxdbkM+d0TrR6RtQf90SI5lzOrAKDSx8AcI2h zrL/P0xDy/oP7Qz1NbNNFhPXK1FCrrXkGt14FBi0nUYxHZgLeZb7TSF6uf/HVYcGAT4n ro358MbH1iXhhvEiPXoLSdKTLJYDaboKCGnNW73UfaQy+ElL8EeuA3MCsrV/Et6IZ9L8 mmlLfaE6/DdMue1CwoSZqYp5xVzoRFU+PGaNMbt0tLByHWU9HLwTH88G6LCdRyShN/Si caaI0za+e9ojtv+vuoXx3Hy6Mt3sMpSW01yesyxWKKGe9kfQsuHZmCljPaBkocIhnMwK 6t3w== X-Forwarded-Encrypted: i=1; AJvYcCWzux+7Of/SZ1RK3EgBZgtAl5mBxZHhh0x8yBSz60g9MXSwjqDJtCNaJyKERnrlOF9eJzxoDp49zpkoIfXPrvpDmVYJ0YU92wbtDEKx X-Gm-Message-State: AOJu0Yz1GBrWbUS0wxvY2eWiudkIXSPhII84ZgaJW+tO0jpmRLa4HBDx hrfjLKbN9+44UVvIy/srTGeoIHum/m6fn6p1P3a2Zmt/jCAXLzfBdqSqaIF7BQ== X-Received: by 2002:a05:6358:7584:b0:17b:b559:2ba3 with SMTP id x4-20020a056358758400b0017bb5592ba3mr819971rwf.11.1711530900939; Wed, 27 Mar 2024 02:15:00 -0700 (PDT) Received: from [127.0.1.1] ([120.60.52.77]) by smtp.gmail.com with ESMTPSA id h190-20020a6383c7000000b005dc4fc80b21sm8673871pge.70.2024.03.27.02.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 02:15:00 -0700 (PDT) From: Manivannan Sadhasivam Date: Wed, 27 Mar 2024 14:43:34 +0530 Subject: [PATCH v12 5/8] PCI: dwc: ep: Introduce dw_pcie_ep_cleanup() API for drivers supporting PERST# 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: <20240327-pci-dbi-rework-v12-5-082625472414@linaro.org> References: <20240327-pci-dbi-rework-v12-0-082625472414@linaro.org> In-Reply-To: <20240327-pci-dbi-rework-v12-0-082625472414@linaro.org> To: Jingoo Han , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Marek Vasut , Yoshihiro Shimoda , Thierry Reding , Jonathan Hunter , Vidya Sagar , Vignesh Raghavendra , Richard Zhu , Lucas Stach , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Minghuan Lian , Mingkai Hu , Roy Zang , Kunihiko Hayashi , Masami Hiramatsu , Kishon Vijay Abraham I , Jesper Nilsson , Srikanth Thokala , Shawn Lin , Heiko Stuebner , Kishon Vijay Abraham I Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Niklas Cassel , linux-arm-kernel@axis.com, linux-rockchip@lists.infradead.org, Manivannan Sadhasivam , Frank Li X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=4250; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=cYPmZhMWF9JrrdBXi4xoNK400WwuLP3vEJRvgS89ChI=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBmA+NJCy5UKQajgGLcJFCmTCocVuyMtWTlZ2Ejs QvYSXEZAl2JATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZgPjSQAKCRBVnxHm/pHO 9T6mB/9pFQquf5LOGTNXV2yHivElmVpYY5aK42tRZFhvZZ0Tq1cMStZlxIL1CLcpD/qAJJPoQS+ yVJ9edDCykI7R6KmW+PI1NL5g3gievubaOlD4LHYQpXWT3eRl4G1adOoeFRaOnbqHWAkiKFRgwM APGy4NWJvEX5fEswTOaqdUIxHOR1D8QSfTpyiQjtc6sbN4hICqqYVM/nNy9qVHB543u9n0PPMK5 mwWvNRApMkR5oCw9X9KChFW25uEjtpqUSGFHWzRJqYacYvkodK+xQuRVRbCraKJY/IJgSJouwp4 NYITRCwxRHIPKRVUpx5qz/2wRe4F6MoptuTdyT8F6F+m+R/s X-Developer-Key: i=manivannan.sadhasivam@linaro.org; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 For DWC glue drivers supporting PERST# (currently Qcom and Tegra194), some of the DWC resources like eDMA should be cleaned up during the PERST# assert time. So let's introduce a dw_pcie_ep_cleanup() API that could be called by these drivers to cleanup the DWC specific resources. Currently, it just removes eDMA. Reported-by: Niklas Cassel Closes: https://lore.kernel.org/linux-pci/ZWYmX8Y%2F7Q9WMxES@x1-carbon Reviewed-by: Frank Li Reviewed-by: Niklas Cassel Signed-off-by: Manivannan Sadhasivam --- drivers/pci/controller/dwc/pcie-designware-ep.c | 19 +++++++++++++++++-- drivers/pci/controller/dwc/pcie-designware.h | 5 +++++ drivers/pci/controller/dwc/pcie-qcom-ep.c | 1 + drivers/pci/controller/dwc/pcie-tegra194.c | 2 ++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index d87f7642d7f6..eeff7f1ff8f1 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -619,6 +619,22 @@ int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, return 0; } +/** + * dw_pcie_ep_cleanup - Cleanup DWC EP resources after fundamental reset + * @ep: DWC EP device + * + * Cleans up the DWC EP specific resources like eDMA etc... after fundamental + * reset like PERST#. Note that this API is only applicable for drivers + * supporting PERST# or any other methods of fundamental reset. + */ +void dw_pcie_ep_cleanup(struct dw_pcie_ep *ep) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + + dw_pcie_edma_remove(pci); +} +EXPORT_SYMBOL_GPL(dw_pcie_ep_cleanup); + /** * dw_pcie_ep_deinit - Deinitialize the endpoint device * @ep: DWC EP device @@ -628,10 +644,9 @@ int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, */ void dw_pcie_ep_deinit(struct dw_pcie_ep *ep) { - struct dw_pcie *pci = to_dw_pcie_from_ep(ep); struct pci_epc *epc = ep->epc; - dw_pcie_edma_remove(pci); + dw_pcie_ep_cleanup(ep); pci_epc_mem_free_addr(epc, ep->msi_mem_phys, ep->msi_mem, epc->mem->window.page_size); diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 61465203bb60..351d2fe3ea4d 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -672,6 +672,7 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep); int dw_pcie_ep_init_complete(struct dw_pcie_ep *ep); void dw_pcie_ep_init_notify(struct dw_pcie_ep *ep); void dw_pcie_ep_deinit(struct dw_pcie_ep *ep); +void dw_pcie_ep_cleanup(struct dw_pcie_ep *ep); int dw_pcie_ep_raise_intx_irq(struct dw_pcie_ep *ep, u8 func_no); int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no, u8 interrupt_num); @@ -705,6 +706,10 @@ static inline void dw_pcie_ep_deinit(struct dw_pcie_ep *ep) { } +static inline void dw_pcie_ep_cleanup(struct dw_pcie_ep *ep) +{ +} + static inline int dw_pcie_ep_raise_intx_irq(struct dw_pcie_ep *ep, u8 func_no) { return 0; diff --git a/drivers/pci/controller/dwc/pcie-qcom-ep.c b/drivers/pci/controller/dwc/pcie-qcom-ep.c index 36e5e80cd22f..59b1c0110288 100644 --- a/drivers/pci/controller/dwc/pcie-qcom-ep.c +++ b/drivers/pci/controller/dwc/pcie-qcom-ep.c @@ -507,6 +507,7 @@ static void qcom_pcie_perst_assert(struct dw_pcie *pci) return; } + dw_pcie_ep_cleanup(&pci->ep); qcom_pcie_disable_resources(pcie_ep); pcie_ep->link_status = QCOM_PCIE_EP_LINK_DISABLED; } diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c index 1f7b662cb8e1..26ea2f8313eb 100644 --- a/drivers/pci/controller/dwc/pcie-tegra194.c +++ b/drivers/pci/controller/dwc/pcie-tegra194.c @@ -1715,6 +1715,8 @@ static void pex_ep_event_pex_rst_assert(struct tegra_pcie_dw *pcie) if (ret) dev_err(pcie->dev, "Failed to go Detect state: %d\n", ret); + dw_pcie_ep_cleanup(&pcie->pci.ep); + reset_control_assert(pcie->core_rst); tegra_pcie_disable_phy(pcie); -- 2.25.1