Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5017959pxj; Wed, 26 May 2021 00:21:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxA2OSf8RMQVeT2aFkSY15qVyZScsNnkE9UHRqvD+MMbIAQ73djIXMqXaTbLvY+R25AmkX8 X-Received: by 2002:a05:6402:518f:: with SMTP id q15mr36353797edd.345.1622013673933; Wed, 26 May 2021 00:21:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622013673; cv=none; d=google.com; s=arc-20160816; b=xf7dH5ba5ySvt1hzXlxuRVCiOtohVZT0I2qh0I7G2BjrufE6UniehP4YEwV9DYZTs6 Hp0jc800jEHPWCtOOxt7u6yG/1GXMfH857+MK6XT6g1AltSTpWNyx74kFeRp3PDXqTRl xt852JIK4pVW5z0IW9Z/KPYKuk+uExqeI9lJ/J0OX7m7zte06dd3x0Gu0RoRyb3Ju1sJ hyJq2b33UCmQlBoiY7Aa4XR2iTNMRU8aVKS+mKWuRL+7Qtut5x7AOAWeJaS/YtyEhmMa K93yN5fhoTmkz7yUv065J8LL3948SFt1VgHKQ0Nv1VYB6AkrqaaGNM20LXtm3OBQH2ey asGg== 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; bh=nJ1OnQyR7RTouJ2iFxXbOZYyw3KDNBf3hiF4Yse7Z+o=; b=YaQrG197Hm8ao1jvimtQNa4fC3WM0NAo1jJTr0nYWsaH9qfYLv/M+dyDdsAsWv1zze O9rHCquTmmjwT3h7jTPEvU6Cr7MSca81JwTYfnNIjn2vVXwgza4V1+Cog1sYbO/8niSu XDCvNT/cDyP8u0Rb9SK/JUXNaQREb/yVxroIraIE2jVhINI50YExuGiHSQvsH6mcR/4c CHPOIzZpLk0kdlUZ1yYF9msDcWc4L18zUJ0bWyaHdbxdbZm2o4i58WzI+OXq/CBsZWHB KcSTJqz3+qF3nSqrdZY/pGlknZ75Co4cAg1fa2ru1fLQssGTGHxXhGd7iSGDnlAiY4D5 eJNg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k3si18300766edi.75.2021.05.26.00.20.48; Wed, 26 May 2021 00:21:13 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233014AbhEZHTk (ORCPT + 99 others); Wed, 26 May 2021 03:19:40 -0400 Received: from smtp1.de.adit-jv.com ([93.241.18.167]:39654 "EHLO smtp1.de.adit-jv.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232970AbhEZHTX (ORCPT ); Wed, 26 May 2021 03:19:23 -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 DBE823C057C; Wed, 26 May 2021 09:11:16 +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.2176.14; Wed, 26 May 2021 09:11:16 +0200 From: Christoph Gellner To: , CC: , Christoph Gellner Subject: [RFC PATCH 3/3] tee: optee: Allow to freeze while waiting in OPTEE_RPC_WAIT_QUEUE_SLEEP Date: Wed, 26 May 2021 09:09:11 +0200 Message-ID: <20210526070911.31681-4-cgellner@de.adit-jv.com> X-Mailer: git-send-email 2.32.0.rc0 In-Reply-To: <20210526070911.31681-1-cgellner@de.adit-jv.com> References: <20210526070911.31681-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