aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoaz Harrosh <bharrosh@panasas.com>2007-10-02 17:16:01 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-12 14:56:09 -0400
commitf842b64e0ffbcc9ce48a3bf799d0b005094107c1 (patch)
tree30f1d9fa5024d647886d651be0009eba728bbbfa
parent3058d5de47ce09ac0e531290566937c7d94d0653 (diff)
[SCSI] gdth: Move members from SCp to gdth_cmndinfo, stage 2
- Cleanup the rest of the scsi_cmnd->SCp members and move them to gdth_cmndinfo: SCp.this_residual => priority SCp.buffers_residual => timeout SCp.Status => status and dma_dir SCp.Message => info SCp.have_data_in => volatile wait_for_completion SCp.sent_command => OpCode SCp.phase => phase - Two more members will be naturally removed in the !use_sg cleanup TODO: What is the meaning of gdth_cmndinfo.phase? (rhetorically) Signed-off-by Boaz Harrosh <bharrosh@panasas.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
-rw-r--r--drivers/scsi/gdth.c177
-rw-r--r--drivers/scsi/gdth.h8
-rw-r--r--drivers/scsi/gdth_proc.c10
3 files changed, 104 insertions, 91 deletions
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index e002c391e0d2..a68004b0d90b 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -85,15 +85,15 @@
85 85
86/* The meaning of the Scsi_Pointer members in this driver is as follows: 86/* The meaning of the Scsi_Pointer members in this driver is as follows:
87 * ptr: Chaining 87 * ptr: Chaining
88 * this_residual: Command priority 88 * this_residual: unused
89 * buffer: unused 89 * buffer: unused
90 * dma_handle: will drop in !use_sg patch. 90 * dma_handle: will drop in !use_sg patch.
91 * buffers_residual: Timeout value 91 * buffers_residual: unused
92 * Status: Command status (gdth_do_cmd()), DMA mem. mappings 92 * Status: DMA mem. mappings (FIXME: drop in !use_sg patch.)
93 * Message: Additional info (gdth_do_cmd()), DMA direction 93 * Message: unused
94 * have_data_in: Flag for gdth_wait_completion() 94 * have_data_in: unused
95 * sent_command: Opcode special command 95 * sent_command: unused
96 * phase: Service/parameter/return code special command 96 * phase: unused
97 */ 97 */
98 98
99 99
@@ -468,7 +468,7 @@ int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd,
468 scp->request_buffer = gdtcmd; 468 scp->request_buffer = gdtcmd;
469 scp->cmd_len = 12; 469 scp->cmd_len = 12;
470 memcpy(scp->cmnd, cmnd, 12); 470 memcpy(scp->cmnd, cmnd, 12);
471 scp->SCp.this_residual = IOCTL_PRI; /* priority */ 471 cmndinfo.priority = IOCTL_PRI;
472 cmndinfo.internal_command = 1; 472 cmndinfo.internal_command = 1;
473 473
474 TRACE(("__gdth_execute() cmd 0x%x\n", scp->cmnd[0])); 474 TRACE(("__gdth_execute() cmd 0x%x\n", scp->cmnd[0]));
@@ -476,9 +476,9 @@ int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd,
476 476
477 wait_for_completion(&wait); 477 wait_for_completion(&wait);
478 478
479 rval = scp->SCp.Status; 479 rval = cmndinfo.status;
480 if (info) 480 if (info)
481 *info = scp->SCp.Message; 481 *info = cmndinfo.info;
482 kfree(scp); 482 kfree(scp);
483 return rval; 483 return rval;
484} 484}
@@ -2016,14 +2016,14 @@ static void gdth_putq(gdth_ha_str *ha, Scsi_Cmnd *scp, unchar priority)
2016 spin_lock_irqsave(&ha->smp_lock, flags); 2016 spin_lock_irqsave(&ha->smp_lock, flags);
2017 2017
2018 if (!cmndinfo->internal_command) { 2018 if (!cmndinfo->internal_command) {
2019 scp->SCp.this_residual = (int)priority; 2019 cmndinfo->priority = priority;
2020 b = scp->device->channel; 2020 b = scp->device->channel;
2021 t = scp->device->id; 2021 t = scp->device->id;
2022 if (priority >= DEFAULT_PRI) { 2022 if (priority >= DEFAULT_PRI) {
2023 if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) || 2023 if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) ||
2024 (b==ha->virt_bus && t<MAX_HDRIVES && ha->hdr[t].lock)) { 2024 (b==ha->virt_bus && t<MAX_HDRIVES && ha->hdr[t].lock)) {
2025 TRACE2(("gdth_putq(): locked IO ->update_timeout()\n")); 2025 TRACE2(("gdth_putq(): locked IO ->update_timeout()\n"));
2026 scp->SCp.buffers_residual = gdth_update_timeout(scp, 0); 2026 cmndinfo->timeout = gdth_update_timeout(scp, 0);
2027 } 2027 }
2028 } 2028 }
2029 } 2029 }
@@ -2035,7 +2035,7 @@ static void gdth_putq(gdth_ha_str *ha, Scsi_Cmnd *scp, unchar priority)
2035 pscp = ha->req_first; 2035 pscp = ha->req_first;
2036 nscp = (Scsi_Cmnd *)pscp->SCp.ptr; 2036 nscp = (Scsi_Cmnd *)pscp->SCp.ptr;
2037 /* priority: 0-highest,..,0xff-lowest */ 2037 /* priority: 0-highest,..,0xff-lowest */
2038 while (nscp && (unchar)nscp->SCp.this_residual <= priority) { 2038 while (nscp && gdth_cmnd_priv(nscp)->priority <= priority) {
2039 pscp = nscp; 2039 pscp = nscp;
2040 nscp = (Scsi_Cmnd *)pscp->SCp.ptr; 2040 nscp = (Scsi_Cmnd *)pscp->SCp.ptr;
2041 } 2041 }
@@ -2074,13 +2074,14 @@ static void gdth_next(gdth_ha_str *ha)
2074 cmd_index = 0; 2074 cmd_index = 0;
2075 2075
2076 for (nscp = pscp = ha->req_first; nscp; nscp = (Scsi_Cmnd *)nscp->SCp.ptr) { 2076 for (nscp = pscp = ha->req_first; nscp; nscp = (Scsi_Cmnd *)nscp->SCp.ptr) {
2077 struct gdth_cmndinfo *nscp_cmndinfo = gdth_cmnd_priv(nscp);
2077 if (nscp != pscp && nscp != (Scsi_Cmnd *)pscp->SCp.ptr) 2078 if (nscp != pscp && nscp != (Scsi_Cmnd *)pscp->SCp.ptr)
2078 pscp = (Scsi_Cmnd *)pscp->SCp.ptr; 2079 pscp = (Scsi_Cmnd *)pscp->SCp.ptr;
2079 if (!gdth_cmnd_priv(nscp)->internal_command) { 2080 if (!nscp_cmndinfo->internal_command) {
2080 b = nscp->device->channel; 2081 b = nscp->device->channel;
2081 t = nscp->device->id; 2082 t = nscp->device->id;
2082 l = nscp->device->lun; 2083 l = nscp->device->lun;
2083 if (nscp->SCp.this_residual >= DEFAULT_PRI) { 2084 if (nscp_cmndinfo->priority >= DEFAULT_PRI) {
2084 if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) || 2085 if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) ||
2085 (b == ha->virt_bus && t < MAX_HDRIVES && ha->hdr[t].lock)) 2086 (b == ha->virt_bus && t < MAX_HDRIVES && ha->hdr[t].lock))
2086 continue; 2087 continue;
@@ -2101,9 +2102,9 @@ static void gdth_next(gdth_ha_str *ha)
2101 firsttime = FALSE; 2102 firsttime = FALSE;
2102 } 2103 }
2103 2104
2104 if (!gdth_cmnd_priv(nscp)->internal_command) { 2105 if (!nscp_cmndinfo->internal_command) {
2105 if (nscp->SCp.phase == -1) { 2106 if (nscp_cmndinfo->phase == -1) {
2106 nscp->SCp.phase = CACHESERVICE; /* default: cache svc. */ 2107 nscp_cmndinfo->phase = CACHESERVICE; /* default: cache svc. */
2107 if (nscp->cmnd[0] == TEST_UNIT_READY) { 2108 if (nscp->cmnd[0] == TEST_UNIT_READY) {
2108 TRACE2(("TEST_UNIT_READY Bus %d Id %d LUN %d\n", 2109 TRACE2(("TEST_UNIT_READY Bus %d Id %d LUN %d\n",
2109 b, t, l)); 2110 b, t, l));
@@ -2116,8 +2117,8 @@ static void gdth_next(gdth_ha_str *ha)
2116 } else if ((ha->scan_mode & 0x0f) == 1) { 2117 } else if ((ha->scan_mode & 0x0f) == 1) {
2117 if (b == 0 && ((t == 0 && l == 1) || 2118 if (b == 0 && ((t == 0 && l == 1) ||
2118 (t == 1 && l == 0))) { 2119 (t == 1 && l == 0))) {
2119 nscp->SCp.sent_command = GDT_SCAN_START; 2120 nscp_cmndinfo->OpCode = GDT_SCAN_START;
2120 nscp->SCp.phase = ((ha->scan_mode & 0x10 ? 1:0) << 8) 2121 nscp_cmndinfo->phase = ((ha->scan_mode & 0x10 ? 1:0) << 8)
2121 | SCSIRAWSERVICE; 2122 | SCSIRAWSERVICE;
2122 ha->scan_mode = 0x12; 2123 ha->scan_mode = 0x12;
2123 TRACE2(("Scan mode: 0x%x (SCAN_START)\n", 2124 TRACE2(("Scan mode: 0x%x (SCAN_START)\n",
@@ -2128,8 +2129,8 @@ static void gdth_next(gdth_ha_str *ha)
2128 } 2129 }
2129 } else if (ha->scan_mode == 0x12) { 2130 } else if (ha->scan_mode == 0x12) {
2130 if (b == ha->bus_cnt && t == ha->tid_cnt-1) { 2131 if (b == ha->bus_cnt && t == ha->tid_cnt-1) {
2131 nscp->SCp.phase = SCSIRAWSERVICE; 2132 nscp_cmndinfo->phase = SCSIRAWSERVICE;
2132 nscp->SCp.sent_command = GDT_SCAN_END; 2133 nscp_cmndinfo->OpCode = GDT_SCAN_END;
2133 ha->scan_mode &= 0x10; 2134 ha->scan_mode &= 0x10;
2134 TRACE2(("Scan mode: 0x%x (SCAN_END)\n", 2135 TRACE2(("Scan mode: 0x%x (SCAN_END)\n",
2135 ha->scan_mode)); 2136 ha->scan_mode));
@@ -2140,17 +2141,17 @@ static void gdth_next(gdth_ha_str *ha)
2140 nscp->cmnd[0] != READ_CAPACITY && nscp->cmnd[0] != MODE_SENSE && 2141 nscp->cmnd[0] != READ_CAPACITY && nscp->cmnd[0] != MODE_SENSE &&
2141 (ha->hdr[t].cluster_type & CLUSTER_DRIVE)) { 2142 (ha->hdr[t].cluster_type & CLUSTER_DRIVE)) {
2142 /* always GDT_CLUST_INFO! */ 2143 /* always GDT_CLUST_INFO! */
2143 nscp->SCp.sent_command = GDT_CLUST_INFO; 2144 nscp_cmndinfo->OpCode = GDT_CLUST_INFO;
2144 } 2145 }
2145 } 2146 }
2146 } 2147 }
2147 2148
2148 if (nscp->SCp.sent_command != -1) { 2149 if (nscp_cmndinfo->OpCode != -1) {
2149 if ((nscp->SCp.phase & 0xff) == CACHESERVICE) { 2150 if ((nscp_cmndinfo->phase & 0xff) == CACHESERVICE) {
2150 if (!(cmd_index=gdth_fill_cache_cmd(ha, nscp, t))) 2151 if (!(cmd_index=gdth_fill_cache_cmd(ha, nscp, t)))
2151 this_cmd = FALSE; 2152 this_cmd = FALSE;
2152 next_cmd = FALSE; 2153 next_cmd = FALSE;
2153 } else if ((nscp->SCp.phase & 0xff) == SCSIRAWSERVICE) { 2154 } else if ((nscp_cmndinfo->phase & 0xff) == SCSIRAWSERVICE) {
2154 if (!(cmd_index=gdth_fill_raw_cmd(ha, nscp, BUS_L2P(ha, b)))) 2155 if (!(cmd_index=gdth_fill_raw_cmd(ha, nscp, BUS_L2P(ha, b))))
2155 this_cmd = FALSE; 2156 this_cmd = FALSE;
2156 next_cmd = FALSE; 2157 next_cmd = FALSE;
@@ -2159,8 +2160,8 @@ static void gdth_next(gdth_ha_str *ha)
2159 nscp->sense_buffer[0] = 0x70; 2160 nscp->sense_buffer[0] = 0x70;
2160 nscp->sense_buffer[2] = NOT_READY; 2161 nscp->sense_buffer[2] = NOT_READY;
2161 nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1); 2162 nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
2162 if (!nscp->SCp.have_data_in) 2163 if (!nscp_cmndinfo->wait_for_completion)
2163 nscp->SCp.have_data_in++; 2164 nscp_cmndinfo->wait_for_completion++;
2164 else 2165 else
2165 gdth_scsi_done(nscp); 2166 gdth_scsi_done(nscp);
2166 } 2167 }
@@ -2178,8 +2179,8 @@ static void gdth_next(gdth_ha_str *ha)
2178 TRACE2(("Command 0x%x to bus %d id %d lun %d -> IGNORE\n", 2179 TRACE2(("Command 0x%x to bus %d id %d lun %d -> IGNORE\n",
2179 nscp->cmnd[0], b, t, l)); 2180 nscp->cmnd[0], b, t, l));
2180 nscp->result = DID_BAD_TARGET << 16; 2181 nscp->result = DID_BAD_TARGET << 16;
2181 if (!nscp->SCp.have_data_in) 2182 if (!nscp_cmndinfo->wait_for_completion)
2182 nscp->SCp.have_data_in++; 2183 nscp_cmndinfo->wait_for_completion++;
2183 else 2184 else
2184 gdth_scsi_done(nscp); 2185 gdth_scsi_done(nscp);
2185 } else { 2186 } else {
@@ -2204,8 +2205,8 @@ static void gdth_next(gdth_ha_str *ha)
2204 nscp->sense_buffer[0] = 0x70; 2205 nscp->sense_buffer[0] = 0x70;
2205 nscp->sense_buffer[2] = UNIT_ATTENTION; 2206 nscp->sense_buffer[2] = UNIT_ATTENTION;
2206 nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1); 2207 nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
2207 if (!nscp->SCp.have_data_in) 2208 if (!nscp_cmndinfo->wait_for_completion)
2208 nscp->SCp.have_data_in++; 2209 nscp_cmndinfo->wait_for_completion++;
2209 else 2210 else
2210 gdth_scsi_done(nscp); 2211 gdth_scsi_done(nscp);
2211 } else if (gdth_internal_cache_cmd(ha, nscp)) 2212 } else if (gdth_internal_cache_cmd(ha, nscp))
@@ -2220,8 +2221,8 @@ static void gdth_next(gdth_ha_str *ha)
2220 TRACE(("Prevent r. nonremov. drive->do nothing\n")); 2221 TRACE(("Prevent r. nonremov. drive->do nothing\n"));
2221 nscp->result = DID_OK << 16; 2222 nscp->result = DID_OK << 16;
2222 nscp->sense_buffer[0] = 0; 2223 nscp->sense_buffer[0] = 0;
2223 if (!nscp->SCp.have_data_in) 2224 if (!nscp_cmndinfo->wait_for_completion)
2224 nscp->SCp.have_data_in++; 2225 nscp_cmndinfo->wait_for_completion++;
2225 else 2226 else
2226 gdth_scsi_done(nscp); 2227 gdth_scsi_done(nscp);
2227 } else { 2228 } else {
@@ -2256,8 +2257,8 @@ static void gdth_next(gdth_ha_str *ha)
2256 nscp->sense_buffer[0] = 0x70; 2257 nscp->sense_buffer[0] = 0x70;
2257 nscp->sense_buffer[2] = UNIT_ATTENTION; 2258 nscp->sense_buffer[2] = UNIT_ATTENTION;
2258 nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1); 2259 nscp->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
2259 if (!nscp->SCp.have_data_in) 2260 if (!nscp_cmndinfo->wait_for_completion)
2260 nscp->SCp.have_data_in++; 2261 nscp_cmndinfo->wait_for_completion++;
2261 else 2262 else
2262 gdth_scsi_done(nscp); 2263 gdth_scsi_done(nscp);
2263 } else if (!(cmd_index=gdth_fill_cache_cmd(ha, nscp, t))) 2264 } else if (!(cmd_index=gdth_fill_cache_cmd(ha, nscp, t)))
@@ -2271,8 +2272,8 @@ static void gdth_next(gdth_ha_str *ha)
2271 printk("GDT-HA %d: Unknown SCSI command 0x%x to cache service !\n", 2272 printk("GDT-HA %d: Unknown SCSI command 0x%x to cache service !\n",
2272 ha->hanum, nscp->cmnd[0]); 2273 ha->hanum, nscp->cmnd[0]);
2273 nscp->result = DID_ABORT << 16; 2274 nscp->result = DID_ABORT << 16;
2274 if (!nscp->SCp.have_data_in) 2275 if (!nscp_cmndinfo->wait_for_completion)
2275 nscp->SCp.have_data_in++; 2276 nscp_cmndinfo->wait_for_completion++;
2276 else 2277 else
2277 gdth_scsi_done(nscp); 2278 gdth_scsi_done(nscp);
2278 break; 2279 break;
@@ -2351,6 +2352,7 @@ static int gdth_internal_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp)
2351 gdth_rdcap_data rdc; 2352 gdth_rdcap_data rdc;
2352 gdth_sense_data sd; 2353 gdth_sense_data sd;
2353 gdth_modep_data mpd; 2354 gdth_modep_data mpd;
2355 struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp);
2354 2356
2355 t = scp->device->id; 2357 t = scp->device->id;
2356 TRACE(("gdth_internal_cache_cmd() cmd 0x%x hdrive %d\n", 2358 TRACE(("gdth_internal_cache_cmd() cmd 0x%x hdrive %d\n",
@@ -2437,8 +2439,8 @@ static int gdth_internal_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp)
2437 break; 2439 break;
2438 } 2440 }
2439 2441
2440 if (!scp->SCp.have_data_in) 2442 if (!cmndinfo->wait_for_completion)
2441 scp->SCp.have_data_in++; 2443 cmndinfo->wait_for_completion++;
2442 else 2444 else
2443 return 1; 2445 return 1;
2444 2446
@@ -2448,6 +2450,7 @@ static int gdth_internal_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp)
2448static int gdth_fill_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, ushort hdrive) 2450static int gdth_fill_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, ushort hdrive)
2449{ 2451{
2450 register gdth_cmd_str *cmdp; 2452 register gdth_cmd_str *cmdp;
2453 struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp);
2451 struct scatterlist *sl; 2454 struct scatterlist *sl;
2452 ulong32 cnt, blockcnt; 2455 ulong32 cnt, blockcnt;
2453 ulong64 no, blockno; 2456 ulong64 no, blockno;
@@ -2481,8 +2484,8 @@ static int gdth_fill_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, ushort hdrive)
2481 2484
2482 /* fill command */ 2485 /* fill command */
2483 read_write = 0; 2486 read_write = 0;
2484 if (scp->SCp.sent_command != -1) 2487 if (cmndinfo->OpCode != -1)
2485 cmdp->OpCode = scp->SCp.sent_command; /* special cache cmd. */ 2488 cmdp->OpCode = cmndinfo->OpCode; /* special cache cmd. */
2486 else if (scp->cmnd[0] == RESERVE) 2489 else if (scp->cmnd[0] == RESERVE)
2487 cmdp->OpCode = GDT_RESERVE_DRV; 2490 cmdp->OpCode = GDT_RESERVE_DRV;
2488 else if (scp->cmnd[0] == RELEASE) 2491 else if (scp->cmnd[0] == RELEASE)
@@ -2547,9 +2550,9 @@ static int gdth_fill_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, ushort hdrive)
2547 sl = (struct scatterlist *)scp->request_buffer; 2550 sl = (struct scatterlist *)scp->request_buffer;
2548 sgcnt = scp->use_sg; 2551 sgcnt = scp->use_sg;
2549 scp->SCp.Status = GDTH_MAP_SG; 2552 scp->SCp.Status = GDTH_MAP_SG;
2550 scp->SCp.Message = (read_write == 1 ? 2553 cmndinfo->dma_dir = (read_write == 1 ?
2551 PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); 2554 PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
2552 sgcnt = pci_map_sg(ha->pdev,sl,scp->use_sg,scp->SCp.Message); 2555 sgcnt = pci_map_sg(ha->pdev, sl, scp->use_sg, cmndinfo->dma_dir);
2553 if (mode64) { 2556 if (mode64) {
2554 cmdp->u.cache64.DestAddr= (ulong64)-1; 2557 cmdp->u.cache64.DestAddr= (ulong64)-1;
2555 cmdp->u.cache64.sg_canz = sgcnt; 2558 cmdp->u.cache64.sg_canz = sgcnt;
@@ -2584,12 +2587,12 @@ static int gdth_fill_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, ushort hdrive)
2584 2587
2585 } else if (scp->request_bufflen) { 2588 } else if (scp->request_bufflen) {
2586 scp->SCp.Status = GDTH_MAP_SINGLE; 2589 scp->SCp.Status = GDTH_MAP_SINGLE;
2587 scp->SCp.Message = (read_write == 1 ? 2590 cmndinfo->dma_dir = (read_write == 1 ?
2588 PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); 2591 PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
2589 page = virt_to_page(scp->request_buffer); 2592 page = virt_to_page(scp->request_buffer);
2590 offset = (ulong)scp->request_buffer & ~PAGE_MASK; 2593 offset = (ulong)scp->request_buffer & ~PAGE_MASK;
2591 phys_addr = pci_map_page(ha->pdev,page,offset, 2594 phys_addr = pci_map_page(ha->pdev,page,offset,
2592 scp->request_bufflen,scp->SCp.Message); 2595 scp->request_bufflen, cmndinfo->dma_dir);
2593 scp->SCp.dma_handle = phys_addr; 2596 scp->SCp.dma_handle = phys_addr;
2594 if (mode64) { 2597 if (mode64) {
2595 if (ha->cache_feat & SCATTER_GATHER) { 2598 if (ha->cache_feat & SCATTER_GATHER) {
@@ -2689,17 +2692,17 @@ static int gdth_fill_raw_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, unchar b)
2689 2692
2690 cmndinfo = gdth_cmnd_priv(scp); 2693 cmndinfo = gdth_cmnd_priv(scp);
2691 /* fill command */ 2694 /* fill command */
2692 if (scp->SCp.sent_command != -1) { 2695 if (cmndinfo->OpCode != -1) {
2693 cmdp->OpCode = scp->SCp.sent_command; /* special raw cmd. */ 2696 cmdp->OpCode = cmndinfo->OpCode; /* special raw cmd. */
2694 cmdp->BoardNode = LOCALBOARD; 2697 cmdp->BoardNode = LOCALBOARD;
2695 if (mode64) { 2698 if (mode64) {
2696 cmdp->u.raw64.direction = (scp->SCp.phase >> 8); 2699 cmdp->u.raw64.direction = (cmndinfo->phase >> 8);
2697 TRACE2(("special raw cmd 0x%x param 0x%x\n", 2700 TRACE2(("special raw cmd 0x%x param 0x%x\n",
2698 cmdp->OpCode, cmdp->u.raw64.direction)); 2701 cmdp->OpCode, cmdp->u.raw64.direction));
2699 /* evaluate command size */ 2702 /* evaluate command size */
2700 ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw64.sg_lst); 2703 ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw64.sg_lst);
2701 } else { 2704 } else {
2702 cmdp->u.raw.direction = (scp->SCp.phase >> 8); 2705 cmdp->u.raw.direction = (cmndinfo->phase >> 8);
2703 TRACE2(("special raw cmd 0x%x param 0x%x\n", 2706 TRACE2(("special raw cmd 0x%x param 0x%x\n",
2704 cmdp->OpCode, cmdp->u.raw.direction)); 2707 cmdp->OpCode, cmdp->u.raw.direction));
2705 /* evaluate command size */ 2708 /* evaluate command size */
@@ -2754,8 +2757,8 @@ static int gdth_fill_raw_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, unchar b)
2754 sl = (struct scatterlist *)scp->request_buffer; 2757 sl = (struct scatterlist *)scp->request_buffer;
2755 sgcnt = scp->use_sg; 2758 sgcnt = scp->use_sg;
2756 scp->SCp.Status = GDTH_MAP_SG; 2759 scp->SCp.Status = GDTH_MAP_SG;
2757 scp->SCp.Message = PCI_DMA_BIDIRECTIONAL; 2760 cmndinfo->dma_dir = PCI_DMA_BIDIRECTIONAL;
2758 sgcnt = pci_map_sg(ha->pdev,sl,scp->use_sg,scp->SCp.Message); 2761 sgcnt = pci_map_sg(ha->pdev,sl, scp->use_sg, cmndinfo->dma_dir);
2759 if (mode64) { 2762 if (mode64) {
2760 cmdp->u.raw64.sdata = (ulong64)-1; 2763 cmdp->u.raw64.sdata = (ulong64)-1;
2761 cmdp->u.raw64.sg_ranz = sgcnt; 2764 cmdp->u.raw64.sg_ranz = sgcnt;
@@ -2790,11 +2793,11 @@ static int gdth_fill_raw_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp, unchar b)
2790 2793
2791 } else if (scp->request_bufflen) { 2794 } else if (scp->request_bufflen) {
2792 scp->SCp.Status = GDTH_MAP_SINGLE; 2795 scp->SCp.Status = GDTH_MAP_SINGLE;
2793 scp->SCp.Message = PCI_DMA_BIDIRECTIONAL; 2796 cmndinfo->dma_dir = PCI_DMA_BIDIRECTIONAL;
2794 page = virt_to_page(scp->request_buffer); 2797 page = virt_to_page(scp->request_buffer);
2795 offset = (ulong)scp->request_buffer & ~PAGE_MASK; 2798 offset = (ulong)scp->request_buffer & ~PAGE_MASK;
2796 phys_addr = pci_map_page(ha->pdev,page,offset, 2799 phys_addr = pci_map_page(ha->pdev,page,offset,
2797 scp->request_bufflen,scp->SCp.Message); 2800 scp->request_bufflen, cmndinfo->dma_dir);
2798 scp->SCp.dma_handle = phys_addr; 2801 scp->SCp.dma_handle = phys_addr;
2799 2802
2800 if (mode64) { 2803 if (mode64) {
@@ -3266,7 +3269,7 @@ static irqreturn_t __gdth_interrupt(gdth_ha_str *ha, int irq,
3266 if (!gdth_polling) 3269 if (!gdth_polling)
3267 spin_unlock_irqrestore(&ha->smp_lock, flags); 3270 spin_unlock_irqrestore(&ha->smp_lock, flags);
3268 if (rval == 2) { 3271 if (rval == 2) {
3269 gdth_putq(ha, scp,scp->SCp.this_residual); 3272 gdth_putq(ha, scp, gdth_cmnd_priv(scp)->priority);
3270 } else if (rval == 1) { 3273 } else if (rval == 1) {
3271 gdth_scsi_done(scp); 3274 gdth_scsi_done(scp);
3272 } 3275 }
@@ -3390,60 +3393,60 @@ static int gdth_sync_event(gdth_ha_str *ha, int service, unchar index,
3390 } else { 3393 } else {
3391 b = scp->device->channel; 3394 b = scp->device->channel;
3392 t = scp->device->id; 3395 t = scp->device->id;
3393 if (scp->SCp.sent_command == -1 && b != ha->virt_bus) { 3396 if (cmndinfo->OpCode == -1 && b != ha->virt_bus) {
3394 ha->raw[BUS_L2P(ha,b)].io_cnt[t]--; 3397 ha->raw[BUS_L2P(ha,b)].io_cnt[t]--;
3395 } 3398 }
3396 /* cache or raw service */ 3399 /* cache or raw service */
3397 if (ha->status == S_BSY) { 3400 if (ha->status == S_BSY) {
3398 TRACE2(("Controller busy -> retry !\n")); 3401 TRACE2(("Controller busy -> retry !\n"));
3399 if (scp->SCp.sent_command == GDT_MOUNT) 3402 if (cmndinfo->OpCode == GDT_MOUNT)
3400 scp->SCp.sent_command = GDT_CLUST_INFO; 3403 cmndinfo->OpCode = GDT_CLUST_INFO;
3401 /* retry */ 3404 /* retry */
3402 return 2; 3405 return 2;
3403 } 3406 }
3404 if (scp->SCp.Status == GDTH_MAP_SG) 3407 if (scp->SCp.Status == GDTH_MAP_SG)
3405 pci_unmap_sg(ha->pdev,scp->request_buffer, 3408 pci_unmap_sg(ha->pdev,scp->request_buffer,
3406 scp->use_sg,scp->SCp.Message); 3409 scp->use_sg, cmndinfo->dma_dir);
3407 else if (scp->SCp.Status == GDTH_MAP_SINGLE) 3410 else if (scp->SCp.Status == GDTH_MAP_SINGLE)
3408 pci_unmap_page(ha->pdev,scp->SCp.dma_handle, 3411 pci_unmap_page(ha->pdev,scp->SCp.dma_handle,
3409 scp->request_bufflen,scp->SCp.Message); 3412 scp->request_bufflen, cmndinfo->dma_dir);
3410 if (cmndinfo->sense_paddr) 3413 if (cmndinfo->sense_paddr)
3411 pci_unmap_page(ha->pdev, cmndinfo->sense_paddr, 16, 3414 pci_unmap_page(ha->pdev, cmndinfo->sense_paddr, 16,
3412 PCI_DMA_FROMDEVICE); 3415 PCI_DMA_FROMDEVICE);
3413 3416
3414 if (ha->status == S_OK) { 3417 if (ha->status == S_OK) {
3415 scp->SCp.Status = S_OK; 3418 cmndinfo->status = S_OK;
3416 scp->SCp.Message = ha->info; 3419 cmndinfo->info = ha->info;
3417 if (scp->SCp.sent_command != -1) { 3420 if (cmndinfo->OpCode != -1) {
3418 TRACE2(("gdth_sync_event(): special cmd 0x%x OK\n", 3421 TRACE2(("gdth_sync_event(): special cmd 0x%x OK\n",
3419 scp->SCp.sent_command)); 3422 cmndinfo->OpCode));
3420 /* special commands GDT_CLUST_INFO/GDT_MOUNT ? */ 3423 /* special commands GDT_CLUST_INFO/GDT_MOUNT ? */
3421 if (scp->SCp.sent_command == GDT_CLUST_INFO) { 3424 if (cmndinfo->OpCode == GDT_CLUST_INFO) {
3422 ha->hdr[t].cluster_type = (unchar)ha->info; 3425 ha->hdr[t].cluster_type = (unchar)ha->info;
3423 if (!(ha->hdr[t].cluster_type & 3426 if (!(ha->hdr[t].cluster_type &
3424 CLUSTER_MOUNTED)) { 3427 CLUSTER_MOUNTED)) {
3425 /* NOT MOUNTED -> MOUNT */ 3428 /* NOT MOUNTED -> MOUNT */
3426 scp->SCp.sent_command = GDT_MOUNT; 3429 cmndinfo->OpCode = GDT_MOUNT;
3427 if (ha->hdr[t].cluster_type & 3430 if (ha->hdr[t].cluster_type &
3428 CLUSTER_RESERVED) { 3431 CLUSTER_RESERVED) {
3429 /* cluster drive RESERVED (on the other node) */ 3432 /* cluster drive RESERVED (on the other node) */
3430 scp->SCp.phase = -2; /* reservation conflict */ 3433 cmndinfo->phase = -2; /* reservation conflict */
3431 } 3434 }
3432 } else { 3435 } else {
3433 scp->SCp.sent_command = -1; 3436 cmndinfo->OpCode = -1;
3434 } 3437 }
3435 } else { 3438 } else {
3436 if (scp->SCp.sent_command == GDT_MOUNT) { 3439 if (cmndinfo->OpCode == GDT_MOUNT) {
3437 ha->hdr[t].cluster_type |= CLUSTER_MOUNTED; 3440 ha->hdr[t].cluster_type |= CLUSTER_MOUNTED;
3438 ha->hdr[t].media_changed = TRUE; 3441 ha->hdr[t].media_changed = TRUE;
3439 } else if (scp->SCp.sent_command == GDT_UNMOUNT) { 3442 } else if (cmndinfo->OpCode == GDT_UNMOUNT) {
3440 ha->hdr[t].cluster_type &= ~CLUSTER_MOUNTED; 3443 ha->hdr[t].cluster_type &= ~CLUSTER_MOUNTED;
3441 ha->hdr[t].media_changed = TRUE; 3444 ha->hdr[t].media_changed = TRUE;
3442 } 3445 }
3443 scp->SCp.sent_command = -1; 3446 cmndinfo->OpCode = -1;
3444 } 3447 }
3445 /* retry */ 3448 /* retry */
3446 scp->SCp.this_residual = HIGH_PRI; 3449 cmndinfo->priority = HIGH_PRI;
3447 return 2; 3450 return 2;
3448 } else { 3451 } else {
3449 /* RESERVE/RELEASE ? */ 3452 /* RESERVE/RELEASE ? */
@@ -3456,17 +3459,17 @@ static int gdth_sync_event(gdth_ha_str *ha, int service, unchar index,
3456 scp->sense_buffer[0] = 0; 3459 scp->sense_buffer[0] = 0;
3457 } 3460 }
3458 } else { 3461 } else {
3459 scp->SCp.Status = ha->status; 3462 cmndinfo->status = ha->status;
3460 scp->SCp.Message = ha->info; 3463 cmndinfo->info = ha->info;
3461 3464
3462 if (scp->SCp.sent_command != -1) { 3465 if (cmndinfo->OpCode != -1) {
3463 TRACE2(("gdth_sync_event(): special cmd 0x%x error 0x%x\n", 3466 TRACE2(("gdth_sync_event(): special cmd 0x%x error 0x%x\n",
3464 scp->SCp.sent_command, ha->status)); 3467 cmndinfo->OpCode, ha->status));
3465 if (scp->SCp.sent_command == GDT_SCAN_START || 3468 if (cmndinfo->OpCode == GDT_SCAN_START ||
3466 scp->SCp.sent_command == GDT_SCAN_END) { 3469 cmndinfo->OpCode == GDT_SCAN_END) {
3467 scp->SCp.sent_command = -1; 3470 cmndinfo->OpCode = -1;
3468 /* retry */ 3471 /* retry */
3469 scp->SCp.this_residual = HIGH_PRI; 3472 cmndinfo->priority = HIGH_PRI;
3470 return 2; 3473 return 2;
3471 } 3474 }
3472 memset((char*)scp->sense_buffer,0,16); 3475 memset((char*)scp->sense_buffer,0,16);
@@ -3509,8 +3512,8 @@ static int gdth_sync_event(gdth_ha_str *ha, int service, unchar index,
3509 } 3512 }
3510 } 3513 }
3511 } 3514 }
3512 if (!scp->SCp.have_data_in) 3515 if (!cmndinfo->wait_for_completion)
3513 scp->SCp.have_data_in++; 3516 cmndinfo->wait_for_completion++;
3514 else 3517 else
3515 return 1; 3518 return 1;
3516 } 3519 }
@@ -4042,7 +4045,7 @@ static int gdth_queuecommand(struct scsi_cmnd *scp,
4042 4045
4043 scp->scsi_done = done; 4046 scp->scsi_done = done;
4044 gdth_update_timeout(scp, scp->timeout_per_command * 6); 4047 gdth_update_timeout(scp, scp->timeout_per_command * 6);
4045 scp->SCp.this_residual = DEFAULT_PRI; 4048 cmndinfo->priority = DEFAULT_PRI;
4046 return __gdth_queuecommand(ha, scp, cmndinfo); 4049 return __gdth_queuecommand(ha, scp, cmndinfo);
4047} 4050}
4048 4051
@@ -4050,16 +4053,16 @@ static int __gdth_queuecommand(gdth_ha_str *ha, struct scsi_cmnd *scp,
4050 struct gdth_cmndinfo *cmndinfo) 4053 struct gdth_cmndinfo *cmndinfo)
4051{ 4054{
4052 scp->host_scribble = (unsigned char *)cmndinfo; 4055 scp->host_scribble = (unsigned char *)cmndinfo;
4053 scp->SCp.have_data_in = 1; 4056 cmndinfo->wait_for_completion = 1;
4054 scp->SCp.phase = -1; 4057 cmndinfo->phase = -1;
4055 scp->SCp.sent_command = -1; 4058 cmndinfo->OpCode = -1;
4056 scp->SCp.Status = GDTH_MAP_NONE; 4059 scp->SCp.Status = GDTH_MAP_NONE;
4057 4060
4058#ifdef GDTH_STATISTICS 4061#ifdef GDTH_STATISTICS
4059 ++act_ios; 4062 ++act_ios;
4060#endif 4063#endif
4061 4064
4062 gdth_putq(ha, scp, scp->SCp.this_residual); 4065 gdth_putq(ha, scp, cmndinfo->priority);
4063 gdth_next(ha); 4066 gdth_next(ha);
4064 return 0; 4067 return 0;
4065} 4068}
diff --git a/drivers/scsi/gdth.h b/drivers/scsi/gdth.h
index be4ae5abd5c3..25803a8f31de 100644
--- a/drivers/scsi/gdth.h
+++ b/drivers/scsi/gdth.h
@@ -923,6 +923,14 @@ typedef struct {
923 int index; 923 int index;
924 int internal_command; /* don't call scsi_done */ 924 int internal_command; /* don't call scsi_done */
925 dma_addr_t sense_paddr; /* sense dma-addr */ 925 dma_addr_t sense_paddr; /* sense dma-addr */
926 unchar priority;
927 int timeout;
928 volatile int wait_for_completion;
929 ushort status;
930 ulong32 info;
931 enum dma_data_direction dma_dir;
932 int phase; /* ???? */
933 int OpCode;
926 } cmndinfo[GDTH_MAXCMDS]; /* index==0 is free */ 934 } cmndinfo[GDTH_MAXCMDS]; /* index==0 is free */
927 unchar bus_cnt; /* SCSI bus count */ 935 unchar bus_cnt; /* SCSI bus count */
928 unchar tid_cnt; /* Target ID count */ 936 unchar tid_cnt; /* Target ID count */
diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
index ad1b60dbcf9c..de5773443c62 100644
--- a/drivers/scsi/gdth_proc.c
+++ b/drivers/scsi/gdth_proc.c
@@ -728,20 +728,22 @@ static void gdth_wait_completion(gdth_ha_str *ha, int busnum, int id)
728 ulong flags; 728 ulong flags;
729 int i; 729 int i;
730 Scsi_Cmnd *scp; 730 Scsi_Cmnd *scp;
731 struct gdth_cmndinfo *cmndinfo;
731 unchar b, t; 732 unchar b, t;
732 733
733 spin_lock_irqsave(&ha->smp_lock, flags); 734 spin_lock_irqsave(&ha->smp_lock, flags);
734 735
735 for (i = 0; i < GDTH_MAXCMDS; ++i) { 736 for (i = 0; i < GDTH_MAXCMDS; ++i) {
736 scp = ha->cmd_tab[i].cmnd; 737 scp = ha->cmd_tab[i].cmnd;
738 cmndinfo = gdth_cmnd_priv(scp);
737 739
738 b = scp->device->channel; 740 b = scp->device->channel;
739 t = scp->device->id; 741 t = scp->device->id;
740 if (!SPECIAL_SCP(scp) && t == (unchar)id && 742 if (!SPECIAL_SCP(scp) && t == (unchar)id &&
741 b == (unchar)busnum) { 743 b == (unchar)busnum) {
742 scp->SCp.have_data_in = 0; 744 cmndinfo->wait_for_completion = 0;
743 spin_unlock_irqrestore(&ha->smp_lock, flags); 745 spin_unlock_irqrestore(&ha->smp_lock, flags);
744 while (!scp->SCp.have_data_in) 746 while (!cmndinfo->wait_for_completion)
745 barrier(); 747 barrier();
746 spin_lock_irqsave(&ha->smp_lock, flags); 748 spin_lock_irqsave(&ha->smp_lock, flags);
747 } 749 }
@@ -764,7 +766,7 @@ static void gdth_stop_timeout(gdth_ha_str *ha, int busnum, int id)
764 t = scp->device->id; 766 t = scp->device->id;
765 if (t == (unchar)id && b == (unchar)busnum) { 767 if (t == (unchar)id && b == (unchar)busnum) {
766 TRACE2(("gdth_stop_timeout(): update_timeout()\n")); 768 TRACE2(("gdth_stop_timeout(): update_timeout()\n"));
767 scp->SCp.buffers_residual = gdth_update_timeout(scp, 0); 769 cmndinfo->timeout = gdth_update_timeout(scp, 0);
768 } 770 }
769 } 771 }
770 } 772 }
@@ -786,7 +788,7 @@ static void gdth_start_timeout(gdth_ha_str *ha, int busnum, int id)
786 t = scp->device->id; 788 t = scp->device->id;
787 if (t == (unchar)id && b == (unchar)busnum) { 789 if (t == (unchar)id && b == (unchar)busnum) {
788 TRACE2(("gdth_start_timeout(): update_timeout()\n")); 790 TRACE2(("gdth_start_timeout(): update_timeout()\n"));
789 gdth_update_timeout(scp, scp->SCp.buffers_residual); 791 gdth_update_timeout(scp, cmndinfo->timeout);
790 } 792 }
791 } 793 }
792 } 794 }