Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp495204pxb; Thu, 30 Sep 2021 10:21:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzG8nDEGcRiuNQYqzh88G7RGfY0RuRxa0NFQVh/8+Eq8uQ9N3t2sMei024xwf3Osr1gqru4 X-Received: by 2002:a17:902:8c98:b0:13e:51d1:6fbd with SMTP id t24-20020a1709028c9800b0013e51d16fbdmr5335565plo.45.1633022486679; Thu, 30 Sep 2021 10:21:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633022486; cv=none; d=google.com; s=arc-20160816; b=sfgZLV530cPYDfTudjVvBuiSlEzzdyIudL3na+2+jvJDjm4OXZQLMX6hMKIiC7/ehO qSZW9dN9wWvWm2HGxxlnT/2MjzFT+aYEagJQoO8mnzn2SG73XpfBU6aPOh4VHjfEIbXR CMk2qdjA9iAiYMePQd5esfnPAph4qnRB8I3kS+unr2rTWQ46ur0fb7ypTRv3J1CElkCx IwrMTRygVX5tFRmH7/BCuKNUf8lwpYvEoi7FSApwIcWky7bg7PHihy4i0EJllOCOL/lJ ftdDQmqQaZC/Hzr9nkA4aZDmN5gNCgbQhj3q2BWRXybTHPxFiyvGROM/glyWwZNgesET yHlQ== 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=n7YGpaD3Ejnc9kEwFbep49OSVhkodRN0+TScVR6S2KhNKBEWtN2I5gQawFtJ+mICjN ZVungneYymntlhf4z/hGVe/o0qUMKR/grw/P/hHgjvorj+gqGw6f0oLZSQnSkx/LdMpR ppxpa1xYIYvDAjuuWFsIwVU0QTESeS/UooUcFmS454H+4UcL0SuRuGtVf6AZ/qcOlAUp CUWXUGaxi9F0sWzhjZRuLPOmIvT9LhQQQm88nUdl1uchsX814IBB9oaQA7BS0AaudMIF 9CHU9jmYUSUjKjyjAHlOpLCjT0XdHS1XYK9tFdieJgo1f6pUNnMLNAyHW/4ji1xSd+C4 WQLg== 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 h21si4365986pgv.209.2021.09.30.10.21.12; Thu, 30 Sep 2021 10:21:26 -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 S1352513AbhI3RUU (ORCPT + 99 others); Thu, 30 Sep 2021 13:20:20 -0400 Received: from mga05.intel.com ([192.55.52.43]:4357 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352486AbhI3RUK (ORCPT ); Thu, 30 Sep 2021 13:20:10 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10123"; a="310787665" X-IronPort-AV: E=Sophos;i="5.85,336,1624345200"; d="scan'208";a="310787665" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2021 10:16:25 -0700 X-IronPort-AV: E=Sophos;i="5.85,336,1624345200"; d="scan'208";a="520489703" Received: from dboland-mobl.ger.corp.intel.com (HELO tursulin-mobl2.home) ([10.213.223.141]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2021 10:16:23 -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/6] drm/i915: Make GEM contexts track DRM clients Date: Thu, 30 Sep 2021 18:15:49 +0100 Message-Id: <20210930171552.501553-4-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210930171552.501553-1-tvrtko.ursulin@linux.intel.com> References: <20210930171552.501553-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