[Intel-gfx] [PATCH] i915: suspend/resume GEM when KMS is active
Eric Anholt
eric at anholt.net
Wed Feb 18 00:54:17 CET 2009
On Tue, 2009-02-17 at 15:36 -0800, Jesse Barnes wrote:
> On Tuesday, February 17, 2009 3:13 pm Jesse Barnes wrote:
> > In the KMS case, we need to suspend/resume GEM as well. So on suspend,
> > make sure we idle GEM and stop any new rendering from coming in, and on
> > resume, re-init the framebuffer and clear the suspended flag.
> >
> > Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>
>
> Oops should have included the IRQ bits as well. We need to do this t
> properly tear down vblank state and make sure no interrupts come in
> either after suspend or before resume while the machine is still running.
>
> Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>
Could we please create a new i915_gem_idle()-like path for the suspend
that actually waits, instead of spinning for a short while and giving
up? I'd really like the BUG_ON from the timeout in that function (the
timeout being there to handle exiting your hung X Server) to stay out of
KMS.
Or we should report the failures resulting from the timout better.
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index a31cbdb..139a0d8 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -27,6 +27,7 @@
> *
> */
>
> +#include <linux/device.h>
> #include "drmP.h"
> #include "drm.h"
> #include "i915_drm.h"
> @@ -64,6 +65,15 @@ static int i915_suspend(struct drm_device *dev, pm_message_t state)
>
> pci_save_state(dev->pdev);
>
> + /* If KMS is active, we do the leavevt stuff here */
> + if (drm_core_check_feature(dev, DRIVER_MODESET) && i915_gem_idle(dev)) {
> + dev_err(&dev->pdev->dev, "GEM idle failed, aborting suspend\n");
> + return -EBUSY;
> + }
> +
> + if (drm_core_check_feature(dev, DRIVER_MODESET))
> + drm_irq_uninstall(dev);
> +
> i915_save_state(dev);
>
> intel_opregion_free(dev);
> @@ -79,6 +89,9 @@ static int i915_suspend(struct drm_device *dev, pm_message_t state)
>
> static int i915_resume(struct drm_device *dev)
> {
> + struct drm_i915_private *dev_priv = dev->dev_private;
> + int ret = 0;
> +
> pci_set_power_state(dev->pdev, PCI_D0);
> pci_restore_state(dev->pdev);
> if (pci_enable_device(dev->pdev))
> @@ -89,7 +102,19 @@ static int i915_resume(struct drm_device *dev)
>
> intel_opregion_init(dev);
>
> - return 0;
> + /* KMS EnterVT equivalent */
> + if (drm_core_check_feature(dev, DRIVER_MODESET)) {
> + mutex_lock(&dev->struct_mutex);
> + dev_priv->mm.suspended = 0;
> +
> + ret = i915_gem_init_ringbuffer(dev);
> + if (ret != 0)
> + ret = -1;
> + mutex_unlock(&dev->struct_mutex);
> + drm_irq_install(dev);
> + }
> +
> + return ret;
> }
>
> static struct vm_operations_struct i915_gem_vm_ops = {
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index a8d3256..2461d9b 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -621,6 +621,7 @@ int i915_gem_init_ringbuffer(struct drm_device *dev);
> void i915_gem_cleanup_ringbuffer(struct drm_device *dev);
> int i915_gem_do_init(struct drm_device *dev, unsigned long start,
> unsigned long end);
> +int i915_gem_idle(struct drm_device *dev);
> int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
> int i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj,
> int write);
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index ac534c9..cd5101c 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -2967,7 +2967,7 @@ i915_gem_evict_from_list(struct drm_device *dev, struct list_head *head)
> return 0;
> }
>
> -static int
> +int
> i915_gem_idle(struct drm_device *dev)
> {
> drm_i915_private_t *dev_priv = dev->dev_private;
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Eric Anholt
eric at anholt.net eric.anholt at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/intel-gfx/attachments/20090217/1294c40a/attachment.sig>
More information about the Intel-gfx
mailing list