Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1691463ybz; Thu, 16 Apr 2020 13:47:29 -0700 (PDT) X-Google-Smtp-Source: APiQypKbmdl83fbJ5F4os6REn0AtchRVPGeZoPXLSlR3zy84CNpWSe+E549unHw84f06ndgRa/lo X-Received: by 2002:a17:906:4a94:: with SMTP id x20mr11547239eju.306.1587070049402; Thu, 16 Apr 2020 13:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587070049; cv=none; d=google.com; s=arc-20160816; b=wL6v7NqDPN/322lus1FgUlmWT+hX+lTirLGpPw63XUM8buLYGQijrTU5APRFwAAlVL 1ZtVSQA2oc/FvFC9zKsapQXK/5ObntLCZFB1JhTSAWVE3q1+RMFs6bm31dOVYGwW9wAn ymxalz57Gxv/cgqyTqliCrWLB28K+ENW2DZAhHeb7FMj7gg2RjqDRBFWJyfccUcKxGAN BdurPdO92lrenT+7IPdCoQ3WYLzXZGHzZPq/XnNTfaI+C0aBC1KilsreB9Bo8/OFFFnx xAjEfJ754VnJwweuRh+4BS3KYSlvC1lI53PO+q4FGRF2O8YuP3+RXFJAhwbzCZSbRRib t8Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=aKFYVYQ9OYxfkj6UtWE/c0zee6GGkl7hN2RiXbrSsVQ=; b=NobzYuIReUQU7kCEj/cSC0xr3A63Tv32/JcSHXVBMAsCjnIE9EWhP4hct55hV/kmFe /MZ4MaqySfLvyTpmvKqmZwssu9odwJw9kw42CNiTCj77Cg5HKH6WV3KEgk7UAgbsC9f1 VBVoAk24OrBP8bly743HXYTCyqlJj3j/aFSb7Id+zqZiUrvRU/HAValREABN37VUmpVQ m+h4jQJsrqdQNBvC0lYZ4ZlJULN7DoTePYOtu3PLXe2QhdArncz5UCzp83Wn/W/SypD/ n5rQy+4dYFY5SAJZuDINOsB+z4Z/agCGMfpwoT8opRdzsGVPOgfZGYxaxgmjuwLvT4Gn Acjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wOOCNhaQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g26si12174037ejr.99.2020.04.16.13.47.06; Thu, 16 Apr 2020 13:47:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wOOCNhaQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729838AbgDPTX5 (ORCPT + 99 others); Thu, 16 Apr 2020 15:23:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727819AbgDPTXx (ORCPT ); Thu, 16 Apr 2020 15:23:53 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58041C061A0C for ; Thu, 16 Apr 2020 12:23:53 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id o1so1782439pjs.4 for ; Thu, 16 Apr 2020 12:23:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=aKFYVYQ9OYxfkj6UtWE/c0zee6GGkl7hN2RiXbrSsVQ=; b=wOOCNhaQsoosxHRpdTHfDHxWt+3yGUwtdVHwF/2+AdpJ85PsC8MarhgRu+8jev/fUw guZPcEBfiQibYkIVoTbLyaM6Sn0VMko49d/uKZC4KFoRxdN0drDm372VeGsWO4MMzNbH IBIx/jZz+pr/4Cwst1GDcrnoY+ozXV3t+DzKHxanKWTIp51IsQSu4wvgiLJJlokx4nQH 0Acdma8hyGFfKiB55qOrNPYc42ho6XiVtd+wmAkwGZp0UA9JevcXfDYt2Qi4c1jRtYnG MONrmuHqYbLHEaHlcRMW9p065LGFFAkDU/brduXXVkgSUPt9l1yml2c5mpbucPCRPhtU CuGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=aKFYVYQ9OYxfkj6UtWE/c0zee6GGkl7hN2RiXbrSsVQ=; b=PmBHtfrW5SKFX5lo/uuqWrHZZnyMtUwbho9JbW9v/G9UWBrpHc2XXV2ROyeqN386lH b/rGXXbJlxQimp166S7QevaE0aNHj6nddhrNao9NkBzU97NbLer3yas0Z6biKgQUwGKr 8vEwvNtJrGu/v1Nr2rQ5+sED0qxp6Yqvwh6SwbkGkXxmBcRX3hwcG//ChBgNQ9YeSq5q n3y1uN/L6NqOZPejnImPX6yTBVp52rGihoS7Dh0T7/Zhkb1W7baATewMPxrbEqohohpo 4aNuLmvy0X+qRerEWdoIpWhrUENX/pQTVq66h9UuFolDPoAMDiuZiS+oDCPFwN6jySnC rwNg== X-Gm-Message-State: AGi0PuYGB21QWmmZ8Md1AUE7B6Xl4sWLLqickZSXN+vG8181NhyNeZgO xciUWl6SrFWjlOH4KxM8Hc47tA== X-Received: by 2002:a17:90b:3691:: with SMTP id mj17mr6924777pjb.114.1587065032831; Thu, 16 Apr 2020 12:23:52 -0700 (PDT) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id p8sm3465938pjd.10.2020.04.16.12.23.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Apr 2020 12:23:52 -0700 (PDT) Date: Thu, 16 Apr 2020 13:23:50 -0600 From: Mathieu Poirier To: Siddharth Gupta Cc: bjorn.andersson@linaro.org, ohad@wizery.com, 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: Re: [PATCH v2 1/2] remoteproc: core: Add an API for changing firmware name Message-ID: <20200416192350.GA29577@xps15> References: <1586384305-7825-1-git-send-email-sidgup@codeaurora.org> <1586384305-7825-2-git-send-email-sidgup@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1586384305-7825-2-git-send-email-sidgup@codeaurora.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Siddharth, On Wed, Apr 08, 2020 at 03:18:24PM -0700, Siddharth Gupta wrote: > 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); > + This is much better, thanks for cleaning things up. Keep in mind that when you do resend this rproc->firmware will likely have become a "const char *", requiring the use of kstrndup_const()... But that is for a later time. Mathieu > +/** > * 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