From patchwork Fri Jul 23 22:02:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 12397057 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=-18.2 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=unavailable 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 E6E9FC4338F for ; Fri, 23 Jul 2021 22:07:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 AA4DC60C51 for ; Fri, 23 Jul 2021 22:07:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AA4DC60C51 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8iPowkKY6YU7QucHu2N68sgCn6lueDz6vaXXB4WEzgk=; b=4QMaTkMpqA4Cs5 IByRwEAeO+WXcfT81W/YVd3Kob2yuq+x6BOo7QhPRTvXk6kjULkEFgnNV6Uti9sm8FY6iy5LE8L4O Q9/wUU1R4RAbd1oRZQiM+NGGWwaZ22NDCyq9lr3fSrxu2lTatTsi7e2F1gflbDIfDu5qpqOnh+bG4 0Flp+S0BOEJmFzuOD3fvn8dwkiiMH7nUyh2rZ9VlLU+Lhe/fQhddtFJLGKal3/CYISfGyRNuY+Wed 5buhBwObKCcNmBAdCpk/i31Ee4SkEGnnTyDBwV+UgjU4WmwX1qyGCpIBit76C/4p3XYNnYVfy7lWW 5vumgfqPg5PUFOSGIQ6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m73IU-00695P-1j; Fri, 23 Jul 2021 22:05:34 +0000 Received: from fllv0016.ext.ti.com ([198.47.19.142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m73Gp-0068Mf-9N for linux-arm-kernel@lists.infradead.org; Fri, 23 Jul 2021 22:03:53 +0000 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 16NM3oap057061; Fri, 23 Jul 2021 17:03:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1627077830; bh=uZZ1RqyhqZ7imMA6Ex9lJr6p4A4y139cey6GLoCZEOk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=H52/RvYbw78aQGyxNpvlpYU/aSAo52ApmKSq3P4W/FO1MRcFyfrvH20Oak5UxZhSF ceIq3kZ/SoRF7hn9CcE/QA7GilCKn3iM3SeMMvVmgphEGCyhw21I3YqIyDiYhqEyAa LHcnmeytHJPHDngVivtTjQt4dnhdhlTsNFH9oyo8= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 16NM3oiG038452 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 23 Jul 2021 17:03:50 -0500 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Fri, 23 Jul 2021 17:02:50 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Fri, 23 Jul 2021 17:02:50 -0500 Received: from fllv0103.dal.design.ti.com (fllv0103.dal.design.ti.com [10.247.120.73]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 16NM2owY025364; Fri, 23 Jul 2021 17:02:50 -0500 Received: from localhost ([10.250.38.176]) by fllv0103.dal.design.ti.com (8.14.7/8.14.7) with ESMTP id 16NM2nf0126728; Fri, 23 Jul 2021 17:02:50 -0500 From: Suman Anna To: Bjorn Andersson , Mathieu Poirier Subject: [PATCH v2 1/5] remoteproc: Add support for detach-only during shutdown Date: Fri, 23 Jul 2021 17:02:44 -0500 Message-ID: <20210723220248.6554-2-s-anna@ti.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210723220248.6554-1-s-anna@ti.com> References: <20210723220248.6554-1-s-anna@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210723_150351_453996_1E244A26 X-CRM114-Status: GOOD ( 18.27 ) 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: , Cc: Lokesh Vutla , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Praneeth Bajjuri , linux-arm-kernel@lists.infradead.org, Hari Nagalla Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The remoteproc core has support for both stopping and detaching a remote processor that was attached to previously, through both the remoteproc sysfs and cdev interfaces. The rproc_shutdown() though unconditionally only uses the stop functionality at present. This may not be the default desired functionality for all the remoteproc platform drivers. Enhance the remoteproc core logic to key off the presence of the .stop() ops and allow the individual remoteproc drivers to continue to use the standard rproc_add() and rproc_del() API. This allows the remoteproc drivers to only do detach if supported when the driver is uninstalled, and the remote processor continues to run undisturbed even after the driver removal. Signed-off-by: Suman Anna --- v2: Addressed various review comments from v1 - Reworked the logic to not use remoteproc detach_on_shutdown and rely only on rproc callback ops - Updated the last para of the patch description v1: https://patchwork.kernel.org/project/linux-remoteproc/patch/20210522000309.26134-3-s-anna@ti.com/ drivers/remoteproc/remoteproc_cdev.c | 7 +++++++ drivers/remoteproc/remoteproc_core.c | 5 ++++- drivers/remoteproc/remoteproc_sysfs.c | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index 4ad98b0b8caa..16c932beed88 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -42,6 +42,13 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_ rproc->state != RPROC_ATTACHED) return -EINVAL; + if (rproc->state == RPROC_ATTACHED && + !rproc->ops->stop) { + dev_err(&rproc->dev, + "stop not supported for this rproc, use detach\n"); + return -EINVAL; + } + rproc_shutdown(rproc); } else if (!strncmp(cmd, "detach", len)) { if (rproc->state != RPROC_ATTACHED) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 7de5905d276a..ab9e52180b04 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2075,7 +2075,10 @@ void rproc_shutdown(struct rproc *rproc) if (!atomic_dec_and_test(&rproc->power)) goto out; - ret = rproc_stop(rproc, false); + if (rproc->state == RPROC_ATTACHED && !rproc->ops->stop) + ret = __rproc_detach(rproc); + else + ret = rproc_stop(rproc, false); if (ret) { atomic_inc(&rproc->power); goto out; diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index ea8b89f97d7b..133e766f38d4 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -206,6 +206,12 @@ static ssize_t state_store(struct device *dev, rproc->state != RPROC_ATTACHED) return -EINVAL; + if (rproc->state == RPROC_ATTACHED && + !rproc->ops->stop) { + dev_err(&rproc->dev, "stop not supported for this rproc, use detach\n"); + return -EINVAL; + } + rproc_shutdown(rproc); } else if (sysfs_streq(buf, "detach")) { if (rproc->state != RPROC_ATTACHED)