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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 81A09C3DA64 for ; Thu, 1 Aug 2024 13:21:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ituu7XR/DhELbO/jAokzr9hjXaeC2nwefVHgABpHf7Y=; b=jU4VHyYx5zVABVBHWkiy4FTdvU MdP5eGlFBEv+8o1Ul0ZBTxRA0+InMacteEmjtikzxatYV6PBzXdrihgYZtSSzunVoHQtSERNOwCyC +OKmfOJMsToONBOzFydb1QT4SP6ZGOWb0l/6WQnwGRM39kbUpJofkZpFCu2bk/PZFrG08qKYEqcds c862B5aXtpPnoMq+Dc7hBcb15uAVMAiGoGNLlrVYZlJVMkP/5nyhwHMklQVr8Yw1cYt+NJCrNBHPv +W3jqk+wm4D3ASCNnz0HbJZyPhcsbeEgL+FrkcJNyca2uIoE7sZXWdbTdF5OcQs0/YEA8tVm0j8SH Yt0OGitg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZVkV-00000005UT5-1feQ; Thu, 01 Aug 2024 13:21:43 +0000 Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZVgQ-00000005SxK-3Rmy for linux-arm-kernel@lists.infradead.org; Thu, 01 Aug 2024 13:17:32 +0000 Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-7a1d3874c1eso404835785a.2 for ; Thu, 01 Aug 2024 06:17:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722518248; x=1723123048; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ituu7XR/DhELbO/jAokzr9hjXaeC2nwefVHgABpHf7Y=; b=yovqxBK5TZd7FcHm1JulewXjdAFJnJEKgkik+sAez5q0R6NPEK+oT2uU0mG1cum1NJ nomCsdLIRNzai9GxJSt/qit9B8EiUhQYBUJ7fQUrWm7R5MmNAu4WSZ7J+Y0D0vor7+YQ HXsW9Tnti4jPoJvKQxcuoJs/6km+9zP0ccw/LK9pkWHxvz19ugoGfOXHvfOXLE2k28tX Tx84QEu0C5QDLFcQuh7wKC3iuxPutGuhVzGgehu96cLoEThrpKpa1dFUGp0JsOdpc1Tp 2o1ZkhvfP1se++2J9ZOPZBz3mhrMQKWJHO4Az6pYg4XZZZ/4xl18vELbbCE+se3e0BVR CLMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722518248; x=1723123048; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ituu7XR/DhELbO/jAokzr9hjXaeC2nwefVHgABpHf7Y=; b=jE02vGSyRfgX3cirhIP8bXwOA3wJ0vMTfVjMLORwmVINnW1q0sR9bWkofARpesZR+Z A5/KEDUBgDb0ZKqNUz0KoNfPsCjAcb5U+y+zzbm3iLhiUU3apl3TvLqlh24VPU7ria3H wl5f1nH18214o6hDu1VkHxyPWSuOhBxYUZgDF9gVC5jxadplTUdvPrvAFeHVwvoILajq I13HUwXCN+hqTg3PPbVYSBnH1eS2Xl49nHEodfa4HWFimRSRlchnmbdlz6ZrFL3E5O69 PRF3zP0F7cZG+L8CklNmuEkrCB6tP1r1JYuyAcGVeQT5zkPaBjwBm0Q8Luqlbd4UQY10 baQA== X-Forwarded-Encrypted: i=1; AJvYcCWRpo9ZmioJrOB/UxlOA5ZvKmJlx1q4idOir1HAsgWca+KHN7jL/QrTAe//vXMeqHUKqjtWORNtwd6G/+QuV4HPj+Gi+y/O7VoW9n0V5LjfcIIAY+Y= X-Gm-Message-State: AOJu0YxxOpE4VwTBhCwOSrrwqshRHiN2QOl+p0bI/D5d4xFxuhLZ0Y0Q RFVmS4CNSxVqo4/olVkoVoDNpnL4BvGetSEmqNR1vjhyfijLgH2epbUE6l7Qayw= X-Google-Smtp-Source: AGHT+IGULwRue6J39V2Pt8e6HLGmbrFB3ZrmAZlfo4mFSBpV9+w6RlH9yVQ3MCtaj0bcK/QNg6Hu/A== X-Received: by 2002:a05:620a:4144:b0:79f:637:b63b with SMTP id af79cd13be357-7a30c70fd72mr248746385a.65.1722518248362; Thu, 01 Aug 2024 06:17:28 -0700 (PDT) Received: from p14s ([2001:56b:dc1d:7300:5196:6a43:e999:d728]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a1edaf5169sm536372485a.76.2024.08.01.06.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 06:17:27 -0700 (PDT) Date: Thu, 1 Aug 2024 07:17:24 -0600 From: Mathieu Poirier To: Peng Fan Cc: "Peng Fan (OSS)" , Bjorn Andersson , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Daniel Baluta , Iuliana Prodan , Marek Vasut , "linux-remoteproc@vger.kernel.org" , "imx@lists.linux.dev" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 2/2] remoteproc: imx_rproc: handle system off for i.MX7ULP Message-ID: References: <20240719-imx_rproc-v2-0-cd8549aa3f1f@nxp.com> <20240719-imx_rproc-v2-2-cd8549aa3f1f@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240801_061730_901296_9A20A260 X-CRM114-Status: GOOD ( 43.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jul 30, 2024 at 08:06:22AM +0000, Peng Fan wrote: > > Subject: Re: [PATCH v2 2/2] remoteproc: imx_rproc: handle system off > > for i.MX7ULP > > > > On Fri, Jul 19, 2024 at 04:49:04PM +0800, Peng Fan (OSS) wrote: > > > From: Peng Fan > > > > > > The i.MX7ULP Cortex-A7 is under control of Cortex-M4. The > > i.MX7ULP > > > Linux poweroff and restart rely on rpmsg driver to send a message to > > > Cortex-M4 firmware. Then Cortex-A7 could poweroff or restart by > > > Cortex-M4 to configure the i.MX7ULP power controller properly. > > > > > > However the reboot and restart kernel common code use atomic > > notifier, > > > so with blocking tx mailbox will trigger kernel dump, because of > > > blocking mailbox will use wait_for_completion_timeout. In such case, > > > linux no need to wait for completion. > > > > > > Current patch is to use non-blocking tx mailbox channel when system > > is > > > going to poweroff or restart. > > > > > > Signed-off-by: Peng Fan > > > --- > > > drivers/remoteproc/imx_rproc.c | 36 > > > ++++++++++++++++++++++++++++++++++++ > > > 1 file changed, 36 insertions(+) > > > > > > diff --git a/drivers/remoteproc/imx_rproc.c > > > b/drivers/remoteproc/imx_rproc.c index > > 01cf1dfb2e87..e1abf110abc9 > > > 100644 > > > --- a/drivers/remoteproc/imx_rproc.c > > > +++ b/drivers/remoteproc/imx_rproc.c > > > @@ -18,6 +18,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > #include > > > @@ -114,6 +115,7 @@ struct imx_rproc { > > > u32 entry; /* cpu start > > address */ > > > u32 core_index; > > > struct dev_pm_domain_list *pd_list; > > > + struct sys_off_data data; > > > > What is this for? I don't see it used in this patch. > > Oh, it was added when I was developing this feature, but in the end > this seems not needed. > > > > > > }; > > > > > > static const struct imx_rproc_att imx_rproc_att_imx93[] = { @@ > > > -1050,6 +1052,22 @@ static int imx_rproc_clk_enable(struct > > imx_rproc *priv) > > > return 0; > > > } > > > > > > +static int imx_rproc_sys_off_handler(struct sys_off_data *data) { > > > + struct rproc *rproc = data->cb_data; > > > + int ret; > > > + > > > + imx_rproc_free_mbox(rproc); > > > + > > > + ret = imx_rproc_xtr_mbox_init(rproc, false); > > > + if (ret) { > > > + dev_err(&rproc->dev, "Failed to request non-blocking > > mbox\n"); > > > + return NOTIFY_BAD; > > > + } > > > + > > > + return NOTIFY_DONE; > > > +} > > > + > > > static int imx_rproc_probe(struct platform_device *pdev) { > > > struct device *dev = &pdev->dev; > > > @@ -1104,6 +1122,24 @@ static int imx_rproc_probe(struct > > platform_device *pdev) > > > if (rproc->state != RPROC_DETACHED) > > > rproc->auto_boot = of_property_read_bool(np, > > "fsl,auto-boot"); > > > > > > + if (of_device_is_compatible(dev->of_node, "fsl,imx7ulp-cm4")) > > { > > > + ret = devm_register_sys_off_handler(dev, > > SYS_OFF_MODE_POWER_OFF_PREPARE, > > > + > > SYS_OFF_PRIO_DEFAULT, > > > + > > imx_rproc_sys_off_handler, rproc); > > > > Why does the mailbox needs to be set up again when the system is > > going down... > > As wrote in commit message: > "i.MX7ULP Linux poweroff and restart rely on rpmsg driver to send a > message," so need to set up mailbox in non-blocking way to send > a message to M4 side. > > > > > > + if (ret) { > > > + dev_err(dev, "register power off handler > > failure\n"); > > > + goto err_put_clk; > > > + } > > > + > > > + ret = devm_register_sys_off_handler(dev, > > SYS_OFF_MODE_RESTART_PREPARE, > > > + > > SYS_OFF_PRIO_DEFAULT, > > > + > > imx_rproc_sys_off_handler, rproc); > > > > ... and why does it need to be free'd when the system is going up? > > > Sorry, I not get your point. The free is in imx_rproc_sys_off_handler. > During system booting, the mailbox is not freed. Why is the same operation done at both startup and shutdown - that is not clear. I am currently away from the office, returning on August 12th. As such I will not be following up on this thread until then. > > Thanks, > Peng. > > > > > > + if (ret) { > > > + dev_err(dev, "register restart handler > > failure\n"); > > > + goto err_put_clk; > > > + } > > > + } > > > + > > > ret = rproc_add(rproc); > > > if (ret) { > > > dev_err(dev, "rproc_add failed\n"); > > > > > > -- > > > 2.37.1 > > > > > >