[SCSI] aic7xxx: remove the completeq

This should finish the spurious queue removal from aic7xxx (there are
other queues that are probably unnecessary, but at least the major and
obviously unnecessary ones are done with).

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by James Bottomley and committed by James Bottomley 8e45ebcc 38c29ce0

+5 -133
+2 -119
drivers/scsi/aic7xxx/aic7xxx_osm.c
··· 433 static void ahc_linux_dev_timed_unfreeze(u_long arg); 434 static int ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag); 435 static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc); 436 - static void ahc_linux_thread_run_complete_queue(struct ahc_softc *ahc); 437 static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc, 438 struct ahc_devinfo *devinfo); 439 static void ahc_linux_device_queue_depth(struct ahc_softc *ahc, ··· 453 static aic_option_callback_t ahc_linux_setup_tag_info; 454 static int aic7xxx_setup(char *s); 455 static int ahc_linux_next_unit(void); 456 - static struct ahc_cmd *ahc_linux_run_complete_queue(struct ahc_softc *ahc); 457 458 /********************************* Inlines ************************************/ 459 static __inline struct ahc_linux_device* 460 ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, 461 u_int target, u_int lun, int alloc); 462 - static __inline void ahc_schedule_completeq(struct ahc_softc *ahc); 463 static __inline void ahc_linux_unmap_scb(struct ahc_softc*, struct scb*); 464 465 static __inline int ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb, 466 struct ahc_dma_seg *sg, 467 dma_addr_t addr, bus_size_t len); 468 - 469 - static __inline void 470 - ahc_schedule_completeq(struct ahc_softc *ahc) 471 - { 472 - if ((ahc->platform_data->flags & AHC_RUN_CMPLT_Q_TIMER) == 0) { 473 - ahc->platform_data->flags |= AHC_RUN_CMPLT_Q_TIMER; 474 - ahc->platform_data->completeq_timer.expires = jiffies; 475 - add_timer(&ahc->platform_data->completeq_timer); 476 - } 477 - } 478 479 static __inline struct ahc_linux_device* 480 ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, u_int target, ··· 488 if (dev == NULL && alloc != 0) 489 dev = ahc_linux_alloc_device(ahc, targ, lun); 490 return (dev); 491 - } 492 - 493 - #define AHC_LINUX_MAX_RETURNED_ERRORS 4 494 - static struct ahc_cmd * 495 - ahc_linux_run_complete_queue(struct ahc_softc *ahc) 496 - { 497 - struct ahc_cmd *acmd; 498 - int with_errors; 499 - 500 - with_errors = 0; 501 - while ((acmd = TAILQ_FIRST(&ahc->platform_data->completeq)) != NULL) { 502 - struct scsi_cmnd *cmd; 503 - 504 - if (with_errors > AHC_LINUX_MAX_RETURNED_ERRORS) { 505 - /* 506 - * Linux uses stack recursion to requeue 507 - * commands that need to be retried. Avoid 508 - * blowing out the stack by "spoon feeding" 509 - * commands that completed with error back 510 - * the operating system in case they are going 511 - * to be retried. "ick" 512 - */ 513 - ahc_schedule_completeq(ahc); 514 - break; 515 - } 516 - TAILQ_REMOVE(&ahc->platform_data->completeq, 517 - acmd, acmd_links.tqe); 518 - cmd = &acmd_scsi_cmd(acmd); 519 - cmd->host_scribble = NULL; 520 - if (ahc_cmd_get_transaction_status(cmd) != DID_OK 521 - || (cmd->result & 0xFF) != SCSI_STATUS_OK) 522 - with_errors++; 523 - 524 - cmd->scsi_done(cmd); 525 - } 526 - return (acmd); 527 } 528 529 static __inline void ··· 807 ahc = *(struct ahc_softc **)cmd->device->host->hostdata; 808 found = ahc_reset_channel(ahc, cmd->device->channel + 'A', 809 /*initiate reset*/TRUE); 810 - ahc_linux_run_complete_queue(ahc); 811 812 if (bootverbose) 813 printf("%s: SCSI bus reset delivered. " ··· 1281 if (ahc->platform_data == NULL) 1282 return (ENOMEM); 1283 memset(ahc->platform_data, 0, sizeof(struct ahc_platform_data)); 1284 - TAILQ_INIT(&ahc->platform_data->completeq); 1285 ahc->platform_data->irq = AHC_LINUX_NOIRQ; 1286 ahc_lockinit(ahc); 1287 - init_timer(&ahc->platform_data->completeq_timer); 1288 - ahc->platform_data->completeq_timer.data = (u_long)ahc; 1289 - ahc->platform_data->completeq_timer.function = 1290 - (ahc_linux_callback_t *)ahc_linux_thread_run_complete_queue; 1291 init_MUTEX_LOCKED(&ahc->platform_data->eh_sem); 1292 ahc->seltime = (aic7xxx_seltime & 0x3) << 4; 1293 ahc->seltime_b = (aic7xxx_seltime & 0x3) << 4; ··· 1300 int i, j; 1301 1302 if (ahc->platform_data != NULL) { 1303 - del_timer_sync(&ahc->platform_data->completeq_timer); 1304 if (ahc->platform_data->host != NULL) { 1305 scsi_remove_host(ahc->platform_data->host); 1306 scsi_host_put(ahc->platform_data->host); ··· 1446 int lun, u_int tag, role_t role, uint32_t status) 1447 { 1448 return 0; 1449 - } 1450 - 1451 - static void 1452 - ahc_linux_thread_run_complete_queue(struct ahc_softc *ahc) 1453 - { 1454 - u_long flags; 1455 - 1456 - ahc_lock(ahc, &flags); 1457 - del_timer(&ahc->platform_data->completeq_timer); 1458 - ahc->platform_data->flags &= ~AHC_RUN_CMPLT_Q_TIMER; 1459 - ahc_linux_run_complete_queue(ahc); 1460 - ahc_unlock(ahc, &flags); 1461 } 1462 1463 static u_int ··· 1717 ahc = (struct ahc_softc *) dev_id; 1718 ahc_lock(ahc, &flags); 1719 ours = ahc_intr(ahc); 1720 - ahc_linux_run_complete_queue(ahc); 1721 ahc_unlock(ahc, &flags); 1722 return IRQ_RETVAL(ours); 1723 } ··· 1725 ahc_platform_flushwork(struct ahc_softc *ahc) 1726 { 1727 1728 - while (ahc_linux_run_complete_queue(ahc) != NULL) 1729 - ; 1730 } 1731 1732 static struct ahc_linux_target* ··· 2204 ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, struct scsi_cmnd *cmd) 2205 { 2206 /* 2207 - * Typically, the complete queue has very few entries 2208 - * queued to it before the queue is emptied by 2209 - * ahc_linux_run_complete_queue, so sorting the entries 2210 - * by generation number should be inexpensive. 2211 - * We perform the sort so that commands that complete 2212 - * with an error are retuned in the order origionally 2213 - * queued to the controller so that any subsequent retries 2214 - * are performed in order. The underlying ahc routines do 2215 - * not guarantee the order that aborted commands will be 2216 - * returned to us. 2217 - */ 2218 - struct ahc_completeq *completeq; 2219 - struct ahc_cmd *list_cmd; 2220 - struct ahc_cmd *acmd; 2221 - 2222 - /* 2223 * Map CAM error codes into Linux Error codes. We 2224 * avoid the conversion so that the DV code has the 2225 * full error information available when making ··· 2256 new_status = DID_ERROR; 2257 break; 2258 case CAM_REQUEUE_REQ: 2259 - /* 2260 - * If we want the request requeued, make sure there 2261 - * are sufficent retries. In the old scsi error code, 2262 - * we used to be able to specify a result code that 2263 - * bypassed the retry count. Now we must use this 2264 - * hack. We also "fake" a check condition with 2265 - * a sense code of ABORTED COMMAND. This seems to 2266 - * evoke a retry even if this command is being sent 2267 - * via the eh thread. Ick! Ick! Ick! 2268 - */ 2269 - if (cmd->retries > 0) 2270 - cmd->retries--; 2271 - new_status = DID_OK; 2272 - ahc_cmd_set_scsi_status(cmd, SCSI_STATUS_CHECK_COND); 2273 - cmd->result |= (DRIVER_SENSE << 24); 2274 - memset(cmd->sense_buffer, 0, 2275 - sizeof(cmd->sense_buffer)); 2276 - cmd->sense_buffer[0] = SSD_ERRCODE_VALID 2277 - | SSD_CURRENT_ERROR; 2278 - cmd->sense_buffer[2] = SSD_KEY_ABORTED_COMMAND; 2279 break; 2280 default: 2281 /* We should never get here */ ··· 2267 ahc_cmd_set_transaction_status(cmd, new_status); 2268 } 2269 2270 - completeq = &ahc->platform_data->completeq; 2271 - list_cmd = TAILQ_FIRST(completeq); 2272 - acmd = (struct ahc_cmd *)cmd; 2273 - while (list_cmd != NULL 2274 - && acmd_scsi_cmd(list_cmd).serial_number 2275 - < acmd_scsi_cmd(acmd).serial_number) 2276 - list_cmd = TAILQ_NEXT(list_cmd, acmd_links.tqe); 2277 - if (list_cmd != NULL) 2278 - TAILQ_INSERT_BEFORE(list_cmd, acmd, acmd_links.tqe); 2279 - else 2280 - TAILQ_INSERT_TAIL(completeq, acmd, acmd_links.tqe); 2281 } 2282 2283 static void ··· 2631 } 2632 spin_lock_irq(&ahc->platform_data->spin_lock); 2633 } 2634 - ahc_linux_run_complete_queue(ahc); 2635 return (retval); 2636 } 2637
··· 433 static void ahc_linux_dev_timed_unfreeze(u_long arg); 434 static int ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag); 435 static void ahc_linux_initialize_scsi_bus(struct ahc_softc *ahc); 436 static u_int ahc_linux_user_tagdepth(struct ahc_softc *ahc, 437 struct ahc_devinfo *devinfo); 438 static void ahc_linux_device_queue_depth(struct ahc_softc *ahc, ··· 454 static aic_option_callback_t ahc_linux_setup_tag_info; 455 static int aic7xxx_setup(char *s); 456 static int ahc_linux_next_unit(void); 457 458 /********************************* Inlines ************************************/ 459 static __inline struct ahc_linux_device* 460 ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, 461 u_int target, u_int lun, int alloc); 462 static __inline void ahc_linux_unmap_scb(struct ahc_softc*, struct scb*); 463 464 static __inline int ahc_linux_map_seg(struct ahc_softc *ahc, struct scb *scb, 465 struct ahc_dma_seg *sg, 466 dma_addr_t addr, bus_size_t len); 467 468 static __inline struct ahc_linux_device* 469 ahc_linux_get_device(struct ahc_softc *ahc, u_int channel, u_int target, ··· 501 if (dev == NULL && alloc != 0) 502 dev = ahc_linux_alloc_device(ahc, targ, lun); 503 return (dev); 504 } 505 506 static __inline void ··· 856 ahc = *(struct ahc_softc **)cmd->device->host->hostdata; 857 found = ahc_reset_channel(ahc, cmd->device->channel + 'A', 858 /*initiate reset*/TRUE); 859 860 if (bootverbose) 861 printf("%s: SCSI bus reset delivered. " ··· 1331 if (ahc->platform_data == NULL) 1332 return (ENOMEM); 1333 memset(ahc->platform_data, 0, sizeof(struct ahc_platform_data)); 1334 ahc->platform_data->irq = AHC_LINUX_NOIRQ; 1335 ahc_lockinit(ahc); 1336 init_MUTEX_LOCKED(&ahc->platform_data->eh_sem); 1337 ahc->seltime = (aic7xxx_seltime & 0x3) << 4; 1338 ahc->seltime_b = (aic7xxx_seltime & 0x3) << 4; ··· 1355 int i, j; 1356 1357 if (ahc->platform_data != NULL) { 1358 if (ahc->platform_data->host != NULL) { 1359 scsi_remove_host(ahc->platform_data->host); 1360 scsi_host_put(ahc->platform_data->host); ··· 1502 int lun, u_int tag, role_t role, uint32_t status) 1503 { 1504 return 0; 1505 } 1506 1507 static u_int ··· 1785 ahc = (struct ahc_softc *) dev_id; 1786 ahc_lock(ahc, &flags); 1787 ours = ahc_intr(ahc); 1788 ahc_unlock(ahc, &flags); 1789 return IRQ_RETVAL(ours); 1790 } ··· 1794 ahc_platform_flushwork(struct ahc_softc *ahc) 1795 { 1796 1797 } 1798 1799 static struct ahc_linux_target* ··· 2275 ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, struct scsi_cmnd *cmd) 2276 { 2277 /* 2278 * Map CAM error codes into Linux Error codes. We 2279 * avoid the conversion so that the DV code has the 2280 * full error information available when making ··· 2343 new_status = DID_ERROR; 2344 break; 2345 case CAM_REQUEUE_REQ: 2346 + new_status = DID_REQUEUE; 2347 break; 2348 default: 2349 /* We should never get here */ ··· 2373 ahc_cmd_set_transaction_status(cmd, new_status); 2374 } 2375 2376 + cmd->scsi_done(cmd); 2377 } 2378 2379 static void ··· 2747 } 2748 spin_lock_irq(&ahc->platform_data->spin_lock); 2749 } 2750 return (retval); 2751 } 2752
+3 -14
drivers/scsi/aic7xxx/aic7xxx_osm.h
··· 436 /* 437 * Per-SCB OSM storage. 438 */ 439 - typedef enum { 440 - AHC_UP_EH_SEMAPHORE = 0x1 441 - } ahc_linux_scb_flags; 442 - 443 struct scb_platform_data { 444 struct ahc_linux_device *dev; 445 dma_addr_t buf_busaddr; 446 uint32_t xfer_len; 447 uint32_t sense_resid; /* Auto-Sense residual */ 448 - ahc_linux_scb_flags flags; 449 }; 450 451 /* ··· 449 * alignment restrictions of the various platforms supported by 450 * this driver. 451 */ 452 - typedef enum { 453 - AHC_RUN_CMPLT_Q_TIMER = 0x10 454 - } ahc_linux_softc_flags; 455 - 456 - TAILQ_HEAD(ahc_completeq, ahc_cmd); 457 - 458 struct ahc_platform_data { 459 /* 460 * Fields accessed from interrupt context. 461 */ 462 struct ahc_linux_target *targets[AHC_NUM_TARGETS]; 463 - struct ahc_completeq completeq; 464 465 spinlock_t spin_lock; 466 u_int qfrozen; 467 - struct timer_list completeq_timer; 468 struct timer_list reset_timer; 469 struct semaphore eh_sem; 470 struct Scsi_Host *host; /* pointer to scsi host */ ··· 464 uint32_t irq; /* IRQ for this adapter */ 465 uint32_t bios_address; 466 uint32_t mem_busaddr; /* Mem Base Addr */ 467 - ahc_linux_softc_flags flags; 468 }; 469 470 /************************** OS Utility Wrappers *******************************/
··· 436 /* 437 * Per-SCB OSM storage. 438 */ 439 struct scb_platform_data { 440 struct ahc_linux_device *dev; 441 dma_addr_t buf_busaddr; 442 uint32_t xfer_len; 443 uint32_t sense_resid; /* Auto-Sense residual */ 444 }; 445 446 /* ··· 454 * alignment restrictions of the various platforms supported by 455 * this driver. 456 */ 457 struct ahc_platform_data { 458 /* 459 * Fields accessed from interrupt context. 460 */ 461 struct ahc_linux_target *targets[AHC_NUM_TARGETS]; 462 463 spinlock_t spin_lock; 464 u_int qfrozen; 465 struct timer_list reset_timer; 466 struct semaphore eh_sem; 467 struct Scsi_Host *host; /* pointer to scsi host */ ··· 477 uint32_t irq; /* IRQ for this adapter */ 478 uint32_t bios_address; 479 uint32_t mem_busaddr; /* Mem Base Addr */ 480 + 481 + #define AHC_UP_EH_SEMAPHORE 0x1 482 + uint32_t flags; 483 }; 484 485 /************************** OS Utility Wrappers *******************************/