diff options
| author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2006-06-25 08:49:06 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-25 13:01:21 -0400 |
| commit | 7c8328355609be6d229e1a5e016a0115e9328b83 (patch) | |
| tree | 9180f623a5380c22e90235a24bfa7a3af522dc76 | |
| parent | e2019b58fac87b93c04d9efc08324a28fd23d601 (diff) | |
[PATCH] CCISS: run through Lindent
cciss is full of inconsistent style ("for (" vs. "for(", lines that end with
whitespace, lines beginning with a mix of spaces & tabs, etc).
This patch changes only whitespace.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Acked-by: Jeff Garzik <jeff@garzik.org>
Acked-by: Mike Miller <mike.miller@hp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
| -rw-r--r-- | drivers/block/cciss.c | 3115 |
1 files changed, 1581 insertions, 1534 deletions
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 44cf001db271..d5c126d7d427 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
| @@ -34,7 +34,7 @@ | |||
| 34 | #include <linux/blkpg.h> | 34 | #include <linux/blkpg.h> |
| 35 | #include <linux/timer.h> | 35 | #include <linux/timer.h> |
| 36 | #include <linux/proc_fs.h> | 36 | #include <linux/proc_fs.h> |
| 37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
| 38 | #include <linux/hdreg.h> | 38 | #include <linux/hdreg.h> |
| 39 | #include <linux/spinlock.h> | 39 | #include <linux/spinlock.h> |
| 40 | #include <linux/compat.h> | 40 | #include <linux/compat.h> |
| @@ -64,141 +64,147 @@ MODULE_LICENSE("GPL"); | |||
| 64 | 64 | ||
| 65 | /* define the PCI info for the cards we can control */ | 65 | /* define the PCI info for the cards we can control */ |
| 66 | static const struct pci_device_id cciss_pci_device_id[] = { | 66 | static const struct pci_device_id cciss_pci_device_id[] = { |
| 67 | { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISS, | 67 | {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISS, |
| 68 | 0x0E11, 0x4070, 0, 0, 0}, | 68 | 0x0E11, 0x4070, 0, 0, 0}, |
| 69 | { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, | 69 | {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, |
| 70 | 0x0E11, 0x4080, 0, 0, 0}, | 70 | 0x0E11, 0x4080, 0, 0, 0}, |
| 71 | { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, | 71 | {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, |
| 72 | 0x0E11, 0x4082, 0, 0, 0}, | 72 | 0x0E11, 0x4082, 0, 0, 0}, |
| 73 | { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, | 73 | {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, |
| 74 | 0x0E11, 0x4083, 0, 0, 0}, | 74 | 0x0E11, 0x4083, 0, 0, 0}, |
| 75 | { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, | 75 | {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, |
| 76 | 0x0E11, 0x409A, 0, 0, 0}, | 76 | 0x0E11, 0x409A, 0, 0, 0}, |
| 77 | { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, | 77 | {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, |
| 78 | 0x0E11, 0x409B, 0, 0, 0}, | 78 | 0x0E11, 0x409B, 0, 0, 0}, |
| 79 | { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, | 79 | {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, |
| 80 | 0x0E11, 0x409C, 0, 0, 0}, | 80 | 0x0E11, 0x409C, 0, 0, 0}, |
| 81 | { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, | 81 | {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, |
| 82 | 0x0E11, 0x409D, 0, 0, 0}, | 82 | 0x0E11, 0x409D, 0, 0, 0}, |
| 83 | { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, | 83 | {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, |
| 84 | 0x0E11, 0x4091, 0, 0, 0}, | 84 | 0x0E11, 0x4091, 0, 0, 0}, |
| 85 | { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSA, | 85 | {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSA, |
| 86 | 0x103C, 0x3225, 0, 0, 0}, | 86 | 0x103C, 0x3225, 0, 0, 0}, |
| 87 | { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, | 87 | {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, |
| 88 | 0x103c, 0x3223, 0, 0, 0}, | 88 | 0x103c, 0x3223, 0, 0, 0}, |
| 89 | { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, | 89 | {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, |
| 90 | 0x103c, 0x3234, 0, 0, 0}, | 90 | 0x103c, 0x3234, 0, 0, 0}, |
| 91 | { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, | 91 | {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, |
| 92 | 0x103c, 0x3235, 0, 0, 0}, | 92 | 0x103c, 0x3235, 0, 0, 0}, |
| 93 | { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, | 93 | {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, |
| 94 | 0x103c, 0x3211, 0, 0, 0}, | 94 | 0x103c, 0x3211, 0, 0, 0}, |
| 95 | { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, | 95 | {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, |
| 96 | 0x103c, 0x3212, 0, 0, 0}, | 96 | 0x103c, 0x3212, 0, 0, 0}, |
| 97 | { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, | 97 | {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, |
| 98 | 0x103c, 0x3213, 0, 0, 0}, | 98 | 0x103c, 0x3213, 0, 0, 0}, |
| 99 | { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, | 99 | {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, |
| 100 | 0x103c, 0x3214, 0, 0, 0}, | 100 | 0x103c, 0x3214, 0, 0, 0}, |
| 101 | { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, | 101 | {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, |
| 102 | 0x103c, 0x3215, 0, 0, 0}, | 102 | 0x103c, 0x3215, 0, 0, 0}, |
| 103 | {0,} | 103 | {0,} |
| 104 | }; | 104 | }; |
| 105 | |||
| 105 | MODULE_DEVICE_TABLE(pci, cciss_pci_device_id); | 106 | MODULE_DEVICE_TABLE(pci, cciss_pci_device_id); |
| 106 | 107 | ||
| 107 | /* board_id = Subsystem Device ID & Vendor ID | 108 | /* board_id = Subsystem Device ID & Vendor ID |
| 108 | * product = Marketing Name for the board | 109 | * product = Marketing Name for the board |
| 109 | * access = Address of the struct of function pointers | 110 | * access = Address of the struct of function pointers |
| 110 | */ | 111 | */ |
| 111 | static struct board_type products[] = { | 112 | static struct board_type products[] = { |
| 112 | { 0x40700E11, "Smart Array 5300", &SA5_access }, | 113 | {0x40700E11, "Smart Array 5300", &SA5_access}, |
| 113 | { 0x40800E11, "Smart Array 5i", &SA5B_access}, | 114 | {0x40800E11, "Smart Array 5i", &SA5B_access}, |
| 114 | { 0x40820E11, "Smart Array 532", &SA5B_access}, | 115 | {0x40820E11, "Smart Array 532", &SA5B_access}, |
| 115 | { 0x40830E11, "Smart Array 5312", &SA5B_access}, | 116 | {0x40830E11, "Smart Array 5312", &SA5B_access}, |
| 116 | { 0x409A0E11, "Smart Array 641", &SA5_access}, | 117 | {0x409A0E11, "Smart Array 641", &SA5_access}, |
| 117 | { 0x409B0E11, "Smart Array 642", &SA5_access}, | 118 | {0x409B0E11, "Smart Array 642", &SA5_access}, |
| 118 | { 0x409C0E11, "Smart Array 6400", &SA5_access}, | 119 | {0x409C0E11, "Smart Array 6400", &SA5_access}, |
| 119 | { 0x409D0E11, "Smart Array 6400 EM", &SA5_access}, | 120 | {0x409D0E11, "Smart Array 6400 EM", &SA5_access}, |
| 120 | { 0x40910E11, "Smart Array 6i", &SA5_access}, | 121 | {0x40910E11, "Smart Array 6i", &SA5_access}, |
| 121 | { 0x3225103C, "Smart Array P600", &SA5_access}, | 122 | {0x3225103C, "Smart Array P600", &SA5_access}, |
| 122 | { 0x3223103C, "Smart Array P800", &SA5_access}, | 123 | {0x3223103C, "Smart Array P800", &SA5_access}, |
| 123 | { 0x3234103C, "Smart Array P400", &SA5_access}, | 124 | {0x3234103C, "Smart Array P400", &SA5_access}, |
| 124 | { 0x3235103C, "Smart Array P400i", &SA5_access}, | 125 | {0x3235103C, "Smart Array P400i", &SA5_access}, |
| 125 | { 0x3211103C, "Smart Array E200i", &SA5_access}, | 126 | {0x3211103C, "Smart Array E200i", &SA5_access}, |
| 126 | { 0x3212103C, "Smart Array E200", &SA5_access}, | 127 | {0x3212103C, "Smart Array E200", &SA5_access}, |
| 127 | { 0x3213103C, "Smart Array E200i", &SA5_access}, | 128 | {0x3213103C, "Smart Array E200i", &SA5_access}, |
| 128 | { 0x3214103C, "Smart Array E200i", &SA5_access}, | 129 | {0x3214103C, "Smart Array E200i", &SA5_access}, |
| 129 | { 0x3215103C, "Smart Array E200i", &SA5_access}, | 130 | {0x3215103C, "Smart Array E200i", &SA5_access}, |
| 130 | }; | 131 | }; |
| 131 | 132 | ||
| 132 | /* How long to wait (in milliseconds) for board to go into simple mode */ | 133 | /* How long to wait (in milliseconds) for board to go into simple mode */ |
| 133 | #define MAX_CONFIG_WAIT 30000 | 134 | #define MAX_CONFIG_WAIT 30000 |
| 134 | #define MAX_IOCTL_CONFIG_WAIT 1000 | 135 | #define MAX_IOCTL_CONFIG_WAIT 1000 |
| 135 | 136 | ||
| 136 | /*define how many times we will try a command because of bus resets */ | 137 | /*define how many times we will try a command because of bus resets */ |
| 137 | #define MAX_CMD_RETRIES 3 | 138 | #define MAX_CMD_RETRIES 3 |
| 138 | 139 | ||
| 139 | #define READ_AHEAD 1024 | 140 | #define READ_AHEAD 1024 |
| 140 | #define NR_CMDS 384 /* #commands that can be outstanding */ | 141 | #define NR_CMDS 384 /* #commands that can be outstanding */ |
| 141 | #define MAX_CTLR 32 | 142 | #define MAX_CTLR 32 |
| 142 | 143 | ||
| 143 | /* Originally cciss driver only supports 8 major numbers */ | 144 | /* Originally cciss driver only supports 8 major numbers */ |
| 144 | #define MAX_CTLR_ORIG 8 | 145 | #define MAX_CTLR_ORIG 8 |
| 145 | 146 | ||
| 146 | |||
| 147 | static ctlr_info_t *hba[MAX_CTLR]; | 147 | static ctlr_info_t *hba[MAX_CTLR]; |
| 148 | 148 | ||
| 149 | static void do_cciss_request(request_queue_t *q); | 149 | static void do_cciss_request(request_queue_t *q); |
| 150 | static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs); | 150 | static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs); |
| 151 | static int cciss_open(struct inode *inode, struct file *filep); | 151 | static int cciss_open(struct inode *inode, struct file *filep); |
| 152 | static int cciss_release(struct inode *inode, struct file *filep); | 152 | static int cciss_release(struct inode *inode, struct file *filep); |
| 153 | static int cciss_ioctl(struct inode *inode, struct file *filep, | 153 | static int cciss_ioctl(struct inode *inode, struct file *filep, |
| 154 | unsigned int cmd, unsigned long arg); | 154 | unsigned int cmd, unsigned long arg); |
| 155 | static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo); | 155 | static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo); |
| 156 | 156 | ||
| 157 | static int revalidate_allvol(ctlr_info_t *host); | 157 | static int revalidate_allvol(ctlr_info_t *host); |
| 158 | static int cciss_revalidate(struct gendisk *disk); | 158 | static int cciss_revalidate(struct gendisk *disk); |
| 159 | static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk); | 159 | static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk); |
| 160 | static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, int clear_all); | 160 | static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, |
| 161 | int clear_all); | ||
| 161 | 162 | ||
| 162 | static void cciss_read_capacity(int ctlr, int logvol, ReadCapdata_struct *buf, | 163 | static void cciss_read_capacity(int ctlr, int logvol, ReadCapdata_struct *buf, |
| 163 | int withirq, unsigned int *total_size, unsigned int *block_size); | 164 | int withirq, unsigned int *total_size, |
| 164 | static void cciss_geometry_inquiry(int ctlr, int logvol, | 165 | unsigned int *block_size); |
| 165 | int withirq, unsigned int total_size, | 166 | static void cciss_geometry_inquiry(int ctlr, int logvol, int withirq, |
| 166 | unsigned int block_size, InquiryData_struct *inq_buff, | 167 | unsigned int total_size, |
| 167 | drive_info_struct *drv); | 168 | unsigned int block_size, |
| 169 | InquiryData_struct *inq_buff, | ||
| 170 | drive_info_struct *drv); | ||
| 168 | static void cciss_getgeometry(int cntl_num); | 171 | static void cciss_getgeometry(int cntl_num); |
| 169 | static void __devinit cciss_interrupt_mode(ctlr_info_t *, struct pci_dev *, __u32); | 172 | static void __devinit cciss_interrupt_mode(ctlr_info_t *, struct pci_dev *, |
| 170 | static void start_io( ctlr_info_t *h); | 173 | __u32); |
| 171 | static int sendcmd( __u8 cmd, int ctlr, void *buff, size_t size, | 174 | static void start_io(ctlr_info_t *h); |
| 172 | unsigned int use_unit_num, unsigned int log_unit, __u8 page_code, | 175 | static int sendcmd(__u8 cmd, int ctlr, void *buff, size_t size, |
| 173 | unsigned char *scsi3addr, int cmd_type); | 176 | unsigned int use_unit_num, unsigned int log_unit, |
| 174 | static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size, | 177 | __u8 page_code, unsigned char *scsi3addr, int cmd_type); |
| 175 | unsigned int use_unit_num, unsigned int log_unit, __u8 page_code, | 178 | static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size, |
| 176 | int cmd_type); | 179 | unsigned int use_unit_num, unsigned int log_unit, |
| 180 | __u8 page_code, int cmd_type); | ||
| 177 | 181 | ||
| 178 | static void fail_all_cmds(unsigned long ctlr); | 182 | static void fail_all_cmds(unsigned long ctlr); |
| 179 | 183 | ||
| 180 | #ifdef CONFIG_PROC_FS | 184 | #ifdef CONFIG_PROC_FS |
| 181 | static int cciss_proc_get_info(char *buffer, char **start, off_t offset, | 185 | static int cciss_proc_get_info(char *buffer, char **start, off_t offset, |
| 182 | int length, int *eof, void *data); | 186 | int length, int *eof, void *data); |
| 183 | static void cciss_procinit(int i); | 187 | static void cciss_procinit(int i); |
| 184 | #else | 188 | #else |
| 185 | static void cciss_procinit(int i) {} | 189 | static void cciss_procinit(int i) |
| 186 | #endif /* CONFIG_PROC_FS */ | 190 | { |
| 191 | } | ||
| 192 | #endif /* CONFIG_PROC_FS */ | ||
| 187 | 193 | ||
| 188 | #ifdef CONFIG_COMPAT | 194 | #ifdef CONFIG_COMPAT |
| 189 | static long cciss_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg); | 195 | static long cciss_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg); |
| 190 | #endif | 196 | #endif |
| 191 | 197 | ||
| 192 | static struct block_device_operations cciss_fops = { | 198 | static struct block_device_operations cciss_fops = { |
| 193 | .owner = THIS_MODULE, | 199 | .owner = THIS_MODULE, |
| 194 | .open = cciss_open, | 200 | .open = cciss_open, |
| 195 | .release = cciss_release, | 201 | .release = cciss_release, |
| 196 | .ioctl = cciss_ioctl, | 202 | .ioctl = cciss_ioctl, |
| 197 | .getgeo = cciss_getgeo, | 203 | .getgeo = cciss_getgeo, |
| 198 | #ifdef CONFIG_COMPAT | 204 | #ifdef CONFIG_COMPAT |
| 199 | .compat_ioctl = cciss_compat_ioctl, | 205 | .compat_ioctl = cciss_compat_ioctl, |
| 200 | #endif | 206 | #endif |
| 201 | .revalidate_disk= cciss_revalidate, | 207 | .revalidate_disk = cciss_revalidate, |
| 202 | }; | 208 | }; |
| 203 | 209 | ||
| 204 | /* | 210 | /* |
| @@ -206,28 +212,29 @@ static struct block_device_operations cciss_fops = { | |||
| 206 | */ | 212 | */ |
| 207 | static inline void addQ(CommandList_struct **Qptr, CommandList_struct *c) | 213 | static inline void addQ(CommandList_struct **Qptr, CommandList_struct *c) |
| 208 | { | 214 | { |
| 209 | if (*Qptr == NULL) { | 215 | if (*Qptr == NULL) { |
| 210 | *Qptr = c; | 216 | *Qptr = c; |
| 211 | c->next = c->prev = c; | 217 | c->next = c->prev = c; |
| 212 | } else { | 218 | } else { |
| 213 | c->prev = (*Qptr)->prev; | 219 | c->prev = (*Qptr)->prev; |
| 214 | c->next = (*Qptr); | 220 | c->next = (*Qptr); |
| 215 | (*Qptr)->prev->next = c; | 221 | (*Qptr)->prev->next = c; |
| 216 | (*Qptr)->prev = c; | 222 | (*Qptr)->prev = c; |
| 217 | } | 223 | } |
| 218 | } | 224 | } |
| 219 | 225 | ||
| 220 | static inline CommandList_struct *removeQ(CommandList_struct **Qptr, | 226 | static inline CommandList_struct *removeQ(CommandList_struct **Qptr, |
| 221 | CommandList_struct *c) | 227 | CommandList_struct *c) |
| 222 | { | 228 | { |
| 223 | if (c && c->next != c) { | 229 | if (c && c->next != c) { |
| 224 | if (*Qptr == c) *Qptr = c->next; | 230 | if (*Qptr == c) |
| 225 | c->prev->next = c->next; | 231 | *Qptr = c->next; |
| 226 | c->next->prev = c->prev; | 232 | c->prev->next = c->next; |
| 227 | } else { | 233 | c->next->prev = c->prev; |
| 228 | *Qptr = NULL; | 234 | } else { |
| 229 | } | 235 | *Qptr = NULL; |
| 230 | return c; | 236 | } |
| 237 | return c; | ||
| 231 | } | 238 | } |
| 232 | 239 | ||
| 233 | #include "cciss_scsi.c" /* For SCSI tape support */ | 240 | #include "cciss_scsi.c" /* For SCSI tape support */ |
| @@ -240,23 +247,24 @@ static inline CommandList_struct *removeQ(CommandList_struct **Qptr, | |||
| 240 | #define ENG_GIG 1000000000 | 247 | #define ENG_GIG 1000000000 |
| 241 | #define ENG_GIG_FACTOR (ENG_GIG/512) | 248 | #define ENG_GIG_FACTOR (ENG_GIG/512) |
| 242 | #define RAID_UNKNOWN 6 | 249 | #define RAID_UNKNOWN 6 |
| 243 | static const char *raid_label[] = {"0","4","1(1+0)","5","5+1","ADG", | 250 | static const char *raid_label[] = { "0", "4", "1(1+0)", "5", "5+1", "ADG", |
| 244 | "UNKNOWN"}; | 251 | "UNKNOWN" |
| 252 | }; | ||
| 245 | 253 | ||
| 246 | static struct proc_dir_entry *proc_cciss; | 254 | static struct proc_dir_entry *proc_cciss; |
| 247 | 255 | ||
| 248 | static int cciss_proc_get_info(char *buffer, char **start, off_t offset, | 256 | static int cciss_proc_get_info(char *buffer, char **start, off_t offset, |
| 249 | int length, int *eof, void *data) | 257 | int length, int *eof, void *data) |
| 250 | { | 258 | { |
| 251 | off_t pos = 0; | 259 | off_t pos = 0; |
| 252 | off_t len = 0; | 260 | off_t len = 0; |
| 253 | int size, i, ctlr; | 261 | int size, i, ctlr; |
| 254 | ctlr_info_t *h = (ctlr_info_t*)data; | 262 | ctlr_info_t *h = (ctlr_info_t *) data; |
| 255 | drive_info_struct *drv; | 263 | drive_info_struct *drv; |
| 256 | unsigned long flags; | 264 | unsigned long flags; |
| 257 | sector_t vol_sz, vol_sz_frac; | 265 | sector_t vol_sz, vol_sz_frac; |
| 258 | 266 | ||
| 259 | ctlr = h->ctlr; | 267 | ctlr = h->ctlr; |
| 260 | 268 | ||
| 261 | /* prevent displaying bogus info during configuration | 269 | /* prevent displaying bogus info during configuration |
| 262 | * or deconfiguration of a logical volume | 270 | * or deconfiguration of a logical volume |
| @@ -264,35 +272,35 @@ static int cciss_proc_get_info(char *buffer, char **start, off_t offset, | |||
| 264 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | 272 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); |
| 265 | if (h->busy_configuring) { | 273 | if (h->busy_configuring) { |
| 266 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | 274 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); |
| 267 | return -EBUSY; | 275 | return -EBUSY; |
| 268 | } | 276 | } |
| 269 | h->busy_configuring = 1; | 277 | h->busy_configuring = 1; |
| 270 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | 278 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); |
| 271 | 279 | ||
| 272 | size = sprintf(buffer, "%s: HP %s Controller\n" | 280 | size = sprintf(buffer, "%s: HP %s Controller\n" |
| 273 | "Board ID: 0x%08lx\n" | 281 | "Board ID: 0x%08lx\n" |
| 274 | "Firmware Version: %c%c%c%c\n" | 282 | "Firmware Version: %c%c%c%c\n" |
| 275 | "IRQ: %d\n" | 283 | "IRQ: %d\n" |
| 276 | "Logical drives: %d\n" | 284 | "Logical drives: %d\n" |
| 277 | "Current Q depth: %d\n" | 285 | "Current Q depth: %d\n" |
| 278 | "Current # commands on controller: %d\n" | 286 | "Current # commands on controller: %d\n" |
| 279 | "Max Q depth since init: %d\n" | 287 | "Max Q depth since init: %d\n" |
| 280 | "Max # commands on controller since init: %d\n" | 288 | "Max # commands on controller since init: %d\n" |
| 281 | "Max SG entries since init: %d\n\n", | 289 | "Max SG entries since init: %d\n\n", |
| 282 | h->devname, | 290 | h->devname, |
| 283 | h->product_name, | 291 | h->product_name, |
| 284 | (unsigned long)h->board_id, | 292 | (unsigned long)h->board_id, |
| 285 | h->firm_ver[0], h->firm_ver[1], h->firm_ver[2], h->firm_ver[3], | 293 | h->firm_ver[0], h->firm_ver[1], h->firm_ver[2], |
| 286 | (unsigned int)h->intr[SIMPLE_MODE_INT], | 294 | h->firm_ver[3], (unsigned int)h->intr[SIMPLE_MODE_INT], |
| 287 | h->num_luns, | 295 | h->num_luns, h->Qdepth, h->commands_outstanding, |
| 288 | h->Qdepth, h->commands_outstanding, | 296 | h->maxQsinceinit, h->max_outstanding, h->maxSG); |
| 289 | h->maxQsinceinit, h->max_outstanding, h->maxSG); | 297 | |
| 290 | 298 | pos += size; | |
| 291 | pos += size; len += size; | 299 | len += size; |
| 292 | cciss_proc_tape_report(ctlr, buffer, &pos, &len); | 300 | cciss_proc_tape_report(ctlr, buffer, &pos, &len); |
| 293 | for(i=0; i<=h->highest_lun; i++) { | 301 | for (i = 0; i <= h->highest_lun; i++) { |
| 294 | 302 | ||
| 295 | drv = &h->drv[i]; | 303 | drv = &h->drv[i]; |
| 296 | if (drv->heads == 0) | 304 | if (drv->heads == 0) |
| 297 | continue; | 305 | continue; |
| 298 | 306 | ||
| @@ -303,25 +311,26 @@ static int cciss_proc_get_info(char *buffer, char **start, off_t offset, | |||
| 303 | 311 | ||
| 304 | if (drv->raid_level > 5) | 312 | if (drv->raid_level > 5) |
| 305 | drv->raid_level = RAID_UNKNOWN; | 313 | drv->raid_level = RAID_UNKNOWN; |
| 306 | size = sprintf(buffer+len, "cciss/c%dd%d:" | 314 | size = sprintf(buffer + len, "cciss/c%dd%d:" |
| 307 | "\t%4u.%02uGB\tRAID %s\n", | 315 | "\t%4u.%02uGB\tRAID %s\n", |
| 308 | ctlr, i, (int)vol_sz, (int)vol_sz_frac, | 316 | ctlr, i, (int)vol_sz, (int)vol_sz_frac, |
| 309 | raid_label[drv->raid_level]); | 317 | raid_label[drv->raid_level]); |
| 310 | pos += size; len += size; | 318 | pos += size; |
| 311 | } | 319 | len += size; |
| 312 | 320 | } | |
| 313 | *eof = 1; | 321 | |
| 314 | *start = buffer+offset; | 322 | *eof = 1; |
| 315 | len -= offset; | 323 | *start = buffer + offset; |
| 316 | if (len>length) | 324 | len -= offset; |
| 317 | len = length; | 325 | if (len > length) |
| 326 | len = length; | ||
| 318 | h->busy_configuring = 0; | 327 | h->busy_configuring = 0; |
| 319 | return len; | 328 | return len; |
| 320 | } | 329 | } |
| 321 | 330 | ||
| 322 | static int | 331 | static int |
| 323 | cciss_proc_write(struct file *file, const char __user *buffer, | 332 | cciss_proc_write(struct file *file, const char __user *buffer, |
| 324 | unsigned long count, void *data) | 333 | unsigned long count, void *data) |
| 325 | { | 334 | { |
| 326 | unsigned char cmd[80]; | 335 | unsigned char cmd[80]; |
| 327 | int len; | 336 | int len; |
| @@ -330,20 +339,23 @@ cciss_proc_write(struct file *file, const char __user *buffer, | |||
| 330 | int rc; | 339 | int rc; |
| 331 | #endif | 340 | #endif |
| 332 | 341 | ||
| 333 | if (count > sizeof(cmd)-1) return -EINVAL; | 342 | if (count > sizeof(cmd) - 1) |
| 334 | if (copy_from_user(cmd, buffer, count)) return -EFAULT; | 343 | return -EINVAL; |
| 344 | if (copy_from_user(cmd, buffer, count)) | ||
| 345 | return -EFAULT; | ||
| 335 | cmd[count] = '\0'; | 346 | cmd[count] = '\0'; |
| 336 | len = strlen(cmd); // above 3 lines ensure safety | 347 | len = strlen(cmd); // above 3 lines ensure safety |
| 337 | if (len && cmd[len-1] == '\n') | 348 | if (len && cmd[len - 1] == '\n') |
| 338 | cmd[--len] = '\0'; | 349 | cmd[--len] = '\0'; |
| 339 | # ifdef CONFIG_CISS_SCSI_TAPE | 350 | # ifdef CONFIG_CISS_SCSI_TAPE |
| 340 | if (strcmp("engage scsi", cmd)==0) { | 351 | if (strcmp("engage scsi", cmd) == 0) { |
| 341 | rc = cciss_engage_scsi(h->ctlr); | 352 | rc = cciss_engage_scsi(h->ctlr); |
| 342 | if (rc != 0) return -rc; | 353 | if (rc != 0) |
| 343 | return count; | 354 | return -rc; |
| 344 | } | 355 | return count; |
| 345 | /* might be nice to have "disengage" too, but it's not | 356 | } |
| 346 | safely possible. (only 1 module use count, lock issues.) */ | 357 | /* might be nice to have "disengage" too, but it's not |
| 358 | safely possible. (only 1 module use count, lock issues.) */ | ||
| 347 | # endif | 359 | # endif |
| 348 | return -EINVAL; | 360 | return -EINVAL; |
| 349 | } | 361 | } |
| @@ -356,116 +368,113 @@ static void __devinit cciss_procinit(int i) | |||
| 356 | { | 368 | { |
| 357 | struct proc_dir_entry *pde; | 369 | struct proc_dir_entry *pde; |
| 358 | 370 | ||
| 359 | if (proc_cciss == NULL) { | 371 | if (proc_cciss == NULL) { |
| 360 | proc_cciss = proc_mkdir("cciss", proc_root_driver); | 372 | proc_cciss = proc_mkdir("cciss", proc_root_driver); |
| 361 | if (!proc_cciss) | 373 | if (!proc_cciss) |
| 362 | return; | 374 | return; |
| 363 | } | 375 | } |
| 364 | 376 | ||
| 365 | pde = create_proc_read_entry(hba[i]->devname, | 377 | pde = create_proc_read_entry(hba[i]->devname, |
| 366 | S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH, | 378 | S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH, |
| 367 | proc_cciss, cciss_proc_get_info, hba[i]); | 379 | proc_cciss, cciss_proc_get_info, hba[i]); |
| 368 | pde->write_proc = cciss_proc_write; | 380 | pde->write_proc = cciss_proc_write; |
| 369 | } | 381 | } |
| 370 | #endif /* CONFIG_PROC_FS */ | 382 | #endif /* CONFIG_PROC_FS */ |
| 371 | 383 | ||
| 372 | /* | 384 | /* |
| 373 | * For operations that cannot sleep, a command block is allocated at init, | 385 | * For operations that cannot sleep, a command block is allocated at init, |
| 374 | * and managed by cmd_alloc() and cmd_free() using a simple bitmap to track | 386 | * and managed by cmd_alloc() and cmd_free() using a simple bitmap to track |
| 375 | * which ones are free or in use. For operations that can wait for kmalloc | 387 | * which ones are free or in use. For operations that can wait for kmalloc |
| 376 | * to possible sleep, this routine can be called with get_from_pool set to 0. | 388 | * to possible sleep, this routine can be called with get_from_pool set to 0. |
| 377 | * cmd_free() MUST be called with a got_from_pool set to 0 if cmd_alloc was. | 389 | * cmd_free() MUST be called with a got_from_pool set to 0 if cmd_alloc was. |
| 378 | */ | 390 | */ |
| 379 | static CommandList_struct * cmd_alloc(ctlr_info_t *h, int get_from_pool) | 391 | static CommandList_struct *cmd_alloc(ctlr_info_t *h, int get_from_pool) |
| 380 | { | 392 | { |
| 381 | CommandList_struct *c; | 393 | CommandList_struct *c; |
| 382 | int i; | 394 | int i; |
| 383 | u64bit temp64; | 395 | u64bit temp64; |
| 384 | dma_addr_t cmd_dma_handle, err_dma_handle; | 396 | dma_addr_t cmd_dma_handle, err_dma_handle; |
| 385 | 397 | ||
| 386 | if (!get_from_pool) | 398 | if (!get_from_pool) { |
| 387 | { | 399 | c = (CommandList_struct *) pci_alloc_consistent(h->pdev, |
| 388 | c = (CommandList_struct *) pci_alloc_consistent( | 400 | sizeof(CommandList_struct), &cmd_dma_handle); |
| 389 | h->pdev, sizeof(CommandList_struct), &cmd_dma_handle); | 401 | if (c == NULL) |
| 390 | if(c==NULL) | 402 | return NULL; |
| 391 | return NULL; | ||
| 392 | memset(c, 0, sizeof(CommandList_struct)); | 403 | memset(c, 0, sizeof(CommandList_struct)); |
| 393 | 404 | ||
| 394 | c->cmdindex = -1; | 405 | c->cmdindex = -1; |
| 395 | 406 | ||
| 396 | c->err_info = (ErrorInfo_struct *)pci_alloc_consistent( | 407 | c->err_info = (ErrorInfo_struct *) |
| 397 | h->pdev, sizeof(ErrorInfo_struct), | 408 | pci_alloc_consistent(h->pdev, sizeof(ErrorInfo_struct), |
| 398 | &err_dma_handle); | 409 | &err_dma_handle); |
| 399 | 410 | ||
| 400 | if (c->err_info == NULL) | 411 | if (c->err_info == NULL) { |
| 401 | { | 412 | pci_free_consistent(h->pdev, |
| 402 | pci_free_consistent(h->pdev, | ||
| 403 | sizeof(CommandList_struct), c, cmd_dma_handle); | 413 | sizeof(CommandList_struct), c, cmd_dma_handle); |
| 404 | return NULL; | 414 | return NULL; |
| 405 | } | 415 | } |
| 406 | memset(c->err_info, 0, sizeof(ErrorInfo_struct)); | 416 | memset(c->err_info, 0, sizeof(ErrorInfo_struct)); |
| 407 | } else /* get it out of the controllers pool */ | 417 | } else { /* get it out of the controllers pool */ |
| 408 | { | 418 | |
| 409 | do { | 419 | do { |
| 410 | i = find_first_zero_bit(h->cmd_pool_bits, NR_CMDS); | 420 | i = find_first_zero_bit(h->cmd_pool_bits, NR_CMDS); |
| 411 | if (i == NR_CMDS) | 421 | if (i == NR_CMDS) |
| 412 | return NULL; | 422 | return NULL; |
| 413 | } while(test_and_set_bit(i & (BITS_PER_LONG - 1), h->cmd_pool_bits+(i/BITS_PER_LONG)) != 0); | 423 | } while (test_and_set_bit |
| 424 | (i & (BITS_PER_LONG - 1), | ||
| 425 | h->cmd_pool_bits + (i / BITS_PER_LONG)) != 0); | ||
| 414 | #ifdef CCISS_DEBUG | 426 | #ifdef CCISS_DEBUG |
| 415 | printk(KERN_DEBUG "cciss: using command buffer %d\n", i); | 427 | printk(KERN_DEBUG "cciss: using command buffer %d\n", i); |
| 416 | #endif | 428 | #endif |
| 417 | c = h->cmd_pool + i; | 429 | c = h->cmd_pool + i; |
| 418 | memset(c, 0, sizeof(CommandList_struct)); | 430 | memset(c, 0, sizeof(CommandList_struct)); |
| 419 | cmd_dma_handle = h->cmd_pool_dhandle | 431 | cmd_dma_handle = h->cmd_pool_dhandle |
| 420 | + i*sizeof(CommandList_struct); | 432 | + i * sizeof(CommandList_struct); |
| 421 | c->err_info = h->errinfo_pool + i; | 433 | c->err_info = h->errinfo_pool + i; |
| 422 | memset(c->err_info, 0, sizeof(ErrorInfo_struct)); | 434 | memset(c->err_info, 0, sizeof(ErrorInfo_struct)); |
| 423 | err_dma_handle = h->errinfo_pool_dhandle | 435 | err_dma_handle = h->errinfo_pool_dhandle |
| 424 | + i*sizeof(ErrorInfo_struct); | 436 | + i * sizeof(ErrorInfo_struct); |
| 425 | h->nr_allocs++; | 437 | h->nr_allocs++; |
| 426 | 438 | ||
| 427 | c->cmdindex = i; | 439 | c->cmdindex = i; |
| 428 | } | 440 | } |
| 429 | 441 | ||
| 430 | c->busaddr = (__u32) cmd_dma_handle; | 442 | c->busaddr = (__u32) cmd_dma_handle; |
| 431 | temp64.val = (__u64) err_dma_handle; | 443 | temp64.val = (__u64) err_dma_handle; |
| 432 | c->ErrDesc.Addr.lower = temp64.val32.lower; | 444 | c->ErrDesc.Addr.lower = temp64.val32.lower; |
| 433 | c->ErrDesc.Addr.upper = temp64.val32.upper; | 445 | c->ErrDesc.Addr.upper = temp64.val32.upper; |
| 434 | c->ErrDesc.Len = sizeof(ErrorInfo_struct); | 446 | c->ErrDesc.Len = sizeof(ErrorInfo_struct); |
| 435 | |||
| 436 | c->ctlr = h->ctlr; | ||
| 437 | return c; | ||
| 438 | |||
| 439 | 447 | ||
| 448 | c->ctlr = h->ctlr; | ||
| 449 | return c; | ||
| 440 | } | 450 | } |
| 441 | 451 | ||
| 442 | /* | 452 | /* |
| 443 | * Frees a command block that was previously allocated with cmd_alloc(). | 453 | * Frees a command block that was previously allocated with cmd_alloc(). |
| 444 | */ | 454 | */ |
| 445 | static void cmd_free(ctlr_info_t *h, CommandList_struct *c, int got_from_pool) | 455 | static void cmd_free(ctlr_info_t *h, CommandList_struct *c, int got_from_pool) |
| 446 | { | 456 | { |
| 447 | int i; | 457 | int i; |
| 448 | u64bit temp64; | 458 | u64bit temp64; |
| 449 | 459 | ||
| 450 | if( !got_from_pool) | 460 | if (!got_from_pool) { |
| 451 | { | ||
| 452 | temp64.val32.lower = c->ErrDesc.Addr.lower; | 461 | temp64.val32.lower = c->ErrDesc.Addr.lower; |
| 453 | temp64.val32.upper = c->ErrDesc.Addr.upper; | 462 | temp64.val32.upper = c->ErrDesc.Addr.upper; |
| 454 | pci_free_consistent(h->pdev, sizeof(ErrorInfo_struct), | 463 | pci_free_consistent(h->pdev, sizeof(ErrorInfo_struct), |
| 455 | c->err_info, (dma_addr_t) temp64.val); | 464 | c->err_info, (dma_addr_t) temp64.val); |
| 456 | pci_free_consistent(h->pdev, sizeof(CommandList_struct), | 465 | pci_free_consistent(h->pdev, sizeof(CommandList_struct), |
| 457 | c, (dma_addr_t) c->busaddr); | 466 | c, (dma_addr_t) c->busaddr); |
| 458 | } else | 467 | } else { |
| 459 | { | ||
| 460 | i = c - h->cmd_pool; | 468 | i = c - h->cmd_pool; |
| 461 | clear_bit(i&(BITS_PER_LONG-1), h->cmd_pool_bits+(i/BITS_PER_LONG)); | 469 | clear_bit(i & (BITS_PER_LONG - 1), |
| 462 | h->nr_frees++; | 470 | h->cmd_pool_bits + (i / BITS_PER_LONG)); |
| 463 | } | 471 | h->nr_frees++; |
| 472 | } | ||
| 464 | } | 473 | } |
| 465 | 474 | ||
| 466 | static inline ctlr_info_t *get_host(struct gendisk *disk) | 475 | static inline ctlr_info_t *get_host(struct gendisk *disk) |
| 467 | { | 476 | { |
| 468 | return disk->queue->queuedata; | 477 | return disk->queue->queuedata; |
| 469 | } | 478 | } |
| 470 | 479 | ||
| 471 | static inline drive_info_struct *get_drv(struct gendisk *disk) | 480 | static inline drive_info_struct *get_drv(struct gendisk *disk) |
| @@ -483,7 +492,7 @@ static int cciss_open(struct inode *inode, struct file *filep) | |||
| 483 | 492 | ||
| 484 | #ifdef CCISS_DEBUG | 493 | #ifdef CCISS_DEBUG |
| 485 | printk(KERN_DEBUG "cciss_open %s\n", inode->i_bdev->bd_disk->disk_name); | 494 | printk(KERN_DEBUG "cciss_open %s\n", inode->i_bdev->bd_disk->disk_name); |
| 486 | #endif /* CCISS_DEBUG */ | 495 | #endif /* CCISS_DEBUG */ |
| 487 | 496 | ||
| 488 | if (host->busy_initializing || drv->busy_configuring) | 497 | if (host->busy_initializing || drv->busy_configuring) |
| 489 | return -EBUSY; | 498 | return -EBUSY; |
| @@ -496,10 +505,10 @@ static int cciss_open(struct inode *inode, struct file *filep) | |||
| 496 | * for "raw controller". | 505 | * for "raw controller". |
| 497 | */ | 506 | */ |
| 498 | if (drv->nr_blocks == 0) { | 507 | if (drv->nr_blocks == 0) { |
| 499 | if (iminor(inode) != 0) { /* not node 0? */ | 508 | if (iminor(inode) != 0) { /* not node 0? */ |
| 500 | /* if not node 0 make sure it is a partition = 0 */ | 509 | /* if not node 0 make sure it is a partition = 0 */ |
| 501 | if (iminor(inode) & 0x0f) { | 510 | if (iminor(inode) & 0x0f) { |
| 502 | return -ENXIO; | 511 | return -ENXIO; |
| 503 | /* if it is, make sure we have a LUN ID */ | 512 | /* if it is, make sure we have a LUN ID */ |
| 504 | } else if (drv->LunID == 0) { | 513 | } else if (drv->LunID == 0) { |
| 505 | return -ENXIO; | 514 | return -ENXIO; |
| @@ -512,6 +521,7 @@ static int cciss_open(struct inode *inode, struct file *filep) | |||
| 512 | host->usage_count++; | 521 | host->usage_count++; |
| 513 | return 0; | 522 | return 0; |
| 514 | } | 523 | } |
| 524 | |||
| 515 | /* | 525 | /* |
| 516 | * Close. Sync first. | 526 | * Close. Sync first. |
| 517 | */ | 527 | */ |
| @@ -521,8 +531,9 @@ static int cciss_release(struct inode *inode, struct file *filep) | |||
| 521 | drive_info_struct *drv = get_drv(inode->i_bdev->bd_disk); | 531 | drive_info_struct *drv = get_drv(inode->i_bdev->bd_disk); |
| 522 | 532 | ||
| 523 | #ifdef CCISS_DEBUG | 533 | #ifdef CCISS_DEBUG |
| 524 | printk(KERN_DEBUG "cciss_release %s\n", inode->i_bdev->bd_disk->disk_name); | 534 | printk(KERN_DEBUG "cciss_release %s\n", |
| 525 | #endif /* CCISS_DEBUG */ | 535 | inode->i_bdev->bd_disk->disk_name); |
| 536 | #endif /* CCISS_DEBUG */ | ||
| 526 | 537 | ||
| 527 | drv->usage_count--; | 538 | drv->usage_count--; |
| 528 | host->usage_count--; | 539 | host->usage_count--; |
| @@ -540,8 +551,10 @@ static int do_ioctl(struct file *f, unsigned cmd, unsigned long arg) | |||
| 540 | return ret; | 551 | return ret; |
| 541 | } | 552 | } |
| 542 | 553 | ||
| 543 | static int cciss_ioctl32_passthru(struct file *f, unsigned cmd, unsigned long arg); | 554 | static int cciss_ioctl32_passthru(struct file *f, unsigned cmd, |
| 544 | static int cciss_ioctl32_big_passthru(struct file *f, unsigned cmd, unsigned long arg); | 555 | unsigned long arg); |
| 556 | static int cciss_ioctl32_big_passthru(struct file *f, unsigned cmd, | ||
| 557 | unsigned long arg); | ||
| 545 | 558 | ||
| 546 | static long cciss_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg) | 559 | static long cciss_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg) |
| 547 | { | 560 | { |
| @@ -573,19 +586,26 @@ static long cciss_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg) | |||
| 573 | } | 586 | } |
| 574 | } | 587 | } |
| 575 | 588 | ||
| 576 | static int cciss_ioctl32_passthru(struct file *f, unsigned cmd, unsigned long arg) | 589 | static int cciss_ioctl32_passthru(struct file *f, unsigned cmd, |
| 590 | unsigned long arg) | ||
| 577 | { | 591 | { |
| 578 | IOCTL32_Command_struct __user *arg32 = | 592 | IOCTL32_Command_struct __user *arg32 = |
| 579 | (IOCTL32_Command_struct __user *) arg; | 593 | (IOCTL32_Command_struct __user *) arg; |
| 580 | IOCTL_Command_struct arg64; | 594 | IOCTL_Command_struct arg64; |
| 581 | IOCTL_Command_struct __user *p = compat_alloc_user_space(sizeof(arg64)); | 595 | IOCTL_Command_struct __user *p = compat_alloc_user_space(sizeof(arg64)); |
| 582 | int err; | 596 | int err; |
| 583 | u32 cp; | 597 | u32 cp; |
| 584 | 598 | ||
| 585 | err = 0; | 599 | err = 0; |
| 586 | err |= copy_from_user(&arg64.LUN_info, &arg32->LUN_info, sizeof(arg64.LUN_info)); | 600 | err |= |
| 587 | err |= copy_from_user(&arg64.Request, &arg32->Request, sizeof(arg64.Request)); | 601 | copy_from_user(&arg64.LUN_info, &arg32->LUN_info, |
| 588 | err |= copy_from_user(&arg64.error_info, &arg32->error_info, sizeof(arg64.error_info)); | 602 | sizeof(arg64.LUN_info)); |
| 603 | err |= | ||
| 604 | copy_from_user(&arg64.Request, &arg32->Request, | ||
| 605 | sizeof(arg64.Request)); | ||
| 606 | err |= | ||
| 607 | copy_from_user(&arg64.error_info, &arg32->error_info, | ||
| 608 | sizeof(arg64.error_info)); | ||
| 589 | err |= get_user(arg64.buf_size, &arg32->buf_size); | 609 | err |= get_user(arg64.buf_size, &arg32->buf_size); |
| 590 | err |= get_user(cp, &arg32->buf); | 610 | err |= get_user(cp, &arg32->buf); |
| 591 | arg64.buf = compat_ptr(cp); | 611 | arg64.buf = compat_ptr(cp); |
| @@ -594,28 +614,38 @@ static int cciss_ioctl32_passthru(struct file *f, unsigned cmd, unsigned long ar | |||
| 594 | if (err) | 614 | if (err) |
| 595 | return -EFAULT; | 615 | return -EFAULT; |
| 596 | 616 | ||
| 597 | err = do_ioctl(f, CCISS_PASSTHRU, (unsigned long) p); | 617 | err = do_ioctl(f, CCISS_PASSTHRU, (unsigned long)p); |
| 598 | if (err) | 618 | if (err) |
| 599 | return err; | 619 | return err; |
| 600 | err |= copy_in_user(&arg32->error_info, &p->error_info, sizeof(arg32->error_info)); | 620 | err |= |
| 621 | copy_in_user(&arg32->error_info, &p->error_info, | ||
| 622 | sizeof(arg32->error_info)); | ||
| 601 | if (err) | 623 | if (err) |
| 602 | return -EFAULT; | 624 | return -EFAULT; |
| 603 | return err; | 625 | return err; |
| 604 | } | 626 | } |
| 605 | 627 | ||
| 606 | static int cciss_ioctl32_big_passthru(struct file *file, unsigned cmd, unsigned long arg) | 628 | static int cciss_ioctl32_big_passthru(struct file *file, unsigned cmd, |
| 629 | unsigned long arg) | ||
| 607 | { | 630 | { |
| 608 | BIG_IOCTL32_Command_struct __user *arg32 = | 631 | BIG_IOCTL32_Command_struct __user *arg32 = |
| 609 | (BIG_IOCTL32_Command_struct __user *) arg; | 632 | (BIG_IOCTL32_Command_struct __user *) arg; |
| 610 | BIG_IOCTL_Command_struct arg64; | 633 | BIG_IOCTL_Command_struct arg64; |
| 611 | BIG_IOCTL_Command_struct __user *p = compat_alloc_user_space(sizeof(arg64)); | 634 | BIG_IOCTL_Command_struct __user *p = |
| 635 | compat_alloc_user_space(sizeof(arg64)); | ||
| 612 | int err; | 636 | int err; |
| 613 | u32 cp; | 637 | u32 cp; |
| 614 | 638 | ||
| 615 | err = 0; | 639 | err = 0; |
| 616 | err |= copy_from_user(&arg64.LUN_info, &arg32->LUN_info, sizeof(arg64.LUN_info)); | 640 | err |= |
| 617 | err |= copy_from_user(&arg64.Request, &arg32->Request, sizeof(arg64.Request)); | 641 | copy_from_user(&arg64.LUN_info, &arg32->LUN_info, |
| 618 | err |= copy_from_user(&arg64.error_info, &arg32->error_info, sizeof(arg64.error_info)); | 642 | sizeof(arg64.LUN_info)); |
| 643 | err |= | ||
| 644 | copy_from_user(&arg64.Request, &arg32->Request, | ||
| 645 | sizeof(arg64.Request)); | ||
| 646 | err |= | ||
| 647 | copy_from_user(&arg64.error_info, &arg32->error_info, | ||
| 648 | sizeof(arg64.error_info)); | ||
| 619 | err |= get_user(arg64.buf_size, &arg32->buf_size); | 649 | err |= get_user(arg64.buf_size, &arg32->buf_size); |
| 620 | err |= get_user(arg64.malloc_size, &arg32->malloc_size); | 650 | err |= get_user(arg64.malloc_size, &arg32->malloc_size); |
| 621 | err |= get_user(cp, &arg32->buf); | 651 | err |= get_user(cp, &arg32->buf); |
| @@ -623,12 +653,14 @@ static int cciss_ioctl32_big_passthru(struct file *file, unsigned cmd, unsigned | |||
| 623 | err |= copy_to_user(p, &arg64, sizeof(arg64)); | 653 | err |= copy_to_user(p, &arg64, sizeof(arg64)); |
| 624 | 654 | ||
| 625 | if (err) | 655 | if (err) |
| 626 | return -EFAULT; | 656 | return -EFAULT; |
| 627 | 657 | ||
| 628 | err = do_ioctl(file, CCISS_BIG_PASSTHRU, (unsigned long) p); | 658 | err = do_ioctl(file, CCISS_BIG_PASSTHRU, (unsigned long)p); |
| 629 | if (err) | 659 | if (err) |
| 630 | return err; | 660 | return err; |
| 631 | err |= copy_in_user(&arg32->error_info, &p->error_info, sizeof(arg32->error_info)); | 661 | err |= |
| 662 | copy_in_user(&arg32->error_info, &p->error_info, | ||
| 663 | sizeof(arg32->error_info)); | ||
| 632 | if (err) | 664 | if (err) |
| 633 | return -EFAULT; | 665 | return -EFAULT; |
| 634 | return err; | 666 | return err; |
| @@ -649,10 +681,10 @@ static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo) | |||
| 649 | } | 681 | } |
| 650 | 682 | ||
| 651 | /* | 683 | /* |
| 652 | * ioctl | 684 | * ioctl |
| 653 | */ | 685 | */ |
| 654 | static int cciss_ioctl(struct inode *inode, struct file *filep, | 686 | static int cciss_ioctl(struct inode *inode, struct file *filep, |
| 655 | unsigned int cmd, unsigned long arg) | 687 | unsigned int cmd, unsigned long arg) |
| 656 | { | 688 | { |
| 657 | struct block_device *bdev = inode->i_bdev; | 689 | struct block_device *bdev = inode->i_bdev; |
| 658 | struct gendisk *disk = bdev->bd_disk; | 690 | struct gendisk *disk = bdev->bd_disk; |
| @@ -663,171 +695,193 @@ static int cciss_ioctl(struct inode *inode, struct file *filep, | |||
| 663 | 695 | ||
| 664 | #ifdef CCISS_DEBUG | 696 | #ifdef CCISS_DEBUG |
| 665 | printk(KERN_DEBUG "cciss_ioctl: Called with cmd=%x %lx\n", cmd, arg); | 697 | printk(KERN_DEBUG "cciss_ioctl: Called with cmd=%x %lx\n", cmd, arg); |
| 666 | #endif /* CCISS_DEBUG */ | 698 | #endif /* CCISS_DEBUG */ |
| 667 | 699 | ||
| 668 | switch(cmd) { | 700 | switch (cmd) { |
| 669 | case CCISS_GETPCIINFO: | 701 | case CCISS_GETPCIINFO: |
| 670 | { | 702 | { |
| 671 | cciss_pci_info_struct pciinfo; | 703 | cciss_pci_info_struct pciinfo; |
| 672 | 704 | ||
| 673 | if (!arg) return -EINVAL; | 705 | if (!arg) |
| 674 | pciinfo.domain = pci_domain_nr(host->pdev->bus); | 706 | return -EINVAL; |
| 675 | pciinfo.bus = host->pdev->bus->number; | 707 | pciinfo.domain = pci_domain_nr(host->pdev->bus); |
| 676 | pciinfo.dev_fn = host->pdev->devfn; | 708 | pciinfo.bus = host->pdev->bus->number; |
| 677 | pciinfo.board_id = host->board_id; | 709 | pciinfo.dev_fn = host->pdev->devfn; |
| 678 | if (copy_to_user(argp, &pciinfo, sizeof( cciss_pci_info_struct ))) | 710 | pciinfo.board_id = host->board_id; |
| 679 | return -EFAULT; | 711 | if (copy_to_user |
| 680 | return 0; | 712 | (argp, &pciinfo, sizeof(cciss_pci_info_struct))) |
| 681 | } | 713 | return -EFAULT; |
| 714 | return 0; | ||
| 715 | } | ||
| 682 | case CCISS_GETINTINFO: | 716 | case CCISS_GETINTINFO: |
| 683 | { | 717 | { |
| 684 | cciss_coalint_struct intinfo; | 718 | cciss_coalint_struct intinfo; |
| 685 | if (!arg) return -EINVAL; | 719 | if (!arg) |
| 686 | intinfo.delay = readl(&host->cfgtable->HostWrite.CoalIntDelay); | 720 | return -EINVAL; |
| 687 | intinfo.count = readl(&host->cfgtable->HostWrite.CoalIntCount); | 721 | intinfo.delay = |
| 688 | if (copy_to_user(argp, &intinfo, sizeof( cciss_coalint_struct ))) | 722 | readl(&host->cfgtable->HostWrite.CoalIntDelay); |
| 689 | return -EFAULT; | 723 | intinfo.count = |
| 690 | return 0; | 724 | readl(&host->cfgtable->HostWrite.CoalIntCount); |
| 691 | } | 725 | if (copy_to_user |
| 726 | (argp, &intinfo, sizeof(cciss_coalint_struct))) | ||
| 727 | return -EFAULT; | ||
| 728 | return 0; | ||
| 729 | } | ||
| 692 | case CCISS_SETINTINFO: | 730 | case CCISS_SETINTINFO: |
| 693 | { | ||
| 694 | cciss_coalint_struct intinfo; | ||
| 695 | unsigned long flags; | ||
| 696 | int i; | ||
| 697 | |||
| 698 | if (!arg) return -EINVAL; | ||
| 699 | if (!capable(CAP_SYS_ADMIN)) return -EPERM; | ||
| 700 | if (copy_from_user(&intinfo, argp, sizeof( cciss_coalint_struct))) | ||
| 701 | return -EFAULT; | ||
| 702 | if ( (intinfo.delay == 0 ) && (intinfo.count == 0)) | ||
| 703 | |||
| 704 | { | 731 | { |
| 705 | // printk("cciss_ioctl: delay and count cannot be 0\n"); | 732 | cciss_coalint_struct intinfo; |
| 706 | return -EINVAL; | 733 | unsigned long flags; |
| 734 | int i; | ||
| 735 | |||
| 736 | if (!arg) | ||
| 737 | return -EINVAL; | ||
| 738 | if (!capable(CAP_SYS_ADMIN)) | ||
| 739 | return -EPERM; | ||
| 740 | if (copy_from_user | ||
| 741 | (&intinfo, argp, sizeof(cciss_coalint_struct))) | ||
| 742 | return -EFAULT; | ||
| 743 | if ((intinfo.delay == 0) && (intinfo.count == 0)) | ||
| 744 | { | ||
| 745 | // printk("cciss_ioctl: delay and count cannot be 0\n"); | ||
| 746 | return -EINVAL; | ||
| 747 | } | ||
| 748 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | ||
| 749 | /* Update the field, and then ring the doorbell */ | ||
| 750 | writel(intinfo.delay, | ||
| 751 | &(host->cfgtable->HostWrite.CoalIntDelay)); | ||
| 752 | writel(intinfo.count, | ||
| 753 | &(host->cfgtable->HostWrite.CoalIntCount)); | ||
| 754 | writel(CFGTBL_ChangeReq, host->vaddr + SA5_DOORBELL); | ||
| 755 | |||
| 756 | for (i = 0; i < MAX_IOCTL_CONFIG_WAIT; i++) { | ||
| 757 | if (!(readl(host->vaddr + SA5_DOORBELL) | ||
| 758 | & CFGTBL_ChangeReq)) | ||
| 759 | break; | ||
| 760 | /* delay and try again */ | ||
| 761 | udelay(1000); | ||
| 762 | } | ||
| 763 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | ||
| 764 | if (i >= MAX_IOCTL_CONFIG_WAIT) | ||
| 765 | return -EAGAIN; | ||
| 766 | return 0; | ||
| 707 | } | 767 | } |
| 708 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | ||
| 709 | /* Update the field, and then ring the doorbell */ | ||
| 710 | writel( intinfo.delay, | ||
| 711 | &(host->cfgtable->HostWrite.CoalIntDelay)); | ||
| 712 | writel( intinfo.count, | ||
| 713 | &(host->cfgtable->HostWrite.CoalIntCount)); | ||
| 714 | writel( CFGTBL_ChangeReq, host->vaddr + SA5_DOORBELL); | ||
| 715 | |||
| 716 | for(i=0;i<MAX_IOCTL_CONFIG_WAIT;i++) { | ||
| 717 | if (!(readl(host->vaddr + SA5_DOORBELL) | ||
| 718 | & CFGTBL_ChangeReq)) | ||
| 719 | break; | ||
| 720 | /* delay and try again */ | ||
| 721 | udelay(1000); | ||
| 722 | } | ||
| 723 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | ||
| 724 | if (i >= MAX_IOCTL_CONFIG_WAIT) | ||
| 725 | return -EAGAIN; | ||
| 726 | return 0; | ||
| 727 | } | ||
| 728 | case CCISS_GETNODENAME: | 768 | case CCISS_GETNODENAME: |
| 729 | { | 769 | { |
| 730 | NodeName_type NodeName; | 770 | NodeName_type NodeName; |
| 731 | int i; | 771 | int i; |
| 732 | 772 | ||
| 733 | if (!arg) return -EINVAL; | 773 | if (!arg) |
| 734 | for(i=0;i<16;i++) | 774 | return -EINVAL; |
| 735 | NodeName[i] = readb(&host->cfgtable->ServerName[i]); | 775 | for (i = 0; i < 16; i++) |
| 736 | if (copy_to_user(argp, NodeName, sizeof( NodeName_type))) | 776 | NodeName[i] = |
| 737 | return -EFAULT; | 777 | readb(&host->cfgtable->ServerName[i]); |
| 738 | return 0; | 778 | if (copy_to_user(argp, NodeName, sizeof(NodeName_type))) |
| 739 | } | 779 | return -EFAULT; |
| 780 | return 0; | ||
| 781 | } | ||
| 740 | case CCISS_SETNODENAME: | 782 | case CCISS_SETNODENAME: |
| 741 | { | 783 | { |
| 742 | NodeName_type NodeName; | 784 | NodeName_type NodeName; |
| 743 | unsigned long flags; | 785 | unsigned long flags; |
| 744 | int i; | 786 | int i; |
| 745 | 787 | ||
| 746 | if (!arg) return -EINVAL; | 788 | if (!arg) |
| 747 | if (!capable(CAP_SYS_ADMIN)) return -EPERM; | 789 | return -EINVAL; |
| 748 | 790 | if (!capable(CAP_SYS_ADMIN)) | |
| 749 | if (copy_from_user(NodeName, argp, sizeof( NodeName_type))) | 791 | return -EPERM; |
| 750 | return -EFAULT; | 792 | |
| 751 | 793 | if (copy_from_user | |
| 752 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | 794 | (NodeName, argp, sizeof(NodeName_type))) |
| 753 | 795 | return -EFAULT; | |
| 754 | /* Update the field, and then ring the doorbell */ | 796 | |
| 755 | for(i=0;i<16;i++) | 797 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); |
| 756 | writeb( NodeName[i], &host->cfgtable->ServerName[i]); | 798 | |
| 757 | 799 | /* Update the field, and then ring the doorbell */ | |
| 758 | writel( CFGTBL_ChangeReq, host->vaddr + SA5_DOORBELL); | 800 | for (i = 0; i < 16; i++) |
| 759 | 801 | writeb(NodeName[i], | |
| 760 | for(i=0;i<MAX_IOCTL_CONFIG_WAIT;i++) { | 802 | &host->cfgtable->ServerName[i]); |
| 761 | if (!(readl(host->vaddr + SA5_DOORBELL) | 803 | |
| 762 | & CFGTBL_ChangeReq)) | 804 | writel(CFGTBL_ChangeReq, host->vaddr + SA5_DOORBELL); |
| 763 | break; | 805 | |
| 764 | /* delay and try again */ | 806 | for (i = 0; i < MAX_IOCTL_CONFIG_WAIT; i++) { |
| 765 | udelay(1000); | 807 | if (!(readl(host->vaddr + SA5_DOORBELL) |
| 766 | } | 808 | & CFGTBL_ChangeReq)) |
| 767 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | 809 | break; |
| 768 | if (i >= MAX_IOCTL_CONFIG_WAIT) | 810 | /* delay and try again */ |
| 769 | return -EAGAIN; | 811 | udelay(1000); |
| 770 | return 0; | 812 | } |
| 771 | } | 813 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); |
| 814 | if (i >= MAX_IOCTL_CONFIG_WAIT) | ||
| 815 | return -EAGAIN; | ||
| 816 | return 0; | ||
| 817 | } | ||
| 772 | 818 | ||
| 773 | case CCISS_GETHEARTBEAT: | 819 | case CCISS_GETHEARTBEAT: |
| 774 | { | 820 | { |
| 775 | Heartbeat_type heartbeat; | 821 | Heartbeat_type heartbeat; |
| 776 | 822 | ||
| 777 | if (!arg) return -EINVAL; | 823 | if (!arg) |
| 778 | heartbeat = readl(&host->cfgtable->HeartBeat); | 824 | return -EINVAL; |
| 779 | if (copy_to_user(argp, &heartbeat, sizeof( Heartbeat_type))) | 825 | heartbeat = readl(&host->cfgtable->HeartBeat); |
| 780 | return -EFAULT; | 826 | if (copy_to_user |
| 781 | return 0; | 827 | (argp, &heartbeat, sizeof(Heartbeat_type))) |
| 782 | } | 828 | return -EFAULT; |
| 829 | return 0; | ||
| 830 | } | ||
| 783 | case CCISS_GETBUSTYPES: | 831 | case CCISS_GETBUSTYPES: |
| 784 | { | 832 | { |
| 785 | BusTypes_type BusTypes; | 833 | BusTypes_type BusTypes; |
| 786 | 834 | ||
| 787 | if (!arg) return -EINVAL; | 835 | if (!arg) |
| 788 | BusTypes = readl(&host->cfgtable->BusTypes); | 836 | return -EINVAL; |
| 789 | if (copy_to_user(argp, &BusTypes, sizeof( BusTypes_type) )) | 837 | BusTypes = readl(&host->cfgtable->BusTypes); |
| 790 | return -EFAULT; | 838 | if (copy_to_user |
| 791 | return 0; | 839 | (argp, &BusTypes, sizeof(BusTypes_type))) |
| 792 | } | 840 | return -EFAULT; |
| 841 | return 0; | ||
| 842 | } | ||
| 793 | case CCISS_GETFIRMVER: | 843 | case CCISS_GETFIRMVER: |
| 794 | { | 844 | { |
| 795 | FirmwareVer_type firmware; | 845 | FirmwareVer_type firmware; |
| 796 | 846 | ||
| 797 | if (!arg) return -EINVAL; | 847 | if (!arg) |
| 798 | memcpy(firmware, host->firm_ver, 4); | 848 | return -EINVAL; |
| 849 | memcpy(firmware, host->firm_ver, 4); | ||
| 799 | 850 | ||
| 800 | if (copy_to_user(argp, firmware, sizeof( FirmwareVer_type))) | 851 | if (copy_to_user |
| 801 | return -EFAULT; | 852 | (argp, firmware, sizeof(FirmwareVer_type))) |
| 802 | return 0; | 853 | return -EFAULT; |
| 803 | } | 854 | return 0; |
| 804 | case CCISS_GETDRIVVER: | 855 | } |
| 805 | { | 856 | case CCISS_GETDRIVVER: |
| 806 | DriverVer_type DriverVer = DRIVER_VERSION; | 857 | { |
| 858 | DriverVer_type DriverVer = DRIVER_VERSION; | ||
| 807 | 859 | ||
| 808 | if (!arg) return -EINVAL; | 860 | if (!arg) |
| 861 | return -EINVAL; | ||
| 809 | 862 | ||
| 810 | if (copy_to_user(argp, &DriverVer, sizeof( DriverVer_type) )) | 863 | if (copy_to_user |
| 811 | return -EFAULT; | 864 | (argp, &DriverVer, sizeof(DriverVer_type))) |
| 812 | return 0; | 865 | return -EFAULT; |
| 813 | } | 866 | return 0; |
| 867 | } | ||
| 814 | 868 | ||
| 815 | case CCISS_REVALIDVOLS: | 869 | case CCISS_REVALIDVOLS: |
| 816 | if (bdev != bdev->bd_contains || drv != host->drv) | 870 | if (bdev != bdev->bd_contains || drv != host->drv) |
| 817 | return -ENXIO; | 871 | return -ENXIO; |
| 818 | return revalidate_allvol(host); | 872 | return revalidate_allvol(host); |
| 819 | 873 | ||
| 820 | case CCISS_GETLUNINFO: { | 874 | case CCISS_GETLUNINFO:{ |
| 821 | LogvolInfo_struct luninfo; | 875 | LogvolInfo_struct luninfo; |
| 822 | 876 | ||
| 823 | luninfo.LunID = drv->LunID; | 877 | luninfo.LunID = drv->LunID; |
| 824 | luninfo.num_opens = drv->usage_count; | 878 | luninfo.num_opens = drv->usage_count; |
| 825 | luninfo.num_parts = 0; | 879 | luninfo.num_parts = 0; |
| 826 | if (copy_to_user(argp, &luninfo, | 880 | if (copy_to_user(argp, &luninfo, |
| 827 | sizeof(LogvolInfo_struct))) | 881 | sizeof(LogvolInfo_struct))) |
| 828 | return -EFAULT; | 882 | return -EFAULT; |
| 829 | return 0; | 883 | return 0; |
| 830 | } | 884 | } |
| 831 | case CCISS_DEREGDISK: | 885 | case CCISS_DEREGDISK: |
| 832 | return rebuild_lun_table(host, disk); | 886 | return rebuild_lun_table(host, disk); |
| 833 | 887 | ||
| @@ -835,278 +889,284 @@ static int cciss_ioctl(struct inode *inode, struct file *filep, | |||
| 835 | return rebuild_lun_table(host, NULL); | 889 | return rebuild_lun_table(host, NULL); |
| 836 | 890 | ||
| 837 | case CCISS_PASSTHRU: | 891 | case CCISS_PASSTHRU: |
| 838 | { | ||
| 839 | IOCTL_Command_struct iocommand; | ||
| 840 | CommandList_struct *c; | ||
| 841 | char *buff = NULL; | ||
| 842 | u64bit temp64; | ||
| 843 | unsigned long flags; | ||
| 844 | DECLARE_COMPLETION(wait); | ||
| 845 | |||
| 846 | if (!arg) return -EINVAL; | ||
| 847 | |||
| 848 | if (!capable(CAP_SYS_RAWIO)) return -EPERM; | ||
| 849 | |||
| 850 | if (copy_from_user(&iocommand, argp, sizeof( IOCTL_Command_struct) )) | ||
| 851 | return -EFAULT; | ||
| 852 | if((iocommand.buf_size < 1) && | ||
| 853 | (iocommand.Request.Type.Direction != XFER_NONE)) | ||
| 854 | { | ||
| 855 | return -EINVAL; | ||
| 856 | } | ||
| 857 | #if 0 /* 'buf_size' member is 16-bits, and always smaller than kmalloc limit */ | ||
| 858 | /* Check kmalloc limits */ | ||
| 859 | if(iocommand.buf_size > 128000) | ||
| 860 | return -EINVAL; | ||
| 861 | #endif | ||
| 862 | if(iocommand.buf_size > 0) | ||
| 863 | { | ||
| 864 | buff = kmalloc(iocommand.buf_size, GFP_KERNEL); | ||
| 865 | if( buff == NULL) | ||
| 866 | return -EFAULT; | ||
| 867 | } | ||
| 868 | if (iocommand.Request.Type.Direction == XFER_WRITE) | ||
| 869 | { | ||
| 870 | /* Copy the data into the buffer we created */ | ||
| 871 | if (copy_from_user(buff, iocommand.buf, iocommand.buf_size)) | ||
| 872 | { | ||
| 873 | kfree(buff); | ||
| 874 | return -EFAULT; | ||
| 875 | } | ||
| 876 | } else { | ||
| 877 | memset(buff, 0, iocommand.buf_size); | ||
| 878 | } | ||
| 879 | if ((c = cmd_alloc(host , 0)) == NULL) | ||
| 880 | { | 892 | { |
| 881 | kfree(buff); | 893 | IOCTL_Command_struct iocommand; |
| 882 | return -ENOMEM; | 894 | CommandList_struct *c; |
| 883 | } | 895 | char *buff = NULL; |
| 884 | // Fill in the command type | 896 | u64bit temp64; |
| 885 | c->cmd_type = CMD_IOCTL_PEND; | 897 | unsigned long flags; |
| 886 | // Fill in Command Header | 898 | DECLARE_COMPLETION(wait); |
| 887 | c->Header.ReplyQueue = 0; // unused in simple mode | ||
| 888 | if( iocommand.buf_size > 0) // buffer to fill | ||
| 889 | { | ||
| 890 | c->Header.SGList = 1; | ||
| 891 | c->Header.SGTotal= 1; | ||
| 892 | } else // no buffers to fill | ||
| 893 | { | ||
| 894 | c->Header.SGList = 0; | ||
| 895 | c->Header.SGTotal= 0; | ||
| 896 | } | ||
| 897 | c->Header.LUN = iocommand.LUN_info; | ||
| 898 | c->Header.Tag.lower = c->busaddr; // use the kernel address the cmd block for tag | ||
| 899 | |||
| 900 | // Fill in Request block | ||
| 901 | c->Request = iocommand.Request; | ||
| 902 | |||
| 903 | // Fill in the scatter gather information | ||
| 904 | if (iocommand.buf_size > 0 ) | ||
| 905 | { | ||
| 906 | temp64.val = pci_map_single( host->pdev, buff, | ||
| 907 | iocommand.buf_size, | ||
| 908 | PCI_DMA_BIDIRECTIONAL); | ||
| 909 | c->SG[0].Addr.lower = temp64.val32.lower; | ||
| 910 | c->SG[0].Addr.upper = temp64.val32.upper; | ||
| 911 | c->SG[0].Len = iocommand.buf_size; | ||
| 912 | c->SG[0].Ext = 0; // we are not chaining | ||
| 913 | } | ||
| 914 | c->waiting = &wait; | ||
| 915 | 899 | ||
| 916 | /* Put the request on the tail of the request queue */ | 900 | if (!arg) |
| 917 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | 901 | return -EINVAL; |
| 918 | addQ(&host->reqQ, c); | ||
| 919 | host->Qdepth++; | ||
| 920 | start_io(host); | ||
| 921 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | ||
| 922 | 902 | ||
| 923 | wait_for_completion(&wait); | 903 | if (!capable(CAP_SYS_RAWIO)) |
| 904 | return -EPERM; | ||
| 924 | 905 | ||
| 925 | /* unlock the buffers from DMA */ | 906 | if (copy_from_user |
| 926 | temp64.val32.lower = c->SG[0].Addr.lower; | 907 | (&iocommand, argp, sizeof(IOCTL_Command_struct))) |
| 927 | temp64.val32.upper = c->SG[0].Addr.upper; | 908 | return -EFAULT; |
| 928 | pci_unmap_single( host->pdev, (dma_addr_t) temp64.val, | 909 | if ((iocommand.buf_size < 1) && |
| 929 | iocommand.buf_size, PCI_DMA_BIDIRECTIONAL); | 910 | (iocommand.Request.Type.Direction != XFER_NONE)) { |
| 911 | return -EINVAL; | ||
| 912 | } | ||
| 913 | #if 0 /* 'buf_size' member is 16-bits, and always smaller than kmalloc limit */ | ||
| 914 | /* Check kmalloc limits */ | ||
| 915 | if (iocommand.buf_size > 128000) | ||
| 916 | return -EINVAL; | ||
| 917 | #endif | ||
| 918 | if (iocommand.buf_size > 0) { | ||
| 919 | buff = kmalloc(iocommand.buf_size, GFP_KERNEL); | ||
| 920 | if (buff == NULL) | ||
| 921 | return -EFAULT; | ||
| 922 | } | ||
| 923 | if (iocommand.Request.Type.Direction == XFER_WRITE) { | ||
| 924 | /* Copy the data into the buffer we created */ | ||
| 925 | if (copy_from_user | ||
| 926 | (buff, iocommand.buf, iocommand.buf_size)) { | ||
| 927 | kfree(buff); | ||
| 928 | return -EFAULT; | ||
| 929 | } | ||
| 930 | } else { | ||
| 931 | memset(buff, 0, iocommand.buf_size); | ||
| 932 | } | ||
| 933 | if ((c = cmd_alloc(host, 0)) == NULL) { | ||
| 934 | kfree(buff); | ||
| 935 | return -ENOMEM; | ||
| 936 | } | ||
| 937 | // Fill in the command type | ||
| 938 | c->cmd_type = CMD_IOCTL_PEND; | ||
| 939 | // Fill in Command Header | ||
| 940 | c->Header.ReplyQueue = 0; // unused in simple mode | ||
| 941 | if (iocommand.buf_size > 0) // buffer to fill | ||
| 942 | { | ||
| 943 | c->Header.SGList = 1; | ||
| 944 | c->Header.SGTotal = 1; | ||
| 945 | } else // no buffers to fill | ||
| 946 | { | ||
| 947 | c->Header.SGList = 0; | ||
| 948 | c->Header.SGTotal = 0; | ||
| 949 | } | ||
| 950 | c->Header.LUN = iocommand.LUN_info; | ||
| 951 | c->Header.Tag.lower = c->busaddr; // use the kernel address the cmd block for tag | ||
| 930 | 952 | ||
| 931 | /* Copy the error information out */ | 953 | // Fill in Request block |
| 932 | iocommand.error_info = *(c->err_info); | 954 | c->Request = iocommand.Request; |
| 933 | if ( copy_to_user(argp, &iocommand, sizeof( IOCTL_Command_struct) ) ) | ||
| 934 | { | ||
| 935 | kfree(buff); | ||
| 936 | cmd_free(host, c, 0); | ||
| 937 | return -EFAULT; | ||
| 938 | } | ||
| 939 | 955 | ||
| 940 | if (iocommand.Request.Type.Direction == XFER_READ) | 956 | // Fill in the scatter gather information |
| 941 | { | 957 | if (iocommand.buf_size > 0) { |
| 942 | /* Copy the data out of the buffer we created */ | 958 | temp64.val = pci_map_single(host->pdev, buff, |
| 943 | if (copy_to_user(iocommand.buf, buff, iocommand.buf_size)) | 959 | iocommand.buf_size, |
| 944 | { | 960 | PCI_DMA_BIDIRECTIONAL); |
| 945 | kfree(buff); | 961 | c->SG[0].Addr.lower = temp64.val32.lower; |
| 962 | c->SG[0].Addr.upper = temp64.val32.upper; | ||
| 963 | c->SG[0].Len = iocommand.buf_size; | ||
| 964 | c->SG[0].Ext = 0; // we are not chaining | ||
| 965 | } | ||
| 966 | c->waiting = &wait; | ||
| 967 | |||
| 968 | /* Put the request on the tail of the request queue */ | ||
| 969 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | ||
| 970 | addQ(&host->reqQ, c); | ||
| 971 | host->Qdepth++; | ||
| 972 | start_io(host); | ||
| 973 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | ||
| 974 | |||
| 975 | wait_for_completion(&wait); | ||
| 976 | |||
| 977 | /* unlock the buffers from DMA */ | ||
| 978 | temp64.val32.lower = c->SG[0].Addr.lower; | ||
| 979 | temp64.val32.upper = c->SG[0].Addr.upper; | ||
| 980 | pci_unmap_single(host->pdev, (dma_addr_t) temp64.val, | ||
| 981 | iocommand.buf_size, | ||
| 982 | PCI_DMA_BIDIRECTIONAL); | ||
| 983 | |||
| 984 | /* Copy the error information out */ | ||
| 985 | iocommand.error_info = *(c->err_info); | ||
| 986 | if (copy_to_user | ||
| 987 | (argp, &iocommand, sizeof(IOCTL_Command_struct))) { | ||
| 988 | kfree(buff); | ||
| 946 | cmd_free(host, c, 0); | 989 | cmd_free(host, c, 0); |
| 947 | return -EFAULT; | 990 | return -EFAULT; |
| 948 | } | 991 | } |
| 949 | } | 992 | |
| 950 | kfree(buff); | 993 | if (iocommand.Request.Type.Direction == XFER_READ) { |
| 951 | cmd_free(host, c, 0); | 994 | /* Copy the data out of the buffer we created */ |
| 952 | return 0; | 995 | if (copy_to_user |
| 953 | } | 996 | (iocommand.buf, buff, iocommand.buf_size)) { |
| 954 | case CCISS_BIG_PASSTHRU: { | 997 | kfree(buff); |
| 955 | BIG_IOCTL_Command_struct *ioc; | 998 | cmd_free(host, c, 0); |
| 956 | CommandList_struct *c; | 999 | return -EFAULT; |
| 957 | unsigned char **buff = NULL; | 1000 | } |
| 958 | int *buff_size = NULL; | 1001 | } |
| 959 | u64bit temp64; | 1002 | kfree(buff); |
| 960 | unsigned long flags; | 1003 | cmd_free(host, c, 0); |
| 961 | BYTE sg_used = 0; | 1004 | return 0; |
| 962 | int status = 0; | ||
| 963 | int i; | ||
| 964 | DECLARE_COMPLETION(wait); | ||
| 965 | __u32 left; | ||
| 966 | __u32 sz; | ||
| 967 | BYTE __user *data_ptr; | ||
| 968 | |||
| 969 | if (!arg) | ||
| 970 | return -EINVAL; | ||
| 971 | if (!capable(CAP_SYS_RAWIO)) | ||
| 972 | return -EPERM; | ||
| 973 | ioc = (BIG_IOCTL_Command_struct *) | ||
| 974 | kmalloc(sizeof(*ioc), GFP_KERNEL); | ||
| 975 | if (!ioc) { | ||
| 976 | status = -ENOMEM; | ||
| 977 | goto cleanup1; | ||
| 978 | } | ||
| 979 | if (copy_from_user(ioc, argp, sizeof(*ioc))) { | ||
| 980 | status = -EFAULT; | ||
| 981 | goto cleanup1; | ||
| 982 | } | 1005 | } |
| 983 | if ((ioc->buf_size < 1) && | 1006 | case CCISS_BIG_PASSTHRU:{ |
| 984 | (ioc->Request.Type.Direction != XFER_NONE)) { | 1007 | BIG_IOCTL_Command_struct *ioc; |
| 1008 | CommandList_struct *c; | ||
| 1009 | unsigned char **buff = NULL; | ||
| 1010 | int *buff_size = NULL; | ||
| 1011 | u64bit temp64; | ||
| 1012 | unsigned long flags; | ||
| 1013 | BYTE sg_used = 0; | ||
| 1014 | int status = 0; | ||
| 1015 | int i; | ||
| 1016 | DECLARE_COMPLETION(wait); | ||
| 1017 | __u32 left; | ||
| 1018 | __u32 sz; | ||
| 1019 | BYTE __user *data_ptr; | ||
| 1020 | |||
| 1021 | if (!arg) | ||
| 1022 | return -EINVAL; | ||
| 1023 | if (!capable(CAP_SYS_RAWIO)) | ||
| 1024 | return -EPERM; | ||
| 1025 | ioc = (BIG_IOCTL_Command_struct *) | ||
| 1026 | kmalloc(sizeof(*ioc), GFP_KERNEL); | ||
| 1027 | if (!ioc) { | ||
| 1028 | status = -ENOMEM; | ||
| 1029 | goto cleanup1; | ||
| 1030 | } | ||
| 1031 | if (copy_from_user(ioc, argp, sizeof(*ioc))) { | ||
| 1032 | status = -EFAULT; | ||
| 1033 | goto cleanup1; | ||
| 1034 | } | ||
| 1035 | if ((ioc->buf_size < 1) && | ||
| 1036 | (ioc->Request.Type.Direction != XFER_NONE)) { | ||
| 985 | status = -EINVAL; | 1037 | status = -EINVAL; |
| 986 | goto cleanup1; | 1038 | goto cleanup1; |
| 987 | } | 1039 | } |
| 988 | /* Check kmalloc limits using all SGs */ | 1040 | /* Check kmalloc limits using all SGs */ |
| 989 | if (ioc->malloc_size > MAX_KMALLOC_SIZE) { | 1041 | if (ioc->malloc_size > MAX_KMALLOC_SIZE) { |
| 990 | status = -EINVAL; | 1042 | status = -EINVAL; |
| 991 | goto cleanup1; | 1043 | goto cleanup1; |
| 992 | } | 1044 | } |
| 993 | if (ioc->buf_size > ioc->malloc_size * MAXSGENTRIES) { | 1045 | if (ioc->buf_size > ioc->malloc_size * MAXSGENTRIES) { |
| 994 | status = -EINVAL; | 1046 | status = -EINVAL; |
| 995 | goto cleanup1; | 1047 | goto cleanup1; |
| 996 | } | 1048 | } |
| 997 | buff = kzalloc(MAXSGENTRIES * sizeof(char *), GFP_KERNEL); | 1049 | buff = |
| 998 | if (!buff) { | 1050 | kzalloc(MAXSGENTRIES * sizeof(char *), GFP_KERNEL); |
| 999 | status = -ENOMEM; | 1051 | if (!buff) { |
| 1000 | goto cleanup1; | ||
| 1001 | } | ||
| 1002 | buff_size = (int *) kmalloc(MAXSGENTRIES * sizeof(int), | ||
| 1003 | GFP_KERNEL); | ||
| 1004 | if (!buff_size) { | ||
| 1005 | status = -ENOMEM; | ||
| 1006 | goto cleanup1; | ||
| 1007 | } | ||
| 1008 | left = ioc->buf_size; | ||
| 1009 | data_ptr = ioc->buf; | ||
| 1010 | while (left) { | ||
| 1011 | sz = (left > ioc->malloc_size) ? ioc->malloc_size : left; | ||
| 1012 | buff_size[sg_used] = sz; | ||
| 1013 | buff[sg_used] = kmalloc(sz, GFP_KERNEL); | ||
| 1014 | if (buff[sg_used] == NULL) { | ||
| 1015 | status = -ENOMEM; | 1052 | status = -ENOMEM; |
| 1016 | goto cleanup1; | 1053 | goto cleanup1; |
| 1017 | } | 1054 | } |
| 1018 | if (ioc->Request.Type.Direction == XFER_WRITE) { | 1055 | buff_size = (int *)kmalloc(MAXSGENTRIES * sizeof(int), |
| 1019 | if (copy_from_user(buff[sg_used], data_ptr, sz)) { | 1056 | GFP_KERNEL); |
| 1057 | if (!buff_size) { | ||
| 1058 | status = -ENOMEM; | ||
| 1059 | goto cleanup1; | ||
| 1060 | } | ||
| 1061 | left = ioc->buf_size; | ||
| 1062 | data_ptr = ioc->buf; | ||
| 1063 | while (left) { | ||
| 1064 | sz = (left > | ||
| 1065 | ioc->malloc_size) ? ioc-> | ||
| 1066 | malloc_size : left; | ||
| 1067 | buff_size[sg_used] = sz; | ||
| 1068 | buff[sg_used] = kmalloc(sz, GFP_KERNEL); | ||
| 1069 | if (buff[sg_used] == NULL) { | ||
| 1020 | status = -ENOMEM; | 1070 | status = -ENOMEM; |
| 1021 | goto cleanup1; | 1071 | goto cleanup1; |
| 1022 | } | 1072 | } |
| 1073 | if (ioc->Request.Type.Direction == XFER_WRITE) { | ||
| 1074 | if (copy_from_user | ||
| 1075 | (buff[sg_used], data_ptr, sz)) { | ||
| 1076 | status = -ENOMEM; | ||
| 1077 | goto cleanup1; | ||
| 1078 | } | ||
| 1079 | } else { | ||
| 1080 | memset(buff[sg_used], 0, sz); | ||
| 1081 | } | ||
| 1082 | left -= sz; | ||
| 1083 | data_ptr += sz; | ||
| 1084 | sg_used++; | ||
| 1085 | } | ||
| 1086 | if ((c = cmd_alloc(host, 0)) == NULL) { | ||
| 1087 | status = -ENOMEM; | ||
| 1088 | goto cleanup1; | ||
| 1089 | } | ||
| 1090 | c->cmd_type = CMD_IOCTL_PEND; | ||
| 1091 | c->Header.ReplyQueue = 0; | ||
| 1092 | |||
| 1093 | if (ioc->buf_size > 0) { | ||
| 1094 | c->Header.SGList = sg_used; | ||
| 1095 | c->Header.SGTotal = sg_used; | ||
| 1023 | } else { | 1096 | } else { |
| 1024 | memset(buff[sg_used], 0, sz); | 1097 | c->Header.SGList = 0; |
| 1098 | c->Header.SGTotal = 0; | ||
| 1025 | } | 1099 | } |
| 1026 | left -= sz; | 1100 | c->Header.LUN = ioc->LUN_info; |
| 1027 | data_ptr += sz; | 1101 | c->Header.Tag.lower = c->busaddr; |
| 1028 | sg_used++; | 1102 | |
| 1029 | } | 1103 | c->Request = ioc->Request; |
| 1030 | if ((c = cmd_alloc(host , 0)) == NULL) { | 1104 | if (ioc->buf_size > 0) { |
| 1031 | status = -ENOMEM; | 1105 | int i; |
| 1032 | goto cleanup1; | 1106 | for (i = 0; i < sg_used; i++) { |
| 1033 | } | 1107 | temp64.val = |
| 1034 | c->cmd_type = CMD_IOCTL_PEND; | 1108 | pci_map_single(host->pdev, buff[i], |
| 1035 | c->Header.ReplyQueue = 0; | 1109 | buff_size[i], |
| 1036 | 1110 | PCI_DMA_BIDIRECTIONAL); | |
| 1037 | if( ioc->buf_size > 0) { | 1111 | c->SG[i].Addr.lower = |
| 1038 | c->Header.SGList = sg_used; | 1112 | temp64.val32.lower; |
| 1039 | c->Header.SGTotal= sg_used; | 1113 | c->SG[i].Addr.upper = |
| 1040 | } else { | 1114 | temp64.val32.upper; |
| 1041 | c->Header.SGList = 0; | 1115 | c->SG[i].Len = buff_size[i]; |
| 1042 | c->Header.SGTotal= 0; | 1116 | c->SG[i].Ext = 0; /* we are not chaining */ |
| 1043 | } | 1117 | } |
| 1044 | c->Header.LUN = ioc->LUN_info; | 1118 | } |
| 1045 | c->Header.Tag.lower = c->busaddr; | 1119 | c->waiting = &wait; |
| 1046 | 1120 | /* Put the request on the tail of the request queue */ | |
| 1047 | c->Request = ioc->Request; | 1121 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); |
| 1048 | if (ioc->buf_size > 0 ) { | 1122 | addQ(&host->reqQ, c); |
| 1049 | int i; | 1123 | host->Qdepth++; |
| 1050 | for(i=0; i<sg_used; i++) { | 1124 | start_io(host); |
| 1051 | temp64.val = pci_map_single( host->pdev, buff[i], | 1125 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); |
| 1052 | buff_size[i], | 1126 | wait_for_completion(&wait); |
| 1127 | /* unlock the buffers from DMA */ | ||
| 1128 | for (i = 0; i < sg_used; i++) { | ||
| 1129 | temp64.val32.lower = c->SG[i].Addr.lower; | ||
| 1130 | temp64.val32.upper = c->SG[i].Addr.upper; | ||
| 1131 | pci_unmap_single(host->pdev, | ||
| 1132 | (dma_addr_t) temp64.val, buff_size[i], | ||
| 1053 | PCI_DMA_BIDIRECTIONAL); | 1133 | PCI_DMA_BIDIRECTIONAL); |
| 1054 | c->SG[i].Addr.lower = temp64.val32.lower; | ||
| 1055 | c->SG[i].Addr.upper = temp64.val32.upper; | ||
| 1056 | c->SG[i].Len = buff_size[i]; | ||
| 1057 | c->SG[i].Ext = 0; /* we are not chaining */ | ||
| 1058 | } | 1134 | } |
| 1059 | } | 1135 | /* Copy the error information out */ |
| 1060 | c->waiting = &wait; | 1136 | ioc->error_info = *(c->err_info); |
| 1061 | /* Put the request on the tail of the request queue */ | 1137 | if (copy_to_user(argp, ioc, sizeof(*ioc))) { |
| 1062 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | 1138 | cmd_free(host, c, 0); |
| 1063 | addQ(&host->reqQ, c); | 1139 | status = -EFAULT; |
| 1064 | host->Qdepth++; | 1140 | goto cleanup1; |
| 1065 | start_io(host); | 1141 | } |
| 1066 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | 1142 | if (ioc->Request.Type.Direction == XFER_READ) { |
| 1067 | wait_for_completion(&wait); | 1143 | /* Copy the data out of the buffer we created */ |
| 1068 | /* unlock the buffers from DMA */ | 1144 | BYTE __user *ptr = ioc->buf; |
| 1069 | for(i=0; i<sg_used; i++) { | 1145 | for (i = 0; i < sg_used; i++) { |
| 1070 | temp64.val32.lower = c->SG[i].Addr.lower; | 1146 | if (copy_to_user |
| 1071 | temp64.val32.upper = c->SG[i].Addr.upper; | 1147 | (ptr, buff[i], buff_size[i])) { |
| 1072 | pci_unmap_single( host->pdev, (dma_addr_t) temp64.val, | 1148 | cmd_free(host, c, 0); |
| 1073 | buff_size[i], PCI_DMA_BIDIRECTIONAL); | 1149 | status = -EFAULT; |
| 1074 | } | 1150 | goto cleanup1; |
| 1075 | /* Copy the error information out */ | 1151 | } |
| 1076 | ioc->error_info = *(c->err_info); | 1152 | ptr += buff_size[i]; |
| 1077 | if (copy_to_user(argp, ioc, sizeof(*ioc))) { | ||
| 1078 | cmd_free(host, c, 0); | ||
| 1079 | status = -EFAULT; | ||
| 1080 | goto cleanup1; | ||
| 1081 | } | ||
| 1082 | if (ioc->Request.Type.Direction == XFER_READ) { | ||
| 1083 | /* Copy the data out of the buffer we created */ | ||
| 1084 | BYTE __user *ptr = ioc->buf; | ||
| 1085 | for(i=0; i< sg_used; i++) { | ||
| 1086 | if (copy_to_user(ptr, buff[i], buff_size[i])) { | ||
| 1087 | cmd_free(host, c, 0); | ||
| 1088 | status = -EFAULT; | ||
| 1089 | goto cleanup1; | ||
| 1090 | } | 1153 | } |
| 1091 | ptr += buff_size[i]; | ||
| 1092 | } | 1154 | } |
| 1155 | cmd_free(host, c, 0); | ||
| 1156 | status = 0; | ||
| 1157 | cleanup1: | ||
| 1158 | if (buff) { | ||
| 1159 | for (i = 0; i < sg_used; i++) | ||
| 1160 | kfree(buff[i]); | ||
| 1161 | kfree(buff); | ||
| 1162 | } | ||
| 1163 | kfree(buff_size); | ||
| 1164 | kfree(ioc); | ||
| 1165 | return status; | ||
| 1093 | } | 1166 | } |
| 1094 | cmd_free(host, c, 0); | ||
| 1095 | status = 0; | ||
| 1096 | cleanup1: | ||
| 1097 | if (buff) { | ||
| 1098 | for(i=0; i<sg_used; i++) | ||
| 1099 | kfree(buff[i]); | ||
| 1100 | kfree(buff); | ||
| 1101 | } | ||
| 1102 | kfree(buff_size); | ||
| 1103 | kfree(ioc); | ||
| 1104 | return status; | ||
| 1105 | } | ||
| 1106 | default: | 1167 | default: |
| 1107 | return -ENOTTY; | 1168 | return -ENOTTY; |
| 1108 | } | 1169 | } |
| 1109 | |||
| 1110 | } | 1170 | } |
| 1111 | 1171 | ||
| 1112 | /* | 1172 | /* |
| @@ -1125,17 +1185,17 @@ static int revalidate_allvol(ctlr_info_t *host) | |||
| 1125 | int ctlr = host->ctlr, i; | 1185 | int ctlr = host->ctlr, i; |
| 1126 | unsigned long flags; | 1186 | unsigned long flags; |
| 1127 | 1187 | ||
| 1128 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | 1188 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); |
| 1129 | if (host->usage_count > 1) { | 1189 | if (host->usage_count > 1) { |
| 1130 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | 1190 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); |
| 1131 | printk(KERN_WARNING "cciss: Device busy for volume" | 1191 | printk(KERN_WARNING "cciss: Device busy for volume" |
| 1132 | " revalidation (usage=%d)\n", host->usage_count); | 1192 | " revalidation (usage=%d)\n", host->usage_count); |
| 1133 | return -EBUSY; | 1193 | return -EBUSY; |
| 1134 | } | 1194 | } |
| 1135 | host->usage_count++; | 1195 | host->usage_count++; |
| 1136 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | 1196 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); |
| 1137 | 1197 | ||
| 1138 | for(i=0; i< NWD; i++) { | 1198 | for (i = 0; i < NWD; i++) { |
| 1139 | struct gendisk *disk = host->gendisk[i]; | 1199 | struct gendisk *disk = host->gendisk[i]; |
| 1140 | if (disk) { | 1200 | if (disk) { |
| 1141 | request_queue_t *q = disk->queue; | 1201 | request_queue_t *q = disk->queue; |
| @@ -1147,22 +1207,22 @@ static int revalidate_allvol(ctlr_info_t *host) | |||
| 1147 | } | 1207 | } |
| 1148 | } | 1208 | } |
| 1149 | 1209 | ||
| 1150 | /* | 1210 | /* |
| 1151 | * Set the partition and block size structures for all volumes | 1211 | * Set the partition and block size structures for all volumes |
| 1152 | * on this controller to zero. We will reread all of this data | 1212 | * on this controller to zero. We will reread all of this data |
| 1153 | */ | 1213 | */ |
| 1154 | memset(host->drv, 0, sizeof(drive_info_struct) | 1214 | memset(host->drv, 0, sizeof(drive_info_struct) |
| 1155 | * CISS_MAX_LUN); | 1215 | * CISS_MAX_LUN); |
| 1156 | /* | 1216 | /* |
| 1157 | * Tell the array controller not to give us any interrupts while | 1217 | * Tell the array controller not to give us any interrupts while |
| 1158 | * we check the new geometry. Then turn interrupts back on when | 1218 | * we check the new geometry. Then turn interrupts back on when |
| 1159 | * we're done. | 1219 | * we're done. |
| 1160 | */ | 1220 | */ |
| 1161 | host->access.set_intr_mask(host, CCISS_INTR_OFF); | 1221 | host->access.set_intr_mask(host, CCISS_INTR_OFF); |
| 1162 | cciss_getgeometry(ctlr); | 1222 | cciss_getgeometry(ctlr); |
| 1163 | host->access.set_intr_mask(host, CCISS_INTR_ON); | 1223 | host->access.set_intr_mask(host, CCISS_INTR_ON); |
| 1164 | 1224 | ||
| 1165 | /* Loop through each real device */ | 1225 | /* Loop through each real device */ |
| 1166 | for (i = 0; i < NWD; i++) { | 1226 | for (i = 0; i < NWD; i++) { |
| 1167 | struct gendisk *disk = host->gendisk[i]; | 1227 | struct gendisk *disk = host->gendisk[i]; |
| 1168 | drive_info_struct *drv = &(host->drv[i]); | 1228 | drive_info_struct *drv = &(host->drv[i]); |
| @@ -1174,8 +1234,8 @@ static int revalidate_allvol(ctlr_info_t *host) | |||
| 1174 | set_capacity(disk, drv->nr_blocks); | 1234 | set_capacity(disk, drv->nr_blocks); |
| 1175 | add_disk(disk); | 1235 | add_disk(disk); |
| 1176 | } | 1236 | } |
| 1177 | host->usage_count--; | 1237 | host->usage_count--; |
| 1178 | return 0; | 1238 | return 0; |
| 1179 | } | 1239 | } |
| 1180 | 1240 | ||
| 1181 | static inline void complete_buffers(struct bio *bio, int status) | 1241 | static inline void complete_buffers(struct bio *bio, int status) |
| @@ -1189,7 +1249,6 @@ static inline void complete_buffers(struct bio *bio, int status) | |||
| 1189 | bio_endio(bio, nr_sectors << 9, status ? 0 : -EIO); | 1249 | bio_endio(bio, nr_sectors << 9, status ? 0 : -EIO); |
| 1190 | bio = xbh; | 1250 | bio = xbh; |
| 1191 | } | 1251 | } |
| 1192 | |||
| 1193 | } | 1252 | } |
| 1194 | 1253 | ||
| 1195 | static void cciss_softirq_done(struct request *rq) | 1254 | static void cciss_softirq_done(struct request *rq) |
| @@ -1207,7 +1266,7 @@ static void cciss_softirq_done(struct request *rq) | |||
| 1207 | 1266 | ||
| 1208 | /* command did not need to be retried */ | 1267 | /* command did not need to be retried */ |
| 1209 | /* unmap the DMA mapping for all the scatter gather elements */ | 1268 | /* unmap the DMA mapping for all the scatter gather elements */ |
| 1210 | for(i=0; i<cmd->Header.SGList; i++) { | 1269 | for (i = 0; i < cmd->Header.SGList; i++) { |
| 1211 | temp64.val32.lower = cmd->SG[i].Addr.lower; | 1270 | temp64.val32.lower = cmd->SG[i].Addr.lower; |
| 1212 | temp64.val32.upper = cmd->SG[i].Addr.upper; | 1271 | temp64.val32.upper = cmd->SG[i].Addr.upper; |
| 1213 | pci_unmap_page(h->pdev, temp64.val, cmd->SG[i].Len, ddir); | 1272 | pci_unmap_page(h->pdev, temp64.val, cmd->SG[i].Len, ddir); |
| @@ -1217,12 +1276,12 @@ static void cciss_softirq_done(struct request *rq) | |||
| 1217 | 1276 | ||
| 1218 | #ifdef CCISS_DEBUG | 1277 | #ifdef CCISS_DEBUG |
| 1219 | printk("Done with %p\n", rq); | 1278 | printk("Done with %p\n", rq); |
| 1220 | #endif /* CCISS_DEBUG */ | 1279 | #endif /* CCISS_DEBUG */ |
| 1221 | 1280 | ||
| 1222 | add_disk_randomness(rq->rq_disk); | 1281 | add_disk_randomness(rq->rq_disk); |
| 1223 | spin_lock_irqsave(&h->lock, flags); | 1282 | spin_lock_irqsave(&h->lock, flags); |
| 1224 | end_that_request_last(rq, rq->errors); | 1283 | end_that_request_last(rq, rq->errors); |
| 1225 | cmd_free(h, cmd,1); | 1284 | cmd_free(h, cmd, 1); |
| 1226 | spin_unlock_irqrestore(&h->lock, flags); | 1285 | spin_unlock_irqrestore(&h->lock, flags); |
| 1227 | } | 1286 | } |
| 1228 | 1287 | ||
| @@ -1233,9 +1292,9 @@ static void cciss_softirq_done(struct request *rq) | |||
| 1233 | * will always be left registered with the kernel since it is also the | 1292 | * will always be left registered with the kernel since it is also the |
| 1234 | * controller node. Any changes to disk 0 will show up on the next | 1293 | * controller node. Any changes to disk 0 will show up on the next |
| 1235 | * reboot. | 1294 | * reboot. |
| 1236 | */ | 1295 | */ |
| 1237 | static void cciss_update_drive_info(int ctlr, int drv_index) | 1296 | static void cciss_update_drive_info(int ctlr, int drv_index) |
| 1238 | { | 1297 | { |
| 1239 | ctlr_info_t *h = hba[ctlr]; | 1298 | ctlr_info_t *h = hba[ctlr]; |
| 1240 | struct gendisk *disk; | 1299 | struct gendisk *disk; |
| 1241 | ReadCapdata_struct *size_buff = NULL; | 1300 | ReadCapdata_struct *size_buff = NULL; |
| @@ -1245,13 +1304,13 @@ static void cciss_update_drive_info(int ctlr, int drv_index) | |||
| 1245 | unsigned long flags = 0; | 1304 | unsigned long flags = 0; |
| 1246 | int ret = 0; | 1305 | int ret = 0; |
| 1247 | 1306 | ||
| 1248 | /* if the disk already exists then deregister it before proceeding*/ | 1307 | /* if the disk already exists then deregister it before proceeding */ |
| 1249 | if (h->drv[drv_index].raid_level != -1){ | 1308 | if (h->drv[drv_index].raid_level != -1) { |
| 1250 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | 1309 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); |
| 1251 | h->drv[drv_index].busy_configuring = 1; | 1310 | h->drv[drv_index].busy_configuring = 1; |
| 1252 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 1311 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); |
| 1253 | ret = deregister_disk(h->gendisk[drv_index], | 1312 | ret = deregister_disk(h->gendisk[drv_index], |
| 1254 | &h->drv[drv_index], 0); | 1313 | &h->drv[drv_index], 0); |
| 1255 | h->drv[drv_index].busy_configuring = 0; | 1314 | h->drv[drv_index].busy_configuring = 0; |
| 1256 | } | 1315 | } |
| 1257 | 1316 | ||
| @@ -1259,27 +1318,25 @@ static void cciss_update_drive_info(int ctlr, int drv_index) | |||
| 1259 | if (ret) | 1318 | if (ret) |
| 1260 | return; | 1319 | return; |
| 1261 | 1320 | ||
| 1262 | |||
| 1263 | /* Get information about the disk and modify the driver structure */ | 1321 | /* Get information about the disk and modify the driver structure */ |
| 1264 | size_buff = kmalloc(sizeof( ReadCapdata_struct), GFP_KERNEL); | 1322 | size_buff = kmalloc(sizeof(ReadCapdata_struct), GFP_KERNEL); |
| 1265 | if (size_buff == NULL) | 1323 | if (size_buff == NULL) |
| 1266 | goto mem_msg; | 1324 | goto mem_msg; |
| 1267 | inq_buff = kmalloc(sizeof( InquiryData_struct), GFP_KERNEL); | 1325 | inq_buff = kmalloc(sizeof(InquiryData_struct), GFP_KERNEL); |
| 1268 | if (inq_buff == NULL) | 1326 | if (inq_buff == NULL) |
| 1269 | goto mem_msg; | 1327 | goto mem_msg; |
| 1270 | 1328 | ||
| 1271 | cciss_read_capacity(ctlr, drv_index, size_buff, 1, | 1329 | cciss_read_capacity(ctlr, drv_index, size_buff, 1, |
| 1272 | &total_size, &block_size); | 1330 | &total_size, &block_size); |
| 1273 | cciss_geometry_inquiry(ctlr, drv_index, 1, total_size, block_size, | 1331 | cciss_geometry_inquiry(ctlr, drv_index, 1, total_size, block_size, |
| 1274 | inq_buff, &h->drv[drv_index]); | 1332 | inq_buff, &h->drv[drv_index]); |
| 1275 | 1333 | ||
| 1276 | ++h->num_luns; | 1334 | ++h->num_luns; |
| 1277 | disk = h->gendisk[drv_index]; | 1335 | disk = h->gendisk[drv_index]; |
| 1278 | set_capacity(disk, h->drv[drv_index].nr_blocks); | 1336 | set_capacity(disk, h->drv[drv_index].nr_blocks); |
| 1279 | 1337 | ||
| 1280 | |||
| 1281 | /* if it's the controller it's already added */ | 1338 | /* if it's the controller it's already added */ |
| 1282 | if (drv_index){ | 1339 | if (drv_index) { |
| 1283 | disk->queue = blk_init_queue(do_cciss_request, &h->lock); | 1340 | disk->queue = blk_init_queue(do_cciss_request, &h->lock); |
| 1284 | 1341 | ||
| 1285 | /* Set up queue information */ | 1342 | /* Set up queue information */ |
| @@ -1299,17 +1356,17 @@ static void cciss_update_drive_info(int ctlr, int drv_index) | |||
| 1299 | disk->queue->queuedata = hba[ctlr]; | 1356 | disk->queue->queuedata = hba[ctlr]; |
| 1300 | 1357 | ||
| 1301 | blk_queue_hardsect_size(disk->queue, | 1358 | blk_queue_hardsect_size(disk->queue, |
| 1302 | hba[ctlr]->drv[drv_index].block_size); | 1359 | hba[ctlr]->drv[drv_index].block_size); |
| 1303 | 1360 | ||
| 1304 | h->drv[drv_index].queue = disk->queue; | 1361 | h->drv[drv_index].queue = disk->queue; |
| 1305 | add_disk(disk); | 1362 | add_disk(disk); |
| 1306 | } | 1363 | } |
| 1307 | 1364 | ||
| 1308 | freeret: | 1365 | freeret: |
| 1309 | kfree(size_buff); | 1366 | kfree(size_buff); |
| 1310 | kfree(inq_buff); | 1367 | kfree(inq_buff); |
| 1311 | return; | 1368 | return; |
| 1312 | mem_msg: | 1369 | mem_msg: |
| 1313 | printk(KERN_ERR "cciss: out of memory\n"); | 1370 | printk(KERN_ERR "cciss: out of memory\n"); |
| 1314 | goto freeret; | 1371 | goto freeret; |
| 1315 | } | 1372 | } |
| @@ -1319,13 +1376,13 @@ mem_msg: | |||
| 1319 | * where new drives will be added. If the index to be returned is greater | 1376 | * where new drives will be added. If the index to be returned is greater |
| 1320 | * than the highest_lun index for the controller then highest_lun is set | 1377 | * than the highest_lun index for the controller then highest_lun is set |
| 1321 | * to this new index. If there are no available indexes then -1 is returned. | 1378 | * to this new index. If there are no available indexes then -1 is returned. |
| 1322 | */ | 1379 | */ |
| 1323 | static int cciss_find_free_drive_index(int ctlr) | 1380 | static int cciss_find_free_drive_index(int ctlr) |
| 1324 | { | 1381 | { |
| 1325 | int i; | 1382 | int i; |
| 1326 | 1383 | ||
| 1327 | for (i=0; i < CISS_MAX_LUN; i++){ | 1384 | for (i = 0; i < CISS_MAX_LUN; i++) { |
| 1328 | if (hba[ctlr]->drv[i].raid_level == -1){ | 1385 | if (hba[ctlr]->drv[i].raid_level == -1) { |
| 1329 | if (i > hba[ctlr]->highest_lun) | 1386 | if (i > hba[ctlr]->highest_lun) |
| 1330 | hba[ctlr]->highest_lun = i; | 1387 | hba[ctlr]->highest_lun = i; |
| 1331 | return i; | 1388 | return i; |
| @@ -1343,7 +1400,7 @@ static int cciss_find_free_drive_index(int ctlr) | |||
| 1343 | * h = The controller to perform the operations on | 1400 | * h = The controller to perform the operations on |
| 1344 | * del_disk = The disk to remove if specified. If the value given | 1401 | * del_disk = The disk to remove if specified. If the value given |
| 1345 | * is NULL then no disk is removed. | 1402 | * is NULL then no disk is removed. |
| 1346 | */ | 1403 | */ |
| 1347 | static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk) | 1404 | static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk) |
| 1348 | { | 1405 | { |
| 1349 | int ctlr = h->ctlr; | 1406 | int ctlr = h->ctlr; |
| @@ -1360,12 +1417,12 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk) | |||
| 1360 | 1417 | ||
| 1361 | /* Set busy_configuring flag for this operation */ | 1418 | /* Set busy_configuring flag for this operation */ |
| 1362 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | 1419 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); |
| 1363 | if (h->num_luns >= CISS_MAX_LUN){ | 1420 | if (h->num_luns >= CISS_MAX_LUN) { |
| 1364 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 1421 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); |
| 1365 | return -EINVAL; | 1422 | return -EINVAL; |
| 1366 | } | 1423 | } |
| 1367 | 1424 | ||
| 1368 | if (h->busy_configuring){ | 1425 | if (h->busy_configuring) { |
| 1369 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 1426 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); |
| 1370 | return -EBUSY; | 1427 | return -EBUSY; |
| 1371 | } | 1428 | } |
| @@ -1375,7 +1432,7 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk) | |||
| 1375 | * and update the logical drive table. If it is not NULL then | 1432 | * and update the logical drive table. If it is not NULL then |
| 1376 | * we will check if the disk is in use or not. | 1433 | * we will check if the disk is in use or not. |
| 1377 | */ | 1434 | */ |
| 1378 | if (del_disk != NULL){ | 1435 | if (del_disk != NULL) { |
| 1379 | drv = get_drv(del_disk); | 1436 | drv = get_drv(del_disk); |
| 1380 | drv->busy_configuring = 1; | 1437 | drv->busy_configuring = 1; |
| 1381 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 1438 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); |
| @@ -1393,61 +1450,67 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk) | |||
| 1393 | goto mem_msg; | 1450 | goto mem_msg; |
| 1394 | 1451 | ||
| 1395 | return_code = sendcmd_withirq(CISS_REPORT_LOG, ctlr, ld_buff, | 1452 | return_code = sendcmd_withirq(CISS_REPORT_LOG, ctlr, ld_buff, |
| 1396 | sizeof(ReportLunData_struct), 0, 0, 0, | 1453 | sizeof(ReportLunData_struct), 0, |
| 1397 | TYPE_CMD); | 1454 | 0, 0, TYPE_CMD); |
| 1398 | 1455 | ||
| 1399 | if (return_code == IO_OK){ | 1456 | if (return_code == IO_OK) { |
| 1400 | listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[0])) << 24; | 1457 | listlength |= |
| 1401 | listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[1])) << 16; | 1458 | (0xff & (unsigned int)(ld_buff->LUNListLength[0])) |
| 1402 | listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[2])) << 8; | 1459 | << 24; |
| 1403 | listlength |= 0xff & (unsigned int)(ld_buff->LUNListLength[3]); | 1460 | listlength |= |
| 1404 | } else{ /* reading number of logical volumes failed */ | 1461 | (0xff & (unsigned int)(ld_buff->LUNListLength[1])) |
| 1462 | << 16; | ||
| 1463 | listlength |= | ||
| 1464 | (0xff & (unsigned int)(ld_buff->LUNListLength[2])) | ||
| 1465 | << 8; | ||
| 1466 | listlength |= | ||
| 1467 | 0xff & (unsigned int)(ld_buff->LUNListLength[3]); | ||
| 1468 | } else { /* reading number of logical volumes failed */ | ||
| 1405 | printk(KERN_WARNING "cciss: report logical volume" | 1469 | printk(KERN_WARNING "cciss: report logical volume" |
| 1406 | " command failed\n"); | 1470 | " command failed\n"); |
| 1407 | listlength = 0; | 1471 | listlength = 0; |
| 1408 | goto freeret; | 1472 | goto freeret; |
| 1409 | } | 1473 | } |
| 1410 | 1474 | ||
| 1411 | num_luns = listlength / 8; /* 8 bytes per entry */ | 1475 | num_luns = listlength / 8; /* 8 bytes per entry */ |
| 1412 | if (num_luns > CISS_MAX_LUN){ | 1476 | if (num_luns > CISS_MAX_LUN) { |
| 1413 | num_luns = CISS_MAX_LUN; | 1477 | num_luns = CISS_MAX_LUN; |
| 1414 | printk(KERN_WARNING "cciss: more luns configured" | 1478 | printk(KERN_WARNING "cciss: more luns configured" |
| 1415 | " on controller than can be handled by" | 1479 | " on controller than can be handled by" |
| 1416 | " this driver.\n"); | 1480 | " this driver.\n"); |
| 1417 | } | 1481 | } |
| 1418 | 1482 | ||
| 1419 | /* Compare controller drive array to drivers drive array. | 1483 | /* Compare controller drive array to drivers drive array. |
| 1420 | * Check for updates in the drive information and any new drives | 1484 | * Check for updates in the drive information and any new drives |
| 1421 | * on the controller. | 1485 | * on the controller. |
| 1422 | */ | 1486 | */ |
| 1423 | for (i=0; i < num_luns; i++){ | 1487 | for (i = 0; i < num_luns; i++) { |
| 1424 | int j; | 1488 | int j; |
| 1425 | 1489 | ||
| 1426 | drv_found = 0; | 1490 | drv_found = 0; |
| 1427 | 1491 | ||
| 1428 | lunid = (0xff & | 1492 | lunid = (0xff & |
| 1429 | (unsigned int)(ld_buff->LUN[i][3])) << 24; | 1493 | (unsigned int)(ld_buff->LUN[i][3])) << 24; |
| 1430 | lunid |= (0xff & | 1494 | lunid |= (0xff & |
| 1431 | (unsigned int)(ld_buff->LUN[i][2])) << 16; | 1495 | (unsigned int)(ld_buff->LUN[i][2])) << 16; |
| 1432 | lunid |= (0xff & | 1496 | lunid |= (0xff & |
| 1433 | (unsigned int)(ld_buff->LUN[i][1])) << 8; | 1497 | (unsigned int)(ld_buff->LUN[i][1])) << 8; |
| 1434 | lunid |= 0xff & | 1498 | lunid |= 0xff & (unsigned int)(ld_buff->LUN[i][0]); |
| 1435 | (unsigned int)(ld_buff->LUN[i][0]); | ||
| 1436 | 1499 | ||
| 1437 | /* Find if the LUN is already in the drive array | 1500 | /* Find if the LUN is already in the drive array |
| 1438 | * of the controller. If so then update its info | 1501 | * of the controller. If so then update its info |
| 1439 | * if not is use. If it does not exist then find | 1502 | * if not is use. If it does not exist then find |
| 1440 | * the first free index and add it. | 1503 | * the first free index and add it. |
| 1441 | */ | 1504 | */ |
| 1442 | for (j=0; j <= h->highest_lun; j++){ | 1505 | for (j = 0; j <= h->highest_lun; j++) { |
| 1443 | if (h->drv[j].LunID == lunid){ | 1506 | if (h->drv[j].LunID == lunid) { |
| 1444 | drv_index = j; | 1507 | drv_index = j; |
| 1445 | drv_found = 1; | 1508 | drv_found = 1; |
| 1446 | } | 1509 | } |
| 1447 | } | 1510 | } |
| 1448 | 1511 | ||
| 1449 | /* check if the drive was found already in the array */ | 1512 | /* check if the drive was found already in the array */ |
| 1450 | if (!drv_found){ | 1513 | if (!drv_found) { |
| 1451 | drv_index = cciss_find_free_drive_index(ctlr); | 1514 | drv_index = cciss_find_free_drive_index(ctlr); |
| 1452 | if (drv_index == -1) | 1515 | if (drv_index == -1) |
| 1453 | goto freeret; | 1516 | goto freeret; |
| @@ -1455,18 +1518,18 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk) | |||
| 1455 | } | 1518 | } |
| 1456 | h->drv[drv_index].LunID = lunid; | 1519 | h->drv[drv_index].LunID = lunid; |
| 1457 | cciss_update_drive_info(ctlr, drv_index); | 1520 | cciss_update_drive_info(ctlr, drv_index); |
| 1458 | } /* end for */ | 1521 | } /* end for */ |
| 1459 | } /* end else */ | 1522 | } /* end else */ |
| 1460 | 1523 | ||
| 1461 | freeret: | 1524 | freeret: |
| 1462 | kfree(ld_buff); | 1525 | kfree(ld_buff); |
| 1463 | h->busy_configuring = 0; | 1526 | h->busy_configuring = 0; |
| 1464 | /* We return -1 here to tell the ACU that we have registered/updated | 1527 | /* We return -1 here to tell the ACU that we have registered/updated |
| 1465 | * all of the drives that we can and to keep it from calling us | 1528 | * all of the drives that we can and to keep it from calling us |
| 1466 | * additional times. | 1529 | * additional times. |
| 1467 | */ | 1530 | */ |
| 1468 | return -1; | 1531 | return -1; |
| 1469 | mem_msg: | 1532 | mem_msg: |
| 1470 | printk(KERN_ERR "cciss: out of memory\n"); | 1533 | printk(KERN_ERR "cciss: out of memory\n"); |
| 1471 | goto freeret; | 1534 | goto freeret; |
| 1472 | } | 1535 | } |
| @@ -1495,19 +1558,17 @@ static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, | |||
| 1495 | return -EPERM; | 1558 | return -EPERM; |
| 1496 | 1559 | ||
| 1497 | /* make sure logical volume is NOT is use */ | 1560 | /* make sure logical volume is NOT is use */ |
| 1498 | if(clear_all || (h->gendisk[0] == disk)) { | 1561 | if (clear_all || (h->gendisk[0] == disk)) { |
| 1499 | if (drv->usage_count > 1) | 1562 | if (drv->usage_count > 1) |
| 1500 | return -EBUSY; | 1563 | return -EBUSY; |
| 1501 | } | 1564 | } else if (drv->usage_count > 0) |
| 1502 | else | 1565 | return -EBUSY; |
| 1503 | if( drv->usage_count > 0 ) | ||
| 1504 | return -EBUSY; | ||
| 1505 | 1566 | ||
| 1506 | /* invalidate the devices and deregister the disk. If it is disk | 1567 | /* invalidate the devices and deregister the disk. If it is disk |
| 1507 | * zero do not deregister it but just zero out it's values. This | 1568 | * zero do not deregister it but just zero out it's values. This |
| 1508 | * allows us to delete disk zero but keep the controller registered. | 1569 | * allows us to delete disk zero but keep the controller registered. |
| 1509 | */ | 1570 | */ |
| 1510 | if (h->gendisk[0] != disk){ | 1571 | if (h->gendisk[0] != disk) { |
| 1511 | if (disk) { | 1572 | if (disk) { |
| 1512 | request_queue_t *q = disk->queue; | 1573 | request_queue_t *q = disk->queue; |
| 1513 | if (disk->flags & GENHD_FL_UP) | 1574 | if (disk->flags & GENHD_FL_UP) |
| @@ -1529,91 +1590,90 @@ static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, | |||
| 1529 | drv->raid_level = -1; /* This can be used as a flag variable to | 1590 | drv->raid_level = -1; /* This can be used as a flag variable to |
| 1530 | * indicate that this element of the drive | 1591 | * indicate that this element of the drive |
| 1531 | * array is free. | 1592 | * array is free. |
| 1532 | */ | 1593 | */ |
| 1533 | 1594 | ||
| 1534 | if (clear_all){ | 1595 | if (clear_all) { |
| 1535 | /* check to see if it was the last disk */ | 1596 | /* check to see if it was the last disk */ |
| 1536 | if (drv == h->drv + h->highest_lun) { | 1597 | if (drv == h->drv + h->highest_lun) { |
| 1537 | /* if so, find the new hightest lun */ | 1598 | /* if so, find the new hightest lun */ |
| 1538 | int i, newhighest =-1; | 1599 | int i, newhighest = -1; |
| 1539 | for(i=0; i<h->highest_lun; i++) { | 1600 | for (i = 0; i < h->highest_lun; i++) { |
| 1540 | /* if the disk has size > 0, it is available */ | 1601 | /* if the disk has size > 0, it is available */ |
| 1541 | if (h->drv[i].heads) | 1602 | if (h->drv[i].heads) |
| 1542 | newhighest = i; | 1603 | newhighest = i; |
| 1604 | } | ||
| 1605 | h->highest_lun = newhighest; | ||
| 1543 | } | 1606 | } |
| 1544 | h->highest_lun = newhighest; | ||
| 1545 | } | ||
| 1546 | 1607 | ||
| 1547 | drv->LunID = 0; | 1608 | drv->LunID = 0; |
| 1548 | } | 1609 | } |
| 1549 | return 0; | 1610 | return 0; |
| 1550 | } | 1611 | } |
| 1551 | 1612 | ||
| 1552 | static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, | 1613 | static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, size_t size, unsigned int use_unit_num, /* 0: address the controller, |
| 1553 | size_t size, | 1614 | 1: address logical volume log_unit, |
| 1554 | unsigned int use_unit_num, /* 0: address the controller, | 1615 | 2: periph device address is scsi3addr */ |
| 1555 | 1: address logical volume log_unit, | 1616 | unsigned int log_unit, __u8 page_code, |
| 1556 | 2: periph device address is scsi3addr */ | 1617 | unsigned char *scsi3addr, int cmd_type) |
| 1557 | unsigned int log_unit, __u8 page_code, unsigned char *scsi3addr, | ||
| 1558 | int cmd_type) | ||
| 1559 | { | 1618 | { |
| 1560 | ctlr_info_t *h= hba[ctlr]; | 1619 | ctlr_info_t *h = hba[ctlr]; |
| 1561 | u64bit buff_dma_handle; | 1620 | u64bit buff_dma_handle; |
| 1562 | int status = IO_OK; | 1621 | int status = IO_OK; |
| 1563 | 1622 | ||
| 1564 | c->cmd_type = CMD_IOCTL_PEND; | 1623 | c->cmd_type = CMD_IOCTL_PEND; |
| 1565 | c->Header.ReplyQueue = 0; | 1624 | c->Header.ReplyQueue = 0; |
| 1566 | if( buff != NULL) { | 1625 | if (buff != NULL) { |
| 1567 | c->Header.SGList = 1; | 1626 | c->Header.SGList = 1; |
| 1568 | c->Header.SGTotal= 1; | 1627 | c->Header.SGTotal = 1; |
| 1569 | } else { | 1628 | } else { |
| 1570 | c->Header.SGList = 0; | 1629 | c->Header.SGList = 0; |
| 1571 | c->Header.SGTotal= 0; | 1630 | c->Header.SGTotal = 0; |
| 1572 | } | 1631 | } |
| 1573 | c->Header.Tag.lower = c->busaddr; | 1632 | c->Header.Tag.lower = c->busaddr; |
| 1574 | 1633 | ||
| 1575 | c->Request.Type.Type = cmd_type; | 1634 | c->Request.Type.Type = cmd_type; |
| 1576 | if (cmd_type == TYPE_CMD) { | 1635 | if (cmd_type == TYPE_CMD) { |
| 1577 | switch(cmd) { | 1636 | switch (cmd) { |
| 1578 | case CISS_INQUIRY: | 1637 | case CISS_INQUIRY: |
| 1579 | /* If the logical unit number is 0 then, this is going | 1638 | /* If the logical unit number is 0 then, this is going |
| 1580 | to controller so It's a physical command | 1639 | to controller so It's a physical command |
| 1581 | mode = 0 target = 0. So we have nothing to write. | 1640 | mode = 0 target = 0. So we have nothing to write. |
| 1582 | otherwise, if use_unit_num == 1, | 1641 | otherwise, if use_unit_num == 1, |
| 1583 | mode = 1(volume set addressing) target = LUNID | 1642 | mode = 1(volume set addressing) target = LUNID |
| 1584 | otherwise, if use_unit_num == 2, | 1643 | otherwise, if use_unit_num == 2, |
| 1585 | mode = 0(periph dev addr) target = scsi3addr */ | 1644 | mode = 0(periph dev addr) target = scsi3addr */ |
| 1586 | if (use_unit_num == 1) { | 1645 | if (use_unit_num == 1) { |
| 1587 | c->Header.LUN.LogDev.VolId= | 1646 | c->Header.LUN.LogDev.VolId = |
| 1588 | h->drv[log_unit].LunID; | 1647 | h->drv[log_unit].LunID; |
| 1589 | c->Header.LUN.LogDev.Mode = 1; | 1648 | c->Header.LUN.LogDev.Mode = 1; |
| 1590 | } else if (use_unit_num == 2) { | 1649 | } else if (use_unit_num == 2) { |
| 1591 | memcpy(c->Header.LUN.LunAddrBytes,scsi3addr,8); | 1650 | memcpy(c->Header.LUN.LunAddrBytes, scsi3addr, |
| 1651 | 8); | ||
| 1592 | c->Header.LUN.LogDev.Mode = 0; | 1652 | c->Header.LUN.LogDev.Mode = 0; |
| 1593 | } | 1653 | } |
| 1594 | /* are we trying to read a vital product page */ | 1654 | /* are we trying to read a vital product page */ |
| 1595 | if(page_code != 0) { | 1655 | if (page_code != 0) { |
| 1596 | c->Request.CDB[1] = 0x01; | 1656 | c->Request.CDB[1] = 0x01; |
| 1597 | c->Request.CDB[2] = page_code; | 1657 | c->Request.CDB[2] = page_code; |
| 1598 | } | 1658 | } |
| 1599 | c->Request.CDBLen = 6; | 1659 | c->Request.CDBLen = 6; |
| 1600 | c->Request.Type.Attribute = ATTR_SIMPLE; | 1660 | c->Request.Type.Attribute = ATTR_SIMPLE; |
| 1601 | c->Request.Type.Direction = XFER_READ; | 1661 | c->Request.Type.Direction = XFER_READ; |
| 1602 | c->Request.Timeout = 0; | 1662 | c->Request.Timeout = 0; |
| 1603 | c->Request.CDB[0] = CISS_INQUIRY; | 1663 | c->Request.CDB[0] = CISS_INQUIRY; |
| 1604 | c->Request.CDB[4] = size & 0xFF; | 1664 | c->Request.CDB[4] = size & 0xFF; |
| 1605 | break; | 1665 | break; |
| 1606 | case CISS_REPORT_LOG: | 1666 | case CISS_REPORT_LOG: |
| 1607 | case CISS_REPORT_PHYS: | 1667 | case CISS_REPORT_PHYS: |
| 1608 | /* Talking to controller so It's a physical command | 1668 | /* Talking to controller so It's a physical command |
| 1609 | mode = 00 target = 0. Nothing to write. | 1669 | mode = 00 target = 0. Nothing to write. |
| 1610 | */ | 1670 | */ |
| 1611 | c->Request.CDBLen = 12; | 1671 | c->Request.CDBLen = 12; |
| 1612 | c->Request.Type.Attribute = ATTR_SIMPLE; | 1672 | c->Request.Type.Attribute = ATTR_SIMPLE; |
| 1613 | c->Request.Type.Direction = XFER_READ; | 1673 | c->Request.Type.Direction = XFER_READ; |
| 1614 | c->Request.Timeout = 0; | 1674 | c->Request.Timeout = 0; |
| 1615 | c->Request.CDB[0] = cmd; | 1675 | c->Request.CDB[0] = cmd; |
| 1616 | c->Request.CDB[6] = (size >> 24) & 0xFF; //MSB | 1676 | c->Request.CDB[6] = (size >> 24) & 0xFF; //MSB |
| 1617 | c->Request.CDB[7] = (size >> 16) & 0xFF; | 1677 | c->Request.CDB[7] = (size >> 16) & 0xFF; |
| 1618 | c->Request.CDB[8] = (size >> 8) & 0xFF; | 1678 | c->Request.CDB[8] = (size >> 8) & 0xFF; |
| 1619 | c->Request.CDB[9] = size & 0xFF; | 1679 | c->Request.CDB[9] = size & 0xFF; |
| @@ -1627,7 +1687,7 @@ static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, | |||
| 1627 | c->Request.Type.Direction = XFER_READ; | 1687 | c->Request.Type.Direction = XFER_READ; |
| 1628 | c->Request.Timeout = 0; | 1688 | c->Request.Timeout = 0; |
| 1629 | c->Request.CDB[0] = cmd; | 1689 | c->Request.CDB[0] = cmd; |
| 1630 | break; | 1690 | break; |
| 1631 | case CCISS_CACHE_FLUSH: | 1691 | case CCISS_CACHE_FLUSH: |
| 1632 | c->Request.CDBLen = 12; | 1692 | c->Request.CDBLen = 12; |
| 1633 | c->Request.Type.Attribute = ATTR_SIMPLE; | 1693 | c->Request.Type.Attribute = ATTR_SIMPLE; |
| @@ -1635,32 +1695,32 @@ static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, | |||
| 1635 | c->Request.Timeout = 0; | 1695 | c->Request.Timeout = 0; |
| 1636 | c->Request.CDB[0] = BMIC_WRITE; | 1696 | c->Request.CDB[0] = BMIC_WRITE; |
| 1637 | c->Request.CDB[6] = BMIC_CACHE_FLUSH; | 1697 | c->Request.CDB[6] = BMIC_CACHE_FLUSH; |
| 1638 | break; | 1698 | break; |
| 1639 | default: | 1699 | default: |
| 1640 | printk(KERN_WARNING | 1700 | printk(KERN_WARNING |
| 1641 | "cciss%d: Unknown Command 0x%c\n", ctlr, cmd); | 1701 | "cciss%d: Unknown Command 0x%c\n", ctlr, cmd); |
| 1642 | return IO_ERROR; | 1702 | return IO_ERROR; |
| 1643 | } | 1703 | } |
| 1644 | } else if (cmd_type == TYPE_MSG) { | 1704 | } else if (cmd_type == TYPE_MSG) { |
| 1645 | switch (cmd) { | 1705 | switch (cmd) { |
| 1646 | case 0: /* ABORT message */ | 1706 | case 0: /* ABORT message */ |
| 1647 | c->Request.CDBLen = 12; | 1707 | c->Request.CDBLen = 12; |
| 1648 | c->Request.Type.Attribute = ATTR_SIMPLE; | 1708 | c->Request.Type.Attribute = ATTR_SIMPLE; |
| 1649 | c->Request.Type.Direction = XFER_WRITE; | 1709 | c->Request.Type.Direction = XFER_WRITE; |
| 1650 | c->Request.Timeout = 0; | 1710 | c->Request.Timeout = 0; |
| 1651 | c->Request.CDB[0] = cmd; /* abort */ | 1711 | c->Request.CDB[0] = cmd; /* abort */ |
| 1652 | c->Request.CDB[1] = 0; /* abort a command */ | 1712 | c->Request.CDB[1] = 0; /* abort a command */ |
| 1653 | /* buff contains the tag of the command to abort */ | 1713 | /* buff contains the tag of the command to abort */ |
| 1654 | memcpy(&c->Request.CDB[4], buff, 8); | 1714 | memcpy(&c->Request.CDB[4], buff, 8); |
| 1655 | break; | 1715 | break; |
| 1656 | case 1: /* RESET message */ | 1716 | case 1: /* RESET message */ |
| 1657 | c->Request.CDBLen = 12; | 1717 | c->Request.CDBLen = 12; |
| 1658 | c->Request.Type.Attribute = ATTR_SIMPLE; | 1718 | c->Request.Type.Attribute = ATTR_SIMPLE; |
| 1659 | c->Request.Type.Direction = XFER_WRITE; | 1719 | c->Request.Type.Direction = XFER_WRITE; |
| 1660 | c->Request.Timeout = 0; | 1720 | c->Request.Timeout = 0; |
| 1661 | memset(&c->Request.CDB[0], 0, sizeof(c->Request.CDB)); | 1721 | memset(&c->Request.CDB[0], 0, sizeof(c->Request.CDB)); |
| 1662 | c->Request.CDB[0] = cmd; /* reset */ | 1722 | c->Request.CDB[0] = cmd; /* reset */ |
| 1663 | c->Request.CDB[1] = 0x04; /* reset a LUN */ | 1723 | c->Request.CDB[1] = 0x04; /* reset a LUN */ |
| 1664 | case 3: /* No-Op message */ | 1724 | case 3: /* No-Op message */ |
| 1665 | c->Request.CDBLen = 1; | 1725 | c->Request.CDBLen = 1; |
| 1666 | c->Request.Type.Attribute = ATTR_SIMPLE; | 1726 | c->Request.Type.Attribute = ATTR_SIMPLE; |
| @@ -1670,168 +1730,164 @@ static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, | |||
| 1670 | break; | 1730 | break; |
| 1671 | default: | 1731 | default: |
| 1672 | printk(KERN_WARNING | 1732 | printk(KERN_WARNING |
| 1673 | "cciss%d: unknown message type %d\n", | 1733 | "cciss%d: unknown message type %d\n", ctlr, cmd); |
| 1674 | ctlr, cmd); | ||
| 1675 | return IO_ERROR; | 1734 | return IO_ERROR; |
| 1676 | } | 1735 | } |
| 1677 | } else { | 1736 | } else { |
| 1678 | printk(KERN_WARNING | 1737 | printk(KERN_WARNING |
| 1679 | "cciss%d: unknown command type %d\n", ctlr, cmd_type); | 1738 | "cciss%d: unknown command type %d\n", ctlr, cmd_type); |
| 1680 | return IO_ERROR; | 1739 | return IO_ERROR; |
| 1681 | } | 1740 | } |
| 1682 | /* Fill in the scatter gather information */ | 1741 | /* Fill in the scatter gather information */ |
| 1683 | if (size > 0) { | 1742 | if (size > 0) { |
| 1684 | buff_dma_handle.val = (__u64) pci_map_single(h->pdev, | 1743 | buff_dma_handle.val = (__u64) pci_map_single(h->pdev, |
| 1685 | buff, size, PCI_DMA_BIDIRECTIONAL); | 1744 | buff, size, |
| 1745 | PCI_DMA_BIDIRECTIONAL); | ||
| 1686 | c->SG[0].Addr.lower = buff_dma_handle.val32.lower; | 1746 | c->SG[0].Addr.lower = buff_dma_handle.val32.lower; |
| 1687 | c->SG[0].Addr.upper = buff_dma_handle.val32.upper; | 1747 | c->SG[0].Addr.upper = buff_dma_handle.val32.upper; |
| 1688 | c->SG[0].Len = size; | 1748 | c->SG[0].Len = size; |
| 1689 | c->SG[0].Ext = 0; /* we are not chaining */ | 1749 | c->SG[0].Ext = 0; /* we are not chaining */ |
| 1690 | } | 1750 | } |
| 1691 | return status; | 1751 | return status; |
| 1692 | } | 1752 | } |
| 1693 | static int sendcmd_withirq(__u8 cmd, | 1753 | |
| 1694 | int ctlr, | 1754 | static int sendcmd_withirq(__u8 cmd, |
| 1695 | void *buff, | 1755 | int ctlr, |
| 1696 | size_t size, | 1756 | void *buff, |
| 1697 | unsigned int use_unit_num, | 1757 | size_t size, |
| 1698 | unsigned int log_unit, | 1758 | unsigned int use_unit_num, |
| 1699 | __u8 page_code, | 1759 | unsigned int log_unit, __u8 page_code, int cmd_type) |
| 1700 | int cmd_type) | ||
| 1701 | { | 1760 | { |
| 1702 | ctlr_info_t *h = hba[ctlr]; | 1761 | ctlr_info_t *h = hba[ctlr]; |
| 1703 | CommandList_struct *c; | 1762 | CommandList_struct *c; |
| 1704 | u64bit buff_dma_handle; | 1763 | u64bit buff_dma_handle; |
| 1705 | unsigned long flags; | 1764 | unsigned long flags; |
| 1706 | int return_status; | 1765 | int return_status; |
| 1707 | DECLARE_COMPLETION(wait); | 1766 | DECLARE_COMPLETION(wait); |
| 1708 | 1767 | ||
| 1709 | if ((c = cmd_alloc(h , 0)) == NULL) | 1768 | if ((c = cmd_alloc(h, 0)) == NULL) |
| 1710 | return -ENOMEM; | 1769 | return -ENOMEM; |
| 1711 | return_status = fill_cmd(c, cmd, ctlr, buff, size, use_unit_num, | 1770 | return_status = fill_cmd(c, cmd, ctlr, buff, size, use_unit_num, |
| 1712 | log_unit, page_code, NULL, cmd_type); | 1771 | log_unit, page_code, NULL, cmd_type); |
| 1713 | if (return_status != IO_OK) { | 1772 | if (return_status != IO_OK) { |
| 1714 | cmd_free(h, c, 0); | 1773 | cmd_free(h, c, 0); |
| 1715 | return return_status; | 1774 | return return_status; |
| 1716 | } | 1775 | } |
| 1717 | resend_cmd2: | 1776 | resend_cmd2: |
| 1718 | c->waiting = &wait; | 1777 | c->waiting = &wait; |
| 1719 | 1778 | ||
| 1720 | /* Put the request on the tail of the queue and send it */ | 1779 | /* Put the request on the tail of the queue and send it */ |
| 1721 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | 1780 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); |
| 1722 | addQ(&h->reqQ, c); | 1781 | addQ(&h->reqQ, c); |
| 1723 | h->Qdepth++; | 1782 | h->Qdepth++; |
| 1724 | start_io(h); | 1783 | start_io(h); |
| 1725 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | 1784 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); |
| 1726 | 1785 | ||
| 1727 | wait_for_completion(&wait); | 1786 | wait_for_completion(&wait); |
| 1728 | 1787 | ||
| 1729 | if(c->err_info->CommandStatus != 0) | 1788 | if (c->err_info->CommandStatus != 0) { /* an error has occurred */ |
| 1730 | { /* an error has occurred */ | 1789 | switch (c->err_info->CommandStatus) { |
| 1731 | switch(c->err_info->CommandStatus) | 1790 | case CMD_TARGET_STATUS: |
| 1732 | { | 1791 | printk(KERN_WARNING "cciss: cmd %p has " |
| 1733 | case CMD_TARGET_STATUS: | 1792 | " completed with errors\n", c); |
| 1734 | printk(KERN_WARNING "cciss: cmd %p has " | 1793 | if (c->err_info->ScsiStatus) { |
| 1735 | " completed with errors\n", c); | 1794 | printk(KERN_WARNING "cciss: cmd %p " |
| 1736 | if( c->err_info->ScsiStatus) | 1795 | "has SCSI Status = %x\n", |
| 1737 | { | 1796 | c, c->err_info->ScsiStatus); |
| 1738 | printk(KERN_WARNING "cciss: cmd %p " | 1797 | } |
| 1739 | "has SCSI Status = %x\n", | ||
| 1740 | c, | ||
| 1741 | c->err_info->ScsiStatus); | ||
| 1742 | } | ||
| 1743 | 1798 | ||
| 1744 | break; | 1799 | break; |
| 1745 | case CMD_DATA_UNDERRUN: | 1800 | case CMD_DATA_UNDERRUN: |
| 1746 | case CMD_DATA_OVERRUN: | 1801 | case CMD_DATA_OVERRUN: |
| 1747 | /* expected for inquire and report lun commands */ | 1802 | /* expected for inquire and report lun commands */ |
| 1748 | break; | 1803 | break; |
| 1749 | case CMD_INVALID: | 1804 | case CMD_INVALID: |
| 1750 | printk(KERN_WARNING "cciss: Cmd %p is " | 1805 | printk(KERN_WARNING "cciss: Cmd %p is " |
| 1751 | "reported invalid\n", c); | 1806 | "reported invalid\n", c); |
| 1752 | return_status = IO_ERROR; | 1807 | return_status = IO_ERROR; |
| 1753 | break; | 1808 | break; |
| 1754 | case CMD_PROTOCOL_ERR: | 1809 | case CMD_PROTOCOL_ERR: |
| 1755 | printk(KERN_WARNING "cciss: cmd %p has " | 1810 | printk(KERN_WARNING "cciss: cmd %p has " |
| 1756 | "protocol error \n", c); | 1811 | "protocol error \n", c); |
| 1757 | return_status = IO_ERROR; | 1812 | return_status = IO_ERROR; |
| 1758 | break; | ||
| 1759 | case CMD_HARDWARE_ERR: | ||
| 1760 | printk(KERN_WARNING "cciss: cmd %p had " | ||
| 1761 | " hardware error\n", c); | ||
| 1762 | return_status = IO_ERROR; | ||
| 1763 | break; | ||
| 1764 | case CMD_CONNECTION_LOST: | ||
| 1765 | printk(KERN_WARNING "cciss: cmd %p had " | ||
| 1766 | "connection lost\n", c); | ||
| 1767 | return_status = IO_ERROR; | ||
| 1768 | break; | 1813 | break; |
| 1769 | case CMD_ABORTED: | 1814 | case CMD_HARDWARE_ERR: |
| 1770 | printk(KERN_WARNING "cciss: cmd %p was " | 1815 | printk(KERN_WARNING "cciss: cmd %p had " |
| 1771 | "aborted\n", c); | 1816 | " hardware error\n", c); |
| 1772 | return_status = IO_ERROR; | 1817 | return_status = IO_ERROR; |
| 1773 | break; | 1818 | break; |
| 1774 | case CMD_ABORT_FAILED: | 1819 | case CMD_CONNECTION_LOST: |
| 1775 | printk(KERN_WARNING "cciss: cmd %p reports " | 1820 | printk(KERN_WARNING "cciss: cmd %p had " |
| 1776 | "abort failed\n", c); | 1821 | "connection lost\n", c); |
| 1777 | return_status = IO_ERROR; | 1822 | return_status = IO_ERROR; |
| 1778 | break; | 1823 | break; |
| 1779 | case CMD_UNSOLICITED_ABORT: | 1824 | case CMD_ABORTED: |
| 1780 | printk(KERN_WARNING | 1825 | printk(KERN_WARNING "cciss: cmd %p was " |
| 1781 | "cciss%d: unsolicited abort %p\n", | 1826 | "aborted\n", c); |
| 1782 | ctlr, c); | 1827 | return_status = IO_ERROR; |
| 1783 | if (c->retry_count < MAX_CMD_RETRIES) { | ||
| 1784 | printk(KERN_WARNING | ||
| 1785 | "cciss%d: retrying %p\n", | ||
| 1786 | ctlr, c); | ||
| 1787 | c->retry_count++; | ||
| 1788 | /* erase the old error information */ | ||
| 1789 | memset(c->err_info, 0, | ||
| 1790 | sizeof(ErrorInfo_struct)); | ||
| 1791 | return_status = IO_OK; | ||
| 1792 | INIT_COMPLETION(wait); | ||
| 1793 | goto resend_cmd2; | ||
| 1794 | } | ||
| 1795 | return_status = IO_ERROR; | ||
| 1796 | break; | 1828 | break; |
| 1797 | default: | 1829 | case CMD_ABORT_FAILED: |
| 1798 | printk(KERN_WARNING "cciss: cmd %p returned " | 1830 | printk(KERN_WARNING "cciss: cmd %p reports " |
| 1799 | "unknown status %x\n", c, | 1831 | "abort failed\n", c); |
| 1800 | c->err_info->CommandStatus); | 1832 | return_status = IO_ERROR; |
| 1801 | return_status = IO_ERROR; | 1833 | break; |
| 1834 | case CMD_UNSOLICITED_ABORT: | ||
| 1835 | printk(KERN_WARNING | ||
| 1836 | "cciss%d: unsolicited abort %p\n", ctlr, c); | ||
| 1837 | if (c->retry_count < MAX_CMD_RETRIES) { | ||
| 1838 | printk(KERN_WARNING | ||
| 1839 | "cciss%d: retrying %p\n", ctlr, c); | ||
| 1840 | c->retry_count++; | ||
| 1841 | /* erase the old error information */ | ||
| 1842 | memset(c->err_info, 0, | ||
| 1843 | sizeof(ErrorInfo_struct)); | ||
| 1844 | return_status = IO_OK; | ||
| 1845 | INIT_COMPLETION(wait); | ||
| 1846 | goto resend_cmd2; | ||
| 1847 | } | ||
| 1848 | return_status = IO_ERROR; | ||
| 1849 | break; | ||
| 1850 | default: | ||
| 1851 | printk(KERN_WARNING "cciss: cmd %p returned " | ||
| 1852 | "unknown status %x\n", c, | ||
| 1853 | c->err_info->CommandStatus); | ||
| 1854 | return_status = IO_ERROR; | ||
| 1802 | } | 1855 | } |
| 1803 | } | 1856 | } |
| 1804 | /* unlock the buffers from DMA */ | 1857 | /* unlock the buffers from DMA */ |
| 1805 | buff_dma_handle.val32.lower = c->SG[0].Addr.lower; | 1858 | buff_dma_handle.val32.lower = c->SG[0].Addr.lower; |
| 1806 | buff_dma_handle.val32.upper = c->SG[0].Addr.upper; | 1859 | buff_dma_handle.val32.upper = c->SG[0].Addr.upper; |
| 1807 | pci_unmap_single( h->pdev, (dma_addr_t) buff_dma_handle.val, | 1860 | pci_unmap_single(h->pdev, (dma_addr_t) buff_dma_handle.val, |
| 1808 | c->SG[0].Len, PCI_DMA_BIDIRECTIONAL); | 1861 | c->SG[0].Len, PCI_DMA_BIDIRECTIONAL); |
| 1809 | cmd_free(h, c, 0); | 1862 | cmd_free(h, c, 0); |
| 1810 | return return_status; | 1863 | return return_status; |
| 1811 | |||
| 1812 | } | 1864 | } |
| 1865 | |||
| 1813 | static void cciss_geometry_inquiry(int ctlr, int logvol, | 1866 | static void cciss_geometry_inquiry(int ctlr, int logvol, |
| 1814 | int withirq, unsigned int total_size, | 1867 | int withirq, unsigned int total_size, |
| 1815 | unsigned int block_size, InquiryData_struct *inq_buff, | 1868 | unsigned int block_size, |
| 1816 | drive_info_struct *drv) | 1869 | InquiryData_struct *inq_buff, |
| 1870 | drive_info_struct *drv) | ||
| 1817 | { | 1871 | { |
| 1818 | int return_code; | 1872 | int return_code; |
| 1819 | memset(inq_buff, 0, sizeof(InquiryData_struct)); | 1873 | memset(inq_buff, 0, sizeof(InquiryData_struct)); |
| 1820 | if (withirq) | 1874 | if (withirq) |
| 1821 | return_code = sendcmd_withirq(CISS_INQUIRY, ctlr, | 1875 | return_code = sendcmd_withirq(CISS_INQUIRY, ctlr, |
| 1822 | inq_buff, sizeof(*inq_buff), 1, logvol ,0xC1, TYPE_CMD); | 1876 | inq_buff, sizeof(*inq_buff), 1, |
| 1877 | logvol, 0xC1, TYPE_CMD); | ||
| 1823 | else | 1878 | else |
| 1824 | return_code = sendcmd(CISS_INQUIRY, ctlr, inq_buff, | 1879 | return_code = sendcmd(CISS_INQUIRY, ctlr, inq_buff, |
| 1825 | sizeof(*inq_buff), 1, logvol ,0xC1, NULL, TYPE_CMD); | 1880 | sizeof(*inq_buff), 1, logvol, 0xC1, NULL, |
| 1881 | TYPE_CMD); | ||
| 1826 | if (return_code == IO_OK) { | 1882 | if (return_code == IO_OK) { |
| 1827 | if(inq_buff->data_byte[8] == 0xFF) { | 1883 | if (inq_buff->data_byte[8] == 0xFF) { |
| 1828 | printk(KERN_WARNING | 1884 | printk(KERN_WARNING |
| 1829 | "cciss: reading geometry failed, volume " | 1885 | "cciss: reading geometry failed, volume " |
| 1830 | "does not support reading geometry\n"); | 1886 | "does not support reading geometry\n"); |
| 1831 | drv->block_size = block_size; | 1887 | drv->block_size = block_size; |
| 1832 | drv->nr_blocks = total_size; | 1888 | drv->nr_blocks = total_size; |
| 1833 | drv->heads = 255; | 1889 | drv->heads = 255; |
| 1834 | drv->sectors = 32; // Sectors per track | 1890 | drv->sectors = 32; // Sectors per track |
| 1835 | drv->cylinders = total_size / 255 / 32; | 1891 | drv->cylinders = total_size / 255 / 32; |
| 1836 | } else { | 1892 | } else { |
| 1837 | unsigned int t; | 1893 | unsigned int t; |
| @@ -1845,37 +1901,42 @@ static void cciss_geometry_inquiry(int ctlr, int logvol, | |||
| 1845 | drv->raid_level = inq_buff->data_byte[8]; | 1901 | drv->raid_level = inq_buff->data_byte[8]; |
| 1846 | t = drv->heads * drv->sectors; | 1902 | t = drv->heads * drv->sectors; |
| 1847 | if (t > 1) { | 1903 | if (t > 1) { |
| 1848 | drv->cylinders = total_size/t; | 1904 | drv->cylinders = total_size / t; |
| 1849 | } | 1905 | } |
| 1850 | } | 1906 | } |
| 1851 | } else { /* Get geometry failed */ | 1907 | } else { /* Get geometry failed */ |
| 1852 | printk(KERN_WARNING "cciss: reading geometry failed\n"); | 1908 | printk(KERN_WARNING "cciss: reading geometry failed\n"); |
| 1853 | } | 1909 | } |
| 1854 | printk(KERN_INFO " heads= %d, sectors= %d, cylinders= %d\n\n", | 1910 | printk(KERN_INFO " heads= %d, sectors= %d, cylinders= %d\n\n", |
| 1855 | drv->heads, drv->sectors, drv->cylinders); | 1911 | drv->heads, drv->sectors, drv->cylinders); |
| 1856 | } | 1912 | } |
| 1913 | |||
| 1857 | static void | 1914 | static void |
| 1858 | cciss_read_capacity(int ctlr, int logvol, ReadCapdata_struct *buf, | 1915 | cciss_read_capacity(int ctlr, int logvol, ReadCapdata_struct *buf, |
| 1859 | int withirq, unsigned int *total_size, unsigned int *block_size) | 1916 | int withirq, unsigned int *total_size, |
| 1917 | unsigned int *block_size) | ||
| 1860 | { | 1918 | { |
| 1861 | int return_code; | 1919 | int return_code; |
| 1862 | memset(buf, 0, sizeof(*buf)); | 1920 | memset(buf, 0, sizeof(*buf)); |
| 1863 | if (withirq) | 1921 | if (withirq) |
| 1864 | return_code = sendcmd_withirq(CCISS_READ_CAPACITY, | 1922 | return_code = sendcmd_withirq(CCISS_READ_CAPACITY, |
| 1865 | ctlr, buf, sizeof(*buf), 1, logvol, 0, TYPE_CMD); | 1923 | ctlr, buf, sizeof(*buf), 1, |
| 1924 | logvol, 0, TYPE_CMD); | ||
| 1866 | else | 1925 | else |
| 1867 | return_code = sendcmd(CCISS_READ_CAPACITY, | 1926 | return_code = sendcmd(CCISS_READ_CAPACITY, |
| 1868 | ctlr, buf, sizeof(*buf), 1, logvol, 0, NULL, TYPE_CMD); | 1927 | ctlr, buf, sizeof(*buf), 1, logvol, 0, |
| 1928 | NULL, TYPE_CMD); | ||
| 1869 | if (return_code == IO_OK) { | 1929 | if (return_code == IO_OK) { |
| 1870 | *total_size = be32_to_cpu(*((__be32 *) &buf->total_size[0]))+1; | 1930 | *total_size = |
| 1871 | *block_size = be32_to_cpu(*((__be32 *) &buf->block_size[0])); | 1931 | be32_to_cpu(*((__be32 *) & buf->total_size[0])) + 1; |
| 1872 | } else { /* read capacity command failed */ | 1932 | *block_size = be32_to_cpu(*((__be32 *) & buf->block_size[0])); |
| 1933 | } else { /* read capacity command failed */ | ||
| 1873 | printk(KERN_WARNING "cciss: read capacity failed\n"); | 1934 | printk(KERN_WARNING "cciss: read capacity failed\n"); |
| 1874 | *total_size = 0; | 1935 | *total_size = 0; |
| 1875 | *block_size = BLOCK_SIZE; | 1936 | *block_size = BLOCK_SIZE; |
| 1876 | } | 1937 | } |
| 1877 | printk(KERN_INFO " blocks= %u block_size= %d\n", | 1938 | printk(KERN_INFO " blocks= %u block_size= %d\n", |
| 1878 | *total_size, *block_size); | 1939 | *total_size, *block_size); |
| 1879 | return; | 1940 | return; |
| 1880 | } | 1941 | } |
| 1881 | 1942 | ||
| @@ -1884,38 +1945,38 @@ static int cciss_revalidate(struct gendisk *disk) | |||
| 1884 | ctlr_info_t *h = get_host(disk); | 1945 | ctlr_info_t *h = get_host(disk); |
| 1885 | drive_info_struct *drv = get_drv(disk); | 1946 | drive_info_struct *drv = get_drv(disk); |
| 1886 | int logvol; | 1947 | int logvol; |
| 1887 | int FOUND=0; | 1948 | int FOUND = 0; |
| 1888 | unsigned int block_size; | 1949 | unsigned int block_size; |
| 1889 | unsigned int total_size; | 1950 | unsigned int total_size; |
| 1890 | ReadCapdata_struct *size_buff = NULL; | 1951 | ReadCapdata_struct *size_buff = NULL; |
| 1891 | InquiryData_struct *inq_buff = NULL; | 1952 | InquiryData_struct *inq_buff = NULL; |
| 1892 | 1953 | ||
| 1893 | for(logvol=0; logvol < CISS_MAX_LUN; logvol++) | 1954 | for (logvol = 0; logvol < CISS_MAX_LUN; logvol++) { |
| 1894 | { | 1955 | if (h->drv[logvol].LunID == drv->LunID) { |
| 1895 | if(h->drv[logvol].LunID == drv->LunID) { | 1956 | FOUND = 1; |
| 1896 | FOUND=1; | ||
| 1897 | break; | 1957 | break; |
| 1898 | } | 1958 | } |
| 1899 | } | 1959 | } |
| 1900 | 1960 | ||
| 1901 | if (!FOUND) return 1; | 1961 | if (!FOUND) |
| 1962 | return 1; | ||
| 1902 | 1963 | ||
| 1903 | size_buff = kmalloc(sizeof( ReadCapdata_struct), GFP_KERNEL); | 1964 | size_buff = kmalloc(sizeof(ReadCapdata_struct), GFP_KERNEL); |
| 1904 | if (size_buff == NULL) | 1965 | if (size_buff == NULL) { |
| 1905 | { | 1966 | printk(KERN_WARNING "cciss: out of memory\n"); |
| 1906 | printk(KERN_WARNING "cciss: out of memory\n"); | 1967 | return 1; |
| 1907 | return 1; | 1968 | } |
| 1908 | } | 1969 | inq_buff = kmalloc(sizeof(InquiryData_struct), GFP_KERNEL); |
| 1909 | inq_buff = kmalloc(sizeof( InquiryData_struct), GFP_KERNEL); | 1970 | if (inq_buff == NULL) { |
| 1910 | if (inq_buff == NULL) | 1971 | printk(KERN_WARNING "cciss: out of memory\n"); |
| 1911 | { | ||
| 1912 | printk(KERN_WARNING "cciss: out of memory\n"); | ||
| 1913 | kfree(size_buff); | 1972 | kfree(size_buff); |
| 1914 | return 1; | 1973 | return 1; |
| 1915 | } | 1974 | } |
| 1916 | 1975 | ||
| 1917 | cciss_read_capacity(h->ctlr, logvol, size_buff, 1, &total_size, &block_size); | 1976 | cciss_read_capacity(h->ctlr, logvol, size_buff, 1, &total_size, |
| 1918 | cciss_geometry_inquiry(h->ctlr, logvol, 1, total_size, block_size, inq_buff, drv); | 1977 | &block_size); |
| 1978 | cciss_geometry_inquiry(h->ctlr, logvol, 1, total_size, block_size, | ||
| 1979 | inq_buff, drv); | ||
| 1919 | 1980 | ||
| 1920 | blk_queue_hardsect_size(drv->queue, drv->block_size); | 1981 | blk_queue_hardsect_size(drv->queue, drv->block_size); |
| 1921 | set_capacity(disk, drv->nr_blocks); | 1982 | set_capacity(disk, drv->nr_blocks); |
| @@ -1951,28 +2012,28 @@ static unsigned long pollcomplete(int ctlr) | |||
| 1951 | static int add_sendcmd_reject(__u8 cmd, int ctlr, unsigned long complete) | 2012 | static int add_sendcmd_reject(__u8 cmd, int ctlr, unsigned long complete) |
| 1952 | { | 2013 | { |
| 1953 | /* We get in here if sendcmd() is polling for completions | 2014 | /* We get in here if sendcmd() is polling for completions |
| 1954 | and gets some command back that it wasn't expecting -- | 2015 | and gets some command back that it wasn't expecting -- |
| 1955 | something other than that which it just sent down. | 2016 | something other than that which it just sent down. |
| 1956 | Ordinarily, that shouldn't happen, but it can happen when | 2017 | Ordinarily, that shouldn't happen, but it can happen when |
| 1957 | the scsi tape stuff gets into error handling mode, and | 2018 | the scsi tape stuff gets into error handling mode, and |
| 1958 | starts using sendcmd() to try to abort commands and | 2019 | starts using sendcmd() to try to abort commands and |
| 1959 | reset tape drives. In that case, sendcmd may pick up | 2020 | reset tape drives. In that case, sendcmd may pick up |
| 1960 | completions of commands that were sent to logical drives | 2021 | completions of commands that were sent to logical drives |
| 1961 | through the block i/o system, or cciss ioctls completing, etc. | 2022 | through the block i/o system, or cciss ioctls completing, etc. |
| 1962 | In that case, we need to save those completions for later | 2023 | In that case, we need to save those completions for later |
| 1963 | processing by the interrupt handler. | 2024 | processing by the interrupt handler. |
| 1964 | */ | 2025 | */ |
| 1965 | 2026 | ||
| 1966 | #ifdef CONFIG_CISS_SCSI_TAPE | 2027 | #ifdef CONFIG_CISS_SCSI_TAPE |
| 1967 | struct sendcmd_reject_list *srl = &hba[ctlr]->scsi_rejects; | 2028 | struct sendcmd_reject_list *srl = &hba[ctlr]->scsi_rejects; |
| 1968 | 2029 | ||
| 1969 | /* If it's not the scsi tape stuff doing error handling, (abort */ | 2030 | /* If it's not the scsi tape stuff doing error handling, (abort */ |
| 1970 | /* or reset) then we don't expect anything weird. */ | 2031 | /* or reset) then we don't expect anything weird. */ |
| 1971 | if (cmd != CCISS_RESET_MSG && cmd != CCISS_ABORT_MSG) { | 2032 | if (cmd != CCISS_RESET_MSG && cmd != CCISS_ABORT_MSG) { |
| 1972 | #endif | 2033 | #endif |
| 1973 | printk( KERN_WARNING "cciss cciss%d: SendCmd " | 2034 | printk(KERN_WARNING "cciss cciss%d: SendCmd " |
| 1974 | "Invalid command list address returned! (%lx)\n", | 2035 | "Invalid command list address returned! (%lx)\n", |
| 1975 | ctlr, complete); | 2036 | ctlr, complete); |
| 1976 | /* not much we can do. */ | 2037 | /* not much we can do. */ |
| 1977 | #ifdef CONFIG_CISS_SCSI_TAPE | 2038 | #ifdef CONFIG_CISS_SCSI_TAPE |
| 1978 | return 1; | 2039 | return 1; |
| @@ -1983,7 +2044,7 @@ static int add_sendcmd_reject(__u8 cmd, int ctlr, unsigned long complete) | |||
| 1983 | if (srl->ncompletions >= (NR_CMDS + 2)) { | 2044 | if (srl->ncompletions >= (NR_CMDS + 2)) { |
| 1984 | /* Uh oh. No room to save it for later... */ | 2045 | /* Uh oh. No room to save it for later... */ |
| 1985 | printk(KERN_WARNING "cciss%d: Sendcmd: Invalid command addr, " | 2046 | printk(KERN_WARNING "cciss%d: Sendcmd: Invalid command addr, " |
| 1986 | "reject list overflow, command lost!\n", ctlr); | 2047 | "reject list overflow, command lost!\n", ctlr); |
| 1987 | return 1; | 2048 | return 1; |
| 1988 | } | 2049 | } |
| 1989 | /* Save it for later */ | 2050 | /* Save it for later */ |
| @@ -1994,26 +2055,19 @@ static int add_sendcmd_reject(__u8 cmd, int ctlr, unsigned long complete) | |||
| 1994 | } | 2055 | } |
| 1995 | 2056 | ||
| 1996 | /* | 2057 | /* |
| 1997 | * Send a command to the controller, and wait for it to complete. | 2058 | * Send a command to the controller, and wait for it to complete. |
| 1998 | * Only used at init time. | 2059 | * Only used at init time. |
| 1999 | */ | 2060 | */ |
| 2000 | static int sendcmd( | 2061 | static int sendcmd(__u8 cmd, int ctlr, void *buff, size_t size, unsigned int use_unit_num, /* 0: address the controller, |
| 2001 | __u8 cmd, | 2062 | 1: address logical volume log_unit, |
| 2002 | int ctlr, | 2063 | 2: periph device address is scsi3addr */ |
| 2003 | void *buff, | 2064 | unsigned int log_unit, |
| 2004 | size_t size, | 2065 | __u8 page_code, unsigned char *scsi3addr, int cmd_type) |
| 2005 | unsigned int use_unit_num, /* 0: address the controller, | ||
| 2006 | 1: address logical volume log_unit, | ||
| 2007 | 2: periph device address is scsi3addr */ | ||
| 2008 | unsigned int log_unit, | ||
| 2009 | __u8 page_code, | ||
| 2010 | unsigned char *scsi3addr, | ||
| 2011 | int cmd_type) | ||
| 2012 | { | 2066 | { |
| 2013 | CommandList_struct *c; | 2067 | CommandList_struct *c; |
| 2014 | int i; | 2068 | int i; |
| 2015 | unsigned long complete; | 2069 | unsigned long complete; |
| 2016 | ctlr_info_t *info_p= hba[ctlr]; | 2070 | ctlr_info_t *info_p = hba[ctlr]; |
| 2017 | u64bit buff_dma_handle; | 2071 | u64bit buff_dma_handle; |
| 2018 | int status, done = 0; | 2072 | int status, done = 0; |
| 2019 | 2073 | ||
| @@ -2022,132 +2076,134 @@ static int sendcmd( | |||
| 2022 | return IO_ERROR; | 2076 | return IO_ERROR; |
| 2023 | } | 2077 | } |
| 2024 | status = fill_cmd(c, cmd, ctlr, buff, size, use_unit_num, | 2078 | status = fill_cmd(c, cmd, ctlr, buff, size, use_unit_num, |
| 2025 | log_unit, page_code, scsi3addr, cmd_type); | 2079 | log_unit, page_code, scsi3addr, cmd_type); |
| 2026 | if (status != IO_OK) { | 2080 | if (status != IO_OK) { |
| 2027 | cmd_free(info_p, c, 1); | 2081 | cmd_free(info_p, c, 1); |
| 2028 | return status; | 2082 | return status; |
| 2029 | } | 2083 | } |
| 2030 | resend_cmd1: | 2084 | resend_cmd1: |
| 2031 | /* | 2085 | /* |
| 2032 | * Disable interrupt | 2086 | * Disable interrupt |
| 2033 | */ | 2087 | */ |
| 2034 | #ifdef CCISS_DEBUG | 2088 | #ifdef CCISS_DEBUG |
| 2035 | printk(KERN_DEBUG "cciss: turning intr off\n"); | 2089 | printk(KERN_DEBUG "cciss: turning intr off\n"); |
| 2036 | #endif /* CCISS_DEBUG */ | 2090 | #endif /* CCISS_DEBUG */ |
| 2037 | info_p->access.set_intr_mask(info_p, CCISS_INTR_OFF); | 2091 | info_p->access.set_intr_mask(info_p, CCISS_INTR_OFF); |
| 2038 | 2092 | ||
| 2039 | /* Make sure there is room in the command FIFO */ | 2093 | /* Make sure there is room in the command FIFO */ |
| 2040 | /* Actually it should be completely empty at this time */ | 2094 | /* Actually it should be completely empty at this time */ |
| 2041 | /* unless we are in here doing error handling for the scsi */ | 2095 | /* unless we are in here doing error handling for the scsi */ |
| 2042 | /* tape side of the driver. */ | 2096 | /* tape side of the driver. */ |
| 2043 | for (i = 200000; i > 0; i--) | 2097 | for (i = 200000; i > 0; i--) { |
| 2044 | { | ||
| 2045 | /* if fifo isn't full go */ | 2098 | /* if fifo isn't full go */ |
| 2046 | if (!(info_p->access.fifo_full(info_p))) | 2099 | if (!(info_p->access.fifo_full(info_p))) { |
| 2047 | { | 2100 | |
| 2048 | 2101 | break; | |
| 2049 | break; | 2102 | } |
| 2050 | } | 2103 | udelay(10); |
| 2051 | udelay(10); | 2104 | printk(KERN_WARNING "cciss cciss%d: SendCmd FIFO full," |
| 2052 | printk(KERN_WARNING "cciss cciss%d: SendCmd FIFO full," | 2105 | " waiting!\n", ctlr); |
| 2053 | " waiting!\n", ctlr); | 2106 | } |
| 2054 | } | 2107 | /* |
| 2055 | /* | 2108 | * Send the cmd |
| 2056 | * Send the cmd | 2109 | */ |
| 2057 | */ | 2110 | info_p->access.submit_command(info_p, c); |
| 2058 | info_p->access.submit_command(info_p, c); | ||
| 2059 | done = 0; | 2111 | done = 0; |
| 2060 | do { | 2112 | do { |
| 2061 | complete = pollcomplete(ctlr); | 2113 | complete = pollcomplete(ctlr); |
| 2062 | 2114 | ||
| 2063 | #ifdef CCISS_DEBUG | 2115 | #ifdef CCISS_DEBUG |
| 2064 | printk(KERN_DEBUG "cciss: command completed\n"); | 2116 | printk(KERN_DEBUG "cciss: command completed\n"); |
| 2065 | #endif /* CCISS_DEBUG */ | 2117 | #endif /* CCISS_DEBUG */ |
| 2066 | 2118 | ||
| 2067 | if (complete == 1) { | 2119 | if (complete == 1) { |
| 2068 | printk( KERN_WARNING | 2120 | printk(KERN_WARNING |
| 2069 | "cciss cciss%d: SendCmd Timeout out, " | 2121 | "cciss cciss%d: SendCmd Timeout out, " |
| 2070 | "No command list address returned!\n", | 2122 | "No command list address returned!\n", ctlr); |
| 2071 | ctlr); | ||
| 2072 | status = IO_ERROR; | 2123 | status = IO_ERROR; |
| 2073 | done = 1; | 2124 | done = 1; |
| 2074 | break; | 2125 | break; |
| 2075 | } | 2126 | } |
| 2076 | 2127 | ||
| 2077 | /* This will need to change for direct lookup completions */ | 2128 | /* This will need to change for direct lookup completions */ |
| 2078 | if ( (complete & CISS_ERROR_BIT) | 2129 | if ((complete & CISS_ERROR_BIT) |
| 2079 | && (complete & ~CISS_ERROR_BIT) == c->busaddr) | 2130 | && (complete & ~CISS_ERROR_BIT) == c->busaddr) { |
| 2080 | { | 2131 | /* if data overrun or underun on Report command |
| 2081 | /* if data overrun or underun on Report command | 2132 | ignore it |
| 2082 | ignore it | 2133 | */ |
| 2083 | */ | ||
| 2084 | if (((c->Request.CDB[0] == CISS_REPORT_LOG) || | 2134 | if (((c->Request.CDB[0] == CISS_REPORT_LOG) || |
| 2085 | (c->Request.CDB[0] == CISS_REPORT_PHYS) || | 2135 | (c->Request.CDB[0] == CISS_REPORT_PHYS) || |
| 2086 | (c->Request.CDB[0] == CISS_INQUIRY)) && | 2136 | (c->Request.CDB[0] == CISS_INQUIRY)) && |
| 2087 | ((c->err_info->CommandStatus == | 2137 | ((c->err_info->CommandStatus == |
| 2088 | CMD_DATA_OVERRUN) || | 2138 | CMD_DATA_OVERRUN) || |
| 2089 | (c->err_info->CommandStatus == | 2139 | (c->err_info->CommandStatus == CMD_DATA_UNDERRUN) |
| 2090 | CMD_DATA_UNDERRUN) | 2140 | )) { |
| 2091 | )) | ||
| 2092 | { | ||
| 2093 | complete = c->busaddr; | 2141 | complete = c->busaddr; |
| 2094 | } else { | 2142 | } else { |
| 2095 | if (c->err_info->CommandStatus == | 2143 | if (c->err_info->CommandStatus == |
| 2096 | CMD_UNSOLICITED_ABORT) { | 2144 | CMD_UNSOLICITED_ABORT) { |
| 2097 | printk(KERN_WARNING "cciss%d: " | 2145 | printk(KERN_WARNING "cciss%d: " |
| 2098 | "unsolicited abort %p\n", | 2146 | "unsolicited abort %p\n", |
| 2099 | ctlr, c); | 2147 | ctlr, c); |
| 2100 | if (c->retry_count < MAX_CMD_RETRIES) { | 2148 | if (c->retry_count < MAX_CMD_RETRIES) { |
| 2101 | printk(KERN_WARNING | 2149 | printk(KERN_WARNING |
| 2102 | "cciss%d: retrying %p\n", | 2150 | "cciss%d: retrying %p\n", |
| 2103 | ctlr, c); | 2151 | ctlr, c); |
| 2104 | c->retry_count++; | 2152 | c->retry_count++; |
| 2105 | /* erase the old error */ | 2153 | /* erase the old error */ |
| 2106 | /* information */ | 2154 | /* information */ |
| 2107 | memset(c->err_info, 0, | 2155 | memset(c->err_info, 0, |
| 2108 | sizeof(ErrorInfo_struct)); | 2156 | sizeof |
| 2157 | (ErrorInfo_struct)); | ||
| 2109 | goto resend_cmd1; | 2158 | goto resend_cmd1; |
| 2110 | } else { | 2159 | } else { |
| 2111 | printk(KERN_WARNING | 2160 | printk(KERN_WARNING |
| 2112 | "cciss%d: retried %p too " | 2161 | "cciss%d: retried %p too " |
| 2113 | "many times\n", ctlr, c); | 2162 | "many times\n", ctlr, c); |
| 2114 | status = IO_ERROR; | 2163 | status = IO_ERROR; |
| 2115 | goto cleanup1; | 2164 | goto cleanup1; |
| 2116 | } | 2165 | } |
| 2117 | } else if (c->err_info->CommandStatus == CMD_UNABORTABLE) { | 2166 | } else if (c->err_info->CommandStatus == |
| 2118 | printk(KERN_WARNING "cciss%d: command could not be aborted.\n", ctlr); | 2167 | CMD_UNABORTABLE) { |
| 2168 | printk(KERN_WARNING | ||
| 2169 | "cciss%d: command could not be aborted.\n", | ||
| 2170 | ctlr); | ||
| 2119 | status = IO_ERROR; | 2171 | status = IO_ERROR; |
| 2120 | goto cleanup1; | 2172 | goto cleanup1; |
| 2121 | } | 2173 | } |
| 2122 | printk(KERN_WARNING "ciss ciss%d: sendcmd" | 2174 | printk(KERN_WARNING "ciss ciss%d: sendcmd" |
| 2123 | " Error %x \n", ctlr, | 2175 | " Error %x \n", ctlr, |
| 2124 | c->err_info->CommandStatus); | 2176 | c->err_info->CommandStatus); |
| 2125 | printk(KERN_WARNING "ciss ciss%d: sendcmd" | 2177 | printk(KERN_WARNING "ciss ciss%d: sendcmd" |
| 2126 | " offensive info\n" | 2178 | " offensive info\n" |
| 2127 | " size %x\n num %x value %x\n", ctlr, | 2179 | " size %x\n num %x value %x\n", |
| 2128 | c->err_info->MoreErrInfo.Invalid_Cmd.offense_size, | 2180 | ctlr, |
| 2129 | c->err_info->MoreErrInfo.Invalid_Cmd.offense_num, | 2181 | c->err_info->MoreErrInfo.Invalid_Cmd. |
| 2130 | c->err_info->MoreErrInfo.Invalid_Cmd.offense_value); | 2182 | offense_size, |
| 2183 | c->err_info->MoreErrInfo.Invalid_Cmd. | ||
| 2184 | offense_num, | ||
| 2185 | c->err_info->MoreErrInfo.Invalid_Cmd. | ||
| 2186 | offense_value); | ||
| 2131 | status = IO_ERROR; | 2187 | status = IO_ERROR; |
| 2132 | goto cleanup1; | 2188 | goto cleanup1; |
| 2133 | } | 2189 | } |
| 2134 | } | 2190 | } |
| 2135 | /* This will need changing for direct lookup completions */ | 2191 | /* This will need changing for direct lookup completions */ |
| 2136 | if (complete != c->busaddr) { | 2192 | if (complete != c->busaddr) { |
| 2137 | if (add_sendcmd_reject(cmd, ctlr, complete) != 0) { | 2193 | if (add_sendcmd_reject(cmd, ctlr, complete) != 0) { |
| 2138 | BUG(); /* we are pretty much hosed if we get here. */ | 2194 | BUG(); /* we are pretty much hosed if we get here. */ |
| 2139 | } | 2195 | } |
| 2140 | continue; | 2196 | continue; |
| 2141 | } else | 2197 | } else |
| 2142 | done = 1; | 2198 | done = 1; |
| 2143 | } while (!done); | 2199 | } while (!done); |
| 2144 | 2200 | ||
| 2145 | cleanup1: | 2201 | cleanup1: |
| 2146 | /* unlock the data buffer from DMA */ | 2202 | /* unlock the data buffer from DMA */ |
| 2147 | buff_dma_handle.val32.lower = c->SG[0].Addr.lower; | 2203 | buff_dma_handle.val32.lower = c->SG[0].Addr.lower; |
| 2148 | buff_dma_handle.val32.upper = c->SG[0].Addr.upper; | 2204 | buff_dma_handle.val32.upper = c->SG[0].Addr.upper; |
| 2149 | pci_unmap_single(info_p->pdev, (dma_addr_t) buff_dma_handle.val, | 2205 | pci_unmap_single(info_p->pdev, (dma_addr_t) buff_dma_handle.val, |
| 2150 | c->SG[0].Len, PCI_DMA_BIDIRECTIONAL); | 2206 | c->SG[0].Len, PCI_DMA_BIDIRECTIONAL); |
| 2151 | #ifdef CONFIG_CISS_SCSI_TAPE | 2207 | #ifdef CONFIG_CISS_SCSI_TAPE |
| 2152 | /* if we saved some commands for later, process them now. */ | 2208 | /* if we saved some commands for later, process them now. */ |
| 2153 | if (info_p->scsi_rejects.ncompletions > 0) | 2209 | if (info_p->scsi_rejects.ncompletions > 0) |
| @@ -2155,179 +2211,171 @@ cleanup1: | |||
| 2155 | #endif | 2211 | #endif |
| 2156 | cmd_free(info_p, c, 1); | 2212 | cmd_free(info_p, c, 1); |
| 2157 | return status; | 2213 | return status; |
| 2158 | } | 2214 | } |
| 2215 | |||
| 2159 | /* | 2216 | /* |
| 2160 | * Map (physical) PCI mem into (virtual) kernel space | 2217 | * Map (physical) PCI mem into (virtual) kernel space |
| 2161 | */ | 2218 | */ |
| 2162 | static void __iomem *remap_pci_mem(ulong base, ulong size) | 2219 | static void __iomem *remap_pci_mem(ulong base, ulong size) |
| 2163 | { | 2220 | { |
| 2164 | ulong page_base = ((ulong) base) & PAGE_MASK; | 2221 | ulong page_base = ((ulong) base) & PAGE_MASK; |
| 2165 | ulong page_offs = ((ulong) base) - page_base; | 2222 | ulong page_offs = ((ulong) base) - page_base; |
| 2166 | void __iomem *page_remapped = ioremap(page_base, page_offs+size); | 2223 | void __iomem *page_remapped = ioremap(page_base, page_offs + size); |
| 2167 | 2224 | ||
| 2168 | return page_remapped ? (page_remapped + page_offs) : NULL; | 2225 | return page_remapped ? (page_remapped + page_offs) : NULL; |
| 2169 | } | 2226 | } |
| 2170 | 2227 | ||
| 2171 | /* | 2228 | /* |
| 2172 | * Takes jobs of the Q and sends them to the hardware, then puts it on | 2229 | * Takes jobs of the Q and sends them to the hardware, then puts it on |
| 2173 | * the Q to wait for completion. | 2230 | * the Q to wait for completion. |
| 2174 | */ | 2231 | */ |
| 2175 | static void start_io( ctlr_info_t *h) | 2232 | static void start_io(ctlr_info_t *h) |
| 2176 | { | 2233 | { |
| 2177 | CommandList_struct *c; | 2234 | CommandList_struct *c; |
| 2178 | 2235 | ||
| 2179 | while(( c = h->reqQ) != NULL ) | 2236 | while ((c = h->reqQ) != NULL) { |
| 2180 | { | ||
| 2181 | /* can't do anything if fifo is full */ | 2237 | /* can't do anything if fifo is full */ |
| 2182 | if ((h->access.fifo_full(h))) { | 2238 | if ((h->access.fifo_full(h))) { |
| 2183 | printk(KERN_WARNING "cciss: fifo full\n"); | 2239 | printk(KERN_WARNING "cciss: fifo full\n"); |
| 2184 | break; | 2240 | break; |
| 2185 | } | 2241 | } |
| 2186 | 2242 | ||
| 2187 | /* Get the first entry from the Request Q */ | 2243 | /* Get the first entry from the Request Q */ |
| 2188 | removeQ(&(h->reqQ), c); | 2244 | removeQ(&(h->reqQ), c); |
| 2189 | h->Qdepth--; | 2245 | h->Qdepth--; |
| 2190 | 2246 | ||
| 2191 | /* Tell the controller execute command */ | 2247 | /* Tell the controller execute command */ |
| 2192 | h->access.submit_command(h, c); | 2248 | h->access.submit_command(h, c); |
| 2193 | 2249 | ||
| 2194 | /* Put job onto the completed Q */ | 2250 | /* Put job onto the completed Q */ |
| 2195 | addQ (&(h->cmpQ), c); | 2251 | addQ(&(h->cmpQ), c); |
| 2196 | } | 2252 | } |
| 2197 | } | 2253 | } |
| 2254 | |||
| 2198 | /* Assumes that CCISS_LOCK(h->ctlr) is held. */ | 2255 | /* Assumes that CCISS_LOCK(h->ctlr) is held. */ |
| 2199 | /* Zeros out the error record and then resends the command back */ | 2256 | /* Zeros out the error record and then resends the command back */ |
| 2200 | /* to the controller */ | 2257 | /* to the controller */ |
| 2201 | static inline void resend_cciss_cmd( ctlr_info_t *h, CommandList_struct *c) | 2258 | static inline void resend_cciss_cmd(ctlr_info_t *h, CommandList_struct *c) |
| 2202 | { | 2259 | { |
| 2203 | /* erase the old error information */ | 2260 | /* erase the old error information */ |
| 2204 | memset(c->err_info, 0, sizeof(ErrorInfo_struct)); | 2261 | memset(c->err_info, 0, sizeof(ErrorInfo_struct)); |
| 2205 | 2262 | ||
| 2206 | /* add it to software queue and then send it to the controller */ | 2263 | /* add it to software queue and then send it to the controller */ |
| 2207 | addQ(&(h->reqQ),c); | 2264 | addQ(&(h->reqQ), c); |
| 2208 | h->Qdepth++; | 2265 | h->Qdepth++; |
| 2209 | if(h->Qdepth > h->maxQsinceinit) | 2266 | if (h->Qdepth > h->maxQsinceinit) |
| 2210 | h->maxQsinceinit = h->Qdepth; | 2267 | h->maxQsinceinit = h->Qdepth; |
| 2211 | 2268 | ||
| 2212 | start_io(h); | 2269 | start_io(h); |
| 2213 | } | 2270 | } |
| 2214 | 2271 | ||
| 2215 | /* checks the status of the job and calls complete buffers to mark all | 2272 | /* checks the status of the job and calls complete buffers to mark all |
| 2216 | * buffers for the completed job. Note that this function does not need | 2273 | * buffers for the completed job. Note that this function does not need |
| 2217 | * to hold the hba/queue lock. | 2274 | * to hold the hba/queue lock. |
| 2218 | */ | 2275 | */ |
| 2219 | static inline void complete_command( ctlr_info_t *h, CommandList_struct *cmd, | 2276 | static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd, |
| 2220 | int timeout) | 2277 | int timeout) |
| 2221 | { | 2278 | { |
| 2222 | int status = 1; | 2279 | int status = 1; |
| 2223 | int retry_cmd = 0; | 2280 | int retry_cmd = 0; |
| 2224 | 2281 | ||
| 2225 | if (timeout) | 2282 | if (timeout) |
| 2226 | status = 0; | 2283 | status = 0; |
| 2227 | 2284 | ||
| 2228 | if(cmd->err_info->CommandStatus != 0) | 2285 | if (cmd->err_info->CommandStatus != 0) { /* an error has occurred */ |
| 2229 | { /* an error has occurred */ | 2286 | switch (cmd->err_info->CommandStatus) { |
| 2230 | switch(cmd->err_info->CommandStatus) | ||
| 2231 | { | ||
| 2232 | unsigned char sense_key; | 2287 | unsigned char sense_key; |
| 2233 | case CMD_TARGET_STATUS: | 2288 | case CMD_TARGET_STATUS: |
| 2234 | status = 0; | 2289 | status = 0; |
| 2235 | 2290 | ||
| 2236 | if( cmd->err_info->ScsiStatus == 0x02) | 2291 | if (cmd->err_info->ScsiStatus == 0x02) { |
| 2237 | { | 2292 | printk(KERN_WARNING "cciss: cmd %p " |
| 2238 | printk(KERN_WARNING "cciss: cmd %p " | 2293 | "has CHECK CONDITION " |
| 2239 | "has CHECK CONDITION " | 2294 | " byte 2 = 0x%x\n", cmd, |
| 2240 | " byte 2 = 0x%x\n", cmd, | 2295 | cmd->err_info->SenseInfo[2] |
| 2241 | cmd->err_info->SenseInfo[2] | 2296 | ); |
| 2242 | ); | 2297 | /* check the sense key */ |
| 2243 | /* check the sense key */ | 2298 | sense_key = 0xf & cmd->err_info->SenseInfo[2]; |
| 2244 | sense_key = 0xf & | 2299 | /* no status or recovered error */ |
| 2245 | cmd->err_info->SenseInfo[2]; | 2300 | if ((sense_key == 0x0) || (sense_key == 0x1)) { |
| 2246 | /* no status or recovered error */ | 2301 | status = 1; |
| 2247 | if((sense_key == 0x0) || | ||
| 2248 | (sense_key == 0x1)) | ||
| 2249 | { | ||
| 2250 | status = 1; | ||
| 2251 | } | ||
| 2252 | } else | ||
| 2253 | { | ||
| 2254 | printk(KERN_WARNING "cciss: cmd %p " | ||
| 2255 | "has SCSI Status 0x%x\n", | ||
| 2256 | cmd, cmd->err_info->ScsiStatus); | ||
| 2257 | } | 2302 | } |
| 2303 | } else { | ||
| 2304 | printk(KERN_WARNING "cciss: cmd %p " | ||
| 2305 | "has SCSI Status 0x%x\n", | ||
| 2306 | cmd, cmd->err_info->ScsiStatus); | ||
| 2307 | } | ||
| 2258 | break; | 2308 | break; |
| 2259 | case CMD_DATA_UNDERRUN: | 2309 | case CMD_DATA_UNDERRUN: |
| 2260 | printk(KERN_WARNING "cciss: cmd %p has" | 2310 | printk(KERN_WARNING "cciss: cmd %p has" |
| 2261 | " completed with data underrun " | 2311 | " completed with data underrun " |
| 2262 | "reported\n", cmd); | 2312 | "reported\n", cmd); |
| 2263 | break; | 2313 | break; |
| 2264 | case CMD_DATA_OVERRUN: | 2314 | case CMD_DATA_OVERRUN: |
| 2265 | printk(KERN_WARNING "cciss: cmd %p has" | 2315 | printk(KERN_WARNING "cciss: cmd %p has" |
| 2266 | " completed with data overrun " | 2316 | " completed with data overrun " |
| 2267 | "reported\n", cmd); | 2317 | "reported\n", cmd); |
| 2268 | break; | 2318 | break; |
| 2269 | case CMD_INVALID: | 2319 | case CMD_INVALID: |
| 2270 | printk(KERN_WARNING "cciss: cmd %p is " | 2320 | printk(KERN_WARNING "cciss: cmd %p is " |
| 2271 | "reported invalid\n", cmd); | 2321 | "reported invalid\n", cmd); |
| 2272 | status = 0; | 2322 | status = 0; |
| 2273 | break; | 2323 | break; |
| 2274 | case CMD_PROTOCOL_ERR: | 2324 | case CMD_PROTOCOL_ERR: |
| 2275 | printk(KERN_WARNING "cciss: cmd %p has " | 2325 | printk(KERN_WARNING "cciss: cmd %p has " |
| 2276 | "protocol error \n", cmd); | 2326 | "protocol error \n", cmd); |
| 2277 | status = 0; | 2327 | status = 0; |
| 2278 | break; | ||
| 2279 | case CMD_HARDWARE_ERR: | ||
| 2280 | printk(KERN_WARNING "cciss: cmd %p had " | ||
| 2281 | " hardware error\n", cmd); | ||
| 2282 | status = 0; | ||
| 2283 | break; | ||
| 2284 | case CMD_CONNECTION_LOST: | ||
| 2285 | printk(KERN_WARNING "cciss: cmd %p had " | ||
| 2286 | "connection lost\n", cmd); | ||
| 2287 | status=0; | ||
| 2288 | break; | 2328 | break; |
| 2289 | case CMD_ABORTED: | 2329 | case CMD_HARDWARE_ERR: |
| 2290 | printk(KERN_WARNING "cciss: cmd %p was " | 2330 | printk(KERN_WARNING "cciss: cmd %p had " |
| 2291 | "aborted\n", cmd); | 2331 | " hardware error\n", cmd); |
| 2292 | status=0; | 2332 | status = 0; |
| 2293 | break; | 2333 | break; |
| 2294 | case CMD_ABORT_FAILED: | 2334 | case CMD_CONNECTION_LOST: |
| 2295 | printk(KERN_WARNING "cciss: cmd %p reports " | 2335 | printk(KERN_WARNING "cciss: cmd %p had " |
| 2296 | "abort failed\n", cmd); | 2336 | "connection lost\n", cmd); |
| 2297 | status=0; | 2337 | status = 0; |
| 2298 | break; | 2338 | break; |
| 2299 | case CMD_UNSOLICITED_ABORT: | 2339 | case CMD_ABORTED: |
| 2300 | printk(KERN_WARNING "cciss%d: unsolicited " | 2340 | printk(KERN_WARNING "cciss: cmd %p was " |
| 2301 | "abort %p\n", h->ctlr, cmd); | 2341 | "aborted\n", cmd); |
| 2302 | if (cmd->retry_count < MAX_CMD_RETRIES) { | 2342 | status = 0; |
| 2303 | retry_cmd=1; | ||
| 2304 | printk(KERN_WARNING | ||
| 2305 | "cciss%d: retrying %p\n", | ||
| 2306 | h->ctlr, cmd); | ||
| 2307 | cmd->retry_count++; | ||
| 2308 | } else | ||
| 2309 | printk(KERN_WARNING | ||
| 2310 | "cciss%d: %p retried too " | ||
| 2311 | "many times\n", h->ctlr, cmd); | ||
| 2312 | status=0; | ||
| 2313 | break; | 2343 | break; |
| 2314 | case CMD_TIMEOUT: | 2344 | case CMD_ABORT_FAILED: |
| 2315 | printk(KERN_WARNING "cciss: cmd %p timedout\n", | 2345 | printk(KERN_WARNING "cciss: cmd %p reports " |
| 2316 | cmd); | 2346 | "abort failed\n", cmd); |
| 2317 | status=0; | 2347 | status = 0; |
| 2318 | break; | 2348 | break; |
| 2319 | default: | 2349 | case CMD_UNSOLICITED_ABORT: |
| 2320 | printk(KERN_WARNING "cciss: cmd %p returned " | 2350 | printk(KERN_WARNING "cciss%d: unsolicited " |
| 2321 | "unknown status %x\n", cmd, | 2351 | "abort %p\n", h->ctlr, cmd); |
| 2322 | cmd->err_info->CommandStatus); | 2352 | if (cmd->retry_count < MAX_CMD_RETRIES) { |
| 2323 | status=0; | 2353 | retry_cmd = 1; |
| 2354 | printk(KERN_WARNING | ||
| 2355 | "cciss%d: retrying %p\n", h->ctlr, cmd); | ||
| 2356 | cmd->retry_count++; | ||
| 2357 | } else | ||
| 2358 | printk(KERN_WARNING | ||
| 2359 | "cciss%d: %p retried too " | ||
| 2360 | "many times\n", h->ctlr, cmd); | ||
| 2361 | status = 0; | ||
| 2362 | break; | ||
| 2363 | case CMD_TIMEOUT: | ||
| 2364 | printk(KERN_WARNING "cciss: cmd %p timedout\n", cmd); | ||
| 2365 | status = 0; | ||
| 2366 | break; | ||
| 2367 | default: | ||
| 2368 | printk(KERN_WARNING "cciss: cmd %p returned " | ||
| 2369 | "unknown status %x\n", cmd, | ||
| 2370 | cmd->err_info->CommandStatus); | ||
| 2371 | status = 0; | ||
| 2324 | } | 2372 | } |
| 2325 | } | 2373 | } |
| 2326 | /* We need to return this command */ | 2374 | /* We need to return this command */ |
| 2327 | if(retry_cmd) { | 2375 | if (retry_cmd) { |
| 2328 | resend_cciss_cmd(h,cmd); | 2376 | resend_cciss_cmd(h, cmd); |
| 2329 | return; | 2377 | return; |
| 2330 | } | 2378 | } |
| 2331 | 2379 | ||
| 2332 | cmd->rq->completion_data = cmd; | 2380 | cmd->rq->completion_data = cmd; |
| 2333 | cmd->rq->errors = status; | 2381 | cmd->rq->errors = status; |
| @@ -2335,12 +2383,12 @@ static inline void complete_command( ctlr_info_t *h, CommandList_struct *cmd, | |||
| 2335 | blk_complete_request(cmd->rq); | 2383 | blk_complete_request(cmd->rq); |
| 2336 | } | 2384 | } |
| 2337 | 2385 | ||
| 2338 | /* | 2386 | /* |
| 2339 | * Get a request and submit it to the controller. | 2387 | * Get a request and submit it to the controller. |
| 2340 | */ | 2388 | */ |
| 2341 | static void do_cciss_request(request_queue_t *q) | 2389 | static void do_cciss_request(request_queue_t *q) |
| 2342 | { | 2390 | { |
| 2343 | ctlr_info_t *h= q->queuedata; | 2391 | ctlr_info_t *h = q->queuedata; |
| 2344 | CommandList_struct *c; | 2392 | CommandList_struct *c; |
| 2345 | int start_blk, seg; | 2393 | int start_blk, seg; |
| 2346 | struct request *creq; | 2394 | struct request *creq; |
| @@ -2351,18 +2399,18 @@ static void do_cciss_request(request_queue_t *q) | |||
| 2351 | 2399 | ||
| 2352 | /* We call start_io here in case there is a command waiting on the | 2400 | /* We call start_io here in case there is a command waiting on the |
| 2353 | * queue that has not been sent. | 2401 | * queue that has not been sent. |
| 2354 | */ | 2402 | */ |
| 2355 | if (blk_queue_plugged(q)) | 2403 | if (blk_queue_plugged(q)) |
| 2356 | goto startio; | 2404 | goto startio; |
| 2357 | 2405 | ||
| 2358 | queue: | 2406 | queue: |
| 2359 | creq = elv_next_request(q); | 2407 | creq = elv_next_request(q); |
| 2360 | if (!creq) | 2408 | if (!creq) |
| 2361 | goto startio; | 2409 | goto startio; |
| 2362 | 2410 | ||
| 2363 | BUG_ON(creq->nr_phys_segments > MAXSGENTRIES); | 2411 | BUG_ON(creq->nr_phys_segments > MAXSGENTRIES); |
| 2364 | 2412 | ||
| 2365 | if (( c = cmd_alloc(h, 1)) == NULL) | 2413 | if ((c = cmd_alloc(h, 1)) == NULL) |
| 2366 | goto full; | 2414 | goto full; |
| 2367 | 2415 | ||
| 2368 | blkdev_dequeue_request(creq); | 2416 | blkdev_dequeue_request(creq); |
| @@ -2371,81 +2419,82 @@ queue: | |||
| 2371 | 2419 | ||
| 2372 | c->cmd_type = CMD_RWREQ; | 2420 | c->cmd_type = CMD_RWREQ; |
| 2373 | c->rq = creq; | 2421 | c->rq = creq; |
| 2374 | 2422 | ||
| 2375 | /* fill in the request */ | 2423 | /* fill in the request */ |
| 2376 | drv = creq->rq_disk->private_data; | 2424 | drv = creq->rq_disk->private_data; |
| 2377 | c->Header.ReplyQueue = 0; // unused in simple mode | 2425 | c->Header.ReplyQueue = 0; // unused in simple mode |
| 2378 | /* got command from pool, so use the command block index instead */ | 2426 | /* got command from pool, so use the command block index instead */ |
| 2379 | /* for direct lookups. */ | 2427 | /* for direct lookups. */ |
| 2380 | /* The first 2 bits are reserved for controller error reporting. */ | 2428 | /* The first 2 bits are reserved for controller error reporting. */ |
| 2381 | c->Header.Tag.lower = (c->cmdindex << 3); | 2429 | c->Header.Tag.lower = (c->cmdindex << 3); |
| 2382 | c->Header.Tag.lower |= 0x04; /* flag for direct lookup. */ | 2430 | c->Header.Tag.lower |= 0x04; /* flag for direct lookup. */ |
| 2383 | c->Header.LUN.LogDev.VolId= drv->LunID; | 2431 | c->Header.LUN.LogDev.VolId = drv->LunID; |
| 2384 | c->Header.LUN.LogDev.Mode = 1; | 2432 | c->Header.LUN.LogDev.Mode = 1; |
| 2385 | c->Request.CDBLen = 10; // 12 byte commands not in FW yet; | 2433 | c->Request.CDBLen = 10; // 12 byte commands not in FW yet; |
| 2386 | c->Request.Type.Type = TYPE_CMD; // It is a command. | 2434 | c->Request.Type.Type = TYPE_CMD; // It is a command. |
| 2387 | c->Request.Type.Attribute = ATTR_SIMPLE; | 2435 | c->Request.Type.Attribute = ATTR_SIMPLE; |
| 2388 | c->Request.Type.Direction = | 2436 | c->Request.Type.Direction = |
| 2389 | (rq_data_dir(creq) == READ) ? XFER_READ: XFER_WRITE; | 2437 | (rq_data_dir(creq) == READ) ? XFER_READ : XFER_WRITE; |
| 2390 | c->Request.Timeout = 0; // Don't time out | 2438 | c->Request.Timeout = 0; // Don't time out |
| 2391 | c->Request.CDB[0] = (rq_data_dir(creq) == READ) ? CCISS_READ : CCISS_WRITE; | 2439 | c->Request.CDB[0] = |
| 2440 | (rq_data_dir(creq) == READ) ? CCISS_READ : CCISS_WRITE; | ||
| 2392 | start_blk = creq->sector; | 2441 | start_blk = creq->sector; |
| 2393 | #ifdef CCISS_DEBUG | 2442 | #ifdef CCISS_DEBUG |
| 2394 | printk(KERN_DEBUG "ciss: sector =%d nr_sectors=%d\n",(int) creq->sector, | 2443 | printk(KERN_DEBUG "ciss: sector =%d nr_sectors=%d\n", (int)creq->sector, |
| 2395 | (int) creq->nr_sectors); | 2444 | (int)creq->nr_sectors); |
| 2396 | #endif /* CCISS_DEBUG */ | 2445 | #endif /* CCISS_DEBUG */ |
| 2397 | 2446 | ||
| 2398 | seg = blk_rq_map_sg(q, creq, tmp_sg); | 2447 | seg = blk_rq_map_sg(q, creq, tmp_sg); |
| 2399 | 2448 | ||
| 2400 | /* get the DMA records for the setup */ | 2449 | /* get the DMA records for the setup */ |
| 2401 | if (c->Request.Type.Direction == XFER_READ) | 2450 | if (c->Request.Type.Direction == XFER_READ) |
| 2402 | dir = PCI_DMA_FROMDEVICE; | 2451 | dir = PCI_DMA_FROMDEVICE; |
| 2403 | else | 2452 | else |
| 2404 | dir = PCI_DMA_TODEVICE; | 2453 | dir = PCI_DMA_TODEVICE; |
| 2405 | 2454 | ||
| 2406 | for (i=0; i<seg; i++) | 2455 | for (i = 0; i < seg; i++) { |
| 2407 | { | ||
| 2408 | c->SG[i].Len = tmp_sg[i].length; | 2456 | c->SG[i].Len = tmp_sg[i].length; |
| 2409 | temp64.val = (__u64) pci_map_page(h->pdev, tmp_sg[i].page, | 2457 | temp64.val = (__u64) pci_map_page(h->pdev, tmp_sg[i].page, |
| 2410 | tmp_sg[i].offset, tmp_sg[i].length, | 2458 | tmp_sg[i].offset, |
| 2411 | dir); | 2459 | tmp_sg[i].length, dir); |
| 2412 | c->SG[i].Addr.lower = temp64.val32.lower; | 2460 | c->SG[i].Addr.lower = temp64.val32.lower; |
| 2413 | c->SG[i].Addr.upper = temp64.val32.upper; | 2461 | c->SG[i].Addr.upper = temp64.val32.upper; |
| 2414 | c->SG[i].Ext = 0; // we are not chaining | 2462 | c->SG[i].Ext = 0; // we are not chaining |
| 2415 | } | 2463 | } |
| 2416 | /* track how many SG entries we are using */ | 2464 | /* track how many SG entries we are using */ |
| 2417 | if( seg > h->maxSG) | 2465 | if (seg > h->maxSG) |
| 2418 | h->maxSG = seg; | 2466 | h->maxSG = seg; |
| 2419 | 2467 | ||
| 2420 | #ifdef CCISS_DEBUG | 2468 | #ifdef CCISS_DEBUG |
| 2421 | printk(KERN_DEBUG "cciss: Submitting %d sectors in %d segments\n", creq->nr_sectors, seg); | 2469 | printk(KERN_DEBUG "cciss: Submitting %d sectors in %d segments\n", |
| 2422 | #endif /* CCISS_DEBUG */ | 2470 | creq->nr_sectors, seg); |
| 2471 | #endif /* CCISS_DEBUG */ | ||
| 2423 | 2472 | ||
| 2424 | c->Header.SGList = c->Header.SGTotal = seg; | 2473 | c->Header.SGList = c->Header.SGTotal = seg; |
| 2425 | c->Request.CDB[1]= 0; | 2474 | c->Request.CDB[1] = 0; |
| 2426 | c->Request.CDB[2]= (start_blk >> 24) & 0xff; //MSB | 2475 | c->Request.CDB[2] = (start_blk >> 24) & 0xff; //MSB |
| 2427 | c->Request.CDB[3]= (start_blk >> 16) & 0xff; | 2476 | c->Request.CDB[3] = (start_blk >> 16) & 0xff; |
| 2428 | c->Request.CDB[4]= (start_blk >> 8) & 0xff; | 2477 | c->Request.CDB[4] = (start_blk >> 8) & 0xff; |
| 2429 | c->Request.CDB[5]= start_blk & 0xff; | 2478 | c->Request.CDB[5] = start_blk & 0xff; |
| 2430 | c->Request.CDB[6]= 0; // (sect >> 24) & 0xff; MSB | 2479 | c->Request.CDB[6] = 0; // (sect >> 24) & 0xff; MSB |
| 2431 | c->Request.CDB[7]= (creq->nr_sectors >> 8) & 0xff; | 2480 | c->Request.CDB[7] = (creq->nr_sectors >> 8) & 0xff; |
| 2432 | c->Request.CDB[8]= creq->nr_sectors & 0xff; | 2481 | c->Request.CDB[8] = creq->nr_sectors & 0xff; |
| 2433 | c->Request.CDB[9] = c->Request.CDB[11] = c->Request.CDB[12] = 0; | 2482 | c->Request.CDB[9] = c->Request.CDB[11] = c->Request.CDB[12] = 0; |
| 2434 | 2483 | ||
| 2435 | spin_lock_irq(q->queue_lock); | 2484 | spin_lock_irq(q->queue_lock); |
| 2436 | 2485 | ||
| 2437 | addQ(&(h->reqQ),c); | 2486 | addQ(&(h->reqQ), c); |
| 2438 | h->Qdepth++; | 2487 | h->Qdepth++; |
| 2439 | if(h->Qdepth > h->maxQsinceinit) | 2488 | if (h->Qdepth > h->maxQsinceinit) |
| 2440 | h->maxQsinceinit = h->Qdepth; | 2489 | h->maxQsinceinit = h->Qdepth; |
| 2441 | 2490 | ||
| 2442 | goto queue; | 2491 | goto queue; |
| 2443 | full: | 2492 | full: |
| 2444 | blk_stop_queue(q); | 2493 | blk_stop_queue(q); |
| 2445 | startio: | 2494 | startio: |
| 2446 | /* We will already have the driver lock here so not need | 2495 | /* We will already have the driver lock here so not need |
| 2447 | * to lock it. | 2496 | * to lock it. |
| 2448 | */ | 2497 | */ |
| 2449 | start_io(h); | 2498 | start_io(h); |
| 2450 | } | 2499 | } |
| 2451 | 2500 | ||
| @@ -2472,7 +2521,7 @@ static inline unsigned long get_next_completion(ctlr_info_t *h) | |||
| 2472 | static inline int interrupt_pending(ctlr_info_t *h) | 2521 | static inline int interrupt_pending(ctlr_info_t *h) |
| 2473 | { | 2522 | { |
| 2474 | #ifdef CONFIG_CISS_SCSI_TAPE | 2523 | #ifdef CONFIG_CISS_SCSI_TAPE |
| 2475 | return ( h->access.intr_pending(h) | 2524 | return (h->access.intr_pending(h) |
| 2476 | || (h->scsi_rejects.ncompletions > 0)); | 2525 | || (h->scsi_rejects.ncompletions > 0)); |
| 2477 | #else | 2526 | #else |
| 2478 | return h->access.intr_pending(h); | 2527 | return h->access.intr_pending(h); |
| @@ -2482,11 +2531,11 @@ static inline int interrupt_pending(ctlr_info_t *h) | |||
| 2482 | static inline long interrupt_not_for_us(ctlr_info_t *h) | 2531 | static inline long interrupt_not_for_us(ctlr_info_t *h) |
| 2483 | { | 2532 | { |
| 2484 | #ifdef CONFIG_CISS_SCSI_TAPE | 2533 | #ifdef CONFIG_CISS_SCSI_TAPE |
| 2485 | return (((h->access.intr_pending(h) == 0) || | 2534 | return (((h->access.intr_pending(h) == 0) || |
| 2486 | (h->interrupts_enabled == 0)) | 2535 | (h->interrupts_enabled == 0)) |
| 2487 | && (h->scsi_rejects.ncompletions == 0)); | 2536 | && (h->scsi_rejects.ncompletions == 0)); |
| 2488 | #else | 2537 | #else |
| 2489 | return (((h->access.intr_pending(h) == 0) || | 2538 | return (((h->access.intr_pending(h) == 0) || |
| 2490 | (h->interrupts_enabled == 0))); | 2539 | (h->interrupts_enabled == 0))); |
| 2491 | #endif | 2540 | #endif |
| 2492 | } | 2541 | } |
| @@ -2508,12 +2557,14 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs) | |||
| 2508 | */ | 2557 | */ |
| 2509 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | 2558 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); |
| 2510 | while (interrupt_pending(h)) { | 2559 | while (interrupt_pending(h)) { |
| 2511 | while((a = get_next_completion(h)) != FIFO_EMPTY) { | 2560 | while ((a = get_next_completion(h)) != FIFO_EMPTY) { |
| 2512 | a1 = a; | 2561 | a1 = a; |
| 2513 | if ((a & 0x04)) { | 2562 | if ((a & 0x04)) { |
| 2514 | a2 = (a >> 3); | 2563 | a2 = (a >> 3); |
| 2515 | if (a2 >= NR_CMDS) { | 2564 | if (a2 >= NR_CMDS) { |
| 2516 | printk(KERN_WARNING "cciss: controller cciss%d failed, stopping.\n", h->ctlr); | 2565 | printk(KERN_WARNING |
| 2566 | "cciss: controller cciss%d failed, stopping.\n", | ||
| 2567 | h->ctlr); | ||
| 2517 | fail_all_cmds(h->ctlr); | 2568 | fail_all_cmds(h->ctlr); |
| 2518 | return IRQ_HANDLED; | 2569 | return IRQ_HANDLED; |
| 2519 | } | 2570 | } |
| @@ -2522,22 +2573,24 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs) | |||
| 2522 | a = c->busaddr; | 2573 | a = c->busaddr; |
| 2523 | 2574 | ||
| 2524 | } else { | 2575 | } else { |
| 2525 | a &= ~3; | 2576 | a &= ~3; |
| 2526 | if ((c = h->cmpQ) == NULL) { | 2577 | if ((c = h->cmpQ) == NULL) { |
| 2527 | printk(KERN_WARNING "cciss: Completion of %08x ignored\n", a1); | 2578 | printk(KERN_WARNING |
| 2528 | continue; | 2579 | "cciss: Completion of %08x ignored\n", |
| 2529 | } | 2580 | a1); |
| 2530 | while(c->busaddr != a) { | 2581 | continue; |
| 2531 | c = c->next; | 2582 | } |
| 2532 | if (c == h->cmpQ) | 2583 | while (c->busaddr != a) { |
| 2533 | break; | 2584 | c = c->next; |
| 2534 | } | 2585 | if (c == h->cmpQ) |
| 2586 | break; | ||
| 2587 | } | ||
| 2535 | } | 2588 | } |
| 2536 | /* | 2589 | /* |
| 2537 | * If we've found the command, take it off the | 2590 | * If we've found the command, take it off the |
| 2538 | * completion Q and free it | 2591 | * completion Q and free it |
| 2539 | */ | 2592 | */ |
| 2540 | if (c->busaddr == a) { | 2593 | if (c->busaddr == a) { |
| 2541 | removeQ(&h->cmpQ, c); | 2594 | removeQ(&h->cmpQ, c); |
| 2542 | if (c->cmd_type == CMD_RWREQ) { | 2595 | if (c->cmd_type == CMD_RWREQ) { |
| 2543 | complete_command(h, c, 0); | 2596 | complete_command(h, c, 0); |
| @@ -2553,120 +2606,118 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs) | |||
| 2553 | } | 2606 | } |
| 2554 | } | 2607 | } |
| 2555 | 2608 | ||
| 2556 | /* check to see if we have maxed out the number of commands that can | 2609 | /* check to see if we have maxed out the number of commands that can |
| 2557 | * be placed on the queue. If so then exit. We do this check here | 2610 | * be placed on the queue. If so then exit. We do this check here |
| 2558 | * in case the interrupt we serviced was from an ioctl and did not | 2611 | * in case the interrupt we serviced was from an ioctl and did not |
| 2559 | * free any new commands. | 2612 | * free any new commands. |
| 2613 | */ | ||
| 2614 | if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS) | ||
| 2615 | goto cleanup; | ||
| 2616 | |||
| 2617 | /* We have room on the queue for more commands. Now we need to queue | ||
| 2618 | * them up. We will also keep track of the next queue to run so | ||
| 2619 | * that every queue gets a chance to be started first. | ||
| 2560 | */ | 2620 | */ |
| 2561 | if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS) | 2621 | for (j = 0; j < h->highest_lun + 1; j++) { |
| 2562 | goto cleanup; | ||
| 2563 | |||
| 2564 | /* We have room on the queue for more commands. Now we need to queue | ||
| 2565 | * them up. We will also keep track of the next queue to run so | ||
| 2566 | * that every queue gets a chance to be started first. | ||
| 2567 | */ | ||
| 2568 | for (j=0; j < h->highest_lun + 1; j++){ | ||
| 2569 | int curr_queue = (start_queue + j) % (h->highest_lun + 1); | 2622 | int curr_queue = (start_queue + j) % (h->highest_lun + 1); |
| 2570 | /* make sure the disk has been added and the drive is real | 2623 | /* make sure the disk has been added and the drive is real |
| 2571 | * because this can be called from the middle of init_one. | 2624 | * because this can be called from the middle of init_one. |
| 2572 | */ | 2625 | */ |
| 2573 | if(!(h->drv[curr_queue].queue) || | 2626 | if (!(h->drv[curr_queue].queue) || !(h->drv[curr_queue].heads)) |
| 2574 | !(h->drv[curr_queue].heads)) | 2627 | continue; |
| 2575 | continue; | 2628 | blk_start_queue(h->gendisk[curr_queue]->queue); |
| 2576 | blk_start_queue(h->gendisk[curr_queue]->queue); | 2629 | |
| 2577 | 2630 | /* check to see if we have maxed out the number of commands | |
| 2578 | /* check to see if we have maxed out the number of commands | 2631 | * that can be placed on the queue. |
| 2579 | * that can be placed on the queue. | 2632 | */ |
| 2580 | */ | 2633 | if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS) { |
| 2581 | if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS) | 2634 | if (curr_queue == start_queue) { |
| 2582 | { | 2635 | h->next_to_run = |
| 2583 | if (curr_queue == start_queue){ | 2636 | (start_queue + 1) % (h->highest_lun + 1); |
| 2584 | h->next_to_run = (start_queue + 1) % (h->highest_lun + 1); | 2637 | goto cleanup; |
| 2585 | goto cleanup; | 2638 | } else { |
| 2586 | } else { | 2639 | h->next_to_run = curr_queue; |
| 2587 | h->next_to_run = curr_queue; | 2640 | goto cleanup; |
| 2588 | goto cleanup; | 2641 | } |
| 2589 | } | 2642 | } else { |
| 2590 | } else { | ||
| 2591 | curr_queue = (curr_queue + 1) % (h->highest_lun + 1); | 2643 | curr_queue = (curr_queue + 1) % (h->highest_lun + 1); |
| 2592 | } | 2644 | } |
| 2593 | } | 2645 | } |
| 2594 | 2646 | ||
| 2595 | cleanup: | 2647 | cleanup: |
| 2596 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | 2648 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); |
| 2597 | return IRQ_HANDLED; | 2649 | return IRQ_HANDLED; |
| 2598 | } | 2650 | } |
| 2599 | /* | 2651 | |
| 2652 | /* | ||
| 2600 | * We cannot read the structure directly, for portability we must use | 2653 | * We cannot read the structure directly, for portability we must use |
| 2601 | * the io functions. | 2654 | * the io functions. |
| 2602 | * This is for debug only. | 2655 | * This is for debug only. |
| 2603 | */ | 2656 | */ |
| 2604 | #ifdef CCISS_DEBUG | 2657 | #ifdef CCISS_DEBUG |
| 2605 | static void print_cfg_table( CfgTable_struct *tb) | 2658 | static void print_cfg_table(CfgTable_struct *tb) |
| 2606 | { | 2659 | { |
| 2607 | int i; | 2660 | int i; |
| 2608 | char temp_name[17]; | 2661 | char temp_name[17]; |
| 2609 | 2662 | ||
| 2610 | printk("Controller Configuration information\n"); | 2663 | printk("Controller Configuration information\n"); |
| 2611 | printk("------------------------------------\n"); | 2664 | printk("------------------------------------\n"); |
| 2612 | for(i=0;i<4;i++) | 2665 | for (i = 0; i < 4; i++) |
| 2613 | temp_name[i] = readb(&(tb->Signature[i])); | 2666 | temp_name[i] = readb(&(tb->Signature[i])); |
| 2614 | temp_name[4]='\0'; | 2667 | temp_name[4] = '\0'; |
| 2615 | printk(" Signature = %s\n", temp_name); | 2668 | printk(" Signature = %s\n", temp_name); |
| 2616 | printk(" Spec Number = %d\n", readl(&(tb->SpecValence))); | 2669 | printk(" Spec Number = %d\n", readl(&(tb->SpecValence))); |
| 2617 | printk(" Transport methods supported = 0x%x\n", | 2670 | printk(" Transport methods supported = 0x%x\n", |
| 2618 | readl(&(tb-> TransportSupport))); | 2671 | readl(&(tb->TransportSupport))); |
| 2619 | printk(" Transport methods active = 0x%x\n", | 2672 | printk(" Transport methods active = 0x%x\n", |
| 2620 | readl(&(tb->TransportActive))); | 2673 | readl(&(tb->TransportActive))); |
| 2621 | printk(" Requested transport Method = 0x%x\n", | 2674 | printk(" Requested transport Method = 0x%x\n", |
| 2622 | readl(&(tb->HostWrite.TransportRequest))); | 2675 | readl(&(tb->HostWrite.TransportRequest))); |
| 2623 | printk(" Coalesce Interrupt Delay = 0x%x\n", | 2676 | printk(" Coalesce Interrupt Delay = 0x%x\n", |
| 2624 | readl(&(tb->HostWrite.CoalIntDelay))); | 2677 | readl(&(tb->HostWrite.CoalIntDelay))); |
| 2625 | printk(" Coalesce Interrupt Count = 0x%x\n", | 2678 | printk(" Coalesce Interrupt Count = 0x%x\n", |
| 2626 | readl(&(tb->HostWrite.CoalIntCount))); | 2679 | readl(&(tb->HostWrite.CoalIntCount))); |
| 2627 | printk(" Max outstanding commands = 0x%d\n", | 2680 | printk(" Max outstanding commands = 0x%d\n", |
| 2628 | readl(&(tb->CmdsOutMax))); | 2681 | readl(&(tb->CmdsOutMax))); |
| 2629 | printk(" Bus Types = 0x%x\n", readl(&(tb-> BusTypes))); | 2682 | printk(" Bus Types = 0x%x\n", readl(&(tb->BusTypes))); |
| 2630 | for(i=0;i<16;i++) | 2683 | for (i = 0; i < 16; i++) |
| 2631 | temp_name[i] = readb(&(tb->ServerName[i])); | 2684 | temp_name[i] = readb(&(tb->ServerName[i])); |
| 2632 | temp_name[16] = '\0'; | 2685 | temp_name[16] = '\0'; |
| 2633 | printk(" Server Name = %s\n", temp_name); | 2686 | printk(" Server Name = %s\n", temp_name); |
| 2634 | printk(" Heartbeat Counter = 0x%x\n\n\n", | 2687 | printk(" Heartbeat Counter = 0x%x\n\n\n", readl(&(tb->HeartBeat))); |
| 2635 | readl(&(tb->HeartBeat))); | ||
| 2636 | } | 2688 | } |
| 2637 | #endif /* CCISS_DEBUG */ | 2689 | #endif /* CCISS_DEBUG */ |
| 2638 | 2690 | ||
| 2639 | static int find_PCI_BAR_index(struct pci_dev *pdev, | 2691 | static int find_PCI_BAR_index(struct pci_dev *pdev, unsigned long pci_bar_addr) |
| 2640 | unsigned long pci_bar_addr) | ||
| 2641 | { | 2692 | { |
| 2642 | int i, offset, mem_type, bar_type; | 2693 | int i, offset, mem_type, bar_type; |
| 2643 | if (pci_bar_addr == PCI_BASE_ADDRESS_0) /* looking for BAR zero? */ | 2694 | if (pci_bar_addr == PCI_BASE_ADDRESS_0) /* looking for BAR zero? */ |
| 2644 | return 0; | 2695 | return 0; |
| 2645 | offset = 0; | 2696 | offset = 0; |
| 2646 | for (i=0; i<DEVICE_COUNT_RESOURCE; i++) { | 2697 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { |
| 2647 | bar_type = pci_resource_flags(pdev, i) & | 2698 | bar_type = pci_resource_flags(pdev, i) & PCI_BASE_ADDRESS_SPACE; |
| 2648 | PCI_BASE_ADDRESS_SPACE; | ||
| 2649 | if (bar_type == PCI_BASE_ADDRESS_SPACE_IO) | 2699 | if (bar_type == PCI_BASE_ADDRESS_SPACE_IO) |
| 2650 | offset += 4; | 2700 | offset += 4; |
| 2651 | else { | 2701 | else { |
| 2652 | mem_type = pci_resource_flags(pdev, i) & | 2702 | mem_type = pci_resource_flags(pdev, i) & |
| 2653 | PCI_BASE_ADDRESS_MEM_TYPE_MASK; | 2703 | PCI_BASE_ADDRESS_MEM_TYPE_MASK; |
| 2654 | switch (mem_type) { | 2704 | switch (mem_type) { |
| 2655 | case PCI_BASE_ADDRESS_MEM_TYPE_32: | 2705 | case PCI_BASE_ADDRESS_MEM_TYPE_32: |
| 2656 | case PCI_BASE_ADDRESS_MEM_TYPE_1M: | 2706 | case PCI_BASE_ADDRESS_MEM_TYPE_1M: |
| 2657 | offset += 4; /* 32 bit */ | 2707 | offset += 4; /* 32 bit */ |
| 2658 | break; | 2708 | break; |
| 2659 | case PCI_BASE_ADDRESS_MEM_TYPE_64: | 2709 | case PCI_BASE_ADDRESS_MEM_TYPE_64: |
| 2660 | offset += 8; | 2710 | offset += 8; |
| 2661 | break; | 2711 | break; |
| 2662 | default: /* reserved in PCI 2.2 */ | 2712 | default: /* reserved in PCI 2.2 */ |
| 2663 | printk(KERN_WARNING "Base address is invalid\n"); | 2713 | printk(KERN_WARNING |
| 2664 | return -1; | 2714 | "Base address is invalid\n"); |
| 2715 | return -1; | ||
| 2665 | break; | 2716 | break; |
| 2666 | } | 2717 | } |
| 2667 | } | 2718 | } |
| 2668 | if (offset == pci_bar_addr - PCI_BASE_ADDRESS_0) | 2719 | if (offset == pci_bar_addr - PCI_BASE_ADDRESS_0) |
| 2669 | return i+1; | 2720 | return i + 1; |
| 2670 | } | 2721 | } |
| 2671 | return -1; | 2722 | return -1; |
| 2672 | } | 2723 | } |
| @@ -2675,53 +2726,54 @@ static int find_PCI_BAR_index(struct pci_dev *pdev, | |||
| 2675 | * controllers that are capable. If not, we use IO-APIC mode. | 2726 | * controllers that are capable. If not, we use IO-APIC mode. |
| 2676 | */ | 2727 | */ |
| 2677 | 2728 | ||
| 2678 | static void __devinit cciss_interrupt_mode(ctlr_info_t *c, struct pci_dev *pdev, __u32 board_id) | 2729 | static void __devinit cciss_interrupt_mode(ctlr_info_t *c, |
| 2730 | struct pci_dev *pdev, __u32 board_id) | ||
| 2679 | { | 2731 | { |
| 2680 | #ifdef CONFIG_PCI_MSI | 2732 | #ifdef CONFIG_PCI_MSI |
| 2681 | int err; | 2733 | int err; |
| 2682 | struct msix_entry cciss_msix_entries[4] = {{0,0}, {0,1}, | 2734 | struct msix_entry cciss_msix_entries[4] = { {0, 0}, {0, 1}, |
| 2683 | {0,2}, {0,3}}; | 2735 | {0, 2}, {0, 3} |
| 2736 | }; | ||
| 2684 | 2737 | ||
| 2685 | /* Some boards advertise MSI but don't really support it */ | 2738 | /* Some boards advertise MSI but don't really support it */ |
| 2686 | if ((board_id == 0x40700E11) || | 2739 | if ((board_id == 0x40700E11) || |
| 2687 | (board_id == 0x40800E11) || | 2740 | (board_id == 0x40800E11) || |
| 2688 | (board_id == 0x40820E11) || | 2741 | (board_id == 0x40820E11) || (board_id == 0x40830E11)) |
| 2689 | (board_id == 0x40830E11)) | ||
| 2690 | goto default_int_mode; | 2742 | goto default_int_mode; |
| 2691 | 2743 | ||
| 2692 | if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) { | 2744 | if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) { |
| 2693 | err = pci_enable_msix(pdev, cciss_msix_entries, 4); | 2745 | err = pci_enable_msix(pdev, cciss_msix_entries, 4); |
| 2694 | if (!err) { | 2746 | if (!err) { |
| 2695 | c->intr[0] = cciss_msix_entries[0].vector; | 2747 | c->intr[0] = cciss_msix_entries[0].vector; |
| 2696 | c->intr[1] = cciss_msix_entries[1].vector; | 2748 | c->intr[1] = cciss_msix_entries[1].vector; |
| 2697 | c->intr[2] = cciss_msix_entries[2].vector; | 2749 | c->intr[2] = cciss_msix_entries[2].vector; |
| 2698 | c->intr[3] = cciss_msix_entries[3].vector; | 2750 | c->intr[3] = cciss_msix_entries[3].vector; |
| 2699 | c->msix_vector = 1; | 2751 | c->msix_vector = 1; |
| 2700 | return; | 2752 | return; |
| 2701 | } | 2753 | } |
| 2702 | if (err > 0) { | 2754 | if (err > 0) { |
| 2703 | printk(KERN_WARNING "cciss: only %d MSI-X vectors " | 2755 | printk(KERN_WARNING "cciss: only %d MSI-X vectors " |
| 2704 | "available\n", err); | 2756 | "available\n", err); |
| 2705 | } else { | 2757 | } else { |
| 2706 | printk(KERN_WARNING "cciss: MSI-X init failed %d\n", | 2758 | printk(KERN_WARNING "cciss: MSI-X init failed %d\n", |
| 2707 | err); | 2759 | err); |
| 2708 | } | 2760 | } |
| 2709 | } | 2761 | } |
| 2710 | if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) { | 2762 | if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) { |
| 2711 | if (!pci_enable_msi(pdev)) { | 2763 | if (!pci_enable_msi(pdev)) { |
| 2712 | c->intr[SIMPLE_MODE_INT] = pdev->irq; | 2764 | c->intr[SIMPLE_MODE_INT] = pdev->irq; |
| 2713 | c->msi_vector = 1; | 2765 | c->msi_vector = 1; |
| 2714 | return; | 2766 | return; |
| 2715 | } else { | 2767 | } else { |
| 2716 | printk(KERN_WARNING "cciss: MSI init failed\n"); | 2768 | printk(KERN_WARNING "cciss: MSI init failed\n"); |
| 2717 | c->intr[SIMPLE_MODE_INT] = pdev->irq; | 2769 | c->intr[SIMPLE_MODE_INT] = pdev->irq; |
| 2718 | return; | 2770 | return; |
| 2719 | } | 2771 | } |
| 2720 | } | 2772 | } |
| 2721 | default_int_mode: | 2773 | default_int_mode: |
| 2722 | #endif /* CONFIG_PCI_MSI */ | 2774 | #endif /* CONFIG_PCI_MSI */ |
| 2723 | /* if we get here we're going to use the default interrupt mode */ | 2775 | /* if we get here we're going to use the default interrupt mode */ |
| 2724 | c->intr[SIMPLE_MODE_INT] = pdev->irq; | 2776 | c->intr[SIMPLE_MODE_INT] = pdev->irq; |
| 2725 | return; | 2777 | return; |
| 2726 | } | 2778 | } |
| 2727 | 2779 | ||
| @@ -2736,16 +2788,15 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) | |||
| 2736 | 2788 | ||
| 2737 | /* check to see if controller has been disabled */ | 2789 | /* check to see if controller has been disabled */ |
| 2738 | /* BEFORE trying to enable it */ | 2790 | /* BEFORE trying to enable it */ |
| 2739 | (void) pci_read_config_word(pdev, PCI_COMMAND,&command); | 2791 | (void)pci_read_config_word(pdev, PCI_COMMAND, &command); |
| 2740 | if(!(command & 0x02)) | 2792 | if (!(command & 0x02)) { |
| 2741 | { | 2793 | printk(KERN_WARNING |
| 2742 | printk(KERN_WARNING "cciss: controller appears to be disabled\n"); | 2794 | "cciss: controller appears to be disabled\n"); |
| 2743 | return -ENODEV; | 2795 | return -ENODEV; |
| 2744 | } | 2796 | } |
| 2745 | 2797 | ||
| 2746 | err = pci_enable_device(pdev); | 2798 | err = pci_enable_device(pdev); |
| 2747 | if (err) | 2799 | if (err) { |
| 2748 | { | ||
| 2749 | printk(KERN_ERR "cciss: Unable to Enable PCI device\n"); | 2800 | printk(KERN_ERR "cciss: Unable to Enable PCI device\n"); |
| 2750 | return err; | 2801 | return err; |
| 2751 | } | 2802 | } |
| @@ -2753,20 +2804,20 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) | |||
| 2753 | err = pci_request_regions(pdev, "cciss"); | 2804 | err = pci_request_regions(pdev, "cciss"); |
| 2754 | if (err) { | 2805 | if (err) { |
| 2755 | printk(KERN_ERR "cciss: Cannot obtain PCI resources, " | 2806 | printk(KERN_ERR "cciss: Cannot obtain PCI resources, " |
| 2756 | "aborting\n"); | 2807 | "aborting\n"); |
| 2757 | goto err_out_disable_pdev; | 2808 | goto err_out_disable_pdev; |
| 2758 | } | 2809 | } |
| 2759 | 2810 | ||
| 2760 | subsystem_vendor_id = pdev->subsystem_vendor; | 2811 | subsystem_vendor_id = pdev->subsystem_vendor; |
| 2761 | subsystem_device_id = pdev->subsystem_device; | 2812 | subsystem_device_id = pdev->subsystem_device; |
| 2762 | board_id = (((__u32) (subsystem_device_id << 16) & 0xffff0000) | | 2813 | board_id = (((__u32) (subsystem_device_id << 16) & 0xffff0000) | |
| 2763 | subsystem_vendor_id); | 2814 | subsystem_vendor_id); |
| 2764 | 2815 | ||
| 2765 | #ifdef CCISS_DEBUG | 2816 | #ifdef CCISS_DEBUG |
| 2766 | printk("command = %x\n", command); | 2817 | printk("command = %x\n", command); |
| 2767 | printk("irq = %x\n", pdev->irq); | 2818 | printk("irq = %x\n", pdev->irq); |
| 2768 | printk("board_id = %x\n", board_id); | 2819 | printk("board_id = %x\n", board_id); |
| 2769 | #endif /* CCISS_DEBUG */ | 2820 | #endif /* CCISS_DEBUG */ |
| 2770 | 2821 | ||
| 2771 | /* If the kernel supports MSI/MSI-X we will try to enable that functionality, | 2822 | /* If the kernel supports MSI/MSI-X we will try to enable that functionality, |
| 2772 | * else we use the IO-APIC interrupt assigned to us by system ROM. | 2823 | * else we use the IO-APIC interrupt assigned to us by system ROM. |
| @@ -2775,23 +2826,23 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) | |||
| 2775 | 2826 | ||
| 2776 | /* | 2827 | /* |
| 2777 | * Memory base addr is first addr , the second points to the config | 2828 | * Memory base addr is first addr , the second points to the config |
| 2778 | * table | 2829 | * table |
| 2779 | */ | 2830 | */ |
| 2780 | 2831 | ||
| 2781 | c->paddr = pci_resource_start(pdev, 0); /* addressing mode bits already removed */ | 2832 | c->paddr = pci_resource_start(pdev, 0); /* addressing mode bits already removed */ |
| 2782 | #ifdef CCISS_DEBUG | 2833 | #ifdef CCISS_DEBUG |
| 2783 | printk("address 0 = %x\n", c->paddr); | 2834 | printk("address 0 = %x\n", c->paddr); |
| 2784 | #endif /* CCISS_DEBUG */ | 2835 | #endif /* CCISS_DEBUG */ |
| 2785 | c->vaddr = remap_pci_mem(c->paddr, 200); | 2836 | c->vaddr = remap_pci_mem(c->paddr, 200); |
| 2786 | 2837 | ||
| 2787 | /* Wait for the board to become ready. (PCI hotplug needs this.) | 2838 | /* Wait for the board to become ready. (PCI hotplug needs this.) |
| 2788 | * We poll for up to 120 secs, once per 100ms. */ | 2839 | * We poll for up to 120 secs, once per 100ms. */ |
| 2789 | for (i=0; i < 1200; i++) { | 2840 | for (i = 0; i < 1200; i++) { |
| 2790 | scratchpad = readl(c->vaddr + SA5_SCRATCHPAD_OFFSET); | 2841 | scratchpad = readl(c->vaddr + SA5_SCRATCHPAD_OFFSET); |
| 2791 | if (scratchpad == CCISS_FIRMWARE_READY) | 2842 | if (scratchpad == CCISS_FIRMWARE_READY) |
| 2792 | break; | 2843 | break; |
| 2793 | set_current_state(TASK_INTERRUPTIBLE); | 2844 | set_current_state(TASK_INTERRUPTIBLE); |
| 2794 | schedule_timeout(HZ / 10); /* wait 100ms */ | 2845 | schedule_timeout(HZ / 10); /* wait 100ms */ |
| 2795 | } | 2846 | } |
| 2796 | if (scratchpad != CCISS_FIRMWARE_READY) { | 2847 | if (scratchpad != CCISS_FIRMWARE_READY) { |
| 2797 | printk(KERN_WARNING "cciss: Board not ready. Timed out.\n"); | 2848 | printk(KERN_WARNING "cciss: Board not ready. Timed out.\n"); |
| @@ -2804,12 +2855,11 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) | |||
| 2804 | cfg_base_addr &= (__u32) 0x0000ffff; | 2855 | cfg_base_addr &= (__u32) 0x0000ffff; |
| 2805 | #ifdef CCISS_DEBUG | 2856 | #ifdef CCISS_DEBUG |
| 2806 | printk("cfg base address = %x\n", cfg_base_addr); | 2857 | printk("cfg base address = %x\n", cfg_base_addr); |
| 2807 | #endif /* CCISS_DEBUG */ | 2858 | #endif /* CCISS_DEBUG */ |
| 2808 | cfg_base_addr_index = | 2859 | cfg_base_addr_index = find_PCI_BAR_index(pdev, cfg_base_addr); |
| 2809 | find_PCI_BAR_index(pdev, cfg_base_addr); | ||
| 2810 | #ifdef CCISS_DEBUG | 2860 | #ifdef CCISS_DEBUG |
| 2811 | printk("cfg base address index = %x\n", cfg_base_addr_index); | 2861 | printk("cfg base address index = %x\n", cfg_base_addr_index); |
| 2812 | #endif /* CCISS_DEBUG */ | 2862 | #endif /* CCISS_DEBUG */ |
| 2813 | if (cfg_base_addr_index == -1) { | 2863 | if (cfg_base_addr_index == -1) { |
| 2814 | printk(KERN_WARNING "cciss: Cannot find cfg_base_addr_index\n"); | 2864 | printk(KERN_WARNING "cciss: Cannot find cfg_base_addr_index\n"); |
| 2815 | err = -ENODEV; | 2865 | err = -ENODEV; |
| @@ -2819,17 +2869,17 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) | |||
| 2819 | cfg_offset = readl(c->vaddr + SA5_CTMEM_OFFSET); | 2869 | cfg_offset = readl(c->vaddr + SA5_CTMEM_OFFSET); |
| 2820 | #ifdef CCISS_DEBUG | 2870 | #ifdef CCISS_DEBUG |
| 2821 | printk("cfg offset = %x\n", cfg_offset); | 2871 | printk("cfg offset = %x\n", cfg_offset); |
| 2822 | #endif /* CCISS_DEBUG */ | 2872 | #endif /* CCISS_DEBUG */ |
| 2823 | c->cfgtable = remap_pci_mem(pci_resource_start(pdev, | 2873 | c->cfgtable = remap_pci_mem(pci_resource_start(pdev, |
| 2824 | cfg_base_addr_index) + cfg_offset, | 2874 | cfg_base_addr_index) + |
| 2825 | sizeof(CfgTable_struct)); | 2875 | cfg_offset, sizeof(CfgTable_struct)); |
| 2826 | c->board_id = board_id; | 2876 | c->board_id = board_id; |
| 2827 | 2877 | ||
| 2828 | #ifdef CCISS_DEBUG | 2878 | #ifdef CCISS_DEBUG |
| 2829 | print_cfg_table(c->cfgtable); | 2879 | print_cfg_table(c->cfgtable); |
| 2830 | #endif /* CCISS_DEBUG */ | 2880 | #endif /* CCISS_DEBUG */ |
| 2831 | 2881 | ||
| 2832 | for(i=0; i<ARRAY_SIZE(products); i++) { | 2882 | for (i = 0; i < ARRAY_SIZE(products); i++) { |
| 2833 | if (board_id == products[i].board_id) { | 2883 | if (board_id == products[i].board_id) { |
| 2834 | c->product_name = products[i].product_name; | 2884 | c->product_name = products[i].product_name; |
| 2835 | c->access = *(products[i].access); | 2885 | c->access = *(products[i].access); |
| @@ -2838,78 +2888,75 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) | |||
| 2838 | } | 2888 | } |
| 2839 | if (i == ARRAY_SIZE(products)) { | 2889 | if (i == ARRAY_SIZE(products)) { |
| 2840 | printk(KERN_WARNING "cciss: Sorry, I don't know how" | 2890 | printk(KERN_WARNING "cciss: Sorry, I don't know how" |
| 2841 | " to access the Smart Array controller %08lx\n", | 2891 | " to access the Smart Array controller %08lx\n", |
| 2842 | (unsigned long)board_id); | 2892 | (unsigned long)board_id); |
| 2843 | err = -ENODEV; | 2893 | err = -ENODEV; |
| 2844 | goto err_out_free_res; | 2894 | goto err_out_free_res; |
| 2845 | } | 2895 | } |
| 2846 | if ( (readb(&c->cfgtable->Signature[0]) != 'C') || | 2896 | if ((readb(&c->cfgtable->Signature[0]) != 'C') || |
| 2847 | (readb(&c->cfgtable->Signature[1]) != 'I') || | 2897 | (readb(&c->cfgtable->Signature[1]) != 'I') || |
| 2848 | (readb(&c->cfgtable->Signature[2]) != 'S') || | 2898 | (readb(&c->cfgtable->Signature[2]) != 'S') || |
| 2849 | (readb(&c->cfgtable->Signature[3]) != 'S') ) | 2899 | (readb(&c->cfgtable->Signature[3]) != 'S')) { |
| 2850 | { | ||
| 2851 | printk("Does not appear to be a valid CISS config table\n"); | 2900 | printk("Does not appear to be a valid CISS config table\n"); |
| 2852 | err = -ENODEV; | 2901 | err = -ENODEV; |
| 2853 | goto err_out_free_res; | 2902 | goto err_out_free_res; |
| 2854 | } | 2903 | } |
| 2855 | |||
| 2856 | #ifdef CONFIG_X86 | 2904 | #ifdef CONFIG_X86 |
| 2857 | { | 2905 | { |
| 2858 | /* Need to enable prefetch in the SCSI core for 6400 in x86 */ | 2906 | /* Need to enable prefetch in the SCSI core for 6400 in x86 */ |
| 2859 | __u32 prefetch; | 2907 | __u32 prefetch; |
| 2860 | prefetch = readl(&(c->cfgtable->SCSI_Prefetch)); | 2908 | prefetch = readl(&(c->cfgtable->SCSI_Prefetch)); |
| 2861 | prefetch |= 0x100; | 2909 | prefetch |= 0x100; |
| 2862 | writel(prefetch, &(c->cfgtable->SCSI_Prefetch)); | 2910 | writel(prefetch, &(c->cfgtable->SCSI_Prefetch)); |
| 2863 | } | 2911 | } |
| 2864 | #endif | 2912 | #endif |
| 2865 | 2913 | ||
| 2866 | #ifdef CCISS_DEBUG | 2914 | #ifdef CCISS_DEBUG |
| 2867 | printk("Trying to put board into Simple mode\n"); | 2915 | printk("Trying to put board into Simple mode\n"); |
| 2868 | #endif /* CCISS_DEBUG */ | 2916 | #endif /* CCISS_DEBUG */ |
| 2869 | c->max_commands = readl(&(c->cfgtable->CmdsOutMax)); | 2917 | c->max_commands = readl(&(c->cfgtable->CmdsOutMax)); |
| 2870 | /* Update the field, and then ring the doorbell */ | 2918 | /* Update the field, and then ring the doorbell */ |
| 2871 | writel( CFGTBL_Trans_Simple, | 2919 | writel(CFGTBL_Trans_Simple, &(c->cfgtable->HostWrite.TransportRequest)); |
| 2872 | &(c->cfgtable->HostWrite.TransportRequest)); | 2920 | writel(CFGTBL_ChangeReq, c->vaddr + SA5_DOORBELL); |
| 2873 | writel( CFGTBL_ChangeReq, c->vaddr + SA5_DOORBELL); | ||
| 2874 | 2921 | ||
| 2875 | /* under certain very rare conditions, this can take awhile. | 2922 | /* under certain very rare conditions, this can take awhile. |
| 2876 | * (e.g.: hot replace a failed 144GB drive in a RAID 5 set right | 2923 | * (e.g.: hot replace a failed 144GB drive in a RAID 5 set right |
| 2877 | * as we enter this code.) */ | 2924 | * as we enter this code.) */ |
| 2878 | for(i=0;i<MAX_CONFIG_WAIT;i++) { | 2925 | for (i = 0; i < MAX_CONFIG_WAIT; i++) { |
| 2879 | if (!(readl(c->vaddr + SA5_DOORBELL) & CFGTBL_ChangeReq)) | 2926 | if (!(readl(c->vaddr + SA5_DOORBELL) & CFGTBL_ChangeReq)) |
| 2880 | break; | 2927 | break; |
| 2881 | /* delay and try again */ | 2928 | /* delay and try again */ |
| 2882 | set_current_state(TASK_INTERRUPTIBLE); | 2929 | set_current_state(TASK_INTERRUPTIBLE); |
| 2883 | schedule_timeout(10); | 2930 | schedule_timeout(10); |
| 2884 | } | 2931 | } |
| 2885 | 2932 | ||
| 2886 | #ifdef CCISS_DEBUG | 2933 | #ifdef CCISS_DEBUG |
| 2887 | printk(KERN_DEBUG "I counter got to %d %x\n", i, readl(c->vaddr + SA5_DOORBELL)); | 2934 | printk(KERN_DEBUG "I counter got to %d %x\n", i, |
| 2888 | #endif /* CCISS_DEBUG */ | 2935 | readl(c->vaddr + SA5_DOORBELL)); |
| 2936 | #endif /* CCISS_DEBUG */ | ||
| 2889 | #ifdef CCISS_DEBUG | 2937 | #ifdef CCISS_DEBUG |
| 2890 | print_cfg_table(c->cfgtable); | 2938 | print_cfg_table(c->cfgtable); |
| 2891 | #endif /* CCISS_DEBUG */ | 2939 | #endif /* CCISS_DEBUG */ |
| 2892 | 2940 | ||
| 2893 | if (!(readl(&(c->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) | 2941 | if (!(readl(&(c->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) { |
| 2894 | { | ||
| 2895 | printk(KERN_WARNING "cciss: unable to get board into" | 2942 | printk(KERN_WARNING "cciss: unable to get board into" |
| 2896 | " simple mode\n"); | 2943 | " simple mode\n"); |
| 2897 | err = -ENODEV; | 2944 | err = -ENODEV; |
| 2898 | goto err_out_free_res; | 2945 | goto err_out_free_res; |
| 2899 | } | 2946 | } |
| 2900 | return 0; | 2947 | return 0; |
| 2901 | 2948 | ||
| 2902 | err_out_free_res: | 2949 | err_out_free_res: |
| 2903 | pci_release_regions(pdev); | 2950 | pci_release_regions(pdev); |
| 2904 | 2951 | ||
| 2905 | err_out_disable_pdev: | 2952 | err_out_disable_pdev: |
| 2906 | pci_disable_device(pdev); | 2953 | pci_disable_device(pdev); |
| 2907 | return err; | 2954 | return err; |
| 2908 | } | 2955 | } |
| 2909 | 2956 | ||
| 2910 | /* | 2957 | /* |
| 2911 | * Gets information about the local volumes attached to the controller. | 2958 | * Gets information about the local volumes attached to the controller. |
| 2912 | */ | 2959 | */ |
| 2913 | static void cciss_getgeometry(int cntl_num) | 2960 | static void cciss_getgeometry(int cntl_num) |
| 2914 | { | 2961 | { |
| 2915 | ReportLunData_struct *ld_buff; | 2962 | ReportLunData_struct *ld_buff; |
| @@ -2920,102 +2967,102 @@ static void cciss_getgeometry(int cntl_num) | |||
| 2920 | int listlength = 0; | 2967 | int listlength = 0; |
| 2921 | __u32 lunid = 0; | 2968 | __u32 lunid = 0; |
| 2922 | int block_size; | 2969 | int block_size; |
| 2923 | int total_size; | 2970 | int total_size; |
| 2924 | 2971 | ||
| 2925 | ld_buff = kzalloc(sizeof(ReportLunData_struct), GFP_KERNEL); | 2972 | ld_buff = kzalloc(sizeof(ReportLunData_struct), GFP_KERNEL); |
| 2926 | if (ld_buff == NULL) | 2973 | if (ld_buff == NULL) { |
| 2927 | { | 2974 | printk(KERN_ERR "cciss: out of memory\n"); |
| 2975 | return; | ||
| 2976 | } | ||
| 2977 | size_buff = kmalloc(sizeof(ReadCapdata_struct), GFP_KERNEL); | ||
| 2978 | if (size_buff == NULL) { | ||
| 2928 | printk(KERN_ERR "cciss: out of memory\n"); | 2979 | printk(KERN_ERR "cciss: out of memory\n"); |
| 2980 | kfree(ld_buff); | ||
| 2929 | return; | 2981 | return; |
| 2930 | } | 2982 | } |
| 2931 | size_buff = kmalloc(sizeof( ReadCapdata_struct), GFP_KERNEL); | 2983 | inq_buff = kmalloc(sizeof(InquiryData_struct), GFP_KERNEL); |
| 2932 | if (size_buff == NULL) | 2984 | if (inq_buff == NULL) { |
| 2933 | { | 2985 | printk(KERN_ERR "cciss: out of memory\n"); |
| 2934 | printk(KERN_ERR "cciss: out of memory\n"); | ||
| 2935 | kfree(ld_buff); | 2986 | kfree(ld_buff); |
| 2936 | return; | ||
| 2937 | } | ||
| 2938 | inq_buff = kmalloc(sizeof( InquiryData_struct), GFP_KERNEL); | ||
| 2939 | if (inq_buff == NULL) | ||
| 2940 | { | ||
| 2941 | printk(KERN_ERR "cciss: out of memory\n"); | ||
| 2942 | kfree(ld_buff); | ||
| 2943 | kfree(size_buff); | 2987 | kfree(size_buff); |
| 2944 | return; | 2988 | return; |
| 2945 | } | 2989 | } |
| 2946 | /* Get the firmware version */ | 2990 | /* Get the firmware version */ |
| 2947 | return_code = sendcmd(CISS_INQUIRY, cntl_num, inq_buff, | 2991 | return_code = sendcmd(CISS_INQUIRY, cntl_num, inq_buff, |
| 2948 | sizeof(InquiryData_struct), 0, 0 ,0, NULL, TYPE_CMD); | 2992 | sizeof(InquiryData_struct), 0, 0, 0, NULL, |
| 2949 | if (return_code == IO_OK) | 2993 | TYPE_CMD); |
| 2950 | { | 2994 | if (return_code == IO_OK) { |
| 2951 | hba[cntl_num]->firm_ver[0] = inq_buff->data_byte[32]; | 2995 | hba[cntl_num]->firm_ver[0] = inq_buff->data_byte[32]; |
| 2952 | hba[cntl_num]->firm_ver[1] = inq_buff->data_byte[33]; | 2996 | hba[cntl_num]->firm_ver[1] = inq_buff->data_byte[33]; |
| 2953 | hba[cntl_num]->firm_ver[2] = inq_buff->data_byte[34]; | 2997 | hba[cntl_num]->firm_ver[2] = inq_buff->data_byte[34]; |
| 2954 | hba[cntl_num]->firm_ver[3] = inq_buff->data_byte[35]; | 2998 | hba[cntl_num]->firm_ver[3] = inq_buff->data_byte[35]; |
| 2955 | } else /* send command failed */ | 2999 | } else { /* send command failed */ |
| 2956 | { | 3000 | |
| 2957 | printk(KERN_WARNING "cciss: unable to determine firmware" | 3001 | printk(KERN_WARNING "cciss: unable to determine firmware" |
| 2958 | " version of controller\n"); | 3002 | " version of controller\n"); |
| 2959 | } | 3003 | } |
| 2960 | /* Get the number of logical volumes */ | 3004 | /* Get the number of logical volumes */ |
| 2961 | return_code = sendcmd(CISS_REPORT_LOG, cntl_num, ld_buff, | 3005 | return_code = sendcmd(CISS_REPORT_LOG, cntl_num, ld_buff, |
| 2962 | sizeof(ReportLunData_struct), 0, 0, 0, NULL, TYPE_CMD); | 3006 | sizeof(ReportLunData_struct), 0, 0, 0, NULL, |
| 3007 | TYPE_CMD); | ||
| 2963 | 3008 | ||
| 2964 | if( return_code == IO_OK) | 3009 | if (return_code == IO_OK) { |
| 2965 | { | ||
| 2966 | #ifdef CCISS_DEBUG | 3010 | #ifdef CCISS_DEBUG |
| 2967 | printk("LUN Data\n--------------------------\n"); | 3011 | printk("LUN Data\n--------------------------\n"); |
| 2968 | #endif /* CCISS_DEBUG */ | 3012 | #endif /* CCISS_DEBUG */ |
| 2969 | 3013 | ||
| 2970 | listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[0])) << 24; | 3014 | listlength |= |
| 2971 | listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[1])) << 16; | 3015 | (0xff & (unsigned int)(ld_buff->LUNListLength[0])) << 24; |
| 2972 | listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[2])) << 8; | 3016 | listlength |= |
| 3017 | (0xff & (unsigned int)(ld_buff->LUNListLength[1])) << 16; | ||
| 3018 | listlength |= | ||
| 3019 | (0xff & (unsigned int)(ld_buff->LUNListLength[2])) << 8; | ||
| 2973 | listlength |= 0xff & (unsigned int)(ld_buff->LUNListLength[3]); | 3020 | listlength |= 0xff & (unsigned int)(ld_buff->LUNListLength[3]); |
| 2974 | } else /* reading number of logical volumes failed */ | 3021 | } else { /* reading number of logical volumes failed */ |
| 2975 | { | 3022 | |
| 2976 | printk(KERN_WARNING "cciss: report logical volume" | 3023 | printk(KERN_WARNING "cciss: report logical volume" |
| 2977 | " command failed\n"); | 3024 | " command failed\n"); |
| 2978 | listlength = 0; | 3025 | listlength = 0; |
| 2979 | } | 3026 | } |
| 2980 | hba[cntl_num]->num_luns = listlength / 8; // 8 bytes pre entry | 3027 | hba[cntl_num]->num_luns = listlength / 8; // 8 bytes pre entry |
| 2981 | if (hba[cntl_num]->num_luns > CISS_MAX_LUN) | 3028 | if (hba[cntl_num]->num_luns > CISS_MAX_LUN) { |
| 2982 | { | 3029 | printk(KERN_ERR |
| 2983 | printk(KERN_ERR "ciss: only %d number of logical volumes supported\n", | 3030 | "ciss: only %d number of logical volumes supported\n", |
| 2984 | CISS_MAX_LUN); | 3031 | CISS_MAX_LUN); |
| 2985 | hba[cntl_num]->num_luns = CISS_MAX_LUN; | 3032 | hba[cntl_num]->num_luns = CISS_MAX_LUN; |
| 2986 | } | 3033 | } |
| 2987 | #ifdef CCISS_DEBUG | 3034 | #ifdef CCISS_DEBUG |
| 2988 | printk(KERN_DEBUG "Length = %x %x %x %x = %d\n", ld_buff->LUNListLength[0], | 3035 | printk(KERN_DEBUG "Length = %x %x %x %x = %d\n", |
| 2989 | ld_buff->LUNListLength[1], ld_buff->LUNListLength[2], | 3036 | ld_buff->LUNListLength[0], ld_buff->LUNListLength[1], |
| 2990 | ld_buff->LUNListLength[3], hba[cntl_num]->num_luns); | 3037 | ld_buff->LUNListLength[2], ld_buff->LUNListLength[3], |
| 2991 | #endif /* CCISS_DEBUG */ | 3038 | hba[cntl_num]->num_luns); |
| 2992 | 3039 | #endif /* CCISS_DEBUG */ | |
| 2993 | hba[cntl_num]->highest_lun = hba[cntl_num]->num_luns-1; | 3040 | |
| 2994 | // for(i=0; i< hba[cntl_num]->num_luns; i++) | 3041 | hba[cntl_num]->highest_lun = hba[cntl_num]->num_luns - 1; |
| 2995 | for(i=0; i < CISS_MAX_LUN; i++) | 3042 | // for(i=0; i< hba[cntl_num]->num_luns; i++) |
| 2996 | { | 3043 | for (i = 0; i < CISS_MAX_LUN; i++) { |
| 2997 | if (i < hba[cntl_num]->num_luns){ | 3044 | if (i < hba[cntl_num]->num_luns) { |
| 2998 | lunid = (0xff & (unsigned int)(ld_buff->LUN[i][3])) | 3045 | lunid = (0xff & (unsigned int)(ld_buff->LUN[i][3])) |
| 2999 | << 24; | 3046 | << 24; |
| 3000 | lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][2])) | 3047 | lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][2])) |
| 3001 | << 16; | 3048 | << 16; |
| 3002 | lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][1])) | 3049 | lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][1])) |
| 3003 | << 8; | 3050 | << 8; |
| 3004 | lunid |= 0xff & (unsigned int)(ld_buff->LUN[i][0]); | 3051 | lunid |= 0xff & (unsigned int)(ld_buff->LUN[i][0]); |
| 3005 | 3052 | ||
| 3006 | hba[cntl_num]->drv[i].LunID = lunid; | 3053 | hba[cntl_num]->drv[i].LunID = lunid; |
| 3007 | |||
| 3008 | 3054 | ||
| 3009 | #ifdef CCISS_DEBUG | 3055 | #ifdef CCISS_DEBUG |
| 3010 | printk(KERN_DEBUG "LUN[%d]: %x %x %x %x = %x\n", i, | 3056 | printk(KERN_DEBUG "LUN[%d]: %x %x %x %x = %x\n", i, |
| 3011 | ld_buff->LUN[i][0], ld_buff->LUN[i][1], | 3057 | ld_buff->LUN[i][0], ld_buff->LUN[i][1], |
| 3012 | ld_buff->LUN[i][2], ld_buff->LUN[i][3], | 3058 | ld_buff->LUN[i][2], ld_buff->LUN[i][3], |
| 3013 | hba[cntl_num]->drv[i].LunID); | 3059 | hba[cntl_num]->drv[i].LunID); |
| 3014 | #endif /* CCISS_DEBUG */ | 3060 | #endif /* CCISS_DEBUG */ |
| 3015 | cciss_read_capacity(cntl_num, i, size_buff, 0, | 3061 | cciss_read_capacity(cntl_num, i, size_buff, 0, |
| 3016 | &total_size, &block_size); | 3062 | &total_size, &block_size); |
| 3017 | cciss_geometry_inquiry(cntl_num, i, 0, total_size, | 3063 | cciss_geometry_inquiry(cntl_num, i, 0, total_size, |
| 3018 | block_size, inq_buff, &hba[cntl_num]->drv[i]); | 3064 | block_size, inq_buff, |
| 3065 | &hba[cntl_num]->drv[i]); | ||
| 3019 | } else { | 3066 | } else { |
| 3020 | /* initialize raid_level to indicate a free space */ | 3067 | /* initialize raid_level to indicate a free space */ |
| 3021 | hba[cntl_num]->drv[i].raid_level = -1; | 3068 | hba[cntl_num]->drv[i].raid_level = -1; |
| @@ -3024,7 +3071,7 @@ static void cciss_getgeometry(int cntl_num) | |||
| 3024 | kfree(ld_buff); | 3071 | kfree(ld_buff); |
| 3025 | kfree(size_buff); | 3072 | kfree(size_buff); |
| 3026 | kfree(inq_buff); | 3073 | kfree(inq_buff); |
| 3027 | } | 3074 | } |
| 3028 | 3075 | ||
| 3029 | /* Function to find the first free pointer into our hba[] array */ | 3076 | /* Function to find the first free pointer into our hba[] array */ |
| 3030 | /* Returns -1 if no free entries are left. */ | 3077 | /* Returns -1 if no free entries are left. */ |
| @@ -3038,7 +3085,7 @@ static int alloc_cciss_hba(void) | |||
| 3038 | goto out; | 3085 | goto out; |
| 3039 | } | 3086 | } |
| 3040 | 3087 | ||
| 3041 | for(i=0; i< MAX_CTLR; i++) { | 3088 | for (i = 0; i < MAX_CTLR; i++) { |
| 3042 | if (!hba[i]) { | 3089 | if (!hba[i]) { |
| 3043 | ctlr_info_t *p; | 3090 | ctlr_info_t *p; |
| 3044 | p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL); | 3091 | p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL); |
| @@ -3051,11 +3098,11 @@ static int alloc_cciss_hba(void) | |||
| 3051 | } | 3098 | } |
| 3052 | } | 3099 | } |
| 3053 | printk(KERN_WARNING "cciss: This driver supports a maximum" | 3100 | printk(KERN_WARNING "cciss: This driver supports a maximum" |
| 3054 | " of %d controllers.\n", MAX_CTLR); | 3101 | " of %d controllers.\n", MAX_CTLR); |
| 3055 | goto out; | 3102 | goto out; |
| 3056 | Enomem: | 3103 | Enomem: |
| 3057 | printk(KERN_ERR "cciss: out of memory.\n"); | 3104 | printk(KERN_ERR "cciss: out of memory.\n"); |
| 3058 | out: | 3105 | out: |
| 3059 | while (n--) | 3106 | while (n--) |
| 3060 | put_disk(disk[n]); | 3107 | put_disk(disk[n]); |
| 3061 | return -1; | 3108 | return -1; |
| @@ -3078,7 +3125,7 @@ static void free_hba(int i) | |||
| 3078 | * returns the number of block devices registered. | 3125 | * returns the number of block devices registered. |
| 3079 | */ | 3126 | */ |
| 3080 | static int __devinit cciss_init_one(struct pci_dev *pdev, | 3127 | static int __devinit cciss_init_one(struct pci_dev *pdev, |
| 3081 | const struct pci_device_id *ent) | 3128 | const struct pci_device_id *ent) |
| 3082 | { | 3129 | { |
| 3083 | request_queue_t *q; | 3130 | request_queue_t *q; |
| 3084 | int i; | 3131 | int i; |
| @@ -3087,7 +3134,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, | |||
| 3087 | int dac; | 3134 | int dac; |
| 3088 | 3135 | ||
| 3089 | i = alloc_cciss_hba(); | 3136 | i = alloc_cciss_hba(); |
| 3090 | if(i < 0) | 3137 | if (i < 0) |
| 3091 | return -1; | 3138 | return -1; |
| 3092 | 3139 | ||
| 3093 | hba[i]->busy_initializing = 1; | 3140 | hba[i]->busy_initializing = 1; |
| @@ -3117,64 +3164,69 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, | |||
| 3117 | if (i < MAX_CTLR_ORIG) | 3164 | if (i < MAX_CTLR_ORIG) |
| 3118 | hba[i]->major = COMPAQ_CISS_MAJOR + i; | 3165 | hba[i]->major = COMPAQ_CISS_MAJOR + i; |
| 3119 | rc = register_blkdev(hba[i]->major, hba[i]->devname); | 3166 | rc = register_blkdev(hba[i]->major, hba[i]->devname); |
| 3120 | if(rc == -EBUSY || rc == -EINVAL) { | 3167 | if (rc == -EBUSY || rc == -EINVAL) { |
| 3121 | printk(KERN_ERR | 3168 | printk(KERN_ERR |
| 3122 | "cciss: Unable to get major number %d for %s " | 3169 | "cciss: Unable to get major number %d for %s " |
| 3123 | "on hba %d\n", hba[i]->major, hba[i]->devname, i); | 3170 | "on hba %d\n", hba[i]->major, hba[i]->devname, i); |
| 3124 | goto clean1; | 3171 | goto clean1; |
| 3125 | } | 3172 | } else { |
| 3126 | else { | ||
| 3127 | if (i >= MAX_CTLR_ORIG) | 3173 | if (i >= MAX_CTLR_ORIG) |
| 3128 | hba[i]->major = rc; | 3174 | hba[i]->major = rc; |
| 3129 | } | 3175 | } |
| 3130 | 3176 | ||
| 3131 | /* make sure the board interrupts are off */ | 3177 | /* make sure the board interrupts are off */ |
| 3132 | hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_OFF); | 3178 | hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_OFF); |
| 3133 | if( request_irq(hba[i]->intr[SIMPLE_MODE_INT], do_cciss_intr, | 3179 | if (request_irq(hba[i]->intr[SIMPLE_MODE_INT], do_cciss_intr, |
| 3134 | SA_INTERRUPT | SA_SHIRQ, hba[i]->devname, hba[i])) { | 3180 | SA_INTERRUPT | SA_SHIRQ, hba[i]->devname, hba[i])) { |
| 3135 | printk(KERN_ERR "cciss: Unable to get irq %d for %s\n", | 3181 | printk(KERN_ERR "cciss: Unable to get irq %d for %s\n", |
| 3136 | hba[i]->intr[SIMPLE_MODE_INT], hba[i]->devname); | 3182 | hba[i]->intr[SIMPLE_MODE_INT], hba[i]->devname); |
| 3137 | goto clean2; | 3183 | goto clean2; |
| 3138 | } | 3184 | } |
| 3139 | 3185 | ||
| 3140 | printk(KERN_INFO "%s: <0x%x> at PCI %s IRQ %d%s using DAC\n", | 3186 | printk(KERN_INFO "%s: <0x%x> at PCI %s IRQ %d%s using DAC\n", |
| 3141 | hba[i]->devname, pdev->device, pci_name(pdev), | 3187 | hba[i]->devname, pdev->device, pci_name(pdev), |
| 3142 | hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not"); | 3188 | hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not"); |
| 3143 | 3189 | ||
| 3144 | hba[i]->cmd_pool_bits = kmalloc(((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long), GFP_KERNEL); | 3190 | hba[i]->cmd_pool_bits = |
| 3145 | hba[i]->cmd_pool = (CommandList_struct *)pci_alloc_consistent( | 3191 | kmalloc(((NR_CMDS + BITS_PER_LONG - |
| 3146 | hba[i]->pdev, NR_CMDS * sizeof(CommandList_struct), | 3192 | 1) / BITS_PER_LONG) * sizeof(unsigned long), GFP_KERNEL); |
| 3147 | &(hba[i]->cmd_pool_dhandle)); | 3193 | hba[i]->cmd_pool = (CommandList_struct *) |
| 3148 | hba[i]->errinfo_pool = (ErrorInfo_struct *)pci_alloc_consistent( | 3194 | pci_alloc_consistent(hba[i]->pdev, |
| 3149 | hba[i]->pdev, NR_CMDS * sizeof( ErrorInfo_struct), | 3195 | NR_CMDS * sizeof(CommandList_struct), |
| 3150 | &(hba[i]->errinfo_pool_dhandle)); | 3196 | &(hba[i]->cmd_pool_dhandle)); |
| 3151 | if((hba[i]->cmd_pool_bits == NULL) | 3197 | hba[i]->errinfo_pool = (ErrorInfo_struct *) |
| 3152 | || (hba[i]->cmd_pool == NULL) | 3198 | pci_alloc_consistent(hba[i]->pdev, |
| 3153 | || (hba[i]->errinfo_pool == NULL)) { | 3199 | NR_CMDS * sizeof(ErrorInfo_struct), |
| 3154 | printk( KERN_ERR "cciss: out of memory"); | 3200 | &(hba[i]->errinfo_pool_dhandle)); |
| 3201 | if ((hba[i]->cmd_pool_bits == NULL) | ||
| 3202 | || (hba[i]->cmd_pool == NULL) | ||
| 3203 | || (hba[i]->errinfo_pool == NULL)) { | ||
| 3204 | printk(KERN_ERR "cciss: out of memory"); | ||
| 3155 | goto clean4; | 3205 | goto clean4; |
| 3156 | } | 3206 | } |
| 3157 | #ifdef CONFIG_CISS_SCSI_TAPE | 3207 | #ifdef CONFIG_CISS_SCSI_TAPE |
| 3158 | hba[i]->scsi_rejects.complete = | 3208 | hba[i]->scsi_rejects.complete = |
| 3159 | kmalloc(sizeof(hba[i]->scsi_rejects.complete[0]) * | 3209 | kmalloc(sizeof(hba[i]->scsi_rejects.complete[0]) * |
| 3160 | (NR_CMDS + 5), GFP_KERNEL); | 3210 | (NR_CMDS + 5), GFP_KERNEL); |
| 3161 | if (hba[i]->scsi_rejects.complete == NULL) { | 3211 | if (hba[i]->scsi_rejects.complete == NULL) { |
| 3162 | printk( KERN_ERR "cciss: out of memory"); | 3212 | printk(KERN_ERR "cciss: out of memory"); |
| 3163 | goto clean4; | 3213 | goto clean4; |
| 3164 | } | 3214 | } |
| 3165 | #endif | 3215 | #endif |
| 3166 | spin_lock_init(&hba[i]->lock); | 3216 | spin_lock_init(&hba[i]->lock); |
| 3167 | 3217 | ||
| 3168 | /* Initialize the pdev driver private data. | 3218 | /* Initialize the pdev driver private data. |
| 3169 | have it point to hba[i]. */ | 3219 | have it point to hba[i]. */ |
| 3170 | pci_set_drvdata(pdev, hba[i]); | 3220 | pci_set_drvdata(pdev, hba[i]); |
| 3171 | /* command and error info recs zeroed out before | 3221 | /* command and error info recs zeroed out before |
| 3172 | they are used */ | 3222 | they are used */ |
| 3173 | memset(hba[i]->cmd_pool_bits, 0, ((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long)); | 3223 | memset(hba[i]->cmd_pool_bits, 0, |
| 3224 | ((NR_CMDS + BITS_PER_LONG - | ||
| 3225 | 1) / BITS_PER_LONG) * sizeof(unsigned long)); | ||
| 3174 | 3226 | ||
| 3175 | #ifdef CCISS_DEBUG | 3227 | #ifdef CCISS_DEBUG |
| 3176 | printk(KERN_DEBUG "Scanning for drives on controller cciss%d\n",i); | 3228 | printk(KERN_DEBUG "Scanning for drives on controller cciss%d\n", i); |
| 3177 | #endif /* CCISS_DEBUG */ | 3229 | #endif /* CCISS_DEBUG */ |
| 3178 | 3230 | ||
| 3179 | cciss_getgeometry(i); | 3231 | cciss_getgeometry(i); |
| 3180 | 3232 | ||
| @@ -3186,15 +3238,15 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, | |||
| 3186 | cciss_procinit(i); | 3238 | cciss_procinit(i); |
| 3187 | hba[i]->busy_initializing = 0; | 3239 | hba[i]->busy_initializing = 0; |
| 3188 | 3240 | ||
| 3189 | for(j=0; j < NWD; j++) { /* mfm */ | 3241 | for (j = 0; j < NWD; j++) { /* mfm */ |
| 3190 | drive_info_struct *drv = &(hba[i]->drv[j]); | 3242 | drive_info_struct *drv = &(hba[i]->drv[j]); |
| 3191 | struct gendisk *disk = hba[i]->gendisk[j]; | 3243 | struct gendisk *disk = hba[i]->gendisk[j]; |
| 3192 | 3244 | ||
| 3193 | q = blk_init_queue(do_cciss_request, &hba[i]->lock); | 3245 | q = blk_init_queue(do_cciss_request, &hba[i]->lock); |
| 3194 | if (!q) { | 3246 | if (!q) { |
| 3195 | printk(KERN_ERR | 3247 | printk(KERN_ERR |
| 3196 | "cciss: unable to allocate queue for disk %d\n", | 3248 | "cciss: unable to allocate queue for disk %d\n", |
| 3197 | j); | 3249 | j); |
| 3198 | break; | 3250 | break; |
| 3199 | } | 3251 | } |
| 3200 | drv->queue = q; | 3252 | drv->queue = q; |
| @@ -3223,7 +3275,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, | |||
| 3223 | disk->driverfs_dev = &pdev->dev; | 3275 | disk->driverfs_dev = &pdev->dev; |
| 3224 | /* we must register the controller even if no disks exist */ | 3276 | /* we must register the controller even if no disks exist */ |
| 3225 | /* this is for the online array utilities */ | 3277 | /* this is for the online array utilities */ |
| 3226 | if(!drv->heads && j) | 3278 | if (!drv->heads && j) |
| 3227 | continue; | 3279 | continue; |
| 3228 | blk_queue_hardsect_size(q, drv->block_size); | 3280 | blk_queue_hardsect_size(q, drv->block_size); |
| 3229 | set_capacity(disk, drv->nr_blocks); | 3281 | set_capacity(disk, drv->nr_blocks); |
| @@ -3232,81 +3284,78 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, | |||
| 3232 | 3284 | ||
| 3233 | return 1; | 3285 | return 1; |
| 3234 | 3286 | ||
| 3235 | clean4: | 3287 | clean4: |
| 3236 | #ifdef CONFIG_CISS_SCSI_TAPE | 3288 | #ifdef CONFIG_CISS_SCSI_TAPE |
| 3237 | kfree(hba[i]->scsi_rejects.complete); | 3289 | kfree(hba[i]->scsi_rejects.complete); |
| 3238 | #endif | 3290 | #endif |
| 3239 | kfree(hba[i]->cmd_pool_bits); | 3291 | kfree(hba[i]->cmd_pool_bits); |
| 3240 | if(hba[i]->cmd_pool) | 3292 | if (hba[i]->cmd_pool) |
| 3241 | pci_free_consistent(hba[i]->pdev, | 3293 | pci_free_consistent(hba[i]->pdev, |
| 3242 | NR_CMDS * sizeof(CommandList_struct), | 3294 | NR_CMDS * sizeof(CommandList_struct), |
| 3243 | hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); | 3295 | hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); |
| 3244 | if(hba[i]->errinfo_pool) | 3296 | if (hba[i]->errinfo_pool) |
| 3245 | pci_free_consistent(hba[i]->pdev, | 3297 | pci_free_consistent(hba[i]->pdev, |
| 3246 | NR_CMDS * sizeof( ErrorInfo_struct), | 3298 | NR_CMDS * sizeof(ErrorInfo_struct), |
| 3247 | hba[i]->errinfo_pool, | 3299 | hba[i]->errinfo_pool, |
| 3248 | hba[i]->errinfo_pool_dhandle); | 3300 | hba[i]->errinfo_pool_dhandle); |
| 3249 | free_irq(hba[i]->intr[SIMPLE_MODE_INT], hba[i]); | 3301 | free_irq(hba[i]->intr[SIMPLE_MODE_INT], hba[i]); |
| 3250 | clean2: | 3302 | clean2: |
| 3251 | unregister_blkdev(hba[i]->major, hba[i]->devname); | 3303 | unregister_blkdev(hba[i]->major, hba[i]->devname); |
| 3252 | clean1: | 3304 | clean1: |
| 3253 | hba[i]->busy_initializing = 0; | 3305 | hba[i]->busy_initializing = 0; |
| 3254 | free_hba(i); | 3306 | free_hba(i); |
| 3255 | return -1; | 3307 | return -1; |
| 3256 | } | 3308 | } |
| 3257 | 3309 | ||
| 3258 | static void __devexit cciss_remove_one (struct pci_dev *pdev) | 3310 | static void __devexit cciss_remove_one(struct pci_dev *pdev) |
| 3259 | { | 3311 | { |
| 3260 | ctlr_info_t *tmp_ptr; | 3312 | ctlr_info_t *tmp_ptr; |
| 3261 | int i, j; | 3313 | int i, j; |
| 3262 | char flush_buf[4]; | 3314 | char flush_buf[4]; |
| 3263 | int return_code; | 3315 | int return_code; |
| 3264 | 3316 | ||
| 3265 | if (pci_get_drvdata(pdev) == NULL) | 3317 | if (pci_get_drvdata(pdev) == NULL) { |
| 3266 | { | 3318 | printk(KERN_ERR "cciss: Unable to remove device \n"); |
| 3267 | printk( KERN_ERR "cciss: Unable to remove device \n"); | ||
| 3268 | return; | 3319 | return; |
| 3269 | } | 3320 | } |
| 3270 | tmp_ptr = pci_get_drvdata(pdev); | 3321 | tmp_ptr = pci_get_drvdata(pdev); |
| 3271 | i = tmp_ptr->ctlr; | 3322 | i = tmp_ptr->ctlr; |
| 3272 | if (hba[i] == NULL) | 3323 | if (hba[i] == NULL) { |
| 3273 | { | ||
| 3274 | printk(KERN_ERR "cciss: device appears to " | 3324 | printk(KERN_ERR "cciss: device appears to " |
| 3275 | "already be removed \n"); | 3325 | "already be removed \n"); |
| 3276 | return; | 3326 | return; |
| 3277 | } | 3327 | } |
| 3278 | /* Turn board interrupts off and send the flush cache command */ | 3328 | /* Turn board interrupts off and send the flush cache command */ |
| 3279 | /* sendcmd will turn off interrupt, and send the flush... | 3329 | /* sendcmd will turn off interrupt, and send the flush... |
| 3280 | * To write all data in the battery backed cache to disks */ | 3330 | * To write all data in the battery backed cache to disks */ |
| 3281 | memset(flush_buf, 0, 4); | 3331 | memset(flush_buf, 0, 4); |
| 3282 | return_code = sendcmd(CCISS_CACHE_FLUSH, i, flush_buf, 4, 0, 0, 0, NULL, | 3332 | return_code = sendcmd(CCISS_CACHE_FLUSH, i, flush_buf, 4, 0, 0, 0, NULL, |
| 3283 | TYPE_CMD); | 3333 | TYPE_CMD); |
| 3284 | if(return_code != IO_OK) | 3334 | if (return_code != IO_OK) { |
| 3285 | { | 3335 | printk(KERN_WARNING "Error Flushing cache on controller %d\n", |
| 3286 | printk(KERN_WARNING "Error Flushing cache on controller %d\n", | 3336 | i); |
| 3287 | i); | ||
| 3288 | } | 3337 | } |
| 3289 | free_irq(hba[i]->intr[2], hba[i]); | 3338 | free_irq(hba[i]->intr[2], hba[i]); |
| 3290 | 3339 | ||
| 3291 | #ifdef CONFIG_PCI_MSI | 3340 | #ifdef CONFIG_PCI_MSI |
| 3292 | if (hba[i]->msix_vector) | 3341 | if (hba[i]->msix_vector) |
| 3293 | pci_disable_msix(hba[i]->pdev); | 3342 | pci_disable_msix(hba[i]->pdev); |
| 3294 | else if (hba[i]->msi_vector) | 3343 | else if (hba[i]->msi_vector) |
| 3295 | pci_disable_msi(hba[i]->pdev); | 3344 | pci_disable_msi(hba[i]->pdev); |
| 3296 | #endif /* CONFIG_PCI_MSI */ | 3345 | #endif /* CONFIG_PCI_MSI */ |
| 3297 | 3346 | ||
| 3298 | iounmap(hba[i]->vaddr); | 3347 | iounmap(hba[i]->vaddr); |
| 3299 | cciss_unregister_scsi(i); /* unhook from SCSI subsystem */ | 3348 | cciss_unregister_scsi(i); /* unhook from SCSI subsystem */ |
| 3300 | unregister_blkdev(hba[i]->major, hba[i]->devname); | 3349 | unregister_blkdev(hba[i]->major, hba[i]->devname); |
| 3301 | remove_proc_entry(hba[i]->devname, proc_cciss); | 3350 | remove_proc_entry(hba[i]->devname, proc_cciss); |
| 3302 | 3351 | ||
| 3303 | /* remove it from the disk list */ | 3352 | /* remove it from the disk list */ |
| 3304 | for (j = 0; j < NWD; j++) { | 3353 | for (j = 0; j < NWD; j++) { |
| 3305 | struct gendisk *disk = hba[i]->gendisk[j]; | 3354 | struct gendisk *disk = hba[i]->gendisk[j]; |
| 3306 | if (disk) { | 3355 | if (disk) { |
| 3307 | request_queue_t *q = disk->queue; | 3356 | request_queue_t *q = disk->queue; |
| 3308 | 3357 | ||
| 3309 | if (disk->flags & GENHD_FL_UP) | 3358 | if (disk->flags & GENHD_FL_UP) |
| 3310 | del_gendisk(disk); | 3359 | del_gendisk(disk); |
| 3311 | if (q) | 3360 | if (q) |
| 3312 | blk_cleanup_queue(q); | 3361 | blk_cleanup_queue(q); |
| @@ -3315,28 +3364,28 @@ static void __devexit cciss_remove_one (struct pci_dev *pdev) | |||
| 3315 | 3364 | ||
| 3316 | pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(CommandList_struct), | 3365 | pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(CommandList_struct), |
| 3317 | hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); | 3366 | hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); |
| 3318 | pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof( ErrorInfo_struct), | 3367 | pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(ErrorInfo_struct), |
| 3319 | hba[i]->errinfo_pool, hba[i]->errinfo_pool_dhandle); | 3368 | hba[i]->errinfo_pool, hba[i]->errinfo_pool_dhandle); |
| 3320 | kfree(hba[i]->cmd_pool_bits); | 3369 | kfree(hba[i]->cmd_pool_bits); |
| 3321 | #ifdef CONFIG_CISS_SCSI_TAPE | 3370 | #ifdef CONFIG_CISS_SCSI_TAPE |
| 3322 | kfree(hba[i]->scsi_rejects.complete); | 3371 | kfree(hba[i]->scsi_rejects.complete); |
| 3323 | #endif | 3372 | #endif |
| 3324 | pci_release_regions(pdev); | 3373 | pci_release_regions(pdev); |
| 3325 | pci_disable_device(pdev); | 3374 | pci_disable_device(pdev); |
| 3326 | pci_set_drvdata(pdev, NULL); | 3375 | pci_set_drvdata(pdev, NULL); |
| 3327 | free_hba(i); | 3376 | free_hba(i); |
| 3328 | } | 3377 | } |
| 3329 | 3378 | ||
| 3330 | static struct pci_driver cciss_pci_driver = { | 3379 | static struct pci_driver cciss_pci_driver = { |
| 3331 | .name = "cciss", | 3380 | .name = "cciss", |
| 3332 | .probe = cciss_init_one, | 3381 | .probe = cciss_init_one, |
| 3333 | .remove = __devexit_p(cciss_remove_one), | 3382 | .remove = __devexit_p(cciss_remove_one), |
| 3334 | .id_table = cciss_pci_device_id, /* id_table */ | 3383 | .id_table = cciss_pci_device_id, /* id_table */ |
| 3335 | }; | 3384 | }; |
| 3336 | 3385 | ||
| 3337 | /* | 3386 | /* |
| 3338 | * This is it. Register the PCI driver information for the cards we control | 3387 | * This is it. Register the PCI driver information for the cards we control |
| 3339 | * the OS will call our registered routines when it finds one of our cards. | 3388 | * the OS will call our registered routines when it finds one of our cards. |
| 3340 | */ | 3389 | */ |
| 3341 | static int __init cciss_init(void) | 3390 | static int __init cciss_init(void) |
| 3342 | { | 3391 | { |
| @@ -3352,12 +3401,10 @@ static void __exit cciss_cleanup(void) | |||
| 3352 | 3401 | ||
| 3353 | pci_unregister_driver(&cciss_pci_driver); | 3402 | pci_unregister_driver(&cciss_pci_driver); |
| 3354 | /* double check that all controller entrys have been removed */ | 3403 | /* double check that all controller entrys have been removed */ |
| 3355 | for (i=0; i< MAX_CTLR; i++) | 3404 | for (i = 0; i < MAX_CTLR; i++) { |
| 3356 | { | 3405 | if (hba[i] != NULL) { |
| 3357 | if (hba[i] != NULL) | ||
| 3358 | { | ||
| 3359 | printk(KERN_WARNING "cciss: had to remove" | 3406 | printk(KERN_WARNING "cciss: had to remove" |
| 3360 | " controller %d\n", i); | 3407 | " controller %d\n", i); |
| 3361 | cciss_remove_one(hba[i]->pdev); | 3408 | cciss_remove_one(hba[i]->pdev); |
| 3362 | } | 3409 | } |
| 3363 | } | 3410 | } |
| @@ -3372,21 +3419,21 @@ static void fail_all_cmds(unsigned long ctlr) | |||
| 3372 | unsigned long flags; | 3419 | unsigned long flags; |
| 3373 | 3420 | ||
| 3374 | printk(KERN_WARNING "cciss%d: controller not responding.\n", h->ctlr); | 3421 | printk(KERN_WARNING "cciss%d: controller not responding.\n", h->ctlr); |
| 3375 | h->alive = 0; /* the controller apparently died... */ | 3422 | h->alive = 0; /* the controller apparently died... */ |
| 3376 | 3423 | ||
| 3377 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | 3424 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); |
| 3378 | 3425 | ||
| 3379 | pci_disable_device(h->pdev); /* Make sure it is really dead. */ | 3426 | pci_disable_device(h->pdev); /* Make sure it is really dead. */ |
| 3380 | 3427 | ||
| 3381 | /* move everything off the request queue onto the completed queue */ | 3428 | /* move everything off the request queue onto the completed queue */ |
| 3382 | while( (c = h->reqQ) != NULL ) { | 3429 | while ((c = h->reqQ) != NULL) { |
| 3383 | removeQ(&(h->reqQ), c); | 3430 | removeQ(&(h->reqQ), c); |
| 3384 | h->Qdepth--; | 3431 | h->Qdepth--; |
| 3385 | addQ (&(h->cmpQ), c); | 3432 | addQ(&(h->cmpQ), c); |
| 3386 | } | 3433 | } |
| 3387 | 3434 | ||
| 3388 | /* Now, fail everything on the completed queue with a HW error */ | 3435 | /* Now, fail everything on the completed queue with a HW error */ |
| 3389 | while( (c = h->cmpQ) != NULL ) { | 3436 | while ((c = h->cmpQ) != NULL) { |
| 3390 | removeQ(&h->cmpQ, c); | 3437 | removeQ(&h->cmpQ, c); |
| 3391 | c->err_info->CommandStatus = CMD_HARDWARE_ERR; | 3438 | c->err_info->CommandStatus = CMD_HARDWARE_ERR; |
| 3392 | if (c->cmd_type == CMD_RWREQ) { | 3439 | if (c->cmd_type == CMD_RWREQ) { |
| @@ -3394,8 +3441,8 @@ static void fail_all_cmds(unsigned long ctlr) | |||
| 3394 | } else if (c->cmd_type == CMD_IOCTL_PEND) | 3441 | } else if (c->cmd_type == CMD_IOCTL_PEND) |
| 3395 | complete(c->waiting); | 3442 | complete(c->waiting); |
| 3396 | #ifdef CONFIG_CISS_SCSI_TAPE | 3443 | #ifdef CONFIG_CISS_SCSI_TAPE |
| 3397 | else if (c->cmd_type == CMD_SCSI) | 3444 | else if (c->cmd_type == CMD_SCSI) |
| 3398 | complete_scsi_command(c, 0, 0); | 3445 | complete_scsi_command(c, 0, 0); |
| 3399 | #endif | 3446 | #endif |
| 3400 | } | 3447 | } |
| 3401 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | 3448 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); |
