Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[PATCH] watchdog, SP5100: Check if firmware has set correct value in tcobase.

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


yinghai at kernel

Mar 16, 2011, 2:18 PM

Post #1 of 4 (1770 views)
Permalink
[PATCH] watchdog, SP5100: Check if firmware has set correct value in tcobase.

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.

Reported-by: Stefano Stabellini <stefano.stabellini [at] eu>
Signed-off-by:Yinghai Lu <yinghai [at] kernel>
Acked-by: Mike Waychison <mikew [at] google>

---
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);
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


konrad.wilk at oracle

Mar 16, 2011, 5:00 PM

Post #2 of 4 (1742 views)
Permalink
Re: [PATCH] watchdog, SP5100: Check if firmware has set correct value in tcobase. [In reply to]

On Wed, Mar 16, 2011 at 02:18:17PM -0700, Yinghai Lu wrote:
>
>
> 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.
>
> Reported-by: Stefano Stabellini <stefano.stabellini [at] eu>
> Signed-off-by:Yinghai Lu <yinghai [at] kernel>
> Acked-by: Mike Waychison <mikew [at] google>

Tested-by: Konrad Rzeszutek Wilk <konrad.wilk [at] oracle>

Stefano,

this fixes my bootup issues with your:
xen: set max_pfn_mapped to the last pfn mapped
patch. Will try the full patchset tomorrow.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


konrad.wilk at oracle

Mar 16, 2011, 7:23 PM

Post #3 of 4 (1733 views)
Permalink
Re: [PATCH] watchdog, SP5100: Check if firmware has set correct value in tcobase. [In reply to]

On Wed, Mar 16, 2011 at 02:18:17PM -0700, Yinghai Lu wrote:
>
>
> 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.
>
> Reported-by: Stefano Stabellini <stefano.stabellini [at] eu>
> Signed-off-by:Yinghai Lu <yinghai [at] kernel>
> Acked-by: Mike Waychison <mikew [at] google>

I have no idea why it worked the first time b/c this:


> + if (request_mem_region_exclusive(val, SP5100_WDT_MEM_MAP_SIZE, "SP5100 TCO")) {

is wrong. It should have been "if (!request...")..

With that, and with Stefano's patches (stefano/2.6.38-rc6-mm-fix) on top of 2.6.39-rc0 it boots up fine.

Excerpt from the log:

[ 0.000000] DEBUG find_early_table_space: _text=1000000 _end=1e33000 pgtable_start=9fc000 pgtable_end=9fc000
[ 0.000000] DEBUG find_early_table_space: _text=1000000 _end=1e33000 pgtable_start=beba5000 pgtable_end=beba5000
[ 9.064064] calling sp5100_tco_init_module+0x0/0x1000 [sp5100_tco] @ 507
[ 9.064067] SP5100 TCO timer: SP5100 TCO WatchDog Timer Driver v0.01
[ 9.064180] SP5100 TCO timer: mmio address 0xb8fe00 already in use
[ 9.064201] initcall sp5100_tco_init_module+0x0/0x1000 [sp5100_tco] returned 0 after 126 usecs

Attached is the full log if folks are curious.
Attachments: d (255 KB)


stefano.stabellini at eu

Mar 17, 2011, 5:35 AM

Post #4 of 4 (1741 views)
Permalink
Re: [PATCH] watchdog, SP5100: Check if firmware has set correct value in tcobase. [In reply to]

On Thu, 17 Mar 2011, Konrad Rzeszutek Wilk wrote:
> On Wed, Mar 16, 2011 at 02:18:17PM -0700, Yinghai Lu wrote:
> >
> >
> > 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.
> >
> > Reported-by: Stefano Stabellini <stefano.stabellini [at] eu>
> > Signed-off-by:Yinghai Lu <yinghai [at] kernel>
> > Acked-by: Mike Waychison <mikew [at] google>
>
> I have no idea why it worked the first time b/c this:
>
>
> > + if (request_mem_region_exclusive(val, SP5100_WDT_MEM_MAP_SIZE, "SP5100 TCO")) {
>
> is wrong. It should have been "if (!request...")..
>
> With that, and with Stefano's patches (stefano/2.6.38-rc6-mm-fix) on top of 2.6.39-rc0 it boots up fine.

Yinghai, thanks for the patch!
I hope that we are not going to find any more of this kind of issues
with other drivers and other BIOSes.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.