aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sym53c8xx_2/sym_hipd.c
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2005-05-20 14:15:43 -0400
committerJames Bottomley <jejb@mulgrave.(none)>2005-05-26 09:41:14 -0400
commit53222b906903fd861dc24ebccfa07ee125941313 (patch)
treea39e9a20718d01b67e89c14baa0e11411643c993 /drivers/scsi/sym53c8xx_2/sym_hipd.c
parent7c00ffa314bf0fb0e23858bbebad33b48b6abbb9 (diff)
[SCSI] sym2 version 2.2.1
sym2 version 2.2.1: - Fix MMIO BAR detection (Thanks to Bob Picco) - Fix odd-sized transfers with a wide bus (Thanks to Larry Stephens) - Write posting fixes (Thanks to Thibaut Varene) - Change one of the GFP_KERNEL allocations back into a GFP_ATOMIC - Make CCB_BA() return a script-endian address - Move range checks and disabling of devices from the queuecommand path to slave_alloc() - Remove a warning in sym_setup_cdb() - Keep a pointer to the scsi_target instead of the scsi_dev in the tcb - Remove a check for the upper layers passing an oversized cmd - Replace CAM_REQ_ constants with the Linux DID_ constants - Replace CAM_DIR_ constants with the Linux DMA_ constants - Inline sym_read_parisc_pdc() on non-parisc systems 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.c65
1 files changed, 36 insertions, 29 deletions
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c
index 50a176b3888d..e753ba27dc59 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.c
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c
@@ -97,7 +97,7 @@ static void sym_print_msg(struct sym_ccb *cp, char *label, u_char *msg)
97static void sym_print_nego_msg(struct sym_hcb *np, int target, char *label, u_char *msg) 97static void sym_print_nego_msg(struct sym_hcb *np, int target, char *label, u_char *msg)
98{ 98{
99 struct sym_tcb *tp = &np->target[target]; 99 struct sym_tcb *tp = &np->target[target];
100 dev_info(&tp->sdev->sdev_target->dev, "%s: ", label); 100 dev_info(&tp->starget->dev, "%s: ", label);
101 101
102 sym_show_msg(msg); 102 sym_show_msg(msg);
103 printf(".\n"); 103 printf(".\n");
@@ -149,8 +149,10 @@ static char *sym_scsi_bus_mode(int mode)
149static void sym_chip_reset (struct sym_hcb *np) 149static void sym_chip_reset (struct sym_hcb *np)
150{ 150{
151 OUTB(np, nc_istat, SRST); 151 OUTB(np, nc_istat, SRST);
152 INB(np, nc_mbox1);
152 udelay(10); 153 udelay(10);
153 OUTB(np, nc_istat, 0); 154 OUTB(np, nc_istat, 0);
155 INB(np, nc_mbox1);
154 udelay(2000); /* For BUS MODE to settle */ 156 udelay(2000); /* For BUS MODE to settle */
155} 157}
156 158
@@ -216,6 +218,7 @@ int sym_reset_scsi_bus(struct sym_hcb *np, int enab_int)
216 OUTB(np, nc_stest3, TE); 218 OUTB(np, nc_stest3, TE);
217 OUTB(np, nc_dcntl, (np->rv_dcntl & IRQM)); 219 OUTB(np, nc_dcntl, (np->rv_dcntl & IRQM));
218 OUTB(np, nc_scntl1, CRST); 220 OUTB(np, nc_scntl1, CRST);
221 INB(np, nc_mbox1);
219 udelay(200); 222 udelay(200);
220 223
221 if (!SYM_SETUP_SCSI_BUS_CHECK) 224 if (!SYM_SETUP_SCSI_BUS_CHECK)
@@ -280,8 +283,10 @@ static void sym_selectclock(struct sym_hcb *np, u_char scntl3)
280 if (!i) 283 if (!i)
281 printf("%s: the chip cannot lock the frequency\n", 284 printf("%s: the chip cannot lock the frequency\n",
282 sym_name(np)); 285 sym_name(np));
283 } else 286 } else {
284 udelay((50+10)); 287 INB(np, nc_mbox1);
288 udelay(50+10);
289 }
285 OUTB(np, nc_stest3, HSC); /* Halt the scsi clock */ 290 OUTB(np, nc_stest3, HSC); /* Halt the scsi clock */
286 OUTB(np, nc_scntl3, scntl3); 291 OUTB(np, nc_scntl3, scntl3);
287 OUTB(np, nc_stest1, (DBLEN|DBLSEL));/* Select clock multiplier */ 292 OUTB(np, nc_stest1, (DBLEN|DBLSEL));/* Select clock multiplier */
@@ -1445,7 +1450,7 @@ static void sym_check_goals(struct sym_hcb *np, struct scsi_target *starget,
1445static int sym_prepare_nego(struct sym_hcb *np, struct sym_ccb *cp, u_char *msgptr) 1450static int sym_prepare_nego(struct sym_hcb *np, struct sym_ccb *cp, u_char *msgptr)
1446{ 1451{
1447 struct sym_tcb *tp = &np->target[cp->target]; 1452 struct sym_tcb *tp = &np->target[cp->target];
1448 struct scsi_target *starget = tp->sdev->sdev_target; 1453 struct scsi_target *starget = tp->starget;
1449 struct sym_trans *goal = &tp->tgoal; 1454 struct sym_trans *goal = &tp->tgoal;
1450 int msglen = 0; 1455 int msglen = 0;
1451 int nego; 1456 int nego;
@@ -1690,7 +1695,7 @@ static void sym_flush_comp_queue(struct sym_hcb *np, int cam_status)
1690 if (cam_status) 1695 if (cam_status)
1691 sym_set_cam_status(cmd, cam_status); 1696 sym_set_cam_status(cmd, cam_status);
1692#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING 1697#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING
1693 if (sym_get_cam_status(cmd) == CAM_REQUEUE_REQ) { 1698 if (sym_get_cam_status(cmd) == DID_SOFT_ERROR) {
1694 struct sym_tcb *tp = &np->target[cp->target]; 1699 struct sym_tcb *tp = &np->target[cp->target];
1695 struct sym_lcb *lp = sym_lp(tp, cp->lun); 1700 struct sym_lcb *lp = sym_lp(tp, cp->lun);
1696 if (lp) { 1701 if (lp) {
@@ -1791,12 +1796,13 @@ void sym_start_up (struct sym_hcb *np, int reason)
1791 /* 1796 /*
1792 * Wakeup all pending jobs. 1797 * Wakeup all pending jobs.
1793 */ 1798 */
1794 sym_flush_busy_queue(np, CAM_SCSI_BUS_RESET); 1799 sym_flush_busy_queue(np, DID_RESET);
1795 1800
1796 /* 1801 /*
1797 * Init chip. 1802 * Init chip.
1798 */ 1803 */
1799 OUTB(np, nc_istat, 0x00); /* Remove Reset, abort */ 1804 OUTB(np, nc_istat, 0x00); /* Remove Reset, abort */
1805 INB(np, nc_mbox1);
1800 udelay(2000); /* The 895 needs time for the bus mode to settle */ 1806 udelay(2000); /* The 895 needs time for the bus mode to settle */
1801 1807
1802 OUTB(np, nc_scntl0, np->rv_scntl0 | 0xc0); 1808 OUTB(np, nc_scntl0, np->rv_scntl0 | 0xc0);
@@ -1905,6 +1911,7 @@ void sym_start_up (struct sym_hcb *np, int reason)
1905 if (np->features & (FE_ULTRA2|FE_ULTRA3)) { 1911 if (np->features & (FE_ULTRA2|FE_ULTRA3)) {
1906 OUTONW(np, nc_sien, SBMC); 1912 OUTONW(np, nc_sien, SBMC);
1907 if (reason == 0) { 1913 if (reason == 0) {
1914 INB(np, nc_mbox1);
1908 mdelay(100); 1915 mdelay(100);
1909 INW(np, nc_sist); 1916 INW(np, nc_sist);
1910 } 1917 }
@@ -2074,7 +2081,7 @@ static void sym_settrans(struct sym_hcb *np, int target, u_char opts, u_char ofs
2074static void sym_setwide(struct sym_hcb *np, int target, u_char wide) 2081static void sym_setwide(struct sym_hcb *np, int target, u_char wide)
2075{ 2082{
2076 struct sym_tcb *tp = &np->target[target]; 2083 struct sym_tcb *tp = &np->target[target];
2077 struct scsi_target *starget = tp->sdev->sdev_target; 2084 struct scsi_target *starget = tp->starget;
2078 2085
2079 if (spi_width(starget) == wide) 2086 if (spi_width(starget) == wide)
2080 return; 2087 return;
@@ -2102,7 +2109,7 @@ sym_setsync(struct sym_hcb *np, int target,
2102 u_char ofs, u_char per, u_char div, u_char fak) 2109 u_char ofs, u_char per, u_char div, u_char fak)
2103{ 2110{
2104 struct sym_tcb *tp = &np->target[target]; 2111 struct sym_tcb *tp = &np->target[target];
2105 struct scsi_target *starget = tp->sdev->sdev_target; 2112 struct scsi_target *starget = tp->starget;
2106 u_char wide = (tp->head.wval & EWS) ? BUS_16_BIT : BUS_8_BIT; 2113 u_char wide = (tp->head.wval & EWS) ? BUS_16_BIT : BUS_8_BIT;
2107 2114
2108 sym_settrans(np, target, 0, ofs, per, wide, div, fak); 2115 sym_settrans(np, target, 0, ofs, per, wide, div, fak);
@@ -2129,7 +2136,7 @@ sym_setpprot(struct sym_hcb *np, int target, u_char opts, u_char ofs,
2129 u_char per, u_char wide, u_char div, u_char fak) 2136 u_char per, u_char wide, u_char div, u_char fak)
2130{ 2137{
2131 struct sym_tcb *tp = &np->target[target]; 2138 struct sym_tcb *tp = &np->target[target];
2132 struct scsi_target *starget = tp->sdev->sdev_target; 2139 struct scsi_target *starget = tp->starget;
2133 2140
2134 sym_settrans(np, target, opts, ofs, per, wide, div, fak); 2141 sym_settrans(np, target, opts, ofs, per, wide, div, fak);
2135 2142
@@ -2944,7 +2951,7 @@ unknown_int:
2944 * Dequeue from the START queue all CCBs that match 2951 * Dequeue from the START queue all CCBs that match
2945 * a given target/lun/task condition (-1 means all), 2952 * a given target/lun/task condition (-1 means all),
2946 * and move them from the BUSY queue to the COMP queue 2953 * and move them from the BUSY queue to the COMP queue
2947 * with CAM_REQUEUE_REQ status condition. 2954 * with DID_SOFT_ERROR status condition.
2948 * This function is used during error handling/recovery. 2955 * This function is used during error handling/recovery.
2949 * It is called with SCRIPTS not running. 2956 * It is called with SCRIPTS not running.
2950 */ 2957 */
@@ -2974,7 +2981,7 @@ sym_dequeue_from_squeue(struct sym_hcb *np, int i, int target, int lun, int task
2974 if ((target == -1 || cp->target == target) && 2981 if ((target == -1 || cp->target == target) &&
2975 (lun == -1 || cp->lun == lun) && 2982 (lun == -1 || cp->lun == lun) &&
2976 (task == -1 || cp->tag == task)) { 2983 (task == -1 || cp->tag == task)) {
2977 sym_set_cam_status(cp->cmd, CAM_REQUEUE_REQ); 2984 sym_set_cam_status(cp->cmd, DID_SOFT_ERROR);
2978 sym_remque(&cp->link_ccbq); 2985 sym_remque(&cp->link_ccbq);
2979 sym_insque_tail(&cp->link_ccbq, &np->comp_ccbq); 2986 sym_insque_tail(&cp->link_ccbq, &np->comp_ccbq);
2980 } 2987 }
@@ -3093,13 +3100,13 @@ static void sym_sir_bad_scsi_status(struct sym_hcb *np, int num, struct sym_ccb
3093 /* 3100 /*
3094 * Message table indirect structure. 3101 * Message table indirect structure.
3095 */ 3102 */
3096 cp->phys.smsg.addr = cpu_to_scr(CCB_BA(cp, scsi_smsg2)); 3103 cp->phys.smsg.addr = CCB_BA(cp, scsi_smsg2);
3097 cp->phys.smsg.size = cpu_to_scr(msglen); 3104 cp->phys.smsg.size = cpu_to_scr(msglen);
3098 3105
3099 /* 3106 /*
3100 * sense command 3107 * sense command
3101 */ 3108 */
3102 cp->phys.cmd.addr = cpu_to_scr(CCB_BA(cp, sensecmd)); 3109 cp->phys.cmd.addr = CCB_BA(cp, sensecmd);
3103 cp->phys.cmd.size = cpu_to_scr(6); 3110 cp->phys.cmd.size = cpu_to_scr(6);
3104 3111
3105 /* 3112 /*
@@ -3116,7 +3123,7 @@ static void sym_sir_bad_scsi_status(struct sym_hcb *np, int num, struct sym_ccb
3116 * sense data 3123 * sense data
3117 */ 3124 */
3118 memset(cp->sns_bbuf, 0, SYM_SNS_BBUF_LEN); 3125 memset(cp->sns_bbuf, 0, SYM_SNS_BBUF_LEN);
3119 cp->phys.sense.addr = cpu_to_scr(CCB_BA(cp, sns_bbuf)); 3126 cp->phys.sense.addr = CCB_BA(cp, sns_bbuf);
3120 cp->phys.sense.size = cpu_to_scr(SYM_SNS_BBUF_LEN); 3127 cp->phys.sense.size = cpu_to_scr(SYM_SNS_BBUF_LEN);
3121 3128
3122 /* 3129 /*
@@ -3198,7 +3205,7 @@ int sym_clear_tasks(struct sym_hcb *np, int cam_status, int target, int lun, int
3198 sym_insque_tail(&cp->link_ccbq, &np->comp_ccbq); 3205 sym_insque_tail(&cp->link_ccbq, &np->comp_ccbq);
3199 3206
3200 /* Preserve the software timeout condition */ 3207 /* Preserve the software timeout condition */
3201 if (sym_get_cam_status(cmd) != CAM_CMD_TIMEOUT) 3208 if (sym_get_cam_status(cmd) != DID_TIME_OUT)
3202 sym_set_cam_status(cmd, cam_status); 3209 sym_set_cam_status(cmd, cam_status);
3203 ++i; 3210 ++i;
3204#if 0 3211#if 0
@@ -3366,7 +3373,7 @@ static void sym_sir_task_recovery(struct sym_hcb *np, int num)
3366 * Make sure at least our IO to abort has been dequeued. 3373 * Make sure at least our IO to abort has been dequeued.
3367 */ 3374 */
3368#ifndef SYM_OPT_HANDLE_DEVICE_QUEUEING 3375#ifndef SYM_OPT_HANDLE_DEVICE_QUEUEING
3369 assert(i && sym_get_cam_status(cp->cmd) == CAM_REQUEUE_REQ); 3376 assert(i && sym_get_cam_status(cp->cmd) == DID_SOFT_ERROR);
3370#else 3377#else
3371 sym_remque(&cp->link_ccbq); 3378 sym_remque(&cp->link_ccbq);
3372 sym_insque_tail(&cp->link_ccbq, &np->comp_ccbq); 3379 sym_insque_tail(&cp->link_ccbq, &np->comp_ccbq);
@@ -3375,9 +3382,9 @@ static void sym_sir_task_recovery(struct sym_hcb *np, int num)
3375 * Keep track in cam status of the reason of the abort. 3382 * Keep track in cam status of the reason of the abort.
3376 */ 3383 */
3377 if (cp->to_abort == 2) 3384 if (cp->to_abort == 2)
3378 sym_set_cam_status(cp->cmd, CAM_CMD_TIMEOUT); 3385 sym_set_cam_status(cp->cmd, DID_TIME_OUT);
3379 else 3386 else
3380 sym_set_cam_status(cp->cmd, CAM_REQ_ABORTED); 3387 sym_set_cam_status(cp->cmd, DID_ABORT);
3381 3388
3382 /* 3389 /*
3383 * Complete with error everything that we have dequeued. 3390 * Complete with error everything that we have dequeued.
@@ -3491,7 +3498,7 @@ static void sym_sir_task_recovery(struct sym_hcb *np, int num)
3491 * conditions not due to timeout. 3498 * conditions not due to timeout.
3492 */ 3499 */
3493 if (cp->to_abort == 2) 3500 if (cp->to_abort == 2)
3494 sym_set_cam_status(cp->cmd, CAM_CMD_TIMEOUT); 3501 sym_set_cam_status(cp->cmd, DID_TIME_OUT);
3495 cp->to_abort = 0; /* We donnot expect to fail here */ 3502 cp->to_abort = 0; /* We donnot expect to fail here */
3496 break; 3503 break;
3497 3504
@@ -3502,7 +3509,7 @@ static void sym_sir_task_recovery(struct sym_hcb *np, int num)
3502 case SIR_ABORT_SENT: 3509 case SIR_ABORT_SENT:
3503 target = INB(np, nc_sdid) & 0xf; 3510 target = INB(np, nc_sdid) & 0xf;
3504 tp = &np->target[target]; 3511 tp = &np->target[target];
3505 starget = tp->sdev->sdev_target; 3512 starget = tp->starget;
3506 3513
3507 /* 3514 /*
3508 ** If we didn't abort anything, leave here. 3515 ** If we didn't abort anything, leave here.
@@ -3551,7 +3558,7 @@ static void sym_sir_task_recovery(struct sym_hcb *np, int num)
3551 */ 3558 */
3552 i = (INL(np, nc_scratcha) - np->squeue_ba) / 4; 3559 i = (INL(np, nc_scratcha) - np->squeue_ba) / 4;
3553 sym_dequeue_from_squeue(np, i, target, lun, -1); 3560 sym_dequeue_from_squeue(np, i, target, lun, -1);
3554 sym_clear_tasks(np, CAM_REQ_ABORTED, target, lun, task); 3561 sym_clear_tasks(np, DID_ABORT, target, lun, task);
3555 sym_flush_comp_queue(np, 0); 3562 sym_flush_comp_queue(np, 0);
3556 3563
3557 /* 3564 /*
@@ -3566,7 +3573,7 @@ static void sym_sir_task_recovery(struct sym_hcb *np, int num)
3566 * Print to the log the message we intend to send. 3573 * Print to the log the message we intend to send.
3567 */ 3574 */
3568 if (num == SIR_TARGET_SELECTED) { 3575 if (num == SIR_TARGET_SELECTED) {
3569 dev_info(&tp->sdev->sdev_target->dev, "control msgout:"); 3576 dev_info(&tp->starget->dev, "control msgout:");
3570 sym_printl_hex(np->abrt_msg, np->abrt_tbl.size); 3577 sym_printl_hex(np->abrt_msg, np->abrt_tbl.size);
3571 np->abrt_tbl.size = cpu_to_scr(np->abrt_tbl.size); 3578 np->abrt_tbl.size = cpu_to_scr(np->abrt_tbl.size);
3572 } 3579 }
@@ -3877,6 +3884,8 @@ int sym_compute_residual(struct sym_hcb *np, struct sym_ccb *cp)
3877 resid += (tmp & 0xffffff); 3884 resid += (tmp & 0xffffff);
3878 } 3885 }
3879 3886
3887 resid -= cp->odd_byte_adjustment;
3888
3880 /* 3889 /*
3881 * Hopefully, the result is not too wrong. 3890 * Hopefully, the result is not too wrong.
3882 */ 3891 */
@@ -4758,10 +4767,8 @@ struct sym_ccb *sym_get_ccb (struct sym_hcb *np, struct scsi_cmnd *cmd, u_char t
4758 } 4767 }
4759 4768
4760#endif 4769#endif
4761 /*
4762 * Remember all informations needed to free this CCB.
4763 */
4764 cp->to_abort = 0; 4770 cp->to_abort = 0;
4771 cp->odd_byte_adjustment = 0;
4765 cp->tag = tag; 4772 cp->tag = tag;
4766 cp->order = tag_order; 4773 cp->order = tag_order;
4767 cp->target = tn; 4774 cp->target = tn;
@@ -5104,7 +5111,7 @@ static void sym_alloc_lcb_tags (struct sym_hcb *np, u_char tn, u_char ln)
5104 lp->itlq_tbl = sym_calloc_dma(SYM_CONF_MAX_TASK*4, "ITLQ_TBL"); 5111 lp->itlq_tbl = sym_calloc_dma(SYM_CONF_MAX_TASK*4, "ITLQ_TBL");
5105 if (!lp->itlq_tbl) 5112 if (!lp->itlq_tbl)
5106 goto fail; 5113 goto fail;
5107 lp->cb_tags = kcalloc(SYM_CONF_MAX_TASK, 1, GFP_KERNEL); 5114 lp->cb_tags = kcalloc(SYM_CONF_MAX_TASK, 1, GFP_ATOMIC);
5108 if (!lp->cb_tags) { 5115 if (!lp->cb_tags) {
5109 sym_mfree_dma(lp->itlq_tbl, SYM_CONF_MAX_TASK*4, "ITLQ_TBL"); 5116 sym_mfree_dma(lp->itlq_tbl, SYM_CONF_MAX_TASK*4, "ITLQ_TBL");
5110 lp->itlq_tbl = NULL; 5117 lp->itlq_tbl = NULL;
@@ -5243,7 +5250,7 @@ int sym_queue_scsiio(struct sym_hcb *np, struct scsi_cmnd *cmd, struct sym_ccb *
5243 /* 5250 /*
5244 * message 5251 * message
5245 */ 5252 */
5246 cp->phys.smsg.addr = cpu_to_scr(CCB_BA(cp, scsi_smsg)); 5253 cp->phys.smsg.addr = CCB_BA(cp, scsi_smsg);
5247 cp->phys.smsg.size = cpu_to_scr(msglen); 5254 cp->phys.smsg.size = cpu_to_scr(msglen);
5248 5255
5249 /* 5256 /*
@@ -5343,7 +5350,7 @@ int sym_abort_scsiio(struct sym_hcb *np, struct scsi_cmnd *cmd, int timed_out)
5343} 5350}
5344 5351
5345/* 5352/*
5346 * Complete execution of a SCSI command with extented 5353 * Complete execution of a SCSI command with extended
5347 * error, SCSI status error, or having been auto-sensed. 5354 * error, SCSI status error, or having been auto-sensed.
5348 * 5355 *
5349 * The SCRIPTS processor is not running there, so we 5356 * The SCRIPTS processor is not running there, so we
@@ -5441,7 +5448,7 @@ if (resid)
5441 /* 5448 /*
5442 * Let's requeue it to device. 5449 * Let's requeue it to device.
5443 */ 5450 */
5444 sym_set_cam_status(cmd, CAM_REQUEUE_REQ); 5451 sym_set_cam_status(cmd, DID_SOFT_ERROR);
5445 goto finish; 5452 goto finish;
5446 } 5453 }
5447weirdness: 5454weirdness: