1 /************************************************************************
3 * ICP vortex GmbH: GDT ISA/EISA/PCI Disk Array Controllers *
4 * Intel Corporation: Storage RAID Controllers *
7 * Copyright (C) 1995-06 ICP vortex GmbH, Achim Leubner *
8 * Copyright (C) 2002-04 Intel Corporation *
9 * Copyright (C) 2003-06 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.6.x supported *
32 ************************************************************************/
34 /* All GDT Disk Array Controllers are fully supported by this driver.
35 * This includes the PCI/EISA/ISA SCSI Disk Array Controllers and the
36 * PCI Fibre Channel Disk Array Controllers. See gdth.h for a complete
37 * list of all controller types.
39 * If you have one or more GDT3000/3020 EISA controllers with
40 * controller BIOS disabled, you have to set the IRQ values with the
41 * command line option "gdth=irq1,irq2,...", where the irq1,irq2,... are
42 * the IRQ values for the EISA controllers.
44 * After the optional list of IRQ values, other possible
45 * command line options are:
46 * disable:Y disable driver
47 * disable:N enable driver
48 * reserve_mode:0 reserve no drives for the raw service
49 * reserve_mode:1 reserve all not init., removable drives
50 * reserve_mode:2 reserve all not init. drives
51 * reserve_list:h,b,t,l,h,b,t,l,... reserve particular drive(s) with
52 * h- controller no., b- channel no.,
53 * t- target ID, l- LUN
54 * reverse_scan:Y reverse scan order for PCI controllers
55 * reverse_scan:N scan PCI controllers like BIOS
56 * max_ids:x x - target ID count per channel (1..MAXID)
57 * rescan:Y rescan all channels/IDs
58 * rescan:N use all devices found until now
59 * hdr_channel:x x - number of virtual bus for host drives
60 * shared_access:Y disable driver reserve/release protocol to
61 * access a shared resource from several nodes,
62 * appropriate controller firmware required
63 * shared_access:N enable driver reserve/release protocol
64 * probe_eisa_isa:Y scan for EISA/ISA controllers
65 * probe_eisa_isa:N do not scan for EISA/ISA controllers
66 * force_dma32:Y use only 32 bit DMA mode
67 * force_dma32:N use 64 bit DMA mode, if supported
69 * The default values are: "gdth=disable:N,reserve_mode:1,reverse_scan:N,
70 * max_ids:127,rescan:N,hdr_channel:0,
71 * shared_access:Y,probe_eisa_isa:N,force_dma32:N".
72 * Here is another example: "gdth=reserve_list:0,1,2,0,0,1,3,0,rescan:Y".
74 * When loading the gdth driver as a module, the same options are available.
75 * You can set the IRQs with "IRQ=...". However, the syntax to specify the
76 * options changes slightly. You must replace all ',' between options
77 * with ' ' and all ':' with '=' and you must use
78 * '1' in place of 'Y' and '0' in place of 'N'.
80 * Default: "modprobe gdth disable=0 reserve_mode=1 reverse_scan=0
81 * max_ids=127 rescan=0 hdr_channel=0 shared_access=0
82 * probe_eisa_isa=0 force_dma32=0"
83 * The other example: "modprobe gdth reserve_list=0,1,2,0,0,1,3,0 rescan=1".
86 /* The meaning of the Scsi_Pointer members in this driver is as follows:
88 * this_residual: gdth_bufflen
91 * buffers_residual: gdth_sg_count
94 * have_data_in: unused
95 * sent_command: unused
100 /* interrupt coalescing */
101 /* #define INT_COAL */
104 #define GDTH_STATISTICS
106 #include <linux/module.h>
108 #include <linux/version.h>
109 #include <linux/kernel.h>
110 #include <linux/types.h>
111 #include <linux/pci.h>
112 #include <linux/string.h>
113 #include <linux/ctype.h>
114 #include <linux/ioport.h>
115 #include <linux/delay.h>
116 #include <linux/interrupt.h>
117 #include <linux/in.h>
118 #include <linux/proc_fs.h>
119 #include <linux/time.h>
120 #include <linux/timer.h>
121 #include <linux/dma-mapping.h>
122 #include <linux/list.h>
125 #include <linux/mc146818rtc.h>
127 #include <linux/reboot.h>
130 #include <asm/system.h>
132 #include <asm/uaccess.h>
133 #include <linux/spinlock.h>
134 #include <linux/blkdev.h>
135 #include <linux/scatterlist.h>
138 #include <scsi/scsi_host.h>
141 static void gdth_delay(int milliseconds
);
142 static void gdth_eval_mapping(ulong32 size
, ulong32
*cyls
, int *heads
, int *secs
);
143 static irqreturn_t
gdth_interrupt(int irq
, void *dev_id
);
144 static irqreturn_t
__gdth_interrupt(gdth_ha_str
*ha
,
145 int gdth_from_wait
, int* pIndex
);
146 static int gdth_sync_event(gdth_ha_str
*ha
, int service
, unchar index
,
148 static int gdth_async_event(gdth_ha_str
*ha
);
149 static void gdth_log_event(gdth_evt_data
*dvr
, char *buffer
);
151 static void gdth_putq(gdth_ha_str
*ha
, Scsi_Cmnd
*scp
, unchar priority
);
152 static void gdth_next(gdth_ha_str
*ha
);
153 static int gdth_fill_raw_cmd(gdth_ha_str
*ha
, Scsi_Cmnd
*scp
, unchar b
);
154 static int gdth_special_cmd(gdth_ha_str
*ha
, Scsi_Cmnd
*scp
);
155 static gdth_evt_str
*gdth_store_event(gdth_ha_str
*ha
, ushort source
,
156 ushort idx
, gdth_evt_data
*evt
);
157 static int gdth_read_event(gdth_ha_str
*ha
, int handle
, gdth_evt_str
*estr
);
158 static void gdth_readapp_event(gdth_ha_str
*ha
, unchar application
,
160 static void gdth_clear_events(void);
162 static void gdth_copy_internal_data(gdth_ha_str
*ha
, Scsi_Cmnd
*scp
,
163 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
164 char *buffer
, ushort count
, int to_buffer
);
166 char *buffer
, ushort count
);
167 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
168 static int gdth_internal_cache_cmd(gdth_ha_str
*ha
, Scsi_Cmnd
*scp
);
169 static int gdth_fill_cache_cmd(gdth_ha_str
*ha
, Scsi_Cmnd
*scp
, ushort hdrive
);
171 static void gdth_enable_int(gdth_ha_str
*ha
);
172 static int gdth_test_busy(gdth_ha_str
*ha
);
173 static int gdth_get_cmd_index(gdth_ha_str
*ha
);
174 static void gdth_release_event(gdth_ha_str
*ha
);
175 static int gdth_wait(gdth_ha_str
*ha
, int index
,ulong32 time
);
176 static int gdth_internal_cmd(gdth_ha_str
*ha
, unchar service
, ushort opcode
,
177 ulong32 p1
, ulong64 p2
,ulong64 p3
);
178 static int gdth_search_drives(gdth_ha_str
*ha
);
179 static int gdth_analyse_hdrive(gdth_ha_str
*ha
, ushort hdrive
);
181 static const char *gdth_ctr_name(gdth_ha_str
*ha
);
183 static int gdth_open(struct inode
*inode
, struct file
*filep
);
184 static int gdth_close(struct inode
*inode
, struct file
*filep
);
185 static int gdth_ioctl(struct inode
*inode
, struct file
*filep
,
186 unsigned int cmd
, unsigned long arg
);
188 static void gdth_flush(gdth_ha_str
*ha
);
189 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
190 static int gdth_halt(struct notifier_block
*nb
, ulong event
, void *buf
);
192 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
193 static int gdth_queuecommand(Scsi_Cmnd
*scp
,void (*done
)(Scsi_Cmnd
*));
194 static int __gdth_queuecommand(gdth_ha_str
*ha
, struct scsi_cmnd
*scp
,
195 struct gdth_cmndinfo
*cmndinfo
);
196 static void gdth_scsi_done(struct scsi_cmnd
*scp
);
199 static unchar DebugState
= DEBUG_GDTH
;
202 #define MAX_SERBUF 160
203 static void ser_init(void);
204 static void ser_puts(char *str
);
205 static void ser_putc(char c
);
206 static int ser_printk(const char *fmt
, ...);
207 static char strbuf
[MAX_SERBUF
+1];
209 #define COM_BASE 0x2f8
211 #define COM_BASE 0x3f8
213 static void ser_init()
215 unsigned port
=COM_BASE
;
219 /* 19200 Baud, if 9600: outb(12,port) */
229 static void ser_puts(char *str
)
234 for (ptr
=str
;*ptr
;++ptr
)
238 static void ser_putc(char c
)
240 unsigned port
=COM_BASE
;
242 while ((inb(port
+5) & 0x20)==0);
246 while ((inb(port
+5) & 0x20)==0);
251 static int ser_printk(const char *fmt
, ...)
257 i
= vsprintf(strbuf
,fmt
,args
);
263 #define TRACE(a) {if (DebugState==1) {ser_printk a;}}
264 #define TRACE2(a) {if (DebugState==1 || DebugState==2) {ser_printk a;}}
265 #define TRACE3(a) {if (DebugState!=0) {ser_printk a;}}
267 #else /* !__SERIAL__ */
268 #define TRACE(a) {if (DebugState==1) {printk a;}}
269 #define TRACE2(a) {if (DebugState==1 || DebugState==2) {printk a;}}
270 #define TRACE3(a) {if (DebugState!=0) {printk a;}}
279 #ifdef GDTH_STATISTICS
280 static ulong32 max_rq
=0, max_index
=0, max_sg
=0;
282 static ulong32 max_int_coal
=0;
284 static ulong32 act_ints
=0, act_ios
=0, act_stats
=0, act_rq
=0;
285 static struct timer_list gdth_timer
;
288 #define PTR2USHORT(a) (ushort)(ulong)(a)
289 #define GDTOFFSOF(a,b) (size_t)&(((a*)0)->b)
290 #define INDEX_OK(i,t) ((i)<ARRAY_SIZE(t))
292 #define BUS_L2P(a,b) ((b)>(a)->virt_bus ? (b-1):(b))
295 static unchar gdth_drq_tab
[4] = {5,6,7,7}; /* DRQ table */
297 #if defined(CONFIG_EISA) || defined(CONFIG_ISA)
298 static unchar gdth_irq_tab
[6] = {0,10,11,12,14,0}; /* IRQ table */
300 static unchar gdth_polling
; /* polling if TRUE */
301 static int gdth_ctr_count
= 0; /* controller count */
302 static LIST_HEAD(gdth_instances
); /* controller list */
303 static unchar gdth_write_through
= FALSE
; /* write through */
304 static gdth_evt_str ebuffer
[MAX_EVENTS
]; /* event buffer */
309 #define DIN 1 /* IN data direction */
310 #define DOU 2 /* OUT data direction */
311 #define DNO DIN /* no data transfer */
312 #define DUN DIN /* unknown data direction */
313 static unchar gdth_direction_tab
[0x100] = {
314 DNO
,DNO
,DIN
,DIN
,DOU
,DIN
,DIN
,DOU
,DIN
,DUN
,DOU
,DOU
,DUN
,DUN
,DUN
,DIN
,
315 DNO
,DIN
,DIN
,DOU
,DIN
,DOU
,DNO
,DNO
,DOU
,DNO
,DIN
,DNO
,DIN
,DOU
,DNO
,DUN
,
316 DIN
,DUN
,DIN
,DUN
,DOU
,DIN
,DUN
,DUN
,DIN
,DIN
,DOU
,DNO
,DUN
,DIN
,DOU
,DOU
,
317 DOU
,DOU
,DOU
,DNO
,DIN
,DNO
,DNO
,DIN
,DOU
,DOU
,DOU
,DOU
,DIN
,DOU
,DIN
,DOU
,
318 DOU
,DOU
,DIN
,DIN
,DIN
,DNO
,DUN
,DNO
,DNO
,DNO
,DUN
,DNO
,DOU
,DIN
,DUN
,DUN
,
319 DUN
,DUN
,DUN
,DUN
,DUN
,DOU
,DUN
,DUN
,DUN
,DUN
,DIN
,DUN
,DUN
,DUN
,DUN
,DUN
,
320 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,
321 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,
322 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DIN
,DUN
,DOU
,DUN
,DUN
,DUN
,DUN
,DUN
,
323 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DIN
,DUN
,
324 DUN
,DUN
,DUN
,DUN
,DUN
,DNO
,DNO
,DUN
,DIN
,DNO
,DOU
,DUN
,DNO
,DUN
,DOU
,DOU
,
325 DOU
,DOU
,DOU
,DNO
,DUN
,DIN
,DOU
,DIN
,DIN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,
326 DUN
,DUN
,DOU
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,
327 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,
328 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DOU
,DUN
,DUN
,DUN
,DUN
,DUN
,
329 DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
,DUN
332 /* LILO and modprobe/insmod parameters */
333 /* IRQ list for GDT3000/3020 EISA controllers */
334 static int irq
[MAXHA
] __initdata
=
335 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
336 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
337 /* disable driver flag */
338 static int disable __initdata
= 0;
340 static int reserve_mode
= 1;
342 static int reserve_list
[MAX_RES_ARGS
] =
343 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
344 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
345 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
346 /* scan order for PCI controllers */
347 static int reverse_scan
= 0;
348 /* virtual channel for the host drives */
349 static int hdr_channel
= 0;
350 /* max. IDs per channel */
351 static int max_ids
= MAXID
;
353 static int rescan
= 0;
355 static int shared_access
= 1;
356 /* enable support for EISA and ISA controllers */
357 static int probe_eisa_isa
= 0;
358 /* 64 bit DMA mode, support for drives > 2 TB, if force_dma32 = 0 */
359 static int force_dma32
= 0;
361 /* parameters for modprobe/insmod */
362 module_param_array(irq
, int, NULL
, 0);
363 module_param(disable
, int, 0);
364 module_param(reserve_mode
, int, 0);
365 module_param_array(reserve_list
, int, NULL
, 0);
366 module_param(reverse_scan
, int, 0);
367 module_param(hdr_channel
, int, 0);
368 module_param(max_ids
, int, 0);
369 module_param(rescan
, int, 0);
370 module_param(shared_access
, int, 0);
371 module_param(probe_eisa_isa
, int, 0);
372 module_param(force_dma32
, int, 0);
373 MODULE_AUTHOR("Achim Leubner");
374 MODULE_LICENSE("GPL");
376 /* ioctl interface */
377 static const struct file_operations gdth_fops
= {
380 .release
= gdth_close
,
384 * gdth scsi_command access wrappers.
385 * below 6 functions are used throughout the driver to access scsi_command's
386 * io parameters. The reason we do not use the regular accessors from
387 * scsi_cmnd.h is because of gdth_execute(). Since it is unrecommended for
388 * llds to directly set scsi_cmnd's IO members. This driver will use SCp
389 * members for IO parameters, and will copy scsi_cmnd's members to Scp
390 * members in queuecommand. For internal commands through gdth_execute()
391 * SCp's members will be set directly.
393 static inline unsigned gdth_bufflen(struct scsi_cmnd
*cmd
)
395 return (unsigned)cmd
->SCp
.this_residual
;
398 static inline void gdth_set_bufflen(struct scsi_cmnd
*cmd
, unsigned bufflen
)
400 cmd
->SCp
.this_residual
= bufflen
;
403 static inline unsigned gdth_sg_count(struct scsi_cmnd
*cmd
)
405 return (unsigned)cmd
->SCp
.buffers_residual
;
408 static inline void gdth_set_sg_count(struct scsi_cmnd
*cmd
, unsigned sg_count
)
410 cmd
->SCp
.buffers_residual
= sg_count
;
413 static inline struct scatterlist
*gdth_sglist(struct scsi_cmnd
*cmd
)
415 return cmd
->SCp
.buffer
;
418 static inline void gdth_set_sglist(struct scsi_cmnd
*cmd
,
419 struct scatterlist
*sglist
)
421 cmd
->SCp
.buffer
= sglist
;
424 #include "gdth_proc.h"
425 #include "gdth_proc.c"
427 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
428 /* notifier block to get a notify on system shutdown/halt/reboot */
429 static struct notifier_block gdth_notifier
= {
432 static int notifier_disabled
= 0;
435 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
436 static gdth_ha_str
*gdth_find_ha(int hanum
)
440 list_for_each_entry(ha
, &gdth_instances
, list
)
441 if (hanum
== ha
->hanum
)
447 static struct gdth_cmndinfo
*gdth_get_cmndinfo(gdth_ha_str
*ha
)
449 struct gdth_cmndinfo
*priv
= NULL
;
453 spin_lock_irqsave(&ha
->smp_lock
, flags
);
455 for (i
=0; i
<GDTH_MAXCMDS
; ++i
) {
456 if (ha
->cmndinfo
[i
].index
== 0) {
457 priv
= &ha
->cmndinfo
[i
];
458 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
461 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
462 memset(priv
, 0, sizeof(*priv
));
463 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
466 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
471 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
476 static void gdth_put_cmndinfo(struct gdth_cmndinfo
*priv
)
482 static void gdth_delay(int milliseconds
)
484 if (milliseconds
== 0) {
487 mdelay(milliseconds
);
491 static void gdth_scsi_done(struct scsi_cmnd
*scp
)
493 struct gdth_cmndinfo
*cmndinfo
= gdth_cmnd_priv(scp
);
494 int internal_command
= cmndinfo
->internal_command
;
496 TRACE2(("gdth_scsi_done()\n"));
498 gdth_put_cmndinfo(cmndinfo
);
499 scp
->host_scribble
= NULL
;
501 if (internal_command
)
502 complete((struct completion
*)scp
->request
);
507 int __gdth_execute(struct scsi_device
*sdev
, gdth_cmd_str
*gdtcmd
, char *cmnd
,
508 int timeout
, u32
*info
)
510 gdth_ha_str
*ha
= shost_priv(sdev
->host
);
512 struct gdth_cmndinfo cmndinfo
;
513 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
514 struct scatterlist one_sg
;
516 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
517 DECLARE_COMPLETION_ONSTACK(wait
);
520 scp
= kzalloc(sizeof(*scp
), GFP_KERNEL
);
525 memset(&cmndinfo
, 0, sizeof(cmndinfo
));
527 /* use request field to save the ptr. to completion struct. */
528 scp
->request
= (struct request
*)&wait
;
529 scp
->timeout_per_command
= timeout
*HZ
;
530 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
531 sg_init_one(&one_sg
, gdtcmd
, sizeof(*gdtcmd
));
532 gdth_set_sglist(scp
, &one_sg
);
533 gdth_set_sg_count(scp
, 1);
534 gdth_set_bufflen(scp
, sizeof(*gdtcmd
));
536 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
538 memcpy(scp
->cmnd
, cmnd
, 12);
539 cmndinfo
.priority
= IOCTL_PRI
;
540 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
542 cmndinfo
.internal_cmd_str
= gdtcmd
;
543 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
544 cmndinfo
.internal_command
= 1;
546 TRACE(("__gdth_execute() cmd 0x%x\n", scp
->cmnd
[0]));
547 __gdth_queuecommand(ha
, scp
, &cmndinfo
);
549 wait_for_completion(&wait
);
551 rval
= cmndinfo
.status
;
553 *info
= cmndinfo
.info
;
558 int gdth_execute(struct Scsi_Host
*shost
, gdth_cmd_str
*gdtcmd
, char *cmnd
,
559 int timeout
, u32
*info
)
561 struct scsi_device
*sdev
= scsi_get_host_dev(shost
);
562 int rval
= __gdth_execute(sdev
, gdtcmd
, cmnd
, timeout
, info
);
564 scsi_free_host_dev(sdev
);
568 static void gdth_eval_mapping(ulong32 size
, ulong32
*cyls
, int *heads
, int *secs
)
570 *cyls
= size
/HEADS
/SECS
;
571 if (*cyls
<= MAXCYLS
) {
574 } else { /* too high for 64*32 */
575 *cyls
= size
/MEDHEADS
/MEDSECS
;
576 if (*cyls
<= MAXCYLS
) {
579 } else { /* too high for 127*63 */
580 *cyls
= size
/BIGHEADS
/BIGSECS
;
587 /* controller search and initialization functions */
589 static int __init
gdth_search_eisa(ushort eisa_adr
)
593 TRACE(("gdth_search_eisa() adr. %x\n",eisa_adr
));
594 id
= inl(eisa_adr
+ID0REG
);
595 if (id
== GDT3A_ID
|| id
== GDT3B_ID
) { /* GDT3000A or GDT3000B */
596 if ((inb(eisa_adr
+EISAREG
) & 8) == 0)
597 return 0; /* not EISA configured */
600 if (id
== GDT3_ID
) /* GDT3000 */
605 #endif /* CONFIG_EISA */
608 static int __init
gdth_search_isa(ulong32 bios_adr
)
613 TRACE(("gdth_search_isa() bios adr. %x\n",bios_adr
));
614 if ((addr
= ioremap(bios_adr
+BIOS_ID_OFFS
, sizeof(ulong32
))) != NULL
) {
617 if (id
== GDT2_ID
) /* GDT2000 */
622 #endif /* CONFIG_ISA */
625 static void gdth_search_dev(gdth_pci_str
*pcistr
, ushort
*cnt
,
626 ushort vendor
, ushort dev
);
628 static int __init
gdth_search_pci(gdth_pci_str
*pcistr
)
632 TRACE(("gdth_search_pci()\n"));
635 for (device
= 0; device
<= PCI_DEVICE_ID_VORTEX_GDT6555
; ++device
)
636 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_VORTEX
, device
);
637 for (device
= PCI_DEVICE_ID_VORTEX_GDT6x17RP
;
638 device
<= PCI_DEVICE_ID_VORTEX_GDTMAXRP
; ++device
)
639 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_VORTEX
, device
);
640 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_VORTEX
,
641 PCI_DEVICE_ID_VORTEX_GDTNEWRX
);
642 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_VORTEX
,
643 PCI_DEVICE_ID_VORTEX_GDTNEWRX2
);
644 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_INTEL
,
645 PCI_DEVICE_ID_INTEL_SRC
);
646 gdth_search_dev(pcistr
, &cnt
, PCI_VENDOR_ID_INTEL
,
647 PCI_DEVICE_ID_INTEL_SRC_XSCALE
);
651 /* Vortex only makes RAID controllers.
652 * We do not really want to specify all 550 ids here, so wildcard match.
654 static struct pci_device_id gdthtable
[] __maybe_unused
= {
655 {PCI_VENDOR_ID_VORTEX
,PCI_ANY_ID
,PCI_ANY_ID
, PCI_ANY_ID
},
656 {PCI_VENDOR_ID_INTEL
,PCI_DEVICE_ID_INTEL_SRC
,PCI_ANY_ID
,PCI_ANY_ID
},
657 {PCI_VENDOR_ID_INTEL
,PCI_DEVICE_ID_INTEL_SRC_XSCALE
,PCI_ANY_ID
,PCI_ANY_ID
},
660 MODULE_DEVICE_TABLE(pci
,gdthtable
);
662 static void __init
gdth_search_dev(gdth_pci_str
*pcistr
, ushort
*cnt
,
663 ushort vendor
, ushort device
)
665 ulong base0
, base1
, base2
;
666 struct pci_dev
*pdev
;
668 TRACE(("gdth_search_dev() cnt %d vendor %x device %x\n",
669 *cnt
, vendor
, device
));
672 while ((pdev
= pci_get_device(vendor
, device
, pdev
))
674 if (pci_enable_device(pdev
))
681 /* GDT PCI controller found, resources are already in pdev */
682 pcistr
[*cnt
].pdev
= pdev
;
683 pcistr
[*cnt
].irq
= pdev
->irq
;
684 base0
= pci_resource_flags(pdev
, 0);
685 base1
= pci_resource_flags(pdev
, 1);
686 base2
= pci_resource_flags(pdev
, 2);
687 if (device
<= PCI_DEVICE_ID_VORTEX_GDT6000B
|| /* GDT6000/B */
688 device
>= PCI_DEVICE_ID_VORTEX_GDT6x17RP
) { /* MPR */
689 if (!(base0
& IORESOURCE_MEM
))
691 pcistr
[*cnt
].dpmem
= pci_resource_start(pdev
, 0);
692 } else { /* GDT6110, GDT6120, .. */
693 if (!(base0
& IORESOURCE_MEM
) ||
694 !(base2
& IORESOURCE_MEM
) ||
695 !(base1
& IORESOURCE_IO
))
697 pcistr
[*cnt
].dpmem
= pci_resource_start(pdev
, 2);
698 pcistr
[*cnt
].io_mm
= pci_resource_start(pdev
, 0);
699 pcistr
[*cnt
].io
= pci_resource_start(pdev
, 1);
701 TRACE2(("Controller found at %d/%d, irq %d, dpmem 0x%lx\n",
702 pcistr
[*cnt
].pdev
->bus
->number
,
703 PCI_SLOT(pcistr
[*cnt
].pdev
->devfn
),
704 pcistr
[*cnt
].irq
, pcistr
[*cnt
].dpmem
));
709 static void __init
gdth_sort_pci(gdth_pci_str
*pcistr
, int cnt
)
714 TRACE(("gdth_sort_pci() cnt %d\n",cnt
));
720 for (i
= 0; i
< cnt
-1; ++i
) {
722 if ((pcistr
[i
].pdev
->bus
->number
> pcistr
[i
+1].pdev
->bus
->number
) ||
723 (pcistr
[i
].pdev
->bus
->number
== pcistr
[i
+1].pdev
->bus
->number
&&
724 PCI_SLOT(pcistr
[i
].pdev
->devfn
) >
725 PCI_SLOT(pcistr
[i
+1].pdev
->devfn
))) {
727 pcistr
[i
] = pcistr
[i
+1];
732 if ((pcistr
[i
].pdev
->bus
->number
< pcistr
[i
+1].pdev
->bus
->number
) ||
733 (pcistr
[i
].pdev
->bus
->number
== pcistr
[i
+1].pdev
->bus
->number
&&
734 PCI_SLOT(pcistr
[i
].pdev
->devfn
) <
735 PCI_SLOT(pcistr
[i
+1].pdev
->devfn
))) {
737 pcistr
[i
] = pcistr
[i
+1];
745 #endif /* CONFIG_PCI */
748 static int __init
gdth_init_eisa(ushort eisa_adr
,gdth_ha_str
*ha
)
751 unchar prot_ver
,eisacf
,i
,irq_found
;
753 TRACE(("gdth_init_eisa() adr. %x\n",eisa_adr
));
755 /* disable board interrupts, deinitialize services */
756 outb(0xff,eisa_adr
+EDOORREG
);
757 outb(0x00,eisa_adr
+EDENABREG
);
758 outb(0x00,eisa_adr
+EINTENABREG
);
760 outb(0xff,eisa_adr
+LDOORREG
);
761 retries
= INIT_RETRIES
;
763 while (inb(eisa_adr
+EDOORREG
) != 0xff) {
764 if (--retries
== 0) {
765 printk("GDT-EISA: Initialization error (DEINIT failed)\n");
769 TRACE2(("wait for DEINIT: retries=%d\n",retries
));
771 prot_ver
= inb(eisa_adr
+MAILBOXREG
);
772 outb(0xff,eisa_adr
+EDOORREG
);
773 if (prot_ver
!= PROTOCOL_VERSION
) {
774 printk("GDT-EISA: Illegal protocol version\n");
778 ha
->brd_phys
= (ulong32
)eisa_adr
>> 12;
780 outl(0,eisa_adr
+MAILBOXREG
);
781 outl(0,eisa_adr
+MAILBOXREG
+4);
782 outl(0,eisa_adr
+MAILBOXREG
+8);
783 outl(0,eisa_adr
+MAILBOXREG
+12);
786 if ((id
= inl(eisa_adr
+ID0REG
)) == GDT3_ID
) {
787 ha
->oem_id
= OEM_ID_ICP
;
790 outl(1,eisa_adr
+MAILBOXREG
+8);
791 outb(0xfe,eisa_adr
+LDOORREG
);
792 retries
= INIT_RETRIES
;
794 while (inb(eisa_adr
+EDOORREG
) != 0xfe) {
795 if (--retries
== 0) {
796 printk("GDT-EISA: Initialization error (get IRQ failed)\n");
801 ha
->irq
= inb(eisa_adr
+MAILBOXREG
);
802 outb(0xff,eisa_adr
+EDOORREG
);
803 TRACE2(("GDT3000/3020: IRQ=%d\n",ha
->irq
));
804 /* check the result */
806 TRACE2(("Unknown IRQ, use IRQ table from cmd line !\n"));
807 for (i
= 0, irq_found
= FALSE
;
808 i
< MAXHA
&& irq
[i
] != 0xff; ++i
) {
809 if (irq
[i
]==10 || irq
[i
]==11 || irq
[i
]==12 || irq
[i
]==14) {
817 printk("GDT-EISA: Can not detect controller IRQ,\n");
818 printk("Use IRQ setting from command line (IRQ = %d)\n",
821 printk("GDT-EISA: Initialization error (unknown IRQ), Enable\n");
822 printk("the controller BIOS or use command line parameters\n");
827 eisacf
= inb(eisa_adr
+EISAREG
) & 7;
828 if (eisacf
> 4) /* level triggered */
830 ha
->irq
= gdth_irq_tab
[eisacf
];
831 ha
->oem_id
= OEM_ID_ICP
;
836 ha
->dma64_support
= 0;
839 #endif /* CONFIG_EISA */
842 static int __init
gdth_init_isa(ulong32 bios_adr
,gdth_ha_str
*ha
)
844 register gdt2_dpram_str __iomem
*dp2_ptr
;
846 unchar irq_drq
,prot_ver
;
849 TRACE(("gdth_init_isa() bios adr. %x\n",bios_adr
));
851 ha
->brd
= ioremap(bios_adr
, sizeof(gdt2_dpram_str
));
852 if (ha
->brd
== NULL
) {
853 printk("GDT-ISA: Initialization error (DPMEM remap error)\n");
857 writeb(1, &dp2_ptr
->io
.memlock
); /* switch off write protection */
858 /* reset interface area */
859 memset_io(&dp2_ptr
->u
, 0, sizeof(dp2_ptr
->u
));
860 if (readl(&dp2_ptr
->u
) != 0) {
861 printk("GDT-ISA: Initialization error (DPMEM write error)\n");
866 /* disable board interrupts, read DRQ and IRQ */
867 writeb(0xff, &dp2_ptr
->io
.irqdel
);
868 writeb(0x00, &dp2_ptr
->io
.irqen
);
869 writeb(0x00, &dp2_ptr
->u
.ic
.S_Status
);
870 writeb(0x00, &dp2_ptr
->u
.ic
.Cmd_Index
);
872 irq_drq
= readb(&dp2_ptr
->io
.rq
);
873 for (i
=0; i
<3; ++i
) {
874 if ((irq_drq
& 1)==0)
878 ha
->drq
= gdth_drq_tab
[i
];
880 irq_drq
= readb(&dp2_ptr
->io
.rq
) >> 3;
881 for (i
=1; i
<5; ++i
) {
882 if ((irq_drq
& 1)==0)
886 ha
->irq
= gdth_irq_tab
[i
];
888 /* deinitialize services */
889 writel(bios_adr
, &dp2_ptr
->u
.ic
.S_Info
[0]);
890 writeb(0xff, &dp2_ptr
->u
.ic
.S_Cmd_Indx
);
891 writeb(0, &dp2_ptr
->io
.event
);
892 retries
= INIT_RETRIES
;
894 while (readb(&dp2_ptr
->u
.ic
.S_Status
) != 0xff) {
895 if (--retries
== 0) {
896 printk("GDT-ISA: Initialization error (DEINIT failed)\n");
902 prot_ver
= (unchar
)readl(&dp2_ptr
->u
.ic
.S_Info
[0]);
903 writeb(0, &dp2_ptr
->u
.ic
.Status
);
904 writeb(0xff, &dp2_ptr
->io
.irqdel
);
905 if (prot_ver
!= PROTOCOL_VERSION
) {
906 printk("GDT-ISA: Illegal protocol version\n");
911 ha
->oem_id
= OEM_ID_ICP
;
913 ha
->ic_all_size
= sizeof(dp2_ptr
->u
);
915 ha
->brd_phys
= bios_adr
>> 4;
917 /* special request to controller BIOS */
918 writel(0x00, &dp2_ptr
->u
.ic
.S_Info
[0]);
919 writel(0x00, &dp2_ptr
->u
.ic
.S_Info
[1]);
920 writel(0x01, &dp2_ptr
->u
.ic
.S_Info
[2]);
921 writel(0x00, &dp2_ptr
->u
.ic
.S_Info
[3]);
922 writeb(0xfe, &dp2_ptr
->u
.ic
.S_Cmd_Indx
);
923 writeb(0, &dp2_ptr
->io
.event
);
924 retries
= INIT_RETRIES
;
926 while (readb(&dp2_ptr
->u
.ic
.S_Status
) != 0xfe) {
927 if (--retries
== 0) {
928 printk("GDT-ISA: Initialization error\n");
934 writeb(0, &dp2_ptr
->u
.ic
.Status
);
935 writeb(0xff, &dp2_ptr
->io
.irqdel
);
937 ha
->dma64_support
= 0;
940 #endif /* CONFIG_ISA */
943 static int __init
gdth_init_pci(gdth_pci_str
*pcistr
,gdth_ha_str
*ha
)
945 register gdt6_dpram_str __iomem
*dp6_ptr
;
946 register gdt6c_dpram_str __iomem
*dp6c_ptr
;
947 register gdt6m_dpram_str __iomem
*dp6m_ptr
;
951 int i
, found
= FALSE
;
953 TRACE(("gdth_init_pci()\n"));
955 if (pcistr
->pdev
->vendor
== PCI_VENDOR_ID_INTEL
)
956 ha
->oem_id
= OEM_ID_INTEL
;
958 ha
->oem_id
= OEM_ID_ICP
;
959 ha
->brd_phys
= (pcistr
->pdev
->bus
->number
<< 8) | (pcistr
->pdev
->devfn
& 0xf8);
960 ha
->stype
= (ulong32
)pcistr
->pdev
->device
;
961 ha
->irq
= pcistr
->irq
;
962 ha
->pdev
= pcistr
->pdev
;
964 if (ha
->pdev
->device
<= PCI_DEVICE_ID_VORTEX_GDT6000B
) { /* GDT6000/B */
965 TRACE2(("init_pci() dpmem %lx irq %d\n",pcistr
->dpmem
,ha
->irq
));
966 ha
->brd
= ioremap(pcistr
->dpmem
, sizeof(gdt6_dpram_str
));
967 if (ha
->brd
== NULL
) {
968 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
971 /* check and reset interface area */
973 writel(DPMEM_MAGIC
, &dp6_ptr
->u
);
974 if (readl(&dp6_ptr
->u
) != DPMEM_MAGIC
) {
975 printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n",
978 for (i
= 0xC8000; i
< 0xE8000; i
+= 0x4000) {
980 ha
->brd
= ioremap(i
, sizeof(ushort
));
981 if (ha
->brd
== NULL
) {
982 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
985 if (readw(ha
->brd
) != 0xffff) {
986 TRACE2(("init_pci_old() address 0x%x busy\n", i
));
990 pci_write_config_dword(pcistr
->pdev
,
991 PCI_BASE_ADDRESS_0
, i
);
992 ha
->brd
= ioremap(i
, sizeof(gdt6_dpram_str
));
993 if (ha
->brd
== NULL
) {
994 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
998 writel(DPMEM_MAGIC
, &dp6_ptr
->u
);
999 if (readl(&dp6_ptr
->u
) == DPMEM_MAGIC
) {
1000 printk("GDT-PCI: Use free address at 0x%x\n", i
);
1006 printk("GDT-PCI: No free address found!\n");
1011 memset_io(&dp6_ptr
->u
, 0, sizeof(dp6_ptr
->u
));
1012 if (readl(&dp6_ptr
->u
) != 0) {
1013 printk("GDT-PCI: Initialization error (DPMEM write error)\n");
1018 /* disable board interrupts, deinit services */
1019 writeb(0xff, &dp6_ptr
->io
.irqdel
);
1020 writeb(0x00, &dp6_ptr
->io
.irqen
);
1021 writeb(0x00, &dp6_ptr
->u
.ic
.S_Status
);
1022 writeb(0x00, &dp6_ptr
->u
.ic
.Cmd_Index
);
1024 writel(pcistr
->dpmem
, &dp6_ptr
->u
.ic
.S_Info
[0]);
1025 writeb(0xff, &dp6_ptr
->u
.ic
.S_Cmd_Indx
);
1026 writeb(0, &dp6_ptr
->io
.event
);
1027 retries
= INIT_RETRIES
;
1029 while (readb(&dp6_ptr
->u
.ic
.S_Status
) != 0xff) {
1030 if (--retries
== 0) {
1031 printk("GDT-PCI: Initialization error (DEINIT failed)\n");
1037 prot_ver
= (unchar
)readl(&dp6_ptr
->u
.ic
.S_Info
[0]);
1038 writeb(0, &dp6_ptr
->u
.ic
.S_Status
);
1039 writeb(0xff, &dp6_ptr
->io
.irqdel
);
1040 if (prot_ver
!= PROTOCOL_VERSION
) {
1041 printk("GDT-PCI: Illegal protocol version\n");
1047 ha
->ic_all_size
= sizeof(dp6_ptr
->u
);
1049 /* special command to controller BIOS */
1050 writel(0x00, &dp6_ptr
->u
.ic
.S_Info
[0]);
1051 writel(0x00, &dp6_ptr
->u
.ic
.S_Info
[1]);
1052 writel(0x00, &dp6_ptr
->u
.ic
.S_Info
[2]);
1053 writel(0x00, &dp6_ptr
->u
.ic
.S_Info
[3]);
1054 writeb(0xfe, &dp6_ptr
->u
.ic
.S_Cmd_Indx
);
1055 writeb(0, &dp6_ptr
->io
.event
);
1056 retries
= INIT_RETRIES
;
1058 while (readb(&dp6_ptr
->u
.ic
.S_Status
) != 0xfe) {
1059 if (--retries
== 0) {
1060 printk("GDT-PCI: Initialization error\n");
1066 writeb(0, &dp6_ptr
->u
.ic
.S_Status
);
1067 writeb(0xff, &dp6_ptr
->io
.irqdel
);
1069 ha
->dma64_support
= 0;
1071 } else if (ha
->pdev
->device
<= PCI_DEVICE_ID_VORTEX_GDT6555
) { /* GDT6110, ... */
1072 ha
->plx
= (gdt6c_plx_regs
*)pcistr
->io
;
1073 TRACE2(("init_pci_new() dpmem %lx irq %d\n",
1074 pcistr
->dpmem
,ha
->irq
));
1075 ha
->brd
= ioremap(pcistr
->dpmem
, sizeof(gdt6c_dpram_str
));
1076 if (ha
->brd
== NULL
) {
1077 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1081 /* check and reset interface area */
1083 writel(DPMEM_MAGIC
, &dp6c_ptr
->u
);
1084 if (readl(&dp6c_ptr
->u
) != DPMEM_MAGIC
) {
1085 printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n",
1088 for (i
= 0xC8000; i
< 0xE8000; i
+= 0x4000) {
1090 ha
->brd
= ioremap(i
, sizeof(ushort
));
1091 if (ha
->brd
== NULL
) {
1092 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1095 if (readw(ha
->brd
) != 0xffff) {
1096 TRACE2(("init_pci_plx() address 0x%x busy\n", i
));
1100 pci_write_config_dword(pcistr
->pdev
,
1101 PCI_BASE_ADDRESS_2
, i
);
1102 ha
->brd
= ioremap(i
, sizeof(gdt6c_dpram_str
));
1103 if (ha
->brd
== NULL
) {
1104 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1108 writel(DPMEM_MAGIC
, &dp6c_ptr
->u
);
1109 if (readl(&dp6c_ptr
->u
) == DPMEM_MAGIC
) {
1110 printk("GDT-PCI: Use free address at 0x%x\n", i
);
1116 printk("GDT-PCI: No free address found!\n");
1121 memset_io(&dp6c_ptr
->u
, 0, sizeof(dp6c_ptr
->u
));
1122 if (readl(&dp6c_ptr
->u
) != 0) {
1123 printk("GDT-PCI: Initialization error (DPMEM write error)\n");
1128 /* disable board interrupts, deinit services */
1129 outb(0x00,PTR2USHORT(&ha
->plx
->control1
));
1130 outb(0xff,PTR2USHORT(&ha
->plx
->edoor_reg
));
1132 writeb(0x00, &dp6c_ptr
->u
.ic
.S_Status
);
1133 writeb(0x00, &dp6c_ptr
->u
.ic
.Cmd_Index
);
1135 writel(pcistr
->dpmem
, &dp6c_ptr
->u
.ic
.S_Info
[0]);
1136 writeb(0xff, &dp6c_ptr
->u
.ic
.S_Cmd_Indx
);
1138 outb(1,PTR2USHORT(&ha
->plx
->ldoor_reg
));
1140 retries
= INIT_RETRIES
;
1142 while (readb(&dp6c_ptr
->u
.ic
.S_Status
) != 0xff) {
1143 if (--retries
== 0) {
1144 printk("GDT-PCI: Initialization error (DEINIT failed)\n");
1150 prot_ver
= (unchar
)readl(&dp6c_ptr
->u
.ic
.S_Info
[0]);
1151 writeb(0, &dp6c_ptr
->u
.ic
.Status
);
1152 if (prot_ver
!= PROTOCOL_VERSION
) {
1153 printk("GDT-PCI: Illegal protocol version\n");
1158 ha
->type
= GDT_PCINEW
;
1159 ha
->ic_all_size
= sizeof(dp6c_ptr
->u
);
1161 /* special command to controller BIOS */
1162 writel(0x00, &dp6c_ptr
->u
.ic
.S_Info
[0]);
1163 writel(0x00, &dp6c_ptr
->u
.ic
.S_Info
[1]);
1164 writel(0x00, &dp6c_ptr
->u
.ic
.S_Info
[2]);
1165 writel(0x00, &dp6c_ptr
->u
.ic
.S_Info
[3]);
1166 writeb(0xfe, &dp6c_ptr
->u
.ic
.S_Cmd_Indx
);
1168 outb(1,PTR2USHORT(&ha
->plx
->ldoor_reg
));
1170 retries
= INIT_RETRIES
;
1172 while (readb(&dp6c_ptr
->u
.ic
.S_Status
) != 0xfe) {
1173 if (--retries
== 0) {
1174 printk("GDT-PCI: Initialization error\n");
1180 writeb(0, &dp6c_ptr
->u
.ic
.S_Status
);
1182 ha
->dma64_support
= 0;
1185 TRACE2(("init_pci_mpr() dpmem %lx irq %d\n",pcistr
->dpmem
,ha
->irq
));
1186 ha
->brd
= ioremap(pcistr
->dpmem
, sizeof(gdt6m_dpram_str
));
1187 if (ha
->brd
== NULL
) {
1188 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1192 /* manipulate config. space to enable DPMEM, start RP controller */
1193 pci_read_config_word(pcistr
->pdev
, PCI_COMMAND
, &command
);
1195 pci_write_config_word(pcistr
->pdev
, PCI_COMMAND
, command
);
1196 if (pci_resource_start(pcistr
->pdev
, 8) == 1UL)
1197 pci_resource_start(pcistr
->pdev
, 8) = 0UL;
1199 pci_write_config_dword(pcistr
->pdev
, PCI_ROM_ADDRESS
, i
);
1201 pci_write_config_dword(pcistr
->pdev
, PCI_ROM_ADDRESS
,
1202 pci_resource_start(pcistr
->pdev
, 8));
1206 /* Ensure that it is safe to access the non HW portions of DPMEM.
1207 * Aditional check needed for Xscale based RAID controllers */
1208 while( ((int)readb(&dp6m_ptr
->i960r
.sema0_reg
) ) & 3 )
1211 /* check and reset interface area */
1212 writel(DPMEM_MAGIC
, &dp6m_ptr
->u
);
1213 if (readl(&dp6m_ptr
->u
) != DPMEM_MAGIC
) {
1214 printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n",
1217 for (i
= 0xC8000; i
< 0xE8000; i
+= 0x4000) {
1219 ha
->brd
= ioremap(i
, sizeof(ushort
));
1220 if (ha
->brd
== NULL
) {
1221 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1224 if (readw(ha
->brd
) != 0xffff) {
1225 TRACE2(("init_pci_mpr() address 0x%x busy\n", i
));
1229 pci_write_config_dword(pcistr
->pdev
,
1230 PCI_BASE_ADDRESS_0
, i
);
1231 ha
->brd
= ioremap(i
, sizeof(gdt6m_dpram_str
));
1232 if (ha
->brd
== NULL
) {
1233 printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
1237 writel(DPMEM_MAGIC
, &dp6m_ptr
->u
);
1238 if (readl(&dp6m_ptr
->u
) == DPMEM_MAGIC
) {
1239 printk("GDT-PCI: Use free address at 0x%x\n", i
);
1245 printk("GDT-PCI: No free address found!\n");
1250 memset_io(&dp6m_ptr
->u
, 0, sizeof(dp6m_ptr
->u
));
1252 /* disable board interrupts, deinit services */
1253 writeb(readb(&dp6m_ptr
->i960r
.edoor_en_reg
) | 4,
1254 &dp6m_ptr
->i960r
.edoor_en_reg
);
1255 writeb(0xff, &dp6m_ptr
->i960r
.edoor_reg
);
1256 writeb(0x00, &dp6m_ptr
->u
.ic
.S_Status
);
1257 writeb(0x00, &dp6m_ptr
->u
.ic
.Cmd_Index
);
1259 writel(pcistr
->dpmem
, &dp6m_ptr
->u
.ic
.S_Info
[0]);
1260 writeb(0xff, &dp6m_ptr
->u
.ic
.S_Cmd_Indx
);
1261 writeb(1, &dp6m_ptr
->i960r
.ldoor_reg
);
1262 retries
= INIT_RETRIES
;
1264 while (readb(&dp6m_ptr
->u
.ic
.S_Status
) != 0xff) {
1265 if (--retries
== 0) {
1266 printk("GDT-PCI: Initialization error (DEINIT failed)\n");
1272 prot_ver
= (unchar
)readl(&dp6m_ptr
->u
.ic
.S_Info
[0]);
1273 writeb(0, &dp6m_ptr
->u
.ic
.S_Status
);
1274 if (prot_ver
!= PROTOCOL_VERSION
) {
1275 printk("GDT-PCI: Illegal protocol version\n");
1280 ha
->type
= GDT_PCIMPR
;
1281 ha
->ic_all_size
= sizeof(dp6m_ptr
->u
);
1283 /* special command to controller BIOS */
1284 writel(0x00, &dp6m_ptr
->u
.ic
.S_Info
[0]);
1285 writel(0x00, &dp6m_ptr
->u
.ic
.S_Info
[1]);
1286 writel(0x00, &dp6m_ptr
->u
.ic
.S_Info
[2]);
1287 writel(0x00, &dp6m_ptr
->u
.ic
.S_Info
[3]);
1288 writeb(0xfe, &dp6m_ptr
->u
.ic
.S_Cmd_Indx
);
1289 writeb(1, &dp6m_ptr
->i960r
.ldoor_reg
);
1290 retries
= INIT_RETRIES
;
1292 while (readb(&dp6m_ptr
->u
.ic
.S_Status
) != 0xfe) {
1293 if (--retries
== 0) {
1294 printk("GDT-PCI: Initialization error\n");
1300 writeb(0, &dp6m_ptr
->u
.ic
.S_Status
);
1302 /* read FW version to detect 64-bit DMA support */
1303 writeb(0xfd, &dp6m_ptr
->u
.ic
.S_Cmd_Indx
);
1304 writeb(1, &dp6m_ptr
->i960r
.ldoor_reg
);
1305 retries
= INIT_RETRIES
;
1307 while (readb(&dp6m_ptr
->u
.ic
.S_Status
) != 0xfd) {
1308 if (--retries
== 0) {
1309 printk("GDT-PCI: Initialization error (DEINIT failed)\n");
1315 prot_ver
= (unchar
)(readl(&dp6m_ptr
->u
.ic
.S_Info
[0]) >> 16);
1316 writeb(0, &dp6m_ptr
->u
.ic
.S_Status
);
1317 if (prot_ver
< 0x2b) /* FW < x.43: no 64-bit DMA support */
1318 ha
->dma64_support
= 0;
1320 ha
->dma64_support
= 1;
1325 #endif /* CONFIG_PCI */
1327 /* controller protocol functions */
1329 static void __init
gdth_enable_int(gdth_ha_str
*ha
)
1332 gdt2_dpram_str __iomem
*dp2_ptr
;
1333 gdt6_dpram_str __iomem
*dp6_ptr
;
1334 gdt6m_dpram_str __iomem
*dp6m_ptr
;
1336 TRACE(("gdth_enable_int() hanum %d\n",ha
->hanum
));
1337 spin_lock_irqsave(&ha
->smp_lock
, flags
);
1339 if (ha
->type
== GDT_EISA
) {
1340 outb(0xff, ha
->bmic
+ EDOORREG
);
1341 outb(0xff, ha
->bmic
+ EDENABREG
);
1342 outb(0x01, ha
->bmic
+ EINTENABREG
);
1343 } else if (ha
->type
== GDT_ISA
) {
1345 writeb(1, &dp2_ptr
->io
.irqdel
);
1346 writeb(0, &dp2_ptr
->u
.ic
.Cmd_Index
);
1347 writeb(1, &dp2_ptr
->io
.irqen
);
1348 } else if (ha
->type
== GDT_PCI
) {
1350 writeb(1, &dp6_ptr
->io
.irqdel
);
1351 writeb(0, &dp6_ptr
->u
.ic
.Cmd_Index
);
1352 writeb(1, &dp6_ptr
->io
.irqen
);
1353 } else if (ha
->type
== GDT_PCINEW
) {
1354 outb(0xff, PTR2USHORT(&ha
->plx
->edoor_reg
));
1355 outb(0x03, PTR2USHORT(&ha
->plx
->control1
));
1356 } else if (ha
->type
== GDT_PCIMPR
) {
1358 writeb(0xff, &dp6m_ptr
->i960r
.edoor_reg
);
1359 writeb(readb(&dp6m_ptr
->i960r
.edoor_en_reg
) & ~4,
1360 &dp6m_ptr
->i960r
.edoor_en_reg
);
1362 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
1365 /* return IStatus if interrupt was from this card else 0 */
1366 static unchar
gdth_get_status(gdth_ha_str
*ha
)
1370 TRACE(("gdth_get_status() irq %d ctr_count %d\n", ha
->irq
, gdth_ctr_count
));
1372 if (ha
->type
== GDT_EISA
)
1373 IStatus
= inb((ushort
)ha
->bmic
+ EDOORREG
);
1374 else if (ha
->type
== GDT_ISA
)
1376 readb(&((gdt2_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Cmd_Index
);
1377 else if (ha
->type
== GDT_PCI
)
1379 readb(&((gdt6_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Cmd_Index
);
1380 else if (ha
->type
== GDT_PCINEW
)
1381 IStatus
= inb(PTR2USHORT(&ha
->plx
->edoor_reg
));
1382 else if (ha
->type
== GDT_PCIMPR
)
1384 readb(&((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.edoor_reg
);
1389 static int gdth_test_busy(gdth_ha_str
*ha
)
1391 register int gdtsema0
= 0;
1393 TRACE(("gdth_test_busy() hanum %d\n", ha
->hanum
));
1395 if (ha
->type
== GDT_EISA
)
1396 gdtsema0
= (int)inb(ha
->bmic
+ SEMA0REG
);
1397 else if (ha
->type
== GDT_ISA
)
1398 gdtsema0
= (int)readb(&((gdt2_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Sema0
);
1399 else if (ha
->type
== GDT_PCI
)
1400 gdtsema0
= (int)readb(&((gdt6_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Sema0
);
1401 else if (ha
->type
== GDT_PCINEW
)
1402 gdtsema0
= (int)inb(PTR2USHORT(&ha
->plx
->sema0_reg
));
1403 else if (ha
->type
== GDT_PCIMPR
)
1405 (int)readb(&((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.sema0_reg
);
1407 return (gdtsema0
& 1);
1411 static int gdth_get_cmd_index(gdth_ha_str
*ha
)
1415 TRACE(("gdth_get_cmd_index() hanum %d\n", ha
->hanum
));
1417 for (i
=0; i
<GDTH_MAXCMDS
; ++i
) {
1418 if (ha
->cmd_tab
[i
].cmnd
== UNUSED_CMND
) {
1419 ha
->cmd_tab
[i
].cmnd
= ha
->pccb
->RequestBuffer
;
1420 ha
->cmd_tab
[i
].service
= ha
->pccb
->Service
;
1421 ha
->pccb
->CommandIndex
= (ulong32
)i
+2;
1429 static void gdth_set_sema0(gdth_ha_str
*ha
)
1431 TRACE(("gdth_set_sema0() hanum %d\n", ha
->hanum
));
1433 if (ha
->type
== GDT_EISA
) {
1434 outb(1, ha
->bmic
+ SEMA0REG
);
1435 } else if (ha
->type
== GDT_ISA
) {
1436 writeb(1, &((gdt2_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Sema0
);
1437 } else if (ha
->type
== GDT_PCI
) {
1438 writeb(1, &((gdt6_dpram_str __iomem
*)ha
->brd
)->u
.ic
.Sema0
);
1439 } else if (ha
->type
== GDT_PCINEW
) {
1440 outb(1, PTR2USHORT(&ha
->plx
->sema0_reg
));
1441 } else if (ha
->type
== GDT_PCIMPR
) {
1442 writeb(1, &((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.sema0_reg
);
1447 static void gdth_copy_command(gdth_ha_str
*ha
)
1449 register gdth_cmd_str
*cmd_ptr
;
1450 register gdt6m_dpram_str __iomem
*dp6m_ptr
;
1451 register gdt6c_dpram_str __iomem
*dp6c_ptr
;
1452 gdt6_dpram_str __iomem
*dp6_ptr
;
1453 gdt2_dpram_str __iomem
*dp2_ptr
;
1454 ushort cp_count
,dp_offset
,cmd_no
;
1456 TRACE(("gdth_copy_command() hanum %d\n", ha
->hanum
));
1458 cp_count
= ha
->cmd_len
;
1459 dp_offset
= ha
->cmd_offs_dpmem
;
1460 cmd_no
= ha
->cmd_cnt
;
1464 if (ha
->type
== GDT_EISA
)
1465 return; /* no DPMEM, no copy */
1467 /* set cpcount dword aligned */
1469 cp_count
+= (4 - (cp_count
& 3));
1471 ha
->cmd_offs_dpmem
+= cp_count
;
1473 /* set offset and service, copy command to DPMEM */
1474 if (ha
->type
== GDT_ISA
) {
1476 writew(dp_offset
+ DPMEM_COMMAND_OFFSET
,
1477 &dp2_ptr
->u
.ic
.comm_queue
[cmd_no
].offset
);
1478 writew((ushort
)cmd_ptr
->Service
,
1479 &dp2_ptr
->u
.ic
.comm_queue
[cmd_no
].serv_id
);
1480 memcpy_toio(&dp2_ptr
->u
.ic
.gdt_dpr_cmd
[dp_offset
],cmd_ptr
,cp_count
);
1481 } else if (ha
->type
== GDT_PCI
) {
1483 writew(dp_offset
+ DPMEM_COMMAND_OFFSET
,
1484 &dp6_ptr
->u
.ic
.comm_queue
[cmd_no
].offset
);
1485 writew((ushort
)cmd_ptr
->Service
,
1486 &dp6_ptr
->u
.ic
.comm_queue
[cmd_no
].serv_id
);
1487 memcpy_toio(&dp6_ptr
->u
.ic
.gdt_dpr_cmd
[dp_offset
],cmd_ptr
,cp_count
);
1488 } else if (ha
->type
== GDT_PCINEW
) {
1490 writew(dp_offset
+ DPMEM_COMMAND_OFFSET
,
1491 &dp6c_ptr
->u
.ic
.comm_queue
[cmd_no
].offset
);
1492 writew((ushort
)cmd_ptr
->Service
,
1493 &dp6c_ptr
->u
.ic
.comm_queue
[cmd_no
].serv_id
);
1494 memcpy_toio(&dp6c_ptr
->u
.ic
.gdt_dpr_cmd
[dp_offset
],cmd_ptr
,cp_count
);
1495 } else if (ha
->type
== GDT_PCIMPR
) {
1497 writew(dp_offset
+ DPMEM_COMMAND_OFFSET
,
1498 &dp6m_ptr
->u
.ic
.comm_queue
[cmd_no
].offset
);
1499 writew((ushort
)cmd_ptr
->Service
,
1500 &dp6m_ptr
->u
.ic
.comm_queue
[cmd_no
].serv_id
);
1501 memcpy_toio(&dp6m_ptr
->u
.ic
.gdt_dpr_cmd
[dp_offset
],cmd_ptr
,cp_count
);
1506 static void gdth_release_event(gdth_ha_str
*ha
)
1508 TRACE(("gdth_release_event() hanum %d\n", ha
->hanum
));
1510 #ifdef GDTH_STATISTICS
1513 for (i
=0,j
=0; j
<GDTH_MAXCMDS
; ++j
) {
1514 if (ha
->cmd_tab
[j
].cmnd
!= UNUSED_CMND
)
1517 if (max_index
< i
) {
1519 TRACE3(("GDT: max_index = %d\n",(ushort
)i
));
1524 if (ha
->pccb
->OpCode
== GDT_INIT
)
1525 ha
->pccb
->Service
|= 0x80;
1527 if (ha
->type
== GDT_EISA
) {
1528 if (ha
->pccb
->OpCode
== GDT_INIT
) /* store DMA buffer */
1529 outl(ha
->ccb_phys
, ha
->bmic
+ MAILBOXREG
);
1530 outb(ha
->pccb
->Service
, ha
->bmic
+ LDOORREG
);
1531 } else if (ha
->type
== GDT_ISA
) {
1532 writeb(0, &((gdt2_dpram_str __iomem
*)ha
->brd
)->io
.event
);
1533 } else if (ha
->type
== GDT_PCI
) {
1534 writeb(0, &((gdt6_dpram_str __iomem
*)ha
->brd
)->io
.event
);
1535 } else if (ha
->type
== GDT_PCINEW
) {
1536 outb(1, PTR2USHORT(&ha
->plx
->ldoor_reg
));
1537 } else if (ha
->type
== GDT_PCIMPR
) {
1538 writeb(1, &((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.ldoor_reg
);
1542 static int gdth_wait(gdth_ha_str
*ha
, int index
, ulong32 time
)
1544 int answer_found
= FALSE
;
1547 TRACE(("gdth_wait() hanum %d index %d time %d\n", ha
->hanum
, index
, time
));
1550 return 1; /* no wait required */
1553 __gdth_interrupt(ha
, true, &wait_index
);
1554 if (wait_index
== index
) {
1555 answer_found
= TRUE
;
1561 while (gdth_test_busy(ha
))
1564 return (answer_found
);
1568 static int gdth_internal_cmd(gdth_ha_str
*ha
, unchar service
, ushort opcode
,
1569 ulong32 p1
, ulong64 p2
, ulong64 p3
)
1571 register gdth_cmd_str
*cmd_ptr
;
1574 TRACE2(("gdth_internal_cmd() service %d opcode %d\n",service
,opcode
));
1577 memset((char*)cmd_ptr
,0,sizeof(gdth_cmd_str
));
1580 for (retries
= INIT_RETRIES
;;) {
1581 cmd_ptr
->Service
= service
;
1582 cmd_ptr
->RequestBuffer
= INTERNAL_CMND
;
1583 if (!(index
=gdth_get_cmd_index(ha
))) {
1584 TRACE(("GDT: No free command index found\n"));
1588 cmd_ptr
->OpCode
= opcode
;
1589 cmd_ptr
->BoardNode
= LOCALBOARD
;
1590 if (service
== CACHESERVICE
) {
1591 if (opcode
== GDT_IOCTL
) {
1592 cmd_ptr
->u
.ioctl
.subfunc
= p1
;
1593 cmd_ptr
->u
.ioctl
.channel
= (ulong32
)p2
;
1594 cmd_ptr
->u
.ioctl
.param_size
= (ushort
)p3
;
1595 cmd_ptr
->u
.ioctl
.p_param
= ha
->scratch_phys
;
1597 if (ha
->cache_feat
& GDT_64BIT
) {
1598 cmd_ptr
->u
.cache64
.DeviceNo
= (ushort
)p1
;
1599 cmd_ptr
->u
.cache64
.BlockNo
= p2
;
1601 cmd_ptr
->u
.cache
.DeviceNo
= (ushort
)p1
;
1602 cmd_ptr
->u
.cache
.BlockNo
= (ulong32
)p2
;
1605 } else if (service
== SCSIRAWSERVICE
) {
1606 if (ha
->raw_feat
& GDT_64BIT
) {
1607 cmd_ptr
->u
.raw64
.direction
= p1
;
1608 cmd_ptr
->u
.raw64
.bus
= (unchar
)p2
;
1609 cmd_ptr
->u
.raw64
.target
= (unchar
)p3
;
1610 cmd_ptr
->u
.raw64
.lun
= (unchar
)(p3
>> 8);
1612 cmd_ptr
->u
.raw
.direction
= p1
;
1613 cmd_ptr
->u
.raw
.bus
= (unchar
)p2
;
1614 cmd_ptr
->u
.raw
.target
= (unchar
)p3
;
1615 cmd_ptr
->u
.raw
.lun
= (unchar
)(p3
>> 8);
1617 } else if (service
== SCREENSERVICE
) {
1618 if (opcode
== GDT_REALTIME
) {
1619 *(ulong32
*)&cmd_ptr
->u
.screen
.su
.data
[0] = p1
;
1620 *(ulong32
*)&cmd_ptr
->u
.screen
.su
.data
[4] = (ulong32
)p2
;
1621 *(ulong32
*)&cmd_ptr
->u
.screen
.su
.data
[8] = (ulong32
)p3
;
1624 ha
->cmd_len
= sizeof(gdth_cmd_str
);
1625 ha
->cmd_offs_dpmem
= 0;
1627 gdth_copy_command(ha
);
1628 gdth_release_event(ha
);
1630 if (!gdth_wait(ha
, index
, INIT_TIMEOUT
)) {
1631 printk("GDT: Initialization error (timeout service %d)\n",service
);
1634 if (ha
->status
!= S_BSY
|| --retries
== 0)
1639 return (ha
->status
!= S_OK
? 0:1);
1643 /* search for devices */
1645 static int __init
gdth_search_drives(gdth_ha_str
*ha
)
1649 ulong32 bus_no
, drv_cnt
, drv_no
, j
;
1650 gdth_getch_str
*chn
;
1651 gdth_drlist_str
*drl
;
1652 gdth_iochan_str
*ioc
;
1653 gdth_raw_iochan_str
*iocr
;
1654 gdth_arcdl_str
*alst
;
1655 gdth_alist_str
*alst2
;
1656 gdth_oem_str_ioctl
*oemstr
;
1658 gdth_perf_modes
*pmod
;
1666 TRACE(("gdth_search_drives() hanum %d\n", ha
->hanum
));
1669 /* initialize controller services, at first: screen service */
1670 ha
->screen_feat
= 0;
1672 ok
= gdth_internal_cmd(ha
, SCREENSERVICE
, GDT_X_INIT_SCR
, 0, 0, 0);
1674 ha
->screen_feat
= GDT_64BIT
;
1676 if (force_dma32
|| (!ok
&& ha
->status
== (ushort
)S_NOFUNC
))
1677 ok
= gdth_internal_cmd(ha
, SCREENSERVICE
, GDT_INIT
, 0, 0, 0);
1679 printk("GDT-HA %d: Initialization error screen service (code %d)\n",
1680 ha
->hanum
, ha
->status
);
1683 TRACE2(("gdth_search_drives(): SCREENSERVICE initialized\n"));
1686 /* read realtime clock info, send to controller */
1687 /* 1. wait for the falling edge of update flag */
1688 spin_lock_irqsave(&rtc_lock
, flags
);
1689 for (j
= 0; j
< 1000000; ++j
)
1690 if (CMOS_READ(RTC_FREQ_SELECT
) & RTC_UIP
)
1692 for (j
= 0; j
< 1000000; ++j
)
1693 if (!(CMOS_READ(RTC_FREQ_SELECT
) & RTC_UIP
))
1697 for (j
= 0; j
< 12; ++j
)
1698 rtc
[j
] = CMOS_READ(j
);
1699 } while (rtc
[0] != CMOS_READ(0));
1700 spin_unlock_irqrestore(&rtc_lock
, flags
);
1701 TRACE2(("gdth_search_drives(): RTC: %x/%x/%x\n",*(ulong32
*)&rtc
[0],
1702 *(ulong32
*)&rtc
[4], *(ulong32
*)&rtc
[8]));
1703 /* 3. send to controller firmware */
1704 gdth_internal_cmd(ha
, SCREENSERVICE
, GDT_REALTIME
, *(ulong32
*)&rtc
[0],
1705 *(ulong32
*)&rtc
[4], *(ulong32
*)&rtc
[8]);
1708 /* unfreeze all IOs */
1709 gdth_internal_cmd(ha
, CACHESERVICE
, GDT_UNFREEZE_IO
, 0, 0, 0);
1711 /* initialize cache service */
1714 ok
= gdth_internal_cmd(ha
, CACHESERVICE
, GDT_X_INIT_HOST
, LINUX_OS
,
1717 ha
->cache_feat
= GDT_64BIT
;
1719 if (force_dma32
|| (!ok
&& ha
->status
== (ushort
)S_NOFUNC
))
1720 ok
= gdth_internal_cmd(ha
, CACHESERVICE
, GDT_INIT
, LINUX_OS
, 0, 0);
1722 printk("GDT-HA %d: Initialization error cache service (code %d)\n",
1723 ha
->hanum
, ha
->status
);
1726 TRACE2(("gdth_search_drives(): CACHESERVICE initialized\n"));
1727 cdev_cnt
= (ushort
)ha
->info
;
1728 ha
->fw_vers
= ha
->service
;
1731 if (ha
->type
== GDT_PCIMPR
) {
1732 /* set perf. modes */
1733 pmod
= (gdth_perf_modes
*)ha
->pscratch
;
1735 pmod
->st_mode
= 1; /* enable one status buffer */
1736 *((ulong64
*)&pmod
->st_buff_addr1
) = ha
->coal_stat_phys
;
1737 pmod
->st_buff_indx1
= COALINDEX
;
1738 pmod
->st_buff_addr2
= 0;
1739 pmod
->st_buff_u_addr2
= 0;
1740 pmod
->st_buff_indx2
= 0;
1741 pmod
->st_buff_size
= sizeof(gdth_coal_status
) * MAXOFFSETS
;
1742 pmod
->cmd_mode
= 0; // disable all cmd buffers
1743 pmod
->cmd_buff_addr1
= 0;
1744 pmod
->cmd_buff_u_addr1
= 0;
1745 pmod
->cmd_buff_indx1
= 0;
1746 pmod
->cmd_buff_addr2
= 0;
1747 pmod
->cmd_buff_u_addr2
= 0;
1748 pmod
->cmd_buff_indx2
= 0;
1749 pmod
->cmd_buff_size
= 0;
1750 pmod
->reserved1
= 0;
1751 pmod
->reserved2
= 0;
1752 if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_IOCTL
, SET_PERF_MODES
,
1753 INVALID_CHANNEL
,sizeof(gdth_perf_modes
))) {
1754 printk("GDT-HA %d: Interrupt coalescing activated\n", ha
->hanum
);
1759 /* detect number of buses - try new IOCTL */
1760 iocr
= (gdth_raw_iochan_str
*)ha
->pscratch
;
1761 iocr
->hdr
.version
= 0xffffffff;
1762 iocr
->hdr
.list_entries
= MAXBUS
;
1763 iocr
->hdr
.first_chan
= 0;
1764 iocr
->hdr
.last_chan
= MAXBUS
-1;
1765 iocr
->hdr
.list_offset
= GDTOFFSOF(gdth_raw_iochan_str
, list
[0]);
1766 if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_IOCTL
, IOCHAN_RAW_DESC
,
1767 INVALID_CHANNEL
,sizeof(gdth_raw_iochan_str
))) {
1768 TRACE2(("IOCHAN_RAW_DESC supported!\n"));
1769 ha
->bus_cnt
= iocr
->hdr
.chan_count
;
1770 for (bus_no
= 0; bus_no
< ha
->bus_cnt
; ++bus_no
) {
1771 if (iocr
->list
[bus_no
].proc_id
< MAXID
)
1772 ha
->bus_id
[bus_no
] = iocr
->list
[bus_no
].proc_id
;
1774 ha
->bus_id
[bus_no
] = 0xff;
1778 chn
= (gdth_getch_str
*)ha
->pscratch
;
1779 for (bus_no
= 0; bus_no
< MAXBUS
; ++bus_no
) {
1780 chn
->channel_no
= bus_no
;
1781 if (!gdth_internal_cmd(ha
, CACHESERVICE
, GDT_IOCTL
,
1782 SCSI_CHAN_CNT
| L_CTRL_PATTERN
,
1783 IO_CHANNEL
| INVALID_CHANNEL
,
1784 sizeof(gdth_getch_str
))) {
1786 printk("GDT-HA %d: Error detecting channel count (0x%x)\n",
1787 ha
->hanum
, ha
->status
);
1792 if (chn
->siop_id
< MAXID
)
1793 ha
->bus_id
[bus_no
] = chn
->siop_id
;
1795 ha
->bus_id
[bus_no
] = 0xff;
1797 ha
->bus_cnt
= (unchar
)bus_no
;
1799 TRACE2(("gdth_search_drives() %d channels\n",ha
->bus_cnt
));
1801 /* read cache configuration */
1802 if (!gdth_internal_cmd(ha
, CACHESERVICE
, GDT_IOCTL
, CACHE_INFO
,
1803 INVALID_CHANNEL
,sizeof(gdth_cinfo_str
))) {
1804 printk("GDT-HA %d: Initialization error cache service (code %d)\n",
1805 ha
->hanum
, ha
->status
);
1808 ha
->cpar
= ((gdth_cinfo_str
*)ha
->pscratch
)->cpar
;
1809 TRACE2(("gdth_search_drives() cinfo: vs %x sta %d str %d dw %d b %d\n",
1810 ha
->cpar
.version
,ha
->cpar
.state
,ha
->cpar
.strategy
,
1811 ha
->cpar
.write_back
,ha
->cpar
.block_size
));
1813 /* read board info and features */
1814 ha
->more_proc
= FALSE
;
1815 if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_IOCTL
, BOARD_INFO
,
1816 INVALID_CHANNEL
,sizeof(gdth_binfo_str
))) {
1817 memcpy(&ha
->binfo
, (gdth_binfo_str
*)ha
->pscratch
,
1818 sizeof(gdth_binfo_str
));
1819 if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_IOCTL
, BOARD_FEATURES
,
1820 INVALID_CHANNEL
,sizeof(gdth_bfeat_str
))) {
1821 TRACE2(("BOARD_INFO/BOARD_FEATURES supported\n"));
1822 ha
->bfeat
= *(gdth_bfeat_str
*)ha
->pscratch
;
1823 ha
->more_proc
= TRUE
;
1826 TRACE2(("BOARD_INFO requires firmware >= 1.10/2.08\n"));
1827 strcpy(ha
->binfo
.type_string
, gdth_ctr_name(ha
));
1829 TRACE2(("Controller name: %s\n",ha
->binfo
.type_string
));
1831 /* read more informations */
1832 if (ha
->more_proc
) {
1833 /* physical drives, channel addresses */
1834 ioc
= (gdth_iochan_str
*)ha
->pscratch
;
1835 ioc
->hdr
.version
= 0xffffffff;
1836 ioc
->hdr
.list_entries
= MAXBUS
;
1837 ioc
->hdr
.first_chan
= 0;
1838 ioc
->hdr
.last_chan
= MAXBUS
-1;
1839 ioc
->hdr
.list_offset
= GDTOFFSOF(gdth_iochan_str
, list
[0]);
1840 if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_IOCTL
, IOCHAN_DESC
,
1841 INVALID_CHANNEL
,sizeof(gdth_iochan_str
))) {
1842 for (bus_no
= 0; bus_no
< ha
->bus_cnt
; ++bus_no
) {
1843 ha
->raw
[bus_no
].address
= ioc
->list
[bus_no
].address
;
1844 ha
->raw
[bus_no
].local_no
= ioc
->list
[bus_no
].local_no
;
1847 for (bus_no
= 0; bus_no
< ha
->bus_cnt
; ++bus_no
) {
1848 ha
->raw
[bus_no
].address
= IO_CHANNEL
;
1849 ha
->raw
[bus_no
].local_no
= bus_no
;
1852 for (bus_no
= 0; bus_no
< ha
->bus_cnt
; ++bus_no
) {
1853 chn
= (gdth_getch_str
*)ha
->pscratch
;
1854 chn
->channel_no
= ha
->raw
[bus_no
].local_no
;
1855 if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_IOCTL
,
1856 SCSI_CHAN_CNT
| L_CTRL_PATTERN
,
1857 ha
->raw
[bus_no
].address
| INVALID_CHANNEL
,
1858 sizeof(gdth_getch_str
))) {
1859 ha
->raw
[bus_no
].pdev_cnt
= chn
->drive_cnt
;
1860 TRACE2(("Channel %d: %d phys. drives\n",
1861 bus_no
,chn
->drive_cnt
));
1863 if (ha
->raw
[bus_no
].pdev_cnt
> 0) {
1864 drl
= (gdth_drlist_str
*)ha
->pscratch
;
1865 drl
->sc_no
= ha
->raw
[bus_no
].local_no
;
1866 drl
->sc_cnt
= ha
->raw
[bus_no
].pdev_cnt
;
1867 if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_IOCTL
,
1868 SCSI_DR_LIST
| L_CTRL_PATTERN
,
1869 ha
->raw
[bus_no
].address
| INVALID_CHANNEL
,
1870 sizeof(gdth_drlist_str
))) {
1871 for (j
= 0; j
< ha
->raw
[bus_no
].pdev_cnt
; ++j
)
1872 ha
->raw
[bus_no
].id_list
[j
] = drl
->sc_list
[j
];
1874 ha
->raw
[bus_no
].pdev_cnt
= 0;
1879 /* logical drives */
1880 if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_IOCTL
, CACHE_DRV_CNT
,
1881 INVALID_CHANNEL
,sizeof(ulong32
))) {
1882 drv_cnt
= *(ulong32
*)ha
->pscratch
;
1883 if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_IOCTL
, CACHE_DRV_LIST
,
1884 INVALID_CHANNEL
,drv_cnt
* sizeof(ulong32
))) {
1885 for (j
= 0; j
< drv_cnt
; ++j
) {
1886 drv_no
= ((ulong32
*)ha
->pscratch
)[j
];
1887 if (drv_no
< MAX_LDRIVES
) {
1888 ha
->hdr
[drv_no
].is_logdrv
= TRUE
;
1889 TRACE2(("Drive %d is log. drive\n",drv_no
));
1893 alst
= (gdth_arcdl_str
*)ha
->pscratch
;
1894 alst
->entries_avail
= MAX_LDRIVES
;
1895 alst
->first_entry
= 0;
1896 alst
->list_offset
= GDTOFFSOF(gdth_arcdl_str
, list
[0]);
1897 if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_IOCTL
,
1898 ARRAY_DRV_LIST2
| LA_CTRL_PATTERN
,
1899 INVALID_CHANNEL
, sizeof(gdth_arcdl_str
) +
1900 (alst
->entries_avail
-1) * sizeof(gdth_alist_str
))) {
1901 for (j
= 0; j
< alst
->entries_init
; ++j
) {
1902 ha
->hdr
[j
].is_arraydrv
= alst
->list
[j
].is_arrayd
;
1903 ha
->hdr
[j
].is_master
= alst
->list
[j
].is_master
;
1904 ha
->hdr
[j
].is_parity
= alst
->list
[j
].is_parity
;
1905 ha
->hdr
[j
].is_hotfix
= alst
->list
[j
].is_hotfix
;
1906 ha
->hdr
[j
].master_no
= alst
->list
[j
].cd_handle
;
1908 } else if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_IOCTL
,
1909 ARRAY_DRV_LIST
| LA_CTRL_PATTERN
,
1910 0, 35 * sizeof(gdth_alist_str
))) {
1911 for (j
= 0; j
< 35; ++j
) {
1912 alst2
= &((gdth_alist_str
*)ha
->pscratch
)[j
];
1913 ha
->hdr
[j
].is_arraydrv
= alst2
->is_arrayd
;
1914 ha
->hdr
[j
].is_master
= alst2
->is_master
;
1915 ha
->hdr
[j
].is_parity
= alst2
->is_parity
;
1916 ha
->hdr
[j
].is_hotfix
= alst2
->is_hotfix
;
1917 ha
->hdr
[j
].master_no
= alst2
->cd_handle
;
1923 /* initialize raw service */
1926 ok
= gdth_internal_cmd(ha
, SCSIRAWSERVICE
, GDT_X_INIT_RAW
, 0, 0, 0);
1928 ha
->raw_feat
= GDT_64BIT
;
1930 if (force_dma32
|| (!ok
&& ha
->status
== (ushort
)S_NOFUNC
))
1931 ok
= gdth_internal_cmd(ha
, SCSIRAWSERVICE
, GDT_INIT
, 0, 0, 0);
1933 printk("GDT-HA %d: Initialization error raw service (code %d)\n",
1934 ha
->hanum
, ha
->status
);
1937 TRACE2(("gdth_search_drives(): RAWSERVICE initialized\n"));
1939 /* set/get features raw service (scatter/gather) */
1940 if (gdth_internal_cmd(ha
, SCSIRAWSERVICE
, GDT_SET_FEAT
, SCATTER_GATHER
,
1942 TRACE2(("gdth_search_drives(): set features RAWSERVICE OK\n"));
1943 if (gdth_internal_cmd(ha
, SCSIRAWSERVICE
, GDT_GET_FEAT
, 0, 0, 0)) {
1944 TRACE2(("gdth_search_dr(): get feat RAWSERVICE %d\n",
1946 ha
->raw_feat
|= (ushort
)ha
->info
;
1950 /* set/get features cache service (equal to raw service) */
1951 if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_SET_FEAT
, 0,
1952 SCATTER_GATHER
,0)) {
1953 TRACE2(("gdth_search_drives(): set features CACHESERVICE OK\n"));
1954 if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_GET_FEAT
, 0, 0, 0)) {
1955 TRACE2(("gdth_search_dr(): get feat CACHESERV. %d\n",
1957 ha
->cache_feat
|= (ushort
)ha
->info
;
1961 /* reserve drives for raw service */
1962 if (reserve_mode
!= 0) {
1963 gdth_internal_cmd(ha
, SCSIRAWSERVICE
, GDT_RESERVE_ALL
,
1964 reserve_mode
== 1 ? 1 : 3, 0, 0);
1965 TRACE2(("gdth_search_drives(): RESERVE_ALL code %d\n",
1968 for (i
= 0; i
< MAX_RES_ARGS
; i
+= 4) {
1969 if (reserve_list
[i
] == ha
->hanum
&& reserve_list
[i
+1] < ha
->bus_cnt
&&
1970 reserve_list
[i
+2] < ha
->tid_cnt
&& reserve_list
[i
+3] < MAXLUN
) {
1971 TRACE2(("gdth_search_drives(): reserve ha %d bus %d id %d lun %d\n",
1972 reserve_list
[i
], reserve_list
[i
+1],
1973 reserve_list
[i
+2], reserve_list
[i
+3]));
1974 if (!gdth_internal_cmd(ha
, SCSIRAWSERVICE
, GDT_RESERVE
, 0,
1975 reserve_list
[i
+1], reserve_list
[i
+2] |
1976 (reserve_list
[i
+3] << 8))) {
1977 printk("GDT-HA %d: Error raw service (RESERVE, code %d)\n",
1978 ha
->hanum
, ha
->status
);
1983 /* Determine OEM string using IOCTL */
1984 oemstr
= (gdth_oem_str_ioctl
*)ha
->pscratch
;
1985 oemstr
->params
.ctl_version
= 0x01;
1986 oemstr
->params
.buffer_size
= sizeof(oemstr
->text
);
1987 if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_IOCTL
,
1988 CACHE_READ_OEM_STRING_RECORD
,INVALID_CHANNEL
,
1989 sizeof(gdth_oem_str_ioctl
))) {
1990 TRACE2(("gdth_search_drives(): CACHE_READ_OEM_STRING_RECORD OK\n"));
1991 printk("GDT-HA %d: Vendor: %s Name: %s\n",
1992 ha
->hanum
, oemstr
->text
.oem_company_name
, ha
->binfo
.type_string
);
1993 /* Save the Host Drive inquiry data */
1994 strlcpy(ha
->oem_name
,oemstr
->text
.scsi_host_drive_inquiry_vendor_id
,
1995 sizeof(ha
->oem_name
));
1997 /* Old method, based on PCI ID */
1998 TRACE2(("gdth_search_drives(): CACHE_READ_OEM_STRING_RECORD failed\n"));
1999 printk("GDT-HA %d: Name: %s\n",
2000 ha
->hanum
, ha
->binfo
.type_string
);
2001 if (ha
->oem_id
== OEM_ID_INTEL
)
2002 strlcpy(ha
->oem_name
,"Intel ", sizeof(ha
->oem_name
));
2004 strlcpy(ha
->oem_name
,"ICP ", sizeof(ha
->oem_name
));
2007 /* scanning for host drives */
2008 for (i
= 0; i
< cdev_cnt
; ++i
)
2009 gdth_analyse_hdrive(ha
, i
);
2011 TRACE(("gdth_search_drives() OK\n"));
2015 static int gdth_analyse_hdrive(gdth_ha_str
*ha
, ushort hdrive
)
2018 int drv_hds
, drv_secs
;
2020 TRACE(("gdth_analyse_hdrive() hanum %d drive %d\n", ha
->hanum
, hdrive
));
2021 if (hdrive
>= MAX_HDRIVES
)
2024 if (!gdth_internal_cmd(ha
, CACHESERVICE
, GDT_INFO
, hdrive
, 0, 0))
2026 ha
->hdr
[hdrive
].present
= TRUE
;
2027 ha
->hdr
[hdrive
].size
= ha
->info
;
2029 /* evaluate mapping (sectors per head, heads per cylinder) */
2030 ha
->hdr
[hdrive
].size
&= ~SECS32
;
2031 if (ha
->info2
== 0) {
2032 gdth_eval_mapping(ha
->hdr
[hdrive
].size
,&drv_cyls
,&drv_hds
,&drv_secs
);
2034 drv_hds
= ha
->info2
& 0xff;
2035 drv_secs
= (ha
->info2
>> 8) & 0xff;
2036 drv_cyls
= (ulong32
)ha
->hdr
[hdrive
].size
/ drv_hds
/ drv_secs
;
2038 ha
->hdr
[hdrive
].heads
= (unchar
)drv_hds
;
2039 ha
->hdr
[hdrive
].secs
= (unchar
)drv_secs
;
2041 ha
->hdr
[hdrive
].size
= drv_cyls
* drv_hds
* drv_secs
;
2043 if (ha
->cache_feat
& GDT_64BIT
) {
2044 if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_X_INFO
, hdrive
, 0, 0)
2045 && ha
->info2
!= 0) {
2046 ha
->hdr
[hdrive
].size
= ((ulong64
)ha
->info2
<< 32) | ha
->info
;
2049 TRACE2(("gdth_search_dr() cdr. %d size %d hds %d scs %d\n",
2050 hdrive
,ha
->hdr
[hdrive
].size
,drv_hds
,drv_secs
));
2052 /* get informations about device */
2053 if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_DEVTYPE
, hdrive
, 0, 0)) {
2054 TRACE2(("gdth_search_dr() cache drive %d devtype %d\n",
2056 ha
->hdr
[hdrive
].devtype
= (ushort
)ha
->info
;
2060 if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_CLUST_INFO
, hdrive
, 0, 0)) {
2061 TRACE2(("gdth_search_dr() cache drive %d cluster info %d\n",
2064 ha
->hdr
[hdrive
].cluster_type
= (unchar
)ha
->info
;
2067 /* R/W attributes */
2068 if (gdth_internal_cmd(ha
, CACHESERVICE
, GDT_RW_ATTRIBS
, hdrive
, 0, 0)) {
2069 TRACE2(("gdth_search_dr() cache drive %d r/w attrib. %d\n",
2071 ha
->hdr
[hdrive
].rw_attribs
= (unchar
)ha
->info
;
2078 /* command queueing/sending functions */
2080 static void gdth_putq(gdth_ha_str
*ha
, Scsi_Cmnd
*scp
, unchar priority
)
2082 struct gdth_cmndinfo
*cmndinfo
= gdth_cmnd_priv(scp
);
2083 register Scsi_Cmnd
*pscp
;
2084 register Scsi_Cmnd
*nscp
;
2088 TRACE(("gdth_putq() priority %d\n",priority
));
2089 spin_lock_irqsave(&ha
->smp_lock
, flags
);
2091 if (!cmndinfo
->internal_command
) {
2092 cmndinfo
->priority
= priority
;
2093 b
= scp
->device
->channel
;
2094 t
= scp
->device
->id
;
2095 if (priority
>= DEFAULT_PRI
) {
2096 if ((b
!= ha
->virt_bus
&& ha
->raw
[BUS_L2P(ha
,b
)].lock
) ||
2097 (b
==ha
->virt_bus
&& t
<MAX_HDRIVES
&& ha
->hdr
[t
].lock
)) {
2098 TRACE2(("gdth_putq(): locked IO ->update_timeout()\n"));
2099 cmndinfo
->timeout
= gdth_update_timeout(scp
, 0);
2104 if (ha
->req_first
==NULL
) {
2105 ha
->req_first
= scp
; /* queue was empty */
2106 scp
->SCp
.ptr
= NULL
;
2107 } else { /* queue not empty */
2108 pscp
= ha
->req_first
;
2109 nscp
= (Scsi_Cmnd
*)pscp
->SCp
.ptr
;
2110 /* priority: 0-highest,..,0xff-lowest */
2111 while (nscp
&& gdth_cmnd_priv(nscp
)->priority
<= priority
) {
2113 nscp
= (Scsi_Cmnd
*)pscp
->SCp
.ptr
;
2115 pscp
->SCp
.ptr
= (char *)scp
;
2116 scp
->SCp
.ptr
= (char *)nscp
;
2118 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
2120 #ifdef GDTH_STATISTICS
2122 for (nscp
=ha
->req_first
; nscp
; nscp
=(Scsi_Cmnd
*)nscp
->SCp
.ptr
)
2124 if (max_rq
< flags
) {
2126 TRACE3(("GDT: max_rq = %d\n",(ushort
)max_rq
));
2131 static void gdth_next(gdth_ha_str
*ha
)
2133 register Scsi_Cmnd
*pscp
;
2134 register Scsi_Cmnd
*nscp
;
2135 unchar b
, t
, l
, firsttime
;
2136 unchar this_cmd
, next_cmd
;
2140 TRACE(("gdth_next() hanum %d\n", ha
->hanum
));
2142 spin_lock_irqsave(&ha
->smp_lock
, flags
);
2144 ha
->cmd_cnt
= ha
->cmd_offs_dpmem
= 0;
2145 this_cmd
= firsttime
= TRUE
;
2146 next_cmd
= gdth_polling
? FALSE
:TRUE
;
2149 for (nscp
= pscp
= ha
->req_first
; nscp
; nscp
= (Scsi_Cmnd
*)nscp
->SCp
.ptr
) {
2150 struct gdth_cmndinfo
*nscp_cmndinfo
= gdth_cmnd_priv(nscp
);
2151 if (nscp
!= pscp
&& nscp
!= (Scsi_Cmnd
*)pscp
->SCp
.ptr
)
2152 pscp
= (Scsi_Cmnd
*)pscp
->SCp
.ptr
;
2153 if (!nscp_cmndinfo
->internal_command
) {
2154 b
= nscp
->device
->channel
;
2155 t
= nscp
->device
->id
;
2156 l
= nscp
->device
->lun
;
2157 if (nscp_cmndinfo
->priority
>= DEFAULT_PRI
) {
2158 if ((b
!= ha
->virt_bus
&& ha
->raw
[BUS_L2P(ha
,b
)].lock
) ||
2159 (b
== ha
->virt_bus
&& t
< MAX_HDRIVES
&& ha
->hdr
[t
].lock
))
2166 if (gdth_test_busy(ha
)) { /* controller busy ? */
2167 TRACE(("gdth_next() controller %d busy !\n", ha
->hanum
));
2168 if (!gdth_polling
) {
2169 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
2172 while (gdth_test_busy(ha
))
2178 if (!nscp_cmndinfo
->internal_command
) {
2179 if (nscp_cmndinfo
->phase
== -1) {
2180 nscp_cmndinfo
->phase
= CACHESERVICE
; /* default: cache svc. */
2181 if (nscp
->cmnd
[0] == TEST_UNIT_READY
) {
2182 TRACE2(("TEST_UNIT_READY Bus %d Id %d LUN %d\n",
2184 /* TEST_UNIT_READY -> set scan mode */
2185 if ((ha
->scan_mode
& 0x0f) == 0) {
2186 if (b
== 0 && t
== 0 && l
== 0) {
2188 TRACE2(("Scan mode: 0x%x\n", ha
->scan_mode
));
2190 } else if ((ha
->scan_mode
& 0x0f) == 1) {
2191 if (b
== 0 && ((t
== 0 && l
== 1) ||
2192 (t
== 1 && l
== 0))) {
2193 nscp_cmndinfo
->OpCode
= GDT_SCAN_START
;
2194 nscp_cmndinfo
->phase
= ((ha
->scan_mode
& 0x10 ? 1:0) << 8)
2196 ha
->scan_mode
= 0x12;
2197 TRACE2(("Scan mode: 0x%x (SCAN_START)\n",
2200 ha
->scan_mode
&= 0x10;
2201 TRACE2(("Scan mode: 0x%x\n", ha
->scan_mode
));
2203 } else if (ha
->scan_mode
== 0x12) {
2204 if (b
== ha
->bus_cnt
&& t
== ha
->tid_cnt
-1) {
2205 nscp_cmndinfo
->phase
= SCSIRAWSERVICE
;
2206 nscp_cmndinfo
->OpCode
= GDT_SCAN_END
;
2207 ha
->scan_mode
&= 0x10;
2208 TRACE2(("Scan mode: 0x%x (SCAN_END)\n",
2213 if (b
== ha
->virt_bus
&& nscp
->cmnd
[0] != INQUIRY
&&
2214 nscp
->cmnd
[0] != READ_CAPACITY
&& nscp
->cmnd
[0] != MODE_SENSE
&&
2215 (ha
->hdr
[t
].cluster_type
& CLUSTER_DRIVE
)) {
2216 /* always GDT_CLUST_INFO! */
2217 nscp_cmndinfo
->OpCode
= GDT_CLUST_INFO
;
2222 if (nscp_cmndinfo
->OpCode
!= -1) {
2223 if ((nscp_cmndinfo
->phase
& 0xff) == CACHESERVICE
) {
2224 if (!(cmd_index
=gdth_fill_cache_cmd(ha
, nscp
, t
)))
2227 } else if ((nscp_cmndinfo
->phase
& 0xff) == SCSIRAWSERVICE
) {
2228 if (!(cmd_index
=gdth_fill_raw_cmd(ha
, nscp
, BUS_L2P(ha
, b
))))
2232 memset((char*)nscp
->sense_buffer
,0,16);
2233 nscp
->sense_buffer
[0] = 0x70;
2234 nscp
->sense_buffer
[2] = NOT_READY
;
2235 nscp
->result
= (DID_OK
<< 16) | (CHECK_CONDITION
<< 1);
2236 if (!nscp_cmndinfo
->wait_for_completion
)
2237 nscp_cmndinfo
->wait_for_completion
++;
2239 gdth_scsi_done(nscp
);
2241 } else if (gdth_cmnd_priv(nscp
)->internal_command
) {
2242 if (!(cmd_index
=gdth_special_cmd(ha
, nscp
)))
2245 } else if (b
!= ha
->virt_bus
) {
2246 if (ha
->raw
[BUS_L2P(ha
,b
)].io_cnt
[t
] >= GDTH_MAX_RAW
||
2247 !(cmd_index
=gdth_fill_raw_cmd(ha
, nscp
, BUS_L2P(ha
, b
))))
2250 ha
->raw
[BUS_L2P(ha
,b
)].io_cnt
[t
]++;
2251 } else if (t
>= MAX_HDRIVES
|| !ha
->hdr
[t
].present
|| l
!= 0) {
2252 TRACE2(("Command 0x%x to bus %d id %d lun %d -> IGNORE\n",
2253 nscp
->cmnd
[0], b
, t
, l
));
2254 nscp
->result
= DID_BAD_TARGET
<< 16;
2255 if (!nscp_cmndinfo
->wait_for_completion
)
2256 nscp_cmndinfo
->wait_for_completion
++;
2258 gdth_scsi_done(nscp
);
2260 switch (nscp
->cmnd
[0]) {
2261 case TEST_UNIT_READY
:
2268 case SERVICE_ACTION_IN
:
2269 TRACE(("cache cmd %x/%x/%x/%x/%x/%x\n",nscp
->cmnd
[0],
2270 nscp
->cmnd
[1],nscp
->cmnd
[2],nscp
->cmnd
[3],
2271 nscp
->cmnd
[4],nscp
->cmnd
[5]));
2272 if (ha
->hdr
[t
].media_changed
&& nscp
->cmnd
[0] != INQUIRY
) {
2273 /* return UNIT_ATTENTION */
2274 TRACE2(("cmd 0x%x target %d: UNIT_ATTENTION\n",
2276 ha
->hdr
[t
].media_changed
= FALSE
;
2277 memset((char*)nscp
->sense_buffer
,0,16);
2278 nscp
->sense_buffer
[0] = 0x70;
2279 nscp
->sense_buffer
[2] = UNIT_ATTENTION
;
2280 nscp
->result
= (DID_OK
<< 16) | (CHECK_CONDITION
<< 1);
2281 if (!nscp_cmndinfo
->wait_for_completion
)
2282 nscp_cmndinfo
->wait_for_completion
++;
2284 gdth_scsi_done(nscp
);
2285 } else if (gdth_internal_cache_cmd(ha
, nscp
))
2286 gdth_scsi_done(nscp
);
2289 case ALLOW_MEDIUM_REMOVAL
:
2290 TRACE(("cache cmd %x/%x/%x/%x/%x/%x\n",nscp
->cmnd
[0],
2291 nscp
->cmnd
[1],nscp
->cmnd
[2],nscp
->cmnd
[3],
2292 nscp
->cmnd
[4],nscp
->cmnd
[5]));
2293 if ( (nscp
->cmnd
[4]&1) && !(ha
->hdr
[t
].devtype
&1) ) {
2294 TRACE(("Prevent r. nonremov. drive->do nothing\n"));
2295 nscp
->result
= DID_OK
<< 16;
2296 nscp
->sense_buffer
[0] = 0;
2297 if (!nscp_cmndinfo
->wait_for_completion
)
2298 nscp_cmndinfo
->wait_for_completion
++;
2300 gdth_scsi_done(nscp
);
2302 nscp
->cmnd
[3] = (ha
->hdr
[t
].devtype
&1) ? 1:0;
2303 TRACE(("Prevent/allow r. %d rem. drive %d\n",
2304 nscp
->cmnd
[4],nscp
->cmnd
[3]));
2305 if (!(cmd_index
=gdth_fill_cache_cmd(ha
, nscp
, t
)))
2312 TRACE2(("cache cmd %s\n",nscp
->cmnd
[0] == RESERVE
?
2313 "RESERVE" : "RELEASE"));
2314 if (!(cmd_index
=gdth_fill_cache_cmd(ha
, nscp
, t
)))
2324 if (ha
->hdr
[t
].media_changed
) {
2325 /* return UNIT_ATTENTION */
2326 TRACE2(("cmd 0x%x target %d: UNIT_ATTENTION\n",
2328 ha
->hdr
[t
].media_changed
= FALSE
;
2329 memset((char*)nscp
->sense_buffer
,0,16);
2330 nscp
->sense_buffer
[0] = 0x70;
2331 nscp
->sense_buffer
[2] = UNIT_ATTENTION
;
2332 nscp
->result
= (DID_OK
<< 16) | (CHECK_CONDITION
<< 1);
2333 if (!nscp_cmndinfo
->wait_for_completion
)
2334 nscp_cmndinfo
->wait_for_completion
++;
2336 gdth_scsi_done(nscp
);
2337 } else if (!(cmd_index
=gdth_fill_cache_cmd(ha
, nscp
, t
)))
2342 TRACE2(("cache cmd %x/%x/%x/%x/%x/%x unknown\n",nscp
->cmnd
[0],
2343 nscp
->cmnd
[1],nscp
->cmnd
[2],nscp
->cmnd
[3],
2344 nscp
->cmnd
[4],nscp
->cmnd
[5]));
2345 printk("GDT-HA %d: Unknown SCSI command 0x%x to cache service !\n",
2346 ha
->hanum
, nscp
->cmnd
[0]);
2347 nscp
->result
= DID_ABORT
<< 16;
2348 if (!nscp_cmndinfo
->wait_for_completion
)
2349 nscp_cmndinfo
->wait_for_completion
++;
2351 gdth_scsi_done(nscp
);
2358 if (nscp
== ha
->req_first
)
2359 ha
->req_first
= pscp
= (Scsi_Cmnd
*)nscp
->SCp
.ptr
;
2361 pscp
->SCp
.ptr
= nscp
->SCp
.ptr
;
2366 if (ha
->cmd_cnt
> 0) {
2367 gdth_release_event(ha
);
2371 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
2373 if (gdth_polling
&& ha
->cmd_cnt
> 0) {
2374 if (!gdth_wait(ha
, cmd_index
, POLL_TIMEOUT
))
2375 printk("GDT-HA %d: Command %d timed out !\n",
2376 ha
->hanum
, cmd_index
);
2381 * gdth_copy_internal_data() - copy to/from a buffer onto a scsi_cmnd's
2382 * buffers, kmap_atomic() as needed.
2384 static void gdth_copy_internal_data(gdth_ha_str
*ha
, Scsi_Cmnd
*scp
,
2385 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
2386 char *buffer
, ushort count
, int to_buffer
)
2388 char *buffer
, ushort count
)
2389 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
2391 ushort cpcount
,i
, max_sg
= gdth_sg_count(scp
);
2393 struct scatterlist
*sl
;
2396 cpcount
= min_t(ushort
, count
, gdth_bufflen(scp
));
2400 scsi_for_each_sg(scp
, sl
, max_sg
, i
) {
2401 unsigned long flags
;
2402 cpnow
= (ushort
)sl
->length
;
2403 TRACE(("copy_internal() now %d sum %d count %d %d\n",
2404 cpnow
, cpsum
, cpcount
, gdth_bufflen(scp
)));
2405 if (cpsum
+cpnow
> cpcount
)
2406 cpnow
= cpcount
- cpsum
;
2409 printk("GDT-HA %d: invalid sc/gt element in gdth_copy_internal_data()\n",
2413 local_irq_save(flags
);
2414 address
= kmap_atomic(sg_page(sl
), KM_BIO_SRC_IRQ
) + sl
->offset
;
2415 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
2417 memcpy(buffer
, address
, cpnow
);
2419 memcpy(address
, buffer
, cpnow
);
2421 memcpy(address
, buffer
, cpnow
);
2422 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
2423 flush_dcache_page(sg_page(sl
));
2424 kunmap_atomic(address
, KM_BIO_SRC_IRQ
);
2425 local_irq_restore(flags
);
2426 if (cpsum
== cpcount
)
2431 printk("GDT-HA %d: SCSI command with no buffers but data transfer expected!\n",
2437 static int gdth_internal_cache_cmd(gdth_ha_str
*ha
, Scsi_Cmnd
*scp
)
2441 gdth_rdcap_data rdc
;
2443 gdth_modep_data mpd
;
2444 struct gdth_cmndinfo
*cmndinfo
= gdth_cmnd_priv(scp
);
2446 t
= scp
->device
->id
;
2447 TRACE(("gdth_internal_cache_cmd() cmd 0x%x hdrive %d\n",
2450 scp
->result
= DID_OK
<< 16;
2451 scp
->sense_buffer
[0] = 0;
2453 switch (scp
->cmnd
[0]) {
2454 case TEST_UNIT_READY
:
2457 TRACE2(("Test/Verify/Start hdrive %d\n",t
));
2461 TRACE2(("Inquiry hdrive %d devtype %d\n",
2462 t
,ha
->hdr
[t
].devtype
));
2463 inq
.type_qual
= (ha
->hdr
[t
].devtype
&4) ? TYPE_ROM
:TYPE_DISK
;
2464 /* you can here set all disks to removable, if you want to do
2465 a flush using the ALLOW_MEDIUM_REMOVAL command */
2466 inq
.modif_rmb
= 0x00;
2467 if ((ha
->hdr
[t
].devtype
& 1) ||
2468 (ha
->hdr
[t
].cluster_type
& CLUSTER_DRIVE
))
2469 inq
.modif_rmb
= 0x80;
2473 strcpy(inq
.vendor
,ha
->oem_name
);
2474 sprintf(inq
.product
,"Host Drive #%02d",t
);
2475 strcpy(inq
.revision
," ");
2476 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
2477 gdth_copy_internal_data(ha
, scp
, (char*)&inq
, sizeof(gdth_inq_data
), 0);
2479 gdth_copy_internal_data(ha
, scp
, (char*)&inq
, sizeof(gdth_inq_data
));
2480 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
2484 TRACE2(("Request sense hdrive %d\n",t
));
2485 sd
.errorcode
= 0x70;
2490 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
2491 gdth_copy_internal_data(ha
, scp
, (char*)&sd
, sizeof(gdth_sense_data
), 0);
2493 gdth_copy_internal_data(ha
, scp
, (char*)&sd
, sizeof(gdth_sense_data
));
2494 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
2498 TRACE2(("Mode sense hdrive %d\n",t
));
2499 memset((char*)&mpd
,0,sizeof(gdth_modep_data
));
2500 mpd
.hd
.data_length
= sizeof(gdth_modep_data
);
2501 mpd
.hd
.dev_par
= (ha
->hdr
[t
].devtype
&2) ? 0x80:0;
2502 mpd
.hd
.bd_length
= sizeof(mpd
.bd
);
2503 mpd
.bd
.block_length
[0] = (SECTOR_SIZE
& 0x00ff0000) >> 16;
2504 mpd
.bd
.block_length
[1] = (SECTOR_SIZE
& 0x0000ff00) >> 8;
2505 mpd
.bd
.block_length
[2] = (SECTOR_SIZE
& 0x000000ff);
2506 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
2507 gdth_copy_internal_data(ha
, scp
, (char*)&mpd
, sizeof(gdth_modep_data
), 0);
2509 gdth_copy_internal_data(ha
, scp
, (char*)&mpd
, sizeof(gdth_modep_data
));
2510 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
2514 TRACE2(("Read capacity hdrive %d\n",t
));
2515 if (ha
->hdr
[t
].size
> (ulong64
)0xffffffff)
2516 rdc
.last_block_no
= 0xffffffff;
2518 rdc
.last_block_no
= cpu_to_be32(ha
->hdr
[t
].size
-1);
2519 rdc
.block_length
= cpu_to_be32(SECTOR_SIZE
);
2520 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
2521 gdth_copy_internal_data(ha
, scp
, (char*)&rdc
, sizeof(gdth_rdcap_data
), 0);
2523 gdth_copy_internal_data(ha
, scp
, (char*)&rdc
, sizeof(gdth_rdcap_data
));
2524 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
2527 case SERVICE_ACTION_IN
:
2528 if ((scp
->cmnd
[1] & 0x1f) == SAI_READ_CAPACITY_16
&&
2529 (ha
->cache_feat
& GDT_64BIT
)) {
2530 gdth_rdcap16_data rdc16
;
2532 TRACE2(("Read capacity (16) hdrive %d\n",t
));
2533 rdc16
.last_block_no
= cpu_to_be64(ha
->hdr
[t
].size
-1);
2534 rdc16
.block_length
= cpu_to_be32(SECTOR_SIZE
);
2535 gdth_copy_internal_data(ha
, scp
, (char*)&rdc16
,
2536 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
2537 sizeof(gdth_rdcap16_data
), 0);
2539 sizeof(gdth_rdcap16_data
));
2540 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
2542 scp
->result
= DID_ABORT
<< 16;
2547 TRACE2(("Internal cache cmd 0x%x unknown\n",scp
->cmnd
[0]));
2551 if (!cmndinfo
->wait_for_completion
)
2552 cmndinfo
->wait_for_completion
++;
2559 static int gdth_fill_cache_cmd(gdth_ha_str
*ha
, Scsi_Cmnd
*scp
, ushort hdrive
)
2561 register gdth_cmd_str
*cmdp
;
2562 struct gdth_cmndinfo
*cmndinfo
= gdth_cmnd_priv(scp
);
2563 ulong32 cnt
, blockcnt
;
2564 ulong64 no
, blockno
;
2565 int i
, cmd_index
, read_write
, sgcnt
, mode64
;
2568 TRACE(("gdth_fill_cache_cmd() cmd 0x%x cmdsize %d hdrive %d\n",
2569 scp
->cmnd
[0],scp
->cmd_len
,hdrive
));
2571 if (ha
->type
==GDT_EISA
&& ha
->cmd_cnt
>0)
2574 mode64
= (ha
->cache_feat
& GDT_64BIT
) ? TRUE
: FALSE
;
2575 /* test for READ_16, WRITE_16 if !mode64 ? ---
2576 not required, should not occur due to error return on
2579 cmdp
->Service
= CACHESERVICE
;
2580 cmdp
->RequestBuffer
= scp
;
2581 /* search free command index */
2582 if (!(cmd_index
=gdth_get_cmd_index(ha
))) {
2583 TRACE(("GDT: No free command index found\n"));
2586 /* if it's the first command, set command semaphore */
2587 if (ha
->cmd_cnt
== 0)
2592 if (cmndinfo
->OpCode
!= -1)
2593 cmdp
->OpCode
= cmndinfo
->OpCode
; /* special cache cmd. */
2594 else if (scp
->cmnd
[0] == RESERVE
)
2595 cmdp
->OpCode
= GDT_RESERVE_DRV
;
2596 else if (scp
->cmnd
[0] == RELEASE
)
2597 cmdp
->OpCode
= GDT_RELEASE_DRV
;
2598 else if (scp
->cmnd
[0] == ALLOW_MEDIUM_REMOVAL
) {
2599 if (scp
->cmnd
[4] & 1) /* prevent ? */
2600 cmdp
->OpCode
= GDT_MOUNT
;
2601 else if (scp
->cmnd
[3] & 1) /* removable drive ? */
2602 cmdp
->OpCode
= GDT_UNMOUNT
;
2604 cmdp
->OpCode
= GDT_FLUSH
;
2605 } else if (scp
->cmnd
[0] == WRITE_6
|| scp
->cmnd
[0] == WRITE_10
||
2606 scp
->cmnd
[0] == WRITE_12
|| scp
->cmnd
[0] == WRITE_16
2609 if (gdth_write_through
|| ((ha
->hdr
[hdrive
].rw_attribs
& 1) &&
2610 (ha
->cache_feat
& GDT_WR_THROUGH
)))
2611 cmdp
->OpCode
= GDT_WRITE_THR
;
2613 cmdp
->OpCode
= GDT_WRITE
;
2616 cmdp
->OpCode
= GDT_READ
;
2619 cmdp
->BoardNode
= LOCALBOARD
;
2621 cmdp
->u
.cache64
.DeviceNo
= hdrive
;
2622 cmdp
->u
.cache64
.BlockNo
= 1;
2623 cmdp
->u
.cache64
.sg_canz
= 0;
2625 cmdp
->u
.cache
.DeviceNo
= hdrive
;
2626 cmdp
->u
.cache
.BlockNo
= 1;
2627 cmdp
->u
.cache
.sg_canz
= 0;
2631 if (scp
->cmd_len
== 16) {
2632 memcpy(&no
, &scp
->cmnd
[2], sizeof(ulong64
));
2633 blockno
= be64_to_cpu(no
);
2634 memcpy(&cnt
, &scp
->cmnd
[10], sizeof(ulong32
));
2635 blockcnt
= be32_to_cpu(cnt
);
2636 } else if (scp
->cmd_len
== 10) {
2637 memcpy(&no
, &scp
->cmnd
[2], sizeof(ulong32
));
2638 blockno
= be32_to_cpu(no
);
2639 memcpy(&cnt
, &scp
->cmnd
[7], sizeof(ushort
));
2640 blockcnt
= be16_to_cpu(cnt
);
2642 memcpy(&no
, &scp
->cmnd
[0], sizeof(ulong32
));
2643 blockno
= be32_to_cpu(no
) & 0x001fffffUL
;
2644 blockcnt
= scp
->cmnd
[4]==0 ? 0x100 : scp
->cmnd
[4];
2647 cmdp
->u
.cache64
.BlockNo
= blockno
;
2648 cmdp
->u
.cache64
.BlockCnt
= blockcnt
;
2650 cmdp
->u
.cache
.BlockNo
= (ulong32
)blockno
;
2651 cmdp
->u
.cache
.BlockCnt
= blockcnt
;
2654 if (gdth_bufflen(scp
)) {
2655 cmndinfo
->dma_dir
= (read_write
== 1 ?
2656 PCI_DMA_TODEVICE
: PCI_DMA_FROMDEVICE
);
2657 sgcnt
= pci_map_sg(ha
->pdev
, gdth_sglist(scp
), gdth_sg_count(scp
),
2660 struct scatterlist
*sl
;
2662 cmdp
->u
.cache64
.DestAddr
= (ulong64
)-1;
2663 cmdp
->u
.cache64
.sg_canz
= sgcnt
;
2664 scsi_for_each_sg(scp
, sl
, sgcnt
, i
) {
2665 cmdp
->u
.cache64
.sg_lst
[i
].sg_ptr
= sg_dma_address(sl
);
2666 #ifdef GDTH_DMA_STATISTICS
2667 if (cmdp
->u
.cache64
.sg_lst
[i
].sg_ptr
> (ulong64
)0xffffffff)
2672 cmdp
->u
.cache64
.sg_lst
[i
].sg_len
= sg_dma_len(sl
);
2675 struct scatterlist
*sl
;
2677 cmdp
->u
.cache
.DestAddr
= 0xffffffff;
2678 cmdp
->u
.cache
.sg_canz
= sgcnt
;
2679 scsi_for_each_sg(scp
, sl
, sgcnt
, i
) {
2680 cmdp
->u
.cache
.sg_lst
[i
].sg_ptr
= sg_dma_address(sl
);
2681 #ifdef GDTH_DMA_STATISTICS
2684 cmdp
->u
.cache
.sg_lst
[i
].sg_len
= sg_dma_len(sl
);
2688 #ifdef GDTH_STATISTICS
2689 if (max_sg
< (ulong32
)sgcnt
) {
2690 max_sg
= (ulong32
)sgcnt
;
2691 TRACE3(("GDT: max_sg = %d\n",max_sg
));
2697 /* evaluate command size, check space */
2699 TRACE(("cache cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n",
2700 cmdp
->u
.cache64
.DestAddr
,cmdp
->u
.cache64
.sg_canz
,
2701 cmdp
->u
.cache64
.sg_lst
[0].sg_ptr
,
2702 cmdp
->u
.cache64
.sg_lst
[0].sg_len
));
2703 TRACE(("cache cmd: cmd %d blockno. %d, blockcnt %d\n",
2704 cmdp
->OpCode
,cmdp
->u
.cache64
.BlockNo
,cmdp
->u
.cache64
.BlockCnt
));
2705 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.cache64
.sg_lst
) +
2706 (ushort
)cmdp
->u
.cache64
.sg_canz
* sizeof(gdth_sg64_str
);
2708 TRACE(("cache cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n",
2709 cmdp
->u
.cache
.DestAddr
,cmdp
->u
.cache
.sg_canz
,
2710 cmdp
->u
.cache
.sg_lst
[0].sg_ptr
,
2711 cmdp
->u
.cache
.sg_lst
[0].sg_len
));
2712 TRACE(("cache cmd: cmd %d blockno. %d, blockcnt %d\n",
2713 cmdp
->OpCode
,cmdp
->u
.cache
.BlockNo
,cmdp
->u
.cache
.BlockCnt
));
2714 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.cache
.sg_lst
) +
2715 (ushort
)cmdp
->u
.cache
.sg_canz
* sizeof(gdth_sg_str
);
2717 if (ha
->cmd_len
& 3)
2718 ha
->cmd_len
+= (4 - (ha
->cmd_len
& 3));
2720 if (ha
->cmd_cnt
> 0) {
2721 if ((ha
->cmd_offs_dpmem
+ ha
->cmd_len
+ DPMEM_COMMAND_OFFSET
) >
2723 TRACE2(("gdth_fill_cache() DPMEM overflow\n"));
2724 ha
->cmd_tab
[cmd_index
-2].cmnd
= UNUSED_CMND
;
2730 gdth_copy_command(ha
);
2734 static int gdth_fill_raw_cmd(gdth_ha_str
*ha
, Scsi_Cmnd
*scp
, unchar b
)
2736 register gdth_cmd_str
*cmdp
;
2738 dma_addr_t sense_paddr
;
2739 int cmd_index
, sgcnt
, mode64
;
2743 struct gdth_cmndinfo
*cmndinfo
;
2745 t
= scp
->device
->id
;
2746 l
= scp
->device
->lun
;
2748 TRACE(("gdth_fill_raw_cmd() cmd 0x%x bus %d ID %d LUN %d\n",
2749 scp
->cmnd
[0],b
,t
,l
));
2751 if (ha
->type
==GDT_EISA
&& ha
->cmd_cnt
>0)
2754 mode64
= (ha
->raw_feat
& GDT_64BIT
) ? TRUE
: FALSE
;
2756 cmdp
->Service
= SCSIRAWSERVICE
;
2757 cmdp
->RequestBuffer
= scp
;
2758 /* search free command index */
2759 if (!(cmd_index
=gdth_get_cmd_index(ha
))) {
2760 TRACE(("GDT: No free command index found\n"));
2763 /* if it's the first command, set command semaphore */
2764 if (ha
->cmd_cnt
== 0)
2767 cmndinfo
= gdth_cmnd_priv(scp
);
2769 if (cmndinfo
->OpCode
!= -1) {
2770 cmdp
->OpCode
= cmndinfo
->OpCode
; /* special raw cmd. */
2771 cmdp
->BoardNode
= LOCALBOARD
;
2773 cmdp
->u
.raw64
.direction
= (cmndinfo
->phase
>> 8);
2774 TRACE2(("special raw cmd 0x%x param 0x%x\n",
2775 cmdp
->OpCode
, cmdp
->u
.raw64
.direction
));
2776 /* evaluate command size */
2777 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.raw64
.sg_lst
);
2779 cmdp
->u
.raw
.direction
= (cmndinfo
->phase
>> 8);
2780 TRACE2(("special raw cmd 0x%x param 0x%x\n",
2781 cmdp
->OpCode
, cmdp
->u
.raw
.direction
));
2782 /* evaluate command size */
2783 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.raw
.sg_lst
);
2787 page
= virt_to_page(scp
->sense_buffer
);
2788 offset
= (ulong
)scp
->sense_buffer
& ~PAGE_MASK
;
2789 sense_paddr
= pci_map_page(ha
->pdev
,page
,offset
,
2790 16,PCI_DMA_FROMDEVICE
);
2792 cmndinfo
->sense_paddr
= sense_paddr
;
2793 cmdp
->OpCode
= GDT_WRITE
; /* always */
2794 cmdp
->BoardNode
= LOCALBOARD
;
2796 cmdp
->u
.raw64
.reserved
= 0;
2797 cmdp
->u
.raw64
.mdisc_time
= 0;
2798 cmdp
->u
.raw64
.mcon_time
= 0;
2799 cmdp
->u
.raw64
.clen
= scp
->cmd_len
;
2800 cmdp
->u
.raw64
.target
= t
;
2801 cmdp
->u
.raw64
.lun
= l
;
2802 cmdp
->u
.raw64
.bus
= b
;
2803 cmdp
->u
.raw64
.priority
= 0;
2804 cmdp
->u
.raw64
.sdlen
= gdth_bufflen(scp
);
2805 cmdp
->u
.raw64
.sense_len
= 16;
2806 cmdp
->u
.raw64
.sense_data
= sense_paddr
;
2807 cmdp
->u
.raw64
.direction
=
2808 gdth_direction_tab
[scp
->cmnd
[0]]==DOU
? GDTH_DATA_OUT
:GDTH_DATA_IN
;
2809 memcpy(cmdp
->u
.raw64
.cmd
,scp
->cmnd
,16);
2810 cmdp
->u
.raw64
.sg_ranz
= 0;
2812 cmdp
->u
.raw
.reserved
= 0;
2813 cmdp
->u
.raw
.mdisc_time
= 0;
2814 cmdp
->u
.raw
.mcon_time
= 0;
2815 cmdp
->u
.raw
.clen
= scp
->cmd_len
;
2816 cmdp
->u
.raw
.target
= t
;
2817 cmdp
->u
.raw
.lun
= l
;
2818 cmdp
->u
.raw
.bus
= b
;
2819 cmdp
->u
.raw
.priority
= 0;
2820 cmdp
->u
.raw
.link_p
= 0;
2821 cmdp
->u
.raw
.sdlen
= gdth_bufflen(scp
);
2822 cmdp
->u
.raw
.sense_len
= 16;
2823 cmdp
->u
.raw
.sense_data
= sense_paddr
;
2824 cmdp
->u
.raw
.direction
=
2825 gdth_direction_tab
[scp
->cmnd
[0]]==DOU
? GDTH_DATA_OUT
:GDTH_DATA_IN
;
2826 memcpy(cmdp
->u
.raw
.cmd
,scp
->cmnd
,12);
2827 cmdp
->u
.raw
.sg_ranz
= 0;
2830 if (gdth_bufflen(scp
)) {
2831 cmndinfo
->dma_dir
= PCI_DMA_BIDIRECTIONAL
;
2832 sgcnt
= pci_map_sg(ha
->pdev
, gdth_sglist(scp
), gdth_sg_count(scp
),
2835 struct scatterlist
*sl
;
2837 cmdp
->u
.raw64
.sdata
= (ulong64
)-1;
2838 cmdp
->u
.raw64
.sg_ranz
= sgcnt
;
2839 scsi_for_each_sg(scp
, sl
, sgcnt
, i
) {
2840 cmdp
->u
.raw64
.sg_lst
[i
].sg_ptr
= sg_dma_address(sl
);
2841 #ifdef GDTH_DMA_STATISTICS
2842 if (cmdp
->u
.raw64
.sg_lst
[i
].sg_ptr
> (ulong64
)0xffffffff)
2847 cmdp
->u
.raw64
.sg_lst
[i
].sg_len
= sg_dma_len(sl
);
2850 struct scatterlist
*sl
;
2852 cmdp
->u
.raw
.sdata
= 0xffffffff;
2853 cmdp
->u
.raw
.sg_ranz
= sgcnt
;
2854 scsi_for_each_sg(scp
, sl
, sgcnt
, i
) {
2855 cmdp
->u
.raw
.sg_lst
[i
].sg_ptr
= sg_dma_address(sl
);
2856 #ifdef GDTH_DMA_STATISTICS
2859 cmdp
->u
.raw
.sg_lst
[i
].sg_len
= sg_dma_len(sl
);
2863 #ifdef GDTH_STATISTICS
2864 if (max_sg
< sgcnt
) {
2866 TRACE3(("GDT: max_sg = %d\n",sgcnt
));
2872 TRACE(("raw cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n",
2873 cmdp
->u
.raw64
.sdata
,cmdp
->u
.raw64
.sg_ranz
,
2874 cmdp
->u
.raw64
.sg_lst
[0].sg_ptr
,
2875 cmdp
->u
.raw64
.sg_lst
[0].sg_len
));
2876 /* evaluate command size */
2877 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.raw64
.sg_lst
) +
2878 (ushort
)cmdp
->u
.raw64
.sg_ranz
* sizeof(gdth_sg64_str
);
2880 TRACE(("raw cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n",
2881 cmdp
->u
.raw
.sdata
,cmdp
->u
.raw
.sg_ranz
,
2882 cmdp
->u
.raw
.sg_lst
[0].sg_ptr
,
2883 cmdp
->u
.raw
.sg_lst
[0].sg_len
));
2884 /* evaluate command size */
2885 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.raw
.sg_lst
) +
2886 (ushort
)cmdp
->u
.raw
.sg_ranz
* sizeof(gdth_sg_str
);
2890 if (ha
->cmd_len
& 3)
2891 ha
->cmd_len
+= (4 - (ha
->cmd_len
& 3));
2893 if (ha
->cmd_cnt
> 0) {
2894 if ((ha
->cmd_offs_dpmem
+ ha
->cmd_len
+ DPMEM_COMMAND_OFFSET
) >
2896 TRACE2(("gdth_fill_raw() DPMEM overflow\n"));
2897 ha
->cmd_tab
[cmd_index
-2].cmnd
= UNUSED_CMND
;
2903 gdth_copy_command(ha
);
2907 static int gdth_special_cmd(gdth_ha_str
*ha
, Scsi_Cmnd
*scp
)
2909 register gdth_cmd_str
*cmdp
;
2910 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
2912 struct gdth_cmndinfo
*cmndinfo
= gdth_cmnd_priv(scp
);
2913 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
2917 TRACE2(("gdth_special_cmd(): "));
2919 if (ha
->type
==GDT_EISA
&& ha
->cmd_cnt
>0)
2922 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
2923 gdth_copy_internal_data(ha
, scp
, (char *)cmdp
, sizeof(gdth_cmd_str
), 1);
2925 *cmdp
= *cmndinfo
->internal_cmd_str
;
2926 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
2927 cmdp
->RequestBuffer
= scp
;
2929 /* search free command index */
2930 if (!(cmd_index
=gdth_get_cmd_index(ha
))) {
2931 TRACE(("GDT: No free command index found\n"));
2935 /* if it's the first command, set command semaphore */
2936 if (ha
->cmd_cnt
== 0)
2939 /* evaluate command size, check space */
2940 if (cmdp
->OpCode
== GDT_IOCTL
) {
2941 TRACE2(("IOCTL\n"));
2943 GDTOFFSOF(gdth_cmd_str
,u
.ioctl
.p_param
) + sizeof(ulong64
);
2944 } else if (cmdp
->Service
== CACHESERVICE
) {
2945 TRACE2(("cache command %d\n",cmdp
->OpCode
));
2946 if (ha
->cache_feat
& GDT_64BIT
)
2948 GDTOFFSOF(gdth_cmd_str
,u
.cache64
.sg_lst
) + sizeof(gdth_sg64_str
);
2951 GDTOFFSOF(gdth_cmd_str
,u
.cache
.sg_lst
) + sizeof(gdth_sg_str
);
2952 } else if (cmdp
->Service
== SCSIRAWSERVICE
) {
2953 TRACE2(("raw command %d\n",cmdp
->OpCode
));
2954 if (ha
->raw_feat
& GDT_64BIT
)
2956 GDTOFFSOF(gdth_cmd_str
,u
.raw64
.sg_lst
) + sizeof(gdth_sg64_str
);
2959 GDTOFFSOF(gdth_cmd_str
,u
.raw
.sg_lst
) + sizeof(gdth_sg_str
);
2962 if (ha
->cmd_len
& 3)
2963 ha
->cmd_len
+= (4 - (ha
->cmd_len
& 3));
2965 if (ha
->cmd_cnt
> 0) {
2966 if ((ha
->cmd_offs_dpmem
+ ha
->cmd_len
+ DPMEM_COMMAND_OFFSET
) >
2968 TRACE2(("gdth_special_cmd() DPMEM overflow\n"));
2969 ha
->cmd_tab
[cmd_index
-2].cmnd
= UNUSED_CMND
;
2975 gdth_copy_command(ha
);
2980 /* Controller event handling functions */
2981 static gdth_evt_str
*gdth_store_event(gdth_ha_str
*ha
, ushort source
,
2982 ushort idx
, gdth_evt_data
*evt
)
2987 /* no GDTH_LOCK_HA() ! */
2988 TRACE2(("gdth_store_event() source %d idx %d\n", source
, idx
));
2989 if (source
== 0) /* no source -> no event */
2992 if (ebuffer
[elastidx
].event_source
== source
&&
2993 ebuffer
[elastidx
].event_idx
== idx
&&
2994 ((evt
->size
!= 0 && ebuffer
[elastidx
].event_data
.size
!= 0 &&
2995 !memcmp((char *)&ebuffer
[elastidx
].event_data
.eu
,
2996 (char *)&evt
->eu
, evt
->size
)) ||
2997 (evt
->size
== 0 && ebuffer
[elastidx
].event_data
.size
== 0 &&
2998 !strcmp((char *)&ebuffer
[elastidx
].event_data
.event_string
,
2999 (char *)&evt
->event_string
)))) {
3000 e
= &ebuffer
[elastidx
];
3001 do_gettimeofday(&tv
);
3002 e
->last_stamp
= tv
.tv_sec
;
3005 if (ebuffer
[elastidx
].event_source
!= 0) { /* entry not free ? */
3007 if (elastidx
== MAX_EVENTS
)
3009 if (elastidx
== eoldidx
) { /* reached mark ? */
3011 if (eoldidx
== MAX_EVENTS
)
3015 e
= &ebuffer
[elastidx
];
3016 e
->event_source
= source
;
3018 do_gettimeofday(&tv
);
3019 e
->first_stamp
= e
->last_stamp
= tv
.tv_sec
;
3021 e
->event_data
= *evt
;
3027 static int gdth_read_event(gdth_ha_str
*ha
, int handle
, gdth_evt_str
*estr
)
3033 TRACE2(("gdth_read_event() handle %d\n", handle
));
3034 spin_lock_irqsave(&ha
->smp_lock
, flags
);
3039 estr
->event_source
= 0;
3041 if (eindex
>= MAX_EVENTS
) {
3042 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
3045 e
= &ebuffer
[eindex
];
3046 if (e
->event_source
!= 0) {
3047 if (eindex
!= elastidx
) {
3048 if (++eindex
== MAX_EVENTS
)
3053 memcpy(estr
, e
, sizeof(gdth_evt_str
));
3055 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
3059 static void gdth_readapp_event(gdth_ha_str
*ha
,
3060 unchar application
, gdth_evt_str
*estr
)
3065 unchar found
= FALSE
;
3067 TRACE2(("gdth_readapp_event() app. %d\n", application
));
3068 spin_lock_irqsave(&ha
->smp_lock
, flags
);
3071 e
= &ebuffer
[eindex
];
3072 if (e
->event_source
== 0)
3074 if ((e
->application
& application
) == 0) {
3075 e
->application
|= application
;
3079 if (eindex
== elastidx
)
3081 if (++eindex
== MAX_EVENTS
)
3085 memcpy(estr
, e
, sizeof(gdth_evt_str
));
3087 estr
->event_source
= 0;
3088 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
3091 static void gdth_clear_events(void)
3093 TRACE(("gdth_clear_events()"));
3095 eoldidx
= elastidx
= 0;
3096 ebuffer
[0].event_source
= 0;
3100 /* SCSI interface functions */
3102 static irqreturn_t
__gdth_interrupt(gdth_ha_str
*ha
,
3103 int gdth_from_wait
, int* pIndex
)
3105 gdt6m_dpram_str __iomem
*dp6m_ptr
= NULL
;
3106 gdt6_dpram_str __iomem
*dp6_ptr
;
3107 gdt2_dpram_str __iomem
*dp2_ptr
;
3114 int coalesced
= FALSE
;
3116 gdth_coal_status
*pcs
= NULL
;
3117 int act_int_coal
= 0;
3120 TRACE(("gdth_interrupt() IRQ %d\n", ha
->irq
));
3122 /* if polling and not from gdth_wait() -> return */
3124 if (!gdth_from_wait
) {
3130 spin_lock_irqsave(&ha
->smp_lock
, flags
);
3132 /* search controller */
3133 IStatus
= gdth_get_status(ha
);
3135 /* spurious interrupt */
3137 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
3141 #ifdef GDTH_STATISTICS
3146 /* See if the fw is returning coalesced status */
3147 if (IStatus
== COALINDEX
) {
3148 /* Coalesced status. Setup the initial status
3149 buffer pointer and flags */
3150 pcs
= ha
->coal_stat
;
3157 /* For coalesced requests all status
3158 information is found in the status buffer */
3159 IStatus
= (unchar
)(pcs
->status
& 0xff);
3163 if (ha
->type
== GDT_EISA
) {
3164 if (IStatus
& 0x80) { /* error flag */
3166 ha
->status
= inw(ha
->bmic
+ MAILBOXREG
+8);
3167 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus
,ha
->status
));
3168 } else /* no error */
3170 ha
->info
= inl(ha
->bmic
+ MAILBOXREG
+12);
3171 ha
->service
= inw(ha
->bmic
+ MAILBOXREG
+10);
3172 ha
->info2
= inl(ha
->bmic
+ MAILBOXREG
+4);
3174 outb(0xff, ha
->bmic
+ EDOORREG
); /* acknowledge interrupt */
3175 outb(0x00, ha
->bmic
+ SEMA1REG
); /* reset status semaphore */
3176 } else if (ha
->type
== GDT_ISA
) {
3178 if (IStatus
& 0x80) { /* error flag */
3180 ha
->status
= readw(&dp2_ptr
->u
.ic
.Status
);
3181 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus
,ha
->status
));
3182 } else /* no error */
3184 ha
->info
= readl(&dp2_ptr
->u
.ic
.Info
[0]);
3185 ha
->service
= readw(&dp2_ptr
->u
.ic
.Service
);
3186 ha
->info2
= readl(&dp2_ptr
->u
.ic
.Info
[1]);
3188 writeb(0xff, &dp2_ptr
->io
.irqdel
); /* acknowledge interrupt */
3189 writeb(0, &dp2_ptr
->u
.ic
.Cmd_Index
);/* reset command index */
3190 writeb(0, &dp2_ptr
->io
.Sema1
); /* reset status semaphore */
3191 } else if (ha
->type
== GDT_PCI
) {
3193 if (IStatus
& 0x80) { /* error flag */
3195 ha
->status
= readw(&dp6_ptr
->u
.ic
.Status
);
3196 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus
,ha
->status
));
3197 } else /* no error */
3199 ha
->info
= readl(&dp6_ptr
->u
.ic
.Info
[0]);
3200 ha
->service
= readw(&dp6_ptr
->u
.ic
.Service
);
3201 ha
->info2
= readl(&dp6_ptr
->u
.ic
.Info
[1]);
3203 writeb(0xff, &dp6_ptr
->io
.irqdel
); /* acknowledge interrupt */
3204 writeb(0, &dp6_ptr
->u
.ic
.Cmd_Index
);/* reset command index */
3205 writeb(0, &dp6_ptr
->io
.Sema1
); /* reset status semaphore */
3206 } else if (ha
->type
== GDT_PCINEW
) {
3207 if (IStatus
& 0x80) { /* error flag */
3209 ha
->status
= inw(PTR2USHORT(&ha
->plx
->status
));
3210 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus
,ha
->status
));
3213 ha
->info
= inl(PTR2USHORT(&ha
->plx
->info
[0]));
3214 ha
->service
= inw(PTR2USHORT(&ha
->plx
->service
));
3215 ha
->info2
= inl(PTR2USHORT(&ha
->plx
->info
[1]));
3217 outb(0xff, PTR2USHORT(&ha
->plx
->edoor_reg
));
3218 outb(0x00, PTR2USHORT(&ha
->plx
->sema1_reg
));
3219 } else if (ha
->type
== GDT_PCIMPR
) {
3221 if (IStatus
& 0x80) { /* error flag */
3225 ha
->status
= pcs
->ext_status
& 0xffff;
3228 ha
->status
= readw(&dp6m_ptr
->i960r
.status
);
3229 TRACE2(("gdth_interrupt() error %d/%d\n",IStatus
,ha
->status
));
3230 } else /* no error */
3233 /* get information */
3235 ha
->info
= pcs
->info0
;
3236 ha
->info2
= pcs
->info1
;
3237 ha
->service
= (pcs
->ext_status
>> 16) & 0xffff;
3241 ha
->info
= readl(&dp6m_ptr
->i960r
.info
[0]);
3242 ha
->service
= readw(&dp6m_ptr
->i960r
.service
);
3243 ha
->info2
= readl(&dp6m_ptr
->i960r
.info
[1]);
3246 if (IStatus
== ASYNCINDEX
) {
3247 if (ha
->service
!= SCREENSERVICE
&&
3248 (ha
->fw_vers
& 0xff) >= 0x1a) {
3249 ha
->dvr
.severity
= readb
3250 (&((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.severity
);
3251 for (i
= 0; i
< 256; ++i
) {
3252 ha
->dvr
.event_string
[i
] = readb
3253 (&((gdt6m_dpram_str __iomem
*)ha
->brd
)->i960r
.evt_str
[i
]);
3254 if (ha
->dvr
.event_string
[i
] == 0)
3260 /* Make sure that non coalesced interrupts get cleared
3261 before being handled by gdth_async_event/gdth_sync_event */
3265 writeb(0xff, &dp6m_ptr
->i960r
.edoor_reg
);
3266 writeb(0, &dp6m_ptr
->i960r
.sema1_reg
);
3269 TRACE2(("gdth_interrupt() unknown controller type\n"));
3271 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
3275 TRACE(("gdth_interrupt() index %d stat %d info %d\n",
3276 IStatus
,ha
->status
,ha
->info
));
3278 if (gdth_from_wait
) {
3279 *pIndex
= (int)IStatus
;
3282 if (IStatus
== ASYNCINDEX
) {
3283 TRACE2(("gdth_interrupt() async. event\n"));
3284 gdth_async_event(ha
);
3286 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
3291 if (IStatus
== SPEZINDEX
) {
3292 TRACE2(("Service unknown or not initialized !\n"));
3293 ha
->dvr
.size
= sizeof(ha
->dvr
.eu
.driver
);
3294 ha
->dvr
.eu
.driver
.ionode
= ha
->hanum
;
3295 gdth_store_event(ha
, ES_DRIVER
, 4, &ha
->dvr
);
3297 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
3300 scp
= ha
->cmd_tab
[IStatus
-2].cmnd
;
3301 Service
= ha
->cmd_tab
[IStatus
-2].service
;
3302 ha
->cmd_tab
[IStatus
-2].cmnd
= UNUSED_CMND
;
3303 if (scp
== UNUSED_CMND
) {
3304 TRACE2(("gdth_interrupt() index to unused command (%d)\n",IStatus
));
3305 ha
->dvr
.size
= sizeof(ha
->dvr
.eu
.driver
);
3306 ha
->dvr
.eu
.driver
.ionode
= ha
->hanum
;
3307 ha
->dvr
.eu
.driver
.index
= IStatus
;
3308 gdth_store_event(ha
, ES_DRIVER
, 1, &ha
->dvr
);
3310 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
3313 if (scp
== INTERNAL_CMND
) {
3314 TRACE(("gdth_interrupt() answer to internal command\n"));
3316 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
3320 TRACE(("gdth_interrupt() sync. status\n"));
3321 rval
= gdth_sync_event(ha
,Service
,IStatus
,scp
);
3323 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
3325 gdth_putq(ha
, scp
, gdth_cmnd_priv(scp
)->priority
);
3326 } else if (rval
== 1) {
3327 gdth_scsi_done(scp
);
3332 /* go to the next status in the status buffer */
3334 #ifdef GDTH_STATISTICS
3336 if (act_int_coal
> max_int_coal
) {
3337 max_int_coal
= act_int_coal
;
3338 printk("GDT: max_int_coal = %d\n",(ushort
)max_int_coal
);
3341 /* see if there is another status */
3342 if (pcs
->status
== 0)
3343 /* Stop the coalesce loop */
3348 /* coalescing only for new GDT_PCIMPR controllers available */
3349 if (ha
->type
== GDT_PCIMPR
&& coalesced
) {
3350 writeb(0xff, &dp6m_ptr
->i960r
.edoor_reg
);
3351 writeb(0, &dp6m_ptr
->i960r
.sema1_reg
);
3359 static irqreturn_t
gdth_interrupt(int irq
, void *dev_id
)
3361 gdth_ha_str
*ha
= dev_id
;
3363 return __gdth_interrupt(ha
, false, NULL
);
3366 static int gdth_sync_event(gdth_ha_str
*ha
, int service
, unchar index
,
3372 struct gdth_cmndinfo
*cmndinfo
= gdth_cmnd_priv(scp
);
3375 TRACE(("gdth_sync_event() serv %d status %d\n",
3376 service
,ha
->status
));
3378 if (service
== SCREENSERVICE
) {
3380 TRACE(("len: %d, answer: %d, ext: %d, alen: %d\n",
3381 msg
->msg_len
,msg
->msg_answer
,msg
->msg_ext
,msg
->msg_alen
));
3382 if (msg
->msg_len
> MSGLEN
+1)
3383 msg
->msg_len
= MSGLEN
+1;
3385 if (!(msg
->msg_answer
&& msg
->msg_ext
)) {
3386 msg
->msg_text
[msg
->msg_len
] = '\0';
3387 printk("%s",msg
->msg_text
);
3390 if (msg
->msg_ext
&& !msg
->msg_answer
) {
3391 while (gdth_test_busy(ha
))
3393 cmdp
->Service
= SCREENSERVICE
;
3394 cmdp
->RequestBuffer
= SCREEN_CMND
;
3395 gdth_get_cmd_index(ha
);
3397 cmdp
->OpCode
= GDT_READ
;
3398 cmdp
->BoardNode
= LOCALBOARD
;
3399 cmdp
->u
.screen
.reserved
= 0;
3400 cmdp
->u
.screen
.su
.msg
.msg_handle
= msg
->msg_handle
;
3401 cmdp
->u
.screen
.su
.msg
.msg_addr
= ha
->msg_phys
;
3402 ha
->cmd_offs_dpmem
= 0;
3403 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.screen
.su
.msg
.msg_addr
)
3406 gdth_copy_command(ha
);
3407 gdth_release_event(ha
);
3411 if (msg
->msg_answer
&& msg
->msg_alen
) {
3412 /* default answers (getchar() not possible) */
3413 if (msg
->msg_alen
== 1) {
3416 msg
->msg_text
[0] = 0;
3420 msg
->msg_text
[0] = 1;
3421 msg
->msg_text
[1] = 0;
3424 msg
->msg_answer
= 0;
3425 while (gdth_test_busy(ha
))
3427 cmdp
->Service
= SCREENSERVICE
;
3428 cmdp
->RequestBuffer
= SCREEN_CMND
;
3429 gdth_get_cmd_index(ha
);
3431 cmdp
->OpCode
= GDT_WRITE
;
3432 cmdp
->BoardNode
= LOCALBOARD
;
3433 cmdp
->u
.screen
.reserved
= 0;
3434 cmdp
->u
.screen
.su
.msg
.msg_handle
= msg
->msg_handle
;
3435 cmdp
->u
.screen
.su
.msg
.msg_addr
= ha
->msg_phys
;
3436 ha
->cmd_offs_dpmem
= 0;
3437 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.screen
.su
.msg
.msg_addr
)
3440 gdth_copy_command(ha
);
3441 gdth_release_event(ha
);
3447 b
= scp
->device
->channel
;
3448 t
= scp
->device
->id
;
3449 if (cmndinfo
->OpCode
== -1 && b
!= ha
->virt_bus
) {
3450 ha
->raw
[BUS_L2P(ha
,b
)].io_cnt
[t
]--;
3452 /* cache or raw service */
3453 if (ha
->status
== S_BSY
) {
3454 TRACE2(("Controller busy -> retry !\n"));
3455 if (cmndinfo
->OpCode
== GDT_MOUNT
)
3456 cmndinfo
->OpCode
= GDT_CLUST_INFO
;
3460 if (gdth_bufflen(scp
))
3461 pci_unmap_sg(ha
->pdev
, gdth_sglist(scp
), gdth_sg_count(scp
),
3464 if (cmndinfo
->sense_paddr
)
3465 pci_unmap_page(ha
->pdev
, cmndinfo
->sense_paddr
, 16,
3466 PCI_DMA_FROMDEVICE
);
3468 if (ha
->status
== S_OK
) {
3469 cmndinfo
->status
= S_OK
;
3470 cmndinfo
->info
= ha
->info
;
3471 if (cmndinfo
->OpCode
!= -1) {
3472 TRACE2(("gdth_sync_event(): special cmd 0x%x OK\n",
3474 /* special commands GDT_CLUST_INFO/GDT_MOUNT ? */
3475 if (cmndinfo
->OpCode
== GDT_CLUST_INFO
) {
3476 ha
->hdr
[t
].cluster_type
= (unchar
)ha
->info
;
3477 if (!(ha
->hdr
[t
].cluster_type
&
3479 /* NOT MOUNTED -> MOUNT */
3480 cmndinfo
->OpCode
= GDT_MOUNT
;
3481 if (ha
->hdr
[t
].cluster_type
&
3483 /* cluster drive RESERVED (on the other node) */
3484 cmndinfo
->phase
= -2; /* reservation conflict */
3487 cmndinfo
->OpCode
= -1;
3490 if (cmndinfo
->OpCode
== GDT_MOUNT
) {
3491 ha
->hdr
[t
].cluster_type
|= CLUSTER_MOUNTED
;
3492 ha
->hdr
[t
].media_changed
= TRUE
;
3493 } else if (cmndinfo
->OpCode
== GDT_UNMOUNT
) {
3494 ha
->hdr
[t
].cluster_type
&= ~CLUSTER_MOUNTED
;
3495 ha
->hdr
[t
].media_changed
= TRUE
;
3497 cmndinfo
->OpCode
= -1;
3500 cmndinfo
->priority
= HIGH_PRI
;
3503 /* RESERVE/RELEASE ? */
3504 if (scp
->cmnd
[0] == RESERVE
) {
3505 ha
->hdr
[t
].cluster_type
|= CLUSTER_RESERVED
;
3506 } else if (scp
->cmnd
[0] == RELEASE
) {
3507 ha
->hdr
[t
].cluster_type
&= ~CLUSTER_RESERVED
;
3509 scp
->result
= DID_OK
<< 16;
3510 scp
->sense_buffer
[0] = 0;
3513 cmndinfo
->status
= ha
->status
;
3514 cmndinfo
->info
= ha
->info
;
3516 if (cmndinfo
->OpCode
!= -1) {
3517 TRACE2(("gdth_sync_event(): special cmd 0x%x error 0x%x\n",
3518 cmndinfo
->OpCode
, ha
->status
));
3519 if (cmndinfo
->OpCode
== GDT_SCAN_START
||
3520 cmndinfo
->OpCode
== GDT_SCAN_END
) {
3521 cmndinfo
->OpCode
= -1;
3523 cmndinfo
->priority
= HIGH_PRI
;
3526 memset((char*)scp
->sense_buffer
,0,16);
3527 scp
->sense_buffer
[0] = 0x70;
3528 scp
->sense_buffer
[2] = NOT_READY
;
3529 scp
->result
= (DID_OK
<< 16) | (CHECK_CONDITION
<< 1);
3530 } else if (service
== CACHESERVICE
) {
3531 if (ha
->status
== S_CACHE_UNKNOWN
&&
3532 (ha
->hdr
[t
].cluster_type
&
3533 CLUSTER_RESERVE_STATE
) == CLUSTER_RESERVE_STATE
) {
3534 /* bus reset -> force GDT_CLUST_INFO */
3535 ha
->hdr
[t
].cluster_type
&= ~CLUSTER_RESERVED
;
3537 memset((char*)scp
->sense_buffer
,0,16);
3538 if (ha
->status
== (ushort
)S_CACHE_RESERV
) {
3539 scp
->result
= (DID_OK
<< 16) | (RESERVATION_CONFLICT
<< 1);
3541 scp
->sense_buffer
[0] = 0x70;
3542 scp
->sense_buffer
[2] = NOT_READY
;
3543 scp
->result
= (DID_OK
<< 16) | (CHECK_CONDITION
<< 1);
3545 if (!cmndinfo
->internal_command
) {
3546 ha
->dvr
.size
= sizeof(ha
->dvr
.eu
.sync
);
3547 ha
->dvr
.eu
.sync
.ionode
= ha
->hanum
;
3548 ha
->dvr
.eu
.sync
.service
= service
;
3549 ha
->dvr
.eu
.sync
.status
= ha
->status
;
3550 ha
->dvr
.eu
.sync
.info
= ha
->info
;
3551 ha
->dvr
.eu
.sync
.hostdrive
= t
;
3552 if (ha
->status
>= 0x8000)
3553 gdth_store_event(ha
, ES_SYNC
, 0, &ha
->dvr
);
3555 gdth_store_event(ha
, ES_SYNC
, service
, &ha
->dvr
);
3558 /* sense buffer filled from controller firmware (DMA) */
3559 if (ha
->status
!= S_RAW_SCSI
|| ha
->info
>= 0x100) {
3560 scp
->result
= DID_BAD_TARGET
<< 16;
3562 scp
->result
= (DID_OK
<< 16) | ha
->info
;
3566 if (!cmndinfo
->wait_for_completion
)
3567 cmndinfo
->wait_for_completion
++;
3575 static char *async_cache_tab
[] = {
3576 /* 0*/ "\011\000\002\002\002\004\002\006\004"
3577 "GDT HA %u, service %u, async. status %u/%lu unknown",
3578 /* 1*/ "\011\000\002\002\002\004\002\006\004"
3579 "GDT HA %u, service %u, async. status %u/%lu unknown",
3580 /* 2*/ "\005\000\002\006\004"
3581 "GDT HA %u, Host Drive %lu not ready",
3582 /* 3*/ "\005\000\002\006\004"
3583 "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",
3584 /* 4*/ "\005\000\002\006\004"
3585 "GDT HA %u, mirror update on Host Drive %lu failed",
3586 /* 5*/ "\005\000\002\006\004"
3587 "GDT HA %u, Mirror Drive %lu failed",
3588 /* 6*/ "\005\000\002\006\004"
3589 "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",
3590 /* 7*/ "\005\000\002\006\004"
3591 "GDT HA %u, Host Drive %lu write protected",
3592 /* 8*/ "\005\000\002\006\004"
3593 "GDT HA %u, media changed in Host Drive %lu",
3594 /* 9*/ "\005\000\002\006\004"
3595 "GDT HA %u, Host Drive %lu is offline",
3596 /*10*/ "\005\000\002\006\004"
3597 "GDT HA %u, media change of Mirror Drive %lu",
3598 /*11*/ "\005\000\002\006\004"
3599 "GDT HA %u, Mirror Drive %lu is write protected",
3600 /*12*/ "\005\000\002\006\004"
3601 "GDT HA %u, general error on Host Drive %lu. Please check the devices of this drive!",
3602 /*13*/ "\007\000\002\006\002\010\002"
3603 "GDT HA %u, Array Drive %u: Cache Drive %u failed",
3604 /*14*/ "\005\000\002\006\002"
3605 "GDT HA %u, Array Drive %u: FAIL state entered",
3606 /*15*/ "\005\000\002\006\002"
3607 "GDT HA %u, Array Drive %u: error",
3608 /*16*/ "\007\000\002\006\002\010\002"
3609 "GDT HA %u, Array Drive %u: failed drive replaced by Cache Drive %u",
3610 /*17*/ "\005\000\002\006\002"
3611 "GDT HA %u, Array Drive %u: parity build failed",
3612 /*18*/ "\005\000\002\006\002"
3613 "GDT HA %u, Array Drive %u: drive rebuild failed",
3614 /*19*/ "\005\000\002\010\002"
3615 "GDT HA %u, Test of Hot Fix %u failed",
3616 /*20*/ "\005\000\002\006\002"
3617 "GDT HA %u, Array Drive %u: drive build finished successfully",
3618 /*21*/ "\005\000\002\006\002"
3619 "GDT HA %u, Array Drive %u: drive rebuild finished successfully",
3620 /*22*/ "\007\000\002\006\002\010\002"
3621 "GDT HA %u, Array Drive %u: Hot Fix %u activated",
3622 /*23*/ "\005\000\002\006\002"
3623 "GDT HA %u, Host Drive %u: processing of i/o aborted due to serious drive error",
3624 /*24*/ "\005\000\002\010\002"
3625 "GDT HA %u, mirror update on Cache Drive %u completed",
3626 /*25*/ "\005\000\002\010\002"
3627 "GDT HA %u, mirror update on Cache Drive %lu failed",
3628 /*26*/ "\005\000\002\006\002"
3629 "GDT HA %u, Array Drive %u: drive rebuild started",
3630 /*27*/ "\005\000\002\012\001"
3631 "GDT HA %u, Fault bus %u: SHELF OK detected",
3632 /*28*/ "\005\000\002\012\001"
3633 "GDT HA %u, Fault bus %u: SHELF not OK detected",
3634 /*29*/ "\007\000\002\012\001\013\001"
3635 "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug started",
3636 /*30*/ "\007\000\002\012\001\013\001"
3637 "GDT HA %u, Fault bus %u, ID %u: new disk detected",
3638 /*31*/ "\007\000\002\012\001\013\001"
3639 "GDT HA %u, Fault bus %u, ID %u: old disk detected",
3640 /*32*/ "\007\000\002\012\001\013\001"
3641 "GDT HA %u, Fault bus %u, ID %u: plugging an active disk is invalid",
3642 /*33*/ "\007\000\002\012\001\013\001"
3643 "GDT HA %u, Fault bus %u, ID %u: invalid device detected",
3644 /*34*/ "\011\000\002\012\001\013\001\006\004"
3645 "GDT HA %u, Fault bus %u, ID %u: insufficient disk capacity (%lu MB required)",
3646 /*35*/ "\007\000\002\012\001\013\001"
3647 "GDT HA %u, Fault bus %u, ID %u: disk write protected",
3648 /*36*/ "\007\000\002\012\001\013\001"
3649 "GDT HA %u, Fault bus %u, ID %u: disk not available",
3650 /*37*/ "\007\000\002\012\001\006\004"
3651 "GDT HA %u, Fault bus %u: swap detected (%lu)",
3652 /*38*/ "\007\000\002\012\001\013\001"
3653 "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug finished successfully",
3654 /*39*/ "\007\000\002\012\001\013\001"
3655 "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug aborted due to user Hot Plug",
3656 /*40*/ "\007\000\002\012\001\013\001"
3657 "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug aborted",
3658 /*41*/ "\007\000\002\012\001\013\001"
3659 "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug for Hot Fix started",
3660 /*42*/ "\005\000\002\006\002"
3661 "GDT HA %u, Array Drive %u: drive build started",
3662 /*43*/ "\003\000\002"
3663 "GDT HA %u, DRAM parity error detected",
3664 /*44*/ "\005\000\002\006\002"
3665 "GDT HA %u, Mirror Drive %u: update started",
3666 /*45*/ "\007\000\002\006\002\010\002"
3667 "GDT HA %u, Mirror Drive %u: Hot Fix %u activated",
3668 /*46*/ "\005\000\002\006\002"
3669 "GDT HA %u, Array Drive %u: no matching Pool Hot Fix Drive available",
3670 /*47*/ "\005\000\002\006\002"
3671 "GDT HA %u, Array Drive %u: Pool Hot Fix Drive available",
3672 /*48*/ "\005\000\002\006\002"
3673 "GDT HA %u, Mirror Drive %u: no matching Pool Hot Fix Drive available",
3674 /*49*/ "\005\000\002\006\002"
3675 "GDT HA %u, Mirror Drive %u: Pool Hot Fix Drive available",
3676 /*50*/ "\007\000\002\012\001\013\001"
3677 "GDT HA %u, SCSI bus %u, ID %u: IGNORE_WIDE_RESIDUE message received",
3678 /*51*/ "\005\000\002\006\002"
3679 "GDT HA %u, Array Drive %u: expand started",
3680 /*52*/ "\005\000\002\006\002"
3681 "GDT HA %u, Array Drive %u: expand finished successfully",
3682 /*53*/ "\005\000\002\006\002"
3683 "GDT HA %u, Array Drive %u: expand failed",
3684 /*54*/ "\003\000\002"
3685 "GDT HA %u, CPU temperature critical",
3686 /*55*/ "\003\000\002"
3687 "GDT HA %u, CPU temperature OK",
3688 /*56*/ "\005\000\002\006\004"
3689 "GDT HA %u, Host drive %lu created",
3690 /*57*/ "\005\000\002\006\002"
3691 "GDT HA %u, Array Drive %u: expand restarted",
3692 /*58*/ "\005\000\002\006\002"
3693 "GDT HA %u, Array Drive %u: expand stopped",
3694 /*59*/ "\005\000\002\010\002"
3695 "GDT HA %u, Mirror Drive %u: drive build quited",
3696 /*60*/ "\005\000\002\006\002"
3697 "GDT HA %u, Array Drive %u: parity build quited",
3698 /*61*/ "\005\000\002\006\002"
3699 "GDT HA %u, Array Drive %u: drive rebuild quited",
3700 /*62*/ "\005\000\002\006\002"
3701 "GDT HA %u, Array Drive %u: parity verify started",
3702 /*63*/ "\005\000\002\006\002"
3703 "GDT HA %u, Array Drive %u: parity verify done",
3704 /*64*/ "\005\000\002\006\002"
3705 "GDT HA %u, Array Drive %u: parity verify failed",
3706 /*65*/ "\005\000\002\006\002"
3707 "GDT HA %u, Array Drive %u: parity error detected",
3708 /*66*/ "\005\000\002\006\002"
3709 "GDT HA %u, Array Drive %u: parity verify quited",
3710 /*67*/ "\005\000\002\006\002"
3711 "GDT HA %u, Host Drive %u reserved",
3712 /*68*/ "\005\000\002\006\002"
3713 "GDT HA %u, Host Drive %u mounted and released",
3714 /*69*/ "\005\000\002\006\002"
3715 "GDT HA %u, Host Drive %u released",
3716 /*70*/ "\003\000\002"
3717 "GDT HA %u, DRAM error detected and corrected with ECC",
3718 /*71*/ "\003\000\002"
3719 "GDT HA %u, Uncorrectable DRAM error detected with ECC",
3720 /*72*/ "\011\000\002\012\001\013\001\014\001"
3721 "GDT HA %u, SCSI bus %u, ID %u, LUN %u: reassigning block",
3722 /*73*/ "\005\000\002\006\002"
3723 "GDT HA %u, Host drive %u resetted locally",
3724 /*74*/ "\005\000\002\006\002"
3725 "GDT HA %u, Host drive %u resetted remotely",
3726 /*75*/ "\003\000\002"
3727 "GDT HA %u, async. status 75 unknown",
3731 static int gdth_async_event(gdth_ha_str
*ha
)
3737 TRACE2(("gdth_async_event() ha %d serv %d\n",
3738 ha
->hanum
, ha
->service
));
3740 if (ha
->service
== SCREENSERVICE
) {
3741 if (ha
->status
== MSG_REQUEST
) {
3742 while (gdth_test_busy(ha
))
3744 cmdp
->Service
= SCREENSERVICE
;
3745 cmdp
->RequestBuffer
= SCREEN_CMND
;
3746 cmd_index
= gdth_get_cmd_index(ha
);
3748 cmdp
->OpCode
= GDT_READ
;
3749 cmdp
->BoardNode
= LOCALBOARD
;
3750 cmdp
->u
.screen
.reserved
= 0;
3751 cmdp
->u
.screen
.su
.msg
.msg_handle
= MSG_INV_HANDLE
;
3752 cmdp
->u
.screen
.su
.msg
.msg_addr
= ha
->msg_phys
;
3753 ha
->cmd_offs_dpmem
= 0;
3754 ha
->cmd_len
= GDTOFFSOF(gdth_cmd_str
,u
.screen
.su
.msg
.msg_addr
)
3757 gdth_copy_command(ha
);
3758 if (ha
->type
== GDT_EISA
)
3759 printk("[EISA slot %d] ",(ushort
)ha
->brd_phys
);
3760 else if (ha
->type
== GDT_ISA
)
3761 printk("[DPMEM 0x%4X] ",(ushort
)ha
->brd_phys
);
3763 printk("[PCI %d/%d] ",(ushort
)(ha
->brd_phys
>>8),
3764 (ushort
)((ha
->brd_phys
>>3)&0x1f));
3765 gdth_release_event(ha
);
3769 if (ha
->type
== GDT_PCIMPR
&&
3770 (ha
->fw_vers
& 0xff) >= 0x1a) {
3772 ha
->dvr
.eu
.async
.ionode
= ha
->hanum
;
3773 ha
->dvr
.eu
.async
.status
= ha
->status
;
3774 /* severity and event_string already set! */
3776 ha
->dvr
.size
= sizeof(ha
->dvr
.eu
.async
);
3777 ha
->dvr
.eu
.async
.ionode
= ha
->hanum
;
3778 ha
->dvr
.eu
.async
.service
= ha
->service
;
3779 ha
->dvr
.eu
.async
.status
= ha
->status
;
3780 ha
->dvr
.eu
.async
.info
= ha
->info
;
3781 *(ulong32
*)ha
->dvr
.eu
.async
.scsi_coord
= ha
->info2
;
3783 gdth_store_event( ha
, ES_ASYNC
, ha
->service
, &ha
->dvr
);
3784 gdth_log_event( &ha
->dvr
, NULL
);
3786 /* new host drive from expand? */
3787 if (ha
->service
== CACHESERVICE
&& ha
->status
== 56) {
3788 TRACE2(("gdth_async_event(): new host drive %d created\n",
3790 /* gdth_analyse_hdrive(hanum, (ushort)ha->info); */
3796 static void gdth_log_event(gdth_evt_data
*dvr
, char *buffer
)
3798 gdth_stackframe stack
;
3802 TRACE2(("gdth_log_event()\n"));
3803 if (dvr
->size
== 0) {
3804 if (buffer
== NULL
) {
3805 printk("Adapter %d: %s\n",dvr
->eu
.async
.ionode
,dvr
->event_string
);
3807 sprintf(buffer
,"Adapter %d: %s\n",
3808 dvr
->eu
.async
.ionode
,dvr
->event_string
);
3810 } else if (dvr
->eu
.async
.service
== CACHESERVICE
&&
3811 INDEX_OK(dvr
->eu
.async
.status
, async_cache_tab
)) {
3812 TRACE2(("GDT: Async. event cache service, event no.: %d\n",
3813 dvr
->eu
.async
.status
));
3815 f
= async_cache_tab
[dvr
->eu
.async
.status
];
3817 /* i: parameter to push, j: stack element to fill */
3818 for (j
=0,i
=1; i
< f
[0]; i
+=2) {
3821 stack
.b
[j
++] = *(ulong32
*)&dvr
->eu
.stream
[(int)f
[i
]];
3824 stack
.b
[j
++] = *(ushort
*)&dvr
->eu
.stream
[(int)f
[i
]];
3827 stack
.b
[j
++] = *(unchar
*)&dvr
->eu
.stream
[(int)f
[i
]];
3834 if (buffer
== NULL
) {
3835 printk(&f
[(int)f
[0]],stack
);
3838 sprintf(buffer
,&f
[(int)f
[0]],stack
);
3842 if (buffer
== NULL
) {
3843 printk("GDT HA %u, Unknown async. event service %d event no. %d\n",
3844 dvr
->eu
.async
.ionode
,dvr
->eu
.async
.service
,dvr
->eu
.async
.status
);
3846 sprintf(buffer
,"GDT HA %u, Unknown async. event service %d event no. %d",
3847 dvr
->eu
.async
.ionode
,dvr
->eu
.async
.service
,dvr
->eu
.async
.status
);
3852 #ifdef GDTH_STATISTICS
3853 static void gdth_timeout(ulong data
)
3860 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
3862 BUG_ON(list_empty(&gdth_instances
));
3864 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
3865 ha
= list_first_entry(&gdth_instances
, gdth_ha_str
, list
);
3866 spin_lock_irqsave(&ha
->smp_lock
, flags
);
3868 for (act_stats
=0,i
=0; i
<GDTH_MAXCMDS
; ++i
)
3869 if (ha
->cmd_tab
[i
].cmnd
!= UNUSED_CMND
)
3872 for (act_rq
=0,nscp
=ha
->req_first
; nscp
; nscp
=(Scsi_Cmnd
*)nscp
->SCp
.ptr
)
3875 TRACE2(("gdth_to(): ints %d, ios %d, act_stats %d, act_rq %d\n",
3876 act_ints
, act_ios
, act_stats
, act_rq
));
3877 act_ints
= act_ios
= 0;
3879 gdth_timer
.expires
= jiffies
+ 30 * HZ
;
3880 add_timer(&gdth_timer
);
3881 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
3885 static void __init
internal_setup(char *str
,int *ints
)
3888 char *cur_str
, *argv
;
3890 TRACE2(("internal_setup() str %s ints[0] %d\n",
3891 str
? str
:"NULL", ints
? ints
[0]:0));
3893 /* read irq[] from ints[] */
3899 for (i
= 0; i
< argc
; ++i
)
3904 /* analyse string */
3906 while (argv
&& (cur_str
= strchr(argv
, ':'))) {
3907 int val
= 0, c
= *++cur_str
;
3909 if (c
== 'n' || c
== 'N')
3911 else if (c
== 'y' || c
== 'Y')
3914 val
= (int)simple_strtoul(cur_str
, NULL
, 0);
3916 if (!strncmp(argv
, "disable:", 8))
3918 else if (!strncmp(argv
, "reserve_mode:", 13))
3920 else if (!strncmp(argv
, "reverse_scan:", 13))
3922 else if (!strncmp(argv
, "hdr_channel:", 12))
3924 else if (!strncmp(argv
, "max_ids:", 8))
3926 else if (!strncmp(argv
, "rescan:", 7))
3928 else if (!strncmp(argv
, "shared_access:", 14))
3929 shared_access
= val
;
3930 else if (!strncmp(argv
, "probe_eisa_isa:", 15))
3931 probe_eisa_isa
= val
;
3932 else if (!strncmp(argv
, "reserve_list:", 13)) {
3933 reserve_list
[0] = val
;
3934 for (i
= 1; i
< MAX_RES_ARGS
; i
++) {
3935 cur_str
= strchr(cur_str
, ',');
3938 if (!isdigit((int)*++cur_str
)) {
3943 (int)simple_strtoul(cur_str
, NULL
, 0);
3951 if ((argv
= strchr(argv
, ',')))
3956 int __init
option_setup(char *str
)
3962 TRACE2(("option_setup() str %s\n", str
? str
:"NULL"));
3964 while (cur
&& isdigit(*cur
) && i
<= MAXHA
) {
3965 ints
[i
++] = simple_strtoul(cur
, NULL
, 0);
3966 if ((cur
= strchr(cur
, ',')) != NULL
) cur
++;
3970 internal_setup(cur
, ints
);
3974 static const char *gdth_ctr_name(gdth_ha_str
*ha
)
3976 TRACE2(("gdth_ctr_name()\n"));
3978 if (ha
->type
== GDT_EISA
) {
3979 switch (ha
->stype
) {
3981 return("GDT3000/3020");
3983 return("GDT3000A/3020A/3050A");
3985 return("GDT3000B/3010A");
3987 } else if (ha
->type
== GDT_ISA
) {
3988 return("GDT2000/2020");
3989 } else if (ha
->type
== GDT_PCI
) {
3990 switch (ha
->pdev
->device
) {
3991 case PCI_DEVICE_ID_VORTEX_GDT60x0
:
3992 return("GDT6000/6020/6050");
3993 case PCI_DEVICE_ID_VORTEX_GDT6000B
:
3994 return("GDT6000B/6010");
3997 /* new controllers (GDT_PCINEW, GDT_PCIMPR, ..) use board_info IOCTL! */
4002 static const char *gdth_info(struct Scsi_Host
*shp
)
4004 gdth_ha_str
*ha
= shost_priv(shp
);
4006 TRACE2(("gdth_info()\n"));
4007 return ((const char *)ha
->binfo
.type_string
);
4010 static int gdth_eh_bus_reset(Scsi_Cmnd
*scp
)
4012 gdth_ha_str
*ha
= shost_priv(scp
->device
->host
);
4018 TRACE2(("gdth_eh_bus_reset()\n"));
4020 b
= scp
->device
->channel
;
4022 /* clear command tab */
4023 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4024 for (i
= 0; i
< GDTH_MAXCMDS
; ++i
) {
4025 cmnd
= ha
->cmd_tab
[i
].cmnd
;
4026 if (!SPECIAL_SCP(cmnd
) && cmnd
->device
->channel
== b
)
4027 ha
->cmd_tab
[i
].cmnd
= UNUSED_CMND
;
4029 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4031 if (b
== ha
->virt_bus
) {
4033 for (i
= 0; i
< MAX_HDRIVES
; ++i
) {
4034 if (ha
->hdr
[i
].present
) {
4035 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4036 gdth_polling
= TRUE
;
4037 while (gdth_test_busy(ha
))
4039 if (gdth_internal_cmd(ha
, CACHESERVICE
,
4040 GDT_CLUST_RESET
, i
, 0, 0))
4041 ha
->hdr
[i
].cluster_type
&= ~CLUSTER_RESERVED
;
4042 gdth_polling
= FALSE
;
4043 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4048 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4049 for (i
= 0; i
< MAXID
; ++i
)
4050 ha
->raw
[BUS_L2P(ha
,b
)].io_cnt
[i
] = 0;
4051 gdth_polling
= TRUE
;
4052 while (gdth_test_busy(ha
))
4054 gdth_internal_cmd(ha
, SCSIRAWSERVICE
, GDT_RESET_BUS
,
4055 BUS_L2P(ha
,b
), 0, 0);
4056 gdth_polling
= FALSE
;
4057 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4062 static int gdth_bios_param(struct scsi_device
*sdev
,struct block_device
*bdev
,sector_t cap
,int *ip
)
4065 gdth_ha_str
*ha
= shost_priv(sdev
->host
);
4066 struct scsi_device
*sd
;
4073 TRACE2(("gdth_bios_param() ha %d bus %d target %d\n", ha
->hanum
, b
, t
));
4075 if (b
!= ha
->virt_bus
|| ha
->hdr
[t
].heads
== 0) {
4076 /* raw device or host drive without mapping information */
4077 TRACE2(("Evaluate mapping\n"));
4078 gdth_eval_mapping(capacity
,&ip
[2],&ip
[0],&ip
[1]);
4080 ip
[0] = ha
->hdr
[t
].heads
;
4081 ip
[1] = ha
->hdr
[t
].secs
;
4082 ip
[2] = capacity
/ ip
[0] / ip
[1];
4085 TRACE2(("gdth_bios_param(): %d heads, %d secs, %d cyls\n",
4086 ip
[0],ip
[1],ip
[2]));
4091 static int gdth_queuecommand(struct scsi_cmnd
*scp
,
4092 void (*done
)(struct scsi_cmnd
*))
4094 gdth_ha_str
*ha
= shost_priv(scp
->device
->host
);
4095 struct gdth_cmndinfo
*cmndinfo
;
4097 TRACE(("gdth_queuecommand() cmd 0x%x\n", scp
->cmnd
[0]));
4099 cmndinfo
= gdth_get_cmndinfo(ha
);
4102 scp
->scsi_done
= done
;
4103 gdth_update_timeout(scp
, scp
->timeout_per_command
* 6);
4104 cmndinfo
->priority
= DEFAULT_PRI
;
4106 gdth_set_bufflen(scp
, scsi_bufflen(scp
));
4107 gdth_set_sg_count(scp
, scsi_sg_count(scp
));
4108 gdth_set_sglist(scp
, scsi_sglist(scp
));
4110 return __gdth_queuecommand(ha
, scp
, cmndinfo
);
4113 static int __gdth_queuecommand(gdth_ha_str
*ha
, struct scsi_cmnd
*scp
,
4114 struct gdth_cmndinfo
*cmndinfo
)
4116 scp
->host_scribble
= (unsigned char *)cmndinfo
;
4117 cmndinfo
->wait_for_completion
= 1;
4118 cmndinfo
->phase
= -1;
4119 cmndinfo
->OpCode
= -1;
4121 #ifdef GDTH_STATISTICS
4125 gdth_putq(ha
, scp
, cmndinfo
->priority
);
4131 static int gdth_open(struct inode
*inode
, struct file
*filep
)
4135 list_for_each_entry(ha
, &gdth_instances
, list
) {
4137 ha
->sdev
= scsi_get_host_dev(ha
->shost
);
4140 TRACE(("gdth_open()\n"));
4144 static int gdth_close(struct inode
*inode
, struct file
*filep
)
4146 TRACE(("gdth_close()\n"));
4150 static int ioc_event(void __user
*arg
)
4152 gdth_ioctl_event evt
;
4156 if (copy_from_user(&evt
, arg
, sizeof(gdth_ioctl_event
)))
4158 ha
= gdth_find_ha(evt
.ionode
);
4162 if (evt
.erase
== 0xff) {
4163 if (evt
.event
.event_source
== ES_TEST
)
4164 evt
.event
.event_data
.size
=sizeof(evt
.event
.event_data
.eu
.test
);
4165 else if (evt
.event
.event_source
== ES_DRIVER
)
4166 evt
.event
.event_data
.size
=sizeof(evt
.event
.event_data
.eu
.driver
);
4167 else if (evt
.event
.event_source
== ES_SYNC
)
4168 evt
.event
.event_data
.size
=sizeof(evt
.event
.event_data
.eu
.sync
);
4170 evt
.event
.event_data
.size
=sizeof(evt
.event
.event_data
.eu
.async
);
4171 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4172 gdth_store_event(ha
, evt
.event
.event_source
, evt
.event
.event_idx
,
4173 &evt
.event
.event_data
);
4174 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4175 } else if (evt
.erase
== 0xfe) {
4176 gdth_clear_events();
4177 } else if (evt
.erase
== 0) {
4178 evt
.handle
= gdth_read_event(ha
, evt
.handle
, &evt
.event
);
4180 gdth_readapp_event(ha
, evt
.erase
, &evt
.event
);
4182 if (copy_to_user(arg
, &evt
, sizeof(gdth_ioctl_event
)))
4187 static int ioc_lockdrv(void __user
*arg
)
4189 gdth_ioctl_lockdrv ldrv
;
4194 if (copy_from_user(&ldrv
, arg
, sizeof(gdth_ioctl_lockdrv
)))
4196 ha
= gdth_find_ha(ldrv
.ionode
);
4200 for (i
= 0; i
< ldrv
.drive_cnt
&& i
< MAX_HDRIVES
; ++i
) {
4202 if (j
>= MAX_HDRIVES
|| !ha
->hdr
[j
].present
)
4205 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4206 ha
->hdr
[j
].lock
= 1;
4207 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4208 gdth_wait_completion(ha
, ha
->bus_cnt
, j
);
4209 gdth_stop_timeout(ha
, ha
->bus_cnt
, j
);
4211 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4212 ha
->hdr
[j
].lock
= 0;
4213 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4214 gdth_start_timeout(ha
, ha
->bus_cnt
, j
);
4221 static int ioc_resetdrv(void __user
*arg
, char *cmnd
)
4223 gdth_ioctl_reset res
;
4228 if (copy_from_user(&res
, arg
, sizeof(gdth_ioctl_reset
)) ||
4229 res
.number
>= MAX_HDRIVES
)
4231 ha
= gdth_find_ha(res
.ionode
);
4235 if (!ha
->hdr
[res
.number
].present
)
4237 memset(&cmd
, 0, sizeof(gdth_cmd_str
));
4238 cmd
.Service
= CACHESERVICE
;
4239 cmd
.OpCode
= GDT_CLUST_RESET
;
4240 if (ha
->cache_feat
& GDT_64BIT
)
4241 cmd
.u
.cache64
.DeviceNo
= res
.number
;
4243 cmd
.u
.cache
.DeviceNo
= res
.number
;
4245 rval
= __gdth_execute(ha
->sdev
, &cmd
, cmnd
, 30, NULL
);
4250 if (copy_to_user(arg
, &res
, sizeof(gdth_ioctl_reset
)))
4255 static int ioc_general(void __user
*arg
, char *cmnd
)
4257 gdth_ioctl_general gen
;
4263 if (copy_from_user(&gen
, arg
, sizeof(gdth_ioctl_general
)))
4265 ha
= gdth_find_ha(gen
.ionode
);
4268 if (gen
.data_len
+ gen
.sense_len
!= 0) {
4269 if (!(buf
= gdth_ioctl_alloc(ha
, gen
.data_len
+ gen
.sense_len
,
4272 if (copy_from_user(buf
, arg
+ sizeof(gdth_ioctl_general
),
4273 gen
.data_len
+ gen
.sense_len
)) {
4274 gdth_ioctl_free(ha
, gen
.data_len
+gen
.sense_len
, buf
, paddr
);
4278 if (gen
.command
.OpCode
== GDT_IOCTL
) {
4279 gen
.command
.u
.ioctl
.p_param
= paddr
;
4280 } else if (gen
.command
.Service
== CACHESERVICE
) {
4281 if (ha
->cache_feat
& GDT_64BIT
) {
4282 /* copy elements from 32-bit IOCTL structure */
4283 gen
.command
.u
.cache64
.BlockCnt
= gen
.command
.u
.cache
.BlockCnt
;
4284 gen
.command
.u
.cache64
.BlockNo
= gen
.command
.u
.cache
.BlockNo
;
4285 gen
.command
.u
.cache64
.DeviceNo
= gen
.command
.u
.cache
.DeviceNo
;
4287 if (ha
->cache_feat
& SCATTER_GATHER
) {
4288 gen
.command
.u
.cache64
.DestAddr
= (ulong64
)-1;
4289 gen
.command
.u
.cache64
.sg_canz
= 1;
4290 gen
.command
.u
.cache64
.sg_lst
[0].sg_ptr
= paddr
;
4291 gen
.command
.u
.cache64
.sg_lst
[0].sg_len
= gen
.data_len
;
4292 gen
.command
.u
.cache64
.sg_lst
[1].sg_len
= 0;
4294 gen
.command
.u
.cache64
.DestAddr
= paddr
;
4295 gen
.command
.u
.cache64
.sg_canz
= 0;
4298 if (ha
->cache_feat
& SCATTER_GATHER
) {
4299 gen
.command
.u
.cache
.DestAddr
= 0xffffffff;
4300 gen
.command
.u
.cache
.sg_canz
= 1;
4301 gen
.command
.u
.cache
.sg_lst
[0].sg_ptr
= (ulong32
)paddr
;
4302 gen
.command
.u
.cache
.sg_lst
[0].sg_len
= gen
.data_len
;
4303 gen
.command
.u
.cache
.sg_lst
[1].sg_len
= 0;
4305 gen
.command
.u
.cache
.DestAddr
= paddr
;
4306 gen
.command
.u
.cache
.sg_canz
= 0;
4309 } else if (gen
.command
.Service
== SCSIRAWSERVICE
) {
4310 if (ha
->raw_feat
& GDT_64BIT
) {
4311 /* copy elements from 32-bit IOCTL structure */
4313 gen
.command
.u
.raw64
.sense_len
= gen
.command
.u
.raw
.sense_len
;
4314 gen
.command
.u
.raw64
.bus
= gen
.command
.u
.raw
.bus
;
4315 gen
.command
.u
.raw64
.lun
= gen
.command
.u
.raw
.lun
;
4316 gen
.command
.u
.raw64
.target
= gen
.command
.u
.raw
.target
;
4317 memcpy(cmd
, gen
.command
.u
.raw
.cmd
, 16);
4318 memcpy(gen
.command
.u
.raw64
.cmd
, cmd
, 16);
4319 gen
.command
.u
.raw64
.clen
= gen
.command
.u
.raw
.clen
;
4320 gen
.command
.u
.raw64
.sdlen
= gen
.command
.u
.raw
.sdlen
;
4321 gen
.command
.u
.raw64
.direction
= gen
.command
.u
.raw
.direction
;
4323 if (ha
->raw_feat
& SCATTER_GATHER
) {
4324 gen
.command
.u
.raw64
.sdata
= (ulong64
)-1;
4325 gen
.command
.u
.raw64
.sg_ranz
= 1;
4326 gen
.command
.u
.raw64
.sg_lst
[0].sg_ptr
= paddr
;
4327 gen
.command
.u
.raw64
.sg_lst
[0].sg_len
= gen
.data_len
;
4328 gen
.command
.u
.raw64
.sg_lst
[1].sg_len
= 0;
4330 gen
.command
.u
.raw64
.sdata
= paddr
;
4331 gen
.command
.u
.raw64
.sg_ranz
= 0;
4333 gen
.command
.u
.raw64
.sense_data
= paddr
+ gen
.data_len
;
4335 if (ha
->raw_feat
& SCATTER_GATHER
) {
4336 gen
.command
.u
.raw
.sdata
= 0xffffffff;
4337 gen
.command
.u
.raw
.sg_ranz
= 1;
4338 gen
.command
.u
.raw
.sg_lst
[0].sg_ptr
= (ulong32
)paddr
;
4339 gen
.command
.u
.raw
.sg_lst
[0].sg_len
= gen
.data_len
;
4340 gen
.command
.u
.raw
.sg_lst
[1].sg_len
= 0;
4342 gen
.command
.u
.raw
.sdata
= paddr
;
4343 gen
.command
.u
.raw
.sg_ranz
= 0;
4345 gen
.command
.u
.raw
.sense_data
= (ulong32
)paddr
+ gen
.data_len
;
4348 gdth_ioctl_free(ha
, gen
.data_len
+gen
.sense_len
, buf
, paddr
);
4353 rval
= __gdth_execute(ha
->sdev
, &gen
.command
, cmnd
, gen
.timeout
, &gen
.info
);
4358 if (copy_to_user(arg
+ sizeof(gdth_ioctl_general
), buf
,
4359 gen
.data_len
+ gen
.sense_len
)) {
4360 gdth_ioctl_free(ha
, gen
.data_len
+gen
.sense_len
, buf
, paddr
);
4363 if (copy_to_user(arg
, &gen
,
4364 sizeof(gdth_ioctl_general
) - sizeof(gdth_cmd_str
))) {
4365 gdth_ioctl_free(ha
, gen
.data_len
+gen
.sense_len
, buf
, paddr
);
4368 gdth_ioctl_free(ha
, gen
.data_len
+gen
.sense_len
, buf
, paddr
);
4372 static int ioc_hdrlist(void __user
*arg
, char *cmnd
)
4374 gdth_ioctl_rescan
*rsc
;
4379 u32 cluster_type
= 0;
4381 rsc
= kmalloc(sizeof(*rsc
), GFP_KERNEL
);
4382 cmd
= kmalloc(sizeof(*cmd
), GFP_KERNEL
);
4386 if (copy_from_user(rsc
, arg
, sizeof(gdth_ioctl_rescan
)) ||
4387 (NULL
== (ha
= gdth_find_ha(rsc
->ionode
)))) {
4391 memset(cmd
, 0, sizeof(gdth_cmd_str
));
4393 for (i
= 0; i
< MAX_HDRIVES
; ++i
) {
4394 if (!ha
->hdr
[i
].present
) {
4395 rsc
->hdr_list
[i
].bus
= 0xff;
4398 rsc
->hdr_list
[i
].bus
= ha
->virt_bus
;
4399 rsc
->hdr_list
[i
].target
= i
;
4400 rsc
->hdr_list
[i
].lun
= 0;
4401 rsc
->hdr_list
[i
].cluster_type
= ha
->hdr
[i
].cluster_type
;
4402 if (ha
->hdr
[i
].cluster_type
& CLUSTER_DRIVE
) {
4403 cmd
->Service
= CACHESERVICE
;
4404 cmd
->OpCode
= GDT_CLUST_INFO
;
4405 if (ha
->cache_feat
& GDT_64BIT
)
4406 cmd
->u
.cache64
.DeviceNo
= i
;
4408 cmd
->u
.cache
.DeviceNo
= i
;
4409 if (__gdth_execute(ha
->sdev
, cmd
, cmnd
, 30, &cluster_type
) == S_OK
)
4410 rsc
->hdr_list
[i
].cluster_type
= cluster_type
;
4414 if (copy_to_user(arg
, rsc
, sizeof(gdth_ioctl_rescan
)))
4425 static int ioc_rescan(void __user
*arg
, char *cmnd
)
4427 gdth_ioctl_rescan
*rsc
;
4429 ushort i
, status
, hdr_cnt
;
4431 int cyls
, hds
, secs
;
4436 rsc
= kmalloc(sizeof(*rsc
), GFP_KERNEL
);
4437 cmd
= kmalloc(sizeof(*cmd
), GFP_KERNEL
);
4441 if (copy_from_user(rsc
, arg
, sizeof(gdth_ioctl_rescan
)) ||
4442 (NULL
== (ha
= gdth_find_ha(rsc
->ionode
)))) {
4446 memset(cmd
, 0, sizeof(gdth_cmd_str
));
4448 if (rsc
->flag
== 0) {
4449 /* old method: re-init. cache service */
4450 cmd
->Service
= CACHESERVICE
;
4451 if (ha
->cache_feat
& GDT_64BIT
) {
4452 cmd
->OpCode
= GDT_X_INIT_HOST
;
4453 cmd
->u
.cache64
.DeviceNo
= LINUX_OS
;
4455 cmd
->OpCode
= GDT_INIT
;
4456 cmd
->u
.cache
.DeviceNo
= LINUX_OS
;
4459 status
= __gdth_execute(ha
->sdev
, cmd
, cmnd
, 30, &info
);
4461 hdr_cnt
= (status
== S_OK
? (ushort
)info
: 0);
4467 for (; i
< hdr_cnt
&& i
< MAX_HDRIVES
; ++i
) {
4468 cmd
->Service
= CACHESERVICE
;
4469 cmd
->OpCode
= GDT_INFO
;
4470 if (ha
->cache_feat
& GDT_64BIT
)
4471 cmd
->u
.cache64
.DeviceNo
= i
;
4473 cmd
->u
.cache
.DeviceNo
= i
;
4475 status
= __gdth_execute(ha
->sdev
, cmd
, cmnd
, 30, &info
);
4477 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4478 rsc
->hdr_list
[i
].bus
= ha
->virt_bus
;
4479 rsc
->hdr_list
[i
].target
= i
;
4480 rsc
->hdr_list
[i
].lun
= 0;
4481 if (status
!= S_OK
) {
4482 ha
->hdr
[i
].present
= FALSE
;
4484 ha
->hdr
[i
].present
= TRUE
;
4485 ha
->hdr
[i
].size
= info
;
4486 /* evaluate mapping */
4487 ha
->hdr
[i
].size
&= ~SECS32
;
4488 gdth_eval_mapping(ha
->hdr
[i
].size
,&cyls
,&hds
,&secs
);
4489 ha
->hdr
[i
].heads
= hds
;
4490 ha
->hdr
[i
].secs
= secs
;
4492 ha
->hdr
[i
].size
= cyls
* hds
* secs
;
4494 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4498 /* extended info, if GDT_64BIT, for drives > 2 TB */
4499 /* but we need ha->info2, not yet stored in scp->SCp */
4501 /* devtype, cluster info, R/W attribs */
4502 cmd
->Service
= CACHESERVICE
;
4503 cmd
->OpCode
= GDT_DEVTYPE
;
4504 if (ha
->cache_feat
& GDT_64BIT
)
4505 cmd
->u
.cache64
.DeviceNo
= i
;
4507 cmd
->u
.cache
.DeviceNo
= i
;
4509 status
= __gdth_execute(ha
->sdev
, cmd
, cmnd
, 30, &info
);
4511 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4512 ha
->hdr
[i
].devtype
= (status
== S_OK
? (ushort
)info
: 0);
4513 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4515 cmd
->Service
= CACHESERVICE
;
4516 cmd
->OpCode
= GDT_CLUST_INFO
;
4517 if (ha
->cache_feat
& GDT_64BIT
)
4518 cmd
->u
.cache64
.DeviceNo
= i
;
4520 cmd
->u
.cache
.DeviceNo
= i
;
4522 status
= __gdth_execute(ha
->sdev
, cmd
, cmnd
, 30, &info
);
4524 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4525 ha
->hdr
[i
].cluster_type
=
4526 ((status
== S_OK
&& !shared_access
) ? (ushort
)info
: 0);
4527 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4528 rsc
->hdr_list
[i
].cluster_type
= ha
->hdr
[i
].cluster_type
;
4530 cmd
->Service
= CACHESERVICE
;
4531 cmd
->OpCode
= GDT_RW_ATTRIBS
;
4532 if (ha
->cache_feat
& GDT_64BIT
)
4533 cmd
->u
.cache64
.DeviceNo
= i
;
4535 cmd
->u
.cache
.DeviceNo
= i
;
4537 status
= __gdth_execute(ha
->sdev
, cmd
, cmnd
, 30, &info
);
4539 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4540 ha
->hdr
[i
].rw_attribs
= (status
== S_OK
? (ushort
)info
: 0);
4541 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4544 if (copy_to_user(arg
, rsc
, sizeof(gdth_ioctl_rescan
)))
4555 static int gdth_ioctl(struct inode
*inode
, struct file
*filep
,
4556 unsigned int cmd
, unsigned long arg
)
4561 char cmnd
[MAX_COMMAND_SIZE
];
4562 void __user
*argp
= (void __user
*)arg
;
4564 memset(cmnd
, 0xff, 12);
4566 TRACE(("gdth_ioctl() cmd 0x%x\n", cmd
));
4569 case GDTIOCTL_CTRCNT
:
4571 int cnt
= gdth_ctr_count
;
4572 if (put_user(cnt
, (int __user
*)argp
))
4577 case GDTIOCTL_DRVERS
:
4579 int ver
= (GDTH_VERSION
<<8) | GDTH_SUBVERSION
;
4580 if (put_user(ver
, (int __user
*)argp
))
4585 case GDTIOCTL_OSVERS
:
4587 gdth_ioctl_osvers osv
;
4589 osv
.version
= (unchar
)(LINUX_VERSION_CODE
>> 16);
4590 osv
.subversion
= (unchar
)(LINUX_VERSION_CODE
>> 8);
4591 osv
.revision
= (ushort
)(LINUX_VERSION_CODE
& 0xff);
4592 if (copy_to_user(argp
, &osv
, sizeof(gdth_ioctl_osvers
)))
4597 case GDTIOCTL_CTRTYPE
:
4599 gdth_ioctl_ctrtype ctrt
;
4601 if (copy_from_user(&ctrt
, argp
, sizeof(gdth_ioctl_ctrtype
)) ||
4602 (NULL
== (ha
= gdth_find_ha(ctrt
.ionode
))))
4605 if (ha
->type
== GDT_ISA
|| ha
->type
== GDT_EISA
) {
4606 ctrt
.type
= (unchar
)((ha
->stype
>>20) - 0x10);
4608 if (ha
->type
!= GDT_PCIMPR
) {
4609 ctrt
.type
= (unchar
)((ha
->stype
<<4) + 6);
4612 (ha
->oem_id
== OEM_ID_INTEL
? 0xfd : 0xfe);
4613 if (ha
->stype
>= 0x300)
4614 ctrt
.ext_type
= 0x6000 | ha
->pdev
->subsystem_device
;
4616 ctrt
.ext_type
= 0x6000 | ha
->stype
;
4618 ctrt
.device_id
= ha
->pdev
->device
;
4619 ctrt
.sub_device_id
= ha
->pdev
->subsystem_device
;
4621 ctrt
.info
= ha
->brd_phys
;
4622 ctrt
.oem_id
= ha
->oem_id
;
4623 if (copy_to_user(argp
, &ctrt
, sizeof(gdth_ioctl_ctrtype
)))
4628 case GDTIOCTL_GENERAL
:
4629 return ioc_general(argp
, cmnd
);
4631 case GDTIOCTL_EVENT
:
4632 return ioc_event(argp
);
4634 case GDTIOCTL_LOCKDRV
:
4635 return ioc_lockdrv(argp
);
4637 case GDTIOCTL_LOCKCHN
:
4639 gdth_ioctl_lockchn lchn
;
4642 if (copy_from_user(&lchn
, argp
, sizeof(gdth_ioctl_lockchn
)) ||
4643 (NULL
== (ha
= gdth_find_ha(lchn
.ionode
))))
4647 if (i
< ha
->bus_cnt
) {
4649 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4650 ha
->raw
[i
].lock
= 1;
4651 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4652 for (j
= 0; j
< ha
->tid_cnt
; ++j
) {
4653 gdth_wait_completion(ha
, i
, j
);
4654 gdth_stop_timeout(ha
, i
, j
);
4657 spin_lock_irqsave(&ha
->smp_lock
, flags
);
4658 ha
->raw
[i
].lock
= 0;
4659 spin_unlock_irqrestore(&ha
->smp_lock
, flags
);
4660 for (j
= 0; j
< ha
->tid_cnt
; ++j
) {
4661 gdth_start_timeout(ha
, i
, j
);
4669 case GDTIOCTL_RESCAN
:
4670 return ioc_rescan(argp
, cmnd
);
4672 case GDTIOCTL_HDRLIST
:
4673 return ioc_hdrlist(argp
, cmnd
);
4675 case GDTIOCTL_RESET_BUS
:
4677 gdth_ioctl_reset res
;
4680 if (copy_from_user(&res
, argp
, sizeof(gdth_ioctl_reset
)) ||
4681 (NULL
== (ha
= gdth_find_ha(res
.ionode
))))
4684 scp
= kzalloc(sizeof(*scp
), GFP_KERNEL
);
4687 scp
->device
= ha
->sdev
;
4689 scp
->device
->channel
= res
.number
;
4690 rval
= gdth_eh_bus_reset(scp
);
4691 res
.status
= (rval
== SUCCESS
? S_OK
: S_GENERR
);
4694 if (copy_to_user(argp
, &res
, sizeof(gdth_ioctl_reset
)))
4699 case GDTIOCTL_RESET_DRV
:
4700 return ioc_resetdrv(argp
, cmnd
);
4710 static void gdth_flush(gdth_ha_str
*ha
)
4713 gdth_cmd_str gdtcmd
;
4714 char cmnd
[MAX_COMMAND_SIZE
];
4715 memset(cmnd
, 0xff, MAX_COMMAND_SIZE
);
4717 TRACE2(("gdth_flush() hanum %d\n", ha
->hanum
));
4719 for (i
= 0; i
< MAX_HDRIVES
; ++i
) {
4720 if (ha
->hdr
[i
].present
) {
4721 gdtcmd
.BoardNode
= LOCALBOARD
;
4722 gdtcmd
.Service
= CACHESERVICE
;
4723 gdtcmd
.OpCode
= GDT_FLUSH
;
4724 if (ha
->cache_feat
& GDT_64BIT
) {
4725 gdtcmd
.u
.cache64
.DeviceNo
= i
;
4726 gdtcmd
.u
.cache64
.BlockNo
= 1;
4727 gdtcmd
.u
.cache64
.sg_canz
= 0;
4729 gdtcmd
.u
.cache
.DeviceNo
= i
;
4730 gdtcmd
.u
.cache
.BlockNo
= 1;
4731 gdtcmd
.u
.cache
.sg_canz
= 0;
4733 TRACE2(("gdth_flush(): flush ha %d drive %d\n", ha
->hanum
, i
));
4735 gdth_execute(ha
->shost
, &gdtcmd
, cmnd
, 30, NULL
);
4740 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
4741 /* shutdown routine */
4742 static int gdth_halt(struct notifier_block
*nb
, ulong event
, void *buf
)
4746 gdth_cmd_str gdtcmd
;
4747 char cmnd
[MAX_COMMAND_SIZE
];
4750 if (notifier_disabled
)
4753 TRACE2(("gdth_halt() event %d\n",(int)event
));
4754 if (event
!= SYS_RESTART
&& event
!= SYS_HALT
&& event
!= SYS_POWER_OFF
)
4757 notifier_disabled
= 1;
4758 printk("GDT-HA: Flushing all host drives .. ");
4759 list_for_each_entry(ha
, &gdth_instances
, list
) {
4763 /* controller reset */
4764 memset(cmnd
, 0xff, MAX_COMMAND_SIZE
);
4765 gdtcmd
.BoardNode
= LOCALBOARD
;
4766 gdtcmd
.Service
= CACHESERVICE
;
4767 gdtcmd
.OpCode
= GDT_RESET
;
4768 TRACE2(("gdth_halt(): reset controller %d\n", ha
->hanum
));
4769 gdth_execute(ha
->shost
, &gdtcmd
, cmnd
, 10, NULL
);
4774 #ifdef GDTH_STATISTICS
4775 del_timer(&gdth_timer
);
4781 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
4783 static int gdth_slave_configure(struct scsi_device
*sdev
)
4785 scsi_adjust_queue_depth(sdev
, 0, sdev
->host
->cmd_per_lun
);
4786 sdev
->skip_ms_page_3f
= 1;
4787 sdev
->skip_ms_page_8
= 1;
4791 static struct scsi_host_template gdth_template
= {
4792 .name
= "GDT SCSI Disk Array Controller",
4794 .queuecommand
= gdth_queuecommand
,
4795 .eh_bus_reset_handler
= gdth_eh_bus_reset
,
4796 .slave_configure
= gdth_slave_configure
,
4797 .bios_param
= gdth_bios_param
,
4798 .proc_info
= gdth_proc_info
,
4799 .proc_name
= "gdth",
4800 .can_queue
= GDTH_MAXCMDS
,
4802 .sg_tablesize
= GDTH_MAXSG
,
4803 .cmd_per_lun
= GDTH_MAXC_P_L
,
4804 .unchecked_isa_dma
= 1,
4805 .use_clustering
= ENABLE_CLUSTERING
,
4809 static int __init
gdth_isa_probe_one(ulong32 isa_bios
)
4811 struct Scsi_Host
*shp
;
4813 dma_addr_t scratch_dma_handle
= 0;
4816 if (!gdth_search_isa(isa_bios
))
4819 shp
= scsi_host_alloc(&gdth_template
, sizeof(gdth_ha_str
));
4822 ha
= shost_priv(shp
);
4825 if (!gdth_init_isa(isa_bios
,ha
))
4828 /* controller found and initialized */
4829 printk("Configuring GDT-ISA HA at BIOS 0x%05X IRQ %u DRQ %u\n",
4830 isa_bios
, ha
->irq
, ha
->drq
);
4832 error
= request_irq(ha
->irq
, gdth_interrupt
, IRQF_DISABLED
, "gdth", ha
);
4834 printk("GDT-ISA: Unable to allocate IRQ\n");
4838 error
= request_dma(ha
->drq
, "gdth");
4840 printk("GDT-ISA: Unable to allocate DMA channel\n");
4844 set_dma_mode(ha
->drq
,DMA_MODE_CASCADE
);
4845 enable_dma(ha
->drq
);
4846 shp
->unchecked_isa_dma
= 1;
4848 shp
->dma_channel
= ha
->drq
;
4850 ha
->hanum
= gdth_ctr_count
++;
4853 ha
->pccb
= &ha
->cmdext
;
4859 ha
->pscratch
= pci_alloc_consistent(ha
->pdev
, GDTH_SCRATCH
,
4860 &scratch_dma_handle
);
4862 goto out_dec_counters
;
4863 ha
->scratch_phys
= scratch_dma_handle
;
4865 ha
->pmsg
= pci_alloc_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
4866 &scratch_dma_handle
);
4868 goto out_free_pscratch
;
4869 ha
->msg_phys
= scratch_dma_handle
;
4872 ha
->coal_stat
= pci_alloc_consistent(ha
->pdev
,
4873 sizeof(gdth_coal_status
) * MAXOFFSETS
,
4874 &scratch_dma_handle
);
4877 ha
->coal_stat_phys
= scratch_dma_handle
;
4880 ha
->scratch_busy
= FALSE
;
4881 ha
->req_first
= NULL
;
4882 ha
->tid_cnt
= MAX_HDRIVES
;
4883 if (max_ids
> 0 && max_ids
< ha
->tid_cnt
)
4884 ha
->tid_cnt
= max_ids
;
4885 for (i
= 0; i
< GDTH_MAXCMDS
; ++i
)
4886 ha
->cmd_tab
[i
].cmnd
= UNUSED_CMND
;
4887 ha
->scan_mode
= rescan
? 0x10 : 0;
4890 if (!gdth_search_drives(ha
)) {
4891 printk("GDT-ISA: Error during device scan\n");
4892 goto out_free_coal_stat
;
4895 if (hdr_channel
< 0 || hdr_channel
> ha
->bus_cnt
)
4896 hdr_channel
= ha
->bus_cnt
;
4897 ha
->virt_bus
= hdr_channel
;
4899 if (ha
->cache_feat
& ha
->raw_feat
& ha
->screen_feat
& GDT_64BIT
)
4900 shp
->max_cmd_len
= 16;
4902 shp
->max_id
= ha
->tid_cnt
;
4903 shp
->max_lun
= MAXLUN
;
4904 shp
->max_channel
= ha
->bus_cnt
;
4906 spin_lock_init(&ha
->smp_lock
);
4907 gdth_enable_int(ha
);
4909 error
= scsi_add_host(shp
, NULL
);
4911 goto out_free_coal_stat
;
4912 list_add_tail(&ha
->list
, &gdth_instances
);
4914 scsi_scan_host(shp
);
4920 pci_free_consistent(ha
->pdev
, sizeof(gdth_coal_status
) * MAXOFFSETS
,
4921 ha
->coal_stat
, ha
->coal_stat_phys
);
4924 pci_free_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
4925 ha
->pmsg
, ha
->msg_phys
);
4927 pci_free_consistent(ha
->pdev
, GDTH_SCRATCH
,
4928 ha
->pscratch
, ha
->scratch_phys
);
4932 free_irq(ha
->irq
, ha
);
4937 #endif /* CONFIG_ISA */
4940 static int __init
gdth_eisa_probe_one(ushort eisa_slot
)
4942 struct Scsi_Host
*shp
;
4944 dma_addr_t scratch_dma_handle
= 0;
4947 if (!gdth_search_eisa(eisa_slot
))
4950 shp
= scsi_host_alloc(&gdth_template
, sizeof(gdth_ha_str
));
4953 ha
= shost_priv(shp
);
4956 if (!gdth_init_eisa(eisa_slot
,ha
))
4959 /* controller found and initialized */
4960 printk("Configuring GDT-EISA HA at Slot %d IRQ %u\n",
4961 eisa_slot
>> 12, ha
->irq
);
4963 error
= request_irq(ha
->irq
, gdth_interrupt
, IRQF_DISABLED
, "gdth", ha
);
4965 printk("GDT-EISA: Unable to allocate IRQ\n");
4969 shp
->unchecked_isa_dma
= 0;
4971 shp
->dma_channel
= 0xff;
4973 ha
->hanum
= gdth_ctr_count
++;
4976 TRACE2(("EISA detect Bus 0: hanum %d\n", ha
->hanum
));
4978 ha
->pccb
= &ha
->cmdext
;
4984 ha
->pscratch
= pci_alloc_consistent(ha
->pdev
, GDTH_SCRATCH
,
4985 &scratch_dma_handle
);
4988 ha
->scratch_phys
= scratch_dma_handle
;
4990 ha
->pmsg
= pci_alloc_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
4991 &scratch_dma_handle
);
4993 goto out_free_pscratch
;
4994 ha
->msg_phys
= scratch_dma_handle
;
4997 ha
->coal_stat
= pci_alloc_consistent(ha
->pdev
,
4998 sizeof(gdth_coal_status
) * MAXOFFSETS
,
4999 &scratch_dma_handle
);
5002 ha
->coal_stat_phys
= scratch_dma_handle
;
5005 ha
->ccb_phys
= pci_map_single(ha
->pdev
,ha
->pccb
,
5006 sizeof(gdth_cmd_str
), PCI_DMA_BIDIRECTIONAL
);
5008 goto out_free_coal_stat
;
5010 ha
->scratch_busy
= FALSE
;
5011 ha
->req_first
= NULL
;
5012 ha
->tid_cnt
= MAX_HDRIVES
;
5013 if (max_ids
> 0 && max_ids
< ha
->tid_cnt
)
5014 ha
->tid_cnt
= max_ids
;
5015 for (i
= 0; i
< GDTH_MAXCMDS
; ++i
)
5016 ha
->cmd_tab
[i
].cmnd
= UNUSED_CMND
;
5017 ha
->scan_mode
= rescan
? 0x10 : 0;
5019 if (!gdth_search_drives(ha
)) {
5020 printk("GDT-EISA: Error during device scan\n");
5022 goto out_free_ccb_phys
;
5025 if (hdr_channel
< 0 || hdr_channel
> ha
->bus_cnt
)
5026 hdr_channel
= ha
->bus_cnt
;
5027 ha
->virt_bus
= hdr_channel
;
5029 if (ha
->cache_feat
& ha
->raw_feat
& ha
->screen_feat
& GDT_64BIT
)
5030 shp
->max_cmd_len
= 16;
5032 shp
->max_id
= ha
->tid_cnt
;
5033 shp
->max_lun
= MAXLUN
;
5034 shp
->max_channel
= ha
->bus_cnt
;
5036 spin_lock_init(&ha
->smp_lock
);
5037 gdth_enable_int(ha
);
5039 error
= scsi_add_host(shp
, NULL
);
5041 goto out_free_coal_stat
;
5042 list_add_tail(&ha
->list
, &gdth_instances
);
5044 scsi_scan_host(shp
);
5049 pci_unmap_single(ha
->pdev
,ha
->ccb_phys
, sizeof(gdth_cmd_str
),
5050 PCI_DMA_BIDIRECTIONAL
);
5053 pci_free_consistent(ha
->pdev
, sizeof(gdth_coal_status
) * MAXOFFSETS
,
5054 ha
->coal_stat
, ha
->coal_stat_phys
);
5057 pci_free_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
5058 ha
->pmsg
, ha
->msg_phys
);
5060 pci_free_consistent(ha
->pdev
, GDTH_SCRATCH
,
5061 ha
->pscratch
, ha
->scratch_phys
);
5063 free_irq(ha
->irq
, ha
);
5069 #endif /* CONFIG_EISA */
5072 static int __init
gdth_pci_probe_one(gdth_pci_str
*pcistr
, int ctr
)
5074 struct Scsi_Host
*shp
;
5076 dma_addr_t scratch_dma_handle
= 0;
5079 shp
= scsi_host_alloc(&gdth_template
, sizeof(gdth_ha_str
));
5082 ha
= shost_priv(shp
);
5085 if (!gdth_init_pci(&pcistr
[ctr
],ha
))
5088 /* controller found and initialized */
5089 printk("Configuring GDT-PCI HA at %d/%d IRQ %u\n",
5090 pcistr
[ctr
].pdev
->bus
->number
,
5091 PCI_SLOT(pcistr
[ctr
].pdev
->devfn
),
5094 error
= request_irq(ha
->irq
, gdth_interrupt
,
5095 IRQF_DISABLED
|IRQF_SHARED
, "gdth", ha
);
5097 printk("GDT-PCI: Unable to allocate IRQ\n");
5101 shp
->unchecked_isa_dma
= 0;
5103 shp
->dma_channel
= 0xff;
5105 ha
->hanum
= gdth_ctr_count
++;
5108 ha
->pccb
= &ha
->cmdext
;
5113 ha
->pscratch
= pci_alloc_consistent(ha
->pdev
, GDTH_SCRATCH
,
5114 &scratch_dma_handle
);
5117 ha
->scratch_phys
= scratch_dma_handle
;
5119 ha
->pmsg
= pci_alloc_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
5120 &scratch_dma_handle
);
5122 goto out_free_pscratch
;
5123 ha
->msg_phys
= scratch_dma_handle
;
5126 ha
->coal_stat
= pci_alloc_consistent(ha
->pdev
,
5127 sizeof(gdth_coal_status
) * MAXOFFSETS
,
5128 &scratch_dma_handle
);
5131 ha
->coal_stat_phys
= scratch_dma_handle
;
5134 ha
->scratch_busy
= FALSE
;
5135 ha
->req_first
= NULL
;
5136 ha
->tid_cnt
= pcistr
[ctr
].pdev
->device
>= 0x200 ? MAXID
: MAX_HDRIVES
;
5137 if (max_ids
> 0 && max_ids
< ha
->tid_cnt
)
5138 ha
->tid_cnt
= max_ids
;
5139 for (i
= 0; i
< GDTH_MAXCMDS
; ++i
)
5140 ha
->cmd_tab
[i
].cmnd
= UNUSED_CMND
;
5141 ha
->scan_mode
= rescan
? 0x10 : 0;
5144 if (!gdth_search_drives(ha
)) {
5145 printk("GDT-PCI %d: Error during device scan\n", ha
->hanum
);
5146 goto out_free_coal_stat
;
5149 if (hdr_channel
< 0 || hdr_channel
> ha
->bus_cnt
)
5150 hdr_channel
= ha
->bus_cnt
;
5151 ha
->virt_bus
= hdr_channel
;
5153 /* 64-bit DMA only supported from FW >= x.43 */
5154 if (!(ha
->cache_feat
& ha
->raw_feat
& ha
->screen_feat
& GDT_64BIT
) ||
5155 !ha
->dma64_support
) {
5156 if (pci_set_dma_mask(pcistr
[ctr
].pdev
, DMA_32BIT_MASK
)) {
5157 printk(KERN_WARNING
"GDT-PCI %d: "
5158 "Unable to set 32-bit DMA\n", ha
->hanum
);
5159 goto out_free_coal_stat
;
5162 shp
->max_cmd_len
= 16;
5163 if (!pci_set_dma_mask(pcistr
[ctr
].pdev
, DMA_64BIT_MASK
)) {
5164 printk("GDT-PCI %d: 64-bit DMA enabled\n", ha
->hanum
);
5165 } else if (pci_set_dma_mask(pcistr
[ctr
].pdev
, DMA_32BIT_MASK
)) {
5166 printk(KERN_WARNING
"GDT-PCI %d: "
5167 "Unable to set 64/32-bit DMA\n", ha
->hanum
);
5168 goto out_free_coal_stat
;
5172 shp
->max_id
= ha
->tid_cnt
;
5173 shp
->max_lun
= MAXLUN
;
5174 shp
->max_channel
= ha
->bus_cnt
;
5176 spin_lock_init(&ha
->smp_lock
);
5177 gdth_enable_int(ha
);
5179 error
= scsi_add_host(shp
, &pcistr
[ctr
].pdev
->dev
);
5181 goto out_free_coal_stat
;
5182 list_add_tail(&ha
->list
, &gdth_instances
);
5184 scsi_scan_host(shp
);
5190 pci_free_consistent(ha
->pdev
, sizeof(gdth_coal_status
) * MAXOFFSETS
,
5191 ha
->coal_stat
, ha
->coal_stat_phys
);
5194 pci_free_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
5195 ha
->pmsg
, ha
->msg_phys
);
5197 pci_free_consistent(ha
->pdev
, GDTH_SCRATCH
,
5198 ha
->pscratch
, ha
->scratch_phys
);
5200 free_irq(ha
->irq
, ha
);
5206 #endif /* CONFIG_PCI */
5208 static void gdth_remove_one(gdth_ha_str
*ha
)
5210 struct Scsi_Host
*shp
= ha
->shost
;
5212 TRACE2(("gdth_remove_one()\n"));
5214 scsi_remove_host(shp
);
5216 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
5220 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
5222 scsi_free_host_dev(ha
->sdev
);
5226 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
5230 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
5232 free_irq(shp
->irq
,ha
);
5235 if (shp
->dma_channel
!= 0xff)
5236 free_dma(shp
->dma_channel
);
5240 pci_free_consistent(ha
->pdev
, sizeof(gdth_coal_status
) *
5241 MAXOFFSETS
, ha
->coal_stat
, ha
->coal_stat_phys
);
5244 pci_free_consistent(ha
->pdev
, GDTH_SCRATCH
,
5245 ha
->pscratch
, ha
->scratch_phys
);
5247 pci_free_consistent(ha
->pdev
, sizeof(gdth_msg_str
),
5248 ha
->pmsg
, ha
->msg_phys
);
5250 pci_unmap_single(ha
->pdev
,ha
->ccb_phys
,
5251 sizeof(gdth_cmd_str
),PCI_DMA_BIDIRECTIONAL
);
5256 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
5258 static int gdth_halt(struct notifier_block
*nb
, ulong event
, void *buf
)
5262 TRACE2(("gdth_halt() event %d\n", (int)event
));
5263 if (event
!= SYS_RESTART
&& event
!= SYS_HALT
&& event
!= SYS_POWER_OFF
)
5266 list_for_each_entry(ha
, &gdth_instances
, list
)
5272 static struct notifier_block gdth_notifier
= {
5276 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
5277 static int __init
gdth_init(void)
5280 printk("GDT-HA: Controller driver disabled from"
5281 " command line !\n");
5285 printk("GDT-HA: Storage RAID Controller Driver. Version: %s\n",
5288 /* initializations */
5289 gdth_polling
= TRUE
;
5290 gdth_clear_events();
5292 /* As default we do not probe for EISA or ISA controllers */
5293 if (probe_eisa_isa
) {
5294 /* scanning for controllers, at first: ISA controller */
5297 for (isa_bios
= 0xc8000UL
; isa_bios
<= 0xd8000UL
;
5298 isa_bios
+= 0x8000UL
)
5299 gdth_isa_probe_one(isa_bios
);
5304 for (eisa_slot
= 0x1000; eisa_slot
<= 0x8000;
5305 eisa_slot
+= 0x1000)
5306 gdth_eisa_probe_one(eisa_slot
);
5312 /* scanning for PCI controllers */
5314 gdth_pci_str pcistr
[MAXHA
];
5317 cnt
= gdth_search_pci(pcistr
);
5318 printk("GDT-HA: Found %d PCI Storage RAID Controllers\n", cnt
);
5319 gdth_sort_pci(pcistr
,cnt
);
5320 for (ctr
= 0; ctr
< cnt
; ++ctr
)
5321 gdth_pci_probe_one(pcistr
, ctr
);
5323 #endif /* CONFIG_PCI */
5325 TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count
));
5327 if (list_empty(&gdth_instances
))
5330 #ifdef GDTH_STATISTICS
5331 TRACE2(("gdth_detect(): Initializing timer !\n"));
5332 init_timer(&gdth_timer
);
5333 gdth_timer
.expires
= jiffies
+ HZ
;
5334 gdth_timer
.data
= 0L;
5335 gdth_timer
.function
= gdth_timeout
;
5336 add_timer(&gdth_timer
);
5338 major
= register_chrdev(0,"gdth", &gdth_fops
);
5339 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
5340 notifier_disabled
= 0;
5342 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
5343 register_reboot_notifier(&gdth_notifier
);
5344 gdth_polling
= FALSE
;
5348 static void __exit
gdth_exit(void)
5352 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
5353 list_for_each_entry(ha
, &gdth_instances
, list
)
5354 gdth_remove_one(ha
);
5356 unregister_chrdev(major
, "gdth");
5357 unregister_reboot_notifier(&gdth_notifier
);
5358 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
5360 #ifdef GDTH_STATISTICS
5361 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
5362 del_timer(&gdth_timer
);
5364 del_timer_sync(&gdth_timer
);
5365 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
5367 <<<<<<< HEAD
:drivers
/scsi
/gdth
.c
5368 unregister_chrdev(major
,"gdth");
5369 unregister_reboot_notifier(&gdth_notifier
);
5372 list_for_each_entry(ha
, &gdth_instances
, list
)
5373 gdth_remove_one(ha
);
5374 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:drivers
/scsi
/gdth
.c
5377 module_init(gdth_init
);
5378 module_exit(gdth_exit
);
5381 __setup("gdth=", option_setup
);