Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10349955ybi; Thu, 11 Jul 2019 03:55:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwd4eUTKhz+F++4sKBn1QV7RU5bhLzdbdudWr9U5PjXskCLN4i0D5B/ncEmVy50HFZEe9pb X-Received: by 2002:a17:902:3381:: with SMTP id b1mr3994792plc.197.1562842517436; Thu, 11 Jul 2019 03:55:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562842517; cv=none; d=google.com; s=arc-20160816; b=EPT0jOuHpz8wGfzkzkpxnmTv6DxaZ15LWuRRZIH769WH/Z7ZuatW7FXPpk20s/zKvp btaNJrwvWYuV7hEA6GZggc69FGu5YxeVdgNpxM95+2Z0CrLw5XI0Ng/Wg1qT+Z71oYDO 3OfaXycz2yHOyrr9/SnNg1b6vG2oRDOWgymLug1EsMo/x7YtNhDosF9Z2VUnaZX/SP1+ qKg8dCWcw4I7+Un71citek+GARDT57UzCSGt6sGXXoSF5p1vl328M0hdiqOgC90ci3EE coSXy2Ji9S9CX0S2v5/jUrMjLS6cUtHaFx5CyzQwNgNXVCDnj6m3Y+rcGECGScjtAwCy GN1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id; bh=wOjBLTbS80uU9yusXyX0bqblzGZf0c4S4WlvkcjAY70=; b=G4Xf5/a8a3L5tdfjhNLYWwM4r8jOSrrDZL10WXeDvyypL1rUietlQB9be8IRIZLzZI ZLT4tj6xrjJF6nFgiqL4BbwcxsXTmJKl4XDxmU1PevInIF/9xK1qXKyxgmr9N1VKqmaa dKh60qUL8U3+S984+CO0d3bkxqjEU3F0xRhud/V/LZptTzodNzaZDq+x2lQOusd36sDG XBsn5ePR/o2QcS7RUT6XgjwpGA37+ax+OMRhOSwebwxlI1YFUSDfdzWRBQHEwscDvLro HxPqR887fXKBrHVluD+EukSLNb0N4Naeiy6S7gFMbh9MMs7x4Kx7Lhe9ky7xeJZ4cf4F +DeQ== 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 cj14si4618482plb.141.2019.07.11.03.54.58; Thu, 11 Jul 2019 03:55:17 -0700 (PDT) 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 S1728342AbfGKKo3 (ORCPT + 99 others); Thu, 11 Jul 2019 06:44:29 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:45791 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727865AbfGKKo2 (ORCPT ); Thu, 11 Jul 2019 06:44:28 -0400 X-UUID: f1369d86e92741d4a99963416bfb7caf-20190711 X-UUID: f1369d86e92741d4a99963416bfb7caf-20190711 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 366328366; Thu, 11 Jul 2019 18:44:22 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 11 Jul 2019 18:44:21 +0800 Received: from [172.21.77.33] (172.21.77.33) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Thu, 11 Jul 2019 18:44:21 +0800 Message-ID: <1562841861.9534.2.camel@mtkswgap22> Subject: Re: [PATCH] kernel/dma: export dma_alloc_from_contiguous to modules From: Miles Chen To: Robin Murphy CC: Christoph Hellwig , Marek Szyprowski , , , , Date: Thu, 11 Jul 2019 18:44:21 +0800 In-Reply-To: <7d14b94f-454f-d512-bc8f-589f71bc07ea@arm.com> References: <20190711053343.28873-1-miles.chen@mediatek.com> <7d14b94f-454f-d512-bc8f-589f71bc07ea@arm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2019-07-11 at 09:50 +0100, Robin Murphy wrote: > On 11/07/2019 06:33, miles.chen@mediatek.com wrote: > > From: Miles Chen > > > > This change exports dma_alloc_from_contiguous and > > dma_release_from_contiguous to modules. > > > > Currently, we can add a reserve a memory node in dts files, make > > it a CMA memory by setting compatible = "shared-dma-pool", > > and setup the dev->cma_area by using of_reserved_mem_device_init_by_idx(). > > > > Export dma_alloc_from_contiguous and dma_release_from_contiguous, so we > > can allocate/free from/to dev->cma_area in kernel modules. > > As far as I understand, this was never intended for drivers to call > directly. If a device has its own private CMA area, then regular > dma_alloc_attrs() should allocate from that automatically; if that's not > happening already, then there's a bug somewhere. > > Robin. Thanks for your comment. After using dma_direct_ops, dma_alloc_attrs() works fine now. Miles > > > Signed-off-by: Miles Chen > > --- > > kernel/dma/contiguous.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c > > index b2a87905846d..d5920bdedc77 100644 > > --- a/kernel/dma/contiguous.c > > +++ b/kernel/dma/contiguous.c > > @@ -197,6 +197,7 @@ struct page *dma_alloc_from_contiguous(struct device *dev, size_t count, > > > > return cma_alloc(dev_get_cma_area(dev), count, align, no_warn); > > } > > +EXPORT_SYMBOL_GPL(dma_alloc_from_contiguous); > > > > /** > > * dma_release_from_contiguous() - release allocated pages > > @@ -213,6 +214,7 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages, > > { > > return cma_release(dev_get_cma_area(dev), pages, count); > > } > > +EXPORT_SYMBOL_GPL(dma_release_from_contiguous); > > > > /* > > * Support for reserved memory regions defined in device tree > >