Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp745721ybt; Wed, 8 Jul 2020 10:38:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvvlGDJYHUccndPF8b0KQwumNoWf2z4n4gmm2SG77UK31SBdy9RRhXtAwAiH08mIuu7nvY X-Received: by 2002:a05:6402:1a4b:: with SMTP id bf11mr52474978edb.191.1594229880002; Wed, 08 Jul 2020 10:38:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594229879; cv=none; d=google.com; s=arc-20160816; b=BqETSRtew/BYxVppXR3w5Anax7VKuKmWL80HrqWhpF5FLwlaWGfrrLk5tK19BeNaZv MdAaIrvrAvmnNKwaFC2ZYxzygwJRJMeZm3WTUwzj91oKPfuMwkUcACzE63tPFK/2o1is mUFwgy9lBU3IUKhI2VR2p4VEOWyePs3HlL/vvneRqsJ9vyuMck6wP1fh98tH69GRP7DT Y0AqB8/mlTQO5JrwPqJV2d+JC6yHpMYWktydN+M74kdwPG+vyAW/xrqwe7z89PO636+F i99ii+1vHSoz23SC0fjsYZvbthXazDRjCXizRsMPiOeQC+GgBViRxl3KmaKKgMw/af5/ ZO3w== 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 :message-id:date:subject:cc:to:from; bh=lxqwCd0/zg6hIQL7rrgTVTn03JX+tqSeLpfLmresWd0=; b=d/fOl5aHqZ1Yge5VoWPZa0o5HYtHUkz3NmAGxewrvNlQCKKkW/85Pt29rqLYXBHiFq jX1YJWIU+m1xHsWuIJufDP8L/06a51Nv5Jr1OeS775w84kiw5mhGognikf2sctwz2N5A /4rOj1gNScT5kTmDWoHP9Ro7DWwGWBan3gM7nNqqxhMXWJheZmJTftAAQQN7Y1qjbqsa Z5TlZdkLz4V1XtC6cOkLlZyJG29BEinkIvJzkiTUxIGqFYy1Rf5UopdfoCE4LEGX6X8W evhHnNHyOlKf5JozZNJrNKhwgC91PVJvN3NoB387u23yvBsr5PcO0MOAHZN2fkDaW4eX kgUA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v9si305637eja.482.2020.07.08.10.37.37; Wed, 08 Jul 2020 10:37:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730500AbgGHRNo (ORCPT + 99 others); Wed, 8 Jul 2020 13:13:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:43606 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725953AbgGHRNn (ORCPT ); Wed, 8 Jul 2020 13:13:43 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E9F5BAE02; Wed, 8 Jul 2020 16:55:29 +0000 (UTC) From: Nicolas Saenz Julienne To: Christoph Hellwig , Marek Szyprowski , Robin Murphy , David Rientjes Cc: linux-rpi-kernel@lists.infradead.org, jeremy.linton@arm.com, Nicolas Saenz Julienne , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH] dma-pool: Do not allocate pool memory from CMA Date: Wed, 8 Jul 2020 18:49:39 +0200 Message-Id: <20200708164936.9340-1-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no guarantee to CMA's placement, so allocating a zone specific atomic pool from CMA might return memory from a completely different memory zone. So stop using it. Fixes: c84dc6e68a1d ("dma-pool: add additional coherent pools to map to gfp mask") Reported-by: Jeremy Linton Signed-off-by: Nicolas Saenz Julienne --- An more costly alternative would be adding an option to dma_alloc_from_contiguous() so it fails when the allocation doesn't fall in a specific zone. kernel/dma/pool.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c index 8cfa01243ed2..4bc1c46ae6ef 100644 --- a/kernel/dma/pool.c +++ b/kernel/dma/pool.c @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -69,12 +68,7 @@ static int atomic_pool_expand(struct gen_pool *pool, size_t pool_size, do { pool_size = 1 << (PAGE_SHIFT + order); - - if (dev_get_cma_area(NULL)) - page = dma_alloc_from_contiguous(NULL, 1 << order, - order, false); - else - page = alloc_pages(gfp, order); + page = alloc_pages(gfp, order); } while (!page && order-- > 0); if (!page) goto out; @@ -118,8 +112,7 @@ static int atomic_pool_expand(struct gen_pool *pool, size_t pool_size, dma_common_free_remap(addr, pool_size); #endif free_page: __maybe_unused - if (!dma_release_from_contiguous(NULL, page, 1 << order)) - __free_pages(page, order); + __free_pages(page, order); out: return ret; } -- 2.27.0