From patchwork Fri Dec 2 09:45:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aiqun Yu (Maria)" X-Patchwork-Id: 13062500 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DE23C4167B for ; Fri, 2 Dec 2022 09:46:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232214AbiLBJqb (ORCPT ); Fri, 2 Dec 2022 04:46:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233166AbiLBJqN (ORCPT ); Fri, 2 Dec 2022 04:46:13 -0500 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8044AC510B; Fri, 2 Dec 2022 01:45:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1669974357; x=1701510357; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=oq2AA38vFA2nQ598SuUp+klmjkxSXqOaUB0WVea32Ls=; b=H1JcGwhydofHGKfZ4gseN9HjkamUYTsUX/Ep79flToN0UC+lh5Gx8Dwk I48NvUBxCmCgxkUhFA/IOxGzMm9qVrEMwC2rowQENPO4P1IucQ28RdE6p gqIgWUJUoJVIe1RKtlrn6fUxyMPwG+1kdjLZvMlCpPc+VSI8QQFoEnoQt w=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-02.qualcomm.com with ESMTP; 02 Dec 2022 01:45:57 -0800 X-QCInternal: smtphost Received: from unknown (HELO nasanex01a.na.qualcomm.com) ([10.52.223.231]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 01:45:56 -0800 Received: from aiquny2-gv.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Fri, 2 Dec 2022 01:45:55 -0800 From: Maria Yu To: CC: Maria Yu , , , , Subject: [PATCH v5 1/2] remoteproc: core: do pm relax when in RPROC_OFFLINE Date: Fri, 2 Dec 2022 17:45:31 +0800 Message-ID: <20221202094532.2925-2-quic_aiquny@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221202094532.2925-1-quic_aiquny@quicinc.com> References: <20221202094532.2925-1-quic_aiquny@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org RPROC_OFFLINE state indicate there is no recovery process is in progress and no chance to do the pm_relax. Because when recovering from crash, rproc->lock is held and state is RPROC_CRASHED -> RPROC_OFFLINE -> RPROC_RUNNING, and then unlock rproc->lock. When the state is in RPROC_OFFLINE it means separate request of rproc_stop was done and no need to hold the wakeup source in crash handler to recover any more. Signed-off-by: Maria Yu --- drivers/remoteproc/remoteproc_core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 8768cb64f560..c2d0af048c69 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1862,11 +1862,16 @@ static void rproc_crash_handler_work(struct work_struct *work) mutex_lock(&rproc->lock); - if (rproc->state == RPROC_CRASHED || rproc->state == RPROC_OFFLINE) { + if (rproc->state == RPROC_CRASHED) { /* handle only the first crash detected */ mutex_unlock(&rproc->lock); return; } + if (rproc->state == RPROC_OFFLINE) { + /* no need to recover if remote processor is offline */ + mutex_unlock(&rproc->lock); + goto out; + } rproc->state = RPROC_CRASHED; dev_err(dev, "handling crash #%u in %s\n", ++rproc->crash_cnt, @@ -1877,6 +1882,7 @@ static void rproc_crash_handler_work(struct work_struct *work) if (!rproc->recovery_disabled) rproc_trigger_recovery(rproc); +out: pm_relax(rproc->dev.parent); } From patchwork Fri Dec 2 09:45:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aiqun Yu (Maria)" X-Patchwork-Id: 13062501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34A8FC4167B for ; Fri, 2 Dec 2022 09:46:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232450AbiLBJqg (ORCPT ); Fri, 2 Dec 2022 04:46:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233090AbiLBJqU (ORCPT ); Fri, 2 Dec 2022 04:46:20 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4449A1D0FF; Fri, 2 Dec 2022 01:46:06 -0800 (PST) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B296Abe029281; Fri, 2 Dec 2022 09:46:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=Cpf5xdVUs0Lts4CKhfQVAVGXLzQbuR2j7KnQIG8ZaIE=; b=fdMvKD5qm0+DUoceQWEqbKkhJQ80lNYoTSH4K2gPoFvfMg/YdyNPc1mBXDUuk3UHEB2u zjC7mhA1jHnE8zT2JkgAdks4lEG9Q1RXMCohT7oG5/dvaUB1COh7MfbAXtKcd4LEHJ9d M4c40M3HlMIU3IOxSC9//fJKV/48Rchg/xxQMq7aT5O5EFAgW3eY+9LT2wd3+llB1CaH D+P/w0ICuIDxRlin3rQH0qUb7BW7q+014WCDlihBUuxW1hJ0s57XyAAy8u7QgMIhrPBe yRxBCFoADdoXX7Zm4t8Oj63CZGKxyimrtXiolOglS38rkuVAH1Dmd1TzudkR2Rj9JUK3 wQ== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3m7c180pua-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Dec 2022 09:46:02 +0000 Received: from nasanex01a.na.qualcomm.com (corens_vlan604_snip.qualcomm.com [10.53.140.1]) by NASANPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2B29k1B5025956 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 2 Dec 2022 09:46:01 GMT Received: from aiquny2-gv.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Fri, 2 Dec 2022 01:46:00 -0800 From: Maria Yu To: CC: Maria Yu , , , , Subject: [PATCH v5 2/2] remoteproc: core: change to ordered workqueue for crash handler Date: Fri, 2 Dec 2022 17:45:32 +0800 Message-ID: <20221202094532.2925-3-quic_aiquny@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221202094532.2925-1-quic_aiquny@quicinc.com> References: <20221202094532.2925-1-quic_aiquny@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: khmbiZQELznI8BHaAI2sQZBdyv-Hm28m X-Proofpoint-GUID: khmbiZQELznI8BHaAI2sQZBdyv-Hm28m X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-02_04,2022-12-01_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxscore=0 spamscore=0 phishscore=0 impostorscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=999 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212020075 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Only the first detected crash needed to be handled, so change to ordered workqueue to avoid unnecessary multi active work at the same time. This will reduce the pm_relax unnecessary concurrency. Signed-off-by: Maria Yu --- drivers/remoteproc/remoteproc_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index c2d0af048c69..4b973eea10bb 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2728,8 +2728,8 @@ static void __exit rproc_exit_panic(void) static int __init remoteproc_init(void) { - rproc_recovery_wq = alloc_workqueue("rproc_recovery_wq", - WQ_UNBOUND | WQ_FREEZABLE, 0); + rproc_recovery_wq = alloc_ordered_workqueue("rproc_recovery_wq", + WQ_FREEZABLE, 0); if (!rproc_recovery_wq) { pr_err("remoteproc: creation of rproc_recovery_wq failed\n"); return -ENOMEM;