From patchwork Tue Feb 11 23:56:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11377233 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 265F714E3 for ; Tue, 11 Feb 2020 23:56:53 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0554F206DA for ; Tue, 11 Feb 2020 23:56:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="PapbMS+4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0554F206DA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 547A66F459; Tue, 11 Feb 2020 23:56:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by gabe.freedesktop.org (Postfix) with ESMTPS id 262446F459 for ; Tue, 11 Feb 2020 23:56:49 +0000 (UTC) Received: by mail-pj1-x1043.google.com with SMTP id e9so48898pjr.4 for ; Tue, 11 Feb 2020 15:56:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DOGovaF1rwceJxVXhyVY03arUQGRSXt/anANw0NupLo=; b=PapbMS+4FWcsirFx2/AXW7KXnXXPQpw8oTzssCLb3vILsnjJwQK4YP7fID1QRlqsIH 3K5HTy3eVkZnoe4AKri58BtP5cOTooF7gHQCLFxLGYAYvp8uD/CmTPSTFuF4qVc1+qQ9 vI+lvRbzMfNASfDPcBYNgMAGp8F3aTD8bqYqU= 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:mime-version:content-transfer-encoding; bh=DOGovaF1rwceJxVXhyVY03arUQGRSXt/anANw0NupLo=; b=dSHyVhJr+atwoUVdbWT/JxlcwKlbK2seZk0JK7Zc0kUTcgx+w0+wQcJVAsp8hFosdn ySMxSWIare6GO8UCxBic0fnK/UNnlQwldswweEmp1ZCMVb3lEBZ5/1999rSagsePjbbU GJtFds1hnmFpIgykWYXLQtq0ujsWYqrbMYi5g8MZLDNOtovRKIdOXSEUaf3wpe/l2ygF A8Nr3/BM1pQ1n8maunxtswrtH+MGk75u9+EC4VH/2Gnq0DXAVaWtMgL5qA0ZTl9NR4wQ elYpFomksXW61V9Doq1tRd+rImDCPCBTlubWNUAz1mxafpCeImd7Vav02Ngizhklavo/ fxmA== X-Gm-Message-State: APjAAAUIu9x4dwEPXLfeOU8tFeFUrC0IxcSrfmjdHI3zJW/Ps09iPFEm Kg5yRa4SEVMmRaBDweuZXUsRyw57b7DC9A== X-Google-Smtp-Source: APXvYqwKF+BMSfp3USRwuvv3EurC/fZTBGNNhw0VlDUEOlQYw4kjzXSzAVhQ4ZUVfFNhuCRJFeX8bg== X-Received: by 2002:a17:902:b412:: with SMTP id x18mr5502752plr.292.1581465408413; Tue, 11 Feb 2020 15:56:48 -0800 (PST) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:bc97:5740:52a7:6875]) by smtp.gmail.com with ESMTPSA id a13sm5816291pfg.65.2020.02.11.15.56.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Feb 2020 15:56:47 -0800 (PST) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/4] drm/virtio: use consistent names for drm_files Date: Tue, 11 Feb 2020 15:56:32 -0800 Message-Id: <20200211235635.488-2-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200211235635.488-1-gurchetansingh@chromium.org> References: <20200211235635.488-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: Gurchetan Singh , kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Minor cleanup, change: - file_priv--> file, - drm_file --> file. Signed-off-by: Gurchetan Singh --- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index 75d818d707e6..89d90e95900f 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -34,12 +34,12 @@ #include "virtgpu_drv.h" static int virtio_gpu_map_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv) + struct drm_file *file) { struct virtio_gpu_device *vgdev = dev->dev_private; struct drm_virtgpu_map *virtio_gpu_map = data; - return virtio_gpu_mode_dumb_mmap(file_priv, vgdev->ddev, + return virtio_gpu_mode_dumb_mmap(file, vgdev->ddev, virtio_gpu_map->handle, &virtio_gpu_map->offset); } @@ -51,11 +51,11 @@ static int virtio_gpu_map_ioctl(struct drm_device *dev, void *data, * VIRTIO_GPUReleaseInfo struct (first XXX bytes) */ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, - struct drm_file *drm_file) + struct drm_file *file) { struct drm_virtgpu_execbuffer *exbuf = data; struct virtio_gpu_device *vgdev = dev->dev_private; - struct virtio_gpu_fpriv *vfpriv = drm_file->driver_priv; + struct virtio_gpu_fpriv *vfpriv = file->driver_priv; struct virtio_gpu_fence *out_fence; int ret; uint32_t *bo_handles = NULL; @@ -116,7 +116,7 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, goto out_unused_fd; } - buflist = virtio_gpu_array_from_handles(drm_file, bo_handles, + buflist = virtio_gpu_array_from_handles(file, bo_handles, exbuf->num_bo_handles); if (!buflist) { ret = -ENOENT; @@ -178,7 +178,7 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, } static int virtio_gpu_getparam_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv) + struct drm_file *file) { struct virtio_gpu_device *vgdev = dev->dev_private; struct drm_virtgpu_getparam *param = data; @@ -201,7 +201,7 @@ static int virtio_gpu_getparam_ioctl(struct drm_device *dev, void *data, } static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv) + struct drm_file *file) { struct virtio_gpu_device *vgdev = dev->dev_private; struct drm_virtgpu_resource_create *rc = data; @@ -252,7 +252,7 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data, return ret; obj = &qobj->base.base; - ret = drm_gem_handle_create(file_priv, obj, &handle); + ret = drm_gem_handle_create(file, obj, &handle); if (ret) { drm_gem_object_release(obj); return ret; @@ -265,13 +265,13 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data, } static int virtio_gpu_resource_info_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv) + struct drm_file *file) { struct drm_virtgpu_resource_info *ri = data; struct drm_gem_object *gobj = NULL; struct virtio_gpu_object *qobj = NULL; - gobj = drm_gem_object_lookup(file_priv, ri->bo_handle); + gobj = drm_gem_object_lookup(file, ri->bo_handle); if (gobj == NULL) return -ENOENT; From patchwork Tue Feb 11 23:56:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11377235 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F7E714E3 for ; Tue, 11 Feb 2020 23:56:55 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6DC41206DA for ; Tue, 11 Feb 2020 23:56:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="eeuoTCtb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6DC41206DA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F03E66F45D; Tue, 11 Feb 2020 23:56:52 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by gabe.freedesktop.org (Postfix) with ESMTPS id B27AE6F45A for ; Tue, 11 Feb 2020 23:56:51 +0000 (UTC) Received: by mail-pg1-x544.google.com with SMTP id b35so76961pgm.13 for ; Tue, 11 Feb 2020 15:56:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=so6FpOtCSORirIXhpIDnv9Uz2ayvCltwYBKqzevADcM=; b=eeuoTCtb/S2LT3P4iKDPHxSvOgxzI9QWzrPcZXwehfTgouOeqq15nqdlQXdRV8Hesn SIEBETVO3h5TTxjRgkAoSrWPrwjpbiHt9TdGE8NNqG7ayOPdBGypV1SxXHzd4yyULQyy 3vbC8DLhWbOJnFbyh7uu/yWDaL1+jlFQKLYhg= 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:mime-version:content-transfer-encoding; bh=so6FpOtCSORirIXhpIDnv9Uz2ayvCltwYBKqzevADcM=; b=tGgH4Kk+tcx1TbXL1zqKAzhDm2R+qxqyAYFvdvxvQWLHYSsn5doujTz9NqudwE7wfB AcZD83e/8IWk3ZBsR8MrmUZiD4snb85OyC8wvZvLh2NIYwWrZWkwdeXPqfhvoSVuO6Dp RWo52q8HuxwsKpvZke0mxdIlQGZj7xfliAT0Rh83CkTuwXa5Onz0KDoSHFO+B25a0kJS eoa37X9s7zl9tPuNgrbdQbuz41ryYOa5fFZYxjRy6AEmSulsk/UlvBI9xQQIG+jLgbv8 GtqA+VL12tR2y9069FFYnkLZKRmDjP8h/wLwUUgem6M/H+Dxi0ai3SyUnsKpPQpltnla JHew== X-Gm-Message-State: APjAAAXiWE2H/PTJum4Ve+PmbCyQYQjnGyZlXVNgFQ/nr88upmCxZXuT zEl9Hy7X8/YjraVulfkjg6QURjvRiiFM5w== X-Google-Smtp-Source: APXvYqy9whlSMKgLB5YGoqDvNNtiixNZh2tmg6LOZxh3S2fQR20idMptBA5D90+okIsAkDbCUvfUSg== X-Received: by 2002:a63:3754:: with SMTP id g20mr9056335pgn.384.1581465410951; Tue, 11 Feb 2020 15:56:50 -0800 (PST) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:bc97:5740:52a7:6875]) by smtp.gmail.com with ESMTPSA id a13sm5816291pfg.65.2020.02.11.15.56.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Feb 2020 15:56:49 -0800 (PST) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/4] drm/virtio: factor out context create cmd Date: Tue, 11 Feb 2020 15:56:33 -0800 Message-Id: <20200211235635.488-3-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200211235635.488-1-gurchetansingh@chromium.org> References: <20200211235635.488-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: Gurchetan Singh , kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We currently do it when open the DRM fd, let's delay it. First step, remove the hyercall from initialization. Signed-off-by: Gurchetan Singh --- drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++ drivers/gpu/drm/virtio/virtgpu_ioctl.c | 16 ++++++++++++++++ drivers/gpu/drm/virtio/virtgpu_kms.c | 10 ++++------ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index 28aeac8717e1..edaa7b8224a8 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -214,6 +214,8 @@ struct virtio_gpu_fpriv { /* virtio_ioctl.c */ #define DRM_VIRTIO_NUM_IOCTLS 10 extern struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS]; +void virtio_gpu_create_context(struct drm_device *dev, + struct drm_file *file); /* virtio_kms.c */ int virtio_gpu_init(struct drm_device *dev); diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index 89d90e95900f..f1afabaa3a08 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -33,6 +33,22 @@ #include "virtgpu_drv.h" +void virtio_gpu_create_context(struct drm_device *dev, + struct drm_file *file) +{ + struct virtio_gpu_device *vgdev = dev->dev_private; + struct virtio_gpu_fpriv *vfpriv = file->driver_priv; + char dbgname[TASK_COMM_LEN]; + + /* can't create contexts without 3d renderer */ + if (!vgdev->has_virgl_3d) + return; + + get_task_comm(dbgname, current); + virtio_gpu_cmd_context_create(vgdev, vfpriv->ctx_id, + strlen(dbgname), dbgname); +} + static int virtio_gpu_map_ioctl(struct drm_device *dev, void *data, struct drm_file *file) { diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c index 44e4c07d0162..e1e1c0821a35 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -52,15 +52,13 @@ static void virtio_gpu_config_changed_work_func(struct work_struct *work) events_clear, &events_clear); } -static int virtio_gpu_context_create(struct virtio_gpu_device *vgdev, - uint32_t nlen, const char *name) +static int virtio_gpu_context_handle(struct virtio_gpu_device *vgdev) { int handle = ida_alloc(&vgdev->ctx_id_ida, GFP_KERNEL); if (handle < 0) return handle; handle += 1; - virtio_gpu_cmd_context_create(vgdev, handle, nlen, name); return handle; } @@ -256,7 +254,6 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file) struct virtio_gpu_device *vgdev = dev->dev_private; struct virtio_gpu_fpriv *vfpriv; int id; - char dbgname[TASK_COMM_LEN]; /* can't create contexts without 3d renderer */ if (!vgdev->has_virgl_3d) @@ -267,8 +264,7 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file) if (!vfpriv) return -ENOMEM; - get_task_comm(dbgname, current); - id = virtio_gpu_context_create(vgdev, strlen(dbgname), dbgname); + id = virtio_gpu_context_handle(vgdev); if (id < 0) { kfree(vfpriv); return id; @@ -276,6 +272,8 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file) vfpriv->ctx_id = id; file->driver_priv = vfpriv; + virtio_gpu_create_context(dev, file); + return 0; } From patchwork Tue Feb 11 23:56:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11377237 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2E9914E3 for ; Tue, 11 Feb 2020 23:56:57 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7E2FC206DA for ; Tue, 11 Feb 2020 23:56:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="JO4QjMG2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E2FC206DA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E04436F45C; Tue, 11 Feb 2020 23:56:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 52D996F45C for ; Tue, 11 Feb 2020 23:56:53 +0000 (UTC) Received: by mail-pf1-x443.google.com with SMTP id i6so267665pfc.1 for ; Tue, 11 Feb 2020 15:56:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SEVsV9QzAbELxo472vv5tingI3HcdVfXCXHNr0ZOTOM=; b=JO4QjMG2bTo+Sr2KhiNYumZfjFSCyNKQxbYQbRugOt9nHz1Wwl7X3efIU/+7iIZ2bF iNR9cvhfB+kkIxovcTDG86C1FeqibLFBA4hIzcbw+KoDFcL2oH1uubTW6fqMKacd/nmH S+OB8nBWuYt2lPVeDBO9MnoOKKK8WvOuIAFiI= 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:mime-version:content-transfer-encoding; bh=SEVsV9QzAbELxo472vv5tingI3HcdVfXCXHNr0ZOTOM=; b=oj4r2qAT3TNvwe+UIYzhBVGEmn1JoA8Rf5NYKAHmI/Vr4+o/JtIUYSZMYkXpp7oJbZ kbNuZBm6n/Iu1XeM6S2T7vRWnwdvWZOwx2zq9KlemGIA75TC/hdRws0rEbkfd8UTW5lX WhGkNKbel92yKg73zN72DZ/mWnqTmcjH47jCBxBiYVVcedP6NAO0SMOE3GFyM/dnRHRS NhxORkRMcNg7bIn9ckCD4kFfMKBcykm2OF4w7FVnL02IBo8k1wzhfKxAt6pc3B+BJlA/ ylQ9aIvlLh7HxxIGOIZtyREIrCrds3d35qxdgAUWmnHFSrAu2jzKuYK7CqefDLAqGq9E 4Agg== X-Gm-Message-State: APjAAAXvUcVQAF7LGAUD8d0f/ZDT83xQ2lIxAlLBdejUF9Fv1ZuxkHIR Iuf0TiLXngMpYipNv/x0wXi9HTUqordAMQ== X-Google-Smtp-Source: APXvYqwOy8iku1kKyoTmTKEfecE/Cku+KOcfRSKs7lFrkf3A3s79M8fidlofk1jtCM7zZXKp/cwhIw== X-Received: by 2002:a63:e30e:: with SMTP id f14mr9933642pgh.260.1581465412693; Tue, 11 Feb 2020 15:56:52 -0800 (PST) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:bc97:5740:52a7:6875]) by smtp.gmail.com with ESMTPSA id a13sm5816291pfg.65.2020.02.11.15.56.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Feb 2020 15:56:52 -0800 (PST) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/4] drm/virtio: track whether or not a context has been initiated Date: Tue, 11 Feb 2020 15:56:34 -0800 Message-Id: <20200211235635.488-4-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200211235635.488-1-gurchetansingh@chromium.org> References: <20200211235635.488-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: Gurchetan Singh , kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We only want create a new virglrenderer context after the first 3D ioctl. Signed-off-by: Gurchetan Singh --- drivers/gpu/drm/virtio/virtgpu_drv.h | 1 + drivers/gpu/drm/virtio/virtgpu_ioctl.c | 5 +++++ drivers/gpu/drm/virtio/virtgpu_kms.c | 2 ++ 3 files changed, 8 insertions(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index edaa7b8224a8..93ce69c0d9be 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -209,6 +209,7 @@ struct virtio_gpu_device { struct virtio_gpu_fpriv { uint32_t ctx_id; + atomic_t context_initiated; }; /* virtio_ioctl.c */ diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index f1afabaa3a08..858ee153fb18 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -44,9 +44,14 @@ void virtio_gpu_create_context(struct drm_device *dev, if (!vgdev->has_virgl_3d) return; + if (atomic_read(&vfpriv->context_initiated)) + return; + get_task_comm(dbgname, current); virtio_gpu_cmd_context_create(vgdev, vfpriv->ctx_id, strlen(dbgname), dbgname); + + atomic_inc(&vfpriv->context_initiated); } static int virtio_gpu_map_ioctl(struct drm_device *dev, void *data, diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c index e1e1c0821a35..64fe5fcbedfd 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -270,7 +270,9 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file) return id; } + vfpriv->ctx_id = id; + atomic_set(&vfpriv->context_initiated, 0); file->driver_priv = vfpriv; virtio_gpu_create_context(dev, file); From patchwork Tue Feb 11 23:56:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11377239 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D61513A4 for ; Tue, 11 Feb 2020 23:56:59 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5C262206DA for ; Tue, 11 Feb 2020 23:56:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="W/UPajIs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C262206DA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 560296F45F; Tue, 11 Feb 2020 23:56:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id 020A36F45F for ; Tue, 11 Feb 2020 23:56:54 +0000 (UTC) Received: by mail-pg1-x542.google.com with SMTP id b35so77010pgm.13 for ; Tue, 11 Feb 2020 15:56:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1iXMmtGG2NwjYsNxm/I9np9THh8z6cpuXTG6KOuPO3M=; b=W/UPajIsQ+2H7+dYeRRKR9AylaV8gbFUcrcHfmz22wpE9vVwYpYtp2To+EXEHbY5gk 5FkSk0chZY1QeBDR5Uv9MBIOkdPL7IEHmTrO5X1PObofo46+DDV3el7djKDOA9TlH1GF 9CUXp/bipl6i1ocdxqNfhhD0bPiFXyPZjy80w= 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:mime-version:content-transfer-encoding; bh=1iXMmtGG2NwjYsNxm/I9np9THh8z6cpuXTG6KOuPO3M=; b=HV3tYhYCFwnLmo6HGAjjH98uHD10nh3aGDkvAZJHGnLuvlyt4GKTlRvt+S9LlXBdn1 sLuFR3nVU2b2hUaNRcAIqxIq0nOdKGRTZk4MT3Ltu0KCSepOLRDEYWJOYddQfy/k4wCc sN+8xjjZYAD/z7IfAyn7669CDapGk63PJMOzw5V31peW0d0ee70NhpXIyqqYRNSMGilO E1UlodwyQF07FgA1AqbYbqlSSANFCncd8yczsFbyhWgN+ypnj3IQeIvGQ6KZrmzgiL+y Hut1WiHOD/Bl8oXJc/kg7w0mL//r8Q+hEcwrypMbtx3ERFTtbStiri/JLDZNx1ztnhIJ EuTA== X-Gm-Message-State: APjAAAUpaArVlUMT+scIyzVXgCqvVY6IGcvDvag3/VVwTRK3XbcKE5NW iPa6hZgwbNk10BIbXoD0tAR9UBNEo+28Nw== X-Google-Smtp-Source: APXvYqzv/Wtn2cD6L+QeirxMwYcshrrIIJPwEGlTCRIpsd9HauEa1AFgyXwvJUcA7x6gzWnqj4hE8g== X-Received: by 2002:a63:86c2:: with SMTP id x185mr9140620pgd.245.1581465414322; Tue, 11 Feb 2020 15:56:54 -0800 (PST) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:bc97:5740:52a7:6875]) by smtp.gmail.com with ESMTPSA id a13sm5816291pfg.65.2020.02.11.15.56.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Feb 2020 15:56:53 -0800 (PST) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/4] drm/virtio: enqueue virtio_gpu_create_context after first 3D ioctl Date: Tue, 11 Feb 2020 15:56:35 -0800 Message-Id: <20200211235635.488-5-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200211235635.488-1-gurchetansingh@chromium.org> References: <20200211235635.488-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: Gurchetan Singh , kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" With virtio_gpu_notify(..), the create context command now is batched with the first 3D hypercall. Signed-off-by: Gurchetan Singh --- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 5 +++++ drivers/gpu/drm/virtio/virtgpu_kms.c | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index 858ee153fb18..32f9af4bcb3a 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -95,6 +95,7 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, exbuf->fence_fd = -1; + virtio_gpu_create_context(dev, file); if (exbuf->flags & VIRTGPU_EXECBUF_FENCE_FD_IN) { struct dma_fence *in_fence; @@ -246,6 +247,7 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data, return -EINVAL; } + virtio_gpu_create_context(dev, file); params.format = rc->format; params.width = rc->width; params.height = rc->height; @@ -319,6 +321,7 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev, if (vgdev->has_virgl_3d == false) return -ENOSYS; + virtio_gpu_create_context(dev, file); objs = virtio_gpu_array_from_handles(file, &args->bo_handle, 1); if (objs == NULL) return -ENOENT; @@ -367,6 +370,7 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data, args->box.w, args->box.h, args->box.x, args->box.y, objs, NULL); } else { + virtio_gpu_create_context(dev, file); ret = virtio_gpu_array_lock_resv(objs); if (ret != 0) goto err_put_free; @@ -467,6 +471,7 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev, spin_unlock(&vgdev->display_info_lock); /* not in cache - need to talk to hw */ + virtio_gpu_create_context(dev, file); virtio_gpu_cmd_get_capset(vgdev, found_valid, args->cap_set_ver, &cache_ent); virtio_gpu_notify(vgdev); diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c index 64fe5fcbedfd..277c76de8e9c 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -274,7 +274,6 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file) vfpriv->ctx_id = id; atomic_set(&vfpriv->context_initiated, 0); file->driver_priv = vfpriv; - virtio_gpu_create_context(dev, file); return 0; }