Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1789772imu; Thu, 24 Jan 2019 01:49:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN7swYC3YK41p0trPz8T6ihr6wqdhQIgvDqNacbVWh/w2/iTAniA0t+zl+m4g0JntH2plyGo X-Received: by 2002:a63:3e05:: with SMTP id l5mr4990889pga.96.1548323399663; Thu, 24 Jan 2019 01:49:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548323399; cv=none; d=google.com; s=arc-20160816; b=fQ2DlvREbQk2YOWHCqaV1kwMB+NIJHNX/1J+zzsnpLJwmkmVwFbs+5K8TDBex+uAi3 UIBdsaIqkX+F00LgruEOEarjPUaNA8din2Ml/8yQFMZ2P8GOw2ejLihC7/ph5jhg4dyp Y8Dla2vyVVHBZAJ2PbeLNj/4n3DY1EEjGEktL48Pk9e/O+ysRENWflTRgf3FyHyZcgAG k4t5yxSjwFrhVrZs0lyfAkbKHMoDtqocIaxDJ4HIr6WpzlSqVcBv7JP8mBEtbdSx21UK yK8n4yf/Pzm4h8952kF45Ba9egbYCCvZOKVMmig+ahA/afKEK7pY5mwvMN3MtFNsAO5E n8iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=lmFP/pb4I5zeZfqkGNoFLNvT1VnfwQ5xiH+1Aqxo9WU=; b=R7zktt7qGlYx983ZPn/Xr4By0rIYBKfiF596TgeVMSlaaKrXF98SSPoP3Gq6dbTAjC gItjbsRuq+AdgNc0Ctx6d0oOKVrgTJI4hAfslpnPz7r7KthJ54lw7pofp4TkxO5/KR2o C+sn1uG6Q34fo+x4SVledCQL+TB+cOKvXqLQZXOgSMmaYDuqnD4haI9wfCWkku74zL1U bY28ojOEhRRG/5JbT+Oe88K69cys4Vz17PPFJfIXTqQovxqu9y1eU3gc5iC9D9y6dM2k +8xFnO65H6FMeL+Q+zNkgHDOkldCRRcN68uy+q9KF5C4vzdpsOAr41QyQEVuhrW0NWB6 xTqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S6uns5Nv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 27si21530061pgu.421.2019.01.24.01.49.43; Thu, 24 Jan 2019 01:49:59 -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=pass header.i=@linaro.org header.s=google header.b=S6uns5Nv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727445AbfAXJsO (ORCPT + 99 others); Thu, 24 Jan 2019 04:48:14 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:35250 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726050AbfAXJsN (ORCPT ); Thu, 24 Jan 2019 04:48:13 -0500 Received: by mail-wm1-f68.google.com with SMTP id t200so2307462wmt.0 for ; Thu, 24 Jan 2019 01:48:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=lmFP/pb4I5zeZfqkGNoFLNvT1VnfwQ5xiH+1Aqxo9WU=; b=S6uns5NvROKjcHrjjPdRTiVOP6Jr3+gYGBi5Nj1xbr8p8a9O83CNFnyO3Y2++RfCN3 x77XVvgLInsrMuj0hsIhYUxIgTcwzDeZ1dlBVd89sWpLxFEteg9jr8kxmNSFvFPS7fel n6Xw5jOwFpOaDD7G8BPcTIbZiWUrpVR0jKjFY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=lmFP/pb4I5zeZfqkGNoFLNvT1VnfwQ5xiH+1Aqxo9WU=; b=Nza2+We35DCn7QoR1aMg1MDlRDCsPDT57x2MB9jldMHuPlJRkQzDwgl1DfQlsPj6A2 1zpt0jxVcZUQZMCXfcIspjWnr7WlJ3xSmmqhLEabCGoT8JltLMujuGy+i/39fMIXfi0C oTt4bqgmDmWymMrW8FS5V7anQ1i3d8woz/WsIff6m1BInsUbKkKp2gmrsah99+Xx/e+5 21u5Oxt+eoaEsTybnZmrn7PIi+LHft2tWLPJ+pHlwGyZVFB94qxJU5KAoVGb9oe2zi41 152Cop84mOWC3QBRxGwsXw32QC+ZEuMdc+5X2oF2TSE9dQ+oWNyEA+8JK7nPXYzzslAB kvfw== X-Gm-Message-State: AJcUukeBIoaZiRdjw1X3a3W5nESwTMONXpPxzhGku4MQQb/YrWGbvnZa axkZAG1ETXXpQvpCWyp+HKQZ7g== X-Received: by 2002:a1c:7eca:: with SMTP id z193mr1808014wmc.5.1548323290424; Thu, 24 Jan 2019 01:48:10 -0800 (PST) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id e17sm161551887wri.36.2019.01.24.01.48.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Jan 2019 01:48:09 -0800 (PST) Date: Thu, 24 Jan 2019 09:48:07 +0000 From: Daniel Thompson To: Sumit Garg Cc: jens.wiklander@linaro.org, herbert@gondor.apana.org.au, ard.biesheuvel@linaro.org, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, yamada.masahiro@socionext.com, michal.lkml@markovi.net, mpm@selenic.com, robh+dt@kernel.org, mark.rutland@arm.com, arnd@arndb.de, gregkh@linuxfoundation.org, bhsharma@redhat.com, tee-dev@lists.linaro.org Subject: Re: [PATCH v5 2/4] tee: add supp_nowait flag in tee_context struct Message-ID: <20190124094807.yg5onsmbx46bi7bm@holly.lan> References: <1548309279-5281-1-git-send-email-sumit.garg@linaro.org> <1548309279-5281-3-git-send-email-sumit.garg@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1548309279-5281-3-git-send-email-sumit.garg@linaro.org> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 24, 2019 at 11:24:37AM +0530, Sumit Garg wrote: > This flag indicates that requests in this context should not wait for > tee-supplicant daemon to be started if not present and just return > with an error code. It is needed for requests which should be > non-blocking in nature like ones arising from TEE based kernel drivers > or any in kernel api that uses TEE internal client interface. > > Signed-off-by: Sumit Garg Reviewed-by: Daniel Thompson > --- > drivers/tee/optee/supp.c | 10 +++++++++- > drivers/tee/tee_core.c | 13 +++++++++++++ > include/linux/tee_drv.h | 6 ++++++ > 3 files changed, 28 insertions(+), 1 deletion(-) > > diff --git a/drivers/tee/optee/supp.c b/drivers/tee/optee/supp.c > index 43626e1..92f56b8 100644 > --- a/drivers/tee/optee/supp.c > +++ b/drivers/tee/optee/supp.c > @@ -88,10 +88,18 @@ u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params, > { > struct optee *optee = tee_get_drvdata(ctx->teedev); > struct optee_supp *supp = &optee->supp; > - struct optee_supp_req *req = kzalloc(sizeof(*req), GFP_KERNEL); > + struct optee_supp_req *req; > bool interruptable; > u32 ret; > > + /* > + * Return in case there is no supplicant available and > + * non-blocking request. > + */ > + if (!supp->ctx && ctx->supp_nowait) > + return TEEC_ERROR_COMMUNICATION; > + > + req = kzalloc(sizeof(*req), GFP_KERNEL); > if (!req) > return TEEC_ERROR_OUT_OF_MEMORY; > > diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c > index 9f4c8bc..2612dfa 100644 > --- a/drivers/tee/tee_core.c > +++ b/drivers/tee/tee_core.c > @@ -105,6 +105,11 @@ static int tee_open(struct inode *inode, struct file *filp) > if (IS_ERR(ctx)) > return PTR_ERR(ctx); > > + /* > + * Default user-space behaviour is to wait for tee-supplicant > + * if not present for any requests in this context. > + */ > + ctx->supp_nowait = false; > filp->private_data = ctx; > return 0; > } > @@ -981,6 +986,14 @@ tee_client_open_context(struct tee_context *start, > } while (IS_ERR(ctx) && PTR_ERR(ctx) != -ENOMEM); > > put_device(put_dev); > + /* > + * Default behaviour for in kernel client is to not wait for > + * tee-supplicant if not present for any requests in this context. > + * Also this flag could be configured again before call to > + * tee_client_open_session() if any in kernel client requires > + * different behaviour. > + */ > + ctx->supp_nowait = true; > return ctx; > } > EXPORT_SYMBOL_GPL(tee_client_open_context); > diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h > index ce957ce..56d7f1b 100644 > --- a/include/linux/tee_drv.h > +++ b/include/linux/tee_drv.h > @@ -50,6 +50,11 @@ struct tee_shm_pool; > * @releasing: flag that indicates if context is being released right now. > * It is needed to break circular dependency on context during > * shared memory release. > + * @supp_nowait: flag that indicates that requests in this context should not > + * wait for tee-supplicant daemon to be started if not present > + * and just return with an error code. It is needed for requests > + * that arises from TEE based kernel drivers that should be > + * non-blocking in nature. > */ > struct tee_context { > struct tee_device *teedev; > @@ -57,6 +62,7 @@ struct tee_context { > void *data; > struct kref refcount; > bool releasing; > + bool supp_nowait; > }; > > struct tee_param_memref { > -- > 2.7.4 >