diff mbox

[47/51] drm/i915: Update ironlake_enable_rc6() to do explicit request management

Message ID 1423828140-10653-48-git-send-email-John.C.Harrison@Intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

John Harrison Feb. 13, 2015, 11:48 a.m. UTC
From: John Harrison <John.C.Harrison@Intel.com>

Updated ironlake_enable_rc6() to do explicit request creation and submission.

For: VIZ-5115
Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
---
 drivers/gpu/drm/i915/intel_pm.c |   31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

Comments

Chris Wilson Feb. 13, 2015, 12:19 p.m. UTC | #1
On Fri, Feb 13, 2015 at 11:48:56AM +0000, John.C.Harrison@Intel.com wrote:
> From: John Harrison <John.C.Harrison@Intel.com>
> 
> Updated ironlake_enable_rc6() to do explicit request creation and submission.

If you merged the context here with the common context switching code,
we don't even need to touch the ring here.
-Chris
John Harrison Feb. 13, 2015, 4:58 p.m. UTC | #2
On 13/02/2015 12:19, Chris Wilson wrote:
> On Fri, Feb 13, 2015 at 11:48:56AM +0000, John.C.Harrison@Intel.com wrote:
>> From: John Harrison <John.C.Harrison@Intel.com>
>>
>> Updated ironlake_enable_rc6() to do explicit request creation and submission.
> If you merged the context here with the common context switching code,
> we don't even need to touch the ring here.
> -Chris
>
It would certainly be preferable to not have any ring commands written 
from deep within the power management code. However, I didn't want to 
change anything I didn't really need to, especially in code that I'm not 
at all sure about. Plus I don't have an ironlake to test any significant 
change on.
Chris Wilson Feb. 13, 2015, 5:03 p.m. UTC | #3
On Fri, Feb 13, 2015 at 04:58:24PM +0000, John Harrison wrote:
> On 13/02/2015 12:19, Chris Wilson wrote:
> >On Fri, Feb 13, 2015 at 11:48:56AM +0000, John.C.Harrison@Intel.com wrote:
> >>From: John Harrison <John.C.Harrison@Intel.com>
> >>
> >>Updated ironlake_enable_rc6() to do explicit request creation and submission.
> >If you merged the context here with the common context switching code,
> >we don't even need to touch the ring here.
> >-Chris
> >
> It would certainly be preferable to not have any ring commands
> written from deep within the power management code. However, I
> didn't want to change anything I didn't really need to, especially
> in code that I'm not at all sure about. Plus I don't have an
> ironlake to test any significant change on.

I did and tested extensively.
-Chris
John Harrison Feb. 18, 2015, 2:28 p.m. UTC | #4
On 13/02/2015 17:03, Chris Wilson wrote:
> On Fri, Feb 13, 2015 at 04:58:24PM +0000, John Harrison wrote:
>> On 13/02/2015 12:19, Chris Wilson wrote:
>>> On Fri, Feb 13, 2015 at 11:48:56AM +0000, John.C.Harrison@Intel.com wrote:
>>>> From: John Harrison <John.C.Harrison@Intel.com>
>>>>
>>>> Updated ironlake_enable_rc6() to do explicit request creation and submission.
>>> If you merged the context here with the common context switching code,
>>> we don't even need to touch the ring here.
>>> -Chris
>>>
>> It would certainly be preferable to not have any ring commands
>> written from deep within the power management code. However, I
>> didn't want to change anything I didn't really need to, especially
>> in code that I'm not at all sure about. Plus I don't have an
>> ironlake to test any significant change on.
> I did and tested extensively.
> -Chris

Do you have a patch that just does the move of this from PM code to 
context switch code? Something that I can drop into this series would be 
great. If not, exactly where about in the context switch code should it 
go? Should it be in the start of day initialisation, in the per context 
intialisation, every context switch, only the first switch after a 
resume, ...?

Tracing back to where/when this code is currently executed seems to be 
quite complicated. The _enable_rc6() function is called during ring 
reset but only for Gen6+ because Ironlake is broken according to the 
comment. It is also called by a system power management callback but it 
is unclear when that would occur. Finally, it is also called from the 
display code in intel_modeset_init_hw().

Thanks,
John.
Daniel Vetter Feb. 25, 2015, 9:31 p.m. UTC | #5
On Wed, Feb 18, 2015 at 02:28:16PM +0000, John Harrison wrote:
> On 13/02/2015 17:03, Chris Wilson wrote:
> >On Fri, Feb 13, 2015 at 04:58:24PM +0000, John Harrison wrote:
> >>On 13/02/2015 12:19, Chris Wilson wrote:
> >>>On Fri, Feb 13, 2015 at 11:48:56AM +0000, John.C.Harrison@Intel.com wrote:
> >>>>From: John Harrison <John.C.Harrison@Intel.com>
> >>>>
> >>>>Updated ironlake_enable_rc6() to do explicit request creation and submission.
> >>>If you merged the context here with the common context switching code,
> >>>we don't even need to touch the ring here.
> >>>-Chris
> >>>
> >>It would certainly be preferable to not have any ring commands
> >>written from deep within the power management code. However, I
> >>didn't want to change anything I didn't really need to, especially
> >>in code that I'm not at all sure about. Plus I don't have an
> >>ironlake to test any significant change on.
> >I did and tested extensively.
> >-Chris
> 
> Do you have a patch that just does the move of this from PM code to context
> switch code? Something that I can drop into this series would be great. If
> not, exactly where about in the context switch code should it go? Should it
> be in the start of day initialisation, in the per context intialisation,
> every context switch, only the first switch after a resume, ...?
> 
> Tracing back to where/when this code is currently executed seems to be quite
> complicated. The _enable_rc6() function is called during ring reset but only
> for Gen6+ because Ironlake is broken according to the comment. It is also
> called by a system power management callback but it is unclear when that
> would occur. Finally, it is also called from the display code in
> intel_modeset_init_hw().

ilk rc6 is disabled by default because it crashes machines hard and
doesn't seem to be all that useful really. Compared to gen6+ rc6 which has
a massive impact on idle power consumption, more with each generation.

I've also never heard of anyone managing to make this work reliably. We
could also just rip the entire code out I think, at least I wouldn't be
surprised if it has bitrot completely by now.
-Daniel
John Harrison Feb. 27, 2015, 12:49 p.m. UTC | #6
On 25/02/2015 21:31, Daniel Vetter wrote:
> On Wed, Feb 18, 2015 at 02:28:16PM +0000, John Harrison wrote:
>> On 13/02/2015 17:03, Chris Wilson wrote:
>>> On Fri, Feb 13, 2015 at 04:58:24PM +0000, John Harrison wrote:
>>>> On 13/02/2015 12:19, Chris Wilson wrote:
>>>>> On Fri, Feb 13, 2015 at 11:48:56AM +0000, John.C.Harrison@Intel.com wrote:
>>>>>> From: John Harrison <John.C.Harrison@Intel.com>
>>>>>>
>>>>>> Updated ironlake_enable_rc6() to do explicit request creation and submission.
>>>>> If you merged the context here with the common context switching code,
>>>>> we don't even need to touch the ring here.
>>>>> -Chris
>>>>>
>>>> It would certainly be preferable to not have any ring commands
>>>> written from deep within the power management code. However, I
>>>> didn't want to change anything I didn't really need to, especially
>>>> in code that I'm not at all sure about. Plus I don't have an
>>>> ironlake to test any significant change on.
>>> I did and tested extensively.
>>> -Chris
>> Do you have a patch that just does the move of this from PM code to context
>> switch code? Something that I can drop into this series would be great. If
>> not, exactly where about in the context switch code should it go? Should it
>> be in the start of day initialisation, in the per context intialisation,
>> every context switch, only the first switch after a resume, ...?
>>
>> Tracing back to where/when this code is currently executed seems to be quite
>> complicated. The _enable_rc6() function is called during ring reset but only
>> for Gen6+ because Ironlake is broken according to the comment. It is also
>> called by a system power management callback but it is unclear when that
>> would occur. Finally, it is also called from the display code in
>> intel_modeset_init_hw().
> ilk rc6 is disabled by default because it crashes machines hard and
> doesn't seem to be all that useful really. Compared to gen6+ rc6 which has
> a massive impact on idle power consumption, more with each generation.
>
> I've also never heard of anyone managing to make this work reliably. We
> could also just rip the entire code out I think, at least I wouldn't be
> surprised if it has bitrot completely by now.
> -Daniel

So just remove the ironlake_enable_rc6() function completely? Or keep it 
as a stub that just says '/* this has never worked so has been removed */'.
Ville Syrjälä Feb. 27, 2015, 1:03 p.m. UTC | #7
On Wed, Feb 25, 2015 at 10:31:13PM +0100, Daniel Vetter wrote:
> On Wed, Feb 18, 2015 at 02:28:16PM +0000, John Harrison wrote:
> > On 13/02/2015 17:03, Chris Wilson wrote:
> > >On Fri, Feb 13, 2015 at 04:58:24PM +0000, John Harrison wrote:
> > >>On 13/02/2015 12:19, Chris Wilson wrote:
> > >>>On Fri, Feb 13, 2015 at 11:48:56AM +0000, John.C.Harrison@Intel.com wrote:
> > >>>>From: John Harrison <John.C.Harrison@Intel.com>
> > >>>>
> > >>>>Updated ironlake_enable_rc6() to do explicit request creation and submission.
> > >>>If you merged the context here with the common context switching code,
> > >>>we don't even need to touch the ring here.
> > >>>-Chris
> > >>>
> > >>It would certainly be preferable to not have any ring commands
> > >>written from deep within the power management code. However, I
> > >>didn't want to change anything I didn't really need to, especially
> > >>in code that I'm not at all sure about. Plus I don't have an
> > >>ironlake to test any significant change on.
> > >I did and tested extensively.
> > >-Chris
> > 
> > Do you have a patch that just does the move of this from PM code to context
> > switch code? Something that I can drop into this series would be great. If
> > not, exactly where about in the context switch code should it go? Should it
> > be in the start of day initialisation, in the per context intialisation,
> > every context switch, only the first switch after a resume, ...?
> > 
> > Tracing back to where/when this code is currently executed seems to be quite
> > complicated. The _enable_rc6() function is called during ring reset but only
> > for Gen6+ because Ironlake is broken according to the comment. It is also
> > called by a system power management callback but it is unclear when that
> > would occur. Finally, it is also called from the display code in
> > intel_modeset_init_hw().
> 
> ilk rc6 is disabled by default because it crashes machines hard and
> doesn't seem to be all that useful really. Compared to gen6+ rc6 which has
> a massive impact on idle power consumption, more with each generation.
> 
> I've also never heard of anyone managing to make this work reliably. We
> could also just rip the entire code out I think, at least I wouldn't be
> surprised if it has bitrot completely by now.

I was running with it when Ben had those ILK context+rc6 patches flying
around. But I admit that was some time ago.
Daniel Vetter Feb. 27, 2015, 1:53 p.m. UTC | #8
On Fri, Feb 27, 2015 at 03:03:22PM +0200, Ville Syrjälä wrote:
> On Wed, Feb 25, 2015 at 10:31:13PM +0100, Daniel Vetter wrote:
> > On Wed, Feb 18, 2015 at 02:28:16PM +0000, John Harrison wrote:
> > > On 13/02/2015 17:03, Chris Wilson wrote:
> > > >On Fri, Feb 13, 2015 at 04:58:24PM +0000, John Harrison wrote:
> > > >>On 13/02/2015 12:19, Chris Wilson wrote:
> > > >>>On Fri, Feb 13, 2015 at 11:48:56AM +0000, John.C.Harrison@Intel.com wrote:
> > > >>>>From: John Harrison <John.C.Harrison@Intel.com>
> > > >>>>
> > > >>>>Updated ironlake_enable_rc6() to do explicit request creation and submission.
> > > >>>If you merged the context here with the common context switching code,
> > > >>>we don't even need to touch the ring here.
> > > >>>-Chris
> > > >>>
> > > >>It would certainly be preferable to not have any ring commands
> > > >>written from deep within the power management code. However, I
> > > >>didn't want to change anything I didn't really need to, especially
> > > >>in code that I'm not at all sure about. Plus I don't have an
> > > >>ironlake to test any significant change on.
> > > >I did and tested extensively.
> > > >-Chris
> > > 
> > > Do you have a patch that just does the move of this from PM code to context
> > > switch code? Something that I can drop into this series would be great. If
> > > not, exactly where about in the context switch code should it go? Should it
> > > be in the start of day initialisation, in the per context intialisation,
> > > every context switch, only the first switch after a resume, ...?
> > > 
> > > Tracing back to where/when this code is currently executed seems to be quite
> > > complicated. The _enable_rc6() function is called during ring reset but only
> > > for Gen6+ because Ironlake is broken according to the comment. It is also
> > > called by a system power management callback but it is unclear when that
> > > would occur. Finally, it is also called from the display code in
> > > intel_modeset_init_hw().
> > 
> > ilk rc6 is disabled by default because it crashes machines hard and
> > doesn't seem to be all that useful really. Compared to gen6+ rc6 which has
> > a massive impact on idle power consumption, more with each generation.
> > 
> > I've also never heard of anyone managing to make this work reliably. We
> > could also just rip the entire code out I think, at least I wouldn't be
> > surprised if it has bitrot completely by now.
> 
> I was running with it when Ben had those ILK context+rc6 patches flying
> around. But I admit that was some time ago.

Iirc we've enabled it for a bit with those, it fell to pieces too. And it
seems to be rare enough that testing on a developers machine doesn't cut
it (tried myself to enable it a few times and had to revert again).
-Daniel
Daniel Vetter Feb. 27, 2015, 1:56 p.m. UTC | #9
On Fri, Feb 27, 2015 at 12:49:11PM +0000, John Harrison wrote:
> On 25/02/2015 21:31, Daniel Vetter wrote:
> >On Wed, Feb 18, 2015 at 02:28:16PM +0000, John Harrison wrote:
> >>On 13/02/2015 17:03, Chris Wilson wrote:
> >>>On Fri, Feb 13, 2015 at 04:58:24PM +0000, John Harrison wrote:
> >>>>On 13/02/2015 12:19, Chris Wilson wrote:
> >>>>>On Fri, Feb 13, 2015 at 11:48:56AM +0000, John.C.Harrison@Intel.com wrote:
> >>>>>>From: John Harrison <John.C.Harrison@Intel.com>
> >>>>>>
> >>>>>>Updated ironlake_enable_rc6() to do explicit request creation and submission.
> >>>>>If you merged the context here with the common context switching code,
> >>>>>we don't even need to touch the ring here.
> >>>>>-Chris
> >>>>>
> >>>>It would certainly be preferable to not have any ring commands
> >>>>written from deep within the power management code. However, I
> >>>>didn't want to change anything I didn't really need to, especially
> >>>>in code that I'm not at all sure about. Plus I don't have an
> >>>>ironlake to test any significant change on.
> >>>I did and tested extensively.
> >>>-Chris
> >>Do you have a patch that just does the move of this from PM code to context
> >>switch code? Something that I can drop into this series would be great. If
> >>not, exactly where about in the context switch code should it go? Should it
> >>be in the start of day initialisation, in the per context intialisation,
> >>every context switch, only the first switch after a resume, ...?
> >>
> >>Tracing back to where/when this code is currently executed seems to be quite
> >>complicated. The _enable_rc6() function is called during ring reset but only
> >>for Gen6+ because Ironlake is broken according to the comment. It is also
> >>called by a system power management callback but it is unclear when that
> >>would occur. Finally, it is also called from the display code in
> >>intel_modeset_init_hw().
> >ilk rc6 is disabled by default because it crashes machines hard and
> >doesn't seem to be all that useful really. Compared to gen6+ rc6 which has
> >a massive impact on idle power consumption, more with each generation.
> >
> >I've also never heard of anyone managing to make this work reliably. We
> >could also just rip the entire code out I think, at least I wouldn't be
> >surprised if it has bitrot completely by now.
> >-Daniel
> 
> So just remove the ironlake_enable_rc6() function completely? Or keep it as
> a stub that just says '/* this has never worked so has been removed */'.

Just remove it entirely, together with all the other ironlake rc6 stuff
plus functions only called by it. All the ironlake_*_rc6 stuff
essentially. ironlake_*_drps is the turbo support, that part needs to
stay.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 6ece663..0844166 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -4959,6 +4959,7 @@  static void ironlake_enable_rc6(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine_cs *ring = &dev_priv->ring[RCS];
+	struct drm_i915_gem_request *req = NULL;
 	bool was_interruptible;
 	int ret;
 
@@ -4977,16 +4978,17 @@  static void ironlake_enable_rc6(struct drm_device *dev)
 	was_interruptible = dev_priv->mm.interruptible;
 	dev_priv->mm.interruptible = false;
 
+	ret = dev_priv->gt.alloc_request(ring, NULL, &req);
+	if (ret)
+		goto err;
+
 	/*
 	 * GPU can automatically power down the render unit if given a page
 	 * to save state.
 	 */
 	ret = intel_ring_begin(ring, 6);
-	if (ret) {
-		ironlake_teardown_rc6(dev);
-		dev_priv->mm.interruptible = was_interruptible;
-		return;
-	}
+	if (ret)
+		goto err;
 
 	intel_ring_emit(ring, MI_SUSPEND_FLUSH | MI_SUSPEND_FLUSH_EN);
 	intel_ring_emit(ring, MI_SET_CONTEXT);
@@ -5000,6 +5002,11 @@  static void ironlake_enable_rc6(struct drm_device *dev)
 	intel_ring_emit(ring, MI_FLUSH);
 	intel_ring_advance(ring);
 
+	ret = i915_add_request_no_flush(req);
+	if (ret)
+		goto err;
+	req = NULL;
+
 	/*
 	 * Wait for the command parser to advance past MI_SET_CONTEXT. The HW
 	 * does an implicit flush, combined with MI_FLUSH above, it should be
@@ -5007,16 +5014,20 @@  static void ironlake_enable_rc6(struct drm_device *dev)
 	 */
 	ret = intel_ring_idle(ring);
 	dev_priv->mm.interruptible = was_interruptible;
-	if (ret) {
-		DRM_ERROR("failed to enable ironlake power savings\n");
-		ironlake_teardown_rc6(dev);
-		return;
-	}
+	if (ret)
+		goto err;
 
 	I915_WRITE(PWRCTXA, i915_gem_obj_ggtt_offset(dev_priv->ips.pwrctx) | PWRCTX_EN);
 	I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) & ~RCX_SW_EXIT);
 
 	intel_print_rc6_info(dev, GEN6_RC_CTL_RC6_ENABLE);
+
+err:
+	DRM_ERROR("failed to enable ironlake power savings\n");
+	ironlake_teardown_rc6(dev);
+	dev_priv->mm.interruptible = was_interruptible;
+	if (req)
+		i915_gem_request_unreference(req);
 }
 
 static unsigned long intel_pxfreq(u32 vidfreq)