Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp646189pxb; Tue, 2 Feb 2021 14:14:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0tWBOcWCeuhSAEeDze/+Z77WdmlHRXxd11DeeOqjjOLo4QVM5+puljG/2FTB2LPJE/EOv X-Received: by 2002:a17:906:4955:: with SMTP id f21mr138022ejt.384.1612304072447; Tue, 02 Feb 2021 14:14:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612304072; cv=none; d=google.com; s=arc-20160816; b=bQuNZ8p6GmDE4HBtyCGbCoW1gqfxYIKHnMZcQOJrvHHeRsV4soUCBWkQTPiyk7ojIq m93bIGtJIF+/Yi5aT4yioVpcKMQ7FCaR+/fmKxJ3g3lwSyoOn/xs+pCW4IjODlCnOLJ0 ZX5dfNPOubKwTvm1pJ9doPc0vQF8f9EdC1bJIi6fF0bJ56990X0yLYrVvrmTcs3FcJEJ bNhE3o8GddRbIrYbUNAd/HN+0X50mPgTxKSvT+NcmeAdDmwOLCQkRjvk0OoeQOjoTUIg Fmh6zHZ0VCQ2tM1WNkxAXw3byIToqB2NBFK+CyrpXdePDUU9cRpQkOEFD80EsmqPYlgg n8BQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=c+jwo00M4YdIdqcvFN1oXIGWrFj30Ig5pZZE76ZPlTc=; b=IswDxoCIdNlvnlmqBFX0PzOG2WXZz3osS0WFG5vC/OLeeLQaqW0QeMMvmNURO3tY2u i9SpsBh4iY/z4KoeCgRl4vzso/mgDa0jpzoFXjJlq2rXfZLCKrs6LEle0+MF8ezFSCb+ WwMVjvKpPypARZDy7Ykih/8I+ZdA0PWc/PxNektQHgrGFAZhJEskBw+28mxu88Ki+7xQ 13iE2UOx/RxbdOOfMG81ddJu2R9a476WMS9kjZADfhCLvr+dpXLn4BMXKnEROntWokyf wdVKQhDgaN46KaMK9X+aYlWkwiFz8KDWfUUr1NXpARVmlPdhRi+YCducdcaRrvKOMRv6 PLoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VgglyEAZ; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j12si127662ejs.13.2021.02.02.14.14.05; Tue, 02 Feb 2021 14:14:32 -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=@linuxfoundation.org header.s=korg header.b=VgglyEAZ; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233352AbhBBNza (ORCPT + 99 others); Tue, 2 Feb 2021 08:55:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:40306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232860AbhBBNtC (ORCPT ); Tue, 2 Feb 2021 08:49:02 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 878E164F99; Tue, 2 Feb 2021 13:42:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273333; bh=UB8p8Pd2jHsx/oIU78zVjDfoX7MsfXZNYptC8w++9XI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VgglyEAZW7eiRYqltIplvFd+v+nmpyd7b0/X/FMuXPHP43I4hWZm477EimcaAXYSV DCaEQOqAGkmdV82RwNaV+RV3DXNidEid/FIdtcG2FLWliUZegJ8czVTJIOLfS97Un8 4nWDZup45sFb0jiU8vX26LVhw0ZjmV2v510GNlyI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rouven Czerwinski , Sumit Garg , Jens Wiklander Subject: [PATCH 5.10 067/142] tee: optee: replace might_sleep with cond_resched Date: Tue, 2 Feb 2021 14:37:10 +0100 Message-Id: <20210202133000.488857996@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rouven Czerwinski commit dcb3b06d9c34f33a249f65c08805461fb0c4325b upstream. might_sleep() is a debugging aid and triggers rescheduling only for certain kernel configurations. Replace with an explicit check and reschedule to work for all kernel configurations. Fixes the following trace: [ 572.945146] rcu: INFO: rcu_sched self-detected stall on CPU [ 572.949275] rcu: 0-....: (2099 ticks this GP) idle=572/1/0x40000002 softirq=7412/7412 fqs=974 [ 572.957964] (t=2100 jiffies g=10393 q=21) [ 572.962054] NMI backtrace for cpu 0 [ 572.965540] CPU: 0 PID: 165 Comm: xtest Not tainted 5.8.7 #1 [ 572.971188] Hardware name: STM32 (Device Tree Support) [ 572.976354] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 572.984080] [] (show_stack) from [] (dump_stack+0xc4/0xd8) [ 572.991300] [] (dump_stack) from [] (nmi_cpu_backtrace+0x90/0xc4) [ 572.999130] [] (nmi_cpu_backtrace) from [] (nmi_trigger_cpumask_backtrace+0xec/0x130) [ 573.008706] [] (nmi_trigger_cpumask_backtrace) from [] (rcu_dump_cpu_stacks+0xe8/0x110) [ 573.018453] [] (rcu_dump_cpu_stacks) from [] (rcu_sched_clock_irq+0x7fc/0xa88) [ 573.027416] [] (rcu_sched_clock_irq) from [] (update_process_times+0x30/0x8c) [ 573.036291] [] (update_process_times) from [] (tick_sched_timer+0x4c/0xa8) [ 573.044905] [] (tick_sched_timer) from [] (__hrtimer_run_queues+0x174/0x358) [ 573.053696] [] (__hrtimer_run_queues) from [] (hrtimer_interrupt+0x118/0x2bc) [ 573.062573] [] (hrtimer_interrupt) from [] (arch_timer_handler_virt+0x28/0x30) [ 573.071536] [] (arch_timer_handler_virt) from [] (handle_percpu_devid_irq+0x8c/0x240) [ 573.081109] [] (handle_percpu_devid_irq) from [] (generic_handle_irq+0x34/0x44) [ 573.090156] [] (generic_handle_irq) from [] (__handle_domain_irq+0x5c/0xb0) [ 573.098857] [] (__handle_domain_irq) from [] (gic_handle_irq+0x4c/0x90) [ 573.107209] [] (gic_handle_irq) from [] (__irq_svc+0x6c/0x90) [ 573.114682] Exception stack(0xd90dfcf8 to 0xd90dfd40) [ 573.119732] fce0: ffff0004 00000000 [ 573.127917] fd00: 00000000 00000000 00000000 00000000 00000000 00000000 d93493cc ffff0000 [ 573.136098] fd20: d2bc39c0 be926998 d90dfd58 d90dfd48 c09f3384 c01151f0 400d0013 ffffffff [ 573.144281] [] (__irq_svc) from [] (__arm_smccc_smc+0x10/0x20) [ 573.151854] [] (__arm_smccc_smc) from [] (optee_smccc_smc+0x3c/0x44) [ 573.159948] [] (optee_smccc_smc) from [] (optee_do_call_with_arg+0xb8/0x154) [ 573.168735] [] (optee_do_call_with_arg) from [] (optee_invoke_func+0x110/0x190) [ 573.177786] [] (optee_invoke_func) from [] (tee_ioctl+0x10b8/0x11c0) [ 573.185879] [] (tee_ioctl) from [] (ksys_ioctl+0xe0/0xa4c) [ 573.193101] [] (ksys_ioctl) from [] (ret_fast_syscall+0x0/0x54) [ 573.200750] Exception stack(0xd90dffa8 to 0xd90dfff0) [ 573.205803] ffa0: be926bf4 be926a78 00000003 8010a403 be926908 004e3cf8 [ 573.213987] ffc0: be926bf4 be926a78 00000000 00000036 be926908 be926918 be9269b0 bffdf0f8 [ 573.222162] ffe0: b6d76fb0 be9268fc b6d66621 b6c7e0d8 seen on STM32 DK2 with CONFIG_PREEMPT_NONE. Fixes: 9f02b8f61f29 ("tee: optee: add might_sleep for RPC requests") Signed-off-by: Rouven Czerwinski Tested-by: Sumit Garg [jw: added fixes tag + small adjustments in the code] Signed-off-by: Jens Wiklander Signed-off-by: Greg Kroah-Hartman --- drivers/tee/optee/call.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/tee/optee/call.c +++ b/drivers/tee/optee/call.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -148,7 +149,8 @@ u32 optee_do_call_with_arg(struct tee_co */ optee_cq_wait_for_completion(&optee->call_queue, &w); } else if (OPTEE_SMC_RETURN_IS_RPC(res.a0)) { - might_sleep(); + if (need_resched()) + cond_resched(); param.a0 = res.a0; param.a1 = res.a1; param.a2 = res.a2;