Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3830673pxb; Mon, 4 Oct 2021 10:30:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXmYHhKJkINRxpY93klDhdLJv4kLb+cVE++SXPnyD1sEBW1684PpQavSmwPc0x2Irog3ok X-Received: by 2002:a63:ea44:: with SMTP id l4mr11874689pgk.210.1633368644171; Mon, 04 Oct 2021 10:30:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633368644; cv=none; d=google.com; s=arc-20160816; b=V0z/8DswkdKsopMKbexQj5Uw9jP0WXdl0C1JApX6XnCIVxFoxlP7YLw/cZb2O+YhqM TZ/8PEHL+lZ4kHO4g7MpW2m6kCTGMK1RXntDpAtehqPPp8C5BN88Qyo0/pLTve76uNXC DhogOuzYHWZJtqNxT5KJhbgTPesKHPlXbCM14g+otyq8lCVDKuowECFIS1w+Qxcs8gRa wqDzN+058qxMYYq+JTLFomGjxf6AY85rQgQx1NvgAb3yM2m8CJxlm/8K16UG1BVUU1Vn WU73wMruQIHPqhAhqR8/CL5pdrz3oNOx1moqE0KIPzVaO3YmmHX/8jC5BOSLIHM6GdLI Qqfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=O9u4RfQdKtPsjyImRF6iZlpdDK5Sudf86x5UP9KKfmM=; b=jG/ijMx4IoUvFq6pLnLQ97mZuoW2hjHMF/7kLzfichnxv/ob7Tsdz4w8/XRQpDNdWG VKi9xLZPs/qcHIXHftWmmEPKEt/nFPFGD6VBHZa+4rbD2tfn297gtUAUKm1MpyXbmmZx +IN80sirHz+EMCf4SbTLhXKbxnX5J8g7xl7WarDRbOnaW13I327o2Tp2xqKQo+hrYskg OzNUBiO2G6vsEPmS6G/85BgaPKCmYhgUgqvyF8vbT8n7ZSAIRx94l+A7QBOsLsKCdDqC KKxyCCkZ49aD/blaGhNfMkWeh6m28baTgAfO0EgrE5JHuqz4svcLKuTh8ikypUylBoOz tk+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d11si18355130pls.251.2021.10.04.10.30.27; Mon, 04 Oct 2021 10:30:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234953AbhJDOrL (ORCPT + 99 others); Mon, 4 Oct 2021 10:47:11 -0400 Received: from mga01.intel.com ([192.55.52.88]:16798 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234804AbhJDOrJ (ORCPT ); Mon, 4 Oct 2021 10:47:09 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10126"; a="248713993" X-IronPort-AV: E=Sophos;i="5.85,346,1624345200"; d="scan'208";a="248713993" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2021 07:37:17 -0700 X-IronPort-AV: E=Sophos;i="5.85,346,1624345200"; d="scan'208";a="622303663" Received: from shearne-mobl.ger.corp.intel.com (HELO tursulin-mobl2.home) ([10.213.208.122]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Oct 2021 07:37:14 -0700 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Tvrtko Ursulin , Chris Wilson , Aravind Iddamsetty Subject: [RFC 3/8] drm/i915: Make GEM contexts track DRM clients Date: Mon, 4 Oct 2021 15:36:45 +0100 Message-Id: <20211004143650.699120-4-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211004143650.699120-1-tvrtko.ursulin@linux.intel.com> References: <20211004143650.699120-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tvrtko Ursulin Make GEM contexts keep a reference to i915_drm_client for the whole of of their lifetime which will come handy in following patches. v2: Don't bother supporting selftests contexts from debugfs. (Chris) v3 (Lucas): Finish constructing ctx before adding it to the list v4 (Ram): Rebase. v5: Trivial rebase for proto ctx changes. v6: Rebase after clients no longer track name and pid. Signed-off-by: Tvrtko Ursulin Reviewed-by: Chris Wilson # v5 Reviewed-by: Aravind Iddamsetty # v5 Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/gem/i915_gem_context.c | 5 +++++ drivers/gpu/drm/i915/gem/i915_gem_context_types.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c index 8208fd5b72c3..9296d69681d7 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c @@ -956,6 +956,9 @@ static void i915_gem_context_release_work(struct work_struct *work) if (vm) i915_vm_put(vm); + if (ctx->client) + i915_drm_client_put(ctx->client); + mutex_destroy(&ctx->engines_mutex); mutex_destroy(&ctx->lut_mutex); @@ -1373,6 +1376,8 @@ static void gem_context_register(struct i915_gem_context *ctx, ctx->file_priv = fpriv; ctx->pid = get_task_pid(current, PIDTYPE_PID); + ctx->client = i915_drm_client_get(fpriv->client); + snprintf(ctx->name, sizeof(ctx->name), "%s[%d]", current->comm, pid_nr(ctx->pid)); diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h index c4617e4d9fa9..598c57ac5cdf 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h +++ b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h @@ -277,6 +277,9 @@ struct i915_gem_context { /** @link: place with &drm_i915_private.context_list */ struct list_head link; + /** @client: struct i915_drm_client */ + struct i915_drm_client *client; + /** * @ref: reference count * -- 2.30.2