1 /************************************************************************
3 * ICP vortex GmbH: GDT ISA/EISA/PCI Disk Array Controllers *
4 * Intel Corporation: Storage RAID Controllers *
7 * Copyright (C) 1995-04 ICP vortex GmbH, Achim Leubner *
8 * Copyright (C) 2002-04 Intel Corporation *
9 * Copyright (C) 2003-04 Adaptec Inc. *
10 * <achim_leubner@adaptec.com> *
13 * Boji Tony Kannanthanam <boji.t.kannanthanam@intel.com> *
14 * Johannes Dinner <johannes_dinner@adaptec.com> *
16 * This program is free software; you can redistribute it and/or modify *
17 * it under the terms of the GNU General Public License as published *
18 * by the Free Software Foundation; either version 2 of the License, *
19 * or (at your option) any later version. *
21 * This program is distributed in the hope that it will be useful, *
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
24 * GNU General Public License for more details. *
26 * You should have received a copy of the GNU General Public License *
27 * along with this kernel; if not, write to the Free Software *
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
30 * Linux kernel 2.2.x, 2.4.x, 2.6.x supported *
33 * Revision 1.73 2004/03/31 13:33:03 achim
34 * Special command 0xfd implemented to detect 64-bit DMA support
36 * Revision 1.72 2004/03/17 08:56:04 achim
37 * 64-bit DMA only enabled if FW >= x.43
39 * Revision 1.71 2004/03/05 15:51:29 achim
40 * Screen service: separate message buffer, bugfixes
42 * Revision 1.70 2004/02/27 12:19:07 achim
43 * Bugfix: Reset bit in config (0xfe) call removed
45 * Revision 1.69 2004/02/20 09:50:24 achim
46 * Compatibility changes for kernels < 2.4.20
47 * Bugfix screen service command size
48 * pci_set_dma_mask() error handling added
50 * Revision 1.68 2004/02/19 15:46:54 achim
52 * Drive size bugfix for drives > 1TB
54 * Revision 1.67 2004/01/14 13:11:57 achim
55 * Tool access over /proc no longer supported
58 * Revision 1.66 2003/12/19 15:04:06 achim
59 * Bugfixes support for drives > 2TB
61 * Revision 1.65 2003/12/15 11:21:56 achim
62 * 64-bit DMA support added
63 * Support for drives > 2 TB implemented
64 * Kernels 2.2.x, 2.4.x, 2.6.x supported
66 * Revision 1.64 2003/09/17 08:30:26 achim
67 * EISA/ISA controller scan disabled
68 * Command line switch probe_eisa_isa added
70 * Revision 1.63 2003/07/12 14:01:00 Daniele Bellucci <bellucda@tiscali.it>
71 * Minor cleanups in gdth_ioctl.
73 * Revision 1.62 2003/02/27 15:01:59 achim
74 * Dynamic DMA mapping implemented
75 * New (character device) IOCTL interface added
76 * Other controller related changes made
78 * Revision 1.61 2002/11/08 13:09:52 boji
79 * Added support for XSCALE based RAID Controllers
80 * Fixed SCREENSERVICE initialization in SMP cases
81 * Added checks for gdth_polling before GDTH_HA_LOCK
83 * Revision 1.60 2002/02/05 09:35:22 achim
84 * MODULE_LICENSE only if kernel >= 2.4.11
86 * Revision 1.59 2002/01/30 09:46:33 achim
89 * Revision 1.58 2002/01/29 15:30:02 achim
90 * Set default value of shared_access to Y
91 * New status S_CACHE_RESERV for clustering added
93 * Revision 1.57 2001/08/21 11:16:35 achim
96 * Revision 1.56 2001/08/09 11:19:39 achim
97 * struct scsi_host_template changes
99 * Revision 1.55 2001/08/09 10:11:28 achim
100 * Command HOST_UNFREEZE_IO before cache service init.
102 * Revision 1.54 2001/07/20 13:48:12 achim
103 * Expand: gdth_analyse_hdrive() removed
105 * Revision 1.53 2001/07/17 09:52:49 achim
106 * Small OEM related change
108 * Revision 1.52 2001/06/19 15:06:20 achim
109 * New host command GDT_UNFREEZE_IO added
111 * Revision 1.51 2001/05/22 06:42:37 achim
112 * PCI: Subdevice ID added
114 * Revision 1.50 2001/05/17 13:42:16 achim
115 * Support for Intel Storage RAID Controllers added
117 * Revision 1.50 2001/05/17 12:12:34 achim
118 * Support for Intel Storage RAID Controllers added
120 * Revision 1.49 2001/03/15 15:07:17 achim
121 * New __setup interface for boot command line options added
123 * Revision 1.48 2001/02/06 12:36:28 achim
124 * Bugfix Cluster protocol
126 * Revision 1.47 2001/01/10 14:42:06 achim
127 * New switch shared_access added
129 * Revision 1.46 2001/01/09 08:11:35 achim
130 * gdth_command() removed
131 * meaning of Scsi_Pointer members changed
133 * Revision 1.45 2000/11/16 12:02:24 achim
134 * Changes for kernel 2.4
136 * Revision 1.44 2000/10/11 08:44:10 achim
137 * Clustering changes: New flag media_changed added
139 * Revision 1.43 2000/09/20 12:59:01 achim
140 * DPMEM remap functions for all PCI controller types implemented
141 * Small changes for ia64 platform
143 * Revision 1.42 2000/07/20 09:04:50 achim
144 * Small changes for kernel 2.4
146 * Revision 1.41 2000/07/04 14:11:11 achim
147 * gdth_analyse_hdrive() added to rescan drives after online expansion
149 * Revision 1.40 2000/06/27 11:24:16 achim
150 * Changes Clustering, Screenservice
152 * Revision 1.39 2000/06/15 13:09:04 achim
153 * Changes for gdth_do_cmd()
155 * Revision 1.38 2000/06/15 12:08:43 achim
156 * Bugfix gdth_sync_event(), service SCREENSERVICE
157 * Data direction for command 0xc2 changed to DOU
159 * Revision 1.37 2000/05/25 13:50:10 achim
160 * New driver parameter virt_ctr added
162 * Revision 1.36 2000/05/04 08:50:46 achim
163 * Event buffer now in gdth_ha_str
165 * Revision 1.35 2000/03/03 10:44:08 achim
166 * New event_string only valid for the RP controller family
168 * Revision 1.34 2000/03/02 14:55:29 achim
169 * New mechanism for async. event handling implemented
171 * Revision 1.33 2000/02/21 15:37:37 achim
172 * Bugfix Alpha platform + DPMEM above 4GB
174 * Revision 1.32 2000/02/14 16:17:37 achim
175 * Bugfix sense_buffer[] + raw devices
177 * Revision 1.31 2000/02/10 10:29:00 achim
178 * Delete sense_buffer[0], if command OK
180 * Revision 1.30 1999/11/02 13:42:39 achim
181 * ARRAY_DRV_LIST2 implemented
182 * Now 255 log. and 100 host drives supported
184 * Revision 1.29 1999/10/05 13:28:47 achim
185 * GDT_CLUST_RESET added
187 * Revision 1.28 1999/08/12 13:44:54 achim
189 * Cluster drives -> removeable drives
191 * Revision 1.27 1999/06/22 07:22:38 achim
194 * Revision 1.26 1999/06/10 16:09:12 achim
195 * Cluster Host Drive support: Bugfixes
197 * Revision 1.25 1999/06/01 16:03:56 achim
198 * gdth_init_pci(): Manipulate config. space to start RP controller
200 * Revision 1.24 1999/05/26 11:53:06 achim
201 * Cluster Host Drive support added
203 * Revision 1.23 1999/03/26 09:12:31 achim
204 * Default value for hdr_channel set to 0
206 * Revision 1.22 1999/03/22 16:27:16 achim
207 * Bugfix: gdth_store_event() must not be locked with GDTH_LOCK_HA()
209 * Revision 1.21 1999/03/16 13:40:34 achim
210 * Problems with reserved drives solved
211 * gdth_eh_bus_reset() implemented
213 * Revision 1.20 1999/03/10 09:08:13 achim
214 * Bugfix: Corrections in gdth_direction_tab[] made
215 * Bugfix: Increase command timeout (gdth_update_timeout()) NOT in gdth_putq()
217 * Revision 1.19 1999/03/05 14:38:16 achim
218 * Bugfix: Heads/Sectors mapping for reserved devices possibly wrong
219 * -> gdth_eval_mapping() implemented, changes in gdth_bios_param()
220 * INIT_RETRIES set to 100s to avoid DEINIT-Timeout for controllers
221 * with BIOS disabled and memory test set to Intensive
222 * Enhanced /proc support
224 * Revision 1.18 1999/02/24 09:54:33 achim
225 * Command line parameter hdr_channel implemented
226 * Bugfix for EISA controllers + Linux 2.2.x
228 * Revision 1.17 1998/12/17 15:58:11 achim
229 * Command line parameters implemented
230 * Changes for Alpha platforms
231 * PCI controller scan changed
232 * SMP support improved (spin_lock_irqsave(),...)
233 * New async. events, new scan/reserve commands included
235 * Revision 1.16 1998/09/28 16:08:46 achim
236 * GDT_PCIMPR: DPMEM remapping, if required
239 * Revision 1.15 1998/06/03 14:54:06 achim
240 * gdth_delay(), gdth_flush() implemented
241 * Bugfix: gdth_release() changed
243 * Revision 1.14 1998/05/22 10:01:17 achim
244 * mj: pcibios_strerror() removed
245 * Improved SMP support (if version >= 2.1.95)
246 * gdth_halt(): halt_called flag added (if version < 2.1)
248 * Revision 1.13 1998/04/16 09:14:57 achim
249 * Reserve drives (for raw service) implemented
250 * New error handling code enabled
251 * Get controller name from board_info() IOCTL
252 * Final round of PCI device driver patches by Martin Mares
254 * Revision 1.12 1998/03/03 09:32:37 achim
255 * Fibre channel controller support added
257 * Revision 1.11 1998/01/27 16:19:14 achim
259 * add_timer()/del_timer() instead of GDTH_TIMER
260 * scsi_add_timer()/scsi_del_timer() instead of SCSI_TIMER
261 * New error handling included
263 * Revision 1.10 1997/10/31 12:29:57 achim
264 * Read heads/sectors from host drive
266 * Revision 1.9 1997/09/04 10:07:25 achim
267 * IO-mapping with virt_to_bus(), gdth_readb(), gdth_writeb(), ...
268 * register_reboot_notifier() to get a notify on shutown used
270 * Revision 1.8 1997/04/02 12:14:30 achim
271 * Version 1.00 (see gdth.h), tested with kernel 2.0.29
273 * Revision 1.7 1997/03/12 13:33:37 achim
274 * gdth_reset() changed, new async. events
276 * Revision 1.6 1997/03/04 14:01:11 achim
277 * Shutdown routine gdth_halt() implemented
279 * Revision 1.5 1997/02/21 09:08:36 achim
280 * New controller included (RP, RP1, RP2 series)
281 * IOCTL interface implemented
283 * Revision 1.4 1996/07/05 12:48:55 achim
284 * Function gdth_bios_param() implemented
285 * New constant GDTH_MAXC_P_L inserted
286 * GDT_WRITE_THR, GDT_EXT_INFO implemented
287 * Function gdth_reset() changed
289 * Revision 1.3 1996/05/10 09:04:41 achim
290 * Small changes for Linux 1.2.13
292 * Revision 1.2 1996/05/09 12:45:27 achim
293 * Loadable module support implemented
294 * /proc support corrections made
296 * Revision 1.1 1996/04/11 07:35:57 achim
299 ************************************************************************/
301 /* All GDT Disk Array Controllers are fully supported by this driver.
302 * This includes the PCI/EISA/ISA SCSI Disk Array Controllers and the
303 * PCI Fibre Channel Disk Array Controllers. See gdth.h for a complete
304 * list of all controller types.
306 * If you have one or more GDT3000/3020 EISA controllers with
307 * controller BIOS disabled, you have to set the IRQ values with the
308 * command line option "gdth=irq1,irq2,...", where the irq1,irq2,... are
309 * the IRQ values for the EISA controllers.
311 * After the optional list of IRQ values, other possible
312 * command line options are:
313 * disable:Y disable driver
314 * disable:N enable driver
315 * reserve_mode:0 reserve no drives for the raw service
316 * reserve_mode:1 reserve all not init., removable drives
317 * reserve_mode:2 reserve all not init. drives
318 * reserve_list:h,b,t,l,h,b,t,l,... reserve particular drive(s) with
319 * h- controller no., b- channel no.,
320 * t- target ID, l- LUN
321 * reverse_scan:Y reverse scan order for PCI controllers
322 * reverse_scan:N scan PCI controllers like BIOS
323 * max_ids:x x - target ID count per channel (1..MAXID)
324 * rescan:Y rescan all channels/IDs
325 * rescan:N use all devices found until now
326 * virt_ctr:Y map every channel to a virtual controller
327 * virt_ctr:N use multi channel support
328 * hdr_channel:x x - number of virtual bus for host drives
329 * shared_access:Y disable driver reserve/release protocol to
330 * access a shared resource from several nodes,
331 * appropiate controller firmware required
332 * shared_access:N enable driver reserve/release protocol
333 * probe_eisa_isa:Y scan for EISA/ISA controllers
334 * probe_eisa_isa:N do not scan for EISA/ISA controllers
335 * force_dma32:Y use only 32 bit DMA mode
336 * force_dma32:N use 64 bit DMA mode, if supported
338 * The default values are: "gdth=disable:N,reserve_mode:1,reverse_scan:N,
339 * max_ids:127,rescan:N,virt_ctr:N,hdr_channel:0,
340 * shared_access:Y,probe_eisa_isa:N,force_dma32:N".
341 * Here is another example: "gdth=reserve_list:0,1,2,0,0,1,3,0,rescan:Y".
343 * When loading the gdth driver as a module, the same options are available.
344 * You can set the IRQs with "IRQ=...". However, the syntax to specify the
345 * options changes slightly. You must replace all ',' between options
346 * with ' ' and all ':' with '=' and you must use
347 * '1' in place of 'Y' and '0' in place of 'N'.
349 * Default: "modprobe gdth disable=0 reserve_mode=1 reverse_scan=0
350 * max_ids=127 rescan=0 virt_ctr=0 hdr_channel=0 shared_access=0
351 * probe_eisa_isa=0 force_dma32=0"
352 * The other example: "modprobe gdth reserve_list=0,1,2,0,0,1,3,0 rescan=1".
355 /* The meaning of the Scsi_Pointer members in this driver is as follows:
357 * this_residual: Command priority
358 * buffer: phys. DMA sense buffer
359 * dma_handle: phys. DMA buffer (kernel >= 2.4.0)
360 * buffers_residual: Timeout value
361 * Status: Command status (gdth_do_cmd()), DMA mem. mappings
362 * Message: Additional info (gdth_do_cmd()), DMA direction
363 * have_data_in: Flag for gdth_wait_completion()
364 * sent_command: Opcode special command
365 * phase: Service/parameter/return code special command
369 /* interrupt coalescing */
370 /* #define INT_COAL */
373 #define GDTH_STATISTICS
375 #include <linux/module.h>
377 #include <linux/version.h>
378 #include <linux/kernel.h>
379 #include <linux/types.h>
380 #include <linux/pci.h>
381 #include <linux/string.h>
382 #include <linux/ctype.h>
383 #include <linux/ioport.h>
384 #include <linux/delay.h>
385 #include <linux/sched.h>
386 #include <linux/interrupt.h>
387 #include <linux/in.h>
388 #include <linux/proc_fs.h>
389 #include <linux/time.h>
390 #include <linux/timer.h>
392 #include <linux/mc146818rtc.h>
394 #include <linux/reboot.h>
397 #include <asm/system.h>
399 #include <asm/uaccess.h>
400 #include <linux/spinlock.h>
401 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
402 #include <linux/blkdev.h>
404 #include <linux/blk.h>
409 #include <scsi/scsi_host.h>
411 #include "gdth_kcompat.h"
413 static void gdth_delay(int milliseconds
);
414 static void gdth_eval_mapping(ulong32 size
, ulong32
*cyls
, int *heads
, int *secs
);
415 static irqreturn_t
gdth_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
);
416 static int gdth_sync_event(int hanum
,int service
,unchar index
,Scsi_Cmnd
*scp
);
417 static int gdth_async_event(int hanum
);
418 static void gdth_log_event(gdth_evt_data
*dvr
, char *buffer
);
420 static void gdth_putq(int hanum
,Scsi_Cmnd
*scp
,unchar priority
);
421 static void gdth_next(int hanum
);
422 static int gdth_fill_raw_cmd(int hanum
,Scsi_Cmnd
*scp
,unchar b
);
423 static int gdth_special_cmd(int hanum
,Scsi_Cmnd
*scp
);
424 static gdth_evt_str
*gdth_store_event(gdth_ha_str
*ha
, ushort source
,
425 ushort idx
, gdth_evt_data
*evt
);
426 static int gdth_read_event(gdth_ha_str
*ha
, int handle
, gdth_evt_str
*estr
);
427 static void gdth_readapp_event(gdth_ha_str
*ha
, unchar application
,
429 static void gdth_clear_events(void);
431 static void gdth_copy_internal_data(int hanum
,Scsi_Cmnd
*scp
,
432 char *buffer
,ushort count
);
433 static int gdth_internal_cache_cmd(int hanum
,Scsi_Cmnd
*scp
);
434 static int gdth_fill_cache_cmd(int hanum
,Scsi_Cmnd
*scp
,ushort hdrive
);
436 static int gdth_search_eisa(ushort eisa_adr
);
437 static int gdth_search_isa(ulong32 bios_adr
);
438 static int gdth_search_pci(gdth_pci_str
*pcistr
);
439 static void gdth_search_dev(gdth_pci_str
*pcistr
, ushort
*cnt
,
440 ushort vendor
, ushort dev
);
441 static void gdth_sort_pci(gdth_pci_str
*pcistr
, int cnt
);
442 static int gdth_init_eisa(ushort eisa_adr
,gdth_ha_str
*ha
);
443 static int gdth_init_isa(ulong32 bios_adr
,gdth_ha_str
*ha
);
444 static int gdth_init_pci(gdth_pci_str
*pcistr
,gdth_ha_str
*ha
);
446 static void gdth_enable_int(int hanum
);
447 static int gdth_get_status(unchar
*pIStatus
,int irq
);
448 static int gdth_test_busy(int hanum
);
449 static int gdth_get_cmd_index(int hanum
);
450 static void gdth_release_event(int hanum
);
451 static int gdth_wait(int hanum
,int index
,ulong32 time
);
452 static int gdth_internal_cmd(int hanum
,unchar service
,ushort opcode
,ulong32 p1
,
453 ulong64 p2
,ulong64 p3
);
454 static int gdth_search_drives(int hanum
);
455 static int gdth_analyse_hdrive(int hanum
, ushort hdrive
);
457 static const char *gdth_ctr_name(int hanum
);
459 static int gdth_open(struct inode
*inode
, struct file
*filep
);
460 static int gdth_close(struct inode
*inode
, struct file
*filep
);
461 static int gdth_ioctl(struct inode
*inode
, struct file
*filep
,
462 unsigned int cmd
, unsigned long arg
);
464 static void gdth_flush(int hanum
);
465 static int gdth_halt(struct notifier_block
*nb
, ulong event
, void *buf
);
468 static unchar DebugState
= DEBUG_GDTH
;
471 #define MAX_SERBUF 160
472 static void ser_init(void);
473 static void ser_puts(char *str
);
474 static void ser_putc(char c
);
475 static int ser_printk(const char *fmt
, ...);
476 static char strbuf
[MAX_SERBUF
+1];
478 #define COM_BASE 0x2f8
480 #define COM_BASE 0x3f8
482 static void ser_init()
484 unsigned port
=COM_BASE
;
488 /* 19200 Baud, if 9600: outb(12,port) */
498 static void ser_puts(char *str
)
503 for (ptr
=str
;*ptr
;++ptr
)
507 static void ser_putc(char c
)
509 unsigned port
=COM_BASE
;
511 while ((inb(port
+5) & 0x20)==0);
515 while ((inb(port
+5) & 0x20)==0);
520 static int ser_printk(const char *fmt
, ...)
526 i
= vsprintf(strbuf
,fmt
,args
);
532 #define TRACE(a) {if (DebugState==1) {ser_printk a;}}
533 #define TRACE2(a) {if (DebugState==1 || DebugState==2) {ser_printk a;}}
534 #define TRACE3(a) {if (DebugState!=0) {ser_printk a;}}
536 #else /* !__SERIAL__ */
537 #define TRACE(a) {if (DebugState==1) {printk a;}}
538 #define TRACE2(a) {if (DebugState==1 || DebugState==2) {printk a;}}
539 #define TRACE3(a) {if (DebugState!=0) {printk a;}}
548 #ifdef GDTH_STATISTICS
549 static ulong32 max_rq
=0, max_index
=0, max_sg
=0;
551 static ulong32 max_int_coal
=0;
553 static ulong32 act_ints
=0, act_ios
=0, act_stats
=0, act_rq
=0;
554 static struct timer_list gdth_timer
;
557 #define PTR2USHORT(a) (ushort)(ulong)(a)
558 #define GDTOFFSOF(a,b) (size_t)&(((a*)0)->b)
559 #define INDEX_OK(i,t) ((i)<sizeof(t)/sizeof((t)[0]))
561 #define NUMDATA(a) ( (gdth_num_str *)((a)->hostdata))
562 #define HADATA(a) (&((gdth_ext_str *)((a)->hostdata))->haext)
563 #define CMDDATA(a) (&((gdth_ext_str *)((a)->hostdata))->cmdext)
565 #define BUS_L2P(a,b) ((b)>(a)->virt_bus ? (b-1):(b))
567 #define gdth_readb(addr) readb(addr)
568 #define gdth_readw(addr) readw(addr)
569 #define gdth_readl(addr) readl(addr)
570 #define gdth_writeb(b,addr) writeb((b),(addr))
571 #define gdth_writew(b,addr) writew((b),(addr))
572 #define gdth_writel(b,addr) writel((b),(addr))
574 static unchar gdth_drq_tab
[4] = {5,6,7,7}; /* DRQ table */
575 static unchar gdth_irq_tab
[6] = {0,10,11,12,14,0}; /* IRQ table */
576 static unchar gdth_polling
; /* polling if TRUE */
577 static unchar gdth_from_wait
= FALSE
; /* gdth_wait() */
578 static int wait_index
,wait_hanum
; /* gdth_wait() */
579 static int gdth_ctr_count
= 0; /* controller count */
580 static int gdth_ctr_vcount
= 0; /* virt. ctr. count */
581 static int gdth_ctr_released
= 0; /* gdth_release() */
582 static struct Scsi_Host
*gdth_ctr_tab
[MAXHA
]; /* controller table */
583 static struct Scsi_Host
*gdth_ctr_vtab
[MAXHA
*MAXBUS
]; /* virt. ctr. table */
584 static unchar gdth_write_through
= FALSE
; /* write through */
585 static gdth_evt_str ebuffer
[MAX_EVENTS
]; /* event buffer */
590 #define DIN 1 /* IN data direction */
591 #define DOU 2 /* OUT data direction */
592 #define DNO DIN /* no data transfer */
593 #define DUN DIN /* unknown data direction */
594 static unchar gdth_direction_tab
[0x100] = {
595 DNO
,DNO
,DIN
,DIN
,DOU
,DIN
,DIN
,DOU
,DIN
,DUN
,DOU
,DOU
,DUN
,DUN
,DUN
,DIN
,
596 DNO
,DIN
,DIN
,DOU
,DIN
,DOU
,DNO
,DNO
,DOU
,DNO
,DIN
,DNO
,DIN
,DOU
,DNO
,DUN
,
597 DIN
,DUN
,DIN
,DUN
,DOU
,DIN
,DUN
,DUN
,DIN
,DIN
,DOU
,DNO
,DUN
,DIN
,DOU
,DOU
,
598 DOU
,DOU
,DOU
,DNO
,DIN
,DNO
,DNO
,DIN
,DOU
,DOU
,DOU
,DOU
,DIN
,DOU
,DIN
,DOU
,
599 DOU
,DOU
,DIN
,DIN
,DIN
,DNO
,DUN
,DNO
,DNO
,DNO
,DUN
,DNO
,DOU
,DIN
,DUN
,DUN
,
600 DUN
,DUN
,DUN
,DUN
,DUN
,DOU
,DUN
,DUN
,DUN
,DUN
,DIN
,DUN
,DUN
,DUN
,DUN
,DUN
,
601 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,
602 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,
603 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DIN
,DUN
,DOU
,DUN
,DUN
,DUN
,DUN
,DUN
,
604 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DIN
,DUN
,
605 DUN
,DUN
,DUN
,DUN
,DUN
,DNO
,DNO
,DUN
,DIN
,DNO
,DOU
,DUN
,DNO
,DUN
,DOU
,DOU
,
606 DOU
,DOU
,DOU
,DNO
,DUN
,DIN
,DOU
,DIN
,DIN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,
607 DUN
,DUN
,DOU
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,
608 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,
609 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DOU
,DUN
,DUN
,DUN
,DUN
,DUN
,
610 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
613 /* LILO and modprobe/insmod parameters */
614 /* IRQ list for GDT3000/3020 EISA controllers */
615 static int irq
[MAXHA
] __initdata
=
616 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
617 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
618 /* disable driver flag */
619 static int disable __initdata
= 0;
621 static int reserve_mode
= 1;
623 static int reserve_list
[MAX_RES_ARGS
] =
624 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
625 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
626 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
627 /* scan order for PCI controllers */
628 static int reverse_scan
= 0;
629 /* virtual channel for the host drives */
630 static int hdr_channel
= 0;
631 /* max. IDs per channel */
632 static int max_ids
= MAXID
;
634 static int rescan
= 0;
635 /* map channels to virtual controllers */
636 static int virt_ctr
= 0;
638 static int shared_access
= 1;
639 /* enable support for EISA and ISA controllers */
640 static int probe_eisa_isa
= 0;
641 /* 64 bit DMA mode, support for drives > 2 TB, if force_dma32 = 0 */
642 static int force_dma32
= 0;
644 /* parameters for modprobe/insmod */
645 module_param_array(irq
, int, NULL
, 0);
646 module_param(disable
, int, 0);
647 module_param(reserve_mode
, int, 0);
648 module_param_array(reserve_list
, int, NULL
, 0);
649 module_param(reverse_scan
, int, 0);
650 module_param(hdr_channel
, int, 0);
651 module_param(max_ids
, int, 0);
652 module_param(rescan
, int, 0);
653 module_param(virt_ctr
, int, 0);
654 module_param(shared_access
, int, 0);
655 module_param(probe_eisa_isa
, int, 0);
656 module_param(force_dma32
, int, 0);
657 MODULE_AUTHOR("Achim Leubner");
658 MODULE_LICENSE("GPL");
660 /* ioctl interface */
661 static struct file_operations gdth_fops
= {
664 .release
= gdth_close
,
667 #include "gdth_proc.h"
668 #include "gdth_proc.c"
670 /* notifier block to get a notify on system shutdown/halt/reboot */
671 static struct notifier_block gdth_notifier
= {
676 static void gdth_delay(int milliseconds
)
678 if (milliseconds
== 0) {
681 mdelay(milliseconds
);
685 static void gdth_eval_mapping(ulong32 size
, ulong32
*cyls
, int *heads
, int *secs
)
687 *cyls
= size
/HEADS
/SECS
;
688 if (*cyls
<= MAXCYLS
) {
691 } else { /* too high for 64*32 */
692 *cyls
= size
/MEDHEADS
/MEDSECS
;
693 if (*cyls
<= MAXCYLS
) {
696 } else { /* too high for 127*63 */
697 *cyls
= size
/BIGHEADS
/BIGSECS
;
704 /* controller search and initialization functions */
706 static int __init
gdth_search_eisa(ushort eisa_adr
)
710 TRACE(("gdth_search_eisa() adr. %x\n",eisa_adr
));
711 id
= inl(eisa_adr
+ID0REG
);
712 if (id
== GDT3A_ID
|| id
== GDT3B_ID
) { /* GDT3000A or GDT3000B */
713 if ((inb(eisa_adr
+EISAREG
) & 8) == 0)
714 return 0; /* not EISA configured */
717 if (id
== GDT3_ID
) /* GDT3000 */
724 static int __init
gdth_search_isa(ulong32 bios_adr
)
729 TRACE(("gdth_search_isa() bios adr. %x\n",bios_adr
));
730 if ((addr
= ioremap(bios_adr
+BIOS_ID_OFFS
, sizeof(ulong32
))) != NULL
) {
731 id
= gdth_readl(addr
);
733 if (id
== GDT2_ID
) /* GDT2000 */
740 static int __init
gdth_search_pci(gdth_pci_str
*pcistr
)
744 TRACE(("gdth_search_pci()\n"));
747 for (device
= 0; device
<= PCI_DEVICE_ID_VORTEX_GDT6555
; ++device
)
748 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_VORTEX
, device
);
749 for (device
= PCI_DEVICE_ID_VORTEX_GDT6x17RP
;
750 device
<= PCI_DEVICE_ID_VORTEX_GDTMAXRP
; ++device
)
751 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_VORTEX
, device
);
752 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_VORTEX
,
753 PCI_DEVICE_ID_VORTEX_GDTNEWRX
);
754 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_VORTEX
,
755 PCI_DEVICE_ID_VORTEX_GDTNEWRX2
);
756 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_INTEL
,
757 PCI_DEVICE_ID_INTEL_SRC
);
758 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_INTEL
,
759 PCI_DEVICE_ID_INTEL_SRC_XSCALE
);
763 /* Vortex only makes RAID controllers.
764 * We do not really want to specify all 550 ids here, so wildcard match.
766 static struct pci_device_id gdthtable
[] __attribute_used__
= {
767 {PCI_VENDOR_ID_VORTEX
,PCI_ANY_ID
,PCI_ANY_ID
, PCI_ANY_ID
},
768 {PCI_VENDOR_ID_INTEL
,PCI_DEVICE_ID_INTEL_SRC
,PCI_ANY_ID
,PCI_ANY_ID
},
769 {PCI_VENDOR_ID_INTEL
,PCI_DEVICE_ID_INTEL_SRC_XSCALE
,PCI_ANY_ID
,PCI_ANY_ID
},
772 MODULE_DEVICE_TABLE(pci
,gdthtable
);
774 static void __init
gdth_search_dev(gdth_pci_str
*pcistr
, ushort
*cnt
,
775 ushort vendor
, ushort device
)
777 ulong base0
, base1
, base2
;
778 struct pci_dev
*pdev
;
780 TRACE(("gdth_search_dev() cnt %d vendor %x device %x\n",
781 *cnt
, vendor
, device
));
784 while ((pdev
= pci_find_device(vendor
, device
, pdev
))
786 if (pci_enable_device(pdev
))
790 /* GDT PCI controller found, resources are already in pdev */
791 pcistr
[*cnt
].pdev
= pdev
;
792 pcistr
[*cnt
].vendor_id
= vendor
;
793 pcistr
[*cnt
].device_id
= device
;
794 pcistr
[*cnt
].subdevice_id
= pdev
->subsystem_device
;
795 pcistr
[*cnt
].bus
= pdev
->bus
->number
;
796 pcistr
[*cnt
].device_fn
= pdev
->devfn
;
797 pcistr
[*cnt
].irq
= pdev
->irq
;
798 base0
= pci_resource_flags(pdev
, 0);
799 base1
= pci_resource_flags(pdev
, 1);
800 base2
= pci_resource_flags(pdev
, 2);
801 if (device
<= PCI_DEVICE_ID_VORTEX_GDT6000B
|| /* GDT6000/B */
802 device
>= PCI_DEVICE_ID_VORTEX_GDT6x17RP
) { /* MPR */
803 if (!(base0
& IORESOURCE_MEM
))
805 pcistr
[*cnt
].dpmem
= pci_resource_start(pdev
, 0);
806 } else { /* GDT6110, GDT6120, .. */
807 if (!(base0
& IORESOURCE_MEM
) ||
808 !(base2
& IORESOURCE_MEM
) ||
809 !(base1
& IORESOURCE_IO
))
811 pcistr
[*cnt
].dpmem
= pci_resource_start(pdev
, 2);
812 pcistr
[*cnt
].io_mm
= pci_resource_start(pdev
, 0);
813 pcistr
[*cnt
].io
= pci_resource_start(pdev
, 1);
815 TRACE2(("Controller found at %d/%d, irq %d, dpmem 0x%lx\n",
816 pcistr
[*cnt
].bus
, PCI_SLOT(pcistr
[*cnt
].device_fn
),
817 pcistr
[*cnt
].irq
, pcistr
[*cnt
].dpmem
));
823 static void __init
gdth_sort_pci(gdth_pci_str
*pcistr
, int cnt
)
828 TRACE(("gdth_sort_pci() cnt %d\n",cnt
));
834 for (i
= 0; i
< cnt
-1; ++i
) {
836 if ((pcistr
[i
].bus
> pcistr
[i
+1].bus
) ||
837 (pcistr
[i
].bus
== pcistr
[i
+1].bus
&&
838 PCI_SLOT(pcistr
[i
].device_fn
) >
839 PCI_SLOT(pcistr
[i
+1].device_fn
))) {
841 pcistr
[i
] = pcistr
[i
+1];
846 if ((pcistr
[i
].bus
< pcistr
[i
+1].bus
) ||
847 (pcistr
[i
].bus
== pcistr
[i
+1].bus
&&
848 PCI_SLOT(pcistr
[i
].device_fn
) <
849 PCI_SLOT(pcistr
[i
+1].device_fn
))) {
851 pcistr
[i
] = pcistr
[i
+1];
861 static int __init
gdth_init_eisa(ushort eisa_adr
,gdth_ha_str
*ha
)
864 unchar prot_ver
,eisacf
,i
,irq_found
;
866 TRACE(("gdth_init_eisa() adr. %x\n",eisa_adr
));
868 /* disable board interrupts, deinitialize services */
869 outb(0xff,eisa_adr
+EDOORREG
);
870 outb(0x00,eisa_adr
+EDENABREG
);
871 outb(0x00,eisa_adr
+EINTENABREG
);
873 outb(0xff,eisa_adr
+LDOORREG
);
874 retries
= INIT_RETRIES
;
876 while (inb(eisa_adr
+EDOORREG
) != 0xff) {
877 if (--retries
== 0) {
878 printk("GDT-EISA: Initialization error (DEINIT failed)\n");
882 TRACE2(("wait for DEINIT: retries=%d\n",retries
));
884 prot_ver
= inb(eisa_adr
+MAILBOXREG
);
885 outb(0xff,eisa_adr
+EDOORREG
);
886 if (prot_ver
!= PROTOCOL_VERSION
) {
887 printk("GDT-EISA: Illegal protocol version\n");
891 ha
->brd_phys
= (ulong32
)eisa_adr
>> 12;
893 outl(0,eisa_adr
+MAILBOXREG
);
894 outl(0,eisa_adr
+MAILBOXREG
+4);
895 outl(0,eisa_adr
+MAILBOXREG
+8);
896 outl(0,eisa_adr
+MAILBOXREG
+12);
899 if ((id
= inl(eisa_adr
+ID0REG
)) == GDT3_ID
) {
900 ha
->oem_id
= OEM_ID_ICP
;
903 outl(1,eisa_adr
+MAILBOXREG
+8);
904 outb(0xfe,eisa_adr
+LDOORREG
);
905 retries
= INIT_RETRIES
;
907 while (inb(eisa_adr
+EDOORREG
) != 0xfe) {
908 if (--retries
== 0) {
909 printk("GDT-EISA: Initialization error (get IRQ failed)\n");
914 ha
->irq
= inb(eisa_adr
+MAILBOXREG
);
915 outb(0xff,eisa_adr
+EDOORREG
);
916 TRACE2(("GDT3000/3020: IRQ=%d\n",ha
->irq
));
917 /* check the result */
919 TRACE2(("Unknown IRQ, use IRQ table from cmd line !\n"));
920 for (i
= 0, irq_found
= FALSE
;
921 i
< MAXHA
&& irq
[i
] != 0xff; ++i
) {
922 if (irq
[i
]==10 || irq
[i
]==11 || irq
[i
]==12 || irq
[i
]==14) {
930 printk("GDT-EISA: Can not detect controller IRQ,\n");
931 printk("Use IRQ setting from command line (IRQ = %d)\n",
934 printk("GDT-EISA: Initialization error (unknown IRQ), Enable\n");
935 printk("the controller BIOS or use command line parameters\n");
940 eisacf
= inb(eisa_adr
+EISAREG
) & 7;
941 if (eisacf
> 4) /* level triggered */
943 ha
->irq
= gdth_irq_tab
[eisacf
];
944 ha
->oem_id
= OEM_ID_ICP
;
949 ha
->dma64_support
= 0;
954 static int __init
gdth_init_isa(ulong32 bios_adr
,gdth_ha_str
*ha
)
956 register gdt2_dpram_str __iomem
*dp2_ptr
;
958 unchar irq_drq
,prot_ver
;
961 TRACE(("gdth_init_isa() bios adr. %x\n",bios_adr
));
963 ha
->brd
= ioremap(bios_adr
, sizeof(gdt2_dpram_str
));
964 if (ha
->brd
== NULL
) {
965 printk("GDT-ISA: Initialization error (DPMEM remap error)\n");
969 gdth_writeb(1, &dp2_ptr
->io
.memlock
); /* switch off write protection */
970 /* reset interface area */
971 memset_io(&dp2_ptr
->u
, 0, sizeof(dp2_ptr
->u
));
972 if (gdth_readl(&dp2_ptr
->u
) != 0) {
973 printk("GDT-ISA: Initialization error (DPMEM write error)\n");
978 /* disable board interrupts, read DRQ and IRQ */
979 gdth_writeb(0xff, &dp2_ptr
->io
.irqdel
);
980 gdth_writeb(0x00, &dp2_ptr
->io
.irqen
);
981 gdth_writeb(0x00, &dp2_ptr
->u
.ic
.S_Status
);
982 gdth_writeb(0x00, &dp2_ptr
->u
.ic
.Cmd_Index
);
984 irq_drq
= gdth_readb(&dp2_ptr
->io
.rq
);
985 for (i
=0; i
<3; ++i
) {
986 if ((irq_drq
& 1)==0)
990 ha
->drq
= gdth_drq_tab
[i
];
992 irq_drq
= gdth_readb(&dp2_ptr
->io
.rq
) >> 3;
993 for (i
=1; i
<5; ++i
) {
994 if ((irq_drq
& 1)==0)
998 ha
->irq
= gdth_irq_tab
[i
];
1000 /* deinitialize services */
1001 gdth_writel(bios_adr
, &dp2_ptr
->u
.ic
.S_Info
[0]);
1002 gdth_writeb(0xff, &dp2_ptr
->u
.ic
.S_Cmd_Indx
);
1003 gdth_writeb(0, &dp2_ptr
->io
.event
);
1004 retries
= INIT_RETRIES
;
1006 while (gdth_readb(&dp2_ptr
->u
.ic
.S_Status
) != 0xff) {
1007 if (--retries
== 0) {
1008 printk("GDT-ISA: Initialization error (DEINIT failed)\n");
1014 prot_ver
= (unchar
)gdth_readl(&dp2_ptr
->u
.ic
.S_Info
[0]);
1015 gdth_writeb(0, &dp2_ptr
->u
.ic
.Status
);
1016 gdth_writeb(0xff, &dp2_ptr
->io
.irqdel
);
1017 if (prot_ver
!= PROTOCOL_VERSION
) {
1018 printk("GDT-ISA: Illegal protocol version\n");
1023 ha
->oem_id
= OEM_ID_ICP
;
1025 ha
->ic_all_size
= sizeof(dp2_ptr
->u
);
1027 ha
->brd_phys
= bios_adr
>> 4;
1029 /* special request to controller BIOS */
1030 gdth_writel(0x00, &dp2_ptr
->u
.ic
.S_Info
[0]);
1031 gdth_writel(0x00, &dp2_ptr
->u
.ic
.S_Info
[1]);
1032 gdth_writel(0x01, &dp2_ptr
->u
.ic
.S_Info
[2]);
1033 gdth_writel(0x00, &dp2_ptr
->u
.ic
.S_Info
[3]);
1034 gdth_writeb(0xfe, &dp2_ptr
->u
.ic
.S_Cmd_Indx
);
1035 gdth_writeb(0, &dp2_ptr
->io
.event
);
1036 retries
= INIT_RETRIES
;
1038 while (gdth_readb(&dp2_ptr
->u
.ic
.S_Status
) != 0xfe) {
1039 if (--retries
== 0) {
1040 printk("GDT-ISA: Initialization error\n");
1046 gdth_writeb(0, &dp2_ptr
->u
.ic
.Status
);
1047 gdth_writeb(0xff, &dp2_ptr
->io
.irqdel
);
1049 ha
->dma64_support
= 0;
1054 static int __init
gdth_init_pci(gdth_pci_str
*pcistr
,gdth_ha_str
*ha
)
1056 register gdt6_dpram_str __iomem
*dp6_ptr
;
1057 register gdt6c_dpram_str __iomem
*dp6c_ptr
;
1058 register gdt6m_dpram_str __iomem
*dp6m_ptr
;
1062 int i
, found
= FALSE
;
1064 TRACE(("gdth_init_pci()\n"));
1066 if (pcistr
->vendor_id
== PCI_VENDOR_ID_INTEL
)
1067 ha
->oem_id
= OEM_ID_INTEL
;
1069 ha
->oem_id
= OEM_ID_ICP
;
1070 ha
->brd_phys
= (pcistr
->bus
<< 8) | (pcistr
->device_fn
& 0xf8);
1071 ha
->stype
= (ulong32
)pcistr
->device_id
;
1072 ha
->subdevice_id
= pcistr
->subdevice_id
;
1073 ha
->irq
= pcistr
->irq
;
1074 ha
->pdev
= pcistr
->pdev
;
1076 if (ha
->stype
<= PCI_DEVICE_ID_VORTEX_GDT6000B
) { /* GDT6000/B */
1077 TRACE2(("init_pci() dpmem %lx irq %d\n",pcistr
->dpmem
,ha
->irq
));
1078 ha
->brd
= ioremap(pcistr
->dpmem
, sizeof(gdt6_dpram_str
));
1079 if (ha
->brd
== NULL
) {
1080 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1083 /* check and reset interface area */
1085 gdth_writel(DPMEM_MAGIC
, &dp6_ptr
->u
);
1086 if (gdth_readl(&dp6_ptr
->u
) != DPMEM_MAGIC
) {
1087 printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n",
1090 for (i
= 0xC8000; i
< 0xE8000; i
+= 0x4000) {
1092 ha
->brd
= ioremap(i
, sizeof(ushort
));
1093 if (ha
->brd
== NULL
) {
1094 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1097 if (gdth_readw(ha
->brd
) != 0xffff) {
1098 TRACE2(("init_pci_old() address 0x%x busy\n", i
));
1102 pci_write_config_dword(pcistr
->pdev
,
1103 PCI_BASE_ADDRESS_0
, i
);
1104 ha
->brd
= ioremap(i
, sizeof(gdt6_dpram_str
));
1105 if (ha
->brd
== NULL
) {
1106 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1110 gdth_writel(DPMEM_MAGIC
, &dp6_ptr
->u
);
1111 if (gdth_readl(&dp6_ptr
->u
) == DPMEM_MAGIC
) {
1112 printk("GDT-PCI: Use free address at 0x%x\n", i
);
1118 printk("GDT-PCI: No free address found!\n");
1123 memset_io(&dp6_ptr
->u
, 0, sizeof(dp6_ptr
->u
));
1124 if (gdth_readl(&dp6_ptr
->u
) != 0) {
1125 printk("GDT-PCI: Initialization error (DPMEM write error)\n");
1130 /* disable board interrupts, deinit services */
1131 gdth_writeb(0xff, &dp6_ptr
->io
.irqdel
);
1132 gdth_writeb(0x00, &dp6_ptr
->io
.irqen
);
1133 gdth_writeb(0x00, &dp6_ptr
->u
.ic
.S_Status
);
1134 gdth_writeb(0x00, &dp6_ptr
->u
.ic
.Cmd_Index
);
1136 gdth_writel(pcistr
->dpmem
, &dp6_ptr
->u
.ic
.S_Info
[0]);
1137 gdth_writeb(0xff, &dp6_ptr
->u
.ic
.S_Cmd_Indx
);
1138 gdth_writeb(0, &dp6_ptr
->io
.event
);
1139 retries
= INIT_RETRIES
;
1141 while (gdth_readb(&dp6_ptr
->u
.ic
.S_Status
) != 0xff) {
1142 if (--retries
== 0) {
1143 printk("GDT-PCI: Initialization error (DEINIT failed)\n");
1149 prot_ver
= (unchar
)gdth_readl(&dp6_ptr
->u
.ic
.S_Info
[0]);
1150 gdth_writeb(0, &dp6_ptr
->u
.ic
.S_Status
);
1151 gdth_writeb(0xff, &dp6_ptr
->io
.irqdel
);
1152 if (prot_ver
!= PROTOCOL_VERSION
) {
1153 printk("GDT-PCI: Illegal protocol version\n");
1159 ha
->ic_all_size
= sizeof(dp6_ptr
->u
);
1161 /* special command to controller BIOS */
1162 gdth_writel(0x00, &dp6_ptr
->u
.ic
.S_Info
[0]);
1163 gdth_writel(0x00, &dp6_ptr
->u
.ic
.S_Info
[1]);
1164 gdth_writel(0x00, &dp6_ptr
->u
.ic
.S_Info
[2]);
1165 gdth_writel(0x00, &dp6_ptr
->u
.ic
.S_Info
[3]);
1166 gdth_writeb(0xfe, &dp6_ptr
->u
.ic
.S_Cmd_Indx
);
1167 gdth_writeb(0, &dp6_ptr
->io
.event
);
1168 retries
= INIT_RETRIES
;
1170 while (gdth_readb(&dp6_ptr
->u
.ic
.S_Status
) != 0xfe) {
1171 if (--retries
== 0) {
1172 printk("GDT-PCI: Initialization error\n");
1178 gdth_writeb(0, &dp6_ptr
->u
.ic
.S_Status
);
1179 gdth_writeb(0xff, &dp6_ptr
->io
.irqdel
);
1181 ha
->dma64_support
= 0;
1183 } else if (ha
->stype
<= PCI_DEVICE_ID_VORTEX_GDT6555
) { /* GDT6110, ... */
1184 ha
->plx
= (gdt6c_plx_regs
*)pcistr
->io
;
1185 TRACE2(("init_pci_new() dpmem %lx irq %d\n",
1186 pcistr
->dpmem
,ha
->irq
));
1187 ha
->brd
= ioremap(pcistr
->dpmem
, sizeof(gdt6c_dpram_str
));
1188 if (ha
->brd
== NULL
) {
1189 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1193 /* check and reset interface area */
1195 gdth_writel(DPMEM_MAGIC
, &dp6c_ptr
->u
);
1196 if (gdth_readl(&dp6c_ptr
->u
) != DPMEM_MAGIC
) {
1197 printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n",
1200 for (i
= 0xC8000; i
< 0xE8000; i
+= 0x4000) {
1202 ha
->brd
= ioremap(i
, sizeof(ushort
));
1203 if (ha
->brd
== NULL
) {
1204 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1207 if (gdth_readw(ha
->brd
) != 0xffff) {
1208 TRACE2(("init_pci_plx() address 0x%x busy\n", i
));
1212 pci_write_config_dword(pcistr
->pdev
,
1213 PCI_BASE_ADDRESS_2
, i
);
1214 ha
->brd
= ioremap(i
, sizeof(gdt6c_dpram_str
));
1215 if (ha
->brd
== NULL
) {
1216 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1220 gdth_writel(DPMEM_MAGIC
, &dp6c_ptr
->u
);
1221 if (gdth_readl(&dp6c_ptr
->u
) == DPMEM_MAGIC
) {
1222 printk("GDT-PCI: Use free address at 0x%x\n", i
);
1228 printk("GDT-PCI: No free address found!\n");
1233 memset_io(&dp6c_ptr
->u
, 0, sizeof(dp6c_ptr
->u
));
1234 if (gdth_readl(&dp6c_ptr
->u
) != 0) {
1235 printk("GDT-PCI: Initialization error (DPMEM write error)\n");
1240 /* disable board interrupts, deinit services */
1241 outb(0x00,PTR2USHORT(&ha
->plx
->control1
));
1242 outb(0xff,PTR2USHORT(&ha
->plx
->edoor_reg
));
1244 gdth_writeb(0x00, &dp6c_ptr
->u
.ic
.S_Status
);
1245 gdth_writeb(0x00, &dp6c_ptr
->u
.ic
.Cmd_Index
);
1247 gdth_writel(pcistr
->dpmem
, &dp6c_ptr
->u
.ic
.S_Info
[0]);
1248 gdth_writeb(0xff, &dp6c_ptr
->u
.ic
.S_Cmd_Indx
);
1250 outb(1,PTR2USHORT(&ha
->plx
->ldoor_reg
));
1252 retries
= INIT_RETRIES
;
1254 while (gdth_readb(&dp6c_ptr
->u
.ic
.S_Status
) != 0xff) {
1255 if (--retries
== 0) {
1256 printk("GDT-PCI: Initialization error (DEINIT failed)\n");
1262 prot_ver
= (unchar
)gdth_readl(&dp6c_ptr
->u
.ic
.S_Info
[0]);
1263 gdth_writeb(0, &dp6c_ptr
->u
.ic
.Status
);
1264 if (prot_ver
!= PROTOCOL_VERSION
) {
1265 printk("GDT-PCI: Illegal protocol version\n");
1270 ha
->type
= GDT_PCINEW
;
1271 ha
->ic_all_size
= sizeof(dp6c_ptr
->u
);
1273 /* special command to controller BIOS */
1274 gdth_writel(0x00, &dp6c_ptr
->u
.ic
.S_Info
[0]);
1275 gdth_writel(0x00, &dp6c_ptr
->u
.ic
.S_Info
[1]);
1276 gdth_writel(0x00, &dp6c_ptr
->u
.ic
.S_Info
[2]);
1277 gdth_writel(0x00, &dp6c_ptr
->u
.ic
.S_Info
[3]);
1278 gdth_writeb(0xfe, &dp6c_ptr
->u
.ic
.S_Cmd_Indx
);
1280 outb(1,PTR2USHORT(&ha
->plx
->ldoor_reg
));
1282 retries
= INIT_RETRIES
;
1284 while (gdth_readb(&dp6c_ptr
->u
.ic
.S_Status
) != 0xfe) {
1285 if (--retries
== 0) {
1286 printk("GDT-PCI: Initialization error\n");
1292 gdth_writeb(0, &dp6c_ptr
->u
.ic
.S_Status
);
1294 ha
->dma64_support
= 0;
1297 TRACE2(("init_pci_mpr() dpmem %lx irq %d\n",pcistr
->dpmem
,ha
->irq
));
1298 ha
->brd
= ioremap(pcistr
->dpmem
, sizeof(gdt6m_dpram_str
));
1299 if (ha
->brd
== NULL
) {
1300 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1304 /* manipulate config. space to enable DPMEM, start RP controller */
1305 pci_read_config_word(pcistr
->pdev
, PCI_COMMAND
, &command
);
1307 pci_write_config_word(pcistr
->pdev
, PCI_COMMAND
, command
);
1308 if (pci_resource_start(pcistr
->pdev
, 8) == 1UL)
1309 pci_resource_start(pcistr
->pdev
, 8) = 0UL;
1311 pci_write_config_dword(pcistr
->pdev
, PCI_ROM_ADDRESS
, i
);
1313 pci_write_config_dword(pcistr
->pdev
, PCI_ROM_ADDRESS
,
1314 pci_resource_start(pcistr
->pdev
, 8));
1318 /* Ensure that it is safe to access the non HW portions of DPMEM.
1319 * Aditional check needed for Xscale based RAID controllers */
1320 while( ((int)gdth_readb(&dp6m_ptr
->i960r
.sema0_reg
) ) & 3 )
1323 /* check and reset interface area */
1324 gdth_writel(DPMEM_MAGIC
, &dp6m_ptr
->u
);
1325 if (gdth_readl(&dp6m_ptr
->u
) != DPMEM_MAGIC
) {
1326 printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n",
1329 for (i
= 0xC8000; i
< 0xE8000; i
+= 0x4000) {
1331 ha
->brd
= ioremap(i
, sizeof(ushort
));
1332 if (ha
->brd
== NULL
) {
1333 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1336 if (gdth_readw(ha
->brd
) != 0xffff) {
1337 TRACE2(("init_pci_mpr() address 0x%x busy\n", i
));
1341 pci_write_config_dword(pcistr
->pdev
,
1342 PCI_BASE_ADDRESS_0
, i
);
1343 ha
->brd
= ioremap(i
, sizeof(gdt6m_dpram_str
));
1344 if (ha
->brd
== NULL
) {
1345 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1349 gdth_writel(DPMEM_MAGIC
, &dp6m_ptr
->u
);
1350 if (gdth_readl(&dp6m_ptr
->u
) == DPMEM_MAGIC
) {
1351 printk("GDT-PCI: Use free address at 0x%x\n", i
);
1357 printk("GDT-PCI: No free address found!\n");
1362 memset_io(&dp6m_ptr
->u
, 0, sizeof(dp6m_ptr
->u
));
1364 /* disable board interrupts, deinit services */
1365 gdth_writeb(gdth_readb(&dp6m_ptr
->i960r
.edoor_en_reg
) | 4,
1366 &dp6m_ptr
->i960r
.edoor_en_reg
);
1367 gdth_writeb(0xff, &dp6m_ptr
->i960r
.edoor_reg
);
1368 gdth_writeb(0x00, &dp6m_ptr
->u
.ic
.S_Status
);
1369 gdth_writeb(0x00, &dp6m_ptr
->u
.ic
.Cmd_Index
);
1371 gdth_writel(pcistr
->dpmem
, &dp6m_ptr
->u
.ic
.S_Info
[0]);
1372 gdth_writeb(0xff, &dp6m_ptr
->u
.ic
.S_Cmd_Indx
);
1373 gdth_writeb(1, &dp6m_ptr
->i960r
.ldoor_reg
);
1374 retries
= INIT_RETRIES
;
1376 while (gdth_readb(&dp6m_ptr
->u
.ic
.S_Status
) != 0xff) {
1377 if (--retries
== 0) {
1378 printk("GDT-PCI: Initialization error (DEINIT failed)\n");
1384 prot_ver
= (unchar
)gdth_readl(&dp6m_ptr
->u
.ic
.S_Info
[0]);
1385 gdth_writeb(0, &dp6m_ptr
->u
.ic
.S_Status
);
1386 if (prot_ver
!= PROTOCOL_VERSION
) {
1387 printk("GDT-PCI: Illegal protocol version\n");
1392 ha
->type
= GDT_PCIMPR
;
1393 ha
->ic_all_size
= sizeof(dp6m_ptr
->u
);
1395 /* special command to controller BIOS */
1396 gdth_writel(0x00, &dp6m_ptr
->u
.ic
.S_Info
[0]);
1397 gdth_writel(0x00, &dp6m_ptr
->u
.ic
.S_Info
[1]);
1398 gdth_writel(0x00, &dp6m_ptr
->u
.ic
.S_Info
[2]);
1399 gdth_writel(0x00, &dp6m_ptr
->u
.ic
.S_Info
[3]);
1400 gdth_writeb(0xfe, &dp6m_ptr
->u
.ic
.S_Cmd_Indx
);
1401 gdth_writeb(1, &dp6m_ptr
->i960r
.ldoor_reg
);
1402 retries
= INIT_RETRIES
;
1404 while (gdth_readb(&dp6m_ptr
->u
.ic
.S_Status
) != 0xfe) {
1405 if (--retries
== 0) {
1406 printk("GDT-PCI: Initialization error\n");
1412 gdth_writeb(0, &dp6m_ptr
->u
.ic
.S_Status
);
1414 /* read FW version to detect 64-bit DMA support */
1415 gdth_writeb(0xfd, &dp6m_ptr
->u
.ic
.S_Cmd_Indx
);
1416 gdth_writeb(1, &dp6m_ptr
->i960r
.ldoor_reg
);
1417 retries
= INIT_RETRIES
;
1419 while (gdth_readb(&dp6m_ptr
->u
.ic
.S_Status
) != 0xfd) {
1420 if (--retries
== 0) {
1421 printk("GDT-PCI: Initialization error (DEINIT failed)\n");
1427 prot_ver
= (unchar
)(gdth_readl(&dp6m_ptr
->u
.ic
.S_Info
[0]) >> 16);
1428 gdth_writeb(0, &dp6m_ptr
->u
.ic
.S_Status
);
1429 if (prot_ver
< 0x2b) /* FW < x.43: no 64-bit DMA support */
1430 ha
->dma64_support
= 0;
1432 ha
->dma64_support
= 1;
1439 /* controller protocol functions */
1441 static void __init
gdth_enable_int(int hanum
)
1445 gdt2_dpram_str __iomem
*dp2_ptr
;
1446 gdt6_dpram_str __iomem
*dp6_ptr
;
1447 gdt6m_dpram_str __iomem
*dp6m_ptr
;
1449 TRACE(("gdth_enable_int() hanum %d\n",hanum
));
1450 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1451 spin_lock_irqsave(&ha
->smp_lock
, flags
);
1453 if (ha
->type
== GDT_EISA
) {
1454 outb(0xff, ha
->bmic
+ EDOORREG
);
1455 outb(0xff, ha
->bmic
+ EDENABREG
);
1456 outb(0x01, ha
->bmic
+ EINTENABREG
);
1457 } else if (ha
->type
== GDT_ISA
) {
1459 gdth_writeb(1, &dp2_ptr
->io
.irqdel
);
1460 gdth_writeb(0, &dp2_ptr
->u
.ic
.Cmd_Index
);
1461 gdth_writeb(1, &dp2_ptr
->io
.irqen
);
1462 } else if (ha
->type
== GDT_PCI
) {
1464 gdth_writeb(1, &dp6_ptr
->io
.irqdel
);
1465 gdth_writeb(0, &dp6_ptr
->u
.ic
.Cmd_Index
);
1466 gdth_writeb(1, &dp6_ptr
->io
.irqen
);
1467 } else if (ha
->type
== GDT_PCINEW
) {
1468 outb(0xff, PTR2USHORT(&ha
->plx
->edoor_reg
));
1469 outb(0x03, PTR2USHORT(&ha
->plx
->control1
));
1470 } else if (ha
->type
== GDT_PCIMPR
) {
1472 gdth_writeb(0xff, &dp6m_ptr
->i960r
.edoor_reg
);
1473 gdth_writeb(gdth_readb(&dp6m_ptr
->i960r
.edoor_en_reg
) & ~4,
1474 &dp6m_ptr
->i960r
.edoor_en_reg
);
1476 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
1480 static int gdth_get_status(unchar
*pIStatus
,int irq
)
1482 register gdth_ha_str
*ha
;
1485 TRACE(("gdth_get_status() irq %d ctr_count %d\n",
1486 irq
,gdth_ctr_count
));
1489 for (i
=0; i
<gdth_ctr_count
; ++i
) {
1490 ha
= HADATA(gdth_ctr_tab
[i
]);
1491 if (ha
->irq
!= (unchar
)irq
) /* check IRQ */
1493 if (ha
->type
== GDT_EISA
)
1494 *pIStatus
= inb((ushort
)ha
->bmic
+ EDOORREG
);
1495 else if (ha
->type
== GDT_ISA
)
1497 gdth_readb(&((gdt2_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Cmd_Index
);
1498 else if (ha
->type
== GDT_PCI
)
1500 gdth_readb(&((gdt6_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Cmd_Index
);
1501 else if (ha
->type
== GDT_PCINEW
)
1502 *pIStatus
= inb(PTR2USHORT(&ha
->plx
->edoor_reg
));
1503 else if (ha
->type
== GDT_PCIMPR
)
1505 gdth_readb(&((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.edoor_reg
);
1508 return i
; /* board found */
1514 static int gdth_test_busy(int hanum
)
1516 register gdth_ha_str
*ha
;
1517 register int gdtsema0
= 0;
1519 TRACE(("gdth_test_busy() hanum %d\n",hanum
));
1521 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1522 if (ha
->type
== GDT_EISA
)
1523 gdtsema0
= (int)inb(ha
->bmic
+ SEMA0REG
);
1524 else if (ha
->type
== GDT_ISA
)
1525 gdtsema0
= (int)gdth_readb(&((gdt2_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Sema0
);
1526 else if (ha
->type
== GDT_PCI
)
1527 gdtsema0
= (int)gdth_readb(&((gdt6_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Sema0
);
1528 else if (ha
->type
== GDT_PCINEW
)
1529 gdtsema0
= (int)inb(PTR2USHORT(&ha
->plx
->sema0_reg
));
1530 else if (ha
->type
== GDT_PCIMPR
)
1532 (int)gdth_readb(&((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.sema0_reg
);
1534 return (gdtsema0
& 1);
1538 static int gdth_get_cmd_index(int hanum
)
1540 register gdth_ha_str
*ha
;
1543 TRACE(("gdth_get_cmd_index() hanum %d\n",hanum
));
1545 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1546 for (i
=0; i
<GDTH_MAXCMDS
; ++i
) {
1547 if (ha
->cmd_tab
[i
].cmnd
== UNUSED_CMND
) {
1548 ha
->cmd_tab
[i
].cmnd
= ha
->pccb
->RequestBuffer
;
1549 ha
->cmd_tab
[i
].service
= ha
->pccb
->Service
;
1550 ha
->pccb
->CommandIndex
= (ulong32
)i
+2;
1558 static void gdth_set_sema0(int hanum
)
1560 register gdth_ha_str
*ha
;
1562 TRACE(("gdth_set_sema0() hanum %d\n",hanum
));
1564 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1565 if (ha
->type
== GDT_EISA
) {
1566 outb(1, ha
->bmic
+ SEMA0REG
);
1567 } else if (ha
->type
== GDT_ISA
) {
1568 gdth_writeb(1, &((gdt2_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Sema0
);
1569 } else if (ha
->type
== GDT_PCI
) {
1570 gdth_writeb(1, &((gdt6_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Sema0
);
1571 } else if (ha
->type
== GDT_PCINEW
) {
1572 outb(1, PTR2USHORT(&ha
->plx
->sema0_reg
));
1573 } else if (ha
->type
== GDT_PCIMPR
) {
1574 gdth_writeb(1, &((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.sema0_reg
);
1579 static void gdth_copy_command(int hanum
)
1581 register gdth_ha_str
*ha
;
1582 register gdth_cmd_str
*cmd_ptr
;
1583 register gdt6m_dpram_str __iomem
*dp6m_ptr
;
1584 register gdt6c_dpram_str __iomem
*dp6c_ptr
;
1585 gdt6_dpram_str __iomem
*dp6_ptr
;
1586 gdt2_dpram_str __iomem
*dp2_ptr
;
1587 ushort cp_count
,dp_offset
,cmd_no
;
1589 TRACE(("gdth_copy_command() hanum %d\n",hanum
));
1591 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1592 cp_count
= ha
->cmd_len
;
1593 dp_offset
= ha
->cmd_offs_dpmem
;
1594 cmd_no
= ha
->cmd_cnt
;
1598 if (ha
->type
== GDT_EISA
)
1599 return; /* no DPMEM, no copy */
1601 /* set cpcount dword aligned */
1603 cp_count
+= (4 - (cp_count
& 3));
1605 ha
->cmd_offs_dpmem
+= cp_count
;
1607 /* set offset and service, copy command to DPMEM */
1608 if (ha
->type
== GDT_ISA
) {
1610 gdth_writew(dp_offset
+ DPMEM_COMMAND_OFFSET
,
1611 &dp2_ptr
->u
.ic
.comm_queue
[cmd_no
].offset
);
1612 gdth_writew((ushort
)cmd_ptr
->Service
,
1613 &dp2_ptr
->u
.ic
.comm_queue
[cmd_no
].serv_id
);
1614 memcpy_toio(&dp2_ptr
->u
.ic
.gdt_dpr_cmd
[dp_offset
],cmd_ptr
,cp_count
);
1615 } else if (ha
->type
== GDT_PCI
) {
1617 gdth_writew(dp_offset
+ DPMEM_COMMAND_OFFSET
,
1618 &dp6_ptr
->u
.ic
.comm_queue
[cmd_no
].offset
);
1619 gdth_writew((ushort
)cmd_ptr
->Service
,
1620 &dp6_ptr
->u
.ic
.comm_queue
[cmd_no
].serv_id
);
1621 memcpy_toio(&dp6_ptr
->u
.ic
.gdt_dpr_cmd
[dp_offset
],cmd_ptr
,cp_count
);
1622 } else if (ha
->type
== GDT_PCINEW
) {
1624 gdth_writew(dp_offset
+ DPMEM_COMMAND_OFFSET
,
1625 &dp6c_ptr
->u
.ic
.comm_queue
[cmd_no
].offset
);
1626 gdth_writew((ushort
)cmd_ptr
->Service
,
1627 &dp6c_ptr
->u
.ic
.comm_queue
[cmd_no
].serv_id
);
1628 memcpy_toio(&dp6c_ptr
->u
.ic
.gdt_dpr_cmd
[dp_offset
],cmd_ptr
,cp_count
);
1629 } else if (ha
->type
== GDT_PCIMPR
) {
1631 gdth_writew(dp_offset
+ DPMEM_COMMAND_OFFSET
,
1632 &dp6m_ptr
->u
.ic
.comm_queue
[cmd_no
].offset
);
1633 gdth_writew((ushort
)cmd_ptr
->Service
,
1634 &dp6m_ptr
->u
.ic
.comm_queue
[cmd_no
].serv_id
);
1635 memcpy_toio(&dp6m_ptr
->u
.ic
.gdt_dpr_cmd
[dp_offset
],cmd_ptr
,cp_count
);
1640 static void gdth_release_event(int hanum
)
1642 register gdth_ha_str
*ha
;
1644 TRACE(("gdth_release_event() hanum %d\n",hanum
));
1645 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1647 #ifdef GDTH_STATISTICS
1650 for (i
=0,j
=0; j
<GDTH_MAXCMDS
; ++j
) {
1651 if (ha
->cmd_tab
[j
].cmnd
!= UNUSED_CMND
)
1654 if (max_index
< i
) {
1656 TRACE3(("GDT: max_index = %d\n",(ushort
)i
));
1661 if (ha
->pccb
->OpCode
== GDT_INIT
)
1662 ha
->pccb
->Service
|= 0x80;
1664 if (ha
->type
== GDT_EISA
) {
1665 if (ha
->pccb
->OpCode
== GDT_INIT
) /* store DMA buffer */
1666 outl(ha
->ccb_phys
, ha
->bmic
+ MAILBOXREG
);
1667 outb(ha
->pccb
->Service
, ha
->bmic
+ LDOORREG
);
1668 } else if (ha
->type
== GDT_ISA
) {
1669 gdth_writeb(0, &((gdt2_dpram_str __iomem
*)ha
->brd
)->io
.event
);
1670 } else if (ha
->type
== GDT_PCI
) {
1671 gdth_writeb(0, &((gdt6_dpram_str __iomem
*)ha
->brd
)->io
.event
);
1672 } else if (ha
->type
== GDT_PCINEW
) {
1673 outb(1, PTR2USHORT(&ha
->plx
->ldoor_reg
));
1674 } else if (ha
->type
== GDT_PCIMPR
) {
1675 gdth_writeb(1, &((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.ldoor_reg
);
1680 static int gdth_wait(int hanum
,int index
,ulong32 time
)
1683 int answer_found
= FALSE
;
1685 TRACE(("gdth_wait() hanum %d index %d time %d\n",hanum
,index
,time
));
1687 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1689 return 1; /* no wait required */
1691 gdth_from_wait
= TRUE
;
1693 gdth_interrupt((int)ha
->irq
,ha
,NULL
);
1694 if (wait_hanum
==hanum
&& wait_index
==index
) {
1695 answer_found
= TRUE
;
1700 gdth_from_wait
= FALSE
;
1702 while (gdth_test_busy(hanum
))
1705 return (answer_found
);
1709 static int gdth_internal_cmd(int hanum
,unchar service
,ushort opcode
,ulong32 p1
,
1710 ulong64 p2
,ulong64 p3
)
1712 register gdth_ha_str
*ha
;
1713 register gdth_cmd_str
*cmd_ptr
;
1716 TRACE2(("gdth_internal_cmd() service %d opcode %d\n",service
,opcode
));
1718 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1720 memset((char*)cmd_ptr
,0,sizeof(gdth_cmd_str
));
1723 for (retries
= INIT_RETRIES
;;) {
1724 cmd_ptr
->Service
= service
;
1725 cmd_ptr
->RequestBuffer
= INTERNAL_CMND
;
1726 if (!(index
=gdth_get_cmd_index(hanum
))) {
1727 TRACE(("GDT: No free command index found\n"));
1730 gdth_set_sema0(hanum
);
1731 cmd_ptr
->OpCode
= opcode
;
1732 cmd_ptr
->BoardNode
= LOCALBOARD
;
1733 if (service
== CACHESERVICE
) {
1734 if (opcode
== GDT_IOCTL
) {
1735 cmd_ptr
->u
.ioctl
.subfunc
= p1
;
1736 cmd_ptr
->u
.ioctl
.channel
= (ulong32
)p2
;
1737 cmd_ptr
->u
.ioctl
.param_size
= (ushort
)p3
;
1738 cmd_ptr
->u
.ioctl
.p_param
= ha
->scratch_phys
;
1740 if (ha
->cache_feat
& GDT_64BIT
) {
1741 cmd_ptr
->u
.cache64
.DeviceNo
= (ushort
)p1
;
1742 cmd_ptr
->u
.cache64
.BlockNo
= p2
;
1744 cmd_ptr
->u
.cache
.DeviceNo
= (ushort
)p1
;
1745 cmd_ptr
->u
.cache
.BlockNo
= (ulong32
)p2
;
1748 } else if (service
== SCSIRAWSERVICE
) {
1749 if (ha
->raw_feat
& GDT_64BIT
) {
1750 cmd_ptr
->u
.raw64
.direction
= p1
;
1751 cmd_ptr
->u
.raw64
.bus
= (unchar
)p2
;
1752 cmd_ptr
->u
.raw64
.target
= (unchar
)p3
;
1753 cmd_ptr
->u
.raw64
.lun
= (unchar
)(p3
>> 8);
1755 cmd_ptr
->u
.raw
.direction
= p1
;
1756 cmd_ptr
->u
.raw
.bus
= (unchar
)p2
;
1757 cmd_ptr
->u
.raw
.target
= (unchar
)p3
;
1758 cmd_ptr
->u
.raw
.lun
= (unchar
)(p3
>> 8);
1760 } else if (service
== SCREENSERVICE
) {
1761 if (opcode
== GDT_REALTIME
) {
1762 *(ulong32
*)&cmd_ptr
->u
.screen
.su
.data
[0] = p1
;
1763 *(ulong32
*)&cmd_ptr
->u
.screen
.su
.data
[4] = (ulong32
)p2
;
1764 *(ulong32
*)&cmd_ptr
->u
.screen
.su
.data
[8] = (ulong32
)p3
;
1767 ha
->cmd_len
= sizeof(gdth_cmd_str
);
1768 ha
->cmd_offs_dpmem
= 0;
1770 gdth_copy_command(hanum
);
1771 gdth_release_event(hanum
);
1773 if (!gdth_wait(hanum
,index
,INIT_TIMEOUT
)) {
1774 printk("GDT: Initialization error (timeout service %d)\n",service
);
1777 if (ha
->status
!= S_BSY
|| --retries
== 0)
1782 return (ha
->status
!= S_OK
? 0:1);
1786 /* search for devices */
1788 static int __init
gdth_search_drives(int hanum
)
1790 register gdth_ha_str
*ha
;
1793 ulong32 bus_no
, drv_cnt
, drv_no
, j
;
1794 gdth_getch_str
*chn
;
1795 gdth_drlist_str
*drl
;
1796 gdth_iochan_str
*ioc
;
1797 gdth_raw_iochan_str
*iocr
;
1798 gdth_arcdl_str
*alst
;
1799 gdth_alist_str
*alst2
;
1800 gdth_oem_str_ioctl
*oemstr
;
1802 gdth_perf_modes
*pmod
;
1810 TRACE(("gdth_search_drives() hanum %d\n",hanum
));
1811 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1814 /* initialize controller services, at first: screen service */
1815 ha
->screen_feat
= 0;
1817 ok
= gdth_internal_cmd(hanum
,SCREENSERVICE
,GDT_X_INIT_SCR
,0,0,0);
1819 ha
->screen_feat
= GDT_64BIT
;
1821 if (force_dma32
|| (!ok
&& ha
->status
== (ushort
)S_NOFUNC
))
1822 ok
= gdth_internal_cmd(hanum
,SCREENSERVICE
,GDT_INIT
,0,0,0);
1824 printk("GDT-HA %d: Initialization error screen service (code %d)\n",
1828 TRACE2(("gdth_search_drives(): SCREENSERVICE initialized\n"));
1831 /* read realtime clock info, send to controller */
1832 /* 1. wait for the falling edge of update flag */
1833 spin_lock_irqsave(&rtc_lock
, flags
);
1834 for (j
= 0; j
< 1000000; ++j
)
1835 if (CMOS_READ(RTC_FREQ_SELECT
) & RTC_UIP
)
1837 for (j
= 0; j
< 1000000; ++j
)
1838 if (!(CMOS_READ(RTC_FREQ_SELECT
) & RTC_UIP
))
1842 for (j
= 0; j
< 12; ++j
)
1843 rtc
[j
] = CMOS_READ(j
);
1844 } while (rtc
[0] != CMOS_READ(0));
1845 spin_lock_irqrestore(&rtc_lock
, flags
);
1846 TRACE2(("gdth_search_drives(): RTC: %x/%x/%x\n",*(ulong32
*)&rtc
[0],
1847 *(ulong32
*)&rtc
[4], *(ulong32
*)&rtc
[8]));
1848 /* 3. send to controller firmware */
1849 gdth_internal_cmd(hanum
,SCREENSERVICE
,GDT_REALTIME
, *(ulong32
*)&rtc
[0],
1850 *(ulong32
*)&rtc
[4], *(ulong32
*)&rtc
[8]);
1853 /* unfreeze all IOs */
1854 gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_UNFREEZE_IO
,0,0,0);
1856 /* initialize cache service */
1859 ok
= gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_X_INIT_HOST
,LINUX_OS
,0,0);
1861 ha
->cache_feat
= GDT_64BIT
;
1863 if (force_dma32
|| (!ok
&& ha
->status
== (ushort
)S_NOFUNC
))
1864 ok
= gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_INIT
,LINUX_OS
,0,0);
1866 printk("GDT-HA %d: Initialization error cache service (code %d)\n",
1870 TRACE2(("gdth_search_drives(): CACHESERVICE initialized\n"));
1871 cdev_cnt
= (ushort
)ha
->info
;
1872 ha
->fw_vers
= ha
->service
;
1875 if (ha
->type
== GDT_PCIMPR
) {
1876 /* set perf. modes */
1877 pmod
= (gdth_perf_modes
*)ha
->pscratch
;
1879 pmod
->st_mode
= 1; /* enable one status buffer */
1880 *((ulong64
*)&pmod
->st_buff_addr1
) = ha
->coal_stat_phys
;
1881 pmod
->st_buff_indx1
= COALINDEX
;
1882 pmod
->st_buff_addr2
= 0;
1883 pmod
->st_buff_u_addr2
= 0;
1884 pmod
->st_buff_indx2
= 0;
1885 pmod
->st_buff_size
= sizeof(gdth_coal_status
) * MAXOFFSETS
;
1886 pmod
->cmd_mode
= 0; // disable all cmd buffers
1887 pmod
->cmd_buff_addr1
= 0;
1888 pmod
->cmd_buff_u_addr1
= 0;
1889 pmod
->cmd_buff_indx1
= 0;
1890 pmod
->cmd_buff_addr2
= 0;
1891 pmod
->cmd_buff_u_addr2
= 0;
1892 pmod
->cmd_buff_indx2
= 0;
1893 pmod
->cmd_buff_size
= 0;
1894 pmod
->reserved1
= 0;
1895 pmod
->reserved2
= 0;
1896 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,SET_PERF_MODES
,
1897 INVALID_CHANNEL
,sizeof(gdth_perf_modes
))) {
1898 printk("GDT-HA %d: Interrupt coalescing activated\n", hanum
);
1903 /* detect number of buses - try new IOCTL */
1904 iocr
= (gdth_raw_iochan_str
*)ha
->pscratch
;
1905 iocr
->hdr
.version
= 0xffffffff;
1906 iocr
->hdr
.list_entries
= MAXBUS
;
1907 iocr
->hdr
.first_chan
= 0;
1908 iocr
->hdr
.last_chan
= MAXBUS
-1;
1909 iocr
->hdr
.list_offset
= GDTOFFSOF(gdth_raw_iochan_str
, list
[0]);
1910 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,IOCHAN_RAW_DESC
,
1911 INVALID_CHANNEL
,sizeof(gdth_raw_iochan_str
))) {
1912 TRACE2(("IOCHAN_RAW_DESC supported!\n"));
1913 ha
->bus_cnt
= iocr
->hdr
.chan_count
;
1914 for (bus_no
= 0; bus_no
< ha
->bus_cnt
; ++bus_no
) {
1915 if (iocr
->list
[bus_no
].proc_id
< MAXID
)
1916 ha
->bus_id
[bus_no
] = iocr
->list
[bus_no
].proc_id
;
1918 ha
->bus_id
[bus_no
] = 0xff;
1922 chn
= (gdth_getch_str
*)ha
->pscratch
;
1923 for (bus_no
= 0; bus_no
< MAXBUS
; ++bus_no
) {
1924 chn
->channel_no
= bus_no
;
1925 if (!gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,
1926 SCSI_CHAN_CNT
| L_CTRL_PATTERN
,
1927 IO_CHANNEL
| INVALID_CHANNEL
,
1928 sizeof(gdth_getch_str
))) {
1930 printk("GDT-HA %d: Error detecting channel count (0x%x)\n",
1936 if (chn
->siop_id
< MAXID
)
1937 ha
->bus_id
[bus_no
] = chn
->siop_id
;
1939 ha
->bus_id
[bus_no
] = 0xff;
1941 ha
->bus_cnt
= (unchar
)bus_no
;
1943 TRACE2(("gdth_search_drives() %d channels\n",ha
->bus_cnt
));
1945 /* read cache configuration */
1946 if (!gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,CACHE_INFO
,
1947 INVALID_CHANNEL
,sizeof(gdth_cinfo_str
))) {
1948 printk("GDT-HA %d: Initialization error cache service (code %d)\n",
1952 ha
->cpar
= ((gdth_cinfo_str
*)ha
->pscratch
)->cpar
;
1953 TRACE2(("gdth_search_drives() cinfo: vs %x sta %d str %d dw %d b %d\n",
1954 ha
->cpar
.version
,ha
->cpar
.state
,ha
->cpar
.strategy
,
1955 ha
->cpar
.write_back
,ha
->cpar
.block_size
));
1957 /* read board info and features */
1958 ha
->more_proc
= FALSE
;
1959 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,BOARD_INFO
,
1960 INVALID_CHANNEL
,sizeof(gdth_binfo_str
))) {
1961 memcpy(&ha
->binfo
, (gdth_binfo_str
*)ha
->pscratch
,
1962 sizeof(gdth_binfo_str
));
1963 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,BOARD_FEATURES
,
1964 INVALID_CHANNEL
,sizeof(gdth_bfeat_str
))) {
1965 TRACE2(("BOARD_INFO/BOARD_FEATURES supported\n"));
1966 ha
->bfeat
= *(gdth_bfeat_str
*)ha
->pscratch
;
1967 ha
->more_proc
= TRUE
;
1970 TRACE2(("BOARD_INFO requires firmware >= 1.10/2.08\n"));
1971 strcpy(ha
->binfo
.type_string
, gdth_ctr_name(hanum
));
1973 TRACE2(("Controller name: %s\n",ha
->binfo
.type_string
));
1975 /* read more informations */
1976 if (ha
->more_proc
) {
1977 /* physical drives, channel addresses */
1978 ioc
= (gdth_iochan_str
*)ha
->pscratch
;
1979 ioc
->hdr
.version
= 0xffffffff;
1980 ioc
->hdr
.list_entries
= MAXBUS
;
1981 ioc
->hdr
.first_chan
= 0;
1982 ioc
->hdr
.last_chan
= MAXBUS
-1;
1983 ioc
->hdr
.list_offset
= GDTOFFSOF(gdth_iochan_str
, list
[0]);
1984 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,IOCHAN_DESC
,
1985 INVALID_CHANNEL
,sizeof(gdth_iochan_str
))) {
1986 for (bus_no
= 0; bus_no
< ha
->bus_cnt
; ++bus_no
) {
1987 ha
->raw
[bus_no
].address
= ioc
->list
[bus_no
].address
;
1988 ha
->raw
[bus_no
].local_no
= ioc
->list
[bus_no
].local_no
;
1991 for (bus_no
= 0; bus_no
< ha
->bus_cnt
; ++bus_no
) {
1992 ha
->raw
[bus_no
].address
= IO_CHANNEL
;
1993 ha
->raw
[bus_no
].local_no
= bus_no
;
1996 for (bus_no
= 0; bus_no
< ha
->bus_cnt
; ++bus_no
) {
1997 chn
= (gdth_getch_str
*)ha
->pscratch
;
1998 chn
->channel_no
= ha
->raw
[bus_no
].local_no
;
1999 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,
2000 SCSI_CHAN_CNT
| L_CTRL_PATTERN
,
2001 ha
->raw
[bus_no
].address
| INVALID_CHANNEL
,
2002 sizeof(gdth_getch_str
))) {
2003 ha
->raw
[bus_no
].pdev_cnt
= chn
->drive_cnt
;
2004 TRACE2(("Channel %d: %d phys. drives\n",
2005 bus_no
,chn
->drive_cnt
));
2007 if (ha
->raw
[bus_no
].pdev_cnt
> 0) {
2008 drl
= (gdth_drlist_str
*)ha
->pscratch
;
2009 drl
->sc_no
= ha
->raw
[bus_no
].local_no
;
2010 drl
->sc_cnt
= ha
->raw
[bus_no
].pdev_cnt
;
2011 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,
2012 SCSI_DR_LIST
| L_CTRL_PATTERN
,
2013 ha
->raw
[bus_no
].address
| INVALID_CHANNEL
,
2014 sizeof(gdth_drlist_str
))) {
2015 for (j
= 0; j
< ha
->raw
[bus_no
].pdev_cnt
; ++j
)
2016 ha
->raw
[bus_no
].id_list
[j
] = drl
->sc_list
[j
];
2018 ha
->raw
[bus_no
].pdev_cnt
= 0;
2023 /* logical drives */
2024 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,CACHE_DRV_CNT
,
2025 INVALID_CHANNEL
,sizeof(ulong32
))) {
2026 drv_cnt
= *(ulong32
*)ha
->pscratch
;
2027 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,CACHE_DRV_LIST
,
2028 INVALID_CHANNEL
,drv_cnt
* sizeof(ulong32
))) {
2029 for (j
= 0; j
< drv_cnt
; ++j
) {
2030 drv_no
= ((ulong32
*)ha
->pscratch
)[j
];
2031 if (drv_no
< MAX_LDRIVES
) {
2032 ha
->hdr
[drv_no
].is_logdrv
= TRUE
;
2033 TRACE2(("Drive %d is log. drive\n",drv_no
));
2037 alst
= (gdth_arcdl_str
*)ha
->pscratch
;
2038 alst
->entries_avail
= MAX_LDRIVES
;
2039 alst
->first_entry
= 0;
2040 alst
->list_offset
= GDTOFFSOF(gdth_arcdl_str
, list
[0]);
2041 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,
2042 ARRAY_DRV_LIST2
| LA_CTRL_PATTERN
,
2043 INVALID_CHANNEL
, sizeof(gdth_arcdl_str
) +
2044 (alst
->entries_avail
-1) * sizeof(gdth_alist_str
))) {
2045 for (j
= 0; j
< alst
->entries_init
; ++j
) {
2046 ha
->hdr
[j
].is_arraydrv
= alst
->list
[j
].is_arrayd
;
2047 ha
->hdr
[j
].is_master
= alst
->list
[j
].is_master
;
2048 ha
->hdr
[j
].is_parity
= alst
->list
[j
].is_parity
;
2049 ha
->hdr
[j
].is_hotfix
= alst
->list
[j
].is_hotfix
;
2050 ha
->hdr
[j
].master_no
= alst
->list
[j
].cd_handle
;
2052 } else if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,
2053 ARRAY_DRV_LIST
| LA_CTRL_PATTERN
,
2054 0, 35 * sizeof(gdth_alist_str
))) {
2055 for (j
= 0; j
< 35; ++j
) {
2056 alst2
= &((gdth_alist_str
*)ha
->pscratch
)[j
];
2057 ha
->hdr
[j
].is_arraydrv
= alst2
->is_arrayd
;
2058 ha
->hdr
[j
].is_master
= alst2
->is_master
;
2059 ha
->hdr
[j
].is_parity
= alst2
->is_parity
;
2060 ha
->hdr
[j
].is_hotfix
= alst2
->is_hotfix
;
2061 ha
->hdr
[j
].master_no
= alst2
->cd_handle
;
2067 /* initialize raw service */
2070 ok
= gdth_internal_cmd(hanum
,SCSIRAWSERVICE
,GDT_X_INIT_RAW
,0,0,0);
2072 ha
->raw_feat
= GDT_64BIT
;
2074 if (force_dma32
|| (!ok
&& ha
->status
== (ushort
)S_NOFUNC
))
2075 ok
= gdth_internal_cmd(hanum
,SCSIRAWSERVICE
,GDT_INIT
,0,0,0);
2077 printk("GDT-HA %d: Initialization error raw service (code %d)\n",
2081 TRACE2(("gdth_search_drives(): RAWSERVICE initialized\n"));
2083 /* set/get features raw service (scatter/gather) */
2084 if (gdth_internal_cmd(hanum
,SCSIRAWSERVICE
,GDT_SET_FEAT
,SCATTER_GATHER
,
2086 TRACE2(("gdth_search_drives(): set features RAWSERVICE OK\n"));
2087 if (gdth_internal_cmd(hanum
,SCSIRAWSERVICE
,GDT_GET_FEAT
,0,0,0)) {
2088 TRACE2(("gdth_search_dr(): get feat RAWSERVICE %d\n",
2090 ha
->raw_feat
|= (ushort
)ha
->info
;
2094 /* set/get features cache service (equal to raw service) */
2095 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_SET_FEAT
,0,
2096 SCATTER_GATHER
,0)) {
2097 TRACE2(("gdth_search_drives(): set features CACHESERVICE OK\n"));
2098 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_GET_FEAT
,0,0,0)) {
2099 TRACE2(("gdth_search_dr(): get feat CACHESERV. %d\n",
2101 ha
->cache_feat
|= (ushort
)ha
->info
;
2105 /* reserve drives for raw service */
2106 if (reserve_mode
!= 0) {
2107 gdth_internal_cmd(hanum
,SCSIRAWSERVICE
,GDT_RESERVE_ALL
,
2108 reserve_mode
== 1 ? 1 : 3, 0, 0);
2109 TRACE2(("gdth_search_drives(): RESERVE_ALL code %d\n",
2112 for (i
= 0; i
< MAX_RES_ARGS
; i
+= 4) {
2113 if (reserve_list
[i
] == hanum
&& reserve_list
[i
+1] < ha
->bus_cnt
&&
2114 reserve_list
[i
+2] < ha
->tid_cnt
&& reserve_list
[i
+3] < MAXLUN
) {
2115 TRACE2(("gdth_search_drives(): reserve ha %d bus %d id %d lun %d\n",
2116 reserve_list
[i
], reserve_list
[i
+1],
2117 reserve_list
[i
+2], reserve_list
[i
+3]));
2118 if (!gdth_internal_cmd(hanum
,SCSIRAWSERVICE
,GDT_RESERVE
,0,
2119 reserve_list
[i
+1], reserve_list
[i
+2] |
2120 (reserve_list
[i
+3] << 8))) {
2121 printk("GDT-HA %d: Error raw service (RESERVE, code %d)\n",
2127 /* Determine OEM string using IOCTL */
2128 oemstr
= (gdth_oem_str_ioctl
*)ha
->pscratch
;
2129 oemstr
->params
.ctl_version
= 0x01;
2130 oemstr
->params
.buffer_size
= sizeof(oemstr
->text
);
2131 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,
2132 CACHE_READ_OEM_STRING_RECORD
,INVALID_CHANNEL
,
2133 sizeof(gdth_oem_str_ioctl
))) {
2134 TRACE2(("gdth_search_drives(): CACHE_READ_OEM_STRING_RECORD OK\n"));
2135 printk("GDT-HA %d: Vendor: %s Name: %s\n",
2136 hanum
,oemstr
->text
.oem_company_name
,ha
->binfo
.type_string
);
2137 /* Save the Host Drive inquiry data */
2138 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
2139 strlcpy(ha
->oem_name
,oemstr
->text
.scsi_host_drive_inquiry_vendor_id
,
2140 sizeof(ha
->oem_name
));
2142 strncpy(ha
->oem_name
,oemstr
->text
.scsi_host_drive_inquiry_vendor_id
,7);
2143 ha
->oem_name
[7] = '\0';
2146 /* Old method, based on PCI ID */
2147 TRACE2(("gdth_search_drives(): CACHE_READ_OEM_STRING_RECORD failed\n"));
2148 printk("GDT-HA %d: Name: %s\n",
2149 hanum
,ha
->binfo
.type_string
);
2150 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
2151 if (ha
->oem_id
== OEM_ID_INTEL
)
2152 strlcpy(ha
->oem_name
,"Intel ", sizeof(ha
->oem_name
));
2154 strlcpy(ha
->oem_name
,"ICP ", sizeof(ha
->oem_name
));
2156 if (ha
->oem_id
== OEM_ID_INTEL
)
2157 strcpy(ha
->oem_name
,"Intel ");
2159 strcpy(ha
->oem_name
,"ICP ");
2163 /* scanning for host drives */
2164 for (i
= 0; i
< cdev_cnt
; ++i
)
2165 gdth_analyse_hdrive(hanum
,i
);
2167 TRACE(("gdth_search_drives() OK\n"));
2171 static int gdth_analyse_hdrive(int hanum
,ushort hdrive
)
2173 register gdth_ha_str
*ha
;
2175 int drv_hds
, drv_secs
;
2177 TRACE(("gdth_analyse_hdrive() hanum %d drive %d\n",hanum
,hdrive
));
2178 if (hdrive
>= MAX_HDRIVES
)
2180 ha
= HADATA(gdth_ctr_tab
[hanum
]);
2182 if (!gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_INFO
,hdrive
,0,0))
2184 ha
->hdr
[hdrive
].present
= TRUE
;
2185 ha
->hdr
[hdrive
].size
= ha
->info
;
2187 /* evaluate mapping (sectors per head, heads per cylinder) */
2188 ha
->hdr
[hdrive
].size
&= ~SECS32
;
2189 if (ha
->info2
== 0) {
2190 gdth_eval_mapping(ha
->hdr
[hdrive
].size
,&drv_cyls
,&drv_hds
,&drv_secs
);
2192 drv_hds
= ha
->info2
& 0xff;
2193 drv_secs
= (ha
->info2
>> 8) & 0xff;
2194 drv_cyls
= (ulong32
)ha
->hdr
[hdrive
].size
/ drv_hds
/ drv_secs
;
2196 ha
->hdr
[hdrive
].heads
= (unchar
)drv_hds
;
2197 ha
->hdr
[hdrive
].secs
= (unchar
)drv_secs
;
2199 ha
->hdr
[hdrive
].size
= drv_cyls
* drv_hds
* drv_secs
;
2201 if (ha
->cache_feat
& GDT_64BIT
) {
2202 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_X_INFO
,hdrive
,0,0)
2203 && ha
->info2
!= 0) {
2204 ha
->hdr
[hdrive
].size
= ((ulong64
)ha
->info2
<< 32) | ha
->info
;
2207 TRACE2(("gdth_search_dr() cdr. %d size %d hds %d scs %d\n",
2208 hdrive
,ha
->hdr
[hdrive
].size
,drv_hds
,drv_secs
));
2210 /* get informations about device */
2211 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_DEVTYPE
,hdrive
,0,0)) {
2212 TRACE2(("gdth_search_dr() cache drive %d devtype %d\n",
2214 ha
->hdr
[hdrive
].devtype
= (ushort
)ha
->info
;
2218 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_CLUST_INFO
,hdrive
,0,0)) {
2219 TRACE2(("gdth_search_dr() cache drive %d cluster info %d\n",
2222 ha
->hdr
[hdrive
].cluster_type
= (unchar
)ha
->info
;
2225 /* R/W attributes */
2226 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_RW_ATTRIBS
,hdrive
,0,0)) {
2227 TRACE2(("gdth_search_dr() cache drive %d r/w attrib. %d\n",
2229 ha
->hdr
[hdrive
].rw_attribs
= (unchar
)ha
->info
;
2236 /* command queueing/sending functions */
2238 static void gdth_putq(int hanum
,Scsi_Cmnd
*scp
,unchar priority
)
2240 register gdth_ha_str
*ha
;
2241 register Scsi_Cmnd
*pscp
;
2242 register Scsi_Cmnd
*nscp
;
2246 TRACE(("gdth_putq() priority %d\n",priority
));
2247 ha
= HADATA(gdth_ctr_tab
[hanum
]);
2248 spin_lock_irqsave(&ha
->smp_lock
, flags
);
2250 scp
->SCp
.this_residual
= (int)priority
;
2251 b
= virt_ctr
? NUMDATA(scp
->device
->host
)->busnum
: scp
->device
->channel
;
2252 t
= scp
->device
->id
;
2253 if (priority
>= DEFAULT_PRI
) {
2254 if ((b
!= ha
->virt_bus
&& ha
->raw
[BUS_L2P(ha
,b
)].lock
) ||
2255 (b
== ha
->virt_bus
&& t
< MAX_HDRIVES
&& ha
->hdr
[t
].lock
)) {
2256 TRACE2(("gdth_putq(): locked IO -> update_timeout()\n"));
2257 scp
->SCp
.buffers_residual
= gdth_update_timeout(hanum
, scp
, 0);
2261 if (ha
->req_first
==NULL
) {
2262 ha
->req_first
= scp
; /* queue was empty */
2263 scp
->SCp
.ptr
= NULL
;
2264 } else { /* queue not empty */
2265 pscp
= ha
->req_first
;
2266 nscp
= (Scsi_Cmnd
*)pscp
->SCp
.ptr
;
2267 /* priority: 0-highest,..,0xff-lowest */
2268 while (nscp
&& (unchar
)nscp
->SCp
.this_residual
<= priority
) {
2270 nscp
= (Scsi_Cmnd
*)pscp
->SCp
.ptr
;
2272 pscp
->SCp
.ptr
= (char *)scp
;
2273 scp
->SCp
.ptr
= (char *)nscp
;
2275 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
2277 #ifdef GDTH_STATISTICS
2279 for (nscp
=ha
->req_first
; nscp
; nscp
=(Scsi_Cmnd
*)nscp
->SCp
.ptr
)
2281 if (max_rq
< flags
) {
2283 TRACE3(("GDT: max_rq = %d\n",(ushort
)max_rq
));
2288 static void gdth_next(int hanum
)
2290 register gdth_ha_str
*ha
;
2291 register Scsi_Cmnd
*pscp
;
2292 register Scsi_Cmnd
*nscp
;
2293 unchar b
, t
, l
, firsttime
;
2294 unchar this_cmd
, next_cmd
;
2298 TRACE(("gdth_next() hanum %d\n",hanum
));
2299 ha
= HADATA(gdth_ctr_tab
[hanum
]);
2301 spin_lock_irqsave(&ha
->smp_lock
, flags
);
2303 ha
->cmd_cnt
= ha
->cmd_offs_dpmem
= 0;
2304 this_cmd
= firsttime
= TRUE
;
2305 next_cmd
= gdth_polling
? FALSE
:TRUE
;
2308 for (nscp
= pscp
= ha
->req_first
; nscp
; nscp
= (Scsi_Cmnd
*)nscp
->SCp
.ptr
) {
2309 if (nscp
!= pscp
&& nscp
!= (Scsi_Cmnd
*)pscp
->SCp
.ptr
)
2310 pscp
= (Scsi_Cmnd
*)pscp
->SCp
.ptr
;
2311 b
= virt_ctr
? NUMDATA(nscp
->device
->host
)->busnum
: nscp
->device
->channel
;
2312 t
= nscp
->device
->id
;
2313 l
= nscp
->device
->lun
;
2314 if (nscp
->SCp
.this_residual
>= DEFAULT_PRI
) {
2315 if ((b
!= ha
->virt_bus
&& ha
->raw
[BUS_L2P(ha
,b
)].lock
) ||
2316 (b
== ha
->virt_bus
&& t
< MAX_HDRIVES
&& ha
->hdr
[t
].lock
))
2321 if (gdth_test_busy(hanum
)) { /* controller busy ? */
2322 TRACE(("gdth_next() controller %d busy !\n",hanum
));
2323 if (!gdth_polling
) {
2324 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
2327 while (gdth_test_busy(hanum
))
2333 if (nscp
->done
!= gdth_scsi_done
|| nscp
->cmnd
[0] != 0xff) {
2334 if (nscp
->SCp
.phase
== -1) {
2335 nscp
->SCp
.phase
= CACHESERVICE
; /* default: cache svc. */
2336 if (nscp
->cmnd
[0] == TEST_UNIT_READY
) {
2337 TRACE2(("TEST_UNIT_READY Bus %d Id %d LUN %d\n",
2339 /* TEST_UNIT_READY -> set scan mode */
2340 if ((ha
->scan_mode
& 0x0f) == 0) {
2341 if (b
== 0 && t
== 0 && l
== 0) {
2343 TRACE2(("Scan mode: 0x%x\n", ha
->scan_mode
));
2345 } else if ((ha
->scan_mode
& 0x0f) == 1) {
2346 if (b
== 0 && ((t
== 0 && l
== 1) ||
2347 (t
== 1 && l
== 0))) {
2348 nscp
->SCp
.sent_command
= GDT_SCAN_START
;
2349 nscp
->SCp
.phase
= ((ha
->scan_mode
& 0x10 ? 1:0) << 8)
2351 ha
->scan_mode
= 0x12;
2352 TRACE2(("Scan mode: 0x%x (SCAN_START)\n",
2355 ha
->scan_mode
&= 0x10;
2356 TRACE2(("Scan mode: 0x%x\n", ha
->scan_mode
));
2358 } else if (ha
->scan_mode
== 0x12) {
2359 if (b
== ha
->bus_cnt
&& t
== ha
->tid_cnt
-1) {
2360 nscp
->SCp
.phase
= SCSIRAWSERVICE
;
2361 nscp
->SCp
.sent_command
= GDT_SCAN_END
;
2362 ha
->scan_mode
&= 0x10;
2363 TRACE2(("Scan mode: 0x%x (SCAN_END)\n",
2368 if (b
== ha
->virt_bus
&& nscp
->cmnd
[0] != INQUIRY
&&
2369 nscp
->cmnd
[0] != READ_CAPACITY
&& nscp
->cmnd
[0] != MODE_SENSE
&&
2370 (ha
->hdr
[t
].cluster_type
& CLUSTER_DRIVE
)) {
2371 /* always GDT_CLUST_INFO! */
2372 nscp
->SCp
.sent_command
= GDT_CLUST_INFO
;
2377 if (nscp
->SCp
.sent_command
!= -1) {
2378 if ((nscp
->SCp
.phase
& 0xff) == CACHESERVICE
) {
2379 if (!(cmd_index
=gdth_fill_cache_cmd(hanum
,nscp
,t
)))
2382 } else if ((nscp
->SCp
.phase
& 0xff) == SCSIRAWSERVICE
) {
2383 if (!(cmd_index
=gdth_fill_raw_cmd(hanum
,nscp
,BUS_L2P(ha
,b
))))
2387 memset((char*)nscp
->sense_buffer
,0,16);
2388 nscp
->sense_buffer
[0] = 0x70;
2389 nscp
->sense_buffer
[2] = NOT_READY
;
2390 nscp
->result
= (DID_OK
<< 16) | (CHECK_CONDITION
<< 1);
2391 if (!nscp
->SCp
.have_data_in
)
2392 nscp
->SCp
.have_data_in
++;
2394 nscp
->scsi_done(nscp
);
2396 } else if (nscp
->done
== gdth_scsi_done
&& nscp
->cmnd
[0] == 0xff) {
2397 if (!(cmd_index
=gdth_special_cmd(hanum
,nscp
)))
2400 } else if (b
!= ha
->virt_bus
) {
2401 if (ha
->raw
[BUS_L2P(ha
,b
)].io_cnt
[t
] >= GDTH_MAX_RAW
||
2402 !(cmd_index
=gdth_fill_raw_cmd(hanum
,nscp
,BUS_L2P(ha
,b
))))
2405 ha
->raw
[BUS_L2P(ha
,b
)].io_cnt
[t
]++;
2406 } else if (t
>= MAX_HDRIVES
|| !ha
->hdr
[t
].present
|| l
!= 0) {
2407 TRACE2(("Command 0x%x to bus %d id %d lun %d -> IGNORE\n",
2408 nscp
->cmnd
[0], b
, t
, l
));
2409 nscp
->result
= DID_BAD_TARGET
<< 16;
2410 if (!nscp
->SCp
.have_data_in
)
2411 nscp
->SCp
.have_data_in
++;
2413 nscp
->scsi_done(nscp
);
2415 switch (nscp
->cmnd
[0]) {
2416 case TEST_UNIT_READY
:
2423 case SERVICE_ACTION_IN
:
2424 TRACE(("cache cmd %x/%x/%x/%x/%x/%x\n",nscp
->cmnd
[0],
2425 nscp
->cmnd
[1],nscp
->cmnd
[2],nscp
->cmnd
[3],
2426 nscp
->cmnd
[4],nscp
->cmnd
[5]));
2427 if (ha
->hdr
[t
].media_changed
&& nscp
->cmnd
[0] != INQUIRY
) {
2428 /* return UNIT_ATTENTION */
2429 TRACE2(("cmd 0x%x target %d: UNIT_ATTENTION\n",
2431 ha
->hdr
[t
].media_changed
= FALSE
;
2432 memset((char*)nscp
->sense_buffer
,0,16);
2433 nscp
->sense_buffer
[0] = 0x70;
2434 nscp
->sense_buffer
[2] = UNIT_ATTENTION
;
2435 nscp
->result
= (DID_OK
<< 16) | (CHECK_CONDITION
<< 1);
2436 if (!nscp
->SCp
.have_data_in
)
2437 nscp
->SCp
.have_data_in
++;
2439 nscp
->scsi_done(nscp
);
2440 } else if (gdth_internal_cache_cmd(hanum
,nscp
))
2441 nscp
->scsi_done(nscp
);
2444 case ALLOW_MEDIUM_REMOVAL
:
2445 TRACE(("cache cmd %x/%x/%x/%x/%x/%x\n",nscp
->cmnd
[0],
2446 nscp
->cmnd
[1],nscp
->cmnd
[2],nscp
->cmnd
[3],
2447 nscp
->cmnd
[4],nscp
->cmnd
[5]));
2448 if ( (nscp
->cmnd
[4]&1) && !(ha
->hdr
[t
].devtype
&1) ) {
2449 TRACE(("Prevent r. nonremov. drive->do nothing\n"));
2450 nscp
->result
= DID_OK
<< 16;
2451 nscp
->sense_buffer
[0] = 0;
2452 if (!nscp
->SCp
.have_data_in
)
2453 nscp
->SCp
.have_data_in
++;
2455 nscp
->scsi_done(nscp
);
2457 nscp
->cmnd
[3] = (ha
->hdr
[t
].devtype
&1) ? 1:0;
2458 TRACE(("Prevent/allow r. %d rem. drive %d\n",
2459 nscp
->cmnd
[4],nscp
->cmnd
[3]));
2460 if (!(cmd_index
=gdth_fill_cache_cmd(hanum
,nscp
,t
)))
2467 TRACE2(("cache cmd %s\n",nscp
->cmnd
[0] == RESERVE
?
2468 "RESERVE" : "RELEASE"));
2469 if (!(cmd_index
=gdth_fill_cache_cmd(hanum
,nscp
,t
)))
2479 if (ha
->hdr
[t
].media_changed
) {
2480 /* return UNIT_ATTENTION */
2481 TRACE2(("cmd 0x%x target %d: UNIT_ATTENTION\n",
2483 ha
->hdr
[t
].media_changed
= FALSE
;
2484 memset((char*)nscp
->sense_buffer
,0,16);
2485 nscp
->sense_buffer
[0] = 0x70;
2486 nscp
->sense_buffer
[2] = UNIT_ATTENTION
;
2487 nscp
->result
= (DID_OK
<< 16) | (CHECK_CONDITION
<< 1);
2488 if (!nscp
->SCp
.have_data_in
)
2489 nscp
->SCp
.have_data_in
++;
2491 nscp
->scsi_done(nscp
);
2492 } else if (!(cmd_index
=gdth_fill_cache_cmd(hanum
,nscp
,t
)))
2497 TRACE2(("cache cmd %x/%x/%x/%x/%x/%x unknown\n",nscp
->cmnd
[0],
2498 nscp
->cmnd
[1],nscp
->cmnd
[2],nscp
->cmnd
[3],
2499 nscp
->cmnd
[4],nscp
->cmnd
[5]));
2500 printk("GDT-HA %d: Unknown SCSI command 0x%x to cache service !\n",
2501 hanum
, nscp
->cmnd
[0]);
2502 nscp
->result
= DID_ABORT
<< 16;
2503 if (!nscp
->SCp
.have_data_in
)
2504 nscp
->SCp
.have_data_in
++;
2506 nscp
->scsi_done(nscp
);
2513 if (nscp
== ha
->req_first
)
2514 ha
->req_first
= pscp
= (Scsi_Cmnd
*)nscp
->SCp
.ptr
;
2516 pscp
->SCp
.ptr
= nscp
->SCp
.ptr
;
2521 if (ha
->cmd_cnt
> 0) {
2522 gdth_release_event(hanum
);
2526 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
2528 if (gdth_polling
&& ha
->cmd_cnt
> 0) {
2529 if (!gdth_wait(hanum
,cmd_index
,POLL_TIMEOUT
))
2530 printk("GDT-HA %d: Command %d timed out !\n",
2535 static void gdth_copy_internal_data(int hanum
,Scsi_Cmnd
*scp
,
2536 char *buffer
,ushort count
)
2540 struct scatterlist
*sl
;
2544 cpcount
= count
<=(ushort
)scp
->bufflen
? count
:(ushort
)scp
->bufflen
;
2545 ha
= HADATA(gdth_ctr_tab
[hanum
]);
2548 sl
= (struct scatterlist
*)scp
->request_buffer
;
2549 for (i
=0,cpsum
=0; i
<scp
->use_sg
; ++i
,++sl
) {
2550 unsigned long flags
;
2551 cpnow
= (ushort
)sl
->length
;
2552 TRACE(("copy_internal() now %d sum %d count %d %d\n",
2553 cpnow
,cpsum
,cpcount
,(ushort
)scp
->bufflen
));
2554 if (cpsum
+cpnow
> cpcount
)
2555 cpnow
= cpcount
- cpsum
;
2558 printk("GDT-HA %d: invalid sc/gt element in gdth_copy_internal_data()\n",
2562 local_irq_save(flags
);
2563 address
= kmap_atomic(sl
->page
, KM_BIO_SRC_IRQ
) + sl
->offset
;
2564 memcpy(address
,buffer
,cpnow
);
2565 flush_dcache_page(sl
->page
);
2566 kunmap_atomic(address
, KM_BIO_SRC_IRQ
);
2567 local_irq_restore(flags
);
2568 if (cpsum
== cpcount
)
2573 TRACE(("copy_internal() count %d\n",cpcount
));
2574 memcpy((char*)scp
->request_buffer
,buffer
,cpcount
);
2578 static int gdth_internal_cache_cmd(int hanum
,Scsi_Cmnd
*scp
)
2580 register gdth_ha_str
*ha
;
2583 gdth_rdcap_data rdc
;
2585 gdth_modep_data mpd
;
2587 ha
= HADATA(gdth_ctr_tab
[hanum
]);
2588 t
= scp
->device
->id
;
2589 TRACE(("gdth_internal_cache_cmd() cmd 0x%x hdrive %d\n",
2592 scp
->result
= DID_OK
<< 16;
2593 scp
->sense_buffer
[0] = 0;
2595 switch (scp
->cmnd
[0]) {
2596 case TEST_UNIT_READY
:
2599 TRACE2(("Test/Verify/Start hdrive %d\n",t
));
2603 TRACE2(("Inquiry hdrive %d devtype %d\n",
2604 t
,ha
->hdr
[t
].devtype
));
2605 inq
.type_qual
= (ha
->hdr
[t
].devtype
&4) ? TYPE_ROM
:TYPE_DISK
;
2606 /* you can here set all disks to removable, if you want to do
2607 a flush using the ALLOW_MEDIUM_REMOVAL command */
2608 inq
.modif_rmb
= 0x00;
2609 if ((ha
->hdr
[t
].devtype
& 1) ||
2610 (ha
->hdr
[t
].cluster_type
& CLUSTER_DRIVE
))
2611 inq
.modif_rmb
= 0x80;
2615 strcpy(inq
.vendor
,ha
->oem_name
);
2616 sprintf(inq
.product
,"Host Drive #%02d",t
);
2617 strcpy(inq
.revision
," ");
2618 gdth_copy_internal_data(hanum
,scp
,(char*)&inq
,sizeof(gdth_inq_data
));
2622 TRACE2(("Request sense hdrive %d\n",t
));
2623 sd
.errorcode
= 0x70;
2628 gdth_copy_internal_data(hanum
,scp
,(char*)&sd
,sizeof(gdth_sense_data
));
2632 TRACE2(("Mode sense hdrive %d\n",t
));
2633 memset((char*)&mpd
,0,sizeof(gdth_modep_data
));
2634 mpd
.hd
.data_length
= sizeof(gdth_modep_data
);
2635 mpd
.hd
.dev_par
= (ha
->hdr
[t
].devtype
&2) ? 0x80:0;
2636 mpd
.hd
.bd_length
= sizeof(mpd
.bd
);
2637 mpd
.bd
.block_length
[0] = (SECTOR_SIZE
& 0x00ff0000) >> 16;
2638 mpd
.bd
.block_length
[1] = (SECTOR_SIZE
& 0x0000ff00) >> 8;
2639 mpd
.bd
.block_length
[2] = (SECTOR_SIZE
& 0x000000ff);
2640 gdth_copy_internal_data(hanum
,scp
,(char*)&mpd
,sizeof(gdth_modep_data
));
2644 TRACE2(("Read capacity hdrive %d\n",t
));
2645 if (ha
->hdr
[t
].size
> (ulong64
)0xffffffff)
2646 rdc
.last_block_no
= 0xffffffff;
2648 rdc
.last_block_no
= cpu_to_be32(ha
->hdr
[t
].size
-1);
2649 rdc
.block_length
= cpu_to_be32(SECTOR_SIZE
);
2650 gdth_copy_internal_data(hanum
,scp
,(char*)&rdc
,sizeof(gdth_rdcap_data
));
2653 case SERVICE_ACTION_IN
:
2654 if ((scp
->cmnd
[1] & 0x1f) == SAI_READ_CAPACITY_16
&&
2655 (ha
->cache_feat
& GDT_64BIT
)) {
2656 gdth_rdcap16_data rdc16
;
2658 TRACE2(("Read capacity (16) hdrive %d\n",t
));
2659 rdc16
.last_block_no
= cpu_to_be64(ha
->hdr
[t
].size
-1);
2660 rdc16
.block_length
= cpu_to_be32(SECTOR_SIZE
);
2661 gdth_copy_internal_data(hanum
,scp
,(char*)&rdc16
,sizeof(gdth_rdcap16_data
));
2663 scp
->result
= DID_ABORT
<< 16;
2668 TRACE2(("Internal cache cmd 0x%x unknown\n",scp
->cmnd
[0]));
2672 if (!scp
->SCp
.have_data_in
)
2673 scp
->SCp
.have_data_in
++;
2680 static int gdth_fill_cache_cmd(int hanum
,Scsi_Cmnd
*scp
,ushort hdrive
)
2682 register gdth_ha_str
*ha
;
2683 register gdth_cmd_str
*cmdp
;
2684 struct scatterlist
*sl
;
2685 ulong32 cnt
, blockcnt
;
2686 ulong64 no
, blockno
;
2687 dma_addr_t phys_addr
;
2688 int i
, cmd_index
, read_write
, sgcnt
, mode64
;
2692 ha
= HADATA(gdth_ctr_tab
[hanum
]);
2694 TRACE(("gdth_fill_cache_cmd() cmd 0x%x cmdsize %d hdrive %d\n",
2695 scp
->cmnd
[0],scp
->cmd_len
,hdrive
));
2697 if (ha
->type
==GDT_EISA
&& ha
->cmd_cnt
>0)
2700 mode64
= (ha
->cache_feat
& GDT_64BIT
) ? TRUE
: FALSE
;
2701 /* test for READ_16, WRITE_16 if !mode64 ? ---
2702 not required, should not occur due to error return on
2705 cmdp
->Service
= CACHESERVICE
;
2706 cmdp
->RequestBuffer
= scp
;
2707 /* search free command index */
2708 if (!(cmd_index
=gdth_get_cmd_index(hanum
))) {
2709 TRACE(("GDT: No free command index found\n"));
2712 /* if it's the first command, set command semaphore */
2713 if (ha
->cmd_cnt
== 0)
2714 gdth_set_sema0(hanum
);
2718 if (scp
->SCp
.sent_command
!= -1)
2719 cmdp
->OpCode
= scp
->SCp
.sent_command
; /* special cache cmd. */
2720 else if (scp
->cmnd
[0] == RESERVE
)
2721 cmdp
->OpCode
= GDT_RESERVE_DRV
;
2722 else if (scp
->cmnd
[0] == RELEASE
)
2723 cmdp
->OpCode
= GDT_RELEASE_DRV
;
2724 else if (scp
->cmnd
[0] == ALLOW_MEDIUM_REMOVAL
) {
2725 if (scp
->cmnd
[4] & 1) /* prevent ? */
2726 cmdp
->OpCode
= GDT_MOUNT
;
2727 else if (scp
->cmnd
[3] & 1) /* removable drive ? */
2728 cmdp
->OpCode
= GDT_UNMOUNT
;
2730 cmdp
->OpCode
= GDT_FLUSH
;
2731 } else if (scp
->cmnd
[0] == WRITE_6
|| scp
->cmnd
[0] == WRITE_10
||
2732 scp
->cmnd
[0] == WRITE_12
|| scp
->cmnd
[0] == WRITE_16
2735 if (gdth_write_through
|| ((ha
->hdr
[hdrive
].rw_attribs
& 1) &&
2736 (ha
->cache_feat
& GDT_WR_THROUGH
)))
2737 cmdp
->OpCode
= GDT_WRITE_THR
;
2739 cmdp
->OpCode
= GDT_WRITE
;
2742 cmdp
->OpCode
= GDT_READ
;
2745 cmdp
->BoardNode
= LOCALBOARD
;
2747 cmdp
->u
.cache64
.DeviceNo
= hdrive
;
2748 cmdp
->u
.cache64
.BlockNo
= 1;
2749 cmdp
->u
.cache64
.sg_canz
= 0;
2751 cmdp
->u
.cache
.DeviceNo
= hdrive
;
2752 cmdp
->u
.cache
.BlockNo
= 1;
2753 cmdp
->u
.cache
.sg_canz
= 0;
2757 if (scp
->cmd_len
== 16) {
2758 memcpy(&no
, &scp
->cmnd
[2], sizeof(ulong64
));
2759 blockno
= be64_to_cpu(no
);
2760 memcpy(&cnt
, &scp
->cmnd
[10], sizeof(ulong32
));
2761 blockcnt
= be32_to_cpu(cnt
);
2762 } else if (scp
->cmd_len
== 10) {
2763 memcpy(&no
, &scp
->cmnd
[2], sizeof(ulong32
));
2764 blockno
= be32_to_cpu(no
);
2765 memcpy(&cnt
, &scp
->cmnd
[7], sizeof(ushort
));
2766 blockcnt
= be16_to_cpu(cnt
);
2768 memcpy(&no
, &scp
->cmnd
[0], sizeof(ulong32
));
2769 blockno
= be32_to_cpu(no
) & 0x001fffffUL
;
2770 blockcnt
= scp
->cmnd
[4]==0 ? 0x100 : scp
->cmnd
[4];
2773 cmdp
->u
.cache64
.BlockNo
= blockno
;
2774 cmdp
->u
.cache64
.BlockCnt
= blockcnt
;
2776 cmdp
->u
.cache
.BlockNo
= (ulong32
)blockno
;
2777 cmdp
->u
.cache
.BlockCnt
= blockcnt
;
2781 sl
= (struct scatterlist
*)scp
->request_buffer
;
2782 sgcnt
= scp
->use_sg
;
2783 scp
->SCp
.Status
= GDTH_MAP_SG
;
2784 scp
->SCp
.Message
= (read_write
== 1 ?
2785 PCI_DMA_TODEVICE
: PCI_DMA_FROMDEVICE
);
2786 sgcnt
= pci_map_sg(ha
->pdev
,sl
,scp
->use_sg
,scp
->SCp
.Message
);
2788 cmdp
->u
.cache64
.DestAddr
= (ulong64
)-1;
2789 cmdp
->u
.cache64
.sg_canz
= sgcnt
;
2790 for (i
=0; i
<sgcnt
; ++i
,++sl
) {
2791 cmdp
->u
.cache64
.sg_lst
[i
].sg_ptr
= sg_dma_address(sl
);
2792 #ifdef GDTH_DMA_STATISTICS
2793 if (cmdp
->u
.cache64
.sg_lst
[i
].sg_ptr
> (ulong64
)0xffffffff)
2798 cmdp
->u
.cache64
.sg_lst
[i
].sg_len
= sg_dma_len(sl
);
2801 cmdp
->u
.cache
.DestAddr
= 0xffffffff;
2802 cmdp
->u
.cache
.sg_canz
= sgcnt
;
2803 for (i
=0; i
<sgcnt
; ++i
,++sl
) {
2804 cmdp
->u
.cache
.sg_lst
[i
].sg_ptr
= sg_dma_address(sl
);
2805 #ifdef GDTH_DMA_STATISTICS
2808 cmdp
->u
.cache
.sg_lst
[i
].sg_len
= sg_dma_len(sl
);
2812 #ifdef GDTH_STATISTICS
2813 if (max_sg
< (ulong32
)sgcnt
) {
2814 max_sg
= (ulong32
)sgcnt
;
2815 TRACE3(("GDT: max_sg = %d\n",max_sg
));
2820 scp
->SCp
.Status
= GDTH_MAP_SINGLE
;
2821 scp
->SCp
.Message
= (read_write
== 1 ?
2822 PCI_DMA_TODEVICE
: PCI_DMA_FROMDEVICE
);
2823 page
= virt_to_page(scp
->request_buffer
);
2824 offset
= (ulong
)scp
->request_buffer
& ~PAGE_MASK
;
2825 phys_addr
= pci_map_page(ha
->pdev
,page
,offset
,
2826 scp
->request_bufflen
,scp
->SCp
.Message
);
2827 scp
->SCp
.dma_handle
= phys_addr
;
2829 if (ha
->cache_feat
& SCATTER_GATHER
) {
2830 cmdp
->u
.cache64
.DestAddr
= (ulong64
)-1;
2831 cmdp
->u
.cache64
.sg_canz
= 1;
2832 cmdp
->u
.cache64
.sg_lst
[0].sg_ptr
= phys_addr
;
2833 cmdp
->u
.cache64
.sg_lst
[0].sg_len
= scp
->request_bufflen
;
2834 cmdp
->u
.cache64
.sg_lst
[1].sg_len
= 0;
2836 cmdp
->u
.cache64
.DestAddr
= phys_addr
;
2837 cmdp
->u
.cache64
.sg_canz
= 0;
2840 if (ha
->cache_feat
& SCATTER_GATHER
) {
2841 cmdp
->u
.cache
.DestAddr
= 0xffffffff;
2842 cmdp
->u
.cache
.sg_canz
= 1;
2843 cmdp
->u
.cache
.sg_lst
[0].sg_ptr
= phys_addr
;
2844 cmdp
->u
.cache
.sg_lst
[0].sg_len
= scp
->request_bufflen
;
2845 cmdp
->u
.cache
.sg_lst
[1].sg_len
= 0;
2847 cmdp
->u
.cache
.DestAddr
= phys_addr
;
2848 cmdp
->u
.cache
.sg_canz
= 0;
2853 /* evaluate command size, check space */
2855 TRACE(("cache cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n",
2856 cmdp
->u
.cache64
.DestAddr
,cmdp
->u
.cache64
.sg_canz
,
2857 cmdp
->u
.cache64
.sg_lst
[0].sg_ptr
,
2858 cmdp
->u
.cache64
.sg_lst
[0].sg_len
));
2859 TRACE(("cache cmd: cmd %d blockno. %d, blockcnt %d\n",
2860 cmdp
->OpCode
,cmdp
->u
.cache64
.BlockNo
,cmdp
->u
.cache64
.BlockCnt
));
2861 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.cache64
.sg_lst
) +
2862 (ushort
)cmdp
->u
.cache64
.sg_canz
* sizeof(gdth_sg64_str
);
2864 TRACE(("cache cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n",
2865 cmdp
->u
.cache
.DestAddr
,cmdp
->u
.cache
.sg_canz
,
2866 cmdp
->u
.cache
.sg_lst
[0].sg_ptr
,
2867 cmdp
->u
.cache
.sg_lst
[0].sg_len
));
2868 TRACE(("cache cmd: cmd %d blockno. %d, blockcnt %d\n",
2869 cmdp
->OpCode
,cmdp
->u
.cache
.BlockNo
,cmdp
->u
.cache
.BlockCnt
));
2870 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.cache
.sg_lst
) +
2871 (ushort
)cmdp
->u
.cache
.sg_canz
* sizeof(gdth_sg_str
);
2873 if (ha
->cmd_len
& 3)
2874 ha
->cmd_len
+= (4 - (ha
->cmd_len
& 3));
2876 if (ha
->cmd_cnt
> 0) {
2877 if ((ha
->cmd_offs_dpmem
+ ha
->cmd_len
+ DPMEM_COMMAND_OFFSET
) >
2879 TRACE2(("gdth_fill_cache() DPMEM overflow\n"));
2880 ha
->cmd_tab
[cmd_index
-2].cmnd
= UNUSED_CMND
;
2886 gdth_copy_command(hanum
);
2890 static int gdth_fill_raw_cmd(int hanum
,Scsi_Cmnd
*scp
,unchar b
)
2892 register gdth_ha_str
*ha
;
2893 register gdth_cmd_str
*cmdp
;
2894 struct scatterlist
*sl
;
2896 dma_addr_t phys_addr
, sense_paddr
;
2897 int cmd_index
, sgcnt
, mode64
;
2902 ha
= HADATA(gdth_ctr_tab
[hanum
]);
2903 t
= scp
->device
->id
;
2904 l
= scp
->device
->lun
;
2906 TRACE(("gdth_fill_raw_cmd() cmd 0x%x bus %d ID %d LUN %d\n",
2907 scp
->cmnd
[0],b
,t
,l
));
2909 if (ha
->type
==GDT_EISA
&& ha
->cmd_cnt
>0)
2912 mode64
= (ha
->raw_feat
& GDT_64BIT
) ? TRUE
: FALSE
;
2914 cmdp
->Service
= SCSIRAWSERVICE
;
2915 cmdp
->RequestBuffer
= scp
;
2916 /* search free command index */
2917 if (!(cmd_index
=gdth_get_cmd_index(hanum
))) {
2918 TRACE(("GDT: No free command index found\n"));
2921 /* if it's the first command, set command semaphore */
2922 if (ha
->cmd_cnt
== 0)
2923 gdth_set_sema0(hanum
);
2926 if (scp
->SCp
.sent_command
!= -1) {
2927 cmdp
->OpCode
= scp
->SCp
.sent_command
; /* special raw cmd. */
2928 cmdp
->BoardNode
= LOCALBOARD
;
2930 cmdp
->u
.raw64
.direction
= (scp
->SCp
.phase
>> 8);
2931 TRACE2(("special raw cmd 0x%x param 0x%x\n",
2932 cmdp
->OpCode
, cmdp
->u
.raw64
.direction
));
2933 /* evaluate command size */
2934 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.raw64
.sg_lst
);
2936 cmdp
->u
.raw
.direction
= (scp
->SCp
.phase
>> 8);
2937 TRACE2(("special raw cmd 0x%x param 0x%x\n",
2938 cmdp
->OpCode
, cmdp
->u
.raw
.direction
));
2939 /* evaluate command size */
2940 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.raw
.sg_lst
);
2944 page
= virt_to_page(scp
->sense_buffer
);
2945 offset
= (ulong
)scp
->sense_buffer
& ~PAGE_MASK
;
2946 sense_paddr
= pci_map_page(ha
->pdev
,page
,offset
,
2947 16,PCI_DMA_FROMDEVICE
);
2948 scp
->SCp
.buffer
= (struct scatterlist
*)((ulong32
)sense_paddr
);
2949 /* high part, if 64bit */
2950 scp
->host_scribble
= (char *)(ulong32
)((ulong64
)sense_paddr
>> 32);
2951 cmdp
->OpCode
= GDT_WRITE
; /* always */
2952 cmdp
->BoardNode
= LOCALBOARD
;
2954 cmdp
->u
.raw64
.reserved
= 0;
2955 cmdp
->u
.raw64
.mdisc_time
= 0;
2956 cmdp
->u
.raw64
.mcon_time
= 0;
2957 cmdp
->u
.raw64
.clen
= scp
->cmd_len
;
2958 cmdp
->u
.raw64
.target
= t
;
2959 cmdp
->u
.raw64
.lun
= l
;
2960 cmdp
->u
.raw64
.bus
= b
;
2961 cmdp
->u
.raw64
.priority
= 0;
2962 cmdp
->u
.raw64
.sdlen
= scp
->request_bufflen
;
2963 cmdp
->u
.raw64
.sense_len
= 16;
2964 cmdp
->u
.raw64
.sense_data
= sense_paddr
;
2965 cmdp
->u
.raw64
.direction
=
2966 gdth_direction_tab
[scp
->cmnd
[0]]==DOU
? GDTH_DATA_OUT
:GDTH_DATA_IN
;
2967 memcpy(cmdp
->u
.raw64
.cmd
,scp
->cmnd
,16);
2969 cmdp
->u
.raw
.reserved
= 0;
2970 cmdp
->u
.raw
.mdisc_time
= 0;
2971 cmdp
->u
.raw
.mcon_time
= 0;
2972 cmdp
->u
.raw
.clen
= scp
->cmd_len
;
2973 cmdp
->u
.raw
.target
= t
;
2974 cmdp
->u
.raw
.lun
= l
;
2975 cmdp
->u
.raw
.bus
= b
;
2976 cmdp
->u
.raw
.priority
= 0;
2977 cmdp
->u
.raw
.link_p
= 0;
2978 cmdp
->u
.raw
.sdlen
= scp
->request_bufflen
;
2979 cmdp
->u
.raw
.sense_len
= 16;
2980 cmdp
->u
.raw
.sense_data
= sense_paddr
;
2981 cmdp
->u
.raw
.direction
=
2982 gdth_direction_tab
[scp
->cmnd
[0]]==DOU
? GDTH_DATA_OUT
:GDTH_DATA_IN
;
2983 memcpy(cmdp
->u
.raw
.cmd
,scp
->cmnd
,12);
2987 sl
= (struct scatterlist
*)scp
->request_buffer
;
2988 sgcnt
= scp
->use_sg
;
2989 scp
->SCp
.Status
= GDTH_MAP_SG
;
2990 scp
->SCp
.Message
= PCI_DMA_BIDIRECTIONAL
;
2991 sgcnt
= pci_map_sg(ha
->pdev
,sl
,scp
->use_sg
,scp
->SCp
.Message
);
2993 cmdp
->u
.raw64
.sdata
= (ulong64
)-1;
2994 cmdp
->u
.raw64
.sg_ranz
= sgcnt
;
2995 for (i
=0; i
<sgcnt
; ++i
,++sl
) {
2996 cmdp
->u
.raw64
.sg_lst
[i
].sg_ptr
= sg_dma_address(sl
);
2997 #ifdef GDTH_DMA_STATISTICS
2998 if (cmdp
->u
.raw64
.sg_lst
[i
].sg_ptr
> (ulong64
)0xffffffff)
3003 cmdp
->u
.raw64
.sg_lst
[i
].sg_len
= sg_dma_len(sl
);
3006 cmdp
->u
.raw
.sdata
= 0xffffffff;
3007 cmdp
->u
.raw
.sg_ranz
= sgcnt
;
3008 for (i
=0; i
<sgcnt
; ++i
,++sl
) {
3009 cmdp
->u
.raw
.sg_lst
[i
].sg_ptr
= sg_dma_address(sl
);
3010 #ifdef GDTH_DMA_STATISTICS
3013 cmdp
->u
.raw
.sg_lst
[i
].sg_len
= sg_dma_len(sl
);
3017 #ifdef GDTH_STATISTICS
3018 if (max_sg
< sgcnt
) {
3020 TRACE3(("GDT: max_sg = %d\n",sgcnt
));
3025 scp
->SCp
.Status
= GDTH_MAP_SINGLE
;
3026 scp
->SCp
.Message
= PCI_DMA_BIDIRECTIONAL
;
3027 page
= virt_to_page(scp
->request_buffer
);
3028 offset
= (ulong
)scp
->request_buffer
& ~PAGE_MASK
;
3029 phys_addr
= pci_map_page(ha
->pdev
,page
,offset
,
3030 scp
->request_bufflen
,scp
->SCp
.Message
);
3031 scp
->SCp
.dma_handle
= phys_addr
;
3034 if (ha
->raw_feat
& SCATTER_GATHER
) {
3035 cmdp
->u
.raw64
.sdata
= (ulong64
)-1;
3036 cmdp
->u
.raw64
.sg_ranz
= 1;
3037 cmdp
->u
.raw64
.sg_lst
[0].sg_ptr
= phys_addr
;
3038 cmdp
->u
.raw64
.sg_lst
[0].sg_len
= scp
->request_bufflen
;
3039 cmdp
->u
.raw64
.sg_lst
[1].sg_len
= 0;
3041 cmdp
->u
.raw64
.sdata
= phys_addr
;
3042 cmdp
->u
.raw64
.sg_ranz
= 0;
3045 if (ha
->raw_feat
& SCATTER_GATHER
) {
3046 cmdp
->u
.raw
.sdata
= 0xffffffff;
3047 cmdp
->u
.raw
.sg_ranz
= 1;
3048 cmdp
->u
.raw
.sg_lst
[0].sg_ptr
= phys_addr
;
3049 cmdp
->u
.raw
.sg_lst
[0].sg_len
= scp
->request_bufflen
;
3050 cmdp
->u
.raw
.sg_lst
[1].sg_len
= 0;
3052 cmdp
->u
.raw
.sdata
= phys_addr
;
3053 cmdp
->u
.raw
.sg_ranz
= 0;
3058 TRACE(("raw cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n",
3059 cmdp
->u
.raw64
.sdata
,cmdp
->u
.raw64
.sg_ranz
,
3060 cmdp
->u
.raw64
.sg_lst
[0].sg_ptr
,
3061 cmdp
->u
.raw64
.sg_lst
[0].sg_len
));
3062 /* evaluate command size */
3063 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.raw64
.sg_lst
) +
3064 (ushort
)cmdp
->u
.raw64
.sg_ranz
* sizeof(gdth_sg64_str
);
3066 TRACE(("raw cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n",
3067 cmdp
->u
.raw
.sdata
,cmdp
->u
.raw
.sg_ranz
,
3068 cmdp
->u
.raw
.sg_lst
[0].sg_ptr
,
3069 cmdp
->u
.raw
.sg_lst
[0].sg_len
));
3070 /* evaluate command size */
3071 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.raw
.sg_lst
) +
3072 (ushort
)cmdp
->u
.raw
.sg_ranz
* sizeof(gdth_sg_str
);
3076 if (ha
->cmd_len
& 3)
3077 ha
->cmd_len
+= (4 - (ha
->cmd_len
& 3));
3079 if (ha
->cmd_cnt
> 0) {
3080 if ((ha
->cmd_offs_dpmem
+ ha
->cmd_len
+ DPMEM_COMMAND_OFFSET
) >
3082 TRACE2(("gdth_fill_raw() DPMEM overflow\n"));
3083 ha
->cmd_tab
[cmd_index
-2].cmnd
= UNUSED_CMND
;
3089 gdth_copy_command(hanum
);
3093 static int gdth_special_cmd(int hanum
,Scsi_Cmnd
*scp
)
3095 register gdth_ha_str
*ha
;
3096 register gdth_cmd_str
*cmdp
;
3099 ha
= HADATA(gdth_ctr_tab
[hanum
]);
3101 TRACE2(("gdth_special_cmd(): "));
3103 if (ha
->type
==GDT_EISA
&& ha
->cmd_cnt
>0)
3106 memcpy( cmdp
, scp
->request_buffer
, sizeof(gdth_cmd_str
));
3107 cmdp
->RequestBuffer
= scp
;
3109 /* search free command index */
3110 if (!(cmd_index
=gdth_get_cmd_index(hanum
))) {
3111 TRACE(("GDT: No free command index found\n"));
3115 /* if it's the first command, set command semaphore */
3116 if (ha
->cmd_cnt
== 0)
3117 gdth_set_sema0(hanum
);
3119 /* evaluate command size, check space */
3120 if (cmdp
->OpCode
== GDT_IOCTL
) {
3121 TRACE2(("IOCTL\n"));
3123 GDTOFFSOF(gdth_cmd_str
,u
.ioctl
.p_param
) + sizeof(ulong64
);
3124 } else if (cmdp
->Service
== CACHESERVICE
) {
3125 TRACE2(("cache command %d\n",cmdp
->OpCode
));
3126 if (ha
->cache_feat
& GDT_64BIT
)
3128 GDTOFFSOF(gdth_cmd_str
,u
.cache64
.sg_lst
) + sizeof(gdth_sg64_str
);
3131 GDTOFFSOF(gdth_cmd_str
,u
.cache
.sg_lst
) + sizeof(gdth_sg_str
);
3132 } else if (cmdp
->Service
== SCSIRAWSERVICE
) {
3133 TRACE2(("raw command %d\n",cmdp
->OpCode
));
3134 if (ha
->raw_feat
& GDT_64BIT
)
3136 GDTOFFSOF(gdth_cmd_str
,u
.raw64
.sg_lst
) + sizeof(gdth_sg64_str
);
3139 GDTOFFSOF(gdth_cmd_str
,u
.raw
.sg_lst
) + sizeof(gdth_sg_str
);
3142 if (ha
->cmd_len
& 3)
3143 ha
->cmd_len
+= (4 - (ha
->cmd_len
& 3));
3145 if (ha
->cmd_cnt
> 0) {
3146 if ((ha
->cmd_offs_dpmem
+ ha
->cmd_len
+ DPMEM_COMMAND_OFFSET
) >
3148 TRACE2(("gdth_special_cmd() DPMEM overflow\n"));
3149 ha
->cmd_tab
[cmd_index
-2].cmnd
= UNUSED_CMND
;
3155 gdth_copy_command(hanum
);
3160 /* Controller event handling functions */
3161 static gdth_evt_str
*gdth_store_event(gdth_ha_str
*ha
, ushort source
,
3162 ushort idx
, gdth_evt_data
*evt
)
3167 /* no GDTH_LOCK_HA() ! */
3168 TRACE2(("gdth_store_event() source %d idx %d\n", source
, idx
));
3169 if (source
== 0) /* no source -> no event */
3172 if (ebuffer
[elastidx
].event_source
== source
&&
3173 ebuffer
[elastidx
].event_idx
== idx
&&
3174 ((evt
->size
!= 0 && ebuffer
[elastidx
].event_data
.size
!= 0 &&
3175 !memcmp((char *)&ebuffer
[elastidx
].event_data
.eu
,
3176 (char *)&evt
->eu
, evt
->size
)) ||
3177 (evt
->size
== 0 && ebuffer
[elastidx
].event_data
.size
== 0 &&
3178 !strcmp((char *)&ebuffer
[elastidx
].event_data
.event_string
,
3179 (char *)&evt
->event_string
)))) {
3180 e
= &ebuffer
[elastidx
];
3181 do_gettimeofday(&tv
);
3182 e
->last_stamp
= tv
.tv_sec
;
3185 if (ebuffer
[elastidx
].event_source
!= 0) { /* entry not free ? */
3187 if (elastidx
== MAX_EVENTS
)
3189 if (elastidx
== eoldidx
) { /* reached mark ? */
3191 if (eoldidx
== MAX_EVENTS
)
3195 e
= &ebuffer
[elastidx
];
3196 e
->event_source
= source
;
3198 do_gettimeofday(&tv
);
3199 e
->first_stamp
= e
->last_stamp
= tv
.tv_sec
;
3201 e
->event_data
= *evt
;
3207 static int gdth_read_event(gdth_ha_str
*ha
, int handle
, gdth_evt_str
*estr
)
3213 TRACE2(("gdth_read_event() handle %d\n", handle
));
3214 spin_lock_irqsave(&ha
->smp_lock
, flags
);
3219 estr
->event_source
= 0;
3221 if (eindex
>= MAX_EVENTS
) {
3222 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
3225 e
= &ebuffer
[eindex
];
3226 if (e
->event_source
!= 0) {
3227 if (eindex
!= elastidx
) {
3228 if (++eindex
== MAX_EVENTS
)
3233 memcpy(estr
, e
, sizeof(gdth_evt_str
));
3235 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
3239 static void gdth_readapp_event(gdth_ha_str
*ha
,
3240 unchar application
, gdth_evt_str
*estr
)
3245 unchar found
= FALSE
;
3247 TRACE2(("gdth_readapp_event() app. %d\n", application
));
3248 spin_lock_irqsave(&ha
->smp_lock
, flags
);
3251 e
= &ebuffer
[eindex
];
3252 if (e
->event_source
== 0)
3254 if ((e
->application
& application
) == 0) {
3255 e
->application
|= application
;
3259 if (eindex
== elastidx
)
3261 if (++eindex
== MAX_EVENTS
)
3265 memcpy(estr
, e
, sizeof(gdth_evt_str
));
3267 estr
->event_source
= 0;
3268 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
3271 static void gdth_clear_events(void)
3273 TRACE(("gdth_clear_events()"));
3275 eoldidx
= elastidx
= 0;
3276 ebuffer
[0].event_source
= 0;
3280 /* SCSI interface functions */
3282 static irqreturn_t
gdth_interrupt(int irq
,void *dev_id
,struct pt_regs
*regs
)
3284 gdth_ha_str
*ha2
= (gdth_ha_str
*)dev_id
;
3285 register gdth_ha_str
*ha
;
3286 gdt6m_dpram_str __iomem
*dp6m_ptr
= NULL
;
3287 gdt6_dpram_str __iomem
*dp6_ptr
;
3288 gdt2_dpram_str __iomem
*dp2_ptr
;
3295 int coalesced
= FALSE
;
3297 gdth_coal_status
*pcs
= NULL
;
3298 int act_int_coal
= 0;
3301 TRACE(("gdth_interrupt() IRQ %d\n",irq
));
3303 /* if polling and not from gdth_wait() -> return */
3305 if (!gdth_from_wait
) {
3311 spin_lock_irqsave(&ha2
->smp_lock
, flags
);
3314 /* search controller */
3315 if ((hanum
= gdth_get_status(&IStatus
,irq
)) == -1) {
3316 /* spurious interrupt */
3318 spin_unlock_irqrestore(&ha2
->smp_lock
, flags
);
3321 ha
= HADATA(gdth_ctr_tab
[hanum
]);
3323 #ifdef GDTH_STATISTICS
3328 /* See if the fw is returning coalesced status */
3329 if (IStatus
== COALINDEX
) {
3330 /* Coalesced status. Setup the initial status
3331 buffer pointer and flags */
3332 pcs
= ha
->coal_stat
;
3339 /* For coalesced requests all status
3340 information is found in the status buffer */
3341 IStatus
= (unchar
)(pcs
->status
& 0xff);
3345 if (ha
->type
== GDT_EISA
) {
3346 if (IStatus
& 0x80) { /* error flag */
3348 ha
->status
= inw(ha
->bmic
+ MAILBOXREG
+8);
3349 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus
,ha
->status
));
3350 } else /* no error */
3352 ha
->info
= inl(ha
->bmic
+ MAILBOXREG
+12);
3353 ha
->service
= inw(ha
->bmic
+ MAILBOXREG
+10);
3354 ha
->info2
= inl(ha
->bmic
+ MAILBOXREG
+4);
3356 outb(0xff, ha
->bmic
+ EDOORREG
); /* acknowledge interrupt */
3357 outb(0x00, ha
->bmic
+ SEMA1REG
); /* reset status semaphore */
3358 } else if (ha
->type
== GDT_ISA
) {
3360 if (IStatus
& 0x80) { /* error flag */
3362 ha
->status
= gdth_readw(&dp2_ptr
->u
.ic
.Status
);
3363 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus
,ha
->status
));
3364 } else /* no error */
3366 ha
->info
= gdth_readl(&dp2_ptr
->u
.ic
.Info
[0]);
3367 ha
->service
= gdth_readw(&dp2_ptr
->u
.ic
.Service
);
3368 ha
->info2
= gdth_readl(&dp2_ptr
->u
.ic
.Info
[1]);
3370 gdth_writeb(0xff, &dp2_ptr
->io
.irqdel
); /* acknowledge interrupt */
3371 gdth_writeb(0, &dp2_ptr
->u
.ic
.Cmd_Index
);/* reset command index */
3372 gdth_writeb(0, &dp2_ptr
->io
.Sema1
); /* reset status semaphore */
3373 } else if (ha
->type
== GDT_PCI
) {
3375 if (IStatus
& 0x80) { /* error flag */
3377 ha
->status
= gdth_readw(&dp6_ptr
->u
.ic
.Status
);
3378 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus
,ha
->status
));
3379 } else /* no error */
3381 ha
->info
= gdth_readl(&dp6_ptr
->u
.ic
.Info
[0]);
3382 ha
->service
= gdth_readw(&dp6_ptr
->u
.ic
.Service
);
3383 ha
->info2
= gdth_readl(&dp6_ptr
->u
.ic
.Info
[1]);
3385 gdth_writeb(0xff, &dp6_ptr
->io
.irqdel
); /* acknowledge interrupt */
3386 gdth_writeb(0, &dp6_ptr
->u
.ic
.Cmd_Index
);/* reset command index */
3387 gdth_writeb(0, &dp6_ptr
->io
.Sema1
); /* reset status semaphore */
3388 } else if (ha
->type
== GDT_PCINEW
) {
3389 if (IStatus
& 0x80) { /* error flag */
3391 ha
->status
= inw(PTR2USHORT(&ha
->plx
->status
));
3392 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus
,ha
->status
));
3395 ha
->info
= inl(PTR2USHORT(&ha
->plx
->info
[0]));
3396 ha
->service
= inw(PTR2USHORT(&ha
->plx
->service
));
3397 ha
->info2
= inl(PTR2USHORT(&ha
->plx
->info
[1]));
3399 outb(0xff, PTR2USHORT(&ha
->plx
->edoor_reg
));
3400 outb(0x00, PTR2USHORT(&ha
->plx
->sema1_reg
));
3401 } else if (ha
->type
== GDT_PCIMPR
) {
3403 if (IStatus
& 0x80) { /* error flag */
3407 ha
->status
= pcs
->ext_status
&& 0xffff;
3410 ha
->status
= gdth_readw(&dp6m_ptr
->i960r
.status
);
3411 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus
,ha
->status
));
3412 } else /* no error */
3415 /* get information */
3417 ha
->info
= pcs
->info0
;
3418 ha
->info2
= pcs
->info1
;
3419 ha
->service
= (pcs
->ext_status
>> 16) && 0xffff;
3423 ha
->info
= gdth_readl(&dp6m_ptr
->i960r
.info
[0]);
3424 ha
->service
= gdth_readw(&dp6m_ptr
->i960r
.service
);
3425 ha
->info2
= gdth_readl(&dp6m_ptr
->i960r
.info
[1]);
3428 if (IStatus
== ASYNCINDEX
) {
3429 if (ha
->service
!= SCREENSERVICE
&&
3430 (ha
->fw_vers
& 0xff) >= 0x1a) {
3431 ha
->dvr
.severity
= gdth_readb
3432 (&((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.severity
);
3433 for (i
= 0; i
< 256; ++i
) {
3434 ha
->dvr
.event_string
[i
] = gdth_readb
3435 (&((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.evt_str
[i
]);
3436 if (ha
->dvr
.event_string
[i
] == 0)
3442 /* Make sure that non coalesced interrupts get cleared
3443 before being handled by gdth_async_event/gdth_sync_event */
3447 gdth_writeb(0xff, &dp6m_ptr
->i960r
.edoor_reg
);
3448 gdth_writeb(0, &dp6m_ptr
->i960r
.sema1_reg
);
3451 TRACE2(("gdth_interrupt() unknown controller type\n"));
3453 spin_unlock_irqrestore(&ha2
->smp_lock
, flags
);
3457 TRACE(("gdth_interrupt() index %d stat %d info %d\n",
3458 IStatus
,ha
->status
,ha
->info
));
3460 if (gdth_from_wait
) {
3462 wait_index
= (int)IStatus
;
3465 if (IStatus
== ASYNCINDEX
) {
3466 TRACE2(("gdth_interrupt() async. event\n"));
3467 gdth_async_event(hanum
);
3469 spin_unlock_irqrestore(&ha2
->smp_lock
, flags
);
3474 if (IStatus
== SPEZINDEX
) {
3475 TRACE2(("Service unknown or not initialized !\n"));
3476 ha
->dvr
.size
= sizeof(ha
->dvr
.eu
.driver
);
3477 ha
->dvr
.eu
.driver
.ionode
= hanum
;
3478 gdth_store_event(ha
, ES_DRIVER
, 4, &ha
->dvr
);
3480 spin_unlock_irqrestore(&ha2
->smp_lock
, flags
);
3483 scp
= ha
->cmd_tab
[IStatus
-2].cmnd
;
3484 Service
= ha
->cmd_tab
[IStatus
-2].service
;
3485 ha
->cmd_tab
[IStatus
-2].cmnd
= UNUSED_CMND
;
3486 if (scp
== UNUSED_CMND
) {
3487 TRACE2(("gdth_interrupt() index to unused command (%d)\n",IStatus
));
3488 ha
->dvr
.size
= sizeof(ha
->dvr
.eu
.driver
);
3489 ha
->dvr
.eu
.driver
.ionode
= hanum
;
3490 ha
->dvr
.eu
.driver
.index
= IStatus
;
3491 gdth_store_event(ha
, ES_DRIVER
, 1, &ha
->dvr
);
3493 spin_unlock_irqrestore(&ha2
->smp_lock
, flags
);
3496 if (scp
== INTERNAL_CMND
) {
3497 TRACE(("gdth_interrupt() answer to internal command\n"));
3499 spin_unlock_irqrestore(&ha2
->smp_lock
, flags
);
3503 TRACE(("gdth_interrupt() sync. status\n"));
3504 rval
= gdth_sync_event(hanum
,Service
,IStatus
,scp
);
3506 spin_unlock_irqrestore(&ha2
->smp_lock
, flags
);
3508 gdth_putq(hanum
,scp
,scp
->SCp
.this_residual
);
3509 } else if (rval
== 1) {
3510 scp
->scsi_done(scp
);
3515 /* go to the next status in the status buffer */
3517 #ifdef GDTH_STATISTICS
3519 if (act_int_coal
> max_int_coal
) {
3520 max_int_coal
= act_int_coal
;
3521 printk("GDT: max_int_coal = %d\n",(ushort
)max_int_coal
);
3524 /* see if there is another status */
3525 if (pcs
->status
== 0)
3526 /* Stop the coalesce loop */
3531 /* coalescing only for new GDT_PCIMPR controllers available */
3532 if (ha
->type
== GDT_PCIMPR
&& coalesced
) {
3533 gdth_writeb(0xff, &dp6m_ptr
->i960r
.edoor_reg
);
3534 gdth_writeb(0, &dp6m_ptr
->i960r
.sema1_reg
);
3542 static int gdth_sync_event(int hanum
,int service
,unchar index
,Scsi_Cmnd
*scp
)
3544 register gdth_ha_str
*ha
;
3549 ha
= HADATA(gdth_ctr_tab
[hanum
]);
3551 TRACE(("gdth_sync_event() serv %d status %d\n",
3552 service
,ha
->status
));
3554 if (service
== SCREENSERVICE
) {
3556 TRACE(("len: %d, answer: %d, ext: %d, alen: %d\n",
3557 msg
->msg_len
,msg
->msg_answer
,msg
->msg_ext
,msg
->msg_alen
));
3558 if (msg
->msg_len
> MSGLEN
+1)
3559 msg
->msg_len
= MSGLEN
+1;
3561 if (!(msg
->msg_answer
&& msg
->msg_ext
)) {
3562 msg
->msg_text
[msg
->msg_len
] = '\0';
3563 printk("%s",msg
->msg_text
);
3566 if (msg
->msg_ext
&& !msg
->msg_answer
) {
3567 while (gdth_test_busy(hanum
))
3569 cmdp
->Service
= SCREENSERVICE
;
3570 cmdp
->RequestBuffer
= SCREEN_CMND
;
3571 gdth_get_cmd_index(hanum
);
3572 gdth_set_sema0(hanum
);
3573 cmdp
->OpCode
= GDT_READ
;
3574 cmdp
->BoardNode
= LOCALBOARD
;
3575 cmdp
->u
.screen
.reserved
= 0;
3576 cmdp
->u
.screen
.su
.msg
.msg_handle
= msg
->msg_handle
;
3577 cmdp
->u
.screen
.su
.msg
.msg_addr
= ha
->msg_phys
;
3578 ha
->cmd_offs_dpmem
= 0;
3579 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.screen
.su
.msg
.msg_addr
)
3582 gdth_copy_command(hanum
);
3583 gdth_release_event(hanum
);
3587 if (msg
->msg_answer
&& msg
->msg_alen
) {
3588 /* default answers (getchar() not possible) */
3589 if (msg
->msg_alen
== 1) {
3592 msg
->msg_text
[0] = 0;
3596 msg
->msg_text
[0] = 1;
3597 msg
->msg_text
[1] = 0;
3600 msg
->msg_answer
= 0;
3601 while (gdth_test_busy(hanum
))
3603 cmdp
->Service
= SCREENSERVICE
;
3604 cmdp
->RequestBuffer
= SCREEN_CMND
;
3605 gdth_get_cmd_index(hanum
);
3606 gdth_set_sema0(hanum
);
3607 cmdp
->OpCode
= GDT_WRITE
;
3608 cmdp
->BoardNode
= LOCALBOARD
;
3609 cmdp
->u
.screen
.reserved
= 0;
3610 cmdp
->u
.screen
.su
.msg
.msg_handle
= msg
->msg_handle
;
3611 cmdp
->u
.screen
.su
.msg
.msg_addr
= ha
->msg_phys
;
3612 ha
->cmd_offs_dpmem
= 0;
3613 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.screen
.su
.msg
.msg_addr
)
3616 gdth_copy_command(hanum
);
3617 gdth_release_event(hanum
);
3623 b
= virt_ctr
? NUMDATA(scp
->device
->host
)->busnum
: scp
->device
->channel
;
3624 t
= scp
->device
->id
;
3625 if (scp
->SCp
.sent_command
== -1 && b
!= ha
->virt_bus
) {
3626 ha
->raw
[BUS_L2P(ha
,b
)].io_cnt
[t
]--;
3628 /* cache or raw service */
3629 if (ha
->status
== S_BSY
) {
3630 TRACE2(("Controller busy -> retry !\n"));
3631 if (scp
->SCp
.sent_command
== GDT_MOUNT
)
3632 scp
->SCp
.sent_command
= GDT_CLUST_INFO
;
3636 if (scp
->SCp
.Status
== GDTH_MAP_SG
)
3637 pci_unmap_sg(ha
->pdev
,scp
->request_buffer
,
3638 scp
->use_sg
,scp
->SCp
.Message
);
3639 else if (scp
->SCp
.Status
== GDTH_MAP_SINGLE
)
3640 pci_unmap_page(ha
->pdev
,scp
->SCp
.dma_handle
,
3641 scp
->request_bufflen
,scp
->SCp
.Message
);
3642 if (scp
->SCp
.buffer
) {
3644 addr
= (dma_addr_t
)(ulong32
)scp
->SCp
.buffer
;
3645 if (scp
->host_scribble
)
3646 addr
+= (dma_addr_t
)((ulong64
)(ulong32
)scp
->host_scribble
<< 32);
3647 pci_unmap_page(ha
->pdev
,addr
,16,PCI_DMA_FROMDEVICE
);
3650 if (ha
->status
== S_OK
) {
3651 scp
->SCp
.Status
= S_OK
;
3652 scp
->SCp
.Message
= ha
->info
;
3653 if (scp
->SCp
.sent_command
!= -1) {
3654 TRACE2(("gdth_sync_event(): special cmd 0x%x OK\n",
3655 scp
->SCp
.sent_command
));
3656 /* special commands GDT_CLUST_INFO/GDT_MOUNT ? */
3657 if (scp
->SCp
.sent_command
== GDT_CLUST_INFO
) {
3658 ha
->hdr
[t
].cluster_type
= (unchar
)ha
->info
;
3659 if (!(ha
->hdr
[t
].cluster_type
&
3661 /* NOT MOUNTED -> MOUNT */
3662 scp
->SCp
.sent_command
= GDT_MOUNT
;
3663 if (ha
->hdr
[t
].cluster_type
&
3665 /* cluster drive RESERVED (on the other node) */
3666 scp
->SCp
.phase
= -2; /* reservation conflict */
3669 scp
->SCp
.sent_command
= -1;
3672 if (scp
->SCp
.sent_command
== GDT_MOUNT
) {
3673 ha
->hdr
[t
].cluster_type
|= CLUSTER_MOUNTED
;
3674 ha
->hdr
[t
].media_changed
= TRUE
;
3675 } else if (scp
->SCp
.sent_command
== GDT_UNMOUNT
) {
3676 ha
->hdr
[t
].cluster_type
&= ~CLUSTER_MOUNTED
;
3677 ha
->hdr
[t
].media_changed
= TRUE
;
3679 scp
->SCp
.sent_command
= -1;
3682 scp
->SCp
.this_residual
= HIGH_PRI
;
3685 /* RESERVE/RELEASE ? */
3686 if (scp
->cmnd
[0] == RESERVE
) {
3687 ha
->hdr
[t
].cluster_type
|= CLUSTER_RESERVED
;
3688 } else if (scp
->cmnd
[0] == RELEASE
) {
3689 ha
->hdr
[t
].cluster_type
&= ~CLUSTER_RESERVED
;
3691 scp
->result
= DID_OK
<< 16;
3692 scp
->sense_buffer
[0] = 0;
3695 scp
->SCp
.Status
= ha
->status
;
3696 scp
->SCp
.Message
= ha
->info
;
3698 if (scp
->SCp
.sent_command
!= -1) {
3699 TRACE2(("gdth_sync_event(): special cmd 0x%x error 0x%x\n",
3700 scp
->SCp
.sent_command
, ha
->status
));
3701 if (scp
->SCp
.sent_command
== GDT_SCAN_START
||
3702 scp
->SCp
.sent_command
== GDT_SCAN_END
) {
3703 scp
->SCp
.sent_command
= -1;
3705 scp
->SCp
.this_residual
= HIGH_PRI
;
3708 memset((char*)scp
->sense_buffer
,0,16);
3709 scp
->sense_buffer
[0] = 0x70;
3710 scp
->sense_buffer
[2] = NOT_READY
;
3711 scp
->result
= (DID_OK
<< 16) | (CHECK_CONDITION
<< 1);
3712 } else if (service
== CACHESERVICE
) {
3713 if (ha
->status
== S_CACHE_UNKNOWN
&&
3714 (ha
->hdr
[t
].cluster_type
&
3715 CLUSTER_RESERVE_STATE
) == CLUSTER_RESERVE_STATE
) {
3716 /* bus reset -> force GDT_CLUST_INFO */
3717 ha
->hdr
[t
].cluster_type
&= ~CLUSTER_RESERVED
;
3719 memset((char*)scp
->sense_buffer
,0,16);
3720 if (ha
->status
== (ushort
)S_CACHE_RESERV
) {
3721 scp
->result
= (DID_OK
<< 16) | (RESERVATION_CONFLICT
<< 1);
3723 scp
->sense_buffer
[0] = 0x70;
3724 scp
->sense_buffer
[2] = NOT_READY
;
3725 scp
->result
= (DID_OK
<< 16) | (CHECK_CONDITION
<< 1);
3727 if (scp
->done
!= gdth_scsi_done
) {
3728 ha
->dvr
.size
= sizeof(ha
->dvr
.eu
.sync
);
3729 ha
->dvr
.eu
.sync
.ionode
= hanum
;
3730 ha
->dvr
.eu
.sync
.service
= service
;
3731 ha
->dvr
.eu
.sync
.status
= ha
->status
;
3732 ha
->dvr
.eu
.sync
.info
= ha
->info
;
3733 ha
->dvr
.eu
.sync
.hostdrive
= t
;
3734 if (ha
->status
>= 0x8000)
3735 gdth_store_event(ha
, ES_SYNC
, 0, &ha
->dvr
);
3737 gdth_store_event(ha
, ES_SYNC
, service
, &ha
->dvr
);
3740 /* sense buffer filled from controller firmware (DMA) */
3741 if (ha
->status
!= S_RAW_SCSI
|| ha
->info
>= 0x100) {
3742 scp
->result
= DID_BAD_TARGET
<< 16;
3744 scp
->result
= (DID_OK
<< 16) | ha
->info
;
3748 if (!scp
->SCp
.have_data_in
)
3749 scp
->SCp
.have_data_in
++;
3757 static char *async_cache_tab
[] = {
3758 /* 0*/ "\011\000\002\002\002\004\002\006\004"
3759 "GDT HA %u, service %u, async. status %u/%lu unknown",
3760 /* 1*/ "\011\000\002\002\002\004\002\006\004"
3761 "GDT HA %u, service %u, async. status %u/%lu unknown",
3762 /* 2*/ "\005\000\002\006\004"
3763 "GDT HA %u, Host Drive %lu not ready",
3764 /* 3*/ "\005\000\002\006\004"
3765 "GDT HA %u, Host Drive %lu: REASSIGN not successful and/or data error on reassigned blocks. Drive may crash in the future and should be replaced",
3766 /* 4*/ "\005\000\002\006\004"
3767 "GDT HA %u, mirror update on Host Drive %lu failed",
3768 /* 5*/ "\005\000\002\006\004"
3769 "GDT HA %u, Mirror Drive %lu failed",
3770 /* 6*/ "\005\000\002\006\004"
3771 "GDT HA %u, Mirror Drive %lu: REASSIGN not successful and/or data error on reassigned blocks. Drive may crash in the future and should be replaced",
3772 /* 7*/ "\005\000\002\006\004"
3773 "GDT HA %u, Host Drive %lu write protected",
3774 /* 8*/ "\005\000\002\006\004"
3775 "GDT HA %u, media changed in Host Drive %lu",
3776 /* 9*/ "\005\000\002\006\004"
3777 "GDT HA %u, Host Drive %lu is offline",
3778 /*10*/ "\005\000\002\006\004"
3779 "GDT HA %u, media change of Mirror Drive %lu",
3780 /*11*/ "\005\000\002\006\004"
3781 "GDT HA %u, Mirror Drive %lu is write protected",
3782 /*12*/ "\005\000\002\006\004"
3783 "GDT HA %u, general error on Host Drive %lu. Please check the devices of this drive!",
3784 /*13*/ "\007\000\002\006\002\010\002"
3785 "GDT HA %u, Array Drive %u: Cache Drive %u failed",
3786 /*14*/ "\005\000\002\006\002"
3787 "GDT HA %u, Array Drive %u: FAIL state entered",
3788 /*15*/ "\005\000\002\006\002"
3789 "GDT HA %u, Array Drive %u: error",
3790 /*16*/ "\007\000\002\006\002\010\002"
3791 "GDT HA %u, Array Drive %u: failed drive replaced by Cache Drive %u",
3792 /*17*/ "\005\000\002\006\002"
3793 "GDT HA %u, Array Drive %u: parity build failed",
3794 /*18*/ "\005\000\002\006\002"
3795 "GDT HA %u, Array Drive %u: drive rebuild failed",
3796 /*19*/ "\005\000\002\010\002"
3797 "GDT HA %u, Test of Hot Fix %u failed",
3798 /*20*/ "\005\000\002\006\002"
3799 "GDT HA %u, Array Drive %u: drive build finished successfully",
3800 /*21*/ "\005\000\002\006\002"
3801 "GDT HA %u, Array Drive %u: drive rebuild finished successfully",
3802 /*22*/ "\007\000\002\006\002\010\002"
3803 "GDT HA %u, Array Drive %u: Hot Fix %u activated",
3804 /*23*/ "\005\000\002\006\002"
3805 "GDT HA %u, Host Drive %u: processing of i/o aborted due to serious drive error",
3806 /*24*/ "\005\000\002\010\002"
3807 "GDT HA %u, mirror update on Cache Drive %u completed",
3808 /*25*/ "\005\000\002\010\002"
3809 "GDT HA %u, mirror update on Cache Drive %lu failed",
3810 /*26*/ "\005\000\002\006\002"
3811 "GDT HA %u, Array Drive %u: drive rebuild started",
3812 /*27*/ "\005\000\002\012\001"
3813 "GDT HA %u, Fault bus %u: SHELF OK detected",
3814 /*28*/ "\005\000\002\012\001"
3815 "GDT HA %u, Fault bus %u: SHELF not OK detected",
3816 /*29*/ "\007\000\002\012\001\013\001"
3817 "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug started",
3818 /*30*/ "\007\000\002\012\001\013\001"
3819 "GDT HA %u, Fault bus %u, ID %u: new disk detected",
3820 /*31*/ "\007\000\002\012\001\013\001"
3821 "GDT HA %u, Fault bus %u, ID %u: old disk detected",
3822 /*32*/ "\007\000\002\012\001\013\001"
3823 "GDT HA %u, Fault bus %u, ID %u: plugging an active disk is invalid",
3824 /*33*/ "\007\000\002\012\001\013\001"
3825 "GDT HA %u, Fault bus %u, ID %u: invalid device detected",
3826 /*34*/ "\011\000\002\012\001\013\001\006\004"
3827 "GDT HA %u, Fault bus %u, ID %u: insufficient disk capacity (%lu MB required)",
3828 /*35*/ "\007\000\002\012\001\013\001"
3829 "GDT HA %u, Fault bus %u, ID %u: disk write protected",
3830 /*36*/ "\007\000\002\012\001\013\001"
3831 "GDT HA %u, Fault bus %u, ID %u: disk not available",
3832 /*37*/ "\007\000\002\012\001\006\004"
3833 "GDT HA %u, Fault bus %u: swap detected (%lu)",
3834 /*38*/ "\007\000\002\012\001\013\001"
3835 "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug finished successfully",
3836 /*39*/ "\007\000\002\012\001\013\001"
3837 "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug aborted due to user Hot Plug",
3838 /*40*/ "\007\000\002\012\001\013\001"
3839 "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug aborted",
3840 /*41*/ "\007\000\002\012\001\013\001"
3841 "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug for Hot Fix started",
3842 /*42*/ "\005\000\002\006\002"
3843 "GDT HA %u, Array Drive %u: drive build started",
3844 /*43*/ "\003\000\002"
3845 "GDT HA %u, DRAM parity error detected",
3846 /*44*/ "\005\000\002\006\002"
3847 "GDT HA %u, Mirror Drive %u: update started",
3848 /*45*/ "\007\000\002\006\002\010\002"
3849 "GDT HA %u, Mirror Drive %u: Hot Fix %u activated",
3850 /*46*/ "\005\000\002\006\002"
3851 "GDT HA %u, Array Drive %u: no matching Pool Hot Fix Drive available",
3852 /*47*/ "\005\000\002\006\002"
3853 "GDT HA %u, Array Drive %u: Pool Hot Fix Drive available",
3854 /*48*/ "\005\000\002\006\002"
3855 "GDT HA %u, Mirror Drive %u: no matching Pool Hot Fix Drive available",
3856 /*49*/ "\005\000\002\006\002"
3857 "GDT HA %u, Mirror Drive %u: Pool Hot Fix Drive available",
3858 /*50*/ "\007\000\002\012\001\013\001"
3859 "GDT HA %u, SCSI bus %u, ID %u: IGNORE_WIDE_RESIDUE message received",
3860 /*51*/ "\005\000\002\006\002"
3861 "GDT HA %u, Array Drive %u: expand started",
3862 /*52*/ "\005\000\002\006\002"
3863 "GDT HA %u, Array Drive %u: expand finished successfully",
3864 /*53*/ "\005\000\002\006\002"
3865 "GDT HA %u, Array Drive %u: expand failed",
3866 /*54*/ "\003\000\002"
3867 "GDT HA %u, CPU temperature critical",
3868 /*55*/ "\003\000\002"
3869 "GDT HA %u, CPU temperature OK",
3870 /*56*/ "\005\000\002\006\004"
3871 "GDT HA %u, Host drive %lu created",
3872 /*57*/ "\005\000\002\006\002"
3873 "GDT HA %u, Array Drive %u: expand restarted",
3874 /*58*/ "\005\000\002\006\002"
3875 "GDT HA %u, Array Drive %u: expand stopped",
3876 /*59*/ "\005\000\002\010\002"
3877 "GDT HA %u, Mirror Drive %u: drive build quited",
3878 /*60*/ "\005\000\002\006\002"
3879 "GDT HA %u, Array Drive %u: parity build quited",
3880 /*61*/ "\005\000\002\006\002"
3881 "GDT HA %u, Array Drive %u: drive rebuild quited",
3882 /*62*/ "\005\000\002\006\002"
3883 "GDT HA %u, Array Drive %u: parity verify started",
3884 /*63*/ "\005\000\002\006\002"
3885 "GDT HA %u, Array Drive %u: parity verify done",
3886 /*64*/ "\005\000\002\006\002"
3887 "GDT HA %u, Array Drive %u: parity verify failed",
3888 /*65*/ "\005\000\002\006\002"
3889 "GDT HA %u, Array Drive %u: parity error detected",
3890 /*66*/ "\005\000\002\006\002"
3891 "GDT HA %u, Array Drive %u: parity verify quited",
3892 /*67*/ "\005\000\002\006\002"
3893 "GDT HA %u, Host Drive %u reserved",
3894 /*68*/ "\005\000\002\006\002"
3895 "GDT HA %u, Host Drive %u mounted and released",
3896 /*69*/ "\005\000\002\006\002"
3897 "GDT HA %u, Host Drive %u released",
3898 /*70*/ "\003\000\002"
3899 "GDT HA %u, DRAM error detected and corrected with ECC",
3900 /*71*/ "\003\000\002"
3901 "GDT HA %u, Uncorrectable DRAM error detected with ECC",
3902 /*72*/ "\011\000\002\012\001\013\001\014\001"
3903 "GDT HA %u, SCSI bus %u, ID %u, LUN %u: reassigning block",
3904 /*73*/ "\005\000\002\006\002"
3905 "GDT HA %u, Host drive %u resetted locally",
3906 /*74*/ "\005\000\002\006\002"
3907 "GDT HA %u, Host drive %u resetted remotely",
3908 /*75*/ "\003\000\002"
3909 "GDT HA %u, async. status 75 unknown",
3913 static int gdth_async_event(int hanum
)
3919 ha
= HADATA(gdth_ctr_tab
[hanum
]);
3921 TRACE2(("gdth_async_event() ha %d serv %d\n",
3922 hanum
,ha
->service
));
3924 if (ha
->service
== SCREENSERVICE
) {
3925 if (ha
->status
== MSG_REQUEST
) {
3926 while (gdth_test_busy(hanum
))
3928 cmdp
->Service
= SCREENSERVICE
;
3929 cmdp
->RequestBuffer
= SCREEN_CMND
;
3930 cmd_index
= gdth_get_cmd_index(hanum
);
3931 gdth_set_sema0(hanum
);
3932 cmdp
->OpCode
= GDT_READ
;
3933 cmdp
->BoardNode
= LOCALBOARD
;
3934 cmdp
->u
.screen
.reserved
= 0;
3935 cmdp
->u
.screen
.su
.msg
.msg_handle
= MSG_INV_HANDLE
;
3936 cmdp
->u
.screen
.su
.msg
.msg_addr
= ha
->msg_phys
;
3937 ha
->cmd_offs_dpmem
= 0;
3938 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.screen
.su
.msg
.msg_addr
)
3941 gdth_copy_command(hanum
);
3942 if (ha
->type
== GDT_EISA
)
3943 printk("[EISA slot %d] ",(ushort
)ha
->brd_phys
);
3944 else if (ha
->type
== GDT_ISA
)
3945 printk("[DPMEM 0x%4X] ",(ushort
)ha
->brd_phys
);
3947 printk("[PCI %d/%d] ",(ushort
)(ha
->brd_phys
>>8),
3948 (ushort
)((ha
->brd_phys
>>3)&0x1f));
3949 gdth_release_event(hanum
);
3953 if (ha
->type
== GDT_PCIMPR
&&
3954 (ha
->fw_vers
& 0xff) >= 0x1a) {
3956 ha
->dvr
.eu
.async
.ionode
= hanum
;
3957 ha
->dvr
.eu
.async
.status
= ha
->status
;
3958 /* severity and event_string already set! */
3960 ha
->dvr
.size
= sizeof(ha
->dvr
.eu
.async
);
3961 ha
->dvr
.eu
.async
.ionode
= hanum
;
3962 ha
->dvr
.eu
.async
.service
= ha
->service
;
3963 ha
->dvr
.eu
.async
.status
= ha
->status
;
3964 ha
->dvr
.eu
.async
.info
= ha
->info
;
3965 *(ulong32
*)ha
->dvr
.eu
.async
.scsi_coord
= ha
->info2
;
3967 gdth_store_event( ha
, ES_ASYNC
, ha
->service
, &ha
->dvr
);
3968 gdth_log_event( &ha
->dvr
, NULL
);
3970 /* new host drive from expand? */
3971 if (ha
->service
== CACHESERVICE
&& ha
->status
== 56) {
3972 TRACE2(("gdth_async_event(): new host drive %d created\n",
3974 /* gdth_analyse_hdrive(hanum, (ushort)ha->info); */
3980 static void gdth_log_event(gdth_evt_data
*dvr
, char *buffer
)
3982 gdth_stackframe stack
;
3986 TRACE2(("gdth_log_event()\n"));
3987 if (dvr
->size
== 0) {
3988 if (buffer
== NULL
) {
3989 printk("Adapter %d: %s\n",dvr
->eu
.async
.ionode
,dvr
->event_string
);
3991 sprintf(buffer
,"Adapter %d: %s\n",
3992 dvr
->eu
.async
.ionode
,dvr
->event_string
);
3994 } else if (dvr
->eu
.async
.service
== CACHESERVICE
&&
3995 INDEX_OK(dvr
->eu
.async
.status
, async_cache_tab
)) {
3996 TRACE2(("GDT: Async. event cache service, event no.: %d\n",
3997 dvr
->eu
.async
.status
));
3999 f
= async_cache_tab
[dvr
->eu
.async
.status
];
4001 /* i: parameter to push, j: stack element to fill */
4002 for (j
=0,i
=1; i
< f
[0]; i
+=2) {
4005 stack
.b
[j
++] = *(ulong32
*)&dvr
->eu
.stream
[(int)f
[i
]];
4008 stack
.b
[j
++] = *(ushort
*)&dvr
->eu
.stream
[(int)f
[i
]];
4011 stack
.b
[j
++] = *(unchar
*)&dvr
->eu
.stream
[(int)f
[i
]];
4018 if (buffer
== NULL
) {
4019 printk(&f
[(int)f
[0]],stack
);
4022 sprintf(buffer
,&f
[(int)f
[0]],stack
);
4026 if (buffer
== NULL
) {
4027 printk("GDT HA %u, Unknown async. event service %d event no. %d\n",
4028 dvr
->eu
.async
.ionode
,dvr
->eu
.async
.service
,dvr
->eu
.async
.status
);
4030 sprintf(buffer
,"GDT HA %u, Unknown async. event service %d event no. %d",
4031 dvr
->eu
.async
.ionode
,dvr
->eu
.async
.service
,dvr
->eu
.async
.status
);
4036 #ifdef GDTH_STATISTICS
4037 static void gdth_timeout(ulong data
)
4045 ha
= HADATA(gdth_ctr_tab
[hanum
]);
4046 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4048 for (act_stats
=0,i
=0; i
<GDTH_MAXCMDS
; ++i
)
4049 if (ha
->cmd_tab
[i
].cmnd
!= UNUSED_CMND
)
4052 for (act_rq
=0,nscp
=ha
->req_first
; nscp
; nscp
=(Scsi_Cmnd
*)nscp
->SCp
.ptr
)
4055 TRACE2(("gdth_to(): ints %d, ios %d, act_stats %d, act_rq %d\n",
4056 act_ints
, act_ios
, act_stats
, act_rq
));
4057 act_ints
= act_ios
= 0;
4059 gdth_timer
.expires
= jiffies
+ 30 * HZ
;
4060 add_timer(&gdth_timer
);
4061 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4065 static void __init
internal_setup(char *str
,int *ints
)
4068 char *cur_str
, *argv
;
4070 TRACE2(("internal_setup() str %s ints[0] %d\n",
4071 str
? str
:"NULL", ints
? ints
[0]:0));
4073 /* read irq[] from ints[] */
4079 for (i
= 0; i
< argc
; ++i
)
4084 /* analyse string */
4086 while (argv
&& (cur_str
= strchr(argv
, ':'))) {
4087 int val
= 0, c
= *++cur_str
;
4089 if (c
== 'n' || c
== 'N')
4091 else if (c
== 'y' || c
== 'Y')
4094 val
= (int)simple_strtoul(cur_str
, NULL
, 0);
4096 if (!strncmp(argv
, "disable:", 8))
4098 else if (!strncmp(argv
, "reserve_mode:", 13))
4100 else if (!strncmp(argv
, "reverse_scan:", 13))
4102 else if (!strncmp(argv
, "hdr_channel:", 12))
4104 else if (!strncmp(argv
, "max_ids:", 8))
4106 else if (!strncmp(argv
, "rescan:", 7))
4108 else if (!strncmp(argv
, "virt_ctr:", 9))
4110 else if (!strncmp(argv
, "shared_access:", 14))
4111 shared_access
= val
;
4112 else if (!strncmp(argv
, "probe_eisa_isa:", 15))
4113 probe_eisa_isa
= val
;
4114 else if (!strncmp(argv
, "reserve_list:", 13)) {
4115 reserve_list
[0] = val
;
4116 for (i
= 1; i
< MAX_RES_ARGS
; i
++) {
4117 cur_str
= strchr(cur_str
, ',');
4120 if (!isdigit((int)*++cur_str
)) {
4125 (int)simple_strtoul(cur_str
, NULL
, 0);
4133 if ((argv
= strchr(argv
, ',')))
4138 int __init
option_setup(char *str
)
4144 TRACE2(("option_setup() str %s\n", str
? str
:"NULL"));
4146 while (cur
&& isdigit(*cur
) && i
<= MAXHA
) {
4147 ints
[i
++] = simple_strtoul(cur
, NULL
, 0);
4148 if ((cur
= strchr(cur
, ',')) != NULL
) cur
++;
4152 internal_setup(cur
, ints
);
4156 static int __init
gdth_detect(struct scsi_host_template
*shtp
)
4158 struct Scsi_Host
*shp
;
4159 gdth_pci_str pcistr
[MAXHA
];
4163 int i
,hanum
,cnt
,ctr
,err
;
4168 printk("GDT: This driver contains debugging information !! Trace level = %d\n",
4170 printk(" Destination of debugging information: ");
4173 printk("Serial port COM2\n");
4175 printk("Serial port COM1\n");
4178 printk("Console\n");
4183 TRACE(("gdth_detect()\n"));
4186 printk("GDT-HA: Controller driver disabled from command line !\n");
4190 printk("GDT-HA: Storage RAID Controller Driver. Version: %s \n",GDTH_VERSION_STR
);
4191 /* initializations */
4192 gdth_polling
= TRUE
; b
= 0;
4193 gdth_clear_events();
4195 /* As default we do not probe for EISA or ISA controllers */
4196 if (probe_eisa_isa
) {
4197 /* scanning for controllers, at first: ISA controller */
4198 for (isa_bios
=0xc8000UL
; isa_bios
<=0xd8000UL
; isa_bios
+=0x8000UL
) {
4199 dma_addr_t scratch_dma_handle
;
4200 scratch_dma_handle
= 0;
4202 if (gdth_ctr_count
>= MAXHA
)
4204 if (gdth_search_isa(isa_bios
)) { /* controller found */
4205 shp
= scsi_register(shtp
,sizeof(gdth_ext_str
));
4210 if (!gdth_init_isa(isa_bios
,ha
)) {
4211 scsi_unregister(shp
);
4217 /* controller found and initialized */
4218 printk("Configuring GDT-ISA HA at BIOS 0x%05X IRQ %u DRQ %u\n",
4219 isa_bios
,ha
->irq
,ha
->drq
);
4221 if (request_irq(ha
->irq
,gdth_interrupt
,SA_INTERRUPT
,"gdth",ha
)) {
4222 printk("GDT-ISA: Unable to allocate IRQ\n");
4223 scsi_unregister(shp
);
4226 if (request_dma(ha
->drq
,"gdth")) {
4227 printk("GDT-ISA: Unable to allocate DMA channel\n");
4228 free_irq(ha
->irq
,ha
);
4229 scsi_unregister(shp
);
4232 set_dma_mode(ha
->drq
,DMA_MODE_CASCADE
);
4233 enable_dma(ha
->drq
);
4234 shp
->unchecked_isa_dma
= 1;
4236 shp
->dma_channel
= ha
->drq
;
4237 hanum
= gdth_ctr_count
;
4238 gdth_ctr_tab
[gdth_ctr_count
++] = shp
;
4239 gdth_ctr_vtab
[gdth_ctr_vcount
++] = shp
;
4241 NUMDATA(shp
)->hanum
= (ushort
)hanum
;
4242 NUMDATA(shp
)->busnum
= 0;
4244 ha
->pccb
= CMDDATA(shp
);
4247 ha
->pscratch
= pci_alloc_consistent(ha
->pdev
, GDTH_SCRATCH
,
4248 &scratch_dma_handle
);
4249 ha
->scratch_phys
= scratch_dma_handle
;
4250 ha
->pmsg
= pci_alloc_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
4251 &scratch_dma_handle
);
4252 ha
->msg_phys
= scratch_dma_handle
;
4254 ha
->coal_stat
= (gdth_coal_status
*)
4255 pci_alloc_consistent(ha
->pdev
, sizeof(gdth_coal_status
) *
4256 MAXOFFSETS
, &scratch_dma_handle
);
4257 ha
->coal_stat_phys
= scratch_dma_handle
;
4260 ha
->scratch_busy
= FALSE
;
4261 ha
->req_first
= NULL
;
4262 ha
->tid_cnt
= MAX_HDRIVES
;
4263 if (max_ids
> 0 && max_ids
< ha
->tid_cnt
)
4264 ha
->tid_cnt
= max_ids
;
4265 for (i
=0; i
<GDTH_MAXCMDS
; ++i
)
4266 ha
->cmd_tab
[i
].cmnd
= UNUSED_CMND
;
4267 ha
->scan_mode
= rescan
? 0x10 : 0;
4269 if (ha
->pscratch
== NULL
|| ha
->pmsg
== NULL
||
4270 !gdth_search_drives(hanum
)) {
4271 printk("GDT-ISA: Error during device scan\n");
4277 pci_free_consistent(ha
->pdev
, sizeof(gdth_coal_status
) *
4278 MAXOFFSETS
, ha
->coal_stat
,
4279 ha
->coal_stat_phys
);
4282 pci_free_consistent(ha
->pdev
, GDTH_SCRATCH
,
4283 ha
->pscratch
, ha
->scratch_phys
);
4285 pci_free_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
4286 ha
->pmsg
, ha
->msg_phys
);
4288 free_irq(ha
->irq
,ha
);
4289 scsi_unregister(shp
);
4292 if (hdr_channel
< 0 || hdr_channel
> ha
->bus_cnt
)
4293 hdr_channel
= ha
->bus_cnt
;
4294 ha
->virt_bus
= hdr_channel
;
4296 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20) && \
4297 LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
4298 shp
->highmem_io
= 0;
4300 if (ha
->cache_feat
& ha
->raw_feat
& ha
->screen_feat
& GDT_64BIT
)
4301 shp
->max_cmd_len
= 16;
4303 shp
->max_id
= ha
->tid_cnt
;
4304 shp
->max_lun
= MAXLUN
;
4305 shp
->max_channel
= virt_ctr
? 0 : ha
->bus_cnt
;
4308 /* register addit. SCSI channels as virtual controllers */
4309 for (b
= 1; b
< ha
->bus_cnt
+ 1; ++b
) {
4310 shp
= scsi_register(shtp
,sizeof(gdth_num_str
));
4311 shp
->unchecked_isa_dma
= 1;
4313 shp
->dma_channel
= ha
->drq
;
4314 gdth_ctr_vtab
[gdth_ctr_vcount
++] = shp
;
4315 NUMDATA(shp
)->hanum
= (ushort
)hanum
;
4316 NUMDATA(shp
)->busnum
= b
;
4320 spin_lock_init(&ha
->smp_lock
);
4321 gdth_enable_int(hanum
);
4322 #endif /* !__ia64__ */
4326 /* scanning for EISA controllers */
4327 for (eisa_slot
=0x1000; eisa_slot
<=0x8000; eisa_slot
+=0x1000) {
4328 dma_addr_t scratch_dma_handle
;
4329 scratch_dma_handle
= 0;
4331 if (gdth_ctr_count
>= MAXHA
)
4333 if (gdth_search_eisa(eisa_slot
)) { /* controller found */
4334 shp
= scsi_register(shtp
,sizeof(gdth_ext_str
));
4339 if (!gdth_init_eisa(eisa_slot
,ha
)) {
4340 scsi_unregister(shp
);
4343 /* controller found and initialized */
4344 printk("Configuring GDT-EISA HA at Slot %d IRQ %u\n",
4345 eisa_slot
>>12,ha
->irq
);
4347 if (request_irq(ha
->irq
,gdth_interrupt
,SA_INTERRUPT
,"gdth",ha
)) {
4348 printk("GDT-EISA: Unable to allocate IRQ\n");
4349 scsi_unregister(shp
);
4352 shp
->unchecked_isa_dma
= 0;
4354 shp
->dma_channel
= 0xff;
4355 hanum
= gdth_ctr_count
;
4356 gdth_ctr_tab
[gdth_ctr_count
++] = shp
;
4357 gdth_ctr_vtab
[gdth_ctr_vcount
++] = shp
;
4359 NUMDATA(shp
)->hanum
= (ushort
)hanum
;
4360 NUMDATA(shp
)->busnum
= 0;
4361 TRACE2(("EISA detect Bus 0: hanum %d\n",
4362 NUMDATA(shp
)->hanum
));
4364 ha
->pccb
= CMDDATA(shp
);
4368 ha
->pscratch
= pci_alloc_consistent(ha
->pdev
, GDTH_SCRATCH
,
4369 &scratch_dma_handle
);
4370 ha
->scratch_phys
= scratch_dma_handle
;
4371 ha
->pmsg
= pci_alloc_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
4372 &scratch_dma_handle
);
4373 ha
->msg_phys
= scratch_dma_handle
;
4375 ha
->coal_stat
= (gdth_coal_status
*)
4376 pci_alloc_consistent(ha
->pdev
, sizeof(gdth_coal_status
) *
4377 MAXOFFSETS
, &scratch_dma_handle
);
4378 ha
->coal_stat_phys
= scratch_dma_handle
;
4381 pci_map_single(ha
->pdev
,ha
->pccb
,
4382 sizeof(gdth_cmd_str
),PCI_DMA_BIDIRECTIONAL
);
4383 ha
->scratch_busy
= FALSE
;
4384 ha
->req_first
= NULL
;
4385 ha
->tid_cnt
= MAX_HDRIVES
;
4386 if (max_ids
> 0 && max_ids
< ha
->tid_cnt
)
4387 ha
->tid_cnt
= max_ids
;
4388 for (i
=0; i
<GDTH_MAXCMDS
; ++i
)
4389 ha
->cmd_tab
[i
].cmnd
= UNUSED_CMND
;
4390 ha
->scan_mode
= rescan
? 0x10 : 0;
4392 if (ha
->pscratch
== NULL
|| ha
->pmsg
== NULL
||
4393 !gdth_search_drives(hanum
)) {
4394 printk("GDT-EISA: Error during device scan\n");
4399 pci_free_consistent(ha
->pdev
, sizeof(gdth_coal_status
) *
4400 MAXOFFSETS
, ha
->coal_stat
,
4401 ha
->coal_stat_phys
);
4404 pci_free_consistent(ha
->pdev
, GDTH_SCRATCH
,
4405 ha
->pscratch
, ha
->scratch_phys
);
4407 pci_free_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
4408 ha
->pmsg
, ha
->msg_phys
);
4410 pci_unmap_single(ha
->pdev
,ha
->ccb_phys
,
4411 sizeof(gdth_cmd_str
),PCI_DMA_BIDIRECTIONAL
);
4412 free_irq(ha
->irq
,ha
);
4413 scsi_unregister(shp
);
4416 if (hdr_channel
< 0 || hdr_channel
> ha
->bus_cnt
)
4417 hdr_channel
= ha
->bus_cnt
;
4418 ha
->virt_bus
= hdr_channel
;
4420 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20) && \
4421 LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
4422 shp
->highmem_io
= 0;
4424 if (ha
->cache_feat
& ha
->raw_feat
& ha
->screen_feat
& GDT_64BIT
)
4425 shp
->max_cmd_len
= 16;
4427 shp
->max_id
= ha
->tid_cnt
;
4428 shp
->max_lun
= MAXLUN
;
4429 shp
->max_channel
= virt_ctr
? 0 : ha
->bus_cnt
;
4432 /* register addit. SCSI channels as virtual controllers */
4433 for (b
= 1; b
< ha
->bus_cnt
+ 1; ++b
) {
4434 shp
= scsi_register(shtp
,sizeof(gdth_num_str
));
4435 shp
->unchecked_isa_dma
= 0;
4437 shp
->dma_channel
= 0xff;
4438 gdth_ctr_vtab
[gdth_ctr_vcount
++] = shp
;
4439 NUMDATA(shp
)->hanum
= (ushort
)hanum
;
4440 NUMDATA(shp
)->busnum
= b
;
4444 spin_lock_init(&ha
->smp_lock
);
4445 gdth_enable_int(hanum
);
4450 /* scanning for PCI controllers */
4451 cnt
= gdth_search_pci(pcistr
);
4452 printk("GDT-HA: Found %d PCI Storage RAID Controllers\n",cnt
);
4453 gdth_sort_pci(pcistr
,cnt
);
4454 for (ctr
= 0; ctr
< cnt
; ++ctr
) {
4455 dma_addr_t scratch_dma_handle
;
4456 scratch_dma_handle
= 0;
4458 if (gdth_ctr_count
>= MAXHA
)
4460 shp
= scsi_register(shtp
,sizeof(gdth_ext_str
));
4465 if (!gdth_init_pci(&pcistr
[ctr
],ha
)) {
4466 scsi_unregister(shp
);
4469 /* controller found and initialized */
4470 printk("Configuring GDT-PCI HA at %d/%d IRQ %u\n",
4471 pcistr
[ctr
].bus
,PCI_SLOT(pcistr
[ctr
].device_fn
),ha
->irq
);
4473 if (request_irq(ha
->irq
, gdth_interrupt
,
4474 SA_INTERRUPT
|SA_SHIRQ
, "gdth", ha
))
4476 printk("GDT-PCI: Unable to allocate IRQ\n");
4477 scsi_unregister(shp
);
4480 shp
->unchecked_isa_dma
= 0;
4482 shp
->dma_channel
= 0xff;
4483 hanum
= gdth_ctr_count
;
4484 gdth_ctr_tab
[gdth_ctr_count
++] = shp
;
4485 gdth_ctr_vtab
[gdth_ctr_vcount
++] = shp
;
4487 NUMDATA(shp
)->hanum
= (ushort
)hanum
;
4488 NUMDATA(shp
)->busnum
= 0;
4490 ha
->pccb
= CMDDATA(shp
);
4493 ha
->pscratch
= pci_alloc_consistent(ha
->pdev
, GDTH_SCRATCH
,
4494 &scratch_dma_handle
);
4495 ha
->scratch_phys
= scratch_dma_handle
;
4496 ha
->pmsg
= pci_alloc_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
4497 &scratch_dma_handle
);
4498 ha
->msg_phys
= scratch_dma_handle
;
4500 ha
->coal_stat
= (gdth_coal_status
*)
4501 pci_alloc_consistent(ha
->pdev
, sizeof(gdth_coal_status
) *
4502 MAXOFFSETS
, &scratch_dma_handle
);
4503 ha
->coal_stat_phys
= scratch_dma_handle
;
4505 ha
->scratch_busy
= FALSE
;
4506 ha
->req_first
= NULL
;
4507 ha
->tid_cnt
= pcistr
[ctr
].device_id
>= 0x200 ? MAXID
: MAX_HDRIVES
;
4508 if (max_ids
> 0 && max_ids
< ha
->tid_cnt
)
4509 ha
->tid_cnt
= max_ids
;
4510 for (i
=0; i
<GDTH_MAXCMDS
; ++i
)
4511 ha
->cmd_tab
[i
].cmnd
= UNUSED_CMND
;
4512 ha
->scan_mode
= rescan
? 0x10 : 0;
4515 if (ha
->pscratch
== NULL
|| ha
->pmsg
== NULL
||
4516 !gdth_search_drives(hanum
)) {
4519 if (hdr_channel
< 0 || hdr_channel
> ha
->bus_cnt
)
4520 hdr_channel
= ha
->bus_cnt
;
4521 ha
->virt_bus
= hdr_channel
;
4524 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
4525 scsi_set_pci_device(shp
, pcistr
[ctr
].pdev
);
4527 if (!(ha
->cache_feat
& ha
->raw_feat
& ha
->screen_feat
&GDT_64BIT
)||
4528 /* 64-bit DMA only supported from FW >= x.43 */
4529 (!ha
->dma64_support
)) {
4530 if (pci_set_dma_mask(pcistr
[ctr
].pdev
, 0xffffffff)) {
4531 printk(KERN_WARNING
"GDT-PCI %d: Unable to set 32-bit DMA\n", hanum
);
4535 shp
->max_cmd_len
= 16;
4536 if (!pci_set_dma_mask(pcistr
[ctr
].pdev
, 0xffffffffffffffffULL
)) {
4537 printk("GDT-PCI %d: 64-bit DMA enabled\n", hanum
);
4538 } else if (pci_set_dma_mask(pcistr
[ctr
].pdev
, 0xffffffff)) {
4539 printk(KERN_WARNING
"GDT-PCI %d: Unable to set 64/32-bit DMA\n", hanum
);
4546 printk("GDT-PCI %d: Error during device scan\n", hanum
);
4551 pci_free_consistent(ha
->pdev
, sizeof(gdth_coal_status
) *
4552 MAXOFFSETS
, ha
->coal_stat
,
4553 ha
->coal_stat_phys
);
4556 pci_free_consistent(ha
->pdev
, GDTH_SCRATCH
,
4557 ha
->pscratch
, ha
->scratch_phys
);
4559 pci_free_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
4560 ha
->pmsg
, ha
->msg_phys
);
4561 free_irq(ha
->irq
,ha
);
4562 scsi_unregister(shp
);
4566 shp
->max_id
= ha
->tid_cnt
;
4567 shp
->max_lun
= MAXLUN
;
4568 shp
->max_channel
= virt_ctr
? 0 : ha
->bus_cnt
;
4571 /* register addit. SCSI channels as virtual controllers */
4572 for (b
= 1; b
< ha
->bus_cnt
+ 1; ++b
) {
4573 shp
= scsi_register(shtp
,sizeof(gdth_num_str
));
4574 shp
->unchecked_isa_dma
= 0;
4576 shp
->dma_channel
= 0xff;
4577 gdth_ctr_vtab
[gdth_ctr_vcount
++] = shp
;
4578 NUMDATA(shp
)->hanum
= (ushort
)hanum
;
4579 NUMDATA(shp
)->busnum
= b
;
4583 spin_lock_init(&ha
->smp_lock
);
4584 gdth_enable_int(hanum
);
4587 TRACE2(("gdth_detect() %d controller detected\n",gdth_ctr_count
));
4588 if (gdth_ctr_count
> 0) {
4589 #ifdef GDTH_STATISTICS
4590 TRACE2(("gdth_detect(): Initializing timer !\n"));
4591 init_timer(&gdth_timer
);
4592 gdth_timer
.expires
= jiffies
+ HZ
;
4593 gdth_timer
.data
= 0L;
4594 gdth_timer
.function
= gdth_timeout
;
4595 add_timer(&gdth_timer
);
4597 major
= register_chrdev(0,"gdth",&gdth_fops
);
4598 register_reboot_notifier(&gdth_notifier
);
4600 gdth_polling
= FALSE
;
4601 return gdth_ctr_vcount
;
4605 static int gdth_release(struct Scsi_Host
*shp
)
4610 TRACE2(("gdth_release()\n"));
4611 if (NUMDATA(shp
)->busnum
== 0) {
4612 hanum
= NUMDATA(shp
)->hanum
;
4613 ha
= HADATA(gdth_ctr_tab
[hanum
]);
4615 scsi_free_host_dev(ha
->sdev
);
4621 free_irq(shp
->irq
,ha
);
4624 if (shp
->dma_channel
!= 0xff) {
4625 free_dma(shp
->dma_channel
);
4630 pci_free_consistent(ha
->pdev
, sizeof(gdth_coal_status
) *
4631 MAXOFFSETS
, ha
->coal_stat
, ha
->coal_stat_phys
);
4634 pci_free_consistent(ha
->pdev
, GDTH_SCRATCH
,
4635 ha
->pscratch
, ha
->scratch_phys
);
4637 pci_free_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
4638 ha
->pmsg
, ha
->msg_phys
);
4640 pci_unmap_single(ha
->pdev
,ha
->ccb_phys
,
4641 sizeof(gdth_cmd_str
),PCI_DMA_BIDIRECTIONAL
);
4642 gdth_ctr_released
++;
4643 TRACE2(("gdth_release(): HA %d of %d\n",
4644 gdth_ctr_released
, gdth_ctr_count
));
4646 if (gdth_ctr_released
== gdth_ctr_count
) {
4647 #ifdef GDTH_STATISTICS
4648 del_timer(&gdth_timer
);
4650 unregister_chrdev(major
,"gdth");
4651 unregister_reboot_notifier(&gdth_notifier
);
4655 scsi_unregister(shp
);
4660 static const char *gdth_ctr_name(int hanum
)
4664 TRACE2(("gdth_ctr_name()\n"));
4666 ha
= HADATA(gdth_ctr_tab
[hanum
]);
4668 if (ha
->type
== GDT_EISA
) {
4669 switch (ha
->stype
) {
4671 return("GDT3000/3020");
4673 return("GDT3000A/3020A/3050A");
4675 return("GDT3000B/3010A");
4677 } else if (ha
->type
== GDT_ISA
) {
4678 return("GDT2000/2020");
4679 } else if (ha
->type
== GDT_PCI
) {
4680 switch (ha
->stype
) {
4681 case PCI_DEVICE_ID_VORTEX_GDT60x0
:
4682 return("GDT6000/6020/6050");
4683 case PCI_DEVICE_ID_VORTEX_GDT6000B
:
4684 return("GDT6000B/6010");
4687 /* new controllers (GDT_PCINEW, GDT_PCIMPR, ..) use board_info IOCTL! */
4692 static const char *gdth_info(struct Scsi_Host
*shp
)
4697 TRACE2(("gdth_info()\n"));
4698 hanum
= NUMDATA(shp
)->hanum
;
4699 ha
= HADATA(gdth_ctr_tab
[hanum
]);
4701 return ((const char *)ha
->binfo
.type_string
);
4704 static int gdth_eh_bus_reset(Scsi_Cmnd
*scp
)
4712 TRACE2(("gdth_eh_bus_reset()\n"));
4714 hanum
= NUMDATA(scp
->device
->host
)->hanum
;
4715 b
= virt_ctr
? NUMDATA(scp
->device
->host
)->busnum
: scp
->device
->channel
;
4716 ha
= HADATA(gdth_ctr_tab
[hanum
]);
4718 /* clear command tab */
4719 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4720 for (i
= 0; i
< GDTH_MAXCMDS
; ++i
) {
4721 cmnd
= ha
->cmd_tab
[i
].cmnd
;
4722 if (!SPECIAL_SCP(cmnd
) && cmnd
->device
->channel
== b
)
4723 ha
->cmd_tab
[i
].cmnd
= UNUSED_CMND
;
4725 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4727 if (b
== ha
->virt_bus
) {
4729 for (i
= 0; i
< MAX_HDRIVES
; ++i
) {
4730 if (ha
->hdr
[i
].present
) {
4731 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4732 gdth_polling
= TRUE
;
4733 while (gdth_test_busy(hanum
))
4735 if (gdth_internal_cmd(hanum
, CACHESERVICE
,
4736 GDT_CLUST_RESET
, i
, 0, 0))
4737 ha
->hdr
[i
].cluster_type
&= ~CLUSTER_RESERVED
;
4738 gdth_polling
= FALSE
;
4739 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4744 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4745 for (i
= 0; i
< MAXID
; ++i
)
4746 ha
->raw
[BUS_L2P(ha
,b
)].io_cnt
[i
] = 0;
4747 gdth_polling
= TRUE
;
4748 while (gdth_test_busy(hanum
))
4750 gdth_internal_cmd(hanum
, SCSIRAWSERVICE
, GDT_RESET_BUS
,
4751 BUS_L2P(ha
,b
), 0, 0);
4752 gdth_polling
= FALSE
;
4753 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4758 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
4759 static int gdth_bios_param(struct scsi_device
*sdev
,struct block_device
*bdev
,sector_t cap
,int *ip
)
4761 static int gdth_bios_param(Disk
*disk
,kdev_t dev
,int *ip
)
4767 struct scsi_device
*sd
;
4770 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
4775 capacity
= disk
->capacity
;
4777 hanum
= NUMDATA(sd
->host
)->hanum
;
4778 b
= virt_ctr
? NUMDATA(sd
->host
)->busnum
: sd
->channel
;
4780 TRACE2(("gdth_bios_param() ha %d bus %d target %d\n", hanum
, b
, t
));
4781 ha
= HADATA(gdth_ctr_tab
[hanum
]);
4783 if (b
!= ha
->virt_bus
|| ha
->hdr
[t
].heads
== 0) {
4784 /* raw device or host drive without mapping information */
4785 TRACE2(("Evaluate mapping\n"));
4786 gdth_eval_mapping(capacity
,&ip
[2],&ip
[0],&ip
[1]);
4788 ip
[0] = ha
->hdr
[t
].heads
;
4789 ip
[1] = ha
->hdr
[t
].secs
;
4790 ip
[2] = capacity
/ ip
[0] / ip
[1];
4793 TRACE2(("gdth_bios_param(): %d heads, %d secs, %d cyls\n",
4794 ip
[0],ip
[1],ip
[2]));
4799 static int gdth_queuecommand(Scsi_Cmnd
*scp
,void (*done
)(Scsi_Cmnd
*))
4804 TRACE(("gdth_queuecommand() cmd 0x%x\n", scp
->cmnd
[0]));
4806 scp
->scsi_done
= (void *)done
;
4807 scp
->SCp
.have_data_in
= 1;
4808 scp
->SCp
.phase
= -1;
4809 scp
->SCp
.sent_command
= -1;
4810 scp
->SCp
.Status
= GDTH_MAP_NONE
;
4811 scp
->SCp
.buffer
= (struct scatterlist
*)NULL
;
4813 hanum
= NUMDATA(scp
->device
->host
)->hanum
;
4814 #ifdef GDTH_STATISTICS
4818 priority
= DEFAULT_PRI
;
4819 if (scp
->done
== gdth_scsi_done
)
4820 priority
= scp
->SCp
.this_residual
;
4821 gdth_update_timeout(hanum
, scp
, scp
->timeout_per_command
* 6);
4822 gdth_putq( hanum
, scp
, priority
);
4828 static int gdth_open(struct inode
*inode
, struct file
*filep
)
4833 for (i
= 0; i
< gdth_ctr_count
; i
++) {
4834 ha
= HADATA(gdth_ctr_tab
[i
]);
4836 ha
->sdev
= scsi_get_host_dev(gdth_ctr_tab
[i
]);
4839 TRACE(("gdth_open()\n"));
4843 static int gdth_close(struct inode
*inode
, struct file
*filep
)
4845 TRACE(("gdth_close()\n"));
4849 static int ioc_event(void __user
*arg
)
4851 gdth_ioctl_event evt
;
4855 if (copy_from_user(&evt
, arg
, sizeof(gdth_ioctl_event
)) ||
4856 evt
.ionode
>= gdth_ctr_count
)
4858 ha
= HADATA(gdth_ctr_tab
[evt
.ionode
]);
4860 if (evt
.erase
== 0xff) {
4861 if (evt
.event
.event_source
== ES_TEST
)
4862 evt
.event
.event_data
.size
=sizeof(evt
.event
.event_data
.eu
.test
);
4863 else if (evt
.event
.event_source
== ES_DRIVER
)
4864 evt
.event
.event_data
.size
=sizeof(evt
.event
.event_data
.eu
.driver
);
4865 else if (evt
.event
.event_source
== ES_SYNC
)
4866 evt
.event
.event_data
.size
=sizeof(evt
.event
.event_data
.eu
.sync
);
4868 evt
.event
.event_data
.size
=sizeof(evt
.event
.event_data
.eu
.async
);
4869 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4870 gdth_store_event(ha
, evt
.event
.event_source
, evt
.event
.event_idx
,
4871 &evt
.event
.event_data
);
4872 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4873 } else if (evt
.erase
== 0xfe) {
4874 gdth_clear_events();
4875 } else if (evt
.erase
== 0) {
4876 evt
.handle
= gdth_read_event(ha
, evt
.handle
, &evt
.event
);
4878 gdth_readapp_event(ha
, evt
.erase
, &evt
.event
);
4880 if (copy_to_user(arg
, &evt
, sizeof(gdth_ioctl_event
)))
4885 static int ioc_lockdrv(void __user
*arg
)
4887 gdth_ioctl_lockdrv ldrv
;
4892 if (copy_from_user(&ldrv
, arg
, sizeof(gdth_ioctl_lockdrv
)) ||
4893 ldrv
.ionode
>= gdth_ctr_count
)
4895 ha
= HADATA(gdth_ctr_tab
[ldrv
.ionode
]);
4897 for (i
= 0; i
< ldrv
.drive_cnt
&& i
< MAX_HDRIVES
; ++i
) {
4899 if (j
>= MAX_HDRIVES
|| !ha
->hdr
[j
].present
)
4902 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4903 ha
->hdr
[j
].lock
= 1;
4904 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4905 gdth_wait_completion(ldrv
.ionode
, ha
->bus_cnt
, j
);
4906 gdth_stop_timeout(ldrv
.ionode
, ha
->bus_cnt
, j
);
4908 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4909 ha
->hdr
[j
].lock
= 0;
4910 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4911 gdth_start_timeout(ldrv
.ionode
, ha
->bus_cnt
, j
);
4912 gdth_next(ldrv
.ionode
);
4918 static int ioc_resetdrv(void __user
*arg
, char *cmnd
)
4920 gdth_ioctl_reset res
;
4924 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
4930 if (copy_from_user(&res
, arg
, sizeof(gdth_ioctl_reset
)) ||
4931 res
.ionode
>= gdth_ctr_count
|| res
.number
>= MAX_HDRIVES
)
4934 ha
= HADATA(gdth_ctr_tab
[hanum
]);
4936 if (!ha
->hdr
[res
.number
].present
)
4938 memset(&cmd
, 0, sizeof(gdth_cmd_str
));
4939 cmd
.Service
= CACHESERVICE
;
4940 cmd
.OpCode
= GDT_CLUST_RESET
;
4941 if (ha
->cache_feat
& GDT_64BIT
)
4942 cmd
.u
.cache64
.DeviceNo
= res
.number
;
4944 cmd
.u
.cache
.DeviceNo
= res
.number
;
4945 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
4946 srp
= scsi_allocate_request(ha
->sdev
, GFP_KERNEL
);
4949 srp
->sr_cmd_len
= 12;
4951 gdth_do_req(srp
, &cmd
, cmnd
, 30);
4952 res
.status
= (ushort
)srp
->sr_command
->SCp
.Status
;
4953 scsi_release_request(srp
);
4955 scp
= scsi_allocate_device(ha
->sdev
, 1, FALSE
);
4960 gdth_do_cmd(scp
, &cmd
, cmnd
, 30);
4961 res
.status
= (ushort
)scp
->SCp
.Status
;
4962 scsi_release_command(scp
);
4965 if (copy_to_user(arg
, &res
, sizeof(gdth_ioctl_reset
)))
4970 static int ioc_general(void __user
*arg
, char *cmnd
)
4972 gdth_ioctl_general gen
;
4977 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
4983 if (copy_from_user(&gen
, arg
, sizeof(gdth_ioctl_general
)) ||
4984 gen
.ionode
>= gdth_ctr_count
)
4987 ha
= HADATA(gdth_ctr_tab
[hanum
]);
4988 if (gen
.data_len
+ gen
.sense_len
!= 0) {
4989 if (!(buf
= gdth_ioctl_alloc(hanum
, gen
.data_len
+ gen
.sense_len
,
4992 if (copy_from_user(buf
, arg
+ sizeof(gdth_ioctl_general
),
4993 gen
.data_len
+ gen
.sense_len
)) {
4994 gdth_ioctl_free(hanum
, gen
.data_len
+gen
.sense_len
, buf
, paddr
);
4998 if (gen
.command
.OpCode
== GDT_IOCTL
) {
4999 gen
.command
.u
.ioctl
.p_param
= paddr
;
5000 } else if (gen
.command
.Service
== CACHESERVICE
) {
5001 if (ha
->cache_feat
& GDT_64BIT
) {
5002 /* copy elements from 32-bit IOCTL structure */
5003 gen
.command
.u
.cache64
.BlockCnt
= gen
.command
.u
.cache
.BlockCnt
;
5004 gen
.command
.u
.cache64
.BlockNo
= gen
.command
.u
.cache
.BlockNo
;
5005 gen
.command
.u
.cache64
.DeviceNo
= gen
.command
.u
.cache
.DeviceNo
;
5007 if (ha
->cache_feat
& SCATTER_GATHER
) {
5008 gen
.command
.u
.cache64
.DestAddr
= (ulong64
)-1;
5009 gen
.command
.u
.cache64
.sg_canz
= 1;
5010 gen
.command
.u
.cache64
.sg_lst
[0].sg_ptr
= paddr
;
5011 gen
.command
.u
.cache64
.sg_lst
[0].sg_len
= gen
.data_len
;
5012 gen
.command
.u
.cache64
.sg_lst
[1].sg_len
= 0;
5014 gen
.command
.u
.cache64
.DestAddr
= paddr
;
5015 gen
.command
.u
.cache64
.sg_canz
= 0;
5018 if (ha
->cache_feat
& SCATTER_GATHER
) {
5019 gen
.command
.u
.cache
.DestAddr
= 0xffffffff;
5020 gen
.command
.u
.cache
.sg_canz
= 1;
5021 gen
.command
.u
.cache
.sg_lst
[0].sg_ptr
= (ulong32
)paddr
;
5022 gen
.command
.u
.cache
.sg_lst
[0].sg_len
= gen
.data_len
;
5023 gen
.command
.u
.cache
.sg_lst
[1].sg_len
= 0;
5025 gen
.command
.u
.cache
.DestAddr
= paddr
;
5026 gen
.command
.u
.cache
.sg_canz
= 0;
5029 } else if (gen
.command
.Service
== SCSIRAWSERVICE
) {
5030 if (ha
->raw_feat
& GDT_64BIT
) {
5031 /* copy elements from 32-bit IOCTL structure */
5033 gen
.command
.u
.raw64
.sense_len
= gen
.command
.u
.raw
.sense_len
;
5034 gen
.command
.u
.raw64
.bus
= gen
.command
.u
.raw
.bus
;
5035 gen
.command
.u
.raw64
.lun
= gen
.command
.u
.raw
.lun
;
5036 gen
.command
.u
.raw64
.target
= gen
.command
.u
.raw
.target
;
5037 memcpy(cmd
, gen
.command
.u
.raw
.cmd
, 16);
5038 memcpy(gen
.command
.u
.raw64
.cmd
, cmd
, 16);
5039 gen
.command
.u
.raw64
.clen
= gen
.command
.u
.raw
.clen
;
5040 gen
.command
.u
.raw64
.sdlen
= gen
.command
.u
.raw
.sdlen
;
5041 gen
.command
.u
.raw64
.direction
= gen
.command
.u
.raw
.direction
;
5043 if (ha
->raw_feat
& SCATTER_GATHER
) {
5044 gen
.command
.u
.raw64
.sdata
= (ulong64
)-1;
5045 gen
.command
.u
.raw64
.sg_ranz
= 1;
5046 gen
.command
.u
.raw64
.sg_lst
[0].sg_ptr
= paddr
;
5047 gen
.command
.u
.raw64
.sg_lst
[0].sg_len
= gen
.data_len
;
5048 gen
.command
.u
.raw64
.sg_lst
[1].sg_len
= 0;
5050 gen
.command
.u
.raw64
.sdata
= paddr
;
5051 gen
.command
.u
.raw64
.sg_ranz
= 0;
5053 gen
.command
.u
.raw64
.sense_data
= paddr
+ gen
.data_len
;
5055 if (ha
->raw_feat
& SCATTER_GATHER
) {
5056 gen
.command
.u
.raw
.sdata
= 0xffffffff;
5057 gen
.command
.u
.raw
.sg_ranz
= 1;
5058 gen
.command
.u
.raw
.sg_lst
[0].sg_ptr
= (ulong32
)paddr
;
5059 gen
.command
.u
.raw
.sg_lst
[0].sg_len
= gen
.data_len
;
5060 gen
.command
.u
.raw
.sg_lst
[1].sg_len
= 0;
5062 gen
.command
.u
.raw
.sdata
= paddr
;
5063 gen
.command
.u
.raw
.sg_ranz
= 0;
5065 gen
.command
.u
.raw
.sense_data
= (ulong32
)paddr
+ gen
.data_len
;
5068 gdth_ioctl_free(hanum
, gen
.data_len
+gen
.sense_len
, buf
, paddr
);
5073 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5074 srp
= scsi_allocate_request(ha
->sdev
, GFP_KERNEL
);
5077 srp
->sr_cmd_len
= 12;
5079 gdth_do_req(srp
, &gen
.command
, cmnd
, gen
.timeout
);
5080 gen
.status
= srp
->sr_command
->SCp
.Status
;
5081 gen
.info
= srp
->sr_command
->SCp
.Message
;
5082 scsi_release_request(srp
);
5084 scp
= scsi_allocate_device(ha
->sdev
, 1, FALSE
);
5089 gdth_do_cmd(scp
, &gen
.command
, cmnd
, gen
.timeout
);
5090 gen
.status
= scp
->SCp
.Status
;
5091 gen
.info
= scp
->SCp
.Message
;
5092 scsi_release_command(scp
);
5095 if (copy_to_user(arg
+ sizeof(gdth_ioctl_general
), buf
,
5096 gen
.data_len
+ gen
.sense_len
)) {
5097 gdth_ioctl_free(hanum
, gen
.data_len
+gen
.sense_len
, buf
, paddr
);
5100 if (copy_to_user(arg
, &gen
,
5101 sizeof(gdth_ioctl_general
) - sizeof(gdth_cmd_str
))) {
5102 gdth_ioctl_free(hanum
, gen
.data_len
+gen
.sense_len
, buf
, paddr
);
5105 gdth_ioctl_free(hanum
, gen
.data_len
+gen
.sense_len
, buf
, paddr
);
5109 static int ioc_hdrlist(void __user
*arg
, char *cmnd
)
5111 gdth_ioctl_rescan
*rsc
;
5115 int hanum
, rc
= -ENOMEM
;
5116 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5122 rsc
= kmalloc(sizeof(*rsc
), GFP_KERNEL
);
5123 cmd
= kmalloc(sizeof(*cmd
), GFP_KERNEL
);
5127 if (copy_from_user(rsc
, arg
, sizeof(gdth_ioctl_rescan
)) ||
5128 rsc
->ionode
>= gdth_ctr_count
) {
5132 hanum
= rsc
->ionode
;
5133 ha
= HADATA(gdth_ctr_tab
[hanum
]);
5134 memset(cmd
, 0, sizeof(gdth_cmd_str
));
5136 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5137 srp
= scsi_allocate_request(ha
->sdev
, GFP_KERNEL
);
5140 srp
->sr_cmd_len
= 12;
5143 scp
= scsi_allocate_device(ha
->sdev
, 1, FALSE
);
5150 for (i
= 0; i
< MAX_HDRIVES
; ++i
) {
5151 if (!ha
->hdr
[i
].present
) {
5152 rsc
->hdr_list
[i
].bus
= 0xff;
5155 rsc
->hdr_list
[i
].bus
= ha
->virt_bus
;
5156 rsc
->hdr_list
[i
].target
= i
;
5157 rsc
->hdr_list
[i
].lun
= 0;
5158 rsc
->hdr_list
[i
].cluster_type
= ha
->hdr
[i
].cluster_type
;
5159 if (ha
->hdr
[i
].cluster_type
& CLUSTER_DRIVE
) {
5160 cmd
->Service
= CACHESERVICE
;
5161 cmd
->OpCode
= GDT_CLUST_INFO
;
5162 if (ha
->cache_feat
& GDT_64BIT
)
5163 cmd
->u
.cache64
.DeviceNo
= i
;
5165 cmd
->u
.cache
.DeviceNo
= i
;
5166 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5167 gdth_do_req(srp
, cmd
, cmnd
, 30);
5168 if (srp
->sr_command
->SCp
.Status
== S_OK
)
5169 rsc
->hdr_list
[i
].cluster_type
= srp
->sr_command
->SCp
.Message
;
5171 gdth_do_cmd(scp
, cmd
, cmnd
, 30);
5172 if (scp
->SCp
.Status
== S_OK
)
5173 rsc
->hdr_list
[i
].cluster_type
= scp
->SCp
.Message
;
5177 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5178 scsi_release_request(srp
);
5180 scsi_release_command(scp
);
5183 if (copy_to_user(arg
, rsc
, sizeof(gdth_ioctl_rescan
)))
5194 static int ioc_rescan(void __user
*arg
, char *cmnd
)
5196 gdth_ioctl_rescan
*rsc
;
5198 ushort i
, status
, hdr_cnt
;
5200 int hanum
, cyls
, hds
, secs
;
5204 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5210 rsc
= kmalloc(sizeof(*rsc
), GFP_KERNEL
);
5211 cmd
= kmalloc(sizeof(*cmd
), GFP_KERNEL
);
5215 if (copy_from_user(rsc
, arg
, sizeof(gdth_ioctl_rescan
)) ||
5216 rsc
->ionode
>= gdth_ctr_count
) {
5220 hanum
= rsc
->ionode
;
5221 ha
= HADATA(gdth_ctr_tab
[hanum
]);
5222 memset(cmd
, 0, sizeof(gdth_cmd_str
));
5224 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5225 srp
= scsi_allocate_request(ha
->sdev
, GFP_KERNEL
);
5228 srp
->sr_cmd_len
= 12;
5231 scp
= scsi_allocate_device(ha
->sdev
, 1, FALSE
);
5238 if (rsc
->flag
== 0) {
5239 /* old method: re-init. cache service */
5240 cmd
->Service
= CACHESERVICE
;
5241 if (ha
->cache_feat
& GDT_64BIT
) {
5242 cmd
->OpCode
= GDT_X_INIT_HOST
;
5243 cmd
->u
.cache64
.DeviceNo
= LINUX_OS
;
5245 cmd
->OpCode
= GDT_INIT
;
5246 cmd
->u
.cache
.DeviceNo
= LINUX_OS
;
5248 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5249 gdth_do_req(srp
, cmd
, cmnd
, 30);
5250 status
= (ushort
)srp
->sr_command
->SCp
.Status
;
5251 info
= (ulong32
)srp
->sr_command
->SCp
.Message
;
5252 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
5253 gdth_do_cmd(scp
, cmd
, cmnd
, 30);
5254 status
= (ushort
)scp
->SCp
.Status
;
5255 info
= (ulong32
)scp
->SCp
.Message
;
5257 gdth_do_cmd(&scp
, cmd
, cmnd
, 30);
5258 status
= (ushort
)scp
.SCp
.Status
;
5259 info
= (ulong32
)scp
.SCp
.Message
;
5262 hdr_cnt
= (status
== S_OK
? (ushort
)info
: 0);
5268 for (; i
< hdr_cnt
&& i
< MAX_HDRIVES
; ++i
) {
5269 cmd
->Service
= CACHESERVICE
;
5270 cmd
->OpCode
= GDT_INFO
;
5271 if (ha
->cache_feat
& GDT_64BIT
)
5272 cmd
->u
.cache64
.DeviceNo
= i
;
5274 cmd
->u
.cache
.DeviceNo
= i
;
5275 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5276 gdth_do_req(srp
, cmd
, cmnd
, 30);
5277 status
= (ushort
)srp
->sr_command
->SCp
.Status
;
5278 info
= (ulong32
)srp
->sr_command
->SCp
.Message
;
5280 gdth_do_cmd(scp
, cmd
, cmnd
, 30);
5281 status
= (ushort
)scp
->SCp
.Status
;
5282 info
= (ulong32
)scp
->SCp
.Message
;
5284 spin_lock_irqsave(&ha
->smp_lock
, flags
);
5285 rsc
->hdr_list
[i
].bus
= ha
->virt_bus
;
5286 rsc
->hdr_list
[i
].target
= i
;
5287 rsc
->hdr_list
[i
].lun
= 0;
5288 if (status
!= S_OK
) {
5289 ha
->hdr
[i
].present
= FALSE
;
5291 ha
->hdr
[i
].present
= TRUE
;
5292 ha
->hdr
[i
].size
= info
;
5293 /* evaluate mapping */
5294 ha
->hdr
[i
].size
&= ~SECS32
;
5295 gdth_eval_mapping(ha
->hdr
[i
].size
,&cyls
,&hds
,&secs
);
5296 ha
->hdr
[i
].heads
= hds
;
5297 ha
->hdr
[i
].secs
= secs
;
5299 ha
->hdr
[i
].size
= cyls
* hds
* secs
;
5301 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
5305 /* extended info, if GDT_64BIT, for drives > 2 TB */
5306 /* but we need ha->info2, not yet stored in scp->SCp */
5308 /* devtype, cluster info, R/W attribs */
5309 cmd
->Service
= CACHESERVICE
;
5310 cmd
->OpCode
= GDT_DEVTYPE
;
5311 if (ha
->cache_feat
& GDT_64BIT
)
5312 cmd
->u
.cache64
.DeviceNo
= i
;
5314 cmd
->u
.cache
.DeviceNo
= i
;
5315 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5316 gdth_do_req(srp
, cmd
, cmnd
, 30);
5317 status
= (ushort
)srp
->sr_command
->SCp
.Status
;
5318 info
= (ulong32
)srp
->sr_command
->SCp
.Message
;
5320 gdth_do_cmd(scp
, cmd
, cmnd
, 30);
5321 status
= (ushort
)scp
->SCp
.Status
;
5322 info
= (ulong32
)scp
->SCp
.Message
;
5324 spin_lock_irqsave(&ha
->smp_lock
, flags
);
5325 ha
->hdr
[i
].devtype
= (status
== S_OK
? (ushort
)info
: 0);
5326 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
5328 cmd
->Service
= CACHESERVICE
;
5329 cmd
->OpCode
= GDT_CLUST_INFO
;
5330 if (ha
->cache_feat
& GDT_64BIT
)
5331 cmd
->u
.cache64
.DeviceNo
= i
;
5333 cmd
->u
.cache
.DeviceNo
= i
;
5334 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5335 gdth_do_req(srp
, cmd
, cmnd
, 30);
5336 status
= (ushort
)srp
->sr_command
->SCp
.Status
;
5337 info
= (ulong32
)srp
->sr_command
->SCp
.Message
;
5339 gdth_do_cmd(scp
, cmd
, cmnd
, 30);
5340 status
= (ushort
)scp
->SCp
.Status
;
5341 info
= (ulong32
)scp
->SCp
.Message
;
5343 spin_lock_irqsave(&ha
->smp_lock
, flags
);
5344 ha
->hdr
[i
].cluster_type
=
5345 ((status
== S_OK
&& !shared_access
) ? (ushort
)info
: 0);
5346 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
5347 rsc
->hdr_list
[i
].cluster_type
= ha
->hdr
[i
].cluster_type
;
5349 cmd
->Service
= CACHESERVICE
;
5350 cmd
->OpCode
= GDT_RW_ATTRIBS
;
5351 if (ha
->cache_feat
& GDT_64BIT
)
5352 cmd
->u
.cache64
.DeviceNo
= i
;
5354 cmd
->u
.cache
.DeviceNo
= i
;
5355 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5356 gdth_do_req(srp
, cmd
, cmnd
, 30);
5357 status
= (ushort
)srp
->sr_command
->SCp
.Status
;
5358 info
= (ulong32
)srp
->sr_command
->SCp
.Message
;
5360 gdth_do_cmd(scp
, cmd
, cmnd
, 30);
5361 status
= (ushort
)scp
->SCp
.Status
;
5362 info
= (ulong32
)scp
->SCp
.Message
;
5364 spin_lock_irqsave(&ha
->smp_lock
, flags
);
5365 ha
->hdr
[i
].rw_attribs
= (status
== S_OK
? (ushort
)info
: 0);
5366 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
5368 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5369 scsi_release_request(srp
);
5371 scsi_release_command(scp
);
5374 if (copy_to_user(arg
, rsc
, sizeof(gdth_ioctl_rescan
)))
5385 static int gdth_ioctl(struct inode
*inode
, struct file
*filep
,
5386 unsigned int cmd
, unsigned long arg
)
5391 char cmnd
[MAX_COMMAND_SIZE
];
5392 void __user
*argp
= (void __user
*)arg
;
5394 memset(cmnd
, 0xff, 12);
5396 TRACE(("gdth_ioctl() cmd 0x%x\n", cmd
));
5399 case GDTIOCTL_CTRCNT
:
5401 int cnt
= gdth_ctr_count
;
5402 if (put_user(cnt
, (int __user
*)argp
))
5407 case GDTIOCTL_DRVERS
:
5409 int ver
= (GDTH_VERSION
<<8) | GDTH_SUBVERSION
;
5410 if (put_user(ver
, (int __user
*)argp
))
5415 case GDTIOCTL_OSVERS
:
5417 gdth_ioctl_osvers osv
;
5419 osv
.version
= (unchar
)(LINUX_VERSION_CODE
>> 16);
5420 osv
.subversion
= (unchar
)(LINUX_VERSION_CODE
>> 8);
5421 osv
.revision
= (ushort
)(LINUX_VERSION_CODE
& 0xff);
5422 if (copy_to_user(argp
, &osv
, sizeof(gdth_ioctl_osvers
)))
5427 case GDTIOCTL_CTRTYPE
:
5429 gdth_ioctl_ctrtype ctrt
;
5431 if (copy_from_user(&ctrt
, argp
, sizeof(gdth_ioctl_ctrtype
)) ||
5432 ctrt
.ionode
>= gdth_ctr_count
)
5434 ha
= HADATA(gdth_ctr_tab
[ctrt
.ionode
]);
5435 if (ha
->type
== GDT_ISA
|| ha
->type
== GDT_EISA
) {
5436 ctrt
.type
= (unchar
)((ha
->stype
>>20) - 0x10);
5438 if (ha
->type
!= GDT_PCIMPR
) {
5439 ctrt
.type
= (unchar
)((ha
->stype
<<4) + 6);
5442 (ha
->oem_id
== OEM_ID_INTEL
? 0xfd : 0xfe);
5443 if (ha
->stype
>= 0x300)
5444 ctrt
.ext_type
= 0x6000 | ha
->subdevice_id
;
5446 ctrt
.ext_type
= 0x6000 | ha
->stype
;
5448 ctrt
.device_id
= ha
->stype
;
5449 ctrt
.sub_device_id
= ha
->subdevice_id
;
5451 ctrt
.info
= ha
->brd_phys
;
5452 ctrt
.oem_id
= ha
->oem_id
;
5453 if (copy_to_user(argp
, &ctrt
, sizeof(gdth_ioctl_ctrtype
)))
5458 case GDTIOCTL_GENERAL
:
5459 return ioc_general(argp
, cmnd
);
5461 case GDTIOCTL_EVENT
:
5462 return ioc_event(argp
);
5464 case GDTIOCTL_LOCKDRV
:
5465 return ioc_lockdrv(argp
);
5467 case GDTIOCTL_LOCKCHN
:
5469 gdth_ioctl_lockchn lchn
;
5472 if (copy_from_user(&lchn
, argp
, sizeof(gdth_ioctl_lockchn
)) ||
5473 lchn
.ionode
>= gdth_ctr_count
)
5475 ha
= HADATA(gdth_ctr_tab
[lchn
.ionode
]);
5478 if (i
< ha
->bus_cnt
) {
5480 spin_lock_irqsave(&ha
->smp_lock
, flags
);
5481 ha
->raw
[i
].lock
= 1;
5482 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
5483 for (j
= 0; j
< ha
->tid_cnt
; ++j
) {
5484 gdth_wait_completion(lchn
.ionode
, i
, j
);
5485 gdth_stop_timeout(lchn
.ionode
, i
, j
);
5488 spin_lock_irqsave(&ha
->smp_lock
, flags
);
5489 ha
->raw
[i
].lock
= 0;
5490 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
5491 for (j
= 0; j
< ha
->tid_cnt
; ++j
) {
5492 gdth_start_timeout(lchn
.ionode
, i
, j
);
5493 gdth_next(lchn
.ionode
);
5500 case GDTIOCTL_RESCAN
:
5501 return ioc_rescan(argp
, cmnd
);
5503 case GDTIOCTL_HDRLIST
:
5504 return ioc_hdrlist(argp
, cmnd
);
5506 case GDTIOCTL_RESET_BUS
:
5508 gdth_ioctl_reset res
;
5511 if (copy_from_user(&res
, argp
, sizeof(gdth_ioctl_reset
)) ||
5512 res
.ionode
>= gdth_ctr_count
)
5515 ha
= HADATA(gdth_ctr_tab
[hanum
]);
5517 /* Because we need a Scsi_Cmnd struct., we make a scsi_allocate device also for kernels >=2.6.x */
5518 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5519 scp
= scsi_get_command(ha
->sdev
, GFP_KERNEL
);
5524 scp
->device
->channel
= virt_ctr
? 0 : res
.number
;
5525 rval
= gdth_eh_bus_reset(scp
);
5526 res
.status
= (rval
== SUCCESS
? S_OK
: S_GENERR
);
5527 scsi_put_command(scp
);
5529 scp
= scsi_allocate_device(ha
->sdev
, 1, FALSE
);
5534 scp
->channel
= virt_ctr
? 0 : res
.number
;
5535 rval
= gdth_eh_bus_reset(scp
);
5536 res
.status
= (rval
== SUCCESS
? S_OK
: S_GENERR
);
5537 scsi_release_command(scp
);
5539 if (copy_to_user(argp
, &res
, sizeof(gdth_ioctl_reset
)))
5544 case GDTIOCTL_RESET_DRV
:
5545 return ioc_resetdrv(argp
, cmnd
);
5555 static void gdth_flush(int hanum
)
5559 gdth_cmd_str gdtcmd
;
5560 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5565 struct scsi_device
*sdev
;
5566 char cmnd
[MAX_COMMAND_SIZE
];
5567 memset(cmnd
, 0xff, MAX_COMMAND_SIZE
);
5569 TRACE2(("gdth_flush() hanum %d\n",hanum
));
5570 ha
= HADATA(gdth_ctr_tab
[hanum
]);
5572 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5573 sdev
= scsi_get_host_dev(gdth_ctr_tab
[hanum
]);
5574 srp
= scsi_allocate_request(sdev
, GFP_KERNEL
);
5577 srp
->sr_cmd_len
= 12;
5580 sdev
= scsi_get_host_dev(gdth_ctr_tab
[hanum
]);
5581 scp
= scsi_allocate_device(sdev
, 1, FALSE
);
5588 for (i
= 0; i
< MAX_HDRIVES
; ++i
) {
5589 if (ha
->hdr
[i
].present
) {
5590 gdtcmd
.BoardNode
= LOCALBOARD
;
5591 gdtcmd
.Service
= CACHESERVICE
;
5592 gdtcmd
.OpCode
= GDT_FLUSH
;
5593 if (ha
->cache_feat
& GDT_64BIT
) {
5594 gdtcmd
.u
.cache64
.DeviceNo
= i
;
5595 gdtcmd
.u
.cache64
.BlockNo
= 1;
5596 gdtcmd
.u
.cache64
.sg_canz
= 0;
5598 gdtcmd
.u
.cache
.DeviceNo
= i
;
5599 gdtcmd
.u
.cache
.BlockNo
= 1;
5600 gdtcmd
.u
.cache
.sg_canz
= 0;
5602 TRACE2(("gdth_flush(): flush ha %d drive %d\n", hanum
, i
));
5603 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5604 gdth_do_req(srp
, &gdtcmd
, cmnd
, 30);
5606 gdth_do_cmd(scp
, &gdtcmd
, cmnd
, 30);
5610 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5611 scsi_release_request(srp
);
5612 scsi_free_host_dev(sdev
);
5614 scsi_release_command(scp
);
5615 scsi_free_host_dev(sdev
);
5619 /* shutdown routine */
5620 static int gdth_halt(struct notifier_block
*nb
, ulong event
, void *buf
)
5624 gdth_cmd_str gdtcmd
;
5625 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5627 struct scsi_device
*sdev
;
5630 struct scsi_device
*sdev
;
5632 char cmnd
[MAX_COMMAND_SIZE
];
5635 TRACE2(("gdth_halt() event %d\n",(int)event
));
5636 if (event
!= SYS_RESTART
&& event
!= SYS_HALT
&& event
!= SYS_POWER_OFF
)
5639 printk("GDT-HA: Flushing all host drives .. ");
5640 for (hanum
= 0; hanum
< gdth_ctr_count
; ++hanum
) {
5644 /* controller reset */
5645 memset(cmnd
, 0xff, MAX_COMMAND_SIZE
);
5646 gdtcmd
.BoardNode
= LOCALBOARD
;
5647 gdtcmd
.Service
= CACHESERVICE
;
5648 gdtcmd
.OpCode
= GDT_RESET
;
5649 TRACE2(("gdth_halt(): reset controller %d\n", hanum
));
5650 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5651 sdev
= scsi_get_host_dev(gdth_ctr_tab
[hanum
]);
5652 srp
= scsi_allocate_request(sdev
, GFP_KERNEL
);
5654 unregister_reboot_notifier(&gdth_notifier
);
5657 srp
->sr_cmd_len
= 12;
5659 gdth_do_req(srp
, &gdtcmd
, cmnd
, 10);
5660 scsi_release_request(srp
);
5661 scsi_free_host_dev(sdev
);
5663 sdev
= scsi_get_host_dev(gdth_ctr_tab
[hanum
]);
5664 scp
= scsi_allocate_device(sdev
, 1, FALSE
);
5666 unregister_reboot_notifier(&gdth_notifier
);
5671 gdth_do_cmd(scp
, &gdtcmd
, cmnd
, 10);
5672 scsi_release_command(scp
);
5673 scsi_free_host_dev(sdev
);
5679 #ifdef GDTH_STATISTICS
5680 del_timer(&gdth_timer
);
5682 unregister_reboot_notifier(&gdth_notifier
);
5686 static struct scsi_host_template driver_template
= {
5687 .proc_name
= "gdth",
5688 .proc_info
= gdth_proc_info
,
5689 .name
= "GDT SCSI Disk Array Controller",
5690 .detect
= gdth_detect
,
5691 .release
= gdth_release
,
5693 .queuecommand
= gdth_queuecommand
,
5694 .eh_bus_reset_handler
= gdth_eh_bus_reset
,
5695 .bios_param
= gdth_bios_param
,
5696 .can_queue
= GDTH_MAXCMDS
,
5698 .sg_tablesize
= GDTH_MAXSG
,
5699 .cmd_per_lun
= GDTH_MAXC_P_L
,
5700 .unchecked_isa_dma
= 1,
5701 .use_clustering
= ENABLE_CLUSTERING
,
5702 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
5703 .use_new_eh_code
= 1,
5704 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20)
5710 #include "scsi_module.c"
5712 __setup("gdth=", option_setup
);