x86-64 support
Subsystems (8)
cover x86-64 support
Hi all,
Here is the latest diskdump patch for kernel 2.6.8.1.
- Supports x86_64
- Fix bug of Fusion-MPT scsi driver patch
- Add new functions for finding ram area
Source code can be downloaded from
http://sourceforge.net/projects/lkdump
When I tested diskdump on x86-64 machine, I found that memory dump of the following two areas failed.
1) 04000000 - 07ffffff
2) around last two page
Memory dump of the area 2) failed because page->flag was broken. So I compare PFN to page_to_pfn(pfn_to_page(PFN)) and skip this PFN if these value is different.
page = pfn_to_page(nr);
if (nr != page_to_pfn(page)) {
/* page_to_pfn() is called from kmap_atomic().
* If page->flag is broken, it specified a wrong
* zone and it causes kmap_atomic() fail.
*/
Err("Bad page. PFN %lu flags %lx\n",
nr, (unsigned long)page->flags);
memset(scratch + blk_in_chunk * PAGE_SIZE, 0,
PAGE_SIZE);
sprintf(scratch + blk_in_chunk * PAGE_SIZE,
"Bad page. PFN %lu flags %lx\n",
nr, (unsigned long)page->flags);
goto write;
}Memory dump of the area 1) failed because this area was not mapped to vaddr. Diskdump checks page using page_is_ram() and maps it using kmap_atomic(). In the area 1), both page_is_ram() and kmap_atomic() return true, but page is not attached to the page table.
I think this area is AGP Aperture. I found this message in the dmesg.
PCI-DMA: Disabling AGP.
PCI-DMA: aperture base @ 4000000 size 65536 KB
PCI-DMA: Reserving 64MB of IOMMU area in the AGP aperture
To resolve this problem, I check page using kern_addr_valid() before kmap_atomic().
if (!kern_addr_valid((unsigned long)pfn_to_kaddr(nr))) {
memset(scratch + blk_in_chunk * PAGE_SIZE, 0,
PAGE_SIZE);
sprintf(scratch + blk_in_chunk * PAGE_SIZE,
"Unmapped page. PFN %lu\n", nr);
goto write;
}
kaddr = kmap_atomic(page, KM_CRASHDUMP);
memcpy(scratch + blk_in_chunk * PAGE_SIZE, kaddr, PAGE_SIZE);
kunmap_atomic(kaddr, KM_CRASHDUMP);
write:Now diskdump seems to work correctly. But I am not sure these method is right. Please let me know if there are better methods.
Best Regards,
Takao Indoh
PATCH 1/4 x86-64 support
This is a patch for diskdump common layer.
arch/i386/kernel/nmi.c +1 -0
@@ -524,3 +524,4 @@EXPORT_SYMBOL (release_lapic_nmi);EXPORT_SYMBOL (disable_timer_nmi_watchdog);EXPORT_SYMBOL (enable_timer_nmi_watchdog); +EXPORT_SYMBOL_GPL (touch_nmi_watchdog);
arch/i386/kernel/reboot.c +2 -1
@@ -330,7 +330,8 @@* Stop all CPUs and turn off local APICs and the IO-APIC, so * other OSs see a clean IRQ state. */ -smp_send_stop (); +if (!crashdump_mode ()) +smp_send_stop ();#elif defined(CONFIG_X86_LOCAL_APIC )if (cpu_has_apic) {local_irq_disable ();
arch/i386/kernel/smp.c +1 -1
@@ -519,7 +519,7 @@return 0 ;/* Can deadlock when called with interrupts disabled */ -WARN_ON (irqs_disabled ()); +WARN_ON (irqs_disabled () && !crashdump_mode ()); data.func = func; data.info = info;
arch/i386/kernel/traps.c +10 -1
@@ -293,6 +293,7 @@ }spinlock_t die_lock =SPIN_LOCK_UNLOCKED ; +static int die_owner =-1 ;void die (const char * str,struct pt_regs * regs,long err) {
@@ -300,7 +301,13 @@int nl =0 ;console_verbose (); -spin_lock_irq (&die_lock); +local_irq_disable (); +if (!spin_trylock (&die_lock)) { +if (smp_processor_id () != die_owner) +spin_lock (&die_lock); +/* allow recursive die to fall through */ + } + die_owner =smp_processor_id ();bust_spinlocks (1 );handle_BUG (regs);printk (KERN_ALERT "%s: %04lx [#%d]\n" , str, err &0xffff , ++die_counter);
@@ -319,7 +326,9 @@if (nl)printk ("\n" );show_registers (regs); +try_crashdump (regs);bust_spinlocks (0 ); + die_owner =-1 ;spin_unlock_irq (&die_lock);if (in_interrupt ())panic ("Fatal exception in interrupt" );
arch/i386/mm/init.c +50 -1
63 lines not on this page · raw message
arch/ia64/kernel/process.c +25 -3
@@ -38,6 +38,7 @@#include <asm/uaccess.h> #include <asm/unwind.h> #include <asm/user.h> +#include <asm/diskdump.h> #ifdef CONFIG_PERFMON # include <asm/perfmon.h>
@@ -547,11 +548,13 @@ }void -do_copy_regs (struct unw_frame_info *info,void *arg) +ia64_do_copy_regs (struct unw_frame_info *info,void *arg) {do_copy_task_regs (current, info, arg); } +EXPORT_SYMBOL (ia64_do_copy_regs); +void do_dump_fpu (struct unw_frame_info *info,void *arg) {
@@ -564,7 +567,7 @@struct unw_frame_info tcore_info;if (current == task) { -unw_init_running (do_copy_regs, regs); +unw_init_running (ia64_do_copy_regs, regs); }else {memset (&tcore_info,0 ,sizeof (tcore_info));unw_init_from_blocked_task (&tcore_info, task);
@@ -576,7 +579,7 @@void ia64_elf_core_copy_regs (struct pt_regs *pt,elf_gregset_t dst) { -unw_init_running (do_copy_regs, dst); +unw_init_running (ia64_do_copy_regs, dst); }int
@@ -765,3 +768,22 @@ }EXPORT_SYMBOL (machine_power_off); + +void +ia64_freeze_cpu (struct unw_frame_info *info,void *arg) +{ + current->thread.ksp = (__u64)(info->sw) -16 ; +for (;;)local_irq_disable (); +} + +EXPORT_SYMBOL (ia64_freeze_cpu); + +void +ia64_start_dump (struct unw_frame_info *info,void *arg) +{ +struct dump_call_param *param = arg; + + param->func (param->regs, info); +} + +EXPORT_SYMBOL (ia64_start_dump);
arch/ia64/kernel/smp.c +1 -1
@@ -332,7 +332,7 @@return 0 ;/* Can deadlock when called with interrupts disabled */ -WARN_ON (irqs_disabled ()); +WARN_ON (irqs_disabled () && !crashdump_mode ()); data.func = func; data.info = info;
arch/ia64/kernel/traps.c +1 -0
@@ -92,6 +92,7 @@ }else printk (KERN_ERR "Recursive die() failure, output suppressed\n" ); +try_crashdump (regs);bust_spinlocks (0 ); die.lock_owner =-1 ;spin_unlock_irq (&die.lock);
arch/ia64/mm/init.c +88 -0
94 lines not on this page · raw message
arch/x86_64/kernel/reboot.c +4 -2
@@ -130,7 +130,8 @@int i;#ifdef CONFIG_SMP -smp_halt (); +if (!crashdump_mode ()) +smp_halt ();#endif local_irq_disable ();
@@ -141,7 +142,8 @@disable_IO_APIC (); -local_irq_enable (); +if (!crashdump_mode ()) +local_irq_enable ();/* Tell the BIOS if we want cold or warm reboot */ *((unsigned short *)__va (0x472 )) = reboot_mode;
arch/x86_64/kernel/smp.c +1 -1
@@ -405,7 +405,7 @@return 0 ;/* Can deadlock when called with interrupts disabled */ -WARN_ON (irqs_disabled ()); +WARN_ON (irqs_disabled () && !crashdump_mode ()); data.func = func; data.info = info;
arch/x86_64/kernel/traps.c +1 -0
@@ -359,6 +359,7 @@printk (KERN_ALERT "RIP " );printk_address (regs->rip);printk (" RSP <%016lx>\n" , regs->rsp); +try_crashdump (regs); }void die (const char * str,struct pt_regs * regs,long err)
arch/x86_64/mm/init.c +34 -1
@@ -22,6 +22,7 @@#include <linux/pagemap.h> #include <linux/bootmem.h> #include <linux/proc_fs.h> +#include <linux/module.h> #include <asm/processor.h> #include <asm/system.h>
@@ -374,7 +375,36 @@__flush_tlb_all (); } -static inline int page_is_ram (unsigned long pagenr) +unsigned long next_ram_page (unsigned long pagenr) +{ +int i; +unsigned long min_pageno =ULONG_MAX ; + + pagenr++; + +for (i =0 ; i < e820.nr_map; i++) { +unsigned long addr, end; + +if (e820.map[i].type !=E820_RAM )/* not usable memory */ +continue ; +/* +* !!!FIXME!!! Some BIOSen report areas as RAM that +* are not. Notably the 640->1Mb area. We need a sanity +* check here. +*/ + addr = (e820.map[i].addr+PAGE_SIZE -1 ) >>PAGE_SHIFT ; + end = (e820.map[i].addr+e820.map[i].size) >>PAGE_SHIFT ; +if ((pagenr >= addr) && (pagenr < end)) +return pagenr; +if ((pagenr < addr) && (addr < min_pageno)) + min_pageno = addr; + } +return min_pageno; +} + +EXPORT_SYMBOL_GPL (next_ram_page); + +int page_is_ram (unsigned long pagenr) {int i;
@@ -396,6 +426,8 @@return 0 ; } +EXPORT_SYMBOL_GPL (page_is_ram); +static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel, kcore_modules, kcore_vsyscall;
@@ -548,6 +580,7 @@return 0 ;return pfn_valid (pte_pfn (*pte)); } +EXPORT_SYMBOL_GPL (kern_addr_valid);#ifdef CONFIG_SYSCTL #include <linux/sysctl.h>
drivers/block/Kconfig +5 -0
@@ -347,6 +347,11 @@ your machine, or if you want to have a raid or loopback device bigger than 2TB. Otherwise say N. +config DISKDUMP + tristate "Disk dump support" + ---help--- + Disk dump support. + source "drivers/s390/block/Kconfig" endmenu
drivers/block/Makefile +1 -0
@@ -43,3 +43,4 @@ obj-$(CONFIG_VIODASD) += viodasd.o obj-$(CONFIG_BLK_DEV_SX8) += sx8.o +obj-$(CONFIG_DISKDUMP) += diskdump.o
drivers/block/diskdump.c +992 -0
992 lines not on this page · raw message
drivers/char/sysrq.c +14 -1
@@ -107,6 +107,19 @@ .action_msg = "Resetting", }; +/* crash sysrq handler */ +static void sysrq_handle_crash (int key,struct pt_regs *pt_regs, +struct tty_struct *tty) +{ + *( (char *)0 ) =0 ; +} + +static struct sysrq_key_op sysrq_crash_op = { + .handler = sysrq_handle_crash, + .help_msg ="Crash" , + .action_msg ="Crashing the kernel by request" , +}; +static void sysrq_handle_sync (int key,struct pt_regs *pt_regs,struct tty_struct *tty) {
@@ -235,7 +248,7 @@it is handled specially on the sparc and will never arrive */ /* b */ &sysrq_reboot_op, -/* c */ NULL , +/* c */ &sysrq_crash_op,/* d */ NULL ,/* e */ &sysrq_term_op, /* f */ NULL,
include/asm-generic/diskdump.h +49 -0
49 lines not on this page · raw message
include/asm-i386/diskdump.h +91 -0
91 lines not on this page · raw message
include/asm-i386/kmap_types.h +2 -1
@@ -23,7 +23,8 @@ D(10) KM_IRQ1, D(11) KM_SOFTIRQ0, D(12) KM_SOFTIRQ1, -D(13) KM_TYPE_NR +D(13) KM_CRASHDUMP, +D(14) KM_TYPE_NR };#undef D
include/asm-ia64/diskdump.h +100 -0
100 lines not on this page · raw message
include/asm-ppc64/diskdump.h +6 -0
@@ -0,0 +1,6 @@ +#ifndef _ASM_PPC64_DISKDUMP_H_ +#define _ASM_PPC64_DISKDUMP_H_ + +#include <asm-generic/diskdump.h> + +#endif /* _ASM_PPC64_DISKDUMP_H_ */
include/asm-s390/diskdump.h +6 -0
@@ -0,0 +1,6 @@ +#ifndef _ASM_S390_DISKDUMP_H_ +#define _ASM_S390_DISKDUMP_H_ + +#include <asm-generic/diskdump.h> + +#endif /* _ASM_S390_DISKDUMP_H_ */
include/asm-x86_64/diskdump.h +82 -0
82 lines not on this page · raw message
include/asm-x86_64/kmap_types.h +1 -0
@@ -13,6 +13,7 @@KM_IRQ1 ,KM_SOFTIRQ0 ,KM_SOFTIRQ1 , +KM_CRASHDUMP , KM_TYPE_NR };
include/linux/diskdump.h +174 -0
174 lines not on this page · raw message
include/linux/interrupt.h +4 -0
@@ -247,4 +247,8 @@extern int probe_irq_off (unsigned long );/* returns 0 or negative on failure */ extern unsigned int probe_irq_mask (unsigned long );/* returns mask of ISA interrupts */ + +extern void dump_clear_tasklet (void ); +extern void dump_run_tasklet (void ); +#endif
include/linux/kernel.h +13 -0
@@ -130,6 +130,12 @@extern int panic_on_oops;extern int tainted;extern const char *print_tainted (void ); +struct pt_regs ; +extern void try_crashdump (struct pt_regs *); +extern void (*diskdump_func) (struct pt_regs *regs); +extern int diskdump_mode; +#define crashdump_mode () unlikely(diskdump_mode) +/* Values used for system_state */ extern enum system_states {
@@ -138,6 +144,7 @@SYSTEM_HALT ,SYSTEM_POWER_OFF ,SYSTEM_RESTART , +SYSTEM_DUMPING , } system_state;#define TAINT_PROPRIETARY_MODULE (1<<0)
@@ -158,6 +165,12 @@ #define pr_info(fmt,arg...) \ printk(KERN_INFO fmt,##arg) +#define pr_err(fmt,arg...) \ + printk(KERN_ERR fmt,##arg) + +#define pr_warn(fmt,arg...) \ + printk(KERN_WARNING fmt,##arg) +/* * Display an IP address in readable format. */
include/linux/timer.h +3 -0
@@ -99,4 +99,7 @@extern void run_local_timers (void );extern void it_real_fn (unsigned long ); +extern void dump_clear_timers (void ); +extern void dump_run_timers (void ); +#endif
include/linux/workqueue.h +3 -0
@@ -84,4 +84,7 @@ return ret; } +extern void dump_clear_workqueue (void ); +extern void dump_run_workqueue (void ); +#endif
kernel/Makefile +1 -1
@@ -7,7 +7,7 @@ sysctl.o capability.o ptrace.o timer.o user.o \ signal.o sys.o kmod.o workqueue.o pid.o \ rcupdate.o intermodule.o extable.o params.o posix-timers.o \ - kthread.o + kthread.o dump.o obj-$(CONFIG_FUTEX) += futex.o obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
kernel/dump.c +241 -0
241 lines not on this page · raw message
kernel/panic.c +2 -0
@@ -60,6 +60,8 @@vsnprintf (buf,sizeof (buf), fmt, args);va_end (args);printk (KERN_EMERG "Kernel panic: %s\n" ,buf); +if (diskdump_func) +BUG ();if (in_interrupt ())printk (KERN_EMERG "In interrupt handler - not syncing\n" );else if (!current->pid)
kernel/softirq.c +32 -0
@@ -314,6 +314,38 @@EXPORT_SYMBOL (tasklet_kill); +struct tasklet_head saved_tasklet; + +void dump_clear_tasklet (void ) +{ + saved_tasklet.list =__get_cpu_var (tasklet_vec).list; +__get_cpu_var (tasklet_vec).list =NULL ; +} + +EXPORT_SYMBOL (dump_clear_tasklet); + +void dump_run_tasklet (void ) +{ +struct tasklet_struct *list; + + list =__get_cpu_var (tasklet_vec).list; +__get_cpu_var (tasklet_vec).list =NULL ; + +while (list) { +struct tasklet_struct *t = list; + list = list->next; + +if (!atomic_read (&t->count) && + (test_and_clear_bit (TASKLET_STATE_SCHED , &t->state))) + t->func (t->data); + + t->next =__get_cpu_var (tasklet_vec).list; +__get_cpu_var (tasklet_vec).list = t; + } +} + +EXPORT_SYMBOL (dump_run_tasklet); +void __init softirq_init (void ) {open_softirq (TASKLET_SOFTIRQ , tasklet_action,NULL );
kernel/timer.c +33 -4
@@ -31,6 +31,7 @@#include <linux/time.h> #include <linux/jiffies.h> #include <linux/cpu.h> +#include <linux/delay.h> #include <asm/uaccess.h> #include <asm/unistd.h>
@@ -423,8 +424,9 @@static inline void __run_timers (tvec_base_t *base) {struct timer_list *timer; +unsigned long flags; -spin_lock_irq (&base->lock); +spin_lock_irqsave (&base->lock, flags);while (time_after_eq (jiffies, base->timer_jiffies)) {struct list_head work_list =LIST_HEAD_INIT (work_list);struct list_head *head = &work_list;
@@ -453,14 +455,14 @@set_running_timer (base, timer);smp_wmb (); timer->base =NULL ; -spin_unlock_irq (&base->lock); +spin_unlock_irqrestore (&base->lock, flags);fn (data);spin_lock_irq (&base->lock); goto repeat; } }set_running_timer (base,NULL ); -spin_unlock_irq (&base->lock); +spin_unlock_irqrestore (&base->lock, flags); }#ifdef CONFIG_NO_IDLE_HZ
@@ -1105,6 +1107,12 @@struct timer_list timer;unsigned long expire; +if (crashdump_mode ()) { +mdelay (timeout); +set_current_state (TASK_RUNNING ); +return timeout; + } +switch (timeout) {case MAX_SCHEDULE_TIMEOUT :
@@ -1308,7 +1316,7 @@return 0 ; } -static void __devinit init_timers_cpu (int cpu) +static void /* __devinit */ init_timers_cpu (int cpu) {int j;tvec_base_t *base;
@@ -1327,6 +1335,27 @@ base->timer_jiffies = jiffies; } +static tvec_base_t saved_tvec_base; + +void dump_clear_timers (void ) +{ +tvec_base_t *base = &per_cpu (tvec_bases,smp_processor_id ()); + +memcpy (&saved_tvec_base, base,sizeof (saved_tvec_base)); +init_timers_cpu (smp_processor_id ()); +} + +EXPORT_SYMBOL (dump_clear_timers); + +void dump_run_timers (void ) +{ +tvec_base_t *base = &__get_cpu_var (tvec_bases); + +__run_timers (base); +} + +EXPORT_SYMBOL (dump_run_timers); +#ifdef CONFIG_HOTPLUG_CPU static int migrate_timer_list (tvec_base_t *new_base,struct list_head *head) {
kernel/workqueue.c +34 -0
@@ -424,6 +424,37 @@ } +static struct cpu_workqueue_struct saved_cwq; + +void dump_clear_workqueue (void ) +{ +int cpu =smp_processor_id (); +struct cpu_workqueue_struct *cwq = keventd_wq->cpu_wq + cpu; + +memcpy (&saved_cwq, cwq,sizeof (saved_cwq)); +spin_lock_init (&cwq->lock); +INIT_LIST_HEAD (&cwq->worklist); +init_waitqueue_head (&cwq->more_work); +init_waitqueue_head (&cwq->work_done); +} + +void dump_run_workqueue (void ) +{ +struct cpu_workqueue_struct *cwq; + + cwq = keventd_wq->cpu_wq +smp_processor_id (); +while (!list_empty (&cwq->worklist)) { +struct work_struct *work =list_entry (cwq->worklist.next, + struct work_struct, entry); +void (*f) (void *) = work->func; +void *data = work->data; + +list_del_init (cwq->worklist.next); +clear_bit (0 , &work->pending); +f (data); + } +} +#ifdef CONFIG_HOTPLUG_CPU /* Take the work from this (downed) CPU. */ static void take_over_work (struct workqueue_struct *wq,unsigned int cpu)
@@ -507,3 +538,6 @@EXPORT_SYMBOL (schedule_delayed_work);EXPORT_SYMBOL (flush_scheduled_work); +EXPORT_SYMBOL (dump_clear_workqueue); +EXPORT_SYMBOL (dump_run_workqueue); +
PATCH 2/4 x86-64 support
In reply to Takao IndohThis is a patch for scsi common layer.
drivers/scsi/Kconfig +6 -0
@@ -55,6 +55,12 @@ In this case, do not compile the driver for your SCSI host adapter (below) as a module either. +config SCSI_DUMP + tristate "SCSI dump support" + depends on DISKDUMP && SCSI + help + SCSI dump support + config CHR_DEV_ST tristate "SCSI tape support" depends on SCSI
drivers/scsi/Makefile +2 -0
@@ -137,6 +137,8 @@ obj-$(CONFIG_BLK_DEV_SR) += sr_mod.o obj-$(CONFIG_CHR_DEV_SG) += sg.o +obj-$(CONFIG_SCSI_DUMP) += scsi_dump.o + scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \ scsicam.o scsi_error.o scsi_lib.o \ scsi_scan.o scsi_syms.o scsi_sysfs.o \
drivers/scsi/scsi.c +3 -0
@@ -714,6 +714,9 @@ {unsigned long flags; +if (crashdump_mode ()) +return ; +/* * Set the serial numbers back to zero */
drivers/scsi/scsi_dump.c +598 -0
598 lines not on this page · raw message
drivers/scsi/scsi_error.c +3 -0
@@ -419,6 +419,9 @@**/ static void scsi_eh_done (struct scsi_cmnd *scmd) { +if (crashdump_mode ()) +return ; +/* * if the timeout handler is already running, then just set the * flag which says we finished late, and return. we have no
drivers/scsi/scsi_syms.c +3 -0
@@ -16,6 +16,7 @@#include <scsi/scsicam.h> #include "scsi_logging.h" +#include "scsi_priv.h" /*
@@ -97,3 +98,5 @@*/ EXPORT_SYMBOL (scsi_add_timer);EXPORT_SYMBOL (scsi_delete_timer); + +EXPORT_SYMBOL (scsi_decide_disposition);
drivers/scsi/scsi_sysfs.c +3 -0
@@ -11,6 +11,7 @@#include <linux/init.h> #include <linux/blkdev.h> #include <linux/device.h> +#include <linux/diskdump.h> #include <scsi/scsi.h> #include <scsi/scsi_device.h>
@@ -376,6 +377,7 @@DEVICE_ATTR (state,S_IRUGO |S_IWUSR , show_state_field, store_state_field); +DEVICE_ATTR (dump,S_IRUGO |S_IWUSR , diskdump_sysfs_show, diskdump_sysfs_store);/* Default template for device attributes. May NOT be modified */ static struct device_attribute *scsi_sysfs_sdev_attrs[] = {
@@ -390,6 +392,7 @@ &dev_attr_delete, &dev_attr_state, &dev_attr_timeout, + &dev_attr_dump, NULL };
include/scsi/scsi_host.h +39 -0
@@ -370,6 +370,45 @@* module_init/module_exit. */ struct list_head legacy_hosts; + +/* operations for dump */ + +/* +* dump_sanity_check() checks if the selected device works normally. +* A device which returns an error status will not be selected as +* the dump device. +* +* Status: OPTIONAL +*/ +int (* dump_sanity_check)(struct scsi_device *); + +/* +* dump_quiesce() is called after the device is selected as the +* dump device. Usually, host reset is executed and Write Cache +* Enable bit of the disk device is temporarily set for the +* dump operation. +* +* Status: OPTIONAL +*/ +int (* dump_quiesce)(struct scsi_device *); + +/* +* dump_shutdown() is called after dump is completed. Usually +* "SYNCHRONIZE CACHE" command is issued to the disk. +* +* Status: OPTIONAL +*/ +int (* dump_shutdown)(struct scsi_device *); + +/* +* dump_poll() should call the interrupt handler. It is called +* repeatedly after queuecommand() is issued, and until the command +* is completed. If the low level device driver support crash dump, +* it must have this routine. +* +* Status: OPTIONAL +*/ +void (* dump_poll)(struct scsi_device *); };/*
Quoted 1 line · Takao Indoh
This is a patch for scsi common layer.
still broken. files that are not part of scsi_mod _must_ not include scsi_priv.h. You're still redefining SCSI_DATA_* instead of using the proper constants directly. scsi_dump_probe still makes too many assumptions, the selection must be entirely inside the scsi layer.
PATCH 3/4 x86-64 support
In reply to Takao IndohThis is a patch for aic7xxx/aic79xx driver.
drivers/scsi/aic7xxx/aic79xx_osm.c +37 -0
@@ -786,6 +786,8 @@static int ahd_linux_bus_reset (Scsi_Cmnd *);static int ahd_linux_dev_reset (Scsi_Cmnd *);static int ahd_linux_abort (Scsi_Cmnd *); +static int ahd_linux_sanity_check (struct scsi_device *); +static void ahd_linux_poll (struct scsi_device *);/* * Calculate a safe value for AHD_NSEG (as expressed through ahd_linux_nseg).
@@ -1684,6 +1686,8 @@ .slave_alloc = ahd_linux_slave_alloc, .slave_configure = ahd_linux_slave_configure, .slave_destroy = ahd_linux_slave_destroy, + .dump_sanity_check = ahd_linux_sanity_check, + .dump_poll = ahd_linux_poll, };/**************************** Tasklet Handler *********************************/
@@ -4191,6 +4195,39 @@return IRQ_RETVAL (ours); } +static int +ahd_linux_sanity_check (struct scsi_device *device) +{ +struct ahd_softc *ahd; +struct ahd_linux_device *dev; + + ahd = *(struct ahd_softc **)device->host->hostdata; + dev =ahd_linux_get_device (ahd, device->channel, + device->id, device->lun, +/*alloc*/ FALSE); + +if (dev ==NULL ) +return -ENXIO ; +if (ahd->platform_data->qfrozen || dev->qfrozen) +return -EBUSY ; +if (spin_is_locked (&ahd->platform_data->spin_lock)) +return -EBUSY ; +return 0 ; +} + +static void +ahd_linux_poll (struct scsi_device *device) +{ +struct ahd_softc *ahd; +int ours; + + ahd = *(struct ahd_softc **)device->host->hostdata; + ours =ahd_intr (ahd); +if (ahd_linux_next_device_to_run (ahd) !=NULL ) +ahd_schedule_runq (ahd); +ahd_linux_run_complete_queue (ahd); +} +void ahd_platform_flushwork (struct ahd_softc *ahd) {
drivers/scsi/aic7xxx/aic7xxx_osm.c +39 -0
@@ -774,6 +774,8 @@static int ahc_linux_bus_reset (Scsi_Cmnd *);static int ahc_linux_dev_reset (Scsi_Cmnd *);static int ahc_linux_abort (Scsi_Cmnd *); +static int ahc_linux_sanity_check (struct scsi_device *); +static void ahc_linux_poll (struct scsi_device *);/* * Calculate a safe value for AHC_NSEG (as expressed through ahc_linux_nseg).
@@ -1310,6 +1312,8 @@ .slave_alloc = ahc_linux_slave_alloc, .slave_configure = ahc_linux_slave_configure, .slave_destroy = ahc_linux_slave_destroy, + .dump_sanity_check = ahc_linux_sanity_check, + .dump_poll = ahc_linux_poll, };/**************************** Tasklet Handler *********************************/
@@ -3863,6 +3867,41 @@return IRQ_RETVAL (ours); } +static int +ahc_linux_sanity_check (struct scsi_device *device) +{ +struct ahc_softc *ahc; +struct ahc_linux_device *dev; + + ahc = *(struct ahc_softc **)device->host->hostdata; + dev =ahc_linux_get_device (ahc, device->channel, + device->id, device->lun, +/*alloc*/ FALSE); +if (dev ==NULL ) +return -ENXIO ; +if (ahc->platform_data->qfrozen || dev->qfrozen) +return -EBUSY ; +if (spin_is_locked (&ahc->platform_data->spin_lock)) +return -EBUSY ; +return 0 ; +} + +static void +ahc_linux_poll (struct scsi_device *device) +{ +struct ahc_softc *ahc; +struct ahc_linux_device *dev; + + ahc = *(struct ahc_softc **)device->host->hostdata; +ahc_intr (ahc); +while ((dev =ahc_linux_next_device_to_run (ahc)) !=NULL ) { +TAILQ_REMOVE (&ahc->platform_data->device_runq, dev, links); + dev->flags &= ~AHC_DEV_ON_RUN_LIST ; +ahc_linux_check_device_queue (ahc, dev); + } +ahc_linux_run_complete_queue (ahc); +} +void ahc_platform_flushwork (struct ahc_softc *ahc) {
PATCH 4/4 x86-64 support
In reply to Takao IndohThis is a patch for Fusion-MPT scsi driver.
drivers/message/fusion/mptbase.c +17 -0
@@ -5950,6 +5950,22 @@ }/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +/** +* mpt_poll_interrupt - Check the status of interrupt and if any interrupt +* are triggered, call interrupt handler. +* @ioc: Pointer to MPT_ADAPTER structure +*/ +void +mpt_poll_interrupt (MPT_ADAPTER *ioc) +{ +u32 intstat; + + intstat =CHIPREG_READ32 (&ioc->chip->IntStatus); + +if (intstat &MPI_HIS_REPLY_MESSAGE_INTERRUPT ) +mpt_interrupt (0 , ioc,NULL ); +} +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ EXPORT_SYMBOL (ioc_list);EXPORT_SYMBOL (mpt_proc_root_dir);
@@ -5988,6 +6004,7 @@EXPORT_SYMBOL (mpt_ASCQ_TableSz);EXPORT_SYMBOL (mpt_ScsiOpcodesPtr); +EXPORT_SYMBOL (mpt_poll_interrupt);static struct pci_driver mptbase_driver = { .name ="mptbase" ,
drivers/message/fusion/mptbase.h +18 -0
@@ -1075,6 +1075,7 @@extern void mpt_free_fw_memory (MPT_ADAPTER *ioc);extern int mpt_findImVolumes (MPT_ADAPTER *ioc);extern int mpt_read_ioc_pg_3 (MPT_ADAPTER *ioc); +extern void mpt_poll_interrupt (MPT_ADAPTER *ioc);/* * Public data decl's...
@@ -1090,6 +1091,23 @@extern const char **mpt_ScsiOpcodesPtr;extern int mpt_ASCQ_TableSz; +/* +* Dump stuff... +*/ +#include <linux/diskdump.h> + +#define MPT_HOST_LOCK (host_lock) \ + if (crashdump_mode()) \ + spin_lock(host_lock); \ + else \ + spin_lock_irq(host_lock); + +#define MPT_HOST_UNLOCK (host_lock) \ + if (crashdump_mode()) \ + spin_unlock(host_lock); \ + else \ + spin_unlock_irq(host_lock); +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ #endif /* } __KERNEL__ */
drivers/message/fusion/mptscsih.c +50 -2
82 lines not on this page · raw message
Quoted 7 lines · Takao Indoh
drivers/message/fusion/mptbase.h +7
-0+/* +* Dump stuff... +*/ +#include <linux/diskdump.h> + +#define MPT_HOST_LOCK (host_lock) \ + if (crashdump_mode()) \
drivers/message/fusion/mptbase.h line 1110
Quoted 10 lines
drivers/message/fusion/mptbase.h +10
-0+spin_lock (host_lock); \ + else \ +spin_lock_irq (host_lock ); + +#define MPT_HOST_UNLOCK (host_lock) \ + if (crashdump_mode()) \ + spin_unlock(host_lock); \ + else \ + spin_unlock_irq(host_lock); +
Please stop this macro madness. Why can't you simply use spin+lock_irqsave?
drivers/message/fusion/mptscsih.c line 3306
Quoted 13 lines
drivers/message/fusion/mptscsih.c +13
-0+mptscsih_sanity_check(struct scsi_device *sdev) +{ +MPT_ADAPTER *ioc; +MPT_SCSI_HOST *hd; + + hd = (MPT_SCSI_HOST *) sdev->host->hostdata; +if (!hd) +return -ENXIO ; + ioc = hd->ioc; + +/* message frame freeQ is busy */ +if (spin_is_locked (&ioc->FreeQlock)) +return -EBUSY ;
As in the scsi code spin_is_locked checks are bogus and racy. Only a spin_trylock would be safe. hd can't be NULL.
Thanks for comment.
Quoted 8 lines · Christoph Hellwig
Quoted 8 lines
drivers/message/fusion/mptscsih.c +8
-0+mptscsih_sanity_check(struct scsi_device *sdev) +{ +MPT_ADAPTER *ioc; +MPT_SCSI_HOST *hd; + + hd = (MPT_SCSI_HOST *) sdev->host->hostdata; +if (!hd) +return -ENXIO ;
Quoted 8 lines
drivers/message/fusion/mptscsih.c line 3306
Quoted 5 lines
drivers/message/fusion/mptscsih.c +5
-0+ ioc = hd->ioc; + +/* message frame freeQ is busy */ +if (spin_is_locked (&ioc->FreeQlock)) +return -EBUSY ;As in the scsi code
spin_is_lockedchecks are bogus and racy. Only aspin_trylockwould be safe. hd can't be NULL.
Could you explain to me why spin_is_locked is not safe?
Regards,
Takao Indoh
Quoted 3 lines · Takao Indoh
Quoted 1 line
a
spin_trylockwould be safe. hd can't be NULL.Could you explain to me why
spin_is_lockedis not safe?
it's inherently racy. Also it's always return 0 on UP systems which makes it totally useless there.
Quoted 5 lines · Takao Indoh
Quoted 2 lines
As in the scsi code
spin_is_lockedchecks are bogus and racy. Only aspin_trylockwould be safe. hd can't be NULL.Could you explain to me why
spin_is_lockedis not safe?
Say you have a door with a lock, and someone on the other side. You look at the lock, see that it's unlocked, then open the door. You cannot guarantee that the door will open because the person on the other side could have locked it between the time you looked and turned the handle.
The only way to know for sure whether the door is locked is to turn the handle and see if it opens.
Lee