From patchwork Wed Feb 4 14:09:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Lambert X-Patchwork-Id: 5776751 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BBB879F336 for ; Wed, 4 Feb 2015 14:09:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 92D502026F for ; Wed, 4 Feb 2015 14:09:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A83620259 for ; Wed, 4 Feb 2015 14:09:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754632AbbBDOJF (ORCPT ); Wed, 4 Feb 2015 09:09:05 -0500 Received: from mail-we0-f171.google.com ([74.125.82.171]:38284 "EHLO mail-we0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751271AbbBDOJD (ORCPT ); Wed, 4 Feb 2015 09:09:03 -0500 Received: by mail-we0-f171.google.com with SMTP id k11so1988157wes.2; Wed, 04 Feb 2015 06:09:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=Ou3C/gghSFGA8SI4Y6Qei03Zc15raXDhkr22Q2SBsEs=; b=lBxh5iITkPq9HTSv6xx12y/MU7IMIeq6ALctiDCOvRV5RvICpiEqw8VZeDAYmotFP9 SkO27GK37tVX/GRuYoRh3gObLBrK+5Zbdy4fd0Sttx4Nbo4waNZ5b7RNUnSIePCokTZ/ OmCbULVV3x6RGVbbMrRoUlpwzA9osK+q/v9nJ3kcSPqWlhZyU6r5Dz+y4vM//loZxXn3 rYknEahq84w76yFPoX443OLL24I+YD9ZI6XgtP6jXGK+dZSjHaQs568toc6UKuR8Dz+W WzUBInq8QuV9afM41wuiyNJSABJ06/flQetMN8jpfxFuNmlx/dvkiqLlgSrnO0eiKVYW 2/1g== X-Received: by 10.180.79.65 with SMTP id h1mr4699038wix.59.1423058941379; Wed, 04 Feb 2015 06:09:01 -0800 (PST) Received: from sloth (hp-quentin.rsr.lip6.fr. [132.227.76.76]) by mx.google.com with ESMTPSA id ha1sm29403807wib.24.2015.02.04.06.09.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Feb 2015 06:09:00 -0800 (PST) Date: Wed, 4 Feb 2015 15:09:11 +0100 From: Quentin Lambert To: Roland Dreier , Sean Hefty , Hal Rosenstock Cc: kernel-janitors@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/1] IB/mthca: remove deprecated use of pci api Message-ID: <20150204140911.GA23076@sloth> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Replace occurences of the pci api by appropriate call to the dma api. A simplified version of the semantic patch that finds this problem is as follows: (http://coccinelle.lip6.fr) @deprecated@ idexpression id; position p; @@ ( pci_dma_supported@p ( id, ...) | pci_alloc_consistent@p ( id, ...) ) @bad1@ idexpression id; position deprecated.p; @@ ...when != &id->dev when != pci_get_drvdata ( id ) when != pci_enable_device ( id ) ( pci_dma_supported@p ( id, ...) | pci_alloc_consistent@p ( id, ...) ) @depends on !bad1@ idexpression id; expression direction; position deprecated.p; @@ ( - pci_dma_supported@p ( id, + dma_supported ( &id->dev, ... + , GFP_ATOMIC ) | - pci_alloc_consistent@p ( id, + dma_alloc_coherent ( &id->dev, ... + , GFP_ATOMIC ) ) Signed-off-by: Quentin Lambert --- drivers/infiniband/hw/mthca/mthca_eq.c | 20 ++++++++++++-------- drivers/infiniband/hw/mthca/mthca_main.c | 8 ++++---- drivers/infiniband/hw/mthca/mthca_memfree.c | 23 ++++++++++++++--------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c index 6902017..cd99e8c 100644 --- a/drivers/infiniband/hw/mthca/mthca_eq.c +++ b/drivers/infiniband/hw/mthca/mthca_eq.c @@ -617,7 +617,7 @@ static void mthca_free_eq(struct mthca_dev *dev, mthca_free_mr(dev, &eq->mr); for (i = 0; i < npages; ++i) - pci_free_consistent(dev->pdev, PAGE_SIZE, + dma_free_coherent(&dev->pdev->dev, PAGE_SIZE, eq->page_list[i].buf, dma_unmap_addr(&eq->page_list[i], mapping)); @@ -739,17 +739,21 @@ int mthca_map_eq_icm(struct mthca_dev *dev, u64 icm_virt) dev->eq_table.icm_page = alloc_page(GFP_HIGHUSER); if (!dev->eq_table.icm_page) return -ENOMEM; - dev->eq_table.icm_dma = pci_map_page(dev->pdev, dev->eq_table.icm_page, 0, - PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); - if (pci_dma_mapping_error(dev->pdev, dev->eq_table.icm_dma)) { + dev->eq_table.icm_dma = dma_map_page(&dev->pdev->dev, + dev->eq_table.icm_page, 0, + PAGE_SIZE, + (enum dma_data_direction)PCI_DMA_BIDIRECTIONAL); + + if (dma_mapping_error(&dev->pdev->dev, dev->eq_table.icm_dma)) { __free_page(dev->eq_table.icm_page); return -ENOMEM; } ret = mthca_MAP_ICM_page(dev, dev->eq_table.icm_dma, icm_virt); if (ret) { - pci_unmap_page(dev->pdev, dev->eq_table.icm_dma, PAGE_SIZE, - PCI_DMA_BIDIRECTIONAL); + dma_unmap_page(&dev->pdev->dev, dev->eq_table.icm_dma, + PAGE_SIZE, + (enum dma_data_direction)PCI_DMA_BIDIRECTIONAL); __free_page(dev->eq_table.icm_page); } @@ -759,8 +763,8 @@ int mthca_map_eq_icm(struct mthca_dev *dev, u64 icm_virt) void mthca_unmap_eq_icm(struct mthca_dev *dev) { mthca_UNMAP_ICM(dev, dev->eq_table.icm_virt, 1); - pci_unmap_page(dev->pdev, dev->eq_table.icm_dma, PAGE_SIZE, - PCI_DMA_BIDIRECTIONAL); + dma_unmap_page(&dev->pdev->dev, dev->eq_table.icm_dma, PAGE_SIZE, + (enum dma_data_direction)PCI_DMA_BIDIRECTIONAL); __free_page(dev->eq_table.icm_page); } diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c index ded76c1..2b52416 100644 --- a/drivers/infiniband/hw/mthca/mthca_main.c +++ b/drivers/infiniband/hw/mthca/mthca_main.c @@ -940,20 +940,20 @@ static int __mthca_init_one(struct pci_dev *pdev, int hca_type) pci_set_master(pdev); - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64)); + err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); if (err) { dev_warn(&pdev->dev, "Warning: couldn't set 64-bit PCI DMA mask.\n"); - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); + err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); if (err) { dev_err(&pdev->dev, "Can't set PCI DMA mask, aborting.\n"); goto err_free_res; } } - err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); + err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); if (err) { dev_warn(&pdev->dev, "Warning: couldn't set 64-bit " "consistent PCI DMA mask.\n"); - err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); + err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); if (err) { dev_err(&pdev->dev, "Can't set consistent PCI DMA mask, " "aborting.\n"); diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c index 7d2e42d..aba6866 100644 --- a/drivers/infiniband/hw/mthca/mthca_memfree.c +++ b/drivers/infiniband/hw/mthca/mthca_memfree.c @@ -66,8 +66,8 @@ static void mthca_free_icm_pages(struct mthca_dev *dev, struct mthca_icm_chunk * int i; if (chunk->nsg > 0) - pci_unmap_sg(dev->pdev, chunk->mem, chunk->npages, - PCI_DMA_BIDIRECTIONAL); + dma_unmap_sg(&dev->pdev->dev, chunk->mem, chunk->npages, + (enum dma_data_direction)PCI_DMA_BIDIRECTIONAL); for (i = 0; i < chunk->npages; ++i) __free_pages(sg_page(&chunk->mem[i]), @@ -184,9 +184,10 @@ struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages, if (coherent) ++chunk->nsg; else if (chunk->npages == MTHCA_ICM_CHUNK_LEN) { - chunk->nsg = pci_map_sg(dev->pdev, chunk->mem, + chunk->nsg = dma_map_sg(&dev->pdev->dev, + chunk->mem, chunk->npages, - PCI_DMA_BIDIRECTIONAL); + (enum dma_data_direction)PCI_DMA_BIDIRECTIONAL); if (chunk->nsg <= 0) goto fail; @@ -204,9 +205,10 @@ struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages, } if (!coherent && chunk) { - chunk->nsg = pci_map_sg(dev->pdev, chunk->mem, + chunk->nsg = dma_map_sg(&dev->pdev->dev, + chunk->mem, chunk->npages, - PCI_DMA_BIDIRECTIONAL); + (enum dma_data_direction)PCI_DMA_BIDIRECTIONAL); if (chunk->nsg <= 0) goto fail; @@ -480,7 +482,8 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar, sg_set_page(&db_tab->page[i].mem, pages[0], MTHCA_ICM_PAGE_SIZE, uaddr & ~PAGE_MASK); - ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); + ret = dma_map_sg(&dev->pdev->dev, &db_tab->page[i].mem, 1, + (enum dma_data_direction)PCI_DMA_TODEVICE); if (ret < 0) { put_page(pages[0]); goto out; @@ -489,7 +492,8 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar, ret = mthca_MAP_ICM_page(dev, sg_dma_address(&db_tab->page[i].mem), mthca_uarc_virt(dev, uar, i)); if (ret) { - pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); + dma_unmap_sg(&dev->pdev->dev, &db_tab->page[i].mem, 1, + (enum dma_data_direction)PCI_DMA_TODEVICE); put_page(sg_page(&db_tab->page[i].mem)); goto out; } @@ -555,7 +559,8 @@ void mthca_cleanup_user_db_tab(struct mthca_dev *dev, struct mthca_uar *uar, for (i = 0; i < dev->uar_table.uarc_size / MTHCA_ICM_PAGE_SIZE; ++i) { if (db_tab->page[i].uvirt) { mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, uar, i), 1); - pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); + dma_unmap_sg(&dev->pdev->dev, &db_tab->page[i].mem, 1, + (enum dma_data_direction)PCI_DMA_TODEVICE); put_page(sg_page(&db_tab->page[i].mem)); } }