hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/scsi/ipr.c
....@@ -1,24 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * ipr.c -- driver for IBM Power Linux RAID adapters
34 *
45 * Written By: Brian King <brking@us.ibm.com>, IBM Corporation
56 *
67 * Copyright (C) 2003, 2004 IBM Corporation
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with this program; if not, write to the Free Software
20
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
- *
228 */
239
2410 /*
....@@ -684,6 +670,7 @@
684670 /**
685671 * ipr_init_ipr_cmnd - Initialize an IPR Cmnd block
686672 * @ipr_cmd: ipr command struct
673
+ * @fast_done: fast done function call-back
687674 *
688675 * Return value:
689676 * none
....@@ -701,7 +688,7 @@
701688
702689 /**
703690 * __ipr_get_free_ipr_cmnd - Get a free IPR Cmnd block
704
- * @ioa_cfg: ioa config struct
691
+ * @hrrq: hrr queue
705692 *
706693 * Return value:
707694 * pointer to ipr command struct
....@@ -751,7 +738,6 @@
751738 static void ipr_mask_and_clear_interrupts(struct ipr_ioa_cfg *ioa_cfg,
752739 u32 clr_ints)
753740 {
754
- volatile u32 int_reg;
755741 int i;
756742
757743 /* Stop new interrupts */
....@@ -771,7 +757,7 @@
771757 if (ioa_cfg->sis64)
772758 writel(~0, ioa_cfg->regs.clr_interrupt_reg);
773759 writel(clr_ints, ioa_cfg->regs.clr_interrupt_reg32);
774
- int_reg = readl(ioa_cfg->regs.sense_interrupt_reg);
760
+ readl(ioa_cfg->regs.sense_interrupt_reg);
775761 }
776762
777763 /**
....@@ -1178,7 +1164,7 @@
11781164 default:
11791165 res->ata_class = ATA_DEV_UNKNOWN;
11801166 break;
1181
- };
1167
+ }
11821168 }
11831169
11841170 /**
....@@ -1301,7 +1287,7 @@
13011287 /**
13021288 * __ipr_format_res_path - Format the resource path for printing.
13031289 * @res_path: resource path
1304
- * @buf: buffer
1290
+ * @buffer: buffer
13051291 * @len: length of buffer provided
13061292 *
13071293 * Return value:
....@@ -1313,9 +1299,9 @@
13131299 char *p = buffer;
13141300
13151301 *p = '\0';
1316
- p += snprintf(p, buffer + len - p, "%02X", res_path[0]);
1302
+ p += scnprintf(p, buffer + len - p, "%02X", res_path[0]);
13171303 for (i = 1; res_path[i] != 0xff && ((i * 3) < len); i++)
1318
- p += snprintf(p, buffer + len - p, "-%02X", res_path[i]);
1304
+ p += scnprintf(p, buffer + len - p, "-%02X", res_path[i]);
13191305
13201306 return buffer;
13211307 }
....@@ -1324,7 +1310,7 @@
13241310 * ipr_format_res_path - Format the resource path for printing.
13251311 * @ioa_cfg: ioa config struct
13261312 * @res_path: resource path
1327
- * @buf: buffer
1313
+ * @buffer: buffer
13281314 * @len: length of buffer provided
13291315 *
13301316 * Return value:
....@@ -1336,7 +1322,7 @@
13361322 char *p = buffer;
13371323
13381324 *p = '\0';
1339
- p += snprintf(p, buffer + len - p, "%d/", ioa_cfg->host->host_no);
1325
+ p += scnprintf(p, buffer + len - p, "%d/", ioa_cfg->host->host_no);
13401326 __ipr_format_res_path(res_path, p, len - (buffer - p));
13411327 return buffer;
13421328 }
....@@ -1405,7 +1391,6 @@
14051391 * ipr_clear_res_target - Clear the bit in the bit map representing the target
14061392 * for the resource.
14071393 * @res: resource entry struct
1408
- * @cfgtew: config table entry wrapper struct
14091394 *
14101395 * Return value:
14111396 * none
....@@ -1531,23 +1516,22 @@
15311516 }
15321517
15331518 /**
1534
- * strip_and_pad_whitespace - Strip and pad trailing whitespace.
1535
- * @i: index into buffer
1536
- * @buf: string to modify
1519
+ * strip_whitespace - Strip and pad trailing whitespace.
1520
+ * @i: size of buffer
1521
+ * @buf: string to modify
15371522 *
1538
- * This function will strip all trailing whitespace, pad the end
1539
- * of the string with a single space, and NULL terminate the string.
1523
+ * This function will strip all trailing whitespace and
1524
+ * NUL terminate the string.
15401525 *
1541
- * Return value:
1542
- * new length of string
15431526 **/
1544
-static int strip_and_pad_whitespace(int i, char *buf)
1527
+static void strip_whitespace(int i, char *buf)
15451528 {
1529
+ if (i < 1)
1530
+ return;
1531
+ i--;
15461532 while (i && buf[i] == ' ')
15471533 i--;
1548
- buf[i+1] = ' ';
1549
- buf[i+2] = '\0';
1550
- return i + 2;
1534
+ buf[i+1] = '\0';
15511535 }
15521536
15531537 /**
....@@ -1562,19 +1546,21 @@
15621546 static void ipr_log_vpd_compact(char *prefix, struct ipr_hostrcb *hostrcb,
15631547 struct ipr_vpd *vpd)
15641548 {
1565
- char buffer[IPR_VENDOR_ID_LEN + IPR_PROD_ID_LEN + IPR_SERIAL_NUM_LEN + 3];
1566
- int i = 0;
1549
+ char vendor_id[IPR_VENDOR_ID_LEN + 1];
1550
+ char product_id[IPR_PROD_ID_LEN + 1];
1551
+ char sn[IPR_SERIAL_NUM_LEN + 1];
15671552
1568
- memcpy(buffer, vpd->vpids.vendor_id, IPR_VENDOR_ID_LEN);
1569
- i = strip_and_pad_whitespace(IPR_VENDOR_ID_LEN - 1, buffer);
1553
+ memcpy(vendor_id, vpd->vpids.vendor_id, IPR_VENDOR_ID_LEN);
1554
+ strip_whitespace(IPR_VENDOR_ID_LEN, vendor_id);
15701555
1571
- memcpy(&buffer[i], vpd->vpids.product_id, IPR_PROD_ID_LEN);
1572
- i = strip_and_pad_whitespace(i + IPR_PROD_ID_LEN - 1, buffer);
1556
+ memcpy(product_id, vpd->vpids.product_id, IPR_PROD_ID_LEN);
1557
+ strip_whitespace(IPR_PROD_ID_LEN, product_id);
15731558
1574
- memcpy(&buffer[i], vpd->sn, IPR_SERIAL_NUM_LEN);
1575
- buffer[IPR_SERIAL_NUM_LEN + i] = '\0';
1559
+ memcpy(sn, vpd->sn, IPR_SERIAL_NUM_LEN);
1560
+ strip_whitespace(IPR_SERIAL_NUM_LEN, sn);
15761561
1577
- ipr_hcam_err(hostrcb, "%s VPID/SN: %s\n", prefix, buffer);
1562
+ ipr_hcam_err(hostrcb, "%s VPID/SN: %s %s %s\n", prefix,
1563
+ vendor_id, product_id, sn);
15781564 }
15791565
15801566 /**
....@@ -2681,7 +2667,7 @@
26812667
26822668 /**
26832669 * ipr_timeout - An internally generated op has timed out.
2684
- * @ipr_cmd: ipr command struct
2670
+ * @t: Timer context used to fetch ipr command struct
26852671 *
26862672 * This function blocks host requests and initiates an
26872673 * adapter reset.
....@@ -2714,7 +2700,7 @@
27142700
27152701 /**
27162702 * ipr_oper_timeout - Adapter timed out transitioning to operational
2717
- * @ipr_cmd: ipr command struct
2703
+ * @t: Timer context used to fetch ipr command struct
27182704 *
27192705 * This function blocks host requests and initiates an
27202706 * adapter reset.
....@@ -3498,6 +3484,7 @@
34983484 /**
34993485 * ipr_show_fw_version - Show the firmware version
35003486 * @dev: class device struct
3487
+ * @attr: device attribute (unused)
35013488 * @buf: buffer
35023489 *
35033490 * Return value:
....@@ -3532,6 +3519,7 @@
35323519 /**
35333520 * ipr_show_log_level - Show the adapter's error logging level
35343521 * @dev: class device struct
3522
+ * @attr: device attribute (unused)
35353523 * @buf: buffer
35363524 *
35373525 * Return value:
....@@ -3554,7 +3542,9 @@
35543542 /**
35553543 * ipr_store_log_level - Change the adapter's error logging level
35563544 * @dev: class device struct
3545
+ * @attr: device attribute (unused)
35573546 * @buf: buffer
3547
+ * @count: buffer size
35583548 *
35593549 * Return value:
35603550 * number of bytes printed to buffer
....@@ -3585,6 +3575,7 @@
35853575 /**
35863576 * ipr_store_diagnostics - IOA Diagnostics interface
35873577 * @dev: device struct
3578
+ * @attr: device attribute (unused)
35883579 * @buf: buffer
35893580 * @count: buffer size
35903581 *
....@@ -3645,7 +3636,8 @@
36453636
36463637 /**
36473638 * ipr_show_adapter_state - Show the adapter's state
3648
- * @class_dev: device struct
3639
+ * @dev: device struct
3640
+ * @attr: device attribute (unused)
36493641 * @buf: buffer
36503642 *
36513643 * Return value:
....@@ -3671,6 +3663,7 @@
36713663 /**
36723664 * ipr_store_adapter_state - Change adapter state
36733665 * @dev: device struct
3666
+ * @attr: device attribute (unused)
36743667 * @buf: buffer
36753668 * @count: buffer size
36763669 *
....@@ -3722,6 +3715,7 @@
37223715 /**
37233716 * ipr_store_reset_adapter - Reset the adapter
37243717 * @dev: device struct
3718
+ * @attr: device attribute (unused)
37253719 * @buf: buffer
37263720 * @count: buffer size
37273721 *
....@@ -3763,6 +3757,7 @@
37633757 /**
37643758 * ipr_show_iopoll_weight - Show ipr polling mode
37653759 * @dev: class device struct
3760
+ * @attr: device attribute (unused)
37663761 * @buf: buffer
37673762 *
37683763 * Return value:
....@@ -3786,7 +3781,9 @@
37863781 /**
37873782 * ipr_store_iopoll_weight - Change the adapter's polling mode
37883783 * @dev: class device struct
3784
+ * @attr: device attribute (unused)
37893785 * @buf: buffer
3786
+ * @count: buffer size
37903787 *
37913788 * Return value:
37923789 * number of bytes printed to buffer
....@@ -3885,7 +3882,7 @@
38853882
38863883 /**
38873884 * ipr_free_ucode_buffer - Frees a microcode download buffer
3888
- * @p_dnld: scatter/gather list pointer
3885
+ * @sglist: scatter/gather list pointer
38893886 *
38903887 * Free a DMA'able ucode download buffer previously allocated with
38913888 * ipr_alloc_ucode_buffer
....@@ -3915,22 +3912,23 @@
39153912 u8 *buffer, u32 len)
39163913 {
39173914 int bsize_elem, i, result = 0;
3918
- struct scatterlist *scatterlist;
3915
+ struct scatterlist *sg;
39193916 void *kaddr;
39203917
39213918 /* Determine the actual number of bytes per element */
39223919 bsize_elem = PAGE_SIZE * (1 << sglist->order);
39233920
3924
- scatterlist = sglist->scatterlist;
3921
+ sg = sglist->scatterlist;
39253922
3926
- for (i = 0; i < (len / bsize_elem); i++, buffer += bsize_elem) {
3927
- struct page *page = sg_page(&scatterlist[i]);
3923
+ for (i = 0; i < (len / bsize_elem); i++, sg = sg_next(sg),
3924
+ buffer += bsize_elem) {
3925
+ struct page *page = sg_page(sg);
39283926
39293927 kaddr = kmap(page);
39303928 memcpy(kaddr, buffer, bsize_elem);
39313929 kunmap(page);
39323930
3933
- scatterlist[i].length = bsize_elem;
3931
+ sg->length = bsize_elem;
39343932
39353933 if (result != 0) {
39363934 ipr_trace;
....@@ -3939,13 +3937,13 @@
39393937 }
39403938
39413939 if (len % bsize_elem) {
3942
- struct page *page = sg_page(&scatterlist[i]);
3940
+ struct page *page = sg_page(sg);
39433941
39443942 kaddr = kmap(page);
39453943 memcpy(kaddr, buffer, len % bsize_elem);
39463944 kunmap(page);
39473945
3948
- scatterlist[i].length = len % bsize_elem;
3946
+ sg->length = len % bsize_elem;
39493947 }
39503948
39513949 sglist->buffer_len = len;
....@@ -3966,6 +3964,7 @@
39663964 struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb;
39673965 struct ipr_ioadl64_desc *ioadl64 = ipr_cmd->i.ioadl64;
39683966 struct scatterlist *scatterlist = sglist->scatterlist;
3967
+ struct scatterlist *sg;
39693968 int i;
39703969
39713970 ipr_cmd->dma_use_sg = sglist->num_dma_sg;
....@@ -3974,10 +3973,10 @@
39743973
39753974 ioarcb->ioadl_len =
39763975 cpu_to_be32(sizeof(struct ipr_ioadl64_desc) * ipr_cmd->dma_use_sg);
3977
- for (i = 0; i < ipr_cmd->dma_use_sg; i++) {
3976
+ for_each_sg(scatterlist, sg, ipr_cmd->dma_use_sg, i) {
39783977 ioadl64[i].flags = cpu_to_be32(IPR_IOADL_FLAGS_WRITE);
3979
- ioadl64[i].data_len = cpu_to_be32(sg_dma_len(&scatterlist[i]));
3980
- ioadl64[i].address = cpu_to_be64(sg_dma_address(&scatterlist[i]));
3978
+ ioadl64[i].data_len = cpu_to_be32(sg_dma_len(sg));
3979
+ ioadl64[i].address = cpu_to_be64(sg_dma_address(sg));
39813980 }
39823981
39833982 ioadl64[i-1].flags |= cpu_to_be32(IPR_IOADL_FLAGS_LAST);
....@@ -3997,6 +3996,7 @@
39973996 struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb;
39983997 struct ipr_ioadl_desc *ioadl = ipr_cmd->i.ioadl;
39993998 struct scatterlist *scatterlist = sglist->scatterlist;
3999
+ struct scatterlist *sg;
40004000 int i;
40014001
40024002 ipr_cmd->dma_use_sg = sglist->num_dma_sg;
....@@ -4006,11 +4006,11 @@
40064006 ioarcb->ioadl_len =
40074007 cpu_to_be32(sizeof(struct ipr_ioadl_desc) * ipr_cmd->dma_use_sg);
40084008
4009
- for (i = 0; i < ipr_cmd->dma_use_sg; i++) {
4009
+ for_each_sg(scatterlist, sg, ipr_cmd->dma_use_sg, i) {
40104010 ioadl[i].flags_and_data_len =
4011
- cpu_to_be32(IPR_IOADL_FLAGS_WRITE | sg_dma_len(&scatterlist[i]));
4011
+ cpu_to_be32(IPR_IOADL_FLAGS_WRITE | sg_dma_len(sg));
40124012 ioadl[i].address =
4013
- cpu_to_be32(sg_dma_address(&scatterlist[i]));
4013
+ cpu_to_be32(sg_dma_address(sg));
40144014 }
40154015
40164016 ioadl[i-1].flags_and_data_len |=
....@@ -4070,7 +4070,8 @@
40704070
40714071 /**
40724072 * ipr_store_update_fw - Update the firmware on the adapter
4073
- * @class_dev: device struct
4073
+ * @dev: device struct
4074
+ * @attr: device attribute (unused)
40744075 * @buf: buffer
40754076 * @count: buffer size
40764077 *
....@@ -4150,6 +4151,7 @@
41504151 /**
41514152 * ipr_show_fw_type - Show the adapter's firmware type.
41524153 * @dev: class device struct
4154
+ * @attr: device attribute (unused)
41534155 * @buf: buffer
41544156 *
41554157 * Return value:
....@@ -4491,7 +4493,6 @@
44914493 * ipr_change_queue_depth - Change the device's queue depth
44924494 * @sdev: scsi device struct
44934495 * @qdepth: depth to set
4494
- * @reason: calling context
44954496 *
44964497 * Return value:
44974498 * actual depth set
....@@ -4661,6 +4662,7 @@
46614662 /**
46624663 * ipr_show_raw_mode - Show the adapter's raw mode
46634664 * @dev: class device struct
4665
+ * @attr: device attribute (unused)
46644666 * @buf: buffer
46654667 *
46664668 * Return value:
....@@ -4688,7 +4690,9 @@
46884690 /**
46894691 * ipr_store_raw_mode - Change the adapter's raw mode
46904692 * @dev: class device struct
4693
+ * @attr: device attribute (unused)
46914694 * @buf: buffer
4695
+ * @count: buffer size
46924696 *
46934697 * Return value:
46944698 * number of bytes printed to buffer
....@@ -5071,7 +5075,7 @@
50715075
50725076 /**
50735077 * ipr_cmnd_is_free - Check if a command is free or not
5074
- * @ipr_cmd ipr command struct
5078
+ * @ipr_cmd: ipr command struct
50755079 *
50765080 * Returns:
50775081 * true / false
....@@ -5107,7 +5111,7 @@
51075111
51085112 /**
51095113 * ipr_wait_for_ops - Wait for matching commands to complete
5110
- * @ipr_cmd: ipr command struct
5114
+ * @ioa_cfg: ioa config struct
51115115 * @device: device to match (sdev)
51125116 * @match: match function to use
51135117 *
....@@ -5272,6 +5276,7 @@
52725276 * ipr_sata_reset - Reset the SATA port
52735277 * @link: SATA link to reset
52745278 * @classes: class of the attached device
5279
+ * @deadline: unused
52755280 *
52765281 * This function issues a SATA phy reset to the affected ATA link.
52775282 *
....@@ -5451,7 +5456,7 @@
54515456
54525457 /**
54535458 * ipr_abort_timeout - An abort task has timed out
5454
- * @ipr_cmd: ipr command struct
5459
+ * @t: Timer context used to fetch ipr command struct
54555460 *
54565461 * This function handles when an abort task times out. If this
54575462 * happens we issue a bus reset since we have resources tied
....@@ -5505,7 +5510,7 @@
55055510 struct ipr_ioa_cfg *ioa_cfg;
55065511 struct ipr_resource_entry *res;
55075512 struct ipr_cmd_pkt *cmd_pkt;
5508
- u32 ioasc, int_reg;
5513
+ u32 ioasc;
55095514 int i, op_found = 0;
55105515 struct ipr_hrr_queue *hrrq;
55115516
....@@ -5528,7 +5533,7 @@
55285533 * by a still not detected EEH error. In such cases, reading a register will
55295534 * trigger the EEH recovery infrastructure.
55305535 */
5531
- int_reg = readl(ioa_cfg->regs.sense_interrupt_reg);
5536
+ readl(ioa_cfg->regs.sense_interrupt_reg);
55325537
55335538 if (!ipr_is_gscsi(res))
55345539 return FAILED;
....@@ -5580,7 +5585,8 @@
55805585
55815586 /**
55825587 * ipr_eh_abort - Abort a single op
5583
- * @scsi_cmd: scsi command struct
5588
+ * @shost: scsi host struct
5589
+ * @elapsed_time: elapsed time
55845590 *
55855591 * Return value:
55865592 * 0 if scan in progress / 1 if scan is complete
....@@ -5707,6 +5713,7 @@
57075713 * ipr_isr_eh - Interrupt service routine error handler
57085714 * @ioa_cfg: ioa config struct
57095715 * @msg: message to log
5716
+ * @number: various meanings depending on the caller/message
57105717 *
57115718 * Return value:
57125719 * none
....@@ -5773,7 +5780,6 @@
57735780
57745781 static int ipr_iopoll(struct irq_poll *iop, int budget)
57755782 {
5776
- struct ipr_ioa_cfg *ioa_cfg;
57775783 struct ipr_hrr_queue *hrrq;
57785784 struct ipr_cmnd *ipr_cmd, *temp;
57795785 unsigned long hrrq_flags;
....@@ -5781,7 +5787,6 @@
57815787 LIST_HEAD(doneq);
57825788
57835789 hrrq = container_of(iop, struct ipr_hrr_queue, iopoll);
5784
- ioa_cfg = hrrq->ioa_cfg;
57855790
57865791 spin_lock_irqsave(hrrq->lock, hrrq_flags);
57875792 completed_ops = ipr_process_hrrq(hrrq, budget, &doneq);
....@@ -6279,8 +6284,7 @@
62796284
62806285 /**
62816286 * ipr_gen_sense - Generate SCSI sense data from an IOASA
6282
- * @ioasa: IOASA
6283
- * @sense_buf: sense data buffer
6287
+ * @ipr_cmd: ipr command struct
62846288 *
62856289 * Return value:
62866290 * none
....@@ -6696,7 +6700,8 @@
66966700 * Return value:
66976701 * 0 on success / other on failure
66986702 **/
6699
-static int ipr_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
6703
+static int ipr_ioctl(struct scsi_device *sdev, unsigned int cmd,
6704
+ void __user *arg)
67006705 {
67016706 struct ipr_resource_entry *res;
67026707
....@@ -6712,7 +6717,7 @@
67126717
67136718 /**
67146719 * ipr_info - Get information about the card/driver
6715
- * @scsi_host: scsi host struct
6720
+ * @host: scsi host struct
67166721 *
67176722 * Return value:
67186723 * pointer to buffer with description string
....@@ -6737,7 +6742,11 @@
67376742 .name = "IPR",
67386743 .info = ipr_ioa_info,
67396744 .ioctl = ipr_ioctl,
6745
+#ifdef CONFIG_COMPAT
6746
+ .compat_ioctl = ipr_ioctl,
6747
+#endif
67406748 .queuecommand = ipr_queuecommand,
6749
+ .dma_need_drain = ata_scsi_dma_need_drain,
67416750 .eh_abort_handler = ipr_eh_abort,
67426751 .eh_device_reset_handler = ipr_eh_dev_reset,
67436752 .eh_host_reset_handler = ipr_eh_host_reset,
....@@ -6754,7 +6763,6 @@
67546763 .sg_tablesize = IPR_MAX_SGLIST,
67556764 .max_sectors = IPR_IOA_MAX_SECTORS,
67566765 .cmd_per_lun = IPR_MAX_CMD_PER_LUN,
6757
- .use_clustering = ENABLE_CLUSTERING,
67586766 .shost_attrs = ipr_ioa_attrs,
67596767 .sdev_attrs = ipr_dev_attrs,
67606768 .proc_name = IPR_NAME,
....@@ -7599,7 +7607,7 @@
75997607 /**
76007608 * ipr_build_mode_sense - Builds a mode sense command
76017609 * @ipr_cmd: ipr command struct
7602
- * @res: resource entry struct
7610
+ * @res_handle: resource entry struct
76037611 * @parm: Byte 2 of mode sense command
76047612 * @dma_addr: DMA address of mode sense buffer
76057613 * @xfer_len: Size of DMA buffer
....@@ -7946,6 +7954,7 @@
79467954 /**
79477955 * ipr_ioafp_set_caching_parameters - Issue Set Cache parameters service
79487956 * action
7957
+ * @ipr_cmd: ipr command struct
79497958 *
79507959 * Return value:
79517960 * none
....@@ -7982,6 +7991,10 @@
79827991 /**
79837992 * ipr_ioafp_inquiry - Send an Inquiry to the adapter.
79847993 * @ipr_cmd: ipr command struct
7994
+ * @flags: flags to send
7995
+ * @page: page to inquire
7996
+ * @dma_addr: DMA address
7997
+ * @xfer_len: transfer data length
79857998 *
79867999 * This utility function sends an inquiry to the adapter.
79878000 *
....@@ -8272,7 +8285,7 @@
82728285
82738286 /**
82748287 * ipr_reset_timer_done - Adapter reset timer function
8275
- * @ipr_cmd: ipr command struct
8288
+ * @t: Timer context used to fetch ipr command struct
82768289 *
82778290 * Description: This function is used in adapter reset processing
82788291 * for timing events. If the reset_cmd pointer in the IOA
....@@ -8666,7 +8679,6 @@
86668679 static int ipr_reset_restore_cfg_space(struct ipr_cmnd *ipr_cmd)
86678680 {
86688681 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
8669
- u32 int_reg;
86708682
86718683 ENTER;
86728684 ioa_cfg->pdev->state_saved = true;
....@@ -8682,7 +8694,7 @@
86828694 if (ioa_cfg->sis64) {
86838695 /* Set the adapter to the correct endian mode. */
86848696 writel(IPR_ENDIAN_SWAP_KEY, ioa_cfg->regs.endian_swap_reg);
8685
- int_reg = readl(ioa_cfg->regs.endian_swap_reg);
8697
+ readl(ioa_cfg->regs.endian_swap_reg);
86868698 }
86878699
86888700 if (ioa_cfg->ioa_unit_checked) {
....@@ -9490,7 +9502,6 @@
94909502 * Description: This is the second phase of adapter initialization
94919503 * This function takes care of initilizing the adapter to the point
94929504 * where it can accept new commands.
9493
-
94949505 * Return value:
94959506 * 0 on success / -EIO on failure
94969507 **/
....@@ -9537,8 +9548,7 @@
95379548 }
95389549 }
95399550
9540
- if (ioa_cfg->ipr_cmd_pool)
9541
- dma_pool_destroy(ioa_cfg->ipr_cmd_pool);
9551
+ dma_pool_destroy(ioa_cfg->ipr_cmd_pool);
95429552
95439553 kfree(ioa_cfg->ipr_cmnd_list);
95449554 kfree(ioa_cfg->ipr_cmnd_list_dma);
....@@ -9605,7 +9615,7 @@
96059615
96069616 /**
96079617 * ipr_free_all_resources - Free all allocated resources for an adapter.
9608
- * @ipr_cmd: ipr command struct
9618
+ * @ioa_cfg: ioa config struct
96099619 *
96109620 * This function frees all allocated resources for the
96119621 * specified adapter.
....@@ -9783,7 +9793,7 @@
97839793 GFP_KERNEL);
97849794
97859795 if (!ioa_cfg->hrrq[i].host_rrq) {
9786
- while (--i > 0)
9796
+ while (--i >= 0)
97879797 dma_free_coherent(&pdev->dev,
97889798 sizeof(u32) * ioa_cfg->hrrq[i].size,
97899799 ioa_cfg->hrrq[i].host_rrq,
....@@ -10056,7 +10066,7 @@
1005610066 ioa_cfg->vectors_info[i].desc,
1005710067 &ioa_cfg->hrrq[i]);
1005810068 if (rc) {
10059
- while (--i >= 0)
10069
+ while (--i > 0)
1006010070 free_irq(pci_irq_vector(pdev, i),
1006110071 &ioa_cfg->hrrq[i]);
1006210072 return rc;
....@@ -10067,7 +10077,8 @@
1006710077
1006810078 /**
1006910079 * ipr_test_intr - Handle the interrupt generated in ipr_test_msi().
10070
- * @pdev: PCI device struct
10080
+ * @devp: PCI device struct
10081
+ * @irq: IRQ number
1007110082 *
1007210083 * Description: Simply set the msi_received flag to 1 indicating that
1007310084 * Message Signaled Interrupts are supported.
....@@ -10093,6 +10104,7 @@
1009310104
1009410105 /**
1009510106 * ipr_test_msi - Test for Message Signaled Interrupt (MSI) support.
10107
+ * @ioa_cfg: ioa config struct
1009610108 * @pdev: PCI device struct
1009710109 *
1009810110 * Description: This routine sets up and initiates a test interrupt to determine
....@@ -10105,7 +10117,6 @@
1010510117 static int ipr_test_msi(struct ipr_ioa_cfg *ioa_cfg, struct pci_dev *pdev)
1010610118 {
1010710119 int rc;
10108
- volatile u32 int_reg;
1010910120 unsigned long lock_flags = 0;
1011010121 int irq = pci_irq_vector(pdev, 0);
1011110122
....@@ -10116,7 +10127,7 @@
1011610127 ioa_cfg->msi_received = 0;
1011710128 ipr_mask_and_clear_interrupts(ioa_cfg, ~IPR_PCII_IOA_TRANS_TO_OPER);
1011810129 writel(IPR_PCII_IO_DEBUG_ACKNOWLEDGE, ioa_cfg->regs.clr_interrupt_mask_reg32);
10119
- int_reg = readl(ioa_cfg->regs.sense_interrupt_mask_reg);
10130
+ readl(ioa_cfg->regs.sense_interrupt_mask_reg);
1012010131 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
1012110132
1012210133 rc = request_irq(irq, ipr_test_intr, 0, IPR_NAME, ioa_cfg);
....@@ -10127,7 +10138,7 @@
1012710138 dev_info(&pdev->dev, "IRQ assigned: %d\n", irq);
1012810139
1012910140 writel(IPR_PCII_IO_DEBUG_ACKNOWLEDGE, ioa_cfg->regs.sense_interrupt_reg32);
10130
- int_reg = readl(ioa_cfg->regs.sense_interrupt_reg);
10141
+ readl(ioa_cfg->regs.sense_interrupt_reg);
1013110142 wait_event_timeout(ioa_cfg->msi_wait_q, ioa_cfg->msi_received, HZ);
1013210143 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
1013310144 ipr_mask_and_clear_interrupts(ioa_cfg, ~IPR_PCII_IOA_TRANS_TO_OPER);
....@@ -10538,6 +10549,8 @@
1053810549
1053910550 /**
1054010551 * ipr_probe - Adapter hot plug add entry point
10552
+ * @pdev: pci device struct
10553
+ * @dev_id: pci device ID
1054110554 *
1054210555 * Return value:
1054310556 * 0 on success / non-zero on failure
....@@ -10794,6 +10807,7 @@
1079410807
1079510808 /**
1079610809 * ipr_halt_done - Shutdown prepare completion
10810
+ * @ipr_cmd: ipr command struct
1079710811 *
1079810812 * Return value:
1079910813 * none
....@@ -10805,6 +10819,9 @@
1080510819
1080610820 /**
1080710821 * ipr_halt - Issue shutdown prepare to all adapters
10822
+ * @nb: Notifier block
10823
+ * @event: Notifier event
10824
+ * @buf: Notifier data (unused)
1080810825 *
1080910826 * Return value:
1081010827 * NOTIFY_OK on success / NOTIFY_DONE on failure
....@@ -10854,11 +10871,19 @@
1085410871 **/
1085510872 static int __init ipr_init(void)
1085610873 {
10874
+ int rc;
10875
+
1085710876 ipr_info("IBM Power RAID SCSI Device Driver version: %s %s\n",
1085810877 IPR_DRIVER_VERSION, IPR_DRIVER_DATE);
1085910878
1086010879 register_reboot_notifier(&ipr_notifier);
10861
- return pci_register_driver(&ipr_driver);
10880
+ rc = pci_register_driver(&ipr_driver);
10881
+ if (rc) {
10882
+ unregister_reboot_notifier(&ipr_notifier);
10883
+ return rc;
10884
+ }
10885
+
10886
+ return 0;
1086210887 }
1086310888
1086410889 /**