Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2288991pxu; Fri, 18 Dec 2020 09:36:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4qn9GlSEkcCTW9z4OrQdySLqeXOswZBPVDVOoeXn376/zBzB0fmUianw/JaHG1Rhv8cnv X-Received: by 2002:a17:906:4d52:: with SMTP id b18mr4860202ejv.405.1608312975361; Fri, 18 Dec 2020 09:36:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608312975; cv=none; d=google.com; s=arc-20160816; b=L4kKaN8Y2EJFm+6/Z7dnTmIHR3rOE4oPcVpx8ZLqPKpoXNLkDG6/MbiO8L6scgSRpN b8qC4Fkg9miLJ8XUeQ2hYKdGMGslx/1JmX34RMQJisdmVVcGLm/dGXXgyPHlYJ7XXxbg yJNpHSKK8xqpNDg1ZX2YKxucJF7IkRYDezNlHghRQxO7jnrg3ygk43o8H5rkbEoUfhLW C/Tum5xu5SRnLMjvVGqlWc6+p6KsbjpssMvyv9tAzxKrC3T6kuIaaH/b/WbKkVhSiTbN OI/KS6XU5AOZKzjs1410yaPO6iQqI6HDMe6kxym1NqWci3/bXBrjqhAO+1YBTE7kVpKS gGDg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mdgob6jb0rUl30rfuLBWyS6H4rN7qpxnzyGATQ2xIt0=; b=XhRD7zcYzpToArb5PhG2rJrhs2MsqKJUZzTHCSOMO8DTyR5tI9FT5Y6AsjftAhlnAp Y/GDU+LRjRUBtLeKZhXZno/y/PIoquwa9ZYlEBlwfw6ZpjdDqbfZcVfWzh0j6oq0Ur8h zl5Tb+pH+ZSx1olRLshIZeKips2xqoAae4Bme20pPEovjoDI4t8CncKrgOg/upcvUK+o jh30HGsuXJuIXBPEgY8mzRxh8bZculDS1bc2zUxq58FVVw4xSbrPGFokth2SDNFucCjE 2y/DRkDDAgy1YQc0hwCyz9AUBv+6NqxG6l7P8y2jIWF9ZQhpzMytASdr7i/Z+zeNVun6 /viw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Z/bCGb66"; 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 o3si6242264eda.133.2020.12.18.09.35.52; Fri, 18 Dec 2020 09:36:15 -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=@linaro.org header.s=google header.b="Z/bCGb66"; 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 S1732848AbgLRReY (ORCPT + 99 others); Fri, 18 Dec 2020 12:34:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732838AbgLRReW (ORCPT ); Fri, 18 Dec 2020 12:34:22 -0500 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF5CCC061A4B for ; Fri, 18 Dec 2020 09:32:46 -0800 (PST) Received: by mail-pg1-x536.google.com with SMTP id c22so1726721pgg.13 for ; Fri, 18 Dec 2020 09:32:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mdgob6jb0rUl30rfuLBWyS6H4rN7qpxnzyGATQ2xIt0=; b=Z/bCGb665F1fxnTF+3LEJAjTLAyRytVrF5nB84gRSWFkw9pBOTDRyaetGJaVASDVf6 +nCf5Bzq1+bCfC0ZehUxmqVXTSEF7Ox4nPgslBlQKHFo2pX4hZzlnMxfuMhnTpEIy2t3 QX1JabKmP8D2ajzElTIJHWwsg0XxZf+Sdj4mOaaDI0x1Zf6hS/8e4LAS3GjSgbVQsycU uXtaDQOOvuGn6B9+d41ZrH+ckbZzv5tgX7LMEi7WxfusAahQEnVXcCvdEODCIMX6ulCo P3yNhh4uYuuNmDcUhd8xzicCX0lfgBiSzor5WZTOjIfdU4Pf4pHUCtMsPZ0nMFbppxC9 2IOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mdgob6jb0rUl30rfuLBWyS6H4rN7qpxnzyGATQ2xIt0=; b=BXRcZ/cZWFi5wmNvprdz037+TO0Y9ZpwesRaRE2Hfr9Sp5dmJIZMHkM2AeqIknSEPr 2TG2/g2VTzGZ9THK5JFdNinKMenNJQ5GRJ+zNlckdR0bcaOSCOx8bVqWmLhzmv/di4Ae ++7ktEdrUZJZqln5uMRlCl+DFaOIxNdUCqhrFvkaGN9uaPE8UySOX894yCBInfNTw+Iz t1g9wCIVH0YlNLteocD0X4M9wIxUcHDsNvgdMOv9CMM+ayOh499M6V76TcKqBf/afKP2 f12d13M0ow3Jk/b9BbFs3iMpmoPgFUKguswCFnxzTAHFRpL3tWxofDemRdpEQT0iUgHF Hq6A== X-Gm-Message-State: AOAM53064B+JuYN1qdkrsf45di2lRtOz09kP4nUKtg9ramL8wmuU+GDY eG9tukz4iFEA2i+gZqHw9g42NA== X-Received: by 2002:a63:2fc5:: with SMTP id v188mr4987089pgv.243.1608312766353; Fri, 18 Dec 2020 09:32:46 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l11sm9892957pgt.79.2020.12.18.09.32.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 09:32:45 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 14/17] remoteproc: Properly deal with a stop request when attached Date: Fri, 18 Dec 2020 10:32:25 -0700 Message-Id: <20201218173228.2277032-15-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201218173228.2277032-1-mathieu.poirier@linaro.org> References: <20201218173228.2277032-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch introduces the capability to stop a remote processor that has been attached to by the remoteproc core. For that to happen a rproc::ops::stop() operation need to be available. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_cdev.c | 5 +++-- drivers/remoteproc/remoteproc_core.c | 6 +++++- drivers/remoteproc/remoteproc_sysfs.c | 5 +++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index b19ea3057bde..d06f8d4919c7 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -37,10 +37,11 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_ ret = rproc_boot(rproc); } else if (!strncmp(cmd, "stop", len)) { - if (rproc->state != RPROC_RUNNING) + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) return -EINVAL; - rproc_shutdown(rproc); + ret = rproc_shutdown(rproc); } else { dev_err(&rproc->dev, "Unrecognized option\n"); ret = -EINVAL; diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 90057ad1bb6c..2fe42ac7ca89 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1648,6 +1648,10 @@ static int rproc_stop(struct rproc *rproc, bool crashed) struct device *dev = &rproc->dev; int ret; + /* No need to continue if a stop() operation has not been provided */ + if (!rproc->ops->stop) + return -EINVAL; + /* Stop any subdevices for the remote processor */ rproc_stop_subdevices(rproc, crashed); @@ -1897,7 +1901,7 @@ int rproc_shutdown(struct rproc *rproc) return ret; } - if (rproc->state != RPROC_RUNNING) { + if (rproc->state != RPROC_RUNNING && rproc->state != RPROC_ATTACHED) { ret = -EPERM; goto out; } diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 99ff51fd9707..96751c087585 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -230,10 +230,11 @@ static ssize_t state_store(struct device *dev, if (ret) dev_err(&rproc->dev, "Boot failed: %d\n", ret); } else if (sysfs_streq(buf, "stop")) { - if (rproc->state != RPROC_RUNNING) + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) return -EINVAL; - rproc_shutdown(rproc); + ret = rproc_shutdown(rproc); } else { dev_err(&rproc->dev, "Unrecognised option: %s\n", buf); ret = -EINVAL; -- 2.25.1