Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3421692pxu; Mon, 30 Nov 2020 02:50:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQsql30dtqnwVs9u/VtCboEeWrfDTGn5KMwDxDLVwUxPD+yCAtBuDKdDAU0H1NxBRPX0gp X-Received: by 2002:aa7:d54a:: with SMTP id u10mr21081995edr.168.1606733403696; Mon, 30 Nov 2020 02:50:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606733403; cv=none; d=google.com; s=arc-20160816; b=S+aDZvAzq1iDOVWGZjwbm4QXMXlyETfdCYBWfXMKyZyr+esz4V5ODDOJXOENLPa4GX kmbKv8QODoxidVHRY+wsG4mZx/JN2pYns6QyKTQC2ZyO9L3+pT44JLSG2vsIs2GoXliK U75YSaWfppKcDg1jN/7erWbAECNIen4kLlzcbX1Kpnw7vRmydmwEyoFMwmjtH+UjXg31 CnlrU82fUUdxXjlnfaA90ioCptfxxz4YeFLIr8xtHybUDnyPvRhmoKHOq3vDMxzcz/yP hDfXyEQiRrEu36ijL7ZltK9V3E+i7wlA5itaPPY5Zyz8TJONk36jNmc1stq5IADOoFtU Umpg== 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=xK46bqlqFiVW7fHm7CJz91H/AAD58x8PrlfeElVPNhbfKkRbyLzYm9YNxtnH1wiIKH 6iPA8Lmiuc4yq2SN35VlKxZB14eSRIMVD6PnLoOJUUuzBynAFdPGnXs8cieFyGCYm99+ CgQgNxu3YAwzzC+ReoMGJRbwzQKrBL7jspGLf763n2zfB5TyZVQRzJDdvltNh6KVwJ44 M/XNfHwtkYM9sAeJcZJJloTrfREfo2iU3CgndlpN4axXA5zr17kxI8Zuh7ZwFkDMTj4z SutCulEd503peDP5YnvqiwI4swljVR/j6LsZeGdskojxQCMapCvbWl2cci+4ennCvOW2 X/aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mxZ+YVsh; 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 gx3si10213299ejb.735.2020.11.30.02.49.39; Mon, 30 Nov 2020 02:50:03 -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=mxZ+YVsh; 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 S1728313AbgK3KsT (ORCPT + 99 others); Mon, 30 Nov 2020 05:48:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727663AbgK3KsS (ORCPT ); Mon, 30 Nov 2020 05:48:18 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1318FC0613D2 for ; Mon, 30 Nov 2020 02:47:38 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id f190so21320175wme.1 for ; Mon, 30 Nov 2020 02:47:37 -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=mxZ+YVshPN8IDgC+Xd8VJSuhvuW+B1Vq1vEOVvhr69IYB6IWocC1WMBCPpZXbtWMu+ c7toL4IxZDaEPMYXB6KuB1ZZHDPxgCxu/yMOhnV0L+cWMh1gK4hhLBZ3/rGsqxxIrR6y qFEqeGNKNm1kApxx2viLIZDmnm5XkEF2f7jxk= 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=iHrFdSqo+bWJx9dASHh/e8PeAeObQPhPW9WrNeEm3HpdTmLI84Rn/UwYLnSl1lY5Cr 9l+RH3oDsk19eJk47nkV07i9tJKZm0tPfO0Bp4CbCszvKzuasd0R9gExAys/11EYrPcb vxyVwv3l48Ehm+ChlTM5rq3wZsKsRXu12X6zkxlIkrcMQOhQGomFA04PR9vBcVLPxZR0 8+pZPQVoBvWGWAtQRaCdksVVJMSDNNBr7C57XbdVa2uw8z2Wr8dMzENnQgnWqgmAkk4s szyxk8spUWA3A8kMeVmkO1qaZd8SFWCMqHbiFeF1ZHWmZmMJqyd5apvh75R6cH3i6IIK aYKw== X-Gm-Message-State: AOAM530BipxfOVZQ7PlQs1noFUgTgSRHJTSFhKd9VIKiBKEwTZTC1daX I+F9gpjBdZxCKmK/GUpcLAvc7vdtMwBbzA== X-Received: by 2002:a1c:2d84:: with SMTP id t126mr22263460wmt.132.1606733256754; Mon, 30 Nov 2020 02:47:36 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id x9sm19719853wru.55.2020.11.30.02.47.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2020 02:47:36 -0800 (PST) From: Ricardo Ribalda To: Marek Szyprowski , Robin Murphy , Christoph Hellwig , Mauro Carvalho Chehab , IOMMU DRIVERS , Joerg Roedel , Linux Doc Mailing List , Linux Kernel Mailing List , Linux Media Mailing List , Tomasz Figa , Sergey Senozhatsky Subject: [PATCH v4 1/4] dma-mapping: remove the {alloc,free}_noncoherent methods Date: Mon, 30 Nov 2020 11:47:27 +0100 Message-Id: <20201130104730.27655-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