Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5637902pxb; Thu, 20 Jan 2022 01:13:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJxArXD9buRU+aIJR0h2LFEvtyDWUklKpNw4DKPczv/oJ3j6xGn/5MCQ5onEueITTbUiCB3A X-Received: by 2002:a17:90a:aa84:: with SMTP id l4mr2818442pjq.121.1642669999439; Thu, 20 Jan 2022 01:13:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642669999; cv=none; d=google.com; s=arc-20160816; b=sZLyXNCs1RQ+ooTddav9Hc41RToBRRdxFtCGBENePZtqIHcu25d04Zm8ovkPCc8ZwS pZhiYZYHiJqryU9P6xd/epqEwS5Onp5wFG0kGPEQbnRidhmBo/UVBcChOl0LIcIwmtFL eicV3Z6OWN60WbiM7kU43XEkF18fkkHQBHBhPnqsYTcNHmQfnKwDt6Goayg92e/4oL9l F1wh38wQy0aM3EXIh/HfZFKan3JkcmaIzkLMztRHzazlemRrtDctOZg94dl1j2QIMlQE IasJghLY/rKl4HaaKWegMEZseqlsO/HY18PXFxzZldIP6S3cYOH8WGSjyag7a6q3gVbF Ru2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=TVZaPKiTrsKRccgkQsYbK/pQLkqx8K3+Dy6ZGqF9QZA=; b=lgc25HVG5yk4Dmhe+qKP/vMjEBwYrBhUZtHrPAN9JSkuZF/8+c8V06lb0Gg3oSqIMJ vT0tKdrwyeQACrhaQjWWNO/QUbrJK+gmu3Y7bDo7zriB89uRKTp4gMCP5IT81SToGnLx g6MnltrYTEOAbcZ3WiOzXe6OCxIt8XybCk5oC60GtByzs6fcLyR4SLno98GhuFOcUgDu ccqI/jbaaAn+n2pkPQt5etD6AJtR1syD2T6Pyjl0xQZjVkrOOZT0NoI97lJrJig7WGgv 4irwGfRJKGJjlgcFR75AN4W8fYtEcUgnNEtE8mUFa0KuFljPFTbxBUVEr1PbuJkryEb6 WWLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pQYJtfx2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a28si2304761pfk.61.2022.01.20.01.13.07; Thu, 20 Jan 2022 01:13:19 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=pQYJtfx2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241892AbiARNLh (ORCPT + 99 others); Tue, 18 Jan 2022 08:11:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238429AbiARNLe (ORCPT ); Tue, 18 Jan 2022 08:11:34 -0500 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96555C061574 for ; Tue, 18 Jan 2022 05:11:33 -0800 (PST) Received: by mail-lf1-x135.google.com with SMTP id x7so70436578lfu.8 for ; Tue, 18 Jan 2022 05:11:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TVZaPKiTrsKRccgkQsYbK/pQLkqx8K3+Dy6ZGqF9QZA=; b=pQYJtfx2w4zuiE62aojn4PLOdpiyQrAbWcBncTzDWYYISGz7tW6CEkat1z81YSOJrW R5VGOQ/dff5gjz4oeMbb2rWoGmzv8DzMMd8sgHnQcNx/TCxkqJHQq/Wl0yyH5Gxi9cWA jG9EkPopRUiiQDbPIyZ6W6L51mGx+8V8CoRAfDgqkSxgfj5G0WhOv5+yMNJEiWJT9HjU bg/n0FFVCg6QzlS6T21XfbnEDfzOMr7TjGYofvQpHrvKiIQGQ1SDQBZ3+BIfBy6pLUp3 yEqeP2rA8kGPIQhKmxVtGeZfn+wy9oyo54aBpNbFCqGkLCKXeFDIkGX+JId30JVLopaR EmhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TVZaPKiTrsKRccgkQsYbK/pQLkqx8K3+Dy6ZGqF9QZA=; b=gacTWPnFiKJTGYwg9xV9KQs6KwuRQftr3dKlmUsym44Wb/TV89g9hd4084/obbhi8R 8Wq8lxhONlJn3zZ50c69ULETeuThcLXEmyStUunwcTMHPk/4fFsiS+Ozew9PVwhKeZq8 bm/A5ZXpcgmhvXPk6qD1G4QicRyHtfyfMYsEE4JY7WYEV2d5J5JwfghddbuDCB5BirJF ER8sQTmVrfyQh7dwvw4SZOnSNklF44uDlPnH27+90MiZkLdw1RDu+Smpj4FY1QIFJIAJ lri/2/RTe1ycGplssGqQoydHslc4V/MireWAkfXShMowzJVPXTy0byT3gADK/YSOsgda g1JA== X-Gm-Message-State: AOAM532roKggvMDxPr/BlzYWSGrTS7dn0670XK3jSLCAk/s2nmUIpLt4 CVUDqbMP0pwu+i11/NvIhlXk1LMAoOylve3xL2ZNRY6q86fdK24A X-Received: by 2002:a05:6512:34d3:: with SMTP id w19mr2395401lfr.253.1642511491968; Tue, 18 Jan 2022 05:11:31 -0800 (PST) MIME-Version: 1.0 References: <20220114150824.3578829-1-jens.wiklander@linaro.org> <20220114150824.3578829-4-jens.wiklander@linaro.org> In-Reply-To: <20220114150824.3578829-4-jens.wiklander@linaro.org> From: Sumit Garg Date: Tue, 18 Jan 2022 18:41:20 +0530 Message-ID: Subject: Re: [PATCH v2 03/12] tee: add tee_shm_alloc_user_buf() To: Jens Wiklander Cc: linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org, Herbert Xu , Devaraj Rangasamy , Rijo Thomas , David Howells , Tyler Hicks Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 14 Jan 2022 at 20:38, Jens Wiklander wrote: > > Adds a new function tee_shm_alloc_user_buf() or user mode allocations, > replacing passing the flags TEE_SHM_MAPPED | TEE_SHM_DMA_BUF to > tee_shm_alloc(). > > Signed-off-by: Jens Wiklander > --- > drivers/tee/tee_core.c | 2 +- > drivers/tee/tee_shm.c | 18 ++++++++++++++++++ > drivers/tee/tee_shm_pool.c | 2 +- > include/linux/tee_drv.h | 3 ++- > 4 files changed, 22 insertions(+), 3 deletions(-) > > diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c > index 3fc426dad2df..a15812baaeb1 100644 > --- a/drivers/tee/tee_core.c > +++ b/drivers/tee/tee_core.c > @@ -297,7 +297,7 @@ static int tee_ioctl_shm_alloc(struct tee_context *ctx, > if (data.flags) > return -EINVAL; > > - shm = tee_shm_alloc(ctx, data.size, TEE_SHM_MAPPED | TEE_SHM_DMA_BUF); > + shm = tee_shm_alloc_user_buf(ctx, data.size); Since it's the only place this API would be used within the driver itself and I can't see any future usage from other kernel drivers.. > if (IS_ERR(shm)) > return PTR_ERR(shm); > > diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c > index 499fccba3d74..b43178986985 100644 > --- a/drivers/tee/tee_shm.c > +++ b/drivers/tee/tee_shm.c > @@ -127,6 +127,24 @@ struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags) > } > EXPORT_SYMBOL_GPL(tee_shm_alloc); > > +/** > + * tee_shm_alloc_user_buf() - Allocate shared memory for user space > + * @ctx: Context that allocates the shared memory > + * @size: Requested size of shared memory > + * > + * Memory allocated as user space shared memory is automatically freed when > + * the TEE file pointer is closed. The primary usage of this function is > + * when the TEE driver doesn't support registering ordinary user space > + * memory. > + * > + * @returns a pointer to 'struct tee_shm' > + */ > +struct tee_shm *tee_shm_alloc_user_buf(struct tee_context *ctx, size_t size) > +{ > + return tee_shm_alloc(ctx, size, TEE_SHM_MAPPED | TEE_SHM_DMA_BUF); > +} > +EXPORT_SYMBOL_GPL(tee_shm_alloc_user_buf); > + ..so I don't see any value-add for this export.. > /** > * tee_shm_alloc_kernel_buf() - Allocate shared memory for kernel buffer > * @ctx: Context that allocates the shared memory > diff --git a/drivers/tee/tee_shm_pool.c b/drivers/tee/tee_shm_pool.c > index a9f9d50fd181..0e460347138a 100644 > --- a/drivers/tee/tee_shm_pool.c > +++ b/drivers/tee/tee_shm_pool.c > @@ -1,6 +1,6 @@ > // SPDX-License-Identifier: GPL-2.0-only > /* > - * Copyright (c) 2015, Linaro Limited > + * Copyright (c) 2015, 2017, 2022 Linaro Limited > */ > #include > #include > diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h > index 6b0f0d01ebdf..26b450484ac1 100644 > --- a/include/linux/tee_drv.h > +++ b/include/linux/tee_drv.h > @@ -1,6 +1,6 @@ > /* SPDX-License-Identifier: GPL-2.0-only */ > /* > - * Copyright (c) 2015-2016, Linaro Limited > + * Copyright (c) 2015-2022 Linaro Limited > */ > > #ifndef __TEE_DRV_H > @@ -308,6 +308,7 @@ void *tee_get_drvdata(struct tee_device *teedev); > * @returns a pointer to 'struct tee_shm' > */ > struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags); > +struct tee_shm *tee_shm_alloc_user_buf(struct tee_context *ctx, size_t size); ..and it should rather belong to drivers/tee/tee_private.h. -Sumit > struct tee_shm *tee_shm_alloc_kernel_buf(struct tee_context *ctx, size_t size); > > /** > -- > 2.31.1 >