From patchwork Fri Oct 25 20:59:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Pouliquen X-Patchwork-Id: 13851889 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C8567D149F7 for ; Fri, 25 Oct 2024 22:16:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3kPJXsYEG94KcBKuUOEMCPWBU+fFx4dEjFZ+fZUq5yM=; b=uWxlvGeSeUQJaZhCKvJnbzle9h 9AVLxVF9Oe3SvF/joq/N4RkNBjfn5O5wkAyEZr2zpq/saDE3oPBu3RQysvvEhAaKt3DtVPnGnwy6Z krvOfhicBxGWxQJVlE7Pl9/7CihzMcdtGJNlsjhb982+Yht+wPzPyFxD5o9JvoaJikJrMyU/f9neO oM74OD44+wI8JNfXH/yV458vHUaxmomLCFXWosIMJlPUtmsfqS7TYHgK19e8SmwEl3W9odM9l0CcA UXQ6hM4JfDjSRBj7Ifua1EWcG2E+P2j18N3omNcPFbOFXP3rSDH5F8du96P//BzJPmmfc5wuit7bM ERE4IYmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t4Sbe-00000005PqF-2Hpn; Fri, 25 Oct 2024 22:16:30 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t4RRQ-00000005ENA-1mWM for linux-arm-kernel@bombadil.infradead.org; Fri, 25 Oct 2024 21:01:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Content-Transfer-Encoding :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=3kPJXsYEG94KcBKuUOEMCPWBU+fFx4dEjFZ+fZUq5yM=; b=FE6KnjSRuTwiJz9qZtnydm4N8v M4XDmlWym7ZZwQ1AxJvWu4I1VsdCWfGo5oClSkpDZ/y8sGykHnG4woStFJebUQV6Hs1jVwmdU/E55 n4FQfTL8mTv0C6VF96nsjb4lMxT5fUmqzxRWHORvZMG42b/qori76EzKQ/I0pIOiei7/HIwAcpK1i n0QYfCducfZFDU8Rq4paZLTqeUh095HpMJZD9FX/zkiRsLHQyWGfzLg6BexR9Wi3bAeynRnlcf65+ LTkp0Pvbvtj/g2uZl3emAh+V6Y/2ycVPj05rgiqZp3NAUMgj79sMFihU+byLs3ZutI8vw6MVqAtZj 6ih2dSFQ==; Received: from mx08-00178001.pphosted.com ([91.207.212.93]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t4RRM-0000000961E-2UdZ for linux-arm-kernel@lists.infradead.org; Fri, 25 Oct 2024 21:01:50 +0000 Received: from pps.filterd (m0369457.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49PJKt1L032047; Fri, 25 Oct 2024 23:01:38 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=selector1; bh= 3kPJXsYEG94KcBKuUOEMCPWBU+fFx4dEjFZ+fZUq5yM=; b=bYe8luM5MxaUlQyv ks64Y0BBmcH4bpwVwncQih/miGRSvvxhw3cwKUndToO5hT/fXWSrpwoWxKY4gD6P gQvotaOXVhR7/pCvL4toxN9PEf9+49DqqRpBnyVsronjN3YPSYTK8+rVmVgptzRi fCdYNSXBLfOjFcPpKyir3zOGnVfQP1LbAIXJKW5F9/pJSkqAnp20z4dBaQAP6KTC X5mBoGD6UOQa7tfCxw9FXphc7oO8MYy6ei09L9VmYRGd4cnZ2G0iftEqM132O6l/ 3TE7dIR1skt1wDCreZxuCmhakh3J9lffwW89jtc0HZ0dgAPxhIc180LgIuLpw/XW lrQ9jg== Received: from beta.dmz-ap.st.com (beta.dmz-ap.st.com [138.198.100.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 42em4dyk0s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Oct 2024 23:01:38 +0200 (MEST) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 0656140047; Fri, 25 Oct 2024 23:00:30 +0200 (CEST) Received: from Webmail-eu.st.com (eqndag1node5.st.com [10.75.129.134]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 8A266231946; Fri, 25 Oct 2024 22:59:37 +0200 (CEST) Received: from SAFDAG1NODE1.st.com (10.75.90.17) by EQNDAG1NODE5.st.com (10.75.129.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Fri, 25 Oct 2024 22:59:37 +0200 Received: from localhost (10.252.3.121) by SAFDAG1NODE1.st.com (10.75.90.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Fri, 25 Oct 2024 22:59:37 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier , Jens Wiklander , "Rob Herring" , Krzysztof Kozlowski , Conor Dooley CC: , , , , , , Arnaud Pouliquen Subject: [PATCH v12 4/7] remoteproc: Introduce release_fw optional operation Date: Fri, 25 Oct 2024 22:59:21 +0200 Message-ID: <20241025205924.2087768-5-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241025205924.2087768-1-arnaud.pouliquen@foss.st.com> References: <20241025205924.2087768-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.252.3.121] X-ClientProxiedBy: SAFCAS1NODE2.st.com (10.75.90.13) To SAFDAG1NODE1.st.com (10.75.90.17) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241025_220148_861044_8CB7AA8D X-CRM114-Status: GOOD ( 14.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch updates the rproc_ops struct to include an optional release_fw function. The release_fw ops is responsible for releasing the remote processor firmware image. The ops is called in the following cases: - An error occurs in rproc_start() between the loading of the segments and the start of the remote processor. - after stopping the remote processor. Signed-off-by: Arnaud Pouliquen --- Update vs previous revision: - fix typo in @release_fw comment --- drivers/remoteproc/remoteproc_core.c | 5 +++++ include/linux/remoteproc.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 7694817f25d4..46863e1ca307 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1258,6 +1258,9 @@ static int rproc_alloc_registered_carveouts(struct rproc *rproc) static void rproc_release_fw(struct rproc *rproc) { + if (rproc->ops->release_fw) + rproc->ops->release_fw(rproc); + /* Free the copy of the resource table */ kfree(rproc->cached_table); rproc->cached_table = NULL; @@ -1377,6 +1380,8 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) unprepare_subdevices: rproc_unprepare_subdevices(rproc); reset_table_ptr: + if (rproc->ops->release_fw) + rproc->ops->release_fw(rproc); rproc->table_ptr = rproc->cached_table; return ret; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 2e0ddcb2d792..bce966bdca15 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -381,6 +381,8 @@ enum rsc_handling_status { * @panic: optional callback to react to system panic, core will delay * panic at least the returned number of milliseconds * @coredump: collect firmware dump after the subsystem is shutdown + * @release_fw: optional function to release the firmware image from ROM memories. + * This function is called after stopping the remote processor or in case of an error */ struct rproc_ops { int (*prepare)(struct rproc *rproc); @@ -403,6 +405,7 @@ struct rproc_ops { u64 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw); unsigned long (*panic)(struct rproc *rproc); void (*coredump)(struct rproc *rproc); + void (*release_fw)(struct rproc *rproc); }; /**