aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/mtip32xx
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2011-09-27 23:27:43 -0400
committerJens Axboe <axboe@kernel.dk>2011-11-05 03:35:10 -0400
commit6316668fbcf8a0a166830e7e84cdbdf0ab9392c8 (patch)
tree7d18003afb0e1be5c9029c277c7fccb1202e5d30 /drivers/block/mtip32xx
parentef0f1587343a4c17b9b0d9061546e36c1c1bb2ec (diff)
mtip32xx: ensure that all local functions are static
Kill the declarations in the header file and mark them as static. Reshuffle a few functions to ensure that everything is properly declared before being used. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/mtip32xx')
-rw-r--r--drivers/block/mtip32xx/mtip32xx.c632
-rw-r--r--drivers/block/mtip32xx/mtip32xx.h33
2 files changed, 313 insertions, 352 deletions
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index d58581b83c8d..40d840e56256 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -108,6 +108,72 @@ static int mtip_exec_internal_command(struct mtip_port *port,
108 unsigned long timeout); 108 unsigned long timeout);
109 109
110/* 110/*
111 * This function check_for_surprise_removal is called
112 * while card is removed from the system and it will
113 * read the vendor id from the configration space
114 *
115 * @pdev Pointer to the pci_dev structure.
116 *
117 * return value
118 * true if device removed, else false
119 */
120static bool mtip_check_surprise_removal(struct pci_dev *pdev)
121{
122 u16 vendor_id = 0;
123
124 /* Read the vendorID from the configuration space */
125 pci_read_config_word(pdev, 0x00, &vendor_id);
126 if (vendor_id == 0xFFFF)
127 return true; /* device removed */
128
129 return false; /* device present */
130}
131
132/*
133 * This function is called for clean the pending command in the
134 * command slot during the surprise removal of device and return
135 * error to the upper layer.
136 *
137 * @dd Pointer to the DRIVER_DATA structure.
138 *
139 * return value
140 * None
141 */
142static void mtip_command_cleanup(struct driver_data *dd)
143{
144 int group = 0, commandslot = 0, commandindex = 0;
145 struct mtip_cmd *command;
146 struct mtip_port *port = dd->port;
147
148 for (group = 0; group < 4; group++) {
149 for (commandslot = 0; commandslot < 32; commandslot++) {
150 if (!(port->allocated[group] & (1 << commandslot)))
151 continue;
152
153 commandindex = group << 5 | commandslot;
154 command = &port->commands[commandindex];
155
156 if (atomic_read(&command->active)
157 && (command->async_callback)) {
158 command->async_callback(command->async_data,
159 -ENODEV);
160 command->async_callback = NULL;
161 command->async_data = NULL;
162 }
163
164 dma_unmap_sg(&port->dd->pdev->dev,
165 command->sg,
166 command->scatter_ents,
167 command->direction);
168 }
169 }
170
171 up(&port->cmd_slot);
172
173 atomic_set(&dd->drv_cleanup_done, true);
174}
175
176/*
111 * Obtain an empty command slot. 177 * Obtain an empty command slot.
112 * 178 *
113 * This function needs to be reentrant since it could be called 179 * This function needs to be reentrant since it could be called
@@ -167,214 +233,72 @@ static inline void release_slot(struct mtip_port *port, int tag)
167} 233}
168 234
169/* 235/*
170 * Issue a command to the hardware. 236 * Reset the HBA (without sleeping)
171 *
172 * Set the appropriate bit in the s_active and Command Issue hardware
173 * registers, causing hardware command processing to begin.
174 *
175 * @port Pointer to the port structure.
176 * @tag The tag of the command to be issued.
177 * 237 *
178 * return value 238 * Just like hba_reset, except does not call sleep, so can be
179 * None 239 * run from interrupt/tasklet context.
180 */
181static inline void mtip_issue_ncq_command(struct mtip_port *port, int tag)
182{
183 unsigned long flags = 0;
184
185 atomic_set(&port->commands[tag].active, 1);
186
187 spin_lock_irqsave(&port->cmd_issue_lock, flags);
188
189 writel((1 << MTIP_TAG_BIT(tag)),
190 port->s_active[MTIP_TAG_INDEX(tag)]);
191 writel((1 << MTIP_TAG_BIT(tag)),
192 port->cmd_issue[MTIP_TAG_INDEX(tag)]);
193
194 spin_unlock_irqrestore(&port->cmd_issue_lock, flags);
195}
196
197/*
198 * Called periodically to see if any read/write commands are
199 * taking too long to complete.
200 * 240 *
201 * @data Pointer to the PORT data structure. 241 * @dd Pointer to the driver data structure.
202 * 242 *
203 * return value 243 * return value
204 * None 244 * 0 The reset was successful.
245 * -1 The HBA Reset bit did not clear.
205 */ 246 */
206void mtip_timeout_function(unsigned long int data) 247static int hba_reset_nosleep(struct driver_data *dd)
207{ 248{
208 struct mtip_port *port = (struct mtip_port *) data; 249 unsigned long timeout;
209 struct host_to_dev_fis *fis;
210 struct mtip_cmd *command;
211 int tag, cmdto_cnt = 0;
212 unsigned int bit, group;
213 unsigned int num_command_slots = port->dd->slot_groups * 32;
214
215 if (unlikely(!port))
216 return;
217
218 if (atomic_read(&port->dd->resumeflag) == true) {
219 mod_timer(&port->cmd_timer,
220 jiffies + msecs_to_jiffies(30000));
221 return;
222 }
223
224 for (tag = 0; tag < num_command_slots; tag++) {
225 /*
226 * Skip internal command slot as it has
227 * its own timeout mechanism
228 */
229 if (tag == MTIP_TAG_INTERNAL)
230 continue;
231
232 if (atomic_read(&port->commands[tag].active) &&
233 (time_after(jiffies, port->commands[tag].comp_time))) {
234 group = tag >> 5;
235 bit = tag & 0x1f;
236
237 command = &port->commands[tag];
238 fis = (struct host_to_dev_fis *) command->command;
239
240 dev_warn(&port->dd->pdev->dev,
241 "Timeout for command tag %d\n", tag);
242
243 cmdto_cnt++;
244 if (cmdto_cnt == 1)
245 atomic_inc(&port->dd->eh_active);
246
247 /*
248 * Clear the completed bit. This should prevent
249 * any interrupt handlers from trying to retire
250 * the command.
251 */
252 writel(1 << bit, port->completed[group]);
253 250
254 /* Call the async completion callback. */ 251 /* Chip quirk: quiesce any chip function */
255 if (likely(command->async_callback)) 252 mdelay(10);
256 command->async_callback(command->async_data,
257 -EIO);
258 command->async_callback = NULL;
259 command->comp_func = NULL;
260 253
261 /* Unmap the DMA scatter list entries */ 254 /* Set the reset bit */
262 dma_unmap_sg(&port->dd->pdev->dev, 255 writel(HOST_RESET, dd->mmio + HOST_CTL);
263 command->sg,
264 command->scatter_ents,
265 command->direction);
266 256
267 /* 257 /* Flush */
268 * Clear the allocated bit and active tag for the 258 readl(dd->mmio + HOST_CTL);
269 * command.
270 */
271 atomic_set(&port->commands[tag].active, 0);
272 release_slot(port, tag);
273 259
274 up(&port->cmd_slot); 260 /*
275 } 261 * Wait 10ms then spin for up to 1 second
276 } 262 * waiting for reset acknowledgement
263 */
264 timeout = jiffies + msecs_to_jiffies(1000);
265 mdelay(10);
266 while ((readl(dd->mmio + HOST_CTL) & HOST_RESET)
267 && time_before(jiffies, timeout))
268 mdelay(1);
277 269
278 if (cmdto_cnt) { 270 if (readl(dd->mmio + HOST_CTL) & HOST_RESET)
279 dev_warn(&port->dd->pdev->dev, 271 return -1;
280 "%d commands timed out: restarting port",
281 cmdto_cnt);
282 mtip_restart_port(port);
283 atomic_dec(&port->dd->eh_active);
284 }
285 272
286 /* Restart the timer */ 273 return 0;
287 mod_timer(&port->cmd_timer,
288 jiffies + msecs_to_jiffies(MTIP_TIMEOUT_CHECK_PERIOD));
289} 274}
290 275
291/* 276/*
292 * IO completion function. 277 * Issue a command to the hardware.
293 * 278 *
294 * This completion function is called by the driver ISR when a 279 * Set the appropriate bit in the s_active and Command Issue hardware
295 * command that was issued by the kernel completes. It first calls the 280 * registers, causing hardware command processing to begin.
296 * asynchronous completion function which normally calls back into the block
297 * layer passing the asynchronous callback data, then unmaps the
298 * scatter list associated with the completed command, and finally
299 * clears the allocated bit associated with the completed command.
300 * 281 *
301 * @port Pointer to the port data structure. 282 * @port Pointer to the port structure.
302 * @tag Tag of the command. 283 * @tag The tag of the command to be issued.
303 * @data Pointer to driver_data.
304 * @status Completion status.
305 * 284 *
306 * return value 285 * return value
307 * None 286 * None
308 */ 287 */
309static void mtip_async_complete(struct mtip_port *port, 288static inline void mtip_issue_ncq_command(struct mtip_port *port, int tag)
310 int tag,
311 void *data,
312 int status)
313{ 289{
314 struct mtip_cmd *command; 290 unsigned long flags = 0;
315 struct driver_data *dd = data;
316 int cb_status = status ? -EIO : 0;
317
318 if (unlikely(!dd) || unlikely(!port))
319 return;
320
321 command = &port->commands[tag];
322
323 if (unlikely(status == PORT_IRQ_TF_ERR)) {
324 dev_warn(&port->dd->pdev->dev,
325 "Command tag %d failed due to TFE\n", tag);
326 }
327
328 /* Upper layer callback */
329 if (likely(command->async_callback))
330 command->async_callback(command->async_data, cb_status);
331
332 command->async_callback = NULL;
333 command->comp_func = NULL;
334
335 /* Unmap the DMA scatter list entries */
336 dma_unmap_sg(&dd->pdev->dev,
337 command->sg,
338 command->scatter_ents,
339 command->direction);
340
341 /* Clear the allocated and active bits for the command */
342 atomic_set(&port->commands[tag].active, 0);
343 release_slot(port, tag);
344 291
345 up(&port->cmd_slot); 292 atomic_set(&port->commands[tag].active, 1);
346}
347 293
348/* 294 spin_lock_irqsave(&port->cmd_issue_lock, flags);
349 * Internal command completion callback function.
350 *
351 * This function is normally called by the driver ISR when an internal
352 * command completed. This function signals the command completion by
353 * calling complete().
354 *
355 * @port Pointer to the port data structure.
356 * @tag Tag of the command that has completed.
357 * @data Pointer to a completion structure.
358 * @status Completion status.
359 *
360 * return value
361 * None
362 */
363static void mtip_completion(struct mtip_port *port,
364 int tag,
365 void *data,
366 int status)
367{
368 struct mtip_cmd *command = &port->commands[tag];
369 struct completion *waiting = data;
370 if (unlikely(status == PORT_IRQ_TF_ERR))
371 dev_warn(&port->dd->pdev->dev,
372 "Internal command %d completed with TFE\n", tag);
373 295
374 command->async_callback = NULL; 296 writel((1 << MTIP_TAG_BIT(tag)),
375 command->comp_func = NULL; 297 port->s_active[MTIP_TAG_INDEX(tag)]);
298 writel((1 << MTIP_TAG_BIT(tag)),
299 port->cmd_issue[MTIP_TAG_INDEX(tag)]);
376 300
377 complete(waiting); 301 spin_unlock_irqrestore(&port->cmd_issue_lock, flags);
378} 302}
379 303
380/* 304/*
@@ -508,47 +432,6 @@ static void mtip_init_port(struct mtip_port *port)
508} 432}
509 433
510/* 434/*
511 * Reset the HBA (without sleeping)
512 *
513 * Just like hba_reset, except does not call sleep, so can be
514 * run from interrupt/tasklet context.
515 *
516 * @dd Pointer to the driver data structure.
517 *
518 * return value
519 * 0 The reset was successful.
520 * -1 The HBA Reset bit did not clear.
521 */
522int hba_reset_nosleep(struct driver_data *dd)
523{
524 unsigned long timeout;
525
526 /* Chip quirk: quiesce any chip function */
527 mdelay(10);
528
529 /* Set the reset bit */
530 writel(HOST_RESET, dd->mmio + HOST_CTL);
531
532 /* Flush */
533 readl(dd->mmio + HOST_CTL);
534
535 /*
536 * Wait 10ms then spin for up to 1 second
537 * waiting for reset acknowledgement
538 */
539 timeout = jiffies + msecs_to_jiffies(1000);
540 mdelay(10);
541 while ((readl(dd->mmio + HOST_CTL) & HOST_RESET)
542 && time_before(jiffies, timeout))
543 mdelay(1);
544
545 if (readl(dd->mmio + HOST_CTL) & HOST_RESET)
546 return -1;
547
548 return 0;
549}
550
551/*
552 * Restart a port 435 * Restart a port
553 * 436 *
554 * @port Pointer to the port data structure. 437 * @port Pointer to the port data structure.
@@ -556,7 +439,7 @@ int hba_reset_nosleep(struct driver_data *dd)
556 * return value 439 * return value
557 * None 440 * None
558 */ 441 */
559void mtip_restart_port(struct mtip_port *port) 442static void mtip_restart_port(struct mtip_port *port)
560{ 443{
561 unsigned long timeout; 444 unsigned long timeout;
562 445
@@ -620,6 +503,189 @@ void mtip_restart_port(struct mtip_port *port)
620} 503}
621 504
622/* 505/*
506 * Called periodically to see if any read/write commands are
507 * taking too long to complete.
508 *
509 * @data Pointer to the PORT data structure.
510 *
511 * return value
512 * None
513 */
514static void mtip_timeout_function(unsigned long int data)
515{
516 struct mtip_port *port = (struct mtip_port *) data;
517 struct host_to_dev_fis *fis;
518 struct mtip_cmd *command;
519 int tag, cmdto_cnt = 0;
520 unsigned int bit, group;
521 unsigned int num_command_slots = port->dd->slot_groups * 32;
522
523 if (unlikely(!port))
524 return;
525
526 if (atomic_read(&port->dd->resumeflag) == true) {
527 mod_timer(&port->cmd_timer,
528 jiffies + msecs_to_jiffies(30000));
529 return;
530 }
531
532 for (tag = 0; tag < num_command_slots; tag++) {
533 /*
534 * Skip internal command slot as it has
535 * its own timeout mechanism
536 */
537 if (tag == MTIP_TAG_INTERNAL)
538 continue;
539
540 if (atomic_read(&port->commands[tag].active) &&
541 (time_after(jiffies, port->commands[tag].comp_time))) {
542 group = tag >> 5;
543 bit = tag & 0x1f;
544
545 command = &port->commands[tag];
546 fis = (struct host_to_dev_fis *) command->command;
547
548 dev_warn(&port->dd->pdev->dev,
549 "Timeout for command tag %d\n", tag);
550
551 cmdto_cnt++;
552 if (cmdto_cnt == 1)
553 atomic_inc(&port->dd->eh_active);
554
555 /*
556 * Clear the completed bit. This should prevent
557 * any interrupt handlers from trying to retire
558 * the command.
559 */
560 writel(1 << bit, port->completed[group]);
561
562 /* Call the async completion callback. */
563 if (likely(command->async_callback))
564 command->async_callback(command->async_data,
565 -EIO);
566 command->async_callback = NULL;
567 command->comp_func = NULL;
568
569 /* Unmap the DMA scatter list entries */
570 dma_unmap_sg(&port->dd->pdev->dev,
571 command->sg,
572 command->scatter_ents,
573 command->direction);
574
575 /*
576 * Clear the allocated bit and active tag for the
577 * command.
578 */
579 atomic_set(&port->commands[tag].active, 0);
580 release_slot(port, tag);
581
582 up(&port->cmd_slot);
583 }
584 }
585
586 if (cmdto_cnt) {
587 dev_warn(&port->dd->pdev->dev,
588 "%d commands timed out: restarting port",
589 cmdto_cnt);
590 mtip_restart_port(port);
591 atomic_dec(&port->dd->eh_active);
592 }
593
594 /* Restart the timer */
595 mod_timer(&port->cmd_timer,
596 jiffies + msecs_to_jiffies(MTIP_TIMEOUT_CHECK_PERIOD));
597}
598
599/*
600 * IO completion function.
601 *
602 * This completion function is called by the driver ISR when a
603 * command that was issued by the kernel completes. It first calls the
604 * asynchronous completion function which normally calls back into the block
605 * layer passing the asynchronous callback data, then unmaps the
606 * scatter list associated with the completed command, and finally
607 * clears the allocated bit associated with the completed command.
608 *
609 * @port Pointer to the port data structure.
610 * @tag Tag of the command.
611 * @data Pointer to driver_data.
612 * @status Completion status.
613 *
614 * return value
615 * None
616 */
617static void mtip_async_complete(struct mtip_port *port,
618 int tag,
619 void *data,
620 int status)
621{
622 struct mtip_cmd *command;
623 struct driver_data *dd = data;
624 int cb_status = status ? -EIO : 0;
625
626 if (unlikely(!dd) || unlikely(!port))
627 return;
628
629 command = &port->commands[tag];
630
631 if (unlikely(status == PORT_IRQ_TF_ERR)) {
632 dev_warn(&port->dd->pdev->dev,
633 "Command tag %d failed due to TFE\n", tag);
634 }
635
636 /* Upper layer callback */
637 if (likely(command->async_callback))
638 command->async_callback(command->async_data, cb_status);
639
640 command->async_callback = NULL;
641 command->comp_func = NULL;
642
643 /* Unmap the DMA scatter list entries */
644 dma_unmap_sg(&dd->pdev->dev,
645 command->sg,
646 command->scatter_ents,
647 command->direction);
648
649 /* Clear the allocated and active bits for the command */
650 atomic_set(&port->commands[tag].active, 0);
651 release_slot(port, tag);
652
653 up(&port->cmd_slot);
654}
655
656/*
657 * Internal command completion callback function.
658 *
659 * This function is normally called by the driver ISR when an internal
660 * command completed. This function signals the command completion by
661 * calling complete().
662 *
663 * @port Pointer to the port data structure.
664 * @tag Tag of the command that has completed.
665 * @data Pointer to a completion structure.
666 * @status Completion status.
667 *
668 * return value
669 * None
670 */
671static void mtip_completion(struct mtip_port *port,
672 int tag,
673 void *data,
674 int status)
675{
676 struct mtip_cmd *command = &port->commands[tag];
677 struct completion *waiting = data;
678 if (unlikely(status == PORT_IRQ_TF_ERR))
679 dev_warn(&port->dd->pdev->dev,
680 "Internal command %d completed with TFE\n", tag);
681
682 command->async_callback = NULL;
683 command->comp_func = NULL;
684
685 complete(waiting);
686}
687
688/*
623 * Helper function for tag logging 689 * Helper function for tag logging
624 */ 690 */
625static void print_tags(struct driver_data *dd, 691static void print_tags(struct driver_data *dd,
@@ -1276,7 +1342,7 @@ static int mtip_standby_immediate(struct mtip_port *port)
1276 * 1 Capacity was returned successfully. 1342 * 1 Capacity was returned successfully.
1277 * 0 The identify information is invalid. 1343 * 0 The identify information is invalid.
1278 */ 1344 */
1279bool mtip_hw_get_capacity(struct driver_data *dd, sector_t *sectors) 1345static bool mtip_hw_get_capacity(struct driver_data *dd, sector_t *sectors)
1280{ 1346{
1281 struct mtip_port *port = dd->port; 1347 struct mtip_port *port = dd->port;
1282 u64 total, raw0, raw1, raw2, raw3; 1348 u64 total, raw0, raw1, raw2, raw3;
@@ -1423,7 +1489,7 @@ static inline void fill_command_sg(struct driver_data *dd,
1423 * return value 0 The command completed successfully. 1489 * return value 0 The command completed successfully.
1424 * return value -1 An error occurred while executing the command. 1490 * return value -1 An error occurred while executing the command.
1425 */ 1491 */
1426int exec_drive_task(struct mtip_port *port, u8 *command) 1492static int exec_drive_task(struct mtip_port *port, u8 *command)
1427{ 1493{
1428 struct host_to_dev_fis fis; 1494 struct host_to_dev_fis fis;
1429 struct host_to_dev_fis *reply = (port->rxfis + RX_FIS_D2H_REG); 1495 struct host_to_dev_fis *reply = (port->rxfis + RX_FIS_D2H_REG);
@@ -1499,8 +1565,8 @@ int exec_drive_task(struct mtip_port *port, u8 *command)
1499 * data to the user space buffer. 1565 * data to the user space buffer.
1500 * return value -1 An error occurred while executing the command. 1566 * return value -1 An error occurred while executing the command.
1501 */ 1567 */
1502int exec_drive_command(struct mtip_port *port, u8 *command, 1568static int exec_drive_command(struct mtip_port *port, u8 *command,
1503 void __user *user_buffer) 1569 void __user *user_buffer)
1504{ 1570{
1505 struct host_to_dev_fis fis; 1571 struct host_to_dev_fis fis;
1506 struct host_to_dev_fis *reply = (port->rxfis + RX_FIS_D2H_REG); 1572 struct host_to_dev_fis *reply = (port->rxfis + RX_FIS_D2H_REG);
@@ -2020,15 +2086,9 @@ static int mtip_hw_ioctl(struct driver_data *dd, unsigned int cmd,
2020 * return value 2086 * return value
2021 * None 2087 * None
2022 */ 2088 */
2023void mtip_hw_submit_io(struct driver_data *dd, 2089static void mtip_hw_submit_io(struct driver_data *dd, sector_t start,
2024 sector_t start, 2090 int nsect, int nents, int tag, void *callback,
2025 int nsect, 2091 void *data, int barrier, int dir)
2026 int nents,
2027 int tag,
2028 void *callback,
2029 void *data,
2030 int barrier,
2031 int dir)
2032{ 2092{
2033 struct host_to_dev_fis *fis; 2093 struct host_to_dev_fis *fis;
2034 struct mtip_port *port = dd->port; 2094 struct mtip_port *port = dd->port;
@@ -2115,7 +2175,7 @@ void mtip_hw_submit_io(struct driver_data *dd,
2115 * return value 2175 * return value
2116 * None 2176 * None
2117 */ 2177 */
2118void mtip_hw_release_scatterlist(struct driver_data *dd, int tag) 2178static void mtip_hw_release_scatterlist(struct driver_data *dd, int tag)
2119{ 2179{
2120 release_slot(dd->port, tag); 2180 release_slot(dd->port, tag);
2121} 2181}
@@ -2131,8 +2191,8 @@ void mtip_hw_release_scatterlist(struct driver_data *dd, int tag)
2131 * Pointer to the scatter list for the allocated command slot 2191 * Pointer to the scatter list for the allocated command slot
2132 * or NULL if no command slots are available. 2192 * or NULL if no command slots are available.
2133 */ 2193 */
2134struct scatterlist *mtip_hw_get_scatterlist(struct driver_data *dd, 2194static struct scatterlist *mtip_hw_get_scatterlist(struct driver_data *dd,
2135 int *tag) 2195 int *tag)
2136{ 2196{
2137 /* 2197 /*
2138 * It is possible that, even with this semaphore, a thread 2198 * It is possible that, even with this semaphore, a thread
@@ -2216,7 +2276,7 @@ static DEVICE_ATTR(registers, S_IRUGO, hw_show_registers, NULL);
2216 * 0 Operation completed successfully. 2276 * 0 Operation completed successfully.
2217 * -EINVAL Invalid parameter. 2277 * -EINVAL Invalid parameter.
2218 */ 2278 */
2219int mtip_hw_sysfs_init(struct driver_data *dd, struct kobject *kobj) 2279static int mtip_hw_sysfs_init(struct driver_data *dd, struct kobject *kobj)
2220{ 2280{
2221 if (!kobj || !dd) 2281 if (!kobj || !dd)
2222 return -EINVAL; 2282 return -EINVAL;
@@ -2237,7 +2297,7 @@ int mtip_hw_sysfs_init(struct driver_data *dd, struct kobject *kobj)
2237 * 0 Operation completed successfully. 2297 * 0 Operation completed successfully.
2238 * -EINVAL Invalid parameter. 2298 * -EINVAL Invalid parameter.
2239 */ 2299 */
2240int mtip_hw_sysfs_exit(struct driver_data *dd, struct kobject *kobj) 2300static int mtip_hw_sysfs_exit(struct driver_data *dd, struct kobject *kobj)
2241{ 2301{
2242 if (!kobj || !dd) 2302 if (!kobj || !dd)
2243 return -EINVAL; 2303 return -EINVAL;
@@ -2385,7 +2445,7 @@ static int mtip_ftl_rebuild_poll(struct driver_data *dd)
2385 * return value 2445 * return value
2386 * 0 on success, else an error code. 2446 * 0 on success, else an error code.
2387 */ 2447 */
2388int mtip_hw_init(struct driver_data *dd) 2448static int mtip_hw_init(struct driver_data *dd)
2389{ 2449{
2390 int i; 2450 int i;
2391 int rv; 2451 int rv;
@@ -2586,7 +2646,7 @@ out1:
2586 * return value 2646 * return value
2587 * 0 2647 * 0
2588 */ 2648 */
2589int mtip_hw_exit(struct driver_data *dd) 2649static int mtip_hw_exit(struct driver_data *dd)
2590{ 2650{
2591 /* 2651 /*
2592 * Send standby immediate (E0h) to the drive so that it 2652 * Send standby immediate (E0h) to the drive so that it
@@ -2634,7 +2694,7 @@ int mtip_hw_exit(struct driver_data *dd)
2634 * return value 2694 * return value
2635 * 0 2695 * 0
2636 */ 2696 */
2637int mtip_hw_shutdown(struct driver_data *dd) 2697static int mtip_hw_shutdown(struct driver_data *dd)
2638{ 2698{
2639 /* 2699 /*
2640 * Send standby immediate (E0h) to the drive so that it 2700 * Send standby immediate (E0h) to the drive so that it
@@ -2657,7 +2717,7 @@ int mtip_hw_shutdown(struct driver_data *dd)
2657 * 0 Suspend was successful 2717 * 0 Suspend was successful
2658 * -EFAULT Suspend was not successful 2718 * -EFAULT Suspend was not successful
2659 */ 2719 */
2660int mtip_hw_suspend(struct driver_data *dd) 2720static int mtip_hw_suspend(struct driver_data *dd)
2661{ 2721{
2662 /* 2722 /*
2663 * Send standby immediate (E0h) to the drive 2723 * Send standby immediate (E0h) to the drive
@@ -2689,7 +2749,7 @@ int mtip_hw_suspend(struct driver_data *dd)
2689 * 0 Resume was successful 2749 * 0 Resume was successful
2690 * -EFAULT Resume was not successful 2750 * -EFAULT Resume was not successful
2691 */ 2751 */
2692int mtip_hw_resume(struct driver_data *dd) 2752static int mtip_hw_resume(struct driver_data *dd)
2693{ 2753{
2694 /* Perform any needed hardware setup steps */ 2754 /* Perform any needed hardware setup steps */
2695 hba_setup(dd); 2755 hba_setup(dd);
@@ -2716,50 +2776,6 @@ int mtip_hw_resume(struct driver_data *dd)
2716} 2776}
2717 2777
2718/* 2778/*
2719 * This function is called for clean the pending command in the
2720 * command slot during the surprise removal of device and return
2721 * error to the upper layer.
2722 *
2723 * @dd Pointer to the DRIVER_DATA structure.
2724 *
2725 * return value
2726 * None
2727 */
2728void mtip_command_cleanup(struct driver_data *dd)
2729{
2730 int group = 0, commandslot = 0, commandindex = 0;
2731 struct mtip_cmd *command;
2732 struct mtip_port *port = dd->port;
2733
2734 for (group = 0; group < 4; group++) {
2735 for (commandslot = 0; commandslot < 32; commandslot++) {
2736 if (!(port->allocated[group] & (1 << commandslot)))
2737 continue;
2738
2739 commandindex = group << 5 | commandslot;
2740 command = &port->commands[commandindex];
2741
2742 if (atomic_read(&command->active)
2743 && (command->async_callback)) {
2744 command->async_callback(command->async_data,
2745 -ENODEV);
2746 command->async_callback = NULL;
2747 command->async_data = NULL;
2748 }
2749
2750 dma_unmap_sg(&port->dd->pdev->dev,
2751 command->sg,
2752 command->scatter_ents,
2753 command->direction);
2754 }
2755 }
2756
2757 up(&port->cmd_slot);
2758
2759 atomic_set(&dd->drv_cleanup_done, true);
2760}
2761
2762/*
2763 * Helper function for reusing disk name 2779 * Helper function for reusing disk name
2764 * upon hot insertion. 2780 * upon hot insertion.
2765 */ 2781 */
@@ -3037,7 +3053,7 @@ static int mtip_make_request(struct request_queue *queue, struct bio *bio)
3037 * return value 3053 * return value
3038 * 0 on success else an error code. 3054 * 0 on success else an error code.
3039 */ 3055 */
3040int mtip_block_initialize(struct driver_data *dd) 3056static int mtip_block_initialize(struct driver_data *dd)
3041{ 3057{
3042 int rv = 0; 3058 int rv = 0;
3043 sector_t capacity; 3059 sector_t capacity;
@@ -3168,7 +3184,7 @@ protocol_init_error:
3168 * return value 3184 * return value
3169 * 0 3185 * 0
3170 */ 3186 */
3171int mtip_block_remove(struct driver_data *dd) 3187static int mtip_block_remove(struct driver_data *dd)
3172{ 3188{
3173 struct kobject *kobj; 3189 struct kobject *kobj;
3174 /* Clean up the sysfs attributes managed by the protocol layer. */ 3190 /* Clean up the sysfs attributes managed by the protocol layer. */
@@ -3205,7 +3221,7 @@ int mtip_block_remove(struct driver_data *dd)
3205 * return value 3221 * return value
3206 * 0 3222 * 0
3207 */ 3223 */
3208int mtip_block_shutdown(struct driver_data *dd) 3224static int mtip_block_shutdown(struct driver_data *dd)
3209{ 3225{
3210 dev_info(&dd->pdev->dev, 3226 dev_info(&dd->pdev->dev,
3211 "Shutting down %s ...\n", dd->disk->disk_name); 3227 "Shutting down %s ...\n", dd->disk->disk_name);
@@ -3220,7 +3236,7 @@ int mtip_block_shutdown(struct driver_data *dd)
3220 return 0; 3236 return 0;
3221} 3237}
3222 3238
3223int mtip_block_suspend(struct driver_data *dd) 3239static int mtip_block_suspend(struct driver_data *dd)
3224{ 3240{
3225 dev_info(&dd->pdev->dev, 3241 dev_info(&dd->pdev->dev,
3226 "Suspending %s ...\n", dd->disk->disk_name); 3242 "Suspending %s ...\n", dd->disk->disk_name);
@@ -3228,7 +3244,7 @@ int mtip_block_suspend(struct driver_data *dd)
3228 return 0; 3244 return 0;
3229} 3245}
3230 3246
3231int mtip_block_resume(struct driver_data *dd) 3247static int mtip_block_resume(struct driver_data *dd)
3232{ 3248{
3233 dev_info(&dd->pdev->dev, "Resuming %s ...\n", 3249 dev_info(&dd->pdev->dev, "Resuming %s ...\n",
3234 dd->disk->disk_name); 3250 dd->disk->disk_name);
@@ -3479,28 +3495,6 @@ static void mtip_pci_shutdown(struct pci_dev *pdev)
3479 mtip_block_shutdown(dd); 3495 mtip_block_shutdown(dd);
3480} 3496}
3481 3497
3482/*
3483 * This function check_for_surprise_removal is called
3484 * while card is removed from the system and it will
3485 * read the vendor id from the configration space
3486 *
3487 * @pdev Pointer to the pci_dev structure.
3488 *
3489 * return value
3490 * true if device removed, else false
3491 */
3492bool mtip_check_surprise_removal(struct pci_dev *pdev)
3493{
3494 u16 vendor_id = 0;
3495
3496 /* Read the vendorID from the configuration space */
3497 pci_read_config_word(pdev, 0x00, &vendor_id);
3498 if (vendor_id == 0xFFFF)
3499 return true; /* device removed */
3500
3501 return false; /* device present */
3502}
3503
3504/* Table of device ids supported by this driver. */ 3498/* Table of device ids supported by this driver. */
3505static DEFINE_PCI_DEVICE_TABLE(mtip_pci_tbl) = { 3499static DEFINE_PCI_DEVICE_TABLE(mtip_pci_tbl) = {
3506 { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P320_DEVICE_ID) }, 3500 { PCI_DEVICE(PCI_VENDOR_ID_MICRON, P320_DEVICE_ID) },
diff --git a/drivers/block/mtip32xx/mtip32xx.h b/drivers/block/mtip32xx/mtip32xx.h
index d6355c6f218f..17be4f444e7d 100644
--- a/drivers/block/mtip32xx/mtip32xx.h
+++ b/drivers/block/mtip32xx/mtip32xx.h
@@ -405,37 +405,4 @@ struct driver_data {
405 atomic_t eh_active; /* Flag for error handling tracking */ 405 atomic_t eh_active; /* Flag for error handling tracking */
406}; 406};
407 407
408/* Function declarations */
409extern int mtip_block_initialize(struct driver_data *dd);
410extern int mtip_block_remove(struct driver_data *dd);
411extern int mtip_block_shutdown(struct driver_data *dd);
412extern int mtip_block_suspend(struct driver_data *dd);
413extern int mtip_block_resume(struct driver_data *dd);
414extern int mtip_hw_init(struct driver_data *dd);
415extern int mtip_hw_exit(struct driver_data *dd);
416extern int mtip_hw_shutdown(struct driver_data *dd);
417extern bool mtip_hw_get_capacity(struct driver_data *dd, sector_t *sectors);
418extern void mtip_hw_release_scatterlist(
419 struct driver_data *dd,
420 int tag);
421extern struct scatterlist *mtip_hw_get_scatterlist(
422 struct driver_data *dd,
423 int *tag);
424extern void mtip_hw_submit_io(struct driver_data *dd,
425 sector_t start,
426 int nsect,
427 int nents,
428 int tag,
429 void *callback,
430 void *data,
431 int barrier,
432 int dir);
433extern int mtip_hw_sysfs_init(struct driver_data *dd, struct kobject *kobj);
434extern int mtip_hw_sysfs_exit(struct driver_data *dd, struct kobject *kobj);
435extern int mtip_hw_resume(struct driver_data *dd);
436extern int mtip_hw_suspend(struct driver_data *dd);
437void mtip_command_cleanup(struct driver_data *dd);
438bool mtip_check_surprise_removal(struct pci_dev *pdev);
439void mtip_restart_port(struct mtip_port *port);
440
441#endif 408#endif