aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
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
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')
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_defs.h2
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c120
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.h27
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.c65
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.h22
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_nvram.c7
6 files changed, 106 insertions, 137 deletions
diff --git a/drivers/scsi/sym53c8xx_2/sym_defs.h b/drivers/scsi/sym53c8xx_2/sym_defs.h
index 15bb89195c09..2d9437d7242b 100644
--- a/drivers/scsi/sym53c8xx_2/sym_defs.h
+++ b/drivers/scsi/sym53c8xx_2/sym_defs.h
@@ -40,7 +40,7 @@
40#ifndef SYM_DEFS_H 40#ifndef SYM_DEFS_H
41#define SYM_DEFS_H 41#define SYM_DEFS_H
42 42
43#define SYM_VERSION "2.2.0" 43#define SYM_VERSION "2.2.1"
44#define SYM_DRIVER_NAME "sym-" SYM_VERSION 44#define SYM_DRIVER_NAME "sym-" SYM_VERSION
45 45
46/* 46/*
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index 5b07c6ec3ecc..be58ffd5a432 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -155,10 +155,11 @@ pci_get_base_address(struct pci_dev *pdev, int index, unsigned long *basep)
155 base = tmp; 155 base = tmp;
156 if ((tmp & 0x7) == PCI_BASE_ADDRESS_MEM_TYPE_64) { 156 if ((tmp & 0x7) == PCI_BASE_ADDRESS_MEM_TYPE_64) {
157 pci_read_config_dword(pdev, PCI_BAR_OFFSET(index++), &tmp); 157 pci_read_config_dword(pdev, PCI_BAR_OFFSET(index++), &tmp);
158 if (tmp > 0) 158 if (tmp > 0) {
159 dev_err(&pdev->dev, 159 dev_err(&pdev->dev,
160 "BAR %d is 64-bit, disabling\n", index - 1); 160 "BAR %d is 64-bit, disabling\n", index - 1);
161 base = 0; 161 base = 0;
162 }
162 } 163 }
163 164
164 if ((base & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO) { 165 if ((base & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO) {
@@ -389,13 +390,20 @@ static int sym_scatter_no_sglist(struct sym_hcb *np, struct sym_ccb *cp, struct
389{ 390{
390 struct sym_tblmove *data = &cp->phys.data[SYM_CONF_MAX_SG-1]; 391 struct sym_tblmove *data = &cp->phys.data[SYM_CONF_MAX_SG-1];
391 int segment; 392 int segment;
393 unsigned int len = cmd->request_bufflen;
392 394
393 cp->data_len = cmd->request_bufflen; 395 if (len) {
394
395 if (cmd->request_bufflen) {
396 dma_addr_t baddr = map_scsi_single_data(np, cmd); 396 dma_addr_t baddr = map_scsi_single_data(np, cmd);
397 if (baddr) { 397 if (baddr) {
398 sym_build_sge(np, data, baddr, cmd->request_bufflen); 398 if (len & 1) {
399 struct sym_tcb *tp = &np->target[cp->target];
400 if (tp->head.wval & EWS) {
401 len++;
402 cp->odd_byte_adjustment++;
403 }
404 }
405 cp->data_len = len;
406 sym_build_sge(np, data, baddr, len);
399 segment = 1; 407 segment = 1;
400 } else { 408 } else {
401 segment = -2; 409 segment = -2;
@@ -418,6 +426,7 @@ static int sym_scatter(struct sym_hcb *np, struct sym_ccb *cp, struct scsi_cmnd
418 segment = sym_scatter_no_sglist(np, cp, cmd); 426 segment = sym_scatter_no_sglist(np, cp, cmd);
419 else if ((use_sg = map_scsi_sg_data(np, cmd)) > 0) { 427 else if ((use_sg = map_scsi_sg_data(np, cmd)) > 0) {
420 struct scatterlist *scatter = (struct scatterlist *)cmd->buffer; 428 struct scatterlist *scatter = (struct scatterlist *)cmd->buffer;
429 struct sym_tcb *tp = &np->target[cp->target];
421 struct sym_tblmove *data; 430 struct sym_tblmove *data;
422 431
423 if (use_sg > SYM_CONF_MAX_SG) { 432 if (use_sg > SYM_CONF_MAX_SG) {
@@ -431,6 +440,11 @@ static int sym_scatter(struct sym_hcb *np, struct sym_ccb *cp, struct scsi_cmnd
431 dma_addr_t baddr = sg_dma_address(&scatter[segment]); 440 dma_addr_t baddr = sg_dma_address(&scatter[segment]);
432 unsigned int len = sg_dma_len(&scatter[segment]); 441 unsigned int len = sg_dma_len(&scatter[segment]);
433 442
443 if ((len & 1) && (tp->head.wval & EWS)) {
444 len++;
445 cp->odd_byte_adjustment++;
446 }
447
434 sym_build_sge(np, &data[segment], baddr, len); 448 sym_build_sge(np, &data[segment], baddr, len);
435 cp->data_len += len; 449 cp->data_len += len;
436 } 450 }
@@ -456,10 +470,8 @@ static int sym_queue_command(struct sym_hcb *np, struct scsi_cmnd *cmd)
456 * Minimal checkings, so that we will not 470 * Minimal checkings, so that we will not
457 * go outside our tables. 471 * go outside our tables.
458 */ 472 */
459 if (sdev->id == np->myaddr || 473 if (sdev->id == np->myaddr) {
460 sdev->id >= SYM_CONF_MAX_TARGET || 474 sym_xpt_done2(np, cmd, DID_NO_CONNECT);
461 sdev->lun >= SYM_CONF_MAX_LUN) {
462 sym_xpt_done2(np, cmd, CAM_DEV_NOT_THERE);
463 return 0; 475 return 0;
464 } 476 }
465 477
@@ -469,28 +481,6 @@ static int sym_queue_command(struct sym_hcb *np, struct scsi_cmnd *cmd)
469 tp = &np->target[sdev->id]; 481 tp = &np->target[sdev->id];
470 482
471 /* 483 /*
472 * Complete the 1st INQUIRY command with error
473 * condition if the device is flagged NOSCAN
474 * at BOOT in the NVRAM. This may speed up
475 * the boot and maintain coherency with BIOS
476 * device numbering. Clearing the flag allows
477 * user to rescan skipped devices later.
478 * We also return error for devices not flagged
479 * for SCAN LUNS in the NVRAM since some mono-lun
480 * devices behave badly when asked for some non
481 * zero LUN. Btw, this is an absolute hack.:-)
482 */
483 if (cmd->cmnd[0] == 0x12 || cmd->cmnd[0] == 0x0) {
484 if ((tp->usrflags & SYM_SCAN_BOOT_DISABLED) ||
485 ((tp->usrflags & SYM_SCAN_LUNS_DISABLED) &&
486 sdev->lun != 0)) {
487 tp->usrflags &= ~SYM_SCAN_BOOT_DISABLED;
488 sym_xpt_done2(np, cmd, CAM_DEV_NOT_THERE);
489 return 0;
490 }
491 }
492
493 /*
494 * Select tagged/untagged. 484 * Select tagged/untagged.
495 */ 485 */
496 lp = sym_lp(tp, sdev->lun); 486 lp = sym_lp(tp, sdev->lun);
@@ -511,23 +501,10 @@ static int sym_queue_command(struct sym_hcb *np, struct scsi_cmnd *cmd)
511 */ 501 */
512static inline int sym_setup_cdb(struct sym_hcb *np, struct scsi_cmnd *cmd, struct sym_ccb *cp) 502static inline int sym_setup_cdb(struct sym_hcb *np, struct scsi_cmnd *cmd, struct sym_ccb *cp)
513{ 503{
514 u32 cmd_ba;
515 int cmd_len;
516
517 /*
518 * CDB is 16 bytes max.
519 */
520 if (cmd->cmd_len > sizeof(cp->cdb_buf)) {
521 sym_set_cam_status(cp->cmd, CAM_REQ_INVALID);
522 return -1;
523 }
524
525 memcpy(cp->cdb_buf, cmd->cmnd, cmd->cmd_len); 504 memcpy(cp->cdb_buf, cmd->cmnd, cmd->cmd_len);
526 cmd_ba = CCB_BA (cp, cdb_buf[0]);
527 cmd_len = cmd->cmd_len;
528 505
529 cp->phys.cmd.addr = cpu_to_scr(cmd_ba); 506 cp->phys.cmd.addr = CCB_BA(cp, cdb_buf[0]);
530 cp->phys.cmd.size = cpu_to_scr(cmd_len); 507 cp->phys.cmd.size = cpu_to_scr(cmd->cmd_len);
531 508
532 return 0; 509 return 0;
533} 510}
@@ -554,10 +531,7 @@ int sym_setup_data_and_start(struct sym_hcb *np, struct scsi_cmnd *cmd, struct s
554 if (dir != DMA_NONE) { 531 if (dir != DMA_NONE) {
555 cp->segments = sym_scatter(np, cp, cmd); 532 cp->segments = sym_scatter(np, cp, cmd);
556 if (cp->segments < 0) { 533 if (cp->segments < 0) {
557 if (cp->segments == -2) 534 sym_set_cam_status(cmd, DID_ERROR);
558 sym_set_cam_status(cmd, CAM_RESRC_UNAVAIL);
559 else
560 sym_set_cam_status(cmd, CAM_REQ_TOO_BIG);
561 goto out_abort; 535 goto out_abort;
562 } 536 }
563 } else { 537 } else {
@@ -855,7 +829,7 @@ prepare:
855 ep->to_do = to_do; 829 ep->to_do = to_do;
856 /* Complete the command with locks held as required by the driver */ 830 /* Complete the command with locks held as required by the driver */
857 if (to_do == SYM_EH_DO_COMPLETE) 831 if (to_do == SYM_EH_DO_COMPLETE)
858 sym_xpt_done2(np, cmd, CAM_REQ_ABORTED); 832 sym_xpt_done2(np, cmd, DID_ABORT);
859 833
860 /* Wait for completion with locks released, as required by kernel */ 834 /* Wait for completion with locks released, as required by kernel */
861 if (to_do == SYM_EH_DO_WAIT) { 835 if (to_do == SYM_EH_DO_WAIT) {
@@ -921,7 +895,7 @@ static void sym_tune_dev_queuing(struct sym_tcb *tp, int lun, u_short reqtags)
921 lp->s.reqtags = reqtags; 895 lp->s.reqtags = reqtags;
922 896
923 if (reqtags != oldtags) { 897 if (reqtags != oldtags) {
924 dev_info(&tp->sdev->sdev_target->dev, 898 dev_info(&tp->starget->dev,
925 "tagged command queuing %s, command queue depth %d.\n", 899 "tagged command queuing %s, command queue depth %d.\n",
926 lp->s.reqtags ? "enabled" : "disabled", 900 lp->s.reqtags ? "enabled" : "disabled",
927 lp->started_limit); 901 lp->started_limit);
@@ -981,22 +955,34 @@ static int device_queue_depth(struct sym_hcb *np, int target, int lun)
981 return DEF_DEPTH; 955 return DEF_DEPTH;
982} 956}
983 957
984static int sym53c8xx_slave_alloc(struct scsi_device *device) 958static int sym53c8xx_slave_alloc(struct scsi_device *sdev)
985{ 959{
986 struct sym_hcb *np = sym_get_hcb(device->host); 960 struct sym_hcb *np;
987 struct sym_tcb *tp = &np->target[device->id]; 961 struct sym_tcb *tp;
988 if (!tp->sdev)
989 tp->sdev = device;
990 962
991 return 0; 963 if (sdev->id >= SYM_CONF_MAX_TARGET || sdev->lun >= SYM_CONF_MAX_LUN)
992} 964 return -ENXIO;
993 965
994static void sym53c8xx_slave_destroy(struct scsi_device *device) 966 np = sym_get_hcb(sdev->host);
995{ 967 tp = &np->target[sdev->id];
996 struct sym_hcb *np = sym_get_hcb(device->host); 968
997 struct sym_tcb *tp = &np->target[device->id]; 969 /*
998 if (tp->sdev == device) 970 * Fail the device init if the device is flagged NOSCAN at BOOT in
999 tp->sdev = NULL; 971 * the NVRAM. This may speed up boot and maintain coherency with
972 * BIOS device numbering. Clearing the flag allows the user to
973 * rescan skipped devices later. We also return an error for
974 * devices not flagged for SCAN LUNS in the NVRAM since some single
975 * lun devices behave badly when asked for a non zero LUN.
976 */
977
978 if ((tp->usrflags & SYM_SCAN_BOOT_DISABLED) ||
979 ((tp->usrflags & SYM_SCAN_LUNS_DISABLED) && sdev->lun != 0)) {
980 tp->usrflags &= ~SYM_SCAN_BOOT_DISABLED;
981 return -ENXIO;
982 }
983
984 tp->starget = sdev->sdev_target;
985 return 0;
1000} 986}
1001 987
1002/* 988/*
@@ -1897,6 +1883,7 @@ static int sym_detach(struct sym_hcb *np, struct pci_dev *pdev)
1897 */ 1883 */
1898 printk("%s: resetting chip\n", sym_name(np)); 1884 printk("%s: resetting chip\n", sym_name(np));
1899 OUTB(np, nc_istat, SRST); 1885 OUTB(np, nc_istat, SRST);
1886 INB(np, nc_mbox1);
1900 udelay(10); 1887 udelay(10);
1901 OUTB(np, nc_istat, 0); 1888 OUTB(np, nc_istat, 0);
1902 1889
@@ -1915,7 +1902,6 @@ static struct scsi_host_template sym2_template = {
1915 .queuecommand = sym53c8xx_queue_command, 1902 .queuecommand = sym53c8xx_queue_command,
1916 .slave_alloc = sym53c8xx_slave_alloc, 1903 .slave_alloc = sym53c8xx_slave_alloc,
1917 .slave_configure = sym53c8xx_slave_configure, 1904 .slave_configure = sym53c8xx_slave_configure,
1918 .slave_destroy = sym53c8xx_slave_destroy,
1919 .eh_abort_handler = sym53c8xx_eh_abort_handler, 1905 .eh_abort_handler = sym53c8xx_eh_abort_handler,
1920 .eh_device_reset_handler = sym53c8xx_eh_device_reset_handler, 1906 .eh_device_reset_handler = sym53c8xx_eh_device_reset_handler,
1921 .eh_bus_reset_handler = sym53c8xx_eh_bus_reset_handler, 1907 .eh_bus_reset_handler = sym53c8xx_eh_bus_reset_handler,
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.h b/drivers/scsi/sym53c8xx_2/sym_glue.h
index e943f167fb51..d3d52f14d7c0 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.h
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.h
@@ -142,33 +142,6 @@
142#define scr_to_cpu(dw) le32_to_cpu(dw) 142#define scr_to_cpu(dw) le32_to_cpu(dw)
143 143
144/* 144/*
145 * Remap some status field values.
146 */
147#define CAM_REQ_CMP DID_OK
148#define CAM_SEL_TIMEOUT DID_NO_CONNECT
149#define CAM_CMD_TIMEOUT DID_TIME_OUT
150#define CAM_REQ_ABORTED DID_ABORT
151#define CAM_UNCOR_PARITY DID_PARITY
152#define CAM_SCSI_BUS_RESET DID_RESET
153#define CAM_REQUEUE_REQ DID_SOFT_ERROR
154#define CAM_UNEXP_BUSFREE DID_ERROR
155#define CAM_SCSI_BUSY DID_BUS_BUSY
156
157#define CAM_DEV_NOT_THERE DID_NO_CONNECT
158#define CAM_REQ_INVALID DID_ERROR
159#define CAM_REQ_TOO_BIG DID_ERROR
160
161#define CAM_RESRC_UNAVAIL DID_ERROR
162
163/*
164 * Remap data direction values.
165 */
166#define CAM_DIR_NONE DMA_NONE
167#define CAM_DIR_IN DMA_FROM_DEVICE
168#define CAM_DIR_OUT DMA_TO_DEVICE
169#define CAM_DIR_UNKNOWN DMA_BIDIRECTIONAL
170
171/*
172 * These ones are used as return code from 145 * These ones are used as return code from
173 * error recovery handlers under Linux. 146 * error recovery handlers under Linux.
174 */ 147 */
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:
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h
index a95cbe4b8e39..c55c7a57afa0 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.h
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h
@@ -444,7 +444,7 @@ struct sym_tcb {
444 */ 444 */
445 u_char usrflags; 445 u_char usrflags;
446 u_short usrtags; 446 u_short usrtags;
447 struct scsi_device *sdev; 447 struct scsi_target *starget;
448}; 448};
449 449
450/* 450/*
@@ -754,10 +754,8 @@ struct sym_ccb {
754 int segments; /* Number of SG segments */ 754 int segments; /* Number of SG segments */
755 755
756 u8 order; /* Tag type (if tagged command) */ 756 u8 order; /* Tag type (if tagged command) */
757 unsigned char odd_byte_adjustment; /* odd-sized req on wide bus */
757 758
758 /*
759 * Miscellaneous status'.
760 */
761 u_char nego_status; /* Negotiation status */ 759 u_char nego_status; /* Negotiation status */
762 u_char xerr_status; /* Extended error flags */ 760 u_char xerr_status; /* Extended error flags */
763 u32 extra_bytes; /* Extraneous bytes transferred */ 761 u32 extra_bytes; /* Extraneous bytes transferred */
@@ -809,7 +807,7 @@ struct sym_ccb {
809#endif 807#endif
810}; 808};
811 809
812#define CCB_BA(cp,lbl) (cp->ccb_ba + offsetof(struct sym_ccb, lbl)) 810#define CCB_BA(cp,lbl) cpu_to_scr(cp->ccb_ba + offsetof(struct sym_ccb, lbl))
813 811
814#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN 812#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
815#define sym_goalp(cp) ((cp->host_flags & HF_DATA_IN) ? cp->goalp : cp->wgoalp) 813#define sym_goalp(cp) ((cp->host_flags & HF_DATA_IN) ? cp->goalp : cp->wgoalp)
@@ -1138,33 +1136,33 @@ static inline void sym_setup_data_pointers(struct sym_hcb *np,
1138 * No segments means no data. 1136 * No segments means no data.
1139 */ 1137 */
1140 if (!cp->segments) 1138 if (!cp->segments)
1141 dir = CAM_DIR_NONE; 1139 dir = DMA_NONE;
1142 1140
1143 /* 1141 /*
1144 * Set the data pointer. 1142 * Set the data pointer.
1145 */ 1143 */
1146 switch(dir) { 1144 switch(dir) {
1147#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN 1145#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
1148 case CAM_DIR_UNKNOWN: 1146 case DMA_BIDIRECTIONAL:
1149#endif 1147#endif
1150 case CAM_DIR_OUT: 1148 case DMA_TO_DEVICE:
1151 goalp = SCRIPTA_BA(np, data_out2) + 8; 1149 goalp = SCRIPTA_BA(np, data_out2) + 8;
1152 lastp = goalp - 8 - (cp->segments * (2*4)); 1150 lastp = goalp - 8 - (cp->segments * (2*4));
1153#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN 1151#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
1154 cp->wgoalp = cpu_to_scr(goalp); 1152 cp->wgoalp = cpu_to_scr(goalp);
1155 if (dir != CAM_DIR_UNKNOWN) 1153 if (dir != DMA_BIDIRECTIONAL)
1156 break; 1154 break;
1157 cp->phys.head.wlastp = cpu_to_scr(lastp); 1155 cp->phys.head.wlastp = cpu_to_scr(lastp);
1158 /* fall through */ 1156 /* fall through */
1159#else 1157#else
1160 break; 1158 break;
1161#endif 1159#endif
1162 case CAM_DIR_IN: 1160 case DMA_FROM_DEVICE:
1163 cp->host_flags |= HF_DATA_IN; 1161 cp->host_flags |= HF_DATA_IN;
1164 goalp = SCRIPTA_BA(np, data_in2) + 8; 1162 goalp = SCRIPTA_BA(np, data_in2) + 8;
1165 lastp = goalp - 8 - (cp->segments * (2*4)); 1163 lastp = goalp - 8 - (cp->segments * (2*4));
1166 break; 1164 break;
1167 case CAM_DIR_NONE: 1165 case DMA_NONE:
1168 default: 1166 default:
1169#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN 1167#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
1170 cp->host_flags |= HF_DATA_IN; 1168 cp->host_flags |= HF_DATA_IN;
@@ -1185,7 +1183,7 @@ static inline void sym_setup_data_pointers(struct sym_hcb *np,
1185 /* 1183 /*
1186 * If direction is unknown, start at data_io. 1184 * If direction is unknown, start at data_io.
1187 */ 1185 */
1188 if (dir == CAM_DIR_UNKNOWN) 1186 if (dir == DMA_BIDIRECTIONAL)
1189 cp->phys.head.savep = cpu_to_scr(SCRIPTB_BA(np, data_io)); 1187 cp->phys.head.savep = cpu_to_scr(SCRIPTB_BA(np, data_io));
1190#endif 1188#endif
1191} 1189}
diff --git a/drivers/scsi/sym53c8xx_2/sym_nvram.c b/drivers/scsi/sym53c8xx_2/sym_nvram.c
index 1b721e3ec520..cd9140e158cf 100644
--- a/drivers/scsi/sym53c8xx_2/sym_nvram.c
+++ b/drivers/scsi/sym53c8xx_2/sym_nvram.c
@@ -270,6 +270,7 @@ static void S24C16_set_bit(struct sym_device *np, u_char write_bit, u_char *gpre
270 270
271 } 271 }
272 OUTB(np, nc_gpreg, *gpreg); 272 OUTB(np, nc_gpreg, *gpreg);
273 INB(np, nc_mbox1);
273 udelay(5); 274 udelay(5);
274} 275}
275 276
@@ -547,6 +548,7 @@ static int sym_read_Symbios_nvram(struct sym_device *np, Symbios_nvram *nvram)
547static void T93C46_Clk(struct sym_device *np, u_char *gpreg) 548static void T93C46_Clk(struct sym_device *np, u_char *gpreg)
548{ 549{
549 OUTB(np, nc_gpreg, *gpreg | 0x04); 550 OUTB(np, nc_gpreg, *gpreg | 0x04);
551 INB(np, nc_mbox1);
550 udelay(2); 552 udelay(2);
551 OUTB(np, nc_gpreg, *gpreg); 553 OUTB(np, nc_gpreg, *gpreg);
552} 554}
@@ -574,6 +576,7 @@ static void T93C46_Write_Bit(struct sym_device *np, u_char write_bit, u_char *gp
574 *gpreg |= 0x10; 576 *gpreg |= 0x10;
575 577
576 OUTB(np, nc_gpreg, *gpreg); 578 OUTB(np, nc_gpreg, *gpreg);
579 INB(np, nc_mbox1);
577 udelay(2); 580 udelay(2);
578 581
579 T93C46_Clk(np, gpreg); 582 T93C46_Clk(np, gpreg);
@@ -586,6 +589,7 @@ static void T93C46_Stop(struct sym_device *np, u_char *gpreg)
586{ 589{
587 *gpreg &= 0xef; 590 *gpreg &= 0xef;
588 OUTB(np, nc_gpreg, *gpreg); 591 OUTB(np, nc_gpreg, *gpreg);
592 INB(np, nc_mbox1);
589 udelay(2); 593 udelay(2);
590 594
591 T93C46_Clk(np, gpreg); 595 T93C46_Clk(np, gpreg);
@@ -733,7 +737,8 @@ static int sym_read_parisc_pdc(struct sym_device *np, struct pdc_initiator *pdc)
733 return SYM_PARISC_PDC; 737 return SYM_PARISC_PDC;
734} 738}
735#else 739#else
736static int sym_read_parisc_pdc(struct sym_device *np, struct pdc_initiator *x) 740static inline int sym_read_parisc_pdc(struct sym_device *np,
741 struct pdc_initiator *x)
737{ 742{
738 return 0; 743 return 0;
739} 744}