Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp159059pxj; Fri, 28 May 2021 00:24:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPjbIu6wTK0itZMbHgIoXAItSZVuxItinSh+KcGkGcWKZz7/jK/LgsqBNTLw6AAAG/X9Xe X-Received: by 2002:a05:6e02:f93:: with SMTP id v19mr6009319ilo.126.1622186687941; Fri, 28 May 2021 00:24:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622186687; cv=none; d=google.com; s=arc-20160816; b=y0wcSPTWgl1n9c15SE5B8V0Q/Tbm2YnYk0inPZS9TyrhGFK42GMXe7CZ29XO1Rnnx8 eJhGACDvxsZav9EIzDmDKkQ1ydoyYgNmXYOXlcp58zEGESWR90qUerIYLfF/Mjclz1L+ oxFRfWhwrv9XySifrKVKYkLV17Xp43W5i74gpkqOst9QG0i9R6Fog5doEkChIG0WcSIr 89HW7drbyT465PptTnE4ntM2vNGvopX7GmaamA/AAwOvMppYYavBSTgMqzJLvpPkGLIN Vu/HjKKXebPDlZ5hJO4+LuTFJt65A1mjBSqnEQbhMbIFi2yttYaeKGpCXQ7uT0vPgbJS X5gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=NLZGZk1IIUiKipUefoX6gAEG+SOaK13kBUUCFsP8sw8=; b=icGL64YG9+4pDg0xdhmlzTBJHvl/Zq+f8wMkdG+aOiqGjRWc0Q3BCqLAINID51rAXS /yAmYJNeu3wiKOQzU2HfGPkVkZ5+MVYcOLY6SZEES6xzukECWdvjVfcJXFYth3861sQi QJBSwsgWauZgk5m87ntAlp9T3elMhdevthyBkihVisRpxzpTgVykH4FqqV3V7aJ+HP0j juHacBLl72KSvtAJoF44NBRl9ZV7iPMS4/iv7F6EAT8jWQUQGoJ+GZgHiwP627PF+qlp 7VtIrgauIduZgWzJ5jxfkByZkdRefGQZJLeYYxp0jEeHZzXeVJLH7on8jH5ptdx6dMOz TNow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="h2/FxC+B"; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x3si4635941ilm.17.2021.05.28.00.24.33; Fri, 28 May 2021 00:24:47 -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; dkim=pass header.i=@linaro.org header.s=google header.b="h2/FxC+B"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230200AbhE1ENt (ORCPT + 99 others); Fri, 28 May 2021 00:13:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230180AbhE1ENm (ORCPT ); Fri, 28 May 2021 00:13:42 -0400 Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30E5CC061760 for ; Thu, 27 May 2021 21:11:27 -0700 (PDT) Received: by mail-ot1-x32a.google.com with SMTP id 66-20020a9d02c80000b02903615edf7c1aso2285721otl.13 for ; Thu, 27 May 2021 21:11:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=NLZGZk1IIUiKipUefoX6gAEG+SOaK13kBUUCFsP8sw8=; b=h2/FxC+BMuT6MTN05CbIXCkDh70SSJ/JVH1Z6T8TxND5Svhp95Zko9eP+iIt7pKZRU Jv6RUjaR0W+NhmIssmJ4yvw4s27vA5tm8+IzV/7eIfCz2vTDs9iFgOae+3KYcXjYfaDH 7X++Z6CSq9QTJvFF7ZO+fHxm08UuhK0UEyCQQzQXPiPGoCo+ZUk0oanWAOZv4q8M9E6x TxYeAkHVcXZ41f76kM6RZDa8yxAj6Q6Ax+cfETcvgX7/FbhsV7NbER/+GYqvf9U9yZwQ MP/fSY+sWAdS1rW/9Fkevf/6VKJzMjz98kkB8FDXlJ7+3xLc8rFv/NBfknUqj93KEqTp Y3Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=NLZGZk1IIUiKipUefoX6gAEG+SOaK13kBUUCFsP8sw8=; b=L54WAuQgfm5/1rkWuO9MlN7LY/frAUYRVKOsBPLn+2BypAIQ6vWk+LrjzPTm1eFcGR fHVIQ8jsTyHtF8TCFpnmJprHqt7ZytcNqO1wgzRg/2+9S0XbA2ZhWRe7sQufHC63jEGY ZCCA0JLbNN+RsIzGUW18UyARz1xE9zYrFq61UdGIT/oR1Qg6dXoRcf/F79ix1H8MN/d2 G64AS0+N/XhkAU8h4vY6WEuUsknBJoiu02oVsOrzu3UW6F2bjyQ0bwRNutqMoLr+8rLW 8OJcRbmv6fBT4+HmGDG80AO6c0Wl3ebXHnMZxrwm3UlkyMGyKkg3kHmYQelA6Dqyg1GR +34g== X-Gm-Message-State: AOAM531eR8HBv5MCEsAv7FKfpYa3bIpsLn+b18yFwWcEKXs7F/zJUSof +JM8LiE/mu6ACN8yUN5kv+793A== X-Received: by 2002:a9d:73d8:: with SMTP id m24mr5398946otk.269.1622175086540; Thu, 27 May 2021 21:11:26 -0700 (PDT) Received: from builder.lan (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id l9sm863355oou.43.2021.05.27.21.11.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 21:11:26 -0700 (PDT) Date: Thu, 27 May 2021 23:11:24 -0500 From: Bjorn Andersson To: Suman Anna Cc: Mathieu Poirier , Lokesh Vutla , Tero Kristo , linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/6] remoteproc: Add support for detach-only during shutdown Message-ID: References: <20210522000309.26134-1-s-anna@ti.com> <20210522000309.26134-3-s-anna@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210522000309.26134-3-s-anna@ti.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 21 May 19:03 CDT 2021, Suman Anna wrote: > The remoteproc core has support for both stopping and detaching a > remote processor that was attached to previously, through both the > remoteproc sysfs and cdev interfaces. The rproc_shutdown() though > unconditionally only uses the stop functionality at present. This > may not be the default desired functionality for all the remoteproc > platform drivers. > > Introduce a new rproc state flag 'detach_on_shutdown' that individual > remoteproc drivers can set to only allow detach in rproc_shutdown() > that would have been invoked when the driver is uninstalled, so that > remote processor continues to run undisturbed even after the driver > removal. > I dislike the introduction of knobs for everything and would much rather see that we define some sound defaults. Can we make shutdown just do detach() if that's supported otherwise stop(). This still allows userspace to explicitly stop the detachable remoteproc before shutdown, if for some reason that's what you want... Regards, Bjorn > Signed-off-by: Suman Anna > --- > drivers/remoteproc/remoteproc_cdev.c | 7 +++++++ > drivers/remoteproc/remoteproc_core.c | 5 ++++- > drivers/remoteproc/remoteproc_sysfs.c | 6 ++++++ > include/linux/remoteproc.h | 3 +++ > 4 files changed, 20 insertions(+), 1 deletion(-) > > diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c > index 0b8a84c04f76..473467711a09 100644 > --- a/drivers/remoteproc/remoteproc_cdev.c > +++ b/drivers/remoteproc/remoteproc_cdev.c > @@ -42,6 +42,13 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_ > rproc->state != RPROC_ATTACHED) > return -EINVAL; > > + if (rproc->state == RPROC_ATTACHED && > + rproc->detach_on_shutdown) { > + dev_err(&rproc->dev, > + "stop not supported for this rproc, use detach\n"); > + return -EINVAL; > + } > + > rproc_shutdown(rproc); > } else if (!strncmp(cmd, "detach", len)) { > if (rproc->state != RPROC_ATTACHED) > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c > index 6019f46001c8..e8ab3eb41f00 100644 > --- a/drivers/remoteproc/remoteproc_core.c > +++ b/drivers/remoteproc/remoteproc_core.c > @@ -2074,7 +2074,10 @@ void rproc_shutdown(struct rproc *rproc) > if (!atomic_dec_and_test(&rproc->power)) > goto out; > > - ret = rproc_stop(rproc, false); > + if (rproc->detach_on_shutdown && rproc->state == RPROC_ATTACHED) > + ret = __rproc_detach(rproc); > + else > + ret = rproc_stop(rproc, false); > if (ret) { > atomic_inc(&rproc->power); > goto out; > diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c > index ea8b89f97d7b..1785fbcb1075 100644 > --- a/drivers/remoteproc/remoteproc_sysfs.c > +++ b/drivers/remoteproc/remoteproc_sysfs.c > @@ -206,6 +206,12 @@ static ssize_t state_store(struct device *dev, > rproc->state != RPROC_ATTACHED) > return -EINVAL; > > + if (rproc->state == RPROC_ATTACHED && > + rproc->detach_on_shutdown) { > + dev_err(&rproc->dev, "stop not supported for this rproc, use detach\n"); > + return -EINVAL; > + } > + > rproc_shutdown(rproc); > } else if (sysfs_streq(buf, "detach")) { > if (rproc->state != RPROC_ATTACHED) > diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h > index 42a1f30e33a7..35ef921676a1 100644 > --- a/include/linux/remoteproc.h > +++ b/include/linux/remoteproc.h > @@ -530,6 +530,8 @@ struct rproc_dump_segment { > * @elf_machine: firmware ELF machine > * @cdev: character device of the rproc > * @cdev_put_on_release: flag to indicate if remoteproc should be shutdown on @char_dev release > + * @detach_on_shutdown: flag to indicate if remoteproc cannot be shutdown in > + * attached state and _only_ support detach > */ > struct rproc { > struct list_head node; > @@ -569,6 +571,7 @@ struct rproc { > u16 elf_machine; > struct cdev cdev; > bool cdev_put_on_release; > + bool detach_on_shutdown; > }; > > /** > -- > 2.30.1 >