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 --- a/drivers/pci/controller/pci-aardvark.c
35 +++ b/drivers/pci/controller/pci-aardvark.c
36 @@ -277,7 +277,6 @@ struct advk_pcie {
38 struct irq_domain *rp_irq_domain;
39 struct irq_domain *irq_domain;
40 - struct irq_chip irq_chip;
41 raw_spinlock_t irq_lock;
42 struct irq_domain *msi_domain;
43 struct irq_domain *msi_inner_domain;
44 @@ -1426,14 +1425,19 @@ static void advk_pcie_irq_unmask(struct
45 raw_spin_unlock_irqrestore(&pcie->irq_lock, flags);
48 +static struct irq_chip advk_irq_chip = {
50 + .irq_mask = advk_pcie_irq_mask,
51 + .irq_unmask = advk_pcie_irq_unmask,
54 static int advk_pcie_irq_map(struct irq_domain *h,
55 unsigned int virq, irq_hw_number_t hwirq)
57 struct advk_pcie *pcie = h->host_data;
59 irq_set_status_flags(virq, IRQ_LEVEL);
60 - irq_set_chip_and_handler(virq, &pcie->irq_chip,
62 + irq_set_chip_and_handler(virq, &advk_irq_chip, handle_level_irq);
63 irq_set_chip_data(virq, pcie);
66 @@ -1492,7 +1496,6 @@ static int advk_pcie_init_irq_domain(str
67 struct device *dev = &pcie->pdev->dev;
68 struct device_node *node = dev->of_node;
69 struct device_node *pcie_intc_node;
70 - struct irq_chip *irq_chip;
73 raw_spin_lock_init(&pcie->irq_lock);
74 @@ -1503,28 +1506,14 @@ static int advk_pcie_init_irq_domain(str
78 - irq_chip = &pcie->irq_chip;
80 - irq_chip->name = devm_kasprintf(dev, GFP_KERNEL, "%s-irq",
82 - if (!irq_chip->name) {
87 - irq_chip->irq_mask = advk_pcie_irq_mask;
88 - irq_chip->irq_unmask = advk_pcie_irq_unmask;
91 irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
92 &advk_pcie_irq_domain_ops, pcie);
93 if (!pcie->irq_domain) {
94 dev_err(dev, "Failed to get a INTx IRQ domain\n");
100 of_node_put(pcie_intc_node);