From patchwork Thu Feb 11 23:46:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 381076 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2496741jah; Thu, 11 Feb 2021 15:52:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJybiHB2MUBySYUJh9XvPmKA5zb02FKoxLlO0D3gl5PEEiqAtUOeor8NvE7WAmbKa818rBD3 X-Received: by 2002:a17:906:660b:: with SMTP id b11mr200241ejp.458.1613087520965; Thu, 11 Feb 2021 15:52:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613087520; cv=none; d=google.com; s=arc-20160816; b=stmKHd0bOwyx9KsoNo4y7U91KgK5pvzBL6MquOfx7om+lBYY7JpQcpEqDj4dOb8Q94 5g5pLoourEwU58UUyF8xIyR2dd8VTYAAU7kpadrywabQ1H6QgHAKsyEn+PIvlYSbsnJq fdRJmz+DV/X3qgTmzwK/XUX7VCTo2wsKQqbGikao3eP+Oym6jPV7TBvDjIyLiQ1m3QB8 CSANdoF5N7Ks1Yhvqa9MOBp8w/zFosxvpinYh+kNtCUhbHHj/NQZdeRCBijND8FdBbzP joxogxMeyF9DwL4ldlYwKI1SJNXSClsCr2hIfTw48LB/W/E+d6+00+eYdxcjYdI0B5qf 8miw== 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=5LiQ+DrqaiKdtyOZ0qd9/kmr3OB05MnkkmAeFHXfjc4=; b=ldTM8NR9hp2gbJu/N+1hiayge7mStuDxtTvzATSOYfAvJqTsUJ7lUDT2Z/dV1YjzL9 /xXCtwdAnY+Mh5Rzzxho2qjMQegiacnwsSHnIPOiD10gicgjYOiKVRLcrZY0ik07WgcN q9vBnmJa6MGSQNRZAXVNF202U/FbzqQfwpVe44ZNV1L60TQ/dCKhYf8FsOO77JRyDvLj 13Hd8xF8NNaMANBNVA3ORg6t4I+3gWINpLGjz5wSaweJaG35gyXgONDbGKnI0WHLgodE cNvEr7QxpLZHCTDzU/Gn6BGG5md+ScAPdOU3Ges1vZEHvyYqpLWRXO1p/EeZK/jJ7nB4 C6Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SSYN+Wgn; 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 ch12si4550788edb.463.2021.02.11.15.52.00; Thu, 11 Feb 2021 15:52:00 -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=SSYN+Wgn; 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 S230444AbhBKXv4 (ORCPT + 6 others); Thu, 11 Feb 2021 18:51:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229700AbhBKXu6 (ORCPT ); Thu, 11 Feb 2021 18:50:58 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2E58C0698D0 for ; Thu, 11 Feb 2021 15:47:10 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id c11so4713237pfp.10 for ; Thu, 11 Feb 2021 15:47:10 -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=5LiQ+DrqaiKdtyOZ0qd9/kmr3OB05MnkkmAeFHXfjc4=; b=SSYN+WgnLbG2ER/GI4pl0JRTRnaR3bgiGuZH/zBXNJZUmCGM0XYF8bs9ogCJw+gBVx zbB61u8+Cx51rvtIkimeNIFskk843o6zkUeplK2mfz34bO/1ixUfEHUwXl45K8bXMRqZ PiI34g01DanreaBh1mVooQr1Lpny4gggo0Ecs3FnrYgdmSL/ItczbJy6TG1e8Vgvxw0T rrjx1CYGbvcHO7WdTREskkiCOB8ou3LOZSK2NggZV+LFMfPrQt8GBf31ZTih+xC3h0aZ JCBRUV5kUczsw4Ca0W+M8C5KkNx8ZljR2rhjpbx4WQgVNq21v//Hc4GIhAYMAmYfXSEq 65tw== 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=5LiQ+DrqaiKdtyOZ0qd9/kmr3OB05MnkkmAeFHXfjc4=; b=CuB5CQUnJnbwCceRdT9Hobc5hBVYOVZoRYOvs9SkFRGu4eiGSJ84bg+vhbbLcI384Q mK0Ykzh26u6W3Tjt20hvG++4gxhr0+LjsrPr6AwZSMrkwmgQMsHwCGw2nMvOYOKglnsn U1j5YDs8ClRP/w0lgC8A3ib7jWxkdP1aMVZde/+X5mIEmMRYpdVAH7yFyf7KnMlXxiuM Q39NjrjpXoA5/iW/6NWoB0y3cipWse8JUuiWy4LyokWEa58hxbCTN3vKCmYLdQsX7HZi Q+K2OkSuPXKFtRcTsWfA0x4eqyQwP95ssRX7gKxQJ883UPi/hJwJHT0k2FdRVnfSgJBp QGDg== X-Gm-Message-State: AOAM530xJBd9KrNawWXb0+Dz/iR7xycwdNqz9Vhlks7lDs4Yf/1p7JRw rIArexg3+Z2NfMrdBzFDkUaEEA== X-Received: by 2002:a63:343:: with SMTP id 64mr556316pgd.232.1613087207742; Thu, 11 Feb 2021 15:46:47 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id iq6sm5932740pjb.6.2021.02.11.15.46.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 15:46:46 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Cc: robh+dt@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 18/19] remoteproc: Properly deal with detach request Date: Thu, 11 Feb 2021 16:46:26 -0700 Message-Id: <20210211234627.2669674-19-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210211234627.2669674-1-mathieu.poirier@linaro.org> References: <20210211234627.2669674-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 detach a remote processor that has been attached to or booted by the remoteproc core. For that to happen a rproc::ops::detach() operation need to be available. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_cdev.c | 6 ++++++ drivers/remoteproc/remoteproc_sysfs.c | 6 ++++++ 2 files changed, 12 insertions(+) -- 2.25.1 diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index 61541bc7d26c..f7645f289563 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -43,6 +43,12 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_ return -EINVAL; ret = rproc_shutdown(rproc); + } else if (!strncmp(cmd, "detach", len)) { + if (rproc->state != RPROC_RUNNING && + 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 7d281cfe3e03..5a239df5877e 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -207,6 +207,12 @@ static ssize_t state_store(struct device *dev, return -EINVAL; ret = rproc_shutdown(rproc); + } else if (sysfs_streq(buf, "detach")) { + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) + return -EINVAL; + + ret = rproc_detach(rproc); } else { dev_err(&rproc->dev, "Unrecognised option: %s\n", buf); ret = -EINVAL;