Received: by 10.213.65.68 with SMTP id h4csp441683imn; Wed, 28 Mar 2018 06:37:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/zCg0ZAxQCMgyAmtTnmhFh5aDYm00+S/p5wXVwI+9/XamkeAHQE6Jg6iCs2MlETRo0jFtW X-Received: by 10.101.97.165 with SMTP id i5mr2576994pgv.449.1522244240190; Wed, 28 Mar 2018 06:37:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522244240; cv=none; d=google.com; s=arc-20160816; b=t3rgyQb+lJOpQhmsnFZ1lAFMtJlQeiAqhHtA1UgmqnbUnXuX0EH0oWgeRUM9YcC4EH asXCddldsVh0u/L2jss/yo85JX/Ua4AGCrEbAMT3dJG31jqMi/DU8iungWTaPFxNGyRf /ty4dwMCIHY/83HiwQkBEDYCaQWONf0lrYO7yvP33tWsKbQwEbOZLdY8MDFkXDX/RbLx ssYagowPGZOZUKleJeZZCO1iEPr4ndlSGdoJLwAiWgFhBY+6b3zd6bj1pRol1vznve61 q2bRPFJiEcWU5xPdsYzcgS6RtsmtlFH+EiOV43mDOoH2gT36BF4BcaFz60Cy4fDkctb6 zGMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=eEFLwG7UIpPju5rFzicQSImR+1zd1tiX8l71vobT4sM=; b=tHE3PV6+PRABMa+H/9baktTvoFqzF+RIriPYi0SVGQ/XmTbSCO4ZTHDqlmQ5XfiHxa BzIv/3N6XMmgAm0aumLJYs+W8PXsurFf7Apx0Y4tVROJd0u0vHJ4w0DJIkd0moTxwJik 1lsfUQ5Lob5B9PzQTKZ5DfruTeR3gnh0ov96Qsn9KZ0mHXen93OGv0xZZYClHJgV5/Zi cVB2kXdO9NLgH9kniU57HMXYrRbMGJbheFAli3CuVUT6PSI+C+M4z/DKS5SnTEIIK5vp A4b94bDi8GriwENm/HWsVR+yBB7ALXC83EUH2rrwEnoPUwgnEqu7XvSjdjNqkK0KYs9W cjYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=JSqPZpDA; 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 w78si128776pfj.339.2018.03.28.06.37.05; Wed, 28 Mar 2018 06:37:20 -0700 (PDT) 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=JSqPZpDA; 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 S1753034AbeC1Nfz (ORCPT + 99 others); Wed, 28 Mar 2018 09:35:55 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:44260 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752831AbeC1Nfs (ORCPT ); Wed, 28 Mar 2018 09:35:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding: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=eEFLwG7UIpPju5rFzicQSImR+1zd1tiX8l71vobT4sM=; b=JSqPZpDAK7Mz6XV8b8olMsSlD Z8RnEZDh9j5IOHcUwMPYGLWamUS7ldgCAvhQgjf/4sN5lg3UsixYMISnqZwcv2kX3rIbYcGIuw9t8 43D00mz9TkA/aRTMbH2QNbPtjOvWjy3/I057PD0BwiuMD4tq74FZdP1U4U9meCv8HrFbquir3N+D8 FAEFm/ADEAkARz8Yy7u9VsLFgVgV5VZY6iqkTKeaD6q4WsBXF6jQ5O/sV7XpvVeB210DMeOQUuv0H +8wTma5Ehh7NhqT0KWj/dFuHbhtMagf6w5YURDrSCKFaDQmuZfs4AI+jGVjqYcVb267erbNuB9cln f0ICSSbuQ==; Received: from 80-109-164-210.cable.dynamic.surfer.at ([80.109.164.210] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1f1BEr-00051R-8S; Wed, 28 Mar 2018 13:35:41 +0000 From: Christoph Hellwig To: x86@kernel.org Cc: Evgeniy Didin , Sebastian Ott , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH] dma-mapping: don't clear GFP_ZERO in dma_alloc_attrs Date: Wed, 28 Mar 2018 15:35:35 +0200 Message-Id: <20180328133535.17302-2-hch@lst.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180328133535.17302-1-hch@lst.de> References: <20180328133535.17302-1-hch@lst.de> 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 Revert the clearing of __GFP_ZERO in dma_alloc_attrs and move it to dma_direct_alloc for now. While most common architectures always zero dma cohereny allocations (and x86 did so since day one) this is not documented and at least arc and s390 do not zero without the explicit __GFP_ZERO argument. Fixes: 57bf5a8963f8 ("dma-mapping: clear harmful GFP_* flags in common code") Reported-by: Evgeniy Didin Reported-by: Sebastian Ott Signed-off-by: Christoph Hellwig --- include/linux/dma-mapping.h | 8 ++------ lib/dma-direct.c | 3 +++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index eb9eab4ecd6d..12fedcba9a9a 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -518,12 +518,8 @@ static inline void *dma_alloc_attrs(struct device *dev, size_t size, if (dma_alloc_from_dev_coherent(dev, size, dma_handle, &cpu_addr)) return cpu_addr; - /* - * Let the implementation decide on the zone to allocate from, and - * decide on the way of zeroing the memory given that the memory - * returned should always be zeroed. - */ - flag &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM | __GFP_ZERO); + /* let the implementation decide on the zone to allocate from: */ + flag &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM); if (!arch_dma_alloc_attrs(&dev, &flag)) return NULL; diff --git a/lib/dma-direct.c b/lib/dma-direct.c index 1277d293d4da..c0bba30fef0a 100644 --- a/lib/dma-direct.c +++ b/lib/dma-direct.c @@ -59,6 +59,9 @@ void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, struct page *page = NULL; void *ret; + /* we always manually zero the memory once we are done: */ + gfp &= ~__GFP_ZERO; + /* GFP_DMA32 and GFP_DMA are no ops without the corresponding zones: */ if (dev->coherent_dma_mask <= DMA_BIT_MASK(ARCH_ZONE_DMA_BITS)) gfp |= GFP_DMA; -- 2.14.2