Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: Drop gdth driver

The gdth driver refers to a SCSI parallel, PCI-only HBA RAID adapter which
was manufactured by the now-defunct ICP Vortex company, later acquired by
Adaptec and superseded by the aacraid series of controllers. The driver
itself would require a major overhaul before any modifications can be
attempted, but seeing that it's unlikely to have any users left it should
rather be removed completely.

Link: https://lore.kernel.org/r/20210113090500.129644-2-hare@suse.de
Cautiously-Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Hannes Reinecke and committed by
Martin K. Petersen
0653c358 bbb08767

+1 -6183
+1 -3
Documentation/kbuild/makefiles.rst
··· 461 461 462 462 # drivers/scsi/Makefile 463 463 CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF 464 - CFLAGS_gdth.o = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ \ 465 - -DGDTH_STATISTICS 466 464 467 - These two lines specify compilation flags for aha152x.o and gdth.o. 465 + This line specify compilation flags for aha152x.o. 468 466 469 467 $(AFLAGS_$@) is a similar feature for source files in assembly 470 468 languages.
-2
Documentation/process/magic-number.rst
··· 99 99 CG_MAGIC 0x00090255 ufs_cylinder_group ``include/linux/ufs_fs.h`` 100 100 RPORT_MAGIC 0x00525001 r_port ``drivers/char/rocket_int.h`` 101 101 LSEMAGIC 0x05091998 lse ``drivers/fc4/fc.c`` 102 - GDTIOCTL_MAGIC 0x06030f07 gdth_iowr_str ``drivers/scsi/gdth_ioctl.h`` 103 102 RIEBL_MAGIC 0x09051990 ``drivers/net/atarilance.c`` 104 103 NBD_REQUEST_MAGIC 0x12560953 nbd_request ``include/linux/nbd.h`` 105 104 RED_MAGIC2 0x170fc2a5 (any) ``mm/slab.c`` ··· 142 143 NBD_REPLY_MAGIC 0x96744668 nbd_reply ``include/linux/nbd.h`` 143 144 ENI155_MAGIC 0xa54b872d midway_eprom ``drivers/atm/eni.h`` 144 145 CODA_MAGIC 0xC0DAC0DA coda_file_info ``fs/coda/coda_fs_i.h`` 145 - DPMEM_MAGIC 0xc0ffee11 gdt_pci_sram ``drivers/scsi/gdth.h`` 146 146 YAM_MAGIC 0xF10A7654 yam_port ``drivers/net/hamradio/yam.c`` 147 147 CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c`` 148 148 QUEUE_MAGIC_FREE 0xf7e1c9a3 queue_entry ``drivers/scsi/arm/queue.c``
-3
Documentation/scsi/scsi-parameters.rst
··· 38 38 See drivers/scsi/BusLogic.c, comment before function 39 39 BusLogic_ParseDriverOptions(). 40 40 41 - gdth= [HW,SCSI] 42 - See header of drivers/scsi/gdth.c. 43 - 44 41 gvp11= [HW,SCSI] 45 42 46 43 ips= [HW,SCSI] Adaptec / IBM ServeRAID controller
-1
Documentation/userspace-api/ioctl/ioctl-number.rst
··· 157 157 'I' all linux/isdn.h conflict! 158 158 'I' 00-0F drivers/isdn/divert/isdn_divert.h conflict! 159 159 'I' 40-4F linux/mISDNif.h conflict! 160 - 'J' 00-1F drivers/scsi/gdth_ioctl.h 161 160 'K' all linux/kd.h 162 161 'L' 00-1F linux/loop.h conflict! 163 162 'L' 10-1F drivers/scsi/mpt3sas/mpt3sas_ctl.h conflict!
-14
drivers/scsi/Kconfig
··· 669 669 To compile this driver as a module, choose M here: the 670 670 module will be called fdomain_isa. 671 671 672 - config SCSI_GDTH 673 - tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller support" 674 - depends on PCI && SCSI 675 - help 676 - Formerly called GDT SCSI Disk Array Controller Support. 677 - 678 - This is a driver for RAID/SCSI Disk Array Controllers (EISA/ISA/PCI) 679 - manufactured by Intel Corporation/ICP vortex GmbH. It is documented 680 - in the kernel source in <file:drivers/scsi/gdth.c> and 681 - <file:drivers/scsi/gdth.h>. 682 - 683 - To compile this driver as a module, choose M here: the 684 - module will be called gdth. 685 - 686 672 config SCSI_ISCI 687 673 tristate "Intel(R) C600 Series Chipset SAS Controller" 688 674 depends on PCI && SCSI
-2
drivers/scsi/Makefile
··· 16 16 17 17 18 18 CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF 19 - CFLAGS_gdth.o = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ -DGDTH_STATISTICS 20 19 21 20 obj-$(CONFIG_PCMCIA) += pcmcia/ 22 21 ··· 102 103 obj-$(CONFIG_SCSI_UFSHCD) += ufs/ 103 104 obj-$(CONFIG_SCSI_ACARD) += atp870u.o 104 105 obj-$(CONFIG_SCSI_SUNESP) += esp_scsi.o sun_esp.o 105 - obj-$(CONFIG_SCSI_GDTH) += gdth.o 106 106 obj-$(CONFIG_SCSI_INITIO) += initio.o 107 107 obj-$(CONFIG_SCSI_INIA100) += a100u2w.o 108 108 obj-$(CONFIG_SCSI_QLOGICPTI) += qlogicpti.o
-4322
drivers/scsi/gdth.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /************************************************************************ 3 - * Linux driver for * 4 - * ICP vortex GmbH: GDT PCI Disk Array Controllers * 5 - * Intel Corporation: Storage RAID Controllers * 6 - * * 7 - * gdth.c * 8 - * Copyright (C) 1995-06 ICP vortex GmbH, Achim Leubner * 9 - * Copyright (C) 2002-04 Intel Corporation * 10 - * Copyright (C) 2003-06 Adaptec Inc. * 11 - * <achim_leubner@adaptec.com> * 12 - * * 13 - * Additions/Fixes: * 14 - * Boji Tony Kannanthanam <boji.t.kannanthanam@intel.com> * 15 - * Johannes Dinner <johannes_dinner@adaptec.com> * 16 - * * 17 - * * 18 - * Linux kernel 2.6.x supported * 19 - * * 20 - ************************************************************************/ 21 - 22 - /* All GDT Disk Array Controllers are fully supported by this driver. 23 - * This includes the PCI SCSI Disk Array Controllers and the 24 - * PCI Fibre Channel Disk Array Controllers. See gdth.h for a complete 25 - * list of all controller types. 26 - * 27 - * After the optional list of IRQ values, other possible 28 - * command line options are: 29 - * disable:Y disable driver 30 - * disable:N enable driver 31 - * reserve_mode:0 reserve no drives for the raw service 32 - * reserve_mode:1 reserve all not init., removable drives 33 - * reserve_mode:2 reserve all not init. drives 34 - * reserve_list:h,b,t,l,h,b,t,l,... reserve particular drive(s) with 35 - * h- controller no., b- channel no., 36 - * t- target ID, l- LUN 37 - * reverse_scan:Y reverse scan order for PCI controllers 38 - * reverse_scan:N scan PCI controllers like BIOS 39 - * max_ids:x x - target ID count per channel (1..MAXID) 40 - * rescan:Y rescan all channels/IDs 41 - * rescan:N use all devices found until now 42 - * hdr_channel:x x - number of virtual bus for host drives 43 - * shared_access:Y disable driver reserve/release protocol to 44 - * access a shared resource from several nodes, 45 - * appropriate controller firmware required 46 - * shared_access:N enable driver reserve/release protocol 47 - * force_dma32:Y use only 32 bit DMA mode 48 - * force_dma32:N use 64 bit DMA mode, if supported 49 - * 50 - * The default values are: "gdth=disable:N,reserve_mode:1,reverse_scan:N, 51 - * max_ids:127,rescan:N,hdr_channel:0, 52 - * shared_access:Y,force_dma32:N". 53 - * Here is another example: "gdth=reserve_list:0,1,2,0,0,1,3,0,rescan:Y". 54 - * 55 - * When loading the gdth driver as a module, the same options are available. 56 - * You can set the IRQs with "IRQ=...". However, the syntax to specify the 57 - * options changes slightly. You must replace all ',' between options 58 - * with ' ' and all ':' with '=' and you must use 59 - * '1' in place of 'Y' and '0' in place of 'N'. 60 - * 61 - * Default: "modprobe gdth disable=0 reserve_mode=1 reverse_scan=0 62 - * max_ids=127 rescan=0 hdr_channel=0 shared_access=0 63 - * force_dma32=0" 64 - * The other example: "modprobe gdth reserve_list=0,1,2,0,0,1,3,0 rescan=1". 65 - */ 66 - 67 - /* The meaning of the Scsi_Pointer members in this driver is as follows: 68 - * ptr: Chaining 69 - * this_residual: unused 70 - * buffer: unused 71 - * dma_handle: unused 72 - * buffers_residual: unused 73 - * Status: unused 74 - * Message: unused 75 - * have_data_in: unused 76 - * sent_command: unused 77 - * phase: unused 78 - */ 79 - 80 - /* statistics */ 81 - #define GDTH_STATISTICS 82 - 83 - #include <linux/module.h> 84 - 85 - #include <linux/version.h> 86 - #include <linux/kernel.h> 87 - #include <linux/types.h> 88 - #include <linux/pci.h> 89 - #include <linux/string.h> 90 - #include <linux/ctype.h> 91 - #include <linux/ioport.h> 92 - #include <linux/delay.h> 93 - #include <linux/interrupt.h> 94 - #include <linux/in.h> 95 - #include <linux/proc_fs.h> 96 - #include <linux/time.h> 97 - #include <linux/timer.h> 98 - #include <linux/dma-mapping.h> 99 - #include <linux/list.h> 100 - #include <linux/mutex.h> 101 - #include <linux/slab.h> 102 - #include <linux/reboot.h> 103 - 104 - #include <asm/dma.h> 105 - #include <asm/io.h> 106 - #include <linux/uaccess.h> 107 - #include <linux/spinlock.h> 108 - #include <linux/blkdev.h> 109 - #include <linux/scatterlist.h> 110 - 111 - #include "scsi.h" 112 - #include <scsi/scsi_host.h> 113 - #include "gdth.h" 114 - 115 - static DEFINE_MUTEX(gdth_mutex); 116 - static void gdth_delay(int milliseconds); 117 - static void gdth_eval_mapping(u32 size, u32 *cyls, int *heads, int *secs); 118 - static irqreturn_t gdth_interrupt(int irq, void *dev_id); 119 - static irqreturn_t __gdth_interrupt(gdth_ha_str *ha, 120 - int gdth_from_wait, int* pIndex); 121 - static int gdth_sync_event(gdth_ha_str *ha, int service, u8 index, 122 - struct scsi_cmnd *scp); 123 - static int gdth_async_event(gdth_ha_str *ha); 124 - static void gdth_log_event(gdth_evt_data *dvr, char *buffer); 125 - 126 - static void gdth_putq(gdth_ha_str *ha, struct scsi_cmnd *scp, u8 priority); 127 - static void gdth_next(gdth_ha_str *ha); 128 - static int gdth_fill_raw_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp, u8 b); 129 - static int gdth_special_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp); 130 - static gdth_evt_str *gdth_store_event(gdth_ha_str *ha, u16 source, 131 - u16 idx, gdth_evt_data *evt); 132 - static int gdth_read_event(gdth_ha_str *ha, int handle, gdth_evt_str *estr); 133 - static void gdth_readapp_event(gdth_ha_str *ha, u8 application, 134 - gdth_evt_str *estr); 135 - static void gdth_clear_events(void); 136 - 137 - static void gdth_copy_internal_data(gdth_ha_str *ha, struct scsi_cmnd *scp, 138 - char *buffer, u16 count); 139 - static int gdth_internal_cache_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp); 140 - static int gdth_fill_cache_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp, 141 - u16 hdrive); 142 - 143 - static void gdth_enable_int(gdth_ha_str *ha); 144 - static int gdth_test_busy(gdth_ha_str *ha); 145 - static int gdth_get_cmd_index(gdth_ha_str *ha); 146 - static void gdth_release_event(gdth_ha_str *ha); 147 - static int gdth_wait(gdth_ha_str *ha, int index,u32 time); 148 - static int gdth_internal_cmd(gdth_ha_str *ha, u8 service, u16 opcode, 149 - u32 p1, u64 p2,u64 p3); 150 - static int gdth_search_drives(gdth_ha_str *ha); 151 - static int gdth_analyse_hdrive(gdth_ha_str *ha, u16 hdrive); 152 - 153 - static const char *gdth_ctr_name(gdth_ha_str *ha); 154 - 155 - static int gdth_open(struct inode *inode, struct file *filep); 156 - static int gdth_close(struct inode *inode, struct file *filep); 157 - static long gdth_unlocked_ioctl(struct file *filep, unsigned int cmd, 158 - unsigned long arg); 159 - 160 - static void gdth_flush(gdth_ha_str *ha); 161 - static int gdth_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd); 162 - static int __gdth_queuecommand(gdth_ha_str *ha, struct scsi_cmnd *scp, 163 - struct gdth_cmndinfo *cmndinfo); 164 - static void gdth_scsi_done(struct scsi_cmnd *scp); 165 - 166 - #ifdef DEBUG_GDTH 167 - static u8 DebugState = DEBUG_GDTH; 168 - #define TRACE(a) {if (DebugState==1) {printk a;}} 169 - #define TRACE2(a) {if (DebugState==1 || DebugState==2) {printk a;}} 170 - #define TRACE3(a) {if (DebugState!=0) {printk a;}} 171 - #else /* !DEBUG */ 172 - #define TRACE(a) 173 - #define TRACE2(a) 174 - #define TRACE3(a) 175 - #endif 176 - 177 - #ifdef GDTH_STATISTICS 178 - static u32 max_rq=0, max_index=0, max_sg=0; 179 - static u32 act_ints=0, act_ios=0, act_stats=0, act_rq=0; 180 - static struct timer_list gdth_timer; 181 - #endif 182 - 183 - #define PTR2USHORT(a) (u16)(unsigned long)(a) 184 - #define GDTOFFSOF(a,b) (size_t)&(((a*)0)->b) 185 - #define INDEX_OK(i,t) ((i)<ARRAY_SIZE(t)) 186 - 187 - #define BUS_L2P(a,b) ((b)>(a)->virt_bus ? (b-1):(b)) 188 - 189 - static u8 gdth_polling; /* polling if TRUE */ 190 - static int gdth_ctr_count = 0; /* controller count */ 191 - static LIST_HEAD(gdth_instances); /* controller list */ 192 - static u8 gdth_write_through = FALSE; /* write through */ 193 - static gdth_evt_str ebuffer[MAX_EVENTS]; /* event buffer */ 194 - static int elastidx; 195 - static int eoldidx; 196 - static int major; 197 - 198 - #define DIN 1 /* IN data direction */ 199 - #define DOU 2 /* OUT data direction */ 200 - #define DNO DIN /* no data transfer */ 201 - #define DUN DIN /* unknown data direction */ 202 - static u8 gdth_direction_tab[0x100] = { 203 - DNO,DNO,DIN,DIN,DOU,DIN,DIN,DOU,DIN,DUN,DOU,DOU,DUN,DUN,DUN,DIN, 204 - DNO,DIN,DIN,DOU,DIN,DOU,DNO,DNO,DOU,DNO,DIN,DNO,DIN,DOU,DNO,DUN, 205 - DIN,DUN,DIN,DUN,DOU,DIN,DUN,DUN,DIN,DIN,DOU,DNO,DUN,DIN,DOU,DOU, 206 - DOU,DOU,DOU,DNO,DIN,DNO,DNO,DIN,DOU,DOU,DOU,DOU,DIN,DOU,DIN,DOU, 207 - DOU,DOU,DIN,DIN,DIN,DNO,DUN,DNO,DNO,DNO,DUN,DNO,DOU,DIN,DUN,DUN, 208 - DUN,DUN,DUN,DUN,DUN,DOU,DUN,DUN,DUN,DUN,DIN,DUN,DUN,DUN,DUN,DUN, 209 - DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN, 210 - DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN, 211 - DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DIN,DUN,DOU,DUN,DUN,DUN,DUN,DUN, 212 - DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DIN,DUN, 213 - DUN,DUN,DUN,DUN,DUN,DNO,DNO,DUN,DIN,DNO,DOU,DUN,DNO,DUN,DOU,DOU, 214 - DOU,DOU,DOU,DNO,DUN,DIN,DOU,DIN,DIN,DUN,DUN,DUN,DUN,DUN,DUN,DUN, 215 - DUN,DUN,DOU,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN, 216 - DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN, 217 - DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DOU,DUN,DUN,DUN,DUN,DUN, 218 - DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN 219 - }; 220 - 221 - /* LILO and modprobe/insmod parameters */ 222 - /* disable driver flag */ 223 - static int disable __initdata = 0; 224 - /* reserve flag */ 225 - static int reserve_mode = 1; 226 - /* reserve list */ 227 - static int reserve_list[MAX_RES_ARGS] = 228 - {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 229 - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 230 - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; 231 - /* scan order for PCI controllers */ 232 - static int reverse_scan = 0; 233 - /* virtual channel for the host drives */ 234 - static int hdr_channel = 0; 235 - /* max. IDs per channel */ 236 - static int max_ids = MAXID; 237 - /* rescan all IDs */ 238 - static int rescan = 0; 239 - /* shared access */ 240 - static int shared_access = 1; 241 - /* 64 bit DMA mode, support for drives > 2 TB, if force_dma32 = 0 */ 242 - static int force_dma32 = 0; 243 - 244 - /* parameters for modprobe/insmod */ 245 - module_param(disable, int, 0); 246 - module_param(reserve_mode, int, 0); 247 - module_param_array(reserve_list, int, NULL, 0); 248 - module_param(reverse_scan, int, 0); 249 - module_param(hdr_channel, int, 0); 250 - module_param(max_ids, int, 0); 251 - module_param(rescan, int, 0); 252 - module_param(shared_access, int, 0); 253 - module_param(force_dma32, int, 0); 254 - MODULE_AUTHOR("Achim Leubner"); 255 - MODULE_LICENSE("GPL"); 256 - 257 - /* ioctl interface */ 258 - static const struct file_operations gdth_fops = { 259 - .unlocked_ioctl = gdth_unlocked_ioctl, 260 - .open = gdth_open, 261 - .release = gdth_close, 262 - .llseek = noop_llseek, 263 - }; 264 - 265 - #include "gdth_proc.h" 266 - #include "gdth_proc.c" 267 - 268 - static gdth_ha_str *gdth_find_ha(int hanum) 269 - { 270 - gdth_ha_str *ha; 271 - 272 - list_for_each_entry(ha, &gdth_instances, list) 273 - if (hanum == ha->hanum) 274 - return ha; 275 - 276 - return NULL; 277 - } 278 - 279 - static struct gdth_cmndinfo *gdth_get_cmndinfo(gdth_ha_str *ha) 280 - { 281 - struct gdth_cmndinfo *priv = NULL; 282 - unsigned long flags; 283 - int i; 284 - 285 - spin_lock_irqsave(&ha->smp_lock, flags); 286 - 287 - for (i=0; i<GDTH_MAXCMDS; ++i) { 288 - if (ha->cmndinfo[i].index == 0) { 289 - priv = &ha->cmndinfo[i]; 290 - memset(priv, 0, sizeof(*priv)); 291 - priv->index = i+1; 292 - break; 293 - } 294 - } 295 - 296 - spin_unlock_irqrestore(&ha->smp_lock, flags); 297 - 298 - return priv; 299 - } 300 - 301 - static void gdth_put_cmndinfo(struct gdth_cmndinfo *priv) 302 - { 303 - BUG_ON(!priv); 304 - priv->index = 0; 305 - } 306 - 307 - static void gdth_delay(int milliseconds) 308 - { 309 - if (milliseconds == 0) { 310 - udelay(1); 311 - } else { 312 - mdelay(milliseconds); 313 - } 314 - } 315 - 316 - static void gdth_scsi_done(struct scsi_cmnd *scp) 317 - { 318 - struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp); 319 - int internal_command = cmndinfo->internal_command; 320 - 321 - TRACE2(("gdth_scsi_done()\n")); 322 - 323 - gdth_put_cmndinfo(cmndinfo); 324 - scp->host_scribble = NULL; 325 - 326 - if (internal_command) 327 - complete((struct completion *)scp->request); 328 - else 329 - scp->scsi_done(scp); 330 - } 331 - 332 - static int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, 333 - char *cmnd, int timeout, u32 *info) 334 - { 335 - gdth_ha_str *ha = shost_priv(sdev->host); 336 - struct scsi_cmnd *scp; 337 - struct gdth_cmndinfo cmndinfo; 338 - DECLARE_COMPLETION_ONSTACK(wait); 339 - int rval; 340 - 341 - scp = kzalloc(sizeof(*scp), GFP_KERNEL); 342 - if (!scp) 343 - return -ENOMEM; 344 - 345 - scp->sense_buffer = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); 346 - if (!scp->sense_buffer) { 347 - kfree(scp); 348 - return -ENOMEM; 349 - } 350 - 351 - scp->device = sdev; 352 - memset(&cmndinfo, 0, sizeof(cmndinfo)); 353 - 354 - /* use request field to save the ptr. to completion struct. */ 355 - scp->request = (struct request *)&wait; 356 - scp->cmd_len = 12; 357 - scp->cmnd = cmnd; 358 - cmndinfo.priority = IOCTL_PRI; 359 - cmndinfo.internal_cmd_str = gdtcmd; 360 - cmndinfo.internal_command = 1; 361 - 362 - TRACE(("__gdth_execute() cmd 0x%x\n", scp->cmnd[0])); 363 - __gdth_queuecommand(ha, scp, &cmndinfo); 364 - 365 - wait_for_completion(&wait); 366 - 367 - rval = cmndinfo.status; 368 - if (info) 369 - *info = cmndinfo.info; 370 - kfree(scp->sense_buffer); 371 - kfree(scp); 372 - return rval; 373 - } 374 - 375 - int gdth_execute(struct Scsi_Host *shost, gdth_cmd_str *gdtcmd, char *cmnd, 376 - int timeout, u32 *info) 377 - { 378 - struct scsi_device *sdev = scsi_get_host_dev(shost); 379 - int rval = __gdth_execute(sdev, gdtcmd, cmnd, timeout, info); 380 - 381 - scsi_free_host_dev(sdev); 382 - return rval; 383 - } 384 - 385 - static void gdth_eval_mapping(u32 size, u32 *cyls, int *heads, int *secs) 386 - { 387 - *cyls = size /HEADS/SECS; 388 - if (*cyls <= MAXCYLS) { 389 - *heads = HEADS; 390 - *secs = SECS; 391 - } else { /* too high for 64*32 */ 392 - *cyls = size /MEDHEADS/MEDSECS; 393 - if (*cyls <= MAXCYLS) { 394 - *heads = MEDHEADS; 395 - *secs = MEDSECS; 396 - } else { /* too high for 127*63 */ 397 - *cyls = size /BIGHEADS/BIGSECS; 398 - *heads = BIGHEADS; 399 - *secs = BIGSECS; 400 - } 401 - } 402 - } 403 - 404 - static bool gdth_search_vortex(u16 device) 405 - { 406 - if (device <= PCI_DEVICE_ID_VORTEX_GDT6555) 407 - return true; 408 - if (device >= PCI_DEVICE_ID_VORTEX_GDT6x17RP && 409 - device <= PCI_DEVICE_ID_VORTEX_GDTMAXRP) 410 - return true; 411 - if (device == PCI_DEVICE_ID_VORTEX_GDTNEWRX || 412 - device == PCI_DEVICE_ID_VORTEX_GDTNEWRX2) 413 - return true; 414 - return false; 415 - } 416 - 417 - static int gdth_pci_probe_one(gdth_pci_str *pcistr, gdth_ha_str **ha_out); 418 - static int gdth_pci_init_one(struct pci_dev *pdev, 419 - const struct pci_device_id *ent); 420 - static void gdth_pci_remove_one(struct pci_dev *pdev); 421 - static void gdth_remove_one(gdth_ha_str *ha); 422 - 423 - /* Vortex only makes RAID controllers. 424 - * We do not really want to specify all 550 ids here, so wildcard match. 425 - */ 426 - static const struct pci_device_id gdthtable[] = { 427 - { PCI_VDEVICE(VORTEX, PCI_ANY_ID) }, 428 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_SRC) }, 429 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_SRC_XSCALE) }, 430 - { } /* terminate list */ 431 - }; 432 - MODULE_DEVICE_TABLE(pci, gdthtable); 433 - 434 - static struct pci_driver gdth_pci_driver = { 435 - .name = "gdth", 436 - .id_table = gdthtable, 437 - .probe = gdth_pci_init_one, 438 - .remove = gdth_pci_remove_one, 439 - }; 440 - 441 - static void gdth_pci_remove_one(struct pci_dev *pdev) 442 - { 443 - gdth_ha_str *ha = pci_get_drvdata(pdev); 444 - 445 - list_del(&ha->list); 446 - gdth_remove_one(ha); 447 - 448 - pci_disable_device(pdev); 449 - } 450 - 451 - static int gdth_pci_init_one(struct pci_dev *pdev, 452 - const struct pci_device_id *ent) 453 - { 454 - u16 vendor = pdev->vendor; 455 - u16 device = pdev->device; 456 - unsigned long base0, base1, base2; 457 - int rc; 458 - gdth_pci_str gdth_pcistr; 459 - gdth_ha_str *ha = NULL; 460 - 461 - TRACE(("gdth_search_dev() cnt %d vendor %x device %x\n", 462 - gdth_ctr_count, vendor, device)); 463 - 464 - memset(&gdth_pcistr, 0, sizeof(gdth_pcistr)); 465 - 466 - if (vendor == PCI_VENDOR_ID_VORTEX && !gdth_search_vortex(device)) 467 - return -ENODEV; 468 - 469 - rc = pci_enable_device(pdev); 470 - if (rc) 471 - return rc; 472 - 473 - if (gdth_ctr_count >= MAXHA) 474 - return -EBUSY; 475 - 476 - /* GDT PCI controller found, resources are already in pdev */ 477 - gdth_pcistr.pdev = pdev; 478 - base0 = pci_resource_flags(pdev, 0); 479 - base1 = pci_resource_flags(pdev, 1); 480 - base2 = pci_resource_flags(pdev, 2); 481 - if (device <= PCI_DEVICE_ID_VORTEX_GDT6000B || /* GDT6000/B */ 482 - device >= PCI_DEVICE_ID_VORTEX_GDT6x17RP) { /* MPR */ 483 - if (!(base0 & IORESOURCE_MEM)) 484 - return -ENODEV; 485 - gdth_pcistr.dpmem = pci_resource_start(pdev, 0); 486 - } else { /* GDT6110, GDT6120, .. */ 487 - if (!(base0 & IORESOURCE_MEM) || 488 - !(base2 & IORESOURCE_MEM) || 489 - !(base1 & IORESOURCE_IO)) 490 - return -ENODEV; 491 - gdth_pcistr.dpmem = pci_resource_start(pdev, 2); 492 - gdth_pcistr.io = pci_resource_start(pdev, 1); 493 - } 494 - TRACE2(("Controller found at %d/%d, irq %d, dpmem 0x%lx\n", 495 - gdth_pcistr.pdev->bus->number, 496 - PCI_SLOT(gdth_pcistr.pdev->devfn), 497 - gdth_pcistr.irq, 498 - gdth_pcistr.dpmem)); 499 - 500 - rc = gdth_pci_probe_one(&gdth_pcistr, &ha); 501 - if (rc) 502 - return rc; 503 - 504 - return 0; 505 - } 506 - 507 - static int gdth_init_pci(struct pci_dev *pdev, gdth_pci_str *pcistr, 508 - gdth_ha_str *ha) 509 - { 510 - register gdt6_dpram_str __iomem *dp6_ptr; 511 - register gdt6c_dpram_str __iomem *dp6c_ptr; 512 - register gdt6m_dpram_str __iomem *dp6m_ptr; 513 - u32 retries; 514 - u8 prot_ver; 515 - u16 command; 516 - int i, found = FALSE; 517 - 518 - TRACE(("gdth_init_pci()\n")); 519 - 520 - if (pdev->vendor == PCI_VENDOR_ID_INTEL) 521 - ha->oem_id = OEM_ID_INTEL; 522 - else 523 - ha->oem_id = OEM_ID_ICP; 524 - ha->brd_phys = (pdev->bus->number << 8) | (pdev->devfn & 0xf8); 525 - ha->stype = (u32)pdev->device; 526 - ha->irq = pdev->irq; 527 - ha->pdev = pdev; 528 - 529 - if (ha->pdev->device <= PCI_DEVICE_ID_VORTEX_GDT6000B) { /* GDT6000/B */ 530 - TRACE2(("init_pci() dpmem %lx irq %d\n",pcistr->dpmem,ha->irq)); 531 - ha->brd = ioremap(pcistr->dpmem, sizeof(gdt6_dpram_str)); 532 - if (ha->brd == NULL) { 533 - printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); 534 - return 0; 535 - } 536 - /* check and reset interface area */ 537 - dp6_ptr = ha->brd; 538 - writel(DPMEM_MAGIC, &dp6_ptr->u); 539 - if (readl(&dp6_ptr->u) != DPMEM_MAGIC) { 540 - printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n", 541 - pcistr->dpmem); 542 - found = FALSE; 543 - for (i = 0xC8000; i < 0xE8000; i += 0x4000) { 544 - iounmap(ha->brd); 545 - ha->brd = ioremap(i, sizeof(u16)); 546 - if (ha->brd == NULL) { 547 - printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); 548 - return 0; 549 - } 550 - if (readw(ha->brd) != 0xffff) { 551 - TRACE2(("init_pci_old() address 0x%x busy\n", i)); 552 - continue; 553 - } 554 - iounmap(ha->brd); 555 - pci_write_config_dword(pdev, PCI_BASE_ADDRESS_0, i); 556 - ha->brd = ioremap(i, sizeof(gdt6_dpram_str)); 557 - if (ha->brd == NULL) { 558 - printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); 559 - return 0; 560 - } 561 - dp6_ptr = ha->brd; 562 - writel(DPMEM_MAGIC, &dp6_ptr->u); 563 - if (readl(&dp6_ptr->u) == DPMEM_MAGIC) { 564 - printk("GDT-PCI: Use free address at 0x%x\n", i); 565 - found = TRUE; 566 - break; 567 - } 568 - } 569 - if (!found) { 570 - printk("GDT-PCI: No free address found!\n"); 571 - iounmap(ha->brd); 572 - return 0; 573 - } 574 - } 575 - memset_io(&dp6_ptr->u, 0, sizeof(dp6_ptr->u)); 576 - if (readl(&dp6_ptr->u) != 0) { 577 - printk("GDT-PCI: Initialization error (DPMEM write error)\n"); 578 - iounmap(ha->brd); 579 - return 0; 580 - } 581 - 582 - /* disable board interrupts, deinit services */ 583 - writeb(0xff, &dp6_ptr->io.irqdel); 584 - writeb(0x00, &dp6_ptr->io.irqen); 585 - writeb(0x00, &dp6_ptr->u.ic.S_Status); 586 - writeb(0x00, &dp6_ptr->u.ic.Cmd_Index); 587 - 588 - writel(pcistr->dpmem, &dp6_ptr->u.ic.S_Info[0]); 589 - writeb(0xff, &dp6_ptr->u.ic.S_Cmd_Indx); 590 - writeb(0, &dp6_ptr->io.event); 591 - retries = INIT_RETRIES; 592 - gdth_delay(20); 593 - while (readb(&dp6_ptr->u.ic.S_Status) != 0xff) { 594 - if (--retries == 0) { 595 - printk("GDT-PCI: Initialization error (DEINIT failed)\n"); 596 - iounmap(ha->brd); 597 - return 0; 598 - } 599 - gdth_delay(1); 600 - } 601 - prot_ver = (u8)readl(&dp6_ptr->u.ic.S_Info[0]); 602 - writeb(0, &dp6_ptr->u.ic.S_Status); 603 - writeb(0xff, &dp6_ptr->io.irqdel); 604 - if (prot_ver != PROTOCOL_VERSION) { 605 - printk("GDT-PCI: Illegal protocol version\n"); 606 - iounmap(ha->brd); 607 - return 0; 608 - } 609 - 610 - ha->type = GDT_PCI; 611 - ha->ic_all_size = sizeof(dp6_ptr->u); 612 - 613 - /* special command to controller BIOS */ 614 - writel(0x00, &dp6_ptr->u.ic.S_Info[0]); 615 - writel(0x00, &dp6_ptr->u.ic.S_Info[1]); 616 - writel(0x00, &dp6_ptr->u.ic.S_Info[2]); 617 - writel(0x00, &dp6_ptr->u.ic.S_Info[3]); 618 - writeb(0xfe, &dp6_ptr->u.ic.S_Cmd_Indx); 619 - writeb(0, &dp6_ptr->io.event); 620 - retries = INIT_RETRIES; 621 - gdth_delay(20); 622 - while (readb(&dp6_ptr->u.ic.S_Status) != 0xfe) { 623 - if (--retries == 0) { 624 - printk("GDT-PCI: Initialization error\n"); 625 - iounmap(ha->brd); 626 - return 0; 627 - } 628 - gdth_delay(1); 629 - } 630 - writeb(0, &dp6_ptr->u.ic.S_Status); 631 - writeb(0xff, &dp6_ptr->io.irqdel); 632 - 633 - ha->dma64_support = 0; 634 - 635 - } else if (ha->pdev->device <= PCI_DEVICE_ID_VORTEX_GDT6555) { /* GDT6110, ... */ 636 - ha->plx = (gdt6c_plx_regs *)pcistr->io; 637 - TRACE2(("init_pci_new() dpmem %lx irq %d\n", 638 - pcistr->dpmem,ha->irq)); 639 - ha->brd = ioremap(pcistr->dpmem, sizeof(gdt6c_dpram_str)); 640 - if (ha->brd == NULL) { 641 - printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); 642 - iounmap(ha->brd); 643 - return 0; 644 - } 645 - /* check and reset interface area */ 646 - dp6c_ptr = ha->brd; 647 - writel(DPMEM_MAGIC, &dp6c_ptr->u); 648 - if (readl(&dp6c_ptr->u) != DPMEM_MAGIC) { 649 - printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n", 650 - pcistr->dpmem); 651 - found = FALSE; 652 - for (i = 0xC8000; i < 0xE8000; i += 0x4000) { 653 - iounmap(ha->brd); 654 - ha->brd = ioremap(i, sizeof(u16)); 655 - if (ha->brd == NULL) { 656 - printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); 657 - return 0; 658 - } 659 - if (readw(ha->brd) != 0xffff) { 660 - TRACE2(("init_pci_plx() address 0x%x busy\n", i)); 661 - continue; 662 - } 663 - iounmap(ha->brd); 664 - pci_write_config_dword(pdev, PCI_BASE_ADDRESS_2, i); 665 - ha->brd = ioremap(i, sizeof(gdt6c_dpram_str)); 666 - if (ha->brd == NULL) { 667 - printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); 668 - return 0; 669 - } 670 - dp6c_ptr = ha->brd; 671 - writel(DPMEM_MAGIC, &dp6c_ptr->u); 672 - if (readl(&dp6c_ptr->u) == DPMEM_MAGIC) { 673 - printk("GDT-PCI: Use free address at 0x%x\n", i); 674 - found = TRUE; 675 - break; 676 - } 677 - } 678 - if (!found) { 679 - printk("GDT-PCI: No free address found!\n"); 680 - iounmap(ha->brd); 681 - return 0; 682 - } 683 - } 684 - memset_io(&dp6c_ptr->u, 0, sizeof(dp6c_ptr->u)); 685 - if (readl(&dp6c_ptr->u) != 0) { 686 - printk("GDT-PCI: Initialization error (DPMEM write error)\n"); 687 - iounmap(ha->brd); 688 - return 0; 689 - } 690 - 691 - /* disable board interrupts, deinit services */ 692 - outb(0x00,PTR2USHORT(&ha->plx->control1)); 693 - outb(0xff,PTR2USHORT(&ha->plx->edoor_reg)); 694 - 695 - writeb(0x00, &dp6c_ptr->u.ic.S_Status); 696 - writeb(0x00, &dp6c_ptr->u.ic.Cmd_Index); 697 - 698 - writel(pcistr->dpmem, &dp6c_ptr->u.ic.S_Info[0]); 699 - writeb(0xff, &dp6c_ptr->u.ic.S_Cmd_Indx); 700 - 701 - outb(1,PTR2USHORT(&ha->plx->ldoor_reg)); 702 - 703 - retries = INIT_RETRIES; 704 - gdth_delay(20); 705 - while (readb(&dp6c_ptr->u.ic.S_Status) != 0xff) { 706 - if (--retries == 0) { 707 - printk("GDT-PCI: Initialization error (DEINIT failed)\n"); 708 - iounmap(ha->brd); 709 - return 0; 710 - } 711 - gdth_delay(1); 712 - } 713 - prot_ver = (u8)readl(&dp6c_ptr->u.ic.S_Info[0]); 714 - writeb(0, &dp6c_ptr->u.ic.Status); 715 - if (prot_ver != PROTOCOL_VERSION) { 716 - printk("GDT-PCI: Illegal protocol version\n"); 717 - iounmap(ha->brd); 718 - return 0; 719 - } 720 - 721 - ha->type = GDT_PCINEW; 722 - ha->ic_all_size = sizeof(dp6c_ptr->u); 723 - 724 - /* special command to controller BIOS */ 725 - writel(0x00, &dp6c_ptr->u.ic.S_Info[0]); 726 - writel(0x00, &dp6c_ptr->u.ic.S_Info[1]); 727 - writel(0x00, &dp6c_ptr->u.ic.S_Info[2]); 728 - writel(0x00, &dp6c_ptr->u.ic.S_Info[3]); 729 - writeb(0xfe, &dp6c_ptr->u.ic.S_Cmd_Indx); 730 - 731 - outb(1,PTR2USHORT(&ha->plx->ldoor_reg)); 732 - 733 - retries = INIT_RETRIES; 734 - gdth_delay(20); 735 - while (readb(&dp6c_ptr->u.ic.S_Status) != 0xfe) { 736 - if (--retries == 0) { 737 - printk("GDT-PCI: Initialization error\n"); 738 - iounmap(ha->brd); 739 - return 0; 740 - } 741 - gdth_delay(1); 742 - } 743 - writeb(0, &dp6c_ptr->u.ic.S_Status); 744 - 745 - ha->dma64_support = 0; 746 - 747 - } else { /* MPR */ 748 - TRACE2(("init_pci_mpr() dpmem %lx irq %d\n",pcistr->dpmem,ha->irq)); 749 - ha->brd = ioremap(pcistr->dpmem, sizeof(gdt6m_dpram_str)); 750 - if (ha->brd == NULL) { 751 - printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); 752 - return 0; 753 - } 754 - 755 - /* manipulate config. space to enable DPMEM, start RP controller */ 756 - pci_read_config_word(pdev, PCI_COMMAND, &command); 757 - command |= 6; 758 - pci_write_config_word(pdev, PCI_COMMAND, command); 759 - gdth_delay(1); 760 - 761 - dp6m_ptr = ha->brd; 762 - 763 - /* Ensure that it is safe to access the non HW portions of DPMEM. 764 - * Aditional check needed for Xscale based RAID controllers */ 765 - while( ((int)readb(&dp6m_ptr->i960r.sema0_reg) ) & 3 ) 766 - gdth_delay(1); 767 - 768 - /* check and reset interface area */ 769 - writel(DPMEM_MAGIC, &dp6m_ptr->u); 770 - if (readl(&dp6m_ptr->u) != DPMEM_MAGIC) { 771 - printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n", 772 - pcistr->dpmem); 773 - found = FALSE; 774 - for (i = 0xC8000; i < 0xE8000; i += 0x4000) { 775 - iounmap(ha->brd); 776 - ha->brd = ioremap(i, sizeof(u16)); 777 - if (ha->brd == NULL) { 778 - printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); 779 - return 0; 780 - } 781 - if (readw(ha->brd) != 0xffff) { 782 - TRACE2(("init_pci_mpr() address 0x%x busy\n", i)); 783 - continue; 784 - } 785 - iounmap(ha->brd); 786 - pci_write_config_dword(pdev, PCI_BASE_ADDRESS_0, i); 787 - ha->brd = ioremap(i, sizeof(gdt6m_dpram_str)); 788 - if (ha->brd == NULL) { 789 - printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); 790 - return 0; 791 - } 792 - dp6m_ptr = ha->brd; 793 - writel(DPMEM_MAGIC, &dp6m_ptr->u); 794 - if (readl(&dp6m_ptr->u) == DPMEM_MAGIC) { 795 - printk("GDT-PCI: Use free address at 0x%x\n", i); 796 - found = TRUE; 797 - break; 798 - } 799 - } 800 - if (!found) { 801 - printk("GDT-PCI: No free address found!\n"); 802 - iounmap(ha->brd); 803 - return 0; 804 - } 805 - } 806 - memset_io(&dp6m_ptr->u, 0, sizeof(dp6m_ptr->u)); 807 - 808 - /* disable board interrupts, deinit services */ 809 - writeb(readb(&dp6m_ptr->i960r.edoor_en_reg) | 4, 810 - &dp6m_ptr->i960r.edoor_en_reg); 811 - writeb(0xff, &dp6m_ptr->i960r.edoor_reg); 812 - writeb(0x00, &dp6m_ptr->u.ic.S_Status); 813 - writeb(0x00, &dp6m_ptr->u.ic.Cmd_Index); 814 - 815 - writel(pcistr->dpmem, &dp6m_ptr->u.ic.S_Info[0]); 816 - writeb(0xff, &dp6m_ptr->u.ic.S_Cmd_Indx); 817 - writeb(1, &dp6m_ptr->i960r.ldoor_reg); 818 - retries = INIT_RETRIES; 819 - gdth_delay(20); 820 - while (readb(&dp6m_ptr->u.ic.S_Status) != 0xff) { 821 - if (--retries == 0) { 822 - printk("GDT-PCI: Initialization error (DEINIT failed)\n"); 823 - iounmap(ha->brd); 824 - return 0; 825 - } 826 - gdth_delay(1); 827 - } 828 - prot_ver = (u8)readl(&dp6m_ptr->u.ic.S_Info[0]); 829 - writeb(0, &dp6m_ptr->u.ic.S_Status); 830 - if (prot_ver != PROTOCOL_VERSION) { 831 - printk("GDT-PCI: Illegal protocol version\n"); 832 - iounmap(ha->brd); 833 - return 0; 834 - } 835 - 836 - ha->type = GDT_PCIMPR; 837 - ha->ic_all_size = sizeof(dp6m_ptr->u); 838 - 839 - /* special command to controller BIOS */ 840 - writel(0x00, &dp6m_ptr->u.ic.S_Info[0]); 841 - writel(0x00, &dp6m_ptr->u.ic.S_Info[1]); 842 - writel(0x00, &dp6m_ptr->u.ic.S_Info[2]); 843 - writel(0x00, &dp6m_ptr->u.ic.S_Info[3]); 844 - writeb(0xfe, &dp6m_ptr->u.ic.S_Cmd_Indx); 845 - writeb(1, &dp6m_ptr->i960r.ldoor_reg); 846 - retries = INIT_RETRIES; 847 - gdth_delay(20); 848 - while (readb(&dp6m_ptr->u.ic.S_Status) != 0xfe) { 849 - if (--retries == 0) { 850 - printk("GDT-PCI: Initialization error\n"); 851 - iounmap(ha->brd); 852 - return 0; 853 - } 854 - gdth_delay(1); 855 - } 856 - writeb(0, &dp6m_ptr->u.ic.S_Status); 857 - 858 - /* read FW version to detect 64-bit DMA support */ 859 - writeb(0xfd, &dp6m_ptr->u.ic.S_Cmd_Indx); 860 - writeb(1, &dp6m_ptr->i960r.ldoor_reg); 861 - retries = INIT_RETRIES; 862 - gdth_delay(20); 863 - while (readb(&dp6m_ptr->u.ic.S_Status) != 0xfd) { 864 - if (--retries == 0) { 865 - printk("GDT-PCI: Initialization error (DEINIT failed)\n"); 866 - iounmap(ha->brd); 867 - return 0; 868 - } 869 - gdth_delay(1); 870 - } 871 - prot_ver = (u8)(readl(&dp6m_ptr->u.ic.S_Info[0]) >> 16); 872 - writeb(0, &dp6m_ptr->u.ic.S_Status); 873 - if (prot_ver < 0x2b) /* FW < x.43: no 64-bit DMA support */ 874 - ha->dma64_support = 0; 875 - else 876 - ha->dma64_support = 1; 877 - } 878 - 879 - return 1; 880 - } 881 - 882 - /* controller protocol functions */ 883 - 884 - static void gdth_enable_int(gdth_ha_str *ha) 885 - { 886 - unsigned long flags; 887 - gdt6_dpram_str __iomem *dp6_ptr; 888 - gdt6m_dpram_str __iomem *dp6m_ptr; 889 - 890 - TRACE(("gdth_enable_int() hanum %d\n",ha->hanum)); 891 - spin_lock_irqsave(&ha->smp_lock, flags); 892 - 893 - if (ha->type == GDT_PCI) { 894 - dp6_ptr = ha->brd; 895 - writeb(1, &dp6_ptr->io.irqdel); 896 - writeb(0, &dp6_ptr->u.ic.Cmd_Index); 897 - writeb(1, &dp6_ptr->io.irqen); 898 - } else if (ha->type == GDT_PCINEW) { 899 - outb(0xff, PTR2USHORT(&ha->plx->edoor_reg)); 900 - outb(0x03, PTR2USHORT(&ha->plx->control1)); 901 - } else if (ha->type == GDT_PCIMPR) { 902 - dp6m_ptr = ha->brd; 903 - writeb(0xff, &dp6m_ptr->i960r.edoor_reg); 904 - writeb(readb(&dp6m_ptr->i960r.edoor_en_reg) & ~4, 905 - &dp6m_ptr->i960r.edoor_en_reg); 906 - } 907 - spin_unlock_irqrestore(&ha->smp_lock, flags); 908 - } 909 - 910 - /* return IStatus if interrupt was from this card else 0 */ 911 - static u8 gdth_get_status(gdth_ha_str *ha) 912 - { 913 - u8 IStatus = 0; 914 - 915 - TRACE(("gdth_get_status() irq %d ctr_count %d\n", ha->irq, gdth_ctr_count)); 916 - 917 - if (ha->type == GDT_PCI) 918 - IStatus = 919 - readb(&((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Cmd_Index); 920 - else if (ha->type == GDT_PCINEW) 921 - IStatus = inb(PTR2USHORT(&ha->plx->edoor_reg)); 922 - else if (ha->type == GDT_PCIMPR) 923 - IStatus = 924 - readb(&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.edoor_reg); 925 - 926 - return IStatus; 927 - } 928 - 929 - static int gdth_test_busy(gdth_ha_str *ha) 930 - { 931 - register int gdtsema0 = 0; 932 - 933 - TRACE(("gdth_test_busy() hanum %d\n", ha->hanum)); 934 - 935 - if (ha->type == GDT_PCI) 936 - gdtsema0 = (int)readb(&((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Sema0); 937 - else if (ha->type == GDT_PCINEW) 938 - gdtsema0 = (int)inb(PTR2USHORT(&ha->plx->sema0_reg)); 939 - else if (ha->type == GDT_PCIMPR) 940 - gdtsema0 = 941 - (int)readb(&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.sema0_reg); 942 - 943 - return (gdtsema0 & 1); 944 - } 945 - 946 - 947 - static int gdth_get_cmd_index(gdth_ha_str *ha) 948 - { 949 - int i; 950 - 951 - TRACE(("gdth_get_cmd_index() hanum %d\n", ha->hanum)); 952 - 953 - for (i=0; i<GDTH_MAXCMDS; ++i) { 954 - if (ha->cmd_tab[i].cmnd == UNUSED_CMND) { 955 - ha->cmd_tab[i].cmnd = ha->pccb->RequestBuffer; 956 - ha->cmd_tab[i].service = ha->pccb->Service; 957 - ha->pccb->CommandIndex = (u32)i+2; 958 - return (i+2); 959 - } 960 - } 961 - return 0; 962 - } 963 - 964 - 965 - static void gdth_set_sema0(gdth_ha_str *ha) 966 - { 967 - TRACE(("gdth_set_sema0() hanum %d\n", ha->hanum)); 968 - 969 - if (ha->type == GDT_PCI) { 970 - writeb(1, &((gdt6_dpram_str __iomem *)ha->brd)->u.ic.Sema0); 971 - } else if (ha->type == GDT_PCINEW) { 972 - outb(1, PTR2USHORT(&ha->plx->sema0_reg)); 973 - } else if (ha->type == GDT_PCIMPR) { 974 - writeb(1, &((gdt6m_dpram_str __iomem *)ha->brd)->i960r.sema0_reg); 975 - } 976 - } 977 - 978 - 979 - static void gdth_copy_command(gdth_ha_str *ha) 980 - { 981 - register gdth_cmd_str *cmd_ptr; 982 - register gdt6m_dpram_str __iomem *dp6m_ptr; 983 - register gdt6c_dpram_str __iomem *dp6c_ptr; 984 - gdt6_dpram_str __iomem *dp6_ptr; 985 - u16 cp_count,dp_offset,cmd_no; 986 - 987 - TRACE(("gdth_copy_command() hanum %d\n", ha->hanum)); 988 - 989 - cp_count = ha->cmd_len; 990 - dp_offset= ha->cmd_offs_dpmem; 991 - cmd_no = ha->cmd_cnt; 992 - cmd_ptr = ha->pccb; 993 - 994 - ++ha->cmd_cnt; 995 - 996 - /* set cpcount dword aligned */ 997 - if (cp_count & 3) 998 - cp_count += (4 - (cp_count & 3)); 999 - 1000 - ha->cmd_offs_dpmem += cp_count; 1001 - 1002 - /* set offset and service, copy command to DPMEM */ 1003 - if (ha->type == GDT_PCI) { 1004 - dp6_ptr = ha->brd; 1005 - writew(dp_offset + DPMEM_COMMAND_OFFSET, 1006 - &dp6_ptr->u.ic.comm_queue[cmd_no].offset); 1007 - writew((u16)cmd_ptr->Service, 1008 - &dp6_ptr->u.ic.comm_queue[cmd_no].serv_id); 1009 - memcpy_toio(&dp6_ptr->u.ic.gdt_dpr_cmd[dp_offset],cmd_ptr,cp_count); 1010 - } else if (ha->type == GDT_PCINEW) { 1011 - dp6c_ptr = ha->brd; 1012 - writew(dp_offset + DPMEM_COMMAND_OFFSET, 1013 - &dp6c_ptr->u.ic.comm_queue[cmd_no].offset); 1014 - writew((u16)cmd_ptr->Service, 1015 - &dp6c_ptr->u.ic.comm_queue[cmd_no].serv_id); 1016 - memcpy_toio(&dp6c_ptr->u.ic.gdt_dpr_cmd[dp_offset],cmd_ptr,cp_count); 1017 - } else if (ha->type == GDT_PCIMPR) { 1018 - dp6m_ptr = ha->brd; 1019 - writew(dp_offset + DPMEM_COMMAND_OFFSET, 1020 - &dp6m_ptr->u.ic.comm_queue[cmd_no].offset); 1021 - writew((u16)cmd_ptr->Service, 1022 - &dp6m_ptr->u.ic.comm_queue[cmd_no].serv_id); 1023 - memcpy_toio(&dp6m_ptr->u.ic.gdt_dpr_cmd[dp_offset],cmd_ptr,cp_count); 1024 - } 1025 - } 1026 - 1027 - 1028 - static void gdth_release_event(gdth_ha_str *ha) 1029 - { 1030 - TRACE(("gdth_release_event() hanum %d\n", ha->hanum)); 1031 - 1032 - #ifdef GDTH_STATISTICS 1033 - { 1034 - u32 i,j; 1035 - for (i=0,j=0; j<GDTH_MAXCMDS; ++j) { 1036 - if (ha->cmd_tab[j].cmnd != UNUSED_CMND) 1037 - ++i; 1038 - } 1039 - if (max_index < i) { 1040 - max_index = i; 1041 - TRACE3(("GDT: max_index = %d\n",(u16)i)); 1042 - } 1043 - } 1044 - #endif 1045 - 1046 - if (ha->pccb->OpCode == GDT_INIT) 1047 - ha->pccb->Service |= 0x80; 1048 - 1049 - if (ha->type == GDT_PCI) { 1050 - writeb(0, &((gdt6_dpram_str __iomem *)ha->brd)->io.event); 1051 - } else if (ha->type == GDT_PCINEW) { 1052 - outb(1, PTR2USHORT(&ha->plx->ldoor_reg)); 1053 - } else if (ha->type == GDT_PCIMPR) { 1054 - writeb(1, &((gdt6m_dpram_str __iomem *)ha->brd)->i960r.ldoor_reg); 1055 - } 1056 - } 1057 - 1058 - static int gdth_wait(gdth_ha_str *ha, int index, u32 time) 1059 - { 1060 - int answer_found = FALSE; 1061 - int wait_index = 0; 1062 - 1063 - TRACE(("gdth_wait() hanum %d index %d time %d\n", ha->hanum, index, time)); 1064 - 1065 - if (index == 0) 1066 - return 1; /* no wait required */ 1067 - 1068 - do { 1069 - __gdth_interrupt(ha, true, &wait_index); 1070 - if (wait_index == index) { 1071 - answer_found = TRUE; 1072 - break; 1073 - } 1074 - gdth_delay(1); 1075 - } while (--time); 1076 - 1077 - while (gdth_test_busy(ha)) 1078 - gdth_delay(0); 1079 - 1080 - return (answer_found); 1081 - } 1082 - 1083 - 1084 - static int gdth_internal_cmd(gdth_ha_str *ha, u8 service, u16 opcode, 1085 - u32 p1, u64 p2, u64 p3) 1086 - { 1087 - register gdth_cmd_str *cmd_ptr; 1088 - int retries,index; 1089 - 1090 - TRACE2(("gdth_internal_cmd() service %d opcode %d\n",service,opcode)); 1091 - 1092 - cmd_ptr = ha->pccb; 1093 - memset((char*)cmd_ptr,0,sizeof(gdth_cmd_str)); 1094 - 1095 - /* make command */ 1096 - for (retries = INIT_RETRIES;;) { 1097 - cmd_ptr->Service = service; 1098 - cmd_ptr->RequestBuffer = INTERNAL_CMND; 1099 - if (!(index=gdth_get_cmd_index(ha))) { 1100 - TRACE(("GDT: No free command index found\n")); 1101 - return 0; 1102 - } 1103 - gdth_set_sema0(ha); 1104 - cmd_ptr->OpCode = opcode; 1105 - cmd_ptr->BoardNode = LOCALBOARD; 1106 - if (service == CACHESERVICE) { 1107 - if (opcode == GDT_IOCTL) { 1108 - cmd_ptr->u.ioctl.subfunc = p1; 1109 - cmd_ptr->u.ioctl.channel = (u32)p2; 1110 - cmd_ptr->u.ioctl.param_size = (u16)p3; 1111 - cmd_ptr->u.ioctl.p_param = ha->scratch_phys; 1112 - } else { 1113 - if (ha->cache_feat & GDT_64BIT) { 1114 - cmd_ptr->u.cache64.DeviceNo = (u16)p1; 1115 - cmd_ptr->u.cache64.BlockNo = p2; 1116 - } else { 1117 - cmd_ptr->u.cache.DeviceNo = (u16)p1; 1118 - cmd_ptr->u.cache.BlockNo = (u32)p2; 1119 - } 1120 - } 1121 - } else if (service == SCSIRAWSERVICE) { 1122 - if (ha->raw_feat & GDT_64BIT) { 1123 - cmd_ptr->u.raw64.direction = p1; 1124 - cmd_ptr->u.raw64.bus = (u8)p2; 1125 - cmd_ptr->u.raw64.target = (u8)p3; 1126 - cmd_ptr->u.raw64.lun = (u8)(p3 >> 8); 1127 - } else { 1128 - cmd_ptr->u.raw.direction = p1; 1129 - cmd_ptr->u.raw.bus = (u8)p2; 1130 - cmd_ptr->u.raw.target = (u8)p3; 1131 - cmd_ptr->u.raw.lun = (u8)(p3 >> 8); 1132 - } 1133 - } else if (service == SCREENSERVICE) { 1134 - if (opcode == GDT_REALTIME) { 1135 - *(u32 *)&cmd_ptr->u.screen.su.data[0] = p1; 1136 - *(u32 *)&cmd_ptr->u.screen.su.data[4] = (u32)p2; 1137 - *(u32 *)&cmd_ptr->u.screen.su.data[8] = (u32)p3; 1138 - } 1139 - } 1140 - ha->cmd_len = sizeof(gdth_cmd_str); 1141 - ha->cmd_offs_dpmem = 0; 1142 - ha->cmd_cnt = 0; 1143 - gdth_copy_command(ha); 1144 - gdth_release_event(ha); 1145 - gdth_delay(20); 1146 - if (!gdth_wait(ha, index, INIT_TIMEOUT)) { 1147 - printk("GDT: Initialization error (timeout service %d)\n",service); 1148 - return 0; 1149 - } 1150 - if (ha->status != S_BSY || --retries == 0) 1151 - break; 1152 - gdth_delay(1); 1153 - } 1154 - 1155 - return (ha->status != S_OK ? 0:1); 1156 - } 1157 - 1158 - 1159 - /* search for devices */ 1160 - 1161 - static int gdth_search_drives(gdth_ha_str *ha) 1162 - { 1163 - u16 cdev_cnt, i; 1164 - int ok; 1165 - u32 bus_no, drv_cnt, drv_no, j; 1166 - gdth_getch_str *chn; 1167 - gdth_drlist_str *drl; 1168 - gdth_iochan_str *ioc; 1169 - gdth_raw_iochan_str *iocr; 1170 - gdth_arcdl_str *alst; 1171 - gdth_alist_str *alst2; 1172 - gdth_oem_str_ioctl *oemstr; 1173 - 1174 - TRACE(("gdth_search_drives() hanum %d\n", ha->hanum)); 1175 - ok = 0; 1176 - 1177 - /* initialize controller services, at first: screen service */ 1178 - ha->screen_feat = 0; 1179 - if (!force_dma32) { 1180 - ok = gdth_internal_cmd(ha, SCREENSERVICE, GDT_X_INIT_SCR, 0, 0, 0); 1181 - if (ok) 1182 - ha->screen_feat = GDT_64BIT; 1183 - } 1184 - if (force_dma32 || (!ok && ha->status == (u16)S_NOFUNC)) 1185 - ok = gdth_internal_cmd(ha, SCREENSERVICE, GDT_INIT, 0, 0, 0); 1186 - if (!ok) { 1187 - printk("GDT-HA %d: Initialization error screen service (code %d)\n", 1188 - ha->hanum, ha->status); 1189 - return 0; 1190 - } 1191 - TRACE2(("gdth_search_drives(): SCREENSERVICE initialized\n")); 1192 - 1193 - /* unfreeze all IOs */ 1194 - gdth_internal_cmd(ha, CACHESERVICE, GDT_UNFREEZE_IO, 0, 0, 0); 1195 - 1196 - /* initialize cache service */ 1197 - ha->cache_feat = 0; 1198 - if (!force_dma32) { 1199 - ok = gdth_internal_cmd(ha, CACHESERVICE, GDT_X_INIT_HOST, LINUX_OS, 1200 - 0, 0); 1201 - if (ok) 1202 - ha->cache_feat = GDT_64BIT; 1203 - } 1204 - if (force_dma32 || (!ok && ha->status == (u16)S_NOFUNC)) 1205 - ok = gdth_internal_cmd(ha, CACHESERVICE, GDT_INIT, LINUX_OS, 0, 0); 1206 - if (!ok) { 1207 - printk("GDT-HA %d: Initialization error cache service (code %d)\n", 1208 - ha->hanum, ha->status); 1209 - return 0; 1210 - } 1211 - TRACE2(("gdth_search_drives(): CACHESERVICE initialized\n")); 1212 - cdev_cnt = (u16)ha->info; 1213 - ha->fw_vers = ha->service; 1214 - 1215 - /* detect number of buses - try new IOCTL */ 1216 - iocr = (gdth_raw_iochan_str *)ha->pscratch; 1217 - iocr->hdr.version = 0xffffffff; 1218 - iocr->hdr.list_entries = MAXBUS; 1219 - iocr->hdr.first_chan = 0; 1220 - iocr->hdr.last_chan = MAXBUS-1; 1221 - iocr->hdr.list_offset = GDTOFFSOF(gdth_raw_iochan_str, list[0]); 1222 - if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, IOCHAN_RAW_DESC, 1223 - INVALID_CHANNEL,sizeof(gdth_raw_iochan_str))) { 1224 - TRACE2(("IOCHAN_RAW_DESC supported!\n")); 1225 - ha->bus_cnt = iocr->hdr.chan_count; 1226 - for (bus_no = 0; bus_no < ha->bus_cnt; ++bus_no) { 1227 - if (iocr->list[bus_no].proc_id < MAXID) 1228 - ha->bus_id[bus_no] = iocr->list[bus_no].proc_id; 1229 - else 1230 - ha->bus_id[bus_no] = 0xff; 1231 - } 1232 - } else { 1233 - /* old method */ 1234 - chn = (gdth_getch_str *)ha->pscratch; 1235 - for (bus_no = 0; bus_no < MAXBUS; ++bus_no) { 1236 - chn->channel_no = bus_no; 1237 - if (!gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, 1238 - SCSI_CHAN_CNT | L_CTRL_PATTERN, 1239 - IO_CHANNEL | INVALID_CHANNEL, 1240 - sizeof(gdth_getch_str))) { 1241 - if (bus_no == 0) { 1242 - printk("GDT-HA %d: Error detecting channel count (0x%x)\n", 1243 - ha->hanum, ha->status); 1244 - return 0; 1245 - } 1246 - break; 1247 - } 1248 - if (chn->siop_id < MAXID) 1249 - ha->bus_id[bus_no] = chn->siop_id; 1250 - else 1251 - ha->bus_id[bus_no] = 0xff; 1252 - } 1253 - ha->bus_cnt = (u8)bus_no; 1254 - } 1255 - TRACE2(("gdth_search_drives() %d channels\n",ha->bus_cnt)); 1256 - 1257 - /* read cache configuration */ 1258 - if (!gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, CACHE_INFO, 1259 - INVALID_CHANNEL,sizeof(gdth_cinfo_str))) { 1260 - printk("GDT-HA %d: Initialization error cache service (code %d)\n", 1261 - ha->hanum, ha->status); 1262 - return 0; 1263 - } 1264 - ha->cpar = ((gdth_cinfo_str *)ha->pscratch)->cpar; 1265 - TRACE2(("gdth_search_drives() cinfo: vs %x sta %d str %d dw %d b %d\n", 1266 - ha->cpar.version,ha->cpar.state,ha->cpar.strategy, 1267 - ha->cpar.write_back,ha->cpar.block_size)); 1268 - 1269 - /* read board info and features */ 1270 - ha->more_proc = FALSE; 1271 - if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, BOARD_INFO, 1272 - INVALID_CHANNEL,sizeof(gdth_binfo_str))) { 1273 - memcpy(&ha->binfo, (gdth_binfo_str *)ha->pscratch, 1274 - sizeof(gdth_binfo_str)); 1275 - if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, BOARD_FEATURES, 1276 - INVALID_CHANNEL,sizeof(gdth_bfeat_str))) { 1277 - TRACE2(("BOARD_INFO/BOARD_FEATURES supported\n")); 1278 - ha->bfeat = *(gdth_bfeat_str *)ha->pscratch; 1279 - ha->more_proc = TRUE; 1280 - } 1281 - } else { 1282 - TRACE2(("BOARD_INFO requires firmware >= 1.10/2.08\n")); 1283 - strcpy(ha->binfo.type_string, gdth_ctr_name(ha)); 1284 - } 1285 - TRACE2(("Controller name: %s\n",ha->binfo.type_string)); 1286 - 1287 - /* read more informations */ 1288 - if (ha->more_proc) { 1289 - /* physical drives, channel addresses */ 1290 - ioc = (gdth_iochan_str *)ha->pscratch; 1291 - ioc->hdr.version = 0xffffffff; 1292 - ioc->hdr.list_entries = MAXBUS; 1293 - ioc->hdr.first_chan = 0; 1294 - ioc->hdr.last_chan = MAXBUS-1; 1295 - ioc->hdr.list_offset = GDTOFFSOF(gdth_iochan_str, list[0]); 1296 - if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, IOCHAN_DESC, 1297 - INVALID_CHANNEL,sizeof(gdth_iochan_str))) { 1298 - for (bus_no = 0; bus_no < ha->bus_cnt; ++bus_no) { 1299 - ha->raw[bus_no].address = ioc->list[bus_no].address; 1300 - ha->raw[bus_no].local_no = ioc->list[bus_no].local_no; 1301 - } 1302 - } else { 1303 - for (bus_no = 0; bus_no < ha->bus_cnt; ++bus_no) { 1304 - ha->raw[bus_no].address = IO_CHANNEL; 1305 - ha->raw[bus_no].local_no = bus_no; 1306 - } 1307 - } 1308 - for (bus_no = 0; bus_no < ha->bus_cnt; ++bus_no) { 1309 - chn = (gdth_getch_str *)ha->pscratch; 1310 - chn->channel_no = ha->raw[bus_no].local_no; 1311 - if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, 1312 - SCSI_CHAN_CNT | L_CTRL_PATTERN, 1313 - ha->raw[bus_no].address | INVALID_CHANNEL, 1314 - sizeof(gdth_getch_str))) { 1315 - ha->raw[bus_no].pdev_cnt = chn->drive_cnt; 1316 - TRACE2(("Channel %d: %d phys. drives\n", 1317 - bus_no,chn->drive_cnt)); 1318 - } 1319 - if (ha->raw[bus_no].pdev_cnt > 0) { 1320 - drl = (gdth_drlist_str *)ha->pscratch; 1321 - drl->sc_no = ha->raw[bus_no].local_no; 1322 - drl->sc_cnt = ha->raw[bus_no].pdev_cnt; 1323 - if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, 1324 - SCSI_DR_LIST | L_CTRL_PATTERN, 1325 - ha->raw[bus_no].address | INVALID_CHANNEL, 1326 - sizeof(gdth_drlist_str))) { 1327 - for (j = 0; j < ha->raw[bus_no].pdev_cnt; ++j) 1328 - ha->raw[bus_no].id_list[j] = drl->sc_list[j]; 1329 - } else { 1330 - ha->raw[bus_no].pdev_cnt = 0; 1331 - } 1332 - } 1333 - } 1334 - 1335 - /* logical drives */ 1336 - if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, CACHE_DRV_CNT, 1337 - INVALID_CHANNEL,sizeof(u32))) { 1338 - drv_cnt = *(u32 *)ha->pscratch; 1339 - if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, CACHE_DRV_LIST, 1340 - INVALID_CHANNEL,drv_cnt * sizeof(u32))) { 1341 - for (j = 0; j < drv_cnt; ++j) { 1342 - drv_no = ((u32 *)ha->pscratch)[j]; 1343 - if (drv_no < MAX_LDRIVES) { 1344 - ha->hdr[drv_no].is_logdrv = TRUE; 1345 - TRACE2(("Drive %d is log. drive\n",drv_no)); 1346 - } 1347 - } 1348 - } 1349 - alst = (gdth_arcdl_str *)ha->pscratch; 1350 - alst->entries_avail = MAX_LDRIVES; 1351 - alst->first_entry = 0; 1352 - alst->list_offset = GDTOFFSOF(gdth_arcdl_str, list[0]); 1353 - if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, 1354 - ARRAY_DRV_LIST2 | LA_CTRL_PATTERN, 1355 - INVALID_CHANNEL, sizeof(gdth_arcdl_str) + 1356 - (alst->entries_avail-1) * sizeof(gdth_alist_str))) { 1357 - for (j = 0; j < alst->entries_init; ++j) { 1358 - ha->hdr[j].is_arraydrv = alst->list[j].is_arrayd; 1359 - ha->hdr[j].is_master = alst->list[j].is_master; 1360 - ha->hdr[j].is_parity = alst->list[j].is_parity; 1361 - ha->hdr[j].is_hotfix = alst->list[j].is_hotfix; 1362 - ha->hdr[j].master_no = alst->list[j].cd_handle; 1363 - } 1364 - } else if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, 1365 - ARRAY_DRV_LIST | LA_CTRL_PATTERN, 1366 - 0, 35 * sizeof(gdth_alist_str))) { 1367 - for (j = 0; j < 35; ++j) { 1368 - alst2 = &((gdth_alist_str *)ha->pscratch)[j]; 1369 - ha->hdr[j].is_arraydrv = alst2->is_arrayd; 1370 - ha->hdr[j].is_master = alst2->is_master; 1371 - ha->hdr[j].is_parity = alst2->is_parity; 1372 - ha->hdr[j].is_hotfix = alst2->is_hotfix; 1373 - ha->hdr[j].master_no = alst2->cd_handle; 1374 - } 1375 - } 1376 - } 1377 - } 1378 - 1379 - /* initialize raw service */ 1380 - ha->raw_feat = 0; 1381 - if (!force_dma32) { 1382 - ok = gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_X_INIT_RAW, 0, 0, 0); 1383 - if (ok) 1384 - ha->raw_feat = GDT_64BIT; 1385 - } 1386 - if (force_dma32 || (!ok && ha->status == (u16)S_NOFUNC)) 1387 - ok = gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_INIT, 0, 0, 0); 1388 - if (!ok) { 1389 - printk("GDT-HA %d: Initialization error raw service (code %d)\n", 1390 - ha->hanum, ha->status); 1391 - return 0; 1392 - } 1393 - TRACE2(("gdth_search_drives(): RAWSERVICE initialized\n")); 1394 - 1395 - /* set/get features raw service (scatter/gather) */ 1396 - if (gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_SET_FEAT, SCATTER_GATHER, 1397 - 0, 0)) { 1398 - TRACE2(("gdth_search_drives(): set features RAWSERVICE OK\n")); 1399 - if (gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_GET_FEAT, 0, 0, 0)) { 1400 - TRACE2(("gdth_search_dr(): get feat RAWSERVICE %d\n", 1401 - ha->info)); 1402 - ha->raw_feat |= (u16)ha->info; 1403 - } 1404 - } 1405 - 1406 - /* set/get features cache service (equal to raw service) */ 1407 - if (gdth_internal_cmd(ha, CACHESERVICE, GDT_SET_FEAT, 0, 1408 - SCATTER_GATHER,0)) { 1409 - TRACE2(("gdth_search_drives(): set features CACHESERVICE OK\n")); 1410 - if (gdth_internal_cmd(ha, CACHESERVICE, GDT_GET_FEAT, 0, 0, 0)) { 1411 - TRACE2(("gdth_search_dr(): get feat CACHESERV. %d\n", 1412 - ha->info)); 1413 - ha->cache_feat |= (u16)ha->info; 1414 - } 1415 - } 1416 - 1417 - /* reserve drives for raw service */ 1418 - if (reserve_mode != 0) { 1419 - gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_RESERVE_ALL, 1420 - reserve_mode == 1 ? 1 : 3, 0, 0); 1421 - TRACE2(("gdth_search_drives(): RESERVE_ALL code %d\n", 1422 - ha->status)); 1423 - } 1424 - for (i = 0; i < MAX_RES_ARGS; i += 4) { 1425 - if (reserve_list[i] == ha->hanum && reserve_list[i+1] < ha->bus_cnt && 1426 - reserve_list[i+2] < ha->tid_cnt && reserve_list[i+3] < MAXLUN) { 1427 - TRACE2(("gdth_search_drives(): reserve ha %d bus %d id %d lun %d\n", 1428 - reserve_list[i], reserve_list[i+1], 1429 - reserve_list[i+2], reserve_list[i+3])); 1430 - if (!gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_RESERVE, 0, 1431 - reserve_list[i+1], reserve_list[i+2] | 1432 - (reserve_list[i+3] << 8))) { 1433 - printk("GDT-HA %d: Error raw service (RESERVE, code %d)\n", 1434 - ha->hanum, ha->status); 1435 - } 1436 - } 1437 - } 1438 - 1439 - /* Determine OEM string using IOCTL */ 1440 - oemstr = (gdth_oem_str_ioctl *)ha->pscratch; 1441 - oemstr->params.ctl_version = 0x01; 1442 - oemstr->params.buffer_size = sizeof(oemstr->text); 1443 - if (gdth_internal_cmd(ha, CACHESERVICE, GDT_IOCTL, 1444 - CACHE_READ_OEM_STRING_RECORD,INVALID_CHANNEL, 1445 - sizeof(gdth_oem_str_ioctl))) { 1446 - TRACE2(("gdth_search_drives(): CACHE_READ_OEM_STRING_RECORD OK\n")); 1447 - printk("GDT-HA %d: Vendor: %s Name: %s\n", 1448 - ha->hanum, oemstr->text.oem_company_name, ha->binfo.type_string); 1449 - /* Save the Host Drive inquiry data */ 1450 - strlcpy(ha->oem_name,oemstr->text.scsi_host_drive_inquiry_vendor_id, 1451 - sizeof(ha->oem_name)); 1452 - } else { 1453 - /* Old method, based on PCI ID */ 1454 - TRACE2(("gdth_search_drives(): CACHE_READ_OEM_STRING_RECORD failed\n")); 1455 - printk("GDT-HA %d: Name: %s\n", 1456 - ha->hanum, ha->binfo.type_string); 1457 - if (ha->oem_id == OEM_ID_INTEL) 1458 - strlcpy(ha->oem_name,"Intel ", sizeof(ha->oem_name)); 1459 - else 1460 - strlcpy(ha->oem_name,"ICP ", sizeof(ha->oem_name)); 1461 - } 1462 - 1463 - /* scanning for host drives */ 1464 - for (i = 0; i < cdev_cnt; ++i) 1465 - gdth_analyse_hdrive(ha, i); 1466 - 1467 - TRACE(("gdth_search_drives() OK\n")); 1468 - return 1; 1469 - } 1470 - 1471 - static int gdth_analyse_hdrive(gdth_ha_str *ha, u16 hdrive) 1472 - { 1473 - u32 drv_cyls; 1474 - int drv_hds, drv_secs; 1475 - 1476 - TRACE(("gdth_analyse_hdrive() hanum %d drive %d\n", ha->hanum, hdrive)); 1477 - if (hdrive >= MAX_HDRIVES) 1478 - return 0; 1479 - 1480 - if (!gdth_internal_cmd(ha, CACHESERVICE, GDT_INFO, hdrive, 0, 0)) 1481 - return 0; 1482 - ha->hdr[hdrive].present = TRUE; 1483 - ha->hdr[hdrive].size = ha->info; 1484 - 1485 - /* evaluate mapping (sectors per head, heads per cylinder) */ 1486 - ha->hdr[hdrive].size &= ~SECS32; 1487 - if (ha->info2 == 0) { 1488 - gdth_eval_mapping(ha->hdr[hdrive].size,&drv_cyls,&drv_hds,&drv_secs); 1489 - } else { 1490 - drv_hds = ha->info2 & 0xff; 1491 - drv_secs = (ha->info2 >> 8) & 0xff; 1492 - drv_cyls = (u32)ha->hdr[hdrive].size / drv_hds / drv_secs; 1493 - } 1494 - ha->hdr[hdrive].heads = (u8)drv_hds; 1495 - ha->hdr[hdrive].secs = (u8)drv_secs; 1496 - /* round size */ 1497 - ha->hdr[hdrive].size = drv_cyls * drv_hds * drv_secs; 1498 - 1499 - if (ha->cache_feat & GDT_64BIT) { 1500 - if (gdth_internal_cmd(ha, CACHESERVICE, GDT_X_INFO, hdrive, 0, 0) 1501 - && ha->info2 != 0) { 1502 - ha->hdr[hdrive].size = ((u64)ha->info2 << 32) | ha->info; 1503 - } 1504 - } 1505 - TRACE2(("gdth_search_dr() cdr. %d size %d hds %d scs %d\n", 1506 - hdrive,ha->hdr[hdrive].size,drv_hds,drv_secs)); 1507 - 1508 - /* get informations about device */ 1509 - if (gdth_internal_cmd(ha, CACHESERVICE, GDT_DEVTYPE, hdrive, 0, 0)) { 1510 - TRACE2(("gdth_search_dr() cache drive %d devtype %d\n", 1511 - hdrive,ha->info)); 1512 - ha->hdr[hdrive].devtype = (u16)ha->info; 1513 - } 1514 - 1515 - /* cluster info */ 1516 - if (gdth_internal_cmd(ha, CACHESERVICE, GDT_CLUST_INFO, hdrive, 0, 0)) { 1517 - TRACE2(("gdth_search_dr() cache drive %d cluster info %d\n", 1518 - hdrive,ha->info)); 1519 - if (!shared_access) 1520 - ha->hdr[hdrive].cluster_type = (u8)ha->info; 1521 - } 1522 - 1523 - /* R/W attributes */ 1524 - if (gdth_internal_cmd(ha, CACHESERVICE, GDT_RW_ATTRIBS, hdrive, 0, 0)) { 1525 - TRACE2(("gdth_search_dr() cache drive %d r/w attrib. %d\n", 1526 - hdrive,ha->info)); 1527 - ha->hdr[hdrive].rw_attribs = (u8)ha->info; 1528 - } 1529 - 1530 - return 1; 1531 - } 1532 - 1533 - 1534 - /* command queueing/sending functions */ 1535 - 1536 - static void gdth_putq(gdth_ha_str *ha, struct scsi_cmnd *scp, u8 priority) 1537 - { 1538 - struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp); 1539 - register struct scsi_cmnd *pscp; 1540 - register struct scsi_cmnd *nscp; 1541 - unsigned long flags; 1542 - 1543 - TRACE(("gdth_putq() priority %d\n",priority)); 1544 - spin_lock_irqsave(&ha->smp_lock, flags); 1545 - 1546 - if (!cmndinfo->internal_command) 1547 - cmndinfo->priority = priority; 1548 - 1549 - if (ha->req_first==NULL) { 1550 - ha->req_first = scp; /* queue was empty */ 1551 - scp->SCp.ptr = NULL; 1552 - } else { /* queue not empty */ 1553 - pscp = ha->req_first; 1554 - nscp = (struct scsi_cmnd *)pscp->SCp.ptr; 1555 - /* priority: 0-highest,..,0xff-lowest */ 1556 - while (nscp && gdth_cmnd_priv(nscp)->priority <= priority) { 1557 - pscp = nscp; 1558 - nscp = (struct scsi_cmnd *)pscp->SCp.ptr; 1559 - } 1560 - pscp->SCp.ptr = (char *)scp; 1561 - scp->SCp.ptr = (char *)nscp; 1562 - } 1563 - spin_unlock_irqrestore(&ha->smp_lock, flags); 1564 - 1565 - #ifdef GDTH_STATISTICS 1566 - flags = 0; 1567 - for (nscp=ha->req_first; nscp; nscp=(struct scsi_cmnd*)nscp->SCp.ptr) 1568 - ++flags; 1569 - if (max_rq < flags) { 1570 - max_rq = flags; 1571 - TRACE3(("GDT: max_rq = %d\n",(u16)max_rq)); 1572 - } 1573 - #endif 1574 - } 1575 - 1576 - static void gdth_next(gdth_ha_str *ha) 1577 - { 1578 - register struct scsi_cmnd *pscp; 1579 - register struct scsi_cmnd *nscp; 1580 - u8 b, t, l, firsttime; 1581 - u8 this_cmd, next_cmd; 1582 - unsigned long flags = 0; 1583 - int cmd_index; 1584 - 1585 - TRACE(("gdth_next() hanum %d\n", ha->hanum)); 1586 - if (!gdth_polling) 1587 - spin_lock_irqsave(&ha->smp_lock, flags); 1588 - 1589 - ha->cmd_cnt = ha->cmd_offs_dpmem = 0; 1590 - this_cmd = firsttime = TRUE; 1591 - next_cmd = gdth_polling ? FALSE:TRUE; 1592 - cmd_index = 0; 1593 - 1594 - for (nscp = pscp = ha->req_first; nscp; nscp = (struct scsi_cmnd *)nscp->SCp.ptr) { 1595 - struct gdth_cmndinfo *nscp_cmndinfo = gdth_cmnd_priv(nscp); 1596 - if (nscp != pscp && nscp != (struct scsi_cmnd *)pscp->SCp.ptr) 1597 - pscp = (struct scsi_cmnd *)pscp->SCp.ptr; 1598 - if (!nscp_cmndinfo->internal_command) { 1599 - b = nscp->device->channel; 1600 - t = nscp->device->id; 1601 - l = nscp->device->lun; 1602 - if (nscp_cmndinfo->priority >= DEFAULT_PRI) { 1603 - if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) || 1604 - (b == ha->virt_bus && t < MAX_HDRIVES && ha->hdr[t].lock)) 1605 - continue; 1606 - } 1607 - } else 1608 - b = t = l = 0; 1609 - 1610 - if (firsttime) { 1611 - if (gdth_test_busy(ha)) { /* controller busy ? */ 1612 - TRACE(("gdth_next() controller %d busy !\n", ha->hanum)); 1613 - if (!gdth_polling) { 1614 - spin_unlock_irqrestore(&ha->smp_lock, flags); 1615 - return; 1616 - } 1617 - while (gdth_test_busy(ha)) 1618 - gdth_delay(1); 1619 - } 1620 - firsttime = FALSE; 1621 - } 1622 - 1623 - if (!nscp_cmndinfo->internal_command) { 1624 - if (nscp_cmndinfo->phase == -1) { 1625 - nscp_cmndinfo->phase = CACHESERVICE; /* default: cache svc. */ 1626 - if (nscp->cmnd[0] == TEST_UNIT_READY) { 1627 - TRACE2(("TEST_UNIT_READY Bus %d Id %d LUN %d\n", 1628 - b, t, l)); 1629 - /* TEST_UNIT_READY -> set scan mode */ 1630 - if ((ha->scan_mode & 0x0f) == 0) { 1631 - if (b == 0 && t == 0 && l == 0) { 1632 - ha->scan_mode |= 1; 1633 - TRACE2(("Scan mode: 0x%x\n", ha->scan_mode)); 1634 - } 1635 - } else if ((ha->scan_mode & 0x0f) == 1) { 1636 - if (b == 0 && ((t == 0 && l == 1) || 1637 - (t == 1 && l == 0))) { 1638 - nscp_cmndinfo->OpCode = GDT_SCAN_START; 1639 - nscp_cmndinfo->phase = ((ha->scan_mode & 0x10 ? 1:0) << 8) 1640 - | SCSIRAWSERVICE; 1641 - ha->scan_mode = 0x12; 1642 - TRACE2(("Scan mode: 0x%x (SCAN_START)\n", 1643 - ha->scan_mode)); 1644 - } else { 1645 - ha->scan_mode &= 0x10; 1646 - TRACE2(("Scan mode: 0x%x\n", ha->scan_mode)); 1647 - } 1648 - } else if (ha->scan_mode == 0x12) { 1649 - if (b == ha->bus_cnt && t == ha->tid_cnt-1) { 1650 - nscp_cmndinfo->phase = SCSIRAWSERVICE; 1651 - nscp_cmndinfo->OpCode = GDT_SCAN_END; 1652 - ha->scan_mode &= 0x10; 1653 - TRACE2(("Scan mode: 0x%x (SCAN_END)\n", 1654 - ha->scan_mode)); 1655 - } 1656 - } 1657 - } 1658 - if (b == ha->virt_bus && nscp->cmnd[0] != INQUIRY && 1659 - nscp->cmnd[0] != READ_CAPACITY && nscp->cmnd[0] != MODE_SENSE && 1660 - (ha->hdr[t].cluster_type & CLUSTER_DRIVE)) { 1661 - /* always GDT_CLUST_INFO! */ 1662 - nscp_cmndinfo->OpCode = GDT_CLUST_INFO; 1663 - } 1664 - } 1665 - } 1666 - 1667 - if (nscp_cmndinfo->OpCode != -1) { 1668 - if ((nscp_cmndinfo->phase & 0xff) == CACHESERVICE) { 1669 - if (!(cmd_index=gdth_fill_cache_cmd(ha, nscp, t))) 1670 - this_cmd = FALSE; 1671 - next_cmd = FALSE; 1672 - } else if ((nscp_cmndinfo->phase & 0xff) == SCSIRAWSERVICE) { 1673 - if (!(cmd_index=gdth_fill_raw_cmd(ha, nscp, BUS_L2P(ha, b)))) 1674 - this_cmd = FALSE; 1675 - next_cmd = FALSE; 1676 - } else { 1677 - memset((char*)nscp->sense_buffer,0,16); 1678 - nscp->sense_buffer[0] = 0x70; 1679 - nscp->sense_buffer[2] = NOT_READY; 1680 - nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1); 1681 - if (!nscp_cmndinfo->wait_for_completion) 1682 - nscp_cmndinfo->wait_for_completion++; 1683 - else 1684 - gdth_scsi_done(nscp); 1685 - } 1686 - } else if (gdth_cmnd_priv(nscp)->internal_command) { 1687 - if (!(cmd_index=gdth_special_cmd(ha, nscp))) 1688 - this_cmd = FALSE; 1689 - next_cmd = FALSE; 1690 - } else if (b != ha->virt_bus) { 1691 - if (ha->raw[BUS_L2P(ha,b)].io_cnt[t] >= GDTH_MAX_RAW || 1692 - !(cmd_index=gdth_fill_raw_cmd(ha, nscp, BUS_L2P(ha, b)))) 1693 - this_cmd = FALSE; 1694 - else 1695 - ha->raw[BUS_L2P(ha,b)].io_cnt[t]++; 1696 - } else if (t >= MAX_HDRIVES || !ha->hdr[t].present || l != 0) { 1697 - TRACE2(("Command 0x%x to bus %d id %d lun %d -> IGNORE\n", 1698 - nscp->cmnd[0], b, t, l)); 1699 - nscp->result = DID_BAD_TARGET << 16; 1700 - if (!nscp_cmndinfo->wait_for_completion) 1701 - nscp_cmndinfo->wait_for_completion++; 1702 - else 1703 - gdth_scsi_done(nscp); 1704 - } else { 1705 - switch (nscp->cmnd[0]) { 1706 - case TEST_UNIT_READY: 1707 - case INQUIRY: 1708 - case REQUEST_SENSE: 1709 - case READ_CAPACITY: 1710 - case VERIFY: 1711 - case START_STOP: 1712 - case MODE_SENSE: 1713 - case SERVICE_ACTION_IN_16: 1714 - TRACE(("cache cmd %x/%x/%x/%x/%x/%x\n",nscp->cmnd[0], 1715 - nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3], 1716 - nscp->cmnd[4],nscp->cmnd[5])); 1717 - if (ha->hdr[t].media_changed && nscp->cmnd[0] != INQUIRY) { 1718 - /* return UNIT_ATTENTION */ 1719 - TRACE2(("cmd 0x%x target %d: UNIT_ATTENTION\n", 1720 - nscp->cmnd[0], t)); 1721 - ha->hdr[t].media_changed = FALSE; 1722 - memset((char*)nscp->sense_buffer,0,16); 1723 - nscp->sense_buffer[0] = 0x70; 1724 - nscp->sense_buffer[2] = UNIT_ATTENTION; 1725 - nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1); 1726 - if (!nscp_cmndinfo->wait_for_completion) 1727 - nscp_cmndinfo->wait_for_completion++; 1728 - else 1729 - gdth_scsi_done(nscp); 1730 - } else if (gdth_internal_cache_cmd(ha, nscp)) 1731 - gdth_scsi_done(nscp); 1732 - break; 1733 - 1734 - case ALLOW_MEDIUM_REMOVAL: 1735 - TRACE(("cache cmd %x/%x/%x/%x/%x/%x\n",nscp->cmnd[0], 1736 - nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3], 1737 - nscp->cmnd[4],nscp->cmnd[5])); 1738 - if ( (nscp->cmnd[4]&1) && !(ha->hdr[t].devtype&1) ) { 1739 - TRACE(("Prevent r. nonremov. drive->do nothing\n")); 1740 - nscp->result = DID_OK << 16; 1741 - nscp->sense_buffer[0] = 0; 1742 - if (!nscp_cmndinfo->wait_for_completion) 1743 - nscp_cmndinfo->wait_for_completion++; 1744 - else 1745 - gdth_scsi_done(nscp); 1746 - } else { 1747 - nscp->cmnd[3] = (ha->hdr[t].devtype&1) ? 1:0; 1748 - TRACE(("Prevent/allow r. %d rem. drive %d\n", 1749 - nscp->cmnd[4],nscp->cmnd[3])); 1750 - if (!(cmd_index=gdth_fill_cache_cmd(ha, nscp, t))) 1751 - this_cmd = FALSE; 1752 - } 1753 - break; 1754 - 1755 - case RESERVE: 1756 - case RELEASE: 1757 - TRACE2(("cache cmd %s\n",nscp->cmnd[0] == RESERVE ? 1758 - "RESERVE" : "RELEASE")); 1759 - if (!(cmd_index=gdth_fill_cache_cmd(ha, nscp, t))) 1760 - this_cmd = FALSE; 1761 - break; 1762 - 1763 - case READ_6: 1764 - case WRITE_6: 1765 - case READ_10: 1766 - case WRITE_10: 1767 - case READ_16: 1768 - case WRITE_16: 1769 - if (ha->hdr[t].media_changed) { 1770 - /* return UNIT_ATTENTION */ 1771 - TRACE2(("cmd 0x%x target %d: UNIT_ATTENTION\n", 1772 - nscp->cmnd[0], t)); 1773 - ha->hdr[t].media_changed = FALSE; 1774 - memset((char*)nscp->sense_buffer,0,16); 1775 - nscp->sense_buffer[0] = 0x70; 1776 - nscp->sense_buffer[2] = UNIT_ATTENTION; 1777 - nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1); 1778 - if (!nscp_cmndinfo->wait_for_completion) 1779 - nscp_cmndinfo->wait_for_completion++; 1780 - else 1781 - gdth_scsi_done(nscp); 1782 - } else if (!(cmd_index=gdth_fill_cache_cmd(ha, nscp, t))) 1783 - this_cmd = FALSE; 1784 - break; 1785 - 1786 - default: 1787 - TRACE2(("cache cmd %x/%x/%x/%x/%x/%x unknown\n",nscp->cmnd[0], 1788 - nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3], 1789 - nscp->cmnd[4],nscp->cmnd[5])); 1790 - printk("GDT-HA %d: Unknown SCSI command 0x%x to cache service !\n", 1791 - ha->hanum, nscp->cmnd[0]); 1792 - nscp->result = DID_ABORT << 16; 1793 - if (!nscp_cmndinfo->wait_for_completion) 1794 - nscp_cmndinfo->wait_for_completion++; 1795 - else 1796 - gdth_scsi_done(nscp); 1797 - break; 1798 - } 1799 - } 1800 - 1801 - if (!this_cmd) 1802 - break; 1803 - if (nscp == ha->req_first) 1804 - ha->req_first = pscp = (struct scsi_cmnd *)nscp->SCp.ptr; 1805 - else 1806 - pscp->SCp.ptr = nscp->SCp.ptr; 1807 - if (!next_cmd) 1808 - break; 1809 - } 1810 - 1811 - if (ha->cmd_cnt > 0) { 1812 - gdth_release_event(ha); 1813 - } 1814 - 1815 - if (!gdth_polling) 1816 - spin_unlock_irqrestore(&ha->smp_lock, flags); 1817 - 1818 - if (gdth_polling && ha->cmd_cnt > 0) { 1819 - if (!gdth_wait(ha, cmd_index, POLL_TIMEOUT)) 1820 - printk("GDT-HA %d: Command %d timed out !\n", 1821 - ha->hanum, cmd_index); 1822 - } 1823 - } 1824 - 1825 - /* 1826 - * gdth_copy_internal_data() - copy to/from a buffer onto a scsi_cmnd's 1827 - * buffers, kmap_atomic() as needed. 1828 - */ 1829 - static void gdth_copy_internal_data(gdth_ha_str *ha, struct scsi_cmnd *scp, 1830 - char *buffer, u16 count) 1831 - { 1832 - u16 cpcount,i, max_sg = scsi_sg_count(scp); 1833 - u16 cpsum,cpnow; 1834 - struct scatterlist *sl; 1835 - char *address; 1836 - 1837 - cpcount = min_t(u16, count, scsi_bufflen(scp)); 1838 - 1839 - if (cpcount) { 1840 - cpsum=0; 1841 - scsi_for_each_sg(scp, sl, max_sg, i) { 1842 - unsigned long flags; 1843 - cpnow = (u16)sl->length; 1844 - TRACE(("copy_internal() now %d sum %d count %d %d\n", 1845 - cpnow, cpsum, cpcount, scsi_bufflen(scp))); 1846 - if (cpsum+cpnow > cpcount) 1847 - cpnow = cpcount - cpsum; 1848 - cpsum += cpnow; 1849 - if (!sg_page(sl)) { 1850 - printk("GDT-HA %d: invalid sc/gt element in gdth_copy_internal_data()\n", 1851 - ha->hanum); 1852 - return; 1853 - } 1854 - local_irq_save(flags); 1855 - address = kmap_atomic(sg_page(sl)) + sl->offset; 1856 - memcpy(address, buffer, cpnow); 1857 - flush_dcache_page(sg_page(sl)); 1858 - kunmap_atomic(address); 1859 - local_irq_restore(flags); 1860 - if (cpsum == cpcount) 1861 - break; 1862 - buffer += cpnow; 1863 - } 1864 - } else if (count) { 1865 - printk("GDT-HA %d: SCSI command with no buffers but data transfer expected!\n", 1866 - ha->hanum); 1867 - WARN_ON(1); 1868 - } 1869 - } 1870 - 1871 - static int gdth_internal_cache_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp) 1872 - { 1873 - u8 t; 1874 - gdth_inq_data inq; 1875 - gdth_rdcap_data rdc; 1876 - gdth_sense_data sd; 1877 - gdth_modep_data mpd; 1878 - struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp); 1879 - 1880 - t = scp->device->id; 1881 - TRACE(("gdth_internal_cache_cmd() cmd 0x%x hdrive %d\n", 1882 - scp->cmnd[0],t)); 1883 - 1884 - scp->result = DID_OK << 16; 1885 - scp->sense_buffer[0] = 0; 1886 - 1887 - switch (scp->cmnd[0]) { 1888 - case TEST_UNIT_READY: 1889 - case VERIFY: 1890 - case START_STOP: 1891 - TRACE2(("Test/Verify/Start hdrive %d\n",t)); 1892 - break; 1893 - 1894 - case INQUIRY: 1895 - TRACE2(("Inquiry hdrive %d devtype %d\n", 1896 - t,ha->hdr[t].devtype)); 1897 - inq.type_qual = (ha->hdr[t].devtype&4) ? TYPE_ROM:TYPE_DISK; 1898 - /* you can here set all disks to removable, if you want to do 1899 - a flush using the ALLOW_MEDIUM_REMOVAL command */ 1900 - inq.modif_rmb = 0x00; 1901 - if ((ha->hdr[t].devtype & 1) || 1902 - (ha->hdr[t].cluster_type & CLUSTER_DRIVE)) 1903 - inq.modif_rmb = 0x80; 1904 - inq.version = 2; 1905 - inq.resp_aenc = 2; 1906 - inq.add_length= 32; 1907 - strcpy(inq.vendor,ha->oem_name); 1908 - snprintf(inq.product, sizeof(inq.product), "Host Drive #%02d",t); 1909 - strcpy(inq.revision," "); 1910 - gdth_copy_internal_data(ha, scp, (char*)&inq, sizeof(gdth_inq_data)); 1911 - break; 1912 - 1913 - case REQUEST_SENSE: 1914 - TRACE2(("Request sense hdrive %d\n",t)); 1915 - sd.errorcode = 0x70; 1916 - sd.segno = 0x00; 1917 - sd.key = NO_SENSE; 1918 - sd.info = 0; 1919 - sd.add_length= 0; 1920 - gdth_copy_internal_data(ha, scp, (char*)&sd, sizeof(gdth_sense_data)); 1921 - break; 1922 - 1923 - case MODE_SENSE: 1924 - TRACE2(("Mode sense hdrive %d\n",t)); 1925 - memset((char*)&mpd,0,sizeof(gdth_modep_data)); 1926 - mpd.hd.data_length = sizeof(gdth_modep_data); 1927 - mpd.hd.dev_par = (ha->hdr[t].devtype&2) ? 0x80:0; 1928 - mpd.hd.bd_length = sizeof(mpd.bd); 1929 - mpd.bd.block_length[0] = (SECTOR_SIZE & 0x00ff0000) >> 16; 1930 - mpd.bd.block_length[1] = (SECTOR_SIZE & 0x0000ff00) >> 8; 1931 - mpd.bd.block_length[2] = (SECTOR_SIZE & 0x000000ff); 1932 - gdth_copy_internal_data(ha, scp, (char*)&mpd, sizeof(gdth_modep_data)); 1933 - break; 1934 - 1935 - case READ_CAPACITY: 1936 - TRACE2(("Read capacity hdrive %d\n",t)); 1937 - if (ha->hdr[t].size > (u64)0xffffffff) 1938 - rdc.last_block_no = 0xffffffff; 1939 - else 1940 - rdc.last_block_no = cpu_to_be32(ha->hdr[t].size-1); 1941 - rdc.block_length = cpu_to_be32(SECTOR_SIZE); 1942 - gdth_copy_internal_data(ha, scp, (char*)&rdc, sizeof(gdth_rdcap_data)); 1943 - break; 1944 - 1945 - case SERVICE_ACTION_IN_16: 1946 - if ((scp->cmnd[1] & 0x1f) == SAI_READ_CAPACITY_16 && 1947 - (ha->cache_feat & GDT_64BIT)) { 1948 - gdth_rdcap16_data rdc16; 1949 - 1950 - TRACE2(("Read capacity (16) hdrive %d\n",t)); 1951 - rdc16.last_block_no = cpu_to_be64(ha->hdr[t].size-1); 1952 - rdc16.block_length = cpu_to_be32(SECTOR_SIZE); 1953 - gdth_copy_internal_data(ha, scp, (char*)&rdc16, 1954 - sizeof(gdth_rdcap16_data)); 1955 - } else { 1956 - scp->result = DID_ABORT << 16; 1957 - } 1958 - break; 1959 - 1960 - default: 1961 - TRACE2(("Internal cache cmd 0x%x unknown\n",scp->cmnd[0])); 1962 - break; 1963 - } 1964 - 1965 - if (!cmndinfo->wait_for_completion) 1966 - cmndinfo->wait_for_completion++; 1967 - else 1968 - return 1; 1969 - 1970 - return 0; 1971 - } 1972 - 1973 - static int gdth_fill_cache_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp, 1974 - u16 hdrive) 1975 - { 1976 - register gdth_cmd_str *cmdp; 1977 - struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp); 1978 - u32 cnt, blockcnt; 1979 - u64 no, blockno; 1980 - int i, cmd_index, read_write, sgcnt, mode64; 1981 - 1982 - cmdp = ha->pccb; 1983 - TRACE(("gdth_fill_cache_cmd() cmd 0x%x cmdsize %d hdrive %d\n", 1984 - scp->cmnd[0],scp->cmd_len,hdrive)); 1985 - 1986 - mode64 = (ha->cache_feat & GDT_64BIT) ? TRUE : FALSE; 1987 - /* test for READ_16, WRITE_16 if !mode64 ? --- 1988 - not required, should not occur due to error return on 1989 - READ_CAPACITY_16 */ 1990 - 1991 - cmdp->Service = CACHESERVICE; 1992 - cmdp->RequestBuffer = scp; 1993 - /* search free command index */ 1994 - if (!(cmd_index=gdth_get_cmd_index(ha))) { 1995 - TRACE(("GDT: No free command index found\n")); 1996 - return 0; 1997 - } 1998 - /* if it's the first command, set command semaphore */ 1999 - if (ha->cmd_cnt == 0) 2000 - gdth_set_sema0(ha); 2001 - 2002 - /* fill command */ 2003 - read_write = 0; 2004 - if (cmndinfo->OpCode != -1) 2005 - cmdp->OpCode = cmndinfo->OpCode; /* special cache cmd. */ 2006 - else if (scp->cmnd[0] == RESERVE) 2007 - cmdp->OpCode = GDT_RESERVE_DRV; 2008 - else if (scp->cmnd[0] == RELEASE) 2009 - cmdp->OpCode = GDT_RELEASE_DRV; 2010 - else if (scp->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { 2011 - if (scp->cmnd[4] & 1) /* prevent ? */ 2012 - cmdp->OpCode = GDT_MOUNT; 2013 - else if (scp->cmnd[3] & 1) /* removable drive ? */ 2014 - cmdp->OpCode = GDT_UNMOUNT; 2015 - else 2016 - cmdp->OpCode = GDT_FLUSH; 2017 - } else if (scp->cmnd[0] == WRITE_6 || scp->cmnd[0] == WRITE_10 || 2018 - scp->cmnd[0] == WRITE_12 || scp->cmnd[0] == WRITE_16 2019 - ) { 2020 - read_write = 1; 2021 - if (gdth_write_through || ((ha->hdr[hdrive].rw_attribs & 1) && 2022 - (ha->cache_feat & GDT_WR_THROUGH))) 2023 - cmdp->OpCode = GDT_WRITE_THR; 2024 - else 2025 - cmdp->OpCode = GDT_WRITE; 2026 - } else { 2027 - read_write = 2; 2028 - cmdp->OpCode = GDT_READ; 2029 - } 2030 - 2031 - cmdp->BoardNode = LOCALBOARD; 2032 - if (mode64) { 2033 - cmdp->u.cache64.DeviceNo = hdrive; 2034 - cmdp->u.cache64.BlockNo = 1; 2035 - cmdp->u.cache64.sg_canz = 0; 2036 - } else { 2037 - cmdp->u.cache.DeviceNo = hdrive; 2038 - cmdp->u.cache.BlockNo = 1; 2039 - cmdp->u.cache.sg_canz = 0; 2040 - } 2041 - 2042 - if (read_write) { 2043 - if (scp->cmd_len == 16) { 2044 - memcpy(&no, &scp->cmnd[2], sizeof(u64)); 2045 - blockno = be64_to_cpu(no); 2046 - memcpy(&cnt, &scp->cmnd[10], sizeof(u32)); 2047 - blockcnt = be32_to_cpu(cnt); 2048 - } else if (scp->cmd_len == 10) { 2049 - memcpy(&no, &scp->cmnd[2], sizeof(u32)); 2050 - blockno = be32_to_cpu(no); 2051 - memcpy(&cnt, &scp->cmnd[7], sizeof(u16)); 2052 - blockcnt = be16_to_cpu(cnt); 2053 - } else { 2054 - memcpy(&no, &scp->cmnd[0], sizeof(u32)); 2055 - blockno = be32_to_cpu(no) & 0x001fffffUL; 2056 - blockcnt= scp->cmnd[4]==0 ? 0x100 : scp->cmnd[4]; 2057 - } 2058 - if (mode64) { 2059 - cmdp->u.cache64.BlockNo = blockno; 2060 - cmdp->u.cache64.BlockCnt = blockcnt; 2061 - } else { 2062 - cmdp->u.cache.BlockNo = (u32)blockno; 2063 - cmdp->u.cache.BlockCnt = blockcnt; 2064 - } 2065 - 2066 - if (scsi_bufflen(scp)) { 2067 - cmndinfo->dma_dir = (read_write == 1 ? 2068 - DMA_TO_DEVICE : DMA_FROM_DEVICE); 2069 - sgcnt = dma_map_sg(&ha->pdev->dev, scsi_sglist(scp), 2070 - scsi_sg_count(scp), cmndinfo->dma_dir); 2071 - if (mode64) { 2072 - struct scatterlist *sl; 2073 - 2074 - cmdp->u.cache64.DestAddr= (u64)-1; 2075 - cmdp->u.cache64.sg_canz = sgcnt; 2076 - scsi_for_each_sg(scp, sl, sgcnt, i) { 2077 - cmdp->u.cache64.sg_lst[i].sg_ptr = sg_dma_address(sl); 2078 - cmdp->u.cache64.sg_lst[i].sg_len = sg_dma_len(sl); 2079 - } 2080 - } else { 2081 - struct scatterlist *sl; 2082 - 2083 - cmdp->u.cache.DestAddr= 0xffffffff; 2084 - cmdp->u.cache.sg_canz = sgcnt; 2085 - scsi_for_each_sg(scp, sl, sgcnt, i) { 2086 - cmdp->u.cache.sg_lst[i].sg_ptr = sg_dma_address(sl); 2087 - cmdp->u.cache.sg_lst[i].sg_len = sg_dma_len(sl); 2088 - } 2089 - } 2090 - 2091 - #ifdef GDTH_STATISTICS 2092 - if (max_sg < (u32)sgcnt) { 2093 - max_sg = (u32)sgcnt; 2094 - TRACE3(("GDT: max_sg = %d\n",max_sg)); 2095 - } 2096 - #endif 2097 - 2098 - } 2099 - } 2100 - /* evaluate command size, check space */ 2101 - if (mode64) { 2102 - TRACE(("cache cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n", 2103 - cmdp->u.cache64.DestAddr,cmdp->u.cache64.sg_canz, 2104 - cmdp->u.cache64.sg_lst[0].sg_ptr, 2105 - cmdp->u.cache64.sg_lst[0].sg_len)); 2106 - TRACE(("cache cmd: cmd %d blockno. %d, blockcnt %d\n", 2107 - cmdp->OpCode,cmdp->u.cache64.BlockNo,cmdp->u.cache64.BlockCnt)); 2108 - ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.cache64.sg_lst) + 2109 - (u16)cmdp->u.cache64.sg_canz * sizeof(gdth_sg64_str); 2110 - } else { 2111 - TRACE(("cache cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n", 2112 - cmdp->u.cache.DestAddr,cmdp->u.cache.sg_canz, 2113 - cmdp->u.cache.sg_lst[0].sg_ptr, 2114 - cmdp->u.cache.sg_lst[0].sg_len)); 2115 - TRACE(("cache cmd: cmd %d blockno. %d, blockcnt %d\n", 2116 - cmdp->OpCode,cmdp->u.cache.BlockNo,cmdp->u.cache.BlockCnt)); 2117 - ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.cache.sg_lst) + 2118 - (u16)cmdp->u.cache.sg_canz * sizeof(gdth_sg_str); 2119 - } 2120 - if (ha->cmd_len & 3) 2121 - ha->cmd_len += (4 - (ha->cmd_len & 3)); 2122 - 2123 - if (ha->cmd_cnt > 0) { 2124 - if ((ha->cmd_offs_dpmem + ha->cmd_len + DPMEM_COMMAND_OFFSET) > 2125 - ha->ic_all_size) { 2126 - TRACE2(("gdth_fill_cache() DPMEM overflow\n")); 2127 - ha->cmd_tab[cmd_index-2].cmnd = UNUSED_CMND; 2128 - return 0; 2129 - } 2130 - } 2131 - 2132 - /* copy command */ 2133 - gdth_copy_command(ha); 2134 - return cmd_index; 2135 - } 2136 - 2137 - static int gdth_fill_raw_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp, u8 b) 2138 - { 2139 - register gdth_cmd_str *cmdp; 2140 - u16 i; 2141 - dma_addr_t sense_paddr; 2142 - int cmd_index, sgcnt, mode64; 2143 - u8 t,l; 2144 - struct gdth_cmndinfo *cmndinfo; 2145 - 2146 - t = scp->device->id; 2147 - l = scp->device->lun; 2148 - cmdp = ha->pccb; 2149 - TRACE(("gdth_fill_raw_cmd() cmd 0x%x bus %d ID %d LUN %d\n", 2150 - scp->cmnd[0],b,t,l)); 2151 - 2152 - mode64 = (ha->raw_feat & GDT_64BIT) ? TRUE : FALSE; 2153 - 2154 - cmdp->Service = SCSIRAWSERVICE; 2155 - cmdp->RequestBuffer = scp; 2156 - /* search free command index */ 2157 - if (!(cmd_index=gdth_get_cmd_index(ha))) { 2158 - TRACE(("GDT: No free command index found\n")); 2159 - return 0; 2160 - } 2161 - /* if it's the first command, set command semaphore */ 2162 - if (ha->cmd_cnt == 0) 2163 - gdth_set_sema0(ha); 2164 - 2165 - cmndinfo = gdth_cmnd_priv(scp); 2166 - /* fill command */ 2167 - if (cmndinfo->OpCode != -1) { 2168 - cmdp->OpCode = cmndinfo->OpCode; /* special raw cmd. */ 2169 - cmdp->BoardNode = LOCALBOARD; 2170 - if (mode64) { 2171 - cmdp->u.raw64.direction = (cmndinfo->phase >> 8); 2172 - TRACE2(("special raw cmd 0x%x param 0x%x\n", 2173 - cmdp->OpCode, cmdp->u.raw64.direction)); 2174 - /* evaluate command size */ 2175 - ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw64.sg_lst); 2176 - } else { 2177 - cmdp->u.raw.direction = (cmndinfo->phase >> 8); 2178 - TRACE2(("special raw cmd 0x%x param 0x%x\n", 2179 - cmdp->OpCode, cmdp->u.raw.direction)); 2180 - /* evaluate command size */ 2181 - ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw.sg_lst); 2182 - } 2183 - 2184 - } else { 2185 - sense_paddr = dma_map_single(&ha->pdev->dev, scp->sense_buffer, 16, 2186 - DMA_FROM_DEVICE); 2187 - 2188 - cmndinfo->sense_paddr = sense_paddr; 2189 - cmdp->OpCode = GDT_WRITE; /* always */ 2190 - cmdp->BoardNode = LOCALBOARD; 2191 - if (mode64) { 2192 - cmdp->u.raw64.reserved = 0; 2193 - cmdp->u.raw64.mdisc_time = 0; 2194 - cmdp->u.raw64.mcon_time = 0; 2195 - cmdp->u.raw64.clen = scp->cmd_len; 2196 - cmdp->u.raw64.target = t; 2197 - cmdp->u.raw64.lun = l; 2198 - cmdp->u.raw64.bus = b; 2199 - cmdp->u.raw64.priority = 0; 2200 - cmdp->u.raw64.sdlen = scsi_bufflen(scp); 2201 - cmdp->u.raw64.sense_len = 16; 2202 - cmdp->u.raw64.sense_data = sense_paddr; 2203 - cmdp->u.raw64.direction = 2204 - gdth_direction_tab[scp->cmnd[0]]==DOU ? GDTH_DATA_OUT:GDTH_DATA_IN; 2205 - memcpy(cmdp->u.raw64.cmd,scp->cmnd,16); 2206 - cmdp->u.raw64.sg_ranz = 0; 2207 - } else { 2208 - cmdp->u.raw.reserved = 0; 2209 - cmdp->u.raw.mdisc_time = 0; 2210 - cmdp->u.raw.mcon_time = 0; 2211 - cmdp->u.raw.clen = scp->cmd_len; 2212 - cmdp->u.raw.target = t; 2213 - cmdp->u.raw.lun = l; 2214 - cmdp->u.raw.bus = b; 2215 - cmdp->u.raw.priority = 0; 2216 - cmdp->u.raw.link_p = 0; 2217 - cmdp->u.raw.sdlen = scsi_bufflen(scp); 2218 - cmdp->u.raw.sense_len = 16; 2219 - cmdp->u.raw.sense_data = sense_paddr; 2220 - cmdp->u.raw.direction = 2221 - gdth_direction_tab[scp->cmnd[0]]==DOU ? GDTH_DATA_OUT:GDTH_DATA_IN; 2222 - memcpy(cmdp->u.raw.cmd,scp->cmnd,12); 2223 - cmdp->u.raw.sg_ranz = 0; 2224 - } 2225 - 2226 - if (scsi_bufflen(scp)) { 2227 - cmndinfo->dma_dir = DMA_BIDIRECTIONAL; 2228 - sgcnt = dma_map_sg(&ha->pdev->dev, scsi_sglist(scp), 2229 - scsi_sg_count(scp), cmndinfo->dma_dir); 2230 - if (mode64) { 2231 - struct scatterlist *sl; 2232 - 2233 - cmdp->u.raw64.sdata = (u64)-1; 2234 - cmdp->u.raw64.sg_ranz = sgcnt; 2235 - scsi_for_each_sg(scp, sl, sgcnt, i) { 2236 - cmdp->u.raw64.sg_lst[i].sg_ptr = sg_dma_address(sl); 2237 - cmdp->u.raw64.sg_lst[i].sg_len = sg_dma_len(sl); 2238 - } 2239 - } else { 2240 - struct scatterlist *sl; 2241 - 2242 - cmdp->u.raw.sdata = 0xffffffff; 2243 - cmdp->u.raw.sg_ranz = sgcnt; 2244 - scsi_for_each_sg(scp, sl, sgcnt, i) { 2245 - cmdp->u.raw.sg_lst[i].sg_ptr = sg_dma_address(sl); 2246 - cmdp->u.raw.sg_lst[i].sg_len = sg_dma_len(sl); 2247 - } 2248 - } 2249 - 2250 - #ifdef GDTH_STATISTICS 2251 - if (max_sg < sgcnt) { 2252 - max_sg = sgcnt; 2253 - TRACE3(("GDT: max_sg = %d\n",sgcnt)); 2254 - } 2255 - #endif 2256 - 2257 - } 2258 - if (mode64) { 2259 - TRACE(("raw cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n", 2260 - cmdp->u.raw64.sdata,cmdp->u.raw64.sg_ranz, 2261 - cmdp->u.raw64.sg_lst[0].sg_ptr, 2262 - cmdp->u.raw64.sg_lst[0].sg_len)); 2263 - /* evaluate command size */ 2264 - ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw64.sg_lst) + 2265 - (u16)cmdp->u.raw64.sg_ranz * sizeof(gdth_sg64_str); 2266 - } else { 2267 - TRACE(("raw cmd: addr. %x sganz %x sgptr0 %x sglen0 %x\n", 2268 - cmdp->u.raw.sdata,cmdp->u.raw.sg_ranz, 2269 - cmdp->u.raw.sg_lst[0].sg_ptr, 2270 - cmdp->u.raw.sg_lst[0].sg_len)); 2271 - /* evaluate command size */ 2272 - ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw.sg_lst) + 2273 - (u16)cmdp->u.raw.sg_ranz * sizeof(gdth_sg_str); 2274 - } 2275 - } 2276 - /* check space */ 2277 - if (ha->cmd_len & 3) 2278 - ha->cmd_len += (4 - (ha->cmd_len & 3)); 2279 - 2280 - if (ha->cmd_cnt > 0) { 2281 - if ((ha->cmd_offs_dpmem + ha->cmd_len + DPMEM_COMMAND_OFFSET) > 2282 - ha->ic_all_size) { 2283 - TRACE2(("gdth_fill_raw() DPMEM overflow\n")); 2284 - ha->cmd_tab[cmd_index-2].cmnd = UNUSED_CMND; 2285 - return 0; 2286 - } 2287 - } 2288 - 2289 - /* copy command */ 2290 - gdth_copy_command(ha); 2291 - return cmd_index; 2292 - } 2293 - 2294 - static int gdth_special_cmd(gdth_ha_str *ha, struct scsi_cmnd *scp) 2295 - { 2296 - register gdth_cmd_str *cmdp; 2297 - struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp); 2298 - int cmd_index; 2299 - 2300 - cmdp= ha->pccb; 2301 - TRACE2(("gdth_special_cmd(): ")); 2302 - 2303 - *cmdp = *cmndinfo->internal_cmd_str; 2304 - cmdp->RequestBuffer = scp; 2305 - 2306 - /* search free command index */ 2307 - if (!(cmd_index=gdth_get_cmd_index(ha))) { 2308 - TRACE(("GDT: No free command index found\n")); 2309 - return 0; 2310 - } 2311 - 2312 - /* if it's the first command, set command semaphore */ 2313 - if (ha->cmd_cnt == 0) 2314 - gdth_set_sema0(ha); 2315 - 2316 - /* evaluate command size, check space */ 2317 - if (cmdp->OpCode == GDT_IOCTL) { 2318 - TRACE2(("IOCTL\n")); 2319 - ha->cmd_len = 2320 - GDTOFFSOF(gdth_cmd_str,u.ioctl.p_param) + sizeof(u64); 2321 - } else if (cmdp->Service == CACHESERVICE) { 2322 - TRACE2(("cache command %d\n",cmdp->OpCode)); 2323 - if (ha->cache_feat & GDT_64BIT) 2324 - ha->cmd_len = 2325 - GDTOFFSOF(gdth_cmd_str,u.cache64.sg_lst) + sizeof(gdth_sg64_str); 2326 - else 2327 - ha->cmd_len = 2328 - GDTOFFSOF(gdth_cmd_str,u.cache.sg_lst) + sizeof(gdth_sg_str); 2329 - } else if (cmdp->Service == SCSIRAWSERVICE) { 2330 - TRACE2(("raw command %d\n",cmdp->OpCode)); 2331 - if (ha->raw_feat & GDT_64BIT) 2332 - ha->cmd_len = 2333 - GDTOFFSOF(gdth_cmd_str,u.raw64.sg_lst) + sizeof(gdth_sg64_str); 2334 - else 2335 - ha->cmd_len = 2336 - GDTOFFSOF(gdth_cmd_str,u.raw.sg_lst) + sizeof(gdth_sg_str); 2337 - } 2338 - 2339 - if (ha->cmd_len & 3) 2340 - ha->cmd_len += (4 - (ha->cmd_len & 3)); 2341 - 2342 - if (ha->cmd_cnt > 0) { 2343 - if ((ha->cmd_offs_dpmem + ha->cmd_len + DPMEM_COMMAND_OFFSET) > 2344 - ha->ic_all_size) { 2345 - TRACE2(("gdth_special_cmd() DPMEM overflow\n")); 2346 - ha->cmd_tab[cmd_index-2].cmnd = UNUSED_CMND; 2347 - return 0; 2348 - } 2349 - } 2350 - 2351 - /* copy command */ 2352 - gdth_copy_command(ha); 2353 - return cmd_index; 2354 - } 2355 - 2356 - 2357 - /* Controller event handling functions */ 2358 - static gdth_evt_str *gdth_store_event(gdth_ha_str *ha, u16 source, 2359 - u16 idx, gdth_evt_data *evt) 2360 - { 2361 - gdth_evt_str *e; 2362 - 2363 - /* no GDTH_LOCK_HA() ! */ 2364 - TRACE2(("gdth_store_event() source %d idx %d\n", source, idx)); 2365 - if (source == 0) /* no source -> no event */ 2366 - return NULL; 2367 - 2368 - if (ebuffer[elastidx].event_source == source && 2369 - ebuffer[elastidx].event_idx == idx && 2370 - ((evt->size != 0 && ebuffer[elastidx].event_data.size != 0 && 2371 - !memcmp((char *)&ebuffer[elastidx].event_data.eu, 2372 - (char *)&evt->eu, evt->size)) || 2373 - (evt->size == 0 && ebuffer[elastidx].event_data.size == 0 && 2374 - !strcmp((char *)&ebuffer[elastidx].event_data.event_string, 2375 - (char *)&evt->event_string)))) { 2376 - e = &ebuffer[elastidx]; 2377 - e->last_stamp = (u32)ktime_get_real_seconds(); 2378 - ++e->same_count; 2379 - } else { 2380 - if (ebuffer[elastidx].event_source != 0) { /* entry not free ? */ 2381 - ++elastidx; 2382 - if (elastidx == MAX_EVENTS) 2383 - elastidx = 0; 2384 - if (elastidx == eoldidx) { /* reached mark ? */ 2385 - ++eoldidx; 2386 - if (eoldidx == MAX_EVENTS) 2387 - eoldidx = 0; 2388 - } 2389 - } 2390 - e = &ebuffer[elastidx]; 2391 - e->event_source = source; 2392 - e->event_idx = idx; 2393 - e->first_stamp = e->last_stamp = (u32)ktime_get_real_seconds(); 2394 - e->same_count = 1; 2395 - e->event_data = *evt; 2396 - e->application = 0; 2397 - } 2398 - return e; 2399 - } 2400 - 2401 - static int gdth_read_event(gdth_ha_str *ha, int handle, gdth_evt_str *estr) 2402 - { 2403 - gdth_evt_str *e; 2404 - int eindex; 2405 - unsigned long flags; 2406 - 2407 - TRACE2(("gdth_read_event() handle %d\n", handle)); 2408 - spin_lock_irqsave(&ha->smp_lock, flags); 2409 - if (handle == -1) 2410 - eindex = eoldidx; 2411 - else 2412 - eindex = handle; 2413 - estr->event_source = 0; 2414 - 2415 - if (eindex < 0 || eindex >= MAX_EVENTS) { 2416 - spin_unlock_irqrestore(&ha->smp_lock, flags); 2417 - return eindex; 2418 - } 2419 - e = &ebuffer[eindex]; 2420 - if (e->event_source != 0) { 2421 - if (eindex != elastidx) { 2422 - if (++eindex == MAX_EVENTS) 2423 - eindex = 0; 2424 - } else { 2425 - eindex = -1; 2426 - } 2427 - memcpy(estr, e, sizeof(gdth_evt_str)); 2428 - } 2429 - spin_unlock_irqrestore(&ha->smp_lock, flags); 2430 - return eindex; 2431 - } 2432 - 2433 - static void gdth_readapp_event(gdth_ha_str *ha, 2434 - u8 application, gdth_evt_str *estr) 2435 - { 2436 - gdth_evt_str *e; 2437 - int eindex; 2438 - unsigned long flags; 2439 - u8 found = FALSE; 2440 - 2441 - TRACE2(("gdth_readapp_event() app. %d\n", application)); 2442 - spin_lock_irqsave(&ha->smp_lock, flags); 2443 - eindex = eoldidx; 2444 - for (;;) { 2445 - e = &ebuffer[eindex]; 2446 - if (e->event_source == 0) 2447 - break; 2448 - if ((e->application & application) == 0) { 2449 - e->application |= application; 2450 - found = TRUE; 2451 - break; 2452 - } 2453 - if (eindex == elastidx) 2454 - break; 2455 - if (++eindex == MAX_EVENTS) 2456 - eindex = 0; 2457 - } 2458 - if (found) 2459 - memcpy(estr, e, sizeof(gdth_evt_str)); 2460 - else 2461 - estr->event_source = 0; 2462 - spin_unlock_irqrestore(&ha->smp_lock, flags); 2463 - } 2464 - 2465 - static void gdth_clear_events(void) 2466 - { 2467 - TRACE(("gdth_clear_events()")); 2468 - 2469 - eoldidx = elastidx = 0; 2470 - ebuffer[0].event_source = 0; 2471 - } 2472 - 2473 - 2474 - /* SCSI interface functions */ 2475 - 2476 - static irqreturn_t __gdth_interrupt(gdth_ha_str *ha, 2477 - int gdth_from_wait, int* pIndex) 2478 - { 2479 - gdt6m_dpram_str __iomem *dp6m_ptr = NULL; 2480 - gdt6_dpram_str __iomem *dp6_ptr; 2481 - struct scsi_cmnd *scp; 2482 - int rval, i; 2483 - u8 IStatus; 2484 - u16 Service; 2485 - unsigned long flags = 0; 2486 - 2487 - TRACE(("gdth_interrupt() IRQ %d\n", ha->irq)); 2488 - 2489 - /* if polling and not from gdth_wait() -> return */ 2490 - if (gdth_polling) { 2491 - if (!gdth_from_wait) { 2492 - return IRQ_HANDLED; 2493 - } 2494 - } 2495 - 2496 - if (!gdth_polling) 2497 - spin_lock_irqsave(&ha->smp_lock, flags); 2498 - 2499 - /* search controller */ 2500 - IStatus = gdth_get_status(ha); 2501 - if (IStatus == 0) { 2502 - /* spurious interrupt */ 2503 - if (!gdth_polling) 2504 - spin_unlock_irqrestore(&ha->smp_lock, flags); 2505 - return IRQ_HANDLED; 2506 - } 2507 - 2508 - #ifdef GDTH_STATISTICS 2509 - ++act_ints; 2510 - #endif 2511 - 2512 - if (ha->type == GDT_PCI) { 2513 - dp6_ptr = ha->brd; 2514 - if (IStatus & 0x80) { /* error flag */ 2515 - IStatus &= ~0x80; 2516 - ha->status = readw(&dp6_ptr->u.ic.Status); 2517 - TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,ha->status)); 2518 - } else /* no error */ 2519 - ha->status = S_OK; 2520 - ha->info = readl(&dp6_ptr->u.ic.Info[0]); 2521 - ha->service = readw(&dp6_ptr->u.ic.Service); 2522 - ha->info2 = readl(&dp6_ptr->u.ic.Info[1]); 2523 - 2524 - writeb(0xff, &dp6_ptr->io.irqdel); /* acknowledge interrupt */ 2525 - writeb(0, &dp6_ptr->u.ic.Cmd_Index);/* reset command index */ 2526 - writeb(0, &dp6_ptr->io.Sema1); /* reset status semaphore */ 2527 - } else if (ha->type == GDT_PCINEW) { 2528 - if (IStatus & 0x80) { /* error flag */ 2529 - IStatus &= ~0x80; 2530 - ha->status = inw(PTR2USHORT(&ha->plx->status)); 2531 - TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,ha->status)); 2532 - } else 2533 - ha->status = S_OK; 2534 - ha->info = inl(PTR2USHORT(&ha->plx->info[0])); 2535 - ha->service = inw(PTR2USHORT(&ha->plx->service)); 2536 - ha->info2 = inl(PTR2USHORT(&ha->plx->info[1])); 2537 - 2538 - outb(0xff, PTR2USHORT(&ha->plx->edoor_reg)); 2539 - outb(0x00, PTR2USHORT(&ha->plx->sema1_reg)); 2540 - } else if (ha->type == GDT_PCIMPR) { 2541 - dp6m_ptr = ha->brd; 2542 - if (IStatus & 0x80) { /* error flag */ 2543 - IStatus &= ~0x80; 2544 - ha->status = readw(&dp6m_ptr->i960r.status); 2545 - TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,ha->status)); 2546 - } else /* no error */ 2547 - ha->status = S_OK; 2548 - 2549 - ha->info = readl(&dp6m_ptr->i960r.info[0]); 2550 - ha->service = readw(&dp6m_ptr->i960r.service); 2551 - ha->info2 = readl(&dp6m_ptr->i960r.info[1]); 2552 - 2553 - /* event string */ 2554 - if (IStatus == ASYNCINDEX) { 2555 - if (ha->service != SCREENSERVICE && 2556 - (ha->fw_vers & 0xff) >= 0x1a) { 2557 - ha->dvr.severity = readb 2558 - (&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.severity); 2559 - for (i = 0; i < 256; ++i) { 2560 - ha->dvr.event_string[i] = readb 2561 - (&((gdt6m_dpram_str __iomem *)ha->brd)->i960r.evt_str[i]); 2562 - if (ha->dvr.event_string[i] == 0) 2563 - break; 2564 - } 2565 - } 2566 - } 2567 - writeb(0xff, &dp6m_ptr->i960r.edoor_reg); 2568 - writeb(0, &dp6m_ptr->i960r.sema1_reg); 2569 - } else { 2570 - TRACE2(("gdth_interrupt() unknown controller type\n")); 2571 - if (!gdth_polling) 2572 - spin_unlock_irqrestore(&ha->smp_lock, flags); 2573 - return IRQ_HANDLED; 2574 - } 2575 - 2576 - TRACE(("gdth_interrupt() index %d stat %d info %d\n", 2577 - IStatus,ha->status,ha->info)); 2578 - 2579 - if (gdth_from_wait) { 2580 - *pIndex = (int)IStatus; 2581 - } 2582 - 2583 - if (IStatus == ASYNCINDEX) { 2584 - TRACE2(("gdth_interrupt() async. event\n")); 2585 - gdth_async_event(ha); 2586 - if (!gdth_polling) 2587 - spin_unlock_irqrestore(&ha->smp_lock, flags); 2588 - gdth_next(ha); 2589 - return IRQ_HANDLED; 2590 - } 2591 - 2592 - if (IStatus == SPEZINDEX) { 2593 - TRACE2(("Service unknown or not initialized !\n")); 2594 - ha->dvr.size = sizeof(ha->dvr.eu.driver); 2595 - ha->dvr.eu.driver.ionode = ha->hanum; 2596 - gdth_store_event(ha, ES_DRIVER, 4, &ha->dvr); 2597 - if (!gdth_polling) 2598 - spin_unlock_irqrestore(&ha->smp_lock, flags); 2599 - return IRQ_HANDLED; 2600 - } 2601 - scp = ha->cmd_tab[IStatus-2].cmnd; 2602 - Service = ha->cmd_tab[IStatus-2].service; 2603 - ha->cmd_tab[IStatus-2].cmnd = UNUSED_CMND; 2604 - if (scp == UNUSED_CMND) { 2605 - TRACE2(("gdth_interrupt() index to unused command (%d)\n",IStatus)); 2606 - ha->dvr.size = sizeof(ha->dvr.eu.driver); 2607 - ha->dvr.eu.driver.ionode = ha->hanum; 2608 - ha->dvr.eu.driver.index = IStatus; 2609 - gdth_store_event(ha, ES_DRIVER, 1, &ha->dvr); 2610 - if (!gdth_polling) 2611 - spin_unlock_irqrestore(&ha->smp_lock, flags); 2612 - return IRQ_HANDLED; 2613 - } 2614 - if (scp == INTERNAL_CMND) { 2615 - TRACE(("gdth_interrupt() answer to internal command\n")); 2616 - if (!gdth_polling) 2617 - spin_unlock_irqrestore(&ha->smp_lock, flags); 2618 - return IRQ_HANDLED; 2619 - } 2620 - 2621 - TRACE(("gdth_interrupt() sync. status\n")); 2622 - rval = gdth_sync_event(ha,Service,IStatus,scp); 2623 - if (!gdth_polling) 2624 - spin_unlock_irqrestore(&ha->smp_lock, flags); 2625 - if (rval == 2) { 2626 - gdth_putq(ha, scp, gdth_cmnd_priv(scp)->priority); 2627 - } else if (rval == 1) { 2628 - gdth_scsi_done(scp); 2629 - } 2630 - 2631 - gdth_next(ha); 2632 - return IRQ_HANDLED; 2633 - } 2634 - 2635 - static irqreturn_t gdth_interrupt(int irq, void *dev_id) 2636 - { 2637 - gdth_ha_str *ha = dev_id; 2638 - 2639 - return __gdth_interrupt(ha, false, NULL); 2640 - } 2641 - 2642 - static int gdth_sync_event(gdth_ha_str *ha, int service, u8 index, 2643 - struct scsi_cmnd *scp) 2644 - { 2645 - gdth_msg_str *msg; 2646 - gdth_cmd_str *cmdp; 2647 - u8 b, t; 2648 - struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp); 2649 - 2650 - cmdp = ha->pccb; 2651 - TRACE(("gdth_sync_event() serv %d status %d\n", 2652 - service,ha->status)); 2653 - 2654 - if (service == SCREENSERVICE) { 2655 - msg = ha->pmsg; 2656 - TRACE(("len: %d, answer: %d, ext: %d, alen: %d\n", 2657 - msg->msg_len,msg->msg_answer,msg->msg_ext,msg->msg_alen)); 2658 - if (msg->msg_len > MSGLEN+1) 2659 - msg->msg_len = MSGLEN+1; 2660 - if (msg->msg_len) 2661 - if (!(msg->msg_answer && msg->msg_ext)) { 2662 - msg->msg_text[msg->msg_len] = '\0'; 2663 - printk("%s",msg->msg_text); 2664 - } 2665 - 2666 - if (msg->msg_ext && !msg->msg_answer) { 2667 - while (gdth_test_busy(ha)) 2668 - gdth_delay(0); 2669 - cmdp->Service = SCREENSERVICE; 2670 - cmdp->RequestBuffer = SCREEN_CMND; 2671 - gdth_get_cmd_index(ha); 2672 - gdth_set_sema0(ha); 2673 - cmdp->OpCode = GDT_READ; 2674 - cmdp->BoardNode = LOCALBOARD; 2675 - cmdp->u.screen.reserved = 0; 2676 - cmdp->u.screen.su.msg.msg_handle= msg->msg_handle; 2677 - cmdp->u.screen.su.msg.msg_addr = ha->msg_phys; 2678 - ha->cmd_offs_dpmem = 0; 2679 - ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr) 2680 - + sizeof(u64); 2681 - ha->cmd_cnt = 0; 2682 - gdth_copy_command(ha); 2683 - gdth_release_event(ha); 2684 - return 0; 2685 - } 2686 - 2687 - if (msg->msg_answer && msg->msg_alen) { 2688 - /* default answers (getchar() not possible) */ 2689 - if (msg->msg_alen == 1) { 2690 - msg->msg_alen = 0; 2691 - msg->msg_len = 1; 2692 - msg->msg_text[0] = 0; 2693 - } else { 2694 - msg->msg_alen -= 2; 2695 - msg->msg_len = 2; 2696 - msg->msg_text[0] = 1; 2697 - msg->msg_text[1] = 0; 2698 - } 2699 - msg->msg_ext = 0; 2700 - msg->msg_answer = 0; 2701 - while (gdth_test_busy(ha)) 2702 - gdth_delay(0); 2703 - cmdp->Service = SCREENSERVICE; 2704 - cmdp->RequestBuffer = SCREEN_CMND; 2705 - gdth_get_cmd_index(ha); 2706 - gdth_set_sema0(ha); 2707 - cmdp->OpCode = GDT_WRITE; 2708 - cmdp->BoardNode = LOCALBOARD; 2709 - cmdp->u.screen.reserved = 0; 2710 - cmdp->u.screen.su.msg.msg_handle= msg->msg_handle; 2711 - cmdp->u.screen.su.msg.msg_addr = ha->msg_phys; 2712 - ha->cmd_offs_dpmem = 0; 2713 - ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr) 2714 - + sizeof(u64); 2715 - ha->cmd_cnt = 0; 2716 - gdth_copy_command(ha); 2717 - gdth_release_event(ha); 2718 - return 0; 2719 - } 2720 - printk("\n"); 2721 - 2722 - } else { 2723 - b = scp->device->channel; 2724 - t = scp->device->id; 2725 - if (cmndinfo->OpCode == -1 && b != ha->virt_bus) { 2726 - ha->raw[BUS_L2P(ha,b)].io_cnt[t]--; 2727 - } 2728 - /* cache or raw service */ 2729 - if (ha->status == S_BSY) { 2730 - TRACE2(("Controller busy -> retry !\n")); 2731 - if (cmndinfo->OpCode == GDT_MOUNT) 2732 - cmndinfo->OpCode = GDT_CLUST_INFO; 2733 - /* retry */ 2734 - return 2; 2735 - } 2736 - if (scsi_bufflen(scp)) 2737 - dma_unmap_sg(&ha->pdev->dev, scsi_sglist(scp), scsi_sg_count(scp), 2738 - cmndinfo->dma_dir); 2739 - 2740 - if (cmndinfo->sense_paddr) 2741 - dma_unmap_page(&ha->pdev->dev, cmndinfo->sense_paddr, 16, 2742 - DMA_FROM_DEVICE); 2743 - 2744 - if (ha->status == S_OK) { 2745 - cmndinfo->status = S_OK; 2746 - cmndinfo->info = ha->info; 2747 - if (cmndinfo->OpCode != -1) { 2748 - TRACE2(("gdth_sync_event(): special cmd 0x%x OK\n", 2749 - cmndinfo->OpCode)); 2750 - /* special commands GDT_CLUST_INFO/GDT_MOUNT ? */ 2751 - if (cmndinfo->OpCode == GDT_CLUST_INFO) { 2752 - ha->hdr[t].cluster_type = (u8)ha->info; 2753 - if (!(ha->hdr[t].cluster_type & 2754 - CLUSTER_MOUNTED)) { 2755 - /* NOT MOUNTED -> MOUNT */ 2756 - cmndinfo->OpCode = GDT_MOUNT; 2757 - if (ha->hdr[t].cluster_type & 2758 - CLUSTER_RESERVED) { 2759 - /* cluster drive RESERVED (on the other node) */ 2760 - cmndinfo->phase = -2; /* reservation conflict */ 2761 - } 2762 - } else { 2763 - cmndinfo->OpCode = -1; 2764 - } 2765 - } else { 2766 - if (cmndinfo->OpCode == GDT_MOUNT) { 2767 - ha->hdr[t].cluster_type |= CLUSTER_MOUNTED; 2768 - ha->hdr[t].media_changed = TRUE; 2769 - } else if (cmndinfo->OpCode == GDT_UNMOUNT) { 2770 - ha->hdr[t].cluster_type &= ~CLUSTER_MOUNTED; 2771 - ha->hdr[t].media_changed = TRUE; 2772 - } 2773 - cmndinfo->OpCode = -1; 2774 - } 2775 - /* retry */ 2776 - cmndinfo->priority = HIGH_PRI; 2777 - return 2; 2778 - } else { 2779 - /* RESERVE/RELEASE ? */ 2780 - if (scp->cmnd[0] == RESERVE) { 2781 - ha->hdr[t].cluster_type |= CLUSTER_RESERVED; 2782 - } else if (scp->cmnd[0] == RELEASE) { 2783 - ha->hdr[t].cluster_type &= ~CLUSTER_RESERVED; 2784 - } 2785 - scp->result = DID_OK << 16; 2786 - scp->sense_buffer[0] = 0; 2787 - } 2788 - } else { 2789 - cmndinfo->status = ha->status; 2790 - cmndinfo->info = ha->info; 2791 - 2792 - if (cmndinfo->OpCode != -1) { 2793 - TRACE2(("gdth_sync_event(): special cmd 0x%x error 0x%x\n", 2794 - cmndinfo->OpCode, ha->status)); 2795 - if (cmndinfo->OpCode == GDT_SCAN_START || 2796 - cmndinfo->OpCode == GDT_SCAN_END) { 2797 - cmndinfo->OpCode = -1; 2798 - /* retry */ 2799 - cmndinfo->priority = HIGH_PRI; 2800 - return 2; 2801 - } 2802 - memset((char*)scp->sense_buffer,0,16); 2803 - scp->sense_buffer[0] = 0x70; 2804 - scp->sense_buffer[2] = NOT_READY; 2805 - scp->result = (DID_OK << 16) | (CHECK_CONDITION << 1); 2806 - } else if (service == CACHESERVICE) { 2807 - if (ha->status == S_CACHE_UNKNOWN && 2808 - (ha->hdr[t].cluster_type & 2809 - CLUSTER_RESERVE_STATE) == CLUSTER_RESERVE_STATE) { 2810 - /* bus reset -> force GDT_CLUST_INFO */ 2811 - ha->hdr[t].cluster_type &= ~CLUSTER_RESERVED; 2812 - } 2813 - memset((char*)scp->sense_buffer,0,16); 2814 - if (ha->status == (u16)S_CACHE_RESERV) { 2815 - scp->result = (DID_OK << 16) | (RESERVATION_CONFLICT << 1); 2816 - } else { 2817 - scp->sense_buffer[0] = 0x70; 2818 - scp->sense_buffer[2] = NOT_READY; 2819 - scp->result = (DID_OK << 16) | (CHECK_CONDITION << 1); 2820 - } 2821 - if (!cmndinfo->internal_command) { 2822 - ha->dvr.size = sizeof(ha->dvr.eu.sync); 2823 - ha->dvr.eu.sync.ionode = ha->hanum; 2824 - ha->dvr.eu.sync.service = service; 2825 - ha->dvr.eu.sync.status = ha->status; 2826 - ha->dvr.eu.sync.info = ha->info; 2827 - ha->dvr.eu.sync.hostdrive = t; 2828 - if (ha->status >= 0x8000) 2829 - gdth_store_event(ha, ES_SYNC, 0, &ha->dvr); 2830 - else 2831 - gdth_store_event(ha, ES_SYNC, service, &ha->dvr); 2832 - } 2833 - } else { 2834 - /* sense buffer filled from controller firmware (DMA) */ 2835 - if (ha->status != S_RAW_SCSI || ha->info >= 0x100) { 2836 - scp->result = DID_BAD_TARGET << 16; 2837 - } else { 2838 - scp->result = (DID_OK << 16) | ha->info; 2839 - } 2840 - } 2841 - } 2842 - if (!cmndinfo->wait_for_completion) 2843 - cmndinfo->wait_for_completion++; 2844 - else 2845 - return 1; 2846 - } 2847 - 2848 - return 0; 2849 - } 2850 - 2851 - static char *async_cache_tab[] = { 2852 - /* 0*/ "\011\000\002\002\002\004\002\006\004" 2853 - "GDT HA %u, service %u, async. status %u/%lu unknown", 2854 - /* 1*/ "\011\000\002\002\002\004\002\006\004" 2855 - "GDT HA %u, service %u, async. status %u/%lu unknown", 2856 - /* 2*/ "\005\000\002\006\004" 2857 - "GDT HA %u, Host Drive %lu not ready", 2858 - /* 3*/ "\005\000\002\006\004" 2859 - "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", 2860 - /* 4*/ "\005\000\002\006\004" 2861 - "GDT HA %u, mirror update on Host Drive %lu failed", 2862 - /* 5*/ "\005\000\002\006\004" 2863 - "GDT HA %u, Mirror Drive %lu failed", 2864 - /* 6*/ "\005\000\002\006\004" 2865 - "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", 2866 - /* 7*/ "\005\000\002\006\004" 2867 - "GDT HA %u, Host Drive %lu write protected", 2868 - /* 8*/ "\005\000\002\006\004" 2869 - "GDT HA %u, media changed in Host Drive %lu", 2870 - /* 9*/ "\005\000\002\006\004" 2871 - "GDT HA %u, Host Drive %lu is offline", 2872 - /*10*/ "\005\000\002\006\004" 2873 - "GDT HA %u, media change of Mirror Drive %lu", 2874 - /*11*/ "\005\000\002\006\004" 2875 - "GDT HA %u, Mirror Drive %lu is write protected", 2876 - /*12*/ "\005\000\002\006\004" 2877 - "GDT HA %u, general error on Host Drive %lu. Please check the devices of this drive!", 2878 - /*13*/ "\007\000\002\006\002\010\002" 2879 - "GDT HA %u, Array Drive %u: Cache Drive %u failed", 2880 - /*14*/ "\005\000\002\006\002" 2881 - "GDT HA %u, Array Drive %u: FAIL state entered", 2882 - /*15*/ "\005\000\002\006\002" 2883 - "GDT HA %u, Array Drive %u: error", 2884 - /*16*/ "\007\000\002\006\002\010\002" 2885 - "GDT HA %u, Array Drive %u: failed drive replaced by Cache Drive %u", 2886 - /*17*/ "\005\000\002\006\002" 2887 - "GDT HA %u, Array Drive %u: parity build failed", 2888 - /*18*/ "\005\000\002\006\002" 2889 - "GDT HA %u, Array Drive %u: drive rebuild failed", 2890 - /*19*/ "\005\000\002\010\002" 2891 - "GDT HA %u, Test of Hot Fix %u failed", 2892 - /*20*/ "\005\000\002\006\002" 2893 - "GDT HA %u, Array Drive %u: drive build finished successfully", 2894 - /*21*/ "\005\000\002\006\002" 2895 - "GDT HA %u, Array Drive %u: drive rebuild finished successfully", 2896 - /*22*/ "\007\000\002\006\002\010\002" 2897 - "GDT HA %u, Array Drive %u: Hot Fix %u activated", 2898 - /*23*/ "\005\000\002\006\002" 2899 - "GDT HA %u, Host Drive %u: processing of i/o aborted due to serious drive error", 2900 - /*24*/ "\005\000\002\010\002" 2901 - "GDT HA %u, mirror update on Cache Drive %u completed", 2902 - /*25*/ "\005\000\002\010\002" 2903 - "GDT HA %u, mirror update on Cache Drive %lu failed", 2904 - /*26*/ "\005\000\002\006\002" 2905 - "GDT HA %u, Array Drive %u: drive rebuild started", 2906 - /*27*/ "\005\000\002\012\001" 2907 - "GDT HA %u, Fault bus %u: SHELF OK detected", 2908 - /*28*/ "\005\000\002\012\001" 2909 - "GDT HA %u, Fault bus %u: SHELF not OK detected", 2910 - /*29*/ "\007\000\002\012\001\013\001" 2911 - "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug started", 2912 - /*30*/ "\007\000\002\012\001\013\001" 2913 - "GDT HA %u, Fault bus %u, ID %u: new disk detected", 2914 - /*31*/ "\007\000\002\012\001\013\001" 2915 - "GDT HA %u, Fault bus %u, ID %u: old disk detected", 2916 - /*32*/ "\007\000\002\012\001\013\001" 2917 - "GDT HA %u, Fault bus %u, ID %u: plugging an active disk is invalid", 2918 - /*33*/ "\007\000\002\012\001\013\001" 2919 - "GDT HA %u, Fault bus %u, ID %u: invalid device detected", 2920 - /*34*/ "\011\000\002\012\001\013\001\006\004" 2921 - "GDT HA %u, Fault bus %u, ID %u: insufficient disk capacity (%lu MB required)", 2922 - /*35*/ "\007\000\002\012\001\013\001" 2923 - "GDT HA %u, Fault bus %u, ID %u: disk write protected", 2924 - /*36*/ "\007\000\002\012\001\013\001" 2925 - "GDT HA %u, Fault bus %u, ID %u: disk not available", 2926 - /*37*/ "\007\000\002\012\001\006\004" 2927 - "GDT HA %u, Fault bus %u: swap detected (%lu)", 2928 - /*38*/ "\007\000\002\012\001\013\001" 2929 - "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug finished successfully", 2930 - /*39*/ "\007\000\002\012\001\013\001" 2931 - "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug aborted due to user Hot Plug", 2932 - /*40*/ "\007\000\002\012\001\013\001" 2933 - "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug aborted", 2934 - /*41*/ "\007\000\002\012\001\013\001" 2935 - "GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug for Hot Fix started", 2936 - /*42*/ "\005\000\002\006\002" 2937 - "GDT HA %u, Array Drive %u: drive build started", 2938 - /*43*/ "\003\000\002" 2939 - "GDT HA %u, DRAM parity error detected", 2940 - /*44*/ "\005\000\002\006\002" 2941 - "GDT HA %u, Mirror Drive %u: update started", 2942 - /*45*/ "\007\000\002\006\002\010\002" 2943 - "GDT HA %u, Mirror Drive %u: Hot Fix %u activated", 2944 - /*46*/ "\005\000\002\006\002" 2945 - "GDT HA %u, Array Drive %u: no matching Pool Hot Fix Drive available", 2946 - /*47*/ "\005\000\002\006\002" 2947 - "GDT HA %u, Array Drive %u: Pool Hot Fix Drive available", 2948 - /*48*/ "\005\000\002\006\002" 2949 - "GDT HA %u, Mirror Drive %u: no matching Pool Hot Fix Drive available", 2950 - /*49*/ "\005\000\002\006\002" 2951 - "GDT HA %u, Mirror Drive %u: Pool Hot Fix Drive available", 2952 - /*50*/ "\007\000\002\012\001\013\001" 2953 - "GDT HA %u, SCSI bus %u, ID %u: IGNORE_WIDE_RESIDUE message received", 2954 - /*51*/ "\005\000\002\006\002" 2955 - "GDT HA %u, Array Drive %u: expand started", 2956 - /*52*/ "\005\000\002\006\002" 2957 - "GDT HA %u, Array Drive %u: expand finished successfully", 2958 - /*53*/ "\005\000\002\006\002" 2959 - "GDT HA %u, Array Drive %u: expand failed", 2960 - /*54*/ "\003\000\002" 2961 - "GDT HA %u, CPU temperature critical", 2962 - /*55*/ "\003\000\002" 2963 - "GDT HA %u, CPU temperature OK", 2964 - /*56*/ "\005\000\002\006\004" 2965 - "GDT HA %u, Host drive %lu created", 2966 - /*57*/ "\005\000\002\006\002" 2967 - "GDT HA %u, Array Drive %u: expand restarted", 2968 - /*58*/ "\005\000\002\006\002" 2969 - "GDT HA %u, Array Drive %u: expand stopped", 2970 - /*59*/ "\005\000\002\010\002" 2971 - "GDT HA %u, Mirror Drive %u: drive build quited", 2972 - /*60*/ "\005\000\002\006\002" 2973 - "GDT HA %u, Array Drive %u: parity build quited", 2974 - /*61*/ "\005\000\002\006\002" 2975 - "GDT HA %u, Array Drive %u: drive rebuild quited", 2976 - /*62*/ "\005\000\002\006\002" 2977 - "GDT HA %u, Array Drive %u: parity verify started", 2978 - /*63*/ "\005\000\002\006\002" 2979 - "GDT HA %u, Array Drive %u: parity verify done", 2980 - /*64*/ "\005\000\002\006\002" 2981 - "GDT HA %u, Array Drive %u: parity verify failed", 2982 - /*65*/ "\005\000\002\006\002" 2983 - "GDT HA %u, Array Drive %u: parity error detected", 2984 - /*66*/ "\005\000\002\006\002" 2985 - "GDT HA %u, Array Drive %u: parity verify quited", 2986 - /*67*/ "\005\000\002\006\002" 2987 - "GDT HA %u, Host Drive %u reserved", 2988 - /*68*/ "\005\000\002\006\002" 2989 - "GDT HA %u, Host Drive %u mounted and released", 2990 - /*69*/ "\005\000\002\006\002" 2991 - "GDT HA %u, Host Drive %u released", 2992 - /*70*/ "\003\000\002" 2993 - "GDT HA %u, DRAM error detected and corrected with ECC", 2994 - /*71*/ "\003\000\002" 2995 - "GDT HA %u, Uncorrectable DRAM error detected with ECC", 2996 - /*72*/ "\011\000\002\012\001\013\001\014\001" 2997 - "GDT HA %u, SCSI bus %u, ID %u, LUN %u: reassigning block", 2998 - /*73*/ "\005\000\002\006\002" 2999 - "GDT HA %u, Host drive %u resetted locally", 3000 - /*74*/ "\005\000\002\006\002" 3001 - "GDT HA %u, Host drive %u resetted remotely", 3002 - /*75*/ "\003\000\002" 3003 - "GDT HA %u, async. status 75 unknown", 3004 - }; 3005 - 3006 - 3007 - static int gdth_async_event(gdth_ha_str *ha) 3008 - { 3009 - gdth_cmd_str *cmdp; 3010 - 3011 - cmdp= ha->pccb; 3012 - TRACE2(("gdth_async_event() ha %d serv %d\n", 3013 - ha->hanum, ha->service)); 3014 - 3015 - if (ha->service == SCREENSERVICE) { 3016 - if (ha->status == MSG_REQUEST) { 3017 - while (gdth_test_busy(ha)) 3018 - gdth_delay(0); 3019 - cmdp->Service = SCREENSERVICE; 3020 - cmdp->RequestBuffer = SCREEN_CMND; 3021 - gdth_set_sema0(ha); 3022 - cmdp->OpCode = GDT_READ; 3023 - cmdp->BoardNode = LOCALBOARD; 3024 - cmdp->u.screen.reserved = 0; 3025 - cmdp->u.screen.su.msg.msg_handle= MSG_INV_HANDLE; 3026 - cmdp->u.screen.su.msg.msg_addr = ha->msg_phys; 3027 - ha->cmd_offs_dpmem = 0; 3028 - ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.su.msg.msg_addr) 3029 - + sizeof(u64); 3030 - ha->cmd_cnt = 0; 3031 - gdth_copy_command(ha); 3032 - printk("[PCI %d/%d] ",(u16)(ha->brd_phys>>8), 3033 - (u16)((ha->brd_phys>>3)&0x1f)); 3034 - gdth_release_event(ha); 3035 - } 3036 - 3037 - } else { 3038 - if (ha->type == GDT_PCIMPR && 3039 - (ha->fw_vers & 0xff) >= 0x1a) { 3040 - ha->dvr.size = 0; 3041 - ha->dvr.eu.async.ionode = ha->hanum; 3042 - ha->dvr.eu.async.status = ha->status; 3043 - /* severity and event_string already set! */ 3044 - } else { 3045 - ha->dvr.size = sizeof(ha->dvr.eu.async); 3046 - ha->dvr.eu.async.ionode = ha->hanum; 3047 - ha->dvr.eu.async.service = ha->service; 3048 - ha->dvr.eu.async.status = ha->status; 3049 - ha->dvr.eu.async.info = ha->info; 3050 - *(u32 *)ha->dvr.eu.async.scsi_coord = ha->info2; 3051 - } 3052 - gdth_store_event( ha, ES_ASYNC, ha->service, &ha->dvr ); 3053 - gdth_log_event( &ha->dvr, NULL ); 3054 - 3055 - /* new host drive from expand? */ 3056 - if (ha->service == CACHESERVICE && ha->status == 56) { 3057 - TRACE2(("gdth_async_event(): new host drive %d created\n", 3058 - (u16)ha->info)); 3059 - /* gdth_analyse_hdrive(hanum, (u16)ha->info); */ 3060 - } 3061 - } 3062 - return 1; 3063 - } 3064 - 3065 - static void gdth_log_event(gdth_evt_data *dvr, char *buffer) 3066 - { 3067 - gdth_stackframe stack; 3068 - char *f = NULL; 3069 - int i,j; 3070 - 3071 - TRACE2(("gdth_log_event()\n")); 3072 - if (dvr->size == 0) { 3073 - if (buffer == NULL) { 3074 - printk("Adapter %d: %s\n",dvr->eu.async.ionode,dvr->event_string); 3075 - } else { 3076 - sprintf(buffer,"Adapter %d: %s\n", 3077 - dvr->eu.async.ionode,dvr->event_string); 3078 - } 3079 - } else if (dvr->eu.async.service == CACHESERVICE && 3080 - INDEX_OK(dvr->eu.async.status, async_cache_tab)) { 3081 - TRACE2(("GDT: Async. event cache service, event no.: %d\n", 3082 - dvr->eu.async.status)); 3083 - 3084 - f = async_cache_tab[dvr->eu.async.status]; 3085 - 3086 - /* i: parameter to push, j: stack element to fill */ 3087 - for (j=0,i=1; i < f[0]; i+=2) { 3088 - switch (f[i+1]) { 3089 - case 4: 3090 - stack.b[j++] = *(u32*)&dvr->eu.stream[(int)f[i]]; 3091 - break; 3092 - case 2: 3093 - stack.b[j++] = *(u16*)&dvr->eu.stream[(int)f[i]]; 3094 - break; 3095 - case 1: 3096 - stack.b[j++] = *(u8*)&dvr->eu.stream[(int)f[i]]; 3097 - break; 3098 - default: 3099 - break; 3100 - } 3101 - } 3102 - 3103 - if (buffer == NULL) { 3104 - printk(&f[(int)f[0]],stack); 3105 - printk("\n"); 3106 - } else { 3107 - sprintf(buffer,&f[(int)f[0]],stack); 3108 - } 3109 - 3110 - } else { 3111 - if (buffer == NULL) { 3112 - printk("GDT HA %u, Unknown async. event service %d event no. %d\n", 3113 - dvr->eu.async.ionode,dvr->eu.async.service,dvr->eu.async.status); 3114 - } else { 3115 - sprintf(buffer,"GDT HA %u, Unknown async. event service %d event no. %d", 3116 - dvr->eu.async.ionode,dvr->eu.async.service,dvr->eu.async.status); 3117 - } 3118 - } 3119 - } 3120 - 3121 - #ifdef GDTH_STATISTICS 3122 - static u8 gdth_timer_running; 3123 - 3124 - static void gdth_timeout(struct timer_list *unused) 3125 - { 3126 - u32 i; 3127 - struct scsi_cmnd *nscp; 3128 - gdth_ha_str *ha; 3129 - unsigned long flags; 3130 - 3131 - if(unlikely(list_empty(&gdth_instances))) { 3132 - gdth_timer_running = 0; 3133 - return; 3134 - } 3135 - 3136 - ha = list_first_entry(&gdth_instances, gdth_ha_str, list); 3137 - spin_lock_irqsave(&ha->smp_lock, flags); 3138 - 3139 - for (act_stats=0,i=0; i<GDTH_MAXCMDS; ++i) 3140 - if (ha->cmd_tab[i].cmnd != UNUSED_CMND) 3141 - ++act_stats; 3142 - 3143 - for (act_rq=0, 3144 - nscp=ha->req_first; nscp; nscp=(struct scsi_cmnd*)nscp->SCp.ptr) 3145 - ++act_rq; 3146 - 3147 - TRACE2(("gdth_to(): ints %d, ios %d, act_stats %d, act_rq %d\n", 3148 - act_ints, act_ios, act_stats, act_rq)); 3149 - act_ints = act_ios = 0; 3150 - 3151 - gdth_timer.expires = jiffies + 30 * HZ; 3152 - add_timer(&gdth_timer); 3153 - spin_unlock_irqrestore(&ha->smp_lock, flags); 3154 - } 3155 - 3156 - static void gdth_timer_init(void) 3157 - { 3158 - if (gdth_timer_running) 3159 - return; 3160 - gdth_timer_running = 1; 3161 - TRACE2(("gdth_detect(): Initializing timer !\n")); 3162 - gdth_timer.expires = jiffies + HZ; 3163 - add_timer(&gdth_timer); 3164 - } 3165 - #else 3166 - static inline void gdth_timer_init(void) 3167 - { 3168 - } 3169 - #endif 3170 - 3171 - 3172 - static const char *gdth_ctr_name(gdth_ha_str *ha) 3173 - { 3174 - TRACE2(("gdth_ctr_name()\n")); 3175 - 3176 - if (ha->type == GDT_PCI) { 3177 - switch (ha->pdev->device) { 3178 - case PCI_DEVICE_ID_VORTEX_GDT60x0: 3179 - return("GDT6000/6020/6050"); 3180 - case PCI_DEVICE_ID_VORTEX_GDT6000B: 3181 - return("GDT6000B/6010"); 3182 - } 3183 - } 3184 - /* new controllers (GDT_PCINEW, GDT_PCIMPR, ..) use board_info IOCTL! */ 3185 - 3186 - return(""); 3187 - } 3188 - 3189 - static const char *gdth_info(struct Scsi_Host *shp) 3190 - { 3191 - gdth_ha_str *ha = shost_priv(shp); 3192 - 3193 - TRACE2(("gdth_info()\n")); 3194 - return ((const char *)ha->binfo.type_string); 3195 - } 3196 - 3197 - static enum blk_eh_timer_return gdth_timed_out(struct scsi_cmnd *scp) 3198 - { 3199 - gdth_ha_str *ha = shost_priv(scp->device->host); 3200 - struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp); 3201 - u8 b, t; 3202 - unsigned long flags; 3203 - enum blk_eh_timer_return retval = BLK_EH_DONE; 3204 - 3205 - TRACE(("%s() cmd 0x%x\n", scp->cmnd[0], __func__)); 3206 - b = scp->device->channel; 3207 - t = scp->device->id; 3208 - 3209 - /* 3210 - * We don't really honor the command timeout, but we try to 3211 - * honor 6 times of the actual command timeout! So reset the 3212 - * timer if this is less than 6th timeout on this command! 3213 - */ 3214 - if (++cmndinfo->timeout_count < 6) 3215 - retval = BLK_EH_RESET_TIMER; 3216 - 3217 - /* Reset the timeout if it is locked IO */ 3218 - spin_lock_irqsave(&ha->smp_lock, flags); 3219 - if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha, b)].lock) || 3220 - (b == ha->virt_bus && t < MAX_HDRIVES && ha->hdr[t].lock)) { 3221 - TRACE2(("%s(): locked IO, reset timeout\n", __func__)); 3222 - retval = BLK_EH_RESET_TIMER; 3223 - } 3224 - spin_unlock_irqrestore(&ha->smp_lock, flags); 3225 - 3226 - return retval; 3227 - } 3228 - 3229 - 3230 - static int gdth_eh_bus_reset(struct scsi_cmnd *scp) 3231 - { 3232 - gdth_ha_str *ha = shost_priv(scp->device->host); 3233 - int i; 3234 - unsigned long flags; 3235 - struct scsi_cmnd *cmnd; 3236 - u8 b; 3237 - 3238 - TRACE2(("gdth_eh_bus_reset()\n")); 3239 - 3240 - b = scp->device->channel; 3241 - 3242 - /* clear command tab */ 3243 - spin_lock_irqsave(&ha->smp_lock, flags); 3244 - for (i = 0; i < GDTH_MAXCMDS; ++i) { 3245 - cmnd = ha->cmd_tab[i].cmnd; 3246 - if (!SPECIAL_SCP(cmnd) && cmnd->device->channel == b) 3247 - ha->cmd_tab[i].cmnd = UNUSED_CMND; 3248 - } 3249 - spin_unlock_irqrestore(&ha->smp_lock, flags); 3250 - 3251 - if (b == ha->virt_bus) { 3252 - /* host drives */ 3253 - for (i = 0; i < MAX_HDRIVES; ++i) { 3254 - if (ha->hdr[i].present) { 3255 - spin_lock_irqsave(&ha->smp_lock, flags); 3256 - gdth_polling = TRUE; 3257 - while (gdth_test_busy(ha)) 3258 - gdth_delay(0); 3259 - if (gdth_internal_cmd(ha, CACHESERVICE, 3260 - GDT_CLUST_RESET, i, 0, 0)) 3261 - ha->hdr[i].cluster_type &= ~CLUSTER_RESERVED; 3262 - gdth_polling = FALSE; 3263 - spin_unlock_irqrestore(&ha->smp_lock, flags); 3264 - } 3265 - } 3266 - } else { 3267 - /* raw devices */ 3268 - spin_lock_irqsave(&ha->smp_lock, flags); 3269 - for (i = 0; i < MAXID; ++i) 3270 - ha->raw[BUS_L2P(ha,b)].io_cnt[i] = 0; 3271 - gdth_polling = TRUE; 3272 - while (gdth_test_busy(ha)) 3273 - gdth_delay(0); 3274 - gdth_internal_cmd(ha, SCSIRAWSERVICE, GDT_RESET_BUS, 3275 - BUS_L2P(ha,b), 0, 0); 3276 - gdth_polling = FALSE; 3277 - spin_unlock_irqrestore(&ha->smp_lock, flags); 3278 - } 3279 - return SUCCESS; 3280 - } 3281 - 3282 - static int gdth_bios_param(struct scsi_device *sdev,struct block_device *bdev,sector_t cap,int *ip) 3283 - { 3284 - u8 b, t; 3285 - gdth_ha_str *ha = shost_priv(sdev->host); 3286 - struct scsi_device *sd; 3287 - unsigned capacity; 3288 - 3289 - sd = sdev; 3290 - capacity = cap; 3291 - b = sd->channel; 3292 - t = sd->id; 3293 - TRACE2(("gdth_bios_param() ha %d bus %d target %d\n", ha->hanum, b, t)); 3294 - 3295 - if (b != ha->virt_bus || ha->hdr[t].heads == 0) { 3296 - /* raw device or host drive without mapping information */ 3297 - TRACE2(("Evaluate mapping\n")); 3298 - gdth_eval_mapping(capacity,&ip[2],&ip[0],&ip[1]); 3299 - } else { 3300 - ip[0] = ha->hdr[t].heads; 3301 - ip[1] = ha->hdr[t].secs; 3302 - ip[2] = capacity / ip[0] / ip[1]; 3303 - } 3304 - 3305 - TRACE2(("gdth_bios_param(): %d heads, %d secs, %d cyls\n", 3306 - ip[0],ip[1],ip[2])); 3307 - return 0; 3308 - } 3309 - 3310 - 3311 - static int gdth_queuecommand_lck(struct scsi_cmnd *scp, 3312 - void (*done)(struct scsi_cmnd *)) 3313 - { 3314 - gdth_ha_str *ha = shost_priv(scp->device->host); 3315 - struct gdth_cmndinfo *cmndinfo; 3316 - 3317 - TRACE(("gdth_queuecommand() cmd 0x%x\n", scp->cmnd[0])); 3318 - 3319 - cmndinfo = gdth_get_cmndinfo(ha); 3320 - BUG_ON(!cmndinfo); 3321 - 3322 - scp->scsi_done = done; 3323 - cmndinfo->timeout_count = 0; 3324 - cmndinfo->priority = DEFAULT_PRI; 3325 - 3326 - return __gdth_queuecommand(ha, scp, cmndinfo); 3327 - } 3328 - 3329 - static DEF_SCSI_QCMD(gdth_queuecommand) 3330 - 3331 - static int __gdth_queuecommand(gdth_ha_str *ha, struct scsi_cmnd *scp, 3332 - struct gdth_cmndinfo *cmndinfo) 3333 - { 3334 - scp->host_scribble = (unsigned char *)cmndinfo; 3335 - cmndinfo->wait_for_completion = 1; 3336 - cmndinfo->phase = -1; 3337 - cmndinfo->OpCode = -1; 3338 - 3339 - #ifdef GDTH_STATISTICS 3340 - ++act_ios; 3341 - #endif 3342 - 3343 - gdth_putq(ha, scp, cmndinfo->priority); 3344 - gdth_next(ha); 3345 - return 0; 3346 - } 3347 - 3348 - 3349 - static int gdth_open(struct inode *inode, struct file *filep) 3350 - { 3351 - gdth_ha_str *ha; 3352 - 3353 - mutex_lock(&gdth_mutex); 3354 - list_for_each_entry(ha, &gdth_instances, list) { 3355 - if (!ha->sdev) 3356 - ha->sdev = scsi_get_host_dev(ha->shost); 3357 - } 3358 - mutex_unlock(&gdth_mutex); 3359 - 3360 - TRACE(("gdth_open()\n")); 3361 - return 0; 3362 - } 3363 - 3364 - static int gdth_close(struct inode *inode, struct file *filep) 3365 - { 3366 - TRACE(("gdth_close()\n")); 3367 - return 0; 3368 - } 3369 - 3370 - static int ioc_event(void __user *arg) 3371 - { 3372 - gdth_ioctl_event evt; 3373 - gdth_ha_str *ha; 3374 - unsigned long flags; 3375 - 3376 - if (copy_from_user(&evt, arg, sizeof(gdth_ioctl_event))) 3377 - return -EFAULT; 3378 - ha = gdth_find_ha(evt.ionode); 3379 - if (!ha) 3380 - return -EFAULT; 3381 - 3382 - if (evt.erase == 0xff) { 3383 - if (evt.event.event_source == ES_TEST) 3384 - evt.event.event_data.size=sizeof(evt.event.event_data.eu.test); 3385 - else if (evt.event.event_source == ES_DRIVER) 3386 - evt.event.event_data.size=sizeof(evt.event.event_data.eu.driver); 3387 - else if (evt.event.event_source == ES_SYNC) 3388 - evt.event.event_data.size=sizeof(evt.event.event_data.eu.sync); 3389 - else 3390 - evt.event.event_data.size=sizeof(evt.event.event_data.eu.async); 3391 - spin_lock_irqsave(&ha->smp_lock, flags); 3392 - gdth_store_event(ha, evt.event.event_source, evt.event.event_idx, 3393 - &evt.event.event_data); 3394 - spin_unlock_irqrestore(&ha->smp_lock, flags); 3395 - } else if (evt.erase == 0xfe) { 3396 - gdth_clear_events(); 3397 - } else if (evt.erase == 0) { 3398 - evt.handle = gdth_read_event(ha, evt.handle, &evt.event); 3399 - } else { 3400 - gdth_readapp_event(ha, evt.erase, &evt.event); 3401 - } 3402 - if (copy_to_user(arg, &evt, sizeof(gdth_ioctl_event))) 3403 - return -EFAULT; 3404 - return 0; 3405 - } 3406 - 3407 - static int ioc_lockdrv(void __user *arg) 3408 - { 3409 - gdth_ioctl_lockdrv ldrv; 3410 - u8 i, j; 3411 - unsigned long flags; 3412 - gdth_ha_str *ha; 3413 - 3414 - if (copy_from_user(&ldrv, arg, sizeof(gdth_ioctl_lockdrv))) 3415 - return -EFAULT; 3416 - ha = gdth_find_ha(ldrv.ionode); 3417 - if (!ha) 3418 - return -EFAULT; 3419 - 3420 - for (i = 0; i < ldrv.drive_cnt && i < MAX_HDRIVES; ++i) { 3421 - j = ldrv.drives[i]; 3422 - if (j >= MAX_HDRIVES || !ha->hdr[j].present) 3423 - continue; 3424 - if (ldrv.lock) { 3425 - spin_lock_irqsave(&ha->smp_lock, flags); 3426 - ha->hdr[j].lock = 1; 3427 - spin_unlock_irqrestore(&ha->smp_lock, flags); 3428 - gdth_wait_completion(ha, ha->bus_cnt, j); 3429 - } else { 3430 - spin_lock_irqsave(&ha->smp_lock, flags); 3431 - ha->hdr[j].lock = 0; 3432 - spin_unlock_irqrestore(&ha->smp_lock, flags); 3433 - gdth_next(ha); 3434 - } 3435 - } 3436 - return 0; 3437 - } 3438 - 3439 - static int ioc_resetdrv(void __user *arg, char *cmnd) 3440 - { 3441 - gdth_ioctl_reset res; 3442 - gdth_cmd_str cmd; 3443 - gdth_ha_str *ha; 3444 - int rval; 3445 - 3446 - if (copy_from_user(&res, arg, sizeof(gdth_ioctl_reset)) || 3447 - res.number >= MAX_HDRIVES) 3448 - return -EFAULT; 3449 - ha = gdth_find_ha(res.ionode); 3450 - if (!ha) 3451 - return -EFAULT; 3452 - 3453 - if (!ha->hdr[res.number].present) 3454 - return 0; 3455 - memset(&cmd, 0, sizeof(gdth_cmd_str)); 3456 - cmd.Service = CACHESERVICE; 3457 - cmd.OpCode = GDT_CLUST_RESET; 3458 - if (ha->cache_feat & GDT_64BIT) 3459 - cmd.u.cache64.DeviceNo = res.number; 3460 - else 3461 - cmd.u.cache.DeviceNo = res.number; 3462 - 3463 - rval = __gdth_execute(ha->sdev, &cmd, cmnd, 30, NULL); 3464 - if (rval < 0) 3465 - return rval; 3466 - res.status = rval; 3467 - 3468 - if (copy_to_user(arg, &res, sizeof(gdth_ioctl_reset))) 3469 - return -EFAULT; 3470 - return 0; 3471 - } 3472 - 3473 - static void gdth_ioc_cacheservice(gdth_ha_str *ha, gdth_ioctl_general *gen, 3474 - u64 paddr) 3475 - { 3476 - if (ha->cache_feat & GDT_64BIT) { 3477 - /* copy elements from 32-bit IOCTL structure */ 3478 - gen->command.u.cache64.BlockCnt = gen->command.u.cache.BlockCnt; 3479 - gen->command.u.cache64.BlockNo = gen->command.u.cache.BlockNo; 3480 - gen->command.u.cache64.DeviceNo = gen->command.u.cache.DeviceNo; 3481 - 3482 - if (ha->cache_feat & SCATTER_GATHER) { 3483 - gen->command.u.cache64.DestAddr = (u64)-1; 3484 - gen->command.u.cache64.sg_canz = 1; 3485 - gen->command.u.cache64.sg_lst[0].sg_ptr = paddr; 3486 - gen->command.u.cache64.sg_lst[0].sg_len = gen->data_len; 3487 - gen->command.u.cache64.sg_lst[1].sg_len = 0; 3488 - } else { 3489 - gen->command.u.cache64.DestAddr = paddr; 3490 - gen->command.u.cache64.sg_canz = 0; 3491 - } 3492 - } else { 3493 - if (ha->cache_feat & SCATTER_GATHER) { 3494 - gen->command.u.cache.DestAddr = 0xffffffff; 3495 - gen->command.u.cache.sg_canz = 1; 3496 - gen->command.u.cache.sg_lst[0].sg_ptr = (u32)paddr; 3497 - gen->command.u.cache.sg_lst[0].sg_len = gen->data_len; 3498 - gen->command.u.cache.sg_lst[1].sg_len = 0; 3499 - } else { 3500 - gen->command.u.cache.DestAddr = paddr; 3501 - gen->command.u.cache.sg_canz = 0; 3502 - } 3503 - } 3504 - } 3505 - 3506 - static void gdth_ioc_scsiraw(gdth_ha_str *ha, gdth_ioctl_general *gen, 3507 - u64 paddr) 3508 - { 3509 - if (ha->raw_feat & GDT_64BIT) { 3510 - /* copy elements from 32-bit IOCTL structure */ 3511 - char cmd[16]; 3512 - 3513 - gen->command.u.raw64.sense_len = gen->command.u.raw.sense_len; 3514 - gen->command.u.raw64.bus = gen->command.u.raw.bus; 3515 - gen->command.u.raw64.lun = gen->command.u.raw.lun; 3516 - gen->command.u.raw64.target = gen->command.u.raw.target; 3517 - memcpy(cmd, gen->command.u.raw.cmd, 16); 3518 - memcpy(gen->command.u.raw64.cmd, cmd, 16); 3519 - gen->command.u.raw64.clen = gen->command.u.raw.clen; 3520 - gen->command.u.raw64.sdlen = gen->command.u.raw.sdlen; 3521 - gen->command.u.raw64.direction = gen->command.u.raw.direction; 3522 - 3523 - /* addresses */ 3524 - if (ha->raw_feat & SCATTER_GATHER) { 3525 - gen->command.u.raw64.sdata = (u64)-1; 3526 - gen->command.u.raw64.sg_ranz = 1; 3527 - gen->command.u.raw64.sg_lst[0].sg_ptr = paddr; 3528 - gen->command.u.raw64.sg_lst[0].sg_len = gen->data_len; 3529 - gen->command.u.raw64.sg_lst[1].sg_len = 0; 3530 - } else { 3531 - gen->command.u.raw64.sdata = paddr; 3532 - gen->command.u.raw64.sg_ranz = 0; 3533 - } 3534 - 3535 - gen->command.u.raw64.sense_data = paddr + gen->data_len; 3536 - } else { 3537 - if (ha->raw_feat & SCATTER_GATHER) { 3538 - gen->command.u.raw.sdata = 0xffffffff; 3539 - gen->command.u.raw.sg_ranz = 1; 3540 - gen->command.u.raw.sg_lst[0].sg_ptr = (u32)paddr; 3541 - gen->command.u.raw.sg_lst[0].sg_len = gen->data_len; 3542 - gen->command.u.raw.sg_lst[1].sg_len = 0; 3543 - } else { 3544 - gen->command.u.raw.sdata = paddr; 3545 - gen->command.u.raw.sg_ranz = 0; 3546 - } 3547 - 3548 - gen->command.u.raw.sense_data = (u32)paddr + gen->data_len; 3549 - } 3550 - } 3551 - 3552 - static int ioc_general(void __user *arg, char *cmnd) 3553 - { 3554 - gdth_ioctl_general gen; 3555 - gdth_ha_str *ha; 3556 - char *buf = NULL; 3557 - dma_addr_t paddr; 3558 - int rval; 3559 - 3560 - if (copy_from_user(&gen, arg, sizeof(gdth_ioctl_general))) 3561 - return -EFAULT; 3562 - ha = gdth_find_ha(gen.ionode); 3563 - if (!ha) 3564 - return -EFAULT; 3565 - 3566 - if (gen.data_len > INT_MAX) 3567 - return -EINVAL; 3568 - if (gen.sense_len > INT_MAX) 3569 - return -EINVAL; 3570 - if (gen.data_len + gen.sense_len > INT_MAX) 3571 - return -EINVAL; 3572 - 3573 - if (gen.data_len + gen.sense_len > 0) { 3574 - buf = dma_alloc_coherent(&ha->pdev->dev, 3575 - gen.data_len + gen.sense_len, &paddr, 3576 - GFP_KERNEL); 3577 - if (!buf) 3578 - return -EFAULT; 3579 - 3580 - rval = -EFAULT; 3581 - if (copy_from_user(buf, arg + sizeof(gdth_ioctl_general), 3582 - gen.data_len + gen.sense_len)) 3583 - goto out_free_buf; 3584 - 3585 - if (gen.command.OpCode == GDT_IOCTL) 3586 - gen.command.u.ioctl.p_param = paddr; 3587 - else if (gen.command.Service == CACHESERVICE) 3588 - gdth_ioc_cacheservice(ha, &gen, paddr); 3589 - else if (gen.command.Service == SCSIRAWSERVICE) 3590 - gdth_ioc_scsiraw(ha, &gen, paddr); 3591 - else 3592 - goto out_free_buf; 3593 - } 3594 - 3595 - rval = __gdth_execute(ha->sdev, &gen.command, cmnd, gen.timeout, 3596 - &gen.info); 3597 - if (rval < 0) 3598 - goto out_free_buf; 3599 - gen.status = rval; 3600 - 3601 - rval = -EFAULT; 3602 - if (copy_to_user(arg + sizeof(gdth_ioctl_general), buf, 3603 - gen.data_len + gen.sense_len)) 3604 - goto out_free_buf; 3605 - if (copy_to_user(arg, &gen, 3606 - sizeof(gdth_ioctl_general) - sizeof(gdth_cmd_str))) 3607 - goto out_free_buf; 3608 - 3609 - rval = 0; 3610 - out_free_buf: 3611 - if (buf) 3612 - dma_free_coherent(&ha->pdev->dev, gen.data_len + gen.sense_len, 3613 - buf, paddr); 3614 - return rval; 3615 - } 3616 - 3617 - static int ioc_hdrlist(void __user *arg, char *cmnd) 3618 - { 3619 - gdth_ioctl_rescan *rsc; 3620 - gdth_cmd_str *cmd; 3621 - gdth_ha_str *ha; 3622 - u8 i; 3623 - int rc = -ENOMEM; 3624 - u32 cluster_type = 0; 3625 - 3626 - rsc = kmalloc(sizeof(*rsc), GFP_KERNEL); 3627 - cmd = kmalloc(sizeof(*cmd), GFP_KERNEL); 3628 - if (!rsc || !cmd) 3629 - goto free_fail; 3630 - 3631 - if (copy_from_user(rsc, arg, sizeof(gdth_ioctl_rescan)) || 3632 - (NULL == (ha = gdth_find_ha(rsc->ionode)))) { 3633 - rc = -EFAULT; 3634 - goto free_fail; 3635 - } 3636 - memset(cmd, 0, sizeof(gdth_cmd_str)); 3637 - 3638 - for (i = 0; i < MAX_HDRIVES; ++i) { 3639 - if (!ha->hdr[i].present) { 3640 - rsc->hdr_list[i].bus = 0xff; 3641 - continue; 3642 - } 3643 - rsc->hdr_list[i].bus = ha->virt_bus; 3644 - rsc->hdr_list[i].target = i; 3645 - rsc->hdr_list[i].lun = 0; 3646 - rsc->hdr_list[i].cluster_type = ha->hdr[i].cluster_type; 3647 - if (ha->hdr[i].cluster_type & CLUSTER_DRIVE) { 3648 - cmd->Service = CACHESERVICE; 3649 - cmd->OpCode = GDT_CLUST_INFO; 3650 - if (ha->cache_feat & GDT_64BIT) 3651 - cmd->u.cache64.DeviceNo = i; 3652 - else 3653 - cmd->u.cache.DeviceNo = i; 3654 - if (__gdth_execute(ha->sdev, cmd, cmnd, 30, &cluster_type) == S_OK) 3655 - rsc->hdr_list[i].cluster_type = cluster_type; 3656 - } 3657 - } 3658 - 3659 - if (copy_to_user(arg, rsc, sizeof(gdth_ioctl_rescan))) 3660 - rc = -EFAULT; 3661 - else 3662 - rc = 0; 3663 - 3664 - free_fail: 3665 - kfree(rsc); 3666 - kfree(cmd); 3667 - return rc; 3668 - } 3669 - 3670 - static int ioc_rescan(void __user *arg, char *cmnd) 3671 - { 3672 - gdth_ioctl_rescan *rsc; 3673 - gdth_cmd_str *cmd; 3674 - u16 i, status, hdr_cnt; 3675 - u32 info; 3676 - int cyls, hds, secs; 3677 - int rc = -ENOMEM; 3678 - unsigned long flags; 3679 - gdth_ha_str *ha; 3680 - 3681 - rsc = kmalloc(sizeof(*rsc), GFP_KERNEL); 3682 - cmd = kmalloc(sizeof(*cmd), GFP_KERNEL); 3683 - if (!cmd || !rsc) 3684 - goto free_fail; 3685 - 3686 - if (copy_from_user(rsc, arg, sizeof(gdth_ioctl_rescan)) || 3687 - (NULL == (ha = gdth_find_ha(rsc->ionode)))) { 3688 - rc = -EFAULT; 3689 - goto free_fail; 3690 - } 3691 - memset(cmd, 0, sizeof(gdth_cmd_str)); 3692 - 3693 - if (rsc->flag == 0) { 3694 - /* old method: re-init. cache service */ 3695 - cmd->Service = CACHESERVICE; 3696 - if (ha->cache_feat & GDT_64BIT) { 3697 - cmd->OpCode = GDT_X_INIT_HOST; 3698 - cmd->u.cache64.DeviceNo = LINUX_OS; 3699 - } else { 3700 - cmd->OpCode = GDT_INIT; 3701 - cmd->u.cache.DeviceNo = LINUX_OS; 3702 - } 3703 - 3704 - status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info); 3705 - i = 0; 3706 - hdr_cnt = (status == S_OK ? (u16)info : 0); 3707 - } else { 3708 - i = rsc->hdr_no; 3709 - hdr_cnt = i + 1; 3710 - } 3711 - 3712 - for (; i < hdr_cnt && i < MAX_HDRIVES; ++i) { 3713 - cmd->Service = CACHESERVICE; 3714 - cmd->OpCode = GDT_INFO; 3715 - if (ha->cache_feat & GDT_64BIT) 3716 - cmd->u.cache64.DeviceNo = i; 3717 - else 3718 - cmd->u.cache.DeviceNo = i; 3719 - 3720 - status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info); 3721 - 3722 - spin_lock_irqsave(&ha->smp_lock, flags); 3723 - rsc->hdr_list[i].bus = ha->virt_bus; 3724 - rsc->hdr_list[i].target = i; 3725 - rsc->hdr_list[i].lun = 0; 3726 - if (status != S_OK) { 3727 - ha->hdr[i].present = FALSE; 3728 - } else { 3729 - ha->hdr[i].present = TRUE; 3730 - ha->hdr[i].size = info; 3731 - /* evaluate mapping */ 3732 - ha->hdr[i].size &= ~SECS32; 3733 - gdth_eval_mapping(ha->hdr[i].size,&cyls,&hds,&secs); 3734 - ha->hdr[i].heads = hds; 3735 - ha->hdr[i].secs = secs; 3736 - /* round size */ 3737 - ha->hdr[i].size = cyls * hds * secs; 3738 - } 3739 - spin_unlock_irqrestore(&ha->smp_lock, flags); 3740 - if (status != S_OK) 3741 - continue; 3742 - 3743 - /* extended info, if GDT_64BIT, for drives > 2 TB */ 3744 - /* but we need ha->info2, not yet stored in scp->SCp */ 3745 - 3746 - /* devtype, cluster info, R/W attribs */ 3747 - cmd->Service = CACHESERVICE; 3748 - cmd->OpCode = GDT_DEVTYPE; 3749 - if (ha->cache_feat & GDT_64BIT) 3750 - cmd->u.cache64.DeviceNo = i; 3751 - else 3752 - cmd->u.cache.DeviceNo = i; 3753 - 3754 - status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info); 3755 - 3756 - spin_lock_irqsave(&ha->smp_lock, flags); 3757 - ha->hdr[i].devtype = (status == S_OK ? (u16)info : 0); 3758 - spin_unlock_irqrestore(&ha->smp_lock, flags); 3759 - 3760 - cmd->Service = CACHESERVICE; 3761 - cmd->OpCode = GDT_CLUST_INFO; 3762 - if (ha->cache_feat & GDT_64BIT) 3763 - cmd->u.cache64.DeviceNo = i; 3764 - else 3765 - cmd->u.cache.DeviceNo = i; 3766 - 3767 - status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info); 3768 - 3769 - spin_lock_irqsave(&ha->smp_lock, flags); 3770 - ha->hdr[i].cluster_type = 3771 - ((status == S_OK && !shared_access) ? (u16)info : 0); 3772 - spin_unlock_irqrestore(&ha->smp_lock, flags); 3773 - rsc->hdr_list[i].cluster_type = ha->hdr[i].cluster_type; 3774 - 3775 - cmd->Service = CACHESERVICE; 3776 - cmd->OpCode = GDT_RW_ATTRIBS; 3777 - if (ha->cache_feat & GDT_64BIT) 3778 - cmd->u.cache64.DeviceNo = i; 3779 - else 3780 - cmd->u.cache.DeviceNo = i; 3781 - 3782 - status = __gdth_execute(ha->sdev, cmd, cmnd, 30, &info); 3783 - 3784 - spin_lock_irqsave(&ha->smp_lock, flags); 3785 - ha->hdr[i].rw_attribs = (status == S_OK ? (u16)info : 0); 3786 - spin_unlock_irqrestore(&ha->smp_lock, flags); 3787 - } 3788 - 3789 - if (copy_to_user(arg, rsc, sizeof(gdth_ioctl_rescan))) 3790 - rc = -EFAULT; 3791 - else 3792 - rc = 0; 3793 - 3794 - free_fail: 3795 - kfree(rsc); 3796 - kfree(cmd); 3797 - return rc; 3798 - } 3799 - 3800 - static int gdth_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) 3801 - { 3802 - gdth_ha_str *ha; 3803 - struct scsi_cmnd *scp; 3804 - unsigned long flags; 3805 - char cmnd[MAX_COMMAND_SIZE]; 3806 - void __user *argp = (void __user *)arg; 3807 - 3808 - memset(cmnd, 0xff, 12); 3809 - 3810 - TRACE(("gdth_ioctl() cmd 0x%x\n", cmd)); 3811 - 3812 - switch (cmd) { 3813 - case GDTIOCTL_CTRCNT: 3814 - { 3815 - int cnt = gdth_ctr_count; 3816 - if (put_user(cnt, (int __user *)argp)) 3817 - return -EFAULT; 3818 - break; 3819 - } 3820 - 3821 - case GDTIOCTL_DRVERS: 3822 - { 3823 - int ver = (GDTH_VERSION<<8) | GDTH_SUBVERSION; 3824 - if (put_user(ver, (int __user *)argp)) 3825 - return -EFAULT; 3826 - break; 3827 - } 3828 - 3829 - case GDTIOCTL_OSVERS: 3830 - { 3831 - gdth_ioctl_osvers osv; 3832 - 3833 - osv.version = (u8)(LINUX_VERSION_CODE >> 16); 3834 - osv.subversion = (u8)(LINUX_VERSION_CODE >> 8); 3835 - osv.revision = (u16)(LINUX_VERSION_CODE & 0xff); 3836 - if (copy_to_user(argp, &osv, sizeof(gdth_ioctl_osvers))) 3837 - return -EFAULT; 3838 - break; 3839 - } 3840 - 3841 - case GDTIOCTL_CTRTYPE: 3842 - { 3843 - gdth_ioctl_ctrtype ctrt; 3844 - 3845 - if (copy_from_user(&ctrt, argp, sizeof(gdth_ioctl_ctrtype)) || 3846 - (NULL == (ha = gdth_find_ha(ctrt.ionode)))) 3847 - return -EFAULT; 3848 - 3849 - if (ha->type != GDT_PCIMPR) { 3850 - ctrt.type = (u8)((ha->stype<<4) + 6); 3851 - } else { 3852 - ctrt.type = (ha->oem_id == OEM_ID_INTEL ? 0xfd : 0xfe); 3853 - if (ha->stype >= 0x300) 3854 - ctrt.ext_type = 0x6000 | ha->pdev->subsystem_device; 3855 - else 3856 - ctrt.ext_type = 0x6000 | ha->stype; 3857 - } 3858 - ctrt.device_id = ha->pdev->device; 3859 - ctrt.sub_device_id = ha->pdev->subsystem_device; 3860 - ctrt.info = ha->brd_phys; 3861 - ctrt.oem_id = ha->oem_id; 3862 - if (copy_to_user(argp, &ctrt, sizeof(gdth_ioctl_ctrtype))) 3863 - return -EFAULT; 3864 - break; 3865 - } 3866 - 3867 - case GDTIOCTL_GENERAL: 3868 - return ioc_general(argp, cmnd); 3869 - 3870 - case GDTIOCTL_EVENT: 3871 - return ioc_event(argp); 3872 - 3873 - case GDTIOCTL_LOCKDRV: 3874 - return ioc_lockdrv(argp); 3875 - 3876 - case GDTIOCTL_LOCKCHN: 3877 - { 3878 - gdth_ioctl_lockchn lchn; 3879 - u8 i, j; 3880 - 3881 - if (copy_from_user(&lchn, argp, sizeof(gdth_ioctl_lockchn)) || 3882 - (NULL == (ha = gdth_find_ha(lchn.ionode)))) 3883 - return -EFAULT; 3884 - 3885 - i = lchn.channel; 3886 - if (i < ha->bus_cnt) { 3887 - if (lchn.lock) { 3888 - spin_lock_irqsave(&ha->smp_lock, flags); 3889 - ha->raw[i].lock = 1; 3890 - spin_unlock_irqrestore(&ha->smp_lock, flags); 3891 - for (j = 0; j < ha->tid_cnt; ++j) 3892 - gdth_wait_completion(ha, i, j); 3893 - } else { 3894 - spin_lock_irqsave(&ha->smp_lock, flags); 3895 - ha->raw[i].lock = 0; 3896 - spin_unlock_irqrestore(&ha->smp_lock, flags); 3897 - for (j = 0; j < ha->tid_cnt; ++j) 3898 - gdth_next(ha); 3899 - } 3900 - } 3901 - break; 3902 - } 3903 - 3904 - case GDTIOCTL_RESCAN: 3905 - return ioc_rescan(argp, cmnd); 3906 - 3907 - case GDTIOCTL_HDRLIST: 3908 - return ioc_hdrlist(argp, cmnd); 3909 - 3910 - case GDTIOCTL_RESET_BUS: 3911 - { 3912 - gdth_ioctl_reset res; 3913 - int rval; 3914 - 3915 - if (copy_from_user(&res, argp, sizeof(gdth_ioctl_reset)) || 3916 - (NULL == (ha = gdth_find_ha(res.ionode)))) 3917 - return -EFAULT; 3918 - 3919 - scp = kzalloc(sizeof(*scp), GFP_KERNEL); 3920 - if (!scp) 3921 - return -ENOMEM; 3922 - scp->device = ha->sdev; 3923 - scp->cmd_len = 12; 3924 - scp->device->channel = res.number; 3925 - rval = gdth_eh_bus_reset(scp); 3926 - res.status = (rval == SUCCESS ? S_OK : S_GENERR); 3927 - kfree(scp); 3928 - 3929 - if (copy_to_user(argp, &res, sizeof(gdth_ioctl_reset))) 3930 - return -EFAULT; 3931 - break; 3932 - } 3933 - 3934 - case GDTIOCTL_RESET_DRV: 3935 - return ioc_resetdrv(argp, cmnd); 3936 - 3937 - default: 3938 - break; 3939 - } 3940 - return 0; 3941 - } 3942 - 3943 - static long gdth_unlocked_ioctl(struct file *file, unsigned int cmd, 3944 - unsigned long arg) 3945 - { 3946 - int ret; 3947 - 3948 - mutex_lock(&gdth_mutex); 3949 - ret = gdth_ioctl(file, cmd, arg); 3950 - mutex_unlock(&gdth_mutex); 3951 - 3952 - return ret; 3953 - } 3954 - 3955 - /* flush routine */ 3956 - static void gdth_flush(gdth_ha_str *ha) 3957 - { 3958 - int i; 3959 - gdth_cmd_str gdtcmd; 3960 - char cmnd[MAX_COMMAND_SIZE]; 3961 - memset(cmnd, 0xff, MAX_COMMAND_SIZE); 3962 - 3963 - TRACE2(("gdth_flush() hanum %d\n", ha->hanum)); 3964 - 3965 - for (i = 0; i < MAX_HDRIVES; ++i) { 3966 - if (ha->hdr[i].present) { 3967 - gdtcmd.BoardNode = LOCALBOARD; 3968 - gdtcmd.Service = CACHESERVICE; 3969 - gdtcmd.OpCode = GDT_FLUSH; 3970 - if (ha->cache_feat & GDT_64BIT) { 3971 - gdtcmd.u.cache64.DeviceNo = i; 3972 - gdtcmd.u.cache64.BlockNo = 1; 3973 - gdtcmd.u.cache64.sg_canz = 0; 3974 - } else { 3975 - gdtcmd.u.cache.DeviceNo = i; 3976 - gdtcmd.u.cache.BlockNo = 1; 3977 - gdtcmd.u.cache.sg_canz = 0; 3978 - } 3979 - TRACE2(("gdth_flush(): flush ha %d drive %d\n", ha->hanum, i)); 3980 - 3981 - gdth_execute(ha->shost, &gdtcmd, cmnd, 30, NULL); 3982 - } 3983 - } 3984 - } 3985 - 3986 - /* configure lun */ 3987 - static int gdth_slave_configure(struct scsi_device *sdev) 3988 - { 3989 - sdev->skip_ms_page_3f = 1; 3990 - sdev->skip_ms_page_8 = 1; 3991 - return 0; 3992 - } 3993 - 3994 - static struct scsi_host_template gdth_template = { 3995 - .name = "GDT SCSI Disk Array Controller", 3996 - .info = gdth_info, 3997 - .queuecommand = gdth_queuecommand, 3998 - .eh_bus_reset_handler = gdth_eh_bus_reset, 3999 - .slave_configure = gdth_slave_configure, 4000 - .bios_param = gdth_bios_param, 4001 - .show_info = gdth_show_info, 4002 - .write_info = gdth_set_info, 4003 - .eh_timed_out = gdth_timed_out, 4004 - .proc_name = "gdth", 4005 - .can_queue = GDTH_MAXCMDS, 4006 - .this_id = -1, 4007 - .sg_tablesize = GDTH_MAXSG, 4008 - .cmd_per_lun = GDTH_MAXC_P_L, 4009 - .unchecked_isa_dma = 1, 4010 - .no_write_same = 1, 4011 - }; 4012 - 4013 - static int gdth_pci_probe_one(gdth_pci_str *pcistr, gdth_ha_str **ha_out) 4014 - { 4015 - struct Scsi_Host *shp; 4016 - gdth_ha_str *ha; 4017 - dma_addr_t scratch_dma_handle = 0; 4018 - int error, i; 4019 - struct pci_dev *pdev = pcistr->pdev; 4020 - 4021 - *ha_out = NULL; 4022 - 4023 - shp = scsi_host_alloc(&gdth_template, sizeof(gdth_ha_str)); 4024 - if (!shp) 4025 - return -ENOMEM; 4026 - ha = shost_priv(shp); 4027 - 4028 - error = -ENODEV; 4029 - if (!gdth_init_pci(pdev, pcistr, ha)) 4030 - goto out_host_put; 4031 - 4032 - /* controller found and initialized */ 4033 - printk("Configuring GDT-PCI HA at %d/%d IRQ %u\n", 4034 - pdev->bus->number, 4035 - PCI_SLOT(pdev->devfn), 4036 - ha->irq); 4037 - 4038 - error = request_irq(ha->irq, gdth_interrupt, 4039 - IRQF_SHARED, "gdth", ha); 4040 - if (error) { 4041 - printk("GDT-PCI: Unable to allocate IRQ\n"); 4042 - goto out_host_put; 4043 - } 4044 - 4045 - shp->unchecked_isa_dma = 0; 4046 - shp->irq = ha->irq; 4047 - shp->dma_channel = 0xff; 4048 - 4049 - ha->hanum = gdth_ctr_count++; 4050 - ha->shost = shp; 4051 - 4052 - ha->pccb = &ha->cmdext; 4053 - ha->ccb_phys = 0L; 4054 - 4055 - error = -ENOMEM; 4056 - 4057 - ha->pscratch = dma_alloc_coherent(&ha->pdev->dev, GDTH_SCRATCH, 4058 - &scratch_dma_handle, GFP_KERNEL); 4059 - if (!ha->pscratch) 4060 - goto out_free_irq; 4061 - ha->scratch_phys = scratch_dma_handle; 4062 - 4063 - ha->pmsg = dma_alloc_coherent(&ha->pdev->dev, sizeof(gdth_msg_str), 4064 - &scratch_dma_handle, GFP_KERNEL); 4065 - if (!ha->pmsg) 4066 - goto out_free_pscratch; 4067 - ha->msg_phys = scratch_dma_handle; 4068 - 4069 - ha->scratch_busy = FALSE; 4070 - ha->req_first = NULL; 4071 - ha->tid_cnt = pdev->device >= 0x200 ? MAXID : MAX_HDRIVES; 4072 - if (max_ids > 0 && max_ids < ha->tid_cnt) 4073 - ha->tid_cnt = max_ids; 4074 - for (i = 0; i < GDTH_MAXCMDS; ++i) 4075 - ha->cmd_tab[i].cmnd = UNUSED_CMND; 4076 - ha->scan_mode = rescan ? 0x10 : 0; 4077 - 4078 - error = -ENODEV; 4079 - if (!gdth_search_drives(ha)) { 4080 - printk("GDT-PCI %d: Error during device scan\n", ha->hanum); 4081 - goto out_free_pmsg; 4082 - } 4083 - 4084 - if (hdr_channel < 0 || hdr_channel > ha->bus_cnt) 4085 - hdr_channel = ha->bus_cnt; 4086 - ha->virt_bus = hdr_channel; 4087 - 4088 - /* 64-bit DMA only supported from FW >= x.43 */ 4089 - if (!(ha->cache_feat & ha->raw_feat & ha->screen_feat & GDT_64BIT) || 4090 - !ha->dma64_support) { 4091 - if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { 4092 - printk(KERN_WARNING "GDT-PCI %d: " 4093 - "Unable to set 32-bit DMA\n", ha->hanum); 4094 - goto out_free_pmsg; 4095 - } 4096 - } else { 4097 - shp->max_cmd_len = 16; 4098 - if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) { 4099 - printk("GDT-PCI %d: 64-bit DMA enabled\n", ha->hanum); 4100 - } else if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { 4101 - printk(KERN_WARNING "GDT-PCI %d: " 4102 - "Unable to set 64/32-bit DMA\n", ha->hanum); 4103 - goto out_free_pmsg; 4104 - } 4105 - } 4106 - 4107 - shp->max_id = ha->tid_cnt; 4108 - shp->max_lun = MAXLUN; 4109 - shp->max_channel = ha->bus_cnt; 4110 - 4111 - spin_lock_init(&ha->smp_lock); 4112 - gdth_enable_int(ha); 4113 - 4114 - error = scsi_add_host(shp, &pdev->dev); 4115 - if (error) 4116 - goto out_free_pmsg; 4117 - list_add_tail(&ha->list, &gdth_instances); 4118 - 4119 - pci_set_drvdata(ha->pdev, ha); 4120 - gdth_timer_init(); 4121 - 4122 - scsi_scan_host(shp); 4123 - 4124 - *ha_out = ha; 4125 - 4126 - return 0; 4127 - 4128 - out_free_pmsg: 4129 - dma_free_coherent(&ha->pdev->dev, sizeof(gdth_msg_str), 4130 - ha->pmsg, ha->msg_phys); 4131 - out_free_pscratch: 4132 - dma_free_coherent(&ha->pdev->dev, GDTH_SCRATCH, 4133 - ha->pscratch, ha->scratch_phys); 4134 - out_free_irq: 4135 - free_irq(ha->irq, ha); 4136 - gdth_ctr_count--; 4137 - out_host_put: 4138 - scsi_host_put(shp); 4139 - return error; 4140 - } 4141 - 4142 - static void gdth_remove_one(gdth_ha_str *ha) 4143 - { 4144 - struct Scsi_Host *shp = ha->shost; 4145 - 4146 - TRACE2(("gdth_remove_one()\n")); 4147 - 4148 - scsi_remove_host(shp); 4149 - 4150 - gdth_flush(ha); 4151 - 4152 - if (ha->sdev) { 4153 - scsi_free_host_dev(ha->sdev); 4154 - ha->sdev = NULL; 4155 - } 4156 - 4157 - if (shp->irq) 4158 - free_irq(shp->irq,ha); 4159 - 4160 - if (ha->pscratch) 4161 - dma_free_coherent(&ha->pdev->dev, GDTH_SCRATCH, 4162 - ha->pscratch, ha->scratch_phys); 4163 - if (ha->pmsg) 4164 - dma_free_coherent(&ha->pdev->dev, sizeof(gdth_msg_str), 4165 - ha->pmsg, ha->msg_phys); 4166 - if (ha->ccb_phys) 4167 - dma_unmap_single(&ha->pdev->dev, ha->ccb_phys, 4168 - sizeof(gdth_cmd_str), DMA_BIDIRECTIONAL); 4169 - 4170 - scsi_host_put(shp); 4171 - } 4172 - 4173 - static int gdth_halt(struct notifier_block *nb, unsigned long event, void *buf) 4174 - { 4175 - gdth_ha_str *ha; 4176 - 4177 - TRACE2(("gdth_halt() event %d\n", (int)event)); 4178 - if (event != SYS_RESTART && event != SYS_HALT && event != SYS_POWER_OFF) 4179 - return NOTIFY_DONE; 4180 - 4181 - list_for_each_entry(ha, &gdth_instances, list) 4182 - gdth_flush(ha); 4183 - 4184 - return NOTIFY_OK; 4185 - } 4186 - 4187 - static struct notifier_block gdth_notifier = { 4188 - gdth_halt, NULL, 0 4189 - }; 4190 - 4191 - static int __init gdth_init(void) 4192 - { 4193 - if (disable) { 4194 - printk("GDT-HA: Controller driver disabled from" 4195 - " command line !\n"); 4196 - return 0; 4197 - } 4198 - 4199 - printk("GDT-HA: Storage RAID Controller Driver. Version: %s\n", 4200 - GDTH_VERSION_STR); 4201 - 4202 - /* initializations */ 4203 - gdth_polling = TRUE; 4204 - gdth_clear_events(); 4205 - timer_setup(&gdth_timer, gdth_timeout, 0); 4206 - 4207 - /* scanning for PCI controllers */ 4208 - if (pci_register_driver(&gdth_pci_driver)) { 4209 - gdth_ha_str *ha; 4210 - 4211 - list_for_each_entry(ha, &gdth_instances, list) 4212 - gdth_remove_one(ha); 4213 - return -ENODEV; 4214 - } 4215 - 4216 - TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count)); 4217 - 4218 - major = register_chrdev(0,"gdth", &gdth_fops); 4219 - register_reboot_notifier(&gdth_notifier); 4220 - gdth_polling = FALSE; 4221 - return 0; 4222 - } 4223 - 4224 - static void __exit gdth_exit(void) 4225 - { 4226 - gdth_ha_str *ha; 4227 - 4228 - unregister_chrdev(major, "gdth"); 4229 - unregister_reboot_notifier(&gdth_notifier); 4230 - 4231 - #ifdef GDTH_STATISTICS 4232 - del_timer_sync(&gdth_timer); 4233 - #endif 4234 - 4235 - pci_unregister_driver(&gdth_pci_driver); 4236 - 4237 - list_for_each_entry(ha, &gdth_instances, list) 4238 - gdth_remove_one(ha); 4239 - } 4240 - 4241 - module_init(gdth_init); 4242 - module_exit(gdth_exit); 4243 - 4244 - #ifndef MODULE 4245 - static void __init internal_setup(char *str,int *ints) 4246 - { 4247 - int i; 4248 - char *cur_str, *argv; 4249 - 4250 - TRACE2(("internal_setup() str %s ints[0] %d\n", 4251 - str ? str:"NULL", ints ? ints[0]:0)); 4252 - 4253 - /* analyse string */ 4254 - argv = str; 4255 - while (argv && (cur_str = strchr(argv, ':'))) { 4256 - int val = 0, c = *++cur_str; 4257 - 4258 - if (c == 'n' || c == 'N') 4259 - val = 0; 4260 - else if (c == 'y' || c == 'Y') 4261 - val = 1; 4262 - else 4263 - val = (int)simple_strtoul(cur_str, NULL, 0); 4264 - 4265 - if (!strncmp(argv, "disable:", 8)) 4266 - disable = val; 4267 - else if (!strncmp(argv, "reserve_mode:", 13)) 4268 - reserve_mode = val; 4269 - else if (!strncmp(argv, "reverse_scan:", 13)) 4270 - reverse_scan = val; 4271 - else if (!strncmp(argv, "hdr_channel:", 12)) 4272 - hdr_channel = val; 4273 - else if (!strncmp(argv, "max_ids:", 8)) 4274 - max_ids = val; 4275 - else if (!strncmp(argv, "rescan:", 7)) 4276 - rescan = val; 4277 - else if (!strncmp(argv, "shared_access:", 14)) 4278 - shared_access = val; 4279 - else if (!strncmp(argv, "reserve_list:", 13)) { 4280 - reserve_list[0] = val; 4281 - for (i = 1; i < MAX_RES_ARGS; i++) { 4282 - cur_str = strchr(cur_str, ','); 4283 - if (!cur_str) 4284 - break; 4285 - if (!isdigit((int)*++cur_str)) { 4286 - --cur_str; 4287 - break; 4288 - } 4289 - reserve_list[i] = 4290 - (int)simple_strtoul(cur_str, NULL, 0); 4291 - } 4292 - if (!cur_str) 4293 - break; 4294 - argv = ++cur_str; 4295 - continue; 4296 - } 4297 - 4298 - if ((argv = strchr(argv, ','))) 4299 - ++argv; 4300 - } 4301 - } 4302 - 4303 - static int __init option_setup(char *str) 4304 - { 4305 - int ints[MAXHA]; 4306 - char *cur = str; 4307 - int i = 1; 4308 - 4309 - TRACE2(("option_setup() str %s\n", str ? str:"NULL")); 4310 - 4311 - while (cur && isdigit(*cur) && i < MAXHA) { 4312 - ints[i++] = simple_strtoul(cur, NULL, 0); 4313 - if ((cur = strchr(cur, ',')) != NULL) cur++; 4314 - } 4315 - 4316 - ints[0] = i - 1; 4317 - internal_setup(cur, ints); 4318 - return 1; 4319 - } 4320 - 4321 - __setup("gdth=", option_setup); 4322 - #endif
-981
drivers/scsi/gdth.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _GDTH_H 3 - #define _GDTH_H 4 - 5 - /* 6 - * Header file for the GDT Disk Array/Storage RAID controllers driver for Linux 7 - * 8 - * gdth.h Copyright (C) 1995-06 ICP vortex, Achim Leubner 9 - * See gdth.c for further informations and 10 - * below for supported controller types 11 - * 12 - * <achim_leubner@adaptec.com> 13 - * 14 - * $Id: gdth.h,v 1.58 2006/01/11 16:14:09 achim Exp $ 15 - */ 16 - 17 - #include <linux/types.h> 18 - 19 - #ifndef TRUE 20 - #define TRUE 1 21 - #endif 22 - #ifndef FALSE 23 - #define FALSE 0 24 - #endif 25 - 26 - /* defines, macros */ 27 - 28 - /* driver version */ 29 - #define GDTH_VERSION_STR "3.05" 30 - #define GDTH_VERSION 3 31 - #define GDTH_SUBVERSION 5 32 - 33 - /* protocol version */ 34 - #define PROTOCOL_VERSION 1 35 - 36 - /* OEM IDs */ 37 - #define OEM_ID_ICP 0x941c 38 - #define OEM_ID_INTEL 0x8000 39 - 40 - /* controller classes */ 41 - #define GDT_PCI 0x03 /* PCI controller */ 42 - #define GDT_PCINEW 0x04 /* new PCI controller */ 43 - #define GDT_PCIMPR 0x05 /* PCI MPR controller */ 44 - 45 - #ifndef PCI_DEVICE_ID_VORTEX_GDT60x0 46 - /* GDT_PCI */ 47 - #define PCI_DEVICE_ID_VORTEX_GDT60x0 0 /* GDT6000/6020/6050 */ 48 - #define PCI_DEVICE_ID_VORTEX_GDT6000B 1 /* GDT6000B/6010 */ 49 - /* GDT_PCINEW */ 50 - #define PCI_DEVICE_ID_VORTEX_GDT6x10 2 /* GDT6110/6510 */ 51 - #define PCI_DEVICE_ID_VORTEX_GDT6x20 3 /* GDT6120/6520 */ 52 - #define PCI_DEVICE_ID_VORTEX_GDT6530 4 /* GDT6530 */ 53 - #define PCI_DEVICE_ID_VORTEX_GDT6550 5 /* GDT6550 */ 54 - /* GDT_PCINEW, wide/ultra SCSI controllers */ 55 - #define PCI_DEVICE_ID_VORTEX_GDT6x17 6 /* GDT6117/6517 */ 56 - #define PCI_DEVICE_ID_VORTEX_GDT6x27 7 /* GDT6127/6527 */ 57 - #define PCI_DEVICE_ID_VORTEX_GDT6537 8 /* GDT6537 */ 58 - #define PCI_DEVICE_ID_VORTEX_GDT6557 9 /* GDT6557/6557-ECC */ 59 - /* GDT_PCINEW, wide SCSI controllers */ 60 - #define PCI_DEVICE_ID_VORTEX_GDT6x15 10 /* GDT6115/6515 */ 61 - #define PCI_DEVICE_ID_VORTEX_GDT6x25 11 /* GDT6125/6525 */ 62 - #define PCI_DEVICE_ID_VORTEX_GDT6535 12 /* GDT6535 */ 63 - #define PCI_DEVICE_ID_VORTEX_GDT6555 13 /* GDT6555/6555-ECC */ 64 - #endif 65 - 66 - #ifndef PCI_DEVICE_ID_VORTEX_GDT6x17RP 67 - /* GDT_MPR, RP series, wide/ultra SCSI */ 68 - #define PCI_DEVICE_ID_VORTEX_GDT6x17RP 0x100 /* GDT6117RP/GDT6517RP */ 69 - #define PCI_DEVICE_ID_VORTEX_GDT6x27RP 0x101 /* GDT6127RP/GDT6527RP */ 70 - #define PCI_DEVICE_ID_VORTEX_GDT6537RP 0x102 /* GDT6537RP */ 71 - #define PCI_DEVICE_ID_VORTEX_GDT6557RP 0x103 /* GDT6557RP */ 72 - /* GDT_MPR, RP series, narrow/ultra SCSI */ 73 - #define PCI_DEVICE_ID_VORTEX_GDT6x11RP 0x104 /* GDT6111RP/GDT6511RP */ 74 - #define PCI_DEVICE_ID_VORTEX_GDT6x21RP 0x105 /* GDT6121RP/GDT6521RP */ 75 - #endif 76 - #ifndef PCI_DEVICE_ID_VORTEX_GDT6x17RD 77 - /* GDT_MPR, RD series, wide/ultra SCSI */ 78 - #define PCI_DEVICE_ID_VORTEX_GDT6x17RD 0x110 /* GDT6117RD/GDT6517RD */ 79 - #define PCI_DEVICE_ID_VORTEX_GDT6x27RD 0x111 /* GDT6127RD/GDT6527RD */ 80 - #define PCI_DEVICE_ID_VORTEX_GDT6537RD 0x112 /* GDT6537RD */ 81 - #define PCI_DEVICE_ID_VORTEX_GDT6557RD 0x113 /* GDT6557RD */ 82 - /* GDT_MPR, RD series, narrow/ultra SCSI */ 83 - #define PCI_DEVICE_ID_VORTEX_GDT6x11RD 0x114 /* GDT6111RD/GDT6511RD */ 84 - #define PCI_DEVICE_ID_VORTEX_GDT6x21RD 0x115 /* GDT6121RD/GDT6521RD */ 85 - /* GDT_MPR, RD series, wide/ultra2 SCSI */ 86 - #define PCI_DEVICE_ID_VORTEX_GDT6x18RD 0x118 /* GDT6118RD/GDT6518RD/ 87 - GDT6618RD */ 88 - #define PCI_DEVICE_ID_VORTEX_GDT6x28RD 0x119 /* GDT6128RD/GDT6528RD/ 89 - GDT6628RD */ 90 - #define PCI_DEVICE_ID_VORTEX_GDT6x38RD 0x11A /* GDT6538RD/GDT6638RD */ 91 - #define PCI_DEVICE_ID_VORTEX_GDT6x58RD 0x11B /* GDT6558RD/GDT6658RD */ 92 - /* GDT_MPR, RN series (64-bit PCI), wide/ultra2 SCSI */ 93 - #define PCI_DEVICE_ID_VORTEX_GDT7x18RN 0x168 /* GDT7118RN/GDT7518RN/ 94 - GDT7618RN */ 95 - #define PCI_DEVICE_ID_VORTEX_GDT7x28RN 0x169 /* GDT7128RN/GDT7528RN/ 96 - GDT7628RN */ 97 - #define PCI_DEVICE_ID_VORTEX_GDT7x38RN 0x16A /* GDT7538RN/GDT7638RN */ 98 - #define PCI_DEVICE_ID_VORTEX_GDT7x58RN 0x16B /* GDT7558RN/GDT7658RN */ 99 - #endif 100 - 101 - #ifndef PCI_DEVICE_ID_VORTEX_GDT6x19RD 102 - /* GDT_MPR, RD series, Fibre Channel */ 103 - #define PCI_DEVICE_ID_VORTEX_GDT6x19RD 0x210 /* GDT6519RD/GDT6619RD */ 104 - #define PCI_DEVICE_ID_VORTEX_GDT6x29RD 0x211 /* GDT6529RD/GDT6629RD */ 105 - /* GDT_MPR, RN series (64-bit PCI), Fibre Channel */ 106 - #define PCI_DEVICE_ID_VORTEX_GDT7x19RN 0x260 /* GDT7519RN/GDT7619RN */ 107 - #define PCI_DEVICE_ID_VORTEX_GDT7x29RN 0x261 /* GDT7529RN/GDT7629RN */ 108 - #endif 109 - 110 - #ifndef PCI_DEVICE_ID_VORTEX_GDTMAXRP 111 - /* GDT_MPR, last device ID */ 112 - #define PCI_DEVICE_ID_VORTEX_GDTMAXRP 0x2ff 113 - #endif 114 - 115 - #ifndef PCI_DEVICE_ID_VORTEX_GDTNEWRX 116 - /* new GDT Rx Controller */ 117 - #define PCI_DEVICE_ID_VORTEX_GDTNEWRX 0x300 118 - #endif 119 - 120 - #ifndef PCI_DEVICE_ID_VORTEX_GDTNEWRX2 121 - /* new(2) GDT Rx Controller */ 122 - #define PCI_DEVICE_ID_VORTEX_GDTNEWRX2 0x301 123 - #endif 124 - 125 - #ifndef PCI_DEVICE_ID_INTEL_SRC 126 - /* Intel Storage RAID Controller */ 127 - #define PCI_DEVICE_ID_INTEL_SRC 0x600 128 - #endif 129 - 130 - #ifndef PCI_DEVICE_ID_INTEL_SRC_XSCALE 131 - /* Intel Storage RAID Controller */ 132 - #define PCI_DEVICE_ID_INTEL_SRC_XSCALE 0x601 133 - #endif 134 - 135 - /* limits */ 136 - #define GDTH_SCRATCH PAGE_SIZE /* 4KB scratch buffer */ 137 - #define GDTH_MAXCMDS 120 138 - #define GDTH_MAXC_P_L 16 /* max. cmds per lun */ 139 - #define GDTH_MAX_RAW 2 /* max. cmds per raw device */ 140 - #define MAXOFFSETS 128 141 - #define MAXHA 16 142 - #define MAXID 127 143 - #define MAXLUN 8 144 - #define MAXBUS 6 145 - #define MAX_EVENTS 100 /* event buffer count */ 146 - #define MAX_RES_ARGS 40 /* device reservation, 147 - must be a multiple of 4 */ 148 - #define MAXCYLS 1024 149 - #define HEADS 64 150 - #define SECS 32 /* mapping 64*32 */ 151 - #define MEDHEADS 127 152 - #define MEDSECS 63 /* mapping 127*63 */ 153 - #define BIGHEADS 255 154 - #define BIGSECS 63 /* mapping 255*63 */ 155 - 156 - /* special command ptr. */ 157 - #define UNUSED_CMND ((struct scsi_cmnd *)-1) 158 - #define INTERNAL_CMND ((struct scsi_cmnd *)-2) 159 - #define SCREEN_CMND ((struct scsi_cmnd *)-3) 160 - #define SPECIAL_SCP(p) (p==UNUSED_CMND || p==INTERNAL_CMND || p==SCREEN_CMND) 161 - 162 - /* controller services */ 163 - #define SCSIRAWSERVICE 3 164 - #define CACHESERVICE 9 165 - #define SCREENSERVICE 11 166 - 167 - /* screenservice defines */ 168 - #define MSG_INV_HANDLE -1 /* special message handle */ 169 - #define MSGLEN 16 /* size of message text */ 170 - #define MSG_SIZE 34 /* size of message structure */ 171 - #define MSG_REQUEST 0 /* async. event: message */ 172 - 173 - /* DPMEM constants */ 174 - #define DPMEM_MAGIC 0xC0FFEE11 175 - #define IC_HEADER_BYTES 48 176 - #define IC_QUEUE_BYTES 4 177 - #define DPMEM_COMMAND_OFFSET IC_HEADER_BYTES+IC_QUEUE_BYTES*MAXOFFSETS 178 - 179 - /* cluster_type constants */ 180 - #define CLUSTER_DRIVE 1 181 - #define CLUSTER_MOUNTED 2 182 - #define CLUSTER_RESERVED 4 183 - #define CLUSTER_RESERVE_STATE (CLUSTER_DRIVE|CLUSTER_MOUNTED|CLUSTER_RESERVED) 184 - 185 - /* commands for all services, cache service */ 186 - #define GDT_INIT 0 /* service initialization */ 187 - #define GDT_READ 1 /* read command */ 188 - #define GDT_WRITE 2 /* write command */ 189 - #define GDT_INFO 3 /* information about devices */ 190 - #define GDT_FLUSH 4 /* flush dirty cache buffers */ 191 - #define GDT_IOCTL 5 /* ioctl command */ 192 - #define GDT_DEVTYPE 9 /* additional information */ 193 - #define GDT_MOUNT 10 /* mount cache device */ 194 - #define GDT_UNMOUNT 11 /* unmount cache device */ 195 - #define GDT_SET_FEAT 12 /* set feat. (scatter/gather) */ 196 - #define GDT_GET_FEAT 13 /* get features */ 197 - #define GDT_WRITE_THR 16 /* write through */ 198 - #define GDT_READ_THR 17 /* read through */ 199 - #define GDT_EXT_INFO 18 /* extended info */ 200 - #define GDT_RESET 19 /* controller reset */ 201 - #define GDT_RESERVE_DRV 20 /* reserve host drive */ 202 - #define GDT_RELEASE_DRV 21 /* release host drive */ 203 - #define GDT_CLUST_INFO 22 /* cluster info */ 204 - #define GDT_RW_ATTRIBS 23 /* R/W attribs (write thru,..)*/ 205 - #define GDT_CLUST_RESET 24 /* releases the cluster drives*/ 206 - #define GDT_FREEZE_IO 25 /* freezes all IOs */ 207 - #define GDT_UNFREEZE_IO 26 /* unfreezes all IOs */ 208 - #define GDT_X_INIT_HOST 29 /* ext. init: 64 bit support */ 209 - #define GDT_X_INFO 30 /* ext. info for drives>2TB */ 210 - 211 - /* raw service commands */ 212 - #define GDT_RESERVE 14 /* reserve dev. to raw serv. */ 213 - #define GDT_RELEASE 15 /* release device */ 214 - #define GDT_RESERVE_ALL 16 /* reserve all devices */ 215 - #define GDT_RELEASE_ALL 17 /* release all devices */ 216 - #define GDT_RESET_BUS 18 /* reset bus */ 217 - #define GDT_SCAN_START 19 /* start device scan */ 218 - #define GDT_SCAN_END 20 /* stop device scan */ 219 - #define GDT_X_INIT_RAW 21 /* ext. init: 64 bit support */ 220 - 221 - /* screen service commands */ 222 - #define GDT_REALTIME 3 /* realtime clock to screens. */ 223 - #define GDT_X_INIT_SCR 4 /* ext. init: 64 bit support */ 224 - 225 - /* IOCTL command defines */ 226 - #define SCSI_DR_INFO 0x00 /* SCSI drive info */ 227 - #define SCSI_CHAN_CNT 0x05 /* SCSI channel count */ 228 - #define SCSI_DR_LIST 0x06 /* SCSI drive list */ 229 - #define SCSI_DEF_CNT 0x15 /* grown/primary defects */ 230 - #define DSK_STATISTICS 0x4b /* SCSI disk statistics */ 231 - #define IOCHAN_DESC 0x5d /* description of IO channel */ 232 - #define IOCHAN_RAW_DESC 0x5e /* description of raw IO chn. */ 233 - #define L_CTRL_PATTERN 0x20000000L /* SCSI IOCTL mask */ 234 - #define ARRAY_INFO 0x12 /* array drive info */ 235 - #define ARRAY_DRV_LIST 0x0f /* array drive list */ 236 - #define ARRAY_DRV_LIST2 0x34 /* array drive list (new) */ 237 - #define LA_CTRL_PATTERN 0x10000000L /* array IOCTL mask */ 238 - #define CACHE_DRV_CNT 0x01 /* cache drive count */ 239 - #define CACHE_DRV_LIST 0x02 /* cache drive list */ 240 - #define CACHE_INFO 0x04 /* cache info */ 241 - #define CACHE_CONFIG 0x05 /* cache configuration */ 242 - #define CACHE_DRV_INFO 0x07 /* cache drive info */ 243 - #define BOARD_FEATURES 0x15 /* controller features */ 244 - #define BOARD_INFO 0x28 /* controller info */ 245 - #define SET_PERF_MODES 0x82 /* set mode (coalescing,..) */ 246 - #define GET_PERF_MODES 0x83 /* get mode */ 247 - #define CACHE_READ_OEM_STRING_RECORD 0x84 /* read OEM string record */ 248 - #define HOST_GET 0x10001L /* get host drive list */ 249 - #define IO_CHANNEL 0x00020000L /* default IO channel */ 250 - #define INVALID_CHANNEL 0x0000ffffL /* invalid channel */ 251 - 252 - /* service errors */ 253 - #define S_OK 1 /* no error */ 254 - #define S_GENERR 6 /* general error */ 255 - #define S_BSY 7 /* controller busy */ 256 - #define S_CACHE_UNKNOWN 12 /* cache serv.: drive unknown */ 257 - #define S_RAW_SCSI 12 /* raw serv.: target error */ 258 - #define S_RAW_ILL 0xff /* raw serv.: illegal */ 259 - #define S_NOFUNC -2 /* unknown function */ 260 - #define S_CACHE_RESERV -24 /* cache: reserv. conflict */ 261 - 262 - /* timeout values */ 263 - #define INIT_RETRIES 100000 /* 100000 * 1ms = 100s */ 264 - #define INIT_TIMEOUT 100000 /* 100000 * 1ms = 100s */ 265 - #define POLL_TIMEOUT 10000 /* 10000 * 1ms = 10s */ 266 - 267 - /* priorities */ 268 - #define DEFAULT_PRI 0x20 269 - #define IOCTL_PRI 0x10 270 - #define HIGH_PRI 0x08 271 - 272 - /* data directions */ 273 - #define GDTH_DATA_IN 0x01000000L /* data from target */ 274 - #define GDTH_DATA_OUT 0x00000000L /* data to target */ 275 - 276 - /* other defines */ 277 - #define LINUX_OS 8 /* used for cache optim. */ 278 - #define SECS32 0x1f /* round capacity */ 279 - #define BIOS_ID_OFFS 0x10 /* offset contr-ID in ISABIOS */ 280 - #define LOCALBOARD 0 /* board node always 0 */ 281 - #define ASYNCINDEX 0 /* cmd index async. event */ 282 - #define SPEZINDEX 1 /* cmd index unknown service */ 283 - #define COALINDEX (GDTH_MAXCMDS + 2) 284 - 285 - /* features */ 286 - #define SCATTER_GATHER 1 /* s/g feature */ 287 - #define GDT_WR_THROUGH 0x100 /* WRITE_THROUGH supported */ 288 - #define GDT_64BIT 0x200 /* 64bit / drv>2TB support */ 289 - 290 - #include "gdth_ioctl.h" 291 - 292 - /* screenservice message */ 293 - typedef struct { 294 - u32 msg_handle; /* message handle */ 295 - u32 msg_len; /* size of message */ 296 - u32 msg_alen; /* answer length */ 297 - u8 msg_answer; /* answer flag */ 298 - u8 msg_ext; /* more messages */ 299 - u8 msg_reserved[2]; 300 - char msg_text[MSGLEN+2]; /* the message text */ 301 - } __attribute__((packed)) gdth_msg_str; 302 - 303 - 304 - /* IOCTL data structures */ 305 - 306 - /* Status coalescing buffer for returning multiple requests per interrupt */ 307 - typedef struct { 308 - u32 status; 309 - u32 ext_status; 310 - u32 info0; 311 - u32 info1; 312 - } __attribute__((packed)) gdth_coal_status; 313 - 314 - /* performance mode data structure */ 315 - typedef struct { 316 - u32 version; /* The version of this IOCTL structure. */ 317 - u32 st_mode; /* 0=dis., 1=st_buf_addr1 valid, 2=both */ 318 - u32 st_buff_addr1; /* physical address of status buffer 1 */ 319 - u32 st_buff_u_addr1; /* reserved for 64 bit addressing */ 320 - u32 st_buff_indx1; /* reserved command idx. for this buffer */ 321 - u32 st_buff_addr2; /* physical address of status buffer 1 */ 322 - u32 st_buff_u_addr2; /* reserved for 64 bit addressing */ 323 - u32 st_buff_indx2; /* reserved command idx. for this buffer */ 324 - u32 st_buff_size; /* size of each buffer in bytes */ 325 - u32 cmd_mode; /* 0 = mode disabled, 1 = cmd_buff_addr1 */ 326 - u32 cmd_buff_addr1; /* physical address of cmd buffer 1 */ 327 - u32 cmd_buff_u_addr1; /* reserved for 64 bit addressing */ 328 - u32 cmd_buff_indx1; /* cmd buf addr1 unique identifier */ 329 - u32 cmd_buff_addr2; /* physical address of cmd buffer 1 */ 330 - u32 cmd_buff_u_addr2; /* reserved for 64 bit addressing */ 331 - u32 cmd_buff_indx2; /* cmd buf addr1 unique identifier */ 332 - u32 cmd_buff_size; /* size of each cmd buffer in bytes */ 333 - u32 reserved1; 334 - u32 reserved2; 335 - } __attribute__((packed)) gdth_perf_modes; 336 - 337 - /* SCSI drive info */ 338 - typedef struct { 339 - u8 vendor[8]; /* vendor string */ 340 - u8 product[16]; /* product string */ 341 - u8 revision[4]; /* revision */ 342 - u32 sy_rate; /* current rate for sync. tr. */ 343 - u32 sy_max_rate; /* max. rate for sync. tr. */ 344 - u32 no_ldrive; /* belongs to this log. drv.*/ 345 - u32 blkcnt; /* number of blocks */ 346 - u16 blksize; /* size of block in bytes */ 347 - u8 available; /* flag: access is available */ 348 - u8 init; /* medium is initialized */ 349 - u8 devtype; /* SCSI devicetype */ 350 - u8 rm_medium; /* medium is removable */ 351 - u8 wp_medium; /* medium is write protected */ 352 - u8 ansi; /* SCSI I/II or III? */ 353 - u8 protocol; /* same as ansi */ 354 - u8 sync; /* flag: sync. transfer enab. */ 355 - u8 disc; /* flag: disconnect enabled */ 356 - u8 queueing; /* flag: command queing enab. */ 357 - u8 cached; /* flag: caching enabled */ 358 - u8 target_id; /* target ID of device */ 359 - u8 lun; /* LUN id of device */ 360 - u8 orphan; /* flag: drive fragment */ 361 - u32 last_error; /* sense key or drive state */ 362 - u32 last_result; /* result of last command */ 363 - u32 check_errors; /* err. in last surface check */ 364 - u8 percent; /* progress for surface check */ 365 - u8 last_check; /* IOCTRL operation */ 366 - u8 res[2]; 367 - u32 flags; /* from 1.19/2.19: raw reserv.*/ 368 - u8 multi_bus; /* multi bus dev? (fibre ch.) */ 369 - u8 mb_status; /* status: available? */ 370 - u8 res2[2]; 371 - u8 mb_alt_status; /* status on second bus */ 372 - u8 mb_alt_bid; /* number of second bus */ 373 - u8 mb_alt_tid; /* target id on second bus */ 374 - u8 res3; 375 - u8 fc_flag; /* from 1.22/2.22: info valid?*/ 376 - u8 res4; 377 - u16 fc_frame_size; /* frame size (bytes) */ 378 - char wwn[8]; /* world wide name */ 379 - } __attribute__((packed)) gdth_diskinfo_str; 380 - 381 - /* get SCSI channel count */ 382 - typedef struct { 383 - u32 channel_no; /* number of channel */ 384 - u32 drive_cnt; /* drive count */ 385 - u8 siop_id; /* SCSI processor ID */ 386 - u8 siop_state; /* SCSI processor state */ 387 - } __attribute__((packed)) gdth_getch_str; 388 - 389 - /* get SCSI drive numbers */ 390 - typedef struct { 391 - u32 sc_no; /* SCSI channel */ 392 - u32 sc_cnt; /* sc_list[] elements */ 393 - u32 sc_list[MAXID]; /* minor device numbers */ 394 - } __attribute__((packed)) gdth_drlist_str; 395 - 396 - /* get grown/primary defect count */ 397 - typedef struct { 398 - u8 sddc_type; /* 0x08: grown, 0x10: prim. */ 399 - u8 sddc_format; /* list entry format */ 400 - u8 sddc_len; /* list entry length */ 401 - u8 sddc_res; 402 - u32 sddc_cnt; /* entry count */ 403 - } __attribute__((packed)) gdth_defcnt_str; 404 - 405 - /* disk statistics */ 406 - typedef struct { 407 - u32 bid; /* SCSI channel */ 408 - u32 first; /* first SCSI disk */ 409 - u32 entries; /* number of elements */ 410 - u32 count; /* (R) number of init. el. */ 411 - u32 mon_time; /* time stamp */ 412 - struct { 413 - u8 tid; /* target ID */ 414 - u8 lun; /* LUN */ 415 - u8 res[2]; 416 - u32 blk_size; /* block size in bytes */ 417 - u32 rd_count; /* bytes read */ 418 - u32 wr_count; /* bytes written */ 419 - u32 rd_blk_count; /* blocks read */ 420 - u32 wr_blk_count; /* blocks written */ 421 - u32 retries; /* retries */ 422 - u32 reassigns; /* reassigns */ 423 - } __attribute__((packed)) list[1]; 424 - } __attribute__((packed)) gdth_dskstat_str; 425 - 426 - /* IO channel header */ 427 - typedef struct { 428 - u32 version; /* version (-1UL: newest) */ 429 - u8 list_entries; /* list entry count */ 430 - u8 first_chan; /* first channel number */ 431 - u8 last_chan; /* last channel number */ 432 - u8 chan_count; /* (R) channel count */ 433 - u32 list_offset; /* offset of list[0] */ 434 - } __attribute__((packed)) gdth_iochan_header; 435 - 436 - /* get IO channel description */ 437 - typedef struct { 438 - gdth_iochan_header hdr; 439 - struct { 440 - u32 address; /* channel address */ 441 - u8 type; /* type (SCSI, FCAL) */ 442 - u8 local_no; /* local number */ 443 - u16 features; /* channel features */ 444 - } __attribute__((packed)) list[MAXBUS]; 445 - } __attribute__((packed)) gdth_iochan_str; 446 - 447 - /* get raw IO channel description */ 448 - typedef struct { 449 - gdth_iochan_header hdr; 450 - struct { 451 - u8 proc_id; /* processor id */ 452 - u8 proc_defect; /* defect ? */ 453 - u8 reserved[2]; 454 - } __attribute__((packed)) list[MAXBUS]; 455 - } __attribute__((packed)) gdth_raw_iochan_str; 456 - 457 - /* array drive component */ 458 - typedef struct { 459 - u32 al_controller; /* controller ID */ 460 - u8 al_cache_drive; /* cache drive number */ 461 - u8 al_status; /* cache drive state */ 462 - u8 al_res[2]; 463 - } __attribute__((packed)) gdth_arraycomp_str; 464 - 465 - /* array drive information */ 466 - typedef struct { 467 - u8 ai_type; /* array type (RAID0,4,5) */ 468 - u8 ai_cache_drive_cnt; /* active cachedrives */ 469 - u8 ai_state; /* array drive state */ 470 - u8 ai_master_cd; /* master cachedrive */ 471 - u32 ai_master_controller; /* ID of master controller */ 472 - u32 ai_size; /* user capacity [sectors] */ 473 - u32 ai_striping_size; /* striping size [sectors] */ 474 - u32 ai_secsize; /* sector size [bytes] */ 475 - u32 ai_err_info; /* failed cache drive */ 476 - u8 ai_name[8]; /* name of the array drive */ 477 - u8 ai_controller_cnt; /* number of controllers */ 478 - u8 ai_removable; /* flag: removable */ 479 - u8 ai_write_protected; /* flag: write protected */ 480 - u8 ai_devtype; /* type: always direct access */ 481 - gdth_arraycomp_str ai_drives[35]; /* drive components: */ 482 - u8 ai_drive_entries; /* number of drive components */ 483 - u8 ai_protected; /* protection flag */ 484 - u8 ai_verify_state; /* state of a parity verify */ 485 - u8 ai_ext_state; /* extended array drive state */ 486 - u8 ai_expand_state; /* array expand state (>=2.18)*/ 487 - u8 ai_reserved[3]; 488 - } __attribute__((packed)) gdth_arrayinf_str; 489 - 490 - /* get array drive list */ 491 - typedef struct { 492 - u32 controller_no; /* controller no. */ 493 - u8 cd_handle; /* master cachedrive */ 494 - u8 is_arrayd; /* Flag: is array drive? */ 495 - u8 is_master; /* Flag: is array master? */ 496 - u8 is_parity; /* Flag: is parity drive? */ 497 - u8 is_hotfix; /* Flag: is hotfix drive? */ 498 - u8 res[3]; 499 - } __attribute__((packed)) gdth_alist_str; 500 - 501 - typedef struct { 502 - u32 entries_avail; /* allocated entries */ 503 - u32 entries_init; /* returned entries */ 504 - u32 first_entry; /* first entry number */ 505 - u32 list_offset; /* offset of following list */ 506 - gdth_alist_str list[1]; /* list */ 507 - } __attribute__((packed)) gdth_arcdl_str; 508 - 509 - /* cache info/config IOCTL */ 510 - typedef struct { 511 - u32 version; /* firmware version */ 512 - u16 state; /* cache state (on/off) */ 513 - u16 strategy; /* cache strategy */ 514 - u16 write_back; /* write back state (on/off) */ 515 - u16 block_size; /* cache block size */ 516 - } __attribute__((packed)) gdth_cpar_str; 517 - 518 - typedef struct { 519 - u32 csize; /* cache size */ 520 - u32 read_cnt; /* read/write counter */ 521 - u32 write_cnt; 522 - u32 tr_hits; /* hits */ 523 - u32 sec_hits; 524 - u32 sec_miss; /* misses */ 525 - } __attribute__((packed)) gdth_cstat_str; 526 - 527 - typedef struct { 528 - gdth_cpar_str cpar; 529 - gdth_cstat_str cstat; 530 - } __attribute__((packed)) gdth_cinfo_str; 531 - 532 - /* cache drive info */ 533 - typedef struct { 534 - u8 cd_name[8]; /* cache drive name */ 535 - u32 cd_devtype; /* SCSI devicetype */ 536 - u32 cd_ldcnt; /* number of log. drives */ 537 - u32 cd_last_error; /* last error */ 538 - u8 cd_initialized; /* drive is initialized */ 539 - u8 cd_removable; /* media is removable */ 540 - u8 cd_write_protected; /* write protected */ 541 - u8 cd_flags; /* Pool Hot Fix? */ 542 - u32 ld_blkcnt; /* number of blocks */ 543 - u32 ld_blksize; /* blocksize */ 544 - u32 ld_dcnt; /* number of disks */ 545 - u32 ld_slave; /* log. drive index */ 546 - u32 ld_dtype; /* type of logical drive */ 547 - u32 ld_last_error; /* last error */ 548 - u8 ld_name[8]; /* log. drive name */ 549 - u8 ld_error; /* error */ 550 - } __attribute__((packed)) gdth_cdrinfo_str; 551 - 552 - /* OEM string */ 553 - typedef struct { 554 - u32 ctl_version; 555 - u32 file_major_version; 556 - u32 file_minor_version; 557 - u32 buffer_size; 558 - u32 cpy_count; 559 - u32 ext_error; 560 - u32 oem_id; 561 - u32 board_id; 562 - } __attribute__((packed)) gdth_oem_str_params; 563 - 564 - typedef struct { 565 - u8 product_0_1_name[16]; 566 - u8 product_4_5_name[16]; 567 - u8 product_cluster_name[16]; 568 - u8 product_reserved[16]; 569 - u8 scsi_cluster_target_vendor_id[16]; 570 - u8 cluster_raid_fw_name[16]; 571 - u8 oem_brand_name[16]; 572 - u8 oem_raid_type[16]; 573 - u8 bios_type[13]; 574 - u8 bios_title[50]; 575 - u8 oem_company_name[37]; 576 - u32 pci_id_1; 577 - u32 pci_id_2; 578 - u8 validation_status[80]; 579 - u8 reserved_1[4]; 580 - u8 scsi_host_drive_inquiry_vendor_id[16]; 581 - u8 library_file_template[16]; 582 - u8 reserved_2[16]; 583 - u8 tool_name_1[32]; 584 - u8 tool_name_2[32]; 585 - u8 tool_name_3[32]; 586 - u8 oem_contact_1[84]; 587 - u8 oem_contact_2[84]; 588 - u8 oem_contact_3[84]; 589 - } __attribute__((packed)) gdth_oem_str; 590 - 591 - typedef struct { 592 - gdth_oem_str_params params; 593 - gdth_oem_str text; 594 - } __attribute__((packed)) gdth_oem_str_ioctl; 595 - 596 - /* board features */ 597 - typedef struct { 598 - u8 chaining; /* Chaining supported */ 599 - u8 striping; /* Striping (RAID-0) supp. */ 600 - u8 mirroring; /* Mirroring (RAID-1) supp. */ 601 - u8 raid; /* RAID-4/5/10 supported */ 602 - } __attribute__((packed)) gdth_bfeat_str; 603 - 604 - /* board info IOCTL */ 605 - typedef struct { 606 - u32 ser_no; /* serial no. */ 607 - u8 oem_id[2]; /* OEM ID */ 608 - u16 ep_flags; /* eprom flags */ 609 - u32 proc_id; /* processor ID */ 610 - u32 memsize; /* memory size (bytes) */ 611 - u8 mem_banks; /* memory banks */ 612 - u8 chan_type; /* channel type */ 613 - u8 chan_count; /* channel count */ 614 - u8 rdongle_pres; /* dongle present? */ 615 - u32 epr_fw_ver; /* (eprom) firmware version */ 616 - u32 upd_fw_ver; /* (update) firmware version */ 617 - u32 upd_revision; /* update revision */ 618 - char type_string[16]; /* controller name */ 619 - char raid_string[16]; /* RAID firmware name */ 620 - u8 update_pres; /* update present? */ 621 - u8 xor_pres; /* XOR engine present? */ 622 - u8 prom_type; /* ROM type (eprom/flash) */ 623 - u8 prom_count; /* number of ROM devices */ 624 - u32 dup_pres; /* duplexing module present? */ 625 - u32 chan_pres; /* number of expansion chn. */ 626 - u32 mem_pres; /* memory expansion inst. ? */ 627 - u8 ft_bus_system; /* fault bus supported? */ 628 - u8 subtype_valid; /* board_subtype valid? */ 629 - u8 board_subtype; /* subtype/hardware level */ 630 - u8 ramparity_pres; /* RAM parity check hardware? */ 631 - } __attribute__((packed)) gdth_binfo_str; 632 - 633 - /* get host drive info */ 634 - typedef struct { 635 - char name[8]; /* host drive name */ 636 - u32 size; /* size (sectors) */ 637 - u8 host_drive; /* host drive number */ 638 - u8 log_drive; /* log. drive (master) */ 639 - u8 reserved; 640 - u8 rw_attribs; /* r/w attribs */ 641 - u32 start_sec; /* start sector */ 642 - } __attribute__((packed)) gdth_hentry_str; 643 - 644 - typedef struct { 645 - u32 entries; /* entry count */ 646 - u32 offset; /* offset of entries */ 647 - u8 secs_p_head; /* sectors/head */ 648 - u8 heads_p_cyl; /* heads/cylinder */ 649 - u8 reserved; 650 - u8 clust_drvtype; /* cluster drive type */ 651 - u32 location; /* controller number */ 652 - gdth_hentry_str entry[MAX_HDRIVES]; /* entries */ 653 - } __attribute__((packed)) gdth_hget_str; 654 - 655 - 656 - /* DPRAM structures */ 657 - 658 - /* interface area ISA/PCI */ 659 - typedef struct { 660 - u8 S_Cmd_Indx; /* special command */ 661 - u8 volatile S_Status; /* status special command */ 662 - u16 reserved1; 663 - u32 S_Info[4]; /* add. info special command */ 664 - u8 volatile Sema0; /* command semaphore */ 665 - u8 reserved2[3]; 666 - u8 Cmd_Index; /* command number */ 667 - u8 reserved3[3]; 668 - u16 volatile Status; /* command status */ 669 - u16 Service; /* service(for async.events) */ 670 - u32 Info[2]; /* additional info */ 671 - struct { 672 - u16 offset; /* command offs. in the DPRAM*/ 673 - u16 serv_id; /* service */ 674 - } __attribute__((packed)) comm_queue[MAXOFFSETS]; /* command queue */ 675 - u32 bios_reserved[2]; 676 - u8 gdt_dpr_cmd[1]; /* commands */ 677 - } __attribute__((packed)) gdt_dpr_if; 678 - 679 - /* SRAM structure PCI controllers */ 680 - typedef struct { 681 - u32 magic; /* controller ID from BIOS */ 682 - u16 need_deinit; /* switch betw. BIOS/driver */ 683 - u8 switch_support; /* see need_deinit */ 684 - u8 padding[9]; 685 - u8 os_used[16]; /* OS code per service */ 686 - u8 unused[28]; 687 - u8 fw_magic; /* contr. ID from firmware */ 688 - } __attribute__((packed)) gdt_pci_sram; 689 - 690 - /* DPRAM ISA controllers */ 691 - typedef struct { 692 - union { 693 - struct { 694 - u8 bios_used[0x3c00-32]; /* 15KB - 32Bytes BIOS */ 695 - u16 need_deinit; /* switch betw. BIOS/driver */ 696 - u8 switch_support; /* see need_deinit */ 697 - u8 padding[9]; 698 - u8 os_used[16]; /* OS code per service */ 699 - } __attribute__((packed)) dp_sram; 700 - u8 bios_area[0x4000]; /* 16KB reserved for BIOS */ 701 - } bu; 702 - union { 703 - gdt_dpr_if ic; /* interface area */ 704 - u8 if_area[0x3000]; /* 12KB for interface */ 705 - } u; 706 - struct { 707 - u8 memlock; /* write protection DPRAM */ 708 - u8 event; /* release event */ 709 - u8 irqen; /* board interrupts enable */ 710 - u8 irqdel; /* acknowledge board int. */ 711 - u8 volatile Sema1; /* status semaphore */ 712 - u8 rq; /* IRQ/DRQ configuration */ 713 - } __attribute__((packed)) io; 714 - } __attribute__((packed)) gdt2_dpram_str; 715 - 716 - /* DPRAM PCI controllers */ 717 - typedef struct { 718 - union { 719 - gdt_dpr_if ic; /* interface area */ 720 - u8 if_area[0xff0-sizeof(gdt_pci_sram)]; 721 - } u; 722 - gdt_pci_sram gdt6sr; /* SRAM structure */ 723 - struct { 724 - u8 unused0[1]; 725 - u8 volatile Sema1; /* command semaphore */ 726 - u8 unused1[3]; 727 - u8 irqen; /* board interrupts enable */ 728 - u8 unused2[2]; 729 - u8 event; /* release event */ 730 - u8 unused3[3]; 731 - u8 irqdel; /* acknowledge board int. */ 732 - u8 unused4[3]; 733 - } __attribute__((packed)) io; 734 - } __attribute__((packed)) gdt6_dpram_str; 735 - 736 - /* PLX register structure (new PCI controllers) */ 737 - typedef struct { 738 - u8 cfg_reg; /* DPRAM cfg.(2:below 1MB,0:anywhere)*/ 739 - u8 unused1[0x3f]; 740 - u8 volatile sema0_reg; /* command semaphore */ 741 - u8 volatile sema1_reg; /* status semaphore */ 742 - u8 unused2[2]; 743 - u16 volatile status; /* command status */ 744 - u16 service; /* service */ 745 - u32 info[2]; /* additional info */ 746 - u8 unused3[0x10]; 747 - u8 ldoor_reg; /* PCI to local doorbell */ 748 - u8 unused4[3]; 749 - u8 volatile edoor_reg; /* local to PCI doorbell */ 750 - u8 unused5[3]; 751 - u8 control0; /* control0 register(unused) */ 752 - u8 control1; /* board interrupts enable */ 753 - u8 unused6[0x16]; 754 - } __attribute__((packed)) gdt6c_plx_regs; 755 - 756 - /* DPRAM new PCI controllers */ 757 - typedef struct { 758 - union { 759 - gdt_dpr_if ic; /* interface area */ 760 - u8 if_area[0x4000-sizeof(gdt_pci_sram)]; 761 - } u; 762 - gdt_pci_sram gdt6sr; /* SRAM structure */ 763 - } __attribute__((packed)) gdt6c_dpram_str; 764 - 765 - /* i960 register structure (PCI MPR controllers) */ 766 - typedef struct { 767 - u8 unused1[16]; 768 - u8 volatile sema0_reg; /* command semaphore */ 769 - u8 unused2; 770 - u8 volatile sema1_reg; /* status semaphore */ 771 - u8 unused3; 772 - u16 volatile status; /* command status */ 773 - u16 service; /* service */ 774 - u32 info[2]; /* additional info */ 775 - u8 ldoor_reg; /* PCI to local doorbell */ 776 - u8 unused4[11]; 777 - u8 volatile edoor_reg; /* local to PCI doorbell */ 778 - u8 unused5[7]; 779 - u8 edoor_en_reg; /* board interrupts enable */ 780 - u8 unused6[27]; 781 - u32 unused7[939]; 782 - u32 severity; 783 - char evt_str[256]; /* event string */ 784 - } __attribute__((packed)) gdt6m_i960_regs; 785 - 786 - /* DPRAM PCI MPR controllers */ 787 - typedef struct { 788 - gdt6m_i960_regs i960r; /* 4KB i960 registers */ 789 - union { 790 - gdt_dpr_if ic; /* interface area */ 791 - u8 if_area[0x3000-sizeof(gdt_pci_sram)]; 792 - } u; 793 - gdt_pci_sram gdt6sr; /* SRAM structure */ 794 - } __attribute__((packed)) gdt6m_dpram_str; 795 - 796 - 797 - /* PCI resources */ 798 - typedef struct { 799 - struct pci_dev *pdev; 800 - unsigned long dpmem; /* DPRAM address */ 801 - unsigned long io; /* IO address */ 802 - } gdth_pci_str; 803 - 804 - 805 - /* controller information structure */ 806 - typedef struct { 807 - struct Scsi_Host *shost; 808 - struct list_head list; 809 - u16 hanum; 810 - u16 oem_id; /* OEM */ 811 - u16 type; /* controller class */ 812 - u32 stype; /* subtype (PCI: device ID) */ 813 - u16 fw_vers; /* firmware version */ 814 - u16 cache_feat; /* feat. cache serv. (s/g,..)*/ 815 - u16 raw_feat; /* feat. raw service (s/g,..)*/ 816 - u16 screen_feat; /* feat. raw service (s/g,..)*/ 817 - void __iomem *brd; /* DPRAM address */ 818 - u32 brd_phys; /* slot number/BIOS address */ 819 - gdt6c_plx_regs *plx; /* PLX regs (new PCI contr.) */ 820 - gdth_cmd_str cmdext; 821 - gdth_cmd_str *pccb; /* address command structure */ 822 - u32 ccb_phys; /* phys. address */ 823 - #ifdef INT_COAL 824 - gdth_coal_status *coal_stat; /* buffer for coalescing int.*/ 825 - u64 coal_stat_phys; /* phys. address */ 826 - #endif 827 - char *pscratch; /* scratch (DMA) buffer */ 828 - u64 scratch_phys; /* phys. address */ 829 - u8 scratch_busy; /* in use? */ 830 - u8 dma64_support; /* 64-bit DMA supported? */ 831 - gdth_msg_str *pmsg; /* message buffer */ 832 - u64 msg_phys; /* phys. address */ 833 - u8 scan_mode; /* current scan mode */ 834 - u8 irq; /* IRQ */ 835 - u8 drq; /* DRQ (ISA controllers) */ 836 - u16 status; /* command status */ 837 - u16 service; /* service/firmware ver./.. */ 838 - u32 info; 839 - u32 info2; /* additional info */ 840 - struct scsi_cmnd *req_first; /* top of request queue */ 841 - struct { 842 - u8 present; /* Flag: host drive present? */ 843 - u8 is_logdrv; /* Flag: log. drive (master)? */ 844 - u8 is_arraydrv; /* Flag: array drive? */ 845 - u8 is_master; /* Flag: array drive master? */ 846 - u8 is_parity; /* Flag: parity drive? */ 847 - u8 is_hotfix; /* Flag: hotfix drive? */ 848 - u8 master_no; /* number of master drive */ 849 - u8 lock; /* drive locked? (hot plug) */ 850 - u8 heads; /* mapping */ 851 - u8 secs; 852 - u16 devtype; /* further information */ 853 - u64 size; /* capacity */ 854 - u8 ldr_no; /* log. drive no. */ 855 - u8 rw_attribs; /* r/w attributes */ 856 - u8 cluster_type; /* cluster properties */ 857 - u8 media_changed; /* Flag:MOUNT/UNMOUNT occurred */ 858 - u32 start_sec; /* start sector */ 859 - } hdr[MAX_LDRIVES]; /* host drives */ 860 - struct { 861 - u8 lock; /* channel locked? (hot plug) */ 862 - u8 pdev_cnt; /* physical device count */ 863 - u8 local_no; /* local channel number */ 864 - u8 io_cnt[MAXID]; /* current IO count */ 865 - u32 address; /* channel address */ 866 - u32 id_list[MAXID]; /* IDs of the phys. devices */ 867 - } raw[MAXBUS]; /* SCSI channels */ 868 - struct { 869 - struct scsi_cmnd *cmnd; /* pending request */ 870 - u16 service; /* service */ 871 - } cmd_tab[GDTH_MAXCMDS]; /* table of pend. requests */ 872 - struct gdth_cmndinfo { /* per-command private info */ 873 - int index; 874 - int internal_command; /* don't call scsi_done */ 875 - gdth_cmd_str *internal_cmd_str; /* crier for internal messages*/ 876 - dma_addr_t sense_paddr; /* sense dma-addr */ 877 - u8 priority; 878 - int timeout_count; /* # of timeout calls */ 879 - volatile int wait_for_completion; 880 - u16 status; 881 - u32 info; 882 - enum dma_data_direction dma_dir; 883 - int phase; /* ???? */ 884 - int OpCode; 885 - } cmndinfo[GDTH_MAXCMDS]; /* index==0 is free */ 886 - u8 bus_cnt; /* SCSI bus count */ 887 - u8 tid_cnt; /* Target ID count */ 888 - u8 bus_id[MAXBUS]; /* IOP IDs */ 889 - u8 virt_bus; /* number of virtual bus */ 890 - u8 more_proc; /* more /proc info supported */ 891 - u16 cmd_cnt; /* command count in DPRAM */ 892 - u16 cmd_len; /* length of actual command */ 893 - u16 cmd_offs_dpmem; /* actual offset in DPRAM */ 894 - u16 ic_all_size; /* sizeof DPRAM interf. area */ 895 - gdth_cpar_str cpar; /* controller cache par. */ 896 - gdth_bfeat_str bfeat; /* controller features */ 897 - gdth_binfo_str binfo; /* controller info */ 898 - gdth_evt_data dvr; /* event structure */ 899 - spinlock_t smp_lock; 900 - struct pci_dev *pdev; 901 - char oem_name[8]; 902 - #ifdef GDTH_DMA_STATISTICS 903 - unsigned long dma32_cnt, dma64_cnt; /* statistics: DMA buffer */ 904 - #endif 905 - struct scsi_device *sdev; 906 - } gdth_ha_str; 907 - 908 - static inline struct gdth_cmndinfo *gdth_cmnd_priv(struct scsi_cmnd* cmd) 909 - { 910 - return (struct gdth_cmndinfo *)cmd->host_scribble; 911 - } 912 - 913 - /* INQUIRY data format */ 914 - typedef struct { 915 - u8 type_qual; 916 - u8 modif_rmb; 917 - u8 version; 918 - u8 resp_aenc; 919 - u8 add_length; 920 - u8 reserved1; 921 - u8 reserved2; 922 - u8 misc; 923 - u8 vendor[8]; 924 - u8 product[16]; 925 - u8 revision[4]; 926 - } __attribute__((packed)) gdth_inq_data; 927 - 928 - /* READ_CAPACITY data format */ 929 - typedef struct { 930 - u32 last_block_no; 931 - u32 block_length; 932 - } __attribute__((packed)) gdth_rdcap_data; 933 - 934 - /* READ_CAPACITY (16) data format */ 935 - typedef struct { 936 - u64 last_block_no; 937 - u32 block_length; 938 - } __attribute__((packed)) gdth_rdcap16_data; 939 - 940 - /* REQUEST_SENSE data format */ 941 - typedef struct { 942 - u8 errorcode; 943 - u8 segno; 944 - u8 key; 945 - u32 info; 946 - u8 add_length; 947 - u32 cmd_info; 948 - u8 adsc; 949 - u8 adsq; 950 - u8 fruc; 951 - u8 key_spec[3]; 952 - } __attribute__((packed)) gdth_sense_data; 953 - 954 - /* MODE_SENSE data format */ 955 - typedef struct { 956 - struct { 957 - u8 data_length; 958 - u8 med_type; 959 - u8 dev_par; 960 - u8 bd_length; 961 - } __attribute__((packed)) hd; 962 - struct { 963 - u8 dens_code; 964 - u8 block_count[3]; 965 - u8 reserved; 966 - u8 block_length[3]; 967 - } __attribute__((packed)) bd; 968 - } __attribute__((packed)) gdth_modep_data; 969 - 970 - /* stack frame */ 971 - typedef struct { 972 - unsigned long b[10]; /* 32/64 bit compiler ! */ 973 - } __attribute__((packed)) gdth_stackframe; 974 - 975 - 976 - /* function prototyping */ 977 - 978 - int gdth_show_info(struct seq_file *, struct Scsi_Host *); 979 - int gdth_set_info(struct Scsi_Host *, char *, int); 980 - 981 - #endif
-251
drivers/scsi/gdth_ioctl.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _GDTH_IOCTL_H 3 - #define _GDTH_IOCTL_H 4 - 5 - /* gdth_ioctl.h 6 - * $Id: gdth_ioctl.h,v 1.14 2004/02/19 15:43:15 achim Exp $ 7 - */ 8 - 9 - /* IOCTLs */ 10 - #define GDTIOCTL_MASK ('J'<<8) 11 - #define GDTIOCTL_GENERAL (GDTIOCTL_MASK | 0) /* general IOCTL */ 12 - #define GDTIOCTL_DRVERS (GDTIOCTL_MASK | 1) /* get driver version */ 13 - #define GDTIOCTL_CTRTYPE (GDTIOCTL_MASK | 2) /* get controller type */ 14 - #define GDTIOCTL_OSVERS (GDTIOCTL_MASK | 3) /* get OS version */ 15 - #define GDTIOCTL_HDRLIST (GDTIOCTL_MASK | 4) /* get host drive list */ 16 - #define GDTIOCTL_CTRCNT (GDTIOCTL_MASK | 5) /* get controller count */ 17 - #define GDTIOCTL_LOCKDRV (GDTIOCTL_MASK | 6) /* lock host drive */ 18 - #define GDTIOCTL_LOCKCHN (GDTIOCTL_MASK | 7) /* lock channel */ 19 - #define GDTIOCTL_EVENT (GDTIOCTL_MASK | 8) /* read controller events */ 20 - #define GDTIOCTL_SCSI (GDTIOCTL_MASK | 9) /* SCSI command */ 21 - #define GDTIOCTL_RESET_BUS (GDTIOCTL_MASK |10) /* reset SCSI bus */ 22 - #define GDTIOCTL_RESCAN (GDTIOCTL_MASK |11) /* rescan host drives */ 23 - #define GDTIOCTL_RESET_DRV (GDTIOCTL_MASK |12) /* reset (remote) drv. res. */ 24 - 25 - #define GDTIOCTL_MAGIC 0xaffe0004 26 - #define EVENT_SIZE 294 27 - #define GDTH_MAXSG 32 /* max. s/g elements */ 28 - 29 - #define MAX_LDRIVES 255 /* max. log. drive count */ 30 - #define MAX_HDRIVES MAX_LDRIVES /* max. host drive count */ 31 - 32 - /* scatter/gather element */ 33 - typedef struct { 34 - u32 sg_ptr; /* address */ 35 - u32 sg_len; /* length */ 36 - } __attribute__((packed)) gdth_sg_str; 37 - 38 - /* scatter/gather element - 64bit addresses */ 39 - typedef struct { 40 - u64 sg_ptr; /* address */ 41 - u32 sg_len; /* length */ 42 - } __attribute__((packed)) gdth_sg64_str; 43 - 44 - /* command structure */ 45 - typedef struct { 46 - u32 BoardNode; /* board node (always 0) */ 47 - u32 CommandIndex; /* command number */ 48 - u16 OpCode; /* the command (READ,..) */ 49 - union { 50 - struct { 51 - u16 DeviceNo; /* number of cache drive */ 52 - u32 BlockNo; /* block number */ 53 - u32 BlockCnt; /* block count */ 54 - u32 DestAddr; /* dest. addr. (if s/g: -1) */ 55 - u32 sg_canz; /* s/g element count */ 56 - gdth_sg_str sg_lst[GDTH_MAXSG]; /* s/g list */ 57 - } __attribute__((packed)) cache; /* cache service cmd. str. */ 58 - struct { 59 - u16 DeviceNo; /* number of cache drive */ 60 - u64 BlockNo; /* block number */ 61 - u32 BlockCnt; /* block count */ 62 - u64 DestAddr; /* dest. addr. (if s/g: -1) */ 63 - u32 sg_canz; /* s/g element count */ 64 - gdth_sg64_str sg_lst[GDTH_MAXSG]; /* s/g list */ 65 - } __attribute__((packed)) cache64; /* cache service cmd. str. */ 66 - struct { 67 - u16 param_size; /* size of p_param buffer */ 68 - u32 subfunc; /* IOCTL function */ 69 - u32 channel; /* device */ 70 - u64 p_param; /* buffer */ 71 - } __attribute__((packed)) ioctl; /* IOCTL command structure */ 72 - struct { 73 - u16 reserved; 74 - union { 75 - struct { 76 - u32 msg_handle; /* message handle */ 77 - u64 msg_addr; /* message buffer address */ 78 - } __attribute__((packed)) msg; 79 - u8 data[12]; /* buffer for rtc data, ... */ 80 - } su; 81 - } __attribute__((packed)) screen; /* screen service cmd. str. */ 82 - struct { 83 - u16 reserved; 84 - u32 direction; /* data direction */ 85 - u32 mdisc_time; /* disc. time (0: no timeout)*/ 86 - u32 mcon_time; /* connect time(0: no to.) */ 87 - u32 sdata; /* dest. addr. (if s/g: -1) */ 88 - u32 sdlen; /* data length (bytes) */ 89 - u32 clen; /* SCSI cmd. length(6,10,12) */ 90 - u8 cmd[12]; /* SCSI command */ 91 - u8 target; /* target ID */ 92 - u8 lun; /* LUN */ 93 - u8 bus; /* SCSI bus number */ 94 - u8 priority; /* only 0 used */ 95 - u32 sense_len; /* sense data length */ 96 - u32 sense_data; /* sense data addr. */ 97 - u32 link_p; /* linked cmds (not supp.) */ 98 - u32 sg_ranz; /* s/g element count */ 99 - gdth_sg_str sg_lst[GDTH_MAXSG]; /* s/g list */ 100 - } __attribute__((packed)) raw; /* raw service cmd. struct. */ 101 - struct { 102 - u16 reserved; 103 - u32 direction; /* data direction */ 104 - u32 mdisc_time; /* disc. time (0: no timeout)*/ 105 - u32 mcon_time; /* connect time(0: no to.) */ 106 - u64 sdata; /* dest. addr. (if s/g: -1) */ 107 - u32 sdlen; /* data length (bytes) */ 108 - u32 clen; /* SCSI cmd. length(6,..,16) */ 109 - u8 cmd[16]; /* SCSI command */ 110 - u8 target; /* target ID */ 111 - u8 lun; /* LUN */ 112 - u8 bus; /* SCSI bus number */ 113 - u8 priority; /* only 0 used */ 114 - u32 sense_len; /* sense data length */ 115 - u64 sense_data; /* sense data addr. */ 116 - u32 sg_ranz; /* s/g element count */ 117 - gdth_sg64_str sg_lst[GDTH_MAXSG]; /* s/g list */ 118 - } __attribute__((packed)) raw64; /* raw service cmd. struct. */ 119 - } u; 120 - /* additional variables */ 121 - u8 Service; /* controller service */ 122 - u8 reserved; 123 - u16 Status; /* command result */ 124 - u32 Info; /* additional information */ 125 - void *RequestBuffer; /* request buffer */ 126 - } __attribute__((packed)) gdth_cmd_str; 127 - 128 - /* controller event structure */ 129 - #define ES_ASYNC 1 130 - #define ES_DRIVER 2 131 - #define ES_TEST 3 132 - #define ES_SYNC 4 133 - typedef struct { 134 - u16 size; /* size of structure */ 135 - union { 136 - char stream[16]; 137 - struct { 138 - u16 ionode; 139 - u16 service; 140 - u32 index; 141 - } __attribute__((packed)) driver; 142 - struct { 143 - u16 ionode; 144 - u16 service; 145 - u16 status; 146 - u32 info; 147 - u8 scsi_coord[3]; 148 - } __attribute__((packed)) async; 149 - struct { 150 - u16 ionode; 151 - u16 service; 152 - u16 status; 153 - u32 info; 154 - u16 hostdrive; 155 - u8 scsi_coord[3]; 156 - u8 sense_key; 157 - } __attribute__((packed)) sync; 158 - struct { 159 - u32 l1, l2, l3, l4; 160 - } __attribute__((packed)) test; 161 - } eu; 162 - u32 severity; 163 - u8 event_string[256]; 164 - } __attribute__((packed)) gdth_evt_data; 165 - 166 - typedef struct { 167 - u32 first_stamp; 168 - u32 last_stamp; 169 - u16 same_count; 170 - u16 event_source; 171 - u16 event_idx; 172 - u8 application; 173 - u8 reserved; 174 - gdth_evt_data event_data; 175 - } __attribute__((packed)) gdth_evt_str; 176 - 177 - /* GDTIOCTL_GENERAL */ 178 - typedef struct { 179 - u16 ionode; /* controller number */ 180 - u16 timeout; /* timeout */ 181 - u32 info; /* error info */ 182 - u16 status; /* status */ 183 - unsigned long data_len; /* data buffer size */ 184 - unsigned long sense_len; /* sense buffer size */ 185 - gdth_cmd_str command; /* command */ 186 - } gdth_ioctl_general; 187 - 188 - /* GDTIOCTL_LOCKDRV */ 189 - typedef struct { 190 - u16 ionode; /* controller number */ 191 - u8 lock; /* lock/unlock */ 192 - u8 drive_cnt; /* drive count */ 193 - u16 drives[MAX_HDRIVES]; /* drives */ 194 - } gdth_ioctl_lockdrv; 195 - 196 - /* GDTIOCTL_LOCKCHN */ 197 - typedef struct { 198 - u16 ionode; /* controller number */ 199 - u8 lock; /* lock/unlock */ 200 - u8 channel; /* channel */ 201 - } gdth_ioctl_lockchn; 202 - 203 - /* GDTIOCTL_OSVERS */ 204 - typedef struct { 205 - u8 version; /* OS version */ 206 - u8 subversion; /* OS subversion */ 207 - u16 revision; /* revision */ 208 - } gdth_ioctl_osvers; 209 - 210 - /* GDTIOCTL_CTRTYPE */ 211 - typedef struct { 212 - u16 ionode; /* controller number */ 213 - u8 type; /* controller type */ 214 - u16 info; /* slot etc. */ 215 - u16 oem_id; /* OEM ID */ 216 - u16 bios_ver; /* not used */ 217 - u16 access; /* not used */ 218 - u16 ext_type; /* extended type */ 219 - u16 device_id; /* device ID */ 220 - u16 sub_device_id; /* sub device ID */ 221 - } gdth_ioctl_ctrtype; 222 - 223 - /* GDTIOCTL_EVENT */ 224 - typedef struct { 225 - u16 ionode; 226 - int erase; /* erase event? */ 227 - int handle; /* event handle */ 228 - gdth_evt_str event; 229 - } gdth_ioctl_event; 230 - 231 - /* GDTIOCTL_RESCAN/GDTIOCTL_HDRLIST */ 232 - typedef struct { 233 - u16 ionode; /* controller number */ 234 - u8 flag; /* add/remove */ 235 - u16 hdr_no; /* drive no. */ 236 - struct { 237 - u8 bus; /* SCSI bus */ 238 - u8 target; /* target ID */ 239 - u8 lun; /* LUN */ 240 - u8 cluster_type; /* cluster properties */ 241 - } hdr_list[MAX_HDRIVES]; /* index is host drive number */ 242 - } gdth_ioctl_rescan; 243 - 244 - /* GDTIOCTL_RESET_BUS/GDTIOCTL_RESET_DRV */ 245 - typedef struct { 246 - u16 ionode; /* controller number */ 247 - u16 number; /* bus/host drive number */ 248 - u16 status; /* status */ 249 - } gdth_ioctl_reset; 250 - 251 - #endif
-586
drivers/scsi/gdth_proc.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* gdth_proc.c 3 - * $Id: gdth_proc.c,v 1.43 2006/01/11 16:15:00 achim Exp $ 4 - */ 5 - 6 - #include <linux/completion.h> 7 - #include <linux/slab.h> 8 - 9 - int gdth_set_info(struct Scsi_Host *host, char *buffer, int length) 10 - { 11 - gdth_ha_str *ha = shost_priv(host); 12 - int ret_val = -EINVAL; 13 - 14 - TRACE2(("gdth_set_info() ha %d\n",ha->hanum,)); 15 - 16 - if (length >= 4) { 17 - if (strncmp(buffer,"gdth",4) == 0) { 18 - buffer += 5; 19 - length -= 5; 20 - ret_val = gdth_set_asc_info(host, buffer, length, ha); 21 - } 22 - } 23 - 24 - return ret_val; 25 - } 26 - 27 - static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer, 28 - int length, gdth_ha_str *ha) 29 - { 30 - int orig_length, drive, wb_mode; 31 - int i, found; 32 - gdth_cmd_str gdtcmd; 33 - gdth_cpar_str *pcpar; 34 - 35 - char cmnd[MAX_COMMAND_SIZE]; 36 - memset(cmnd, 0xff, 12); 37 - memset(&gdtcmd, 0, sizeof(gdth_cmd_str)); 38 - 39 - TRACE2(("gdth_set_asc_info() ha %d\n",ha->hanum)); 40 - orig_length = length + 5; 41 - drive = -1; 42 - wb_mode = 0; 43 - found = FALSE; 44 - 45 - if (length >= 5 && strncmp(buffer,"flush",5)==0) { 46 - buffer += 6; 47 - length -= 6; 48 - if (length && *buffer>='0' && *buffer<='9') { 49 - drive = (int)(*buffer-'0'); 50 - ++buffer; --length; 51 - if (length && *buffer>='0' && *buffer<='9') { 52 - drive = drive*10 + (int)(*buffer-'0'); 53 - ++buffer; --length; 54 - } 55 - printk("GDT: Flushing host drive %d .. ",drive); 56 - } else { 57 - printk("GDT: Flushing all host drives .. "); 58 - } 59 - for (i = 0; i < MAX_HDRIVES; ++i) { 60 - if (ha->hdr[i].present) { 61 - if (drive != -1 && i != drive) 62 - continue; 63 - found = TRUE; 64 - gdtcmd.Service = CACHESERVICE; 65 - gdtcmd.OpCode = GDT_FLUSH; 66 - if (ha->cache_feat & GDT_64BIT) { 67 - gdtcmd.u.cache64.DeviceNo = i; 68 - gdtcmd.u.cache64.BlockNo = 1; 69 - } else { 70 - gdtcmd.u.cache.DeviceNo = i; 71 - gdtcmd.u.cache.BlockNo = 1; 72 - } 73 - 74 - gdth_execute(host, &gdtcmd, cmnd, 30, NULL); 75 - } 76 - } 77 - if (!found) 78 - printk("\nNo host drive found !\n"); 79 - else 80 - printk("Done.\n"); 81 - return(orig_length); 82 - } 83 - 84 - if (length >= 7 && strncmp(buffer,"wbp_off",7)==0) { 85 - buffer += 8; 86 - length -= 8; 87 - printk("GDT: Disabling write back permanently .. "); 88 - wb_mode = 1; 89 - } else if (length >= 6 && strncmp(buffer,"wbp_on",6)==0) { 90 - buffer += 7; 91 - length -= 7; 92 - printk("GDT: Enabling write back permanently .. "); 93 - wb_mode = 2; 94 - } else if (length >= 6 && strncmp(buffer,"wb_off",6)==0) { 95 - buffer += 7; 96 - length -= 7; 97 - printk("GDT: Disabling write back commands .. "); 98 - if (ha->cache_feat & GDT_WR_THROUGH) { 99 - gdth_write_through = TRUE; 100 - printk("Done.\n"); 101 - } else { 102 - printk("Not supported !\n"); 103 - } 104 - return(orig_length); 105 - } else if (length >= 5 && strncmp(buffer,"wb_on",5)==0) { 106 - buffer += 6; 107 - length -= 6; 108 - printk("GDT: Enabling write back commands .. "); 109 - gdth_write_through = FALSE; 110 - printk("Done.\n"); 111 - return(orig_length); 112 - } 113 - 114 - if (wb_mode) { 115 - unsigned long flags; 116 - 117 - BUILD_BUG_ON(sizeof(gdth_cpar_str) > GDTH_SCRATCH); 118 - 119 - spin_lock_irqsave(&ha->smp_lock, flags); 120 - if (ha->scratch_busy) { 121 - spin_unlock_irqrestore(&ha->smp_lock, flags); 122 - return -EBUSY; 123 - } 124 - ha->scratch_busy = TRUE; 125 - spin_unlock_irqrestore(&ha->smp_lock, flags); 126 - 127 - pcpar = (gdth_cpar_str *)ha->pscratch; 128 - memcpy( pcpar, &ha->cpar, sizeof(gdth_cpar_str) ); 129 - gdtcmd.Service = CACHESERVICE; 130 - gdtcmd.OpCode = GDT_IOCTL; 131 - gdtcmd.u.ioctl.p_param = ha->scratch_phys; 132 - gdtcmd.u.ioctl.param_size = sizeof(gdth_cpar_str); 133 - gdtcmd.u.ioctl.subfunc = CACHE_CONFIG; 134 - gdtcmd.u.ioctl.channel = INVALID_CHANNEL; 135 - pcpar->write_back = wb_mode==1 ? 0:1; 136 - 137 - gdth_execute(host, &gdtcmd, cmnd, 30, NULL); 138 - 139 - spin_lock_irqsave(&ha->smp_lock, flags); 140 - ha->scratch_busy = FALSE; 141 - spin_unlock_irqrestore(&ha->smp_lock, flags); 142 - 143 - printk("Done.\n"); 144 - return(orig_length); 145 - } 146 - 147 - printk("GDT: Unknown command: %s Length: %d\n",buffer,length); 148 - return(-EINVAL); 149 - } 150 - 151 - int gdth_show_info(struct seq_file *m, struct Scsi_Host *host) 152 - { 153 - gdth_ha_str *ha = shost_priv(host); 154 - int hlen; 155 - int id, i, j, k, sec, flag; 156 - int no_mdrv = 0, drv_no, is_mirr; 157 - u32 cnt; 158 - dma_addr_t paddr; 159 - int rc = -ENOMEM; 160 - 161 - gdth_cmd_str *gdtcmd; 162 - gdth_evt_str *estr; 163 - char hrec[277]; 164 - 165 - char *buf; 166 - gdth_dskstat_str *pds; 167 - gdth_diskinfo_str *pdi; 168 - gdth_arrayinf_str *pai; 169 - gdth_defcnt_str *pdef; 170 - gdth_cdrinfo_str *pcdi; 171 - gdth_hget_str *phg; 172 - char cmnd[MAX_COMMAND_SIZE]; 173 - 174 - gdtcmd = kmalloc(sizeof(*gdtcmd), GFP_KERNEL); 175 - estr = kmalloc(sizeof(*estr), GFP_KERNEL); 176 - if (!gdtcmd || !estr) 177 - goto free_fail; 178 - 179 - memset(cmnd, 0xff, 12); 180 - memset(gdtcmd, 0, sizeof(gdth_cmd_str)); 181 - 182 - TRACE2(("gdth_get_info() ha %d\n",ha->hanum)); 183 - 184 - 185 - /* request is i.e. "cat /proc/scsi/gdth/0" */ 186 - /* format: %-15s\t%-10s\t%-15s\t%s */ 187 - /* driver parameters */ 188 - seq_puts(m, "Driver Parameters:\n"); 189 - if (reserve_list[0] == 0xff) 190 - strcpy(hrec, "--"); 191 - else { 192 - hlen = sprintf(hrec, "%d", reserve_list[0]); 193 - for (i = 1; i < MAX_RES_ARGS; i++) { 194 - if (reserve_list[i] == 0xff) 195 - break; 196 - hlen += scnprintf(hrec + hlen, 161 - hlen, ",%d", reserve_list[i]); 197 - } 198 - } 199 - seq_printf(m, 200 - " reserve_mode: \t%d \treserve_list: \t%s\n", 201 - reserve_mode, hrec); 202 - seq_printf(m, 203 - " max_ids: \t%-3d \thdr_channel: \t%d\n", 204 - max_ids, hdr_channel); 205 - 206 - /* controller information */ 207 - seq_puts(m, "\nDisk Array Controller Information:\n"); 208 - seq_printf(m, 209 - " Number: \t%d \tName: \t%s\n", 210 - ha->hanum, ha->binfo.type_string); 211 - 212 - seq_printf(m, 213 - " Driver Ver.: \t%-10s\tFirmware Ver.: \t", 214 - GDTH_VERSION_STR); 215 - if (ha->more_proc) 216 - seq_printf(m, "%d.%02d.%02d-%c%03X\n", 217 - (u8)(ha->binfo.upd_fw_ver>>24), 218 - (u8)(ha->binfo.upd_fw_ver>>16), 219 - (u8)(ha->binfo.upd_fw_ver), 220 - ha->bfeat.raid ? 'R':'N', 221 - ha->binfo.upd_revision); 222 - else 223 - seq_printf(m, "%d.%02d\n", (u8)(ha->cpar.version>>8), 224 - (u8)(ha->cpar.version)); 225 - 226 - if (ha->more_proc) 227 - /* more information: 1. about controller */ 228 - seq_printf(m, 229 - " Serial No.: \t0x%8X\tCache RAM size:\t%d KB\n", 230 - ha->binfo.ser_no, ha->binfo.memsize / 1024); 231 - 232 - if (ha->more_proc) { 233 - size_t size = max_t(size_t, GDTH_SCRATCH, sizeof(gdth_hget_str)); 234 - 235 - /* more information: 2. about physical devices */ 236 - seq_puts(m, "\nPhysical Devices:"); 237 - flag = FALSE; 238 - 239 - buf = dma_alloc_coherent(&ha->pdev->dev, size, &paddr, GFP_KERNEL); 240 - if (!buf) 241 - goto stop_output; 242 - for (i = 0; i < ha->bus_cnt; ++i) { 243 - /* 2.a statistics (and retries/reassigns) */ 244 - TRACE2(("pdr_statistics() chn %d\n",i)); 245 - pds = (gdth_dskstat_str *)(buf + GDTH_SCRATCH/4); 246 - gdtcmd->Service = CACHESERVICE; 247 - gdtcmd->OpCode = GDT_IOCTL; 248 - gdtcmd->u.ioctl.p_param = paddr + GDTH_SCRATCH/4; 249 - gdtcmd->u.ioctl.param_size = 3*GDTH_SCRATCH/4; 250 - gdtcmd->u.ioctl.subfunc = DSK_STATISTICS | L_CTRL_PATTERN; 251 - gdtcmd->u.ioctl.channel = ha->raw[i].address | INVALID_CHANNEL; 252 - pds->bid = ha->raw[i].local_no; 253 - pds->first = 0; 254 - pds->entries = ha->raw[i].pdev_cnt; 255 - cnt = (3*GDTH_SCRATCH/4 - 5 * sizeof(u32)) / 256 - sizeof(pds->list[0]); 257 - if (pds->entries > cnt) 258 - pds->entries = cnt; 259 - 260 - if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) != S_OK) 261 - pds->count = 0; 262 - 263 - /* other IOCTLs must fit into area GDTH_SCRATCH/4 */ 264 - for (j = 0; j < ha->raw[i].pdev_cnt; ++j) { 265 - /* 2.b drive info */ 266 - TRACE2(("scsi_drv_info() chn %d dev %d\n", 267 - i, ha->raw[i].id_list[j])); 268 - pdi = (gdth_diskinfo_str *)buf; 269 - gdtcmd->Service = CACHESERVICE; 270 - gdtcmd->OpCode = GDT_IOCTL; 271 - gdtcmd->u.ioctl.p_param = paddr; 272 - gdtcmd->u.ioctl.param_size = sizeof(gdth_diskinfo_str); 273 - gdtcmd->u.ioctl.subfunc = SCSI_DR_INFO | L_CTRL_PATTERN; 274 - gdtcmd->u.ioctl.channel = 275 - ha->raw[i].address | ha->raw[i].id_list[j]; 276 - 277 - if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) { 278 - strncpy(hrec,pdi->vendor,8); 279 - strncpy(hrec+8,pdi->product,16); 280 - strncpy(hrec+24,pdi->revision,4); 281 - hrec[28] = 0; 282 - seq_printf(m, 283 - "\n Chn/ID/LUN: \t%c/%02d/%d \tName: \t%s\n", 284 - 'A'+i,pdi->target_id,pdi->lun,hrec); 285 - flag = TRUE; 286 - pdi->no_ldrive &= 0xffff; 287 - if (pdi->no_ldrive == 0xffff) 288 - strcpy(hrec,"--"); 289 - else 290 - sprintf(hrec,"%d",pdi->no_ldrive); 291 - seq_printf(m, 292 - " Capacity [MB]:\t%-6d \tTo Log. Drive: \t%s\n", 293 - pdi->blkcnt/(1024*1024/pdi->blksize), 294 - hrec); 295 - } else { 296 - pdi->devtype = 0xff; 297 - } 298 - 299 - if (pdi->devtype == 0) { 300 - /* search retries/reassigns */ 301 - for (k = 0; k < pds->count; ++k) { 302 - if (pds->list[k].tid == pdi->target_id && 303 - pds->list[k].lun == pdi->lun) { 304 - seq_printf(m, 305 - " Retries: \t%-6d \tReassigns: \t%d\n", 306 - pds->list[k].retries, 307 - pds->list[k].reassigns); 308 - break; 309 - } 310 - } 311 - /* 2.c grown defects */ 312 - TRACE2(("scsi_drv_defcnt() chn %d dev %d\n", 313 - i, ha->raw[i].id_list[j])); 314 - pdef = (gdth_defcnt_str *)buf; 315 - gdtcmd->Service = CACHESERVICE; 316 - gdtcmd->OpCode = GDT_IOCTL; 317 - gdtcmd->u.ioctl.p_param = paddr; 318 - gdtcmd->u.ioctl.param_size = sizeof(gdth_defcnt_str); 319 - gdtcmd->u.ioctl.subfunc = SCSI_DEF_CNT | L_CTRL_PATTERN; 320 - gdtcmd->u.ioctl.channel = 321 - ha->raw[i].address | ha->raw[i].id_list[j]; 322 - pdef->sddc_type = 0x08; 323 - 324 - if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) { 325 - seq_printf(m, 326 - " Grown Defects:\t%d\n", 327 - pdef->sddc_cnt); 328 - } 329 - } 330 - } 331 - } 332 - 333 - if (!flag) 334 - seq_puts(m, "\n --\n"); 335 - 336 - /* 3. about logical drives */ 337 - seq_puts(m, "\nLogical Drives:"); 338 - flag = FALSE; 339 - 340 - for (i = 0; i < MAX_LDRIVES; ++i) { 341 - if (!ha->hdr[i].is_logdrv) 342 - continue; 343 - drv_no = i; 344 - j = k = 0; 345 - is_mirr = FALSE; 346 - do { 347 - /* 3.a log. drive info */ 348 - TRACE2(("cache_drv_info() drive no %d\n",drv_no)); 349 - pcdi = (gdth_cdrinfo_str *)buf; 350 - gdtcmd->Service = CACHESERVICE; 351 - gdtcmd->OpCode = GDT_IOCTL; 352 - gdtcmd->u.ioctl.p_param = paddr; 353 - gdtcmd->u.ioctl.param_size = sizeof(gdth_cdrinfo_str); 354 - gdtcmd->u.ioctl.subfunc = CACHE_DRV_INFO; 355 - gdtcmd->u.ioctl.channel = drv_no; 356 - if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) != S_OK) 357 - break; 358 - pcdi->ld_dtype >>= 16; 359 - j++; 360 - if (pcdi->ld_dtype > 2) { 361 - strcpy(hrec, "missing"); 362 - } else if (pcdi->ld_error & 1) { 363 - strcpy(hrec, "fault"); 364 - } else if (pcdi->ld_error & 2) { 365 - strcpy(hrec, "invalid"); 366 - k++; j--; 367 - } else { 368 - strcpy(hrec, "ok"); 369 - } 370 - 371 - if (drv_no == i) { 372 - seq_printf(m, 373 - "\n Number: \t%-2d \tStatus: \t%s\n", 374 - drv_no, hrec); 375 - flag = TRUE; 376 - no_mdrv = pcdi->cd_ldcnt; 377 - if (no_mdrv > 1 || pcdi->ld_slave != -1) { 378 - is_mirr = TRUE; 379 - strcpy(hrec, "RAID-1"); 380 - } else if (pcdi->ld_dtype == 0) { 381 - strcpy(hrec, "Disk"); 382 - } else if (pcdi->ld_dtype == 1) { 383 - strcpy(hrec, "RAID-0"); 384 - } else if (pcdi->ld_dtype == 2) { 385 - strcpy(hrec, "Chain"); 386 - } else { 387 - strcpy(hrec, "???"); 388 - } 389 - seq_printf(m, 390 - " Capacity [MB]:\t%-6d \tType: \t%s\n", 391 - pcdi->ld_blkcnt/(1024*1024/pcdi->ld_blksize), 392 - hrec); 393 - } else { 394 - seq_printf(m, 395 - " Slave Number: \t%-2d \tStatus: \t%s\n", 396 - drv_no & 0x7fff, hrec); 397 - } 398 - drv_no = pcdi->ld_slave; 399 - } while (drv_no != -1); 400 - 401 - if (is_mirr) 402 - seq_printf(m, 403 - " Missing Drv.: \t%-2d \tInvalid Drv.: \t%d\n", 404 - no_mdrv - j - k, k); 405 - 406 - if (!ha->hdr[i].is_arraydrv) 407 - strcpy(hrec, "--"); 408 - else 409 - sprintf(hrec, "%d", ha->hdr[i].master_no); 410 - seq_printf(m, 411 - " To Array Drv.:\t%s\n", hrec); 412 - } 413 - 414 - if (!flag) 415 - seq_puts(m, "\n --\n"); 416 - 417 - /* 4. about array drives */ 418 - seq_puts(m, "\nArray Drives:"); 419 - flag = FALSE; 420 - 421 - for (i = 0; i < MAX_LDRIVES; ++i) { 422 - if (!(ha->hdr[i].is_arraydrv && ha->hdr[i].is_master)) 423 - continue; 424 - /* 4.a array drive info */ 425 - TRACE2(("array_info() drive no %d\n",i)); 426 - pai = (gdth_arrayinf_str *)buf; 427 - gdtcmd->Service = CACHESERVICE; 428 - gdtcmd->OpCode = GDT_IOCTL; 429 - gdtcmd->u.ioctl.p_param = paddr; 430 - gdtcmd->u.ioctl.param_size = sizeof(gdth_arrayinf_str); 431 - gdtcmd->u.ioctl.subfunc = ARRAY_INFO | LA_CTRL_PATTERN; 432 - gdtcmd->u.ioctl.channel = i; 433 - if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) { 434 - if (pai->ai_state == 0) 435 - strcpy(hrec, "idle"); 436 - else if (pai->ai_state == 2) 437 - strcpy(hrec, "build"); 438 - else if (pai->ai_state == 4) 439 - strcpy(hrec, "ready"); 440 - else if (pai->ai_state == 6) 441 - strcpy(hrec, "fail"); 442 - else if (pai->ai_state == 8 || pai->ai_state == 10) 443 - strcpy(hrec, "rebuild"); 444 - else 445 - strcpy(hrec, "error"); 446 - if (pai->ai_ext_state & 0x10) 447 - strcat(hrec, "/expand"); 448 - else if (pai->ai_ext_state & 0x1) 449 - strcat(hrec, "/patch"); 450 - seq_printf(m, 451 - "\n Number: \t%-2d \tStatus: \t%s\n", 452 - i,hrec); 453 - flag = TRUE; 454 - 455 - if (pai->ai_type == 0) 456 - strcpy(hrec, "RAID-0"); 457 - else if (pai->ai_type == 4) 458 - strcpy(hrec, "RAID-4"); 459 - else if (pai->ai_type == 5) 460 - strcpy(hrec, "RAID-5"); 461 - else 462 - strcpy(hrec, "RAID-10"); 463 - seq_printf(m, 464 - " Capacity [MB]:\t%-6d \tType: \t%s\n", 465 - pai->ai_size/(1024*1024/pai->ai_secsize), 466 - hrec); 467 - } 468 - } 469 - 470 - if (!flag) 471 - seq_puts(m, "\n --\n"); 472 - 473 - /* 5. about host drives */ 474 - seq_puts(m, "\nHost Drives:"); 475 - flag = FALSE; 476 - 477 - for (i = 0; i < MAX_LDRIVES; ++i) { 478 - if (!ha->hdr[i].is_logdrv || 479 - (ha->hdr[i].is_arraydrv && !ha->hdr[i].is_master)) 480 - continue; 481 - /* 5.a get host drive list */ 482 - TRACE2(("host_get() drv_no %d\n",i)); 483 - phg = (gdth_hget_str *)buf; 484 - gdtcmd->Service = CACHESERVICE; 485 - gdtcmd->OpCode = GDT_IOCTL; 486 - gdtcmd->u.ioctl.p_param = paddr; 487 - gdtcmd->u.ioctl.param_size = sizeof(gdth_hget_str); 488 - gdtcmd->u.ioctl.subfunc = HOST_GET | LA_CTRL_PATTERN; 489 - gdtcmd->u.ioctl.channel = i; 490 - phg->entries = MAX_HDRIVES; 491 - phg->offset = GDTOFFSOF(gdth_hget_str, entry[0]); 492 - if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) { 493 - ha->hdr[i].ldr_no = i; 494 - ha->hdr[i].rw_attribs = 0; 495 - ha->hdr[i].start_sec = 0; 496 - } else { 497 - for (j = 0; j < phg->entries; ++j) { 498 - k = phg->entry[j].host_drive; 499 - if (k >= MAX_LDRIVES) 500 - continue; 501 - ha->hdr[k].ldr_no = phg->entry[j].log_drive; 502 - ha->hdr[k].rw_attribs = phg->entry[j].rw_attribs; 503 - ha->hdr[k].start_sec = phg->entry[j].start_sec; 504 - } 505 - } 506 - } 507 - dma_free_coherent(&ha->pdev->dev, size, buf, paddr); 508 - 509 - for (i = 0; i < MAX_HDRIVES; ++i) { 510 - if (!(ha->hdr[i].present)) 511 - continue; 512 - 513 - seq_printf(m, 514 - "\n Number: \t%-2d \tArr/Log. Drive:\t%d\n", 515 - i, ha->hdr[i].ldr_no); 516 - flag = TRUE; 517 - 518 - seq_printf(m, 519 - " Capacity [MB]:\t%-6d \tStart Sector: \t%d\n", 520 - (u32)(ha->hdr[i].size/2048), ha->hdr[i].start_sec); 521 - } 522 - 523 - if (!flag) 524 - seq_puts(m, "\n --\n"); 525 - } 526 - 527 - /* controller events */ 528 - seq_puts(m, "\nController Events:\n"); 529 - 530 - for (id = -1;;) { 531 - id = gdth_read_event(ha, id, estr); 532 - if (estr->event_source == 0) 533 - break; 534 - if (estr->event_data.eu.driver.ionode == ha->hanum && 535 - estr->event_source == ES_ASYNC) { 536 - gdth_log_event(&estr->event_data, hrec); 537 - 538 - /* 539 - * Elapsed seconds subtraction with unsigned operands is 540 - * safe from wrap around in year 2106. Executes as: 541 - * operand a + (2's complement operand b) + 1 542 - */ 543 - 544 - sec = (int)((u32)ktime_get_real_seconds() - estr->first_stamp); 545 - if (sec < 0) sec = 0; 546 - seq_printf(m," date- %02d:%02d:%02d\t%s\n", 547 - sec/3600, sec%3600/60, sec%60, hrec); 548 - } 549 - if (id == -1) 550 - break; 551 - } 552 - stop_output: 553 - rc = 0; 554 - free_fail: 555 - kfree(gdtcmd); 556 - kfree(estr); 557 - return rc; 558 - } 559 - 560 - static void gdth_wait_completion(gdth_ha_str *ha, int busnum, int id) 561 - { 562 - unsigned long flags; 563 - int i; 564 - struct scsi_cmnd *scp; 565 - struct gdth_cmndinfo *cmndinfo; 566 - u8 b, t; 567 - 568 - spin_lock_irqsave(&ha->smp_lock, flags); 569 - 570 - for (i = 0; i < GDTH_MAXCMDS; ++i) { 571 - scp = ha->cmd_tab[i].cmnd; 572 - cmndinfo = gdth_cmnd_priv(scp); 573 - 574 - b = scp->device->channel; 575 - t = scp->device->id; 576 - if (!SPECIAL_SCP(scp) && t == (u8)id && 577 - b == (u8)busnum) { 578 - cmndinfo->wait_for_completion = 0; 579 - spin_unlock_irqrestore(&ha->smp_lock, flags); 580 - while (!cmndinfo->wait_for_completion) 581 - barrier(); 582 - spin_lock_irqsave(&ha->smp_lock, flags); 583 - } 584 - } 585 - spin_unlock_irqrestore(&ha->smp_lock, flags); 586 - }
-18
drivers/scsi/gdth_proc.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _GDTH_PROC_H 3 - #define _GDTH_PROC_H 4 - 5 - /* gdth_proc.h 6 - * $Id: gdth_proc.h,v 1.16 2004/01/14 13:09:01 achim Exp $ 7 - */ 8 - 9 - int gdth_execute(struct Scsi_Host *shost, gdth_cmd_str *gdtcmd, char *cmnd, 10 - int timeout, u32 *info); 11 - 12 - static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer, 13 - int length, gdth_ha_str *ha); 14 - 15 - static void gdth_wait_completion(gdth_ha_str *ha, int busnum, int id); 16 - 17 - #endif 18 -