Module Name: src Committed By: riastradh Date: Wed Jul 16 23:25:18 UTC 2014
Modified Files: src/sys/external/bsd/drm2/dist/drm/i915: i915_dma.c i915_drv.c i915_drv.h intel_uncore.c src/sys/external/bsd/drm2/i915drm: i915_pci.c Log Message: Get suspend/resume sorta working for i915drm. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c cvs rdiff -u -r1.5 -r1.6 src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h cvs rdiff -u -r1.3 -r1.4 \ src/sys/external/bsd/drm2/dist/drm/i915/intel_uncore.c cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/drm2/i915drm/i915_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c:1.9 src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c:1.10 --- src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c:1.9 Wed Jul 16 20:56:24 2014 +++ src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c Wed Jul 16 23:25:18 2014 @@ -1851,6 +1851,7 @@ out_gtt: dev_priv->gtt.base.cleanup(&dev_priv->gtt.base); out_regs: intel_uncore_fini(dev); + intel_uncore_destroy(dev); pci_iounmap(dev->pdev, dev_priv->regs); put_bridge: pci_dev_put(dev_priv->bridge_dev); @@ -1966,6 +1967,7 @@ int i915_driver_unload(struct drm_device dev_priv->gtt.base.cleanup(&dev_priv->gtt.base); intel_uncore_fini(dev); + intel_uncore_destroy(dev); if (dev_priv->regs != NULL) pci_iounmap(dev->pdev, dev_priv->regs); Index: src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c:1.4 src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c:1.5 --- src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c:1.4 Wed Jul 16 20:56:24 2014 +++ src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.c Wed Jul 16 23:25:18 2014 @@ -427,7 +427,7 @@ bool i915_semaphore_is_enabled(struct dr return true; } -static int i915_drm_freeze(struct drm_device *dev) +int i915_drm_freeze(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; struct drm_crtc *crtc; @@ -563,7 +563,7 @@ static void intel_resume_hotplug(struct drm_helper_hpd_irq_event(dev); } -static int i915_drm_thaw_early(struct drm_device *dev) +int i915_drm_thaw_early(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; @@ -644,15 +644,13 @@ static int __i915_drm_thaw(struct drm_de return error; } -#ifndef __NetBSD__ /* XXX freeze/thaw */ -static int i915_drm_thaw(struct drm_device *dev) +int i915_drm_thaw(struct drm_device *dev) { if (drm_core_check_feature(dev, DRIVER_MODESET)) i915_check_and_clear_faults(dev); return __i915_drm_thaw(dev, true); } -#endif static int i915_resume_early(struct drm_device *dev) { Index: src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h:1.5 src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h:1.6 --- src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h:1.5 Wed Jul 16 20:56:24 2014 +++ src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h Wed Jul 16 23:25:18 2014 @@ -2158,6 +2158,10 @@ extern int i915_resume(struct drm_device extern int i915_master_create(struct drm_device *dev, struct drm_master *master); extern void i915_master_destroy(struct drm_device *dev, struct drm_master *master); +extern int i915_drm_freeze(struct drm_device *dev); +extern int i915_drm_thaw_early(struct drm_device *dev); +extern int i915_drm_thaw(struct drm_device *dev); + /* i915_params.c */ struct i915_params { int modeset; @@ -2230,6 +2234,7 @@ extern void intel_uncore_early_sanitize( extern void intel_uncore_init(struct drm_device *dev); extern void intel_uncore_check_errors(struct drm_device *dev); extern void intel_uncore_fini(struct drm_device *dev); +extern void intel_uncore_destroy(struct drm_device *dev); void i915_enable_pipestat(struct drm_i915_private *dev_priv, enum pipe pipe, Index: src/sys/external/bsd/drm2/dist/drm/i915/intel_uncore.c diff -u src/sys/external/bsd/drm2/dist/drm/i915/intel_uncore.c:1.3 src/sys/external/bsd/drm2/dist/drm/i915/intel_uncore.c:1.4 --- src/sys/external/bsd/drm2/dist/drm/i915/intel_uncore.c:1.3 Wed Jul 16 20:56:25 2014 +++ src/sys/external/bsd/drm2/dist/drm/i915/intel_uncore.c Wed Jul 16 23:25:18 2014 @@ -868,14 +868,16 @@ void intel_uncore_init(struct drm_device void intel_uncore_fini(struct drm_device *dev) { -#ifdef __NetBSD__ - struct drm_i915_private *const dev_priv = dev->dev_private; -#endif - /* Paranoia: make sure we have disabled everything before we exit. */ intel_uncore_sanitize(dev); intel_uncore_forcewake_reset(dev, false); +} + +void intel_uncore_destroy(struct drm_device *dev) +{ #ifdef __NetBSD__ + struct drm_i915_private *const dev_priv = dev->dev_private; + teardown_timer(&dev_priv->uncore.force_wake_timer); #endif } Index: src/sys/external/bsd/drm2/i915drm/i915_pci.c diff -u src/sys/external/bsd/drm2/i915drm/i915_pci.c:1.11 src/sys/external/bsd/drm2/i915drm/i915_pci.c:1.12 --- src/sys/external/bsd/drm2/i915drm/i915_pci.c:1.11 Wed Jul 16 20:56:25 2014 +++ src/sys/external/bsd/drm2/i915drm/i915_pci.c Wed Jul 16 23:25:18 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: i915_pci.c,v 1.11 2014/07/16 20:56:25 riastradh Exp $ */ +/* $NetBSD: i915_pci.c,v 1.12 2014/07/16 23:25:18 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: i915_pci.c,v 1.11 2014/07/16 20:56:25 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i915_pci.c,v 1.12 2014/07/16 23:25:18 riastradh Exp $"); #ifdef _KERNEL_OPT #include "vga.h" @@ -94,6 +94,9 @@ static int i915drmkms_match(device_t, cf static void i915drmkms_attach(device_t, device_t, void *); static int i915drmkms_detach(device_t, int); +static bool i915drmkms_suspend(device_t, const pmf_qual_t *); +static bool i915drmkms_resume(device_t, const pmf_qual_t *); + static void intel_genfb_defer_set_config(struct drm_fb_helper *); static void intel_genfb_set_config_work(struct work *, void *); static void intel_genfb_set_config(struct intel_genfb_work *); @@ -190,6 +193,10 @@ i915drmkms_attach(device_t parent, devic pci_aprint_devinfo(pa, NULL); + if (!pmf_device_register(self, &i915drmkms_suspend, + &i915drmkms_resume)) + aprint_error_dev(self, "unable to establish power handler\n"); + SIMPLEQ_INIT(&sc->sc_genfb_work); /* XXX errno Linux->NetBSD */ @@ -229,19 +236,58 @@ i915drmkms_detach(device_t self, int fla return error; if (sc->sc_genfb_wq == NULL) - return 0; + goto out; workqueue_destroy(sc->sc_genfb_wq); if (sc->sc_drm_dev == NULL) - return 0; + goto out; /* XXX errno Linux->NetBSD */ error = -drm_pci_detach(sc->sc_drm_dev, flags); if (error) return error; + sc->sc_drm_dev = NULL; +out: pmf_device_deregister(self); return 0; } +static bool +i915drmkms_suspend(device_t self, const pmf_qual_t *qual) +{ + struct i915drmkms_softc *const sc = device_private(self); + struct drm_device *const dev = sc->sc_drm_dev; + int ret; + + if (dev == NULL) + return true; + + ret = i915_drm_freeze(dev); + if (ret) + return false; + + return true; +} + +static bool +i915drmkms_resume(device_t self, const pmf_qual_t *qual) +{ + struct i915drmkms_softc *const sc = device_private(self); + struct drm_device *const dev = sc->sc_drm_dev; + int ret; + + if (dev == NULL) + return true; + + ret = i915_drm_thaw_early(dev); + if (ret) + return false; + ret = i915_drm_thaw(dev); + if (ret) + return false; + + return true; +} + int intel_genfb_attach(struct drm_device *dev, struct drm_fb_helper *helper, const struct drm_fb_helper_surface_size *sizes)