1 From 663b9f99bb35dbc0c7b685f71ee3668a60d31320 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <kabel@kernel.org>
3 Date: Mon, 10 Jan 2022 02:02:00 +0100
4 Subject: [PATCH] PCI: aardvark: Make main irq_chip structure a static driver
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 Marc Zyngier says [1] that we should use struct irq_chip as a global
11 static struct in the driver. Even though the structure currently
12 contains a dynamic member (parent_device), Marc says [2] that he plans
13 to kill it and make the structure completely static.
15 We have already converted others irq_chip structures in this driver in
16 this way, but we omitted this one because the .name member is
17 dynamically created from device's name, and the name is displayed in
18 sysfs, so changing it would break sysfs ABI.
20 The rationale for changing the name (to "advk-INT") in spite of sysfs
21 ABI, and thus allowing to convert to a static structure, is that after
22 the other changes we made in this series, the IRQ chip is basically
23 something different: it no logner generates ERR and PME interrupts (they
24 are generated by emulated bridge's rp_irq_chip).
26 [1] https://lore.kernel.org/linux-pci/877dbcvngf.wl-maz@kernel.org/
27 [2] https://lore.kernel.org/linux-pci/874k6gvkhz.wl-maz@kernel.org/
29 Signed-off-by: Marek BehĂșn <kabel@kernel.org>
31 drivers/pci/controller/pci-aardvark.c | 25 +++++++------------------
32 1 file changed, 7 insertions(+), 18 deletions(-)
34 diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c
35 index 3c0b6b931061..319dd830e36e 100644
36 --- a/drivers/pci/controller/pci-aardvark.c
37 +++ b/drivers/pci/controller/pci-aardvark.c
38 @@ -282,7 +282,6 @@ struct advk_pcie {
40 struct irq_domain *rp_irq_domain;
41 struct irq_domain *irq_domain;
42 - struct irq_chip irq_chip;
43 raw_spinlock_t irq_lock;
44 struct irq_domain *msi_domain;
45 struct irq_domain *msi_inner_domain;
46 @@ -1336,14 +1335,19 @@ static void advk_pcie_irq_unmask(struct irq_data *d)
47 raw_spin_unlock_irqrestore(&pcie->irq_lock, flags);
50 +static struct irq_chip advk_irq_chip = {
52 + .irq_mask = advk_pcie_irq_mask,
53 + .irq_unmask = advk_pcie_irq_unmask,
56 static int advk_pcie_irq_map(struct irq_domain *h,
57 unsigned int virq, irq_hw_number_t hwirq)
59 struct advk_pcie *pcie = h->host_data;
61 irq_set_status_flags(virq, IRQ_LEVEL);
62 - irq_set_chip_and_handler(virq, &pcie->irq_chip,
64 + irq_set_chip_and_handler(virq, &advk_irq_chip, handle_level_irq);
65 irq_set_chip_data(virq, pcie);
68 @@ -1402,7 +1406,6 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie)
69 struct device *dev = &pcie->pdev->dev;
70 struct device_node *node = dev->of_node;
71 struct device_node *pcie_intc_node;
72 - struct irq_chip *irq_chip;
75 raw_spin_lock_init(&pcie->irq_lock);
76 @@ -1413,28 +1416,14 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie)
80 - irq_chip = &pcie->irq_chip;
82 - irq_chip->name = devm_kasprintf(dev, GFP_KERNEL, "%s-irq",
84 - if (!irq_chip->name) {
89 - irq_chip->irq_mask = advk_pcie_irq_mask;
90 - irq_chip->irq_unmask = advk_pcie_irq_unmask;
93 irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
94 &advk_pcie_irq_domain_ops, pcie);
95 if (!pcie->irq_domain) {
96 dev_err(dev, "Failed to get a INTx IRQ domain\n");
102 of_node_put(pcie_intc_node);