From patchwork Tue Feb 1 18:16:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 523631 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p11ILrJw002313 for ; Tue, 1 Feb 2011 18:22:14 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DE85C9E764 for ; Tue, 1 Feb 2011 10:21:53 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yx0-f177.google.com (mail-yx0-f177.google.com [209.85.213.177]) by gabe.freedesktop.org (Postfix) with ESMTP id F39CE9E7C2 for ; Tue, 1 Feb 2011 10:18:02 -0800 (PST) Received: by mail-yx0-f177.google.com with SMTP id 30so2689010yxd.36 for ; Tue, 01 Feb 2011 10:18:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=YvtsVTfKemYCdli496533NDHNeijYn32iTa4SRdkbCs=; b=EGbb4bkemZFZWrvPtQRQjmmMum9f++ZN/aKDZFVVxw3c+s4foyEc0EecowbCC0GVDd ezinS0AcWys4AfEPum++zXnS+Zq1mwxU3j1DrQh/nbQXzmV418W32tnSWNHafvdo+0qp 2baqOB/3xuIalG6BWnq2Ae3LnsxFKV6H3/AFM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=ErscypZo00wnnIH5sYp+DMSnKp6tdtxyEQwBAlrDjZS/7V4SDK20M9/fm0/wk2magQ axfikhW0BQ7UB3rnpe1plgSCnmZU3RPdNqYNa5Q/U9zL6OAVIBX/CL3y03NHHt4O8jXA h3HUBKjshQEjMRnZBxWiJXLs6VLidrLeX2LwQ= Received: by 10.100.10.20 with SMTP id 20mr5036875anj.264.1296584282681; Tue, 01 Feb 2011 10:18:02 -0800 (PST) Received: from localhost.localdomain ([67.208.96.87]) by mx.google.com with ESMTPS id f10sm27543608anh.5.2011.02.01.10.18.00 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 01 Feb 2011 10:18:01 -0800 (PST) From: Ben Widawsky To: intel-gfx@lists.freedesktop.org Date: Tue, 1 Feb 2011 10:16:23 -0800 Message-Id: <1296584186-20446-7-git-send-email-bwidawsk@gmail.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1296584186-20446-1-git-send-email-bwidawsk@gmail.com> References: <1296584186-20446-1-git-send-email-bwidawsk@gmail.com> Subject: [Intel-gfx] [PATCH 6/9] drm/i915/context: minimal support for contexts in execbuffer2 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 01 Feb 2011 18:22:14 +0000 (UTC) diff --git a/drivers/gpu/drm/i915/i915_context.c b/drivers/gpu/drm/i915/i915_context.c index 90b7bf3..a486a9c 100644 --- a/drivers/gpu/drm/i915/i915_context.c +++ b/drivers/gpu/drm/i915/i915_context.c @@ -59,14 +59,19 @@ i915_context_lookup_id(struct drm_device *dev, return idr_find(&dev_priv->i915_ctx_idr, id); } -static void -i915_context_del_id(struct drm_device *dev, - struct drm_i915_gem_context *ctx) +static void i915_context_del_id(struct drm_device *dev, + struct drm_i915_gem_context *ctx) { struct drm_i915_private *dev_priv = dev->dev_private; idr_remove(&dev_priv->i915_ctx_idr, ctx->ctx_id); } +int i915_context_validate(struct drm_device *dev, struct drm_file *file, + uint32_t ctx_id, + struct drm_i915_context_flag *ctx_flag, int count) +{ + return 0; +} /** * i915_context_alloc_backing_obj - Allocate and pin space in the global GTT for * use by the HW to save, and restore context information. diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 695a0bf..48d4e6f 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1323,6 +1323,11 @@ extern void intel_display_print_error_state(struct seq_file *m, extern void i915_context_init(struct drm_device *dev); extern void i915_context_deinit(struct drm_device *dev); extern void i915_context_close(struct drm_device *dev, struct drm_file *file); +struct drm_i915_context_flag; +extern int i915_context_validate(struct drm_device *dev, + struct drm_file *file, uint32_t ctx_id, + struct drm_i915_context_flag *ctx_flag, + int count); #define LP_RING(d) (&((struct drm_i915_private *)(d))->ring[RCS]) diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index d2f445e..a60996d 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -979,7 +979,9 @@ static int i915_gem_do_execbuffer(struct drm_device *dev, void *data, struct drm_file *file, struct drm_i915_gem_execbuffer2 *args, - struct drm_i915_gem_exec_object2 *exec) + struct drm_i915_gem_exec_object2 *exec, + struct drm_i915_context_flag *ctx_flags, + int flag_count) { drm_i915_private_t *dev_priv = dev->dev_private; struct list_head objects; @@ -999,7 +1001,15 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, ret = validate_exec_list(exec, args->buffer_count); if (ret) return ret; - + if (ctx_flags) { + ret = i915_context_validate(dev, file, EXECBUFFER2_CTX_ID(args), + ctx_flags, flag_count); + if (ret) { + if (ret == -EAGAIN) + DRM_DEBUG_DRIVER("Context resubmission required\n"); + return ret; + } + } #if WATCH_EXEC DRM_INFO("buffers_ptr %d buffer_count %d len %08x\n", (int) args->buffers_ptr, args->buffer_count, args->batch_len); @@ -1299,7 +1309,8 @@ i915_gem_execbuffer(struct drm_device *dev, void *data, exec2.cliprects_ptr = args->cliprects_ptr; exec2.flags = I915_EXEC_RENDER; - ret = i915_gem_do_execbuffer(dev, data, file, &exec2, exec2_list); + ret = i915_gem_do_execbuffer(dev, data, file, &exec2, exec2_list, + NULL, 0); if (!ret) { /* Copy the new buffer offsets back to the user's exec list. */ for (i = 0; i < args->buffer_count; i++) @@ -1328,6 +1339,8 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data, { struct drm_i915_gem_execbuffer2 *args = data; struct drm_i915_gem_exec_object2 *exec2_list = NULL; + struct drm_i915_context_flag *flags = NULL; + uint32_t flag_count = 0; int ret; #if WATCH_EXEC @@ -1356,8 +1369,32 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data, drm_free_large(exec2_list); return -EFAULT; } + if (EXECBUFFER2_FLAGS_PTR(args) && EXECBUFFER2_FLAGS_COUNT(argc)) { + flag_count = EXECBUFFER2_FLAGS_COUNT(argc); + flags = drm_malloc_ab(sizeof(*flags), flag_count); + if (flags == NULL) { + DRM_ERROR("allocation of flags failed\n"); + drm_free_large(exec2_list); + /* return -EAGAIN; */ + return -ENOMEM; + } - ret = i915_gem_do_execbuffer(dev, data, file, args, exec2_list); + ret = copy_from_user(flags, + (struct drm_context_flags __user *) + (uintptr_t)EXECBUFFER2_FLAGS_PTR(args), + sizeof(*flags) * flag_count); + if (ret != 0) { + DRM_ERROR("copy %d flags failed %d\n", + flag_count, ret); + drm_free_large(flags); + drm_free_large(exec2_list); + return -EFAULT; + } + ret = i915_gem_do_execbuffer(dev, data, file, args, exec2_list, + flags, flag_count); + } else + ret = i915_gem_do_execbuffer(dev, data, file, args, exec2_list, + NULL, 0); if (!ret) { /* Copy the new buffer offsets back to the user's exec list. */ ret = copy_to_user((struct drm_i915_relocation_entry __user *) diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h index 58c4482..0ebce11 100644 --- a/include/drm/i915_drm.h +++ b/include/drm/i915_drm.h @@ -659,6 +659,21 @@ struct drm_i915_gem_execbuffer2 { __u64 rsvd2; }; +#define EXECBUFFER2_FLAGS_PTR(exec2) (exec2->rsvd1) +#define EXECBUFFER2_FLAGS_COUNT(exec2) ((uint32_t)(args->rsvd2>>32)) +#define EXECBUFFER2_CTX_ID(exec2) ((uint32_t)args->rsvd2 ) + +struct drm_i915_context_flag { + __u8 slot; + __u32 handle; + __u64 offset; + __u32 read_domain; + __u32 write_domain; +#define I915_CTX_ASSOC_BUF (1 << 0) +#define I915_CTX_DISASSOC_BUF (1 << 1) + __u32 command; +}; + struct drm_i915_gem_pin { /** Handle of the buffer to be pinned. */ __u32 handle;