From patchwork Tue Feb 23 23:35:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86733C433E6 for ; Tue, 23 Feb 2021 23:38:28 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4D31864FBF for ; Tue, 23 Feb 2021 23:38:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D31864FBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+Oz3+vFUdSVakDNifnkcCnx9acpPm/I0+yr0l9ShavM=; b=KtozgBp+EgA2iVIcTtibuosVp sM3+B1j5k8ecyUn6Eni8D7IvWYb76qYv+dtwalCbLLYrffSaMhZ0fJMbcKWMgVgRO51vyp71qMel9 ogXf4XqEGHXQ0hbK+IFjJFXI1rx5y2HmX6evIAprcI2omhsFYk6bm5pd+h93I+DwvUzRU46YvG8Gm iPg9xNYf0HRlJwl48zfK8xnbo4actY/dQUlXPY0pz69kbVt/u4jIofekvPsEYH2QYSKpCdFKREKGM 8Bc3gqm3S2WBxLFkDscj/FW/AnBq/aBN/7IbLD4zRVoHFnHu0qW8sDTLRLQzlnVizVfI7eO4ZVQT2 zKOqf2Ahw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhEi-00043K-5W; Tue, 23 Feb 2021 23:37:00 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDJ-0003W4-MR for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:36 +0000 Received: by mail-pl1-x62d.google.com with SMTP id s16so10840683plr.9 for ; Tue, 23 Feb 2021 15:35:33 -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=IMATzOxqG+4XWK+lBIN3ktMAZxQ6xCg8Qpu1vipELEtxyqG4LrEAuAWlC19yDZhZge 9XQgaHx7hv136nrsJyNx80X/OM8ofFab+2v9s+UVmy4PQg0C9EETJJ4UvH8Ee2dWVPeP oM2blqrksvCBj+hcWYuA2lbF3qCFmNAanhulMvP/lddv0R0FUb6kDQV/SrV7WXlvXKEB rcEcyRB6TSla7MWNWsKrYkMkatUCXUlFsH2ZbzAXEVul4b3SI68FJwqlBDMpW9f0zAVe HzBWlqpQt+STMjOhZHJ6z2lNNKfk6Q4aDHbkLqvdQ5MQsWabeWPNBf0Aq4wZwvlxj3XG QFuw== X-Gm-Message-State: AOAM531cV/L2E1Bz9ij8zucWHjRMXutzjrofwBPQv+5yKg3qjPrDcv8L 8tG91sRk6Yx8HClPtUTJJN/inA== X-Google-Smtp-Source: ABdhPJyR651tRS4bDZK72lnBVxuVN3KAk7P6cdiDxXGAKnu4Rzr7sbRRMCz02RCa2EQ4DN7T5maLSQ== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_183534_828968_29C7BD62 X-CRM114-Status: GOOD ( 16.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 Reviewed-by: Arnaud Pouliquen --- 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);