Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp112061lqe; Tue, 26 Mar 2024 23:40:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWqN+B42DR8z21jWjWHrNe1hItFX/bAhxT6LaE13r/3kdl2ecHmYgMqhWLuZQnbVGGedHX/SUfUJ67Svo75Hh694rG9fqhqsV/pMU0nsA== X-Google-Smtp-Source: AGHT+IEAy+qpuDEn3Ro3yuDFClLlYMZRr9r6XG5LdLHbShOoYoD9r5PySOk5DDL1pI4h+qTMcr9l X-Received: by 2002:a17:907:20b2:b0:a46:617e:d3a7 with SMTP id pw18-20020a17090720b200b00a46617ed3a7mr3418325ejb.60.1711521606257; Tue, 26 Mar 2024 23:40:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711521606; cv=pass; d=google.com; s=arc-20160816; b=Y71XzEusxzOglgRqIz3kMsyyAYRKj+2rMlU70HbVvCZfKAoyM1sNULoPxfYVrXu9bK VJPu99C7MVY14oed2MVCODpnhGPdNF6/PIlR0ONrW6A7lrDoFCa9+ZV6H0oYg9fDRy2v P1Fy5EZJknc9WrpSw1usDKqI4Kc5L1wcdUV3YANvuWPxFnmBz7nKcLN2bQEYTdSpvNsF h51wkwmlc2g4Y5cd2bjMbH2x877E0dygUDklKrEqh6JyMya/XukYplFao3sXk/N+peV1 LsdeOBbS/jryDAVL4NZg/V2Hrwp5l/9HRZ/HFTQ2M96A5A6Tkec+sDRXhZ7Th6V9AUiW P2sw== 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=mivPPYHKcOKy4Ao8y34XOU96LcUYepuBhGKc2WiBoys=; fh=6oXPuqtXIDZ0Xc/tJKG996MNUzroZUl5L5Jfn8J3H+M=; b=quWcvp9187wAJ+gK6A7Ejylk4htXjOyaMPmS0yDWIrUoVpBpKKKFr3ulBmqN7IBvMI UX7WFjFy0ZKjbVdYnrKGEq1kWa2CKdDgRzufBTvuH0x+At6CrwSiSuCe1GjPK7CnibaC /ftFsLoHN/JcqUEeUFKQ13FHRPyOwoLNWSE1aiAhAXwo+Vvdps1ATMiV/JSYc5rGmISS b/nYhuk1TooaSj3eU0/AgzOEAH6SClcLeJJhTq4H7Qjf2IZCtThksWTgyQw4H3Y56kcc Jf2Am8OvnlevwtiGi+pFH2du7fL/Lu5LoUudBHrTFJX7OFE2AWpURL6znzX8sQImxa2j JHTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q4NclsD3; 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-120388-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120388-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 p15-20020a17090653cf00b00a4dc79d3edbsi1788429ejo.1017.2024.03.26.23.40.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 23:40:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120388-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=q4NclsD3; 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-120388-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120388-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 CE3211F2ADB8 for ; Wed, 27 Mar 2024 06:40:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F4CA36114; Wed, 27 Mar 2024 06:38:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="q4NclsD3" Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 3EB6636119 for ; Wed, 27 Mar 2024 06:38:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711521486; cv=none; b=XRceg6x4alSJjtKEuvCq0F5fC0urMkCfY0xKrKkYQ1xYtaIR6gifyjbwEb7j6RnNg5gRzahEDrgzvOwovhDyH1+vDlK29JtLrFqD1t2DHF3n55Lzb+355VLXMOLBBKFuhh66KQQv9PSye+9AZFvmujRfhR9hvHVG0WI6vSdpSUQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711521486; c=relaxed/simple; bh=qsrXEYDJ7iRM5G49lWMuNsUTn79ZQLOBCbqctpAd/Xc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kvPXbyysYOVU6x6/21jWKAC2hOI5nJs2HS+A5fzbJc9Kl+gh1raqB291AjPlLhBVFEWr17wf0rz6kcWMF3BOLX2Loow4QqF6pcsW3nGXldrYlbWlDuNsKQYmwLRfgbJakUHzNPBwfxz7u749u+b1dOs2NojsW2ORpQH+fPpLVdI= 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=q4NclsD3; arc=none smtp.client-ip=209.85.214.177 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-pl1-f177.google.com with SMTP id d9443c01a7336-1e034607879so50657925ad.0 for ; Tue, 26 Mar 2024 23:38:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711521483; x=1712126283; 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=mivPPYHKcOKy4Ao8y34XOU96LcUYepuBhGKc2WiBoys=; b=q4NclsD3/Pvn5OvVmCmeRwdSIKEv46Xeg8T2s3OtozdWY1bXvIp9atfvZeL7Ok4Bcq hiA6aRpuXaYdBQ7PYbcJfTzX/cBrddLvRtkHgqgtx2sc9BsQD59cMRxGz0CRc2IDaG8d S6C7maDu86/bhH3XhgAFbA674uSQy7e64uKtlJ5kD+QvrWBBqk0kOWOPvH204euzzocL ND/mn2nPvQ2EnU3Qu+Iv9zvlJn23E0qU/yKLgyFFPIuRLchSvIqIjVVLgWhNvFOFvv6S 0wGGh4Wy8j14A8JOefH8ZtOJFtQSzILnhqkCvGVmHsXURfNgC6yzy4NrnAde62wF0ulA eCpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711521483; x=1712126283; 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=mivPPYHKcOKy4Ao8y34XOU96LcUYepuBhGKc2WiBoys=; b=k1fFxqMw7G1iwS1XT91Ssso3tbK5REYig+GzhfHL3EUI1ndkVd+7RVdcBS10B3FMOB Vq9pUY+g3i31MG+D9katozja9PSdz8vYqNOVtGcZkX/6XDNcmluz14csj0egzvtf11s/ o356liwa9MLEtVAxHH7jQ5bBKDmJW5xDNA3ZpsgVT6s21kLTss5PxLft1IVCUnontj3l xJrxK0vylB3DXvkhkxgcZpXPXsr/ddC+ZRsWTYiff223e/MvOWVTQZH/TwoKKE9eY+co JEx7QNzZMWedbtG1kqBRca0VpflA/px+JHVumfTT6vguABHR1aXQv8GH+6XoWWufja87 gnHg== X-Forwarded-Encrypted: i=1; AJvYcCXCbGDseOC+dh2exE3DBzkwrir/hZ6ie4pnNIpfpyplHUuxWuyqqNNco+f4VojGgudTClqtFHp563I+LPAqfevsRg4Co3OYkKbfp7es X-Gm-Message-State: AOJu0YwyCURnxG2xF3ixVt9c9OaXicwbdJhVdI1iRG4B3juuSc1XH0e9 FLro5Jd/+nFdClrr2etyDih3uUtDk52GL/DDDrQRUk1lwcWIY/rPrpwU/Xt9xA== X-Received: by 2002:a17:902:ea09:b0:1e0:bd8e:5a66 with SMTP id s9-20020a170902ea0900b001e0bd8e5a66mr442911plg.8.1711521483320; Tue, 26 Mar 2024 23:38:03 -0700 (PDT) Received: from [127.0.1.1] ([117.207.28.168]) by smtp.gmail.com with ESMTPSA id r9-20020a170902be0900b001e14807c7dfsm602553pls.86.2024.03.26.23.37.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 23:38:02 -0700 (PDT) From: Manivannan Sadhasivam Date: Wed, 27 Mar 2024 12:05:51 +0530 Subject: [PATCH v11 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-v11-5-6f5259f90673@linaro.org> References: <20240327-pci-dbi-rework-v11-0-6f5259f90673@linaro.org> In-Reply-To: <20240327-pci-dbi-rework-v11-0-6f5259f90673@linaro.org> To: Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Marek Vasut , Yoshihiro Shimoda , Thierry Reding , Jonathan Hunter , Kishon Vijay Abraham I , 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 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=qsrXEYDJ7iRM5G49lWMuNsUTn79ZQLOBCbqctpAd/Xc=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBmA75WoMjoLUGDerPhNIv6VyZTOayQ0uU/PY+4B kAPbZoTMMyJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZgO+VgAKCRBVnxHm/pHO 9ZymB/42xHgi+oA0QmT/QC4mzKmaeoOjY/JSPU1j3L93vbjOssxOJeezhE7Swp/n6lyaHPxoY+r ZUoL9JO8pKFg9cX69Kz2fjso7GFmQTr+32IhNeaQjJKvCFAgudmbh1oJodl/NyDHnbqkGnprS2d L5o+eAB6f4MmYT6ecfcpzH4aHPJzkjC5Tn8H16P4w7vjT63h0WZCZe2RRRTaI5ieaRGE2Gm1H49 /tjWHhmjJlptTfyF0MFN9Qfy2Bba9LzKYjsPZrWo/d1ip0fYBaYxDBHdlShr0Ea4mHZRVM+gOn8 W6QF6ehLfXxKTDiMLCJ3CLVqU3YxefS9Wy+lpHGuCAJcVkzG 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 7ff2015736ef..7509fa1d1e7d 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -617,6 +617,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 @@ -626,10 +642,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 7afa9e9aabe2..68bfeed3429b 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