From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93D7EC4338F for ; Mon, 9 Aug 2021 07:17:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71D6460F55 for ; Mon, 9 Aug 2021 07:17:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233364AbhHIHR3 (ORCPT ); Mon, 9 Aug 2021 03:17:29 -0400 Received: from smtp1.de.adit-jv.com ([93.241.18.167]:34248 "EHLO smtp1.de.adit-jv.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233283AbhHIHRM (ORCPT ); Mon, 9 Aug 2021 03:17:12 -0400 Received: from hi2exch02.adit-jv.com (hi2exch02.adit-jv.com [10.72.92.28]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id DC8053C0016; Mon, 9 Aug 2021 09:16:50 +0200 (CEST) Received: from lxhi-059.adit-jv.com (10.72.93.144) by hi2exch02.adit-jv.com (10.72.92.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Mon, 9 Aug 2021 09:16:50 +0200 From: Christoph Gellner To: , CC: , Christoph Gellner Subject: [PATCH 3/3 RESEND] tee: optee: Allow to freeze while waiting in OPTEE_RPC_WAIT_QUEUE_SLEEP Date: Mon, 9 Aug 2021 09:14:52 +0200 Message-ID: <20210809071452.28508-4-cgellner@de.adit-jv.com> X-Mailer: git-send-email 2.32.0.rc0 In-Reply-To: <20210809071452.28508-1-cgellner@de.adit-jv.com> References: <20210809071452.28508-1-cgellner@de.adit-jv.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.72.93.144] X-ClientProxiedBy: hi2exch02.adit-jv.com (10.72.92.28) To hi2exch02.adit-jv.com (10.72.92.28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the system is going to hibernate or suspend and the task calling the corresponding OPTEE_RPC_WAIT_QUEUE_WAKEUP gets frozen waiting for completion in OPTEE_RPC_WAIT_QUEUE_SLEEP might get stuck. Change wait to interruptible and add try_to_freeze in order to allow that the waiting task is frozen as well. Signed-off-by: Christoph Gellner --- drivers/tee/optee/rpc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/tee/optee/rpc.c b/drivers/tee/optee/rpc.c index 1849180b0278..0851b19be529 100644 --- a/drivers/tee/optee/rpc.c +++ b/drivers/tee/optee/rpc.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "optee_private.h" #include "optee_smc.h" #include "optee_rpc_cmd.h" @@ -169,7 +170,13 @@ static void wq_sleep(struct optee_wait_queue *wq, u32 key) struct wq_entry *w = wq_entry_get(wq, key); if (w) { - wait_for_completion(&w->c); + /* + * wait_for_completion but allow hibernation/suspend + * to freeze the waiting task + */ + while (wait_for_completion_interruptible(&w->c)) + try_to_freeze(); + mutex_lock(&wq->mu); list_del(&w->link); mutex_unlock(&wq->mu); -- 2.32.0.rc0