Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp258120pxa; Wed, 26 Aug 2020 09:48:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAFE1COsK528rkignkVbF054cbtTh3HmS3Wq0tzEqfRhE+VK2N2up9DNnsUdiC4lzhPXmW X-Received: by 2002:a50:8f44:: with SMTP id 62mr16553388edy.3.1598460489218; Wed, 26 Aug 2020 09:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598460489; cv=none; d=google.com; s=arc-20160816; b=mUpH1bKwfOGNfJDbFC6ymKxyKNLUKTWGxbEsPFPwvLv5ZZFiVc40CZJ8XuOebB6PE2 Noz9DBMIYT9kOQOS6fvDxPAQzyfUNaqcbuxhzTjedQ6l8jc4jncsOqjKT0tKYOW1Jlbd oIBTuLlZOddJf4gCarcEnklaVl51a98c/LH9KFktOuEd3b2astQAheKrbFu5uwlKd2Iw CF+Vw39yHByU78MJTcddX7pLwAdyYcJ7zzbS6t6tKL4ecP+yiepMW8jvBg9I1rIU6WQm p3xMaOop4YzIXgyvT81ojpyg+vIN8wfMijrae4z8doiKHT9Y//tBtNGaIfgyobf/XhSM Gd1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vD2rRkpHQd7S7fgYM9UtluBQRAWNlF6cNXgHEuKBTDo=; b=d+QsMBkHPQ12RjbcWe/DCE9kJfzUX91AOI6/EBo54ZNUI44/plIY/NdeGi++PNfOpV DRVVpjY43AxJTLgolKHIs+50ipvu+fY5aTL1f73qhhOmd7ao+0rrTECj0yHUrsxmCsUP qaqJQUwaGFnfUckm+l0FLBZBHFbFl5JdC9Nv3nVoiRluvmjpqxUzR2O54O28EFqcLafH C7EbkII6l7Fau79hblw+qbN+wu4YodQ9ao/EvyHSy9QvFO44W9iJZqsrBXXHP0MF/amy zPhUa2AzGxJmSmg2m+jxnYtIOaHM1FZwRdMpOCD+vYL4rfA3VV3F/CCCK6B1mOW552A2 +yGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u4MqR1kf; 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 r26si2066109ejb.209.2020.08.26.09.47.45; Wed, 26 Aug 2020 09:48:09 -0700 (PDT) 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=u4MqR1kf; 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 S1728030AbgHZQrB (ORCPT + 99 others); Wed, 26 Aug 2020 12:47:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728105AbgHZQps (ORCPT ); Wed, 26 Aug 2020 12:45:48 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CA6CC061757 for ; Wed, 26 Aug 2020 09:45:43 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id z18so1148535pjr.2 for ; Wed, 26 Aug 2020 09:45:43 -0700 (PDT) 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=vD2rRkpHQd7S7fgYM9UtluBQRAWNlF6cNXgHEuKBTDo=; b=u4MqR1kfjSxsFjxQ0PC6CVjxgQW0LN3TJ+f5D5WxPBbfYC7VvbcnbDe6a2bsjweMD0 zqA0IvUIthS4sUphaqwCH0nFieEOcHnKksL0wv2C9jzLeZUP6R7/VnUoG5X0fDF/Zort O6tTF023b0+CKYMxv1qDpgPMNneIPHm8Js2tzpU7KU2SwgUqeSP8ZUBIryDQ/VD8kTcB Iah0xIR/R0yB9nB1NY/Ue3ZnarEhN+fkVgmGGKsVP7Yuw4/iSSTjTmCOLH1FpaASL3T5 J9eD7F7tlXchyJQSE42YPgiBpdC7nM5HbjRZE5W/hKT32qW+jk36o9D9MI00tNeNGSSA 5D9w== 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=vD2rRkpHQd7S7fgYM9UtluBQRAWNlF6cNXgHEuKBTDo=; b=SdNpirQ3UT/syVjQs55uHR7B/I4i6qyHEk/on4FhokuTgj9SbJwuyWkh/9/HL8SdxJ BiSCY4pEYhyEBBolFRVe+ztI/fMDsdKxLGumB2S2Rxils/HhygpEgROmvBIK5AXpsjWz b1Tfogrq4Qp8oEMcqChBRQGuIs2eaju5/cVq6z47q2p97/tRpYTruvoaLEr5fGMi1nSz hDT9m+qSUnO35bVW6gMzcoNWj6OQ8D9Ooi6RlD23kwTaULsRDxBUH96BdqwUM6v5Fsi6 LbTfuJt2el1dOPy2ZpMF7r8uEnpfoJT7HT/0ZPQwqZHzsC4iFk7wRshX5uf1tjVuXOfM fLIw== X-Gm-Message-State: AOAM530g0FPkcPwJSsz9Hp43fWcdmrWvagnZB+A0UK3GZNg+OZQ7Totw LfyYSkJe+tt6wPPozjcVbJWVeg== X-Received: by 2002:a17:90a:d3c2:: with SMTP id d2mr6797133pjw.112.1598460342752; Wed, 26 Aug 2020 09:45:42 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id u3sm2548878pjn.29.2020.08.26.09.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 09:45:42 -0700 (PDT) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/13] remoteproc: Properly deal with detach request Date: Wed, 26 Aug 2020 10:45:27 -0600 Message-Id: <20200826164529.224476-12-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200826164529.224476-1-mathieu.poirier@linaro.org> References: <20200826164529.224476-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org 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 or booted by the remoteproc core. For that to happen a rproc::ops::detach() operation need to be available. Signed-off-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_cdev.c | 6 ++++++ drivers/remoteproc/remoteproc_sysfs.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index d06f8d4919c7..3a3830e27050 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -42,6 +42,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 6134d2f083ce..013231f69837 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -118,6 +118,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; -- 2.25.1