aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/fc4/fc.c28
-rw-r--r--drivers/fc4/fcp_impl.h15
-rw-r--r--drivers/message/fusion/mptbase.h4
-rw-r--r--drivers/message/fusion/mptfc.c89
-rw-r--r--drivers/s390/scsi/zfcp_def.h4
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c1
-rw-r--r--drivers/scsi/aic7xxx/aic79xx.h66
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_core.c350
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_inline.h30
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c45
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.h5
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm_pci.c2
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_pci.c7
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_proc.c2
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx.h11
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_core.c40
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c72
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.h13
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm_pci.c2
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_pci.c4
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_proc.c10
-rw-r--r--drivers/scsi/aic7xxx_old.c2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_hwi.h1
-rw-r--r--drivers/scsi/aic94xx/aic94xx_init.c2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_sds.c4
-rw-r--r--drivers/scsi/fdomain.c30
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c2
-rw-r--r--drivers/scsi/libiscsi.c69
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c3
-rw-r--r--drivers/scsi/lpfc/lpfc_ct.c3
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c42
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.h46
-rw-r--r--drivers/scsi/pcmcia/nsp_debug.c4
-rw-r--r--drivers/scsi/pcmcia/nsp_message.c4
-rw-r--r--drivers/scsi/psi240i.c31
-rw-r--r--drivers/scsi/psi240i.h6
-rw-r--r--drivers/scsi/qla1280.c7
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c51
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.h14
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h4
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h4
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c23
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c91
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c35
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h2
-rw-r--r--drivers/scsi/qla4xxx/ql4_dbg.h4
-rw-r--r--drivers/scsi/qla4xxx/ql4_glbl.h2
-rw-r--r--drivers/scsi/qla4xxx/ql4_mbx.c2
-rw-r--r--drivers/scsi/qla4xxx/ql4_os.c10
-rw-r--r--drivers/scsi/qlogicfas408.c18
-rw-r--r--drivers/scsi/qlogicfas408.h29
-rw-r--r--drivers/scsi/scsi_debug.c141
-rw-r--r--drivers/scsi/scsi_lib.c2
-rw-r--r--drivers/scsi/scsi_sysfs.c2
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c246
-rw-r--r--drivers/scsi/st.c5
-rw-r--r--drivers/scsi/sun3_NCR5380.c109
-rw-r--r--drivers/scsi/sun3_scsi.c7
-rw-r--r--drivers/scsi/sun3_scsi.h7
-rw-r--r--drivers/scsi/sun3_scsi_vme.c7
-rw-r--r--drivers/scsi/tmscsim.c1
-rw-r--r--include/scsi/libiscsi.h3
-rw-r--r--include/scsi/scsi.h5
-rw-r--r--include/scsi/scsi_transport_iscsi.h4
64 files changed, 1010 insertions, 874 deletions
diff --git a/drivers/fc4/fc.c b/drivers/fc4/fc.c
index 22d17474755f..ca4e67a022d0 100644
--- a/drivers/fc4/fc.c
+++ b/drivers/fc4/fc.c
@@ -70,9 +70,9 @@
70 70
71#define FCP_CMND(SCpnt) ((fcp_cmnd *)&(SCpnt->SCp)) 71#define FCP_CMND(SCpnt) ((fcp_cmnd *)&(SCpnt->SCp))
72#define FC_SCMND(SCpnt) ((fc_channel *)(SCpnt->device->host->hostdata[0])) 72#define FC_SCMND(SCpnt) ((fc_channel *)(SCpnt->device->host->hostdata[0]))
73#define SC_FCMND(fcmnd) ((Scsi_Cmnd *)((long)fcmnd - (long)&(((Scsi_Cmnd *)0)->SCp))) 73#define SC_FCMND(fcmnd) ((struct scsi_cmnd *)((long)fcmnd - (long)&(((struct scsi_cmnd *)0)->SCp)))
74 74
75static int fcp_scsi_queue_it(fc_channel *, Scsi_Cmnd *, fcp_cmnd *, int); 75static int fcp_scsi_queue_it(fc_channel *, struct scsi_cmnd *, fcp_cmnd *, int);
76void fcp_queue_empty(fc_channel *); 76void fcp_queue_empty(fc_channel *);
77 77
78static void fcp_scsi_insert_queue (fc_channel *fc, fcp_cmnd *fcmd) 78static void fcp_scsi_insert_queue (fc_channel *fc, fcp_cmnd *fcmd)
@@ -378,14 +378,14 @@ void fcp_register(fc_channel *fc, u8 type, int unregister)
378 printk ("FC: %segistering unknown type %02x\n", unregister ? "Unr" : "R", type); 378 printk ("FC: %segistering unknown type %02x\n", unregister ? "Unr" : "R", type);
379} 379}
380 380
381static void fcp_scsi_done(Scsi_Cmnd *SCpnt); 381static void fcp_scsi_done(struct scsi_cmnd *SCpnt);
382 382
383static inline void fcp_scsi_receive(fc_channel *fc, int token, int status, fc_hdr *fch) 383static inline void fcp_scsi_receive(fc_channel *fc, int token, int status, fc_hdr *fch)
384{ 384{
385 fcp_cmnd *fcmd; 385 fcp_cmnd *fcmd;
386 fcp_rsp *rsp; 386 fcp_rsp *rsp;
387 int host_status; 387 int host_status;
388 Scsi_Cmnd *SCpnt; 388 struct scsi_cmnd *SCpnt;
389 int sense_len; 389 int sense_len;
390 int rsp_status; 390 int rsp_status;
391 391
@@ -757,13 +757,14 @@ void fcp_release(fc_channel *fcchain, int count) /* count must > 0 */
757} 757}
758 758
759 759
760static void fcp_scsi_done (Scsi_Cmnd *SCpnt) 760static void fcp_scsi_done(struct scsi_cmnd *SCpnt)
761{ 761{
762 if (FCP_CMND(SCpnt)->done) 762 if (FCP_CMND(SCpnt)->done)
763 FCP_CMND(SCpnt)->done(SCpnt); 763 FCP_CMND(SCpnt)->done(SCpnt);
764} 764}
765 765
766static int fcp_scsi_queue_it(fc_channel *fc, Scsi_Cmnd *SCpnt, fcp_cmnd *fcmd, int prepare) 766static int fcp_scsi_queue_it(fc_channel *fc, struct scsi_cmnd *SCpnt,
767 fcp_cmnd *fcmd, int prepare)
767{ 768{
768 long i; 769 long i;
769 fcp_cmd *cmd; 770 fcp_cmd *cmd;
@@ -837,7 +838,8 @@ static int fcp_scsi_queue_it(fc_channel *fc, Scsi_Cmnd *SCpnt, fcp_cmnd *fcmd, i
837 return 0; 838 return 0;
838} 839}
839 840
840int fcp_scsi_queuecommand(Scsi_Cmnd *SCpnt, void (* done)(Scsi_Cmnd *)) 841int fcp_scsi_queuecommand(struct scsi_cmnd *SCpnt,
842 void (* done)(struct scsi_cmnd *))
841{ 843{
842 fcp_cmnd *fcmd = FCP_CMND(SCpnt); 844 fcp_cmnd *fcmd = FCP_CMND(SCpnt);
843 fc_channel *fc = FC_SCMND(SCpnt); 845 fc_channel *fc = FC_SCMND(SCpnt);
@@ -873,7 +875,7 @@ void fcp_queue_empty(fc_channel *fc)
873 } 875 }
874} 876}
875 877
876int fcp_scsi_abort(Scsi_Cmnd *SCpnt) 878int fcp_scsi_abort(struct scsi_cmnd *SCpnt)
877{ 879{
878 /* Internal bookkeeping only. Lose 1 cmd_slots slot. */ 880 /* Internal bookkeeping only. Lose 1 cmd_slots slot. */
879 fcp_cmnd *fcmd = FCP_CMND(SCpnt); 881 fcp_cmnd *fcmd = FCP_CMND(SCpnt);
@@ -910,7 +912,7 @@ int fcp_scsi_abort(Scsi_Cmnd *SCpnt)
910} 912}
911 913
912#if 0 914#if 0
913void fcp_scsi_reset_done(Scsi_Cmnd *SCpnt) 915void fcp_scsi_reset_done(struct scsi_cmnd *SCpnt)
914{ 916{
915 fc_channel *fc = FC_SCMND(SCpnt); 917 fc_channel *fc = FC_SCMND(SCpnt);
916 918
@@ -921,7 +923,7 @@ void fcp_scsi_reset_done(Scsi_Cmnd *SCpnt)
921 923
922#define FCP_RESET_TIMEOUT (2*HZ) 924#define FCP_RESET_TIMEOUT (2*HZ)
923 925
924int fcp_scsi_dev_reset(Scsi_Cmnd *SCpnt) 926int fcp_scsi_dev_reset(struct scsi_cmnd *SCpnt)
925{ 927{
926#if 0 /* broken junk, but if davem wants to compile this driver, let him.. */ 928#if 0 /* broken junk, but if davem wants to compile this driver, let him.. */
927 unsigned long flags; 929 unsigned long flags;
@@ -931,7 +933,7 @@ int fcp_scsi_dev_reset(Scsi_Cmnd *SCpnt)
931 DECLARE_MUTEX_LOCKED(sem); 933 DECLARE_MUTEX_LOCKED(sem);
932 934
933 if (!fc->rst_pkt) { 935 if (!fc->rst_pkt) {
934 fc->rst_pkt = (Scsi_Cmnd *) kmalloc(sizeof(SCpnt), GFP_KERNEL); 936 fc->rst_pkt = (struct scsi_cmnd *) kmalloc(sizeof(SCpnt), GFP_KERNEL);
935 if (!fc->rst_pkt) return FAILED; 937 if (!fc->rst_pkt) return FAILED;
936 938
937 fcmd = FCP_CMND(fc->rst_pkt); 939 fcmd = FCP_CMND(fc->rst_pkt);
@@ -999,7 +1001,7 @@ int fcp_scsi_dev_reset(Scsi_Cmnd *SCpnt)
999 return SUCCESS; 1001 return SUCCESS;
1000} 1002}
1001 1003
1002static int __fcp_scsi_host_reset(Scsi_Cmnd *SCpnt) 1004static int __fcp_scsi_host_reset(struct scsi_cmnd *SCpnt)
1003{ 1005{
1004 fc_channel *fc = FC_SCMND(SCpnt); 1006 fc_channel *fc = FC_SCMND(SCpnt);
1005 fcp_cmnd *fcmd = FCP_CMND(SCpnt); 1007 fcp_cmnd *fcmd = FCP_CMND(SCpnt);
@@ -1020,7 +1022,7 @@ static int __fcp_scsi_host_reset(Scsi_Cmnd *SCpnt)
1020 else return FAILED; 1022 else return FAILED;
1021} 1023}
1022 1024
1023int fcp_scsi_host_reset(Scsi_Cmnd *SCpnt) 1025int fcp_scsi_host_reset(struct scsi_cmnd *SCpnt)
1024{ 1026{
1025 unsigned long flags; 1027 unsigned long flags;
1026 int rc; 1028 int rc;
diff --git a/drivers/fc4/fcp_impl.h b/drivers/fc4/fcp_impl.h
index c397c84bef63..1ac61330592e 100644
--- a/drivers/fc4/fcp_impl.h
+++ b/drivers/fc4/fcp_impl.h
@@ -39,7 +39,7 @@ struct _fc_channel;
39typedef struct fcp_cmnd { 39typedef struct fcp_cmnd {
40 struct fcp_cmnd *next; 40 struct fcp_cmnd *next;
41 struct fcp_cmnd *prev; 41 struct fcp_cmnd *prev;
42 void (*done)(Scsi_Cmnd *); 42 void (*done)(struct scsi_cmnd *);
43 unsigned short proto; 43 unsigned short proto;
44 unsigned short token; 44 unsigned short token;
45 unsigned int did; 45 unsigned int did;
@@ -94,14 +94,14 @@ typedef struct _fc_channel {
94 long *scsi_bitmap; 94 long *scsi_bitmap;
95 long scsi_bitmap_end; 95 long scsi_bitmap_end;
96 int scsi_free; 96 int scsi_free;
97 int (*encode_addr)(Scsi_Cmnd *, u16 *, struct _fc_channel *, fcp_cmnd *); 97 int (*encode_addr)(struct scsi_cmnd *, u16 *, struct _fc_channel *, fcp_cmnd *);
98 fcp_cmnd *scsi_que; 98 fcp_cmnd *scsi_que;
99 char scsi_name[4]; 99 char scsi_name[4];
100 fcp_cmnd **cmd_slots; 100 fcp_cmnd **cmd_slots;
101 int channels; 101 int channels;
102 int targets; 102 int targets;
103 long *ages; 103 long *ages;
104 Scsi_Cmnd *rst_pkt; 104 struct scsi_cmnd *rst_pkt;
105 fcp_posmap *posmap; 105 fcp_posmap *posmap;
106 /* LOGIN stuff */ 106 /* LOGIN stuff */
107 fcp_cmnd *login; 107 fcp_cmnd *login;
@@ -155,9 +155,10 @@ int fc_do_prli(fc_channel *, unsigned char);
155 for_each_fc_channel(fc) \ 155 for_each_fc_channel(fc) \
156 if (fc->state == FC_STATE_ONLINE) 156 if (fc->state == FC_STATE_ONLINE)
157 157
158int fcp_scsi_queuecommand(Scsi_Cmnd *, void (* done)(Scsi_Cmnd *)); 158int fcp_scsi_queuecommand(struct scsi_cmnd *,
159int fcp_scsi_abort(Scsi_Cmnd *); 159 void (* done) (struct scsi_cmnd *));
160int fcp_scsi_dev_reset(Scsi_Cmnd *); 160int fcp_scsi_abort(struct scsi_cmnd *);
161int fcp_scsi_host_reset(Scsi_Cmnd *); 161int fcp_scsi_dev_reset(struct scsi_cmnd *);
162int fcp_scsi_host_reset(struct scsi_cmnd *);
162 163
163#endif /* !(_FCP_SCSI_H) */ 164#endif /* !(_FCP_SCSI_H) */
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index c537d71c18e4..a4afad4ecab2 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -75,8 +75,8 @@
75#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR 75#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR
76#endif 76#endif
77 77
78#define MPT_LINUX_VERSION_COMMON "3.04.01" 78#define MPT_LINUX_VERSION_COMMON "3.04.02"
79#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.04.01" 79#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.04.02"
80#define WHAT_MAGIC_STRING "@" "(" "#" ")" 80#define WHAT_MAGIC_STRING "@" "(" "#" ")"
81 81
82#define show_mptmod_ver(s,ver) \ 82#define show_mptmod_ver(s,ver) \
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index e57bb035a021..1dd491773150 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -96,6 +96,10 @@ static int mptfc_qcmd(struct scsi_cmnd *SCpnt,
96static void mptfc_target_destroy(struct scsi_target *starget); 96static void mptfc_target_destroy(struct scsi_target *starget);
97static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout); 97static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout);
98static void __devexit mptfc_remove(struct pci_dev *pdev); 98static void __devexit mptfc_remove(struct pci_dev *pdev);
99static int mptfc_abort(struct scsi_cmnd *SCpnt);
100static int mptfc_dev_reset(struct scsi_cmnd *SCpnt);
101static int mptfc_bus_reset(struct scsi_cmnd *SCpnt);
102static int mptfc_host_reset(struct scsi_cmnd *SCpnt);
99 103
100static struct scsi_host_template mptfc_driver_template = { 104static struct scsi_host_template mptfc_driver_template = {
101 .module = THIS_MODULE, 105 .module = THIS_MODULE,
@@ -110,10 +114,10 @@ static struct scsi_host_template mptfc_driver_template = {
110 .target_destroy = mptfc_target_destroy, 114 .target_destroy = mptfc_target_destroy,
111 .slave_destroy = mptscsih_slave_destroy, 115 .slave_destroy = mptscsih_slave_destroy,
112 .change_queue_depth = mptscsih_change_queue_depth, 116 .change_queue_depth = mptscsih_change_queue_depth,
113 .eh_abort_handler = mptscsih_abort, 117 .eh_abort_handler = mptfc_abort,
114 .eh_device_reset_handler = mptscsih_dev_reset, 118 .eh_device_reset_handler = mptfc_dev_reset,
115 .eh_bus_reset_handler = mptscsih_bus_reset, 119 .eh_bus_reset_handler = mptfc_bus_reset,
116 .eh_host_reset_handler = mptscsih_host_reset, 120 .eh_host_reset_handler = mptfc_host_reset,
117 .bios_param = mptscsih_bios_param, 121 .bios_param = mptscsih_bios_param,
118 .can_queue = MPT_FC_CAN_QUEUE, 122 .can_queue = MPT_FC_CAN_QUEUE,
119 .this_id = -1, 123 .this_id = -1,
@@ -171,6 +175,77 @@ static struct fc_function_template mptfc_transport_functions = {
171 .show_host_symbolic_name = 1, 175 .show_host_symbolic_name = 1,
172}; 176};
173 177
178static int
179mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
180 int (*func)(struct scsi_cmnd *SCpnt),
181 const char *caller)
182{
183 struct scsi_device *sdev = SCpnt->device;
184 struct Scsi_Host *shost = sdev->host;
185 struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
186 unsigned long flags;
187 int ready;
188
189 spin_lock_irqsave(shost->host_lock, flags);
190 while ((ready = fc_remote_port_chkready(rport) >> 16) == DID_IMM_RETRY) {
191 spin_unlock_irqrestore(shost->host_lock, flags);
192 dfcprintk ((MYIOC_s_INFO_FMT
193 "mptfc_block_error_handler.%d: %d:%d, port status is "
194 "DID_IMM_RETRY, deferring %s recovery.\n",
195 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
196 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no,
197 SCpnt->device->id,SCpnt->device->lun,caller));
198 msleep(1000);
199 spin_lock_irqsave(shost->host_lock, flags);
200 }
201 spin_unlock_irqrestore(shost->host_lock, flags);
202
203 if (ready == DID_NO_CONNECT || !SCpnt->device->hostdata) {
204 dfcprintk ((MYIOC_s_INFO_FMT
205 "%s.%d: %d:%d, failing recovery, "
206 "port state %d, vdev %p.\n", caller,
207 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
208 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no,
209 SCpnt->device->id,SCpnt->device->lun,ready,
210 SCpnt->device->hostdata));
211 return FAILED;
212 }
213 dfcprintk ((MYIOC_s_INFO_FMT
214 "%s.%d: %d:%d, executing recovery.\n", caller,
215 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
216 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no,
217 SCpnt->device->id,SCpnt->device->lun));
218 return (*func)(SCpnt);
219}
220
221static int
222mptfc_abort(struct scsi_cmnd *SCpnt)
223{
224 return
225 mptfc_block_error_handler(SCpnt, mptscsih_abort, __FUNCTION__);
226}
227
228static int
229mptfc_dev_reset(struct scsi_cmnd *SCpnt)
230{
231 return
232 mptfc_block_error_handler(SCpnt, mptscsih_dev_reset, __FUNCTION__);
233}
234
235static int
236mptfc_bus_reset(struct scsi_cmnd *SCpnt)
237{
238 return
239 mptfc_block_error_handler(SCpnt, mptscsih_bus_reset, __FUNCTION__);
240}
241
242static int
243mptfc_host_reset(struct scsi_cmnd *SCpnt)
244{
245 return
246 mptfc_block_error_handler(SCpnt, mptscsih_host_reset, __FUNCTION__);
247}
248
174static void 249static void
175mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) 250mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
176{ 251{
@@ -562,6 +637,12 @@ mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
562 return 0; 637 return 0;
563 } 638 }
564 639
640 if (!SCpnt->device->hostdata) { /* vdev */
641 SCpnt->result = DID_NO_CONNECT << 16;
642 done(SCpnt);
643 return 0;
644 }
645
565 /* dd_data is null until finished adding target */ 646 /* dd_data is null until finished adding target */
566 ri = *((struct mptfc_rport_info **)rport->dd_data); 647 ri = *((struct mptfc_rport_info **)rport->dd_data);
567 if (unlikely(!ri)) { 648 if (unlikely(!ri)) {
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 8f882690994d..74c0eac083e4 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -107,6 +107,10 @@ zfcp_address_to_sg(void *address, struct scatterlist *list)
107 (ZFCP_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2) 107 (ZFCP_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2)
108 /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */ 108 /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
109 109
110#define ZFCP_MAX_SECTORS (ZFCP_MAX_SBALES_PER_REQ * 8)
111 /* max. number of (data buffer) SBALEs in largest SBAL chain
112 multiplied with number of sectors per 4k block */
113
110/* FIXME(tune): free space should be one max. SBAL chain plus what? */ 114/* FIXME(tune): free space should be one max. SBAL chain plus what? */
111#define ZFCP_QDIO_PCI_INTERVAL (QDIO_MAX_BUFFERS_PER_Q \ 115#define ZFCP_QDIO_PCI_INTERVAL (QDIO_MAX_BUFFERS_PER_Q \
112 - (ZFCP_MAX_SBALS_PER_REQ + 4)) 116 - (ZFCP_MAX_SBALS_PER_REQ + 4))
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 4d2bc7981324..452d96f92a14 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -58,6 +58,7 @@ struct zfcp_data zfcp_data = {
58 .cmd_per_lun = 1, 58 .cmd_per_lun = 1,
59 .use_clustering = 1, 59 .use_clustering = 1,
60 .sdev_attrs = zfcp_sysfs_sdev_attrs, 60 .sdev_attrs = zfcp_sysfs_sdev_attrs,
61 .max_sectors = ZFCP_MAX_SECTORS,
61 }, 62 },
62 .driver_version = ZFCP_VERSION, 63 .driver_version = ZFCP_VERSION,
63}; 64};
diff --git a/drivers/scsi/aic7xxx/aic79xx.h b/drivers/scsi/aic7xxx/aic79xx.h
index df3346b5caf8..170a4344cbb2 100644
--- a/drivers/scsi/aic7xxx/aic79xx.h
+++ b/drivers/scsi/aic7xxx/aic79xx.h
@@ -53,14 +53,6 @@ struct ahd_platform_data;
53struct scb_platform_data; 53struct scb_platform_data;
54 54
55/****************************** Useful Macros *********************************/ 55/****************************** Useful Macros *********************************/
56#ifndef MAX
57#define MAX(a,b) (((a) > (b)) ? (a) : (b))
58#endif
59
60#ifndef MIN
61#define MIN(a,b) (((a) < (b)) ? (a) : (b))
62#endif
63
64#ifndef TRUE 56#ifndef TRUE
65#define TRUE 1 57#define TRUE 1
66#endif 58#endif
@@ -972,8 +964,6 @@ int ahd_read_seeprom(struct ahd_softc *ahd, uint16_t *buf,
972 964
973int ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf, 965int ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf,
974 u_int start_addr, u_int count); 966 u_int start_addr, u_int count);
975int ahd_wait_seeprom(struct ahd_softc *ahd);
976int ahd_verify_vpd_cksum(struct vpd_config *vpd);
977int ahd_verify_cksum(struct seeprom_config *sc); 967int ahd_verify_cksum(struct seeprom_config *sc);
978int ahd_acquire_seeprom(struct ahd_softc *ahd); 968int ahd_acquire_seeprom(struct ahd_softc *ahd);
979void ahd_release_seeprom(struct ahd_softc *ahd); 969void ahd_release_seeprom(struct ahd_softc *ahd);
@@ -1320,8 +1310,6 @@ struct ahd_pci_identity {
1320 char *name; 1310 char *name;
1321 ahd_device_setup_t *setup; 1311 ahd_device_setup_t *setup;
1322}; 1312};
1323extern struct ahd_pci_identity ahd_pci_ident_table [];
1324extern const u_int ahd_num_pci_devs;
1325 1313
1326/***************************** VL/EISA Declarations ***************************/ 1314/***************************** VL/EISA Declarations ***************************/
1327struct aic7770_identity { 1315struct aic7770_identity {
@@ -1339,15 +1327,6 @@ extern const int ahd_num_aic7770_devs;
1339/*************************** Function Declarations ****************************/ 1327/*************************** Function Declarations ****************************/
1340/******************************************************************************/ 1328/******************************************************************************/
1341void ahd_reset_cmds_pending(struct ahd_softc *ahd); 1329void ahd_reset_cmds_pending(struct ahd_softc *ahd);
1342u_int ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl);
1343void ahd_busy_tcl(struct ahd_softc *ahd,
1344 u_int tcl, u_int busyid);
1345static __inline void ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl);
1346static __inline void
1347ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl)
1348{
1349 ahd_busy_tcl(ahd, tcl, SCB_LIST_NULL);
1350}
1351 1330
1352/***************************** PCI Front End *********************************/ 1331/***************************** PCI Front End *********************************/
1353struct ahd_pci_identity *ahd_find_pci_device(ahd_dev_softc_t); 1332struct ahd_pci_identity *ahd_find_pci_device(ahd_dev_softc_t);
@@ -1356,7 +1335,6 @@ int ahd_pci_config(struct ahd_softc *,
1356int ahd_pci_test_register_access(struct ahd_softc *); 1335int ahd_pci_test_register_access(struct ahd_softc *);
1357 1336
1358/************************** SCB and SCB queue management **********************/ 1337/************************** SCB and SCB queue management **********************/
1359int ahd_probe_scbs(struct ahd_softc *);
1360void ahd_qinfifo_requeue_tail(struct ahd_softc *ahd, 1338void ahd_qinfifo_requeue_tail(struct ahd_softc *ahd,
1361 struct scb *scb); 1339 struct scb *scb);
1362int ahd_match_scb(struct ahd_softc *ahd, struct scb *scb, 1340int ahd_match_scb(struct ahd_softc *ahd, struct scb *scb,
@@ -1374,33 +1352,20 @@ int ahd_parse_vpddata(struct ahd_softc *ahd,
1374int ahd_parse_cfgdata(struct ahd_softc *ahd, 1352int ahd_parse_cfgdata(struct ahd_softc *ahd,
1375 struct seeprom_config *sc); 1353 struct seeprom_config *sc);
1376void ahd_intr_enable(struct ahd_softc *ahd, int enable); 1354void ahd_intr_enable(struct ahd_softc *ahd, int enable);
1377void ahd_update_coalescing_values(struct ahd_softc *ahd,
1378 u_int timer,
1379 u_int maxcmds,
1380 u_int mincmds);
1381void ahd_enable_coalescing(struct ahd_softc *ahd,
1382 int enable);
1383void ahd_pause_and_flushwork(struct ahd_softc *ahd); 1355void ahd_pause_and_flushwork(struct ahd_softc *ahd);
1384int ahd_suspend(struct ahd_softc *ahd); 1356int ahd_suspend(struct ahd_softc *ahd);
1385int ahd_resume(struct ahd_softc *ahd);
1386void ahd_set_unit(struct ahd_softc *, int); 1357void ahd_set_unit(struct ahd_softc *, int);
1387void ahd_set_name(struct ahd_softc *, char *); 1358void ahd_set_name(struct ahd_softc *, char *);
1388struct scb *ahd_get_scb(struct ahd_softc *ahd, u_int col_idx); 1359struct scb *ahd_get_scb(struct ahd_softc *ahd, u_int col_idx);
1389void ahd_free_scb(struct ahd_softc *ahd, struct scb *scb); 1360void ahd_free_scb(struct ahd_softc *ahd, struct scb *scb);
1390void ahd_alloc_scbs(struct ahd_softc *ahd);
1391void ahd_free(struct ahd_softc *ahd); 1361void ahd_free(struct ahd_softc *ahd);
1392int ahd_reset(struct ahd_softc *ahd, int reinit); 1362int ahd_reset(struct ahd_softc *ahd, int reinit);
1393void ahd_shutdown(void *arg);
1394int ahd_write_flexport(struct ahd_softc *ahd, 1363int ahd_write_flexport(struct ahd_softc *ahd,
1395 u_int addr, u_int value); 1364 u_int addr, u_int value);
1396int ahd_read_flexport(struct ahd_softc *ahd, u_int addr, 1365int ahd_read_flexport(struct ahd_softc *ahd, u_int addr,
1397 uint8_t *value); 1366 uint8_t *value);
1398int ahd_wait_flexport(struct ahd_softc *ahd);
1399 1367
1400/*************************** Interrupt Services *******************************/ 1368/*************************** Interrupt Services *******************************/
1401void ahd_pci_intr(struct ahd_softc *ahd);
1402void ahd_clear_intstat(struct ahd_softc *ahd);
1403void ahd_flush_qoutfifo(struct ahd_softc *ahd);
1404void ahd_run_qoutfifo(struct ahd_softc *ahd); 1369void ahd_run_qoutfifo(struct ahd_softc *ahd);
1405#ifdef AHD_TARGET_MODE 1370#ifdef AHD_TARGET_MODE
1406void ahd_run_tqinfifo(struct ahd_softc *ahd, int paused); 1371void ahd_run_tqinfifo(struct ahd_softc *ahd, int paused);
@@ -1409,7 +1374,6 @@ void ahd_handle_hwerrint(struct ahd_softc *ahd);
1409void ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat); 1374void ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat);
1410void ahd_handle_scsiint(struct ahd_softc *ahd, 1375void ahd_handle_scsiint(struct ahd_softc *ahd,
1411 u_int intstat); 1376 u_int intstat);
1412void ahd_clear_critical_section(struct ahd_softc *ahd);
1413 1377
1414/***************************** Error Recovery *********************************/ 1378/***************************** Error Recovery *********************************/
1415typedef enum { 1379typedef enum {
@@ -1426,23 +1390,9 @@ int ahd_search_disc_list(struct ahd_softc *ahd, int target,
1426 char channel, int lun, u_int tag, 1390 char channel, int lun, u_int tag,
1427 int stop_on_first, int remove, 1391 int stop_on_first, int remove,
1428 int save_state); 1392 int save_state);
1429void ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb);
1430int ahd_reset_channel(struct ahd_softc *ahd, char channel, 1393int ahd_reset_channel(struct ahd_softc *ahd, char channel,
1431 int initiate_reset); 1394 int initiate_reset);
1432int ahd_abort_scbs(struct ahd_softc *ahd, int target,
1433 char channel, int lun, u_int tag,
1434 role_t role, uint32_t status);
1435void ahd_restart(struct ahd_softc *ahd);
1436void ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo);
1437void ahd_handle_scb_status(struct ahd_softc *ahd,
1438 struct scb *scb);
1439void ahd_handle_scsi_status(struct ahd_softc *ahd,
1440 struct scb *scb);
1441void ahd_calc_residual(struct ahd_softc *ahd,
1442 struct scb *scb);
1443/*************************** Utility Functions ********************************/ 1395/*************************** Utility Functions ********************************/
1444struct ahd_phase_table_entry*
1445 ahd_lookup_phase_entry(int phase);
1446void ahd_compile_devinfo(struct ahd_devinfo *devinfo, 1396void ahd_compile_devinfo(struct ahd_devinfo *devinfo,
1447 u_int our_id, u_int target, 1397 u_int our_id, u_int target,
1448 u_int lun, char channel, 1398 u_int lun, char channel,
@@ -1450,14 +1400,6 @@ void ahd_compile_devinfo(struct ahd_devinfo *devinfo,
1450/************************** Transfer Negotiation ******************************/ 1400/************************** Transfer Negotiation ******************************/
1451void ahd_find_syncrate(struct ahd_softc *ahd, u_int *period, 1401void ahd_find_syncrate(struct ahd_softc *ahd, u_int *period,
1452 u_int *ppr_options, u_int maxsync); 1402 u_int *ppr_options, u_int maxsync);
1453void ahd_validate_offset(struct ahd_softc *ahd,
1454 struct ahd_initiator_tinfo *tinfo,
1455 u_int period, u_int *offset,
1456 int wide, role_t role);
1457void ahd_validate_width(struct ahd_softc *ahd,
1458 struct ahd_initiator_tinfo *tinfo,
1459 u_int *bus_width,
1460 role_t role);
1461/* 1403/*
1462 * Negotiation types. These are used to qualify if we should renegotiate 1404 * Negotiation types. These are used to qualify if we should renegotiate
1463 * even if our goal and current transport parameters are identical. 1405 * even if our goal and current transport parameters are identical.
@@ -1486,11 +1428,6 @@ typedef enum {
1486 AHD_QUEUE_TAGGED 1428 AHD_QUEUE_TAGGED
1487} ahd_queue_alg; 1429} ahd_queue_alg;
1488 1430
1489void ahd_set_tags(struct ahd_softc *ahd,
1490 struct scsi_cmnd *cmd,
1491 struct ahd_devinfo *devinfo,
1492 ahd_queue_alg alg);
1493
1494/**************************** Target Mode *************************************/ 1431/**************************** Target Mode *************************************/
1495#ifdef AHD_TARGET_MODE 1432#ifdef AHD_TARGET_MODE
1496void ahd_send_lstate_events(struct ahd_softc *, 1433void ahd_send_lstate_events(struct ahd_softc *,
@@ -1528,10 +1465,8 @@ extern uint32_t ahd_debug;
1528#define AHD_SHOW_INT_COALESCING 0x10000 1465#define AHD_SHOW_INT_COALESCING 0x10000
1529#define AHD_DEBUG_SEQUENCER 0x20000 1466#define AHD_DEBUG_SEQUENCER 0x20000
1530#endif 1467#endif
1531void ahd_print_scb(struct scb *scb);
1532void ahd_print_devinfo(struct ahd_softc *ahd, 1468void ahd_print_devinfo(struct ahd_softc *ahd,
1533 struct ahd_devinfo *devinfo); 1469 struct ahd_devinfo *devinfo);
1534void ahd_dump_sglist(struct scb *scb);
1535void ahd_dump_card_state(struct ahd_softc *ahd); 1470void ahd_dump_card_state(struct ahd_softc *ahd);
1536int ahd_print_register(ahd_reg_parse_entry_t *table, 1471int ahd_print_register(ahd_reg_parse_entry_t *table,
1537 u_int num_entries, 1472 u_int num_entries,
@@ -1540,5 +1475,4 @@ int ahd_print_register(ahd_reg_parse_entry_t *table,
1540 u_int value, 1475 u_int value,
1541 u_int *cur_column, 1476 u_int *cur_column,
1542 u_int wrap_point); 1477 u_int wrap_point);
1543void ahd_dump_scbs(struct ahd_softc *ahd);
1544#endif /* _AIC79XX_H_ */ 1478#endif /* _AIC79XX_H_ */
diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c
index 653818d2f802..07a86a30f676 100644
--- a/drivers/scsi/aic7xxx/aic79xx_core.c
+++ b/drivers/scsi/aic7xxx/aic79xx_core.c
@@ -52,7 +52,7 @@
52 52
53 53
54/***************************** Lookup Tables **********************************/ 54/***************************** Lookup Tables **********************************/
55char *ahd_chip_names[] = 55static char *ahd_chip_names[] =
56{ 56{
57 "NONE", 57 "NONE",
58 "aic7901", 58 "aic7901",
@@ -237,10 +237,33 @@ static int ahd_handle_target_cmd(struct ahd_softc *ahd,
237 struct target_cmd *cmd); 237 struct target_cmd *cmd);
238#endif 238#endif
239 239
240static int ahd_abort_scbs(struct ahd_softc *ahd, int target,
241 char channel, int lun, u_int tag,
242 role_t role, uint32_t status);
243static void ahd_alloc_scbs(struct ahd_softc *ahd);
244static void ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl,
245 u_int scbid);
246static void ahd_calc_residual(struct ahd_softc *ahd,
247 struct scb *scb);
248static void ahd_clear_critical_section(struct ahd_softc *ahd);
249static void ahd_clear_intstat(struct ahd_softc *ahd);
250static void ahd_enable_coalescing(struct ahd_softc *ahd,
251 int enable);
252static u_int ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl);
253static void ahd_freeze_devq(struct ahd_softc *ahd,
254 struct scb *scb);
255static void ahd_handle_scb_status(struct ahd_softc *ahd,
256 struct scb *scb);
257static struct ahd_phase_table_entry* ahd_lookup_phase_entry(int phase);
258static void ahd_shutdown(void *arg);
259static void ahd_update_coalescing_values(struct ahd_softc *ahd,
260 u_int timer,
261 u_int maxcmds,
262 u_int mincmds);
263static int ahd_verify_vpd_cksum(struct vpd_config *vpd);
264static int ahd_wait_seeprom(struct ahd_softc *ahd);
265
240/******************************** Private Inlines *****************************/ 266/******************************** Private Inlines *****************************/
241static __inline void ahd_assert_atn(struct ahd_softc *ahd);
242static __inline int ahd_currently_packetized(struct ahd_softc *ahd);
243static __inline int ahd_set_active_fifo(struct ahd_softc *ahd);
244 267
245static __inline void 268static __inline void
246ahd_assert_atn(struct ahd_softc *ahd) 269ahd_assert_atn(struct ahd_softc *ahd)
@@ -294,11 +317,44 @@ ahd_set_active_fifo(struct ahd_softc *ahd)
294 } 317 }
295} 318}
296 319
320static __inline void
321ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl)
322{
323 ahd_busy_tcl(ahd, tcl, SCB_LIST_NULL);
324}
325
326/*
327 * Determine whether the sequencer reported a residual
328 * for this SCB/transaction.
329 */
330static __inline void
331ahd_update_residual(struct ahd_softc *ahd, struct scb *scb)
332{
333 uint32_t sgptr;
334
335 sgptr = ahd_le32toh(scb->hscb->sgptr);
336 if ((sgptr & SG_STATUS_VALID) != 0)
337 ahd_calc_residual(ahd, scb);
338}
339
340static __inline void
341ahd_complete_scb(struct ahd_softc *ahd, struct scb *scb)
342{
343 uint32_t sgptr;
344
345 sgptr = ahd_le32toh(scb->hscb->sgptr);
346 if ((sgptr & SG_STATUS_VALID) != 0)
347 ahd_handle_scb_status(ahd, scb);
348 else
349 ahd_done(ahd, scb);
350}
351
352
297/************************* Sequencer Execution Control ************************/ 353/************************* Sequencer Execution Control ************************/
298/* 354/*
299 * Restart the sequencer program from address zero 355 * Restart the sequencer program from address zero
300 */ 356 */
301void 357static void
302ahd_restart(struct ahd_softc *ahd) 358ahd_restart(struct ahd_softc *ahd)
303{ 359{
304 360
@@ -342,7 +398,7 @@ ahd_restart(struct ahd_softc *ahd)
342 ahd_unpause(ahd); 398 ahd_unpause(ahd);
343} 399}
344 400
345void 401static void
346ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo) 402ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo)
347{ 403{
348 ahd_mode_state saved_modes; 404 ahd_mode_state saved_modes;
@@ -366,7 +422,7 @@ ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo)
366 * Flush and completed commands that are sitting in the command 422 * Flush and completed commands that are sitting in the command
367 * complete queues down on the chip but have yet to be dma'ed back up. 423 * complete queues down on the chip but have yet to be dma'ed back up.
368 */ 424 */
369void 425static void
370ahd_flush_qoutfifo(struct ahd_softc *ahd) 426ahd_flush_qoutfifo(struct ahd_softc *ahd)
371{ 427{
372 struct scb *scb; 428 struct scb *scb;
@@ -905,6 +961,51 @@ ahd_handle_hwerrint(struct ahd_softc *ahd)
905 ahd_free(ahd); 961 ahd_free(ahd);
906} 962}
907 963
964#ifdef AHD_DEBUG
965static void
966ahd_dump_sglist(struct scb *scb)
967{
968 int i;
969
970 if (scb->sg_count > 0) {
971 if ((scb->ahd_softc->flags & AHD_64BIT_ADDRESSING) != 0) {
972 struct ahd_dma64_seg *sg_list;
973
974 sg_list = (struct ahd_dma64_seg*)scb->sg_list;
975 for (i = 0; i < scb->sg_count; i++) {
976 uint64_t addr;
977 uint32_t len;
978
979 addr = ahd_le64toh(sg_list[i].addr);
980 len = ahd_le32toh(sg_list[i].len);
981 printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
982 i,
983 (uint32_t)((addr >> 32) & 0xFFFFFFFF),
984 (uint32_t)(addr & 0xFFFFFFFF),
985 sg_list[i].len & AHD_SG_LEN_MASK,
986 (sg_list[i].len & AHD_DMA_LAST_SEG)
987 ? " Last" : "");
988 }
989 } else {
990 struct ahd_dma_seg *sg_list;
991
992 sg_list = (struct ahd_dma_seg*)scb->sg_list;
993 for (i = 0; i < scb->sg_count; i++) {
994 uint32_t len;
995
996 len = ahd_le32toh(sg_list[i].len);
997 printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
998 i,
999 (len & AHD_SG_HIGH_ADDR_MASK) >> 24,
1000 ahd_le32toh(sg_list[i].addr),
1001 len & AHD_SG_LEN_MASK,
1002 len & AHD_DMA_LAST_SEG ? " Last" : "");
1003 }
1004 }
1005 }
1006}
1007#endif /* AHD_DEBUG */
1008
908void 1009void
909ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat) 1010ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
910{ 1011{
@@ -1053,10 +1154,12 @@ ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
1053 * If a target takes us into the command phase 1154 * If a target takes us into the command phase
1054 * assume that it has been externally reset and 1155 * assume that it has been externally reset and
1055 * has thus lost our previous packetized negotiation 1156 * has thus lost our previous packetized negotiation
1056 * agreement. 1157 * agreement. Since we have not sent an identify
1057 * Revert to async/narrow transfers until we 1158 * message and may not have fully qualified the
1058 * can renegotiate with the device and notify 1159 * connection, we change our command to TUR, assert
1059 * the OSM about the reset. 1160 * ATN and ABORT the task when we go to message in
1161 * phase. The OSM will see the REQUEUE_REQUEST
1162 * status and retry the command.
1060 */ 1163 */
1061 scbid = ahd_get_scbptr(ahd); 1164 scbid = ahd_get_scbptr(ahd);
1062 scb = ahd_lookup_scb(ahd, scbid); 1165 scb = ahd_lookup_scb(ahd, scbid);
@@ -1083,7 +1186,28 @@ ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
1083 ahd_set_syncrate(ahd, &devinfo, /*period*/0, 1186 ahd_set_syncrate(ahd, &devinfo, /*period*/0,
1084 /*offset*/0, /*ppr_options*/0, 1187 /*offset*/0, /*ppr_options*/0,
1085 AHD_TRANS_ACTIVE, /*paused*/TRUE); 1188 AHD_TRANS_ACTIVE, /*paused*/TRUE);
1086 scb->flags |= SCB_EXTERNAL_RESET; 1189 /* Hand-craft TUR command */
1190 ahd_outb(ahd, SCB_CDB_STORE, 0);
1191 ahd_outb(ahd, SCB_CDB_STORE+1, 0);
1192 ahd_outb(ahd, SCB_CDB_STORE+2, 0);
1193 ahd_outb(ahd, SCB_CDB_STORE+3, 0);
1194 ahd_outb(ahd, SCB_CDB_STORE+4, 0);
1195 ahd_outb(ahd, SCB_CDB_STORE+5, 0);
1196 ahd_outb(ahd, SCB_CDB_LEN, 6);
1197 scb->hscb->control &= ~(TAG_ENB|SCB_TAG_TYPE);
1198 scb->hscb->control |= MK_MESSAGE;
1199 ahd_outb(ahd, SCB_CONTROL, scb->hscb->control);
1200 ahd_outb(ahd, MSG_OUT, HOST_MSG);
1201 ahd_outb(ahd, SAVED_SCSIID, scb->hscb->scsiid);
1202 /*
1203 * The lun is 0, regardless of the SCB's lun
1204 * as we have not sent an identify message.
1205 */
1206 ahd_outb(ahd, SAVED_LUN, 0);
1207 ahd_outb(ahd, SEQ_FLAGS, 0);
1208 ahd_assert_atn(ahd);
1209 scb->flags &= ~SCB_PACKETIZED;
1210 scb->flags |= SCB_ABORT|SCB_EXTERNAL_RESET;
1087 ahd_freeze_devq(ahd, scb); 1211 ahd_freeze_devq(ahd, scb);
1088 ahd_set_transaction_status(scb, CAM_REQUEUE_REQ); 1212 ahd_set_transaction_status(scb, CAM_REQUEUE_REQ);
1089 ahd_freeze_scb(scb); 1213 ahd_freeze_scb(scb);
@@ -1519,8 +1643,10 @@ ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
1519 /* 1643 /*
1520 * Ignore external resets after a bus reset. 1644 * Ignore external resets after a bus reset.
1521 */ 1645 */
1522 if (((status & SCSIRSTI) != 0) && (ahd->flags & AHD_BUS_RESET_ACTIVE)) 1646 if (((status & SCSIRSTI) != 0) && (ahd->flags & AHD_BUS_RESET_ACTIVE)) {
1647 ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI);
1523 return; 1648 return;
1649 }
1524 1650
1525 /* 1651 /*
1526 * Clear bus reset flag 1652 * Clear bus reset flag
@@ -2200,6 +2326,22 @@ ahd_handle_nonpkt_busfree(struct ahd_softc *ahd)
2200 if (sent_msg == MSG_ABORT_TAG) 2326 if (sent_msg == MSG_ABORT_TAG)
2201 tag = SCB_GET_TAG(scb); 2327 tag = SCB_GET_TAG(scb);
2202 2328
2329 if ((scb->flags & SCB_EXTERNAL_RESET) != 0) {
2330 /*
2331 * This abort is in response to an
2332 * unexpected switch to command phase
2333 * for a packetized connection. Since
2334 * the identify message was never sent,
2335 * "saved lun" is 0. We really want to
2336 * abort only the SCB that encountered
2337 * this error, which could have a different
2338 * lun. The SCB will be retried so the OS
2339 * will see the UA after renegotiating to
2340 * packetized.
2341 */
2342 tag = SCB_GET_TAG(scb);
2343 saved_lun = scb->hscb->lun;
2344 }
2203 found = ahd_abort_scbs(ahd, target, 'A', saved_lun, 2345 found = ahd_abort_scbs(ahd, target, 'A', saved_lun,
2204 tag, ROLE_INITIATOR, 2346 tag, ROLE_INITIATOR,
2205 CAM_REQ_ABORTED); 2347 CAM_REQ_ABORTED);
@@ -2523,7 +2665,7 @@ ahd_force_renegotiation(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
2523} 2665}
2524 2666
2525#define AHD_MAX_STEPS 2000 2667#define AHD_MAX_STEPS 2000
2526void 2668static void
2527ahd_clear_critical_section(struct ahd_softc *ahd) 2669ahd_clear_critical_section(struct ahd_softc *ahd)
2528{ 2670{
2529 ahd_mode_state saved_modes; 2671 ahd_mode_state saved_modes;
@@ -2646,7 +2788,7 @@ ahd_clear_critical_section(struct ahd_softc *ahd)
2646/* 2788/*
2647 * Clear any pending interrupt status. 2789 * Clear any pending interrupt status.
2648 */ 2790 */
2649void 2791static void
2650ahd_clear_intstat(struct ahd_softc *ahd) 2792ahd_clear_intstat(struct ahd_softc *ahd)
2651{ 2793{
2652 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK), 2794 AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
@@ -2677,6 +2819,8 @@ ahd_clear_intstat(struct ahd_softc *ahd)
2677#ifdef AHD_DEBUG 2819#ifdef AHD_DEBUG
2678uint32_t ahd_debug = AHD_DEBUG_OPTS; 2820uint32_t ahd_debug = AHD_DEBUG_OPTS;
2679#endif 2821#endif
2822
2823#if 0
2680void 2824void
2681ahd_print_scb(struct scb *scb) 2825ahd_print_scb(struct scb *scb)
2682{ 2826{
@@ -2701,49 +2845,7 @@ ahd_print_scb(struct scb *scb)
2701 SCB_GET_TAG(scb)); 2845 SCB_GET_TAG(scb));
2702 ahd_dump_sglist(scb); 2846 ahd_dump_sglist(scb);
2703} 2847}
2704 2848#endif /* 0 */
2705void
2706ahd_dump_sglist(struct scb *scb)
2707{
2708 int i;
2709
2710 if (scb->sg_count > 0) {
2711 if ((scb->ahd_softc->flags & AHD_64BIT_ADDRESSING) != 0) {
2712 struct ahd_dma64_seg *sg_list;
2713
2714 sg_list = (struct ahd_dma64_seg*)scb->sg_list;
2715 for (i = 0; i < scb->sg_count; i++) {
2716 uint64_t addr;
2717 uint32_t len;
2718
2719 addr = ahd_le64toh(sg_list[i].addr);
2720 len = ahd_le32toh(sg_list[i].len);
2721 printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
2722 i,
2723 (uint32_t)((addr >> 32) & 0xFFFFFFFF),
2724 (uint32_t)(addr & 0xFFFFFFFF),
2725 sg_list[i].len & AHD_SG_LEN_MASK,
2726 (sg_list[i].len & AHD_DMA_LAST_SEG)
2727 ? " Last" : "");
2728 }
2729 } else {
2730 struct ahd_dma_seg *sg_list;
2731
2732 sg_list = (struct ahd_dma_seg*)scb->sg_list;
2733 for (i = 0; i < scb->sg_count; i++) {
2734 uint32_t len;
2735
2736 len = ahd_le32toh(sg_list[i].len);
2737 printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
2738 i,
2739 (len & AHD_SG_HIGH_ADDR_MASK) >> 24,
2740 ahd_le32toh(sg_list[i].addr),
2741 len & AHD_SG_LEN_MASK,
2742 len & AHD_DMA_LAST_SEG ? " Last" : "");
2743 }
2744 }
2745 }
2746}
2747 2849
2748/************************* Transfer Negotiation *******************************/ 2850/************************* Transfer Negotiation *******************************/
2749/* 2851/*
@@ -2850,14 +2952,14 @@ ahd_devlimited_syncrate(struct ahd_softc *ahd,
2850 transinfo = &tinfo->goal; 2952 transinfo = &tinfo->goal;
2851 *ppr_options &= (transinfo->ppr_options|MSG_EXT_PPR_PCOMP_EN); 2953 *ppr_options &= (transinfo->ppr_options|MSG_EXT_PPR_PCOMP_EN);
2852 if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) { 2954 if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) {
2853 maxsync = MAX(maxsync, AHD_SYNCRATE_ULTRA2); 2955 maxsync = max(maxsync, (u_int)AHD_SYNCRATE_ULTRA2);
2854 *ppr_options &= ~MSG_EXT_PPR_DT_REQ; 2956 *ppr_options &= ~MSG_EXT_PPR_DT_REQ;
2855 } 2957 }
2856 if (transinfo->period == 0) { 2958 if (transinfo->period == 0) {
2857 *period = 0; 2959 *period = 0;
2858 *ppr_options = 0; 2960 *ppr_options = 0;
2859 } else { 2961 } else {
2860 *period = MAX(*period, transinfo->period); 2962 *period = max(*period, (u_int)transinfo->period);
2861 ahd_find_syncrate(ahd, period, ppr_options, maxsync); 2963 ahd_find_syncrate(ahd, period, ppr_options, maxsync);
2862 } 2964 }
2863} 2965}
@@ -2906,7 +3008,7 @@ ahd_find_syncrate(struct ahd_softc *ahd, u_int *period,
2906 * Truncate the given synchronous offset to a value the 3008 * Truncate the given synchronous offset to a value the
2907 * current adapter type and syncrate are capable of. 3009 * current adapter type and syncrate are capable of.
2908 */ 3010 */
2909void 3011static void
2910ahd_validate_offset(struct ahd_softc *ahd, 3012ahd_validate_offset(struct ahd_softc *ahd,
2911 struct ahd_initiator_tinfo *tinfo, 3013 struct ahd_initiator_tinfo *tinfo,
2912 u_int period, u_int *offset, int wide, 3014 u_int period, u_int *offset, int wide,
@@ -2924,12 +3026,12 @@ ahd_validate_offset(struct ahd_softc *ahd,
2924 maxoffset = MAX_OFFSET_PACED; 3026 maxoffset = MAX_OFFSET_PACED;
2925 } else 3027 } else
2926 maxoffset = MAX_OFFSET_NON_PACED; 3028 maxoffset = MAX_OFFSET_NON_PACED;
2927 *offset = MIN(*offset, maxoffset); 3029 *offset = min(*offset, maxoffset);
2928 if (tinfo != NULL) { 3030 if (tinfo != NULL) {
2929 if (role == ROLE_TARGET) 3031 if (role == ROLE_TARGET)
2930 *offset = MIN(*offset, tinfo->user.offset); 3032 *offset = min(*offset, (u_int)tinfo->user.offset);
2931 else 3033 else
2932 *offset = MIN(*offset, tinfo->goal.offset); 3034 *offset = min(*offset, (u_int)tinfo->goal.offset);
2933 } 3035 }
2934} 3036}
2935 3037
@@ -2937,7 +3039,7 @@ ahd_validate_offset(struct ahd_softc *ahd,
2937 * Truncate the given transfer width parameter to a value the 3039 * Truncate the given transfer width parameter to a value the
2938 * current adapter type is capable of. 3040 * current adapter type is capable of.
2939 */ 3041 */
2940void 3042static void
2941ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo, 3043ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo,
2942 u_int *bus_width, role_t role) 3044 u_int *bus_width, role_t role)
2943{ 3045{
@@ -2955,9 +3057,9 @@ ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo,
2955 } 3057 }
2956 if (tinfo != NULL) { 3058 if (tinfo != NULL) {
2957 if (role == ROLE_TARGET) 3059 if (role == ROLE_TARGET)
2958 *bus_width = MIN(tinfo->user.width, *bus_width); 3060 *bus_width = min((u_int)tinfo->user.width, *bus_width);
2959 else 3061 else
2960 *bus_width = MIN(tinfo->goal.width, *bus_width); 3062 *bus_width = min((u_int)tinfo->goal.width, *bus_width);
2961 } 3063 }
2962} 3064}
2963 3065
@@ -3210,7 +3312,7 @@ ahd_set_width(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
3210/* 3312/*
3211 * Update the current state of tagged queuing for a given target. 3313 * Update the current state of tagged queuing for a given target.
3212 */ 3314 */
3213void 3315static void
3214ahd_set_tags(struct ahd_softc *ahd, struct scsi_cmnd *cmd, 3316ahd_set_tags(struct ahd_softc *ahd, struct scsi_cmnd *cmd,
3215 struct ahd_devinfo *devinfo, ahd_queue_alg alg) 3317 struct ahd_devinfo *devinfo, ahd_queue_alg alg)
3216{ 3318{
@@ -3466,7 +3568,7 @@ ahd_print_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
3466 devinfo->target, devinfo->lun); 3568 devinfo->target, devinfo->lun);
3467} 3569}
3468 3570
3469struct ahd_phase_table_entry* 3571static struct ahd_phase_table_entry*
3470ahd_lookup_phase_entry(int phase) 3572ahd_lookup_phase_entry(int phase)
3471{ 3573{
3472 struct ahd_phase_table_entry *entry; 3574 struct ahd_phase_table_entry *entry;
@@ -5351,7 +5453,7 @@ ahd_free(struct ahd_softc *ahd)
5351 return; 5453 return;
5352} 5454}
5353 5455
5354void 5456static void
5355ahd_shutdown(void *arg) 5457ahd_shutdown(void *arg)
5356{ 5458{
5357 struct ahd_softc *ahd; 5459 struct ahd_softc *ahd;
@@ -5480,7 +5582,7 @@ ahd_reset(struct ahd_softc *ahd, int reinit)
5480/* 5582/*
5481 * Determine the number of SCBs available on the controller 5583 * Determine the number of SCBs available on the controller
5482 */ 5584 */
5483int 5585static int
5484ahd_probe_scbs(struct ahd_softc *ahd) { 5586ahd_probe_scbs(struct ahd_softc *ahd) {
5485 int i; 5587 int i;
5486 5588
@@ -5929,7 +6031,7 @@ ahd_free_scb(struct ahd_softc *ahd, struct scb *scb)
5929 ahd_platform_scb_free(ahd, scb); 6031 ahd_platform_scb_free(ahd, scb);
5930} 6032}
5931 6033
5932void 6034static void
5933ahd_alloc_scbs(struct ahd_softc *ahd) 6035ahd_alloc_scbs(struct ahd_softc *ahd)
5934{ 6036{
5935 struct scb_data *scb_data; 6037 struct scb_data *scb_data;
@@ -6057,9 +6159,9 @@ ahd_alloc_scbs(struct ahd_softc *ahd)
6057#endif 6159#endif
6058 } 6160 }
6059 6161
6060 newcount = MIN(scb_data->sense_left, scb_data->scbs_left); 6162 newcount = min(scb_data->sense_left, scb_data->scbs_left);
6061 newcount = MIN(newcount, scb_data->sgs_left); 6163 newcount = min(newcount, scb_data->sgs_left);
6062 newcount = MIN(newcount, (AHD_SCB_MAX_ALLOC - scb_data->numscbs)); 6164 newcount = min(newcount, (AHD_SCB_MAX_ALLOC - scb_data->numscbs));
6063 for (i = 0; i < newcount; i++) { 6165 for (i = 0; i < newcount; i++) {
6064 struct scb_platform_data *pdata; 6166 struct scb_platform_data *pdata;
6065 u_int col_tag; 6167 u_int col_tag;
@@ -6982,7 +7084,7 @@ ahd_intr_enable(struct ahd_softc *ahd, int enable)
6982 ahd_outb(ahd, HCNTRL, hcntrl); 7084 ahd_outb(ahd, HCNTRL, hcntrl);
6983} 7085}
6984 7086
6985void 7087static void
6986ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds, 7088ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds,
6987 u_int mincmds) 7089 u_int mincmds)
6988{ 7090{
@@ -7000,7 +7102,7 @@ ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds,
7000 ahd_outb(ahd, INT_COALESCING_MINCMDS, -mincmds); 7102 ahd_outb(ahd, INT_COALESCING_MINCMDS, -mincmds);
7001} 7103}
7002 7104
7003void 7105static void
7004ahd_enable_coalescing(struct ahd_softc *ahd, int enable) 7106ahd_enable_coalescing(struct ahd_softc *ahd, int enable)
7005{ 7107{
7006 7108
@@ -7070,6 +7172,7 @@ ahd_pause_and_flushwork(struct ahd_softc *ahd)
7070 ahd->flags &= ~AHD_ALL_INTERRUPTS; 7172 ahd->flags &= ~AHD_ALL_INTERRUPTS;
7071} 7173}
7072 7174
7175#if 0
7073int 7176int
7074ahd_suspend(struct ahd_softc *ahd) 7177ahd_suspend(struct ahd_softc *ahd)
7075{ 7178{
@@ -7083,7 +7186,9 @@ ahd_suspend(struct ahd_softc *ahd)
7083 ahd_shutdown(ahd); 7186 ahd_shutdown(ahd);
7084 return (0); 7187 return (0);
7085} 7188}
7189#endif /* 0 */
7086 7190
7191#if 0
7087int 7192int
7088ahd_resume(struct ahd_softc *ahd) 7193ahd_resume(struct ahd_softc *ahd)
7089{ 7194{
@@ -7093,6 +7198,7 @@ ahd_resume(struct ahd_softc *ahd)
7093 ahd_restart(ahd); 7198 ahd_restart(ahd);
7094 return (0); 7199 return (0);
7095} 7200}
7201#endif /* 0 */
7096 7202
7097/************************** Busy Target Table *********************************/ 7203/************************** Busy Target Table *********************************/
7098/* 7204/*
@@ -7125,7 +7231,7 @@ ahd_index_busy_tcl(struct ahd_softc *ahd, u_int *saved_scbid, u_int tcl)
7125/* 7231/*
7126 * Return the untagged transaction id for a given target/channel lun. 7232 * Return the untagged transaction id for a given target/channel lun.
7127 */ 7233 */
7128u_int 7234static u_int
7129ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl) 7235ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl)
7130{ 7236{
7131 u_int scbid; 7237 u_int scbid;
@@ -7138,7 +7244,7 @@ ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl)
7138 return (scbid); 7244 return (scbid);
7139} 7245}
7140 7246
7141void 7247static void
7142ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl, u_int scbid) 7248ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl, u_int scbid)
7143{ 7249{
7144 u_int scb_offset; 7250 u_int scb_offset;
@@ -7186,7 +7292,7 @@ ahd_match_scb(struct ahd_softc *ahd, struct scb *scb, int target,
7186 return match; 7292 return match;
7187} 7293}
7188 7294
7189void 7295static void
7190ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb) 7296ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb)
7191{ 7297{
7192 int target; 7298 int target;
@@ -7690,7 +7796,7 @@ ahd_add_scb_to_free_list(struct ahd_softc *ahd, u_int scbid)
7690 * been modified from CAM_REQ_INPROG. This routine assumes that the sequencer 7796 * been modified from CAM_REQ_INPROG. This routine assumes that the sequencer
7691 * is paused before it is called. 7797 * is paused before it is called.
7692 */ 7798 */
7693int 7799static int
7694ahd_abort_scbs(struct ahd_softc *ahd, int target, char channel, 7800ahd_abort_scbs(struct ahd_softc *ahd, int target, char channel,
7695 int lun, u_int tag, role_t role, uint32_t status) 7801 int lun, u_int tag, role_t role, uint32_t status)
7696{ 7802{
@@ -7920,6 +8026,11 @@ ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
7920 ahd_clear_fifo(ahd, 1); 8026 ahd_clear_fifo(ahd, 1);
7921 8027
7922 /* 8028 /*
8029 * Clear SCSI interrupt status
8030 */
8031 ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI);
8032
8033 /*
7923 * Reenable selections 8034 * Reenable selections
7924 */ 8035 */
7925 ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) | ENSCSIRST); 8036 ahd_outb(ahd, SIMODE1, ahd_inb(ahd, SIMODE1) | ENSCSIRST);
@@ -7952,10 +8063,6 @@ ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
7952 } 8063 }
7953 } 8064 }
7954#endif 8065#endif
7955 /* Notify the XPT that a bus reset occurred */
7956 ahd_send_async(ahd, devinfo.channel, CAM_TARGET_WILDCARD,
7957 CAM_LUN_WILDCARD, AC_BUS_RESET);
7958
7959 /* 8066 /*
7960 * Revert to async/narrow transfers until we renegotiate. 8067 * Revert to async/narrow transfers until we renegotiate.
7961 */ 8068 */
@@ -7977,6 +8084,10 @@ ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
7977 } 8084 }
7978 } 8085 }
7979 8086
8087 /* Notify the XPT that a bus reset occurred */
8088 ahd_send_async(ahd, devinfo.channel, CAM_TARGET_WILDCARD,
8089 CAM_LUN_WILDCARD, AC_BUS_RESET);
8090
7980 ahd_restart(ahd); 8091 ahd_restart(ahd);
7981 8092
7982 return (found); 8093 return (found);
@@ -8019,18 +8130,8 @@ ahd_stat_timer(void *arg)
8019} 8130}
8020 8131
8021/****************************** Status Processing *****************************/ 8132/****************************** Status Processing *****************************/
8022void
8023ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb)
8024{
8025 if (scb->hscb->shared_data.istatus.scsi_status != 0) {
8026 ahd_handle_scsi_status(ahd, scb);
8027 } else {
8028 ahd_calc_residual(ahd, scb);
8029 ahd_done(ahd, scb);
8030 }
8031}
8032 8133
8033void 8134static void
8034ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb) 8135ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
8035{ 8136{
8036 struct hardware_scb *hscb; 8137 struct hardware_scb *hscb;
@@ -8238,10 +8339,21 @@ ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
8238 } 8339 }
8239} 8340}
8240 8341
8342static void
8343ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb)
8344{
8345 if (scb->hscb->shared_data.istatus.scsi_status != 0) {
8346 ahd_handle_scsi_status(ahd, scb);
8347 } else {
8348 ahd_calc_residual(ahd, scb);
8349 ahd_done(ahd, scb);
8350 }
8351}
8352
8241/* 8353/*
8242 * Calculate the residual for a just completed SCB. 8354 * Calculate the residual for a just completed SCB.
8243 */ 8355 */
8244void 8356static void
8245ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb) 8357ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb)
8246{ 8358{
8247 struct hardware_scb *hscb; 8359 struct hardware_scb *hscb;
@@ -8668,7 +8780,7 @@ ahd_resolve_seqaddr(struct ahd_softc *ahd, u_int address)
8668 if (skip_addr > i) { 8780 if (skip_addr > i) {
8669 int end_addr; 8781 int end_addr;
8670 8782
8671 end_addr = MIN(address, skip_addr); 8783 end_addr = min(address, skip_addr);
8672 address_offset += end_addr - i; 8784 address_offset += end_addr - i;
8673 i = skip_addr; 8785 i = skip_addr;
8674 } else { 8786 } else {
@@ -9092,6 +9204,7 @@ ahd_dump_card_state(struct ahd_softc *ahd)
9092 ahd_unpause(ahd); 9204 ahd_unpause(ahd);
9093} 9205}
9094 9206
9207#if 0
9095void 9208void
9096ahd_dump_scbs(struct ahd_softc *ahd) 9209ahd_dump_scbs(struct ahd_softc *ahd)
9097{ 9210{
@@ -9117,6 +9230,7 @@ ahd_dump_scbs(struct ahd_softc *ahd)
9117 ahd_set_scbptr(ahd, saved_scb_index); 9230 ahd_set_scbptr(ahd, saved_scb_index);
9118 ahd_restore_modes(ahd, saved_modes); 9231 ahd_restore_modes(ahd, saved_modes);
9119} 9232}
9233#endif /* 0 */
9120 9234
9121/**************************** Flexport Logic **********************************/ 9235/**************************** Flexport Logic **********************************/
9122/* 9236/*
@@ -9219,7 +9333,7 @@ ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf,
9219/* 9333/*
9220 * Wait ~100us for the serial eeprom to satisfy our request. 9334 * Wait ~100us for the serial eeprom to satisfy our request.
9221 */ 9335 */
9222int 9336static int
9223ahd_wait_seeprom(struct ahd_softc *ahd) 9337ahd_wait_seeprom(struct ahd_softc *ahd)
9224{ 9338{
9225 int cnt; 9339 int cnt;
@@ -9237,7 +9351,7 @@ ahd_wait_seeprom(struct ahd_softc *ahd)
9237 * Validate the two checksums in the per_channel 9351 * Validate the two checksums in the per_channel
9238 * vital product data struct. 9352 * vital product data struct.
9239 */ 9353 */
9240int 9354static int
9241ahd_verify_vpd_cksum(struct vpd_config *vpd) 9355ahd_verify_vpd_cksum(struct vpd_config *vpd)
9242{ 9356{
9243 int i; 9357 int i;
@@ -9316,6 +9430,24 @@ ahd_release_seeprom(struct ahd_softc *ahd)
9316 /* Currently a no-op */ 9430 /* Currently a no-op */
9317} 9431}
9318 9432
9433/*
9434 * Wait at most 2 seconds for flexport arbitration to succeed.
9435 */
9436static int
9437ahd_wait_flexport(struct ahd_softc *ahd)
9438{
9439 int cnt;
9440
9441 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
9442 cnt = 1000000 * 2 / 5;
9443 while ((ahd_inb(ahd, BRDCTL) & FLXARBACK) == 0 && --cnt)
9444 ahd_delay(5);
9445
9446 if (cnt == 0)
9447 return (ETIMEDOUT);
9448 return (0);
9449}
9450
9319int 9451int
9320ahd_write_flexport(struct ahd_softc *ahd, u_int addr, u_int value) 9452ahd_write_flexport(struct ahd_softc *ahd, u_int addr, u_int value)
9321{ 9453{
@@ -9357,24 +9489,6 @@ ahd_read_flexport(struct ahd_softc *ahd, u_int addr, uint8_t *value)
9357 return (0); 9489 return (0);
9358} 9490}
9359 9491
9360/*
9361 * Wait at most 2 seconds for flexport arbitration to succeed.
9362 */
9363int
9364ahd_wait_flexport(struct ahd_softc *ahd)
9365{
9366 int cnt;
9367
9368 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
9369 cnt = 1000000 * 2 / 5;
9370 while ((ahd_inb(ahd, BRDCTL) & FLXARBACK) == 0 && --cnt)
9371 ahd_delay(5);
9372
9373 if (cnt == 0)
9374 return (ETIMEDOUT);
9375 return (0);
9376}
9377
9378/************************* Target Mode ****************************************/ 9492/************************* Target Mode ****************************************/
9379#ifdef AHD_TARGET_MODE 9493#ifdef AHD_TARGET_MODE
9380cam_status 9494cam_status
diff --git a/drivers/scsi/aic7xxx/aic79xx_inline.h b/drivers/scsi/aic7xxx/aic79xx_inline.h
index a3266e066c00..2ceb67f4af2a 100644
--- a/drivers/scsi/aic7xxx/aic79xx_inline.h
+++ b/drivers/scsi/aic7xxx/aic79xx_inline.h
@@ -418,10 +418,6 @@ ahd_targetcmd_offset(struct ahd_softc *ahd, u_int index)
418} 418}
419 419
420/*********************** Miscelaneous Support Functions ***********************/ 420/*********************** Miscelaneous Support Functions ***********************/
421static __inline void ahd_complete_scb(struct ahd_softc *ahd,
422 struct scb *scb);
423static __inline void ahd_update_residual(struct ahd_softc *ahd,
424 struct scb *scb);
425static __inline struct ahd_initiator_tinfo * 421static __inline struct ahd_initiator_tinfo *
426 ahd_fetch_transinfo(struct ahd_softc *ahd, 422 ahd_fetch_transinfo(struct ahd_softc *ahd,
427 char channel, u_int our_id, 423 char channel, u_int our_id,
@@ -467,32 +463,6 @@ static __inline uint32_t
467 ahd_get_sense_bufaddr(struct ahd_softc *ahd, 463 ahd_get_sense_bufaddr(struct ahd_softc *ahd,
468 struct scb *scb); 464 struct scb *scb);
469 465
470static __inline void
471ahd_complete_scb(struct ahd_softc *ahd, struct scb *scb)
472{
473 uint32_t sgptr;
474
475 sgptr = ahd_le32toh(scb->hscb->sgptr);
476 if ((sgptr & SG_STATUS_VALID) != 0)
477 ahd_handle_scb_status(ahd, scb);
478 else
479 ahd_done(ahd, scb);
480}
481
482/*
483 * Determine whether the sequencer reported a residual
484 * for this SCB/transaction.
485 */
486static __inline void
487ahd_update_residual(struct ahd_softc *ahd, struct scb *scb)
488{
489 uint32_t sgptr;
490
491 sgptr = ahd_le32toh(scb->hscb->sgptr);
492 if ((sgptr & SG_STATUS_VALID) != 0)
493 ahd_calc_residual(ahd, scb);
494}
495
496/* 466/*
497 * Return pointers to the transfer negotiation information 467 * Return pointers to the transfer negotiation information
498 * for the specified our_id/remote_id pair. 468 * for the specified our_id/remote_id pair.
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index f8e60486167d..9bfcca5ede08 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -293,7 +293,7 @@ static uint32_t aic79xx_seltime;
293 * force all outstanding transactions to be serviced prior to a new 293 * force all outstanding transactions to be serviced prior to a new
294 * transaction. 294 * transaction.
295 */ 295 */
296uint32_t aic79xx_periodic_otag; 296static uint32_t aic79xx_periodic_otag;
297 297
298/* Some storage boxes are using an LSI chip which has a bug making it 298/* Some storage boxes are using an LSI chip which has a bug making it
299 * impossible to use aic79xx Rev B chip in 320 speeds. The following 299 * impossible to use aic79xx Rev B chip in 320 speeds. The following
@@ -773,6 +773,7 @@ struct scsi_host_template aic79xx_driver_template = {
773#endif 773#endif
774 .can_queue = AHD_MAX_QUEUE, 774 .can_queue = AHD_MAX_QUEUE,
775 .this_id = -1, 775 .this_id = -1,
776 .max_sectors = 8192,
776 .cmd_per_lun = 2, 777 .cmd_per_lun = 2,
777 .use_clustering = ENABLE_CLUSTERING, 778 .use_clustering = ENABLE_CLUSTERING,
778 .slave_alloc = ahd_linux_slave_alloc, 779 .slave_alloc = ahd_linux_slave_alloc,
@@ -1813,9 +1814,9 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd,
1813 u_int sense_offset; 1814 u_int sense_offset;
1814 1815
1815 if (scb->flags & SCB_SENSE) { 1816 if (scb->flags & SCB_SENSE) {
1816 sense_size = MIN(sizeof(struct scsi_sense_data) 1817 sense_size = min(sizeof(struct scsi_sense_data)
1817 - ahd_get_sense_residual(scb), 1818 - ahd_get_sense_residual(scb),
1818 sizeof(cmd->sense_buffer)); 1819 (u_long)sizeof(cmd->sense_buffer));
1819 sense_offset = 0; 1820 sense_offset = 0;
1820 } else { 1821 } else {
1821 /* 1822 /*
@@ -1824,7 +1825,8 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd,
1824 */ 1825 */
1825 siu = (struct scsi_status_iu_header *) 1826 siu = (struct scsi_status_iu_header *)
1826 scb->sense_data; 1827 scb->sense_data;
1827 sense_size = MIN(scsi_4btoul(siu->sense_length), 1828 sense_size = min_t(size_t,
1829 scsi_4btoul(siu->sense_length),
1828 sizeof(cmd->sense_buffer)); 1830 sizeof(cmd->sense_buffer));
1829 sense_offset = SIU_SENSE_OFFSET(siu); 1831 sense_offset = SIU_SENSE_OFFSET(siu);
1830 } 1832 }
@@ -2634,8 +2636,22 @@ static void ahd_linux_set_pcomp_en(struct scsi_target *starget, int pcomp)
2634 pcomp ? "Enable" : "Disable"); 2636 pcomp ? "Enable" : "Disable");
2635#endif 2637#endif
2636 2638
2637 if (pcomp) 2639 if (pcomp) {
2640 uint8_t precomp;
2641
2642 if (ahd->unit < ARRAY_SIZE(aic79xx_iocell_info)) {
2643 struct ahd_linux_iocell_opts *iocell_opts;
2644
2645 iocell_opts = &aic79xx_iocell_info[ahd->unit];
2646 precomp = iocell_opts->precomp;
2647 } else {
2648 precomp = AIC79XX_DEFAULT_PRECOMP;
2649 }
2638 ppr_options |= MSG_EXT_PPR_PCOMP_EN; 2650 ppr_options |= MSG_EXT_PPR_PCOMP_EN;
2651 AHD_SET_PRECOMP(ahd, precomp);
2652 } else {
2653 AHD_SET_PRECOMP(ahd, 0);
2654 }
2639 2655
2640 ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2656 ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0,
2641 starget->channel + 'A', ROLE_INITIATOR); 2657 starget->channel + 'A', ROLE_INITIATOR);
@@ -2678,7 +2694,25 @@ static void ahd_linux_set_hold_mcs(struct scsi_target *starget, int hold)
2678 ahd_unlock(ahd, &flags); 2694 ahd_unlock(ahd, &flags);
2679} 2695}
2680 2696
2697static void ahd_linux_get_signalling(struct Scsi_Host *shost)
2698{
2699 struct ahd_softc *ahd = *(struct ahd_softc **)shost->hostdata;
2700 unsigned long flags;
2701 u8 mode;
2702
2703 ahd_lock(ahd, &flags);
2704 ahd_pause(ahd);
2705 mode = ahd_inb(ahd, SBLKCTL);
2706 ahd_unpause(ahd);
2707 ahd_unlock(ahd, &flags);
2681 2708
2709 if (mode & ENAB40)
2710 spi_signalling(shost) = SPI_SIGNAL_LVD;
2711 else if (mode & ENAB20)
2712 spi_signalling(shost) = SPI_SIGNAL_SE;
2713 else
2714 spi_signalling(shost) = SPI_SIGNAL_UNKNOWN;
2715}
2682 2716
2683static struct spi_function_template ahd_linux_transport_functions = { 2717static struct spi_function_template ahd_linux_transport_functions = {
2684 .set_offset = ahd_linux_set_offset, 2718 .set_offset = ahd_linux_set_offset,
@@ -2703,6 +2737,7 @@ static struct spi_function_template ahd_linux_transport_functions = {
2703 .show_pcomp_en = 1, 2737 .show_pcomp_en = 1,
2704 .set_hold_mcs = ahd_linux_set_hold_mcs, 2738 .set_hold_mcs = ahd_linux_set_hold_mcs,
2705 .show_hold_mcs = 1, 2739 .show_hold_mcs = 1,
2740 .get_signalling = ahd_linux_get_signalling,
2706}; 2741};
2707 2742
2708static int __init 2743static int __init
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.h b/drivers/scsi/aic7xxx/aic79xx_osm.h
index fb3d4dd54413..3a67fc578d78 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.h
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.h
@@ -506,9 +506,6 @@ struct info_str {
506 int pos; 506 int pos;
507}; 507};
508 508
509void ahd_format_transinfo(struct info_str *info,
510 struct ahd_transinfo *tinfo);
511
512/******************************** Locking *************************************/ 509/******************************** Locking *************************************/
513static __inline void 510static __inline void
514ahd_lockinit(struct ahd_softc *ahd) 511ahd_lockinit(struct ahd_softc *ahd)
@@ -582,8 +579,6 @@ ahd_unlock(struct ahd_softc *ahd, unsigned long *flags)
582#define PCIXM_STATUS_MAXCRDS 0x1C00 /* Maximum Cumulative Read Size */ 579#define PCIXM_STATUS_MAXCRDS 0x1C00 /* Maximum Cumulative Read Size */
583#define PCIXM_STATUS_RCVDSCEM 0x2000 /* Received a Split Comp w/Error msg */ 580#define PCIXM_STATUS_RCVDSCEM 0x2000 /* Received a Split Comp w/Error msg */
584 581
585extern struct pci_driver aic79xx_pci_driver;
586
587typedef enum 582typedef enum
588{ 583{
589 AHD_POWER_STATE_D0, 584 AHD_POWER_STATE_D0,
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
index 4b5354201807..2001fe890e71 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
@@ -82,7 +82,7 @@ static struct pci_device_id ahd_linux_pci_id_table[] = {
82 82
83MODULE_DEVICE_TABLE(pci, ahd_linux_pci_id_table); 83MODULE_DEVICE_TABLE(pci, ahd_linux_pci_id_table);
84 84
85struct pci_driver aic79xx_pci_driver = { 85static struct pci_driver aic79xx_pci_driver = {
86 .name = "aic79xx", 86 .name = "aic79xx",
87 .probe = ahd_linux_pci_dev_probe, 87 .probe = ahd_linux_pci_dev_probe,
88 .remove = ahd_linux_pci_dev_remove, 88 .remove = ahd_linux_pci_dev_remove,
diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
index 14850f31aafa..c07735819cd1 100644
--- a/drivers/scsi/aic7xxx/aic79xx_pci.c
+++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
@@ -97,7 +97,7 @@ static ahd_device_setup_t ahd_aic7901A_setup;
97static ahd_device_setup_t ahd_aic7902_setup; 97static ahd_device_setup_t ahd_aic7902_setup;
98static ahd_device_setup_t ahd_aic790X_setup; 98static ahd_device_setup_t ahd_aic790X_setup;
99 99
100struct ahd_pci_identity ahd_pci_ident_table [] = 100static struct ahd_pci_identity ahd_pci_ident_table [] =
101{ 101{
102 /* aic7901 based controllers */ 102 /* aic7901 based controllers */
103 { 103 {
@@ -201,7 +201,7 @@ struct ahd_pci_identity ahd_pci_ident_table [] =
201 } 201 }
202}; 202};
203 203
204const u_int ahd_num_pci_devs = ARRAY_SIZE(ahd_pci_ident_table); 204static const u_int ahd_num_pci_devs = ARRAY_SIZE(ahd_pci_ident_table);
205 205
206#define DEVCONFIG 0x40 206#define DEVCONFIG 0x40
207#define PCIXINITPAT 0x0000E000ul 207#define PCIXINITPAT 0x0000E000ul
@@ -245,6 +245,7 @@ static int ahd_check_extport(struct ahd_softc *ahd);
245static void ahd_configure_termination(struct ahd_softc *ahd, 245static void ahd_configure_termination(struct ahd_softc *ahd,
246 u_int adapter_control); 246 u_int adapter_control);
247static void ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat); 247static void ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat);
248static void ahd_pci_intr(struct ahd_softc *ahd);
248 249
249struct ahd_pci_identity * 250struct ahd_pci_identity *
250ahd_find_pci_device(ahd_dev_softc_t pci) 251ahd_find_pci_device(ahd_dev_softc_t pci)
@@ -757,7 +758,7 @@ static const char *pci_status_strings[] =
757 "%s: Address or Write Phase Parity Error Detected in %s.\n" 758 "%s: Address or Write Phase Parity Error Detected in %s.\n"
758}; 759};
759 760
760void 761static void
761ahd_pci_intr(struct ahd_softc *ahd) 762ahd_pci_intr(struct ahd_softc *ahd)
762{ 763{
763 uint8_t pci_status[8]; 764 uint8_t pci_status[8];
diff --git a/drivers/scsi/aic7xxx/aic79xx_proc.c b/drivers/scsi/aic7xxx/aic79xx_proc.c
index c5f0ee591509..6b28bebcbca0 100644
--- a/drivers/scsi/aic7xxx/aic79xx_proc.c
+++ b/drivers/scsi/aic7xxx/aic79xx_proc.c
@@ -136,7 +136,7 @@ copy_info(struct info_str *info, char *fmt, ...)
136 return (len); 136 return (len);
137} 137}
138 138
139void 139static void
140ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo) 140ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo)
141{ 141{
142 u_int speed; 142 u_int speed;
diff --git a/drivers/scsi/aic7xxx/aic7xxx.h b/drivers/scsi/aic7xxx/aic7xxx.h
index 62ff8c3dc2bb..954c7c24501d 100644
--- a/drivers/scsi/aic7xxx/aic7xxx.h
+++ b/drivers/scsi/aic7xxx/aic7xxx.h
@@ -54,14 +54,6 @@ struct scb_platform_data;
54struct seeprom_descriptor; 54struct seeprom_descriptor;
55 55
56/****************************** Useful Macros *********************************/ 56/****************************** Useful Macros *********************************/
57#ifndef MAX
58#define MAX(a,b) (((a) > (b)) ? (a) : (b))
59#endif
60
61#ifndef MIN
62#define MIN(a,b) (((a) < (b)) ? (a) : (b))
63#endif
64
65#ifndef TRUE 57#ifndef TRUE
66#define TRUE 1 58#define TRUE 1
67#endif 59#endif
@@ -1135,8 +1127,6 @@ struct ahc_pci_identity {
1135 char *name; 1127 char *name;
1136 ahc_device_setup_t *setup; 1128 ahc_device_setup_t *setup;
1137}; 1129};
1138extern struct ahc_pci_identity ahc_pci_ident_table[];
1139extern const u_int ahc_num_pci_devs;
1140 1130
1141/***************************** VL/EISA Declarations ***************************/ 1131/***************************** VL/EISA Declarations ***************************/
1142struct aic7770_identity { 1132struct aic7770_identity {
@@ -1289,6 +1279,7 @@ typedef enum {
1289} ahc_queue_alg; 1279} ahc_queue_alg;
1290 1280
1291void ahc_set_tags(struct ahc_softc *ahc, 1281void ahc_set_tags(struct ahc_softc *ahc,
1282 struct scsi_cmnd *cmd,
1292 struct ahc_devinfo *devinfo, 1283 struct ahc_devinfo *devinfo,
1293 ahc_queue_alg alg); 1284 ahc_queue_alg alg);
1294 1285
diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
index 93e4e40944b6..50ef785224de 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -1671,7 +1671,7 @@ ahc_devlimited_syncrate(struct ahc_softc *ahc,
1671 transinfo = &tinfo->goal; 1671 transinfo = &tinfo->goal;
1672 *ppr_options &= transinfo->ppr_options; 1672 *ppr_options &= transinfo->ppr_options;
1673 if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) { 1673 if (transinfo->width == MSG_EXT_WDTR_BUS_8_BIT) {
1674 maxsync = MAX(maxsync, AHC_SYNCRATE_ULTRA2); 1674 maxsync = max(maxsync, (u_int)AHC_SYNCRATE_ULTRA2);
1675 *ppr_options &= ~MSG_EXT_PPR_DT_REQ; 1675 *ppr_options &= ~MSG_EXT_PPR_DT_REQ;
1676 } 1676 }
1677 if (transinfo->period == 0) { 1677 if (transinfo->period == 0) {
@@ -1679,7 +1679,7 @@ ahc_devlimited_syncrate(struct ahc_softc *ahc,
1679 *ppr_options = 0; 1679 *ppr_options = 0;
1680 return (NULL); 1680 return (NULL);
1681 } 1681 }
1682 *period = MAX(*period, transinfo->period); 1682 *period = max(*period, (u_int)transinfo->period);
1683 return (ahc_find_syncrate(ahc, period, ppr_options, maxsync)); 1683 return (ahc_find_syncrate(ahc, period, ppr_options, maxsync));
1684} 1684}
1685 1685
@@ -1804,12 +1804,12 @@ ahc_validate_offset(struct ahc_softc *ahc,
1804 else 1804 else
1805 maxoffset = MAX_OFFSET_8BIT; 1805 maxoffset = MAX_OFFSET_8BIT;
1806 } 1806 }
1807 *offset = MIN(*offset, maxoffset); 1807 *offset = min(*offset, maxoffset);
1808 if (tinfo != NULL) { 1808 if (tinfo != NULL) {
1809 if (role == ROLE_TARGET) 1809 if (role == ROLE_TARGET)
1810 *offset = MIN(*offset, tinfo->user.offset); 1810 *offset = min(*offset, (u_int)tinfo->user.offset);
1811 else 1811 else
1812 *offset = MIN(*offset, tinfo->goal.offset); 1812 *offset = min(*offset, (u_int)tinfo->goal.offset);
1813 } 1813 }
1814} 1814}
1815 1815
@@ -1835,9 +1835,9 @@ ahc_validate_width(struct ahc_softc *ahc, struct ahc_initiator_tinfo *tinfo,
1835 } 1835 }
1836 if (tinfo != NULL) { 1836 if (tinfo != NULL) {
1837 if (role == ROLE_TARGET) 1837 if (role == ROLE_TARGET)
1838 *bus_width = MIN(tinfo->user.width, *bus_width); 1838 *bus_width = min((u_int)tinfo->user.width, *bus_width);
1839 else 1839 else
1840 *bus_width = MIN(tinfo->goal.width, *bus_width); 1840 *bus_width = min((u_int)tinfo->goal.width, *bus_width);
1841 } 1841 }
1842} 1842}
1843 1843
@@ -1986,7 +1986,7 @@ ahc_set_syncrate(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
1986 tinfo->curr.ppr_options = ppr_options; 1986 tinfo->curr.ppr_options = ppr_options;
1987 1987
1988 ahc_send_async(ahc, devinfo->channel, devinfo->target, 1988 ahc_send_async(ahc, devinfo->channel, devinfo->target,
1989 CAM_LUN_WILDCARD, AC_TRANSFER_NEG, NULL); 1989 CAM_LUN_WILDCARD, AC_TRANSFER_NEG);
1990 if (bootverbose) { 1990 if (bootverbose) {
1991 if (offset != 0) { 1991 if (offset != 0) {
1992 printf("%s: target %d synchronous at %sMHz%s, " 1992 printf("%s: target %d synchronous at %sMHz%s, "
@@ -2056,7 +2056,7 @@ ahc_set_width(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
2056 tinfo->curr.width = width; 2056 tinfo->curr.width = width;
2057 2057
2058 ahc_send_async(ahc, devinfo->channel, devinfo->target, 2058 ahc_send_async(ahc, devinfo->channel, devinfo->target,
2059 CAM_LUN_WILDCARD, AC_TRANSFER_NEG, NULL); 2059 CAM_LUN_WILDCARD, AC_TRANSFER_NEG);
2060 if (bootverbose) { 2060 if (bootverbose) {
2061 printf("%s: target %d using %dbit transfers\n", 2061 printf("%s: target %d using %dbit transfers\n",
2062 ahc_name(ahc), devinfo->target, 2062 ahc_name(ahc), devinfo->target,
@@ -2074,12 +2074,14 @@ ahc_set_width(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
2074 * Update the current state of tagged queuing for a given target. 2074 * Update the current state of tagged queuing for a given target.
2075 */ 2075 */
2076void 2076void
2077ahc_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, 2077ahc_set_tags(struct ahc_softc *ahc, struct scsi_cmnd *cmd,
2078 ahc_queue_alg alg) 2078 struct ahc_devinfo *devinfo, ahc_queue_alg alg)
2079{ 2079{
2080 ahc_platform_set_tags(ahc, devinfo, alg); 2080 struct scsi_device *sdev = cmd->device;
2081
2082 ahc_platform_set_tags(ahc, sdev, devinfo, alg);
2081 ahc_send_async(ahc, devinfo->channel, devinfo->target, 2083 ahc_send_async(ahc, devinfo->channel, devinfo->target,
2082 devinfo->lun, AC_TRANSFER_NEG, &alg); 2084 devinfo->lun, AC_TRANSFER_NEG);
2083} 2085}
2084 2086
2085/* 2087/*
@@ -3489,7 +3491,7 @@ ahc_handle_msg_reject(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
3489 printf("(%s:%c:%d:%d): refuses tagged commands. " 3491 printf("(%s:%c:%d:%d): refuses tagged commands. "
3490 "Performing non-tagged I/O\n", ahc_name(ahc), 3492 "Performing non-tagged I/O\n", ahc_name(ahc),
3491 devinfo->channel, devinfo->target, devinfo->lun); 3493 devinfo->channel, devinfo->target, devinfo->lun);
3492 ahc_set_tags(ahc, devinfo, AHC_QUEUE_NONE); 3494 ahc_set_tags(ahc, scb->io_ctx, devinfo, AHC_QUEUE_NONE);
3493 mask = ~0x23; 3495 mask = ~0x23;
3494 } else { 3496 } else {
3495 printf("(%s:%c:%d:%d): refuses %s tagged commands. " 3497 printf("(%s:%c:%d:%d): refuses %s tagged commands. "
@@ -3497,7 +3499,7 @@ ahc_handle_msg_reject(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
3497 ahc_name(ahc), devinfo->channel, devinfo->target, 3499 ahc_name(ahc), devinfo->channel, devinfo->target,
3498 devinfo->lun, tag_type == MSG_ORDERED_TASK 3500 devinfo->lun, tag_type == MSG_ORDERED_TASK
3499 ? "ordered" : "head of queue"); 3501 ? "ordered" : "head of queue");
3500 ahc_set_tags(ahc, devinfo, AHC_QUEUE_BASIC); 3502 ahc_set_tags(ahc, scb->io_ctx, devinfo, AHC_QUEUE_BASIC);
3501 mask = ~0x03; 3503 mask = ~0x03;
3502 } 3504 }
3503 3505
@@ -3763,7 +3765,7 @@ ahc_handle_devreset(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
3763 3765
3764 if (status != CAM_SEL_TIMEOUT) 3766 if (status != CAM_SEL_TIMEOUT)
3765 ahc_send_async(ahc, devinfo->channel, devinfo->target, 3767 ahc_send_async(ahc, devinfo->channel, devinfo->target,
3766 CAM_LUN_WILDCARD, AC_SENT_BDR, NULL); 3768 CAM_LUN_WILDCARD, AC_SENT_BDR);
3767 3769
3768 if (message != NULL 3770 if (message != NULL
3769 && (verbose_level <= bootverbose)) 3771 && (verbose_level <= bootverbose))
@@ -4406,7 +4408,7 @@ ahc_alloc_scbs(struct ahc_softc *ahc)
4406 physaddr = sg_map->sg_physaddr; 4408 physaddr = sg_map->sg_physaddr;
4407 4409
4408 newcount = (PAGE_SIZE / (AHC_NSEG * sizeof(struct ahc_dma_seg))); 4410 newcount = (PAGE_SIZE / (AHC_NSEG * sizeof(struct ahc_dma_seg)));
4409 newcount = MIN(newcount, (AHC_SCB_MAX_ALLOC - scb_data->numscbs)); 4411 newcount = min(newcount, (AHC_SCB_MAX_ALLOC - scb_data->numscbs));
4410 for (i = 0; i < newcount; i++) { 4412 for (i = 0; i < newcount; i++) {
4411 struct scb_platform_data *pdata; 4413 struct scb_platform_data *pdata;
4412#ifndef __linux__ 4414#ifndef __linux__
@@ -6018,7 +6020,7 @@ ahc_reset_channel(struct ahc_softc *ahc, char channel, int initiate_reset)
6018#endif 6020#endif
6019 /* Notify the XPT that a bus reset occurred */ 6021 /* Notify the XPT that a bus reset occurred */
6020 ahc_send_async(ahc, devinfo.channel, CAM_TARGET_WILDCARD, 6022 ahc_send_async(ahc, devinfo.channel, CAM_TARGET_WILDCARD,
6021 CAM_LUN_WILDCARD, AC_BUS_RESET, NULL); 6023 CAM_LUN_WILDCARD, AC_BUS_RESET);
6022 6024
6023 /* 6025 /*
6024 * Revert to async/narrow transfers until we renegotiate. 6026 * Revert to async/narrow transfers until we renegotiate.
@@ -6442,7 +6444,7 @@ ahc_download_instr(struct ahc_softc *ahc, u_int instrptr, uint8_t *dconsts)
6442 if (skip_addr > i) { 6444 if (skip_addr > i) {
6443 int end_addr; 6445 int end_addr;
6444 6446
6445 end_addr = MIN(address, skip_addr); 6447 end_addr = min(address, skip_addr);
6446 address_offset += end_addr - i; 6448 address_offset += end_addr - i;
6447 i = skip_addr; 6449 i = skip_addr;
6448 } else { 6450 } else {
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index 43ab753d2739..660f26e23a38 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -328,7 +328,7 @@ static uint32_t aic7xxx_seltime;
328 * force all outstanding transactions to be serviced prior to a new 328 * force all outstanding transactions to be serviced prior to a new
329 * transaction. 329 * transaction.
330 */ 330 */
331uint32_t aic7xxx_periodic_otag; 331static uint32_t aic7xxx_periodic_otag;
332 332
333/* 333/*
334 * Module information and settable options. 334 * Module information and settable options.
@@ -512,7 +512,6 @@ ahc_linux_target_alloc(struct scsi_target *starget)
512 struct seeprom_config *sc = ahc->seep_config; 512 struct seeprom_config *sc = ahc->seep_config;
513 unsigned long flags; 513 unsigned long flags;
514 struct scsi_target **ahc_targp = ahc_linux_target_in_softc(starget); 514 struct scsi_target **ahc_targp = ahc_linux_target_in_softc(starget);
515 struct ahc_linux_target *targ = scsi_transport_target_data(starget);
516 unsigned short scsirate; 515 unsigned short scsirate;
517 struct ahc_devinfo devinfo; 516 struct ahc_devinfo devinfo;
518 struct ahc_initiator_tinfo *tinfo; 517 struct ahc_initiator_tinfo *tinfo;
@@ -533,7 +532,6 @@ ahc_linux_target_alloc(struct scsi_target *starget)
533 BUG_ON(*ahc_targp != NULL); 532 BUG_ON(*ahc_targp != NULL);
534 533
535 *ahc_targp = starget; 534 *ahc_targp = starget;
536 memset(targ, 0, sizeof(*targ));
537 535
538 if (sc) { 536 if (sc) {
539 int maxsync = AHC_SYNCRATE_DT; 537 int maxsync = AHC_SYNCRATE_DT;
@@ -594,14 +592,11 @@ ahc_linux_slave_alloc(struct scsi_device *sdev)
594 struct ahc_softc *ahc = 592 struct ahc_softc *ahc =
595 *((struct ahc_softc **)sdev->host->hostdata); 593 *((struct ahc_softc **)sdev->host->hostdata);
596 struct scsi_target *starget = sdev->sdev_target; 594 struct scsi_target *starget = sdev->sdev_target;
597 struct ahc_linux_target *targ = scsi_transport_target_data(starget);
598 struct ahc_linux_device *dev; 595 struct ahc_linux_device *dev;
599 596
600 if (bootverbose) 597 if (bootverbose)
601 printf("%s: Slave Alloc %d\n", ahc_name(ahc), sdev->id); 598 printf("%s: Slave Alloc %d\n", ahc_name(ahc), sdev->id);
602 599
603 BUG_ON(targ->sdev[sdev->lun] != NULL);
604
605 dev = scsi_transport_device_data(sdev); 600 dev = scsi_transport_device_data(sdev);
606 memset(dev, 0, sizeof(*dev)); 601 memset(dev, 0, sizeof(*dev));
607 602
@@ -618,8 +613,6 @@ ahc_linux_slave_alloc(struct scsi_device *sdev)
618 */ 613 */
619 dev->maxtags = 0; 614 dev->maxtags = 0;
620 615
621 targ->sdev[sdev->lun] = sdev;
622
623 spi_period(starget) = 0; 616 spi_period(starget) = 0;
624 617
625 return 0; 618 return 0;
@@ -644,22 +637,6 @@ ahc_linux_slave_configure(struct scsi_device *sdev)
644 return 0; 637 return 0;
645} 638}
646 639
647static void
648ahc_linux_slave_destroy(struct scsi_device *sdev)
649{
650 struct ahc_softc *ahc;
651 struct ahc_linux_device *dev = scsi_transport_device_data(sdev);
652 struct ahc_linux_target *targ = scsi_transport_target_data(sdev->sdev_target);
653
654 ahc = *((struct ahc_softc **)sdev->host->hostdata);
655 if (bootverbose)
656 printf("%s: Slave Destroy %d\n", ahc_name(ahc), sdev->id);
657
658 BUG_ON(dev->active);
659
660 targ->sdev[sdev->lun] = NULL;
661}
662
663#if defined(__i386__) 640#if defined(__i386__)
664/* 641/*
665 * Return the disk geometry for the given SCSI device. 642 * Return the disk geometry for the given SCSI device.
@@ -777,11 +754,11 @@ struct scsi_host_template aic7xxx_driver_template = {
777#endif 754#endif
778 .can_queue = AHC_MAX_QUEUE, 755 .can_queue = AHC_MAX_QUEUE,
779 .this_id = -1, 756 .this_id = -1,
757 .max_sectors = 8192,
780 .cmd_per_lun = 2, 758 .cmd_per_lun = 2,
781 .use_clustering = ENABLE_CLUSTERING, 759 .use_clustering = ENABLE_CLUSTERING,
782 .slave_alloc = ahc_linux_slave_alloc, 760 .slave_alloc = ahc_linux_slave_alloc,
783 .slave_configure = ahc_linux_slave_configure, 761 .slave_configure = ahc_linux_slave_configure,
784 .slave_destroy = ahc_linux_slave_destroy,
785 .target_alloc = ahc_linux_target_alloc, 762 .target_alloc = ahc_linux_target_alloc,
786 .target_destroy = ahc_linux_target_destroy, 763 .target_destroy = ahc_linux_target_destroy,
787}; 764};
@@ -1203,21 +1180,13 @@ void
1203ahc_platform_free(struct ahc_softc *ahc) 1180ahc_platform_free(struct ahc_softc *ahc)
1204{ 1181{
1205 struct scsi_target *starget; 1182 struct scsi_target *starget;
1206 int i, j; 1183 int i;
1207 1184
1208 if (ahc->platform_data != NULL) { 1185 if (ahc->platform_data != NULL) {
1209 /* destroy all of the device and target objects */ 1186 /* destroy all of the device and target objects */
1210 for (i = 0; i < AHC_NUM_TARGETS; i++) { 1187 for (i = 0; i < AHC_NUM_TARGETS; i++) {
1211 starget = ahc->platform_data->starget[i]; 1188 starget = ahc->platform_data->starget[i];
1212 if (starget != NULL) { 1189 if (starget != NULL) {
1213 for (j = 0; j < AHC_NUM_LUNS; j++) {
1214 struct ahc_linux_target *targ =
1215 scsi_transport_target_data(starget);
1216
1217 if (targ->sdev[j] == NULL)
1218 continue;
1219 targ->sdev[j] = NULL;
1220 }
1221 ahc->platform_data->starget[i] = NULL; 1190 ahc->platform_data->starget[i] = NULL;
1222 } 1191 }
1223 } 1192 }
@@ -1251,24 +1220,13 @@ ahc_platform_freeze_devq(struct ahc_softc *ahc, struct scb *scb)
1251} 1220}
1252 1221
1253void 1222void
1254ahc_platform_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, 1223ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev,
1255 ahc_queue_alg alg) 1224 struct ahc_devinfo *devinfo, ahc_queue_alg alg)
1256{ 1225{
1257 struct scsi_target *starget;
1258 struct ahc_linux_target *targ;
1259 struct ahc_linux_device *dev; 1226 struct ahc_linux_device *dev;
1260 struct scsi_device *sdev;
1261 u_int target_offset;
1262 int was_queuing; 1227 int was_queuing;
1263 int now_queuing; 1228 int now_queuing;
1264 1229
1265 target_offset = devinfo->target;
1266 if (devinfo->channel != 'A')
1267 target_offset += 8;
1268 starget = ahc->platform_data->starget[target_offset];
1269 targ = scsi_transport_target_data(starget);
1270 BUG_ON(targ == NULL);
1271 sdev = targ->sdev[devinfo->lun];
1272 if (sdev == NULL) 1230 if (sdev == NULL)
1273 return; 1231 return;
1274 dev = scsi_transport_device_data(sdev); 1232 dev = scsi_transport_device_data(sdev);
@@ -1401,11 +1359,15 @@ ahc_linux_device_queue_depth(struct scsi_device *sdev)
1401 tags = ahc_linux_user_tagdepth(ahc, &devinfo); 1359 tags = ahc_linux_user_tagdepth(ahc, &devinfo);
1402 if (tags != 0 && sdev->tagged_supported != 0) { 1360 if (tags != 0 && sdev->tagged_supported != 0) {
1403 1361
1404 ahc_set_tags(ahc, &devinfo, AHC_QUEUE_TAGGED); 1362 ahc_platform_set_tags(ahc, sdev, &devinfo, AHC_QUEUE_TAGGED);
1363 ahc_send_async(ahc, devinfo.channel, devinfo.target,
1364 devinfo.lun, AC_TRANSFER_NEG);
1405 ahc_print_devinfo(ahc, &devinfo); 1365 ahc_print_devinfo(ahc, &devinfo);
1406 printf("Tagged Queuing enabled. Depth %d\n", tags); 1366 printf("Tagged Queuing enabled. Depth %d\n", tags);
1407 } else { 1367 } else {
1408 ahc_set_tags(ahc, &devinfo, AHC_QUEUE_NONE); 1368 ahc_platform_set_tags(ahc, sdev, &devinfo, AHC_QUEUE_NONE);
1369 ahc_send_async(ahc, devinfo.channel, devinfo.target,
1370 devinfo.lun, AC_TRANSFER_NEG);
1409 } 1371 }
1410} 1372}
1411 1373
@@ -1629,7 +1591,7 @@ ahc_platform_flushwork(struct ahc_softc *ahc)
1629 1591
1630void 1592void
1631ahc_send_async(struct ahc_softc *ahc, char channel, 1593ahc_send_async(struct ahc_softc *ahc, char channel,
1632 u_int target, u_int lun, ac_code code, void *arg) 1594 u_int target, u_int lun, ac_code code)
1633{ 1595{
1634 switch (code) { 1596 switch (code) {
1635 case AC_TRANSFER_NEG: 1597 case AC_TRANSFER_NEG:
@@ -1875,9 +1837,9 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
1875 if (scb->flags & SCB_SENSE) { 1837 if (scb->flags & SCB_SENSE) {
1876 u_int sense_size; 1838 u_int sense_size;
1877 1839
1878 sense_size = MIN(sizeof(struct scsi_sense_data) 1840 sense_size = min(sizeof(struct scsi_sense_data)
1879 - ahc_get_sense_residual(scb), 1841 - ahc_get_sense_residual(scb),
1880 sizeof(cmd->sense_buffer)); 1842 (u_long)sizeof(cmd->sense_buffer));
1881 memcpy(cmd->sense_buffer, 1843 memcpy(cmd->sense_buffer,
1882 ahc_get_sense_buf(ahc, scb), sense_size); 1844 ahc_get_sense_buf(ahc, scb), sense_size);
1883 if (sense_size < sizeof(cmd->sense_buffer)) 1845 if (sense_size < sizeof(cmd->sense_buffer))
@@ -1946,7 +1908,7 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
1946 } 1908 }
1947 ahc_set_transaction_status(scb, CAM_REQUEUE_REQ); 1909 ahc_set_transaction_status(scb, CAM_REQUEUE_REQ);
1948 ahc_set_scsi_status(scb, SCSI_STATUS_OK); 1910 ahc_set_scsi_status(scb, SCSI_STATUS_OK);
1949 ahc_platform_set_tags(ahc, &devinfo, 1911 ahc_platform_set_tags(ahc, sdev, &devinfo,
1950 (dev->flags & AHC_DEV_Q_BASIC) 1912 (dev->flags & AHC_DEV_Q_BASIC)
1951 ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED); 1913 ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED);
1952 break; 1914 break;
@@ -1957,7 +1919,7 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,
1957 */ 1919 */
1958 dev->openings = 1; 1920 dev->openings = 1;
1959 ahc_set_scsi_status(scb, SCSI_STATUS_BUSY); 1921 ahc_set_scsi_status(scb, SCSI_STATUS_BUSY);
1960 ahc_platform_set_tags(ahc, &devinfo, 1922 ahc_platform_set_tags(ahc, sdev, &devinfo,
1961 (dev->flags & AHC_DEV_Q_BASIC) 1923 (dev->flags & AHC_DEV_Q_BASIC)
1962 ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED); 1924 ? AHC_QUEUE_BASIC : AHC_QUEUE_TAGGED);
1963 break; 1925 break;
@@ -2599,8 +2561,6 @@ ahc_linux_init(void)
2599 if (!ahc_linux_transport_template) 2561 if (!ahc_linux_transport_template)
2600 return -ENODEV; 2562 return -ENODEV;
2601 2563
2602 scsi_transport_reserve_target(ahc_linux_transport_template,
2603 sizeof(struct ahc_linux_target));
2604 scsi_transport_reserve_device(ahc_linux_transport_template, 2564 scsi_transport_reserve_device(ahc_linux_transport_template,
2605 sizeof(struct ahc_linux_device)); 2565 sizeof(struct ahc_linux_device));
2606 2566
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.h b/drivers/scsi/aic7xxx/aic7xxx_osm.h
index a87a4ce090df..85ae5d836fa4 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.h
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.h
@@ -256,7 +256,6 @@ typedef enum {
256 AHC_DEV_PERIODIC_OTAG = 0x40, /* Send OTAG to prevent starvation */ 256 AHC_DEV_PERIODIC_OTAG = 0x40, /* Send OTAG to prevent starvation */
257} ahc_linux_dev_flags; 257} ahc_linux_dev_flags;
258 258
259struct ahc_linux_target;
260struct ahc_linux_device { 259struct ahc_linux_device {
261 /* 260 /*
262 * The number of transactions currently 261 * The number of transactions currently
@@ -329,12 +328,6 @@ struct ahc_linux_device {
329#define AHC_OTAG_THRESH 500 328#define AHC_OTAG_THRESH 500
330}; 329};
331 330
332struct ahc_linux_target {
333 struct scsi_device *sdev[AHC_NUM_LUNS];
334 struct ahc_transinfo last_tinfo;
335 struct ahc_softc *ahc;
336};
337
338/********************* Definitions Required by the Core ***********************/ 331/********************* Definitions Required by the Core ***********************/
339/* 332/*
340 * Number of SG segments we require. So long as the S/G segments for 333 * Number of SG segments we require. So long as the S/G segments for
@@ -533,8 +526,6 @@ ahc_unlock(struct ahc_softc *ahc, unsigned long *flags)
533#define PCIR_SUBVEND_0 0x2c 526#define PCIR_SUBVEND_0 0x2c
534#define PCIR_SUBDEV_0 0x2e 527#define PCIR_SUBDEV_0 0x2e
535 528
536extern struct pci_driver aic7xxx_pci_driver;
537
538typedef enum 529typedef enum
539{ 530{
540 AHC_POWER_STATE_D0, 531 AHC_POWER_STATE_D0,
@@ -824,7 +815,7 @@ ahc_freeze_scb(struct scb *scb)
824 } 815 }
825} 816}
826 817
827void ahc_platform_set_tags(struct ahc_softc *ahc, 818void ahc_platform_set_tags(struct ahc_softc *ahc, struct scsi_device *sdev,
828 struct ahc_devinfo *devinfo, ahc_queue_alg); 819 struct ahc_devinfo *devinfo, ahc_queue_alg);
829int ahc_platform_abort_scbs(struct ahc_softc *ahc, int target, 820int ahc_platform_abort_scbs(struct ahc_softc *ahc, int target,
830 char channel, int lun, u_int tag, 821 char channel, int lun, u_int tag,
@@ -834,7 +825,7 @@ irqreturn_t
834void ahc_platform_flushwork(struct ahc_softc *ahc); 825void ahc_platform_flushwork(struct ahc_softc *ahc);
835void ahc_done(struct ahc_softc*, struct scb*); 826void ahc_done(struct ahc_softc*, struct scb*);
836void ahc_send_async(struct ahc_softc *, char channel, 827void ahc_send_async(struct ahc_softc *, char channel,
837 u_int target, u_int lun, ac_code, void *); 828 u_int target, u_int lun, ac_code);
838void ahc_print_path(struct ahc_softc *, struct scb *); 829void ahc_print_path(struct ahc_softc *, struct scb *);
839void ahc_platform_dump_card_state(struct ahc_softc *ahc); 830void ahc_platform_dump_card_state(struct ahc_softc *ahc);
840 831
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
index d20ca514e9f3..ea5687df732d 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
@@ -130,7 +130,7 @@ static struct pci_device_id ahc_linux_pci_id_table[] = {
130 130
131MODULE_DEVICE_TABLE(pci, ahc_linux_pci_id_table); 131MODULE_DEVICE_TABLE(pci, ahc_linux_pci_id_table);
132 132
133struct pci_driver aic7xxx_pci_driver = { 133static struct pci_driver aic7xxx_pci_driver = {
134 .name = "aic7xxx", 134 .name = "aic7xxx",
135 .probe = ahc_linux_pci_dev_probe, 135 .probe = ahc_linux_pci_dev_probe,
136 .remove = ahc_linux_pci_dev_remove, 136 .remove = ahc_linux_pci_dev_remove,
diff --git a/drivers/scsi/aic7xxx/aic7xxx_pci.c b/drivers/scsi/aic7xxx/aic7xxx_pci.c
index 63cab2d74552..09c8172c9e5e 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_pci.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_pci.c
@@ -168,7 +168,7 @@ static ahc_device_setup_t ahc_aha394XX_setup;
168static ahc_device_setup_t ahc_aha494XX_setup; 168static ahc_device_setup_t ahc_aha494XX_setup;
169static ahc_device_setup_t ahc_aha398XX_setup; 169static ahc_device_setup_t ahc_aha398XX_setup;
170 170
171struct ahc_pci_identity ahc_pci_ident_table [] = 171static struct ahc_pci_identity ahc_pci_ident_table [] =
172{ 172{
173 /* aic7850 based controllers */ 173 /* aic7850 based controllers */
174 { 174 {
@@ -559,7 +559,7 @@ struct ahc_pci_identity ahc_pci_ident_table [] =
559 } 559 }
560}; 560};
561 561
562const u_int ahc_num_pci_devs = ARRAY_SIZE(ahc_pci_ident_table); 562static const u_int ahc_num_pci_devs = ARRAY_SIZE(ahc_pci_ident_table);
563 563
564#define AHC_394X_SLOT_CHANNEL_A 4 564#define AHC_394X_SLOT_CHANNEL_A 4
565#define AHC_394X_SLOT_CHANNEL_B 5 565#define AHC_394X_SLOT_CHANNEL_B 5
diff --git a/drivers/scsi/aic7xxx/aic7xxx_proc.c b/drivers/scsi/aic7xxx/aic7xxx_proc.c
index 5914b4aa4a8f..99e5443e7535 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_proc.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_proc.c
@@ -182,7 +182,6 @@ ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info,
182 u_int our_id, char channel, u_int target_id, 182 u_int our_id, char channel, u_int target_id,
183 u_int target_offset) 183 u_int target_offset)
184{ 184{
185 struct ahc_linux_target *targ;
186 struct scsi_target *starget; 185 struct scsi_target *starget;
187 struct ahc_initiator_tinfo *tinfo; 186 struct ahc_initiator_tinfo *tinfo;
188 struct ahc_tmode_tstate *tstate; 187 struct ahc_tmode_tstate *tstate;
@@ -198,7 +197,6 @@ ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info,
198 starget = ahc->platform_data->starget[target_offset]; 197 starget = ahc->platform_data->starget[target_offset];
199 if (!starget) 198 if (!starget)
200 return; 199 return;
201 targ = scsi_transport_target_data(starget);
202 200
203 copy_info(info, "\tGoal: "); 201 copy_info(info, "\tGoal: ");
204 ahc_format_transinfo(info, &tinfo->goal); 202 ahc_format_transinfo(info, &tinfo->goal);
@@ -208,7 +206,7 @@ ahc_dump_target_state(struct ahc_softc *ahc, struct info_str *info,
208 for (lun = 0; lun < AHC_NUM_LUNS; lun++) { 206 for (lun = 0; lun < AHC_NUM_LUNS; lun++) {
209 struct scsi_device *sdev; 207 struct scsi_device *sdev;
210 208
211 sdev = targ->sdev[lun]; 209 sdev = scsi_device_lookup_by_target(starget, lun);
212 210
213 if (sdev == NULL) 211 if (sdev == NULL)
214 continue; 212 continue;
@@ -383,11 +381,11 @@ ahc_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
383 } 381 }
384 copy_info(&info, "\n"); 382 copy_info(&info, "\n");
385 383
386 max_targ = 15; 384 max_targ = 16;
387 if ((ahc->features & (AHC_WIDE|AHC_TWIN)) == 0) 385 if ((ahc->features & (AHC_WIDE|AHC_TWIN)) == 0)
388 max_targ = 7; 386 max_targ = 8;
389 387
390 for (i = 0; i <= max_targ; i++) { 388 for (i = 0; i < max_targ; i++) {
391 u_int our_id; 389 u_int our_id;
392 u_int target_id; 390 u_int target_id;
393 char channel; 391 char channel;
diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
index bcd7fffab907..46eed10b25d9 100644
--- a/drivers/scsi/aic7xxx_old.c
+++ b/drivers/scsi/aic7xxx_old.c
@@ -2646,7 +2646,7 @@ static void aic7xxx_done_cmds_complete(struct aic7xxx_host *p)
2646 2646
2647 while (p->completeq.head != NULL) { 2647 while (p->completeq.head != NULL) {
2648 cmd = p->completeq.head; 2648 cmd = p->completeq.head;
2649 p->completeq.head = (struct scsi_Cmnd *) cmd->host_scribble; 2649 p->completeq.head = (struct scsi_cmnd *) cmd->host_scribble;
2650 cmd->host_scribble = NULL; 2650 cmd->host_scribble = NULL;
2651 cmd->scsi_done(cmd); 2651 cmd->scsi_done(cmd);
2652 } 2652 }
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.h b/drivers/scsi/aic94xx/aic94xx_hwi.h
index 14319d1d6804..7b6aca02cf70 100644
--- a/drivers/scsi/aic94xx/aic94xx_hwi.h
+++ b/drivers/scsi/aic94xx/aic94xx_hwi.h
@@ -46,6 +46,7 @@
46#define PCI_DEVICE_ID_ADAPTEC2_RAZOR10 0x410 46#define PCI_DEVICE_ID_ADAPTEC2_RAZOR10 0x410
47#define PCI_DEVICE_ID_ADAPTEC2_RAZOR12 0x412 47#define PCI_DEVICE_ID_ADAPTEC2_RAZOR12 0x412
48#define PCI_DEVICE_ID_ADAPTEC2_RAZOR1E 0x41E 48#define PCI_DEVICE_ID_ADAPTEC2_RAZOR1E 0x41E
49#define PCI_DEVICE_ID_ADAPTEC2_RAZOR1F 0x41F
49#define PCI_DEVICE_ID_ADAPTEC2_RAZOR30 0x430 50#define PCI_DEVICE_ID_ADAPTEC2_RAZOR30 0x430
50#define PCI_DEVICE_ID_ADAPTEC2_RAZOR32 0x432 51#define PCI_DEVICE_ID_ADAPTEC2_RAZOR32 0x432
51#define PCI_DEVICE_ID_ADAPTEC2_RAZOR3E 0x43E 52#define PCI_DEVICE_ID_ADAPTEC2_RAZOR3E 0x43E
diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index 99743ca29ca1..a4cc432bbdab 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -814,6 +814,8 @@ static const struct pci_device_id aic94xx_pci_table[] __devinitdata = {
814 0, 0, 1}, 814 0, 0, 1},
815 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR1E), 815 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR1E),
816 0, 0, 1}, 816 0, 0, 1},
817 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR1F),
818 0, 0, 1},
817 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR30), 819 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR30),
818 0, 0, 2}, 820 0, 0, 2},
819 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR32), 821 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_RAZOR32),
diff --git a/drivers/scsi/aic94xx/aic94xx_sds.c b/drivers/scsi/aic94xx/aic94xx_sds.c
index 83574b5b4e69..de7c04d4254d 100644
--- a/drivers/scsi/aic94xx/aic94xx_sds.c
+++ b/drivers/scsi/aic94xx/aic94xx_sds.c
@@ -630,10 +630,6 @@ static int asd_flash_getid(struct asd_ha_struct *asd_ha)
630 630
631 reg = asd_read_reg_dword(asd_ha, EXSICNFGR); 631 reg = asd_read_reg_dword(asd_ha, EXSICNFGR);
632 632
633 if (!(reg & FLASHEX)) {
634 ASD_DPRINTK("flash doesn't exist\n");
635 return -ENOENT;
636 }
637 if (pci_read_config_dword(asd_ha->pcidev, PCI_CONF_FLSH_BAR, 633 if (pci_read_config_dword(asd_ha->pcidev, PCI_CONF_FLSH_BAR,
638 &asd_ha->hw_prof.flash.bar)) { 634 &asd_ha->hw_prof.flash.bar)) {
639 asd_printk("couldn't read PCI_CONF_FLSH_BAR of %s\n", 635 asd_printk("couldn't read PCI_CONF_FLSH_BAR of %s\n",
diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
index 65e6e7b7ba07..5d4ea6f77953 100644
--- a/drivers/scsi/fdomain.c
+++ b/drivers/scsi/fdomain.c
@@ -387,6 +387,7 @@ static void __iomem * bios_mem;
387static int bios_major; 387static int bios_major;
388static int bios_minor; 388static int bios_minor;
389static int PCI_bus; 389static int PCI_bus;
390static struct pci_dev *PCI_dev;
390static int Quantum; /* Quantum board variant */ 391static int Quantum; /* Quantum board variant */
391static int interrupt_level; 392static int interrupt_level;
392static volatile int in_command; 393static volatile int in_command;
@@ -812,9 +813,10 @@ static int fdomain_pci_bios_detect( int *irq, int *iobase, struct pci_dev **ret_
812 PCI_DEVICE_ID_FD_36C70 ); 813 PCI_DEVICE_ID_FD_36C70 );
813#endif 814#endif
814 815
815 if ((pdev = pci_find_device(PCI_VENDOR_ID_FD, PCI_DEVICE_ID_FD_36C70, pdev)) == NULL) 816 if ((pdev = pci_get_device(PCI_VENDOR_ID_FD, PCI_DEVICE_ID_FD_36C70, pdev)) == NULL)
816 return 0; 817 return 0;
817 if (pci_enable_device(pdev)) return 0; 818 if (pci_enable_device(pdev))
819 goto fail;
818 820
819#if DEBUG_DETECT 821#if DEBUG_DETECT
820 printk( "scsi: <fdomain> TMC-3260 detect:" 822 printk( "scsi: <fdomain> TMC-3260 detect:"
@@ -831,7 +833,7 @@ static int fdomain_pci_bios_detect( int *irq, int *iobase, struct pci_dev **ret_
831 pci_irq = pdev->irq; 833 pci_irq = pdev->irq;
832 834
833 if (!request_region( pci_base, 0x10, "fdomain" )) 835 if (!request_region( pci_base, 0x10, "fdomain" ))
834 return 0; 836 goto fail;
835 837
836 /* Now we have the I/O base address and interrupt from the PCI 838 /* Now we have the I/O base address and interrupt from the PCI
837 configuration registers. */ 839 configuration registers. */
@@ -848,17 +850,22 @@ static int fdomain_pci_bios_detect( int *irq, int *iobase, struct pci_dev **ret_
848 if (!fdomain_is_valid_port(pci_base)) { 850 if (!fdomain_is_valid_port(pci_base)) {
849 printk(KERN_ERR "scsi: <fdomain> PCI card detected, but driver not loaded (invalid port)\n" ); 851 printk(KERN_ERR "scsi: <fdomain> PCI card detected, but driver not loaded (invalid port)\n" );
850 release_region(pci_base, 0x10); 852 release_region(pci_base, 0x10);
851 return 0; 853 goto fail;
852 } 854 }
853 855
854 /* Fill in a few global variables. Ugh. */ 856 /* Fill in a few global variables. Ugh. */
855 bios_major = bios_minor = -1; 857 bios_major = bios_minor = -1;
856 PCI_bus = 1; 858 PCI_bus = 1;
859 PCI_dev = pdev;
857 Quantum = 0; 860 Quantum = 0;
858 bios_base = 0; 861 bios_base = 0;
859 862
860 return 1; 863 return 1;
864fail:
865 pci_dev_put(pdev);
866 return 0;
861} 867}
868
862#endif 869#endif
863 870
864struct Scsi_Host *__fdomain_16x0_detect(struct scsi_host_template *tpnt ) 871struct Scsi_Host *__fdomain_16x0_detect(struct scsi_host_template *tpnt )
@@ -909,8 +916,7 @@ struct Scsi_Host *__fdomain_16x0_detect(struct scsi_host_template *tpnt )
909 if (setup_called) { 916 if (setup_called) {
910 printk(KERN_ERR "scsi: <fdomain> Bad LILO/INSMOD parameters?\n"); 917 printk(KERN_ERR "scsi: <fdomain> Bad LILO/INSMOD parameters?\n");
911 } 918 }
912 release_region(port_base, 0x10); 919 goto fail;
913 return NULL;
914 } 920 }
915 921
916 if (this_id) { 922 if (this_id) {
@@ -942,8 +948,7 @@ struct Scsi_Host *__fdomain_16x0_detect(struct scsi_host_template *tpnt )
942 /* Log IRQ with kernel */ 948 /* Log IRQ with kernel */
943 if (!interrupt_level) { 949 if (!interrupt_level) {
944 printk(KERN_ERR "scsi: <fdomain> Card Detected, but driver not loaded (no IRQ)\n" ); 950 printk(KERN_ERR "scsi: <fdomain> Card Detected, but driver not loaded (no IRQ)\n" );
945 release_region(port_base, 0x10); 951 goto fail;
946 return NULL;
947 } else { 952 } else {
948 /* Register the IRQ with the kernel */ 953 /* Register the IRQ with the kernel */
949 954
@@ -964,11 +969,14 @@ struct Scsi_Host *__fdomain_16x0_detect(struct scsi_host_template *tpnt )
964 printk(KERN_ERR " Send mail to faith@acm.org\n" ); 969 printk(KERN_ERR " Send mail to faith@acm.org\n" );
965 } 970 }
966 printk(KERN_ERR "scsi: <fdomain> Detected, but driver not loaded (IRQ)\n" ); 971 printk(KERN_ERR "scsi: <fdomain> Detected, but driver not loaded (IRQ)\n" );
967 release_region(port_base, 0x10); 972 goto fail;
968 return NULL;
969 } 973 }
970 } 974 }
971 return shpnt; 975 return shpnt;
976fail:
977 pci_dev_put(pdev);
978 release_region(port_base, 0x10);
979 return NULL;
972} 980}
973 981
974static int fdomain_16x0_detect(struct scsi_host_template *tpnt) 982static int fdomain_16x0_detect(struct scsi_host_template *tpnt)
@@ -1714,6 +1722,8 @@ static int fdomain_16x0_release(struct Scsi_Host *shpnt)
1714 free_irq(shpnt->irq, shpnt); 1722 free_irq(shpnt->irq, shpnt);
1715 if (shpnt->io_port && shpnt->n_io_port) 1723 if (shpnt->io_port && shpnt->n_io_port)
1716 release_region(shpnt->io_port, shpnt->n_io_port); 1724 release_region(shpnt->io_port, shpnt->n_io_port);
1725 if (PCI_bus)
1726 pci_dev_put(PCI_dev);
1717 return 0; 1727 return 0;
1718} 1728}
1719 1729
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 669ea4fff166..fbc1d5c3b0a7 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -1213,7 +1213,7 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq,
1213 "ibmvscsi: Re-enabling adapter!\n"); 1213 "ibmvscsi: Re-enabling adapter!\n");
1214 purge_requests(hostdata, DID_REQUEUE); 1214 purge_requests(hostdata, DID_REQUEUE);
1215 if ((ibmvscsi_reenable_crq_queue(&hostdata->queue, 1215 if ((ibmvscsi_reenable_crq_queue(&hostdata->queue,
1216 hostdata) == 0) || 1216 hostdata)) ||
1217 (ibmvscsi_send_crq(hostdata, 1217 (ibmvscsi_send_crq(hostdata,
1218 0xC001000000000000LL, 0))) { 1218 0xC001000000000000LL, 0))) {
1219 atomic_set(&hostdata->request_limit, 1219 atomic_set(&hostdata->request_limit,
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index c542d0e95e68..2865ebd557ef 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -481,8 +481,8 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
481 break; 481 break;
482 case ISCSI_OP_ASYNC_EVENT: 482 case ISCSI_OP_ASYNC_EVENT:
483 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1; 483 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;
484 /* we need sth like iscsi_async_event_rsp() */ 484 if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen))
485 rc = ISCSI_ERR_BAD_OPCODE; 485 rc = ISCSI_ERR_CONN_FAILED;
486 break; 486 break;
487 default: 487 default:
488 rc = ISCSI_ERR_BAD_OPCODE; 488 rc = ISCSI_ERR_BAD_OPCODE;
@@ -578,6 +578,27 @@ void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err)
578} 578}
579EXPORT_SYMBOL_GPL(iscsi_conn_failure); 579EXPORT_SYMBOL_GPL(iscsi_conn_failure);
580 580
581static int iscsi_xmit_imm_task(struct iscsi_conn *conn)
582{
583 struct iscsi_hdr *hdr = conn->mtask->hdr;
584 int rc, was_logout = 0;
585
586 if ((hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGOUT) {
587 conn->session->state = ISCSI_STATE_IN_RECOVERY;
588 iscsi_block_session(session_to_cls(conn->session));
589 was_logout = 1;
590 }
591 rc = conn->session->tt->xmit_mgmt_task(conn, conn->mtask);
592 if (rc)
593 return rc;
594
595 if (was_logout) {
596 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
597 return -ENODATA;
598 }
599 return 0;
600}
601
581/** 602/**
582 * iscsi_data_xmit - xmit any command into the scheduled connection 603 * iscsi_data_xmit - xmit any command into the scheduled connection
583 * @conn: iscsi connection 604 * @conn: iscsi connection
@@ -623,7 +644,7 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)
623 conn->ctask = NULL; 644 conn->ctask = NULL;
624 } 645 }
625 if (conn->mtask) { 646 if (conn->mtask) {
626 rc = tt->xmit_mgmt_task(conn, conn->mtask); 647 rc = iscsi_xmit_imm_task(conn);
627 if (rc) 648 if (rc)
628 goto again; 649 goto again;
629 /* done with this in-progress mtask */ 650 /* done with this in-progress mtask */
@@ -638,7 +659,7 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)
638 list_add_tail(&conn->mtask->running, 659 list_add_tail(&conn->mtask->running,
639 &conn->mgmt_run_list); 660 &conn->mgmt_run_list);
640 spin_unlock_bh(&conn->session->lock); 661 spin_unlock_bh(&conn->session->lock);
641 rc = tt->xmit_mgmt_task(conn, conn->mtask); 662 rc = iscsi_xmit_imm_task(conn);
642 if (rc) 663 if (rc)
643 goto again; 664 goto again;
644 } 665 }
@@ -661,8 +682,6 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)
661 spin_unlock_bh(&conn->session->lock); 682 spin_unlock_bh(&conn->session->lock);
662 683
663 rc = tt->xmit_cmd_task(conn, conn->ctask); 684 rc = tt->xmit_cmd_task(conn, conn->ctask);
664 if (rc)
665 goto again;
666 685
667 spin_lock_bh(&conn->session->lock); 686 spin_lock_bh(&conn->session->lock);
668 __iscsi_put_ctask(conn->ctask); 687 __iscsi_put_ctask(conn->ctask);
@@ -778,6 +797,10 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
778 } 797 }
779 798
780 conn = session->leadconn; 799 conn = session->leadconn;
800 if (!conn) {
801 reason = FAILURE_SESSION_FREED;
802 goto fault;
803 }
781 804
782 if (!__kfifo_get(session->cmdpool.queue, (void*)&ctask, 805 if (!__kfifo_get(session->cmdpool.queue, (void*)&ctask,
783 sizeof(void*))) { 806 sizeof(void*))) {
@@ -1377,7 +1400,6 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
1377 } 1400 }
1378 1401
1379 spin_lock_init(&session->lock); 1402 spin_lock_init(&session->lock);
1380 INIT_LIST_HEAD(&session->connections);
1381 1403
1382 /* initialize immediate command pool */ 1404 /* initialize immediate command pool */
1383 if (iscsi_pool_init(&session->mgmtpool, session->mgmtpool_max, 1405 if (iscsi_pool_init(&session->mgmtpool, session->mgmtpool_max,
@@ -1580,16 +1602,11 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
1580 kfree(conn->persistent_address); 1602 kfree(conn->persistent_address);
1581 __kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask, 1603 __kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask,
1582 sizeof(void*)); 1604 sizeof(void*));
1583 list_del(&conn->item); 1605 if (session->leadconn == conn) {
1584 if (list_empty(&session->connections))
1585 session->leadconn = NULL; 1606 session->leadconn = NULL;
1586 if (session->leadconn && session->leadconn == conn)
1587 session->leadconn = container_of(session->connections.next,
1588 struct iscsi_conn, item);
1589
1590 if (session->leadconn == NULL)
1591 /* no connections exits.. reset sequencing */ 1607 /* no connections exits.. reset sequencing */
1592 session->cmdsn = session->max_cmdsn = session->exp_cmdsn = 1; 1608 session->cmdsn = session->max_cmdsn = session->exp_cmdsn = 1;
1609 }
1593 spin_unlock_bh(&session->lock); 1610 spin_unlock_bh(&session->lock);
1594 1611
1595 kfifo_free(conn->immqueue); 1612 kfifo_free(conn->immqueue);
@@ -1777,32 +1794,12 @@ int iscsi_conn_bind(struct iscsi_cls_session *cls_session,
1777 struct iscsi_cls_conn *cls_conn, int is_leading) 1794 struct iscsi_cls_conn *cls_conn, int is_leading)
1778{ 1795{
1779 struct iscsi_session *session = class_to_transport_session(cls_session); 1796 struct iscsi_session *session = class_to_transport_session(cls_session);
1780 struct iscsi_conn *tmp = ERR_PTR(-EEXIST), *conn = cls_conn->dd_data; 1797 struct iscsi_conn *conn = cls_conn->dd_data;
1781 1798
1782 /* lookup for existing connection */
1783 spin_lock_bh(&session->lock); 1799 spin_lock_bh(&session->lock);
1784 list_for_each_entry(tmp, &session->connections, item) {
1785 if (tmp == conn) {
1786 if (conn->c_stage != ISCSI_CONN_STOPPED ||
1787 conn->stop_stage == STOP_CONN_TERM) {
1788 printk(KERN_ERR "iscsi: can't bind "
1789 "non-stopped connection (%d:%d)\n",
1790 conn->c_stage, conn->stop_stage);
1791 spin_unlock_bh(&session->lock);
1792 return -EIO;
1793 }
1794 break;
1795 }
1796 }
1797 if (tmp != conn) {
1798 /* bind new iSCSI connection to session */
1799 conn->session = session;
1800 list_add(&conn->item, &session->connections);
1801 }
1802 spin_unlock_bh(&session->lock);
1803
1804 if (is_leading) 1800 if (is_leading)
1805 session->leadconn = conn; 1801 session->leadconn = conn;
1802 spin_unlock_bh(&session->lock);
1806 1803
1807 /* 1804 /*
1808 * Unblock xmitworker(), Login Phase will pass through. 1805 * Unblock xmitworker(), Login Phase will pass through.
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 9496e87c135e..2a4e02e7a392 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -594,7 +594,8 @@ lpfc_soft_wwpn_show(struct class_device *cdev, char *buf)
594{ 594{
595 struct Scsi_Host *host = class_to_shost(cdev); 595 struct Scsi_Host *host = class_to_shost(cdev);
596 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; 596 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
597 return snprintf(buf, PAGE_SIZE, "0x%llx\n", phba->cfg_soft_wwpn); 597 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
598 (unsigned long long)phba->cfg_soft_wwpn);
598} 599}
599 600
600 601
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 1b53afb1cb57..3add7c237859 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -188,7 +188,8 @@ lpfc_alloc_ct_rsp(struct lpfc_hba * phba, int cmdcode, struct ulp_bde64 * bpl,
188 188
189 if (!mp->virt) { 189 if (!mp->virt) {
190 kfree(mp); 190 kfree(mp);
191 lpfc_free_ct_rsp(phba, mlist); 191 if (mlist)
192 lpfc_free_ct_rsp(phba, mlist);
192 return NULL; 193 return NULL;
193 } 194 }
194 195
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index b1d346049525..f2d79c3f0b8e 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -183,7 +183,7 @@ static void nsp_cs_dmessage(const char *func, int line, int mask, char *fmt, ...
183 * Clenaup parameters and call done() functions. 183 * Clenaup parameters and call done() functions.
184 * You must be set SCpnt->result before call this function. 184 * You must be set SCpnt->result before call this function.
185 */ 185 */
186static void nsp_scsi_done(Scsi_Cmnd *SCpnt) 186static void nsp_scsi_done(struct scsi_cmnd *SCpnt)
187{ 187{
188 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 188 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
189 189
@@ -192,7 +192,8 @@ static void nsp_scsi_done(Scsi_Cmnd *SCpnt)
192 SCpnt->scsi_done(SCpnt); 192 SCpnt->scsi_done(SCpnt);
193} 193}
194 194
195static int nsp_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) 195static int nsp_queuecommand(struct scsi_cmnd *SCpnt,
196 void (*done)(struct scsi_cmnd *))
196{ 197{
197#ifdef NSP_DEBUG 198#ifdef NSP_DEBUG
198 /*unsigned int host_id = SCpnt->device->host->this_id;*/ 199 /*unsigned int host_id = SCpnt->device->host->this_id;*/
@@ -365,7 +366,7 @@ static int nsphw_init(nsp_hw_data *data)
365/* 366/*
366 * Start selection phase 367 * Start selection phase
367 */ 368 */
368static int nsphw_start_selection(Scsi_Cmnd *SCpnt) 369static int nsphw_start_selection(struct scsi_cmnd *SCpnt)
369{ 370{
370 unsigned int host_id = SCpnt->device->host->this_id; 371 unsigned int host_id = SCpnt->device->host->this_id;
371 unsigned int base = SCpnt->device->host->io_port; 372 unsigned int base = SCpnt->device->host->io_port;
@@ -446,7 +447,7 @@ static struct nsp_sync_table nsp_sync_table_20M[] = {
446/* 447/*
447 * setup synchronous data transfer mode 448 * setup synchronous data transfer mode
448 */ 449 */
449static int nsp_analyze_sdtr(Scsi_Cmnd *SCpnt) 450static int nsp_analyze_sdtr(struct scsi_cmnd *SCpnt)
450{ 451{
451 unsigned char target = scmd_id(SCpnt); 452 unsigned char target = scmd_id(SCpnt);
452// unsigned char lun = SCpnt->device->lun; 453// unsigned char lun = SCpnt->device->lun;
@@ -504,7 +505,7 @@ static int nsp_analyze_sdtr(Scsi_Cmnd *SCpnt)
504/* 505/*
505 * start ninja hardware timer 506 * start ninja hardware timer
506 */ 507 */
507static void nsp_start_timer(Scsi_Cmnd *SCpnt, int time) 508static void nsp_start_timer(struct scsi_cmnd *SCpnt, int time)
508{ 509{
509 unsigned int base = SCpnt->device->host->io_port; 510 unsigned int base = SCpnt->device->host->io_port;
510 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 511 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
@@ -517,7 +518,8 @@ static void nsp_start_timer(Scsi_Cmnd *SCpnt, int time)
517/* 518/*
518 * wait for bus phase change 519 * wait for bus phase change
519 */ 520 */
520static int nsp_negate_signal(Scsi_Cmnd *SCpnt, unsigned char mask, char *str) 521static int nsp_negate_signal(struct scsi_cmnd *SCpnt, unsigned char mask,
522 char *str)
521{ 523{
522 unsigned int base = SCpnt->device->host->io_port; 524 unsigned int base = SCpnt->device->host->io_port;
523 unsigned char reg; 525 unsigned char reg;
@@ -544,9 +546,9 @@ static int nsp_negate_signal(Scsi_Cmnd *SCpnt, unsigned char mask, char *str)
544/* 546/*
545 * expect Ninja Irq 547 * expect Ninja Irq
546 */ 548 */
547static int nsp_expect_signal(Scsi_Cmnd *SCpnt, 549static int nsp_expect_signal(struct scsi_cmnd *SCpnt,
548 unsigned char current_phase, 550 unsigned char current_phase,
549 unsigned char mask) 551 unsigned char mask)
550{ 552{
551 unsigned int base = SCpnt->device->host->io_port; 553 unsigned int base = SCpnt->device->host->io_port;
552 int time_out; 554 int time_out;
@@ -579,7 +581,7 @@ static int nsp_expect_signal(Scsi_Cmnd *SCpnt,
579/* 581/*
580 * transfer SCSI message 582 * transfer SCSI message
581 */ 583 */
582static int nsp_xfer(Scsi_Cmnd *SCpnt, int phase) 584static int nsp_xfer(struct scsi_cmnd *SCpnt, int phase)
583{ 585{
584 unsigned int base = SCpnt->device->host->io_port; 586 unsigned int base = SCpnt->device->host->io_port;
585 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 587 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
@@ -619,7 +621,7 @@ static int nsp_xfer(Scsi_Cmnd *SCpnt, int phase)
619/* 621/*
620 * get extra SCSI data from fifo 622 * get extra SCSI data from fifo
621 */ 623 */
622static int nsp_dataphase_bypass(Scsi_Cmnd *SCpnt) 624static int nsp_dataphase_bypass(struct scsi_cmnd *SCpnt)
623{ 625{
624 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 626 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
625 unsigned int count; 627 unsigned int count;
@@ -651,7 +653,7 @@ static int nsp_dataphase_bypass(Scsi_Cmnd *SCpnt)
651/* 653/*
652 * accept reselection 654 * accept reselection
653 */ 655 */
654static int nsp_reselected(Scsi_Cmnd *SCpnt) 656static int nsp_reselected(struct scsi_cmnd *SCpnt)
655{ 657{
656 unsigned int base = SCpnt->device->host->io_port; 658 unsigned int base = SCpnt->device->host->io_port;
657 unsigned int host_id = SCpnt->device->host->this_id; 659 unsigned int host_id = SCpnt->device->host->this_id;
@@ -690,7 +692,7 @@ static int nsp_reselected(Scsi_Cmnd *SCpnt)
690/* 692/*
691 * count how many data transferd 693 * count how many data transferd
692 */ 694 */
693static int nsp_fifo_count(Scsi_Cmnd *SCpnt) 695static int nsp_fifo_count(struct scsi_cmnd *SCpnt)
694{ 696{
695 unsigned int base = SCpnt->device->host->io_port; 697 unsigned int base = SCpnt->device->host->io_port;
696 unsigned int count; 698 unsigned int count;
@@ -717,7 +719,7 @@ static int nsp_fifo_count(Scsi_Cmnd *SCpnt)
717/* 719/*
718 * read data in DATA IN phase 720 * read data in DATA IN phase
719 */ 721 */
720static void nsp_pio_read(Scsi_Cmnd *SCpnt) 722static void nsp_pio_read(struct scsi_cmnd *SCpnt)
721{ 723{
722 unsigned int base = SCpnt->device->host->io_port; 724 unsigned int base = SCpnt->device->host->io_port;
723 unsigned long mmio_base = SCpnt->device->host->base; 725 unsigned long mmio_base = SCpnt->device->host->base;
@@ -812,7 +814,7 @@ static void nsp_pio_read(Scsi_Cmnd *SCpnt)
812/* 814/*
813 * write data in DATA OUT phase 815 * write data in DATA OUT phase
814 */ 816 */
815static void nsp_pio_write(Scsi_Cmnd *SCpnt) 817static void nsp_pio_write(struct scsi_cmnd *SCpnt)
816{ 818{
817 unsigned int base = SCpnt->device->host->io_port; 819 unsigned int base = SCpnt->device->host->io_port;
818 unsigned long mmio_base = SCpnt->device->host->base; 820 unsigned long mmio_base = SCpnt->device->host->base;
@@ -905,7 +907,7 @@ static void nsp_pio_write(Scsi_Cmnd *SCpnt)
905/* 907/*
906 * setup synchronous/asynchronous data transfer mode 908 * setup synchronous/asynchronous data transfer mode
907 */ 909 */
908static int nsp_nexus(Scsi_Cmnd *SCpnt) 910static int nsp_nexus(struct scsi_cmnd *SCpnt)
909{ 911{
910 unsigned int base = SCpnt->device->host->io_port; 912 unsigned int base = SCpnt->device->host->io_port;
911 unsigned char target = scmd_id(SCpnt); 913 unsigned char target = scmd_id(SCpnt);
@@ -952,7 +954,7 @@ static irqreturn_t nspintr(int irq, void *dev_id)
952{ 954{
953 unsigned int base; 955 unsigned int base;
954 unsigned char irq_status, irq_phase, phase; 956 unsigned char irq_status, irq_phase, phase;
955 Scsi_Cmnd *tmpSC; 957 struct scsi_cmnd *tmpSC;
956 unsigned char target, lun; 958 unsigned char target, lun;
957 unsigned int *sync_neg; 959 unsigned int *sync_neg;
958 int i, tmp; 960 int i, tmp;
@@ -1530,7 +1532,7 @@ nsp_proc_info(
1530/*---------------------------------------------------------------*/ 1532/*---------------------------------------------------------------*/
1531 1533
1532/* 1534/*
1533static int nsp_eh_abort(Scsi_Cmnd *SCpnt) 1535static int nsp_eh_abort(struct scsi_cmnd *SCpnt)
1534{ 1536{
1535 nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt); 1537 nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt);
1536 1538
@@ -1558,7 +1560,7 @@ static int nsp_bus_reset(nsp_hw_data *data)
1558 return SUCCESS; 1560 return SUCCESS;
1559} 1561}
1560 1562
1561static int nsp_eh_bus_reset(Scsi_Cmnd *SCpnt) 1563static int nsp_eh_bus_reset(struct scsi_cmnd *SCpnt)
1562{ 1564{
1563 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 1565 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
1564 1566
@@ -1567,7 +1569,7 @@ static int nsp_eh_bus_reset(Scsi_Cmnd *SCpnt)
1567 return nsp_bus_reset(data); 1569 return nsp_bus_reset(data);
1568} 1570}
1569 1571
1570static int nsp_eh_host_reset(Scsi_Cmnd *SCpnt) 1572static int nsp_eh_host_reset(struct scsi_cmnd *SCpnt)
1571{ 1573{
1572 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 1574 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
1573 1575
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
index a88714f4c05b..625ca97da52d 100644
--- a/drivers/scsi/pcmcia/nsp_cs.h
+++ b/drivers/scsi/pcmcia/nsp_cs.h
@@ -266,7 +266,7 @@ typedef struct _nsp_hw_data {
266 266
267 int TimerCount; 267 int TimerCount;
268 int SelectionTimeOut; 268 int SelectionTimeOut;
269 Scsi_Cmnd *CurrentSC; 269 struct scsi_cmnd *CurrentSC;
270 //int CurrnetTarget; 270 //int CurrnetTarget;
271 271
272 int FifoCount; 272 int FifoCount;
@@ -319,30 +319,34 @@ static int nsp_proc_info (
319 int hostno, 319 int hostno,
320#endif 320#endif
321 int inout); 321 int inout);
322static int nsp_queuecommand(Scsi_Cmnd *SCpnt, void (* done)(Scsi_Cmnd *SCpnt)); 322static int nsp_queuecommand(struct scsi_cmnd *SCpnt,
323 void (* done)(struct scsi_cmnd *SCpnt));
323 324
324/* Error handler */ 325/* Error handler */
325/*static int nsp_eh_abort (Scsi_Cmnd *SCpnt);*/ 326/*static int nsp_eh_abort (struct scsi_cmnd *SCpnt);*/
326/*static int nsp_eh_device_reset(Scsi_Cmnd *SCpnt);*/ 327/*static int nsp_eh_device_reset(struct scsi_cmnd *SCpnt);*/
327static int nsp_eh_bus_reset (Scsi_Cmnd *SCpnt); 328static int nsp_eh_bus_reset (struct scsi_cmnd *SCpnt);
328static int nsp_eh_host_reset (Scsi_Cmnd *SCpnt); 329static int nsp_eh_host_reset (struct scsi_cmnd *SCpnt);
329static int nsp_bus_reset (nsp_hw_data *data); 330static int nsp_bus_reset (nsp_hw_data *data);
330 331
331/* */ 332/* */
332static int nsphw_init (nsp_hw_data *data); 333static int nsphw_init (nsp_hw_data *data);
333static int nsphw_start_selection(Scsi_Cmnd *SCpnt); 334static int nsphw_start_selection(struct scsi_cmnd *SCpnt);
334static void nsp_start_timer (Scsi_Cmnd *SCpnt, int time); 335static void nsp_start_timer (struct scsi_cmnd *SCpnt, int time);
335static int nsp_fifo_count (Scsi_Cmnd *SCpnt); 336static int nsp_fifo_count (struct scsi_cmnd *SCpnt);
336static void nsp_pio_read (Scsi_Cmnd *SCpnt); 337static void nsp_pio_read (struct scsi_cmnd *SCpnt);
337static void nsp_pio_write (Scsi_Cmnd *SCpnt); 338static void nsp_pio_write (struct scsi_cmnd *SCpnt);
338static int nsp_nexus (Scsi_Cmnd *SCpnt); 339static int nsp_nexus (struct scsi_cmnd *SCpnt);
339static void nsp_scsi_done (Scsi_Cmnd *SCpnt); 340static void nsp_scsi_done (struct scsi_cmnd *SCpnt);
340static int nsp_analyze_sdtr (Scsi_Cmnd *SCpnt); 341static int nsp_analyze_sdtr (struct scsi_cmnd *SCpnt);
341static int nsp_negate_signal (Scsi_Cmnd *SCpnt, unsigned char mask, char *str); 342static int nsp_negate_signal (struct scsi_cmnd *SCpnt,
342static int nsp_expect_signal (Scsi_Cmnd *SCpnt, unsigned char current_phase, unsigned char mask); 343 unsigned char mask, char *str);
343static int nsp_xfer (Scsi_Cmnd *SCpnt, int phase); 344static int nsp_expect_signal (struct scsi_cmnd *SCpnt,
344static int nsp_dataphase_bypass (Scsi_Cmnd *SCpnt); 345 unsigned char current_phase,
345static int nsp_reselected (Scsi_Cmnd *SCpnt); 346 unsigned char mask);
347static int nsp_xfer (struct scsi_cmnd *SCpnt, int phase);
348static int nsp_dataphase_bypass (struct scsi_cmnd *SCpnt);
349static int nsp_reselected (struct scsi_cmnd *SCpnt);
346static struct Scsi_Host *nsp_detect(struct scsi_host_template *sht); 350static struct Scsi_Host *nsp_detect(struct scsi_host_template *sht);
347 351
348/* Interrupt handler */ 352/* Interrupt handler */
@@ -355,8 +359,8 @@ static void __exit nsp_cs_exit(void);
355 359
356/* Debug */ 360/* Debug */
357#ifdef NSP_DEBUG 361#ifdef NSP_DEBUG
358static void show_command (Scsi_Cmnd *SCpnt); 362static void show_command (struct scsi_cmnd *SCpnt);
359static void show_phase (Scsi_Cmnd *SCpnt); 363static void show_phase (struct scsi_cmnd *SCpnt);
360static void show_busphase(unsigned char stat); 364static void show_busphase(unsigned char stat);
361static void show_message (nsp_hw_data *data); 365static void show_message (nsp_hw_data *data);
362#else 366#else
diff --git a/drivers/scsi/pcmcia/nsp_debug.c b/drivers/scsi/pcmcia/nsp_debug.c
index 62e5c60067fd..2f75fe6e35a7 100644
--- a/drivers/scsi/pcmcia/nsp_debug.c
+++ b/drivers/scsi/pcmcia/nsp_debug.c
@@ -138,12 +138,12 @@ static void print_commandk (unsigned char *command)
138 printk("\n"); 138 printk("\n");
139} 139}
140 140
141static void show_command(Scsi_Cmnd *SCpnt) 141static void show_command(struct scsi_cmnd *SCpnt)
142{ 142{
143 print_commandk(SCpnt->cmnd); 143 print_commandk(SCpnt->cmnd);
144} 144}
145 145
146static void show_phase(Scsi_Cmnd *SCpnt) 146static void show_phase(struct scsi_cmnd *SCpnt)
147{ 147{
148 int i = SCpnt->SCp.phase; 148 int i = SCpnt->SCp.phase;
149 149
diff --git a/drivers/scsi/pcmcia/nsp_message.c b/drivers/scsi/pcmcia/nsp_message.c
index d7057737ff34..ef593b70d0f0 100644
--- a/drivers/scsi/pcmcia/nsp_message.c
+++ b/drivers/scsi/pcmcia/nsp_message.c
@@ -8,7 +8,7 @@
8 8
9/* $Id: nsp_message.c,v 1.6 2003/07/26 14:21:09 elca Exp $ */ 9/* $Id: nsp_message.c,v 1.6 2003/07/26 14:21:09 elca Exp $ */
10 10
11static void nsp_message_in(Scsi_Cmnd *SCpnt) 11static void nsp_message_in(struct scsi_cmnd *SCpnt)
12{ 12{
13 unsigned int base = SCpnt->device->host->io_port; 13 unsigned int base = SCpnt->device->host->io_port;
14 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 14 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
@@ -50,7 +50,7 @@ static void nsp_message_in(Scsi_Cmnd *SCpnt)
50 50
51} 51}
52 52
53static void nsp_message_out(Scsi_Cmnd *SCpnt) 53static void nsp_message_out(struct scsi_cmnd *SCpnt)
54{ 54{
55 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; 55 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
56 int ret = 1; 56 int ret = 1;
diff --git a/drivers/scsi/psi240i.c b/drivers/scsi/psi240i.c
index a720c9265e66..ac0419e2714a 100644
--- a/drivers/scsi/psi240i.c
+++ b/drivers/scsi/psi240i.c
@@ -87,11 +87,11 @@ typedef struct
87 { 87 {
88 USHORT ports[13]; 88 USHORT ports[13];
89 OUR_DEVICE device[8]; 89 OUR_DEVICE device[8];
90 Scsi_Cmnd *pSCmnd; 90 struct scsi_cmnd *pSCmnd;
91 IDE_STRUCT ide; 91 IDE_STRUCT ide;
92 ULONG startSector; 92 ULONG startSector;
93 USHORT sectorCount; 93 USHORT sectorCount;
94 Scsi_Cmnd *SCpnt; 94 struct scsi_cmnd *SCpnt;
95 VOID *buffer; 95 VOID *buffer;
96 USHORT expectingIRQ; 96 USHORT expectingIRQ;
97 } ADAPTER240I, *PADAPTER240I; 97 } ADAPTER240I, *PADAPTER240I;
@@ -253,12 +253,12 @@ static ULONG DecodeError (struct Scsi_Host *pshost, UCHAR status)
253 ****************************************************************/ 253 ****************************************************************/
254static void Irq_Handler (int irq, void *dev_id) 254static void Irq_Handler (int irq, void *dev_id)
255 { 255 {
256 struct Scsi_Host *shost; // Pointer to host data block 256 struct Scsi_Host *shost; // Pointer to host data block
257 PADAPTER240I padapter; // Pointer to adapter control structure 257 PADAPTER240I padapter; // Pointer to adapter control structure
258 USHORT *pports; // I/O port array 258 USHORT *pports; // I/O port array
259 Scsi_Cmnd *SCpnt; 259 struct scsi_cmnd *SCpnt;
260 UCHAR status; 260 UCHAR status;
261 int z; 261 int z;
262 262
263 DEB(printk ("\npsi240i received interrupt\n")); 263 DEB(printk ("\npsi240i received interrupt\n"));
264 264
@@ -389,12 +389,17 @@ static irqreturn_t do_Irq_Handler (int irq, void *dev_id)
389 * Returns: Status code. 389 * Returns: Status code.
390 * 390 *
391 ****************************************************************/ 391 ****************************************************************/
392static int Psi240i_QueueCommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) 392static int Psi240i_QueueCommand(struct scsi_cmnd *SCpnt,
393 void (*done)(struct scsi_cmnd *))
393 { 394 {
394 UCHAR *cdb = (UCHAR *)SCpnt->cmnd; // Pointer to SCSI CDB 395 UCHAR *cdb = (UCHAR *)SCpnt->cmnd;
395 PADAPTER240I padapter = HOSTDATA (SCpnt->device->host); // Pointer to adapter control structure 396 // Pointer to SCSI CDB
396 POUR_DEVICE pdev = &padapter->device [SCpnt->device->id];// Pointer to device information 397 PADAPTER240I padapter = HOSTDATA (SCpnt->device->host);
397 UCHAR rc; // command return code 398 // Pointer to adapter control structure
399 POUR_DEVICE pdev = &padapter->device [SCpnt->device->id];
400 // Pointer to device information
401 UCHAR rc;
402 // command return code
398 403
399 SCpnt->scsi_done = done; 404 SCpnt->scsi_done = done;
400 padapter->ide.ide.ides.spigot = pdev->spigot; 405 padapter->ide.ide.ides.spigot = pdev->spigot;
diff --git a/drivers/scsi/psi240i.h b/drivers/scsi/psi240i.h
index 6a598766df51..21ebb9214004 100644
--- a/drivers/scsi/psi240i.h
+++ b/drivers/scsi/psi240i.h
@@ -309,7 +309,7 @@ typedef struct _IDENTIFY_DATA2 {
309#endif // PSI_EIDE_SCSIOP 309#endif // PSI_EIDE_SCSIOP
310 310
311// function prototypes 311// function prototypes
312int Psi240i_Command (Scsi_Cmnd *SCpnt); 312int Psi240i_Command(struct scsi_cmnd *SCpnt);
313int Psi240i_Abort (Scsi_Cmnd *SCpnt); 313int Psi240i_Abort(struct scsi_cmnd *SCpnt);
314int Psi240i_Reset (Scsi_Cmnd *SCpnt, unsigned int flags); 314int Psi240i_Reset(struct scsi_cmnd *SCpnt, unsigned int flags);
315#endif 315#endif
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 2521d548dd59..16af5b79e587 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -931,11 +931,10 @@ qla1280_error_action(struct scsi_cmnd *cmd, enum action action)
931 931
932 case BUS_RESET: 932 case BUS_RESET:
933 if (qla1280_verbose) 933 if (qla1280_verbose)
934 printk(KERN_INFO "qla1280(%ld:%d): Issuing BUS " 934 printk(KERN_INFO "qla1280(%ld:%d): Issued bus "
935 "DEVICE RESET\n", ha->host_no, bus); 935 "reset.\n", ha->host_no, bus);
936 if (qla1280_bus_reset(ha, bus == 0)) 936 if (qla1280_bus_reset(ha, bus) == 0)
937 result = SUCCESS; 937 result = SUCCESS;
938
939 break; 938 break;
940 939
941 case ADAPTER_RESET: 940 case ADAPTER_RESET:
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index ee75a71f3c66..285c8e8ff1a0 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -379,21 +379,37 @@ static struct bin_attribute sysfs_sfp_attr = {
379 .read = qla2x00_sysfs_read_sfp, 379 .read = qla2x00_sysfs_read_sfp,
380}; 380};
381 381
382static struct sysfs_entry {
383 char *name;
384 struct bin_attribute *attr;
385 int is4GBp_only;
386} bin_file_entries[] = {
387 { "fw_dump", &sysfs_fw_dump_attr, },
388 { "nvram", &sysfs_nvram_attr, },
389 { "optrom", &sysfs_optrom_attr, },
390 { "optrom_ctl", &sysfs_optrom_ctl_attr, },
391 { "vpd", &sysfs_vpd_attr, 1 },
392 { "sfp", &sysfs_sfp_attr, 1 },
393 { 0 },
394};
395
382void 396void
383qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha) 397qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha)
384{ 398{
385 struct Scsi_Host *host = ha->host; 399 struct Scsi_Host *host = ha->host;
400 struct sysfs_entry *iter;
401 int ret;
386 402
387 sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr); 403 for (iter = bin_file_entries; iter->name; iter++) {
388 sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr); 404 if (iter->is4GBp_only && (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)))
389 sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_attr); 405 continue;
390 sysfs_create_bin_file(&host->shost_gendev.kobj, 406
391 &sysfs_optrom_ctl_attr); 407 ret = sysfs_create_bin_file(&host->shost_gendev.kobj,
392 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 408 iter->attr);
393 sysfs_create_bin_file(&host->shost_gendev.kobj, 409 if (ret)
394 &sysfs_vpd_attr); 410 qla_printk(KERN_INFO, ha,
395 sysfs_create_bin_file(&host->shost_gendev.kobj, 411 "Unable to create sysfs %s binary attribute "
396 &sysfs_sfp_attr); 412 "(%d).\n", iter->name, ret);
397 } 413 }
398} 414}
399 415
@@ -401,17 +417,14 @@ void
401qla2x00_free_sysfs_attr(scsi_qla_host_t *ha) 417qla2x00_free_sysfs_attr(scsi_qla_host_t *ha)
402{ 418{
403 struct Scsi_Host *host = ha->host; 419 struct Scsi_Host *host = ha->host;
420 struct sysfs_entry *iter;
421
422 for (iter = bin_file_entries; iter->name; iter++) {
423 if (iter->is4GBp_only && (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)))
424 continue;
404 425
405 sysfs_remove_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr);
406 sysfs_remove_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr);
407 sysfs_remove_bin_file(&host->shost_gendev.kobj, &sysfs_optrom_attr);
408 sysfs_remove_bin_file(&host->shost_gendev.kobj,
409 &sysfs_optrom_ctl_attr);
410 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
411 sysfs_remove_bin_file(&host->shost_gendev.kobj,
412 &sysfs_vpd_attr);
413 sysfs_remove_bin_file(&host->shost_gendev.kobj, 426 sysfs_remove_bin_file(&host->shost_gendev.kobj,
414 &sysfs_sfp_attr); 427 iter->attr);
415 } 428 }
416 429
417 if (ha->beacon_blink_led == 1) 430 if (ha->beacon_blink_led == 1)
diff --git a/drivers/scsi/qla2xxx/qla_dbg.h b/drivers/scsi/qla2xxx/qla_dbg.h
index 90dad7e88985..5b12278968e0 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.h
+++ b/drivers/scsi/qla2xxx/qla_dbg.h
@@ -38,7 +38,7 @@
38* Macros use for debugging the driver. 38* Macros use for debugging the driver.
39*/ 39*/
40 40
41#define DEBUG(x) do { if (qla2_extended_error_logging) { x; } } while (0) 41#define DEBUG(x) do { if (ql2xextended_error_logging) { x; } } while (0)
42 42
43#if defined(QL_DEBUG_LEVEL_1) 43#if defined(QL_DEBUG_LEVEL_1)
44#define DEBUG1(x) do {x;} while (0) 44#define DEBUG1(x) do {x;} while (0)
@@ -46,12 +46,12 @@
46#define DEBUG1(x) do {} while (0) 46#define DEBUG1(x) do {} while (0)
47#endif 47#endif
48 48
49#define DEBUG2(x) do { if (qla2_extended_error_logging) { x; } } while (0) 49#define DEBUG2(x) do { if (ql2xextended_error_logging) { x; } } while (0)
50#define DEBUG2_3(x) do { if (qla2_extended_error_logging) { x; } } while (0) 50#define DEBUG2_3(x) do { if (ql2xextended_error_logging) { x; } } while (0)
51#define DEBUG2_3_11(x) do { if (qla2_extended_error_logging) { x; } } while (0) 51#define DEBUG2_3_11(x) do { if (ql2xextended_error_logging) { x; } } while (0)
52#define DEBUG2_9_10(x) do { if (qla2_extended_error_logging) { x; } } while (0) 52#define DEBUG2_9_10(x) do { if (ql2xextended_error_logging) { x; } } while (0)
53#define DEBUG2_11(x) do { if (qla2_extended_error_logging) { x; } } while (0) 53#define DEBUG2_11(x) do { if (ql2xextended_error_logging) { x; } } while (0)
54#define DEBUG2_13(x) do { if (qla2_extended_error_logging) { x; } } while (0) 54#define DEBUG2_13(x) do { if (ql2xextended_error_logging) { x; } } while (0)
55 55
56#if defined(QL_DEBUG_LEVEL_3) 56#if defined(QL_DEBUG_LEVEL_3)
57#define DEBUG3(x) do {x;} while (0) 57#define DEBUG3(x) do {x;} while (0)
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index bab33f6d0bdb..c4fc40f8e8ca 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -1545,6 +1545,9 @@ typedef struct fc_port {
1545 spinlock_t rport_lock; 1545 spinlock_t rport_lock;
1546 struct fc_rport *rport, *drport; 1546 struct fc_rport *rport, *drport;
1547 u32 supported_classes; 1547 u32 supported_classes;
1548
1549 unsigned long last_queue_full;
1550 unsigned long last_ramp_up;
1548} fc_port_t; 1551} fc_port_t;
1549 1552
1550/* 1553/*
@@ -2255,6 +2258,7 @@ typedef struct scsi_qla_host {
2255 uint16_t mgmt_svr_loop_id; 2258 uint16_t mgmt_svr_loop_id;
2256 2259
2257 uint32_t login_retry_count; 2260 uint32_t login_retry_count;
2261 int max_q_depth;
2258 2262
2259 /* Fibre Channel Device List. */ 2263 /* Fibre Channel Device List. */
2260 struct list_head fcports; 2264 struct list_head fcports;
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 7da69832d74c..32ebeec45ff0 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -48,6 +48,7 @@ extern void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *);
48extern void qla2x00_reg_remote_port(scsi_qla_host_t *, fc_port_t *); 48extern void qla2x00_reg_remote_port(scsi_qla_host_t *, fc_port_t *);
49 49
50extern void qla2x00_alloc_fw_dump(scsi_qla_host_t *); 50extern void qla2x00_alloc_fw_dump(scsi_qla_host_t *);
51extern void qla2x00_try_to_stop_firmware(scsi_qla_host_t *);
51 52
52/* 53/*
53 * Global Data in qla_os.c source file. 54 * Global Data in qla_os.c source file.
@@ -60,7 +61,8 @@ extern int ql2xplogiabsentdevice;
60extern int ql2xloginretrycount; 61extern int ql2xloginretrycount;
61extern int ql2xfdmienable; 62extern int ql2xfdmienable;
62extern int ql2xallocfwdump; 63extern int ql2xallocfwdump;
63extern int qla2_extended_error_logging; 64extern int ql2xextended_error_logging;
65extern int ql2xqfullrampup;
64 66
65extern void qla2x00_sp_compl(scsi_qla_host_t *, srb_t *); 67extern void qla2x00_sp_compl(scsi_qla_host_t *, srb_t *);
66 68
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 833b93085fd3..08cb5e3fb553 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1644,7 +1644,7 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
1644 * Set host adapter parameters. 1644 * Set host adapter parameters.
1645 */ 1645 */
1646 if (nv->host_p[0] & BIT_7) 1646 if (nv->host_p[0] & BIT_7)
1647 qla2_extended_error_logging = 1; 1647 ql2xextended_error_logging = 1;
1648 ha->flags.disable_risc_code_load = ((nv->host_p[0] & BIT_4) ? 1 : 0); 1648 ha->flags.disable_risc_code_load = ((nv->host_p[0] & BIT_4) ? 1 : 0);
1649 /* Always load RISC code on non ISP2[12]00 chips. */ 1649 /* Always load RISC code on non ISP2[12]00 chips. */
1650 if (!IS_QLA2100(ha) && !IS_QLA2200(ha)) 1650 if (!IS_QLA2100(ha) && !IS_QLA2200(ha))
@@ -3948,3 +3948,24 @@ qla24xx_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3948fail_fw_integrity: 3948fail_fw_integrity:
3949 return QLA_FUNCTION_FAILED; 3949 return QLA_FUNCTION_FAILED;
3950} 3950}
3951
3952void
3953qla2x00_try_to_stop_firmware(scsi_qla_host_t *ha)
3954{
3955 int ret, retries;
3956
3957 if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha))
3958 return;
3959
3960 ret = qla2x00_stop_firmware(ha);
3961 for (retries = 5; ret != QLA_SUCCESS && retries ; retries--) {
3962 qla2x00_reset_chip(ha);
3963 if (qla2x00_chip_diag(ha) != QLA_SUCCESS)
3964 continue;
3965 if (qla2x00_setup_chip(ha) != QLA_SUCCESS)
3966 continue;
3967 qla_printk(KERN_INFO, ha,
3968 "Attempting retry of stop-firmware command...\n");
3969 ret = qla2x00_stop_firmware(ha);
3970 }
3971}
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 626c7178a434..d3b6df4d55c8 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -6,6 +6,8 @@
6 */ 6 */
7#include "qla_def.h" 7#include "qla_def.h"
8 8
9#include <scsi/scsi_tcq.h>
10
9static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t); 11static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t);
10static void qla2x00_async_event(scsi_qla_host_t *, uint16_t *); 12static void qla2x00_async_event(scsi_qla_host_t *, uint16_t *);
11static void qla2x00_process_completed_request(struct scsi_qla_host *, uint32_t); 13static void qla2x00_process_completed_request(struct scsi_qla_host *, uint32_t);
@@ -593,6 +595,67 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
593 } 595 }
594} 596}
595 597
598static void
599qla2x00_adjust_sdev_qdepth_up(struct scsi_device *sdev, void *data)
600{
601 fc_port_t *fcport = data;
602
603 if (fcport->ha->max_q_depth <= sdev->queue_depth)
604 return;
605
606 if (sdev->ordered_tags)
607 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
608 sdev->queue_depth + 1);
609 else
610 scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG,
611 sdev->queue_depth + 1);
612
613 fcport->last_ramp_up = jiffies;
614
615 DEBUG2(qla_printk(KERN_INFO, fcport->ha,
616 "scsi(%ld:%d:%d:%d): Queue depth adjusted-up to %d.\n",
617 fcport->ha->host_no, sdev->channel, sdev->id, sdev->lun,
618 sdev->queue_depth));
619}
620
621static void
622qla2x00_adjust_sdev_qdepth_down(struct scsi_device *sdev, void *data)
623{
624 fc_port_t *fcport = data;
625
626 if (!scsi_track_queue_full(sdev, sdev->queue_depth - 1))
627 return;
628
629 DEBUG2(qla_printk(KERN_INFO, fcport->ha,
630 "scsi(%ld:%d:%d:%d): Queue depth adjusted-down to %d.\n",
631 fcport->ha->host_no, sdev->channel, sdev->id, sdev->lun,
632 sdev->queue_depth));
633}
634
635static inline void
636qla2x00_ramp_up_queue_depth(scsi_qla_host_t *ha, srb_t *sp)
637{
638 fc_port_t *fcport;
639 struct scsi_device *sdev;
640
641 sdev = sp->cmd->device;
642 if (sdev->queue_depth >= ha->max_q_depth)
643 return;
644
645 fcport = sp->fcport;
646 if (time_before(jiffies,
647 fcport->last_ramp_up + ql2xqfullrampup * HZ))
648 return;
649 if (time_before(jiffies,
650 fcport->last_queue_full + ql2xqfullrampup * HZ))
651 return;
652
653 spin_unlock_irq(&ha->hardware_lock);
654 starget_for_each_device(sdev->sdev_target, fcport,
655 qla2x00_adjust_sdev_qdepth_up);
656 spin_lock_irq(&ha->hardware_lock);
657}
658
596/** 659/**
597 * qla2x00_process_completed_request() - Process a Fast Post response. 660 * qla2x00_process_completed_request() - Process a Fast Post response.
598 * @ha: SCSI driver HA context 661 * @ha: SCSI driver HA context
@@ -624,6 +687,8 @@ qla2x00_process_completed_request(struct scsi_qla_host *ha, uint32_t index)
624 687
625 /* Save ISP completion status */ 688 /* Save ISP completion status */
626 sp->cmd->result = DID_OK << 16; 689 sp->cmd->result = DID_OK << 16;
690
691 qla2x00_ramp_up_queue_depth(ha, sp);
627 qla2x00_sp_compl(ha, sp); 692 qla2x00_sp_compl(ha, sp);
628 } else { 693 } else {
629 DEBUG2(printk("scsi(%ld): Invalid ISP SCSI completion handle\n", 694 DEBUG2(printk("scsi(%ld): Invalid ISP SCSI completion handle\n",
@@ -823,6 +888,7 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
823 */ 888 */
824 switch (comp_status) { 889 switch (comp_status) {
825 case CS_COMPLETE: 890 case CS_COMPLETE:
891 case CS_QUEUE_FULL:
826 if (scsi_status == 0) { 892 if (scsi_status == 0) {
827 cp->result = DID_OK << 16; 893 cp->result = DID_OK << 16;
828 break; 894 break;
@@ -849,6 +915,20 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
849 } 915 }
850 cp->result = DID_OK << 16 | lscsi_status; 916 cp->result = DID_OK << 16 | lscsi_status;
851 917
918 if (lscsi_status == SAM_STAT_TASK_SET_FULL) {
919 DEBUG2(printk(KERN_INFO
920 "scsi(%ld): QUEUE FULL status detected "
921 "0x%x-0x%x.\n", ha->host_no, comp_status,
922 scsi_status));
923
924 /* Adjust queue depth for all luns on the port. */
925 fcport->last_queue_full = jiffies;
926 spin_unlock_irq(&ha->hardware_lock);
927 starget_for_each_device(cp->device->sdev_target,
928 fcport, qla2x00_adjust_sdev_qdepth_down);
929 spin_lock_irq(&ha->hardware_lock);
930 break;
931 }
852 if (lscsi_status != SS_CHECK_CONDITION) 932 if (lscsi_status != SS_CHECK_CONDITION)
853 break; 933 break;
854 934
@@ -1066,17 +1146,6 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
1066 qla2x00_mark_device_lost(ha, fcport, 1, 1); 1146 qla2x00_mark_device_lost(ha, fcport, 1, 1);
1067 break; 1147 break;
1068 1148
1069 case CS_QUEUE_FULL:
1070 DEBUG2(printk(KERN_INFO
1071 "scsi(%ld): QUEUE FULL status detected 0x%x-0x%x.\n",
1072 ha->host_no, comp_status, scsi_status));
1073
1074 /* SCSI Mid-Layer handles device queue full */
1075
1076 cp->result = DID_OK << 16 | lscsi_status;
1077
1078 break;
1079
1080 default: 1149 default:
1081 DEBUG3(printk("scsi(%ld): Error detected (unknown status) " 1150 DEBUG3(printk("scsi(%ld): Error detected (unknown status) "
1082 "0x%x-0x%x.\n", ha->host_no, comp_status, scsi_status)); 1151 "0x%x-0x%x.\n", ha->host_no, comp_status, scsi_status));
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 3f20d765563e..208607be78c7 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -61,9 +61,9 @@ MODULE_PARM_DESC(ql2xallocfwdump,
61 "during HBA initialization. Memory allocation requirements " 61 "during HBA initialization. Memory allocation requirements "
62 "vary by ISP type. Default is 1 - allocate memory."); 62 "vary by ISP type. Default is 1 - allocate memory.");
63 63
64int qla2_extended_error_logging; 64int ql2xextended_error_logging;
65module_param(qla2_extended_error_logging, int, S_IRUGO|S_IRUSR); 65module_param(ql2xextended_error_logging, int, S_IRUGO|S_IRUSR);
66MODULE_PARM_DESC(qla2_extended_error_logging, 66MODULE_PARM_DESC(ql2xextended_error_logging,
67 "Option to enable extended error logging, " 67 "Option to enable extended error logging, "
68 "Default is 0 - no logging. 1 - log errors."); 68 "Default is 0 - no logging. 1 - log errors.");
69 69
@@ -77,6 +77,19 @@ MODULE_PARM_DESC(ql2xfdmienable,
77 "Enables FDMI registratons " 77 "Enables FDMI registratons "
78 "Default is 0 - no FDMI. 1 - perfom FDMI."); 78 "Default is 0 - no FDMI. 1 - perfom FDMI.");
79 79
80#define MAX_Q_DEPTH 32
81static int ql2xmaxqdepth = MAX_Q_DEPTH;
82module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR);
83MODULE_PARM_DESC(ql2xmaxqdepth,
84 "Maximum queue depth to report for target devices.");
85
86int ql2xqfullrampup = 120;
87module_param(ql2xqfullrampup, int, S_IRUGO|S_IWUSR);
88MODULE_PARM_DESC(ql2xqfullrampup,
89 "Number of seconds to wait to begin to ramp-up the queue "
90 "depth for a device after a queue-full condition has been "
91 "detected. Default is 120 seconds.");
92
80/* 93/*
81 * SCSI host template entry points 94 * SCSI host template entry points
82 */ 95 */
@@ -1104,9 +1117,9 @@ qla2xxx_slave_configure(struct scsi_device *sdev)
1104 struct fc_rport *rport = starget_to_rport(sdev->sdev_target); 1117 struct fc_rport *rport = starget_to_rport(sdev->sdev_target);
1105 1118
1106 if (sdev->tagged_supported) 1119 if (sdev->tagged_supported)
1107 scsi_activate_tcq(sdev, 32); 1120 scsi_activate_tcq(sdev, ha->max_q_depth);
1108 else 1121 else
1109 scsi_deactivate_tcq(sdev, 32); 1122 scsi_deactivate_tcq(sdev, ha->max_q_depth);
1110 1123
1111 rport->dev_loss_tmo = ha->port_down_retry_count + 5; 1124 rport->dev_loss_tmo = ha->port_down_retry_count + 5;
1112 1125
@@ -1413,6 +1426,10 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1413 ha->link_data_rate = PORT_SPEED_UNKNOWN; 1426 ha->link_data_rate = PORT_SPEED_UNKNOWN;
1414 ha->optrom_size = OPTROM_SIZE_2300; 1427 ha->optrom_size = OPTROM_SIZE_2300;
1415 1428
1429 ha->max_q_depth = MAX_Q_DEPTH;
1430 if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU)
1431 ha->max_q_depth = ql2xmaxqdepth;
1432
1416 /* Assign ISP specific operations. */ 1433 /* Assign ISP specific operations. */
1417 ha->isp_ops.pci_config = qla2100_pci_config; 1434 ha->isp_ops.pci_config = qla2100_pci_config;
1418 ha->isp_ops.reset_chip = qla2x00_reset_chip; 1435 ha->isp_ops.reset_chip = qla2x00_reset_chip;
@@ -1712,8 +1729,10 @@ qla2x00_free_device(scsi_qla_host_t *ha)
1712 if (ha->eft) 1729 if (ha->eft)
1713 qla2x00_trace_control(ha, TC_DISABLE, 0, 0); 1730 qla2x00_trace_control(ha, TC_DISABLE, 0, 0);
1714 1731
1732 ha->flags.online = 0;
1733
1715 /* Stop currently executing firmware. */ 1734 /* Stop currently executing firmware. */
1716 qla2x00_stop_firmware(ha); 1735 qla2x00_try_to_stop_firmware(ha);
1717 1736
1718 /* turn-off interrupts on the card */ 1737 /* turn-off interrupts on the card */
1719 if (ha->interrupts_on) 1738 if (ha->interrupts_on)
@@ -1721,8 +1740,6 @@ qla2x00_free_device(scsi_qla_host_t *ha)
1721 1740
1722 qla2x00_mem_free(ha); 1741 qla2x00_mem_free(ha);
1723 1742
1724 ha->flags.online = 0;
1725
1726 /* Detach interrupts */ 1743 /* Detach interrupts */
1727 if (ha->host->irq) 1744 if (ha->host->irq)
1728 free_irq(ha->host->irq, ha); 1745 free_irq(ha->host->irq, ha);
@@ -2697,7 +2714,7 @@ qla2x00_module_init(void)
2697 2714
2698 /* Derive version string. */ 2715 /* Derive version string. */
2699 strcpy(qla2x00_version_str, QLA2XXX_VERSION); 2716 strcpy(qla2x00_version_str, QLA2XXX_VERSION);
2700 if (qla2_extended_error_logging) 2717 if (ql2xextended_error_logging)
2701 strcat(qla2x00_version_str, "-debug"); 2718 strcat(qla2x00_version_str, "-debug");
2702 2719
2703 qla2xxx_transport_template = 2720 qla2xxx_transport_template =
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index e57bf45a3393..1fa0bce6b24e 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.01.07-k2" 10#define QLA2XXX_VERSION "8.01.07-k3"
11 11
12#define QLA_DRIVER_MAJOR_VER 8 12#define QLA_DRIVER_MAJOR_VER 8
13#define QLA_DRIVER_MINOR_VER 1 13#define QLA_DRIVER_MINOR_VER 1
diff --git a/drivers/scsi/qla4xxx/ql4_dbg.h b/drivers/scsi/qla4xxx/ql4_dbg.h
index 3e99dcfd5a9f..d861c3b411c8 100644
--- a/drivers/scsi/qla4xxx/ql4_dbg.h
+++ b/drivers/scsi/qla4xxx/ql4_dbg.h
@@ -22,14 +22,14 @@
22#endif 22#endif
23 23
24#if defined(QL_DEBUG_LEVEL_2) 24#if defined(QL_DEBUG_LEVEL_2)
25#define DEBUG2(x) do {if(qla4_extended_error_logging == 2) x;} while (0); 25#define DEBUG2(x) do {if(ql4xextended_error_logging == 2) x;} while (0);
26#define DEBUG2_3(x) do {x;} while (0); 26#define DEBUG2_3(x) do {x;} while (0);
27#else /* */ 27#else /* */
28#define DEBUG2(x) do {} while (0); 28#define DEBUG2(x) do {} while (0);
29#endif /* */ 29#endif /* */
30 30
31#if defined(QL_DEBUG_LEVEL_3) 31#if defined(QL_DEBUG_LEVEL_3)
32#define DEBUG3(x) do {if(qla4_extended_error_logging == 3) x;} while (0); 32#define DEBUG3(x) do {if(ql4xextended_error_logging == 3) x;} while (0);
33#else /* */ 33#else /* */
34#define DEBUG3(x) do {} while (0); 34#define DEBUG3(x) do {} while (0);
35#if !defined(QL_DEBUG_LEVEL_2) 35#if !defined(QL_DEBUG_LEVEL_2)
diff --git a/drivers/scsi/qla4xxx/ql4_glbl.h b/drivers/scsi/qla4xxx/ql4_glbl.h
index 2c803edf2de8..1b221ff0f6f7 100644
--- a/drivers/scsi/qla4xxx/ql4_glbl.h
+++ b/drivers/scsi/qla4xxx/ql4_glbl.h
@@ -72,7 +72,7 @@ int qla4xxx_reinitialize_ddb_list(struct scsi_qla_host * ha);
72int qla4xxx_process_ddb_changed(struct scsi_qla_host * ha, 72int qla4xxx_process_ddb_changed(struct scsi_qla_host * ha,
73 uint32_t fw_ddb_index, uint32_t state); 73 uint32_t fw_ddb_index, uint32_t state);
74 74
75extern int qla4_extended_error_logging; 75extern int ql4xextended_error_logging;
76extern int ql4xdiscoverywait; 76extern int ql4xdiscoverywait;
77extern int ql4xdontresethba; 77extern int ql4xdontresethba;
78#endif /* _QLA4x_GBL_H */ 78#endif /* _QLA4x_GBL_H */
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index ef82399c0858..b721dc5dd711 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -701,7 +701,7 @@ void qla4xxx_get_conn_event_log(struct scsi_qla_host * ha)
701 DEBUG3(printk("scsi%ld: Connection Event Log Dump (%d entries):\n", 701 DEBUG3(printk("scsi%ld: Connection Event Log Dump (%d entries):\n",
702 ha->host_no, num_valid_entries)); 702 ha->host_no, num_valid_entries));
703 703
704 if (qla4_extended_error_logging == 3) { 704 if (ql4xextended_error_logging == 3) {
705 if (oldest_entry == 0) { 705 if (oldest_entry == 0) {
706 /* Circular Buffer has not wrapped around */ 706 /* Circular Buffer has not wrapped around */
707 for (i=0; i < num_valid_entries; i++) { 707 for (i=0; i < num_valid_entries; i++) {
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 178fcddcfd81..5b8db6109536 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -34,9 +34,9 @@ MODULE_PARM_DESC(ql4xdontresethba,
34 " default it will reset hba :0" 34 " default it will reset hba :0"
35 " set to 1 to avoid resetting HBA"); 35 " set to 1 to avoid resetting HBA");
36 36
37int qla4_extended_error_logging = 0; /* 0 = off, 1 = log errors */ 37int ql4xextended_error_logging = 0; /* 0 = off, 1 = log errors */
38module_param(qla4_extended_error_logging, int, S_IRUGO | S_IRUSR); 38module_param(ql4xextended_error_logging, int, S_IRUGO | S_IRUSR);
39MODULE_PARM_DESC(qla4_extended_error_logging, 39MODULE_PARM_DESC(ql4xextended_error_logging,
40 "Option to enable extended error logging, " 40 "Option to enable extended error logging, "
41 "Default is 0 - no logging, 1 - debug logging"); 41 "Default is 0 - no logging, 1 - debug logging");
42 42
@@ -1714,7 +1714,7 @@ static int __init qla4xxx_module_init(void)
1714 1714
1715 /* Derive version string. */ 1715 /* Derive version string. */
1716 strcpy(qla4xxx_version_str, QLA4XXX_DRIVER_VERSION); 1716 strcpy(qla4xxx_version_str, QLA4XXX_DRIVER_VERSION);
1717 if (qla4_extended_error_logging) 1717 if (ql4xextended_error_logging)
1718 strcat(qla4xxx_version_str, "-debug"); 1718 strcat(qla4xxx_version_str, "-debug");
1719 1719
1720 qla4xxx_scsi_transport = 1720 qla4xxx_scsi_transport =
@@ -1724,13 +1724,13 @@ static int __init qla4xxx_module_init(void)
1724 goto release_srb_cache; 1724 goto release_srb_cache;
1725 } 1725 }
1726 1726
1727 printk(KERN_INFO "QLogic iSCSI HBA Driver\n");
1728 ret = pci_register_driver(&qla4xxx_pci_driver); 1727 ret = pci_register_driver(&qla4xxx_pci_driver);
1729 if (ret) 1728 if (ret)
1730 goto unregister_transport; 1729 goto unregister_transport;
1731 1730
1732 printk(KERN_INFO "QLogic iSCSI HBA Driver\n"); 1731 printk(KERN_INFO "QLogic iSCSI HBA Driver\n");
1733 return 0; 1732 return 0;
1733
1734unregister_transport: 1734unregister_transport:
1735 iscsi_unregister_transport(&qla4xxx_iscsi_transport); 1735 iscsi_unregister_transport(&qla4xxx_iscsi_transport);
1736release_srb_cache: 1736release_srb_cache:
diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c
index e0725353c99c..2e7db18f5aef 100644
--- a/drivers/scsi/qlogicfas408.c
+++ b/drivers/scsi/qlogicfas408.c
@@ -209,7 +209,7 @@ static int ql_wai(struct qlogicfas408_priv *priv)
209 * caller must hold host lock 209 * caller must hold host lock
210 */ 210 */
211 211
212static void ql_icmd(Scsi_Cmnd * cmd) 212static void ql_icmd(struct scsi_cmnd *cmd)
213{ 213{
214 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); 214 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);
215 int qbase = priv->qbase; 215 int qbase = priv->qbase;
@@ -256,7 +256,7 @@ static void ql_icmd(Scsi_Cmnd * cmd)
256 * Process scsi command - usually after interrupt 256 * Process scsi command - usually after interrupt
257 */ 257 */
258 258
259static unsigned int ql_pcmd(Scsi_Cmnd * cmd) 259static unsigned int ql_pcmd(struct scsi_cmnd *cmd)
260{ 260{
261 unsigned int i, j; 261 unsigned int i, j;
262 unsigned long k; 262 unsigned long k;
@@ -407,7 +407,7 @@ static unsigned int ql_pcmd(Scsi_Cmnd * cmd)
407 407
408static void ql_ihandl(void *dev_id) 408static void ql_ihandl(void *dev_id)
409{ 409{
410 Scsi_Cmnd *icmd; 410 struct scsi_cmnd *icmd;
411 struct Scsi_Host *host = dev_id; 411 struct Scsi_Host *host = dev_id;
412 struct qlogicfas408_priv *priv = get_priv_by_host(host); 412 struct qlogicfas408_priv *priv = get_priv_by_host(host);
413 int qbase = priv->qbase; 413 int qbase = priv->qbase;
@@ -447,7 +447,8 @@ irqreturn_t qlogicfas408_ihandl(int irq, void *dev_id)
447 * Queued command 447 * Queued command
448 */ 448 */
449 449
450int qlogicfas408_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) 450int qlogicfas408_queuecommand(struct scsi_cmnd *cmd,
451 void (*done) (struct scsi_cmnd *))
451{ 452{
452 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); 453 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);
453 if (scmd_id(cmd) == priv->qinitid) { 454 if (scmd_id(cmd) == priv->qinitid) {
@@ -470,9 +471,8 @@ int qlogicfas408_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
470 * Return bios parameters 471 * Return bios parameters
471 */ 472 */
472 473
473int qlogicfas408_biosparam(struct scsi_device * disk, 474int qlogicfas408_biosparam(struct scsi_device *disk, struct block_device *dev,
474 struct block_device *dev, 475 sector_t capacity, int ip[])
475 sector_t capacity, int ip[])
476{ 476{
477/* This should mimic the DOS Qlogic driver's behavior exactly */ 477/* This should mimic the DOS Qlogic driver's behavior exactly */
478 ip[0] = 0x40; 478 ip[0] = 0x40;
@@ -494,7 +494,7 @@ int qlogicfas408_biosparam(struct scsi_device * disk,
494 * Abort a command in progress 494 * Abort a command in progress
495 */ 495 */
496 496
497int qlogicfas408_abort(Scsi_Cmnd * cmd) 497int qlogicfas408_abort(struct scsi_cmnd *cmd)
498{ 498{
499 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); 499 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);
500 priv->qabort = 1; 500 priv->qabort = 1;
@@ -508,7 +508,7 @@ int qlogicfas408_abort(Scsi_Cmnd * cmd)
508 * the PCMCIA qlogic_stub code. This wants fixing 508 * the PCMCIA qlogic_stub code. This wants fixing
509 */ 509 */
510 510
511int qlogicfas408_bus_reset(Scsi_Cmnd * cmd) 511int qlogicfas408_bus_reset(struct scsi_cmnd *cmd)
512{ 512{
513 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd); 513 struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);
514 unsigned long flags; 514 unsigned long flags;
diff --git a/drivers/scsi/qlogicfas408.h b/drivers/scsi/qlogicfas408.h
index 8fd5555c75b1..260626427a32 100644
--- a/drivers/scsi/qlogicfas408.h
+++ b/drivers/scsi/qlogicfas408.h
@@ -75,15 +75,15 @@
75/*----------------------------------------------------------------*/ 75/*----------------------------------------------------------------*/
76 76
77struct qlogicfas408_priv { 77struct qlogicfas408_priv {
78 int qbase; /* Port */ 78 int qbase; /* Port */
79 int qinitid; /* initiator ID */ 79 int qinitid; /* initiator ID */
80 int qabort; /* Flag to cause an abort */ 80 int qabort; /* Flag to cause an abort */
81 int qlirq; /* IRQ being used */ 81 int qlirq; /* IRQ being used */
82 int int_type; /* type of irq, 2 for ISA board, 0 for PCMCIA */ 82 int int_type; /* type of irq, 2 for ISA board, 0 for PCMCIA */
83 char qinfo[80]; /* description */ 83 char qinfo[80]; /* description */
84 Scsi_Cmnd *qlcmd; /* current command being processed */ 84 struct scsi_cmnd *qlcmd; /* current command being processed */
85 struct Scsi_Host *shost; /* pointer back to host */ 85 struct Scsi_Host *shost; /* pointer back to host */
86 struct qlogicfas408_priv *next; /* next private struct */ 86 struct qlogicfas408_priv *next; /* next private struct */
87}; 87};
88 88
89/* The qlogic card uses two register maps - These macros select which one */ 89/* The qlogic card uses two register maps - These macros select which one */
@@ -103,12 +103,13 @@ struct qlogicfas408_priv {
103#define get_priv_by_host(x) (struct qlogicfas408_priv *)&((x)->hostdata[0]) 103#define get_priv_by_host(x) (struct qlogicfas408_priv *)&((x)->hostdata[0])
104 104
105irqreturn_t qlogicfas408_ihandl(int irq, void *dev_id); 105irqreturn_t qlogicfas408_ihandl(int irq, void *dev_id);
106int qlogicfas408_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)); 106int qlogicfas408_queuecommand(struct scsi_cmnd * cmd,
107 void (*done) (struct scsi_cmnd *));
107int qlogicfas408_biosparam(struct scsi_device * disk, 108int qlogicfas408_biosparam(struct scsi_device * disk,
108 struct block_device *dev, 109 struct block_device *dev,
109 sector_t capacity, int ip[]); 110 sector_t capacity, int ip[]);
110int qlogicfas408_abort(Scsi_Cmnd * cmd); 111int qlogicfas408_abort(struct scsi_cmnd * cmd);
111int qlogicfas408_bus_reset(Scsi_Cmnd * cmd); 112int qlogicfas408_bus_reset(struct scsi_cmnd * cmd);
112const char *qlogicfas408_info(struct Scsi_Host *host); 113const char *qlogicfas408_info(struct Scsi_Host *host);
113int qlogicfas408_get_chip_type(int qbase, int int_type); 114int qlogicfas408_get_chip_type(int qbase, int int_type);
114void qlogicfas408_setup(int qbase, int id, int int_type); 115void qlogicfas408_setup(int qbase, int id, int int_type);
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 9c0f35820e3e..30ee3d72c021 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -52,7 +52,7 @@
52#include "scsi_debug.h" 52#include "scsi_debug.h"
53 53
54#define SCSI_DEBUG_VERSION "1.80" 54#define SCSI_DEBUG_VERSION "1.80"
55static const char * scsi_debug_version_date = "20060914"; 55static const char * scsi_debug_version_date = "20061018";
56 56
57/* Additional Sense Code (ASC) used */ 57/* Additional Sense Code (ASC) used */
58#define NO_ADDITIONAL_SENSE 0x0 58#define NO_ADDITIONAL_SENSE 0x0
@@ -254,6 +254,8 @@ static int resp_requests(struct scsi_cmnd * SCpnt,
254 struct sdebug_dev_info * devip); 254 struct sdebug_dev_info * devip);
255static int resp_start_stop(struct scsi_cmnd * scp, 255static int resp_start_stop(struct scsi_cmnd * scp,
256 struct sdebug_dev_info * devip); 256 struct sdebug_dev_info * devip);
257static int resp_report_tgtpgs(struct scsi_cmnd * scp,
258 struct sdebug_dev_info * devip);
257static int resp_readcap(struct scsi_cmnd * SCpnt, 259static int resp_readcap(struct scsi_cmnd * SCpnt,
258 struct sdebug_dev_info * devip); 260 struct sdebug_dev_info * devip);
259static int resp_readcap16(struct scsi_cmnd * SCpnt, 261static int resp_readcap16(struct scsi_cmnd * SCpnt,
@@ -287,9 +289,9 @@ static void __init sdebug_build_parts(unsigned char * ramp);
287static void __init init_all_queued(void); 289static void __init init_all_queued(void);
288static void stop_all_queued(void); 290static void stop_all_queued(void);
289static int stop_queued_cmnd(struct scsi_cmnd * cmnd); 291static int stop_queued_cmnd(struct scsi_cmnd * cmnd);
290static int inquiry_evpd_83(unsigned char * arr, int target_dev_id, 292static int inquiry_evpd_83(unsigned char * arr, int port_group_id,
291 int dev_id_num, const char * dev_id_str, 293 int target_dev_id, int dev_id_num,
292 int dev_id_str_len); 294 const char * dev_id_str, int dev_id_str_len);
293static int inquiry_evpd_88(unsigned char * arr, int target_dev_id); 295static int inquiry_evpd_88(unsigned char * arr, int target_dev_id);
294static int do_create_driverfs_files(void); 296static int do_create_driverfs_files(void);
295static void do_remove_driverfs_files(void); 297static void do_remove_driverfs_files(void);
@@ -422,6 +424,15 @@ int scsi_debug_queuecommand(struct scsi_cmnd * SCpnt, done_funct_t done)
422 } 424 }
423 errsts = resp_readcap16(SCpnt, devip); 425 errsts = resp_readcap16(SCpnt, devip);
424 break; 426 break;
427 case MAINTENANCE_IN:
428 if (MI_REPORT_TARGET_PGS != cmd[1]) {
429 mk_sense_buffer(devip, ILLEGAL_REQUEST,
430 INVALID_OPCODE, 0);
431 errsts = check_condition_result;
432 break;
433 }
434 errsts = resp_report_tgtpgs(SCpnt, devip);
435 break;
425 case READ_16: 436 case READ_16:
426 case READ_12: 437 case READ_12:
427 case READ_10: 438 case READ_10:
@@ -665,8 +676,9 @@ static const char * inq_vendor_id = "Linux ";
665static const char * inq_product_id = "scsi_debug "; 676static const char * inq_product_id = "scsi_debug ";
666static const char * inq_product_rev = "0004"; 677static const char * inq_product_rev = "0004";
667 678
668static int inquiry_evpd_83(unsigned char * arr, int target_dev_id, 679static int inquiry_evpd_83(unsigned char * arr, int port_group_id,
669 int dev_id_num, const char * dev_id_str, 680 int target_dev_id, int dev_id_num,
681 const char * dev_id_str,
670 int dev_id_str_len) 682 int dev_id_str_len)
671{ 683{
672 int num, port_a; 684 int num, port_a;
@@ -720,6 +732,15 @@ static int inquiry_evpd_83(unsigned char * arr, int target_dev_id,
720 arr[num++] = (port_a >> 16) & 0xff; 732 arr[num++] = (port_a >> 16) & 0xff;
721 arr[num++] = (port_a >> 8) & 0xff; 733 arr[num++] = (port_a >> 8) & 0xff;
722 arr[num++] = port_a & 0xff; 734 arr[num++] = port_a & 0xff;
735 /* NAA-5, Target port group identifier */
736 arr[num++] = 0x61; /* proto=sas, binary */
737 arr[num++] = 0x95; /* piv=1, target port group id */
738 arr[num++] = 0x0;
739 arr[num++] = 0x4;
740 arr[num++] = 0;
741 arr[num++] = 0;
742 arr[num++] = (port_group_id >> 8) & 0xff;
743 arr[num++] = port_group_id & 0xff;
723 /* NAA-5, Target device identifier */ 744 /* NAA-5, Target device identifier */
724 arr[num++] = 0x61; /* proto=sas, binary */ 745 arr[num++] = 0x61; /* proto=sas, binary */
725 arr[num++] = 0xa3; /* piv=1, target device, naa */ 746 arr[num++] = 0xa3; /* piv=1, target device, naa */
@@ -928,12 +949,12 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target,
928 struct sdebug_dev_info * devip) 949 struct sdebug_dev_info * devip)
929{ 950{
930 unsigned char pq_pdt; 951 unsigned char pq_pdt;
931 unsigned char arr[SDEBUG_MAX_INQ_ARR_SZ]; 952 unsigned char * arr;
932 unsigned char *cmd = (unsigned char *)scp->cmnd; 953 unsigned char *cmd = (unsigned char *)scp->cmnd;
933 int alloc_len, n; 954 int alloc_len, n, ret;
934 955
935 alloc_len = (cmd[3] << 8) + cmd[4]; 956 alloc_len = (cmd[3] << 8) + cmd[4];
936 memset(arr, 0, SDEBUG_MAX_INQ_ARR_SZ); 957 arr = kzalloc(SDEBUG_MAX_INQ_ARR_SZ, GFP_KERNEL);
937 if (devip->wlun) 958 if (devip->wlun)
938 pq_pdt = 0x1e; /* present, wlun */ 959 pq_pdt = 0x1e; /* present, wlun */
939 else if (scsi_debug_no_lun_0 && (0 == devip->lun)) 960 else if (scsi_debug_no_lun_0 && (0 == devip->lun))
@@ -944,12 +965,15 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target,
944 if (0x2 & cmd[1]) { /* CMDDT bit set */ 965 if (0x2 & cmd[1]) { /* CMDDT bit set */
945 mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB, 966 mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB,
946 0); 967 0);
968 kfree(arr);
947 return check_condition_result; 969 return check_condition_result;
948 } else if (0x1 & cmd[1]) { /* EVPD bit set */ 970 } else if (0x1 & cmd[1]) { /* EVPD bit set */
949 int lu_id_num, target_dev_id, len; 971 int lu_id_num, port_group_id, target_dev_id, len;
950 char lu_id_str[6]; 972 char lu_id_str[6];
951 int host_no = devip->sdbg_host->shost->host_no; 973 int host_no = devip->sdbg_host->shost->host_no;
952 974
975 port_group_id = (((host_no + 1) & 0x7f) << 8) +
976 (devip->channel & 0x7f);
953 if (0 == scsi_debug_vpd_use_hostno) 977 if (0 == scsi_debug_vpd_use_hostno)
954 host_no = 0; 978 host_no = 0;
955 lu_id_num = devip->wlun ? -1 : (((host_no + 1) * 2000) + 979 lu_id_num = devip->wlun ? -1 : (((host_no + 1) * 2000) +
@@ -977,8 +1001,9 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target,
977 memcpy(&arr[4], lu_id_str, len); 1001 memcpy(&arr[4], lu_id_str, len);
978 } else if (0x83 == cmd[2]) { /* device identification */ 1002 } else if (0x83 == cmd[2]) { /* device identification */
979 arr[1] = cmd[2]; /*sanity */ 1003 arr[1] = cmd[2]; /*sanity */
980 arr[3] = inquiry_evpd_83(&arr[4], target_dev_id, 1004 arr[3] = inquiry_evpd_83(&arr[4], port_group_id,
981 lu_id_num, lu_id_str, len); 1005 target_dev_id, lu_id_num,
1006 lu_id_str, len);
982 } else if (0x84 == cmd[2]) { /* Software interface ident. */ 1007 } else if (0x84 == cmd[2]) { /* Software interface ident. */
983 arr[1] = cmd[2]; /*sanity */ 1008 arr[1] = cmd[2]; /*sanity */
984 arr[3] = inquiry_evpd_84(&arr[4]); 1009 arr[3] = inquiry_evpd_84(&arr[4]);
@@ -1012,17 +1037,22 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target,
1012 /* Illegal request, invalid field in cdb */ 1037 /* Illegal request, invalid field in cdb */
1013 mk_sense_buffer(devip, ILLEGAL_REQUEST, 1038 mk_sense_buffer(devip, ILLEGAL_REQUEST,
1014 INVALID_FIELD_IN_CDB, 0); 1039 INVALID_FIELD_IN_CDB, 0);
1040 kfree(arr);
1015 return check_condition_result; 1041 return check_condition_result;
1016 } 1042 }
1017 len = min(((arr[2] << 8) + arr[3]) + 4, alloc_len); 1043 len = min(((arr[2] << 8) + arr[3]) + 4, alloc_len);
1018 return fill_from_dev_buffer(scp, arr, 1044 ret = fill_from_dev_buffer(scp, arr,
1019 min(len, SDEBUG_MAX_INQ_ARR_SZ)); 1045 min(len, SDEBUG_MAX_INQ_ARR_SZ));
1046 kfree(arr);
1047 return ret;
1020 } 1048 }
1021 /* drops through here for a standard inquiry */ 1049 /* drops through here for a standard inquiry */
1022 arr[1] = DEV_REMOVEABLE(target) ? 0x80 : 0; /* Removable disk */ 1050 arr[1] = DEV_REMOVEABLE(target) ? 0x80 : 0; /* Removable disk */
1023 arr[2] = scsi_debug_scsi_level; 1051 arr[2] = scsi_debug_scsi_level;
1024 arr[3] = 2; /* response_data_format==2 */ 1052 arr[3] = 2; /* response_data_format==2 */
1025 arr[4] = SDEBUG_LONG_INQ_SZ - 5; 1053 arr[4] = SDEBUG_LONG_INQ_SZ - 5;
1054 if (0 == scsi_debug_vpd_use_hostno)
1055 arr[5] = 0x10; /* claim: implicit TGPS */
1026 arr[6] = 0x10; /* claim: MultiP */ 1056 arr[6] = 0x10; /* claim: MultiP */
1027 /* arr[6] |= 0x40; ... claim: EncServ (enclosure services) */ 1057 /* arr[6] |= 0x40; ... claim: EncServ (enclosure services) */
1028 arr[7] = 0xa; /* claim: LINKED + CMDQUE */ 1058 arr[7] = 0xa; /* claim: LINKED + CMDQUE */
@@ -1039,8 +1069,10 @@ static int resp_inquiry(struct scsi_cmnd * scp, int target,
1039 arr[n++] = 0x3; arr[n++] = 0x60; /* SSC-2 no version */ 1069 arr[n++] = 0x3; arr[n++] = 0x60; /* SSC-2 no version */
1040 } 1070 }
1041 arr[n++] = 0xc; arr[n++] = 0xf; /* SAS-1.1 rev 10 */ 1071 arr[n++] = 0xc; arr[n++] = 0xf; /* SAS-1.1 rev 10 */
1042 return fill_from_dev_buffer(scp, arr, 1072 ret = fill_from_dev_buffer(scp, arr,
1043 min(alloc_len, SDEBUG_LONG_INQ_SZ)); 1073 min(alloc_len, SDEBUG_LONG_INQ_SZ));
1074 kfree(arr);
1075 return ret;
1044} 1076}
1045 1077
1046static int resp_requests(struct scsi_cmnd * scp, 1078static int resp_requests(struct scsi_cmnd * scp,
@@ -1171,6 +1203,87 @@ static int resp_readcap16(struct scsi_cmnd * scp,
1171 min(alloc_len, SDEBUG_READCAP16_ARR_SZ)); 1203 min(alloc_len, SDEBUG_READCAP16_ARR_SZ));
1172} 1204}
1173 1205
1206#define SDEBUG_MAX_TGTPGS_ARR_SZ 1412
1207
1208static int resp_report_tgtpgs(struct scsi_cmnd * scp,
1209 struct sdebug_dev_info * devip)
1210{
1211 unsigned char *cmd = (unsigned char *)scp->cmnd;
1212 unsigned char * arr;
1213 int host_no = devip->sdbg_host->shost->host_no;
1214 int n, ret, alen, rlen;
1215 int port_group_a, port_group_b, port_a, port_b;
1216
1217 alen = ((cmd[6] << 24) + (cmd[7] << 16) + (cmd[8] << 8)
1218 + cmd[9]);
1219
1220 arr = kzalloc(SDEBUG_MAX_TGTPGS_ARR_SZ, GFP_KERNEL);
1221 /*
1222 * EVPD page 0x88 states we have two ports, one
1223 * real and a fake port with no device connected.
1224 * So we create two port groups with one port each
1225 * and set the group with port B to unavailable.
1226 */
1227 port_a = 0x1; /* relative port A */
1228 port_b = 0x2; /* relative port B */
1229 port_group_a = (((host_no + 1) & 0x7f) << 8) +
1230 (devip->channel & 0x7f);
1231 port_group_b = (((host_no + 1) & 0x7f) << 8) +
1232 (devip->channel & 0x7f) + 0x80;
1233
1234 /*
1235 * The asymmetric access state is cycled according to the host_id.
1236 */
1237 n = 4;
1238 if (0 == scsi_debug_vpd_use_hostno) {
1239 arr[n++] = host_no % 3; /* Asymm access state */
1240 arr[n++] = 0x0F; /* claim: all states are supported */
1241 } else {
1242 arr[n++] = 0x0; /* Active/Optimized path */
1243 arr[n++] = 0x01; /* claim: only support active/optimized paths */
1244 }
1245 arr[n++] = (port_group_a >> 8) & 0xff;
1246 arr[n++] = port_group_a & 0xff;
1247 arr[n++] = 0; /* Reserved */
1248 arr[n++] = 0; /* Status code */
1249 arr[n++] = 0; /* Vendor unique */
1250 arr[n++] = 0x1; /* One port per group */
1251 arr[n++] = 0; /* Reserved */
1252 arr[n++] = 0; /* Reserved */
1253 arr[n++] = (port_a >> 8) & 0xff;
1254 arr[n++] = port_a & 0xff;
1255 arr[n++] = 3; /* Port unavailable */
1256 arr[n++] = 0x08; /* claim: only unavailalbe paths are supported */
1257 arr[n++] = (port_group_b >> 8) & 0xff;
1258 arr[n++] = port_group_b & 0xff;
1259 arr[n++] = 0; /* Reserved */
1260 arr[n++] = 0; /* Status code */
1261 arr[n++] = 0; /* Vendor unique */
1262 arr[n++] = 0x1; /* One port per group */
1263 arr[n++] = 0; /* Reserved */
1264 arr[n++] = 0; /* Reserved */
1265 arr[n++] = (port_b >> 8) & 0xff;
1266 arr[n++] = port_b & 0xff;
1267
1268 rlen = n - 4;
1269 arr[0] = (rlen >> 24) & 0xff;
1270 arr[1] = (rlen >> 16) & 0xff;
1271 arr[2] = (rlen >> 8) & 0xff;
1272 arr[3] = rlen & 0xff;
1273
1274 /*
1275 * Return the smallest value of either
1276 * - The allocated length
1277 * - The constructed command length
1278 * - The maximum array size
1279 */
1280 rlen = min(alen,n);
1281 ret = fill_from_dev_buffer(scp, arr,
1282 min(rlen, SDEBUG_MAX_TGTPGS_ARR_SZ));
1283 kfree(arr);
1284 return ret;
1285}
1286
1174/* <<Following mode page info copied from ST318451LW>> */ 1287/* <<Following mode page info copied from ST318451LW>> */
1175 1288
1176static int resp_err_recov_pg(unsigned char * p, int pcontrol, int target) 1289static int resp_err_recov_pg(unsigned char * p, int pcontrol, int target)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 743f67ed7640..d2c02df12fdc 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1084,7 +1084,7 @@ static void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd)
1084{ 1084{
1085 struct request *req = cmd->request; 1085 struct request *req = cmd->request;
1086 1086
1087 BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd)); 1087 BUILD_BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd));
1088 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); 1088 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd));
1089 cmd->cmd_len = req->cmd_len; 1089 cmd->cmd_len = req->cmd_len;
1090 if (!req->data_len) 1090 if (!req->data_len)
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index e7fe565b96de..e1a91665d1c2 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -192,6 +192,7 @@ static CLASS_DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost
192shost_rd_attr(unique_id, "%u\n"); 192shost_rd_attr(unique_id, "%u\n");
193shost_rd_attr(host_busy, "%hu\n"); 193shost_rd_attr(host_busy, "%hu\n");
194shost_rd_attr(cmd_per_lun, "%hd\n"); 194shost_rd_attr(cmd_per_lun, "%hd\n");
195shost_rd_attr(can_queue, "%hd\n");
195shost_rd_attr(sg_tablesize, "%hu\n"); 196shost_rd_attr(sg_tablesize, "%hu\n");
196shost_rd_attr(unchecked_isa_dma, "%d\n"); 197shost_rd_attr(unchecked_isa_dma, "%d\n");
197shost_rd_attr2(proc_name, hostt->proc_name, "%s\n"); 198shost_rd_attr2(proc_name, hostt->proc_name, "%s\n");
@@ -200,6 +201,7 @@ static struct class_device_attribute *scsi_sysfs_shost_attrs[] = {
200 &class_device_attr_unique_id, 201 &class_device_attr_unique_id,
201 &class_device_attr_host_busy, 202 &class_device_attr_host_busy,
202 &class_device_attr_cmd_per_lun, 203 &class_device_attr_cmd_per_lun,
204 &class_device_attr_can_queue,
203 &class_device_attr_sg_tablesize, 205 &class_device_attr_sg_tablesize,
204 &class_device_attr_unchecked_isa_dma, 206 &class_device_attr_unchecked_isa_dma,
205 &class_device_attr_proc_name, 207 &class_device_attr_proc_name,
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 7b0019cccce3..2d3baa99ca25 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -21,7 +21,6 @@
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */ 22 */
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/mempool.h>
25#include <linux/mutex.h> 24#include <linux/mutex.h>
26#include <net/tcp.h> 25#include <net/tcp.h>
27#include <scsi/scsi.h> 26#include <scsi/scsi.h>
@@ -149,30 +148,6 @@ static DECLARE_TRANSPORT_CLASS(iscsi_connection_class,
149static struct sock *nls; 148static struct sock *nls;
150static DEFINE_MUTEX(rx_queue_mutex); 149static DEFINE_MUTEX(rx_queue_mutex);
151 150
152struct mempool_zone {
153 mempool_t *pool;
154 atomic_t allocated;
155 int size;
156 int hiwat;
157 struct list_head freequeue;
158 spinlock_t freelock;
159};
160
161static struct mempool_zone *z_reply;
162
163/*
164 * Z_MAX_* - actual mempool size allocated at the mempool_zone_init() time
165 * Z_HIWAT_* - zone's high watermark when if_error bit will be set to -ENOMEM
166 * so daemon will notice OOM on NETLINK tranposrt level and will
167 * be able to predict or change operational behavior
168 */
169#define Z_MAX_REPLY 8
170#define Z_HIWAT_REPLY 6
171#define Z_MAX_PDU 8
172#define Z_HIWAT_PDU 6
173#define Z_MAX_ERROR 16
174#define Z_HIWAT_ERROR 12
175
176static LIST_HEAD(sesslist); 151static LIST_HEAD(sesslist);
177static DEFINE_SPINLOCK(sesslock); 152static DEFINE_SPINLOCK(sesslock);
178static LIST_HEAD(connlist); 153static LIST_HEAD(connlist);
@@ -414,59 +389,11 @@ int iscsi_destroy_session(struct iscsi_cls_session *session)
414} 389}
415EXPORT_SYMBOL_GPL(iscsi_destroy_session); 390EXPORT_SYMBOL_GPL(iscsi_destroy_session);
416 391
417static void mempool_zone_destroy(struct mempool_zone *zp)
418{
419 mempool_destroy(zp->pool);
420 kfree(zp);
421}
422
423static void*
424mempool_zone_alloc_skb(gfp_t gfp_mask, void *pool_data)
425{
426 struct mempool_zone *zone = pool_data;
427
428 return alloc_skb(zone->size, gfp_mask);
429}
430
431static void
432mempool_zone_free_skb(void *element, void *pool_data)
433{
434 kfree_skb(element);
435}
436
437static struct mempool_zone *
438mempool_zone_init(unsigned max, unsigned size, unsigned hiwat)
439{
440 struct mempool_zone *zp;
441
442 zp = kzalloc(sizeof(*zp), GFP_KERNEL);
443 if (!zp)
444 return NULL;
445
446 zp->size = size;
447 zp->hiwat = hiwat;
448 INIT_LIST_HEAD(&zp->freequeue);
449 spin_lock_init(&zp->freelock);
450 atomic_set(&zp->allocated, 0);
451
452 zp->pool = mempool_create(max, mempool_zone_alloc_skb,
453 mempool_zone_free_skb, zp);
454 if (!zp->pool) {
455 kfree(zp);
456 return NULL;
457 }
458
459 return zp;
460}
461
462static void iscsi_conn_release(struct device *dev) 392static void iscsi_conn_release(struct device *dev)
463{ 393{
464 struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev); 394 struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev);
465 struct device *parent = conn->dev.parent; 395 struct device *parent = conn->dev.parent;
466 396
467 mempool_zone_destroy(conn->z_pdu);
468 mempool_zone_destroy(conn->z_error);
469
470 kfree(conn); 397 kfree(conn);
471 put_device(parent); 398 put_device(parent);
472} 399}
@@ -476,31 +403,6 @@ static int iscsi_is_conn_dev(const struct device *dev)
476 return dev->release == iscsi_conn_release; 403 return dev->release == iscsi_conn_release;
477} 404}
478 405
479static int iscsi_create_event_pools(struct iscsi_cls_conn *conn)
480{
481 conn->z_pdu = mempool_zone_init(Z_MAX_PDU,
482 NLMSG_SPACE(sizeof(struct iscsi_uevent) +
483 sizeof(struct iscsi_hdr) +
484 DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH),
485 Z_HIWAT_PDU);
486 if (!conn->z_pdu) {
487 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not allocate "
488 "pdu zone for new conn\n");
489 return -ENOMEM;
490 }
491
492 conn->z_error = mempool_zone_init(Z_MAX_ERROR,
493 NLMSG_SPACE(sizeof(struct iscsi_uevent)),
494 Z_HIWAT_ERROR);
495 if (!conn->z_error) {
496 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not allocate "
497 "error zone for new conn\n");
498 mempool_zone_destroy(conn->z_pdu);
499 return -ENOMEM;
500 }
501 return 0;
502}
503
504/** 406/**
505 * iscsi_create_conn - create iscsi class connection 407 * iscsi_create_conn - create iscsi class connection
506 * @session: iscsi cls session 408 * @session: iscsi cls session
@@ -533,12 +435,9 @@ iscsi_create_conn(struct iscsi_cls_session *session, uint32_t cid)
533 conn->transport = transport; 435 conn->transport = transport;
534 conn->cid = cid; 436 conn->cid = cid;
535 437
536 if (iscsi_create_event_pools(conn))
537 goto free_conn;
538
539 /* this is released in the dev's release function */ 438 /* this is released in the dev's release function */
540 if (!get_device(&session->dev)) 439 if (!get_device(&session->dev))
541 goto free_conn_pools; 440 goto free_conn;
542 441
543 snprintf(conn->dev.bus_id, BUS_ID_SIZE, "connection%d:%u", 442 snprintf(conn->dev.bus_id, BUS_ID_SIZE, "connection%d:%u",
544 session->sid, cid); 443 session->sid, cid);
@@ -555,8 +454,6 @@ iscsi_create_conn(struct iscsi_cls_session *session, uint32_t cid)
555 454
556release_parent_ref: 455release_parent_ref:
557 put_device(&session->dev); 456 put_device(&session->dev);
558free_conn_pools:
559
560free_conn: 457free_conn:
561 kfree(conn); 458 kfree(conn);
562 return NULL; 459 return NULL;
@@ -599,81 +496,31 @@ iscsi_if_transport_lookup(struct iscsi_transport *tt)
599 return NULL; 496 return NULL;
600} 497}
601 498
602static inline struct list_head *skb_to_lh(struct sk_buff *skb)
603{
604 return (struct list_head *)&skb->cb;
605}
606
607static void
608mempool_zone_complete(struct mempool_zone *zone)
609{
610 unsigned long flags;
611 struct list_head *lh, *n;
612
613 spin_lock_irqsave(&zone->freelock, flags);
614 list_for_each_safe(lh, n, &zone->freequeue) {
615 struct sk_buff *skb = (struct sk_buff *)((char *)lh -
616 offsetof(struct sk_buff, cb));
617 if (!skb_shared(skb)) {
618 list_del(skb_to_lh(skb));
619 mempool_free(skb, zone->pool);
620 atomic_dec(&zone->allocated);
621 }
622 }
623 spin_unlock_irqrestore(&zone->freelock, flags);
624}
625
626static struct sk_buff*
627mempool_zone_get_skb(struct mempool_zone *zone)
628{
629 struct sk_buff *skb;
630
631 skb = mempool_alloc(zone->pool, GFP_ATOMIC);
632 if (skb)
633 atomic_inc(&zone->allocated);
634 return skb;
635}
636
637static int 499static int
638iscsi_broadcast_skb(struct mempool_zone *zone, struct sk_buff *skb, gfp_t gfp) 500iscsi_broadcast_skb(struct sk_buff *skb, gfp_t gfp)
639{ 501{
640 unsigned long flags;
641 int rc; 502 int rc;
642 503
643 skb_get(skb);
644 rc = netlink_broadcast(nls, skb, 0, 1, gfp); 504 rc = netlink_broadcast(nls, skb, 0, 1, gfp);
645 if (rc < 0) { 505 if (rc < 0) {
646 mempool_free(skb, zone->pool);
647 printk(KERN_ERR "iscsi: can not broadcast skb (%d)\n", rc); 506 printk(KERN_ERR "iscsi: can not broadcast skb (%d)\n", rc);
648 return rc; 507 return rc;
649 } 508 }
650 509
651 spin_lock_irqsave(&zone->freelock, flags);
652 INIT_LIST_HEAD(skb_to_lh(skb));
653 list_add(skb_to_lh(skb), &zone->freequeue);
654 spin_unlock_irqrestore(&zone->freelock, flags);
655 return 0; 510 return 0;
656} 511}
657 512
658static int 513static int
659iscsi_unicast_skb(struct mempool_zone *zone, struct sk_buff *skb, int pid) 514iscsi_unicast_skb(struct sk_buff *skb, int pid)
660{ 515{
661 unsigned long flags;
662 int rc; 516 int rc;
663 517
664 skb_get(skb);
665 rc = netlink_unicast(nls, skb, pid, MSG_DONTWAIT); 518 rc = netlink_unicast(nls, skb, pid, MSG_DONTWAIT);
666 if (rc < 0) { 519 if (rc < 0) {
667 mempool_free(skb, zone->pool);
668 printk(KERN_ERR "iscsi: can not unicast skb (%d)\n", rc); 520 printk(KERN_ERR "iscsi: can not unicast skb (%d)\n", rc);
669 return rc; 521 return rc;
670 } 522 }
671 523
672 spin_lock_irqsave(&zone->freelock, flags);
673 INIT_LIST_HEAD(skb_to_lh(skb));
674 list_add(skb_to_lh(skb), &zone->freequeue);
675 spin_unlock_irqrestore(&zone->freelock, flags);
676
677 return 0; 524 return 0;
678} 525}
679 526
@@ -692,9 +539,7 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
692 if (!priv) 539 if (!priv)
693 return -EINVAL; 540 return -EINVAL;
694 541
695 mempool_zone_complete(conn->z_pdu); 542 skb = alloc_skb(len, GFP_ATOMIC);
696
697 skb = mempool_zone_get_skb(conn->z_pdu);
698 if (!skb) { 543 if (!skb) {
699 iscsi_conn_error(conn, ISCSI_ERR_CONN_FAILED); 544 iscsi_conn_error(conn, ISCSI_ERR_CONN_FAILED);
700 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not deliver " 545 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not deliver "
@@ -707,15 +552,13 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
707 memset(ev, 0, sizeof(*ev)); 552 memset(ev, 0, sizeof(*ev));
708 ev->transport_handle = iscsi_handle(conn->transport); 553 ev->transport_handle = iscsi_handle(conn->transport);
709 ev->type = ISCSI_KEVENT_RECV_PDU; 554 ev->type = ISCSI_KEVENT_RECV_PDU;
710 if (atomic_read(&conn->z_pdu->allocated) >= conn->z_pdu->hiwat)
711 ev->iferror = -ENOMEM;
712 ev->r.recv_req.cid = conn->cid; 555 ev->r.recv_req.cid = conn->cid;
713 ev->r.recv_req.sid = iscsi_conn_get_sid(conn); 556 ev->r.recv_req.sid = iscsi_conn_get_sid(conn);
714 pdu = (char*)ev + sizeof(*ev); 557 pdu = (char*)ev + sizeof(*ev);
715 memcpy(pdu, hdr, sizeof(struct iscsi_hdr)); 558 memcpy(pdu, hdr, sizeof(struct iscsi_hdr));
716 memcpy(pdu + sizeof(struct iscsi_hdr), data, data_size); 559 memcpy(pdu + sizeof(struct iscsi_hdr), data, data_size);
717 560
718 return iscsi_unicast_skb(conn->z_pdu, skb, priv->daemon_pid); 561 return iscsi_unicast_skb(skb, priv->daemon_pid);
719} 562}
720EXPORT_SYMBOL_GPL(iscsi_recv_pdu); 563EXPORT_SYMBOL_GPL(iscsi_recv_pdu);
721 564
@@ -731,9 +574,7 @@ void iscsi_conn_error(struct iscsi_cls_conn *conn, enum iscsi_err error)
731 if (!priv) 574 if (!priv)
732 return; 575 return;
733 576
734 mempool_zone_complete(conn->z_error); 577 skb = alloc_skb(len, GFP_ATOMIC);
735
736 skb = mempool_zone_get_skb(conn->z_error);
737 if (!skb) { 578 if (!skb) {
738 dev_printk(KERN_ERR, &conn->dev, "iscsi: gracefully ignored " 579 dev_printk(KERN_ERR, &conn->dev, "iscsi: gracefully ignored "
739 "conn error (%d)\n", error); 580 "conn error (%d)\n", error);
@@ -744,13 +585,11 @@ void iscsi_conn_error(struct iscsi_cls_conn *conn, enum iscsi_err error)
744 ev = NLMSG_DATA(nlh); 585 ev = NLMSG_DATA(nlh);
745 ev->transport_handle = iscsi_handle(conn->transport); 586 ev->transport_handle = iscsi_handle(conn->transport);
746 ev->type = ISCSI_KEVENT_CONN_ERROR; 587 ev->type = ISCSI_KEVENT_CONN_ERROR;
747 if (atomic_read(&conn->z_error->allocated) >= conn->z_error->hiwat)
748 ev->iferror = -ENOMEM;
749 ev->r.connerror.error = error; 588 ev->r.connerror.error = error;
750 ev->r.connerror.cid = conn->cid; 589 ev->r.connerror.cid = conn->cid;
751 ev->r.connerror.sid = iscsi_conn_get_sid(conn); 590 ev->r.connerror.sid = iscsi_conn_get_sid(conn);
752 591
753 iscsi_broadcast_skb(conn->z_error, skb, GFP_ATOMIC); 592 iscsi_broadcast_skb(skb, GFP_ATOMIC);
754 593
755 dev_printk(KERN_INFO, &conn->dev, "iscsi: detected conn error (%d)\n", 594 dev_printk(KERN_INFO, &conn->dev, "iscsi: detected conn error (%d)\n",
756 error); 595 error);
@@ -767,9 +606,7 @@ iscsi_if_send_reply(int pid, int seq, int type, int done, int multi,
767 int flags = multi ? NLM_F_MULTI : 0; 606 int flags = multi ? NLM_F_MULTI : 0;
768 int t = done ? NLMSG_DONE : type; 607 int t = done ? NLMSG_DONE : type;
769 608
770 mempool_zone_complete(z_reply); 609 skb = alloc_skb(len, GFP_ATOMIC);
771
772 skb = mempool_zone_get_skb(z_reply);
773 /* 610 /*
774 * FIXME: 611 * FIXME:
775 * user is supposed to react on iferror == -ENOMEM; 612 * user is supposed to react on iferror == -ENOMEM;
@@ -780,7 +617,7 @@ iscsi_if_send_reply(int pid, int seq, int type, int done, int multi,
780 nlh = __nlmsg_put(skb, pid, seq, t, (len - sizeof(*nlh)), 0); 617 nlh = __nlmsg_put(skb, pid, seq, t, (len - sizeof(*nlh)), 0);
781 nlh->nlmsg_flags = flags; 618 nlh->nlmsg_flags = flags;
782 memcpy(NLMSG_DATA(nlh), payload, size); 619 memcpy(NLMSG_DATA(nlh), payload, size);
783 return iscsi_unicast_skb(z_reply, skb, pid); 620 return iscsi_unicast_skb(skb, pid);
784} 621}
785 622
786static int 623static int
@@ -810,9 +647,7 @@ iscsi_if_get_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
810 do { 647 do {
811 int actual_size; 648 int actual_size;
812 649
813 mempool_zone_complete(conn->z_pdu); 650 skbstat = alloc_skb(len, GFP_ATOMIC);
814
815 skbstat = mempool_zone_get_skb(conn->z_pdu);
816 if (!skbstat) { 651 if (!skbstat) {
817 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not " 652 dev_printk(KERN_ERR, &conn->dev, "iscsi: can not "
818 "deliver stats: OOM\n"); 653 "deliver stats: OOM\n");
@@ -825,8 +660,6 @@ iscsi_if_get_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
825 memset(evstat, 0, sizeof(*evstat)); 660 memset(evstat, 0, sizeof(*evstat));
826 evstat->transport_handle = iscsi_handle(conn->transport); 661 evstat->transport_handle = iscsi_handle(conn->transport);
827 evstat->type = nlh->nlmsg_type; 662 evstat->type = nlh->nlmsg_type;
828 if (atomic_read(&conn->z_pdu->allocated) >= conn->z_pdu->hiwat)
829 evstat->iferror = -ENOMEM;
830 evstat->u.get_stats.cid = 663 evstat->u.get_stats.cid =
831 ev->u.get_stats.cid; 664 ev->u.get_stats.cid;
832 evstat->u.get_stats.sid = 665 evstat->u.get_stats.sid =
@@ -845,7 +678,7 @@ iscsi_if_get_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
845 skb_trim(skbstat, NLMSG_ALIGN(actual_size)); 678 skb_trim(skbstat, NLMSG_ALIGN(actual_size));
846 nlhstat->nlmsg_len = actual_size; 679 nlhstat->nlmsg_len = actual_size;
847 680
848 err = iscsi_unicast_skb(conn->z_pdu, skbstat, priv->daemon_pid); 681 err = iscsi_unicast_skb(skbstat, priv->daemon_pid);
849 } while (err < 0 && err != -ECONNREFUSED); 682 } while (err < 0 && err != -ECONNREFUSED);
850 683
851 return err; 684 return err;
@@ -876,9 +709,7 @@ int iscsi_if_destroy_session_done(struct iscsi_cls_conn *conn)
876 session = iscsi_dev_to_session(conn->dev.parent); 709 session = iscsi_dev_to_session(conn->dev.parent);
877 shost = iscsi_session_to_shost(session); 710 shost = iscsi_session_to_shost(session);
878 711
879 mempool_zone_complete(conn->z_pdu); 712 skb = alloc_skb(len, GFP_KERNEL);
880
881 skb = mempool_zone_get_skb(conn->z_pdu);
882 if (!skb) { 713 if (!skb) {
883 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of " 714 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "
884 "session creation event\n"); 715 "session creation event\n");
@@ -896,7 +727,7 @@ int iscsi_if_destroy_session_done(struct iscsi_cls_conn *conn)
896 * this will occur if the daemon is not up, so we just warn 727 * this will occur if the daemon is not up, so we just warn
897 * the user and when the daemon is restarted it will handle it 728 * the user and when the daemon is restarted it will handle it
898 */ 729 */
899 rc = iscsi_broadcast_skb(conn->z_pdu, skb, GFP_KERNEL); 730 rc = iscsi_broadcast_skb(skb, GFP_KERNEL);
900 if (rc < 0) 731 if (rc < 0)
901 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of " 732 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "
902 "session destruction event. Check iscsi daemon\n"); 733 "session destruction event. Check iscsi daemon\n");
@@ -939,9 +770,7 @@ int iscsi_if_create_session_done(struct iscsi_cls_conn *conn)
939 session = iscsi_dev_to_session(conn->dev.parent); 770 session = iscsi_dev_to_session(conn->dev.parent);
940 shost = iscsi_session_to_shost(session); 771 shost = iscsi_session_to_shost(session);
941 772
942 mempool_zone_complete(conn->z_pdu); 773 skb = alloc_skb(len, GFP_KERNEL);
943
944 skb = mempool_zone_get_skb(conn->z_pdu);
945 if (!skb) { 774 if (!skb) {
946 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of " 775 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "
947 "session creation event\n"); 776 "session creation event\n");
@@ -959,7 +788,7 @@ int iscsi_if_create_session_done(struct iscsi_cls_conn *conn)
959 * this will occur if the daemon is not up, so we just warn 788 * this will occur if the daemon is not up, so we just warn
960 * the user and when the daemon is restarted it will handle it 789 * the user and when the daemon is restarted it will handle it
961 */ 790 */
962 rc = iscsi_broadcast_skb(conn->z_pdu, skb, GFP_KERNEL); 791 rc = iscsi_broadcast_skb(skb, GFP_KERNEL);
963 if (rc < 0) 792 if (rc < 0)
964 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of " 793 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "
965 "session creation event. Check iscsi daemon\n"); 794 "session creation event. Check iscsi daemon\n");
@@ -1278,9 +1107,6 @@ iscsi_if_rx(struct sock *sk, int len)
1278 err = iscsi_if_send_reply( 1107 err = iscsi_if_send_reply(
1279 NETLINK_CREDS(skb)->pid, nlh->nlmsg_seq, 1108 NETLINK_CREDS(skb)->pid, nlh->nlmsg_seq,
1280 nlh->nlmsg_type, 0, 0, ev, sizeof(*ev)); 1109 nlh->nlmsg_type, 0, 0, ev, sizeof(*ev));
1281 if (atomic_read(&z_reply->allocated) >=
1282 z_reply->hiwat)
1283 ev->iferror = -ENOMEM;
1284 } while (err < 0 && err != -ECONNREFUSED); 1110 } while (err < 0 && err != -ECONNREFUSED);
1285 skb_pull(skb, rlen); 1111 skb_pull(skb, rlen);
1286 } 1112 }
@@ -1584,32 +1410,6 @@ int iscsi_unregister_transport(struct iscsi_transport *tt)
1584} 1410}
1585EXPORT_SYMBOL_GPL(iscsi_unregister_transport); 1411EXPORT_SYMBOL_GPL(iscsi_unregister_transport);
1586 1412
1587static int
1588iscsi_rcv_nl_event(struct notifier_block *this, unsigned long event, void *ptr)
1589{
1590 struct netlink_notify *n = ptr;
1591
1592 if (event == NETLINK_URELEASE &&
1593 n->protocol == NETLINK_ISCSI && n->pid) {
1594 struct iscsi_cls_conn *conn;
1595 unsigned long flags;
1596
1597 mempool_zone_complete(z_reply);
1598 spin_lock_irqsave(&connlock, flags);
1599 list_for_each_entry(conn, &connlist, conn_list) {
1600 mempool_zone_complete(conn->z_error);
1601 mempool_zone_complete(conn->z_pdu);
1602 }
1603 spin_unlock_irqrestore(&connlock, flags);
1604 }
1605
1606 return NOTIFY_DONE;
1607}
1608
1609static struct notifier_block iscsi_nl_notifier = {
1610 .notifier_call = iscsi_rcv_nl_event,
1611};
1612
1613static __init int iscsi_transport_init(void) 1413static __init int iscsi_transport_init(void)
1614{ 1414{
1615 int err; 1415 int err;
@@ -1633,25 +1433,15 @@ static __init int iscsi_transport_init(void)
1633 if (err) 1433 if (err)
1634 goto unregister_conn_class; 1434 goto unregister_conn_class;
1635 1435
1636 err = netlink_register_notifier(&iscsi_nl_notifier);
1637 if (err)
1638 goto unregister_session_class;
1639
1640 nls = netlink_kernel_create(NETLINK_ISCSI, 1, iscsi_if_rx, 1436 nls = netlink_kernel_create(NETLINK_ISCSI, 1, iscsi_if_rx,
1641 THIS_MODULE); 1437 THIS_MODULE);
1642 if (!nls) { 1438 if (!nls) {
1643 err = -ENOBUFS; 1439 err = -ENOBUFS;
1644 goto unregister_notifier; 1440 goto unregister_session_class;
1645 } 1441 }
1646 1442
1647 z_reply = mempool_zone_init(Z_MAX_REPLY, 1443 return 0;
1648 NLMSG_SPACE(sizeof(struct iscsi_uevent)), Z_HIWAT_REPLY);
1649 if (z_reply)
1650 return 0;
1651 1444
1652 sock_release(nls->sk_socket);
1653unregister_notifier:
1654 netlink_unregister_notifier(&iscsi_nl_notifier);
1655unregister_session_class: 1445unregister_session_class:
1656 transport_class_unregister(&iscsi_session_class); 1446 transport_class_unregister(&iscsi_session_class);
1657unregister_conn_class: 1447unregister_conn_class:
@@ -1665,9 +1455,7 @@ unregister_transport_class:
1665 1455
1666static void __exit iscsi_transport_exit(void) 1456static void __exit iscsi_transport_exit(void)
1667{ 1457{
1668 mempool_zone_destroy(z_reply);
1669 sock_release(nls->sk_socket); 1458 sock_release(nls->sk_socket);
1670 netlink_unregister_notifier(&iscsi_nl_notifier);
1671 transport_class_unregister(&iscsi_connection_class); 1459 transport_class_unregister(&iscsi_connection_class);
1672 transport_class_unregister(&iscsi_session_class); 1460 transport_class_unregister(&iscsi_session_class);
1673 transport_class_unregister(&iscsi_host_class); 1461 transport_class_unregister(&iscsi_host_class);
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 3babdc76b3fb..e1a52c525ed4 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -1177,7 +1177,10 @@ static int st_open(struct inode *inode, struct file *filp)
1177 goto err_out; 1177 goto err_out;
1178 if ((filp->f_flags & O_NONBLOCK) == 0 && 1178 if ((filp->f_flags & O_NONBLOCK) == 0 &&
1179 retval != CHKRES_READY) { 1179 retval != CHKRES_READY) {
1180 retval = (-EIO); 1180 if (STp->ready == NO_TAPE)
1181 retval = (-ENOMEDIUM);
1182 else
1183 retval = (-EIO);
1181 goto err_out; 1184 goto err_out;
1182 } 1185 }
1183 return 0; 1186 return 0;
diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c
index 5ec5af8e3379..3b3f3050a877 100644
--- a/drivers/scsi/sun3_NCR5380.c
+++ b/drivers/scsi/sun3_NCR5380.c
@@ -266,8 +266,8 @@ static struct scsi_host_template *the_template = NULL;
266 (struct NCR5380_hostdata *)(in)->hostdata 266 (struct NCR5380_hostdata *)(in)->hostdata
267#define HOSTDATA(in) ((struct NCR5380_hostdata *)(in)->hostdata) 267#define HOSTDATA(in) ((struct NCR5380_hostdata *)(in)->hostdata)
268 268
269#define NEXT(cmd) ((Scsi_Cmnd *)((cmd)->host_scribble)) 269#define NEXT(cmd) ((struct scsi_cmnd *)((cmd)->host_scribble))
270#define NEXTADDR(cmd) ((Scsi_Cmnd **)&((cmd)->host_scribble)) 270#define NEXTADDR(cmd) ((struct scsi_cmnd **)&((cmd)->host_scribble))
271 271
272#define HOSTNO instance->host_no 272#define HOSTNO instance->host_no
273#define H_NO(cmd) (cmd)->device->host->host_no 273#define H_NO(cmd) (cmd)->device->host->host_no
@@ -360,7 +360,7 @@ static void __init init_tags( void )
360 * conditions. 360 * conditions.
361 */ 361 */
362 362
363static int is_lun_busy( Scsi_Cmnd *cmd, int should_be_tagged ) 363static int is_lun_busy(struct scsi_cmnd *cmd, int should_be_tagged)
364{ 364{
365 SETUP_HOSTDATA(cmd->device->host); 365 SETUP_HOSTDATA(cmd->device->host);
366 366
@@ -384,7 +384,7 @@ static int is_lun_busy( Scsi_Cmnd *cmd, int should_be_tagged )
384 * untagged. 384 * untagged.
385 */ 385 */
386 386
387static void cmd_get_tag( Scsi_Cmnd *cmd, int should_be_tagged ) 387static void cmd_get_tag(struct scsi_cmnd *cmd, int should_be_tagged)
388{ 388{
389 SETUP_HOSTDATA(cmd->device->host); 389 SETUP_HOSTDATA(cmd->device->host);
390 390
@@ -416,7 +416,7 @@ static void cmd_get_tag( Scsi_Cmnd *cmd, int should_be_tagged )
416 * unlock the LUN. 416 * unlock the LUN.
417 */ 417 */
418 418
419static void cmd_free_tag( Scsi_Cmnd *cmd ) 419static void cmd_free_tag(struct scsi_cmnd *cmd)
420{ 420{
421 SETUP_HOSTDATA(cmd->device->host); 421 SETUP_HOSTDATA(cmd->device->host);
422 422
@@ -460,18 +460,18 @@ static void free_all_tags( void )
460 460
461 461
462/* 462/*
463 * Function: void merge_contiguous_buffers( Scsi_Cmnd *cmd ) 463 * Function: void merge_contiguous_buffers(struct scsi_cmnd *cmd)
464 * 464 *
465 * Purpose: Try to merge several scatter-gather requests into one DMA 465 * Purpose: Try to merge several scatter-gather requests into one DMA
466 * transfer. This is possible if the scatter buffers lie on 466 * transfer. This is possible if the scatter buffers lie on
467 * physical contiguous addresses. 467 * physical contiguous addresses.
468 * 468 *
469 * Parameters: Scsi_Cmnd *cmd 469 * Parameters: struct scsi_cmnd *cmd
470 * The command to work on. The first scatter buffer's data are 470 * The command to work on. The first scatter buffer's data are
471 * assumed to be already transfered into ptr/this_residual. 471 * assumed to be already transfered into ptr/this_residual.
472 */ 472 */
473 473
474static void merge_contiguous_buffers( Scsi_Cmnd *cmd ) 474static void merge_contiguous_buffers(struct scsi_cmnd *cmd)
475{ 475{
476 unsigned long endaddr; 476 unsigned long endaddr;
477#if (NDEBUG & NDEBUG_MERGING) 477#if (NDEBUG & NDEBUG_MERGING)
@@ -501,15 +501,15 @@ static void merge_contiguous_buffers( Scsi_Cmnd *cmd )
501} 501}
502 502
503/* 503/*
504 * Function : void initialize_SCp(Scsi_Cmnd *cmd) 504 * Function : void initialize_SCp(struct scsi_cmnd *cmd)
505 * 505 *
506 * Purpose : initialize the saved data pointers for cmd to point to the 506 * Purpose : initialize the saved data pointers for cmd to point to the
507 * start of the buffer. 507 * start of the buffer.
508 * 508 *
509 * Inputs : cmd - Scsi_Cmnd structure to have pointers reset. 509 * Inputs : cmd - struct scsi_cmnd structure to have pointers reset.
510 */ 510 */
511 511
512static __inline__ void initialize_SCp(Scsi_Cmnd *cmd) 512static __inline__ void initialize_SCp(struct scsi_cmnd *cmd)
513{ 513{
514 /* 514 /*
515 * Initialize the Scsi Pointer field so that all of the commands in the 515 * Initialize the Scsi Pointer field so that all of the commands in the
@@ -753,14 +753,15 @@ static void NCR5380_print_status (struct Scsi_Host *instance)
753 do { if (pos + strlen(fmt) + 20 /* slop */ < buffer + length) \ 753 do { if (pos + strlen(fmt) + 20 /* slop */ < buffer + length) \
754 pos += sprintf(pos, fmt , ## args); } while(0) 754 pos += sprintf(pos, fmt , ## args); } while(0)
755static 755static
756char *lprint_Scsi_Cmnd (Scsi_Cmnd *cmd, char *pos, char *buffer, int length); 756char *lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, char *pos, char *buffer,
757 int length);
757 758
758static int NCR5380_proc_info (struct Scsi_Host *instance, char *buffer, char **start, 759static int NCR5380_proc_info(struct Scsi_Host *instance, char *buffer,
759 off_t offset, int length, int inout) 760 char **start, off_t offset, int length, int inout)
760{ 761{
761 char *pos = buffer; 762 char *pos = buffer;
762 struct NCR5380_hostdata *hostdata; 763 struct NCR5380_hostdata *hostdata;
763 Scsi_Cmnd *ptr; 764 struct scsi_cmnd *ptr;
764 unsigned long flags; 765 unsigned long flags;
765 off_t begin = 0; 766 off_t begin = 0;
766#define check_offset() \ 767#define check_offset() \
@@ -784,18 +785,19 @@ static int NCR5380_proc_info (struct Scsi_Host *instance, char *buffer, char **s
784 if (!hostdata->connected) 785 if (!hostdata->connected)
785 SPRINTF("scsi%d: no currently connected command\n", HOSTNO); 786 SPRINTF("scsi%d: no currently connected command\n", HOSTNO);
786 else 787 else
787 pos = lprint_Scsi_Cmnd ((Scsi_Cmnd *) hostdata->connected, 788 pos = lprint_Scsi_Cmnd ((struct scsi_cmnd *) hostdata->connected,
788 pos, buffer, length); 789 pos, buffer, length);
789 SPRINTF("scsi%d: issue_queue\n", HOSTNO); 790 SPRINTF("scsi%d: issue_queue\n", HOSTNO);
790 check_offset(); 791 check_offset();
791 for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = NEXT(ptr)) { 792 for (ptr = (struct scsi_cmnd *) hostdata->issue_queue; ptr; ptr = NEXT(ptr))
793 {
792 pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length); 794 pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length);
793 check_offset(); 795 check_offset();
794 } 796 }
795 797
796 SPRINTF("scsi%d: disconnected_queue\n", HOSTNO); 798 SPRINTF("scsi%d: disconnected_queue\n", HOSTNO);
797 check_offset(); 799 check_offset();
798 for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; 800 for (ptr = (struct scsi_cmnd *) hostdata->disconnected_queue; ptr;
799 ptr = NEXT(ptr)) { 801 ptr = NEXT(ptr)) {
800 pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length); 802 pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length);
801 check_offset(); 803 check_offset();
@@ -810,8 +812,8 @@ static int NCR5380_proc_info (struct Scsi_Host *instance, char *buffer, char **s
810 return length; 812 return length;
811} 813}
812 814
813static char * 815static char *lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, char *pos, char *buffer,
814lprint_Scsi_Cmnd (Scsi_Cmnd *cmd, char *pos, char *buffer, int length) 816 int length)
815{ 817{
816 int i, s; 818 int i, s;
817 unsigned char *command; 819 unsigned char *command;
@@ -888,8 +890,8 @@ static int NCR5380_init (struct Scsi_Host *instance, int flags)
888} 890}
889 891
890/* 892/*
891 * Function : int NCR5380_queue_command (Scsi_Cmnd *cmd, 893 * Function : int NCR5380_queue_command (struct scsi_cmnd *cmd,
892 * void (*done)(Scsi_Cmnd *)) 894 * void (*done)(struct scsi_cmnd *))
893 * 895 *
894 * Purpose : enqueues a SCSI command 896 * Purpose : enqueues a SCSI command
895 * 897 *
@@ -906,10 +908,11 @@ static int NCR5380_init (struct Scsi_Host *instance, int flags)
906 */ 908 */
907 909
908/* Only make static if a wrapper function is used */ 910/* Only make static if a wrapper function is used */
909static int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) 911static int NCR5380_queue_command(struct scsi_cmnd *cmd,
912 void (*done)(struct scsi_cmnd *))
910{ 913{
911 SETUP_HOSTDATA(cmd->device->host); 914 SETUP_HOSTDATA(cmd->device->host);
912 Scsi_Cmnd *tmp; 915 struct scsi_cmnd *tmp;
913 unsigned long flags; 916 unsigned long flags;
914 917
915#if (NDEBUG & NDEBUG_NO_WRITE) 918#if (NDEBUG & NDEBUG_NO_WRITE)
@@ -990,7 +993,7 @@ static int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
990 NEXT(cmd) = hostdata->issue_queue; 993 NEXT(cmd) = hostdata->issue_queue;
991 hostdata->issue_queue = cmd; 994 hostdata->issue_queue = cmd;
992 } else { 995 } else {
993 for (tmp = (Scsi_Cmnd *)hostdata->issue_queue; 996 for (tmp = (struct scsi_cmnd *)hostdata->issue_queue;
994 NEXT(tmp); tmp = NEXT(tmp)) 997 NEXT(tmp); tmp = NEXT(tmp))
995 ; 998 ;
996 LIST(cmd, tmp); 999 LIST(cmd, tmp);
@@ -1030,7 +1033,7 @@ static int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
1030 1033
1031static void NCR5380_main (void *bl) 1034static void NCR5380_main (void *bl)
1032{ 1035{
1033 Scsi_Cmnd *tmp, *prev; 1036 struct scsi_cmnd *tmp, *prev;
1034 struct Scsi_Host *instance = first_instance; 1037 struct Scsi_Host *instance = first_instance;
1035 struct NCR5380_hostdata *hostdata = HOSTDATA(instance); 1038 struct NCR5380_hostdata *hostdata = HOSTDATA(instance);
1036 int done; 1039 int done;
@@ -1073,12 +1076,12 @@ static void NCR5380_main (void *bl)
1073 * for a target that's not busy. 1076 * for a target that's not busy.
1074 */ 1077 */
1075#if (NDEBUG & NDEBUG_LISTS) 1078#if (NDEBUG & NDEBUG_LISTS)
1076 for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, prev = NULL; 1079 for (tmp = (struct scsi_cmnd *) hostdata->issue_queue, prev = NULL;
1077 tmp && (tmp != prev); prev = tmp, tmp = NEXT(tmp)) 1080 tmp && (tmp != prev); prev = tmp, tmp = NEXT(tmp))
1078 ; 1081 ;
1079 if ((tmp == prev) && tmp) printk(" LOOP\n");/* else printk("\n");*/ 1082 if ((tmp == prev) && tmp) printk(" LOOP\n");/* else printk("\n");*/
1080#endif 1083#endif
1081 for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, 1084 for (tmp = (struct scsi_cmnd *) hostdata->issue_queue,
1082 prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp) ) { 1085 prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp) ) {
1083 1086
1084#if (NDEBUG & NDEBUG_LISTS) 1087#if (NDEBUG & NDEBUG_LISTS)
@@ -1339,7 +1342,8 @@ static irqreturn_t NCR5380_intr (int irq, void *dev_id)
1339} 1342}
1340 1343
1341#ifdef NCR5380_STATS 1344#ifdef NCR5380_STATS
1342static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd* cmd) 1345static void collect_stats(struct NCR5380_hostdata *hostdata,
1346 struct scsi_cmnd *cmd)
1343{ 1347{
1344# ifdef NCR5380_STAT_LIMIT 1348# ifdef NCR5380_STAT_LIMIT
1345 if (cmd->request_bufflen > NCR5380_STAT_LIMIT) 1349 if (cmd->request_bufflen > NCR5380_STAT_LIMIT)
@@ -1365,8 +1369,8 @@ static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd* cmd)
1365#endif 1369#endif
1366 1370
1367/* 1371/*
1368 * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, 1372 * Function : int NCR5380_select(struct Scsi_Host *instance,
1369 * int tag); 1373 * struct scsi_cmnd *cmd, int tag);
1370 * 1374 *
1371 * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command, 1375 * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command,
1372 * including ARBITRATION, SELECTION, and initial message out for 1376 * including ARBITRATION, SELECTION, and initial message out for
@@ -1395,7 +1399,8 @@ static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd* cmd)
1395 * cmd->result host byte set to DID_BAD_TARGET. 1399 * cmd->result host byte set to DID_BAD_TARGET.
1396 */ 1400 */
1397 1401
1398static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag) 1402static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd,
1403 int tag)
1399{ 1404{
1400 SETUP_HOSTDATA(instance); 1405 SETUP_HOSTDATA(instance);
1401 unsigned char tmp[3], phase; 1406 unsigned char tmp[3], phase;
@@ -1985,7 +1990,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
1985#endif 1990#endif
1986 unsigned char *data; 1991 unsigned char *data;
1987 unsigned char phase, tmp, extended_msg[10], old_phase=0xff; 1992 unsigned char phase, tmp, extended_msg[10], old_phase=0xff;
1988 Scsi_Cmnd *cmd = (Scsi_Cmnd *) hostdata->connected; 1993 struct scsi_cmnd *cmd = (struct scsi_cmnd *) hostdata->connected;
1989 1994
1990#ifdef SUN3_SCSI_VME 1995#ifdef SUN3_SCSI_VME
1991 dregs->csr |= CSR_INTR; 1996 dregs->csr |= CSR_INTR;
@@ -2272,7 +2277,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
2272 local_irq_save(flags); 2277 local_irq_save(flags);
2273 LIST(cmd,hostdata->issue_queue); 2278 LIST(cmd,hostdata->issue_queue);
2274 NEXT(cmd) = hostdata->issue_queue; 2279 NEXT(cmd) = hostdata->issue_queue;
2275 hostdata->issue_queue = (Scsi_Cmnd *) cmd; 2280 hostdata->issue_queue = (struct scsi_cmnd *) cmd;
2276 local_irq_restore(flags); 2281 local_irq_restore(flags);
2277 QU_PRINTK("scsi%d: REQUEST SENSE added to head of " 2282 QU_PRINTK("scsi%d: REQUEST SENSE added to head of "
2278 "issue queue\n", H_NO(cmd)); 2283 "issue queue\n", H_NO(cmd));
@@ -2502,7 +2507,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
2502 * Function : void NCR5380_reselect (struct Scsi_Host *instance) 2507 * Function : void NCR5380_reselect (struct Scsi_Host *instance)
2503 * 2508 *
2504 * Purpose : does reselection, initializing the instance->connected 2509 * Purpose : does reselection, initializing the instance->connected
2505 * field to point to the Scsi_Cmnd for which the I_T_L or I_T_L_Q 2510 * field to point to the struct scsi_cmnd for which the I_T_L or I_T_L_Q
2506 * nexus has been reestablished, 2511 * nexus has been reestablished,
2507 * 2512 *
2508 * Inputs : instance - this instance of the NCR5380. 2513 * Inputs : instance - this instance of the NCR5380.
@@ -2521,7 +2526,7 @@ static void NCR5380_reselect (struct Scsi_Host *instance)
2521 unsigned char tag; 2526 unsigned char tag;
2522#endif 2527#endif
2523 unsigned char msg[3]; 2528 unsigned char msg[3];
2524 Scsi_Cmnd *tmp = NULL, *prev; 2529 struct scsi_cmnd *tmp = NULL, *prev;
2525/* unsigned long flags; */ 2530/* unsigned long flags; */
2526 2531
2527 /* 2532 /*
@@ -2577,7 +2582,7 @@ static void NCR5380_reselect (struct Scsi_Host *instance)
2577 * just reestablished, and remove it from the disconnected queue. 2582 * just reestablished, and remove it from the disconnected queue.
2578 */ 2583 */
2579 2584
2580 for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL; 2585 for (tmp = (struct scsi_cmnd *) hostdata->disconnected_queue, prev = NULL;
2581 tmp; prev = tmp, tmp = NEXT(tmp) ) { 2586 tmp; prev = tmp, tmp = NEXT(tmp) ) {
2582 if ((target_mask == (1 << tmp->device->id)) && (lun == tmp->device->lun) 2587 if ((target_mask == (1 << tmp->device->id)) && (lun == tmp->device->lun)
2583#ifdef SUPPORT_TAGS 2588#ifdef SUPPORT_TAGS
@@ -2668,11 +2673,11 @@ static void NCR5380_reselect (struct Scsi_Host *instance)
2668 2673
2669 2674
2670/* 2675/*
2671 * Function : int NCR5380_abort (Scsi_Cmnd *cmd) 2676 * Function : int NCR5380_abort(struct scsi_cmnd *cmd)
2672 * 2677 *
2673 * Purpose : abort a command 2678 * Purpose : abort a command
2674 * 2679 *
2675 * Inputs : cmd - the Scsi_Cmnd to abort, code - code to set the 2680 * Inputs : cmd - the struct scsi_cmnd to abort, code - code to set the
2676 * host byte of the result field to, if zero DID_ABORTED is 2681 * host byte of the result field to, if zero DID_ABORTED is
2677 * used. 2682 * used.
2678 * 2683 *
@@ -2684,11 +2689,11 @@ static void NCR5380_reselect (struct Scsi_Host *instance)
2684 * called where the loop started in NCR5380_main(). 2689 * called where the loop started in NCR5380_main().
2685 */ 2690 */
2686 2691
2687static int NCR5380_abort (Scsi_Cmnd *cmd) 2692static int NCR5380_abort(struct scsi_cmnd *cmd)
2688{ 2693{
2689 struct Scsi_Host *instance = cmd->device->host; 2694 struct Scsi_Host *instance = cmd->device->host;
2690 SETUP_HOSTDATA(instance); 2695 SETUP_HOSTDATA(instance);
2691 Scsi_Cmnd *tmp, **prev; 2696 struct scsi_cmnd *tmp, **prev;
2692 unsigned long flags; 2697 unsigned long flags;
2693 2698
2694 printk(KERN_NOTICE "scsi%d: aborting command\n", HOSTNO); 2699 printk(KERN_NOTICE "scsi%d: aborting command\n", HOSTNO);
@@ -2753,9 +2758,9 @@ static int NCR5380_abort (Scsi_Cmnd *cmd)
2753 * Case 2 : If the command hasn't been issued yet, we simply remove it 2758 * Case 2 : If the command hasn't been issued yet, we simply remove it
2754 * from the issue queue. 2759 * from the issue queue.
2755 */ 2760 */
2756 for (prev = (Scsi_Cmnd **) &(hostdata->issue_queue), 2761 for (prev = (struct scsi_cmnd **) &(hostdata->issue_queue),
2757 tmp = (Scsi_Cmnd *) hostdata->issue_queue; 2762 tmp = (struct scsi_cmnd *) hostdata->issue_queue;
2758 tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp) ) 2763 tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp))
2759 if (cmd == tmp) { 2764 if (cmd == tmp) {
2760 REMOVE(5, *prev, tmp, NEXT(tmp)); 2765 REMOVE(5, *prev, tmp, NEXT(tmp));
2761 (*prev) = NEXT(tmp); 2766 (*prev) = NEXT(tmp);
@@ -2812,7 +2817,7 @@ static int NCR5380_abort (Scsi_Cmnd *cmd)
2812 * it from the disconnected queue. 2817 * it from the disconnected queue.
2813 */ 2818 */
2814 2819
2815 for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp; 2820 for (tmp = (struct scsi_cmnd *) hostdata->disconnected_queue; tmp;
2816 tmp = NEXT(tmp)) 2821 tmp = NEXT(tmp))
2817 if (cmd == tmp) { 2822 if (cmd == tmp) {
2818 local_irq_restore(flags); 2823 local_irq_restore(flags);
@@ -2826,8 +2831,8 @@ static int NCR5380_abort (Scsi_Cmnd *cmd)
2826 do_abort (instance); 2831 do_abort (instance);
2827 2832
2828 local_irq_save(flags); 2833 local_irq_save(flags);
2829 for (prev = (Scsi_Cmnd **) &(hostdata->disconnected_queue), 2834 for (prev = (struct scsi_cmnd **) &(hostdata->disconnected_queue),
2830 tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; 2835 tmp = (struct scsi_cmnd *) hostdata->disconnected_queue;
2831 tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp) ) 2836 tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp) )
2832 if (cmd == tmp) { 2837 if (cmd == tmp) {
2833 REMOVE(5, *prev, tmp, NEXT(tmp)); 2838 REMOVE(5, *prev, tmp, NEXT(tmp));
@@ -2868,7 +2873,7 @@ static int NCR5380_abort (Scsi_Cmnd *cmd)
2868 2873
2869 2874
2870/* 2875/*
2871 * Function : int NCR5380_bus_reset (Scsi_Cmnd *cmd) 2876 * Function : int NCR5380_bus_reset(struct scsi_cmnd *cmd)
2872 * 2877 *
2873 * Purpose : reset the SCSI bus. 2878 * Purpose : reset the SCSI bus.
2874 * 2879 *
@@ -2876,13 +2881,13 @@ static int NCR5380_abort (Scsi_Cmnd *cmd)
2876 * 2881 *
2877 */ 2882 */
2878 2883
2879static int NCR5380_bus_reset( Scsi_Cmnd *cmd) 2884static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
2880{ 2885{
2881 SETUP_HOSTDATA(cmd->device->host); 2886 SETUP_HOSTDATA(cmd->device->host);
2882 int i; 2887 int i;
2883 unsigned long flags; 2888 unsigned long flags;
2884#if 1 2889#if 1
2885 Scsi_Cmnd *connected, *disconnected_queue; 2890 struct scsi_cmnd *connected, *disconnected_queue;
2886#endif 2891#endif
2887 2892
2888 2893
@@ -2914,9 +2919,9 @@ static int NCR5380_bus_reset( Scsi_Cmnd *cmd)
2914 * remembered in local variables first. 2919 * remembered in local variables first.
2915 */ 2920 */
2916 local_irq_save(flags); 2921 local_irq_save(flags);
2917 connected = (Scsi_Cmnd *)hostdata->connected; 2922 connected = (struct scsi_cmnd *)hostdata->connected;
2918 hostdata->connected = NULL; 2923 hostdata->connected = NULL;
2919 disconnected_queue = (Scsi_Cmnd *)hostdata->disconnected_queue; 2924 disconnected_queue = (struct scsi_cmnd *)hostdata->disconnected_queue;
2920 hostdata->disconnected_queue = NULL; 2925 hostdata->disconnected_queue = NULL;
2921#ifdef SUPPORT_TAGS 2926#ifdef SUPPORT_TAGS
2922 free_all_tags(); 2927 free_all_tags();
diff --git a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c
index e625b4c5833a..d56d85dd9ba0 100644
--- a/drivers/scsi/sun3_scsi.c
+++ b/drivers/scsi/sun3_scsi.c
@@ -119,7 +119,7 @@ module_param(setup_use_tagged_queuing, int, 0);
119static int setup_hostid = -1; 119static int setup_hostid = -1;
120module_param(setup_hostid, int, 0); 120module_param(setup_hostid, int, 0);
121 121
122static Scsi_Cmnd *sun3_dma_setup_done = NULL; 122static struct scsi_cmnd *sun3_dma_setup_done = NULL;
123 123
124#define AFTER_RESET_DELAY (HZ/2) 124#define AFTER_RESET_DELAY (HZ/2)
125 125
@@ -521,8 +521,9 @@ static inline unsigned long sun3scsi_dma_residual(struct Scsi_Host *instance)
521 return last_residual; 521 return last_residual;
522} 522}
523 523
524static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted, Scsi_Cmnd *cmd, 524static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted,
525 int write_flag) 525 struct scsi_cmnd *cmd,
526 int write_flag)
526{ 527{
527 if(blk_fs_request(cmd->request)) 528 if(blk_fs_request(cmd->request))
528 return wanted; 529 return wanted;
diff --git a/drivers/scsi/sun3_scsi.h b/drivers/scsi/sun3_scsi.h
index 834dab428019..a1103b3e2034 100644
--- a/drivers/scsi/sun3_scsi.h
+++ b/drivers/scsi/sun3_scsi.h
@@ -47,11 +47,12 @@
47 47
48#define IOBASE_SUN3_VMESCSI 0xff200000 48#define IOBASE_SUN3_VMESCSI 0xff200000
49 49
50static int sun3scsi_abort (Scsi_Cmnd *); 50static int sun3scsi_abort(struct scsi_cmnd *);
51static int sun3scsi_detect (struct scsi_host_template *); 51static int sun3scsi_detect (struct scsi_host_template *);
52static const char *sun3scsi_info (struct Scsi_Host *); 52static const char *sun3scsi_info (struct Scsi_Host *);
53static int sun3scsi_bus_reset(Scsi_Cmnd *); 53static int sun3scsi_bus_reset(struct scsi_cmnd *);
54static int sun3scsi_queue_command (Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 54static int sun3scsi_queue_command(struct scsi_cmnd *,
55 void (*done)(struct scsi_cmnd *));
55static int sun3scsi_release (struct Scsi_Host *); 56static int sun3scsi_release (struct Scsi_Host *);
56 57
57#ifndef CMD_PER_LUN 58#ifndef CMD_PER_LUN
diff --git a/drivers/scsi/sun3_scsi_vme.c b/drivers/scsi/sun3_scsi_vme.c
index e8faab16567b..92def310a84c 100644
--- a/drivers/scsi/sun3_scsi_vme.c
+++ b/drivers/scsi/sun3_scsi_vme.c
@@ -84,7 +84,7 @@ module_param(setup_use_tagged_queuing, int, 0);
84static int setup_hostid = -1; 84static int setup_hostid = -1;
85module_param(setup_hostid, int, 0); 85module_param(setup_hostid, int, 0);
86 86
87static Scsi_Cmnd *sun3_dma_setup_done = NULL; 87static struct scsi_cmnd *sun3_dma_setup_done = NULL;
88 88
89#define AFTER_RESET_DELAY (HZ/2) 89#define AFTER_RESET_DELAY (HZ/2)
90 90
@@ -455,8 +455,9 @@ static inline unsigned long sun3scsi_dma_residual(struct Scsi_Host *instance)
455 return last_residual; 455 return last_residual;
456} 456}
457 457
458static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted, Scsi_Cmnd *cmd, 458static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted,
459 int write_flag) 459 struct scsi_cmnd *cmd,
460 int write_flag)
460{ 461{
461 if(blk_fs_request(cmd->request)) 462 if(blk_fs_request(cmd->request))
462 return wanted; 463 return wanted;
diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
index d03aa6ce8fe8..fa5382e354be 100644
--- a/drivers/scsi/tmscsim.c
+++ b/drivers/scsi/tmscsim.c
@@ -2304,6 +2304,7 @@ static struct scsi_host_template driver_template = {
2304 .sg_tablesize = SG_ALL, 2304 .sg_tablesize = SG_ALL,
2305 .cmd_per_lun = 1, 2305 .cmd_per_lun = 1,
2306 .use_clustering = ENABLE_CLUSTERING, 2306 .use_clustering = ENABLE_CLUSTERING,
2307 .max_sectors = 0x4000, /* 8MiB = 16 * 1024 * 512 */
2307}; 2308};
2308 2309
2309/*********************************************************************** 2310/***********************************************************************
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 401192e56e50..61eebec00a7b 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -136,7 +136,6 @@ struct iscsi_conn {
136 136
137 /* control data */ 137 /* control data */
138 int id; /* CID */ 138 int id; /* CID */
139 struct list_head item; /* maintains list of conns */
140 int c_stage; /* connection state */ 139 int c_stage; /* connection state */
141 /* 140 /*
142 * Preallocated buffer for pdus that have data but do not 141 * Preallocated buffer for pdus that have data but do not
@@ -235,10 +234,8 @@ struct iscsi_session {
235 * - mgmtpool, * 234 * - mgmtpool, *
236 * - r2tpool */ 235 * - r2tpool */
237 int state; /* session state */ 236 int state; /* session state */
238 struct list_head item;
239 int age; /* counts session re-opens */ 237 int age; /* counts session re-opens */
240 238
241 struct list_head connections; /* list of connections */
242 int cmds_max; /* size of cmds array */ 239 int cmds_max; /* size of cmds array */
243 struct iscsi_cmd_task **cmds; /* Original Cmds arr */ 240 struct iscsi_cmd_task **cmds; /* Original Cmds arr */
244 struct iscsi_queue cmdpool; /* PDU's pool */ 241 struct iscsi_queue cmdpool; /* PDU's pool */
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 84a6d5fe0920..5c0e9791441c 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -97,6 +97,7 @@ extern const unsigned char scsi_command_size[8];
97#define PERSISTENT_RESERVE_IN 0x5e 97#define PERSISTENT_RESERVE_IN 0x5e
98#define PERSISTENT_RESERVE_OUT 0x5f 98#define PERSISTENT_RESERVE_OUT 0x5f
99#define REPORT_LUNS 0xa0 99#define REPORT_LUNS 0xa0
100#define MAINTENANCE_IN 0xa3
100#define MOVE_MEDIUM 0xa5 101#define MOVE_MEDIUM 0xa5
101#define EXCHANGE_MEDIUM 0xa6 102#define EXCHANGE_MEDIUM 0xa6
102#define READ_12 0xa8 103#define READ_12 0xa8
@@ -114,6 +115,8 @@ extern const unsigned char scsi_command_size[8];
114#define SERVICE_ACTION_IN 0x9e 115#define SERVICE_ACTION_IN 0x9e
115/* values for service action in */ 116/* values for service action in */
116#define SAI_READ_CAPACITY_16 0x10 117#define SAI_READ_CAPACITY_16 0x10
118/* values for maintenance in */
119#define MI_REPORT_TARGET_PGS 0x0a
117 120
118/* Values for T10/04-262r7 */ 121/* Values for T10/04-262r7 */
119#define ATA_16 0x85 /* 16-byte pass-thru */ 122#define ATA_16 0x85 /* 16-byte pass-thru */
@@ -430,7 +433,7 @@ struct scsi_lun {
430#define SCSI_IOCTL_GET_PCI 0x5387 433#define SCSI_IOCTL_GET_PCI 0x5387
431 434
432/* Pull a u32 out of a SCSI message (using BE SCSI conventions) */ 435/* Pull a u32 out of a SCSI message (using BE SCSI conventions) */
433static inline u32 scsi_to_u32(u8 *ptr) 436static inline __u32 scsi_to_u32(__u8 *ptr)
434{ 437{
435 return (ptr[0]<<24) + (ptr[1]<<16) + (ptr[2]<<8) + ptr[3]; 438 return (ptr[0]<<24) + (ptr[1]<<16) + (ptr[2]<<8) + ptr[3];
436} 439}
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 39e833260bd0..4b95c89c95c9 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -29,7 +29,6 @@
29struct scsi_transport_template; 29struct scsi_transport_template;
30struct iscsi_transport; 30struct iscsi_transport;
31struct Scsi_Host; 31struct Scsi_Host;
32struct mempool_zone;
33struct iscsi_cls_conn; 32struct iscsi_cls_conn;
34struct iscsi_conn; 33struct iscsi_conn;
35struct iscsi_cmd_task; 34struct iscsi_cmd_task;
@@ -157,9 +156,6 @@ struct iscsi_cls_conn {
157 156
158 int active; /* must be accessed with the connlock */ 157 int active; /* must be accessed with the connlock */
159 struct device dev; /* sysfs transport/container device */ 158 struct device dev; /* sysfs transport/container device */
160 struct mempool_zone *z_error;
161 struct mempool_zone *z_pdu;
162 struct list_head freequeue;
163}; 159};
164 160
165#define iscsi_dev_to_conn(_dev) \ 161#define iscsi_dev_to_conn(_dev) \