From patchwork Tue Apr 17 12:27:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10344903 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 33387601D7 for ; Tue, 17 Apr 2018 12:28:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A5D8286EC for ; Tue, 17 Apr 2018 12:28:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F2AB28A8E; Tue, 17 Apr 2018 12:28:22 +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=-5.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,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 B5EDF286EC for ; Tue, 17 Apr 2018 12:28:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E4A9A6E40F; Tue, 17 Apr 2018 12:28:16 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 05C8E6E160 for ; Tue, 17 Apr 2018 12:28:13 +0000 (UTC) Received: by mail-wr0-x244.google.com with SMTP id z73so34989671wrb.0 for ; Tue, 17 Apr 2018 05:28:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8F2XZbZIhDcPmTrRLBh1u3+XJbyfnhThcZRyyCxcVEc=; b=lCrN72j6tLD4SdhSMHH12qbyNvpUKIz0b8LNkm68eLjqZo17/eUCXGIBTu36NM2Nx/ /f88FuibtLPYu9tIxD2KseHYPqT9PaWTQrz4WPqOk+U4BTiYX7wx2QpZtQHUofo0Xcdk uUawcrKdparFrl1IijxGR5s1ZU/JQFoJ8L7cAU35qYxBoQ7NpdKqAY8rBVFLm+UTn2ZP eNynTw1tKTeYtUkAmZxiEaslIKT3RfeIXyTutMuDtMcbYRemqeL0I7q6GnXowgJTlFhA EeN/ZReq3kbb9Qhr8Fh9E0drK/1ThIF/ENR8vONs+qXdmh5ZOkasOoCoNfaZlasaaof7 8bVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8F2XZbZIhDcPmTrRLBh1u3+XJbyfnhThcZRyyCxcVEc=; b=DRFS+9XvV/5y7arWimwdbUlyFcKaqSM7H8EQJ4710aVnMPNipVnAGEUezPLq8lx6HM dJlUcNHADVaod5eVaVL8z0yJdUJFPH76/diDClfitRCL3mT3RTjc11/9sOaj0Xe7qR9H eMWqmLB6ji2HhhRxhDKN162fVl4Kl+RA669sBJ9xbjuzjh9XS6yAQ81XeYuCaQNh2cZl KW0DPqq8lgjB9UJD8o2OSMdFdK5bMbaqdqLZzEltd8Oby0ZoggRfSHBCyyZh668C7EMG tbMFj2ARhYFkvu75M6RiZbfeRnpQIgMNfSf7kqLPPZKPLTbQoWGmp2uAxO1R6MHfIQrV qe8Q== X-Gm-Message-State: ALQs6tAFpTuSEPUKWjVhUFB+8ylprPLU3vKglOL1ugjSKeCYmOaLpr3G bVfFhNUOyoNSIweK4bhhNJvf6A== X-Google-Smtp-Source: AIpwx4+be2APuKO+0PX0PFIbqqFDjuwZsKy/KmzKSzG2L/LarFuX1S8u39s00syHo0HgA/OOavNMsw== X-Received: by 10.28.66.90 with SMTP id p87mr904740wma.58.1523968091671; Tue, 17 Apr 2018 05:28:11 -0700 (PDT) Received: from localhost.localdomain ([95.146.151.144]) by smtp.gmail.com with ESMTPSA id f22sm9226027wmc.3.2018.04.17.05.28.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Apr 2018 05:28:11 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Tue, 17 Apr 2018 13:27:33 +0100 Message-Id: <20180417122736.11603-5-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180417122736.11603-1-tvrtko.ursulin@linux.intel.com> References: <20180417122736.11603-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [RFC 4/7] drm/i915: Update client name on context create X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Intel-gfx@lists.freedesktop.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin Some clients have the DRM fd passed to them over a socket by the X server. Grab the real client and pid when they create their first context and update the exposed data for more useful enumeration. Signed-off-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/i915_drv.h | 8 ++++++++ drivers/gpu/drm/i915/i915_gem.c | 4 ++-- drivers/gpu/drm/i915/i915_gem_context.c | 16 +++++++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index ff2ad9719b1e..456dc495e017 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -3195,6 +3195,14 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj, void i915_gem_object_unpin_from_display_plane(struct i915_vma *vma); int i915_gem_object_attach_phys(struct drm_i915_gem_object *obj, int align); + +int +i915_gem_add_client(struct drm_i915_private *i915, + struct drm_i915_file_private *file_priv, + struct task_struct *task, + unsigned int serial); +void i915_gem_remove_client(struct drm_i915_file_private *file_priv); + int i915_gem_open(struct drm_i915_private *i915, struct drm_file *file); void i915_gem_release(struct drm_device *dev, struct drm_file *file); diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 421e6c9e95f4..4c20545e3539 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -5728,7 +5728,7 @@ show_client_pid(struct device *kdev, struct device_attribute *attr, char *buf) return snprintf(buf, PAGE_SIZE, "%u", file_priv->client.pid); } -static int +int i915_gem_add_client(struct drm_i915_private *i915, struct drm_i915_file_private *file_priv, struct task_struct *task, @@ -5786,7 +5786,7 @@ i915_gem_add_client(struct drm_i915_private *i915, return ret; } -static void i915_gem_remove_client(struct drm_i915_file_private *file_priv) +void i915_gem_remove_client(struct drm_i915_file_private *file_priv) { sysfs_remove_file(file_priv->client.root, (struct attribute *)&file_priv->client.attr.pid); diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 85627fa4565b..e9b0940ce7f9 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -653,9 +653,10 @@ static bool client_is_banned(struct drm_i915_file_private *file_priv) int i915_gem_context_create_ioctl(struct drm_device *dev, void *data, struct drm_file *file) { + struct drm_i915_file_private *file_priv = file->driver_priv; + pid_t pid = pid_nr(get_task_pid(current, PIDTYPE_PID)); struct drm_i915_private *dev_priv = to_i915(dev); struct drm_i915_gem_context_create *args = data; - struct drm_i915_file_private *file_priv = file->driver_priv; struct i915_gem_context *ctx; int ret; @@ -667,8 +668,7 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data, if (client_is_banned(file_priv)) { DRM_DEBUG("client %s[%d] banned from creating ctx\n", - current->comm, - pid_nr(get_task_pid(current, PIDTYPE_PID))); + current->comm, pid); return -EIO; } @@ -677,6 +677,16 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data, if (ret) return ret; + if (file_priv->client.pid != pid) { + i915_gem_remove_client(file_priv); + ret = i915_gem_add_client(dev_priv, file_priv, current, + file_priv->client.id); + if (ret) { + mutex_unlock(&dev->struct_mutex); + return ret; + } + } + ctx = i915_gem_create_context(dev_priv, file_priv); mutex_unlock(&dev->struct_mutex); if (IS_ERR(ctx))