Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1735221pxu; Tue, 24 Nov 2020 07:43:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxstcJq1Mmp8r4xt7QPQldCKjFMKrqMrxhIpvrdudjkGjxTqWVnJq03G5ByiJfLu3itTACJ X-Received: by 2002:a17:906:f84f:: with SMTP id ks15mr4517995ejb.337.1606232619753; Tue, 24 Nov 2020 07:43:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606232619; cv=none; d=google.com; s=arc-20160816; b=qLDI4QZV4MfH2kK2NxfTOJiyFeXRMmbcO4hX7HtYCrg17/Px3f6nDfIpZaogkF0Dpa V6k9kUGt7iKGTo3aqC91oZcFS1OdNiiehz+1DDyv8OCb0AZYsRPNIyqAC4CeYcX1Lh6x OOQ4rSLIiyvWSep0POE3IMnrV/v9qi4dW5T5+E6IrtuGBgKMRy7xk5PuilQJp0zwxHdy GexpadmU0egx/pnz4GBlHHVwlunoITrRbKR/otMbL5wZq3CJqYwsZlCfzD3lgsdB9QcL gY7U3QzHL4b+dpDD7/Jq+IkjRzlbhd9JwTNYH4PK8m03jqmwy5y5ANCXR/ffd7deEGBL trvA== 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:to:from:dkim-signature; bh=kEyLf8LFch+KdsSp/Rnz95CvSLqxxYSUroQ+WOd06N4=; b=0/T+qjOLIutY6bqhMjrzOq5JfzKSCBjid+0eY4c1+oDoENsAjGm8J+9r768r0MjBHG IZx7KMcnEayB1abtbTVb43f81WwV4lDVpk84H4ocYdrAF3tyctR9Q1IBqdzMk4vxxthW ZII50aBoDKXFPKgOgFj/2EB7vBvyPPZf+DmM5mOVoDNL9vxK1IGKuFMtkqynUmAe0wGr mz8YtJVjWq/37sRCNsfoy69EAsmEAqmRC63k8VQYb2G20Tr1DL2m+8rWrFbiz1MQw1Qo lSCFmoaH4dbfcMh0OgcgBqMgBfSeZFr936mFaem+mN2RaZ5JXNEV5ALX7cfKIeitDXaK LE3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=R8lV2o5T; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l20si8609049eje.737.2020.11.24.07.43.16; Tue, 24 Nov 2020 07:43:39 -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; dkim=pass header.i=@chromium.org header.s=google header.b=R8lV2o5T; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389367AbgKXPiu (ORCPT + 99 others); Tue, 24 Nov 2020 10:38:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389715AbgKXPit (ORCPT ); Tue, 24 Nov 2020 10:38:49 -0500 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AA58C061A4D for ; Tue, 24 Nov 2020 07:38:49 -0800 (PST) Received: by mail-wr1-x441.google.com with SMTP id u12so22834689wrt.0 for ; Tue, 24 Nov 2020 07:38:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=kEyLf8LFch+KdsSp/Rnz95CvSLqxxYSUroQ+WOd06N4=; b=R8lV2o5TDdkXVFg+npOQOfmTr894UuBL+hiZgpOvOeemCAGJLSxzNsjKPmbqTtaUBV df3z1UFF5oKZaN5ZQr91KwUZQ6ERHZqqQx0vdG6is+IDe89rDGCvNsXovvJQ5Kdp+51K 7t350VA05XF6rpHuFim6dpw29CirGR9tsMJuQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=kEyLf8LFch+KdsSp/Rnz95CvSLqxxYSUroQ+WOd06N4=; b=UDpaMba/NDNK/kUikHl0d+CkaeM43+rNnGaqBXMYBeIprAq4kDnXjpWSA1GBzkxOxv JSSLcRAd6C28/Vf7hjdoSDLuuTL1kCw7c+suerakrUwIjlnuUmgyIBUDylmiXJf2DFOs 5CULcapaNLWrSXrsgcq/O67NAZlFtNFn7PiPB7vk7ktNnj4cBKAhnl9TnvjDg3h3na3N fcJCvw1q5JYDAC4CSxn9SRoFLe4z6Ewtme9kF0yAQihk3dIH7MmOUw++TKpuY/sZhT4V veHgpHZd9vaDlRqCQp6JVEJLkMU84ag9f0Mfrte2Yo09yeAoghein0dbkiEhHTEOFw65 5m2g== X-Gm-Message-State: AOAM532VH/63bU6mAmwNGisOz0DTLgodb1NbZ23G4p8P43e9mLuPksR6 9YlWU+eKuWiFMjJyEorf9nTHjg== X-Received: by 2002:a5d:544e:: with SMTP id w14mr5889967wrv.227.1606232327782; Tue, 24 Nov 2020 07:38:47 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id 25sm5814752wmk.19.2020.11.24.07.38.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 07:38:47 -0800 (PST) From: Ricardo Ribalda To: Christoph Hellwig , Mauro Carvalho Chehab , Marek Szyprowski , IOMMU DRIVERS , Joerg Roedel , Robin Murphy , Linux Doc Mailing List , Linux Kernel Mailing List , Linux Media Mailing List , Tomasz Figa , Sergey Senozhatsky Subject: [PATCH 1/6] dma-mapping: remove the {alloc,free}_noncoherent methods Date: Tue, 24 Nov 2020 16:38:40 +0100 Message-Id: <20201124153845.132207-1-ribalda@chromium.org> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christoph Hellwig It turns out allowing non-contigous allocations here was a rather bad idea, as we'll now need to define ways to get the pages for mmaping or dma_buf sharing. Revert this change and stick to the original concept. A different API for the use case of non-contigous allocations will be added back later. Signed-off-by: Christoph Hellwig --- drivers/iommu/dma-iommu.c | 30 ------------------------------ include/linux/dma-map-ops.h | 5 ----- kernel/dma/mapping.c | 33 ++++++--------------------------- 3 files changed, 6 insertions(+), 62 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 0cbcd3fc3e7e..73249732afd3 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -1054,34 +1054,6 @@ static void *iommu_dma_alloc(struct device *dev, size_t size, return cpu_addr; } -#ifdef CONFIG_DMA_REMAP -static void *iommu_dma_alloc_noncoherent(struct device *dev, size_t size, - dma_addr_t *handle, enum dma_data_direction dir, gfp_t gfp) -{ - if (!gfpflags_allow_blocking(gfp)) { - struct page *page; - - page = dma_common_alloc_pages(dev, size, handle, dir, gfp); - if (!page) - return NULL; - return page_address(page); - } - - return iommu_dma_alloc_remap(dev, size, handle, gfp | __GFP_ZERO, - PAGE_KERNEL, 0); -} - -static void iommu_dma_free_noncoherent(struct device *dev, size_t size, - void *cpu_addr, dma_addr_t handle, enum dma_data_direction dir) -{ - __iommu_dma_unmap(dev, handle, size); - __iommu_dma_free(dev, size, cpu_addr); -} -#else -#define iommu_dma_alloc_noncoherent NULL -#define iommu_dma_free_noncoherent NULL -#endif /* CONFIG_DMA_REMAP */ - static int iommu_dma_mmap(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, dma_addr_t dma_addr, size_t size, unsigned long attrs) @@ -1152,8 +1124,6 @@ static const struct dma_map_ops iommu_dma_ops = { .free = iommu_dma_free, .alloc_pages = dma_common_alloc_pages, .free_pages = dma_common_free_pages, - .alloc_noncoherent = iommu_dma_alloc_noncoherent, - .free_noncoherent = iommu_dma_free_noncoherent, .mmap = iommu_dma_mmap, .get_sgtable = iommu_dma_get_sgtable, .map_page = iommu_dma_map_page, diff --git a/include/linux/dma-map-ops.h b/include/linux/dma-map-ops.h index a5f89fc4d6df..3d1f91464bcf 100644 --- a/include/linux/dma-map-ops.h +++ b/include/linux/dma-map-ops.h @@ -22,11 +22,6 @@ struct dma_map_ops { gfp_t gfp); void (*free_pages)(struct device *dev, size_t size, struct page *vaddr, dma_addr_t dma_handle, enum dma_data_direction dir); - void *(*alloc_noncoherent)(struct device *dev, size_t size, - dma_addr_t *dma_handle, enum dma_data_direction dir, - gfp_t gfp); - void (*free_noncoherent)(struct device *dev, size_t size, void *vaddr, - dma_addr_t dma_handle, enum dma_data_direction dir); int (*mmap)(struct device *, struct vm_area_struct *, void *, dma_addr_t, size_t, unsigned long attrs); diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c index 51bb8fa8eb89..d3032513c54b 100644 --- a/kernel/dma/mapping.c +++ b/kernel/dma/mapping.c @@ -514,40 +514,19 @@ EXPORT_SYMBOL_GPL(dma_free_pages); void *dma_alloc_noncoherent(struct device *dev, size_t size, dma_addr_t *dma_handle, enum dma_data_direction dir, gfp_t gfp) { - const struct dma_map_ops *ops = get_dma_ops(dev); - void *vaddr; - - if (!ops || !ops->alloc_noncoherent) { - struct page *page; - - page = dma_alloc_pages(dev, size, dma_handle, dir, gfp); - if (!page) - return NULL; - return page_address(page); - } + struct page *page; - size = PAGE_ALIGN(size); - vaddr = ops->alloc_noncoherent(dev, size, dma_handle, dir, gfp); - if (vaddr) - debug_dma_map_page(dev, virt_to_page(vaddr), 0, size, dir, - *dma_handle); - return vaddr; + page = dma_alloc_pages(dev, size, dma_handle, dir, gfp); + if (!page) + return NULL; + return page_address(page); } EXPORT_SYMBOL_GPL(dma_alloc_noncoherent); void dma_free_noncoherent(struct device *dev, size_t size, void *vaddr, dma_addr_t dma_handle, enum dma_data_direction dir) { - const struct dma_map_ops *ops = get_dma_ops(dev); - - if (!ops || !ops->free_noncoherent) { - dma_free_pages(dev, size, virt_to_page(vaddr), dma_handle, dir); - return; - } - - size = PAGE_ALIGN(size); - debug_dma_unmap_page(dev, dma_handle, size, dir); - ops->free_noncoherent(dev, size, vaddr, dma_handle, dir); + dma_free_pages(dev, size, virt_to_page(vaddr), dma_handle, dir); } EXPORT_SYMBOL_GPL(dma_free_noncoherent); -- 2.29.2.454.gaff20da3a2-goog