Skip to content

Commit 6be6cba

Browse files
Yipeng ZouKAGA-KOKO
Yipeng Zou
authored andcommitted
irqchip/mbigen: Fix mbigen node address layout
The mbigen interrupt chip has its per node registers located in a contiguous region of page sized chunks. The code maps them into virtual address space as a contiguous region and determines the address of a node by using the node ID as index. mbigen chip |-----------------|------------|--------------| mgn_node_0 mgn_node_1 ... mgn_node_i |--------------| |--------------| |----------------------| [0x0000, 0x0x0FFF] [0x1000, 0x1FFF] [i*0x1000, (i+1)*0x1000 - 1] This works correctly up to 10 nodes, but then fails because the 11th's array slot is used for the MGN_CLEAR registers. mbigen chip |-----------|--------|--------|---------------|--------| mgn_node_0 mgn_node_1 ... mgn_clear_register ... mgn_node_i |-----------------| [0xA000, 0xAFFF] Skip the MGN_CLEAR register space when calculating the offset for node IDs greater than or equal to ten. Fixes: a6c2f87 ("irqchip/mbigen: Implement the mbigen irq chip operation functions") Signed-off-by: Yipeng Zou <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent f872d4a commit 6be6cba

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

drivers/irqchip/irq-mbigen.c

+16-4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@ struct mbigen_device {
6464
void __iomem *base;
6565
};
6666

67+
static inline unsigned int get_mbigen_node_offset(unsigned int nid)
68+
{
69+
unsigned int offset = nid * MBIGEN_NODE_OFFSET;
70+
71+
/*
72+
* To avoid touched clear register in unexpected way, we need to directly
73+
* skip clear register when access to more than 10 mbigen nodes.
74+
*/
75+
if (nid >= (REG_MBIGEN_CLEAR_OFFSET / MBIGEN_NODE_OFFSET))
76+
offset += MBIGEN_NODE_OFFSET;
77+
78+
return offset;
79+
}
80+
6781
static inline unsigned int get_mbigen_vec_reg(irq_hw_number_t hwirq)
6882
{
6983
unsigned int nid, pin;
@@ -72,8 +86,7 @@ static inline unsigned int get_mbigen_vec_reg(irq_hw_number_t hwirq)
7286
nid = hwirq / IRQS_PER_MBIGEN_NODE + 1;
7387
pin = hwirq % IRQS_PER_MBIGEN_NODE;
7488

75-
return pin * 4 + nid * MBIGEN_NODE_OFFSET
76-
+ REG_MBIGEN_VEC_OFFSET;
89+
return pin * 4 + get_mbigen_node_offset(nid) + REG_MBIGEN_VEC_OFFSET;
7790
}
7891

7992
static inline void get_mbigen_type_reg(irq_hw_number_t hwirq,
@@ -88,8 +101,7 @@ static inline void get_mbigen_type_reg(irq_hw_number_t hwirq,
88101
*mask = 1 << (irq_ofst % 32);
89102
ofst = irq_ofst / 32 * 4;
90103

91-
*addr = ofst + nid * MBIGEN_NODE_OFFSET
92-
+ REG_MBIGEN_TYPE_OFFSET;
104+
*addr = ofst + get_mbigen_node_offset(nid) + REG_MBIGEN_TYPE_OFFSET;
93105
}
94106

95107
static inline void get_mbigen_clear_reg(irq_hw_number_t hwirq,

0 commit comments

Comments
 (0)