All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jon Hunter <jon-hunter@ti.com>
To: Tony Lindgren <tony@atomide.com>
Cc: linux-omap <linux-omap@vger.kernel.org>,
	linux-arm <linux-arm-kernel@lists.infradead.org>,
	Afzal Mohammed <afzal@ti.com>, Jon Hunter <jon-hunter@ti.com>
Subject: [PATCH 1/2] ARM: OMAP2+: Prevent potential crash if GPMC probe fails
Date: Fri, 1 Feb 2013 10:38:45 -0600	[thread overview]
Message-ID: <1359736726-10193-2-git-send-email-jon-hunter@ti.com> (raw)
In-Reply-To: <1359736726-10193-1-git-send-email-jon-hunter@ti.com>

If the GPMC probe fails, devices that use the GPMC (such as ethernet
chips, flash memories, etc) can still allocate a GPMC chip-select and
register the device. On the OMAP2420 H4 board, this was causing the
kernel to crash after the gpmc probe failed and the board attempted
to start networking. Prevent this by marking all the chip-selects as
reserved by default and only make them available for devices to request
if the GPMC probe succeeds.

Signed-off-by: Jon Hunter <jon-hunter@ti.com>
---
 arch/arm/mach-omap2/gpmc.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 8033cb7..441cc63 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -145,7 +145,8 @@ static unsigned gpmc_irq_start;
 static struct resource	gpmc_mem_root;
 static struct resource	gpmc_cs_mem[GPMC_CS_NUM];
 static DEFINE_SPINLOCK(gpmc_mem_lock);
-static unsigned int gpmc_cs_map;	/* flag for cs which are initialized */
+/* Define chip-selects as reserved by default until probe completes */
+static unsigned int gpmc_cs_map = ((1 << GPMC_CS_NUM) - 1);
 static struct device *gpmc_dev;
 static int gpmc_irq;
 static resource_size_t phys_base, mem_size;
@@ -1174,6 +1175,9 @@ static int gpmc_probe(struct platform_device *pdev)
 	if (IS_ERR_VALUE(gpmc_setup_irq()))
 		dev_warn(gpmc_dev, "gpmc_setup_irq failed\n");
 
+	/* Now the GPMC is initialised, unreserve the chip-selects */
+	gpmc_cs_map = 0;
+
 	return 0;
 }
 
-- 
1.7.10.4


WARNING: multiple messages have this Message-ID (diff)
From: jon-hunter@ti.com (Jon Hunter)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] ARM: OMAP2+: Prevent potential crash if GPMC probe fails
Date: Fri, 1 Feb 2013 10:38:45 -0600	[thread overview]
Message-ID: <1359736726-10193-2-git-send-email-jon-hunter@ti.com> (raw)
In-Reply-To: <1359736726-10193-1-git-send-email-jon-hunter@ti.com>

If the GPMC probe fails, devices that use the GPMC (such as ethernet
chips, flash memories, etc) can still allocate a GPMC chip-select and
register the device. On the OMAP2420 H4 board, this was causing the
kernel to crash after the gpmc probe failed and the board attempted
to start networking. Prevent this by marking all the chip-selects as
reserved by default and only make them available for devices to request
if the GPMC probe succeeds.

Signed-off-by: Jon Hunter <jon-hunter@ti.com>
---
 arch/arm/mach-omap2/gpmc.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 8033cb7..441cc63 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -145,7 +145,8 @@ static unsigned gpmc_irq_start;
 static struct resource	gpmc_mem_root;
 static struct resource	gpmc_cs_mem[GPMC_CS_NUM];
 static DEFINE_SPINLOCK(gpmc_mem_lock);
-static unsigned int gpmc_cs_map;	/* flag for cs which are initialized */
+/* Define chip-selects as reserved by default until probe completes */
+static unsigned int gpmc_cs_map = ((1 << GPMC_CS_NUM) - 1);
 static struct device *gpmc_dev;
 static int gpmc_irq;
 static resource_size_t phys_base, mem_size;
@@ -1174,6 +1175,9 @@ static int gpmc_probe(struct platform_device *pdev)
 	if (IS_ERR_VALUE(gpmc_setup_irq()))
 		dev_warn(gpmc_dev, "gpmc_setup_irq failed\n");
 
+	/* Now the GPMC is initialised, unreserve the chip-selects */
+	gpmc_cs_map = 0;
+
 	return 0;
 }
 
-- 
1.7.10.4

  reply	other threads:[~2013-02-01 16:38 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-01 16:38 [PATCH 0/2] ARM: OMAP2+: GPMC Fixes Jon Hunter
2013-02-01 16:38 ` Jon Hunter
2013-02-01 16:38 ` Jon Hunter [this message]
2013-02-01 16:38   ` [PATCH 1/2] ARM: OMAP2+: Prevent potential crash if GPMC probe fails Jon Hunter
2013-02-01 22:08   ` Tony Lindgren
2013-02-01 22:08     ` Tony Lindgren
2013-02-08 22:56     ` Jon Hunter
2013-02-08 22:56       ` Jon Hunter
2013-02-09 15:55       ` Ezequiel Garcia
2013-02-09 15:55         ` Ezequiel Garcia
2013-02-14 12:04         ` Philip, Avinash
2013-02-14 12:04           ` Philip, Avinash
2013-02-16 22:37           ` Grazvydas Ignotas
2013-02-16 22:37             ` Grazvydas Ignotas
2013-02-01 16:38 ` [PATCH 2/2] ARM: OMAP2: Fix GPMC memory initialisation Jon Hunter
2013-02-01 16:38   ` Jon Hunter
2013-02-01 21:51   ` Tony Lindgren
2013-02-01 21:51     ` Tony Lindgren
2013-02-02  1:22     ` Jon Hunter
2013-02-02  1:22       ` Jon Hunter
2013-02-02 18:11       ` Tony Lindgren
2013-02-02 18:11         ` Tony Lindgren
2013-02-04 15:05         ` Jon Hunter
2013-02-04 15:05           ` Jon Hunter
2013-02-04 17:45           ` Tony Lindgren
2013-02-04 17:45             ` Tony Lindgren
2013-02-04 18:46             ` Jon Hunter
2013-02-04 18:46               ` Jon Hunter
2013-02-04 19:15               ` Tony Lindgren
2013-02-04 19:15                 ` Tony Lindgren
2013-02-04 19:33                 ` Jon Hunter
2013-02-04 19:33                   ` Jon Hunter
2013-02-04 19:47                   ` Tony Lindgren
2013-02-04 19:47                     ` Tony Lindgren
2013-02-04 19:51                     ` Jon Hunter
2013-02-04 19:51                       ` Jon Hunter
2013-02-04 22:12     ` Jon Hunter
2013-02-04 22:12       ` Jon Hunter
2013-02-04 22:45       ` Jon Hunter
2013-02-04 22:45         ` Jon Hunter
2013-02-05 23:34         ` Tony Lindgren
2013-02-05 23:34           ` Tony Lindgren
2013-02-06  0:22           ` Jon Hunter
2013-02-06  0:22             ` Jon Hunter
2013-02-06 17:28             ` Tony Lindgren
2013-02-06 17:28               ` Tony Lindgren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1359736726-10193-2-git-send-email-jon-hunter@ti.com \
    --to=jon-hunter@ti.com \
    --cc=afzal@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.