Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1000242imu; Fri, 4 Jan 2019 11:02:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ugt8umhnK14neskCfXR4jE7s0ZF+xQThBYsAUYFvnfjxSIX+iooQbPvgHIliUmk9v6kojm X-Received: by 2002:a62:a99:: with SMTP id 25mr52660205pfk.121.1546628557166; Fri, 04 Jan 2019 11:02:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546628557; cv=none; d=google.com; s=arc-20160816; b=ZgST1FQ3OkaAAcV3+4ijRGL/lh8EOU+l2oJMSUKqScQ6AhSZ6Zm1K8nCvLDxYI/fM6 thh5pDdPv1WAPQX/r0X+TGGXcfwgZt4MDwZmJ/314oMKwPMAEWXU40c29ibothJeLmb+ uUghkkP1yNMX2q51Kse7HkgCwQOJT7Q+FtZdLrJqdiscNFKtTpk90pKaHhP0PE0pgs+n pyUKozxlHuJ8KUaDCO48dluLNNGMP/tKr7X6PH6Pr2AzOd2VjkaL8LsT9xZ4tS3RqJk1 aLSRrthwvOQ7g5AUF2BL06e6thAAivdHn90Jj+Swug30Ir2/sEKLPnYiqSHYFsBi34zb 4TmQ== 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=BS1sV6OKBu5w5N/3Vf10mOAx5WcY5MRRU8Ojk5rYDgs=; b=Z3I0i+3V2m2e0LIODBPdtzS4BHNlpSH5yMtBcZ9tqwLGDNWRo2TPLzUs+7DTV/DEU8 qbwXElBdeAsAsWzcr4qaABuuHJuolpd9cQqcDzf+mNglZ0ZekWWw/qNLBV54ObEay7GV ymSnK9a29oJelfNq2l4lkxyhPVQF/GXb8wGOeBC6kZj67ZE2o1DBFFuydHKieJ9X5cuP Wn9NYcuC5paLARDeJWMoTf91vfrYY3FGnpYgHpZAkVrBDKr5dV3+he/HPZqhsjDRk6Bm 1lFwdViJauYpmyOR5zpiCmUqWXvn0CnsXloyCbN41qUUMK2A0wpS33qfO1/cCy93h/AQ hKWQ== 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 n1si55013944pgh.172.2019.01.04.11.02.22; Fri, 04 Jan 2019 11:02:37 -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; 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 S1726218AbfADRet (ORCPT + 99 others); Fri, 4 Jan 2019 12:34:49 -0500 Received: from verein.lst.de ([213.95.11.211]:40889 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725958AbfADRet (ORCPT ); Fri, 4 Jan 2019 12:34:49 -0500 Received: by newverein.lst.de (Postfix, from userid 2407) id 1D0EB68D93; Fri, 4 Jan 2019 18:34:47 +0100 (CET) Date: Fri, 4 Jan 2019 18:34:47 +0100 From: Christoph Hellwig To: Liviu Dudau Cc: Christoph Hellwig , Lorenzo Pieralisi , Bjorn Helgaas , Robin Murphy , linux-pci@vger.kernel.org, LAKML , LKML Subject: Re: [REGRESSION, BISECTED] pci: nvme device with HMB fails on arm64 Message-ID: <20190104173446.GA24554@lst.de> References: <20190104125735.GF20342@bart.dudau.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190104125735.GF20342@bart.dudau.co.uk> 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 Hi Liviu, please try the patch below. Note that this is in top of mainline, as the commit you found already needed another fixup, which has made it to Linus already. -- From a959cc1a8ee00dcb274922f9d74f6ed632709047 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 4 Jan 2019 18:31:48 +0100 Subject: dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING for remapped allocations We need to return a dma_addr_t even if we don't have a kernel mapping. Do so by consolidating the phys_to_dma call in a single place and jump to it from all the branches that return successfully. Fixes: bfd56cd60521 ("dma-mapping: support highmem in the generic remap allocator") Reported-by: Liviu Dudau --- kernel/dma/remap.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/kernel/dma/remap.c b/kernel/dma/remap.c index 18cc09fc27b9..7a723194ecbe 100644 --- a/kernel/dma/remap.c +++ b/kernel/dma/remap.c @@ -204,8 +204,7 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, ret = dma_alloc_from_pool(size, &page, flags); if (!ret) return NULL; - *dma_handle = phys_to_dma(dev, page_to_phys(page)); - return ret; + goto done; } page = __dma_direct_alloc_pages(dev, size, dma_handle, flags, attrs); @@ -215,8 +214,10 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, /* remove any dirty cache lines on the kernel alias */ arch_dma_prep_coherent(page, size); - if (attrs & DMA_ATTR_NO_KERNEL_MAPPING) - return page; /* opaque cookie */ + if (attrs & DMA_ATTR_NO_KERNEL_MAPPING) { + ret = page; /* opaque cookie */ + goto done; + } /* create a coherent mapping */ ret = dma_common_contiguous_remap(page, size, VM_USERMAP, @@ -227,9 +228,9 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, return ret; } - *dma_handle = phys_to_dma(dev, page_to_phys(page)); memset(ret, 0, size); - +done: + *dma_handle = phys_to_dma(dev, page_to_phys(page)); return ret; } -- 2.20.1