Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp159288pxb; Tue, 23 Feb 2021 21:38:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3TEZgbIZoGDcREpEQPO1eQsv9lNwb8D0omcSUsSFhIGjDdOMXO9lA7pLvoamUYAvclAsg X-Received: by 2002:a17:906:1447:: with SMTP id q7mr30791159ejc.27.1614145088055; Tue, 23 Feb 2021 21:38:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614145088; cv=none; d=google.com; s=arc-20160816; b=oaJ6qtIkuonDl9wWbsvJE/Qs3hK56tHBqiysxzBCcD8X0luurrIF4JNP6Buhh1duJ7 SIYzIVIemHbED5r79Az19XhiJzygRAZykkTq2d4VNA97Kc1epQUNFJv/xQZZxmXE3wIQ /u4UrjNVKhG6T1imnpxtsow+fRpjQYnDlo1MbrRZWioZQ2CNwjtX/ujlS4VZXw/RqtG0 lTCSYbsHHbOPMNj1O1n8Q3YRylEFS5Cp1xBe5Fg/t2ZC6YnUDEc0jyouFvSq+wyUt6Hw XtD2JK/mO2Gcfwqu3qoltk/5MvTxsBVyTl++NMecX38O5Wz4jrnnxzbFQNtDJo2oFRjB 3Urg== 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=LAmTI3bglQtEFeSTtt3Ql1nIs9Boi2zxtX6t4SxVxWc=; b=t9eZlNfvXwqzlFLHD2/FuabnLHfY+2eUEDoICSuvNBl8R/wXnr5cBEgNWddV0S8chP 013sRz/xQw7TJsIMwV2/YQ4ZGL3ZSO3x1zC7WXZnY5DQA3EbGlYEyjyDft+CMLV3mVSM 0C0ltlLCSXrdml926gaaJvR58n5h4CeipnXj/5DMWk5/WXCCFijmovEJuFSnXy2dW/3h us+1YIeZNwegMhFAB7rzRPWUcfeYCjgwWujr9jgINng3vdUXHQBjFFYN0FOLIF5SjCaT rrbuTndtm9Ez5Q6s6Fi/fqnwu6MJYq86iTE0/pvYPvPTzqcLVaWEQi1P8zQggfpspANG E4mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NGED3eMg; 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 j22si533536eds.434.2021.02.23.21.37.44; Tue, 23 Feb 2021 21:38:08 -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=NGED3eMg; 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 S235024AbhBXAfW (ORCPT + 99 others); Tue, 23 Feb 2021 19:35:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234017AbhBWXr4 (ORCPT ); Tue, 23 Feb 2021 18:47:56 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07206C0611BD for ; Tue, 23 Feb 2021 15:35:32 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id z7so3310plk.7 for ; Tue, 23 Feb 2021 15:35:32 -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=LAmTI3bglQtEFeSTtt3Ql1nIs9Boi2zxtX6t4SxVxWc=; b=NGED3eMgJhGkZutPXOY2WKCOmKOme62DKhXx1QZ0sElxKyqqf9wTTUOVOY3wtc5K7q 3BbDYubPwKdE1O0ikOKN+N07cltdgjsC/CdhLIFXmy9woQx2nyu9a26Q7ESUKcBEzMC7 TO1YtNGCi4mw6gNi+ZsBjHUW0aiM82TfpG9EfQvvYNPNPKiAlyd62qoGwdcO2Jf3AhTT tEXJu57bkHJ+qN2qzBLsnv8CS2MFmfTAl6LhTSsnNhOYQveF03NPu06l3/SnMa5tZVTM IxQIyS5lLIxjrjMnNTmNa/ITI7VH/w6egSsVh/Ca8ZUE6WdbTdzQdFDqvVstrTk2dC0n awnQ== 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=LAmTI3bglQtEFeSTtt3Ql1nIs9Boi2zxtX6t4SxVxWc=; b=ZZKpG6QgUn/OoJdoi8Z1lIx3W7oFn7TwyaeuiCFA9MvxKU6W403ydGyLxQI5sFB3wG BbjA72XfON4vf/NVEvWV6JtYDb5PSO2WvCjbLVyJkllFntFI+Gi02LpLK7GxhUVRVjMq KP+qPsLVQgNQ1bbZL/NqHjmUSFG3KgjnmtHT4BKo6QCmpDS5+63+BdW5PTrG6FlPIgDh Xf4DkEOQHuV3Xoj/ufNC4Wzl+JWCpHTTC25ssuCLWni10JqAFyC+EkSYpUMuzYzVyPhV 7hPkaRTbgc9pCyhvfD5QvBnLfJs6Iz8dnIHqELqqI5K+QRN7RGH/uixolawBQakstpph HjsA== X-Gm-Message-State: AOAM530s+ndAcRHVV5MxdtgcilfPziuarap+Z7n8S+XkNZzJ5xMwyzAq zwH94T/ozTaM9POZi7Tjkel4pA== X-Received: by 2002:a17:90a:bc8e:: with SMTP id x14mr1111361pjr.153.1614123331588; Tue, 23 Feb 2021 15:35:31 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id c24sm311999pfd.11.2021.02.23.15.35.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:31 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 14/16] remoteproc: Properly deal with a stop request when attached Date: Tue, 23 Feb 2021 16:35:13 -0700 Message-Id: <20210223233515.3468677-15-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210223233515.3468677-1-mathieu.poirier@linaro.org> References: <20210223233515.3468677-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 Allow a remote processor that was started by another entity to be switched off by the remoteproc core. For that to happen a rproc::ops::stop() operation needs to be available. Signed-off-by: Mathieu Poirier --- New for V6: - Removed state check in rproc_shutdown() as it is already done in in calling functions. - rproc_shutdown() doesn't return an error code to keep legacy behevior. - Removed Peng and Arnaud's RB tags because of the above. --- drivers/remoteproc/remoteproc_cdev.c | 3 ++- drivers/remoteproc/remoteproc_core.c | 4 ++++ drivers/remoteproc/remoteproc_sysfs.c | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index b2cee9afb41b..0249d8f6c3f8 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -38,7 +38,8 @@ 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); diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 0dc518a24104..00452da25fba 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1758,6 +1758,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); diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 66801e6fe5cd..09eb700c5e7e 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -202,7 +202,8 @@ 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); -- 2.25.1