From patchwork Thu Nov 17 13:00:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 9434219 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AC06960238 for ; Thu, 17 Nov 2016 13:00:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B5A8294C2 for ; Thu, 17 Nov 2016 13:00:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DC64294CE; Thu, 17 Nov 2016 13:00:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DC471294C2 for ; Thu, 17 Nov 2016 13:00:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 363A06E2F1; Thu, 17 Nov 2016 13:00:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 642596E7E5 for ; Thu, 17 Nov 2016 13:00:52 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id u144so21035301wmu.0 for ; Thu, 17 Nov 2016 05:00:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id; bh=IRHJmMchxMMAM962/CW3zewq6sK/823Ru61GCPZ1s4Y=; b=eywUTYqfhWrxL7DpwPPRjvAyEx9LfwIQ1brrp+A0cItWIDZfQSIg4aKrm2Qj6Zargr +YTDqdrPnqKE3qfYQC2BERgtonfiKkzV/mWrJ59KEBVo4sSdBFO3es3LuxYdnU1+VrEu EabYNj0giDITEvMPds0EyAnNjqYLPDWoXItnf1WlaLNN1jvjyvVKO+tvdC6j4eCGJfmI jfo6X75BqWNo05bDz70DVkYgCowu6xXu4ABBTbx2uFY7BfpAIFJtmO+nLKzoZrNmhxRk dYzbJZhrheDoW0B7A+FAb5bkMmMsPzP3pb7PPeMzLgh4F1ZNPtJB9TuhVKCxwDKznxFe xvAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id; bh=IRHJmMchxMMAM962/CW3zewq6sK/823Ru61GCPZ1s4Y=; b=K7EDVJJVPVDkNTC/WqbyZ7zmKDVPv/dme9fHC49DVR3PhvigShVjHDwSTBidhIBxsH Sbh1ufvtFcqjeHeSRZ/ZX1PEwYDHsWFDbqg8dCyC+o3FV7tgluVMvE9mCOV6VT8wpbi2 0tlMyS7MlCDz5sxoNoTxyS0AW0Yv7AsE0B69bUQ1DdtOg8vDb0NP9KJpvNsEDs11TD1z oUmCnuZfjcpcqvjAZfe/WY4/E/9a3ls9i+wxuTrgZ1h2jriE3DpjKb2cVqsx45jh1E04 8jOAC+xV5EB7rhbg227F0QTVzlGJiPePKkzl6D4h9ZXwsyJj62UCLNJJIgoLVNw9lkZN bbMg== X-Gm-Message-State: AKaTC03PZQdK8lWDueT6hGfSB6ixR/eeAkMf6t69zqHMIocNY/YxvoYk5jpZURk0IEQVeA== X-Received: by 10.194.19.101 with SMTP id d5mr1905261wje.18.1479387650683; Thu, 17 Nov 2016 05:00:50 -0800 (PST) Received: from sixbynine.org (host-78-151-23-30.as13285.net. [78.151.23.30]) by smtp.gmail.com with ESMTPSA id d10sm3166029wja.20.2016.11.17.05.00.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Nov 2016 05:00:50 -0800 (PST) From: Robert Bragg To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm] intel: Add a getter for the intel_context ctx_id Date: Thu, 17 Nov 2016 13:00:49 +0000 Message-Id: <20161117130049.5627-1-robert@sixbynine.org> X-Mailer: git-send-email 2.10.1 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP I forgot that my recently sent out i915-perf i-g-t tests depend on this utility api (not just my Mesa / GL_INTEL_performance_query patches). Not all tests in i-g-t use libdrm to create contexts, but the i915-perf tests use render_copy (drm_intel_context based) while testing single context filtering and so want to pluck out the u32 ctx_id for passing to i915-perf. I made a last moment tweak to the utility to return an error value separate from a uint32_t output ctx_id pointer, so there will need to be a corresponding tweak of the perf.c tests I sent out. Regards, - Robert --- >8 --- Exposing the u32 context ID makes it possible to define new drm kernel interfaces based on the same IDs that e.g. execbuf uses to identify a gem context, that aren't themselves abstracted by libdrm but need to be used by libdrm/drm_intel_context based clients such as (parts of) i-g-t or Mesa. For example this can be used to configure an i915-perf stream to collect metrics for a specific context. Signed-off: Robert Bragg --- intel/intel_bufmgr.h | 2 ++ intel/intel_bufmgr_gem.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/intel/intel_bufmgr.h b/intel/intel_bufmgr.h index ce4e70d..7530fa5 100644 --- a/intel/intel_bufmgr.h +++ b/intel/intel_bufmgr.h @@ -212,6 +212,8 @@ int drm_intel_bufmgr_gem_get_devid(drm_intel_bufmgr *bufmgr); int drm_intel_gem_bo_wait(drm_intel_bo *bo, int64_t timeout_ns); drm_intel_context *drm_intel_gem_context_create(drm_intel_bufmgr *bufmgr); +int drm_intel_gem_context_get_context_id(drm_intel_context *ctx, + uint32_t *ctx_id); void drm_intel_gem_context_destroy(drm_intel_context *ctx); int drm_intel_gem_bo_context_exec(drm_intel_bo *bo, drm_intel_context *ctx, int used, unsigned int flags); diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index 15c79b3..cefe4a7 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -3184,6 +3184,17 @@ drm_intel_gem_context_create(drm_intel_bufmgr *bufmgr) return context; } +int +drm_intel_gem_context_get_context_id(drm_intel_context *ctx, uint32_t *ctx_id) +{ + if (ctx == NULL) + return -EINVAL; + + *ctx_id = ctx->ctx_id; + + return 0; +} + void drm_intel_gem_context_destroy(drm_intel_context *ctx) {