aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2005-11-29 23:08:31 -0500
committerJames Bottomley <jejb@mulgrave.(none)>2005-12-13 20:11:33 -0500
commit84e203a279d3de1c8a41a73ab45e55a89bc19345 (patch)
tree3015ec3496d9e8ed0dceb5beea5ec28ede6f1a0d /drivers
parent760c9de589175f5285668d17825c259aec08370c (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')
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c59
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.c86
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.h14
3 files changed, 38 insertions, 121 deletions
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index 7fc0b97173e1..a2bfdf8417a2 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -563,10 +563,7 @@ int sym_setup_data_and_start(struct sym_hcb *np, struct scsi_cmnd *cmd, struct s
563 /* 563 /*
564 * activate this job. 564 * activate this job.
565 */ 565 */
566 if (lp) 566 sym_start_next_ccbs(np, lp, 2);
567 sym_start_next_ccbs(np, lp, 2);
568 else
569 sym_put_start_queue(np, cp);
570 return 0; 567 return 0;
571 568
572out_abort: 569out_abort:
@@ -981,15 +978,13 @@ static int device_queue_depth(struct sym_hcb *np, int target, int lun)
981 978
982static int sym53c8xx_slave_alloc(struct scsi_device *sdev) 979static int sym53c8xx_slave_alloc(struct scsi_device *sdev)
983{ 980{
984 struct sym_hcb *np; 981 struct sym_hcb *np = sym_get_hcb(sdev->host);
985 struct sym_tcb *tp; 982 struct sym_tcb *tp = &np->target[sdev->id];
983 struct sym_lcb *lp;
986 984
987 if (sdev->id >= SYM_CONF_MAX_TARGET || sdev->lun >= SYM_CONF_MAX_LUN) 985 if (sdev->id >= SYM_CONF_MAX_TARGET || sdev->lun >= SYM_CONF_MAX_LUN)
988 return -ENXIO; 986 return -ENXIO;
989 987
990 np = sym_get_hcb(sdev->host);
991 tp = &np->target[sdev->id];
992
993 /* 988 /*
994 * Fail the device init if the device is flagged NOSCAN at BOOT in 989 * Fail the device init if the device is flagged NOSCAN at BOOT in
995 * the NVRAM. This may speed up boot and maintain coherency with 990 * the NVRAM. This may speed up boot and maintain coherency with
@@ -1005,6 +1000,10 @@ static int sym53c8xx_slave_alloc(struct scsi_device *sdev)
1005 return -ENXIO; 1000 return -ENXIO;
1006 } 1001 }
1007 1002
1003 lp = sym_alloc_lcb(np, sdev->id, sdev->lun);
1004 if (!lp)
1005 return -ENOMEM;
1006
1008 tp->starget = sdev->sdev_target; 1007 tp->starget = sdev->sdev_target;
1009 return 0; 1008 return 0;
1010} 1009}
@@ -1012,22 +1011,14 @@ static int sym53c8xx_slave_alloc(struct scsi_device *sdev)
1012/* 1011/*
1013 * Linux entry point for device queue sizing. 1012 * Linux entry point for device queue sizing.
1014 */ 1013 */
1015static int sym53c8xx_slave_configure(struct scsi_device *device) 1014static int sym53c8xx_slave_configure(struct scsi_device *sdev)
1016{ 1015{
1017 struct sym_hcb *np = sym_get_hcb(device->host); 1016 struct sym_hcb *np = sym_get_hcb(sdev->host);
1018 struct sym_tcb *tp = &np->target[device->id]; 1017 struct sym_tcb *tp = &np->target[sdev->id];
1019 struct sym_lcb *lp; 1018 struct sym_lcb *lp = sym_lp(tp, sdev->lun);
1020 int reqtags, depth_to_use; 1019 int reqtags, depth_to_use;
1021 1020
1022 /* 1021 /*
1023 * Allocate the LCB if not yet.
1024 * If it fail, we may well be in the sh*t. :)
1025 */
1026 lp = sym_alloc_lcb(np, device->id, device->lun);
1027 if (!lp)
1028 return -ENOMEM;
1029
1030 /*
1031 * Get user flags. 1022 * Get user flags.
1032 */ 1023 */
1033 lp->curr_flags = lp->user_flags; 1024 lp->curr_flags = lp->user_flags;
@@ -1038,10 +1029,10 @@ static int sym53c8xx_slave_configure(struct scsi_device *device)
1038 * Use at least 2. 1029 * Use at least 2.
1039 * Donnot use more than our maximum. 1030 * Donnot use more than our maximum.
1040 */ 1031 */
1041 reqtags = device_queue_depth(np, device->id, device->lun); 1032 reqtags = device_queue_depth(np, sdev->id, sdev->lun);
1042 if (reqtags > tp->usrtags) 1033 if (reqtags > tp->usrtags)
1043 reqtags = tp->usrtags; 1034 reqtags = tp->usrtags;
1044 if (!device->tagged_supported) 1035 if (!sdev->tagged_supported)
1045 reqtags = 0; 1036 reqtags = 0;
1046#if 1 /* Avoid to locally queue commands for no good reasons */ 1037#if 1 /* Avoid to locally queue commands for no good reasons */
1047 if (reqtags > SYM_CONF_MAX_TAG) 1038 if (reqtags > SYM_CONF_MAX_TAG)
@@ -1050,19 +1041,30 @@ static int sym53c8xx_slave_configure(struct scsi_device *device)
1050#else 1041#else
1051 depth_to_use = (reqtags ? SYM_CONF_MAX_TAG : 2); 1042 depth_to_use = (reqtags ? SYM_CONF_MAX_TAG : 2);
1052#endif 1043#endif
1053 scsi_adjust_queue_depth(device, 1044 scsi_adjust_queue_depth(sdev,
1054 (device->tagged_supported ? 1045 (sdev->tagged_supported ?
1055 MSG_SIMPLE_TAG : 0), 1046 MSG_SIMPLE_TAG : 0),
1056 depth_to_use); 1047 depth_to_use);
1057 lp->s.scdev_depth = depth_to_use; 1048 lp->s.scdev_depth = depth_to_use;
1058 sym_tune_dev_queuing(tp, device->lun, reqtags); 1049 sym_tune_dev_queuing(tp, sdev->lun, reqtags);
1059 1050
1060 if (!spi_initial_dv(device->sdev_target)) 1051 if (!spi_initial_dv(sdev->sdev_target))
1061 spi_dv_device(device); 1052 spi_dv_device(sdev);
1062 1053
1063 return 0; 1054 return 0;
1064} 1055}
1065 1056
1057static void sym53c8xx_slave_destroy(struct scsi_device *sdev)
1058{
1059 struct sym_hcb *np = sym_get_hcb(sdev->host);
1060 struct sym_lcb *lp = sym_lp(&np->target[sdev->id], sdev->lun);
1061
1062 if (lp->itlq_tbl)
1063 sym_mfree_dma(lp->itlq_tbl, SYM_CONF_MAX_TASK * 4, "ITLQ_TBL");
1064 kfree(lp->cb_tags);
1065 sym_mfree_dma(lp, sizeof(*lp), "LCB");
1066}
1067
1066/* 1068/*
1067 * Linux entry point for info() function 1069 * Linux entry point for info() function
1068 */ 1070 */
@@ -1926,6 +1928,7 @@ static struct scsi_host_template sym2_template = {
1926 .queuecommand = sym53c8xx_queue_command, 1928 .queuecommand = sym53c8xx_queue_command,
1927 .slave_alloc = sym53c8xx_slave_alloc, 1929 .slave_alloc = sym53c8xx_slave_alloc,
1928 .slave_configure = sym53c8xx_slave_configure, 1930 .slave_configure = sym53c8xx_slave_configure,
1931 .slave_destroy = sym53c8xx_slave_destroy,
1929 .eh_abort_handler = sym53c8xx_eh_abort_handler, 1932 .eh_abort_handler = sym53c8xx_eh_abort_handler,
1930 .eh_device_reset_handler = sym53c8xx_eh_device_reset_handler, 1933 .eh_device_reset_handler = sym53c8xx_eh_device_reset_handler,
1931 .eh_bus_reset_handler = sym53c8xx_eh_bus_reset_handler, 1934 .eh_bus_reset_handler = sym53c8xx_eh_bus_reset_handler,
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 */
1526void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp) 1526static 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)
4997struct sym_lcb *sym_alloc_lcb (struct sym_hcb *np, u_char tn, u_char ln) 4968struct 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 }
5092fail: 5044fail:
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
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h
index 3a264a408216..756008812aa1 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.h
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h
@@ -416,19 +416,6 @@ struct sym_tcb {
416 struct sym_lcb **lunmp; /* Other LCBs [1..MAX_LUN] */ 416 struct sym_lcb **lunmp; /* Other LCBs [1..MAX_LUN] */
417#endif 417#endif
418 418
419 /*
420 * Bitmap that tells about LUNs that succeeded at least
421 * 1 IO and therefore assumed to be a real device.
422 * Avoid useless allocation of the LCB structure.
423 */
424 u32 lun_map[(SYM_CONF_MAX_LUN+31)/32];
425
426 /*
427 * Bitmap that tells about LUNs that haven't yet an LCB
428 * allocated (not discovered or LCB allocation failed).
429 */
430 u32 busy0_map[(SYM_CONF_MAX_LUN+31)/32];
431
432#ifdef SYM_HAVE_STCB 419#ifdef SYM_HAVE_STCB
433 /* 420 /*
434 * O/S specific data structure. 421 * O/S specific data structure.
@@ -1077,7 +1064,6 @@ char *sym_driver_name(void);
1077void sym_print_xerr(struct scsi_cmnd *cmd, int x_status); 1064void sym_print_xerr(struct scsi_cmnd *cmd, int x_status);
1078int sym_reset_scsi_bus(struct sym_hcb *np, int enab_int); 1065int sym_reset_scsi_bus(struct sym_hcb *np, int enab_int);
1079struct sym_chip *sym_lookup_chip_table(u_short device_id, u_char revision); 1066struct sym_chip *sym_lookup_chip_table(u_short device_id, u_char revision);
1080void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp);
1081#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING 1067#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING
1082void sym_start_next_ccbs(struct sym_hcb *np, struct sym_lcb *lp, int maxn); 1068void sym_start_next_ccbs(struct sym_hcb *np, struct sym_lcb *lp, int maxn);
1083#endif 1069#endif