Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp4149552ybh; Tue, 6 Aug 2019 07:07:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7EsDOckPZPgB6likuFOPPpruLatlo7EP4S5DKurzzd1kuTyiT4NJkiLjuFNJwuJ3qOf7s X-Received: by 2002:a17:902:8490:: with SMTP id c16mr3464187plo.1.1565100420262; Tue, 06 Aug 2019 07:07:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565100420; cv=none; d=google.com; s=arc-20160816; b=kEhKJxZ4UuJZSj6PmJ4nveOXPi4dORg0YkDeuqpemuSVeZ8B5asWSLSkEfFZtdbeM5 qrg/w1r1a9PcgfAVShPy3Lf7I3KvFx6TAYjssAjyadcRLf/Av3VcGtGr8eGmFthCSTPG cOM1bvKSMA431+jS+MYFM8IZgKBscXEvKZAnwFHmSrdTQrjKN0CQekCiAgz1aFLkpa5V wWtXAZj3VVe8BaA/42ICXW2JGCcRfp0719Z/n66gsSxIyYChG69tZ9kPeUpK0fC2g3qg b0g1S+DYm7ybzVS/EshmBUhKEI04iAXfC5LH5U3WfPfxljdgPz7AfBqCFV5g1BHwSDh3 VBhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=GF8f39ztRtnbG+mYEM5MXoyJkHcboHdcHHe+QCw0y38=; b=gtqo2LEmREtLsgjeVfaqlq2M2zfVDZ7N5++Ay+c3wBwfFi1Mic+gftvds4KUm8q0xV 6tv7BPUxqQGSAkSWrOQX/zVyrvY+8uFd7WuBGazQrXvLChqSNZqxhVowG6vUKDzRiJuJ +GX4iPgPk1xJlMjV1jpniQUvBhInrm6M9y9TXt9kIFRdLzbcmGi9czI/IpcW1YWdIoSR 5nGcRfEk3DEJI1bWPVWUlNH3mbDIVoTXOXCXsMVyLklh0q6z3IpzZr0U8IdKG8tnExGJ fSg/wM9qQ7YAZ64NCoSKXWEYRZmzd7cuo5KdmQ0aYbT7Ngb8JT9XGCHQizXnbs+0NwYi cqcg== ARC-Authentication-Results: i=1; mx.google.com; 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 c137si48531850pga.80.2019.08.06.07.06.39; Tue, 06 Aug 2019 07:07:00 -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; 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 S1732807AbfHFOEN (ORCPT + 99 others); Tue, 6 Aug 2019 10:04:13 -0400 Received: from verein.lst.de ([213.95.11.211]:56760 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728259AbfHFOEM (ORCPT ); Tue, 6 Aug 2019 10:04:12 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 31004227A81; Tue, 6 Aug 2019 16:04:09 +0200 (CEST) Date: Tue, 6 Aug 2019 16:04:08 +0200 From: Christoph Hellwig To: "Lendacky, Thomas" Cc: Christoph Hellwig , Lucas Stach , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , Thiago Jung Bauermann , Halil Pasic Subject: Re: Regression due to d98849aff879 (dma-direct: handle DMA_ATTR_NO_KERNEL_MAPPING in common code) Message-ID: <20190806140408.GA22902@lst.de> References: <1565082809.2323.24.camel@pengutronix.de> <20190806113318.GA20215@lst.de> <41cc93b1-62b5-7fb6-060d-01982e68503b@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41cc93b1-62b5-7fb6-060d-01982e68503b@amd.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ok, does this work? -- From 34d35f335a98f515f2516b515051e12eae744c8d Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 6 Aug 2019 14:33:23 +0300 Subject: dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING The new DMA_ATTR_NO_KERNEL_MAPPING needs to actually assign a dma_addr to work. Also skip it if the architecture needs forced decryption handling, as that needs a kernel virtual address. Fixes: d98849aff879 (dma-direct: handle DMA_ATTR_NO_KERNEL_MAPPING in common code) Signed-off-by: Christoph Hellwig --- kernel/dma/direct.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 59bdceea3737..b01064d884f2 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -130,11 +130,13 @@ void *dma_direct_alloc_pages(struct device *dev, size_t size, if (!page) return NULL; - if (attrs & DMA_ATTR_NO_KERNEL_MAPPING) { + if ((attrs & DMA_ATTR_NO_KERNEL_MAPPING) && + !force_dma_unencrypted(dev)) { /* remove any dirty cache lines on the kernel alias */ if (!PageHighMem(page)) arch_dma_prep_coherent(page, size); /* return the page pointer as the opaque cookie */ + *dma_handle = phys_to_dma(dev, page_to_phys(page)); return page; } -- 2.20.1