2 * $Id: gdth_proc.c,v 1.43 2006/01/11 16:15:00 achim Exp $
5 #include <linux/completion.h>
7 int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t offset,int length,
12 TRACE2(("gdth_proc_info() length %d offs %d inout %d\n",
13 length,(int)offset,inout));
15 hanum = NUMDATA(host)->hanum;
16 busnum= NUMDATA(host)->busnum;
19 return(gdth_set_info(buffer,length,host,hanum,busnum));
21 return(gdth_get_info(buffer,start,offset,length,host,hanum,busnum));
24 static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host,
27 int ret_val = -EINVAL;
29 TRACE2(("gdth_set_info() ha %d bus %d\n",hanum,busnum));
32 if (strncmp(buffer,"gdth",4) == 0) {
35 ret_val = gdth_set_asc_info(host, buffer, length, hanum);
42 static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
45 int orig_length, drive, wb_mode;
52 char cmnd[MAX_COMMAND_SIZE];
53 memset(cmnd, 0xff, 12);
54 memset(&gdtcmd, 0, sizeof(gdth_cmd_str));
56 TRACE2(("gdth_set_asc_info() ha %d\n",hanum));
57 ha = HADATA(gdth_ctr_tab[hanum]);
58 orig_length = length + 5;
63 if (length >= 5 && strncmp(buffer,"flush",5)==0) {
66 if (length && *buffer>='0' && *buffer<='9') {
67 drive = (int)(*buffer-'0');
69 if (length && *buffer>='0' && *buffer<='9') {
70 drive = drive*10 + (int)(*buffer-'0');
73 printk("GDT: Flushing host drive %d .. ",drive);
75 printk("GDT: Flushing all host drives .. ");
77 for (i = 0; i < MAX_HDRIVES; ++i) {
78 if (ha->hdr[i].present) {
79 if (drive != -1 && i != drive)
82 gdtcmd.Service = CACHESERVICE;
83 gdtcmd.OpCode = GDT_FLUSH;
84 if (ha->cache_feat & GDT_64BIT) {
85 gdtcmd.u.cache64.DeviceNo = i;
86 gdtcmd.u.cache64.BlockNo = 1;
88 gdtcmd.u.cache.DeviceNo = i;
89 gdtcmd.u.cache.BlockNo = 1;
92 gdth_execute(host, &gdtcmd, cmnd, 30, NULL);
96 printk("\nNo host drive found !\n");
102 if (length >= 7 && strncmp(buffer,"wbp_off",7)==0) {
105 printk("GDT: Disabling write back permanently .. ");
107 } else if (length >= 6 && strncmp(buffer,"wbp_on",6)==0) {
110 printk("GDT: Enabling write back permanently .. ");
112 } else if (length >= 6 && strncmp(buffer,"wb_off",6)==0) {
115 printk("GDT: Disabling write back commands .. ");
116 if (ha->cache_feat & GDT_WR_THROUGH) {
117 gdth_write_through = TRUE;
120 printk("Not supported !\n");
123 } else if (length >= 5 && strncmp(buffer,"wb_on",5)==0) {
126 printk("GDT: Enabling write back commands .. ");
127 gdth_write_through = FALSE;
133 if (!gdth_ioctl_alloc(hanum, sizeof(gdth_cpar_str), TRUE, &paddr))
135 pcpar = (gdth_cpar_str *)ha->pscratch;
136 memcpy( pcpar, &ha->cpar, sizeof(gdth_cpar_str) );
137 gdtcmd.Service = CACHESERVICE;
138 gdtcmd.OpCode = GDT_IOCTL;
139 gdtcmd.u.ioctl.p_param = paddr;
140 gdtcmd.u.ioctl.param_size = sizeof(gdth_cpar_str);
141 gdtcmd.u.ioctl.subfunc = CACHE_CONFIG;
142 gdtcmd.u.ioctl.channel = INVALID_CHANNEL;
143 pcpar->write_back = wb_mode==1 ? 0:1;
145 gdth_execute(host, &gdtcmd, cmnd, 30, NULL);
147 gdth_ioctl_free(hanum, GDTH_SCRATCH, ha->pscratch, paddr);
152 printk("GDT: Unknown command: %s Length: %d\n",buffer,length);
156 static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
157 struct Scsi_Host *host,int hanum,int busnum)
159 int size = 0,len = 0;
160 off_t begin = 0,pos = 0;
162 int id, i, j, k, sec, flag;
163 int no_mdrv = 0, drv_no, is_mirr;
168 gdth_cmd_str *gdtcmd;
174 gdth_dskstat_str *pds;
175 gdth_diskinfo_str *pdi;
176 gdth_arrayinf_str *pai;
177 gdth_defcnt_str *pdef;
178 gdth_cdrinfo_str *pcdi;
180 char cmnd[MAX_COMMAND_SIZE];
182 gdtcmd = kmalloc(sizeof(*gdtcmd), GFP_KERNEL);
183 estr = kmalloc(sizeof(*estr), GFP_KERNEL);
184 if (!gdtcmd || !estr)
187 memset(cmnd, 0xff, 12);
188 memset(gdtcmd, 0, sizeof(gdth_cmd_str));
190 TRACE2(("gdth_get_info() ha %d bus %d\n",hanum,busnum));
191 ha = HADATA(gdth_ctr_tab[hanum]);
194 /* request is i.e. "cat /proc/scsi/gdth/0" */
195 /* format: %-15s\t%-10s\t%-15s\t%s */
196 /* driver parameters */
197 size = sprintf(buffer+len,"Driver Parameters:\n");
198 len += size; pos = begin + len;
199 if (reserve_list[0] == 0xff)
202 sprintf(hrec, "%d", reserve_list[0]);
203 for (i = 1; i < MAX_RES_ARGS; i++) {
204 if (reserve_list[i] == 0xff)
206 sprintf(hrec,"%s,%d", hrec, reserve_list[i]);
209 size = sprintf(buffer+len,
210 " reserve_mode: \t%d \treserve_list: \t%s\n",
212 len += size; pos = begin + len;
213 size = sprintf(buffer+len,
214 " max_ids: \t%-3d \thdr_channel: \t%d\n",
215 max_ids, hdr_channel);
216 len += size; pos = begin + len;
218 /* controller information */
219 size = sprintf(buffer+len,"\nDisk Array Controller Information:\n");
220 len += size; pos = begin + len;
222 sprintf(hrec, "%s (Bus %d)", ha->binfo.type_string, busnum);
224 strcpy(hrec, ha->binfo.type_string);
225 size = sprintf(buffer+len,
226 " Number: \t%d \tName: \t%s\n",
228 len += size; pos = begin + len;
231 sprintf(hrec, "%d.%02d.%02d-%c%03X",
232 (unchar)(ha->binfo.upd_fw_ver>>24),
233 (unchar)(ha->binfo.upd_fw_ver>>16),
234 (unchar)(ha->binfo.upd_fw_ver),
235 ha->bfeat.raid ? 'R':'N',
236 ha->binfo.upd_revision);
238 sprintf(hrec, "%d.%02d", (unchar)(ha->cpar.version>>8),
239 (unchar)(ha->cpar.version));
241 size = sprintf(buffer+len,
242 " Driver Ver.: \t%-10s\tFirmware Ver.: \t%s\n",
243 GDTH_VERSION_STR, hrec);
244 len += size; pos = begin + len;
247 /* more information: 1. about controller */
248 size = sprintf(buffer+len,
249 " Serial No.: \t0x%8X\tCache RAM size:\t%d KB\n",
250 ha->binfo.ser_no, ha->binfo.memsize / 1024);
251 len += size; pos = begin + len;
254 #ifdef GDTH_DMA_STATISTICS
255 /* controller statistics */
256 size = sprintf(buffer+len,"\nController Statistics:\n");
257 len += size; pos = begin + len;
258 size = sprintf(buffer+len,
259 " 32-bit DMA buffer:\t%lu\t64-bit DMA buffer:\t%lu\n",
260 ha->dma32_cnt, ha->dma64_cnt);
261 len += size; pos = begin + len;
268 if (pos > offset + length)
272 /* more information: 2. about physical devices */
273 size = sprintf(buffer+len,"\nPhysical Devices:");
274 len += size; pos = begin + len;
277 buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr);
280 for (i = 0; i < ha->bus_cnt; ++i) {
281 /* 2.a statistics (and retries/reassigns) */
282 TRACE2(("pdr_statistics() chn %d\n",i));
283 pds = (gdth_dskstat_str *)(buf + GDTH_SCRATCH/4);
284 gdtcmd->Service = CACHESERVICE;
285 gdtcmd->OpCode = GDT_IOCTL;
286 gdtcmd->u.ioctl.p_param = paddr + GDTH_SCRATCH/4;
287 gdtcmd->u.ioctl.param_size = 3*GDTH_SCRATCH/4;
288 gdtcmd->u.ioctl.subfunc = DSK_STATISTICS | L_CTRL_PATTERN;
289 gdtcmd->u.ioctl.channel = ha->raw[i].address | INVALID_CHANNEL;
290 pds->bid = ha->raw[i].local_no;
292 pds->entries = ha->raw[i].pdev_cnt;
293 cnt = (3*GDTH_SCRATCH/4 - 5 * sizeof(ulong32)) /
294 sizeof(pds->list[0]);
295 if (pds->entries > cnt)
298 if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) != S_OK)
301 /* other IOCTLs must fit into area GDTH_SCRATCH/4 */
302 for (j = 0; j < ha->raw[i].pdev_cnt; ++j) {
304 TRACE2(("scsi_drv_info() chn %d dev %d\n",
305 i, ha->raw[i].id_list[j]));
306 pdi = (gdth_diskinfo_str *)buf;
307 gdtcmd->Service = CACHESERVICE;
308 gdtcmd->OpCode = GDT_IOCTL;
309 gdtcmd->u.ioctl.p_param = paddr;
310 gdtcmd->u.ioctl.param_size = sizeof(gdth_diskinfo_str);
311 gdtcmd->u.ioctl.subfunc = SCSI_DR_INFO | L_CTRL_PATTERN;
312 gdtcmd->u.ioctl.channel =
313 ha->raw[i].address | ha->raw[i].id_list[j];
315 if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
316 strncpy(hrec,pdi->vendor,8);
317 strncpy(hrec+8,pdi->product,16);
318 strncpy(hrec+24,pdi->revision,4);
320 size = sprintf(buffer+len,
321 "\n Chn/ID/LUN: \t%c/%02d/%d \tName: \t%s\n",
322 'A'+i,pdi->target_id,pdi->lun,hrec);
323 len += size; pos = begin + len;
325 pdi->no_ldrive &= 0xffff;
326 if (pdi->no_ldrive == 0xffff)
329 sprintf(hrec,"%d",pdi->no_ldrive);
330 size = sprintf(buffer+len,
331 " Capacity [MB]:\t%-6d \tTo Log. Drive: \t%s\n",
332 pdi->blkcnt/(1024*1024/pdi->blksize),
334 len += size; pos = begin + len;
339 if (pdi->devtype == 0) {
340 /* search retries/reassigns */
341 for (k = 0; k < pds->count; ++k) {
342 if (pds->list[k].tid == pdi->target_id &&
343 pds->list[k].lun == pdi->lun) {
344 size = sprintf(buffer+len,
345 " Retries: \t%-6d \tReassigns: \t%d\n",
346 pds->list[k].retries,
347 pds->list[k].reassigns);
348 len += size; pos = begin + len;
352 /* 2.c grown defects */
353 TRACE2(("scsi_drv_defcnt() chn %d dev %d\n",
354 i, ha->raw[i].id_list[j]));
355 pdef = (gdth_defcnt_str *)buf;
356 gdtcmd->Service = CACHESERVICE;
357 gdtcmd->OpCode = GDT_IOCTL;
358 gdtcmd->u.ioctl.p_param = paddr;
359 gdtcmd->u.ioctl.param_size = sizeof(gdth_defcnt_str);
360 gdtcmd->u.ioctl.subfunc = SCSI_DEF_CNT | L_CTRL_PATTERN;
361 gdtcmd->u.ioctl.channel =
362 ha->raw[i].address | ha->raw[i].id_list[j];
363 pdef->sddc_type = 0x08;
365 if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
366 size = sprintf(buffer+len,
367 " Grown Defects:\t%d\n",
369 len += size; pos = begin + len;
376 if (pos > offset + length)
380 gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr);
383 size = sprintf(buffer+len, "\n --\n");
384 len += size; pos = begin + len;
387 /* 3. about logical drives */
388 size = sprintf(buffer+len,"\nLogical Drives:");
389 len += size; pos = begin + len;
392 buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr);
395 for (i = 0; i < MAX_LDRIVES; ++i) {
396 if (!ha->hdr[i].is_logdrv)
402 /* 3.a log. drive info */
403 TRACE2(("cache_drv_info() drive no %d\n",drv_no));
404 pcdi = (gdth_cdrinfo_str *)buf;
405 gdtcmd->Service = CACHESERVICE;
406 gdtcmd->OpCode = GDT_IOCTL;
407 gdtcmd->u.ioctl.p_param = paddr;
408 gdtcmd->u.ioctl.param_size = sizeof(gdth_cdrinfo_str);
409 gdtcmd->u.ioctl.subfunc = CACHE_DRV_INFO;
410 gdtcmd->u.ioctl.channel = drv_no;
411 if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) != S_OK)
413 pcdi->ld_dtype >>= 16;
415 if (pcdi->ld_dtype > 2) {
416 strcpy(hrec, "missing");
417 } else if (pcdi->ld_error & 1) {
418 strcpy(hrec, "fault");
419 } else if (pcdi->ld_error & 2) {
420 strcpy(hrec, "invalid");
427 size = sprintf(buffer+len,
428 "\n Number: \t%-2d \tStatus: \t%s\n",
430 len += size; pos = begin + len;
432 no_mdrv = pcdi->cd_ldcnt;
433 if (no_mdrv > 1 || pcdi->ld_slave != -1) {
435 strcpy(hrec, "RAID-1");
436 } else if (pcdi->ld_dtype == 0) {
437 strcpy(hrec, "Disk");
438 } else if (pcdi->ld_dtype == 1) {
439 strcpy(hrec, "RAID-0");
440 } else if (pcdi->ld_dtype == 2) {
441 strcpy(hrec, "Chain");
445 size = sprintf(buffer+len,
446 " Capacity [MB]:\t%-6d \tType: \t%s\n",
447 pcdi->ld_blkcnt/(1024*1024/pcdi->ld_blksize),
449 len += size; pos = begin + len;
451 size = sprintf(buffer+len,
452 " Slave Number: \t%-2d \tStatus: \t%s\n",
453 drv_no & 0x7fff, hrec);
454 len += size; pos = begin + len;
456 drv_no = pcdi->ld_slave;
461 if (pos > offset + length)
463 } while (drv_no != -1);
466 size = sprintf(buffer+len,
467 " Missing Drv.: \t%-2d \tInvalid Drv.: \t%d\n",
469 len += size; pos = begin + len;
472 if (!ha->hdr[i].is_arraydrv)
475 sprintf(hrec, "%d", ha->hdr[i].master_no);
476 size = sprintf(buffer+len,
477 " To Array Drv.:\t%s\n", hrec);
478 len += size; pos = begin + len;
483 if (pos > offset + length)
486 gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr);
489 size = sprintf(buffer+len, "\n --\n");
490 len += size; pos = begin + len;
493 /* 4. about array drives */
494 size = sprintf(buffer+len,"\nArray Drives:");
495 len += size; pos = begin + len;
498 buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr);
501 for (i = 0; i < MAX_LDRIVES; ++i) {
502 if (!(ha->hdr[i].is_arraydrv && ha->hdr[i].is_master))
504 /* 4.a array drive info */
505 TRACE2(("array_info() drive no %d\n",i));
506 pai = (gdth_arrayinf_str *)buf;
507 gdtcmd->Service = CACHESERVICE;
508 gdtcmd->OpCode = GDT_IOCTL;
509 gdtcmd->u.ioctl.p_param = paddr;
510 gdtcmd->u.ioctl.param_size = sizeof(gdth_arrayinf_str);
511 gdtcmd->u.ioctl.subfunc = ARRAY_INFO | LA_CTRL_PATTERN;
512 gdtcmd->u.ioctl.channel = i;
513 if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
514 if (pai->ai_state == 0)
515 strcpy(hrec, "idle");
516 else if (pai->ai_state == 2)
517 strcpy(hrec, "build");
518 else if (pai->ai_state == 4)
519 strcpy(hrec, "ready");
520 else if (pai->ai_state == 6)
521 strcpy(hrec, "fail");
522 else if (pai->ai_state == 8 || pai->ai_state == 10)
523 strcpy(hrec, "rebuild");
525 strcpy(hrec, "error");
526 if (pai->ai_ext_state & 0x10)
527 strcat(hrec, "/expand");
528 else if (pai->ai_ext_state & 0x1)
529 strcat(hrec, "/patch");
530 size = sprintf(buffer+len,
531 "\n Number: \t%-2d \tStatus: \t%s\n",
533 len += size; pos = begin + len;
536 if (pai->ai_type == 0)
537 strcpy(hrec, "RAID-0");
538 else if (pai->ai_type == 4)
539 strcpy(hrec, "RAID-4");
540 else if (pai->ai_type == 5)
541 strcpy(hrec, "RAID-5");
543 strcpy(hrec, "RAID-10");
544 size = sprintf(buffer+len,
545 " Capacity [MB]:\t%-6d \tType: \t%s\n",
546 pai->ai_size/(1024*1024/pai->ai_secsize),
548 len += size; pos = begin + len;
553 if (pos > offset + length)
557 gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr);
560 size = sprintf(buffer+len, "\n --\n");
561 len += size; pos = begin + len;
564 /* 5. about host drives */
565 size = sprintf(buffer+len,"\nHost Drives:");
566 len += size; pos = begin + len;
569 buf = gdth_ioctl_alloc(hanum, sizeof(gdth_hget_str), FALSE, &paddr);
572 for (i = 0; i < MAX_LDRIVES; ++i) {
573 if (!ha->hdr[i].is_logdrv ||
574 (ha->hdr[i].is_arraydrv && !ha->hdr[i].is_master))
576 /* 5.a get host drive list */
577 TRACE2(("host_get() drv_no %d\n",i));
578 phg = (gdth_hget_str *)buf;
579 gdtcmd->Service = CACHESERVICE;
580 gdtcmd->OpCode = GDT_IOCTL;
581 gdtcmd->u.ioctl.p_param = paddr;
582 gdtcmd->u.ioctl.param_size = sizeof(gdth_hget_str);
583 gdtcmd->u.ioctl.subfunc = HOST_GET | LA_CTRL_PATTERN;
584 gdtcmd->u.ioctl.channel = i;
585 phg->entries = MAX_HDRIVES;
586 phg->offset = GDTOFFSOF(gdth_hget_str, entry[0]);
587 if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
588 ha->hdr[i].ldr_no = i;
589 ha->hdr[i].rw_attribs = 0;
590 ha->hdr[i].start_sec = 0;
592 for (j = 0; j < phg->entries; ++j) {
593 k = phg->entry[j].host_drive;
594 if (k >= MAX_LDRIVES)
596 ha->hdr[k].ldr_no = phg->entry[j].log_drive;
597 ha->hdr[k].rw_attribs = phg->entry[j].rw_attribs;
598 ha->hdr[k].start_sec = phg->entry[j].start_sec;
602 gdth_ioctl_free(hanum, sizeof(gdth_hget_str), buf, paddr);
604 for (i = 0; i < MAX_HDRIVES; ++i) {
605 if (!(ha->hdr[i].present))
608 size = sprintf(buffer+len,
609 "\n Number: \t%-2d \tArr/Log. Drive:\t%d\n",
610 i, ha->hdr[i].ldr_no);
611 len += size; pos = begin + len;
614 size = sprintf(buffer+len,
615 " Capacity [MB]:\t%-6d \tStart Sector: \t%d\n",
616 (ulong32)(ha->hdr[i].size/2048), ha->hdr[i].start_sec);
617 len += size; pos = begin + len;
622 if (pos > offset + length)
627 size = sprintf(buffer+len, "\n --\n");
628 len += size; pos = begin + len;
632 /* controller events */
633 size = sprintf(buffer+len,"\nController Events:\n");
634 len += size; pos = begin + len;
637 id = gdth_read_event(ha, id, estr);
638 if (estr->event_source == 0)
640 if (estr->event_data.eu.driver.ionode == hanum &&
641 estr->event_source == ES_ASYNC) {
642 gdth_log_event(&estr->event_data, hrec);
643 do_gettimeofday(&tv);
644 sec = (int)(tv.tv_sec - estr->first_stamp);
645 if (sec < 0) sec = 0;
646 size = sprintf(buffer+len," date- %02d:%02d:%02d\t%s\n",
647 sec/3600, sec%3600/60, sec%60, hrec);
648 len += size; pos = begin + len;
653 if (pos > offset + length)
661 *start = buffer +(offset-begin);
662 len -= (offset-begin);
665 TRACE2(("get_info() len %d pos %d begin %d offset %d length %d size %d\n",
666 len,(int)pos,(int)begin,(int)offset,length,size));
675 static char *gdth_ioctl_alloc(int hanum, int size, int scratch,
685 ha = HADATA(gdth_ctr_tab[hanum]);
686 spin_lock_irqsave(&ha->smp_lock, flags);
688 if (!ha->scratch_busy && size <= GDTH_SCRATCH) {
689 ha->scratch_busy = TRUE;
690 ret_val = ha->pscratch;
691 *paddr = ha->scratch_phys;
692 } else if (scratch) {
697 ret_val = pci_alloc_consistent(ha->pdev, size, &dma_addr);
701 spin_unlock_irqrestore(&ha->smp_lock, flags);
705 static void gdth_ioctl_free(int hanum, int size, char *buf, ulong64 paddr)
710 ha = HADATA(gdth_ctr_tab[hanum]);
711 spin_lock_irqsave(&ha->smp_lock, flags);
713 if (buf == ha->pscratch) {
714 ha->scratch_busy = FALSE;
716 pci_free_consistent(ha->pdev, size, buf, paddr);
719 spin_unlock_irqrestore(&ha->smp_lock, flags);
722 #ifdef GDTH_IOCTL_PROC
723 static int gdth_ioctl_check_bin(int hanum, ushort size)
729 ha = HADATA(gdth_ctr_tab[hanum]);
730 spin_lock_irqsave(&ha->smp_lock, flags);
733 if (ha->scratch_busy) {
734 if (((gdth_iord_str *)ha->pscratch)->size == (ulong32)size)
737 spin_unlock_irqrestore(&ha->smp_lock, flags);
742 static void gdth_wait_completion(int hanum, int busnum, int id)
750 ha = HADATA(gdth_ctr_tab[hanum]);
751 spin_lock_irqsave(&ha->smp_lock, flags);
753 for (i = 0; i < GDTH_MAXCMDS; ++i) {
754 scp = ha->cmd_tab[i].cmnd;
756 b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel;
758 if (!SPECIAL_SCP(scp) && t == (unchar)id &&
759 b == (unchar)busnum) {
760 scp->SCp.have_data_in = 0;
761 spin_unlock_irqrestore(&ha->smp_lock, flags);
762 while (!scp->SCp.have_data_in)
764 spin_lock_irqsave(&ha->smp_lock, flags);
767 spin_unlock_irqrestore(&ha->smp_lock, flags);
770 static void gdth_stop_timeout(int hanum, int busnum, int id)
777 ha = HADATA(gdth_ctr_tab[hanum]);
778 spin_lock_irqsave(&ha->smp_lock, flags);
780 for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
781 if (!IS_GDTH_INTERNAL_CMD(scp)) {
783 NUMDATA(scp->device->host)->busnum : scp->device->channel;
785 if (t == (unchar)id && b == (unchar)busnum) {
786 TRACE2(("gdth_stop_timeout(): update_timeout()\n"));
787 scp->SCp.buffers_residual = gdth_update_timeout(hanum, scp, 0);
791 spin_unlock_irqrestore(&ha->smp_lock, flags);
794 static void gdth_start_timeout(int hanum, int busnum, int id)
801 ha = HADATA(gdth_ctr_tab[hanum]);
802 spin_lock_irqsave(&ha->smp_lock, flags);
804 for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
805 if (!IS_GDTH_INTERNAL_CMD(scp)) {
807 NUMDATA(scp->device->host)->busnum : scp->device->channel;
809 if (t == (unchar)id && b == (unchar)busnum) {
810 TRACE2(("gdth_start_timeout(): update_timeout()\n"));
811 gdth_update_timeout(hanum, scp, scp->SCp.buffers_residual);
815 spin_unlock_irqrestore(&ha->smp_lock, flags);
818 static int gdth_update_timeout(int hanum, Scsi_Cmnd *scp, int timeout)
822 oldto = scp->timeout_per_command;
823 scp->timeout_per_command = timeout;
826 del_timer(&scp->eh_timeout);
827 scp->eh_timeout.data = (unsigned long) NULL;
828 scp->eh_timeout.expires = 0;
830 if (scp->eh_timeout.data != (unsigned long) NULL)
831 del_timer(&scp->eh_timeout);
832 scp->eh_timeout.data = (unsigned long) scp;
833 scp->eh_timeout.expires = jiffies + timeout;
834 add_timer(&scp->eh_timeout);