Message ID | 20231011110514.107528-1-minda.chen@starfivetech.com |
---|---|
Headers | show |
Series | Refactoring Microchip PCIe driver and add StarFive PCIe | expand |
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Thanks,
Conor.
On Wed, Oct 11, 2023 at 07:04:58PM +0800, Minda Chen wrote: > Move the common data structures definition to head file for nit: "to a header file so that these data structures" > these data structure can be re-used. > > Signed-off-by: Minda Chen <minda.chen@starfivetech.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Thanks, Conor. > --- > .../pci/controller/plda/pcie-microchip-host.c | 20 ------------------ > drivers/pci/controller/plda/pcie-plda.h | 21 +++++++++++++++++++ > 2 files changed, 21 insertions(+), 20 deletions(-) > > diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c > index 3dc4d4ca9d0c..261147a0a446 100644 > --- a/drivers/pci/controller/plda/pcie-microchip-host.c > +++ b/drivers/pci/controller/plda/pcie-microchip-host.c > @@ -21,9 +21,6 @@ > #include "../../pci.h" > #include "pcie-plda.h" > > -/* Number of MSI IRQs */ > -#define PLDA_MAX_NUM_MSI_IRQS 32 > - > /* PCIe Bridge Phy and Controller Phy offsets */ > #define MC_PCIE1_BRIDGE_ADDR 0x00008000u > #define MC_PCIE1_CTRL_ADDR 0x0000a000u > @@ -179,23 +176,6 @@ struct event_map { > u32 event_bit; > }; > > -struct plda_msi { > - struct mutex lock; /* Protect used bitmap */ > - struct irq_domain *msi_domain; > - struct irq_domain *dev_domain; > - u32 num_vectors; > - u64 vector_phy; > - DECLARE_BITMAP(used, PLDA_MAX_NUM_MSI_IRQS); > -}; > - > -struct plda_pcie_rp { > - struct device *dev; > - struct irq_domain *intx_domain; > - struct irq_domain *event_domain; > - raw_spinlock_t lock; > - struct plda_msi msi; > - void __iomem *bridge_addr; > -}; > > struct mc_pcie { > struct plda_pcie_rp plda; > diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h > index 727fc54312c9..363fcbbaf6ec 100644 > --- a/drivers/pci/controller/plda/pcie-plda.h > +++ b/drivers/pci/controller/plda/pcie-plda.h > @@ -6,6 +6,9 @@ > #ifndef _PCIE_PLDA_H > #define _PCIE_PLDA_H > > +/* Number of MSI IRQs */ > +#define PLDA_MAX_NUM_MSI_IRQS 32 > + > /* PCIe Bridge Phy Regs */ > #define PCIE_PCI_IRQ_DW0 0xa8 > #define MSIX_CAP_MASK BIT(31) > @@ -99,4 +102,22 @@ > #define EVENT_PM_MSI_INT_SYS_ERR 12 > #define NUM_PLDA_EVENTS 13 > > +struct plda_msi { > + struct mutex lock; /* Protect used bitmap */ > + struct irq_domain *msi_domain; > + struct irq_domain *dev_domain; > + u32 num_vectors; > + u64 vector_phy; > + DECLARE_BITMAP(used, PLDA_MAX_NUM_MSI_IRQS); > +}; > + > +struct plda_pcie_rp { > + struct device *dev; > + struct irq_domain *intx_domain; > + struct irq_domain *event_domain; > + raw_spinlock_t lock; > + struct plda_msi msi; > + void __iomem *bridge_addr; > +}; > + > #endif > -- > 2.17.1 >
On Wed, Oct 11, 2023 at 07:05:07PM +0800, Minda Chen wrote: > For different interrupts to event num mapping function, > add get_events() function pointer. > For extenting event ops in the fucture, Add struct > plda_event_ops data structure. I still think these commit messages are a bit weak and should point out the reasons why these are needed, rather than handwaving about future users. Otherwise, Acked-by: Conor Dooley <conor.dooley@microchip.com> Thanks, Conor. > > plda_handle_events() will call the get_events() callback > function pointer directly. For the robustness of codes, > add checking in plda_init_interrupts(). > > Signed-off-by: Minda Chen <minda.chen@starfivetech.com> > --- > drivers/pci/controller/plda/pcie-microchip-host.c | 14 +++++++++++++- > drivers/pci/controller/plda/pcie-plda.h | 8 ++++++++ > 2 files changed, 21 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c > index e99498b5b563..fca1520d56c9 100644 > --- a/drivers/pci/controller/plda/pcie-microchip-host.c > +++ b/drivers/pci/controller/plda/pcie-microchip-host.c > @@ -647,7 +647,7 @@ static void plda_handle_event(struct irq_desc *desc) > > chained_irq_enter(chip, desc); > > - events = mc_get_events(port); > + events = port->event_ops->get_events(port); > > for_each_set_bit(bit, &events, port->num_events) > generic_handle_domain_irq(port->event_domain, bit); > @@ -806,7 +806,12 @@ static int mc_request_event_irq(struct plda_pcie_rp *plda, int event_irq, > 0, event_cause[event].sym, plda); > } > > +static const struct plda_event_ops mc_event_ops = { > + .get_events = mc_get_events, > +}; > + > static const struct plda_event mc_event = { > + .event_ops = &mc_event_ops, > .request_event_irq = mc_request_event_irq, > .intx_event = EVENT_LOCAL_PM_MSI_INT_INTX, > .msi_event = EVENT_LOCAL_PM_MSI_INT_MSI, > @@ -920,6 +925,11 @@ static int plda_init_interrupts(struct platform_device *pdev, > int i, intx_irq, msi_irq, event_irq; > int ret; > > + if (!event->event_ops || !event->event_ops->get_events) { > + dev_err(dev, "no get events ops\n"); > + return -EINVAL; > + } > + > ret = plda_pcie_init_irq_domains(port); > if (ret) { > dev_err(dev, "failed creating IRQ domains\n"); > @@ -930,6 +940,8 @@ static int plda_init_interrupts(struct platform_device *pdev, > if (irq < 0) > return -ENODEV; > > + port->event_ops = event->event_ops; > + > for (i = 0; i < port->num_events; i++) { > event_irq = irq_create_mapping(port->event_domain, i); > if (!event_irq) { > diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h > index 5ad1b81c0086..6571a4befac9 100644 > --- a/drivers/pci/controller/plda/pcie-plda.h > +++ b/drivers/pci/controller/plda/pcie-plda.h > @@ -102,6 +102,12 @@ > #define EVENT_PM_MSI_INT_SYS_ERR 12 > #define NUM_PLDA_EVENTS 13 > > +struct plda_pcie_rp; > + > +struct plda_event_ops { > + u32 (*get_events)(struct plda_pcie_rp *pcie); > +}; > + > struct plda_msi { > struct mutex lock; /* Protect used bitmap */ > struct irq_domain *msi_domain; > @@ -117,11 +123,13 @@ struct plda_pcie_rp { > struct irq_domain *event_domain; > raw_spinlock_t lock; > struct plda_msi msi; > + const struct plda_event_ops *event_ops; > void __iomem *bridge_addr; > int num_events; > }; > > struct plda_event { > + const struct plda_event_ops *event_ops; > int (*request_event_irq)(struct plda_pcie_rp *pcie, > int event_irq, int event); > int intx_event; > -- > 2.17.1 >