public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@gmail.com>
To: Paulo Zanoni <przanoni@gmail.com>
Cc: intel-gfx@lists.freedesktop.org, Paulo Zanoni <paulo.r.zanoni@intel.com>
Subject: Re: [PATCH 07/19] drm/i915: add runtime put/get calls at the basic places
Date: Fri, 29 Nov 2013 11:03:38 -0200	[thread overview]
Message-ID: <20131129130338.GE4697@bratislava.amr.corp.intel.com> (raw)
In-Reply-To: <1385583634-2648-1-git-send-email-przanoni@gmail.com>

On Wed, Nov 27, 2013 at 06:20:34PM -0200, Paulo Zanoni wrote:
> From: Paulo Zanoni <paulo.r.zanoni@intel.com>
> 
> If I add code to enable runtime PM on my Haswell machine, start a
> desktop environment, then enable runtime PM, these functions will
> complain that they're trying to read/write registers while the
> graphics card is suspended.
> 
> v2: - Simplify i915_gem_fault changes.
> 
> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem.c            | 27 +++++++++++++++++++++------
>  drivers/gpu/drm/i915/i915_gem_execbuffer.c |  6 ++++++
>  drivers/gpu/drm/i915/i915_irq.c            |  6 ++++++
>  3 files changed, 33 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 40d9dcf..430b875 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -1380,6 +1380,8 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
>  	int ret = 0;
>  	bool write = !!(vmf->flags & FAULT_FLAG_WRITE);
>  
> +	intel_runtime_pm_get(dev_priv);
> +
>  	/* We don't use vmf->pgoff since that has the fake offset */
>  	page_offset = ((unsigned long)vmf->virtual_address - vma->vm_start) >>
>  		PAGE_SHIFT;
> @@ -1427,8 +1429,10 @@ out:
>  		/* If this -EIO is due to a gpu hang, give the reset code a
>  		 * chance to clean up the mess. Otherwise return the proper
>  		 * SIGBUS. */
> -		if (i915_terminally_wedged(&dev_priv->gpu_error))
> -			return VM_FAULT_SIGBUS;
> +		if (i915_terminally_wedged(&dev_priv->gpu_error)) {
> +			ret = VM_FAULT_SIGBUS;
> +			break;
> +		}
>  	case -EAGAIN:
>  		/*
>  		 * EAGAIN means the gpu is hung and we'll wait for the error
> @@ -1443,15 +1447,22 @@ out:
>  		 * EBUSY is ok: this just means that another thread
>  		 * already did the job.
>  		 */
> -		return VM_FAULT_NOPAGE;
> +		ret = VM_FAULT_NOPAGE;
> +		break;
>  	case -ENOMEM:
> -		return VM_FAULT_OOM;
> +		ret = VM_FAULT_OOM;
> +		break;
>  	case -ENOSPC:
> -		return VM_FAULT_SIGBUS;
> +		ret = VM_FAULT_SIGBUS;
> +		break;
>  	default:
>  		WARN_ONCE(ret, "unhandled error in i915_gem_fault: %i\n", ret);
> -		return VM_FAULT_SIGBUS;
> +		ret = VM_FAULT_SIGBUS;
> +		break;
>  	}
> +
> +	intel_runtime_pm_put(dev_priv);
> +	return ret;
>  }
>  
>  /**
> @@ -4165,6 +4176,8 @@ void i915_gem_free_object(struct drm_gem_object *gem_obj)
>  	drm_i915_private_t *dev_priv = dev->dev_private;
>  	struct i915_vma *vma, *next;
>  
> +	intel_runtime_pm_get(dev_priv);
> +
>  	trace_i915_gem_object_destroy(obj);
>  
>  	if (obj->phys_obj)
> @@ -4209,6 +4222,8 @@ void i915_gem_free_object(struct drm_gem_object *gem_obj)
>  
>  	kfree(obj->bit_17);
>  	i915_gem_object_free(obj);
> +
> +	intel_runtime_pm_put(dev_priv);
>  }
>  
>  struct i915_vma *i915_gem_obj_to_vma(struct drm_i915_gem_object *obj,
> diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> index 3c90dd1..260c147 100644
> --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
> @@ -1095,6 +1095,8 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
>  		}
>  	}
>  
> +	intel_runtime_pm_get(dev_priv);
> +
>  	ret = i915_mutex_lock_interruptible(dev);
>  	if (ret)
>  		goto pre_mutex_err;
> @@ -1229,6 +1231,10 @@ err:
>  
>  pre_mutex_err:
>  	kfree(cliprects);
> +
> +	/* intel_gpu_busy should also get a ref, so it will free when the device
> +	 * is really idle. */
> +	intel_runtime_pm_put(dev_priv);
>  	return ret;
>  }
>  
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 2715600..70c4cef 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -2477,6 +2477,12 @@ static void i915_hangcheck_elapsed(unsigned long data)
>  	if (!i915_enable_hangcheck)
>  		return;
>  
> +	/* Just postpone in case we're completely idle... */
> +	if (dev_priv->pm.suspended) {
> +		i915_queue_hangcheck(dev);
> +		return;
> +	}

I got the idea here, just not sure if it fits on this patch or it is just the commit message.

Anyway,
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>

> +
>  	for_each_ring(ring, dev_priv, i) {
>  		u32 seqno, acthd;
>  		bool busy = true;
> -- 
> 1.8.3.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2013-11-29 13:03 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-21 15:47 [PATCH 00/19] Haswell runtime PM support + D3 Paulo Zanoni
2013-11-21 15:47 ` [PATCH 01/19] drm/i915: WARN if !HAS_PC8 when enabling/disabling PC8 Paulo Zanoni
2013-11-29 11:11   ` Rodrigo Vivi
2013-11-29 12:55     ` Paulo Zanoni
2013-11-29 13:31       ` Rodrigo Vivi
2013-11-21 15:47 ` [PATCH 02/19] drm/i915: use the correct force_wake function at the PC8 code Paulo Zanoni
2013-11-27 19:57   ` Paulo Zanoni
2013-11-29 11:14     ` [Intel-gfx] " Rodrigo Vivi
2013-11-29 13:23       ` Daniel Vetter
2013-11-21 15:47 ` [PATCH 03/19] drm/i915: get a PC8 reference when enabling the power well Paulo Zanoni
2013-11-27 19:59   ` Paulo Zanoni
2013-11-29 12:35     ` Rodrigo Vivi
2013-11-29 13:34       ` Rodrigo Vivi
2013-12-10 21:29     ` Daniel Vetter
2013-11-21 15:47 ` [PATCH 04/19] drm/i915: get/put PC8 when we get/put a CRTC Paulo Zanoni
2013-11-21 16:12   ` Chris Wilson
2013-11-27 20:01     ` Paulo Zanoni
2013-11-29 12:38       ` Rodrigo Vivi
2013-11-29 13:34         ` Rodrigo Vivi
2013-12-04  9:01   ` Daniel Vetter
2013-12-04 13:44     ` Paulo Zanoni
2013-12-04 14:07       ` Daniel Vetter
2013-12-05 13:43         ` Paulo Zanoni
2013-12-05 14:40           ` Daniel Vetter
2013-12-06 22:29             ` [PATCH] drm/i915: change CRTC assertion on LCPLL disable Paulo Zanoni
2013-12-06 22:37               ` Daniel Vetter
2013-11-21 15:47 ` [PATCH 05/19] drm/i915: add initial Runtime PM functions Paulo Zanoni
2013-11-27 20:10   ` Paulo Zanoni
2013-11-29 12:54     ` Rodrigo Vivi
2013-11-29 13:33       ` Rodrigo Vivi
2013-11-29 14:05     ` Takashi Iwai
2013-12-06 22:31       ` Paulo Zanoni
2013-12-06 22:32         ` Paulo Zanoni
2013-12-08  9:06         ` Takashi Iwai
2013-12-02 12:23   ` Imre Deak
2013-11-21 15:47 ` [PATCH 06/19] drm/i915: do adapter power state notification at runtime PM Paulo Zanoni
2013-11-21 16:14   ` Chris Wilson
2013-11-27 20:13     ` Paulo Zanoni
2013-11-29 12:56       ` Rodrigo Vivi
2013-11-29 13:33         ` Rodrigo Vivi
2013-12-06 22:34         ` Paulo Zanoni
2013-11-21 15:47 ` [PATCH 07/19] drm/i915: add runtime put/get calls at the basic places Paulo Zanoni
2013-11-21 16:07   ` Chris Wilson
2013-11-25 20:55     ` Paulo Zanoni
2013-11-25 21:21       ` Chris Wilson
2013-11-27 20:20         ` Paulo Zanoni
2013-11-29 13:03           ` Rodrigo Vivi [this message]
2013-11-29 13:32             ` Rodrigo Vivi
2013-12-10 21:49             ` Daniel Vetter
2013-12-12 20:07               ` Paulo Zanoni
2013-12-12 20:54                 ` Daniel Vetter
2013-11-21 15:47 ` [PATCH 08/19] drm/i915: add some runtime PM get/put calls Paulo Zanoni
2013-11-27 20:21   ` Paulo Zanoni
2013-11-29 13:05     ` Rodrigo Vivi
2013-11-29 13:31       ` Rodrigo Vivi
2013-11-29 13:42       ` Daniel Vetter
2013-11-29 13:56         ` Paulo Zanoni
2013-11-21 15:47 ` [PATCH 09/19] drm/i915: get a runtime PM reference when the panel VDD is on Paulo Zanoni
2013-11-29 13:50   ` Rodrigo Vivi
2013-11-29 13:59     ` Paulo Zanoni
2013-11-29 14:37       ` Rodrigo Vivi
2013-12-06 22:23         ` Paulo Zanoni
2013-11-21 15:47 ` [PATCH 10/19] drm/i915: do not assert DE_PCH_EVENT_IVB enabled Paulo Zanoni
2013-11-29 14:30   ` Rodrigo Vivi
2013-12-10 21:54   ` Daniel Vetter
2013-11-21 15:47 ` [PATCH 11/19] drm/i915: disable interrupts when enabling PC8 Paulo Zanoni
2013-12-02 13:33   ` Rodrigo Vivi
2013-12-10 21:59   ` Daniel Vetter
2013-12-11 21:33     ` Paulo Zanoni
2013-11-21 15:47 ` [PATCH 12/19] drm/i915: release the GTT mmaps when going into D3 Paulo Zanoni
2013-11-21 16:02   ` Chris Wilson
2013-11-21 16:27     ` Paulo Zanoni
2013-12-10 22:03   ` Daniel Vetter
2013-11-21 15:47 ` [PATCH 13/19] drm: do not steal the display if we have a master Paulo Zanoni
2013-11-21 16:04   ` Chris Wilson
2013-11-27 20:24     ` Paulo Zanoni
2013-11-29 13:37       ` Daniel Vetter
2013-11-30 11:19       ` David Herrmann
2013-11-21 15:47 ` [PATCH 14/19] drm/i915: add runtime PM support on Haswell Paulo Zanoni
2013-12-02 13:37   ` Rodrigo Vivi
2013-12-10 22:10     ` Daniel Vetter
2013-12-10 22:06   ` Daniel Vetter
2013-11-21 15:47 ` [PATCH 15/19] drm/i915: don't enable VDD just to enable the panel Paulo Zanoni
2013-11-29 14:40   ` Rodrigo Vivi
2013-11-21 15:47 ` [PATCH 16/19] drm/i915: don't touch the VDD when disabling " Paulo Zanoni
2013-11-29 14:41   ` Rodrigo Vivi
2013-11-21 15:47 ` [PATCH 17/19] drm/i915: fix VDD override off wait Paulo Zanoni
2013-11-21 15:47 ` [PATCH 18/19] drm/i915: save some time when waiting the eDP timings Paulo Zanoni
2013-11-21 16:00   ` Chris Wilson
2013-11-25 22:17     ` Ben Widawsky
2013-11-25 23:25       ` Chris Wilson
2013-11-26  2:38         ` Ben Widawsky
2013-11-26  9:14           ` Chris Wilson
2013-11-26 15:53             ` Paulo Zanoni
2013-11-21 15:47 ` [PATCH 19/19] drm/i915: init the DP panel power seq regs earlier Paulo Zanoni
2013-12-05 15:00   ` Jani Nikula
2013-12-06 18:39     ` Paulo Zanoni

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=20131129130338.GE4697@bratislava.amr.corp.intel.com \
    --to=rodrigo.vivi@gmail.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=paulo.r.zanoni@intel.com \
    --cc=przanoni@gmail.com \
    /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