From patchwork Tue Feb 23 23:35:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101059 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=-16.8 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 C25D1C43381 for ; Tue, 23 Feb 2021 23:36:56 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 71D2264F25 for ; Tue, 23 Feb 2021 23:36:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 71D2264F25 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=merlin.20170209; 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=iQHgNCjXw2gbKvbggID3LDgVMQeIMTG2TBMC4+Kjkjg=; b=QySy6qBEpA46l/lSEyn5P7fSY V6OclB1nKLUGlXGyiPlvFH0HnzobfjpPuoTtsjMwFXxCNJlhscOkYqJAR0nomwgufpfDby+duTfl0 tKphO7FmO4pp+/LPlZBqEWRjkta608v8pGJORKxtFq9L0GvmsmOvrKuLDechjH8k0P/ntbLGNvQ8S SGVPHw07rUbgHC/tqos9kUPLZUROLk6JZkAk2av2FB3ulb9iJqEcGEwZzQZAd9DaRI3LS49bBVqpi hRafqLEfAkkumDg0ws3mZDrlVgFc2EUQqrKxDi1q3+GtTfqLCzjMgl29gx5sbLWlr53+Wv3xuKWEd f4gT6t2DA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDM-0003X8-EX; Tue, 23 Feb 2021 23:35:36 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhD7-0003Rl-SO for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:23 +0000 Received: by mail-pj1-x102e.google.com with SMTP id s23so50784pji.1 for ; Tue, 23 Feb 2021 15:35:19 -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=2KkXz7Q+zlIq4fjTeJz23Qytt+RMPnrKFr7q6Kz46gw=; b=VT3vWAAA1/nWsaEJw5qwCO0P0+fsf/zztlHgIz27KF6UqyOj3/o4QRT+ZnBkifIFFl ijt3TjrVTXgRdMiNE41ZaxRFrnMsB1WHCc9NZ0oXoNjAgETLSILe1CDqHduMyCQXX5WZ tgaIZBHWoNk0/2CmLsXaS8226jUShwMzLeIRL3iOSfMFCKB6x0TvF6Z7psLOoOsMx/q0 kgVnboJxNpRg0aE/NIZPJ54I0lteJH8hVC6XX0i8bTCpXFAIdpXSnUBdOeCEz6gXWehw Kbn/fgeQBcml5A9IzvpUTOWr7CHq21nbbBZIjwoEUME24CAp4lSupkH95NZIMs4Hzetc l2Cg== 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=2KkXz7Q+zlIq4fjTeJz23Qytt+RMPnrKFr7q6Kz46gw=; b=hProZpbwagUKv41hMCoRYJoV707MPNsVHGbwRazl7gPd5Tg/B9uHQ5hVyKA5KNE15I M3Fo+N8IXuAOe+XOLOL8Y051pYgrTeeF4uopk5uWKvexlUIccnUn+H61i+BxCib2/rn7 ZnUf+E9URF0rq1HwBa8zuT2Xl/n1FSj5b2wj0Z45e/EuOjqy7LwH7Vj/M3+s9+vJA4kH zYEzVwBbtd7uhNzVnLzSTrRqaH6EUHlGhOy/fhMsu77VzRG18xeolObBm9Ycbq6D/2ox nTYlkUytljkGVkyjbFeE4h4QA7Dz+x9K9PvSCPZHkqsYO7rNA72bmeIlmFHHSPoOREVK +wLw== X-Gm-Message-State: AOAM533KKYGrWK06ahMxM1DGz5oc4QW3l7/xtgNm0o6uUw6f7O36lo2W EZXS/T8j15bL98SWGSCgx86Ozg== X-Google-Smtp-Source: ABdhPJzME6ROr47/MgtNT8Vns+S4eE+gd/rS7UXIX0eua10m+gAhj0BDo1+R5PHgYg8wdAG3+u1+bA== X-Received: by 2002:a17:902:c789:b029:e3:dcbd:843b with SMTP id w9-20020a170902c789b02900e3dcbd843bmr4832710pla.61.1614123318320; Tue, 23 Feb 2021 15:35:18 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:17 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Subject: [PATCH v6 01/16] remoteproc: Remove useless check in rproc_del() Date: Tue, 23 Feb 2021 16:35:00 -0700 Message-Id: <20210223233515.3468677-2-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_183521_949826_1F1311EE X-CRM114-Status: GOOD ( 14.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Whether started at probe() time or thereafter from the command line, a remote processor needs to be shut down before the final cleanup phases can happen. Otherwise the system may be left in an unpredictable state where the remote processor is expecting the remoteproc core to be providing services when in fact it no longer exist. Invariably calling rproc_shutdown() is fine since it will return immediately if the remote processor has already been switched off. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index ab150765d124..d2704501b653 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2347,10 +2347,8 @@ int rproc_del(struct rproc *rproc) if (!rproc) return -EINVAL; - /* if rproc is marked always-on, rproc_add() booted it */ /* TODO: make sure this works with rproc->power > 1 */ - if (rproc->auto_boot) - rproc_shutdown(rproc); + rproc_shutdown(rproc); mutex_lock(&rproc->lock); rproc->state = RPROC_DELETED; From patchwork Tue Feb 23 23:35:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101063 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=-16.8 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 81187C433E0 for ; Tue, 23 Feb 2021 23:36:59 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 339DF64F2B for ; Tue, 23 Feb 2021 23:36:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 339DF64F2B 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=merlin.20170209; 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=hypLriGUX/1a4e7/L/y1/eipRTGbXJcIczcxJTu69Vc=; b=n2gPLDkVKLSqgTa4MmoXlN2ev z6DUa1aePLI1o/dt7MZ8GsBoNYmgQXvffT7dhVOMqoPij39Zi7Mgw7ecvBOZkJE7dpX/bUzandUTH Joeq6e+xBk3xsHPFnJVVmeezrm9qleJ/5/ZNklvvdDNtPz1pjdHmA5G6Rzio3i109v5njPxNEVl8g D+MKdewI6nVuLVl65ni5Chl5DTN7JJ80KpEB3CevENpB9fB9t47kWWjnJtldAKwvErHQcm7SlBDzG QuISe+/Q60Ey6izgZsxvOSA+osAQonjscrFFAEcD42bAGJNxTn2pnqWHNv/JdNfXDXA9kK1vff2Gj Zr93ci/CQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDB-0003TV-79; Tue, 23 Feb 2021 23:35:25 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhD7-0003Rm-9K for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:22 +0000 Received: by mail-pf1-x434.google.com with SMTP id 201so56605pfw.5 for ; Tue, 23 Feb 2021 15:35:20 -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=eI1kKtC7UxMHnJr2s3EPvhdO8fxk/LLGwiTP5XOosV0=; b=JYeh3wnybb4/m/UUR8LYuWcMywXegKKe2DxENoFrS8xZIgUWNzlNef/Jz6v/hiVsiP vQeR+YNRluWGmPtmVcduAElrCxHj/amtzcAQsk7k1opnA3cxk1NPbEEfW28RCmrCFU+i xinri+qaJjiwsZi+zvHwsgM6I4diKQaopxwU8k4vT4g4pPqHGollzxJtHQv+bfp2WUtv qcPJsmhxv+NsT4KYpMXyR77TxvcPjIZc2Zq2dF8STNuhPSr3n1dbBPBvmYz6z+LfOEEh uUNSv5lOQLVrFtQ81NC0TcOfgxgJloEjFPkP4RS2+8BeivYwe2Zr8/jqxEdYyVWy6qnP YnOA== 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=eI1kKtC7UxMHnJr2s3EPvhdO8fxk/LLGwiTP5XOosV0=; b=W7U6qZ/ZdsWNtnDBzRGUeRbTjfn4nHGdokZ74aUTkhICQkmCUkSq3MwGJ/8AXY02EN FhH3pCKhup5m26YH4jCpdcA2lIKml+okLkSsJIFJUI9Pj1CENtVPpFJ7ffzDbCLAAHT9 4/Jr7zDZP5B+8cqkbzehxHb2oH6g4Z5ftGxGz8nMqWd8jENnUK5N4R0kiadd1lBWuaol vfkKLWbKGSMN7fc7qO+0jDnA5GFyIe0o+GKgV/G8Cdgpwd6AfVTdWMaHfA257dY/aV/N x4pKUHrPZztjhDgSiCyUXfdKWchu6tF4fyQbIDZ7zucqr6r1V1P+acpqkJmgLrjLOMuE XCpg== X-Gm-Message-State: AOAM531lKrUk1Rx5FTDznf0Pq2pDcd3MQ/L2HGNA8LoEuSP5av9PQqT9 yTC2dkUdodmdh4avn9pXAt08oQ== X-Google-Smtp-Source: ABdhPJzsi6TXNp0kZzJEbaem3F4zHgJtQu4fTQYb8U7x7qnmSjpWBBr5dEjDShlaI4BKVzv+X/STLQ== X-Received: by 2002:a62:7c15:0:b029:1ed:9e29:5998 with SMTP id x21-20020a627c150000b02901ed9e295998mr12313479pfc.22.1614123319231; Tue, 23 Feb 2021 15:35:19 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:18 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Subject: [PATCH v6 02/16] remoteproc: Rename function rproc_actuate() Date: Tue, 23 Feb 2021 16:35:01 -0700 Message-Id: <20210223233515.3468677-3-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_183521_412717_5D81AACF X-CRM114-Status: GOOD ( 13.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Rename function rproc_actuate() to rproc_attach(). That way it is easy to understand that it does the opposite of rproc_detach(). Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index d2704501b653..7b66e1e96e4a 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1416,7 +1416,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) return ret; } -static int rproc_attach(struct rproc *rproc) +static int __rproc_attach(struct rproc *rproc) { struct device *dev = &rproc->dev; int ret; @@ -1541,7 +1541,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) * Attach to remote processor - similar to rproc_fw_boot() but without * the steps that deal with the firmware image. */ -static int rproc_actuate(struct rproc *rproc) +static int rproc_attach(struct rproc *rproc) { struct device *dev = &rproc->dev; int ret; @@ -1581,7 +1581,7 @@ static int rproc_actuate(struct rproc *rproc) goto clean_up_resources; } - ret = rproc_attach(rproc); + ret = __rproc_attach(rproc); if (ret) goto clean_up_resources; @@ -1802,7 +1802,7 @@ int rproc_boot(struct rproc *rproc) if (rproc->state == RPROC_DETACHED) { dev_info(dev, "attaching to %s\n", rproc->name); - ret = rproc_actuate(rproc); + ret = rproc_attach(rproc); } else { dev_info(dev, "powering up %s\n", rproc->name); From patchwork Tue Feb 23 23:35:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101057 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=-16.8 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 16912C433E0 for ; Tue, 23 Feb 2021 23:36:55 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 B894964F1C for ; Tue, 23 Feb 2021 23:36:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B894964F1C 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=merlin.20170209; 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=4Ol2dtKPYpAMa6Rfv2rWFhjpKBdqBFZGHp/23479TEw=; b=Hp4tHpChbNjVTSRnQGBq5eMFd TFpd/av44xE+zb+KOqxtrRuZ5Nrd37ZobS9dp7iMDcRYKhN3OrxBH23d9ZOdblOBftLyX6fAPWErw kSe3UHt85tDZ1UURqZ8x7bfA2UbS2DO3G+r/qFvEmNYIzAGEPp4caA7KoaACEsmJ2POGUCkcx5xoY IUzRmogW67ymG+2h/hJ8u+Pmc95PDiNEXjgxzFaX2mjdCjxQSOjfX79r1fAgyqasfZttJSUHPyghC D0WhubhVpH2cAmBD5bpmBuaaXYBky+dbkgv1eoMtSeDUMhGM2xEmRGgjoEe3yVxDp76cEnQCDTXr4 dhYrxyFGg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDG-0003V6-7H; Tue, 23 Feb 2021 23:35:30 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhD8-0003Rn-9Y for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:23 +0000 Received: by mail-pl1-x62a.google.com with SMTP id z7so3020plk.7 for ; Tue, 23 Feb 2021 15:35:21 -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=waytkFv28UuOXcaaNeh19CxfKAUzKWp03mnaFrOUKvo=; b=sufk6rE3/dXnMqzi78VzeEuWwNSyI9Jafh5/gweW9kamLR3HYQEs/qr0R2FCq+SpLV TUHEr6smwUpZYibTMKN+7V+oTpSBLajAf4fbj9gUmGw65vUbNqYScn9J+y3IXVaRdrlk o+YGaCC9XXt/0a3xDztIAps6TaKutwVtyv37jY6lnY0HlCHC6AcZ4+ivZJqp8WjfBJSc uJdJEQnEe6FC5u3mu4/GfQTxlCh1znYrjeWMHinbrt1vE1xJM1XfKZDN6XOCeiv5LUhi fHMpsUs5ArvPYM/UlxQjwiM92KTXDpbOcC4f4zRyqF3aNQP/NtJ9Y1cqQ4JK4nSO3555 nPzg== 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=waytkFv28UuOXcaaNeh19CxfKAUzKWp03mnaFrOUKvo=; b=f8MNfU9EBBUH1wpFgrhI4tG3pQYSRpAO6/a78N7plY685oEGwcsxkOjeCTykcLcDDv az3wgbNbmtt9SZ28XWpo3kx4ju/fAzPWwPrz6N2+RheFPMtZdV5Tea2PoG6wQNwPCS6o k8kigHX+1jNJUMur62pbiYNn9IuOELovFVAXcTviu4N41I4UGScUF2TaEg9pkuUFJrxO QaWqhUDuJPp5Nl05DfGufbtVYHInLdMwiJqnMeH57gCnOw7gFW0H+K/adCXjDGp+ujhQ Jee5K3eefnGcAsReVvH/JOrne0kwpaTzIOCgR5ksrxsQs+QvI1o9I2bR+uAHQBdqtfud +GOQ== X-Gm-Message-State: AOAM530hi2bv47TD6Y0hIfz6EQ4aeTs3M/AiJGMhwBIjivAMFKDWLitH F5e1b1GMfSHpH2yYRxHNlHwxVw== X-Google-Smtp-Source: ABdhPJyz53wXTScCJJHK+0zal+VXwSHeBnigEJ0IybsgF/8onQIB+fzZZu6AviRn5AHuVdwP6tT/6A== X-Received: by 2002:a17:902:e993:b029:e4:1426:8e71 with SMTP id f19-20020a170902e993b02900e414268e71mr5806317plb.74.1614123320126; Tue, 23 Feb 2021 15:35:20 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:19 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Subject: [PATCH v6 03/16] remoteproc: Add new RPROC_ATTACHED state Date: Tue, 23 Feb 2021 16:35:02 -0700 Message-Id: <20210223233515.3468677-4-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_183522_391926_E035AB02 X-CRM114-Status: GOOD ( 16.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a new RPROC_ATTACHED state to take into account scenarios where the remoteproc core needs to attach to a remote processor that is booted by another entity. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_sysfs.c | 1 + include/linux/remoteproc.h | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 1dbef895e65e..4b4aab0d4c4b 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -172,6 +172,7 @@ static const char * const rproc_state_string[] = { [RPROC_RUNNING] = "running", [RPROC_CRASHED] = "crashed", [RPROC_DELETED] = "deleted", + [RPROC_ATTACHED] = "attached", [RPROC_DETACHED] = "detached", [RPROC_LAST] = "invalid", }; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index f28ee75d1005..b0a57ff73849 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -405,6 +405,8 @@ struct rproc_ops { * @RPROC_RUNNING: device is up and running * @RPROC_CRASHED: device has crashed; need to start recovery * @RPROC_DELETED: device is deleted + * @RPROC_ATTACHED: device has been booted by another entity and the core + * has attached to it * @RPROC_DETACHED: device has been booted by another entity and waiting * for the core to attach to it * @RPROC_LAST: just keep this one at the end @@ -421,8 +423,9 @@ enum rproc_state { RPROC_RUNNING = 2, RPROC_CRASHED = 3, RPROC_DELETED = 4, - RPROC_DETACHED = 5, - RPROC_LAST = 6, + RPROC_ATTACHED = 5, + RPROC_DETACHED = 6, + RPROC_LAST = 7, }; /** From patchwork Tue Feb 23 23:35:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101065 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=-16.8 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 BE37CC433DB for ; Tue, 23 Feb 2021 23:37:17 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 68B2864F64 for ; Tue, 23 Feb 2021 23:37:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68B2864F64 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=merlin.20170209; 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=nqyjUD8qeoCKFYACk1YaR37dyyQToyPSTssiyc82CcI=; b=bLZtGT4frvn+ZHrBORQQiy0Zh wNh+QuciQwVDbG4Y6h/UUGZjysHQp1iA3ZyTbiHvduxi07hH9uM1DzPkcvC2MKIYEYbtk3bV4Md6d VpPQtMd2PwDCVvyXzYXFsB2DTNx9RUMlBkZdP5kz/FMPz4VueMCW6j1UWFaH+zPh6v/NuGVo+96PB ibCR7gBDMV8vfR2eUGV8WP32kEKhrF8Xll/H0w6WkeRVnfOexIiLeevMb2E/LO7BHxrEONr9PxxGZ I+68cNpD/0MFamuMA7K08yIuw/H6gg+IPXiQw39W8OblibyOon/M2+PtyxzpyTieAKAzfNImZ1Fao ZDYyInkmQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDV-0003ZF-Fn; Tue, 23 Feb 2021 23:35:45 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhD9-0003SF-4x for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:24 +0000 Received: by mail-pl1-x62c.google.com with SMTP id 17so7537965pli.10 for ; Tue, 23 Feb 2021 15:35:22 -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=EmIttTOsgDNM++s8zt1RjF9fKLTZIPRgfTRmynUwSgM=; b=mcwM58WWsUXUvIsh2FdJ4BES+IgpYxO9AhUPJ1gWIw1zLuH2xRbnJpycVWoQY4dTme qd23XOhFVBK0Zm6R5OB2q8jjG7/BJOFGyDGUlj0bBDMrxogj2MLSKaDvvZ1GYJoXMo0c bF+o0kIrw0ndsMOdNGwjYVFJGe+Gro2hwWGIMWc6WYuUFHK4Bl5u40JATi5ho20E6NgM 9y43IF7s5l7K5wvZ0rwgVnDq25TJVK0SIx7iaLQB6bf4xBJTzwi2Mt0O4ot30d7hccm+ aX3YxzcOp7V67egVVkk8mRCOiVQXT+sdCpAUDhl0H6Gd1anKXA30nc7vmSLU0NDefPM6 xhMg== 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=EmIttTOsgDNM++s8zt1RjF9fKLTZIPRgfTRmynUwSgM=; b=laoBf1sMb/MPTz201UJxVfBQ4fGZyTV4+mSWQkSoSWlnlWki2TBTLQLmuxMUdvhUvz tTVqScJC/MhZbChu+qRSwcygC4J+5NHlB0gfd1AijMNc8MkC8QMa1IULt9evlwS9Wr+O YPmT21sYoqPvkR+IpOfWfLMjgbo8+14oAFufeJ2wce7HNWx9jdvGMEVkjp7dsPd7dQ+z Wd6OzGswBhn30MrsKQkoN3WYcie1qMk0XeHsU7cL36GrdKExZu8rYVN1a8tkz6tgP22m 52Ur/CDhIxMU2dotT1wyowx4OP5KDCVcH7+0BVti8AGNXnWJqyf3WP6A7he6mfyou5FW K4hQ== X-Gm-Message-State: AOAM53287upqrQiQtOun5ZKrjGp+MWlzh32y3whVDg6r1+T8w3DTcF1m MEudk53Zn7dgeoYZPnLLnoJq8g== X-Google-Smtp-Source: ABdhPJwB64ZHJ+69jz6oUR677oeFjkpkM0jxtAJzpXOouYsqrX1PbR4Ai+OtceRTW6rwTfNvfVAlOg== X-Received: by 2002:a17:902:7c90:b029:e4:340b:37e7 with SMTP id y16-20020a1709027c90b02900e4340b37e7mr475922pll.2.1614123321091; Tue, 23 Feb 2021 15:35:21 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:20 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Subject: [PATCH v6 04/16] remoteproc: Properly represent the attached state Date: Tue, 23 Feb 2021 16:35:03 -0700 Message-Id: <20210223233515.3468677-5-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_183523_776376_60D5130A X-CRM114-Status: GOOD ( 19.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There is a need to know when a remote processor has been attached to rather than booted by the remoteproc core. In order to avoid manipulating two variables, i.e rproc::autonomous and rproc::state, get rid of the former and simply use the newly introduced RPROC_ATTACHED state. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 20 +------------------- drivers/remoteproc/remoteproc_sysfs.c | 5 +---- include/linux/remoteproc.h | 2 -- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 7b66e1e96e4a..8c7e9f1d50d7 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1444,7 +1444,7 @@ static int __rproc_attach(struct rproc *rproc) goto stop_rproc; } - rproc->state = RPROC_RUNNING; + rproc->state = RPROC_ATTACHED; dev_info(dev, "remote processor %s is now attached\n", rproc->name); @@ -1659,14 +1659,6 @@ static int rproc_stop(struct rproc *rproc, bool crashed) rproc->state = RPROC_OFFLINE; - /* - * The remote processor has been stopped and is now offline, which means - * that the next time it is brought back online the remoteproc core will - * be responsible to load its firmware. As such it is no longer - * autonomous. - */ - rproc->autonomous = false; - dev_info(dev, "stopped remote processor %s\n", rproc->name); return 0; @@ -2077,16 +2069,6 @@ int rproc_add(struct rproc *rproc) if (ret < 0) return ret; - /* - * Remind ourselves the remote processor has been attached to rather - * than booted by the remoteproc core. This is important because the - * RPROC_DETACHED state will be lost as soon as the remote processor - * has been attached to. Used in firmware_show() and reset in - * rproc_stop(). - */ - if (rproc->state == RPROC_DETACHED) - rproc->autonomous = true; - /* if rproc is marked always-on, request it to boot */ if (rproc->auto_boot) { ret = rproc_trigger_auto_boot(rproc); diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 4b4aab0d4c4b..f9694def9b54 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -138,11 +138,8 @@ static ssize_t firmware_show(struct device *dev, struct device_attribute *attr, * If the remote processor has been started by an external * entity we have no idea of what image it is running. As such * simply display a generic string rather then rproc->firmware. - * - * Here we rely on the autonomous flag because a remote processor - * may have been attached to and currently in a running state. */ - if (rproc->autonomous) + if (rproc->state == RPROC_ATTACHED) firmware = "unknown"; return sprintf(buf, "%s\n", firmware); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index b0a57ff73849..6b0a0ed30a03 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -512,7 +512,6 @@ struct rproc_dump_segment { * @table_sz: size of @cached_table * @has_iommu: flag to indicate if remote processor is behind an MMU * @auto_boot: flag to indicate if remote processor should be auto-started - * @autonomous: true if an external entity has booted the remote processor * @dump_segments: list of segments in the firmware * @nb_vdev: number of vdev currently handled by rproc * @char_dev: character device of the rproc @@ -549,7 +548,6 @@ struct rproc { size_t table_sz; bool has_iommu; bool auto_boot; - bool autonomous; struct list_head dump_segments; int nb_vdev; u8 elf_class; From patchwork Tue Feb 23 23:35:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101067 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=-16.8 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 DE7E9C433E0 for ; Tue, 23 Feb 2021 23:37:18 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 9569764F6B for ; Tue, 23 Feb 2021 23:37:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9569764F6B 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=merlin.20170209; 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=pje33pFOKp5qOSdOMQ7zBINE+Z2Pl6qgcVug8UGDeMY=; b=MK8wQivPWTrDPloFr8toyjF8d CjWxz0NhFqWbohGvKG7oDWHgec7KeuiUIh1djLstubUrtE6ommL48lG0oHZrTS2PbrPXEPCv/7G+I 6lUPFDgR/VCulxC6uAuCaTndQ79dp248W9K3vMIAaDUhY9gWyhB6M7NInOBqKRQKtEMF2MPF4JZWn //3SvzqvDZUB55U2ECkIS7Mh3I9qKgGLBeL9SEq63/LWt/jWAKyN/I8hn4jQ6EQSwxLOgQhebmWch OPVs72UnWw7rwhqSEmVvji64UkWyEb4Vqb1fX+IEyxVVY4LQHry/z7XJvE7IqIYjZOvQ0CcKEfA3s nEuVPjsAw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDY-0003Zq-7M; Tue, 23 Feb 2021 23:35:48 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDA-0003Ss-6a for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:25 +0000 Received: by mail-pf1-x432.google.com with SMTP id j12so31622pfj.12 for ; Tue, 23 Feb 2021 15:35:23 -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=FhTtWZ2doNdRzGDtmgu+jcX3oUvQ8f/zyG4h5bfvKfU=; b=oJCAZRog6hxBAFJw2zpiSM+UvYVpBhl6yqgyqt6dOItsdVpAy+Kv4v+nUBfcqbhALd VMm/uz8Iy9pICeudHEluanUam5NITXMiefOGc3QRfPNVfhpnFaPzNQqTx3gpxnUaiS6G zvWacl8Eb4rVT70iE12VJbCZQYd5TK+ydLD2YedIWDxaidsX+FvkzYaLjpFouHXBTuoZ Xr6o4zkgDgTUpS9yJmNJ/YHc2kraD5PorZUunMLmdALlvGkSSZczpvfcWwiA1A1bF1RN VUhPRCQrQ/S4rHt/Xq/kbSelkCh9/sGshD9zH2fFle3YMvWlBg6F0vQFeA+4YLvrIiP6 nXFw== 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=FhTtWZ2doNdRzGDtmgu+jcX3oUvQ8f/zyG4h5bfvKfU=; b=h9gop2v160j3LRJbZ2BrWv+OdpuFcHZZi28rqOoSQ/l3Cv/G7RyiZ4rxp3Rt2R0gNT eHpgCchWnFpmO4QhF+GxOrLPHLYbPfYCrdGD91jsft1PhHMZ66Mzcpm1RDOK+woUmDUR MCJCZ+D9O5T/Z4sOqXId5L/u58+JlFTySgGzCT/U+Qi9MbjmES9DGaPbNkL+9ATS5mj/ pTLRfvgGXYkWYoV15BVkKrc9Sh95r5hwMJCSSXdQWQsLyRgdo5UAWL5+dPqFTZZlYIAA dq6BNpDuTvVwjj+BYQV6Z52DkeOT4uweG3ALk9Kpy8JddKVDsGh6dt9KHxaw4gCUDRCZ K1Pg== X-Gm-Message-State: AOAM533+RMxrKxMD5+bJ1EFAXQiR5pQJKs/DYAXvtTZwIFXTxKN6REAJ unGLNtWtnG9gpTjf4dZyM+VBPzx3sRt3Tw== X-Google-Smtp-Source: ABdhPJyyk1a9A4dF+jF++NTAGKcmDAEFkg+LKnFi+FHWIYuXkBFjIHVrtAUNNc+tQhYddkk/W8JbJg== X-Received: by 2002:a62:83ca:0:b029:1ed:78d1:531a with SMTP id h193-20020a6283ca0000b02901ed78d1531amr15767699pfe.56.1614123322159; Tue, 23 Feb 2021 15:35:22 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:21 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Subject: [PATCH v6 05/16] remoteproc: Add new get_loaded_rsc_table() to rproc_ops Date: Tue, 23 Feb 2021 16:35:04 -0700 Message-Id: <20210223233515.3468677-6-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_183524_302705_87289986 X-CRM114-Status: GOOD ( 20.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a new get_loaded_rsc_table() operation in order to support scenarios where the remoteproc core has booted a remote processor and detaches from it. When re-attaching to the remote processor, the core needs to know where the resource table has been placed in memory. Signed-off-by: Mathieu Poirier Reviewed-by: Arnaud Pouliquen --- New for V6: - Don't return an error if a resource table doesn't exist. --- drivers/remoteproc/remoteproc_core.c | 32 ++++++++++++++++++++++++ drivers/remoteproc/remoteproc_internal.h | 10 ++++++++ include/linux/remoteproc.h | 6 ++++- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 8c7e9f1d50d7..0012b7bdce24 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1537,6 +1537,32 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) return ret; } +static int rproc_set_loaded_rsc_table(struct rproc *rproc) +{ + struct resource_table *table_ptr; + struct device *dev = &rproc->dev; + size_t table_sz; + int ret; + + table_ptr = rproc_get_loaded_rsc_table(rproc, &table_sz); + if (!table_ptr) { + /* Not having a resource table is acceptable */ + return 0; + } + + if (IS_ERR(table_ptr)) { + ret = PTR_ERR(table_ptr); + dev_err(dev, "can't load resource table: %d\n", ret); + return ret; + } + + rproc->cached_table = NULL; + rproc->table_ptr = table_ptr; + rproc->table_sz = table_sz; + + return 0; +} + /* * Attach to remote processor - similar to rproc_fw_boot() but without * the steps that deal with the firmware image. @@ -1556,6 +1582,12 @@ static int rproc_attach(struct rproc *rproc) return ret; } + ret = rproc_set_loaded_rsc_table(rproc); + if (ret) { + dev_err(dev, "can't load resource table: %d\n", ret); + goto disable_iommu; + } + /* reset max_notifyid */ rproc->max_notifyid = -1; diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index c34002888d2c..4f73aac7e60d 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -177,6 +177,16 @@ struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, return NULL; } +static inline +struct resource_table *rproc_get_loaded_rsc_table(struct rproc *rproc, + size_t *size) +{ + if (rproc->ops->get_loaded_rsc_table) + return rproc->ops->get_loaded_rsc_table(rproc, size); + + return NULL; +} + static inline bool rproc_u64_fit_in_size_t(u64 val) { diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 6b0a0ed30a03..51538a7d120d 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -368,7 +368,9 @@ enum rsc_handling_status { * RSC_HANDLED if resource was handled, RSC_IGNORED if not handled and a * negative value on error * @load_rsc_table: load resource table from firmware image - * @find_loaded_rsc_table: find the loaded resouce table + * @find_loaded_rsc_table: find the loaded resource table from firmware image + * @get_loaded_rsc_table: get resource table installed in memory + * by external entity * @load: load firmware to memory, where the remote processor * expects to find it * @sanity_check: sanity check the fw image @@ -390,6 +392,8 @@ struct rproc_ops { int offset, int avail); struct resource_table *(*find_loaded_rsc_table)( struct rproc *rproc, const struct firmware *fw); + struct resource_table *(*get_loaded_rsc_table)( + struct rproc *rproc, size_t *size); int (*load)(struct rproc *rproc, const struct firmware *fw); int (*sanity_check)(struct rproc *rproc, const struct firmware *fw); u64 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw); From patchwork Tue Feb 23 23:35:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101069 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=-13.9 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, UNWANTED_LANGUAGE_BODY,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 80C37C433DB for ; Tue, 23 Feb 2021 23:37:26 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 3A0EF64F7B for ; Tue, 23 Feb 2021 23:37:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A0EF64F7B 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=merlin.20170209; 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=XW81533OLPkBB0hB1VF6IoilLR085ppu54jQ7a2CPPk=; b=GPnfKRaM2XjBHh46dBtRpMfzJ fzt38gF5oBwpI8MlgWVMpcwOZOgvCvwSjp9t4wVADGtEeC0UZK2MuqYhrTYBN23RvH1uF1U/HG4+P fT4DTLR0cD3mtjSROoWiZ822oxdoBNnfT4jmVb1ECcjTsYfmRtkWbu6YMAZaVWaWkXvx9C6ME+zCZ GtDhqYzOs6qQOzt65b+RdHFY+VMOhPVhC33PCUL1YVnYc0Rcyq0Jk67zBfiTVDnd/O+B3EMVgJQYg CZdyrgAOSwXevfWqbI4rQYhK/pLk+40/X4SNRdicjhHV0A6utg+959XM6cAOHBNPM4RHqYijwBwCU WIy6s29lg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDb-0003am-Vp; Tue, 23 Feb 2021 23:35:52 +0000 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDB-0003T8-Ai for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:26 +0000 Received: by mail-pg1-x52a.google.com with SMTP id e6so226408pgk.5 for ; Tue, 23 Feb 2021 15:35:24 -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=kLNVNgyYcxdqJmRqLa5XNmkFnVZ2anTxOTUhUAuTSOQ=; b=brMDm+YrllAIy0EMAf2YORgbS5YJdVihgVpAn6zkEHPcvFsvCLQbdW4rUSoPnXSvQz fKWAflTzrm0ayYjtPn7Wy4VR/HpOqdEMBi96b25w0OYij6xf4HxcFvlB2ecfCLq/0OD2 DRIrKrm9U6pn0o2UwM0OYDuKZ8rrxZ7PQHEBf2ft/91VsCA5GerXag0jXc6tuK0m3pT3 ROA/3aNyTah8Hy6uxzh1RstKCxez0E6YFbY02KsvkKMtjZEeXJ6NQtO0u8bJuSNgQd8i QLalzEj82IkAmZ4/PPXp4yw0OoVwNPsic7z5Jp0wcec10stReoI5zKlkbAyk6dnhJ+xc Iwjw== 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=kLNVNgyYcxdqJmRqLa5XNmkFnVZ2anTxOTUhUAuTSOQ=; b=J5TXTUO3MDrx0BcsFgopticHSSfen2ayY+czytCpmehBGtSSdbaP/4wPR1mAurvx5o HKsHahwHunhKxdQMWr1w50ogGE4acQIn5MgKSrmm8vJGPGfWlp9R3YQ9dxzXTi8sRpSW ZHw5n2fuj0UgywB3eBsqsKmdRTy6L5VlK+jeoaQse/DMMFY5e1Ik549X5MJTWdiZL+ls ik8cWyv8ydeu31hfuD2m0oZW8n3Bv3bAax5VWr9YoWKHVf5zI5dhuJ5ShXDsbbGIzIHo mIBqQAf8uU07NIsBJo0M3XoXJFBkjHKyT+BKFKlZ/WWdD5XUIFhHCdR348FcTa7NNoLJ pL3A== X-Gm-Message-State: AOAM533rHkR4vHS7O5j3oMPkv3gDn65DhekMGgAmcpLOUcq9+qSxfLxF YVw+Uwy0o+uUovm+yVbSDq4ueQ== X-Google-Smtp-Source: ABdhPJzLh6US6rt9m7pZ8huuEAD0RCT4PheA0LVI/f4wFIQe7O3OYnMp8zOgP60N3RG7mEEl91uYfw== X-Received: by 2002:a63:5a02:: with SMTP id o2mr15912066pgb.202.1614123323178; Tue, 23 Feb 2021 15:35:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:22 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Subject: [PATCH v6 06/16] remoteproc: stm32: Move resource table setup to rproc_ops Date: Tue, 23 Feb 2021 16:35:05 -0700 Message-Id: <20210223233515.3468677-7-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_183525_432306_29980278 X-CRM114-Status: GOOD ( 22.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move the setting of the resource table installed by an external entity to rproc_ops::get_loaded_rsc_table(). This is to support scenarios where a remote processor has been started by the core but is detached at a later stage. To re-attach the remote processor, the address of the resource table needs to be available at a later time than the platform driver's probe() function. Signed-off-by: Mathieu Poirier Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/stm32_rproc.c | 141 +++++++++++++++---------------- 1 file changed, 68 insertions(+), 73 deletions(-) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index ccb3c14a0023..f647e565014b 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -546,6 +546,73 @@ static void stm32_rproc_kick(struct rproc *rproc, int vqid) } } +static int stm32_rproc_da_to_pa(struct rproc *rproc, + u64 da, phys_addr_t *pa) +{ + struct stm32_rproc *ddata = rproc->priv; + struct device *dev = rproc->dev.parent; + struct stm32_rproc_mem *p_mem; + unsigned int i; + + for (i = 0; i < ddata->nb_rmems; i++) { + p_mem = &ddata->rmems[i]; + + if (da < p_mem->dev_addr || + da >= p_mem->dev_addr + p_mem->size) + continue; + + *pa = da - p_mem->dev_addr + p_mem->bus_addr; + dev_dbg(dev, "da %llx to pa %#x\n", da, *pa); + + return 0; + } + + dev_err(dev, "can't translate da %llx\n", da); + + return -EINVAL; +} + +static struct resource_table * +stm32_rproc_get_loaded_rsc_table(struct rproc *rproc, size_t *table_sz) +{ + struct stm32_rproc *ddata = rproc->priv; + struct device *dev = rproc->dev.parent; + phys_addr_t rsc_pa; + u32 rsc_da; + int err; + + /* The resource table has already been mapped, nothing to do */ + if (ddata->rsc_va) + goto done; + + err = regmap_read(ddata->rsctbl.map, ddata->rsctbl.reg, &rsc_da); + if (err) { + dev_err(dev, "failed to read rsc tbl addr\n"); + return ERR_PTR(-EINVAL); + } + + if (!rsc_da) + /* no rsc table */ + return ERR_PTR(-ENOENT); + + err = stm32_rproc_da_to_pa(rproc, rsc_da, &rsc_pa); + if (err) + return ERR_PTR(err); + + ddata->rsc_va = devm_ioremap_wc(dev, rsc_pa, RSC_TBL_SIZE); + if (IS_ERR_OR_NULL(ddata->rsc_va)) { + dev_err(dev, "Unable to map memory region: %pa+%zx\n", + &rsc_pa, RSC_TBL_SIZE); + ddata->rsc_va = NULL; + return ERR_PTR(-ENOMEM); + } + +done: + /* Assuming the resource table fits in 1kB is fair */ + *table_sz = RSC_TBL_SIZE; + return (struct resource_table *)ddata->rsc_va; +} + static const struct rproc_ops st_rproc_ops = { .start = stm32_rproc_start, .stop = stm32_rproc_stop, @@ -554,6 +621,7 @@ static const struct rproc_ops st_rproc_ops = { .load = rproc_elf_load_segments, .parse_fw = stm32_rproc_parse_fw, .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table, + .get_loaded_rsc_table = stm32_rproc_get_loaded_rsc_table, .sanity_check = rproc_elf_sanity_check, .get_boot_addr = rproc_elf_get_boot_addr, }; @@ -695,75 +763,6 @@ static int stm32_rproc_get_m4_status(struct stm32_rproc *ddata, return regmap_read(ddata->m4_state.map, ddata->m4_state.reg, state); } -static int stm32_rproc_da_to_pa(struct platform_device *pdev, - struct stm32_rproc *ddata, - u64 da, phys_addr_t *pa) -{ - struct device *dev = &pdev->dev; - struct stm32_rproc_mem *p_mem; - unsigned int i; - - for (i = 0; i < ddata->nb_rmems; i++) { - p_mem = &ddata->rmems[i]; - - if (da < p_mem->dev_addr || - da >= p_mem->dev_addr + p_mem->size) - continue; - - *pa = da - p_mem->dev_addr + p_mem->bus_addr; - dev_dbg(dev, "da %llx to pa %#x\n", da, *pa); - - return 0; - } - - dev_err(dev, "can't translate da %llx\n", da); - - return -EINVAL; -} - -static int stm32_rproc_get_loaded_rsc_table(struct platform_device *pdev, - struct rproc *rproc, - struct stm32_rproc *ddata) -{ - struct device *dev = &pdev->dev; - phys_addr_t rsc_pa; - u32 rsc_da; - int err; - - err = regmap_read(ddata->rsctbl.map, ddata->rsctbl.reg, &rsc_da); - if (err) { - dev_err(dev, "failed to read rsc tbl addr\n"); - return err; - } - - if (!rsc_da) - /* no rsc table */ - return 0; - - err = stm32_rproc_da_to_pa(pdev, ddata, rsc_da, &rsc_pa); - if (err) - return err; - - ddata->rsc_va = devm_ioremap_wc(dev, rsc_pa, RSC_TBL_SIZE); - if (IS_ERR_OR_NULL(ddata->rsc_va)) { - dev_err(dev, "Unable to map memory region: %pa+%zx\n", - &rsc_pa, RSC_TBL_SIZE); - ddata->rsc_va = NULL; - return -ENOMEM; - } - - /* - * The resource table is already loaded in device memory, no need - * to work with a cached table. - */ - rproc->cached_table = NULL; - /* Assuming the resource table fits in 1kB is fair */ - rproc->table_sz = RSC_TBL_SIZE; - rproc->table_ptr = (struct resource_table *)ddata->rsc_va; - - return 0; -} - static int stm32_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -803,10 +802,6 @@ static int stm32_rproc_probe(struct platform_device *pdev) ret = stm32_rproc_parse_memory_regions(rproc); if (ret) goto free_resources; - - ret = stm32_rproc_get_loaded_rsc_table(pdev, rproc, ddata); - if (ret) - goto free_resources; } rproc->has_iommu = false; From patchwork Tue Feb 23 23:35:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101071 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=-16.8 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 C56C8C433E6 for ; Tue, 23 Feb 2021 23:37:28 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 7A21364F88 for ; Tue, 23 Feb 2021 23:37:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A21364F88 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=merlin.20170209; 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=SukWCK/tMDVx+aQWVS0BJVCXKfXPLQojzewJG7L7ZCw=; b=G6wus/cCZ55OjtQplVhFrj0F1 b49CHgzHfFN2slJ2IfdaFS1i2lHzDNNnvWoi4mRkMjyy8QqOVJTx0OO6fw7TJxzyynQT5AzRMOJrv 6eYYv/u8FaYq0Ay7eTKlmYoVDm/fcwqt8abAwgvf/7Q1FNhAyWFtRyzFAykiz2JyNb11gulhCJiB6 Ws33wdQCSq0WRZx9cDzjhWzoVER1r4fxm9we17sTIFd/fFAQ/KACQPYPKCciSbgfWZbnjjH4mwwcJ nN/2TtBDvYyuflTBbVUdjl/FeLsfxGBlxRBLydbWlmAAgW+sKwpH8fkx9W9OKuPxUy9+iTPZz9utM C4HYt5HvA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDe-0003be-QX; Tue, 23 Feb 2021 23:35:54 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDC-0003Th-9D for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:27 +0000 Received: by mail-pf1-x434.google.com with SMTP id j24so65072pfi.2 for ; Tue, 23 Feb 2021 15:35:26 -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=1mq+57Jm1O/SI3Ar3tu9qAzNfEq1LOaTZvnWBe70UXM=; b=bDJYJ+uV0Y04uJLxLFoIFN9hEMwMonS1oWOlTmnQqGcIyW0bNmXWD99NKXjc+uk9Vi RPA9/LYA/tvFwNmU1U2kfLib8j620t4Km3L46Z+FOb1oX1k6UGBdBGRABT2cLX5t30St ECgz87UpRuSuCz6Agk+mhJHAXagn1RhM8DWsaczmG0hirydKd3lKTWm7UcA8W7t6J6LH tNDH3/UF7ChMV1VanK6YbidZ4cdtGOhT6xM/RUZzxHzM3Hc3JaYflUAnHdMCKkyCOtmd 9RUgwbz3AcAdAOXDn7dWNpzrVJ5JIx365MyT2ovwaHgY6lcjyTXg+dSbB3q51tPtSa3+ hsEw== 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=1mq+57Jm1O/SI3Ar3tu9qAzNfEq1LOaTZvnWBe70UXM=; b=jaekyvntK3ROLgDvCumML0IYWnM+sNP2qsIOZYkSMPg7WkZFh+r23hb6GluSjJzyEu dzysa+Ocnnkc3A8PA03sMMttEkAn5+T3D6AxLY5+cDeSV90o/OGZu1ct0N3Rl9CBORzP b6T2lShITkuv1W6i95z/zJnd9AKmrah8pR+e0MP869ZdFpxjCLLhCfoZ2Z5iCKTvQjBg Nb2qgkjQbBphsr5l8O0tLwFVGGZCyk7eFwqwo9ouVfSX39UIIH7KF3s+RMoe6x0O5+3D wIXAVUH9B/Q80E2+Ihi5mdwgQ413fsPN/lMW++1pjjpGSJJLW4sBslJ0+D8diECMnsa7 H2ag== X-Gm-Message-State: AOAM531vbxL2ewOXOSJ6Dh8zWh/9Fbl7UJxw9q1v93V67qD2lj68DB4x HNhZH3ZIPgOb5T7zgUjUzj0UTQ== X-Google-Smtp-Source: ABdhPJwSwMYbGtLEjvvq6ULUpR1HJGxWJcpn79Lb+4Chp/PQ2GsxIschv1R7KaMoGDC9nq4q0Z+Mag== X-Received: by 2002:a62:5a45:0:b029:1e5:4c81:c59 with SMTP id o66-20020a625a450000b02901e54c810c59mr29105018pfb.51.1614123324584; Tue, 23 Feb 2021 15:35:24 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:23 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Subject: [PATCH v6 07/16] remoteproc: stm32: Move memory parsing to rproc_ops Date: Tue, 23 Feb 2021 16:35:06 -0700 Message-Id: <20210223233515.3468677-8-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_183526_439412_67F1F771 X-CRM114-Status: GOOD ( 18.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Arnaud POULIQUEN Some actions such as memory resources reallocation are needed when trying to reattach a co-processor. Use the prepare() operation for these actions. Co-developed-by: Mathieu Poirier Signed-off-by: Mathieu Poirier Signed-off-by: Arnaud POULIQUEN --- drivers/remoteproc/remoteproc_core.c | 14 ++++++++++++-- drivers/remoteproc/stm32_rproc.c | 27 ++++++--------------------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 0012b7bdce24..86572880c726 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1582,10 +1582,17 @@ static int rproc_attach(struct rproc *rproc) return ret; } + /* Do anything that is needed to boot the remote processor */ + ret = rproc_prepare_device(rproc); + if (ret) { + dev_err(dev, "can't prepare rproc %s: %d\n", rproc->name, ret); + goto disable_iommu; + } + ret = rproc_set_loaded_rsc_table(rproc); if (ret) { dev_err(dev, "can't load resource table: %d\n", ret); - goto disable_iommu; + goto unprepare_device; } /* reset max_notifyid */ @@ -1602,7 +1609,7 @@ static int rproc_attach(struct rproc *rproc) ret = rproc_handle_resources(rproc, rproc_loading_handlers); if (ret) { dev_err(dev, "Failed to process resources: %d\n", ret); - goto disable_iommu; + goto unprepare_device; } /* Allocate carveout resources associated to rproc */ @@ -1621,6 +1628,9 @@ static int rproc_attach(struct rproc *rproc) clean_up_resources: rproc_resource_cleanup(rproc); +unprepare_device: + /* release HW resources if needed */ + rproc_unprepare_device(rproc); disable_iommu: rproc_disable_iommu(rproc); return ret; diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index f647e565014b..3d45f51de4d0 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -207,16 +207,7 @@ static int stm32_rproc_mbox_idx(struct rproc *rproc, const unsigned char *name) return -EINVAL; } -static int stm32_rproc_elf_load_rsc_table(struct rproc *rproc, - const struct firmware *fw) -{ - if (rproc_elf_load_rsc_table(rproc, fw)) - dev_warn(&rproc->dev, "no resource table found for this firmware\n"); - - return 0; -} - -static int stm32_rproc_parse_memory_regions(struct rproc *rproc) +static int stm32_rproc_prepare(struct rproc *rproc) { struct device *dev = rproc->dev.parent; struct device_node *np = dev->of_node; @@ -274,12 +265,10 @@ static int stm32_rproc_parse_memory_regions(struct rproc *rproc) static int stm32_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw) { - int ret = stm32_rproc_parse_memory_regions(rproc); - - if (ret) - return ret; + if (rproc_elf_load_rsc_table(rproc, fw)) + dev_warn(&rproc->dev, "no resource table found for this firmware\n"); - return stm32_rproc_elf_load_rsc_table(rproc, fw); + return 0; } static irqreturn_t stm32_rproc_wdg(int irq, void *data) @@ -614,6 +603,7 @@ stm32_rproc_get_loaded_rsc_table(struct rproc *rproc, size_t *table_sz) } static const struct rproc_ops st_rproc_ops = { + .prepare = stm32_rproc_prepare, .start = stm32_rproc_start, .stop = stm32_rproc_stop, .attach = stm32_rproc_attach, @@ -796,14 +786,9 @@ static int stm32_rproc_probe(struct platform_device *pdev) if (ret) goto free_rproc; - if (state == M4_STATE_CRUN) { + if (state == M4_STATE_CRUN) rproc->state = RPROC_DETACHED; - ret = stm32_rproc_parse_memory_regions(rproc); - if (ret) - goto free_resources; - } - rproc->has_iommu = false; ddata->workqueue = create_workqueue(dev_name(dev)); if (!ddata->workqueue) { From patchwork Tue Feb 23 23:35:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101073 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=-16.8 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 C6FC9C433E9 for ; Tue, 23 Feb 2021 23:37:28 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 7A11564F82 for ; Tue, 23 Feb 2021 23:37:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A11564F82 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=merlin.20170209; 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=CzMzcgDaUMkUJnLc49ucteeFquGTfjxd5Xux9YG6up4=; b=A6KReXMx2R2FXKfVugVuNWCo5 dej8EB3l0gAJRPRCj2iNUUsswyYQVDF9pCQYVDY6S35BrQV95wDQO+EhPNqshXaXDo1jJwHOT/r/9 1eBfVUT695kOjjqzaz/JuZhq8RvbS49C0tZkGtfQuyFfIUgr8HeDkrH1EekdfZHjepuxmWQu24XIp 0zNsX+to2XwXcRe9OmF898S+1jAIibYG2zFDBX7dJyR3oXR6mQVwch2l4eK/RwCL3l0yQDNOuuoqD aWp5J4fNNnTVXm+azsop7ZQERsKoBZEl/XlmwlpU02GbCw8sR9m1hjnMfcUVO2KVi1uDrBCqe9u/v aymgcqp5A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDk-0003d7-1b; Tue, 23 Feb 2021 23:36:00 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDE-0003UJ-8q for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:29 +0000 Received: by mail-pf1-x429.google.com with SMTP id j24so65101pfi.2 for ; Tue, 23 Feb 2021 15:35:27 -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=XYqKe5JHKTsf6qqgvmLT8SEOr6JSbsFQUrC6la75+Tk=; b=MVV3vhm//Qy9ZrlCKMb16NdKTMroR2imuUkINcRxjjux/bl+uLuSLPbpRD1+1mGIZ2 /+sbA0DrgyiBvh1ce7jR11k4/prDQABZEu8ZLl3253su/2GxBM+oPNcmyeOpwTYRE+7z +rEw6KT7cYrDATX1TD0OrKkoCUkaxwMFoCtsF8rAZqLVI00FRRM7Smxj+VDWVRSjMIV3 OThZC45qFdxVv2NFrY+eZC93qdE+bRPGGmbzveBgWmpKZ2ubGAN8sVI9cO3knHgUkDs5 DIp1kZYv0d42wEBFiWsihBdlBZHobFfXoZup1cI+LlhkMqK7Dncr90uKVhwBfkAxZDjG Lq9Q== 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=XYqKe5JHKTsf6qqgvmLT8SEOr6JSbsFQUrC6la75+Tk=; b=isVTdAY/+74sDWjc//fDbaaJBFcOljBQpP2bdvfiCGYBE1nh727vqAiZ0Zv4L+/BzZ +RPZZPUcvKTpcCqbwpj4y97bDkR9BXK3JxNvHctEaB0q/DMGH/s3MkXs9vlpXgHuOaNF ZmizwPjHRLgVRdHzhliRap16fqKt42O4+efP2PhX6oKbC87hhZewSR8QYRd8Mi10WTnN I27KX1il2bLOwOakmDG5dDtjGjqAT/8QlGiFShy5ckCyDuFr7UCDn1Nhw/pIo98JraRh x5BCh3s6bMNfQRiB+U0sLlxffSwsBJ7W7jwt3pqHTPxNCBjrd9nS8LjrfgP24GtnAvZ3 UtwA== X-Gm-Message-State: AOAM530YmP0eLQ11YFKmQFII/caw6SeJdzQozbzYwy+J3rW4kz+RBEzp btwlZS+z/QV2glqnwKr80F87lA== X-Google-Smtp-Source: ABdhPJznFf7DZqYNrPiOXAMW7oDr5knTQMa3p2jpXOrDYXjPzd9l0Vi8c8/FZ3GcjCq+M+pXBqRevg== X-Received: by 2002:a63:fc1c:: with SMTP id j28mr26149581pgi.281.1614123326234; Tue, 23 Feb 2021 15:35:26 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:25 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Subject: [PATCH v6 08/16] remoteproc: Add new detach() remoteproc operation Date: Tue, 23 Feb 2021 16:35:07 -0700 Message-Id: <20210223233515.3468677-9-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_183528_453689_008CF7BF X-CRM114-Status: GOOD ( 15.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add an new detach() operation in order to support scenarios where the remoteproc core is going away but the remote processor is kept operating. This could be the case when the system is rebooted or when the platform driver is removed. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- include/linux/remoteproc.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 51538a7d120d..eff55ec72e80 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -361,6 +361,7 @@ enum rsc_handling_status { * @start: power on the device and boot it * @stop: power off the device * @attach: attach to a device that his already powered up + * @detach: detach from a device, leaving it powered up * @kick: kick a virtqueue (virtqueue id given as a parameter) * @da_to_va: optional platform hook to perform address translations * @parse_fw: parse firmware to extract information (e.g. resource table) @@ -385,6 +386,7 @@ struct rproc_ops { int (*start)(struct rproc *rproc); int (*stop)(struct rproc *rproc); int (*attach)(struct rproc *rproc); + int (*detach)(struct rproc *rproc); void (*kick)(struct rproc *rproc, int vqid); void * (*da_to_va)(struct rproc *rproc, u64 da, size_t len); int (*parse_fw)(struct rproc *rproc, const struct firmware *fw); From patchwork Tue Feb 23 23:35:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101075 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=-16.8 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 91D56C433DB for ; Tue, 23 Feb 2021 23:37:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 5577D64FAE for ; Tue, 23 Feb 2021 23:37:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5577D64FAE 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=merlin.20170209; 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=HFPkm+ZZIuWV7HbavQ24bos7Xf2SiwyMQ1/5vkGs8/U=; b=LuxjBe4Pq3CE0cXaLJBXMrjxu M5/wU5ueTUhRN0IGsO0ZYUDyxHObDh7BhIRNtQZgWe/z1LybizbT0jHSa7tE9W2aBDXbzTI9nKVs/ lB2cM5elXDbtJSNNPNOi+lqEZ7I5s8G3+fZ4nLQuUEgH1tb0fmnJM20DK6FR9Xt7youjnpUZjVibc JoeKeL13bqNAl3uiFjIOue97hA2xrgC+jcCVK6aZRhiijVy6dyDg4ATWMtvpbfgWvVpNG3+AkBdtx JqMF+V1QeYDIBIE/4zHsZGPIvT9tVVhE/MsbLBbF4X48qf6HJpL8F1aXyFnUVQ826fWDwCm7ysVhf B/Dj6lgWg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDr-0003fE-7Z; Tue, 23 Feb 2021 23:36:07 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDF-0003US-5f for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:30 +0000 Received: by mail-pf1-x42c.google.com with SMTP id j24so65122pfi.2 for ; Tue, 23 Feb 2021 15:35:28 -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=ZQJKNkYdJD+3H3cXZ1fnXW9mmfT2GDRPmw5t76E+z4s=; b=ttJfPAO38DPwRk7QDxMpxEP4AkrTQ+bdqW821L2JbyNrPr+ztnhUsH9KLuRItEmDtw wjQCHPOaFFLXndgzQnwNsBRWQjbE7Nkv3yYhyyPiKSUF4zrOkf81EB7HH/CVMNKLReOl 40lPa9a7imYaNlA0rnzPsIxBHz9UH15WkcvPepLH//K3qI2oqRpyv+7m/k2trU8fH2hQ nCa+l/PeuYtT9ao0c9zxmD1+rbke6+GR9K6hp4Sg8uRsgpQCH/ava+wbb6iKyBePKvfY UbrZyzFTq9u9hpTsiLWuG/HWgK8cSyKRcwltNqNB6pOAUHD0w8vNeGX2ClFMu//8RtR/ V/0A== 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=ZQJKNkYdJD+3H3cXZ1fnXW9mmfT2GDRPmw5t76E+z4s=; b=s6dF+3VkajfSyUAezK/i+bd3pvj2vKtIdt8XpTl/9SwzSnPOOYiSv4QTCaovk0eihw L6dgz6luc+nfOyfcJSyNI3+NLIxW/26+s06rM/U1zzDtsz3DFVk/kv9dr7+zt7qU5VOT GjwxY9HlogD7cOqX5tvgYeKcOx7Kns7Y9ZFiPWMjmnNWQghWDC6nku9iqwHyf3QGjVAS 0a1HtU2gkynedJkTqK8Spoz1Z1dilKjrttzPAUoZFUXV1D3HKec6uaqjXQNIPgsq2ss7 cGdrCt5feQnItlC5jXh17QLdTYjutOZ2lhTx6iCx4iLLDtQ/vIfJi2hs7WPKLRmeV3UW 5cAQ== X-Gm-Message-State: AOAM5331sIztnMMjctR6TlYawNGSUeJiAWHcr2I190vP9/WA1iQoHbqV jVYyD7gKI9L8TWchhKKt9Zu9MA== X-Google-Smtp-Source: ABdhPJyEhqRX/KZWWyw75LLa3g9cesvmVpn7ESbIlO+bDp+Sw/fJGi8whC21vuhA6iI2rCtr8TkLzg== X-Received: by 2002:a05:6a00:9d:b029:1ed:c1d6:5042 with SMTP id c29-20020a056a00009db02901edc1d65042mr8009649pfj.71.1614123327093; Tue, 23 Feb 2021 15:35:27 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:26 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Subject: [PATCH v6 09/16] remoteproc: Introduce function __rproc_detach() Date: Tue, 23 Feb 2021 16:35:08 -0700 Message-Id: <20210223233515.3468677-10-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_183529_280380_01BB8184 X-CRM114-Status: GOOD ( 17.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Introduce function __rproc_detach() to perform the same kind of operation as rproc_stop(), but instead of switching off the remote processor using rproc->ops->stop(), it uses rproc->ops->detach(). That way it is possible for the core to release the resources associated with a remote processor while the latter is kept operating. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 86572880c726..0f680b7ff8f1 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1706,6 +1706,36 @@ static int rproc_stop(struct rproc *rproc, bool crashed) return 0; } +/* + * __rproc_detach(): Does the opposite of __rproc_attach() + */ +static int __maybe_unused __rproc_detach(struct rproc *rproc) +{ + struct device *dev = &rproc->dev; + int ret; + + /* No need to continue if a detach() operation has not been provided */ + if (!rproc->ops->detach) + return -EINVAL; + + /* Stop any subdevices for the remote processor */ + rproc_stop_subdevices(rproc, false); + + /* Tell the remote processor the core isn't available anymore */ + ret = rproc->ops->detach(rproc); + if (ret) { + dev_err(dev, "can't detach from rproc: %d\n", ret); + return ret; + } + + rproc_unprepare_subdevices(rproc); + + rproc->state = RPROC_DETACHED; + + dev_info(dev, "detached remote processor %s\n", rproc->name); + + return 0; +} /** * rproc_trigger_recovery() - recover a remoteproc From patchwork Tue Feb 23 23:35:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101077 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=-16.8 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 528E7C433DB for ; Tue, 23 Feb 2021 23:38:04 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 DF8D764FBE for ; Tue, 23 Feb 2021 23:38:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF8D764FBE 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=merlin.20170209; 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=x9pN1FZ/QyZ4zJ4ZuoIPJy6xxDbsC88evNd32p+SUKc=; b=wU9aiFPUNSDwxd6Mb7yzpygBr d2pLYLxE2ZUaVHA9Or5YQaQzfAgPCW6UDftO5Ge1Zm4zkD/7htlBr8G/dqcQB3Gl3Lwd4E9yN6Dib QUPtY+54eoaGIq6QjrCfwtv2STM3AEUYlrM0ej7j8HlLJKfDecJc1SpwMiv701Ovov3ujds9qpYRy wHXmoEgBjY8FgXncx+oMC4au6F5mYY4ycTsge4QXhsjYCnmzmG+Z76ZBrxpL6J6zugPd4uhF9Hf1i G2quUPxGD7cvdLc63zZcrjXdFrdLe2lNf/C/r5wFeAbLhWknBxY/TkKkLcZn3awzCG/T/fk7RTdKO hVhNkjTVg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDx-0003i4-K6; Tue, 23 Feb 2021 23:36:13 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDG-0003Uk-4s for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:32 +0000 Received: by mail-pf1-x42d.google.com with SMTP id j24so65143pfi.2 for ; Tue, 23 Feb 2021 15:35:29 -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=GF5EQHFlmp0+qmUZul6iVpKZ4h0RkwOCQenPoUGAdoc=; b=JXFzabmRKJ8V0T+o9nOAxWVsuMgdr+B8uaPJVlbvmPmcxc8D6urjBQYMXSW2PwklpB bLKPh91Z/GF+3TG31+OpZ+cASxREnq6WnPHRCUV1ycXtwqyrWBImOtrXS5ynLbt2vBsM HOPj48ofMMoFkxHSPjERWm8vGjs97SXvNzKBva13fVqzcrx6emz4c9e9nOxtvyKkXbDn UI/EXGCm5L3V/ZnYJZvvjUVSgdUy99W4qBIzXOCwMgryXYPjgb5oUt/IiRB3+74VMUMg SkY0NYoGrq1zLG0Y9ooK6VlJMJD4YkNiMgngT0hXE5T8g+hR9wjGZsWWCI8fFSqOAkNe ansg== 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=GF5EQHFlmp0+qmUZul6iVpKZ4h0RkwOCQenPoUGAdoc=; b=J0vCV5ey4jXyvMuxf8MRjXovEU2G/wEgaQjDEepFr4JvBWIIHsokaq3NWEQ6miCIfV ETamdoGNvTK8V4waFCQ5uB+K6qB/JV6pV0fDps6f9/B8nuEd2IXYTzrPuUa8ECIg98DA 383gynFQs2MUwEY/phBq2j4mqeGtLkr1e82wq3mSFSMHxMwuowoHZDDYooG4i3U2agxd t1xFwNOGTNUvl4XxluVYe3bckr3gZuCG9kZ9emkTKTclx21rxtYcb++dWmMg5UQ4mubE G6MTy+MbNCzalz2i/KrkEZxmjyMVhMhkUVi7fXUupyUTZYi6sU21MAxu9c6cQnoA/Lh9 /w5g== X-Gm-Message-State: AOAM531L0/8JHfq7VZNS6s0avSuoqGrWG677iozoakX7fd1ZvBTnVib1 TaZaAgLPT2U+zTYam5+r4srlFg== X-Google-Smtp-Source: ABdhPJz42IAXFy40S62cYn6Imjzfoc1xcaOkTJIhpRstco5Pcq5ISsfYuxsdM4Ul6ZKyAulxaa/GhA== X-Received: by 2002:a65:6205:: with SMTP id d5mr4569749pgv.40.1614123327949; Tue, 23 Feb 2021 15:35:27 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:27 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Subject: [PATCH v6 10/16] remoteproc: Introduce function rproc_detach() Date: Tue, 23 Feb 2021 16:35:09 -0700 Message-Id: <20210223233515.3468677-11-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_183530_313063_3BADD288 X-CRM114-Status: GOOD ( 20.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Introduce function rproc_detach() to enable the remoteproc core to release the resources associated with a remote processor without stopping its operation. Signed-off-by: Mathieu Poirier Reviewed-by: Arnaud Pouliquen --- New for V6: - Checking for rproc->state has been removed. They have been moved to calling functions. - Freeing the cache table has been moved to the next patch, i.e 11/16. --- drivers/remoteproc/remoteproc_core.c | 58 +++++++++++++++++++++++++++- include/linux/remoteproc.h | 1 + 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 0f680b7ff8f1..fc01b29290a6 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1709,7 +1709,7 @@ static int rproc_stop(struct rproc *rproc, bool crashed) /* * __rproc_detach(): Does the opposite of __rproc_attach() */ -static int __maybe_unused __rproc_detach(struct rproc *rproc) +static int __rproc_detach(struct rproc *rproc) { struct device *dev = &rproc->dev; int ret; @@ -1948,6 +1948,62 @@ void rproc_shutdown(struct rproc *rproc) } EXPORT_SYMBOL(rproc_shutdown); +/** + * rproc_detach() - Detach the remote processor from the + * remoteproc core + * + * @rproc: the remote processor + * + * Detach a remote processor (previously attached to with rproc_attach()). + * + * In case @rproc is still being used by an additional user(s), then + * this function will just decrement the power refcount and exit, + * without disconnecting the device. + * + * Function rproc_detach() calls __rproc_detach() in order to let a remote + * processor know that services provided by the application processor are + * no longer available. From there it should be possible to remove the + * platform driver and even power cycle the application processor (if the HW + * supports it) without needing to switch off the remote processor. + */ +int rproc_detach(struct rproc *rproc) +{ + struct device *dev = &rproc->dev; + int ret; + + ret = mutex_lock_interruptible(&rproc->lock); + if (ret) { + dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, ret); + return ret; + } + + /* if the remote proc is still needed, bail out */ + if (!atomic_dec_and_test(&rproc->power)) { + ret = 0; + goto out; + } + + ret = __rproc_detach(rproc); + if (ret) { + atomic_inc(&rproc->power); + goto out; + } + + /* clean up all acquired resources */ + rproc_resource_cleanup(rproc); + + /* release HW resources if needed */ + rproc_unprepare_device(rproc); + + rproc_disable_iommu(rproc); + + rproc->table_ptr = NULL; +out: + mutex_unlock(&rproc->lock); + return ret; +} +EXPORT_SYMBOL(rproc_detach); + /** * rproc_get_by_phandle() - find a remote processor by phandle * @phandle: phandle to the rproc diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index eff55ec72e80..e1c843c19cc6 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -662,6 +662,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, size_t len, int rproc_boot(struct rproc *rproc); void rproc_shutdown(struct rproc *rproc); +int rproc_detach(struct rproc *rproc); int rproc_set_firmware(struct rproc *rproc, const char *fw_name); void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); void rproc_coredump_using_sections(struct rproc *rproc); From patchwork Tue Feb 23 23:35:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101079 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=-16.8 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 C2AE9C433E0 for ; Tue, 23 Feb 2021 23:38:05 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 836E664FBE for ; Tue, 23 Feb 2021 23:38:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 836E664FBE 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=merlin.20170209; 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=xBHXlbNF7W3exBJeuBl36Iqy6IWRS900Eg6MkwgejnI=; b=1+/A2AInqvMAiD3ILFP+h/IQc NOh5aG/2JHlRVBwi5J315BVuWQzD7HYQoDtsN8cXzzVdNcfufR0e3hwk60fZYZeHD9hmDl/ErePK+ ojbsS0nPCD93HdzMSkDmRH12vhhXpDX39ytBTjICAJfMVX6VJ6HW+DLKOnE4oWzzxnkh5KM7r57QR 4CtylXpWg9OO69K8Yzb4XClrrLO9LcJdLfkGD7otz7tZsQJttBxpN9qlxgOhY5UhgZl0jQzONUmAj frIxcLPWvoTcD/xpnamFmhNcQ34s9SV07jfs12KcYMb7k9KtD8YTB+fvU2n0aGQcSRH8FKFCuDC8T JWGByKG2g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhEC-0003mJ-LW; Tue, 23 Feb 2021 23:36:28 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDG-0003V5-UC for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:33 +0000 Received: by mail-pl1-x632.google.com with SMTP id 17so7538173pli.10 for ; Tue, 23 Feb 2021 15:35:30 -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=HPbp3odOfaIom8lulpC+zN3L+Tw5Db1SxhlJJbdYzWA=; b=Lnhc24KUMdXeZxlsoSjmtldmuCTGikwcXR8zVl7VpxCaVNl0reanjW2E/uPrMbr4Jk JCe2X/s4nJZ1ORlDlUbDUNrKCN8Z0311QgBQI7bxsxWtZMgckQ8Kt/KDOUqADlTvfE3U zTszAoiysnpt3YoNW9JD2SuFL3QC54p956Qa9TcMHZKdBKDZdD1fpoCrZQSIKrMLvHXb bVC4ELvIfewd8z+2/69lluul2fFT1q1obxQ5Kje7e3cMPH4UdzTbJS5Hkhbw1l/Pp4tb AblViX0ispBByz7T9pemaTozghMPHlrIW09cSlrW/kFTyTlS0z8D6qJErGxF0TqPhnxy CRKA== 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=HPbp3odOfaIom8lulpC+zN3L+Tw5Db1SxhlJJbdYzWA=; b=JpU0IdSMhsJu0Sit+XrGt0B0sN945YhPGpJLwQw9+alYSrl+42f/W5Y0ACWSJBx5qH M3mUU7kViLukXBnU3G/OSmLs5ou5BJMJ8ogdsf6aBfx7Z7dfKWfP7NAqhUBEFR9AUk14 UaMqNZXCaQOZ70xnN6VtTDlOT6ib/IwPDkqAh+KoSaRCk0ut+QYoQfHUKbboE89j85K4 9yTB7lcpOWPdky6zUq6VsaEGNncPcty4Y22X51QHP5SDKaaYP/S3K8y5bT6/Trm5PRz4 2xg+qV1Wsxenwxsd0ZYx09l6gSqOmLjihxoRQ9EloehmjPWb+oELEaERt/LFO2r8rHfH VZrg== X-Gm-Message-State: AOAM530V1/cMB5bHEAQm3LZLhmApx5uoEU/OZJxEoHlVm5g6oEZESiHm P9X3tLUMnrGqpK98SqlW1CLC0g== X-Google-Smtp-Source: ABdhPJx/VI9lhdfasSY6+J9J7zhrY1PeQnVBk9Jj0sOSq96rQttwigsoFbpE/xJcM+9epB+bcWL5OQ== X-Received: by 2002:a17:90a:fb58:: with SMTP id iq24mr1208810pjb.64.1614123328836; Tue, 23 Feb 2021 15:35:28 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:28 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Subject: [PATCH v6 11/16] remoteproc: Properly deal with the resource table when attached Date: Tue, 23 Feb 2021 16:35:10 -0700 Message-Id: <20210223233515.3468677-12-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_183531_097484_CD16256C X-CRM114-Status: GOOD ( 29.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If it is possible to detach the remote processor, keep an untouched copy of the resource table. That way we can start from the same resource table without having to worry about original values or what elements the startup code has changed when re-attaching to the remote processor. Signed-off-by: Mathieu Poirier --- New for V6: - Double free of the cached table has been fixed. - rproc_reset_loaded_rsc_table() has seen a complete re-write. - rproc_stop() now calls rproc_reset_loaded_rsc_table() rather than dealing with the cached. This allows to properly shutdown a remote processor that was attached to. --- drivers/remoteproc/remoteproc_core.c | 86 +++++++++++++++++++++++++++- include/linux/remoteproc.h | 3 + 2 files changed, 88 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index fc01b29290a6..3a4692cc5220 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1556,6 +1556,21 @@ static int rproc_set_loaded_rsc_table(struct rproc *rproc) return ret; } + /* + * If it is possible to detach the remote processor, keep an untouched + * copy of the resource table. That way we can start fresh again when + * the remote processor is re-attached, that is: + * + * DETACHED -> ATTACHED -> DETACHED -> ATTACHED + * + * Free'd in rproc_reset_loaded_rsc_table(). + */ + if (rproc->ops->detach) { + rproc->clean_table = kmemdup(table_ptr, table_sz, GFP_KERNEL); + if (!rproc->clean_table) + return -ENOMEM; + } + rproc->cached_table = NULL; rproc->table_ptr = table_ptr; rproc->table_sz = table_sz; @@ -1563,6 +1578,65 @@ static int rproc_set_loaded_rsc_table(struct rproc *rproc) return 0; } +static int rproc_reset_loaded_rsc_table(struct rproc *rproc) +{ + struct resource_table *table_ptr; + + /* + * The cached table is already set if the remote processor was started + * by the remoteproc core. + */ + if (rproc->state == RPROC_RUNNING) { + rproc->table_ptr = rproc->cached_table; + return 0; + } + + /* A resource table was never retrieved, nothing to do here */ + if (!rproc->table_ptr) + return 0; + + /* + * If we made it to this point a cached_table _must_ have been + * allocated in rproc_set_loaded_rsc_table(). If one isn't present + * something went really wrong and we must complain. + */ + if (WARN_ON(!rproc->clean_table)) + return -EINVAL; + + /* Remember where the external entity installed the resource table */ + table_ptr = rproc->table_ptr; + + /* + * Make a copy of the resource table currently used by the remote + * processor. Free'd in rproc_detach() or rproc_shutdown(). + */ + rproc->cached_table = kmemdup(rproc->table_ptr, + rproc->table_sz, GFP_KERNEL); + if (!rproc->cached_table) + return -ENOMEM; + + /* + * Use a copy of the resource table for the remainder of the + * shutdown process. + */ + rproc->table_ptr = rproc->cached_table; + + /* + * Reset the memory area where the firmware loaded the resource table + * to its original value. That way when we re-attach the remote + * processor the resource table is clean and ready to be used again. + */ + memcpy(table_ptr, rproc->clean_table, rproc->table_sz); + + /* + * The clean resource table is no longer needed. Allocated in + * rproc_set_loaded_rsc_table(). + */ + kfree(rproc->clean_table); + + return 0; +} + /* * Attach to remote processor - similar to rproc_fw_boot() but without * the steps that deal with the firmware image. @@ -1688,7 +1762,11 @@ static int rproc_stop(struct rproc *rproc, bool crashed) rproc_stop_subdevices(rproc, crashed); /* the installed resource table is no longer accessible */ - rproc->table_ptr = rproc->cached_table; + ret = rproc_reset_loaded_rsc_table(rproc); + if (ret) { + dev_err(dev, "can't reset resource table: %d\n", ret); + return ret; + } /* power off the remote processor */ ret = rproc->ops->stop(rproc); @@ -1721,6 +1799,9 @@ static int __rproc_detach(struct rproc *rproc) /* Stop any subdevices for the remote processor */ rproc_stop_subdevices(rproc, false); + /* the installed resource table is no longer accessible */ + ret = rproc_reset_loaded_rsc_table(rproc); + /* Tell the remote processor the core isn't available anymore */ ret = rproc->ops->detach(rproc); if (ret) { @@ -1997,6 +2078,9 @@ int rproc_detach(struct rproc *rproc) rproc_disable_iommu(rproc); + /* Free the copy of the resource table */ + kfree(rproc->cached_table); + rproc->cached_table = NULL; rproc->table_ptr = NULL; out: mutex_unlock(&rproc->lock); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index e1c843c19cc6..e5f52a12a650 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -514,6 +514,8 @@ struct rproc_dump_segment { * @recovery_disabled: flag that state if recovery was disabled * @max_notifyid: largest allocated notify id. * @table_ptr: pointer to the resource table in effect + * @clean_table: copy of the resource table without modifications. Used + * when a remote processor is attached or detached from the core * @cached_table: copy of the resource table * @table_sz: size of @cached_table * @has_iommu: flag to indicate if remote processor is behind an MMU @@ -550,6 +552,7 @@ struct rproc { bool recovery_disabled; int max_notifyid; struct resource_table *table_ptr; + struct resource_table *clean_table; struct resource_table *cached_table; size_t table_sz; bool has_iommu; From patchwork Tue Feb 23 23:35:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101081 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=-16.8 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 136A4C433DB for ; Tue, 23 Feb 2021 23:38:20 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 CACEC64FBE for ; Tue, 23 Feb 2021 23:38:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CACEC64FBE 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=merlin.20170209; 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=rLJczm/QVqkZbRSiF9pchuCAJaHfkrHY+28xnZrNg6M=; b=JTAywy/0kZM51bzHmCL63V1XH +I/JlgXUZBgw/aYxbYDRI+0uO6aRa38w4KoluIIYEmzwFVQUzfqH0UKbsi6mSy0B/jXT5b+yfZpLY GfDUz7taMEMAbAMUGAdPlz+4Sk42PJ8K40HMZg5Gm9/uA3ap564Y26/PF415HNpLkrTXrACVmy1q3 rzyVv6VC2sVsoe1h4YI2fFfTVk9/41WUZJpyyK/i1gNZkiMJMFrzOhuptlm3iFO8j40ZJxeuTMtIl D0oRTBOUSpaPqNrFasMo62f+PCY0SPOdOiOq75f8McWvYXXLS4a9+vFNKwJNaQuzNL+5Vi33U8AEa Co5e7k06g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhET-0003v9-Jm; Tue, 23 Feb 2021 23:36:45 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDI-0003VT-0G for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:34 +0000 Received: by mail-pf1-x42f.google.com with SMTP id z5so63042pfe.3 for ; Tue, 23 Feb 2021 15:35:31 -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=70JCEwLX10Z8DU4ByYhqbD5Bs/NYPpdr+UeUH0EROyg=; b=N88XbmgPFY0tBL+nREjZof5xI3M2ZNmAG8U2gcExz3QoFVbxPON6BETexyL4v5/axT NMvkJeeyOx/gXRHMZKTpGuV2CrN/cYTde9bOUTYNlrOjcwrROSGin9JWiFSbNskLAG2z g+n7hzn5LtTJ7SWRABd+hnyBF3rWONLrJt9/7b0Re0SjI7kMF6ZyzXqUy2yKiZMcQ+uo Mc9wgFqCHhAppyFeuJUW0XqXLG7V0xqTJK/wGe2WhfK1rz0qK/tFwQtV4Ztf2EmJebmD pmDFdOS8mCjz1F3UaEbjiH85CTJSMNxEU/xeioeWcY93f5WYGMqhvmsCWH5t4dnMVGir LBYw== 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=70JCEwLX10Z8DU4ByYhqbD5Bs/NYPpdr+UeUH0EROyg=; b=szR98LZfjAVOyW6ve/vgeIMyQ2FWEVN+saTNSVrLAWxRbdtb2TYpajfVaAKOik4cuB rrE6nJlJtAbGL8zfvu/844QodQKosyESWgqGA8wnOuKbf7d4jS3meL9pO4bFeYSb9YQ5 568PBFZJvyknEcZAWDAXBfLGUzaRQksWMk0iRMMVIjnjRPgwZfY9Uv2ojQ55xgljcsjf lt3MoBImmysuo4rsWAph8roMnmBGc+54Ez1+DLCXblAtMKloRV4dRcROgmTBN2P1FVjG aa/SjwsiJ7rL9UeadI4ZnT9LxzBsZ2g9O1GvjCUDFFTeRu+wCZMMOL1uVI0+aalxyFwB gKbQ== X-Gm-Message-State: AOAM532hXxEsiIbPZZvRWO11zKZZaEvGSZetL/av/MDVxGc6pDIz/dnn HlucBLZgp08suIuB6ps7vptmJw== X-Google-Smtp-Source: ABdhPJxktytv7llBIEju6a5H8h+Ul5Vrj9GmHcU8b1aSOP67/rAzaK7GrW6MDJiRmAWPqcQkjT+Qlw== X-Received: by 2002:a63:a22:: with SMTP id 34mr23087036pgk.328.1614123329746; Tue, 23 Feb 2021 15:35:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:29 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Subject: [PATCH v6 12/16] remoteproc: Properly deal with a kernel panic when attached Date: Tue, 23 Feb 2021 16:35:11 -0700 Message-Id: <20210223233515.3468677-13-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_183532_132442_68CC7312 X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The panic handler operation of registered remote processors should also be called when remote processors have been attached to. Signed-off-by: Mathieu Poirier Reviewed-by: Peng Fan Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 3a4692cc5220..0dc518a24104 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2684,7 +2684,11 @@ static int rproc_panic_handler(struct notifier_block *nb, unsigned long event, rcu_read_lock(); list_for_each_entry_rcu(rproc, &rproc_list, node) { - if (!rproc->ops->panic || rproc->state != RPROC_RUNNING) + if (!rproc->ops->panic) + continue; + + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) continue; d = rproc->ops->panic(rproc); From patchwork Tue Feb 23 23:35:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101085 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=-16.8 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 BF012C433DB for ; Tue, 23 Feb 2021 23:38:27 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 824AB64FBF for ; Tue, 23 Feb 2021 23:38:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 824AB64FBF 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=merlin.20170209; 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=3DOR/bvveCPvpzhMTPu4C2uEPVXRKwPmdV2q56XiT7o=; b=TkDIAVEKio9cF8hGxKuNtSGc7 r/lR2i6LpW8Kb8vPlOfdsUq0+O5EJ3BYAYcUo+cDVtwZn3QiEqQjrwexixwnpoLa3cMaLfjtTz7c9 sSHfyrRz2pfWdw67Yj9MvhiLWi4OeG3gx0T+F0b+e3hldsRmnckHcCUpl60bGm0l22QvIRpb9Kfuh f+fO64eO9GBs67ColXisVZ+8CcmFGSy6qA2UV/EgsYYTEgIA/vbWDSueUvkFwbE5LTx0zTGIybK8B It6wc8YL5rbmOz3DfAQN5N/2RNR9ZeMjQgcWY8KW6g5dFSo1fG/ItfEshanaKJBVxZ84PEodeyrK0 MN9bEmsvA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhEX-0003xh-SN; Tue, 23 Feb 2021 23:36:49 +0000 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDI-0003Vr-QL for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:34 +0000 Received: by mail-pg1-x535.google.com with SMTP id g4so245055pgj.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=gj6WF/1oKuVocPkZDr0q35lcZZqhgtjB+hq21nBtWDQ=; b=ZkrwA5l6fGRzXKbDLnTP+sAznOgBEqIPSOLtIN2KgJHSPZ4BwfMkB2e9ZC5lzjMPlF X/ULwxMUqbVeIGtBxZGIYYv9szkBJOOiuq+735KJ9sCtMvU8T13XtbLE0Og6I5tbgj77 du0CWnXdaILg/8qmH2LNjdphquJqoWGTSntiXlVed65w8Xt6zRZAELKPgPerQ4HnREsQ TDwR3jH7jKHcVSB8CQYrLky9GENdJf8sFbNo6gw8Pk84QyUuKX695nXeotPEtNPIYbhZ oK5mHP6Kjql5B/l+VyZDtSGxn0pGHDi7wkN4lxO/lWrQDVoGWOWZ6o+gwxFNmxJvQG5R feng== 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=gj6WF/1oKuVocPkZDr0q35lcZZqhgtjB+hq21nBtWDQ=; b=iPnJCMx9twJiiGNmsj6g/ZAnvIJ4H75s8KTTJ6iwgDdNaq0ixq0l+NuxWRZGeYSYt2 In+97A3tt9rGINjOPf06HnYsOgk7U1ZKvy0NHXgoUcyZEUjiw3Y3qrppQTEc6Et3+jcS fZJktuUz0k0gXwtTjA+11tYxBpnY/ULhRIkqKcF3FYX47U6fxActHz/DEuTpHRC2HR5H zeHF8Qj2G2HkNRJUU9JV4aIh5eN+OLqT48GMLDvxPFV61LLextaYnsUNWSnmYleNFCjK 01XQ1zAQlWbd3DoUF+DVLJz/EtEp11JNwZs4ODXnmLyfWC2HMCEfLYWsZURBHcj7GhRq 7rxw== X-Gm-Message-State: AOAM533tATU9o3kbmwZosda1bPkKG72FwWFAR+Gpb42qveGypV/++XxP hfh3s9odorxiNw5iztq5Q/WA+w== X-Google-Smtp-Source: ABdhPJxifZVF0IEfjvNgnYfuzrC/lhgLJk67zzdhvo7k9W8T3W4tzIDFjIAhgw6I2UHWX1oqa300pw== X-Received: by 2002:a63:ce4d:: with SMTP id r13mr25383523pgi.204.1614123330723; Tue, 23 Feb 2021 15:35:30 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:30 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Subject: [PATCH v6 13/16] remoteproc: Properly deal with a start request when attached Date: Tue, 23 Feb 2021 16:35:12 -0700 Message-Id: <20210223233515.3468677-14-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_183532_945028_B56D5B0B X-CRM114-Status: GOOD ( 14.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch takes into account scenarios where a remote processor has been attached to when receiving a "start" command from sysfs. As with the case with the running state, the command can't be carried out if the remote processor is already in operation. Signed-off-by: Mathieu Poirier Reviewed-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_cdev.c | 3 ++- drivers/remoteproc/remoteproc_sysfs.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index b19ea3057bde..b2cee9afb41b 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -32,7 +32,8 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_ return -EFAULT; if (!strncmp(cmd, "start", len)) { - if (rproc->state == RPROC_RUNNING) + if (rproc->state == RPROC_RUNNING || + rproc->state == RPROC_ATTACHED) return -EBUSY; ret = rproc_boot(rproc); diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index f9694def9b54..66801e6fe5cd 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -194,7 +194,8 @@ static ssize_t state_store(struct device *dev, int ret = 0; if (sysfs_streq(buf, "start")) { - if (rproc->state == RPROC_RUNNING) + if (rproc->state == RPROC_RUNNING || + rproc->state == RPROC_ATTACHED) return -EBUSY; ret = rproc_boot(rproc); From patchwork Tue Feb 23 23:35:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101087 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=-16.8 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 86733C433E6 for ; Tue, 23 Feb 2021 23:38:28 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 4D31864FBF for ; Tue, 23 Feb 2021 23:38:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D31864FBF 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=merlin.20170209; 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=+Oz3+vFUdSVakDNifnkcCnx9acpPm/I0+yr0l9ShavM=; b=KtozgBp+EgA2iVIcTtibuosVp sM3+B1j5k8ecyUn6Eni8D7IvWYb76qYv+dtwalCbLLYrffSaMhZ0fJMbcKWMgVgRO51vyp71qMel9 ogXf4XqEGHXQ0hbK+IFjJFXI1rx5y2HmX6evIAprcI2omhsFYk6bm5pd+h93I+DwvUzRU46YvG8Gm iPg9xNYf0HRlJwl48zfK8xnbo4actY/dQUlXPY0pz69kbVt/u4jIofekvPsEYH2QYSKpCdFKREKGM 8Bc3gqm3S2WBxLFkDscj/FW/AnBq/aBN/7IbLD4zRVoHFnHu0qW8sDTLRLQzlnVizVfI7eO4ZVQT2 zKOqf2Ahw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhEi-00043K-5W; Tue, 23 Feb 2021 23:37:00 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDJ-0003W4-MR for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:36 +0000 Received: by mail-pl1-x62d.google.com with SMTP id s16so10840683plr.9 for ; Tue, 23 Feb 2021 15:35:33 -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=LAmTI3bglQtEFeSTtt3Ql1nIs9Boi2zxtX6t4SxVxWc=; b=NGED3eMgJhGkZutPXOY2WKCOmKOme62DKhXx1QZ0sElxKyqqf9wTTUOVOY3wtc5K7q 3BbDYubPwKdE1O0ikOKN+N07cltdgjsC/CdhLIFXmy9woQx2nyu9a26Q7ESUKcBEzMC7 TO1YtNGCi4mw6gNi+ZsBjHUW0aiM82TfpG9EfQvvYNPNPKiAlyd62qoGwdcO2Jf3AhTT tEXJu57bkHJ+qN2qzBLsnv8CS2MFmfTAl6LhTSsnNhOYQveF03NPu06l3/SnMa5tZVTM IxQIyS5lLIxjrjMnNTmNa/ITI7VH/w6egSsVh/Ca8ZUE6WdbTdzQdFDqvVstrTk2dC0n awnQ== 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=LAmTI3bglQtEFeSTtt3Ql1nIs9Boi2zxtX6t4SxVxWc=; b=IMATzOxqG+4XWK+lBIN3ktMAZxQ6xCg8Qpu1vipELEtxyqG4LrEAuAWlC19yDZhZge 9XQgaHx7hv136nrsJyNx80X/OM8ofFab+2v9s+UVmy4PQg0C9EETJJ4UvH8Ee2dWVPeP oM2blqrksvCBj+hcWYuA2lbF3qCFmNAanhulMvP/lddv0R0FUb6kDQV/SrV7WXlvXKEB rcEcyRB6TSla7MWNWsKrYkMkatUCXUlFsH2ZbzAXEVul4b3SI68FJwqlBDMpW9f0zAVe HzBWlqpQt+STMjOhZHJ6z2lNNKfk6Q4aDHbkLqvdQ5MQsWabeWPNBf0Aq4wZwvlxj3XG QFuw== X-Gm-Message-State: AOAM531cV/L2E1Bz9ij8zucWHjRMXutzjrofwBPQv+5yKg3qjPrDcv8L 8tG91sRk6Yx8HClPtUTJJN/inA== X-Google-Smtp-Source: ABdhPJyR651tRS4bDZK72lnBVxuVN3KAk7P6cdiDxXGAKnu4Rzr7sbRRMCz02RCa2EQ4DN7T5maLSQ== X-Received: by 2002:a17:90a:bc8e:: with SMTP id x14mr1111361pjr.153.1614123331588; Tue, 23 Feb 2021 15:35:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:31 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Subject: [PATCH v6 14/16] remoteproc: Properly deal with a stop request when attached Date: Tue, 23 Feb 2021 16:35:13 -0700 Message-Id: <20210223233515.3468677-15-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_183534_828968_29C7BD62 X-CRM114-Status: GOOD ( 16.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allow a remote processor that was started by another entity to be switched off by the remoteproc core. For that to happen a rproc::ops::stop() operation needs to be available. Signed-off-by: Mathieu Poirier Reviewed-by: Arnaud Pouliquen --- New for V6: - Removed state check in rproc_shutdown() as it is already done in in calling functions. - rproc_shutdown() doesn't return an error code to keep legacy behevior. - Removed Peng and Arnaud's RB tags because of the above. --- drivers/remoteproc/remoteproc_cdev.c | 3 ++- drivers/remoteproc/remoteproc_core.c | 4 ++++ drivers/remoteproc/remoteproc_sysfs.c | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index b2cee9afb41b..0249d8f6c3f8 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -38,7 +38,8 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_ ret = rproc_boot(rproc); } else if (!strncmp(cmd, "stop", len)) { - if (rproc->state != RPROC_RUNNING) + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) return -EINVAL; rproc_shutdown(rproc); diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 0dc518a24104..00452da25fba 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1758,6 +1758,10 @@ static int rproc_stop(struct rproc *rproc, bool crashed) struct device *dev = &rproc->dev; int ret; + /* No need to continue if a stop() operation has not been provided */ + if (!rproc->ops->stop) + return -EINVAL; + /* Stop any subdevices for the remote processor */ rproc_stop_subdevices(rproc, crashed); diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 66801e6fe5cd..09eb700c5e7e 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -202,7 +202,8 @@ static ssize_t state_store(struct device *dev, if (ret) dev_err(&rproc->dev, "Boot failed: %d\n", ret); } else if (sysfs_streq(buf, "stop")) { - if (rproc->state != RPROC_RUNNING) + if (rproc->state != RPROC_RUNNING && + rproc->state != RPROC_ATTACHED) return -EINVAL; rproc_shutdown(rproc); From patchwork Tue Feb 23 23:35:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101083 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=-16.8 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 15946C433E6 for ; Tue, 23 Feb 2021 23:38:20 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 CB20864FBF for ; Tue, 23 Feb 2021 23:38:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB20864FBF 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=merlin.20170209; 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=zAEErGSdIgtB7W2Y/Fx+HHhXNrEK3Q77sJAg0OKN3Q0=; b=VnTRicl4jtulNK4ISn6WJvF3a BbamnoN+19rwEuzoY+APxnYuJh6qUqc/cnLqiq4iE/1/j3oQST4Sqii+8vWxe4grdGW8gmCz2LWS4 x2mvegmJ7ZUqA8APNndufQt62Z/JPr+VHrvFUQ5Cf2/Q6oy1r8NAUAnaGbjIFRnNsfY1L6OfKyAyA 4nq6Nx6hTzj6tWhrpH4kvNJKOIiD0+2O/YrIxwz1G4D52VX4vIY3r1hnRjBuXs8ssRftBtUDhmRgU wrAdRM2vtYrCKdzS++uyhN2w4pZLhVLW2PLqqHj3RsVFOc0T0Pz5+mFk3RF14/0VGPfETlnFyd6b3 xdzwYQFZQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhEc-00040D-SM; Tue, 23 Feb 2021 23:36:55 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDK-0003WX-Je for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:36 +0000 Received: by mail-pj1-x102d.google.com with SMTP id s23so51120pji.1 for ; Tue, 23 Feb 2021 15:35:34 -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=pJrJ9GxwCqKWRLgp2LCrOR8UdnV+g0aafOP2gLL02EaQsr4U80+m4/5W6SCnkSEw3I h79p917uHDl1e/EmkzrgxPx/ZGxygdG28XzDltju6W7BUzOM8qTZZIrt7AhHETMEGECA YE5llj+NRxBIVqsosWtPxUEznW4b4KNzkl0cewBjeOYidU+9HYYYRe7fYx+4t+s8k67g HZ5RNfharrYUEGqM76z6EFTQb+o0FcI4SkjQ5LYMqiKJKqtnFSfpiG1gcBrk1/wjQ78H YHCqynWb5GzXgVlY0HFI66VVYkHaP+2AmArzWU3kp+Wrh/WVJOZHX5XxsjAyK/+p/JeC ztQA== X-Gm-Message-State: AOAM532PUqzdTeZmGZZMQW10rwQkFwGDbJmYBzNT8gL7kWK6Ya7ZYoT1 PFoYlc36CU0XsqRwWXDcZF0ODw== X-Google-Smtp-Source: ABdhPJylws8xRS7yb6Lx8oAsaa4CQlYQ1WGcJw/Rv+dLerg4frRX3/lypczOzj811/g3w5SiIH0aKg== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_183534_851712_D18A0E8B X-CRM114-Status: GOOD ( 13.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org 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 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 --- 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; From patchwork Tue Feb 23 23:35:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12101089 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=-16.8 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 28B0FC433DB for ; Tue, 23 Feb 2021 23:38:42 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 E0C8A64FC0 for ; Tue, 23 Feb 2021 23:38:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E0C8A64FC0 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=merlin.20170209; 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=/N+NC6nF6fTehlsohtjZGipobbW6Fjx3zFM3jHT+GY0=; b=YBMzOeAEnV6SQhPBceUTmNvVb yRDJs/a3DMGukAfq/4PZpO4ZZMFkkZmsg8T4Nb28ynriqrENcfJwei/6zZSK9xm28aUJObqN7jkQq EUoyjZ4nTI+dL/xYKraJX06dDu8pX/s+rqr++FkO1gkVkaJFY+v1Fmn9NKTxCyUgtLPAhTNkw19+h D/41YqCYCvGI7JpMAidq4hLDfk3VWOngyTWQccvaV38+joIyxdCHDCDh+5y5Y+UhaCF1Lo/fflE1o R06WqCdxv0AXgjYBV7ML1KvF75Rrn5sL5l1FIbeNv1JyxQqheWVdXRj11tBlZxtpjrPiXBr9+U69y tebIMJWFQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhEq-00048j-Gq; Tue, 23 Feb 2021 23:37:08 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEhDL-0003Wb-F4 for linux-arm-kernel@lists.infradead.org; Tue, 23 Feb 2021 23:35:37 +0000 Received: by mail-pl1-x62f.google.com with SMTP id s16so10840724plr.9 for ; Tue, 23 Feb 2021 15:35:35 -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=9dNXLfIEwaBmyxdvGPLcXIZoYDoiye95/dFOxo0lMe4=; b=FacrPQa+2h15QlpIr28yddn6IuvoguAmRAZYlTCp41sRk7VfSbFMMi2D9zF2VeoMVT lvlrXDCraOoq8hw/Hd6ybksPaLxpOFGajiMU2ieGncuh6NybqdpyvHRRkwXU/UjOBGM+ TUQgRGVRW4k05wOMkgzVXIYlWss60zHMqwZvLSiwQsmkXhgVszeak0UuXk5E6Iw8z7Hd wu1QmI7wa2PfmOxwH1qiYm/V8xlSYqdvXwvMgazNhLtLuLOwSiPZN3DdNyRAgga/VkdD END38q1jtAVeC7pWOVX2IAEp9taTPnTKdHNiWUZ89mdX6PgHv+/nG5g/As1233+t08MD YRBw== 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=9dNXLfIEwaBmyxdvGPLcXIZoYDoiye95/dFOxo0lMe4=; b=e/CKQ2jc0Vl8MFaQvysYdoz9AiFlE08DgANW/Zf9eZZkFVVdaAqsgewePhVq3krcD6 rqCGC/IUoNs0ifDLmaT+VhMn5ei8qhTLGjjzE1J9AX06IIgBH2WN35NWC+XNYkHSNY4D trJH3mQVZLcAN7tAtZIAijU4Iv9Od5jz5jV+4+O3YGfajQ+xLkhldveps2xxLFuAarur vzXWg9UzXecv3hfsZFrODjehk1D0qF5fLX6yx04Rtk/nkDWy9QbxozawltcN71L74Gbl bf1PQ7ZR4RhJdAeCZQb/USSGBS+rwnjmFKa0+XJnHs3K/ZgrBzoOy2f/mAcV1iTBRvZg 9g1w== X-Gm-Message-State: AOAM533gt0R2xRrxvU0neWjDlQNGa4aMNVueaLwhckXqab0qGUjt0vB4 5XNpdVJRV7VhBxQcUZOMlZd90A== X-Google-Smtp-Source: ABdhPJzDAGh6wh3Npt8Bm/YQ7HhxIWxiSdzM/fQpCszCDx97I+KOxtsQXnMjbwrn7gO/M6IugUvOzA== X-Received: by 2002:a17:90a:4a0a:: with SMTP id e10mr1161914pjh.112.1614123333381; Tue, 23 Feb 2021 15:35:33 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 15:35:33 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, arnaud.pouliquen@st.com Subject: [PATCH v6 16/16] remoteproc: Refactor rproc delete and cdev release path Date: Tue, 23 Feb 2021 16:35:15 -0700 Message-Id: <20210223233515.3468677-17-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_183535_604282_E6966E94 X-CRM114-Status: GOOD ( 18.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, linux-remoteproc@vger.kernel.org, alexandre.torgue@st.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Refactor function rproc_del() and rproc_cdev_release() to take into account the current state of the remote processor when choosing the state to transition to. 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. - Transition to the next state is no longer dictated by a DT binding for the same reason as above. - Removed Peng and Arnaud's RB tags because of the above. --- drivers/remoteproc/remoteproc_cdev.c | 10 ++++++++-- drivers/remoteproc/remoteproc_core.c | 9 +++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index 2db494816d5f..0b8a84c04f76 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -86,11 +86,17 @@ static long rproc_device_ioctl(struct file *filp, unsigned int ioctl, unsigned l static int rproc_cdev_release(struct inode *inode, struct file *filp) { struct rproc *rproc = container_of(inode->i_cdev, struct rproc, cdev); + int ret = 0; + + if (!rproc->cdev_put_on_release) + return 0; - if (rproc->cdev_put_on_release && rproc->state == RPROC_RUNNING) + if (rproc->state == RPROC_RUNNING) rproc_shutdown(rproc); + else if (rproc->state == RPROC_ATTACHED) + ret = rproc_detach(rproc); - return 0; + return ret; } static const struct file_operations rproc_fops = { diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 00452da25fba..a05d5fec43b1 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2542,11 +2542,16 @@ EXPORT_SYMBOL(rproc_put); */ int rproc_del(struct rproc *rproc) { + int ret = 0; + if (!rproc) return -EINVAL; /* TODO: make sure this works with rproc->power > 1 */ - rproc_shutdown(rproc); + if (rproc->state == RPROC_RUNNING) + rproc_shutdown(rproc); + else if (rproc->state == RPROC_ATTACHED) + ret = rproc_detach(rproc); mutex_lock(&rproc->lock); rproc->state = RPROC_DELETED; @@ -2565,7 +2570,7 @@ int rproc_del(struct rproc *rproc) device_del(&rproc->dev); - return 0; + return ret; } EXPORT_SYMBOL(rproc_del);