2007-12-05 00:41:54 +07:00
|
|
|
/*
|
|
|
|
* HP WatchDog Driver
|
|
|
|
* based on
|
|
|
|
*
|
|
|
|
* SoftDog 0.05: A Software Watchdog Device
|
|
|
|
*
|
|
|
|
* (c) Copyright 2007 Hewlett-Packard Development Company, L.P.
|
|
|
|
* Thomas Mingarelli <thomas.mingarelli@hp.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* version 2 as published by the Free Software Foundation
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-02-16 06:06:19 +07:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2007-12-05 00:41:54 +07:00
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/io.h>
|
2010-07-28 06:50:50 +07:00
|
|
|
#include <linux/bitops.h>
|
2007-12-05 00:41:54 +07:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/miscdevice.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/moduleparam.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/pci_ids.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/uaccess.h>
|
|
|
|
#include <linux/watchdog.h>
|
2010-07-28 06:51:02 +07:00
|
|
|
#ifdef CONFIG_HPWDT_NMI_DECODING
|
2007-12-05 00:41:54 +07:00
|
|
|
#include <linux/dmi.h>
|
2010-07-28 06:50:50 +07:00
|
|
|
#include <linux/spinlock.h>
|
2010-07-28 06:50:54 +07:00
|
|
|
#include <linux/nmi.h>
|
|
|
|
#include <linux/kdebug.h>
|
|
|
|
#include <linux/notifier.h>
|
2008-11-14 21:47:03 +07:00
|
|
|
#include <asm/cacheflush.h>
|
2010-07-28 06:51:02 +07:00
|
|
|
#endif /* CONFIG_HPWDT_NMI_DECODING */
|
2011-10-06 19:20:27 +07:00
|
|
|
#include <asm/nmi.h>
|
2007-12-05 00:41:54 +07:00
|
|
|
|
2014-01-29 03:26:10 +07:00
|
|
|
#define HPWDT_VERSION "1.3.3"
|
2010-06-03 05:23:39 +07:00
|
|
|
#define SECS_TO_TICKS(secs) ((secs) * 1000 / 128)
|
2010-06-03 05:23:40 +07:00
|
|
|
#define TICKS_TO_SECS(ticks) ((ticks) * 128 / 1000)
|
|
|
|
#define HPWDT_MAX_TIMER TICKS_TO_SECS(65535)
|
2010-07-28 06:50:54 +07:00
|
|
|
#define DEFAULT_MARGIN 30
|
|
|
|
|
|
|
|
static unsigned int soft_margin = DEFAULT_MARGIN; /* in seconds */
|
|
|
|
static unsigned int reload; /* the computed soft_margin */
|
2012-03-05 22:51:11 +07:00
|
|
|
static bool nowayout = WATCHDOG_NOWAYOUT;
|
2010-07-28 06:50:54 +07:00
|
|
|
static char expect_release;
|
|
|
|
static unsigned long hpwdt_is_open;
|
|
|
|
|
|
|
|
static void __iomem *pci_mem_addr; /* the PCI-memory address */
|
|
|
|
static unsigned long __iomem *hpwdt_timer_reg;
|
|
|
|
static unsigned long __iomem *hpwdt_timer_con;
|
|
|
|
|
2013-12-03 06:30:22 +07:00
|
|
|
static const struct pci_device_id hpwdt_devices[] = {
|
2010-07-28 06:50:57 +07:00
|
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_COMPAQ, 0xB203) }, /* iLO2 */
|
|
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_HP, 0x3306) }, /* iLO3 */
|
2010-07-28 06:50:54 +07:00
|
|
|
{0}, /* terminate list */
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pci, hpwdt_devices);
|
|
|
|
|
2010-07-28 06:51:02 +07:00
|
|
|
#ifdef CONFIG_HPWDT_NMI_DECODING
|
2007-12-05 00:41:54 +07:00
|
|
|
#define PCI_BIOS32_SD_VALUE 0x5F32335F /* "_32_" */
|
|
|
|
#define CRU_BIOS_SIGNATURE_VALUE 0x55524324
|
|
|
|
#define PCI_BIOS32_PARAGRAPH_LEN 16
|
|
|
|
#define PCI_ROM_BASE1 0x000F0000
|
|
|
|
#define ROM_SIZE 0x10000
|
|
|
|
|
|
|
|
struct bios32_service_dir {
|
|
|
|
u32 signature;
|
|
|
|
u32 entry_point;
|
|
|
|
u8 revision;
|
|
|
|
u8 length;
|
|
|
|
u8 checksum;
|
|
|
|
u8 reserved[5];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* type 212 */
|
|
|
|
struct smbios_cru64_info {
|
|
|
|
u8 type;
|
|
|
|
u8 byte_length;
|
|
|
|
u16 handle;
|
|
|
|
u32 signature;
|
|
|
|
u64 physical_address;
|
|
|
|
u32 double_length;
|
|
|
|
u32 double_offset;
|
|
|
|
};
|
|
|
|
#define SMBIOS_CRU64_INFORMATION 212
|
|
|
|
|
2011-07-26 20:05:53 +07:00
|
|
|
/* type 219 */
|
|
|
|
struct smbios_proliant_info {
|
|
|
|
u8 type;
|
|
|
|
u8 byte_length;
|
|
|
|
u16 handle;
|
|
|
|
u32 power_features;
|
|
|
|
u32 omega_features;
|
|
|
|
u32 reserved;
|
|
|
|
u32 misc_features;
|
|
|
|
};
|
|
|
|
#define SMBIOS_ICRU_INFORMATION 219
|
|
|
|
|
|
|
|
|
2007-12-05 00:41:54 +07:00
|
|
|
struct cmn_registers {
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u8 ral;
|
|
|
|
u8 rah;
|
|
|
|
u16 rea2;
|
|
|
|
};
|
|
|
|
u32 reax;
|
|
|
|
} u1;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u8 rbl;
|
|
|
|
u8 rbh;
|
|
|
|
u8 reb2l;
|
|
|
|
u8 reb2h;
|
|
|
|
};
|
|
|
|
u32 rebx;
|
|
|
|
} u2;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u8 rcl;
|
|
|
|
u8 rch;
|
|
|
|
u16 rec2;
|
|
|
|
};
|
|
|
|
u32 recx;
|
|
|
|
} u3;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u8 rdl;
|
|
|
|
u8 rdh;
|
|
|
|
u16 red2;
|
|
|
|
};
|
|
|
|
u32 redx;
|
|
|
|
} u4;
|
|
|
|
|
|
|
|
u32 resi;
|
|
|
|
u32 redi;
|
|
|
|
u16 rds;
|
|
|
|
u16 res;
|
|
|
|
u32 reflags;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2010-07-28 06:51:01 +07:00
|
|
|
static unsigned int hpwdt_nmi_decoding;
|
2012-06-26 15:27:00 +07:00
|
|
|
static unsigned int allow_kdump = 1;
|
2011-07-26 20:05:53 +07:00
|
|
|
static unsigned int is_icru;
|
2013-07-10 06:04:55 +07:00
|
|
|
static unsigned int is_uefi;
|
2007-12-05 00:41:54 +07:00
|
|
|
static DEFINE_SPINLOCK(rom_lock);
|
|
|
|
static void *cru_rom_addr;
|
|
|
|
static struct cmn_registers cmn_regs;
|
|
|
|
|
2009-03-18 15:35:09 +07:00
|
|
|
extern asmlinkage void asminline_call(struct cmn_registers *pi86Regs,
|
|
|
|
unsigned long *pRomEntry);
|
2008-06-21 02:19:28 +07:00
|
|
|
|
2010-07-28 06:50:59 +07:00
|
|
|
#ifdef CONFIG_X86_32
|
2007-12-05 00:41:54 +07:00
|
|
|
/* --32 Bit Bios------------------------------------------------------------ */
|
|
|
|
|
|
|
|
#define HPWDT_ARCH 32
|
|
|
|
|
2008-06-21 02:19:28 +07:00
|
|
|
asm(".text \n\t"
|
2013-09-12 04:23:20 +07:00
|
|
|
".align 4 \n\t"
|
|
|
|
".globl asminline_call \n"
|
2008-06-21 02:19:28 +07:00
|
|
|
"asminline_call: \n\t"
|
|
|
|
"pushl %ebp \n\t"
|
|
|
|
"movl %esp, %ebp \n\t"
|
|
|
|
"pusha \n\t"
|
|
|
|
"pushf \n\t"
|
|
|
|
"push %es \n\t"
|
|
|
|
"push %ds \n\t"
|
|
|
|
"pop %es \n\t"
|
|
|
|
"movl 8(%ebp),%eax \n\t"
|
|
|
|
"movl 4(%eax),%ebx \n\t"
|
|
|
|
"movl 8(%eax),%ecx \n\t"
|
|
|
|
"movl 12(%eax),%edx \n\t"
|
|
|
|
"movl 16(%eax),%esi \n\t"
|
|
|
|
"movl 20(%eax),%edi \n\t"
|
|
|
|
"movl (%eax),%eax \n\t"
|
|
|
|
"push %cs \n\t"
|
|
|
|
"call *12(%ebp) \n\t"
|
|
|
|
"pushf \n\t"
|
|
|
|
"pushl %eax \n\t"
|
|
|
|
"movl 8(%ebp),%eax \n\t"
|
|
|
|
"movl %ebx,4(%eax) \n\t"
|
|
|
|
"movl %ecx,8(%eax) \n\t"
|
|
|
|
"movl %edx,12(%eax) \n\t"
|
|
|
|
"movl %esi,16(%eax) \n\t"
|
|
|
|
"movl %edi,20(%eax) \n\t"
|
|
|
|
"movw %ds,24(%eax) \n\t"
|
|
|
|
"movw %es,26(%eax) \n\t"
|
|
|
|
"popl %ebx \n\t"
|
|
|
|
"movl %ebx,(%eax) \n\t"
|
|
|
|
"popl %ebx \n\t"
|
|
|
|
"movl %ebx,28(%eax) \n\t"
|
|
|
|
"pop %es \n\t"
|
|
|
|
"popf \n\t"
|
|
|
|
"popa \n\t"
|
|
|
|
"leave \n\t"
|
|
|
|
"ret \n\t"
|
|
|
|
".previous");
|
|
|
|
|
2007-12-05 00:41:54 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* cru_detect
|
|
|
|
*
|
|
|
|
* Routine Description:
|
|
|
|
* This function uses the 32-bit BIOS Service Directory record to
|
|
|
|
* search for a $CRU record.
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* 0 : SUCCESS
|
|
|
|
* <0 : FAILURE
|
|
|
|
*/
|
2012-11-20 01:21:41 +07:00
|
|
|
static int cru_detect(unsigned long map_entry,
|
2007-12-05 00:41:54 +07:00
|
|
|
unsigned long map_offset)
|
|
|
|
{
|
|
|
|
void *bios32_map;
|
|
|
|
unsigned long *bios32_entrypoint;
|
|
|
|
unsigned long cru_physical_address;
|
|
|
|
unsigned long cru_length;
|
|
|
|
unsigned long physical_bios_base = 0;
|
|
|
|
unsigned long physical_bios_offset = 0;
|
|
|
|
int retval = -ENODEV;
|
|
|
|
|
|
|
|
bios32_map = ioremap(map_entry, (2 * PAGE_SIZE));
|
|
|
|
|
|
|
|
if (bios32_map == NULL)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
bios32_entrypoint = bios32_map + map_offset;
|
|
|
|
|
|
|
|
cmn_regs.u1.reax = CRU_BIOS_SIGNATURE_VALUE;
|
|
|
|
|
2012-01-16 11:02:50 +07:00
|
|
|
set_memory_x((unsigned long)bios32_map, 2);
|
2007-12-05 00:41:54 +07:00
|
|
|
asminline_call(&cmn_regs, bios32_entrypoint);
|
|
|
|
|
|
|
|
if (cmn_regs.u1.ral != 0) {
|
2012-02-16 06:06:19 +07:00
|
|
|
pr_warn("Call succeeded but with an error: 0x%x\n",
|
2008-07-16 02:40:41 +07:00
|
|
|
cmn_regs.u1.ral);
|
2007-12-05 00:41:54 +07:00
|
|
|
} else {
|
|
|
|
physical_bios_base = cmn_regs.u2.rebx;
|
|
|
|
physical_bios_offset = cmn_regs.u4.redx;
|
|
|
|
cru_length = cmn_regs.u3.recx;
|
|
|
|
cru_physical_address =
|
2008-07-16 02:40:41 +07:00
|
|
|
physical_bios_base + physical_bios_offset;
|
2007-12-05 00:41:54 +07:00
|
|
|
|
|
|
|
/* If the values look OK, then map it in. */
|
|
|
|
if ((physical_bios_base + physical_bios_offset)) {
|
|
|
|
cru_rom_addr =
|
2008-07-16 02:40:41 +07:00
|
|
|
ioremap(cru_physical_address, cru_length);
|
2011-11-07 16:59:00 +07:00
|
|
|
if (cru_rom_addr) {
|
2012-01-16 11:02:50 +07:00
|
|
|
set_memory_x((unsigned long)cru_rom_addr & PAGE_MASK,
|
|
|
|
(cru_length + PAGE_SIZE - 1) >> PAGE_SHIFT);
|
2007-12-05 00:41:54 +07:00
|
|
|
retval = 0;
|
2011-11-07 16:59:00 +07:00
|
|
|
}
|
2007-12-05 00:41:54 +07:00
|
|
|
}
|
|
|
|
|
2012-02-16 06:06:19 +07:00
|
|
|
pr_debug("CRU Base Address: 0x%lx\n", physical_bios_base);
|
|
|
|
pr_debug("CRU Offset Address: 0x%lx\n", physical_bios_offset);
|
|
|
|
pr_debug("CRU Length: 0x%lx\n", cru_length);
|
|
|
|
pr_debug("CRU Mapped Address: %p\n", &cru_rom_addr);
|
2007-12-05 00:41:54 +07:00
|
|
|
}
|
|
|
|
iounmap(bios32_map);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2008-02-29 03:34:42 +07:00
|
|
|
/*
|
|
|
|
* bios_checksum
|
|
|
|
*/
|
2012-11-20 01:21:41 +07:00
|
|
|
static int bios_checksum(const char __iomem *ptr, int len)
|
2008-02-29 03:34:42 +07:00
|
|
|
{
|
|
|
|
char sum = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* calculate checksum of size bytes. This should add up
|
|
|
|
* to zero if we have a valid header.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
sum += ptr[i];
|
|
|
|
|
|
|
|
return ((sum == 0) && (len > 0));
|
|
|
|
}
|
|
|
|
|
2007-12-05 00:41:54 +07:00
|
|
|
/*
|
|
|
|
* bios32_present
|
|
|
|
*
|
|
|
|
* Routine Description:
|
|
|
|
* This function finds the 32-bit BIOS Service Directory
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* 0 : SUCCESS
|
|
|
|
* <0 : FAILURE
|
|
|
|
*/
|
2012-11-20 01:21:41 +07:00
|
|
|
static int bios32_present(const char __iomem *p)
|
2007-12-05 00:41:54 +07:00
|
|
|
{
|
|
|
|
struct bios32_service_dir *bios_32_ptr;
|
|
|
|
int length;
|
|
|
|
unsigned long map_entry, map_offset;
|
|
|
|
|
|
|
|
bios_32_ptr = (struct bios32_service_dir *) p;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Search for signature by checking equal to the swizzled value
|
|
|
|
* instead of calling another routine to perform a strcmp.
|
|
|
|
*/
|
|
|
|
if (bios_32_ptr->signature == PCI_BIOS32_SD_VALUE) {
|
|
|
|
length = bios_32_ptr->length * PCI_BIOS32_PARAGRAPH_LEN;
|
|
|
|
if (bios_checksum(p, length)) {
|
|
|
|
/*
|
|
|
|
* According to the spec, we're looking for the
|
|
|
|
* first 4KB-aligned address below the entrypoint
|
|
|
|
* listed in the header. The Service Directory code
|
|
|
|
* is guaranteed to occupy no more than 2 4KB pages.
|
|
|
|
*/
|
|
|
|
map_entry = bios_32_ptr->entry_point & ~(PAGE_SIZE - 1);
|
|
|
|
map_offset = bios_32_ptr->entry_point - map_entry;
|
|
|
|
|
|
|
|
return cru_detect(map_entry, map_offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2012-11-20 01:21:41 +07:00
|
|
|
static int detect_cru_service(void)
|
2007-12-05 00:41:54 +07:00
|
|
|
{
|
|
|
|
char __iomem *p, *q;
|
|
|
|
int rc = -1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Search from 0x0f0000 through 0x0fffff, inclusive.
|
|
|
|
*/
|
|
|
|
p = ioremap(PCI_ROM_BASE1, ROM_SIZE);
|
|
|
|
if (p == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
for (q = p; q < p + ROM_SIZE; q += 16) {
|
|
|
|
rc = bios32_present(q);
|
|
|
|
if (!rc)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
iounmap(p);
|
|
|
|
return rc;
|
|
|
|
}
|
2010-07-28 06:50:59 +07:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
#endif /* CONFIG_X86_32 */
|
|
|
|
#ifdef CONFIG_X86_64
|
2007-12-05 00:41:54 +07:00
|
|
|
/* --64 Bit Bios------------------------------------------------------------ */
|
|
|
|
|
|
|
|
#define HPWDT_ARCH 64
|
|
|
|
|
2008-06-21 02:19:28 +07:00
|
|
|
asm(".text \n\t"
|
2013-09-12 04:23:20 +07:00
|
|
|
".align 4 \n\t"
|
|
|
|
".globl asminline_call \n"
|
2008-06-21 02:19:28 +07:00
|
|
|
"asminline_call: \n\t"
|
|
|
|
"pushq %rbp \n\t"
|
|
|
|
"movq %rsp, %rbp \n\t"
|
|
|
|
"pushq %rax \n\t"
|
|
|
|
"pushq %rbx \n\t"
|
|
|
|
"pushq %rdx \n\t"
|
|
|
|
"pushq %r12 \n\t"
|
|
|
|
"pushq %r9 \n\t"
|
|
|
|
"movq %rsi, %r12 \n\t"
|
|
|
|
"movq %rdi, %r9 \n\t"
|
|
|
|
"movl 4(%r9),%ebx \n\t"
|
|
|
|
"movl 8(%r9),%ecx \n\t"
|
|
|
|
"movl 12(%r9),%edx \n\t"
|
|
|
|
"movl 16(%r9),%esi \n\t"
|
|
|
|
"movl 20(%r9),%edi \n\t"
|
|
|
|
"movl (%r9),%eax \n\t"
|
|
|
|
"call *%r12 \n\t"
|
|
|
|
"pushfq \n\t"
|
|
|
|
"popq %r12 \n\t"
|
|
|
|
"movl %eax, (%r9) \n\t"
|
|
|
|
"movl %ebx, 4(%r9) \n\t"
|
|
|
|
"movl %ecx, 8(%r9) \n\t"
|
|
|
|
"movl %edx, 12(%r9) \n\t"
|
|
|
|
"movl %esi, 16(%r9) \n\t"
|
|
|
|
"movl %edi, 20(%r9) \n\t"
|
|
|
|
"movq %r12, %rax \n\t"
|
|
|
|
"movl %eax, 28(%r9) \n\t"
|
|
|
|
"popq %r9 \n\t"
|
|
|
|
"popq %r12 \n\t"
|
|
|
|
"popq %rdx \n\t"
|
|
|
|
"popq %rbx \n\t"
|
|
|
|
"popq %rax \n\t"
|
|
|
|
"leave \n\t"
|
|
|
|
"ret \n\t"
|
|
|
|
".previous");
|
2007-12-05 00:41:54 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* dmi_find_cru
|
|
|
|
*
|
|
|
|
* Routine Description:
|
2008-02-29 03:34:42 +07:00
|
|
|
* This function checks whether or not a SMBIOS/DMI record is
|
2007-12-05 00:41:54 +07:00
|
|
|
* the 64bit CRU info or not
|
|
|
|
*/
|
2012-11-20 01:21:41 +07:00
|
|
|
static void dmi_find_cru(const struct dmi_header *dm, void *dummy)
|
2007-12-05 00:41:54 +07:00
|
|
|
{
|
|
|
|
struct smbios_cru64_info *smbios_cru64_ptr;
|
|
|
|
unsigned long cru_physical_address;
|
|
|
|
|
|
|
|
if (dm->type == SMBIOS_CRU64_INFORMATION) {
|
|
|
|
smbios_cru64_ptr = (struct smbios_cru64_info *) dm;
|
|
|
|
if (smbios_cru64_ptr->signature == CRU_BIOS_SIGNATURE_VALUE) {
|
|
|
|
cru_physical_address =
|
2008-07-16 02:40:41 +07:00
|
|
|
smbios_cru64_ptr->physical_address +
|
|
|
|
smbios_cru64_ptr->double_offset;
|
2007-12-05 00:41:54 +07:00
|
|
|
cru_rom_addr = ioremap(cru_physical_address,
|
2008-07-16 02:40:41 +07:00
|
|
|
smbios_cru64_ptr->double_length);
|
2008-11-14 21:47:03 +07:00
|
|
|
set_memory_x((unsigned long)cru_rom_addr & PAGE_MASK,
|
|
|
|
smbios_cru64_ptr->double_length >> PAGE_SHIFT);
|
2007-12-05 00:41:54 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-20 01:21:41 +07:00
|
|
|
static int detect_cru_service(void)
|
2007-12-05 00:41:54 +07:00
|
|
|
{
|
|
|
|
cru_rom_addr = NULL;
|
|
|
|
|
2009-03-31 02:46:44 +07:00
|
|
|
dmi_walk(dmi_find_cru, NULL);
|
2007-12-05 00:41:54 +07:00
|
|
|
|
|
|
|
/* if cru_rom_addr has been set then we found a CRU service */
|
2008-07-16 02:40:41 +07:00
|
|
|
return ((cru_rom_addr != NULL) ? 0 : -ENODEV);
|
2007-12-05 00:41:54 +07:00
|
|
|
}
|
|
|
|
/* ------------------------------------------------------------------------- */
|
2010-07-28 06:50:59 +07:00
|
|
|
#endif /* CONFIG_X86_64 */
|
2010-07-28 06:51:02 +07:00
|
|
|
#endif /* CONFIG_HPWDT_NMI_DECODING */
|
2007-12-05 00:41:54 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Watchdog operations
|
|
|
|
*/
|
|
|
|
static void hpwdt_start(void)
|
|
|
|
{
|
2010-06-03 05:23:39 +07:00
|
|
|
reload = SECS_TO_TICKS(soft_margin);
|
2007-12-05 00:41:54 +07:00
|
|
|
iowrite16(reload, hpwdt_timer_reg);
|
2012-04-03 12:37:01 +07:00
|
|
|
iowrite8(0x85, hpwdt_timer_con);
|
2007-12-05 00:41:54 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void hpwdt_stop(void)
|
|
|
|
{
|
|
|
|
unsigned long data;
|
|
|
|
|
2012-04-03 12:37:01 +07:00
|
|
|
data = ioread8(hpwdt_timer_con);
|
2007-12-05 00:41:54 +07:00
|
|
|
data &= 0xFE;
|
2012-04-03 12:37:01 +07:00
|
|
|
iowrite8(data, hpwdt_timer_con);
|
2007-12-05 00:41:54 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void hpwdt_ping(void)
|
|
|
|
{
|
|
|
|
iowrite16(reload, hpwdt_timer_reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hpwdt_change_timer(int new_margin)
|
|
|
|
{
|
2010-06-03 05:23:40 +07:00
|
|
|
if (new_margin < 1 || new_margin > HPWDT_MAX_TIMER) {
|
2012-02-16 06:06:19 +07:00
|
|
|
pr_warn("New value passed in is invalid: %d seconds\n",
|
2007-12-05 00:41:54 +07:00
|
|
|
new_margin);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
soft_margin = new_margin;
|
2012-02-16 06:06:19 +07:00
|
|
|
pr_debug("New timer passed in is %d seconds\n", new_margin);
|
2010-06-03 05:23:39 +07:00
|
|
|
reload = SECS_TO_TICKS(soft_margin);
|
2007-12-05 00:41:54 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-03 05:23:41 +07:00
|
|
|
static int hpwdt_time_left(void)
|
|
|
|
{
|
|
|
|
return TICKS_TO_SECS(ioread16(hpwdt_timer_reg));
|
|
|
|
}
|
|
|
|
|
2010-07-28 06:51:02 +07:00
|
|
|
#ifdef CONFIG_HPWDT_NMI_DECODING
|
2008-07-16 02:40:41 +07:00
|
|
|
/*
|
|
|
|
* NMI Handler
|
|
|
|
*/
|
2011-10-01 02:06:21 +07:00
|
|
|
static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs)
|
2008-07-16 02:40:41 +07:00
|
|
|
{
|
|
|
|
unsigned long rom_pl;
|
|
|
|
static int die_nmi_called;
|
|
|
|
|
2010-07-28 06:51:01 +07:00
|
|
|
if (!hpwdt_nmi_decoding)
|
2010-07-28 06:50:49 +07:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&rom_lock, rom_pl);
|
2013-07-10 06:04:55 +07:00
|
|
|
if (!die_nmi_called && !is_icru && !is_uefi)
|
2010-07-28 06:50:49 +07:00
|
|
|
asminline_call(&cmn_regs, cru_rom_addr);
|
|
|
|
die_nmi_called = 1;
|
|
|
|
spin_unlock_irqrestore(&rom_lock, rom_pl);
|
2011-08-10 05:27:26 +07:00
|
|
|
|
|
|
|
if (allow_kdump)
|
|
|
|
hpwdt_stop();
|
|
|
|
|
2013-07-10 06:04:55 +07:00
|
|
|
if (!is_icru && !is_uefi) {
|
2011-07-26 20:05:53 +07:00
|
|
|
if (cmn_regs.u1.ral == 0) {
|
2011-08-10 05:27:26 +07:00
|
|
|
panic("An NMI occurred, "
|
2011-07-26 20:05:53 +07:00
|
|
|
"but unable to determine source.\n");
|
|
|
|
}
|
2008-07-16 02:40:41 +07:00
|
|
|
}
|
2014-01-29 03:26:10 +07:00
|
|
|
panic("An NMI occurred. Depending on your system the reason "
|
|
|
|
"for the NMI is logged in any one of the following "
|
|
|
|
"resources:\n"
|
|
|
|
"1. Integrated Management Log (IML)\n"
|
|
|
|
"2. OA Syslog\n"
|
|
|
|
"3. OA Forward Progress Log\n"
|
|
|
|
"4. iLO Event Log");
|
2011-07-26 20:05:53 +07:00
|
|
|
|
2010-07-28 06:50:49 +07:00
|
|
|
out:
|
2011-10-01 02:06:21 +07:00
|
|
|
return NMI_DONE;
|
2008-07-16 02:40:41 +07:00
|
|
|
}
|
2010-07-28 06:51:02 +07:00
|
|
|
#endif /* CONFIG_HPWDT_NMI_DECODING */
|
2008-07-16 02:40:41 +07:00
|
|
|
|
2007-12-05 00:41:54 +07:00
|
|
|
/*
|
|
|
|
* /dev/watchdog handling
|
|
|
|
*/
|
|
|
|
static int hpwdt_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
/* /dev/watchdog can only be opened once */
|
|
|
|
if (test_and_set_bit(0, &hpwdt_is_open))
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
/* Start the watchdog */
|
|
|
|
hpwdt_start();
|
|
|
|
hpwdt_ping();
|
|
|
|
|
|
|
|
return nonseekable_open(inode, file);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hpwdt_release(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
/* Stop the watchdog */
|
|
|
|
if (expect_release == 42) {
|
|
|
|
hpwdt_stop();
|
|
|
|
} else {
|
2012-02-16 06:06:19 +07:00
|
|
|
pr_crit("Unexpected close, not stopping watchdog!\n");
|
2007-12-05 00:41:54 +07:00
|
|
|
hpwdt_ping();
|
|
|
|
}
|
|
|
|
|
|
|
|
expect_release = 0;
|
|
|
|
|
|
|
|
/* /dev/watchdog is being closed, make sure it can be re-opened */
|
|
|
|
clear_bit(0, &hpwdt_is_open);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t hpwdt_write(struct file *file, const char __user *data,
|
|
|
|
size_t len, loff_t *ppos)
|
|
|
|
{
|
|
|
|
/* See if we got the magic character 'V' and reload the timer */
|
|
|
|
if (len) {
|
|
|
|
if (!nowayout) {
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
/* note: just in case someone wrote the magic character
|
|
|
|
* five months ago... */
|
|
|
|
expect_release = 0;
|
|
|
|
|
|
|
|
/* scan to see whether or not we got the magic char. */
|
|
|
|
for (i = 0; i != len; i++) {
|
|
|
|
char c;
|
2008-08-07 03:19:41 +07:00
|
|
|
if (get_user(c, data + i))
|
2007-12-05 00:41:54 +07:00
|
|
|
return -EFAULT;
|
|
|
|
if (c == 'V')
|
|
|
|
expect_release = 42;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* someone wrote to us, we should reload the timer */
|
|
|
|
hpwdt_ping();
|
|
|
|
}
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2009-12-27 01:55:22 +07:00
|
|
|
static const struct watchdog_info ident = {
|
2007-12-05 00:41:54 +07:00
|
|
|
.options = WDIOF_SETTIMEOUT |
|
|
|
|
WDIOF_KEEPALIVEPING |
|
|
|
|
WDIOF_MAGICCLOSE,
|
2010-07-28 06:50:57 +07:00
|
|
|
.identity = "HP iLO2+ HW Watchdog Timer",
|
2007-12-05 00:41:54 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static long hpwdt_ioctl(struct file *file, unsigned int cmd,
|
|
|
|
unsigned long arg)
|
|
|
|
{
|
|
|
|
void __user *argp = (void __user *)arg;
|
|
|
|
int __user *p = argp;
|
|
|
|
int new_margin;
|
|
|
|
int ret = -ENOTTY;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case WDIOC_GETSUPPORT:
|
|
|
|
ret = 0;
|
|
|
|
if (copy_to_user(argp, &ident, sizeof(ident)))
|
|
|
|
ret = -EFAULT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WDIOC_GETSTATUS:
|
|
|
|
case WDIOC_GETBOOTSTATUS:
|
|
|
|
ret = put_user(0, p);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WDIOC_KEEPALIVE:
|
|
|
|
hpwdt_ping();
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WDIOC_SETTIMEOUT:
|
|
|
|
ret = get_user(new_margin, p);
|
|
|
|
if (ret)
|
|
|
|
break;
|
|
|
|
|
|
|
|
ret = hpwdt_change_timer(new_margin);
|
|
|
|
if (ret)
|
|
|
|
break;
|
|
|
|
|
|
|
|
hpwdt_ping();
|
|
|
|
/* Fall */
|
|
|
|
case WDIOC_GETTIMEOUT:
|
|
|
|
ret = put_user(soft_margin, p);
|
|
|
|
break;
|
2010-06-03 05:23:41 +07:00
|
|
|
|
|
|
|
case WDIOC_GETTIMELEFT:
|
|
|
|
ret = put_user(hpwdt_time_left(), p);
|
|
|
|
break;
|
2007-12-05 00:41:54 +07:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Kernel interfaces
|
|
|
|
*/
|
2009-03-18 15:18:43 +07:00
|
|
|
static const struct file_operations hpwdt_fops = {
|
2007-12-05 00:41:54 +07:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.llseek = no_llseek,
|
|
|
|
.write = hpwdt_write,
|
|
|
|
.unlocked_ioctl = hpwdt_ioctl,
|
|
|
|
.open = hpwdt_open,
|
|
|
|
.release = hpwdt_release,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct miscdevice hpwdt_miscdev = {
|
|
|
|
.minor = WATCHDOG_MINOR,
|
|
|
|
.name = "watchdog",
|
|
|
|
.fops = &hpwdt_fops,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Init & Exit
|
|
|
|
*/
|
|
|
|
|
2010-07-28 06:51:02 +07:00
|
|
|
#ifdef CONFIG_HPWDT_NMI_DECODING
|
x86, nmi_watchdog: Remove ARCH_HAS_NMI_WATCHDOG and rely on CONFIG_HARDLOCKUP_DETECTOR
The x86 arch has shifted its use of the nmi_watchdog from a
local implementation to the global one provide by
kernel/watchdog.c. This shift has caused a whole bunch of
compile problems under different config options. I attempt to
simplify things with the patch below.
In order to simplify things, I had to come to terms with the
meaning of two terms ARCH_HAS_NMI_WATCHDOG and
CONFIG_HARDLOCKUP_DETECTOR. Basically they mean the same thing,
the former on a local level and the latter on a global level.
With the old x86 nmi watchdog gone, there is no need to rely on
defining the ARCH_HAS_NMI_WATCHDOG variable because it doesn't
make sense any more. x86 will now use the global
implementation.
The changes below do a few things. First it changes the few
places that relied on ARCH_HAS_NMI_WATCHDOG to use
CONFIG_X86_LOCAL_APIC (the former was an alias for the latter
anyway, so nothing unusual here). Those pieces of code were
relying more on local apic functionality the nmi watchdog
functionality, so the change should make sense.
Second, I removed the x86 implementation of
touch_nmi_watchdog(). It isn't need now, instead x86 will rely
on kernel/watchdog.c's implementation.
Third, I removed the #define ARCH_HAS_NMI_WATCHDOG itself from
x86. And tweaked the include/linux/nmi.h file to tell users to
look for an externally defined touch_nmi_watchdog in the case of
ARCH_HAS_NMI_WATCHDOG _or_ CONFIG_HARDLOCKUP_DETECTOR. This
changes removes some of the ugliness in that file.
Finally, I added a Kconfig dependency for
CONFIG_HARDLOCKUP_DETECTOR that said you can't have
ARCH_HAS_NMI_WATCHDOG _and_ CONFIG_HARDLOCKUP_DETECTOR. You can
only have one nmi_watchdog.
Tested with
ARCH=i386: allnoconfig, defconfig, allyesconfig, (various broken
configs) ARCH=x86_64: allnoconfig, defconfig, allyesconfig,
(various broken configs)
Hopefully, after this patch I won't get any more compile broken
emails. :-)
v3:
changed a couple of 'linux/nmi.h' -> 'asm/nmi.h' to pick-up correct function
prototypes when CONFIG_HARDLOCKUP_DETECTOR is not set.
Signed-off-by: Don Zickus <dzickus@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: fweisbec@gmail.com
LKML-Reference: <1293044403-14117-1-git-send-email-dzickus@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-12-23 02:00:03 +07:00
|
|
|
#ifdef CONFIG_X86_LOCAL_APIC
|
2012-11-20 01:21:41 +07:00
|
|
|
static void hpwdt_check_nmi_decoding(struct pci_dev *dev)
|
2009-06-05 02:50:45 +07:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* If nmi_watchdog is turned off then we can turn on
|
2010-07-28 06:51:01 +07:00
|
|
|
* our nmi decoding capability.
|
2009-06-05 02:50:45 +07:00
|
|
|
*/
|
2010-11-12 23:22:24 +07:00
|
|
|
hpwdt_nmi_decoding = 1;
|
2009-06-05 02:50:45 +07:00
|
|
|
}
|
|
|
|
#else
|
2012-11-20 01:21:41 +07:00
|
|
|
static void hpwdt_check_nmi_decoding(struct pci_dev *dev)
|
2009-06-05 02:50:45 +07:00
|
|
|
{
|
2010-07-28 06:51:01 +07:00
|
|
|
dev_warn(&dev->dev, "NMI decoding is disabled. "
|
2009-06-05 02:50:45 +07:00
|
|
|
"Your kernel does not support a NMI Watchdog.\n");
|
|
|
|
}
|
x86, nmi_watchdog: Remove ARCH_HAS_NMI_WATCHDOG and rely on CONFIG_HARDLOCKUP_DETECTOR
The x86 arch has shifted its use of the nmi_watchdog from a
local implementation to the global one provide by
kernel/watchdog.c. This shift has caused a whole bunch of
compile problems under different config options. I attempt to
simplify things with the patch below.
In order to simplify things, I had to come to terms with the
meaning of two terms ARCH_HAS_NMI_WATCHDOG and
CONFIG_HARDLOCKUP_DETECTOR. Basically they mean the same thing,
the former on a local level and the latter on a global level.
With the old x86 nmi watchdog gone, there is no need to rely on
defining the ARCH_HAS_NMI_WATCHDOG variable because it doesn't
make sense any more. x86 will now use the global
implementation.
The changes below do a few things. First it changes the few
places that relied on ARCH_HAS_NMI_WATCHDOG to use
CONFIG_X86_LOCAL_APIC (the former was an alias for the latter
anyway, so nothing unusual here). Those pieces of code were
relying more on local apic functionality the nmi watchdog
functionality, so the change should make sense.
Second, I removed the x86 implementation of
touch_nmi_watchdog(). It isn't need now, instead x86 will rely
on kernel/watchdog.c's implementation.
Third, I removed the #define ARCH_HAS_NMI_WATCHDOG itself from
x86. And tweaked the include/linux/nmi.h file to tell users to
look for an externally defined touch_nmi_watchdog in the case of
ARCH_HAS_NMI_WATCHDOG _or_ CONFIG_HARDLOCKUP_DETECTOR. This
changes removes some of the ugliness in that file.
Finally, I added a Kconfig dependency for
CONFIG_HARDLOCKUP_DETECTOR that said you can't have
ARCH_HAS_NMI_WATCHDOG _and_ CONFIG_HARDLOCKUP_DETECTOR. You can
only have one nmi_watchdog.
Tested with
ARCH=i386: allnoconfig, defconfig, allyesconfig, (various broken
configs) ARCH=x86_64: allnoconfig, defconfig, allyesconfig,
(various broken configs)
Hopefully, after this patch I won't get any more compile broken
emails. :-)
v3:
changed a couple of 'linux/nmi.h' -> 'asm/nmi.h' to pick-up correct function
prototypes when CONFIG_HARDLOCKUP_DETECTOR is not set.
Signed-off-by: Don Zickus <dzickus@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: fweisbec@gmail.com
LKML-Reference: <1293044403-14117-1-git-send-email-dzickus@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-12-23 02:00:03 +07:00
|
|
|
#endif /* CONFIG_X86_LOCAL_APIC */
|
2010-07-29 01:38:43 +07:00
|
|
|
|
2011-07-26 20:05:53 +07:00
|
|
|
/*
|
|
|
|
* dmi_find_icru
|
|
|
|
*
|
|
|
|
* Routine Description:
|
|
|
|
* This function checks whether or not we are on an iCRU-based server.
|
|
|
|
* This check is independent of architecture and needs to be made for
|
|
|
|
* any ProLiant system.
|
|
|
|
*/
|
2012-11-20 01:21:41 +07:00
|
|
|
static void dmi_find_icru(const struct dmi_header *dm, void *dummy)
|
2011-07-26 20:05:53 +07:00
|
|
|
{
|
|
|
|
struct smbios_proliant_info *smbios_proliant_ptr;
|
|
|
|
|
|
|
|
if (dm->type == SMBIOS_ICRU_INFORMATION) {
|
|
|
|
smbios_proliant_ptr = (struct smbios_proliant_info *) dm;
|
|
|
|
if (smbios_proliant_ptr->misc_features & 0x01)
|
|
|
|
is_icru = 1;
|
2013-07-10 06:04:55 +07:00
|
|
|
if (smbios_proliant_ptr->misc_features & 0x408)
|
|
|
|
is_uefi = 1;
|
2011-07-26 20:05:53 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-20 01:21:41 +07:00
|
|
|
static int hpwdt_init_nmi_decoding(struct pci_dev *dev)
|
2010-07-29 01:38:43 +07:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
/*
|
2011-07-26 20:05:53 +07:00
|
|
|
* On typical CRU-based systems we need to map that service in
|
|
|
|
* the BIOS. For 32 bit Operating Systems we need to go through
|
|
|
|
* the 32 Bit BIOS Service Directory. For 64 bit Operating
|
|
|
|
* Systems we get that service through SMBIOS.
|
|
|
|
*
|
|
|
|
* On systems that support the new iCRU service all we need to
|
|
|
|
* do is call dmi_walk to get the supported flag value and skip
|
|
|
|
* the old cru detect code.
|
2010-07-29 01:38:43 +07:00
|
|
|
*/
|
2011-07-26 20:05:53 +07:00
|
|
|
dmi_walk(dmi_find_icru, NULL);
|
2013-07-10 06:04:55 +07:00
|
|
|
if (!is_icru && !is_uefi) {
|
2011-07-26 20:05:53 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We need to map the ROM to get the CRU service.
|
|
|
|
* For 32 bit Operating Systems we need to go through the 32 Bit
|
|
|
|
* BIOS Service Directory
|
|
|
|
* For 64 bit Operating Systems we get that service through SMBIOS.
|
|
|
|
*/
|
|
|
|
retval = detect_cru_service();
|
|
|
|
if (retval < 0) {
|
|
|
|
dev_warn(&dev->dev,
|
|
|
|
"Unable to detect the %d Bit CRU Service.\n",
|
|
|
|
HPWDT_ARCH);
|
|
|
|
return retval;
|
|
|
|
}
|
2010-07-29 01:38:43 +07:00
|
|
|
|
2011-07-26 20:05:53 +07:00
|
|
|
/*
|
|
|
|
* We know this is the only CRU call we need to make so lets keep as
|
|
|
|
* few instructions as possible once the NMI comes in.
|
|
|
|
*/
|
|
|
|
cmn_regs.u1.rah = 0x0D;
|
|
|
|
cmn_regs.u1.ral = 0x02;
|
|
|
|
}
|
2010-07-29 01:38:43 +07:00
|
|
|
|
|
|
|
/*
|
2012-03-30 03:11:15 +07:00
|
|
|
* Only one function can register for NMI_UNKNOWN
|
2010-07-29 01:38:43 +07:00
|
|
|
*/
|
2012-03-30 03:11:15 +07:00
|
|
|
retval = register_nmi_handler(NMI_UNKNOWN, hpwdt_pretimeout, 0, "hpwdt");
|
2012-03-30 03:11:16 +07:00
|
|
|
if (retval)
|
|
|
|
goto error;
|
|
|
|
retval = register_nmi_handler(NMI_SERR, hpwdt_pretimeout, 0, "hpwdt");
|
|
|
|
if (retval)
|
|
|
|
goto error1;
|
|
|
|
retval = register_nmi_handler(NMI_IO_CHECK, hpwdt_pretimeout, 0, "hpwdt");
|
|
|
|
if (retval)
|
|
|
|
goto error2;
|
2010-07-29 01:38:43 +07:00
|
|
|
|
|
|
|
dev_info(&dev->dev,
|
|
|
|
"HP Watchdog Timer Driver: NMI decoding initialized"
|
2012-03-30 03:11:15 +07:00
|
|
|
", allow kernel dump: %s (default = 0/OFF)\n",
|
|
|
|
(allow_kdump == 0) ? "OFF" : "ON");
|
2010-07-29 01:38:43 +07:00
|
|
|
return 0;
|
2012-03-30 03:11:16 +07:00
|
|
|
|
|
|
|
error2:
|
|
|
|
unregister_nmi_handler(NMI_SERR, "hpwdt");
|
|
|
|
error1:
|
|
|
|
unregister_nmi_handler(NMI_UNKNOWN, "hpwdt");
|
|
|
|
error:
|
|
|
|
dev_warn(&dev->dev,
|
|
|
|
"Unable to register a die notifier (err=%d).\n",
|
|
|
|
retval);
|
|
|
|
if (cru_rom_addr)
|
|
|
|
iounmap(cru_rom_addr);
|
|
|
|
return retval;
|
2010-07-29 01:38:43 +07:00
|
|
|
}
|
|
|
|
|
2011-03-02 10:49:44 +07:00
|
|
|
static void hpwdt_exit_nmi_decoding(void)
|
2010-07-29 01:38:43 +07:00
|
|
|
{
|
2011-10-01 02:06:21 +07:00
|
|
|
unregister_nmi_handler(NMI_UNKNOWN, "hpwdt");
|
2012-06-26 15:27:00 +07:00
|
|
|
unregister_nmi_handler(NMI_SERR, "hpwdt");
|
|
|
|
unregister_nmi_handler(NMI_IO_CHECK, "hpwdt");
|
2010-07-29 01:38:43 +07:00
|
|
|
if (cru_rom_addr)
|
|
|
|
iounmap(cru_rom_addr);
|
|
|
|
}
|
2010-07-28 06:51:02 +07:00
|
|
|
#else /* !CONFIG_HPWDT_NMI_DECODING */
|
2012-11-20 01:21:41 +07:00
|
|
|
static void hpwdt_check_nmi_decoding(struct pci_dev *dev)
|
2010-07-28 06:51:02 +07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-11-20 01:21:41 +07:00
|
|
|
static int hpwdt_init_nmi_decoding(struct pci_dev *dev)
|
2010-07-28 06:51:02 +07:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-03-02 10:49:44 +07:00
|
|
|
static void hpwdt_exit_nmi_decoding(void)
|
2010-07-28 06:51:02 +07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_HPWDT_NMI_DECODING */
|
2009-06-05 02:50:45 +07:00
|
|
|
|
2012-11-20 01:21:41 +07:00
|
|
|
static int hpwdt_init_one(struct pci_dev *dev,
|
2008-07-16 02:40:41 +07:00
|
|
|
const struct pci_device_id *ent)
|
2007-12-05 00:41:54 +07:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
|
2009-06-05 02:50:45 +07:00
|
|
|
/*
|
2010-07-28 06:51:01 +07:00
|
|
|
* Check if we can do NMI decoding or not
|
2009-06-05 02:50:45 +07:00
|
|
|
*/
|
2010-07-28 06:51:01 +07:00
|
|
|
hpwdt_check_nmi_decoding(dev);
|
2009-06-05 02:50:45 +07:00
|
|
|
|
2007-12-05 00:41:54 +07:00
|
|
|
/*
|
2010-07-28 06:50:57 +07:00
|
|
|
* First let's find out if we are on an iLO2+ server. We will
|
2007-12-05 00:41:54 +07:00
|
|
|
* not run on a legacy ASM box.
|
2008-07-16 02:40:41 +07:00
|
|
|
* So we only support the G5 ProLiant servers and higher.
|
2007-12-05 00:41:54 +07:00
|
|
|
*/
|
|
|
|
if (dev->subsystem_vendor != PCI_VENDOR_ID_HP) {
|
|
|
|
dev_warn(&dev->dev,
|
2010-07-28 06:50:57 +07:00
|
|
|
"This server does not have an iLO2+ ASIC.\n");
|
2007-12-05 00:41:54 +07:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2013-08-09 23:31:09 +07:00
|
|
|
/*
|
|
|
|
* Ignore all auxilary iLO devices with the following PCI ID
|
|
|
|
*/
|
|
|
|
if (dev->subsystem_device == 0x1979)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2007-12-05 00:41:54 +07:00
|
|
|
if (pci_enable_device(dev)) {
|
|
|
|
dev_warn(&dev->dev,
|
|
|
|
"Not possible to enable PCI Device: 0x%x:0x%x.\n",
|
|
|
|
ent->vendor, ent->device);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
pci_mem_addr = pci_iomap(dev, 1, 0x80);
|
|
|
|
if (!pci_mem_addr) {
|
|
|
|
dev_warn(&dev->dev,
|
2010-07-28 06:50:57 +07:00
|
|
|
"Unable to detect the iLO2+ server memory.\n");
|
2007-12-05 00:41:54 +07:00
|
|
|
retval = -ENOMEM;
|
|
|
|
goto error_pci_iomap;
|
|
|
|
}
|
|
|
|
hpwdt_timer_reg = pci_mem_addr + 0x70;
|
|
|
|
hpwdt_timer_con = pci_mem_addr + 0x72;
|
|
|
|
|
2012-08-28 01:52:24 +07:00
|
|
|
/* Make sure that timer is disabled until /dev/watchdog is opened */
|
|
|
|
hpwdt_stop();
|
|
|
|
|
2007-12-05 00:41:54 +07:00
|
|
|
/* Make sure that we have a valid soft_margin */
|
|
|
|
if (hpwdt_change_timer(soft_margin))
|
|
|
|
hpwdt_change_timer(DEFAULT_MARGIN);
|
|
|
|
|
2010-07-29 01:38:43 +07:00
|
|
|
/* Initialize NMI Decoding functionality */
|
|
|
|
retval = hpwdt_init_nmi_decoding(dev);
|
|
|
|
if (retval != 0)
|
|
|
|
goto error_init_nmi_decoding;
|
2007-12-05 00:41:54 +07:00
|
|
|
|
|
|
|
retval = misc_register(&hpwdt_miscdev);
|
|
|
|
if (retval < 0) {
|
|
|
|
dev_warn(&dev->dev,
|
|
|
|
"Unable to register miscdev on minor=%d (err=%d).\n",
|
|
|
|
WATCHDOG_MINOR, retval);
|
|
|
|
goto error_misc_register;
|
|
|
|
}
|
|
|
|
|
2010-07-29 01:38:43 +07:00
|
|
|
dev_info(&dev->dev, "HP Watchdog Timer Driver: %s"
|
|
|
|
", timer margin: %d seconds (nowayout=%d).\n",
|
|
|
|
HPWDT_VERSION, soft_margin, nowayout);
|
2007-12-05 00:41:54 +07:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
error_misc_register:
|
2010-07-29 01:38:43 +07:00
|
|
|
hpwdt_exit_nmi_decoding();
|
|
|
|
error_init_nmi_decoding:
|
2007-12-05 00:41:54 +07:00
|
|
|
pci_iounmap(dev, pci_mem_addr);
|
|
|
|
error_pci_iomap:
|
|
|
|
pci_disable_device(dev);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2012-11-20 01:26:24 +07:00
|
|
|
static void hpwdt_exit(struct pci_dev *dev)
|
2007-12-05 00:41:54 +07:00
|
|
|
{
|
|
|
|
if (!nowayout)
|
|
|
|
hpwdt_stop();
|
|
|
|
|
|
|
|
misc_deregister(&hpwdt_miscdev);
|
2010-07-29 01:38:43 +07:00
|
|
|
hpwdt_exit_nmi_decoding();
|
2007-12-05 00:41:54 +07:00
|
|
|
pci_iounmap(dev, pci_mem_addr);
|
|
|
|
pci_disable_device(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct pci_driver hpwdt_driver = {
|
|
|
|
.name = "hpwdt",
|
|
|
|
.id_table = hpwdt_devices,
|
|
|
|
.probe = hpwdt_init_one,
|
2012-11-20 01:21:12 +07:00
|
|
|
.remove = hpwdt_exit,
|
2007-12-05 00:41:54 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Tom Mingarelli");
|
|
|
|
MODULE_DESCRIPTION("hp watchdog driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
2009-03-03 07:17:16 +07:00
|
|
|
MODULE_VERSION(HPWDT_VERSION);
|
2007-12-05 00:41:54 +07:00
|
|
|
|
|
|
|
module_param(soft_margin, int, 0);
|
|
|
|
MODULE_PARM_DESC(soft_margin, "Watchdog timeout in seconds");
|
|
|
|
|
2012-03-05 22:51:11 +07:00
|
|
|
module_param(nowayout, bool, 0);
|
2007-12-05 00:41:54 +07:00
|
|
|
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
|
|
|
|
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
|
|
|
|
|
2010-07-28 06:51:02 +07:00
|
|
|
#ifdef CONFIG_HPWDT_NMI_DECODING
|
2010-07-28 06:50:54 +07:00
|
|
|
module_param(allow_kdump, int, 0);
|
|
|
|
MODULE_PARM_DESC(allow_kdump, "Start a kernel dump after NMI occurs");
|
2010-07-28 06:51:02 +07:00
|
|
|
#endif /* !CONFIG_HPWDT_NMI_DECODING */
|
2009-06-19 06:28:57 +07:00
|
|
|
|
2012-05-04 19:43:25 +07:00
|
|
|
module_pci_driver(hpwdt_driver);
|