From patchwork Thu Nov 26 21:06:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 333064 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1634078ilb; Thu, 26 Nov 2020 13:08:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0WYGRN6gw0KniCa+dyEIeKYeDAZAKaE2OrlHZ51Fsu8REda7BhnRGy2tHR22GblElMtXj X-Received: by 2002:a50:fd8d:: with SMTP id o13mr4469367edt.248.1606424909761; Thu, 26 Nov 2020 13:08:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424909; cv=none; d=google.com; s=arc-20160816; b=1KdqsjTcoAV12J+Pyp6Wv4o2jCJHm0uykEnP/a8FOJWwdX4XL/rxL3B5wWRIdZR98N 6Ff7hVD7dH7NId6Gu9wNG0C/HL5UbntdElW9Ix+Afh8S7nM61CFBNhB5PxdY6ekxbdai wva5cU2MAYdtMaqWBsWHuHidRHFhoZFS0DbCiYlVbV0xpDe09V+sGgisgb6cjgOEvTi3 Smujdtpy2dgFNSI06cfPkY/55GYY3dXyDQsrknqGk+bpseKib8IJ4m4QNRsH81Z2cZ8F 7tfl6GgLZZR0B4Uq275lI3QGgZRod2y+lK4g+/Mvhuat55z+sEsrYCl42kIe8ovcQfv4 byHQ== 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=/KGOX9KkEX+n+yFMKTjakVzZosqRnFOWNvseTfllA6Q=; b=pR7MItyrkSamhuoBZruiKVfbwXEsztpcpEzJbK7R++hHCOj2N5lBkgRhRUsoisN+w3 tmIXsn3z2TFfLSoUmanAFT+JMbhPDHwnl7nxi7qRYvg4BPTci3AzmxpgeMZeAsqkd7Bz jd0J+XmvnYx4NHusMUDlaGNbj3YPOmZELWOQHBvtfO/Ps9cG2JtGwzw6utds/1hOwq6p lVRxmKj1dpB7KNt66rxq4ECZdNTEZdGNXGt/W6Ff390pZPH1EmMrZg2dNTG+92dNqd9t ezObPP8+iU1+RfqPV7jz/Dlq5zxNODcpbcWLbswSrKgpAsZWADspZiO8LZvIVRltY408 2/hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dg+HdzxD; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 k11si3567033ejg.330.2020.11.26.13.08.29; Thu, 26 Nov 2020 13:08:29 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-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=Dg+HdzxD; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 S2391620AbgKZVHM (ORCPT + 6 others); Thu, 26 Nov 2020 16:07:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391639AbgKZVG6 (ORCPT ); Thu, 26 Nov 2020 16:06:58 -0500 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72247C061A52 for ; Thu, 26 Nov 2020 13:06:56 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id b6so2608035pfp.7 for ; Thu, 26 Nov 2020 13:06:56 -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=/KGOX9KkEX+n+yFMKTjakVzZosqRnFOWNvseTfllA6Q=; b=Dg+HdzxDV2YNawQ0UhBP6HdLS5ZVfu3mLkvXwyT6jnxsG2wu2G+m7UD0mOxya3fTN2 a9YMPlCBY/rXtrETa0IEBOpG/TCZKmhJsG1jozvA4SM9iuIVszkHSgf+Q9SPAx5DIGCW Pwh61Oz8jyJQb0BuXQy8+l1YJhUgNlq9j4tWrr/dqDZJiI8IVfWCzO5G50b2Usgzcv1W IvWXUq5805Wcj7MwD2WFiInSQL8+Ltpv5QL8ebWvwGCOPUNejoEmFYsIesO0NeSQbimY 1MlVtiFWwIm/l1LjWovvF+mF6BIdiCKp5xTS77fFQLxqNJ0g7M9vSZvDmKQ/9jsQnNsY 3XNw== 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=/KGOX9KkEX+n+yFMKTjakVzZosqRnFOWNvseTfllA6Q=; b=L15JhH7Gi0Ir+8w6v2kkp5nDEFQjXWHQlvQFxnEPvx6lvkzfl+/p1YET4CaM+SJbR6 BwL6u5cvGbhaPLhemzJkbW92e2lfXANQ6laZ1brjA+sZ9s0G1znNQJpjw3vTObLCGnTE R0ftFalnM7qJ9v2tm3LZ6ztxC7j0JdbueB4smTlwvi/cO+bl/usXvx8vUCzDIUHPADDy QpyU2hzK1RyFPJXKVuw1kq5kri7an40/sCYh5z9nqZb9UD/9bMLnnP/hXbiMyP8EqQU6 vgUkOSWnWoMDH3FuDLccYCUgRkTP4IUqMzRqAshhEEORrvrSXA8Z1f6thu3FIbjG8WzR /agA== X-Gm-Message-State: AOAM531UPA2ILDBQDTPHiPIyas2a2geGkxaR6rjLSwp3sDXV2fdnEMh7 hE3Eqbw6ALqqzIKWft3AiPP+TA== X-Received: by 2002:a62:1d6:0:b029:197:f8a8:e6de with SMTP id 205-20020a6201d60000b0290197f8a8e6demr4133919pfb.38.1606424816035; Thu, 26 Nov 2020 13:06:56 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id c203sm5612676pfc.10.2020.11.26.13.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:55 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org Cc: linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, arnaud.pouliquen@st.com Subject: [PATCH v3 12/15] remoteproc: Properly deal with a stop request when attached Date: Thu, 26 Nov 2020 14:06:39 -0700 Message-Id: <20201126210642.897302-13-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201126210642.897302-1-mathieu.poirier@linaro.org> References: <20201126210642.897302-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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(-) -- 2.25.1 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 51275107eb1f..3d7d245edc4e 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1642,6 +1642,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); @@ -1880,7 +1884,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 f9694def9b54..3696f2ccc785 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -201,10 +201,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;