Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp489669imu; Mon, 5 Nov 2018 04:20:37 -0800 (PST) X-Google-Smtp-Source: AJdET5cEOM7wkQ2tF++q5Bk8FwWcF+XQKYbyAJRov9AF2BViXf1CV+OCw5BV210C61gOgtQmzhB5 X-Received: by 2002:a62:302:: with SMTP id 2-v6mr6510461pfd.135.1541420437006; Mon, 05 Nov 2018 04:20:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541420436; cv=none; d=google.com; s=arc-20160816; b=lXeHd1l+jkklHvNiyiETUiB3/G7UcbjKHZPVyKoKmMH8uSzWuacaaI+r4zu2Qxuxt2 nst3rHosqruKG17dwFSGviTajsjbdHcJ3u6KImbpGwGwkvT5W32j7xAt4oJq1yg0npmj odMjgEzJVHcNwPejEXZRtEy0OK/LX7daoXyr9QB2cj6h3j89BzqoJ+Y48Oh2KaVs53P3 gAWc+iNQhXLLSLyRpwClCHO7z/8zubO9riiLA4t89+PJT6y6DGynqU7RmCuq2hDV8r38 WUgjEbwF0Wh/A0v5GtETptdEH0J7G2ZmOk9mjjYfx/yd5rwHQt26n1279zU18npF01dV qkSQ== 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=d4McgTckpWhV6ILQUNWqr0DpsukYNOWnupHnTZO3Q1Y=; b=ExXRuslTyvcjeiLck6jHOKAgIPfnrccmoVII5nLsad7rqb1/srg8QCEeEj0f1mDbir n7aN86Q0KSStJKSJ23A6QHLqlR3Iu3sOv2dbGoFWSKMD9eonl8B7XpbduTTIT64P7A4+ zykEsl7qs5U/TzLK+tScljLuIdHVqpsP+Kq62l1TBgakUixyxsmg+vdkpVWtVm30D/da Ze9+Pq+jaNzBZJcbxMVYRKuX4sAUjQbX1zC5AYBf9Xa3hcBcIbnrGfi0LMhsV6wUHzC4 puAhDdkiqH/FUL1UqFQuArRTzJ469cUMSRvGidWFjpEX0D66BSIaHx89a9gktxbil2E7 arNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="YvZFw/zS"; 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 f189-v6si6935399pfg.84.2018.11.05.04.20.15; Mon, 05 Nov 2018 04:20:36 -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="YvZFw/zS"; 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 S1729601AbeKEVjP (ORCPT + 99 others); Mon, 5 Nov 2018 16:39:15 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:41344 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726358AbeKEVjP (ORCPT ); Mon, 5 Nov 2018 16:39:15 -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=d4McgTckpWhV6ILQUNWqr0DpsukYNOWnupHnTZO3Q1Y=; b=YvZFw/zSxNQYNeBPEjlLF6BgO3 RX6kpUdt6j24cM3h2nkrexoDOeH6G4WY+Bvm+/Glr4ThasP49NINGjgla5yotStbFsQk9fljVXjPA WnuzDqqv6APXd9+Hd4CwWiVX4GmZqSnnpK7uQGY0mdycHVLqkBfcG0MaXY2kSwVadCbNlPwFo/JBT PQSezbEcdBwar5k3LU8m4kc6+rmg5fbcz7DvtHfZmaphGCNl5p8uJP16+lfhfHngjX8Hp9lyCz/0d ImcwHKEvzB2WM1gz4d3uwjd0dS1LrCN/trLQg/l20fi4LY1HYjREzhJR5Nwg3nPkzNjbQUvzI6zSW IJl6BAsA==; 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 1gJdr2-0003KW-Qk; Mon, 05 Nov 2018 12:19:41 +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 2/9] dma-direct: reject highmem pages from dma_alloc_from_contiguous Date: Mon, 5 Nov 2018 13:19:24 +0100 Message-Id: <20181105121931.13481-3-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 dma_alloc_from_contiguous can return highmem pages depending on the setup, which a plain non-remapping DMA allocator can't handle. Detect this case and try the normal page allocator instead. Signed-off-by: Christoph Hellwig --- kernel/dma/direct.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 680287779b0a..c49849bcced6 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -162,6 +162,18 @@ void *dma_direct_alloc_pages(struct device *dev, size_t size, if (!page) return NULL; + if (PageHighMem(page)) { + /* + * Depending on the cma= arguments and per-arch setup + * dma_alloc_from_contiguous could return highmem pages. + * Without remapping there is no way to return them here, + * so log an error and fail. + */ + dev_info(dev, "Rejecting highmem page from CMA.\n"); + __dma_direct_free_pages(dev, size, page); + return NULL; + } + ret = page_address(page); if (force_dma_unencrypted()) { set_memory_decrypted((unsigned long)ret, 1 << get_order(size)); -- 2.19.1