Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4740338pjb; Mon, 27 Jul 2020 04:04:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHavRdkmroa3lRKpz4bWx8ea0ovvJW9eZdROvKZJRTSzV0SE16ISkMSi5PnwgntsYed8M+ X-Received: by 2002:aa7:c45a:: with SMTP id n26mr1557005edr.45.1595847863601; Mon, 27 Jul 2020 04:04:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595847863; cv=none; d=google.com; s=arc-20160816; b=V2ssS46RQezvOcYrTceSfzgM7jPUB/uS5wSCUwtc6X5qvUC9ZEwv+vT7lhNenW5Cbk 9dIJOO0CKRqoldCZPVnryf+Y9qRO9MTFwS1Xqpo+5fNmysyBwk3hXvUjzVBraBdjfhs+ 3D3lMZynC+p7KoME7VnYDorzJaxojjuyJTRaRJVl7VSNhbp2/bw36BAag7sRMnFKZuub 5YS1HJYSzLGSTS1EbvDiaBP0goS2Vddb6//Dgr8OWrbx3QqIIqgB0NALcZpmPZdHvO7X jVnjnxYalkvWe0TKDkrHaOgwQ6w97+7Ghmy1M7bVq2ZJh4BrZm6m6BLjIDgdFqlexYyK TdTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=+6dBYzqD1uUlRW5KcJY7SgSBY9IgvzX2vDNRCDCel/M=; b=GdGYJ5bnx8LqotUXkFW8IY3zjnBn2Y9R01gE5QBbsXpWQgHNfDZtUCd06PKO7kfpJp LlW21iI4lzLIz17DkOR5eM21m1jEXNvC6sgG9Wn5b2YLd5lxNYx0Fiad7F0fSIlPOW9t HV0ppUDp/8le1fn4sSAmQ1H9HInm3kHUQ4xn943AHB1Jke6kwaApUAJ2/7a/C5M1VyqC pEIy7GILpQC0x2zjAUBz8x/FY/J4qLeYTDefVX8FsD0jDgwmjk/9twmeUblfB3q2btGb qn7WArq/Z86FY+nXkHrl6Li72OoevXbW48I8YgNQKxsZbioN8rLjV1r/YYRiMIxGyunR Y7ig== 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 mc26si331320ejb.333.2020.07.27.04.04.00; Mon, 27 Jul 2020 04:04:23 -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 S1728134AbgG0Kea (ORCPT + 99 others); Mon, 27 Jul 2020 06:34:30 -0400 Received: from smtp04.smtpout.orange.fr ([80.12.242.126]:35893 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728122AbgG0Kea (ORCPT ); Mon, 27 Jul 2020 06:34:30 -0400 Received: from localhost.localdomain ([93.23.16.147]) by mwinf5d60 with ME id 8AaP2300L3ANib903AaQj9; Mon, 27 Jul 2020 12:34:27 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 27 Jul 2020 12:34:27 +0200 X-ME-IP: 93.23.16.147 From: Christophe JAILLET To: alexander.deucher@amd.com, christian.koenig@amd.com, airlied@linux.ie, daniel@ffwll.ch Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 1/2] drm/radeon: switch from 'pci_' to 'dma_' API Date: Mon, 27 Jul 2020 12:34:21 +0200 Message-Id: <20200727103421.50739-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org 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 'radeon_gart_table_ram_alloc()' GFP_KERNEL can be used because its callers already use this flag. Both 'r100_pci_gart_init()' (r100.c) and 'rs400_gart_init()' (rs400.c) call 'radeon_gart_init()'. This function uses 'vmalloc'. @@ @@ - 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/gpu/drm/radeon/radeon_gart.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c index f178ba321715..b7ce254e5663 100644 --- a/drivers/gpu/drm/radeon/radeon_gart.c +++ b/drivers/gpu/drm/radeon/radeon_gart.c @@ -72,8 +72,8 @@ int radeon_gart_table_ram_alloc(struct radeon_device *rdev) { void *ptr; - ptr = pci_alloc_consistent(rdev->pdev, rdev->gart.table_size, - &rdev->gart.table_addr); + ptr = dma_alloc_coherent(&rdev->pdev->dev, rdev->gart.table_size, + &rdev->gart.table_addr, GFP_KERNEL); if (ptr == NULL) { return -ENOMEM; } @@ -110,9 +110,8 @@ void radeon_gart_table_ram_free(struct radeon_device *rdev) rdev->gart.table_size >> PAGE_SHIFT); } #endif - pci_free_consistent(rdev->pdev, rdev->gart.table_size, - (void *)rdev->gart.ptr, - rdev->gart.table_addr); + dma_free_coherent(&rdev->pdev->dev, rdev->gart.table_size, + (void *)rdev->gart.ptr, rdev->gart.table_addr); rdev->gart.ptr = NULL; rdev->gart.table_addr = 0; } -- 2.25.1