diff options
Diffstat (limited to 'drivers/scsi/sym53c8xx_2/sym_hipd.c')
-rw-r--r-- | drivers/scsi/sym53c8xx_2/sym_hipd.c | 164 |
1 files changed, 17 insertions, 147 deletions
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index 1564ca203a3e..8260f040d39c 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c | |||
@@ -40,6 +40,7 @@ | |||
40 | 40 | ||
41 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
42 | #include <asm/param.h> /* for timeouts in units of HZ */ | 42 | #include <asm/param.h> /* for timeouts in units of HZ */ |
43 | #include <scsi/scsi_dbg.h> | ||
43 | 44 | ||
44 | #include "sym_glue.h" | 45 | #include "sym_glue.h" |
45 | #include "sym_nvram.h" | 46 | #include "sym_nvram.h" |
@@ -70,32 +71,12 @@ static void sym_printl_hex(u_char *p, int n) | |||
70 | printf (".\n"); | 71 | printf (".\n"); |
71 | } | 72 | } |
72 | 73 | ||
73 | /* | ||
74 | * Print out the content of a SCSI message. | ||
75 | */ | ||
76 | static int sym_show_msg (u_char * msg) | ||
77 | { | ||
78 | u_char i; | ||
79 | printf ("%x",*msg); | ||
80 | if (*msg==M_EXTENDED) { | ||
81 | for (i=1;i<8;i++) { | ||
82 | if (i-1>msg[1]) break; | ||
83 | printf ("-%x",msg[i]); | ||
84 | } | ||
85 | return (i+1); | ||
86 | } else if ((*msg & 0xf0) == 0x20) { | ||
87 | printf ("-%x",msg[1]); | ||
88 | return (2); | ||
89 | } | ||
90 | return (1); | ||
91 | } | ||
92 | |||
93 | static void sym_print_msg(struct sym_ccb *cp, char *label, u_char *msg) | 74 | static void sym_print_msg(struct sym_ccb *cp, char *label, u_char *msg) |
94 | { | 75 | { |
95 | sym_print_addr(cp->cmd, "%s: ", label); | 76 | sym_print_addr(cp->cmd, "%s: ", label); |
96 | 77 | ||
97 | sym_show_msg(msg); | 78 | spi_print_msg(msg); |
98 | printf(".\n"); | 79 | printf("\n"); |
99 | } | 80 | } |
100 | 81 | ||
101 | static void sym_print_nego_msg(struct sym_hcb *np, int target, char *label, u_char *msg) | 82 | static void sym_print_nego_msg(struct sym_hcb *np, int target, char *label, u_char *msg) |
@@ -103,8 +84,8 @@ static void sym_print_nego_msg(struct sym_hcb *np, int target, char *label, u_ch | |||
103 | struct sym_tcb *tp = &np->target[target]; | 84 | struct sym_tcb *tp = &np->target[target]; |
104 | dev_info(&tp->starget->dev, "%s: ", label); | 85 | dev_info(&tp->starget->dev, "%s: ", label); |
105 | 86 | ||
106 | sym_show_msg(msg); | 87 | spi_print_msg(msg); |
107 | printf(".\n"); | 88 | printf("\n"); |
108 | } | 89 | } |
109 | 90 | ||
110 | /* | 91 | /* |
@@ -635,29 +616,6 @@ static __inline void sym_init_burst(struct sym_hcb *np, u_char bc) | |||
635 | } | 616 | } |
636 | } | 617 | } |
637 | 618 | ||
638 | |||
639 | /* | ||
640 | * Print out the list of targets that have some flag disabled by user. | ||
641 | */ | ||
642 | static void sym_print_targets_flag(struct sym_hcb *np, int mask, char *msg) | ||
643 | { | ||
644 | int cnt; | ||
645 | int i; | ||
646 | |||
647 | for (cnt = 0, i = 0 ; i < SYM_CONF_MAX_TARGET ; i++) { | ||
648 | if (i == np->myaddr) | ||
649 | continue; | ||
650 | if (np->target[i].usrflags & mask) { | ||
651 | if (!cnt++) | ||
652 | printf("%s: %s disabled for targets", | ||
653 | sym_name(np), msg); | ||
654 | printf(" %d", i); | ||
655 | } | ||
656 | } | ||
657 | if (cnt) | ||
658 | printf(".\n"); | ||
659 | } | ||
660 | |||
661 | /* | 619 | /* |
662 | * Save initial settings of some IO registers. | 620 | * Save initial settings of some IO registers. |
663 | * Assumed to have been set by BIOS. | 621 | * Assumed to have been set by BIOS. |
@@ -962,7 +920,7 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru | |||
962 | tp->usrflags |= (SYM_DISC_ENABLED | SYM_TAGS_ENABLED); | 920 | tp->usrflags |= (SYM_DISC_ENABLED | SYM_TAGS_ENABLED); |
963 | tp->usrtags = SYM_SETUP_MAX_TAG; | 921 | tp->usrtags = SYM_SETUP_MAX_TAG; |
964 | 922 | ||
965 | sym_nvram_setup_target(np, i, nvram); | 923 | sym_nvram_setup_target(tp, i, nvram); |
966 | 924 | ||
967 | if (!tp->usrtags) | 925 | if (!tp->usrtags) |
968 | tp->usrflags &= ~SYM_TAGS_ENABLED; | 926 | tp->usrflags &= ~SYM_TAGS_ENABLED; |
@@ -1005,13 +963,6 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru | |||
1005 | sym_name(np), np->rv_scntl3, np->rv_dmode, np->rv_dcntl, | 963 | sym_name(np), np->rv_scntl3, np->rv_dmode, np->rv_dcntl, |
1006 | np->rv_ctest3, np->rv_ctest4, np->rv_ctest5); | 964 | np->rv_ctest3, np->rv_ctest4, np->rv_ctest5); |
1007 | } | 965 | } |
1008 | /* | ||
1009 | * Let user be aware of targets that have some disable flags set. | ||
1010 | */ | ||
1011 | sym_print_targets_flag(np, SYM_SCAN_BOOT_DISABLED, "SCAN AT BOOT"); | ||
1012 | if (sym_verbose) | ||
1013 | sym_print_targets_flag(np, SYM_SCAN_LUNS_DISABLED, | ||
1014 | "SCAN FOR LUNS"); | ||
1015 | 966 | ||
1016 | return 0; | 967 | return 0; |
1017 | } | 968 | } |
@@ -1523,7 +1474,7 @@ static int sym_prepare_nego(struct sym_hcb *np, struct sym_ccb *cp, u_char *msgp | |||
1523 | /* | 1474 | /* |
1524 | * Insert a job into the start queue. | 1475 | * Insert a job into the start queue. |
1525 | */ | 1476 | */ |
1526 | void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp) | 1477 | static void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp) |
1527 | { | 1478 | { |
1528 | u_short qidx; | 1479 | u_short qidx; |
1529 | 1480 | ||
@@ -3654,7 +3605,7 @@ static int sym_evaluate_dp(struct sym_hcb *np, struct sym_ccb *cp, u32 scr, int | |||
3654 | * If result is dp_sg = SYM_CONF_MAX_SG, then we are at the | 3605 | * If result is dp_sg = SYM_CONF_MAX_SG, then we are at the |
3655 | * end of the data. | 3606 | * end of the data. |
3656 | */ | 3607 | */ |
3657 | tmp = scr_to_cpu(sym_goalp(cp)); | 3608 | tmp = scr_to_cpu(cp->goalp); |
3658 | dp_sg = SYM_CONF_MAX_SG; | 3609 | dp_sg = SYM_CONF_MAX_SG; |
3659 | if (dp_scr != tmp) | 3610 | if (dp_scr != tmp) |
3660 | dp_sg -= (tmp - 8 - (int)dp_scr) / (2*4); | 3611 | dp_sg -= (tmp - 8 - (int)dp_scr) / (2*4); |
@@ -3761,7 +3712,7 @@ static void sym_modify_dp(struct sym_hcb *np, struct sym_tcb *tp, struct sym_ccb | |||
3761 | * And our alchemy:) allows to easily calculate the data | 3712 | * And our alchemy:) allows to easily calculate the data |
3762 | * script address we want to return for the next data phase. | 3713 | * script address we want to return for the next data phase. |
3763 | */ | 3714 | */ |
3764 | dp_ret = cpu_to_scr(sym_goalp(cp)); | 3715 | dp_ret = cpu_to_scr(cp->goalp); |
3765 | dp_ret = dp_ret - 8 - (SYM_CONF_MAX_SG - dp_sg) * (2*4); | 3716 | dp_ret = dp_ret - 8 - (SYM_CONF_MAX_SG - dp_sg) * (2*4); |
3766 | 3717 | ||
3767 | /* | 3718 | /* |
@@ -3857,7 +3808,7 @@ int sym_compute_residual(struct sym_hcb *np, struct sym_ccb *cp) | |||
3857 | * If all data has been transferred, | 3808 | * If all data has been transferred, |
3858 | * there is no residual. | 3809 | * there is no residual. |
3859 | */ | 3810 | */ |
3860 | if (cp->phys.head.lastp == sym_goalp(cp)) | 3811 | if (cp->phys.head.lastp == cp->goalp) |
3861 | return resid; | 3812 | return resid; |
3862 | 3813 | ||
3863 | /* | 3814 | /* |
@@ -4664,30 +4615,7 @@ struct sym_ccb *sym_get_ccb (struct sym_hcb *np, struct scsi_cmnd *cmd, u_char t | |||
4664 | goto out; | 4615 | goto out; |
4665 | cp = sym_que_entry(qp, struct sym_ccb, link_ccbq); | 4616 | cp = sym_que_entry(qp, struct sym_ccb, link_ccbq); |
4666 | 4617 | ||
4667 | #ifndef SYM_OPT_HANDLE_DEVICE_QUEUEING | 4618 | { |
4668 | /* | ||
4669 | * If the LCB is not yet available and the LUN | ||
4670 | * has been probed ok, try to allocate the LCB. | ||
4671 | */ | ||
4672 | if (!lp && sym_is_bit(tp->lun_map, ln)) { | ||
4673 | lp = sym_alloc_lcb(np, tn, ln); | ||
4674 | if (!lp) | ||
4675 | goto out_free; | ||
4676 | } | ||
4677 | #endif | ||
4678 | |||
4679 | /* | ||
4680 | * If the LCB is not available here, then the | ||
4681 | * logical unit is not yet discovered. For those | ||
4682 | * ones only accept 1 SCSI IO per logical unit, | ||
4683 | * since we cannot allow disconnections. | ||
4684 | */ | ||
4685 | if (!lp) { | ||
4686 | if (!sym_is_bit(tp->busy0_map, ln)) | ||
4687 | sym_set_bit(tp->busy0_map, ln); | ||
4688 | else | ||
4689 | goto out_free; | ||
4690 | } else { | ||
4691 | /* | 4619 | /* |
4692 | * If we have been asked for a tagged command. | 4620 | * If we have been asked for a tagged command. |
4693 | */ | 4621 | */ |
@@ -4840,12 +4768,6 @@ void sym_free_ccb (struct sym_hcb *np, struct sym_ccb *cp) | |||
4840 | lp->head.resel_sa = | 4768 | lp->head.resel_sa = |
4841 | cpu_to_scr(SCRIPTB_BA(np, resel_bad_lun)); | 4769 | cpu_to_scr(SCRIPTB_BA(np, resel_bad_lun)); |
4842 | } | 4770 | } |
4843 | /* | ||
4844 | * Otherwise, we only accept 1 IO per LUN. | ||
4845 | * Clear the bit that keeps track of this IO. | ||
4846 | */ | ||
4847 | else | ||
4848 | sym_clr_bit(tp->busy0_map, cp->lun); | ||
4849 | 4771 | ||
4850 | /* | 4772 | /* |
4851 | * We donnot queue more than 1 ccb per target | 4773 | * We donnot queue more than 1 ccb per target |
@@ -4997,20 +4919,7 @@ static void sym_init_tcb (struct sym_hcb *np, u_char tn) | |||
4997 | struct sym_lcb *sym_alloc_lcb (struct sym_hcb *np, u_char tn, u_char ln) | 4919 | struct sym_lcb *sym_alloc_lcb (struct sym_hcb *np, u_char tn, u_char ln) |
4998 | { | 4920 | { |
4999 | struct sym_tcb *tp = &np->target[tn]; | 4921 | struct sym_tcb *tp = &np->target[tn]; |
5000 | struct sym_lcb *lp = sym_lp(tp, ln); | 4922 | struct sym_lcb *lp = NULL; |
5001 | |||
5002 | /* | ||
5003 | * Already done, just return. | ||
5004 | */ | ||
5005 | if (lp) | ||
5006 | return lp; | ||
5007 | |||
5008 | /* | ||
5009 | * Donnot allow LUN control block | ||
5010 | * allocation for not probed LUNs. | ||
5011 | */ | ||
5012 | if (!sym_is_bit(tp->lun_map, ln)) | ||
5013 | return NULL; | ||
5014 | 4923 | ||
5015 | /* | 4924 | /* |
5016 | * Initialize the target control block if not yet. | 4925 | * Initialize the target control block if not yet. |
@@ -5082,13 +4991,7 @@ struct sym_lcb *sym_alloc_lcb (struct sym_hcb *np, u_char tn, u_char ln) | |||
5082 | lp->started_max = SYM_CONF_MAX_TASK; | 4991 | lp->started_max = SYM_CONF_MAX_TASK; |
5083 | lp->started_limit = SYM_CONF_MAX_TASK; | 4992 | lp->started_limit = SYM_CONF_MAX_TASK; |
5084 | #endif | 4993 | #endif |
5085 | /* | 4994 | |
5086 | * If we are busy, count the IO. | ||
5087 | */ | ||
5088 | if (sym_is_bit(tp->busy0_map, ln)) { | ||
5089 | lp->busy_itl = 1; | ||
5090 | sym_clr_bit(tp->busy0_map, ln); | ||
5091 | } | ||
5092 | fail: | 4995 | fail: |
5093 | return lp; | 4996 | return lp; |
5094 | } | 4997 | } |
@@ -5103,12 +5006,6 @@ static void sym_alloc_lcb_tags (struct sym_hcb *np, u_char tn, u_char ln) | |||
5103 | int i; | 5006 | int i; |
5104 | 5007 | ||
5105 | /* | 5008 | /* |
5106 | * If LCB not available, try to allocate it. | ||
5107 | */ | ||
5108 | if (!lp && !(lp = sym_alloc_lcb(np, tn, ln))) | ||
5109 | goto fail; | ||
5110 | |||
5111 | /* | ||
5112 | * Allocate the task table and and the tag allocation | 5009 | * Allocate the task table and and the tag allocation |
5113 | * circular buffer. We want both or none. | 5010 | * circular buffer. We want both or none. |
5114 | */ | 5011 | */ |
@@ -5481,8 +5378,7 @@ finish: | |||
5481 | /* | 5378 | /* |
5482 | * Donnot start more than 1 command after an error. | 5379 | * Donnot start more than 1 command after an error. |
5483 | */ | 5380 | */ |
5484 | if (lp) | 5381 | sym_start_next_ccbs(np, lp, 1); |
5485 | sym_start_next_ccbs(np, lp, 1); | ||
5486 | #endif | 5382 | #endif |
5487 | } | 5383 | } |
5488 | 5384 | ||
@@ -5521,17 +5417,11 @@ void sym_complete_ok (struct sym_hcb *np, struct sym_ccb *cp) | |||
5521 | lp = sym_lp(tp, cp->lun); | 5417 | lp = sym_lp(tp, cp->lun); |
5522 | 5418 | ||
5523 | /* | 5419 | /* |
5524 | * Assume device discovered on first success. | ||
5525 | */ | ||
5526 | if (!lp) | ||
5527 | sym_set_bit(tp->lun_map, cp->lun); | ||
5528 | |||
5529 | /* | ||
5530 | * If all data have been transferred, given than no | 5420 | * If all data have been transferred, given than no |
5531 | * extended error did occur, there is no residual. | 5421 | * extended error did occur, there is no residual. |
5532 | */ | 5422 | */ |
5533 | resid = 0; | 5423 | resid = 0; |
5534 | if (cp->phys.head.lastp != sym_goalp(cp)) | 5424 | if (cp->phys.head.lastp != cp->goalp) |
5535 | resid = sym_compute_residual(np, cp); | 5425 | resid = sym_compute_residual(np, cp); |
5536 | 5426 | ||
5537 | /* | 5427 | /* |
@@ -5551,15 +5441,6 @@ if (resid) | |||
5551 | */ | 5441 | */ |
5552 | sym_set_cam_result_ok(cp, cmd, resid); | 5442 | sym_set_cam_result_ok(cp, cmd, resid); |
5553 | 5443 | ||
5554 | #ifdef SYM_OPT_SNIFF_INQUIRY | ||
5555 | /* | ||
5556 | * On standard INQUIRY response (EVPD and CmDt | ||
5557 | * not set), sniff out device capabilities. | ||
5558 | */ | ||
5559 | if (cp->cdb_buf[0] == INQUIRY && !(cp->cdb_buf[1] & 0x3)) | ||
5560 | sym_sniff_inquiry(np, cmd, resid); | ||
5561 | #endif | ||
5562 | |||
5563 | #ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING | 5444 | #ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING |
5564 | /* | 5445 | /* |
5565 | * If max number of started ccbs had been reduced, | 5446 | * If max number of started ccbs had been reduced, |
@@ -5587,7 +5468,7 @@ if (resid) | |||
5587 | /* | 5468 | /* |
5588 | * Requeue a couple of awaiting scsi commands. | 5469 | * Requeue a couple of awaiting scsi commands. |
5589 | */ | 5470 | */ |
5590 | if (lp && !sym_que_empty(&lp->waiting_ccbq)) | 5471 | if (!sym_que_empty(&lp->waiting_ccbq)) |
5591 | sym_start_next_ccbs(np, lp, 2); | 5472 | sym_start_next_ccbs(np, lp, 2); |
5592 | #endif | 5473 | #endif |
5593 | /* | 5474 | /* |
@@ -5830,8 +5711,7 @@ void sym_hcb_free(struct sym_hcb *np) | |||
5830 | SYM_QUEHEAD *qp; | 5711 | SYM_QUEHEAD *qp; |
5831 | struct sym_ccb *cp; | 5712 | struct sym_ccb *cp; |
5832 | struct sym_tcb *tp; | 5713 | struct sym_tcb *tp; |
5833 | struct sym_lcb *lp; | 5714 | int target; |
5834 | int target, lun; | ||
5835 | 5715 | ||
5836 | if (np->scriptz0) | 5716 | if (np->scriptz0) |
5837 | sym_mfree_dma(np->scriptz0, np->scriptz_sz, "SCRIPTZ0"); | 5717 | sym_mfree_dma(np->scriptz0, np->scriptz_sz, "SCRIPTZ0"); |
@@ -5857,16 +5737,6 @@ void sym_hcb_free(struct sym_hcb *np) | |||
5857 | 5737 | ||
5858 | for (target = 0; target < SYM_CONF_MAX_TARGET ; target++) { | 5738 | for (target = 0; target < SYM_CONF_MAX_TARGET ; target++) { |
5859 | tp = &np->target[target]; | 5739 | tp = &np->target[target]; |
5860 | for (lun = 0 ; lun < SYM_CONF_MAX_LUN ; lun++) { | ||
5861 | lp = sym_lp(tp, lun); | ||
5862 | if (!lp) | ||
5863 | continue; | ||
5864 | if (lp->itlq_tbl) | ||
5865 | sym_mfree_dma(lp->itlq_tbl, SYM_CONF_MAX_TASK*4, | ||
5866 | "ITLQ_TBL"); | ||
5867 | kfree(lp->cb_tags); | ||
5868 | sym_mfree_dma(lp, sizeof(*lp), "LCB"); | ||
5869 | } | ||
5870 | #if SYM_CONF_MAX_LUN > 1 | 5740 | #if SYM_CONF_MAX_LUN > 1 |
5871 | kfree(tp->lunmp); | 5741 | kfree(tp->lunmp); |
5872 | #endif | 5742 | #endif |