Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4269983ybz; Mon, 20 Apr 2020 19:54:46 -0700 (PDT) X-Google-Smtp-Source: APiQypLf597goi3b45hmTHy/saUa02V0vOw4cwfyiXDvcgvJTaI/ugGpPl1MSy4qspXeUAPLNV1V X-Received: by 2002:a17:907:214d:: with SMTP id rk13mr19482522ejb.220.1587437685897; Mon, 20 Apr 2020 19:54:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587437685; cv=none; d=google.com; s=arc-20160816; b=fEmp99Y07LGYq3yHqUu2WODJbA6Y2DPHhZm+4arhIUIu4lx05xrWUk9EH7Q+S92n+s EP1N19OXSgm/MopUb4pXMBTMnqsOJ70IA4xQ/gad/B56OwWKypwNQmVXUFOYaofUItng 9S9alrGgA5mYCaoXAwDEkh11qUUjcfQ6iCWuksgPzeR5S1/ugmuoMbqWe3Td224nnHoU 67SsZrJucN/KtIku1UReHH1boQr/nqcBv1Ot6Ch9xEOrg8V7xH38WNiDlV9O96dROdVz 5/0uCNiQnRoBWPLZb0ETE3PWN0KYFqXn0TeMcFbePKpQ+xen47hC51RtfQp2xX7c3T/J ed3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=eX6YUoAUyU+ald9w0j9y7218CuMrF9AfTefdb4alt7k=; b=IKdPY30iD/3SuDABUSjcU1gGxhrotmUm0Qn5YJa+ukx8qwx9dT5WnWbSnxgbav3+Hj 7V1FoGS6T8YQ8GkQOaT5nH53m7S+KeeWTZJTcmAX8WNRpRVroq9xcwYqRuPzCzfouR1R 7/03ckAgxIJ7eKM+bzWGyxEGC0UyPwH/tKrZJMpk51mUAk8LT8fNapv6V0ApknC2bBHy TqJ8zFEWVsyBfHYcJ5vfjptISgUUEm7ugp0UvtvNeA+/d5kVRkMNIfIUvQnlTG1kWiQ3 WPl+xLjuvHCIBNIlSwkt4WhwaZcsniySK89+b9dSOiJrAVplw3q/yhiRINxZ58bLZaEn RN1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ho+pWboh; 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 l7si716245ejb.42.2020.04.20.19.54.22; Mon, 20 Apr 2020 19:54:45 -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=Ho+pWboh; 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 S1726931AbgDUCwd (ORCPT + 99 others); Mon, 20 Apr 2020 22:52:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726325AbgDUCwc (ORCPT ); Mon, 20 Apr 2020 22:52:32 -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 A8809C061A0E for ; Mon, 20 Apr 2020 19:52:31 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id t40so740906pjb.3 for ; Mon, 20 Apr 2020 19:52:31 -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; bh=eX6YUoAUyU+ald9w0j9y7218CuMrF9AfTefdb4alt7k=; b=Ho+pWbohjKTbqwiK7ylfi0+5ra50+e7O/4vhoi7sO6wSGyeQVWHW9pMw3K1ByITxeq z0VvDWGxnjNrIHd5LsVqLBwa+BcbghBVjOwGn+dONaY1qVIeFuWkO9US9xfPmPFawzgQ 5heqivxlNf5V7lEkyxccC4wEAfuJ4O3QWWAnX3wN7o27anigl1fSE85ambi3Z1CAm4G4 pBZvpf8kjuSRWxzoXqrLT/G6DxdUFxnztpSVJTkos2ocV7t2YT71m5OneanzpNN2r+Bo cFzpE+4/KfDlKV/cuYb/1FIKHJrqQebnIHs9DuaGlRiuDp8KeU3aJGSnpTtiSaiUYmy4 wDPA== 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; bh=eX6YUoAUyU+ald9w0j9y7218CuMrF9AfTefdb4alt7k=; b=DUv4UOzNpMshrePGGCxPdHkfNpI+bT7k2qUKsWS1/X36JAX2EyCSsbiJ4fIwXYqvfO 0HivO7mzWsT+L7BuqUk44CSXj/3bWi6s6cr7pflkqBbqgW66F4RVRmM5oaurFfru9aIS kegs3viScedpz4Y8I1nFM+fIWI+QTUpGlToK+/WiHkT8cbHxoCzviz8dhANmwMlVcgJk s8YmiOPQS4gCVrVFENh5MUXTrUDa0XyiMjruPitkIZEMs2JO4/eHwVKIC1sqgmh3JFCn RTcVfgETmffsxx67g/7ODW22iLQU9UYVdVDp1dGn4YLmYBW7LvDHtfMyhb8X2qzLaQ7Z 4zcg== X-Gm-Message-State: AGi0PubGPF84gq9bswGWwn4jXco4/sQRMAZM6s6i/Scta4NDR8g7OgHW HfSkNvBE2Tgi4HInsQtG1UIriw== X-Received: by 2002:a17:90a:8c93:: with SMTP id b19mr2947130pjo.141.1587437551079; Mon, 20 Apr 2020 19:52:31 -0700 (PDT) Received: from builder.lan (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id c201sm910602pfc.73.2020.04.20.19.52.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2020 19:52:30 -0700 (PDT) Date: Mon, 20 Apr 2020 19:52:54 -0700 From: Bjorn Andersson To: Suman Anna Cc: Mathieu Poirier , linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Loic Pallardy Subject: Re: [PATCH 1/2] remoteproc: Add prepare and unprepare ops Message-ID: <20200421025254.GK1868936@builder.lan> References: <20200417002036.24359-1-s-anna@ti.com> <20200417002036.24359-2-s-anna@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200417002036.24359-2-s-anna@ti.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 16 Apr 17:20 PDT 2020, Suman Anna wrote: > From: Loic Pallardy > > On some SoC architecture, it is needed to enable HW like > clock, bus, regulator, memory region... before loading > co-processor firmware. > > This patch introduces prepare and unprepare ops to execute > platform specific function before firmware loading and after > stop execution. > > Signed-off-by: Loic Pallardy > Signed-off-by: Suman Anna > Reviewed-by: Bjorn Andersson > Reviewed-by: Mathieu Poirier Do we have an inbound user of these new oops? Regards, Bjorn > --- > v1: > - Make the direct ops into inline helper functions in line > with the comments on the MCU sync series (v1 comments). > No change in functionality. > - Picked up the Reviewed-by tags > v0: https://patchwork.kernel.org/patch/11456383/ > > drivers/remoteproc/remoteproc_core.c | 15 ++++++++++++++- > drivers/remoteproc/remoteproc_internal.h | 16 ++++++++++++++++ > include/linux/remoteproc.h | 4 ++++ > 3 files changed, 34 insertions(+), 1 deletion(-) > > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c > index d681eeb962b6..e38f627059ac 100644 > --- a/drivers/remoteproc/remoteproc_core.c > +++ b/drivers/remoteproc/remoteproc_core.c > @@ -1394,12 +1394,19 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) > return ret; > } > > + /* Prepare rproc for firmware loading if needed */ > + ret = rproc_prepare_device(rproc); > + if (ret) { > + dev_err(dev, "can't prepare rproc %s: %d\n", rproc->name, ret); > + goto disable_iommu; > + } > + > rproc->bootaddr = rproc_get_boot_addr(rproc, fw); > > /* Load resource table, core dump segment list etc from the firmware */ > ret = rproc_parse_fw(rproc, fw); > if (ret) > - goto disable_iommu; > + goto unprepare_rproc; > > /* reset max_notifyid */ > rproc->max_notifyid = -1; > @@ -1433,6 +1440,9 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) > kfree(rproc->cached_table); > rproc->cached_table = NULL; > rproc->table_ptr = NULL; > +unprepare_rproc: > + /* release HW resources if needed */ > + rproc_unprepare_device(rproc); > disable_iommu: > rproc_disable_iommu(rproc); > return ret; > @@ -1838,6 +1848,9 @@ void rproc_shutdown(struct rproc *rproc) > /* clean up all acquired resources */ > rproc_resource_cleanup(rproc); > > + /* release HW resources if needed */ > + rproc_unprepare_device(rproc); > + > rproc_disable_iommu(rproc); > > /* Free the copy of the resource table */ > diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h > index b389dc79da81..101e6be8d240 100644 > --- a/drivers/remoteproc/remoteproc_internal.h > +++ b/drivers/remoteproc/remoteproc_internal.h > @@ -64,6 +64,22 @@ struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, > struct rproc_mem_entry * > rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...); > > +static inline int rproc_prepare_device(struct rproc *rproc) > +{ > + if (rproc->ops->prepare) > + return rproc->ops->prepare(rproc); > + > + return 0; > +} > + > +static inline int rproc_unprepare_device(struct rproc *rproc) > +{ > + if (rproc->ops->unprepare) > + return rproc->ops->unprepare(rproc); > + > + return 0; > +} > + > static inline > int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) > { > diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h > index 38607107b7cb..b8481ac969f1 100644 > --- a/include/linux/remoteproc.h > +++ b/include/linux/remoteproc.h > @@ -355,6 +355,8 @@ enum rsc_handling_status { > > /** > * struct rproc_ops - platform-specific device handlers > + * @prepare: prepare device for code loading > + * @unprepare: unprepare device after stop > * @start: power on the device and boot it > * @stop: power off the device > * @kick: kick a virtqueue (virtqueue id given as a parameter) > @@ -373,6 +375,8 @@ enum rsc_handling_status { > * panic at least the returned number of milliseconds > */ > struct rproc_ops { > + int (*prepare)(struct rproc *rproc); > + int (*unprepare)(struct rproc *rproc); > int (*start)(struct rproc *rproc); > int (*stop)(struct rproc *rproc); > void (*kick)(struct rproc *rproc, int vqid); > -- > 2.26.0 >