Module Name: src Committed By: riastradh Date: Fri Apr 4 16:02:34 UTC 2014
Modified Files: src/sys/external/bsd/drm2/i915drm: i915_pci.c Log Message: Tweak i915 framebuffer attachment in preparation for detach/reconfig. Can't do this yet because genfb can't detach or reconfigure... To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 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/i915drm/i915_pci.c diff -u src/sys/external/bsd/drm2/i915drm/i915_pci.c:1.4 src/sys/external/bsd/drm2/i915drm/i915_pci.c:1.5 --- src/sys/external/bsd/drm2/i915drm/i915_pci.c:1.4 Thu Apr 3 19:18:29 2014 +++ src/sys/external/bsd/drm2/i915drm/i915_pci.c Fri Apr 4 16:02:34 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: i915_pci.c,v 1.4 2014/04/03 19:18:29 riastradh Exp $ */ +/* $NetBSD: i915_pci.c,v 1.5 2014/04/04 16:02:34 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.4 2014/04/03 19:18:29 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i915_pci.c,v 1.5 2014/04/04 16:02:34 riastradh Exp $"); #include <sys/types.h> #ifndef _MODULE @@ -248,6 +248,7 @@ i915drm_attach_framebuffer(device_t self INIT_LIST_HEAD(&sc->sc_fb_list); + KASSERT(dev_priv->fbdev == NULL); dev_priv->fbdev = kmem_zalloc(sizeof(*dev_priv->fbdev), KM_SLEEP); struct drm_fb_helper *const fb_helper = &dev_priv->fbdev->helper; @@ -267,6 +268,8 @@ i915drm_attach_framebuffer(device_t self /* Success! */ return; +fail1: __unused + drm_fb_helper_fini(fb_helper); fail0: kmem_free(dev_priv->fbdev, sizeof(*dev_priv->fbdev)); dev_priv->fbdev = NULL; } @@ -282,21 +285,9 @@ i915drm_detach_framebuffer(device_t self if (fbdev != NULL) { struct drm_fb_helper *const fb_helper = &fbdev->helper; - if (fb_helper->fb != NULL) { - struct drm_i915_gem_object *const obj = sc->sc_fb_obj; - - /* - * genfb children have already been detached, - * so all we need do is unmap the space and - * clean up the drm structures. - */ - bus_space_unmap(dev->bst, sc->sc_fb_bsh, - obj->base.size); - drm_framebuffer_unreference(fb_helper->fb); - fb_helper->fb = NULL; - drm_gem_object_unreference_unlocked(&obj->base); - sc->sc_fb_obj = NULL; - } + if (fb_helper->fb != NULL) + i915drm_fb_detach(fb_helper); + KASSERT(fb_helper->fb == NULL); KASSERT(sc->sc_fb_obj == NULL); drm_fb_helper_fini(fb_helper); @@ -336,9 +327,13 @@ i915drm_fb_probe(struct drm_fb_helper *f sizes->surface_depth); if (fb_helper->fb != NULL) { +#if notyet /* XXX genfb detach */ + i915drm_fb_detach(fb_helper); +#else aprint_debug_dev(sc->sc_dev, "already have a framebuffer" ": %p\n", fb_helper->fb); return 0; +#endif } /* @@ -453,6 +448,22 @@ fail0: KASSERT(ret < 0); } static void +i915drm_fb_detach(struct drm_fb_helper *fb_helper) +{ + struct drm_device *const dev = fb_helper->dev; + struct i915drm_softc *const sc = container_of(dev, + struct i915drm_softc, sc_drm_dev); + struct drm_i915_gem_object *const obj = sc->sc_fb_obj; + + /* XXX How to detach genfb? */ + bus_space_unmap(dev->bst, sc->sc_fb_bsh, obj->base.size); + drm_framebuffer_unreference(fb_helper->fb); + fb_helper->fb = NULL; + drm_gem_object_unreference_unlocked(&obj->base); + sc->sc_fb_obj = NULL; +} + +static void i915drm_fb_destroy(struct drm_framebuffer *fb) {