Received: by 2002:ab2:5c0e:0:b0:1ef:a325:1205 with SMTP id i14csp225724lqk; Thu, 14 Mar 2024 00:53:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5OlRg7aNrx7kn/oVuH64j9OYJ63Dvgrbpy9Us/SdNzv8W70/66Y42am+TzPvr7eW9pMzcy9RfYpuFoQNlCHCntMJNiM/z5OMhWSX3Bw== X-Google-Smtp-Source: AGHT+IFFPChG/iJrrK8OiPJHN/FLMFeJQpIpc50jMk6zV+jmfHsz13KxJBF1MzATdjv3VK1oJ9Jz X-Received: by 2002:aa7:8881:0:b0:6e6:9fdc:19e with SMTP id z1-20020aa78881000000b006e69fdc019emr989883pfe.22.1710402790238; Thu, 14 Mar 2024 00:53:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710402790; cv=pass; d=google.com; s=arc-20160816; b=qtNC7GSwo8qZwQDYZXvprPPX1oX6wiPeM1ltZBEeJ62mNaPcqENGcl+6SXDRH/vPU9 2VmiR+YHS0BqZO0isuP/UVmMfrovjL/iIg5Lvw0sBAdt+04t3k03TAlY9HCs50C7U6nt TQChfP9bIADWp6TqJT2NpgkHmuyCiUSoy3yEryWeuL/9FE5Zd1/HaYG1xsb8xWm93SZl HGpXUeF1vw1Yar5hUjP+u/sLU5xMAlZtfsuIT4zBdbCF3mqibjiCHck2XHzKOKF5RaM8 7BOYxu+TOKrmD3m3pCfnDQuiuMvskL6mLKZn8ozr3UlKOqbQvpEEZI/AeJ+GcduPuWYz gNCw== 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=ESlUf6Tb8Sm/rW4Mp2Hu3vGGr3y8fch0rbkMlMxrb2c=; fh=gW1enIfWvZJ+rP+5D2HFbM7VCbwF3oGs0mR84AEwf5Y=; b=X7q2zNDU4IoiAh6WKCf81Fo42TBU/cTyut0L1mHR+NquUA8OEbCIct0gyo8HR6Yrmw r91sGjzuLtASclFIzZ1aHq8s5YbvFmCUOg+NCEXD9HNkkZbcMHT0GpjsTGFPIW/OVRHe 6+HQjeiVTBt3d3elIqEXCK7IQg0UqFRi9kPniLI8LfchDsh+FE4VNAEK6KgGDM16HgnV gr0B0ymwAXMwwAf35HNePvTii/zOAEeFsAyhhYAAdTY4tX1ydrDBzSK2PYRkwCwlYRgX US+k1LEu4UO5usyIXaRIKU1q95pCk79BOCxerZin+nvlqzMyDGYLmjohrIZs8KtP5usS KSsg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EkHhDSxE; 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-102945-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102945-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id fn26-20020a056a002fda00b006e6b77f6aabsi967434pfb.263.2024.03.14.00.53.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 00:53:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102945-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EkHhDSxE; 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-102945-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102945-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 353CCB23BBC for ; Thu, 14 Mar 2024 07:50:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33B885F550; Thu, 14 Mar 2024 07:49:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EkHhDSxE" Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 9DC555F55C for ; Thu, 14 Mar 2024 07:49:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710402563; cv=none; b=n+AYC14UFKaLCNGza1W92ecHefltsVDe7/o1o+7UkZaaTY1apEjXEY2PqPMRpnT6MlZ8nOEVWPcvN5oCIp5T7vBI9o6FIM09nhfntghToQzZcWWC4slocjT/atEP99mNeXi80SoofkTVuCARGtjzic0mgIndf1R2GoICac0PWHc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710402563; c=relaxed/simple; bh=imNUy+f7eKE6KAlrBpk8JwGpYkEF4zA5IlOifIZB9Hs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IS7vBMrUizHq7e1Vbp/UhHNz2Fx+lPnxFiQsKFIJc9jI0Te7fnLflL6zG2Yn2eG06jUNmM8mfBNpJYqobjKy/MB54Q7Lmgp4Oc1ey8FZlBWFrR8XckE8dqDPLOQfm7b+RCU3tItB5xLm7cGfQ+w3HZfq644THaX+gXD2RsyANMs= 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=EkHhDSxE; arc=none smtp.client-ip=209.85.210.178 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-pf1-f178.google.com with SMTP id d2e1a72fcca58-6e6ccd69ebcso243749b3a.0 for ; Thu, 14 Mar 2024 00:49:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710402560; x=1711007360; 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=ESlUf6Tb8Sm/rW4Mp2Hu3vGGr3y8fch0rbkMlMxrb2c=; b=EkHhDSxE5cxNZh+CWWdoaI2Vs+ysqYtB7plyShvPPtQYo3+Pyf/paMRNlBXted8YzD wDSteFHTJMBRtGcitvt3M8oSIudBwqnhOK6mcLiOCxJRR+cLf4AwOfwU8ftDBDUeOmUH 4VV0H9GVbg4cM7pcDivhO5+3pA4vJ54fCQKjrtB7M+cpsGSS13sWCGT05MdRpny1PveL Ov+e3jtfAJe1801THWffczayGptlLEGttHHVbW3L905X6IXHskLuVadNrM43QlGV2GOe XoYcy/+OwRLuP9wtchXtaG1DknWN3extI6eNJWysC0c6JzGVF3JWsO8eMB7ElO1VS+c+ Lxvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710402560; x=1711007360; 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=ESlUf6Tb8Sm/rW4Mp2Hu3vGGr3y8fch0rbkMlMxrb2c=; b=t7efhVLQrtRSthl//sGOGcsrFPA0I0qVC9CClXy/Lma/zWG7/srH6AmeggZ0t+FSpM y8ik1/QOFRP8LhmYZIJyJm2FQi4VRiKNRJQgwscV3xAHBc2j8jnmDu21tx44z2JKB+gU yn9VcBIqlscJ31CHQuU5lQPYNdenFgzryvOVKDUFfWkyecn+OqcyWOcFYh/vcMV16Y4r 2vzBUsqrbBFYor7L+2GHglkkIcxZK8oHYBcP816IoK7XHo+2YQ4elwisZhK4RjxLsFQQ IVy0pzprqSi0KXEb5GXbXWhB9FFeaVBZiXb8uqT4Y5Ws3DU3c1jdUyCPii9w5lg1tEsT sWjA== X-Forwarded-Encrypted: i=1; AJvYcCU1pDbSkS7giaJ9wZRdbvZ7taXPHHONTIwRm5JqCN9Er8LmTsmxRa9uwbt2QEyVLLUgqIP7T8bqMC0288H/DSs9IMmMW6M/RYTvxnkp X-Gm-Message-State: AOJu0YyxFwvX4l7Tnps7yKEPVRjQ/6OqgCOZb14Wo1fuKXMTXAoMmExU 6X72QiUmHZkvUPF4V2gOAD4L/G5GQoIB21ckWlj1N2jCJMT2yghXr5XKV9ALkA== X-Received: by 2002:a05:6a20:ce4c:b0:1a0:fcf5:c931 with SMTP id id12-20020a056a20ce4c00b001a0fcf5c931mr1425804pzb.29.1710402559843; Thu, 14 Mar 2024 00:49:19 -0700 (PDT) Received: from [127.0.1.1] ([117.207.30.211]) by smtp.gmail.com with ESMTPSA id l9-20020a170903120900b001dd4fabf695sm946321plh.38.2024.03.14.00.49.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 00:49:19 -0700 (PDT) From: Manivannan Sadhasivam Date: Thu, 14 Mar 2024 13:18:03 +0530 Subject: [PATCH v10 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: <20240314-pci-dbi-rework-v10-5-14a45c5a938e@linaro.org> References: <20240314-pci-dbi-rework-v10-0-14a45c5a938e@linaro.org> In-Reply-To: <20240314-pci-dbi-rework-v10-0-14a45c5a938e@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 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, 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=imNUy+f7eKE6KAlrBpk8JwGpYkEF4zA5IlOifIZB9Hs=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBl8qvDNh9SoNQS7cCRqGiggvD+IxFKqux+H5pE4 aNIO/Bun6WJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZfKrwwAKCRBVnxHm/pHO 9QbwB/9IPw0cbRyNEQBGZFD+88QKUklHkJ/Q0V8R5oOp3iToag0Ul6YZsg1J3cyv8cdlU05yQFK nMe8mzxyjLeNS2V5Dq5wp58OvhMVogisL52A9q6Rzss373950T9/uvNOBFirkSpKUCi2DxK29Bp wRlSc6nAaZMuRWC6sbXUZDhRTqr8k/NXJ0b+3AW8l7IaDUb8J32OnsY/7nOqqxQSpFaqkDBOJVb lz1CKHwq0JEs9fjYSl1fBXISGY8a5Uabg+hWQ6xBE4O2+ZegzcOe7evzGuhyWpwSUT0QkvfCQOM G4Ye13hO2ZQxBiD6n6BOtCk4kp1aUUr1SjHSMLmNPolQy6hu 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 fa7b26da8718..4c21a38245b6 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -618,6 +618,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 @@ -627,10 +643,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