Skip to content

Commit 86c12c7

Browse files
author
Marc Zyngier
committed
Merge branch irq/print_chip into irq/irqchip-next
* irq/print_chip: : . : Convert irqchip drivers that use the .name field as a topology : description to the .irq_print_chip callback, which allows the : name to be made dymanic. The irq_chip structures are then made : 'const' in order to prevent further abuse. : . irqchip/versatile-fpga: Switch to dynamic chip name output irqchip/ts4800: Switch to dynamic chip name output irqchip/mvebu-pic: Switch to dynamic chip name output irqchip/lpc32xx: Switch to dynamic chip name output irqchip/gic: Switch to dynamic chip name output genirq/debugfs: Use irq_print_chip() when provided by irqchip genirq: Allow irq_chip registration functions to take a const irq_chip irqdomain: Let irq_domain_set_{info,hwirq_and_chip} take a const irq_chip Signed-off-by: Marc Zyngier <maz@kernel.org>
2 parents add679d + 3fb212a commit 86c12c7

12 files changed

Lines changed: 158 additions & 130 deletions

File tree

drivers/irqchip/irq-ftintc010.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <linux/irq.h>
1212
#include <linux/io.h>
1313
#include <linux/irqchip.h>
14-
#include <linux/irqchip/versatile-fpga.h>
1514
#include <linux/irqdomain.h>
1615
#include <linux/module.h>
1716
#include <linux/of.h>

drivers/irqchip/irq-gic.c

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <linux/irqdomain.h>
3535
#include <linux/interrupt.h>
3636
#include <linux/percpu.h>
37+
#include <linux/seq_file.h>
3738
#include <linux/slab.h>
3839
#include <linux/irqchip.h>
3940
#include <linux/irqchip/chained_irq.h>
@@ -66,7 +67,6 @@ union gic_base {
6667
};
6768

6869
struct gic_chip_data {
69-
struct irq_chip chip;
7070
union gic_base dist_base;
7171
union gic_base cpu_base;
7272
void __iomem *raw_dist_base;
@@ -397,18 +397,15 @@ static void gic_handle_cascade_irq(struct irq_desc *desc)
397397
chained_irq_exit(chip, desc);
398398
}
399399

400-
static const struct irq_chip gic_chip = {
401-
.irq_mask = gic_mask_irq,
402-
.irq_unmask = gic_unmask_irq,
403-
.irq_eoi = gic_eoi_irq,
404-
.irq_set_type = gic_set_type,
405-
.irq_retrigger = gic_retrigger,
406-
.irq_get_irqchip_state = gic_irq_get_irqchip_state,
407-
.irq_set_irqchip_state = gic_irq_set_irqchip_state,
408-
.flags = IRQCHIP_SET_TYPE_MASKED |
409-
IRQCHIP_SKIP_SET_WAKE |
410-
IRQCHIP_MASK_ON_SUSPEND,
411-
};
400+
static void gic_irq_print_chip(struct irq_data *d, struct seq_file *p)
401+
{
402+
struct gic_chip_data *gic = irq_data_get_irq_chip_data(d);
403+
404+
if (gic->domain->dev)
405+
seq_printf(p, gic->domain->dev->of_node->name);
406+
else
407+
seq_printf(p, "GIC-%d", (int)(gic - &gic_data[0]));
408+
}
412409

413410
void __init gic_cascade_irq(unsigned int gic_nr, unsigned int irq)
414411
{
@@ -799,8 +796,12 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
799796
bool force)
800797
{
801798
void __iomem *reg = gic_dist_base(d) + GIC_DIST_TARGET + gic_irq(d);
799+
struct gic_chip_data *gic = irq_data_get_irq_chip_data(d);
802800
unsigned int cpu;
803801

802+
if (unlikely(gic != &gic_data[0]))
803+
return -EINVAL;
804+
804805
if (!force)
805806
cpu = cpumask_any_and(mask_val, cpu_online_mask);
806807
else
@@ -880,6 +881,39 @@ static __init void gic_smp_init(void)
880881
#define gic_ipi_send_mask NULL
881882
#endif
882883

884+
static const struct irq_chip gic_chip = {
885+
.irq_mask = gic_mask_irq,
886+
.irq_unmask = gic_unmask_irq,
887+
.irq_eoi = gic_eoi_irq,
888+
.irq_set_type = gic_set_type,
889+
.irq_retrigger = gic_retrigger,
890+
.irq_set_affinity = gic_set_affinity,
891+
.ipi_send_mask = gic_ipi_send_mask,
892+
.irq_get_irqchip_state = gic_irq_get_irqchip_state,
893+
.irq_set_irqchip_state = gic_irq_set_irqchip_state,
894+
.irq_print_chip = gic_irq_print_chip,
895+
.flags = IRQCHIP_SET_TYPE_MASKED |
896+
IRQCHIP_SKIP_SET_WAKE |
897+
IRQCHIP_MASK_ON_SUSPEND,
898+
};
899+
900+
static const struct irq_chip gic_chip_mode1 = {
901+
.name = "GICv2",
902+
.irq_mask = gic_eoimode1_mask_irq,
903+
.irq_unmask = gic_unmask_irq,
904+
.irq_eoi = gic_eoimode1_eoi_irq,
905+
.irq_set_type = gic_set_type,
906+
.irq_retrigger = gic_retrigger,
907+
.irq_set_affinity = gic_set_affinity,
908+
.ipi_send_mask = gic_ipi_send_mask,
909+
.irq_get_irqchip_state = gic_irq_get_irqchip_state,
910+
.irq_set_irqchip_state = gic_irq_set_irqchip_state,
911+
.irq_set_vcpu_affinity = gic_irq_set_vcpu_affinity,
912+
.flags = IRQCHIP_SET_TYPE_MASKED |
913+
IRQCHIP_SKIP_SET_WAKE |
914+
IRQCHIP_MASK_ON_SUSPEND,
915+
};
916+
883917
#ifdef CONFIG_BL_SWITCHER
884918
/*
885919
* gic_send_sgi - send a SGI directly to given CPU interface number
@@ -1024,15 +1058,19 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int irq,
10241058
{
10251059
struct gic_chip_data *gic = d->host_data;
10261060
struct irq_data *irqd = irq_desc_get_irq_data(irq_to_desc(irq));
1061+
const struct irq_chip *chip;
1062+
1063+
chip = (static_branch_likely(&supports_deactivate_key) &&
1064+
gic == &gic_data[0]) ? &gic_chip_mode1 : &gic_chip;
10271065

10281066
switch (hw) {
10291067
case 0 ... 31:
10301068
irq_set_percpu_devid(irq);
1031-
irq_domain_set_info(d, irq, hw, &gic->chip, d->host_data,
1069+
irq_domain_set_info(d, irq, hw, chip, d->host_data,
10321070
handle_percpu_devid_irq, NULL, NULL);
10331071
break;
10341072
default:
1035-
irq_domain_set_info(d, irq, hw, &gic->chip, d->host_data,
1073+
irq_domain_set_info(d, irq, hw, chip, d->host_data,
10361074
handle_fasteoi_irq, NULL, NULL);
10371075
irq_set_probe(irq);
10381076
irqd_set_single_target(irqd);
@@ -1127,25 +1165,6 @@ static const struct irq_domain_ops gic_irq_domain_ops = {
11271165
.unmap = gic_irq_domain_unmap,
11281166
};
11291167

1130-
static void gic_init_chip(struct gic_chip_data *gic, const char *name,
1131-
bool use_eoimode1)
1132-
{
1133-
/* Initialize irq_chip */
1134-
gic->chip = gic_chip;
1135-
gic->chip.name = name;
1136-
1137-
if (use_eoimode1) {
1138-
gic->chip.irq_mask = gic_eoimode1_mask_irq;
1139-
gic->chip.irq_eoi = gic_eoimode1_eoi_irq;
1140-
gic->chip.irq_set_vcpu_affinity = gic_irq_set_vcpu_affinity;
1141-
}
1142-
1143-
if (gic == &gic_data[0]) {
1144-
gic->chip.irq_set_affinity = gic_set_affinity;
1145-
gic->chip.ipi_send_mask = gic_ipi_send_mask;
1146-
}
1147-
}
1148-
11491168
static int gic_init_bases(struct gic_chip_data *gic,
11501169
struct fwnode_handle *handle)
11511170
{
@@ -1245,7 +1264,6 @@ static int gic_init_bases(struct gic_chip_data *gic,
12451264
static int __init __gic_init_bases(struct gic_chip_data *gic,
12461265
struct fwnode_handle *handle)
12471266
{
1248-
char *name;
12491267
int i, ret;
12501268

12511269
if (WARN_ON(!gic || gic->domain))
@@ -1265,18 +1283,8 @@ static int __init __gic_init_bases(struct gic_chip_data *gic,
12651283
pr_info("GIC: Using split EOI/Deactivate mode\n");
12661284
}
12671285

1268-
if (static_branch_likely(&supports_deactivate_key) && gic == &gic_data[0]) {
1269-
name = kasprintf(GFP_KERNEL, "GICv2");
1270-
gic_init_chip(gic, name, true);
1271-
} else {
1272-
name = kasprintf(GFP_KERNEL, "GIC-%d", (int)(gic-&gic_data[0]));
1273-
gic_init_chip(gic, name, false);
1274-
}
1275-
12761286
ret = gic_init_bases(gic, handle);
1277-
if (ret)
1278-
kfree(name);
1279-
else if (gic == &gic_data[0])
1287+
if (gic == &gic_data[0])
12801288
gic_smp_init();
12811289

12821290
return ret;
@@ -1459,8 +1467,6 @@ int gic_of_init_child(struct device *dev, struct gic_chip_data **gic, int irq)
14591467
if (!*gic)
14601468
return -ENOMEM;
14611469

1462-
gic_init_chip(*gic, dev->of_node->name, false);
1463-
14641470
ret = gic_of_setup(*gic, dev->of_node);
14651471
if (ret)
14661472
return ret;

drivers/irqchip/irq-lpc32xx.c

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/of_address.h>
1212
#include <linux/of_irq.h>
1313
#include <linux/of_platform.h>
14+
#include <linux/seq_file.h>
1415
#include <linux/slab.h>
1516
#include <asm/exception.h>
1617

@@ -25,8 +26,8 @@
2526

2627
struct lpc32xx_irq_chip {
2728
void __iomem *base;
29+
phys_addr_t addr;
2830
struct irq_domain *domain;
29-
struct irq_chip chip;
3031
};
3132

3233
static struct lpc32xx_irq_chip *lpc32xx_mic_irqc;
@@ -118,6 +119,24 @@ static int lpc32xx_irq_set_type(struct irq_data *d, unsigned int type)
118119
return 0;
119120
}
120121

122+
static void lpc32xx_irq_print_chip(struct irq_data *d, struct seq_file *p)
123+
{
124+
struct lpc32xx_irq_chip *ic = irq_data_get_irq_chip_data(d);
125+
126+
if (ic == lpc32xx_mic_irqc)
127+
seq_printf(p, "%08x.mic", ic->addr);
128+
else
129+
seq_printf(p, "%08x.sic", ic->addr);
130+
}
131+
132+
static const struct irq_chip lpc32xx_chip = {
133+
.irq_ack = lpc32xx_irq_ack,
134+
.irq_mask = lpc32xx_irq_mask,
135+
.irq_unmask = lpc32xx_irq_unmask,
136+
.irq_set_type = lpc32xx_irq_set_type,
137+
.irq_print_chip = lpc32xx_irq_print_chip,
138+
};
139+
121140
static void __exception_irq_entry lpc32xx_handle_irq(struct pt_regs *regs)
122141
{
123142
struct lpc32xx_irq_chip *ic = lpc32xx_mic_irqc;
@@ -153,7 +172,7 @@ static int lpc32xx_irq_domain_map(struct irq_domain *id, unsigned int virq,
153172
struct lpc32xx_irq_chip *ic = id->host_data;
154173

155174
irq_set_chip_data(virq, ic);
156-
irq_set_chip_and_handler(virq, &ic->chip, handle_level_irq);
175+
irq_set_chip_and_handler(virq, &lpc32xx_chip, handle_level_irq);
157176
irq_set_status_flags(virq, IRQ_LEVEL);
158177
irq_set_noprobe(virq);
159178

@@ -183,28 +202,19 @@ static int __init lpc32xx_of_ic_init(struct device_node *node,
183202
if (!irqc)
184203
return -ENOMEM;
185204

205+
irqc->addr = addr;
186206
irqc->base = of_iomap(node, 0);
187207
if (!irqc->base) {
188208
pr_err("%pOF: unable to map registers\n", node);
189209
kfree(irqc);
190210
return -EINVAL;
191211
}
192212

193-
irqc->chip.irq_ack = lpc32xx_irq_ack;
194-
irqc->chip.irq_mask = lpc32xx_irq_mask;
195-
irqc->chip.irq_unmask = lpc32xx_irq_unmask;
196-
irqc->chip.irq_set_type = lpc32xx_irq_set_type;
197-
if (is_mic)
198-
irqc->chip.name = kasprintf(GFP_KERNEL, "%08x.mic", addr);
199-
else
200-
irqc->chip.name = kasprintf(GFP_KERNEL, "%08x.sic", addr);
201-
202213
irqc->domain = irq_domain_add_linear(node, NR_LPC32XX_IC_IRQS,
203214
&lpc32xx_irq_domain_ops, irqc);
204215
if (!irqc->domain) {
205216
pr_err("unable to add irq domain\n");
206217
iounmap(irqc->base);
207-
kfree(irqc->chip.name);
208218
kfree(irqc);
209219
return -ENODEV;
210220
}

drivers/irqchip/irq-mvebu-pic.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/module.h>
1919
#include <linux/of_irq.h>
2020
#include <linux/platform_device.h>
21+
#include <linux/seq_file.h>
2122

2223
#define PIC_CAUSE 0x0
2324
#define PIC_MASK 0x4
@@ -29,7 +30,7 @@ struct mvebu_pic {
2930
void __iomem *base;
3031
u32 parent_irq;
3132
struct irq_domain *domain;
32-
struct irq_chip irq_chip;
33+
struct platform_device *pdev;
3334
};
3435

3536
static void mvebu_pic_reset(struct mvebu_pic *pic)
@@ -66,15 +67,28 @@ static void mvebu_pic_unmask_irq(struct irq_data *d)
6667
writel(reg, pic->base + PIC_MASK);
6768
}
6869

70+
static void mvebu_pic_print_chip(struct irq_data *d, struct seq_file *p)
71+
{
72+
struct mvebu_pic *pic = irq_data_get_irq_chip_data(d);
73+
74+
seq_printf(p, dev_name(&pic->pdev->dev));
75+
}
76+
77+
static const struct irq_chip mvebu_pic_chip = {
78+
.irq_mask = mvebu_pic_mask_irq,
79+
.irq_unmask = mvebu_pic_unmask_irq,
80+
.irq_eoi = mvebu_pic_eoi_irq,
81+
.irq_print_chip = mvebu_pic_print_chip,
82+
};
83+
6984
static int mvebu_pic_irq_map(struct irq_domain *domain, unsigned int virq,
7085
irq_hw_number_t hwirq)
7186
{
7287
struct mvebu_pic *pic = domain->host_data;
7388

7489
irq_set_percpu_devid(virq);
7590
irq_set_chip_data(virq, pic);
76-
irq_set_chip_and_handler(virq, &pic->irq_chip,
77-
handle_percpu_devid_irq);
91+
irq_set_chip_and_handler(virq, &mvebu_pic_chip, handle_percpu_devid_irq);
7892
irq_set_status_flags(virq, IRQ_LEVEL);
7993
irq_set_probe(virq);
8094

@@ -120,22 +134,16 @@ static int mvebu_pic_probe(struct platform_device *pdev)
120134
{
121135
struct device_node *node = pdev->dev.of_node;
122136
struct mvebu_pic *pic;
123-
struct irq_chip *irq_chip;
124137

125138
pic = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_pic), GFP_KERNEL);
126139
if (!pic)
127140
return -ENOMEM;
128141

142+
pic->pdev = pdev;
129143
pic->base = devm_platform_ioremap_resource(pdev, 0);
130144
if (IS_ERR(pic->base))
131145
return PTR_ERR(pic->base);
132146

133-
irq_chip = &pic->irq_chip;
134-
irq_chip->name = dev_name(&pdev->dev);
135-
irq_chip->irq_mask = mvebu_pic_mask_irq;
136-
irq_chip->irq_unmask = mvebu_pic_unmask_irq;
137-
irq_chip->irq_eoi = mvebu_pic_eoi_irq;
138-
139147
pic->parent_irq = irq_of_parse_and_map(node, 0);
140148
if (pic->parent_irq <= 0) {
141149
dev_err(&pdev->dev, "Failed to parse parent interrupt\n");

0 commit comments

Comments
 (0)