From owner-freebsd-current@FreeBSD.ORG Sat Jun 29 14:22:53 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 8B1BFE7C; Sat, 29 Jun 2013 14:22:53 +0000 (UTC) (envelope-from dt71@gmx.com) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by mx1.freebsd.org (Postfix) with ESMTP id 1E43E183D; Sat, 29 Jun 2013 14:22:53 +0000 (UTC) Received: from [192.168.1.80] ([46.107.123.81]) by mail.gmx.com (mrgmx001) with ESMTPSA (Nemesis) id 0LdHeL-1USddi4AVN-00iXTy; Sat, 29 Jun 2013 16:22:52 +0200 Message-ID: <51CEED9B.6050603@gmx.com> Date: Sat, 29 Jun 2013 16:22:19 +0200 From: dt71@gmx.com User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:20.0) Gecko/20100101 Firefox/20.0 SeaMonkey/2.17.1 MIME-Version: 1.0 To: freebsd-current@freebsd.org, rnoland@freebsd.org Subject: Re: Robert Noland's DRM patch References: <51CEED6F.8050605@gmx.com> In-Reply-To: <51CEED6F.8050605@gmx.com> Content-Type: multipart/mixed; boundary="------------050301030108050908010407" X-Provags-ID: V03:K0:a/C/rfNi+61z0pkJfzEGMj8cwW4eRYAC2hOdtiEvjchyy9t92B0 VajrOdHHqaEr3R9oUU53kFgFPu0Rl2DlARG7P3xOihzZ+lFKt1GCWhJ0xLUFhDN6NRe1QIs UsnVgijY0esjeSPOMe66EpBVx7Ons7qpQy/rkS23SvNIcN2C2ozQbzKu8LSgI01emkma9CO vr+dHevg+JeMgxMuq01Wg== X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Jun 2013 14:22:53 -0000 This is a multi-part message in MIME format. --------------050301030108050908010407 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit --------------050301030108050908010407 Content-Type: text/x-patch; name="rn_drm.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="rn_drm.patch" Index: sys/dev/drm/r300_cmdbuf.c =================================================================== --- sys/dev/drm/r300_cmdbuf.c (revision 252372) +++ sys/dev/drm/r300_cmdbuf.c (working copy) @@ -1043,6 +1043,8 @@ int emit_dispatch_age = 0; int ret = 0; + DRM_UNLOCK(); + DRM_DEBUG("\n"); /* pacify */ @@ -1205,5 +1207,7 @@ COMMIT_RING(); + DRM_LOCK(); + return ret; } Index: sys/dev/drm/radeon_irq.c =================================================================== --- sys/dev/drm/radeon_irq.c (revision 252372) +++ sys/dev/drm/radeon_irq.c (working copy) @@ -338,10 +338,13 @@ result = radeon_emit_irq(dev); + DRM_UNLOCK(); if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) { DRM_ERROR("copy_to_user\n"); + DRM_LOCK(); return -EFAULT; } + DRM_LOCK(); return 0; } Index: sys/dev/drm/radeon_mem.c =================================================================== --- sys/dev/drm/radeon_mem.c (revision 252372) +++ sys/dev/drm/radeon_mem.c (working copy) @@ -246,11 +246,14 @@ if (!block) return -ENOMEM; + DRM_UNLOCK(); if (DRM_COPY_TO_USER(alloc->region_offset, &block->start, sizeof(int))) { DRM_ERROR("copy_to_user\n"); + DRM_LOCK(); return -EFAULT; } + DRM_LOCK(); return 0; } Index: sys/dev/drm/radeon_state.c =================================================================== --- sys/dev/drm/radeon_state.c (revision 252372) +++ sys/dev/drm/radeon_state.c (working copy) @@ -1773,8 +1773,13 @@ } if (!buf) { DRM_DEBUG("EAGAIN\n"); - if (DRM_COPY_TO_USER(tex->image, image, sizeof(*image))) + DRM_UNLOCK(); + if (DRM_COPY_TO_USER(tex->image, image, + sizeof(*image))) { + DRM_LOCK(); return -EFAULT; + } + DRM_LOCK(); return -EAGAIN; } @@ -1786,10 +1791,13 @@ #define RADEON_COPY_MT(_buf, _data, _width) \ do { \ - if (DRM_COPY_FROM_USER(_buf, _data, (_width))) {\ + DRM_UNLOCK(); \ + if (DRM_COPY_FROM_USER(_buf, _data, (_width))) { \ DRM_ERROR("EFAULT on pad, %d bytes\n", (_width)); \ + DRM_LOCK(); \ return -EFAULT; \ } \ + DRM_LOCK(); \ } while(0) if (microtile) { @@ -2130,9 +2138,13 @@ if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS) sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS; + DRM_UNLOCK(); if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes, - sarea_priv->nbox * sizeof(depth_boxes[0]))) + sarea_priv->nbox * sizeof(depth_boxes[0]))) { + DRM_LOCK(); return -EFAULT; + } + DRM_LOCK(); radeon_cp_dispatch_clear(dev, clear, depth_boxes); @@ -2394,10 +2406,13 @@ return -EINVAL; } - if (DRM_COPY_FROM_USER(&image, - (drm_radeon_tex_image_t __user *) tex->image, - sizeof(image))) - return -EFAULT; + DRM_UNLOCK(); + ret = -DRM_COPY_FROM_USER(&image, + (drm_radeon_tex_image_t __user *) tex->image, + sizeof(image)); + DRM_LOCK(); + if (ret) + return ret; RING_SPACE_TEST_WITH_RETURN(dev_priv); VB_AGE_TEST_WITH_RETURN(dev_priv); @@ -2418,8 +2433,12 @@ LOCK_TEST_WITH_RETURN(dev, file_priv); - if (DRM_COPY_FROM_USER(&mask, stipple->mask, 32 * sizeof(u32))) + DRM_UNLOCK(); + if (DRM_COPY_FROM_USER(&mask, stipple->mask, 32 * sizeof(u32))) { + DRM_LOCK(); return -EFAULT; + } + DRM_LOCK(); RING_SPACE_TEST_WITH_RETURN(dev_priv); @@ -2546,16 +2565,24 @@ drm_radeon_prim_t prim; drm_radeon_tcl_prim_t tclprim; - if (DRM_COPY_FROM_USER(&prim, &vertex->prim[i], sizeof(prim))) + DRM_UNLOCK(); + if (DRM_COPY_FROM_USER(&prim, &vertex->prim[i], sizeof(prim))) { + DRM_LOCK(); return -EFAULT; + } + DRM_LOCK(); if (prim.stateidx != laststate) { drm_radeon_state_t state; + DRM_UNLOCK(); if (DRM_COPY_FROM_USER(&state, &vertex->state[prim.stateidx], - sizeof(state))) + sizeof(state))) { + DRM_LOCK(); return -EFAULT; + } + DRM_LOCK(); if (radeon_emit_state2(dev_priv, file_priv, &state)) { DRM_ERROR("radeon_emit_state2 failed\n"); @@ -2772,8 +2799,12 @@ do { if (i < cmdbuf->nbox) { - if (DRM_COPY_FROM_USER(&box, &boxes[i], sizeof(box))) + DRM_UNLOCK(); + if (DRM_COPY_FROM_USER(&box, &boxes[i], sizeof(box))) { + DRM_LOCK(); return -EFAULT; + } + DRM_LOCK(); /* FIXME The second and subsequent times round * this loop, send a WAIT_UNTIL_3D_IDLE before * calling emit_clip_rect(). This fixes a @@ -2866,11 +2897,14 @@ kbuf = drm_alloc(cmdbuf->bufsz, DRM_MEM_DRIVER); if (kbuf == NULL) return -ENOMEM; + DRM_UNLOCK(); if (DRM_COPY_FROM_USER(kbuf, (void __user *)cmdbuf->buf, cmdbuf->bufsz)) { + DRM_LOCK(); drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER); return -EFAULT; } + DRM_LOCK(); cmdbuf->buf = kbuf; } @@ -3089,10 +3123,13 @@ return -EINVAL; } + DRM_UNLOCK(); if (DRM_COPY_TO_USER(param->value, &value, sizeof(int))) { DRM_ERROR("copy_to_user\n"); + DRM_LOCK(); return -EFAULT; } + DRM_LOCK(); return 0; } --------------050301030108050908010407--