Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp271305pxb; Wed, 3 Feb 2021 05:20:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYx8/IcxFOvwe7h0GHwj3Uk4Io5abpqkZlTRE1NFlBBeRdYkrBsKne+O0LDfowovl+tmRm X-Received: by 2002:a05:6402:31ae:: with SMTP id dj14mr2882034edb.364.1612358443744; Wed, 03 Feb 2021 05:20:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612358443; cv=none; d=google.com; s=arc-20160816; b=RsezmniKFkYiuTKC5K2CjwduPvgmUM11qbTa5nHl8t3hZ+sKQUymUZ0BxDFFTx3GFL MdnqYnxvsR0Eh8hkHVyFUd79SAwySSuYr7m8NygAQvAZMcFBA7sMVI1ewtikWz6ZLq/1 pnBWCcoSmQDQawNCCVuGn/VV4VFfVOgWdeSV+ikZVeI5HqhVj/hprApkokblY8RdnqSb IJVIQo7mKrNlfIqRxTVaVGXVJzbUMDmqrtYVgGImsNs+jsoEpCzxxVgAxs+iyd9Eok3w rdx2WcBEwW77OH0BS2SHXYuhwWrOdd8SIIQFzCbvLUcKZRA4FfocAy/sljw0heCS7veZ 1cSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jIQiGfgSUKUQ4lTI2ex1yiuCPVjrmXrlcR2znxklmvA=; b=skzUobBmZF8OqBW9f3be16z8DpfRklMBSHDoYqaOTrncqKGKWmPD4wQKMhz5PBsvx0 AnXDZmzQdP5Bug+gorhRj4WowGna3mpN2rzeLRuipfnxiOLw5GyN4EE7kovzVoAQF9t2 6TsqWbXEnJDaF9T20TR9XHBts3E/eL0Df5ZCDQFINCzI65roQGGdW9TKRFHbCIxOCGzN /C9jvDUkvCFPRyL9uw0w4A87eLGOMTITa68Fmmnxsso91yiJIiaz2NPdDIjyh47XHYol eSCAl5U+wfFlwbESNLexGekXYBnqaVOSGULm2H6LOd+PgzQkOu7glbJ4F8ki639hf/e5 r75Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UrWKaFWk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i3si1375328ejz.79.2021.02.03.05.20.17; Wed, 03 Feb 2021 05:20:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UrWKaFWk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230437AbhBCNR7 (ORCPT + 99 others); Wed, 3 Feb 2021 08:17:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:47302 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231310AbhBCNR4 (ORCPT ); Wed, 3 Feb 2021 08:17:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612358189; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jIQiGfgSUKUQ4lTI2ex1yiuCPVjrmXrlcR2znxklmvA=; b=UrWKaFWkeoKezU3w0TCMahcFdy69bgyfan81OhEFxc/kFMCrG/xcnXjViB5mKsgIHqpcQf kCHxbHTiEpJGEquLgazp7AoaV5rGNXy7wdBAKhaKKP5lpmACGCnBOdH7l8qxES7Wreu/iQ T4PMCPR/xcKTgWOOItUmcYlV6SClj2k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-310-P3MjeksvMd-vYzW12ilQag-1; Wed, 03 Feb 2021 08:16:26 -0500 X-MC-Unique: P3MjeksvMd-vYzW12ilQag-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E7B6C107ACE6; Wed, 3 Feb 2021 13:16:24 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-113-27.ams2.redhat.com [10.36.113.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B7D8C60C5F; Wed, 3 Feb 2021 13:16:21 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 09075180085A; Wed, 3 Feb 2021 14:16:16 +0100 (CET) From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org Cc: Gerd Hoffmann , Dave Airlie , David Airlie , Daniel Vetter , virtualization@lists.linux-foundation.org (open list:DRM DRIVER FOR QXL VIRTUAL GPU), spice-devel@lists.freedesktop.org (open list:DRM DRIVER FOR QXL VIRTUAL GPU), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 6/6] drm/qxl: simplify qxl_fence_wait Date: Wed, 3 Feb 2021 14:16:15 +0100 Message-Id: <20210203131615.1714021-7-kraxel@redhat.com> In-Reply-To: <20210203131615.1714021-1-kraxel@redhat.com> References: <20210203131615.1714021-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we have the new release_event wait queue we can just use that in qxl_fence_wait() and simplify the code alot. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/qxl/qxl_release.c | 42 +++---------------------------- 1 file changed, 4 insertions(+), 38 deletions(-) diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c index 43a5436853b7..b6f4b8dcf228 100644 --- a/drivers/gpu/drm/qxl/qxl_release.c +++ b/drivers/gpu/drm/qxl/qxl_release.c @@ -59,53 +59,19 @@ static long qxl_fence_wait(struct dma_fence *fence, bool intr, { struct qxl_device *qdev; struct qxl_release *release; - int count = 0, sc = 0; - bool have_drawable_releases; unsigned long cur, end = jiffies + timeout; qdev = container_of(fence->lock, struct qxl_device, release_lock); release = container_of(fence, struct qxl_release, base); - have_drawable_releases = release->type == QXL_RELEASE_DRAWABLE; - -retry: - sc++; if (dma_fence_is_signaled(fence)) goto signaled; qxl_io_notify_oom(qdev); - - for (count = 0; count < 11; count++) { - if (!qxl_queue_garbage_collect(qdev, true)) - break; - - if (dma_fence_is_signaled(fence)) - goto signaled; - } - - if (dma_fence_is_signaled(fence)) - goto signaled; - - if (have_drawable_releases || sc < 4) { - if (sc > 2) - /* back off */ - usleep_range(500, 1000); - - if (time_after(jiffies, end)) - return 0; - - if (have_drawable_releases && sc > 300) { - DMA_FENCE_WARN(fence, "failed to wait on release %llu " - "after spincount %d\n", - fence->context & ~0xf0000000, sc); - goto signaled; - } - goto retry; - } - /* - * yeah, original sync_obj_wait gave up after 3 spins when - * have_drawable_releases is not set. - */ + if (!wait_event_timeout(qdev->release_event, + dma_fence_is_signaled(fence), + timeout)) + return 0; signaled: cur = jiffies; -- 2.29.2