2039
2040 TRACE(("gdth_next() hanum %d\n", ha->hanum));
2041 if (!gdth_polling)
2042 spin_lock_irqsave(&ha->smp_lock, flags);
2043
2044 ha->cmd_cnt = ha->cmd_offs_dpmem = 0;
2045 this_cmd = firsttime = TRUE;
2046 next_cmd = gdth_polling ? FALSE:TRUE;
2047 cmd_index = 0;
2048
2049 for (nscp = pscp = ha->req_first; nscp; nscp = (Scsi_Cmnd *)nscp->SCp.ptr) {
2050 struct gdth_cmndinfo *nscp_cmndinfo = gdth_cmnd_priv(nscp);
2051 if (nscp != pscp && nscp != (Scsi_Cmnd *)pscp->SCp.ptr)
2052 pscp = (Scsi_Cmnd *)pscp->SCp.ptr;
2053 if (!nscp_cmndinfo->internal_command) {
2054 b = nscp->device->channel;
2055 t = nscp->device->id;
2056 l = nscp->device->lun;
2057 if (nscp_cmndinfo->priority >= DEFAULT_PRI) {
2058 if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) ||
2059 (b == ha->virt_bus && t < MAX_HDRIVES && ha->hdr[t].lock))
2060 continue;
2061 }
2062 } else
2063 b = t = l = 0;
2064
2065 if (firsttime) {
2066 if (gdth_test_busy(ha)) {
2067 TRACE(("gdth_next() controller %d busy !\n", ha->hanum));
2068 if (!gdth_polling) {
2069 spin_unlock_irqrestore(&ha->smp_lock, flags);
2070 return;
2071 }
2072 while (gdth_test_busy(ha))
2073 gdth_delay(1);
2074 }
2075 firsttime = FALSE;
2076 }
2077
2078 if (!nscp_cmndinfo->internal_command) {
2079 if (nscp_cmndinfo->phase == -1) {