Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp614852pxf; Wed, 10 Mar 2021 13:15:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxouTF3tS6VPvNIhBAX++kY0OmumZw8fySNJqzOppic3WvmQBs9k7dahNrWQP5G0Iv8EcyZ X-Received: by 2002:a17:906:aac5:: with SMTP id kt5mr374408ejb.548.1615410900135; Wed, 10 Mar 2021 13:15:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615410900; cv=none; d=google.com; s=arc-20160816; b=pHYvCBIlBkkrkiPmkQLU0ZmZjXDVeg6ERY+q4vHLof+JNDMJUYgEnjIGz4Bbu+ZVNs pQuZnOxQsSYhVBryDWvY917a+bEhmJpM6cLxKci6JqXo/ppEiFqHdwkAUCyrd11flBaf a3QYj0T8kpQJ9FZNIg9X7VtQ/0L8VWYXEv/X5RiEsG3GJs7jveidn13Z4sJX8rAIbEj/ kscoSGWk0rKKP7JwHh+XLNiToP7nXm2jg+YQ1vUIvOnWp5ruZTTxoPMrgNk/LwOKXd0v aa99ht+1syeEyZCdERE91q6OETsYy+tCA9WOMfGZfXcwcWdKmJmO7eC6PjBhCNb7HEqp DtpQ== 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=NN7h66rSqKzczqrKUwACdy1DE0E9dT7gEJY334oVOV4=; b=T3m127ml8qlKwye/KbmSGk0jjItBUTwUcN5otV1bsiZOqloHn1KLBbR8RJhxdH5LY6 HqhAU9uk1taAfKH3T8fF7/nv+AofJRTU9+j4DBNaWk3n/bcCJSaTBkQ6HOGNxH7wSclC l8lI3IAHYlpI0JE9t08fSusnr4lfIk8aUc7kvueFXhcIc/DbObUWP1qA6JM73D/EuZyS yBQY1mVq6WNc5XhyVV2YgXAfbWq4AssymCrohGIv0UOtgoldg1Ks/R0vN2FLkI0Mw0cX BZ5bA2o5/3+wSZx34CsJt8PDCW48EO/Fn906cHuIQewF6CB8PRFu1WL2a2jLziKtVoVN Y7VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YsAjFMkp; 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 t12si326589ejc.21.2021.03.10.13.14.14; Wed, 10 Mar 2021 13:15:00 -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=YsAjFMkp; 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 S233761AbhCJVLP (ORCPT + 99 others); Wed, 10 Mar 2021 16:11:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232254AbhCJVKv (ORCPT ); Wed, 10 Mar 2021 16:10:51 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E61DCC061760 for ; Wed, 10 Mar 2021 13:10:50 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id t85so7701113pfc.13 for ; Wed, 10 Mar 2021 13:10:50 -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=NN7h66rSqKzczqrKUwACdy1DE0E9dT7gEJY334oVOV4=; b=YsAjFMkpkwep25SwkBMcSnhfdoVYmzl5QqEIPCJbSwI74cnvyGX4V5wUqrnUVokUaa Wwe0fGdh9p1WmI8zDIGi0H/2xW+uWaCGsKbpdYsHH0KuFkUC1ijJUlmk4fxphEx+69qg HTt1iNg6dk3TlCiNPQpdrB5SA98/PtH21zClh6HwbkMMgDTQK3H4LD/w9Xjtuel9L87Y wrcjU/4YeLVOjlmoYb7vCgcbhXxtXTpQlm8/kA7JA0FoWh3bqIps41ay7knAgYM7n8gK gZW8oXhs0XmuEBFUWkuoZCdNwRBivGpWiQbNUe3feoCqhkONqvUdtMWWYcxvHwXnZ6+t j3/w== 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=NN7h66rSqKzczqrKUwACdy1DE0E9dT7gEJY334oVOV4=; b=PVxGuDb0FEmSbxnC4mmT3Qv8xgUPjtIMJR02FjrfdBGWt/qtJ1w3+DD9rzcpSk4f+n ieuxcrdnXXQPTJC0usLFa3ONCzza2sd421OVcTRf7ba4q5bAO5YpZBvDVrHDE7Crhkx7 t0SyhIeeTFZUjAGyRjpUsZI75Do3MftnzIT39VN8wksg9VKaBr/Gfo0b25Og11Orcrly u5gQTzhrTxmJq2jfSLjJd505725QGeRD3mGxkmibSLbcUIi6M8/P5gK0YNL1lQz3xoBy pEeeQherTAb6UUPv16OxjRpvj7Hd4jsfQcCAS2ZcpBKzCmuxBnjOMBHVydfQiFRUcRVS +yRg== X-Gm-Message-State: AOAM5320l8gLQ52L0B8sQ7hKRFP8ilW17ybgPz3cS4DfRnqA7zCSLTCp quSawbKs13HCk5/XbUxLv60IhsEqEhXEow== X-Received: by 2002:a65:4386:: with SMTP id m6mr4472767pgp.384.1615410650544; Wed, 10 Mar 2021 13:10:50 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:49 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, 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 v7 16/17] remoteproc: Properly deal with a detach request when attached Date: Wed, 10 Mar 2021 14:10:24 -0700 Message-Id: <20210310211025.1084636-17-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-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 detach a remote processor that has been attached to by the remoteproc core. For that to happen a rproc::ops::detach() operation needs to be available. Signed-off-by: Mathieu Poirier Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_cdev.c | 5 +++++ drivers/remoteproc/remoteproc_sysfs.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index 0249d8f6c3f8..2db494816d5f 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -43,6 +43,11 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_ return -EINVAL; rproc_shutdown(rproc); + } else if (!strncmp(cmd, "detach", len)) { + if (rproc->state != RPROC_ATTACHED) + return -EINVAL; + + ret = rproc_detach(rproc); } else { dev_err(&rproc->dev, "Unrecognized option\n"); ret = -EINVAL; diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 09eb700c5e7e..ad3dd208024c 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -207,6 +207,11 @@ static ssize_t state_store(struct device *dev, return -EINVAL; rproc_shutdown(rproc); + } else if (sysfs_streq(buf, "detach")) { + if (rproc->state != RPROC_ATTACHED) + return -EINVAL; + + ret = rproc_detach(rproc); } else { dev_err(&rproc->dev, "Unrecognised option: %s\n", buf); ret = -EINVAL; -- 2.25.1