Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp32409pxb; Tue, 23 Feb 2021 17:07:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxt7iTKiodb9sWn/+o2M6Wcr2vaIzhfMM56qbn8XCm7ltjtA2WJwp4PYxMVJ91Bq3itgPIk X-Received: by 2002:a17:906:4e1a:: with SMTP id z26mr28353533eju.349.1614128849536; Tue, 23 Feb 2021 17:07:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614128849; cv=none; d=google.com; s=arc-20160816; b=Ctfpe1cfW1SiLJ13BaZdfAxpIvi+X6UKNOfP80HF4gLUgcn62DMT6c8VPWwmlZoD8w RaEHzqbr2WS1bZ0mnDaXm1DpLYTfTylyblxH9D47uB0k9hZnDGu6Dq1sZ1dQqGnz5EXI MfOfmvMnxdoO2ufEHxvOalGz2ebBnQsrE66puLo72NFExK97SzqriMnRWo/9omiDVxz9 8XurJCtJnxC9oxZrU2yBMcYSn8TRQvf6wUXneTgd93VJxNa7ZEh7dMcRjZtiejwXMJpq zRrZmX/HmLCBtrRpJ2TYjOR8gAhjLRgXOQzqYqOjtLOGqpu/wvDJP/KNLtQBabHA1kSr lZVw== 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=skygqmTpwpFqHXp0ZsK0QIEBfsju4nOHMOtLAZPE+UA=; b=nMKfrY7ij/tzIF4uqPyMMyq9ATcgOqIxolnIk9NgQjYv1RYC698OVjf0ThsOfwKDLg teN00gKTjlBWnjRF6jHOUngHy0ZgRBJaAUK2himQalII5pNAscoLVlOSx2mVI+LTjg81 eExVVh60JqpBynW2GTV1RtUXUTbIFwwB/AfQVULFQpwRQikdYvnX3GAvGT3xh4R4EI1y BPpqdMhi/jz11C7mWs7cJwp97CTRP3hsrUWUG3O2SDckXAWDQSNThATshB6S+jwLX5+a j9JjENf/xT5qDac7cdWWkZvavf8Q50h1DpbpMpWiIayZq0cMsuGS9I63aIt1ZlsN0XVg XHBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fkfxqba5; 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 p9si285307ejg.571.2021.02.23.17.06.56; Tue, 23 Feb 2021 17:07:29 -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=Fkfxqba5; 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 S231414AbhBXANW (ORCPT + 99 others); Tue, 23 Feb 2021 19:13:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233914AbhBWXma (ORCPT ); Tue, 23 Feb 2021 18:42:30 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA0C1C0611BE for ; Tue, 23 Feb 2021 15:35:32 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id b15so48879pjb.0 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=skygqmTpwpFqHXp0ZsK0QIEBfsju4nOHMOtLAZPE+UA=; b=Fkfxqba5KS3e8uLyKOIcfVl1j5B95mT1rMRKDnEO5h2ddnC8Bxa9CP4mbLlZtFtkx9 vqk+yoMuByYC0Mg/maHGla3K2ROMO0yRNYXC4UAXDJMSuMwhidb/MbVKEnK/pY4fXqEZ bWnhoj+R99HcmRPHWIbfZkzulHB214Mmsb2vug7Cr7iclMxThGLcHB0HKQ4oXkhsoB0Y HiT7tIEtdaBow9CFuyCQkdgjeOjpka+tXtFfdVjWvIrAYiAP04RduYO/euP+hHmCuy/S C2EoCSLs3NyndBUtke4wis2WOyNFxZPZFZCQvPLp9UDUcElnRkGyDJeDTIJxHV/3L8FU eGvQ== 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=skygqmTpwpFqHXp0ZsK0QIEBfsju4nOHMOtLAZPE+UA=; b=VA/Hzu3vQ64ydhhdmY26X74WP4KYy+2O13CEvSaSzoj8Vj6ChTCCGoILx3GgFCtCaF q7KygQsqNN4bKJ82MvUvneioVjIlonrMpi2et9JXKP0BNJlQ9M0OJpTr4MkXp7+UDBde haPaEN/REye6Syuzx5tgf82y9BJ+068vGh3pM7rwQW2xBvyKrOLF0Q27TyJbE5OwD04t 09NIqjJQA33B72nBnJ5CYpA/Bv1EdQt7ALSWviMm5iFvPap0VSGrYYa9Sb1DDYUe0N0G qljmEDklQjHeMasdiX4IOssdlPmmc8Whjdfc+80Q7vOibyJl0L57M29E3XW6jQFs6cYv qE5w== X-Gm-Message-State: AOAM531iBSszsO8TyNHiuIMjxune+sAL2WU+Izfpyxd7rmCzW6kCTqoK KljD9ApsYoTKyNJ/H3ebrj3FJA== X-Received: by 2002:a17:902:ec83:b029:e3:ec1f:9def with SMTP id x3-20020a170902ec83b02900e3ec1f9defmr15096233plg.11.1614123332545; Tue, 23 Feb 2021 15:35:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:32 -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 15/16] remoteproc: Properly deal with a detach request when attached Date: Tue, 23 Feb 2021 16:35:14 -0700 Message-Id: <20210223233515.3468677-16-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 This patch introduces the capability to detach a remote processor that has been attached by the remoteproc core. For that to happen a rproc::ops::detach() operation needs to be available. Signed-off-by: Mathieu Poirier --- New for V6: - The RPROC_RUNNING -> RPROC_DETACHED transition is no longer permitted to avoid dealing with complex resource table management problems. - Removed Peng and Arnaud's RB tags because of the above. --- 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