aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2007-05-25 13:00:42 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2007-06-17 13:04:36 -0400
commit727eead62e22cf0a9498cf34e075c08269402978 (patch)
tree05835453a61f23932dc5dd7a7c095be2347c1e5a /drivers
parent2f4cf91cc0a1f32f75e1fa0a4d70a9bc7340a302 (diff)
[SCSI] aacraid: convert to use the data buffer accessors
- remove the unnecessary map_single path. - convert to use the new accessors for the sg lists and the parameters. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Acked-by: "Salyzyn, Mark" <mark_salyzyn@adaptec.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/aacraid/aachba.c166
1 files changed, 49 insertions, 117 deletions
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 47014beef96e..2dbfbe3cf453 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -344,21 +344,16 @@ static void aac_internal_transfer(struct scsi_cmnd *scsicmd, void *data, unsigne
344{ 344{
345 void *buf; 345 void *buf;
346 int transfer_len; 346 int transfer_len;
347 struct scatterlist *sg = scsicmd->request_buffer; 347 struct scatterlist *sg = scsi_sglist(scsicmd);
348
349 buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset;
350 transfer_len = min(sg->length, len + offset);
348 351
349 if (scsicmd->use_sg) {
350 buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset;
351 transfer_len = min(sg->length, len + offset);
352 } else {
353 buf = scsicmd->request_buffer;
354 transfer_len = min(scsicmd->request_bufflen, len + offset);
355 }
356 transfer_len -= offset; 352 transfer_len -= offset;
357 if (buf && transfer_len > 0) 353 if (buf && transfer_len > 0)
358 memcpy(buf + offset, data, transfer_len); 354 memcpy(buf + offset, data, transfer_len);
359 355
360 if (scsicmd->use_sg) 356 kunmap_atomic(buf - sg->offset, KM_IRQ0);
361 kunmap_atomic(buf - sg->offset, KM_IRQ0);
362 357
363} 358}
364 359
@@ -1043,7 +1038,7 @@ static int aac_scsi_64(struct fib * fib, struct scsi_cmnd * cmd)
1043 struct aac_srb * srbcmd = aac_scsi_common(fib, cmd); 1038 struct aac_srb * srbcmd = aac_scsi_common(fib, cmd);
1044 1039
1045 aac_build_sg64(cmd, (struct sgmap64*) &srbcmd->sg); 1040 aac_build_sg64(cmd, (struct sgmap64*) &srbcmd->sg);
1046 srbcmd->count = cpu_to_le32(cmd->request_bufflen); 1041 srbcmd->count = cpu_to_le32(scsi_bufflen(cmd));
1047 1042
1048 memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb)); 1043 memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb));
1049 memcpy(srbcmd->cdb, cmd->cmnd, cmd->cmd_len); 1044 memcpy(srbcmd->cdb, cmd->cmnd, cmd->cmd_len);
@@ -1071,7 +1066,7 @@ static int aac_scsi_32(struct fib * fib, struct scsi_cmnd * cmd)
1071 struct aac_srb * srbcmd = aac_scsi_common(fib, cmd); 1066 struct aac_srb * srbcmd = aac_scsi_common(fib, cmd);
1072 1067
1073 aac_build_sg(cmd, (struct sgmap*)&srbcmd->sg); 1068 aac_build_sg(cmd, (struct sgmap*)&srbcmd->sg);
1074 srbcmd->count = cpu_to_le32(cmd->request_bufflen); 1069 srbcmd->count = cpu_to_le32(scsi_bufflen(cmd));
1075 1070
1076 memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb)); 1071 memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb));
1077 memcpy(srbcmd->cdb, cmd->cmnd, cmd->cmd_len); 1072 memcpy(srbcmd->cdb, cmd->cmnd, cmd->cmd_len);
@@ -1373,16 +1368,9 @@ static void io_callback(void *context, struct fib * fibptr)
1373 } 1368 }
1374 1369
1375 BUG_ON(fibptr == NULL); 1370 BUG_ON(fibptr == NULL);
1376 1371
1377 if(scsicmd->use_sg) 1372 scsi_dma_unmap(scsicmd);
1378 pci_unmap_sg(dev->pdev, 1373
1379 (struct scatterlist *)scsicmd->request_buffer,
1380 scsicmd->use_sg,
1381 scsicmd->sc_data_direction);
1382 else if(scsicmd->request_bufflen)
1383 pci_unmap_single(dev->pdev, scsicmd->SCp.dma_handle,
1384 scsicmd->request_bufflen,
1385 scsicmd->sc_data_direction);
1386 readreply = (struct aac_read_reply *)fib_data(fibptr); 1374 readreply = (struct aac_read_reply *)fib_data(fibptr);
1387 if (le32_to_cpu(readreply->status) == ST_OK) 1375 if (le32_to_cpu(readreply->status) == ST_OK)
1388 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; 1376 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
@@ -2182,18 +2170,11 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
2182 /* 2170 /*
2183 * Calculate resid for sg 2171 * Calculate resid for sg
2184 */ 2172 */
2185 2173
2186 scsicmd->resid = scsicmd->request_bufflen - 2174 scsi_set_resid(scsicmd, scsi_bufflen(scsicmd)
2187 le32_to_cpu(srbreply->data_xfer_length); 2175 - le32_to_cpu(srbreply->data_xfer_length));
2188 2176
2189 if(scsicmd->use_sg) 2177 scsi_dma_unmap(scsicmd);
2190 pci_unmap_sg(dev->pdev,
2191 (struct scatterlist *)scsicmd->request_buffer,
2192 scsicmd->use_sg,
2193 scsicmd->sc_data_direction);
2194 else if(scsicmd->request_bufflen)
2195 pci_unmap_single(dev->pdev, scsicmd->SCp.dma_handle, scsicmd->request_bufflen,
2196 scsicmd->sc_data_direction);
2197 2178
2198 /* 2179 /*
2199 * First check the fib status 2180 * First check the fib status
@@ -2379,34 +2360,33 @@ static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* psg)
2379{ 2360{
2380 struct aac_dev *dev; 2361 struct aac_dev *dev;
2381 unsigned long byte_count = 0; 2362 unsigned long byte_count = 0;
2363 int nseg;
2382 2364
2383 dev = (struct aac_dev *)scsicmd->device->host->hostdata; 2365 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
2384 // Get rid of old data 2366 // Get rid of old data
2385 psg->count = 0; 2367 psg->count = 0;
2386 psg->sg[0].addr = 0; 2368 psg->sg[0].addr = 0;
2387 psg->sg[0].count = 0; 2369 psg->sg[0].count = 0;
2388 if (scsicmd->use_sg) { 2370
2371 nseg = scsi_dma_map(scsicmd);
2372 BUG_ON(nseg < 0);
2373 if (nseg) {
2389 struct scatterlist *sg; 2374 struct scatterlist *sg;
2390 int i; 2375 int i;
2391 int sg_count;
2392 sg = (struct scatterlist *) scsicmd->request_buffer;
2393 2376
2394 sg_count = pci_map_sg(dev->pdev, sg, scsicmd->use_sg, 2377 psg->count = cpu_to_le32(nseg);
2395 scsicmd->sc_data_direction);
2396 psg->count = cpu_to_le32(sg_count);
2397 2378
2398 for (i = 0; i < sg_count; i++) { 2379 scsi_for_each_sg(scsicmd, sg, nseg, i) {
2399 psg->sg[i].addr = cpu_to_le32(sg_dma_address(sg)); 2380 psg->sg[i].addr = cpu_to_le32(sg_dma_address(sg));
2400 psg->sg[i].count = cpu_to_le32(sg_dma_len(sg)); 2381 psg->sg[i].count = cpu_to_le32(sg_dma_len(sg));
2401 byte_count += sg_dma_len(sg); 2382 byte_count += sg_dma_len(sg);
2402 sg++;
2403 } 2383 }
2404 /* hba wants the size to be exact */ 2384 /* hba wants the size to be exact */
2405 if(byte_count > scsicmd->request_bufflen){ 2385 if (byte_count > scsi_bufflen(scsicmd)) {
2406 u32 temp = le32_to_cpu(psg->sg[i-1].count) - 2386 u32 temp = le32_to_cpu(psg->sg[i-1].count) -
2407 (byte_count - scsicmd->request_bufflen); 2387 (byte_count - scsi_bufflen(scsicmd));
2408 psg->sg[i-1].count = cpu_to_le32(temp); 2388 psg->sg[i-1].count = cpu_to_le32(temp);
2409 byte_count = scsicmd->request_bufflen; 2389 byte_count = scsi_bufflen(scsicmd);
2410 } 2390 }
2411 /* Check for command underflow */ 2391 /* Check for command underflow */
2412 if(scsicmd->underflow && (byte_count < scsicmd->underflow)){ 2392 if(scsicmd->underflow && (byte_count < scsicmd->underflow)){
@@ -2414,18 +2394,6 @@ static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* psg)
2414 byte_count, scsicmd->underflow); 2394 byte_count, scsicmd->underflow);
2415 } 2395 }
2416 } 2396 }
2417 else if(scsicmd->request_bufflen) {
2418 u32 addr;
2419 scsicmd->SCp.dma_handle = pci_map_single(dev->pdev,
2420 scsicmd->request_buffer,
2421 scsicmd->request_bufflen,
2422 scsicmd->sc_data_direction);
2423 addr = scsicmd->SCp.dma_handle;
2424 psg->count = cpu_to_le32(1);
2425 psg->sg[0].addr = cpu_to_le32(addr);
2426 psg->sg[0].count = cpu_to_le32(scsicmd->request_bufflen);
2427 byte_count = scsicmd->request_bufflen;
2428 }
2429 return byte_count; 2397 return byte_count;
2430} 2398}
2431 2399
@@ -2435,6 +2403,7 @@ static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* p
2435 struct aac_dev *dev; 2403 struct aac_dev *dev;
2436 unsigned long byte_count = 0; 2404 unsigned long byte_count = 0;
2437 u64 addr; 2405 u64 addr;
2406 int nseg;
2438 2407
2439 dev = (struct aac_dev *)scsicmd->device->host->hostdata; 2408 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
2440 // Get rid of old data 2409 // Get rid of old data
@@ -2442,31 +2411,28 @@ static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* p
2442 psg->sg[0].addr[0] = 0; 2411 psg->sg[0].addr[0] = 0;
2443 psg->sg[0].addr[1] = 0; 2412 psg->sg[0].addr[1] = 0;
2444 psg->sg[0].count = 0; 2413 psg->sg[0].count = 0;
2445 if (scsicmd->use_sg) { 2414
2415 nseg = scsi_dma_map(scsicmd);
2416 BUG_ON(nseg < 0);
2417 if (nseg) {
2446 struct scatterlist *sg; 2418 struct scatterlist *sg;
2447 int i; 2419 int i;
2448 int sg_count;
2449 sg = (struct scatterlist *) scsicmd->request_buffer;
2450
2451 sg_count = pci_map_sg(dev->pdev, sg, scsicmd->use_sg,
2452 scsicmd->sc_data_direction);
2453 2420
2454 for (i = 0; i < sg_count; i++) { 2421 scsi_for_each_sg(scsicmd, sg, nseg, i) {
2455 int count = sg_dma_len(sg); 2422 int count = sg_dma_len(sg);
2456 addr = sg_dma_address(sg); 2423 addr = sg_dma_address(sg);
2457 psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff); 2424 psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff);
2458 psg->sg[i].addr[1] = cpu_to_le32(addr>>32); 2425 psg->sg[i].addr[1] = cpu_to_le32(addr>>32);
2459 psg->sg[i].count = cpu_to_le32(count); 2426 psg->sg[i].count = cpu_to_le32(count);
2460 byte_count += count; 2427 byte_count += count;
2461 sg++;
2462 } 2428 }
2463 psg->count = cpu_to_le32(sg_count); 2429 psg->count = cpu_to_le32(nseg);
2464 /* hba wants the size to be exact */ 2430 /* hba wants the size to be exact */
2465 if(byte_count > scsicmd->request_bufflen){ 2431 if (byte_count > scsi_bufflen(scsicmd)) {
2466 u32 temp = le32_to_cpu(psg->sg[i-1].count) - 2432 u32 temp = le32_to_cpu(psg->sg[i-1].count) -
2467 (byte_count - scsicmd->request_bufflen); 2433 (byte_count - scsi_bufflen(scsicmd));
2468 psg->sg[i-1].count = cpu_to_le32(temp); 2434 psg->sg[i-1].count = cpu_to_le32(temp);
2469 byte_count = scsicmd->request_bufflen; 2435 byte_count = scsi_bufflen(scsicmd);
2470 } 2436 }
2471 /* Check for command underflow */ 2437 /* Check for command underflow */
2472 if(scsicmd->underflow && (byte_count < scsicmd->underflow)){ 2438 if(scsicmd->underflow && (byte_count < scsicmd->underflow)){
@@ -2474,26 +2440,13 @@ static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* p
2474 byte_count, scsicmd->underflow); 2440 byte_count, scsicmd->underflow);
2475 } 2441 }
2476 } 2442 }
2477 else if(scsicmd->request_bufflen) {
2478 scsicmd->SCp.dma_handle = pci_map_single(dev->pdev,
2479 scsicmd->request_buffer,
2480 scsicmd->request_bufflen,
2481 scsicmd->sc_data_direction);
2482 addr = scsicmd->SCp.dma_handle;
2483 psg->count = cpu_to_le32(1);
2484 psg->sg[0].addr[0] = cpu_to_le32(addr & 0xffffffff);
2485 psg->sg[0].addr[1] = cpu_to_le32(addr >> 32);
2486 psg->sg[0].count = cpu_to_le32(scsicmd->request_bufflen);
2487 byte_count = scsicmd->request_bufflen;
2488 }
2489 return byte_count; 2443 return byte_count;
2490} 2444}
2491 2445
2492static unsigned long aac_build_sgraw(struct scsi_cmnd* scsicmd, struct sgmapraw* psg) 2446static unsigned long aac_build_sgraw(struct scsi_cmnd* scsicmd, struct sgmapraw* psg)
2493{ 2447{
2494 struct Scsi_Host *host = scsicmd->device->host;
2495 struct aac_dev *dev = (struct aac_dev *)host->hostdata;
2496 unsigned long byte_count = 0; 2448 unsigned long byte_count = 0;
2449 int nseg;
2497 2450
2498 // Get rid of old data 2451 // Get rid of old data
2499 psg->count = 0; 2452 psg->count = 0;
@@ -2503,16 +2456,14 @@ static unsigned long aac_build_sgraw(struct scsi_cmnd* scsicmd, struct sgmapraw*
2503 psg->sg[0].addr[1] = 0; 2456 psg->sg[0].addr[1] = 0;
2504 psg->sg[0].count = 0; 2457 psg->sg[0].count = 0;
2505 psg->sg[0].flags = 0; 2458 psg->sg[0].flags = 0;
2506 if (scsicmd->use_sg) { 2459
2460 nseg = scsi_dma_map(scsicmd);
2461 BUG_ON(nseg < 0);
2462 if (nseg) {
2507 struct scatterlist *sg; 2463 struct scatterlist *sg;
2508 int i; 2464 int i;
2509 int sg_count;
2510 sg = (struct scatterlist *) scsicmd->request_buffer;
2511 2465
2512 sg_count = pci_map_sg(dev->pdev, sg, scsicmd->use_sg, 2466 scsi_for_each_sg(scsicmd, sg, nseg, i) {
2513 scsicmd->sc_data_direction);
2514
2515 for (i = 0; i < sg_count; i++) {
2516 int count = sg_dma_len(sg); 2467 int count = sg_dma_len(sg);
2517 u64 addr = sg_dma_address(sg); 2468 u64 addr = sg_dma_address(sg);
2518 psg->sg[i].next = 0; 2469 psg->sg[i].next = 0;
@@ -2522,15 +2473,14 @@ static unsigned long aac_build_sgraw(struct scsi_cmnd* scsicmd, struct sgmapraw*
2522 psg->sg[i].count = cpu_to_le32(count); 2473 psg->sg[i].count = cpu_to_le32(count);
2523 psg->sg[i].flags = 0; 2474 psg->sg[i].flags = 0;
2524 byte_count += count; 2475 byte_count += count;
2525 sg++;
2526 } 2476 }
2527 psg->count = cpu_to_le32(sg_count); 2477 psg->count = cpu_to_le32(nseg);
2528 /* hba wants the size to be exact */ 2478 /* hba wants the size to be exact */
2529 if(byte_count > scsicmd->request_bufflen){ 2479 if (byte_count > scsi_bufflen(scsicmd)) {
2530 u32 temp = le32_to_cpu(psg->sg[i-1].count) - 2480 u32 temp = le32_to_cpu(psg->sg[i-1].count) -
2531 (byte_count - scsicmd->request_bufflen); 2481 (byte_count - scsi_bufflen(scsicmd));
2532 psg->sg[i-1].count = cpu_to_le32(temp); 2482 psg->sg[i-1].count = cpu_to_le32(temp);
2533 byte_count = scsicmd->request_bufflen; 2483 byte_count = scsi_bufflen(scsicmd);
2534 } 2484 }
2535 /* Check for command underflow */ 2485 /* Check for command underflow */
2536 if(scsicmd->underflow && (byte_count < scsicmd->underflow)){ 2486 if(scsicmd->underflow && (byte_count < scsicmd->underflow)){
@@ -2538,24 +2488,6 @@ static unsigned long aac_build_sgraw(struct scsi_cmnd* scsicmd, struct sgmapraw*
2538 byte_count, scsicmd->underflow); 2488 byte_count, scsicmd->underflow);
2539 } 2489 }
2540 } 2490 }
2541 else if(scsicmd->request_bufflen) {
2542 int count;
2543 u64 addr;
2544 scsicmd->SCp.dma_handle = pci_map_single(dev->pdev,
2545 scsicmd->request_buffer,
2546 scsicmd->request_bufflen,
2547 scsicmd->sc_data_direction);
2548 addr = scsicmd->SCp.dma_handle;
2549 count = scsicmd->request_bufflen;
2550 psg->count = cpu_to_le32(1);
2551 psg->sg[0].next = 0;
2552 psg->sg[0].prev = 0;
2553 psg->sg[0].addr[1] = cpu_to_le32((u32)(addr>>32));
2554 psg->sg[0].addr[0] = cpu_to_le32((u32)(addr & 0xffffffff));
2555 psg->sg[0].count = cpu_to_le32(count);
2556 psg->sg[0].flags = 0;
2557 byte_count = scsicmd->request_bufflen;
2558 }
2559 return byte_count; 2491 return byte_count;
2560} 2492}
2561 2493