From patchwork Thu Sep 24 00:31:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795825 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 C86526CB for ; Thu, 24 Sep 2020 00:32:22 +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 8F3AD21734 for ; Thu, 24 Sep 2020 00:32:22 +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="JcgK0TG2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F3AD21734 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 1E7066E067; Thu, 24 Sep 2020 00:32:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id DD2EB6E067 for ; Thu, 24 Sep 2020 00:32:17 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id z19so741215pfn.8 for ; Wed, 23 Sep 2020 17:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dCeErYaYU/OrSRlMHth62JhyG2DwbGqcl8xZ6TAfBZs=; b=JcgK0TG2QFhnJcjddAuVYXwC9peg7zHnVdEq+LKYnj/R+UzPMllRU/D4UQbUYSI3J6 +3lacNTePlukZXSG5H69vWYXIFKf2jX4B7v0Z1LRDrdQgbiQAMjf8Q9vEfrOiySEr0kr jdogWiQd1EJW6uDj705dUw+c0Yz1bVpR+QGnM= 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:mime-version :content-transfer-encoding; bh=dCeErYaYU/OrSRlMHth62JhyG2DwbGqcl8xZ6TAfBZs=; b=OW6mOkvlScmwapcEI5jN7o9LV2+8YPbBVhPDBV3nMgIzaUDvj2+P/JpJAl0eDHp6th zL0zU2+2Z7C/0cBYG/KfmiMahpXuH6dbmOden/aSsmGnW/rZthhC0RuErVdpPNVJs/CJ DZ8F0jBxnzZ1U75hCaNQ1+kxwwge0gs3VD3+PJIOMMN430Jj2wiJYj3IK0x4ueqB8f8J Ask4Snyv++mAtP0UXuBjqDmlU0VJpFMVDT2oOjG5lV8pS3skGwkThslR6ijVSg0/U/aw 8clsZ3Iw095kwdjLOoNBPbT2oqc2r/GU2isXstCmLLm8xAvufwkBY5gyLbvP5rmnT0CD 2cPA== X-Gm-Message-State: AOAM530kT/hpY1FVQZFjd1i3kJN4KV/+qc64m6tLSlFc3MyeQSXsO20C TrFcKyvQ5xLI98Rp7I1ynbf3TQTos7K+Sw== X-Google-Smtp-Source: ABdhPJyFhmEFuvIzNCXQSCsAyUuYJYNanWSPTWeGBOS08sv0yOXCh9Bt1a9LqquTh+CeLnjDDKM9Rg== X-Received: by 2002:a62:bd05:0:b029:142:2501:3a02 with SMTP id a5-20020a62bd050000b029014225013a02mr2037584pff.81.1600907537086; Wed, 23 Sep 2020 17:32:17 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:16 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 01/19] drm/virtio: blob prep: refactor getting pages and attaching backing Date: Wed, 23 Sep 2020 17:31:56 -0700 Message-Id: <20200924003214.662-1-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Useful for upcoming blob resources. Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso --- drivers/gpu/drm/virtio/virtgpu_object.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c index 842f8b61aa897..4c107b53e81a0 100644 --- a/drivers/gpu/drm/virtio/virtgpu_object.c +++ b/drivers/gpu/drm/virtio/virtgpu_object.c @@ -228,22 +228,22 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, goto err_put_objs; } + ret = virtio_gpu_object_shmem_init(vgdev, bo, &ents, &nents); + if (ret != 0) { + virtio_gpu_free_object(&shmem_obj->base); + return ret; + } + if (params->virgl) { virtio_gpu_cmd_resource_create_3d(vgdev, bo, params, objs, fence); + virtio_gpu_object_attach(vgdev, bo, ents, nents); } else { virtio_gpu_cmd_create_resource(vgdev, bo, params, objs, fence); + virtio_gpu_object_attach(vgdev, bo, ents, nents); } - ret = virtio_gpu_object_shmem_init(vgdev, bo, &ents, &nents); - if (ret != 0) { - virtio_gpu_free_object(&shmem_obj->base); - return ret; - } - - virtio_gpu_object_attach(vgdev, bo, ents, nents); - *bo_ptr = bo; return 0; From patchwork Thu Sep 24 00:31:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795827 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 D15266CA for ; Thu, 24 Sep 2020 00:32:25 +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 969312145D for ; Thu, 24 Sep 2020 00:32:25 +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="S/PTaQQn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 969312145D 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 203586EA1A; Thu, 24 Sep 2020 00:32:21 +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 DEACE6E067 for ; Thu, 24 Sep 2020 00:32:18 +0000 (UTC) Received: by mail-pj1-x1043.google.com with SMTP id u3so621883pjr.3 for ; Wed, 23 Sep 2020 17:32:18 -0700 (PDT) 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=V8m7qPDfB55B1mb2byxbuGqYmAz2nUtTaDYRFEV2hkc=; b=S/PTaQQnrFwzatjaDVA1RGYct8NNxO8G8GWmlG/E1yfldDbz2hWidmsnd7n9qCE8DU rojlXwSnRGjRa8OnBspCMZ/9bAsADdgA03Ket4xFkmCbX9f2Omnqbf+lsx6Z9ZWHms5c UipsioRWKlk2vwJDPG6OB5PS1YPHJdYYhuI78= 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=V8m7qPDfB55B1mb2byxbuGqYmAz2nUtTaDYRFEV2hkc=; b=mJfmSyaOYCo9UUR2UqOY1OP/QRID74ZrPHycXBFyC7BxoN/ZeUvJlUFzjeAegTZArl MEVySiHxhks7AzRJkp9fA2XWJpBQ/fHBN/0fG8UAbmGCZ7iccDvNjocZi+h0Ac3j6a2M nPDvjAIxPMwhAebAzhLtRTgckTb8fyqeFj4bxDxT+NNLB0iHUc9tcWxfJM1gLS5M6Akr hi4FOgo4Pt1hQF/e5QUb6dsKWKHO2cZRD4K5ujO/hlgTDsdSjJ54LB5V+MZCvJFDJP06 DYfNfON6I7RMOKqaKkp1VQ1wgWnNbKE5KLtuQdpyHIuQTIW0xRk0REeSoocs1GS2pnGx NgEA== X-Gm-Message-State: AOAM531IdNOoRDPblMr+HPwOaa5ZloKTT/RskxXtnmVlitnIEx722ZKL yyEOEiX1vKr3znAr4X0pepGEBKuyzEGMIg== X-Google-Smtp-Source: ABdhPJyuq06faHzvvJBFdx7ghVG4h+qCut/f8PbyaP2uv0IiPiIh6IIyglQT5L+3gv+eIZKbaRkeOg== X-Received: by 2002:a17:902:8bca:b029:d2:42fe:21da with SMTP id r10-20020a1709028bcab02900d242fe21damr2105939plo.31.1600907538158; Wed, 23 Sep 2020 17:32:18 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:17 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 02/19] drm/virtio: blob prep: make CPU responses more generic Date: Wed, 23 Sep 2020 17:31:57 -0700 Message-Id: <20200924003214.662-2-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" RESOURCE_MAP_BLOB / RESOURCE_UNMAP_BLOB can use this. Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso --- drivers/gpu/drm/virtio/virtgpu_drv.h | 6 +++--- drivers/gpu/drm/virtio/virtgpu_prime.c | 6 +++--- drivers/gpu/drm/virtio/virtgpu_vq.c | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index 55c34b4fc3e99..272abe177ded6 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -49,9 +49,9 @@ #define DRIVER_MINOR 1 #define DRIVER_PATCHLEVEL 0 -#define UUID_INITIALIZING 0 -#define UUID_INITIALIZED 1 -#define UUID_INITIALIZATION_FAILED 2 +#define STATE_INITIALIZING 0 +#define STATE_OK 1 +#define STATE_ERR 2 struct virtio_gpu_object_params { uint32_t format; diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c index acd14ef73d563..3552db128ba3d 100644 --- a/drivers/gpu/drm/virtio/virtgpu_prime.c +++ b/drivers/gpu/drm/virtio/virtgpu_prime.c @@ -34,8 +34,8 @@ static int virtgpu_virtio_get_uuid(struct dma_buf *buf, struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj); struct virtio_gpu_device *vgdev = obj->dev->dev_private; - wait_event(vgdev->resp_wq, bo->uuid_state != UUID_INITIALIZING); - if (bo->uuid_state != UUID_INITIALIZED) + wait_event(vgdev->resp_wq, bo->uuid_state != STATE_INITIALIZING); + if (bo->uuid_state != STATE_OK) return -ENODEV; uuid_copy(uuid, &bo->uuid); @@ -81,7 +81,7 @@ struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj, return ERR_PTR(ret); virtio_gpu_notify(vgdev); } else { - bo->uuid_state = UUID_INITIALIZATION_FAILED; + bo->uuid_state = STATE_ERR; } exp_info.ops = &virtgpu_dmabuf_ops.ops; diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index a7550044b8b2e..55529ed97d9c7 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -1127,14 +1127,14 @@ static void virtio_gpu_cmd_resource_uuid_cb(struct virtio_gpu_device *vgdev, uint32_t resp_type = le32_to_cpu(resp->hdr.type); spin_lock(&vgdev->resource_export_lock); - WARN_ON(obj->uuid_state != UUID_INITIALIZING); + WARN_ON(obj->uuid_state != STATE_INITIALIZING); if (resp_type == VIRTIO_GPU_RESP_OK_RESOURCE_UUID && - obj->uuid_state == UUID_INITIALIZING) { + obj->uuid_state == STATE_INITIALIZING) { memcpy(&obj->uuid.b, resp->uuid, sizeof(obj->uuid.b)); - obj->uuid_state = UUID_INITIALIZED; + obj->uuid_state = STATE_OK; } else { - obj->uuid_state = UUID_INITIALIZATION_FAILED; + obj->uuid_state = STATE_ERR; } spin_unlock(&vgdev->resource_export_lock); @@ -1153,7 +1153,7 @@ virtio_gpu_cmd_resource_assign_uuid(struct virtio_gpu_device *vgdev, resp_buf = kzalloc(sizeof(*resp_buf), GFP_KERNEL); if (!resp_buf) { spin_lock(&vgdev->resource_export_lock); - bo->uuid_state = UUID_INITIALIZATION_FAILED; + bo->uuid_state = STATE_ERR; spin_unlock(&vgdev->resource_export_lock); virtio_gpu_array_put_free(objs); return -ENOMEM; From patchwork Thu Sep 24 00:31:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795837 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 102156CB for ; Thu, 24 Sep 2020 00:32:36 +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 D48832145D for ; Thu, 24 Sep 2020 00:32:35 +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="Yh1zR0gj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D48832145D 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 3235C6EA21; Thu, 24 Sep 2020 00:32:27 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by gabe.freedesktop.org (Postfix) with ESMTPS id 197E46EA1A for ; Thu, 24 Sep 2020 00:32:20 +0000 (UTC) Received: by mail-pl1-x643.google.com with SMTP id r19so686572pls.1 for ; Wed, 23 Sep 2020 17:32:20 -0700 (PDT) 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=RCQ+EYT2MzbQv/dr3N4s0E8HTwBjP5d0FY0g8w6KX0M=; b=Yh1zR0gjXv0GjRvZeDLiifp1UwkQNeOPR3BYGfAjXk0Cs+MOkn4Ps+xUR07Xlx/1ZX /vvrW6MD4zwzLqZXTITMbZiPFQIOaldMpfqQh4xax0HHRVR/lqjgXYctxoCI0C+lZAlH QQ6x03yA8kGXS1JdMrIiEeZIn22eq+zm4PbJA= 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=RCQ+EYT2MzbQv/dr3N4s0E8HTwBjP5d0FY0g8w6KX0M=; b=RJ9Lq4f0fnuFxUB8zMxDLMqyaXOeSKE5Zxx1qJkoDcFxHfxVy1uAmKD1gzpWvGu2b+ W+cOPIPzP8FIpa4hGYK4PSc8PY37X+h0A9pPmk98vggMKpAkUoNFmfsmdboOB52QHyaY 5EPfStfywigF9Bpkn1IidZB94GJpY60znwAq41nbMq4r9tlcvDsIJpoCiLS/ePvMXtAj n+0Zz2d++zbCmBEkPiQpr2R2NVyREucyW8chvnSnEB07pf50mlIWrrPsA4vZQDdayzd4 Isrc1Qa1v8vig1W/rNjsNxswVuF8dxN7ntCS/B9sGLOnFF1/+9Yp2NqqDg7mIBMndLxz tA9w== X-Gm-Message-State: AOAM532IQt48M08t8gJiLBIZv34g9hE+RYuBeO0Etplm/pXQ+H3uTYGA jbLLu1FcDnBJIMquf+b+pmSoiVBoTsfI2Q== X-Google-Smtp-Source: ABdhPJywgAU06xARCaE20LKD96lT3RM2T4Qq7720moTiT1yKImfPx7LA2rDrnfIhNDoMQnXp3/B9uA== X-Received: by 2002:a17:902:6903:b029:d2:2503:e5c1 with SMTP id j3-20020a1709026903b02900d22503e5c1mr2178157plk.60.1600907539304; Wed, 23 Sep 2020 17:32:19 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:18 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 03/19] virtio-gpu api: blob resources Date: Wed, 23 Sep 2020 17:31:58 -0700 Message-Id: <20200924003214.662-3-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Gerd Hoffmann A blob resource is a container for: - VIRTIO_GPU_BLOB_MEM_GUEST: a guest memory allocation (referred to as a "guest-only blob resource") - VIRTIO_GPU_BLOB_MEM_HOST3D: a host3d memory allocation (referred to as a "host-only blob resource") - VIRTIO_GPU_BLOB_MEM_HOST3D_GUEST: a guest + host3d memory allocation (referred to as a "default blob resource"). The memory properties of the blob resource must be described by `blob_mem`. For default and guest only blob resources set, `nents` guest system pages are assigned to the resource. For default blob resources, these guest pages are used for transfer operations. Attach/detach is also possible to allow swap-in/swap-out, but isn't required since it may not be applicable to future blob mem types (shared guest/guest vram). Host allocations depend on whether the 3D is supported. If 3D is not supported, the only valid field for `blob_mem` is VIRTIO_GPU_BLOB_MEM_GUEST. If 3D is supported, the virtio-gpu resource is created from the context local object identified by the `blob_id`. The actual host allocation done by the CMD_SUBMIT_3D. Userspace must specify if the blob resource is intended to be used for userspace mapping, sharing between virtio-gpu contexts and/or sharing between virtio devices. This is done via `blob_flags`. For 3D hosts, both VIRTIO_GPU_CMD_TRANSFER_TO_HOST_3D and VIRTIO_GPU_CMD_TRANSFER_FROM_HOST_3D may be used to update the host resource. There is no restriction on the image/buffer view the guest/host userspace has on the blob resource. VIRTIO_GPU_CMD_SET_SCANOUT_BLOB / VIRTIO_GPU_CMD_RESOURCE_FLUSH may be used with blob resources as well. The modifier is intentionally left out of SCANOUT_BLOB, and auxilary blobs are also left out as a simplification. The use case for blob resources is zero-copy, needed for coherent memory in virglrenderer. Host only blob resources are not mappable without the feature described in the next patch, but are shareable. Future work: - Emulated coherent `blob_mem` type for QEMU/vhost-user - A `blob_mem` type for guest-only resources imported in cache-coherent FOSS GPU/display drivers. - Display integration involving the blob model using seamless Wayland windows. Signed-off-by: Gerd Hoffmann Co-developed-by: Gurchetan Singh Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso Acked-by: Chia-I Wu Acked-by: Lingfeng Yang Link: https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/374 --- include/uapi/linux/virtio_gpu.h | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/include/uapi/linux/virtio_gpu.h b/include/uapi/linux/virtio_gpu.h index 747a5c5cc4e60..4ddf2fe342ed0 100644 --- a/include/uapi/linux/virtio_gpu.h +++ b/include/uapi/linux/virtio_gpu.h @@ -55,6 +55,11 @@ */ #define VIRTIO_GPU_F_RESOURCE_UUID 2 +/* + * VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB + */ +#define VIRTIO_GPU_F_RESOURCE_BLOB 3 + enum virtio_gpu_ctrl_type { VIRTIO_GPU_UNDEFINED = 0, @@ -71,6 +76,8 @@ enum virtio_gpu_ctrl_type { VIRTIO_GPU_CMD_GET_CAPSET, VIRTIO_GPU_CMD_GET_EDID, VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID, + VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB, + VIRTIO_GPU_CMD_SET_SCANOUT_BLOB, /* 3d commands */ VIRTIO_GPU_CMD_CTX_CREATE = 0x0200, @@ -359,4 +366,40 @@ struct virtio_gpu_resp_resource_uuid { __u8 uuid[16]; }; +/* VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB */ +struct virtio_gpu_resource_create_blob { + struct virtio_gpu_ctrl_hdr hdr; + __le32 resource_id; +#define VIRTIO_GPU_BLOB_MEM_GUEST 0x0001 +#define VIRTIO_GPU_BLOB_MEM_HOST3D 0x0002 +#define VIRTIO_GPU_BLOB_MEM_HOST3D_GUEST 0x0003 + +#define VIRTIO_GPU_BLOB_FLAG_USE_MAPPABLE 0x0001 +#define VIRTIO_GPU_BLOB_FLAG_USE_SHAREABLE 0x0002 +#define VIRTIO_GPU_BLOB_FLAG_USE_CROSS_DEVICE 0x0004 + /* zero is invalid blob mem */ + __le32 blob_mem; + __le32 blob_flags; + __le64 blob_id; + __le64 size; + __le32 nr_entries; + /* + * sizeof(nr_entries * virtio_gpu_mem_entry) bytes follow + */ +}; + +/* VIRTIO_GPU_CMD_SET_SCANOUT_BLOB */ +struct virtio_gpu_set_scanout_blob { + struct virtio_gpu_ctrl_hdr hdr; + struct virtio_gpu_rect r; + __le32 scanout_id; + __le32 resource_id; + __le32 width; + __le32 height; + __le32 format; + __le32 padding; + __le32 strides[4]; + __le32 offsets[4]; +}; + #endif From patchwork Thu Sep 24 00:31:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795829 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 E548F6CA for ; Thu, 24 Sep 2020 00:32:28 +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 A87142145D for ; Thu, 24 Sep 2020 00:32:28 +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="j/udGvnV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A87142145D 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 1FEAB6EA1B; Thu, 24 Sep 2020 00:32:22 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id EDECD6EA1A for ; Thu, 24 Sep 2020 00:32:20 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id d6so739186pfn.9 for ; Wed, 23 Sep 2020 17:32:20 -0700 (PDT) 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=XSX/urUFLsiFC1lKYCAeObeY4sFWjg0RKAvq3ynqLts=; b=j/udGvnVqj8KCOFOER/N7xuiHQS38nl+C1oayfYuIwMYdqwO3jcbkBydPU2zZuFg0q 4rk744yvBegVR94F+AS6sfvJlzYTdtb0sbPrmOEH21bN/IIakyLg1bvYgm6731CcP/7/ nLmnTPlhj/WUSOBB2C5fyNmk3W+de8xZ8FgEA= 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=XSX/urUFLsiFC1lKYCAeObeY4sFWjg0RKAvq3ynqLts=; b=DyEHl8g5iftVrqhrztfyzX4TnJXQmshqZczraiphDjlVuYITwlYUGSssD6JSEiiiSS XaCzCpDuLCh8o02gAluNIHxrYwIHg4LjrlFclfpIHJ0kgHvexhhIUK1M5revfJeJvoGA W39IoXasSEBf5tz/AbdoRYiVKm6QoCRBlfQIxxGyehJr0yfqd+zj5m0K4oS1ivH3bGGK OpvdsDN9LBtj6ZhCY0tJrwBuVPU3wnQjrSHd6gvSa7prvEjinuYl8PXXqd/MpM2E2Kek s4qx5KTT4MBffi/sjOtpC62jRiYWKuz1MIXkfpSUVg353NvEHLO1ihpiIZWiq/RQrWCb BQxg== X-Gm-Message-State: AOAM531BZz1LAHFdG8ph79SHJd3j9Ji3sYSzNc8qrlDoJXRU4p2tbpBm rVU6TtaQZsKRC5qlK6gpE+ayJ0cRQ7/B7w== X-Google-Smtp-Source: ABdhPJw5mw1zbMHQOrBT1dX8jADBMo+pmAckqKYtMyko0ouQ9+Y/o/OJMYotUKFMO/CzEuRQmw/EFA== X-Received: by 2002:a63:4f10:: with SMTP id d16mr1836133pgb.152.1600907540306; Wed, 23 Sep 2020 17:32:20 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:19 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 04/19] virtio-gpu api: host visible feature Date: Wed, 23 Sep 2020 17:31:59 -0700 Message-Id: <20200924003214.662-4-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Gerd Hoffmann This patch adds a new virtgpu feature that allows directly mapping host allocated resources. This is based on virtio shared memory regions, which allows querying for memory regions using PCI transport. Each shared memory region has an associated "shmid", the meaning of which is device specific. For virtio-gpu, we can define the shared memory region with id VIRTIO_GPU_SHM_ID_HOST_VISIBLE to be the "host visible memory region". The presence of the host visible memory region means the following hypercalls are supported: 1) VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB This hypercall tells the host to inject the host resource's mapping in an offset into virtio-gpu's PCI address space. This is typically done via KVM_SET_USER_MEMORY_REGION on Linux hosts. On success, VIRTIO_GPU_RESP_OK_MAP_INFO is returned, which specifies the host buffer's caching type and possibly in the future performance hints about the buffer.. 2) VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB This hypercall tells the host to remove the host resource's mapping from the guest VM. Signed-off-by: Gerd Hoffmann Co-developed-by: Gurchetan Singh Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso Acked-by: Lingfeng Yang --- include/uapi/linux/virtio_gpu.h | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/include/uapi/linux/virtio_gpu.h b/include/uapi/linux/virtio_gpu.h index 4ddf2fe342ed0..fa2ae4a1da5f9 100644 --- a/include/uapi/linux/virtio_gpu.h +++ b/include/uapi/linux/virtio_gpu.h @@ -88,6 +88,8 @@ enum virtio_gpu_ctrl_type { VIRTIO_GPU_CMD_TRANSFER_TO_HOST_3D, VIRTIO_GPU_CMD_TRANSFER_FROM_HOST_3D, VIRTIO_GPU_CMD_SUBMIT_3D, + VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB, + VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB, /* cursor commands */ VIRTIO_GPU_CMD_UPDATE_CURSOR = 0x0300, @@ -100,6 +102,7 @@ enum virtio_gpu_ctrl_type { VIRTIO_GPU_RESP_OK_CAPSET, VIRTIO_GPU_RESP_OK_EDID, VIRTIO_GPU_RESP_OK_RESOURCE_UUID, + VIRTIO_GPU_RESP_OK_MAP_INFO, /* error responses */ VIRTIO_GPU_RESP_ERR_UNSPEC = 0x1200, @@ -110,6 +113,11 @@ enum virtio_gpu_ctrl_type { VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER, }; +enum virtio_gpu_shm_id { + VIRTIO_GPU_SHM_ID_UNDEFINED = 0, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE = 1 +}; + #define VIRTIO_GPU_FLAG_FENCE (1 << 0) struct virtio_gpu_ctrl_hdr { @@ -402,4 +410,31 @@ struct virtio_gpu_set_scanout_blob { __le32 offsets[4]; }; +/* VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB */ +struct virtio_gpu_resource_map_blob { + struct virtio_gpu_ctrl_hdr hdr; + __le32 resource_id; + __le32 padding; + __le64 offset; +}; + +/* VIRTIO_GPU_RESP_OK_MAP_INFO */ +#define VIRTIO_GPU_MAP_CACHE_MASK 0x0f +#define VIRTIO_GPU_MAP_CACHE_NONE 0x00 +#define VIRTIO_GPU_MAP_CACHE_CACHED 0x01 +#define VIRTIO_GPU_MAP_CACHE_UNCACHED 0x02 +#define VIRTIO_GPU_MAP_CACHE_WC 0x03 +struct virtio_gpu_resp_map_info { + struct virtio_gpu_ctrl_hdr hdr; + __u32 map_info; + __u32 padding; +}; + +/* VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB */ +struct virtio_gpu_resource_unmap_blob { + struct virtio_gpu_ctrl_hdr hdr; + __le32 resource_id; + __le32 padding; +}; + #endif From patchwork Thu Sep 24 00:32:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795839 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 892386CB for ; Thu, 24 Sep 2020 00:32:37 +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 523A42145D for ; Thu, 24 Sep 2020 00:32:37 +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="iSnlWPnX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 523A42145D 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 499AE6EA23; Thu, 24 Sep 2020 00:32:27 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by gabe.freedesktop.org (Postfix) with ESMTPS id 068226EA1D for ; Thu, 24 Sep 2020 00:32:22 +0000 (UTC) Received: by mail-pl1-x643.google.com with SMTP id c3so671096plz.5 for ; Wed, 23 Sep 2020 17:32:22 -0700 (PDT) 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=CgElxpOI4YrUTvxXMX4kkD1juWhcMpMUDyjmJnDZD6s=; b=iSnlWPnXUZxAWhLrqhrCHrs+xPirfwaRZNhr0GggrPkGO7b2DHm2GBcs4+D6g5A/8M 70FWOg2Ysd4SHOdtswQSoLNQ7bN4jEhyPcRJYVrr53vrK6AVazmBlcdYFYgIzbHpi+RK HJe3oBS1s3zNQx3IhxoFLQvOIChmmzFR2+7x8= 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=CgElxpOI4YrUTvxXMX4kkD1juWhcMpMUDyjmJnDZD6s=; b=ME5TndwHdeXkz+dnwpG/6MK7fMnRP2iDmzKtF+R6j9yRtD4LN7yWG4uVBSHieifB+a 7hNJPo4HCMdfzCPK8jY9MRrSC6rbkD1O7/fOf3DWcDDn8HZN+BLo8Yv5osB7UzV0fQnt RASffiVZJrIc07Tq3O6H/+2K5F8OBnrGSnouz89OFAmKoMmXdTMKlo6uQ/IzRSmBmOmG UZN595JyIhOW2asEciIhGVPJX3grwCg6nB2hKJvZk932OJaxiX3DbD7adTr8zRrb8Ru+ wH/ChAwRYTk0eST5E9rxfjFZrCMqDRYOnqjv2r/MwkoMal9dy3MBdFUEp1m/vNDUZmit 0Q/w== X-Gm-Message-State: AOAM532+qO+prB/wjPG+2850viin6AIIxwejkBSxj2pS6uEdlz5Pr5Fw 4Iu8LoBFPQJlnISdcjymTMqxQq235+HiyQ== X-Google-Smtp-Source: ABdhPJxIf/HzZIxpVy5snJZPpumI0ceDwjgKrAHB0tskKQ2EmOd44cfVQZQTKI/qcd19WFSGl0SBdQ== X-Received: by 2002:a17:902:c692:b029:d0:90a3:24f4 with SMTP id r18-20020a170902c692b02900d090a324f4mr2142038plx.12.1600907541311; Wed, 23 Sep 2020 17:32:21 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:20 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 05/19] drm/virtgpu api: blob resources Date: Wed, 23 Sep 2020 17:32:00 -0700 Message-Id: <20200924003214.662-5-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This makes blob resources available to guest userspace. They are needed for GL4.5, Vulkan and zero-copy virtio-gpu. For Mesa, blob resources have been tested with Piglit's ARB_buffer_storage tests and apitraces. Apitraces of GL4.5 games show we're between 70% to 80% of host performance on Iris, based on a apitrace of a 2013 GL4.5 game: 11.204 FPS (guest) 15.947 FPS (host) This is still better than the status quo, when said game was unplayable with Virgl due to an inefficient GL4.3 fallback. But there's still room for improvement if we want to match HW-assisted virtualization. For Vulkan, blob resources have been tested with dEQP.vk.memory* and running Vulkan applications in production with the "Cuttlefish" virtual Android device. This has been done with Lingfeng Yang's "gfxstream" Vulkan implementation, which virtualizes Vulkan across many Google products. Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso Acked-by: Chia-I Wu Acked-by: Lingfeng Yang Link: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4821 Link: https://android-review.googlesource.com/c/device/generic/goldfish-opengl/+/1283761 --- include/uapi/drm/virtgpu_drm.h | 37 +++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h index f06a789f34cd9..bb224f604c9e3 100644 --- a/include/uapi/drm/virtgpu_drm.h +++ b/include/uapi/drm/virtgpu_drm.h @@ -46,6 +46,7 @@ extern "C" { #define DRM_VIRTGPU_TRANSFER_TO_HOST 0x07 #define DRM_VIRTGPU_WAIT 0x08 #define DRM_VIRTGPU_GET_CAPS 0x09 +#define DRM_VIRTGPU_RESOURCE_CREATE_BLOB 0x0a #define VIRTGPU_EXECBUF_FENCE_FD_IN 0x01 #define VIRTGPU_EXECBUF_FENCE_FD_OUT 0x02 @@ -71,6 +72,7 @@ struct drm_virtgpu_execbuffer { #define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */ #define VIRTGPU_PARAM_CAPSET_QUERY_FIX 2 /* do we have the capset fix */ +#define VIRTGPU_PARAM_RESOURCE_BLOB 3 /* DRM_VIRTGPU_RESOURCE_CREATE_BLOB */ struct drm_virtgpu_getparam { __u64 param; @@ -100,7 +102,7 @@ struct drm_virtgpu_resource_info { __u32 bo_handle; __u32 res_handle; __u32 size; - __u32 stride; + __u32 blob_mem; }; struct drm_virtgpu_3d_box { @@ -117,6 +119,8 @@ struct drm_virtgpu_3d_transfer_to_host { struct drm_virtgpu_3d_box box; __u32 level; __u32 offset; + __u32 stride; + __u32 layer_stride; }; struct drm_virtgpu_3d_transfer_from_host { @@ -124,6 +128,8 @@ struct drm_virtgpu_3d_transfer_from_host { struct drm_virtgpu_3d_box box; __u32 level; __u32 offset; + __u32 stride; + __u32 layer_stride; }; #define VIRTGPU_WAIT_NOWAIT 1 /* like it */ @@ -140,6 +146,31 @@ struct drm_virtgpu_get_caps { __u32 pad; }; +struct drm_virtgpu_resource_create_blob { +#define VIRTGPU_BLOB_MEM_GUEST 0x0001 +#define VIRTGPU_BLOB_MEM_HOST3D 0x0002 +#define VIRTGPU_BLOB_MEM_HOST3D_GUEST 0x0003 + +#define VIRTGPU_BLOB_FLAG_USE_MAPPABLE 0x0001 +#define VIRTGPU_BLOB_FLAG_USE_SHAREABLE 0x0002 +#define VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE 0x0004 + /* zero is invalid blob_mem */ + __u32 blob_mem; + __u32 blob_flags; + __u32 bo_handle; + __u32 res_handle; + __u64 size; + + /* + * for 3D contexts with VIRTGPU_BLOB_MEM_HOST3D_GUEST and + * VIRTGPU_BLOB_MEM_HOST3D otherwise, must be zero. + */ + __u32 pad; + __u32 cmd_size; + __u64 cmd; + __u64 blob_id; +}; + #define DRM_IOCTL_VIRTGPU_MAP \ DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_MAP, struct drm_virtgpu_map) @@ -175,6 +206,10 @@ struct drm_virtgpu_get_caps { DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GET_CAPS, \ struct drm_virtgpu_get_caps) +#define DRM_IOCTL_VIRTGPU_RESOURCE_CREATE_BLOB \ + DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_CREATE_BLOB, \ + struct drm_virtgpu_resource_create_blob) + #if defined(__cplusplus) } #endif From patchwork Thu Sep 24 00:32:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795831 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 E92856CB for ; Thu, 24 Sep 2020 00:32:30 +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 B71FF2145D for ; Thu, 24 Sep 2020 00:32:30 +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="SYHDdtwU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B71FF2145D 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 2AC516EA1E; Thu, 24 Sep 2020 00:32:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3DF2C6EA1D for ; Thu, 24 Sep 2020 00:32:23 +0000 (UTC) Received: by mail-pj1-x1041.google.com with SMTP id s14so3438713pju.1 for ; Wed, 23 Sep 2020 17:32:23 -0700 (PDT) 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=gtt8qhOX791+4VTJl4etyAvZU3rZa3LH1wjsXrfykoE=; b=SYHDdtwU3xqvhx/Zv9jilr/X9MMBDfpX/SRV34UDQmDAjLCYhCjX6j3MvfbatmqaIR wOs+rtP4WZpjjU2z0Spu/rs99RPAWRr1vMz4zTmPHmzsxdj4ZHJliDUvcHEahymfPGWT oGjsUTkNEStKBh54YEZfcVEyWjHq8Bpx344Ms= 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=gtt8qhOX791+4VTJl4etyAvZU3rZa3LH1wjsXrfykoE=; b=MzE/c2Bw8+pu7RlvhD3DWM2VmUdjMRxyDqqWr0M7bwajtgS2iHLIWShWmNWMDOXVZb cPQG9rLzlNGLKHxScE6gpdDk8ySKA2+KQq8eBHo2InvELVsKf1WDY81PoaRYYPLcUMKT GodLL+7fzWCbyPGO+aIVgQNB+IoIFZY9JrQ08knMe9rb1x80zyDQtgKZ9sUzZNxxGmMX AduRrRh9BtBrddMhishSgV+Jofnf60rFsr4H2LAw5lJ7z00+LIj5Vqzo8B8QicgP/IcM zWJOtEA5CCL3vTRccEQo8zT88FffB8JXC1CApZdsPlVnYuCKuxSJzSddxnNydcliZUS6 /auQ== X-Gm-Message-State: AOAM530FBaSZTFIt7Bj4gIWXzOtSfMeLu0vUDRbZDbBISIIvB9UnSOSI ZcGGPTlb+8vqifx8BP9qcODCMYPOSaK5iA== X-Google-Smtp-Source: ABdhPJzVPdAXkzlxsTCg1Sb0AsO+I5MnDE7aQn9sXGx3jSf4jIM4abkVk8m/TO9kz5+fKC8j5SHNGQ== X-Received: by 2002:a17:902:8493:b029:d2:42a6:238 with SMTP id c19-20020a1709028493b02900d242a60238mr2124906plo.4.1600907542538; Wed, 23 Sep 2020 17:32:22 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:21 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 06/19] drm/virtgpu api: host visible feature Date: Wed, 23 Sep 2020 17:32:01 -0700 Message-Id: <20200924003214.662-6-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This exposes the host visible feature to userspace. Without it, it is an error to specify BLOB_MEM_HOST3D with BLOG_FLAG_USE_MAPPABLE. Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso Acked-by: Lingfeng Yang --- include/uapi/drm/virtgpu_drm.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h index bb224f604c9e3..e1b1518f9acc5 100644 --- a/include/uapi/drm/virtgpu_drm.h +++ b/include/uapi/drm/virtgpu_drm.h @@ -73,6 +73,7 @@ struct drm_virtgpu_execbuffer { #define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */ #define VIRTGPU_PARAM_CAPSET_QUERY_FIX 2 /* do we have the capset fix */ #define VIRTGPU_PARAM_RESOURCE_BLOB 3 /* DRM_VIRTGPU_RESOURCE_CREATE_BLOB */ +#define VIRTGPU_PARAM_HOST_VISIBLE 4 /* Host blob resources are mappable */ struct drm_virtgpu_getparam { __u64 param; From patchwork Thu Sep 24 00:32:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795835 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 734EE6CA for ; Thu, 24 Sep 2020 00:32:34 +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 4000421734 for ; Thu, 24 Sep 2020 00:32:34 +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="JcqgMiFa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4000421734 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 2479E6EA1D; Thu, 24 Sep 2020 00:32:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2B28D6EA1D for ; Thu, 24 Sep 2020 00:32:24 +0000 (UTC) Received: by mail-pj1-x1041.google.com with SMTP id a9so676794pjg.1 for ; Wed, 23 Sep 2020 17:32:24 -0700 (PDT) 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=HqROGzlbToaRzBVid4qBojAP/QMcbnLz/KvrDQUDCZk=; b=JcqgMiFaX83xTfip9uoF4eYLraEoFRdehlUI23AX09WC1TXwE8e5A+3NxI0MiOD5tt ilJJXQDHe0YrLPtb+ja5Tpoy7ZlK87MeYOkFxcKPGfPrZ7UzkM1behYRHDcfN10knmC8 cGPOjQI+OTNKGZ77HwHgpNNPx8ZUPGoE7f5O4= 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=HqROGzlbToaRzBVid4qBojAP/QMcbnLz/KvrDQUDCZk=; b=IFHcTSRe30cFbzoQi5cSqmozk92uS6En1jrTxP3y+3Ui4WkBokxGEa54eJSItjdLTn ZuJrap+QXYkrdNCP9PRsvM0rP4GLeuBj5LhMg1nlWNhmJhxKG8g6TPuplGpVBgGm5AM3 J8haIKz1+Stbd0311SZDmL6Z1Bdb6DxroTpkzsXa1BPBAqnly1nVdE7d8dDy/rZywQUL Ud7SabT9zO3sFhHyN4/1muM6xHQaS85yWrqwpTm07diRwMSN/Ybql0wCk0P89mgmbtcD 40ZfaNAKU3jgT0wAm90cPZzbjOMKP3hnlG+vmeiwA0F35avi9EcIWNnba5HKDmh4kftj sNJQ== X-Gm-Message-State: AOAM532ziQwYCAx9rOx4U9b39J3p+Df1ktMXy9sSqN3W0SHruVSf9Rve T1shPD4Q1j9dLu6euBGaOFDNF90wMlr08A== X-Google-Smtp-Source: ABdhPJxqLEXAQRunBfsRTd1UAzff249c8l/kuETQRhhzuqePgFeehL0FMDZKl7osR0i4Piudl6Qymw== X-Received: by 2002:a17:902:b591:b029:d1:e598:740a with SMTP id a17-20020a170902b591b02900d1e598740amr2093912pls.61.1600907543536; Wed, 23 Sep 2020 17:32:23 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:22 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 07/19] drm/virtgpu api: cross-device feature Date: Wed, 23 Sep 2020 17:32:02 -0700 Message-Id: <20200924003214.662-7-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This feature was recently added to virtio-gpu, lets make it userspace queryable. It's an error to use BLOB_FLAG_USE_CROSS_DEVICE when this feature is not present. Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso --- include/uapi/drm/virtgpu_drm.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h index e1b1518f9acc5..b9ec26e9c6463 100644 --- a/include/uapi/drm/virtgpu_drm.h +++ b/include/uapi/drm/virtgpu_drm.h @@ -74,6 +74,7 @@ struct drm_virtgpu_execbuffer { #define VIRTGPU_PARAM_CAPSET_QUERY_FIX 2 /* do we have the capset fix */ #define VIRTGPU_PARAM_RESOURCE_BLOB 3 /* DRM_VIRTGPU_RESOURCE_CREATE_BLOB */ #define VIRTGPU_PARAM_HOST_VISIBLE 4 /* Host blob resources are mappable */ +#define VIRTGPU_PARAM_CROSS_DEVICE 5 /* Cross virtio-device resource sharing */ struct drm_virtgpu_getparam { __u64 param; From patchwork Thu Sep 24 00:32:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795833 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 D16A26CB for ; Thu, 24 Sep 2020 00:32:32 +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 9B7F121734 for ; Thu, 24 Sep 2020 00:32:32 +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="YKP5W/CM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B7F121734 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 9AF476EA20; Thu, 24 Sep 2020 00:32:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by gabe.freedesktop.org (Postfix) with ESMTPS id 357E76EA1D for ; Thu, 24 Sep 2020 00:32:25 +0000 (UTC) Received: by mail-pj1-x1044.google.com with SMTP id mm21so668384pjb.4 for ; Wed, 23 Sep 2020 17:32:25 -0700 (PDT) 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=ymOxxBlf3Bu02IZ3jPmEKr++nGZ0/geoYQ1uDOjJMKE=; b=YKP5W/CMYCXUNm6iEBohuNQ+rm8w147fBPkaVNabxX18vezauml6mliXr0CQhlB489 bLr53SVQ1jbE2IJBoO3oVCsfFc31iNDzK+NbddSP0tiOzO2hk/W3znYBjS7yFd7PK3pc 8EbB9bPzOJ2HiYJzWy2K+uZ3D1R5nZYJSHfDY= 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=ymOxxBlf3Bu02IZ3jPmEKr++nGZ0/geoYQ1uDOjJMKE=; b=EUR+VFqwyVvXxC3z4VrvD89b+sxl9WhFcOZcmoqAFKvtDxEk7TBSVlwYRGVepQJ84Q oKHeblE+EKIHPJZ25z1Gsn/RL0CdpgCupKUYUwjL2i9dQvQjIJk8ZSu+n2N5nQN+dT2q BuDeubbZbd1gZiGVWJWzsDjVyhGht3Qsgh6WuvuveX32mNL0T2FujJlH09H3/+K6wkOW 2QriwbFRTqnOMMtWcqtBON3qN3rO97jWHaCnlAN79aFcq5nWgnWyxxXNCeRJuzgWcViL z0dHVTrk/0xq2BSv5PM/zlzkrzmcvopc0X7EhdfGWu+zM8Z7WN/ZNhmsAVGHLrheSRNm DQAw== X-Gm-Message-State: AOAM533I/Z+UrDA3YSOWzV350LVIx2iklGEA3Z9p6CEtsLE0LcXX+bmq z2sIGyceK3K0HIpFVX/5zl6WfHIAl44MOg== X-Google-Smtp-Source: ABdhPJwMtHYPePOD4GGSyHTvzKZG6z4Ulsl3i9JGb624UUYnGSH6Vh8ZvKQg1pwtAkISlb6EqAlJsw== X-Received: by 2002:a17:902:fe0e:b029:d1:e5ec:28d6 with SMTP id g14-20020a170902fe0eb02900d1e5ec28d6mr2118229plj.66.1600907544507; Wed, 23 Sep 2020 17:32:24 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:23 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 08/19] drm/virtio: implement blob resources: probe for the feature. Date: Wed, 23 Sep 2020 17:32:03 -0700 Message-Id: <20200924003214.662-8-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Gerd Hoffmann Let's proble for VIRTIO_GPU_F_RESOURCE_BLOB. Signed-off-by: Gerd Hoffmann Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso --- drivers/gpu/drm/virtio/virtgpu_debugfs.c | 1 + drivers/gpu/drm/virtio/virtgpu_drv.c | 1 + drivers/gpu/drm/virtio/virtgpu_drv.h | 1 + drivers/gpu/drm/virtio/virtgpu_kms.c | 10 +++++++--- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_debugfs.c b/drivers/gpu/drm/virtio/virtgpu_debugfs.c index d5b0c543bd6d7..6b9b8376613f0 100644 --- a/drivers/gpu/drm/virtio/virtgpu_debugfs.c +++ b/drivers/gpu/drm/virtio/virtgpu_debugfs.c @@ -49,6 +49,7 @@ static int virtio_gpu_features(struct seq_file *m, void *data) virtio_add_bool(m, "edid", vgdev->has_edid); virtio_add_bool(m, "indirect", vgdev->has_indirect); virtio_add_bool(m, "resource uuid", vgdev->has_resource_assign_uuid); + virtio_add_bool(m, "blob resources", vgdev->has_resource_blob); virtio_add_int(m, "cap sets", vgdev->num_capsets); virtio_add_int(m, "scanouts", vgdev->num_scanouts); return 0; diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c index b039f493bda99..3d04e428be140 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.c +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c @@ -166,6 +166,7 @@ static unsigned int features[] = { #endif VIRTIO_GPU_F_EDID, VIRTIO_GPU_F_RESOURCE_UUID, + VIRTIO_GPU_F_RESOURCE_BLOB, }; static struct virtio_driver virtio_gpu_driver = { .feature_table = features, diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index 272abe177ded6..b53478a6a3c08 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -208,6 +208,7 @@ struct virtio_gpu_device { bool has_edid; bool has_indirect; bool has_resource_assign_uuid; + bool has_resource_blob; struct work_struct config_changed_work; diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c index eed57a9313098..0678e56100dae 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -152,10 +152,14 @@ int virtio_gpu_init(struct drm_device *dev) if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_RESOURCE_UUID)) { vgdev->has_resource_assign_uuid = true; } + if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_RESOURCE_BLOB)) { + vgdev->has_resource_blob = true; + } - DRM_INFO("features: %cvirgl %cedid\n", - vgdev->has_virgl_3d ? '+' : '-', - vgdev->has_edid ? '+' : '-'); + DRM_INFO("features: %cvirgl %cedid %cresource_blob\n", + vgdev->has_virgl_3d ? '+' : '-', + vgdev->has_edid ? '+' : '-', + vgdev->has_resource_blob ? '+' : '-'); ret = virtio_find_vqs(vgdev->vdev, 2, vqs, callbacks, names, NULL); if (ret) { From patchwork Thu Sep 24 00:32:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795843 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 802DD6CA for ; Thu, 24 Sep 2020 00:32:43 +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 4925721734 for ; Thu, 24 Sep 2020 00:32:43 +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="MY+mWkva" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4925721734 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 3C9B16EA24; Thu, 24 Sep 2020 00:32:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 923DB6EA25 for ; Thu, 24 Sep 2020 00:32:27 +0000 (UTC) Received: by mail-vs1-xe41.google.com with SMTP id w25so1059646vsk.9 for ; Wed, 23 Sep 2020 17:32:27 -0700 (PDT) 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=slxxkPttXx89E/npUKwyp25sb5MdvAkiByWGPO08fKI=; b=MY+mWkva7bTHYQrWTTteasjMe0u924Xkmx8Vlc3bLaA13VfKU/29elxtRZP7BMOd8U H2H67XSeR5cIX2Onyz/oYwCqoHUoh0a1FzTFfn0YxtndYfW/34QJlNAni8HjVu581nNx myt+PMgGm0T64ZZ+38LO30ghhN/HMQcQN5q38= 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=slxxkPttXx89E/npUKwyp25sb5MdvAkiByWGPO08fKI=; b=fa0jkfPnY9VIaQKnpNToAVK0IxjemDGwV/LgVuMQSRkLTuTqcLJsZYJJJEeFX7xrep 8gSIhvt6mVxrrE1cHexM7JmocsI2jV7J2htniohNAUuY9+fsPftyj01B+vTpdAUocV4g cu3HJfLrpOsINs1MgZfQ1/vq4O/0BdHJYDm9eaPXKvmyyFYYZPK/oPpJPLZyoonxDYHG EAvTCF+BODkcxCKT340ZwV4wnctx2X2CwasBwgvw3CcuQgibJu0PhTXTG6FVWX6Bd0rP ZyVtAhqC4x4m19/Uy4a1ABlVS1bFNZ6A5QAhM/F5zpVqbGzmrxJYgjXjJvv5eqjwKfBk 74tg== X-Gm-Message-State: AOAM532Ggk4HJnk6dLKq0wD2LOR4JABE4h/0oYtw2Ox1L2hQ6+NRqij1 jRTJ4B77AyJyJGm7fIqqnrS1VudLAfi6AA== X-Google-Smtp-Source: ABdhPJymFegcObgsReGivdM3z7IFyC2Q2kBForMu22YUtFFzLY1pDhXCXzpsno6XzkGjqKhcJmH6JQ== X-Received: by 2002:a62:2985:0:b029:142:2501:34d6 with SMTP id p127-20020a6229850000b0290142250134d6mr2016126pfp.47.1600907545565; Wed, 23 Sep 2020 17:32:25 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:24 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 09/19] drm/virtio: implement blob resources: probe for host visible region Date: Wed, 23 Sep 2020 17:32:04 -0700 Message-Id: <20200924003214.662-9-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Gerd Hoffmann The availability of the host visible region means host 3D allocations can be directly mapped in the guest. Signed-off-by: Gerd Hoffmann Co-developed-by: Gurchetan Singh Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso --- drivers/gpu/drm/virtio/virtgpu_debugfs.c | 5 +++++ drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++ drivers/gpu/drm/virtio/virtgpu_kms.c | 20 ++++++++++++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_debugfs.c b/drivers/gpu/drm/virtio/virtgpu_debugfs.c index 6b9b8376613f0..a2cdd267914ac 100644 --- a/drivers/gpu/drm/virtio/virtgpu_debugfs.c +++ b/drivers/gpu/drm/virtio/virtgpu_debugfs.c @@ -52,6 +52,11 @@ static int virtio_gpu_features(struct seq_file *m, void *data) virtio_add_bool(m, "blob resources", vgdev->has_resource_blob); virtio_add_int(m, "cap sets", vgdev->num_capsets); virtio_add_int(m, "scanouts", vgdev->num_scanouts); + if (vgdev->host_visible_region.len) { + seq_printf(m, "%-16s : 0x%lx +0x%lx\n", "host visible region", + (unsigned long)vgdev->host_visible_region.addr, + (unsigned long)vgdev->host_visible_region.len); + } return 0; } diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index b53478a6a3c08..391637f0b362d 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -209,6 +209,8 @@ struct virtio_gpu_device { bool has_indirect; bool has_resource_assign_uuid; bool has_resource_blob; + bool has_host_visible; + struct virtio_shm_region host_visible_region; struct work_struct config_changed_work; diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c index 0678e56100dae..e17d3f5a0b54e 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -155,11 +155,27 @@ int virtio_gpu_init(struct drm_device *dev) if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_RESOURCE_BLOB)) { vgdev->has_resource_blob = true; } + if (virtio_get_shm_region(vgdev->vdev, &vgdev->host_visible_region, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE)) { + if (!devm_request_mem_region(&vgdev->vdev->dev, + vgdev->host_visible_region.addr, + vgdev->host_visible_region.len, + dev_name(&vgdev->vdev->dev))) { + DRM_ERROR("Could not reserve host visible region\n"); + goto err_vqs; + } + + DRM_INFO("Host memory window: 0x%lx +0x%lx\n", + (unsigned long)vgdev->host_visible_region.addr, + (unsigned long)vgdev->host_visible_region.len); + vgdev->has_host_visible = true; + } - DRM_INFO("features: %cvirgl %cedid %cresource_blob\n", + DRM_INFO("features: %cvirgl %cedid %cresource_blob %chost_visible\n", vgdev->has_virgl_3d ? '+' : '-', vgdev->has_edid ? '+' : '-', - vgdev->has_resource_blob ? '+' : '-'); + vgdev->has_resource_blob ? '+' : '-', + vgdev->has_host_visible ? '+' : '-'); ret = virtio_find_vqs(vgdev->vdev, 2, vqs, callbacks, names, NULL); if (ret) { From patchwork Thu Sep 24 00:32:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795861 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 AAC706CB for ; Thu, 24 Sep 2020 00:33:03 +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 8222C21D91 for ; Thu, 24 Sep 2020 00:33:03 +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="kAvYLdL8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8222C21D91 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 999736EA2E; Thu, 24 Sep 2020 00:33:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id 67CCC6EA24 for ; Thu, 24 Sep 2020 00:32:27 +0000 (UTC) Received: by mail-pf1-x444.google.com with SMTP id n14so749776pff.6 for ; Wed, 23 Sep 2020 17:32:27 -0700 (PDT) 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=fKpQR63Na8jJbJnL8hjl5PeqAwZSPyFZ5TFGGP+fpN0=; b=kAvYLdL8i8ULQ3HM1g5icSO8pa0H/b6ZI01XrObHpZTw/5Y4/katGgMvpSyj34PGe9 Ls0C5iby7Jjsn9AoCxxibJEUdFoSPWPWbVzzv5bUcw0G30fcX+JK2JPeeJsku+jdnSfd QgjBcSDnmnizUkiMbbnOBf2mTzQtSA5cA7K5I= 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=fKpQR63Na8jJbJnL8hjl5PeqAwZSPyFZ5TFGGP+fpN0=; b=Lxut16kILSHvtStXKMrE0dTMNX7DvLST3WIoOGhJbSwsKh9Y/IB5fAVYVXPRqFhFqt VyTIo8px3Z2unyEGHzmj22v1yilYdmPAff/sZOn2rr1xtukeX+h0RbaLZMkz88R/Wg9g GK9AMzsEFp3quSHDyQJVa4UlPvpezI5WBbZ70hrtvzC+TOCv24y9FnB5YyKPuQXZQ3HY EUyvFHqLiklPDocW1QG5+2+Gx5TSqAB8TmUm3RIU2lz5P6VGDwyENggc15dKuGhkdxi3 HsmAKkva2a88OLjOdO30L6LT/6qvr8DUIQartDijrG0+ui5ywjmfz9PUgLWhbBxEUYop D7UA== X-Gm-Message-State: AOAM532DjsVsHIKcICTxQNPsYsneBRN6w1TTjKxOhXEdU77CClv6ERMF iVrzkMaq7Jq3GTfoZerr3ueIeBEc3J9Kdg== X-Google-Smtp-Source: ABdhPJzaWUMH04sChCg2aksO1rXYwtdIXXQZnvSsLPQSrKFfvxdABi7CraCLepgmjnhQ6E/8H5aO+Q== X-Received: by 2002:a62:7c82:0:b029:13c:1611:66b9 with SMTP id x124-20020a627c820000b029013c161166b9mr2146235pfc.4.1600907546606; Wed, 23 Sep 2020 17:32:26 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:26 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 10/19] drm/virtio: implement blob resources: expose virtio_gpu_resource_id_get Date: Wed, 23 Sep 2020 17:32:05 -0700 Message-Id: <20200924003214.662-10-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" VRAM object will need it. Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso --- drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++ drivers/gpu/drm/virtio/virtgpu_object.c | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index 391637f0b362d..674a525df9bcc 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -384,6 +384,8 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, bool virtio_gpu_is_shmem(struct virtio_gpu_object *bo); +int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev, + uint32_t *resid); /* virtgpu_prime.c */ struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj, int flags); diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c index 4c107b53e81a0..9469ddda523e9 100644 --- a/drivers/gpu/drm/virtio/virtgpu_object.c +++ b/drivers/gpu/drm/virtio/virtgpu_object.c @@ -31,8 +31,7 @@ static int virtio_gpu_virglrenderer_workaround = 1; module_param_named(virglhack, virtio_gpu_virglrenderer_workaround, int, 0400); -static int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev, - uint32_t *resid) +int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev, uint32_t *resid) { if (virtio_gpu_virglrenderer_workaround) { /* From patchwork Thu Sep 24 00:32:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795841 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 44D186CB for ; Thu, 24 Sep 2020 00:32:42 +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 130AD2176B for ; Thu, 24 Sep 2020 00:32:42 +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="L4fjyUAH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 130AD2176B 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 262A66EA1F; Thu, 24 Sep 2020 00:32:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3DDB56EA24 for ; Thu, 24 Sep 2020 00:32:28 +0000 (UTC) Received: by mail-pf1-x431.google.com with SMTP id o20so730079pfp.11 for ; Wed, 23 Sep 2020 17:32:28 -0700 (PDT) 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=iGaee43EXlPWhgdf9Gnv3QJC5jb1e3zTIJUwX52KPp4=; b=L4fjyUAHDHSMY/yuD8q2gKyVZKmUTZz9F9q77YpzOGksqwaCHfRbYRit5Qg6LKnaNt 036jEKpolYpZFsKubZlrm5EKeVkL6ZmT8Y8VbNTig59tgYOO5KrcITwmxXPxFGxBREPf UiMPpc3rC6cQ9ZKBtoWlYCjUeUFLqFGH/BSjE= 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=iGaee43EXlPWhgdf9Gnv3QJC5jb1e3zTIJUwX52KPp4=; b=sJ6X9D5CXU/keaof40fTG+BGuhLL8vYoULP2dy9CYTVYTA6slcwlECELTeFjHXedIT ebIE/pyyiDTNJ+o9zjZyTHvCtk+yzAVR5vl6FowbHIt9BXhFrOLzYH9I269qhgq+y8Z8 21SCNBEUFLLB2A84QrhAgcoyF00+VzUdkv9U+m6zh8zjFgxJCw1vSWT3k7cyNzpduUta WCbM5gBV8hJWBLn9Komio8OunPGDTYfJ+4xAD/jKzoAJAf3pgW1g7VYr0OeYtYflXHVu XikLQFOGikqlkr2QQ/zkojKsCTlwkgFQwbnE4h8n15xp8VjOhPFjuYkj6HZ/x3YULhB7 2VMg== X-Gm-Message-State: AOAM533v9WSAcx7TUjyCT7Yjsq2+A8vrQSwNicCkKxAoN970QGCvrE+u crC7FmIXI+lbgJtwsDvFXyGge0pUKZwa6g== X-Google-Smtp-Source: ABdhPJxwpOkMwwn2YXhRUm1ZOWqkqrsCtWHrCy2B84AhOZhnU4ayb2FoPjG8kLEgFYcJAHubERbrEw== X-Received: by 2002:aa7:9518:0:b029:142:2501:35e3 with SMTP id b24-20020aa795180000b0290142250135e3mr2106763pfp.67.1600907547542; Wed, 23 Sep 2020 17:32:27 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:26 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 11/19] drm/virtio: implement blob resources: add new fields to internal structs Date: Wed, 23 Sep 2020 17:32:06 -0700 Message-Id: <20200924003214.662-11-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Useful for upcoming blob resources. Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso --- drivers/gpu/drm/virtio/virtgpu_drv.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index 674a525df9bcc..bddf06b8fb684 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -54,13 +54,16 @@ #define STATE_ERR 2 struct virtio_gpu_object_params { - uint32_t format; - uint32_t width; - uint32_t height; unsigned long size; bool dumb; /* 3d */ bool virgl; + bool blob; + + /* classic resources only */ + uint32_t format; + uint32_t width; + uint32_t height; uint32_t target; uint32_t bind; uint32_t depth; @@ -68,6 +71,12 @@ struct virtio_gpu_object_params { uint32_t last_level; uint32_t nr_samples; uint32_t flags; + + /* blob resources only */ + uint32_t ctx_id; + uint32_t blob_mem; + uint32_t blob_flags; + uint64_t blob_id; }; struct virtio_gpu_object { @@ -75,6 +84,8 @@ struct virtio_gpu_object { uint32_t hw_res_handle; bool dumb; bool created; + bool host3d_blob, guest_blob; + uint32_t blob_mem, blob_flags; int uuid_state; uuid_t uuid; From patchwork Thu Sep 24 00:32:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795849 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 594356CA for ; Thu, 24 Sep 2020 00:32:47 +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 2500F2145D for ; Thu, 24 Sep 2020 00:32:47 +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="GuvLGRBy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2500F2145D 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 C6DB06EA27; Thu, 24 Sep 2020 00:32:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9B32C6EA1F for ; Thu, 24 Sep 2020 00:32:29 +0000 (UTC) Received: by mail-pl1-x641.google.com with SMTP id y17so667486plb.6 for ; Wed, 23 Sep 2020 17:32:29 -0700 (PDT) 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=Fu5Gil0+jaX5v7AWrq6KgWSYkdMfxJ6E7c8h0cSmtZM=; b=GuvLGRBy4DTDV3q6E4hoSlAZ2UXqNRWpY8LFvoVU6V1CX7OtU6vDRb7pMHzZrB/+A8 V9Pfqb3EExW1f/TNUVsbj9H6nC6IOS5rs5gJO9pP1GGkPQo8/caHLAo68Sj8L+evGbfy fhr1Eh8ICKtde0D+zUHYSjAWP9mUaIIdm06ro= 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=Fu5Gil0+jaX5v7AWrq6KgWSYkdMfxJ6E7c8h0cSmtZM=; b=cyjnHtcoA1Mp0CcPGqmM3iD5n58JVsCtUodqrVpCih+xjZmEDWf8qCGzhqhop1knHo zBuy4KTsuJz175mcrUfLINuqudyZnR1Mz7Y4YvcKDv9uw5NK3xDETX5XaskdXPREBjXw 7y9VOxJ/IGgg6emho4NoB8oM59SIvuI4cxwUggK2R0wlngx8SlZNn8LtYctzTVvmQXRj cey6kKJ7J3Jw9uNzdfW5dJ2D2Zcobl0ajDpDGq+V5OAI/ttkBtFe0WhWmDSuA287EXRg AfXAc55Uvu20lBxG1fLDzAXTg+mexZ3fsEMNyhq4qjUw0+ClyynRrcupK3k4HyDizOVD ARew== X-Gm-Message-State: AOAM533c34PT7lOLlv52Usd14YV7RS4sLCYqKL7qTLZYCZrPd8zmQZw4 KVya0GWt9mAYfg7onEx/tjSjvqfzqPxPww== X-Google-Smtp-Source: ABdhPJxRucRuM5vh/xyKhOFvM1OsUcTs5tfYrzGYwqye1AftPpEFJLu0VjUoJjkmA+nRDL9uyC7qAA== X-Received: by 2002:a17:90b:80a:: with SMTP id bk10mr1601991pjb.53.1600907548632; Wed, 23 Sep 2020 17:32:28 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:27 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 12/19] drm/virtio: implement blob resources: implement vram object Date: Wed, 23 Sep 2020 17:32:07 -0700 Message-Id: <20200924003214.662-12-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Gerd Hoffmann A virtio-gpu vram object is based on range-based allocation. No guest shmemfs backing, so we call drm_gem_private_object_init. This is for host memory without any guest backing (atleast initially). Signed-off-by: Gerd Hoffmann Co-developed-by: Gurchetan Singh Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso --- drivers/gpu/drm/virtio/Makefile | 2 +- drivers/gpu/drm/virtio/virtgpu_debugfs.c | 20 ++- drivers/gpu/drm/virtio/virtgpu_drv.h | 26 +++- drivers/gpu/drm/virtio/virtgpu_kms.c | 8 ++ drivers/gpu/drm/virtio/virtgpu_object.c | 12 ++ drivers/gpu/drm/virtio/virtgpu_vq.c | 66 +++++++++ drivers/gpu/drm/virtio/virtgpu_vram.c | 162 +++++++++++++++++++++++ 7 files changed, 293 insertions(+), 3 deletions(-) create mode 100644 drivers/gpu/drm/virtio/virtgpu_vram.c diff --git a/drivers/gpu/drm/virtio/Makefile b/drivers/gpu/drm/virtio/Makefile index 92aa2b3d349d9..b99fa4a73b68e 100644 --- a/drivers/gpu/drm/virtio/Makefile +++ b/drivers/gpu/drm/virtio/Makefile @@ -3,7 +3,7 @@ # Makefile for the drm device driver. This driver provides support for the # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. -virtio-gpu-y := virtgpu_drv.o virtgpu_kms.o virtgpu_gem.o \ +virtio-gpu-y := virtgpu_drv.o virtgpu_kms.o virtgpu_gem.o virtgpu_vram.o \ virtgpu_display.o virtgpu_vq.o \ virtgpu_fence.o virtgpu_object.o virtgpu_debugfs.o virtgpu_plane.o \ virtgpu_ioctl.o virtgpu_prime.o virtgpu_trace_points.o diff --git a/drivers/gpu/drm/virtio/virtgpu_debugfs.c b/drivers/gpu/drm/virtio/virtgpu_debugfs.c index a2cdd267914ac..f336a8fa66667 100644 --- a/drivers/gpu/drm/virtio/virtgpu_debugfs.c +++ b/drivers/gpu/drm/virtio/virtgpu_debugfs.c @@ -42,7 +42,7 @@ static void virtio_add_int(struct seq_file *m, const char *name, static int virtio_gpu_features(struct seq_file *m, void *data) { - struct drm_info_node *node = (struct drm_info_node *) m->private; + struct drm_info_node *node = (struct drm_info_node *)m->private; struct virtio_gpu_device *vgdev = node->minor->dev->dev_private; virtio_add_bool(m, "virgl", vgdev->has_virgl_3d); @@ -72,9 +72,27 @@ virtio_gpu_debugfs_irq_info(struct seq_file *m, void *data) return 0; } +static int +virtio_gpu_debugfs_host_visible_mm(struct seq_file *m, void *data) +{ + struct drm_info_node *node = (struct drm_info_node *)m->private; + struct virtio_gpu_device *vgdev = node->minor->dev->dev_private; + struct drm_printer p; + + if (!vgdev->has_host_visible) { + seq_puts(m, "Host allocations not visible to guest\n"); + return 0; + } + + p = drm_seq_file_printer(m); + drm_mm_print(&vgdev->host_visible_mm, &p); + return 0; +} + static struct drm_info_list virtio_gpu_debugfs_list[] = { { "virtio-gpu-features", virtio_gpu_features }, { "virtio-gpu-irq-fence", virtio_gpu_debugfs_irq_info, 0, NULL }, + { "virtio-gpu-host-visible-mm", virtio_gpu_debugfs_host_visible_mm }, }; #define VIRTIO_GPU_DEBUGFS_ENTRIES ARRAY_SIZE(virtio_gpu_debugfs_list) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index bddf06b8fb684..7c9cf6960a92f 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -99,9 +99,19 @@ struct virtio_gpu_object_shmem { uint32_t mapped; }; +struct virtio_gpu_object_vram { + struct virtio_gpu_object base; + uint32_t map_state; + uint32_t map_info; + struct drm_mm_node vram_node; +}; + #define to_virtio_gpu_shmem(virtio_gpu_object) \ container_of((virtio_gpu_object), struct virtio_gpu_object_shmem, base) +#define to_virtio_gpu_vram(virtio_gpu_object) \ + container_of((virtio_gpu_object), struct virtio_gpu_object_vram, base) + struct virtio_gpu_object_array { struct ww_acquire_ctx ticket; struct list_head next; @@ -222,6 +232,7 @@ struct virtio_gpu_device { bool has_resource_blob; bool has_host_visible; struct virtio_shm_region host_visible_region; + struct drm_mm host_visible_mm; struct work_struct config_changed_work; @@ -233,8 +244,10 @@ struct virtio_gpu_device { uint32_t num_capsets; struct list_head cap_cache; - /* protects resource state when exporting */ + /* protects uuid state when exporting */ spinlock_t resource_export_lock; + /* protects map state and host_visible_mm */ + spinlock_t host_visible_lock; }; struct virtio_gpu_fpriv { @@ -365,6 +378,12 @@ int virtio_gpu_cmd_resource_assign_uuid(struct virtio_gpu_device *vgdev, struct virtio_gpu_object_array *objs); +int virtio_gpu_cmd_map(struct virtio_gpu_device *vgdev, + struct virtio_gpu_object_array *objs, uint64_t offset); + +void virtio_gpu_cmd_unmap(struct virtio_gpu_device *vgdev, + struct virtio_gpu_object *bo); + /* virtgpu_display.c */ int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev); void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev); @@ -411,4 +430,9 @@ struct drm_gem_object *virtgpu_gem_prime_import_sg_table( /* virtgpu_debugfs.c */ void virtio_gpu_debugfs_init(struct drm_minor *minor); +/* virtgpu_vram.c */ +bool virtio_gpu_is_vram(struct virtio_gpu_object *bo); +int virtio_gpu_vram_create(struct virtio_gpu_device *vgdev, + struct virtio_gpu_object_params *params, + struct virtio_gpu_object **bo_ptr); #endif diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c index e17d3f5a0b54e..b4ec479c32cda 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -121,6 +121,7 @@ int virtio_gpu_init(struct drm_device *dev) spin_lock_init(&vgdev->display_info_lock); spin_lock_init(&vgdev->resource_export_lock); + spin_lock_init(&vgdev->host_visible_lock); ida_init(&vgdev->ctx_id_ida); ida_init(&vgdev->resource_ida); init_waitqueue_head(&vgdev->resp_wq); @@ -169,6 +170,9 @@ int virtio_gpu_init(struct drm_device *dev) (unsigned long)vgdev->host_visible_region.addr, (unsigned long)vgdev->host_visible_region.len); vgdev->has_host_visible = true; + drm_mm_init(&vgdev->host_visible_mm, + (unsigned long)vgdev->host_visible_region.addr, + (unsigned long)vgdev->host_visible_region.len); } DRM_INFO("features: %cvirgl %cedid %cresource_blob %chost_visible\n", @@ -262,6 +266,10 @@ void virtio_gpu_release(struct drm_device *dev) virtio_gpu_modeset_fini(vgdev); virtio_gpu_free_vbufs(vgdev); virtio_gpu_cleanup_cap_cache(vgdev); + + if (vgdev->has_host_visible) + drm_mm_takedown(&vgdev->host_visible_mm); + kfree(vgdev->capsets); kfree(vgdev); } diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c index 9469ddda523e9..099f10313815a 100644 --- a/drivers/gpu/drm/virtio/virtgpu_object.c +++ b/drivers/gpu/drm/virtio/virtgpu_object.c @@ -84,6 +84,18 @@ void virtio_gpu_cleanup_object(struct virtio_gpu_object *bo) } drm_gem_shmem_free_object(&bo->base.base); + } else if (virtio_gpu_is_vram(bo)) { + struct virtio_gpu_object_vram *vram = to_virtio_gpu_vram(bo); + + spin_lock(&vgdev->host_visible_lock); + if (drm_mm_node_allocated(&vram->vram_node)) + drm_mm_remove_node(&vram->vram_node); + + spin_unlock(&vgdev->host_visible_lock); + + drm_gem_free_mmap_offset(&vram->base.base.base); + drm_gem_object_release(&vram->base.base.base); + kfree(vram); } } diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index 55529ed97d9c7..41fd253d357ed 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -1171,3 +1171,69 @@ virtio_gpu_cmd_resource_assign_uuid(struct virtio_gpu_device *vgdev, virtio_gpu_queue_ctrl_buffer(vgdev, vbuf); return 0; } + +static void virtio_gpu_cmd_resource_map_cb(struct virtio_gpu_device *vgdev, + struct virtio_gpu_vbuffer *vbuf) +{ + struct virtio_gpu_object *bo = + gem_to_virtio_gpu_obj(vbuf->objs->objs[0]); + struct virtio_gpu_resp_map_info *resp = + (struct virtio_gpu_resp_map_info *)vbuf->resp_buf; + struct virtio_gpu_object_vram *vram = to_virtio_gpu_vram(bo); + uint32_t resp_type = le32_to_cpu(resp->hdr.type); + + spin_lock(&vgdev->host_visible_lock); + + if (resp_type == VIRTIO_GPU_RESP_OK_MAP_INFO) { + vram->map_info = resp->map_info; + vram->map_state = STATE_OK; + } else { + vram->map_state = STATE_ERR; + } + + spin_unlock(&vgdev->host_visible_lock); + wake_up_all(&vgdev->resp_wq); +} + +int virtio_gpu_cmd_map(struct virtio_gpu_device *vgdev, + struct virtio_gpu_object_array *objs, uint64_t offset) +{ + struct virtio_gpu_resource_map_blob *cmd_p; + struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]); + struct virtio_gpu_vbuffer *vbuf; + struct virtio_gpu_resp_map_info *resp_buf; + + resp_buf = kzalloc(sizeof(*resp_buf), GFP_KERNEL); + if (!resp_buf) { + virtio_gpu_array_put_free(objs); + return -ENOMEM; + } + + cmd_p = virtio_gpu_alloc_cmd_resp + (vgdev, virtio_gpu_cmd_resource_map_cb, &vbuf, sizeof(*cmd_p), + sizeof(struct virtio_gpu_resp_map_info), resp_buf); + memset(cmd_p, 0, sizeof(*cmd_p)); + + cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB); + cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle); + cmd_p->offset = cpu_to_le64(offset); + vbuf->objs = objs; + + virtio_gpu_queue_ctrl_buffer(vgdev, vbuf); + return 0; +} + +void virtio_gpu_cmd_unmap(struct virtio_gpu_device *vgdev, + struct virtio_gpu_object *bo) +{ + struct virtio_gpu_resource_unmap_blob *cmd_p; + struct virtio_gpu_vbuffer *vbuf; + + cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p)); + memset(cmd_p, 0, sizeof(*cmd_p)); + + cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB); + cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle); + + virtio_gpu_queue_ctrl_buffer(vgdev, vbuf); +} diff --git a/drivers/gpu/drm/virtio/virtgpu_vram.c b/drivers/gpu/drm/virtio/virtgpu_vram.c new file mode 100644 index 0000000000000..087945fcd230f --- /dev/null +++ b/drivers/gpu/drm/virtio/virtgpu_vram.c @@ -0,0 +1,162 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "virtgpu_drv.h" + +static void virtio_gpu_vram_free(struct drm_gem_object *obj) +{ + struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj); + struct virtio_gpu_device *vgdev = obj->dev->dev_private; + struct virtio_gpu_object_vram *vram = to_virtio_gpu_vram(bo); + bool unmap; + + if (bo->created) { + spin_lock(&vgdev->host_visible_lock); + unmap = drm_mm_node_allocated(&vram->vram_node); + spin_unlock(&vgdev->host_visible_lock); + + if (unmap) + virtio_gpu_cmd_unmap(vgdev, bo); + + virtio_gpu_cmd_unref_resource(vgdev, bo); + virtio_gpu_notify(vgdev); + return; + } +} + +static const struct vm_operations_struct virtio_gpu_vram_vm_ops = { + .open = drm_gem_vm_open, + .close = drm_gem_vm_close, +}; + +static int virtio_gpu_vram_mmap(struct drm_gem_object *obj, + struct vm_area_struct *vma) +{ + int ret; + struct virtio_gpu_device *vgdev = obj->dev->dev_private; + struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj); + struct virtio_gpu_object_vram *vram = to_virtio_gpu_vram(bo); + unsigned long vm_size = vma->vm_end - vma->vm_start; + + if (!(bo->blob_flags & VIRTGPU_BLOB_FLAG_USE_MAPPABLE)) + return -EINVAL; + + wait_event(vgdev->resp_wq, vram->map_state != STATE_INITIALIZING); + if (vram->map_state != STATE_OK) + return -EINVAL; + + vma->vm_pgoff -= drm_vma_node_start(&obj->vma_node); + vma->vm_flags |= VM_MIXEDMAP | VM_DONTEXPAND; + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); + vma->vm_ops = &virtio_gpu_vram_vm_ops; + + if (vram->map_info == VIRTIO_GPU_MAP_CACHE_WC) + vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); + else if (vram->map_info == VIRTIO_GPU_MAP_CACHE_UNCACHED) + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + + /* Partial mappings of GEM buffers don't happen much in practice. */ + if (vm_size != vram->vram_node.size) + return -EINVAL; + + ret = io_remap_pfn_range(vma, vma->vm_start, + vram->vram_node.start >> PAGE_SHIFT, + vm_size, vma->vm_page_prot); + return ret; +} + +static const struct drm_gem_object_funcs virtio_gpu_vram_funcs = { + .open = virtio_gpu_gem_object_open, + .close = virtio_gpu_gem_object_close, + .free = virtio_gpu_vram_free, + .mmap = virtio_gpu_vram_mmap, +}; + +bool virtio_gpu_is_vram(struct virtio_gpu_object *bo) +{ + return bo->base.base.funcs == &virtio_gpu_vram_funcs; +} + +static int virtio_gpu_vram_map(struct virtio_gpu_object *bo) +{ + int ret; + uint64_t offset; + struct virtio_gpu_object_array *objs; + struct virtio_gpu_device *vgdev = bo->base.base.dev->dev_private; + struct virtio_gpu_object_vram *vram = to_virtio_gpu_vram(bo); + + if (!vgdev->has_host_visible) + return -EINVAL; + + spin_lock(&vgdev->host_visible_lock); + ret = drm_mm_insert_node(&vgdev->host_visible_mm, &vram->vram_node, + bo->base.base.size); + spin_unlock(&vgdev->host_visible_lock); + + if (ret) + return ret; + + objs = virtio_gpu_array_alloc(1); + if (!objs) { + ret = -ENOMEM; + goto err_remove_node; + } + + virtio_gpu_array_add_obj(objs, &bo->base.base); + /*TODO: Add an error checking helper function in drm_mm.h */ + offset = vram->vram_node.start - vgdev->host_visible_region.addr; + + ret = virtio_gpu_cmd_map(vgdev, objs, offset); + if (ret) { + virtio_gpu_array_put_free(objs); + goto err_remove_node; + } + + return 0; + +err_remove_node: + spin_lock(&vgdev->host_visible_lock); + drm_mm_remove_node(&vram->vram_node); + spin_unlock(&vgdev->host_visible_lock); + return ret; +} + +int virtio_gpu_vram_create(struct virtio_gpu_device *vgdev, + struct virtio_gpu_object_params *params, + struct virtio_gpu_object **bo_ptr) +{ + struct drm_gem_object *obj; + struct virtio_gpu_object_vram *vram; + int ret; + + vram = kzalloc(sizeof(*vram), GFP_KERNEL); + if (!vram) + return -ENOMEM; + + obj = &vram->base.base.base; + obj->funcs = &virtio_gpu_vram_funcs; + drm_gem_private_object_init(vgdev->ddev, obj, params->size); + + /* Create fake offset */ + ret = drm_gem_create_mmap_offset(obj); + if (ret) { + kfree(vram); + return ret; + } + + ret = virtio_gpu_resource_id_get(vgdev, &vram->base.hw_res_handle); + if (ret) { + kfree(vram); + return ret; + } + + if (params->blob_flags & VIRTGPU_BLOB_FLAG_USE_MAPPABLE) { + ret = virtio_gpu_vram_map(&vram->base); + if (ret) { + virtio_gpu_vram_free(obj); + return ret; + } + } + + *bo_ptr = &vram->base; + return 0; +} From patchwork Thu Sep 24 00:32:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795847 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 0D73E6CA for ; Thu, 24 Sep 2020 00:32:46 +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 CEF342176B for ; Thu, 24 Sep 2020 00:32:45 +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="Rqa8YkFK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CEF342176B 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 E5B8B6EA28; Thu, 24 Sep 2020 00:32:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id 529616EA1F for ; Thu, 24 Sep 2020 00:32:30 +0000 (UTC) Received: by mail-pg1-x541.google.com with SMTP id f2so788163pgd.3 for ; Wed, 23 Sep 2020 17:32:30 -0700 (PDT) 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=Bfig8TwqH9ydH1ryVe4vBcf/KpLkukv15QWltbsF2CU=; b=Rqa8YkFKq1FoCnt2ADnM2pr4njGqMd2L4SKv+wDtcz9NKAaOamnE5OH9TIcLPW6QW9 Rfgw9+Hn/GKaLuMURSHGKLYTQ87f85owdXAE6Ku8ymTt58mhXhDoEdbVSGg30QzyGQYK FXvFHrsg5eU1niP5SpbwM4zd99CaixRJ8IDiM= 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=Bfig8TwqH9ydH1ryVe4vBcf/KpLkukv15QWltbsF2CU=; b=JHljEoIzgVKmhD1nXTJ+ov892/X5VojwEICrdYpIep5E43qELREFIklplmeN0zsYaH WCWcFm+RoeyGyEeIghvnZ/2oCka6wgr+mrdEkNf4MKIgwmzzux1UbMN8ndgIwxv2p26q aJ9jyMup99riseaGWtu7qFmvyv8CLpqeelICjw4BGQX4LpHLB+n6layUhI2BhO8Z3iml /8UUri+xPXBKhXueqQ8Ma6FjRibLv4TQ7oJlB1tbxbrlZUf9+L9w1sUSKeAq4Oy2Wfv5 3ly/ZEymRBWDmbMz7ItDP7vwOAap5/wMKPoj3kc1787iBkMRPOarm4s6uIBfbywD8LYz B7sA== X-Gm-Message-State: AOAM530aXyhHDBNQEIaTYIIn5oN14WH/QOph2T2wTsfyJnTf6aNh4Y1u UUHQ8nu3fwG/iEgNg13ZGTXIl7hAQ0Vveg== X-Google-Smtp-Source: ABdhPJzWmAQ6hUusVJ3rOT/qh9k6IMgLLgpwSkqVkpaqdCGJuyvJcbMUenMA+jlnKqNnpw5X9y3iXQ== X-Received: by 2002:aa7:96c7:0:b029:142:38cd:13de with SMTP id h7-20020aa796c70000b029014238cd13demr2139539pfq.66.1600907549640; Wed, 23 Sep 2020 17:32:29 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:29 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 13/19] drm/virtio: implement blob resources: hypercall interface Date: Wed, 23 Sep 2020 17:32:08 -0700 Message-Id: <20200924003214.662-13-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This implements the blob hypercall interface. Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso --- drivers/gpu/drm/virtio/virtgpu_drv.h | 15 +++++++ drivers/gpu/drm/virtio/virtgpu_vq.c | 65 ++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index 7c9cf6960a92f..e1143a00017c5 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -384,6 +385,20 @@ int virtio_gpu_cmd_map(struct virtio_gpu_device *vgdev, void virtio_gpu_cmd_unmap(struct virtio_gpu_device *vgdev, struct virtio_gpu_object *bo); +void +virtio_gpu_cmd_resource_create_blob(struct virtio_gpu_device *vgdev, + struct virtio_gpu_object *bo, + struct virtio_gpu_object_params *params, + struct virtio_gpu_mem_entry *ents, + uint32_t nents); +void +virtio_gpu_cmd_set_scanout_blob(struct virtio_gpu_device *vgdev, + uint32_t scanout_id, + struct virtio_gpu_object *bo, + struct drm_framebuffer *fb, + uint32_t width, uint32_t height, + uint32_t x, uint32_t y); + /* virtgpu_display.c */ int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev); void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev); diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index 41fd253d357ed..e71c8eec0b914 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -1237,3 +1237,68 @@ void virtio_gpu_cmd_unmap(struct virtio_gpu_device *vgdev, virtio_gpu_queue_ctrl_buffer(vgdev, vbuf); } + +void +virtio_gpu_cmd_resource_create_blob(struct virtio_gpu_device *vgdev, + struct virtio_gpu_object *bo, + struct virtio_gpu_object_params *params, + struct virtio_gpu_mem_entry *ents, + uint32_t nents) +{ + struct virtio_gpu_resource_create_blob *cmd_p; + struct virtio_gpu_vbuffer *vbuf; + + cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p)); + memset(cmd_p, 0, sizeof(*cmd_p)); + + cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB); + cmd_p->hdr.ctx_id = cpu_to_le32(params->ctx_id); + cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle); + cmd_p->blob_mem = cpu_to_le32(params->blob_mem); + cmd_p->blob_flags = cpu_to_le32(params->blob_flags); + cmd_p->blob_id = cpu_to_le64(params->blob_id); + cmd_p->size = cpu_to_le64(params->size); + cmd_p->nr_entries = cpu_to_le32(nents); + + vbuf->data_buf = ents; + vbuf->data_size = sizeof(*ents) * nents; + + virtio_gpu_queue_ctrl_buffer(vgdev, vbuf); + bo->created = true; +} + +void virtio_gpu_cmd_set_scanout_blob(struct virtio_gpu_device *vgdev, + uint32_t scanout_id, + struct virtio_gpu_object *bo, + struct drm_framebuffer *fb, + uint32_t width, uint32_t height, + uint32_t x, uint32_t y) +{ + uint32_t i; + struct virtio_gpu_set_scanout_blob *cmd_p; + struct virtio_gpu_vbuffer *vbuf; + uint32_t format = virtio_gpu_translate_format(fb->format->format); + + cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p)); + memset(cmd_p, 0, sizeof(*cmd_p)); + + cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_SET_SCANOUT_BLOB); + cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle); + cmd_p->scanout_id = cpu_to_le32(scanout_id); + + cmd_p->format = cpu_to_le32(format); + cmd_p->width = cpu_to_le32(fb->width); + cmd_p->height = cpu_to_le32(fb->height); + + for (i = 0; i < 4; i++) { + cmd_p->strides[i] = cpu_to_le32(fb->pitches[i]); + cmd_p->offsets[i] = cpu_to_le32(fb->offsets[i]); + } + + cmd_p->r.width = cpu_to_le32(width); + cmd_p->r.height = cpu_to_le32(height); + cmd_p->r.x = cpu_to_le32(x); + cmd_p->r.y = cpu_to_le32(y); + + virtio_gpu_queue_ctrl_buffer(vgdev, vbuf); +} From patchwork Thu Sep 24 00:32:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795859 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 121656CA for ; Thu, 24 Sep 2020 00:32: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 D2DCA2176B for ; Thu, 24 Sep 2020 00:32:52 +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="T+iWSrNp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2DCA2176B 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 4A2226EA2B; Thu, 24 Sep 2020 00:32:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2CB296EA1F for ; Thu, 24 Sep 2020 00:32:31 +0000 (UTC) Received: by mail-pf1-x442.google.com with SMTP id k13so769980pfg.1 for ; Wed, 23 Sep 2020 17:32:31 -0700 (PDT) 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=BOXDdY1Dj7RStxqOavoh+pSLQdK+vdGARXnQxUkS1Tk=; b=T+iWSrNpZNCPbnf8bYXa8BmegptrRExKOUJ3xlsbarjYY4+Q6DBbJ7eux+zX8+tC4b 8JTIDo2VeSRm2tYdKvFdhqhOdeVH1AHDoFUSSaMR26QU4VZOEgKdSETWEq0fROepZDa/ Ew7SHvZM9y/kYapomaIPLA2H7mXP7wYnmaXQU= 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=BOXDdY1Dj7RStxqOavoh+pSLQdK+vdGARXnQxUkS1Tk=; b=dXjm2UO9zAFKUlO4LZAGyZqS/IL01APRSqAX2dDr9FvQox349fWwU3bvNz/2Am1+0u bHvWHH9g5cYmdzxPYsiTAx5VkyWswtF4rkOzWXCvFYute9yjem9spyP5Nle71hddA1lB wgnmsgtgtCedgiSZxGW544yKXjxBssVYFR6jFdhpJfSh3O+vTmcoOTa57ZhCoYYK+5ZT bFFhI99u2vFUSgg/76cBJ5+6F7UILET80xPc4natAuUGuiRcMIXizd4xfdJDRCC+JJ+L IPwVFbRlAjRKnrzPoKCzy0JyTTYK9a8GJHoy1eMriTV2Lq8W2LJzwAZPXWFvivG/od5g 1+Ig== X-Gm-Message-State: AOAM532QbT0SG8+M/z/XtKKtC+F98N9FpiEPBQ82g/1D35O6AdsMmrFl bd7K2aM/DvIKDyxXyN8kqgIvYnchuDNe5A== X-Google-Smtp-Source: ABdhPJw7kCf4V3Tml2u0/P4O5C+uM+g+r0TzgarxZuPE/YJAm3SNAFKqNoCykMd2n5XWNVaR5Lr5xg== X-Received: by 2002:a05:6a00:792:b029:13c:1611:652d with SMTP id g18-20020a056a000792b029013c1611652dmr2076098pfu.13.1600907550570; Wed, 23 Sep 2020 17:32:30 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:30 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 14/19] drm/virtio: implement blob resources: blob display integration Date: Wed, 23 Sep 2020 17:32:09 -0700 Message-Id: <20200924003214.662-14-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" SCANOUT_BLOB forwards the DRM framebuffer metadata to the host. The modifier is intentionally left out -- it may be possible to query the host for that. We also assume one blob resource per DRM framebuffer. That too is an intentional simplification. Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso --- drivers/gpu/drm/virtio/virtgpu_plane.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c index 6a311cd934403..42ac08ed1442e 100644 --- a/drivers/gpu/drm/virtio/virtgpu_plane.c +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c @@ -174,12 +174,23 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane, plane->state->src_h >> 16, plane->state->src_x >> 16, plane->state->src_y >> 16); - virtio_gpu_cmd_set_scanout(vgdev, output->index, - bo->hw_res_handle, - plane->state->src_w >> 16, - plane->state->src_h >> 16, - plane->state->src_x >> 16, - plane->state->src_y >> 16); + + if (bo->host3d_blob || bo->guest_blob) { + virtio_gpu_cmd_set_scanout_blob + (vgdev, output->index, bo, + plane->state->fb, + plane->state->src_w >> 16, + plane->state->src_h >> 16, + plane->state->src_x >> 16, + plane->state->src_y >> 16); + } else { + virtio_gpu_cmd_set_scanout(vgdev, output->index, + bo->hw_res_handle, + plane->state->src_w >> 16, + plane->state->src_h >> 16, + plane->state->src_x >> 16, + plane->state->src_y >> 16); + } } virtio_gpu_cmd_resource_flush(vgdev, bo->hw_res_handle, From patchwork Thu Sep 24 00:32:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795851 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 70F9D6CA for ; Thu, 24 Sep 2020 00:32:48 +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 40E422145D for ; Thu, 24 Sep 2020 00:32:48 +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="TwpdAJom" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 40E422145D 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 4D78C6EA2C; Thu, 24 Sep 2020 00:32:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3ABD06EA1F for ; Thu, 24 Sep 2020 00:32:32 +0000 (UTC) Received: by mail-pl1-x643.google.com with SMTP id f1so642507plo.13 for ; Wed, 23 Sep 2020 17:32:32 -0700 (PDT) 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=8mXNSXYut9HcAcT3m1n94YKqL04blq1VBP+Feila5hE=; b=TwpdAJomkAt0oX9wene/nHkhXEI09INgd1lJ7Uo/QA8x+MrRP0gY61vHXG75nwnXWS DXh3GclpaqKNTsv4wJD5D9oGPaL/8mboQHTuQqzvceJ4MBL6hXYnttgnq95uUTaiDzLJ U2l+EHhW0/FCVS17TIlh9J933r6rCiPGeNeAk= 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=8mXNSXYut9HcAcT3m1n94YKqL04blq1VBP+Feila5hE=; b=ewwcuqcwceIOz9fryAZT9EkWAFr/h7cR0yVnywS889Opzfq6uL0WkyvHql45F2aHxs AnXtdLIpTL1jOW47ze7vE8fvCYjV3fbtka8Z7ME3X/Koz/ii8fOGvBV3+e7Sa/tCJXmP unS+iQ+a1PaXn8uDVxH64FjaZaG3tqyod8hyIx8iSfNUns/Z8Pbox772lTLq1zkm6spL 7HbZf4IhCZLHFW7bf7iT9ZMsGhPCPK2e+TEoP4ZgDJ3q/4rbDDMHEm5Lte3FU8rknP6P /OttMfQSVOVL8K+zwE8iayrK+vDQ4shTIdJ5UbKtISdhqwPQEEcD4yYI0dG4uWvOjOmF OSaw== X-Gm-Message-State: AOAM530pRdqb3T5v2igniViBoFTOwUA1aRahE+MleQ+t0iTRJlDkH6zG XhhV5jMTWYW+zwBRBCgDCxeXMAC8tzPGSQ== X-Google-Smtp-Source: ABdhPJygiuj/SbiUV51+I+P7eCz8BOpxFq4/DVkBELvAaCoT78GJJ0M7bAHNCpj3WO2u5n4ooeum7w== X-Received: by 2002:a17:90b:209:: with SMTP id fy9mr1599851pjb.189.1600907551608; Wed, 23 Sep 2020 17:32:31 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:30 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 15/19] drm/virtio: implement blob resources: refactor UUID code somewhat Date: Wed, 23 Sep 2020 17:32:10 -0700 Message-Id: <20200924003214.662-15-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" For upcoming blob resources, userspace can specify that the resource will be used for cross-device sharing. This is mainly for exportable blobs that will only shared with the virtgpu display but not across devices. Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso --- drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++ drivers/gpu/drm/virtio/virtgpu_prime.c | 42 ++++++++++++++++++-------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index e1143a00017c5..bbbe28f8b9436 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -432,6 +432,8 @@ bool virtio_gpu_is_shmem(struct virtio_gpu_object *bo); int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev, uint32_t *resid); /* virtgpu_prime.c */ +int virtio_gpu_resource_assign_uuid(struct virtio_gpu_device *vgdev, + struct virtio_gpu_object *bo); struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj, int flags); struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev, diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c index 3552db128ba3d..1ef1e2f226333 100644 --- a/drivers/gpu/drm/virtio/virtgpu_prime.c +++ b/drivers/gpu/drm/virtio/virtgpu_prime.c @@ -59,6 +59,24 @@ const struct virtio_dma_buf_ops virtgpu_dmabuf_ops = { .get_uuid = virtgpu_virtio_get_uuid, }; +int virtio_gpu_resource_assign_uuid(struct virtio_gpu_device *vgdev, + struct virtio_gpu_object *bo) +{ + int ret; + struct virtio_gpu_object_array *objs; + + objs = virtio_gpu_array_alloc(1); + if (!objs) + return -ENOMEM; + + virtio_gpu_array_add_obj(objs, &bo->base.base); + ret = virtio_gpu_cmd_resource_assign_uuid(vgdev, objs); + if (ret) + return ret; + + return 0; +} + struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj, int flags) { @@ -66,22 +84,20 @@ struct dma_buf *virtgpu_gem_prime_export(struct drm_gem_object *obj, struct drm_device *dev = obj->dev; struct virtio_gpu_device *vgdev = dev->dev_private; struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj); - struct virtio_gpu_object_array *objs; int ret = 0; + bool blob = bo->host3d_blob || bo->guest_blob; DEFINE_DMA_BUF_EXPORT_INFO(exp_info); - if (vgdev->has_resource_assign_uuid) { - objs = virtio_gpu_array_alloc(1); - if (!objs) - return ERR_PTR(-ENOMEM); - virtio_gpu_array_add_obj(objs, &bo->base.base); - - ret = virtio_gpu_cmd_resource_assign_uuid(vgdev, objs); - if (ret) - return ERR_PTR(ret); - virtio_gpu_notify(vgdev); - } else { - bo->uuid_state = STATE_ERR; + if (!blob) { + if (vgdev->has_resource_assign_uuid) { + ret = virtio_gpu_resource_assign_uuid(vgdev, bo); + if (ret) + return ERR_PTR(ret); + + virtio_gpu_notify(vgdev); + } else { + bo->uuid_state = STATE_ERR; + } } exp_info.ops = &virtgpu_dmabuf_ops.ops; From patchwork Thu Sep 24 00:32:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795845 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 D048A6CB for ; Thu, 24 Sep 2020 00:32:44 +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 992772176B for ; Thu, 24 Sep 2020 00:32:44 +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="FR0ko5QZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 992772176B 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 5236B6EA25; Thu, 24 Sep 2020 00:32:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by gabe.freedesktop.org (Postfix) with ESMTPS id 22A686EA1F for ; Thu, 24 Sep 2020 00:32:33 +0000 (UTC) Received: by mail-pl1-x644.google.com with SMTP id r19so686928pls.1 for ; Wed, 23 Sep 2020 17:32:33 -0700 (PDT) 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=OhCNiGI9NYjEwyuNbdCt8zktPQl+shbeSod2slXCdug=; b=FR0ko5QZLAoc8fbTZ9kx4ML56hXLjfl/CvISyxBkKhyWntg0aLsG5wiPwfEHvCpgjN yWZXDZ+mqwDpFjEbuV6KwYi7EXnvGE7zUtzGbqMH92956nIXw0StK7yjnJIhejRyWGDP UFjd7ZBECnOTT2pJ+Si8ByhxS08zhtKhVCOWs= 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=OhCNiGI9NYjEwyuNbdCt8zktPQl+shbeSod2slXCdug=; b=tq3CNoZmQcgmzVUGnBNiJkLrOunCchdcl+5LZBZP1UJ7PnG/21pPbluFqW7KjEMCgI KCRcGOt3Y73Cd2saf4irB06uanL0fqKxztZI5qeXgKU6uFfMso/odanZKV6lKcGPqUoR 2fQF52laGs/c5TvIbzAvgx4LSFsDd7UjGWdwnRxXZfUI9JX3qd2bf8P0/b6VEPX3A/qw 5tsdyDbr+jQ9LhjxAQE1jM7K2xcSYHA5kzA9Cxtk4qXW3oAlphcv/6zbdpo998X5jwq8 U9cb7uu8iFKupX17EhPXkiOOpz/3x3xTWTFUBfm291naekMgNlI767WZV6xdOEPvFRDH MbdQ== X-Gm-Message-State: AOAM531HjhjIyXS81613OHOCMqhRASz8XkHoSDSizzVQBtD6q1kCeRre WaWKDBzF/1BX8wLgad+5Mi7d56SulB6mzA== X-Google-Smtp-Source: ABdhPJwU2iOqQ/Iqq5lPf6P6ViUfUO+I8Jvx4sii94VoxhsCHle9MfKaMVpA+xaCEJ7BUDOpgmzWbQ== X-Received: by 2002:a17:90b:d8f:: with SMTP id bg15mr1640400pjb.90.1600907552514; Wed, 23 Sep 2020 17:32:32 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:31 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 16/19] drm/virtio: implement blob resources: fix stride discrepancy Date: Wed, 23 Sep 2020 17:32:11 -0700 Message-Id: <20200924003214.662-16-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The old transfer ioctls may work on blob resources, and there is no TRANSFER_BLOB hypercall now for simplicity. The guest may have a image view on the blob resources such that the stride is not equal to width * bytes_per_pixel. For host-only blobs, we can repurpose the transfer ioctls to synchronize caches as well. For guest-only blobs, these operations are undefined for now so leave them out. Also, with seamless Wayland integration between guest/host looking increasingly attractive, it also makes sense to keep track of one value for stride. Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso --- drivers/gpu/drm/virtio/virtgpu_drv.h | 4 +++ drivers/gpu/drm/virtio/virtgpu_ioctl.c | 35 +++++++++++++++++++++++--- drivers/gpu/drm/virtio/virtgpu_vq.c | 14 +++++++++-- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index bbbe28f8b9436..ad16cef9a39b8 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -351,12 +351,16 @@ void virtio_gpu_cmd_submit(struct virtio_gpu_device *vgdev, void virtio_gpu_cmd_transfer_from_host_3d(struct virtio_gpu_device *vgdev, uint32_t ctx_id, uint64_t offset, uint32_t level, + uint32_t stride, + uint32_t layer_stride, struct drm_virtgpu_3d_box *box, struct virtio_gpu_object_array *objs, struct virtio_gpu_fence *fence); void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev, uint32_t ctx_id, uint64_t offset, uint32_t level, + uint32_t stride, + uint32_t layer_stride, struct drm_virtgpu_3d_box *box, struct virtio_gpu_object_array *objs, struct virtio_gpu_fence *fence); diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index c8da7adc6b307..0bf789f2bfdec 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -312,6 +312,7 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev, struct virtio_gpu_device *vgdev = dev->dev_private; struct virtio_gpu_fpriv *vfpriv = file->driver_priv; struct drm_virtgpu_3d_transfer_from_host *args = data; + struct virtio_gpu_object *bo; struct virtio_gpu_object_array *objs; struct virtio_gpu_fence *fence; int ret; @@ -325,6 +326,17 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev, if (objs == NULL) return -ENOENT; + bo = gem_to_virtio_gpu_obj(objs->objs[0]); + if (bo->guest_blob && !bo->host3d_blob) { + ret = -EINVAL; + goto err_put_free; + } + + if (!bo->host3d_blob && (args->stride || args->layer_stride)) { + ret = -EINVAL; + goto err_put_free; + } + ret = virtio_gpu_array_lock_resv(objs); if (ret != 0) goto err_put_free; @@ -334,9 +346,10 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev, ret = -ENOMEM; goto err_unlock; } + virtio_gpu_cmd_transfer_from_host_3d - (vgdev, vfpriv->ctx_id, offset, args->level, - &args->box, objs, fence); + (vgdev, vfpriv->ctx_id, offset, args->level, args->stride, + args->layer_stride, &args->box, objs, fence); dma_fence_put(&fence->f); virtio_gpu_notify(vgdev); return 0; @@ -354,6 +367,7 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data, struct virtio_gpu_device *vgdev = dev->dev_private; struct virtio_gpu_fpriv *vfpriv = file->driver_priv; struct drm_virtgpu_3d_transfer_to_host *args = data; + struct virtio_gpu_object *bo; struct virtio_gpu_object_array *objs; struct virtio_gpu_fence *fence; int ret; @@ -363,6 +377,12 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data, if (objs == NULL) return -ENOENT; + bo = gem_to_virtio_gpu_obj(objs->objs[0]); + if (bo->guest_blob && !bo->host3d_blob) { + ret = -EINVAL; + goto err_put_free; + } + if (!vgdev->has_virgl_3d) { virtio_gpu_cmd_transfer_to_host_2d (vgdev, offset, @@ -370,6 +390,12 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data, objs, NULL); } else { virtio_gpu_create_context(dev, file); + + if (!bo->host3d_blob && (args->stride || args->layer_stride)) { + ret = -EINVAL; + goto err_put_free; + } + ret = virtio_gpu_array_lock_resv(objs); if (ret != 0) goto err_put_free; @@ -381,8 +407,9 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data, virtio_gpu_cmd_transfer_to_host_3d (vgdev, - vfpriv ? vfpriv->ctx_id : 0, offset, - args->level, &args->box, objs, fence); + vfpriv ? vfpriv->ctx_id : 0, offset, args->level, + args->stride, args->layer_stride, &args->box, objs, + fence); dma_fence_put(&fence->f); } virtio_gpu_notify(vgdev); diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index e71c8eec0b914..6434b9fb38a65 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -1017,6 +1017,8 @@ virtio_gpu_cmd_resource_create_3d(struct virtio_gpu_device *vgdev, void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev, uint32_t ctx_id, uint64_t offset, uint32_t level, + uint32_t stride, + uint32_t layer_stride, struct drm_virtgpu_3d_box *box, struct virtio_gpu_object_array *objs, struct virtio_gpu_fence *fence) @@ -1025,12 +1027,14 @@ void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev, struct virtio_gpu_transfer_host_3d *cmd_p; struct virtio_gpu_vbuffer *vbuf; bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev); - struct virtio_gpu_object_shmem *shmem = to_virtio_gpu_shmem(bo); - if (use_dma_api) + if (virtio_gpu_is_shmem(bo) && use_dma_api) { + struct virtio_gpu_object_shmem *shmem = to_virtio_gpu_shmem(bo); + dma_sync_sg_for_device(vgdev->vdev->dev.parent, shmem->pages->sgl, shmem->pages->nents, DMA_TO_DEVICE); + } cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p)); memset(cmd_p, 0, sizeof(*cmd_p)); @@ -1043,6 +1047,8 @@ void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev, convert_to_hw_box(&cmd_p->box, box); cmd_p->offset = cpu_to_le64(offset); cmd_p->level = cpu_to_le32(level); + cmd_p->stride = cpu_to_le32(stride); + cmd_p->layer_stride = cpu_to_le32(layer_stride); virtio_gpu_queue_fenced_ctrl_buffer(vgdev, vbuf, fence); } @@ -1050,6 +1056,8 @@ void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev, void virtio_gpu_cmd_transfer_from_host_3d(struct virtio_gpu_device *vgdev, uint32_t ctx_id, uint64_t offset, uint32_t level, + uint32_t stride, + uint32_t layer_stride, struct drm_virtgpu_3d_box *box, struct virtio_gpu_object_array *objs, struct virtio_gpu_fence *fence) @@ -1069,6 +1077,8 @@ void virtio_gpu_cmd_transfer_from_host_3d(struct virtio_gpu_device *vgdev, convert_to_hw_box(&cmd_p->box, box); cmd_p->offset = cpu_to_le64(offset); cmd_p->level = cpu_to_le32(level); + cmd_p->stride = cpu_to_le32(stride); + cmd_p->layer_stride = cpu_to_le32(layer_stride); virtio_gpu_queue_fenced_ctrl_buffer(vgdev, vbuf, fence); } From patchwork Thu Sep 24 00:32:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795855 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 B669D6CA for ; Thu, 24 Sep 2020 00:32:50 +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 8AAD72176B for ; Thu, 24 Sep 2020 00:32:50 +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="SD5l2Sue" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8AAD72176B 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 A0D9E6EA26; Thu, 24 Sep 2020 00:32:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id 452B46EA24 for ; Thu, 24 Sep 2020 00:32:34 +0000 (UTC) Received: by mail-pf1-x444.google.com with SMTP id d9so761392pfd.3 for ; Wed, 23 Sep 2020 17:32:34 -0700 (PDT) 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=inq5VPAbGj55lVsEfqOots0UsyGc9IzMu7tBnt2vhjs=; b=SD5l2SueYF2dya0c8P5SH/msAUiz3HNEkTxjZgoSVFFm2/Z9PFJRvioIzWzU1OSw0D dlIAA63y0/OtgUDGn1QRm2zs0LoGRrn9W1in4C7ZeDMujVyWfbkCMy+qImJsL6wbtygx 5XBuJNM49usbAQAOsWNAgqdx6UD1ygqItiW34= 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=inq5VPAbGj55lVsEfqOots0UsyGc9IzMu7tBnt2vhjs=; b=NdZIxide5nhU3THlHnQUcGxfcwI3xuRGD1Enj+I+AI20qag4ichKNaz9sVwRofLDMd e/zYBpTloQrd6mUroJVa3uTO3Ql+ZUS9Ol860lZqCjGw2Xz9ZPmu2yNI+stC/JMC/rtM 1Al+LLPkhlSI21i6EAlv3FFSVCGhtXLh/Rz0tGSowKIUqHDcTd4u42EZP35Pxhwd3Fb5 Y5Taa2zpk4p6YyCjYagCN91SR90tn7K07FaHyk8xC9kyUQq+1WN6Lq6T6PH8sSvICUYI rCGts/dDSU5WsEFTM9iCiVqizeYELgg1nztzBr1m+lZ541mTobCeXqyjSD3Yqc1edbnU V5pg== X-Gm-Message-State: AOAM5311qbsw2/93BqYVYUyobrrwInjSVDdc2tr6bi4DxZhxTwms6esu vmWj0xn310g8/H+BuI6r3ApvC1w58QKWNA== X-Google-Smtp-Source: ABdhPJxKhEfZSeocV9so28xsUmX5ApZsLGhQtfYLSC8chXRa4h3d9UdLjJ/IPqbV2N1viARzZHB0tA== X-Received: by 2002:a63:2547:: with SMTP id l68mr1790275pgl.241.1600907553659; Wed, 23 Sep 2020 17:32:33 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:32 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 17/19] drm/virtio: implement blob resources: report blob mem to userspace Date: Wed, 23 Sep 2020 17:32:12 -0700 Message-Id: <20200924003214.662-17-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The stride field has never been used, so repurpose it to be "blob_mem". This way, userspace can know the memory properties of the blob if it's passed between userspace processes and no suitable userspace API exists to transmit that knowledge. Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso --- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index 0bf789f2bfdec..b0c9dd171ad8a 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -301,6 +301,9 @@ static int virtio_gpu_resource_info_ioctl(struct drm_device *dev, void *data, ri->size = qobj->base.base.size; ri->res_handle = qobj->hw_res_handle; + if (qobj->host3d_blob || qobj->guest_blob) + ri->blob_mem = qobj->blob_mem; + drm_gem_object_put(gobj); return 0; } From patchwork Thu Sep 24 00:32:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795857 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 D6D526CB for ; Thu, 24 Sep 2020 00:32:51 +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 A4DBF2176B for ; Thu, 24 Sep 2020 00:32:51 +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="W5jCBw7t" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4DBF2176B 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 28EFA6EA2A; Thu, 24 Sep 2020 00:32:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6CD756EA1F for ; Thu, 24 Sep 2020 00:32:35 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id f18so736700pfa.10 for ; Wed, 23 Sep 2020 17:32:35 -0700 (PDT) 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=ov+uNTFyykfN8s/Ihlj9Oe3dnyFVG8aGLcJ922NpizE=; b=W5jCBw7t0MLz6v+Cnzz1o3TPNyBVDTUM0k4z1UFDYwJub85z6S6xwPe04fpspUFjc0 BfvG8+Ppq8ulANNrgEr5zXhQcMFRIWC1CzDk7cTYxx3hIcD+UZ2KayB8CLKSHgLJcbeg S4/d8etNPVTQE0HEvPtikVhBO/KQtthfjyvLY= 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=ov+uNTFyykfN8s/Ihlj9Oe3dnyFVG8aGLcJ922NpizE=; b=nH4oMKjQ4BOeM/1Th/vv7fOpPEmYW5t9liQsSUXT+CJElHkjpj6oLZhT7pDX/A8HdZ QNt19OaoX+NofzsR/pKk1e74mD9X0I2GUrvP8CrDgbY6YEPWM+FOBvQQDAbyHkydF2lZ kUGKCZBghjElSwnnmiFLSl7LeVijEgGVS/UNP9B9NN8qF+3aARk751OMMYin3jjetxqG oPeidmaTKmvA23/t0leKKUc7xdg0W/7xxVoXMKknxKpe7or8NCgPd/2iC/KSzdjnMigh uD5VvKS/7HmZ0OuVeATS9WAB5RdPNLcXtyxmiXXKN43WvPY+P0b+Dz/LvaDzEAs5/OJf lApw== X-Gm-Message-State: AOAM532nEflKTkjGy7cR1g4NXCMxY6dlOb7khg9n3ZPCTih9Z5h2A9Yi EuJc+NPowcHyM5sZzPedJAcSmL2TXnwb+g== X-Google-Smtp-Source: ABdhPJyiRndd4/3/dxgE0ZQWIpIui+Zj408+i+bfYkXopbUCJyqSHLJDmvXJHaSZ9yKRrg6DtqWu4w== X-Received: by 2002:a65:4641:: with SMTP id k1mr1819662pgr.133.1600907554619; Wed, 23 Sep 2020 17:32:34 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:34 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 18/19] drm/virtio: implement blob resources: resource create blob ioctl Date: Wed, 23 Sep 2020 17:32:13 -0700 Message-Id: <20200924003214.662-18-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Gerd Hoffmann Implement resource create blob as specified. Signed-off-by: Gerd Hoffmann Co-developed-by: Gurchetan Singh Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso --- drivers/gpu/drm/virtio/virtgpu_drv.h | 4 +- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 136 ++++++++++++++++++++++++ drivers/gpu/drm/virtio/virtgpu_object.c | 5 +- drivers/gpu/drm/virtio/virtgpu_vram.c | 2 + 4 files changed, 144 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index ad16cef9a39b8..3c0e17212c336 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -257,8 +257,8 @@ struct virtio_gpu_fpriv { struct mutex context_lock; }; -/* virtgpu_ioctl.c */ -#define DRM_VIRTIO_NUM_IOCTLS 10 +/* virtio_ioctl.c */ +#define DRM_VIRTIO_NUM_IOCTLS 11 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); diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index b0c9dd171ad8a..3ede098c1d280 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -34,6 +34,10 @@ #include "virtgpu_drv.h" +#define VIRTGPU_BLOB_FLAG_USE_MASK (VIRTGPU_BLOB_FLAG_USE_MAPPABLE | \ + VIRTGPU_BLOB_FLAG_USE_SHAREABLE | \ + VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE) + void virtio_gpu_create_context(struct drm_device *dev, struct drm_file *file) { struct virtio_gpu_device *vgdev = dev->dev_private; @@ -521,6 +525,134 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev, return 0; } +static int verify_blob(struct virtio_gpu_device *vgdev, + struct virtio_gpu_fpriv *vfpriv, + struct virtio_gpu_object_params *params, + struct drm_virtgpu_resource_create_blob *rc_blob, + bool *guest_blob, bool *host3d_blob) +{ + if (!vgdev->has_resource_blob) + return -EINVAL; + + if ((rc_blob->blob_flags & ~VIRTGPU_BLOB_FLAG_USE_MASK) || + !rc_blob->blob_flags) + return -EINVAL; + + if (rc_blob->blob_flags & VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE) { + if (!vgdev->has_resource_assign_uuid) + return -EINVAL; + } + + switch (rc_blob->blob_mem) { + case VIRTGPU_BLOB_MEM_GUEST: + *guest_blob = true; + break; + case VIRTGPU_BLOB_MEM_HOST3D_GUEST: + *guest_blob = true; + fallthrough; + case VIRTGPU_BLOB_MEM_HOST3D: + *host3d_blob = true; + break; + default: + return -EINVAL; + } + + if (*host3d_blob) { + if (!vgdev->has_virgl_3d) + return -EINVAL; + + /* Must be dword aligned. */ + if (rc_blob->cmd_size % 4 != 0) + return -EINVAL; + + params->ctx_id = vfpriv->ctx_id; + params->blob_id = rc_blob->blob_id; + } else { + if (rc_blob->blob_id != 0) + return -EINVAL; + + if (rc_blob->cmd_size != 0) + return -EINVAL; + } + + params->blob_mem = rc_blob->blob_mem; + params->size = rc_blob->size; + params->blob = true; + params->blob_flags = rc_blob->blob_flags; + return 0; +} + +static int virtio_gpu_resource_create_blob(struct drm_device *dev, + void *data, struct drm_file *file) +{ + int ret = 0; + uint32_t handle = 0; + bool guest_blob = false; + bool host3d_blob = false; + struct drm_gem_object *obj; + struct virtio_gpu_object *bo; + struct virtio_gpu_object_params params = { 0 }; + struct virtio_gpu_device *vgdev = dev->dev_private; + struct virtio_gpu_fpriv *vfpriv = file->driver_priv; + struct drm_virtgpu_resource_create_blob *rc_blob = data; + + if (verify_blob(vgdev, vfpriv, ¶ms, rc_blob, + &guest_blob, &host3d_blob)) + return -EINVAL; + + if (vgdev->has_virgl_3d) + virtio_gpu_create_context(dev, file); + + if (rc_blob->cmd_size) { + void *buf; + + buf = memdup_user(u64_to_user_ptr(rc_blob->cmd), + rc_blob->cmd_size); + + if (IS_ERR(buf)) + return PTR_ERR(buf); + + virtio_gpu_cmd_submit(vgdev, buf, rc_blob->cmd_size, + vfpriv->ctx_id, NULL, NULL); + } + + if (guest_blob) + ret = virtio_gpu_object_create(vgdev, ¶ms, &bo, NULL); + else if (!guest_blob && host3d_blob) + ret = virtio_gpu_vram_create(vgdev, ¶ms, &bo); + else + return -EINVAL; + + if (ret < 0) + return ret; + + bo->guest_blob = guest_blob; + bo->host3d_blob = host3d_blob; + bo->blob_mem = rc_blob->blob_mem; + bo->blob_flags = rc_blob->blob_flags; + + obj = &bo->base.base; + if (params.blob_flags & VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE) { + ret = virtio_gpu_resource_assign_uuid(vgdev, bo); + if (ret) { + drm_gem_object_release(obj); + return ret; + } + } + + ret = drm_gem_handle_create(file, obj, &handle); + if (ret) { + drm_gem_object_release(obj); + return ret; + } + drm_gem_object_put(obj); + + rc_blob->res_handle = bo->hw_res_handle; + rc_blob->bo_handle = handle; + + return 0; +} + struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS] = { DRM_IOCTL_DEF_DRV(VIRTGPU_MAP, virtio_gpu_map_ioctl, DRM_RENDER_ALLOW), @@ -553,4 +685,8 @@ struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS] = { DRM_IOCTL_DEF_DRV(VIRTGPU_GET_CAPS, virtio_gpu_get_caps_ioctl, DRM_RENDER_ALLOW), + + DRM_IOCTL_DEF_DRV(VIRTGPU_RESOURCE_CREATE_BLOB, + virtio_gpu_resource_create_blob, + DRM_RENDER_ALLOW), }; diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c index 099f10313815a..82250daae5ebd 100644 --- a/drivers/gpu/drm/virtio/virtgpu_object.c +++ b/drivers/gpu/drm/virtio/virtgpu_object.c @@ -245,7 +245,10 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, return ret; } - if (params->virgl) { + if (params->blob) { + virtio_gpu_cmd_resource_create_blob(vgdev, bo, params, + ents, nents); + } else if (params->virgl) { virtio_gpu_cmd_resource_create_3d(vgdev, bo, params, objs, fence); virtio_gpu_object_attach(vgdev, bo, ents, nents); diff --git a/drivers/gpu/drm/virtio/virtgpu_vram.c b/drivers/gpu/drm/virtio/virtgpu_vram.c index 087945fcd230f..23c21bc4d01e2 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vram.c +++ b/drivers/gpu/drm/virtio/virtgpu_vram.c @@ -149,6 +149,8 @@ int virtio_gpu_vram_create(struct virtio_gpu_device *vgdev, return ret; } + virtio_gpu_cmd_resource_create_blob(vgdev, &vram->base, params, NULL, + 0); if (params->blob_flags & VIRTGPU_BLOB_FLAG_USE_MAPPABLE) { ret = virtio_gpu_vram_map(&vram->base); if (ret) { From patchwork Thu Sep 24 00:32:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 11795853 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 A0AEF6CB for ; Thu, 24 Sep 2020 00:32:49 +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 70FE82145D for ; Thu, 24 Sep 2020 00:32:49 +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="VAEDJWEq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70FE82145D 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 0D7BE6EA29; Thu, 24 Sep 2020 00:32:40 +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 6F4636EA1F for ; Thu, 24 Sep 2020 00:32:36 +0000 (UTC) Received: by mail-pg1-x544.google.com with SMTP id y1so771465pgk.8 for ; Wed, 23 Sep 2020 17:32:36 -0700 (PDT) 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=N6EdaR9KwU+pnvkycYJPPLNu+q7R7PLRGVA6ARzb1Q8=; b=VAEDJWEq0ipDK1qzu7evsiwzHq+7Z3oMnJ3AwGZTYjOWtk1G6hqfTpLvdMlhS18ZcB ug5naX1mw5GzwibHMrMDkTVvDT9jMpINw8VGeQKeUzyVWizO83cTZ8mdlGTVJkGGpijA 2uFb3E1Xl4W1NNsd8xdGdryAs5/ACzXKZ8KDw= 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=N6EdaR9KwU+pnvkycYJPPLNu+q7R7PLRGVA6ARzb1Q8=; b=F8KEZn6/6iZLn/6VLyMgu395zL0SwZBk7+DUX5nRPnJRtr5Y3AV5o8CvkSynci2Ib7 p3SEkRqYL2FJDGcSVryxyRNbcYH1rC33vvv5l9iCFTJvMEbtHw1oDhbH2DXHMFLCsf46 UFqzRxpb1X7/M8mulz7GucIGzIAWVbl7rKaenFfJquFduhRkOXxRBaHthUQTu47mM6h8 kR3wjJhXSYS50zWVcorADiePm3BzU71g7VDQ5pPdUsl1eBzK7DSgjzvWUb8yy0XdiaCn OmSjM2f6ECHXlaM5ttQGRP9W0OUUyr7T+KufWw+FAF/GbNrz3aynA0FYoIoeyEdxXMm0 4Keg== X-Gm-Message-State: AOAM531QlCava5p/0i6rqKcD2NP911GegCcp8kK8Sx1vwvLMl497wiF6 0NwqNLmMskNcaVjLwdEFdFrjvxY0TKeI3w== X-Google-Smtp-Source: ABdhPJzb29Ufrs6bmTmK/NBK0WyydsWT5zfdV5zcILSL4Pg4i0dPPofQDkQ/kSLIOBftJEBg9pp7jg== X-Received: by 2002:a63:eb4c:: with SMTP id b12mr1836592pgk.266.1600907555769; Wed, 23 Sep 2020 17:32:35 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id 64sm735312pfd.7.2020.09.23.17.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 17:32:35 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 19/19] drm/virtio: advertise features to userspace Date: Wed, 23 Sep 2020 17:32:14 -0700 Message-Id: <20200924003214.662-19-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200924003214.662-1-gurchetansingh@chromium.org> References: <20200924003214.662-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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" New api changes are now available to userspace. Also, the comparison to true is redundant, so remove it. Signed-off-by: Gurchetan Singh Acked-by: Tomeu Vizoso --- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index 3ede098c1d280..5417f365d1a39 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -212,11 +212,20 @@ static int virtio_gpu_getparam_ioctl(struct drm_device *dev, void *data, switch (param->param) { case VIRTGPU_PARAM_3D_FEATURES: - value = vgdev->has_virgl_3d == true ? 1 : 0; + value = vgdev->has_virgl_3d ? 1 : 0; break; case VIRTGPU_PARAM_CAPSET_QUERY_FIX: value = 1; break; + case VIRTGPU_PARAM_RESOURCE_BLOB: + value = vgdev->has_resource_blob ? 1 : 0; + break; + case VIRTGPU_PARAM_HOST_VISIBLE: + value = vgdev->has_host_visible ? 1 : 0; + break; + case VIRTGPU_PARAM_CROSS_DEVICE: + value = vgdev->has_resource_assign_uuid ? 1 : 0; + break; default: return -EINVAL; }