diff options
author | Matthew Wilcox <matthew@wil.cx> | 2005-11-29 23:08:31 -0500 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.(none)> | 2005-12-13 20:11:33 -0500 |
commit | 84e203a279d3de1c8a41a73ab45e55a89bc19345 (patch) | |
tree | 3015ec3496d9e8ed0dceb5beea5ec28ede6f1a0d /drivers/scsi/sym53c8xx_2/sym_hipd.c | |
parent | 760c9de589175f5285668d17825c259aec08370c (diff) |
[SCSI] sym2: Manage sym_lcb properly
Allocate the lcb in slave_alloc and free it in slave_destroy. This allows
us to remove all the code that checks to see if it's already been allocated.
From: Christoph Hellwig <hch@lst.de>
Signed-off-by: Matthew Wilcox <matthew@wil.cx>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/sym53c8xx_2/sym_hipd.c')
-rw-r--r-- | drivers/scsi/sym53c8xx_2/sym_hipd.c | 86 |
1 files changed, 7 insertions, 79 deletions
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index 113e3b357163..bec644850d3b 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c | |||
@@ -1523,7 +1523,7 @@ static int sym_prepare_nego(struct sym_hcb *np, struct sym_ccb *cp, u_char *msgp | |||
1523 | /* | 1523 | /* |
1524 | * Insert a job into the start queue. | 1524 | * Insert a job into the start queue. |
1525 | */ | 1525 | */ |
1526 | void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp) | 1526 | static void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp) |
1527 | { | 1527 | { |
1528 | u_short qidx; | 1528 | u_short qidx; |
1529 | 1529 | ||
@@ -4664,30 +4664,7 @@ struct sym_ccb *sym_get_ccb (struct sym_hcb *np, struct scsi_cmnd *cmd, u_char t | |||
4664 | goto out; | 4664 | goto out; |
4665 | cp = sym_que_entry(qp, struct sym_ccb, link_ccbq); | 4665 | cp = sym_que_entry(qp, struct sym_ccb, link_ccbq); |
4666 | 4666 | ||
4667 | #ifndef SYM_OPT_HANDLE_DEVICE_QUEUEING | 4667 | { |
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 | /* | 4668 | /* |
4692 | * If we have been asked for a tagged command. | 4669 | * If we have been asked for a tagged command. |
4693 | */ | 4670 | */ |
@@ -4840,12 +4817,6 @@ void sym_free_ccb (struct sym_hcb *np, struct sym_ccb *cp) | |||
4840 | lp->head.resel_sa = | 4817 | lp->head.resel_sa = |
4841 | cpu_to_scr(SCRIPTB_BA(np, resel_bad_lun)); | 4818 | cpu_to_scr(SCRIPTB_BA(np, resel_bad_lun)); |
4842 | } | 4819 | } |
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 | 4820 | ||
4850 | /* | 4821 | /* |
4851 | * We donnot queue more than 1 ccb per target | 4822 | * We donnot queue more than 1 ccb per target |
@@ -4997,20 +4968,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) | 4968 | struct sym_lcb *sym_alloc_lcb (struct sym_hcb *np, u_char tn, u_char ln) |
4998 | { | 4969 | { |
4999 | struct sym_tcb *tp = &np->target[tn]; | 4970 | struct sym_tcb *tp = &np->target[tn]; |
5000 | struct sym_lcb *lp = sym_lp(tp, ln); | 4971 | 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 | 4972 | ||
5015 | /* | 4973 | /* |
5016 | * Initialize the target control block if not yet. | 4974 | * Initialize the target control block if not yet. |
@@ -5082,13 +5040,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; | 5040 | lp->started_max = SYM_CONF_MAX_TASK; |
5083 | lp->started_limit = SYM_CONF_MAX_TASK; | 5041 | lp->started_limit = SYM_CONF_MAX_TASK; |
5084 | #endif | 5042 | #endif |
5085 | /* | 5043 | |
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: | 5044 | fail: |
5093 | return lp; | 5045 | return lp; |
5094 | } | 5046 | } |
@@ -5103,12 +5055,6 @@ static void sym_alloc_lcb_tags (struct sym_hcb *np, u_char tn, u_char ln) | |||
5103 | int i; | 5055 | int i; |
5104 | 5056 | ||
5105 | /* | 5057 | /* |
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 | 5058 | * Allocate the task table and and the tag allocation |
5113 | * circular buffer. We want both or none. | 5059 | * circular buffer. We want both or none. |
5114 | */ | 5060 | */ |
@@ -5481,8 +5427,7 @@ finish: | |||
5481 | /* | 5427 | /* |
5482 | * Donnot start more than 1 command after an error. | 5428 | * Donnot start more than 1 command after an error. |
5483 | */ | 5429 | */ |
5484 | if (lp) | 5430 | sym_start_next_ccbs(np, lp, 1); |
5485 | sym_start_next_ccbs(np, lp, 1); | ||
5486 | #endif | 5431 | #endif |
5487 | } | 5432 | } |
5488 | 5433 | ||
@@ -5521,12 +5466,6 @@ void sym_complete_ok (struct sym_hcb *np, struct sym_ccb *cp) | |||
5521 | lp = sym_lp(tp, cp->lun); | 5466 | lp = sym_lp(tp, cp->lun); |
5522 | 5467 | ||
5523 | /* | 5468 | /* |
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 | 5469 | * If all data have been transferred, given than no |
5531 | * extended error did occur, there is no residual. | 5470 | * extended error did occur, there is no residual. |
5532 | */ | 5471 | */ |
@@ -5578,7 +5517,7 @@ if (resid) | |||
5578 | /* | 5517 | /* |
5579 | * Requeue a couple of awaiting scsi commands. | 5518 | * Requeue a couple of awaiting scsi commands. |
5580 | */ | 5519 | */ |
5581 | if (lp && !sym_que_empty(&lp->waiting_ccbq)) | 5520 | if (!sym_que_empty(&lp->waiting_ccbq)) |
5582 | sym_start_next_ccbs(np, lp, 2); | 5521 | sym_start_next_ccbs(np, lp, 2); |
5583 | #endif | 5522 | #endif |
5584 | /* | 5523 | /* |
@@ -5821,8 +5760,7 @@ void sym_hcb_free(struct sym_hcb *np) | |||
5821 | SYM_QUEHEAD *qp; | 5760 | SYM_QUEHEAD *qp; |
5822 | struct sym_ccb *cp; | 5761 | struct sym_ccb *cp; |
5823 | struct sym_tcb *tp; | 5762 | struct sym_tcb *tp; |
5824 | struct sym_lcb *lp; | 5763 | int target; |
5825 | int target, lun; | ||
5826 | 5764 | ||
5827 | if (np->scriptz0) | 5765 | if (np->scriptz0) |
5828 | sym_mfree_dma(np->scriptz0, np->scriptz_sz, "SCRIPTZ0"); | 5766 | sym_mfree_dma(np->scriptz0, np->scriptz_sz, "SCRIPTZ0"); |
@@ -5848,16 +5786,6 @@ void sym_hcb_free(struct sym_hcb *np) | |||
5848 | 5786 | ||
5849 | for (target = 0; target < SYM_CONF_MAX_TARGET ; target++) { | 5787 | for (target = 0; target < SYM_CONF_MAX_TARGET ; target++) { |
5850 | tp = &np->target[target]; | 5788 | tp = &np->target[target]; |
5851 | for (lun = 0 ; lun < SYM_CONF_MAX_LUN ; lun++) { | ||
5852 | lp = sym_lp(tp, lun); | ||
5853 | if (!lp) | ||
5854 | continue; | ||
5855 | if (lp->itlq_tbl) | ||
5856 | sym_mfree_dma(lp->itlq_tbl, SYM_CONF_MAX_TASK*4, | ||
5857 | "ITLQ_TBL"); | ||
5858 | kfree(lp->cb_tags); | ||
5859 | sym_mfree_dma(lp, sizeof(*lp), "LCB"); | ||
5860 | } | ||
5861 | #if SYM_CONF_MAX_LUN > 1 | 5789 | #if SYM_CONF_MAX_LUN > 1 |
5862 | kfree(tp->lunmp); | 5790 | kfree(tp->lunmp); |
5863 | #endif | 5791 | #endif |