Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp230125imw; Mon, 4 Jul 2022 08:12:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1slEoMsTgGb4YSm7TxujBpNNnlvzet3yarYwerocczrCz28pZiD/EdBzzdhpJEPp1PXjzZx X-Received: by 2002:aa7:de88:0:b0:435:9a54:168a with SMTP id j8-20020aa7de88000000b004359a54168amr38641281edv.73.1656947525882; Mon, 04 Jul 2022 08:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656947525; cv=none; d=google.com; s=arc-20160816; b=xHCSu+JxiPBdgtZ3HrnBkM0OA4kSC1pgl9R/lZAlBUZDOGyZsxSQTTA6AQBMNCgjE1 AYlGjQ5zCh9WLWTmihai1MvHqb8Jr6H9npsams1w86IK7oWYkpQm8n3NJ2jnjp0qbWef bt0s3wxWROazy7xZHxggNo3tzRtZ2oD/gfJKM0HwZg8Npb6ZbyGtqC88hhdlvKLODkq9 1h8KFFqdtV2qpn3ekIghO+NtWm1ohnd1L5BMfRcoZ3Me1AQ3s+c7PpDf981NMx3m0Q5D xuVqSYpUiJ3xSnlg2WQtTlNYc4bGWFLKQ9R0QZTLVn8oKct+jQ9LWvjhoHp9HRZFknt3 6Bow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=+zRfghuFRHUHo1b772Ta7sUSNim87Ohn59ycNpVDF3Y=; b=Rq3eW6q0PkopSIjA1KGtwTBk+2DSLy4j5Dh90QDsywewdHEM9ykWbG2Ufm9qcpF/Ky h+CBRcoL/FTe0U9avi4Kqt0AvXDJh1HhB0hlGf/9+oOouAFZ+CY2ssZrAPg9Oh+OWePf a4ISlDb7uOGqnPQ08k/xxrzoOBfo7Ap2pZOIKqlMDUH9uFKS48PrjgPsFa7NJ2pmTP1L ajGUW7sCKWxx1pq18XcBPdMgSbC7fzSmBU5K+IMhL2A41BeZFNhvLM0Qyy/w6sSVmsts tMESx6rBXv6epNMR+7ueNwail2dUYnRRm+1LbDWH9l6fMD4jdRbv+9/tOWYkehF4LNQL n/ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=OJE2Hcx1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fd25-20020a056402389900b0043a6799389bsi2465882edb.425.2022.07.04.08.11.40; Mon, 04 Jul 2022 08:12:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=OJE2Hcx1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233634AbiGDPJf (ORCPT + 99 others); Mon, 4 Jul 2022 11:09:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234182AbiGDPJL (ORCPT ); Mon, 4 Jul 2022 11:09:11 -0400 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAE4413CD8; Mon, 4 Jul 2022 08:07:48 -0700 (PDT) Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 264BGm2N020004; Mon, 4 Jul 2022 17:07:43 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=+zRfghuFRHUHo1b772Ta7sUSNim87Ohn59ycNpVDF3Y=; b=OJE2Hcx1Yf1MGdGbxDHtEj46lWjiwbZNDcF4O8WpWThvF2YLLptM9kAXbccpga/oN1ue qbAj1LCPYWior9IjrAnvDXnff/IshyBVka4ZuwdY9Ap4+uKJ4xbtk+tiHnGJLW7d+6ot Ku+6q6yZDkSb+dJ+f/WEHTiWypWgAKh6fyksml32JxTG8f2sIlWH81Vm/pWC+VDrg/bh TuF+YczgGA9nmg0bakkdEmM2OxPYwIbnUy688OmkQSslEmQR1tJIAGCX0VaUS+bNaIyQ ayNF75goPekUokqWJXmbrrBsN7jz/TfUXwfae0m0jUxBb72fD+EWJYToblFW+a4D6zzE Uw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3h2cwhu4xq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 Jul 2022 17:07:02 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8C44010002A; Mon, 4 Jul 2022 17:06:57 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node2.st.com [10.75.129.70]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 86927227895; Mon, 4 Jul 2022 17:06:57 +0200 (CEST) Received: from [10.252.4.55] (10.75.127.44) by SHFDAG1NODE2.st.com (10.75.129.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Mon, 4 Jul 2022 17:06:56 +0200 Message-ID: <290a2840-a282-1e45-360f-348b827c60bf@foss.st.com> Date: Mon, 4 Jul 2022 17:06:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH V6 2/2] remoteproc: support attach recovery after rproc crash Content-Language: en-US To: "Peng Fan (OSS)" , , CC: , , Peng Fan References: <20220701093702.265249-1-peng.fan@oss.nxp.com> <20220701093702.265249-3-peng.fan@oss.nxp.com> From: Arnaud POULIQUEN In-Reply-To: <20220701093702.265249-3-peng.fan@oss.nxp.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SHFDAG1NODE2.st.com (10.75.129.70) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-04_14,2022-06-28_01,2022-06-22_01 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/1/22 11:37, Peng Fan (OSS) wrote: > From: Peng Fan > > Current logic only support main processor to stop/start the remote > processor after rproc crash. However to SoC, such as i.MX8QM/QXP, the > remote processor could do attach recovery after crash and trigger watchdog > reboot. It does not need main processor to load image, or stop/start M4 > core. I would suppress "M4 core" to be generic. > > Introduce two functions: rproc_attach_recovery, rproc_firmware_recovery rproc_boot_recovery > for the two cases. Firmware recovery is as before, let main processor to s/Firmware/Boot/ > help recovery, while attach recovery is recover itself withou help. without > To attach recovery, we only do detach and attach. > > Signed-off-by: Peng Fan > --- > drivers/remoteproc/remoteproc_core.c | 62 +++++++++++++++++++--------- > 1 file changed, 43 insertions(+), 19 deletions(-) > > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c > index ed374c8bf14a..ef5b9310bc83 100644 > --- a/drivers/remoteproc/remoteproc_core.c > +++ b/drivers/remoteproc/remoteproc_core.c > @@ -1884,6 +1884,45 @@ static int __rproc_detach(struct rproc *rproc) > return 0; > } > > +static int rproc_attach_recovery(struct rproc *rproc) > +{ > + int ret; > + > + ret = __rproc_detach(rproc); > + if (ret) > + return ret; > + > + return __rproc_attach(rproc); > +} > + > +static int rproc_boot_recovery(struct rproc *rproc) > +{ > + const struct firmware *firmware_p; > + struct device *dev = &rproc->dev; > + int ret; > + > + ret = rproc_stop(rproc, true); > + if (ret) > + return ret; > + > + /* generate coredump */ > + rproc->ops->coredump(rproc); > + > + /* load firmware */ > + ret = request_firmware(&firmware_p, rproc->firmware, dev); > + if (ret < 0) { > + dev_err(dev, "request_firmware failed: %d\n", ret); > + return ret; > + } > + > + /* boot the remote processor up again */ > + ret = rproc_start(rproc, firmware_p); > + > + release_firmware(firmware_p); > + > + return ret; > +} > + > /** > * rproc_trigger_recovery() - recover a remoteproc > * @rproc: the remote processor > @@ -1898,7 +1937,6 @@ static int __rproc_detach(struct rproc *rproc) > */ > int rproc_trigger_recovery(struct rproc *rproc) > { > - const struct firmware *firmware_p; > struct device *dev = &rproc->dev; > int ret; > > @@ -1912,24 +1950,10 @@ int rproc_trigger_recovery(struct rproc *rproc) > > dev_err(dev, "recovering %s\n", rproc->name); > > - ret = rproc_stop(rproc, true); > - if (ret) > - goto unlock_mutex; > - > - /* generate coredump */ > - rproc->ops->coredump(rproc); > - > - /* load firmware */ > - ret = request_firmware(&firmware_p, rproc->firmware, dev); > - if (ret < 0) { > - dev_err(dev, "request_firmware failed: %d\n", ret); > - goto unlock_mutex; > - } > - > - /* boot the remote processor up again */ > - ret = rproc_start(rproc, firmware_p); > - > - release_firmware(firmware_p); > + if (rproc_has_feature(rproc, RPROC_FEAT_ATTACH_ON_RECOVERY)) > + ret = rproc_attach_recovery(rproc); > + else > + ret = rproc_boot_recovery(rproc); I tested the series on stm32mp1 with success. With typo fixes: Acked-by: Arnaud Pouliquen Thanks, Arnaud > > unlock_mutex: > mutex_unlock(&rproc->lock);