Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2734059ybv; Mon, 24 Feb 2020 10:32:38 -0800 (PST) X-Google-Smtp-Source: APXvYqyoJSw3kZaRvkZuv8kqZymx8euVTQNUJY2lrH9m28JoU1GJNWs2YgpOZ56DdtpTbNquThBy X-Received: by 2002:a05:6830:1447:: with SMTP id w7mr6654359otp.368.1582569158042; Mon, 24 Feb 2020 10:32:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582569158; cv=none; d=google.com; s=arc-20160816; b=x7K8pl2twwjz6eJ+DgBdA1SYkK7hYzrE0G+MeDmkklvfa/yd02HQdYumo4sf6iqhmw BBG1xiqMpbdnXq5Mg7v2HyBOuqDoEVFda5DBAo+l++CxtYs0oajrGBFLCSFwMmDmnaun d33WNnMqs7f/q04VbPSGxRQWJX5UKmjDmZ/wDdYGz4lyYs7A1TsOGmvn30TZ1QcWUxcz waJlrEr+0nNhrQZOM0VvBnGpUuAu5Aj8RAsbqJxj90rMlNwHJlS6kjxOj9zQtwnu9sZl pLPeVRIZp+wNuxGU8LyjGa2Rv/7lYA1qGF2TC5uZ2ULxwJEpxP3l6Bg7o1L0u/H35WtI RCEg== 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=eB+RF5Mh4FenHE6w3IEcxS14k96bS8yZIKZCBidnPPI=; b=N3oP1T5lLS2xTQaPJ3IJEc26tO0JhR3+IwmOrQjvRoXUI0MNq0N+bg5VNSO8UpAACb zjHPl/1ZYXpkzj8jQ/5XA/RrxldI0II/rVT0U1mvoR4POzZSoaO1SorvjiC9FH6WSKAp mFR8yDEPKuSv6sYs+MjLIE+r/bJH+OV8YG0nf5AQ8zOTv9CaBxgtJJtLVXpGmTxm8yGt 3r84BodxaaGdHCsTQkpZPX12KY/gAqvmOpijqOBtpNLikf0bFkBAVZLJJz/nRjMo7U3C 32XcP2PUhvZzEyH/dTsuVyXJki0LfKx8PiAIe+fax6b9UuysGH2xvLAj9MJSmUE97Bp/ 4+RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J38ofieD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si6681603ote.9.2020.02.24.10.32.25; Mon, 24 Feb 2020 10:32:38 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b=J38ofieD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727996AbgBXSar (ORCPT + 99 others); Mon, 24 Feb 2020 13:30:47 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:50293 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726652AbgBXSar (ORCPT ); Mon, 24 Feb 2020 13:30:47 -0500 Received: by mail-pj1-f68.google.com with SMTP id r67so124067pjb.0 for ; Mon, 24 Feb 2020 10:30:46 -0800 (PST) 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=eB+RF5Mh4FenHE6w3IEcxS14k96bS8yZIKZCBidnPPI=; b=J38ofieDuZwieGmCqkTF7yAGdU9ZfG6J4h1Oex9EJi2MJ7UiXHedPEZIWhorABF9w1 4LjBAflwCt5SlXeCaH6i5WilMtAyA6OV/uYRzixRdSSUTOzx6mnQgRWR4HMbDigZPqzn TFC07Pp933b4ftOkv9QPDT7GtUKAVRlKgyHDA4mw/6HVEeKspQjfkn5RzIqTCcdYIKPw diVTC03tNk5VYl0qckRql0EFXLRnSwMQ/ecb+6mEDjIWOsELPf61faJslWaJBAEE6ZO1 e2MzZ/CTAAZ8wNUNAsYLwhXhxMZhXhkPw9ZC+f2YHLq/tRNNOyT8lwq3Ec3miG2/kYqJ CffA== 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=eB+RF5Mh4FenHE6w3IEcxS14k96bS8yZIKZCBidnPPI=; b=uDDXFBydRMmQZF4ZOk8UqI5YHYJzZZy5roValceDjWxmw4mt2n9k4/ZvNlWJeem+dc W/SltVZzoN0NCWLhoULQtr061JXy77nKsr77Q/SO3mjaTj80dgKQDO8Uu/83u2MJ4TqN RqO9W7JPMH6knVHmZRWUNplDDh2vV9xguphSJbHP0/NFEWRJnpQpUaIHr2VA4CgicwU9 waogm/NeGTLa1jibztJqcfMKiL5Z279AvaXfv5jEUKY/GcBOAhqKvTF7BLmYmSkHm6Ns 5RPGPPutuOrChQX08cKVvjaJLxRBTqrKg1d4TQtuqRMtBVVjWQhaQXUUrRi4hrsizV8B zEQw== X-Gm-Message-State: APjAAAWE9jArdalBZ3MuVQEd7NDeJZ3DNx808jeyjV4lSG7F2Y0LWp5t IC9BEzvwu/98NxlOCj+MupruZURcNMU= X-Received: by 2002:a17:902:401:: with SMTP id 1mr50094099ple.177.1582569046452; Mon, 24 Feb 2020 10:30:46 -0800 (PST) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id q7sm13363109pgk.62.2020.02.24.10.30.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 10:30:45 -0800 (PST) Date: Mon, 24 Feb 2020 11:30:43 -0700 From: Mathieu Poirier To: Siddharth Gupta Cc: ohad@wizery.com, bjorn.andersson@linaro.org, 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 1/2] remoteproc: core: Add an API for booting with firmware name Message-ID: <20200224183043.GA9477@xps15> References: <1582164713-6413-1-git-send-email-sidgup@codeaurora.org> <1582164713-6413-2-git-send-email-sidgup@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1582164713-6413-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, Feb 19, 2020 at 06:11:52PM -0800, 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 | 34 ++++++++++++++++++++++++++++++++++ > include/linux/remoteproc.h | 1 + > 2 files changed, 35 insertions(+) > > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c > index 097f33e..5ab65a4 100644 > --- a/drivers/remoteproc/remoteproc_core.c > +++ b/drivers/remoteproc/remoteproc_core.c > @@ -1779,6 +1779,40 @@ int rproc_boot(struct rproc *rproc) > EXPORT_SYMBOL(rproc_boot); > > /** > + * rproc_boot_with_fw() - boot a remote processor with the specified firmware > + * @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, and call rproc_boot(). > + * > + * Returns 0 on success, and an appropriate error value otherwise. > + */ > +int rproc_boot_with_fw(struct rproc *rproc, const char *firmware) > +{ > + char *p; > + > + if (!rproc) { > + pr_err("invalid rproc handle\n"); > + return -EINVAL; > + } if (!rproc || !firmware) return -EINVAL; There is no user involved here so no point in printing anything. If @rproc or @firmware is NULL than callers should be smart enough to figure it out from the error code. > + > + if (firmware) { > + p = kstrdup(firmware, GFP_KERNEL); > + if (!p) > + return -ENOMEM; As in firmware_store() I think it is a good idea to mandate the MCU be offline before changing the firmware name. That way we avoid situations where what is running on the MCU is not what gets reported in sysfs. > + > + mutex_lock(&rproc->lock); > + kfree(rproc->firmware); > + rproc->firmware = p; > + mutex_unlock(&rproc->lock); > + } > + > + return rproc_boot(rproc); Function rproc_boot() is also an exported symbol and belongs in the caller - please move it out of here. When that is done rproc_boot_with_fw() can become rproc_set_firmware_name() and concentrate on doing just that. > +} > +EXPORT_SYMBOL(rproc_boot_with_fw); Although choosing the firmware image to boot without user involvement seems like a valid scenario to me, this can't be added until there is an actual user of this API. > + > +/** > * rproc_shutdown() - power off the remote processor > * @rproc: the remote processor > * > diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h > index 16ad666..e2eaba9 100644 > --- a/include/linux/remoteproc.h > +++ b/include/linux/remoteproc.h > @@ -609,6 +609,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, int len, > u32 da, const char *name, ...); > > int rproc_boot(struct rproc *rproc); > +int rproc_boot_with_fw(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