Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4109784imu; Fri, 30 Nov 2018 11:08:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/XVS11KQw1tAbvrghgzlRMj8eykE3EZ6GFnQjJ8SFxiy+diamMfUnYcpWFV1yuzx/gMpZ5/ X-Received: by 2002:a63:a91a:: with SMTP id u26mr5720150pge.349.1543604910096; Fri, 30 Nov 2018 11:08:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543604910; cv=none; d=google.com; s=arc-20160816; b=ip71TrmEp6RMhAHrOnjXx1JNKVMLp2ir4N+VN43zO85EKwqtZhS4ms337oVzoLYGeg 4Ufx79Z4kRUTSgI6oYskmKIg0cvcVnNrptmqOfocjzDHvKwBAeYet1PcXGmWDQVw1Lqe 90VOKw9gt+Md5JgPSBK+YpYKMPNzufniHXoLGgug4AkIBQLQsZiot7BmOb8iudAzsdfV tphk24rQT0lm0RpzWe1qMXcb/9Izimpv1zumSM4f91z6hzkVQF9EDf9eHuZMslAt2t+o 8zMCOBEC2Ofwod7oJ9a8tybiBBV3pZaWCaU34idTpHoxIWov+mlgLJUV/uAwGn9d8q/d KJUw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=q4g7ukqxYBrHzkMG4fEOAWBbzHjeYzUtYP6+FaT2osw=; b=kuywewioyowLqnDpGnzNG3EYbjOY6Z8rj/BUgZAyehlBCQT/1tlpZnDHkYNWZ3zDso z/dqyX9Hq4RZ/MLg8t/QQJQaplxCKWp1P+V90KOm+aYBZov2nADytY5jAEW1weeghsxi TOhysThqdBGH9BH9ipp69Az6XAq7WwK1DMadnJiwRrpD1bVhaFSFrN2o5u/hvRAG/9Xw mcQQPIN7XnqqGu0FkyNs3vOlWxQnAGtPwpB//FmyOhtRNKtUAepewSUB52mTFapaaUtA EUpyFi+j5XWO8aWqYzwmUUrlDnr96/DSeKV88yJNH5iJNuAt5HqKzwtXdYkzIFWdQLOR heCg== 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 x16si5574341pga.407.2018.11.30.11.08.14; Fri, 30 Nov 2018 11:08:30 -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 S1727027AbeLAGPv (ORCPT + 99 others); Sat, 1 Dec 2018 01:15:51 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:35178 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbeLAGPv (ORCPT ); Sat, 1 Dec 2018 01:15:51 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2EE1C165C; Fri, 30 Nov 2018 11:05:36 -0800 (PST) Received: from [10.1.196.75] (e110467-lin.cambridge.arm.com [10.1.196.75]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CA4F63F575; Fri, 30 Nov 2018 11:05:34 -0800 (PST) Subject: Re: [PATCH 5/9] dma-mapping: support highmem in the generic remap allocator To: Christoph Hellwig , iommu@lists.linux-foundation.org Cc: Catalin Marinas , Will Deacon , Guo Ren , Laura Abbott , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20181105121931.13481-1-hch@lst.de> <20181105121931.13481-6-hch@lst.de> From: Robin Murphy Message-ID: <449e0631-aa32-d4a8-9fa9-07234ae1e533@arm.com> Date: Fri, 30 Nov 2018 19:05:33 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181105121931.13481-6-hch@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/11/2018 12:19, Christoph Hellwig wrote: > By using __dma_direct_alloc_pages we can deal entirely with struct page > instead of having to derive a kernel virtual address. Simple enough :) Reviewed-by: Robin Murphy > Signed-off-by: Christoph Hellwig > --- > kernel/dma/remap.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/kernel/dma/remap.c b/kernel/dma/remap.c > index bc42766f52df..8f1fca34b894 100644 > --- a/kernel/dma/remap.c > +++ b/kernel/dma/remap.c > @@ -196,7 +196,7 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, > gfp_t flags, unsigned long attrs) > { > struct page *page = NULL; > - void *ret, *kaddr; > + void *ret; > > size = PAGE_ALIGN(size); > > @@ -208,10 +208,9 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, > return ret; > } > > - kaddr = dma_direct_alloc_pages(dev, size, dma_handle, flags, attrs); > - if (!kaddr) > + page = __dma_direct_alloc_pages(dev, size, dma_handle, flags, attrs); > + if (!page) > return NULL; > - page = virt_to_page(kaddr); > > /* remove any dirty cache lines on the kernel alias */ > arch_dma_prep_coherent(page, size); > @@ -221,7 +220,7 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, > arch_dma_mmap_pgprot(dev, PAGE_KERNEL, attrs), > __builtin_return_address(0)); > if (!ret) > - dma_direct_free_pages(dev, size, kaddr, *dma_handle, attrs); > + __dma_direct_free_pages(dev, size, page); > return ret; > } > > @@ -229,10 +228,11 @@ void arch_dma_free(struct device *dev, size_t size, void *vaddr, > dma_addr_t dma_handle, unsigned long attrs) > { > if (!dma_free_from_pool(vaddr, PAGE_ALIGN(size))) { > - void *kaddr = phys_to_virt(dma_to_phys(dev, dma_handle)); > + phys_addr_t phys = dma_to_phys(dev, dma_handle); > + struct page *page = pfn_to_page(__phys_to_pfn(phys)); > > vunmap(vaddr); > - dma_direct_free_pages(dev, size, kaddr, dma_handle, attrs); > + __dma_direct_free_pages(dev, size, page); > } > } > >