irqchip/mbigen: Fix mbigen node address layout
PATCH 1/1 irqchip/mbigen: Fix mbigen node address layout
Mbigen chip contains several mbigen nodes, and mapped address space per nodes one by one.
mbigen chip
|-----------------|------------|--------------|
mgn_node_0 mgn_node_1 ... mgn_node_i
|--------------| |--------------| |----------------------|
[0x0000, 0x1000) [0x1000, 0x2000) [i*0x1000, (i+1)*0x1000)Mbigen also defined a clear register with all other mbigen nodes in uniform address space.
mbigen chip
|-----------|--------|--------|---------------|--------|
mgn_node_0 mgn_node_1 ... mgn_clear_register ... mgn_node_i
|-----------------|
[0xA000, 0xB000)Everything is OK for now, when the mbigen nodes number less than 10, there is no conflict with clear register.
Once we defined mbigen node more than 10, it's going to touch clear register in unexpected way.
There should have a gap of 0x1000 between mgn_node9 and mgn_node10.
The simplest solution is directly skip clear register when access to more than 10 mbigen nodes.
--- drivers/irqchip/irq-mbigen.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/irqchip/irq-mbigen.c +16 -2
@@ -64,6 +64,20 @@ struct mbigen_device {void __iomem *base; }; +static inline unsigned int get_mbigen_node_offset (unsigned int nid) +{ +unsigned int offset = nid *MBIGEN_NODE_OFFSET ; + +/** +* To avoid touched clear register in unexpected way, we need to directly +* skip clear register when access to more than 10 mbigen nodes. +*/ +if (nid >= (REG_MBIGEN_CLEAR_OFFSET /MBIGEN_NODE_OFFSET )) + offset +=MBIGEN_NODE_OFFSET ; + +return offset; +} +static inline unsigned int get_mbigen_vec_reg (irq_hw_number_t hwirq) {unsigned int nid, pin;
@@ -72,7 +86,7 @@ static inline unsigned int get_mbigen_vec_reg(irq_hw_number_t hwirq) nid = hwirq /IRQS_PER_MBIGEN_NODE +1 ; pin = hwirq %IRQS_PER_MBIGEN_NODE ; -return pin *4 + nid *MBIGEN_NODE_OFFSET +return pin *4 +get_mbigen_node_offset (nid) +REG_MBIGEN_VEC_OFFSET ; }
@@ -88,7 +102,7 @@ static inline void get_mbigen_type_reg(irq_hw_number_t hwirq, *mask =1 << (irq_ofst %32 ); ofst = irq_ofst /32 *4 ; - *addr = ofst + nid *MBIGEN_NODE_OFFSET + *addr = ofst +get_mbigen_node_offset (nid) +REG_MBIGEN_TYPE_OFFSET ; }
Signature · 1 line
2.34.1
Quoted 21 lines · Yipeng Zou
Mbigen chip contains several mbigen nodes, and mapped address space per nodes one by one.
mbigen chip |-----------------|------------|--------------| mgn_node_0 mgn_node_1 ... mgn_node_i |--------------| |--------------| |----------------------| [0x0000, 0x1000) [0x1000, 0x2000) [i*0x1000, (i+1)*0x1000)Mbigen also defined a clear register with all other mbigen nodes in uniform address space.
mbigen chip |-----------|--------|--------|---------------|--------| mgn_node_0 mgn_node_1 ... mgn_clear_register ... mgn_node_i |-----------------| [0xA000, 0xB000)Everything is OK for now, when the mbigen nodes number less than 10, there is no conflict with clear register.
Quoted 7 lines
Once we defined mbigen node more than 10, it's going to touch clear register in unexpected way.
There should have a gap of
0x1000betweenmgn_node9andmgn_node10.The simplest solution is directly skip clear register when access to more than 10 mbigen nodes.
I see what you are trying to tell. Something like this makes it more clear:
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.
This works correctly up to 10 nodes, but then fails because the 11th's array slot is used for the MGN_CLEAR registers.
Skip the MGN_CLEAR register space when calculating the offset for node IDs greater or equal ten.
Hmm?
Quoted 11 lines
Fixes a6c2f87b8820 ("irqchip/mbigen: Implement the mbigen irq chip operation functions")Signed-off-by Yipeng Zou <[email protected]>--- drivers/irqchip/irq-mbigen.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)drivers/irqchip/irq-mbigen.c +0
-0
drivers/irqchip/irq-mbigen.c struct mbigen_device { · line 71
Quoted 8 lines
drivers/irqchip/irq-mbigen.c +5
-0@@ -64,6 +64,20 @@ struct mbigen_device {void __iomem *base; }; +static inline unsigned int get_mbigen_node_offset (unsigned int nid) +{ +unsigned int offset = nid *MBIGEN_NODE_OFFSET ; + +/**
This is not a kernel doc comment. Please use '/*'
drivers/irqchip/irq-mbigen.c static inline unsigned int get_mbigen_vec_reg(irq_hw_number_t hwirq) · line 90
Quoted 11 lines
drivers/irqchip/irq-mbigen.c +4
-1+* To avoid touched clear register in unexpected way, we need to directly +* skip clear register when access to more than 10 mbigen nodes. +*/ @@ -72,7 +86,7 @@ static inline unsigned int get_mbigen_vec_reg(irq_hw_number_t hwirq) nid = hwirq /IRQS_PER_MBIGEN_NODE +1 ; pin = hwirq %IRQS_PER_MBIGEN_NODE ; -return pin *4 + nid *MBIGEN_NODE_OFFSET +return pin *4 +get_mbigen_node_offset (nid) +REG_MBIGEN_VEC_OFFSET ;
Please get rid of these pointless line breaks.
Thanks,
tglx
Hi Thomas:
Reword it in v2.
https://lore.kernel.org/all/[email protected]/T/#u
Quoted 81 lines · Thomas Gleixner
Quoted 21 lines · Yipeng Zou
Mbigen chip contains several mbigen nodes, and mapped address space per nodes one by one.
mbigen chip
|-----------------|------------|--------------|
mgn_node_0mgn_node_1...mgn_node_i|--------------| |--------------| |----------------------| [0x0000, 0x1000) [0x1000, 0x2000) [i*0x1000, (i+1)*0x1000)Mbigen also defined a clear register with all other mbigen nodes in uniform address space.
mbigen chip |-----------|--------|--------|---------------|--------| mgn_node_0 mgn_node_1 ... mgn_clear_register ... mgn_node_i |-----------------| [0xA000, 0xB000)Everything is OK for now, when the mbigen nodes number less than 10, there is no conflict with clear register.
Quoted 7 lines
Once we defined mbigen node more than 10, it's going to touch clear register in unexpected way.
There should have a gap of
0x1000betweenmgn_node9andmgn_node10.The simplest solution is directly skip clear register when access to more than 10 mbigen nodes.
I see what you are trying to tell. Something like this makes it more clear:
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.
This works correctly up to 10 nodes, but then fails because the 11th's array slot is used for the
MGN_CLEARregisters.Skip the
MGN_CLEARregister space when calculating the offset for node IDs greater or equal ten.Hmm?
Quoted 11 lines
Fixes a6c2f87b8820 ("irqchip/mbigen: Implement the mbigen irq chip operation functions")Signed-off-by Yipeng Zou <[email protected]>--- drivers/irqchip/irq-mbigen.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)drivers/irqchip/irq-mbigen.c +0
-0drivers/irqchip/irq-mbigen.c struct mbigen_device { · line 71
Quoted 8 lines
drivers/irqchip/irq-mbigen.c +5
-0@@ -64,6 +64,20 @@ struct mbigen_device {void __iomem *base; }; +static inline unsigned int get_mbigen_node_offset (unsigned int nid) +{ +unsigned int offset = nid *MBIGEN_NODE_OFFSET ; + +/** This is not a kernel doc comment. Please use '/*'
drivers/irqchip/irq-mbigen.c static inline unsigned int get_mbigen_vec_reg(irq_hw_number_t hwirq) · line 90
Quoted 10 lines
drivers/irqchip/irq-mbigen.c +4
-1+* To avoid touched clear register in unexpected way, we need to directly +* skip clear register when access to more than 10 mbigen nodes. +*/ @@ -72,7 +86,7 @@ static inline unsigned int get_mbigen_vec_reg(irq_hw_number_t hwirq) nid = hwirq /IRQS_PER_MBIGEN_NODE +1 ; pin = hwirq %IRQS_PER_MBIGEN_NODE ; -return pin *4 + nid *MBIGEN_NODE_OFFSET +return pin *4 +get_mbigen_node_offset (nid) +REG_MBIGEN_VEC_OFFSET ;Please get rid of these pointless line breaks.
Thanks,
tglx
Signature · 2 lines
Regards, Yipeng Zou