diff options
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/3w-9xxx.c | 3 | ||||
-rw-r--r-- | drivers/scsi/3w-xxxx.c | 3 | ||||
-rw-r--r-- | drivers/scsi/aacraid/linit.c | 3 | ||||
-rw-r--r-- | drivers/scsi/aic94xx/aic94xx_sds.c | 12 | ||||
-rw-r--r-- | drivers/scsi/aic94xx/aic94xx_sds.h | 4 | ||||
-rw-r--r-- | drivers/scsi/aic94xx/aic94xx_seq.c | 7 | ||||
-rw-r--r-- | drivers/scsi/arm/Kconfig | 2 | ||||
-rw-r--r-- | drivers/scsi/arm/acornscsi-io.S | 15 | ||||
-rw-r--r-- | drivers/scsi/arm/acornscsi.c | 426 | ||||
-rw-r--r-- | drivers/scsi/arm/acornscsi.h | 9 | ||||
-rw-r--r-- | drivers/scsi/ch.c | 4 | ||||
-rw-r--r-- | drivers/scsi/dpt_i2o.c | 5 | ||||
-rw-r--r-- | drivers/scsi/esp_scsi.c | 22 | ||||
-rw-r--r-- | drivers/scsi/gdth.c | 3 | ||||
-rw-r--r-- | drivers/scsi/ide-scsi.c | 302 | ||||
-rw-r--r-- | drivers/scsi/ipr.c | 6 | ||||
-rw-r--r-- | drivers/scsi/megaraid.c | 5 | ||||
-rw-r--r-- | drivers/scsi/megaraid/megaraid_mm.c | 2 | ||||
-rw-r--r-- | drivers/scsi/megaraid/megaraid_sas.c | 2 | ||||
-rw-r--r-- | drivers/scsi/osst.c | 15 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 9 | ||||
-rw-r--r-- | drivers/scsi/scsi_tgt_if.c | 2 | ||||
-rw-r--r-- | drivers/scsi/ses.c | 2 | ||||
-rw-r--r-- | drivers/scsi/sg.c | 60 | ||||
-rw-r--r-- | drivers/scsi/sr.c | 20 | ||||
-rw-r--r-- | drivers/scsi/st.c | 11 |
26 files changed, 407 insertions, 547 deletions
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index 867f6fd5c2c0..7045511f9ad2 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c | |||
@@ -84,6 +84,7 @@ | |||
84 | #include <linux/pci.h> | 84 | #include <linux/pci.h> |
85 | #include <linux/time.h> | 85 | #include <linux/time.h> |
86 | #include <linux/mutex.h> | 86 | #include <linux/mutex.h> |
87 | #include <linux/smp_lock.h> | ||
87 | #include <asm/io.h> | 88 | #include <asm/io.h> |
88 | #include <asm/irq.h> | 89 | #include <asm/irq.h> |
89 | #include <asm/uaccess.h> | 90 | #include <asm/uaccess.h> |
@@ -862,11 +863,13 @@ out: | |||
862 | } /* End twa_chrdev_ioctl() */ | 863 | } /* End twa_chrdev_ioctl() */ |
863 | 864 | ||
864 | /* This function handles open for the character device */ | 865 | /* This function handles open for the character device */ |
866 | /* NOTE that this function will race with remove. */ | ||
865 | static int twa_chrdev_open(struct inode *inode, struct file *file) | 867 | static int twa_chrdev_open(struct inode *inode, struct file *file) |
866 | { | 868 | { |
867 | unsigned int minor_number; | 869 | unsigned int minor_number; |
868 | int retval = TW_IOCTL_ERROR_OS_ENODEV; | 870 | int retval = TW_IOCTL_ERROR_OS_ENODEV; |
869 | 871 | ||
872 | cycle_kernel_lock(); | ||
870 | minor_number = iminor(inode); | 873 | minor_number = iminor(inode); |
871 | if (minor_number >= twa_device_extension_count) | 874 | if (minor_number >= twa_device_extension_count) |
872 | goto out; | 875 | goto out; |
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index 8c22329aa85e..a0537f09aa21 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c | |||
@@ -198,6 +198,7 @@ | |||
198 | 198 | ||
199 | #include <linux/module.h> | 199 | #include <linux/module.h> |
200 | #include <linux/reboot.h> | 200 | #include <linux/reboot.h> |
201 | #include <linux/smp_lock.h> | ||
201 | #include <linux/spinlock.h> | 202 | #include <linux/spinlock.h> |
202 | #include <linux/interrupt.h> | 203 | #include <linux/interrupt.h> |
203 | #include <linux/moduleparam.h> | 204 | #include <linux/moduleparam.h> |
@@ -1027,10 +1028,12 @@ out: | |||
1027 | } /* End tw_chrdev_ioctl() */ | 1028 | } /* End tw_chrdev_ioctl() */ |
1028 | 1029 | ||
1029 | /* This function handles open for the character device */ | 1030 | /* This function handles open for the character device */ |
1031 | /* NOTE that this function races with remove. */ | ||
1030 | static int tw_chrdev_open(struct inode *inode, struct file *file) | 1032 | static int tw_chrdev_open(struct inode *inode, struct file *file) |
1031 | { | 1033 | { |
1032 | unsigned int minor_number; | 1034 | unsigned int minor_number; |
1033 | 1035 | ||
1036 | cycle_kernel_lock(); | ||
1034 | dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n"); | 1037 | dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n"); |
1035 | 1038 | ||
1036 | minor_number = iminor(inode); | 1039 | minor_number = iminor(inode); |
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 1f7c83607f84..68c140e82673 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/moduleparam.h> | 38 | #include <linux/moduleparam.h> |
39 | #include <linux/pci.h> | 39 | #include <linux/pci.h> |
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/smp_lock.h> | ||
41 | #include <linux/spinlock.h> | 42 | #include <linux/spinlock.h> |
42 | #include <linux/syscalls.h> | 43 | #include <linux/syscalls.h> |
43 | #include <linux/delay.h> | 44 | #include <linux/delay.h> |
@@ -667,6 +668,7 @@ static int aac_cfg_open(struct inode *inode, struct file *file) | |||
667 | unsigned minor_number = iminor(inode); | 668 | unsigned minor_number = iminor(inode); |
668 | int err = -ENODEV; | 669 | int err = -ENODEV; |
669 | 670 | ||
671 | lock_kernel(); /* BKL pushdown: nothing else protects this list */ | ||
670 | list_for_each_entry(aac, &aac_devices, entry) { | 672 | list_for_each_entry(aac, &aac_devices, entry) { |
671 | if (aac->id == minor_number) { | 673 | if (aac->id == minor_number) { |
672 | file->private_data = aac; | 674 | file->private_data = aac; |
@@ -674,6 +676,7 @@ static int aac_cfg_open(struct inode *inode, struct file *file) | |||
674 | break; | 676 | break; |
675 | } | 677 | } |
676 | } | 678 | } |
679 | unlock_kernel(); | ||
677 | 680 | ||
678 | return err; | 681 | return err; |
679 | } | 682 | } |
diff --git a/drivers/scsi/aic94xx/aic94xx_sds.c b/drivers/scsi/aic94xx/aic94xx_sds.c index 4446e3d584dc..8630a75b2872 100644 --- a/drivers/scsi/aic94xx/aic94xx_sds.c +++ b/drivers/scsi/aic94xx/aic94xx_sds.c | |||
@@ -1093,9 +1093,9 @@ out: | |||
1093 | * @bytes_to_verify: total bytes to verify | 1093 | * @bytes_to_verify: total bytes to verify |
1094 | */ | 1094 | */ |
1095 | int asd_verify_flash_seg(struct asd_ha_struct *asd_ha, | 1095 | int asd_verify_flash_seg(struct asd_ha_struct *asd_ha, |
1096 | void *src, u32 dest_offset, u32 bytes_to_verify) | 1096 | const void *src, u32 dest_offset, u32 bytes_to_verify) |
1097 | { | 1097 | { |
1098 | u8 *src_buf; | 1098 | const u8 *src_buf; |
1099 | u8 flash_char; | 1099 | u8 flash_char; |
1100 | int err; | 1100 | int err; |
1101 | u32 nv_offset, reg, i; | 1101 | u32 nv_offset, reg, i; |
@@ -1105,7 +1105,7 @@ int asd_verify_flash_seg(struct asd_ha_struct *asd_ha, | |||
1105 | 1105 | ||
1106 | err = FLASH_OK; | 1106 | err = FLASH_OK; |
1107 | nv_offset = dest_offset; | 1107 | nv_offset = dest_offset; |
1108 | src_buf = (u8 *)src; | 1108 | src_buf = (const u8 *)src; |
1109 | for (i = 0; i < bytes_to_verify; i++) { | 1109 | for (i = 0; i < bytes_to_verify; i++) { |
1110 | flash_char = asd_read_reg_byte(asd_ha, reg + nv_offset + i); | 1110 | flash_char = asd_read_reg_byte(asd_ha, reg + nv_offset + i); |
1111 | if (flash_char != src_buf[i]) { | 1111 | if (flash_char != src_buf[i]) { |
@@ -1124,9 +1124,9 @@ int asd_verify_flash_seg(struct asd_ha_struct *asd_ha, | |||
1124 | * @bytes_to_write: total bytes to write | 1124 | * @bytes_to_write: total bytes to write |
1125 | */ | 1125 | */ |
1126 | int asd_write_flash_seg(struct asd_ha_struct *asd_ha, | 1126 | int asd_write_flash_seg(struct asd_ha_struct *asd_ha, |
1127 | void *src, u32 dest_offset, u32 bytes_to_write) | 1127 | const void *src, u32 dest_offset, u32 bytes_to_write) |
1128 | { | 1128 | { |
1129 | u8 *src_buf; | 1129 | const u8 *src_buf; |
1130 | u32 nv_offset, reg, i; | 1130 | u32 nv_offset, reg, i; |
1131 | int err; | 1131 | int err; |
1132 | 1132 | ||
@@ -1153,7 +1153,7 @@ int asd_write_flash_seg(struct asd_ha_struct *asd_ha, | |||
1153 | return err; | 1153 | return err; |
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | src_buf = (u8 *)src; | 1156 | src_buf = (const u8 *)src; |
1157 | for (i = 0; i < bytes_to_write; i++) { | 1157 | for (i = 0; i < bytes_to_write; i++) { |
1158 | /* Setup program command sequence */ | 1158 | /* Setup program command sequence */ |
1159 | switch (asd_ha->hw_prof.flash.method) { | 1159 | switch (asd_ha->hw_prof.flash.method) { |
diff --git a/drivers/scsi/aic94xx/aic94xx_sds.h b/drivers/scsi/aic94xx/aic94xx_sds.h index bb9795a04dc3..a06dc0114b8c 100644 --- a/drivers/scsi/aic94xx/aic94xx_sds.h +++ b/drivers/scsi/aic94xx/aic94xx_sds.h | |||
@@ -110,9 +110,9 @@ struct bios_file_header { | |||
110 | }; | 110 | }; |
111 | 111 | ||
112 | int asd_verify_flash_seg(struct asd_ha_struct *asd_ha, | 112 | int asd_verify_flash_seg(struct asd_ha_struct *asd_ha, |
113 | void *src, u32 dest_offset, u32 bytes_to_verify); | 113 | const void *src, u32 dest_offset, u32 bytes_to_verify); |
114 | int asd_write_flash_seg(struct asd_ha_struct *asd_ha, | 114 | int asd_write_flash_seg(struct asd_ha_struct *asd_ha, |
115 | void *src, u32 dest_offset, u32 bytes_to_write); | 115 | const void *src, u32 dest_offset, u32 bytes_to_write); |
116 | int asd_chk_write_status(struct asd_ha_struct *asd_ha, | 116 | int asd_chk_write_status(struct asd_ha_struct *asd_ha, |
117 | u32 sector_addr, u8 erase_flag); | 117 | u32 sector_addr, u8 erase_flag); |
118 | int asd_check_flash_type(struct asd_ha_struct *asd_ha); | 118 | int asd_check_flash_type(struct asd_ha_struct *asd_ha); |
diff --git a/drivers/scsi/aic94xx/aic94xx_seq.c b/drivers/scsi/aic94xx/aic94xx_seq.c index f4272ac4c685..8f98e33155e9 100644 --- a/drivers/scsi/aic94xx/aic94xx_seq.c +++ b/drivers/scsi/aic94xx/aic94xx_seq.c | |||
@@ -46,7 +46,7 @@ | |||
46 | static const struct firmware *sequencer_fw; | 46 | static const struct firmware *sequencer_fw; |
47 | static u16 cseq_vecs[CSEQ_NUM_VECS], lseq_vecs[LSEQ_NUM_VECS], mode2_task, | 47 | static u16 cseq_vecs[CSEQ_NUM_VECS], lseq_vecs[LSEQ_NUM_VECS], mode2_task, |
48 | cseq_idle_loop, lseq_idle_loop; | 48 | cseq_idle_loop, lseq_idle_loop; |
49 | static u8 *cseq_code, *lseq_code; | 49 | static const u8 *cseq_code, *lseq_code; |
50 | static u32 cseq_code_size, lseq_code_size; | 50 | static u32 cseq_code_size, lseq_code_size; |
51 | 51 | ||
52 | static u16 first_scb_site_no = 0xFFFF; | 52 | static u16 first_scb_site_no = 0xFFFF; |
@@ -1235,7 +1235,8 @@ int asd_release_firmware(void) | |||
1235 | static int asd_request_firmware(struct asd_ha_struct *asd_ha) | 1235 | static int asd_request_firmware(struct asd_ha_struct *asd_ha) |
1236 | { | 1236 | { |
1237 | int err, i; | 1237 | int err, i; |
1238 | struct sequencer_file_header header, *hdr_ptr; | 1238 | struct sequencer_file_header header; |
1239 | const struct sequencer_file_header *hdr_ptr; | ||
1239 | u32 csum = 0; | 1240 | u32 csum = 0; |
1240 | u16 *ptr_cseq_vecs, *ptr_lseq_vecs; | 1241 | u16 *ptr_cseq_vecs, *ptr_lseq_vecs; |
1241 | 1242 | ||
@@ -1249,7 +1250,7 @@ static int asd_request_firmware(struct asd_ha_struct *asd_ha) | |||
1249 | if (err) | 1250 | if (err) |
1250 | return err; | 1251 | return err; |
1251 | 1252 | ||
1252 | hdr_ptr = (struct sequencer_file_header *)sequencer_fw->data; | 1253 | hdr_ptr = (const struct sequencer_file_header *)sequencer_fw->data; |
1253 | 1254 | ||
1254 | header.csum = le32_to_cpu(hdr_ptr->csum); | 1255 | header.csum = le32_to_cpu(hdr_ptr->csum); |
1255 | header.major = le32_to_cpu(hdr_ptr->major); | 1256 | header.major = le32_to_cpu(hdr_ptr->major); |
diff --git a/drivers/scsi/arm/Kconfig b/drivers/scsi/arm/Kconfig index 7236143941f3..a8587f1f5e7e 100644 --- a/drivers/scsi/arm/Kconfig +++ b/drivers/scsi/arm/Kconfig | |||
@@ -3,7 +3,7 @@ | |||
3 | # | 3 | # |
4 | config SCSI_ACORNSCSI_3 | 4 | config SCSI_ACORNSCSI_3 |
5 | tristate "Acorn SCSI card (aka30) support" | 5 | tristate "Acorn SCSI card (aka30) support" |
6 | depends on ARCH_ACORN && SCSI && BROKEN | 6 | depends on ARCH_ACORN && SCSI |
7 | select SCSI_SPI_ATTRS | 7 | select SCSI_SPI_ATTRS |
8 | help | 8 | help |
9 | This enables support for the Acorn SCSI card (aka30). If you have an | 9 | This enables support for the Acorn SCSI card (aka30). If you have an |
diff --git a/drivers/scsi/arm/acornscsi-io.S b/drivers/scsi/arm/acornscsi-io.S index 93467e6ac923..5cebe3105260 100644 --- a/drivers/scsi/arm/acornscsi-io.S +++ b/drivers/scsi/arm/acornscsi-io.S | |||
@@ -10,17 +10,10 @@ | |||
10 | #include <asm/assembler.h> | 10 | #include <asm/assembler.h> |
11 | #include <asm/hardware.h> | 11 | #include <asm/hardware.h> |
12 | 12 | ||
13 | #if (IO_BASE == (PCIO_BASE & 0xff000000)) | 13 | #if defined(__APCS_32__) |
14 | #define ADDR(off,reg) \ | 14 | #define LOADREGS(t,r,l...) ldm##t r, l |
15 | tst off, $0x80000000 ;\ | 15 | #elif defined(__APCS_26__) |
16 | mov reg, $IO_BASE ;\ | 16 | #define LOADREGS(t,r,l...) ldm##t r, l##^ |
17 | orreq reg, reg, $(PCIO_BASE & 0x00ff0000) | ||
18 | #else | ||
19 | #define ADDR(off,reg) \ | ||
20 | tst off, $0x80000000 ;\ | ||
21 | movne reg, $IO_BASE ;\ | ||
22 | moveq reg, $(PCIO_BASE & 0xff000000) ;\ | ||
23 | orreq reg, reg, $(PCIO_BASE & 0x00ff0000) | ||
24 | #endif | 17 | #endif |
25 | 18 | ||
26 | @ Purpose: transfer a block of data from the acorn scsi card to memory | 19 | @ Purpose: transfer a block of data from the acorn scsi card to memory |
diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c index 8e53f02cc311..918ccf818757 100644 --- a/drivers/scsi/arm/acornscsi.c +++ b/drivers/scsi/arm/acornscsi.c | |||
@@ -123,12 +123,6 @@ | |||
123 | #define DBG(cmd,xxx...) xxx | 123 | #define DBG(cmd,xxx...) xxx |
124 | #endif | 124 | #endif |
125 | 125 | ||
126 | #ifndef STRINGIFY | ||
127 | #define STRINGIFY(x) #x | ||
128 | #endif | ||
129 | #define STRx(x) STRINGIFY(x) | ||
130 | #define NO_WRITE_STR STRx(NO_WRITE) | ||
131 | |||
132 | #include <linux/module.h> | 126 | #include <linux/module.h> |
133 | #include <linux/kernel.h> | 127 | #include <linux/kernel.h> |
134 | #include <linux/string.h> | 128 | #include <linux/string.h> |
@@ -141,9 +135,10 @@ | |||
141 | #include <linux/interrupt.h> | 135 | #include <linux/interrupt.h> |
142 | #include <linux/init.h> | 136 | #include <linux/init.h> |
143 | #include <linux/bitops.h> | 137 | #include <linux/bitops.h> |
138 | #include <linux/stringify.h> | ||
139 | #include <linux/io.h> | ||
144 | 140 | ||
145 | #include <asm/system.h> | 141 | #include <asm/system.h> |
146 | #include <asm/io.h> | ||
147 | #include <asm/ecard.h> | 142 | #include <asm/ecard.h> |
148 | 143 | ||
149 | #include "../scsi.h" | 144 | #include "../scsi.h" |
@@ -203,44 +198,46 @@ static void acornscsi_abortcmd(AS_Host *host, unsigned char tag); | |||
203 | * Miscellaneous | 198 | * Miscellaneous |
204 | */ | 199 | */ |
205 | 200 | ||
206 | static inline void | 201 | /* Offsets from MEMC base */ |
207 | sbic_arm_write(unsigned int io_port, int reg, int value) | 202 | #define SBIC_REGIDX 0x2000 |
203 | #define SBIC_REGVAL 0x2004 | ||
204 | #define DMAC_OFFSET 0x3000 | ||
205 | |||
206 | /* Offsets from FAST IOC base */ | ||
207 | #define INT_REG 0x2000 | ||
208 | #define PAGE_REG 0x3000 | ||
209 | |||
210 | static inline void sbic_arm_write(AS_Host *host, unsigned int reg, unsigned int value) | ||
208 | { | 211 | { |
209 | __raw_writeb(reg, io_port); | 212 | writeb(reg, host->base + SBIC_REGIDX); |
210 | __raw_writeb(value, io_port + 4); | 213 | writeb(value, host->base + SBIC_REGVAL); |
211 | } | 214 | } |
212 | 215 | ||
213 | #define sbic_arm_writenext(io,val) \ | 216 | static inline int sbic_arm_read(AS_Host *host, unsigned int reg) |
214 | __raw_writeb((val), (io) + 4) | ||
215 | |||
216 | static inline | ||
217 | int sbic_arm_read(unsigned int io_port, int reg) | ||
218 | { | 217 | { |
219 | if(reg == SBIC_ASR) | 218 | if(reg == SBIC_ASR) |
220 | return __raw_readl(io_port) & 255; | 219 | return readl(host->base + SBIC_REGIDX) & 255; |
221 | __raw_writeb(reg, io_port); | 220 | writeb(reg, host->base + SBIC_REGIDX); |
222 | return __raw_readl(io_port + 4) & 255; | 221 | return readl(host->base + SBIC_REGVAL) & 255; |
223 | } | 222 | } |
224 | 223 | ||
225 | #define sbic_arm_readnext(io) \ | 224 | #define sbic_arm_writenext(host, val) writeb((val), (host)->base + SBIC_REGVAL) |
226 | __raw_readb((io) + 4) | 225 | #define sbic_arm_readnext(host) readb((host)->base + SBIC_REGVAL) |
227 | 226 | ||
228 | #ifdef USE_DMAC | 227 | #ifdef USE_DMAC |
229 | #define dmac_read(io_port,reg) \ | 228 | #define dmac_read(host,reg) \ |
230 | inb((io_port) + (reg)) | 229 | readb((host)->base + DMAC_OFFSET + ((reg) << 2)) |
231 | 230 | ||
232 | #define dmac_write(io_port,reg,value) \ | 231 | #define dmac_write(host,reg,value) \ |
233 | ({ outb((value), (io_port) + (reg)); }) | 232 | ({ writeb((value), (host)->base + DMAC_OFFSET + ((reg) << 2)); }) |
234 | 233 | ||
235 | #define dmac_clearintr(io_port) \ | 234 | #define dmac_clearintr(host) writeb(0, (host)->fast + INT_REG) |
236 | ({ outb(0, (io_port)); }) | ||
237 | 235 | ||
238 | static inline | 236 | static inline unsigned int dmac_address(AS_Host *host) |
239 | unsigned int dmac_address(unsigned int io_port) | ||
240 | { | 237 | { |
241 | return dmac_read(io_port, DMAC_TXADRHI) << 16 | | 238 | return dmac_read(host, DMAC_TXADRHI) << 16 | |
242 | dmac_read(io_port, DMAC_TXADRMD) << 8 | | 239 | dmac_read(host, DMAC_TXADRMD) << 8 | |
243 | dmac_read(io_port, DMAC_TXADRLO); | 240 | dmac_read(host, DMAC_TXADRLO); |
244 | } | 241 | } |
245 | 242 | ||
246 | static | 243 | static |
@@ -248,15 +245,15 @@ void acornscsi_dumpdma(AS_Host *host, char *where) | |||
248 | { | 245 | { |
249 | unsigned int mode, addr, len; | 246 | unsigned int mode, addr, len; |
250 | 247 | ||
251 | mode = dmac_read(host->dma.io_port, DMAC_MODECON); | 248 | mode = dmac_read(host, DMAC_MODECON); |
252 | addr = dmac_address(host->dma.io_port); | 249 | addr = dmac_address(host); |
253 | len = dmac_read(host->dma.io_port, DMAC_TXCNTHI) << 8 | | 250 | len = dmac_read(host, DMAC_TXCNTHI) << 8 | |
254 | dmac_read(host->dma.io_port, DMAC_TXCNTLO); | 251 | dmac_read(host, DMAC_TXCNTLO); |
255 | 252 | ||
256 | printk("scsi%d: %s: DMAC %02x @%06x+%04x msk %02x, ", | 253 | printk("scsi%d: %s: DMAC %02x @%06x+%04x msk %02x, ", |
257 | host->host->host_no, where, | 254 | host->host->host_no, where, |
258 | mode, addr, (len + 1) & 0xffff, | 255 | mode, addr, (len + 1) & 0xffff, |
259 | dmac_read(host->dma.io_port, DMAC_MASKREG)); | 256 | dmac_read(host, DMAC_MASKREG)); |
260 | 257 | ||
261 | printk("DMA @%06x, ", host->dma.start_addr); | 258 | printk("DMA @%06x, ", host->dma.start_addr); |
262 | printk("BH @%p +%04x, ", host->scsi.SCp.ptr, | 259 | printk("BH @%p +%04x, ", host->scsi.SCp.ptr, |
@@ -272,9 +269,9 @@ unsigned long acornscsi_sbic_xfcount(AS_Host *host) | |||
272 | { | 269 | { |
273 | unsigned long length; | 270 | unsigned long length; |
274 | 271 | ||
275 | length = sbic_arm_read(host->scsi.io_port, SBIC_TRANSCNTH) << 16; | 272 | length = sbic_arm_read(host, SBIC_TRANSCNTH) << 16; |
276 | length |= sbic_arm_readnext(host->scsi.io_port) << 8; | 273 | length |= sbic_arm_readnext(host) << 8; |
277 | length |= sbic_arm_readnext(host->scsi.io_port); | 274 | length |= sbic_arm_readnext(host); |
278 | 275 | ||
279 | return length; | 276 | return length; |
280 | } | 277 | } |
@@ -285,7 +282,7 @@ acornscsi_sbic_wait(AS_Host *host, int stat_mask, int stat, int timeout, char *m | |||
285 | int asr; | 282 | int asr; |
286 | 283 | ||
287 | do { | 284 | do { |
288 | asr = sbic_arm_read(host->scsi.io_port, SBIC_ASR); | 285 | asr = sbic_arm_read(host, SBIC_ASR); |
289 | 286 | ||
290 | if ((asr & stat_mask) == stat) | 287 | if ((asr & stat_mask) == stat) |
291 | return 0; | 288 | return 0; |
@@ -304,7 +301,7 @@ int acornscsi_sbic_issuecmd(AS_Host *host, int command) | |||
304 | if (acornscsi_sbic_wait(host, ASR_CIP, 0, 1000, "issuing command")) | 301 | if (acornscsi_sbic_wait(host, ASR_CIP, 0, 1000, "issuing command")) |
305 | return -1; | 302 | return -1; |
306 | 303 | ||
307 | sbic_arm_write(host->scsi.io_port, SBIC_CMND, command); | 304 | sbic_arm_write(host, SBIC_CMND, command); |
308 | 305 | ||
309 | return 0; | 306 | return 0; |
310 | } | 307 | } |
@@ -331,20 +328,20 @@ void acornscsi_resetcard(AS_Host *host) | |||
331 | 328 | ||
332 | /* assert reset line */ | 329 | /* assert reset line */ |
333 | host->card.page_reg = 0x80; | 330 | host->card.page_reg = 0x80; |
334 | outb(host->card.page_reg, host->card.io_page); | 331 | writeb(host->card.page_reg, host->fast + PAGE_REG); |
335 | 332 | ||
336 | /* wait 3 cs. SCSI standard says 25ms. */ | 333 | /* wait 3 cs. SCSI standard says 25ms. */ |
337 | acornscsi_csdelay(3); | 334 | acornscsi_csdelay(3); |
338 | 335 | ||
339 | host->card.page_reg = 0; | 336 | host->card.page_reg = 0; |
340 | outb(host->card.page_reg, host->card.io_page); | 337 | writeb(host->card.page_reg, host->fast + PAGE_REG); |
341 | 338 | ||
342 | /* | 339 | /* |
343 | * Should get a reset from the card | 340 | * Should get a reset from the card |
344 | */ | 341 | */ |
345 | timeout = 1000; | 342 | timeout = 1000; |
346 | do { | 343 | do { |
347 | if (inb(host->card.io_intr) & 8) | 344 | if (readb(host->fast + INT_REG) & 8) |
348 | break; | 345 | break; |
349 | udelay(1); | 346 | udelay(1); |
350 | } while (--timeout); | 347 | } while (--timeout); |
@@ -353,19 +350,19 @@ void acornscsi_resetcard(AS_Host *host) | |||
353 | printk("scsi%d: timeout while resetting card\n", | 350 | printk("scsi%d: timeout while resetting card\n", |
354 | host->host->host_no); | 351 | host->host->host_no); |
355 | 352 | ||
356 | sbic_arm_read(host->scsi.io_port, SBIC_ASR); | 353 | sbic_arm_read(host, SBIC_ASR); |
357 | sbic_arm_read(host->scsi.io_port, SBIC_SSR); | 354 | sbic_arm_read(host, SBIC_SSR); |
358 | 355 | ||
359 | /* setup sbic - WD33C93A */ | 356 | /* setup sbic - WD33C93A */ |
360 | sbic_arm_write(host->scsi.io_port, SBIC_OWNID, OWNID_EAF | host->host->this_id); | 357 | sbic_arm_write(host, SBIC_OWNID, OWNID_EAF | host->host->this_id); |
361 | sbic_arm_write(host->scsi.io_port, SBIC_CMND, CMND_RESET); | 358 | sbic_arm_write(host, SBIC_CMND, CMND_RESET); |
362 | 359 | ||
363 | /* | 360 | /* |
364 | * Command should cause a reset interrupt | 361 | * Command should cause a reset interrupt |
365 | */ | 362 | */ |
366 | timeout = 1000; | 363 | timeout = 1000; |
367 | do { | 364 | do { |
368 | if (inb(host->card.io_intr) & 8) | 365 | if (readb(host->fast + INT_REG) & 8) |
369 | break; | 366 | break; |
370 | udelay(1); | 367 | udelay(1); |
371 | } while (--timeout); | 368 | } while (--timeout); |
@@ -374,26 +371,26 @@ void acornscsi_resetcard(AS_Host *host) | |||
374 | printk("scsi%d: timeout while resetting card\n", | 371 | printk("scsi%d: timeout while resetting card\n", |
375 | host->host->host_no); | 372 | host->host->host_no); |
376 | 373 | ||
377 | sbic_arm_read(host->scsi.io_port, SBIC_ASR); | 374 | sbic_arm_read(host, SBIC_ASR); |
378 | if (sbic_arm_read(host->scsi.io_port, SBIC_SSR) != 0x01) | 375 | if (sbic_arm_read(host, SBIC_SSR) != 0x01) |
379 | printk(KERN_CRIT "scsi%d: WD33C93A didn't give enhanced reset interrupt\n", | 376 | printk(KERN_CRIT "scsi%d: WD33C93A didn't give enhanced reset interrupt\n", |
380 | host->host->host_no); | 377 | host->host->host_no); |
381 | 378 | ||
382 | sbic_arm_write(host->scsi.io_port, SBIC_CTRL, INIT_SBICDMA | CTRL_IDI); | 379 | sbic_arm_write(host, SBIC_CTRL, INIT_SBICDMA | CTRL_IDI); |
383 | sbic_arm_write(host->scsi.io_port, SBIC_TIMEOUT, TIMEOUT_TIME); | 380 | sbic_arm_write(host, SBIC_TIMEOUT, TIMEOUT_TIME); |
384 | sbic_arm_write(host->scsi.io_port, SBIC_SYNCHTRANSFER, SYNCHTRANSFER_2DBA); | 381 | sbic_arm_write(host, SBIC_SYNCHTRANSFER, SYNCHTRANSFER_2DBA); |
385 | sbic_arm_write(host->scsi.io_port, SBIC_SOURCEID, SOURCEID_ER | SOURCEID_DSP); | 382 | sbic_arm_write(host, SBIC_SOURCEID, SOURCEID_ER | SOURCEID_DSP); |
386 | 383 | ||
387 | host->card.page_reg = 0x40; | 384 | host->card.page_reg = 0x40; |
388 | outb(host->card.page_reg, host->card.io_page); | 385 | writeb(host->card.page_reg, host->fast + PAGE_REG); |
389 | 386 | ||
390 | /* setup dmac - uPC71071 */ | 387 | /* setup dmac - uPC71071 */ |
391 | dmac_write(host->dma.io_port, DMAC_INIT, 0); | 388 | dmac_write(host, DMAC_INIT, 0); |
392 | #ifdef USE_DMAC | 389 | #ifdef USE_DMAC |
393 | dmac_write(host->dma.io_port, DMAC_INIT, INIT_8BIT); | 390 | dmac_write(host, DMAC_INIT, INIT_8BIT); |
394 | dmac_write(host->dma.io_port, DMAC_CHANNEL, CHANNEL_0); | 391 | dmac_write(host, DMAC_CHANNEL, CHANNEL_0); |
395 | dmac_write(host->dma.io_port, DMAC_DEVCON0, INIT_DEVCON0); | 392 | dmac_write(host, DMAC_DEVCON0, INIT_DEVCON0); |
396 | dmac_write(host->dma.io_port, DMAC_DEVCON1, INIT_DEVCON1); | 393 | dmac_write(host, DMAC_DEVCON1, INIT_DEVCON1); |
397 | #endif | 394 | #endif |
398 | 395 | ||
399 | host->SCpnt = NULL; | 396 | host->SCpnt = NULL; |
@@ -741,9 +738,9 @@ intr_ret_t acornscsi_kick(AS_Host *host) | |||
741 | * If we have an interrupt pending, then we may have been reselected. | 738 | * If we have an interrupt pending, then we may have been reselected. |
742 | * In this case, we don't want to write to the registers | 739 | * In this case, we don't want to write to the registers |
743 | */ | 740 | */ |
744 | if (!(sbic_arm_read(host->scsi.io_port, SBIC_ASR) & (ASR_INT|ASR_BSY|ASR_CIP))) { | 741 | if (!(sbic_arm_read(host, SBIC_ASR) & (ASR_INT|ASR_BSY|ASR_CIP))) { |
745 | sbic_arm_write(host->scsi.io_port, SBIC_DESTID, SCpnt->device->id); | 742 | sbic_arm_write(host, SBIC_DESTID, SCpnt->device->id); |
746 | sbic_arm_write(host->scsi.io_port, SBIC_CMND, CMND_SELWITHATN); | 743 | sbic_arm_write(host, SBIC_CMND, CMND_SELWITHATN); |
747 | } | 744 | } |
748 | 745 | ||
749 | /* | 746 | /* |
@@ -807,7 +804,7 @@ static void acornscsi_done(AS_Host *host, struct scsi_cmnd **SCpntp, | |||
807 | struct scsi_cmnd *SCpnt = *SCpntp; | 804 | struct scsi_cmnd *SCpnt = *SCpntp; |
808 | 805 | ||
809 | /* clean up */ | 806 | /* clean up */ |
810 | sbic_arm_write(host->scsi.io_port, SBIC_SOURCEID, SOURCEID_ER | SOURCEID_DSP); | 807 | sbic_arm_write(host, SBIC_SOURCEID, SOURCEID_ER | SOURCEID_DSP); |
811 | 808 | ||
812 | host->stats.fins += 1; | 809 | host->stats.fins += 1; |
813 | 810 | ||
@@ -918,13 +915,13 @@ static | |||
918 | void acornscsi_data_read(AS_Host *host, char *ptr, | 915 | void acornscsi_data_read(AS_Host *host, char *ptr, |
919 | unsigned int start_addr, unsigned int length) | 916 | unsigned int start_addr, unsigned int length) |
920 | { | 917 | { |
921 | extern void __acornscsi_in(int port, char *buf, int len); | 918 | extern void __acornscsi_in(void __iomem *, char *buf, int len); |
922 | unsigned int page, offset, len = length; | 919 | unsigned int page, offset, len = length; |
923 | 920 | ||
924 | page = (start_addr >> 12); | 921 | page = (start_addr >> 12); |
925 | offset = start_addr & ((1 << 12) - 1); | 922 | offset = start_addr & ((1 << 12) - 1); |
926 | 923 | ||
927 | outb((page & 0x3f) | host->card.page_reg, host->card.io_page); | 924 | writeb((page & 0x3f) | host->card.page_reg, host->fast + PAGE_REG); |
928 | 925 | ||
929 | while (len > 0) { | 926 | while (len > 0) { |
930 | unsigned int this_len; | 927 | unsigned int this_len; |
@@ -934,7 +931,7 @@ void acornscsi_data_read(AS_Host *host, char *ptr, | |||
934 | else | 931 | else |
935 | this_len = len; | 932 | this_len = len; |
936 | 933 | ||
937 | __acornscsi_in(host->card.io_ram + (offset << 1), ptr, this_len); | 934 | __acornscsi_in(host->base + (offset << 1), ptr, this_len); |
938 | 935 | ||
939 | offset += this_len; | 936 | offset += this_len; |
940 | ptr += this_len; | 937 | ptr += this_len; |
@@ -943,10 +940,10 @@ void acornscsi_data_read(AS_Host *host, char *ptr, | |||
943 | if (offset == (1 << 12)) { | 940 | if (offset == (1 << 12)) { |
944 | offset = 0; | 941 | offset = 0; |
945 | page ++; | 942 | page ++; |
946 | outb((page & 0x3f) | host->card.page_reg, host->card.io_page); | 943 | writeb((page & 0x3f) | host->card.page_reg, host->fast + PAGE_REG); |
947 | } | 944 | } |
948 | } | 945 | } |
949 | outb(host->card.page_reg, host->card.io_page); | 946 | writeb(host->card.page_reg, host->fast + PAGE_REG); |
950 | } | 947 | } |
951 | 948 | ||
952 | /* | 949 | /* |
@@ -963,13 +960,13 @@ static | |||
963 | void acornscsi_data_write(AS_Host *host, char *ptr, | 960 | void acornscsi_data_write(AS_Host *host, char *ptr, |
964 | unsigned int start_addr, unsigned int length) | 961 | unsigned int start_addr, unsigned int length) |
965 | { | 962 | { |
966 | extern void __acornscsi_out(int port, char *buf, int len); | 963 | extern void __acornscsi_out(void __iomem *, char *buf, int len); |
967 | unsigned int page, offset, len = length; | 964 | unsigned int page, offset, len = length; |
968 | 965 | ||
969 | page = (start_addr >> 12); | 966 | page = (start_addr >> 12); |
970 | offset = start_addr & ((1 << 12) - 1); | 967 | offset = start_addr & ((1 << 12) - 1); |
971 | 968 | ||
972 | outb((page & 0x3f) | host->card.page_reg, host->card.io_page); | 969 | writeb((page & 0x3f) | host->card.page_reg, host->fast + PAGE_REG); |
973 | 970 | ||
974 | while (len > 0) { | 971 | while (len > 0) { |
975 | unsigned int this_len; | 972 | unsigned int this_len; |
@@ -979,7 +976,7 @@ void acornscsi_data_write(AS_Host *host, char *ptr, | |||
979 | else | 976 | else |
980 | this_len = len; | 977 | this_len = len; |
981 | 978 | ||
982 | __acornscsi_out(host->card.io_ram + (offset << 1), ptr, this_len); | 979 | __acornscsi_out(host->base + (offset << 1), ptr, this_len); |
983 | 980 | ||
984 | offset += this_len; | 981 | offset += this_len; |
985 | ptr += this_len; | 982 | ptr += this_len; |
@@ -988,10 +985,10 @@ void acornscsi_data_write(AS_Host *host, char *ptr, | |||
988 | if (offset == (1 << 12)) { | 985 | if (offset == (1 << 12)) { |
989 | offset = 0; | 986 | offset = 0; |
990 | page ++; | 987 | page ++; |
991 | outb((page & 0x3f) | host->card.page_reg, host->card.io_page); | 988 | writeb((page & 0x3f) | host->card.page_reg, host->fast + PAGE_REG); |
992 | } | 989 | } |
993 | } | 990 | } |
994 | outb(host->card.page_reg, host->card.io_page); | 991 | writeb(host->card.page_reg, host->fast + PAGE_REG); |
995 | } | 992 | } |
996 | 993 | ||
997 | /* ========================================================================================= | 994 | /* ========================================================================================= |
@@ -1008,8 +1005,8 @@ void acornscsi_data_write(AS_Host *host, char *ptr, | |||
1008 | static inline | 1005 | static inline |
1009 | void acornscsi_dma_stop(AS_Host *host) | 1006 | void acornscsi_dma_stop(AS_Host *host) |
1010 | { | 1007 | { |
1011 | dmac_write(host->dma.io_port, DMAC_MASKREG, MASK_ON); | 1008 | dmac_write(host, DMAC_MASKREG, MASK_ON); |
1012 | dmac_clearintr(host->dma.io_intr_clear); | 1009 | dmac_clearintr(host); |
1013 | 1010 | ||
1014 | #if (DEBUG & DEBUG_DMA) | 1011 | #if (DEBUG & DEBUG_DMA) |
1015 | DBG(host->SCpnt, acornscsi_dumpdma(host, "stop")); | 1012 | DBG(host->SCpnt, acornscsi_dumpdma(host, "stop")); |
@@ -1031,7 +1028,7 @@ void acornscsi_dma_setup(AS_Host *host, dmadir_t direction) | |||
1031 | 1028 | ||
1032 | host->dma.direction = direction; | 1029 | host->dma.direction = direction; |
1033 | 1030 | ||
1034 | dmac_write(host->dma.io_port, DMAC_MASKREG, MASK_ON); | 1031 | dmac_write(host, DMAC_MASKREG, MASK_ON); |
1035 | 1032 | ||
1036 | if (direction == DMA_OUT) { | 1033 | if (direction == DMA_OUT) { |
1037 | #if (DEBUG & DEBUG_NO_WRITE) | 1034 | #if (DEBUG & DEBUG_NO_WRITE) |
@@ -1062,13 +1059,13 @@ void acornscsi_dma_setup(AS_Host *host, dmadir_t direction) | |||
1062 | length); | 1059 | length); |
1063 | 1060 | ||
1064 | length -= 1; | 1061 | length -= 1; |
1065 | dmac_write(host->dma.io_port, DMAC_TXCNTLO, length); | 1062 | dmac_write(host, DMAC_TXCNTLO, length); |
1066 | dmac_write(host->dma.io_port, DMAC_TXCNTHI, length >> 8); | 1063 | dmac_write(host, DMAC_TXCNTHI, length >> 8); |
1067 | dmac_write(host->dma.io_port, DMAC_TXADRLO, address); | 1064 | dmac_write(host, DMAC_TXADRLO, address); |
1068 | dmac_write(host->dma.io_port, DMAC_TXADRMD, address >> 8); | 1065 | dmac_write(host, DMAC_TXADRMD, address >> 8); |
1069 | dmac_write(host->dma.io_port, DMAC_TXADRHI, 0); | 1066 | dmac_write(host, DMAC_TXADRHI, 0); |
1070 | dmac_write(host->dma.io_port, DMAC_MODECON, mode); | 1067 | dmac_write(host, DMAC_MODECON, mode); |
1071 | dmac_write(host->dma.io_port, DMAC_MASKREG, MASK_OFF); | 1068 | dmac_write(host, DMAC_MASKREG, MASK_OFF); |
1072 | 1069 | ||
1073 | #if (DEBUG & DEBUG_DMA) | 1070 | #if (DEBUG & DEBUG_DMA) |
1074 | DBG(host->SCpnt, acornscsi_dumpdma(host, "strt")); | 1071 | DBG(host->SCpnt, acornscsi_dumpdma(host, "strt")); |
@@ -1088,8 +1085,8 @@ void acornscsi_dma_setup(AS_Host *host, dmadir_t direction) | |||
1088 | static | 1085 | static |
1089 | void acornscsi_dma_cleanup(AS_Host *host) | 1086 | void acornscsi_dma_cleanup(AS_Host *host) |
1090 | { | 1087 | { |
1091 | dmac_write(host->dma.io_port, DMAC_MASKREG, MASK_ON); | 1088 | dmac_write(host, DMAC_MASKREG, MASK_ON); |
1092 | dmac_clearintr(host->dma.io_intr_clear); | 1089 | dmac_clearintr(host); |
1093 | 1090 | ||
1094 | /* | 1091 | /* |
1095 | * Check for a pending transfer | 1092 | * Check for a pending transfer |
@@ -1116,7 +1113,7 @@ void acornscsi_dma_cleanup(AS_Host *host) | |||
1116 | /* | 1113 | /* |
1117 | * Calculate number of bytes transferred from DMA. | 1114 | * Calculate number of bytes transferred from DMA. |
1118 | */ | 1115 | */ |
1119 | transferred = dmac_address(host->dma.io_port) - host->dma.start_addr; | 1116 | transferred = dmac_address(host) - host->dma.start_addr; |
1120 | host->dma.transferred += transferred; | 1117 | host->dma.transferred += transferred; |
1121 | 1118 | ||
1122 | if (host->dma.direction == DMA_IN) | 1119 | if (host->dma.direction == DMA_IN) |
@@ -1152,13 +1149,13 @@ void acornscsi_dma_intr(AS_Host *host) | |||
1152 | DBG(host->SCpnt, acornscsi_dumpdma(host, "inti")); | 1149 | DBG(host->SCpnt, acornscsi_dumpdma(host, "inti")); |
1153 | #endif | 1150 | #endif |
1154 | 1151 | ||
1155 | dmac_write(host->dma.io_port, DMAC_MASKREG, MASK_ON); | 1152 | dmac_write(host, DMAC_MASKREG, MASK_ON); |
1156 | dmac_clearintr(host->dma.io_intr_clear); | 1153 | dmac_clearintr(host); |
1157 | 1154 | ||
1158 | /* | 1155 | /* |
1159 | * Calculate amount transferred via DMA | 1156 | * Calculate amount transferred via DMA |
1160 | */ | 1157 | */ |
1161 | transferred = dmac_address(host->dma.io_port) - host->dma.start_addr; | 1158 | transferred = dmac_address(host) - host->dma.start_addr; |
1162 | host->dma.transferred += transferred; | 1159 | host->dma.transferred += transferred; |
1163 | 1160 | ||
1164 | /* | 1161 | /* |
@@ -1190,12 +1187,12 @@ void acornscsi_dma_intr(AS_Host *host) | |||
1190 | length); | 1187 | length); |
1191 | 1188 | ||
1192 | length -= 1; | 1189 | length -= 1; |
1193 | dmac_write(host->dma.io_port, DMAC_TXCNTLO, length); | 1190 | dmac_write(host, DMAC_TXCNTLO, length); |
1194 | dmac_write(host->dma.io_port, DMAC_TXCNTHI, length >> 8); | 1191 | dmac_write(host, DMAC_TXCNTHI, length >> 8); |
1195 | dmac_write(host->dma.io_port, DMAC_TXADRLO, address); | 1192 | dmac_write(host, DMAC_TXADRLO, address); |
1196 | dmac_write(host->dma.io_port, DMAC_TXADRMD, address >> 8); | 1193 | dmac_write(host, DMAC_TXADRMD, address >> 8); |
1197 | dmac_write(host->dma.io_port, DMAC_TXADRHI, 0); | 1194 | dmac_write(host, DMAC_TXADRHI, 0); |
1198 | dmac_write(host->dma.io_port, DMAC_MASKREG, MASK_OFF); | 1195 | dmac_write(host, DMAC_MASKREG, MASK_OFF); |
1199 | 1196 | ||
1200 | #if (DEBUG & DEBUG_DMA) | 1197 | #if (DEBUG & DEBUG_DMA) |
1201 | DBG(host->SCpnt, acornscsi_dumpdma(host, "into")); | 1198 | DBG(host->SCpnt, acornscsi_dumpdma(host, "into")); |
@@ -1209,15 +1206,15 @@ void acornscsi_dma_intr(AS_Host *host) | |||
1209 | * attention condition. We continue giving one byte until | 1206 | * attention condition. We continue giving one byte until |
1210 | * the device recognises the attention. | 1207 | * the device recognises the attention. |
1211 | */ | 1208 | */ |
1212 | if (dmac_read(host->dma.io_port, DMAC_STATUS) & STATUS_RQ0) { | 1209 | if (dmac_read(host, DMAC_STATUS) & STATUS_RQ0) { |
1213 | acornscsi_abortcmd(host, host->SCpnt->tag); | 1210 | acornscsi_abortcmd(host, host->SCpnt->tag); |
1214 | 1211 | ||
1215 | dmac_write(host->dma.io_port, DMAC_TXCNTLO, 0); | 1212 | dmac_write(host, DMAC_TXCNTLO, 0); |
1216 | dmac_write(host->dma.io_port, DMAC_TXCNTHI, 0); | 1213 | dmac_write(host, DMAC_TXCNTHI, 0); |
1217 | dmac_write(host->dma.io_port, DMAC_TXADRLO, 0); | 1214 | dmac_write(host, DMAC_TXADRLO, 0); |
1218 | dmac_write(host->dma.io_port, DMAC_TXADRMD, 0); | 1215 | dmac_write(host, DMAC_TXADRMD, 0); |
1219 | dmac_write(host->dma.io_port, DMAC_TXADRHI, 0); | 1216 | dmac_write(host, DMAC_TXADRHI, 0); |
1220 | dmac_write(host->dma.io_port, DMAC_MASKREG, MASK_OFF); | 1217 | dmac_write(host, DMAC_MASKREG, MASK_OFF); |
1221 | } | 1218 | } |
1222 | #endif | 1219 | #endif |
1223 | } | 1220 | } |
@@ -1271,9 +1268,9 @@ void acornscsi_dma_adjust(AS_Host *host) | |||
1271 | host->dma.xfer_setup = 0; | 1268 | host->dma.xfer_setup = 0; |
1272 | else { | 1269 | else { |
1273 | transferred += host->dma.start_addr; | 1270 | transferred += host->dma.start_addr; |
1274 | dmac_write(host->dma.io_port, DMAC_TXADRLO, transferred); | 1271 | dmac_write(host, DMAC_TXADRLO, transferred); |
1275 | dmac_write(host->dma.io_port, DMAC_TXADRMD, transferred >> 8); | 1272 | dmac_write(host, DMAC_TXADRMD, transferred >> 8); |
1276 | dmac_write(host->dma.io_port, DMAC_TXADRHI, transferred >> 16); | 1273 | dmac_write(host, DMAC_TXADRHI, transferred >> 16); |
1277 | #if (DEBUG & (DEBUG_DMA|DEBUG_WRITE)) | 1274 | #if (DEBUG & (DEBUG_DMA|DEBUG_WRITE)) |
1278 | DBG(host->SCpnt, acornscsi_dumpdma(host, "adjo")); | 1275 | DBG(host->SCpnt, acornscsi_dumpdma(host, "adjo")); |
1279 | #endif | 1276 | #endif |
@@ -1292,12 +1289,12 @@ acornscsi_write_pio(AS_Host *host, char *bytes, int *ptr, int len, unsigned int | |||
1292 | int my_ptr = *ptr; | 1289 | int my_ptr = *ptr; |
1293 | 1290 | ||
1294 | while (my_ptr < len) { | 1291 | while (my_ptr < len) { |
1295 | asr = sbic_arm_read(host->scsi.io_port, SBIC_ASR); | 1292 | asr = sbic_arm_read(host, SBIC_ASR); |
1296 | 1293 | ||
1297 | if (asr & ASR_DBR) { | 1294 | if (asr & ASR_DBR) { |
1298 | timeout = max_timeout; | 1295 | timeout = max_timeout; |
1299 | 1296 | ||
1300 | sbic_arm_write(host->scsi.io_port, SBIC_DATA, bytes[my_ptr++]); | 1297 | sbic_arm_write(host, SBIC_DATA, bytes[my_ptr++]); |
1301 | } else if (asr & ASR_INT) | 1298 | } else if (asr & ASR_INT) |
1302 | break; | 1299 | break; |
1303 | else if (--timeout == 0) | 1300 | else if (--timeout == 0) |
@@ -1320,9 +1317,9 @@ acornscsi_sendcommand(AS_Host *host) | |||
1320 | { | 1317 | { |
1321 | struct scsi_cmnd *SCpnt = host->SCpnt; | 1318 | struct scsi_cmnd *SCpnt = host->SCpnt; |
1322 | 1319 | ||
1323 | sbic_arm_write(host->scsi.io_port, SBIC_TRANSCNTH, 0); | 1320 | sbic_arm_write(host, SBIC_TRANSCNTH, 0); |
1324 | sbic_arm_writenext(host->scsi.io_port, 0); | 1321 | sbic_arm_writenext(host, 0); |
1325 | sbic_arm_writenext(host->scsi.io_port, SCpnt->cmd_len - host->scsi.SCp.sent_command); | 1322 | sbic_arm_writenext(host, SCpnt->cmd_len - host->scsi.SCp.sent_command); |
1326 | 1323 | ||
1327 | acornscsi_sbic_issuecmd(host, CMND_XFERINFO); | 1324 | acornscsi_sbic_issuecmd(host, CMND_XFERINFO); |
1328 | 1325 | ||
@@ -1351,7 +1348,7 @@ void acornscsi_sendmessage(AS_Host *host) | |||
1351 | 1348 | ||
1352 | acornscsi_sbic_wait(host, ASR_DBR, ASR_DBR, 1000, "sending message 1"); | 1349 | acornscsi_sbic_wait(host, ASR_DBR, ASR_DBR, 1000, "sending message 1"); |
1353 | 1350 | ||
1354 | sbic_arm_write(host->scsi.io_port, SBIC_DATA, NOP); | 1351 | sbic_arm_write(host, SBIC_DATA, NOP); |
1355 | 1352 | ||
1356 | host->scsi.last_message = NOP; | 1353 | host->scsi.last_message = NOP; |
1357 | #if (DEBUG & DEBUG_MESSAGES) | 1354 | #if (DEBUG & DEBUG_MESSAGES) |
@@ -1365,7 +1362,7 @@ void acornscsi_sendmessage(AS_Host *host) | |||
1365 | 1362 | ||
1366 | acornscsi_sbic_wait(host, ASR_DBR, ASR_DBR, 1000, "sending message 2"); | 1363 | acornscsi_sbic_wait(host, ASR_DBR, ASR_DBR, 1000, "sending message 2"); |
1367 | 1364 | ||
1368 | sbic_arm_write(host->scsi.io_port, SBIC_DATA, msg->msg[0]); | 1365 | sbic_arm_write(host, SBIC_DATA, msg->msg[0]); |
1369 | 1366 | ||
1370 | host->scsi.last_message = msg->msg[0]; | 1367 | host->scsi.last_message = msg->msg[0]; |
1371 | #if (DEBUG & DEBUG_MESSAGES) | 1368 | #if (DEBUG & DEBUG_MESSAGES) |
@@ -1382,9 +1379,9 @@ void acornscsi_sendmessage(AS_Host *host) | |||
1382 | * initiator. This provides an interlock so that the | 1379 | * initiator. This provides an interlock so that the |
1383 | * initiator can determine which message byte is rejected. | 1380 | * initiator can determine which message byte is rejected. |
1384 | */ | 1381 | */ |
1385 | sbic_arm_write(host->scsi.io_port, SBIC_TRANSCNTH, 0); | 1382 | sbic_arm_write(host, SBIC_TRANSCNTH, 0); |
1386 | sbic_arm_writenext(host->scsi.io_port, 0); | 1383 | sbic_arm_writenext(host, 0); |
1387 | sbic_arm_writenext(host->scsi.io_port, message_length); | 1384 | sbic_arm_writenext(host, message_length); |
1388 | acornscsi_sbic_issuecmd(host, CMND_XFERINFO); | 1385 | acornscsi_sbic_issuecmd(host, CMND_XFERINFO); |
1389 | 1386 | ||
1390 | msgnr = 0; | 1387 | msgnr = 0; |
@@ -1421,7 +1418,7 @@ void acornscsi_readstatusbyte(AS_Host *host) | |||
1421 | { | 1418 | { |
1422 | acornscsi_sbic_issuecmd(host, CMND_XFERINFO|CMND_SBT); | 1419 | acornscsi_sbic_issuecmd(host, CMND_XFERINFO|CMND_SBT); |
1423 | acornscsi_sbic_wait(host, ASR_DBR, ASR_DBR, 1000, "reading status byte"); | 1420 | acornscsi_sbic_wait(host, ASR_DBR, ASR_DBR, 1000, "reading status byte"); |
1424 | host->scsi.SCp.Status = sbic_arm_read(host->scsi.io_port, SBIC_DATA); | 1421 | host->scsi.SCp.Status = sbic_arm_read(host, SBIC_DATA); |
1425 | } | 1422 | } |
1426 | 1423 | ||
1427 | /* | 1424 | /* |
@@ -1438,12 +1435,12 @@ unsigned char acornscsi_readmessagebyte(AS_Host *host) | |||
1438 | 1435 | ||
1439 | acornscsi_sbic_wait(host, ASR_DBR, ASR_DBR, 1000, "for message byte"); | 1436 | acornscsi_sbic_wait(host, ASR_DBR, ASR_DBR, 1000, "for message byte"); |
1440 | 1437 | ||
1441 | message = sbic_arm_read(host->scsi.io_port, SBIC_DATA); | 1438 | message = sbic_arm_read(host, SBIC_DATA); |
1442 | 1439 | ||
1443 | /* wait for MSGIN-XFER-PAUSED */ | 1440 | /* wait for MSGIN-XFER-PAUSED */ |
1444 | acornscsi_sbic_wait(host, ASR_INT, ASR_INT, 1000, "for interrupt after message byte"); | 1441 | acornscsi_sbic_wait(host, ASR_INT, ASR_INT, 1000, "for interrupt after message byte"); |
1445 | 1442 | ||
1446 | sbic_arm_read(host->scsi.io_port, SBIC_SSR); | 1443 | sbic_arm_read(host, SBIC_SSR); |
1447 | 1444 | ||
1448 | return message; | 1445 | return message; |
1449 | } | 1446 | } |
@@ -1480,7 +1477,7 @@ void acornscsi_message(AS_Host *host) | |||
1480 | 1477 | ||
1481 | /* wait for next msg-in */ | 1478 | /* wait for next msg-in */ |
1482 | acornscsi_sbic_wait(host, ASR_INT, ASR_INT, 1000, "for interrupt after negate ack"); | 1479 | acornscsi_sbic_wait(host, ASR_INT, ASR_INT, 1000, "for interrupt after negate ack"); |
1483 | sbic_arm_read(host->scsi.io_port, SBIC_SSR); | 1480 | sbic_arm_read(host, SBIC_SSR); |
1484 | } | 1481 | } |
1485 | } while (msgidx < msglen); | 1482 | } while (msgidx < msglen); |
1486 | 1483 | ||
@@ -1602,7 +1599,7 @@ void acornscsi_message(AS_Host *host) | |||
1602 | host->host->host_no, acornscsi_target(host)); | 1599 | host->host->host_no, acornscsi_target(host)); |
1603 | host->device[host->SCpnt->device->id].sync_xfer = SYNCHTRANSFER_2DBA; | 1600 | host->device[host->SCpnt->device->id].sync_xfer = SYNCHTRANSFER_2DBA; |
1604 | host->device[host->SCpnt->device->id].sync_state = SYNC_ASYNCHRONOUS; | 1601 | host->device[host->SCpnt->device->id].sync_state = SYNC_ASYNCHRONOUS; |
1605 | sbic_arm_write(host->scsi.io_port, SBIC_SYNCHTRANSFER, host->device[host->SCpnt->device->id].sync_xfer); | 1602 | sbic_arm_write(host, SBIC_SYNCHTRANSFER, host->device[host->SCpnt->device->id].sync_xfer); |
1606 | break; | 1603 | break; |
1607 | 1604 | ||
1608 | default: | 1605 | default: |
@@ -1652,7 +1649,7 @@ void acornscsi_message(AS_Host *host) | |||
1652 | host->device[host->SCpnt->device->id].sync_xfer = | 1649 | host->device[host->SCpnt->device->id].sync_xfer = |
1653 | calc_sync_xfer(period * 4, length); | 1650 | calc_sync_xfer(period * 4, length); |
1654 | } | 1651 | } |
1655 | sbic_arm_write(host->scsi.io_port, SBIC_SYNCHTRANSFER, host->device[host->SCpnt->device->id].sync_xfer); | 1652 | sbic_arm_write(host, SBIC_SYNCHTRANSFER, host->device[host->SCpnt->device->id].sync_xfer); |
1656 | break; | 1653 | break; |
1657 | #else | 1654 | #else |
1658 | /* We do not accept synchronous transfers. Respond with a | 1655 | /* We do not accept synchronous transfers. Respond with a |
@@ -1792,10 +1789,10 @@ int acornscsi_starttransfer(AS_Host *host) | |||
1792 | 1789 | ||
1793 | residual = scsi_bufflen(host->SCpnt) - host->scsi.SCp.scsi_xferred; | 1790 | residual = scsi_bufflen(host->SCpnt) - host->scsi.SCp.scsi_xferred; |
1794 | 1791 | ||
1795 | sbic_arm_write(host->scsi.io_port, SBIC_SYNCHTRANSFER, host->device[host->SCpnt->device->id].sync_xfer); | 1792 | sbic_arm_write(host, SBIC_SYNCHTRANSFER, host->device[host->SCpnt->device->id].sync_xfer); |
1796 | sbic_arm_writenext(host->scsi.io_port, residual >> 16); | 1793 | sbic_arm_writenext(host, residual >> 16); |
1797 | sbic_arm_writenext(host->scsi.io_port, residual >> 8); | 1794 | sbic_arm_writenext(host, residual >> 8); |
1798 | sbic_arm_writenext(host->scsi.io_port, residual); | 1795 | sbic_arm_writenext(host, residual); |
1799 | acornscsi_sbic_issuecmd(host, CMND_XFERINFO); | 1796 | acornscsi_sbic_issuecmd(host, CMND_XFERINFO); |
1800 | return 1; | 1797 | return 1; |
1801 | } | 1798 | } |
@@ -1816,7 +1813,7 @@ int acornscsi_reconnect(AS_Host *host) | |||
1816 | { | 1813 | { |
1817 | unsigned int target, lun, ok = 0; | 1814 | unsigned int target, lun, ok = 0; |
1818 | 1815 | ||
1819 | target = sbic_arm_read(host->scsi.io_port, SBIC_SOURCEID); | 1816 | target = sbic_arm_read(host, SBIC_SOURCEID); |
1820 | 1817 | ||
1821 | if (!(target & 8)) | 1818 | if (!(target & 8)) |
1822 | printk(KERN_ERR "scsi%d: invalid source id after reselection " | 1819 | printk(KERN_ERR "scsi%d: invalid source id after reselection " |
@@ -1832,7 +1829,7 @@ int acornscsi_reconnect(AS_Host *host) | |||
1832 | host->SCpnt = NULL; | 1829 | host->SCpnt = NULL; |
1833 | } | 1830 | } |
1834 | 1831 | ||
1835 | lun = sbic_arm_read(host->scsi.io_port, SBIC_DATA) & 7; | 1832 | lun = sbic_arm_read(host, SBIC_DATA) & 7; |
1836 | 1833 | ||
1837 | host->scsi.reconnected.target = target; | 1834 | host->scsi.reconnected.target = target; |
1838 | host->scsi.reconnected.lun = lun; | 1835 | host->scsi.reconnected.lun = lun; |
@@ -1952,7 +1949,7 @@ static | |||
1952 | void acornscsi_abortcmd(AS_Host *host, unsigned char tag) | 1949 | void acornscsi_abortcmd(AS_Host *host, unsigned char tag) |
1953 | { | 1950 | { |
1954 | host->scsi.phase = PHASE_ABORTED; | 1951 | host->scsi.phase = PHASE_ABORTED; |
1955 | sbic_arm_write(host->scsi.io_port, SBIC_CMND, CMND_ASSERTATN); | 1952 | sbic_arm_write(host, SBIC_CMND, CMND_ASSERTATN); |
1956 | 1953 | ||
1957 | msgqueue_flush(&host->scsi.msgs); | 1954 | msgqueue_flush(&host->scsi.msgs); |
1958 | #ifdef CONFIG_SCSI_ACORNSCSI_TAGGED_QUEUE | 1955 | #ifdef CONFIG_SCSI_ACORNSCSI_TAGGED_QUEUE |
@@ -1979,11 +1976,11 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq) | |||
1979 | { | 1976 | { |
1980 | unsigned int asr, ssr; | 1977 | unsigned int asr, ssr; |
1981 | 1978 | ||
1982 | asr = sbic_arm_read(host->scsi.io_port, SBIC_ASR); | 1979 | asr = sbic_arm_read(host, SBIC_ASR); |
1983 | if (!(asr & ASR_INT)) | 1980 | if (!(asr & ASR_INT)) |
1984 | return INTR_IDLE; | 1981 | return INTR_IDLE; |
1985 | 1982 | ||
1986 | ssr = sbic_arm_read(host->scsi.io_port, SBIC_SSR); | 1983 | ssr = sbic_arm_read(host, SBIC_SSR); |
1987 | 1984 | ||
1988 | #if (DEBUG & DEBUG_PHASES) | 1985 | #if (DEBUG & DEBUG_PHASES) |
1989 | print_sbic_status(asr, ssr, host->scsi.phase); | 1986 | print_sbic_status(asr, ssr, host->scsi.phase); |
@@ -1999,15 +1996,15 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq) | |||
1999 | printk(KERN_ERR "scsi%d: reset in standard mode but wanted advanced mode.\n", | 1996 | printk(KERN_ERR "scsi%d: reset in standard mode but wanted advanced mode.\n", |
2000 | host->host->host_no); | 1997 | host->host->host_no); |
2001 | /* setup sbic - WD33C93A */ | 1998 | /* setup sbic - WD33C93A */ |
2002 | sbic_arm_write(host->scsi.io_port, SBIC_OWNID, OWNID_EAF | host->host->this_id); | 1999 | sbic_arm_write(host, SBIC_OWNID, OWNID_EAF | host->host->this_id); |
2003 | sbic_arm_write(host->scsi.io_port, SBIC_CMND, CMND_RESET); | 2000 | sbic_arm_write(host, SBIC_CMND, CMND_RESET); |
2004 | return INTR_IDLE; | 2001 | return INTR_IDLE; |
2005 | 2002 | ||
2006 | case 0x01: /* reset state - advanced */ | 2003 | case 0x01: /* reset state - advanced */ |
2007 | sbic_arm_write(host->scsi.io_port, SBIC_CTRL, INIT_SBICDMA | CTRL_IDI); | 2004 | sbic_arm_write(host, SBIC_CTRL, INIT_SBICDMA | CTRL_IDI); |
2008 | sbic_arm_write(host->scsi.io_port, SBIC_TIMEOUT, TIMEOUT_TIME); | 2005 | sbic_arm_write(host, SBIC_TIMEOUT, TIMEOUT_TIME); |
2009 | sbic_arm_write(host->scsi.io_port, SBIC_SYNCHTRANSFER, SYNCHTRANSFER_2DBA); | 2006 | sbic_arm_write(host, SBIC_SYNCHTRANSFER, SYNCHTRANSFER_2DBA); |
2010 | sbic_arm_write(host->scsi.io_port, SBIC_SOURCEID, SOURCEID_ER | SOURCEID_DSP); | 2007 | sbic_arm_write(host, SBIC_SOURCEID, SOURCEID_ER | SOURCEID_DSP); |
2011 | msgqueue_flush(&host->scsi.msgs); | 2008 | msgqueue_flush(&host->scsi.msgs); |
2012 | return INTR_IDLE; | 2009 | return INTR_IDLE; |
2013 | 2010 | ||
@@ -2025,10 +2022,10 @@ intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq) | |||
2025 | msgqueue_flush(&host->scsi.msgs); | 2022 | msgqueue_flush(&host->scsi.msgs); |
2026 | host->dma.transferred = host->scsi.SCp.scsi_xferred; | 2023 | host->dma.transferred = host->scsi.SCp.scsi_xferred; |
2027 | /* 33C93 gives next interrupt indicating bus phase */ | 2024 | /* 33C93 gives next interrupt indicating bus phase */ |
2028 | asr = sbic_arm_read(host->scsi.io_port, SBIC_ASR); | 2025 | asr = sbic_arm_read(host, SBIC_ASR); |
2029 | if (!(asr & ASR_INT)) | 2026 | if (!(asr & ASR_INT)) |
2030 | break; | 2027 | break; |
2031 | ssr = sbic_arm_read(host->scsi.io_port, SBIC_SSR); | 2028 | ssr = sbic_arm_read(host, SBIC_SSR); |
2032 | ADD_STATUS(8, ssr, host->scsi.phase, 1); | 2029 | ADD_STATUS(8, ssr, host->scsi.phase, 1); |
2033 | ADD_STATUS(host->SCpnt->device->id, ssr, host->scsi.phase, 1); | 2030 | ADD_STATUS(host->SCpnt->device->id, ssr, host->scsi.phase, 1); |
2034 | goto connected; | 2031 | goto connected; |
@@ -2476,11 +2473,11 @@ acornscsi_intr(int irq, void *dev_id) | |||
2476 | do { | 2473 | do { |
2477 | ret = INTR_IDLE; | 2474 | ret = INTR_IDLE; |
2478 | 2475 | ||
2479 | iostatus = inb(host->card.io_intr); | 2476 | iostatus = readb(host->fast + INT_REG); |
2480 | 2477 | ||
2481 | if (iostatus & 2) { | 2478 | if (iostatus & 2) { |
2482 | acornscsi_dma_intr(host); | 2479 | acornscsi_dma_intr(host); |
2483 | iostatus = inb(host->card.io_intr); | 2480 | iostatus = readb(host->fast + INT_REG); |
2484 | } | 2481 | } |
2485 | 2482 | ||
2486 | if (iostatus & 8) | 2483 | if (iostatus & 8) |
@@ -2655,7 +2652,7 @@ static enum res_abort acornscsi_do_abort(AS_Host *host, struct scsi_cmnd *SCpnt) | |||
2655 | * busylun bit. | 2652 | * busylun bit. |
2656 | */ | 2653 | */ |
2657 | case PHASE_CONNECTED: | 2654 | case PHASE_CONNECTED: |
2658 | sbic_arm_write(host->scsi.io_port, SBIC_CMND, CMND_DISCONNECT); | 2655 | sbic_arm_write(host, SBIC_CMND, CMND_DISCONNECT); |
2659 | host->SCpnt = NULL; | 2656 | host->SCpnt = NULL; |
2660 | res = res_success_clear; | 2657 | res = res_success_clear; |
2661 | break; | 2658 | break; |
@@ -2699,8 +2696,8 @@ int acornscsi_abort(struct scsi_cmnd *SCpnt) | |||
2699 | #if (DEBUG & DEBUG_ABORT) | 2696 | #if (DEBUG & DEBUG_ABORT) |
2700 | { | 2697 | { |
2701 | int asr, ssr; | 2698 | int asr, ssr; |
2702 | asr = sbic_arm_read(host->scsi.io_port, SBIC_ASR); | 2699 | asr = sbic_arm_read(host, SBIC_ASR); |
2703 | ssr = sbic_arm_read(host->scsi.io_port, SBIC_SSR); | 2700 | ssr = sbic_arm_read(host, SBIC_SSR); |
2704 | 2701 | ||
2705 | printk(KERN_WARNING "acornscsi_abort: "); | 2702 | printk(KERN_WARNING "acornscsi_abort: "); |
2706 | print_sbic_status(asr, ssr, host->scsi.phase); | 2703 | print_sbic_status(asr, ssr, host->scsi.phase); |
@@ -2731,9 +2728,7 @@ int acornscsi_abort(struct scsi_cmnd *SCpnt) | |||
2731 | //#if (DEBUG & DEBUG_ABORT) | 2728 | //#if (DEBUG & DEBUG_ABORT) |
2732 | printk("success\n"); | 2729 | printk("success\n"); |
2733 | //#endif | 2730 | //#endif |
2734 | SCpnt->result = DID_ABORT << 16; | 2731 | result = SUCCESS; |
2735 | SCpnt->scsi_done(SCpnt); | ||
2736 | result = SCSI_ABORT_SUCCESS; | ||
2737 | break; | 2732 | break; |
2738 | 2733 | ||
2739 | /* | 2734 | /* |
@@ -2745,7 +2740,7 @@ int acornscsi_abort(struct scsi_cmnd *SCpnt) | |||
2745 | //#if (DEBUG & DEBUG_ABORT) | 2740 | //#if (DEBUG & DEBUG_ABORT) |
2746 | printk("snooze\n"); | 2741 | printk("snooze\n"); |
2747 | //#endif | 2742 | //#endif |
2748 | result = SCSI_ABORT_SNOOZE; | 2743 | result = FAILED; |
2749 | break; | 2744 | break; |
2750 | 2745 | ||
2751 | /* | 2746 | /* |
@@ -2755,11 +2750,7 @@ int acornscsi_abort(struct scsi_cmnd *SCpnt) | |||
2755 | default: | 2750 | default: |
2756 | case res_not_running: | 2751 | case res_not_running: |
2757 | acornscsi_dumplog(host, SCpnt->device->id); | 2752 | acornscsi_dumplog(host, SCpnt->device->id); |
2758 | #if (DEBUG & DEBUG_ABORT) | 2753 | result = FAILED; |
2759 | result = SCSI_ABORT_SNOOZE; | ||
2760 | #else | ||
2761 | result = SCSI_ABORT_NOT_RUNNING; | ||
2762 | #endif | ||
2763 | //#if (DEBUG & DEBUG_ABORT) | 2754 | //#if (DEBUG & DEBUG_ABORT) |
2764 | printk("not running\n"); | 2755 | printk("not running\n"); |
2765 | //#endif | 2756 | //#endif |
@@ -2770,13 +2761,12 @@ int acornscsi_abort(struct scsi_cmnd *SCpnt) | |||
2770 | } | 2761 | } |
2771 | 2762 | ||
2772 | /* | 2763 | /* |
2773 | * Prototype: int acornscsi_reset(struct scsi_cmnd *SCpnt, unsigned int reset_flags) | 2764 | * Prototype: int acornscsi_reset(struct scsi_cmnd *SCpnt) |
2774 | * Purpose : reset a command on this host/reset this host | 2765 | * Purpose : reset a command on this host/reset this host |
2775 | * Params : SCpnt - command causing reset | 2766 | * Params : SCpnt - command causing reset |
2776 | * result - what type of reset to perform | ||
2777 | * Returns : one of SCSI_RESET_ macros | 2767 | * Returns : one of SCSI_RESET_ macros |
2778 | */ | 2768 | */ |
2779 | int acornscsi_reset(struct scsi_cmnd *SCpnt, unsigned int reset_flags) | 2769 | int acornscsi_bus_reset(struct scsi_cmnd *SCpnt) |
2780 | { | 2770 | { |
2781 | AS_Host *host = (AS_Host *)SCpnt->device->host->hostdata; | 2771 | AS_Host *host = (AS_Host *)SCpnt->device->host->hostdata; |
2782 | struct scsi_cmnd *SCptr; | 2772 | struct scsi_cmnd *SCptr; |
@@ -2787,8 +2777,8 @@ int acornscsi_reset(struct scsi_cmnd *SCpnt, unsigned int reset_flags) | |||
2787 | { | 2777 | { |
2788 | int asr, ssr; | 2778 | int asr, ssr; |
2789 | 2779 | ||
2790 | asr = sbic_arm_read(host->scsi.io_port, SBIC_ASR); | 2780 | asr = sbic_arm_read(host, SBIC_ASR); |
2791 | ssr = sbic_arm_read(host->scsi.io_port, SBIC_SSR); | 2781 | ssr = sbic_arm_read(host, SBIC_SSR); |
2792 | 2782 | ||
2793 | printk(KERN_WARNING "acornscsi_reset: "); | 2783 | printk(KERN_WARNING "acornscsi_reset: "); |
2794 | print_sbic_status(asr, ssr, host->scsi.phase); | 2784 | print_sbic_status(asr, ssr, host->scsi.phase); |
@@ -2798,28 +2788,16 @@ int acornscsi_reset(struct scsi_cmnd *SCpnt, unsigned int reset_flags) | |||
2798 | 2788 | ||
2799 | acornscsi_dma_stop(host); | 2789 | acornscsi_dma_stop(host); |
2800 | 2790 | ||
2801 | SCptr = host->SCpnt; | ||
2802 | |||
2803 | /* | 2791 | /* |
2804 | * do hard reset. This resets all devices on this host, and so we | 2792 | * do hard reset. This resets all devices on this host, and so we |
2805 | * must set the reset status on all commands. | 2793 | * must set the reset status on all commands. |
2806 | */ | 2794 | */ |
2807 | acornscsi_resetcard(host); | 2795 | acornscsi_resetcard(host); |
2808 | 2796 | ||
2809 | /* | ||
2810 | * report reset on commands current connected/disconnected | ||
2811 | */ | ||
2812 | acornscsi_reportstatus(&host->SCpnt, &SCptr, DID_RESET); | ||
2813 | |||
2814 | while ((SCptr = queue_remove(&host->queues.disconnected)) != NULL) | 2797 | while ((SCptr = queue_remove(&host->queues.disconnected)) != NULL) |
2815 | acornscsi_reportstatus(&SCptr, &SCpnt, DID_RESET); | 2798 | ; |
2816 | |||
2817 | if (SCpnt) { | ||
2818 | SCpnt->result = DID_RESET << 16; | ||
2819 | SCpnt->scsi_done(SCpnt); | ||
2820 | } | ||
2821 | 2799 | ||
2822 | return SCSI_RESET_BUS_RESET | SCSI_RESET_HOST_RESET | SCSI_RESET_SUCCESS; | 2800 | return SUCCESS; |
2823 | } | 2801 | } |
2824 | 2802 | ||
2825 | /*============================================================================================== | 2803 | /*============================================================================================== |
@@ -2850,7 +2828,7 @@ char *acornscsi_info(struct Scsi_Host *host) | |||
2850 | " LINK" | 2828 | " LINK" |
2851 | #endif | 2829 | #endif |
2852 | #if (DEBUG & DEBUG_NO_WRITE) | 2830 | #if (DEBUG & DEBUG_NO_WRITE) |
2853 | " NOWRITE ("NO_WRITE_STR")" | 2831 | " NOWRITE (" __stringify(NO_WRITE) ")" |
2854 | #endif | 2832 | #endif |
2855 | , host->hostt->name, host->io_port, host->irq, | 2833 | , host->hostt->name, host->io_port, host->irq, |
2856 | VER_MAJOR, VER_MINOR, VER_PATCH); | 2834 | VER_MAJOR, VER_MINOR, VER_PATCH); |
@@ -2881,15 +2859,15 @@ int acornscsi_proc_info(struct Scsi_Host *instance, char *buffer, char **start, | |||
2881 | " LINK" | 2859 | " LINK" |
2882 | #endif | 2860 | #endif |
2883 | #if (DEBUG & DEBUG_NO_WRITE) | 2861 | #if (DEBUG & DEBUG_NO_WRITE) |
2884 | " NOWRITE ("NO_WRITE_STR")" | 2862 | " NOWRITE (" __stringify(NO_WRITE) ")" |
2885 | #endif | 2863 | #endif |
2886 | "\n\n", VER_MAJOR, VER_MINOR, VER_PATCH); | 2864 | "\n\n", VER_MAJOR, VER_MINOR, VER_PATCH); |
2887 | 2865 | ||
2888 | p += sprintf(p, "SBIC: WD33C93A Address: %08X IRQ : %d\n", | 2866 | p += sprintf(p, "SBIC: WD33C93A Address: %p IRQ : %d\n", |
2889 | host->scsi.io_port, host->scsi.irq); | 2867 | host->base + SBIC_REGIDX, host->scsi.irq); |
2890 | #ifdef USE_DMAC | 2868 | #ifdef USE_DMAC |
2891 | p += sprintf(p, "DMAC: uPC71071 Address: %08X IRQ : %d\n\n", | 2869 | p += sprintf(p, "DMAC: uPC71071 Address: %p IRQ : %d\n\n", |
2892 | host->dma.io_port, host->scsi.irq); | 2870 | host->base + DMAC_OFFSET, host->scsi.irq); |
2893 | #endif | 2871 | #endif |
2894 | 2872 | ||
2895 | p += sprintf(p, "Statistics:\n" | 2873 | p += sprintf(p, "Statistics:\n" |
@@ -2976,9 +2954,8 @@ static struct scsi_host_template acornscsi_template = { | |||
2976 | .name = "AcornSCSI", | 2954 | .name = "AcornSCSI", |
2977 | .info = acornscsi_info, | 2955 | .info = acornscsi_info, |
2978 | .queuecommand = acornscsi_queuecmd, | 2956 | .queuecommand = acornscsi_queuecmd, |
2979 | #warning fixme | 2957 | .eh_abort_handler = acornscsi_abort, |
2980 | .abort = acornscsi_abort, | 2958 | .eh_bus_reset_handler = acornscsi_bus_reset, |
2981 | .reset = acornscsi_reset, | ||
2982 | .can_queue = 16, | 2959 | .can_queue = 16, |
2983 | .this_id = 7, | 2960 | .this_id = 7, |
2984 | .sg_tablesize = SG_ALL, | 2961 | .sg_tablesize = SG_ALL, |
@@ -2992,48 +2969,37 @@ acornscsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
2992 | { | 2969 | { |
2993 | struct Scsi_Host *host; | 2970 | struct Scsi_Host *host; |
2994 | AS_Host *ashost; | 2971 | AS_Host *ashost; |
2995 | int ret = -ENOMEM; | 2972 | int ret; |
2996 | 2973 | ||
2997 | host = scsi_host_alloc(&acornscsi_template, sizeof(AS_Host)); | 2974 | ret = ecard_request_resources(ec); |
2998 | if (!host) | 2975 | if (ret) |
2999 | goto out; | 2976 | goto out; |
3000 | 2977 | ||
2978 | host = scsi_host_alloc(&acornscsi_template, sizeof(AS_Host)); | ||
2979 | if (!host) { | ||
2980 | ret = -ENOMEM; | ||
2981 | goto out_release; | ||
2982 | } | ||
2983 | |||
3001 | ashost = (AS_Host *)host->hostdata; | 2984 | ashost = (AS_Host *)host->hostdata; |
3002 | 2985 | ||
3003 | host->io_port = ecard_address(ec, ECARD_MEMC, 0); | 2986 | ashost->base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); |
3004 | host->irq = ec->irq; | 2987 | ashost->fast = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); |
2988 | if (!ashost->base || !ashost->fast) | ||
2989 | goto out_put; | ||
3005 | 2990 | ||
3006 | ashost->host = host; | 2991 | host->irq = ec->irq; |
3007 | ashost->scsi.io_port = ioaddr(host->io_port + 0x800); | 2992 | ashost->host = host; |
3008 | ashost->scsi.irq = host->irq; | 2993 | ashost->scsi.irq = host->irq; |
3009 | ashost->card.io_intr = POD_SPACE(host->io_port) + 0x800; | ||
3010 | ashost->card.io_page = POD_SPACE(host->io_port) + 0xc00; | ||
3011 | ashost->card.io_ram = ioaddr(host->io_port); | ||
3012 | ashost->dma.io_port = host->io_port + 0xc00; | ||
3013 | ashost->dma.io_intr_clear = POD_SPACE(host->io_port) + 0x800; | ||
3014 | 2994 | ||
3015 | ec->irqaddr = (char *)ioaddr(ashost->card.io_intr); | 2995 | ec->irqaddr = ashost->fast + INT_REG; |
3016 | ec->irqmask = 0x0a; | 2996 | ec->irqmask = 0x0a; |
3017 | 2997 | ||
3018 | ret = -EBUSY; | ||
3019 | if (!request_region(host->io_port + 0x800, 2, "acornscsi(sbic)")) | ||
3020 | goto err_1; | ||
3021 | if (!request_region(ashost->card.io_intr, 1, "acornscsi(intr)")) | ||
3022 | goto err_2; | ||
3023 | if (!request_region(ashost->card.io_page, 1, "acornscsi(page)")) | ||
3024 | goto err_3; | ||
3025 | #ifdef USE_DMAC | ||
3026 | if (!request_region(ashost->dma.io_port, 256, "acornscsi(dmac)")) | ||
3027 | goto err_4; | ||
3028 | #endif | ||
3029 | if (!request_region(host->io_port, 2048, "acornscsi(ram)")) | ||
3030 | goto err_5; | ||
3031 | |||
3032 | ret = request_irq(host->irq, acornscsi_intr, IRQF_DISABLED, "acornscsi", ashost); | 2998 | ret = request_irq(host->irq, acornscsi_intr, IRQF_DISABLED, "acornscsi", ashost); |
3033 | if (ret) { | 2999 | if (ret) { |
3034 | printk(KERN_CRIT "scsi%d: IRQ%d not free: %d\n", | 3000 | printk(KERN_CRIT "scsi%d: IRQ%d not free: %d\n", |
3035 | host->host_no, ashost->scsi.irq, ret); | 3001 | host->host_no, ashost->scsi.irq, ret); |
3036 | goto err_6; | 3002 | goto out_put; |
3037 | } | 3003 | } |
3038 | 3004 | ||
3039 | memset(&ashost->stats, 0, sizeof (ashost->stats)); | 3005 | memset(&ashost->stats, 0, sizeof (ashost->stats)); |
@@ -3045,27 +3011,22 @@ acornscsi_probe(struct expansion_card *ec, const struct ecard_id *id) | |||
3045 | 3011 | ||
3046 | ret = scsi_add_host(host, &ec->dev); | 3012 | ret = scsi_add_host(host, &ec->dev); |
3047 | if (ret) | 3013 | if (ret) |
3048 | goto err_7; | 3014 | goto out_irq; |
3049 | 3015 | ||
3050 | scsi_scan_host(host); | 3016 | scsi_scan_host(host); |
3051 | goto out; | 3017 | goto out; |
3052 | 3018 | ||
3053 | err_7: | 3019 | out_irq: |
3054 | free_irq(host->irq, ashost); | 3020 | free_irq(host->irq, ashost); |
3055 | err_6: | 3021 | msgqueue_free(&ashost->scsi.msgs); |
3056 | release_region(host->io_port, 2048); | 3022 | queue_free(&ashost->queues.disconnected); |
3057 | err_5: | 3023 | queue_free(&ashost->queues.issue); |
3058 | #ifdef USE_DMAC | 3024 | out_put: |
3059 | release_region(ashost->dma.io_port, 256); | 3025 | ecardm_iounmap(ec, ashost->fast); |
3060 | #endif | 3026 | ecardm_iounmap(ec, ashost->base); |
3061 | err_4: | ||
3062 | release_region(ashost->card.io_page, 1); | ||
3063 | err_3: | ||
3064 | release_region(ashost->card.io_intr, 1); | ||
3065 | err_2: | ||
3066 | release_region(host->io_port + 0x800, 2); | ||
3067 | err_1: | ||
3068 | scsi_host_put(host); | 3027 | scsi_host_put(host); |
3028 | out_release: | ||
3029 | ecard_release_resources(ec); | ||
3069 | out: | 3030 | out: |
3070 | return ret; | 3031 | return ret; |
3071 | } | 3032 | } |
@@ -3081,20 +3042,17 @@ static void __devexit acornscsi_remove(struct expansion_card *ec) | |||
3081 | /* | 3042 | /* |
3082 | * Put card into RESET state | 3043 | * Put card into RESET state |
3083 | */ | 3044 | */ |
3084 | outb(0x80, ashost->card.io_page); | 3045 | writeb(0x80, ashost->fast + PAGE_REG); |
3085 | 3046 | ||
3086 | free_irq(host->irq, ashost); | 3047 | free_irq(host->irq, ashost); |
3087 | 3048 | ||
3088 | release_region(host->io_port + 0x800, 2); | ||
3089 | release_region(ashost->card.io_intr, 1); | ||
3090 | release_region(ashost->card.io_page, 1); | ||
3091 | release_region(ashost->dma.io_port, 256); | ||
3092 | release_region(host->io_port, 2048); | ||
3093 | |||
3094 | msgqueue_free(&ashost->scsi.msgs); | 3049 | msgqueue_free(&ashost->scsi.msgs); |
3095 | queue_free(&ashost->queues.disconnected); | 3050 | queue_free(&ashost->queues.disconnected); |
3096 | queue_free(&ashost->queues.issue); | 3051 | queue_free(&ashost->queues.issue); |
3052 | ecardm_iounmap(ec, ashost->fast); | ||
3053 | ecardm_iounmap(ec, ashost->base); | ||
3097 | scsi_host_put(host); | 3054 | scsi_host_put(host); |
3055 | ecard_release_resources(ec); | ||
3098 | } | 3056 | } |
3099 | 3057 | ||
3100 | static const struct ecard_id acornscsi_cids[] = { | 3058 | static const struct ecard_id acornscsi_cids[] = { |
diff --git a/drivers/scsi/arm/acornscsi.h b/drivers/scsi/arm/acornscsi.h index d11424b89f42..8d2172a0b351 100644 --- a/drivers/scsi/arm/acornscsi.h +++ b/drivers/scsi/arm/acornscsi.h | |||
@@ -179,7 +179,6 @@ | |||
179 | 179 | ||
180 | /* miscellaneous internal variables */ | 180 | /* miscellaneous internal variables */ |
181 | 181 | ||
182 | #define POD_SPACE(x) ((x) + 0xd0000) | ||
183 | #define MASK_ON (MASKREG_M3|MASKREG_M2|MASKREG_M1|MASKREG_M0) | 182 | #define MASK_ON (MASKREG_M3|MASKREG_M2|MASKREG_M1|MASKREG_M0) |
184 | #define MASK_OFF (MASKREG_M3|MASKREG_M2|MASKREG_M1) | 183 | #define MASK_OFF (MASKREG_M3|MASKREG_M2|MASKREG_M1) |
185 | 184 | ||
@@ -279,10 +278,11 @@ typedef struct acornscsi_hostdata { | |||
279 | struct Scsi_Host *host; /* host */ | 278 | struct Scsi_Host *host; /* host */ |
280 | struct scsi_cmnd *SCpnt; /* currently processing command */ | 279 | struct scsi_cmnd *SCpnt; /* currently processing command */ |
281 | struct scsi_cmnd *origSCpnt; /* original connecting command */ | 280 | struct scsi_cmnd *origSCpnt; /* original connecting command */ |
281 | void __iomem *base; /* memc base address */ | ||
282 | void __iomem *fast; /* fast ioc base address */ | ||
282 | 283 | ||
283 | /* driver information */ | 284 | /* driver information */ |
284 | struct { | 285 | struct { |
285 | unsigned int io_port; /* base address of WD33C93 */ | ||
286 | unsigned int irq; /* interrupt */ | 286 | unsigned int irq; /* interrupt */ |
287 | phase_t phase; /* current phase */ | 287 | phase_t phase; /* current phase */ |
288 | 288 | ||
@@ -329,8 +329,6 @@ typedef struct acornscsi_hostdata { | |||
329 | 329 | ||
330 | /* DMA info */ | 330 | /* DMA info */ |
331 | struct { | 331 | struct { |
332 | unsigned int io_port; /* base address of DMA controller */ | ||
333 | unsigned int io_intr_clear; /* address of DMA interrupt clear */ | ||
334 | unsigned int free_addr; /* next free address */ | 332 | unsigned int free_addr; /* next free address */ |
335 | unsigned int start_addr; /* start address of current transfer */ | 333 | unsigned int start_addr; /* start address of current transfer */ |
336 | dmadir_t direction; /* dma direction */ | 334 | dmadir_t direction; /* dma direction */ |
@@ -345,9 +343,6 @@ typedef struct acornscsi_hostdata { | |||
345 | 343 | ||
346 | /* card info */ | 344 | /* card info */ |
347 | struct { | 345 | struct { |
348 | unsigned int io_intr; /* base address of interrupt id reg */ | ||
349 | unsigned int io_page; /* base address of page reg */ | ||
350 | unsigned int io_ram; /* base address of RAM access */ | ||
351 | unsigned char page_reg; /* current setting of page reg */ | 346 | unsigned char page_reg; /* current setting of page reg */ |
352 | } card; | 347 | } card; |
353 | 348 | ||
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index c4b938bc30d3..aa2011b64683 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/chio.h> /* here are all the ioctls */ | 22 | #include <linux/chio.h> /* here are all the ioctls */ |
23 | #include <linux/mutex.h> | 23 | #include <linux/mutex.h> |
24 | #include <linux/idr.h> | 24 | #include <linux/idr.h> |
25 | #include <linux/smp_lock.h> | ||
25 | 26 | ||
26 | #include <scsi/scsi.h> | 27 | #include <scsi/scsi.h> |
27 | #include <scsi/scsi_cmnd.h> | 28 | #include <scsi/scsi_cmnd.h> |
@@ -571,16 +572,19 @@ ch_open(struct inode *inode, struct file *file) | |||
571 | scsi_changer *ch; | 572 | scsi_changer *ch; |
572 | int minor = iminor(inode); | 573 | int minor = iminor(inode); |
573 | 574 | ||
575 | lock_kernel(); | ||
574 | spin_lock(&ch_index_lock); | 576 | spin_lock(&ch_index_lock); |
575 | ch = idr_find(&ch_index_idr, minor); | 577 | ch = idr_find(&ch_index_idr, minor); |
576 | 578 | ||
577 | if (NULL == ch || scsi_device_get(ch->device)) { | 579 | if (NULL == ch || scsi_device_get(ch->device)) { |
578 | spin_unlock(&ch_index_lock); | 580 | spin_unlock(&ch_index_lock); |
581 | unlock_kernel(); | ||
579 | return -ENXIO; | 582 | return -ENXIO; |
580 | } | 583 | } |
581 | spin_unlock(&ch_index_lock); | 584 | spin_unlock(&ch_index_lock); |
582 | 585 | ||
583 | file->private_data = ch; | 586 | file->private_data = ch; |
587 | unlock_kernel(); | ||
584 | return 0; | 588 | return 0; |
585 | } | 589 | } |
586 | 590 | ||
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index 8508816f303d..2bc30e32b67a 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c | |||
@@ -49,6 +49,7 @@ MODULE_DESCRIPTION("Adaptec I2O RAID Driver"); | |||
49 | #include <linux/kernel.h> /* for printk */ | 49 | #include <linux/kernel.h> /* for printk */ |
50 | #include <linux/sched.h> | 50 | #include <linux/sched.h> |
51 | #include <linux/reboot.h> | 51 | #include <linux/reboot.h> |
52 | #include <linux/smp_lock.h> | ||
52 | #include <linux/spinlock.h> | 53 | #include <linux/spinlock.h> |
53 | #include <linux/dma-mapping.h> | 54 | #include <linux/dma-mapping.h> |
54 | 55 | ||
@@ -1727,10 +1728,12 @@ static int adpt_open(struct inode *inode, struct file *file) | |||
1727 | int minor; | 1728 | int minor; |
1728 | adpt_hba* pHba; | 1729 | adpt_hba* pHba; |
1729 | 1730 | ||
1731 | lock_kernel(); | ||
1730 | //TODO check for root access | 1732 | //TODO check for root access |
1731 | // | 1733 | // |
1732 | minor = iminor(inode); | 1734 | minor = iminor(inode); |
1733 | if (minor >= hba_count) { | 1735 | if (minor >= hba_count) { |
1736 | unlock_kernel(); | ||
1734 | return -ENXIO; | 1737 | return -ENXIO; |
1735 | } | 1738 | } |
1736 | mutex_lock(&adpt_configuration_lock); | 1739 | mutex_lock(&adpt_configuration_lock); |
@@ -1741,6 +1744,7 @@ static int adpt_open(struct inode *inode, struct file *file) | |||
1741 | } | 1744 | } |
1742 | if (pHba == NULL) { | 1745 | if (pHba == NULL) { |
1743 | mutex_unlock(&adpt_configuration_lock); | 1746 | mutex_unlock(&adpt_configuration_lock); |
1747 | unlock_kernel(); | ||
1744 | return -ENXIO; | 1748 | return -ENXIO; |
1745 | } | 1749 | } |
1746 | 1750 | ||
@@ -1751,6 +1755,7 @@ static int adpt_open(struct inode *inode, struct file *file) | |||
1751 | 1755 | ||
1752 | pHba->in_use = 1; | 1756 | pHba->in_use = 1; |
1753 | mutex_unlock(&adpt_configuration_lock); | 1757 | mutex_unlock(&adpt_configuration_lock); |
1758 | unlock_kernel(); | ||
1754 | 1759 | ||
1755 | return 0; | 1760 | return 0; |
1756 | } | 1761 | } |
diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c index a0b6d414953d..59fbef08d690 100644 --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c | |||
@@ -2359,6 +2359,24 @@ void scsi_esp_unregister(struct esp *esp) | |||
2359 | } | 2359 | } |
2360 | EXPORT_SYMBOL(scsi_esp_unregister); | 2360 | EXPORT_SYMBOL(scsi_esp_unregister); |
2361 | 2361 | ||
2362 | static int esp_target_alloc(struct scsi_target *starget) | ||
2363 | { | ||
2364 | struct esp *esp = shost_priv(dev_to_shost(&starget->dev)); | ||
2365 | struct esp_target_data *tp = &esp->target[starget->id]; | ||
2366 | |||
2367 | tp->starget = starget; | ||
2368 | |||
2369 | return 0; | ||
2370 | } | ||
2371 | |||
2372 | static void esp_target_destroy(struct scsi_target *starget) | ||
2373 | { | ||
2374 | struct esp *esp = shost_priv(dev_to_shost(&starget->dev)); | ||
2375 | struct esp_target_data *tp = &esp->target[starget->id]; | ||
2376 | |||
2377 | tp->starget = NULL; | ||
2378 | } | ||
2379 | |||
2362 | static int esp_slave_alloc(struct scsi_device *dev) | 2380 | static int esp_slave_alloc(struct scsi_device *dev) |
2363 | { | 2381 | { |
2364 | struct esp *esp = shost_priv(dev->host); | 2382 | struct esp *esp = shost_priv(dev->host); |
@@ -2370,8 +2388,6 @@ static int esp_slave_alloc(struct scsi_device *dev) | |||
2370 | return -ENOMEM; | 2388 | return -ENOMEM; |
2371 | dev->hostdata = lp; | 2389 | dev->hostdata = lp; |
2372 | 2390 | ||
2373 | tp->starget = dev->sdev_target; | ||
2374 | |||
2375 | spi_min_period(tp->starget) = esp->min_period; | 2391 | spi_min_period(tp->starget) = esp->min_period; |
2376 | spi_max_offset(tp->starget) = 15; | 2392 | spi_max_offset(tp->starget) = 15; |
2377 | 2393 | ||
@@ -2608,6 +2624,8 @@ struct scsi_host_template scsi_esp_template = { | |||
2608 | .name = "esp", | 2624 | .name = "esp", |
2609 | .info = esp_info, | 2625 | .info = esp_info, |
2610 | .queuecommand = esp_queuecommand, | 2626 | .queuecommand = esp_queuecommand, |
2627 | .target_alloc = esp_target_alloc, | ||
2628 | .target_destroy = esp_target_destroy, | ||
2611 | .slave_alloc = esp_slave_alloc, | 2629 | .slave_alloc = esp_slave_alloc, |
2612 | .slave_configure = esp_slave_configure, | 2630 | .slave_configure = esp_slave_configure, |
2613 | .slave_destroy = esp_slave_destroy, | 2631 | .slave_destroy = esp_slave_destroy, |
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index 46771d4c81bd..822d5214692b 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c | |||
@@ -120,6 +120,7 @@ | |||
120 | #include <linux/timer.h> | 120 | #include <linux/timer.h> |
121 | #include <linux/dma-mapping.h> | 121 | #include <linux/dma-mapping.h> |
122 | #include <linux/list.h> | 122 | #include <linux/list.h> |
123 | #include <linux/smp_lock.h> | ||
123 | 124 | ||
124 | #ifdef GDTH_RTC | 125 | #ifdef GDTH_RTC |
125 | #include <linux/mc146818rtc.h> | 126 | #include <linux/mc146818rtc.h> |
@@ -4019,10 +4020,12 @@ static int gdth_open(struct inode *inode, struct file *filep) | |||
4019 | { | 4020 | { |
4020 | gdth_ha_str *ha; | 4021 | gdth_ha_str *ha; |
4021 | 4022 | ||
4023 | lock_kernel(); | ||
4022 | list_for_each_entry(ha, &gdth_instances, list) { | 4024 | list_for_each_entry(ha, &gdth_instances, list) { |
4023 | if (!ha->sdev) | 4025 | if (!ha->sdev) |
4024 | ha->sdev = scsi_get_host_dev(ha->shost); | 4026 | ha->sdev = scsi_get_host_dev(ha->shost); |
4025 | } | 4027 | } |
4028 | unlock_kernel(); | ||
4026 | 4029 | ||
4027 | TRACE(("gdth_open()\n")); | 4030 | TRACE(("gdth_open()\n")); |
4028 | return 0; | 4031 | return 0; |
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 44d8d5163a1a..683bce375c74 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
@@ -60,6 +60,13 @@ | |||
60 | 60 | ||
61 | #define IDESCSI_DEBUG_LOG 0 | 61 | #define IDESCSI_DEBUG_LOG 0 |
62 | 62 | ||
63 | #if IDESCSI_DEBUG_LOG | ||
64 | #define debug_log(fmt, args...) \ | ||
65 | printk(KERN_INFO "ide-scsi: " fmt, ## args) | ||
66 | #else | ||
67 | #define debug_log(fmt, args...) do {} while (0) | ||
68 | #endif | ||
69 | |||
63 | /* | 70 | /* |
64 | * SCSI command transformation layer | 71 | * SCSI command transformation layer |
65 | */ | 72 | */ |
@@ -129,14 +136,15 @@ static inline idescsi_scsi_t *drive_to_idescsi(ide_drive_t *ide_drive) | |||
129 | #define IDESCSI_PC_RQ 90 | 136 | #define IDESCSI_PC_RQ 90 |
130 | 137 | ||
131 | /* | 138 | /* |
132 | * PIO data transfer routines using the scatter gather table. | 139 | * PIO data transfer routine using the scatter gather table. |
133 | */ | 140 | */ |
134 | static void idescsi_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | 141 | static void ide_scsi_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, |
135 | unsigned int bcount) | 142 | unsigned int bcount, int write) |
136 | { | 143 | { |
137 | ide_hwif_t *hwif = drive->hwif; | 144 | ide_hwif_t *hwif = drive->hwif; |
138 | int count; | 145 | xfer_func_t *xf = write ? hwif->output_data : hwif->input_data; |
139 | char *buf; | 146 | char *buf; |
147 | int count; | ||
140 | 148 | ||
141 | while (bcount) { | 149 | while (bcount) { |
142 | count = min(pc->sg->length - pc->b_count, bcount); | 150 | count = min(pc->sg->length - pc->b_count, bcount); |
@@ -145,13 +153,13 @@ static void idescsi_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
145 | 153 | ||
146 | local_irq_save(flags); | 154 | local_irq_save(flags); |
147 | buf = kmap_atomic(sg_page(pc->sg), KM_IRQ0) + | 155 | buf = kmap_atomic(sg_page(pc->sg), KM_IRQ0) + |
148 | pc->sg->offset; | 156 | pc->sg->offset; |
149 | hwif->input_data(drive, NULL, buf + pc->b_count, count); | 157 | xf(drive, NULL, buf + pc->b_count, count); |
150 | kunmap_atomic(buf - pc->sg->offset, KM_IRQ0); | 158 | kunmap_atomic(buf - pc->sg->offset, KM_IRQ0); |
151 | local_irq_restore(flags); | 159 | local_irq_restore(flags); |
152 | } else { | 160 | } else { |
153 | buf = sg_virt(pc->sg); | 161 | buf = sg_virt(pc->sg); |
154 | hwif->input_data(drive, NULL, buf + pc->b_count, count); | 162 | xf(drive, NULL, buf + pc->b_count, count); |
155 | } | 163 | } |
156 | bcount -= count; pc->b_count += count; | 164 | bcount -= count; pc->b_count += count; |
157 | if (pc->b_count == pc->sg->length) { | 165 | if (pc->b_count == pc->sg->length) { |
@@ -163,51 +171,34 @@ static void idescsi_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
163 | } | 171 | } |
164 | 172 | ||
165 | if (bcount) { | 173 | if (bcount) { |
166 | printk (KERN_ERR "ide-scsi: scatter gather table too small, discarding data\n"); | 174 | printk(KERN_ERR "%s: scatter gather table too small, %s\n", |
167 | ide_pad_transfer(drive, 0, bcount); | 175 | drive->name, write ? "padding with zeros" |
176 | : "discarding data"); | ||
177 | ide_pad_transfer(drive, write, bcount); | ||
168 | } | 178 | } |
169 | } | 179 | } |
170 | 180 | ||
171 | static void idescsi_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | 181 | static void ide_scsi_hex_dump(u8 *data, int len) |
172 | unsigned int bcount) | ||
173 | { | 182 | { |
174 | ide_hwif_t *hwif = drive->hwif; | 183 | print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, data, len, 0); |
175 | int count; | 184 | } |
176 | char *buf; | ||
177 | 185 | ||
178 | while (bcount) { | 186 | static int idescsi_end_request(ide_drive_t *, int, int); |
179 | count = min(pc->sg->length - pc->b_count, bcount); | ||
180 | if (PageHighMem(sg_page(pc->sg))) { | ||
181 | unsigned long flags; | ||
182 | 187 | ||
183 | local_irq_save(flags); | 188 | static void ide_scsi_callback(ide_drive_t *drive) |
184 | buf = kmap_atomic(sg_page(pc->sg), KM_IRQ0) + | 189 | { |
185 | pc->sg->offset; | 190 | idescsi_scsi_t *scsi = drive_to_idescsi(drive); |
186 | hwif->output_data(drive, NULL, buf + pc->b_count, count); | 191 | struct ide_atapi_pc *pc = scsi->pc; |
187 | kunmap_atomic(buf - pc->sg->offset, KM_IRQ0); | ||
188 | local_irq_restore(flags); | ||
189 | } else { | ||
190 | buf = sg_virt(pc->sg); | ||
191 | hwif->output_data(drive, NULL, buf + pc->b_count, count); | ||
192 | } | ||
193 | bcount -= count; pc->b_count += count; | ||
194 | if (pc->b_count == pc->sg->length) { | ||
195 | if (!--pc->sg_cnt) | ||
196 | break; | ||
197 | pc->sg = sg_next(pc->sg); | ||
198 | pc->b_count = 0; | ||
199 | } | ||
200 | } | ||
201 | 192 | ||
202 | if (bcount) { | 193 | if (pc->flags & PC_FLAG_TIMEDOUT) |
203 | printk (KERN_ERR "ide-scsi: scatter gather table too small, padding with zeros\n"); | 194 | debug_log("%s: got timed out packet %lu at %lu\n", __func__, |
204 | ide_pad_transfer(drive, 1, bcount); | 195 | pc->scsi_cmd->serial_number, jiffies); |
205 | } | 196 | /* end this request now - scsi should retry it*/ |
206 | } | 197 | else if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) |
198 | printk(KERN_INFO "Packet command completed, %d bytes" | ||
199 | " transferred\n", pc->xferred); | ||
207 | 200 | ||
208 | static void ide_scsi_hex_dump(u8 *data, int len) | 201 | idescsi_end_request(drive, 1, 0); |
209 | { | ||
210 | print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, data, len, 0); | ||
211 | } | 202 | } |
212 | 203 | ||
213 | static int idescsi_check_condition(ide_drive_t *drive, | 204 | static int idescsi_check_condition(ide_drive_t *drive, |
@@ -228,14 +219,16 @@ static int idescsi_check_condition(ide_drive_t *drive, | |||
228 | kfree(pc); | 219 | kfree(pc); |
229 | return -ENOMEM; | 220 | return -ENOMEM; |
230 | } | 221 | } |
231 | ide_init_drive_cmd(rq); | 222 | blk_rq_init(NULL, rq); |
232 | rq->special = (char *) pc; | 223 | rq->special = (char *) pc; |
233 | pc->rq = rq; | 224 | pc->rq = rq; |
234 | pc->buf = buf; | 225 | pc->buf = buf; |
235 | pc->c[0] = REQUEST_SENSE; | 226 | pc->c[0] = REQUEST_SENSE; |
236 | pc->c[4] = pc->req_xfer = pc->buf_size = SCSI_SENSE_BUFFERSIZE; | 227 | pc->c[4] = pc->req_xfer = pc->buf_size = SCSI_SENSE_BUFFERSIZE; |
237 | rq->cmd_type = REQ_TYPE_SENSE; | 228 | rq->cmd_type = REQ_TYPE_SENSE; |
229 | rq->cmd_flags |= REQ_PREEMPT; | ||
238 | pc->timeout = jiffies + WAIT_READY; | 230 | pc->timeout = jiffies + WAIT_READY; |
231 | pc->callback = ide_scsi_callback; | ||
239 | /* NOTE! Save the failed packet command in "rq->buffer" */ | 232 | /* NOTE! Save the failed packet command in "rq->buffer" */ |
240 | rq->buffer = (void *) failed_cmd->special; | 233 | rq->buffer = (void *) failed_cmd->special; |
241 | pc->scsi_cmd = ((struct ide_atapi_pc *) failed_cmd->special)->scsi_cmd; | 234 | pc->scsi_cmd = ((struct ide_atapi_pc *) failed_cmd->special)->scsi_cmd; |
@@ -244,11 +237,10 @@ static int idescsi_check_condition(ide_drive_t *drive, | |||
244 | ide_scsi_hex_dump(pc->c, 6); | 237 | ide_scsi_hex_dump(pc->c, 6); |
245 | } | 238 | } |
246 | rq->rq_disk = scsi->disk; | 239 | rq->rq_disk = scsi->disk; |
247 | return ide_do_drive_cmd(drive, rq, ide_preempt); | 240 | ide_do_drive_cmd(drive, rq); |
241 | return 0; | ||
248 | } | 242 | } |
249 | 243 | ||
250 | static int idescsi_end_request(ide_drive_t *, int, int); | ||
251 | |||
252 | static ide_startstop_t | 244 | static ide_startstop_t |
253 | idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) | 245 | idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) |
254 | { | 246 | { |
@@ -256,7 +248,7 @@ idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) | |||
256 | 248 | ||
257 | if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) | 249 | if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) |
258 | /* force an abort */ | 250 | /* force an abort */ |
259 | hwif->OUTBSYNC(drive, WIN_IDLEIMMEDIATE, | 251 | hwif->OUTBSYNC(hwif, WIN_IDLEIMMEDIATE, |
260 | hwif->io_ports.command_addr); | 252 | hwif->io_ports.command_addr); |
261 | 253 | ||
262 | rq->errors++; | 254 | rq->errors++; |
@@ -269,10 +261,9 @@ idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) | |||
269 | static ide_startstop_t | 261 | static ide_startstop_t |
270 | idescsi_atapi_abort(ide_drive_t *drive, struct request *rq) | 262 | idescsi_atapi_abort(ide_drive_t *drive, struct request *rq) |
271 | { | 263 | { |
272 | #if IDESCSI_DEBUG_LOG | 264 | debug_log("%s called for %lu\n", __func__, |
273 | printk(KERN_WARNING "idescsi_atapi_abort called for %lu\n", | ||
274 | ((struct ide_atapi_pc *) rq->special)->scsi_cmd->serial_number); | 265 | ((struct ide_atapi_pc *) rq->special)->scsi_cmd->serial_number); |
275 | #endif | 266 | |
276 | rq->errors |= ERROR_MAX; | 267 | rq->errors |= ERROR_MAX; |
277 | 268 | ||
278 | idescsi_end_request(drive, 0, 0); | 269 | idescsi_end_request(drive, 0, 0); |
@@ -351,9 +342,9 @@ static int idescsi_expiry(ide_drive_t *drive) | |||
351 | idescsi_scsi_t *scsi = drive_to_idescsi(drive); | 342 | idescsi_scsi_t *scsi = drive_to_idescsi(drive); |
352 | struct ide_atapi_pc *pc = scsi->pc; | 343 | struct ide_atapi_pc *pc = scsi->pc; |
353 | 344 | ||
354 | #if IDESCSI_DEBUG_LOG | 345 | debug_log("%s called for %lu at %lu\n", __func__, |
355 | printk(KERN_WARNING "idescsi_expiry called for %lu at %lu\n", pc->scsi_cmd->serial_number, jiffies); | 346 | pc->scsi_cmd->serial_number, jiffies); |
356 | #endif | 347 | |
357 | pc->flags |= PC_FLAG_TIMEDOUT; | 348 | pc->flags |= PC_FLAG_TIMEDOUT; |
358 | 349 | ||
359 | return 0; /* we do not want the ide subsystem to retry */ | 350 | return 0; /* we do not want the ide subsystem to retry */ |
@@ -365,141 +356,19 @@ static int idescsi_expiry(ide_drive_t *drive) | |||
365 | static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) | 356 | static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) |
366 | { | 357 | { |
367 | idescsi_scsi_t *scsi = drive_to_idescsi(drive); | 358 | idescsi_scsi_t *scsi = drive_to_idescsi(drive); |
368 | ide_hwif_t *hwif = drive->hwif; | ||
369 | struct ide_atapi_pc *pc = scsi->pc; | 359 | struct ide_atapi_pc *pc = scsi->pc; |
370 | struct request *rq = pc->rq; | ||
371 | unsigned int temp; | ||
372 | u16 bcount; | ||
373 | u8 stat, ireason; | ||
374 | |||
375 | #if IDESCSI_DEBUG_LOG | ||
376 | printk (KERN_INFO "ide-scsi: Reached idescsi_pc_intr interrupt handler\n"); | ||
377 | #endif /* IDESCSI_DEBUG_LOG */ | ||
378 | |||
379 | if (pc->flags & PC_FLAG_TIMEDOUT) { | ||
380 | #if IDESCSI_DEBUG_LOG | ||
381 | printk(KERN_WARNING "idescsi_pc_intr: got timed out packet %lu at %lu\n", | ||
382 | pc->scsi_cmd->serial_number, jiffies); | ||
383 | #endif | ||
384 | /* end this request now - scsi should retry it*/ | ||
385 | idescsi_end_request (drive, 1, 0); | ||
386 | return ide_stopped; | ||
387 | } | ||
388 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | ||
389 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | ||
390 | #if IDESCSI_DEBUG_LOG | ||
391 | printk ("ide-scsi: %s: DMA complete\n", drive->name); | ||
392 | #endif /* IDESCSI_DEBUG_LOG */ | ||
393 | pc->xferred = pc->req_xfer; | ||
394 | (void)hwif->dma_ops->dma_end(drive); | ||
395 | } | ||
396 | |||
397 | /* Clear the interrupt */ | ||
398 | stat = ide_read_status(drive); | ||
399 | |||
400 | if ((stat & DRQ_STAT) == 0) { | ||
401 | /* No more interrupts */ | ||
402 | if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) | ||
403 | printk(KERN_INFO "Packet command completed, %d bytes" | ||
404 | " transferred\n", pc->xferred); | ||
405 | local_irq_enable_in_hardirq(); | ||
406 | if (stat & ERR_STAT) | ||
407 | rq->errors++; | ||
408 | idescsi_end_request (drive, 1, 0); | ||
409 | return ide_stopped; | ||
410 | } | ||
411 | bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) | | ||
412 | hwif->INB(hwif->io_ports.lbam_addr); | ||
413 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
414 | |||
415 | if (ireason & CD) { | ||
416 | printk(KERN_ERR "ide-scsi: CoD != 0 in idescsi_pc_intr\n"); | ||
417 | return ide_do_reset (drive); | ||
418 | } | ||
419 | if (ireason & IO) { | ||
420 | temp = pc->xferred + bcount; | ||
421 | if (temp > pc->req_xfer) { | ||
422 | if (temp > pc->buf_size) { | ||
423 | printk(KERN_ERR "ide-scsi: The scsi wants to " | ||
424 | "send us more data than expected " | ||
425 | "- discarding data\n"); | ||
426 | temp = pc->buf_size - pc->xferred; | ||
427 | if (temp) { | ||
428 | pc->flags &= ~PC_FLAG_WRITING; | ||
429 | if (pc->sg) | ||
430 | idescsi_input_buffers(drive, pc, | ||
431 | temp); | ||
432 | else | ||
433 | hwif->input_data(drive, NULL, | ||
434 | pc->cur_pos, temp); | ||
435 | printk(KERN_ERR "ide-scsi: transferred" | ||
436 | " %d of %d bytes\n", | ||
437 | temp, bcount); | ||
438 | } | ||
439 | pc->xferred += temp; | ||
440 | pc->cur_pos += temp; | ||
441 | ide_pad_transfer(drive, 0, bcount - temp); | ||
442 | ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry); | ||
443 | return ide_started; | ||
444 | } | ||
445 | #if IDESCSI_DEBUG_LOG | ||
446 | printk (KERN_NOTICE "ide-scsi: The scsi wants to send us more data than expected - allowing transfer\n"); | ||
447 | #endif /* IDESCSI_DEBUG_LOG */ | ||
448 | } | ||
449 | } | ||
450 | if (ireason & IO) { | ||
451 | pc->flags &= ~PC_FLAG_WRITING; | ||
452 | if (pc->sg) | ||
453 | idescsi_input_buffers(drive, pc, bcount); | ||
454 | else | ||
455 | hwif->input_data(drive, NULL, pc->cur_pos, bcount); | ||
456 | } else { | ||
457 | pc->flags |= PC_FLAG_WRITING; | ||
458 | if (pc->sg) | ||
459 | idescsi_output_buffers(drive, pc, bcount); | ||
460 | else | ||
461 | hwif->output_data(drive, NULL, pc->cur_pos, bcount); | ||
462 | } | ||
463 | /* Update the current position */ | ||
464 | pc->xferred += bcount; | ||
465 | pc->cur_pos += bcount; | ||
466 | 360 | ||
467 | /* And set the interrupt handler again */ | 361 | return ide_pc_intr(drive, pc, idescsi_pc_intr, get_timeout(pc), |
468 | ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry); | 362 | idescsi_expiry, NULL, NULL, NULL, |
469 | return ide_started; | 363 | ide_scsi_io_buffers); |
470 | } | 364 | } |
471 | 365 | ||
472 | static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive) | 366 | static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive) |
473 | { | 367 | { |
474 | ide_hwif_t *hwif = drive->hwif; | ||
475 | idescsi_scsi_t *scsi = drive_to_idescsi(drive); | 368 | idescsi_scsi_t *scsi = drive_to_idescsi(drive); |
476 | struct ide_atapi_pc *pc = scsi->pc; | ||
477 | ide_startstop_t startstop; | ||
478 | u8 ireason; | ||
479 | 369 | ||
480 | if (ide_wait_stat(&startstop,drive,DRQ_STAT,BUSY_STAT,WAIT_READY)) { | 370 | return ide_transfer_pc(drive, scsi->pc, idescsi_pc_intr, |
481 | printk(KERN_ERR "ide-scsi: Strange, packet command " | 371 | get_timeout(scsi->pc), idescsi_expiry); |
482 | "initiated yet DRQ isn't asserted\n"); | ||
483 | return startstop; | ||
484 | } | ||
485 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
486 | if ((ireason & CD) == 0 || (ireason & IO)) { | ||
487 | printk(KERN_ERR "ide-scsi: (IO,CoD) != (0,1) while " | ||
488 | "issuing a packet command\n"); | ||
489 | return ide_do_reset (drive); | ||
490 | } | ||
491 | BUG_ON(HWGROUP(drive)->handler != NULL); | ||
492 | /* Set the interrupt routine */ | ||
493 | ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry); | ||
494 | |||
495 | /* Send the actual packet */ | ||
496 | hwif->output_data(drive, NULL, scsi->pc->c, 12); | ||
497 | |||
498 | if (pc->flags & PC_FLAG_DMA_OK) { | ||
499 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; | ||
500 | hwif->dma_ops->dma_start(drive); | ||
501 | } | ||
502 | return ide_started; | ||
503 | } | 372 | } |
504 | 373 | ||
505 | static inline int idescsi_set_direction(struct ide_atapi_pc *pc) | 374 | static inline int idescsi_set_direction(struct ide_atapi_pc *pc) |
@@ -545,38 +414,12 @@ static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive, | |||
545 | struct ide_atapi_pc *pc) | 414 | struct ide_atapi_pc *pc) |
546 | { | 415 | { |
547 | idescsi_scsi_t *scsi = drive_to_idescsi(drive); | 416 | idescsi_scsi_t *scsi = drive_to_idescsi(drive); |
548 | ide_hwif_t *hwif = drive->hwif; | ||
549 | u16 bcount; | ||
550 | u8 dma = 0; | ||
551 | 417 | ||
552 | /* Set the current packet command */ | 418 | /* Set the current packet command */ |
553 | scsi->pc = pc; | 419 | scsi->pc = pc; |
554 | /* We haven't transferred any data yet */ | ||
555 | pc->xferred = 0; | ||
556 | pc->cur_pos = pc->buf; | ||
557 | /* Request to transfer the entire buffer at once */ | ||
558 | bcount = min(pc->req_xfer, 63 * 1024); | ||
559 | |||
560 | if (drive->using_dma && !idescsi_map_sg(drive, pc)) { | ||
561 | hwif->sg_mapped = 1; | ||
562 | dma = !hwif->dma_ops->dma_setup(drive); | ||
563 | hwif->sg_mapped = 0; | ||
564 | } | ||
565 | |||
566 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK, bcount, dma); | ||
567 | 420 | ||
568 | if (dma) | 421 | return ide_issue_pc(drive, pc, idescsi_transfer_pc, |
569 | pc->flags |= PC_FLAG_DMA_OK; | 422 | get_timeout(pc), idescsi_expiry); |
570 | |||
571 | if (test_bit(IDESCSI_DRQ_INTERRUPT, &scsi->flags)) { | ||
572 | ide_execute_command(drive, WIN_PACKETCMD, &idescsi_transfer_pc, | ||
573 | get_timeout(pc), idescsi_expiry); | ||
574 | return ide_started; | ||
575 | } else { | ||
576 | /* Issue the packet command */ | ||
577 | ide_execute_pkt_cmd(drive); | ||
578 | return idescsi_transfer_pc(drive); | ||
579 | } | ||
580 | } | 423 | } |
581 | 424 | ||
582 | /* | 425 | /* |
@@ -584,14 +427,22 @@ static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive, | |||
584 | */ | 427 | */ |
585 | static ide_startstop_t idescsi_do_request (ide_drive_t *drive, struct request *rq, sector_t block) | 428 | static ide_startstop_t idescsi_do_request (ide_drive_t *drive, struct request *rq, sector_t block) |
586 | { | 429 | { |
587 | #if IDESCSI_DEBUG_LOG | 430 | debug_log("dev: %s, cmd: %x, errors: %d\n", rq->rq_disk->disk_name, |
588 | printk (KERN_INFO "dev: %s, cmd: %x, errors: %d\n", rq->rq_disk->disk_name,rq->cmd[0],rq->errors); | 431 | rq->cmd[0], rq->errors); |
589 | printk (KERN_INFO "sector: %ld, nr_sectors: %ld, current_nr_sectors: %d\n",rq->sector,rq->nr_sectors,rq->current_nr_sectors); | 432 | debug_log("sector: %ld, nr_sectors: %ld, current_nr_sectors: %d\n", |
590 | #endif /* IDESCSI_DEBUG_LOG */ | 433 | rq->sector, rq->nr_sectors, rq->current_nr_sectors); |
591 | 434 | ||
592 | if (blk_sense_request(rq) || blk_special_request(rq)) { | 435 | if (blk_sense_request(rq) || blk_special_request(rq)) { |
593 | return idescsi_issue_pc(drive, | 436 | struct ide_atapi_pc *pc = (struct ide_atapi_pc *)rq->special; |
594 | (struct ide_atapi_pc *) rq->special); | 437 | idescsi_scsi_t *scsi = drive_to_idescsi(drive); |
438 | |||
439 | if (test_bit(IDESCSI_DRQ_INTERRUPT, &scsi->flags)) | ||
440 | pc->flags |= PC_FLAG_DRQ_INTERRUPT; | ||
441 | |||
442 | if (drive->using_dma && !idescsi_map_sg(drive, pc)) | ||
443 | pc->flags |= PC_FLAG_DMA_OK; | ||
444 | |||
445 | return idescsi_issue_pc(drive, pc); | ||
595 | } | 446 | } |
596 | blk_dump_rq_flags(rq, "ide-scsi: unsup command"); | 447 | blk_dump_rq_flags(rq, "ide-scsi: unsup command"); |
597 | idescsi_end_request (drive, 0, 0); | 448 | idescsi_end_request (drive, 0, 0); |
@@ -646,6 +497,8 @@ static void ide_scsi_remove(ide_drive_t *drive) | |||
646 | put_disk(g); | 497 | put_disk(g); |
647 | 498 | ||
648 | ide_scsi_put(scsi); | 499 | ide_scsi_put(scsi); |
500 | |||
501 | drive->scsi = 0; | ||
649 | } | 502 | } |
650 | 503 | ||
651 | static int ide_scsi_probe(ide_drive_t *); | 504 | static int ide_scsi_probe(ide_drive_t *); |
@@ -765,6 +618,8 @@ static int idescsi_queue (struct scsi_cmnd *cmd, | |||
765 | 618 | ||
766 | memset (pc->c, 0, 12); | 619 | memset (pc->c, 0, 12); |
767 | pc->flags = 0; | 620 | pc->flags = 0; |
621 | if (cmd->sc_data_direction == DMA_TO_DEVICE) | ||
622 | pc->flags |= PC_FLAG_WRITING; | ||
768 | pc->rq = rq; | 623 | pc->rq = rq; |
769 | memcpy (pc->c, cmd->cmnd, cmd->cmd_len); | 624 | memcpy (pc->c, cmd->cmnd, cmd->cmd_len); |
770 | pc->buf = NULL; | 625 | pc->buf = NULL; |
@@ -775,6 +630,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd, | |||
775 | pc->scsi_cmd = cmd; | 630 | pc->scsi_cmd = cmd; |
776 | pc->done = done; | 631 | pc->done = done; |
777 | pc->timeout = jiffies + cmd->timeout_per_command; | 632 | pc->timeout = jiffies + cmd->timeout_per_command; |
633 | pc->callback = ide_scsi_callback; | ||
778 | 634 | ||
779 | if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) { | 635 | if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) { |
780 | printk ("ide-scsi: %s: que %lu, cmd = ", drive->name, cmd->serial_number); | 636 | printk ("ide-scsi: %s: que %lu, cmd = ", drive->name, cmd->serial_number); |
@@ -785,12 +641,11 @@ static int idescsi_queue (struct scsi_cmnd *cmd, | |||
785 | } | 641 | } |
786 | } | 642 | } |
787 | 643 | ||
788 | ide_init_drive_cmd (rq); | 644 | blk_rq_init(NULL, rq); |
789 | rq->special = (char *) pc; | 645 | rq->special = (char *) pc; |
790 | rq->cmd_type = REQ_TYPE_SPECIAL; | 646 | rq->cmd_type = REQ_TYPE_SPECIAL; |
791 | spin_unlock_irq(host->host_lock); | 647 | spin_unlock_irq(host->host_lock); |
792 | rq->rq_disk = scsi->disk; | 648 | blk_execute_rq_nowait(drive->queue, scsi->disk, rq, 0, NULL); |
793 | (void) ide_do_drive_cmd (drive, rq, ide_end); | ||
794 | spin_lock_irq(host->host_lock); | 649 | spin_lock_irq(host->host_lock); |
795 | return 0; | 650 | return 0; |
796 | abort: | 651 | abort: |
@@ -985,6 +840,8 @@ static int ide_scsi_probe(ide_drive_t *drive) | |||
985 | !(host = scsi_host_alloc(&idescsi_template,sizeof(idescsi_scsi_t)))) | 840 | !(host = scsi_host_alloc(&idescsi_template,sizeof(idescsi_scsi_t)))) |
986 | return -ENODEV; | 841 | return -ENODEV; |
987 | 842 | ||
843 | drive->scsi = 1; | ||
844 | |||
988 | g = alloc_disk(1 << PARTN_BITS); | 845 | g = alloc_disk(1 << PARTN_BITS); |
989 | if (!g) | 846 | if (!g) |
990 | goto out_host_put; | 847 | goto out_host_put; |
@@ -993,10 +850,10 @@ static int ide_scsi_probe(ide_drive_t *drive) | |||
993 | 850 | ||
994 | host->max_id = 1; | 851 | host->max_id = 1; |
995 | 852 | ||
996 | #if IDESCSI_DEBUG_LOG | ||
997 | if (drive->id->last_lun) | 853 | if (drive->id->last_lun) |
998 | printk(KERN_NOTICE "%s: id->last_lun=%u\n", drive->name, drive->id->last_lun); | 854 | debug_log("%s: id->last_lun=%u\n", drive->name, |
999 | #endif | 855 | drive->id->last_lun); |
856 | |||
1000 | if ((drive->id->last_lun & 0x7) != 7) | 857 | if ((drive->id->last_lun & 0x7) != 7) |
1001 | host->max_lun = (drive->id->last_lun & 0x7) + 1; | 858 | host->max_lun = (drive->id->last_lun & 0x7) + 1; |
1002 | else | 859 | else |
@@ -1025,6 +882,7 @@ static int ide_scsi_probe(ide_drive_t *drive) | |||
1025 | 882 | ||
1026 | put_disk(g); | 883 | put_disk(g); |
1027 | out_host_put: | 884 | out_host_put: |
885 | drive->scsi = 0; | ||
1028 | scsi_host_put(host); | 886 | scsi_host_put(host); |
1029 | return err; | 887 | return err; |
1030 | } | 888 | } |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 999e91ea7451..e7a3a6554425 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -71,6 +71,7 @@ | |||
71 | #include <linux/module.h> | 71 | #include <linux/module.h> |
72 | #include <linux/moduleparam.h> | 72 | #include <linux/moduleparam.h> |
73 | #include <linux/libata.h> | 73 | #include <linux/libata.h> |
74 | #include <linux/hdreg.h> | ||
74 | #include <asm/io.h> | 75 | #include <asm/io.h> |
75 | #include <asm/irq.h> | 76 | #include <asm/irq.h> |
76 | #include <asm/processor.h> | 77 | #include <asm/processor.h> |
@@ -4913,8 +4914,11 @@ static int ipr_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) | |||
4913 | struct ipr_resource_entry *res; | 4914 | struct ipr_resource_entry *res; |
4914 | 4915 | ||
4915 | res = (struct ipr_resource_entry *)sdev->hostdata; | 4916 | res = (struct ipr_resource_entry *)sdev->hostdata; |
4916 | if (res && ipr_is_gata(res)) | 4917 | if (res && ipr_is_gata(res)) { |
4918 | if (cmd == HDIO_GET_IDENTITY) | ||
4919 | return -ENOTTY; | ||
4917 | return ata_scsi_ioctl(sdev, cmd, arg); | 4920 | return ata_scsi_ioctl(sdev, cmd, arg); |
4921 | } | ||
4918 | 4922 | ||
4919 | return -EINVAL; | 4923 | return -EINVAL; |
4920 | } | 4924 | } |
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 18551aaf5e09..28c9da7d4a5c 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/pci.h> | 46 | #include <linux/pci.h> |
47 | #include <linux/init.h> | 47 | #include <linux/init.h> |
48 | #include <linux/dma-mapping.h> | 48 | #include <linux/dma-mapping.h> |
49 | #include <linux/smp_lock.h> | ||
49 | #include <scsi/scsicam.h> | 50 | #include <scsi/scsicam.h> |
50 | 51 | ||
51 | #include "scsi.h" | 52 | #include "scsi.h" |
@@ -3272,12 +3273,12 @@ mega_init_scb(adapter_t *adapter) | |||
3272 | * @filep - unused | 3273 | * @filep - unused |
3273 | * | 3274 | * |
3274 | * Routines for the character/ioctl interface to the driver. Find out if this | 3275 | * Routines for the character/ioctl interface to the driver. Find out if this |
3275 | * is a valid open. If yes, increment the module use count so that it cannot | 3276 | * is a valid open. |
3276 | * be unloaded. | ||
3277 | */ | 3277 | */ |
3278 | static int | 3278 | static int |
3279 | megadev_open (struct inode *inode, struct file *filep) | 3279 | megadev_open (struct inode *inode, struct file *filep) |
3280 | { | 3280 | { |
3281 | cycle_kernel_lock(); | ||
3281 | /* | 3282 | /* |
3282 | * Only allow superuser to access private ioctl interface | 3283 | * Only allow superuser to access private ioctl interface |
3283 | */ | 3284 | */ |
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c index 0ad215e27b83..ac3b280c2a72 100644 --- a/drivers/scsi/megaraid/megaraid_mm.c +++ b/drivers/scsi/megaraid/megaraid_mm.c | |||
@@ -15,6 +15,7 @@ | |||
15 | * Common management module | 15 | * Common management module |
16 | */ | 16 | */ |
17 | #include <linux/sched.h> | 17 | #include <linux/sched.h> |
18 | #include <linux/smp_lock.h> | ||
18 | #include "megaraid_mm.h" | 19 | #include "megaraid_mm.h" |
19 | 20 | ||
20 | 21 | ||
@@ -96,6 +97,7 @@ mraid_mm_open(struct inode *inode, struct file *filep) | |||
96 | */ | 97 | */ |
97 | if (!capable(CAP_SYS_ADMIN)) return (-EACCES); | 98 | if (!capable(CAP_SYS_ADMIN)) return (-EACCES); |
98 | 99 | ||
100 | cycle_kernel_lock(); | ||
99 | return 0; | 101 | return 0; |
100 | } | 102 | } |
101 | 103 | ||
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c index 7d84c8bbcf3f..fc7ac158476c 100644 --- a/drivers/scsi/megaraid/megaraid_sas.c +++ b/drivers/scsi/megaraid/megaraid_sas.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/spinlock.h> | 33 | #include <linux/spinlock.h> |
34 | #include <linux/interrupt.h> | 34 | #include <linux/interrupt.h> |
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/smp_lock.h> | ||
36 | #include <linux/uio.h> | 37 | #include <linux/uio.h> |
37 | #include <asm/uaccess.h> | 38 | #include <asm/uaccess.h> |
38 | #include <linux/fs.h> | 39 | #include <linux/fs.h> |
@@ -2863,6 +2864,7 @@ static void megasas_shutdown(struct pci_dev *pdev) | |||
2863 | */ | 2864 | */ |
2864 | static int megasas_mgmt_open(struct inode *inode, struct file *filep) | 2865 | static int megasas_mgmt_open(struct inode *inode, struct file *filep) |
2865 | { | 2866 | { |
2867 | cycle_kernel_lock(); | ||
2866 | /* | 2868 | /* |
2867 | * Allow only those users with admin rights | 2869 | * Allow only those users with admin rights |
2868 | */ | 2870 | */ |
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 243d8becd30f..1c79f9794f4e 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c | |||
@@ -50,6 +50,7 @@ static const char * osst_version = "0.99.4"; | |||
50 | #include <linux/moduleparam.h> | 50 | #include <linux/moduleparam.h> |
51 | #include <linux/delay.h> | 51 | #include <linux/delay.h> |
52 | #include <linux/jiffies.h> | 52 | #include <linux/jiffies.h> |
53 | #include <linux/smp_lock.h> | ||
53 | #include <asm/uaccess.h> | 54 | #include <asm/uaccess.h> |
54 | #include <asm/dma.h> | 55 | #include <asm/dma.h> |
55 | #include <asm/system.h> | 56 | #include <asm/system.h> |
@@ -4359,7 +4360,7 @@ os_bypass: | |||
4359 | 4360 | ||
4360 | 4361 | ||
4361 | /* Open the device */ | 4362 | /* Open the device */ |
4362 | static int os_scsi_tape_open(struct inode * inode, struct file * filp) | 4363 | static int __os_scsi_tape_open(struct inode * inode, struct file * filp) |
4363 | { | 4364 | { |
4364 | unsigned short flags; | 4365 | unsigned short flags; |
4365 | int i, b_size, new_session = 0, retval = 0; | 4366 | int i, b_size, new_session = 0, retval = 0; |
@@ -4725,6 +4726,18 @@ err_out: | |||
4725 | return retval; | 4726 | return retval; |
4726 | } | 4727 | } |
4727 | 4728 | ||
4729 | /* BKL pushdown: spaghetti avoidance wrapper */ | ||
4730 | static int os_scsi_tape_open(struct inode * inode, struct file * filp) | ||
4731 | { | ||
4732 | int ret; | ||
4733 | |||
4734 | lock_kernel(); | ||
4735 | ret = __os_scsi_tape_open(inode, filp); | ||
4736 | unlock_kernel(); | ||
4737 | return ret; | ||
4738 | } | ||
4739 | |||
4740 | |||
4728 | 4741 | ||
4729 | /* Flush the tape buffer before close */ | 4742 | /* Flush the tape buffer before close */ |
4730 | static int os_scsi_tape_flush(struct file * filp, fl_owner_t id) | 4743 | static int os_scsi_tape_flush(struct file * filp, fl_owner_t id) |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index a82d2fe80fb5..cbf55d59a54c 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -207,6 +207,15 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, | |||
207 | */ | 207 | */ |
208 | blk_execute_rq(req->q, NULL, req, 1); | 208 | blk_execute_rq(req->q, NULL, req, 1); |
209 | 209 | ||
210 | /* | ||
211 | * Some devices (USB mass-storage in particular) may transfer | ||
212 | * garbage data together with a residue indicating that the data | ||
213 | * is invalid. Prevent the garbage from being misinterpreted | ||
214 | * and prevent security leaks by zeroing out the excess data. | ||
215 | */ | ||
216 | if (unlikely(req->data_len > 0 && req->data_len <= bufflen)) | ||
217 | memset(buffer + (bufflen - req->data_len), 0, req->data_len); | ||
218 | |||
210 | ret = req->errors; | 219 | ret = req->errors; |
211 | out: | 220 | out: |
212 | blk_put_request(req); | 221 | blk_put_request(req); |
diff --git a/drivers/scsi/scsi_tgt_if.c b/drivers/scsi/scsi_tgt_if.c index d2557dbc2dc1..0e9533f7aabc 100644 --- a/drivers/scsi/scsi_tgt_if.c +++ b/drivers/scsi/scsi_tgt_if.c | |||
@@ -21,6 +21,7 @@ | |||
21 | */ | 21 | */ |
22 | #include <linux/miscdevice.h> | 22 | #include <linux/miscdevice.h> |
23 | #include <linux/file.h> | 23 | #include <linux/file.h> |
24 | #include <linux/smp_lock.h> | ||
24 | #include <net/tcp.h> | 25 | #include <net/tcp.h> |
25 | #include <scsi/scsi.h> | 26 | #include <scsi/scsi.h> |
26 | #include <scsi/scsi_cmnd.h> | 27 | #include <scsi/scsi_cmnd.h> |
@@ -321,6 +322,7 @@ static int tgt_open(struct inode *inode, struct file *file) | |||
321 | { | 322 | { |
322 | tx_ring.tr_idx = rx_ring.tr_idx = 0; | 323 | tx_ring.tr_idx = rx_ring.tr_idx = 0; |
323 | 324 | ||
325 | cycle_kernel_lock(); | ||
324 | return 0; | 326 | return 0; |
325 | } | 327 | } |
326 | 328 | ||
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index 45df83b9d847..0fe031f003e7 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c | |||
@@ -61,7 +61,7 @@ static int ses_probe(struct device *dev) | |||
61 | return err; | 61 | return err; |
62 | } | 62 | } |
63 | 63 | ||
64 | #define SES_TIMEOUT 30 | 64 | #define SES_TIMEOUT (30 * HZ) |
65 | #define SES_RETRIES 3 | 65 | #define SES_RETRIES 3 |
66 | 66 | ||
67 | static int ses_recv_diag(struct scsi_device *sdev, int page_code, | 67 | static int ses_recv_diag(struct scsi_device *sdev, int page_code, |
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index ea0edd1b2e76..fccd2e88d600 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -49,6 +49,7 @@ static int sg_version_num = 30534; /* 2 digits for each component */ | |||
49 | #include <linux/delay.h> | 49 | #include <linux/delay.h> |
50 | #include <linux/scatterlist.h> | 50 | #include <linux/scatterlist.h> |
51 | #include <linux/blktrace_api.h> | 51 | #include <linux/blktrace_api.h> |
52 | #include <linux/smp_lock.h> | ||
52 | 53 | ||
53 | #include "scsi.h" | 54 | #include "scsi.h" |
54 | #include <scsi/scsi_dbg.h> | 55 | #include <scsi/scsi_dbg.h> |
@@ -182,8 +183,9 @@ static int sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp, | |||
182 | int tablesize); | 183 | int tablesize); |
183 | static ssize_t sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, | 184 | static ssize_t sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, |
184 | Sg_request * srp); | 185 | Sg_request * srp); |
185 | static ssize_t sg_new_write(Sg_fd * sfp, const char __user *buf, size_t count, | 186 | static ssize_t sg_new_write(Sg_fd *sfp, struct file *file, |
186 | int blocking, int read_only, Sg_request ** o_srp); | 187 | const char __user *buf, size_t count, int blocking, |
188 | int read_only, Sg_request **o_srp); | ||
187 | static int sg_common_write(Sg_fd * sfp, Sg_request * srp, | 189 | static int sg_common_write(Sg_fd * sfp, Sg_request * srp, |
188 | unsigned char *cmnd, int timeout, int blocking); | 190 | unsigned char *cmnd, int timeout, int blocking); |
189 | static int sg_u_iovec(sg_io_hdr_t * hp, int sg_num, int ind, | 191 | static int sg_u_iovec(sg_io_hdr_t * hp, int sg_num, int ind, |
@@ -204,7 +206,6 @@ static Sg_request *sg_get_rq_mark(Sg_fd * sfp, int pack_id); | |||
204 | static Sg_request *sg_add_request(Sg_fd * sfp); | 206 | static Sg_request *sg_add_request(Sg_fd * sfp); |
205 | static int sg_remove_request(Sg_fd * sfp, Sg_request * srp); | 207 | static int sg_remove_request(Sg_fd * sfp, Sg_request * srp); |
206 | static int sg_res_in_use(Sg_fd * sfp); | 208 | static int sg_res_in_use(Sg_fd * sfp); |
207 | static int sg_allow_access(unsigned char opcode, char dev_type); | ||
208 | static int sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len); | 209 | static int sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len); |
209 | static Sg_device *sg_get_dev(int dev); | 210 | static Sg_device *sg_get_dev(int dev); |
210 | #ifdef CONFIG_SCSI_PROC_FS | 211 | #ifdef CONFIG_SCSI_PROC_FS |
@@ -227,19 +228,26 @@ sg_open(struct inode *inode, struct file *filp) | |||
227 | int res; | 228 | int res; |
228 | int retval; | 229 | int retval; |
229 | 230 | ||
231 | lock_kernel(); | ||
230 | nonseekable_open(inode, filp); | 232 | nonseekable_open(inode, filp); |
231 | SCSI_LOG_TIMEOUT(3, printk("sg_open: dev=%d, flags=0x%x\n", dev, flags)); | 233 | SCSI_LOG_TIMEOUT(3, printk("sg_open: dev=%d, flags=0x%x\n", dev, flags)); |
232 | sdp = sg_get_dev(dev); | 234 | sdp = sg_get_dev(dev); |
233 | if ((!sdp) || (!sdp->device)) | 235 | if ((!sdp) || (!sdp->device)) { |
236 | unlock_kernel(); | ||
234 | return -ENXIO; | 237 | return -ENXIO; |
235 | if (sdp->detached) | 238 | } |
239 | if (sdp->detached) { | ||
240 | unlock_kernel(); | ||
236 | return -ENODEV; | 241 | return -ENODEV; |
242 | } | ||
237 | 243 | ||
238 | /* This driver's module count bumped by fops_get in <linux/fs.h> */ | 244 | /* This driver's module count bumped by fops_get in <linux/fs.h> */ |
239 | /* Prevent the device driver from vanishing while we sleep */ | 245 | /* Prevent the device driver from vanishing while we sleep */ |
240 | retval = scsi_device_get(sdp->device); | 246 | retval = scsi_device_get(sdp->device); |
241 | if (retval) | 247 | if (retval) { |
248 | unlock_kernel(); | ||
242 | return retval; | 249 | return retval; |
250 | } | ||
243 | 251 | ||
244 | if (!((flags & O_NONBLOCK) || | 252 | if (!((flags & O_NONBLOCK) || |
245 | scsi_block_when_processing_errors(sdp->device))) { | 253 | scsi_block_when_processing_errors(sdp->device))) { |
@@ -295,10 +303,12 @@ sg_open(struct inode *inode, struct file *filp) | |||
295 | retval = -ENOMEM; | 303 | retval = -ENOMEM; |
296 | goto error_out; | 304 | goto error_out; |
297 | } | 305 | } |
306 | unlock_kernel(); | ||
298 | return 0; | 307 | return 0; |
299 | 308 | ||
300 | error_out: | 309 | error_out: |
301 | scsi_device_put(sdp->device); | 310 | scsi_device_put(sdp->device); |
311 | unlock_kernel(); | ||
302 | return retval; | 312 | return retval; |
303 | } | 313 | } |
304 | 314 | ||
@@ -544,7 +554,7 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) | |||
544 | return -EFAULT; | 554 | return -EFAULT; |
545 | blocking = !(filp->f_flags & O_NONBLOCK); | 555 | blocking = !(filp->f_flags & O_NONBLOCK); |
546 | if (old_hdr.reply_len < 0) | 556 | if (old_hdr.reply_len < 0) |
547 | return sg_new_write(sfp, buf, count, blocking, 0, NULL); | 557 | return sg_new_write(sfp, filp, buf, count, blocking, 0, NULL); |
548 | if (count < (SZ_SG_HEADER + 6)) | 558 | if (count < (SZ_SG_HEADER + 6)) |
549 | return -EIO; /* The minimum scsi command length is 6 bytes. */ | 559 | return -EIO; /* The minimum scsi command length is 6 bytes. */ |
550 | 560 | ||
@@ -621,8 +631,9 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) | |||
621 | } | 631 | } |
622 | 632 | ||
623 | static ssize_t | 633 | static ssize_t |
624 | sg_new_write(Sg_fd * sfp, const char __user *buf, size_t count, | 634 | sg_new_write(Sg_fd *sfp, struct file *file, const char __user *buf, |
625 | int blocking, int read_only, Sg_request ** o_srp) | 635 | size_t count, int blocking, int read_only, |
636 | Sg_request **o_srp) | ||
626 | { | 637 | { |
627 | int k; | 638 | int k; |
628 | Sg_request *srp; | 639 | Sg_request *srp; |
@@ -678,8 +689,7 @@ sg_new_write(Sg_fd * sfp, const char __user *buf, size_t count, | |||
678 | sg_remove_request(sfp, srp); | 689 | sg_remove_request(sfp, srp); |
679 | return -EFAULT; | 690 | return -EFAULT; |
680 | } | 691 | } |
681 | if (read_only && | 692 | if (read_only && !blk_verify_command(file, cmnd)) { |
682 | (!sg_allow_access(cmnd[0], sfp->parentdp->device->type))) { | ||
683 | sg_remove_request(sfp, srp); | 693 | sg_remove_request(sfp, srp); |
684 | return -EPERM; | 694 | return -EPERM; |
685 | } | 695 | } |
@@ -799,7 +809,7 @@ sg_ioctl(struct inode *inode, struct file *filp, | |||
799 | if (!access_ok(VERIFY_WRITE, p, SZ_SG_IO_HDR)) | 809 | if (!access_ok(VERIFY_WRITE, p, SZ_SG_IO_HDR)) |
800 | return -EFAULT; | 810 | return -EFAULT; |
801 | result = | 811 | result = |
802 | sg_new_write(sfp, p, SZ_SG_IO_HDR, | 812 | sg_new_write(sfp, filp, p, SZ_SG_IO_HDR, |
803 | blocking, read_only, &srp); | 813 | blocking, read_only, &srp); |
804 | if (result < 0) | 814 | if (result < 0) |
805 | return result; | 815 | return result; |
@@ -1048,7 +1058,7 @@ sg_ioctl(struct inode *inode, struct file *filp, | |||
1048 | 1058 | ||
1049 | if (copy_from_user(&opcode, siocp->data, 1)) | 1059 | if (copy_from_user(&opcode, siocp->data, 1)) |
1050 | return -EFAULT; | 1060 | return -EFAULT; |
1051 | if (!sg_allow_access(opcode, sdp->device->type)) | 1061 | if (!blk_verify_command(filp, &opcode)) |
1052 | return -EPERM; | 1062 | return -EPERM; |
1053 | } | 1063 | } |
1054 | return sg_scsi_ioctl(filp, sdp->device->request_queue, NULL, p); | 1064 | return sg_scsi_ioctl(filp, sdp->device->request_queue, NULL, p); |
@@ -2502,30 +2512,6 @@ sg_page_free(struct page *page, int size) | |||
2502 | __free_pages(page, order); | 2512 | __free_pages(page, order); |
2503 | } | 2513 | } |
2504 | 2514 | ||
2505 | #ifndef MAINTENANCE_IN_CMD | ||
2506 | #define MAINTENANCE_IN_CMD 0xa3 | ||
2507 | #endif | ||
2508 | |||
2509 | static unsigned char allow_ops[] = { TEST_UNIT_READY, REQUEST_SENSE, | ||
2510 | INQUIRY, READ_CAPACITY, READ_BUFFER, READ_6, READ_10, READ_12, | ||
2511 | READ_16, MODE_SENSE, MODE_SENSE_10, LOG_SENSE, REPORT_LUNS, | ||
2512 | SERVICE_ACTION_IN, RECEIVE_DIAGNOSTIC, READ_LONG, MAINTENANCE_IN_CMD | ||
2513 | }; | ||
2514 | |||
2515 | static int | ||
2516 | sg_allow_access(unsigned char opcode, char dev_type) | ||
2517 | { | ||
2518 | int k; | ||
2519 | |||
2520 | if (TYPE_SCANNER == dev_type) /* TYPE_ROM maybe burner */ | ||
2521 | return 1; | ||
2522 | for (k = 0; k < sizeof (allow_ops); ++k) { | ||
2523 | if (opcode == allow_ops[k]) | ||
2524 | return 1; | ||
2525 | } | ||
2526 | return 0; | ||
2527 | } | ||
2528 | |||
2529 | #ifdef CONFIG_SCSI_PROC_FS | 2515 | #ifdef CONFIG_SCSI_PROC_FS |
2530 | static int | 2516 | static int |
2531 | sg_idr_max_id(int id, void *p, void *data) | 2517 | sg_idr_max_id(int id, void *p, void *data) |
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index c82df8bd4d89..27f5bfd1def3 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -673,24 +673,20 @@ fail: | |||
673 | static void get_sectorsize(struct scsi_cd *cd) | 673 | static void get_sectorsize(struct scsi_cd *cd) |
674 | { | 674 | { |
675 | unsigned char cmd[10]; | 675 | unsigned char cmd[10]; |
676 | unsigned char *buffer; | 676 | unsigned char buffer[8]; |
677 | int the_result, retries = 3; | 677 | int the_result, retries = 3; |
678 | int sector_size; | 678 | int sector_size; |
679 | struct request_queue *queue; | 679 | struct request_queue *queue; |
680 | 680 | ||
681 | buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); | ||
682 | if (!buffer) | ||
683 | goto Enomem; | ||
684 | |||
685 | do { | 681 | do { |
686 | cmd[0] = READ_CAPACITY; | 682 | cmd[0] = READ_CAPACITY; |
687 | memset((void *) &cmd[1], 0, 9); | 683 | memset((void *) &cmd[1], 0, 9); |
688 | memset(buffer, 0, 8); | 684 | memset(buffer, 0, sizeof(buffer)); |
689 | 685 | ||
690 | /* Do the command and wait.. */ | 686 | /* Do the command and wait.. */ |
691 | the_result = scsi_execute_req(cd->device, cmd, DMA_FROM_DEVICE, | 687 | the_result = scsi_execute_req(cd->device, cmd, DMA_FROM_DEVICE, |
692 | buffer, 8, NULL, SR_TIMEOUT, | 688 | buffer, sizeof(buffer), NULL, |
693 | MAX_RETRIES); | 689 | SR_TIMEOUT, MAX_RETRIES); |
694 | 690 | ||
695 | retries--; | 691 | retries--; |
696 | 692 | ||
@@ -745,14 +741,8 @@ static void get_sectorsize(struct scsi_cd *cd) | |||
745 | 741 | ||
746 | queue = cd->device->request_queue; | 742 | queue = cd->device->request_queue; |
747 | blk_queue_hardsect_size(queue, sector_size); | 743 | blk_queue_hardsect_size(queue, sector_size); |
748 | out: | ||
749 | kfree(buffer); | ||
750 | return; | ||
751 | 744 | ||
752 | Enomem: | 745 | return; |
753 | cd->capacity = 0x1fffff; | ||
754 | cd->device->sector_size = 2048; /* A guess, just in case */ | ||
755 | goto out; | ||
756 | } | 746 | } |
757 | 747 | ||
758 | static void get_capabilities(struct scsi_cd *cd) | 748 | static void get_capabilities(struct scsi_cd *cd) |
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 6e5a5bb31311..4684cc716aa4 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -38,6 +38,7 @@ static const char *verstr = "20080224"; | |||
38 | #include <linux/cdev.h> | 38 | #include <linux/cdev.h> |
39 | #include <linux/delay.h> | 39 | #include <linux/delay.h> |
40 | #include <linux/mutex.h> | 40 | #include <linux/mutex.h> |
41 | #include <linux/smp_lock.h> | ||
41 | 42 | ||
42 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
43 | #include <asm/dma.h> | 44 | #include <asm/dma.h> |
@@ -1113,7 +1114,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp) | |||
1113 | } | 1114 | } |
1114 | 1115 | ||
1115 | 1116 | ||
1116 | /* Open the device. Needs to be called with BKL only because of incrementing the SCSI host | 1117 | /* Open the device. Needs to take the BKL only because of incrementing the SCSI host |
1117 | module count. */ | 1118 | module count. */ |
1118 | static int st_open(struct inode *inode, struct file *filp) | 1119 | static int st_open(struct inode *inode, struct file *filp) |
1119 | { | 1120 | { |
@@ -1123,6 +1124,7 @@ static int st_open(struct inode *inode, struct file *filp) | |||
1123 | int dev = TAPE_NR(inode); | 1124 | int dev = TAPE_NR(inode); |
1124 | char *name; | 1125 | char *name; |
1125 | 1126 | ||
1127 | lock_kernel(); | ||
1126 | /* | 1128 | /* |
1127 | * We really want to do nonseekable_open(inode, filp); here, but some | 1129 | * We really want to do nonseekable_open(inode, filp); here, but some |
1128 | * versions of tar incorrectly call lseek on tapes and bail out if that | 1130 | * versions of tar incorrectly call lseek on tapes and bail out if that |
@@ -1130,8 +1132,10 @@ static int st_open(struct inode *inode, struct file *filp) | |||
1130 | */ | 1132 | */ |
1131 | filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); | 1133 | filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); |
1132 | 1134 | ||
1133 | if (!(STp = scsi_tape_get(dev))) | 1135 | if (!(STp = scsi_tape_get(dev))) { |
1136 | unlock_kernel(); | ||
1134 | return -ENXIO; | 1137 | return -ENXIO; |
1138 | } | ||
1135 | 1139 | ||
1136 | write_lock(&st_dev_arr_lock); | 1140 | write_lock(&st_dev_arr_lock); |
1137 | filp->private_data = STp; | 1141 | filp->private_data = STp; |
@@ -1140,6 +1144,7 @@ static int st_open(struct inode *inode, struct file *filp) | |||
1140 | if (STp->in_use) { | 1144 | if (STp->in_use) { |
1141 | write_unlock(&st_dev_arr_lock); | 1145 | write_unlock(&st_dev_arr_lock); |
1142 | scsi_tape_put(STp); | 1146 | scsi_tape_put(STp); |
1147 | unlock_kernel(); | ||
1143 | DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); ) | 1148 | DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); ) |
1144 | return (-EBUSY); | 1149 | return (-EBUSY); |
1145 | } | 1150 | } |
@@ -1188,12 +1193,14 @@ static int st_open(struct inode *inode, struct file *filp) | |||
1188 | retval = (-EIO); | 1193 | retval = (-EIO); |
1189 | goto err_out; | 1194 | goto err_out; |
1190 | } | 1195 | } |
1196 | unlock_kernel(); | ||
1191 | return 0; | 1197 | return 0; |
1192 | 1198 | ||
1193 | err_out: | 1199 | err_out: |
1194 | normalize_buffer(STp->buffer); | 1200 | normalize_buffer(STp->buffer); |
1195 | STp->in_use = 0; | 1201 | STp->in_use = 0; |
1196 | scsi_tape_put(STp); | 1202 | scsi_tape_put(STp); |
1203 | unlock_kernel(); | ||
1197 | return retval; | 1204 | return retval; |
1198 | 1205 | ||
1199 | } | 1206 | } |