Message ID | 20230823091153.2578417-13-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 |
On Wed, Aug 23, 2023 at 06:11:46PM +0900, Yoshihiro Shimoda wrote: > Renesas R-Car Gen4 PCIe controllers require vendor-specific > initialization before .init(). To use dw->dbi and dw->num-lanes > in the initialization code, introduce .pre_init() into struct > dw_pcie_ep_ops. Also introduce .deinit() to disable the controller > by using vendor-specific de-initialization. > > Note that the ep_init in the struct dw_pcie_ep_ops should be renamed > to init later. Note this message look very little related to the patch itself. If you want to signify your agreement with Mani then just put that note below the "---" line. Anyway. The callbacks execution order looks correct now. Thanks. Reviewed-by: Serge Semin <fancer.lancer@gmail.com> -Serge(y) > > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> > --- > drivers/pci/controller/dwc/pcie-designware-ep.c | 12 +++++++++++- > drivers/pci/controller/dwc/pcie-designware.h | 2 ++ > 2 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c > index 9a51a723b892..ea8063742fac 100644 > --- a/drivers/pci/controller/dwc/pcie-designware-ep.c > +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c > @@ -695,6 +695,9 @@ void dw_pcie_ep_exit(struct dw_pcie_ep *ep) > epc->mem->window.page_size); > > pci_epc_mem_exit(epc); > + > + if (ep->ops->deinit) > + ep->ops->deinit(ep); > } > EXPORT_SYMBOL_GPL(dw_pcie_ep_exit); > > @@ -798,6 +801,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->pre_init) > + ep->ops->pre_init(ep); > + > dw_pcie_version_detect(pci); > > dw_pcie_iatu_detect(pci); > @@ -852,7 +858,7 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) > ep->page_size); > if (ret < 0) { > dev_err(dev, "Failed to initialize address space\n"); > - return ret; > + goto err_ep_deinit; > } > > ep->msi_mem = pci_epc_mem_alloc_addr(epc, &ep->msi_mem_phys, > @@ -898,6 +904,10 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) > err_exit_epc_mem: > pci_epc_mem_exit(epc); > > +err_ep_deinit: > + if (ep->ops->deinit) > + ep->ops->deinit(ep); > + > return ret; > } > EXPORT_SYMBOL_GPL(dw_pcie_ep_init); > diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h > index 89999c483c37..77a9c3e70120 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 (*pre_init)(struct dw_pcie_ep *ep); > void (*ep_init)(struct dw_pcie_ep *ep); > + void (*deinit)(struct dw_pcie_ep *ep); > int (*raise_irq)(struct dw_pcie_ep *ep, u8 func_no, > unsigned int type, u16 interrupt_num); > const struct pci_epc_features* (*get_features)(struct dw_pcie_ep *ep); > -- > 2.25.1 >
diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 9a51a723b892..ea8063742fac 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -695,6 +695,9 @@ void dw_pcie_ep_exit(struct dw_pcie_ep *ep) epc->mem->window.page_size); pci_epc_mem_exit(epc); + + if (ep->ops->deinit) + ep->ops->deinit(ep); } EXPORT_SYMBOL_GPL(dw_pcie_ep_exit); @@ -798,6 +801,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->pre_init) + ep->ops->pre_init(ep); + dw_pcie_version_detect(pci); dw_pcie_iatu_detect(pci); @@ -852,7 +858,7 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) ep->page_size); if (ret < 0) { dev_err(dev, "Failed to initialize address space\n"); - return ret; + goto err_ep_deinit; } ep->msi_mem = pci_epc_mem_alloc_addr(epc, &ep->msi_mem_phys, @@ -898,6 +904,10 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) err_exit_epc_mem: pci_epc_mem_exit(epc); +err_ep_deinit: + if (ep->ops->deinit) + ep->ops->deinit(ep); + return ret; } EXPORT_SYMBOL_GPL(dw_pcie_ep_init); diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 89999c483c37..77a9c3e70120 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 (*pre_init)(struct dw_pcie_ep *ep); void (*ep_init)(struct dw_pcie_ep *ep); + void (*deinit)(struct dw_pcie_ep *ep); int (*raise_irq)(struct dw_pcie_ep *ep, u8 func_no, unsigned int type, u16 interrupt_num); const struct pci_epc_features* (*get_features)(struct dw_pcie_ep *ep);
Renesas R-Car Gen4 PCIe controllers require vendor-specific initialization before .init(). To use dw->dbi and dw->num-lanes in the initialization code, introduce .pre_init() into struct dw_pcie_ep_ops. Also introduce .deinit() to disable the controller by using vendor-specific de-initialization. Note that the ep_init in the struct dw_pcie_ep_ops should be renamed to init later. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> --- drivers/pci/controller/dwc/pcie-designware-ep.c | 12 +++++++++++- drivers/pci/controller/dwc/pcie-designware.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-)