Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2267359pxv; Sun, 11 Jul 2021 07:55:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGw9LkhPc61ZcE55s0BmVjlR5GLUQf2M2k0FlbRN/dcRqSfetJdQynmXfvHvjOWMRbe146 X-Received: by 2002:a17:906:498b:: with SMTP id p11mr48980445eju.295.1626015302066; Sun, 11 Jul 2021 07:55:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626015302; cv=none; d=google.com; s=arc-20160816; b=0Cv7RlEBg+zAOv3sx8guh2EG5bED5LHIe0QfWXIh6WsKomA0P9L9z1r6CMztxQh68T ddPFIXvLoM8jOmqkKl8kOc6ZKPh0ck6OUys5ROAHAOnMlWgeWCCDsWTOOoMzwKmxh1p4 veikdy4jTBx5Th4qlSpjG/4XVTWeMuwMDQ71yRIhAd3LSFkrsJfMoLu4zdsodqEF1Yv0 PADlpw7l4xIBntlVTQ7jkD2Wd6BQZdR2SJJWtzXoq4uJXtBA9Ei0Lwgf1D5AkkvjCb6s 68bb9+wxmBlSHt0vgsy+rFv96YSX8X2dPszQZQFD8hTdhszdBOB4Gw652RSx4oSy/PZQ 7Uag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=HQGsVVf0gM/1/aJD4pnf3mrVWVOnaFKjQmQBbhJHeDQ=; b=idsvzSdxBK5i/MdM7IQDL0ow25kaVxPgr0IO/rWXJUqULXgiXKNAvt0UFGg3IXbpMF DNQNP6mukEBqxse2TcSZ2d76jf0g/fIROIfvi7loL111jLOp3JxPy0g0VxPPPPOp9NcB ktZiHBitet2kNwndeyEY6aD9rMlQGTw+/clPUT8jTmq2gduVckB+NH0SYd85K56W21Fa 9Uxc+NAeHNe21Bz7Yci1/qRR2T3/oxO+KS7b1VMNigIukm0Rehn007FE7mLaZW3N/SjY janwK2SooJDUegHdNr88stplHOPlv/taLUaRRcehnqRFYWxn/k607wCnR1Zt53lwfWWa ATCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q5si14397175edh.492.2021.07.11.07.54.38; Sun, 11 Jul 2021 07:55:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233715AbhGKOy3 (ORCPT + 99 others); Sun, 11 Jul 2021 10:54:29 -0400 Received: from out07.smtpout.orange.fr ([193.252.22.91]:55631 "EHLO out.smtpout.orange.fr" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233711AbhGKOy3 (ORCPT ); Sun, 11 Jul 2021 10:54:29 -0400 Received: from localhost.localdomain ([86.243.172.93]) by mwinf5d67 with ME id Tqrb2500921Fzsu03qrbGm; Sun, 11 Jul 2021 16:51:39 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 11 Jul 2021 16:51:39 +0200 X-ME-IP: 86.243.172.93 From: Christophe JAILLET To: m.chetan.kumar@intel.com, linuxwwan@intel.com, loic.poulain@linaro.org, ryazanov.s.a@gmail.com, johannes@sipsolutions.net, davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] net: wwan: iosm: switch from 'pci_' to 'dma_' API Date: Sun, 11 Jul 2021 16:51:33 +0200 Message-Id: X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The wrappers in include/linux/pci-dma-compat.h should go away. The patch has been generated with the coccinelle script below and has been hand modified to replace GFP_ with a correct flag. It has been compile tested. When memory is allocated in 'ipc_protocol_init()' GFP_KERNEL can be used because this flag is already used a few lines above and no lock is acquired in the between. When memory is allocated in 'ipc_protocol_msg_prepipe_open()' GFP_ATOMIC should be used because this flag is already used a few lines above. @@ @@ - PCI_DMA_BIDIRECTIONAL + DMA_BIDIRECTIONAL @@ @@ - PCI_DMA_TODEVICE + DMA_TO_DEVICE @@ @@ - PCI_DMA_FROMDEVICE + DMA_FROM_DEVICE @@ @@ - PCI_DMA_NONE + DMA_NONE @@ expression e1, e2, e3; @@ - pci_alloc_consistent(e1, e2, e3) + dma_alloc_coherent(&e1->dev, e2, e3, GFP_) @@ expression e1, e2, e3; @@ - pci_zalloc_consistent(e1, e2, e3) + dma_alloc_coherent(&e1->dev, e2, e3, GFP_) @@ expression e1, e2, e3, e4; @@ - pci_free_consistent(e1, e2, e3, e4) + dma_free_coherent(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4; @@ - pci_map_single(e1, e2, e3, e4) + dma_map_single(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4; @@ - pci_unmap_single(e1, e2, e3, e4) + dma_unmap_single(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4, e5; @@ - pci_map_page(e1, e2, e3, e4, e5) + dma_map_page(&e1->dev, e2, e3, e4, e5) @@ expression e1, e2, e3, e4; @@ - pci_unmap_page(e1, e2, e3, e4) + dma_unmap_page(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4; @@ - pci_map_sg(e1, e2, e3, e4) + dma_map_sg(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4; @@ - pci_unmap_sg(e1, e2, e3, e4) + dma_unmap_sg(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4; @@ - pci_dma_sync_single_for_cpu(e1, e2, e3, e4) + dma_sync_single_for_cpu(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4; @@ - pci_dma_sync_single_for_device(e1, e2, e3, e4) + dma_sync_single_for_device(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4; @@ - pci_dma_sync_sg_for_cpu(e1, e2, e3, e4) + dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4; @@ - pci_dma_sync_sg_for_device(e1, e2, e3, e4) + dma_sync_sg_for_device(&e1->dev, e2, e3, e4) @@ expression e1, e2; @@ - pci_dma_mapping_error(e1, e2) + dma_mapping_error(&e1->dev, e2) @@ expression e1, e2; @@ - pci_set_dma_mask(e1, e2) + dma_set_mask(&e1->dev, e2) @@ expression e1, e2; @@ - pci_set_consistent_dma_mask(e1, e2) + dma_set_coherent_mask(&e1->dev, e2) Signed-off-by: Christophe JAILLET --- If needed, see post from Christoph Hellwig on the kernel-janitors ML: https://marc.info/?l=kernel-janitors&m=158745678307186&w=4 When memory is allocated in 'ipc_protocol_msg_prepipe_open()', I think that GFP_KERNEL could be used, but I've not dug enough to be sure. So, better safe that sorry. --- drivers/net/wwan/iosm/iosm_ipc_protocol.c | 10 +++++----- drivers/net/wwan/iosm/iosm_ipc_protocol_ops.c | 13 ++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/net/wwan/iosm/iosm_ipc_protocol.c b/drivers/net/wwan/iosm/iosm_ipc_protocol.c index 834d8b146a94..63fc7012f09f 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_protocol.c +++ b/drivers/net/wwan/iosm/iosm_ipc_protocol.c @@ -239,9 +239,9 @@ struct iosm_protocol *ipc_protocol_init(struct iosm_imem *ipc_imem) ipc_protocol->old_msg_tail = 0; ipc_protocol->p_ap_shm = - pci_alloc_consistent(ipc_protocol->pcie->pci, - sizeof(*ipc_protocol->p_ap_shm), - &ipc_protocol->phy_ap_shm); + dma_alloc_coherent(&ipc_protocol->pcie->pci->dev, + sizeof(*ipc_protocol->p_ap_shm), + &ipc_protocol->phy_ap_shm, GFP_KERNEL); if (!ipc_protocol->p_ap_shm) { dev_err(ipc_protocol->dev, "pci shm alloc error"); @@ -275,8 +275,8 @@ struct iosm_protocol *ipc_protocol_init(struct iosm_imem *ipc_imem) void ipc_protocol_deinit(struct iosm_protocol *proto) { - pci_free_consistent(proto->pcie->pci, sizeof(*proto->p_ap_shm), - proto->p_ap_shm, proto->phy_ap_shm); + dma_free_coherent(&proto->pcie->pci->dev, sizeof(*proto->p_ap_shm), + proto->p_ap_shm, proto->phy_ap_shm); ipc_pm_deinit(proto); kfree(proto); diff --git a/drivers/net/wwan/iosm/iosm_ipc_protocol_ops.c b/drivers/net/wwan/iosm/iosm_ipc_protocol_ops.c index 91109e27efd3..a53ad97abb98 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_protocol_ops.c +++ b/drivers/net/wwan/iosm/iosm_ipc_protocol_ops.c @@ -74,9 +74,9 @@ static int ipc_protocol_msg_prepipe_open(struct iosm_protocol *ipc_protocol, return -ENOMEM; /* Allocate the transfer descriptors for the pipe. */ - tdr = pci_alloc_consistent(ipc_protocol->pcie->pci, - pipe->nr_of_entries * sizeof(*tdr), - &pipe->phy_tdr_start); + tdr = dma_alloc_coherent(&ipc_protocol->pcie->pci->dev, + pipe->nr_of_entries * sizeof(*tdr), + &pipe->phy_tdr_start, GFP_ATOMIC); if (!tdr) { kfree(skbr); dev_err(ipc_protocol->dev, "tdr alloc error"); @@ -492,10 +492,9 @@ void ipc_protocol_pipe_cleanup(struct iosm_protocol *ipc_protocol, /* Free and reset the td and skbuf circular buffers. kfree is save! */ if (pipe->tdr_start) { - pci_free_consistent(ipc_protocol->pcie->pci, - sizeof(*pipe->tdr_start) * - pipe->nr_of_entries, - pipe->tdr_start, pipe->phy_tdr_start); + dma_free_coherent(&ipc_protocol->pcie->pci->dev, + sizeof(*pipe->tdr_start) * pipe->nr_of_entries, + pipe->tdr_start, pipe->phy_tdr_start); pipe->tdr_start = NULL; } -- 2.30.2