From patchwork Thu Oct 11 18:49:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10637155 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CFA86112B for ; Thu, 11 Oct 2018 18:50:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD26C2BF8A for ; Thu, 11 Oct 2018 18:50:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBA342BF9A; Thu, 11 Oct 2018 18:50:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B9C72BFA5 for ; Thu, 11 Oct 2018 18:50:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729751AbeJLCTP (ORCPT ); Thu, 11 Oct 2018 22:19:15 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35646 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727569AbeJLCTP (ORCPT ); Thu, 11 Oct 2018 22:19:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender: Reply-To:Cc:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=tI0rzVJxQrq/h0zpDpyO4hDgsfqmxToKCPjyoj9gAuw=; b=K27jwe6XsQX8eOYyJCgoTH1Vi tCIqBQcJoRGxffhNkuTV+vRQe13X67awfROJPxOTOshiPdV8jf0oXMHNf/mpebxvqsDFpP7mDbi/n Av+c30DwkkZQBSEDEuKrHbr2jSBEoYUCVF02+GJ2WFpriOkg9nx5hAaFbvOswXmB6+MQyIJF5lzmo SjbQ6Gd8JVZFD529DvY+qJYsgM3nZimLqHbzQdXe5KMSyQY8PqbvmyOiixjerLbZzxZmzMXasdTiM oPrv41jfefteIOPzJREvoJUp1FvkvZdNNwwMkSTk6o+CW/ZSXf+etI0PdykngAWH6LG2aVfrLoQNC ouWMO5yow==; Received: from 089144207060.atnat0016.highway.bob.at ([89.144.207.60] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gAg2o-0001mT-O1 for linux-scsi@vger.kernel.org; Thu, 11 Oct 2018 18:50:47 +0000 From: Christoph Hellwig To: linux-scsi@vger.kernel.org Subject: [PATCH 12/28] megaraid_mbox: switch to generic DMA API Date: Thu, 11 Oct 2018 20:49:47 +0200 Message-Id: <20181011185003.16116-13-hch@lst.de> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181011185003.16116-1-hch@lst.de> References: <20181011185003.16116-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Switch from the legacy PCI DMA API to the generic DMA API. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- drivers/scsi/megaraid/megaraid_mbox.c | 51 +++++++++++++-------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index 89c85a5a47af..fbae1d88a29b 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c @@ -457,10 +457,9 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) // Setup the default DMA mask. This would be changed later on // depending on hardware capabilities - if (pci_set_dma_mask(adapter->pdev, DMA_BIT_MASK(32)) != 0) { - + if (dma_set_mask(&adapter->pdev->dev, DMA_BIT_MASK(32))) { con_log(CL_ANN, (KERN_WARNING - "megaraid: pci_set_dma_mask failed:%d\n", __LINE__)); + "megaraid: dma_set_mask failed:%d\n", __LINE__)); goto out_free_adapter; } @@ -878,11 +877,12 @@ megaraid_init_mbox(adapter_t *adapter) adapter->pdev->device == PCI_DEVICE_ID_PERC4_DI_EVERGLADES) || (adapter->pdev->vendor == PCI_VENDOR_ID_DELL && adapter->pdev->device == PCI_DEVICE_ID_PERC4E_DI_KOBUK)) { - if (pci_set_dma_mask(adapter->pdev, DMA_BIT_MASK(64))) { + if (dma_set_mask(&adapter->pdev->dev, DMA_BIT_MASK(64))) { con_log(CL_ANN, (KERN_WARNING "megaraid: DMA mask for 64-bit failed\n")); - if (pci_set_dma_mask (adapter->pdev, DMA_BIT_MASK(32))) { + if (dma_set_mask(&adapter->pdev->dev, + DMA_BIT_MASK(32))) { con_log(CL_ANN, (KERN_WARNING "megaraid: 32-bit DMA mask failed\n")); goto out_free_sysfs_res; @@ -975,9 +975,9 @@ megaraid_alloc_cmd_packets(adapter_t *adapter) * Allocate the common 16-byte aligned memory for the handshake * mailbox. */ - raid_dev->una_mbox64 = pci_zalloc_consistent(adapter->pdev, - sizeof(mbox64_t), - &raid_dev->una_mbox64_dma); + raid_dev->una_mbox64 = dma_zalloc_coherent(&adapter->pdev->dev, + sizeof(mbox64_t), &raid_dev->una_mbox64_dma, + GFP_KERNEL); if (!raid_dev->una_mbox64) { con_log(CL_ANN, (KERN_WARNING @@ -1003,8 +1003,8 @@ megaraid_alloc_cmd_packets(adapter_t *adapter) align; // Allocate memory for commands issued internally - adapter->ibuf = pci_zalloc_consistent(pdev, MBOX_IBUF_SIZE, - &adapter->ibuf_dma_h); + adapter->ibuf = dma_zalloc_coherent(&pdev->dev, MBOX_IBUF_SIZE, + &adapter->ibuf_dma_h, GFP_KERNEL); if (!adapter->ibuf) { con_log(CL_ANN, (KERN_WARNING @@ -1082,7 +1082,7 @@ megaraid_alloc_cmd_packets(adapter_t *adapter) scb->scp = NULL; scb->state = SCB_FREE; - scb->dma_direction = PCI_DMA_NONE; + scb->dma_direction = DMA_NONE; scb->dma_type = MRAID_DMA_NONE; scb->dev_channel = -1; scb->dev_target = -1; @@ -1098,10 +1098,10 @@ megaraid_alloc_cmd_packets(adapter_t *adapter) out_free_scb_list: kfree(adapter->kscb_list); out_free_ibuf: - pci_free_consistent(pdev, MBOX_IBUF_SIZE, (void *)adapter->ibuf, + dma_free_coherent(&pdev->dev, MBOX_IBUF_SIZE, (void *)adapter->ibuf, adapter->ibuf_dma_h); out_free_common_mbox: - pci_free_consistent(adapter->pdev, sizeof(mbox64_t), + dma_free_coherent(&adapter->pdev->dev, sizeof(mbox64_t), (caddr_t)raid_dev->una_mbox64, raid_dev->una_mbox64_dma); return -1; @@ -1123,10 +1123,10 @@ megaraid_free_cmd_packets(adapter_t *adapter) kfree(adapter->kscb_list); - pci_free_consistent(adapter->pdev, MBOX_IBUF_SIZE, + dma_free_coherent(&adapter->pdev->dev, MBOX_IBUF_SIZE, (void *)adapter->ibuf, adapter->ibuf_dma_h); - pci_free_consistent(adapter->pdev, sizeof(mbox64_t), + dma_free_coherent(&adapter->pdev->dev, sizeof(mbox64_t), (caddr_t)raid_dev->una_mbox64, raid_dev->una_mbox64_dma); return; } @@ -2915,9 +2915,8 @@ megaraid_mbox_product_info(adapter_t *adapter) * Issue an ENQUIRY3 command to find out certain adapter parameters, * e.g., max channels, max commands etc. */ - pinfo = pci_zalloc_consistent(adapter->pdev, sizeof(mraid_pinfo_t), - &pinfo_dma_h); - + pinfo = dma_zalloc_coherent(&adapter->pdev->dev, sizeof(mraid_pinfo_t), + &pinfo_dma_h, GFP_KERNEL); if (pinfo == NULL) { con_log(CL_ANN, (KERN_WARNING "megaraid: out of memory, %s %d\n", __func__, @@ -2938,7 +2937,7 @@ megaraid_mbox_product_info(adapter_t *adapter) con_log(CL_ANN, (KERN_WARNING "megaraid: Inquiry3 failed\n")); - pci_free_consistent(adapter->pdev, sizeof(mraid_pinfo_t), + dma_free_coherent(&adapter->pdev->dev, sizeof(mraid_pinfo_t), pinfo, pinfo_dma_h); return -1; @@ -2969,7 +2968,7 @@ megaraid_mbox_product_info(adapter_t *adapter) con_log(CL_ANN, (KERN_WARNING "megaraid: product info failed\n")); - pci_free_consistent(adapter->pdev, sizeof(mraid_pinfo_t), + dma_free_coherent(&adapter->pdev->dev, sizeof(mraid_pinfo_t), pinfo, pinfo_dma_h); return -1; @@ -3005,7 +3004,7 @@ megaraid_mbox_product_info(adapter_t *adapter) "megaraid: fw version:[%s] bios version:[%s]\n", adapter->fw_version, adapter->bios_version)); - pci_free_consistent(adapter->pdev, sizeof(mraid_pinfo_t), pinfo, + dma_free_coherent(&adapter->pdev->dev, sizeof(mraid_pinfo_t), pinfo, pinfo_dma_h); return 0; @@ -3482,7 +3481,7 @@ megaraid_cmm_register(adapter_t *adapter) scb->scp = NULL; scb->state = SCB_FREE; - scb->dma_direction = PCI_DMA_NONE; + scb->dma_direction = DMA_NONE; scb->dma_type = MRAID_DMA_NONE; scb->dev_channel = -1; scb->dev_target = -1; @@ -3620,7 +3619,7 @@ megaraid_mbox_mm_command(adapter_t *adapter, uioc_t *kioc) scb->state = SCB_ACTIVE; scb->dma_type = MRAID_DMA_NONE; - scb->dma_direction = PCI_DMA_NONE; + scb->dma_direction = DMA_NONE; ccb = (mbox_ccb_t *)scb->ccb; mbox64 = (mbox64_t *)(unsigned long)kioc->cmdbuf; @@ -3810,8 +3809,8 @@ megaraid_sysfs_alloc_resources(adapter_t *adapter) raid_dev->sysfs_mbox64 = kmalloc(sizeof(mbox64_t), GFP_KERNEL); - raid_dev->sysfs_buffer = pci_alloc_consistent(adapter->pdev, - PAGE_SIZE, &raid_dev->sysfs_buffer_dma); + raid_dev->sysfs_buffer = dma_alloc_coherent(&adapter->pdev->dev, + PAGE_SIZE, &raid_dev->sysfs_buffer_dma, GFP_KERNEL); if (!raid_dev->sysfs_uioc || !raid_dev->sysfs_mbox64 || !raid_dev->sysfs_buffer) { @@ -3848,7 +3847,7 @@ megaraid_sysfs_free_resources(adapter_t *adapter) kfree(raid_dev->sysfs_mbox64); if (raid_dev->sysfs_buffer) { - pci_free_consistent(adapter->pdev, PAGE_SIZE, + dma_free_coherent(&adapter->pdev->dev, PAGE_SIZE, raid_dev->sysfs_buffer, raid_dev->sysfs_buffer_dma); } }