From patchwork Tue Nov 24 02:19: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: 11926955 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52CD1C2D0E4 for ; Tue, 24 Nov 2020 02:19:08 +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 EC121206E5 for ; Tue, 24 Nov 2020 02:19:07 +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="C5gtRUcI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC121206E5 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 1C49E6E19B; Tue, 24 Nov 2020 02:19:07 +0000 (UTC) Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4122C6E19B for ; Tue, 24 Nov 2020 02:19:06 +0000 (UTC) Received: by mail-pf1-x443.google.com with SMTP id y7so16900287pfq.11 for ; Mon, 23 Nov 2020 18:19:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gED05o6qM6JYcgzJSGphWESgZ2iZtaePZaZE1VI8plA=; b=C5gtRUcIioc273NDlKhZJg7LPyfXhsHvAMgkxlNKOvZGDGAlKMmZ/adtk2QLe7GAgx 3C6dAxOsyvRbaA7OUQdURQ3X3UcEx+L0Pt6SB1H5yfXjBD5J6id0U81+qzf6BRRhZ4ZF jNEDUwvlRyXJ6oiSwaBTcSduOqwOXbs/kwkDU= 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=gED05o6qM6JYcgzJSGphWESgZ2iZtaePZaZE1VI8plA=; b=bSFPGx9pZJnbceuVExPdKOhq0N5MMJzvxl6jeNnjlUFGhUEYLP0HA6Tf2j4JqG5Pd4 ri0PK1OFp8wfw0/3Ri2rRTlpLQcuT/4apYysKzSBpG1zKumHHJIE9E/+B1xjL9tJYPoP sXctMuxS3OELOGvkc7gHG9u6lAN1Eb79iNBCc9rkDKrP4ZLJ3d0nA3FP9ceKOe9OMEfG gZpVWTDr4GtrIR+MXdJGh+mlIYGFfGMF2CNsD/GuKOdOEy5SS78K4MigEIgeWbb2/mbB gctCGNLu9TIRkyXmJqjhielxZc2IxFOjA3BG30eQZxQa0hca5aPNXwhMV5TLWfhvBCxI BKMQ== X-Gm-Message-State: AOAM530/HJ9p5EX1l4qu0zb5XzdxVvbKQbAqkcr6fFTaTxyH6odb3smK SXhcfnBOLYOLsHfXGR21InqWSiKzIAksmA== X-Google-Smtp-Source: ABdhPJxGizH2ecoSD65/W25MPMXcCa032bnpiBtuxUnCiDOt1g80uHeFuq7rSHCng9oH7SRubLnAxQ== X-Received: by 2002:a17:90a:5404:: with SMTP id z4mr2107046pjh.198.1606184345521; Mon, 23 Nov 2020 18:19:05 -0800 (PST) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id o198sm6209642pfg.102.2020.11.23.18.19.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 18:19:04 -0800 (PST) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/3] drm/virtio: virtio_{blah} --> virtio_gpu_{blah} Date: Mon, 23 Nov 2020 18:19:00 -0800 Message-Id: <20201124021902.407-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: anthoine.bourgeois@gmail.co, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" virtio_gpu typically uses the prefix virtio_gpu, but there are a few places where the virtio prefix is used. Modify this for consistency. Signed-off-by: Gurchetan Singh Reviewed-by: Anthoine Bourgeois --- drivers/gpu/drm/virtio/virtgpu_debugfs.c | 24 ++++++++++-------- drivers/gpu/drm/virtio/virtgpu_fence.c | 32 +++++++++++++----------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_debugfs.c b/drivers/gpu/drm/virtio/virtgpu_debugfs.c index 5fefc88d47e4..c2b20e0ee030 100644 --- a/drivers/gpu/drm/virtio/virtgpu_debugfs.c +++ b/drivers/gpu/drm/virtio/virtgpu_debugfs.c @@ -28,14 +28,13 @@ #include "virtgpu_drv.h" -static void virtio_add_bool(struct seq_file *m, const char *name, - bool value) +static void virtio_gpu_add_bool(struct seq_file *m, const char *name, + bool value) { seq_printf(m, "%-16s : %s\n", name, value ? "yes" : "no"); } -static void virtio_add_int(struct seq_file *m, const char *name, - int value) +static void virtio_gpu_add_int(struct seq_file *m, const char *name, int value) { seq_printf(m, "%-16s : %d\n", name, value); } @@ -45,13 +44,16 @@ static int virtio_gpu_features(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; - virtio_add_bool(m, "virgl", vgdev->has_virgl_3d); - 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); + virtio_gpu_add_bool(m, "virgl", vgdev->has_virgl_3d); + virtio_gpu_add_bool(m, "edid", vgdev->has_edid); + virtio_gpu_add_bool(m, "indirect", vgdev->has_indirect); + + virtio_gpu_add_bool(m, "resource uuid", + vgdev->has_resource_assign_uuid); + + virtio_gpu_add_bool(m, "blob resources", vgdev->has_resource_blob); + virtio_gpu_add_int(m, "cap sets", vgdev->num_capsets); + virtio_gpu_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, diff --git a/drivers/gpu/drm/virtio/virtgpu_fence.c b/drivers/gpu/drm/virtio/virtgpu_fence.c index 728ca36f6327..586034c90587 100644 --- a/drivers/gpu/drm/virtio/virtgpu_fence.c +++ b/drivers/gpu/drm/virtio/virtgpu_fence.c @@ -27,22 +27,22 @@ #include "virtgpu_drv.h" -#define to_virtio_fence(x) \ +#define to_virtio_gpu_fence(x) \ container_of(x, struct virtio_gpu_fence, f) -static const char *virtio_get_driver_name(struct dma_fence *f) +static const char *virtio_gpu_get_driver_name(struct dma_fence *f) { return "virtio_gpu"; } -static const char *virtio_get_timeline_name(struct dma_fence *f) +static const char *virtio_gpu_get_timeline_name(struct dma_fence *f) { return "controlq"; } -static bool virtio_fence_signaled(struct dma_fence *f) +static bool virtio_gpu_fence_signaled(struct dma_fence *f) { - struct virtio_gpu_fence *fence = to_virtio_fence(f); + struct virtio_gpu_fence *fence = to_virtio_gpu_fence(f); if (WARN_ON_ONCE(fence->f.seqno == 0)) /* leaked fence outside driver before completing @@ -53,25 +53,26 @@ static bool virtio_fence_signaled(struct dma_fence *f) return false; } -static void virtio_fence_value_str(struct dma_fence *f, char *str, int size) +static void virtio_gpu_fence_value_str(struct dma_fence *f, char *str, int size) { snprintf(str, size, "%llu", f->seqno); } -static void virtio_timeline_value_str(struct dma_fence *f, char *str, int size) +static void virtio_gpu_timeline_value_str(struct dma_fence *f, char *str, + int size) { - struct virtio_gpu_fence *fence = to_virtio_fence(f); + struct virtio_gpu_fence *fence = to_virtio_gpu_fence(f); snprintf(str, size, "%llu", (u64)atomic64_read(&fence->drv->last_fence_id)); } -static const struct dma_fence_ops virtio_fence_ops = { - .get_driver_name = virtio_get_driver_name, - .get_timeline_name = virtio_get_timeline_name, - .signaled = virtio_fence_signaled, - .fence_value_str = virtio_fence_value_str, - .timeline_value_str = virtio_timeline_value_str, +static const struct dma_fence_ops virtio_gpu_fence_ops = { + .get_driver_name = virtio_gpu_get_driver_name, + .get_timeline_name = virtio_gpu_get_timeline_name, + .signaled = virtio_gpu_fence_signaled, + .fence_value_str = virtio_gpu_fence_value_str, + .timeline_value_str = virtio_gpu_timeline_value_str, }; struct virtio_gpu_fence *virtio_gpu_fence_alloc(struct virtio_gpu_device *vgdev) @@ -88,7 +89,8 @@ struct virtio_gpu_fence *virtio_gpu_fence_alloc(struct virtio_gpu_device *vgdev) * 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); + dma_fence_init(&fence->f, &virtio_gpu_fence_ops, &drv->lock, drv->context, + 0); return fence; } From patchwork Tue Nov 24 02:19: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: 11926959 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 493B9C63697 for ; Tue, 24 Nov 2020 02:19:15 +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 D5E76206E5 for ; Tue, 24 Nov 2020 02:19:14 +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="WDQhoXPo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D5E76206E5 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 CF8766E1AA; Tue, 24 Nov 2020 02:19:11 +0000 (UTC) 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 38E926E1A7 for ; Tue, 24 Nov 2020 02:19:07 +0000 (UTC) Received: by mail-pg1-x544.google.com with SMTP id l17so5623676pgk.1 for ; Mon, 23 Nov 2020 18:19:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0Bv13npSpfF2TWRCs41hxa8CIfpSwBxXtLVE6tC1RsQ=; b=WDQhoXPo+SH8cNLOwIzSIMIyRAT5bADFNZFcvg3+4Bhqp30VrjMwEAB1/65FLe9geh I/RTw91KAfU4OYzQExx2lZMfCOT/7Kg5co0Z9UuDLhrhQOB+wDiiCyvbKUBaR+mn2h/c lgkS8DaDIhPgFhLMuDk9LxOPOXgVMECB+NoyA= 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=0Bv13npSpfF2TWRCs41hxa8CIfpSwBxXtLVE6tC1RsQ=; b=XmQEN2bfM20xqi4G8ux4vcRGC6XsfBaGt4NFjMYZljEWLHPxHeLaqusRzo6oUKCC1U e3B/7QNExzOj2hhXAjb4R04AdKYS3YXXMHMHD6x8kGrYRa04+51+IsbX8oDwbL3s5OGW Mas1cy9uQ2Z8OWoPQUAkmx91WsAAd7XjJdceB+5J1IYbm79WAzRMloJgmZ7FYyY5cNX8 e4Bod/ujtYoC/JW+gXtagv5ViBPvH9xTEx0pCNwEgGSEHkfKxx+7Ni3AjJo27uyPJJgB 7sP+1jxHbjDrAqz0Gxxs3Lg3pfTKtwnYrraFscI2NMrhE1bPKJRO3SSxz4TjVRcQHfUg Nquw== X-Gm-Message-State: AOAM533epnu7tYjf5zeToulwUAiQb7iyncwaovSlhU0sLo+ew318FxkN DD2e21Pv8IhKBGFJpLm8scxDKFKoIK779A== X-Google-Smtp-Source: ABdhPJwJCRok80IeNGPVKtG3DTNdc6dU+7k7HjdS4BF6r9QqSdWwo37g37idL5c9rtwkBimjVaAL5g== X-Received: by 2002:a62:4e96:0:b029:198:1080:5bc6 with SMTP id c144-20020a624e960000b029019810805bc6mr2078050pfb.26.1606184346567; Mon, 23 Nov 2020 18:19:06 -0800 (PST) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id o198sm6209642pfg.102.2020.11.23.18.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 18:19:06 -0800 (PST) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/3] drm/virtio: rework virtio_fence_signaled Date: Mon, 23 Nov 2020 18:19:01 -0800 Message-Id: <20201124021902.407-2-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201124021902.407-1-gurchetansingh@chromium.org> References: <20201124021902.407-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: anthoine.bourgeois@gmail.co, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" virtio_gpu_fence_event_process sets the last_fence_id and subsequently calls dma_fence_signal_locked(..). dma_fence_signal_locked(..) sets DMA_FENCE_FLAG_SIGNALED_BIT, which is actually checked before &dma_fence_ops.(*signaled) is called. The check for last_fence_id is therefore a bit redundant, and it will not be sufficient to check the last_fence_id for multiple synchronization timelines. Remove it. Signed-off-by: Gurchetan Singh Reviewed-by: Anthoine Bourgeois --- drivers/gpu/drm/virtio/virtgpu_fence.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_fence.c b/drivers/gpu/drm/virtio/virtgpu_fence.c index 586034c90587..b35fcd1d02d7 100644 --- a/drivers/gpu/drm/virtio/virtgpu_fence.c +++ b/drivers/gpu/drm/virtio/virtgpu_fence.c @@ -42,14 +42,10 @@ static const char *virtio_gpu_get_timeline_name(struct dma_fence *f) static bool virtio_gpu_fence_signaled(struct dma_fence *f) { - struct virtio_gpu_fence *fence = to_virtio_gpu_fence(f); - - if (WARN_ON_ONCE(fence->f.seqno == 0)) - /* leaked fence outside driver before completing - * initialization with virtio_gpu_fence_emit */ - return false; - if (atomic64_read(&fence->drv->last_fence_id) >= fence->f.seqno) - return true; + /* leaked fence outside driver before completing + * initialization with virtio_gpu_fence_emit. + */ + WARN_ON_ONCE(f->seqno == 0); return false; } From patchwork Tue Nov 24 02:19: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: 11926957 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31AB7C2D0E4 for ; Tue, 24 Nov 2020 02:19:13 +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 BD8D6206E5 for ; Tue, 24 Nov 2020 02:19:12 +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="iuME6ZhV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD8D6206E5 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 D119B6E1B1; Tue, 24 Nov 2020 02:19:11 +0000 (UTC) Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id 67DB36E1A7 for ; Tue, 24 Nov 2020 02:19:08 +0000 (UTC) Received: by mail-pg1-x542.google.com with SMTP id m9so16076636pgb.4 for ; Mon, 23 Nov 2020 18:19:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NqhGugUbJorLXtJYLxm+cfpaPmbES7zUe994vKjJ41Q=; b=iuME6ZhVE9qVJrasg/Nse92AayTfe0uxkoyWkYEJjH4P0zs2OF++CQ0rRYI+WiPjnJ HFpI+czgEFg40QfHj8rNQDKGQn9hnAQDWTvbh7jfWykp2MCfdA95YTXmc72udc6JYGQC NR07orAXTBJ28cP1IibauTk+bBLN6YAoGq/0A= 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=NqhGugUbJorLXtJYLxm+cfpaPmbES7zUe994vKjJ41Q=; b=Hv8HN8RWYrx+ZlxOErLA6+x77fY1TznYDiG4IS+Q8WWL/4R5A5GhTW9ulOeLWlBSZ6 43Kn8Fi9xcrCWZs+CLVztbPADPshnSWMEdf7DZbQIgF8UPpQa2LKhmxZbuj5agvau4Gu gsNlo3wN0kZjPtW7n6UIAv4MVNsEv3B+u3vV+4AxZ1k+F2uNMcdqMP63hC4eeUql246/ 4C8gj2f0rktcS2bzwyJvtWsDOQQmIR7smpn3dJz1g5nhO943Y9zVYH2TZLK5lgRE8zF3 Umt2X6nA7Cz0MRDfaLjDiTy+viEizbE3aWVFYNPXN97oqh7fZkti52fVyMDr3DL4t/AQ W+5g== X-Gm-Message-State: AOAM53144MpIbFnmKQjCjg8Y1viN3FAUVUWZY84bJN5H1mjH68nQUug/ BXnnsLYCJ95OFQvzHW/eKtJFp/eKQynbTA== X-Google-Smtp-Source: ABdhPJwctbmjAZhQf53B5tdX8x/CoG2uxcV6qfip7n+arLmaWpgkfJvPqefC3thrjABhp7ztWlyieQ== X-Received: by 2002:a63:f20:: with SMTP id e32mr1970082pgl.130.1606184347763; Mon, 23 Nov 2020 18:19:07 -0800 (PST) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:5265:f3ff:fe2d:4d58]) by smtp.gmail.com with ESMTPSA id o198sm6209642pfg.102.2020.11.23.18.19.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 18:19:07 -0800 (PST) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/3] drm/virtio: consider dma-fence context when signaling Date: Mon, 23 Nov 2020 18:19:02 -0800 Message-Id: <20201124021902.407-3-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201124021902.407-1-gurchetansingh@chromium.org> References: <20201124021902.407-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: anthoine.bourgeois@gmail.co, kraxel@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This an incremental refactor towards multiple dma-fence contexts in virtio-gpu. Since all fences are still allocated using &virtio_gpu_fence_driver.context, nothing should break and every processed fence will be signaled. The overall idea is every 3D context can allocate a number of dma-fence contexts. Each dma-fence context refers to it's own timeline. For example, consider the following case where virgl submits commands to the GPU (fence ids 1, 3) and does a metadata query with the CPU (fence id 5). In a different process, gfxstream submits commands to the GPU (fence ids 2, 4). fence_id (&dma_fence.seqno) | 1 2 3 4 5 ----------------------------------|----------- fence_ctx 0 (virgl gpu) | 1 3 fence_ctx 1 (virgl metadata query)| 5 fence_ctx 2 (gfxstream gpu) | 2 4 With multiple fence contexts, we can wait for the metadata query to finish without waiting for the virgl gpu to finish. virgl gpu does not have to wait for gfxstream gpu. The fence id still is the monotonically increasing sequence number, but it's only revelant to the specific dma-fence context. To fully enable this feature, we'll need to: - have each 3d context allocate a number of fence contexts. Not too hard with explicit context initialization on the horizon. - have guest userspace specify fence context when performing ioctls. - tag each fence emitted to the host with the fence context information. virtio_gpu_ctrl_hdr has padding + flags available, so that should be easy. This change goes in the direction specified above, by: - looking up the virtgpu_fence given a fence_id - signalling all prior fences in a given context - signalling current fence Signed-off-by: Gurchetan Singh --- drivers/gpu/drm/virtio/virtgpu_drv.h | 1 + drivers/gpu/drm/virtio/virtgpu_fence.c | 39 ++++++++++++++++++++------ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index 6a232553c99b..d9dbc4f258f3 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -136,6 +136,7 @@ struct virtio_gpu_fence_driver { struct virtio_gpu_fence { struct dma_fence f; + uint64_t fence_id; struct virtio_gpu_fence_driver *drv; struct list_head node; }; diff --git a/drivers/gpu/drm/virtio/virtgpu_fence.c b/drivers/gpu/drm/virtio/virtgpu_fence.c index b35fcd1d02d7..3de09d78dada 100644 --- a/drivers/gpu/drm/virtio/virtgpu_fence.c +++ b/drivers/gpu/drm/virtio/virtgpu_fence.c @@ -51,7 +51,7 @@ static bool virtio_gpu_fence_signaled(struct dma_fence *f) static void virtio_gpu_fence_value_str(struct dma_fence *f, char *str, int size) { - snprintf(str, size, "%llu", f->seqno); + snprintf(str, size, "[%llu, %llu]", f->context, f->seqno); } static void virtio_gpu_timeline_value_str(struct dma_fence *f, char *str, @@ -99,7 +99,7 @@ void virtio_gpu_fence_emit(struct virtio_gpu_device *vgdev, unsigned long irq_flags; spin_lock_irqsave(&drv->lock, irq_flags); - fence->f.seqno = ++drv->current_fence_id; + fence->fence_id = fence->f.seqno = ++drv->current_fence_id; dma_fence_get(&fence->f); list_add_tail(&fence->node, &drv->fences); spin_unlock_irqrestore(&drv->lock, irq_flags); @@ -107,24 +107,45 @@ void virtio_gpu_fence_emit(struct virtio_gpu_device *vgdev, 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); + cmd_hdr->fence_id = cpu_to_le64(fence->fence_id); } void virtio_gpu_fence_event_process(struct virtio_gpu_device *vgdev, u64 fence_id) { struct virtio_gpu_fence_driver *drv = &vgdev->fence_drv; - struct virtio_gpu_fence *fence, *tmp; + struct virtio_gpu_fence *signaled, *curr, *tmp; unsigned long irq_flags; spin_lock_irqsave(&drv->lock, irq_flags); atomic64_set(&vgdev->fence_drv.last_fence_id, fence_id); - list_for_each_entry_safe(fence, tmp, &drv->fences, node) { - if (fence_id < fence->f.seqno) + list_for_each_entry_safe(curr, tmp, &drv->fences, node) { + if (fence_id != curr->fence_id) continue; - dma_fence_signal_locked(&fence->f); - list_del(&fence->node); - dma_fence_put(&fence->f); + + signaled = curr; + + /* + * Signal any fences with a strictly smaller sequence number + * the current signaled fence. + */ + list_for_each_entry_safe(curr, tmp, &drv->fences, node) { + /* dma-fence contexts must match */ + if (signaled->f.context != curr->f.context) + continue; + + if (!dma_fence_is_later(&signaled->f, &curr->f)) + continue; + + dma_fence_signal_locked(&curr->f); + list_del(&curr->node); + dma_fence_put(&curr->f); + } + + dma_fence_signal_locked(&signaled->f); + list_del(&signaled->node); + dma_fence_put(&signaled->f); + break; } spin_unlock_irqrestore(&drv->lock, irq_flags); }