From patchwork Thu Nov 26 21:06:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 333063 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp1634068ilb; Thu, 26 Nov 2020 13:08:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxX/CCOVMO4JMP/nlqzM3w3xhga/An/SUIvk+BmT7Lz10aJ0Ui5IHhroOnH//hq/th9vamp X-Received: by 2002:a17:906:7147:: with SMTP id z7mr4212288ejj.65.1606424908521; Thu, 26 Nov 2020 13:08:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606424908; cv=none; d=google.com; s=arc-20160816; b=hNy4Pe8a80zHTcpKSmKrjf2ow78c4uSOqo6uvEbc9SgU/BVxhgV8rYZaTSTH3xIKpJ HJzLE/WM4Gy70cf2xeFc5/jurEuL2OtfDYrBhjbRThojRTWLcDDBPlRtxUeCDzfLbu5a NNLhB/6+M6QJv1oCT68PKIScabbePn8QeQU1pyLIVD6TUg6ayps/RFpy4BnAU4fpVUoA 3tNNRCd97RxLb56sbMoGc5t0Ks4vhbV8k5qNZQO17Z7HEqANIG3jhDRgGQTiYB2rGPKd CSeN32Tm3uHI/9fAdnRc9G085kJSi8KgSHcSMwEqs4DUX7mII+sSTyGC9vhVU7hsvq9E /FYw== 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=BZKEoNhgpUCxk0BJFPhN8SyKdDsMxIN4bfJcnaCrMrQ=; b=EI+F7woMwtN9/DKidxgCHsxYTHBPzz8+TzuAEXJZ6+1nAFzemtrT2nbyfOuzGof7R7 otrdNzwBmIDtG58RvXWlSvNV36xyB5oM6zwy7TNB23Zm6ufy5BYhd/3ake+LB7AlajXF pGBiOyWnb1jl5sQe4hqGWkYJpaifdqEmHro5GS8zZpBUymfvU59+J0c7DbXpOoQAn8LY uplRtNAs8wYfW/mLrcwuqrXSFrTSeByv6OjaU0F361uxJoCdfAKwZhoJHwpyMBCLuz8p Ij9/kdkoeJUtkPDa9I3riwnpsX8KmhODCVY34Jxr1WbbwMBFmGIEDcCYRKEnxex+VNis wMkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pBsQ3pXn; 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.28; Thu, 26 Nov 2020 13:08:28 -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=pBsQ3pXn; 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 S2391758AbgKZVHL (ORCPT + 6 others); Thu, 26 Nov 2020 16:07:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391620AbgKZVG6 (ORCPT ); Thu, 26 Nov 2020 16:06:58 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 773BFC061A47 for ; Thu, 26 Nov 2020 13:06:58 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id o4so306364pgj.0 for ; Thu, 26 Nov 2020 13:06:58 -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=BZKEoNhgpUCxk0BJFPhN8SyKdDsMxIN4bfJcnaCrMrQ=; b=pBsQ3pXncC41Q83qq1u3ofxVdrDRk/6O4wPSti+nnYcmiF/ZOJ+H5vqGvPmxtPWizc 8y3XwipOESsOriEGeSxOxbflSMQm4o+Zmj2Tk14XtK/OJ7+4S3LV6hNbruVNDcsVejL0 3I5CJZZVpoIcl5kia7yH3D5fKKpBOVfAHD5gSGFglaYzgTr6wT+ol0kdNyBvyKzWULPA 1zRpvcdUbIxHbgCWet60vwfVRlsnB0mCIl9fX6QZcSxbDEg2EytQI9J75p2Sg4/y79NQ fmRGRnv6MkGS1+KhY6nNhQJVg5BiNov4S0XYjDOjoH/haen8AIlWClVRPfxi/mft/PB+ GKxQ== 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=BZKEoNhgpUCxk0BJFPhN8SyKdDsMxIN4bfJcnaCrMrQ=; b=A6Grh3HAA4fDnUImTlimcI2nLK0ZElltaG+5AXnSUa19Ej4xtTe5T3qpYfuW2duiGN umn5tGk0Uuhe5/JBWZB/VgzkPbPXLSt0ClJPPc+udUR284hUEmDiwTGBZ0Ep5wNeM0HA 0QwOUsCwmNc/pmz4O9h/V7vLI+y7rG4xoF7D+4zUfv52uPBXtUet+KPS7qGcecS9IYmP ibrXDMnBpgH1fxlVgA+yX0deeslCBdHlGRZoelaFHabUcOCMA+2qQevYtiBON1g9MjOc miqeXoyTBevgk+goMs/AK9EX7CsMS14n7K003dAwsjoU6IyNxthTZ4wnCTfhH57x0uEO OTIQ== X-Gm-Message-State: AOAM533R8d9tpoRCDiepf87Bz0Yo330SH/tSuLup/JKUOSY+LmzrEr6s BYJ7tnfIKe5CQ/Xf9WftOqLk66Bm3zN+tCQt X-Received: by 2002:a62:fc4a:0:b029:19a:ad58:b015 with SMTP id e71-20020a62fc4a0000b029019aad58b015mr1116046pfh.77.1606424818052; Thu, 26 Nov 2020 13:06:58 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 13:06:57 -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 14/15] remoteproc: Properly deal with detach request Date: Thu, 26 Nov 2020 14:06:41 -0700 Message-Id: <20201126210642.897302-15-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 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 --- drivers/remoteproc/remoteproc_cdev.c | 6 ++++++ drivers/remoteproc/remoteproc_sysfs.c | 6 ++++++ 2 files changed, 12 insertions(+) -- 2.25.1 Reviewed-by: Arnaud Pouliquen 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;