diff mbox series

[v18,13/20] PCI: dwc: Introduce .ep_pre_init() and .ep_deinit()

Message ID 20230721074452.65545-14-yoshihiro.shimoda.uh@renesas.com (mailing list archive)
State Superseded
Delegated to: Krzysztof Wilczyński
Headers show
Series PCI: rcar-gen4: Add R-Car Gen4 PCIe support | expand

Commit Message

Yoshihiro Shimoda July 21, 2023, 7:44 a.m. UTC
Renesas R-Car Gen4 PCIe controllers require vender-specific
initialization before .ep_init(). To use dw->dbi and dw->num-lanes
in the initialization code, introduce .ep_pre_init() into struct
dw_pcie_ep_ops. Also introduce .ep_deinit() to disable the controller
by using vender-specific de-initialization.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/pci/controller/dwc/pcie-designware-ep.c | 6 ++++++
 drivers/pci/controller/dwc/pcie-designware.h    | 2 ++
 2 files changed, 8 insertions(+)

Comments

Sergey Shtylyov July 21, 2023, 9:23 a.m. UTC | #1
On 7/21/23 10:44 AM, Yoshihiro Shimoda wrote:

> Renesas R-Car Gen4 PCIe controllers require vender-specific

   It's "vendor". :-)

> initialization before .ep_init(). To use dw->dbi and dw->num-lanes
> in the initialization code, introduce .ep_pre_init() into struct
> dw_pcie_ep_ops. Also introduce .ep_deinit() to disable the controller
> by using vender-specific de-initialization.
> 
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
[...]

MBR, Sergey
Manivannan Sadhasivam July 24, 2023, 11:40 a.m. UTC | #2
On Fri, Jul 21, 2023 at 04:44:45PM +0900, Yoshihiro Shimoda wrote:
> Renesas R-Car Gen4 PCIe controllers require vender-specific
> initialization before .ep_init(). To use dw->dbi and dw->num-lanes
> in the initialization code, introduce .ep_pre_init() into struct
> dw_pcie_ep_ops. Also introduce .ep_deinit() to disable the controller
> by using vender-specific de-initialization.
> 
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
>  drivers/pci/controller/dwc/pcie-designware-ep.c | 6 ++++++
>  drivers/pci/controller/dwc/pcie-designware.h    | 2 ++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
> index 14c641395c3b..52b3e7f67513 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> @@ -684,6 +684,9 @@ void dw_pcie_ep_exit(struct dw_pcie_ep *ep)
>  	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
>  	struct pci_epc *epc = ep->epc;
>  
> +	if (ep->ops->ep_deinit)
> +		ep->ops->ep_deinit(ep);
> +
>  	dw_pcie_edma_remove(pci);
>  
>  	if (ep->intx_mem)
> @@ -797,6 +800,9 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)
>  	ep->phys_base = res->start;
>  	ep->addr_size = resource_size(res);
>  
> +	if (ep->ops->ep_pre_init)
> +		ep->ops->ep_pre_init(ep);
> +
>  	dw_pcie_version_detect(pci);
>  
>  	dw_pcie_iatu_detect(pci);
> diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> index 6821446d7c66..c3aeafd0f4c9 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.h
> +++ b/drivers/pci/controller/dwc/pcie-designware.h
> @@ -332,7 +332,9 @@ struct dw_pcie_rp {
>  };
>  
>  struct dw_pcie_ep_ops {
> +	void	(*ep_pre_init)(struct dw_pcie_ep *ep);
>  	void	(*ep_init)(struct dw_pcie_ep *ep);
> +	void	(*ep_deinit)(struct dw_pcie_ep *ep);

Since the struct name itself has "ep", there is no need to add the "ep" suffix
to callbacks. You should fix the existing ep_init callback too in a separate
patch.

(this series is just GROWING!!!)

- Mani

>  	int	(*raise_irq)(struct dw_pcie_ep *ep, u8 func_no,
>  			     enum pci_epc_irq_type type, u16 interrupt_num);
>  	const struct pci_epc_features* (*get_features)(struct dw_pcie_ep *ep);
> -- 
> 2.25.1
>
Yoshihiro Shimoda July 26, 2023, 3:02 a.m. UTC | #3
Hi Manivannan,

> From: Manivannan Sadhasivam, Sent: Monday, July 24, 2023 8:40 PM
> 
> On Fri, Jul 21, 2023 at 04:44:45PM +0900, Yoshihiro Shimoda wrote:
> > Renesas R-Car Gen4 PCIe controllers require vender-specific
> > initialization before .ep_init(). To use dw->dbi and dw->num-lanes
> > in the initialization code, introduce .ep_pre_init() into struct
> > dw_pcie_ep_ops. Also introduce .ep_deinit() to disable the controller
> > by using vender-specific de-initialization.
> >
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > ---
> >  drivers/pci/controller/dwc/pcie-designware-ep.c | 6 ++++++
> >  drivers/pci/controller/dwc/pcie-designware.h    | 2 ++
> >  2 files changed, 8 insertions(+)
> >
> > diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
> > index 14c641395c3b..52b3e7f67513 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> > +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> > @@ -684,6 +684,9 @@ void dw_pcie_ep_exit(struct dw_pcie_ep *ep)
> >  	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> >  	struct pci_epc *epc = ep->epc;
> >
> > +	if (ep->ops->ep_deinit)
> > +		ep->ops->ep_deinit(ep);
> > +
> >  	dw_pcie_edma_remove(pci);
> >
> >  	if (ep->intx_mem)
> > @@ -797,6 +800,9 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)
> >  	ep->phys_base = res->start;
> >  	ep->addr_size = resource_size(res);
> >
> > +	if (ep->ops->ep_pre_init)
> > +		ep->ops->ep_pre_init(ep);
> > +
> >  	dw_pcie_version_detect(pci);
> >
> >  	dw_pcie_iatu_detect(pci);
> > diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> > index 6821446d7c66..c3aeafd0f4c9 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware.h
> > +++ b/drivers/pci/controller/dwc/pcie-designware.h
> > @@ -332,7 +332,9 @@ struct dw_pcie_rp {
> >  };
> >
> >  struct dw_pcie_ep_ops {
> > +	void	(*ep_pre_init)(struct dw_pcie_ep *ep);
> >  	void	(*ep_init)(struct dw_pcie_ep *ep);
> > +	void	(*ep_deinit)(struct dw_pcie_ep *ep);
> 
> Since the struct name itself has "ep", there is no need to add the "ep" suffix
> to callbacks. You should fix the existing ep_init callback too in a separate
> patch.

I got it. I'll make such a separate patch before this patch.

Best regards,
Yoshihiro Shimoda

> (this series is just GROWING!!!)
> 
> - Mani
> 
> >  	int	(*raise_irq)(struct dw_pcie_ep *ep, u8 func_no,
> >  			     enum pci_epc_irq_type type, u16 interrupt_num);
> >  	const struct pci_epc_features* (*get_features)(struct dw_pcie_ep *ep);
> > --
> > 2.25.1
> >
> 
> --
> மணிவண்ணன் சதாசிவம்
Serge Semin Aug. 1, 2023, 12:15 a.m. UTC | #4
On Wed, Jul 26, 2023 at 03:02:13AM +0000, Yoshihiro Shimoda wrote:
> Hi Manivannan,
> 
> > From: Manivannan Sadhasivam, Sent: Monday, July 24, 2023 8:40 PM
> > 
> > On Fri, Jul 21, 2023 at 04:44:45PM +0900, Yoshihiro Shimoda wrote:
> > > Renesas R-Car Gen4 PCIe controllers require vender-specific
> > > initialization before .ep_init(). To use dw->dbi and dw->num-lanes
> > > in the initialization code, introduce .ep_pre_init() into struct
> > > dw_pcie_ep_ops. Also introduce .ep_deinit() to disable the controller
> > > by using vender-specific de-initialization.
> > >
> > > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > > ---
> > >  drivers/pci/controller/dwc/pcie-designware-ep.c | 6 ++++++
> > >  drivers/pci/controller/dwc/pcie-designware.h    | 2 ++
> > >  2 files changed, 8 insertions(+)
> > >
> > > diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
> > > index 14c641395c3b..52b3e7f67513 100644
> > > --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> > > +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> > > @@ -684,6 +684,9 @@ void dw_pcie_ep_exit(struct dw_pcie_ep *ep)
> > >  	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> > >  	struct pci_epc *epc = ep->epc;
> > >
> > > +	if (ep->ops->ep_deinit)
> > > +		ep->ops->ep_deinit(ep);
> > > +
> > >  	dw_pcie_edma_remove(pci);
> > >
> > >  	if (ep->intx_mem)
> > > @@ -797,6 +800,9 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)
> > >  	ep->phys_base = res->start;
> > >  	ep->addr_size = resource_size(res);
> > >
> > > +	if (ep->ops->ep_pre_init)
> > > +		ep->ops->ep_pre_init(ep);
> > > +
> > >  	dw_pcie_version_detect(pci);
> > >
> > >  	dw_pcie_iatu_detect(pci);
> > > diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> > > index 6821446d7c66..c3aeafd0f4c9 100644
> > > --- a/drivers/pci/controller/dwc/pcie-designware.h
> > > +++ b/drivers/pci/controller/dwc/pcie-designware.h
> > > @@ -332,7 +332,9 @@ struct dw_pcie_rp {
> > >  };
> > >
> > >  struct dw_pcie_ep_ops {
> > > +	void	(*ep_pre_init)(struct dw_pcie_ep *ep);
> > >  	void	(*ep_init)(struct dw_pcie_ep *ep);
> > > +	void	(*ep_deinit)(struct dw_pcie_ep *ep);
> > 
> > Since the struct name itself has "ep", there is no need to add the "ep" suffix
> > to callbacks. You should fix the existing ep_init callback too in a separate
> > patch.
> 

> I got it. I'll make such a separate patch before this patch.
> 
> Best regards,
> Yoshihiro Shimoda
> 
> > (this series is just GROWING!!!)

The series indeed gets to be too bulky. What about moving that cleanup
patch to a separate patchset which Yoshihiro promised to create
afterwards? Mani?

Anyway should you provide the init()/deinit() callbacks prefix
dropping patch it should fix the dw_pcie_host_ops fields too. It also
has a redundant prefix/suffix. Though it's up to Mani to decide
whether it should be really done.

-Serge(y)

> > 
> > - Mani
> > 
> > >  	int	(*raise_irq)(struct dw_pcie_ep *ep, u8 func_no,
> > >  			     enum pci_epc_irq_type type, u16 interrupt_num);
> > >  	const struct pci_epc_features* (*get_features)(struct dw_pcie_ep *ep);
> > > --
> > > 2.25.1
> > >
> > 
> > --
> > மணிவண்ணன் சதாசிவம்
Serge Semin Aug. 1, 2023, 12:22 a.m. UTC | #5
On Fri, Jul 21, 2023 at 04:44:45PM +0900, Yoshihiro Shimoda wrote:
> Renesas R-Car Gen4 PCIe controllers require vender-specific
> initialization before .ep_init(). To use dw->dbi and dw->num-lanes
> in the initialization code, introduce .ep_pre_init() into struct
> dw_pcie_ep_ops. Also introduce .ep_deinit() to disable the controller
> by using vender-specific de-initialization.
> 
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
>  drivers/pci/controller/dwc/pcie-designware-ep.c | 6 ++++++
>  drivers/pci/controller/dwc/pcie-designware.h    | 2 ++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
> index 14c641395c3b..52b3e7f67513 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> @@ -684,6 +684,9 @@ void dw_pcie_ep_exit(struct dw_pcie_ep *ep)
>  	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
>  	struct pci_epc *epc = ep->epc;
>  

> +	if (ep->ops->ep_deinit)
> +		ep->ops->ep_deinit(ep);
> +

This doesn't seem like a correct place to call the de-initialization
callback. I also don't see you adding the de-initialization to the
cleanup-on-error path of the dw_pcie_ep_init() method. You need to add
it there it. Afterwards you'll see a correct place for it in the
dw_pcie_ep_exit() function.

-Serge(y)

>  	dw_pcie_edma_remove(pci);
>  
>  	if (ep->intx_mem)
> @@ -797,6 +800,9 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)
>  	ep->phys_base = res->start;
>  	ep->addr_size = resource_size(res);
>  
> +	if (ep->ops->ep_pre_init)
> +		ep->ops->ep_pre_init(ep);
> +
>  	dw_pcie_version_detect(pci);
>  
>  	dw_pcie_iatu_detect(pci);
> diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> index 6821446d7c66..c3aeafd0f4c9 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.h
> +++ b/drivers/pci/controller/dwc/pcie-designware.h
> @@ -332,7 +332,9 @@ struct dw_pcie_rp {
>  };
>  
>  struct dw_pcie_ep_ops {
> +	void	(*ep_pre_init)(struct dw_pcie_ep *ep);
>  	void	(*ep_init)(struct dw_pcie_ep *ep);
> +	void	(*ep_deinit)(struct dw_pcie_ep *ep);
>  	int	(*raise_irq)(struct dw_pcie_ep *ep, u8 func_no,
>  			     enum pci_epc_irq_type type, u16 interrupt_num);
>  	const struct pci_epc_features* (*get_features)(struct dw_pcie_ep *ep);
> -- 
> 2.25.1
>
Yoshihiro Shimoda Aug. 1, 2023, 6:27 a.m. UTC | #6
Hi Serge,

> From: Serge Semin, Sent: Tuesday, August 1, 2023 9:22 AM
> 
> On Fri, Jul 21, 2023 at 04:44:45PM +0900, Yoshihiro Shimoda wrote:
> > Renesas R-Car Gen4 PCIe controllers require vender-specific
> > initialization before .ep_init(). To use dw->dbi and dw->num-lanes
> > in the initialization code, introduce .ep_pre_init() into struct
> > dw_pcie_ep_ops. Also introduce .ep_deinit() to disable the controller
> > by using vender-specific de-initialization.
> >
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > ---
> >  drivers/pci/controller/dwc/pcie-designware-ep.c | 6 ++++++
> >  drivers/pci/controller/dwc/pcie-designware.h    | 2 ++
> >  2 files changed, 8 insertions(+)
> >
> > diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
> > index 14c641395c3b..52b3e7f67513 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> > +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> > @@ -684,6 +684,9 @@ void dw_pcie_ep_exit(struct dw_pcie_ep *ep)
> >  	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> >  	struct pci_epc *epc = ep->epc;
> >
> 
> > +	if (ep->ops->ep_deinit)
> > +		ep->ops->ep_deinit(ep);
> > +
> 
> This doesn't seem like a correct place to call the de-initialization
> callback. I also don't see you adding the de-initialization to the
> cleanup-on-error path of the dw_pcie_ep_init() method. You need to add
> it there it. Afterwards you'll see a correct place for it in the
> dw_pcie_ep_exit() function.

I understood it. I'll fix these functions on v19.

Best regards,
Yoshihiro Shimoda

> -Serge(y)
> 
> >  	dw_pcie_edma_remove(pci);
> >
> >  	if (ep->intx_mem)
> > @@ -797,6 +800,9 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)
> >  	ep->phys_base = res->start;
> >  	ep->addr_size = resource_size(res);
> >
> > +	if (ep->ops->ep_pre_init)
> > +		ep->ops->ep_pre_init(ep);
> > +
> >  	dw_pcie_version_detect(pci);
> >
> >  	dw_pcie_iatu_detect(pci);
> > diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> > index 6821446d7c66..c3aeafd0f4c9 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware.h
> > +++ b/drivers/pci/controller/dwc/pcie-designware.h
> > @@ -332,7 +332,9 @@ struct dw_pcie_rp {
> >  };
> >
> >  struct dw_pcie_ep_ops {
> > +	void	(*ep_pre_init)(struct dw_pcie_ep *ep);
> >  	void	(*ep_init)(struct dw_pcie_ep *ep);
> > +	void	(*ep_deinit)(struct dw_pcie_ep *ep);
> >  	int	(*raise_irq)(struct dw_pcie_ep *ep, u8 func_no,
> >  			     enum pci_epc_irq_type type, u16 interrupt_num);
> >  	const struct pci_epc_features* (*get_features)(struct dw_pcie_ep *ep);
> > --
> > 2.25.1
> >
Manivannan Sadhasivam Aug. 2, 2023, 10:40 a.m. UTC | #7
On Tue, Aug 01, 2023 at 03:15:41AM +0300, Serge Semin wrote:
> On Wed, Jul 26, 2023 at 03:02:13AM +0000, Yoshihiro Shimoda wrote:
> > Hi Manivannan,
> > 
> > > From: Manivannan Sadhasivam, Sent: Monday, July 24, 2023 8:40 PM
> > > 
> > > On Fri, Jul 21, 2023 at 04:44:45PM +0900, Yoshihiro Shimoda wrote:
> > > > Renesas R-Car Gen4 PCIe controllers require vender-specific
> > > > initialization before .ep_init(). To use dw->dbi and dw->num-lanes
> > > > in the initialization code, introduce .ep_pre_init() into struct
> > > > dw_pcie_ep_ops. Also introduce .ep_deinit() to disable the controller
> > > > by using vender-specific de-initialization.
> > > >
> > > > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > > > ---
> > > >  drivers/pci/controller/dwc/pcie-designware-ep.c | 6 ++++++
> > > >  drivers/pci/controller/dwc/pcie-designware.h    | 2 ++
> > > >  2 files changed, 8 insertions(+)
> > > >
> > > > diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
> > > > index 14c641395c3b..52b3e7f67513 100644
> > > > --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> > > > +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> > > > @@ -684,6 +684,9 @@ void dw_pcie_ep_exit(struct dw_pcie_ep *ep)
> > > >  	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> > > >  	struct pci_epc *epc = ep->epc;
> > > >
> > > > +	if (ep->ops->ep_deinit)
> > > > +		ep->ops->ep_deinit(ep);
> > > > +
> > > >  	dw_pcie_edma_remove(pci);
> > > >
> > > >  	if (ep->intx_mem)
> > > > @@ -797,6 +800,9 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)
> > > >  	ep->phys_base = res->start;
> > > >  	ep->addr_size = resource_size(res);
> > > >
> > > > +	if (ep->ops->ep_pre_init)
> > > > +		ep->ops->ep_pre_init(ep);
> > > > +
> > > >  	dw_pcie_version_detect(pci);
> > > >
> > > >  	dw_pcie_iatu_detect(pci);
> > > > diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> > > > index 6821446d7c66..c3aeafd0f4c9 100644
> > > > --- a/drivers/pci/controller/dwc/pcie-designware.h
> > > > +++ b/drivers/pci/controller/dwc/pcie-designware.h
> > > > @@ -332,7 +332,9 @@ struct dw_pcie_rp {
> > > >  };
> > > >
> > > >  struct dw_pcie_ep_ops {
> > > > +	void	(*ep_pre_init)(struct dw_pcie_ep *ep);
> > > >  	void	(*ep_init)(struct dw_pcie_ep *ep);
> > > > +	void	(*ep_deinit)(struct dw_pcie_ep *ep);
> > > 
> > > Since the struct name itself has "ep", there is no need to add the "ep" suffix
> > > to callbacks. You should fix the existing ep_init callback too in a separate
> > > patch.
> > 
> 
> > I got it. I'll make such a separate patch before this patch.
> > 
> > Best regards,
> > Yoshihiro Shimoda
> > 
> > > (this series is just GROWING!!!)
> 
> The series indeed gets to be too bulky. What about moving that cleanup
> patch to a separate patchset which Yoshihiro promised to create
> afterwards? Mani?
> 
> Anyway should you provide the init()/deinit() callbacks prefix
> dropping patch it should fix the dw_pcie_host_ops fields too. It also
> has a redundant prefix/suffix. Though it's up to Mani to decide
> whether it should be really done.
> 

I'm fine with a separate cleanup series/patch later.

- Mani

> -Serge(y)
> 
> > > 
> > > - Mani
> > > 
> > > >  	int	(*raise_irq)(struct dw_pcie_ep *ep, u8 func_no,
> > > >  			     enum pci_epc_irq_type type, u16 interrupt_num);
> > > >  	const struct pci_epc_features* (*get_features)(struct dw_pcie_ep *ep);
> > > > --
> > > > 2.25.1
> > > >
> > > 
> > > --
> > > மணிவண்ணன் சதாசிவம்
diff mbox series

Patch

diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
index 14c641395c3b..52b3e7f67513 100644
--- a/drivers/pci/controller/dwc/pcie-designware-ep.c
+++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
@@ -684,6 +684,9 @@  void dw_pcie_ep_exit(struct dw_pcie_ep *ep)
 	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
 	struct pci_epc *epc = ep->epc;
 
+	if (ep->ops->ep_deinit)
+		ep->ops->ep_deinit(ep);
+
 	dw_pcie_edma_remove(pci);
 
 	if (ep->intx_mem)
@@ -797,6 +800,9 @@  int dw_pcie_ep_init(struct dw_pcie_ep *ep)
 	ep->phys_base = res->start;
 	ep->addr_size = resource_size(res);
 
+	if (ep->ops->ep_pre_init)
+		ep->ops->ep_pre_init(ep);
+
 	dw_pcie_version_detect(pci);
 
 	dw_pcie_iatu_detect(pci);
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index 6821446d7c66..c3aeafd0f4c9 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -332,7 +332,9 @@  struct dw_pcie_rp {
 };
 
 struct dw_pcie_ep_ops {
+	void	(*ep_pre_init)(struct dw_pcie_ep *ep);
 	void	(*ep_init)(struct dw_pcie_ep *ep);
+	void	(*ep_deinit)(struct dw_pcie_ep *ep);
 	int	(*raise_irq)(struct dw_pcie_ep *ep, u8 func_no,
 			     enum pci_epc_irq_type type, u16 interrupt_num);
 	const struct pci_epc_features* (*get_features)(struct dw_pcie_ep *ep);