* [PATCH] drm/imagination: properly support stopping LAYOUT_MARS = 1 cores
@ 2024-08-11 8:28 Icenowy Zheng
2024-09-02 9:24 ` Matt Coster
0 siblings, 1 reply; 3+ messages in thread
From: Icenowy Zheng @ 2024-08-11 8:28 UTC (permalink / raw)
To: Frank Binns, Matt Coster
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Daniel Vetter, dri-devel, linux-kernel,
Icenowy Zheng
Some new Rogue GPU cores have an extra MARS power domain, which
controlls the power of the firmware core and allows the firmware core to
power down most parts of the GPU.
Adapt to this by ignoring power domains that should be powered down by
the fiwmare and checking MARS idle status instead.
The logic mimics RGXStop() function in the DDK kernel mode source code.
Tested on BXE-4-32 (36.50.54.182) with firmware build 6503725 OS provided
by Imagination Technologies.
Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
---
.../gpu/drm/imagination/pvr_fw_startstop.c | 49 +++++++++++++------
1 file changed, 35 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/imagination/pvr_fw_startstop.c b/drivers/gpu/drm/imagination/pvr_fw_startstop.c
index 159a4c3dd65b..4301a7aded64 100644
--- a/drivers/gpu/drm/imagination/pvr_fw_startstop.c
+++ b/drivers/gpu/drm/imagination/pvr_fw_startstop.c
@@ -201,19 +201,28 @@ pvr_fw_stop(struct pvr_device *pvr_dev)
~(ROGUE_CR_SIDEKICK_IDLE_GARTEN_EN |
ROGUE_CR_SIDEKICK_IDLE_SOCIF_EN |
ROGUE_CR_SIDEKICK_IDLE_HOSTIF_EN);
+ const u32 mars_idle_mask = ROGUE_CR_MARS_IDLE_CPU_EN |
+ ROGUE_CR_MARS_IDLE_MH_SYSARB0_EN;
bool skip_garten_idle = false;
+ u32 mars = 0;
u32 reg_value;
int err;
+ if (PVR_HAS_FEATURE(pvr_dev, layout_mars))
+ PVR_FEATURE_VALUE(pvr_dev, layout_mars, &mars);
+
/*
* Wait for Sidekick/Jones to signal IDLE except for the Garten Wrapper.
* For cores with the LAYOUT_MARS feature, SIDEKICK would have been
* powered down by the FW.
*/
- err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SIDEKICK_IDLE, sidekick_idle_mask,
- sidekick_idle_mask, POLL_TIMEOUT_USEC);
- if (err)
- return err;
+ if (mars) {
+ err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SIDEKICK_IDLE,
+ sidekick_idle_mask,
+ sidekick_idle_mask, POLL_TIMEOUT_USEC);
+ if (err)
+ return err;
+ }
/* Unset MTS DM association with threads. */
pvr_cr_write32(pvr_dev, ROGUE_CR_MTS_INTCTX_THREAD0_DM_ASSOC,
@@ -267,21 +276,27 @@ pvr_fw_stop(struct pvr_device *pvr_dev)
* For cores with the LAYOUT_MARS feature, SLC would have been powered
* down by the FW.
*/
- err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SLC_IDLE,
- ROGUE_CR_SLC_IDLE_MASKFULL,
- ROGUE_CR_SLC_IDLE_MASKFULL, POLL_TIMEOUT_USEC);
- if (err)
- return err;
+ if (mars) {
+ err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SLC_IDLE,
+ ROGUE_CR_SLC_IDLE_MASKFULL,
+ ROGUE_CR_SLC_IDLE_MASKFULL,
+ POLL_TIMEOUT_USEC);
+ if (err)
+ return err;
+ }
/*
* Wait for Sidekick/Jones to signal IDLE except for the Garten Wrapper.
* For cores with the LAYOUT_MARS feature, SIDEKICK would have been powered
* down by the FW.
*/
- err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SIDEKICK_IDLE, sidekick_idle_mask,
- sidekick_idle_mask, POLL_TIMEOUT_USEC);
- if (err)
- return err;
+ if (mars) {
+ err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SIDEKICK_IDLE,
+ sidekick_idle_mask,
+ sidekick_idle_mask, POLL_TIMEOUT_USEC);
+ if (err)
+ return err;
+ }
if (pvr_dev->fw_dev.processor_type == PVR_FW_PROCESSOR_TYPE_META) {
err = pvr_meta_cr_read32(pvr_dev, META_CR_TxVECINT_BHALT, ®_value);
@@ -297,7 +312,13 @@ pvr_fw_stop(struct pvr_device *pvr_dev)
skip_garten_idle = true;
}
- if (!skip_garten_idle) {
+ if (mars) {
+ err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_MARS_IDLE,
+ mars_idle_mask, mars_idle_mask,
+ POLL_TIMEOUT_USEC);
+ if (err)
+ return err;
+ } else if (!skip_garten_idle) {
err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SIDEKICK_IDLE,
ROGUE_CR_SIDEKICK_IDLE_GARTEN_EN,
ROGUE_CR_SIDEKICK_IDLE_GARTEN_EN,
--
2.46.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/imagination: properly support stopping LAYOUT_MARS = 1 cores
2024-08-11 8:28 [PATCH] drm/imagination: properly support stopping LAYOUT_MARS = 1 cores Icenowy Zheng
@ 2024-09-02 9:24 ` Matt Coster
2024-09-02 13:39 ` Icenowy Zheng
0 siblings, 1 reply; 3+ messages in thread
From: Matt Coster @ 2024-09-02 9:24 UTC (permalink / raw)
To: Icenowy Zheng, dri-devel, linux-kernel
Cc: Frank Binns, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Daniel Vetter
[-- Attachment #1.1: Type: text/plain, Size: 4565 bytes --]
On 11/08/2024 09:28, Icenowy Zheng wrote:
> Some new Rogue GPU cores have an extra MARS power domain, which
> controlls the power of the firmware core and allows the firmware core to
> power down most parts of the GPU.
>
> Adapt to this by ignoring power domains that should be powered down by
> the fiwmare and checking MARS idle status instead.
>
> The logic mimics RGXStop() function in the DDK kernel mode source code.
>
> Tested on BXE-4-32 (36.50.54.182) with firmware build 6503725 OS provided
> by Imagination Technologies.
>
> Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Hi Icenowy,
Thanks for the patch! It's great to see people getting involved in
getting this driver working on more platforms.
> ---
> .../gpu/drm/imagination/pvr_fw_startstop.c | 49 +++++++++++++------
> 1 file changed, 35 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/imagination/pvr_fw_startstop.c b/drivers/gpu/drm/imagination/pvr_fw_startstop.c
> index 159a4c3dd65b..4301a7aded64 100644
> --- a/drivers/gpu/drm/imagination/pvr_fw_startstop.c
> +++ b/drivers/gpu/drm/imagination/pvr_fw_startstop.c
> @@ -201,19 +201,28 @@ pvr_fw_stop(struct pvr_device *pvr_dev)
> ~(ROGUE_CR_SIDEKICK_IDLE_GARTEN_EN |
> ROGUE_CR_SIDEKICK_IDLE_SOCIF_EN |
> ROGUE_CR_SIDEKICK_IDLE_HOSTIF_EN);
> + const u32 mars_idle_mask = ROGUE_CR_MARS_IDLE_CPU_EN |
> + ROGUE_CR_MARS_IDLE_MH_SYSARB0_EN;
> bool skip_garten_idle = false;
> + u32 mars = 0;
> u32 reg_value;
> int err;
>
> + if (PVR_HAS_FEATURE(pvr_dev, layout_mars))
> + PVR_FEATURE_VALUE(pvr_dev, layout_mars, &mars);
> +
This check is unnecessary – the PVR_FEATURE_VALUE() macro already checks
for the feature presence internally and doesn't change the output value
if it's not present.
> /*
> * Wait for Sidekick/Jones to signal IDLE except for the Garten Wrapper.
> * For cores with the LAYOUT_MARS feature, SIDEKICK would have been
> * powered down by the FW.
> */
> - err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SIDEKICK_IDLE, sidekick_idle_mask,
> - sidekick_idle_mask, POLL_TIMEOUT_USEC);
> - if (err)
> - return err;
> + if (mars) {
I think you might have these conditionals backwards. This is saying we
need to touch sidekick iff mars is present, but the comments say this is
the other way around (mars takes care of powering sidekick, so we don't
need to).
Cheers,
Matt
> + err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SIDEKICK_IDLE,
> + sidekick_idle_mask,
> + sidekick_idle_mask, POLL_TIMEOUT_USEC);
> + if (err)
> + return err;
> + }
>
> /* Unset MTS DM association with threads. */
> pvr_cr_write32(pvr_dev, ROGUE_CR_MTS_INTCTX_THREAD0_DM_ASSOC,
> @@ -267,21 +276,27 @@ pvr_fw_stop(struct pvr_device *pvr_dev)
> * For cores with the LAYOUT_MARS feature, SLC would have been powered
> * down by the FW.
> */
> - err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SLC_IDLE,
> - ROGUE_CR_SLC_IDLE_MASKFULL,
> - ROGUE_CR_SLC_IDLE_MASKFULL, POLL_TIMEOUT_USEC);
> - if (err)
> - return err;
> + if (mars) {
> + err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SLC_IDLE,
> + ROGUE_CR_SLC_IDLE_MASKFULL,
> + ROGUE_CR_SLC_IDLE_MASKFULL,
> + POLL_TIMEOUT_USEC);
> + if (err)
> + return err;
> + }
>
> /*
> * Wait for Sidekick/Jones to signal IDLE except for the Garten Wrapper.
> * For cores with the LAYOUT_MARS feature, SIDEKICK would have been powered
> * down by the FW.
> */
> - err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SIDEKICK_IDLE, sidekick_idle_mask,
> - sidekick_idle_mask, POLL_TIMEOUT_USEC);
> - if (err)
> - return err;
> + if (mars) {
> + err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SIDEKICK_IDLE,
> + sidekick_idle_mask,
> + sidekick_idle_mask, POLL_TIMEOUT_USEC);
> + if (err)
> + return err;
> + }
>
> if (pvr_dev->fw_dev.processor_type == PVR_FW_PROCESSOR_TYPE_META) {
> err = pvr_meta_cr_read32(pvr_dev, META_CR_TxVECINT_BHALT, ®_value);
> @@ -297,7 +312,13 @@ pvr_fw_stop(struct pvr_device *pvr_dev)
> skip_garten_idle = true;
> }
>
> - if (!skip_garten_idle) {
> + if (mars) {
> + err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_MARS_IDLE,
> + mars_idle_mask, mars_idle_mask,
> + POLL_TIMEOUT_USEC);
> + if (err)
> + return err;
> + } else if (!skip_garten_idle) {
> err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SIDEKICK_IDLE,
> ROGUE_CR_SIDEKICK_IDLE_GARTEN_EN,
> ROGUE_CR_SIDEKICK_IDLE_GARTEN_EN,
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/imagination: properly support stopping LAYOUT_MARS = 1 cores
2024-09-02 9:24 ` Matt Coster
@ 2024-09-02 13:39 ` Icenowy Zheng
0 siblings, 0 replies; 3+ messages in thread
From: Icenowy Zheng @ 2024-09-02 13:39 UTC (permalink / raw)
To: Matt Coster, dri-devel, linux-kernel
Cc: Frank Binns, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Daniel Vetter
在 2024-09-02星期一的 09:24 +0000,Matt Coster写道:
> On 11/08/2024 09:28, Icenowy Zheng wrote:
> > Some new Rogue GPU cores have an extra MARS power domain, which
> > controlls the power of the firmware core and allows the firmware
> > core to
> > power down most parts of the GPU.
> >
> > Adapt to this by ignoring power domains that should be powered down
> > by
> > the fiwmare and checking MARS idle status instead.
> >
> > The logic mimics RGXStop() function in the DDK kernel mode source
> > code.
> >
> > Tested on BXE-4-32 (36.50.54.182) with firmware build 6503725 OS
> > provided
> > by Imagination Technologies.
> >
> > Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
>
> Hi Icenowy,
>
> Thanks for the patch! It's great to see people getting involved in
> getting this driver working on more platforms.
>
> > ---
> > .../gpu/drm/imagination/pvr_fw_startstop.c | 49 +++++++++++++--
> > ----
> > 1 file changed, 35 insertions(+), 14 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/imagination/pvr_fw_startstop.c
> > b/drivers/gpu/drm/imagination/pvr_fw_startstop.c
> > index 159a4c3dd65b..4301a7aded64 100644
> > --- a/drivers/gpu/drm/imagination/pvr_fw_startstop.c
> > +++ b/drivers/gpu/drm/imagination/pvr_fw_startstop.c
> > @@ -201,19 +201,28 @@ pvr_fw_stop(struct pvr_device *pvr_dev)
> >
> > ~(ROGUE_CR_SIDEKICK_IDLE_GARTEN_EN |
> >
> > ROGUE_CR_SIDEKICK_IDLE_SOCIF_EN |
> >
> > ROGUE_CR_SIDEKICK_IDLE_HOSTIF_EN);
> > + const u32 mars_idle_mask = ROGUE_CR_MARS_IDLE_CPU_EN |
> > +
> > ROGUE_CR_MARS_IDLE_MH_SYSARB0_EN;
> > bool skip_garten_idle = false;
> > + u32 mars = 0;
> > u32 reg_value;
> > int err;
> >
> > + if (PVR_HAS_FEATURE(pvr_dev, layout_mars))
> > + PVR_FEATURE_VALUE(pvr_dev, layout_mars, &mars);
> > +
>
> This check is unnecessary – the PVR_FEATURE_VALUE() macro already
> checks
> for the feature presence internally and doesn't change the output
> value
> if it's not present.
>
> > /*
> > * Wait for Sidekick/Jones to signal IDLE except for the
> > Garten Wrapper.
> > * For cores with the LAYOUT_MARS feature, SIDEKICK would
> > have been
> > * powered down by the FW.
> > */
> > - err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SIDEKICK_IDLE,
> > sidekick_idle_mask,
> > - sidekick_idle_mask,
> > POLL_TIMEOUT_USEC);
> > - if (err)
> > - return err;
> > + if (mars) {
>
> I think you might have these conditionals backwards. This is saying
> we
> need to touch sidekick iff mars is present, but the comments say this
> is
> the other way around (mars takes care of powering sidekick, so we
> don't
> need to).
Thanks for this tip. I am thinking I got this wrong too, so I am going
to change this.
>
> Cheers,
> Matt
>
> > + err = pvr_cr_poll_reg32(pvr_dev,
> > ROGUE_CR_SIDEKICK_IDLE,
> > + sidekick_idle_mask,
> > + sidekick_idle_mask,
> > POLL_TIMEOUT_USEC);
> > + if (err)
> > + return err;
> > + }
> >
> > /* Unset MTS DM association with threads. */
> > pvr_cr_write32(pvr_dev,
> > ROGUE_CR_MTS_INTCTX_THREAD0_DM_ASSOC,
> > @@ -267,21 +276,27 @@ pvr_fw_stop(struct pvr_device *pvr_dev)
> > * For cores with the LAYOUT_MARS feature, SLC would have
> > been powered
> > * down by the FW.
> > */
> > - err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SLC_IDLE,
> > - ROGUE_CR_SLC_IDLE_MASKFULL,
> > - ROGUE_CR_SLC_IDLE_MASKFULL,
> > POLL_TIMEOUT_USEC);
> > - if (err)
> > - return err;
> > + if (mars) {
> > + err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SLC_IDLE,
> > + ROGUE_CR_SLC_IDLE_MASKFULL,
> > + ROGUE_CR_SLC_IDLE_MASKFULL,
> > + POLL_TIMEOUT_USEC);
> > + if (err)
> > + return err;
> > + }
> >
> > /*
> > * Wait for Sidekick/Jones to signal IDLE except for the
> > Garten Wrapper.
> > * For cores with the LAYOUT_MARS feature, SIDEKICK would
> > have been powered
> > * down by the FW.
> > */
> > - err = pvr_cr_poll_reg32(pvr_dev, ROGUE_CR_SIDEKICK_IDLE,
> > sidekick_idle_mask,
> > - sidekick_idle_mask,
> > POLL_TIMEOUT_USEC);
> > - if (err)
> > - return err;
> > + if (mars) {
> > + err = pvr_cr_poll_reg32(pvr_dev,
> > ROGUE_CR_SIDEKICK_IDLE,
> > + sidekick_idle_mask,
> > + sidekick_idle_mask,
> > POLL_TIMEOUT_USEC);
> > + if (err)
> > + return err;
> > + }
> >
> > if (pvr_dev->fw_dev.processor_type ==
> > PVR_FW_PROCESSOR_TYPE_META) {
> > err = pvr_meta_cr_read32(pvr_dev,
> > META_CR_TxVECINT_BHALT, ®_value);
> > @@ -297,7 +312,13 @@ pvr_fw_stop(struct pvr_device *pvr_dev)
> > skip_garten_idle = true;
> > }
> >
> > - if (!skip_garten_idle) {
> > + if (mars) {
> > + err = pvr_cr_poll_reg32(pvr_dev,
> > ROGUE_CR_MARS_IDLE,
> > + mars_idle_mask,
> > mars_idle_mask,
> > + POLL_TIMEOUT_USEC);
> > + if (err)
> > + return err;
> > + } else if (!skip_garten_idle) {
> > err = pvr_cr_poll_reg32(pvr_dev,
> > ROGUE_CR_SIDEKICK_IDLE,
> > ROGUE_CR_SIDEKICK_IDLE_GART
> > EN_EN,
> > ROGUE_CR_SIDEKICK_IDLE_GART
> > EN_EN,
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-02 13:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-11 8:28 [PATCH] drm/imagination: properly support stopping LAYOUT_MARS = 1 cores Icenowy Zheng
2024-09-02 9:24 ` Matt Coster
2024-09-02 13:39 ` Icenowy Zheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®