Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1043736ybb; Wed, 8 Apr 2020 15:19:42 -0700 (PDT) X-Google-Smtp-Source: APiQypJIgFLg+Z5HntdrGX7bZjoPhr7LAj4xi7qATbgUoXULh/9UT9uAA6veO34UUWwhVZJ//Ks+ X-Received: by 2002:a05:6830:18e6:: with SMTP id d6mr7448396otf.108.1586384382170; Wed, 08 Apr 2020 15:19:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586384382; cv=none; d=google.com; s=arc-20160816; b=OLUdClvJrhPm5g6bBOYItnVXG5vM0T5IZqOqIaDte181V6VTicpdxQE/IWyUS/zsOy WFS7HOFSQNzwuxvOUR1gTdYIPztPVakfY2ExCR6xpUXqV4UtSUmqAJN7ID+C5jV/XafE XxOGiveuXU4wD7TbEWxLNeIdCLQiEX1cEZwwsPNK/1sgZLU9ncTpmB3dUSQGmd1uNI44 F4AYUfkFub3fsYRv7YErX2WIiJ8p9enYTmtGdVqeemnw23r8OEAPrYbBXJeA9+oIkpml 9pEhi3lWvluH4NLrkEAsFe7ZR3vvmMGb0s1xTqqvxaxV8RSgzYkvTofaZshsxYa3CB0Y O5gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature; bh=nxckJHsYlH6PpUyv1QAJtQ0NRWLvH1oUQd2EinXVQSg=; b=MRyWVd7mSKspao1DO2RTN4HssCt4DWRIBBIwxvJUwAopEmb9aYUIEZbGFh7gpQP3WG +faaomxqTkp9kWaCSBS0dQQIY3+NKCo/p39U/TxvH+2Q1By8UG7gypjacnFSR2+vFky8 PV4eJVlxBFuOczGiYOMHDNNzB7DQQC+jR58lDUmN5sJ/J7uwqhdSwrWBzfsE/iPG7Dzx mO7AXQNrg5LR/dK68fHfj8xH8HlPusin0vmd0wIxJSSzZacJA3rrzhsYmKS99vQVBtOc 4amPVuKY6BEgOilYZXe4PhMOyANIxPH4sU2zuij9iSQ0jx/TT4HB1mi/nKa77aH2uPaZ MYqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=XQ+j2Ts1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x14si2351050oix.264.2020.04.08.15.19.27; Wed, 08 Apr 2020 15:19:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=XQ+j2Ts1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726584AbgDHWSy (ORCPT + 99 others); Wed, 8 Apr 2020 18:18:54 -0400 Received: from mail27.static.mailgun.info ([104.130.122.27]:13345 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726534AbgDHWSx (ORCPT ); Wed, 8 Apr 2020 18:18:53 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1586384332; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=nxckJHsYlH6PpUyv1QAJtQ0NRWLvH1oUQd2EinXVQSg=; b=XQ+j2Ts1YMk9DBu4mt1cMYmvApJ5ZcRWsa+iuFPnHfADNYmYuRY5OCuZIjgCeGUjqrPicsuA w+CvrJLxeQPGf7wP2vzwuJi9e0rlOiZ507qHXVCKBDCkfSDCMlNPyUrouyk2cbIztM1vUc8u GCnPQAP8sdABNq2/GE1ZGMPOuHQ= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e8e4dcb.7fcf59ae6260-smtp-out-n04; Wed, 08 Apr 2020 22:18:51 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 7CA9EC433D2; Wed, 8 Apr 2020 22:18:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from sidgup-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sidgup) by smtp.codeaurora.org (Postfix) with ESMTPSA id C7EDCC433BA; Wed, 8 Apr 2020 22:18:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C7EDCC433BA Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=sidgup@codeaurora.org From: Siddharth Gupta To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: Siddharth Gupta , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, tsoni@codeaurora.org, psodagud@codeaurora.org, rishabhb@codeaurora.org Subject: [PATCH v2 1/2] remoteproc: core: Add an API for changing firmware name Date: Wed, 8 Apr 2020 15:18:24 -0700 Message-Id: <1586384305-7825-2-git-send-email-sidgup@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1586384305-7825-1-git-send-email-sidgup@codeaurora.org> References: <1586384305-7825-1-git-send-email-sidgup@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add an API which allows to change the name of the firmware to be booted on the specified rproc. This change gives us the flixibility to change the firmware at run-time depending on the usecase. Some remoteprocs might use a different firmware for testing, production and development purposes, which may be selected based on the fuse settings during bootup. Signed-off-by: Siddharth Gupta --- drivers/remoteproc/remoteproc_core.c | 43 ++++++++++++++++++++++++++++++++++++ include/linux/remoteproc.h | 1 + 2 files changed, 44 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index fb9c813..9f99fe2 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1796,6 +1796,49 @@ int rproc_boot(struct rproc *rproc) EXPORT_SYMBOL(rproc_boot); /** + * rproc_set_firmware_name() - change the firmware name for specified remoteproc + * @rproc: handle of a remote processor + * @firmware: name of the firmware to boot with + * + * Change the name of the firmware to be loaded to @firmware in the rproc + * structure. We should ensure that the remoteproc is not running. + * + * Returns 0 on success, and an appropriate error value otherwise. + */ +int rproc_set_firmware_name(struct rproc *rproc, const char *firmware) +{ + int len, ret = 0; + char *p; + + if (!rproc || !firmware) + return -EINVAL; + + len = strcspn(firmware, "\n"); + if (!len) + return -EINVAL; + + mutex_lock(&rproc->lock); + + if (rproc->state != RPROC_OFFLINE) { + ret = -EBUSY; + goto out; + } + + p = kstrndup(firmware, len, GFP_KERNEL); + if (!p) { + ret = -ENOMEM; + goto out; + } + + kfree(rproc->firmware); + rproc->firmware = p; +out: + mutex_unlock(&rproc->lock); + return ret; +} +EXPORT_SYMBOL(rproc_set_firmware_name); + +/** * rproc_shutdown() - power off the remote processor * @rproc: the remote processor * diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 9c07d79..c5d36e6 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -613,6 +613,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, size_t len, u32 da, const char *name, ...); int rproc_boot(struct rproc *rproc); +int rproc_set_firmware_name(struct rproc *rproc, const char *firmware); void rproc_shutdown(struct rproc *rproc); void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); int rproc_coredump_add_segment(struct rproc *rproc, dma_addr_t da, size_t size); -- Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project