Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4541711ybz; Tue, 28 Apr 2020 13:15:23 -0700 (PDT) X-Google-Smtp-Source: APiQypIAxscBSSC3NzdlITOcdKnVzsskBEwPhcdV5WJXtFnHON6QFolKiJ9g/NbpULdRVEyR4u/c X-Received: by 2002:a17:906:340a:: with SMTP id c10mr26783632ejb.218.1588104923156; Tue, 28 Apr 2020 13:15:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588104923; cv=none; d=google.com; s=arc-20160816; b=dksyQs6e4O0pu99IFgNDbySRNJw8Iu0ssKRNPPrz33Euqtop+55EUm25jhVZnmeNi1 ypMrIsR+Am62uBB2sGEfNRUhZa0wLD49TVSZ5kauUJiUkcsZG4GWFx/SlA2ng0tDmy0T cz5NL/5lBDlMTsOViU5Hys3Z7+IqXs999Pz3/z5tkX783vV9OR60PeAWGGA4VDmJWaT1 aD01Dl50or6RDyyYtrpAPk0D2krx7lOfUdhUyBgrr76XpkULsueSA4Md3EXZRZTW1xZ9 SeQ5BxNM9cowwGuDl+3hn15vJOL/e/0U77sUHnWNuWZuJZkYEe7BSX4ipJR1raR/5Uy4 pang== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=6b8JEdc86QQaLWgUONgVk5QnyKn0OwJfe4nUlQTwps0=; b=HSzyL7zze/7iZ7w0ZcCWp9cppyBvvcy/qAl0RDkfmekyRRjLKiC2727sUfo65pNQIT 5q8jT/kCGjTJIQNqaeTyfRnlMXje28mqFIvIskM9nSpu8NHgNuNiNwk+g1xvXqm0b3bl tjDg39f10Wt+eZSmLJR/Fw1nprYabul5VTBxuvvng47vzX9pt+6b2k9J6wO26ZwgLDSu 5vcahyMUXgNM12FaUR/fgswQSBS4dGD5yg/HY/uQqKVsFpT+ubsCxNTlWQ80ROTwLQdk JqsEOyt3UQbEQhPuDR1V9/lEz/f6f08YvtODT2fedxTDH6+dTADnrC/Av0ehnLAxTge7 oO6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d3Lktalo; 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 cc27si2668867edb.544.2020.04.28.13.14.45; Tue, 28 Apr 2020 13:15:23 -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=d3Lktalo; 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 S1726488AbgD1UJm (ORCPT + 99 others); Tue, 28 Apr 2020 16:09:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726412AbgD1UJZ (ORCPT ); Tue, 28 Apr 2020 16:09:25 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC74DC03C1AC for ; Tue, 28 Apr 2020 13:09:24 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id f3so24747263ioj.1 for ; Tue, 28 Apr 2020 13:09:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6b8JEdc86QQaLWgUONgVk5QnyKn0OwJfe4nUlQTwps0=; b=d3LktalotbLI0rJhUPptVS5m6TeC3T7IVM9AmAJQcKzSqXkCYx4sHzfZBRXBWNrhJ9 nChBqVreBXCMxoNCEjAdTXCR1vRzfCytEZUtf13z9oltklrIDGVULrwgUMUto7+0T9eP 0tAKMU6ESdpJJtGA7/8moPsY9glywvT/o6LZIGOKLkAUj+DSnUNkiSLG/haa3Vu9JQSt XZT9vMf6gbkocCwqFSitNVkd2Xqvyt4YOII+8CJDtXjmcZbbo2a9JtwVOsVq9az4EJs+ jOBj56RrVFe/Zh/Ev3wvJuYasVOlY0KYDQx3OsfEiC5t6GDwauOkY9EpJBKZdEGwt0Gx EYUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6b8JEdc86QQaLWgUONgVk5QnyKn0OwJfe4nUlQTwps0=; b=oj8hadvvJHvi+zQ0cCm93ON9ut1ADiurOmDV4guTs4zwJx2B1b0eGCX7ZYh//z40ve smcZTLtRuHy3FzIzgVycGR2fcudrAB+Jqki1hfClySQKxv+qYZIqeLaywuw/cjE57yWw 3kz2BMdfz0SpvU+qiby9Ef5XDZcTnGb8OkBGBf2bzYKSIVQwnx4tM9qxVuPzKpdwztr1 65svDG3/5t7Photop3Y4yjNhdVKH++xjxv4488Npqphcz5EktnZgfitdjbxzj0hkhra8 04bD2NdUl2HKvyf7N066B8X7jdwOsySJx6z+BUCRJABfVfBDBKhYdkC6KUapvzQXzi1r guOg== X-Gm-Message-State: AGi0PuZYtSE5NourLISD7/wpwISWj0Qk11CrAzn3xobNGHLS5rsDWpVB c9J/7W17+mG/+DjNEAC6U9u5X2szY5i4htq2tGjdGMuf X-Received: by 2002:a02:b88e:: with SMTP id p14mr25945179jam.36.1588104563944; Tue, 28 Apr 2020 13:09:23 -0700 (PDT) MIME-Version: 1.0 References: <20200325201839.15896-1-s-anna@ti.com> <20200325201839.15896-4-s-anna@ti.com> <20200428195855.GC10552@xps15> In-Reply-To: <20200428195855.GC10552@xps15> From: Mathieu Poirier Date: Tue, 28 Apr 2020 14:09:13 -0600 Message-ID: Subject: Re: [PATCH 3/3] remoteproc/k3-dsp: Add support for L2RAM loading on C66x DSPs To: Suman Anna Cc: Bjorn Andersson , Rob Herring , Lokesh Vutla , linux-remoteproc , devicetree@vger.kernel.org, linux-arm-kernel , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 28 Apr 2020 at 13:58, Mathieu Poirier wrote: > > On Wed, Mar 25, 2020 at 03:18:39PM -0500, Suman Anna wrote: > > The resets for the DSP processors on K3 SoCs are managed through the > > Power and Sleep Controller (PSC) module. Each DSP typically has two > > resets - a global module reset for powering on the device, and a local > > reset that affects only the CPU while allowing access to the other > > sub-modules within the DSP processor sub-systems. > > > > The C66x DSPs have two levels of internal RAMs that can be used to > > boot from, and the firmware loading into these RAMs require the > > local reset to be asserted with the device powered on/enabled using > > the module reset. Enhance the K3 DSP remoteproc driver to add support > > for loading into the internal RAMs. The local reset is deasserted on > > SoC power-on-reset, so logic has to be added in probe in remoteproc > > mode to balance the remoteproc state-machine. > > > > Note that the local resets are a no-op on C71x cores, and the hardware > > does not supporting loading into its internal RAMs. > > > > Signed-off-by: Suman Anna > > --- > > drivers/remoteproc/ti_k3_dsp_remoteproc.c | 82 +++++++++++++++++++++++ > > 1 file changed, 82 insertions(+) > > > > diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c > > index fd0d84f46f90..7b712ef74611 100644 > > --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c > > +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c > > @@ -175,6 +175,9 @@ static int k3_dsp_rproc_reset(struct k3_dsp_rproc *kproc) > > return ret; > > } > > > > + if (kproc->data->uses_lreset) > > + return ret; > > + > > ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, > > kproc->ti_sci_id); > > if (ret) { > > @@ -192,6 +195,9 @@ static int k3_dsp_rproc_release(struct k3_dsp_rproc *kproc) > > struct device *dev = kproc->dev; > > int ret; > > > > + if (kproc->data->uses_lreset) > > + goto lreset; > > + > > ret = kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci, > > kproc->ti_sci_id); > > if (ret) { > > @@ -199,6 +205,7 @@ static int k3_dsp_rproc_release(struct k3_dsp_rproc *kproc) > > return ret; > > } > > > > +lreset: > > ret = reset_control_deassert(kproc->reset); > > if (ret) { > > dev_err(dev, "local-reset deassert failed, ret = %d\n", ret); > > @@ -210,6 +217,63 @@ static int k3_dsp_rproc_release(struct k3_dsp_rproc *kproc) > > return ret; > > } > > > > +/* > > + * The C66x DSP cores have a local reset that affects only the CPU, and a > > + * generic module reset that powers on the device and allows the DSP internal > > + * memories to be accessed while the local reset is asserted. This function is > > + * used to release the global reset on C66x DSPs to allow loading into the DSP > > + * internal RAMs. The .prepare() ops is invoked by remoteproc core before any > > + * firmware loading, and is followed by the .start() ops after loading to > > + * actually let the C66x DSP cores run. The local reset on C71x cores is a > > + * no-op and the global reset cannot be released on C71x cores until after > > + * the firmware images are loaded, so this function does nothing for C71x cores. > > + */ > > +static int k3_dsp_rproc_prepare(struct rproc *rproc) > > +{ > > + struct k3_dsp_rproc *kproc = rproc->priv; > > + struct device *dev = kproc->dev; > > + int ret; > > + > > + /* local reset is no-op on C71x processors */ > > + if (!kproc->data->uses_lreset) > > + return 0; > > In k3_dsp_rproc_release() the condition is "if (kproc->data->uses_lreset)" and > here it is the opposite, which did a good job at getting me confused. > > Taking a step back, I assume c71 DSPs will have their own k3_dsp_dev_data where > the users_lreset flag will be false. In that case I think it would make the > code easier to understand if the k3_dsp_rproc_ops was declared without the > .prepare and .unprepare. In probe(), if data->uses_lreset is true then > k3_dsp_rproc_prepare() and k3_dsp_rproc_unprepare() are set. > I forgot... Since this is a C71 related change, was there a reason to lump it with the C66 set? If not I would simply move that to the C71 work. > I am done reviewing this set. > > Thanks, > Mathieu > > > + > > + ret = kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci, > > + kproc->ti_sci_id); > > + if (ret) > > + dev_err(dev, "module-reset deassert failed, cannot enable internal RAM loading, ret = %d\n", > > + ret); > > + > > + return ret; > > +} > > + > > +/* > > + * This function implements the .unprepare() ops and performs the complimentary > > + * operations to that of the .prepare() ops. The function is used to assert the > > + * global reset on applicable C66x cores. This completes the second portion of > > + * powering down the C66x DSP cores. The cores themselves are only halted in the > > + * .stop() callback through the local reset, and the .unprepare() ops is invoked > > + * by the remoteproc core after the remoteproc is stopped to balance the global > > + * reset. > > + */ > > +static int k3_dsp_rproc_unprepare(struct rproc *rproc) > > +{ > > + struct k3_dsp_rproc *kproc = rproc->priv; > > + struct device *dev = kproc->dev; > > + int ret; > > + > > + /* local reset is no-op on C71x processors */ > > + if (!kproc->data->uses_lreset) > > + return 0; > > + > > + ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, > > + kproc->ti_sci_id); > > + if (ret) > > + dev_err(dev, "module-reset assert failed, ret = %d\n", ret); > > + > > + return ret; > > +} > > + > > /* > > * Power up the DSP remote processor. > > * > > @@ -353,6 +417,8 @@ static void *k3_dsp_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len) > > } > > > > static const struct rproc_ops k3_dsp_rproc_ops = { > > + .prepare = k3_dsp_rproc_prepare, > > + .unprepare = k3_dsp_rproc_unprepare, > > .start = k3_dsp_rproc_start, > > .stop = k3_dsp_rproc_stop, > > .kick = k3_dsp_rproc_kick, > > @@ -644,6 +710,22 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) > > goto disable_clk; > > } > > > > + /* > > + * ensure the DSP local reset is asserted to ensure the DSP doesn't > > + * execute bogus code in .prepare() when the module reset is released. > > + */ > > + if (data->uses_lreset) { > > + ret = reset_control_status(kproc->reset); > > + if (ret < 0) { > > + dev_err(dev, "failed to get reset status, status = %d\n", > > + ret); > > + goto release_mem; > > + } else if (ret == 0) { > > + dev_warn(dev, "local reset is deasserted for device\n"); > > + k3_dsp_rproc_reset(kproc); > > + } > > + } > > + > > ret = rproc_add(rproc); > > if (ret) { > > dev_err(dev, "failed to add register device with remoteproc core, status = %d\n", > > -- > > 2.23.0 > >