From patchwork Mon Apr 29 22:08:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chia-I Wu X-Patchwork-Id: 10922555 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1AAF81390 for ; Mon, 29 Apr 2019 22:08:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08D2E289EA for ; Mon, 29 Apr 2019 22:08:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0DA5289ED; Mon, 29 Apr 2019 22:08:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8C4C2289EA for ; Mon, 29 Apr 2019 22:08:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 259D9892E4; Mon, 29 Apr 2019 22:08:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by gabe.freedesktop.org (Postfix) with ESMTPS id 15852892E4 for ; Mon, 29 Apr 2019 22:08:29 +0000 (UTC) Received: by mail-pg1-x543.google.com with SMTP id t22so2811680pgi.10 for ; Mon, 29 Apr 2019 15:08:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=neudzHMjG+trVVVGpjV7l9fWvO6StovsfoKxdSU/ZIA=; b=AWROIKbWyc/45g3jZvRmQ3Otr9vyWxDqWjESTprBAmW9ctuAApY549KXp1D3F7hRdn 7k3uwKG7fNAwvGVgeQA+NTRtXVTuOCCYvAjh5EeOsLtlYSN9qNP0OngpLj+iq1V4l/eE iKK4+94jBXqaNZqce0cKvV0/elQQ6zYSQVoBOWxoCMxBmxlQqXTLgqgNc7Ttw1ppJxTx EiBmft+KHWUDupemlCP6b+snw5Y0w9Y8MT70HnKy1EAR8bK0n93v4TS7iLAPpFtnyBoa VfjfeH4kMKKKBOR9QndM043e7IHOq93ugUB943gKppULHWwPjJ3W8MYD3f2HBDOUdLFf IZGA== X-Gm-Message-State: APjAAAXLPKeC/SvYQnt/t6H1kuBYRr+yX2UTaImCLJLLfLMJ2EGjTG9W RpkvuB8kSGBQSj35JcaEUzUfXr1b X-Google-Smtp-Source: APXvYqzbmnrjBmExhJ3it6/PaKTv8B/fYuVhR6UQOeIjQCeR9sWjd3dhQpfWgu915YZNl9vHK4DrUA== X-Received: by 2002:a65:4907:: with SMTP id p7mr12744067pgs.288.1556575708070; Mon, 29 Apr 2019 15:08:28 -0700 (PDT) Received: from olv0.mtv.corp.google.com ([2620:15c:202:201:9649:82d6:f889:b307]) by smtp.gmail.com with ESMTPSA id g3sm14828635pfm.167.2019.04.29.15.08.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Apr 2019 15:08:27 -0700 (PDT) From: Chia-I Wu To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/3] drm/virtio: set seqno for dma-fence Date: Mon, 29 Apr 2019 15:08:23 -0700 Message-Id: <20190429220825.156644-1-olvaffe@gmail.com> X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=neudzHMjG+trVVVGpjV7l9fWvO6StovsfoKxdSU/ZIA=; b=EAG9jofuxrKzhgGJAiMmQYJxKdNBHe+HxBCZAFLhQmKo2VKtiX9sMaudaEVVUuJbU0 cGC7Ab55v91eh/WpQXQP/QMKb4uO+dR/NWLibN1iZeQHgLKuHp+jFGKw9ggyJk5rUXMe I83gbSA0b3tt2c+6a/Ok29TWlIPt3Gr911IW7DOgI6+ojW9S9+BMiDFHoPvAWqkevuBw gQIWN2Pjh1IFtY3GfpjnZ4beEaLbQNpzWsokrpIqyqlDkF4XZzfVFEo5KDfi9tmG8L8j unJgJUJrQ2Z5usush4n5xFDE8FdYnIFan5DIACzR3fJHm1mF6qCFcZZW9jQmVjYVb1uH 5Jsg== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This is motivated by having meaningful ftrace events, but it also fixes use cases where dma_fence_is_later is called, such as in sync_file_merge. In other drivers, fence creation and cmdbuf submission normally happen atomically, mutex_lock(); fence = dma_fence_create(..., ++timeline->seqno); submit_cmdbuf(); mutex_unlock(); and have no such issue. But in our driver, because most ioctls queue commands into ctrlq, we do not want to grab a lock. Instead, we set seqno to 0 when a fence is created, and update it when the command is finally queued and the seqno is known. Signed-off-by: Chia-I Wu Reviewed-by: Emil Velikov --- drivers/gpu/drm/virtio/virtgpu_drv.h | 1 - drivers/gpu/drm/virtio/virtgpu_fence.c | 17 ++++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index 491dec0712b3..90461feeafdb 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -102,7 +102,6 @@ struct virtio_gpu_fence { struct dma_fence f; struct virtio_gpu_fence_driver *drv; struct list_head node; - uint64_t seq; }; #define to_virtio_fence(x) \ container_of(x, struct virtio_gpu_fence, f) diff --git a/drivers/gpu/drm/virtio/virtgpu_fence.c b/drivers/gpu/drm/virtio/virtgpu_fence.c index 87d1966192f4..72b4f7561432 100644 --- a/drivers/gpu/drm/virtio/virtgpu_fence.c +++ b/drivers/gpu/drm/virtio/virtgpu_fence.c @@ -40,16 +40,14 @@ bool virtio_fence_signaled(struct dma_fence *f) { struct virtio_gpu_fence *fence = to_virtio_fence(f); - if (atomic64_read(&fence->drv->last_seq) >= fence->seq) + if (atomic64_read(&fence->drv->last_seq) >= fence->f.seqno) return true; return false; } static void virtio_fence_value_str(struct dma_fence *f, char *str, int size) { - struct virtio_gpu_fence *fence = to_virtio_fence(f); - - snprintf(str, size, "%llu", fence->seq); + snprintf(str, size, "%llu", f->seqno); } static void virtio_timeline_value_str(struct dma_fence *f, char *str, int size) @@ -76,6 +74,11 @@ struct virtio_gpu_fence *virtio_gpu_fence_alloc(struct virtio_gpu_device *vgdev) return fence; fence->drv = drv; + + /* This only partially initializes the fence because the seqno is + * unknown yet. The fence must not be used outside of the driver + * until virtio_gpu_fence_emit is called. + */ dma_fence_init(&fence->f, &virtio_fence_ops, &drv->lock, drv->context, 0); return fence; @@ -89,13 +92,13 @@ int virtio_gpu_fence_emit(struct virtio_gpu_device *vgdev, unsigned long irq_flags; spin_lock_irqsave(&drv->lock, irq_flags); - fence->seq = ++drv->sync_seq; + fence->f.seqno = ++drv->sync_seq; dma_fence_get(&fence->f); list_add_tail(&fence->node, &drv->fences); spin_unlock_irqrestore(&drv->lock, irq_flags); cmd_hdr->flags |= cpu_to_le32(VIRTIO_GPU_FLAG_FENCE); - cmd_hdr->fence_id = cpu_to_le64(fence->seq); + cmd_hdr->fence_id = cpu_to_le64(fence->f.seqno); return 0; } @@ -109,7 +112,7 @@ void virtio_gpu_fence_event_process(struct virtio_gpu_device *vgdev, spin_lock_irqsave(&drv->lock, irq_flags); atomic64_set(&vgdev->fence_drv.last_seq, last_seq); list_for_each_entry_safe(fence, tmp, &drv->fences, node) { - if (last_seq < fence->seq) + if (last_seq < fence->f.seqno) continue; dma_fence_signal_locked(&fence->f); list_del(&fence->node); From patchwork Mon Apr 29 22:08:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chia-I Wu X-Patchwork-Id: 10922559 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60D681390 for ; Mon, 29 Apr 2019 22:08:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 503C3289EF for ; Mon, 29 Apr 2019 22:08:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 451D7289F3; Mon, 29 Apr 2019 22:08:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0E0AF289EF for ; Mon, 29 Apr 2019 22:08:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3C4768934F; Mon, 29 Apr 2019 22:08: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 81278892E4 for ; Mon, 29 Apr 2019 22:08:29 +0000 (UTC) Received: by mail-pl1-x641.google.com with SMTP id b3so5727848plr.7 for ; Mon, 29 Apr 2019 15:08:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DSXLhD7wHCaSgLKFWGmhSkyMj1YNvbI1NjkgvBf+Kws=; b=WT6H5IJqK7HrDEeb83NjHhArmxqDjJVoALSubzRqLTqyLzPlWNzN5+X3i73Kfa6zBQ pVG3uW7uNr772j1WrOroztVKWTEJ4v0pdtnVJ8PL19dc5OmelOUTxidytN25b2MpX0vj 6HWRJfYse3mfzqqXte0veoKwrcodKUiAqgyvZ9xNPxBkkHgh7MMXORYIZ1BVsr0az4yX G4/9SkmDiB11M75QRcvlBP6rrWyAqXILV9OuN//n7St6sKic/PAHc57LmYWwmFiun4RR XxxXAFQnCFKTmM/nLmsOKk+FyI7+Uza6NR8O7tinURKHwtxEUhRCBDm//Ekzd9NHU0+v n9dQ== X-Gm-Message-State: APjAAAWmYSWPuTgc/3VKTnv+5CgUS8W6kXKatLAAFAcbAOeeNqCQ0n9a /fPgOFMH37GpHAY6WgijPApfu5gp X-Google-Smtp-Source: APXvYqyy0lG7vVgK77wDJ8wX1L9TblWrlFg5ViAqpVt78Ksd3Y8r5fRZraYxR8/CUn4f5iJsq4AXwQ== X-Received: by 2002:a17:902:2cc1:: with SMTP id n59mr1834391plb.22.1556575708781; Mon, 29 Apr 2019 15:08:28 -0700 (PDT) Received: from olv0.mtv.corp.google.com ([2620:15c:202:201:9649:82d6:f889:b307]) by smtp.gmail.com with ESMTPSA id g3sm14828635pfm.167.2019.04.29.15.08.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Apr 2019 15:08:28 -0700 (PDT) From: Chia-I Wu To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/3] drm/virtio: trace drm_fence_emit Date: Mon, 29 Apr 2019 15:08:24 -0700 Message-Id: <20190429220825.156644-2-olvaffe@gmail.com> X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog In-Reply-To: <20190429220825.156644-1-olvaffe@gmail.com> References: <20190429220825.156644-1-olvaffe@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=DSXLhD7wHCaSgLKFWGmhSkyMj1YNvbI1NjkgvBf+Kws=; b=KjKueBg4FXrmLVN1N9isYalx6Up4cfpJx2Hgj6YyqLlwSk/w7J3DmFW64HSk88ueuS LRPJl1E3BP+D0MLJV0m6eCzVEp1Y1j5lUNCCXKy2Z4XzgFWLfXUe0Vcg6RElKyrW/AxU Y9o+pyc5u8/c3bZoCgabMVWvgiikDnvTTPe79QPlr+6Hfnf5kAVgcjHa4Z8LZ0v2JYSo LjS+Wo1/pepADGo9jaVTBd7WWbGJujO5jaysCkcL2XkwAJAmfQGjcLQ4rQiaa5Li9nce Tuv4ts/nJniA2jKquNTnt8DqKNKUGpkYikCYl/wgRbcGbITR5ftpbeYN+M+HdFifD/Aq Jb4g== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP For most drivers, drm_fence_init is followed by drm_fence_emit immediately. But for our driver, they are done separately. We also don't know the fence seqno until drm_fence_emit. Signed-off-by: Chia-I Wu --- drivers/gpu/drm/virtio/virtgpu_fence.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_fence.c b/drivers/gpu/drm/virtio/virtgpu_fence.c index 72b4f7561432..e22918ca621b 100644 --- a/drivers/gpu/drm/virtio/virtgpu_fence.c +++ b/drivers/gpu/drm/virtio/virtgpu_fence.c @@ -24,6 +24,7 @@ */ #include +#include #include "virtgpu_drv.h" static const char *virtio_get_driver_name(struct dma_fence *f) @@ -97,6 +98,8 @@ int virtio_gpu_fence_emit(struct virtio_gpu_device *vgdev, list_add_tail(&fence->node, &drv->fences); spin_unlock_irqrestore(&drv->lock, irq_flags); + trace_dma_fence_emit(&fence->f); + cmd_hdr->flags |= cpu_to_le32(VIRTIO_GPU_FLAG_FENCE); cmd_hdr->fence_id = cpu_to_le64(fence->f.seqno); return 0; From patchwork Mon Apr 29 22:08:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chia-I Wu X-Patchwork-Id: 10922557 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 96CDA1390 for ; Mon, 29 Apr 2019 22:08:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88468289EA for ; Mon, 29 Apr 2019 22:08:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CDA9289ED; Mon, 29 Apr 2019 22:08:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 16B24289EA for ; Mon, 29 Apr 2019 22:08:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CAFCC892ED; Mon, 29 Apr 2019 22:08:34 +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 32614892ED for ; Mon, 29 Apr 2019 22:08:30 +0000 (UTC) Received: by mail-pf1-x444.google.com with SMTP id g3so6015650pfi.4 for ; Mon, 29 Apr 2019 15:08:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8AprnTxHJB2MYoO0dd3odhl+asXG20VcbV+fWqZiTrY=; b=UroHRH8UlWLip0dFEld3FKMUaF8Lv9WxnOGcWaFkpOcd3VXimM2J5FgirR7sF2JPB+ KQT6MMO6QcTcMpOeeUzqWrimx4QWhqJuekypDbwDtNjGp32CeQxWiHrPGPIMV9MVOHZi EBTW3QV0CmhjHfRo2ebUf5ErrxLlvAnIaOmf/uMNnCeKt/0sDNkXsK3Yp93lEk6C4agQ erX4l+JYTvTMvINAs43XSW3O92BvW0OTb1STaOBfUgca80cC+uUVJz1syjMFaKXmLLE5 NrkrUs7IAU3f1tzDejDVGRbJQIIrGtur5NYx71DQhI3eCSPZM5x8Y5JfgHIjqcpoOe4c XPKQ== X-Gm-Message-State: APjAAAWy7YLqjPPdfUGI5foVK7ViNnzQvvLDT8jamU2NAkUVpz77VQld 2p7hQEN0sAfdLViL51+80KKHhQ+d X-Google-Smtp-Source: APXvYqyFQgsXhf8HHnZ0GCvV1uDZIKfbhmx+XnK14IkNplrZjqZU5UhJZtkaW+K8ufXcochTGS883g== X-Received: by 2002:a65:4c07:: with SMTP id u7mr9408368pgq.93.1556575709479; Mon, 29 Apr 2019 15:08:29 -0700 (PDT) Received: from olv0.mtv.corp.google.com ([2620:15c:202:201:9649:82d6:f889:b307]) by smtp.gmail.com with ESMTPSA id g3sm14828635pfm.167.2019.04.29.15.08.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Apr 2019 15:08:28 -0700 (PDT) From: Chia-I Wu To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/3] drm/virtio: add trace events for commands Date: Mon, 29 Apr 2019 15:08:25 -0700 Message-Id: <20190429220825.156644-3-olvaffe@gmail.com> X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog In-Reply-To: <20190429220825.156644-1-olvaffe@gmail.com> References: <20190429220825.156644-1-olvaffe@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=8AprnTxHJB2MYoO0dd3odhl+asXG20VcbV+fWqZiTrY=; b=Jqb9tqVFI2QXvX+wHZWW/NEnjtQ4XGMhqCLgd/QcELvT2xuEFd8RvouJW/PmaC+aze VmJ7NVBcmemgdESKVwJRXdzvnuungfbdE8le+dqZPC6u8m6zibXyOyUKJmB7+mHweDhy JCIHxIh22XzynwcTEF3xcsYVkytW36TGrxOOkrrEJt6vM2OSEYqynGxyM3cORz7eWvTf JTzgkEB9naAx5CHwqnNaVy9y8cdlHjrHohHRJl//uqCuejCmC2op3WtOEJEWUgG8GCPr X0q9nM+DiM+haL7fOjcS0jp5QteQS8BopPlItPRvA8p+4ciF1/ILhx/HeZW9AKdtIYzs 4MCQ== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Trace when commands are queued for both ctrlq and cursorq. Trace when responses are received for ctrlq. Signed-off-by: Chia-I Wu --- drivers/gpu/drm/virtio/Makefile | 2 +- drivers/gpu/drm/virtio/virtgpu_trace.h | 52 +++++++++++++++++++ drivers/gpu/drm/virtio/virtgpu_trace_points.c | 5 ++ drivers/gpu/drm/virtio/virtgpu_vq.c | 10 ++++ 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/virtio/virtgpu_trace.h create mode 100644 drivers/gpu/drm/virtio/virtgpu_trace_points.c diff --git a/drivers/gpu/drm/virtio/Makefile b/drivers/gpu/drm/virtio/Makefile index 4e90cc8fa651..42949a17ff70 100644 --- a/drivers/gpu/drm/virtio/Makefile +++ b/drivers/gpu/drm/virtio/Makefile @@ -6,6 +6,6 @@ virtio-gpu-y := virtgpu_drv.o virtgpu_kms.o virtgpu_gem.o \ virtgpu_fb.o virtgpu_display.o virtgpu_vq.o virtgpu_ttm.o \ virtgpu_fence.o virtgpu_object.o virtgpu_debugfs.o virtgpu_plane.o \ - virtgpu_ioctl.o virtgpu_prime.o + virtgpu_ioctl.o virtgpu_prime.o virtgpu_trace_points.o obj-$(CONFIG_DRM_VIRTIO_GPU) += virtio-gpu.o diff --git a/drivers/gpu/drm/virtio/virtgpu_trace.h b/drivers/gpu/drm/virtio/virtgpu_trace.h new file mode 100644 index 000000000000..711ecc2bd241 --- /dev/null +++ b/drivers/gpu/drm/virtio/virtgpu_trace.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#if !defined(_VIRTGPU_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ) +#define _VIRTGPU_TRACE_H_ + +#include + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM virtio_gpu +#define TRACE_INCLUDE_FILE virtgpu_trace + +DECLARE_EVENT_CLASS(virtio_gpu_cmd, + TP_PROTO(struct virtqueue *vq, struct virtio_gpu_ctrl_hdr *hdr), + TP_ARGS(vq, hdr), + TP_STRUCT__entry( + __field(int, dev) + __field(unsigned int, vq) + __field(const char *, name) + __field(u32, type) + __field(u32, flags) + __field(u64, fence_id) + __field(u32, ctx_id) + ), + TP_fast_assign( + __entry->dev = vq->vdev->index; + __entry->vq = vq->index; + __entry->name = vq->name; + __entry->type = le32_to_cpu(hdr->type); + __entry->flags = le32_to_cpu(hdr->flags); + __entry->fence_id = le64_to_cpu(hdr->fence_id); + __entry->ctx_id = le32_to_cpu(hdr->ctx_id); + ), + TP_printk("vdev=%d vq=%u name=%s type=0x%x flags=0x%x fence_id=%llu ctx_id=%u", + __entry->dev, __entry->vq, __entry->name, + __entry->type, __entry->flags, __entry->fence_id, + __entry->ctx_id) +); + +DEFINE_EVENT(virtio_gpu_cmd, virtio_gpu_cmd_queue, + TP_PROTO(struct virtqueue *vq, struct virtio_gpu_ctrl_hdr *hdr), + TP_ARGS(vq, hdr) +); + +DEFINE_EVENT(virtio_gpu_cmd, virtio_gpu_cmd_response, + TP_PROTO(struct virtqueue *vq, struct virtio_gpu_ctrl_hdr *hdr), + TP_ARGS(vq, hdr) +); + +#endif + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/virtio +#include diff --git a/drivers/gpu/drm/virtio/virtgpu_trace_points.c b/drivers/gpu/drm/virtio/virtgpu_trace_points.c new file mode 100644 index 000000000000..1970cb6f24ef --- /dev/null +++ b/drivers/gpu/drm/virtio/virtgpu_trace_points.c @@ -0,0 +1,5 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "virtgpu_drv.h" + +#define CREATE_TRACE_POINTS +#include "virtgpu_trace.h" diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index e62fe24b1a2e..2c5eeccb88c0 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -28,6 +28,7 @@ #include #include "virtgpu_drv.h" +#include "virtgpu_trace.h" #include #include #include @@ -192,6 +193,9 @@ void virtio_gpu_dequeue_ctrl_func(struct work_struct *work) list_for_each_entry_safe(entry, tmp, &reclaim_list, list) { resp = (struct virtio_gpu_ctrl_hdr *)entry->resp_buf; + + trace_virtio_gpu_cmd_response(vgdev->ctrlq.vq, resp); + if (resp->type != cpu_to_le32(VIRTIO_GPU_RESP_OK_NODATA)) { if (resp->type >= cpu_to_le32(VIRTIO_GPU_RESP_ERR_UNSPEC)) { struct virtio_gpu_ctrl_hdr *cmd; @@ -284,6 +288,9 @@ static int virtio_gpu_queue_ctrl_buffer_locked(struct virtio_gpu_device *vgdev, spin_lock(&vgdev->ctrlq.qlock); goto retry; } else { + trace_virtio_gpu_cmd_queue(vq, + (struct virtio_gpu_ctrl_hdr *)vbuf->buf); + virtqueue_kick(vq); } @@ -359,6 +366,9 @@ static int virtio_gpu_queue_cursor(struct virtio_gpu_device *vgdev, spin_lock(&vgdev->cursorq.qlock); goto retry; } else { + trace_virtio_gpu_cmd_queue(vq, + (struct virtio_gpu_ctrl_hdr *)vbuf->buf); + virtqueue_kick(vq); }