Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp509531lqg; Fri, 1 Mar 2024 11:45:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWPFW91xY9Z0cikAfZJoFvjT1TTDRAjvpeBF2qtyxv4FpUoLPgRvNKiUpQ7iQvEOhMdGOpm1KkDLhZTgrZfa9YfzAJJe/ymmtGVdzmUsg== X-Google-Smtp-Source: AGHT+IHzS9dCUuS1igtuyQriWI/yv87oPTHh1jSWHgQHmHzC6xNTtY+Jik0JgGZQCs37aZ1ZRCrM X-Received: by 2002:a17:906:1b06:b0:a44:797a:2485 with SMTP id o6-20020a1709061b0600b00a44797a2485mr2319809ejg.19.1709322307243; Fri, 01 Mar 2024 11:45:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709322307; cv=pass; d=google.com; s=arc-20160816; b=ns4A1Uz8Y2X/oxudDeZq8ZIql3bKpTqUjqaGomQ3mNdpRUwy3IO5ll6SMjQF943KYG WgvNXDRXfzqUHH/bm2/kGM4BRWzfDjoHwE6tYqwBQZiFDqJBwcv4A1dEZ/8mnax5b2SV Zn2g/Qu2uStDeYexKwypVyKpF0/q6DKMTfc6kIfa461Ugn8p6fIGtGMRFtl63FYGgvUq tRSThX5hwtaiWx6cCbeZJVoQGy09I5QGHR0E5nHxlYyWqvQkD4fmxgidrRUW4nFcJ9iA kxZcRIeO90+Cm93Ok7esVzg608XNQ6QMOmzGQr13hHOhAYX8qgdsptsZAMOO/I4HHLp9 QZ0g== 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:message-id:subject:cc:to:from :date:dkim-signature; bh=E5TqI/cKf7XoIx1Plm/UupFEfuQTr5n1O71dbhkK90g=; fh=EJixKwi4ANjrmkxVmx0FN2qD88GEpylMmWKM2zUyGcQ=; b=rtI1/6xaJQowidHIQFYRRJmRWmub5Oj4Ba2llZa3xNWANOaXCizsm2onak25xUPRWs qq+E7gPNqFFHqEJpG2PBptR2GJxx1buvp3wX/bv77na1l1rGboI3Z+Jp+nI/fc+hHw+H tnM00si2LbdmwRpmHRkq4vx/tvrASuHxPNeqUWT1R++qwAW9TpL8gejmKk0TAwG9Ns+O ncrqvM3qOZ25nj7bcU+KGCxTmwqkg4eR2BQUTlT+92M1XT3carUA2T9ZDWUwHcn56B+n iBUS878j2G7bZV7SCX5+CrgwEQTApcAMPY05Qgv2CxvtpRBjPdlmKErYULLDz9Jd60hD XBEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QhADx1af; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-89048-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89048-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id mc5-20020a170906eb4500b00a43c5d522a7si1707952ejb.103.2024.03.01.11.45.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 11:45:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89048-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=@kernel.org header.s=k20201202 header.b=QhADx1af; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-89048-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89048-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 am.mirrors.kernel.org (Postfix) with ESMTPS id EC5491F23956 for ; Fri, 1 Mar 2024 19:45:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E74913BB25; Fri, 1 Mar 2024 19:44:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QhADx1af" 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 0CD6420DCD; Fri, 1 Mar 2024 19:44:58 +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=1709322299; cv=none; b=ZEgcHIqd2+jM4oXnXEaOi5P/wVQno4kCnBpKVudOJbhJpUgLAD0cGz28+GMg6ROB0jlckLYa1mHFb87frA5yfDihAP7DYtbQ/VtXjK/j0HPeVE4+k3/GpPfcZ+koWS97enObSp/mhbAPAq6wvl9HWgkI5E4U29wrLkBEhx9j24o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709322299; c=relaxed/simple; bh=8lwYTHmcz1N3RNwv/Abs9wbTECfpsDj44DA5D9MMh9g=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=JnN6wkJKkHcxdkxgbGgWm+vQVvMj23jr6r77aDXueUbIJrO/qG9Fwl96nFAdtrPsGALLjij2JMbvCEpI2yXm2oAj1LOMTx0T3Y71kHGp0UdPSrQ/i2fVptWC6rNBQzXal5oBIZf0Rx0tse7+9DCIQPhrpMEFU8xorRYLjeBCEcY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QhADx1af; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DDEBC433F1; Fri, 1 Mar 2024 19:44:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709322298; bh=8lwYTHmcz1N3RNwv/Abs9wbTECfpsDj44DA5D9MMh9g=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=QhADx1afMqH/uKdM+aDqalPjrFzmzQWyhj/ZacgFr/gMqeLhhU4OH/z3UhDO3V4Bq y732d0Zc1y6/MAdHt4zE199vlFklIzicS1f3BxcVhuVMJ2/6y7BN99pMwqzaO50ID7 g8dCljTYocEx4eFOTSR9wRiIIRt9FPE5+HLbrd2OSY+JU9qlgn2cs61l18dYoZlOrT lH4/CKDeTB1W0MAN+JyncS9g3XCI/tlKHTXnZXovWlKKWoCKt62hO8EFkQOabPAYtL 9MTQKQxkPBhyec4626FFP1b5avopg9+LTsJFe1IUHYGnwt/Mxf221oCPTtBtngortI DMrhIQGWImpcw== Date: Fri, 1 Mar 2024 13:44:56 -0600 From: Bjorn Helgaas To: Shashank Babu Chinta Venkata Cc: agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, mani@kernel.org, quic_msarkar@quicinc.com, quic_kraravin@quicinc.com, Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Manivannan Sadhasivam , Serge Semin , Yoshihiro Shimoda , Conor Dooley , Josh Triplett , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH v1 1/3] PCI: dwc: refactor common code Message-ID: <20240301194456.GA405061@bhelgaas> 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: <20240301051220.20917-2-quic_schintav@quicinc.com> On Thu, Feb 29, 2024 at 09:11:34PM -0800, Shashank Babu Chinta Venkata wrote: > Refactor common code from RC(Root Complex) and EP(End Point) > drivers and move them to a common repository. This acts as placeholder > for common source code for both drivers avoiding duplication. > > Signed-off-by: Shashank Babu Chinta Venkata > --- > drivers/pci/controller/dwc/Kconfig | 5 ++ > drivers/pci/controller/dwc/Makefile | 1 + > drivers/pci/controller/dwc/pcie-qcom-cmn.c | 85 ++++++++++++++++++++++ > drivers/pci/controller/dwc/pcie-qcom-cmn.h | 30 ++++++++ > drivers/pci/controller/dwc/pcie-qcom-ep.c | 39 +--------- > drivers/pci/controller/dwc/pcie-qcom.c | 67 ++--------------- > 6 files changed, 133 insertions(+), 94 deletions(-) > create mode 100644 drivers/pci/controller/dwc/pcie-qcom-cmn.c > create mode 100644 drivers/pci/controller/dwc/pcie-qcom-cmn.h Hmm. I'm a little ambivalent about adding two new files. Overall I think I prefer the drivers that include both RC and EP mode in a single source file because one file is easier to browse than four and more things can be static. A single file would also reduce quite a bit more duplication between pcie-qcom.c and pcie-qcom-ep.c, e.g., register names and fields with needlessly different names: #define AUX_PWR_DET BIT(4) # pcie-qcom.c #define PARF_SYS_CTRL_AUX_PWR_DET BIT(4) # pcie-qcom-ep.c I do see PCIE_QCOM is bool and PCIE_QCOM_EP is tristate, so that and other considerations might make a single source file impractical. > +++ b/drivers/pci/controller/dwc/Makefile > @@ -27,6 +27,7 @@ obj-$(CONFIG_PCIE_UNIPHIER) += pcie-uniphier.o > obj-$(CONFIG_PCIE_UNIPHIER_EP) += pcie-uniphier-ep.o > obj-$(CONFIG_PCIE_VISCONTI_HOST) += pcie-visconti.o > obj-$(CONFIG_PCIE_RCAR_GEN4) += pcie-rcar-gen4.o > +obj-$(CONFIG_PCIE_QCOM_CMN) += pcie-qcom-cmn.o If we have to have pcie-qcom-cmn.o, at least move this next to the existing lines: obj-$(CONFIG_PCIE_QCOM) += pcie-qcom.o obj-$(CONFIG_PCIE_QCOM_EP) += pcie-qcom-ep.o > +++ b/drivers/pci/controller/dwc/pcie-qcom-cmn.c > @@ -0,0 +1,85 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (c) 2014-2015, 2020 The Linux Foundation. All rights reserved. > + * Copyright 2015, 2021 Linaro Limited. > + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. > + * Spurious blank line. > +int qcom_pcie_cmn_icc_get_resource(struct dw_pcie *pci, struct icc_path *icc_mem) I don't see the value of adding "cmn" in the middle of the names. > +{ > + int ret = 0; > + > + if (IS_ERR(pci)) > + return PTR_ERR(pci); > + > + icc_mem = devm_of_icc_get(pci->dev, "pcie-mem"); > + if (IS_ERR(icc_mem)) > + return PTR_ERR(icc_mem); > + > + return ret; No need for the "ret" variable since it's never assigned. "return 0" here would be easier to read. > +int qcom_pcie_cmn_icc_init(struct dw_pcie *pci, struct icc_path *icc_mem) > +{ > + int ret = 0; Unnecessary initialization. > +++ b/drivers/pci/controller/dwc/pcie-qcom-cmn.h > @@ -0,0 +1,30 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Copyright (c) 2014-2015, 2020 The Linux Foundation. All rights reserved. > + * Copyright 2015, 2021 Linaro Limited. > + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. > + */ > + > +#include > +#include "../../pci.h" > +#include "pcie-designware.h" > + > +#ifdef CONFIG_PCIE_QCOM_CMN Why the #ifdef wrapper? And why do we need the stubs when CONFIG_PCIE_QCOM_CMN isn't defined? > +#else > +static inline int qcom_pcie_cmn_icc_get_resource(struct dw_pcie *pci, struct icc_path *icc_mem) > +{ > + return 0; > +}