From: Bjorn Helgaas <helgaas@kernel.org>
To: Shashank Babu Chinta Venkata <quic_schintav@quicinc.com>
Cc: agross@kernel.org, andersson@kernel.org,
konrad.dybcio@linaro.org, mani@kernel.org,
quic_msarkar@quicinc.com, quic_kraravin@quicinc.com,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
"Serge Semin" <fancer.lancer@gmail.com>,
"Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>,
"Conor Dooley" <conor.dooley@microchip.com>,
"Josh Triplett" <josh@joshtriplett.org>,
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
Date: Fri, 1 Mar 2024 13:44:56 -0600 [thread overview]
Message-ID: <20240301194456.GA405061@bhelgaas> (raw)
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 <quic_schintav@quicinc.com>
> ---
> 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 <linux/pci.h>
> +#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;
> +}
next prev parent reply other threads:[~2024-03-01 19:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-01 5:11 [PATCH v1 0/3] Add Gen4 equalization and margining settings Shashank Babu Chinta Venkata
2024-03-01 5:11 ` [PATCH v1 1/3] PCI: dwc: refactor common code Shashank Babu Chinta Venkata
2024-03-01 5:22 ` Frank Li
2024-03-01 19:44 ` Bjorn Helgaas [this message]
2024-03-04 17:28 ` Manivannan Sadhasivam
2024-03-01 23:30 ` Konrad Dybcio
2024-03-01 5:11 ` [PATCH v1 2/3] PCI: dwc: add equalization settings for gen4 Shashank Babu Chinta Venkata
2024-03-01 20:00 ` Bjorn Helgaas
2024-03-19 11:07 ` Shashank Babu Chinta Venkata
2024-03-01 5:11 ` [PATCH v1 3/3] PCI: dwc: add rx margining " Shashank Babu Chinta Venkata
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240301194456.GA405061@bhelgaas \
--to=helgaas@kernel.org \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=bhelgaas@google.com \
--cc=conor.dooley@microchip.com \
--cc=fancer.lancer@gmail.com \
--cc=josh@joshtriplett.org \
--cc=konrad.dybcio@linaro.org \
--cc=kw@linux.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=quic_kraravin@quicinc.com \
--cc=quic_msarkar@quicinc.com \
--cc=quic_schintav@quicinc.com \
--cc=robh@kernel.org \
--cc=yoshihiro.shimoda.uh@renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox