de28ebe73aa510350f3e55fcea2fb4a917a68d63
[openwrt/staging/stintel.git] /
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
5 structure
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
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.
14
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.
19
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).
25
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/
28
29 Signed-off-by: Marek BehĂșn <kabel@kernel.org>
30 ---
31 drivers/pci/controller/pci-aardvark.c | 25 +++++++------------------
32 1 file changed, 7 insertions(+), 18 deletions(-)
33
34 --- a/drivers/pci/controller/pci-aardvark.c
35 +++ b/drivers/pci/controller/pci-aardvark.c
36 @@ -274,7 +274,6 @@ struct advk_pcie {
37 u8 wins_count;
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 @@ -1330,14 +1329,19 @@ static void advk_pcie_irq_unmask(struct
45 raw_spin_unlock_irqrestore(&pcie->irq_lock, flags);
46 }
47
48 +static struct irq_chip advk_irq_chip = {
49 + .name = "advk-INT",
50 + .irq_mask = advk_pcie_irq_mask,
51 + .irq_unmask = advk_pcie_irq_unmask,
52 +};
53 +
54 static int advk_pcie_irq_map(struct irq_domain *h,
55 unsigned int virq, irq_hw_number_t hwirq)
56 {
57 struct advk_pcie *pcie = h->host_data;
58
59 irq_set_status_flags(virq, IRQ_LEVEL);
60 - irq_set_chip_and_handler(virq, &pcie->irq_chip,
61 - handle_level_irq);
62 + irq_set_chip_and_handler(virq, &advk_irq_chip, handle_level_irq);
63 irq_set_chip_data(virq, pcie);
64
65 return 0;
66 @@ -1396,7 +1400,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;
71 int ret = 0;
72
73 raw_spin_lock_init(&pcie->irq_lock);
74 @@ -1407,28 +1410,14 @@ static int advk_pcie_init_irq_domain(str
75 return -ENODEV;
76 }
77
78 - irq_chip = &pcie->irq_chip;
79 -
80 - irq_chip->name = devm_kasprintf(dev, GFP_KERNEL, "%s-irq",
81 - dev_name(dev));
82 - if (!irq_chip->name) {
83 - ret = -ENOMEM;
84 - goto out_put_node;
85 - }
86 -
87 - irq_chip->irq_mask = advk_pcie_irq_mask;
88 - irq_chip->irq_unmask = advk_pcie_irq_unmask;
89 -
90 pcie->irq_domain =
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");
95 ret = -ENOMEM;
96 - goto out_put_node;
97 }
98
99 -out_put_node:
100 of_node_put(pcie_intc_node);
101 return ret;
102 }