]>
Commit | Line | Data |
---|---|---|
28741dc2 | 1 | diff -uNr linux-2.6.16.orig/Documentation/cciss.txt linux-2.6.16/Documentation/cciss.txt |
2 | --- linux-2.6.16.orig/Documentation/cciss.txt 2006-03-20 06:53:29.000000000 +0100 | |
3 | +++ linux-2.6.16/Documentation/cciss.txt 2008-10-03 02:40:19.000000000 +0200 | |
4 | @@ -16,10 +16,16 @@ | |
5 | * SA 6i | |
6 | * SA P600 | |
7 | * SA P800 | |
8 | - * SA E400 | |
9 | + * SA P400 | |
10 | * SA P400i | |
11 | * SA E200 | |
12 | * SA E200i | |
13 | + * SA E500 | |
14 | + | |
15 | +This driver also implements a new method of detecting HP Smart Array | |
16 | +controllers. If an "unknown" controller is detected, we will attempt to | |
17 | +bind to the controller. On success a message is displayed informing the | |
18 | +user to upgrade the driver. On failure we bail. | |
19 | ||
20 | If nodes are not already created in the /dev/cciss directory, run as root: | |
21 | ||
22 | @@ -36,8 +42,8 @@ | |
23 | Major numbers: | |
24 | 104 cciss0 | |
25 | 105 cciss1 | |
26 | - 106 cciss2 | |
27 | - 105 cciss3 | |
28 | + 106 cciss2 | |
29 | + 107 cciss3 | |
30 | 108 cciss4 | |
31 | 109 cciss5 | |
32 | 110 cciss6 | |
33 | @@ -79,7 +85,7 @@ | |
34 | the SCSI core may not yet be initialized (because the driver is a block | |
35 | driver) and attempting to register it with the SCSI core in such a case | |
36 | would cause a hang. This is best done via an initialization script | |
37 | -(typically in /etc/init.d, but could vary depending on distibution). | |
38 | +(typically in /etc/init.d, but could vary depending on distribution). | |
39 | For example: | |
40 | ||
41 | for x in /proc/driver/cciss/cciss[0-9]* | |
42 | @@ -145,18 +151,18 @@ | |
43 | If that doesn't work, the SCSI bus is reset. If that doesn't work | |
44 | the host bus adapter is reset. Because the cciss driver is a block | |
45 | driver as well as a SCSI driver and only the tape drives and medium | |
46 | -changers are presented to the SCSI mid layer, and unlike more | |
47 | +changers are presented to the SCSI mid layer, and unlike more | |
48 | straightforward SCSI drivers, disk i/o continues through the block | |
49 | side during the SCSI error recovery process, the cciss driver only | |
50 | implements the first two of these actions, aborting the command, and | |
51 | -resetting the device. Additionally, most tape drives will not oblige | |
52 | -in aborting commands, and sometimes it appears they will not even | |
53 | -obey a reset coommand, though in most circumstances they will. In | |
54 | -the case that the command cannot be aborted and the device cannot be | |
55 | +resetting the device. Additionally, most tape drives will not oblige | |
56 | +in aborting commands, and sometimes it appears they will not even | |
57 | +obey a reset command, though in most circumstances they will. In | |
58 | +the case that the command cannot be aborted and the device cannot be | |
59 | reset, the device will be set offline. | |
60 | ||
61 | In the event the error handling code is triggered and a tape drive is | |
62 | -successfully reset or the tardy command is successfully aborted, the | |
63 | +successfully reset or the tardy command is successfully aborted, the | |
64 | tape drive may still not allow i/o to continue until some command | |
65 | is issued which positions the tape to a known position. Typically you | |
66 | must rewind the tape (by issuing "mt -f /dev/st0 rewind" for example) | |
67 | diff -uNr linux-2.6.16.orig/drivers/block/cciss.c linux-2.6.16/drivers/block/cciss.c | |
68 | --- linux-2.6.16.orig/drivers/block/cciss.c 2008-11-02 19:51:53.000000000 +0100 | |
69 | +++ linux-2.6.16/drivers/block/cciss.c 2008-10-03 02:40:19.000000000 +0200 | |
70 | @@ -33,6 +33,7 @@ | |
71 | #include <linux/bio.h> | |
72 | #include <linux/blkpg.h> | |
73 | #include <linux/timer.h> | |
74 | +#include <linux/seq_file.h> | |
75 | #include <linux/proc_fs.h> | |
76 | #include <linux/init.h> | |
77 | #include <linux/hdreg.h> | |
78 | @@ -40,111 +41,121 @@ | |
79 | #include <linux/compat.h> | |
80 | #include <asm/uaccess.h> | |
81 | #include <asm/io.h> | |
82 | +#include <asm/div64.h> | |
83 | + | |
84 | +#ifdef CONFIG_BLK_DEV_IO_TRACE | |
85 | +#include <linux/blktrace_api.h> | |
86 | +#endif | |
87 | ||
88 | #include <linux/dma-mapping.h> | |
89 | #include <linux/blkdev.h> | |
90 | #include <linux/genhd.h> | |
91 | #include <linux/completion.h> | |
92 | +#include <scsi/scsi.h> | |
93 | +#include <scsi/sg.h> | |
94 | +#include <scsi/scsi_ioctl.h> | |
95 | +#include <linux/cdrom.h> | |
96 | ||
97 | #define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin)) | |
98 | -#define DRIVER_NAME "HP CISS Driver (v 2.6.10)" | |
99 | -#define DRIVER_VERSION CCISS_DRIVER_VERSION(2,6,10) | |
100 | +#define DRIVER_NAME "HP CISS Driver (v 3.6.18)" | |
101 | +#define DRIVER_VERSION CCISS_DRIVER_VERSION(3,6,18) | |
102 | ||
103 | /* Embedded module documentation macros - see modules.h */ | |
104 | MODULE_AUTHOR("Hewlett-Packard Company"); | |
105 | -MODULE_DESCRIPTION("Driver for HP Controller SA5xxx SA6xxx version 2.6.10"); | |
106 | +MODULE_DESCRIPTION("Driver for HP Controller SA5xxx SA6xxx version 3.6.18"); | |
107 | MODULE_SUPPORTED_DEVICE("HP SA5i SA5i+ SA532 SA5300 SA5312 SA641 SA642 SA6400" | |
108 | - " SA6i P600 P800 P400 P400i E200 E200i"); | |
109 | + " SA6i P600 P800 P400 P400i E200 E200i E500"); | |
110 | MODULE_LICENSE("GPL"); | |
111 | ||
112 | #include "cciss_cmd.h" | |
113 | #include "cciss.h" | |
114 | #include <linux/cciss_ioctl.h> | |
115 | ||
116 | +#ifndef PCI_DEVICE_ID_COMPAQ_CISSC | |
117 | +#define PCI_DEVICE_ID_COMPAQ_CISSC 0x46 | |
118 | +#endif | |
119 | +#ifndef PCI_DEVICE_ID_HP_CISS | |
120 | +#define PCI_DEVICE_ID_HP_CISS 0x3210 | |
121 | +#endif | |
122 | +#ifndef PCI_DEVICE_ID_HP_CISSA | |
123 | +#define PCI_DEVICE_ID_HP_CISSA 0x3220 | |
124 | +#endif | |
125 | +#ifndef PCI_DEVICE_ID_HP_CISSC | |
126 | +#define PCI_DEVICE_ID_HP_CISSC 0x3230 | |
127 | +#endif | |
128 | +#ifndef PCI_DEVICE_ID_HP_CISSD | |
129 | +#define PCI_DEVICE_ID_HP_CISSD 0x3238 | |
130 | +#endif | |
131 | /* define the PCI info for the cards we can control */ | |
132 | static const struct pci_device_id cciss_pci_device_id[] = { | |
133 | - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISS, | |
134 | - 0x0E11, 0x4070, 0, 0, 0}, | |
135 | - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, | |
136 | - 0x0E11, 0x4080, 0, 0, 0}, | |
137 | - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, | |
138 | - 0x0E11, 0x4082, 0, 0, 0}, | |
139 | - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, | |
140 | - 0x0E11, 0x4083, 0, 0, 0}, | |
141 | - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, | |
142 | - 0x0E11, 0x409A, 0, 0, 0}, | |
143 | - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, | |
144 | - 0x0E11, 0x409B, 0, 0, 0}, | |
145 | - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, | |
146 | - 0x0E11, 0x409C, 0, 0, 0}, | |
147 | - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, | |
148 | - 0x0E11, 0x409D, 0, 0, 0}, | |
149 | - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, | |
150 | - 0x0E11, 0x4091, 0, 0, 0}, | |
151 | - { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSA, | |
152 | - 0x103C, 0x3225, 0, 0, 0}, | |
153 | - { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, | |
154 | - 0x103c, 0x3223, 0, 0, 0}, | |
155 | - { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, | |
156 | - 0x103c, 0x3234, 0, 0, 0}, | |
157 | - { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, | |
158 | - 0x103c, 0x3235, 0, 0, 0}, | |
159 | - { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, | |
160 | - 0x103c, 0x3211, 0, 0, 0}, | |
161 | - { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, | |
162 | - 0x103c, 0x3212, 0, 0, 0}, | |
163 | - { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, | |
164 | - 0x103c, 0x3213, 0, 0, 0}, | |
165 | - { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, | |
166 | - 0x103c, 0x3214, 0, 0, 0}, | |
167 | - { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, | |
168 | - 0x103c, 0x3215, 0, 0, 0}, | |
169 | + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISS, 0x0E11, 0x4070}, | |
170 | + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, 0x0E11, 0x4080}, | |
171 | + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, 0x0E11, 0x4082}, | |
172 | + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSB, 0x0E11, 0x4083}, | |
173 | + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, 0x0E11, 0x409A}, | |
174 | + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, 0x0E11, 0x409B}, | |
175 | + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, 0x0E11, 0x409C}, | |
176 | + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, 0x0E11, 0x409D}, | |
177 | + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, 0x0E11, 0x4091}, | |
178 | + {PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_CISSC, 0x0E11, 0x409E}, | |
179 | + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSA, 0x103C, 0x3225}, | |
180 | + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103c, 0x3234}, | |
181 | + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103c, 0x3235}, | |
182 | + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103c, 0x3211}, | |
183 | + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103c, 0x3212}, | |
184 | + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103c, 0x3213}, | |
185 | + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103c, 0x3214}, | |
186 | + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103c, 0x3215}, | |
187 | + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x3223}, | |
188 | + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103c, 0x3237}, | |
189 | + {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x323D}, | |
190 | + {PCI_VENDOR_ID_HP, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, | |
191 | + PCI_CLASS_STORAGE_RAID << 8, 0xffff << 8, 0}, | |
192 | {0,} | |
193 | }; | |
194 | MODULE_DEVICE_TABLE(pci, cciss_pci_device_id); | |
195 | ||
196 | -#define NR_PRODUCTS ARRAY_SIZE(products) | |
197 | - | |
198 | /* board_id = Subsystem Device ID & Vendor ID | |
199 | * product = Marketing Name for the board | |
200 | * access = Address of the struct of function pointers | |
201 | + * nr_cmds = Number of commands supported by controller | |
202 | */ | |
203 | static struct board_type products[] = { | |
204 | - { 0x40700E11, "Smart Array 5300", &SA5_access }, | |
205 | - { 0x40800E11, "Smart Array 5i", &SA5B_access}, | |
206 | - { 0x40820E11, "Smart Array 532", &SA5B_access}, | |
207 | - { 0x40830E11, "Smart Array 5312", &SA5B_access}, | |
208 | - { 0x409A0E11, "Smart Array 641", &SA5_access}, | |
209 | - { 0x409B0E11, "Smart Array 642", &SA5_access}, | |
210 | - { 0x409C0E11, "Smart Array 6400", &SA5_access}, | |
211 | - { 0x409D0E11, "Smart Array 6400 EM", &SA5_access}, | |
212 | - { 0x40910E11, "Smart Array 6i", &SA5_access}, | |
213 | - { 0x3225103C, "Smart Array P600", &SA5_access}, | |
214 | - { 0x3223103C, "Smart Array P800", &SA5_access}, | |
215 | - { 0x3234103C, "Smart Array P400", &SA5_access}, | |
216 | - { 0x3235103C, "Smart Array P400i", &SA5_access}, | |
217 | - { 0x3211103C, "Smart Array E200i", &SA5_access}, | |
218 | - { 0x3212103C, "Smart Array E200", &SA5_access}, | |
219 | - { 0x3213103C, "Smart Array E200i", &SA5_access}, | |
220 | - { 0x3214103C, "Smart Array E200i", &SA5_access}, | |
221 | - { 0x3215103C, "Smart Array E200i", &SA5_access}, | |
222 | + { 0x40700E11, "Smart Array 5300", &SA5_access, 384}, | |
223 | + { 0x40800E11, "Smart Array 5i", &SA5B_access, 384}, | |
224 | + { 0x40820E11, "Smart Array 532", &SA5B_access, 384}, | |
225 | + { 0x40830E11, "Smart Array 5312", &SA5B_access, 384}, | |
226 | + { 0x409A0E11, "Smart Array 641", &SA5_access, 384}, | |
227 | + { 0x409B0E11, "Smart Array 642", &SA5_access, 384}, | |
228 | + { 0x409C0E11, "Smart Array 6400", &SA5_access, 384}, | |
229 | + { 0x409D0E11, "Smart Array 6400 EM", &SA5_access, 384}, | |
230 | + { 0x40910E11, "Smart Array 6i", &SA5_access, 384}, | |
231 | + { 0x409E0E11, "Smart Array 6422", &SA5_access, 384}, | |
232 | + { 0x3225103C, "Smart Array P600", &SA5_access, 384}, | |
233 | + { 0x3234103C, "Smart Array P400", &SA5_access, 512}, | |
234 | + { 0x3235103C, "Smart Array P400i", &SA5_access, 512}, | |
235 | + { 0x3211103C, "Smart Array E200i", &SA5_access,120}, | |
236 | + { 0x3212103C, "Smart Array E200", &SA5_access,120}, | |
237 | + { 0x3213103C, "Smart Array E200i", &SA5_access,120}, | |
238 | + { 0x3214103C, "Smart Array E200i", &SA5_access, 120}, | |
239 | + { 0x3215103C, "Smart Array E200i", &SA5_access, 120}, | |
240 | + { 0x3223103C, "Smart Array P800", &SA5_access, 512}, | |
241 | + { 0x3237103C, "Smart Array E500", &SA5_access, 128}, | |
242 | + { 0x323D103C, "Smart Array P700m", &SA5_access, 512}, | |
243 | + { 0xFFFF103C, "Unknown Smart Array", &SA5_access, 120}, | |
244 | }; | |
245 | ||
246 | -/* How long to wait (in millesconds) for board to go into simple mode */ | |
247 | +/* How long to wait (in millisconds) for board to go into simple mode */ | |
248 | #define MAX_CONFIG_WAIT 30000 | |
249 | #define MAX_IOCTL_CONFIG_WAIT 1000 | |
250 | ||
251 | /*define how many times we will try a command because of bus resets */ | |
252 | #define MAX_CMD_RETRIES 3 | |
253 | - | |
254 | -#define READ_AHEAD 1024 | |
255 | -#define NR_CMDS 384 /* #commands that can be outstanding */ | |
256 | #define MAX_CTLR 32 | |
257 | ||
258 | /* Originally cciss driver only supports 8 major numbers */ | |
259 | #define MAX_CTLR_ORIG 8 | |
260 | ||
261 | - | |
262 | static ctlr_info_t *hba[MAX_CTLR]; | |
263 | ||
264 | static void do_cciss_request(request_queue_t *q); | |
265 | @@ -155,35 +166,40 @@ | |
266 | unsigned int cmd, unsigned long arg); | |
267 | static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo); | |
268 | ||
269 | -static int revalidate_allvol(ctlr_info_t *host); | |
270 | static int cciss_revalidate(struct gendisk *disk); | |
271 | static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk); | |
272 | -static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, int clear_all); | |
273 | - | |
274 | -static void cciss_read_capacity(int ctlr, int logvol, ReadCapdata_struct *buf, | |
275 | - int withirq, unsigned int *total_size, unsigned int *block_size); | |
276 | +static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, | |
277 | + int clear_all); | |
278 | +static void cciss_read_capacity(int ctlr, int logvol, int withirq, | |
279 | + sector_t *total_size, unsigned int *block_size); | |
280 | +static void cciss_read_capacity_16(int ctlr, int logvol, int withirq, | |
281 | + sector_t *total_size, unsigned int *block_size); | |
282 | static void cciss_geometry_inquiry(int ctlr, int logvol, | |
283 | - int withirq, unsigned int total_size, | |
284 | + int withirq, sector_t total_size, | |
285 | unsigned int block_size, InquiryData_struct *inq_buff, | |
286 | drive_info_struct *drv); | |
287 | static void cciss_getgeometry(int cntl_num); | |
288 | -static void __devinit cciss_interrupt_mode(ctlr_info_t *, struct pci_dev *, __u32); | |
289 | +static void __devinit cciss_interrupt_mode(ctlr_info_t *, struct pci_dev *, | |
290 | + __u32); | |
291 | static void start_io( ctlr_info_t *h); | |
292 | static int sendcmd( __u8 cmd, int ctlr, void *buff, size_t size, | |
293 | - unsigned int use_unit_num, unsigned int log_unit, __u8 page_code, | |
294 | - unsigned char *scsi3addr, int cmd_type); | |
295 | + unsigned int use_unit_num, unsigned int log_unit, | |
296 | + __u8 page_code, unsigned char *scsi3addr, int cmd_type); | |
297 | static int sendcmd_withirq(__u8 cmd, int ctlr, void *buff, size_t size, | |
298 | - unsigned int use_unit_num, unsigned int log_unit, __u8 page_code, | |
299 | - int cmd_type); | |
300 | + unsigned int use_unit_num, unsigned int log_unit, | |
301 | + __u8 page_code, int cmd_type); | |
302 | ||
303 | -static void fail_all_cmds(unsigned long ctlr); | |
304 | +static void cciss_shutdown (struct pci_dev *pdev); | |
305 | +static void __devexit cciss_remove_one(struct pci_dev *pdev); | |
306 | ||
307 | +static void fail_all_cmds(unsigned long ctlr); | |
308 | +static void print_cmd(CommandList_struct *); | |
309 | #ifdef CONFIG_PROC_FS | |
310 | -static int cciss_proc_get_info(char *buffer, char **start, off_t offset, | |
311 | - int length, int *eof, void *data); | |
312 | static void cciss_procinit(int i); | |
313 | #else | |
314 | -static void cciss_procinit(int i) {} | |
315 | +static void cciss_procinit(int i) | |
316 | +{ | |
317 | +} | |
318 | #endif /* CONFIG_PROC_FS */ | |
319 | ||
320 | #ifdef CONFIG_COMPAT | |
321 | @@ -222,7 +238,8 @@ | |
322 | CommandList_struct *c) | |
323 | { | |
324 | if (c && c->next != c) { | |
325 | - if (*Qptr == c) *Qptr = c->next; | |
326 | + if (*Qptr == c) | |
327 | + *Qptr = c->next; | |
328 | c->prev->next = c->next; | |
329 | c->next->prev = c->prev; | |
330 | } else { | |
331 | @@ -231,46 +248,492 @@ | |
332 | return c; | |
333 | } | |
334 | ||
335 | -#include "cciss_scsi.c" /* For SCSI tape support */ | |
336 | +static inline int find_drv_index(int ctlr, drive_info_struct *drv){ | |
337 | + int i; | |
338 | + for (i=0; i < CISS_MAX_LUN; i++) { | |
339 | + if (hba[ctlr]->drv[i].LunID == drv->LunID) | |
340 | + return i; | |
341 | + } | |
342 | + return i; | |
343 | +} | |
344 | ||
345 | -#ifdef CONFIG_PROC_FS | |
346 | +#include "cciss_scsi.c" /* For SCSI tape support */ | |
347 | ||
348 | -/* | |
349 | - * Report information about this controller. | |
350 | - */ | |
351 | #define ENG_GIG 1000000000 | |
352 | #define ENG_GIG_FACTOR (ENG_GIG/512) | |
353 | #define RAID_UNKNOWN 6 | |
354 | +#define ENGAGE_SCSI "engage scsi" | |
355 | +#define RESCAN_VOLUMES "rescan volumes" | |
356 | + | |
357 | static const char *raid_label[] = {"0","4","1(1+0)","5","5+1","ADG", | |
358 | "UNKNOWN"}; | |
359 | ||
360 | -static struct proc_dir_entry *proc_cciss; | |
361 | +static spinlock_t sysfs_lock = SPIN_LOCK_UNLOCKED; | |
362 | + | |
363 | +static void cciss_sysfs_stat_inquiry(int ctlr, int logvol, | |
364 | + int withirq, drive_info_struct *drv) | |
365 | +{ | |
366 | + int return_code; | |
367 | + InquiryData_struct *inq_buff; | |
368 | + | |
369 | + /* If there are no heads then this is the controller disk and | |
370 | + * not a valid logical drive so don't query it. | |
371 | + */ | |
372 | + if (!drv->heads) | |
373 | + return; | |
374 | + | |
375 | + inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL); | |
376 | + if (!inq_buff) { | |
377 | + printk(KERN_ERR "cciss: out of memory\n"); | |
378 | + goto err; | |
379 | + } | |
380 | + | |
381 | + if (withirq) | |
382 | + return_code = sendcmd_withirq(CISS_INQUIRY, ctlr, | |
383 | + inq_buff, sizeof(*inq_buff), 1, logvol ,0, TYPE_CMD); | |
384 | + else | |
385 | + return_code = sendcmd(CISS_INQUIRY, ctlr, inq_buff, | |
386 | + sizeof(*inq_buff), 1, logvol , 0, NULL, TYPE_CMD); | |
387 | + if (return_code == IO_OK) { | |
388 | + memcpy(drv->vendor, &inq_buff->data_byte[8], 8); | |
389 | + drv->vendor[8]='\0'; | |
390 | + memcpy(drv->model, &inq_buff->data_byte[16], 16); | |
391 | + drv->model[16] = '\0'; | |
392 | + memcpy(drv->rev, &inq_buff->data_byte[32], 4); | |
393 | + drv->rev[4] = '\0'; | |
394 | + } else { /* Get geometry failed */ | |
395 | + printk(KERN_WARNING "cciss: inquiry for VPD page 0 failed\n"); | |
396 | + } | |
397 | + | |
398 | + if (withirq) | |
399 | + return_code = sendcmd_withirq(CISS_INQUIRY, ctlr, | |
400 | + inq_buff, sizeof(*inq_buff), 1, logvol ,0x83, TYPE_CMD); | |
401 | + else | |
402 | + return_code = sendcmd(CISS_INQUIRY, ctlr, inq_buff, | |
403 | + sizeof(*inq_buff), 1, logvol , 0x83, NULL, TYPE_CMD); | |
404 | + | |
405 | + if (return_code == IO_OK) { | |
406 | + memcpy(drv->uid, &inq_buff->data_byte[8], 16); | |
407 | + } else { /* Get geometry failed */ | |
408 | + printk(KERN_WARNING "cciss: id logical drive failed\n"); | |
409 | + } | |
410 | + | |
411 | + kfree(inq_buff); | |
412 | +err: | |
413 | + drv->vendor[8] = '\0'; | |
414 | + drv->model[16] = '\0'; | |
415 | + drv->rev[4] = '\0'; | |
416 | + | |
417 | +} | |
418 | ||
419 | -static int cciss_proc_get_info(char *buffer, char **start, off_t offset, | |
420 | - int length, int *eof, void *data) | |
421 | +static ssize_t cciss_show_raid_level(struct device *dev, | |
422 | + struct device_attribute *attr, char *buf) | |
423 | { | |
424 | - off_t pos = 0; | |
425 | - off_t len = 0; | |
426 | - int size, i, ctlr; | |
427 | - ctlr_info_t *h = (ctlr_info_t*)data; | |
428 | - drive_info_struct *drv; | |
429 | + struct drv_dynamic *d; | |
430 | + drive_info_struct *drv; | |
431 | + ctlr_info_t *h; | |
432 | unsigned long flags; | |
433 | - sector_t vol_sz, vol_sz_frac; | |
434 | + int raid; | |
435 | ||
436 | - ctlr = h->ctlr; | |
437 | + d = container_of(dev, struct drv_dynamic, dev); | |
438 | + spin_lock(&sysfs_lock); | |
439 | + if (!d->disk) { | |
440 | + spin_unlock(&sysfs_lock); | |
441 | + return -ENOENT; | |
442 | + } | |
443 | ||
444 | - /* prevent displaying bogus info during configuration | |
445 | - * or deconfiguration of a logical volume | |
446 | - */ | |
447 | - spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | |
448 | + h = get_host(d->disk); | |
449 | + | |
450 | + spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | |
451 | if (h->busy_configuring) { | |
452 | - spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | |
453 | - return -EBUSY; | |
454 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
455 | + spin_unlock(&sysfs_lock); | |
456 | + return snprintf(buf, 30, "Device busy configuring\n"); | |
457 | } | |
458 | - h->busy_configuring = 1; | |
459 | - spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | |
460 | ||
461 | - size = sprintf(buffer, "%s: HP %s Controller\n" | |
462 | + drv = d->disk->private_data; | |
463 | + if ((drv->raid_level < 0) || (drv->raid_level) > 5) | |
464 | + raid = RAID_UNKNOWN; | |
465 | + else | |
466 | + raid = drv->raid_level; | |
467 | + | |
468 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
469 | + spin_unlock(&sysfs_lock); | |
470 | + return snprintf(buf, 20, "RAID %s\n", raid_label[raid]); | |
471 | +} | |
472 | + | |
473 | +static ssize_t cciss_show_disk_size(struct device *dev, | |
474 | + struct device_attribute *attr, char *buf) | |
475 | +{ | |
476 | + struct drv_dynamic *d; | |
477 | + drive_info_struct *drv; | |
478 | + ctlr_info_t *h; | |
479 | + unsigned long flags; | |
480 | + sector_t vol_sz, vol_sz_frac; | |
481 | + | |
482 | + d = container_of(dev, struct drv_dynamic, dev); | |
483 | + spin_lock(&sysfs_lock); | |
484 | + if (!d->disk) { | |
485 | + spin_unlock(&sysfs_lock); | |
486 | + return -ENOENT; | |
487 | + } | |
488 | + h = get_host(d->disk); | |
489 | + | |
490 | + spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | |
491 | + if (h->busy_configuring) { | |
492 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
493 | + spin_unlock(&sysfs_lock); | |
494 | + return snprintf(buf, 30, "Device busy configuring\n"); | |
495 | + } | |
496 | + | |
497 | + drv = d->disk->private_data; | |
498 | + vol_sz = drv->nr_blocks; | |
499 | + vol_sz_frac = sector_div(vol_sz, ENG_GIG_FACTOR); | |
500 | + vol_sz_frac *= 100; | |
501 | + sector_div(vol_sz_frac, ENG_GIG_FACTOR); | |
502 | + | |
503 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
504 | + spin_unlock(&sysfs_lock); | |
505 | + return snprintf(buf, 30, "%4u.%02uGB\n", (int)vol_sz, (int)vol_sz_frac); | |
506 | +} | |
507 | + | |
508 | +static ssize_t cciss_show_usage_count(struct device *dev, | |
509 | + struct device_attribute *attr, char *buf) | |
510 | +{ | |
511 | + struct drv_dynamic *d; | |
512 | + drive_info_struct *drv; | |
513 | + int count; | |
514 | + | |
515 | + d = container_of(dev, struct drv_dynamic, dev); | |
516 | + spin_lock(&sysfs_lock); | |
517 | + if (!d->disk) { | |
518 | + spin_unlock(&sysfs_lock); | |
519 | + return -ENOENT; | |
520 | + } | |
521 | + drv = d->disk->private_data; | |
522 | + count = drv->usage_count; | |
523 | + spin_unlock(&sysfs_lock); | |
524 | + return snprintf(buf, 20, "%d\n", count); | |
525 | +} | |
526 | + | |
527 | +static ssize_t cciss_show_vendor(struct device *dev, | |
528 | + struct device_attribute *attr, char *buf) | |
529 | +{ | |
530 | + struct drv_dynamic *d; | |
531 | + drive_info_struct *drv; | |
532 | + ctlr_info_t *h; | |
533 | + unsigned long flags; | |
534 | + int drv_index; | |
535 | + | |
536 | + d = container_of(dev, struct drv_dynamic, dev); | |
537 | + spin_lock(&sysfs_lock); | |
538 | + if (!d->disk) { | |
539 | + spin_unlock(&sysfs_lock); | |
540 | + return -ENOENT; | |
541 | + } | |
542 | + | |
543 | + h = get_host(d->disk); | |
544 | + | |
545 | + spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | |
546 | + if (h->busy_configuring) { | |
547 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
548 | + spin_unlock(&sysfs_lock); | |
549 | + return -EBUSY; | |
550 | + } | |
551 | + | |
552 | + drv = d->disk->private_data; | |
553 | + | |
554 | + if (!drv->heads) { | |
555 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
556 | + spin_unlock(&sysfs_lock); | |
557 | + return -ENOTTY; | |
558 | + } | |
559 | + | |
560 | + drv_index = find_drv_index(h->ctlr, drv); | |
561 | + if (drv_index != CISS_MAX_LUN) { | |
562 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
563 | + spin_unlock(&sysfs_lock); | |
564 | + return snprintf(buf, 20, "%s\n", (char *)drv->vendor); | |
565 | + } | |
566 | + | |
567 | + printk(KERN_ERR "cciss: logical drive not found\n"); | |
568 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
569 | + spin_unlock(&sysfs_lock); | |
570 | + return -ENOTTY; | |
571 | +} | |
572 | + | |
573 | +static ssize_t cciss_show_model(struct device *dev, | |
574 | + struct device_attribute *attr, char *buf) | |
575 | +{ | |
576 | + struct drv_dynamic *d; | |
577 | + drive_info_struct *drv; | |
578 | + ctlr_info_t *h; | |
579 | + unsigned long flags; | |
580 | + int drv_index; | |
581 | + | |
582 | + d = container_of(dev, struct drv_dynamic, dev); | |
583 | + spin_lock(&sysfs_lock); | |
584 | + if (!d->disk) { | |
585 | + spin_unlock(&sysfs_lock); | |
586 | + return -ENOENT; | |
587 | + } | |
588 | + | |
589 | + h = get_host(d->disk); | |
590 | + | |
591 | + spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | |
592 | + if (h->busy_configuring) { | |
593 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
594 | + spin_unlock(&sysfs_lock); | |
595 | + return -EBUSY; | |
596 | + } | |
597 | + | |
598 | + drv = d->disk->private_data; | |
599 | + | |
600 | + if (!drv->heads) { | |
601 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
602 | + spin_unlock(&sysfs_lock); | |
603 | + return -ENOTTY; | |
604 | + } | |
605 | + | |
606 | + drv_index = find_drv_index(h->ctlr, drv); | |
607 | + if (drv_index != CISS_MAX_LUN) { | |
608 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
609 | + spin_unlock(&sysfs_lock); | |
610 | + return snprintf(buf, 20, "%s\n", (char *)drv->model); | |
611 | + } | |
612 | + printk(KERN_ERR "cciss: logical drive not found\n"); | |
613 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
614 | + spin_unlock(&sysfs_lock); | |
615 | + return -ENOTTY; | |
616 | +} | |
617 | + | |
618 | +static ssize_t cciss_show_rev(struct device *dev, | |
619 | + struct device_attribute *attr, char *buf) | |
620 | +{ | |
621 | + struct drv_dynamic *d; | |
622 | + drive_info_struct *drv; | |
623 | + ctlr_info_t *h; | |
624 | + unsigned long flags; | |
625 | + int drv_index; | |
626 | + | |
627 | + d = container_of(dev, struct drv_dynamic, dev); | |
628 | + spin_lock(&sysfs_lock); | |
629 | + if (!d->disk) { | |
630 | + spin_unlock(&sysfs_lock); | |
631 | + return -ENOENT; | |
632 | + } | |
633 | + | |
634 | + h = get_host(d->disk); | |
635 | + | |
636 | + spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | |
637 | + if (h->busy_configuring) { | |
638 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
639 | + spin_unlock(&sysfs_lock); | |
640 | + return -EBUSY; | |
641 | + } | |
642 | + | |
643 | + drv = d->disk->private_data; | |
644 | + | |
645 | + if (!drv->heads) { | |
646 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
647 | + spin_unlock(&sysfs_lock); | |
648 | + return -ENOTTY; | |
649 | + } | |
650 | + | |
651 | + drv_index = find_drv_index(h->ctlr, drv); | |
652 | + if (drv_index != CISS_MAX_LUN) { | |
653 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
654 | + spin_unlock(&sysfs_lock); | |
655 | + return snprintf(buf, 20, "%s\n", (char *)drv->rev); | |
656 | + } | |
657 | + | |
658 | + printk(KERN_ERR "cciss: logical drive not found\n"); | |
659 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
660 | + spin_unlock(&sysfs_lock); | |
661 | + return -ENOTTY; | |
662 | +} | |
663 | + | |
664 | +static ssize_t cciss_show_unique_id(struct device *dev, | |
665 | + struct device_attribute *attr, char *buf) | |
666 | +{ | |
667 | + struct drv_dynamic *d; | |
668 | + drive_info_struct *drv; | |
669 | + ctlr_info_t *h; | |
670 | + unsigned long flags; | |
671 | + int drv_index; | |
672 | + | |
673 | + d = container_of(dev, struct drv_dynamic, dev); | |
674 | + spin_lock(&sysfs_lock); | |
675 | + if (!d->disk) { | |
676 | + spin_unlock(&sysfs_lock); | |
677 | + return -ENOENT; | |
678 | + } | |
679 | + | |
680 | + h = get_host(d->disk); | |
681 | + | |
682 | + spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | |
683 | + if (h->busy_configuring) { | |
684 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
685 | + spin_unlock(&sysfs_lock); | |
686 | + return snprintf(buf, 30, "Device busy configuring\n"); | |
687 | + } | |
688 | + drv = d->disk->private_data; | |
689 | + | |
690 | + if (!drv->heads) { | |
691 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
692 | + spin_unlock(&sysfs_lock); | |
693 | + return -ENOTTY; | |
694 | + } | |
695 | + | |
696 | + drv_index = find_drv_index(h->ctlr, drv); | |
697 | + if (drv_index != CISS_MAX_LUN) { | |
698 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
699 | + spin_unlock(&sysfs_lock); | |
700 | + | |
701 | + return snprintf(buf, 40, "%02X%02X%02X%02X%02X%02X%02X%02X" | |
702 | + "%02X%02X%02X%02X%02X%02X%02X%02X\n", | |
703 | + drv->uid[0], drv->uid[1], drv->uid[2], | |
704 | + drv->uid[3], drv->uid[4], drv->uid[5], | |
705 | + drv->uid[6], drv->uid[7], drv->uid[8], | |
706 | + drv->uid[9], drv->uid[10], drv->uid[11], | |
707 | + drv->uid[12], drv->uid[13], drv->uid[14], | |
708 | + drv->uid[15]); | |
709 | + } | |
710 | + | |
711 | + printk(KERN_ERR "cciss: logical drive not found\n"); | |
712 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
713 | + spin_unlock(&sysfs_lock); | |
714 | + return -ENOENT; | |
715 | +} | |
716 | + | |
717 | +static ssize_t cciss_show_bus(struct device *dev, | |
718 | + struct device_attribute *attr, char *buf) | |
719 | +{ | |
720 | + return snprintf(buf, 20, "cciss\n"); | |
721 | +} | |
722 | + | |
723 | +static ssize_t cciss_show_lunid(struct device *dev, | |
724 | + struct device_attribute *attr, char *buf) | |
725 | +{ | |
726 | + struct drv_dynamic *d; | |
727 | + drive_info_struct *drv; | |
728 | + ctlr_info_t *h; | |
729 | + unsigned long flags; | |
730 | + int drv_index; | |
731 | + | |
732 | + d = container_of(dev, struct drv_dynamic, dev); | |
733 | + spin_lock(&sysfs_lock); | |
734 | + if (!d->disk) { | |
735 | + spin_unlock(&sysfs_lock); | |
736 | + return -ENOENT; | |
737 | + } | |
738 | + | |
739 | + h = get_host(d->disk); | |
740 | + | |
741 | + spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | |
742 | + if (h->busy_configuring) { | |
743 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
744 | + spin_unlock(&sysfs_lock); | |
745 | + return -EBUSY; | |
746 | + } | |
747 | + | |
748 | + drv = d->disk->private_data; | |
749 | + | |
750 | + if (!drv->heads) { | |
751 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
752 | + spin_unlock(&sysfs_lock); | |
753 | + return -ENOTTY; | |
754 | + } | |
755 | + | |
756 | + drv_index = find_drv_index(h->ctlr, drv); | |
757 | + if (drv_index != CISS_MAX_LUN) { | |
758 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
759 | + spin_unlock(&sysfs_lock); | |
760 | + return snprintf(buf, 20, "%d\n", drv->LunID); | |
761 | + } | |
762 | + | |
763 | + printk(KERN_ERR "cciss: logical drive not found\n"); | |
764 | + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
765 | + spin_unlock(&sysfs_lock); | |
766 | + return -ENOTTY; | |
767 | +} | |
768 | + | |
769 | +DEVICE_ATTR(raid_level, S_IRUGO | S_IWUSR, cciss_show_raid_level, NULL); | |
770 | +DEVICE_ATTR(disk_size, S_IRUGO | S_IWUSR, cciss_show_disk_size, NULL); | |
771 | +DEVICE_ATTR(usage_count, S_IRUGO | S_IWUSR, cciss_show_usage_count, NULL); | |
772 | +DEVICE_ATTR(vendor, S_IRUGO | S_IWUSR, cciss_show_vendor, NULL); | |
773 | +DEVICE_ATTR(model, S_IRUGO | S_IWUSR, cciss_show_model, NULL); | |
774 | +DEVICE_ATTR(rev, S_IRUGO | S_IWUSR, cciss_show_rev, NULL); | |
775 | +DEVICE_ATTR(unique_id, S_IRUGO | S_IWUSR, cciss_show_unique_id, NULL); | |
776 | +DEVICE_ATTR(bus, S_IRUGO | S_IWUSR, cciss_show_bus, NULL); | |
777 | +DEVICE_ATTR(lunid, S_IRUGO | S_IWUSR, cciss_show_lunid, NULL); | |
778 | + | |
779 | +static struct attribute *cciss_sysfs_attrs[] = { | |
780 | + &dev_attr_raid_level.attr, | |
781 | + &dev_attr_disk_size.attr, | |
782 | + &dev_attr_usage_count.attr, | |
783 | + &dev_attr_vendor.attr, | |
784 | + &dev_attr_model.attr, | |
785 | + &dev_attr_rev.attr, | |
786 | + &dev_attr_unique_id.attr, | |
787 | + &dev_attr_bus.attr, | |
788 | + &dev_attr_lunid.attr, | |
789 | + NULL | |
790 | +}; | |
791 | + | |
792 | +static struct attribute_group cciss_attrs = {.attrs = cciss_sysfs_attrs}; | |
793 | + | |
794 | +static void cciss_add_blk_sysfs_dev(drive_info_struct *drv, | |
795 | + struct gendisk* disk, | |
796 | + struct pci_dev *pdev, int disk_num) | |
797 | +{ | |
798 | + struct drv_dynamic *d = kmalloc(sizeof(struct drv_dynamic), GFP_KERNEL); | |
799 | + if (!d) | |
800 | + return; | |
801 | + memset(d, 0, sizeof(struct drv_dynamic)); | |
802 | + disk->driverfs_dev = &d->dev; | |
803 | + d->dev.parent = &pdev->dev; | |
804 | + d->dev.release = (void (*)(struct device *))kfree; | |
805 | + sprintf(d->dev.bus_id, "disk%d", disk_num); | |
806 | + d->dev.driver_data = "cciss"; | |
807 | + if (device_register(&d->dev)) { | |
808 | + put_device(&d->dev); | |
809 | + return; | |
810 | + } | |
811 | + sysfs_create_group(&d->dev.kobj, &cciss_attrs); | |
812 | + d->disk = disk; | |
813 | + drv->dev_info = &d->dev; | |
814 | +} | |
815 | + | |
816 | +static void cciss_remove_blk_sysfs_dev(struct gendisk *disk) | |
817 | +{ | |
818 | + drive_info_struct *drv = get_drv(disk); | |
819 | + struct drv_dynamic *d; | |
820 | + | |
821 | + if (!drv->dev_info) | |
822 | + return; | |
823 | + | |
824 | + d = container_of(drv->dev_info, struct drv_dynamic, dev); | |
825 | + spin_lock(&sysfs_lock); | |
826 | + sysfs_remove_group(&d->dev.kobj, &cciss_attrs); | |
827 | + d->disk = NULL; | |
828 | + spin_unlock(&sysfs_lock); | |
829 | + device_unregister(drv->dev_info); | |
830 | + drv->dev_info = NULL; | |
831 | +} | |
832 | + | |
833 | +#ifdef CONFIG_PROC_FS | |
834 | + | |
835 | +/* | |
836 | + * Report information about this controller. | |
837 | + */ | |
838 | +static struct proc_dir_entry *proc_cciss; | |
839 | + | |
840 | +static void cciss_seq_show_header(struct seq_file *seq) | |
841 | +{ | |
842 | + ctlr_info_t *h = seq->private; | |
843 | + | |
844 | + seq_printf(seq, "%s: HP %s Controller\n" | |
845 | "Board ID: 0x%08lx\n" | |
846 | "Firmware Version: %c%c%c%c\n" | |
847 | "IRQ: %d\n" | |
848 | @@ -279,94 +742,196 @@ | |
849 | "Current # commands on controller: %d\n" | |
850 | "Max Q depth since init: %d\n" | |
851 | "Max # commands on controller since init: %d\n" | |
852 | - "Max SG entries since init: %d\n\n", | |
853 | - h->devname, | |
854 | - h->product_name, | |
855 | - (unsigned long)h->board_id, | |
856 | - h->firm_ver[0], h->firm_ver[1], h->firm_ver[2], h->firm_ver[3], | |
857 | - (unsigned int)h->intr[SIMPLE_MODE_INT], | |
858 | - h->num_luns, | |
859 | + "Max SG entries since init: %d\n", | |
860 | + h->devname, | |
861 | + h->product_name, | |
862 | + (unsigned long)h->board_id, | |
863 | + h->firm_ver[0], h->firm_ver[1], h->firm_ver[2], | |
864 | + h->firm_ver[3], (unsigned int)h->intr[SIMPLE_MODE_INT], | |
865 | + h->num_luns, | |
866 | h->Qdepth, h->commands_outstanding, | |
867 | h->maxQsinceinit, h->max_outstanding, h->maxSG); | |
868 | + | |
869 | +#ifdef CONFIG_CISS_SCSI_TAPE | |
870 | + cciss_seq_tape_report(seq, h->ctlr); | |
871 | +#endif /* CONFIG_CISS_SCSI_TAPE */ | |
872 | +} | |
873 | ||
874 | - pos += size; len += size; | |
875 | - cciss_proc_tape_report(ctlr, buffer, &pos, &len); | |
876 | - for(i=0; i<=h->highest_lun; i++) { | |
877 | +static void *cciss_seq_start(struct seq_file *seq, loff_t *pos) | |
878 | +{ | |
879 | + ctlr_info_t *h = seq->private; | |
880 | + unsigned ctlr = h->ctlr; | |
881 | + unsigned long flags; | |
882 | ||
883 | - drv = &h->drv[i]; | |
884 | - if (drv->heads == 0) | |
885 | - continue; | |
886 | + /* prevent displaying bogus info during configuration | |
887 | + * or deconfiguration of a logical volume | |
888 | + */ | |
889 | + spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | |
890 | + if (h->busy_configuring) { | |
891 | + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | |
892 | + return ERR_PTR(-EBUSY); | |
893 | + } | |
894 | + h->busy_configuring = 1; | |
895 | + spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | |
896 | ||
897 | - vol_sz = drv->nr_blocks; | |
898 | - vol_sz_frac = sector_div(vol_sz, ENG_GIG_FACTOR); | |
899 | - vol_sz_frac *= 100; | |
900 | - sector_div(vol_sz_frac, ENG_GIG_FACTOR); | |
901 | + if (*pos == 0) | |
902 | + cciss_seq_show_header(seq); | |
903 | ||
904 | - if (drv->raid_level > 5) | |
905 | - drv->raid_level = RAID_UNKNOWN; | |
906 | - size = sprintf(buffer+len, "cciss/c%dd%d:" | |
907 | - "\t%4u.%02uGB\tRAID %s\n", | |
908 | - ctlr, i, (int)vol_sz, (int)vol_sz_frac, | |
909 | - raid_label[drv->raid_level]); | |
910 | - pos += size; len += size; | |
911 | - } | |
912 | + return pos; | |
913 | +} | |
914 | + | |
915 | +static int cciss_seq_show(struct seq_file *seq, void *v) | |
916 | +{ | |
917 | + sector_t vol_sz, vol_sz_frac; | |
918 | + ctlr_info_t *h = seq->private; | |
919 | + unsigned ctlr = h->ctlr; | |
920 | + loff_t *pos = v; | |
921 | + drive_info_struct *drv = &h->drv[*pos]; | |
922 | + | |
923 | + if (*pos > h->highest_lun) | |
924 | + return 0; | |
925 | + | |
926 | + if (drv->heads == 0) | |
927 | + return 0; | |
928 | + | |
929 | + vol_sz = drv->nr_blocks; | |
930 | + vol_sz_frac = sector_div(vol_sz, ENG_GIG_FACTOR); | |
931 | + vol_sz_frac *= 100; | |
932 | + sector_div(vol_sz_frac, ENG_GIG_FACTOR); | |
933 | + | |
934 | + if (drv->raid_level > 5) | |
935 | + drv->raid_level = RAID_UNKNOWN; | |
936 | + seq_printf(seq, "cciss/c%dd%d:" | |
937 | + "\t%4u.%02uGB\tRAID %s\n", | |
938 | + ctlr, (int) *pos, (int)vol_sz, (int)vol_sz_frac, | |
939 | + raid_label[drv->raid_level]); | |
940 | + return 0; | |
941 | +} | |
942 | + | |
943 | +static void *cciss_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |
944 | +{ | |
945 | + ctlr_info_t *h = seq->private; | |
946 | + | |
947 | + if (*pos > h->highest_lun) | |
948 | + return NULL; | |
949 | + *pos += 1; | |
950 | + | |
951 | + return pos; | |
952 | +} | |
953 | + | |
954 | +static void cciss_seq_stop(struct seq_file *seq, void *v) | |
955 | +{ | |
956 | + ctlr_info_t *h = seq->private; | |
957 | + | |
958 | + /* Only reset h->busy_configuring if we succeeded in setting | |
959 | + * it during cciss_seq_start. */ | |
960 | + if (v == ERR_PTR(-EBUSY)) | |
961 | + return; | |
962 | ||
963 | - *eof = 1; | |
964 | - *start = buffer+offset; | |
965 | - len -= offset; | |
966 | - if (len>length) | |
967 | - len = length; | |
968 | h->busy_configuring = 0; | |
969 | - return len; | |
970 | } | |
971 | ||
972 | -static int | |
973 | -cciss_proc_write(struct file *file, const char __user *buffer, | |
974 | - unsigned long count, void *data) | |
975 | +static struct seq_operations cciss_seq_ops = { | |
976 | + .start = cciss_seq_start, | |
977 | + .show = cciss_seq_show, | |
978 | + .next = cciss_seq_next, | |
979 | + .stop = cciss_seq_stop, | |
980 | +}; | |
981 | + | |
982 | +static int cciss_seq_open(struct inode *inode, struct file *file) | |
983 | +{ | |
984 | + int ret = seq_open(file, &cciss_seq_ops); | |
985 | + struct seq_file *seq = file->private_data; | |
986 | + | |
987 | + if (!ret) | |
988 | + seq->private = PDE(inode)->data; | |
989 | + | |
990 | + return ret; | |
991 | +} | |
992 | + | |
993 | +static ssize_t | |
994 | +cciss_proc_write(struct file *file, const char __user *buf, | |
995 | + size_t length, loff_t *ppos) | |
996 | { | |
997 | - unsigned char cmd[80]; | |
998 | - int len; | |
999 | -#ifdef CONFIG_CISS_SCSI_TAPE | |
1000 | - ctlr_info_t *h = (ctlr_info_t *) data; | |
1001 | + int err; | |
1002 | + char *buffer; | |
1003 | + struct seq_file *seq = file->private_data; | |
1004 | + ctlr_info_t *h = seq->private; | |
1005 | int rc; | |
1006 | -#endif | |
1007 | ||
1008 | - if (count > sizeof(cmd)-1) return -EINVAL; | |
1009 | - if (copy_from_user(cmd, buffer, count)) return -EFAULT; | |
1010 | - cmd[count] = '\0'; | |
1011 | - len = strlen(cmd); // above 3 lines ensure safety | |
1012 | - if (len && cmd[len-1] == '\n') | |
1013 | - cmd[--len] = '\0'; | |
1014 | -# ifdef CONFIG_CISS_SCSI_TAPE | |
1015 | - if (strcmp("engage scsi", cmd)==0) { | |
1016 | - rc = cciss_engage_scsi(h->ctlr); | |
1017 | - if (rc != 0) return -rc; | |
1018 | - return count; | |
1019 | - } | |
1020 | + if (!buf || length > PAGE_SIZE - 1) | |
1021 | + return -EINVAL; | |
1022 | + | |
1023 | + buffer = (char *)__get_free_page(GFP_KERNEL); | |
1024 | + if (!buffer) | |
1025 | + return -ENOMEM; | |
1026 | + | |
1027 | + err = -EFAULT; | |
1028 | + if (copy_from_user(buffer, buf, length)) | |
1029 | + goto out; | |
1030 | + buffer[length] = '\0'; | |
1031 | + | |
1032 | + /* For the MSA2000 the firmware cannot tell the driver to | |
1033 | + * rescan when new logical volumes are created. We provide | |
1034 | + * this interface so users can `echo "rescan volumes" > | |
1035 | + * /proc/driver/cciss/ccissN` to accomplish that task. It's not | |
1036 | + * the best solution because it must be done on every server | |
1037 | + * that connected to the storage. | |
1038 | + */ | |
1039 | + if (strncmp(RESCAN_VOLUMES, buffer, sizeof RESCAN_VOLUMES - 1) == 0) { | |
1040 | + /* rebuild_lun_table returns -1 on success to tell ACU | |
1041 | + * to quit calling it. In this case we just ignore any | |
1042 | + * return code. | |
1043 | + */ | |
1044 | + (void) rebuild_lun_table(h, NULL); | |
1045 | + err = length; | |
1046 | + goto out; | |
1047 | + } | |
1048 | + | |
1049 | +#ifdef CONFIG_CISS_SCSI_TAPE | |
1050 | + if (strncmp(ENGAGE_SCSI, buffer, sizeof ENGAGE_SCSI - 1) == 0) { | |
1051 | + rc = cciss_engage_scsi(h->ctlr); | |
1052 | + if (rc != 0) | |
1053 | + err = -rc; | |
1054 | + else | |
1055 | + err = length; | |
1056 | + } else | |
1057 | +#endif /* CONFIG_CISS_SCSI_TAPE */ | |
1058 | + err = -EINVAL; | |
1059 | /* might be nice to have "disengage" too, but it's not | |
1060 | safely possible. (only 1 module use count, lock issues.) */ | |
1061 | -# endif | |
1062 | - return -EINVAL; | |
1063 | + | |
1064 | +out: | |
1065 | + free_page((unsigned long)buffer); | |
1066 | + return err; | |
1067 | } | |
1068 | ||
1069 | -/* | |
1070 | - * Get us a file in /proc/cciss that says something about each controller. | |
1071 | - * Create /proc/cciss if it doesn't exist yet. | |
1072 | - */ | |
1073 | +static struct file_operations cciss_proc_fops = { | |
1074 | + .owner = THIS_MODULE, | |
1075 | + .open = cciss_seq_open, | |
1076 | + .read = seq_read, | |
1077 | + .llseek = seq_lseek, | |
1078 | + .release = seq_release, | |
1079 | + .write = cciss_proc_write, | |
1080 | +}; | |
1081 | + | |
1082 | static void __devinit cciss_procinit(int i) | |
1083 | { | |
1084 | struct proc_dir_entry *pde; | |
1085 | ||
1086 | - if (proc_cciss == NULL) { | |
1087 | + if (proc_cciss == NULL) | |
1088 | proc_cciss = proc_mkdir("cciss", proc_root_driver); | |
1089 | - if (!proc_cciss) | |
1090 | - return; | |
1091 | - } | |
1092 | ||
1093 | - pde = create_proc_read_entry(hba[i]->devname, | |
1094 | - S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH, | |
1095 | - proc_cciss, cciss_proc_get_info, hba[i]); | |
1096 | - pde->write_proc = cciss_proc_write; | |
1097 | + if (!proc_cciss) | |
1098 | + return; | |
1099 | + | |
1100 | + pde = create_proc_entry(hba[i]->devname, | |
1101 | + S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH, proc_cciss); | |
1102 | + if (!pde) | |
1103 | + return; | |
1104 | + | |
1105 | + pde->proc_fops = &cciss_proc_fops; | |
1106 | + pde->data = hba[i]; | |
1107 | } | |
1108 | #endif /* CONFIG_PROC_FS */ | |
1109 | ||
1110 | @@ -377,52 +942,51 @@ | |
1111 | * to possible sleep, this routine can be called with get_from_pool set to 0. | |
1112 | * cmd_free() MUST be called with a got_from_pool set to 0 if cmd_alloc was. | |
1113 | */ | |
1114 | -static CommandList_struct * cmd_alloc(ctlr_info_t *h, int get_from_pool) | |
1115 | +static CommandList_struct *cmd_alloc(ctlr_info_t *h, int get_from_pool) | |
1116 | { | |
1117 | CommandList_struct *c; | |
1118 | int i; | |
1119 | u64bit temp64; | |
1120 | dma_addr_t cmd_dma_handle, err_dma_handle; | |
1121 | ||
1122 | - if (!get_from_pool) | |
1123 | - { | |
1124 | - c = (CommandList_struct *) pci_alloc_consistent( | |
1125 | - h->pdev, sizeof(CommandList_struct), &cmd_dma_handle); | |
1126 | - if(c==NULL) | |
1127 | + if (!get_from_pool) { | |
1128 | + c = (CommandList_struct *) pci_alloc_consistent(h->pdev, | |
1129 | + sizeof(CommandList_struct), &cmd_dma_handle); | |
1130 | + if(c == NULL) | |
1131 | return NULL; | |
1132 | memset(c, 0, sizeof(CommandList_struct)); | |
1133 | ||
1134 | c->cmdindex = -1; | |
1135 | ||
1136 | - c->err_info = (ErrorInfo_struct *)pci_alloc_consistent( | |
1137 | - h->pdev, sizeof(ErrorInfo_struct), | |
1138 | + c->err_info = (ErrorInfo_struct *) | |
1139 | + pci_alloc_consistent(h->pdev, sizeof(ErrorInfo_struct), | |
1140 | &err_dma_handle); | |
1141 | ||
1142 | - if (c->err_info == NULL) | |
1143 | - { | |
1144 | + if (c->err_info == NULL) { | |
1145 | pci_free_consistent(h->pdev, | |
1146 | sizeof(CommandList_struct), c, cmd_dma_handle); | |
1147 | return NULL; | |
1148 | } | |
1149 | memset(c->err_info, 0, sizeof(ErrorInfo_struct)); | |
1150 | - } else /* get it out of the controllers pool */ | |
1151 | - { | |
1152 | - do { | |
1153 | - i = find_first_zero_bit(h->cmd_pool_bits, NR_CMDS); | |
1154 | - if (i == NR_CMDS) | |
1155 | - return NULL; | |
1156 | - } while(test_and_set_bit(i & (BITS_PER_LONG - 1), h->cmd_pool_bits+(i/BITS_PER_LONG)) != 0); | |
1157 | + } else { /* get it out of the controllers pool */ | |
1158 | + do { | |
1159 | + i = find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds); | |
1160 | + if (i == h->nr_cmds) | |
1161 | + return NULL; | |
1162 | + } while(test_and_set_bit | |
1163 | + (i & (BITS_PER_LONG - 1), | |
1164 | + h->cmd_pool_bits + (i / BITS_PER_LONG)) != 0); | |
1165 | #ifdef CCISS_DEBUG | |
1166 | printk(KERN_DEBUG "cciss: using command buffer %d\n", i); | |
1167 | #endif | |
1168 | c = h->cmd_pool + i; | |
1169 | memset(c, 0, sizeof(CommandList_struct)); | |
1170 | - cmd_dma_handle = h->cmd_pool_dhandle | |
1171 | - + i*sizeof(CommandList_struct); | |
1172 | + cmd_dma_handle = h->cmd_pool_dhandle | |
1173 | + + i * sizeof(CommandList_struct); | |
1174 | c->err_info = h->errinfo_pool + i; | |
1175 | memset(c->err_info, 0, sizeof(ErrorInfo_struct)); | |
1176 | err_dma_handle = h->errinfo_pool_dhandle | |
1177 | - + i*sizeof(ErrorInfo_struct); | |
1178 | + + i * sizeof(ErrorInfo_struct); | |
1179 | h->nr_allocs++; | |
1180 | ||
1181 | c->cmdindex = i; | |
1182 | @@ -436,8 +1000,6 @@ | |
1183 | ||
1184 | c->ctlr = h->ctlr; | |
1185 | return c; | |
1186 | - | |
1187 | - | |
1188 | } | |
1189 | ||
1190 | /* | |
1191 | @@ -448,32 +1010,21 @@ | |
1192 | int i; | |
1193 | u64bit temp64; | |
1194 | ||
1195 | - if( !got_from_pool) | |
1196 | - { | |
1197 | + if (!got_from_pool) { | |
1198 | temp64.val32.lower = c->ErrDesc.Addr.lower; | |
1199 | temp64.val32.upper = c->ErrDesc.Addr.upper; | |
1200 | pci_free_consistent(h->pdev, sizeof(ErrorInfo_struct), | |
1201 | c->err_info, (dma_addr_t) temp64.val); | |
1202 | pci_free_consistent(h->pdev, sizeof(CommandList_struct), | |
1203 | c, (dma_addr_t) c->busaddr); | |
1204 | - } else | |
1205 | - { | |
1206 | + } else { | |
1207 | i = c - h->cmd_pool; | |
1208 | - clear_bit(i&(BITS_PER_LONG-1), h->cmd_pool_bits+(i/BITS_PER_LONG)); | |
1209 | + clear_bit(i & (BITS_PER_LONG - 1), | |
1210 | + h->cmd_pool_bits + (i / BITS_PER_LONG)); | |
1211 | h->nr_frees++; | |
1212 | } | |
1213 | } | |
1214 | ||
1215 | -static inline ctlr_info_t *get_host(struct gendisk *disk) | |
1216 | -{ | |
1217 | - return disk->queue->queuedata; | |
1218 | -} | |
1219 | - | |
1220 | -static inline drive_info_struct *get_drv(struct gendisk *disk) | |
1221 | -{ | |
1222 | - return disk->private_data; | |
1223 | -} | |
1224 | - | |
1225 | /* | |
1226 | * Open. Make sure the device is really there. | |
1227 | */ | |
1228 | @@ -496,7 +1047,7 @@ | |
1229 | * but I'm already using way to many device nodes to claim another one | |
1230 | * for "raw controller". | |
1231 | */ | |
1232 | - if (drv->nr_blocks == 0) { | |
1233 | + if (drv->heads == 0) { | |
1234 | if (iminor(inode) != 0) { /* not node 0? */ | |
1235 | /* if not node 0 make sure it is a partition = 0 */ | |
1236 | if (iminor(inode) & 0x0f) { | |
1237 | @@ -513,6 +1064,7 @@ | |
1238 | host->usage_count++; | |
1239 | return 0; | |
1240 | } | |
1241 | + | |
1242 | /* | |
1243 | * Close. Sync first. | |
1244 | */ | |
1245 | @@ -522,7 +1074,8 @@ | |
1246 | drive_info_struct *drv = get_drv(inode->i_bdev->bd_disk); | |
1247 | ||
1248 | #ifdef CCISS_DEBUG | |
1249 | - printk(KERN_DEBUG "cciss_release %s\n", inode->i_bdev->bd_disk->disk_name); | |
1250 | + printk(KERN_DEBUG "cciss_release %s\n", | |
1251 | + inode->i_bdev->bd_disk->disk_name); | |
1252 | #endif /* CCISS_DEBUG */ | |
1253 | ||
1254 | drv->usage_count--; | |
1255 | @@ -541,8 +1094,10 @@ | |
1256 | return ret; | |
1257 | } | |
1258 | ||
1259 | -static int cciss_ioctl32_passthru(struct file *f, unsigned cmd, unsigned long arg); | |
1260 | -static int cciss_ioctl32_big_passthru(struct file *f, unsigned cmd, unsigned long arg); | |
1261 | +static int cciss_ioctl32_passthru(struct file *f, unsigned cmd, | |
1262 | + unsigned long arg); | |
1263 | +static int cciss_ioctl32_big_passthru(struct file *f, unsigned cmd, | |
1264 | + unsigned long arg); | |
1265 | ||
1266 | static long cciss_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg) | |
1267 | { | |
1268 | @@ -574,7 +1129,8 @@ | |
1269 | } | |
1270 | } | |
1271 | ||
1272 | -static int cciss_ioctl32_passthru(struct file *f, unsigned cmd, unsigned long arg) | |
1273 | +static int cciss_ioctl32_passthru(struct file *f, unsigned cmd, | |
1274 | + unsigned long arg) | |
1275 | { | |
1276 | IOCTL32_Command_struct __user *arg32 = | |
1277 | (IOCTL32_Command_struct __user *) arg; | |
1278 | @@ -584,9 +1140,12 @@ | |
1279 | u32 cp; | |
1280 | ||
1281 | err = 0; | |
1282 | - err |= copy_from_user(&arg64.LUN_info, &arg32->LUN_info, sizeof(arg64.LUN_info)); | |
1283 | - err |= copy_from_user(&arg64.Request, &arg32->Request, sizeof(arg64.Request)); | |
1284 | - err |= copy_from_user(&arg64.error_info, &arg32->error_info, sizeof(arg64.error_info)); | |
1285 | + err |= copy_from_user(&arg64.LUN_info, &arg32->LUN_info, | |
1286 | + sizeof(arg64.LUN_info)); | |
1287 | + err |= copy_from_user(&arg64.Request, &arg32->Request, | |
1288 | + sizeof(arg64.Request)); | |
1289 | + err |= copy_from_user(&arg64.error_info, &arg32->error_info, | |
1290 | + sizeof(arg64.error_info)); | |
1291 | err |= get_user(arg64.buf_size, &arg32->buf_size); | |
1292 | err |= get_user(cp, &arg32->buf); | |
1293 | arg64.buf = compat_ptr(cp); | |
1294 | @@ -595,28 +1154,34 @@ | |
1295 | if (err) | |
1296 | return -EFAULT; | |
1297 | ||
1298 | - err = do_ioctl(f, CCISS_PASSTHRU, (unsigned long) p); | |
1299 | + err = do_ioctl(f, CCISS_PASSTHRU, (unsigned long)p); | |
1300 | if (err) | |
1301 | return err; | |
1302 | - err |= copy_in_user(&arg32->error_info, &p->error_info, sizeof(arg32->error_info)); | |
1303 | + err |= copy_in_user(&arg32->error_info, &p->error_info, | |
1304 | + sizeof(arg32->error_info)); | |
1305 | if (err) | |
1306 | return -EFAULT; | |
1307 | return err; | |
1308 | } | |
1309 | ||
1310 | -static int cciss_ioctl32_big_passthru(struct file *file, unsigned cmd, unsigned long arg) | |
1311 | +static int cciss_ioctl32_big_passthru(struct file *file, unsigned cmd, | |
1312 | + unsigned long arg) | |
1313 | { | |
1314 | BIG_IOCTL32_Command_struct __user *arg32 = | |
1315 | (BIG_IOCTL32_Command_struct __user *) arg; | |
1316 | BIG_IOCTL_Command_struct arg64; | |
1317 | - BIG_IOCTL_Command_struct __user *p = compat_alloc_user_space(sizeof(arg64)); | |
1318 | + BIG_IOCTL_Command_struct __user *p = | |
1319 | + compat_alloc_user_space(sizeof(arg64)); | |
1320 | int err; | |
1321 | u32 cp; | |
1322 | ||
1323 | err = 0; | |
1324 | - err |= copy_from_user(&arg64.LUN_info, &arg32->LUN_info, sizeof(arg64.LUN_info)); | |
1325 | - err |= copy_from_user(&arg64.Request, &arg32->Request, sizeof(arg64.Request)); | |
1326 | - err |= copy_from_user(&arg64.error_info, &arg32->error_info, sizeof(arg64.error_info)); | |
1327 | + err |= copy_from_user(&arg64.LUN_info, &arg32->LUN_info, | |
1328 | + sizeof(arg64.LUN_info)); | |
1329 | + err |= copy_from_user(&arg64.Request, &arg32->Request, | |
1330 | + sizeof(arg64.Request)); | |
1331 | + err |= copy_from_user(&arg64.error_info, &arg32->error_info, | |
1332 | + sizeof(arg64.error_info)); | |
1333 | err |= get_user(arg64.buf_size, &arg32->buf_size); | |
1334 | err |= get_user(arg64.malloc_size, &arg32->malloc_size); | |
1335 | err |= get_user(cp, &arg32->buf); | |
1336 | @@ -626,10 +1191,11 @@ | |
1337 | if (err) | |
1338 | return -EFAULT; | |
1339 | ||
1340 | - err = do_ioctl(file, CCISS_BIG_PASSTHRU, (unsigned long) p); | |
1341 | + err = do_ioctl(file, CCISS_BIG_PASSTHRU, (unsigned long)p); | |
1342 | if (err) | |
1343 | return err; | |
1344 | - err |= copy_in_user(&arg32->error_info, &p->error_info, sizeof(arg32->error_info)); | |
1345 | + err |= copy_in_user(&arg32->error_info, &p->error_info, | |
1346 | + sizeof(arg32->error_info)); | |
1347 | if (err) | |
1348 | return -EFAULT; | |
1349 | return err; | |
1350 | @@ -666,29 +1232,33 @@ | |
1351 | printk(KERN_DEBUG "cciss_ioctl: Called with cmd=%x %lx\n", cmd, arg); | |
1352 | #endif /* CCISS_DEBUG */ | |
1353 | ||
1354 | - switch(cmd) { | |
1355 | + switch (cmd) { | |
1356 | case CCISS_GETPCIINFO: | |
1357 | { | |
1358 | cciss_pci_info_struct pciinfo; | |
1359 | ||
1360 | - if (!arg) return -EINVAL; | |
1361 | + if (!arg) | |
1362 | + return -EINVAL; | |
1363 | pciinfo.domain = pci_domain_nr(host->pdev->bus); | |
1364 | pciinfo.bus = host->pdev->bus->number; | |
1365 | pciinfo.dev_fn = host->pdev->devfn; | |
1366 | pciinfo.board_id = host->board_id; | |
1367 | - if (copy_to_user(argp, &pciinfo, sizeof( cciss_pci_info_struct ))) | |
1368 | - return -EFAULT; | |
1369 | - return(0); | |
1370 | + if (copy_to_user(argp, &pciinfo, | |
1371 | + sizeof( cciss_pci_info_struct))) | |
1372 | + return -EFAULT; | |
1373 | + return 0; | |
1374 | } | |
1375 | case CCISS_GETINTINFO: | |
1376 | { | |
1377 | cciss_coalint_struct intinfo; | |
1378 | - if (!arg) return -EINVAL; | |
1379 | + if (!arg) | |
1380 | + return -EINVAL; | |
1381 | intinfo.delay = readl(&host->cfgtable->HostWrite.CoalIntDelay); | |
1382 | intinfo.count = readl(&host->cfgtable->HostWrite.CoalIntCount); | |
1383 | - if (copy_to_user(argp, &intinfo, sizeof( cciss_coalint_struct ))) | |
1384 | + if (copy_to_user(argp, &intinfo, | |
1385 | + sizeof( cciss_coalint_struct))) | |
1386 | return -EFAULT; | |
1387 | - return(0); | |
1388 | + return 0; | |
1389 | } | |
1390 | case CCISS_SETINTINFO: | |
1391 | { | |
1392 | @@ -696,25 +1266,28 @@ | |
1393 | unsigned long flags; | |
1394 | int i; | |
1395 | ||
1396 | - if (!arg) return -EINVAL; | |
1397 | - if (!capable(CAP_SYS_ADMIN)) return -EPERM; | |
1398 | - if (copy_from_user(&intinfo, argp, sizeof( cciss_coalint_struct))) | |
1399 | + if (!arg) | |
1400 | + return -EINVAL; | |
1401 | + if (!capable(CAP_SYS_ADMIN)) | |
1402 | + return -EPERM; | |
1403 | + if (copy_from_user(&intinfo, argp, | |
1404 | + sizeof(cciss_coalint_struct))) | |
1405 | return -EFAULT; | |
1406 | - if ( (intinfo.delay == 0 ) && (intinfo.count == 0)) | |
1407 | + if ((intinfo.delay == 0 ) && (intinfo.count == 0)) | |
1408 | ||
1409 | { | |
1410 | // printk("cciss_ioctl: delay and count cannot be 0\n"); | |
1411 | - return( -EINVAL); | |
1412 | + return -EINVAL; | |
1413 | } | |
1414 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | |
1415 | /* Update the field, and then ring the doorbell */ | |
1416 | - writel( intinfo.delay, | |
1417 | + writel(intinfo.delay, | |
1418 | &(host->cfgtable->HostWrite.CoalIntDelay)); | |
1419 | - writel( intinfo.count, | |
1420 | + writel(intinfo.count, | |
1421 | &(host->cfgtable->HostWrite.CoalIntCount)); | |
1422 | - writel( CFGTBL_ChangeReq, host->vaddr + SA5_DOORBELL); | |
1423 | + writel(CFGTBL_ChangeReq, host->vaddr + SA5_DOORBELL); | |
1424 | ||
1425 | - for(i=0;i<MAX_IOCTL_CONFIG_WAIT;i++) { | |
1426 | + for(i = 0; i < MAX_IOCTL_CONFIG_WAIT; i++) { | |
1427 | if (!(readl(host->vaddr + SA5_DOORBELL) | |
1428 | & CFGTBL_ChangeReq)) | |
1429 | break; | |
1430 | @@ -724,19 +1297,21 @@ | |
1431 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | |
1432 | if (i >= MAX_IOCTL_CONFIG_WAIT) | |
1433 | return -EAGAIN; | |
1434 | - return(0); | |
1435 | + return 0; | |
1436 | } | |
1437 | case CCISS_GETNODENAME: | |
1438 | { | |
1439 | NodeName_type NodeName; | |
1440 | int i; | |
1441 | ||
1442 | - if (!arg) return -EINVAL; | |
1443 | - for(i=0;i<16;i++) | |
1444 | + if (!arg) | |
1445 | + return -EINVAL; | |
1446 | + for(i = 0; i < 16; i++) { | |
1447 | NodeName[i] = readb(&host->cfgtable->ServerName[i]); | |
1448 | - if (copy_to_user(argp, NodeName, sizeof( NodeName_type))) | |
1449 | - return -EFAULT; | |
1450 | - return(0); | |
1451 | + } | |
1452 | + if (copy_to_user(argp, NodeName, sizeof(NodeName_type))) | |
1453 | + return -EFAULT; | |
1454 | + return 0; | |
1455 | } | |
1456 | case CCISS_SETNODENAME: | |
1457 | { | |
1458 | @@ -744,21 +1319,23 @@ | |
1459 | unsigned long flags; | |
1460 | int i; | |
1461 | ||
1462 | - if (!arg) return -EINVAL; | |
1463 | - if (!capable(CAP_SYS_ADMIN)) return -EPERM; | |
1464 | + if (!arg) | |
1465 | + return -EINVAL; | |
1466 | + if (!capable(CAP_SYS_ADMIN)) | |
1467 | + return -EPERM; | |
1468 | ||
1469 | - if (copy_from_user(NodeName, argp, sizeof( NodeName_type))) | |
1470 | + if (copy_from_user(NodeName, argp, sizeof(NodeName_type))) | |
1471 | return -EFAULT; | |
1472 | ||
1473 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | |
1474 | ||
1475 | /* Update the field, and then ring the doorbell */ | |
1476 | - for(i=0;i<16;i++) | |
1477 | - writeb( NodeName[i], &host->cfgtable->ServerName[i]); | |
1478 | + for(i = 0; i < 16; i++) | |
1479 | + writeb(NodeName[i], &host->cfgtable->ServerName[i]); | |
1480 | ||
1481 | - writel( CFGTBL_ChangeReq, host->vaddr + SA5_DOORBELL); | |
1482 | + writel(CFGTBL_ChangeReq, host->vaddr + SA5_DOORBELL); | |
1483 | ||
1484 | - for(i=0;i<MAX_IOCTL_CONFIG_WAIT;i++) { | |
1485 | + for(i = 0; i < MAX_IOCTL_CONFIG_WAIT; i++) { | |
1486 | if (!(readl(host->vaddr + SA5_DOORBELL) | |
1487 | & CFGTBL_ChangeReq)) | |
1488 | break; | |
1489 | @@ -768,70 +1345,70 @@ | |
1490 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | |
1491 | if (i >= MAX_IOCTL_CONFIG_WAIT) | |
1492 | return -EAGAIN; | |
1493 | - return(0); | |
1494 | + return 0; | |
1495 | } | |
1496 | ||
1497 | case CCISS_GETHEARTBEAT: | |
1498 | { | |
1499 | Heartbeat_type heartbeat; | |
1500 | ||
1501 | - if (!arg) return -EINVAL; | |
1502 | + if (!arg) | |
1503 | + return -EINVAL; | |
1504 | heartbeat = readl(&host->cfgtable->HeartBeat); | |
1505 | - if (copy_to_user(argp, &heartbeat, sizeof( Heartbeat_type))) | |
1506 | + if (copy_to_user(argp, &heartbeat, sizeof(Heartbeat_type))) | |
1507 | return -EFAULT; | |
1508 | - return(0); | |
1509 | + return 0; | |
1510 | } | |
1511 | case CCISS_GETBUSTYPES: | |
1512 | { | |
1513 | BusTypes_type BusTypes; | |
1514 | ||
1515 | - if (!arg) return -EINVAL; | |
1516 | + if (!arg) | |
1517 | + return -EINVAL; | |
1518 | BusTypes = readl(&host->cfgtable->BusTypes); | |
1519 | - if (copy_to_user(argp, &BusTypes, sizeof( BusTypes_type) )) | |
1520 | - return -EFAULT; | |
1521 | - return(0); | |
1522 | + if (copy_to_user(argp, &BusTypes, sizeof(BusTypes_type))) | |
1523 | + return -EFAULT; | |
1524 | + return 0; | |
1525 | } | |
1526 | case CCISS_GETFIRMVER: | |
1527 | { | |
1528 | FirmwareVer_type firmware; | |
1529 | ||
1530 | - if (!arg) return -EINVAL; | |
1531 | + if (!arg) | |
1532 | + return -EINVAL; | |
1533 | memcpy(firmware, host->firm_ver, 4); | |
1534 | ||
1535 | - if (copy_to_user(argp, firmware, sizeof( FirmwareVer_type))) | |
1536 | + if (copy_to_user(argp, firmware, sizeof(FirmwareVer_type))) | |
1537 | return -EFAULT; | |
1538 | - return(0); | |
1539 | + return 0; | |
1540 | } | |
1541 | case CCISS_GETDRIVVER: | |
1542 | { | |
1543 | DriverVer_type DriverVer = DRIVER_VERSION; | |
1544 | ||
1545 | - if (!arg) return -EINVAL; | |
1546 | + if (!arg) | |
1547 | + return -EINVAL; | |
1548 | ||
1549 | - if (copy_to_user(argp, &DriverVer, sizeof( DriverVer_type) )) | |
1550 | + if (copy_to_user(argp, &DriverVer, sizeof(DriverVer_type))) | |
1551 | return -EFAULT; | |
1552 | - return(0); | |
1553 | + return 0; | |
1554 | } | |
1555 | ||
1556 | - case CCISS_REVALIDVOLS: | |
1557 | - if (bdev != bdev->bd_contains || drv != host->drv) | |
1558 | - return -ENXIO; | |
1559 | - return revalidate_allvol(host); | |
1560 | - | |
1561 | - case CCISS_GETLUNINFO: { | |
1562 | + case CCISS_GETLUNINFO: | |
1563 | + { | |
1564 | LogvolInfo_struct luninfo; | |
1565 | ||
1566 | luninfo.LunID = drv->LunID; | |
1567 | luninfo.num_opens = drv->usage_count; | |
1568 | - luninfo.num_parts = 0; | |
1569 | + | |
1570 | if (copy_to_user(argp, &luninfo, | |
1571 | sizeof(LogvolInfo_struct))) | |
1572 | return -EFAULT; | |
1573 | - return(0); | |
1574 | + return 0; | |
1575 | } | |
1576 | - case CCISS_DEREGDISK: | |
1577 | - return rebuild_lun_table(host, disk); | |
1578 | ||
1579 | + case CCISS_REVALIDVOLS: | |
1580 | + case CCISS_DEREGDISK: | |
1581 | case CCISS_REGNEWD: | |
1582 | return rebuild_lun_table(host, NULL); | |
1583 | ||
1584 | @@ -842,17 +1419,19 @@ | |
1585 | char *buff = NULL; | |
1586 | u64bit temp64; | |
1587 | unsigned long flags; | |
1588 | - DECLARE_COMPLETION(wait); | |
1589 | + CCISS_DECLARE_COMPLETION(wait); | |
1590 | ||
1591 | - if (!arg) return -EINVAL; | |
1592 | + if (!arg) | |
1593 | + return -EINVAL; | |
1594 | ||
1595 | - if (!capable(CAP_SYS_RAWIO)) return -EPERM; | |
1596 | + if (!capable(CAP_SYS_RAWIO)) | |
1597 | + return -EPERM; | |
1598 | ||
1599 | - if (copy_from_user(&iocommand, argp, sizeof( IOCTL_Command_struct) )) | |
1600 | + if (copy_from_user(&iocommand, argp, | |
1601 | + sizeof(IOCTL_Command_struct))) | |
1602 | return -EFAULT; | |
1603 | - if((iocommand.buf_size < 1) && | |
1604 | - (iocommand.Request.Type.Direction != XFER_NONE)) | |
1605 | - { | |
1606 | + if((iocommand.buf_size < 1) && | |
1607 | + (iocommand.Request.Type.Direction != XFER_NONE)) { | |
1608 | return -EINVAL; | |
1609 | } | |
1610 | #if 0 /* 'buf_size' member is 16-bits, and always smaller than kmalloc limit */ | |
1611 | @@ -860,25 +1439,22 @@ | |
1612 | if(iocommand.buf_size > 128000) | |
1613 | return -EINVAL; | |
1614 | #endif | |
1615 | - if(iocommand.buf_size > 0) | |
1616 | - { | |
1617 | + if (iocommand.buf_size > 0) { | |
1618 | buff = kmalloc(iocommand.buf_size, GFP_KERNEL); | |
1619 | if( buff == NULL) | |
1620 | - return -EFAULT; | |
1621 | + return -ENOMEM; | |
1622 | } | |
1623 | - if (iocommand.Request.Type.Direction == XFER_WRITE) | |
1624 | - { | |
1625 | + if (iocommand.Request.Type.Direction == XFER_WRITE) { | |
1626 | /* Copy the data into the buffer we created */ | |
1627 | - if (copy_from_user(buff, iocommand.buf, iocommand.buf_size)) | |
1628 | - { | |
1629 | + if (copy_from_user(buff, | |
1630 | + iocommand.buf, iocommand.buf_size)) { | |
1631 | kfree(buff); | |
1632 | return -EFAULT; | |
1633 | } | |
1634 | } else { | |
1635 | memset(buff, 0, iocommand.buf_size); | |
1636 | } | |
1637 | - if ((c = cmd_alloc(host , 0)) == NULL) | |
1638 | - { | |
1639 | + if ((c = cmd_alloc(host, 0)) == NULL) { | |
1640 | kfree(buff); | |
1641 | return -ENOMEM; | |
1642 | } | |
1643 | @@ -886,14 +1462,12 @@ | |
1644 | c->cmd_type = CMD_IOCTL_PEND; | |
1645 | // Fill in Command Header | |
1646 | c->Header.ReplyQueue = 0; // unused in simple mode | |
1647 | - if( iocommand.buf_size > 0) // buffer to fill | |
1648 | - { | |
1649 | + if(iocommand.buf_size > 0) { // buffer to fill | |
1650 | c->Header.SGList = 1; | |
1651 | - c->Header.SGTotal= 1; | |
1652 | - } else // no buffers to fill | |
1653 | - { | |
1654 | + c->Header.SGTotal = 1; | |
1655 | + } else { // no buffers to fill | |
1656 | c->Header.SGList = 0; | |
1657 | - c->Header.SGTotal= 0; | |
1658 | + c->Header.SGTotal = 0; | |
1659 | } | |
1660 | c->Header.LUN = iocommand.LUN_info; | |
1661 | c->Header.Tag.lower = c->busaddr; // use the kernel address the cmd block for tag | |
1662 | @@ -902,11 +1476,10 @@ | |
1663 | c->Request = iocommand.Request; | |
1664 | ||
1665 | // Fill in the scatter gather information | |
1666 | - if (iocommand.buf_size > 0 ) | |
1667 | - { | |
1668 | - temp64.val = pci_map_single( host->pdev, buff, | |
1669 | - iocommand.buf_size, | |
1670 | - PCI_DMA_BIDIRECTIONAL); | |
1671 | + if (iocommand.buf_size > 0) { | |
1672 | + temp64.val = pci_map_single(host->pdev, buff, | |
1673 | + iocommand.buf_size, | |
1674 | + PCI_DMA_BIDIRECTIONAL); | |
1675 | c->SG[0].Addr.lower = temp64.val32.lower; | |
1676 | c->SG[0].Addr.upper = temp64.val32.upper; | |
1677 | c->SG[0].Len = iocommand.buf_size; | |
1678 | @@ -926,23 +1499,22 @@ | |
1679 | /* unlock the buffers from DMA */ | |
1680 | temp64.val32.lower = c->SG[0].Addr.lower; | |
1681 | temp64.val32.upper = c->SG[0].Addr.upper; | |
1682 | - pci_unmap_single( host->pdev, (dma_addr_t) temp64.val, | |
1683 | + pci_unmap_single(host->pdev, (dma_addr_t) temp64.val, | |
1684 | iocommand.buf_size, PCI_DMA_BIDIRECTIONAL); | |
1685 | ||
1686 | /* Copy the error information out */ | |
1687 | iocommand.error_info = *(c->err_info); | |
1688 | - if ( copy_to_user(argp, &iocommand, sizeof( IOCTL_Command_struct) ) ) | |
1689 | - { | |
1690 | + if (copy_to_user(argp, &iocommand, | |
1691 | + sizeof(IOCTL_Command_struct))) { | |
1692 | kfree(buff); | |
1693 | cmd_free(host, c, 0); | |
1694 | - return( -EFAULT); | |
1695 | + return -EFAULT; | |
1696 | } | |
1697 | ||
1698 | - if (iocommand.Request.Type.Direction == XFER_READ) | |
1699 | - { | |
1700 | + if (iocommand.Request.Type.Direction == XFER_READ) { | |
1701 | /* Copy the data out of the buffer we created */ | |
1702 | - if (copy_to_user(iocommand.buf, buff, iocommand.buf_size)) | |
1703 | - { | |
1704 | + if (copy_to_user(iocommand.buf, buff, | |
1705 | + iocommand.buf_size)) { | |
1706 | kfree(buff); | |
1707 | cmd_free(host, c, 0); | |
1708 | return -EFAULT; | |
1709 | @@ -950,9 +1522,10 @@ | |
1710 | } | |
1711 | kfree(buff); | |
1712 | cmd_free(host, c, 0); | |
1713 | - return(0); | |
1714 | + return 0; | |
1715 | } | |
1716 | - case CCISS_BIG_PASSTHRU: { | |
1717 | + case CCISS_BIG_PASSTHRU: | |
1718 | + { | |
1719 | BIG_IOCTL_Command_struct *ioc; | |
1720 | CommandList_struct *c; | |
1721 | unsigned char **buff = NULL; | |
1722 | @@ -962,7 +1535,7 @@ | |
1723 | BYTE sg_used = 0; | |
1724 | int status = 0; | |
1725 | int i; | |
1726 | - DECLARE_COMPLETION(wait); | |
1727 | + CCISS_DECLARE_COMPLETION(wait); | |
1728 | __u32 left; | |
1729 | __u32 sz; | |
1730 | BYTE __user *data_ptr; | |
1731 | @@ -995,14 +1568,13 @@ | |
1732 | status = -EINVAL; | |
1733 | goto cleanup1; | |
1734 | } | |
1735 | - buff = (unsigned char **) kmalloc(MAXSGENTRIES * | |
1736 | - sizeof(char *), GFP_KERNEL); | |
1737 | + buff = kzalloc(MAXSGENTRIES * sizeof(char *), GFP_KERNEL); | |
1738 | + | |
1739 | if (!buff) { | |
1740 | status = -ENOMEM; | |
1741 | goto cleanup1; | |
1742 | } | |
1743 | - memset(buff, 0, MAXSGENTRIES); | |
1744 | - buff_size = (int *) kmalloc(MAXSGENTRIES * sizeof(int), | |
1745 | + buff_size = (int *) kmalloc(MAXSGENTRIES * sizeof(int), | |
1746 | GFP_KERNEL); | |
1747 | if (!buff_size) { | |
1748 | status = -ENOMEM; | |
1749 | @@ -1019,8 +1591,8 @@ | |
1750 | goto cleanup1; | |
1751 | } | |
1752 | if (ioc->Request.Type.Direction == XFER_WRITE) { | |
1753 | - if (copy_from_user(buff[sg_used], data_ptr, sz)) { | |
1754 | - status = -ENOMEM; | |
1755 | + if (copy_from_user(buff[sg_used],data_ptr,sz)) { | |
1756 | + status = -EFAULT; | |
1757 | goto cleanup1; | |
1758 | } | |
1759 | } else { | |
1760 | @@ -1030,19 +1602,19 @@ | |
1761 | data_ptr += sz; | |
1762 | sg_used++; | |
1763 | } | |
1764 | - if ((c = cmd_alloc(host , 0)) == NULL) { | |
1765 | + if ((c = cmd_alloc(host, 0)) == NULL) { | |
1766 | status = -ENOMEM; | |
1767 | goto cleanup1; | |
1768 | } | |
1769 | c->cmd_type = CMD_IOCTL_PEND; | |
1770 | c->Header.ReplyQueue = 0; | |
1771 | ||
1772 | - if( ioc->buf_size > 0) { | |
1773 | + if (ioc->buf_size > 0) { | |
1774 | c->Header.SGList = sg_used; | |
1775 | - c->Header.SGTotal= sg_used; | |
1776 | + c->Header.SGTotal = sg_used; | |
1777 | } else { | |
1778 | c->Header.SGList = 0; | |
1779 | - c->Header.SGTotal= 0; | |
1780 | + c->Header.SGTotal = 0; | |
1781 | } | |
1782 | c->Header.LUN = ioc->LUN_info; | |
1783 | c->Header.Tag.lower = c->busaddr; | |
1784 | @@ -1050,8 +1622,9 @@ | |
1785 | c->Request = ioc->Request; | |
1786 | if (ioc->buf_size > 0 ) { | |
1787 | int i; | |
1788 | - for(i=0; i<sg_used; i++) { | |
1789 | - temp64.val = pci_map_single( host->pdev, buff[i], | |
1790 | + for (i = 0; i < sg_used; i++) { | |
1791 | + temp64.val = | |
1792 | + pci_map_single(host->pdev, buff[i], | |
1793 | buff_size[i], | |
1794 | PCI_DMA_BIDIRECTIONAL); | |
1795 | c->SG[i].Addr.lower = temp64.val32.lower; | |
1796 | @@ -1069,10 +1642,10 @@ | |
1797 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | |
1798 | wait_for_completion(&wait); | |
1799 | /* unlock the buffers from DMA */ | |
1800 | - for(i=0; i<sg_used; i++) { | |
1801 | + for (i = 0; i < sg_used; i++) { | |
1802 | temp64.val32.lower = c->SG[i].Addr.lower; | |
1803 | temp64.val32.upper = c->SG[i].Addr.upper; | |
1804 | - pci_unmap_single( host->pdev, (dma_addr_t) temp64.val, | |
1805 | + pci_unmap_single(host->pdev, (dma_addr_t) temp64.val, | |
1806 | buff_size[i], PCI_DMA_BIDIRECTIONAL); | |
1807 | } | |
1808 | /* Copy the error information out */ | |
1809 | @@ -1085,7 +1658,7 @@ | |
1810 | if (ioc->Request.Type.Direction == XFER_READ) { | |
1811 | /* Copy the data out of the buffer we created */ | |
1812 | BYTE __user *ptr = ioc->buf; | |
1813 | - for(i=0; i< sg_used; i++) { | |
1814 | + for(i=0; i < sg_used; i++) { | |
1815 | if (copy_to_user(ptr, buff[i], buff_size[i])) { | |
1816 | cmd_free(host, c, 0); | |
1817 | status = -EFAULT; | |
1818 | @@ -1098,101 +1671,103 @@ | |
1819 | status = 0; | |
1820 | cleanup1: | |
1821 | if (buff) { | |
1822 | - for(i=0; i<sg_used; i++) | |
1823 | + for (i = 0; i < sg_used; i++) | |
1824 | kfree(buff[i]); | |
1825 | + | |
1826 | kfree(buff); | |
1827 | } | |
1828 | kfree(buff_size); | |
1829 | kfree(ioc); | |
1830 | - return(status); | |
1831 | + return status; | |
1832 | } | |
1833 | + | |
1834 | + /* scsi_cmd_ioctl handles these, below, though some are not */ | |
1835 | + /* very meaningful for cciss. SG_IO is the main one people want. */ | |
1836 | + | |
1837 | + case SG_GET_VERSION_NUM: | |
1838 | + case SG_SET_TIMEOUT: | |
1839 | + case SG_GET_TIMEOUT: | |
1840 | + case SG_GET_RESERVED_SIZE: | |
1841 | + case SG_SET_RESERVED_SIZE: | |
1842 | + case SG_EMULATED_HOST: | |
1843 | + case SG_IO: | |
1844 | + case SCSI_IOCTL_SEND_COMMAND: | |
1845 | + return scsi_cmd_ioctl(filep, disk, cmd, argp); | |
1846 | + | |
1847 | + /* scsi_cmd_ioctl would normally handle these, below, but */ | |
1848 | + /* they aren't a good fit for cciss, as CD-ROMs are */ | |
1849 | + /* not supported, and we don't have any bus/target/lun */ | |
1850 | + /* which we present to the kernel. */ | |
1851 | + | |
1852 | + case CDROM_SEND_PACKET: | |
1853 | + case CDROMCLOSETRAY: | |
1854 | + case CDROMEJECT: | |
1855 | + case SCSI_IOCTL_GET_IDLUN: | |
1856 | + case SCSI_IOCTL_GET_BUS_NUMBER: | |
1857 | default: | |
1858 | return -ENOTTY; | |
1859 | } | |
1860 | ||
1861 | } | |
1862 | ||
1863 | -/* | |
1864 | - * revalidate_allvol is for online array config utilities. After a | |
1865 | - * utility reconfigures the drives in the array, it can use this function | |
1866 | - * (through an ioctl) to make the driver zap any previous disk structs for | |
1867 | - * that controller and get new ones. | |
1868 | - * | |
1869 | - * Right now I'm using the getgeometry() function to do this, but this | |
1870 | - * function should probably be finer grained and allow you to revalidate one | |
1871 | - * particualar logical volume (instead of all of them on a particular | |
1872 | - * controller). | |
1873 | - */ | |
1874 | -static int revalidate_allvol(ctlr_info_t *host) | |
1875 | -{ | |
1876 | - int ctlr = host->ctlr, i; | |
1877 | - unsigned long flags; | |
1878 | - | |
1879 | - spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | |
1880 | - if (host->usage_count > 1) { | |
1881 | - spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | |
1882 | - printk(KERN_WARNING "cciss: Device busy for volume" | |
1883 | - " revalidation (usage=%d)\n", host->usage_count); | |
1884 | - return -EBUSY; | |
1885 | - } | |
1886 | - host->usage_count++; | |
1887 | - spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | |
1888 | - | |
1889 | - for(i=0; i< NWD; i++) { | |
1890 | - struct gendisk *disk = host->gendisk[i]; | |
1891 | - if (disk) { | |
1892 | - request_queue_t *q = disk->queue; | |
1893 | - | |
1894 | - if (disk->flags & GENHD_FL_UP) | |
1895 | - del_gendisk(disk); | |
1896 | - if (q) | |
1897 | - blk_cleanup_queue(q); | |
1898 | - } | |
1899 | - } | |
1900 | - | |
1901 | - /* | |
1902 | - * Set the partition and block size structures for all volumes | |
1903 | - * on this controller to zero. We will reread all of this data | |
1904 | - */ | |
1905 | - memset(host->drv, 0, sizeof(drive_info_struct) | |
1906 | - * CISS_MAX_LUN); | |
1907 | - /* | |
1908 | - * Tell the array controller not to give us any interrupts while | |
1909 | - * we check the new geometry. Then turn interrupts back on when | |
1910 | - * we're done. | |
1911 | - */ | |
1912 | - host->access.set_intr_mask(host, CCISS_INTR_OFF); | |
1913 | - cciss_getgeometry(ctlr); | |
1914 | - host->access.set_intr_mask(host, CCISS_INTR_ON); | |
1915 | - | |
1916 | - /* Loop through each real device */ | |
1917 | - for (i = 0; i < NWD; i++) { | |
1918 | - struct gendisk *disk = host->gendisk[i]; | |
1919 | - drive_info_struct *drv = &(host->drv[i]); | |
1920 | - /* we must register the controller even if no disks exist */ | |
1921 | - /* this is for the online array utilities */ | |
1922 | - if (!drv->heads && i) | |
1923 | - continue; | |
1924 | - blk_queue_hardsect_size(drv->queue, drv->block_size); | |
1925 | - set_capacity(disk, drv->nr_blocks); | |
1926 | - add_disk(disk); | |
1927 | - } | |
1928 | - host->usage_count--; | |
1929 | - return 0; | |
1930 | -} | |
1931 | - | |
1932 | static inline void complete_buffers(struct bio *bio, int status) | |
1933 | { | |
1934 | while (bio) { | |
1935 | struct bio *xbh = bio->bi_next; | |
1936 | int nr_sectors = bio_sectors(bio); | |
1937 | - | |
1938 | + | |
1939 | bio->bi_next = NULL; | |
1940 | blk_finished_io(len); | |
1941 | bio_endio(bio, nr_sectors << 9, status ? 0 : -EIO); | |
1942 | bio = xbh; | |
1943 | } | |
1944 | +} | |
1945 | + | |
1946 | +static void cciss_check_queues(ctlr_info_t *h) | |
1947 | +{ | |
1948 | + int start_queue = h->next_to_run; | |
1949 | + int i; | |
1950 | + | |
1951 | + /* check to see if we have maxed out the number of commands that can | |
1952 | + * be placed on the queue. If so then exit. We do this check here | |
1953 | + * in case the interrupt we serviced was from an ioctl and did not | |
1954 | + * free any new commands. | |
1955 | + */ | |
1956 | + if ((find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds)) == h->nr_cmds) | |
1957 | + return; | |
1958 | + | |
1959 | + /* We have room on the queue for more commands. Now we need to queue | |
1960 | + * them up. We will also keep track of the next queue to run so | |
1961 | + * that every queue gets a chance to be started first. | |
1962 | + */ | |
1963 | + for (i = 0; i < h->highest_lun + 1; i++) { | |
1964 | + int curr_queue = (start_queue + i) % (h->highest_lun + 1); | |
1965 | + /* make sure the disk has been added and the drive is real | |
1966 | + * because this can be called from the middle of init_one. | |
1967 | + */ | |
1968 | + if (!(h->drv[curr_queue].queue) || | |
1969 | + !(h->drv[curr_queue].heads) || | |
1970 | + h->drv[curr_queue].busy_configuring) | |
1971 | + continue; | |
1972 | + | |
1973 | + blk_start_queue(h->gendisk[curr_queue]->queue); | |
1974 | ||
1975 | + /* check to see if we have maxed out the number of commands | |
1976 | + * that can be placed on the queue. | |
1977 | + */ | |
1978 | + if ((find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds)) == h->nr_cmds) { | |
1979 | + if (curr_queue == start_queue) { | |
1980 | + h->next_to_run = | |
1981 | + (start_queue + 1) % (h->highest_lun + 1); | |
1982 | + break; | |
1983 | + } else { | |
1984 | + h->next_to_run = curr_queue; | |
1985 | + break; | |
1986 | + } | |
1987 | + } else { | |
1988 | + curr_queue = (curr_queue + 1) % (h->highest_lun + 1); | |
1989 | + } | |
1990 | + } | |
1991 | } | |
1992 | ||
1993 | static void cciss_softirq_done(struct request *rq) | |
1994 | @@ -1210,17 +1785,16 @@ | |
1995 | ||
1996 | /* command did not need to be retried */ | |
1997 | /* unmap the DMA mapping for all the scatter gather elements */ | |
1998 | - for(i=0; i<cmd->Header.SGList; i++) { | |
1999 | + for (i = 0; i < cmd->Header.SGList; i++) { | |
2000 | temp64.val32.lower = cmd->SG[i].Addr.lower; | |
2001 | temp64.val32.upper = cmd->SG[i].Addr.upper; | |
2002 | pci_unmap_page(h->pdev, temp64.val, cmd->SG[i].Len, ddir); | |
2003 | } | |
2004 | ||
2005 | - complete_buffers(rq->bio, rq->errors); | |
2006 | + complete_buffers(rq->bio, (rq->errors == 0)); | |
2007 | ||
2008 | if (blk_fs_request(rq)) { | |
2009 | const int rw = rq_data_dir(rq); | |
2010 | - | |
2011 | disk_stat_add(rq->rq_disk, sectors[rw], rq->nr_sectors); | |
2012 | } | |
2013 | ||
2014 | @@ -1228,9 +1802,11 @@ | |
2015 | printk("Done with %p\n", rq); | |
2016 | #endif /* CCISS_DEBUG */ | |
2017 | ||
2018 | + add_disk_randomness(rq->rq_disk); | |
2019 | spin_lock_irqsave(&h->lock, flags); | |
2020 | - end_that_request_last(rq, rq->errors); | |
2021 | - cmd_free(h, cmd,1); | |
2022 | + end_that_request_last(rq, (rq->errors == 0)); | |
2023 | + cmd_free(h, cmd, 1); | |
2024 | + cciss_check_queues(h); | |
2025 | spin_unlock_irqrestore(&h->lock, flags); | |
2026 | } | |
2027 | ||
2028 | @@ -1241,23 +1817,26 @@ | |
2029 | * will always be left registered with the kernel since it is also the | |
2030 | * controller node. Any changes to disk 0 will show up on the next | |
2031 | * reboot. | |
2032 | -*/ | |
2033 | + */ | |
2034 | static void cciss_update_drive_info(int ctlr, int drv_index) | |
2035 | - { | |
2036 | +{ | |
2037 | ctlr_info_t *h = hba[ctlr]; | |
2038 | struct gendisk *disk; | |
2039 | - ReadCapdata_struct *size_buff = NULL; | |
2040 | InquiryData_struct *inq_buff = NULL; | |
2041 | unsigned int block_size; | |
2042 | - unsigned int total_size; | |
2043 | + sector_t total_size; | |
2044 | unsigned long flags = 0; | |
2045 | int ret = 0; | |
2046 | ||
2047 | - /* if the disk already exists then deregister it before proceeding*/ | |
2048 | - if (h->drv[drv_index].raid_level != -1){ | |
2049 | + /* if the disk already exists then deregister it before proceeding */ | |
2050 | + if (h->drv[drv_index].raid_level != -1) { | |
2051 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | |
2052 | h->drv[drv_index].busy_configuring = 1; | |
2053 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
2054 | + | |
2055 | + /* deregister_disk sets h->drv[drv_index].queue = NULL */ | |
2056 | + /* which keeps the interrupt handler from starting */ | |
2057 | + /* the queue. */ | |
2058 | ret = deregister_disk(h->gendisk[drv_index], | |
2059 | &h->drv[drv_index], 0); | |
2060 | h->drv[drv_index].busy_configuring = 0; | |
2061 | @@ -1268,16 +1847,38 @@ | |
2062 | return; | |
2063 | ||
2064 | ||
2065 | - /* Get information about the disk and modify the driver sturcture */ | |
2066 | - size_buff = kmalloc(sizeof( ReadCapdata_struct), GFP_KERNEL); | |
2067 | - if (size_buff == NULL) | |
2068 | - goto mem_msg; | |
2069 | - inq_buff = kmalloc(sizeof( InquiryData_struct), GFP_KERNEL); | |
2070 | + /* Get information about the disk and modify the driver structure */ | |
2071 | + inq_buff = kmalloc(sizeof(InquiryData_struct), GFP_KERNEL); | |
2072 | if (inq_buff == NULL) | |
2073 | goto mem_msg; | |
2074 | ||
2075 | - cciss_read_capacity(ctlr, drv_index, size_buff, 1, | |
2076 | + /* testing to see if 16-byte CDBs are already | |
2077 | + being used */ | |
2078 | + if (h->cciss_read == CCISS_READ_16) { | |
2079 | + cciss_read_capacity_16(h->ctlr, drv_index, 1, | |
2080 | + &total_size, &block_size); | |
2081 | + goto geo_inq; | |
2082 | + } | |
2083 | + | |
2084 | + cciss_read_capacity(ctlr, drv_index, 1, | |
2085 | &total_size, &block_size); | |
2086 | + | |
2087 | + /* | |
2088 | + * If read_capacity returns all F's the logical volume is >2TB | |
2089 | + * so we switch to 16-byte CDBs for all read/write ops | |
2090 | + */ | |
2091 | + | |
2092 | + if (total_size == 0xFFFFFFFFULL) { | |
2093 | + cciss_read_capacity_16(ctlr, drv_index, 1, | |
2094 | + &total_size, &block_size); | |
2095 | + h->cciss_read = CCISS_READ_16; | |
2096 | + h->cciss_write = CCISS_WRITE_16; | |
2097 | + } else { | |
2098 | + h->cciss_read = CCISS_READ_10; | |
2099 | + h->cciss_write = CCISS_WRITE_10; | |
2100 | + } | |
2101 | + | |
2102 | +geo_inq: | |
2103 | cciss_geometry_inquiry(ctlr, drv_index, 1, total_size, block_size, | |
2104 | inq_buff, &h->drv[drv_index]); | |
2105 | ||
2106 | @@ -1287,11 +1888,16 @@ | |
2107 | ||
2108 | ||
2109 | /* if it's the controller it's already added */ | |
2110 | - if (drv_index){ | |
2111 | + if (drv_index) { | |
2112 | + | |
2113 | disk->queue = blk_init_queue(do_cciss_request, &h->lock); | |
2114 | + sprintf(disk->disk_name, "cciss/c%dd%d", ctlr, drv_index); | |
2115 | + disk->major = h->major; | |
2116 | + disk->first_minor = drv_index << NWD_SHIFT; | |
2117 | + disk->fops = &cciss_fops; | |
2118 | + disk->private_data = &h->drv[drv_index]; | |
2119 | ||
2120 | /* Set up queue information */ | |
2121 | - disk->queue->backing_dev_info.ra_pages = READ_AHEAD; | |
2122 | blk_queue_bounce_limit(disk->queue, hba[ctlr]->pdev->dma_mask); | |
2123 | ||
2124 | /* This is a hardware imposed limit. */ | |
2125 | @@ -1304,17 +1910,30 @@ | |
2126 | ||
2127 | blk_queue_softirq_done(disk->queue, cciss_softirq_done); | |
2128 | ||
2129 | + blk_queue_max_sectors(disk->queue, hba[ctlr]->cciss_sector_size); | |
2130 | + | |
2131 | disk->queue->queuedata = hba[ctlr]; | |
2132 | ||
2133 | + if (!h->drv[drv_index].heads) | |
2134 | + goto freeret; | |
2135 | + | |
2136 | blk_queue_hardsect_size(disk->queue, | |
2137 | hba[ctlr]->drv[drv_index].block_size); | |
2138 | ||
2139 | + | |
2140 | + cciss_sysfs_stat_inquiry(ctlr, drv_index, 1, &h->drv[drv_index]); | |
2141 | + | |
2142 | + cciss_add_blk_sysfs_dev(&h->drv[drv_index], disk, h->pdev, drv_index); | |
2143 | + | |
2144 | + /* Make sure all queue data is written out before */ | |
2145 | + /* setting h->drv[drv_index].queue, as setting this */ | |
2146 | + /* allows the interrupt handler to start the queue */ | |
2147 | + wmb(); | |
2148 | h->drv[drv_index].queue = disk->queue; | |
2149 | add_disk(disk); | |
2150 | } | |
2151 | ||
2152 | freeret: | |
2153 | - kfree(size_buff); | |
2154 | kfree(inq_buff); | |
2155 | return; | |
2156 | mem_msg: | |
2157 | @@ -1327,13 +1946,13 @@ | |
2158 | * where new drives will be added. If the index to be returned is greater | |
2159 | * than the highest_lun index for the controller then highest_lun is set | |
2160 | * to this new index. If there are no available indexes then -1 is returned. | |
2161 | -*/ | |
2162 | + */ | |
2163 | static int cciss_find_free_drive_index(int ctlr) | |
2164 | { | |
2165 | int i; | |
2166 | ||
2167 | - for (i=0; i < CISS_MAX_LUN; i++){ | |
2168 | - if (hba[ctlr]->drv[i].raid_level == -1){ | |
2169 | + for (i = 0; i < CISS_MAX_LUN; i++){ | |
2170 | + if (hba[ctlr]->drv[i].raid_level == -1) { | |
2171 | if (i > hba[ctlr]->highest_lun) | |
2172 | hba[ctlr]->highest_lun = i; | |
2173 | return i; | |
2174 | @@ -1343,7 +1962,7 @@ | |
2175 | } | |
2176 | ||
2177 | /* This function will add and remove logical drives from the Logical | |
2178 | - * drive array of the controller and maintain persistancy of ordering | |
2179 | + * drive array of the controller and maintain persistency of ordering | |
2180 | * so that mount points are preserved until the next reboot. This allows | |
2181 | * for the removal of logical drives in the middle of the drive array | |
2182 | * without a re-ordering of those drives. | |
2183 | @@ -1351,7 +1970,7 @@ | |
2184 | * h = The controller to perform the operations on | |
2185 | * del_disk = The disk to remove if specified. If the value given | |
2186 | * is NULL then no disk is removed. | |
2187 | -*/ | |
2188 | + */ | |
2189 | static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk) | |
2190 | { | |
2191 | int ctlr = h->ctlr; | |
2192 | @@ -1368,12 +1987,7 @@ | |
2193 | ||
2194 | /* Set busy_configuring flag for this operation */ | |
2195 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | |
2196 | - if (h->num_luns >= CISS_MAX_LUN){ | |
2197 | - spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
2198 | - return -EINVAL; | |
2199 | - } | |
2200 | - | |
2201 | - if (h->busy_configuring){ | |
2202 | + if (h->busy_configuring) { | |
2203 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
2204 | return -EBUSY; | |
2205 | } | |
2206 | @@ -1383,7 +1997,7 @@ | |
2207 | * and update the logical drive table. If it is not NULL then | |
2208 | * we will check if the disk is in use or not. | |
2209 | */ | |
2210 | - if (del_disk != NULL){ | |
2211 | + if (del_disk != NULL) { | |
2212 | drv = get_drv(del_disk); | |
2213 | drv->busy_configuring = 1; | |
2214 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
2215 | @@ -1405,11 +2019,9 @@ | |
2216 | TYPE_CMD); | |
2217 | ||
2218 | if (return_code == IO_OK){ | |
2219 | - listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[0])) << 24; | |
2220 | - listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[1])) << 16; | |
2221 | - listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[2])) << 8; | |
2222 | - listlength |= 0xff & (unsigned int)(ld_buff->LUNListLength[3]); | |
2223 | - } else{ /* reading number of logical volumes failed */ | |
2224 | + listlength = | |
2225 | + be32_to_cpu(*(__u32 *) ld_buff->LUNListLength); | |
2226 | + } else { /* reading number of logical volumes failed */ | |
2227 | printk(KERN_WARNING "cciss: report logical volume" | |
2228 | " command failed\n"); | |
2229 | listlength = 0; | |
2230 | @@ -1417,7 +2029,7 @@ | |
2231 | } | |
2232 | ||
2233 | num_luns = listlength / 8; /* 8 bytes per entry */ | |
2234 | - if (num_luns > CISS_MAX_LUN){ | |
2235 | + if (num_luns > CISS_MAX_LUN) { | |
2236 | num_luns = CISS_MAX_LUN; | |
2237 | printk(KERN_WARNING "cciss: more luns configured" | |
2238 | " on controller than can be handled by" | |
2239 | @@ -1428,7 +2040,7 @@ | |
2240 | * Check for updates in the drive information and any new drives | |
2241 | * on the controller. | |
2242 | */ | |
2243 | - for (i=0; i < num_luns; i++){ | |
2244 | + for (i = 0; i < num_luns; i++) { | |
2245 | int j; | |
2246 | ||
2247 | drv_found = 0; | |
2248 | @@ -1447,19 +2059,26 @@ | |
2249 | * if not is use. If it does not exist then find | |
2250 | * the first free index and add it. | |
2251 | */ | |
2252 | - for (j=0; j <= h->highest_lun; j++){ | |
2253 | - if (h->drv[j].LunID == lunid){ | |
2254 | + for (j = 0; j <= h->highest_lun; j++) { | |
2255 | + if (h->drv[j].LunID == lunid) { | |
2256 | drv_index = j; | |
2257 | drv_found = 1; | |
2258 | } | |
2259 | } | |
2260 | ||
2261 | /* check if the drive was found already in the array */ | |
2262 | - if (!drv_found){ | |
2263 | + if (!drv_found) { | |
2264 | drv_index = cciss_find_free_drive_index(ctlr); | |
2265 | if (drv_index == -1) | |
2266 | goto freeret; | |
2267 | - | |
2268 | + /*Check if the gendisk needs to be allocated */ | |
2269 | + if (!h->gendisk[drv_index]) { | |
2270 | + h->gendisk[drv_index] = alloc_disk(1 << NWD_SHIFT); | |
2271 | + if (!h->gendisk[drv_index]) { | |
2272 | + printk(KERN_ERR "cciss: could not allocate new disk %d\n", drv_index); | |
2273 | + goto mem_msg; | |
2274 | + } | |
2275 | + } | |
2276 | } | |
2277 | h->drv[drv_index].LunID = lunid; | |
2278 | cciss_update_drive_info(ctlr, drv_index); | |
2279 | @@ -1490,41 +2109,68 @@ | |
2280 | * clear_all = This flag determines whether or not the disk information | |
2281 | * is going to be completely cleared out and the highest_lun | |
2282 | * reset. Sometimes we want to clear out information about | |
2283 | - * the disk in preperation for re-adding it. In this case | |
2284 | + * the disk in preparation for re-adding it. In this case | |
2285 | * the highest_lun should be left unchanged and the LunID | |
2286 | * should not be cleared. | |
2287 | */ | |
2288 | static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, | |
2289 | int clear_all) | |
2290 | { | |
2291 | + int i; | |
2292 | ctlr_info_t *h = get_host(disk); | |
2293 | ||
2294 | if (!capable(CAP_SYS_RAWIO)) | |
2295 | return -EPERM; | |
2296 | ||
2297 | /* make sure logical volume is NOT is use */ | |
2298 | - if(clear_all || (h->gendisk[0] == disk)) { | |
2299 | + if (clear_all || (h->gendisk[0] == disk)) { | |
2300 | if (drv->usage_count > 1) | |
2301 | return -EBUSY; | |
2302 | - } | |
2303 | - else | |
2304 | - if( drv->usage_count > 0 ) | |
2305 | + } else if (drv->usage_count > 0) | |
2306 | return -EBUSY; | |
2307 | ||
2308 | /* invalidate the devices and deregister the disk. If it is disk | |
2309 | * zero do not deregister it but just zero out it's values. This | |
2310 | * allows us to delete disk zero but keep the controller registered. | |
2311 | */ | |
2312 | - if (h->gendisk[0] != disk){ | |
2313 | + if (h->gendisk[0] != disk) { | |
2314 | if (disk) { | |
2315 | request_queue_t *q = disk->queue; | |
2316 | - if (disk->flags & GENHD_FL_UP) | |
2317 | + if (disk->flags & GENHD_FL_UP) { | |
2318 | + cciss_remove_blk_sysfs_dev(disk); | |
2319 | del_gendisk(disk); | |
2320 | + } | |
2321 | if (q) { | |
2322 | blk_cleanup_queue(q); | |
2323 | + /* Set drv->queue to NULL so that we do not try | |
2324 | + * to call blk_start_queue on this queue in the | |
2325 | + * interrupt handler | |
2326 | + */ | |
2327 | drv->queue = NULL; | |
2328 | } | |
2329 | + /* If clear_all is set then we are deleting the logical | |
2330 | + * drive, not just refreshing its info. For drives | |
2331 | + * other than disk 0 we will call put_disk. We do not | |
2332 | + * do this for disk 0 as we need it to be able to | |
2333 | + * configure the controller. | |
2334 | + */ | |
2335 | + if (clear_all) { | |
2336 | + /* This isn't pretty, but we need to find the | |
2337 | + * disk in our array and NULL our the pointer. | |
2338 | + * This is so that we will call alloc_disk if | |
2339 | + * this index is used again later. | |
2340 | + */ | |
2341 | + for (i = 0; i < CISS_MAX_LUN; i++) { | |
2342 | + if (h->gendisk[i] == disk) { | |
2343 | + h->gendisk[i] = NULL; | |
2344 | + break; | |
2345 | + } | |
2346 | + } | |
2347 | + put_disk(disk); | |
2348 | + } | |
2349 | } | |
2350 | + } else { | |
2351 | + set_capacity(disk, 0); | |
2352 | } | |
2353 | ||
2354 | --h->num_luns; | |
2355 | @@ -1539,22 +2185,22 @@ | |
2356 | * array is free. | |
2357 | */ | |
2358 | ||
2359 | - if (clear_all){ | |
2360 | - /* check to see if it was the last disk */ | |
2361 | - if (drv == h->drv + h->highest_lun) { | |
2362 | - /* if so, find the new hightest lun */ | |
2363 | - int i, newhighest =-1; | |
2364 | - for(i=0; i<h->highest_lun; i++) { | |
2365 | - /* if the disk has size > 0, it is available */ | |
2366 | - if (h->drv[i].heads) | |
2367 | - newhighest = i; | |
2368 | + if (clear_all) { | |
2369 | + /* check to see if it was the last disk */ | |
2370 | + if (drv == h->drv + h->highest_lun) { | |
2371 | + /* if so, find the new hightest lun */ | |
2372 | + int i, newhighest = -1; | |
2373 | + for (i = 0; i < h->highest_lun; i++) { | |
2374 | + /* if the disk has size > 0, it is available */ | |
2375 | + if (h->drv[i].heads) | |
2376 | + newhighest = i; | |
2377 | + } | |
2378 | + h->highest_lun = newhighest; | |
2379 | } | |
2380 | - h->highest_lun = newhighest; | |
2381 | - } | |
2382 | ||
2383 | - drv->LunID = 0; | |
2384 | + drv->LunID = 0; | |
2385 | } | |
2386 | - return(0); | |
2387 | + return 0; | |
2388 | } | |
2389 | ||
2390 | static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, | |
2391 | @@ -1565,24 +2211,24 @@ | |
2392 | unsigned int log_unit, __u8 page_code, unsigned char *scsi3addr, | |
2393 | int cmd_type) | |
2394 | { | |
2395 | - ctlr_info_t *h= hba[ctlr]; | |
2396 | + ctlr_info_t *h = hba[ctlr]; | |
2397 | u64bit buff_dma_handle; | |
2398 | int status = IO_OK; | |
2399 | ||
2400 | c->cmd_type = CMD_IOCTL_PEND; | |
2401 | c->Header.ReplyQueue = 0; | |
2402 | - if( buff != NULL) { | |
2403 | + if (buff != NULL) { | |
2404 | c->Header.SGList = 1; | |
2405 | - c->Header.SGTotal= 1; | |
2406 | + c->Header.SGTotal = 1; | |
2407 | } else { | |
2408 | c->Header.SGList = 0; | |
2409 | - c->Header.SGTotal= 0; | |
2410 | + c->Header.SGTotal = 0; | |
2411 | } | |
2412 | c->Header.Tag.lower = c->busaddr; | |
2413 | ||
2414 | c->Request.Type.Type = cmd_type; | |
2415 | if (cmd_type == TYPE_CMD) { | |
2416 | - switch(cmd) { | |
2417 | + switch (cmd) { | |
2418 | case CISS_INQUIRY: | |
2419 | /* If the logical unit number is 0 then, this is going | |
2420 | to controller so It's a physical command | |
2421 | @@ -1592,15 +2238,16 @@ | |
2422 | otherwise, if use_unit_num == 2, | |
2423 | mode = 0(periph dev addr) target = scsi3addr */ | |
2424 | if (use_unit_num == 1) { | |
2425 | - c->Header.LUN.LogDev.VolId= | |
2426 | + c->Header.LUN.LogDev.VolId = | |
2427 | h->drv[log_unit].LunID; | |
2428 | c->Header.LUN.LogDev.Mode = 1; | |
2429 | } else if (use_unit_num == 2) { | |
2430 | - memcpy(c->Header.LUN.LunAddrBytes,scsi3addr,8); | |
2431 | + memcpy(c->Header.LUN.LunAddrBytes, scsi3addr, | |
2432 | + 8); | |
2433 | c->Header.LUN.LogDev.Mode = 0; | |
2434 | } | |
2435 | /* are we trying to read a vital product page */ | |
2436 | - if(page_code != 0) { | |
2437 | + if (page_code != 0) { | |
2438 | c->Request.CDB[1] = 0x01; | |
2439 | c->Request.CDB[2] = page_code; | |
2440 | } | |
2441 | @@ -1636,6 +2283,20 @@ | |
2442 | c->Request.Timeout = 0; | |
2443 | c->Request.CDB[0] = cmd; | |
2444 | break; | |
2445 | + case CCISS_READ_CAPACITY_16: | |
2446 | + c->Header.LUN.LogDev.VolId = h->drv[log_unit].LunID; | |
2447 | + c->Header.LUN.LogDev.Mode = 1; | |
2448 | + c->Request.CDBLen = 16; | |
2449 | + c->Request.Type.Attribute = ATTR_SIMPLE; | |
2450 | + c->Request.Type.Direction = XFER_READ; | |
2451 | + c->Request.Timeout = 0; | |
2452 | + c->Request.CDB[0] = cmd; | |
2453 | + c->Request.CDB[1] = 0x10; | |
2454 | + c->Request.CDB[10] = (size >> 24) & 0xFF; | |
2455 | + c->Request.CDB[11] = (size >> 16) & 0xFF; | |
2456 | + c->Request.CDB[12] = (size >> 8) & 0xFF; | |
2457 | + c->Request.CDB[13] = size & 0xFF; | |
2458 | + break; | |
2459 | case CCISS_CACHE_FLUSH: | |
2460 | c->Request.CDBLen = 12; | |
2461 | c->Request.Type.Attribute = ATTR_SIMPLE; | |
2462 | @@ -1647,7 +2308,7 @@ | |
2463 | default: | |
2464 | printk(KERN_WARNING | |
2465 | "cciss%d: Unknown Command 0x%c\n", ctlr, cmd); | |
2466 | - return(IO_ERROR); | |
2467 | + return IO_ERROR; | |
2468 | } | |
2469 | } else if (cmd_type == TYPE_MSG) { | |
2470 | switch (cmd) { | |
2471 | @@ -1669,6 +2330,7 @@ | |
2472 | memset(&c->Request.CDB[0], 0, sizeof(c->Request.CDB)); | |
2473 | c->Request.CDB[0] = cmd; /* reset */ | |
2474 | c->Request.CDB[1] = 0x04; /* reset a LUN */ | |
2475 | + break; | |
2476 | case 3: /* No-Op message */ | |
2477 | c->Request.CDBLen = 1; | |
2478 | c->Request.Type.Attribute = ATTR_SIMPLE; | |
2479 | @@ -1698,6 +2360,7 @@ | |
2480 | } | |
2481 | return status; | |
2482 | } | |
2483 | + | |
2484 | static int sendcmd_withirq(__u8 cmd, | |
2485 | int ctlr, | |
2486 | void *buff, | |
2487 | @@ -1712,9 +2375,10 @@ | |
2488 | u64bit buff_dma_handle; | |
2489 | unsigned long flags; | |
2490 | int return_status; | |
2491 | - DECLARE_COMPLETION(wait); | |
2492 | + int print_this_error = 1; /* by default print this error */ | |
2493 | + CCISS_DECLARE_COMPLETION(wait); | |
2494 | ||
2495 | - if ((c = cmd_alloc(h , 0)) == NULL) | |
2496 | + if ((c = cmd_alloc(h, 0)) == NULL) | |
2497 | return -ENOMEM; | |
2498 | return_status = fill_cmd(c, cmd, ctlr, buff, size, use_unit_num, | |
2499 | log_unit, page_code, NULL, cmd_type); | |
2500 | @@ -1734,22 +2398,56 @@ | |
2501 | ||
2502 | wait_for_completion(&wait); | |
2503 | ||
2504 | - if(c->err_info->CommandStatus != 0) | |
2505 | - { /* an error has occurred */ | |
2506 | - switch(c->err_info->CommandStatus) | |
2507 | - { | |
2508 | + if(c->err_info->CommandStatus != 0) { /* an error has occurred */ | |
2509 | + switch(c->err_info->CommandStatus) { | |
2510 | + unsigned char sense_key; | |
2511 | case CMD_TARGET_STATUS: | |
2512 | - printk(KERN_WARNING "cciss: cmd %p has " | |
2513 | - " completed with errors\n", c); | |
2514 | - if( c->err_info->ScsiStatus) | |
2515 | - { | |
2516 | - printk(KERN_WARNING "cciss: cmd %p " | |
2517 | - "has SCSI Status = %x\n", | |
2518 | - c, | |
2519 | - c->err_info->ScsiStatus); | |
2520 | - } | |
2521 | + return_status = IO_ERROR; | |
2522 | + switch( c->err_info->ScsiStatus) { | |
2523 | + case 0x02: /* Check Condition */ | |
2524 | + /* Check if condition is Unit | |
2525 | + * Attention | |
2526 | + */ | |
2527 | + if((c->err_info->SenseInfo[2] == 6) && | |
2528 | + (c->retry_count < MAX_CMD_RETRIES)) | |
2529 | + { | |
2530 | + printk(KERN_WARNING | |
2531 | + "cciss%d: retrying unit " | |
2532 | + "attention\n", ctlr); | |
2533 | + c->retry_count++; | |
2534 | + /* erase old err info */ | |
2535 | + memset(c->err_info, 0, | |
2536 | + sizeof(ErrorInfo_struct)); | |
2537 | + return_status = IO_OK; | |
2538 | + INIT_COMPLETION(wait); | |
2539 | + goto resend_cmd2; | |
2540 | + } else { | |
2541 | + printk(KERN_WARNING "cciss%d: " | |
2542 | + "has CHECK CONDITION " | |
2543 | + "byte 2 = 0x%x\n", ctlr, | |
2544 | + c->err_info->SenseInfo[2]); | |
2545 | + } | |
2546 | + /* check the sense key */ | |
2547 | + sense_key = 0xf & | |
2548 | + c->err_info->SenseInfo[2]; | |
2549 | + | |
2550 | + /* no status or recovered error */ | |
2551 | ||
2552 | + if((sense_key == 0x0) || | |
2553 | + (sense_key == 0x1) ) | |
2554 | + return_status=IO_OK; | |
2555 | + break; | |
2556 | + case 0x18: /* Reserve Conflict */ | |
2557 | + return_status=IO_ERROR; | |
2558 | + print_this_error=0; | |
2559 | + break; | |
2560 | + default: | |
2561 | + printk(KERN_WARNING "cciss%d:" | |
2562 | + " cmd has SCSI Status" | |
2563 | + " = %x\n", ctlr, | |
2564 | + c->err_info->ScsiStatus); | |
2565 | break; | |
2566 | + } | |
2567 | case CMD_DATA_UNDERRUN: | |
2568 | case CMD_DATA_OVERRUN: | |
2569 | /* expected for inquire and report lun commands */ | |
2570 | @@ -1764,7 +2462,7 @@ | |
2571 | "protocol error \n", c); | |
2572 | return_status = IO_ERROR; | |
2573 | break; | |
2574 | -case CMD_HARDWARE_ERR: | |
2575 | + case CMD_HARDWARE_ERR: | |
2576 | printk(KERN_WARNING "cciss: cmd %p had " | |
2577 | " hardware error\n", c); | |
2578 | return_status = IO_ERROR; | |
2579 | @@ -1807,23 +2505,31 @@ | |
2580 | "unknown status %x\n", c, | |
2581 | c->err_info->CommandStatus); | |
2582 | return_status = IO_ERROR; | |
2583 | + | |
2584 | + | |
2585 | } | |
2586 | } | |
2587 | + if ((return_status == IO_ERROR) && (print_this_error)) { | |
2588 | + print_cmd(c); | |
2589 | + } | |
2590 | + | |
2591 | /* unlock the buffers from DMA */ | |
2592 | buff_dma_handle.val32.lower = c->SG[0].Addr.lower; | |
2593 | buff_dma_handle.val32.upper = c->SG[0].Addr.upper; | |
2594 | - pci_unmap_single( h->pdev, (dma_addr_t) buff_dma_handle.val, | |
2595 | + pci_unmap_single(h->pdev, (dma_addr_t) buff_dma_handle.val, | |
2596 | c->SG[0].Len, PCI_DMA_BIDIRECTIONAL); | |
2597 | cmd_free(h, c, 0); | |
2598 | - return(return_status); | |
2599 | + return return_status; | |
2600 | ||
2601 | } | |
2602 | static void cciss_geometry_inquiry(int ctlr, int logvol, | |
2603 | - int withirq, unsigned int total_size, | |
2604 | + int withirq, sector_t total_size, | |
2605 | unsigned int block_size, InquiryData_struct *inq_buff, | |
2606 | drive_info_struct *drv) | |
2607 | { | |
2608 | int return_code; | |
2609 | + unsigned int t; | |
2610 | + | |
2611 | memset(inq_buff, 0, sizeof(InquiryData_struct)); | |
2612 | if (withirq) | |
2613 | return_code = sendcmd_withirq(CISS_INQUIRY, ctlr, | |
2614 | @@ -1832,58 +2538,98 @@ | |
2615 | return_code = sendcmd(CISS_INQUIRY, ctlr, inq_buff, | |
2616 | sizeof(*inq_buff), 1, logvol ,0xC1, NULL, TYPE_CMD); | |
2617 | if (return_code == IO_OK) { | |
2618 | - if(inq_buff->data_byte[8] == 0xFF) { | |
2619 | + if (inq_buff->data_byte[8] == 0xFF) { | |
2620 | printk(KERN_WARNING | |
2621 | "cciss: reading geometry failed, volume " | |
2622 | "does not support reading geometry\n"); | |
2623 | - drv->block_size = block_size; | |
2624 | - drv->nr_blocks = total_size; | |
2625 | drv->heads = 255; | |
2626 | drv->sectors = 32; // Sectors per track | |
2627 | - drv->cylinders = total_size / 255 / 32; | |
2628 | + drv->raid_level = RAID_UNKNOWN; | |
2629 | } else { | |
2630 | - unsigned int t; | |
2631 | - | |
2632 | - drv->block_size = block_size; | |
2633 | - drv->nr_blocks = total_size; | |
2634 | drv->heads = inq_buff->data_byte[6]; | |
2635 | drv->sectors = inq_buff->data_byte[7]; | |
2636 | drv->cylinders = (inq_buff->data_byte[4] & 0xff) << 8; | |
2637 | drv->cylinders += inq_buff->data_byte[5]; | |
2638 | drv->raid_level = inq_buff->data_byte[8]; | |
2639 | - t = drv->heads * drv->sectors; | |
2640 | - if (t > 1) { | |
2641 | - drv->cylinders = total_size/t; | |
2642 | - } | |
2643 | + } | |
2644 | + drv->block_size = block_size; | |
2645 | + drv->nr_blocks = total_size + 1; | |
2646 | + t = drv->heads * drv->sectors; | |
2647 | + if (t > 1) { | |
2648 | + sector_t real_size = total_size+1; | |
2649 | + unsigned long rem = sector_div(real_size, t); | |
2650 | + if (rem) | |
2651 | + real_size++; | |
2652 | + drv->cylinders = real_size; | |
2653 | } | |
2654 | } else { /* Get geometry failed */ | |
2655 | printk(KERN_WARNING "cciss: reading geometry failed\n"); | |
2656 | } | |
2657 | - printk(KERN_INFO " heads= %d, sectors= %d, cylinders= %d\n\n", | |
2658 | - drv->heads, drv->sectors, drv->cylinders); | |
2659 | } | |
2660 | + | |
2661 | static void | |
2662 | -cciss_read_capacity(int ctlr, int logvol, ReadCapdata_struct *buf, | |
2663 | - int withirq, unsigned int *total_size, unsigned int *block_size) | |
2664 | +cciss_read_capacity(int ctlr, int logvol, int withirq, sector_t *total_size, | |
2665 | + unsigned int *block_size) | |
2666 | { | |
2667 | + ReadCapdata_struct *buf; | |
2668 | int return_code; | |
2669 | - memset(buf, 0, sizeof(*buf)); | |
2670 | + buf = kmalloc(sizeof(ReadCapdata_struct), GFP_KERNEL); | |
2671 | + if (buf == NULL) { | |
2672 | + printk(KERN_WARNING "cciss: out of memory\n"); | |
2673 | + return; | |
2674 | + } | |
2675 | + memset(buf, 0, sizeof(ReadCapdata_struct)); | |
2676 | + | |
2677 | if (withirq) | |
2678 | return_code = sendcmd_withirq(CCISS_READ_CAPACITY, | |
2679 | - ctlr, buf, sizeof(*buf), 1, logvol, 0, TYPE_CMD); | |
2680 | + ctlr, buf, sizeof(ReadCapdata_struct), | |
2681 | + 1, logvol, 0, TYPE_CMD); | |
2682 | else | |
2683 | return_code = sendcmd(CCISS_READ_CAPACITY, | |
2684 | - ctlr, buf, sizeof(*buf), 1, logvol, 0, NULL, TYPE_CMD); | |
2685 | + ctlr, buf, sizeof(ReadCapdata_struct), | |
2686 | + 1, logvol, 0, NULL, TYPE_CMD); | |
2687 | + if (return_code == IO_OK) { | |
2688 | + *total_size = be32_to_cpu(*(__u32 *) buf->total_size); | |
2689 | + *block_size = be32_to_cpu(*(__u32 *) buf->block_size); | |
2690 | + } else { /* read capacity command failed */ | |
2691 | + printk(KERN_WARNING "cciss: read capacity failed\n"); | |
2692 | + *total_size = 0; | |
2693 | + *block_size = BLOCK_SIZE; | |
2694 | + } | |
2695 | + kfree(buf); | |
2696 | + return; | |
2697 | +} | |
2698 | + | |
2699 | +static void | |
2700 | +cciss_read_capacity_16(int ctlr, int logvol, int withirq, sector_t *total_size, unsigned int *block_size) | |
2701 | +{ | |
2702 | + ReadCapdata_struct_16 *buf; | |
2703 | + int return_code; | |
2704 | + buf = kmalloc(sizeof(ReadCapdata_struct_16), GFP_KERNEL); | |
2705 | + if (buf == NULL) { | |
2706 | + printk(KERN_WARNING "cciss: out of memory\n"); | |
2707 | + return; | |
2708 | + } | |
2709 | + memset(buf, 0, sizeof(ReadCapdata_struct_16)); | |
2710 | + if (withirq) { | |
2711 | + return_code = sendcmd_withirq(CCISS_READ_CAPACITY_16, | |
2712 | + ctlr, buf, sizeof(ReadCapdata_struct_16), | |
2713 | + 1, logvol, 0, TYPE_CMD); | |
2714 | + } | |
2715 | + else { | |
2716 | + return_code = sendcmd(CCISS_READ_CAPACITY_16, | |
2717 | + ctlr, buf, sizeof(ReadCapdata_struct_16), | |
2718 | + 1, logvol, 0, NULL, TYPE_CMD); | |
2719 | + } | |
2720 | if (return_code == IO_OK) { | |
2721 | - *total_size = be32_to_cpu(*((__be32 *) &buf->total_size[0]))+1; | |
2722 | - *block_size = be32_to_cpu(*((__be32 *) &buf->block_size[0])); | |
2723 | + *total_size = be64_to_cpu(*(__u64 *) buf->total_size); | |
2724 | + *block_size = be32_to_cpu(*(__u32 *) buf->block_size); | |
2725 | } else { /* read capacity command failed */ | |
2726 | printk(KERN_WARNING "cciss: read capacity failed\n"); | |
2727 | *total_size = 0; | |
2728 | *block_size = BLOCK_SIZE; | |
2729 | } | |
2730 | - printk(KERN_INFO " blocks= %u block_size= %d\n", | |
2731 | - *total_size, *block_size); | |
2732 | + kfree(buf); | |
2733 | return; | |
2734 | } | |
2735 | ||
2736 | @@ -1894,8 +2640,7 @@ | |
2737 | int logvol; | |
2738 | int FOUND=0; | |
2739 | unsigned int block_size; | |
2740 | - unsigned int total_size; | |
2741 | - ReadCapdata_struct *size_buff = NULL; | |
2742 | + sector_t total_size; | |
2743 | InquiryData_struct *inq_buff = NULL; | |
2744 | ||
2745 | for(logvol=0; logvol < CISS_MAX_LUN; logvol++) | |
2746 | @@ -1908,27 +2653,24 @@ | |
2747 | ||
2748 | if (!FOUND) return 1; | |
2749 | ||
2750 | - size_buff = kmalloc(sizeof( ReadCapdata_struct), GFP_KERNEL); | |
2751 | - if (size_buff == NULL) | |
2752 | - { | |
2753 | - printk(KERN_WARNING "cciss: out of memory\n"); | |
2754 | - return 1; | |
2755 | - } | |
2756 | inq_buff = kmalloc(sizeof( InquiryData_struct), GFP_KERNEL); | |
2757 | - if (inq_buff == NULL) | |
2758 | - { | |
2759 | + if (inq_buff == NULL) { | |
2760 | printk(KERN_WARNING "cciss: out of memory\n"); | |
2761 | - kfree(size_buff); | |
2762 | return 1; | |
2763 | } | |
2764 | - | |
2765 | - cciss_read_capacity(h->ctlr, logvol, size_buff, 1, &total_size, &block_size); | |
2766 | - cciss_geometry_inquiry(h->ctlr, logvol, 1, total_size, block_size, inq_buff, drv); | |
2767 | + if (h->cciss_read == CCISS_READ_10) { | |
2768 | + cciss_read_capacity(h->ctlr, logvol, 1, | |
2769 | + &total_size, &block_size); | |
2770 | + } else { | |
2771 | + cciss_read_capacity_16(h->ctlr, logvol, 1, | |
2772 | + &total_size, &block_size); | |
2773 | + } | |
2774 | + cciss_geometry_inquiry(h->ctlr, logvol, 1, total_size, block_size, | |
2775 | + inq_buff, drv); | |
2776 | ||
2777 | blk_queue_hardsect_size(drv->queue, drv->block_size); | |
2778 | set_capacity(disk, drv->nr_blocks); | |
2779 | ||
2780 | - kfree(size_buff); | |
2781 | kfree(inq_buff); | |
2782 | return 0; | |
2783 | } | |
2784 | @@ -1943,14 +2685,17 @@ | |
2785 | unsigned long done; | |
2786 | int i; | |
2787 | ||
2788 | - /* Wait (up to 20 seconds) for a command to complete */ | |
2789 | + /* Increase timeout from 20 to 60 seconds to support a | |
2790 | + * large number of logical volumes. Otherwise we may | |
2791 | + * timeout during init. | |
2792 | + */ | |
2793 | ||
2794 | - for (i = 20 * HZ; i > 0; i--) { | |
2795 | + for (i = 60 * HZ; i > 0; i--) { | |
2796 | done = hba[ctlr]->access.command_completed(hba[ctlr]); | |
2797 | if (done == FIFO_EMPTY) | |
2798 | schedule_timeout_uninterruptible(1); | |
2799 | else | |
2800 | - return (done); | |
2801 | + return done; | |
2802 | } | |
2803 | /* Invalid address to tell caller we ran out of time */ | |
2804 | return 1; | |
2805 | @@ -1978,7 +2723,7 @@ | |
2806 | /* or reset) then we don't expect anything weird. */ | |
2807 | if (cmd != CCISS_RESET_MSG && cmd != CCISS_ABORT_MSG) { | |
2808 | #endif | |
2809 | - printk( KERN_WARNING "cciss cciss%d: SendCmd " | |
2810 | + printk(KERN_WARNING "cciss cciss%d: SendCmd " | |
2811 | "Invalid command list address returned! (%lx)\n", | |
2812 | ctlr, complete); | |
2813 | /* not much we can do. */ | |
2814 | @@ -1988,7 +2733,7 @@ | |
2815 | ||
2816 | /* We've sent down an abort or reset, but something else | |
2817 | has completed */ | |
2818 | - if (srl->ncompletions >= (NR_CMDS + 2)) { | |
2819 | + if (srl->ncompletions >= (hba[ctlr]->nr_cmds + 2)) { | |
2820 | /* Uh oh. No room to save it for later... */ | |
2821 | printk(KERN_WARNING "cciss%d: Sendcmd: Invalid command addr, " | |
2822 | "reject list overflow, command lost!\n", ctlr); | |
2823 | @@ -2021,13 +2766,15 @@ | |
2824 | CommandList_struct *c; | |
2825 | int i; | |
2826 | unsigned long complete; | |
2827 | - ctlr_info_t *info_p= hba[ctlr]; | |
2828 | + ctlr_info_t *info_p = hba[ctlr]; | |
2829 | u64bit buff_dma_handle; | |
2830 | int status, done = 0; | |
2831 | + unsigned char sense_key; | |
2832 | + int print_this_error = 1; /* print errors by default */ | |
2833 | ||
2834 | if ((c = cmd_alloc(info_p, 1)) == NULL) { | |
2835 | printk(KERN_WARNING "cciss: unable to get memory"); | |
2836 | - return(IO_ERROR); | |
2837 | + return IO_ERROR; | |
2838 | } | |
2839 | status = fill_cmd(c, cmd, ctlr, buff, size, use_unit_num, | |
2840 | log_unit, page_code, scsi3addr, cmd_type); | |
2841 | @@ -2048,12 +2795,9 @@ | |
2842 | /* Actually it should be completely empty at this time */ | |
2843 | /* unless we are in here doing error handling for the scsi */ | |
2844 | /* tape side of the driver. */ | |
2845 | - for (i = 200000; i > 0; i--) | |
2846 | - { | |
2847 | + for (i = 200000; i > 0; i--) { | |
2848 | /* if fifo isn't full go */ | |
2849 | - if (!(info_p->access.fifo_full(info_p))) | |
2850 | - { | |
2851 | - | |
2852 | + if (!(info_p->access.fifo_full(info_p))) { | |
2853 | break; | |
2854 | } | |
2855 | udelay(10); | |
2856 | @@ -2081,11 +2825,9 @@ | |
2857 | done = 1; | |
2858 | break; | |
2859 | } | |
2860 | - | |
2861 | /* This will need to change for direct lookup completions */ | |
2862 | - if ( (complete & CISS_ERROR_BIT) | |
2863 | - && (complete & ~CISS_ERROR_BIT) == c->busaddr) | |
2864 | - { | |
2865 | + if ((complete & CISS_ERROR_BIT) | |
2866 | + && (complete & ~CISS_ERROR_BIT) == c->busaddr) { | |
2867 | /* if data overrun or underun on Report command | |
2868 | ignore it | |
2869 | */ | |
2870 | @@ -2095,37 +2837,44 @@ | |
2871 | ((c->err_info->CommandStatus == | |
2872 | CMD_DATA_OVERRUN) || | |
2873 | (c->err_info->CommandStatus == | |
2874 | - CMD_DATA_UNDERRUN) | |
2875 | - )) | |
2876 | - { | |
2877 | + CMD_DATA_UNDERRUN))) { | |
2878 | complete = c->busaddr; | |
2879 | } else { | |
2880 | - if (c->err_info->CommandStatus == | |
2881 | - CMD_UNSOLICITED_ABORT) { | |
2882 | + switch(c->err_info->CommandStatus) { | |
2883 | + case CMD_UNSOLICITED_ABORT: | |
2884 | printk(KERN_WARNING "cciss%d: " | |
2885 | - "unsolicited abort %p\n", | |
2886 | - ctlr, c); | |
2887 | - if (c->retry_count < MAX_CMD_RETRIES) { | |
2888 | + "unsolicited abort\n", | |
2889 | + ctlr); | |
2890 | + if (c->retry_count | |
2891 | + < MAX_CMD_RETRIES) { | |
2892 | printk(KERN_WARNING | |
2893 | - "cciss%d: retrying %p\n", | |
2894 | - ctlr, c); | |
2895 | + "cciss%d:" | |
2896 | + " retrying" | |
2897 | + " cmd\n", | |
2898 | + ctlr); | |
2899 | c->retry_count++; | |
2900 | - /* erase the old error */ | |
2901 | - /* information */ | |
2902 | + /* erase the old | |
2903 | + * error info | |
2904 | + */ | |
2905 | memset(c->err_info, 0, | |
2906 | - sizeof(ErrorInfo_struct)); | |
2907 | + sizeof (ErrorInfo_struct)); | |
2908 | goto resend_cmd1; | |
2909 | } else { | |
2910 | printk(KERN_WARNING | |
2911 | - "cciss%d: retried %p too " | |
2912 | - "many times\n", ctlr, c); | |
2913 | + "cciss%d: retried" | |
2914 | + " cmd too many " | |
2915 | + " times\n", ctlr); | |
2916 | status = IO_ERROR; | |
2917 | goto cleanup1; | |
2918 | } | |
2919 | - } else if (c->err_info->CommandStatus == CMD_UNABORTABLE) { | |
2920 | - printk(KERN_WARNING "cciss%d: command could not be aborted.\n", ctlr); | |
2921 | + break; | |
2922 | + case CMD_UNABORTABLE: | |
2923 | + printk(KERN_WARNING "cciss%d" | |
2924 | + " command could not be" | |
2925 | + " aborted.\n", ctlr); | |
2926 | status = IO_ERROR; | |
2927 | goto cleanup1; | |
2928 | + break; | |
2929 | } | |
2930 | printk(KERN_WARNING "ciss ciss%d: sendcmd" | |
2931 | " Error %x \n", ctlr, | |
2932 | @@ -2140,6 +2889,15 @@ | |
2933 | goto cleanup1; | |
2934 | } | |
2935 | } | |
2936 | + if ((c->err_info->ScsiStatus) == | |
2937 | + CMD_RESERVATION_CONFLICT) { | |
2938 | + printk(KERN_WARNING "cciss:%d" | |
2939 | + " device is reserved." | |
2940 | + "\n", ctlr); | |
2941 | + print_this_error = 0; | |
2942 | + status = IO_ERROR; | |
2943 | + goto cleanup1; | |
2944 | + } | |
2945 | /* This will need changing for direct lookup completions */ | |
2946 | if (complete != c->busaddr) { | |
2947 | if (add_sendcmd_reject(cmd, ctlr, complete) != 0) { | |
2948 | @@ -2151,6 +2909,10 @@ | |
2949 | } while (!done); | |
2950 | ||
2951 | cleanup1: | |
2952 | + | |
2953 | + if ((status == IO_ERROR) && (print_this_error)) | |
2954 | + print_cmd(c); | |
2955 | + | |
2956 | /* unlock the data buffer from DMA */ | |
2957 | buff_dma_handle.val32.lower = c->SG[0].Addr.lower; | |
2958 | buff_dma_handle.val32.upper = c->SG[0].Addr.upper; | |
2959 | @@ -2162,7 +2924,7 @@ | |
2960 | do_cciss_intr(0, info_p, NULL); | |
2961 | #endif | |
2962 | cmd_free(info_p, c, 1); | |
2963 | - return (status); | |
2964 | + return status; | |
2965 | } | |
2966 | /* | |
2967 | * Map (physical) PCI mem into (virtual) kernel space | |
2968 | @@ -2171,7 +2933,7 @@ | |
2969 | { | |
2970 | ulong page_base = ((ulong) base) & PAGE_MASK; | |
2971 | ulong page_offs = ((ulong) base) - page_base; | |
2972 | - void __iomem *page_remapped = ioremap(page_base, page_offs+size); | |
2973 | + void __iomem *page_remapped = ioremap(page_base, page_offs + size); | |
2974 | ||
2975 | return page_remapped ? (page_remapped + page_offs) : NULL; | |
2976 | } | |
2977 | @@ -2180,19 +2942,18 @@ | |
2978 | * Takes jobs of the Q and sends them to the hardware, then puts it on | |
2979 | * the Q to wait for completion. | |
2980 | */ | |
2981 | -static void start_io( ctlr_info_t *h) | |
2982 | +static void start_io(ctlr_info_t *h) | |
2983 | { | |
2984 | CommandList_struct *c; | |
2985 | ||
2986 | - while(( c = h->reqQ) != NULL ) | |
2987 | - { | |
2988 | + while(( c = h->reqQ) != NULL ) { | |
2989 | /* can't do anything if fifo is full */ | |
2990 | if ((h->access.fifo_full(h))) { | |
2991 | printk(KERN_WARNING "cciss: fifo full\n"); | |
2992 | break; | |
2993 | } | |
2994 | ||
2995 | - /* Get the frist entry from the Request Q */ | |
2996 | + /* Get the first entry from the Request Q */ | |
2997 | removeQ(&(h->reqQ), c); | |
2998 | h->Qdepth--; | |
2999 | ||
3000 | @@ -2200,145 +2961,220 @@ | |
3001 | h->access.submit_command(h, c); | |
3002 | ||
3003 | /* Put job onto the completed Q */ | |
3004 | - addQ (&(h->cmpQ), c); | |
3005 | + addQ(&(h->cmpQ), c); | |
3006 | } | |
3007 | } | |
3008 | /* Assumes that CCISS_LOCK(h->ctlr) is held. */ | |
3009 | /* Zeros out the error record and then resends the command back */ | |
3010 | /* to the controller */ | |
3011 | -static inline void resend_cciss_cmd( ctlr_info_t *h, CommandList_struct *c) | |
3012 | +static inline void resend_cciss_cmd(ctlr_info_t *h, CommandList_struct *c) | |
3013 | { | |
3014 | /* erase the old error information */ | |
3015 | memset(c->err_info, 0, sizeof(ErrorInfo_struct)); | |
3016 | ||
3017 | /* add it to software queue and then send it to the controller */ | |
3018 | - addQ(&(h->reqQ),c); | |
3019 | + addQ(&(h->reqQ), c); | |
3020 | h->Qdepth++; | |
3021 | - if(h->Qdepth > h->maxQsinceinit) | |
3022 | + if (h->Qdepth > h->maxQsinceinit) | |
3023 | h->maxQsinceinit = h->Qdepth; | |
3024 | ||
3025 | start_io(h); | |
3026 | } | |
3027 | ||
3028 | +static inline unsigned int make_status_bytes(unsigned int scsi_status_byte, | |
3029 | + unsigned int msg_byte, unsigned int host_byte, | |
3030 | + unsigned int driver_byte) | |
3031 | +{ | |
3032 | + /* inverse of macros in scsi.h */ | |
3033 | + return (scsi_status_byte & 0xff) | | |
3034 | + ((msg_byte & 0xff) << 8) | | |
3035 | + ((host_byte & 0xff) << 16) | | |
3036 | + ((driver_byte & 0xff) << 24); | |
3037 | +} | |
3038 | + | |
3039 | +static inline int evaluate_target_status(CommandList_struct *cmd) | |
3040 | +{ | |
3041 | + unsigned char sense_key; | |
3042 | + unsigned char status_byte, msg_byte, host_byte, driver_byte; | |
3043 | + int error_value; | |
3044 | + | |
3045 | + /* If we get in here, it means we got "target status", that is, scsi status */ | |
3046 | + status_byte = cmd->err_info->ScsiStatus; | |
3047 | + driver_byte = DRIVER_OK; | |
3048 | + msg_byte = cmd->err_info->CommandStatus; /* correct? seems too device specific */ | |
3049 | + | |
3050 | + if (blk_pc_request(cmd->rq)) | |
3051 | + host_byte = DID_PASSTHROUGH; | |
3052 | + else | |
3053 | + host_byte = DID_OK; | |
3054 | + | |
3055 | + error_value = make_status_bytes(status_byte, msg_byte, | |
3056 | + host_byte, driver_byte); | |
3057 | + | |
3058 | + if (cmd->err_info->ScsiStatus != CMD_RESERVATION_CONFLICT) { | |
3059 | + if (cmd->err_info->ScsiStatus != SAM_STAT_CHECK_CONDITION) | |
3060 | + if (!blk_pc_request(cmd->rq)) | |
3061 | + printk(KERN_WARNING "cciss: cmd %p " | |
3062 | + "has SCSI Status 0x%x\n", | |
3063 | + cmd, cmd->err_info->ScsiStatus); | |
3064 | + return error_value; | |
3065 | + } | |
3066 | + | |
3067 | + /* check the sense key */ | |
3068 | + sense_key = 0xf & cmd->err_info->SenseInfo[2]; | |
3069 | + /* no status or recovered error */ | |
3070 | + if (((sense_key == 0x0) || (sense_key == 0x1)) && !blk_pc_request(cmd->rq)) | |
3071 | + error_value = 0; | |
3072 | + | |
3073 | + if (!blk_pc_request(cmd->rq)) { /* Not SG_IO or similar? */ | |
3074 | + if (error_value != 0) | |
3075 | + printk(KERN_WARNING "cciss: cmd %p has CHECK CONDITION" | |
3076 | + " sense key = 0x%x\n", cmd, sense_key); | |
3077 | + return error_value; | |
3078 | + } | |
3079 | + | |
3080 | + /* SG_IO or similar, copy sense data back */ | |
3081 | + if (cmd->rq->sense) { | |
3082 | + if (cmd->rq->sense_len > cmd->err_info->SenseLen) | |
3083 | + cmd->rq->sense_len = cmd->err_info->SenseLen; | |
3084 | + memcpy(cmd->rq->sense, cmd->err_info->SenseInfo, | |
3085 | + cmd->rq->sense_len); | |
3086 | + } else | |
3087 | + cmd->rq->sense_len = 0; | |
3088 | + | |
3089 | + return error_value; | |
3090 | +} | |
3091 | + | |
3092 | /* checks the status of the job and calls complete buffers to mark all | |
3093 | * buffers for the completed job. Note that this function does not need | |
3094 | * to hold the hba/queue lock. | |
3095 | */ | |
3096 | -static inline void complete_command( ctlr_info_t *h, CommandList_struct *cmd, | |
3097 | +static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd, | |
3098 | int timeout) | |
3099 | { | |
3100 | - int status = 1; | |
3101 | int retry_cmd = 0; | |
3102 | - | |
3103 | + struct request *rq = cmd->rq; | |
3104 | + int ctlr = h->ctlr; | |
3105 | + int print_this_error = 1; /* print errors by default */ | |
3106 | + | |
3107 | + rq->errors = 0; | |
3108 | if (timeout) | |
3109 | - status = 0; | |
3110 | + rq->errors = make_status_bytes(0, 0, 0, DRIVER_TIMEOUT); | |
3111 | ||
3112 | - if(cmd->err_info->CommandStatus != 0) | |
3113 | - { /* an error has occurred */ | |
3114 | - switch(cmd->err_info->CommandStatus) | |
3115 | - { | |
3116 | - unsigned char sense_key; | |
3117 | - case CMD_TARGET_STATUS: | |
3118 | - status = 0; | |
3119 | - | |
3120 | - if( cmd->err_info->ScsiStatus == 0x02) | |
3121 | - { | |
3122 | - printk(KERN_WARNING "cciss: cmd %p " | |
3123 | - "has CHECK CONDITION " | |
3124 | - " byte 2 = 0x%x\n", cmd, | |
3125 | - cmd->err_info->SenseInfo[2] | |
3126 | - ); | |
3127 | - /* check the sense key */ | |
3128 | - sense_key = 0xf & | |
3129 | - cmd->err_info->SenseInfo[2]; | |
3130 | - /* no status or recovered error */ | |
3131 | - if((sense_key == 0x0) || | |
3132 | - (sense_key == 0x1)) | |
3133 | - { | |
3134 | - status = 1; | |
3135 | - } | |
3136 | - } else | |
3137 | - { | |
3138 | - printk(KERN_WARNING "cciss: cmd %p " | |
3139 | - "has SCSI Status 0x%x\n", | |
3140 | - cmd, cmd->err_info->ScsiStatus); | |
3141 | - } | |
3142 | - break; | |
3143 | - case CMD_DATA_UNDERRUN: | |
3144 | - printk(KERN_WARNING "cciss: cmd %p has" | |
3145 | - " completed with data underrun " | |
3146 | - "reported\n", cmd); | |
3147 | - break; | |
3148 | - case CMD_DATA_OVERRUN: | |
3149 | - printk(KERN_WARNING "cciss: cmd %p has" | |
3150 | - " completed with data overrun " | |
3151 | - "reported\n", cmd); | |
3152 | - break; | |
3153 | - case CMD_INVALID: | |
3154 | - printk(KERN_WARNING "cciss: cmd %p is " | |
3155 | - "reported invalid\n", cmd); | |
3156 | - status = 0; | |
3157 | - break; | |
3158 | - case CMD_PROTOCOL_ERR: | |
3159 | - printk(KERN_WARNING "cciss: cmd %p has " | |
3160 | - "protocol error \n", cmd); | |
3161 | - status = 0; | |
3162 | - break; | |
3163 | - case CMD_HARDWARE_ERR: | |
3164 | - printk(KERN_WARNING "cciss: cmd %p had " | |
3165 | - " hardware error\n", cmd); | |
3166 | - status = 0; | |
3167 | - break; | |
3168 | - case CMD_CONNECTION_LOST: | |
3169 | - printk(KERN_WARNING "cciss: cmd %p had " | |
3170 | - "connection lost\n", cmd); | |
3171 | - status=0; | |
3172 | - break; | |
3173 | - case CMD_ABORTED: | |
3174 | - printk(KERN_WARNING "cciss: cmd %p was " | |
3175 | - "aborted\n", cmd); | |
3176 | - status=0; | |
3177 | - break; | |
3178 | - case CMD_ABORT_FAILED: | |
3179 | - printk(KERN_WARNING "cciss: cmd %p reports " | |
3180 | - "abort failed\n", cmd); | |
3181 | - status=0; | |
3182 | - break; | |
3183 | - case CMD_UNSOLICITED_ABORT: | |
3184 | - printk(KERN_WARNING "cciss%d: unsolicited " | |
3185 | - "abort %p\n", h->ctlr, cmd); | |
3186 | - if (cmd->retry_count < MAX_CMD_RETRIES) { | |
3187 | - retry_cmd=1; | |
3188 | - printk(KERN_WARNING | |
3189 | - "cciss%d: retrying %p\n", | |
3190 | - h->ctlr, cmd); | |
3191 | - cmd->retry_count++; | |
3192 | - } else | |
3193 | - printk(KERN_WARNING | |
3194 | - "cciss%d: %p retried too " | |
3195 | - "many times\n", h->ctlr, cmd); | |
3196 | - status=0; | |
3197 | - break; | |
3198 | - case CMD_TIMEOUT: | |
3199 | - printk(KERN_WARNING "cciss: cmd %p timedout\n", | |
3200 | - cmd); | |
3201 | - status=0; | |
3202 | - break; | |
3203 | - default: | |
3204 | - printk(KERN_WARNING "cciss: cmd %p returned " | |
3205 | - "unknown status %x\n", cmd, | |
3206 | - cmd->err_info->CommandStatus); | |
3207 | - status=0; | |
3208 | - } | |
3209 | + if(cmd->err_info->CommandStatus == 0) /* no error has occurred */ | |
3210 | + goto after_error_processing; | |
3211 | + | |
3212 | + switch(cmd->err_info->CommandStatus) { | |
3213 | + case CMD_TARGET_STATUS: | |
3214 | + rq->errors = evaluate_target_status(cmd); | |
3215 | + break; | |
3216 | + case CMD_DATA_UNDERRUN: | |
3217 | + if (blk_fs_request(rq)) | |
3218 | + printk(KERN_WARNING "cciss: cmd %p has" | |
3219 | + " completed with data underrun " | |
3220 | + "reported\n", cmd); | |
3221 | + break; | |
3222 | + case CMD_DATA_OVERRUN: | |
3223 | + if (blk_fs_request(rq)) | |
3224 | + printk(KERN_WARNING "cciss: cmd %p has" | |
3225 | + " completed with data overrun " | |
3226 | + "reported\n", cmd); | |
3227 | + break; | |
3228 | + case CMD_INVALID: | |
3229 | + printk(KERN_WARNING "cciss%d: cmd is " | |
3230 | + "reported invalid\n", ctlr); | |
3231 | + rq->errors = make_status_bytes(SAM_STAT_GOOD, | |
3232 | + cmd->err_info->CommandStatus, DRIVER_OK, | |
3233 | + blk_pc_request(rq) ? DID_PASSTHROUGH : DID_ERROR); | |
3234 | + break; | |
3235 | + case CMD_PROTOCOL_ERR: | |
3236 | + printk(KERN_WARNING "cciss%d: cmd has " | |
3237 | + "protocol error \n", ctlr); | |
3238 | + rq->errors = make_status_bytes(SAM_STAT_GOOD, | |
3239 | + cmd->err_info->CommandStatus, DRIVER_OK, | |
3240 | + blk_pc_request(rq) ? DID_PASSTHROUGH : DID_ERROR); | |
3241 | + break; | |
3242 | + case CMD_HARDWARE_ERR: | |
3243 | + printk(KERN_WARNING "cciss%d: cmd had " | |
3244 | + " hardware error\n", ctlr); | |
3245 | + rq->errors = make_status_bytes(SAM_STAT_GOOD, | |
3246 | + cmd->err_info->CommandStatus, DRIVER_OK, | |
3247 | + blk_pc_request(rq) ? DID_PASSTHROUGH : DID_ERROR); | |
3248 | + break; | |
3249 | + case CMD_CONNECTION_LOST: | |
3250 | + printk(KERN_WARNING "cciss%d: cmd had " | |
3251 | + "connection lost\n", ctlr); | |
3252 | + rq->errors = make_status_bytes(SAM_STAT_GOOD, | |
3253 | + cmd->err_info->CommandStatus, DRIVER_OK, | |
3254 | + blk_pc_request(rq) ? DID_PASSTHROUGH : DID_ERROR); | |
3255 | + break; | |
3256 | + case CMD_ABORTED: | |
3257 | + printk(KERN_WARNING "cciss%d: cmd was " | |
3258 | + "aborted\n", ctlr); | |
3259 | + rq->errors = make_status_bytes(SAM_STAT_GOOD, | |
3260 | + cmd->err_info->CommandStatus, DRIVER_OK, | |
3261 | + blk_pc_request(rq) ? DID_PASSTHROUGH : DID_ABORT); | |
3262 | + break; | |
3263 | + case CMD_ABORT_FAILED: | |
3264 | + printk(KERN_WARNING "cciss%d: cmd reports " | |
3265 | + "abort failed\n", ctlr); | |
3266 | + rq->errors = make_status_bytes(SAM_STAT_GOOD, | |
3267 | + cmd->err_info->CommandStatus, DRIVER_OK, | |
3268 | + blk_pc_request(rq) ? DID_PASSTHROUGH : DID_ERROR); | |
3269 | + break; | |
3270 | + case CMD_UNSOLICITED_ABORT: | |
3271 | + printk(KERN_WARNING "cciss%d: unsolicited " | |
3272 | + "abort\n", ctlr); | |
3273 | + if (cmd->retry_count < MAX_CMD_RETRIES) { | |
3274 | + retry_cmd = 1; | |
3275 | + printk(KERN_WARNING | |
3276 | + "cciss%d: retrying cmd\n", ctlr); | |
3277 | + cmd->retry_count++; | |
3278 | + } else | |
3279 | + printk(KERN_WARNING | |
3280 | + "cciss%d: cmd retried too " | |
3281 | + "many times\n", ctlr); | |
3282 | + rq->errors = make_status_bytes(SAM_STAT_GOOD, | |
3283 | + cmd->err_info->CommandStatus, DRIVER_OK, | |
3284 | + blk_pc_request(rq) ? DID_PASSTHROUGH : DID_ABORT); | |
3285 | + break; | |
3286 | + case CMD_TIMEOUT: | |
3287 | + printk(KERN_WARNING "cciss%d: cmd timedout\n", ctlr); | |
3288 | + rq->errors = make_status_bytes(SAM_STAT_GOOD, | |
3289 | + cmd->err_info->CommandStatus, DRIVER_OK, | |
3290 | + blk_pc_request(rq) ? DID_PASSTHROUGH : DID_ERROR); | |
3291 | + break; | |
3292 | + case CMD_RESERVATION_CONFLICT: | |
3293 | + printk(KERN_WARNING "reservation conflict in complete_command\n"); | |
3294 | + rq->errors = make_status_bytes(SAM_STAT_GOOD, | |
3295 | + cmd->err_info->CommandStatus, DRIVER_OK, | |
3296 | + blk_pc_request(rq) ? DID_PASSTHROUGH : DID_ERROR); | |
3297 | + print_this_error = 0; | |
3298 | + break; | |
3299 | + default: | |
3300 | + printk(KERN_WARNING "cciss%d: cmd returned " | |
3301 | + "unknown status %x\n", ctlr, | |
3302 | + cmd->err_info->CommandStatus); | |
3303 | + rq->errors = make_status_bytes(SAM_STAT_GOOD, | |
3304 | + cmd->err_info->CommandStatus, DRIVER_OK, | |
3305 | + blk_pc_request(rq) ? DID_PASSTHROUGH : DID_ERROR); | |
3306 | } | |
3307 | + | |
3308 | +after_error_processing: | |
3309 | + | |
3310 | /* We need to return this command */ | |
3311 | - if(retry_cmd) { | |
3312 | - resend_cciss_cmd(h,cmd); | |
3313 | + if (retry_cmd) { | |
3314 | + resend_cciss_cmd(h, cmd); | |
3315 | return; | |
3316 | - } | |
3317 | + } | |
3318 | + | |
3319 | + if ((rq->errors != 0) && !blk_pc_request(rq) && print_this_error) | |
3320 | + print_cmd(cmd); | |
3321 | ||
3322 | cmd->rq->completion_data = cmd; | |
3323 | - cmd->rq->errors = status; | |
3324 | +#ifdef CONFIG_BLK_DEV_IO_TRACE | |
3325 | + blk_add_trace_rq(cmd->rq->q, cmd->rq, BLK_TA_COMPLETE); | |
3326 | +#endif | |
3327 | blk_complete_request(cmd->rq); | |
3328 | } | |
3329 | ||
3330 | @@ -2347,9 +3183,10 @@ | |
3331 | */ | |
3332 | static void do_cciss_request(request_queue_t *q) | |
3333 | { | |
3334 | - ctlr_info_t *h= q->queuedata; | |
3335 | + ctlr_info_t *h = q->queuedata; | |
3336 | CommandList_struct *c; | |
3337 | - int start_blk, seg; | |
3338 | + sector_t start_blk; | |
3339 | + int seg; | |
3340 | struct request *creq; | |
3341 | u64bit temp64; | |
3342 | struct scatterlist tmp_sg[MAXSGENTRIES]; | |
3343 | @@ -2367,10 +3204,9 @@ | |
3344 | if (!creq) | |
3345 | goto startio; | |
3346 | ||
3347 | - if (creq->nr_phys_segments > MAXSGENTRIES) | |
3348 | - BUG(); | |
3349 | + BUG_ON(creq->nr_phys_segments > MAXSGENTRIES); | |
3350 | ||
3351 | - if (( c = cmd_alloc(h, 1)) == NULL) | |
3352 | + if ((c = cmd_alloc(h, 1)) == NULL) | |
3353 | goto full; | |
3354 | ||
3355 | blkdev_dequeue_request(creq); | |
3356 | @@ -2388,7 +3224,7 @@ | |
3357 | /* The first 2 bits are reserved for controller error reporting. */ | |
3358 | c->Header.Tag.lower = (c->cmdindex << 3); | |
3359 | c->Header.Tag.lower |= 0x04; /* flag for direct lookup. */ | |
3360 | - c->Header.LUN.LogDev.VolId= drv->LunID; | |
3361 | + c->Header.LUN.LogDev.VolId = drv->LunID; | |
3362 | c->Header.LUN.LogDev.Mode = 1; | |
3363 | c->Request.CDBLen = 10; // 12 byte commands not in FW yet; | |
3364 | c->Request.Type.Type = TYPE_CMD; // It is a command. | |
3365 | @@ -2396,10 +3232,10 @@ | |
3366 | c->Request.Type.Direction = | |
3367 | (rq_data_dir(creq) == READ) ? XFER_READ: XFER_WRITE; | |
3368 | c->Request.Timeout = 0; // Don't time out | |
3369 | - c->Request.CDB[0] = (rq_data_dir(creq) == READ) ? CCISS_READ : CCISS_WRITE; | |
3370 | + c->Request.CDB[0] = (rq_data_dir(creq) == READ) ? h->cciss_read : h->cciss_write; | |
3371 | start_blk = creq->sector; | |
3372 | #ifdef CCISS_DEBUG | |
3373 | - printk(KERN_DEBUG "ciss: sector =%d nr_sectors=%d\n",(int) creq->sector, | |
3374 | + printk(KERN_DEBUG "ciss: sector =%d nr_sectors=%d\n", (int)creq->sector, | |
3375 | (int) creq->nr_sectors); | |
3376 | #endif /* CCISS_DEBUG */ | |
3377 | ||
3378 | @@ -2411,8 +3247,7 @@ | |
3379 | else | |
3380 | dir = PCI_DMA_TODEVICE; | |
3381 | ||
3382 | - for (i=0; i<seg; i++) | |
3383 | - { | |
3384 | + for (i = 0; i < seg; i++) { | |
3385 | c->SG[i].Len = tmp_sg[i].length; | |
3386 | temp64.val = (__u64) pci_map_page(h->pdev, tmp_sg[i].page, | |
3387 | tmp_sg[i].offset, tmp_sg[i].length, | |
3388 | @@ -2422,7 +3257,7 @@ | |
3389 | c->SG[i].Ext = 0; // we are not chaining | |
3390 | } | |
3391 | /* track how many SG entries we are using */ | |
3392 | - if( seg > h->maxSG) | |
3393 | + if(seg > h->maxSG) | |
3394 | h->maxSG = seg; | |
3395 | ||
3396 | #ifdef CCISS_DEBUG | |
3397 | @@ -2430,21 +3265,49 @@ | |
3398 | #endif /* CCISS_DEBUG */ | |
3399 | ||
3400 | c->Header.SGList = c->Header.SGTotal = seg; | |
3401 | - c->Request.CDB[1]= 0; | |
3402 | - c->Request.CDB[2]= (start_blk >> 24) & 0xff; //MSB | |
3403 | - c->Request.CDB[3]= (start_blk >> 16) & 0xff; | |
3404 | - c->Request.CDB[4]= (start_blk >> 8) & 0xff; | |
3405 | - c->Request.CDB[5]= start_blk & 0xff; | |
3406 | - c->Request.CDB[6]= 0; // (sect >> 24) & 0xff; MSB | |
3407 | - c->Request.CDB[7]= (creq->nr_sectors >> 8) & 0xff; | |
3408 | - c->Request.CDB[8]= creq->nr_sectors & 0xff; | |
3409 | - c->Request.CDB[9] = c->Request.CDB[11] = c->Request.CDB[12] = 0; | |
3410 | + if (likely(blk_fs_request(creq))) { | |
3411 | + if(h->cciss_read == CCISS_READ_10) { | |
3412 | + c->Request.CDB[1] = 0; | |
3413 | + c->Request.CDB[2] = (start_blk >> 24) & 0xff; //MSB | |
3414 | + c->Request.CDB[3] = (start_blk >> 16) & 0xff; | |
3415 | + c->Request.CDB[4] = (start_blk >> 8) & 0xff; | |
3416 | + c->Request.CDB[5] = start_blk & 0xff; | |
3417 | + c->Request.CDB[6] = 0; // (sect >> 24) & 0xff; MSB | |
3418 | + c->Request.CDB[7] = (creq->nr_sectors >> 8) & 0xff; | |
3419 | + c->Request.CDB[8] = creq->nr_sectors & 0xff; | |
3420 | + c->Request.CDB[9] = c->Request.CDB[11] = c->Request.CDB[12] = 0; | |
3421 | + } else { | |
3422 | + c->Request.CDBLen = 16; | |
3423 | + c->Request.CDB[1] = 0; | |
3424 | + c->Request.CDB[2] = (start_blk >> 56) & 0xff; //MSB | |
3425 | + c->Request.CDB[3] = (start_blk >> 48) & 0xff; | |
3426 | + c->Request.CDB[4] = (start_blk >> 40) & 0xff; | |
3427 | + c->Request.CDB[5] = (start_blk >> 32) & 0xff; | |
3428 | + c->Request.CDB[6] = (start_blk >> 24) & 0xff; | |
3429 | + c->Request.CDB[7] = (start_blk >> 16) & 0xff; | |
3430 | + c->Request.CDB[8] = (start_blk >> 8) & 0xff; | |
3431 | + c->Request.CDB[9] = start_blk & 0xff; | |
3432 | + c->Request.CDB[10] = (creq->nr_sectors >> 24) & 0xff; | |
3433 | + c->Request.CDB[11] = (creq->nr_sectors >> 16) & 0xff; | |
3434 | + c->Request.CDB[12] = (creq->nr_sectors >> 8) & 0xff; | |
3435 | + c->Request.CDB[13] = creq->nr_sectors & 0xff; | |
3436 | + c->Request.CDB[14] = c->Request.CDB[15] = 0; | |
3437 | + } | |
3438 | + } else if (blk_pc_request(creq)) { | |
3439 | + c->Request.CDBLen = creq->cmd_len; | |
3440 | + memcpy(c->Request.CDB, creq->cmd, BLK_MAX_CDB); | |
3441 | + } else { | |
3442 | + /* In later kernels, rq->flags is supplanted by rq->cmd_type */ | |
3443 | + printk(KERN_WARNING "cciss%d: bad request type, rq->flags=%ld\n", | |
3444 | + h->ctlr, creq->flags); | |
3445 | + BUG(); | |
3446 | + } | |
3447 | ||
3448 | spin_lock_irq(q->queue_lock); | |
3449 | ||
3450 | - addQ(&(h->reqQ),c); | |
3451 | + addQ(&(h->reqQ), c); | |
3452 | h->Qdepth++; | |
3453 | - if(h->Qdepth > h->maxQsinceinit) | |
3454 | + if (h->Qdepth > h->maxQsinceinit) | |
3455 | h->maxQsinceinit = h->Qdepth; | |
3456 | ||
3457 | goto queue; | |
3458 | @@ -2480,7 +3343,7 @@ | |
3459 | static inline int interrupt_pending(ctlr_info_t *h) | |
3460 | { | |
3461 | #ifdef CONFIG_CISS_SCSI_TAPE | |
3462 | - return ( h->access.intr_pending(h) | |
3463 | + return (h->access.intr_pending(h) | |
3464 | || (h->scsi_rejects.ncompletions > 0)); | |
3465 | #else | |
3466 | return h->access.intr_pending(h); | |
3467 | @@ -2505,8 +3368,6 @@ | |
3468 | CommandList_struct *c; | |
3469 | unsigned long flags; | |
3470 | __u32 a, a1, a2; | |
3471 | - int j; | |
3472 | - int start_queue = h->next_to_run; | |
3473 | ||
3474 | if (interrupt_not_for_us(h)) | |
3475 | return IRQ_NONE; | |
3476 | @@ -2516,12 +3377,14 @@ | |
3477 | */ | |
3478 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | |
3479 | while (interrupt_pending(h)) { | |
3480 | - while((a = get_next_completion(h)) != FIFO_EMPTY) { | |
3481 | + while ((a = get_next_completion(h)) != FIFO_EMPTY) { | |
3482 | a1 = a; | |
3483 | if ((a & 0x04)) { | |
3484 | a2 = (a >> 3); | |
3485 | - if (a2 >= NR_CMDS) { | |
3486 | + if (a2 >= h->nr_cmds) { | |
3487 | printk(KERN_WARNING "cciss: controller cciss%d failed, stopping.\n", h->ctlr); | |
3488 | + spin_unlock_irqrestore( | |
3489 | + CCISS_LOCK(h->ctlr), flags); | |
3490 | fail_all_cmds(h->ctlr); | |
3491 | return IRQ_HANDLED; | |
3492 | } | |
3493 | @@ -2535,7 +3398,7 @@ | |
3494 | printk(KERN_WARNING "cciss: Completion of %08x ignored\n", a1); | |
3495 | continue; | |
3496 | } | |
3497 | - while(c->busaddr != a) { | |
3498 | + while (c->busaddr != a) { | |
3499 | c = c->next; | |
3500 | if (c == h->cmpQ) | |
3501 | break; | |
3502 | @@ -2560,66 +3423,25 @@ | |
3503 | } | |
3504 | } | |
3505 | } | |
3506 | - | |
3507 | - /* check to see if we have maxed out the number of commands that can | |
3508 | - * be placed on the queue. If so then exit. We do this check here | |
3509 | - * in case the interrupt we serviced was from an ioctl and did not | |
3510 | - * free any new commands. | |
3511 | - */ | |
3512 | - if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS) | |
3513 | - goto cleanup; | |
3514 | - | |
3515 | - /* We have room on the queue for more commands. Now we need to queue | |
3516 | - * them up. We will also keep track of the next queue to run so | |
3517 | - * that every queue gets a chance to be started first. | |
3518 | - */ | |
3519 | - for (j=0; j < h->highest_lun + 1; j++){ | |
3520 | - int curr_queue = (start_queue + j) % (h->highest_lun + 1); | |
3521 | - /* make sure the disk has been added and the drive is real | |
3522 | - * because this can be called from the middle of init_one. | |
3523 | - */ | |
3524 | - if(!(h->drv[curr_queue].queue) || | |
3525 | - !(h->drv[curr_queue].heads)) | |
3526 | - continue; | |
3527 | - blk_start_queue(h->gendisk[curr_queue]->queue); | |
3528 | - | |
3529 | - /* check to see if we have maxed out the number of commands | |
3530 | - * that can be placed on the queue. | |
3531 | - */ | |
3532 | - if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS) | |
3533 | - { | |
3534 | - if (curr_queue == start_queue){ | |
3535 | - h->next_to_run = (start_queue + 1) % (h->highest_lun + 1); | |
3536 | - goto cleanup; | |
3537 | - } else { | |
3538 | - h->next_to_run = curr_queue; | |
3539 | - goto cleanup; | |
3540 | - } | |
3541 | - } else { | |
3542 | - curr_queue = (curr_queue + 1) % (h->highest_lun + 1); | |
3543 | - } | |
3544 | - } | |
3545 | - | |
3546 | -cleanup: | |
3547 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | |
3548 | return IRQ_HANDLED; | |
3549 | } | |
3550 | /* | |
3551 | - * We cannot read the structure directly, for portablity we must use | |
3552 | + * We cannot read the structure directly, for portability we must use | |
3553 | * the io functions. | |
3554 | * This is for debug only. | |
3555 | */ | |
3556 | #ifdef CCISS_DEBUG | |
3557 | -static void print_cfg_table( CfgTable_struct *tb) | |
3558 | +static void print_cfg_table(CfgTable_struct *tb) | |
3559 | { | |
3560 | int i; | |
3561 | char temp_name[17]; | |
3562 | ||
3563 | printk("Controller Configuration information\n"); | |
3564 | printk("------------------------------------\n"); | |
3565 | - for(i=0;i<4;i++) | |
3566 | + for (i = 0; i < 4; i++) | |
3567 | temp_name[i] = readb(&(tb->Signature[i])); | |
3568 | - temp_name[4]='\0'; | |
3569 | + temp_name[4] = '\0'; | |
3570 | printk(" Signature = %s\n", temp_name); | |
3571 | printk(" Spec Number = %d\n", readl(&(tb->SpecValence))); | |
3572 | printk(" Transport methods supported = 0x%x\n", | |
3573 | @@ -2628,14 +3450,14 @@ | |
3574 | readl(&(tb->TransportActive))); | |
3575 | printk(" Requested transport Method = 0x%x\n", | |
3576 | readl(&(tb->HostWrite.TransportRequest))); | |
3577 | - printk(" Coalese Interrupt Delay = 0x%x\n", | |
3578 | + printk(" Coalesce Interrupt Delay = 0x%x\n", | |
3579 | readl(&(tb->HostWrite.CoalIntDelay))); | |
3580 | - printk(" Coalese Interrupt Count = 0x%x\n", | |
3581 | + printk(" Coalesce Interrupt Count = 0x%x\n", | |
3582 | readl(&(tb->HostWrite.CoalIntCount))); | |
3583 | printk(" Max outstanding commands = 0x%d\n", | |
3584 | readl(&(tb->CmdsOutMax))); | |
3585 | printk(" Bus Types = 0x%x\n", readl(&(tb-> BusTypes))); | |
3586 | - for(i=0;i<16;i++) | |
3587 | + for (i = 0; i < 16; i++) | |
3588 | temp_name[i] = readb(&(tb->ServerName[i])); | |
3589 | temp_name[16] = '\0'; | |
3590 | printk(" Server Name = %s\n", temp_name); | |
3591 | @@ -2644,16 +3466,6 @@ | |
3592 | } | |
3593 | #endif /* CCISS_DEBUG */ | |
3594 | ||
3595 | -static void release_io_mem(ctlr_info_t *c) | |
3596 | -{ | |
3597 | - /* if IO mem was not protected do nothing */ | |
3598 | - if( c->io_mem_addr == 0) | |
3599 | - return; | |
3600 | - release_region(c->io_mem_addr, c->io_mem_length); | |
3601 | - c->io_mem_addr = 0; | |
3602 | - c->io_mem_length = 0; | |
3603 | -} | |
3604 | - | |
3605 | static int find_PCI_BAR_index(struct pci_dev *pdev, | |
3606 | unsigned long pci_bar_addr) | |
3607 | { | |
3608 | @@ -2661,7 +3473,7 @@ | |
3609 | if (pci_bar_addr == PCI_BASE_ADDRESS_0) /* looking for BAR zero? */ | |
3610 | return 0; | |
3611 | offset = 0; | |
3612 | - for (i=0; i<DEVICE_COUNT_RESOURCE; i++) { | |
3613 | + for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { | |
3614 | bar_type = pci_resource_flags(pdev, i) & | |
3615 | PCI_BASE_ADDRESS_SPACE; | |
3616 | if (bar_type == PCI_BASE_ADDRESS_SPACE_IO) | |
3617 | @@ -2684,7 +3496,7 @@ | |
3618 | } | |
3619 | } | |
3620 | if (offset == pci_bar_addr - PCI_BASE_ADDRESS_0) | |
3621 | - return i+1; | |
3622 | + return i + 1; | |
3623 | } | |
3624 | return -1; | |
3625 | } | |
3626 | @@ -2692,8 +3504,8 @@ | |
3627 | /* If MSI/MSI-X is supported by the kernel we will try to enable it on | |
3628 | * controllers that are capable. If not, we use IO-APIC mode. | |
3629 | */ | |
3630 | - | |
3631 | -static void __devinit cciss_interrupt_mode(ctlr_info_t *c, struct pci_dev *pdev, __u32 board_id) | |
3632 | +static void __devinit cciss_interrupt_mode(ctlr_info_t *c, | |
3633 | + struct pci_dev *pdev, __u32 board_id) | |
3634 | { | |
3635 | #ifdef CONFIG_PCI_MSI | |
3636 | int err; | |
3637 | @@ -2719,26 +3531,24 @@ | |
3638 | } | |
3639 | if (err > 0) { | |
3640 | printk(KERN_WARNING "cciss: only %d MSI-X vectors " | |
3641 | - "available\n", err); | |
3642 | + " available\n", err); | |
3643 | + goto default_int_mode; | |
3644 | } else { | |
3645 | - printk(KERN_WARNING "cciss: MSI-X init failed %d\n", | |
3646 | - err); | |
3647 | + printk(KERN_WARNING "cciss: MSI-X init failed," | |
3648 | + " failure mode unknown, error = %d\n", err); | |
3649 | + goto default_int_mode; | |
3650 | } | |
3651 | } | |
3652 | if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) { | |
3653 | if (!pci_enable_msi(pdev)) { | |
3654 | - c->intr[SIMPLE_MODE_INT] = pdev->irq; | |
3655 | c->msi_vector = 1; | |
3656 | - return; | |
3657 | } else { | |
3658 | printk(KERN_WARNING "cciss: MSI init failed\n"); | |
3659 | - c->intr[SIMPLE_MODE_INT] = pdev->irq; | |
3660 | - return; | |
3661 | } | |
3662 | } | |
3663 | +default_int_mode: | |
3664 | #endif /* CONFIG_PCI_MSI */ | |
3665 | /* if we get here we're going to use the default interrupt mode */ | |
3666 | -default_int_mode: | |
3667 | c->intr[SIMPLE_MODE_INT] = pdev->irq; | |
3668 | return; | |
3669 | } | |
3670 | @@ -2750,53 +3560,34 @@ | |
3671 | __u64 cfg_offset; | |
3672 | __u32 cfg_base_addr; | |
3673 | __u64 cfg_base_addr_index; | |
3674 | - int i; | |
3675 | + int i, err; | |
3676 | ||
3677 | /* check to see if controller has been disabled */ | |
3678 | /* BEFORE trying to enable it */ | |
3679 | - (void) pci_read_config_word(pdev, PCI_COMMAND,&command); | |
3680 | - if(!(command & 0x02)) | |
3681 | - { | |
3682 | - printk(KERN_WARNING "cciss: controller appears to be disabled\n"); | |
3683 | - return(-1); | |
3684 | + (void)pci_read_config_word(pdev, PCI_COMMAND,&command); | |
3685 | + if (!(command & 0x02)) { | |
3686 | + printk(KERN_WARNING | |
3687 | + "cciss: controller appears to be disabled\n"); | |
3688 | + return -ENODEV; | |
3689 | } | |
3690 | ||
3691 | - if (pci_enable_device(pdev)) | |
3692 | - { | |
3693 | + err = pci_enable_device(pdev); | |
3694 | + if (err) { | |
3695 | printk(KERN_ERR "cciss: Unable to Enable PCI device\n"); | |
3696 | - return( -1); | |
3697 | + return err; | |
3698 | } | |
3699 | ||
3700 | + err = pci_request_regions(pdev, "cciss"); | |
3701 | + if (err) { | |
3702 | + printk(KERN_ERR "cciss: Cannot obtain PCI resources, " | |
3703 | + "aborting\n"); | |
3704 | + goto err_out_disable_pdev; | |
3705 | + } | |
3706 | subsystem_vendor_id = pdev->subsystem_vendor; | |
3707 | subsystem_device_id = pdev->subsystem_device; | |
3708 | board_id = (((__u32) (subsystem_device_id << 16) & 0xffff0000) | | |
3709 | subsystem_vendor_id); | |
3710 | ||
3711 | - /* search for our IO range so we can protect it */ | |
3712 | - for(i=0; i<DEVICE_COUNT_RESOURCE; i++) | |
3713 | - { | |
3714 | - /* is this an IO range */ | |
3715 | - if( pci_resource_flags(pdev, i) & 0x01 ) { | |
3716 | - c->io_mem_addr = pci_resource_start(pdev, i); | |
3717 | - c->io_mem_length = pci_resource_end(pdev, i) - | |
3718 | - pci_resource_start(pdev, i) +1; | |
3719 | -#ifdef CCISS_DEBUG | |
3720 | - printk("IO value found base_addr[%d] %lx %lx\n", i, | |
3721 | - c->io_mem_addr, c->io_mem_length); | |
3722 | -#endif /* CCISS_DEBUG */ | |
3723 | - /* register the IO range */ | |
3724 | - if(!request_region( c->io_mem_addr, | |
3725 | - c->io_mem_length, "cciss")) | |
3726 | - { | |
3727 | - printk(KERN_WARNING "cciss I/O memory range already in use addr=%lx length=%ld\n", | |
3728 | - c->io_mem_addr, c->io_mem_length); | |
3729 | - c->io_mem_addr= 0; | |
3730 | - c->io_mem_length = 0; | |
3731 | - } | |
3732 | - break; | |
3733 | - } | |
3734 | - } | |
3735 | - | |
3736 | #ifdef CCISS_DEBUG | |
3737 | printk("command = %x\n", command); | |
3738 | printk("irq = %x\n", pdev->irq); | |
3739 | @@ -2817,11 +3608,11 @@ | |
3740 | #ifdef CCISS_DEBUG | |
3741 | printk("address 0 = %x\n", c->paddr); | |
3742 | #endif /* CCISS_DEBUG */ | |
3743 | - c->vaddr = remap_pci_mem(c->paddr, 200); | |
3744 | + c->vaddr = remap_pci_mem(c->paddr, 0x250); | |
3745 | ||
3746 | /* Wait for the board to become ready. (PCI hotplug needs this.) | |
3747 | * We poll for up to 120 secs, once per 100ms. */ | |
3748 | - for (i=0; i < 1200; i++) { | |
3749 | + for (i = 0; i < 1200; i++) { | |
3750 | scratchpad = readl(c->vaddr + SA5_SCRATCHPAD_OFFSET); | |
3751 | if (scratchpad == CCISS_FIRMWARE_READY) | |
3752 | break; | |
3753 | @@ -2830,7 +3621,8 @@ | |
3754 | } | |
3755 | if (scratchpad != CCISS_FIRMWARE_READY) { | |
3756 | printk(KERN_WARNING "cciss: Board not ready. Timed out.\n"); | |
3757 | - return -1; | |
3758 | + err = -ENODEV; | |
3759 | + goto err_out_free_res; | |
3760 | } | |
3761 | ||
3762 | /* get the address index number */ | |
3763 | @@ -2839,15 +3631,14 @@ | |
3764 | #ifdef CCISS_DEBUG | |
3765 | printk("cfg base address = %x\n", cfg_base_addr); | |
3766 | #endif /* CCISS_DEBUG */ | |
3767 | - cfg_base_addr_index = | |
3768 | - find_PCI_BAR_index(pdev, cfg_base_addr); | |
3769 | + cfg_base_addr_index = find_PCI_BAR_index(pdev, cfg_base_addr); | |
3770 | #ifdef CCISS_DEBUG | |
3771 | printk("cfg base address index = %x\n", cfg_base_addr_index); | |
3772 | #endif /* CCISS_DEBUG */ | |
3773 | if (cfg_base_addr_index == -1) { | |
3774 | printk(KERN_WARNING "cciss: Cannot find cfg_base_addr_index\n"); | |
3775 | - release_io_mem(c); | |
3776 | - return -1; | |
3777 | + err = -ENODEV; | |
3778 | + goto err_out_free_res; | |
3779 | } | |
3780 | ||
3781 | cfg_offset = readl(c->vaddr + SA5_CTMEM_OFFSET); | |
3782 | @@ -2863,19 +3654,14 @@ | |
3783 | print_cfg_table(c->cfgtable); | |
3784 | #endif /* CCISS_DEBUG */ | |
3785 | ||
3786 | - for(i=0; i<NR_PRODUCTS; i++) { | |
3787 | + for (i = 0; i < ARRAY_SIZE(products); i++) { | |
3788 | if (board_id == products[i].board_id) { | |
3789 | c->product_name = products[i].product_name; | |
3790 | c->access = *(products[i].access); | |
3791 | + c->nr_cmds = products[i].nr_cmds; | |
3792 | break; | |
3793 | } | |
3794 | } | |
3795 | - if (i == NR_PRODUCTS) { | |
3796 | - printk(KERN_WARNING "cciss: Sorry, I don't know how" | |
3797 | - " to access the Smart Array controller %08lx\n", | |
3798 | - (unsigned long)board_id); | |
3799 | - return -1; | |
3800 | - } | |
3801 | if ( (readb(&c->cfgtable->Signature[0]) != 'C') || | |
3802 | (readb(&c->cfgtable->Signature[1]) != 'I') || | |
3803 | (readb(&c->cfgtable->Signature[2]) != 'S') || | |
3804 | @@ -2885,6 +3671,27 @@ | |
3805 | return -1; | |
3806 | } | |
3807 | ||
3808 | + /* We didn't find the controller in our list. We know the | |
3809 | + * signature is valid. If it's an HP device let's try to | |
3810 | + * bind to the device and fire it up. Otherwise we bail. | |
3811 | + */ | |
3812 | + if (i == ARRAY_SIZE(products)) { | |
3813 | + if (subsystem_vendor_id == PCI_VENDOR_ID_HP) { | |
3814 | + c->product_name = products[ARRAY_SIZE(products)-1].product_name; | |
3815 | + c->access = *(products[ARRAY_SIZE(products)-1].access); | |
3816 | + c->nr_cmds = products[ARRAY_SIZE(products)-1].nr_cmds; | |
3817 | + printk(KERN_WARNING "cciss: This is an unknown " | |
3818 | + "Smart Array controller.\n" | |
3819 | + "cciss: Please update to the latest driver " | |
3820 | + "available from www.hp.com.\n"); | |
3821 | + } else { | |
3822 | + printk(KERN_WARNING "cciss: Sorry, I don't know how" | |
3823 | + " to access the Smart Array controller %08lx\n" | |
3824 | + , (unsigned long)board_id); | |
3825 | + return -1; | |
3826 | + } | |
3827 | + } | |
3828 | + | |
3829 | #ifdef CONFIG_X86 | |
3830 | { | |
3831 | /* Need to enable prefetch in the SCSI core for 6400 in x86 */ | |
3832 | @@ -2895,6 +3702,28 @@ | |
3833 | } | |
3834 | #endif | |
3835 | ||
3836 | + /* Disabling DMA prefetch for the P600 | |
3837 | + * An ASIC bug may result in a prefetch beyond | |
3838 | + * physical memory. | |
3839 | + */ | |
3840 | + if(board_id == 0x3225103C) { | |
3841 | + __u32 dma_prefetch; | |
3842 | + dma_prefetch = readl(c->vaddr + I2O_DMA1_CFG); | |
3843 | + dma_prefetch |= 0x8000; | |
3844 | + writel(dma_prefetch, c->vaddr + I2O_DMA1_CFG); | |
3845 | +#ifdef __ia64__ | |
3846 | + /* On HP Integrity platforms, turn off DMA refetch | |
3847 | + * as well. | |
3848 | + */ | |
3849 | + { | |
3850 | + __u32 dma_refetch; | |
3851 | + pci_read_config_dword(pdev, PCI_COMMAND_PARITY, &dma_refetch); | |
3852 | + dma_refetch |= 0x1; | |
3853 | + pci_write_config_dword(pdev, PCI_COMMAND_PARITY, dma_refetch); | |
3854 | + } | |
3855 | +#endif | |
3856 | + } | |
3857 | + | |
3858 | #ifdef CCISS_DEBUG | |
3859 | printk("Trying to put board into Simple mode\n"); | |
3860 | #endif /* CCISS_DEBUG */ | |
3861 | @@ -2907,7 +3736,7 @@ | |
3862 | /* under certain very rare conditions, this can take awhile. | |
3863 | * (e.g.: hot replace a failed 144GB drive in a RAID 5 set right | |
3864 | * as we enter this code.) */ | |
3865 | - for(i=0;i<MAX_CONFIG_WAIT;i++) { | |
3866 | + for (i = 0; i < MAX_CONFIG_WAIT; i++) { | |
3867 | if (!(readl(c->vaddr + SA5_DOORBELL) & CFGTBL_ChangeReq)) | |
3868 | break; | |
3869 | /* delay and try again */ | |
3870 | @@ -2922,14 +3751,20 @@ | |
3871 | print_cfg_table(c->cfgtable); | |
3872 | #endif /* CCISS_DEBUG */ | |
3873 | ||
3874 | - if (!(readl(&(c->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) | |
3875 | - { | |
3876 | + if (!(readl(&(c->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) { | |
3877 | printk(KERN_WARNING "cciss: unable to get board into" | |
3878 | " simple mode\n"); | |
3879 | - return -1; | |
3880 | + err = -ENODEV; | |
3881 | + goto err_out_free_res; | |
3882 | } | |
3883 | return 0; | |
3884 | ||
3885 | +err_out_free_res: | |
3886 | + pci_release_regions(pdev); | |
3887 | + | |
3888 | +err_out_disable_pdev: | |
3889 | + pci_disable_device(pdev); | |
3890 | + return err; | |
3891 | } | |
3892 | ||
3893 | /* | |
3894 | @@ -2938,48 +3773,34 @@ | |
3895 | static void cciss_getgeometry(int cntl_num) | |
3896 | { | |
3897 | ReportLunData_struct *ld_buff; | |
3898 | - ReadCapdata_struct *size_buff; | |
3899 | InquiryData_struct *inq_buff; | |
3900 | int return_code; | |
3901 | int i; | |
3902 | int listlength = 0; | |
3903 | __u32 lunid = 0; | |
3904 | int block_size; | |
3905 | - int total_size; | |
3906 | + sector_t total_size; | |
3907 | ||
3908 | - ld_buff = kmalloc(sizeof(ReportLunData_struct), GFP_KERNEL); | |
3909 | - if (ld_buff == NULL) | |
3910 | - { | |
3911 | + ld_buff = kzalloc(sizeof(ReportLunData_struct), GFP_KERNEL); | |
3912 | + if (ld_buff == NULL) { | |
3913 | printk(KERN_ERR "cciss: out of memory\n"); | |
3914 | return; | |
3915 | } | |
3916 | - memset(ld_buff, 0, sizeof(ReportLunData_struct)); | |
3917 | - size_buff = kmalloc(sizeof( ReadCapdata_struct), GFP_KERNEL); | |
3918 | - if (size_buff == NULL) | |
3919 | - { | |
3920 | - printk(KERN_ERR "cciss: out of memory\n"); | |
3921 | - kfree(ld_buff); | |
3922 | - return; | |
3923 | - } | |
3924 | - inq_buff = kmalloc(sizeof( InquiryData_struct), GFP_KERNEL); | |
3925 | - if (inq_buff == NULL) | |
3926 | - { | |
3927 | + inq_buff = kmalloc(sizeof(InquiryData_struct), GFP_KERNEL); | |
3928 | + if (inq_buff == NULL) { | |
3929 | printk(KERN_ERR "cciss: out of memory\n"); | |
3930 | kfree(ld_buff); | |
3931 | - kfree(size_buff); | |
3932 | return; | |
3933 | } | |
3934 | /* Get the firmware version */ | |
3935 | return_code = sendcmd(CISS_INQUIRY, cntl_num, inq_buff, | |
3936 | sizeof(InquiryData_struct), 0, 0 ,0, NULL, TYPE_CMD); | |
3937 | - if (return_code == IO_OK) | |
3938 | - { | |
3939 | + if (return_code == IO_OK) { | |
3940 | hba[cntl_num]->firm_ver[0] = inq_buff->data_byte[32]; | |
3941 | hba[cntl_num]->firm_ver[1] = inq_buff->data_byte[33]; | |
3942 | hba[cntl_num]->firm_ver[2] = inq_buff->data_byte[34]; | |
3943 | hba[cntl_num]->firm_ver[3] = inq_buff->data_byte[35]; | |
3944 | - } else /* send command failed */ | |
3945 | - { | |
3946 | + } else { /* send command failed */ | |
3947 | printk(KERN_WARNING "cciss: unable to determine firmware" | |
3948 | " version of controller\n"); | |
3949 | } | |
3950 | @@ -2987,8 +3808,7 @@ | |
3951 | return_code = sendcmd(CISS_REPORT_LOG, cntl_num, ld_buff, | |
3952 | sizeof(ReportLunData_struct), 0, 0, 0, NULL, TYPE_CMD); | |
3953 | ||
3954 | - if( return_code == IO_OK) | |
3955 | - { | |
3956 | + if (return_code == IO_OK) { | |
3957 | #ifdef CCISS_DEBUG | |
3958 | printk("LUN Data\n--------------------------\n"); | |
3959 | #endif /* CCISS_DEBUG */ | |
3960 | @@ -2997,15 +3817,14 @@ | |
3961 | listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[1])) << 16; | |
3962 | listlength |= (0xff & (unsigned int)(ld_buff->LUNListLength[2])) << 8; | |
3963 | listlength |= 0xff & (unsigned int)(ld_buff->LUNListLength[3]); | |
3964 | - } else /* reading number of logical volumes failed */ | |
3965 | - { | |
3966 | + } else { | |
3967 | + /* reading number of logical volumes failed */ | |
3968 | printk(KERN_WARNING "cciss: report logical volume" | |
3969 | " command failed\n"); | |
3970 | listlength = 0; | |
3971 | } | |
3972 | - hba[cntl_num]->num_luns = listlength / 8; // 8 bytes pre entry | |
3973 | - if (hba[cntl_num]->num_luns > CISS_MAX_LUN) | |
3974 | - { | |
3975 | + hba[cntl_num]->num_luns = listlength / 8; // 8 bytes per entry | |
3976 | + if (hba[cntl_num]->num_luns > CISS_MAX_LUN) { | |
3977 | printk(KERN_ERR "ciss: only %d number of logical volumes supported\n", | |
3978 | CISS_MAX_LUN); | |
3979 | hba[cntl_num]->num_luns = CISS_MAX_LUN; | |
3980 | @@ -3016,11 +3835,9 @@ | |
3981 | ld_buff->LUNListLength[3], hba[cntl_num]->num_luns); | |
3982 | #endif /* CCISS_DEBUG */ | |
3983 | ||
3984 | - hba[cntl_num]->highest_lun = hba[cntl_num]->num_luns-1; | |
3985 | -// for(i=0; i< hba[cntl_num]->num_luns; i++) | |
3986 | - for(i=0; i < CISS_MAX_LUN; i++) | |
3987 | - { | |
3988 | - if (i < hba[cntl_num]->num_luns){ | |
3989 | + hba[cntl_num]->highest_lun = hba[cntl_num]->num_luns - 1; | |
3990 | + for (i = 0; i < CISS_MAX_LUN; i++) { | |
3991 | + if (i < hba[cntl_num]->num_luns) { | |
3992 | lunid = (0xff & (unsigned int)(ld_buff->LUN[i][3])) | |
3993 | << 24; | |
3994 | lunid |= (0xff & (unsigned int)(ld_buff->LUN[i][2])) | |
3995 | @@ -3031,15 +3848,33 @@ | |
3996 | ||
3997 | hba[cntl_num]->drv[i].LunID = lunid; | |
3998 | ||
3999 | - | |
4000 | #ifdef CCISS_DEBUG | |
4001 | printk(KERN_DEBUG "LUN[%d]: %x %x %x %x = %x\n", i, | |
4002 | ld_buff->LUN[i][0], ld_buff->LUN[i][1], | |
4003 | ld_buff->LUN[i][2], ld_buff->LUN[i][3], | |
4004 | hba[cntl_num]->drv[i].LunID); | |
4005 | #endif /* CCISS_DEBUG */ | |
4006 | - cciss_read_capacity(cntl_num, i, size_buff, 0, | |
4007 | - &total_size, &block_size); | |
4008 | + | |
4009 | + /* testing to see if 16-byte CDBs are already being used */ | |
4010 | + if(hba[cntl_num]->cciss_read == CCISS_READ_16) { | |
4011 | + cciss_read_capacity_16(cntl_num, i, 0, | |
4012 | + &total_size, &block_size); | |
4013 | + goto geo_inq; | |
4014 | + } | |
4015 | + cciss_read_capacity(cntl_num, i, 0, &total_size, &block_size); | |
4016 | + | |
4017 | + /* If read_capacity returns all F's the volume is >2TB */ | |
4018 | + /* so we switch to 16-byte CDBs for all read/write ops */ | |
4019 | + if(total_size == 0xFFFFFFFFULL) { | |
4020 | + cciss_read_capacity_16(cntl_num, i, 0, | |
4021 | + &total_size, &block_size); | |
4022 | + hba[cntl_num]->cciss_read = CCISS_READ_16; | |
4023 | + hba[cntl_num]->cciss_write = CCISS_WRITE_16; | |
4024 | + } else { | |
4025 | + hba[cntl_num]->cciss_read = CCISS_READ_10; | |
4026 | + hba[cntl_num]->cciss_write = CCISS_WRITE_10; | |
4027 | + } | |
4028 | +geo_inq: | |
4029 | cciss_geometry_inquiry(cntl_num, i, 0, total_size, | |
4030 | block_size, inq_buff, &hba[cntl_num]->drv[i]); | |
4031 | } else { | |
4032 | @@ -3048,7 +3883,6 @@ | |
4033 | } | |
4034 | } | |
4035 | kfree(ld_buff); | |
4036 | - kfree(size_buff); | |
4037 | kfree(inq_buff); | |
4038 | } | |
4039 | ||
4040 | @@ -3056,35 +3890,29 @@ | |
4041 | /* Returns -1 if no free entries are left. */ | |
4042 | static int alloc_cciss_hba(void) | |
4043 | { | |
4044 | - struct gendisk *disk[NWD]; | |
4045 | - int i, n; | |
4046 | - for (n = 0; n < NWD; n++) { | |
4047 | - disk[n] = alloc_disk(1 << NWD_SHIFT); | |
4048 | - if (!disk[n]) | |
4049 | - goto out; | |
4050 | - } | |
4051 | + int i; | |
4052 | ||
4053 | - for(i=0; i< MAX_CTLR; i++) { | |
4054 | + for (i = 0; i < MAX_CTLR; i++) { | |
4055 | if (!hba[i]) { | |
4056 | ctlr_info_t *p; | |
4057 | p = kmalloc(sizeof(ctlr_info_t), GFP_KERNEL); | |
4058 | if (!p) | |
4059 | goto Enomem; | |
4060 | memset(p, 0, sizeof(ctlr_info_t)); | |
4061 | - for (n = 0; n < NWD; n++) | |
4062 | - p->gendisk[n] = disk[n]; | |
4063 | + p->gendisk[0] = alloc_disk(1 << NWD_SHIFT); | |
4064 | + if (!p->gendisk[0]) { | |
4065 | + kfree(p); | |
4066 | + goto Enomem; | |
4067 | + } | |
4068 | hba[i] = p; | |
4069 | return i; | |
4070 | } | |
4071 | } | |
4072 | printk(KERN_WARNING "cciss: This driver supports a maximum" | |
4073 | " of %d controllers.\n", MAX_CTLR); | |
4074 | - goto out; | |
4075 | + return -1; | |
4076 | Enomem: | |
4077 | printk(KERN_ERR "cciss: out of memory.\n"); | |
4078 | -out: | |
4079 | - while (n--) | |
4080 | - put_disk(disk[n]); | |
4081 | return -1; | |
4082 | } | |
4083 | ||
4084 | @@ -3094,7 +3922,7 @@ | |
4085 | int n; | |
4086 | ||
4087 | hba[i] = NULL; | |
4088 | - for (n = 0; n < NWD; n++) | |
4089 | + for (n = 0; n < CISS_MAX_LUN; n++) | |
4090 | put_disk(p->gendisk[n]); | |
4091 | kfree(p); | |
4092 | } | |
4093 | @@ -3107,18 +3935,19 @@ | |
4094 | static int __devinit cciss_init_one(struct pci_dev *pdev, | |
4095 | const struct pci_device_id *ent) | |
4096 | { | |
4097 | - request_queue_t *q; | |
4098 | - int i; | |
4099 | - int j; | |
4100 | + int i, k; | |
4101 | + int j = 0; | |
4102 | int rc; | |
4103 | + int dac; | |
4104 | + InquiryData_struct *inq_buff; | |
4105 | ||
4106 | printk(KERN_DEBUG "cciss: Device 0x%x has been found at" | |
4107 | " bus %d dev %d func %d\n", | |
4108 | pdev->device, pdev->bus->number, PCI_SLOT(pdev->devfn), | |
4109 | PCI_FUNC(pdev->devfn)); | |
4110 | i = alloc_cciss_hba(); | |
4111 | - if(i < 0) | |
4112 | - return (-1); | |
4113 | + if (i < 0) | |
4114 | + return -1; | |
4115 | ||
4116 | hba[i]->busy_initializing = 1; | |
4117 | ||
4118 | @@ -3131,11 +3960,11 @@ | |
4119 | ||
4120 | /* configure PCI DMA stuff */ | |
4121 | if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) | |
4122 | - printk("cciss: using DAC cycles\n"); | |
4123 | + dac = 1; | |
4124 | else if (!pci_set_dma_mask(pdev, DMA_32BIT_MASK)) | |
4125 | - printk("cciss: not using DAC cycles\n"); | |
4126 | + dac = 0; | |
4127 | else { | |
4128 | - printk("cciss: no suitable DMA available\n"); | |
4129 | + printk(KERN_ERR "cciss: no suitable DMA available\n"); | |
4130 | goto clean1; | |
4131 | } | |
4132 | ||
4133 | @@ -3147,45 +3976,62 @@ | |
4134 | if (i < MAX_CTLR_ORIG) | |
4135 | hba[i]->major = COMPAQ_CISS_MAJOR + i; | |
4136 | rc = register_blkdev(hba[i]->major, hba[i]->devname); | |
4137 | - if(rc == -EBUSY || rc == -EINVAL) { | |
4138 | + if (rc == -EBUSY || rc == -EINVAL) { | |
4139 | printk(KERN_ERR | |
4140 | "cciss: Unable to get major number %d for %s " | |
4141 | "on hba %d\n", hba[i]->major, hba[i]->devname, i); | |
4142 | goto clean1; | |
4143 | - } | |
4144 | - else { | |
4145 | + } else { | |
4146 | if (i >= MAX_CTLR_ORIG) | |
4147 | hba[i]->major = rc; | |
4148 | } | |
4149 | ||
4150 | /* make sure the board interrupts are off */ | |
4151 | hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_OFF); | |
4152 | - if( request_irq(hba[i]->intr[SIMPLE_MODE_INT], do_cciss_intr, | |
4153 | - SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM, | |
4154 | + /* If we are running in IO-APIC or MSI mode we register only | |
4155 | + * one interrupt. If we're running MSI-X mode we must register | |
4156 | + * four interrupts because the hardware ORing is ignored. | |
4157 | + */ | |
4158 | + if (hba[i]->msix_vector) { | |
4159 | + for (k = 0; k < 4; k++) { | |
4160 | + if (request_irq(hba[i]->intr[k], do_cciss_intr, | |
4161 | + SA_INTERRUPT | SA_SAMPLE_RANDOM, | |
4162 | + hba[i]->devname, hba[i])) { | |
4163 | + printk(KERN_ERR "cciss: Unable to get msi irq %d" | |
4164 | + " for %s\n", | |
4165 | + hba[i]->intr[k], hba[i]->devname); | |
4166 | + goto clean2; | |
4167 | + } | |
4168 | + } | |
4169 | + } else { | |
4170 | + if (request_irq(hba[i]->intr[SIMPLE_MODE_INT], do_cciss_intr, | |
4171 | + SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM, | |
4172 | hba[i]->devname, hba[i])) { | |
4173 | - printk(KERN_ERR "cciss: Unable to get irq %d for %s\n", | |
4174 | - hba[i]->intr[SIMPLE_MODE_INT], hba[i]->devname); | |
4175 | - goto clean2; | |
4176 | + printk(KERN_ERR "cciss: Unable to get irq %d for %s\n", | |
4177 | + hba[i]->intr[SIMPLE_MODE_INT], hba[i]->devname); | |
4178 | + goto clean2; | |
4179 | + } | |
4180 | } | |
4181 | - hba[i]->cmd_pool_bits = kmalloc(((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long), GFP_KERNEL); | |
4182 | + | |
4183 | + hba[i]->cmd_pool_bits = kmalloc(((hba[i]->nr_cmds+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long), GFP_KERNEL); | |
4184 | hba[i]->cmd_pool = (CommandList_struct *)pci_alloc_consistent( | |
4185 | - hba[i]->pdev, NR_CMDS * sizeof(CommandList_struct), | |
4186 | + hba[i]->pdev, hba[i]->nr_cmds * sizeof(CommandList_struct), | |
4187 | &(hba[i]->cmd_pool_dhandle)); | |
4188 | hba[i]->errinfo_pool = (ErrorInfo_struct *)pci_alloc_consistent( | |
4189 | - hba[i]->pdev, NR_CMDS * sizeof( ErrorInfo_struct), | |
4190 | + hba[i]->pdev, hba[i]->nr_cmds * sizeof( ErrorInfo_struct), | |
4191 | &(hba[i]->errinfo_pool_dhandle)); | |
4192 | - if((hba[i]->cmd_pool_bits == NULL) | |
4193 | + if ((hba[i]->cmd_pool_bits == NULL) | |
4194 | || (hba[i]->cmd_pool == NULL) | |
4195 | || (hba[i]->errinfo_pool == NULL)) { | |
4196 | - printk( KERN_ERR "cciss: out of memory"); | |
4197 | + printk(KERN_ERR "cciss: out of memory"); | |
4198 | goto clean4; | |
4199 | } | |
4200 | #ifdef CONFIG_CISS_SCSI_TAPE | |
4201 | hba[i]->scsi_rejects.complete = | |
4202 | kmalloc(sizeof(hba[i]->scsi_rejects.complete[0]) * | |
4203 | - (NR_CMDS + 5), GFP_KERNEL); | |
4204 | + (hba[i]->nr_cmds + 5), GFP_KERNEL); | |
4205 | if (hba[i]->scsi_rejects.complete == NULL) { | |
4206 | - printk( KERN_ERR "cciss: out of memory"); | |
4207 | + printk(KERN_ERR "cciss: out of memory"); | |
4208 | goto clean4; | |
4209 | } | |
4210 | #endif | |
4211 | @@ -3196,10 +4042,10 @@ | |
4212 | pci_set_drvdata(pdev, hba[i]); | |
4213 | /* command and error info recs zeroed out before | |
4214 | they are used */ | |
4215 | - memset(hba[i]->cmd_pool_bits, 0, ((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long)); | |
4216 | + memset(hba[i]->cmd_pool_bits, 0, ((hba[i]->nr_cmds+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long)); | |
4217 | ||
4218 | #ifdef CCISS_DEBUG | |
4219 | - printk(KERN_DEBUG "Scanning for drives on controller cciss%d\n",i); | |
4220 | + printk(KERN_DEBUG "Scanning for drives on controller cciss%d\n", i); | |
4221 | #endif /* CCISS_DEBUG */ | |
4222 | ||
4223 | cciss_getgeometry(i); | |
4224 | @@ -3210,22 +4056,35 @@ | |
4225 | hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_ON); | |
4226 | ||
4227 | cciss_procinit(i); | |
4228 | + hba[i]->cciss_sector_size = 2048; | |
4229 | + | |
4230 | hba[i]->busy_initializing = 0; | |
4231 | ||
4232 | - for(j=0; j < NWD; j++) { /* mfm */ | |
4233 | + do { | |
4234 | drive_info_struct *drv = &(hba[i]->drv[j]); | |
4235 | struct gendisk *disk = hba[i]->gendisk[j]; | |
4236 | + request_queue_t *q; | |
4237 | + | |
4238 | + /* Check if the disk was allocated already */ | |
4239 | + if (!disk) { | |
4240 | + hba[i]->gendisk[j] = alloc_disk(1 << NWD_SHIFT); | |
4241 | + disk = hba[i]->gendisk[j]; | |
4242 | + } | |
4243 | + | |
4244 | + /* Check that the disk was able to be allocated */ | |
4245 | + if (!disk) { | |
4246 | + printk(KERN_ERR "cciss: unable to allocate memory for disk %d\n", j); | |
4247 | + goto clean4; | |
4248 | + } | |
4249 | ||
4250 | q = blk_init_queue(do_cciss_request, &hba[i]->lock); | |
4251 | if (!q) { | |
4252 | printk(KERN_ERR | |
4253 | "cciss: unable to allocate queue for disk %d\n", | |
4254 | j); | |
4255 | - break; | |
4256 | + goto clean4; | |
4257 | } | |
4258 | - drv->queue = q; | |
4259 | ||
4260 | - q->backing_dev_info.ra_pages = READ_AHEAD; | |
4261 | blk_queue_bounce_limit(q, hba[i]->pdev->dma_mask); | |
4262 | ||
4263 | /* This is a hardware imposed limit. */ | |
4264 | @@ -3234,130 +4093,181 @@ | |
4265 | /* This is a limit in the driver and could be eliminated. */ | |
4266 | blk_queue_max_phys_segments(q, MAXSGENTRIES); | |
4267 | ||
4268 | - blk_queue_max_sectors(q, 512); | |
4269 | + blk_queue_max_sectors(q, hba[i]->cciss_sector_size); | |
4270 | ||
4271 | blk_queue_softirq_done(q, cciss_softirq_done); | |
4272 | ||
4273 | q->queuedata = hba[i]; | |
4274 | - sprintf(disk->disk_name, "cciss/c%dd%d", i, j); | |
4275 | - sprintf(disk->devfs_name, "cciss/host%d/target%d", i, j); | |
4276 | - disk->major = hba[i]->major; | |
4277 | - disk->first_minor = j << NWD_SHIFT; | |
4278 | - disk->fops = &cciss_fops; | |
4279 | - disk->queue = q; | |
4280 | - disk->private_data = drv; | |
4281 | /* we must register the controller even if no disks exist */ | |
4282 | /* this is for the online array utilities */ | |
4283 | - if(!drv->heads && j) | |
4284 | + if (!drv->heads && j) | |
4285 | continue; | |
4286 | blk_queue_hardsect_size(q, drv->block_size); | |
4287 | + cciss_sysfs_stat_inquiry(i, j, 1, drv); | |
4288 | + cciss_add_blk_sysfs_dev(drv, disk, pdev, j); | |
4289 | set_capacity(disk, drv->nr_blocks); | |
4290 | + sprintf(disk->disk_name, "cciss/c%dd%d", i, j); | |
4291 | + disk->major = hba[i]->major; | |
4292 | + disk->first_minor = j << NWD_SHIFT; | |
4293 | + disk->fops = &cciss_fops; | |
4294 | + disk->private_data = drv; | |
4295 | + disk->queue = q; | |
4296 | + drv->queue = q; | |
4297 | add_disk(disk); | |
4298 | - } | |
4299 | + j++; | |
4300 | + } while (j <= hba[i]->highest_lun); | |
4301 | ||
4302 | - return(1); | |
4303 | + return 1; | |
4304 | ||
4305 | clean4: | |
4306 | #ifdef CONFIG_CISS_SCSI_TAPE | |
4307 | - if(hba[i]->scsi_rejects.complete) | |
4308 | - kfree(hba[i]->scsi_rejects.complete); | |
4309 | + kfree(hba[i]->scsi_rejects.complete); | |
4310 | #endif | |
4311 | kfree(hba[i]->cmd_pool_bits); | |
4312 | - if(hba[i]->cmd_pool) | |
4313 | + if (hba[i]->cmd_pool) | |
4314 | pci_free_consistent(hba[i]->pdev, | |
4315 | - NR_CMDS * sizeof(CommandList_struct), | |
4316 | + hba[i]->nr_cmds * sizeof(CommandList_struct), | |
4317 | hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); | |
4318 | - if(hba[i]->errinfo_pool) | |
4319 | + if (hba[i]->errinfo_pool) | |
4320 | pci_free_consistent(hba[i]->pdev, | |
4321 | - NR_CMDS * sizeof( ErrorInfo_struct), | |
4322 | + hba[i]->nr_cmds * sizeof( ErrorInfo_struct), | |
4323 | hba[i]->errinfo_pool, | |
4324 | hba[i]->errinfo_pool_dhandle); | |
4325 | - free_irq(hba[i]->intr[SIMPLE_MODE_INT], hba[i]); | |
4326 | + if (hba[i]->msix_vector) { | |
4327 | + for (j = 0; j < 4; j++) | |
4328 | + free_irq(hba[i]->intr[j], hba[i]); | |
4329 | + } else { | |
4330 | + free_irq(hba[i]->intr[SIMPLE_MODE_INT], hba[i]); | |
4331 | + } | |
4332 | +#ifdef CONFIG_PCI_MSI | |
4333 | + if (hba[i]->msix_vector) | |
4334 | + pci_disable_msix(hba[i]->pdev); | |
4335 | + else if (hba[i]->msi_vector) | |
4336 | + pci_disable_msi(hba[i]->pdev); | |
4337 | +#endif /* CONFIG_PCI_MSI */ | |
4338 | clean2: | |
4339 | unregister_blkdev(hba[i]->major, hba[i]->devname); | |
4340 | clean1: | |
4341 | - release_io_mem(hba[i]); | |
4342 | hba[i]->busy_initializing = 0; | |
4343 | + /* cleanup any queues that may have been initialized */ | |
4344 | + for (j = 0; j <= hba[i]->highest_lun; j++){ | |
4345 | + drive_info_struct *drv = &(hba[i]->drv[j]); | |
4346 | + if (drv->queue) | |
4347 | + blk_cleanup_queue(drv->queue); | |
4348 | + } | |
4349 | + pci_release_regions(pdev); | |
4350 | + /* This call to pci_disable_device causes the driver to be unable | |
4351 | + * to load/unload multiple times. No reason why yet, but we are | |
4352 | + * leaving it out for now. | |
4353 | + */ | |
4354 | +// pci_disable_device(pdev); | |
4355 | + pci_set_drvdata(pdev, NULL); | |
4356 | free_hba(i); | |
4357 | - return(-1); | |
4358 | + return -1; | |
4359 | } | |
4360 | ||
4361 | -static void __devexit cciss_remove_one (struct pci_dev *pdev) | |
4362 | +static void cciss_shutdown (struct pci_dev *pdev) | |
4363 | { | |
4364 | ctlr_info_t *tmp_ptr; | |
4365 | int i, j; | |
4366 | char flush_buf[4]; | |
4367 | int return_code; | |
4368 | ||
4369 | - if (pci_get_drvdata(pdev) == NULL) | |
4370 | - { | |
4371 | - printk( KERN_ERR "cciss: Unable to remove device \n"); | |
4372 | - return; | |
4373 | - } | |
4374 | tmp_ptr = pci_get_drvdata(pdev); | |
4375 | + if (tmp_ptr == NULL) | |
4376 | + return; | |
4377 | i = tmp_ptr->ctlr; | |
4378 | - if (hba[i] == NULL) | |
4379 | - { | |
4380 | - printk(KERN_ERR "cciss: device appears to " | |
4381 | - "already be removed \n"); | |
4382 | + if (hba[i] == NULL) | |
4383 | return; | |
4384 | - } | |
4385 | + | |
4386 | /* Turn board interrupts off and send the flush cache command */ | |
4387 | /* sendcmd will turn off interrupt, and send the flush... | |
4388 | * To write all data in the battery backed cache to disks */ | |
4389 | memset(flush_buf, 0, 4); | |
4390 | return_code = sendcmd(CCISS_CACHE_FLUSH, i, flush_buf, 4, 0, 0, 0, NULL, | |
4391 | TYPE_CMD); | |
4392 | - if(return_code != IO_OK) | |
4393 | - { | |
4394 | + if(return_code != IO_OK) { | |
4395 | printk(KERN_WARNING "Error Flushing cache on controller %d\n", | |
4396 | i); | |
4397 | } | |
4398 | - free_irq(hba[i]->intr[2], hba[i]); | |
4399 | + if (hba[i]->msix_vector) { | |
4400 | + for (j = 0; j < 4; j++) | |
4401 | + free_irq(hba[i]->intr[j], hba[i]); | |
4402 | + } else { | |
4403 | + free_irq(hba[i]->intr[SIMPLE_MODE_INT], hba[i]); | |
4404 | + } | |
4405 | +} | |
4406 | ||
4407 | -#ifdef CONFIG_PCI_MSI | |
4408 | - if (hba[i]->msix_vector) | |
4409 | - pci_disable_msix(hba[i]->pdev); | |
4410 | - else if (hba[i]->msi_vector) | |
4411 | - pci_disable_msi(hba[i]->pdev); | |
4412 | -#endif /* CONFIG_PCI_MSI */ | |
4413 | +static void __devexit cciss_remove_one(struct pci_dev *pdev) | |
4414 | +{ | |
4415 | + ctlr_info_t *tmp_ptr; | |
4416 | + int i, j; | |
4417 | ||
4418 | - pci_set_drvdata(pdev, NULL); | |
4419 | - iounmap(hba[i]->vaddr); | |
4420 | - cciss_unregister_scsi(i); /* unhook from SCSI subsystem */ | |
4421 | + if (pci_get_drvdata(pdev) == NULL) { | |
4422 | + printk(KERN_ERR "cciss: Unable to remove device \n"); | |
4423 | + return; | |
4424 | + } | |
4425 | + tmp_ptr = pci_get_drvdata(pdev); | |
4426 | + i = tmp_ptr->ctlr; | |
4427 | + if (hba[i] == NULL) { | |
4428 | + printk(KERN_ERR "cciss: device appears to " | |
4429 | + "already be removed \n"); | |
4430 | + return; | |
4431 | + } | |
4432 | + | |
4433 | + remove_proc_entry(hba[i]->devname, proc_cciss); | |
4434 | unregister_blkdev(hba[i]->major, hba[i]->devname); | |
4435 | - remove_proc_entry(hba[i]->devname, proc_cciss); | |
4436 | - | |
4437 | + | |
4438 | /* remove it from the disk list */ | |
4439 | - for (j = 0; j < NWD; j++) { | |
4440 | + for (j = 0; j < CISS_MAX_LUN; j++) { | |
4441 | struct gendisk *disk = hba[i]->gendisk[j]; | |
4442 | if (disk) { | |
4443 | request_queue_t *q = disk->queue; | |
4444 | ||
4445 | - if (disk->flags & GENHD_FL_UP) | |
4446 | + if (disk->flags & GENHD_FL_UP) | |
4447 | + cciss_remove_blk_sysfs_dev(disk); | |
4448 | del_gendisk(disk); | |
4449 | if (q) | |
4450 | blk_cleanup_queue(q); | |
4451 | } | |
4452 | } | |
4453 | ||
4454 | - pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(CommandList_struct), | |
4455 | + cciss_unregister_scsi(i); /* unhook from SCSI subsystem */ | |
4456 | + | |
4457 | + cciss_shutdown(pdev); | |
4458 | + | |
4459 | +#ifdef CONFIG_PCI_MSI | |
4460 | + if (hba[i]->msix_vector) | |
4461 | + pci_disable_msix(hba[i]->pdev); | |
4462 | + else if (hba[i]->msi_vector) | |
4463 | + pci_disable_msi(hba[i]->pdev); | |
4464 | +#endif /* CONFIG_PCI_MSI */ | |
4465 | + | |
4466 | + iounmap(hba[i]->vaddr); | |
4467 | + | |
4468 | + pci_free_consistent(hba[i]->pdev, hba[i]->nr_cmds * sizeof(CommandList_struct), | |
4469 | hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); | |
4470 | - pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof( ErrorInfo_struct), | |
4471 | - hba[i]->errinfo_pool, hba[i]->errinfo_pool_dhandle); | |
4472 | + pci_free_consistent(hba[i]->pdev, hba[i]->nr_cmds * sizeof(ErrorInfo_struct), | |
4473 | + hba[i]->errinfo_pool, hba[i]->errinfo_pool_dhandle); | |
4474 | kfree(hba[i]->cmd_pool_bits); | |
4475 | #ifdef CONFIG_CISS_SCSI_TAPE | |
4476 | kfree(hba[i]->scsi_rejects.complete); | |
4477 | #endif | |
4478 | - release_io_mem(hba[i]); | |
4479 | + /* | |
4480 | + * Deliberately omit pci_disable_device(): it does something nasty to | |
4481 | + * Smart Array controllers that pci_enable_device does not undo | |
4482 | + */ | |
4483 | + pci_release_regions(pdev); | |
4484 | + pci_set_drvdata(pdev, NULL); | |
4485 | free_hba(i); | |
4486 | -} | |
4487 | +} | |
4488 | ||
4489 | static struct pci_driver cciss_pci_driver = { | |
4490 | - .name = "cciss", | |
4491 | - .probe = cciss_init_one, | |
4492 | - .remove = __devexit_p(cciss_remove_one), | |
4493 | - .id_table = cciss_pci_device_id, /* id_table */ | |
4494 | + .name = "cciss", | |
4495 | + .probe = cciss_init_one, | |
4496 | + .remove = __devexit_p(cciss_remove_one), | |
4497 | + .id_table = cciss_pci_device_id, /* id_table */ | |
4498 | + .shutdown = cciss_shutdown, | |
4499 | }; | |
4500 | ||
4501 | /* | |
4502 | @@ -3378,10 +4288,8 @@ | |
4503 | ||
4504 | pci_unregister_driver(&cciss_pci_driver); | |
4505 | /* double check that all controller entrys have been removed */ | |
4506 | - for (i=0; i< MAX_CTLR; i++) | |
4507 | - { | |
4508 | - if (hba[i] != NULL) | |
4509 | - { | |
4510 | + for (i = 0; i < MAX_CTLR; i++) { | |
4511 | + if (hba[i] != NULL) { | |
4512 | printk(KERN_WARNING "cciss: had to remove" | |
4513 | " controller %d\n", i); | |
4514 | cciss_remove_one(hba[i]->pdev); | |
4515 | @@ -3405,14 +4313,14 @@ | |
4516 | pci_disable_device(h->pdev); /* Make sure it is really dead. */ | |
4517 | ||
4518 | /* move everything off the request queue onto the completed queue */ | |
4519 | - while( (c = h->reqQ) != NULL ) { | |
4520 | + while ((c = h->reqQ) != NULL) { | |
4521 | removeQ(&(h->reqQ), c); | |
4522 | h->Qdepth--; | |
4523 | - addQ (&(h->cmpQ), c); | |
4524 | + addQ(&(h->cmpQ), c); | |
4525 | } | |
4526 | ||
4527 | /* Now, fail everything on the completed queue with a HW error */ | |
4528 | - while( (c = h->cmpQ) != NULL ) { | |
4529 | + while ((c = h->cmpQ) != NULL) { | |
4530 | removeQ(&h->cmpQ, c); | |
4531 | c->err_info->CommandStatus = CMD_HARDWARE_ERR; | |
4532 | if (c->cmd_type == CMD_RWREQ) { | |
4533 | diff -uNr linux-2.6.16.orig/drivers/block/cciss_cmd.h linux-2.6.16/drivers/block/cciss_cmd.h | |
4534 | --- linux-2.6.16.orig/drivers/block/cciss_cmd.h 2006-03-20 06:53:29.000000000 +0100 | |
4535 | +++ linux-2.6.16/drivers/block/cciss_cmd.h 2008-10-03 02:40:19.000000000 +0200 | |
4536 | @@ -8,7 +8,7 @@ | |
4537 | //general boundary defintions | |
4538 | #define SENSEINFOBYTES 32//note that this value may vary between host implementations | |
4539 | #define MAXSGENTRIES 31 | |
4540 | -#define MAXREPLYQS 256 | |
4541 | +#define MAXREPLYQS 1024 | |
4542 | ||
4543 | //Command Status value | |
4544 | #define CMD_SUCCESS 0x0000 | |
4545 | @@ -24,6 +24,7 @@ | |
4546 | #define CMD_UNSOLICITED_ABORT 0x000A | |
4547 | #define CMD_TIMEOUT 0x000B | |
4548 | #define CMD_UNABORTABLE 0x000C | |
4549 | +#define CMD_RESERVATION_CONFLICT 0x0018 | |
4550 | ||
4551 | //transfer direction | |
4552 | #define XFER_NONE 0x00 | |
4553 | @@ -55,6 +56,7 @@ | |
4554 | #define I2O_INT_MASK 0x34 | |
4555 | #define I2O_IBPOST_Q 0x40 | |
4556 | #define I2O_OBPOST_Q 0x44 | |
4557 | +#define I2O_DMA1_CFG 0x214 | |
4558 | ||
4559 | //Configuration Table | |
4560 | #define CFGTBL_ChangeReq 0x00000001l | |
4561 | @@ -88,7 +90,7 @@ | |
4562 | //########################################################################### | |
4563 | //STRUCTURES | |
4564 | //########################################################################### | |
4565 | -#define CISS_MAX_LUN 16 | |
4566 | +#define CISS_MAX_LUN 1024 | |
4567 | #define CISS_MAX_PHYS_LUN 1024 | |
4568 | // SCSI-3 Cmmands | |
4569 | ||
4570 | @@ -118,11 +120,34 @@ | |
4571 | BYTE block_size[4]; // Size of blocks in bytes | |
4572 | } ReadCapdata_struct; | |
4573 | ||
4574 | -// 12 byte commands not implemented in firmware yet. | |
4575 | -// #define CCISS_READ 0xa8 // Read(12) | |
4576 | -// #define CCISS_WRITE 0xaa // Write(12) | |
4577 | - #define CCISS_READ 0x28 // Read(10) | |
4578 | - #define CCISS_WRITE 0x2a // Write(10) | |
4579 | +#define CCISS_READ_CAPACITY_16 0x9e /* Read Capacity 16 */ | |
4580 | + | |
4581 | +/* service action to differentiate a 16 byte read capacity from | |
4582 | + other commands that use the 0x9e SCSI op code */ | |
4583 | + | |
4584 | +#define CCISS_READ_CAPACITY_16_SERVICE_ACT 0x10 | |
4585 | + | |
4586 | +typedef struct _ReadCapdata_struct_16 | |
4587 | +{ | |
4588 | + BYTE total_size[8]; /* Total size in blocks */ | |
4589 | + BYTE block_size[4]; /* Size of blocks in bytes */ | |
4590 | + BYTE prot_en:1; /* protection enable bit */ | |
4591 | + BYTE rto_en:1; /* reference tag own enable bit */ | |
4592 | + BYTE reserved:6; /* reserved bits */ | |
4593 | + BYTE reserved2[18]; /* reserved bytes per spec */ | |
4594 | +} ReadCapdata_struct_16; | |
4595 | + | |
4596 | +/* Define the supported read/write commands for cciss based controllers */ | |
4597 | + | |
4598 | +#define CCISS_READ_10 0x28 /* Read(10) */ | |
4599 | +#define CCISS_WRITE_10 0x2a /* Write(10) */ | |
4600 | +#define CCISS_READ_16 0x88 /* Read(16) */ | |
4601 | +#define CCISS_WRITE_16 0x8a /* Write(16) */ | |
4602 | + | |
4603 | +/* Define the CDB lengths supported by cciss based controllers */ | |
4604 | + | |
4605 | +#define CDB_LEN10 10 | |
4606 | +#define CDB_LEN16 16 | |
4607 | ||
4608 | // BMIC commands | |
4609 | #define BMIC_READ 0x26 | |
4610 | diff -uNr linux-2.6.16.orig/drivers/block/cciss.h linux-2.6.16/drivers/block/cciss.h | |
4611 | --- linux-2.6.16.orig/drivers/block/cciss.h 2006-03-20 06:53:29.000000000 +0100 | |
4612 | +++ linux-2.6.16/drivers/block/cciss.h 2008-10-03 02:40:19.000000000 +0200 | |
4613 | @@ -6,7 +6,6 @@ | |
4614 | #include "cciss_cmd.h" | |
4615 | ||
4616 | ||
4617 | -#define NWD 16 | |
4618 | #define NWD_SHIFT 4 | |
4619 | #define MAX_PART (1 << NWD_SHIFT) | |
4620 | ||
4621 | @@ -37,16 +36,21 @@ | |
4622 | * the drive is not in use/configured | |
4623 | */ | |
4624 | int busy_configuring; /*This is set when the drive is being removed | |
4625 | - *to prevent it from being opened or it's queue | |
4626 | - *from being started. | |
4627 | + *to prevent it from being opened or it's | |
4628 | + *queue from being started. | |
4629 | */ | |
4630 | + char vendor[9]; | |
4631 | + char model[17]; | |
4632 | + char rev[5]; | |
4633 | + BYTE uid[16]; | |
4634 | + struct device *dev_info; | |
4635 | } drive_info_struct; | |
4636 | ||
4637 | #ifdef CONFIG_CISS_SCSI_TAPE | |
4638 | ||
4639 | struct sendcmd_reject_list { | |
4640 | int ncompletions; | |
4641 | - unsigned long *complete; /* array of NR_CMDS tags */ | |
4642 | + unsigned long *complete; /* array of tags */ | |
4643 | }; | |
4644 | ||
4645 | #endif | |
4646 | @@ -60,8 +64,7 @@ | |
4647 | __u32 board_id; | |
4648 | void __iomem *vaddr; | |
4649 | unsigned long paddr; | |
4650 | - unsigned long io_mem_addr; | |
4651 | - unsigned long io_mem_length; | |
4652 | + int nr_cmds; /* Number of commands allowed on this controller */ | |
4653 | CfgTable_struct __iomem *cfgtable; | |
4654 | int interrupts_enabled; | |
4655 | int major; | |
4656 | @@ -78,6 +81,10 @@ | |
4657 | unsigned int intr[4]; | |
4658 | unsigned int msix_vector; | |
4659 | unsigned int msi_vector; | |
4660 | + int cciss_sector_size; /* For setting blk_queue_max_sectors */ | |
4661 | + BYTE cciss_read; | |
4662 | + BYTE cciss_write; | |
4663 | + BYTE cciss_read_capacity; | |
4664 | ||
4665 | // information about each logical volume | |
4666 | drive_info_struct drv[CISS_MAX_LUN]; | |
4667 | @@ -109,7 +116,7 @@ | |
4668 | int next_to_run; | |
4669 | ||
4670 | // Disk structures we need to pass back | |
4671 | - struct gendisk *gendisk[NWD]; | |
4672 | + struct gendisk *gendisk[CISS_MAX_LUN]; | |
4673 | #ifdef CONFIG_CISS_SCSI_TAPE | |
4674 | void *scsi_ctlr; /* ptr to structure containing scsi related stuff */ | |
4675 | /* list of block side commands the scsi error handling sucked up */ | |
4676 | @@ -144,6 +151,17 @@ | |
4677 | ||
4678 | #define CCISS_INTR_ON 1 | |
4679 | #define CCISS_INTR_OFF 0 | |
4680 | + | |
4681 | +static inline ctlr_info_t *get_host(struct gendisk *disk) | |
4682 | +{ | |
4683 | + return disk->queue->queuedata; | |
4684 | +} | |
4685 | + | |
4686 | +static inline drive_info_struct *get_drv(struct gendisk *disk) | |
4687 | +{ | |
4688 | + return disk->private_data; | |
4689 | +} | |
4690 | + | |
4691 | /* | |
4692 | Send the command to the hardware | |
4693 | */ | |
4694 | @@ -281,9 +299,21 @@ | |
4695 | __u32 board_id; | |
4696 | char *product_name; | |
4697 | struct access_method *access; | |
4698 | + int nr_cmds; /* Max cmds to send to this kind of ctlr. */ | |
4699 | +}; | |
4700 | + | |
4701 | +struct drv_dynamic { | |
4702 | + struct device dev; /* should be the first member */ | |
4703 | + struct gendisk *disk; | |
4704 | }; | |
4705 | ||
4706 | #define CCISS_LOCK(i) (&hba[i]->lock) | |
4707 | ||
4708 | +#ifdef DECLARE_COMPLETION_ONSTACK | |
4709 | +#define CCISS_DECLARE_COMPLETION(work) DECLARE_COMPLETION_ONSTACK(work) | |
4710 | +#else | |
4711 | +#define CCISS_DECLARE_COMPLETION(work) DECLARE_COMPLETION(work) | |
4712 | +#endif | |
4713 | + | |
4714 | #endif /* CCISS_H */ | |
4715 | ||
4716 | diff -uNr linux-2.6.16.orig/drivers/block/cciss_scsi.c linux-2.6.16/drivers/block/cciss_scsi.c | |
4717 | --- linux-2.6.16.orig/drivers/block/cciss_scsi.c 2006-03-20 06:53:29.000000000 +0100 | |
4718 | +++ linux-2.6.16/drivers/block/cciss_scsi.c 2008-10-03 02:40:19.000000000 +0200 | |
4719 | @@ -35,12 +35,12 @@ | |
4720 | ||
4721 | #include <asm/atomic.h> | |
4722 | ||
4723 | -#include <scsi/scsi.h> | |
4724 | #include <scsi/scsi_cmnd.h> | |
4725 | #include <scsi/scsi_device.h> | |
4726 | #include <scsi/scsi_host.h> | |
4727 | ||
4728 | #include "cciss_scsi.h" | |
4729 | +#include "cciss.h" | |
4730 | ||
4731 | #define CCISS_ABORT_MSG 0x00 | |
4732 | #define CCISS_RESET_MSG 0x01 | |
4733 | @@ -255,7 +255,6 @@ | |
4734 | #define DEVICETYPE(n) (n<0 || n>MAX_SCSI_DEVICE_CODE) ? \ | |
4735 | "Unknown" : scsi_device_types[n] | |
4736 | ||
4737 | -#if 0 | |
4738 | static int xmargin=8; | |
4739 | static int amargin=60; | |
4740 | ||
4741 | @@ -293,6 +292,7 @@ | |
4742 | } | |
4743 | } | |
4744 | ||
4745 | + | |
4746 | static void | |
4747 | print_cmd(CommandList_struct *cp) | |
4748 | { | |
4749 | @@ -329,18 +329,21 @@ | |
4750 | cp->ErrDesc.Addr.upper, cp->ErrDesc.Addr.lower, | |
4751 | cp->ErrDesc.Len); | |
4752 | printk("sgs..........Errorinfo:\n"); | |
4753 | - printk("scsistatus:%d\n", cp->err_info->ScsiStatus); | |
4754 | - printk("senselen:%d\n", cp->err_info->SenseLen); | |
4755 | - printk("cmd status:%d\n", cp->err_info->CommandStatus); | |
4756 | - printk("resid cnt:%d\n", cp->err_info->ResidualCnt); | |
4757 | - printk("offense size:%d\n", cp->err_info->MoreErrInfo.Invalid_Cmd.offense_size); | |
4758 | - printk("offense byte:%d\n", cp->err_info->MoreErrInfo.Invalid_Cmd.offense_num); | |
4759 | - printk("offense value:%d\n", cp->err_info->MoreErrInfo.Invalid_Cmd.offense_value); | |
4760 | + printk("scsistatus: 0x%x\n", cp->err_info->ScsiStatus); | |
4761 | + printk("senselen: 0x%x\n", cp->err_info->SenseLen); | |
4762 | + printk("cmd status: 0x%x\n", cp->err_info->CommandStatus); | |
4763 | + printk("resid cnt: 0x%x\n", cp->err_info->ResidualCnt); | |
4764 | + | |
4765 | + /* If this is a check condition print the SenseInfo */ | |
4766 | + if ((cp->err_info->SenseInfo[2] & 0x0F) == 0x02) | |
4767 | + print_bytes(cp->err_info->SenseInfo, cp->err_info->SenseLen, 1, 0); | |
4768 | + | |
4769 | + printk("offense size: 0x%x\n", cp->err_info->MoreErrInfo.Invalid_Cmd.offense_size); | |
4770 | + printk("offense byte: 0x%x\n", cp->err_info->MoreErrInfo.Invalid_Cmd.offense_num); | |
4771 | + printk("offense value: 0x%x\n", cp->err_info->MoreErrInfo.Invalid_Cmd.offense_value); | |
4772 | ||
4773 | } | |
4774 | ||
4775 | -#endif | |
4776 | - | |
4777 | static int | |
4778 | find_bus_target_lun(int ctlr, int *bus, int *target, int *lun) | |
4779 | { | |
4780 | @@ -578,7 +581,7 @@ | |
4781 | ||
4782 | if (cmd->use_sg) { | |
4783 | pci_unmap_sg(ctlr->pdev, | |
4784 | - cmd->buffer, cmd->use_sg, | |
4785 | + cmd->request_buffer, cmd->use_sg, | |
4786 | cmd->sc_data_direction); | |
4787 | } | |
4788 | else if (cmd->request_bufflen) { | |
4789 | @@ -652,6 +655,7 @@ | |
4790 | } | |
4791 | break; | |
4792 | case CMD_PROTOCOL_ERR: | |
4793 | + cmd->result = DID_ERROR << 16; | |
4794 | printk(KERN_WARNING "cciss: cp %p has " | |
4795 | "protocol error \n", cp); | |
4796 | break; | |
4797 | @@ -770,7 +774,7 @@ | |
4798 | int direction) | |
4799 | { | |
4800 | unsigned long flags; | |
4801 | - DECLARE_COMPLETION(wait); | |
4802 | + CCISS_DECLARE_COMPLETION(wait); | |
4803 | ||
4804 | cp->cmd_type = CMD_IOCTL_PEND; // treat this like an ioctl | |
4805 | cp->scsi_cmd = NULL; | |
4806 | @@ -1211,7 +1215,7 @@ | |
4807 | struct scsi_cmnd *cmd) | |
4808 | { | |
4809 | unsigned int use_sg, nsegs=0, len; | |
4810 | - struct scatterlist *scatter = (struct scatterlist *) cmd->buffer; | |
4811 | + struct scatterlist *scatter = (struct scatterlist *) cmd->request_buffer; | |
4812 | __u64 addr64; | |
4813 | ||
4814 | /* is it just one virtual address? */ | |
4815 | @@ -1233,7 +1237,7 @@ | |
4816 | } /* else, must be a list of virtual addresses.... */ | |
4817 | else if (cmd->use_sg <= MAXSGENTRIES) { /* not too many addrs? */ | |
4818 | ||
4819 | - use_sg = pci_map_sg(pdev, cmd->buffer, cmd->use_sg, | |
4820 | + use_sg = pci_map_sg(pdev, cmd->request_buffer, cmd->use_sg, | |
4821 | cmd->sc_data_direction); | |
4822 | ||
4823 | for (nsegs=0; nsegs < use_sg; nsegs++) { | |
4824 | @@ -1441,21 +1445,18 @@ | |
4825 | } | |
4826 | ||
4827 | static void | |
4828 | -cciss_proc_tape_report(int ctlr, unsigned char *buffer, off_t *pos, off_t *len) | |
4829 | +cciss_seq_tape_report(struct seq_file *seq, int ctlr) | |
4830 | { | |
4831 | unsigned long flags; | |
4832 | - int size; | |
4833 | - | |
4834 | - *pos = *pos -1; *len = *len - 1; // cut off the last trailing newline | |
4835 | ||
4836 | CPQ_TAPE_LOCK(ctlr, flags); | |
4837 | - size = sprintf(buffer + *len, | |
4838 | + seq_printf(seq, | |
4839 | "Sequential access devices: %d\n\n", | |
4840 | ccissscsi[ctlr].ndevices); | |
4841 | CPQ_TAPE_UNLOCK(ctlr, flags); | |
4842 | - *pos += size; *len += size; | |
4843 | } | |
4844 | ||
4845 | + | |
4846 | /* Need at least one of these error handlers to keep ../scsi/hosts.c from | |
4847 | * complaining. Doing a host- or bus-reset can't do anything good here. | |
4848 | * Despite what it might say in scsi_error.c, there may well be commands | |
4849 | @@ -1535,6 +1536,5 @@ | |
4850 | #define cciss_scsi_setup(cntl_num) | |
4851 | #define cciss_unregister_scsi(ctlr) | |
4852 | #define cciss_register_scsi(ctlr) | |
4853 | -#define cciss_proc_tape_report(ctlr, buffer, pos, len) | |
4854 | ||
4855 | #endif /* CONFIG_CISS_SCSI_TAPE */ | |
4856 | diff -uNr linux-2.6.16.orig/include/linux/cciss_ioctl.h linux-2.6.16/include/linux/cciss_ioctl.h | |
4857 | --- linux-2.6.16.orig/include/linux/cciss_ioctl.h 2006-03-20 06:53:29.000000000 +0100 | |
4858 | +++ linux-2.6.16/include/linux/cciss_ioctl.h 2008-10-03 02:40:19.000000000 +0200 | |
4859 | @@ -11,7 +11,7 @@ | |
4860 | { | |
4861 | unsigned char bus; | |
4862 | unsigned char dev_fn; | |
4863 | - unsigned short domain; | |
4864 | + __u16 domain; | |
4865 | __u32 board_id; | |
4866 | } cciss_pci_info_struct; | |
4867 | ||
4868 | @@ -80,7 +80,7 @@ | |
4869 | #define HWORD __u16 | |
4870 | #define DWORD __u32 | |
4871 | ||
4872 | -#define CISS_MAX_LUN 16 | |
4873 | +#define CISS_MAX_LUN 256 | |
4874 | ||
4875 | #define LEVEL2LUN 1 // index into Target(x) structure, due to byte swapping | |
4876 | #define LEVEL3LUN 0 |