Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp260256rdh; Thu, 26 Oct 2023 01:04:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmbOgpAHOHBVnFekvCDgLUSJUDRB91iZStVss3cCthUY/ZFoCbFbKcFIAXLMnXLGOmhb73 X-Received: by 2002:a81:a08b:0:b0:5a7:e5de:79a4 with SMTP id x133-20020a81a08b000000b005a7e5de79a4mr20093176ywg.17.1698307495257; Thu, 26 Oct 2023 01:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698307495; cv=none; d=google.com; s=arc-20160816; b=nUBPvnjjFXv420pYyks+KlTN0jO6XNhyjOfqXl9m/0dwCdUAKdjVdbrkxMBpV4YDkr ZMnlAUyqHHfWmtPySnHTqmrhZ0mSxH0JHdtXhGmDEh7297F7DTq+HnImtgvTcV2LA/Yy Iq548M0BI5Q5kCqXWonfLhpnaLWQJirvkXMuL4oRp6CR+tJQWx/4nhyB6q0Hios3JO0i vhnmbURZC9MoEKqaW8KSoo+h/AZ7lCMVvScG1jMpIv0/QeKKfuhDUeP4wz0rC1nMahbA Xw9YQn3DlctMohN39tOYwXmOOlEp/rj29+dmF0/tFHSgM5ktpIoieMN3UUyUwYaw4neO dmxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1MSbsB17ImXC7InZqbHYeoUD4yxFmt2thb5ufhbkOeg=; fh=MUQ6rxZ25LNC+jTmyAXdEOxVXq57wz7eCStwGhwbXZY=; b=yNB3Xqv/Tz52BLlXmUJHRTaxJ1dsOmT9FR3AlQQApJv3aaww55hBpqyJZaZSjezLFb 7oMpFk/UM2a31QRmbMEU/xpsAqU59WGn/cQSpQQmzvm/9/Vy4BBchsj3pNDP0y4M2ccy PlpwUBY1NlqR555aYSlFzxR7A1h4WVNyDhgjouZs+xLSaBnEL/30Z7u0RB8uIIc8Ft37 NkFaW6X9liovh2EsRWJV96H5v+WZy4YzZMac1zV6wlUzbEr4PZL3sSR7jUkWo6kvaI+7 CBT9tVJZ2y+/yba/N3H1sYUvRPuV8w1cnmq6BxJ1h8Owr40gjUwPUi8fbNhhlMsT1n3z 82Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kFqMckzd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id j131-20020a816e89000000b005652078563csi14237758ywc.153.2023.10.26.01.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 01:04:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kFqMckzd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E499B82696F7; Thu, 26 Oct 2023 01:04:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234602AbjJZIEX (ORCPT + 99 others); Thu, 26 Oct 2023 04:04:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231383AbjJZIEU (ORCPT ); Thu, 26 Oct 2023 04:04:20 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A5B1198 for ; Thu, 26 Oct 2023 01:04:17 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-53de0d1dc46so916941a12.3 for ; Thu, 26 Oct 2023 01:04:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698307455; x=1698912255; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1MSbsB17ImXC7InZqbHYeoUD4yxFmt2thb5ufhbkOeg=; b=kFqMckzdkdxT79lUzRWr3wzEHVCCTnU7Rxgp5og1ovfbWfTd+R4kDY1dpQteM0L+h4 3uHfZRQ8ujs7mZeRXkK+aXhmO35XOhlOvDxbQtu3UFU9pQZaCClai3CuQ9WmOrzv5HXC UCZZjwyfcJL/3H0IGwhvbYi3YhUrratFGpuqXD8w8WszoZU6+0giKp59Ggj0pTJkEs4t dxInoo+vKIOPDfs0K2xmrsMMLUo8+jQLcqUj8YfeNWBPCI2SJuog3ziu8nXFyYtE//VH C0UU1UKdhOnmCmz/1rtsKX9UbOuNb7++YR94v5tdRazdfB7Sgo6bEF4zo1QfSV7J8LpJ y6xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698307455; x=1698912255; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1MSbsB17ImXC7InZqbHYeoUD4yxFmt2thb5ufhbkOeg=; b=eSQXJXc74eldnQR77n2IAyaZxPZzFHOko0oHJrnnAYyBVPnr8oK1gLVYeLHKSPZcIF DWsZg+zUKcmflz3ztgzLCHv9g95yspi+lw6gnMcPWncqZHqpNVa3aVeW+hejwVxMD1Y2 h6neSD4DFVB54iPebdyxTI3hc2FxsDD1ZdoJVNjzrA/F5Db9gKO7HVWmhjULiJZZPtBy 9JS+zGqhnpXVLvPa1cpTFcR5ES5UB9nv1RLrbhv/hjFTPR6yI2fynI3pA2lGY9F8mQBY kEGpvkGoiJYx4n7lTWNlFG5uVWugGKiCVWuVtEKBmo1ZnZtklmam/mQ9S9lK9UuIeI1r vyuA== X-Gm-Message-State: AOJu0Yyhqk8Sb1AUoed7VV6+jgpj1SWZFEVu1wUP3Zk7U1kxbfG8gl5D C4vwxw9UK1H9HT3Vq1uw0rHpcwH6aZjARAucOJ4= X-Received: by 2002:a17:907:7e8e:b0:9a2:225a:8d01 with SMTP id qb14-20020a1709077e8e00b009a2225a8d01mr13773554ejc.7.1698307455418; Thu, 26 Oct 2023 01:04:15 -0700 (PDT) Received: from rayden.urgonet (h-217-31-164-171.A175.priv.bahnhof.se. [217.31.164.171]) by smtp.gmail.com with ESMTPSA id a19-20020a1709065f9300b0099e12a49c8fsm11313448eju.173.2023.10.26.01.04.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 01:04:14 -0700 (PDT) From: Jens Wiklander To: linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org Cc: Sumit Garg , Jerome Forissier , Sudeep Holla , Marc Bonnici , Olivier Deprez , Lorenzo Pieralisi , Jens Wiklander Subject: [PATCH 1/2] optee: provide optee_do_bottom_half() as a common function Date: Thu, 26 Oct 2023 10:04:08 +0200 Message-Id: <20231026080409.4149616-2-jens.wiklander@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026080409.4149616-1-jens.wiklander@linaro.org> References: <20231026080409.4149616-1-jens.wiklander@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 26 Oct 2023 01:04:52 -0700 (PDT) Provides optee_do_bottom_half() and optee_stop_async_notif() as common functions callable from the FF-A ABI part of the driver too. Signed-off-by: Jens Wiklander --- drivers/tee/optee/call.c | 31 +++++++++++++++++++++++++- drivers/tee/optee/optee_private.h | 5 ++++- drivers/tee/optee/smc_abi.c | 36 ++++--------------------------- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/drivers/tee/optee/call.c b/drivers/tee/optee/call.c index df5fb5410b72..5afc759794ce 100644 --- a/drivers/tee/optee/call.c +++ b/drivers/tee/optee/call.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2015-2021, Linaro Limited + * Copyright (c) 2015-2021, 2023 Linaro Limited */ #include #include @@ -524,3 +524,32 @@ int optee_check_mem_type(unsigned long start, size_t num_pages) return rc; } + +static int simple_call_with_arg(struct tee_context *ctx, u32 cmd) +{ + struct optee *optee = tee_get_drvdata(ctx->teedev); + struct optee_shm_arg_entry *entry; + struct optee_msg_arg *msg_arg; + struct tee_shm *shm; + u_int offs; + + msg_arg = optee_get_msg_arg(ctx, 0, &entry, &shm, &offs); + if (IS_ERR(msg_arg)) + return PTR_ERR(msg_arg); + + msg_arg->cmd = cmd; + optee->ops->do_call_with_arg(ctx, shm, offs); + + optee_free_msg_arg(ctx, entry, offs); + return 0; +} + +int optee_do_bottom_half(struct tee_context *ctx) +{ + return simple_call_with_arg(ctx, OPTEE_MSG_CMD_DO_BOTTOM_HALF); +} + +int optee_stop_async_notif(struct tee_context *ctx) +{ + return simple_call_with_arg(ctx, OPTEE_MSG_CMD_STOP_ASYNC_NOTIF); +} diff --git a/drivers/tee/optee/optee_private.h b/drivers/tee/optee/optee_private.h index 72685ee0d53f..2165bd11e6ac 100644 --- a/drivers/tee/optee/optee_private.h +++ b/drivers/tee/optee/optee_private.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2015-2021, Linaro Limited + * Copyright (c) 2015-2021, 2023 Linaro Limited */ #ifndef OPTEE_PRIVATE_H @@ -325,6 +325,9 @@ void optee_rpc_cmd_free_suppl(struct tee_context *ctx, struct tee_shm *shm); void optee_rpc_cmd(struct tee_context *ctx, struct optee *optee, struct optee_msg_arg *arg); +int optee_do_bottom_half(struct tee_context *ctx); +int optee_stop_async_notif(struct tee_context *ctx); + /* * Small helpers */ diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c index d5b28fd35d66..94e96803a722 100644 --- a/drivers/tee/optee/smc_abi.c +++ b/drivers/tee/optee/smc_abi.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2015-2021, Linaro Limited + * Copyright (c) 2015-2021, 2023 Linaro Limited * Copyright (c) 2016, EPAM Systems */ @@ -965,34 +965,6 @@ static int optee_smc_do_call_with_arg(struct tee_context *ctx, return rc; } -static int simple_call_with_arg(struct tee_context *ctx, u32 cmd) -{ - struct optee_shm_arg_entry *entry; - struct optee_msg_arg *msg_arg; - struct tee_shm *shm; - u_int offs; - - msg_arg = optee_get_msg_arg(ctx, 0, &entry, &shm, &offs); - if (IS_ERR(msg_arg)) - return PTR_ERR(msg_arg); - - msg_arg->cmd = cmd; - optee_smc_do_call_with_arg(ctx, shm, offs); - - optee_free_msg_arg(ctx, entry, offs); - return 0; -} - -static int optee_smc_do_bottom_half(struct tee_context *ctx) -{ - return simple_call_with_arg(ctx, OPTEE_MSG_CMD_DO_BOTTOM_HALF); -} - -static int optee_smc_stop_async_notif(struct tee_context *ctx) -{ - return simple_call_with_arg(ctx, OPTEE_MSG_CMD_STOP_ASYNC_NOTIF); -} - /* * 5. Asynchronous notification */ @@ -1048,7 +1020,7 @@ static irqreturn_t notif_irq_thread_fn(int irq, void *dev_id) { struct optee *optee = dev_id; - optee_smc_do_bottom_half(optee->ctx); + optee_do_bottom_half(optee->ctx); return IRQ_HANDLED; } @@ -1086,7 +1058,7 @@ static void notif_pcpu_irq_work_fn(struct work_struct *work) notif_pcpu_work); struct optee *optee = container_of(optee_smc, struct optee, smc); - optee_smc_do_bottom_half(optee->ctx); + optee_do_bottom_half(optee->ctx); } static int init_pcpu_irq(struct optee *optee, u_int irq) @@ -1158,7 +1130,7 @@ static void uninit_pcpu_irq(struct optee *optee) static void optee_smc_notif_uninit_irq(struct optee *optee) { if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_ASYNC_NOTIF) { - optee_smc_stop_async_notif(optee->ctx); + optee_stop_async_notif(optee->ctx); if (optee->smc.notif_irq) { if (irq_is_percpu_devid(optee->smc.notif_irq)) uninit_pcpu_irq(optee); -- 2.34.1