From owner-svn-src-all@freebsd.org Wed Aug 26 13:23:57 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6C0809C3B50; Wed, 26 Aug 2015 13:23:57 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5C879FA9; Wed, 26 Aug 2015 13:23:57 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7QDNvlE062626; Wed, 26 Aug 2015 13:23:57 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7QDNv0v062625; Wed, 26 Aug 2015 13:23:57 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201508261323.t7QDNv0v062625@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Wed, 26 Aug 2015 13:23:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287165 - head/sys/dev/drm2/i915 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2015 13:23:57 -0000 Author: bapt Date: Wed Aug 26 13:23:56 2015 New Revision: 287165 URL: https://svnweb.freebsd.org/changeset/base/287165 Log: Reduce diff on i915_dma.c against linux 3.8.13 No functional changes Discussed with: dumbbell Reviewed by: dumbbell Modified: head/sys/dev/drm2/i915/i915_dma.c Modified: head/sys/dev/drm2/i915/i915_dma.c ============================================================================== --- head/sys/dev/drm2/i915/i915_dma.c Wed Aug 26 12:32:46 2015 (r287164) +++ head/sys/dev/drm2/i915/i915_dma.c Wed Aug 26 13:23:56 2015 (r287165) @@ -1,6 +1,6 @@ /* i915_dma.c -- DMA support for the I915 -*- linux-c -*- */ -/*- +/* * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. * @@ -47,6 +47,12 @@ __FBSDID("$FreeBSD$"); #define ADVANCE_LP_RING() \ intel_ring_advance(LP_RING(dev_priv)) +/** + * Lock test for when it's just for synchronization of ring access. + * + * In that case, we don't need to do it when GEM is initialized as nobody else + * has access to the ring. + */ #define RING_LOCK_TEST_WITH_RETURN(dev, file) do { \ if (LP_RING(dev->dev_private)->obj == NULL) \ LOCK_TEST_WITH_RETURN(dev, file); \ @@ -179,7 +185,6 @@ static int i915_dma_cleanup(struct drm_d drm_i915_private_t *dev_priv = dev->dev_private; int i; - /* Make sure interrupts are disabled here because the uninstall ioctl * may not have been called from userspace and after dev_private * is freed, it's too late. @@ -208,7 +213,7 @@ static int i915_initialize(struct drm_de master_priv->sarea = drm_getsarea(dev); if (master_priv->sarea) { master_priv->sarea_priv = (drm_i915_sarea_t *) - ((u8 *)master_priv->sarea->handle + init->sarea_priv_offset); + ((u8 *)master_priv->sarea->handle + init->sarea_priv_offset); } else { DRM_DEBUG_DRIVER("sarea not found assuming DRI2 userspace\n"); } @@ -309,7 +314,7 @@ static int i915_dma_init(struct drm_devi * instruction detected will be given a size of zero, which is a * signal to abort the rest of the buffer. */ -static int do_validate_cmd(int cmd) +static int validate_cmd(int cmd) { switch (((cmd >> 29) & 0x7)) { case 0x0: @@ -367,17 +372,7 @@ static int do_validate_cmd(int cmd) return 0; } -static int validate_cmd(int cmd) -{ - int ret = do_validate_cmd(cmd); - -/* printk("validate_cmd( %x ): %d\n", cmd, ret); */ - - return ret; -} - -static int i915_emit_cmds(struct drm_device *dev, int __user *buffer, - int dwords) +static int i915_emit_cmds(struct drm_device * dev, int *buffer, int dwords) { drm_i915_private_t *dev_priv = dev->dev_private; int i; @@ -429,14 +424,15 @@ int i915_emit_box(struct drm_device * de } int -i915_emit_box_p(struct drm_device *dev, struct drm_clip_rect *box, - int DR1, int DR4) +i915_emit_box_p(struct drm_device *dev, + struct drm_clip_rect *box, + int DR1, int DR4) { - drm_i915_private_t *dev_priv = dev->dev_private; + struct drm_i915_private *dev_priv = dev->dev_private; int ret; - if (box->y2 <= box->y1 || box->x2 <= box->x1 || box->y2 <= 0 || - box->x2 <= 0) { + if (box->y2 <= box->y1 || box->x2 <= box->x1 || + box->y2 <= 0 || box->x2 <= 0) { DRM_ERROR("Bad box %d,%d..%d,%d\n", box->x1, box->y1, box->x2, box->y2); return -EINVAL; @@ -444,8 +440,8 @@ i915_emit_box_p(struct drm_device *dev, if (INTEL_INFO(dev)->gen >= 4) { ret = BEGIN_LP_RING(4); - if (ret != 0) - return (ret); + if (ret) + return ret; OUT_RING(GFX_OP_DRAWRECT_INFO_I965); OUT_RING((box->x1 & 0xffff) | (box->y1 << 16)); @@ -453,8 +449,8 @@ i915_emit_box_p(struct drm_device *dev, OUT_RING(DR4); } else { ret = BEGIN_LP_RING(6); - if (ret != 0) - return (ret); + if (ret) + return ret; OUT_RING(GFX_OP_DRAWRECT_INFO); OUT_RING(DR1); @@ -492,7 +488,9 @@ static void i915_emit_breadcrumb(struct } static int i915_dispatch_cmdbuffer(struct drm_device * dev, - drm_i915_cmdbuffer_t * cmd, struct drm_clip_rect *cliprects, void *cmdbuf) + drm_i915_cmdbuffer_t *cmd, + struct drm_clip_rect *cliprects, + void *cmdbuf) { int nbox = cmd->num_cliprects; int i = 0, count, ret; @@ -523,11 +521,11 @@ static int i915_dispatch_cmdbuffer(struc return 0; } -static int -i915_dispatch_batchbuffer(struct drm_device * dev, - drm_i915_batchbuffer_t * batch, struct drm_clip_rect *cliprects) +static int i915_dispatch_batchbuffer(struct drm_device * dev, + drm_i915_batchbuffer_t * batch, + struct drm_clip_rect *cliprects) { - drm_i915_private_t *dev_priv = dev->dev_private; + struct drm_i915_private *dev_priv = dev->dev_private; int nbox = batch->num_cliprects; int i, count, ret; @@ -542,7 +540,6 @@ i915_dispatch_batchbuffer(struct drm_dev i915_kernel_lost_context(dev); count = nbox ? nbox : 1; - for (i = 0; i < count; i++) { if (i < nbox) { int ret = i915_emit_box_p(dev, &cliprects[i], @@ -553,8 +550,8 @@ i915_dispatch_batchbuffer(struct drm_dev if (!IS_I830(dev) && !IS_845G(dev)) { ret = BEGIN_LP_RING(2); - if (ret != 0) - return (ret); + if (ret) + return ret; if (INTEL_INFO(dev)->gen >= 4) { OUT_RING(MI_BATCH_BUFFER_START | (2 << 6) | @@ -566,8 +563,8 @@ i915_dispatch_batchbuffer(struct drm_dev } } else { ret = BEGIN_LP_RING(4); - if (ret != 0) - return (ret); + if (ret) + return ret; OUT_RING(MI_BATCH_BUFFER); OUT_RING(batch->start | MI_BATCH_NON_SECURE); @@ -602,6 +599,7 @@ static int i915_dispatch_flip(struct drm ret = BEGIN_LP_RING(10); if (ret) return ret; + OUT_RING(MI_FLUSH | MI_READ_FLUSH); OUT_RING(0); @@ -635,8 +633,7 @@ static int i915_dispatch_flip(struct drm return 0; } -static int -i915_quiescent(struct drm_device *dev) +static int i915_quiescent(struct drm_device *dev) { struct intel_ring_buffer *ring = LP_RING(dev->dev_private); @@ -644,8 +641,8 @@ i915_quiescent(struct drm_device *dev) return (intel_wait_ring_idle(ring)); } -static int -i915_flush_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) +static int i915_flush_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv) { int ret; @@ -1132,7 +1129,7 @@ i915_load_modeset_init(struct drm_device intel_modeset_init(dev); ret = i915_gem_init(dev); - if (ret != 0) + if (ret) goto cleanup_gem_stolen; intel_modeset_gem_init(dev); @@ -1152,7 +1149,7 @@ i915_load_modeset_init(struct drm_device /* We're off and running w/KMS */ dev_priv->mm.suspended = 0; - return (0); + return 0; cleanup_gem: DRM_LOCK(dev); @@ -1339,8 +1336,18 @@ intel_teardown_mchbar(struct drm_device } } -int -i915_driver_load(struct drm_device *dev, unsigned long flags) +/** + * i915_driver_load - setup chip and create an initial config + * @dev: DRM device + * @flags: startup flags + * + * The driver load routine has to do several things: + * - drive output discovery via intel_modeset_init() + * - initialize the memory manager + * - allocate initial config memory + * - setup the DRM framebuffer with the allocated memory + */ +int i915_driver_load(struct drm_device *dev, unsigned long flags) { struct drm_i915_private *dev_priv = dev->dev_private; const struct intel_device_info *info; @@ -1475,8 +1482,7 @@ out_gem_unload: return (ret); } -int -i915_driver_unload(struct drm_device *dev) +int i915_driver_unload(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; int ret; @@ -1546,11 +1552,10 @@ i915_driver_unload(struct drm_device *de mtx_destroy(&dev_priv->rps_lock); free(dev->dev_private, DRM_MEM_DRIVER); - return (0); + return 0; } -int -i915_driver_open(struct drm_device *dev, struct drm_file *file_priv) +int i915_driver_open(struct drm_device *dev, struct drm_file *file) { struct drm_i915_file_private *i915_file_priv; @@ -1559,19 +1564,35 @@ i915_driver_open(struct drm_device *dev, mtx_init(&i915_file_priv->mm.lck, "915fp", NULL, MTX_DEF); INIT_LIST_HEAD(&i915_file_priv->mm.request_list); - file_priv->driver_priv = i915_file_priv; + file->driver_priv = i915_file_priv; drm_gem_names_init(&i915_file_priv->context_idr); - return (0); + return 0; } -void -i915_driver_lastclose(struct drm_device * dev) +/** + * i915_driver_lastclose - clean up after all DRM clients have exited + * @dev: DRM device + * + * Take care of cleaning up after all DRM clients have exited. In the + * mode setting case, we want to restore the kernel's initial mode (just + * in case the last client left us in a bad state). + * + * Additionally, in the non-mode setting case, we'll tear down the GTT + * and DMA structures, since the kernel won't be using them, and clea + * up any GEM state. + */ +void i915_driver_lastclose(struct drm_device * dev) { drm_i915_private_t *dev_priv = dev->dev_private; - if (!dev_priv || drm_core_check_feature(dev, DRIVER_MODESET)) { + /* On gen6+ we refuse to init without kms enabled, but then the drm core + * goes right around and calls lastclose. Check for this and don't clean + * up anything. */ + if (!dev_priv) + return; + if (drm_core_check_feature(dev, DRIVER_MODESET)) { #if 1 KIB_NOTYET(); #else @@ -1580,13 +1601,14 @@ i915_driver_lastclose(struct drm_device #endif return; } + i915_gem_lastclose(dev); + i915_dma_cleanup(dev); } void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv) { - i915_gem_context_close(dev, file_priv); i915_gem_release(dev, file_priv); }