From patchwork Tue Nov 16 10:24:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 12622421 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C65FFC433F5 for ; Tue, 16 Nov 2021 14:05: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 8F78F61B48 for ; Tue, 16 Nov 2021 14:05:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8F78F61B48 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 888E26EA36; Tue, 16 Nov 2021 14:05:09 +0000 (UTC) Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by gabe.freedesktop.org (Postfix) with ESMTPS id B12B36E092; Tue, 16 Nov 2021 10:24:37 +0000 (UTC) Received: by mail-wr1-x434.google.com with SMTP id w29so36466691wra.12; Tue, 16 Nov 2021 02:24:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=aE6l4NuYKZntvX18ph7Q5o2EYNVJMQNc5RA+RnsTb4g=; b=TQXLcMc9k40XyejLlDnNaPtfq2p4yMMKBRaez3W6EjTDBslR9RtJhL+CdCNJJBt4/D eiiea5zQdpNQCJ5Cd35Goxz3uWCgn/C/LBDNpXB2r44AbfA5KWeAbLjp/jRHwehApLU/ UXnkPTxa16a/OLVa0hWs4EUeVrQ9vAOiXKljYjWtBK3FUmDQNVml8SCkORDKgtzF+M7o FOApEKhDqabxJYg5uiqgqXa9VZYmWeMxRtmkoZPmXhdvTa1CVzqe+5AW2Y5WplDFs4Ay eIrw8IQht031aMFTcengNn8WugA2EQofgrAUhDJkAqYKBq1VizqFwHkz7wPG6HffmRAc CEUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aE6l4NuYKZntvX18ph7Q5o2EYNVJMQNc5RA+RnsTb4g=; b=02gVlxoxejNNYkruUgtiKSBJ2zAP7mdIAmbz420vnNETyF9bBEGYRNeteFVLLVahJT owJZo+okoaSY/kyypNeZ57ijDRPzqsdMIzcGxSCFiyoiRshToCUex3FRFiDpaDEgkrsN 0bHW02fG4EpASIclXc+lCWs2Vx670sKnDIjRj9DNIRwJ5gVhZ2MhyY2uIePh0GgVplzm 6wPeu343vE2NkUH+slBCaXu+oqg8Km+rPQ0b/+lpLJYdqvzw7+wK2cWx7BJwst98+kbf Pw42sGgWNZapz0WvEwQmSOGveGBndMsxhuYSy73uxMmhHuBhz2EOSTB2maaY2m41NhYO yXnw== X-Gm-Message-State: AOAM532rg1wdKuXQuWEzXMQtcWkKosuG24co9xOrPppPb17yAuNVVGB8 +4xGWdn3PmpWpGvNumO5aLtj51oXXPEKOA== X-Google-Smtp-Source: ABdhPJwqK9iy+6VBb8JBGWD3+Ieb3KpWWSs1OLz7ZTz/DwTk1n+BKRFemtKJ1T1DfbwmtHs2WmdB4g== X-Received: by 2002:a05:6000:188c:: with SMTP id a12mr8033404wri.92.1637058276224; Tue, 16 Nov 2021 02:24:36 -0800 (PST) Received: from abel.fritz.box (p57b0b77b.dip0.t-ipconnect.de. [87.176.183.123]) by smtp.gmail.com with ESMTPSA id 4sm22119334wrz.90.2021.11.16.02.24.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 02:24:35 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Tue, 16 Nov 2021 11:24:26 +0100 Message-Id: <20211116102431.198905-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116102431.198905-1-christian.koenig@amd.com> References: <20211116102431.198905-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 16 Nov 2021 14:05:08 +0000 Subject: [Intel-gfx] [PATCH 1/6] drm/i915: use the new iterator in i915_gem_busy_ioctl v2 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" This makes the function much simpler since the complex retry logic is now handled else where. Signed-off-by: Christian König Acked-by: Daniel Vetter --- drivers/gpu/drm/i915/gem/i915_gem_busy.c | 35 ++++++++++-------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_busy.c b/drivers/gpu/drm/i915/gem/i915_gem_busy.c index 7358bebef15c..470fdfd61a0f 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_busy.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_busy.c @@ -115,8 +115,8 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data, { struct drm_i915_gem_busy *args = data; struct drm_i915_gem_object *obj; - struct dma_resv_list *list; - unsigned int seq; + struct dma_resv_iter cursor; + struct dma_fence *fence; int err; err = -ENOENT; @@ -142,27 +142,20 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data, * to report the overall busyness. This is what the wait-ioctl does. * */ -retry: - seq = raw_read_seqcount(&obj->base.resv->seq); - - /* Translate the exclusive fence to the READ *and* WRITE engine */ - args->busy = busy_check_writer(dma_resv_excl_fence(obj->base.resv)); - - /* Translate shared fences to READ set of engines */ - list = dma_resv_shared_list(obj->base.resv); - if (list) { - unsigned int shared_count = list->shared_count, i; - - for (i = 0; i < shared_count; ++i) { - struct dma_fence *fence = - rcu_dereference(list->shared[i]); - + args->busy = 0; + dma_resv_iter_begin(&cursor, obj->base.resv, true); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + if (dma_resv_iter_is_restarted(&cursor)) + args->busy = 0; + + if (dma_resv_iter_is_exclusive(&cursor)) + /* Translate the exclusive fence to the READ *and* WRITE engine */ + args->busy |= busy_check_writer(fence); + else + /* Translate shared fences to READ set of engines */ args->busy |= busy_check_reader(fence); - } } - - if (args->busy && read_seqcount_retry(&obj->base.resv->seq, seq)) - goto retry; + dma_resv_iter_end(&cursor); err = 0; out: From patchwork Tue Nov 16 10:24:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 12622427 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99461C433F5 for ; Tue, 16 Nov 2021 14:05:21 +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 5BDF061B48 for ; Tue, 16 Nov 2021 14:05:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5BDF061B48 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B1D806EABA; Tue, 16 Nov 2021 14:05:16 +0000 (UTC) Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F7866E1B5; Tue, 16 Nov 2021 10:24:38 +0000 (UTC) Received: by mail-wr1-x42e.google.com with SMTP id d27so36574802wrb.6; Tue, 16 Nov 2021 02:24:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=E1mLau2z1VIOncH+lY3sIrl5+7OvgX/wzzV/iwEt37Y=; b=Jq/9mDt5YvEnnX4kt3FoZbm7R0vW3Q5zVKCegHUFhlZUdR4G6j18YG3/ogXuFMTS/U Xte8fGB7tGXMN6/heURAAB1KEJwwnjuOzR4cHn8Mfx/RSHVBYZi1PdmynJ5/2d3YHYJh 82u0QkL1DUaHI7bUzNQvW0FLW0bbmXbFRiBYatyJw1lkb/GfmidoVNR//Z0lDgs1aM/Y voc4mlJVZpV6igU/vxWaAPVWQ0BegHb19YTWmarViE+QJ21XbiT/AqaRvBisFIMnBfX3 i7Wb2r92ByKo6PX80GEotN5JUIoJcUpRMwYT/nT6yLmvMklzsNIxBHrk4xyvP5fIiRtp RvoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E1mLau2z1VIOncH+lY3sIrl5+7OvgX/wzzV/iwEt37Y=; b=0SiYg2yO/RfbbGHcAKxUacrLVFaUQaXWcA/UWDlwn3Smk3JT7ELtJMjDcD1Exww3+h QI1v9En63sRxs4wp77NE38TCVqzBbpWzSFvnpvT4Mb1Vb3ZRyuE18k4TRHKsamZR/U9R cNHj0PNxjEwYiz35QUM+y7P3TDsXnskKKqN1X9m0VTG4kcMoyz2YCVjH7Vtw1+WOpfAM IhrhiGB7DvLESEOJwbq3c9NbrBGBB4mSAk2hW9wQCEKJDCzoqkJBQSSYEfbY+rGsm+2E 8MiN15P7F8xib0m183SP7LqflcAx7t7ZRNpfEuWKdXIZVTrCjq2xamEJAHjBIwYidd4K wDeA== X-Gm-Message-State: AOAM533Ovi5uEK26KYAFRqsnFltidKK3ao6VDiKjk1xMoYndfwyWi/LE YwJZNLgt2wXomeDC+TMInMjo0tiLIwghCA== X-Google-Smtp-Source: ABdhPJwLWyRpIQXYjMIYKD9V+cuyLA4cYUFhfRZluE1j0YdkGhqOdezWTOQiCY8w86fAGItzyxJu5g== X-Received: by 2002:adf:cd06:: with SMTP id w6mr7653944wrm.431.1637058276992; Tue, 16 Nov 2021 02:24:36 -0800 (PST) Received: from abel.fritz.box (p57b0b77b.dip0.t-ipconnect.de. [87.176.183.123]) by smtp.gmail.com with ESMTPSA id 4sm22119334wrz.90.2021.11.16.02.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 02:24:36 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Tue, 16 Nov 2021 11:24:27 +0100 Message-Id: <20211116102431.198905-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116102431.198905-1-christian.koenig@amd.com> References: <20211116102431.198905-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 16 Nov 2021 14:05:08 +0000 Subject: [Intel-gfx] [PATCH 2/6] drm/i915: use new iterator in i915_gem_object_wait_priority X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Simplifying the code a bit. Signed-off-by: Christian König Acked-by: Daniel Vetter --- drivers/gpu/drm/i915/gem/i915_gem_wait.c | 31 +++++------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_wait.c b/drivers/gpu/drm/i915/gem/i915_gem_wait.c index f909aaa09d9c..34e46134326b 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_wait.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_wait.c @@ -151,32 +151,13 @@ i915_gem_object_wait_priority(struct drm_i915_gem_object *obj, unsigned int flags, const struct i915_sched_attr *attr) { - struct dma_fence *excl; - - if (flags & I915_WAIT_ALL) { - struct dma_fence **shared; - unsigned int count, i; - int ret; - - ret = dma_resv_get_fences(obj->base.resv, &excl, &count, - &shared); - if (ret) - return ret; + struct dma_resv_iter cursor; + struct dma_fence *fence; - for (i = 0; i < count; i++) { - i915_gem_fence_wait_priority(shared[i], attr); - dma_fence_put(shared[i]); - } - - kfree(shared); - } else { - excl = dma_resv_get_excl_unlocked(obj->base.resv); - } - - if (excl) { - i915_gem_fence_wait_priority(excl, attr); - dma_fence_put(excl); - } + dma_resv_iter_begin(&cursor, obj->base.resv, flags & I915_WAIT_ALL); + dma_resv_for_each_fence_unlocked(&cursor, fence) + i915_gem_fence_wait_priority(fence, attr); + dma_resv_iter_end(&cursor); return 0; } From patchwork Tue Nov 16 10:24:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 12622419 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3E49C433EF for ; Tue, 16 Nov 2021 14:05:10 +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 6713961B48 for ; Tue, 16 Nov 2021 14:05:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6713961B48 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6019A6EA04; Tue, 16 Nov 2021 14:05:09 +0000 (UTC) Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 27A3C6E1B5; Tue, 16 Nov 2021 10:24:39 +0000 (UTC) Received: by mail-wr1-x42f.google.com with SMTP id d24so36600502wra.0; Tue, 16 Nov 2021 02:24:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=HEGpUo6vrxQTNQUpP+urhAJCyKmgX70ObR6Liot+zKA=; b=YSlaiSgZu8R7FWJr5N+13V4kFoqOp5L5K53VTVGRRoh78jw5j9rPC3Pw61Ud2KEAW7 W+0GtNAjQWeodEOU9xqJnQYoKGKTi8QHbyYXs0ftEg0q+oWUsl78U0k4I0WYxevfutt0 mzGmFRlcbcW5Kd1B6sAceZfFfNTWlBIgk6hbT7naTlXRSPPjvt2XkhD7WU79AnZZEWpz 6SjKqFYIoG5RBg2kjtofZmoqpvyUn8LtmaEaGYPmP7BBxzUSBrX6aHyXZTIMloOuToLM vpYnUzR/p+cub6y7rogy1ygNR3jbQcXqNgh2ZhRzVgWvPZMmXeAyV2K8VQN652qYM+/M T6Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HEGpUo6vrxQTNQUpP+urhAJCyKmgX70ObR6Liot+zKA=; b=d5yuujeScHMdQZ1/9EzOo6lMUx6+w8GSBPtAxBbF1xaEGE7iP0r5yiklnKAPCUvwO7 ty2lqAOHpsS7x77IWUGDqZJH14fOeBgjmaNhqBVSfYI7krveoR4HhLfV8gsVARBbkRcB YGFQXcTH+wqG3uZ/ZuFOKbxdwAhdK2rzIJRv3zE7CPCPYedVKC9ffw+TIc4Czgl8IsCq jeKN9epwBfuCg9RGnSrSOy99MDg5YwJpC4WmXhWYLb7neGzPXhqcPQmThBHwzlUUlEJ+ RTLbypPzbtgB/nS07rk9KcihvKzUMHHw5gMiKGdRd/RUZlz9tC/1a5dkFRH/4Xg2oNJp OSaQ== X-Gm-Message-State: AOAM531hOjCtvg6wVq3CIApLprPFoT/fvW/0GwogivbmOJkGWZKWevWx MMv5yuk+7Krz0OTJuN0MOCPljtoftbqfqw== X-Google-Smtp-Source: ABdhPJwDUe5nG1AD/KQ32GgR6sI90Gd9RMpELbglo1cLe9X+4QY5wD/vqMqT/vPQL+7xDO30J4g89w== X-Received: by 2002:a5d:518d:: with SMTP id k13mr7899747wrv.120.1637058277767; Tue, 16 Nov 2021 02:24:37 -0800 (PST) Received: from abel.fritz.box (p57b0b77b.dip0.t-ipconnect.de. [87.176.183.123]) by smtp.gmail.com with ESMTPSA id 4sm22119334wrz.90.2021.11.16.02.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 02:24:37 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Tue, 16 Nov 2021 11:24:28 +0100 Message-Id: <20211116102431.198905-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116102431.198905-1-christian.koenig@amd.com> References: <20211116102431.198905-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 16 Nov 2021 14:05:08 +0000 Subject: [Intel-gfx] [PATCH 3/6] drm/i915: use the new iterator in i915_sw_fence_await_reservation v3 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Simplifying the code a bit. v2: use dma_resv_for_each_fence instead, according to Tvrtko the lock is held here anyway. v3: back to using dma_resv_for_each_fence_unlocked. Signed-off-by: Christian König Acked-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_sw_fence.c | 53 ++++++---------------------- 1 file changed, 11 insertions(+), 42 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_sw_fence.c b/drivers/gpu/drm/i915/i915_sw_fence.c index c589a681da77..7ea0dbf81530 100644 --- a/drivers/gpu/drm/i915/i915_sw_fence.c +++ b/drivers/gpu/drm/i915/i915_sw_fence.c @@ -572,56 +572,25 @@ int i915_sw_fence_await_reservation(struct i915_sw_fence *fence, unsigned long timeout, gfp_t gfp) { - struct dma_fence *excl; + struct dma_resv_iter cursor; + struct dma_fence *f; int ret = 0, pending; debug_fence_assert(fence); might_sleep_if(gfpflags_allow_blocking(gfp)); - if (write) { - struct dma_fence **shared; - unsigned int count, i; - - ret = dma_resv_get_fences(resv, &excl, &count, &shared); - if (ret) - return ret; - - for (i = 0; i < count; i++) { - if (shared[i]->ops == exclude) - continue; - - pending = i915_sw_fence_await_dma_fence(fence, - shared[i], - timeout, - gfp); - if (pending < 0) { - ret = pending; - break; - } - - ret |= pending; - } - - for (i = 0; i < count; i++) - dma_fence_put(shared[i]); - kfree(shared); - } else { - excl = dma_resv_get_excl_unlocked(resv); - } - - if (ret >= 0 && excl && excl->ops != exclude) { - pending = i915_sw_fence_await_dma_fence(fence, - excl, - timeout, + dma_resv_iter_begin(&cursor, resv, write); + dma_resv_for_each_fence_unlocked(&cursor, f) { + pending = i915_sw_fence_await_dma_fence(fence, f, timeout, gfp); - if (pending < 0) + if (pending < 0) { ret = pending; - else - ret |= pending; - } - - dma_fence_put(excl); + break; + } + ret |= pending; + } + dma_resv_iter_end(&cursor); return ret; } From patchwork Tue Nov 16 10:24:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 12622429 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02CADC433FE for ; Tue, 16 Nov 2021 14:05:23 +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 BF2BD61B48 for ; Tue, 16 Nov 2021 14:05:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BF2BD61B48 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7A6F26EAE3; Tue, 16 Nov 2021 14:05:17 +0000 (UTC) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by gabe.freedesktop.org (Postfix) with ESMTPS id D8A826E1B5; Tue, 16 Nov 2021 10:24:39 +0000 (UTC) Received: by mail-wr1-x42a.google.com with SMTP id i5so36561612wrb.2; Tue, 16 Nov 2021 02:24:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=/4l9UpfpZvlcAJNqS1oueUKAgaTadj3L3dcu3aCeFd0=; b=X6YtO8fQFgHeAM78h1drfhlaE/8TTV0MtTOgWsG8UaHat9K//dTItofi9o1fVhvDWx i6doqxMw0iVQUGtbGygBljZWhYVi5WCpcxiTeCOsNRtx3MMzV25YqR5j2DyUgc2lCMCy p23QrtoCC8i41mDpvMCD3V1d4bC9Qn8gZEABZMRn2UQkYKkrUQtUoQWFgBTyItNISpgL OomRNHhv56CwICwHWrCcqYxURZSW6fqQgVDqAI5EwD+01Ozj3/kEmzehIxlKg5TDzfvP BdjBoft5Y2bZemAnKgJcSyjKNWQNJqIm9ZDj0ygTyiZCGZ0V6CaaDu1b9BwhxJAwEcPD CdyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/4l9UpfpZvlcAJNqS1oueUKAgaTadj3L3dcu3aCeFd0=; b=SuI5ZQSzURGBY9t6udLowMbI4WMHm6dsNt9HDVK+x00xCucK7pQS/eEK6osoNCnui2 kxNa9r3r2fzRMeP24C2fszSsjUUoWOaaWVQb7zmkAqN0+kQCEjWRZL5p1f5a43sabKfE xUWQriNv64GXPu7p1JJCUBRn54xHqlLgqwawUCOG5ZegUBxzKHCh8F61nJihyn3C6f9L fAwuEiDyzmx/KTxj27mphrRp2GK++1JpzNR4zoPUCwbvlorirJmsR0tHrbpZU1nvI1rj +WvBnctBbCkT6zWJE6T0Aj/Pfo8KfXmXizN9xSncESWiq1Qq9LzZGVTeSVHiIU9sddQB 1YkQ== X-Gm-Message-State: AOAM530NVeF58/SWGA724ObBdMOIw8mETQ45hvcxiI9tuAsnJfwKRImw bq0DzyapjL+Q8fjhGf9tzvhYFKW34m4OLQ== X-Google-Smtp-Source: ABdhPJzBbsuMAlzgo6pQRHAkbRYqahbSlTQixxFF9G+xUmm2lvGRQeddunENZlSax7WELSUAX1/xvA== X-Received: by 2002:adf:fa81:: with SMTP id h1mr7890427wrr.27.1637058278542; Tue, 16 Nov 2021 02:24:38 -0800 (PST) Received: from abel.fritz.box (p57b0b77b.dip0.t-ipconnect.de. [87.176.183.123]) by smtp.gmail.com with ESMTPSA id 4sm22119334wrz.90.2021.11.16.02.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 02:24:38 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Tue, 16 Nov 2021 11:24:29 +0100 Message-Id: <20211116102431.198905-5-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116102431.198905-1-christian.koenig@amd.com> References: <20211116102431.198905-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 16 Nov 2021 14:05:08 +0000 Subject: [Intel-gfx] [PATCH 4/6] drm/i915: use new cursor in intel_prepare_plane_fb v2 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Simplifying the code a bit. v2: rebased Signed-off-by: Christian König Acked-by: Daniel Vetter --- drivers/gpu/drm/i915/display/intel_atomic_plane.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c index 0be8c00e3db9..cdc68fb51ba6 100644 --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c @@ -738,6 +738,7 @@ intel_prepare_plane_fb(struct drm_plane *_plane, i915_gem_object_wait_priority(obj, 0, &attr); if (!new_plane_state->uapi.fence) { /* implicit fencing */ + struct dma_resv_iter cursor; struct dma_fence *fence; ret = i915_sw_fence_await_reservation(&state->commit_ready, @@ -748,12 +749,12 @@ intel_prepare_plane_fb(struct drm_plane *_plane, if (ret < 0) goto unpin_fb; - fence = dma_resv_get_excl_unlocked(obj->base.resv); - if (fence) { + dma_resv_iter_begin(&cursor, obj->base.resv, false); + dma_resv_for_each_fence_unlocked(&cursor, fence) { add_rps_boost_after_vblank(new_plane_state->hw.crtc, fence); - dma_fence_put(fence); } + dma_resv_iter_end(&cursor); } else { add_rps_boost_after_vblank(new_plane_state->hw.crtc, new_plane_state->uapi.fence); From patchwork Tue Nov 16 10:24:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 12622423 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45004C433EF for ; Tue, 16 Nov 2021 14:05:16 +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 107A361BE6 for ; Tue, 16 Nov 2021 14:05:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 107A361BE6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D08CB6EA4F; Tue, 16 Nov 2021 14:05:09 +0000 (UTC) Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by gabe.freedesktop.org (Postfix) with ESMTPS id A09706E1B5; Tue, 16 Nov 2021 10:24:40 +0000 (UTC) Received: by mail-wm1-x332.google.com with SMTP id o29so16434339wms.2; Tue, 16 Nov 2021 02:24:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Yvjc1coossNdhTK2oO9Fca5G2s5nGciyVwZQ1Y878tM=; b=LFLLXW935M50vLPFjT34+6ReA2hmr6HNS/Hn3hM9AVYVXMSBB/tEC+tmzgpBHRmoB5 OGvlB+A7EzYowh3TIH8XK8Iigo1yg5vJG1zRA8IWyRlhw8qgBjqCaAoRi6YzywEjyusG KkIWYFeWPyGOGNCzs3rHu1EuZfaiMQxPX0+bfwFyuIwa6uWRKySQ9g3SfnlSqsMhf82k LmqYHSqYbSVouGgf6omoSqwMmFCBLEeoBZdryzIAzNneXMw5hyCRWyaqmhGlatdO4JvF Sd7+aZYgTpxif3RRdPkyRutGOBpb19oF9ji/YlOVT5VHSUWXw9cx2r8MGlwdbGHnMhjg bXjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Yvjc1coossNdhTK2oO9Fca5G2s5nGciyVwZQ1Y878tM=; b=mTpNNE5WqK0aEoWnq9x0O6S/yhir4OeUlUzHbO7Bf01EfxBFA/fy/7SoM9fwk8PzBW ljEvF3UDczB6DPz2hsdb99p94V2YAgcN2Qb3eVfOKkp/gxcUllQWxzeGJc+czScqKy53 9y86VsFa/xZyIYOIccyXxHn/r7OF9vAM5LBnGtFDKq8g+hq2FxPEVEN5pVhywEy/U6qD OYBr6g8NiyEWXXTQ7sFD1Q4x79K5ppnPv03kklhuWFxl5LyDkDEl9b6D7JDLCC5Zsu0R m+aX8SxbJyJ9cA90kCVgj03CKVHQFaTbhemAILMNjpAl3dvkNgy6VLEYvB9qfMrf6Ztz qkyA== X-Gm-Message-State: AOAM530/BETkX4m7EIKH14w4NIbmmMxWkDzOidus2C7SAtzGynyHMpDR 9Ohn5Q07/d5rm4gXiYS8mdeM/t0UqkRsCA== X-Google-Smtp-Source: ABdhPJzk5CGDuYi33Uf2z1TBRx528jNnRqlGsMxdAvBoYGBq9hdF+1XbdEewIOdEBTVc6cQWmAjcxg== X-Received: by 2002:a1c:ed1a:: with SMTP id l26mr69866612wmh.19.1637058279210; Tue, 16 Nov 2021 02:24:39 -0800 (PST) Received: from abel.fritz.box (p57b0b77b.dip0.t-ipconnect.de. [87.176.183.123]) by smtp.gmail.com with ESMTPSA id 4sm22119334wrz.90.2021.11.16.02.24.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 02:24:38 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Tue, 16 Nov 2021 11:24:30 +0100 Message-Id: <20211116102431.198905-6-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116102431.198905-1-christian.koenig@amd.com> References: <20211116102431.198905-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 16 Nov 2021 14:05:08 +0000 Subject: [Intel-gfx] [PATCH 5/6] drm/i915: Fix i915_request fence wait semantics X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Maarten Lankhorst The i915_request fence wait behaves differently for timeout = 0 compared to expected dma-fence behavior. i915 behavior: - Unsignaled: -ETIME - Signaled: 0 (= timeout) Expected: - Unsignaled: 0 - Signaled: 1 Signed-off-by: Maarten Lankhorst Acked-by: Daniel Vetter Acked-by: Christian König --- drivers/gpu/drm/i915/i915_request.c | 57 ++++++++++++++++++++++++----- drivers/gpu/drm/i915/i915_request.h | 5 +++ 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c index 820a1f38b271..42cd17357771 100644 --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c @@ -96,9 +96,9 @@ static signed long i915_fence_wait(struct dma_fence *fence, bool interruptible, signed long timeout) { - return i915_request_wait(to_request(fence), - interruptible | I915_WAIT_PRIORITY, - timeout); + return i915_request_wait_timeout(to_request(fence), + interruptible | I915_WAIT_PRIORITY, + timeout); } struct kmem_cache *i915_request_slab_cache(void) @@ -1857,23 +1857,27 @@ static void request_wait_wake(struct dma_fence *fence, struct dma_fence_cb *cb) } /** - * i915_request_wait - wait until execution of request has finished + * i915_request_wait_timeout - wait until execution of request has finished * @rq: the request to wait upon * @flags: how to wait * @timeout: how long to wait in jiffies * - * i915_request_wait() waits for the request to be completed, for a + * i915_request_wait_timeout() waits for the request to be completed, for a * maximum of @timeout jiffies (with MAX_SCHEDULE_TIMEOUT implying an * unbounded wait). * * Returns the remaining time (in jiffies) if the request completed, which may - * be zero or -ETIME if the request is unfinished after the timeout expires. + * be zero if the request is unfinished after the timeout expires. + * If the timeout is 0, it will return 1 if the fence is signaled. + * * May return -EINTR is called with I915_WAIT_INTERRUPTIBLE and a signal is * pending before the request completes. + * + * NOTE: This function has the same wait semantics as dma-fence. */ -long i915_request_wait(struct i915_request *rq, - unsigned int flags, - long timeout) +long i915_request_wait_timeout(struct i915_request *rq, + unsigned int flags, + long timeout) { const int state = flags & I915_WAIT_INTERRUPTIBLE ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE; @@ -1883,7 +1887,7 @@ long i915_request_wait(struct i915_request *rq, GEM_BUG_ON(timeout < 0); if (dma_fence_is_signaled(&rq->fence)) - return timeout; + return timeout ?: 1; if (!timeout) return -ETIME; @@ -1992,6 +1996,39 @@ long i915_request_wait(struct i915_request *rq, return timeout; } +/** + * i915_request_wait - wait until execution of request has finished + * @rq: the request to wait upon + * @flags: how to wait + * @timeout: how long to wait in jiffies + * + * i915_request_wait() waits for the request to be completed, for a + * maximum of @timeout jiffies (with MAX_SCHEDULE_TIMEOUT implying an + * unbounded wait). + * + * Returns the remaining time (in jiffies) if the request completed, which may + * be zero or -ETIME if the request is unfinished after the timeout expires. + * May return -EINTR is called with I915_WAIT_INTERRUPTIBLE and a signal is + * pending before the request completes. + * + * NOTE: This function behaves differently from dma-fence wait semantics for + * timeout = 0. It returns 0 on success, and -ETIME if not signaled. + */ +long i915_request_wait(struct i915_request *rq, + unsigned int flags, + long timeout) +{ + long ret = i915_request_wait_timeout(rq, flags, timeout); + + if (!ret) + return -ETIME; + + if (ret > 0 && !timeout) + return 0; + + return ret; +} + static int print_sched_attr(const struct i915_sched_attr *attr, char *buf, int x, int len) { diff --git a/drivers/gpu/drm/i915/i915_request.h b/drivers/gpu/drm/i915/i915_request.h index dc359242d1ae..3c6e8acd1457 100644 --- a/drivers/gpu/drm/i915/i915_request.h +++ b/drivers/gpu/drm/i915/i915_request.h @@ -414,6 +414,11 @@ void i915_request_unsubmit(struct i915_request *request); void i915_request_cancel(struct i915_request *rq, int error); +long i915_request_wait_timeout(struct i915_request *rq, + unsigned int flags, + long timeout) + __attribute__((nonnull(1))); + long i915_request_wait(struct i915_request *rq, unsigned int flags, long timeout) From patchwork Tue Nov 16 10:24:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 12622425 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5202FC433EF for ; Tue, 16 Nov 2021 14:05:18 +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 1BDA761B48 for ; Tue, 16 Nov 2021 14:05:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1BDA761B48 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4C09F6EA54; Tue, 16 Nov 2021 14:05:10 +0000 (UTC) Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4F1106E3AA; Tue, 16 Nov 2021 10:24:41 +0000 (UTC) Received: by mail-wm1-x329.google.com with SMTP id 133so16462154wme.0; Tue, 16 Nov 2021 02:24:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=I/M6sTf7ATt/rzPF6URMkni7yX+VjLJUHjt0X/PXmv0=; b=ndZTe8Y9mlxRHD1/+xdtSC+e40sWXeMCSvdJBE/wZWd1iPQNL2mCLaVO2X02xni34g BFyog4vXPqQU6eshAPpGRbAETCP64JTuaqhtpjWB2/15fHa/gSwAG21xWns45cmWUvsc EL8x6wIxcyeBwbF0VgPBPiRRXyKufLTDiUX1PMclWY7frcVcOoe5Pad8jUxbae+VaMAk NneDHDX8LDSZGfCrEAeYWnDXUZoO4S2XDaIKieyPXktKsXUTHq671Uv8WE80btsx/TA9 sxYMNsUQp0LD18i8n4Ps1xh8ewlvcs3raWp55sH3fe49WQgIQbpw13qh0Dd/GmKJEOsQ K28g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I/M6sTf7ATt/rzPF6URMkni7yX+VjLJUHjt0X/PXmv0=; b=MVSdhg1tzmjUN5LCfiER9omDCMyD+tL3EcKhKG43L9LNI8YBPJ3xba5dj8Wgc6uxt5 UIUdya1YyXqEWpokhKIu/D1Vj9pCXoq44KQTi4FtyNuYsSMwlK7tTRn0acGOexddoT9S 4jsA/UuUr/DFd2DImrR0OXZ3EgK5NbYnRW5/1kQ/qFqRIqq8Bv1/2kJF60pfdQpQYKmX 5ijs+sIAKqCGbeqre5UJY88Qq/IZZj2/77z52rAt/o5hTTCk7PKxvDyA6pARWBzoJprq uJ9u03pMm0mqOmqeFBizxN6aVeqwh5rPfDVEiqJWmJBaYXSwoIhNadOsZqd1S93SJ3BK HmlA== X-Gm-Message-State: AOAM531URECACvVd6Fx5pODaXEuzDVQGRpmO+N+9M40K44Pcu8ItQdWS neXJxjjPnB/7iVp240K1hrKfqDCerxpbtw== X-Google-Smtp-Source: ABdhPJyVjz3Wm6UD2lJOaHzrThq4QhzjSSQzJdbbe9KcUHIUpL+a0yNteV2Wyp/AmL4ZtAwD6gqw/A== X-Received: by 2002:a1c:cc09:: with SMTP id h9mr6658826wmb.191.1637058279891; Tue, 16 Nov 2021 02:24:39 -0800 (PST) Received: from abel.fritz.box (p57b0b77b.dip0.t-ipconnect.de. [87.176.183.123]) by smtp.gmail.com with ESMTPSA id 4sm22119334wrz.90.2021.11.16.02.24.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 02:24:39 -0800 (PST) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Tue, 16 Nov 2021 11:24:31 +0100 Message-Id: <20211116102431.198905-7-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116102431.198905-1-christian.koenig@amd.com> References: <20211116102431.198905-1-christian.koenig@amd.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 16 Nov 2021 14:05:08 +0000 Subject: [Intel-gfx] [PATCH 6/6] drm/i915: use new iterator in i915_gem_object_wait_reservation X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Simplifying the code a bit. Signed-off-by: Christian König [mlankhorst: Handle timeout = 0 correctly, use new i915_request_wait_timeout.] Signed-off-by: Maarten Lankhorst Acked-by: Daniel Vetter --- drivers/gpu/drm/i915/gem/i915_gem_wait.c | 63 +++++++----------------- 1 file changed, 19 insertions(+), 44 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_wait.c b/drivers/gpu/drm/i915/gem/i915_gem_wait.c index 34e46134326b..f11325484110 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_wait.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_wait.c @@ -25,7 +25,7 @@ i915_gem_object_wait_fence(struct dma_fence *fence, return timeout; if (dma_fence_is_i915(fence)) - return i915_request_wait(to_request(fence), flags, timeout); + return i915_request_wait_timeout(to_request(fence), flags, timeout); return dma_fence_wait_timeout(fence, flags & I915_WAIT_INTERRUPTIBLE, @@ -37,58 +37,29 @@ i915_gem_object_wait_reservation(struct dma_resv *resv, unsigned int flags, long timeout) { - struct dma_fence *excl; - bool prune_fences = false; - - if (flags & I915_WAIT_ALL) { - struct dma_fence **shared; - unsigned int count, i; - int ret; - - ret = dma_resv_get_fences(resv, &excl, &count, &shared); - if (ret) - return ret; - - for (i = 0; i < count; i++) { - timeout = i915_gem_object_wait_fence(shared[i], - flags, timeout); - if (timeout < 0) - break; - - dma_fence_put(shared[i]); - } + struct dma_resv_iter cursor; + struct dma_fence *fence; + long ret = timeout ?: 1; - for (; i < count; i++) - dma_fence_put(shared[i]); - kfree(shared); + dma_resv_iter_begin(&cursor, resv, flags & I915_WAIT_ALL); + dma_resv_for_each_fence_unlocked(&cursor, fence) { + ret = i915_gem_object_wait_fence(fence, flags, timeout); + if (ret <= 0) + break; - /* - * If both shared fences and an exclusive fence exist, - * then by construction the shared fences must be later - * than the exclusive fence. If we successfully wait for - * all the shared fences, we know that the exclusive fence - * must all be signaled. If all the shared fences are - * signaled, we can prune the array and recover the - * floating references on the fences/requests. - */ - prune_fences = count && timeout >= 0; - } else { - excl = dma_resv_get_excl_unlocked(resv); + if (timeout) + timeout = ret; } - - if (excl && timeout >= 0) - timeout = i915_gem_object_wait_fence(excl, flags, timeout); - - dma_fence_put(excl); + dma_resv_iter_end(&cursor); /* * Opportunistically prune the fences iff we know they have *all* been * signaled. */ - if (prune_fences) + if (timeout > 0) dma_resv_prune(resv); - return timeout; + return ret; } static void fence_set_priority(struct dma_fence *fence, @@ -177,7 +148,11 @@ i915_gem_object_wait(struct drm_i915_gem_object *obj, timeout = i915_gem_object_wait_reservation(obj->base.resv, flags, timeout); - return timeout < 0 ? timeout : 0; + + if (timeout < 0) + return timeout; + + return !timeout ? -ETIME : 0; } static inline unsigned long nsecs_to_jiffies_timeout(const u64 n)