Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4713702imu; Tue, 8 Jan 2019 05:09:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN5DLJFJ6/sBvP3+wpeoKG6AKGbrGCf8307KnLdBABXax761SJ475LGR88E90hmAsgl6aQfP X-Received: by 2002:a17:902:5982:: with SMTP id p2mr1697315pli.39.1546952951085; Tue, 08 Jan 2019 05:09:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546952951; cv=none; d=google.com; s=arc-20160816; b=C1wDRVNtefo8n7YGEqX4m55FhuPUZGfVYeZLV3NVHrP/uRkW5e+cWLkgSgJYNcKlmS f9YyIWKrtjc8F6Uf45m8pPkAvh0EXUgg3rUuz+1gdN24Jb18ZFuaOOIjorzM+5cG7xTJ jp8Otx6L1j1yW8QDHTjHYiUud8aiqx8PBIgi4YERZJjRTOd0YnF/oAaN3KBeLHUEgKmk 7hwaUFevPNP5Ikhd8fVLYpZUph6JNtxr4XUyufOQ5LIUd3iqJT0jiG87PSyFlrEnGRf+ WwOxu90tSRFBSbTY+QDDYxi2/DBuh/TZFSSX9RabMptkaJHtMil7Oi13bAkB44TqWNco TGew== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=30fPNqiJhNB/fhrijdhBItayyeau+8kMnT8NwCIPPZg=; b=vYHeJgeJ0sAEXZ5+N4K3KZctx+UgKskB7AfWhLfTIngycPAtvumtymD0vzeRT7nCmv JkdHMTlTBgFxgV/I+2IjCx8k90Dpqznm7pE/LMcDKrehaSy44tg9pzFOdJGq6cgGGWjg dr96X3UMD+ruWjTVAeSrWYRNGq1B3QRJUtlYmvMm4B0CLiRjT/uTUc3FMMRJYNP2sGQi KUgTGqEXlqoraCT137rZlDvnRRyAA0mJV1lHxiyrgpndOeD0B93NQ0gMes1kbWxDpRHk YOacGHIgAV7l3Ec7rCJV75JtBuq9xji/Wjorc2lF59r62E2Q9p0DuEoB+ArXkQV8m1W4 JE6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ceYErFMc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e22si5611540pge.479.2019.01.08.05.08.55; Tue, 08 Jan 2019 05:09:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ceYErFMc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728428AbfAHNHN (ORCPT + 99 others); Tue, 8 Jan 2019 08:07:13 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:36222 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728394AbfAHNHK (ORCPT ); Tue, 8 Jan 2019 08:07:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=30fPNqiJhNB/fhrijdhBItayyeau+8kMnT8NwCIPPZg=; b=ceYErFMcqnrJOphUi34zx7MAW5 VJquzHKZRHHWlwyKZBoOiv1tUBXW8oDifhQr95lvTblJ6FtgYXyVtafPg/fRchOPyzzwmsgJGbFgz S9IJfZ/72HXnMe5Sd7swCzmbvktVFFT11hAt20e/z1xgFdNp6Tl4iw0dSaI7oMhOndXoiu+1gydDH lmL7JeAHK3PmQaYNxkPOyBwcyaI2Sv8ILuwrJdYtq9Va9kzF4l4k3LRzONIFg/bJLkk05ortMDdZU V9PrNIcZwkbEcwWdRA76NLwb/M3MwzBBib6OD9GiG4fCBG4/IHxmlYFRk3Qp7G2T1JIvAAulm7Ea2 Tc7+TDCg==; Received: from rrcs-24-103-175-221.nys.biz.rr.com ([24.103.175.221] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1ggr64-0005bn-MA; Tue, 08 Jan 2019 13:07:08 +0000 From: Christoph Hellwig To: Linus Torvalds Cc: Luis Chamberlain , Julia Lawall , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] dma-mapping: remove dma_zalloc_coherent() Date: Tue, 8 Jan 2019 08:07:01 -0500 Message-Id: <20190108130701.14161-4-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190108130701.14161-1-hch@lst.de> References: <20190108130701.14161-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luis Chamberlain dma_zalloc_coherent() is no longer needed as it has no users because dma_alloc_coherent() already zeroes out memory for us. The Coccinelle grammar rule that used to check for dma_alloc_coherent() + memset() is modified so that it just tells the user that the memset is not needed anymore. Suggested-by: Christoph Hellwig Signed-off-by: Luis Chamberlain Signed-off-by: Christoph Hellwig --- include/linux/dma-mapping.h | 9 --------- scripts/coccinelle/api/alloc/alloc_cast.cocci | 8 ++++---- scripts/coccinelle/api/alloc/zalloc-simple.cocci | 11 +---------- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index cef2127e1d70..f6ded992c183 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -717,15 +717,6 @@ static inline unsigned long dma_max_pfn(struct device *dev) } #endif -/* - * Please always use dma_alloc_coherent instead as it already zeroes the memory! - */ -static inline void *dma_zalloc_coherent(struct device *dev, size_t size, - dma_addr_t *dma_handle, gfp_t flag) -{ - return dma_alloc_coherent(dev, size, dma_handle, flag); -} - static inline int dma_get_cache_alignment(void) { #ifdef ARCH_DMA_MINALIGN diff --git a/scripts/coccinelle/api/alloc/alloc_cast.cocci b/scripts/coccinelle/api/alloc/alloc_cast.cocci index 408ee3879f9b..18fedf7c60ed 100644 --- a/scripts/coccinelle/api/alloc/alloc_cast.cocci +++ b/scripts/coccinelle/api/alloc/alloc_cast.cocci @@ -32,7 +32,7 @@ type T; (T *) \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\| kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\| - dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\| + dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\| kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\| pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\| kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...) @@ -55,7 +55,7 @@ type r1.T; * (T *) \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\| kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\| - dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\| + dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\| kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\| pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\| kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...) @@ -78,7 +78,7 @@ type r1.T; - (T *) \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\| kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\| - dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\| + dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\| kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\| pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\| kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...) @@ -95,7 +95,7 @@ position p; (T@p *) \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\| kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\| - dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\| + dma_alloc_coherent\|devm_kmalloc\|devm_kzalloc\| kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\| pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\| kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...) diff --git a/scripts/coccinelle/api/alloc/zalloc-simple.cocci b/scripts/coccinelle/api/alloc/zalloc-simple.cocci index d819275b7fde..5cd1991c582e 100644 --- a/scripts/coccinelle/api/alloc/zalloc-simple.cocci +++ b/scripts/coccinelle/api/alloc/zalloc-simple.cocci @@ -69,15 +69,6 @@ statement S; - x = (T)vmalloc(E1); + x = (T)vzalloc(E1); | -- x = dma_alloc_coherent(E2,E1,E3,E4); -+ x = dma_zalloc_coherent(E2,E1,E3,E4); -| -- x = (T *)dma_alloc_coherent(E2,E1,E3,E4); -+ x = dma_zalloc_coherent(E2,E1,E3,E4); -| -- x = (T)dma_alloc_coherent(E2,E1,E3,E4); -+ x = (T)dma_zalloc_coherent(E2,E1,E3,E4); -| - x = kmalloc_node(E1,E2,E3); + x = kzalloc_node(E1,E2,E3); | @@ -225,7 +216,7 @@ p << r2.p; x << r2.x; @@ -msg="WARNING: dma_zalloc_coherent should be used for %s, instead of dma_alloc_coherent/memset" % (x) +msg="WARNING: dma_alloc_coherent use in %s already zeroes out memory, so memset is not needed" % (x) coccilib.report.print_report(p[0], msg) //----------------------------------------------------------------- -- 2.20.1