Received: by 2002:ab2:2997:0:b0:1ec:cbc4:63fb with SMTP id n23csp400930lqb; Thu, 29 Feb 2024 04:40:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX2homrPqKmha4VcswMaIfsqzgyEhP/jPocyDqO+sDUlmF/BxqfdypXQH/IPsq9kJOmDTM3EVkv5UiOW0DAvSYrHvsRu6GyNXYEpW+u2A== X-Google-Smtp-Source: AGHT+IEBXbBNL8CxohpXlyAVMRINtSc/iwK5uj2tsGVfImgWSCWuhu9UEcT0gROWHedB7WzBn30U X-Received: by 2002:a05:620a:5e07:b0:787:e01a:b1fc with SMTP id xz7-20020a05620a5e0700b00787e01ab1fcmr1782772qkn.34.1709210451262; Thu, 29 Feb 2024 04:40:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709210451; cv=pass; d=google.com; s=arc-20160816; b=CXpQsXVx7N1i32aIJbKfoTFAibDC6QaHETzmKvNinU95DOyj1gYS3srKFhjEOSfNVA 8AV5mjP8ugGMiViDU89kWRG0M532ASAuM0D4WkaNdlezcrGMkbr4oGOTgEO9wnd9cRpV neIikfXoQW4N6pt2M7TiRV4Hd1IaDPgQWILJRaFVdK+cqGENeCZEuA1AcEWMh7tJPrd3 EG/u8Zc3hmcW75tX/1TCmQxKjc/0q/YBQ95zYUuJefcKORgVb++hyvwE6Md7Ju3z1iIm uzoZDevMTgFYMcXUHShZ7loy0h6Md6kc8OKsNeQwIzFO2+S1Z5TpJ8EZpZEAt4P0YiSl nK6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=dFDZcKCy/0oQEtYq6n0OwiOl85gVgaPQ6fUQR8XCu+Q=; fh=y9nZknAH1oMEGk392bqSNlfgw2xhvyzYDCRswAnmBH4=; b=oVOslGgVdBboW4ZUBBmSliGdr2vEsGXBIKPPiZjF3H4+JhIcJvFoSvkfLocYoTyMu/ NYWyafHaQveq9VE7dYZGm4+DCdp3mCoc4dFc+zeadS7J1hUP1r7tFRbY6mX1Upo2WQWc FAgO1DGGZSxlbIyozexajdF/08hXQB1sQS0AN92Y91jUm5h26Pznq0vvbdnbEB+As2CQ wY7KhwBQa2MucdFHYrSXJO848QhjalaQCHJpqQSicJY7eDKRMitigP7N47fhTxdxKGzc iDGJ4zjF3VYHQQjml8WSjk+k71lwTdI6ZVuSYsX/V5bOkXS8370SMasPIDWxPbVFuZvC o/OQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=igRhD60z; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-86708-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86708-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h6-20020a05620a21c600b0078716503107si1275735qka.767.2024.02.29.04.40.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 04:40:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86708-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=@kernel.org header.s=k20201202 header.b=igRhD60z; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-86708-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86708-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E25A81C20EDF for ; Thu, 29 Feb 2024 12:40:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EED357D403; Thu, 29 Feb 2024 12:40:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="igRhD60z" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.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 EA6807D06E; Thu, 29 Feb 2024 12:40:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709210441; cv=none; b=IHz/uqXJqNZFu9ac2ZJmh4QZTjBxBjbTPBiOqaXXZVDqiFPdPtp4W9TaklVvf4RAyA/a8HCj2CfDKh4hVI36yc1ruIZmbdzM2dV0CEG7VtVy35zs4AR6YbCeHE3FdorCmp/HUvVy+bLqr+7wAUQETuMiKtHexRCaDVzGw9TgQ78= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709210441; c=relaxed/simple; bh=C74fudEZIJp8y6o4pvj1vAj1a7GmlDzym5p5G0Bm6Hg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HVmhGjMymoQJC2MWFbnM/tA18dFjAaon/JVSB75Wir+cmVCWyNYRg4X08MIRboPhcc9OQkbCU7zvZo5zdXbJ1Dju8A8Cfjg/G0hiOLP2fATpis+1eHyOGDe8HWEW+vDayORoJGuDobfOpbr8qZRbXRySR6rHIhsoxW3Sp45kyP4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=igRhD60z; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8281AC433F1; Thu, 29 Feb 2024 12:40:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709210440; bh=C74fudEZIJp8y6o4pvj1vAj1a7GmlDzym5p5G0Bm6Hg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=igRhD60zQhE2flMc7jhx2MrzTM3u1/VMNwCv20yuLsBTePswSGs0X1xa0IEwh6qxp nGmGx20s2y/z2Y/7/x5KxqT2Pad88xVz6DFGlL2yA4QXSg/ZMY7abQgztMXgoYV+l6 NUeKaPE8KreSQ/V4CePVSvOLMtPDBTGxjtGmtRtg70dR30dtLNk9SlFHIpCOi96TLy oqxYya9Bx84enGhB/y1vWh0l5jqH8u4QcGjHP+nlkbvDdQ/xdhjUqF6ABw7RDRbbtn MSrAAgCkrsqv6kkUQSN4WgHTdjz4fPUOQaf27+8z1dJpR+VSCd/y8Caw0vQ+G025fI zmTsCRQmtCINg== Date: Thu, 29 Feb 2024 13:40:29 +0100 From: Niklas Cassel To: Manivannan Sadhasivam Cc: Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?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 , 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 Subject: Re: [PATCH v8 03/10] PCI: dwc: ep: Introduce dw_pcie_ep_cleanup() API for drivers supporting PERST# Message-ID: References: <20240224-pci-dbi-rework-v8-0-64c7fd0cfe64@linaro.org> <20240224-pci-dbi-rework-v8-3-64c7fd0cfe64@linaro.org> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240224-pci-dbi-rework-v8-3-64c7fd0cfe64@linaro.org> On Sat, Feb 24, 2024 at 12:24:09PM +0530, Manivannan Sadhasivam wrote: > 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 > Signed-off-by: Manivannan Sadhasivam > --- > drivers/pci/controller/dwc/pcie-designware-ep.c | 11 +++++++++-- > 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, 17 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c > index 2b11290aab4c..1205bfba8310 100644 > --- a/drivers/pci/controller/dwc/pcie-designware-ep.c > +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c > @@ -564,12 +564,19 @@ int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no, > return 0; > } > > -void dw_pcie_ep_deinit(struct dw_pcie_ep *ep) > +void dw_pcie_ep_cleanup(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); Hello Mani, In this message: https://lore.kernel.org/linux-pci/20240130062938.GB32821@thinkpad/ You mentioned that you were going to clean up the BARs. (Like I wrote in that thread, I really think that we should merge a fix for the broken "do we have a saved value from find_first_zero_bit() in the array", by using a "if (!saved_value[bar])", when find_first_zero_bit() returns zero.) However, regardless of that, I do not see that this series (neither dw_pcie_ep_cleanup(), nor dw_pcie_ep_linkdown()), calls any function which will clean up the BARs. Since e.g. qcom-ep.c does a reset_control_assert() during perst assert/deassert, which should clear sticky registers, I think that you should let dw_pcie_ep_cleanup() clean up the BARs using dw_pcie_ep_clear_bar(). Kind regards, Niklas > +} > +EXPORT_SYMBOL_GPL(dw_pcie_ep_cleanup); > + > +void dw_pcie_ep_deinit(struct dw_pcie_ep *ep) > +{ > + struct pci_epc *epc = ep->epc; > + > + 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 >