From patchwork Sun Oct 14 15:59:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10640691 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 47045933 for ; Sun, 14 Oct 2018 16:00:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45F7929E19 for ; Sun, 14 Oct 2018 16:00:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A2C129E29; Sun, 14 Oct 2018 16:00:21 +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 AE0F729E19 for ; Sun, 14 Oct 2018 16:00:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727747AbeJNXlq (ORCPT ); Sun, 14 Oct 2018 19:41:46 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:46872 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727386AbeJNXlq (ORCPT ); Sun, 14 Oct 2018 19:41:46 -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=FhMSBX9Th2T6lV0TiYrCp1ulkFM/xx6rRIYNeFDe6KY=; b=CDDw1/GE5wkOk1sWq+pE+hDOU J37KbTnN3rtnW2l50FiVgtSZKRfaQfLho4eQiq/LNuBBWk4RTzwEuo1EPpTukVm9U4UeDtAC03YaV 9300XrjBx3zvRdN/tStKd4hTsWWU9i66vfFtoLY9CfqsUAH5rSs5ieBQUthtpozNpV4I0/FM+hfkF qBvy7GKe2oB8gT/D+X9VGdPRmAdqMsS03LyZWJ+62ETKqwv4Wxmi0NeIrxGfyA9pBte/M6pUiiDZS wpJAx91sEC1x6KpzyT9w1ce/UOikdbGDrRrdk3ztT6YRb0PksLH7qQ1NFCZIh3ulTthKe5httwvGe hpUM6XUng==; Received: from 089144199123.atnat0008.highway.a1.net ([89.144.199.123] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gBioU-0002to-B3 for linux-scsi@vger.kernel.org; Sun, 14 Oct 2018 16:00:18 +0000 From: Christoph Hellwig To: linux-scsi@vger.kernel.org Subject: [PATCH 05/28] BusLogic: switch to generic DMA API Date: Sun, 14 Oct 2018 17:59:39 +0200 Message-Id: <20181014160002.8383-6-hch@lst.de> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181014160002.8383-1-hch@lst.de> References: <20181014160002.8383-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/BusLogic.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c index 0d4ffe0ae306..9cee941f97d6 100644 --- a/drivers/scsi/BusLogic.c +++ b/drivers/scsi/BusLogic.c @@ -201,8 +201,8 @@ static bool __init blogic_create_initccbs(struct blogic_adapter *adapter) dma_addr_t blkp; while (adapter->alloc_ccbs < adapter->initccbs) { - blk_pointer = pci_alloc_consistent(adapter->pci_device, - blk_size, &blkp); + blk_pointer = dma_alloc_coherent(&adapter->pci_device->dev, + blk_size, &blkp, GFP_KERNEL); if (blk_pointer == NULL) { blogic_err("UNABLE TO ALLOCATE CCB GROUP - DETACHING\n", adapter); @@ -227,15 +227,16 @@ static void blogic_destroy_ccbs(struct blogic_adapter *adapter) next_ccb = ccb->next_all; if (ccb->allocgrp_head) { if (lastccb) - pci_free_consistent(adapter->pci_device, + dma_free_coherent(&adapter->pci_device->dev, lastccb->allocgrp_size, lastccb, lastccb->allocgrp_head); lastccb = ccb; } } if (lastccb) - pci_free_consistent(adapter->pci_device, lastccb->allocgrp_size, - lastccb, lastccb->allocgrp_head); + dma_free_coherent(&adapter->pci_device->dev, + lastccb->allocgrp_size, lastccb, + lastccb->allocgrp_head); } @@ -256,8 +257,8 @@ static void blogic_create_addlccbs(struct blogic_adapter *adapter, if (addl_ccbs <= 0) return; while (adapter->alloc_ccbs - prev_alloc < addl_ccbs) { - blk_pointer = pci_alloc_consistent(adapter->pci_device, - blk_size, &blkp); + blk_pointer = dma_alloc_coherent(&adapter->pci_device->dev, + blk_size, &blkp, GFP_KERNEL); if (blk_pointer == NULL) break; blogic_init_ccbs(adapter, blk_pointer, blk_size, blkp); @@ -318,8 +319,8 @@ static void blogic_dealloc_ccb(struct blogic_ccb *ccb, int dma_unmap) if (ccb->command != NULL) scsi_dma_unmap(ccb->command); if (dma_unmap) - pci_unmap_single(adapter->pci_device, ccb->sensedata, - ccb->sense_datalen, PCI_DMA_FROMDEVICE); + dma_unmap_single(&adapter->pci_device->dev, ccb->sensedata, + ccb->sense_datalen, DMA_FROM_DEVICE); ccb->command = NULL; ccb->status = BLOGIC_CCB_FREE; @@ -712,7 +713,7 @@ static int __init blogic_init_mm_probeinfo(struct blogic_adapter *adapter) if (pci_enable_device(pci_device)) continue; - if (pci_set_dma_mask(pci_device, DMA_BIT_MASK(32))) + if (dma_set_mask(&pci_device->dev, DMA_BIT_MASK(32))) continue; bus = pci_device->bus->number; @@ -895,7 +896,7 @@ static int __init blogic_init_mm_probeinfo(struct blogic_adapter *adapter) if (pci_enable_device(pci_device)) continue; - if (pci_set_dma_mask(pci_device, DMA_BIT_MASK(32))) + if (dma_set_mask(&pci_device->dev, DMA_BIT_MASK(32))) continue; bus = pci_device->bus->number; @@ -952,7 +953,7 @@ static int __init blogic_init_fp_probeinfo(struct blogic_adapter *adapter) if (pci_enable_device(pci_device)) continue; - if (pci_set_dma_mask(pci_device, DMA_BIT_MASK(32))) + if (dma_set_mask(&pci_device->dev, DMA_BIT_MASK(32))) continue; bus = pci_device->bus->number; @@ -2040,7 +2041,7 @@ static void blogic_relres(struct blogic_adapter *adapter) Release any allocated memory structs not released elsewhere */ if (adapter->mbox_space) - pci_free_consistent(adapter->pci_device, adapter->mbox_sz, + dma_free_coherent(&adapter->pci_device->dev, adapter->mbox_sz, adapter->mbox_space, adapter->mbox_space_handle); pci_dev_put(adapter->pci_device); adapter->mbox_space = NULL; @@ -2092,8 +2093,9 @@ static bool blogic_initadapter(struct blogic_adapter *adapter) Initialize the Outgoing and Incoming Mailbox pointers. */ adapter->mbox_sz = adapter->mbox_count * (sizeof(struct blogic_outbox) + sizeof(struct blogic_inbox)); - adapter->mbox_space = pci_alloc_consistent(adapter->pci_device, - adapter->mbox_sz, &adapter->mbox_space_handle); + adapter->mbox_space = dma_alloc_coherent(&adapter->pci_device->dev, + adapter->mbox_sz, &adapter->mbox_space_handle, + GFP_KERNEL); if (adapter->mbox_space == NULL) return blogic_failure(adapter, "MAILBOX ALLOCATION"); adapter->first_outbox = (struct blogic_outbox *) adapter->mbox_space; @@ -3183,9 +3185,9 @@ static int blogic_qcmd_lck(struct scsi_cmnd *command, memcpy(ccb->cdb, cdb, cdblen); ccb->sense_datalen = SCSI_SENSE_BUFFERSIZE; ccb->command = command; - sense_buf = pci_map_single(adapter->pci_device, + sense_buf = dma_map_single(&adapter->pci_device->dev, command->sense_buffer, ccb->sense_datalen, - PCI_DMA_FROMDEVICE); + DMA_FROM_DEVICE); if (dma_mapping_error(&adapter->pci_device->dev, sense_buf)) { blogic_err("DMA mapping for sense data buffer failed\n", adapter);