aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2008-04-24 22:34:49 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-04-27 13:20:00 -0400
commitd1d7b19d433188e94fc87cc7ca66363cd77a0bba (patch)
treeca3474a25f2ca420e0004e47fd1a1b9d0cf5e057
parentd10c2e4627b0dda286bcd1c77720eb5fe4a04f93 (diff)
[SCSI] aic7xxx: add static
This patch adds static (and sometimes const) keywords where appropriate. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> Acked-by: Hannes Reinecke <hare@suse.de> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r--drivers/scsi/aic7xxx/aic79xx.h17
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_core.c88
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_inline.h44
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c5
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.h1
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_pci.c2
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx.h49
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_core.c180
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_inline.h55
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c6
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.h3
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_proc.c2
12 files changed, 195 insertions, 257 deletions
diff --git a/drivers/scsi/aic7xxx/aic79xx.h b/drivers/scsi/aic7xxx/aic79xx.h
index 2f00467b6b8c..9c1484453d5f 100644
--- a/drivers/scsi/aic7xxx/aic79xx.h
+++ b/drivers/scsi/aic7xxx/aic79xx.h
@@ -1314,7 +1314,7 @@ typedef int (ahd_device_setup_t)(struct ahd_softc *);
1314struct ahd_pci_identity { 1314struct ahd_pci_identity {
1315 uint64_t full_id; 1315 uint64_t full_id;
1316 uint64_t id_mask; 1316 uint64_t id_mask;
1317 char *name; 1317 const char *name;
1318 ahd_device_setup_t *setup; 1318 ahd_device_setup_t *setup;
1319}; 1319};
1320 1320
@@ -1322,7 +1322,7 @@ struct ahd_pci_identity {
1322struct aic7770_identity { 1322struct aic7770_identity {
1323 uint32_t full_id; 1323 uint32_t full_id;
1324 uint32_t id_mask; 1324 uint32_t id_mask;
1325 char *name; 1325 const char *name;
1326 ahd_device_setup_t *setup; 1326 ahd_device_setup_t *setup;
1327}; 1327};
1328extern struct aic7770_identity aic7770_ident_table []; 1328extern struct aic7770_identity aic7770_ident_table [];
@@ -1333,7 +1333,6 @@ extern const int ahd_num_aic7770_devs;
1333 1333
1334/*************************** Function Declarations ****************************/ 1334/*************************** Function Declarations ****************************/
1335/******************************************************************************/ 1335/******************************************************************************/
1336void ahd_reset_cmds_pending(struct ahd_softc *ahd);
1337 1336
1338/***************************** PCI Front End *********************************/ 1337/***************************** PCI Front End *********************************/
1339struct ahd_pci_identity *ahd_find_pci_device(ahd_dev_softc_t); 1338struct ahd_pci_identity *ahd_find_pci_device(ahd_dev_softc_t);
@@ -1376,16 +1375,6 @@ int ahd_write_flexport(struct ahd_softc *ahd,
1376int ahd_read_flexport(struct ahd_softc *ahd, u_int addr, 1375int ahd_read_flexport(struct ahd_softc *ahd, u_int addr,
1377 uint8_t *value); 1376 uint8_t *value);
1378 1377
1379/*************************** Interrupt Services *******************************/
1380void ahd_run_qoutfifo(struct ahd_softc *ahd);
1381#ifdef AHD_TARGET_MODE
1382void ahd_run_tqinfifo(struct ahd_softc *ahd, int paused);
1383#endif
1384void ahd_handle_hwerrint(struct ahd_softc *ahd);
1385void ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat);
1386void ahd_handle_scsiint(struct ahd_softc *ahd,
1387 u_int intstat);
1388
1389/***************************** Error Recovery *********************************/ 1378/***************************** Error Recovery *********************************/
1390typedef enum { 1379typedef enum {
1391 SEARCH_COMPLETE, 1380 SEARCH_COMPLETE,
@@ -1479,7 +1468,7 @@ extern uint32_t ahd_debug;
1479void ahd_print_devinfo(struct ahd_softc *ahd, 1468void ahd_print_devinfo(struct ahd_softc *ahd,
1480 struct ahd_devinfo *devinfo); 1469 struct ahd_devinfo *devinfo);
1481void ahd_dump_card_state(struct ahd_softc *ahd); 1470void ahd_dump_card_state(struct ahd_softc *ahd);
1482int ahd_print_register(ahd_reg_parse_entry_t *table, 1471int ahd_print_register(const ahd_reg_parse_entry_t *table,
1483 u_int num_entries, 1472 u_int num_entries,
1484 const char *name, 1473 const char *name,
1485 u_int address, 1474 u_int address,
diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c
index 336f4bea251b..1e452cfa2390 100644
--- a/drivers/scsi/aic7xxx/aic79xx_core.c
+++ b/drivers/scsi/aic7xxx/aic79xx_core.c
@@ -266,6 +266,18 @@ static int ahd_match_scb(struct ahd_softc *ahd, struct scb *scb,
266 int target, char channel, int lun, 266 int target, char channel, int lun,
267 u_int tag, role_t role); 267 u_int tag, role_t role);
268 268
269static void ahd_reset_cmds_pending(struct ahd_softc *ahd);
270
271/*************************** Interrupt Services *******************************/
272static void ahd_run_qoutfifo(struct ahd_softc *ahd);
273#ifdef AHD_TARGET_MODE
274static void ahd_run_tqinfifo(struct ahd_softc *ahd, int paused);
275#endif
276static void ahd_handle_hwerrint(struct ahd_softc *ahd);
277static void ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat);
278static void ahd_handle_scsiint(struct ahd_softc *ahd,
279 u_int intstat);
280
269/************************ Sequencer Execution Control *************************/ 281/************************ Sequencer Execution Control *************************/
270void 282void
271ahd_set_modes(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst) 283ahd_set_modes(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
@@ -285,7 +297,7 @@ ahd_set_modes(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
285 ahd->dst_mode = dst; 297 ahd->dst_mode = dst;
286} 298}
287 299
288void 300static void
289ahd_update_modes(struct ahd_softc *ahd) 301ahd_update_modes(struct ahd_softc *ahd)
290{ 302{
291 ahd_mode_state mode_ptr; 303 ahd_mode_state mode_ptr;
@@ -301,7 +313,7 @@ ahd_update_modes(struct ahd_softc *ahd)
301 ahd_known_modes(ahd, src, dst); 313 ahd_known_modes(ahd, src, dst);
302} 314}
303 315
304void 316static void
305ahd_assert_modes(struct ahd_softc *ahd, ahd_mode srcmode, 317ahd_assert_modes(struct ahd_softc *ahd, ahd_mode srcmode,
306 ahd_mode dstmode, const char *file, int line) 318 ahd_mode dstmode, const char *file, int line)
307{ 319{
@@ -422,7 +434,7 @@ ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb,
422 } 434 }
423} 435}
424 436
425void 437static void
426ahd_setup_scb_common(struct ahd_softc *ahd, struct scb *scb) 438ahd_setup_scb_common(struct ahd_softc *ahd, struct scb *scb)
427{ 439{
428 /* XXX Handle target mode SCBs. */ 440 /* XXX Handle target mode SCBs. */
@@ -443,7 +455,7 @@ ahd_setup_scb_common(struct ahd_softc *ahd, struct scb *scb)
443 ahd_htole32(scb->sense_busaddr); 455 ahd_htole32(scb->sense_busaddr);
444} 456}
445 457
446void 458static void
447ahd_setup_data_scb(struct ahd_softc *ahd, struct scb *scb) 459ahd_setup_data_scb(struct ahd_softc *ahd, struct scb *scb)
448{ 460{
449 /* 461 /*
@@ -480,7 +492,7 @@ ahd_setup_data_scb(struct ahd_softc *ahd, struct scb *scb)
480 scb->hscb->sgptr = ahd_htole32(scb->sg_list_busaddr|SG_FULL_RESID); 492 scb->hscb->sgptr = ahd_htole32(scb->sg_list_busaddr|SG_FULL_RESID);
481} 493}
482 494
483void 495static void
484ahd_setup_noxfer_scb(struct ahd_softc *ahd, struct scb *scb) 496ahd_setup_noxfer_scb(struct ahd_softc *ahd, struct scb *scb)
485{ 497{
486 scb->hscb->sgptr = ahd_htole32(SG_LIST_NULL); 498 scb->hscb->sgptr = ahd_htole32(SG_LIST_NULL);
@@ -489,7 +501,7 @@ ahd_setup_noxfer_scb(struct ahd_softc *ahd, struct scb *scb)
489} 501}
490 502
491/************************** Memory mapping routines ***************************/ 503/************************** Memory mapping routines ***************************/
492void * 504static void *
493ahd_sg_bus_to_virt(struct ahd_softc *ahd, struct scb *scb, uint32_t sg_busaddr) 505ahd_sg_bus_to_virt(struct ahd_softc *ahd, struct scb *scb, uint32_t sg_busaddr)
494{ 506{
495 dma_addr_t sg_offset; 507 dma_addr_t sg_offset;
@@ -499,7 +511,7 @@ ahd_sg_bus_to_virt(struct ahd_softc *ahd, struct scb *scb, uint32_t sg_busaddr)
499 return ((uint8_t *)scb->sg_list + sg_offset); 511 return ((uint8_t *)scb->sg_list + sg_offset);
500} 512}
501 513
502uint32_t 514static uint32_t
503ahd_sg_virt_to_bus(struct ahd_softc *ahd, struct scb *scb, void *sg) 515ahd_sg_virt_to_bus(struct ahd_softc *ahd, struct scb *scb, void *sg)
504{ 516{
505 dma_addr_t sg_offset; 517 dma_addr_t sg_offset;
@@ -511,7 +523,7 @@ ahd_sg_virt_to_bus(struct ahd_softc *ahd, struct scb *scb, void *sg)
511 return (scb->sg_list_busaddr + sg_offset); 523 return (scb->sg_list_busaddr + sg_offset);
512} 524}
513 525
514void 526static void
515ahd_sync_scb(struct ahd_softc *ahd, struct scb *scb, int op) 527ahd_sync_scb(struct ahd_softc *ahd, struct scb *scb, int op)
516{ 528{
517 ahd_dmamap_sync(ahd, ahd->scb_data.hscb_dmat, 529 ahd_dmamap_sync(ahd, ahd->scb_data.hscb_dmat,
@@ -532,7 +544,7 @@ ahd_sync_sglist(struct ahd_softc *ahd, struct scb *scb, int op)
532 /*len*/ahd_sg_size(ahd) * scb->sg_count, op); 544 /*len*/ahd_sg_size(ahd) * scb->sg_count, op);
533} 545}
534 546
535void 547static void
536ahd_sync_sense(struct ahd_softc *ahd, struct scb *scb, int op) 548ahd_sync_sense(struct ahd_softc *ahd, struct scb *scb, int op)
537{ 549{
538 ahd_dmamap_sync(ahd, ahd->scb_data.sense_dmat, 550 ahd_dmamap_sync(ahd, ahd->scb_data.sense_dmat,
@@ -541,12 +553,14 @@ ahd_sync_sense(struct ahd_softc *ahd, struct scb *scb, int op)
541 /*len*/AHD_SENSE_BUFSIZE, op); 553 /*len*/AHD_SENSE_BUFSIZE, op);
542} 554}
543 555
544uint32_t 556#ifdef AHD_TARGET_MODE
557static uint32_t
545ahd_targetcmd_offset(struct ahd_softc *ahd, u_int index) 558ahd_targetcmd_offset(struct ahd_softc *ahd, u_int index)
546{ 559{
547 return (((uint8_t *)&ahd->targetcmds[index]) 560 return (((uint8_t *)&ahd->targetcmds[index])
548 - (uint8_t *)ahd->qoutfifo); 561 - (uint8_t *)ahd->qoutfifo);
549} 562}
563#endif
550 564
551/*********************** Miscelaneous Support Functions ***********************/ 565/*********************** Miscelaneous Support Functions ***********************/
552/* 566/*
@@ -653,31 +667,35 @@ ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr)
653 ahd_outb(ahd, SCBPTR+1, (scbptr >> 8) & 0xFF); 667 ahd_outb(ahd, SCBPTR+1, (scbptr >> 8) & 0xFF);
654} 668}
655 669
656u_int 670#if 0 /* unused */
671static u_int
657ahd_get_hnscb_qoff(struct ahd_softc *ahd) 672ahd_get_hnscb_qoff(struct ahd_softc *ahd)
658{ 673{
659 return (ahd_inw_atomic(ahd, HNSCB_QOFF)); 674 return (ahd_inw_atomic(ahd, HNSCB_QOFF));
660} 675}
676#endif
661 677
662void 678static void
663ahd_set_hnscb_qoff(struct ahd_softc *ahd, u_int value) 679ahd_set_hnscb_qoff(struct ahd_softc *ahd, u_int value)
664{ 680{
665 ahd_outw_atomic(ahd, HNSCB_QOFF, value); 681 ahd_outw_atomic(ahd, HNSCB_QOFF, value);
666} 682}
667 683
668u_int 684#if 0 /* unused */
685static u_int
669ahd_get_hescb_qoff(struct ahd_softc *ahd) 686ahd_get_hescb_qoff(struct ahd_softc *ahd)
670{ 687{
671 return (ahd_inb(ahd, HESCB_QOFF)); 688 return (ahd_inb(ahd, HESCB_QOFF));
672} 689}
690#endif
673 691
674void 692static void
675ahd_set_hescb_qoff(struct ahd_softc *ahd, u_int value) 693ahd_set_hescb_qoff(struct ahd_softc *ahd, u_int value)
676{ 694{
677 ahd_outb(ahd, HESCB_QOFF, value); 695 ahd_outb(ahd, HESCB_QOFF, value);
678} 696}
679 697
680u_int 698static u_int
681ahd_get_snscb_qoff(struct ahd_softc *ahd) 699ahd_get_snscb_qoff(struct ahd_softc *ahd)
682{ 700{
683 u_int oldvalue; 701 u_int oldvalue;
@@ -688,35 +706,39 @@ ahd_get_snscb_qoff(struct ahd_softc *ahd)
688 return (oldvalue); 706 return (oldvalue);
689} 707}
690 708
691void 709static void
692ahd_set_snscb_qoff(struct ahd_softc *ahd, u_int value) 710ahd_set_snscb_qoff(struct ahd_softc *ahd, u_int value)
693{ 711{
694 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); 712 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
695 ahd_outw(ahd, SNSCB_QOFF, value); 713 ahd_outw(ahd, SNSCB_QOFF, value);
696} 714}
697 715
698u_int 716#if 0 /* unused */
717static u_int
699ahd_get_sescb_qoff(struct ahd_softc *ahd) 718ahd_get_sescb_qoff(struct ahd_softc *ahd)
700{ 719{
701 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); 720 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
702 return (ahd_inb(ahd, SESCB_QOFF)); 721 return (ahd_inb(ahd, SESCB_QOFF));
703} 722}
723#endif
704 724
705void 725static void
706ahd_set_sescb_qoff(struct ahd_softc *ahd, u_int value) 726ahd_set_sescb_qoff(struct ahd_softc *ahd, u_int value)
707{ 727{
708 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); 728 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
709 ahd_outb(ahd, SESCB_QOFF, value); 729 ahd_outb(ahd, SESCB_QOFF, value);
710} 730}
711 731
712u_int 732#if 0 /* unused */
733static u_int
713ahd_get_sdscb_qoff(struct ahd_softc *ahd) 734ahd_get_sdscb_qoff(struct ahd_softc *ahd)
714{ 735{
715 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); 736 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
716 return (ahd_inb(ahd, SDSCB_QOFF) | (ahd_inb(ahd, SDSCB_QOFF + 1) << 8)); 737 return (ahd_inb(ahd, SDSCB_QOFF) | (ahd_inb(ahd, SDSCB_QOFF + 1) << 8));
717} 738}
739#endif
718 740
719void 741static void
720ahd_set_sdscb_qoff(struct ahd_softc *ahd, u_int value) 742ahd_set_sdscb_qoff(struct ahd_softc *ahd, u_int value)
721{ 743{
722 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK); 744 AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
@@ -756,14 +778,14 @@ ahd_inw_scbram(struct ahd_softc *ahd, u_int offset)
756 | (ahd_inb_scbram(ahd, offset+1) << 8)); 778 | (ahd_inb_scbram(ahd, offset+1) << 8));
757} 779}
758 780
759uint32_t 781static uint32_t
760ahd_inl_scbram(struct ahd_softc *ahd, u_int offset) 782ahd_inl_scbram(struct ahd_softc *ahd, u_int offset)
761{ 783{
762 return (ahd_inw_scbram(ahd, offset) 784 return (ahd_inw_scbram(ahd, offset)
763 | (ahd_inw_scbram(ahd, offset+2) << 16)); 785 | (ahd_inw_scbram(ahd, offset+2) << 16));
764} 786}
765 787
766uint64_t 788static uint64_t
767ahd_inq_scbram(struct ahd_softc *ahd, u_int offset) 789ahd_inq_scbram(struct ahd_softc *ahd, u_int offset)
768{ 790{
769 return (ahd_inl_scbram(ahd, offset) 791 return (ahd_inl_scbram(ahd, offset)
@@ -784,7 +806,7 @@ ahd_lookup_scb(struct ahd_softc *ahd, u_int tag)
784 return (scb); 806 return (scb);
785} 807}
786 808
787void 809static void
788ahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb) 810ahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb)
789{ 811{
790 struct hardware_scb *q_hscb; 812 struct hardware_scb *q_hscb;
@@ -869,7 +891,7 @@ ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb)
869} 891}
870 892
871/************************** Interrupt Processing ******************************/ 893/************************** Interrupt Processing ******************************/
872void 894static void
873ahd_sync_qoutfifo(struct ahd_softc *ahd, int op) 895ahd_sync_qoutfifo(struct ahd_softc *ahd, int op)
874{ 896{
875 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_map.dmamap, 897 ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_map.dmamap,
@@ -877,7 +899,7 @@ ahd_sync_qoutfifo(struct ahd_softc *ahd, int op)
877 /*len*/AHD_SCB_MAX * sizeof(struct ahd_completion), op); 899 /*len*/AHD_SCB_MAX * sizeof(struct ahd_completion), op);
878} 900}
879 901
880void 902static void
881ahd_sync_tqinfifo(struct ahd_softc *ahd, int op) 903ahd_sync_tqinfifo(struct ahd_softc *ahd, int op)
882{ 904{
883#ifdef AHD_TARGET_MODE 905#ifdef AHD_TARGET_MODE
@@ -897,7 +919,7 @@ ahd_sync_tqinfifo(struct ahd_softc *ahd, int op)
897 */ 919 */
898#define AHD_RUN_QOUTFIFO 0x1 920#define AHD_RUN_QOUTFIFO 0x1
899#define AHD_RUN_TQINFIFO 0x2 921#define AHD_RUN_TQINFIFO 0x2
900u_int 922static u_int
901ahd_check_cmdcmpltqueues(struct ahd_softc *ahd) 923ahd_check_cmdcmpltqueues(struct ahd_softc *ahd)
902{ 924{
903 u_int retval; 925 u_int retval;
@@ -1640,7 +1662,7 @@ clrchn:
1640 * a copy of the first byte (little endian) of the sgptr 1662 * a copy of the first byte (little endian) of the sgptr
1641 * hscb field. 1663 * hscb field.
1642 */ 1664 */
1643void 1665static void
1644ahd_run_qoutfifo(struct ahd_softc *ahd) 1666ahd_run_qoutfifo(struct ahd_softc *ahd)
1645{ 1667{
1646 struct ahd_completion *completion; 1668 struct ahd_completion *completion;
@@ -1679,7 +1701,7 @@ ahd_run_qoutfifo(struct ahd_softc *ahd)
1679} 1701}
1680 1702
1681/************************* Interrupt Handling *********************************/ 1703/************************* Interrupt Handling *********************************/
1682void 1704static void
1683ahd_handle_hwerrint(struct ahd_softc *ahd) 1705ahd_handle_hwerrint(struct ahd_softc *ahd)
1684{ 1706{
1685 /* 1707 /*
@@ -1753,7 +1775,7 @@ ahd_dump_sglist(struct scb *scb)
1753} 1775}
1754#endif /* AHD_DEBUG */ 1776#endif /* AHD_DEBUG */
1755 1777
1756void 1778static void
1757ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat) 1779ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
1758{ 1780{
1759 u_int seqintcode; 1781 u_int seqintcode;
@@ -2365,7 +2387,7 @@ ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
2365 ahd_unpause(ahd); 2387 ahd_unpause(ahd);
2366} 2388}
2367 2389
2368void 2390static void
2369ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat) 2391ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
2370{ 2392{
2371 struct scb *scb; 2393 struct scb *scb;
@@ -8131,7 +8153,7 @@ ahd_qinfifo_count(struct ahd_softc *ahd)
8131 + ARRAY_SIZE(ahd->qinfifo) - wrap_qinpos); 8153 + ARRAY_SIZE(ahd->qinfifo) - wrap_qinpos);
8132} 8154}
8133 8155
8134void 8156static void
8135ahd_reset_cmds_pending(struct ahd_softc *ahd) 8157ahd_reset_cmds_pending(struct ahd_softc *ahd)
8136{ 8158{
8137 struct scb *scb; 8159 struct scb *scb;
@@ -9656,7 +9678,7 @@ sized:
9656} 9678}
9657 9679
9658int 9680int
9659ahd_print_register(ahd_reg_parse_entry_t *table, u_int num_entries, 9681ahd_print_register(const ahd_reg_parse_entry_t *table, u_int num_entries,
9660 const char *name, u_int address, u_int value, 9682 const char *name, u_int address, u_int value,
9661 u_int *cur_column, u_int wrap_point) 9683 u_int *cur_column, u_int wrap_point)
9662{ 9684{
@@ -10647,7 +10669,7 @@ ahd_update_scsiid(struct ahd_softc *ahd, u_int targid_mask)
10647#endif 10669#endif
10648} 10670}
10649 10671
10650void 10672static void
10651ahd_run_tqinfifo(struct ahd_softc *ahd, int paused) 10673ahd_run_tqinfifo(struct ahd_softc *ahd, int paused)
10652{ 10674{
10653 struct target_cmd *cmd; 10675 struct target_cmd *cmd;
diff --git a/drivers/scsi/aic7xxx/aic79xx_inline.h b/drivers/scsi/aic7xxx/aic79xx_inline.h
index 875137262156..5f12cf9d99d0 100644
--- a/drivers/scsi/aic7xxx/aic79xx_inline.h
+++ b/drivers/scsi/aic7xxx/aic79xx_inline.h
@@ -66,10 +66,6 @@ static __inline void ahd_extract_mode_state(struct ahd_softc *ahd,
66 66
67void ahd_set_modes(struct ahd_softc *ahd, ahd_mode src, 67void ahd_set_modes(struct ahd_softc *ahd, ahd_mode src,
68 ahd_mode dst); 68 ahd_mode dst);
69void ahd_update_modes(struct ahd_softc *ahd);
70void ahd_assert_modes(struct ahd_softc *ahd, ahd_mode srcmode,
71 ahd_mode dstmode, const char *file,
72 int line);
73ahd_mode_state ahd_save_modes(struct ahd_softc *ahd); 69ahd_mode_state ahd_save_modes(struct ahd_softc *ahd);
74void ahd_restore_modes(struct ahd_softc *ahd, 70void ahd_restore_modes(struct ahd_softc *ahd,
75 ahd_mode_state state); 71 ahd_mode_state state);
@@ -104,33 +100,12 @@ ahd_extract_mode_state(struct ahd_softc *ahd, ahd_mode_state state,
104void *ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb, 100void *ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb,
105 void *sgptr, dma_addr_t addr, 101 void *sgptr, dma_addr_t addr,
106 bus_size_t len, int last); 102 bus_size_t len, int last);
107void ahd_setup_scb_common(struct ahd_softc *ahd,
108 struct scb *scb);
109void ahd_setup_data_scb(struct ahd_softc *ahd,
110 struct scb *scb);
111void ahd_setup_noxfer_scb(struct ahd_softc *ahd,
112 struct scb *scb);
113 103
114/************************** Memory mapping routines ***************************/ 104/************************** Memory mapping routines ***************************/
115static __inline size_t ahd_sg_size(struct ahd_softc *ahd); 105static __inline size_t ahd_sg_size(struct ahd_softc *ahd);
116 106
117void *
118 ahd_sg_bus_to_virt(struct ahd_softc *ahd,
119 struct scb *scb,
120 uint32_t sg_busaddr);
121uint32_t
122 ahd_sg_virt_to_bus(struct ahd_softc *ahd,
123 struct scb *scb,
124 void *sg);
125void ahd_sync_scb(struct ahd_softc *ahd,
126 struct scb *scb, int op);
127void ahd_sync_sglist(struct ahd_softc *ahd, 107void ahd_sync_sglist(struct ahd_softc *ahd,
128 struct scb *scb, int op); 108 struct scb *scb, int op);
129void ahd_sync_sense(struct ahd_softc *ahd,
130 struct scb *scb, int op);
131uint32_t
132 ahd_targetcmd_offset(struct ahd_softc *ahd,
133 u_int index);
134 109
135static __inline size_t 110static __inline size_t
136ahd_sg_size(struct ahd_softc *ahd) 111ahd_sg_size(struct ahd_softc *ahd)
@@ -160,26 +135,10 @@ void ahd_outq(struct ahd_softc *ahd, u_int port,
160 uint64_t value); 135 uint64_t value);
161u_int ahd_get_scbptr(struct ahd_softc *ahd); 136u_int ahd_get_scbptr(struct ahd_softc *ahd);
162void ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr); 137void ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr);
163u_int ahd_get_hnscb_qoff(struct ahd_softc *ahd);
164void ahd_set_hnscb_qoff(struct ahd_softc *ahd, u_int value);
165u_int ahd_get_hescb_qoff(struct ahd_softc *ahd);
166void ahd_set_hescb_qoff(struct ahd_softc *ahd, u_int value);
167u_int ahd_get_snscb_qoff(struct ahd_softc *ahd);
168void ahd_set_snscb_qoff(struct ahd_softc *ahd, u_int value);
169u_int ahd_get_sescb_qoff(struct ahd_softc *ahd);
170void ahd_set_sescb_qoff(struct ahd_softc *ahd, u_int value);
171u_int ahd_get_sdscb_qoff(struct ahd_softc *ahd);
172void ahd_set_sdscb_qoff(struct ahd_softc *ahd, u_int value);
173u_int ahd_inb_scbram(struct ahd_softc *ahd, u_int offset); 138u_int ahd_inb_scbram(struct ahd_softc *ahd, u_int offset);
174u_int ahd_inw_scbram(struct ahd_softc *ahd, u_int offset); 139u_int ahd_inw_scbram(struct ahd_softc *ahd, u_int offset);
175uint32_t
176 ahd_inl_scbram(struct ahd_softc *ahd, u_int offset);
177uint64_t
178 ahd_inq_scbram(struct ahd_softc *ahd, u_int offset);
179struct scb * 140struct scb *
180 ahd_lookup_scb(struct ahd_softc *ahd, u_int tag); 141 ahd_lookup_scb(struct ahd_softc *ahd, u_int tag);
181void ahd_swap_with_next_hscb(struct ahd_softc *ahd,
182 struct scb *scb);
183void ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb); 142void ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb);
184 143
185static __inline uint8_t * 144static __inline uint8_t *
@@ -212,9 +171,6 @@ ahd_get_sense_bufaddr(struct ahd_softc *ahd, struct scb *scb)
212} 171}
213 172
214/************************** Interrupt Processing ******************************/ 173/************************** Interrupt Processing ******************************/
215void ahd_sync_qoutfifo(struct ahd_softc *ahd, int op);
216void ahd_sync_tqinfifo(struct ahd_softc *ahd, int op);
217u_int ahd_check_cmdcmpltqueues(struct ahd_softc *ahd);
218int ahd_intr(struct ahd_softc *ahd); 174int ahd_intr(struct ahd_softc *ahd);
219 175
220#endif /* _AIC79XX_INLINE_H_ */ 176#endif /* _AIC79XX_INLINE_H_ */
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 6c5287722465..ea0bbda47324 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -388,7 +388,6 @@ ahd_delay(long usec)
388 388
389/***************************** Low Level I/O **********************************/ 389/***************************** Low Level I/O **********************************/
390uint8_t ahd_inb(struct ahd_softc * ahd, long port); 390uint8_t ahd_inb(struct ahd_softc * ahd, long port);
391uint16_t ahd_inw_atomic(struct ahd_softc * ahd, long port);
392void ahd_outb(struct ahd_softc * ahd, long port, uint8_t val); 391void ahd_outb(struct ahd_softc * ahd, long port, uint8_t val);
393void ahd_outw_atomic(struct ahd_softc * ahd, 392void ahd_outw_atomic(struct ahd_softc * ahd,
394 long port, uint16_t val); 393 long port, uint16_t val);
@@ -411,7 +410,8 @@ ahd_inb(struct ahd_softc * ahd, long port)
411 return (x); 410 return (x);
412} 411}
413 412
414uint16_t 413#if 0 /* unused */
414static uint16_t
415ahd_inw_atomic(struct ahd_softc * ahd, long port) 415ahd_inw_atomic(struct ahd_softc * ahd, long port)
416{ 416{
417 uint8_t x; 417 uint8_t x;
@@ -424,6 +424,7 @@ ahd_inw_atomic(struct ahd_softc * ahd, long port)
424 mb(); 424 mb();
425 return (x); 425 return (x);
426} 426}
427#endif
427 428
428void 429void
429ahd_outb(struct ahd_softc * ahd, long port, uint8_t val) 430ahd_outb(struct ahd_softc * ahd, long port, uint8_t val)
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h
index 08dd18229b45..8d6612c19922 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.h
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.h
@@ -374,7 +374,6 @@ void ahd_delay(long);
374 374
375/***************************** Low Level I/O **********************************/ 375/***************************** Low Level I/O **********************************/
376uint8_t ahd_inb(struct ahd_softc * ahd, long port); 376uint8_t ahd_inb(struct ahd_softc * ahd, long port);
377uint16_t ahd_inw_atomic(struct ahd_softc * ahd, long port);
378void ahd_outb(struct ahd_softc * ahd, long port, uint8_t val); 377void ahd_outb(struct ahd_softc * ahd, long port, uint8_t val);
379void ahd_outw_atomic(struct ahd_softc * ahd, 378void ahd_outw_atomic(struct ahd_softc * ahd,
380 long port, uint16_t val); 379 long port, uint16_t val);
diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
index c9f79fdf9131..0bb352573f57 100644
--- a/drivers/scsi/aic7xxx/aic79xx_pci.c
+++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
@@ -97,7 +97,7 @@ static ahd_device_setup_t ahd_aic7901A_setup;
97static ahd_device_setup_t ahd_aic7902_setup; 97static ahd_device_setup_t ahd_aic7902_setup;
98static ahd_device_setup_t ahd_aic790X_setup; 98static ahd_device_setup_t ahd_aic790X_setup;
99 99
100static struct ahd_pci_identity ahd_pci_ident_table [] = 100static struct ahd_pci_identity ahd_pci_ident_table[] =
101{ 101{
102 /* aic7901 based controllers */ 102 /* aic7901 based controllers */
103 { 103 {
diff --git a/drivers/scsi/aic7xxx/aic7xxx.h b/drivers/scsi/aic7xxx/aic7xxx.h
index c0344e617651..862e0fbffa42 100644
--- a/drivers/scsi/aic7xxx/aic7xxx.h
+++ b/drivers/scsi/aic7xxx/aic7xxx.h
@@ -736,7 +736,7 @@ struct ahc_syncrate {
736#define ST_SXFR 0x010 /* Rate Single Transition Only */ 736#define ST_SXFR 0x010 /* Rate Single Transition Only */
737#define DT_SXFR 0x040 /* Rate Double Transition Only */ 737#define DT_SXFR 0x040 /* Rate Double Transition Only */
738 uint8_t period; /* Period to send to SCSI target */ 738 uint8_t period; /* Period to send to SCSI target */
739 char *rate; 739 const char *rate;
740}; 740};
741 741
742/* Safe and valid period for async negotiations. */ 742/* Safe and valid period for async negotiations. */
@@ -1133,10 +1133,6 @@ extern const int ahc_num_aic7770_devs;
1133 1133
1134/*************************** Function Declarations ****************************/ 1134/*************************** Function Declarations ****************************/
1135/******************************************************************************/ 1135/******************************************************************************/
1136u_int ahc_index_busy_tcl(struct ahc_softc *ahc, u_int tcl);
1137void ahc_unbusy_tcl(struct ahc_softc *ahc, u_int tcl);
1138void ahc_busy_tcl(struct ahc_softc *ahc,
1139 u_int tcl, u_int busyid);
1140 1136
1141/***************************** PCI Front End *********************************/ 1137/***************************** PCI Front End *********************************/
1142struct ahc_pci_identity *ahc_find_pci_device(ahc_dev_softc_t); 1138struct ahc_pci_identity *ahc_find_pci_device(ahc_dev_softc_t);
@@ -1155,9 +1151,6 @@ int aic7770_config(struct ahc_softc *ahc,
1155 1151
1156/************************** SCB and SCB queue management **********************/ 1152/************************** SCB and SCB queue management **********************/
1157int ahc_probe_scbs(struct ahc_softc *); 1153int ahc_probe_scbs(struct ahc_softc *);
1158void ahc_run_untagged_queues(struct ahc_softc *ahc);
1159void ahc_run_untagged_queue(struct ahc_softc *ahc,
1160 struct scb_tailq *queue);
1161void ahc_qinfifo_requeue_tail(struct ahc_softc *ahc, 1154void ahc_qinfifo_requeue_tail(struct ahc_softc *ahc,
1162 struct scb *scb); 1155 struct scb *scb);
1163int ahc_match_scb(struct ahc_softc *ahc, struct scb *scb, 1156int ahc_match_scb(struct ahc_softc *ahc, struct scb *scb,
@@ -1178,22 +1171,8 @@ int ahc_resume(struct ahc_softc *ahc);
1178#endif 1171#endif
1179void ahc_set_unit(struct ahc_softc *, int); 1172void ahc_set_unit(struct ahc_softc *, int);
1180void ahc_set_name(struct ahc_softc *, char *); 1173void ahc_set_name(struct ahc_softc *, char *);
1181void ahc_alloc_scbs(struct ahc_softc *ahc);
1182void ahc_free(struct ahc_softc *ahc); 1174void ahc_free(struct ahc_softc *ahc);
1183int ahc_reset(struct ahc_softc *ahc, int reinit); 1175int ahc_reset(struct ahc_softc *ahc, int reinit);
1184void ahc_shutdown(void *arg);
1185
1186/*************************** Interrupt Services *******************************/
1187void ahc_clear_intstat(struct ahc_softc *ahc);
1188void ahc_run_qoutfifo(struct ahc_softc *ahc);
1189#ifdef AHC_TARGET_MODE
1190void ahc_run_tqinfifo(struct ahc_softc *ahc, int paused);
1191#endif
1192void ahc_handle_brkadrint(struct ahc_softc *ahc);
1193void ahc_handle_seqint(struct ahc_softc *ahc, u_int intstat);
1194void ahc_handle_scsiint(struct ahc_softc *ahc,
1195 u_int intstat);
1196void ahc_clear_critical_section(struct ahc_softc *ahc);
1197 1176
1198/***************************** Error Recovery *********************************/ 1177/***************************** Error Recovery *********************************/
1199typedef enum { 1178typedef enum {
@@ -1214,36 +1193,19 @@ int ahc_search_disc_list(struct ahc_softc *ahc, int target,
1214 char channel, int lun, u_int tag, 1193 char channel, int lun, u_int tag,
1215 int stop_on_first, int remove, 1194 int stop_on_first, int remove,
1216 int save_state); 1195 int save_state);
1217void ahc_freeze_devq(struct ahc_softc *ahc, struct scb *scb);
1218int ahc_reset_channel(struct ahc_softc *ahc, char channel, 1196int ahc_reset_channel(struct ahc_softc *ahc, char channel,
1219 int initiate_reset); 1197 int initiate_reset);
1220int ahc_abort_scbs(struct ahc_softc *ahc, int target, 1198
1221 char channel, int lun, u_int tag,
1222 role_t role, uint32_t status);
1223void ahc_restart(struct ahc_softc *ahc);
1224void ahc_calc_residual(struct ahc_softc *ahc,
1225 struct scb *scb);
1226/*************************** Utility Functions ********************************/ 1199/*************************** Utility Functions ********************************/
1227struct ahc_phase_table_entry*
1228 ahc_lookup_phase_entry(int phase);
1229void ahc_compile_devinfo(struct ahc_devinfo *devinfo, 1200void ahc_compile_devinfo(struct ahc_devinfo *devinfo,
1230 u_int our_id, u_int target, 1201 u_int our_id, u_int target,
1231 u_int lun, char channel, 1202 u_int lun, char channel,
1232 role_t role); 1203 role_t role);
1233/************************** Transfer Negotiation ******************************/ 1204/************************** Transfer Negotiation ******************************/
1234struct ahc_syncrate* ahc_find_syncrate(struct ahc_softc *ahc, u_int *period, 1205const struct ahc_syncrate* ahc_find_syncrate(struct ahc_softc *ahc, u_int *period,
1235 u_int *ppr_options, u_int maxsync); 1206 u_int *ppr_options, u_int maxsync);
1236u_int ahc_find_period(struct ahc_softc *ahc, 1207u_int ahc_find_period(struct ahc_softc *ahc,
1237 u_int scsirate, u_int maxsync); 1208 u_int scsirate, u_int maxsync);
1238void ahc_validate_offset(struct ahc_softc *ahc,
1239 struct ahc_initiator_tinfo *tinfo,
1240 struct ahc_syncrate *syncrate,
1241 u_int *offset, int wide,
1242 role_t role);
1243void ahc_validate_width(struct ahc_softc *ahc,
1244 struct ahc_initiator_tinfo *tinfo,
1245 u_int *bus_width,
1246 role_t role);
1247/* 1209/*
1248 * Negotiation types. These are used to qualify if we should renegotiate 1210 * Negotiation types. These are used to qualify if we should renegotiate
1249 * even if our goal and current transport parameters are identical. 1211 * even if our goal and current transport parameters are identical.
@@ -1263,7 +1225,7 @@ void ahc_set_width(struct ahc_softc *ahc,
1263 u_int width, u_int type, int paused); 1225 u_int width, u_int type, int paused);
1264void ahc_set_syncrate(struct ahc_softc *ahc, 1226void ahc_set_syncrate(struct ahc_softc *ahc,
1265 struct ahc_devinfo *devinfo, 1227 struct ahc_devinfo *devinfo,
1266 struct ahc_syncrate *syncrate, 1228 const struct ahc_syncrate *syncrate,
1267 u_int period, u_int offset, 1229 u_int period, u_int offset,
1268 u_int ppr_options, 1230 u_int ppr_options,
1269 u_int type, int paused); 1231 u_int type, int paused);
@@ -1305,11 +1267,10 @@ extern uint32_t ahc_debug;
1305#define AHC_SHOW_MASKED_ERRORS 0x1000 1267#define AHC_SHOW_MASKED_ERRORS 0x1000
1306#define AHC_DEBUG_SEQUENCER 0x2000 1268#define AHC_DEBUG_SEQUENCER 0x2000
1307#endif 1269#endif
1308void ahc_print_scb(struct scb *scb);
1309void ahc_print_devinfo(struct ahc_softc *ahc, 1270void ahc_print_devinfo(struct ahc_softc *ahc,
1310 struct ahc_devinfo *dev); 1271 struct ahc_devinfo *dev);
1311void ahc_dump_card_state(struct ahc_softc *ahc); 1272void ahc_dump_card_state(struct ahc_softc *ahc);
1312int ahc_print_register(ahc_reg_parse_entry_t *table, 1273int ahc_print_register(const ahc_reg_parse_entry_t *table,
1313 u_int num_entries, 1274 u_int num_entries,
1314 const char *name, 1275 const char *name,
1315 u_int address, 1276 u_int address,
diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
index d1d006b8b3a9..62417ed17cf3 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -51,8 +51,7 @@
51#endif 51#endif
52 52
53/***************************** Lookup Tables **********************************/ 53/***************************** Lookup Tables **********************************/
54char *ahc_chip_names[] = 54static const char *const ahc_chip_names[] = {
55{
56 "NONE", 55 "NONE",
57 "aic7770", 56 "aic7770",
58 "aic7850", 57 "aic7850",
@@ -75,10 +74,10 @@ static const u_int num_chip_names = ARRAY_SIZE(ahc_chip_names);
75 */ 74 */
76struct ahc_hard_error_entry { 75struct ahc_hard_error_entry {
77 uint8_t errno; 76 uint8_t errno;
78 char *errmesg; 77 const char *errmesg;
79}; 78};
80 79
81static struct ahc_hard_error_entry ahc_hard_errors[] = { 80static const struct ahc_hard_error_entry ahc_hard_errors[] = {
82 { ILLHADDR, "Illegal Host Access" }, 81 { ILLHADDR, "Illegal Host Access" },
83 { ILLSADDR, "Illegal Sequencer Address referrenced" }, 82 { ILLSADDR, "Illegal Sequencer Address referrenced" },
84 { ILLOPCODE, "Illegal Opcode in sequencer program" }, 83 { ILLOPCODE, "Illegal Opcode in sequencer program" },
@@ -90,7 +89,7 @@ static struct ahc_hard_error_entry ahc_hard_errors[] = {
90}; 89};
91static const u_int num_errors = ARRAY_SIZE(ahc_hard_errors); 90static const u_int num_errors = ARRAY_SIZE(ahc_hard_errors);
92 91
93static struct ahc_phase_table_entry ahc_phase_table[] = 92static const struct ahc_phase_table_entry ahc_phase_table[] =
94{ 93{
95 { P_DATAOUT, MSG_NOOP, "in Data-out phase" }, 94 { P_DATAOUT, MSG_NOOP, "in Data-out phase" },
96 { P_DATAIN, MSG_INITIATOR_DET_ERR, "in Data-in phase" }, 95 { P_DATAIN, MSG_INITIATOR_DET_ERR, "in Data-in phase" },
@@ -115,7 +114,7 @@ static const u_int num_phases = ARRAY_SIZE(ahc_phase_table) - 1;
115 * Provides a mapping of tranfer periods in ns to the proper value to 114 * Provides a mapping of tranfer periods in ns to the proper value to
116 * stick in the scsixfer reg. 115 * stick in the scsixfer reg.
117 */ 116 */
118static struct ahc_syncrate ahc_syncrates[] = 117static const struct ahc_syncrate ahc_syncrates[] =
119{ 118{
120 /* ultra2 fast/ultra period rate */ 119 /* ultra2 fast/ultra period rate */
121 { 0x42, 0x000, 9, "80.0" }, 120 { 0x42, 0x000, 9, "80.0" },
@@ -148,7 +147,7 @@ static struct ahc_tmode_tstate*
148static void ahc_free_tstate(struct ahc_softc *ahc, 147static void ahc_free_tstate(struct ahc_softc *ahc,
149 u_int scsi_id, char channel, int force); 148 u_int scsi_id, char channel, int force);
150#endif 149#endif
151static struct ahc_syncrate* 150static const struct ahc_syncrate*
152 ahc_devlimited_syncrate(struct ahc_softc *ahc, 151 ahc_devlimited_syncrate(struct ahc_softc *ahc,
153 struct ahc_initiator_tinfo *, 152 struct ahc_initiator_tinfo *,
154 u_int *period, 153 u_int *period,
@@ -204,9 +203,9 @@ static void ahc_setup_target_msgin(struct ahc_softc *ahc,
204#endif 203#endif
205 204
206static bus_dmamap_callback_t ahc_dmamap_cb; 205static bus_dmamap_callback_t ahc_dmamap_cb;
207static void ahc_build_free_scb_list(struct ahc_softc *ahc); 206static void ahc_build_free_scb_list(struct ahc_softc *ahc);
208static int ahc_init_scbdata(struct ahc_softc *ahc); 207static int ahc_init_scbdata(struct ahc_softc *ahc);
209static void ahc_fini_scbdata(struct ahc_softc *ahc); 208static void ahc_fini_scbdata(struct ahc_softc *ahc);
210static void ahc_qinfifo_requeue(struct ahc_softc *ahc, 209static void ahc_qinfifo_requeue(struct ahc_softc *ahc,
211 struct scb *prev_scb, 210 struct scb *prev_scb,
212 struct scb *scb); 211 struct scb *scb);
@@ -238,6 +237,71 @@ static int ahc_handle_target_cmd(struct ahc_softc *ahc,
238 struct target_cmd *cmd); 237 struct target_cmd *cmd);
239#endif 238#endif
240 239
240static u_int ahc_index_busy_tcl(struct ahc_softc *ahc, u_int tcl);
241static void ahc_unbusy_tcl(struct ahc_softc *ahc, u_int tcl);
242static void ahc_busy_tcl(struct ahc_softc *ahc,
243 u_int tcl, u_int busyid);
244
245/************************** SCB and SCB queue management **********************/
246static void ahc_run_untagged_queues(struct ahc_softc *ahc);
247static void ahc_run_untagged_queue(struct ahc_softc *ahc,
248 struct scb_tailq *queue);
249
250/****************************** Initialization ********************************/
251static void ahc_alloc_scbs(struct ahc_softc *ahc);
252static void ahc_shutdown(void *arg);
253
254/*************************** Interrupt Services *******************************/
255static void ahc_clear_intstat(struct ahc_softc *ahc);
256static void ahc_run_qoutfifo(struct ahc_softc *ahc);
257#ifdef AHC_TARGET_MODE
258static void ahc_run_tqinfifo(struct ahc_softc *ahc, int paused);
259#endif
260static void ahc_handle_brkadrint(struct ahc_softc *ahc);
261static void ahc_handle_seqint(struct ahc_softc *ahc, u_int intstat);
262static void ahc_handle_scsiint(struct ahc_softc *ahc,
263 u_int intstat);
264static void ahc_clear_critical_section(struct ahc_softc *ahc);
265
266/***************************** Error Recovery *********************************/
267static void ahc_freeze_devq(struct ahc_softc *ahc, struct scb *scb);
268static int ahc_abort_scbs(struct ahc_softc *ahc, int target,
269 char channel, int lun, u_int tag,
270 role_t role, uint32_t status);
271static void ahc_calc_residual(struct ahc_softc *ahc,
272 struct scb *scb);
273
274/*********************** Untagged Transaction Routines ************************/
275static inline void ahc_freeze_untagged_queues(struct ahc_softc *ahc);
276static inline void ahc_release_untagged_queues(struct ahc_softc *ahc);
277
278/*
279 * Block our completion routine from starting the next untagged
280 * transaction for this target or target lun.
281 */
282static inline void
283ahc_freeze_untagged_queues(struct ahc_softc *ahc)
284{
285 if ((ahc->flags & AHC_SCB_BTT) == 0)
286 ahc->untagged_queue_lock++;
287}
288
289/*
290 * Allow the next untagged transaction for this target or target lun
291 * to be executed. We use a counting semaphore to allow the lock
292 * to be acquired recursively. Once the count drops to zero, the
293 * transaction queues will be run.
294 */
295static inline void
296ahc_release_untagged_queues(struct ahc_softc *ahc)
297{
298 if ((ahc->flags & AHC_SCB_BTT) == 0) {
299 ahc->untagged_queue_lock--;
300 if (ahc->untagged_queue_lock == 0)
301 ahc_run_untagged_queues(ahc);
302 }
303}
304
241/************************* Sequencer Execution Control ************************/ 305/************************* Sequencer Execution Control ************************/
242/* 306/*
243 * Work around any chip bugs related to halting sequencer execution. 307 * Work around any chip bugs related to halting sequencer execution.
@@ -247,7 +311,7 @@ static int ahc_handle_target_cmd(struct ahc_softc *ahc,
247 * manual pause while accessing scb ram, accesses to certain registers 311 * manual pause while accessing scb ram, accesses to certain registers
248 * will hang the system (infinite pci retries). 312 * will hang the system (infinite pci retries).
249 */ 313 */
250void 314static void
251ahc_pause_bug_fix(struct ahc_softc *ahc) 315ahc_pause_bug_fix(struct ahc_softc *ahc)
252{ 316{
253 if ((ahc->features & AHC_ULTRA2) != 0) 317 if ((ahc->features & AHC_ULTRA2) != 0)
@@ -304,7 +368,7 @@ ahc_unpause(struct ahc_softc *ahc)
304} 368}
305 369
306/************************** Memory mapping routines ***************************/ 370/************************** Memory mapping routines ***************************/
307struct ahc_dma_seg * 371static struct ahc_dma_seg *
308ahc_sg_bus_to_virt(struct scb *scb, uint32_t sg_busaddr) 372ahc_sg_bus_to_virt(struct scb *scb, uint32_t sg_busaddr)
309{ 373{
310 int sg_index; 374 int sg_index;
@@ -316,7 +380,7 @@ ahc_sg_bus_to_virt(struct scb *scb, uint32_t sg_busaddr)
316 return (&scb->sg_list[sg_index]); 380 return (&scb->sg_list[sg_index]);
317} 381}
318 382
319uint32_t 383static uint32_t
320ahc_sg_virt_to_bus(struct scb *scb, struct ahc_dma_seg *sg) 384ahc_sg_virt_to_bus(struct scb *scb, struct ahc_dma_seg *sg)
321{ 385{
322 int sg_index; 386 int sg_index;
@@ -327,14 +391,14 @@ ahc_sg_virt_to_bus(struct scb *scb, struct ahc_dma_seg *sg)
327 return (scb->sg_list_phys + (sg_index * sizeof(*scb->sg_list))); 391 return (scb->sg_list_phys + (sg_index * sizeof(*scb->sg_list)));
328} 392}
329 393
330uint32_t 394static uint32_t
331ahc_hscb_busaddr(struct ahc_softc *ahc, u_int index) 395ahc_hscb_busaddr(struct ahc_softc *ahc, u_int index)
332{ 396{
333 return (ahc->scb_data->hscb_busaddr 397 return (ahc->scb_data->hscb_busaddr
334 + (sizeof(struct hardware_scb) * index)); 398 + (sizeof(struct hardware_scb) * index));
335} 399}
336 400
337void 401static void
338ahc_sync_scb(struct ahc_softc *ahc, struct scb *scb, int op) 402ahc_sync_scb(struct ahc_softc *ahc, struct scb *scb, int op)
339{ 403{
340 ahc_dmamap_sync(ahc, ahc->scb_data->hscb_dmat, 404 ahc_dmamap_sync(ahc, ahc->scb_data->hscb_dmat,
@@ -355,18 +419,20 @@ ahc_sync_sglist(struct ahc_softc *ahc, struct scb *scb, int op)
355 /*len*/sizeof(struct ahc_dma_seg) * scb->sg_count, op); 419 /*len*/sizeof(struct ahc_dma_seg) * scb->sg_count, op);
356} 420}
357 421
358uint32_t 422#ifdef AHC_TARGET_MODE
423static uint32_t
359ahc_targetcmd_offset(struct ahc_softc *ahc, u_int index) 424ahc_targetcmd_offset(struct ahc_softc *ahc, u_int index)
360{ 425{
361 return (((uint8_t *)&ahc->targetcmds[index]) - ahc->qoutfifo); 426 return (((uint8_t *)&ahc->targetcmds[index]) - ahc->qoutfifo);
362} 427}
428#endif
363 429
364/*********************** Miscelaneous Support Functions ***********************/ 430/*********************** Miscelaneous Support Functions ***********************/
365/* 431/*
366 * Determine whether the sequencer reported a residual 432 * Determine whether the sequencer reported a residual
367 * for this SCB/transaction. 433 * for this SCB/transaction.
368 */ 434 */
369void 435static void
370ahc_update_residual(struct ahc_softc *ahc, struct scb *scb) 436ahc_update_residual(struct ahc_softc *ahc, struct scb *scb)
371{ 437{
372 uint32_t sgptr; 438 uint32_t sgptr;
@@ -504,7 +570,7 @@ ahc_lookup_scb(struct ahc_softc *ahc, u_int tag)
504 return (scb); 570 return (scb);
505} 571}
506 572
507void 573static void
508ahc_swap_with_next_hscb(struct ahc_softc *ahc, struct scb *scb) 574ahc_swap_with_next_hscb(struct ahc_softc *ahc, struct scb *scb)
509{ 575{
510 struct hardware_scb *q_hscb; 576 struct hardware_scb *q_hscb;
@@ -593,7 +659,7 @@ ahc_get_sense_buf(struct ahc_softc *ahc, struct scb *scb)
593 return (&ahc->scb_data->sense[offset]); 659 return (&ahc->scb_data->sense[offset]);
594} 660}
595 661
596uint32_t 662static uint32_t
597ahc_get_sense_bufaddr(struct ahc_softc *ahc, struct scb *scb) 663ahc_get_sense_bufaddr(struct ahc_softc *ahc, struct scb *scb)
598{ 664{
599 int offset; 665 int offset;
@@ -604,14 +670,14 @@ ahc_get_sense_bufaddr(struct ahc_softc *ahc, struct scb *scb)
604} 670}
605 671
606/************************** Interrupt Processing ******************************/ 672/************************** Interrupt Processing ******************************/
607void 673static void
608ahc_sync_qoutfifo(struct ahc_softc *ahc, int op) 674ahc_sync_qoutfifo(struct ahc_softc *ahc, int op)
609{ 675{
610 ahc_dmamap_sync(ahc, ahc->shared_data_dmat, ahc->shared_data_dmamap, 676 ahc_dmamap_sync(ahc, ahc->shared_data_dmat, ahc->shared_data_dmamap,
611 /*offset*/0, /*len*/256, op); 677 /*offset*/0, /*len*/256, op);
612} 678}
613 679
614void 680static void
615ahc_sync_tqinfifo(struct ahc_softc *ahc, int op) 681ahc_sync_tqinfifo(struct ahc_softc *ahc, int op)
616{ 682{
617#ifdef AHC_TARGET_MODE 683#ifdef AHC_TARGET_MODE
@@ -631,7 +697,7 @@ ahc_sync_tqinfifo(struct ahc_softc *ahc, int op)
631 */ 697 */
632#define AHC_RUN_QOUTFIFO 0x1 698#define AHC_RUN_QOUTFIFO 0x1
633#define AHC_RUN_TQINFIFO 0x2 699#define AHC_RUN_TQINFIFO 0x2
634u_int 700static u_int
635ahc_check_cmdcmpltqueues(struct ahc_softc *ahc) 701ahc_check_cmdcmpltqueues(struct ahc_softc *ahc)
636{ 702{
637 u_int retval; 703 u_int retval;
@@ -745,7 +811,7 @@ ahc_intr(struct ahc_softc *ahc)
745/* 811/*
746 * Restart the sequencer program from address zero 812 * Restart the sequencer program from address zero
747 */ 813 */
748void 814static void
749ahc_restart(struct ahc_softc *ahc) 815ahc_restart(struct ahc_softc *ahc)
750{ 816{
751 817
@@ -806,7 +872,7 @@ ahc_restart(struct ahc_softc *ahc)
806} 872}
807 873
808/************************* Input/Output Queues ********************************/ 874/************************* Input/Output Queues ********************************/
809void 875static void
810ahc_run_qoutfifo(struct ahc_softc *ahc) 876ahc_run_qoutfifo(struct ahc_softc *ahc)
811{ 877{
812 struct scb *scb; 878 struct scb *scb;
@@ -853,7 +919,7 @@ ahc_run_qoutfifo(struct ahc_softc *ahc)
853 } 919 }
854} 920}
855 921
856void 922static void
857ahc_run_untagged_queues(struct ahc_softc *ahc) 923ahc_run_untagged_queues(struct ahc_softc *ahc)
858{ 924{
859 int i; 925 int i;
@@ -862,7 +928,7 @@ ahc_run_untagged_queues(struct ahc_softc *ahc)
862 ahc_run_untagged_queue(ahc, &ahc->untagged_queues[i]); 928 ahc_run_untagged_queue(ahc, &ahc->untagged_queues[i]);
863} 929}
864 930
865void 931static void
866ahc_run_untagged_queue(struct ahc_softc *ahc, struct scb_tailq *queue) 932ahc_run_untagged_queue(struct ahc_softc *ahc, struct scb_tailq *queue)
867{ 933{
868 struct scb *scb; 934 struct scb *scb;
@@ -878,7 +944,7 @@ ahc_run_untagged_queue(struct ahc_softc *ahc, struct scb_tailq *queue)
878} 944}
879 945
880/************************* Interrupt Handling *********************************/ 946/************************* Interrupt Handling *********************************/
881void 947static void
882ahc_handle_brkadrint(struct ahc_softc *ahc) 948ahc_handle_brkadrint(struct ahc_softc *ahc)
883{ 949{
884 /* 950 /*
@@ -907,7 +973,7 @@ ahc_handle_brkadrint(struct ahc_softc *ahc)
907 ahc_shutdown(ahc); 973 ahc_shutdown(ahc);
908} 974}
909 975
910void 976static void
911ahc_handle_seqint(struct ahc_softc *ahc, u_int intstat) 977ahc_handle_seqint(struct ahc_softc *ahc, u_int intstat)
912{ 978{
913 struct scb *scb; 979 struct scb *scb;
@@ -1458,7 +1524,7 @@ unpause:
1458 ahc_unpause(ahc); 1524 ahc_unpause(ahc);
1459} 1525}
1460 1526
1461void 1527static void
1462ahc_handle_scsiint(struct ahc_softc *ahc, u_int intstat) 1528ahc_handle_scsiint(struct ahc_softc *ahc, u_int intstat)
1463{ 1529{
1464 u_int scb_index; 1530 u_int scb_index;
@@ -1911,7 +1977,7 @@ ahc_force_renegotiation(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
1911} 1977}
1912 1978
1913#define AHC_MAX_STEPS 2000 1979#define AHC_MAX_STEPS 2000
1914void 1980static void
1915ahc_clear_critical_section(struct ahc_softc *ahc) 1981ahc_clear_critical_section(struct ahc_softc *ahc)
1916{ 1982{
1917 int stepping; 1983 int stepping;
@@ -2004,7 +2070,7 @@ ahc_clear_critical_section(struct ahc_softc *ahc)
2004/* 2070/*
2005 * Clear any pending interrupt status. 2071 * Clear any pending interrupt status.
2006 */ 2072 */
2007void 2073static void
2008ahc_clear_intstat(struct ahc_softc *ahc) 2074ahc_clear_intstat(struct ahc_softc *ahc)
2009{ 2075{
2010 /* Clear any interrupt conditions this may have caused */ 2076 /* Clear any interrupt conditions this may have caused */
@@ -2023,7 +2089,8 @@ ahc_clear_intstat(struct ahc_softc *ahc)
2023uint32_t ahc_debug = AHC_DEBUG_OPTS; 2089uint32_t ahc_debug = AHC_DEBUG_OPTS;
2024#endif 2090#endif
2025 2091
2026void 2092#if 0 /* unused */
2093static void
2027ahc_print_scb(struct scb *scb) 2094ahc_print_scb(struct scb *scb)
2028{ 2095{
2029 int i; 2096 int i;
@@ -2055,6 +2122,7 @@ ahc_print_scb(struct scb *scb)
2055 } 2122 }
2056 } 2123 }
2057} 2124}
2125#endif
2058 2126
2059/************************* Transfer Negotiation *******************************/ 2127/************************* Transfer Negotiation *******************************/
2060/* 2128/*
@@ -2138,7 +2206,7 @@ ahc_free_tstate(struct ahc_softc *ahc, u_int scsi_id, char channel, int force)
2138 * by the capabilities of the bus connectivity of and sync settings for 2206 * by the capabilities of the bus connectivity of and sync settings for
2139 * the target. 2207 * the target.
2140 */ 2208 */
2141struct ahc_syncrate * 2209const struct ahc_syncrate *
2142ahc_devlimited_syncrate(struct ahc_softc *ahc, 2210ahc_devlimited_syncrate(struct ahc_softc *ahc,
2143 struct ahc_initiator_tinfo *tinfo, 2211 struct ahc_initiator_tinfo *tinfo,
2144 u_int *period, u_int *ppr_options, role_t role) 2212 u_int *period, u_int *ppr_options, role_t role)
@@ -2193,11 +2261,11 @@ ahc_devlimited_syncrate(struct ahc_softc *ahc,
2193 * Return the period and offset that should be sent to the target 2261 * Return the period and offset that should be sent to the target
2194 * if this was the beginning of an SDTR. 2262 * if this was the beginning of an SDTR.
2195 */ 2263 */
2196struct ahc_syncrate * 2264const struct ahc_syncrate *
2197ahc_find_syncrate(struct ahc_softc *ahc, u_int *period, 2265ahc_find_syncrate(struct ahc_softc *ahc, u_int *period,
2198 u_int *ppr_options, u_int maxsync) 2266 u_int *ppr_options, u_int maxsync)
2199{ 2267{
2200 struct ahc_syncrate *syncrate; 2268 const struct ahc_syncrate *syncrate;
2201 2269
2202 if ((ahc->features & AHC_DT) == 0) 2270 if ((ahc->features & AHC_DT) == 0)
2203 *ppr_options &= ~MSG_EXT_PPR_DT_REQ; 2271 *ppr_options &= ~MSG_EXT_PPR_DT_REQ;
@@ -2272,7 +2340,7 @@ ahc_find_syncrate(struct ahc_softc *ahc, u_int *period,
2272u_int 2340u_int
2273ahc_find_period(struct ahc_softc *ahc, u_int scsirate, u_int maxsync) 2341ahc_find_period(struct ahc_softc *ahc, u_int scsirate, u_int maxsync)
2274{ 2342{
2275 struct ahc_syncrate *syncrate; 2343 const struct ahc_syncrate *syncrate;
2276 2344
2277 if ((ahc->features & AHC_ULTRA2) != 0) 2345 if ((ahc->features & AHC_ULTRA2) != 0)
2278 scsirate &= SXFR_ULTRA2; 2346 scsirate &= SXFR_ULTRA2;
@@ -2310,10 +2378,10 @@ ahc_find_period(struct ahc_softc *ahc, u_int scsirate, u_int maxsync)
2310 * Truncate the given synchronous offset to a value the 2378 * Truncate the given synchronous offset to a value the
2311 * current adapter type and syncrate are capable of. 2379 * current adapter type and syncrate are capable of.
2312 */ 2380 */
2313void 2381static void
2314ahc_validate_offset(struct ahc_softc *ahc, 2382ahc_validate_offset(struct ahc_softc *ahc,
2315 struct ahc_initiator_tinfo *tinfo, 2383 struct ahc_initiator_tinfo *tinfo,
2316 struct ahc_syncrate *syncrate, 2384 const struct ahc_syncrate *syncrate,
2317 u_int *offset, int wide, role_t role) 2385 u_int *offset, int wide, role_t role)
2318{ 2386{
2319 u_int maxoffset; 2387 u_int maxoffset;
@@ -2342,7 +2410,7 @@ ahc_validate_offset(struct ahc_softc *ahc,
2342 * Truncate the given transfer width parameter to a value the 2410 * Truncate the given transfer width parameter to a value the
2343 * current adapter type is capable of. 2411 * current adapter type is capable of.
2344 */ 2412 */
2345void 2413static void
2346ahc_validate_width(struct ahc_softc *ahc, struct ahc_initiator_tinfo *tinfo, 2414ahc_validate_width(struct ahc_softc *ahc, struct ahc_initiator_tinfo *tinfo,
2347 u_int *bus_width, role_t role) 2415 u_int *bus_width, role_t role)
2348{ 2416{
@@ -2417,7 +2485,7 @@ ahc_update_neg_request(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
2417 */ 2485 */
2418void 2486void
2419ahc_set_syncrate(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, 2487ahc_set_syncrate(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
2420 struct ahc_syncrate *syncrate, u_int period, 2488 const struct ahc_syncrate *syncrate, u_int period,
2421 u_int offset, u_int ppr_options, u_int type, int paused) 2489 u_int offset, u_int ppr_options, u_int type, int paused)
2422{ 2490{
2423 struct ahc_initiator_tinfo *tinfo; 2491 struct ahc_initiator_tinfo *tinfo;
@@ -2724,11 +2792,11 @@ ahc_fetch_devinfo(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
2724 role); 2792 role);
2725} 2793}
2726 2794
2727struct ahc_phase_table_entry* 2795static const struct ahc_phase_table_entry*
2728ahc_lookup_phase_entry(int phase) 2796ahc_lookup_phase_entry(int phase)
2729{ 2797{
2730 struct ahc_phase_table_entry *entry; 2798 const struct ahc_phase_table_entry *entry;
2731 struct ahc_phase_table_entry *last_entry; 2799 const struct ahc_phase_table_entry *last_entry;
2732 2800
2733 /* 2801 /*
2734 * num_phases doesn't include the default entry which 2802 * num_phases doesn't include the default entry which
@@ -2894,7 +2962,7 @@ ahc_build_transfer_msg(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
2894 */ 2962 */
2895 struct ahc_initiator_tinfo *tinfo; 2963 struct ahc_initiator_tinfo *tinfo;
2896 struct ahc_tmode_tstate *tstate; 2964 struct ahc_tmode_tstate *tstate;
2897 struct ahc_syncrate *rate; 2965 const struct ahc_syncrate *rate;
2898 int dowide; 2966 int dowide;
2899 int dosync; 2967 int dosync;
2900 int doppr; 2968 int doppr;
@@ -3560,7 +3628,7 @@ ahc_parse_msg(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
3560 switch (ahc->msgin_buf[2]) { 3628 switch (ahc->msgin_buf[2]) {
3561 case MSG_EXT_SDTR: 3629 case MSG_EXT_SDTR:
3562 { 3630 {
3563 struct ahc_syncrate *syncrate; 3631 const struct ahc_syncrate *syncrate;
3564 u_int period; 3632 u_int period;
3565 u_int ppr_options; 3633 u_int ppr_options;
3566 u_int offset; 3634 u_int offset;
@@ -3735,7 +3803,7 @@ ahc_parse_msg(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
3735 } 3803 }
3736 case MSG_EXT_PPR: 3804 case MSG_EXT_PPR:
3737 { 3805 {
3738 struct ahc_syncrate *syncrate; 3806 const struct ahc_syncrate *syncrate;
3739 u_int period; 3807 u_int period;
3740 u_int offset; 3808 u_int offset;
3741 u_int bus_width; 3809 u_int bus_width;
@@ -4488,7 +4556,7 @@ ahc_free(struct ahc_softc *ahc)
4488 return; 4556 return;
4489} 4557}
4490 4558
4491void 4559static void
4492ahc_shutdown(void *arg) 4560ahc_shutdown(void *arg)
4493{ 4561{
4494 struct ahc_softc *ahc; 4562 struct ahc_softc *ahc;
@@ -4892,7 +4960,7 @@ ahc_fini_scbdata(struct ahc_softc *ahc)
4892 free(scb_data->scbarray, M_DEVBUF); 4960 free(scb_data->scbarray, M_DEVBUF);
4893} 4961}
4894 4962
4895void 4963static void
4896ahc_alloc_scbs(struct ahc_softc *ahc) 4964ahc_alloc_scbs(struct ahc_softc *ahc)
4897{ 4965{
4898 struct scb_data *scb_data; 4966 struct scb_data *scb_data;
@@ -5625,7 +5693,7 @@ ahc_resume(struct ahc_softc *ahc)
5625 * Return the untagged transaction id for a given target/channel lun. 5693 * Return the untagged transaction id for a given target/channel lun.
5626 * Optionally, clear the entry. 5694 * Optionally, clear the entry.
5627 */ 5695 */
5628u_int 5696static u_int
5629ahc_index_busy_tcl(struct ahc_softc *ahc, u_int tcl) 5697ahc_index_busy_tcl(struct ahc_softc *ahc, u_int tcl)
5630{ 5698{
5631 u_int scbid; 5699 u_int scbid;
@@ -5646,7 +5714,7 @@ ahc_index_busy_tcl(struct ahc_softc *ahc, u_int tcl)
5646 return (scbid); 5714 return (scbid);
5647} 5715}
5648 5716
5649void 5717static void
5650ahc_unbusy_tcl(struct ahc_softc *ahc, u_int tcl) 5718ahc_unbusy_tcl(struct ahc_softc *ahc, u_int tcl)
5651{ 5719{
5652 u_int target_offset; 5720 u_int target_offset;
@@ -5664,7 +5732,7 @@ ahc_unbusy_tcl(struct ahc_softc *ahc, u_int tcl)
5664 } 5732 }
5665} 5733}
5666 5734
5667void 5735static void
5668ahc_busy_tcl(struct ahc_softc *ahc, u_int tcl, u_int scbid) 5736ahc_busy_tcl(struct ahc_softc *ahc, u_int tcl, u_int scbid)
5669{ 5737{
5670 u_int target_offset; 5738 u_int target_offset;
@@ -5719,7 +5787,7 @@ ahc_match_scb(struct ahc_softc *ahc, struct scb *scb, int target,
5719 return match; 5787 return match;
5720} 5788}
5721 5789
5722void 5790static void
5723ahc_freeze_devq(struct ahc_softc *ahc, struct scb *scb) 5791ahc_freeze_devq(struct ahc_softc *ahc, struct scb *scb)
5724{ 5792{
5725 int target; 5793 int target;
@@ -6260,7 +6328,7 @@ ahc_rem_wscb(struct ahc_softc *ahc, u_int scbpos, u_int prev)
6260 * been modified from CAM_REQ_INPROG. This routine assumes that the sequencer 6328 * been modified from CAM_REQ_INPROG. This routine assumes that the sequencer
6261 * is paused before it is called. 6329 * is paused before it is called.
6262 */ 6330 */
6263int 6331static int
6264ahc_abort_scbs(struct ahc_softc *ahc, int target, char channel, 6332ahc_abort_scbs(struct ahc_softc *ahc, int target, char channel,
6265 int lun, u_int tag, role_t role, uint32_t status) 6333 int lun, u_int tag, role_t role, uint32_t status)
6266{ 6334{
@@ -6582,7 +6650,7 @@ ahc_reset_channel(struct ahc_softc *ahc, char channel, int initiate_reset)
6582/* 6650/*
6583 * Calculate the residual for a just completed SCB. 6651 * Calculate the residual for a just completed SCB.
6584 */ 6652 */
6585void 6653static void
6586ahc_calc_residual(struct ahc_softc *ahc, struct scb *scb) 6654ahc_calc_residual(struct ahc_softc *ahc, struct scb *scb)
6587{ 6655{
6588 struct hardware_scb *hscb; 6656 struct hardware_scb *hscb;
@@ -7049,7 +7117,7 @@ ahc_download_instr(struct ahc_softc *ahc, u_int instrptr, uint8_t *dconsts)
7049} 7117}
7050 7118
7051int 7119int
7052ahc_print_register(ahc_reg_parse_entry_t *table, u_int num_entries, 7120ahc_print_register(const ahc_reg_parse_entry_t *table, u_int num_entries,
7053 const char *name, u_int address, u_int value, 7121 const char *name, u_int address, u_int value,
7054 u_int *cur_column, u_int wrap_point) 7122 u_int *cur_column, u_int wrap_point)
7055{ 7123{
@@ -7733,7 +7801,7 @@ ahc_update_scsiid(struct ahc_softc *ahc, u_int targid_mask)
7733 ahc_outb(ahc, SCSIID, scsiid); 7801 ahc_outb(ahc, SCSIID, scsiid);
7734} 7802}
7735 7803
7736void 7804static void
7737ahc_run_tqinfifo(struct ahc_softc *ahc, int paused) 7805ahc_run_tqinfifo(struct ahc_softc *ahc, int paused)
7738{ 7806{
7739 struct target_cmd *cmd; 7807 struct target_cmd *cmd;
diff --git a/drivers/scsi/aic7xxx/aic7xxx_inline.h b/drivers/scsi/aic7xxx/aic7xxx_inline.h
index d18cd743618d..09bf2f4d78d5 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_inline.h
+++ b/drivers/scsi/aic7xxx/aic7xxx_inline.h
@@ -46,58 +46,13 @@
46#define _AIC7XXX_INLINE_H_ 46#define _AIC7XXX_INLINE_H_
47 47
48/************************* Sequencer Execution Control ************************/ 48/************************* Sequencer Execution Control ************************/
49void ahc_pause_bug_fix(struct ahc_softc *ahc);
50int ahc_is_paused(struct ahc_softc *ahc); 49int ahc_is_paused(struct ahc_softc *ahc);
51void ahc_pause(struct ahc_softc *ahc); 50void ahc_pause(struct ahc_softc *ahc);
52void ahc_unpause(struct ahc_softc *ahc); 51void ahc_unpause(struct ahc_softc *ahc);
53 52
54/*********************** Untagged Transaction Routines ************************/
55static __inline void ahc_freeze_untagged_queues(struct ahc_softc *ahc);
56static __inline void ahc_release_untagged_queues(struct ahc_softc *ahc);
57
58/*
59 * Block our completion routine from starting the next untagged
60 * transaction for this target or target lun.
61 */
62static __inline void
63ahc_freeze_untagged_queues(struct ahc_softc *ahc)
64{
65 if ((ahc->flags & AHC_SCB_BTT) == 0)
66 ahc->untagged_queue_lock++;
67}
68
69/*
70 * Allow the next untagged transaction for this target or target lun
71 * to be executed. We use a counting semaphore to allow the lock
72 * to be acquired recursively. Once the count drops to zero, the
73 * transaction queues will be run.
74 */
75static __inline void
76ahc_release_untagged_queues(struct ahc_softc *ahc)
77{
78 if ((ahc->flags & AHC_SCB_BTT) == 0) {
79 ahc->untagged_queue_lock--;
80 if (ahc->untagged_queue_lock == 0)
81 ahc_run_untagged_queues(ahc);
82 }
83}
84
85/************************** Memory mapping routines ***************************/ 53/************************** Memory mapping routines ***************************/
86struct ahc_dma_seg *
87 ahc_sg_bus_to_virt(struct scb *scb,
88 uint32_t sg_busaddr);
89uint32_t
90 ahc_sg_virt_to_bus(struct scb *scb,
91 struct ahc_dma_seg *sg);
92uint32_t
93 ahc_hscb_busaddr(struct ahc_softc *ahc, u_int index);
94void ahc_sync_scb(struct ahc_softc *ahc,
95 struct scb *scb, int op);
96void ahc_sync_sglist(struct ahc_softc *ahc, 54void ahc_sync_sglist(struct ahc_softc *ahc,
97 struct scb *scb, int op); 55 struct scb *scb, int op);
98uint32_t
99 ahc_targetcmd_offset(struct ahc_softc *ahc,
100 u_int index);
101 56
102/******************************** Debugging ***********************************/ 57/******************************** Debugging ***********************************/
103static __inline char *ahc_name(struct ahc_softc *ahc); 58static __inline char *ahc_name(struct ahc_softc *ahc);
@@ -110,8 +65,6 @@ ahc_name(struct ahc_softc *ahc)
110 65
111/*********************** Miscellaneous Support Functions ***********************/ 66/*********************** Miscellaneous Support Functions ***********************/
112 67
113void ahc_update_residual(struct ahc_softc *ahc,
114 struct scb *scb);
115struct ahc_initiator_tinfo * 68struct ahc_initiator_tinfo *
116 ahc_fetch_transinfo(struct ahc_softc *ahc, 69 ahc_fetch_transinfo(struct ahc_softc *ahc,
117 char channel, u_int our_id, 70 char channel, u_int our_id,
@@ -134,20 +87,12 @@ struct scb*
134void ahc_free_scb(struct ahc_softc *ahc, struct scb *scb); 87void ahc_free_scb(struct ahc_softc *ahc, struct scb *scb);
135struct scb * 88struct scb *
136 ahc_lookup_scb(struct ahc_softc *ahc, u_int tag); 89 ahc_lookup_scb(struct ahc_softc *ahc, u_int tag);
137void ahc_swap_with_next_hscb(struct ahc_softc *ahc,
138 struct scb *scb);
139void ahc_queue_scb(struct ahc_softc *ahc, struct scb *scb); 90void ahc_queue_scb(struct ahc_softc *ahc, struct scb *scb);
140struct scsi_sense_data * 91struct scsi_sense_data *
141 ahc_get_sense_buf(struct ahc_softc *ahc, 92 ahc_get_sense_buf(struct ahc_softc *ahc,
142 struct scb *scb); 93 struct scb *scb);
143uint32_t
144 ahc_get_sense_bufaddr(struct ahc_softc *ahc,
145 struct scb *scb);
146 94
147/************************** Interrupt Processing ******************************/ 95/************************** Interrupt Processing ******************************/
148void ahc_sync_qoutfifo(struct ahc_softc *ahc, int op);
149void ahc_sync_tqinfifo(struct ahc_softc *ahc, int op);
150u_int ahc_check_cmdcmpltqueues(struct ahc_softc *ahc);
151int ahc_intr(struct ahc_softc *ahc); 96int ahc_intr(struct ahc_softc *ahc);
152 97
153#endif /* _AIC7XXX_INLINE_H_ */ 98#endif /* _AIC7XXX_INLINE_H_ */
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index c5a354b39d88..01118c3f56b5 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -2386,7 +2386,7 @@ static void ahc_linux_set_period(struct scsi_target *starget, int period)
2386 unsigned int ppr_options = tinfo->goal.ppr_options; 2386 unsigned int ppr_options = tinfo->goal.ppr_options;
2387 unsigned long flags; 2387 unsigned long flags;
2388 unsigned long offset = tinfo->goal.offset; 2388 unsigned long offset = tinfo->goal.offset;
2389 struct ahc_syncrate *syncrate; 2389 const struct ahc_syncrate *syncrate;
2390 2390
2391 if (offset == 0) 2391 if (offset == 0)
2392 offset = MAX_OFFSET; 2392 offset = MAX_OFFSET;
@@ -2430,7 +2430,7 @@ static void ahc_linux_set_offset(struct scsi_target *starget, int offset)
2430 unsigned int ppr_options = 0; 2430 unsigned int ppr_options = 0;
2431 unsigned int period = 0; 2431 unsigned int period = 0;
2432 unsigned long flags; 2432 unsigned long flags;
2433 struct ahc_syncrate *syncrate = NULL; 2433 const struct ahc_syncrate *syncrate = NULL;
2434 2434
2435 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2435 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0,
2436 starget->channel + 'A', ROLE_INITIATOR); 2436 starget->channel + 'A', ROLE_INITIATOR);
@@ -2460,7 +2460,7 @@ static void ahc_linux_set_dt(struct scsi_target *starget, int dt)
2460 unsigned int period = tinfo->goal.period; 2460 unsigned int period = tinfo->goal.period;
2461 unsigned int width = tinfo->goal.width; 2461 unsigned int width = tinfo->goal.width;
2462 unsigned long flags; 2462 unsigned long flags;
2463 struct ahc_syncrate *syncrate; 2463 const struct ahc_syncrate *syncrate;
2464 2464
2465 if (dt && spi_max_width(starget)) { 2465 if (dt && spi_max_width(starget)) {
2466 ppr_options |= MSG_EXT_PPR_DT_REQ; 2466 ppr_options |= MSG_EXT_PPR_DT_REQ;
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h
index c2a9ad76d35d..3f7238db35e5 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.h
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h
@@ -398,9 +398,6 @@ struct info_str {
398 int pos; 398 int pos;
399}; 399};
400 400
401void ahc_format_transinfo(struct info_str *info,
402 struct ahc_transinfo *tinfo);
403
404/******************************** Locking *************************************/ 401/******************************** Locking *************************************/
405/* Lock protecting internal data structures */ 402/* Lock protecting internal data structures */
406 403
diff --git a/drivers/scsi/aic7xxx/aic7xxx_proc.c b/drivers/scsi/aic7xxx/aic7xxx_proc.c
index 99e5443e7535..3afa34c7c591 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_proc.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_proc.c
@@ -137,7 +137,7 @@ copy_info(struct info_str *info, char *fmt, ...)
137 return (len); 137 return (len);
138} 138}
139 139
140void 140static void
141ahc_format_transinfo(struct info_str *info, struct ahc_transinfo *tinfo) 141ahc_format_transinfo(struct info_str *info, struct ahc_transinfo *tinfo)
142{ 142{
143 u_int speed; 143 u_int speed;