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 * appropriate 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>
391 #include <linux/dma-mapping.h>
393 #include <linux/mc146818rtc.h>
395 #include <linux/reboot.h>
398 #include <asm/system.h>
400 #include <asm/uaccess.h>
401 #include <linux/spinlock.h>
402 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
403 #include <linux/blkdev.h>
405 #include <linux/blk.h>
410 #include <scsi/scsi_host.h>
412 #include "gdth_kcompat.h"
414 static void gdth_delay(int milliseconds
);
415 static void gdth_eval_mapping(ulong32 size
, ulong32
*cyls
, int *heads
, int *secs
);
416 static irqreturn_t
gdth_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
);
417 static int gdth_sync_event(int hanum
,int service
,unchar index
,Scsi_Cmnd
*scp
);
418 static int gdth_async_event(int hanum
);
419 static void gdth_log_event(gdth_evt_data
*dvr
, char *buffer
);
421 static void gdth_putq(int hanum
,Scsi_Cmnd
*scp
,unchar priority
);
422 static void gdth_next(int hanum
);
423 static int gdth_fill_raw_cmd(int hanum
,Scsi_Cmnd
*scp
,unchar b
);
424 static int gdth_special_cmd(int hanum
,Scsi_Cmnd
*scp
);
425 static gdth_evt_str
*gdth_store_event(gdth_ha_str
*ha
, ushort source
,
426 ushort idx
, gdth_evt_data
*evt
);
427 static int gdth_read_event(gdth_ha_str
*ha
, int handle
, gdth_evt_str
*estr
);
428 static void gdth_readapp_event(gdth_ha_str
*ha
, unchar application
,
430 static void gdth_clear_events(void);
432 static void gdth_copy_internal_data(int hanum
,Scsi_Cmnd
*scp
,
433 char *buffer
,ushort count
);
434 static int gdth_internal_cache_cmd(int hanum
,Scsi_Cmnd
*scp
);
435 static int gdth_fill_cache_cmd(int hanum
,Scsi_Cmnd
*scp
,ushort hdrive
);
437 static int gdth_search_eisa(ushort eisa_adr
);
438 static int gdth_search_isa(ulong32 bios_adr
);
439 static int gdth_search_pci(gdth_pci_str
*pcistr
);
440 static void gdth_search_dev(gdth_pci_str
*pcistr
, ushort
*cnt
,
441 ushort vendor
, ushort dev
);
442 static void gdth_sort_pci(gdth_pci_str
*pcistr
, int cnt
);
443 static int gdth_init_eisa(ushort eisa_adr
,gdth_ha_str
*ha
);
444 static int gdth_init_isa(ulong32 bios_adr
,gdth_ha_str
*ha
);
445 static int gdth_init_pci(gdth_pci_str
*pcistr
,gdth_ha_str
*ha
);
447 static void gdth_enable_int(int hanum
);
448 static int gdth_get_status(unchar
*pIStatus
,int irq
);
449 static int gdth_test_busy(int hanum
);
450 static int gdth_get_cmd_index(int hanum
);
451 static void gdth_release_event(int hanum
);
452 static int gdth_wait(int hanum
,int index
,ulong32 time
);
453 static int gdth_internal_cmd(int hanum
,unchar service
,ushort opcode
,ulong32 p1
,
454 ulong64 p2
,ulong64 p3
);
455 static int gdth_search_drives(int hanum
);
456 static int gdth_analyse_hdrive(int hanum
, ushort hdrive
);
458 static const char *gdth_ctr_name(int hanum
);
460 static int gdth_open(struct inode
*inode
, struct file
*filep
);
461 static int gdth_close(struct inode
*inode
, struct file
*filep
);
462 static int gdth_ioctl(struct inode
*inode
, struct file
*filep
,
463 unsigned int cmd
, unsigned long arg
);
465 static void gdth_flush(int hanum
);
466 static int gdth_halt(struct notifier_block
*nb
, ulong event
, void *buf
);
469 static unchar DebugState
= DEBUG_GDTH
;
472 #define MAX_SERBUF 160
473 static void ser_init(void);
474 static void ser_puts(char *str
);
475 static void ser_putc(char c
);
476 static int ser_printk(const char *fmt
, ...);
477 static char strbuf
[MAX_SERBUF
+1];
479 #define COM_BASE 0x2f8
481 #define COM_BASE 0x3f8
483 static void ser_init()
485 unsigned port
=COM_BASE
;
489 /* 19200 Baud, if 9600: outb(12,port) */
499 static void ser_puts(char *str
)
504 for (ptr
=str
;*ptr
;++ptr
)
508 static void ser_putc(char c
)
510 unsigned port
=COM_BASE
;
512 while ((inb(port
+5) & 0x20)==0);
516 while ((inb(port
+5) & 0x20)==0);
521 static int ser_printk(const char *fmt
, ...)
527 i
= vsprintf(strbuf
,fmt
,args
);
533 #define TRACE(a) {if (DebugState==1) {ser_printk a;}}
534 #define TRACE2(a) {if (DebugState==1 || DebugState==2) {ser_printk a;}}
535 #define TRACE3(a) {if (DebugState!=0) {ser_printk a;}}
537 #else /* !__SERIAL__ */
538 #define TRACE(a) {if (DebugState==1) {printk a;}}
539 #define TRACE2(a) {if (DebugState==1 || DebugState==2) {printk a;}}
540 #define TRACE3(a) {if (DebugState!=0) {printk a;}}
549 #ifdef GDTH_STATISTICS
550 static ulong32 max_rq
=0, max_index
=0, max_sg
=0;
552 static ulong32 max_int_coal
=0;
554 static ulong32 act_ints
=0, act_ios
=0, act_stats
=0, act_rq
=0;
555 static struct timer_list gdth_timer
;
558 #define PTR2USHORT(a) (ushort)(ulong)(a)
559 #define GDTOFFSOF(a,b) (size_t)&(((a*)0)->b)
560 #define INDEX_OK(i,t) ((i)<sizeof(t)/sizeof((t)[0]))
562 #define NUMDATA(a) ( (gdth_num_str *)((a)->hostdata))
563 #define HADATA(a) (&((gdth_ext_str *)((a)->hostdata))->haext)
564 #define CMDDATA(a) (&((gdth_ext_str *)((a)->hostdata))->cmdext)
566 #define BUS_L2P(a,b) ((b)>(a)->virt_bus ? (b-1):(b))
568 #define gdth_readb(addr) readb(addr)
569 #define gdth_readw(addr) readw(addr)
570 #define gdth_readl(addr) readl(addr)
571 #define gdth_writeb(b,addr) writeb((b),(addr))
572 #define gdth_writew(b,addr) writew((b),(addr))
573 #define gdth_writel(b,addr) writel((b),(addr))
575 static unchar gdth_drq_tab
[4] = {5,6,7,7}; /* DRQ table */
576 static unchar gdth_irq_tab
[6] = {0,10,11,12,14,0}; /* IRQ table */
577 static unchar gdth_polling
; /* polling if TRUE */
578 static unchar gdth_from_wait
= FALSE
; /* gdth_wait() */
579 static int wait_index
,wait_hanum
; /* gdth_wait() */
580 static int gdth_ctr_count
= 0; /* controller count */
581 static int gdth_ctr_vcount
= 0; /* virt. ctr. count */
582 static int gdth_ctr_released
= 0; /* gdth_release() */
583 static struct Scsi_Host
*gdth_ctr_tab
[MAXHA
]; /* controller table */
584 static struct Scsi_Host
*gdth_ctr_vtab
[MAXHA
*MAXBUS
]; /* virt. ctr. table */
585 static unchar gdth_write_through
= FALSE
; /* write through */
586 static gdth_evt_str ebuffer
[MAX_EVENTS
]; /* event buffer */
591 #define DIN 1 /* IN data direction */
592 #define DOU 2 /* OUT data direction */
593 #define DNO DIN /* no data transfer */
594 #define DUN DIN /* unknown data direction */
595 static unchar gdth_direction_tab
[0x100] = {
596 DNO
,DNO
,DIN
,DIN
,DOU
,DIN
,DIN
,DOU
,DIN
,DUN
,DOU
,DOU
,DUN
,DUN
,DUN
,DIN
,
597 DNO
,DIN
,DIN
,DOU
,DIN
,DOU
,DNO
,DNO
,DOU
,DNO
,DIN
,DNO
,DIN
,DOU
,DNO
,DUN
,
598 DIN
,DUN
,DIN
,DUN
,DOU
,DIN
,DUN
,DUN
,DIN
,DIN
,DOU
,DNO
,DUN
,DIN
,DOU
,DOU
,
599 DOU
,DOU
,DOU
,DNO
,DIN
,DNO
,DNO
,DIN
,DOU
,DOU
,DOU
,DOU
,DIN
,DOU
,DIN
,DOU
,
600 DOU
,DOU
,DIN
,DIN
,DIN
,DNO
,DUN
,DNO
,DNO
,DNO
,DUN
,DNO
,DOU
,DIN
,DUN
,DUN
,
601 DUN
,DUN
,DUN
,DUN
,DUN
,DOU
,DUN
,DUN
,DUN
,DUN
,DIN
,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
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,
604 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DIN
,DUN
,DOU
,DUN
,DUN
,DUN
,DUN
,DUN
,
605 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DIN
,DUN
,
606 DUN
,DUN
,DUN
,DUN
,DUN
,DNO
,DNO
,DUN
,DIN
,DNO
,DOU
,DUN
,DNO
,DUN
,DOU
,DOU
,
607 DOU
,DOU
,DOU
,DNO
,DUN
,DIN
,DOU
,DIN
,DIN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,
608 DUN
,DUN
,DOU
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,
609 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,
610 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DOU
,DUN
,DUN
,DUN
,DUN
,DUN
,
611 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
614 /* LILO and modprobe/insmod parameters */
615 /* IRQ list for GDT3000/3020 EISA controllers */
616 static int irq
[MAXHA
] __initdata
=
617 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
618 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
619 /* disable driver flag */
620 static int disable __initdata
= 0;
622 static int reserve_mode
= 1;
624 static int reserve_list
[MAX_RES_ARGS
] =
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,0xff,0xff,
627 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
628 /* scan order for PCI controllers */
629 static int reverse_scan
= 0;
630 /* virtual channel for the host drives */
631 static int hdr_channel
= 0;
632 /* max. IDs per channel */
633 static int max_ids
= MAXID
;
635 static int rescan
= 0;
636 /* map channels to virtual controllers */
637 static int virt_ctr
= 0;
639 static int shared_access
= 1;
640 /* enable support for EISA and ISA controllers */
641 static int probe_eisa_isa
= 0;
642 /* 64 bit DMA mode, support for drives > 2 TB, if force_dma32 = 0 */
643 static int force_dma32
= 0;
645 /* parameters for modprobe/insmod */
646 module_param_array(irq
, int, NULL
, 0);
647 module_param(disable
, int, 0);
648 module_param(reserve_mode
, int, 0);
649 module_param_array(reserve_list
, int, NULL
, 0);
650 module_param(reverse_scan
, int, 0);
651 module_param(hdr_channel
, int, 0);
652 module_param(max_ids
, int, 0);
653 module_param(rescan
, int, 0);
654 module_param(virt_ctr
, int, 0);
655 module_param(shared_access
, int, 0);
656 module_param(probe_eisa_isa
, int, 0);
657 module_param(force_dma32
, int, 0);
658 MODULE_AUTHOR("Achim Leubner");
659 MODULE_LICENSE("GPL");
661 /* ioctl interface */
662 static struct file_operations gdth_fops
= {
665 .release
= gdth_close
,
668 #include "gdth_proc.h"
669 #include "gdth_proc.c"
671 /* notifier block to get a notify on system shutdown/halt/reboot */
672 static struct notifier_block gdth_notifier
= {
675 static int notifier_disabled
= 0;
677 static void gdth_delay(int milliseconds
)
679 if (milliseconds
== 0) {
682 mdelay(milliseconds
);
686 static void gdth_eval_mapping(ulong32 size
, ulong32
*cyls
, int *heads
, int *secs
)
688 *cyls
= size
/HEADS
/SECS
;
689 if (*cyls
<= MAXCYLS
) {
692 } else { /* too high for 64*32 */
693 *cyls
= size
/MEDHEADS
/MEDSECS
;
694 if (*cyls
<= MAXCYLS
) {
697 } else { /* too high for 127*63 */
698 *cyls
= size
/BIGHEADS
/BIGSECS
;
705 /* controller search and initialization functions */
707 static int __init
gdth_search_eisa(ushort eisa_adr
)
711 TRACE(("gdth_search_eisa() adr. %x\n",eisa_adr
));
712 id
= inl(eisa_adr
+ID0REG
);
713 if (id
== GDT3A_ID
|| id
== GDT3B_ID
) { /* GDT3000A or GDT3000B */
714 if ((inb(eisa_adr
+EISAREG
) & 8) == 0)
715 return 0; /* not EISA configured */
718 if (id
== GDT3_ID
) /* GDT3000 */
725 static int __init
gdth_search_isa(ulong32 bios_adr
)
730 TRACE(("gdth_search_isa() bios adr. %x\n",bios_adr
));
731 if ((addr
= ioremap(bios_adr
+BIOS_ID_OFFS
, sizeof(ulong32
))) != NULL
) {
732 id
= gdth_readl(addr
);
734 if (id
== GDT2_ID
) /* GDT2000 */
741 static int __init
gdth_search_pci(gdth_pci_str
*pcistr
)
745 TRACE(("gdth_search_pci()\n"));
748 for (device
= 0; device
<= PCI_DEVICE_ID_VORTEX_GDT6555
; ++device
)
749 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_VORTEX
, device
);
750 for (device
= PCI_DEVICE_ID_VORTEX_GDT6x17RP
;
751 device
<= PCI_DEVICE_ID_VORTEX_GDTMAXRP
; ++device
)
752 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_VORTEX
, device
);
753 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_VORTEX
,
754 PCI_DEVICE_ID_VORTEX_GDTNEWRX
);
755 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_VORTEX
,
756 PCI_DEVICE_ID_VORTEX_GDTNEWRX2
);
757 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_INTEL
,
758 PCI_DEVICE_ID_INTEL_SRC
);
759 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_INTEL
,
760 PCI_DEVICE_ID_INTEL_SRC_XSCALE
);
764 /* Vortex only makes RAID controllers.
765 * We do not really want to specify all 550 ids here, so wildcard match.
767 static struct pci_device_id gdthtable
[] __attribute_used__
= {
768 {PCI_VENDOR_ID_VORTEX
,PCI_ANY_ID
,PCI_ANY_ID
, PCI_ANY_ID
},
769 {PCI_VENDOR_ID_INTEL
,PCI_DEVICE_ID_INTEL_SRC
,PCI_ANY_ID
,PCI_ANY_ID
},
770 {PCI_VENDOR_ID_INTEL
,PCI_DEVICE_ID_INTEL_SRC_XSCALE
,PCI_ANY_ID
,PCI_ANY_ID
},
773 MODULE_DEVICE_TABLE(pci
,gdthtable
);
775 static void __init
gdth_search_dev(gdth_pci_str
*pcistr
, ushort
*cnt
,
776 ushort vendor
, ushort device
)
778 ulong base0
, base1
, base2
;
779 struct pci_dev
*pdev
;
781 TRACE(("gdth_search_dev() cnt %d vendor %x device %x\n",
782 *cnt
, vendor
, device
));
785 while ((pdev
= pci_find_device(vendor
, device
, pdev
))
787 if (pci_enable_device(pdev
))
791 /* GDT PCI controller found, resources are already in pdev */
792 pcistr
[*cnt
].pdev
= pdev
;
793 pcistr
[*cnt
].vendor_id
= vendor
;
794 pcistr
[*cnt
].device_id
= device
;
795 pcistr
[*cnt
].subdevice_id
= pdev
->subsystem_device
;
796 pcistr
[*cnt
].bus
= pdev
->bus
->number
;
797 pcistr
[*cnt
].device_fn
= pdev
->devfn
;
798 pcistr
[*cnt
].irq
= pdev
->irq
;
799 base0
= pci_resource_flags(pdev
, 0);
800 base1
= pci_resource_flags(pdev
, 1);
801 base2
= pci_resource_flags(pdev
, 2);
802 if (device
<= PCI_DEVICE_ID_VORTEX_GDT6000B
|| /* GDT6000/B */
803 device
>= PCI_DEVICE_ID_VORTEX_GDT6x17RP
) { /* MPR */
804 if (!(base0
& IORESOURCE_MEM
))
806 pcistr
[*cnt
].dpmem
= pci_resource_start(pdev
, 0);
807 } else { /* GDT6110, GDT6120, .. */
808 if (!(base0
& IORESOURCE_MEM
) ||
809 !(base2
& IORESOURCE_MEM
) ||
810 !(base1
& IORESOURCE_IO
))
812 pcistr
[*cnt
].dpmem
= pci_resource_start(pdev
, 2);
813 pcistr
[*cnt
].io_mm
= pci_resource_start(pdev
, 0);
814 pcistr
[*cnt
].io
= pci_resource_start(pdev
, 1);
816 TRACE2(("Controller found at %d/%d, irq %d, dpmem 0x%lx\n",
817 pcistr
[*cnt
].bus
, PCI_SLOT(pcistr
[*cnt
].device_fn
),
818 pcistr
[*cnt
].irq
, pcistr
[*cnt
].dpmem
));
824 static void __init
gdth_sort_pci(gdth_pci_str
*pcistr
, int cnt
)
829 TRACE(("gdth_sort_pci() cnt %d\n",cnt
));
835 for (i
= 0; i
< cnt
-1; ++i
) {
837 if ((pcistr
[i
].bus
> pcistr
[i
+1].bus
) ||
838 (pcistr
[i
].bus
== pcistr
[i
+1].bus
&&
839 PCI_SLOT(pcistr
[i
].device_fn
) >
840 PCI_SLOT(pcistr
[i
+1].device_fn
))) {
842 pcistr
[i
] = pcistr
[i
+1];
847 if ((pcistr
[i
].bus
< pcistr
[i
+1].bus
) ||
848 (pcistr
[i
].bus
== pcistr
[i
+1].bus
&&
849 PCI_SLOT(pcistr
[i
].device_fn
) <
850 PCI_SLOT(pcistr
[i
+1].device_fn
))) {
852 pcistr
[i
] = pcistr
[i
+1];
862 static int __init
gdth_init_eisa(ushort eisa_adr
,gdth_ha_str
*ha
)
865 unchar prot_ver
,eisacf
,i
,irq_found
;
867 TRACE(("gdth_init_eisa() adr. %x\n",eisa_adr
));
869 /* disable board interrupts, deinitialize services */
870 outb(0xff,eisa_adr
+EDOORREG
);
871 outb(0x00,eisa_adr
+EDENABREG
);
872 outb(0x00,eisa_adr
+EINTENABREG
);
874 outb(0xff,eisa_adr
+LDOORREG
);
875 retries
= INIT_RETRIES
;
877 while (inb(eisa_adr
+EDOORREG
) != 0xff) {
878 if (--retries
== 0) {
879 printk("GDT-EISA: Initialization error (DEINIT failed)\n");
883 TRACE2(("wait for DEINIT: retries=%d\n",retries
));
885 prot_ver
= inb(eisa_adr
+MAILBOXREG
);
886 outb(0xff,eisa_adr
+EDOORREG
);
887 if (prot_ver
!= PROTOCOL_VERSION
) {
888 printk("GDT-EISA: Illegal protocol version\n");
892 ha
->brd_phys
= (ulong32
)eisa_adr
>> 12;
894 outl(0,eisa_adr
+MAILBOXREG
);
895 outl(0,eisa_adr
+MAILBOXREG
+4);
896 outl(0,eisa_adr
+MAILBOXREG
+8);
897 outl(0,eisa_adr
+MAILBOXREG
+12);
900 if ((id
= inl(eisa_adr
+ID0REG
)) == GDT3_ID
) {
901 ha
->oem_id
= OEM_ID_ICP
;
904 outl(1,eisa_adr
+MAILBOXREG
+8);
905 outb(0xfe,eisa_adr
+LDOORREG
);
906 retries
= INIT_RETRIES
;
908 while (inb(eisa_adr
+EDOORREG
) != 0xfe) {
909 if (--retries
== 0) {
910 printk("GDT-EISA: Initialization error (get IRQ failed)\n");
915 ha
->irq
= inb(eisa_adr
+MAILBOXREG
);
916 outb(0xff,eisa_adr
+EDOORREG
);
917 TRACE2(("GDT3000/3020: IRQ=%d\n",ha
->irq
));
918 /* check the result */
920 TRACE2(("Unknown IRQ, use IRQ table from cmd line !\n"));
921 for (i
= 0, irq_found
= FALSE
;
922 i
< MAXHA
&& irq
[i
] != 0xff; ++i
) {
923 if (irq
[i
]==10 || irq
[i
]==11 || irq
[i
]==12 || irq
[i
]==14) {
931 printk("GDT-EISA: Can not detect controller IRQ,\n");
932 printk("Use IRQ setting from command line (IRQ = %d)\n",
935 printk("GDT-EISA: Initialization error (unknown IRQ), Enable\n");
936 printk("the controller BIOS or use command line parameters\n");
941 eisacf
= inb(eisa_adr
+EISAREG
) & 7;
942 if (eisacf
> 4) /* level triggered */
944 ha
->irq
= gdth_irq_tab
[eisacf
];
945 ha
->oem_id
= OEM_ID_ICP
;
950 ha
->dma64_support
= 0;
955 static int __init
gdth_init_isa(ulong32 bios_adr
,gdth_ha_str
*ha
)
957 register gdt2_dpram_str __iomem
*dp2_ptr
;
959 unchar irq_drq
,prot_ver
;
962 TRACE(("gdth_init_isa() bios adr. %x\n",bios_adr
));
964 ha
->brd
= ioremap(bios_adr
, sizeof(gdt2_dpram_str
));
965 if (ha
->brd
== NULL
) {
966 printk("GDT-ISA: Initialization error (DPMEM remap error)\n");
970 gdth_writeb(1, &dp2_ptr
->io
.memlock
); /* switch off write protection */
971 /* reset interface area */
972 memset_io(&dp2_ptr
->u
, 0, sizeof(dp2_ptr
->u
));
973 if (gdth_readl(&dp2_ptr
->u
) != 0) {
974 printk("GDT-ISA: Initialization error (DPMEM write error)\n");
979 /* disable board interrupts, read DRQ and IRQ */
980 gdth_writeb(0xff, &dp2_ptr
->io
.irqdel
);
981 gdth_writeb(0x00, &dp2_ptr
->io
.irqen
);
982 gdth_writeb(0x00, &dp2_ptr
->u
.ic
.S_Status
);
983 gdth_writeb(0x00, &dp2_ptr
->u
.ic
.Cmd_Index
);
985 irq_drq
= gdth_readb(&dp2_ptr
->io
.rq
);
986 for (i
=0; i
<3; ++i
) {
987 if ((irq_drq
& 1)==0)
991 ha
->drq
= gdth_drq_tab
[i
];
993 irq_drq
= gdth_readb(&dp2_ptr
->io
.rq
) >> 3;
994 for (i
=1; i
<5; ++i
) {
995 if ((irq_drq
& 1)==0)
999 ha
->irq
= gdth_irq_tab
[i
];
1001 /* deinitialize services */
1002 gdth_writel(bios_adr
, &dp2_ptr
->u
.ic
.S_Info
[0]);
1003 gdth_writeb(0xff, &dp2_ptr
->u
.ic
.S_Cmd_Indx
);
1004 gdth_writeb(0, &dp2_ptr
->io
.event
);
1005 retries
= INIT_RETRIES
;
1007 while (gdth_readb(&dp2_ptr
->u
.ic
.S_Status
) != 0xff) {
1008 if (--retries
== 0) {
1009 printk("GDT-ISA: Initialization error (DEINIT failed)\n");
1015 prot_ver
= (unchar
)gdth_readl(&dp2_ptr
->u
.ic
.S_Info
[0]);
1016 gdth_writeb(0, &dp2_ptr
->u
.ic
.Status
);
1017 gdth_writeb(0xff, &dp2_ptr
->io
.irqdel
);
1018 if (prot_ver
!= PROTOCOL_VERSION
) {
1019 printk("GDT-ISA: Illegal protocol version\n");
1024 ha
->oem_id
= OEM_ID_ICP
;
1026 ha
->ic_all_size
= sizeof(dp2_ptr
->u
);
1028 ha
->brd_phys
= bios_adr
>> 4;
1030 /* special request to controller BIOS */
1031 gdth_writel(0x00, &dp2_ptr
->u
.ic
.S_Info
[0]);
1032 gdth_writel(0x00, &dp2_ptr
->u
.ic
.S_Info
[1]);
1033 gdth_writel(0x01, &dp2_ptr
->u
.ic
.S_Info
[2]);
1034 gdth_writel(0x00, &dp2_ptr
->u
.ic
.S_Info
[3]);
1035 gdth_writeb(0xfe, &dp2_ptr
->u
.ic
.S_Cmd_Indx
);
1036 gdth_writeb(0, &dp2_ptr
->io
.event
);
1037 retries
= INIT_RETRIES
;
1039 while (gdth_readb(&dp2_ptr
->u
.ic
.S_Status
) != 0xfe) {
1040 if (--retries
== 0) {
1041 printk("GDT-ISA: Initialization error\n");
1047 gdth_writeb(0, &dp2_ptr
->u
.ic
.Status
);
1048 gdth_writeb(0xff, &dp2_ptr
->io
.irqdel
);
1050 ha
->dma64_support
= 0;
1055 static int __init
gdth_init_pci(gdth_pci_str
*pcistr
,gdth_ha_str
*ha
)
1057 register gdt6_dpram_str __iomem
*dp6_ptr
;
1058 register gdt6c_dpram_str __iomem
*dp6c_ptr
;
1059 register gdt6m_dpram_str __iomem
*dp6m_ptr
;
1063 int i
, found
= FALSE
;
1065 TRACE(("gdth_init_pci()\n"));
1067 if (pcistr
->vendor_id
== PCI_VENDOR_ID_INTEL
)
1068 ha
->oem_id
= OEM_ID_INTEL
;
1070 ha
->oem_id
= OEM_ID_ICP
;
1071 ha
->brd_phys
= (pcistr
->bus
<< 8) | (pcistr
->device_fn
& 0xf8);
1072 ha
->stype
= (ulong32
)pcistr
->device_id
;
1073 ha
->subdevice_id
= pcistr
->subdevice_id
;
1074 ha
->irq
= pcistr
->irq
;
1075 ha
->pdev
= pcistr
->pdev
;
1077 if (ha
->stype
<= PCI_DEVICE_ID_VORTEX_GDT6000B
) { /* GDT6000/B */
1078 TRACE2(("init_pci() dpmem %lx irq %d\n",pcistr
->dpmem
,ha
->irq
));
1079 ha
->brd
= ioremap(pcistr
->dpmem
, sizeof(gdt6_dpram_str
));
1080 if (ha
->brd
== NULL
) {
1081 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1084 /* check and reset interface area */
1086 gdth_writel(DPMEM_MAGIC
, &dp6_ptr
->u
);
1087 if (gdth_readl(&dp6_ptr
->u
) != DPMEM_MAGIC
) {
1088 printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n",
1091 for (i
= 0xC8000; i
< 0xE8000; i
+= 0x4000) {
1093 ha
->brd
= ioremap(i
, sizeof(ushort
));
1094 if (ha
->brd
== NULL
) {
1095 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1098 if (gdth_readw(ha
->brd
) != 0xffff) {
1099 TRACE2(("init_pci_old() address 0x%x busy\n", i
));
1103 pci_write_config_dword(pcistr
->pdev
,
1104 PCI_BASE_ADDRESS_0
, i
);
1105 ha
->brd
= ioremap(i
, sizeof(gdt6_dpram_str
));
1106 if (ha
->brd
== NULL
) {
1107 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1111 gdth_writel(DPMEM_MAGIC
, &dp6_ptr
->u
);
1112 if (gdth_readl(&dp6_ptr
->u
) == DPMEM_MAGIC
) {
1113 printk("GDT-PCI: Use free address at 0x%x\n", i
);
1119 printk("GDT-PCI: No free address found!\n");
1124 memset_io(&dp6_ptr
->u
, 0, sizeof(dp6_ptr
->u
));
1125 if (gdth_readl(&dp6_ptr
->u
) != 0) {
1126 printk("GDT-PCI: Initialization error (DPMEM write error)\n");
1131 /* disable board interrupts, deinit services */
1132 gdth_writeb(0xff, &dp6_ptr
->io
.irqdel
);
1133 gdth_writeb(0x00, &dp6_ptr
->io
.irqen
);
1134 gdth_writeb(0x00, &dp6_ptr
->u
.ic
.S_Status
);
1135 gdth_writeb(0x00, &dp6_ptr
->u
.ic
.Cmd_Index
);
1137 gdth_writel(pcistr
->dpmem
, &dp6_ptr
->u
.ic
.S_Info
[0]);
1138 gdth_writeb(0xff, &dp6_ptr
->u
.ic
.S_Cmd_Indx
);
1139 gdth_writeb(0, &dp6_ptr
->io
.event
);
1140 retries
= INIT_RETRIES
;
1142 while (gdth_readb(&dp6_ptr
->u
.ic
.S_Status
) != 0xff) {
1143 if (--retries
== 0) {
1144 printk("GDT-PCI: Initialization error (DEINIT failed)\n");
1150 prot_ver
= (unchar
)gdth_readl(&dp6_ptr
->u
.ic
.S_Info
[0]);
1151 gdth_writeb(0, &dp6_ptr
->u
.ic
.S_Status
);
1152 gdth_writeb(0xff, &dp6_ptr
->io
.irqdel
);
1153 if (prot_ver
!= PROTOCOL_VERSION
) {
1154 printk("GDT-PCI: Illegal protocol version\n");
1160 ha
->ic_all_size
= sizeof(dp6_ptr
->u
);
1162 /* special command to controller BIOS */
1163 gdth_writel(0x00, &dp6_ptr
->u
.ic
.S_Info
[0]);
1164 gdth_writel(0x00, &dp6_ptr
->u
.ic
.S_Info
[1]);
1165 gdth_writel(0x00, &dp6_ptr
->u
.ic
.S_Info
[2]);
1166 gdth_writel(0x00, &dp6_ptr
->u
.ic
.S_Info
[3]);
1167 gdth_writeb(0xfe, &dp6_ptr
->u
.ic
.S_Cmd_Indx
);
1168 gdth_writeb(0, &dp6_ptr
->io
.event
);
1169 retries
= INIT_RETRIES
;
1171 while (gdth_readb(&dp6_ptr
->u
.ic
.S_Status
) != 0xfe) {
1172 if (--retries
== 0) {
1173 printk("GDT-PCI: Initialization error\n");
1179 gdth_writeb(0, &dp6_ptr
->u
.ic
.S_Status
);
1180 gdth_writeb(0xff, &dp6_ptr
->io
.irqdel
);
1182 ha
->dma64_support
= 0;
1184 } else if (ha
->stype
<= PCI_DEVICE_ID_VORTEX_GDT6555
) { /* GDT6110, ... */
1185 ha
->plx
= (gdt6c_plx_regs
*)pcistr
->io
;
1186 TRACE2(("init_pci_new() dpmem %lx irq %d\n",
1187 pcistr
->dpmem
,ha
->irq
));
1188 ha
->brd
= ioremap(pcistr
->dpmem
, sizeof(gdt6c_dpram_str
));
1189 if (ha
->brd
== NULL
) {
1190 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1194 /* check and reset interface area */
1196 gdth_writel(DPMEM_MAGIC
, &dp6c_ptr
->u
);
1197 if (gdth_readl(&dp6c_ptr
->u
) != DPMEM_MAGIC
) {
1198 printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n",
1201 for (i
= 0xC8000; i
< 0xE8000; i
+= 0x4000) {
1203 ha
->brd
= ioremap(i
, sizeof(ushort
));
1204 if (ha
->brd
== NULL
) {
1205 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1208 if (gdth_readw(ha
->brd
) != 0xffff) {
1209 TRACE2(("init_pci_plx() address 0x%x busy\n", i
));
1213 pci_write_config_dword(pcistr
->pdev
,
1214 PCI_BASE_ADDRESS_2
, i
);
1215 ha
->brd
= ioremap(i
, sizeof(gdt6c_dpram_str
));
1216 if (ha
->brd
== NULL
) {
1217 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1221 gdth_writel(DPMEM_MAGIC
, &dp6c_ptr
->u
);
1222 if (gdth_readl(&dp6c_ptr
->u
) == DPMEM_MAGIC
) {
1223 printk("GDT-PCI: Use free address at 0x%x\n", i
);
1229 printk("GDT-PCI: No free address found!\n");
1234 memset_io(&dp6c_ptr
->u
, 0, sizeof(dp6c_ptr
->u
));
1235 if (gdth_readl(&dp6c_ptr
->u
) != 0) {
1236 printk("GDT-PCI: Initialization error (DPMEM write error)\n");
1241 /* disable board interrupts, deinit services */
1242 outb(0x00,PTR2USHORT(&ha
->plx
->control1
));
1243 outb(0xff,PTR2USHORT(&ha
->plx
->edoor_reg
));
1245 gdth_writeb(0x00, &dp6c_ptr
->u
.ic
.S_Status
);
1246 gdth_writeb(0x00, &dp6c_ptr
->u
.ic
.Cmd_Index
);
1248 gdth_writel(pcistr
->dpmem
, &dp6c_ptr
->u
.ic
.S_Info
[0]);
1249 gdth_writeb(0xff, &dp6c_ptr
->u
.ic
.S_Cmd_Indx
);
1251 outb(1,PTR2USHORT(&ha
->plx
->ldoor_reg
));
1253 retries
= INIT_RETRIES
;
1255 while (gdth_readb(&dp6c_ptr
->u
.ic
.S_Status
) != 0xff) {
1256 if (--retries
== 0) {
1257 printk("GDT-PCI: Initialization error (DEINIT failed)\n");
1263 prot_ver
= (unchar
)gdth_readl(&dp6c_ptr
->u
.ic
.S_Info
[0]);
1264 gdth_writeb(0, &dp6c_ptr
->u
.ic
.Status
);
1265 if (prot_ver
!= PROTOCOL_VERSION
) {
1266 printk("GDT-PCI: Illegal protocol version\n");
1271 ha
->type
= GDT_PCINEW
;
1272 ha
->ic_all_size
= sizeof(dp6c_ptr
->u
);
1274 /* special command to controller BIOS */
1275 gdth_writel(0x00, &dp6c_ptr
->u
.ic
.S_Info
[0]);
1276 gdth_writel(0x00, &dp6c_ptr
->u
.ic
.S_Info
[1]);
1277 gdth_writel(0x00, &dp6c_ptr
->u
.ic
.S_Info
[2]);
1278 gdth_writel(0x00, &dp6c_ptr
->u
.ic
.S_Info
[3]);
1279 gdth_writeb(0xfe, &dp6c_ptr
->u
.ic
.S_Cmd_Indx
);
1281 outb(1,PTR2USHORT(&ha
->plx
->ldoor_reg
));
1283 retries
= INIT_RETRIES
;
1285 while (gdth_readb(&dp6c_ptr
->u
.ic
.S_Status
) != 0xfe) {
1286 if (--retries
== 0) {
1287 printk("GDT-PCI: Initialization error\n");
1293 gdth_writeb(0, &dp6c_ptr
->u
.ic
.S_Status
);
1295 ha
->dma64_support
= 0;
1298 TRACE2(("init_pci_mpr() dpmem %lx irq %d\n",pcistr
->dpmem
,ha
->irq
));
1299 ha
->brd
= ioremap(pcistr
->dpmem
, sizeof(gdt6m_dpram_str
));
1300 if (ha
->brd
== NULL
) {
1301 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1305 /* manipulate config. space to enable DPMEM, start RP controller */
1306 pci_read_config_word(pcistr
->pdev
, PCI_COMMAND
, &command
);
1308 pci_write_config_word(pcistr
->pdev
, PCI_COMMAND
, command
);
1309 if (pci_resource_start(pcistr
->pdev
, 8) == 1UL)
1310 pci_resource_start(pcistr
->pdev
, 8) = 0UL;
1312 pci_write_config_dword(pcistr
->pdev
, PCI_ROM_ADDRESS
, i
);
1314 pci_write_config_dword(pcistr
->pdev
, PCI_ROM_ADDRESS
,
1315 pci_resource_start(pcistr
->pdev
, 8));
1319 /* Ensure that it is safe to access the non HW portions of DPMEM.
1320 * Aditional check needed for Xscale based RAID controllers */
1321 while( ((int)gdth_readb(&dp6m_ptr
->i960r
.sema0_reg
) ) & 3 )
1324 /* check and reset interface area */
1325 gdth_writel(DPMEM_MAGIC
, &dp6m_ptr
->u
);
1326 if (gdth_readl(&dp6m_ptr
->u
) != DPMEM_MAGIC
) {
1327 printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n",
1330 for (i
= 0xC8000; i
< 0xE8000; i
+= 0x4000) {
1332 ha
->brd
= ioremap(i
, sizeof(ushort
));
1333 if (ha
->brd
== NULL
) {
1334 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1337 if (gdth_readw(ha
->brd
) != 0xffff) {
1338 TRACE2(("init_pci_mpr() address 0x%x busy\n", i
));
1342 pci_write_config_dword(pcistr
->pdev
,
1343 PCI_BASE_ADDRESS_0
, i
);
1344 ha
->brd
= ioremap(i
, sizeof(gdt6m_dpram_str
));
1345 if (ha
->brd
== NULL
) {
1346 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1350 gdth_writel(DPMEM_MAGIC
, &dp6m_ptr
->u
);
1351 if (gdth_readl(&dp6m_ptr
->u
) == DPMEM_MAGIC
) {
1352 printk("GDT-PCI: Use free address at 0x%x\n", i
);
1358 printk("GDT-PCI: No free address found!\n");
1363 memset_io(&dp6m_ptr
->u
, 0, sizeof(dp6m_ptr
->u
));
1365 /* disable board interrupts, deinit services */
1366 gdth_writeb(gdth_readb(&dp6m_ptr
->i960r
.edoor_en_reg
) | 4,
1367 &dp6m_ptr
->i960r
.edoor_en_reg
);
1368 gdth_writeb(0xff, &dp6m_ptr
->i960r
.edoor_reg
);
1369 gdth_writeb(0x00, &dp6m_ptr
->u
.ic
.S_Status
);
1370 gdth_writeb(0x00, &dp6m_ptr
->u
.ic
.Cmd_Index
);
1372 gdth_writel(pcistr
->dpmem
, &dp6m_ptr
->u
.ic
.S_Info
[0]);
1373 gdth_writeb(0xff, &dp6m_ptr
->u
.ic
.S_Cmd_Indx
);
1374 gdth_writeb(1, &dp6m_ptr
->i960r
.ldoor_reg
);
1375 retries
= INIT_RETRIES
;
1377 while (gdth_readb(&dp6m_ptr
->u
.ic
.S_Status
) != 0xff) {
1378 if (--retries
== 0) {
1379 printk("GDT-PCI: Initialization error (DEINIT failed)\n");
1385 prot_ver
= (unchar
)gdth_readl(&dp6m_ptr
->u
.ic
.S_Info
[0]);
1386 gdth_writeb(0, &dp6m_ptr
->u
.ic
.S_Status
);
1387 if (prot_ver
!= PROTOCOL_VERSION
) {
1388 printk("GDT-PCI: Illegal protocol version\n");
1393 ha
->type
= GDT_PCIMPR
;
1394 ha
->ic_all_size
= sizeof(dp6m_ptr
->u
);
1396 /* special command to controller BIOS */
1397 gdth_writel(0x00, &dp6m_ptr
->u
.ic
.S_Info
[0]);
1398 gdth_writel(0x00, &dp6m_ptr
->u
.ic
.S_Info
[1]);
1399 gdth_writel(0x00, &dp6m_ptr
->u
.ic
.S_Info
[2]);
1400 gdth_writel(0x00, &dp6m_ptr
->u
.ic
.S_Info
[3]);
1401 gdth_writeb(0xfe, &dp6m_ptr
->u
.ic
.S_Cmd_Indx
);
1402 gdth_writeb(1, &dp6m_ptr
->i960r
.ldoor_reg
);
1403 retries
= INIT_RETRIES
;
1405 while (gdth_readb(&dp6m_ptr
->u
.ic
.S_Status
) != 0xfe) {
1406 if (--retries
== 0) {
1407 printk("GDT-PCI: Initialization error\n");
1413 gdth_writeb(0, &dp6m_ptr
->u
.ic
.S_Status
);
1415 /* read FW version to detect 64-bit DMA support */
1416 gdth_writeb(0xfd, &dp6m_ptr
->u
.ic
.S_Cmd_Indx
);
1417 gdth_writeb(1, &dp6m_ptr
->i960r
.ldoor_reg
);
1418 retries
= INIT_RETRIES
;
1420 while (gdth_readb(&dp6m_ptr
->u
.ic
.S_Status
) != 0xfd) {
1421 if (--retries
== 0) {
1422 printk("GDT-PCI: Initialization error (DEINIT failed)\n");
1428 prot_ver
= (unchar
)(gdth_readl(&dp6m_ptr
->u
.ic
.S_Info
[0]) >> 16);
1429 gdth_writeb(0, &dp6m_ptr
->u
.ic
.S_Status
);
1430 if (prot_ver
< 0x2b) /* FW < x.43: no 64-bit DMA support */
1431 ha
->dma64_support
= 0;
1433 ha
->dma64_support
= 1;
1440 /* controller protocol functions */
1442 static void __init
gdth_enable_int(int hanum
)
1446 gdt2_dpram_str __iomem
*dp2_ptr
;
1447 gdt6_dpram_str __iomem
*dp6_ptr
;
1448 gdt6m_dpram_str __iomem
*dp6m_ptr
;
1450 TRACE(("gdth_enable_int() hanum %d\n",hanum
));
1451 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1452 spin_lock_irqsave(&ha
->smp_lock
, flags
);
1454 if (ha
->type
== GDT_EISA
) {
1455 outb(0xff, ha
->bmic
+ EDOORREG
);
1456 outb(0xff, ha
->bmic
+ EDENABREG
);
1457 outb(0x01, ha
->bmic
+ EINTENABREG
);
1458 } else if (ha
->type
== GDT_ISA
) {
1460 gdth_writeb(1, &dp2_ptr
->io
.irqdel
);
1461 gdth_writeb(0, &dp2_ptr
->u
.ic
.Cmd_Index
);
1462 gdth_writeb(1, &dp2_ptr
->io
.irqen
);
1463 } else if (ha
->type
== GDT_PCI
) {
1465 gdth_writeb(1, &dp6_ptr
->io
.irqdel
);
1466 gdth_writeb(0, &dp6_ptr
->u
.ic
.Cmd_Index
);
1467 gdth_writeb(1, &dp6_ptr
->io
.irqen
);
1468 } else if (ha
->type
== GDT_PCINEW
) {
1469 outb(0xff, PTR2USHORT(&ha
->plx
->edoor_reg
));
1470 outb(0x03, PTR2USHORT(&ha
->plx
->control1
));
1471 } else if (ha
->type
== GDT_PCIMPR
) {
1473 gdth_writeb(0xff, &dp6m_ptr
->i960r
.edoor_reg
);
1474 gdth_writeb(gdth_readb(&dp6m_ptr
->i960r
.edoor_en_reg
) & ~4,
1475 &dp6m_ptr
->i960r
.edoor_en_reg
);
1477 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
1481 static int gdth_get_status(unchar
*pIStatus
,int irq
)
1483 register gdth_ha_str
*ha
;
1486 TRACE(("gdth_get_status() irq %d ctr_count %d\n",
1487 irq
,gdth_ctr_count
));
1490 for (i
=0; i
<gdth_ctr_count
; ++i
) {
1491 ha
= HADATA(gdth_ctr_tab
[i
]);
1492 if (ha
->irq
!= (unchar
)irq
) /* check IRQ */
1494 if (ha
->type
== GDT_EISA
)
1495 *pIStatus
= inb((ushort
)ha
->bmic
+ EDOORREG
);
1496 else if (ha
->type
== GDT_ISA
)
1498 gdth_readb(&((gdt2_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Cmd_Index
);
1499 else if (ha
->type
== GDT_PCI
)
1501 gdth_readb(&((gdt6_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Cmd_Index
);
1502 else if (ha
->type
== GDT_PCINEW
)
1503 *pIStatus
= inb(PTR2USHORT(&ha
->plx
->edoor_reg
));
1504 else if (ha
->type
== GDT_PCIMPR
)
1506 gdth_readb(&((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.edoor_reg
);
1509 return i
; /* board found */
1515 static int gdth_test_busy(int hanum
)
1517 register gdth_ha_str
*ha
;
1518 register int gdtsema0
= 0;
1520 TRACE(("gdth_test_busy() hanum %d\n",hanum
));
1522 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1523 if (ha
->type
== GDT_EISA
)
1524 gdtsema0
= (int)inb(ha
->bmic
+ SEMA0REG
);
1525 else if (ha
->type
== GDT_ISA
)
1526 gdtsema0
= (int)gdth_readb(&((gdt2_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Sema0
);
1527 else if (ha
->type
== GDT_PCI
)
1528 gdtsema0
= (int)gdth_readb(&((gdt6_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Sema0
);
1529 else if (ha
->type
== GDT_PCINEW
)
1530 gdtsema0
= (int)inb(PTR2USHORT(&ha
->plx
->sema0_reg
));
1531 else if (ha
->type
== GDT_PCIMPR
)
1533 (int)gdth_readb(&((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.sema0_reg
);
1535 return (gdtsema0
& 1);
1539 static int gdth_get_cmd_index(int hanum
)
1541 register gdth_ha_str
*ha
;
1544 TRACE(("gdth_get_cmd_index() hanum %d\n",hanum
));
1546 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1547 for (i
=0; i
<GDTH_MAXCMDS
; ++i
) {
1548 if (ha
->cmd_tab
[i
].cmnd
== UNUSED_CMND
) {
1549 ha
->cmd_tab
[i
].cmnd
= ha
->pccb
->RequestBuffer
;
1550 ha
->cmd_tab
[i
].service
= ha
->pccb
->Service
;
1551 ha
->pccb
->CommandIndex
= (ulong32
)i
+2;
1559 static void gdth_set_sema0(int hanum
)
1561 register gdth_ha_str
*ha
;
1563 TRACE(("gdth_set_sema0() hanum %d\n",hanum
));
1565 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1566 if (ha
->type
== GDT_EISA
) {
1567 outb(1, ha
->bmic
+ SEMA0REG
);
1568 } else if (ha
->type
== GDT_ISA
) {
1569 gdth_writeb(1, &((gdt2_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Sema0
);
1570 } else if (ha
->type
== GDT_PCI
) {
1571 gdth_writeb(1, &((gdt6_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Sema0
);
1572 } else if (ha
->type
== GDT_PCINEW
) {
1573 outb(1, PTR2USHORT(&ha
->plx
->sema0_reg
));
1574 } else if (ha
->type
== GDT_PCIMPR
) {
1575 gdth_writeb(1, &((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.sema0_reg
);
1580 static void gdth_copy_command(int hanum
)
1582 register gdth_ha_str
*ha
;
1583 register gdth_cmd_str
*cmd_ptr
;
1584 register gdt6m_dpram_str __iomem
*dp6m_ptr
;
1585 register gdt6c_dpram_str __iomem
*dp6c_ptr
;
1586 gdt6_dpram_str __iomem
*dp6_ptr
;
1587 gdt2_dpram_str __iomem
*dp2_ptr
;
1588 ushort cp_count
,dp_offset
,cmd_no
;
1590 TRACE(("gdth_copy_command() hanum %d\n",hanum
));
1592 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1593 cp_count
= ha
->cmd_len
;
1594 dp_offset
= ha
->cmd_offs_dpmem
;
1595 cmd_no
= ha
->cmd_cnt
;
1599 if (ha
->type
== GDT_EISA
)
1600 return; /* no DPMEM, no copy */
1602 /* set cpcount dword aligned */
1604 cp_count
+= (4 - (cp_count
& 3));
1606 ha
->cmd_offs_dpmem
+= cp_count
;
1608 /* set offset and service, copy command to DPMEM */
1609 if (ha
->type
== GDT_ISA
) {
1611 gdth_writew(dp_offset
+ DPMEM_COMMAND_OFFSET
,
1612 &dp2_ptr
->u
.ic
.comm_queue
[cmd_no
].offset
);
1613 gdth_writew((ushort
)cmd_ptr
->Service
,
1614 &dp2_ptr
->u
.ic
.comm_queue
[cmd_no
].serv_id
);
1615 memcpy_toio(&dp2_ptr
->u
.ic
.gdt_dpr_cmd
[dp_offset
],cmd_ptr
,cp_count
);
1616 } else if (ha
->type
== GDT_PCI
) {
1618 gdth_writew(dp_offset
+ DPMEM_COMMAND_OFFSET
,
1619 &dp6_ptr
->u
.ic
.comm_queue
[cmd_no
].offset
);
1620 gdth_writew((ushort
)cmd_ptr
->Service
,
1621 &dp6_ptr
->u
.ic
.comm_queue
[cmd_no
].serv_id
);
1622 memcpy_toio(&dp6_ptr
->u
.ic
.gdt_dpr_cmd
[dp_offset
],cmd_ptr
,cp_count
);
1623 } else if (ha
->type
== GDT_PCINEW
) {
1625 gdth_writew(dp_offset
+ DPMEM_COMMAND_OFFSET
,
1626 &dp6c_ptr
->u
.ic
.comm_queue
[cmd_no
].offset
);
1627 gdth_writew((ushort
)cmd_ptr
->Service
,
1628 &dp6c_ptr
->u
.ic
.comm_queue
[cmd_no
].serv_id
);
1629 memcpy_toio(&dp6c_ptr
->u
.ic
.gdt_dpr_cmd
[dp_offset
],cmd_ptr
,cp_count
);
1630 } else if (ha
->type
== GDT_PCIMPR
) {
1632 gdth_writew(dp_offset
+ DPMEM_COMMAND_OFFSET
,
1633 &dp6m_ptr
->u
.ic
.comm_queue
[cmd_no
].offset
);
1634 gdth_writew((ushort
)cmd_ptr
->Service
,
1635 &dp6m_ptr
->u
.ic
.comm_queue
[cmd_no
].serv_id
);
1636 memcpy_toio(&dp6m_ptr
->u
.ic
.gdt_dpr_cmd
[dp_offset
],cmd_ptr
,cp_count
);
1641 static void gdth_release_event(int hanum
)
1643 register gdth_ha_str
*ha
;
1645 TRACE(("gdth_release_event() hanum %d\n",hanum
));
1646 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1648 #ifdef GDTH_STATISTICS
1651 for (i
=0,j
=0; j
<GDTH_MAXCMDS
; ++j
) {
1652 if (ha
->cmd_tab
[j
].cmnd
!= UNUSED_CMND
)
1655 if (max_index
< i
) {
1657 TRACE3(("GDT: max_index = %d\n",(ushort
)i
));
1662 if (ha
->pccb
->OpCode
== GDT_INIT
)
1663 ha
->pccb
->Service
|= 0x80;
1665 if (ha
->type
== GDT_EISA
) {
1666 if (ha
->pccb
->OpCode
== GDT_INIT
) /* store DMA buffer */
1667 outl(ha
->ccb_phys
, ha
->bmic
+ MAILBOXREG
);
1668 outb(ha
->pccb
->Service
, ha
->bmic
+ LDOORREG
);
1669 } else if (ha
->type
== GDT_ISA
) {
1670 gdth_writeb(0, &((gdt2_dpram_str __iomem
*)ha
->brd
)->io
.event
);
1671 } else if (ha
->type
== GDT_PCI
) {
1672 gdth_writeb(0, &((gdt6_dpram_str __iomem
*)ha
->brd
)->io
.event
);
1673 } else if (ha
->type
== GDT_PCINEW
) {
1674 outb(1, PTR2USHORT(&ha
->plx
->ldoor_reg
));
1675 } else if (ha
->type
== GDT_PCIMPR
) {
1676 gdth_writeb(1, &((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.ldoor_reg
);
1681 static int gdth_wait(int hanum
,int index
,ulong32 time
)
1684 int answer_found
= FALSE
;
1686 TRACE(("gdth_wait() hanum %d index %d time %d\n",hanum
,index
,time
));
1688 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1690 return 1; /* no wait required */
1692 gdth_from_wait
= TRUE
;
1694 gdth_interrupt((int)ha
->irq
,ha
,NULL
);
1695 if (wait_hanum
==hanum
&& wait_index
==index
) {
1696 answer_found
= TRUE
;
1701 gdth_from_wait
= FALSE
;
1703 while (gdth_test_busy(hanum
))
1706 return (answer_found
);
1710 static int gdth_internal_cmd(int hanum
,unchar service
,ushort opcode
,ulong32 p1
,
1711 ulong64 p2
,ulong64 p3
)
1713 register gdth_ha_str
*ha
;
1714 register gdth_cmd_str
*cmd_ptr
;
1717 TRACE2(("gdth_internal_cmd() service %d opcode %d\n",service
,opcode
));
1719 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1721 memset((char*)cmd_ptr
,0,sizeof(gdth_cmd_str
));
1724 for (retries
= INIT_RETRIES
;;) {
1725 cmd_ptr
->Service
= service
;
1726 cmd_ptr
->RequestBuffer
= INTERNAL_CMND
;
1727 if (!(index
=gdth_get_cmd_index(hanum
))) {
1728 TRACE(("GDT: No free command index found\n"));
1731 gdth_set_sema0(hanum
);
1732 cmd_ptr
->OpCode
= opcode
;
1733 cmd_ptr
->BoardNode
= LOCALBOARD
;
1734 if (service
== CACHESERVICE
) {
1735 if (opcode
== GDT_IOCTL
) {
1736 cmd_ptr
->u
.ioctl
.subfunc
= p1
;
1737 cmd_ptr
->u
.ioctl
.channel
= (ulong32
)p2
;
1738 cmd_ptr
->u
.ioctl
.param_size
= (ushort
)p3
;
1739 cmd_ptr
->u
.ioctl
.p_param
= ha
->scratch_phys
;
1741 if (ha
->cache_feat
& GDT_64BIT
) {
1742 cmd_ptr
->u
.cache64
.DeviceNo
= (ushort
)p1
;
1743 cmd_ptr
->u
.cache64
.BlockNo
= p2
;
1745 cmd_ptr
->u
.cache
.DeviceNo
= (ushort
)p1
;
1746 cmd_ptr
->u
.cache
.BlockNo
= (ulong32
)p2
;
1749 } else if (service
== SCSIRAWSERVICE
) {
1750 if (ha
->raw_feat
& GDT_64BIT
) {
1751 cmd_ptr
->u
.raw64
.direction
= p1
;
1752 cmd_ptr
->u
.raw64
.bus
= (unchar
)p2
;
1753 cmd_ptr
->u
.raw64
.target
= (unchar
)p3
;
1754 cmd_ptr
->u
.raw64
.lun
= (unchar
)(p3
>> 8);
1756 cmd_ptr
->u
.raw
.direction
= p1
;
1757 cmd_ptr
->u
.raw
.bus
= (unchar
)p2
;
1758 cmd_ptr
->u
.raw
.target
= (unchar
)p3
;
1759 cmd_ptr
->u
.raw
.lun
= (unchar
)(p3
>> 8);
1761 } else if (service
== SCREENSERVICE
) {
1762 if (opcode
== GDT_REALTIME
) {
1763 *(ulong32
*)&cmd_ptr
->u
.screen
.su
.data
[0] = p1
;
1764 *(ulong32
*)&cmd_ptr
->u
.screen
.su
.data
[4] = (ulong32
)p2
;
1765 *(ulong32
*)&cmd_ptr
->u
.screen
.su
.data
[8] = (ulong32
)p3
;
1768 ha
->cmd_len
= sizeof(gdth_cmd_str
);
1769 ha
->cmd_offs_dpmem
= 0;
1771 gdth_copy_command(hanum
);
1772 gdth_release_event(hanum
);
1774 if (!gdth_wait(hanum
,index
,INIT_TIMEOUT
)) {
1775 printk("GDT: Initialization error (timeout service %d)\n",service
);
1778 if (ha
->status
!= S_BSY
|| --retries
== 0)
1783 return (ha
->status
!= S_OK
? 0:1);
1787 /* search for devices */
1789 static int __init
gdth_search_drives(int hanum
)
1791 register gdth_ha_str
*ha
;
1794 ulong32 bus_no
, drv_cnt
, drv_no
, j
;
1795 gdth_getch_str
*chn
;
1796 gdth_drlist_str
*drl
;
1797 gdth_iochan_str
*ioc
;
1798 gdth_raw_iochan_str
*iocr
;
1799 gdth_arcdl_str
*alst
;
1800 gdth_alist_str
*alst2
;
1801 gdth_oem_str_ioctl
*oemstr
;
1803 gdth_perf_modes
*pmod
;
1811 TRACE(("gdth_search_drives() hanum %d\n",hanum
));
1812 ha
= HADATA(gdth_ctr_tab
[hanum
]);
1815 /* initialize controller services, at first: screen service */
1816 ha
->screen_feat
= 0;
1818 ok
= gdth_internal_cmd(hanum
,SCREENSERVICE
,GDT_X_INIT_SCR
,0,0,0);
1820 ha
->screen_feat
= GDT_64BIT
;
1822 if (force_dma32
|| (!ok
&& ha
->status
== (ushort
)S_NOFUNC
))
1823 ok
= gdth_internal_cmd(hanum
,SCREENSERVICE
,GDT_INIT
,0,0,0);
1825 printk("GDT-HA %d: Initialization error screen service (code %d)\n",
1829 TRACE2(("gdth_search_drives(): SCREENSERVICE initialized\n"));
1832 /* read realtime clock info, send to controller */
1833 /* 1. wait for the falling edge of update flag */
1834 spin_lock_irqsave(&rtc_lock
, flags
);
1835 for (j
= 0; j
< 1000000; ++j
)
1836 if (CMOS_READ(RTC_FREQ_SELECT
) & RTC_UIP
)
1838 for (j
= 0; j
< 1000000; ++j
)
1839 if (!(CMOS_READ(RTC_FREQ_SELECT
) & RTC_UIP
))
1843 for (j
= 0; j
< 12; ++j
)
1844 rtc
[j
] = CMOS_READ(j
);
1845 } while (rtc
[0] != CMOS_READ(0));
1846 spin_lock_irqrestore(&rtc_lock
, flags
);
1847 TRACE2(("gdth_search_drives(): RTC: %x/%x/%x\n",*(ulong32
*)&rtc
[0],
1848 *(ulong32
*)&rtc
[4], *(ulong32
*)&rtc
[8]));
1849 /* 3. send to controller firmware */
1850 gdth_internal_cmd(hanum
,SCREENSERVICE
,GDT_REALTIME
, *(ulong32
*)&rtc
[0],
1851 *(ulong32
*)&rtc
[4], *(ulong32
*)&rtc
[8]);
1854 /* unfreeze all IOs */
1855 gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_UNFREEZE_IO
,0,0,0);
1857 /* initialize cache service */
1860 ok
= gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_X_INIT_HOST
,LINUX_OS
,0,0);
1862 ha
->cache_feat
= GDT_64BIT
;
1864 if (force_dma32
|| (!ok
&& ha
->status
== (ushort
)S_NOFUNC
))
1865 ok
= gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_INIT
,LINUX_OS
,0,0);
1867 printk("GDT-HA %d: Initialization error cache service (code %d)\n",
1871 TRACE2(("gdth_search_drives(): CACHESERVICE initialized\n"));
1872 cdev_cnt
= (ushort
)ha
->info
;
1873 ha
->fw_vers
= ha
->service
;
1876 if (ha
->type
== GDT_PCIMPR
) {
1877 /* set perf. modes */
1878 pmod
= (gdth_perf_modes
*)ha
->pscratch
;
1880 pmod
->st_mode
= 1; /* enable one status buffer */
1881 *((ulong64
*)&pmod
->st_buff_addr1
) = ha
->coal_stat_phys
;
1882 pmod
->st_buff_indx1
= COALINDEX
;
1883 pmod
->st_buff_addr2
= 0;
1884 pmod
->st_buff_u_addr2
= 0;
1885 pmod
->st_buff_indx2
= 0;
1886 pmod
->st_buff_size
= sizeof(gdth_coal_status
) * MAXOFFSETS
;
1887 pmod
->cmd_mode
= 0; // disable all cmd buffers
1888 pmod
->cmd_buff_addr1
= 0;
1889 pmod
->cmd_buff_u_addr1
= 0;
1890 pmod
->cmd_buff_indx1
= 0;
1891 pmod
->cmd_buff_addr2
= 0;
1892 pmod
->cmd_buff_u_addr2
= 0;
1893 pmod
->cmd_buff_indx2
= 0;
1894 pmod
->cmd_buff_size
= 0;
1895 pmod
->reserved1
= 0;
1896 pmod
->reserved2
= 0;
1897 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,SET_PERF_MODES
,
1898 INVALID_CHANNEL
,sizeof(gdth_perf_modes
))) {
1899 printk("GDT-HA %d: Interrupt coalescing activated\n", hanum
);
1904 /* detect number of buses - try new IOCTL */
1905 iocr
= (gdth_raw_iochan_str
*)ha
->pscratch
;
1906 iocr
->hdr
.version
= 0xffffffff;
1907 iocr
->hdr
.list_entries
= MAXBUS
;
1908 iocr
->hdr
.first_chan
= 0;
1909 iocr
->hdr
.last_chan
= MAXBUS
-1;
1910 iocr
->hdr
.list_offset
= GDTOFFSOF(gdth_raw_iochan_str
, list
[0]);
1911 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,IOCHAN_RAW_DESC
,
1912 INVALID_CHANNEL
,sizeof(gdth_raw_iochan_str
))) {
1913 TRACE2(("IOCHAN_RAW_DESC supported!\n"));
1914 ha
->bus_cnt
= iocr
->hdr
.chan_count
;
1915 for (bus_no
= 0; bus_no
< ha
->bus_cnt
; ++bus_no
) {
1916 if (iocr
->list
[bus_no
].proc_id
< MAXID
)
1917 ha
->bus_id
[bus_no
] = iocr
->list
[bus_no
].proc_id
;
1919 ha
->bus_id
[bus_no
] = 0xff;
1923 chn
= (gdth_getch_str
*)ha
->pscratch
;
1924 for (bus_no
= 0; bus_no
< MAXBUS
; ++bus_no
) {
1925 chn
->channel_no
= bus_no
;
1926 if (!gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,
1927 SCSI_CHAN_CNT
| L_CTRL_PATTERN
,
1928 IO_CHANNEL
| INVALID_CHANNEL
,
1929 sizeof(gdth_getch_str
))) {
1931 printk("GDT-HA %d: Error detecting channel count (0x%x)\n",
1937 if (chn
->siop_id
< MAXID
)
1938 ha
->bus_id
[bus_no
] = chn
->siop_id
;
1940 ha
->bus_id
[bus_no
] = 0xff;
1942 ha
->bus_cnt
= (unchar
)bus_no
;
1944 TRACE2(("gdth_search_drives() %d channels\n",ha
->bus_cnt
));
1946 /* read cache configuration */
1947 if (!gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,CACHE_INFO
,
1948 INVALID_CHANNEL
,sizeof(gdth_cinfo_str
))) {
1949 printk("GDT-HA %d: Initialization error cache service (code %d)\n",
1953 ha
->cpar
= ((gdth_cinfo_str
*)ha
->pscratch
)->cpar
;
1954 TRACE2(("gdth_search_drives() cinfo: vs %x sta %d str %d dw %d b %d\n",
1955 ha
->cpar
.version
,ha
->cpar
.state
,ha
->cpar
.strategy
,
1956 ha
->cpar
.write_back
,ha
->cpar
.block_size
));
1958 /* read board info and features */
1959 ha
->more_proc
= FALSE
;
1960 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,BOARD_INFO
,
1961 INVALID_CHANNEL
,sizeof(gdth_binfo_str
))) {
1962 memcpy(&ha
->binfo
, (gdth_binfo_str
*)ha
->pscratch
,
1963 sizeof(gdth_binfo_str
));
1964 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,BOARD_FEATURES
,
1965 INVALID_CHANNEL
,sizeof(gdth_bfeat_str
))) {
1966 TRACE2(("BOARD_INFO/BOARD_FEATURES supported\n"));
1967 ha
->bfeat
= *(gdth_bfeat_str
*)ha
->pscratch
;
1968 ha
->more_proc
= TRUE
;
1971 TRACE2(("BOARD_INFO requires firmware >= 1.10/2.08\n"));
1972 strcpy(ha
->binfo
.type_string
, gdth_ctr_name(hanum
));
1974 TRACE2(("Controller name: %s\n",ha
->binfo
.type_string
));
1976 /* read more informations */
1977 if (ha
->more_proc
) {
1978 /* physical drives, channel addresses */
1979 ioc
= (gdth_iochan_str
*)ha
->pscratch
;
1980 ioc
->hdr
.version
= 0xffffffff;
1981 ioc
->hdr
.list_entries
= MAXBUS
;
1982 ioc
->hdr
.first_chan
= 0;
1983 ioc
->hdr
.last_chan
= MAXBUS
-1;
1984 ioc
->hdr
.list_offset
= GDTOFFSOF(gdth_iochan_str
, list
[0]);
1985 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,IOCHAN_DESC
,
1986 INVALID_CHANNEL
,sizeof(gdth_iochan_str
))) {
1987 for (bus_no
= 0; bus_no
< ha
->bus_cnt
; ++bus_no
) {
1988 ha
->raw
[bus_no
].address
= ioc
->list
[bus_no
].address
;
1989 ha
->raw
[bus_no
].local_no
= ioc
->list
[bus_no
].local_no
;
1992 for (bus_no
= 0; bus_no
< ha
->bus_cnt
; ++bus_no
) {
1993 ha
->raw
[bus_no
].address
= IO_CHANNEL
;
1994 ha
->raw
[bus_no
].local_no
= bus_no
;
1997 for (bus_no
= 0; bus_no
< ha
->bus_cnt
; ++bus_no
) {
1998 chn
= (gdth_getch_str
*)ha
->pscratch
;
1999 chn
->channel_no
= ha
->raw
[bus_no
].local_no
;
2000 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,
2001 SCSI_CHAN_CNT
| L_CTRL_PATTERN
,
2002 ha
->raw
[bus_no
].address
| INVALID_CHANNEL
,
2003 sizeof(gdth_getch_str
))) {
2004 ha
->raw
[bus_no
].pdev_cnt
= chn
->drive_cnt
;
2005 TRACE2(("Channel %d: %d phys. drives\n",
2006 bus_no
,chn
->drive_cnt
));
2008 if (ha
->raw
[bus_no
].pdev_cnt
> 0) {
2009 drl
= (gdth_drlist_str
*)ha
->pscratch
;
2010 drl
->sc_no
= ha
->raw
[bus_no
].local_no
;
2011 drl
->sc_cnt
= ha
->raw
[bus_no
].pdev_cnt
;
2012 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,
2013 SCSI_DR_LIST
| L_CTRL_PATTERN
,
2014 ha
->raw
[bus_no
].address
| INVALID_CHANNEL
,
2015 sizeof(gdth_drlist_str
))) {
2016 for (j
= 0; j
< ha
->raw
[bus_no
].pdev_cnt
; ++j
)
2017 ha
->raw
[bus_no
].id_list
[j
] = drl
->sc_list
[j
];
2019 ha
->raw
[bus_no
].pdev_cnt
= 0;
2024 /* logical drives */
2025 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,CACHE_DRV_CNT
,
2026 INVALID_CHANNEL
,sizeof(ulong32
))) {
2027 drv_cnt
= *(ulong32
*)ha
->pscratch
;
2028 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,CACHE_DRV_LIST
,
2029 INVALID_CHANNEL
,drv_cnt
* sizeof(ulong32
))) {
2030 for (j
= 0; j
< drv_cnt
; ++j
) {
2031 drv_no
= ((ulong32
*)ha
->pscratch
)[j
];
2032 if (drv_no
< MAX_LDRIVES
) {
2033 ha
->hdr
[drv_no
].is_logdrv
= TRUE
;
2034 TRACE2(("Drive %d is log. drive\n",drv_no
));
2038 alst
= (gdth_arcdl_str
*)ha
->pscratch
;
2039 alst
->entries_avail
= MAX_LDRIVES
;
2040 alst
->first_entry
= 0;
2041 alst
->list_offset
= GDTOFFSOF(gdth_arcdl_str
, list
[0]);
2042 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,
2043 ARRAY_DRV_LIST2
| LA_CTRL_PATTERN
,
2044 INVALID_CHANNEL
, sizeof(gdth_arcdl_str
) +
2045 (alst
->entries_avail
-1) * sizeof(gdth_alist_str
))) {
2046 for (j
= 0; j
< alst
->entries_init
; ++j
) {
2047 ha
->hdr
[j
].is_arraydrv
= alst
->list
[j
].is_arrayd
;
2048 ha
->hdr
[j
].is_master
= alst
->list
[j
].is_master
;
2049 ha
->hdr
[j
].is_parity
= alst
->list
[j
].is_parity
;
2050 ha
->hdr
[j
].is_hotfix
= alst
->list
[j
].is_hotfix
;
2051 ha
->hdr
[j
].master_no
= alst
->list
[j
].cd_handle
;
2053 } else if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,
2054 ARRAY_DRV_LIST
| LA_CTRL_PATTERN
,
2055 0, 35 * sizeof(gdth_alist_str
))) {
2056 for (j
= 0; j
< 35; ++j
) {
2057 alst2
= &((gdth_alist_str
*)ha
->pscratch
)[j
];
2058 ha
->hdr
[j
].is_arraydrv
= alst2
->is_arrayd
;
2059 ha
->hdr
[j
].is_master
= alst2
->is_master
;
2060 ha
->hdr
[j
].is_parity
= alst2
->is_parity
;
2061 ha
->hdr
[j
].is_hotfix
= alst2
->is_hotfix
;
2062 ha
->hdr
[j
].master_no
= alst2
->cd_handle
;
2068 /* initialize raw service */
2071 ok
= gdth_internal_cmd(hanum
,SCSIRAWSERVICE
,GDT_X_INIT_RAW
,0,0,0);
2073 ha
->raw_feat
= GDT_64BIT
;
2075 if (force_dma32
|| (!ok
&& ha
->status
== (ushort
)S_NOFUNC
))
2076 ok
= gdth_internal_cmd(hanum
,SCSIRAWSERVICE
,GDT_INIT
,0,0,0);
2078 printk("GDT-HA %d: Initialization error raw service (code %d)\n",
2082 TRACE2(("gdth_search_drives(): RAWSERVICE initialized\n"));
2084 /* set/get features raw service (scatter/gather) */
2085 if (gdth_internal_cmd(hanum
,SCSIRAWSERVICE
,GDT_SET_FEAT
,SCATTER_GATHER
,
2087 TRACE2(("gdth_search_drives(): set features RAWSERVICE OK\n"));
2088 if (gdth_internal_cmd(hanum
,SCSIRAWSERVICE
,GDT_GET_FEAT
,0,0,0)) {
2089 TRACE2(("gdth_search_dr(): get feat RAWSERVICE %d\n",
2091 ha
->raw_feat
|= (ushort
)ha
->info
;
2095 /* set/get features cache service (equal to raw service) */
2096 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_SET_FEAT
,0,
2097 SCATTER_GATHER
,0)) {
2098 TRACE2(("gdth_search_drives(): set features CACHESERVICE OK\n"));
2099 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_GET_FEAT
,0,0,0)) {
2100 TRACE2(("gdth_search_dr(): get feat CACHESERV. %d\n",
2102 ha
->cache_feat
|= (ushort
)ha
->info
;
2106 /* reserve drives for raw service */
2107 if (reserve_mode
!= 0) {
2108 gdth_internal_cmd(hanum
,SCSIRAWSERVICE
,GDT_RESERVE_ALL
,
2109 reserve_mode
== 1 ? 1 : 3, 0, 0);
2110 TRACE2(("gdth_search_drives(): RESERVE_ALL code %d\n",
2113 for (i
= 0; i
< MAX_RES_ARGS
; i
+= 4) {
2114 if (reserve_list
[i
] == hanum
&& reserve_list
[i
+1] < ha
->bus_cnt
&&
2115 reserve_list
[i
+2] < ha
->tid_cnt
&& reserve_list
[i
+3] < MAXLUN
) {
2116 TRACE2(("gdth_search_drives(): reserve ha %d bus %d id %d lun %d\n",
2117 reserve_list
[i
], reserve_list
[i
+1],
2118 reserve_list
[i
+2], reserve_list
[i
+3]));
2119 if (!gdth_internal_cmd(hanum
,SCSIRAWSERVICE
,GDT_RESERVE
,0,
2120 reserve_list
[i
+1], reserve_list
[i
+2] |
2121 (reserve_list
[i
+3] << 8))) {
2122 printk("GDT-HA %d: Error raw service (RESERVE, code %d)\n",
2128 /* Determine OEM string using IOCTL */
2129 oemstr
= (gdth_oem_str_ioctl
*)ha
->pscratch
;
2130 oemstr
->params
.ctl_version
= 0x01;
2131 oemstr
->params
.buffer_size
= sizeof(oemstr
->text
);
2132 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_IOCTL
,
2133 CACHE_READ_OEM_STRING_RECORD
,INVALID_CHANNEL
,
2134 sizeof(gdth_oem_str_ioctl
))) {
2135 TRACE2(("gdth_search_drives(): CACHE_READ_OEM_STRING_RECORD OK\n"));
2136 printk("GDT-HA %d: Vendor: %s Name: %s\n",
2137 hanum
,oemstr
->text
.oem_company_name
,ha
->binfo
.type_string
);
2138 /* Save the Host Drive inquiry data */
2139 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
2140 strlcpy(ha
->oem_name
,oemstr
->text
.scsi_host_drive_inquiry_vendor_id
,
2141 sizeof(ha
->oem_name
));
2143 strncpy(ha
->oem_name
,oemstr
->text
.scsi_host_drive_inquiry_vendor_id
,7);
2144 ha
->oem_name
[7] = '\0';
2147 /* Old method, based on PCI ID */
2148 TRACE2(("gdth_search_drives(): CACHE_READ_OEM_STRING_RECORD failed\n"));
2149 printk("GDT-HA %d: Name: %s\n",
2150 hanum
,ha
->binfo
.type_string
);
2151 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
2152 if (ha
->oem_id
== OEM_ID_INTEL
)
2153 strlcpy(ha
->oem_name
,"Intel ", sizeof(ha
->oem_name
));
2155 strlcpy(ha
->oem_name
,"ICP ", sizeof(ha
->oem_name
));
2157 if (ha
->oem_id
== OEM_ID_INTEL
)
2158 strcpy(ha
->oem_name
,"Intel ");
2160 strcpy(ha
->oem_name
,"ICP ");
2164 /* scanning for host drives */
2165 for (i
= 0; i
< cdev_cnt
; ++i
)
2166 gdth_analyse_hdrive(hanum
,i
);
2168 TRACE(("gdth_search_drives() OK\n"));
2172 static int gdth_analyse_hdrive(int hanum
,ushort hdrive
)
2174 register gdth_ha_str
*ha
;
2176 int drv_hds
, drv_secs
;
2178 TRACE(("gdth_analyse_hdrive() hanum %d drive %d\n",hanum
,hdrive
));
2179 if (hdrive
>= MAX_HDRIVES
)
2181 ha
= HADATA(gdth_ctr_tab
[hanum
]);
2183 if (!gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_INFO
,hdrive
,0,0))
2185 ha
->hdr
[hdrive
].present
= TRUE
;
2186 ha
->hdr
[hdrive
].size
= ha
->info
;
2188 /* evaluate mapping (sectors per head, heads per cylinder) */
2189 ha
->hdr
[hdrive
].size
&= ~SECS32
;
2190 if (ha
->info2
== 0) {
2191 gdth_eval_mapping(ha
->hdr
[hdrive
].size
,&drv_cyls
,&drv_hds
,&drv_secs
);
2193 drv_hds
= ha
->info2
& 0xff;
2194 drv_secs
= (ha
->info2
>> 8) & 0xff;
2195 drv_cyls
= (ulong32
)ha
->hdr
[hdrive
].size
/ drv_hds
/ drv_secs
;
2197 ha
->hdr
[hdrive
].heads
= (unchar
)drv_hds
;
2198 ha
->hdr
[hdrive
].secs
= (unchar
)drv_secs
;
2200 ha
->hdr
[hdrive
].size
= drv_cyls
* drv_hds
* drv_secs
;
2202 if (ha
->cache_feat
& GDT_64BIT
) {
2203 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_X_INFO
,hdrive
,0,0)
2204 && ha
->info2
!= 0) {
2205 ha
->hdr
[hdrive
].size
= ((ulong64
)ha
->info2
<< 32) | ha
->info
;
2208 TRACE2(("gdth_search_dr() cdr. %d size %d hds %d scs %d\n",
2209 hdrive
,ha
->hdr
[hdrive
].size
,drv_hds
,drv_secs
));
2211 /* get informations about device */
2212 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_DEVTYPE
,hdrive
,0,0)) {
2213 TRACE2(("gdth_search_dr() cache drive %d devtype %d\n",
2215 ha
->hdr
[hdrive
].devtype
= (ushort
)ha
->info
;
2219 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_CLUST_INFO
,hdrive
,0,0)) {
2220 TRACE2(("gdth_search_dr() cache drive %d cluster info %d\n",
2223 ha
->hdr
[hdrive
].cluster_type
= (unchar
)ha
->info
;
2226 /* R/W attributes */
2227 if (gdth_internal_cmd(hanum
,CACHESERVICE
,GDT_RW_ATTRIBS
,hdrive
,0,0)) {
2228 TRACE2(("gdth_search_dr() cache drive %d r/w attrib. %d\n",
2230 ha
->hdr
[hdrive
].rw_attribs
= (unchar
)ha
->info
;
2237 /* command queueing/sending functions */
2239 static void gdth_putq(int hanum
,Scsi_Cmnd
*scp
,unchar priority
)
2241 register gdth_ha_str
*ha
;
2242 register Scsi_Cmnd
*pscp
;
2243 register Scsi_Cmnd
*nscp
;
2247 TRACE(("gdth_putq() priority %d\n",priority
));
2248 ha
= HADATA(gdth_ctr_tab
[hanum
]);
2249 spin_lock_irqsave(&ha
->smp_lock
, flags
);
2251 scp
->SCp
.this_residual
= (int)priority
;
2252 b
= virt_ctr
? NUMDATA(scp
->device
->host
)->busnum
: scp
->device
->channel
;
2253 t
= scp
->device
->id
;
2254 if (priority
>= DEFAULT_PRI
) {
2255 if ((b
!= ha
->virt_bus
&& ha
->raw
[BUS_L2P(ha
,b
)].lock
) ||
2256 (b
== ha
->virt_bus
&& t
< MAX_HDRIVES
&& ha
->hdr
[t
].lock
)) {
2257 TRACE2(("gdth_putq(): locked IO -> update_timeout()\n"));
2258 scp
->SCp
.buffers_residual
= gdth_update_timeout(hanum
, scp
, 0);
2262 if (ha
->req_first
==NULL
) {
2263 ha
->req_first
= scp
; /* queue was empty */
2264 scp
->SCp
.ptr
= NULL
;
2265 } else { /* queue not empty */
2266 pscp
= ha
->req_first
;
2267 nscp
= (Scsi_Cmnd
*)pscp
->SCp
.ptr
;
2268 /* priority: 0-highest,..,0xff-lowest */
2269 while (nscp
&& (unchar
)nscp
->SCp
.this_residual
<= priority
) {
2271 nscp
= (Scsi_Cmnd
*)pscp
->SCp
.ptr
;
2273 pscp
->SCp
.ptr
= (char *)scp
;
2274 scp
->SCp
.ptr
= (char *)nscp
;
2276 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
2278 #ifdef GDTH_STATISTICS
2280 for (nscp
=ha
->req_first
; nscp
; nscp
=(Scsi_Cmnd
*)nscp
->SCp
.ptr
)
2282 if (max_rq
< flags
) {
2284 TRACE3(("GDT: max_rq = %d\n",(ushort
)max_rq
));
2289 static void gdth_next(int hanum
)
2291 register gdth_ha_str
*ha
;
2292 register Scsi_Cmnd
*pscp
;
2293 register Scsi_Cmnd
*nscp
;
2294 unchar b
, t
, l
, firsttime
;
2295 unchar this_cmd
, next_cmd
;
2299 TRACE(("gdth_next() hanum %d\n",hanum
));
2300 ha
= HADATA(gdth_ctr_tab
[hanum
]);
2302 spin_lock_irqsave(&ha
->smp_lock
, flags
);
2304 ha
->cmd_cnt
= ha
->cmd_offs_dpmem
= 0;
2305 this_cmd
= firsttime
= TRUE
;
2306 next_cmd
= gdth_polling
? FALSE
:TRUE
;
2309 for (nscp
= pscp
= ha
->req_first
; nscp
; nscp
= (Scsi_Cmnd
*)nscp
->SCp
.ptr
) {
2310 if (nscp
!= pscp
&& nscp
!= (Scsi_Cmnd
*)pscp
->SCp
.ptr
)
2311 pscp
= (Scsi_Cmnd
*)pscp
->SCp
.ptr
;
2312 b
= virt_ctr
? NUMDATA(nscp
->device
->host
)->busnum
: nscp
->device
->channel
;
2313 t
= nscp
->device
->id
;
2314 l
= nscp
->device
->lun
;
2315 if (nscp
->SCp
.this_residual
>= DEFAULT_PRI
) {
2316 if ((b
!= ha
->virt_bus
&& ha
->raw
[BUS_L2P(ha
,b
)].lock
) ||
2317 (b
== ha
->virt_bus
&& t
< MAX_HDRIVES
&& ha
->hdr
[t
].lock
))
2322 if (gdth_test_busy(hanum
)) { /* controller busy ? */
2323 TRACE(("gdth_next() controller %d busy !\n",hanum
));
2324 if (!gdth_polling
) {
2325 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
2328 while (gdth_test_busy(hanum
))
2334 if (nscp
->done
!= gdth_scsi_done
|| nscp
->cmnd
[0] != 0xff) {
2335 if (nscp
->SCp
.phase
== -1) {
2336 nscp
->SCp
.phase
= CACHESERVICE
; /* default: cache svc. */
2337 if (nscp
->cmnd
[0] == TEST_UNIT_READY
) {
2338 TRACE2(("TEST_UNIT_READY Bus %d Id %d LUN %d\n",
2340 /* TEST_UNIT_READY -> set scan mode */
2341 if ((ha
->scan_mode
& 0x0f) == 0) {
2342 if (b
== 0 && t
== 0 && l
== 0) {
2344 TRACE2(("Scan mode: 0x%x\n", ha
->scan_mode
));
2346 } else if ((ha
->scan_mode
& 0x0f) == 1) {
2347 if (b
== 0 && ((t
== 0 && l
== 1) ||
2348 (t
== 1 && l
== 0))) {
2349 nscp
->SCp
.sent_command
= GDT_SCAN_START
;
2350 nscp
->SCp
.phase
= ((ha
->scan_mode
& 0x10 ? 1:0) << 8)
2352 ha
->scan_mode
= 0x12;
2353 TRACE2(("Scan mode: 0x%x (SCAN_START)\n",
2356 ha
->scan_mode
&= 0x10;
2357 TRACE2(("Scan mode: 0x%x\n", ha
->scan_mode
));
2359 } else if (ha
->scan_mode
== 0x12) {
2360 if (b
== ha
->bus_cnt
&& t
== ha
->tid_cnt
-1) {
2361 nscp
->SCp
.phase
= SCSIRAWSERVICE
;
2362 nscp
->SCp
.sent_command
= GDT_SCAN_END
;
2363 ha
->scan_mode
&= 0x10;
2364 TRACE2(("Scan mode: 0x%x (SCAN_END)\n",
2369 if (b
== ha
->virt_bus
&& nscp
->cmnd
[0] != INQUIRY
&&
2370 nscp
->cmnd
[0] != READ_CAPACITY
&& nscp
->cmnd
[0] != MODE_SENSE
&&
2371 (ha
->hdr
[t
].cluster_type
& CLUSTER_DRIVE
)) {
2372 /* always GDT_CLUST_INFO! */
2373 nscp
->SCp
.sent_command
= GDT_CLUST_INFO
;
2378 if (nscp
->SCp
.sent_command
!= -1) {
2379 if ((nscp
->SCp
.phase
& 0xff) == CACHESERVICE
) {
2380 if (!(cmd_index
=gdth_fill_cache_cmd(hanum
,nscp
,t
)))
2383 } else if ((nscp
->SCp
.phase
& 0xff) == SCSIRAWSERVICE
) {
2384 if (!(cmd_index
=gdth_fill_raw_cmd(hanum
,nscp
,BUS_L2P(ha
,b
))))
2388 memset((char*)nscp
->sense_buffer
,0,16);
2389 nscp
->sense_buffer
[0] = 0x70;
2390 nscp
->sense_buffer
[2] = NOT_READY
;
2391 nscp
->result
= (DID_OK
<< 16) | (CHECK_CONDITION
<< 1);
2392 if (!nscp
->SCp
.have_data_in
)
2393 nscp
->SCp
.have_data_in
++;
2395 nscp
->scsi_done(nscp
);
2397 } else if (nscp
->done
== gdth_scsi_done
&& nscp
->cmnd
[0] == 0xff) {
2398 if (!(cmd_index
=gdth_special_cmd(hanum
,nscp
)))
2401 } else if (b
!= ha
->virt_bus
) {
2402 if (ha
->raw
[BUS_L2P(ha
,b
)].io_cnt
[t
] >= GDTH_MAX_RAW
||
2403 !(cmd_index
=gdth_fill_raw_cmd(hanum
,nscp
,BUS_L2P(ha
,b
))))
2406 ha
->raw
[BUS_L2P(ha
,b
)].io_cnt
[t
]++;
2407 } else if (t
>= MAX_HDRIVES
|| !ha
->hdr
[t
].present
|| l
!= 0) {
2408 TRACE2(("Command 0x%x to bus %d id %d lun %d -> IGNORE\n",
2409 nscp
->cmnd
[0], b
, t
, l
));
2410 nscp
->result
= DID_BAD_TARGET
<< 16;
2411 if (!nscp
->SCp
.have_data_in
)
2412 nscp
->SCp
.have_data_in
++;
2414 nscp
->scsi_done(nscp
);
2416 switch (nscp
->cmnd
[0]) {
2417 case TEST_UNIT_READY
:
2424 case SERVICE_ACTION_IN
:
2425 TRACE(("cache cmd %x/%x/%x/%x/%x/%x\n",nscp
->cmnd
[0],
2426 nscp
->cmnd
[1],nscp
->cmnd
[2],nscp
->cmnd
[3],
2427 nscp
->cmnd
[4],nscp
->cmnd
[5]));
2428 if (ha
->hdr
[t
].media_changed
&& nscp
->cmnd
[0] != INQUIRY
) {
2429 /* return UNIT_ATTENTION */
2430 TRACE2(("cmd 0x%x target %d: UNIT_ATTENTION\n",
2432 ha
->hdr
[t
].media_changed
= FALSE
;
2433 memset((char*)nscp
->sense_buffer
,0,16);
2434 nscp
->sense_buffer
[0] = 0x70;
2435 nscp
->sense_buffer
[2] = UNIT_ATTENTION
;
2436 nscp
->result
= (DID_OK
<< 16) | (CHECK_CONDITION
<< 1);
2437 if (!nscp
->SCp
.have_data_in
)
2438 nscp
->SCp
.have_data_in
++;
2440 nscp
->scsi_done(nscp
);
2441 } else if (gdth_internal_cache_cmd(hanum
,nscp
))
2442 nscp
->scsi_done(nscp
);
2445 case ALLOW_MEDIUM_REMOVAL
:
2446 TRACE(("cache cmd %x/%x/%x/%x/%x/%x\n",nscp
->cmnd
[0],
2447 nscp
->cmnd
[1],nscp
->cmnd
[2],nscp
->cmnd
[3],
2448 nscp
->cmnd
[4],nscp
->cmnd
[5]));
2449 if ( (nscp
->cmnd
[4]&1) && !(ha
->hdr
[t
].devtype
&1) ) {
2450 TRACE(("Prevent r. nonremov. drive->do nothing\n"));
2451 nscp
->result
= DID_OK
<< 16;
2452 nscp
->sense_buffer
[0] = 0;
2453 if (!nscp
->SCp
.have_data_in
)
2454 nscp
->SCp
.have_data_in
++;
2456 nscp
->scsi_done(nscp
);
2458 nscp
->cmnd
[3] = (ha
->hdr
[t
].devtype
&1) ? 1:0;
2459 TRACE(("Prevent/allow r. %d rem. drive %d\n",
2460 nscp
->cmnd
[4],nscp
->cmnd
[3]));
2461 if (!(cmd_index
=gdth_fill_cache_cmd(hanum
,nscp
,t
)))
2468 TRACE2(("cache cmd %s\n",nscp
->cmnd
[0] == RESERVE
?
2469 "RESERVE" : "RELEASE"));
2470 if (!(cmd_index
=gdth_fill_cache_cmd(hanum
,nscp
,t
)))
2480 if (ha
->hdr
[t
].media_changed
) {
2481 /* return UNIT_ATTENTION */
2482 TRACE2(("cmd 0x%x target %d: UNIT_ATTENTION\n",
2484 ha
->hdr
[t
].media_changed
= FALSE
;
2485 memset((char*)nscp
->sense_buffer
,0,16);
2486 nscp
->sense_buffer
[0] = 0x70;
2487 nscp
->sense_buffer
[2] = UNIT_ATTENTION
;
2488 nscp
->result
= (DID_OK
<< 16) | (CHECK_CONDITION
<< 1);
2489 if (!nscp
->SCp
.have_data_in
)
2490 nscp
->SCp
.have_data_in
++;
2492 nscp
->scsi_done(nscp
);
2493 } else if (!(cmd_index
=gdth_fill_cache_cmd(hanum
,nscp
,t
)))
2498 TRACE2(("cache cmd %x/%x/%x/%x/%x/%x unknown\n",nscp
->cmnd
[0],
2499 nscp
->cmnd
[1],nscp
->cmnd
[2],nscp
->cmnd
[3],
2500 nscp
->cmnd
[4],nscp
->cmnd
[5]));
2501 printk("GDT-HA %d: Unknown SCSI command 0x%x to cache service !\n",
2502 hanum
, nscp
->cmnd
[0]);
2503 nscp
->result
= DID_ABORT
<< 16;
2504 if (!nscp
->SCp
.have_data_in
)
2505 nscp
->SCp
.have_data_in
++;
2507 nscp
->scsi_done(nscp
);
2514 if (nscp
== ha
->req_first
)
2515 ha
->req_first
= pscp
= (Scsi_Cmnd
*)nscp
->SCp
.ptr
;
2517 pscp
->SCp
.ptr
= nscp
->SCp
.ptr
;
2522 if (ha
->cmd_cnt
> 0) {
2523 gdth_release_event(hanum
);
2527 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
2529 if (gdth_polling
&& ha
->cmd_cnt
> 0) {
2530 if (!gdth_wait(hanum
,cmd_index
,POLL_TIMEOUT
))
2531 printk("GDT-HA %d: Command %d timed out !\n",
2536 static void gdth_copy_internal_data(int hanum
,Scsi_Cmnd
*scp
,
2537 char *buffer
,ushort count
)
2541 struct scatterlist
*sl
;
2545 cpcount
= count
<=(ushort
)scp
->bufflen
? count
:(ushort
)scp
->bufflen
;
2546 ha
= HADATA(gdth_ctr_tab
[hanum
]);
2549 sl
= (struct scatterlist
*)scp
->request_buffer
;
2550 for (i
=0,cpsum
=0; i
<scp
->use_sg
; ++i
,++sl
) {
2551 unsigned long flags
;
2552 cpnow
= (ushort
)sl
->length
;
2553 TRACE(("copy_internal() now %d sum %d count %d %d\n",
2554 cpnow
,cpsum
,cpcount
,(ushort
)scp
->bufflen
));
2555 if (cpsum
+cpnow
> cpcount
)
2556 cpnow
= cpcount
- cpsum
;
2559 printk("GDT-HA %d: invalid sc/gt element in gdth_copy_internal_data()\n",
2563 local_irq_save(flags
);
2564 address
= kmap_atomic(sl
->page
, KM_BIO_SRC_IRQ
) + sl
->offset
;
2565 memcpy(address
,buffer
,cpnow
);
2566 flush_dcache_page(sl
->page
);
2567 kunmap_atomic(address
, KM_BIO_SRC_IRQ
);
2568 local_irq_restore(flags
);
2569 if (cpsum
== cpcount
)
2574 TRACE(("copy_internal() count %d\n",cpcount
));
2575 memcpy((char*)scp
->request_buffer
,buffer
,cpcount
);
2579 static int gdth_internal_cache_cmd(int hanum
,Scsi_Cmnd
*scp
)
2581 register gdth_ha_str
*ha
;
2584 gdth_rdcap_data rdc
;
2586 gdth_modep_data mpd
;
2588 ha
= HADATA(gdth_ctr_tab
[hanum
]);
2589 t
= scp
->device
->id
;
2590 TRACE(("gdth_internal_cache_cmd() cmd 0x%x hdrive %d\n",
2593 scp
->result
= DID_OK
<< 16;
2594 scp
->sense_buffer
[0] = 0;
2596 switch (scp
->cmnd
[0]) {
2597 case TEST_UNIT_READY
:
2600 TRACE2(("Test/Verify/Start hdrive %d\n",t
));
2604 TRACE2(("Inquiry hdrive %d devtype %d\n",
2605 t
,ha
->hdr
[t
].devtype
));
2606 inq
.type_qual
= (ha
->hdr
[t
].devtype
&4) ? TYPE_ROM
:TYPE_DISK
;
2607 /* you can here set all disks to removable, if you want to do
2608 a flush using the ALLOW_MEDIUM_REMOVAL command */
2609 inq
.modif_rmb
= 0x00;
2610 if ((ha
->hdr
[t
].devtype
& 1) ||
2611 (ha
->hdr
[t
].cluster_type
& CLUSTER_DRIVE
))
2612 inq
.modif_rmb
= 0x80;
2616 strcpy(inq
.vendor
,ha
->oem_name
);
2617 sprintf(inq
.product
,"Host Drive #%02d",t
);
2618 strcpy(inq
.revision
," ");
2619 gdth_copy_internal_data(hanum
,scp
,(char*)&inq
,sizeof(gdth_inq_data
));
2623 TRACE2(("Request sense hdrive %d\n",t
));
2624 sd
.errorcode
= 0x70;
2629 gdth_copy_internal_data(hanum
,scp
,(char*)&sd
,sizeof(gdth_sense_data
));
2633 TRACE2(("Mode sense hdrive %d\n",t
));
2634 memset((char*)&mpd
,0,sizeof(gdth_modep_data
));
2635 mpd
.hd
.data_length
= sizeof(gdth_modep_data
);
2636 mpd
.hd
.dev_par
= (ha
->hdr
[t
].devtype
&2) ? 0x80:0;
2637 mpd
.hd
.bd_length
= sizeof(mpd
.bd
);
2638 mpd
.bd
.block_length
[0] = (SECTOR_SIZE
& 0x00ff0000) >> 16;
2639 mpd
.bd
.block_length
[1] = (SECTOR_SIZE
& 0x0000ff00) >> 8;
2640 mpd
.bd
.block_length
[2] = (SECTOR_SIZE
& 0x000000ff);
2641 gdth_copy_internal_data(hanum
,scp
,(char*)&mpd
,sizeof(gdth_modep_data
));
2645 TRACE2(("Read capacity hdrive %d\n",t
));
2646 if (ha
->hdr
[t
].size
> (ulong64
)0xffffffff)
2647 rdc
.last_block_no
= 0xffffffff;
2649 rdc
.last_block_no
= cpu_to_be32(ha
->hdr
[t
].size
-1);
2650 rdc
.block_length
= cpu_to_be32(SECTOR_SIZE
);
2651 gdth_copy_internal_data(hanum
,scp
,(char*)&rdc
,sizeof(gdth_rdcap_data
));
2654 case SERVICE_ACTION_IN
:
2655 if ((scp
->cmnd
[1] & 0x1f) == SAI_READ_CAPACITY_16
&&
2656 (ha
->cache_feat
& GDT_64BIT
)) {
2657 gdth_rdcap16_data rdc16
;
2659 TRACE2(("Read capacity (16) hdrive %d\n",t
));
2660 rdc16
.last_block_no
= cpu_to_be64(ha
->hdr
[t
].size
-1);
2661 rdc16
.block_length
= cpu_to_be32(SECTOR_SIZE
);
2662 gdth_copy_internal_data(hanum
,scp
,(char*)&rdc16
,sizeof(gdth_rdcap16_data
));
2664 scp
->result
= DID_ABORT
<< 16;
2669 TRACE2(("Internal cache cmd 0x%x unknown\n",scp
->cmnd
[0]));
2673 if (!scp
->SCp
.have_data_in
)
2674 scp
->SCp
.have_data_in
++;
2681 static int gdth_fill_cache_cmd(int hanum
,Scsi_Cmnd
*scp
,ushort hdrive
)
2683 register gdth_ha_str
*ha
;
2684 register gdth_cmd_str
*cmdp
;
2685 struct scatterlist
*sl
;
2686 ulong32 cnt
, blockcnt
;
2687 ulong64 no
, blockno
;
2688 dma_addr_t phys_addr
;
2689 int i
, cmd_index
, read_write
, sgcnt
, mode64
;
2693 ha
= HADATA(gdth_ctr_tab
[hanum
]);
2695 TRACE(("gdth_fill_cache_cmd() cmd 0x%x cmdsize %d hdrive %d\n",
2696 scp
->cmnd
[0],scp
->cmd_len
,hdrive
));
2698 if (ha
->type
==GDT_EISA
&& ha
->cmd_cnt
>0)
2701 mode64
= (ha
->cache_feat
& GDT_64BIT
) ? TRUE
: FALSE
;
2702 /* test for READ_16, WRITE_16 if !mode64 ? ---
2703 not required, should not occur due to error return on
2706 cmdp
->Service
= CACHESERVICE
;
2707 cmdp
->RequestBuffer
= scp
;
2708 /* search free command index */
2709 if (!(cmd_index
=gdth_get_cmd_index(hanum
))) {
2710 TRACE(("GDT: No free command index found\n"));
2713 /* if it's the first command, set command semaphore */
2714 if (ha
->cmd_cnt
== 0)
2715 gdth_set_sema0(hanum
);
2719 if (scp
->SCp
.sent_command
!= -1)
2720 cmdp
->OpCode
= scp
->SCp
.sent_command
; /* special cache cmd. */
2721 else if (scp
->cmnd
[0] == RESERVE
)
2722 cmdp
->OpCode
= GDT_RESERVE_DRV
;
2723 else if (scp
->cmnd
[0] == RELEASE
)
2724 cmdp
->OpCode
= GDT_RELEASE_DRV
;
2725 else if (scp
->cmnd
[0] == ALLOW_MEDIUM_REMOVAL
) {
2726 if (scp
->cmnd
[4] & 1) /* prevent ? */
2727 cmdp
->OpCode
= GDT_MOUNT
;
2728 else if (scp
->cmnd
[3] & 1) /* removable drive ? */
2729 cmdp
->OpCode
= GDT_UNMOUNT
;
2731 cmdp
->OpCode
= GDT_FLUSH
;
2732 } else if (scp
->cmnd
[0] == WRITE_6
|| scp
->cmnd
[0] == WRITE_10
||
2733 scp
->cmnd
[0] == WRITE_12
|| scp
->cmnd
[0] == WRITE_16
2736 if (gdth_write_through
|| ((ha
->hdr
[hdrive
].rw_attribs
& 1) &&
2737 (ha
->cache_feat
& GDT_WR_THROUGH
)))
2738 cmdp
->OpCode
= GDT_WRITE_THR
;
2740 cmdp
->OpCode
= GDT_WRITE
;
2743 cmdp
->OpCode
= GDT_READ
;
2746 cmdp
->BoardNode
= LOCALBOARD
;
2748 cmdp
->u
.cache64
.DeviceNo
= hdrive
;
2749 cmdp
->u
.cache64
.BlockNo
= 1;
2750 cmdp
->u
.cache64
.sg_canz
= 0;
2752 cmdp
->u
.cache
.DeviceNo
= hdrive
;
2753 cmdp
->u
.cache
.BlockNo
= 1;
2754 cmdp
->u
.cache
.sg_canz
= 0;
2758 if (scp
->cmd_len
== 16) {
2759 memcpy(&no
, &scp
->cmnd
[2], sizeof(ulong64
));
2760 blockno
= be64_to_cpu(no
);
2761 memcpy(&cnt
, &scp
->cmnd
[10], sizeof(ulong32
));
2762 blockcnt
= be32_to_cpu(cnt
);
2763 } else if (scp
->cmd_len
== 10) {
2764 memcpy(&no
, &scp
->cmnd
[2], sizeof(ulong32
));
2765 blockno
= be32_to_cpu(no
);
2766 memcpy(&cnt
, &scp
->cmnd
[7], sizeof(ushort
));
2767 blockcnt
= be16_to_cpu(cnt
);
2769 memcpy(&no
, &scp
->cmnd
[0], sizeof(ulong32
));
2770 blockno
= be32_to_cpu(no
) & 0x001fffffUL
;
2771 blockcnt
= scp
->cmnd
[4]==0 ? 0x100 : scp
->cmnd
[4];
2774 cmdp
->u
.cache64
.BlockNo
= blockno
;
2775 cmdp
->u
.cache64
.BlockCnt
= blockcnt
;
2777 cmdp
->u
.cache
.BlockNo
= (ulong32
)blockno
;
2778 cmdp
->u
.cache
.BlockCnt
= blockcnt
;
2782 sl
= (struct scatterlist
*)scp
->request_buffer
;
2783 sgcnt
= scp
->use_sg
;
2784 scp
->SCp
.Status
= GDTH_MAP_SG
;
2785 scp
->SCp
.Message
= (read_write
== 1 ?
2786 PCI_DMA_TODEVICE
: PCI_DMA_FROMDEVICE
);
2787 sgcnt
= pci_map_sg(ha
->pdev
,sl
,scp
->use_sg
,scp
->SCp
.Message
);
2789 cmdp
->u
.cache64
.DestAddr
= (ulong64
)-1;
2790 cmdp
->u
.cache64
.sg_canz
= sgcnt
;
2791 for (i
=0; i
<sgcnt
; ++i
,++sl
) {
2792 cmdp
->u
.cache64
.sg_lst
[i
].sg_ptr
= sg_dma_address(sl
);
2793 #ifdef GDTH_DMA_STATISTICS
2794 if (cmdp
->u
.cache64
.sg_lst
[i
].sg_ptr
> (ulong64
)0xffffffff)
2799 cmdp
->u
.cache64
.sg_lst
[i
].sg_len
= sg_dma_len(sl
);
2802 cmdp
->u
.cache
.DestAddr
= 0xffffffff;
2803 cmdp
->u
.cache
.sg_canz
= sgcnt
;
2804 for (i
=0; i
<sgcnt
; ++i
,++sl
) {
2805 cmdp
->u
.cache
.sg_lst
[i
].sg_ptr
= sg_dma_address(sl
);
2806 #ifdef GDTH_DMA_STATISTICS
2809 cmdp
->u
.cache
.sg_lst
[i
].sg_len
= sg_dma_len(sl
);
2813 #ifdef GDTH_STATISTICS
2814 if (max_sg
< (ulong32
)sgcnt
) {
2815 max_sg
= (ulong32
)sgcnt
;
2816 TRACE3(("GDT: max_sg = %d\n",max_sg
));
2820 } else if (scp
->request_bufflen
) {
2821 scp
->SCp
.Status
= GDTH_MAP_SINGLE
;
2822 scp
->SCp
.Message
= (read_write
== 1 ?
2823 PCI_DMA_TODEVICE
: PCI_DMA_FROMDEVICE
);
2824 page
= virt_to_page(scp
->request_buffer
);
2825 offset
= (ulong
)scp
->request_buffer
& ~PAGE_MASK
;
2826 phys_addr
= pci_map_page(ha
->pdev
,page
,offset
,
2827 scp
->request_bufflen
,scp
->SCp
.Message
);
2828 scp
->SCp
.dma_handle
= phys_addr
;
2830 if (ha
->cache_feat
& SCATTER_GATHER
) {
2831 cmdp
->u
.cache64
.DestAddr
= (ulong64
)-1;
2832 cmdp
->u
.cache64
.sg_canz
= 1;
2833 cmdp
->u
.cache64
.sg_lst
[0].sg_ptr
= phys_addr
;
2834 cmdp
->u
.cache64
.sg_lst
[0].sg_len
= scp
->request_bufflen
;
2835 cmdp
->u
.cache64
.sg_lst
[1].sg_len
= 0;
2837 cmdp
->u
.cache64
.DestAddr
= phys_addr
;
2838 cmdp
->u
.cache64
.sg_canz
= 0;
2841 if (ha
->cache_feat
& SCATTER_GATHER
) {
2842 cmdp
->u
.cache
.DestAddr
= 0xffffffff;
2843 cmdp
->u
.cache
.sg_canz
= 1;
2844 cmdp
->u
.cache
.sg_lst
[0].sg_ptr
= phys_addr
;
2845 cmdp
->u
.cache
.sg_lst
[0].sg_len
= scp
->request_bufflen
;
2846 cmdp
->u
.cache
.sg_lst
[1].sg_len
= 0;
2848 cmdp
->u
.cache
.DestAddr
= phys_addr
;
2849 cmdp
->u
.cache
.sg_canz
= 0;
2854 /* evaluate command size, check space */
2856 TRACE(("cache cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n",
2857 cmdp
->u
.cache64
.DestAddr
,cmdp
->u
.cache64
.sg_canz
,
2858 cmdp
->u
.cache64
.sg_lst
[0].sg_ptr
,
2859 cmdp
->u
.cache64
.sg_lst
[0].sg_len
));
2860 TRACE(("cache cmd: cmd %d blockno. %d, blockcnt %d\n",
2861 cmdp
->OpCode
,cmdp
->u
.cache64
.BlockNo
,cmdp
->u
.cache64
.BlockCnt
));
2862 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.cache64
.sg_lst
) +
2863 (ushort
)cmdp
->u
.cache64
.sg_canz
* sizeof(gdth_sg64_str
);
2865 TRACE(("cache cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n",
2866 cmdp
->u
.cache
.DestAddr
,cmdp
->u
.cache
.sg_canz
,
2867 cmdp
->u
.cache
.sg_lst
[0].sg_ptr
,
2868 cmdp
->u
.cache
.sg_lst
[0].sg_len
));
2869 TRACE(("cache cmd: cmd %d blockno. %d, blockcnt %d\n",
2870 cmdp
->OpCode
,cmdp
->u
.cache
.BlockNo
,cmdp
->u
.cache
.BlockCnt
));
2871 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.cache
.sg_lst
) +
2872 (ushort
)cmdp
->u
.cache
.sg_canz
* sizeof(gdth_sg_str
);
2874 if (ha
->cmd_len
& 3)
2875 ha
->cmd_len
+= (4 - (ha
->cmd_len
& 3));
2877 if (ha
->cmd_cnt
> 0) {
2878 if ((ha
->cmd_offs_dpmem
+ ha
->cmd_len
+ DPMEM_COMMAND_OFFSET
) >
2880 TRACE2(("gdth_fill_cache() DPMEM overflow\n"));
2881 ha
->cmd_tab
[cmd_index
-2].cmnd
= UNUSED_CMND
;
2887 gdth_copy_command(hanum
);
2891 static int gdth_fill_raw_cmd(int hanum
,Scsi_Cmnd
*scp
,unchar b
)
2893 register gdth_ha_str
*ha
;
2894 register gdth_cmd_str
*cmdp
;
2895 struct scatterlist
*sl
;
2897 dma_addr_t phys_addr
, sense_paddr
;
2898 int cmd_index
, sgcnt
, mode64
;
2903 ha
= HADATA(gdth_ctr_tab
[hanum
]);
2904 t
= scp
->device
->id
;
2905 l
= scp
->device
->lun
;
2907 TRACE(("gdth_fill_raw_cmd() cmd 0x%x bus %d ID %d LUN %d\n",
2908 scp
->cmnd
[0],b
,t
,l
));
2910 if (ha
->type
==GDT_EISA
&& ha
->cmd_cnt
>0)
2913 mode64
= (ha
->raw_feat
& GDT_64BIT
) ? TRUE
: FALSE
;
2915 cmdp
->Service
= SCSIRAWSERVICE
;
2916 cmdp
->RequestBuffer
= scp
;
2917 /* search free command index */
2918 if (!(cmd_index
=gdth_get_cmd_index(hanum
))) {
2919 TRACE(("GDT: No free command index found\n"));
2922 /* if it's the first command, set command semaphore */
2923 if (ha
->cmd_cnt
== 0)
2924 gdth_set_sema0(hanum
);
2927 if (scp
->SCp
.sent_command
!= -1) {
2928 cmdp
->OpCode
= scp
->SCp
.sent_command
; /* special raw cmd. */
2929 cmdp
->BoardNode
= LOCALBOARD
;
2931 cmdp
->u
.raw64
.direction
= (scp
->SCp
.phase
>> 8);
2932 TRACE2(("special raw cmd 0x%x param 0x%x\n",
2933 cmdp
->OpCode
, cmdp
->u
.raw64
.direction
));
2934 /* evaluate command size */
2935 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.raw64
.sg_lst
);
2937 cmdp
->u
.raw
.direction
= (scp
->SCp
.phase
>> 8);
2938 TRACE2(("special raw cmd 0x%x param 0x%x\n",
2939 cmdp
->OpCode
, cmdp
->u
.raw
.direction
));
2940 /* evaluate command size */
2941 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.raw
.sg_lst
);
2945 page
= virt_to_page(scp
->sense_buffer
);
2946 offset
= (ulong
)scp
->sense_buffer
& ~PAGE_MASK
;
2947 sense_paddr
= pci_map_page(ha
->pdev
,page
,offset
,
2948 16,PCI_DMA_FROMDEVICE
);
2949 scp
->SCp
.buffer
= (struct scatterlist
*)((ulong32
)sense_paddr
);
2950 /* high part, if 64bit */
2951 scp
->host_scribble
= (char *)(ulong32
)((ulong64
)sense_paddr
>> 32);
2952 cmdp
->OpCode
= GDT_WRITE
; /* always */
2953 cmdp
->BoardNode
= LOCALBOARD
;
2955 cmdp
->u
.raw64
.reserved
= 0;
2956 cmdp
->u
.raw64
.mdisc_time
= 0;
2957 cmdp
->u
.raw64
.mcon_time
= 0;
2958 cmdp
->u
.raw64
.clen
= scp
->cmd_len
;
2959 cmdp
->u
.raw64
.target
= t
;
2960 cmdp
->u
.raw64
.lun
= l
;
2961 cmdp
->u
.raw64
.bus
= b
;
2962 cmdp
->u
.raw64
.priority
= 0;
2963 cmdp
->u
.raw64
.sdlen
= scp
->request_bufflen
;
2964 cmdp
->u
.raw64
.sense_len
= 16;
2965 cmdp
->u
.raw64
.sense_data
= sense_paddr
;
2966 cmdp
->u
.raw64
.direction
=
2967 gdth_direction_tab
[scp
->cmnd
[0]]==DOU
? GDTH_DATA_OUT
:GDTH_DATA_IN
;
2968 memcpy(cmdp
->u
.raw64
.cmd
,scp
->cmnd
,16);
2970 cmdp
->u
.raw
.reserved
= 0;
2971 cmdp
->u
.raw
.mdisc_time
= 0;
2972 cmdp
->u
.raw
.mcon_time
= 0;
2973 cmdp
->u
.raw
.clen
= scp
->cmd_len
;
2974 cmdp
->u
.raw
.target
= t
;
2975 cmdp
->u
.raw
.lun
= l
;
2976 cmdp
->u
.raw
.bus
= b
;
2977 cmdp
->u
.raw
.priority
= 0;
2978 cmdp
->u
.raw
.link_p
= 0;
2979 cmdp
->u
.raw
.sdlen
= scp
->request_bufflen
;
2980 cmdp
->u
.raw
.sense_len
= 16;
2981 cmdp
->u
.raw
.sense_data
= sense_paddr
;
2982 cmdp
->u
.raw
.direction
=
2983 gdth_direction_tab
[scp
->cmnd
[0]]==DOU
? GDTH_DATA_OUT
:GDTH_DATA_IN
;
2984 memcpy(cmdp
->u
.raw
.cmd
,scp
->cmnd
,12);
2988 sl
= (struct scatterlist
*)scp
->request_buffer
;
2989 sgcnt
= scp
->use_sg
;
2990 scp
->SCp
.Status
= GDTH_MAP_SG
;
2991 scp
->SCp
.Message
= PCI_DMA_BIDIRECTIONAL
;
2992 sgcnt
= pci_map_sg(ha
->pdev
,sl
,scp
->use_sg
,scp
->SCp
.Message
);
2994 cmdp
->u
.raw64
.sdata
= (ulong64
)-1;
2995 cmdp
->u
.raw64
.sg_ranz
= sgcnt
;
2996 for (i
=0; i
<sgcnt
; ++i
,++sl
) {
2997 cmdp
->u
.raw64
.sg_lst
[i
].sg_ptr
= sg_dma_address(sl
);
2998 #ifdef GDTH_DMA_STATISTICS
2999 if (cmdp
->u
.raw64
.sg_lst
[i
].sg_ptr
> (ulong64
)0xffffffff)
3004 cmdp
->u
.raw64
.sg_lst
[i
].sg_len
= sg_dma_len(sl
);
3007 cmdp
->u
.raw
.sdata
= 0xffffffff;
3008 cmdp
->u
.raw
.sg_ranz
= sgcnt
;
3009 for (i
=0; i
<sgcnt
; ++i
,++sl
) {
3010 cmdp
->u
.raw
.sg_lst
[i
].sg_ptr
= sg_dma_address(sl
);
3011 #ifdef GDTH_DMA_STATISTICS
3014 cmdp
->u
.raw
.sg_lst
[i
].sg_len
= sg_dma_len(sl
);
3018 #ifdef GDTH_STATISTICS
3019 if (max_sg
< sgcnt
) {
3021 TRACE3(("GDT: max_sg = %d\n",sgcnt
));
3026 scp
->SCp
.Status
= GDTH_MAP_SINGLE
;
3027 scp
->SCp
.Message
= PCI_DMA_BIDIRECTIONAL
;
3028 page
= virt_to_page(scp
->request_buffer
);
3029 offset
= (ulong
)scp
->request_buffer
& ~PAGE_MASK
;
3030 phys_addr
= pci_map_page(ha
->pdev
,page
,offset
,
3031 scp
->request_bufflen
,scp
->SCp
.Message
);
3032 scp
->SCp
.dma_handle
= phys_addr
;
3035 if (ha
->raw_feat
& SCATTER_GATHER
) {
3036 cmdp
->u
.raw64
.sdata
= (ulong64
)-1;
3037 cmdp
->u
.raw64
.sg_ranz
= 1;
3038 cmdp
->u
.raw64
.sg_lst
[0].sg_ptr
= phys_addr
;
3039 cmdp
->u
.raw64
.sg_lst
[0].sg_len
= scp
->request_bufflen
;
3040 cmdp
->u
.raw64
.sg_lst
[1].sg_len
= 0;
3042 cmdp
->u
.raw64
.sdata
= phys_addr
;
3043 cmdp
->u
.raw64
.sg_ranz
= 0;
3046 if (ha
->raw_feat
& SCATTER_GATHER
) {
3047 cmdp
->u
.raw
.sdata
= 0xffffffff;
3048 cmdp
->u
.raw
.sg_ranz
= 1;
3049 cmdp
->u
.raw
.sg_lst
[0].sg_ptr
= phys_addr
;
3050 cmdp
->u
.raw
.sg_lst
[0].sg_len
= scp
->request_bufflen
;
3051 cmdp
->u
.raw
.sg_lst
[1].sg_len
= 0;
3053 cmdp
->u
.raw
.sdata
= phys_addr
;
3054 cmdp
->u
.raw
.sg_ranz
= 0;
3059 TRACE(("raw cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n",
3060 cmdp
->u
.raw64
.sdata
,cmdp
->u
.raw64
.sg_ranz
,
3061 cmdp
->u
.raw64
.sg_lst
[0].sg_ptr
,
3062 cmdp
->u
.raw64
.sg_lst
[0].sg_len
));
3063 /* evaluate command size */
3064 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.raw64
.sg_lst
) +
3065 (ushort
)cmdp
->u
.raw64
.sg_ranz
* sizeof(gdth_sg64_str
);
3067 TRACE(("raw cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n",
3068 cmdp
->u
.raw
.sdata
,cmdp
->u
.raw
.sg_ranz
,
3069 cmdp
->u
.raw
.sg_lst
[0].sg_ptr
,
3070 cmdp
->u
.raw
.sg_lst
[0].sg_len
));
3071 /* evaluate command size */
3072 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.raw
.sg_lst
) +
3073 (ushort
)cmdp
->u
.raw
.sg_ranz
* sizeof(gdth_sg_str
);
3077 if (ha
->cmd_len
& 3)
3078 ha
->cmd_len
+= (4 - (ha
->cmd_len
& 3));
3080 if (ha
->cmd_cnt
> 0) {
3081 if ((ha
->cmd_offs_dpmem
+ ha
->cmd_len
+ DPMEM_COMMAND_OFFSET
) >
3083 TRACE2(("gdth_fill_raw() DPMEM overflow\n"));
3084 ha
->cmd_tab
[cmd_index
-2].cmnd
= UNUSED_CMND
;
3090 gdth_copy_command(hanum
);
3094 static int gdth_special_cmd(int hanum
,Scsi_Cmnd
*scp
)
3096 register gdth_ha_str
*ha
;
3097 register gdth_cmd_str
*cmdp
;
3100 ha
= HADATA(gdth_ctr_tab
[hanum
]);
3102 TRACE2(("gdth_special_cmd(): "));
3104 if (ha
->type
==GDT_EISA
&& ha
->cmd_cnt
>0)
3107 memcpy( cmdp
, scp
->request_buffer
, sizeof(gdth_cmd_str
));
3108 cmdp
->RequestBuffer
= scp
;
3110 /* search free command index */
3111 if (!(cmd_index
=gdth_get_cmd_index(hanum
))) {
3112 TRACE(("GDT: No free command index found\n"));
3116 /* if it's the first command, set command semaphore */
3117 if (ha
->cmd_cnt
== 0)
3118 gdth_set_sema0(hanum
);
3120 /* evaluate command size, check space */
3121 if (cmdp
->OpCode
== GDT_IOCTL
) {
3122 TRACE2(("IOCTL\n"));
3124 GDTOFFSOF(gdth_cmd_str
,u
.ioctl
.p_param
) + sizeof(ulong64
);
3125 } else if (cmdp
->Service
== CACHESERVICE
) {
3126 TRACE2(("cache command %d\n",cmdp
->OpCode
));
3127 if (ha
->cache_feat
& GDT_64BIT
)
3129 GDTOFFSOF(gdth_cmd_str
,u
.cache64
.sg_lst
) + sizeof(gdth_sg64_str
);
3132 GDTOFFSOF(gdth_cmd_str
,u
.cache
.sg_lst
) + sizeof(gdth_sg_str
);
3133 } else if (cmdp
->Service
== SCSIRAWSERVICE
) {
3134 TRACE2(("raw command %d\n",cmdp
->OpCode
));
3135 if (ha
->raw_feat
& GDT_64BIT
)
3137 GDTOFFSOF(gdth_cmd_str
,u
.raw64
.sg_lst
) + sizeof(gdth_sg64_str
);
3140 GDTOFFSOF(gdth_cmd_str
,u
.raw
.sg_lst
) + sizeof(gdth_sg_str
);
3143 if (ha
->cmd_len
& 3)
3144 ha
->cmd_len
+= (4 - (ha
->cmd_len
& 3));
3146 if (ha
->cmd_cnt
> 0) {
3147 if ((ha
->cmd_offs_dpmem
+ ha
->cmd_len
+ DPMEM_COMMAND_OFFSET
) >
3149 TRACE2(("gdth_special_cmd() DPMEM overflow\n"));
3150 ha
->cmd_tab
[cmd_index
-2].cmnd
= UNUSED_CMND
;
3156 gdth_copy_command(hanum
);
3161 /* Controller event handling functions */
3162 static gdth_evt_str
*gdth_store_event(gdth_ha_str
*ha
, ushort source
,
3163 ushort idx
, gdth_evt_data
*evt
)
3168 /* no GDTH_LOCK_HA() ! */
3169 TRACE2(("gdth_store_event() source %d idx %d\n", source
, idx
));
3170 if (source
== 0) /* no source -> no event */
3173 if (ebuffer
[elastidx
].event_source
== source
&&
3174 ebuffer
[elastidx
].event_idx
== idx
&&
3175 ((evt
->size
!= 0 && ebuffer
[elastidx
].event_data
.size
!= 0 &&
3176 !memcmp((char *)&ebuffer
[elastidx
].event_data
.eu
,
3177 (char *)&evt
->eu
, evt
->size
)) ||
3178 (evt
->size
== 0 && ebuffer
[elastidx
].event_data
.size
== 0 &&
3179 !strcmp((char *)&ebuffer
[elastidx
].event_data
.event_string
,
3180 (char *)&evt
->event_string
)))) {
3181 e
= &ebuffer
[elastidx
];
3182 do_gettimeofday(&tv
);
3183 e
->last_stamp
= tv
.tv_sec
;
3186 if (ebuffer
[elastidx
].event_source
!= 0) { /* entry not free ? */
3188 if (elastidx
== MAX_EVENTS
)
3190 if (elastidx
== eoldidx
) { /* reached mark ? */
3192 if (eoldidx
== MAX_EVENTS
)
3196 e
= &ebuffer
[elastidx
];
3197 e
->event_source
= source
;
3199 do_gettimeofday(&tv
);
3200 e
->first_stamp
= e
->last_stamp
= tv
.tv_sec
;
3202 e
->event_data
= *evt
;
3208 static int gdth_read_event(gdth_ha_str
*ha
, int handle
, gdth_evt_str
*estr
)
3214 TRACE2(("gdth_read_event() handle %d\n", handle
));
3215 spin_lock_irqsave(&ha
->smp_lock
, flags
);
3220 estr
->event_source
= 0;
3222 if (eindex
>= MAX_EVENTS
) {
3223 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
3226 e
= &ebuffer
[eindex
];
3227 if (e
->event_source
!= 0) {
3228 if (eindex
!= elastidx
) {
3229 if (++eindex
== MAX_EVENTS
)
3234 memcpy(estr
, e
, sizeof(gdth_evt_str
));
3236 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
3240 static void gdth_readapp_event(gdth_ha_str
*ha
,
3241 unchar application
, gdth_evt_str
*estr
)
3246 unchar found
= FALSE
;
3248 TRACE2(("gdth_readapp_event() app. %d\n", application
));
3249 spin_lock_irqsave(&ha
->smp_lock
, flags
);
3252 e
= &ebuffer
[eindex
];
3253 if (e
->event_source
== 0)
3255 if ((e
->application
& application
) == 0) {
3256 e
->application
|= application
;
3260 if (eindex
== elastidx
)
3262 if (++eindex
== MAX_EVENTS
)
3266 memcpy(estr
, e
, sizeof(gdth_evt_str
));
3268 estr
->event_source
= 0;
3269 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
3272 static void gdth_clear_events(void)
3274 TRACE(("gdth_clear_events()"));
3276 eoldidx
= elastidx
= 0;
3277 ebuffer
[0].event_source
= 0;
3281 /* SCSI interface functions */
3283 static irqreturn_t
gdth_interrupt(int irq
,void *dev_id
,struct pt_regs
*regs
)
3285 gdth_ha_str
*ha2
= (gdth_ha_str
*)dev_id
;
3286 register gdth_ha_str
*ha
;
3287 gdt6m_dpram_str __iomem
*dp6m_ptr
= NULL
;
3288 gdt6_dpram_str __iomem
*dp6_ptr
;
3289 gdt2_dpram_str __iomem
*dp2_ptr
;
3296 int coalesced
= FALSE
;
3298 gdth_coal_status
*pcs
= NULL
;
3299 int act_int_coal
= 0;
3302 TRACE(("gdth_interrupt() IRQ %d\n",irq
));
3304 /* if polling and not from gdth_wait() -> return */
3306 if (!gdth_from_wait
) {
3312 spin_lock_irqsave(&ha2
->smp_lock
, flags
);
3315 /* search controller */
3316 if ((hanum
= gdth_get_status(&IStatus
,irq
)) == -1) {
3317 /* spurious interrupt */
3319 spin_unlock_irqrestore(&ha2
->smp_lock
, flags
);
3322 ha
= HADATA(gdth_ctr_tab
[hanum
]);
3324 #ifdef GDTH_STATISTICS
3329 /* See if the fw is returning coalesced status */
3330 if (IStatus
== COALINDEX
) {
3331 /* Coalesced status. Setup the initial status
3332 buffer pointer and flags */
3333 pcs
= ha
->coal_stat
;
3340 /* For coalesced requests all status
3341 information is found in the status buffer */
3342 IStatus
= (unchar
)(pcs
->status
& 0xff);
3346 if (ha
->type
== GDT_EISA
) {
3347 if (IStatus
& 0x80) { /* error flag */
3349 ha
->status
= inw(ha
->bmic
+ MAILBOXREG
+8);
3350 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus
,ha
->status
));
3351 } else /* no error */
3353 ha
->info
= inl(ha
->bmic
+ MAILBOXREG
+12);
3354 ha
->service
= inw(ha
->bmic
+ MAILBOXREG
+10);
3355 ha
->info2
= inl(ha
->bmic
+ MAILBOXREG
+4);
3357 outb(0xff, ha
->bmic
+ EDOORREG
); /* acknowledge interrupt */
3358 outb(0x00, ha
->bmic
+ SEMA1REG
); /* reset status semaphore */
3359 } else if (ha
->type
== GDT_ISA
) {
3361 if (IStatus
& 0x80) { /* error flag */
3363 ha
->status
= gdth_readw(&dp2_ptr
->u
.ic
.Status
);
3364 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus
,ha
->status
));
3365 } else /* no error */
3367 ha
->info
= gdth_readl(&dp2_ptr
->u
.ic
.Info
[0]);
3368 ha
->service
= gdth_readw(&dp2_ptr
->u
.ic
.Service
);
3369 ha
->info2
= gdth_readl(&dp2_ptr
->u
.ic
.Info
[1]);
3371 gdth_writeb(0xff, &dp2_ptr
->io
.irqdel
); /* acknowledge interrupt */
3372 gdth_writeb(0, &dp2_ptr
->u
.ic
.Cmd_Index
);/* reset command index */
3373 gdth_writeb(0, &dp2_ptr
->io
.Sema1
); /* reset status semaphore */
3374 } else if (ha
->type
== GDT_PCI
) {
3376 if (IStatus
& 0x80) { /* error flag */
3378 ha
->status
= gdth_readw(&dp6_ptr
->u
.ic
.Status
);
3379 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus
,ha
->status
));
3380 } else /* no error */
3382 ha
->info
= gdth_readl(&dp6_ptr
->u
.ic
.Info
[0]);
3383 ha
->service
= gdth_readw(&dp6_ptr
->u
.ic
.Service
);
3384 ha
->info2
= gdth_readl(&dp6_ptr
->u
.ic
.Info
[1]);
3386 gdth_writeb(0xff, &dp6_ptr
->io
.irqdel
); /* acknowledge interrupt */
3387 gdth_writeb(0, &dp6_ptr
->u
.ic
.Cmd_Index
);/* reset command index */
3388 gdth_writeb(0, &dp6_ptr
->io
.Sema1
); /* reset status semaphore */
3389 } else if (ha
->type
== GDT_PCINEW
) {
3390 if (IStatus
& 0x80) { /* error flag */
3392 ha
->status
= inw(PTR2USHORT(&ha
->plx
->status
));
3393 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus
,ha
->status
));
3396 ha
->info
= inl(PTR2USHORT(&ha
->plx
->info
[0]));
3397 ha
->service
= inw(PTR2USHORT(&ha
->plx
->service
));
3398 ha
->info2
= inl(PTR2USHORT(&ha
->plx
->info
[1]));
3400 outb(0xff, PTR2USHORT(&ha
->plx
->edoor_reg
));
3401 outb(0x00, PTR2USHORT(&ha
->plx
->sema1_reg
));
3402 } else if (ha
->type
== GDT_PCIMPR
) {
3404 if (IStatus
& 0x80) { /* error flag */
3408 ha
->status
= pcs
->ext_status
&& 0xffff;
3411 ha
->status
= gdth_readw(&dp6m_ptr
->i960r
.status
);
3412 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus
,ha
->status
));
3413 } else /* no error */
3416 /* get information */
3418 ha
->info
= pcs
->info0
;
3419 ha
->info2
= pcs
->info1
;
3420 ha
->service
= (pcs
->ext_status
>> 16) && 0xffff;
3424 ha
->info
= gdth_readl(&dp6m_ptr
->i960r
.info
[0]);
3425 ha
->service
= gdth_readw(&dp6m_ptr
->i960r
.service
);
3426 ha
->info2
= gdth_readl(&dp6m_ptr
->i960r
.info
[1]);
3429 if (IStatus
== ASYNCINDEX
) {
3430 if (ha
->service
!= SCREENSERVICE
&&
3431 (ha
->fw_vers
& 0xff) >= 0x1a) {
3432 ha
->dvr
.severity
= gdth_readb
3433 (&((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.severity
);
3434 for (i
= 0; i
< 256; ++i
) {
3435 ha
->dvr
.event_string
[i
] = gdth_readb
3436 (&((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.evt_str
[i
]);
3437 if (ha
->dvr
.event_string
[i
] == 0)
3443 /* Make sure that non coalesced interrupts get cleared
3444 before being handled by gdth_async_event/gdth_sync_event */
3448 gdth_writeb(0xff, &dp6m_ptr
->i960r
.edoor_reg
);
3449 gdth_writeb(0, &dp6m_ptr
->i960r
.sema1_reg
);
3452 TRACE2(("gdth_interrupt() unknown controller type\n"));
3454 spin_unlock_irqrestore(&ha2
->smp_lock
, flags
);
3458 TRACE(("gdth_interrupt() index %d stat %d info %d\n",
3459 IStatus
,ha
->status
,ha
->info
));
3461 if (gdth_from_wait
) {
3463 wait_index
= (int)IStatus
;
3466 if (IStatus
== ASYNCINDEX
) {
3467 TRACE2(("gdth_interrupt() async. event\n"));
3468 gdth_async_event(hanum
);
3470 spin_unlock_irqrestore(&ha2
->smp_lock
, flags
);
3475 if (IStatus
== SPEZINDEX
) {
3476 TRACE2(("Service unknown or not initialized !\n"));
3477 ha
->dvr
.size
= sizeof(ha
->dvr
.eu
.driver
);
3478 ha
->dvr
.eu
.driver
.ionode
= hanum
;
3479 gdth_store_event(ha
, ES_DRIVER
, 4, &ha
->dvr
);
3481 spin_unlock_irqrestore(&ha2
->smp_lock
, flags
);
3484 scp
= ha
->cmd_tab
[IStatus
-2].cmnd
;
3485 Service
= ha
->cmd_tab
[IStatus
-2].service
;
3486 ha
->cmd_tab
[IStatus
-2].cmnd
= UNUSED_CMND
;
3487 if (scp
== UNUSED_CMND
) {
3488 TRACE2(("gdth_interrupt() index to unused command (%d)\n",IStatus
));
3489 ha
->dvr
.size
= sizeof(ha
->dvr
.eu
.driver
);
3490 ha
->dvr
.eu
.driver
.ionode
= hanum
;
3491 ha
->dvr
.eu
.driver
.index
= IStatus
;
3492 gdth_store_event(ha
, ES_DRIVER
, 1, &ha
->dvr
);
3494 spin_unlock_irqrestore(&ha2
->smp_lock
, flags
);
3497 if (scp
== INTERNAL_CMND
) {
3498 TRACE(("gdth_interrupt() answer to internal command\n"));
3500 spin_unlock_irqrestore(&ha2
->smp_lock
, flags
);
3504 TRACE(("gdth_interrupt() sync. status\n"));
3505 rval
= gdth_sync_event(hanum
,Service
,IStatus
,scp
);
3507 spin_unlock_irqrestore(&ha2
->smp_lock
, flags
);
3509 gdth_putq(hanum
,scp
,scp
->SCp
.this_residual
);
3510 } else if (rval
== 1) {
3511 scp
->scsi_done(scp
);
3516 /* go to the next status in the status buffer */
3518 #ifdef GDTH_STATISTICS
3520 if (act_int_coal
> max_int_coal
) {
3521 max_int_coal
= act_int_coal
;
3522 printk("GDT: max_int_coal = %d\n",(ushort
)max_int_coal
);
3525 /* see if there is another status */
3526 if (pcs
->status
== 0)
3527 /* Stop the coalesce loop */
3532 /* coalescing only for new GDT_PCIMPR controllers available */
3533 if (ha
->type
== GDT_PCIMPR
&& coalesced
) {
3534 gdth_writeb(0xff, &dp6m_ptr
->i960r
.edoor_reg
);
3535 gdth_writeb(0, &dp6m_ptr
->i960r
.sema1_reg
);
3543 static int gdth_sync_event(int hanum
,int service
,unchar index
,Scsi_Cmnd
*scp
)
3545 register gdth_ha_str
*ha
;
3550 ha
= HADATA(gdth_ctr_tab
[hanum
]);
3552 TRACE(("gdth_sync_event() serv %d status %d\n",
3553 service
,ha
->status
));
3555 if (service
== SCREENSERVICE
) {
3557 TRACE(("len: %d, answer: %d, ext: %d, alen: %d\n",
3558 msg
->msg_len
,msg
->msg_answer
,msg
->msg_ext
,msg
->msg_alen
));
3559 if (msg
->msg_len
> MSGLEN
+1)
3560 msg
->msg_len
= MSGLEN
+1;
3562 if (!(msg
->msg_answer
&& msg
->msg_ext
)) {
3563 msg
->msg_text
[msg
->msg_len
] = '\0';
3564 printk("%s",msg
->msg_text
);
3567 if (msg
->msg_ext
&& !msg
->msg_answer
) {
3568 while (gdth_test_busy(hanum
))
3570 cmdp
->Service
= SCREENSERVICE
;
3571 cmdp
->RequestBuffer
= SCREEN_CMND
;
3572 gdth_get_cmd_index(hanum
);
3573 gdth_set_sema0(hanum
);
3574 cmdp
->OpCode
= GDT_READ
;
3575 cmdp
->BoardNode
= LOCALBOARD
;
3576 cmdp
->u
.screen
.reserved
= 0;
3577 cmdp
->u
.screen
.su
.msg
.msg_handle
= msg
->msg_handle
;
3578 cmdp
->u
.screen
.su
.msg
.msg_addr
= ha
->msg_phys
;
3579 ha
->cmd_offs_dpmem
= 0;
3580 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.screen
.su
.msg
.msg_addr
)
3583 gdth_copy_command(hanum
);
3584 gdth_release_event(hanum
);
3588 if (msg
->msg_answer
&& msg
->msg_alen
) {
3589 /* default answers (getchar() not possible) */
3590 if (msg
->msg_alen
== 1) {
3593 msg
->msg_text
[0] = 0;
3597 msg
->msg_text
[0] = 1;
3598 msg
->msg_text
[1] = 0;
3601 msg
->msg_answer
= 0;
3602 while (gdth_test_busy(hanum
))
3604 cmdp
->Service
= SCREENSERVICE
;
3605 cmdp
->RequestBuffer
= SCREEN_CMND
;
3606 gdth_get_cmd_index(hanum
);
3607 gdth_set_sema0(hanum
);
3608 cmdp
->OpCode
= GDT_WRITE
;
3609 cmdp
->BoardNode
= LOCALBOARD
;
3610 cmdp
->u
.screen
.reserved
= 0;
3611 cmdp
->u
.screen
.su
.msg
.msg_handle
= msg
->msg_handle
;
3612 cmdp
->u
.screen
.su
.msg
.msg_addr
= ha
->msg_phys
;
3613 ha
->cmd_offs_dpmem
= 0;
3614 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.screen
.su
.msg
.msg_addr
)
3617 gdth_copy_command(hanum
);
3618 gdth_release_event(hanum
);
3624 b
= virt_ctr
? NUMDATA(scp
->device
->host
)->busnum
: scp
->device
->channel
;
3625 t
= scp
->device
->id
;
3626 if (scp
->SCp
.sent_command
== -1 && b
!= ha
->virt_bus
) {
3627 ha
->raw
[BUS_L2P(ha
,b
)].io_cnt
[t
]--;
3629 /* cache or raw service */
3630 if (ha
->status
== S_BSY
) {
3631 TRACE2(("Controller busy -> retry !\n"));
3632 if (scp
->SCp
.sent_command
== GDT_MOUNT
)
3633 scp
->SCp
.sent_command
= GDT_CLUST_INFO
;
3637 if (scp
->SCp
.Status
== GDTH_MAP_SG
)
3638 pci_unmap_sg(ha
->pdev
,scp
->request_buffer
,
3639 scp
->use_sg
,scp
->SCp
.Message
);
3640 else if (scp
->SCp
.Status
== GDTH_MAP_SINGLE
)
3641 pci_unmap_page(ha
->pdev
,scp
->SCp
.dma_handle
,
3642 scp
->request_bufflen
,scp
->SCp
.Message
);
3643 if (scp
->SCp
.buffer
) {
3645 addr
= (dma_addr_t
)(ulong32
)scp
->SCp
.buffer
;
3646 if (scp
->host_scribble
)
3647 addr
+= (dma_addr_t
)((ulong64
)(ulong32
)scp
->host_scribble
<< 32);
3648 pci_unmap_page(ha
->pdev
,addr
,16,PCI_DMA_FROMDEVICE
);
3651 if (ha
->status
== S_OK
) {
3652 scp
->SCp
.Status
= S_OK
;
3653 scp
->SCp
.Message
= ha
->info
;
3654 if (scp
->SCp
.sent_command
!= -1) {
3655 TRACE2(("gdth_sync_event(): special cmd 0x%x OK\n",
3656 scp
->SCp
.sent_command
));
3657 /* special commands GDT_CLUST_INFO/GDT_MOUNT ? */
3658 if (scp
->SCp
.sent_command
== GDT_CLUST_INFO
) {
3659 ha
->hdr
[t
].cluster_type
= (unchar
)ha
->info
;
3660 if (!(ha
->hdr
[t
].cluster_type
&
3662 /* NOT MOUNTED -> MOUNT */
3663 scp
->SCp
.sent_command
= GDT_MOUNT
;
3664 if (ha
->hdr
[t
].cluster_type
&
3666 /* cluster drive RESERVED (on the other node) */
3667 scp
->SCp
.phase
= -2; /* reservation conflict */
3670 scp
->SCp
.sent_command
= -1;
3673 if (scp
->SCp
.sent_command
== GDT_MOUNT
) {
3674 ha
->hdr
[t
].cluster_type
|= CLUSTER_MOUNTED
;
3675 ha
->hdr
[t
].media_changed
= TRUE
;
3676 } else if (scp
->SCp
.sent_command
== GDT_UNMOUNT
) {
3677 ha
->hdr
[t
].cluster_type
&= ~CLUSTER_MOUNTED
;
3678 ha
->hdr
[t
].media_changed
= TRUE
;
3680 scp
->SCp
.sent_command
= -1;
3683 scp
->SCp
.this_residual
= HIGH_PRI
;
3686 /* RESERVE/RELEASE ? */
3687 if (scp
->cmnd
[0] == RESERVE
) {
3688 ha
->hdr
[t
].cluster_type
|= CLUSTER_RESERVED
;
3689 } else if (scp
->cmnd
[0] == RELEASE
) {
3690 ha
->hdr
[t
].cluster_type
&= ~CLUSTER_RESERVED
;
3692 scp
->result
= DID_OK
<< 16;
3693 scp
->sense_buffer
[0] = 0;
3696 scp
->SCp
.Status
= ha
->status
;
3697 scp
->SCp
.Message
= ha
->info
;
3699 if (scp
->SCp
.sent_command
!= -1) {
3700 TRACE2(("gdth_sync_event(): special cmd 0x%x error 0x%x\n",
3701 scp
->SCp
.sent_command
, ha
->status
));
3702 if (scp
->SCp
.sent_command
== GDT_SCAN_START
||
3703 scp
->SCp
.sent_command
== GDT_SCAN_END
) {
3704 scp
->SCp
.sent_command
= -1;
3706 scp
->SCp
.this_residual
= HIGH_PRI
;
3709 memset((char*)scp
->sense_buffer
,0,16);
3710 scp
->sense_buffer
[0] = 0x70;
3711 scp
->sense_buffer
[2] = NOT_READY
;
3712 scp
->result
= (DID_OK
<< 16) | (CHECK_CONDITION
<< 1);
3713 } else if (service
== CACHESERVICE
) {
3714 if (ha
->status
== S_CACHE_UNKNOWN
&&
3715 (ha
->hdr
[t
].cluster_type
&
3716 CLUSTER_RESERVE_STATE
) == CLUSTER_RESERVE_STATE
) {
3717 /* bus reset -> force GDT_CLUST_INFO */
3718 ha
->hdr
[t
].cluster_type
&= ~CLUSTER_RESERVED
;
3720 memset((char*)scp
->sense_buffer
,0,16);
3721 if (ha
->status
== (ushort
)S_CACHE_RESERV
) {
3722 scp
->result
= (DID_OK
<< 16) | (RESERVATION_CONFLICT
<< 1);
3724 scp
->sense_buffer
[0] = 0x70;
3725 scp
->sense_buffer
[2] = NOT_READY
;
3726 scp
->result
= (DID_OK
<< 16) | (CHECK_CONDITION
<< 1);
3728 if (scp
->done
!= gdth_scsi_done
) {
3729 ha
->dvr
.size
= sizeof(ha
->dvr
.eu
.sync
);
3730 ha
->dvr
.eu
.sync
.ionode
= hanum
;
3731 ha
->dvr
.eu
.sync
.service
= service
;
3732 ha
->dvr
.eu
.sync
.status
= ha
->status
;
3733 ha
->dvr
.eu
.sync
.info
= ha
->info
;
3734 ha
->dvr
.eu
.sync
.hostdrive
= t
;
3735 if (ha
->status
>= 0x8000)
3736 gdth_store_event(ha
, ES_SYNC
, 0, &ha
->dvr
);
3738 gdth_store_event(ha
, ES_SYNC
, service
, &ha
->dvr
);
3741 /* sense buffer filled from controller firmware (DMA) */
3742 if (ha
->status
!= S_RAW_SCSI
|| ha
->info
>= 0x100) {
3743 scp
->result
= DID_BAD_TARGET
<< 16;
3745 scp
->result
= (DID_OK
<< 16) | ha
->info
;
3749 if (!scp
->SCp
.have_data_in
)
3750 scp
->SCp
.have_data_in
++;
3758 static char *async_cache_tab
[] = {
3759 /* 0*/ "\011\000\002\002\002\004\002\006\004"
3760 "GDT HA %u, service %u, async. status %u/%lu unknown",
3761 /* 1*/ "\011\000\002\002\002\004\002\006\004"
3762 "GDT HA %u, service %u, async. status %u/%lu unknown",
3763 /* 2*/ "\005\000\002\006\004"
3764 "GDT HA %u, Host Drive %lu not ready",
3765 /* 3*/ "\005\000\002\006\004"
3766 "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",
3767 /* 4*/ "\005\000\002\006\004"
3768 "GDT HA %u, mirror update on Host Drive %lu failed",
3769 /* 5*/ "\005\000\002\006\004"
3770 "GDT HA %u, Mirror Drive %lu failed",
3771 /* 6*/ "\005\000\002\006\004"
3772 "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",
3773 /* 7*/ "\005\000\002\006\004"
3774 "GDT HA %u, Host Drive %lu write protected",
3775 /* 8*/ "\005\000\002\006\004"
3776 "GDT HA %u, media changed in Host Drive %lu",
3777 /* 9*/ "\005\000\002\006\004"
3778 "GDT HA %u, Host Drive %lu is offline",
3779 /*10*/ "\005\000\002\006\004"
3780 "GDT HA %u, media change of Mirror Drive %lu",
3781 /*11*/ "\005\000\002\006\004"
3782 "GDT HA %u, Mirror Drive %lu is write protected",
3783 /*12*/ "\005\000\002\006\004"
3784 "GDT HA %u, general error on Host Drive %lu. Please check the devices of this drive!",
3785 /*13*/ "\007\000\002\006\002\010\002"
3786 "GDT HA %u, Array Drive %u: Cache Drive %u failed",
3787 /*14*/ "\005\000\002\006\002"
3788 "GDT HA %u, Array Drive %u: FAIL state entered",
3789 /*15*/ "\005\000\002\006\002"
3790 "GDT HA %u, Array Drive %u: error",
3791 /*16*/ "\007\000\002\006\002\010\002"
3792 "GDT HA %u, Array Drive %u: failed drive replaced by Cache Drive %u",
3793 /*17*/ "\005\000\002\006\002"
3794 "GDT HA %u, Array Drive %u: parity build failed",
3795 /*18*/ "\005\000\002\006\002"
3796 "GDT HA %u, Array Drive %u: drive rebuild failed",
3797 /*19*/ "\005\000\002\010\002"
3798 "GDT HA %u, Test of Hot Fix %u failed",
3799 /*20*/ "\005\000\002\006\002"
3800 "GDT HA %u, Array Drive %u: drive build finished successfully",
3801 /*21*/ "\005\000\002\006\002"
3802 "GDT HA %u, Array Drive %u: drive rebuild finished successfully",
3803 /*22*/ "\007\000\002\006\002\010\002"
3804 "GDT HA %u, Array Drive %u: Hot Fix %u activated",
3805 /*23*/ "\005\000\002\006\002"
3806 "GDT HA %u, Host Drive %u: processing of i/o aborted due to serious drive error",
3807 /*24*/ "\005\000\002\010\002"
3808 "GDT HA %u, mirror update on Cache Drive %u completed",
3809 /*25*/ "\005\000\002\010\002"
3810 "GDT HA %u, mirror update on Cache Drive %lu failed",
3811 /*26*/ "\005\000\002\006\002"
3812 "GDT HA %u, Array Drive %u: drive rebuild started",
3813 /*27*/ "\005\000\002\012\001"
3814 "GDT HA %u, Fault bus %u: SHELF OK detected",
3815 /*28*/ "\005\000\002\012\001"
3816 "GDT HA %u, Fault bus %u: SHELF not OK detected",
3817 /*29*/ "\007\000\002\012\001\013\001"
3818 "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug started",
3819 /*30*/ "\007\000\002\012\001\013\001"
3820 "GDT HA %u, Fault bus %u, ID %u: new disk detected",
3821 /*31*/ "\007\000\002\012\001\013\001"
3822 "GDT HA %u, Fault bus %u, ID %u: old disk detected",
3823 /*32*/ "\007\000\002\012\001\013\001"
3824 "GDT HA %u, Fault bus %u, ID %u: plugging an active disk is invalid",
3825 /*33*/ "\007\000\002\012\001\013\001"
3826 "GDT HA %u, Fault bus %u, ID %u: invalid device detected",
3827 /*34*/ "\011\000\002\012\001\013\001\006\004"
3828 "GDT HA %u, Fault bus %u, ID %u: insufficient disk capacity (%lu MB required)",
3829 /*35*/ "\007\000\002\012\001\013\001"
3830 "GDT HA %u, Fault bus %u, ID %u: disk write protected",
3831 /*36*/ "\007\000\002\012\001\013\001"
3832 "GDT HA %u, Fault bus %u, ID %u: disk not available",
3833 /*37*/ "\007\000\002\012\001\006\004"
3834 "GDT HA %u, Fault bus %u: swap detected (%lu)",
3835 /*38*/ "\007\000\002\012\001\013\001"
3836 "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug finished successfully",
3837 /*39*/ "\007\000\002\012\001\013\001"
3838 "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug aborted due to user Hot Plug",
3839 /*40*/ "\007\000\002\012\001\013\001"
3840 "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug aborted",
3841 /*41*/ "\007\000\002\012\001\013\001"
3842 "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug for Hot Fix started",
3843 /*42*/ "\005\000\002\006\002"
3844 "GDT HA %u, Array Drive %u: drive build started",
3845 /*43*/ "\003\000\002"
3846 "GDT HA %u, DRAM parity error detected",
3847 /*44*/ "\005\000\002\006\002"
3848 "GDT HA %u, Mirror Drive %u: update started",
3849 /*45*/ "\007\000\002\006\002\010\002"
3850 "GDT HA %u, Mirror Drive %u: Hot Fix %u activated",
3851 /*46*/ "\005\000\002\006\002"
3852 "GDT HA %u, Array Drive %u: no matching Pool Hot Fix Drive available",
3853 /*47*/ "\005\000\002\006\002"
3854 "GDT HA %u, Array Drive %u: Pool Hot Fix Drive available",
3855 /*48*/ "\005\000\002\006\002"
3856 "GDT HA %u, Mirror Drive %u: no matching Pool Hot Fix Drive available",
3857 /*49*/ "\005\000\002\006\002"
3858 "GDT HA %u, Mirror Drive %u: Pool Hot Fix Drive available",
3859 /*50*/ "\007\000\002\012\001\013\001"
3860 "GDT HA %u, SCSI bus %u, ID %u: IGNORE_WIDE_RESIDUE message received",
3861 /*51*/ "\005\000\002\006\002"
3862 "GDT HA %u, Array Drive %u: expand started",
3863 /*52*/ "\005\000\002\006\002"
3864 "GDT HA %u, Array Drive %u: expand finished successfully",
3865 /*53*/ "\005\000\002\006\002"
3866 "GDT HA %u, Array Drive %u: expand failed",
3867 /*54*/ "\003\000\002"
3868 "GDT HA %u, CPU temperature critical",
3869 /*55*/ "\003\000\002"
3870 "GDT HA %u, CPU temperature OK",
3871 /*56*/ "\005\000\002\006\004"
3872 "GDT HA %u, Host drive %lu created",
3873 /*57*/ "\005\000\002\006\002"
3874 "GDT HA %u, Array Drive %u: expand restarted",
3875 /*58*/ "\005\000\002\006\002"
3876 "GDT HA %u, Array Drive %u: expand stopped",
3877 /*59*/ "\005\000\002\010\002"
3878 "GDT HA %u, Mirror Drive %u: drive build quited",
3879 /*60*/ "\005\000\002\006\002"
3880 "GDT HA %u, Array Drive %u: parity build quited",
3881 /*61*/ "\005\000\002\006\002"
3882 "GDT HA %u, Array Drive %u: drive rebuild quited",
3883 /*62*/ "\005\000\002\006\002"
3884 "GDT HA %u, Array Drive %u: parity verify started",
3885 /*63*/ "\005\000\002\006\002"
3886 "GDT HA %u, Array Drive %u: parity verify done",
3887 /*64*/ "\005\000\002\006\002"
3888 "GDT HA %u, Array Drive %u: parity verify failed",
3889 /*65*/ "\005\000\002\006\002"
3890 "GDT HA %u, Array Drive %u: parity error detected",
3891 /*66*/ "\005\000\002\006\002"
3892 "GDT HA %u, Array Drive %u: parity verify quited",
3893 /*67*/ "\005\000\002\006\002"
3894 "GDT HA %u, Host Drive %u reserved",
3895 /*68*/ "\005\000\002\006\002"
3896 "GDT HA %u, Host Drive %u mounted and released",
3897 /*69*/ "\005\000\002\006\002"
3898 "GDT HA %u, Host Drive %u released",
3899 /*70*/ "\003\000\002"
3900 "GDT HA %u, DRAM error detected and corrected with ECC",
3901 /*71*/ "\003\000\002"
3902 "GDT HA %u, Uncorrectable DRAM error detected with ECC",
3903 /*72*/ "\011\000\002\012\001\013\001\014\001"
3904 "GDT HA %u, SCSI bus %u, ID %u, LUN %u: reassigning block",
3905 /*73*/ "\005\000\002\006\002"
3906 "GDT HA %u, Host drive %u resetted locally",
3907 /*74*/ "\005\000\002\006\002"
3908 "GDT HA %u, Host drive %u resetted remotely",
3909 /*75*/ "\003\000\002"
3910 "GDT HA %u, async. status 75 unknown",
3914 static int gdth_async_event(int hanum
)
3920 ha
= HADATA(gdth_ctr_tab
[hanum
]);
3922 TRACE2(("gdth_async_event() ha %d serv %d\n",
3923 hanum
,ha
->service
));
3925 if (ha
->service
== SCREENSERVICE
) {
3926 if (ha
->status
== MSG_REQUEST
) {
3927 while (gdth_test_busy(hanum
))
3929 cmdp
->Service
= SCREENSERVICE
;
3930 cmdp
->RequestBuffer
= SCREEN_CMND
;
3931 cmd_index
= gdth_get_cmd_index(hanum
);
3932 gdth_set_sema0(hanum
);
3933 cmdp
->OpCode
= GDT_READ
;
3934 cmdp
->BoardNode
= LOCALBOARD
;
3935 cmdp
->u
.screen
.reserved
= 0;
3936 cmdp
->u
.screen
.su
.msg
.msg_handle
= MSG_INV_HANDLE
;
3937 cmdp
->u
.screen
.su
.msg
.msg_addr
= ha
->msg_phys
;
3938 ha
->cmd_offs_dpmem
= 0;
3939 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.screen
.su
.msg
.msg_addr
)
3942 gdth_copy_command(hanum
);
3943 if (ha
->type
== GDT_EISA
)
3944 printk("[EISA slot %d] ",(ushort
)ha
->brd_phys
);
3945 else if (ha
->type
== GDT_ISA
)
3946 printk("[DPMEM 0x%4X] ",(ushort
)ha
->brd_phys
);
3948 printk("[PCI %d/%d] ",(ushort
)(ha
->brd_phys
>>8),
3949 (ushort
)((ha
->brd_phys
>>3)&0x1f));
3950 gdth_release_event(hanum
);
3954 if (ha
->type
== GDT_PCIMPR
&&
3955 (ha
->fw_vers
& 0xff) >= 0x1a) {
3957 ha
->dvr
.eu
.async
.ionode
= hanum
;
3958 ha
->dvr
.eu
.async
.status
= ha
->status
;
3959 /* severity and event_string already set! */
3961 ha
->dvr
.size
= sizeof(ha
->dvr
.eu
.async
);
3962 ha
->dvr
.eu
.async
.ionode
= hanum
;
3963 ha
->dvr
.eu
.async
.service
= ha
->service
;
3964 ha
->dvr
.eu
.async
.status
= ha
->status
;
3965 ha
->dvr
.eu
.async
.info
= ha
->info
;
3966 *(ulong32
*)ha
->dvr
.eu
.async
.scsi_coord
= ha
->info2
;
3968 gdth_store_event( ha
, ES_ASYNC
, ha
->service
, &ha
->dvr
);
3969 gdth_log_event( &ha
->dvr
, NULL
);
3971 /* new host drive from expand? */
3972 if (ha
->service
== CACHESERVICE
&& ha
->status
== 56) {
3973 TRACE2(("gdth_async_event(): new host drive %d created\n",
3975 /* gdth_analyse_hdrive(hanum, (ushort)ha->info); */
3981 static void gdth_log_event(gdth_evt_data
*dvr
, char *buffer
)
3983 gdth_stackframe stack
;
3987 TRACE2(("gdth_log_event()\n"));
3988 if (dvr
->size
== 0) {
3989 if (buffer
== NULL
) {
3990 printk("Adapter %d: %s\n",dvr
->eu
.async
.ionode
,dvr
->event_string
);
3992 sprintf(buffer
,"Adapter %d: %s\n",
3993 dvr
->eu
.async
.ionode
,dvr
->event_string
);
3995 } else if (dvr
->eu
.async
.service
== CACHESERVICE
&&
3996 INDEX_OK(dvr
->eu
.async
.status
, async_cache_tab
)) {
3997 TRACE2(("GDT: Async. event cache service, event no.: %d\n",
3998 dvr
->eu
.async
.status
));
4000 f
= async_cache_tab
[dvr
->eu
.async
.status
];
4002 /* i: parameter to push, j: stack element to fill */
4003 for (j
=0,i
=1; i
< f
[0]; i
+=2) {
4006 stack
.b
[j
++] = *(ulong32
*)&dvr
->eu
.stream
[(int)f
[i
]];
4009 stack
.b
[j
++] = *(ushort
*)&dvr
->eu
.stream
[(int)f
[i
]];
4012 stack
.b
[j
++] = *(unchar
*)&dvr
->eu
.stream
[(int)f
[i
]];
4019 if (buffer
== NULL
) {
4020 printk(&f
[(int)f
[0]],stack
);
4023 sprintf(buffer
,&f
[(int)f
[0]],stack
);
4027 if (buffer
== NULL
) {
4028 printk("GDT HA %u, Unknown async. event service %d event no. %d\n",
4029 dvr
->eu
.async
.ionode
,dvr
->eu
.async
.service
,dvr
->eu
.async
.status
);
4031 sprintf(buffer
,"GDT HA %u, Unknown async. event service %d event no. %d",
4032 dvr
->eu
.async
.ionode
,dvr
->eu
.async
.service
,dvr
->eu
.async
.status
);
4037 #ifdef GDTH_STATISTICS
4038 static void gdth_timeout(ulong data
)
4046 ha
= HADATA(gdth_ctr_tab
[hanum
]);
4047 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4049 for (act_stats
=0,i
=0; i
<GDTH_MAXCMDS
; ++i
)
4050 if (ha
->cmd_tab
[i
].cmnd
!= UNUSED_CMND
)
4053 for (act_rq
=0,nscp
=ha
->req_first
; nscp
; nscp
=(Scsi_Cmnd
*)nscp
->SCp
.ptr
)
4056 TRACE2(("gdth_to(): ints %d, ios %d, act_stats %d, act_rq %d\n",
4057 act_ints
, act_ios
, act_stats
, act_rq
));
4058 act_ints
= act_ios
= 0;
4060 gdth_timer
.expires
= jiffies
+ 30 * HZ
;
4061 add_timer(&gdth_timer
);
4062 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4066 static void __init
internal_setup(char *str
,int *ints
)
4069 char *cur_str
, *argv
;
4071 TRACE2(("internal_setup() str %s ints[0] %d\n",
4072 str
? str
:"NULL", ints
? ints
[0]:0));
4074 /* read irq[] from ints[] */
4080 for (i
= 0; i
< argc
; ++i
)
4085 /* analyse string */
4087 while (argv
&& (cur_str
= strchr(argv
, ':'))) {
4088 int val
= 0, c
= *++cur_str
;
4090 if (c
== 'n' || c
== 'N')
4092 else if (c
== 'y' || c
== 'Y')
4095 val
= (int)simple_strtoul(cur_str
, NULL
, 0);
4097 if (!strncmp(argv
, "disable:", 8))
4099 else if (!strncmp(argv
, "reserve_mode:", 13))
4101 else if (!strncmp(argv
, "reverse_scan:", 13))
4103 else if (!strncmp(argv
, "hdr_channel:", 12))
4105 else if (!strncmp(argv
, "max_ids:", 8))
4107 else if (!strncmp(argv
, "rescan:", 7))
4109 else if (!strncmp(argv
, "virt_ctr:", 9))
4111 else if (!strncmp(argv
, "shared_access:", 14))
4112 shared_access
= val
;
4113 else if (!strncmp(argv
, "probe_eisa_isa:", 15))
4114 probe_eisa_isa
= val
;
4115 else if (!strncmp(argv
, "reserve_list:", 13)) {
4116 reserve_list
[0] = val
;
4117 for (i
= 1; i
< MAX_RES_ARGS
; i
++) {
4118 cur_str
= strchr(cur_str
, ',');
4121 if (!isdigit((int)*++cur_str
)) {
4126 (int)simple_strtoul(cur_str
, NULL
, 0);
4134 if ((argv
= strchr(argv
, ',')))
4139 int __init
option_setup(char *str
)
4145 TRACE2(("option_setup() str %s\n", str
? str
:"NULL"));
4147 while (cur
&& isdigit(*cur
) && i
<= MAXHA
) {
4148 ints
[i
++] = simple_strtoul(cur
, NULL
, 0);
4149 if ((cur
= strchr(cur
, ',')) != NULL
) cur
++;
4153 internal_setup(cur
, ints
);
4157 static int __init
gdth_detect(struct scsi_host_template
*shtp
)
4159 struct Scsi_Host
*shp
;
4160 gdth_pci_str pcistr
[MAXHA
];
4164 int i
,hanum
,cnt
,ctr
,err
;
4169 printk("GDT: This driver contains debugging information !! Trace level = %d\n",
4171 printk(" Destination of debugging information: ");
4174 printk("Serial port COM2\n");
4176 printk("Serial port COM1\n");
4179 printk("Console\n");
4184 TRACE(("gdth_detect()\n"));
4187 printk("GDT-HA: Controller driver disabled from command line !\n");
4191 printk("GDT-HA: Storage RAID Controller Driver. Version: %s \n",GDTH_VERSION_STR
);
4192 /* initializations */
4193 gdth_polling
= TRUE
; b
= 0;
4194 gdth_clear_events();
4196 /* As default we do not probe for EISA or ISA controllers */
4197 if (probe_eisa_isa
) {
4198 /* scanning for controllers, at first: ISA controller */
4199 for (isa_bios
=0xc8000UL
; isa_bios
<=0xd8000UL
; isa_bios
+=0x8000UL
) {
4200 dma_addr_t scratch_dma_handle
;
4201 scratch_dma_handle
= 0;
4203 if (gdth_ctr_count
>= MAXHA
)
4205 if (gdth_search_isa(isa_bios
)) { /* controller found */
4206 shp
= scsi_register(shtp
,sizeof(gdth_ext_str
));
4211 if (!gdth_init_isa(isa_bios
,ha
)) {
4212 scsi_unregister(shp
);
4218 /* controller found and initialized */
4219 printk("Configuring GDT-ISA HA at BIOS 0x%05X IRQ %u DRQ %u\n",
4220 isa_bios
,ha
->irq
,ha
->drq
);
4222 if (request_irq(ha
->irq
,gdth_interrupt
,SA_INTERRUPT
,"gdth",ha
)) {
4223 printk("GDT-ISA: Unable to allocate IRQ\n");
4224 scsi_unregister(shp
);
4227 if (request_dma(ha
->drq
,"gdth")) {
4228 printk("GDT-ISA: Unable to allocate DMA channel\n");
4229 free_irq(ha
->irq
,ha
);
4230 scsi_unregister(shp
);
4233 set_dma_mode(ha
->drq
,DMA_MODE_CASCADE
);
4234 enable_dma(ha
->drq
);
4235 shp
->unchecked_isa_dma
= 1;
4237 shp
->dma_channel
= ha
->drq
;
4238 hanum
= gdth_ctr_count
;
4239 gdth_ctr_tab
[gdth_ctr_count
++] = shp
;
4240 gdth_ctr_vtab
[gdth_ctr_vcount
++] = shp
;
4242 NUMDATA(shp
)->hanum
= (ushort
)hanum
;
4243 NUMDATA(shp
)->busnum
= 0;
4245 ha
->pccb
= CMDDATA(shp
);
4248 ha
->pscratch
= pci_alloc_consistent(ha
->pdev
, GDTH_SCRATCH
,
4249 &scratch_dma_handle
);
4250 ha
->scratch_phys
= scratch_dma_handle
;
4251 ha
->pmsg
= pci_alloc_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
4252 &scratch_dma_handle
);
4253 ha
->msg_phys
= scratch_dma_handle
;
4255 ha
->coal_stat
= (gdth_coal_status
*)
4256 pci_alloc_consistent(ha
->pdev
, sizeof(gdth_coal_status
) *
4257 MAXOFFSETS
, &scratch_dma_handle
);
4258 ha
->coal_stat_phys
= scratch_dma_handle
;
4261 ha
->scratch_busy
= FALSE
;
4262 ha
->req_first
= NULL
;
4263 ha
->tid_cnt
= MAX_HDRIVES
;
4264 if (max_ids
> 0 && max_ids
< ha
->tid_cnt
)
4265 ha
->tid_cnt
= max_ids
;
4266 for (i
=0; i
<GDTH_MAXCMDS
; ++i
)
4267 ha
->cmd_tab
[i
].cmnd
= UNUSED_CMND
;
4268 ha
->scan_mode
= rescan
? 0x10 : 0;
4270 if (ha
->pscratch
== NULL
|| ha
->pmsg
== NULL
||
4271 !gdth_search_drives(hanum
)) {
4272 printk("GDT-ISA: Error during device scan\n");
4278 pci_free_consistent(ha
->pdev
, sizeof(gdth_coal_status
) *
4279 MAXOFFSETS
, ha
->coal_stat
,
4280 ha
->coal_stat_phys
);
4283 pci_free_consistent(ha
->pdev
, GDTH_SCRATCH
,
4284 ha
->pscratch
, ha
->scratch_phys
);
4286 pci_free_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
4287 ha
->pmsg
, ha
->msg_phys
);
4289 free_irq(ha
->irq
,ha
);
4290 scsi_unregister(shp
);
4293 if (hdr_channel
< 0 || hdr_channel
> ha
->bus_cnt
)
4294 hdr_channel
= ha
->bus_cnt
;
4295 ha
->virt_bus
= hdr_channel
;
4297 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20) && \
4298 LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
4299 shp
->highmem_io
= 0;
4301 if (ha
->cache_feat
& ha
->raw_feat
& ha
->screen_feat
& GDT_64BIT
)
4302 shp
->max_cmd_len
= 16;
4304 shp
->max_id
= ha
->tid_cnt
;
4305 shp
->max_lun
= MAXLUN
;
4306 shp
->max_channel
= virt_ctr
? 0 : ha
->bus_cnt
;
4309 /* register addit. SCSI channels as virtual controllers */
4310 for (b
= 1; b
< ha
->bus_cnt
+ 1; ++b
) {
4311 shp
= scsi_register(shtp
,sizeof(gdth_num_str
));
4312 shp
->unchecked_isa_dma
= 1;
4314 shp
->dma_channel
= ha
->drq
;
4315 gdth_ctr_vtab
[gdth_ctr_vcount
++] = shp
;
4316 NUMDATA(shp
)->hanum
= (ushort
)hanum
;
4317 NUMDATA(shp
)->busnum
= b
;
4321 spin_lock_init(&ha
->smp_lock
);
4322 gdth_enable_int(hanum
);
4323 #endif /* !__ia64__ */
4327 /* scanning for EISA controllers */
4328 for (eisa_slot
=0x1000; eisa_slot
<=0x8000; eisa_slot
+=0x1000) {
4329 dma_addr_t scratch_dma_handle
;
4330 scratch_dma_handle
= 0;
4332 if (gdth_ctr_count
>= MAXHA
)
4334 if (gdth_search_eisa(eisa_slot
)) { /* controller found */
4335 shp
= scsi_register(shtp
,sizeof(gdth_ext_str
));
4340 if (!gdth_init_eisa(eisa_slot
,ha
)) {
4341 scsi_unregister(shp
);
4344 /* controller found and initialized */
4345 printk("Configuring GDT-EISA HA at Slot %d IRQ %u\n",
4346 eisa_slot
>>12,ha
->irq
);
4348 if (request_irq(ha
->irq
,gdth_interrupt
,SA_INTERRUPT
,"gdth",ha
)) {
4349 printk("GDT-EISA: Unable to allocate IRQ\n");
4350 scsi_unregister(shp
);
4353 shp
->unchecked_isa_dma
= 0;
4355 shp
->dma_channel
= 0xff;
4356 hanum
= gdth_ctr_count
;
4357 gdth_ctr_tab
[gdth_ctr_count
++] = shp
;
4358 gdth_ctr_vtab
[gdth_ctr_vcount
++] = shp
;
4360 NUMDATA(shp
)->hanum
= (ushort
)hanum
;
4361 NUMDATA(shp
)->busnum
= 0;
4362 TRACE2(("EISA detect Bus 0: hanum %d\n",
4363 NUMDATA(shp
)->hanum
));
4365 ha
->pccb
= CMDDATA(shp
);
4369 ha
->pscratch
= pci_alloc_consistent(ha
->pdev
, GDTH_SCRATCH
,
4370 &scratch_dma_handle
);
4371 ha
->scratch_phys
= scratch_dma_handle
;
4372 ha
->pmsg
= pci_alloc_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
4373 &scratch_dma_handle
);
4374 ha
->msg_phys
= scratch_dma_handle
;
4376 ha
->coal_stat
= (gdth_coal_status
*)
4377 pci_alloc_consistent(ha
->pdev
, sizeof(gdth_coal_status
) *
4378 MAXOFFSETS
, &scratch_dma_handle
);
4379 ha
->coal_stat_phys
= scratch_dma_handle
;
4382 pci_map_single(ha
->pdev
,ha
->pccb
,
4383 sizeof(gdth_cmd_str
),PCI_DMA_BIDIRECTIONAL
);
4384 ha
->scratch_busy
= FALSE
;
4385 ha
->req_first
= NULL
;
4386 ha
->tid_cnt
= MAX_HDRIVES
;
4387 if (max_ids
> 0 && max_ids
< ha
->tid_cnt
)
4388 ha
->tid_cnt
= max_ids
;
4389 for (i
=0; i
<GDTH_MAXCMDS
; ++i
)
4390 ha
->cmd_tab
[i
].cmnd
= UNUSED_CMND
;
4391 ha
->scan_mode
= rescan
? 0x10 : 0;
4393 if (ha
->pscratch
== NULL
|| ha
->pmsg
== NULL
||
4394 !gdth_search_drives(hanum
)) {
4395 printk("GDT-EISA: Error during device scan\n");
4400 pci_free_consistent(ha
->pdev
, sizeof(gdth_coal_status
) *
4401 MAXOFFSETS
, ha
->coal_stat
,
4402 ha
->coal_stat_phys
);
4405 pci_free_consistent(ha
->pdev
, GDTH_SCRATCH
,
4406 ha
->pscratch
, ha
->scratch_phys
);
4408 pci_free_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
4409 ha
->pmsg
, ha
->msg_phys
);
4411 pci_unmap_single(ha
->pdev
,ha
->ccb_phys
,
4412 sizeof(gdth_cmd_str
),PCI_DMA_BIDIRECTIONAL
);
4413 free_irq(ha
->irq
,ha
);
4414 scsi_unregister(shp
);
4417 if (hdr_channel
< 0 || hdr_channel
> ha
->bus_cnt
)
4418 hdr_channel
= ha
->bus_cnt
;
4419 ha
->virt_bus
= hdr_channel
;
4421 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20) && \
4422 LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
4423 shp
->highmem_io
= 0;
4425 if (ha
->cache_feat
& ha
->raw_feat
& ha
->screen_feat
& GDT_64BIT
)
4426 shp
->max_cmd_len
= 16;
4428 shp
->max_id
= ha
->tid_cnt
;
4429 shp
->max_lun
= MAXLUN
;
4430 shp
->max_channel
= virt_ctr
? 0 : ha
->bus_cnt
;
4433 /* register addit. SCSI channels as virtual controllers */
4434 for (b
= 1; b
< ha
->bus_cnt
+ 1; ++b
) {
4435 shp
= scsi_register(shtp
,sizeof(gdth_num_str
));
4436 shp
->unchecked_isa_dma
= 0;
4438 shp
->dma_channel
= 0xff;
4439 gdth_ctr_vtab
[gdth_ctr_vcount
++] = shp
;
4440 NUMDATA(shp
)->hanum
= (ushort
)hanum
;
4441 NUMDATA(shp
)->busnum
= b
;
4445 spin_lock_init(&ha
->smp_lock
);
4446 gdth_enable_int(hanum
);
4451 /* scanning for PCI controllers */
4452 cnt
= gdth_search_pci(pcistr
);
4453 printk("GDT-HA: Found %d PCI Storage RAID Controllers\n",cnt
);
4454 gdth_sort_pci(pcistr
,cnt
);
4455 for (ctr
= 0; ctr
< cnt
; ++ctr
) {
4456 dma_addr_t scratch_dma_handle
;
4457 scratch_dma_handle
= 0;
4459 if (gdth_ctr_count
>= MAXHA
)
4461 shp
= scsi_register(shtp
,sizeof(gdth_ext_str
));
4466 if (!gdth_init_pci(&pcistr
[ctr
],ha
)) {
4467 scsi_unregister(shp
);
4470 /* controller found and initialized */
4471 printk("Configuring GDT-PCI HA at %d/%d IRQ %u\n",
4472 pcistr
[ctr
].bus
,PCI_SLOT(pcistr
[ctr
].device_fn
),ha
->irq
);
4474 if (request_irq(ha
->irq
, gdth_interrupt
,
4475 SA_INTERRUPT
|SA_SHIRQ
, "gdth", ha
))
4477 printk("GDT-PCI: Unable to allocate IRQ\n");
4478 scsi_unregister(shp
);
4481 shp
->unchecked_isa_dma
= 0;
4483 shp
->dma_channel
= 0xff;
4484 hanum
= gdth_ctr_count
;
4485 gdth_ctr_tab
[gdth_ctr_count
++] = shp
;
4486 gdth_ctr_vtab
[gdth_ctr_vcount
++] = shp
;
4488 NUMDATA(shp
)->hanum
= (ushort
)hanum
;
4489 NUMDATA(shp
)->busnum
= 0;
4491 ha
->pccb
= CMDDATA(shp
);
4494 ha
->pscratch
= pci_alloc_consistent(ha
->pdev
, GDTH_SCRATCH
,
4495 &scratch_dma_handle
);
4496 ha
->scratch_phys
= scratch_dma_handle
;
4497 ha
->pmsg
= pci_alloc_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
4498 &scratch_dma_handle
);
4499 ha
->msg_phys
= scratch_dma_handle
;
4501 ha
->coal_stat
= (gdth_coal_status
*)
4502 pci_alloc_consistent(ha
->pdev
, sizeof(gdth_coal_status
) *
4503 MAXOFFSETS
, &scratch_dma_handle
);
4504 ha
->coal_stat_phys
= scratch_dma_handle
;
4506 ha
->scratch_busy
= FALSE
;
4507 ha
->req_first
= NULL
;
4508 ha
->tid_cnt
= pcistr
[ctr
].device_id
>= 0x200 ? MAXID
: MAX_HDRIVES
;
4509 if (max_ids
> 0 && max_ids
< ha
->tid_cnt
)
4510 ha
->tid_cnt
= max_ids
;
4511 for (i
=0; i
<GDTH_MAXCMDS
; ++i
)
4512 ha
->cmd_tab
[i
].cmnd
= UNUSED_CMND
;
4513 ha
->scan_mode
= rescan
? 0x10 : 0;
4516 if (ha
->pscratch
== NULL
|| ha
->pmsg
== NULL
||
4517 !gdth_search_drives(hanum
)) {
4520 if (hdr_channel
< 0 || hdr_channel
> ha
->bus_cnt
)
4521 hdr_channel
= ha
->bus_cnt
;
4522 ha
->virt_bus
= hdr_channel
;
4525 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
4526 scsi_set_pci_device(shp
, pcistr
[ctr
].pdev
);
4528 if (!(ha
->cache_feat
& ha
->raw_feat
& ha
->screen_feat
&GDT_64BIT
)||
4529 /* 64-bit DMA only supported from FW >= x.43 */
4530 (!ha
->dma64_support
)) {
4531 if (pci_set_dma_mask(pcistr
[ctr
].pdev
, DMA_32BIT_MASK
)) {
4532 printk(KERN_WARNING
"GDT-PCI %d: Unable to set 32-bit DMA\n", hanum
);
4536 shp
->max_cmd_len
= 16;
4537 if (!pci_set_dma_mask(pcistr
[ctr
].pdev
, DMA_64BIT_MASK
)) {
4538 printk("GDT-PCI %d: 64-bit DMA enabled\n", hanum
);
4539 } else if (pci_set_dma_mask(pcistr
[ctr
].pdev
, DMA_32BIT_MASK
)) {
4540 printk(KERN_WARNING
"GDT-PCI %d: Unable to set 64/32-bit DMA\n", hanum
);
4547 printk("GDT-PCI %d: Error during device scan\n", hanum
);
4552 pci_free_consistent(ha
->pdev
, sizeof(gdth_coal_status
) *
4553 MAXOFFSETS
, ha
->coal_stat
,
4554 ha
->coal_stat_phys
);
4557 pci_free_consistent(ha
->pdev
, GDTH_SCRATCH
,
4558 ha
->pscratch
, ha
->scratch_phys
);
4560 pci_free_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
4561 ha
->pmsg
, ha
->msg_phys
);
4562 free_irq(ha
->irq
,ha
);
4563 scsi_unregister(shp
);
4567 shp
->max_id
= ha
->tid_cnt
;
4568 shp
->max_lun
= MAXLUN
;
4569 shp
->max_channel
= virt_ctr
? 0 : ha
->bus_cnt
;
4572 /* register addit. SCSI channels as virtual controllers */
4573 for (b
= 1; b
< ha
->bus_cnt
+ 1; ++b
) {
4574 shp
= scsi_register(shtp
,sizeof(gdth_num_str
));
4575 shp
->unchecked_isa_dma
= 0;
4577 shp
->dma_channel
= 0xff;
4578 gdth_ctr_vtab
[gdth_ctr_vcount
++] = shp
;
4579 NUMDATA(shp
)->hanum
= (ushort
)hanum
;
4580 NUMDATA(shp
)->busnum
= b
;
4584 spin_lock_init(&ha
->smp_lock
);
4585 gdth_enable_int(hanum
);
4588 TRACE2(("gdth_detect() %d controller detected\n",gdth_ctr_count
));
4589 if (gdth_ctr_count
> 0) {
4590 #ifdef GDTH_STATISTICS
4591 TRACE2(("gdth_detect(): Initializing timer !\n"));
4592 init_timer(&gdth_timer
);
4593 gdth_timer
.expires
= jiffies
+ HZ
;
4594 gdth_timer
.data
= 0L;
4595 gdth_timer
.function
= gdth_timeout
;
4596 add_timer(&gdth_timer
);
4598 major
= register_chrdev(0,"gdth",&gdth_fops
);
4599 notifier_disabled
= 0;
4600 register_reboot_notifier(&gdth_notifier
);
4602 gdth_polling
= FALSE
;
4603 return gdth_ctr_vcount
;
4606 static int gdth_release(struct Scsi_Host
*shp
)
4611 TRACE2(("gdth_release()\n"));
4612 if (NUMDATA(shp
)->busnum
== 0) {
4613 hanum
= NUMDATA(shp
)->hanum
;
4614 ha
= HADATA(gdth_ctr_tab
[hanum
]);
4616 scsi_free_host_dev(ha
->sdev
);
4622 free_irq(shp
->irq
,ha
);
4625 if (shp
->dma_channel
!= 0xff) {
4626 free_dma(shp
->dma_channel
);
4631 pci_free_consistent(ha
->pdev
, sizeof(gdth_coal_status
) *
4632 MAXOFFSETS
, ha
->coal_stat
, ha
->coal_stat_phys
);
4635 pci_free_consistent(ha
->pdev
, GDTH_SCRATCH
,
4636 ha
->pscratch
, ha
->scratch_phys
);
4638 pci_free_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
4639 ha
->pmsg
, ha
->msg_phys
);
4641 pci_unmap_single(ha
->pdev
,ha
->ccb_phys
,
4642 sizeof(gdth_cmd_str
),PCI_DMA_BIDIRECTIONAL
);
4643 gdth_ctr_released
++;
4644 TRACE2(("gdth_release(): HA %d of %d\n",
4645 gdth_ctr_released
, gdth_ctr_count
));
4647 if (gdth_ctr_released
== gdth_ctr_count
) {
4648 #ifdef GDTH_STATISTICS
4649 del_timer(&gdth_timer
);
4651 unregister_chrdev(major
,"gdth");
4652 unregister_reboot_notifier(&gdth_notifier
);
4656 scsi_unregister(shp
);
4661 static const char *gdth_ctr_name(int hanum
)
4665 TRACE2(("gdth_ctr_name()\n"));
4667 ha
= HADATA(gdth_ctr_tab
[hanum
]);
4669 if (ha
->type
== GDT_EISA
) {
4670 switch (ha
->stype
) {
4672 return("GDT3000/3020");
4674 return("GDT3000A/3020A/3050A");
4676 return("GDT3000B/3010A");
4678 } else if (ha
->type
== GDT_ISA
) {
4679 return("GDT2000/2020");
4680 } else if (ha
->type
== GDT_PCI
) {
4681 switch (ha
->stype
) {
4682 case PCI_DEVICE_ID_VORTEX_GDT60x0
:
4683 return("GDT6000/6020/6050");
4684 case PCI_DEVICE_ID_VORTEX_GDT6000B
:
4685 return("GDT6000B/6010");
4688 /* new controllers (GDT_PCINEW, GDT_PCIMPR, ..) use board_info IOCTL! */
4693 static const char *gdth_info(struct Scsi_Host
*shp
)
4698 TRACE2(("gdth_info()\n"));
4699 hanum
= NUMDATA(shp
)->hanum
;
4700 ha
= HADATA(gdth_ctr_tab
[hanum
]);
4702 return ((const char *)ha
->binfo
.type_string
);
4705 static int gdth_eh_bus_reset(Scsi_Cmnd
*scp
)
4713 TRACE2(("gdth_eh_bus_reset()\n"));
4715 hanum
= NUMDATA(scp
->device
->host
)->hanum
;
4716 b
= virt_ctr
? NUMDATA(scp
->device
->host
)->busnum
: scp
->device
->channel
;
4717 ha
= HADATA(gdth_ctr_tab
[hanum
]);
4719 /* clear command tab */
4720 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4721 for (i
= 0; i
< GDTH_MAXCMDS
; ++i
) {
4722 cmnd
= ha
->cmd_tab
[i
].cmnd
;
4723 if (!SPECIAL_SCP(cmnd
) && cmnd
->device
->channel
== b
)
4724 ha
->cmd_tab
[i
].cmnd
= UNUSED_CMND
;
4726 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4728 if (b
== ha
->virt_bus
) {
4730 for (i
= 0; i
< MAX_HDRIVES
; ++i
) {
4731 if (ha
->hdr
[i
].present
) {
4732 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4733 gdth_polling
= TRUE
;
4734 while (gdth_test_busy(hanum
))
4736 if (gdth_internal_cmd(hanum
, CACHESERVICE
,
4737 GDT_CLUST_RESET
, i
, 0, 0))
4738 ha
->hdr
[i
].cluster_type
&= ~CLUSTER_RESERVED
;
4739 gdth_polling
= FALSE
;
4740 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4745 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4746 for (i
= 0; i
< MAXID
; ++i
)
4747 ha
->raw
[BUS_L2P(ha
,b
)].io_cnt
[i
] = 0;
4748 gdth_polling
= TRUE
;
4749 while (gdth_test_busy(hanum
))
4751 gdth_internal_cmd(hanum
, SCSIRAWSERVICE
, GDT_RESET_BUS
,
4752 BUS_L2P(ha
,b
), 0, 0);
4753 gdth_polling
= FALSE
;
4754 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4759 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
4760 static int gdth_bios_param(struct scsi_device
*sdev
,struct block_device
*bdev
,sector_t cap
,int *ip
)
4762 static int gdth_bios_param(Disk
*disk
,kdev_t dev
,int *ip
)
4768 struct scsi_device
*sd
;
4771 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
4776 capacity
= disk
->capacity
;
4778 hanum
= NUMDATA(sd
->host
)->hanum
;
4779 b
= virt_ctr
? NUMDATA(sd
->host
)->busnum
: sd
->channel
;
4781 TRACE2(("gdth_bios_param() ha %d bus %d target %d\n", hanum
, b
, t
));
4782 ha
= HADATA(gdth_ctr_tab
[hanum
]);
4784 if (b
!= ha
->virt_bus
|| ha
->hdr
[t
].heads
== 0) {
4785 /* raw device or host drive without mapping information */
4786 TRACE2(("Evaluate mapping\n"));
4787 gdth_eval_mapping(capacity
,&ip
[2],&ip
[0],&ip
[1]);
4789 ip
[0] = ha
->hdr
[t
].heads
;
4790 ip
[1] = ha
->hdr
[t
].secs
;
4791 ip
[2] = capacity
/ ip
[0] / ip
[1];
4794 TRACE2(("gdth_bios_param(): %d heads, %d secs, %d cyls\n",
4795 ip
[0],ip
[1],ip
[2]));
4800 static int gdth_queuecommand(Scsi_Cmnd
*scp
,void (*done
)(Scsi_Cmnd
*))
4805 TRACE(("gdth_queuecommand() cmd 0x%x\n", scp
->cmnd
[0]));
4807 scp
->scsi_done
= (void *)done
;
4808 scp
->SCp
.have_data_in
= 1;
4809 scp
->SCp
.phase
= -1;
4810 scp
->SCp
.sent_command
= -1;
4811 scp
->SCp
.Status
= GDTH_MAP_NONE
;
4812 scp
->SCp
.buffer
= (struct scatterlist
*)NULL
;
4814 hanum
= NUMDATA(scp
->device
->host
)->hanum
;
4815 #ifdef GDTH_STATISTICS
4819 priority
= DEFAULT_PRI
;
4820 if (scp
->done
== gdth_scsi_done
)
4821 priority
= scp
->SCp
.this_residual
;
4822 gdth_update_timeout(hanum
, scp
, scp
->timeout_per_command
* 6);
4823 gdth_putq( hanum
, scp
, priority
);
4829 static int gdth_open(struct inode
*inode
, struct file
*filep
)
4834 for (i
= 0; i
< gdth_ctr_count
; i
++) {
4835 ha
= HADATA(gdth_ctr_tab
[i
]);
4837 ha
->sdev
= scsi_get_host_dev(gdth_ctr_tab
[i
]);
4840 TRACE(("gdth_open()\n"));
4844 static int gdth_close(struct inode
*inode
, struct file
*filep
)
4846 TRACE(("gdth_close()\n"));
4850 static int ioc_event(void __user
*arg
)
4852 gdth_ioctl_event evt
;
4856 if (copy_from_user(&evt
, arg
, sizeof(gdth_ioctl_event
)) ||
4857 evt
.ionode
>= gdth_ctr_count
)
4859 ha
= HADATA(gdth_ctr_tab
[evt
.ionode
]);
4861 if (evt
.erase
== 0xff) {
4862 if (evt
.event
.event_source
== ES_TEST
)
4863 evt
.event
.event_data
.size
=sizeof(evt
.event
.event_data
.eu
.test
);
4864 else if (evt
.event
.event_source
== ES_DRIVER
)
4865 evt
.event
.event_data
.size
=sizeof(evt
.event
.event_data
.eu
.driver
);
4866 else if (evt
.event
.event_source
== ES_SYNC
)
4867 evt
.event
.event_data
.size
=sizeof(evt
.event
.event_data
.eu
.sync
);
4869 evt
.event
.event_data
.size
=sizeof(evt
.event
.event_data
.eu
.async
);
4870 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4871 gdth_store_event(ha
, evt
.event
.event_source
, evt
.event
.event_idx
,
4872 &evt
.event
.event_data
);
4873 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4874 } else if (evt
.erase
== 0xfe) {
4875 gdth_clear_events();
4876 } else if (evt
.erase
== 0) {
4877 evt
.handle
= gdth_read_event(ha
, evt
.handle
, &evt
.event
);
4879 gdth_readapp_event(ha
, evt
.erase
, &evt
.event
);
4881 if (copy_to_user(arg
, &evt
, sizeof(gdth_ioctl_event
)))
4886 static int ioc_lockdrv(void __user
*arg
)
4888 gdth_ioctl_lockdrv ldrv
;
4893 if (copy_from_user(&ldrv
, arg
, sizeof(gdth_ioctl_lockdrv
)) ||
4894 ldrv
.ionode
>= gdth_ctr_count
)
4896 ha
= HADATA(gdth_ctr_tab
[ldrv
.ionode
]);
4898 for (i
= 0; i
< ldrv
.drive_cnt
&& i
< MAX_HDRIVES
; ++i
) {
4900 if (j
>= MAX_HDRIVES
|| !ha
->hdr
[j
].present
)
4903 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4904 ha
->hdr
[j
].lock
= 1;
4905 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4906 gdth_wait_completion(ldrv
.ionode
, ha
->bus_cnt
, j
);
4907 gdth_stop_timeout(ldrv
.ionode
, ha
->bus_cnt
, j
);
4909 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4910 ha
->hdr
[j
].lock
= 0;
4911 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4912 gdth_start_timeout(ldrv
.ionode
, ha
->bus_cnt
, j
);
4913 gdth_next(ldrv
.ionode
);
4919 static int ioc_resetdrv(void __user
*arg
, char *cmnd
)
4921 gdth_ioctl_reset res
;
4925 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
4931 if (copy_from_user(&res
, arg
, sizeof(gdth_ioctl_reset
)) ||
4932 res
.ionode
>= gdth_ctr_count
|| res
.number
>= MAX_HDRIVES
)
4935 ha
= HADATA(gdth_ctr_tab
[hanum
]);
4937 if (!ha
->hdr
[res
.number
].present
)
4939 memset(&cmd
, 0, sizeof(gdth_cmd_str
));
4940 cmd
.Service
= CACHESERVICE
;
4941 cmd
.OpCode
= GDT_CLUST_RESET
;
4942 if (ha
->cache_feat
& GDT_64BIT
)
4943 cmd
.u
.cache64
.DeviceNo
= res
.number
;
4945 cmd
.u
.cache
.DeviceNo
= res
.number
;
4946 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
4947 srp
= scsi_allocate_request(ha
->sdev
, GFP_KERNEL
);
4950 srp
->sr_cmd_len
= 12;
4952 gdth_do_req(srp
, &cmd
, cmnd
, 30);
4953 res
.status
= (ushort
)srp
->sr_command
->SCp
.Status
;
4954 scsi_release_request(srp
);
4956 scp
= scsi_allocate_device(ha
->sdev
, 1, FALSE
);
4961 gdth_do_cmd(scp
, &cmd
, cmnd
, 30);
4962 res
.status
= (ushort
)scp
->SCp
.Status
;
4963 scsi_release_command(scp
);
4966 if (copy_to_user(arg
, &res
, sizeof(gdth_ioctl_reset
)))
4971 static int ioc_general(void __user
*arg
, char *cmnd
)
4973 gdth_ioctl_general gen
;
4978 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
4984 if (copy_from_user(&gen
, arg
, sizeof(gdth_ioctl_general
)) ||
4985 gen
.ionode
>= gdth_ctr_count
)
4988 ha
= HADATA(gdth_ctr_tab
[hanum
]);
4989 if (gen
.data_len
+ gen
.sense_len
!= 0) {
4990 if (!(buf
= gdth_ioctl_alloc(hanum
, gen
.data_len
+ gen
.sense_len
,
4993 if (copy_from_user(buf
, arg
+ sizeof(gdth_ioctl_general
),
4994 gen
.data_len
+ gen
.sense_len
)) {
4995 gdth_ioctl_free(hanum
, gen
.data_len
+gen
.sense_len
, buf
, paddr
);
4999 if (gen
.command
.OpCode
== GDT_IOCTL
) {
5000 gen
.command
.u
.ioctl
.p_param
= paddr
;
5001 } else if (gen
.command
.Service
== CACHESERVICE
) {
5002 if (ha
->cache_feat
& GDT_64BIT
) {
5003 /* copy elements from 32-bit IOCTL structure */
5004 gen
.command
.u
.cache64
.BlockCnt
= gen
.command
.u
.cache
.BlockCnt
;
5005 gen
.command
.u
.cache64
.BlockNo
= gen
.command
.u
.cache
.BlockNo
;
5006 gen
.command
.u
.cache64
.DeviceNo
= gen
.command
.u
.cache
.DeviceNo
;
5008 if (ha
->cache_feat
& SCATTER_GATHER
) {
5009 gen
.command
.u
.cache64
.DestAddr
= (ulong64
)-1;
5010 gen
.command
.u
.cache64
.sg_canz
= 1;
5011 gen
.command
.u
.cache64
.sg_lst
[0].sg_ptr
= paddr
;
5012 gen
.command
.u
.cache64
.sg_lst
[0].sg_len
= gen
.data_len
;
5013 gen
.command
.u
.cache64
.sg_lst
[1].sg_len
= 0;
5015 gen
.command
.u
.cache64
.DestAddr
= paddr
;
5016 gen
.command
.u
.cache64
.sg_canz
= 0;
5019 if (ha
->cache_feat
& SCATTER_GATHER
) {
5020 gen
.command
.u
.cache
.DestAddr
= 0xffffffff;
5021 gen
.command
.u
.cache
.sg_canz
= 1;
5022 gen
.command
.u
.cache
.sg_lst
[0].sg_ptr
= (ulong32
)paddr
;
5023 gen
.command
.u
.cache
.sg_lst
[0].sg_len
= gen
.data_len
;
5024 gen
.command
.u
.cache
.sg_lst
[1].sg_len
= 0;
5026 gen
.command
.u
.cache
.DestAddr
= paddr
;
5027 gen
.command
.u
.cache
.sg_canz
= 0;
5030 } else if (gen
.command
.Service
== SCSIRAWSERVICE
) {
5031 if (ha
->raw_feat
& GDT_64BIT
) {
5032 /* copy elements from 32-bit IOCTL structure */
5034 gen
.command
.u
.raw64
.sense_len
= gen
.command
.u
.raw
.sense_len
;
5035 gen
.command
.u
.raw64
.bus
= gen
.command
.u
.raw
.bus
;
5036 gen
.command
.u
.raw64
.lun
= gen
.command
.u
.raw
.lun
;
5037 gen
.command
.u
.raw64
.target
= gen
.command
.u
.raw
.target
;
5038 memcpy(cmd
, gen
.command
.u
.raw
.cmd
, 16);
5039 memcpy(gen
.command
.u
.raw64
.cmd
, cmd
, 16);
5040 gen
.command
.u
.raw64
.clen
= gen
.command
.u
.raw
.clen
;
5041 gen
.command
.u
.raw64
.sdlen
= gen
.command
.u
.raw
.sdlen
;
5042 gen
.command
.u
.raw64
.direction
= gen
.command
.u
.raw
.direction
;
5044 if (ha
->raw_feat
& SCATTER_GATHER
) {
5045 gen
.command
.u
.raw64
.sdata
= (ulong64
)-1;
5046 gen
.command
.u
.raw64
.sg_ranz
= 1;
5047 gen
.command
.u
.raw64
.sg_lst
[0].sg_ptr
= paddr
;
5048 gen
.command
.u
.raw64
.sg_lst
[0].sg_len
= gen
.data_len
;
5049 gen
.command
.u
.raw64
.sg_lst
[1].sg_len
= 0;
5051 gen
.command
.u
.raw64
.sdata
= paddr
;
5052 gen
.command
.u
.raw64
.sg_ranz
= 0;
5054 gen
.command
.u
.raw64
.sense_data
= paddr
+ gen
.data_len
;
5056 if (ha
->raw_feat
& SCATTER_GATHER
) {
5057 gen
.command
.u
.raw
.sdata
= 0xffffffff;
5058 gen
.command
.u
.raw
.sg_ranz
= 1;
5059 gen
.command
.u
.raw
.sg_lst
[0].sg_ptr
= (ulong32
)paddr
;
5060 gen
.command
.u
.raw
.sg_lst
[0].sg_len
= gen
.data_len
;
5061 gen
.command
.u
.raw
.sg_lst
[1].sg_len
= 0;
5063 gen
.command
.u
.raw
.sdata
= paddr
;
5064 gen
.command
.u
.raw
.sg_ranz
= 0;
5066 gen
.command
.u
.raw
.sense_data
= (ulong32
)paddr
+ gen
.data_len
;
5069 gdth_ioctl_free(hanum
, gen
.data_len
+gen
.sense_len
, buf
, paddr
);
5074 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5075 srp
= scsi_allocate_request(ha
->sdev
, GFP_KERNEL
);
5078 srp
->sr_cmd_len
= 12;
5080 gdth_do_req(srp
, &gen
.command
, cmnd
, gen
.timeout
);
5081 gen
.status
= srp
->sr_command
->SCp
.Status
;
5082 gen
.info
= srp
->sr_command
->SCp
.Message
;
5083 scsi_release_request(srp
);
5085 scp
= scsi_allocate_device(ha
->sdev
, 1, FALSE
);
5090 gdth_do_cmd(scp
, &gen
.command
, cmnd
, gen
.timeout
);
5091 gen
.status
= scp
->SCp
.Status
;
5092 gen
.info
= scp
->SCp
.Message
;
5093 scsi_release_command(scp
);
5096 if (copy_to_user(arg
+ sizeof(gdth_ioctl_general
), buf
,
5097 gen
.data_len
+ gen
.sense_len
)) {
5098 gdth_ioctl_free(hanum
, gen
.data_len
+gen
.sense_len
, buf
, paddr
);
5101 if (copy_to_user(arg
, &gen
,
5102 sizeof(gdth_ioctl_general
) - sizeof(gdth_cmd_str
))) {
5103 gdth_ioctl_free(hanum
, gen
.data_len
+gen
.sense_len
, buf
, paddr
);
5106 gdth_ioctl_free(hanum
, gen
.data_len
+gen
.sense_len
, buf
, paddr
);
5110 static int ioc_hdrlist(void __user
*arg
, char *cmnd
)
5112 gdth_ioctl_rescan
*rsc
;
5116 int hanum
, rc
= -ENOMEM
;
5117 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5123 rsc
= kmalloc(sizeof(*rsc
), GFP_KERNEL
);
5124 cmd
= kmalloc(sizeof(*cmd
), GFP_KERNEL
);
5128 if (copy_from_user(rsc
, arg
, sizeof(gdth_ioctl_rescan
)) ||
5129 rsc
->ionode
>= gdth_ctr_count
) {
5133 hanum
= rsc
->ionode
;
5134 ha
= HADATA(gdth_ctr_tab
[hanum
]);
5135 memset(cmd
, 0, sizeof(gdth_cmd_str
));
5137 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5138 srp
= scsi_allocate_request(ha
->sdev
, GFP_KERNEL
);
5141 srp
->sr_cmd_len
= 12;
5144 scp
= scsi_allocate_device(ha
->sdev
, 1, FALSE
);
5151 for (i
= 0; i
< MAX_HDRIVES
; ++i
) {
5152 if (!ha
->hdr
[i
].present
) {
5153 rsc
->hdr_list
[i
].bus
= 0xff;
5156 rsc
->hdr_list
[i
].bus
= ha
->virt_bus
;
5157 rsc
->hdr_list
[i
].target
= i
;
5158 rsc
->hdr_list
[i
].lun
= 0;
5159 rsc
->hdr_list
[i
].cluster_type
= ha
->hdr
[i
].cluster_type
;
5160 if (ha
->hdr
[i
].cluster_type
& CLUSTER_DRIVE
) {
5161 cmd
->Service
= CACHESERVICE
;
5162 cmd
->OpCode
= GDT_CLUST_INFO
;
5163 if (ha
->cache_feat
& GDT_64BIT
)
5164 cmd
->u
.cache64
.DeviceNo
= i
;
5166 cmd
->u
.cache
.DeviceNo
= i
;
5167 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5168 gdth_do_req(srp
, cmd
, cmnd
, 30);
5169 if (srp
->sr_command
->SCp
.Status
== S_OK
)
5170 rsc
->hdr_list
[i
].cluster_type
= srp
->sr_command
->SCp
.Message
;
5172 gdth_do_cmd(scp
, cmd
, cmnd
, 30);
5173 if (scp
->SCp
.Status
== S_OK
)
5174 rsc
->hdr_list
[i
].cluster_type
= scp
->SCp
.Message
;
5178 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5179 scsi_release_request(srp
);
5181 scsi_release_command(scp
);
5184 if (copy_to_user(arg
, rsc
, sizeof(gdth_ioctl_rescan
)))
5195 static int ioc_rescan(void __user
*arg
, char *cmnd
)
5197 gdth_ioctl_rescan
*rsc
;
5199 ushort i
, status
, hdr_cnt
;
5201 int hanum
, cyls
, hds
, secs
;
5205 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5211 rsc
= kmalloc(sizeof(*rsc
), GFP_KERNEL
);
5212 cmd
= kmalloc(sizeof(*cmd
), GFP_KERNEL
);
5216 if (copy_from_user(rsc
, arg
, sizeof(gdth_ioctl_rescan
)) ||
5217 rsc
->ionode
>= gdth_ctr_count
) {
5221 hanum
= rsc
->ionode
;
5222 ha
= HADATA(gdth_ctr_tab
[hanum
]);
5223 memset(cmd
, 0, sizeof(gdth_cmd_str
));
5225 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5226 srp
= scsi_allocate_request(ha
->sdev
, GFP_KERNEL
);
5229 srp
->sr_cmd_len
= 12;
5232 scp
= scsi_allocate_device(ha
->sdev
, 1, FALSE
);
5239 if (rsc
->flag
== 0) {
5240 /* old method: re-init. cache service */
5241 cmd
->Service
= CACHESERVICE
;
5242 if (ha
->cache_feat
& GDT_64BIT
) {
5243 cmd
->OpCode
= GDT_X_INIT_HOST
;
5244 cmd
->u
.cache64
.DeviceNo
= LINUX_OS
;
5246 cmd
->OpCode
= GDT_INIT
;
5247 cmd
->u
.cache
.DeviceNo
= LINUX_OS
;
5249 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5250 gdth_do_req(srp
, cmd
, cmnd
, 30);
5251 status
= (ushort
)srp
->sr_command
->SCp
.Status
;
5252 info
= (ulong32
)srp
->sr_command
->SCp
.Message
;
5253 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
5254 gdth_do_cmd(scp
, cmd
, cmnd
, 30);
5255 status
= (ushort
)scp
->SCp
.Status
;
5256 info
= (ulong32
)scp
->SCp
.Message
;
5258 gdth_do_cmd(&scp
, cmd
, cmnd
, 30);
5259 status
= (ushort
)scp
.SCp
.Status
;
5260 info
= (ulong32
)scp
.SCp
.Message
;
5263 hdr_cnt
= (status
== S_OK
? (ushort
)info
: 0);
5269 for (; i
< hdr_cnt
&& i
< MAX_HDRIVES
; ++i
) {
5270 cmd
->Service
= CACHESERVICE
;
5271 cmd
->OpCode
= GDT_INFO
;
5272 if (ha
->cache_feat
& GDT_64BIT
)
5273 cmd
->u
.cache64
.DeviceNo
= i
;
5275 cmd
->u
.cache
.DeviceNo
= i
;
5276 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5277 gdth_do_req(srp
, cmd
, cmnd
, 30);
5278 status
= (ushort
)srp
->sr_command
->SCp
.Status
;
5279 info
= (ulong32
)srp
->sr_command
->SCp
.Message
;
5281 gdth_do_cmd(scp
, cmd
, cmnd
, 30);
5282 status
= (ushort
)scp
->SCp
.Status
;
5283 info
= (ulong32
)scp
->SCp
.Message
;
5285 spin_lock_irqsave(&ha
->smp_lock
, flags
);
5286 rsc
->hdr_list
[i
].bus
= ha
->virt_bus
;
5287 rsc
->hdr_list
[i
].target
= i
;
5288 rsc
->hdr_list
[i
].lun
= 0;
5289 if (status
!= S_OK
) {
5290 ha
->hdr
[i
].present
= FALSE
;
5292 ha
->hdr
[i
].present
= TRUE
;
5293 ha
->hdr
[i
].size
= info
;
5294 /* evaluate mapping */
5295 ha
->hdr
[i
].size
&= ~SECS32
;
5296 gdth_eval_mapping(ha
->hdr
[i
].size
,&cyls
,&hds
,&secs
);
5297 ha
->hdr
[i
].heads
= hds
;
5298 ha
->hdr
[i
].secs
= secs
;
5300 ha
->hdr
[i
].size
= cyls
* hds
* secs
;
5302 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
5306 /* extended info, if GDT_64BIT, for drives > 2 TB */
5307 /* but we need ha->info2, not yet stored in scp->SCp */
5309 /* devtype, cluster info, R/W attribs */
5310 cmd
->Service
= CACHESERVICE
;
5311 cmd
->OpCode
= GDT_DEVTYPE
;
5312 if (ha
->cache_feat
& GDT_64BIT
)
5313 cmd
->u
.cache64
.DeviceNo
= i
;
5315 cmd
->u
.cache
.DeviceNo
= i
;
5316 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5317 gdth_do_req(srp
, cmd
, cmnd
, 30);
5318 status
= (ushort
)srp
->sr_command
->SCp
.Status
;
5319 info
= (ulong32
)srp
->sr_command
->SCp
.Message
;
5321 gdth_do_cmd(scp
, cmd
, cmnd
, 30);
5322 status
= (ushort
)scp
->SCp
.Status
;
5323 info
= (ulong32
)scp
->SCp
.Message
;
5325 spin_lock_irqsave(&ha
->smp_lock
, flags
);
5326 ha
->hdr
[i
].devtype
= (status
== S_OK
? (ushort
)info
: 0);
5327 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
5329 cmd
->Service
= CACHESERVICE
;
5330 cmd
->OpCode
= GDT_CLUST_INFO
;
5331 if (ha
->cache_feat
& GDT_64BIT
)
5332 cmd
->u
.cache64
.DeviceNo
= i
;
5334 cmd
->u
.cache
.DeviceNo
= i
;
5335 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5336 gdth_do_req(srp
, cmd
, cmnd
, 30);
5337 status
= (ushort
)srp
->sr_command
->SCp
.Status
;
5338 info
= (ulong32
)srp
->sr_command
->SCp
.Message
;
5340 gdth_do_cmd(scp
, cmd
, cmnd
, 30);
5341 status
= (ushort
)scp
->SCp
.Status
;
5342 info
= (ulong32
)scp
->SCp
.Message
;
5344 spin_lock_irqsave(&ha
->smp_lock
, flags
);
5345 ha
->hdr
[i
].cluster_type
=
5346 ((status
== S_OK
&& !shared_access
) ? (ushort
)info
: 0);
5347 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
5348 rsc
->hdr_list
[i
].cluster_type
= ha
->hdr
[i
].cluster_type
;
5350 cmd
->Service
= CACHESERVICE
;
5351 cmd
->OpCode
= GDT_RW_ATTRIBS
;
5352 if (ha
->cache_feat
& GDT_64BIT
)
5353 cmd
->u
.cache64
.DeviceNo
= i
;
5355 cmd
->u
.cache
.DeviceNo
= i
;
5356 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5357 gdth_do_req(srp
, cmd
, cmnd
, 30);
5358 status
= (ushort
)srp
->sr_command
->SCp
.Status
;
5359 info
= (ulong32
)srp
->sr_command
->SCp
.Message
;
5361 gdth_do_cmd(scp
, cmd
, cmnd
, 30);
5362 status
= (ushort
)scp
->SCp
.Status
;
5363 info
= (ulong32
)scp
->SCp
.Message
;
5365 spin_lock_irqsave(&ha
->smp_lock
, flags
);
5366 ha
->hdr
[i
].rw_attribs
= (status
== S_OK
? (ushort
)info
: 0);
5367 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
5369 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5370 scsi_release_request(srp
);
5372 scsi_release_command(scp
);
5375 if (copy_to_user(arg
, rsc
, sizeof(gdth_ioctl_rescan
)))
5386 static int gdth_ioctl(struct inode
*inode
, struct file
*filep
,
5387 unsigned int cmd
, unsigned long arg
)
5392 char cmnd
[MAX_COMMAND_SIZE
];
5393 void __user
*argp
= (void __user
*)arg
;
5395 memset(cmnd
, 0xff, 12);
5397 TRACE(("gdth_ioctl() cmd 0x%x\n", cmd
));
5400 case GDTIOCTL_CTRCNT
:
5402 int cnt
= gdth_ctr_count
;
5403 if (put_user(cnt
, (int __user
*)argp
))
5408 case GDTIOCTL_DRVERS
:
5410 int ver
= (GDTH_VERSION
<<8) | GDTH_SUBVERSION
;
5411 if (put_user(ver
, (int __user
*)argp
))
5416 case GDTIOCTL_OSVERS
:
5418 gdth_ioctl_osvers osv
;
5420 osv
.version
= (unchar
)(LINUX_VERSION_CODE
>> 16);
5421 osv
.subversion
= (unchar
)(LINUX_VERSION_CODE
>> 8);
5422 osv
.revision
= (ushort
)(LINUX_VERSION_CODE
& 0xff);
5423 if (copy_to_user(argp
, &osv
, sizeof(gdth_ioctl_osvers
)))
5428 case GDTIOCTL_CTRTYPE
:
5430 gdth_ioctl_ctrtype ctrt
;
5432 if (copy_from_user(&ctrt
, argp
, sizeof(gdth_ioctl_ctrtype
)) ||
5433 ctrt
.ionode
>= gdth_ctr_count
)
5435 ha
= HADATA(gdth_ctr_tab
[ctrt
.ionode
]);
5436 if (ha
->type
== GDT_ISA
|| ha
->type
== GDT_EISA
) {
5437 ctrt
.type
= (unchar
)((ha
->stype
>>20) - 0x10);
5439 if (ha
->type
!= GDT_PCIMPR
) {
5440 ctrt
.type
= (unchar
)((ha
->stype
<<4) + 6);
5443 (ha
->oem_id
== OEM_ID_INTEL
? 0xfd : 0xfe);
5444 if (ha
->stype
>= 0x300)
5445 ctrt
.ext_type
= 0x6000 | ha
->subdevice_id
;
5447 ctrt
.ext_type
= 0x6000 | ha
->stype
;
5449 ctrt
.device_id
= ha
->stype
;
5450 ctrt
.sub_device_id
= ha
->subdevice_id
;
5452 ctrt
.info
= ha
->brd_phys
;
5453 ctrt
.oem_id
= ha
->oem_id
;
5454 if (copy_to_user(argp
, &ctrt
, sizeof(gdth_ioctl_ctrtype
)))
5459 case GDTIOCTL_GENERAL
:
5460 return ioc_general(argp
, cmnd
);
5462 case GDTIOCTL_EVENT
:
5463 return ioc_event(argp
);
5465 case GDTIOCTL_LOCKDRV
:
5466 return ioc_lockdrv(argp
);
5468 case GDTIOCTL_LOCKCHN
:
5470 gdth_ioctl_lockchn lchn
;
5473 if (copy_from_user(&lchn
, argp
, sizeof(gdth_ioctl_lockchn
)) ||
5474 lchn
.ionode
>= gdth_ctr_count
)
5476 ha
= HADATA(gdth_ctr_tab
[lchn
.ionode
]);
5479 if (i
< ha
->bus_cnt
) {
5481 spin_lock_irqsave(&ha
->smp_lock
, flags
);
5482 ha
->raw
[i
].lock
= 1;
5483 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
5484 for (j
= 0; j
< ha
->tid_cnt
; ++j
) {
5485 gdth_wait_completion(lchn
.ionode
, i
, j
);
5486 gdth_stop_timeout(lchn
.ionode
, i
, j
);
5489 spin_lock_irqsave(&ha
->smp_lock
, flags
);
5490 ha
->raw
[i
].lock
= 0;
5491 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
5492 for (j
= 0; j
< ha
->tid_cnt
; ++j
) {
5493 gdth_start_timeout(lchn
.ionode
, i
, j
);
5494 gdth_next(lchn
.ionode
);
5501 case GDTIOCTL_RESCAN
:
5502 return ioc_rescan(argp
, cmnd
);
5504 case GDTIOCTL_HDRLIST
:
5505 return ioc_hdrlist(argp
, cmnd
);
5507 case GDTIOCTL_RESET_BUS
:
5509 gdth_ioctl_reset res
;
5512 if (copy_from_user(&res
, argp
, sizeof(gdth_ioctl_reset
)) ||
5513 res
.ionode
>= gdth_ctr_count
)
5516 ha
= HADATA(gdth_ctr_tab
[hanum
]);
5518 /* Because we need a Scsi_Cmnd struct., we make a scsi_allocate device also for kernels >=2.6.x */
5519 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5520 scp
= scsi_get_command(ha
->sdev
, GFP_KERNEL
);
5525 scp
->device
->channel
= virt_ctr
? 0 : res
.number
;
5526 rval
= gdth_eh_bus_reset(scp
);
5527 res
.status
= (rval
== SUCCESS
? S_OK
: S_GENERR
);
5528 scsi_put_command(scp
);
5530 scp
= scsi_allocate_device(ha
->sdev
, 1, FALSE
);
5535 scp
->channel
= virt_ctr
? 0 : res
.number
;
5536 rval
= gdth_eh_bus_reset(scp
);
5537 res
.status
= (rval
== SUCCESS
? S_OK
: S_GENERR
);
5538 scsi_release_command(scp
);
5540 if (copy_to_user(argp
, &res
, sizeof(gdth_ioctl_reset
)))
5545 case GDTIOCTL_RESET_DRV
:
5546 return ioc_resetdrv(argp
, cmnd
);
5556 static void gdth_flush(int hanum
)
5560 gdth_cmd_str gdtcmd
;
5561 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5566 struct scsi_device
*sdev
;
5567 char cmnd
[MAX_COMMAND_SIZE
];
5568 memset(cmnd
, 0xff, MAX_COMMAND_SIZE
);
5570 TRACE2(("gdth_flush() hanum %d\n",hanum
));
5571 ha
= HADATA(gdth_ctr_tab
[hanum
]);
5573 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5574 sdev
= scsi_get_host_dev(gdth_ctr_tab
[hanum
]);
5575 srp
= scsi_allocate_request(sdev
, GFP_KERNEL
);
5578 srp
->sr_cmd_len
= 12;
5581 sdev
= scsi_get_host_dev(gdth_ctr_tab
[hanum
]);
5582 scp
= scsi_allocate_device(sdev
, 1, FALSE
);
5589 for (i
= 0; i
< MAX_HDRIVES
; ++i
) {
5590 if (ha
->hdr
[i
].present
) {
5591 gdtcmd
.BoardNode
= LOCALBOARD
;
5592 gdtcmd
.Service
= CACHESERVICE
;
5593 gdtcmd
.OpCode
= GDT_FLUSH
;
5594 if (ha
->cache_feat
& GDT_64BIT
) {
5595 gdtcmd
.u
.cache64
.DeviceNo
= i
;
5596 gdtcmd
.u
.cache64
.BlockNo
= 1;
5597 gdtcmd
.u
.cache64
.sg_canz
= 0;
5599 gdtcmd
.u
.cache
.DeviceNo
= i
;
5600 gdtcmd
.u
.cache
.BlockNo
= 1;
5601 gdtcmd
.u
.cache
.sg_canz
= 0;
5603 TRACE2(("gdth_flush(): flush ha %d drive %d\n", hanum
, i
));
5604 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5605 gdth_do_req(srp
, &gdtcmd
, cmnd
, 30);
5607 gdth_do_cmd(scp
, &gdtcmd
, cmnd
, 30);
5611 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5612 scsi_release_request(srp
);
5613 scsi_free_host_dev(sdev
);
5615 scsi_release_command(scp
);
5616 scsi_free_host_dev(sdev
);
5620 /* shutdown routine */
5621 static int gdth_halt(struct notifier_block
*nb
, ulong event
, void *buf
)
5625 gdth_cmd_str gdtcmd
;
5626 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5628 struct scsi_device
*sdev
;
5631 struct scsi_device
*sdev
;
5633 char cmnd
[MAX_COMMAND_SIZE
];
5636 if (notifier_disabled
)
5639 TRACE2(("gdth_halt() event %d\n",(int)event
));
5640 if (event
!= SYS_RESTART
&& event
!= SYS_HALT
&& event
!= SYS_POWER_OFF
)
5643 notifier_disabled
= 1;
5644 printk("GDT-HA: Flushing all host drives .. ");
5645 for (hanum
= 0; hanum
< gdth_ctr_count
; ++hanum
) {
5649 /* controller reset */
5650 memset(cmnd
, 0xff, MAX_COMMAND_SIZE
);
5651 gdtcmd
.BoardNode
= LOCALBOARD
;
5652 gdtcmd
.Service
= CACHESERVICE
;
5653 gdtcmd
.OpCode
= GDT_RESET
;
5654 TRACE2(("gdth_halt(): reset controller %d\n", hanum
));
5655 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5656 sdev
= scsi_get_host_dev(gdth_ctr_tab
[hanum
]);
5657 srp
= scsi_allocate_request(sdev
, GFP_KERNEL
);
5659 unregister_reboot_notifier(&gdth_notifier
);
5662 srp
->sr_cmd_len
= 12;
5664 gdth_do_req(srp
, &gdtcmd
, cmnd
, 10);
5665 scsi_release_request(srp
);
5666 scsi_free_host_dev(sdev
);
5668 sdev
= scsi_get_host_dev(gdth_ctr_tab
[hanum
]);
5669 scp
= scsi_allocate_device(sdev
, 1, FALSE
);
5671 unregister_reboot_notifier(&gdth_notifier
);
5676 gdth_do_cmd(scp
, &gdtcmd
, cmnd
, 10);
5677 scsi_release_command(scp
);
5678 scsi_free_host_dev(sdev
);
5684 #ifdef GDTH_STATISTICS
5685 del_timer(&gdth_timer
);
5690 static struct scsi_host_template driver_template
= {
5691 .proc_name
= "gdth",
5692 .proc_info
= gdth_proc_info
,
5693 .name
= "GDT SCSI Disk Array Controller",
5694 .detect
= gdth_detect
,
5695 .release
= gdth_release
,
5697 .queuecommand
= gdth_queuecommand
,
5698 .eh_bus_reset_handler
= gdth_eh_bus_reset
,
5699 .bios_param
= gdth_bios_param
,
5700 .can_queue
= GDTH_MAXCMDS
,
5702 .sg_tablesize
= GDTH_MAXSG
,
5703 .cmd_per_lun
= GDTH_MAXC_P_L
,
5704 .unchecked_isa_dma
= 1,
5705 .use_clustering
= ENABLE_CLUSTERING
,
5706 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
5707 .use_new_eh_code
= 1,
5708 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20)
5714 #include "scsi_module.c"
5716 __setup("gdth=", option_setup
);