Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2318263pxu; Sat, 28 Nov 2020 10:00:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBIoSvL9VjVsOcb4JXO8KgzmKq/cz2d649IDafksS/1lUQhowc92eiqJUS4uURrFkIYVnr X-Received: by 2002:a17:906:f84f:: with SMTP id ks15mr13123579ejb.337.1606586427371; Sat, 28 Nov 2020 10:00:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606586427; cv=none; d=google.com; s=arc-20160816; b=0h9gDe+GkoYGviRSLpvetuR6CSU0CBWZgc6jQ+v5e2G0ED8dKY+uUpfKPi8LEB0aTL fWdX8uK+ZEbWYsrZ6QspXDpDEy72L+TjEPf2N42mrEY9WD4sXNYsdhRDBJYPPJrroo7o Tqc6IgWEAm+Iji/ZXWx3cp2V403hG85iA8I7sXbgpeAjRZGq+GZCpc/go9HajthG3fvx iZJ3S06cPr253PvRPn5aym2d/RylevmBFFo20kSXMMumJSYLpUf1/T598rIpqR+fKXyi x46BbGBmVHRiOxGejlD2XKaR+1EMfA4Kvh0GrVNDOV6zvYZcuQ0F/embT5sIuo8Mmiho 6Acw== 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=0LvkwOeLQt0GmkhQ3A+np4JshLm+iNr/YcDKJYtBGHU=; b=V9udaXMlfv/agxivnEUf54mzHVNG9BBidB/GsixZ1lUVtxPzLZ1kHL/lItPOu7gUt6 eMO9oSmbubSwLSJzRwBocXhXtAoENA8HkObNF4w6+AUmBxexdXL+3p5nIZRd42BZFW1q 4oZde4xctF+AfdVyz1PujHRLfgG0XjzexW+e/J6HIdN/OQe0/Xty2jU85RXp6Mqagx8E NLk7jgmTp7/2Ex+TWL0ClqwXk12EU1gq0UFpHU41rAt3bGSJGx6Df9wdde5ug2tVYVyA ltXQUbvXFJiaIVR6NeZjJFriEmIsotwOq2hJAEB8OkuwufDIV2DspO7yX9PgZwGlJQfC BGNw== 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 u8si7218956eje.57.2020.11.28.09.59.46; Sat, 28 Nov 2020 10:00:27 -0800 (PST) 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 S1732464AbgK0Uf5 (ORCPT + 99 others); Fri, 27 Nov 2020 15:35:57 -0500 Received: from smtp04.smtpout.orange.fr ([80.12.242.126]:49703 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732423AbgK0Ue5 (ORCPT ); Fri, 27 Nov 2020 15:34:57 -0500 Received: from localhost.localdomain ([81.185.168.160]) by mwinf5d27 with ME id xYag2300C3Tyla903YahlD; Fri, 27 Nov 2020 21:34:46 +0100 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 27 Nov 2020 21:34:46 +0100 X-ME-IP: 81.185.168.160 From: Christophe JAILLET To: maintainers@bluecherrydvr.com, anton@corp.bluecherry.net, andrey_utkin@fastmail.com, ismael@iodev.co.uk, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] media: solo6x10: switch from 'pci_' to 'dma_' API Date: Fri, 27 Nov 2020 21:34:40 +0100 Message-Id: <20201127203440.1381359-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.27.0 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 'snd_solo_pcm_open()' (solo6x10-g723.c) GFP_KERNEL can be used because this flag is already used jew a few lines above. When memory is allocated in 'solo_enc_alloc()' (solo6x10-v4l2-enc.c) GFP_KERNEL can be used because this flag is already used jew a few lines above. When memory is allocated in 'solo_enc_v4l2_init()' (solo6x10-v4l2-enc.c) GFP_KERNEL can be used because calls 'solo_enc_alloc()' which already uses this flag. @@ @@ - 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 --- drivers/media/pci/solo6x10/solo6x10-g723.c | 11 +++--- drivers/media/pci/solo6x10/solo6x10-p2m.c | 10 +++--- .../media/pci/solo6x10/solo6x10-v4l2-enc.c | 35 ++++++++++--------- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/drivers/media/pci/solo6x10/solo6x10-g723.c b/drivers/media/pci/solo6x10/solo6x10-g723.c index d137b94869d8..6cebad665565 100644 --- a/drivers/media/pci/solo6x10/solo6x10-g723.c +++ b/drivers/media/pci/solo6x10/solo6x10-g723.c @@ -124,9 +124,10 @@ static int snd_solo_pcm_open(struct snd_pcm_substream *ss) if (solo_pcm == NULL) goto oom; - solo_pcm->g723_buf = pci_alloc_consistent(solo_dev->pdev, - G723_PERIOD_BYTES, - &solo_pcm->g723_dma); + solo_pcm->g723_buf = dma_alloc_coherent(&solo_dev->pdev->dev, + G723_PERIOD_BYTES, + &solo_pcm->g723_dma, + GFP_KERNEL); if (solo_pcm->g723_buf == NULL) goto oom; @@ -148,8 +149,8 @@ static int snd_solo_pcm_close(struct snd_pcm_substream *ss) struct solo_snd_pcm *solo_pcm = snd_pcm_substream_chip(ss); snd_pcm_substream_chip(ss) = solo_pcm->solo_dev; - pci_free_consistent(solo_pcm->solo_dev->pdev, G723_PERIOD_BYTES, - solo_pcm->g723_buf, solo_pcm->g723_dma); + dma_free_coherent(&solo_pcm->solo_dev->pdev->dev, G723_PERIOD_BYTES, + solo_pcm->g723_buf, solo_pcm->g723_dma); kfree(solo_pcm); return 0; diff --git a/drivers/media/pci/solo6x10/solo6x10-p2m.c b/drivers/media/pci/solo6x10/solo6x10-p2m.c index db2afc6a5fcb..ca70a864a3ef 100644 --- a/drivers/media/pci/solo6x10/solo6x10-p2m.c +++ b/drivers/media/pci/solo6x10/solo6x10-p2m.c @@ -37,16 +37,16 @@ int solo_p2m_dma(struct solo_dev *solo_dev, int wr, if (WARN_ON_ONCE(!size)) return -EINVAL; - dma_addr = pci_map_single(solo_dev->pdev, sys_addr, size, - wr ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); - if (pci_dma_mapping_error(solo_dev->pdev, dma_addr)) + dma_addr = dma_map_single(&solo_dev->pdev->dev, sys_addr, size, + wr ? DMA_TO_DEVICE : DMA_FROM_DEVICE); + if (dma_mapping_error(&solo_dev->pdev->dev, dma_addr)) return -ENOMEM; ret = solo_p2m_dma_t(solo_dev, wr, dma_addr, ext_addr, size, repeat, ext_size); - pci_unmap_single(solo_dev->pdev, dma_addr, size, - wr ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); + dma_unmap_single(&solo_dev->pdev->dev, dma_addr, size, + wr ? DMA_TO_DEVICE : DMA_FROM_DEVICE); return ret; } diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c index 3cf7bd6186aa..0abcad4e84fa 100644 --- a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c +++ b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c @@ -1286,10 +1286,11 @@ static struct solo_enc_dev *solo_enc_alloc(struct solo_dev *solo_dev, memcpy(solo_enc->jpeg_header, jpeg_header, solo_enc->jpeg_len); solo_enc->desc_nelts = 32; - solo_enc->desc_items = pci_alloc_consistent(solo_dev->pdev, - sizeof(struct solo_p2m_desc) * - solo_enc->desc_nelts, - &solo_enc->desc_dma); + solo_enc->desc_items = dma_alloc_coherent(&solo_dev->pdev->dev, + sizeof(struct solo_p2m_desc) * + solo_enc->desc_nelts, + &solo_enc->desc_dma, + GFP_KERNEL); ret = -ENOMEM; if (solo_enc->desc_items == NULL) goto hdl_free; @@ -1317,9 +1318,9 @@ static struct solo_enc_dev *solo_enc_alloc(struct solo_dev *solo_dev, vdev_release: video_device_release(solo_enc->vfd); pci_free: - pci_free_consistent(solo_enc->solo_dev->pdev, - sizeof(struct solo_p2m_desc) * solo_enc->desc_nelts, - solo_enc->desc_items, solo_enc->desc_dma); + dma_free_coherent(&solo_enc->solo_dev->pdev->dev, + sizeof(struct solo_p2m_desc) * solo_enc->desc_nelts, + solo_enc->desc_items, solo_enc->desc_dma); hdl_free: v4l2_ctrl_handler_free(hdl); kfree(solo_enc); @@ -1331,9 +1332,9 @@ static void solo_enc_free(struct solo_enc_dev *solo_enc) if (solo_enc == NULL) return; - pci_free_consistent(solo_enc->solo_dev->pdev, - sizeof(struct solo_p2m_desc) * solo_enc->desc_nelts, - solo_enc->desc_items, solo_enc->desc_dma); + dma_free_coherent(&solo_enc->solo_dev->pdev->dev, + sizeof(struct solo_p2m_desc) * solo_enc->desc_nelts, + solo_enc->desc_items, solo_enc->desc_dma); video_unregister_device(solo_enc->vfd); v4l2_ctrl_handler_free(&solo_enc->hdl); kfree(solo_enc); @@ -1346,9 +1347,9 @@ int solo_enc_v4l2_init(struct solo_dev *solo_dev, unsigned nr) init_waitqueue_head(&solo_dev->ring_thread_wait); solo_dev->vh_size = sizeof(vop_header); - solo_dev->vh_buf = pci_alloc_consistent(solo_dev->pdev, - solo_dev->vh_size, - &solo_dev->vh_dma); + solo_dev->vh_buf = dma_alloc_coherent(&solo_dev->pdev->dev, + solo_dev->vh_size, + &solo_dev->vh_dma, GFP_KERNEL); if (solo_dev->vh_buf == NULL) return -ENOMEM; @@ -1363,8 +1364,8 @@ int solo_enc_v4l2_init(struct solo_dev *solo_dev, unsigned nr) while (i--) solo_enc_free(solo_dev->v4l2_enc[i]); - pci_free_consistent(solo_dev->pdev, solo_dev->vh_size, - solo_dev->vh_buf, solo_dev->vh_dma); + dma_free_coherent(&solo_dev->pdev->dev, solo_dev->vh_size, + solo_dev->vh_buf, solo_dev->vh_dma); solo_dev->vh_buf = NULL; return ret; } @@ -1391,6 +1392,6 @@ void solo_enc_v4l2_exit(struct solo_dev *solo_dev) solo_enc_free(solo_dev->v4l2_enc[i]); if (solo_dev->vh_buf) - pci_free_consistent(solo_dev->pdev, solo_dev->vh_size, - solo_dev->vh_buf, solo_dev->vh_dma); + dma_free_coherent(&solo_dev->pdev->dev, solo_dev->vh_size, + solo_dev->vh_buf, solo_dev->vh_dma); } -- 2.27.0