mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/3] irqchip/mbigen: Fix memory mapping code
@ 2017-05-02  7:06 Hanjun Guo
  2017-05-02  7:06 ` [PATCH 2/3] irqchip/mbigen: Fix potential NULL dereferencing Hanjun Guo
  2017-05-02  7:06 ` [PATCH 3/3] irqchip/mbigen: Fix the clear register offset Hanjun Guo
  0 siblings, 2 replies; 3+ messages in thread
From: Hanjun Guo @ 2017-05-02  7:06 UTC (permalink / raw)
  To: Thomas Gleixner, Marc Zyngier
  Cc: Kefeng Wang, Wei Yongjun, MaJun, linux-kernel, 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..e1d99f4 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	[flat|nested] 3+ messages in thread

* [PATCH 2/3] irqchip/mbigen: Fix potential NULL dereferencing
  2017-05-02  7:06 [PATCH 1/3] irqchip/mbigen: Fix memory mapping code Hanjun Guo
@ 2017-05-02  7:06 ` Hanjun Guo
  2017-05-02  7:06 ` [PATCH 3/3] irqchip/mbigen: Fix the clear register offset Hanjun Guo
  1 sibling, 0 replies; 3+ messages in thread
From: Hanjun Guo @ 2017-05-02  7:06 UTC (permalink / raw)
  To: Thomas Gleixner, Marc Zyngier
  Cc: Kefeng Wang, Wei Yongjun, MaJun, linux-kernel, 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 e1d99f4..167cdb5 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	[flat|nested] 3+ messages in thread

* [PATCH 3/3] irqchip/mbigen: Fix the clear register offset
  2017-05-02  7:06 [PATCH 1/3] irqchip/mbigen: Fix memory mapping code Hanjun Guo
  2017-05-02  7:06 ` [PATCH 2/3] irqchip/mbigen: Fix potential NULL dereferencing Hanjun Guo
@ 2017-05-02  7:06 ` Hanjun Guo
  1 sibling, 0 replies; 3+ messages in thread
From: Hanjun Guo @ 2017-05-02  7:06 UTC (permalink / raw)
  To: Thomas Gleixner, Marc Zyngier
  Cc: Kefeng Wang, Wei Yongjun, MaJun, linux-kernel, 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 167cdb5..295c2a0 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	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-05-02  7:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-02  7:06 [PATCH 1/3] irqchip/mbigen: Fix memory mapping code Hanjun Guo
2017-05-02  7:06 ` [PATCH 2/3] irqchip/mbigen: Fix potential NULL dereferencing Hanjun Guo
2017-05-02  7:06 ` [PATCH 3/3] irqchip/mbigen: Fix the clear register offset Hanjun Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome