From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: "Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
"Minghuan Lian" <minghuan.Lian@nxp.com>,
"Mingkai Hu" <mingkai.hu@nxp.com>, "Roy Zang" <roy.zang@nxp.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Jingoo Han" <jingoohan1@gmail.com>,
"Gustavo Pimentel" <gustavo.pimentel@synopsys.com>,
"Serge Semin" <fancer.lancer@gmail.com>,
"Alexey Malahov" <Alexey.Malahov@baikalelectronics.ru>,
"Pavel Parkhomenko" <Pavel.Parkhomenko@baikalelectronics.ru>,
"Frank Li" <Frank.Li@nxp.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH RESEND v5 13/18] PCI: dwc: Add start_link/stop_link inliners
Date: Tue, 28 Jun 2022 12:13:13 +0530 [thread overview]
Message-ID: <20220628064313.GF23601@thinkpad> (raw)
In-Reply-To: <20220624143428.8334-14-Sergey.Semin@baikalelectronics.ru>
On Fri, Jun 24, 2022 at 05:34:23PM +0300, Serge Semin wrote:
> There are several places in the generic DW PCIe code where the
> platform-specific PCIe link start/stop methods are called after making
> sure the ops handler and the callbacks are specified. Instead of repeating
> the same pattern over and over let's define the static-inline methods in
> the DW PCIe header file and use them in the relevant parts of the driver.
>
> Note returning a negative error from the EP link start procedure if the
> start_link pointer isn't specified doesn't really make much sense since
> it's perfectly normal to have such a platform. Moreover even
> pci_epc_start() doesn't fail if no epc->ops->start callback is spotted. As
> a side-effect of this modification we can set the generic DW PCIe and
> Layerscape EP platform drivers free from the empty start_link callbacks
> and as such entirely dummy dw_pcie_ops instances.
>
> Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Thanks,
Mani
> Reviewed-by: Rob Herring <robh@kernel.org>
>
> ---
>
> Changelog v4:
> - This is a new patch created on the v4 lap of the series.
> ---
> drivers/pci/controller/dwc/pci-layerscape-ep.c | 12 ------------
> drivers/pci/controller/dwc/pcie-designware-ep.c | 8 ++------
> drivers/pci/controller/dwc/pcie-designware-host.c | 10 ++++------
> drivers/pci/controller/dwc/pcie-designware-plat.c | 10 ----------
> drivers/pci/controller/dwc/pcie-designware.h | 14 ++++++++++++++
> 5 files changed, 20 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c
> index 39f4664bd84c..ad99707b3b99 100644
> --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c
> +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c
> @@ -32,15 +32,6 @@ struct ls_pcie_ep {
> const struct ls_pcie_ep_drvdata *drvdata;
> };
>
> -static int ls_pcie_establish_link(struct dw_pcie *pci)
> -{
> - return 0;
> -}
> -
> -static const struct dw_pcie_ops dw_ls_pcie_ep_ops = {
> - .start_link = ls_pcie_establish_link,
> -};
> -
> static const struct pci_epc_features*
> ls_pcie_ep_get_features(struct dw_pcie_ep *ep)
> {
> @@ -106,19 +97,16 @@ static const struct dw_pcie_ep_ops ls_pcie_ep_ops = {
>
> static const struct ls_pcie_ep_drvdata ls1_ep_drvdata = {
> .ops = &ls_pcie_ep_ops,
> - .dw_pcie_ops = &dw_ls_pcie_ep_ops,
> };
>
> static const struct ls_pcie_ep_drvdata ls2_ep_drvdata = {
> .func_offset = 0x20000,
> .ops = &ls_pcie_ep_ops,
> - .dw_pcie_ops = &dw_ls_pcie_ep_ops,
> };
>
> static const struct ls_pcie_ep_drvdata lx2_ep_drvdata = {
> .func_offset = 0x8000,
> .ops = &ls_pcie_ep_ops,
> - .dw_pcie_ops = &dw_ls_pcie_ep_ops,
> };
>
> static const struct of_device_id ls_pcie_ep_of_match[] = {
> diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
> index 7ad349c32082..15b8059544e3 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> @@ -435,8 +435,7 @@ static void dw_pcie_ep_stop(struct pci_epc *epc)
> struct dw_pcie_ep *ep = epc_get_drvdata(epc);
> struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
>
> - if (pci->ops && pci->ops->stop_link)
> - pci->ops->stop_link(pci);
> + dw_pcie_stop_link(pci);
> }
>
> static int dw_pcie_ep_start(struct pci_epc *epc)
> @@ -444,10 +443,7 @@ static int dw_pcie_ep_start(struct pci_epc *epc)
> struct dw_pcie_ep *ep = epc_get_drvdata(epc);
> struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
>
> - if (!pci->ops || !pci->ops->start_link)
> - return -EINVAL;
> -
> - return pci->ops->start_link(pci);
> + return dw_pcie_start_link(pci);
> }
>
> static const struct pci_epc_features*
> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
> index 2f13eec4812d..c49a3bde7a2a 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-host.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c
> @@ -409,8 +409,8 @@ int dw_pcie_host_init(struct pcie_port *pp)
>
> dw_pcie_setup_rc(pp);
>
> - if (!dw_pcie_link_up(pci) && pci->ops && pci->ops->start_link) {
> - ret = pci->ops->start_link(pci);
> + if (!dw_pcie_link_up(pci)) {
> + ret = dw_pcie_start_link(pci);
> if (ret)
> goto err_free_msi;
> }
> @@ -427,8 +427,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
> return 0;
>
> err_stop_link:
> - if (pci->ops && pci->ops->stop_link)
> - pci->ops->stop_link(pci);
> + dw_pcie_stop_link(pci);
>
> err_free_msi:
> if (pp->has_msi_ctrl)
> @@ -444,8 +443,7 @@ void dw_pcie_host_deinit(struct pcie_port *pp)
> pci_stop_root_bus(pp->bridge->bus);
> pci_remove_root_bus(pp->bridge->bus);
>
> - if (pci->ops && pci->ops->stop_link)
> - pci->ops->stop_link(pci);
> + dw_pcie_stop_link(pci);
>
> if (pp->has_msi_ctrl)
> dw_pcie_free_msi(pp);
> diff --git a/drivers/pci/controller/dwc/pcie-designware-plat.c b/drivers/pci/controller/dwc/pcie-designware-plat.c
> index 0c5de87d3cc6..abf1afac6064 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-plat.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-plat.c
> @@ -36,15 +36,6 @@ static const struct of_device_id dw_plat_pcie_of_match[];
> static const struct dw_pcie_host_ops dw_plat_pcie_host_ops = {
> };
>
> -static int dw_plat_pcie_establish_link(struct dw_pcie *pci)
> -{
> - return 0;
> -}
> -
> -static const struct dw_pcie_ops dw_pcie_ops = {
> - .start_link = dw_plat_pcie_establish_link,
> -};
> -
> static void dw_plat_pcie_ep_init(struct dw_pcie_ep *ep)
> {
> struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> @@ -140,7 +131,6 @@ static int dw_plat_pcie_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> pci->dev = dev;
> - pci->ops = &dw_pcie_ops;
>
> dw_plat_pcie->pci = pci;
> dw_plat_pcie->mode = mode;
> diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> index 7d6e9b7576be..8ba239292634 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.h
> +++ b/drivers/pci/controller/dwc/pcie-designware.h
> @@ -365,6 +365,20 @@ static inline void dw_pcie_dbi_ro_wr_dis(struct dw_pcie *pci)
> dw_pcie_writel_dbi(pci, reg, val);
> }
>
> +static inline int dw_pcie_start_link(struct dw_pcie *pci)
> +{
> + if (pci->ops && pci->ops->start_link)
> + return pci->ops->start_link(pci);
> +
> + return 0;
> +}
> +
> +static inline void dw_pcie_stop_link(struct dw_pcie *pci)
> +{
> + if (pci->ops && pci->ops->stop_link)
> + pci->ops->stop_link(pci);
> +}
> +
> #ifdef CONFIG_PCIE_DW_HOST
> irqreturn_t dw_handle_msi_irq(struct pcie_port *pp);
> void dw_pcie_setup_rc(struct pcie_port *pp);
> --
> 2.35.1
>
--
மணிவண்ணன் சதாசிவம்
next prev parent reply other threads:[~2022-06-28 6:43 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-24 14:34 [PATCH RESEND v5 00/18] PCI: dwc: Various fixes and cleanups Serge Semin
2022-06-24 14:34 ` [PATCH RESEND v5 01/18] PCI: dwc: Stop link in the host init error and de-initialization Serge Semin
2022-06-24 14:34 ` [PATCH RESEND v5 02/18] PCI: dwc: Add unroll iATU space support to the regions disable method Serge Semin
2022-06-24 14:34 ` [PATCH RESEND v5 03/18] PCI: dwc: Disable outbound windows for controllers with iATU Serge Semin
2022-06-27 22:40 ` Bjorn Helgaas
2022-06-28 11:42 ` Serge Semin
2022-06-24 14:34 ` [PATCH RESEND v5 04/18] PCI: dwc: Set INCREASE_REGION_SIZE flag based on limit address Serge Semin
2022-06-24 14:34 ` [PATCH RESEND v5 05/18] PCI: dwc: Deallocate EPC memory on EP init error Serge Semin
2022-06-28 6:35 ` Manivannan Sadhasivam
2022-06-24 14:34 ` [PATCH RESEND v5 06/18] PCI: dwc: Enable CDM-check independently from the num_lanes value Serge Semin
2022-06-28 6:37 ` Manivannan Sadhasivam
2022-06-24 14:34 ` [PATCH RESEND v5 07/18] PCI: dwc: Add braces to the multi-line if-else statements Serge Semin
2022-06-24 14:34 ` [PATCH RESEND v5 08/18] PCI: dwc: Add trailing new-line literals to the log messages Serge Semin
2022-06-24 14:34 ` [PATCH RESEND v5 09/18] PCI: dwc: Discard IP-core version checking on unrolled iATU detection Serge Semin
2022-06-24 14:34 ` [PATCH RESEND v5 10/18] PCI: dwc: Convert Link-up status method to using dw_pcie_readl_dbi() Serge Semin
2022-06-24 14:34 ` [PATCH RESEND v5 11/18] PCI: dwc: Organize local variables usage Serge Semin
2022-06-28 6:38 ` Manivannan Sadhasivam
2022-06-28 23:33 ` Bjorn Helgaas
2022-06-29 2:03 ` Serge Semin
2022-06-24 14:34 ` [PATCH RESEND v5 12/18] PCI: dwc: Re-use local pointer to the resource data Serge Semin
2022-06-28 6:39 ` Manivannan Sadhasivam
2022-06-24 14:34 ` [PATCH RESEND v5 13/18] PCI: dwc: Add start_link/stop_link inliners Serge Semin
2022-06-28 6:43 ` Manivannan Sadhasivam [this message]
2022-06-24 14:34 ` [PATCH RESEND v5 14/18] PCI: dwc: Move io_cfg_atu_shared to the Root Port descriptor Serge Semin
2022-06-28 6:44 ` Manivannan Sadhasivam
2022-06-24 14:34 ` [PATCH RESEND v5 15/18] PCI: dwc: Add dw_ prefix to the pcie_port structure name Serge Semin
2022-06-27 11:47 ` Jesper Nilsson
2022-06-27 12:16 ` Neil Armstrong
2022-06-28 6:46 ` Manivannan Sadhasivam
2022-06-24 14:34 ` [PATCH RESEND v5 16/18] PCI: dwc-plat: Simplify the probe method return value handling Serge Semin
2022-06-24 14:34 ` [PATCH RESEND v5 17/18] PCI: dwc-plat: Discard unused regmap pointer Serge Semin
2022-06-24 14:34 ` [PATCH RESEND v5 18/18] PCI: dwc-plat: Drop dw_plat_pcie_of_match forward declaration Serge Semin
2022-06-28 6:58 ` [PATCH RESEND v5 00/18] PCI: dwc: Various fixes and cleanups Manivannan Sadhasivam
2022-06-28 11:57 ` Serge Semin
2022-06-28 23:35 ` Bjorn Helgaas
2022-06-29 1:38 ` Serge Semin
2022-07-11 18:40 ` Serge Semin
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=20220628064313.GF23601@thinkpad \
--to=manivannan.sadhasivam@linaro.org \
--cc=Alexey.Malahov@baikalelectronics.ru \
--cc=Frank.Li@nxp.com \
--cc=Pavel.Parkhomenko@baikalelectronics.ru \
--cc=Sergey.Semin@baikalelectronics.ru \
--cc=bhelgaas@google.com \
--cc=fancer.lancer@gmail.com \
--cc=gustavo.pimentel@synopsys.com \
--cc=jingoohan1@gmail.com \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=lpieralisi@kernel.org \
--cc=minghuan.Lian@nxp.com \
--cc=mingkai.hu@nxp.com \
--cc=robh@kernel.org \
--cc=roy.zang@nxp.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;
as well as URLs for NNTP newsgroup(s).