From: Frank Li <Frank.li@nxp.com>
To: Rob Herring <robh@kernel.org>
Cc: "Tomeu Vizoso" <tomeu@tomeuvizoso.net>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Oded Gabbay" <ogabbay@kernel.org>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
"Robin Murphy" <robin.murphy@arm.com>,
"Steven Price" <steven.price@arm.com>,
"Daniel Stone" <daniel@fooishbar.org>,
"Sui Jingfeng" <sui.jingfeng@linux.dev>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org,
linaro-mm-sig@lists.linaro.org
Subject: Re: [PATCH v4 2/2] accel: Add Arm Ethos-U NPU driver
Date: Thu, 16 Oct 2025 10:48:00 -0400 [thread overview]
Message-ID: <aPEFoDrTBxH7Y2FL@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <CAL_Jsq+sEYztJKdD0t8uPwwv1uKk_tac3MqQMUgxfrRjRZmz4A@mail.gmail.com>
On Thu, Oct 16, 2025 at 07:35:06AM -0500, Rob Herring wrote:
> On Wed, Oct 15, 2025 at 4:02 PM Frank Li <Frank.li@nxp.com> wrote:
> >
> > On Wed, Oct 15, 2025 at 03:36:05PM -0500, Rob Herring wrote:
> > > On Wed, Oct 15, 2025 at 2:39 PM Frank Li <Frank.li@nxp.com> wrote:
> > > >
> > > > On Wed, Oct 15, 2025 at 12:47:40PM -0500, Rob Herring (Arm) wrote:
> > > > > Add a driver for Arm Ethos-U65/U85 NPUs. The Ethos-U NPU has a
> > > > > relatively simple interface with single command stream to describe
> > > > > buffers, operation settings, and network operations. It supports up to 8
> > > > > memory regions (though no h/w bounds on a region). The Ethos NPUs
> > > > > are designed to use an SRAM for scratch memory. Region 2 is reserved
> > > > > for SRAM (like the downstream driver stack and compiler). Userspace
> > > > > doesn't need access to the SRAM.
>
> > > > > +static int ethosu_init(struct ethosu_device *ethosudev)
> > > > > +{
> > > > > + int ret;
> > > > > + u32 id, config;
> > > > > +
> > > > > + ret = devm_pm_runtime_enable(ethosudev->base.dev);
> > > > > + if (ret)
> > > > > + return ret;
> > > > > +
> > > > > + ret = pm_runtime_resume_and_get(ethosudev->base.dev);
> > > > > + if (ret)
> > > > > + return ret;
> > > > > +
> > > > > + pm_runtime_set_autosuspend_delay(ethosudev->base.dev, 50);
> > > > > + pm_runtime_use_autosuspend(ethosudev->base.dev);
> > > > > +
> > > > > + /* If PM is disabled, we need to call ethosu_device_resume() manually. */
> > > > > + if (!IS_ENABLED(CONFIG_PM)) {
> > > > > + ret = ethosu_device_resume(ethosudev->base.dev);
> > > > > + if (ret)
> > > > > + return ret;
> > > > > + }
> > > >
> > > > I think it should call ethosu_device_resume() unconditional before
> > > > devm_pm_runtime_enable();
> > > >
> > > > ethosu_device_resume();
> > > > pm_runtime_set_active();
> > > > pm_runtime_set_autosuspend_delay(ethosudev->base.dev, 50);
> > > > devm_pm_runtime_enable();
> > >
> > > Why do you think this? Does this do a get?
> > >
> > > I don't think it is good to call the resume hook on our own, but we
> > > have no choice with !CONFIG_PM. With CONFIG_PM, we should only use the
> > > pm_runtime API.
> >
> > Enable clock and do some init work at probe() is quite common. But I never
> > seen IS_ENABLED(CONFIG_PM) check. It is quite weird and not necessary to
> > check CONFIG_PM flags. The most CONFIG_PM is enabled, so the branch !CONFIG_PM
> > almost never tested.
>
> Okay, I get what you meant.
>
> >
> > probe()
> > {
> > devm_clk_bulk_get_all_enabled();
> >
> > ... did some init work
> >
> > pm_runtime_set_active();
> > devm_pm_runtime_enable();
> >
> > ...
> > pm_runtime_put_autosuspend(ethosudev->base.dev);
> > }
>
> I think we still need a pm_runtime_get_noresume() in here since we do
> a put later on. Here's what I have now:
>
> ret = ethosu_device_resume(ethosudev->base.dev);
> if (ret)
> return ret;
>
> pm_runtime_set_autosuspend_delay(ethosudev->base.dev, 50);
> pm_runtime_use_autosuspend(ethosudev->base.dev);
> ret = devm_pm_runtime_set_active_enabled(ethosudev->base.dev);
> if (ret)
> return ret;
> pm_runtime_get_noresume(ethosudev->base.dev);
Look good.
Frank
>
>
> Rob
next prev parent reply other threads:[~2025-10-16 14:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 17:47 [PATCH v4 0/2] accel: Add Arm Ethos-U NPU Rob Herring (Arm)
2025-10-15 17:47 ` [PATCH v4 1/2] dt-bindings: npu: Add Arm Ethos-U65/U85 Rob Herring (Arm)
2025-10-15 17:47 ` [PATCH v4 2/2] accel: Add Arm Ethos-U NPU driver Rob Herring (Arm)
2025-10-15 19:39 ` Frank Li
2025-10-15 20:36 ` Rob Herring
2025-10-15 21:02 ` Frank Li
2025-10-16 12:35 ` Rob Herring
2025-10-16 14:48 ` Frank Li [this message]
2025-10-15 17:53 ` [PATCH v4 0/2] accel: Add Arm Ethos-U NPU Tomeu Vizoso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aPEFoDrTBxH7Y2FL@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=airlied@gmail.com \
--cc=christian.koenig@amd.com \
--cc=conor+dt@kernel.org \
--cc=daniel@fooishbar.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=krzk+dt@kernel.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=ogabbay@kernel.org \
--cc=robh@kernel.org \
--cc=robin.murphy@arm.com \
--cc=simona@ffwll.ch \
--cc=steven.price@arm.com \
--cc=sui.jingfeng@linux.dev \
--cc=sumit.semwal@linaro.org \
--cc=tomeu@tomeuvizoso.net \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox