Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3984184ybh; Tue, 6 Aug 2019 04:35:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxAk311jtUEMpVB4fV/J+77BYBh4+JDnPHgNVbQOL3Aa0vlTFu6jkEfv4xKC6sUIt/K/isy X-Received: by 2002:a17:90a:ac0e:: with SMTP id o14mr2794627pjq.142.1565091345117; Tue, 06 Aug 2019 04:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565091345; cv=none; d=google.com; s=arc-20160816; b=gSM7W91RJuztL52l4yzAOv+4Pp0YIabO2IjE8gKR4AqV/CNOHbNWGGAYyLsdO/4nSu uf7C/mPyyyeQYd9wVXP5h3HgpIKg4WmHphj6AQxbkjIoyIrGCPkZT8mk1AsHs9ogaOrk pNcDSN/4RCN8F/XWOQrLySxHFl0jKhDmd4U/R+1GFYF4c2ljPiXYKUn4wmHILlomerZb Pd0MtZJfBVhsDtael+PhvYIJ+BbAxBHn7kZhgISUri5F3qJDLP+b2ZRf9SHPCCENoCdm szwy7NXgXsLdTudS6CIKP/LG0pwPh49l2YRrT0DGBtlQzh2lUIxXOWEWQd3KjeAsRALW kX+w== 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=XyDl+8eovHUGrsdYdabuSFvzQq+G0BJ459tWthL5EGs=; b=EA/wCwytTjYXe5QFO82IUjxcVV1xmHAJkFaeeu8wLoxQhfgrZUbrtw+6I0CC6hBqE/ 1Fz5S9PdTzgYMIdF2hkIJM8QoeZMstxygqWmC4jr5EWAF1gg9WlS2sd9hlkk3/U6p+Qg SJsSkLlrPHmEFu93/zDbNciXIusHr+AGlF/wqYlFAgRqw+M6OtMkO2dtm2iWH1Eu4OOF 69I4i80vkhwRA/q/aMQIW0cmOpBVTXRZRNQqJRi5MTRgifRGx+zzGf43AXcKmnYihESi UNBmPJbJklwjZOjWP4U97bhnUpgulZ2kmNJNchT4t5POJcKLPLUTcu0pRTIDcDsFpYAp GB3g== 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 l1si14801661pjq.17.2019.08.06.04.35.29; Tue, 06 Aug 2019 04:35:45 -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 S1732807AbfHFLdW (ORCPT + 99 others); Tue, 6 Aug 2019 07:33:22 -0400 Received: from verein.lst.de ([213.95.11.211]:55706 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730399AbfHFLdV (ORCPT ); Tue, 6 Aug 2019 07:33:21 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id B6461227A81; Tue, 6 Aug 2019 13:33:18 +0200 (CEST) Date: Tue, 6 Aug 2019 13:33:18 +0200 From: Christoph Hellwig To: Lucas Stach Cc: Christoph Hellwig , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Tom Lendacky Subject: Re: Regression due to d98849aff879 (dma-direct: handle DMA_ATTR_NO_KERNEL_MAPPING in common code) Message-ID: <20190806113318.GA20215@lst.de> References: <1565082809.2323.24.camel@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1565082809.2323.24.camel@pengutronix.de> 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 On Tue, Aug 06, 2019 at 11:13:29AM +0200, Lucas Stach wrote: > Hi Christoph, > > I just found a regression where my NVMe device is no longer able to set > up its HMB. > > After subject commit dma_direct_alloc_pages() is no longer initializing > dma_handle properly when DMA_ATTR_NO_KERNEL_MAPPING is set, as the > function is now returning too early. > > Now this could easily be fixed by adding the phy_to_dma translation to > the NO_KERNEL_MAPPING code path, but I'm not sure how this stuff > interacts with the memory encryption stuff set up later in the > function, so I guess this should be looked at by someone with more > experience with this code than me. There is not much we can do about the memory encryption case here, as that requires a kernel address to mark the memory as unencrypted. So the obvious trivial fix is probably the right one: diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 59bdceea3737..c49120193309 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -135,6 +135,7 @@ void *dma_direct_alloc_pages(struct device *dev, size_t size, 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; }