X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fscsi%2Fgdth_proc.c;h=ce0228e26aec24fe070acb47b93451b0c377af23;hb=04489eeb02a40bc15029886cef7285ada3ab0de6;hp=5e8657f9cdf68f825b19c6d26346559d24e5e0bd;hpb=9cf93d7b2f4516271ccf5b48f958bd474cf9dd67;p=linux-2.6 diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c index 5e8657f9cd..ce0228e26a 100644 --- a/drivers/scsi/gdth_proc.c +++ b/drivers/scsi/gdth_proc.c @@ -1,108 +1,46 @@ /* gdth_proc.c - * $Id: gdth_proc.c,v 1.42 2004/03/05 15:50:20 achim Exp $ + * $Id: gdth_proc.c,v 1.43 2006/01/11 16:15:00 achim Exp $ */ #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t offset,int length, int inout) { - int hanum,busnum; + gdth_ha_str *ha = shost_priv(host); TRACE2(("gdth_proc_info() length %d offs %d inout %d\n", length,(int)offset,inout)); - hanum = NUMDATA(host)->hanum; - busnum= NUMDATA(host)->busnum; - if (inout) - return(gdth_set_info(buffer,length,host,hanum,busnum)); + return(gdth_set_info(buffer,length,host,ha)); else - return(gdth_get_info(buffer,start,offset,length,host,hanum,busnum)); + return(gdth_get_info(buffer,start,offset,length,host,ha)); } -#else -int gdth_proc_info(char *buffer,char **start,off_t offset,int length,int hostno, - int inout) -{ - int hanum,busnum,i; - - TRACE2(("gdth_proc_info() length %d offs %d inout %d\n", - length,(int)offset,inout)); - - for (i = 0; i < gdth_ctr_vcount; ++i) { - if (gdth_ctr_vtab[i]->host_no == hostno) - break; - } - if (i == gdth_ctr_vcount) - return(-EINVAL); - - hanum = NUMDATA(gdth_ctr_vtab[i])->hanum; - busnum= NUMDATA(gdth_ctr_vtab[i])->busnum; - - if (inout) - return(gdth_set_info(buffer,length,gdth_ctr_vtab[i],hanum,busnum)); - else - return(gdth_get_info(buffer,start,offset,length, - gdth_ctr_vtab[i],hanum,busnum)); -} -#endif static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host, - int hanum,int busnum) + gdth_ha_str *ha) { - int ret_val = -EINVAL; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) - Scsi_Request *scp; - struct scsi_device *sdev; -#else - Scsi_Cmnd *scp; - struct scsi_device *sdev; -#endif - TRACE2(("gdth_set_info() ha %d bus %d\n",hanum,busnum)); - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) - sdev = scsi_get_host_dev(host); - scp = scsi_allocate_request(sdev, GFP_KERNEL); - if (!scp) - return -ENOMEM; - scp->sr_cmd_len = 12; - scp->sr_use_sg = 0; -#else - sdev = scsi_get_host_dev(host); - scp = scsi_allocate_device(sdev, 1, FALSE); - if (!scp) - return -ENOMEM; - scp->cmd_len = 12; - scp->use_sg = 0; -#endif + int ret_val = -EINVAL; + + TRACE2(("gdth_set_info() ha %d\n",ha->hanum,)); if (length >= 4) { if (strncmp(buffer,"gdth",4) == 0) { buffer += 5; length -= 5; - ret_val = gdth_set_asc_info( buffer, length, hanum, scp ); + ret_val = gdth_set_asc_info(host, buffer, length, ha); } } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) - scsi_release_request(scp); - scsi_free_host_dev(sdev); -#else - scsi_release_command(scp); - scsi_free_host_dev(sdev); -#endif + return ret_val; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Request *scp) -#else -static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp) -#endif +static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer, + int length, gdth_ha_str *ha) { - int orig_length, drive, wb_mode; - int i, found; - gdth_ha_str *ha; + int orig_length, drive, wb_mode; + int i, found; gdth_cmd_str gdtcmd; gdth_cpar_str *pcpar; ulong64 paddr; @@ -111,8 +49,7 @@ static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp) memset(cmnd, 0xff, 12); memset(&gdtcmd, 0, sizeof(gdth_cmd_str)); - TRACE2(("gdth_set_asc_info() ha %d\n",hanum)); - ha = HADATA(gdth_ctr_tab[hanum]); + TRACE2(("gdth_set_asc_info() ha %d\n",ha->hanum)); orig_length = length + 5; drive = -1; wb_mode = 0; @@ -146,11 +83,8 @@ static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp) gdtcmd.u.cache.DeviceNo = i; gdtcmd.u.cache.BlockNo = 1; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) - gdth_do_req(scp, &gdtcmd, cmnd, 30); -#else - gdth_do_cmd(scp, &gdtcmd, cmnd, 30); -#endif + + gdth_execute(host, &gdtcmd, cmnd, 30, NULL); } } if (!found) @@ -191,7 +125,7 @@ static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp) } if (wb_mode) { - if (!gdth_ioctl_alloc(hanum, sizeof(gdth_cpar_str), TRUE, &paddr)) + if (!gdth_ioctl_alloc(ha, sizeof(gdth_cpar_str), TRUE, &paddr)) return(-EBUSY); pcpar = (gdth_cpar_str *)ha->pscratch; memcpy( pcpar, &ha->cpar, sizeof(gdth_cpar_str) ); @@ -202,12 +136,10 @@ static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp) gdtcmd.u.ioctl.subfunc = CACHE_CONFIG; gdtcmd.u.ioctl.channel = INVALID_CHANNEL; pcpar->write_back = wb_mode==1 ? 0:1; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) - gdth_do_req(scp, &gdtcmd, cmnd, 30); -#else - gdth_do_cmd(scp, &gdtcmd, cmnd, 30); -#endif - gdth_ioctl_free(hanum, GDTH_SCRATCH, ha->pscratch, paddr); + + gdth_execute(host, &gdtcmd, cmnd, 30, NULL); + + gdth_ioctl_free(ha, GDTH_SCRATCH, ha->pscratch, paddr); printk("Done.\n"); return(orig_length); } @@ -217,11 +149,10 @@ static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp) } static int gdth_get_info(char *buffer,char **start,off_t offset,int length, - struct Scsi_Host *host,int hanum,int busnum) + struct Scsi_Host *host, gdth_ha_str *ha) { int size = 0,len = 0; off_t begin = 0,pos = 0; - gdth_ha_str *ha; int id, i, j, k, sec, flag; int no_mdrv = 0, drv_no, is_mirr; ulong32 cnt; @@ -230,13 +161,6 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, gdth_cmd_str *gdtcmd; gdth_evt_str *estr; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) - Scsi_Request *scp; - struct scsi_device *sdev; -#else - Scsi_Cmnd *scp; - struct scsi_device *sdev; -#endif char hrec[161]; struct timeval tv; @@ -252,36 +176,13 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, gdtcmd = kmalloc(sizeof(*gdtcmd), GFP_KERNEL); estr = kmalloc(sizeof(*estr), GFP_KERNEL); if (!gdtcmd || !estr) - goto free_fail; + goto free_fail; memset(cmnd, 0xff, 12); memset(gdtcmd, 0, sizeof(gdth_cmd_str)); - TRACE2(("gdth_get_info() ha %d bus %d\n",hanum,busnum)); - ha = HADATA(gdth_ctr_tab[hanum]); + TRACE2(("gdth_get_info() ha %d\n",ha->hanum)); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) - sdev = scsi_get_host_dev(host); - scp = scsi_allocate_request(sdev, GFP_KERNEL); - if (!scp) - goto free_fail; - scp->sr_cmd_len = 12; - scp->sr_use_sg = 0; -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) - sdev = scsi_get_host_dev(host); - scp = scsi_allocate_device(sdev, 1, FALSE); - if (!scp) - goto free_fail; - scp->cmd_len = 12; - scp->use_sg = 0; -#else - memset(&sdev,0,sizeof(struct scsi_device)); - memset(&scp, 0,sizeof(Scsi_Cmnd)); - sdev.host = scp.host = host; - sdev.id = scp.target = sdev.host->this_id; - scp.device = &sdev; -#endif - /* request is i.e. "cat /proc/scsi/gdth/0" */ /* format: %-15s\t%-10s\t%-15s\t%s */ @@ -310,13 +211,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, /* controller information */ size = sprintf(buffer+len,"\nDisk Array Controller Information:\n"); len += size; pos = begin + len; - if (virt_ctr) - sprintf(hrec, "%s (Bus %d)", ha->binfo.type_string, busnum); - else - strcpy(hrec, ha->binfo.type_string); + strcpy(hrec, ha->binfo.type_string); size = sprintf(buffer+len, " Number: \t%d \tName: \t%s\n", - hanum, hrec); + ha->hanum, hrec); len += size; pos = begin + len; if (ha->more_proc) @@ -366,7 +264,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, len += size; pos = begin + len; flag = FALSE; - buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr); + buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); if (!buf) goto stop_output; for (i = 0; i < ha->bus_cnt; ++i) { @@ -386,16 +284,9 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, sizeof(pds->list[0]); if (pds->entries > cnt) pds->entries = cnt; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) - gdth_do_req(scp, gdtcmd, cmnd, 30); - if (scp->sr_command->SCp.Status != S_OK) -#else - gdth_do_cmd(scp, gdtcmd, cmnd, 30); - if (scp->SCp.Status != S_OK) -#endif - { + + if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) != S_OK) pds->count = 0; - } /* other IOCTLs must fit into area GDTH_SCRATCH/4 */ for (j = 0; j < ha->raw[i].pdev_cnt; ++j) { @@ -410,14 +301,8 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, gdtcmd->u.ioctl.subfunc = SCSI_DR_INFO | L_CTRL_PATTERN; gdtcmd->u.ioctl.channel = ha->raw[i].address | ha->raw[i].id_list[j]; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) - gdth_do_req(scp, gdtcmd, cmnd, 30); - if (scp->sr_command->SCp.Status == S_OK) -#else - gdth_do_cmd(scp, gdtcmd, cmnd, 30); - if (scp->SCp.Status == S_OK) -#endif - { + + if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) { strncpy(hrec,pdi->vendor,8); strncpy(hrec+8,pdi->product,16); strncpy(hrec+24,pdi->revision,4); @@ -466,14 +351,8 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, gdtcmd->u.ioctl.channel = ha->raw[i].address | ha->raw[i].id_list[j]; pdef->sddc_type = 0x08; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) - gdth_do_req(scp, gdtcmd, cmnd, 30); - if (scp->sr_command->SCp.Status == S_OK) -#else - gdth_do_cmd(scp, gdtcmd, cmnd, 30); - if (scp->SCp.Status == S_OK) -#endif - { + + if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) { size = sprintf(buffer+len, " Grown Defects:\t%d\n", pdef->sddc_cnt); @@ -488,7 +367,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, goto stop_output; } } - gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr); + gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); if (!flag) { size = sprintf(buffer+len, "\n --\n"); @@ -500,7 +379,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, len += size; pos = begin + len; flag = FALSE; - buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr); + buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); if (!buf) goto stop_output; for (i = 0; i < MAX_LDRIVES; ++i) { @@ -519,16 +398,8 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, gdtcmd->u.ioctl.param_size = sizeof(gdth_cdrinfo_str); gdtcmd->u.ioctl.subfunc = CACHE_DRV_INFO; gdtcmd->u.ioctl.channel = drv_no; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) - gdth_do_req(scp, gdtcmd, cmnd, 30); - if (scp->sr_command->SCp.Status != S_OK) -#else - gdth_do_cmd(scp, gdtcmd, cmnd, 30); - if (scp->SCp.Status != S_OK) -#endif - { + if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) != S_OK) break; - } pcdi->ld_dtype >>= 16; j++; if (pcdi->ld_dtype > 2) { @@ -602,7 +473,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, if (pos > offset + length) goto stop_output; } - gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr); + gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); if (!flag) { size = sprintf(buffer+len, "\n --\n"); @@ -614,7 +485,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, len += size; pos = begin + len; flag = FALSE; - buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr); + buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); if (!buf) goto stop_output; for (i = 0; i < MAX_LDRIVES; ++i) { @@ -629,14 +500,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, gdtcmd->u.ioctl.param_size = sizeof(gdth_arrayinf_str); gdtcmd->u.ioctl.subfunc = ARRAY_INFO | LA_CTRL_PATTERN; gdtcmd->u.ioctl.channel = i; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) - gdth_do_req(scp, gdtcmd, cmnd, 30); - if (scp->sr_command->SCp.Status == S_OK) -#else - gdth_do_cmd(scp, gdtcmd, cmnd, 30); - if (scp->SCp.Status == S_OK) -#endif - { + if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) { if (pai->ai_state == 0) strcpy(hrec, "idle"); else if (pai->ai_state == 2) @@ -680,7 +544,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, goto stop_output; } } - gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr); + gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); if (!flag) { size = sprintf(buffer+len, "\n --\n"); @@ -692,7 +556,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, len += size; pos = begin + len; flag = FALSE; - buf = gdth_ioctl_alloc(hanum, sizeof(gdth_hget_str), FALSE, &paddr); + buf = gdth_ioctl_alloc(ha, sizeof(gdth_hget_str), FALSE, &paddr); if (!buf) goto stop_output; for (i = 0; i < MAX_LDRIVES; ++i) { @@ -710,14 +574,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, gdtcmd->u.ioctl.channel = i; phg->entries = MAX_HDRIVES; phg->offset = GDTOFFSOF(gdth_hget_str, entry[0]); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) - gdth_do_req(scp, gdtcmd, cmnd, 30); - if (scp->sr_command->SCp.Status != S_OK) -#else - gdth_do_cmd(scp, gdtcmd, cmnd, 30); - if (scp->SCp.Status != S_OK) -#endif - { + if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) { ha->hdr[i].ldr_no = i; ha->hdr[i].rw_attribs = 0; ha->hdr[i].start_sec = 0; @@ -732,7 +589,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, } } } - gdth_ioctl_free(hanum, sizeof(gdth_hget_str), buf, paddr); + gdth_ioctl_free(ha, sizeof(gdth_hget_str), buf, paddr); for (i = 0; i < MAX_HDRIVES; ++i) { if (!(ha->hdr[i].present)) @@ -770,7 +627,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, id = gdth_read_event(ha, id, estr); if (estr->event_source == 0) break; - if (estr->event_data.eu.driver.ionode == hanum && + if (estr->event_data.eu.driver.ionode == ha->hanum && estr->event_source == ES_ASYNC) { gdth_log_event(&estr->event_data, hrec); do_gettimeofday(&tv); @@ -791,13 +648,6 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length, } stop_output: -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) - scsi_release_request(scp); - scsi_free_host_dev(sdev); -#else - scsi_release_command(scp); - scsi_free_host_dev(sdev); -#endif *start = buffer +(offset-begin); len -= (offset-begin); if (len > length) @@ -812,75 +662,15 @@ free_fail: return rc; } - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -static void gdth_do_req(Scsi_Request *scp, gdth_cmd_str *gdtcmd, - char *cmnd, int timeout) -{ - unsigned bufflen; - DECLARE_COMPLETION(wait); - - TRACE2(("gdth_do_req()\n")); - if (gdtcmd != NULL) { - bufflen = sizeof(gdth_cmd_str); - } else { - bufflen = 0; - } - scp->sr_request->rq_status = RQ_SCSI_BUSY; - scp->sr_request->waiting = &wait; - scsi_do_req(scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ, 1); - wait_for_completion(&wait); -} - -#else -static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *gdtcmd, - char *cmnd, int timeout) -{ - unsigned bufflen; - DECLARE_COMPLETION(wait); - - TRACE2(("gdth_do_cmd()\n")); - if (gdtcmd != NULL) { - scp->SCp.this_residual = IOCTL_PRI; - bufflen = sizeof(gdth_cmd_str); - } else { - scp->SCp.this_residual = DEFAULT_PRI; - bufflen = 0; - } - - scp->request.rq_status = RQ_SCSI_BUSY; - scp->request.waiting = &wait; - scsi_do_cmd(scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ, 1); - wait_for_completion(&wait); -} -#endif - -void gdth_scsi_done(Scsi_Cmnd *scp) -{ - TRACE2(("gdth_scsi_done()\n")); - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) - scp->request->rq_status = RQ_SCSI_DONE; - if (scp->request->waiting != NULL) - complete(scp->request->waiting); -#else - scp->request.rq_status = RQ_SCSI_DONE; - if (scp->request.waiting != NULL) - complete(scp->request.waiting); -#endif -} - -static char *gdth_ioctl_alloc(int hanum, int size, int scratch, +static char *gdth_ioctl_alloc(gdth_ha_str *ha, int size, int scratch, ulong64 *paddr) { - gdth_ha_str *ha; ulong flags; char *ret_val; if (size == 0) return NULL; - ha = HADATA(gdth_ctr_tab[hanum]); spin_lock_irqsave(&ha->smp_lock, flags); if (!ha->scratch_busy && size <= GDTH_SCRATCH) { @@ -900,31 +690,25 @@ static char *gdth_ioctl_alloc(int hanum, int size, int scratch, return ret_val; } -static void gdth_ioctl_free(int hanum, int size, char *buf, ulong64 paddr) +static void gdth_ioctl_free(gdth_ha_str *ha, int size, char *buf, ulong64 paddr) { - gdth_ha_str *ha; ulong flags; - ha = HADATA(gdth_ctr_tab[hanum]); - spin_lock_irqsave(&ha->smp_lock, flags); - if (buf == ha->pscratch) { + spin_lock_irqsave(&ha->smp_lock, flags); ha->scratch_busy = FALSE; + spin_unlock_irqrestore(&ha->smp_lock, flags); } else { pci_free_consistent(ha->pdev, size, buf, paddr); } - - spin_unlock_irqrestore(&ha->smp_lock, flags); } #ifdef GDTH_IOCTL_PROC -static int gdth_ioctl_check_bin(int hanum, ushort size) +static int gdth_ioctl_check_bin(gdth_ha_str *ha, ushort size) { - gdth_ha_str *ha; ulong flags; int ret_val; - ha = HADATA(gdth_ctr_tab[hanum]); spin_lock_irqsave(&ha->smp_lock, flags); ret_val = FALSE; @@ -937,27 +721,27 @@ static int gdth_ioctl_check_bin(int hanum, ushort size) } #endif -static void gdth_wait_completion(int hanum, int busnum, int id) +static void gdth_wait_completion(gdth_ha_str *ha, int busnum, int id) { - gdth_ha_str *ha; ulong flags; int i; Scsi_Cmnd *scp; + struct gdth_cmndinfo *cmndinfo; unchar b, t; - ha = HADATA(gdth_ctr_tab[hanum]); spin_lock_irqsave(&ha->smp_lock, flags); for (i = 0; i < GDTH_MAXCMDS; ++i) { scp = ha->cmd_tab[i].cmnd; + cmndinfo = gdth_cmnd_priv(scp); - b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel; + b = scp->device->channel; t = scp->device->id; if (!SPECIAL_SCP(scp) && t == (unchar)id && b == (unchar)busnum) { - scp->SCp.have_data_in = 0; + cmndinfo->wait_for_completion = 0; spin_unlock_irqrestore(&ha->smp_lock, flags); - while (!scp->SCp.have_data_in) + while (!cmndinfo->wait_for_completion) barrier(); spin_lock_irqsave(&ha->smp_lock, flags); } @@ -965,49 +749,51 @@ static void gdth_wait_completion(int hanum, int busnum, int id) spin_unlock_irqrestore(&ha->smp_lock, flags); } -static void gdth_stop_timeout(int hanum, int busnum, int id) +static void gdth_stop_timeout(gdth_ha_str *ha, int busnum, int id) { - gdth_ha_str *ha; ulong flags; Scsi_Cmnd *scp; unchar b, t; - ha = HADATA(gdth_ctr_tab[hanum]); spin_lock_irqsave(&ha->smp_lock, flags); for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { - b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel; - t = scp->device->id; - if (t == (unchar)id && b == (unchar)busnum) { - TRACE2(("gdth_stop_timeout(): update_timeout()\n")); - scp->SCp.buffers_residual = gdth_update_timeout(hanum, scp, 0); + struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp); + if (!cmndinfo->internal_command) { + b = scp->device->channel; + t = scp->device->id; + if (t == (unchar)id && b == (unchar)busnum) { + TRACE2(("gdth_stop_timeout(): update_timeout()\n")); + cmndinfo->timeout = gdth_update_timeout(scp, 0); + } } } spin_unlock_irqrestore(&ha->smp_lock, flags); } -static void gdth_start_timeout(int hanum, int busnum, int id) +static void gdth_start_timeout(gdth_ha_str *ha, int busnum, int id) { - gdth_ha_str *ha; ulong flags; Scsi_Cmnd *scp; unchar b, t; - ha = HADATA(gdth_ctr_tab[hanum]); spin_lock_irqsave(&ha->smp_lock, flags); for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { - b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel; - t = scp->device->id; - if (t == (unchar)id && b == (unchar)busnum) { - TRACE2(("gdth_start_timeout(): update_timeout()\n")); - gdth_update_timeout(hanum, scp, scp->SCp.buffers_residual); + struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp); + if (!cmndinfo->internal_command) { + b = scp->device->channel; + t = scp->device->id; + if (t == (unchar)id && b == (unchar)busnum) { + TRACE2(("gdth_start_timeout(): update_timeout()\n")); + gdth_update_timeout(scp, cmndinfo->timeout); + } } } spin_unlock_irqrestore(&ha->smp_lock, flags); } -static int gdth_update_timeout(int hanum, Scsi_Cmnd *scp, int timeout) +static int gdth_update_timeout(Scsi_Cmnd *scp, int timeout) { int oldto;