Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp259431pxa; Wed, 26 Aug 2020 09:50:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLK7H3wy+ygTilpw/i16XOuGdWhZ2xQd8Iz+ZPAl8AFP4D3nDBDzkHKqkWP5bzgZYFtK1V X-Received: by 2002:a17:906:4994:: with SMTP id p20mr15454440eju.299.1598460618388; Wed, 26 Aug 2020 09:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598460618; cv=none; d=google.com; s=arc-20160816; b=w6S8Bq8EHA4cPLgmetTF+QMmqZuTXRUfiwD3tZnP9yP9Owu51fq8iDVTD0spA1lUHx IbaD+6tx3PJBdu0WOPA0QKQ6dFplzwlBy++SFCCr6ZlClSkuUZDi1ZR7v4b1rUFnUJ63 pwwb7ppHvOvJw7QPTvqcce8jcampgDDFTtDYnUfkTwDUEJingYMt1e28suHY12EDaEvH ZH3CE6r3tLfnPoQvsY1rdWbDv4fwrFeYII62bfOsjBg/rQ5l7u/EOEz85Do9ukCNxAUJ 7yw+4zHSxnGpK8wz8qAZ2B3+DSeD2lyzkS5Yl9hxtu+8cLrwp1ZtL0+QJoImMk8s5DPS piXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wk7DlN4RR6k6lg+nX/WYTS8+aJhqAF/kFILSCMp8TGw=; b=Bt/IwWWCviYXL6ZLJKyaqsKhnG9qIOdmNOXuwvVDLfkAfUqjVLc/NjBFwquo53u2Mz CIzgfF9+D0vvQO9GVXYfD/g3o6sw+1ko6MRzTZLhUutjq6cMCHao65i/zXOBUwvFq3B9 4JabJMToRfy7PJJtshpurNHoCsAYjAyzd5PsrkLBLwxXPV85myTikYgRXLsb49+QmRqY E0zsDezPRW3rl4S2UPLE0OXAJQFCmBneoKt3fjHoVOQDFnvxNPvwg6Tvl7Fuy4XqKcrs MalzjJdKx3VWIN4rA0knEybtSZABW34/UT72NNdnyXdXSa9Hawc7YsSwT94YbZeNoqND /G/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="UdinP/Yb"; 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 l23si1863844ejb.172.2020.08.26.09.49.55; Wed, 26 Aug 2020 09:50:18 -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="UdinP/Yb"; 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 S1728238AbgHZQsZ (ORCPT + 99 others); Wed, 26 Aug 2020 12:48:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728098AbgHZQpr (ORCPT ); Wed, 26 Aug 2020 12:45:47 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E9E8C061756 for ; Wed, 26 Aug 2020 09:45:42 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id s2so528099pjr.4 for ; Wed, 26 Aug 2020 09:45:42 -0700 (PDT) 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=wk7DlN4RR6k6lg+nX/WYTS8+aJhqAF/kFILSCMp8TGw=; b=UdinP/YbA0u1t4KDbjuAf+r71DAWjgY3RPz9ZScLNzkB7tPAhMeHX9QmzC9malvaJF hoj9Qwbdr4GuV/WOxVpVYRdSZi46IYmQXewQvgP6oA1/VfZ6BFNX6Bd9YHSeErmBJqv8 yiP3pd4ykmjYYOi/+0ds2XovLu2/QdPHghSjYtKuw5i8xKHp5waepuCI/l2+9IciBIJd 3wI5yo+0meEJJg5WPfOX/Zx/4R4WNhVfcFKPW7GQ6fVFsmsvcXUjO16zSVY7TJph+RUC WPwsHa7jskkpIjIuBp1MnDdy9KRecBHrpp8IBOMggvj7+3+aTWG/1gSXa5fistCF+sx7 Kg1A== 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=wk7DlN4RR6k6lg+nX/WYTS8+aJhqAF/kFILSCMp8TGw=; b=LLjW1vulvJ9G0hbfeshq3E5J1yh4nMADIyYxp+xHbLnbTjPWJzfruxkz9E8SxZ2Dv5 L112Hvx9DBEy2a8KqJxjpiOqitzKpPckVQMtOIbKqzbSXC+FH7pJ4+B8sB5VmCweyEbv kSf1xpsWJXgKeloLccx/E3hcbUO4OKUnKQYXwtl7UvbF8qve+XN4djKhXofF45InSxHs s005PYk3zF7sWU3SYlaRryRxL/8xCF7hxX00nnucbPzY/C+Bu4UYJbZJCHMTHbxJiBK4 WrG6BTwZgq57oEYqXbSlSVaVAV/58uYx5PXqKqlQ5ez5mDg1QzZjTOiOnMFf1TN8hlXJ 0+TQ== X-Gm-Message-State: AOAM531Z+AHnh23K5d4dpuVaO6/uia5sxaeUBx6K1GTshYwVt+oKzIB3 w7fWT068yCunGPngMHqXnzjdpjy/f0X2tw== X-Received: by 2002:a17:90a:d908:: with SMTP id c8mr1106186pjv.4.1598460341768; Wed, 26 Aug 2020 09:45:41 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id u3sm2548878pjn.29.2020.08.26.09.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 09:45:41 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/13] remoteproc: Properly deal with a stop request when attached Date: Wed, 26 Aug 2020 10:45:26 -0600 Message-Id: <20200826164529.224476-11-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200826164529.224476-1-mathieu.poirier@linaro.org> References: <20200826164529.224476-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org 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 --- 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 c6c6aba66098..95bb40b4ebb3 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1619,6 +1619,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); @@ -1857,7 +1861,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 c152d11a4d3c..6134d2f083ce 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -113,10 +113,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