From patchwork Fri Mar 12 16:24:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12135265 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01694C433E0 for ; Fri, 12 Mar 2021 16:31:36 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 30BEA64F9E for ; Fri, 12 Mar 2021 16:31:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30BEA64F9E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pi6cYAAxHxC6xT5qapMI9sq6RTdxHgrzN+zcRrEY5ek=; b=nNvJdHMDYm2ADTXpSobTu3kwG jEe1V2OP4JcHwY1Sy2LMYw3ft4iSAaWnW3jGdsm7RH59HFfK7Nbw+2Efufc01IMADDYEQ4jM6nAgQ IrUhGjR9i6HuKabAbAgu0UaKaMmndvu7y8RVz99gsuT0bCcPJZyZv4XPUviZIKfGnsKD0pflZCgWW dfj9ISEmmSKveCi2ipiwm0mieY1pVbU8dKMnzwQBsWzp/6iFnnrM660UDD0z0IZfc73vDuUF1Cmsl flZJbfkRpTms+UkBG1z+IQxiN5f15i8Uhq3eWHbmEaH+gGQ/PmMwwOCtopfFd7cGNYPF3DnVrrevj mJAvJqZ/Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKkfi-00ByeN-6t; Fri, 12 Mar 2021 16:29:54 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKkbC-00Bwkk-OM for linux-arm-kernel@lists.infradead.org; Fri, 12 Mar 2021 16:25:18 +0000 Received: by mail-pf1-x42a.google.com with SMTP id r16so877110pfh.10 for ; Fri, 12 Mar 2021 08:25:14 -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=DoxVu73kjDBB6G+GqFJuZWjDsELYStjGVY6plUBqlVW8SEESXd4UJfYhxlcENxplnE 1xJ85jHSD+DESiciZ/whQ0v9aVsTsCxif+CUVhw+6qZFG+jZR077sQ2MC6+yzs8jYm31 ceCUx/8XDTX9SftcjKYiPXuiIVKRII7oLCTjseZm5RvRVH4ZjhMNt8pl4Jox7SvI5Szv VZl1Qd3JBAMUkeeVCDFmYTofk0/nZ9zoYFwvlg2AxNilu/b0S5DrSjpUHHDxYYL9SRO8 ACKowoV+UgnPTI3nFETwbDA6ejSXNodP39T2sI31UwvblMk4PXFPZdssJYX+pYx8/oAg t7MA== 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=Q+W/rpWavEMyKNnbZh6U6I+0ATp5XSlzU3ekr/uKTdwjA7boO8bqvxVNVmHBB2WMWh Db2nGEHBsd0/VOn3qarti4Ra0zT1oeW94V/KjAYPqBW5QerXNaWLfH2a7K8N3a68SJWn UzezLZRCNpUNBgZ6Cs/Yyi0T7ed/UW45Y77ckbCqHjZYr4ZvurdcxvTzujdZDySoOJRV J2Zrzo97CduCC+zzUZQ2rpXOSIHj2iBoZDhtRX64oRkagOPF8UUtUz1PR7i+tuDt+vyF FDlve18mVDYwiXXThnM8QK8WCX1PIgfoDWJ+i7+ZEreli5wp5GX7H90lBYEHRbdHUyjr V/2Q== X-Gm-Message-State: AOAM531tA45EkefSqocK1z+A6WjK6ttXuYax72nFVkOcMvYISNvkw1bb i8aWcg9YKhPN9beE1E/apswTAQ== X-Google-Smtp-Source: ABdhPJzPJ7a7B2gKd7mX/cHBrA1bcydfqcm9yX2BF56Hal2O0TDosxxZI3SuKPX6uNk5f41tojh1pQ== X-Received: by 2002:a63:db57:: with SMTP id x23mr12394765pgi.432.1615566313341; Fri, 12 Mar 2021 08:25:13 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id e8sm5899599pgb.35.2021.03.12.08.25.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 08:25:13 -0800 (PST) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com 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 v8 16/17] remoteproc: Properly deal with a detach request when attached Date: Fri, 12 Mar 2021 09:24:52 -0700 Message-Id: <20210312162453.1234145-17-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210312162453.1234145-1-mathieu.poirier@linaro.org> References: <20210312162453.1234145-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210312_162516_335813_B114084E X-CRM114-Status: GOOD ( 11.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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;