From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2E427C5475B for ; Fri, 8 Mar 2024 09:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8WkrNjzeyhGGdHkmxmf4+qh2ghCJkHIo8akzGzmk89Q=; b=wDrCmTzUmgVeaA cT/Qbv+G6gTI7K2IUjHVVxfl7h0fcWLW8s+gZJMoMBFzbq0gtSBKlf98c0c3RFdPLsTTRisEiTAOq qUVU1/sNumivUjJgtljIq4cPVcKHN/oOEu/O0Ka1gLMM5OyWGwZ4tQS1qf/McKYiZRVONsRPxEzQM fPFHrJ05Q6MhDfbDwZCP3hjsXrCRz0C2kVVHvHpY2enu3ZAX8DlP8MCzCVoSPsoNH86JLlfYkHYDf 9HJY2g+acuZyp4HTT3f2s5rsP+mpT8ZeCoR9EZ8xgT+yxj2JfxvsVKKUriRAtdjw+Y72QG5Y6/a0a 8SDot93rrdmdA093BcvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1riWAQ-00000008UtB-258t; Fri, 08 Mar 2024 09:05:26 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1riWAN-00000008Ur5-23oG for linux-arm-kernel@lists.infradead.org; Fri, 08 Mar 2024 09:05:24 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 84CF561DB8; Fri, 8 Mar 2024 09:05:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6806C433B1; Fri, 8 Mar 2024 09:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709888722; bh=bZE3lLlkuJ7PvYUKEQqczGXk3MirQvfYGrIhBNhV2+0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MWkI4xtHh0q/rku6OXru8Y5F0uyRm3OagmGFpmUyIc2rYcZiMSPOiATfm4KcSiUkW IA/wiVN/IG7POxQlNaaz79LCo+ocHGUmXgYP6x6UEr/8a5tlpJo5msNuAtAERLfowz OydyRBOmxFQHHf4+urZfZqiXS8SHOFOoGxXqRrutLHKA76PqWRFuhnOKTTspI+kuci BQ28JitosqrxLAk3FoKKSH0YNWL74SOgWXdv6mXlpxLAHHLBY1yr79+O6wbAgLS4s4 B4A1F/m+kSB0tUh7hiHLnsNWlFj4wbjuW+NQlJBLF+NrcRpNktQGGd61YzrHsCJ5xm y+8eyn0zKZ4sA== Date: Fri, 8 Mar 2024 10:05:11 +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 , Jesper Nilsson , Srikanth Thokala , 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, linux-arm-kernel@axis.com Subject: Re: [PATCH v9 06/10] PCI: dwc: ep: Call dw_pcie_ep_init_registers() API directly from all glue drivers Message-ID: References: <20240304-pci-dbi-rework-v9-0-29d433d99cda@linaro.org> <20240304-pci-dbi-rework-v9-6-29d433d99cda@linaro.org> <20240308053624.GB3789@thinkpad> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240308053624.GB3789@thinkpad> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240308_010523_663528_265023D3 X-CRM114-Status: GOOD ( 33.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Mar 08, 2024 at 11:06:24AM +0530, Manivannan Sadhasivam wrote: > On Thu, Mar 07, 2024 at 09:36:56PM +0100, Niklas Cassel wrote: > > On Mon, Mar 04, 2024 at 02:52:18PM +0530, Manivannan Sadhasivam wrote: > > > Currently, dw_pcie_ep_init_registers() API is directly called by the glue > > > drivers requiring active refclk from host. But for the other drivers, it is > > > getting called implicitly by dw_pcie_ep_init(). This is due to the fact > > > that this API initializes DWC EP specific registers and that requires an > > > active refclk (either from host or generated locally by endpoint itsef). > > > > > > But, this causes a discrepancy among the glue drivers. So to avoid this > > > confusion, let's call this API directly from all glue drivers irrespective > > > of refclk dependency. Only difference here is that the drivers requiring > > > refclk from host will call this API only after the refclk is received and > > > other drivers without refclk dependency will call this API right after > > > dw_pcie_ep_init(). > > > > > > With this change, the check for 'core_init_notifier' flag can now be > > > dropped from dw_pcie_ep_init() API. This will also allow us to remove the > > > 'core_init_notifier' flag completely in the later commits. > > > > > > Signed-off-by: Manivannan Sadhasivam > > > --- > > > drivers/pci/controller/dwc/pci-dra7xx.c | 7 +++++++ > > > drivers/pci/controller/dwc/pci-imx6.c | 8 ++++++++ > > > drivers/pci/controller/dwc/pci-keystone.c | 9 +++++++++ > > > drivers/pci/controller/dwc/pci-layerscape-ep.c | 7 +++++++ > > > drivers/pci/controller/dwc/pcie-artpec6.c | 13 ++++++++++++- > > > drivers/pci/controller/dwc/pcie-designware-ep.c | 22 ---------------------- > > > drivers/pci/controller/dwc/pcie-designware-plat.c | 9 +++++++++ > > > drivers/pci/controller/dwc/pcie-keembay.c | 16 +++++++++++++++- > > > drivers/pci/controller/dwc/pcie-rcar-gen4.c | 12 +++++++++++- > > > drivers/pci/controller/dwc/pcie-uniphier-ep.c | 13 ++++++++++++- > > > 10 files changed, 90 insertions(+), 26 deletions(-) > > > > > > diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c > > > index 0e406677060d..395042b29ffc 100644 > > > --- a/drivers/pci/controller/dwc/pci-dra7xx.c > > > +++ b/drivers/pci/controller/dwc/pci-dra7xx.c > > > @@ -467,6 +467,13 @@ static int dra7xx_add_pcie_ep(struct dra7xx_pcie *dra7xx, > > > return ret; > > > } > > > > > > + ret = dw_pcie_ep_init_registers(ep); > > > + if (ret) { > > > > Here you are using if (ret) to error check the return from > > dw_pcie_ep_init_registers(). > > > > > > > index c0c62533a3f1..8392894ed286 100644 > > > --- a/drivers/pci/controller/dwc/pci-keystone.c > > > +++ b/drivers/pci/controller/dwc/pci-keystone.c > > > @@ -1286,6 +1286,13 @@ static int ks_pcie_probe(struct platform_device *pdev) > > > ret = dw_pcie_ep_init(&pci->ep); > > > if (ret < 0) > > > goto err_get_sync; > > > + > > > + ret = dw_pcie_ep_init_registers(&pci->ep); > > > + if (ret < 0) { > > > > Here you are using if (ret < 0) to error check the return from > > dw_pcie_ep_init_registers(). Please be consistent. > > > > I maintained the consistency w.r.t individual drivers. Please check them > individually. > > If I maintain consistency w.r.t this patch, then the style will change within > the drivers. Personally, I disagree with that. All glue drivers should use the same way of checking dw_pcie_ep_init(), depending on the kdoc of dw_pcie_ep_init(). If the kdoc for dw_pcie_ep_init() says returns 0 on success, then I think that it is strictly more correct to do: ret = dw_pcie_ep_init() if (ret) { } And if a glue driver doesn't look like that, then I think we should change them. (Same reasoning for dw_pcie_ep_init_registers().) If you read code that looks like: ret = dw_pcie_ep_init() if (ret < 0) { } then you assume that is is a function with a kdoc that says it can return 0 or a positive value on success, e.g. a function that returns an index in an array. Kind regards, Niklas _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel