All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Wim Van Sebroeck <wim@iguana.be>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Mike Waychison <mikew@google.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Jeremy Fitzhardinge <jeremy@goop.org>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	linux-watchdog@vger.kernel.org,
	Priyanka Gupta <priyankag@google.com>
Subject: [PATCH -v3 -resend] watchdog, SP5100: Check if firmware has set correct value in tcobase.
Date: Wed, 23 Mar 2011 22:33:05 -0700	[thread overview]
Message-ID: <4D8AD791.9010602@kernel.org> (raw)
In-Reply-To: <20110317022331.GA3528@dumpdata.com>


Stefano found SP5100 TCO watchdog driver using wrong address.

[    9.148536] SP5100 TCO timer: SP5100 TCO WatchDog Timer Driver v0.01
[    9.148628] DEBUG __ioremap_caller WARNING address=b8fe00 size=8 valid=1 reserved=1

and e820 said that range is RAM.

We should check if we can use that reading out. BIOS could just program wrong address there.

-v2: Mike pointed out one path need one release.
-v3: corrected logic checking with request_mem_region_exclusive()
      Found by Konrad.


Reported-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by:Yinghai Lu <yinghai@kernel.org>
Acked-by: Mike Waychison <mikew@google.com>
Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

---
  drivers/watchdog/sp5100_tco.c |   14 ++++++++++++--
  1 file changed, 12 insertions(+), 2 deletions(-)

Index: linux-2.6/drivers/watchdog/sp5100_tco.c
===================================================================
--- linux-2.6.orig/drivers/watchdog/sp5100_tco.c
+++ linux-2.6/drivers/watchdog/sp5100_tco.c
@@ -42,6 +42,7 @@
  #define PFX TCO_MODULE_NAME ": "
  
  /* internal variables */
+static u32 tcobase_phys;
  static void __iomem *tcobase;
  static unsigned int pm_iobase;
  static DEFINE_SPINLOCK(tco_lock);	/* Guards the hardware */
@@ -305,10 +306,16 @@ static unsigned char __devinit sp5100_tc
  	/* Low three bits of BASE0 are reserved. */
  	val = val << 8 | (inb(SP5100_IO_PM_DATA_REG) & 0xf8);
  
+	if (!request_mem_region_exclusive(val, SP5100_WDT_MEM_MAP_SIZE, "SP5100 TCO")) {
+		printk(KERN_ERR PFX "mmio address 0x%04x already in use\n", val);
+		goto unreg_region;
+	}
+	tcobase_phys = val;
+
  	tcobase = ioremap(val, SP5100_WDT_MEM_MAP_SIZE);
  	if (tcobase == 0) {
  		printk(KERN_ERR PFX "failed to get tcobase address\n");
-		goto unreg_region;
+		goto unreg_mem_region;
  	}
  
  	/* Enable watchdog decode bit */
@@ -346,7 +353,8 @@ static unsigned char __devinit sp5100_tc
  	/* Done */
  	return 1;
  
-	iounmap(tcobase);
+unreg_mem_region:
+	release_mem_region(tcobase_phys, SP5100_WDT_MEM_MAP_SIZE);
  unreg_region:
  	release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE);
  exit:
@@ -401,6 +409,7 @@ static int __devinit sp5100_tco_init(str
  
  exit:
  	iounmap(tcobase);
+	release_mem_region(tcobase_phys, SP5100_WDT_MEM_MAP_SIZE);
  	release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE);
  	return ret;
  }
@@ -414,6 +423,7 @@ static void __devexit sp5100_tco_cleanup
  	/* Deregister */
  	misc_deregister(&sp5100_tco_miscdev);
  	iounmap(tcobase);
+	release_mem_region(tcobase_phys, SP5100_WDT_MEM_MAP_SIZE);
  	release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE);
  }
  

WARNING: multiple messages have this Message-ID (diff)
From: Yinghai Lu <yinghai@kernel.org>
To: Wim Van Sebroeck <wim@iguana.be>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Priyanka Gupta <priyankag@google.com>,
	Jeremy Fitzhardinge <jeremy@goop.org>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	linux-watchdog@vger.kernel.org,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Mike Waychison <mikew@google.com>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: [PATCH -v3 -resend] watchdog, SP5100: Check if firmware has set correct value in tcobase.
Date: Wed, 23 Mar 2011 22:33:05 -0700	[thread overview]
Message-ID: <4D8AD791.9010602@kernel.org> (raw)
In-Reply-To: <20110317022331.GA3528@dumpdata.com>


Stefano found SP5100 TCO watchdog driver using wrong address.

[    9.148536] SP5100 TCO timer: SP5100 TCO WatchDog Timer Driver v0.01
[    9.148628] DEBUG __ioremap_caller WARNING address=b8fe00 size=8 valid=1 reserved=1

and e820 said that range is RAM.

We should check if we can use that reading out. BIOS could just program wrong address there.

-v2: Mike pointed out one path need one release.
-v3: corrected logic checking with request_mem_region_exclusive()
      Found by Konrad.


Reported-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by:Yinghai Lu <yinghai@kernel.org>
Acked-by: Mike Waychison <mikew@google.com>
Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

---
  drivers/watchdog/sp5100_tco.c |   14 ++++++++++++--
  1 file changed, 12 insertions(+), 2 deletions(-)

Index: linux-2.6/drivers/watchdog/sp5100_tco.c
===================================================================
--- linux-2.6.orig/drivers/watchdog/sp5100_tco.c
+++ linux-2.6/drivers/watchdog/sp5100_tco.c
@@ -42,6 +42,7 @@
  #define PFX TCO_MODULE_NAME ": "
  
  /* internal variables */
+static u32 tcobase_phys;
  static void __iomem *tcobase;
  static unsigned int pm_iobase;
  static DEFINE_SPINLOCK(tco_lock);	/* Guards the hardware */
@@ -305,10 +306,16 @@ static unsigned char __devinit sp5100_tc
  	/* Low three bits of BASE0 are reserved. */
  	val = val << 8 | (inb(SP5100_IO_PM_DATA_REG) & 0xf8);
  
+	if (!request_mem_region_exclusive(val, SP5100_WDT_MEM_MAP_SIZE, "SP5100 TCO")) {
+		printk(KERN_ERR PFX "mmio address 0x%04x already in use\n", val);
+		goto unreg_region;
+	}
+	tcobase_phys = val;
+
  	tcobase = ioremap(val, SP5100_WDT_MEM_MAP_SIZE);
  	if (tcobase == 0) {
  		printk(KERN_ERR PFX "failed to get tcobase address\n");
-		goto unreg_region;
+		goto unreg_mem_region;
  	}
  
  	/* Enable watchdog decode bit */
@@ -346,7 +353,8 @@ static unsigned char __devinit sp5100_tc
  	/* Done */
  	return 1;
  
-	iounmap(tcobase);
+unreg_mem_region:
+	release_mem_region(tcobase_phys, SP5100_WDT_MEM_MAP_SIZE);
  unreg_region:
  	release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE);
  exit:
@@ -401,6 +409,7 @@ static int __devinit sp5100_tco_init(str
  
  exit:
  	iounmap(tcobase);
+	release_mem_region(tcobase_phys, SP5100_WDT_MEM_MAP_SIZE);
  	release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE);
  	return ret;
  }
@@ -414,6 +423,7 @@ static void __devexit sp5100_tco_cleanup
  	/* Deregister */
  	misc_deregister(&sp5100_tco_miscdev);
  	iounmap(tcobase);
+	release_mem_region(tcobase_phys, SP5100_WDT_MEM_MAP_SIZE);
  	release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE);
  }

  parent reply	other threads:[~2011-03-24  5:33 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-11 13:17 [GIT PULL tip/x86/mm] xen/x86 fixes Stefano Stabellini
2011-03-11 13:17 ` Stefano Stabellini
2011-03-11 22:21 ` Konrad Rzeszutek Wilk
2011-03-16 12:28   ` Stefano Stabellini
2011-03-16 12:28     ` Stefano Stabellini
2011-03-16 14:43     ` Stefano Stabellini
2011-03-16 14:43       ` Stefano Stabellini
2011-03-16 17:55       ` Yinghai Lu
2011-03-16 17:55         ` Yinghai Lu
2011-03-16 18:02         ` Stefano Stabellini
2011-03-16 20:45           ` [GIT PULL tip/x86/mm] xen/x86 fixes ===> fix sp5100_tco mmio checking Yinghai Lu
2011-03-16 21:01             ` Mike Waychison
2011-03-16 21:18               ` [PATCH] watchdog, SP5100: Check if firmware has set correct value in tcobase Yinghai Lu
2011-03-17  0:00                 ` Konrad Rzeszutek Wilk
2011-03-17  2:23                 ` Konrad Rzeszutek Wilk
2011-03-17  2:23                   ` Konrad Rzeszutek Wilk
2011-03-17  3:01                   ` [PATCH -v3] " Yinghai Lu
2011-03-18 13:10                     ` [Xen-devel] " Konrad Rzeszutek Wilk
2011-03-18 16:39                       ` Yinghai Lu
2011-03-18 16:39                         ` Yinghai Lu
2011-03-17 12:35                   ` [PATCH] " Stefano Stabellini
2011-03-24  5:33                   ` Yinghai Lu [this message]
2011-03-24  5:33                     ` [PATCH -v3 -resend] " Yinghai Lu
2011-03-24  8:31                     ` Wim Van Sebroeck
2011-03-24  8:31                       ` Wim Van Sebroeck
2011-03-24 15:40                       ` Yinghai Lu
2011-03-17 12:44     ` [GIT PULL tip/x86/mm] xen/x86 fixes Stefano Stabellini
2011-03-17 17:25       ` Yinghai Lu
2011-03-17 17:38         ` Stefano Stabellini
2011-03-17 17:38           ` Stefano Stabellini

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=4D8AD791.9010602@kernel.org \
    --to=yinghai@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=jeremy@goop.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=mikew@google.com \
    --cc=priyankag@google.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wim@iguana.be \
    --cc=xen-devel@lists.xensource.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.