* [PATCH v2 0/3] irqchip/mbigen: bugfixs
@ 2017-05-12 3:55 Hanjun Guo
2017-05-12 3:55 ` [PATCH v2 1/3] irqchip/mbigen: Fix memory mapping code Hanjun Guo
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Hanjun Guo @ 2017-05-12 3:55 UTC (permalink / raw)
To: Marc Zyngier, Thomas Gleixner
Cc: Kefeng Wang, Wei Yongjun, MaJun, linux-kernel, linuxarm,
Hanjun Guo
From: Hanjun Guo <hanjun.guo@linaro.org>
Here are 3 bugfixes for mbigen:
Patch 1 is a critical bugfix which to fix the mbigen probe failure,
commit 216646e4d82e ("irqchip/mbigen: Fix return value check in
mbigen_device_probe()") introduced this breakage;
Patch 2 fixes a potential NULL dereferencing;
Patch 3 fixes a wrong clear register offset;
v1 -> v2:
- Rebase on top of lastest Linus tree (09d79d1 Merge tag
'docs-4.12-2' of git://git.lwn.net/linux);
- Fix a checkpatch error.
Thanks
Hanjun
Hanjun Guo (2):
irqchip/mbigen: Fix memory mapping code
irqchip/mbigen: Fix potential NULL dereferencing
MaJun (1):
irqchip/mbigen: Fix the clear register offset
drivers/irqchip/irq-mbigen.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
--
1.7.12.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/3] irqchip/mbigen: Fix memory mapping code
2017-05-12 3:55 [PATCH v2 0/3] irqchip/mbigen: bugfixs Hanjun Guo
@ 2017-05-12 3:55 ` Hanjun Guo
2017-05-12 8:34 ` [tip:irq/urgent] " tip-bot for Hanjun Guo
2017-05-12 3:55 ` [PATCH v2 2/3] irqchip/mbigen: Fix potential NULL dereferencing Hanjun Guo
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Hanjun Guo @ 2017-05-12 3:55 UTC (permalink / raw)
To: Marc Zyngier, Thomas Gleixner
Cc: Kefeng Wang, Wei Yongjun, MaJun, linux-kernel, linuxarm,
Hanjun Guo
From: Hanjun Guo <hanjun.guo@linaro.org>
Some mbigens share memory regions, and devm_ioremap_resource
does not allow to share resources which will break the probe
of mbigen, in opposition to devm_ioremap.
This patch restores back usage of devm_ioremap function, but
with proper error handling and logging.
Fixes: 216646e4d82e ("irqchip/mbigen: Fix return value check in mbigen_device_probe()")
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
drivers/irqchip/irq-mbigen.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c
index d2306c8..0f5e66e 100644
--- a/drivers/irqchip/irq-mbigen.c
+++ b/drivers/irqchip/irq-mbigen.c
@@ -337,9 +337,12 @@ static int mbigen_device_probe(struct platform_device *pdev)
mgn_chip->pdev = pdev;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- mgn_chip->base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(mgn_chip->base))
- return PTR_ERR(mgn_chip->base);
+ mgn_chip->base = devm_ioremap(&pdev->dev, res->start,
+ resource_size(res));
+ if (!mgn_chip->base) {
+ dev_err(&pdev->dev, "failed to ioremap %pR\n", res);
+ return -ENOMEM;
+ }
if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node)
err = mbigen_of_create_domain(pdev, mgn_chip);
--
1.7.12.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/3] irqchip/mbigen: Fix potential NULL dereferencing
2017-05-12 3:55 [PATCH v2 0/3] irqchip/mbigen: bugfixs Hanjun Guo
2017-05-12 3:55 ` [PATCH v2 1/3] irqchip/mbigen: Fix memory mapping code Hanjun Guo
@ 2017-05-12 3:55 ` Hanjun Guo
2017-05-12 8:35 ` [tip:irq/urgent] " tip-bot for Hanjun Guo
2017-05-12 3:55 ` [PATCH v2 3/3] irqchip/mbigen: Fix the clear register offset Hanjun Guo
` (2 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Hanjun Guo @ 2017-05-12 3:55 UTC (permalink / raw)
To: Marc Zyngier, Thomas Gleixner
Cc: Kefeng Wang, Wei Yongjun, MaJun, linux-kernel, linuxarm,
Hanjun Guo
From: Hanjun Guo <hanjun.guo@linaro.org>
platform_get_resource() may return NULL, add proper
check to avoid potential NULL dereferencing.
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
drivers/irqchip/irq-mbigen.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c
index 0f5e66e..2fa1e45 100644
--- a/drivers/irqchip/irq-mbigen.c
+++ b/drivers/irqchip/irq-mbigen.c
@@ -337,6 +337,9 @@ static int mbigen_device_probe(struct platform_device *pdev)
mgn_chip->pdev = pdev;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res)
+ return -EINVAL;
+
mgn_chip->base = devm_ioremap(&pdev->dev, res->start,
resource_size(res));
if (!mgn_chip->base) {
--
1.7.12.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 3/3] irqchip/mbigen: Fix the clear register offset
2017-05-12 3:55 [PATCH v2 0/3] irqchip/mbigen: bugfixs Hanjun Guo
2017-05-12 3:55 ` [PATCH v2 1/3] irqchip/mbigen: Fix memory mapping code Hanjun Guo
2017-05-12 3:55 ` [PATCH v2 2/3] irqchip/mbigen: Fix potential NULL dereferencing Hanjun Guo
@ 2017-05-12 3:55 ` Hanjun Guo
2017-05-12 8:35 ` [tip:irq/urgent] irqchip/mbigen: Fix the clear register offset calculation tip-bot for MaJun
2017-05-12 6:55 ` [PATCH v2 0/3] irqchip/mbigen: bugfixs majun (Euler7)
2017-05-12 7:58 ` Marc Zyngier
4 siblings, 1 reply; 9+ messages in thread
From: Hanjun Guo @ 2017-05-12 3:55 UTC (permalink / raw)
To: Marc Zyngier, Thomas Gleixner
Cc: Kefeng Wang, Wei Yongjun, MaJun, linux-kernel, linuxarm,
Hanjun Guo
From: MaJun <majun258@huawei.com>
Don't minus reserved interrupts (64) when get the clear
register offset, because the clear register space includes
the space of these 64 interrupts.
This bug wasn't discovered until we running the driver on
a new platform with an updated firmware. It turns out that
there is a timeout mechanism to clear the register in the
mbigen which is for debug purpose and should be turned off,
but because of configuration mistake in firmware, this
function was turned on and covered up the bug in clear offset
calculate, it's time to fix it now.
Fixes: a6c2f87b8820 ("irqchip/mbigen: Implement the mbigen irq chip operation functions")
Signed-off-by: MaJun <majun258@huawei.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
drivers/irqchip/irq-mbigen.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c
index 2fa1e45..57a860c 100644
--- a/drivers/irqchip/irq-mbigen.c
+++ b/drivers/irqchip/irq-mbigen.c
@@ -106,10 +106,7 @@ static inline void get_mbigen_type_reg(irq_hw_number_t hwirq,
static inline void get_mbigen_clear_reg(irq_hw_number_t hwirq,
u32 *mask, u32 *addr)
{
- unsigned int ofst;
-
- hwirq -= RESERVED_IRQ_PER_MBIGEN_CHIP;
- ofst = hwirq / 32 * 4;
+ unsigned int ofst = hwirq / 32 * 4;
*mask = 1 << (hwirq % 32);
*addr = ofst + REG_MBIGEN_CLEAR_OFFSET;
--
1.7.12.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/3] irqchip/mbigen: bugfixs
2017-05-12 3:55 [PATCH v2 0/3] irqchip/mbigen: bugfixs Hanjun Guo
` (2 preceding siblings ...)
2017-05-12 3:55 ` [PATCH v2 3/3] irqchip/mbigen: Fix the clear register offset Hanjun Guo
@ 2017-05-12 6:55 ` majun (Euler7)
2017-05-12 7:58 ` Marc Zyngier
4 siblings, 0 replies; 9+ messages in thread
From: majun (Euler7) @ 2017-05-12 6:55 UTC (permalink / raw)
To: Hanjun Guo, Marc Zyngier, Thomas Gleixner
Cc: majun258, Kefeng Wang, Wei Yongjun, linux-kernel, linuxarm,
Hanjun Guo
Hi Hanjun,
This patchset is fine to me and make my
D05 machine work again.So,
Tested-by: MaJun <majun258@huawei.com>
Thanks
Majun
在 2017/5/12 11:55, Hanjun Guo 写道:
> From: Hanjun Guo <hanjun.guo@linaro.org>
>
> Here are 3 bugfixes for mbigen:
>
> Patch 1 is a critical bugfix which to fix the mbigen probe failure,
> commit 216646e4d82e ("irqchip/mbigen: Fix return value check in
> mbigen_device_probe()") introduced this breakage;
>
> Patch 2 fixes a potential NULL dereferencing;
>
> Patch 3 fixes a wrong clear register offset;
>
> v1 -> v2:
> - Rebase on top of lastest Linus tree (09d79d1 Merge tag
> 'docs-4.12-2' of git://git.lwn.net/linux);
>
> - Fix a checkpatch error.
>
> Thanks
> Hanjun
>
> Hanjun Guo (2):
> irqchip/mbigen: Fix memory mapping code
> irqchip/mbigen: Fix potential NULL dereferencing
>
> MaJun (1):
> irqchip/mbigen: Fix the clear register offset
>
> drivers/irqchip/irq-mbigen.c | 17 ++++++++++-------
> 1 file changed, 10 insertions(+), 7 deletions(-)
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/3] irqchip/mbigen: bugfixs
2017-05-12 3:55 [PATCH v2 0/3] irqchip/mbigen: bugfixs Hanjun Guo
` (3 preceding siblings ...)
2017-05-12 6:55 ` [PATCH v2 0/3] irqchip/mbigen: bugfixs majun (Euler7)
@ 2017-05-12 7:58 ` Marc Zyngier
4 siblings, 0 replies; 9+ messages in thread
From: Marc Zyngier @ 2017-05-12 7:58 UTC (permalink / raw)
To: Hanjun Guo, Thomas Gleixner
Cc: Kefeng Wang, Wei Yongjun, MaJun, linux-kernel, linuxarm,
Hanjun Guo
On 12/05/17 04:55, Hanjun Guo wrote:
> From: Hanjun Guo <hanjun.guo@linaro.org>
>
> Here are 3 bugfixes for mbigen:
>
> Patch 1 is a critical bugfix which to fix the mbigen probe failure,
> commit 216646e4d82e ("irqchip/mbigen: Fix return value check in
> mbigen_device_probe()") introduced this breakage;
>
> Patch 2 fixes a potential NULL dereferencing;
>
> Patch 3 fixes a wrong clear register offset;
>
> v1 -> v2:
> - Rebase on top of lastest Linus tree (09d79d1 Merge tag
> 'docs-4.12-2' of git://git.lwn.net/linux);
>
> - Fix a checkpatch error.
>
> Thanks
> Hanjun
>
> Hanjun Guo (2):
> irqchip/mbigen: Fix memory mapping code
> irqchip/mbigen: Fix potential NULL dereferencing
>
> MaJun (1):
> irqchip/mbigen: Fix the clear register offset
>
> drivers/irqchip/irq-mbigen.c | 17 ++++++++++-------
> 1 file changed, 10 insertions(+), 7 deletions(-)
>
For the whole series:
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
M.
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 9+ messages in thread
* [tip:irq/urgent] irqchip/mbigen: Fix memory mapping code
2017-05-12 3:55 ` [PATCH v2 1/3] irqchip/mbigen: Fix memory mapping code Hanjun Guo
@ 2017-05-12 8:34 ` tip-bot for Hanjun Guo
0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Hanjun Guo @ 2017-05-12 8:34 UTC (permalink / raw)
To: linux-tip-commits
Cc: hpa, tglx, mingo, wangkefeng.wang, linux-kernel, marc.zyngier,
majun258, hanjun.guo, weiyongjun1
Commit-ID: 5ba9b0a14132d0b8d97affe909f324045a968d03
Gitweb: http://git.kernel.org/tip/5ba9b0a14132d0b8d97affe909f324045a968d03
Author: Hanjun Guo <hanjun.guo@linaro.org>
AuthorDate: Fri, 12 May 2017 11:55:26 +0800
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 12 May 2017 10:25:37 +0200
irqchip/mbigen: Fix memory mapping code
Some mbigens share memory regions, and devm_ioremap_resource
does not allow to share resources which will break the probe
of mbigen, in opposition to devm_ioremap.
This patch restores back usage of devm_ioremap function, but
with proper error handling and logging.
Fixes: 216646e4d82e ("irqchip/mbigen: Fix return value check in mbigen_device_probe()")
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: linuxarm@huawei.com
Cc: Wei Yongjun <weiyongjun1@huawei.com>
Cc: MaJun <majun258@huawei.com>
Link: http://lkml.kernel.org/r/1494561328-39514-2-git-send-email-guohanjun@huawei.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
drivers/irqchip/irq-mbigen.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c
index d2306c8..0f5e66e 100644
--- a/drivers/irqchip/irq-mbigen.c
+++ b/drivers/irqchip/irq-mbigen.c
@@ -337,9 +337,12 @@ static int mbigen_device_probe(struct platform_device *pdev)
mgn_chip->pdev = pdev;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- mgn_chip->base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(mgn_chip->base))
- return PTR_ERR(mgn_chip->base);
+ mgn_chip->base = devm_ioremap(&pdev->dev, res->start,
+ resource_size(res));
+ if (!mgn_chip->base) {
+ dev_err(&pdev->dev, "failed to ioremap %pR\n", res);
+ return -ENOMEM;
+ }
if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node)
err = mbigen_of_create_domain(pdev, mgn_chip);
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [tip:irq/urgent] irqchip/mbigen: Fix potential NULL dereferencing
2017-05-12 3:55 ` [PATCH v2 2/3] irqchip/mbigen: Fix potential NULL dereferencing Hanjun Guo
@ 2017-05-12 8:35 ` tip-bot for Hanjun Guo
0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Hanjun Guo @ 2017-05-12 8:35 UTC (permalink / raw)
To: linux-tip-commits
Cc: weiyongjun1, wangkefeng.wang, linux-kernel, majun258, hpa,
hanjun.guo, mingo, marc.zyngier, tglx
Commit-ID: ad7cc3c0c57d77b442db323056354d0e49833569
Gitweb: http://git.kernel.org/tip/ad7cc3c0c57d77b442db323056354d0e49833569
Author: Hanjun Guo <hanjun.guo@linaro.org>
AuthorDate: Fri, 12 May 2017 11:55:27 +0800
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 12 May 2017 10:25:37 +0200
irqchip/mbigen: Fix potential NULL dereferencing
platform_get_resource() may return NULL, add proper
check to avoid potential NULL dereferencing.
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: linuxarm@huawei.com
Cc: Wei Yongjun <weiyongjun1@huawei.com>
Cc: MaJun <majun258@huawei.com>
Link: http://lkml.kernel.org/r/1494561328-39514-3-git-send-email-guohanjun@huawei.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
drivers/irqchip/irq-mbigen.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c
index 0f5e66e..2fa1e45 100644
--- a/drivers/irqchip/irq-mbigen.c
+++ b/drivers/irqchip/irq-mbigen.c
@@ -337,6 +337,9 @@ static int mbigen_device_probe(struct platform_device *pdev)
mgn_chip->pdev = pdev;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res)
+ return -EINVAL;
+
mgn_chip->base = devm_ioremap(&pdev->dev, res->start,
resource_size(res));
if (!mgn_chip->base) {
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [tip:irq/urgent] irqchip/mbigen: Fix the clear register offset calculation
2017-05-12 3:55 ` [PATCH v2 3/3] irqchip/mbigen: Fix the clear register offset Hanjun Guo
@ 2017-05-12 8:35 ` tip-bot for MaJun
0 siblings, 0 replies; 9+ messages in thread
From: tip-bot for MaJun @ 2017-05-12 8:35 UTC (permalink / raw)
To: linux-tip-commits
Cc: hanjun.guo, weiyongjun1, majun258, hpa, tglx, wangkefeng.wang,
mingo, linux-kernel, marc.zyngier
Commit-ID: 9459a04b6a5a09967eec94a1b66f0a74312819d9
Gitweb: http://git.kernel.org/tip/9459a04b6a5a09967eec94a1b66f0a74312819d9
Author: MaJun <majun258@huawei.com>
AuthorDate: Fri, 12 May 2017 11:55:28 +0800
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 12 May 2017 10:25:38 +0200
irqchip/mbigen: Fix the clear register offset calculation
The register array offset for clearing an interrupt is calculated by:
offset = (hwirq - RESERVED_IRQ_PER_MBIGEN_CHIP) / 32;
This is wrong because the clear register array includes the reserved
interrupts. So the clear operation ends up in the wrong register.
This went unnoticed so far, because the hardware clears the real bit
through a timeout mechanism when the hardware is configured in debug
mode. That debug mode was enabled on early generations of the hardware, so
the problem was papered over.
On newer hardware with updated firmware the debug mode was disabled, so the
bits did not get cleared which causes the system to malfunction.
Remove the subtraction of RESERVED_IRQ_PER_MBIGEN_CHIP, so the correct
register is accessed.
[ tglx: Rewrote changelog ]
Fixes: a6c2f87b8820 ("irqchip/mbigen: Implement the mbigen irq chip operation functions")
Signed-off-by: MaJun <majun258@huawei.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: linuxarm@huawei.com
Cc: Wei Yongjun <weiyongjun1@huawei.com>
Link: http://lkml.kernel.org/r/1494561328-39514-4-git-send-email-guohanjun@huawei.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
drivers/irqchip/irq-mbigen.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c
index 2fa1e45..31d6b5a 100644
--- a/drivers/irqchip/irq-mbigen.c
+++ b/drivers/irqchip/irq-mbigen.c
@@ -106,10 +106,7 @@ static inline void get_mbigen_type_reg(irq_hw_number_t hwirq,
static inline void get_mbigen_clear_reg(irq_hw_number_t hwirq,
u32 *mask, u32 *addr)
{
- unsigned int ofst;
-
- hwirq -= RESERVED_IRQ_PER_MBIGEN_CHIP;
- ofst = hwirq / 32 * 4;
+ unsigned int ofst = (hwirq / 32) * 4;
*mask = 1 << (hwirq % 32);
*addr = ofst + REG_MBIGEN_CLEAR_OFFSET;
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-05-12 8:37 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-12 3:55 [PATCH v2 0/3] irqchip/mbigen: bugfixs Hanjun Guo
2017-05-12 3:55 ` [PATCH v2 1/3] irqchip/mbigen: Fix memory mapping code Hanjun Guo
2017-05-12 8:34 ` [tip:irq/urgent] " tip-bot for Hanjun Guo
2017-05-12 3:55 ` [PATCH v2 2/3] irqchip/mbigen: Fix potential NULL dereferencing Hanjun Guo
2017-05-12 8:35 ` [tip:irq/urgent] " tip-bot for Hanjun Guo
2017-05-12 3:55 ` [PATCH v2 3/3] irqchip/mbigen: Fix the clear register offset Hanjun Guo
2017-05-12 8:35 ` [tip:irq/urgent] irqchip/mbigen: Fix the clear register offset calculation tip-bot for MaJun
2017-05-12 6:55 ` [PATCH v2 0/3] irqchip/mbigen: bugfixs majun (Euler7)
2017-05-12 7:58 ` Marc Zyngier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox