aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sym53c8xx_2
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-01-04 19:30:12 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-04 19:30:12 -0500
commitf61ea1b0c825a20a1826bb43a226387091934586 (patch)
treefdedf0a2368f707e3fd5205db05bfcbac79606ec /drivers/scsi/sym53c8xx_2
parentd347da0deffa1d8f88f0d270eab040e4707c9916 (diff)
parent7b32b8e018d8f8cc94c808a5fa84a3f889441b91 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
Diffstat (limited to 'drivers/scsi/sym53c8xx_2')
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_defs.h2
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_fw.c18
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_fw.h6
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_fw1.h48
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_fw2.h52
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c117
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.h2
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.c164
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.h104
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_malloc.c4
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_nvram.c29
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_nvram.h4
12 files changed, 122 insertions, 428 deletions
diff --git a/drivers/scsi/sym53c8xx_2/sym_defs.h b/drivers/scsi/sym53c8xx_2/sym_defs.h
index 2d9437d7242b..3659dd7b9d76 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.1" 43#define SYM_VERSION "2.2.2"
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_fw.c b/drivers/scsi/sym53c8xx_2/sym_fw.c
index fd36cf9858cb..9916a2a22558 100644
--- a/drivers/scsi/sym53c8xx_2/sym_fw.c
+++ b/drivers/scsi/sym53c8xx_2/sym_fw.c
@@ -37,11 +37,7 @@
37 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 37 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38 */ 38 */
39 39
40#ifdef __FreeBSD__
41#include <dev/sym/sym_glue.h>
42#else
43#include "sym_glue.h" 40#include "sym_glue.h"
44#endif
45 41
46/* 42/*
47 * Macros used for all firmwares. 43 * Macros used for all firmwares.
@@ -60,19 +56,12 @@
60#define SYM_FWA_SCR sym_fw1a_scr 56#define SYM_FWA_SCR sym_fw1a_scr
61#define SYM_FWB_SCR sym_fw1b_scr 57#define SYM_FWB_SCR sym_fw1b_scr
62#define SYM_FWZ_SCR sym_fw1z_scr 58#define SYM_FWZ_SCR sym_fw1z_scr
63#ifdef __FreeBSD__
64#include <dev/sym/sym_fw1.h>
65#else
66#include "sym_fw1.h" 59#include "sym_fw1.h"
67#endif
68static struct sym_fwa_ofs sym_fw1a_ofs = { 60static struct sym_fwa_ofs sym_fw1a_ofs = {
69 SYM_GEN_FW_A(struct SYM_FWA_SCR) 61 SYM_GEN_FW_A(struct SYM_FWA_SCR)
70}; 62};
71static struct sym_fwb_ofs sym_fw1b_ofs = { 63static struct sym_fwb_ofs sym_fw1b_ofs = {
72 SYM_GEN_FW_B(struct SYM_FWB_SCR) 64 SYM_GEN_FW_B(struct SYM_FWB_SCR)
73#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
74 SYM_GEN_B(struct SYM_FWB_SCR, data_io)
75#endif
76}; 65};
77static struct sym_fwz_ofs sym_fw1z_ofs = { 66static struct sym_fwz_ofs sym_fw1z_ofs = {
78 SYM_GEN_FW_Z(struct SYM_FWZ_SCR) 67 SYM_GEN_FW_Z(struct SYM_FWZ_SCR)
@@ -88,19 +77,12 @@ static struct sym_fwz_ofs sym_fw1z_ofs = {
88#define SYM_FWA_SCR sym_fw2a_scr 77#define SYM_FWA_SCR sym_fw2a_scr
89#define SYM_FWB_SCR sym_fw2b_scr 78#define SYM_FWB_SCR sym_fw2b_scr
90#define SYM_FWZ_SCR sym_fw2z_scr 79#define SYM_FWZ_SCR sym_fw2z_scr
91#ifdef __FreeBSD__
92#include <dev/sym/sym_fw2.h>
93#else
94#include "sym_fw2.h" 80#include "sym_fw2.h"
95#endif
96static struct sym_fwa_ofs sym_fw2a_ofs = { 81static struct sym_fwa_ofs sym_fw2a_ofs = {
97 SYM_GEN_FW_A(struct SYM_FWA_SCR) 82 SYM_GEN_FW_A(struct SYM_FWA_SCR)
98}; 83};
99static struct sym_fwb_ofs sym_fw2b_ofs = { 84static struct sym_fwb_ofs sym_fw2b_ofs = {
100 SYM_GEN_FW_B(struct SYM_FWB_SCR) 85 SYM_GEN_FW_B(struct SYM_FWB_SCR)
101#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
102 SYM_GEN_B(struct SYM_FWB_SCR, data_io)
103#endif
104 SYM_GEN_B(struct SYM_FWB_SCR, start64) 86 SYM_GEN_B(struct SYM_FWB_SCR, start64)
105 SYM_GEN_B(struct SYM_FWB_SCR, pm_handle) 87 SYM_GEN_B(struct SYM_FWB_SCR, pm_handle)
106}; 88};
diff --git a/drivers/scsi/sym53c8xx_2/sym_fw.h b/drivers/scsi/sym53c8xx_2/sym_fw.h
index 43f6810a4045..66ec35beab5b 100644
--- a/drivers/scsi/sym53c8xx_2/sym_fw.h
+++ b/drivers/scsi/sym53c8xx_2/sym_fw.h
@@ -92,9 +92,6 @@ struct sym_fwa_ofs {
92}; 92};
93struct sym_fwb_ofs { 93struct sym_fwb_ofs {
94 SYM_GEN_FW_B(u_short) 94 SYM_GEN_FW_B(u_short)
95#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
96 SYM_GEN_B(u_short, data_io)
97#endif
98 SYM_GEN_B(u_short, start64) 95 SYM_GEN_B(u_short, start64)
99 SYM_GEN_B(u_short, pm_handle) 96 SYM_GEN_B(u_short, pm_handle)
100}; 97};
@@ -111,9 +108,6 @@ struct sym_fwa_ba {
111}; 108};
112struct sym_fwb_ba { 109struct sym_fwb_ba {
113 SYM_GEN_FW_B(u32) 110 SYM_GEN_FW_B(u32)
114#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
115 SYM_GEN_B(u32, data_io)
116#endif
117 SYM_GEN_B(u32, start64); 111 SYM_GEN_B(u32, start64);
118 SYM_GEN_B(u32, pm_handle); 112 SYM_GEN_B(u32, pm_handle);
119}; 113};
diff --git a/drivers/scsi/sym53c8xx_2/sym_fw1.h b/drivers/scsi/sym53c8xx_2/sym_fw1.h
index cdd92d82f4b2..7b39f4a35e98 100644
--- a/drivers/scsi/sym53c8xx_2/sym_fw1.h
+++ b/drivers/scsi/sym53c8xx_2/sym_fw1.h
@@ -197,12 +197,6 @@ struct SYM_FWB_SCR {
197 u32 bad_status [ 7]; 197 u32 bad_status [ 7];
198 u32 wsr_ma_helper [ 4]; 198 u32 wsr_ma_helper [ 4];
199 199
200#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
201 /* Unknown direction handling */
202 u32 data_io [ 2];
203 u32 data_io_com [ 8];
204 u32 data_io_out [ 7];
205#endif
206 /* Data area */ 200 /* Data area */
207 u32 zero [ 1]; 201 u32 zero [ 1];
208 u32 scratch [ 1]; 202 u32 scratch [ 1];
@@ -1747,48 +1741,6 @@ static struct SYM_FWB_SCR SYM_FWB_SCR = {
1747 SCR_JUMP, 1741 SCR_JUMP,
1748 PADDR_A (dispatch), 1742 PADDR_A (dispatch),
1749 1743
1750#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
1751}/*-------------------------< DATA_IO >--------------------------*/,{
1752 /*
1753 * We jump here if the data direction was unknown at the
1754 * time we had to queue the command to the scripts processor.
1755 * Pointers had been set as follow in this situation:
1756 * savep --> DATA_IO
1757 * lastp --> start pointer when DATA_IN
1758 * wlastp --> start pointer when DATA_OUT
1759 * This script sets savep and lastp according to the
1760 * direction chosen by the target.
1761 */
1762 SCR_JUMP ^ IFTRUE (WHEN (SCR_DATA_OUT)),
1763 PADDR_B (data_io_out),
1764}/*-------------------------< DATA_IO_COM >----------------------*/,{
1765 /*
1766 * Direction is DATA IN.
1767 */
1768 SCR_COPY (4),
1769 HADDR_1 (ccb_head.lastp),
1770 HADDR_1 (ccb_head.savep),
1771 /*
1772 * Jump to the SCRIPTS according to actual direction.
1773 */
1774 SCR_COPY (4),
1775 HADDR_1 (ccb_head.savep),
1776 RADDR_1 (temp),
1777 SCR_RETURN,
1778 0,
1779}/*-------------------------< DATA_IO_OUT >----------------------*/,{
1780 /*
1781 * Direction is DATA OUT.
1782 */
1783 SCR_REG_REG (HF_REG, SCR_AND, (~HF_DATA_IN)),
1784 0,
1785 SCR_COPY (4),
1786 HADDR_1 (ccb_head.wlastp),
1787 HADDR_1 (ccb_head.lastp),
1788 SCR_JUMP,
1789 PADDR_B(data_io_com),
1790#endif /* SYM_OPT_HANDLE_DIR_UNKNOWN */
1791
1792}/*-------------------------< ZERO >-----------------------------*/,{ 1744}/*-------------------------< ZERO >-----------------------------*/,{
1793 SCR_DATA_ZERO, 1745 SCR_DATA_ZERO,
1794}/*-------------------------< SCRATCH >--------------------------*/,{ 1746}/*-------------------------< SCRATCH >--------------------------*/,{
diff --git a/drivers/scsi/sym53c8xx_2/sym_fw2.h b/drivers/scsi/sym53c8xx_2/sym_fw2.h
index 7ea7151f5d1d..851f2706f220 100644
--- a/drivers/scsi/sym53c8xx_2/sym_fw2.h
+++ b/drivers/scsi/sym53c8xx_2/sym_fw2.h
@@ -191,13 +191,6 @@ struct SYM_FWB_SCR {
191 u32 pm_wsr_handle [ 38]; 191 u32 pm_wsr_handle [ 38];
192 u32 wsr_ma_helper [ 4]; 192 u32 wsr_ma_helper [ 4];
193 193
194#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
195 /* Unknown direction handling */
196 u32 data_io [ 2];
197 u32 data_io_in [ 2];
198 u32 data_io_com [ 6];
199 u32 data_io_out [ 8];
200#endif
201 /* Data area */ 194 /* Data area */
202 u32 zero [ 1]; 195 u32 zero [ 1];
203 u32 scratch [ 1]; 196 u32 scratch [ 1];
@@ -1838,51 +1831,6 @@ static struct SYM_FWB_SCR SYM_FWB_SCR = {
1838 SCR_JUMP, 1831 SCR_JUMP,
1839 PADDR_A (dispatch), 1832 PADDR_A (dispatch),
1840 1833
1841#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
1842}/*-------------------------< DATA_IO >--------------------------*/,{
1843 /*
1844 * We jump here if the data direction was unknown at the
1845 * time we had to queue the command to the scripts processor.
1846 * Pointers had been set as follow in this situation:
1847 * savep --> DATA_IO
1848 * lastp --> start pointer when DATA_IN
1849 * wlastp --> start pointer when DATA_OUT
1850 * This script sets savep and lastp according to the
1851 * direction chosen by the target.
1852 */
1853 SCR_JUMP ^ IFTRUE (WHEN (SCR_DATA_OUT)),
1854 PADDR_B (data_io_out),
1855}/*-------------------------< DATA_IO_IN >-----------------------*/,{
1856 /*
1857 * Direction is DATA IN.
1858 */
1859 SCR_LOAD_REL (scratcha, 4),
1860 offsetof (struct sym_ccb, phys.head.lastp),
1861}/*-------------------------< DATA_IO_COM >----------------------*/,{
1862 SCR_STORE_REL (scratcha, 4),
1863 offsetof (struct sym_ccb, phys.head.savep),
1864
1865 /*
1866 * Jump to the SCRIPTS according to actual direction.
1867 */
1868 SCR_LOAD_REL (temp, 4),
1869 offsetof (struct sym_ccb, phys.head.savep),
1870 SCR_RETURN,
1871 0,
1872}/*-------------------------< DATA_IO_OUT >----------------------*/,{
1873 /*
1874 * Direction is DATA OUT.
1875 */
1876 SCR_REG_REG (HF_REG, SCR_AND, (~HF_DATA_IN)),
1877 0,
1878 SCR_LOAD_REL (scratcha, 4),
1879 offsetof (struct sym_ccb, phys.head.wlastp),
1880 SCR_STORE_REL (scratcha, 4),
1881 offsetof (struct sym_ccb, phys.head.lastp),
1882 SCR_JUMP,
1883 PADDR_B(data_io_com),
1884#endif /* SYM_OPT_HANDLE_DIR_UNKNOWN */
1885
1886}/*-------------------------< ZERO >-----------------------------*/,{ 1834}/*-------------------------< ZERO >-----------------------------*/,{
1887 SCR_DATA_ZERO, 1835 SCR_DATA_ZERO,
1888}/*-------------------------< SCRATCH >--------------------------*/,{ 1836}/*-------------------------< SCRATCH >--------------------------*/,{
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index 7fc0b97173e1..1fffd2b3c654 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -514,9 +514,10 @@ static inline int sym_setup_cdb(struct sym_hcb *np, struct scsi_cmnd *cmd, struc
514 */ 514 */
515int sym_setup_data_and_start(struct sym_hcb *np, struct scsi_cmnd *cmd, struct sym_ccb *cp) 515int sym_setup_data_and_start(struct sym_hcb *np, struct scsi_cmnd *cmd, struct sym_ccb *cp)
516{ 516{
517 int dir;
518 struct sym_tcb *tp = &np->target[cp->target]; 517 struct sym_tcb *tp = &np->target[cp->target];
519 struct sym_lcb *lp = sym_lp(tp, cp->lun); 518 struct sym_lcb *lp = sym_lp(tp, cp->lun);
519 u32 lastp, goalp;
520 int dir;
520 521
521 /* 522 /*
522 * Build the CDB. 523 * Build the CDB.
@@ -534,15 +535,47 @@ int sym_setup_data_and_start(struct sym_hcb *np, struct scsi_cmnd *cmd, struct s
534 sym_set_cam_status(cmd, DID_ERROR); 535 sym_set_cam_status(cmd, DID_ERROR);
535 goto out_abort; 536 goto out_abort;
536 } 537 }
538
539 /*
540 * No segments means no data.
541 */
542 if (!cp->segments)
543 dir = DMA_NONE;
537 } else { 544 } else {
538 cp->data_len = 0; 545 cp->data_len = 0;
539 cp->segments = 0; 546 cp->segments = 0;
540 } 547 }
541 548
542 /* 549 /*
543 * Set data pointers. 550 * Set the data pointer.
544 */ 551 */
545 sym_setup_data_pointers(np, cp, dir); 552 switch (dir) {
553 case DMA_BIDIRECTIONAL:
554 printk("%s: got DMA_BIDIRECTIONAL command", sym_name(np));
555 sym_set_cam_status(cmd, DID_ERROR);
556 goto out_abort;
557 case DMA_TO_DEVICE:
558 goalp = SCRIPTA_BA(np, data_out2) + 8;
559 lastp = goalp - 8 - (cp->segments * (2*4));
560 break;
561 case DMA_FROM_DEVICE:
562 cp->host_flags |= HF_DATA_IN;
563 goalp = SCRIPTA_BA(np, data_in2) + 8;
564 lastp = goalp - 8 - (cp->segments * (2*4));
565 break;
566 case DMA_NONE:
567 default:
568 lastp = goalp = SCRIPTB_BA(np, no_data);
569 break;
570 }
571
572 /*
573 * Set all pointers values needed by SCRIPTS.
574 */
575 cp->phys.head.lastp = cpu_to_scr(lastp);
576 cp->phys.head.savep = cpu_to_scr(lastp);
577 cp->startp = cp->phys.head.savep;
578 cp->goalp = cpu_to_scr(goalp);
546 579
547 /* 580 /*
548 * When `#ifed 1', the code below makes the driver 581 * When `#ifed 1', the code below makes the driver
@@ -563,10 +596,7 @@ int sym_setup_data_and_start(struct sym_hcb *np, struct scsi_cmnd *cmd, struct s
563 /* 596 /*
564 * activate this job. 597 * activate this job.
565 */ 598 */
566 if (lp) 599 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; 600 return 0;
571 601
572out_abort: 602out_abort:
@@ -981,15 +1011,14 @@ static int device_queue_depth(struct sym_hcb *np, int target, int lun)
981 1011
982static int sym53c8xx_slave_alloc(struct scsi_device *sdev) 1012static int sym53c8xx_slave_alloc(struct scsi_device *sdev)
983{ 1013{
984 struct sym_hcb *np; 1014 struct sym_hcb *np = sym_get_hcb(sdev->host);
985 struct sym_tcb *tp; 1015 struct sym_tcb *tp = &np->target[sdev->id];
1016 struct sym_lcb *lp;
986 1017
987 if (sdev->id >= SYM_CONF_MAX_TARGET || sdev->lun >= SYM_CONF_MAX_LUN) 1018 if (sdev->id >= SYM_CONF_MAX_TARGET || sdev->lun >= SYM_CONF_MAX_LUN)
988 return -ENXIO; 1019 return -ENXIO;
989 1020
990 np = sym_get_hcb(sdev->host); 1021 tp->starget = sdev->sdev_target;
991 tp = &np->target[sdev->id];
992
993 /* 1022 /*
994 * Fail the device init if the device is flagged NOSCAN at BOOT in 1023 * 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 1024 * the NVRAM. This may speed up boot and maintain coherency with
@@ -999,35 +1028,41 @@ static int sym53c8xx_slave_alloc(struct scsi_device *sdev)
999 * lun devices behave badly when asked for a non zero LUN. 1028 * lun devices behave badly when asked for a non zero LUN.
1000 */ 1029 */
1001 1030
1002 if ((tp->usrflags & SYM_SCAN_BOOT_DISABLED) || 1031 if (tp->usrflags & SYM_SCAN_BOOT_DISABLED) {
1003 ((tp->usrflags & SYM_SCAN_LUNS_DISABLED) && sdev->lun != 0)) {
1004 tp->usrflags &= ~SYM_SCAN_BOOT_DISABLED; 1032 tp->usrflags &= ~SYM_SCAN_BOOT_DISABLED;
1033 starget_printk(KERN_INFO, tp->starget,
1034 "Scan at boot disabled in NVRAM\n");
1005 return -ENXIO; 1035 return -ENXIO;
1006 } 1036 }
1007 1037
1008 tp->starget = sdev->sdev_target; 1038 if (tp->usrflags & SYM_SCAN_LUNS_DISABLED) {
1039 if (sdev->lun != 0)
1040 return -ENXIO;
1041 starget_printk(KERN_INFO, tp->starget,
1042 "Multiple LUNs disabled in NVRAM\n");
1043 }
1044
1045 lp = sym_alloc_lcb(np, sdev->id, sdev->lun);
1046 if (!lp)
1047 return -ENOMEM;
1048
1049 spi_min_period(tp->starget) = tp->usr_period;
1050 spi_max_width(tp->starget) = tp->usr_width;
1051
1009 return 0; 1052 return 0;
1010} 1053}
1011 1054
1012/* 1055/*
1013 * Linux entry point for device queue sizing. 1056 * Linux entry point for device queue sizing.
1014 */ 1057 */
1015static int sym53c8xx_slave_configure(struct scsi_device *device) 1058static int sym53c8xx_slave_configure(struct scsi_device *sdev)
1016{ 1059{
1017 struct sym_hcb *np = sym_get_hcb(device->host); 1060 struct sym_hcb *np = sym_get_hcb(sdev->host);
1018 struct sym_tcb *tp = &np->target[device->id]; 1061 struct sym_tcb *tp = &np->target[sdev->id];
1019 struct sym_lcb *lp; 1062 struct sym_lcb *lp = sym_lp(tp, sdev->lun);
1020 int reqtags, depth_to_use; 1063 int reqtags, depth_to_use;
1021 1064
1022 /* 1065 /*
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. 1066 * Get user flags.
1032 */ 1067 */
1033 lp->curr_flags = lp->user_flags; 1068 lp->curr_flags = lp->user_flags;
@@ -1038,10 +1073,10 @@ static int sym53c8xx_slave_configure(struct scsi_device *device)
1038 * Use at least 2. 1073 * Use at least 2.
1039 * Donnot use more than our maximum. 1074 * Donnot use more than our maximum.
1040 */ 1075 */
1041 reqtags = device_queue_depth(np, device->id, device->lun); 1076 reqtags = device_queue_depth(np, sdev->id, sdev->lun);
1042 if (reqtags > tp->usrtags) 1077 if (reqtags > tp->usrtags)
1043 reqtags = tp->usrtags; 1078 reqtags = tp->usrtags;
1044 if (!device->tagged_supported) 1079 if (!sdev->tagged_supported)
1045 reqtags = 0; 1080 reqtags = 0;
1046#if 1 /* Avoid to locally queue commands for no good reasons */ 1081#if 1 /* Avoid to locally queue commands for no good reasons */
1047 if (reqtags > SYM_CONF_MAX_TAG) 1082 if (reqtags > SYM_CONF_MAX_TAG)
@@ -1050,19 +1085,30 @@ static int sym53c8xx_slave_configure(struct scsi_device *device)
1050#else 1085#else
1051 depth_to_use = (reqtags ? SYM_CONF_MAX_TAG : 2); 1086 depth_to_use = (reqtags ? SYM_CONF_MAX_TAG : 2);
1052#endif 1087#endif
1053 scsi_adjust_queue_depth(device, 1088 scsi_adjust_queue_depth(sdev,
1054 (device->tagged_supported ? 1089 (sdev->tagged_supported ?
1055 MSG_SIMPLE_TAG : 0), 1090 MSG_SIMPLE_TAG : 0),
1056 depth_to_use); 1091 depth_to_use);
1057 lp->s.scdev_depth = depth_to_use; 1092 lp->s.scdev_depth = depth_to_use;
1058 sym_tune_dev_queuing(tp, device->lun, reqtags); 1093 sym_tune_dev_queuing(tp, sdev->lun, reqtags);
1059 1094
1060 if (!spi_initial_dv(device->sdev_target)) 1095 if (!spi_initial_dv(sdev->sdev_target))
1061 spi_dv_device(device); 1096 spi_dv_device(sdev);
1062 1097
1063 return 0; 1098 return 0;
1064} 1099}
1065 1100
1101static void sym53c8xx_slave_destroy(struct scsi_device *sdev)
1102{
1103 struct sym_hcb *np = sym_get_hcb(sdev->host);
1104 struct sym_lcb *lp = sym_lp(&np->target[sdev->id], sdev->lun);
1105
1106 if (lp->itlq_tbl)
1107 sym_mfree_dma(lp->itlq_tbl, SYM_CONF_MAX_TASK * 4, "ITLQ_TBL");
1108 kfree(lp->cb_tags);
1109 sym_mfree_dma(lp, sizeof(*lp), "LCB");
1110}
1111
1066/* 1112/*
1067 * Linux entry point for info() function 1113 * Linux entry point for info() function
1068 */ 1114 */
@@ -1497,7 +1543,7 @@ static int sym_setup_bus_dma_mask(struct sym_hcb *np)
1497{ 1543{
1498#if SYM_CONF_DMA_ADDRESSING_MODE > 0 1544#if SYM_CONF_DMA_ADDRESSING_MODE > 0
1499#if SYM_CONF_DMA_ADDRESSING_MODE == 1 1545#if SYM_CONF_DMA_ADDRESSING_MODE == 1
1500#define DMA_DAC_MASK 0x000000ffffffffffULL /* 40-bit */ 1546#define DMA_DAC_MASK DMA_40BIT_MASK
1501#elif SYM_CONF_DMA_ADDRESSING_MODE == 2 1547#elif SYM_CONF_DMA_ADDRESSING_MODE == 2
1502#define DMA_DAC_MASK DMA_64BIT_MASK 1548#define DMA_DAC_MASK DMA_64BIT_MASK
1503#endif 1549#endif
@@ -1926,6 +1972,7 @@ static struct scsi_host_template sym2_template = {
1926 .queuecommand = sym53c8xx_queue_command, 1972 .queuecommand = sym53c8xx_queue_command,
1927 .slave_alloc = sym53c8xx_slave_alloc, 1973 .slave_alloc = sym53c8xx_slave_alloc,
1928 .slave_configure = sym53c8xx_slave_configure, 1974 .slave_configure = sym53c8xx_slave_configure,
1975 .slave_destroy = sym53c8xx_slave_destroy,
1929 .eh_abort_handler = sym53c8xx_eh_abort_handler, 1976 .eh_abort_handler = sym53c8xx_eh_abort_handler,
1930 .eh_device_reset_handler = sym53c8xx_eh_device_reset_handler, 1977 .eh_device_reset_handler = sym53c8xx_eh_device_reset_handler,
1931 .eh_bus_reset_handler = sym53c8xx_eh_bus_reset_handler, 1978 .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 d3d52f14d7c0..cc92d0c70cd7 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.h
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.h
@@ -68,7 +68,6 @@
68 */ 68 */
69#define SYM_CONF_TIMER_INTERVAL ((HZ+1)/2) 69#define SYM_CONF_TIMER_INTERVAL ((HZ+1)/2)
70 70
71#define SYM_OPT_HANDLE_DIR_UNKNOWN
72#define SYM_OPT_HANDLE_DEVICE_QUEUEING 71#define SYM_OPT_HANDLE_DEVICE_QUEUEING
73#define SYM_OPT_LIMIT_COMMAND_REORDERING 72#define SYM_OPT_LIMIT_COMMAND_REORDERING
74 73
@@ -268,6 +267,5 @@ void sym_xpt_async_bus_reset(struct sym_hcb *np);
268void sym_xpt_async_sent_bdr(struct sym_hcb *np, int target); 267void sym_xpt_async_sent_bdr(struct sym_hcb *np, int target);
269int sym_setup_data_and_start (struct sym_hcb *np, struct scsi_cmnd *csio, struct sym_ccb *cp); 268int sym_setup_data_and_start (struct sym_hcb *np, struct scsi_cmnd *csio, struct sym_ccb *cp);
270void sym_log_bus_error(struct sym_hcb *np); 269void sym_log_bus_error(struct sym_hcb *np);
271void sym_sniff_inquiry(struct sym_hcb *np, struct scsi_cmnd *cmd, int resid);
272 270
273#endif /* SYM_GLUE_H */ 271#endif /* SYM_GLUE_H */
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 */
76static 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
93static void sym_print_msg(struct sym_ccb *cp, char *label, u_char *msg) 74static 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
101static void sym_print_nego_msg(struct sym_hcb *np, int target, char *label, u_char *msg) 82static 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 */
642static 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 */
1526void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp) 1477static 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)
4997struct sym_lcb *sym_alloc_lcb (struct sym_hcb *np, u_char tn, u_char ln) 4919struct 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 }
5092fail: 4995fail:
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
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h
index 3a264a408216..2456090bb241 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.h
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h
@@ -48,12 +48,6 @@
48 * They may be defined in platform specific headers, if they 48 * They may be defined in platform specific headers, if they
49 * are useful. 49 * are useful.
50 * 50 *
51 * SYM_OPT_HANDLE_DIR_UNKNOWN
52 * When this option is set, the SCRIPTS used by the driver
53 * are able to handle SCSI transfers with direction not
54 * supplied by user.
55 * (set for Linux-2.0.X)
56 *
57 * SYM_OPT_HANDLE_DEVICE_QUEUEING 51 * SYM_OPT_HANDLE_DEVICE_QUEUEING
58 * When this option is set, the driver will use a queue per 52 * When this option is set, the driver will use a queue per
59 * device and handle QUEUE FULL status requeuing internally. 53 * device and handle QUEUE FULL status requeuing internally.
@@ -64,7 +58,6 @@
64 * (set for Linux) 58 * (set for Linux)
65 */ 59 */
66#if 0 60#if 0
67#define SYM_OPT_HANDLE_DIR_UNKNOWN
68#define SYM_OPT_HANDLE_DEVICE_QUEUEING 61#define SYM_OPT_HANDLE_DEVICE_QUEUEING
69#define SYM_OPT_LIMIT_COMMAND_REORDERING 62#define SYM_OPT_LIMIT_COMMAND_REORDERING
70#endif 63#endif
@@ -416,19 +409,6 @@ struct sym_tcb {
416 struct sym_lcb **lunmp; /* Other LCBs [1..MAX_LUN] */ 409 struct sym_lcb **lunmp; /* Other LCBs [1..MAX_LUN] */
417#endif 410#endif
418 411
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 412#ifdef SYM_HAVE_STCB
433 /* 413 /*
434 * O/S specific data structure. 414 * O/S specific data structure.
@@ -454,8 +434,10 @@ struct sym_tcb {
454 * Other user settable limits and options. 434 * Other user settable limits and options.
455 * These limits are read from the NVRAM if present. 435 * These limits are read from the NVRAM if present.
456 */ 436 */
457 u_char usrflags; 437 unsigned char usrflags;
458 u_short usrtags; 438 unsigned char usr_period;
439 unsigned char usr_width;
440 unsigned short usrtags;
459 struct scsi_target *starget; 441 struct scsi_target *starget;
460}; 442};
461 443
@@ -672,9 +654,6 @@ struct sym_ccbh {
672 */ 654 */
673 u32 savep; /* Jump address to saved data pointer */ 655 u32 savep; /* Jump address to saved data pointer */
674 u32 lastp; /* SCRIPTS address at end of data */ 656 u32 lastp; /* SCRIPTS address at end of data */
675#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
676 u32 wlastp;
677#endif
678 657
679 /* 658 /*
680 * Status fields. 659 * Status fields.
@@ -804,9 +783,6 @@ struct sym_ccb {
804 SYM_QUEHEAD link_ccbq; /* Link to free/busy CCB queue */ 783 SYM_QUEHEAD link_ccbq; /* Link to free/busy CCB queue */
805 u32 startp; /* Initial data pointer */ 784 u32 startp; /* Initial data pointer */
806 u32 goalp; /* Expected last data pointer */ 785 u32 goalp; /* Expected last data pointer */
807#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
808 u32 wgoalp;
809#endif
810 int ext_sg; /* Extreme data pointer, used */ 786 int ext_sg; /* Extreme data pointer, used */
811 int ext_ofs; /* to calculate the residual. */ 787 int ext_ofs; /* to calculate the residual. */
812#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING 788#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING
@@ -821,12 +797,6 @@ struct sym_ccb {
821 797
822#define CCB_BA(cp,lbl) cpu_to_scr(cp->ccb_ba + offsetof(struct sym_ccb, lbl)) 798#define CCB_BA(cp,lbl) cpu_to_scr(cp->ccb_ba + offsetof(struct sym_ccb, lbl))
823 799
824#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
825#define sym_goalp(cp) ((cp->host_flags & HF_DATA_IN) ? cp->goalp : cp->wgoalp)
826#else
827#define sym_goalp(cp) (cp->goalp)
828#endif
829
830typedef struct device *m_pool_ident_t; 800typedef struct device *m_pool_ident_t;
831 801
832/* 802/*
@@ -1077,7 +1047,6 @@ char *sym_driver_name(void);
1077void sym_print_xerr(struct scsi_cmnd *cmd, int x_status); 1047void sym_print_xerr(struct scsi_cmnd *cmd, int x_status);
1078int sym_reset_scsi_bus(struct sym_hcb *np, int enab_int); 1048int 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); 1049struct 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 1050#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING
1082void sym_start_next_ccbs(struct sym_hcb *np, struct sym_lcb *lp, int maxn); 1051void sym_start_next_ccbs(struct sym_hcb *np, struct sym_lcb *lp, int maxn);
1083#endif 1052#endif
@@ -1136,71 +1105,6 @@ bad:
1136#endif 1105#endif
1137 1106
1138/* 1107/*
1139 * Set up data pointers used by SCRIPTS.
1140 * Called from O/S specific code.
1141 */
1142static inline void sym_setup_data_pointers(struct sym_hcb *np,
1143 struct sym_ccb *cp, int dir)
1144{
1145 u32 lastp, goalp;
1146
1147 /*
1148 * No segments means no data.
1149 */
1150 if (!cp->segments)
1151 dir = DMA_NONE;
1152
1153 /*
1154 * Set the data pointer.
1155 */
1156 switch(dir) {
1157#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
1158 case DMA_BIDIRECTIONAL:
1159#endif
1160 case DMA_TO_DEVICE:
1161 goalp = SCRIPTA_BA(np, data_out2) + 8;
1162 lastp = goalp - 8 - (cp->segments * (2*4));
1163#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
1164 cp->wgoalp = cpu_to_scr(goalp);
1165 if (dir != DMA_BIDIRECTIONAL)
1166 break;
1167 cp->phys.head.wlastp = cpu_to_scr(lastp);
1168 /* fall through */
1169#else
1170 break;
1171#endif
1172 case DMA_FROM_DEVICE:
1173 cp->host_flags |= HF_DATA_IN;
1174 goalp = SCRIPTA_BA(np, data_in2) + 8;
1175 lastp = goalp - 8 - (cp->segments * (2*4));
1176 break;
1177 case DMA_NONE:
1178 default:
1179#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
1180 cp->host_flags |= HF_DATA_IN;
1181#endif
1182 lastp = goalp = SCRIPTB_BA(np, no_data);
1183 break;
1184 }
1185
1186 /*
1187 * Set all pointers values needed by SCRIPTS.
1188 */
1189 cp->phys.head.lastp = cpu_to_scr(lastp);
1190 cp->phys.head.savep = cpu_to_scr(lastp);
1191 cp->startp = cp->phys.head.savep;
1192 cp->goalp = cpu_to_scr(goalp);
1193
1194#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
1195 /*
1196 * If direction is unknown, start at data_io.
1197 */
1198 if (dir == DMA_BIDIRECTIONAL)
1199 cp->phys.head.savep = cpu_to_scr(SCRIPTB_BA(np, data_io));
1200#endif
1201}
1202
1203/*
1204 * MEMORY ALLOCATOR. 1108 * MEMORY ALLOCATOR.
1205 */ 1109 */
1206 1110
diff --git a/drivers/scsi/sym53c8xx_2/sym_malloc.c b/drivers/scsi/sym53c8xx_2/sym_malloc.c
index a34d403ccc6c..92bf9b14a7a2 100644
--- a/drivers/scsi/sym53c8xx_2/sym_malloc.c
+++ b/drivers/scsi/sym53c8xx_2/sym_malloc.c
@@ -37,11 +37,7 @@
37 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 37 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38 */ 38 */
39 39
40#ifdef __FreeBSD__
41#include <dev/sym/sym_glue.h>
42#else
43#include "sym_glue.h" 40#include "sym_glue.h"
44#endif
45 41
46/* 42/*
47 * Simple power of two buddy-like generic allocator. 43 * Simple power of two buddy-like generic allocator.
diff --git a/drivers/scsi/sym53c8xx_2/sym_nvram.c b/drivers/scsi/sym53c8xx_2/sym_nvram.c
index 994b7566bcac..15d69298ab6e 100644
--- a/drivers/scsi/sym53c8xx_2/sym_nvram.c
+++ b/drivers/scsi/sym53c8xx_2/sym_nvram.c
@@ -92,29 +92,32 @@ void sym_nvram_setup_host(struct Scsi_Host *shost, struct sym_hcb *np, struct sy
92 * Get target set-up from Symbios format NVRAM. 92 * Get target set-up from Symbios format NVRAM.
93 */ 93 */
94static void 94static void
95sym_Symbios_setup_target(struct sym_hcb *np, int target, Symbios_nvram *nvram) 95sym_Symbios_setup_target(struct sym_tcb *tp, int target, Symbios_nvram *nvram)
96{ 96{
97 struct sym_tcb *tp = &np->target[target];
98 Symbios_target *tn = &nvram->target[target]; 97 Symbios_target *tn = &nvram->target[target];
99 98
100 tp->usrtags = 99 if (!(tn->flags & SYMBIOS_QUEUE_TAGS_ENABLED))
101 (tn->flags & SYMBIOS_QUEUE_TAGS_ENABLED)? SYM_SETUP_MAX_TAG : 0; 100 tp->usrtags = 0;
102
103 if (!(tn->flags & SYMBIOS_DISCONNECT_ENABLE)) 101 if (!(tn->flags & SYMBIOS_DISCONNECT_ENABLE))
104 tp->usrflags &= ~SYM_DISC_ENABLED; 102 tp->usrflags &= ~SYM_DISC_ENABLED;
105 if (!(tn->flags & SYMBIOS_SCAN_AT_BOOT_TIME)) 103 if (!(tn->flags & SYMBIOS_SCAN_AT_BOOT_TIME))
106 tp->usrflags |= SYM_SCAN_BOOT_DISABLED; 104 tp->usrflags |= SYM_SCAN_BOOT_DISABLED;
107 if (!(tn->flags & SYMBIOS_SCAN_LUNS)) 105 if (!(tn->flags & SYMBIOS_SCAN_LUNS))
108 tp->usrflags |= SYM_SCAN_LUNS_DISABLED; 106 tp->usrflags |= SYM_SCAN_LUNS_DISABLED;
107 tp->usr_period = (tn->sync_period + 3) / 4;
108 tp->usr_width = (tn->bus_width == 0x8) ? 0 : 1;
109} 109}
110 110
111static const unsigned char Tekram_sync[16] = {
112 25, 31, 37, 43, 50, 62, 75, 125, 12, 15, 18, 21, 6, 7, 9, 10
113};
114
111/* 115/*
112 * Get target set-up from Tekram format NVRAM. 116 * Get target set-up from Tekram format NVRAM.
113 */ 117 */
114static void 118static void
115sym_Tekram_setup_target(struct sym_hcb *np, int target, Tekram_nvram *nvram) 119sym_Tekram_setup_target(struct sym_tcb *tp, int target, Tekram_nvram *nvram)
116{ 120{
117 struct sym_tcb *tp = &np->target[target];
118 struct Tekram_target *tn = &nvram->target[target]; 121 struct Tekram_target *tn = &nvram->target[target];
119 122
120 if (tn->flags & TEKRAM_TAGGED_COMMANDS) { 123 if (tn->flags & TEKRAM_TAGGED_COMMANDS) {
@@ -124,22 +127,22 @@ sym_Tekram_setup_target(struct sym_hcb *np, int target, Tekram_nvram *nvram)
124 if (tn->flags & TEKRAM_DISCONNECT_ENABLE) 127 if (tn->flags & TEKRAM_DISCONNECT_ENABLE)
125 tp->usrflags |= SYM_DISC_ENABLED; 128 tp->usrflags |= SYM_DISC_ENABLED;
126 129
127 /* If any device does not support parity, we will not use this option */ 130 if (tn->flags & TEKRAM_SYNC_NEGO)
128 if (!(tn->flags & TEKRAM_PARITY_CHECK)) 131 tp->usr_period = Tekram_sync[tn->sync_index & 0xf];
129 np->rv_scntl0 &= ~0x0a; /* SCSI parity checking disabled */ 132 tp->usr_width = (tn->flags & TEKRAM_WIDE_NEGO) ? 1 : 0;
130} 133}
131 134
132/* 135/*
133 * Get target setup from NVRAM. 136 * Get target setup from NVRAM.
134 */ 137 */
135void sym_nvram_setup_target(struct sym_hcb *np, int target, struct sym_nvram *nvp) 138void sym_nvram_setup_target(struct sym_tcb *tp, int target, struct sym_nvram *nvp)
136{ 139{
137 switch (nvp->type) { 140 switch (nvp->type) {
138 case SYM_SYMBIOS_NVRAM: 141 case SYM_SYMBIOS_NVRAM:
139 sym_Symbios_setup_target(np, target, &nvp->data.Symbios); 142 sym_Symbios_setup_target(tp, target, &nvp->data.Symbios);
140 break; 143 break;
141 case SYM_TEKRAM_NVRAM: 144 case SYM_TEKRAM_NVRAM:
142 sym_Tekram_setup_target(np, target, &nvp->data.Tekram); 145 sym_Tekram_setup_target(tp, target, &nvp->data.Tekram);
143 break; 146 break;
144 default: 147 default:
145 break; 148 break;
diff --git a/drivers/scsi/sym53c8xx_2/sym_nvram.h b/drivers/scsi/sym53c8xx_2/sym_nvram.h
index 1538bede5277..bdfbbb083b69 100644
--- a/drivers/scsi/sym53c8xx_2/sym_nvram.h
+++ b/drivers/scsi/sym53c8xx_2/sym_nvram.h
@@ -194,12 +194,12 @@ struct sym_nvram {
194 194
195#if SYM_CONF_NVRAM_SUPPORT 195#if SYM_CONF_NVRAM_SUPPORT
196void sym_nvram_setup_host(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram); 196void sym_nvram_setup_host(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram);
197void sym_nvram_setup_target (struct sym_hcb *np, int target, struct sym_nvram *nvp); 197void sym_nvram_setup_target (struct sym_tcb *tp, int target, struct sym_nvram *nvp);
198int sym_read_nvram (struct sym_device *np, struct sym_nvram *nvp); 198int sym_read_nvram (struct sym_device *np, struct sym_nvram *nvp);
199char *sym_nvram_type(struct sym_nvram *nvp); 199char *sym_nvram_type(struct sym_nvram *nvp);
200#else 200#else
201static inline void sym_nvram_setup_host(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram) { } 201static inline void sym_nvram_setup_host(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram) { }
202static inline void sym_nvram_setup_target(struct sym_hcb *np, struct sym_nvram *nvram) { } 202static inline void sym_nvram_setup_target(struct sym_tcb *tp, struct sym_nvram *nvram) { }
203static inline int sym_read_nvram(struct sym_device *np, struct sym_nvram *nvp) 203static inline int sym_read_nvram(struct sym_device *np, struct sym_nvram *nvp)
204{ 204{
205 nvp->type = 0; 205 nvp->type = 0;