Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp489921imu; Mon, 5 Nov 2018 04:20:50 -0800 (PST) X-Google-Smtp-Source: AJdET5cNUVckX0VUyGW8Egcm0vryNL+Zdpj2NYXPxXN5Bf3a+urKvWTsecy8z4g+2K7wQCbWQuFr X-Received: by 2002:a17:902:2702:: with SMTP id c2-v6mr21928943plb.314.1541420450608; Mon, 05 Nov 2018 04:20:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541420450; cv=none; d=google.com; s=arc-20160816; b=VbB1Vtc3vpi/OKVFw7Pcwwa7qNppRnbd8dPpImM9mTotTkQdUjejh1i4yU3NXpmbDA Ikv9c2lydlitxWw0EfVIyEwhBsckbj1TLLpQ76nulsI1Pv6XYBi9GeXnYHABPBRAfXCH 7nMhS3eLI0Z/CbqJEIYV9rfJOvcsEFYgwx2lSECVkI1lPYt43qB8q1VtmwbjxBhOXtw0 VtGxH34uFHbElCujCyMW+tRjr0L4jkYzutHDkZlkwSAX4YojtQVL54z7+74H2QYMpw4y 5uhGTsVD9weiko6b8LirCcaje7ZUGv2Q4lIujIrPMWuyf2LhguHfQiQ7s9QnCmk48co0 I7BA== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6CZ8u2Hp6BszJscW6OKAY0pFx5HDYwXE3CfpN14wo7w=; b=x0IRaHE3OUXuQgknPlbF222wMfQyeZ5+EBNl0XB6/5zJItrFN5Ed6THm2h3SgSUVjp dMu+wWoAY8YUFMrhrzd8ezj7PcZJqvwmn3fY1aCH82res/of2toztiGN+e+ryKqM5md+ f/ErKfhQJl88nC7DzxwTNT8Y/rEvONS4fcOXmGaBs859UZKf3+ivALIp2N9ZKi3oqdgk 7VnDUap6se1xhz33HesW4TSgLBTelPAO79AvNlZKzyKy4ovfa1B5h9jMRoQJhQYpdhhK S6XNY+9KgVTut0ITb3mEk/AqF+nZxh4rwlrC1MRR2Pgh4rWpar9MXSbCArQB5K1d3vhJ ue2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=EC9mYGM4; 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 e67-v6si32405989plb.401.2018.11.05.04.20.33; Mon, 05 Nov 2018 04:20:50 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=EC9mYGM4; 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 S1729692AbeKEVjZ (ORCPT + 99 others); Mon, 5 Nov 2018 16:39:25 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:42740 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726358AbeKEVjZ (ORCPT ); Mon, 5 Nov 2018 16:39:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=6CZ8u2Hp6BszJscW6OKAY0pFx5HDYwXE3CfpN14wo7w=; b=EC9mYGM4U7MOgNIWhpuJr2gljA EN1yR9PngfOEjdUMJvpPTfdPwg4c0QsPeIJleGbGRmTuJSMKyH9Od8eDbCnwzSE9PsecxtztUxNvE VZBSgGt8z7o+SbqIK3n9PBmJ+4XYANqG6WfzIAtt03sbIl7F9XViV471HXwfAMbDnnXvqOMqSnX2b Y0OME3MeEhYK1riRoKrbVMAH+NTxt26W7666Tz3mV00xFloC0RgCHaKZPPPp9ud1gR7Wl5Qfb2ty5 eNmhU0YtJYAJRJkCGhbgvKZF3KS9k7kn3qCM3ag+IcDoMiB4QVyJZknQjMpNCLny8dUtTmxDLGiYv AXlohccQ==; Received: from 213-225-37-95.nat.highway.a1.net ([213.225.37.95] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gJdrB-0003ZI-Hq; Mon, 05 Nov 2018 12:19:49 +0000 From: Christoph Hellwig To: iommu@lists.linux-foundation.org Cc: Robin Murphy , Catalin Marinas , Will Deacon , Guo Ren , Laura Abbott , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/9] dma-mapping: support highmem in the generic remap allocator Date: Mon, 5 Nov 2018 13:19:27 +0100 Message-Id: <20181105121931.13481-6-hch@lst.de> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181105121931.13481-1-hch@lst.de> References: <20181105121931.13481-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 By using __dma_direct_alloc_pages we can deal entirely with struct page instead of having to derive a kernel virtual address. 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); } } -- 2.19.1