From patchwork Sun Oct 14 15:59:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10640687 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 516AF13AD for ; Sun, 14 Oct 2018 16:00:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F92729E19 for ; Sun, 14 Oct 2018 16:00:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43E9D29E29; Sun, 14 Oct 2018 16:00:15 +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 D1E4F29E19 for ; Sun, 14 Oct 2018 16:00:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727966AbeJNXll (ORCPT ); Sun, 14 Oct 2018 19:41:41 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:46862 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727386AbeJNXll (ORCPT ); Sun, 14 Oct 2018 19:41:41 -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=zJ88QZH4F/noPkSd/InL6dNUy7cVU0r2CFmtiMnJ9gs=; b=mQmGeLgn+X2QBwMiRdWmd8J6v cxN3jDxKKB16ktoVIc+Ya/B3q8i11cewz1ldOx/dfWhIHa/fU31GXixXdp8wyVYTfR2svTMpjA46q dv6Sgda2nScOpUvukB+k2E8iQODB0lufiEsq98QYPMEJZQPR7ZF2RPHDloexgXva+ADcufVoEnLGp ODk0lGnQx7up4KuTyD8Dd/WistDnuwFAtwk5BYp3n0vZHraboC38TIZMXbqyEfKUJEo15E7Q4vtmV tCf5ZbV1NBm1vrY6ycvqQBnAijhfgqoLN+p+uazJ5e08If5BebK0R2PKBIkCNVXcdx7HpiyfRBPoB 92+bFJSkA==; 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 1gBioP-000298-1y for linux-scsi@vger.kernel.org; Sun, 14 Oct 2018 16:00:13 +0000 From: Christoph Hellwig To: linux-scsi@vger.kernel.org Subject: [PATCH 03/28] 3w-xxx: fully convert to the generic DMA API Date: Sun, 14 Oct 2018 17:59:37 +0200 Message-Id: <20181014160002.8383-4-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 The driver is currently using an odd mix of legacy PCI DMA API and generic DMA API calls, switch it over to the generic API entirely. Signed-off-by: Christoph Hellwig Acked-by: Adam Radford Reviewed-by: Johannes Thumshirn --- drivers/scsi/3w-xxxx.c | 20 ++++++++++++++------ drivers/scsi/3w-xxxx.h | 1 - 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index 471366945bd4..a58257645e94 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c @@ -834,15 +834,17 @@ static int tw_allocate_memory(TW_Device_Extension *tw_dev, int size, int which) dprintk(KERN_NOTICE "3w-xxxx: tw_allocate_memory()\n"); - cpu_addr = pci_alloc_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, &dma_handle); + cpu_addr = dma_alloc_coherent(&tw_dev->tw_pci_dev->dev, + size * TW_Q_LENGTH, &dma_handle, GFP_KERNEL); if (cpu_addr == NULL) { - printk(KERN_WARNING "3w-xxxx: pci_alloc_consistent() failed.\n"); + printk(KERN_WARNING "3w-xxxx: dma_alloc_coherent() failed.\n"); return 1; } if ((unsigned long)cpu_addr % (tw_dev->tw_pci_dev->device == TW_DEVICE_ID ? TW_ALIGNMENT_6000 : TW_ALIGNMENT_7000)) { printk(KERN_WARNING "3w-xxxx: Couldn't allocate correctly aligned memory.\n"); - pci_free_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, cpu_addr, dma_handle); + dma_free_coherent(&tw_dev->tw_pci_dev->dev, size * TW_Q_LENGTH, + cpu_addr, dma_handle); return 1; } @@ -1062,10 +1064,16 @@ static void tw_free_device_extension(TW_Device_Extension *tw_dev) /* Free command packet and generic buffer memory */ if (tw_dev->command_packet_virtual_address[0]) - pci_free_consistent(tw_dev->tw_pci_dev, sizeof(TW_Command)*TW_Q_LENGTH, tw_dev->command_packet_virtual_address[0], tw_dev->command_packet_physical_address[0]); + dma_free_coherent(&tw_dev->tw_pci_dev->dev, + sizeof(TW_Command) * TW_Q_LENGTH, + tw_dev->command_packet_virtual_address[0], + tw_dev->command_packet_physical_address[0]); if (tw_dev->alignment_virtual_address[0]) - pci_free_consistent(tw_dev->tw_pci_dev, sizeof(TW_Sector)*TW_Q_LENGTH, tw_dev->alignment_virtual_address[0], tw_dev->alignment_physical_address[0]); + dma_free_coherent(&tw_dev->tw_pci_dev->dev, + sizeof(TW_Sector) * TW_Q_LENGTH, + tw_dev->alignment_virtual_address[0], + tw_dev->alignment_physical_address[0]); } /* End tw_free_device_extension() */ /* This function will send an initconnection command to controller */ @@ -2260,7 +2268,7 @@ static int tw_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id) pci_set_master(pdev); - retval = pci_set_dma_mask(pdev, TW_DMA_MASK); + retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); if (retval) { printk(KERN_WARNING "3w-xxxx: Failed to set dma mask."); goto out_disable_device; diff --git a/drivers/scsi/3w-xxxx.h b/drivers/scsi/3w-xxxx.h index 69e80c1ed1ca..bd87fbacfbc7 100644 --- a/drivers/scsi/3w-xxxx.h +++ b/drivers/scsi/3w-xxxx.h @@ -230,7 +230,6 @@ static unsigned char tw_sense_table[][4] = #define TW_IOCTL_TIMEOUT 25 /* 25 seconds */ #define TW_IOCTL_CHRDEV_TIMEOUT 60 /* 60 seconds */ #define TW_IOCTL_CHRDEV_FREE -1 -#define TW_DMA_MASK DMA_BIT_MASK(32) #define TW_MAX_CDB_LEN 16 /* Bitmask macros to eliminate bitfields */