| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Linux MegaRAID device driver |
|---|
| 4 | 5 | * |
|---|
| 5 | 6 | * 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. |
|---|
| 11 | 7 | * |
|---|
| 12 | 8 | * Copyright (c) 2002 Red Hat, Inc. All rights reserved. |
|---|
| 13 | 9 | * - fixes |
|---|
| .. | .. |
|---|
| 28 | 24 | * This driver is supported by LSI Logic, with assistance from Red Hat, Dell, |
|---|
| 29 | 25 | * and others. Please send updates to the mailing list |
|---|
| 30 | 26 | * linux-scsi@vger.kernel.org . |
|---|
| 31 | | - * |
|---|
| 32 | 27 | */ |
|---|
| 33 | 28 | |
|---|
| 34 | 29 | #include <linux/mm.h> |
|---|
| .. | .. |
|---|
| 129 | 124 | |
|---|
| 130 | 125 | /** |
|---|
| 131 | 126 | * mega_setup_mailbox() |
|---|
| 132 | | - * @adapter - pointer to our soft state |
|---|
| 127 | + * @adapter: pointer to our soft state |
|---|
| 133 | 128 | * |
|---|
| 134 | 129 | * Allocates a 8 byte aligned memory for the handshake mailbox. |
|---|
| 135 | 130 | */ |
|---|
| .. | .. |
|---|
| 138 | 133 | { |
|---|
| 139 | 134 | unsigned long align; |
|---|
| 140 | 135 | |
|---|
| 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); |
|---|
| 143 | 140 | |
|---|
| 144 | 141 | if( !adapter->una_mbox64 ) return -1; |
|---|
| 145 | 142 | |
|---|
| .. | .. |
|---|
| 227 | 224 | mraid_inquiry *inq; |
|---|
| 228 | 225 | dma_addr_t dma_handle; |
|---|
| 229 | 226 | |
|---|
| 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); |
|---|
| 232 | 230 | |
|---|
| 233 | 231 | if( ext_inq == NULL ) return -1; |
|---|
| 234 | 232 | |
|---|
| .. | .. |
|---|
| 248 | 246 | mega_8_to_40ld(inq, inquiry3, |
|---|
| 249 | 247 | (mega_product_info *)&adapter->product_info); |
|---|
| 250 | 248 | |
|---|
| 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); |
|---|
| 253 | 252 | |
|---|
| 254 | 253 | } else { /*adapter supports 40ld */ |
|---|
| 255 | 254 | adapter->flag |= BOARD_40LD; |
|---|
| .. | .. |
|---|
| 258 | 257 | * get product_info, which is static information and will be |
|---|
| 259 | 258 | * unchanged |
|---|
| 260 | 259 | */ |
|---|
| 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); |
|---|
| 264 | 264 | |
|---|
| 265 | 265 | mbox->m_out.xferaddr = prod_info_dma_handle; |
|---|
| 266 | 266 | |
|---|
| .. | .. |
|---|
| 272 | 272 | "Product_info cmd failed with error: %d\n", |
|---|
| 273 | 273 | retval); |
|---|
| 274 | 274 | |
|---|
| 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); |
|---|
| 277 | 277 | } |
|---|
| 278 | 278 | |
|---|
| 279 | 279 | |
|---|
| .. | .. |
|---|
| 352 | 352 | |
|---|
| 353 | 353 | /** |
|---|
| 354 | 354 | * mega_runpendq() |
|---|
| 355 | | - * @adapter - pointer to our soft state |
|---|
| 355 | + * @adapter: pointer to our soft state |
|---|
| 356 | 356 | * |
|---|
| 357 | 357 | * Runs through the list of pending requests. |
|---|
| 358 | 358 | */ |
|---|
| .. | .. |
|---|
| 418 | 418 | |
|---|
| 419 | 419 | /** |
|---|
| 420 | 420 | * 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 |
|---|
| 423 | 423 | * |
|---|
| 424 | 424 | * Allocate a SCB structure. This is the central structure for controller |
|---|
| 425 | 425 | * commands. |
|---|
| .. | .. |
|---|
| 449 | 449 | |
|---|
| 450 | 450 | /** |
|---|
| 451 | 451 | * 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 |
|---|
| 455 | 455 | * |
|---|
| 456 | 456 | * Calculate the logical drive number based on the information in scsi command |
|---|
| 457 | 457 | * and the channel number. |
|---|
| .. | .. |
|---|
| 496 | 496 | |
|---|
| 497 | 497 | if (adapter->support_random_del && adapter->read_ldidmap ) |
|---|
| 498 | 498 | 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: |
|---|
| 502 | 502 | case WRITE_10: |
|---|
| 503 | 503 | ldrv_num += 0x80; |
|---|
| 504 | 504 | } |
|---|
| .. | .. |
|---|
| 508 | 508 | |
|---|
| 509 | 509 | /** |
|---|
| 510 | 510 | * 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 |
|---|
| 514 | 514 | * |
|---|
| 515 | 515 | * Prepares a command and scatter gather list for the controller. This routine |
|---|
| 516 | 516 | * also finds out if the commands is intended for a logical drive or a |
|---|
| .. | .. |
|---|
| 522 | 522 | static scb_t * |
|---|
| 523 | 523 | mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) |
|---|
| 524 | 524 | { |
|---|
| 525 | | - mega_ext_passthru *epthru; |
|---|
| 526 | 525 | mega_passthru *pthru; |
|---|
| 527 | 526 | scb_t *scb; |
|---|
| 528 | 527 | mbox_t *mbox; |
|---|
| .. | .. |
|---|
| 651 | 650 | scb->raw_mbox[2] = MEGA_RESERVATION_STATUS; |
|---|
| 652 | 651 | scb->raw_mbox[3] = ldrv_num; |
|---|
| 653 | 652 | |
|---|
| 654 | | - scb->dma_direction = PCI_DMA_NONE; |
|---|
| 653 | + scb->dma_direction = DMA_NONE; |
|---|
| 655 | 654 | |
|---|
| 656 | 655 | return scb; |
|---|
| 657 | 656 | #else |
|---|
| .. | .. |
|---|
| 715 | 714 | mbox->m_out.cmd = MEGA_MBOXCMD_PASSTHRU; |
|---|
| 716 | 715 | } |
|---|
| 717 | 716 | |
|---|
| 718 | | - scb->dma_direction = PCI_DMA_FROMDEVICE; |
|---|
| 717 | + scb->dma_direction = DMA_FROM_DEVICE; |
|---|
| 719 | 718 | |
|---|
| 720 | 719 | pthru->numsgelements = mega_build_sglist(adapter, scb, |
|---|
| 721 | 720 | &pthru->dataxferaddr, &pthru->dataxferlen); |
|---|
| .. | .. |
|---|
| 845 | 844 | * If it is a read command |
|---|
| 846 | 845 | */ |
|---|
| 847 | 846 | if( (*cmd->cmnd & 0x0F) == 0x08 ) { |
|---|
| 848 | | - scb->dma_direction = PCI_DMA_FROMDEVICE; |
|---|
| 847 | + scb->dma_direction = DMA_FROM_DEVICE; |
|---|
| 849 | 848 | } |
|---|
| 850 | 849 | else { |
|---|
| 851 | | - scb->dma_direction = PCI_DMA_TODEVICE; |
|---|
| 850 | + scb->dma_direction = DMA_TO_DEVICE; |
|---|
| 852 | 851 | } |
|---|
| 853 | 852 | |
|---|
| 854 | 853 | /* Calculate Scatter-Gather info */ |
|---|
| .. | .. |
|---|
| 858 | 857 | return scb; |
|---|
| 859 | 858 | |
|---|
| 860 | 859 | #if MEGA_HAVE_CLUSTERING |
|---|
| 861 | | - case RESERVE: /* Fall through */ |
|---|
| 860 | + case RESERVE: |
|---|
| 862 | 861 | case RELEASE: |
|---|
| 863 | 862 | |
|---|
| 864 | 863 | /* |
|---|
| .. | .. |
|---|
| 883 | 882 | |
|---|
| 884 | 883 | scb->raw_mbox[3] = ldrv_num; |
|---|
| 885 | 884 | |
|---|
| 886 | | - scb->dma_direction = PCI_DMA_NONE; |
|---|
| 885 | + scb->dma_direction = DMA_NONE; |
|---|
| 887 | 886 | |
|---|
| 888 | 887 | return scb; |
|---|
| 889 | 888 | #endif |
|---|
| .. | .. |
|---|
| 910 | 909 | |
|---|
| 911 | 910 | if( adapter->support_ext_cdb ) { |
|---|
| 912 | 911 | |
|---|
| 913 | | - epthru = mega_prepare_extpassthru(adapter, scb, cmd, |
|---|
| 912 | + mega_prepare_extpassthru(adapter, scb, cmd, |
|---|
| 914 | 913 | channel, target); |
|---|
| 915 | 914 | |
|---|
| 916 | 915 | mbox->m_out.cmd = MEGA_MBOXCMD_EXTPTHRU; |
|---|
| .. | .. |
|---|
| 942 | 941 | |
|---|
| 943 | 942 | /** |
|---|
| 944 | 943 | * 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. |
|---|
| 950 | 949 | * |
|---|
| 951 | 950 | * prepare a command for the scsi physical devices. |
|---|
| 952 | 951 | */ |
|---|
| .. | .. |
|---|
| 977 | 976 | memcpy(pthru->cdb, cmd->cmnd, cmd->cmd_len); |
|---|
| 978 | 977 | |
|---|
| 979 | 978 | /* Not sure about the direction */ |
|---|
| 980 | | - scb->dma_direction = PCI_DMA_BIDIRECTIONAL; |
|---|
| 979 | + scb->dma_direction = DMA_BIDIRECTIONAL; |
|---|
| 981 | 980 | |
|---|
| 982 | 981 | /* Special Code for Handling READ_CAPA/ INQ using bounce buffers */ |
|---|
| 983 | 982 | switch (cmd->cmnd[0]) { |
|---|
| .. | .. |
|---|
| 993 | 992 | |
|---|
| 994 | 993 | adapter->flag |= (1L << cmd->device->channel); |
|---|
| 995 | 994 | } |
|---|
| 996 | | - /* Fall through */ |
|---|
| 995 | + fallthrough; |
|---|
| 997 | 996 | default: |
|---|
| 998 | 997 | pthru->numsgelements = mega_build_sglist(adapter, scb, |
|---|
| 999 | 998 | &pthru->dataxferaddr, &pthru->dataxferlen); |
|---|
| .. | .. |
|---|
| 1005 | 1004 | |
|---|
| 1006 | 1005 | /** |
|---|
| 1007 | 1006 | * 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. |
|---|
| 1013 | 1012 | * |
|---|
| 1014 | 1013 | * prepare a command for the scsi physical devices. This rountine prepares |
|---|
| 1015 | 1014 | * commands for devices which can take extended CDBs (>10 bytes) |
|---|
| .. | .. |
|---|
| 1041 | 1040 | memcpy(epthru->cdb, cmd->cmnd, cmd->cmd_len); |
|---|
| 1042 | 1041 | |
|---|
| 1043 | 1042 | /* Not sure about the direction */ |
|---|
| 1044 | | - scb->dma_direction = PCI_DMA_BIDIRECTIONAL; |
|---|
| 1043 | + scb->dma_direction = DMA_BIDIRECTIONAL; |
|---|
| 1045 | 1044 | |
|---|
| 1046 | 1045 | switch(cmd->cmnd[0]) { |
|---|
| 1047 | 1046 | case INQUIRY: |
|---|
| .. | .. |
|---|
| 1056 | 1055 | |
|---|
| 1057 | 1056 | adapter->flag |= (1L << cmd->device->channel); |
|---|
| 1058 | 1057 | } |
|---|
| 1059 | | - /* Fall through */ |
|---|
| 1058 | + fallthrough; |
|---|
| 1060 | 1059 | default: |
|---|
| 1061 | 1060 | epthru->numsgelements = mega_build_sglist(adapter, scb, |
|---|
| 1062 | 1061 | &epthru->dataxferaddr, &epthru->dataxferlen); |
|---|
| .. | .. |
|---|
| 1090 | 1089 | |
|---|
| 1091 | 1090 | /** |
|---|
| 1092 | 1091 | * 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 |
|---|
| 1095 | 1094 | * |
|---|
| 1096 | 1095 | * Post a command to the card if the mailbox is available, otherwise return |
|---|
| 1097 | 1096 | * busy. We also take the scb from the pending list if the mailbox is |
|---|
| .. | .. |
|---|
| 1171 | 1170 | |
|---|
| 1172 | 1171 | /** |
|---|
| 1173 | 1172 | * 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 |
|---|
| 1176 | 1175 | * |
|---|
| 1177 | 1176 | * Issue a scb in synchronous and non-interrupt mode |
|---|
| 1178 | 1177 | */ |
|---|
| .. | .. |
|---|
| 1252 | 1251 | |
|---|
| 1253 | 1252 | /** |
|---|
| 1254 | 1253 | * megaraid_isr_iomapped() |
|---|
| 1255 | | - * @irq - irq |
|---|
| 1256 | | - * @devp - pointer to our soft state |
|---|
| 1254 | + * @irq: irq |
|---|
| 1255 | + * @devp: pointer to our soft state |
|---|
| 1257 | 1256 | * |
|---|
| 1258 | 1257 | * Interrupt service routine for io-mapped controllers. |
|---|
| 1259 | 1258 | * Find out if our device is interrupting. If yes, acknowledge the interrupt |
|---|
| .. | .. |
|---|
| 1328 | 1327 | |
|---|
| 1329 | 1328 | /** |
|---|
| 1330 | 1329 | * megaraid_isr_memmapped() |
|---|
| 1331 | | - * @irq - irq |
|---|
| 1332 | | - * @devp - pointer to our soft state |
|---|
| 1330 | + * @irq: irq |
|---|
| 1331 | + * @devp: pointer to our soft state |
|---|
| 1333 | 1332 | * |
|---|
| 1334 | 1333 | * Interrupt service routine for memory-mapped controllers. |
|---|
| 1335 | 1334 | * Find out if our device is interrupting. If yes, acknowledge the interrupt |
|---|
| .. | .. |
|---|
| 1406 | 1405 | } |
|---|
| 1407 | 1406 | /** |
|---|
| 1408 | 1407 | * 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 |
|---|
| 1413 | 1412 | * |
|---|
| 1414 | 1413 | * Complete the commands and call the scsi mid-layer callback hooks. |
|---|
| 1415 | 1414 | */ |
|---|
| .. | .. |
|---|
| 1444 | 1443 | */ |
|---|
| 1445 | 1444 | if (cmdid == CMDID_INT_CMDS) { |
|---|
| 1446 | 1445 | scb = &adapter->int_scb; |
|---|
| 1446 | + cmd = scb->cmd; |
|---|
| 1447 | 1447 | |
|---|
| 1448 | 1448 | list_del_init(&scb->list); |
|---|
| 1449 | 1449 | scb->state = SCB_FREE; |
|---|
| .. | .. |
|---|
| 1819 | 1819 | scb = &adapter->scb_list[i]; |
|---|
| 1820 | 1820 | |
|---|
| 1821 | 1821 | if( scb->sgl64 ) { |
|---|
| 1822 | | - pci_free_consistent(adapter->dev, |
|---|
| 1823 | | - sizeof(mega_sgl64) * adapter->sglen, |
|---|
| 1824 | | - scb->sgl64, |
|---|
| 1825 | | - scb->sgl_dma_addr); |
|---|
| 1822 | + dma_free_coherent(&adapter->dev->dev, |
|---|
| 1823 | + sizeof(mega_sgl64) * adapter->sglen, |
|---|
| 1824 | + scb->sgl64, scb->sgl_dma_addr); |
|---|
| 1826 | 1825 | |
|---|
| 1827 | 1826 | scb->sgl64 = NULL; |
|---|
| 1828 | 1827 | } |
|---|
| 1829 | 1828 | |
|---|
| 1830 | 1829 | if( scb->pthru ) { |
|---|
| 1831 | | - pci_free_consistent(adapter->dev, sizeof(mega_passthru), |
|---|
| 1832 | | - scb->pthru, scb->pthru_dma_addr); |
|---|
| 1830 | + dma_free_coherent(&adapter->dev->dev, |
|---|
| 1831 | + sizeof(mega_passthru), scb->pthru, |
|---|
| 1832 | + scb->pthru_dma_addr); |
|---|
| 1833 | 1833 | |
|---|
| 1834 | 1834 | scb->pthru = NULL; |
|---|
| 1835 | 1835 | } |
|---|
| 1836 | 1836 | |
|---|
| 1837 | 1837 | if( scb->epthru ) { |
|---|
| 1838 | | - pci_free_consistent(adapter->dev, |
|---|
| 1839 | | - sizeof(mega_ext_passthru), |
|---|
| 1840 | | - scb->epthru, scb->epthru_dma_addr); |
|---|
| 1838 | + dma_free_coherent(&adapter->dev->dev, |
|---|
| 1839 | + sizeof(mega_ext_passthru), |
|---|
| 1840 | + scb->epthru, scb->epthru_dma_addr); |
|---|
| 1841 | 1841 | |
|---|
| 1842 | 1842 | scb->epthru = NULL; |
|---|
| 1843 | 1843 | } |
|---|
| .. | .. |
|---|
| 1926 | 1926 | |
|---|
| 1927 | 1927 | /** |
|---|
| 1928 | 1928 | * megaraid_abort_and_reset() |
|---|
| 1929 | | - * @adapter - megaraid soft state |
|---|
| 1930 | | - * @cmd - scsi command to be aborted or reset |
|---|
| 1931 | | - * @aor - abort or reset flag |
|---|
| 1929 | + * @adapter: megaraid soft state |
|---|
| 1930 | + * @cmd: scsi command to be aborted or reset |
|---|
| 1931 | + * @aor: abort or reset flag |
|---|
| 1932 | 1932 | * |
|---|
| 1933 | 1933 | * Try to locate the scsi command in the pending queue. If found and is not |
|---|
| 1934 | 1934 | * issued to the controller, abort/reset it. Otherwise return failure |
|---|
| .. | .. |
|---|
| 2010 | 2010 | |
|---|
| 2011 | 2011 | memcpy(*pdev, adapter->dev, sizeof(struct pci_dev)); |
|---|
| 2012 | 2012 | |
|---|
| 2013 | | - if( pci_set_dma_mask(*pdev, DMA_BIT_MASK(32)) != 0 ) { |
|---|
| 2013 | + if (dma_set_mask(&(*pdev)->dev, DMA_BIT_MASK(32)) != 0) { |
|---|
| 2014 | 2014 | kfree(*pdev); |
|---|
| 2015 | 2015 | return -1; |
|---|
| 2016 | 2016 | } |
|---|
| .. | .. |
|---|
| 2026 | 2026 | |
|---|
| 2027 | 2027 | /** |
|---|
| 2028 | 2028 | * mega_allocate_inquiry() |
|---|
| 2029 | | - * @dma_handle - handle returned for dma address |
|---|
| 2030 | | - * @pdev - handle to pci device |
|---|
| 2029 | + * @dma_handle: handle returned for dma address |
|---|
| 2030 | + * @pdev: handle to pci device |
|---|
| 2031 | 2031 | * |
|---|
| 2032 | 2032 | * allocates memory for inquiry structure |
|---|
| 2033 | 2033 | */ |
|---|
| 2034 | 2034 | static inline void * |
|---|
| 2035 | 2035 | mega_allocate_inquiry(dma_addr_t *dma_handle, struct pci_dev *pdev) |
|---|
| 2036 | 2036 | { |
|---|
| 2037 | | - return pci_alloc_consistent(pdev, sizeof(mega_inquiry3), dma_handle); |
|---|
| 2037 | + return dma_alloc_coherent(&pdev->dev, sizeof(mega_inquiry3), |
|---|
| 2038 | + dma_handle, GFP_KERNEL); |
|---|
| 2038 | 2039 | } |
|---|
| 2039 | 2040 | |
|---|
| 2040 | 2041 | |
|---|
| 2041 | 2042 | static inline void |
|---|
| 2042 | 2043 | mega_free_inquiry(void *inquiry, dma_addr_t dma_handle, struct pci_dev *pdev) |
|---|
| 2043 | 2044 | { |
|---|
| 2044 | | - pci_free_consistent(pdev, sizeof(mega_inquiry3), inquiry, dma_handle); |
|---|
| 2045 | + dma_free_coherent(&pdev->dev, sizeof(mega_inquiry3), inquiry, |
|---|
| 2046 | + dma_handle); |
|---|
| 2045 | 2047 | } |
|---|
| 2046 | 2048 | |
|---|
| 2047 | 2049 | |
|---|
| .. | .. |
|---|
| 2050 | 2052 | |
|---|
| 2051 | 2053 | /** |
|---|
| 2052 | 2054 | * proc_show_config() |
|---|
| 2053 | | - * @m - Synthetic file construction data |
|---|
| 2054 | | - * @v - File iterator |
|---|
| 2055 | + * @m: Synthetic file construction data |
|---|
| 2056 | + * @v: File iterator |
|---|
| 2055 | 2057 | * |
|---|
| 2056 | 2058 | * Display configuration information about the controller. |
|---|
| 2057 | 2059 | */ |
|---|
| .. | .. |
|---|
| 2114 | 2116 | |
|---|
| 2115 | 2117 | /** |
|---|
| 2116 | 2118 | * proc_show_stat() |
|---|
| 2117 | | - * @m - Synthetic file construction data |
|---|
| 2118 | | - * @v - File iterator |
|---|
| 2119 | + * @m: Synthetic file construction data |
|---|
| 2120 | + * @v: File iterator |
|---|
| 2119 | 2121 | * |
|---|
| 2120 | 2122 | * Display statistical information about the I/O activity. |
|---|
| 2121 | 2123 | */ |
|---|
| .. | .. |
|---|
| 2148 | 2150 | |
|---|
| 2149 | 2151 | /** |
|---|
| 2150 | 2152 | * proc_show_mbox() |
|---|
| 2151 | | - * @m - Synthetic file construction data |
|---|
| 2152 | | - * @v - File iterator |
|---|
| 2153 | + * @m: Synthetic file construction data |
|---|
| 2154 | + * @v: File iterator |
|---|
| 2153 | 2155 | * |
|---|
| 2154 | 2156 | * Display mailbox information for the last command issued. This information |
|---|
| 2155 | 2157 | * is good for debugging. |
|---|
| .. | .. |
|---|
| 2176 | 2178 | |
|---|
| 2177 | 2179 | /** |
|---|
| 2178 | 2180 | * proc_show_rebuild_rate() |
|---|
| 2179 | | - * @m - Synthetic file construction data |
|---|
| 2180 | | - * @v - File iterator |
|---|
| 2181 | + * @m: Synthetic file construction data |
|---|
| 2182 | + * @v: File iterator |
|---|
| 2181 | 2183 | * |
|---|
| 2182 | 2184 | * Display current rebuild rate |
|---|
| 2183 | 2185 | */ |
|---|
| .. | .. |
|---|
| 2219 | 2221 | |
|---|
| 2220 | 2222 | /** |
|---|
| 2221 | 2223 | * proc_show_battery() |
|---|
| 2222 | | - * @m - Synthetic file construction data |
|---|
| 2223 | | - * @v - File iterator |
|---|
| 2224 | + * @m: Synthetic file construction data |
|---|
| 2225 | + * @v: File iterator |
|---|
| 2224 | 2226 | * |
|---|
| 2225 | 2227 | * Display information about the battery module on the controller. |
|---|
| 2226 | 2228 | */ |
|---|
| .. | .. |
|---|
| 2322 | 2324 | |
|---|
| 2323 | 2325 | /** |
|---|
| 2324 | 2326 | * proc_show_pdrv() |
|---|
| 2325 | | - * @m - Synthetic file construction data |
|---|
| 2326 | | - * @page - buffer to write the data in |
|---|
| 2327 | | - * @adapter - pointer to our soft state |
|---|
| 2327 | + * @m: Synthetic file construction data |
|---|
| 2328 | + * @adapter: pointer to our soft state |
|---|
| 2329 | + * @channel: channel |
|---|
| 2328 | 2330 | * |
|---|
| 2329 | 2331 | * Display information about the physical drives. |
|---|
| 2330 | 2332 | */ |
|---|
| .. | .. |
|---|
| 2355 | 2357 | } |
|---|
| 2356 | 2358 | |
|---|
| 2357 | 2359 | |
|---|
| 2358 | | - scsi_inq = pci_alloc_consistent(pdev, 256, &scsi_inq_dma_handle); |
|---|
| 2360 | + scsi_inq = dma_alloc_coherent(&pdev->dev, 256, &scsi_inq_dma_handle, |
|---|
| 2361 | + GFP_KERNEL); |
|---|
| 2359 | 2362 | if( scsi_inq == NULL ) { |
|---|
| 2360 | 2363 | seq_puts(m, "memory not available for scsi inq.\n"); |
|---|
| 2361 | 2364 | goto free_inquiry; |
|---|
| .. | .. |
|---|
| 2428 | 2431 | } |
|---|
| 2429 | 2432 | |
|---|
| 2430 | 2433 | free_pci: |
|---|
| 2431 | | - pci_free_consistent(pdev, 256, scsi_inq, scsi_inq_dma_handle); |
|---|
| 2434 | + dma_free_coherent(&pdev->dev, 256, scsi_inq, scsi_inq_dma_handle); |
|---|
| 2432 | 2435 | free_inquiry: |
|---|
| 2433 | 2436 | mega_free_inquiry(inquiry, dma_handle, pdev); |
|---|
| 2434 | 2437 | free_pdev: |
|---|
| .. | .. |
|---|
| 2438 | 2441 | |
|---|
| 2439 | 2442 | /** |
|---|
| 2440 | 2443 | * proc_show_pdrv_ch0() |
|---|
| 2441 | | - * @m - Synthetic file construction data |
|---|
| 2442 | | - * @v - File iterator |
|---|
| 2444 | + * @m: Synthetic file construction data |
|---|
| 2445 | + * @v: File iterator |
|---|
| 2443 | 2446 | * |
|---|
| 2444 | 2447 | * Display information about the physical drives on physical channel 0. |
|---|
| 2445 | 2448 | */ |
|---|
| .. | .. |
|---|
| 2452 | 2455 | |
|---|
| 2453 | 2456 | /** |
|---|
| 2454 | 2457 | * proc_show_pdrv_ch1() |
|---|
| 2455 | | - * @m - Synthetic file construction data |
|---|
| 2456 | | - * @v - File iterator |
|---|
| 2458 | + * @m: Synthetic file construction data |
|---|
| 2459 | + * @v: File iterator |
|---|
| 2457 | 2460 | * |
|---|
| 2458 | 2461 | * Display information about the physical drives on physical channel 1. |
|---|
| 2459 | 2462 | */ |
|---|
| .. | .. |
|---|
| 2466 | 2469 | |
|---|
| 2467 | 2470 | /** |
|---|
| 2468 | 2471 | * proc_show_pdrv_ch2() |
|---|
| 2469 | | - * @m - Synthetic file construction data |
|---|
| 2470 | | - * @v - File iterator |
|---|
| 2472 | + * @m: Synthetic file construction data |
|---|
| 2473 | + * @v: File iterator |
|---|
| 2471 | 2474 | * |
|---|
| 2472 | 2475 | * Display information about the physical drives on physical channel 2. |
|---|
| 2473 | 2476 | */ |
|---|
| .. | .. |
|---|
| 2480 | 2483 | |
|---|
| 2481 | 2484 | /** |
|---|
| 2482 | 2485 | * proc_show_pdrv_ch3() |
|---|
| 2483 | | - * @m - Synthetic file construction data |
|---|
| 2484 | | - * @v - File iterator |
|---|
| 2486 | + * @m: Synthetic file construction data |
|---|
| 2487 | + * @v: File iterator |
|---|
| 2485 | 2488 | * |
|---|
| 2486 | 2489 | * Display information about the physical drives on physical channel 3. |
|---|
| 2487 | 2490 | */ |
|---|
| .. | .. |
|---|
| 2494 | 2497 | |
|---|
| 2495 | 2498 | /** |
|---|
| 2496 | 2499 | * 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 |
|---|
| 2500 | + * @m: Synthetic file construction data |
|---|
| 2501 | + * @adapter: pointer to our soft state |
|---|
| 2502 | + * @start: starting logical drive to display |
|---|
| 2503 | + * @end: ending logical drive to display |
|---|
| 2501 | 2504 | * |
|---|
| 2502 | 2505 | * We do not print the inquiry information since its already available through |
|---|
| 2503 | 2506 | * /proc/scsi/scsi interface |
|---|
| .. | .. |
|---|
| 2548 | 2551 | raid_inq.logdrv_info.num_ldrv; |
|---|
| 2549 | 2552 | } |
|---|
| 2550 | 2553 | |
|---|
| 2551 | | - disk_array = pci_alloc_consistent(pdev, array_sz, |
|---|
| 2552 | | - &disk_array_dma_handle); |
|---|
| 2554 | + disk_array = dma_alloc_coherent(&pdev->dev, array_sz, |
|---|
| 2555 | + &disk_array_dma_handle, GFP_KERNEL); |
|---|
| 2553 | 2556 | |
|---|
| 2554 | 2557 | if( disk_array == NULL ) { |
|---|
| 2555 | 2558 | seq_puts(m, "memory not available.\n"); |
|---|
| .. | .. |
|---|
| 2668 | 2671 | } |
|---|
| 2669 | 2672 | |
|---|
| 2670 | 2673 | free_pci: |
|---|
| 2671 | | - pci_free_consistent(pdev, array_sz, disk_array, |
|---|
| 2672 | | - disk_array_dma_handle); |
|---|
| 2674 | + dma_free_coherent(&pdev->dev, array_sz, disk_array, |
|---|
| 2675 | + disk_array_dma_handle); |
|---|
| 2673 | 2676 | free_inquiry: |
|---|
| 2674 | 2677 | mega_free_inquiry(inquiry, dma_handle, pdev); |
|---|
| 2675 | 2678 | free_pdev: |
|---|
| .. | .. |
|---|
| 2679 | 2682 | |
|---|
| 2680 | 2683 | /** |
|---|
| 2681 | 2684 | * proc_show_rdrv_10() |
|---|
| 2682 | | - * @m - Synthetic file construction data |
|---|
| 2683 | | - * @v - File iterator |
|---|
| 2685 | + * @m: Synthetic file construction data |
|---|
| 2686 | + * @v: File iterator |
|---|
| 2684 | 2687 | * |
|---|
| 2685 | 2688 | * Display real time information about the logical drives 0 through 9. |
|---|
| 2686 | 2689 | */ |
|---|
| .. | .. |
|---|
| 2693 | 2696 | |
|---|
| 2694 | 2697 | /** |
|---|
| 2695 | 2698 | * proc_show_rdrv_20() |
|---|
| 2696 | | - * @m - Synthetic file construction data |
|---|
| 2697 | | - * @v - File iterator |
|---|
| 2699 | + * @m: Synthetic file construction data |
|---|
| 2700 | + * @v: File iterator |
|---|
| 2698 | 2701 | * |
|---|
| 2699 | 2702 | * Display real time information about the logical drives 0 through 9. |
|---|
| 2700 | 2703 | */ |
|---|
| .. | .. |
|---|
| 2707 | 2710 | |
|---|
| 2708 | 2711 | /** |
|---|
| 2709 | 2712 | * proc_show_rdrv_30() |
|---|
| 2710 | | - * @m - Synthetic file construction data |
|---|
| 2711 | | - * @v - File iterator |
|---|
| 2713 | + * @m: Synthetic file construction data |
|---|
| 2714 | + * @v: File iterator |
|---|
| 2712 | 2715 | * |
|---|
| 2713 | 2716 | * Display real time information about the logical drives 0 through 9. |
|---|
| 2714 | 2717 | */ |
|---|
| .. | .. |
|---|
| 2721 | 2724 | |
|---|
| 2722 | 2725 | /** |
|---|
| 2723 | 2726 | * proc_show_rdrv_40() |
|---|
| 2724 | | - * @m - Synthetic file construction data |
|---|
| 2725 | | - * @v - File iterator |
|---|
| 2727 | + * @m: Synthetic file construction data |
|---|
| 2728 | + * @v: File iterator |
|---|
| 2726 | 2729 | * |
|---|
| 2727 | 2730 | * Display real time information about the logical drives 0 through 9. |
|---|
| 2728 | 2731 | */ |
|---|
| .. | .. |
|---|
| 2734 | 2737 | |
|---|
| 2735 | 2738 | /** |
|---|
| 2736 | 2739 | * mega_create_proc_entry() |
|---|
| 2737 | | - * @index - index in soft state array |
|---|
| 2738 | | - * @parent - parent node for this /proc entry |
|---|
| 2740 | + * @index: index in soft state array |
|---|
| 2741 | + * @parent: parent node for this /proc entry |
|---|
| 2739 | 2742 | * |
|---|
| 2740 | 2743 | * Creates /proc entries for our controllers. |
|---|
| 2741 | 2744 | */ |
|---|
| .. | .. |
|---|
| 2790 | 2793 | #endif |
|---|
| 2791 | 2794 | |
|---|
| 2792 | 2795 | |
|---|
| 2793 | | -/** |
|---|
| 2796 | +/* |
|---|
| 2794 | 2797 | * megaraid_biosparam() |
|---|
| 2795 | 2798 | * |
|---|
| 2796 | 2799 | * Return the disk geometry for a particular disk |
|---|
| .. | .. |
|---|
| 2800 | 2803 | sector_t capacity, int geom[]) |
|---|
| 2801 | 2804 | { |
|---|
| 2802 | 2805 | adapter_t *adapter; |
|---|
| 2803 | | - unsigned char *bh; |
|---|
| 2804 | 2806 | int heads; |
|---|
| 2805 | 2807 | int sectors; |
|---|
| 2806 | 2808 | int cylinders; |
|---|
| 2807 | | - int rval; |
|---|
| 2808 | 2809 | |
|---|
| 2809 | 2810 | /* Get pointer to host config structure */ |
|---|
| 2810 | 2811 | adapter = (adapter_t *)sdev->host->hostdata; |
|---|
| .. | .. |
|---|
| 2831 | 2832 | geom[2] = cylinders; |
|---|
| 2832 | 2833 | } |
|---|
| 2833 | 2834 | 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 | | - } |
|---|
| 2835 | + if (scsi_partsize(bdev, capacity, geom)) |
|---|
| 2836 | + return 0; |
|---|
| 2843 | 2837 | |
|---|
| 2844 | 2838 | dev_info(&adapter->dev->dev, |
|---|
| 2845 | 2839 | "invalid partition on this disk on channel %d\n", |
|---|
| .. | .. |
|---|
| 2868 | 2862 | |
|---|
| 2869 | 2863 | /** |
|---|
| 2870 | 2864 | * mega_init_scb() |
|---|
| 2871 | | - * @adapter - pointer to our soft state |
|---|
| 2865 | + * @adapter: pointer to our soft state |
|---|
| 2872 | 2866 | * |
|---|
| 2873 | 2867 | * Allocate memory for the various pointers in the scb structures: |
|---|
| 2874 | 2868 | * scatter-gather list pointer, passthru and extended passthru structure |
|---|
| .. | .. |
|---|
| 2896 | 2890 | |
|---|
| 2897 | 2891 | scb->idx = i; |
|---|
| 2898 | 2892 | |
|---|
| 2899 | | - scb->sgl64 = pci_alloc_consistent(adapter->dev, |
|---|
| 2900 | | - sizeof(mega_sgl64) * adapter->sglen, |
|---|
| 2901 | | - &scb->sgl_dma_addr); |
|---|
| 2893 | + scb->sgl64 = dma_alloc_coherent(&adapter->dev->dev, |
|---|
| 2894 | + sizeof(mega_sgl64) * adapter->sglen, |
|---|
| 2895 | + &scb->sgl_dma_addr, GFP_KERNEL); |
|---|
| 2902 | 2896 | |
|---|
| 2903 | 2897 | scb->sgl = (mega_sglist *)scb->sgl64; |
|---|
| 2904 | 2898 | |
|---|
| .. | .. |
|---|
| 2908 | 2902 | return -1; |
|---|
| 2909 | 2903 | } |
|---|
| 2910 | 2904 | |
|---|
| 2911 | | - scb->pthru = pci_alloc_consistent(adapter->dev, |
|---|
| 2912 | | - sizeof(mega_passthru), |
|---|
| 2913 | | - &scb->pthru_dma_addr); |
|---|
| 2905 | + scb->pthru = dma_alloc_coherent(&adapter->dev->dev, |
|---|
| 2906 | + sizeof(mega_passthru), |
|---|
| 2907 | + &scb->pthru_dma_addr, GFP_KERNEL); |
|---|
| 2914 | 2908 | |
|---|
| 2915 | 2909 | if( !scb->pthru ) { |
|---|
| 2916 | 2910 | dev_warn(&adapter->dev->dev, "RAID: Can't allocate passthru\n"); |
|---|
| .. | .. |
|---|
| 2918 | 2912 | return -1; |
|---|
| 2919 | 2913 | } |
|---|
| 2920 | 2914 | |
|---|
| 2921 | | - scb->epthru = pci_alloc_consistent(adapter->dev, |
|---|
| 2922 | | - sizeof(mega_ext_passthru), |
|---|
| 2923 | | - &scb->epthru_dma_addr); |
|---|
| 2915 | + scb->epthru = dma_alloc_coherent(&adapter->dev->dev, |
|---|
| 2916 | + sizeof(mega_ext_passthru), |
|---|
| 2917 | + &scb->epthru_dma_addr, GFP_KERNEL); |
|---|
| 2924 | 2918 | |
|---|
| 2925 | 2919 | if( !scb->epthru ) { |
|---|
| 2926 | 2920 | dev_warn(&adapter->dev->dev, |
|---|
| .. | .. |
|---|
| 2948 | 2942 | |
|---|
| 2949 | 2943 | /** |
|---|
| 2950 | 2944 | * megadev_open() |
|---|
| 2951 | | - * @inode - unused |
|---|
| 2952 | | - * @filep - unused |
|---|
| 2945 | + * @inode: unused |
|---|
| 2946 | + * @filep: unused |
|---|
| 2953 | 2947 | * |
|---|
| 2954 | 2948 | * Routines for the character/ioctl interface to the driver. Find out if this |
|---|
| 2955 | 2949 | * is a valid open. |
|---|
| .. | .. |
|---|
| 2968 | 2962 | |
|---|
| 2969 | 2963 | /** |
|---|
| 2970 | 2964 | * megadev_ioctl() |
|---|
| 2971 | | - * @inode - Our device inode |
|---|
| 2972 | | - * @filep - unused |
|---|
| 2973 | | - * @cmd - ioctl command |
|---|
| 2974 | | - * @arg - user buffer |
|---|
| 2965 | + * @filep: Our device file |
|---|
| 2966 | + * @cmd: ioctl command |
|---|
| 2967 | + * @arg: user buffer |
|---|
| 2975 | 2968 | * |
|---|
| 2976 | 2969 | * ioctl entry point for our private ioctl interface. We move the data in from |
|---|
| 2977 | 2970 | * the user space, prepare the command (if necessary, convert the old MIMD |
|---|
| .. | .. |
|---|
| 2991 | 2984 | void *data = NULL; /* data to be transferred */ |
|---|
| 2992 | 2985 | dma_addr_t data_dma_hndl; /* dma handle for data xfer area */ |
|---|
| 2993 | 2986 | megacmd_t mc; |
|---|
| 2994 | | - megastat_t __user *ustats; |
|---|
| 2995 | | - int num_ldrv; |
|---|
| 2987 | +#if MEGA_HAVE_STATS |
|---|
| 2988 | + megastat_t __user *ustats = NULL; |
|---|
| 2989 | + int num_ldrv = 0; |
|---|
| 2990 | +#endif |
|---|
| 2996 | 2991 | u32 uxferaddr = 0; |
|---|
| 2997 | 2992 | struct pci_dev *pdev; |
|---|
| 2998 | | - |
|---|
| 2999 | | - ustats = NULL; /* avoid compilation warnings */ |
|---|
| 3000 | | - num_ldrv = 0; |
|---|
| 3001 | 2993 | |
|---|
| 3002 | 2994 | /* |
|---|
| 3003 | 2995 | * Make sure only USCSICMD are issued through this interface. |
|---|
| .. | .. |
|---|
| 3162 | 3154 | if( uioc.uioc_rmbox[0] == MEGA_MBOXCMD_PASSTHRU ) { |
|---|
| 3163 | 3155 | /* Passthru commands */ |
|---|
| 3164 | 3156 | |
|---|
| 3165 | | - pthru = pci_alloc_consistent(pdev, |
|---|
| 3166 | | - sizeof(mega_passthru), |
|---|
| 3167 | | - &pthru_dma_hndl); |
|---|
| 3157 | + pthru = dma_alloc_coherent(&pdev->dev, |
|---|
| 3158 | + sizeof(mega_passthru), |
|---|
| 3159 | + &pthru_dma_hndl, GFP_KERNEL); |
|---|
| 3168 | 3160 | |
|---|
| 3169 | 3161 | if( pthru == NULL ) { |
|---|
| 3170 | 3162 | free_local_pdev(pdev); |
|---|
| .. | .. |
|---|
| 3182 | 3174 | if( copy_from_user(pthru, upthru, |
|---|
| 3183 | 3175 | sizeof(mega_passthru)) ) { |
|---|
| 3184 | 3176 | |
|---|
| 3185 | | - pci_free_consistent(pdev, |
|---|
| 3186 | | - sizeof(mega_passthru), pthru, |
|---|
| 3187 | | - pthru_dma_hndl); |
|---|
| 3177 | + dma_free_coherent(&pdev->dev, |
|---|
| 3178 | + sizeof(mega_passthru), |
|---|
| 3179 | + pthru, pthru_dma_hndl); |
|---|
| 3188 | 3180 | |
|---|
| 3189 | 3181 | free_local_pdev(pdev); |
|---|
| 3190 | 3182 | |
|---|
| .. | .. |
|---|
| 3195 | 3187 | * Is there a data transfer |
|---|
| 3196 | 3188 | */ |
|---|
| 3197 | 3189 | if( pthru->dataxferlen ) { |
|---|
| 3198 | | - data = pci_alloc_consistent(pdev, |
|---|
| 3199 | | - pthru->dataxferlen, |
|---|
| 3200 | | - &data_dma_hndl); |
|---|
| 3190 | + data = dma_alloc_coherent(&pdev->dev, |
|---|
| 3191 | + pthru->dataxferlen, |
|---|
| 3192 | + &data_dma_hndl, |
|---|
| 3193 | + GFP_KERNEL); |
|---|
| 3201 | 3194 | |
|---|
| 3202 | 3195 | if( data == NULL ) { |
|---|
| 3203 | | - pci_free_consistent(pdev, |
|---|
| 3204 | | - sizeof(mega_passthru), |
|---|
| 3205 | | - pthru, |
|---|
| 3206 | | - pthru_dma_hndl); |
|---|
| 3196 | + dma_free_coherent(&pdev->dev, |
|---|
| 3197 | + sizeof(mega_passthru), |
|---|
| 3198 | + pthru, |
|---|
| 3199 | + pthru_dma_hndl); |
|---|
| 3207 | 3200 | |
|---|
| 3208 | 3201 | free_local_pdev(pdev); |
|---|
| 3209 | 3202 | |
|---|
| .. | .. |
|---|
| 3268 | 3261 | |
|---|
| 3269 | 3262 | freemem_and_return: |
|---|
| 3270 | 3263 | if( pthru->dataxferlen ) { |
|---|
| 3271 | | - pci_free_consistent(pdev, |
|---|
| 3272 | | - pthru->dataxferlen, data, |
|---|
| 3273 | | - data_dma_hndl); |
|---|
| 3264 | + dma_free_coherent(&pdev->dev, |
|---|
| 3265 | + pthru->dataxferlen, data, |
|---|
| 3266 | + data_dma_hndl); |
|---|
| 3274 | 3267 | } |
|---|
| 3275 | 3268 | |
|---|
| 3276 | | - pci_free_consistent(pdev, sizeof(mega_passthru), |
|---|
| 3277 | | - pthru, pthru_dma_hndl); |
|---|
| 3269 | + dma_free_coherent(&pdev->dev, sizeof(mega_passthru), |
|---|
| 3270 | + pthru, pthru_dma_hndl); |
|---|
| 3278 | 3271 | |
|---|
| 3279 | 3272 | free_local_pdev(pdev); |
|---|
| 3280 | 3273 | |
|---|
| .. | .. |
|---|
| 3287 | 3280 | * Is there a data transfer |
|---|
| 3288 | 3281 | */ |
|---|
| 3289 | 3282 | if( uioc.xferlen ) { |
|---|
| 3290 | | - data = pci_alloc_consistent(pdev, |
|---|
| 3291 | | - uioc.xferlen, &data_dma_hndl); |
|---|
| 3283 | + data = dma_alloc_coherent(&pdev->dev, |
|---|
| 3284 | + uioc.xferlen, |
|---|
| 3285 | + &data_dma_hndl, |
|---|
| 3286 | + GFP_KERNEL); |
|---|
| 3292 | 3287 | |
|---|
| 3293 | 3288 | if( data == NULL ) { |
|---|
| 3294 | 3289 | free_local_pdev(pdev); |
|---|
| .. | .. |
|---|
| 3308 | 3303 | if( copy_from_user(data, (char __user *)(unsigned long) uxferaddr, |
|---|
| 3309 | 3304 | uioc.xferlen) ) { |
|---|
| 3310 | 3305 | |
|---|
| 3311 | | - pci_free_consistent(pdev, |
|---|
| 3312 | | - uioc.xferlen, |
|---|
| 3313 | | - data, data_dma_hndl); |
|---|
| 3306 | + dma_free_coherent(&pdev->dev, |
|---|
| 3307 | + uioc.xferlen, data, |
|---|
| 3308 | + data_dma_hndl); |
|---|
| 3314 | 3309 | |
|---|
| 3315 | 3310 | free_local_pdev(pdev); |
|---|
| 3316 | 3311 | |
|---|
| .. | .. |
|---|
| 3331 | 3326 | |
|---|
| 3332 | 3327 | if( rval ) { |
|---|
| 3333 | 3328 | if( uioc.xferlen ) { |
|---|
| 3334 | | - pci_free_consistent(pdev, |
|---|
| 3335 | | - uioc.xferlen, data, |
|---|
| 3336 | | - data_dma_hndl); |
|---|
| 3329 | + dma_free_coherent(&pdev->dev, |
|---|
| 3330 | + uioc.xferlen, data, |
|---|
| 3331 | + data_dma_hndl); |
|---|
| 3337 | 3332 | } |
|---|
| 3338 | 3333 | |
|---|
| 3339 | 3334 | free_local_pdev(pdev); |
|---|
| .. | .. |
|---|
| 3353 | 3348 | } |
|---|
| 3354 | 3349 | |
|---|
| 3355 | 3350 | if( uioc.xferlen ) { |
|---|
| 3356 | | - pci_free_consistent(pdev, |
|---|
| 3357 | | - uioc.xferlen, data, |
|---|
| 3358 | | - data_dma_hndl); |
|---|
| 3351 | + dma_free_coherent(&pdev->dev, uioc.xferlen, |
|---|
| 3352 | + data, data_dma_hndl); |
|---|
| 3359 | 3353 | } |
|---|
| 3360 | 3354 | |
|---|
| 3361 | 3355 | free_local_pdev(pdev); |
|---|
| .. | .. |
|---|
| 3384 | 3378 | |
|---|
| 3385 | 3379 | /** |
|---|
| 3386 | 3380 | * mega_m_to_n() |
|---|
| 3387 | | - * @arg - user address |
|---|
| 3388 | | - * @uioc - new ioctl structure |
|---|
| 3381 | + * @arg: user address |
|---|
| 3382 | + * @uioc: new ioctl structure |
|---|
| 3389 | 3383 | * |
|---|
| 3390 | 3384 | * A thin layer to convert older mimd interface ioctl structure to NIT ioctl |
|---|
| 3391 | 3385 | * structure |
|---|
| .. | .. |
|---|
| 3512 | 3506 | |
|---|
| 3513 | 3507 | /* |
|---|
| 3514 | 3508 | * mega_n_to_m() |
|---|
| 3515 | | - * @arg - user address |
|---|
| 3516 | | - * @mc - mailbox command |
|---|
| 3509 | + * @arg: user address |
|---|
| 3510 | + * @mc: mailbox command |
|---|
| 3517 | 3511 | * |
|---|
| 3518 | 3512 | * Updates the status information to the application, depending on application |
|---|
| 3519 | 3513 | * conforms to older mimd ioctl interface or newer NIT ioctl interface |
|---|
| .. | .. |
|---|
| 3579 | 3573 | |
|---|
| 3580 | 3574 | /** |
|---|
| 3581 | 3575 | * mega_is_bios_enabled() |
|---|
| 3582 | | - * @adapter - pointer to our soft state |
|---|
| 3576 | + * @adapter: pointer to our soft state |
|---|
| 3583 | 3577 | * |
|---|
| 3584 | 3578 | * issue command to find out if the BIOS is enabled for this controller |
|---|
| 3585 | 3579 | */ |
|---|
| .. | .. |
|---|
| 3588 | 3582 | { |
|---|
| 3589 | 3583 | unsigned char raw_mbox[sizeof(struct mbox_out)]; |
|---|
| 3590 | 3584 | mbox_t *mbox; |
|---|
| 3591 | | - int ret; |
|---|
| 3592 | 3585 | |
|---|
| 3593 | 3586 | mbox = (mbox_t *)raw_mbox; |
|---|
| 3594 | 3587 | |
|---|
| .. | .. |
|---|
| 3601 | 3594 | raw_mbox[0] = IS_BIOS_ENABLED; |
|---|
| 3602 | 3595 | raw_mbox[2] = GET_BIOS; |
|---|
| 3603 | 3596 | |
|---|
| 3604 | | - |
|---|
| 3605 | | - ret = issue_scb_block(adapter, raw_mbox); |
|---|
| 3597 | + issue_scb_block(adapter, raw_mbox); |
|---|
| 3606 | 3598 | |
|---|
| 3607 | 3599 | return *(char *)adapter->mega_buffer; |
|---|
| 3608 | 3600 | } |
|---|
| .. | .. |
|---|
| 3610 | 3602 | |
|---|
| 3611 | 3603 | /** |
|---|
| 3612 | 3604 | * mega_enum_raid_scsi() |
|---|
| 3613 | | - * @adapter - pointer to our soft state |
|---|
| 3605 | + * @adapter: pointer to our soft state |
|---|
| 3614 | 3606 | * |
|---|
| 3615 | 3607 | * Find out what channels are RAID/SCSI. This information is used to |
|---|
| 3616 | 3608 | * differentiate the virtual channels and physical channels and to support |
|---|
| .. | .. |
|---|
| 3665 | 3657 | |
|---|
| 3666 | 3658 | /** |
|---|
| 3667 | 3659 | * mega_get_boot_drv() |
|---|
| 3668 | | - * @adapter - pointer to our soft state |
|---|
| 3660 | + * @adapter: pointer to our soft state |
|---|
| 3669 | 3661 | * |
|---|
| 3670 | 3662 | * Find out which device is the boot device. Note, any logical drive or any |
|---|
| 3671 | 3663 | * phyical device (e.g., a CDROM) can be designated as a boot device. |
|---|
| .. | .. |
|---|
| 3732 | 3724 | |
|---|
| 3733 | 3725 | /** |
|---|
| 3734 | 3726 | * mega_support_random_del() |
|---|
| 3735 | | - * @adapter - pointer to our soft state |
|---|
| 3727 | + * @adapter: pointer to our soft state |
|---|
| 3736 | 3728 | * |
|---|
| 3737 | 3729 | * Find out if this controller supports random deletion and addition of |
|---|
| 3738 | 3730 | * logical drives |
|---|
| .. | .. |
|---|
| 3762 | 3754 | |
|---|
| 3763 | 3755 | /** |
|---|
| 3764 | 3756 | * mega_support_ext_cdb() |
|---|
| 3765 | | - * @adapter - pointer to our soft state |
|---|
| 3757 | + * @adapter: pointer to our soft state |
|---|
| 3766 | 3758 | * |
|---|
| 3767 | 3759 | * Find out if this firmware support cdblen > 10 |
|---|
| 3768 | 3760 | */ |
|---|
| .. | .. |
|---|
| 3790 | 3782 | |
|---|
| 3791 | 3783 | /** |
|---|
| 3792 | 3784 | * mega_del_logdrv() |
|---|
| 3793 | | - * @adapter - pointer to our soft state |
|---|
| 3794 | | - * @logdrv - logical drive to be deleted |
|---|
| 3785 | + * @adapter: pointer to our soft state |
|---|
| 3786 | + * @logdrv: logical drive to be deleted |
|---|
| 3795 | 3787 | * |
|---|
| 3796 | 3788 | * Delete the specified logical drive. It is the responsibility of the user |
|---|
| 3797 | 3789 | * app to let the OS know about this operation. |
|---|
| .. | .. |
|---|
| 3876 | 3868 | |
|---|
| 3877 | 3869 | /** |
|---|
| 3878 | 3870 | * mega_get_max_sgl() |
|---|
| 3879 | | - * @adapter - pointer to our soft state |
|---|
| 3871 | + * @adapter: pointer to our soft state |
|---|
| 3880 | 3872 | * |
|---|
| 3881 | 3873 | * Find out the maximum number of scatter-gather elements supported by this |
|---|
| 3882 | 3874 | * version of the firmware |
|---|
| .. | .. |
|---|
| 3922 | 3914 | |
|---|
| 3923 | 3915 | /** |
|---|
| 3924 | 3916 | * mega_support_cluster() |
|---|
| 3925 | | - * @adapter - pointer to our soft state |
|---|
| 3917 | + * @adapter: pointer to our soft state |
|---|
| 3926 | 3918 | * |
|---|
| 3927 | 3919 | * Find out if this firmware support cluster calls. |
|---|
| 3928 | 3920 | */ |
|---|
| .. | .. |
|---|
| 3964 | 3956 | #ifdef CONFIG_PROC_FS |
|---|
| 3965 | 3957 | /** |
|---|
| 3966 | 3958 | * mega_adapinq() |
|---|
| 3967 | | - * @adapter - pointer to our soft state |
|---|
| 3968 | | - * @dma_handle - DMA address of the buffer |
|---|
| 3959 | + * @adapter: pointer to our soft state |
|---|
| 3960 | + * @dma_handle: DMA address of the buffer |
|---|
| 3969 | 3961 | * |
|---|
| 3970 | 3962 | * Issue internal commands while interrupts are available. |
|---|
| 3971 | 3963 | * We only issue direct mailbox commands from within the driver. ioctl() |
|---|
| .. | .. |
|---|
| 3997 | 3989 | } |
|---|
| 3998 | 3990 | |
|---|
| 3999 | 3991 | |
|---|
| 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 |
|---|
| 3992 | +/** |
|---|
| 3993 | + * mega_internal_dev_inquiry() |
|---|
| 3994 | + * @adapter: pointer to our soft state |
|---|
| 3995 | + * @ch: channel for this device |
|---|
| 3996 | + * @tgt: ID of this device |
|---|
| 3997 | + * @buf_dma_handle: DMA address of the buffer |
|---|
| 4005 | 3998 | * |
|---|
| 4006 | 3999 | * Issue the scsi inquiry for the specified device. |
|---|
| 4007 | 4000 | */ |
|---|
| .. | .. |
|---|
| 4022 | 4015 | */ |
|---|
| 4023 | 4016 | if( make_local_pdev(adapter, &pdev) != 0 ) return -1; |
|---|
| 4024 | 4017 | |
|---|
| 4025 | | - pthru = pci_alloc_consistent(pdev, sizeof(mega_passthru), |
|---|
| 4026 | | - &pthru_dma_handle); |
|---|
| 4018 | + pthru = dma_alloc_coherent(&pdev->dev, sizeof(mega_passthru), |
|---|
| 4019 | + &pthru_dma_handle, GFP_KERNEL); |
|---|
| 4027 | 4020 | |
|---|
| 4028 | 4021 | if( pthru == NULL ) { |
|---|
| 4029 | 4022 | free_local_pdev(pdev); |
|---|
| .. | .. |
|---|
| 4059 | 4052 | |
|---|
| 4060 | 4053 | rval = mega_internal_command(adapter, &mc, pthru); |
|---|
| 4061 | 4054 | |
|---|
| 4062 | | - pci_free_consistent(pdev, sizeof(mega_passthru), pthru, |
|---|
| 4063 | | - pthru_dma_handle); |
|---|
| 4055 | + dma_free_coherent(&pdev->dev, sizeof(mega_passthru), pthru, |
|---|
| 4056 | + pthru_dma_handle); |
|---|
| 4064 | 4057 | |
|---|
| 4065 | 4058 | free_local_pdev(pdev); |
|---|
| 4066 | 4059 | |
|---|
| .. | .. |
|---|
| 4070 | 4063 | |
|---|
| 4071 | 4064 | /** |
|---|
| 4072 | 4065 | * mega_internal_command() |
|---|
| 4073 | | - * @adapter - pointer to our soft state |
|---|
| 4074 | | - * @mc - the mailbox command |
|---|
| 4075 | | - * @pthru - Passthru structure for DCDB commands |
|---|
| 4066 | + * @adapter: pointer to our soft state |
|---|
| 4067 | + * @mc: the mailbox command |
|---|
| 4068 | + * @pthru: Passthru structure for DCDB commands |
|---|
| 4076 | 4069 | * |
|---|
| 4077 | 4070 | * Issue the internal commands in interrupt mode. |
|---|
| 4078 | 4071 | * The last argument is the address of the passthru structure if the command |
|---|
| .. | .. |
|---|
| 4148 | 4141 | .this_id = DEFAULT_INITIATOR_ID, |
|---|
| 4149 | 4142 | .sg_tablesize = MAX_SGLIST, |
|---|
| 4150 | 4143 | .cmd_per_lun = DEF_CMD_PER_LUN, |
|---|
| 4151 | | - .use_clustering = ENABLE_CLUSTERING, |
|---|
| 4152 | 4144 | .eh_abort_handler = megaraid_abort, |
|---|
| 4153 | 4145 | .eh_device_reset_handler = megaraid_reset, |
|---|
| 4154 | 4146 | .eh_bus_reset_handler = megaraid_reset, |
|---|
| .. | .. |
|---|
| 4286 | 4278 | /* |
|---|
| 4287 | 4279 | * Allocate buffer to issue internal commands. |
|---|
| 4288 | 4280 | */ |
|---|
| 4289 | | - adapter->mega_buffer = pci_alloc_consistent(adapter->dev, |
|---|
| 4290 | | - MEGA_BUFFER_SIZE, &adapter->buf_dma_handle); |
|---|
| 4281 | + adapter->mega_buffer = dma_alloc_coherent(&adapter->dev->dev, |
|---|
| 4282 | + MEGA_BUFFER_SIZE, |
|---|
| 4283 | + &adapter->buf_dma_handle, |
|---|
| 4284 | + GFP_KERNEL); |
|---|
| 4291 | 4285 | if (!adapter->mega_buffer) { |
|---|
| 4292 | 4286 | dev_warn(&pdev->dev, "out of RAM\n"); |
|---|
| 4293 | 4287 | goto out_host_put; |
|---|
| .. | .. |
|---|
| 4446 | 4440 | |
|---|
| 4447 | 4441 | /* Set the Mode of addressing to 64 bit if we can */ |
|---|
| 4448 | 4442 | if ((adapter->flag & BOARD_64BIT) && (sizeof(dma_addr_t) == 8)) { |
|---|
| 4449 | | - pci_set_dma_mask(pdev, DMA_BIT_MASK(64)); |
|---|
| 4443 | + dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); |
|---|
| 4450 | 4444 | adapter->has_64bit_addr = 1; |
|---|
| 4451 | 4445 | } else { |
|---|
| 4452 | | - pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
|---|
| 4446 | + dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); |
|---|
| 4453 | 4447 | adapter->has_64bit_addr = 0; |
|---|
| 4454 | 4448 | } |
|---|
| 4455 | 4449 | |
|---|
| .. | .. |
|---|
| 4488 | 4482 | return 0; |
|---|
| 4489 | 4483 | |
|---|
| 4490 | 4484 | out_free_mbox: |
|---|
| 4491 | | - pci_free_consistent(adapter->dev, sizeof(mbox64_t), |
|---|
| 4492 | | - adapter->una_mbox64, adapter->una_mbox64_dma); |
|---|
| 4485 | + dma_free_coherent(&adapter->dev->dev, sizeof(mbox64_t), |
|---|
| 4486 | + adapter->una_mbox64, adapter->una_mbox64_dma); |
|---|
| 4493 | 4487 | out_free_irq: |
|---|
| 4494 | 4488 | free_irq(adapter->host->irq, adapter); |
|---|
| 4495 | 4489 | out_free_scb_list: |
|---|
| 4496 | 4490 | kfree(adapter->scb_list); |
|---|
| 4497 | 4491 | out_free_cmd_buffer: |
|---|
| 4498 | | - pci_free_consistent(adapter->dev, MEGA_BUFFER_SIZE, |
|---|
| 4499 | | - adapter->mega_buffer, adapter->buf_dma_handle); |
|---|
| 4492 | + dma_free_coherent(&adapter->dev->dev, MEGA_BUFFER_SIZE, |
|---|
| 4493 | + adapter->mega_buffer, adapter->buf_dma_handle); |
|---|
| 4500 | 4494 | out_host_put: |
|---|
| 4501 | 4495 | scsi_host_put(host); |
|---|
| 4502 | 4496 | out_iounmap: |
|---|
| .. | .. |
|---|
| 4570 | 4564 | sprintf(buf, "hba%d", adapter->host->host_no); |
|---|
| 4571 | 4565 | remove_proc_subtree(buf, mega_proc_dir_entry); |
|---|
| 4572 | 4566 | |
|---|
| 4573 | | - pci_free_consistent(adapter->dev, MEGA_BUFFER_SIZE, |
|---|
| 4574 | | - adapter->mega_buffer, adapter->buf_dma_handle); |
|---|
| 4567 | + dma_free_coherent(&adapter->dev->dev, MEGA_BUFFER_SIZE, |
|---|
| 4568 | + adapter->mega_buffer, adapter->buf_dma_handle); |
|---|
| 4575 | 4569 | kfree(adapter->scb_list); |
|---|
| 4576 | | - pci_free_consistent(adapter->dev, sizeof(mbox64_t), |
|---|
| 4577 | | - adapter->una_mbox64, adapter->una_mbox64_dma); |
|---|
| 4570 | + dma_free_coherent(&adapter->dev->dev, sizeof(mbox64_t), |
|---|
| 4571 | + adapter->una_mbox64, adapter->una_mbox64_dma); |
|---|
| 4578 | 4572 | |
|---|
| 4579 | 4573 | scsi_host_put(host); |
|---|
| 4580 | 4574 | pci_disable_device(pdev); |
|---|
| .. | .. |
|---|
| 4641 | 4635 | * major number allocation. |
|---|
| 4642 | 4636 | */ |
|---|
| 4643 | 4637 | major = register_chrdev(0, "megadev_legacy", &megadev_fops); |
|---|
| 4644 | | - if (!major) { |
|---|
| 4638 | + if (major < 0) { |
|---|
| 4645 | 4639 | printk(KERN_WARNING |
|---|
| 4646 | 4640 | "megaraid: failed to register char device\n"); |
|---|
| 4647 | 4641 | } |
|---|