forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/scsi/megaraid.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 *
34 * Linux MegaRAID device driver
45 *
56 * Copyright (c) 2002 LSI Logic Corporation.
6
- *
7
- * This program is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU General Public License
9
- * as published by the Free Software Foundation; either version
10
- * 2 of the License, or (at your option) any later version.
117 *
128 * Copyright (c) 2002 Red Hat, Inc. All rights reserved.
139 * - fixes
....@@ -28,7 +24,6 @@
2824 * This driver is supported by LSI Logic, with assistance from Red Hat, Dell,
2925 * and others. Please send updates to the mailing list
3026 * linux-scsi@vger.kernel.org .
31
- *
3227 */
3328
3429 #include <linux/mm.h>
....@@ -129,7 +124,7 @@
129124
130125 /**
131126 * mega_setup_mailbox()
132
- * @adapter - pointer to our soft state
127
+ * @adapter: pointer to our soft state
133128 *
134129 * Allocates a 8 byte aligned memory for the handshake mailbox.
135130 */
....@@ -138,8 +133,10 @@
138133 {
139134 unsigned long align;
140135
141
- adapter->una_mbox64 = pci_alloc_consistent(adapter->dev,
142
- sizeof(mbox64_t), &adapter->una_mbox64_dma);
136
+ adapter->una_mbox64 = dma_alloc_coherent(&adapter->dev->dev,
137
+ sizeof(mbox64_t),
138
+ &adapter->una_mbox64_dma,
139
+ GFP_KERNEL);
143140
144141 if( !adapter->una_mbox64 ) return -1;
145142
....@@ -227,8 +224,9 @@
227224 mraid_inquiry *inq;
228225 dma_addr_t dma_handle;
229226
230
- ext_inq = pci_alloc_consistent(adapter->dev,
231
- sizeof(mraid_ext_inquiry), &dma_handle);
227
+ ext_inq = dma_alloc_coherent(&adapter->dev->dev,
228
+ sizeof(mraid_ext_inquiry),
229
+ &dma_handle, GFP_KERNEL);
232230
233231 if( ext_inq == NULL ) return -1;
234232
....@@ -248,8 +246,9 @@
248246 mega_8_to_40ld(inq, inquiry3,
249247 (mega_product_info *)&adapter->product_info);
250248
251
- pci_free_consistent(adapter->dev, sizeof(mraid_ext_inquiry),
252
- ext_inq, dma_handle);
249
+ dma_free_coherent(&adapter->dev->dev,
250
+ sizeof(mraid_ext_inquiry), ext_inq,
251
+ dma_handle);
253252
254253 } else { /*adapter supports 40ld */
255254 adapter->flag |= BOARD_40LD;
....@@ -258,9 +257,10 @@
258257 * get product_info, which is static information and will be
259258 * unchanged
260259 */
261
- prod_info_dma_handle = pci_map_single(adapter->dev, (void *)
262
- &adapter->product_info,
263
- sizeof(mega_product_info), PCI_DMA_FROMDEVICE);
260
+ prod_info_dma_handle = dma_map_single(&adapter->dev->dev,
261
+ (void *)&adapter->product_info,
262
+ sizeof(mega_product_info),
263
+ DMA_FROM_DEVICE);
264264
265265 mbox->m_out.xferaddr = prod_info_dma_handle;
266266
....@@ -272,8 +272,8 @@
272272 "Product_info cmd failed with error: %d\n",
273273 retval);
274274
275
- pci_unmap_single(adapter->dev, prod_info_dma_handle,
276
- sizeof(mega_product_info), PCI_DMA_FROMDEVICE);
275
+ dma_unmap_single(&adapter->dev->dev, prod_info_dma_handle,
276
+ sizeof(mega_product_info), DMA_FROM_DEVICE);
277277 }
278278
279279
....@@ -352,7 +352,7 @@
352352
353353 /**
354354 * mega_runpendq()
355
- * @adapter - pointer to our soft state
355
+ * @adapter: pointer to our soft state
356356 *
357357 * Runs through the list of pending requests.
358358 */
....@@ -418,8 +418,8 @@
418418
419419 /**
420420 * mega_allocate_scb()
421
- * @adapter - pointer to our soft state
422
- * @cmd - scsi command from the mid-layer
421
+ * @adapter: pointer to our soft state
422
+ * @cmd: scsi command from the mid-layer
423423 *
424424 * Allocate a SCB structure. This is the central structure for controller
425425 * commands.
....@@ -449,9 +449,9 @@
449449
450450 /**
451451 * mega_get_ldrv_num()
452
- * @adapter - pointer to our soft state
453
- * @cmd - scsi mid layer command
454
- * @channel - channel on the controller
452
+ * @adapter: pointer to our soft state
453
+ * @cmd: scsi mid layer command
454
+ * @channel: channel on the controller
455455 *
456456 * Calculate the logical drive number based on the information in scsi command
457457 * and the channel number.
....@@ -496,9 +496,9 @@
496496
497497 if (adapter->support_random_del && adapter->read_ldidmap )
498498 switch (cmd->cmnd[0]) {
499
- case READ_6: /* fall through */
500
- case WRITE_6: /* fall through */
501
- case READ_10: /* fall through */
499
+ case READ_6:
500
+ case WRITE_6:
501
+ case READ_10:
502502 case WRITE_10:
503503 ldrv_num += 0x80;
504504 }
....@@ -508,9 +508,9 @@
508508
509509 /**
510510 * mega_build_cmd()
511
- * @adapter - pointer to our soft state
512
- * @cmd - Prepare using this scsi command
513
- * @busy - busy flag if no resources
511
+ * @adapter: pointer to our soft state
512
+ * @cmd: Prepare using this scsi command
513
+ * @busy: busy flag if no resources
514514 *
515515 * Prepares a command and scatter gather list for the controller. This routine
516516 * also finds out if the commands is intended for a logical drive or a
....@@ -522,7 +522,6 @@
522522 static scb_t *
523523 mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)
524524 {
525
- mega_ext_passthru *epthru;
526525 mega_passthru *pthru;
527526 scb_t *scb;
528527 mbox_t *mbox;
....@@ -651,7 +650,7 @@
651650 scb->raw_mbox[2] = MEGA_RESERVATION_STATUS;
652651 scb->raw_mbox[3] = ldrv_num;
653652
654
- scb->dma_direction = PCI_DMA_NONE;
653
+ scb->dma_direction = DMA_NONE;
655654
656655 return scb;
657656 #else
....@@ -715,7 +714,7 @@
715714 mbox->m_out.cmd = MEGA_MBOXCMD_PASSTHRU;
716715 }
717716
718
- scb->dma_direction = PCI_DMA_FROMDEVICE;
717
+ scb->dma_direction = DMA_FROM_DEVICE;
719718
720719 pthru->numsgelements = mega_build_sglist(adapter, scb,
721720 &pthru->dataxferaddr, &pthru->dataxferlen);
....@@ -845,10 +844,10 @@
845844 * If it is a read command
846845 */
847846 if( (*cmd->cmnd & 0x0F) == 0x08 ) {
848
- scb->dma_direction = PCI_DMA_FROMDEVICE;
847
+ scb->dma_direction = DMA_FROM_DEVICE;
849848 }
850849 else {
851
- scb->dma_direction = PCI_DMA_TODEVICE;
850
+ scb->dma_direction = DMA_TO_DEVICE;
852851 }
853852
854853 /* Calculate Scatter-Gather info */
....@@ -858,7 +857,7 @@
858857 return scb;
859858
860859 #if MEGA_HAVE_CLUSTERING
861
- case RESERVE: /* Fall through */
860
+ case RESERVE:
862861 case RELEASE:
863862
864863 /*
....@@ -883,7 +882,7 @@
883882
884883 scb->raw_mbox[3] = ldrv_num;
885884
886
- scb->dma_direction = PCI_DMA_NONE;
885
+ scb->dma_direction = DMA_NONE;
887886
888887 return scb;
889888 #endif
....@@ -910,7 +909,7 @@
910909
911910 if( adapter->support_ext_cdb ) {
912911
913
- epthru = mega_prepare_extpassthru(adapter, scb, cmd,
912
+ mega_prepare_extpassthru(adapter, scb, cmd,
914913 channel, target);
915914
916915 mbox->m_out.cmd = MEGA_MBOXCMD_EXTPTHRU;
....@@ -942,11 +941,11 @@
942941
943942 /**
944943 * mega_prepare_passthru()
945
- * @adapter - pointer to our soft state
946
- * @scb - our scsi control block
947
- * @cmd - scsi command from the mid-layer
948
- * @channel - actual channel on the controller
949
- * @target - actual id on the controller.
944
+ * @adapter: pointer to our soft state
945
+ * @scb: our scsi control block
946
+ * @cmd: scsi command from the mid-layer
947
+ * @channel: actual channel on the controller
948
+ * @target: actual id on the controller.
950949 *
951950 * prepare a command for the scsi physical devices.
952951 */
....@@ -977,7 +976,7 @@
977976 memcpy(pthru->cdb, cmd->cmnd, cmd->cmd_len);
978977
979978 /* Not sure about the direction */
980
- scb->dma_direction = PCI_DMA_BIDIRECTIONAL;
979
+ scb->dma_direction = DMA_BIDIRECTIONAL;
981980
982981 /* Special Code for Handling READ_CAPA/ INQ using bounce buffers */
983982 switch (cmd->cmnd[0]) {
....@@ -993,7 +992,7 @@
993992
994993 adapter->flag |= (1L << cmd->device->channel);
995994 }
996
- /* Fall through */
995
+ fallthrough;
997996 default:
998997 pthru->numsgelements = mega_build_sglist(adapter, scb,
999998 &pthru->dataxferaddr, &pthru->dataxferlen);
....@@ -1005,11 +1004,11 @@
10051004
10061005 /**
10071006 * mega_prepare_extpassthru()
1008
- * @adapter - pointer to our soft state
1009
- * @scb - our scsi control block
1010
- * @cmd - scsi command from the mid-layer
1011
- * @channel - actual channel on the controller
1012
- * @target - actual id on the controller.
1007
+ * @adapter: pointer to our soft state
1008
+ * @scb: our scsi control block
1009
+ * @cmd: scsi command from the mid-layer
1010
+ * @channel: actual channel on the controller
1011
+ * @target: actual id on the controller.
10131012 *
10141013 * prepare a command for the scsi physical devices. This rountine prepares
10151014 * commands for devices which can take extended CDBs (>10 bytes)
....@@ -1041,7 +1040,7 @@
10411040 memcpy(epthru->cdb, cmd->cmnd, cmd->cmd_len);
10421041
10431042 /* Not sure about the direction */
1044
- scb->dma_direction = PCI_DMA_BIDIRECTIONAL;
1043
+ scb->dma_direction = DMA_BIDIRECTIONAL;
10451044
10461045 switch(cmd->cmnd[0]) {
10471046 case INQUIRY:
....@@ -1056,7 +1055,7 @@
10561055
10571056 adapter->flag |= (1L << cmd->device->channel);
10581057 }
1059
- /* Fall through */
1058
+ fallthrough;
10601059 default:
10611060 epthru->numsgelements = mega_build_sglist(adapter, scb,
10621061 &epthru->dataxferaddr, &epthru->dataxferlen);
....@@ -1090,8 +1089,8 @@
10901089
10911090 /**
10921091 * issue_scb()
1093
- * @adapter - pointer to our soft state
1094
- * @scb - scsi control block
1092
+ * @adapter: pointer to our soft state
1093
+ * @scb: scsi control block
10951094 *
10961095 * Post a command to the card if the mailbox is available, otherwise return
10971096 * busy. We also take the scb from the pending list if the mailbox is
....@@ -1171,8 +1170,8 @@
11711170
11721171 /**
11731172 * issue_scb_block()
1174
- * @adapter - pointer to our soft state
1175
- * @raw_mbox - the mailbox
1173
+ * @adapter: pointer to our soft state
1174
+ * @raw_mbox: the mailbox
11761175 *
11771176 * Issue a scb in synchronous and non-interrupt mode
11781177 */
....@@ -1252,8 +1251,8 @@
12521251
12531252 /**
12541253 * megaraid_isr_iomapped()
1255
- * @irq - irq
1256
- * @devp - pointer to our soft state
1254
+ * @irq: irq
1255
+ * @devp: pointer to our soft state
12571256 *
12581257 * Interrupt service routine for io-mapped controllers.
12591258 * Find out if our device is interrupting. If yes, acknowledge the interrupt
....@@ -1328,8 +1327,8 @@
13281327
13291328 /**
13301329 * megaraid_isr_memmapped()
1331
- * @irq - irq
1332
- * @devp - pointer to our soft state
1330
+ * @irq: irq
1331
+ * @devp: pointer to our soft state
13331332 *
13341333 * Interrupt service routine for memory-mapped controllers.
13351334 * Find out if our device is interrupting. If yes, acknowledge the interrupt
....@@ -1406,10 +1405,10 @@
14061405 }
14071406 /**
14081407 * mega_cmd_done()
1409
- * @adapter - pointer to our soft state
1410
- * @completed - array of ids of completed commands
1411
- * @nstatus - number of completed commands
1412
- * @status - status of the last command completed
1408
+ * @adapter: pointer to our soft state
1409
+ * @completed: array of ids of completed commands
1410
+ * @nstatus: number of completed commands
1411
+ * @status: status of the last command completed
14131412 *
14141413 * Complete the commands and call the scsi mid-layer callback hooks.
14151414 */
....@@ -1819,25 +1818,25 @@
18191818 scb = &adapter->scb_list[i];
18201819
18211820 if( scb->sgl64 ) {
1822
- pci_free_consistent(adapter->dev,
1823
- sizeof(mega_sgl64) * adapter->sglen,
1824
- scb->sgl64,
1825
- scb->sgl_dma_addr);
1821
+ dma_free_coherent(&adapter->dev->dev,
1822
+ sizeof(mega_sgl64) * adapter->sglen,
1823
+ scb->sgl64, scb->sgl_dma_addr);
18261824
18271825 scb->sgl64 = NULL;
18281826 }
18291827
18301828 if( scb->pthru ) {
1831
- pci_free_consistent(adapter->dev, sizeof(mega_passthru),
1832
- scb->pthru, scb->pthru_dma_addr);
1829
+ dma_free_coherent(&adapter->dev->dev,
1830
+ sizeof(mega_passthru), scb->pthru,
1831
+ scb->pthru_dma_addr);
18331832
18341833 scb->pthru = NULL;
18351834 }
18361835
18371836 if( scb->epthru ) {
1838
- pci_free_consistent(adapter->dev,
1839
- sizeof(mega_ext_passthru),
1840
- scb->epthru, scb->epthru_dma_addr);
1837
+ dma_free_coherent(&adapter->dev->dev,
1838
+ sizeof(mega_ext_passthru),
1839
+ scb->epthru, scb->epthru_dma_addr);
18411840
18421841 scb->epthru = NULL;
18431842 }
....@@ -1926,9 +1925,9 @@
19261925
19271926 /**
19281927 * megaraid_abort_and_reset()
1929
- * @adapter - megaraid soft state
1930
- * @cmd - scsi command to be aborted or reset
1931
- * @aor - abort or reset flag
1928
+ * @adapter: megaraid soft state
1929
+ * @cmd: scsi command to be aborted or reset
1930
+ * @aor: abort or reset flag
19321931 *
19331932 * Try to locate the scsi command in the pending queue. If found and is not
19341933 * issued to the controller, abort/reset it. Otherwise return failure
....@@ -2010,7 +2009,7 @@
20102009
20112010 memcpy(*pdev, adapter->dev, sizeof(struct pci_dev));
20122011
2013
- if( pci_set_dma_mask(*pdev, DMA_BIT_MASK(32)) != 0 ) {
2012
+ if (dma_set_mask(&(*pdev)->dev, DMA_BIT_MASK(32)) != 0) {
20142013 kfree(*pdev);
20152014 return -1;
20162015 }
....@@ -2026,22 +2025,24 @@
20262025
20272026 /**
20282027 * mega_allocate_inquiry()
2029
- * @dma_handle - handle returned for dma address
2030
- * @pdev - handle to pci device
2028
+ * @dma_handle: handle returned for dma address
2029
+ * @pdev: handle to pci device
20312030 *
20322031 * allocates memory for inquiry structure
20332032 */
20342033 static inline void *
20352034 mega_allocate_inquiry(dma_addr_t *dma_handle, struct pci_dev *pdev)
20362035 {
2037
- return pci_alloc_consistent(pdev, sizeof(mega_inquiry3), dma_handle);
2036
+ return dma_alloc_coherent(&pdev->dev, sizeof(mega_inquiry3),
2037
+ dma_handle, GFP_KERNEL);
20382038 }
20392039
20402040
20412041 static inline void
20422042 mega_free_inquiry(void *inquiry, dma_addr_t dma_handle, struct pci_dev *pdev)
20432043 {
2044
- pci_free_consistent(pdev, sizeof(mega_inquiry3), inquiry, dma_handle);
2044
+ dma_free_coherent(&pdev->dev, sizeof(mega_inquiry3), inquiry,
2045
+ dma_handle);
20452046 }
20462047
20472048
....@@ -2050,8 +2051,8 @@
20502051
20512052 /**
20522053 * proc_show_config()
2053
- * @m - Synthetic file construction data
2054
- * @v - File iterator
2054
+ * @m: Synthetic file construction data
2055
+ * @v: File iterator
20552056 *
20562057 * Display configuration information about the controller.
20572058 */
....@@ -2114,8 +2115,8 @@
21142115
21152116 /**
21162117 * proc_show_stat()
2117
- * @m - Synthetic file construction data
2118
- * @v - File iterator
2118
+ * @m: Synthetic file construction data
2119
+ * @v: File iterator
21192120 *
21202121 * Display statistical information about the I/O activity.
21212122 */
....@@ -2148,8 +2149,8 @@
21482149
21492150 /**
21502151 * proc_show_mbox()
2151
- * @m - Synthetic file construction data
2152
- * @v - File iterator
2152
+ * @m: Synthetic file construction data
2153
+ * @v: File iterator
21532154 *
21542155 * Display mailbox information for the last command issued. This information
21552156 * is good for debugging.
....@@ -2176,8 +2177,8 @@
21762177
21772178 /**
21782179 * proc_show_rebuild_rate()
2179
- * @m - Synthetic file construction data
2180
- * @v - File iterator
2180
+ * @m: Synthetic file construction data
2181
+ * @v: File iterator
21812182 *
21822183 * Display current rebuild rate
21832184 */
....@@ -2219,8 +2220,8 @@
22192220
22202221 /**
22212222 * proc_show_battery()
2222
- * @m - Synthetic file construction data
2223
- * @v - File iterator
2223
+ * @m: Synthetic file construction data
2224
+ * @v: File iterator
22242225 *
22252226 * Display information about the battery module on the controller.
22262227 */
....@@ -2322,9 +2323,9 @@
23222323
23232324 /**
23242325 * proc_show_pdrv()
2325
- * @m - Synthetic file construction data
2326
- * @page - buffer to write the data in
2327
- * @adapter - pointer to our soft state
2326
+ * @m: Synthetic file construction data
2327
+ * @adapter: pointer to our soft state
2328
+ * @channel: channel
23282329 *
23292330 * Display information about the physical drives.
23302331 */
....@@ -2355,7 +2356,8 @@
23552356 }
23562357
23572358
2358
- scsi_inq = pci_alloc_consistent(pdev, 256, &scsi_inq_dma_handle);
2359
+ scsi_inq = dma_alloc_coherent(&pdev->dev, 256, &scsi_inq_dma_handle,
2360
+ GFP_KERNEL);
23592361 if( scsi_inq == NULL ) {
23602362 seq_puts(m, "memory not available for scsi inq.\n");
23612363 goto free_inquiry;
....@@ -2428,7 +2430,7 @@
24282430 }
24292431
24302432 free_pci:
2431
- pci_free_consistent(pdev, 256, scsi_inq, scsi_inq_dma_handle);
2433
+ dma_free_coherent(&pdev->dev, 256, scsi_inq, scsi_inq_dma_handle);
24322434 free_inquiry:
24332435 mega_free_inquiry(inquiry, dma_handle, pdev);
24342436 free_pdev:
....@@ -2438,8 +2440,8 @@
24382440
24392441 /**
24402442 * proc_show_pdrv_ch0()
2441
- * @m - Synthetic file construction data
2442
- * @v - File iterator
2443
+ * @m: Synthetic file construction data
2444
+ * @v: File iterator
24432445 *
24442446 * Display information about the physical drives on physical channel 0.
24452447 */
....@@ -2452,8 +2454,8 @@
24522454
24532455 /**
24542456 * proc_show_pdrv_ch1()
2455
- * @m - Synthetic file construction data
2456
- * @v - File iterator
2457
+ * @m: Synthetic file construction data
2458
+ * @v: File iterator
24572459 *
24582460 * Display information about the physical drives on physical channel 1.
24592461 */
....@@ -2466,8 +2468,8 @@
24662468
24672469 /**
24682470 * proc_show_pdrv_ch2()
2469
- * @m - Synthetic file construction data
2470
- * @v - File iterator
2471
+ * @m: Synthetic file construction data
2472
+ * @v: File iterator
24712473 *
24722474 * Display information about the physical drives on physical channel 2.
24732475 */
....@@ -2480,8 +2482,8 @@
24802482
24812483 /**
24822484 * proc_show_pdrv_ch3()
2483
- * @m - Synthetic file construction data
2484
- * @v - File iterator
2485
+ * @m: Synthetic file construction data
2486
+ * @v: File iterator
24852487 *
24862488 * Display information about the physical drives on physical channel 3.
24872489 */
....@@ -2494,10 +2496,10 @@
24942496
24952497 /**
24962498 * proc_show_rdrv()
2497
- * @m - Synthetic file construction data
2498
- * @adapter - pointer to our soft state
2499
- * @start - starting logical drive to display
2500
- * @end - ending logical drive to display
2499
+ * @m: Synthetic file construction data
2500
+ * @adapter: pointer to our soft state
2501
+ * @start: starting logical drive to display
2502
+ * @end: ending logical drive to display
25012503 *
25022504 * We do not print the inquiry information since its already available through
25032505 * /proc/scsi/scsi interface
....@@ -2548,8 +2550,8 @@
25482550 raid_inq.logdrv_info.num_ldrv;
25492551 }
25502552
2551
- disk_array = pci_alloc_consistent(pdev, array_sz,
2552
- &disk_array_dma_handle);
2553
+ disk_array = dma_alloc_coherent(&pdev->dev, array_sz,
2554
+ &disk_array_dma_handle, GFP_KERNEL);
25532555
25542556 if( disk_array == NULL ) {
25552557 seq_puts(m, "memory not available.\n");
....@@ -2668,8 +2670,8 @@
26682670 }
26692671
26702672 free_pci:
2671
- pci_free_consistent(pdev, array_sz, disk_array,
2672
- disk_array_dma_handle);
2673
+ dma_free_coherent(&pdev->dev, array_sz, disk_array,
2674
+ disk_array_dma_handle);
26732675 free_inquiry:
26742676 mega_free_inquiry(inquiry, dma_handle, pdev);
26752677 free_pdev:
....@@ -2679,8 +2681,8 @@
26792681
26802682 /**
26812683 * proc_show_rdrv_10()
2682
- * @m - Synthetic file construction data
2683
- * @v - File iterator
2684
+ * @m: Synthetic file construction data
2685
+ * @v: File iterator
26842686 *
26852687 * Display real time information about the logical drives 0 through 9.
26862688 */
....@@ -2693,8 +2695,8 @@
26932695
26942696 /**
26952697 * proc_show_rdrv_20()
2696
- * @m - Synthetic file construction data
2697
- * @v - File iterator
2698
+ * @m: Synthetic file construction data
2699
+ * @v: File iterator
26982700 *
26992701 * Display real time information about the logical drives 0 through 9.
27002702 */
....@@ -2707,8 +2709,8 @@
27072709
27082710 /**
27092711 * proc_show_rdrv_30()
2710
- * @m - Synthetic file construction data
2711
- * @v - File iterator
2712
+ * @m: Synthetic file construction data
2713
+ * @v: File iterator
27122714 *
27132715 * Display real time information about the logical drives 0 through 9.
27142716 */
....@@ -2721,8 +2723,8 @@
27212723
27222724 /**
27232725 * proc_show_rdrv_40()
2724
- * @m - Synthetic file construction data
2725
- * @v - File iterator
2726
+ * @m: Synthetic file construction data
2727
+ * @v: File iterator
27262728 *
27272729 * Display real time information about the logical drives 0 through 9.
27282730 */
....@@ -2734,8 +2736,8 @@
27342736
27352737 /**
27362738 * mega_create_proc_entry()
2737
- * @index - index in soft state array
2738
- * @parent - parent node for this /proc entry
2739
+ * @index: index in soft state array
2740
+ * @parent: parent node for this /proc entry
27392741 *
27402742 * Creates /proc entries for our controllers.
27412743 */
....@@ -2790,7 +2792,7 @@
27902792 #endif
27912793
27922794
2793
-/**
2795
+/*
27942796 * megaraid_biosparam()
27952797 *
27962798 * Return the disk geometry for a particular disk
....@@ -2800,11 +2802,9 @@
28002802 sector_t capacity, int geom[])
28012803 {
28022804 adapter_t *adapter;
2803
- unsigned char *bh;
28042805 int heads;
28052806 int sectors;
28062807 int cylinders;
2807
- int rval;
28082808
28092809 /* Get pointer to host config structure */
28102810 adapter = (adapter_t *)sdev->host->hostdata;
....@@ -2831,15 +2831,8 @@
28312831 geom[2] = cylinders;
28322832 }
28332833 else {
2834
- bh = scsi_bios_ptable(bdev);
2835
-
2836
- if( bh ) {
2837
- rval = scsi_partsize(bh, capacity,
2838
- &geom[2], &geom[0], &geom[1]);
2839
- kfree(bh);
2840
- if( rval != -1 )
2841
- return rval;
2842
- }
2834
+ if (scsi_partsize(bdev, capacity, geom))
2835
+ return 0;
28432836
28442837 dev_info(&adapter->dev->dev,
28452838 "invalid partition on this disk on channel %d\n",
....@@ -2868,7 +2861,7 @@
28682861
28692862 /**
28702863 * mega_init_scb()
2871
- * @adapter - pointer to our soft state
2864
+ * @adapter: pointer to our soft state
28722865 *
28732866 * Allocate memory for the various pointers in the scb structures:
28742867 * scatter-gather list pointer, passthru and extended passthru structure
....@@ -2896,9 +2889,9 @@
28962889
28972890 scb->idx = i;
28982891
2899
- scb->sgl64 = pci_alloc_consistent(adapter->dev,
2900
- sizeof(mega_sgl64) * adapter->sglen,
2901
- &scb->sgl_dma_addr);
2892
+ scb->sgl64 = dma_alloc_coherent(&adapter->dev->dev,
2893
+ sizeof(mega_sgl64) * adapter->sglen,
2894
+ &scb->sgl_dma_addr, GFP_KERNEL);
29022895
29032896 scb->sgl = (mega_sglist *)scb->sgl64;
29042897
....@@ -2908,9 +2901,9 @@
29082901 return -1;
29092902 }
29102903
2911
- scb->pthru = pci_alloc_consistent(adapter->dev,
2912
- sizeof(mega_passthru),
2913
- &scb->pthru_dma_addr);
2904
+ scb->pthru = dma_alloc_coherent(&adapter->dev->dev,
2905
+ sizeof(mega_passthru),
2906
+ &scb->pthru_dma_addr, GFP_KERNEL);
29142907
29152908 if( !scb->pthru ) {
29162909 dev_warn(&adapter->dev->dev, "RAID: Can't allocate passthru\n");
....@@ -2918,9 +2911,9 @@
29182911 return -1;
29192912 }
29202913
2921
- scb->epthru = pci_alloc_consistent(adapter->dev,
2922
- sizeof(mega_ext_passthru),
2923
- &scb->epthru_dma_addr);
2914
+ scb->epthru = dma_alloc_coherent(&adapter->dev->dev,
2915
+ sizeof(mega_ext_passthru),
2916
+ &scb->epthru_dma_addr, GFP_KERNEL);
29242917
29252918 if( !scb->epthru ) {
29262919 dev_warn(&adapter->dev->dev,
....@@ -2948,8 +2941,8 @@
29482941
29492942 /**
29502943 * megadev_open()
2951
- * @inode - unused
2952
- * @filep - unused
2944
+ * @inode: unused
2945
+ * @filep: unused
29532946 *
29542947 * Routines for the character/ioctl interface to the driver. Find out if this
29552948 * is a valid open.
....@@ -2968,10 +2961,9 @@
29682961
29692962 /**
29702963 * megadev_ioctl()
2971
- * @inode - Our device inode
2972
- * @filep - unused
2973
- * @cmd - ioctl command
2974
- * @arg - user buffer
2964
+ * @filep: Our device file
2965
+ * @cmd: ioctl command
2966
+ * @arg: user buffer
29752967 *
29762968 * ioctl entry point for our private ioctl interface. We move the data in from
29772969 * the user space, prepare the command (if necessary, convert the old MIMD
....@@ -2991,13 +2983,12 @@
29912983 void *data = NULL; /* data to be transferred */
29922984 dma_addr_t data_dma_hndl; /* dma handle for data xfer area */
29932985 megacmd_t mc;
2994
- megastat_t __user *ustats;
2995
- int num_ldrv;
2986
+#if MEGA_HAVE_STATS
2987
+ megastat_t __user *ustats = NULL;
2988
+ int num_ldrv = 0;
2989
+#endif
29962990 u32 uxferaddr = 0;
29972991 struct pci_dev *pdev;
2998
-
2999
- ustats = NULL; /* avoid compilation warnings */
3000
- num_ldrv = 0;
30012992
30022993 /*
30032994 * Make sure only USCSICMD are issued through this interface.
....@@ -3162,9 +3153,9 @@
31623153 if( uioc.uioc_rmbox[0] == MEGA_MBOXCMD_PASSTHRU ) {
31633154 /* Passthru commands */
31643155
3165
- pthru = pci_alloc_consistent(pdev,
3166
- sizeof(mega_passthru),
3167
- &pthru_dma_hndl);
3156
+ pthru = dma_alloc_coherent(&pdev->dev,
3157
+ sizeof(mega_passthru),
3158
+ &pthru_dma_hndl, GFP_KERNEL);
31683159
31693160 if( pthru == NULL ) {
31703161 free_local_pdev(pdev);
....@@ -3182,9 +3173,9 @@
31823173 if( copy_from_user(pthru, upthru,
31833174 sizeof(mega_passthru)) ) {
31843175
3185
- pci_free_consistent(pdev,
3186
- sizeof(mega_passthru), pthru,
3187
- pthru_dma_hndl);
3176
+ dma_free_coherent(&pdev->dev,
3177
+ sizeof(mega_passthru),
3178
+ pthru, pthru_dma_hndl);
31883179
31893180 free_local_pdev(pdev);
31903181
....@@ -3195,15 +3186,16 @@
31953186 * Is there a data transfer
31963187 */
31973188 if( pthru->dataxferlen ) {
3198
- data = pci_alloc_consistent(pdev,
3199
- pthru->dataxferlen,
3200
- &data_dma_hndl);
3189
+ data = dma_alloc_coherent(&pdev->dev,
3190
+ pthru->dataxferlen,
3191
+ &data_dma_hndl,
3192
+ GFP_KERNEL);
32013193
32023194 if( data == NULL ) {
3203
- pci_free_consistent(pdev,
3204
- sizeof(mega_passthru),
3205
- pthru,
3206
- pthru_dma_hndl);
3195
+ dma_free_coherent(&pdev->dev,
3196
+ sizeof(mega_passthru),
3197
+ pthru,
3198
+ pthru_dma_hndl);
32073199
32083200 free_local_pdev(pdev);
32093201
....@@ -3268,13 +3260,13 @@
32683260
32693261 freemem_and_return:
32703262 if( pthru->dataxferlen ) {
3271
- pci_free_consistent(pdev,
3272
- pthru->dataxferlen, data,
3273
- data_dma_hndl);
3263
+ dma_free_coherent(&pdev->dev,
3264
+ pthru->dataxferlen, data,
3265
+ data_dma_hndl);
32743266 }
32753267
3276
- pci_free_consistent(pdev, sizeof(mega_passthru),
3277
- pthru, pthru_dma_hndl);
3268
+ dma_free_coherent(&pdev->dev, sizeof(mega_passthru),
3269
+ pthru, pthru_dma_hndl);
32783270
32793271 free_local_pdev(pdev);
32803272
....@@ -3287,8 +3279,10 @@
32873279 * Is there a data transfer
32883280 */
32893281 if( uioc.xferlen ) {
3290
- data = pci_alloc_consistent(pdev,
3291
- uioc.xferlen, &data_dma_hndl);
3282
+ data = dma_alloc_coherent(&pdev->dev,
3283
+ uioc.xferlen,
3284
+ &data_dma_hndl,
3285
+ GFP_KERNEL);
32923286
32933287 if( data == NULL ) {
32943288 free_local_pdev(pdev);
....@@ -3308,9 +3302,9 @@
33083302 if( copy_from_user(data, (char __user *)(unsigned long) uxferaddr,
33093303 uioc.xferlen) ) {
33103304
3311
- pci_free_consistent(pdev,
3312
- uioc.xferlen,
3313
- data, data_dma_hndl);
3305
+ dma_free_coherent(&pdev->dev,
3306
+ uioc.xferlen, data,
3307
+ data_dma_hndl);
33143308
33153309 free_local_pdev(pdev);
33163310
....@@ -3331,9 +3325,9 @@
33313325
33323326 if( rval ) {
33333327 if( uioc.xferlen ) {
3334
- pci_free_consistent(pdev,
3335
- uioc.xferlen, data,
3336
- data_dma_hndl);
3328
+ dma_free_coherent(&pdev->dev,
3329
+ uioc.xferlen, data,
3330
+ data_dma_hndl);
33373331 }
33383332
33393333 free_local_pdev(pdev);
....@@ -3353,9 +3347,8 @@
33533347 }
33543348
33553349 if( uioc.xferlen ) {
3356
- pci_free_consistent(pdev,
3357
- uioc.xferlen, data,
3358
- data_dma_hndl);
3350
+ dma_free_coherent(&pdev->dev, uioc.xferlen,
3351
+ data, data_dma_hndl);
33593352 }
33603353
33613354 free_local_pdev(pdev);
....@@ -3384,8 +3377,8 @@
33843377
33853378 /**
33863379 * mega_m_to_n()
3387
- * @arg - user address
3388
- * @uioc - new ioctl structure
3380
+ * @arg: user address
3381
+ * @uioc: new ioctl structure
33893382 *
33903383 * A thin layer to convert older mimd interface ioctl structure to NIT ioctl
33913384 * structure
....@@ -3512,8 +3505,8 @@
35123505
35133506 /*
35143507 * mega_n_to_m()
3515
- * @arg - user address
3516
- * @mc - mailbox command
3508
+ * @arg: user address
3509
+ * @mc: mailbox command
35173510 *
35183511 * Updates the status information to the application, depending on application
35193512 * conforms to older mimd ioctl interface or newer NIT ioctl interface
....@@ -3579,7 +3572,7 @@
35793572
35803573 /**
35813574 * mega_is_bios_enabled()
3582
- * @adapter - pointer to our soft state
3575
+ * @adapter: pointer to our soft state
35833576 *
35843577 * issue command to find out if the BIOS is enabled for this controller
35853578 */
....@@ -3588,7 +3581,6 @@
35883581 {
35893582 unsigned char raw_mbox[sizeof(struct mbox_out)];
35903583 mbox_t *mbox;
3591
- int ret;
35923584
35933585 mbox = (mbox_t *)raw_mbox;
35943586
....@@ -3601,8 +3593,7 @@
36013593 raw_mbox[0] = IS_BIOS_ENABLED;
36023594 raw_mbox[2] = GET_BIOS;
36033595
3604
-
3605
- ret = issue_scb_block(adapter, raw_mbox);
3596
+ issue_scb_block(adapter, raw_mbox);
36063597
36073598 return *(char *)adapter->mega_buffer;
36083599 }
....@@ -3610,7 +3601,7 @@
36103601
36113602 /**
36123603 * mega_enum_raid_scsi()
3613
- * @adapter - pointer to our soft state
3604
+ * @adapter: pointer to our soft state
36143605 *
36153606 * Find out what channels are RAID/SCSI. This information is used to
36163607 * differentiate the virtual channels and physical channels and to support
....@@ -3665,7 +3656,7 @@
36653656
36663657 /**
36673658 * mega_get_boot_drv()
3668
- * @adapter - pointer to our soft state
3659
+ * @adapter: pointer to our soft state
36693660 *
36703661 * Find out which device is the boot device. Note, any logical drive or any
36713662 * phyical device (e.g., a CDROM) can be designated as a boot device.
....@@ -3732,7 +3723,7 @@
37323723
37333724 /**
37343725 * mega_support_random_del()
3735
- * @adapter - pointer to our soft state
3726
+ * @adapter: pointer to our soft state
37363727 *
37373728 * Find out if this controller supports random deletion and addition of
37383729 * logical drives
....@@ -3762,7 +3753,7 @@
37623753
37633754 /**
37643755 * mega_support_ext_cdb()
3765
- * @adapter - pointer to our soft state
3756
+ * @adapter: pointer to our soft state
37663757 *
37673758 * Find out if this firmware support cdblen > 10
37683759 */
....@@ -3790,8 +3781,8 @@
37903781
37913782 /**
37923783 * mega_del_logdrv()
3793
- * @adapter - pointer to our soft state
3794
- * @logdrv - logical drive to be deleted
3784
+ * @adapter: pointer to our soft state
3785
+ * @logdrv: logical drive to be deleted
37953786 *
37963787 * Delete the specified logical drive. It is the responsibility of the user
37973788 * app to let the OS know about this operation.
....@@ -3876,7 +3867,7 @@
38763867
38773868 /**
38783869 * mega_get_max_sgl()
3879
- * @adapter - pointer to our soft state
3870
+ * @adapter: pointer to our soft state
38803871 *
38813872 * Find out the maximum number of scatter-gather elements supported by this
38823873 * version of the firmware
....@@ -3922,7 +3913,7 @@
39223913
39233914 /**
39243915 * mega_support_cluster()
3925
- * @adapter - pointer to our soft state
3916
+ * @adapter: pointer to our soft state
39263917 *
39273918 * Find out if this firmware support cluster calls.
39283919 */
....@@ -3964,8 +3955,8 @@
39643955 #ifdef CONFIG_PROC_FS
39653956 /**
39663957 * mega_adapinq()
3967
- * @adapter - pointer to our soft state
3968
- * @dma_handle - DMA address of the buffer
3958
+ * @adapter: pointer to our soft state
3959
+ * @dma_handle: DMA address of the buffer
39693960 *
39703961 * Issue internal commands while interrupts are available.
39713962 * We only issue direct mailbox commands from within the driver. ioctl()
....@@ -3997,11 +3988,12 @@
39973988 }
39983989
39993990
4000
-/** mega_internal_dev_inquiry()
4001
- * @adapter - pointer to our soft state
4002
- * @ch - channel for this device
4003
- * @tgt - ID of this device
4004
- * @buf_dma_handle - DMA address of the buffer
3991
+/**
3992
+ * mega_internal_dev_inquiry()
3993
+ * @adapter: pointer to our soft state
3994
+ * @ch: channel for this device
3995
+ * @tgt: ID of this device
3996
+ * @buf_dma_handle: DMA address of the buffer
40053997 *
40063998 * Issue the scsi inquiry for the specified device.
40073999 */
....@@ -4022,8 +4014,8 @@
40224014 */
40234015 if( make_local_pdev(adapter, &pdev) != 0 ) return -1;
40244016
4025
- pthru = pci_alloc_consistent(pdev, sizeof(mega_passthru),
4026
- &pthru_dma_handle);
4017
+ pthru = dma_alloc_coherent(&pdev->dev, sizeof(mega_passthru),
4018
+ &pthru_dma_handle, GFP_KERNEL);
40274019
40284020 if( pthru == NULL ) {
40294021 free_local_pdev(pdev);
....@@ -4059,8 +4051,8 @@
40594051
40604052 rval = mega_internal_command(adapter, &mc, pthru);
40614053
4062
- pci_free_consistent(pdev, sizeof(mega_passthru), pthru,
4063
- pthru_dma_handle);
4054
+ dma_free_coherent(&pdev->dev, sizeof(mega_passthru), pthru,
4055
+ pthru_dma_handle);
40644056
40654057 free_local_pdev(pdev);
40664058
....@@ -4070,9 +4062,9 @@
40704062
40714063 /**
40724064 * mega_internal_command()
4073
- * @adapter - pointer to our soft state
4074
- * @mc - the mailbox command
4075
- * @pthru - Passthru structure for DCDB commands
4065
+ * @adapter: pointer to our soft state
4066
+ * @mc: the mailbox command
4067
+ * @pthru: Passthru structure for DCDB commands
40764068 *
40774069 * Issue the internal commands in interrupt mode.
40784070 * The last argument is the address of the passthru structure if the command
....@@ -4148,7 +4140,6 @@
41484140 .this_id = DEFAULT_INITIATOR_ID,
41494141 .sg_tablesize = MAX_SGLIST,
41504142 .cmd_per_lun = DEF_CMD_PER_LUN,
4151
- .use_clustering = ENABLE_CLUSTERING,
41524143 .eh_abort_handler = megaraid_abort,
41534144 .eh_device_reset_handler = megaraid_reset,
41544145 .eh_bus_reset_handler = megaraid_reset,
....@@ -4286,8 +4277,10 @@
42864277 /*
42874278 * Allocate buffer to issue internal commands.
42884279 */
4289
- adapter->mega_buffer = pci_alloc_consistent(adapter->dev,
4290
- MEGA_BUFFER_SIZE, &adapter->buf_dma_handle);
4280
+ adapter->mega_buffer = dma_alloc_coherent(&adapter->dev->dev,
4281
+ MEGA_BUFFER_SIZE,
4282
+ &adapter->buf_dma_handle,
4283
+ GFP_KERNEL);
42914284 if (!adapter->mega_buffer) {
42924285 dev_warn(&pdev->dev, "out of RAM\n");
42934286 goto out_host_put;
....@@ -4446,10 +4439,10 @@
44464439
44474440 /* Set the Mode of addressing to 64 bit if we can */
44484441 if ((adapter->flag & BOARD_64BIT) && (sizeof(dma_addr_t) == 8)) {
4449
- pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
4442
+ dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
44504443 adapter->has_64bit_addr = 1;
44514444 } else {
4452
- pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
4445
+ dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
44534446 adapter->has_64bit_addr = 0;
44544447 }
44554448
....@@ -4488,15 +4481,15 @@
44884481 return 0;
44894482
44904483 out_free_mbox:
4491
- pci_free_consistent(adapter->dev, sizeof(mbox64_t),
4492
- adapter->una_mbox64, adapter->una_mbox64_dma);
4484
+ dma_free_coherent(&adapter->dev->dev, sizeof(mbox64_t),
4485
+ adapter->una_mbox64, adapter->una_mbox64_dma);
44934486 out_free_irq:
44944487 free_irq(adapter->host->irq, adapter);
44954488 out_free_scb_list:
44964489 kfree(adapter->scb_list);
44974490 out_free_cmd_buffer:
4498
- pci_free_consistent(adapter->dev, MEGA_BUFFER_SIZE,
4499
- adapter->mega_buffer, adapter->buf_dma_handle);
4491
+ dma_free_coherent(&adapter->dev->dev, MEGA_BUFFER_SIZE,
4492
+ adapter->mega_buffer, adapter->buf_dma_handle);
45004493 out_host_put:
45014494 scsi_host_put(host);
45024495 out_iounmap:
....@@ -4570,11 +4563,11 @@
45704563 sprintf(buf, "hba%d", adapter->host->host_no);
45714564 remove_proc_subtree(buf, mega_proc_dir_entry);
45724565
4573
- pci_free_consistent(adapter->dev, MEGA_BUFFER_SIZE,
4574
- adapter->mega_buffer, adapter->buf_dma_handle);
4566
+ dma_free_coherent(&adapter->dev->dev, MEGA_BUFFER_SIZE,
4567
+ adapter->mega_buffer, adapter->buf_dma_handle);
45754568 kfree(adapter->scb_list);
4576
- pci_free_consistent(adapter->dev, sizeof(mbox64_t),
4577
- adapter->una_mbox64, adapter->una_mbox64_dma);
4569
+ dma_free_coherent(&adapter->dev->dev, sizeof(mbox64_t),
4570
+ adapter->una_mbox64, adapter->una_mbox64_dma);
45784571
45794572 scsi_host_put(host);
45804573 pci_disable_device(pdev);
....@@ -4641,7 +4634,7 @@
46414634 * major number allocation.
46424635 */
46434636 major = register_chrdev(0, "megadev_legacy", &megadev_fops);
4644
- if (!major) {
4637
+ if (major < 0) {
46454638 printk(KERN_WARNING
46464639 "megaraid: failed to register char device\n");
46474640 }