From patchwork Mon Oct 16 18:41:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 13424013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7CAFCDB465 for ; Mon, 16 Oct 2023 18:42:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4444510E00B; Mon, 16 Oct 2023 18:42:05 +0000 (UTC) Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by gabe.freedesktop.org (Postfix) with ESMTPS id EFC3310E00B for ; Mon, 16 Oct 2023 18:42:03 +0000 (UTC) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-68fb85afef4so3827639b3a.1 for ; Mon, 16 Oct 2023 11:42:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1697481723; x=1698086523; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/6WZJz45cUsK68zoTOTamsyrEphZOqaei7wiOeu4KLY=; b=WBo6etMO5HmQBUZQ6nDcWNHREAmkDaRUWln3UfEhLY2JjLIGEziSsTPaUcsl5KJJRL 3NbBpx76JRG8rmh+KUjvKiyrag/IZOfG1TXfDFFyf7uhwelBui1Yoouf1VOekRNnjjUJ iA0zQOT4ZuMlSEv/lxNi/zDWXqctWdh8hlUWM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697481723; x=1698086523; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/6WZJz45cUsK68zoTOTamsyrEphZOqaei7wiOeu4KLY=; b=Rb6wcGEeBoEDbN3dGW4Qq21sWsvImn/SnYZbxnraWWpVzu1bWN2KLfNPwkfdhxHAvF FdaAPVMusICJ7P5Ay14sUSLnwfPyfLa3hA4+Vv6I2B1AFmTXZEyed8JaHEtEtbksO5d1 I7ZkZ9ruBFXFlru83Je2VzhoFdaoE6FsJ2mp3flpV/cl+YGuBFkqpBUQQ+YS/jPcjnns b4hGAxOs9YTV4OZIlL694Boqe7TEoBe5gnVJVGzxR9cfIu9ggPoo487FKcfOC0PU8OXV gfrCoEe6E1C6aIBF1OmJgD+rP8znjdL9P9TTV8Ek/9cKSrkqe1QUlPuTiuWj7POaU0Yc tNRw== X-Gm-Message-State: AOJu0YwS206WlI42zGclkUSogA7GtoRv3Q9DGjwnhI2h4iOYmbfiPS8H IEN21TBitHLDbyY8p07rFsv6TwqtWe6E6dHtAHA= X-Google-Smtp-Source: AGHT+IGU3WJBZtzKTObRorjELiamT+jizeHAUSBpFphWKT29ZD32dBtgkl7poh8klrVV4uOzUSE1gw== X-Received: by 2002:a05:6a00:194a:b0:6bd:9281:9453 with SMTP id s10-20020a056a00194a00b006bd92819453mr13296pfk.9.1697481722963; Mon, 16 Oct 2023 11:42:02 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:a7:2:9fd0:fd3c:780a:6af7]) by smtp.gmail.com with ESMTPSA id x28-20020a056a00189c00b0068a46cd4120sm218735pfh.199.2023.10.16.11.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 11:42:02 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/3] drm/virtio: use uint64_t more in virtio_gpu_context_init_ioctl Date: Mon, 16 Oct 2023 11:41:58 -0700 Message-Id: <20231016184200.639-1-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com, dmitry.osipenko@collabora.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" drm_virtgpu_context_set_param defines both param and value to be u64s. Signed-off-by: Gurchetan Singh Reviewed-by: Josh Simonot Reviewed-by: Dmitry Osipenko --- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index b24b11f25197..8d13b17c215b 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -565,8 +565,8 @@ static int virtio_gpu_context_init_ioctl(struct drm_device *dev, void *data, struct drm_file *file) { int ret = 0; - uint32_t num_params, i, param, value; - uint64_t valid_ring_mask; + uint32_t num_params, i; + uint64_t valid_ring_mask, param, value; size_t len; struct drm_virtgpu_context_set_param *ctx_set_params = NULL; struct virtio_gpu_device *vgdev = dev->dev_private; From patchwork Mon Oct 16 18:41:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 13424014 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5C388CDB465 for ; Mon, 16 Oct 2023 18:42:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 158D610E236; Mon, 16 Oct 2023 18:42:07 +0000 (UTC) Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by gabe.freedesktop.org (Postfix) with ESMTPS id BF25B10E00B for ; Mon, 16 Oct 2023 18:42:04 +0000 (UTC) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6b5cac99cfdso2273530b3a.2 for ; Mon, 16 Oct 2023 11:42:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1697481724; x=1698086524; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7jAFFYinHZhCREdHd0fA7hDznAJrXS3vHKq9UJd0JcE=; b=HTDg8gSoKsv80nsihZD/eVFiQU71iM+SXN8KXdIm1Xn6CHmU/A85aeU2qIWEbldFkI o2iAaXvwjlPqV7BkB5OJLXJEES+7HbCqRDyTyrOyf57V4cPhpYZWXNv/c23W5Tj+3v4n IeaE/mZe/x/PsCjVgzGrL7v0Bv/4pxw6TKHTY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697481724; x=1698086524; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7jAFFYinHZhCREdHd0fA7hDznAJrXS3vHKq9UJd0JcE=; b=T97WmhNePHAscM+ma+mNUX3Aj/ml1v6paZYqxepKb6UE8XLAvTv/uGa+Vb3jcg9n0E M2wRiWisXiqgQB7mZpS/oX29pFnGwjkhp78JOaJYvlVjy9fZVYIa0ldhEenkhbin0Xgk GDByG6VeFtazj740bHH60RM/m3vO/6gNLSlGL+s+u36kPkdf1oETpzI8BB+/9hUvebbk F0Y+h87YtszO34i+/yf1QrLAH8fNsr2iPq5WT/6eXTCVSuyZTsReZNn7sa9uwpgV8X2Z QnLLq2WvZ5jrY20TaSQh1AM7ZF3XgGh379KE6SmNaKXbkUIeNypqwDkQ5Su5K/6EHUXD xEzA== X-Gm-Message-State: AOJu0YyQAMAYg13P6Ux4c0VyOHSXAIBM26tu43BqK9+dYSnZJaL5lIwS hbDihThgAl/SzGMhIyAK7/cPNtaOU4pQiPuCRLc= X-Google-Smtp-Source: AGHT+IE1ud5MMvEQDU/n0J2zets/9+0ryz8YRnLxfxsx5IH7sBKK9ROvhY3CroV3q177i/jJFDvd2g== X-Received: by 2002:a05:6a00:134a:b0:6be:2dce:cf5a with SMTP id k10-20020a056a00134a00b006be2dcecf5amr3103924pfu.26.1697481724013; Mon, 16 Oct 2023 11:42:04 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:a7:2:9fd0:fd3c:780a:6af7]) by smtp.gmail.com with ESMTPSA id x28-20020a056a00189c00b0068a46cd4120sm218735pfh.199.2023.10.16.11.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 11:42:03 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/3] drm/uapi: add explicit virtgpu context debug name Date: Mon, 16 Oct 2023 11:41:59 -0700 Message-Id: <20231016184200.639-2-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20231016184200.639-1-gurchetansingh@chromium.org> References: <20231016184200.639-1-gurchetansingh@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com, dmitry.osipenko@collabora.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" There are two problems with the current method of determining the virtio-gpu debug name. 1) TASK_COMM_LEN is defined to be 16 bytes only, and this is a Linux kernel idiom (see PR_SET_NAME + PR_GET_NAME). Though, Android/FreeBSD get around this via setprogname(..)/getprogname(..) in libc. On Android, names longer than 16 bytes are common. For example, one often encounters a program like "com.android.systemui". The virtio-gpu spec allows the debug name to be up to 64 bytes, so ideally userspace should be able to set debug names up to 64 bytes. 2) The current implementation determines the debug name using whatever task initiated virtgpu. This is could be a "RenderThread" of a larger program, when we actually want to propagate the debug name of the program. To fix these issues, add a new CONTEXT_INIT param that allows userspace to set the debug name when creating a context. It takes a null-terminated C-string as the param value. Link to open-source userspace: https://android-review.googlesource.com/c/platform/hardware/google/gfxstream/+/2787176 Signed-off-by: Gurchetan Singh Reviewed-by: Josh Simonot --- include/uapi/drm/virtgpu_drm.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h index b1d0e56565bc..c2ce71987e9b 100644 --- a/include/uapi/drm/virtgpu_drm.h +++ b/include/uapi/drm/virtgpu_drm.h @@ -97,6 +97,7 @@ struct drm_virtgpu_execbuffer { #define VIRTGPU_PARAM_CROSS_DEVICE 5 /* Cross virtio-device resource sharing */ #define VIRTGPU_PARAM_CONTEXT_INIT 6 /* DRM_VIRTGPU_CONTEXT_INIT */ #define VIRTGPU_PARAM_SUPPORTED_CAPSET_IDs 7 /* Bitmask of supported capability set ids */ +#define VIRTGPU_PARAM_EXPLICIT_DEBUG_NAME 8 /* Ability to set debug name from userspace */ struct drm_virtgpu_getparam { __u64 param; @@ -198,6 +199,7 @@ struct drm_virtgpu_resource_create_blob { #define VIRTGPU_CONTEXT_PARAM_CAPSET_ID 0x0001 #define VIRTGPU_CONTEXT_PARAM_NUM_RINGS 0x0002 #define VIRTGPU_CONTEXT_PARAM_POLL_RINGS_MASK 0x0003 +#define VIRTGPU_CONTEXT_PARAM_DEBUG_NAME 0x0004 struct drm_virtgpu_context_set_param { __u64 param; __u64 value; From patchwork Mon Oct 16 18:42:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 13424015 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 88327CDB465 for ; Mon, 16 Oct 2023 18:42:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 044EF10E240; Mon, 16 Oct 2023 18:42:11 +0000 (UTC) Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2914210E236 for ; Mon, 16 Oct 2023 18:42:06 +0000 (UTC) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6b87c1edfd5so1924552b3a.1 for ; Mon, 16 Oct 2023 11:42:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1697481725; x=1698086525; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qcVYSFrcn0wmcrVCWCtuQmtDHw9+zKA8hiKcgvGFiPY=; b=H7LnrRseYBw8zVOdA3L+o2EohJLQFTbN6SPPDj7/xAW0acMoWxf93nqEprXfbfyXns VEW3ZQm/k15TWGNLzv17f9FmFr15Q/hmaJnPN0OuUG7ProzzBBmZYBhM+/UjPELc2Hxl 5dgXaiHTHsC+dbcn54bsMmRIgOBd3UkvQUgNM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697481725; x=1698086525; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qcVYSFrcn0wmcrVCWCtuQmtDHw9+zKA8hiKcgvGFiPY=; b=YKPn20WoRODvLArp6aC78TkRdrMQVweSoL0T37Uiizhm6OJjyO9f2Zvi6firpnM9AT /EaaWGhayQ/eFG0QVcbkfrY0l7QBaJcWe2EnjmGyoOCJqZTdwOFNvAmAuV/30TOaNGCr FiWeJ889HeGGHKxc4lUclJKe40zh8ie9oUJadM7vedwOScPVcpGkqtCRnZNUOTkvKUPu wwXAosrvnP3bY68nmESgyHvqq8K5W9F4r0uqdBfKxKu1aigmFzftcJLhEhVzyG2u/lkT hT4kLx2RfsQaHQY74LuNdQPcbet99+cxIbKdBp//CntGU5vVh7nsQzpKZLdMqq0IWGNH mY2A== X-Gm-Message-State: AOJu0YyFBrBsRgbISi8sV7tg3B6vrtMaDxUdHCDl1Iy6OyGGAk5f+uvX 0tBWh1ub6IU6qrrZwK5ogBSj3WCNY6I2UwJuIIM= X-Google-Smtp-Source: AGHT+IECFQNrnub37b3haZCrBbhuzh+qEYOSze5qKbRtY/g+1xlm+cAE1gweBqjdwd+J8BRbiFbEMw== X-Received: by 2002:a05:6a00:2396:b0:6be:11ac:98a5 with SMTP id f22-20020a056a00239600b006be11ac98a5mr3693582pfc.27.1697481725006; Mon, 16 Oct 2023 11:42:05 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:a7:2:9fd0:fd3c:780a:6af7]) by smtp.gmail.com with ESMTPSA id x28-20020a056a00189c00b0068a46cd4120sm218735pfh.199.2023.10.16.11.42.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 11:42:04 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/3] drm/virtio: implement debug name via CONTEXT_INIT Date: Mon, 16 Oct 2023 11:42:00 -0700 Message-Id: <20231016184200.639-3-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20231016184200.639-1-gurchetansingh@chromium.org> References: <20231016184200.639-1-gurchetansingh@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com, dmitry.osipenko@collabora.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This allows setting the debug name during CONTEXT_INIT. Signed-off-by: Gurchetan Singh Reviewed-by: Josh Simonot --- drivers/gpu/drm/virtio/virtgpu_drv.h | 4 +++ drivers/gpu/drm/virtio/virtgpu_ioctl.c | 38 ++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index 96365a772f77..c0702d630e05 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -58,6 +58,8 @@ #define MAX_CAPSET_ID 63 #define MAX_RINGS 64 +#define DEBUG_NAME_MAX_LEN 64 + struct virtio_gpu_object_params { unsigned long size; bool dumb; @@ -274,6 +276,8 @@ struct virtio_gpu_fpriv { uint64_t base_fence_ctx; uint64_t ring_idx_mask; struct mutex context_lock; + char debug_name[DEBUG_NAME_MAX_LEN]; + char explicit_debug_name; }; /* virtgpu_ioctl.c */ diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index 8d13b17c215b..4d6d44a4c899 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -42,12 +42,19 @@ static void virtio_gpu_create_context_locked(struct virtio_gpu_device *vgdev, struct virtio_gpu_fpriv *vfpriv) { - char dbgname[TASK_COMM_LEN]; + if (vfpriv->explicit_debug_name) { + virtio_gpu_cmd_context_create(vgdev, vfpriv->ctx_id, + vfpriv->context_init, + strlen(vfpriv->debug_name), + vfpriv->debug_name); + } else { + char dbgname[TASK_COMM_LEN]; - get_task_comm(dbgname, current); - virtio_gpu_cmd_context_create(vgdev, vfpriv->ctx_id, - vfpriv->context_init, strlen(dbgname), - dbgname); + get_task_comm(dbgname, current); + virtio_gpu_cmd_context_create(vgdev, vfpriv->ctx_id, + vfpriv->context_init, strlen(dbgname), + dbgname); + } vfpriv->context_created = true; } @@ -107,6 +114,9 @@ static int virtio_gpu_getparam_ioctl(struct drm_device *dev, void *data, case VIRTGPU_PARAM_SUPPORTED_CAPSET_IDs: value = vgdev->capset_id_mask; break; + case VIRTGPU_PARAM_EXPLICIT_DEBUG_NAME: + value = vgdev->has_context_init ? 1 : 0; + break; default: return -EINVAL; } @@ -580,7 +590,7 @@ static int virtio_gpu_context_init_ioctl(struct drm_device *dev, return -EINVAL; /* Number of unique parameters supported at this time. */ - if (num_params > 3) + if (num_params > 4) return -EINVAL; ctx_set_params = memdup_user(u64_to_user_ptr(args->ctx_set_params), @@ -642,6 +652,22 @@ static int virtio_gpu_context_init_ioctl(struct drm_device *dev, vfpriv->ring_idx_mask = value; break; + case VIRTGPU_CONTEXT_PARAM_DEBUG_NAME: + if (vfpriv->explicit_debug_name) { + ret = -EINVAL; + goto out_unlock; + } + + ret = strncpy_from_user(vfpriv->debug_name, + (const char __user *)u64_to_user_ptr(value), + DEBUG_NAME_MAX_LEN); + if (ret < 0) { + ret = -EFAULT; + goto out_unlock; + } + + vfpriv->explicit_debug_name = true; + break; default: ret = -EINVAL; goto out_unlock;