From patchwork Fri Feb 24 20:01:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13151783 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id EE9FEC6FA8E for ; Fri, 24 Feb 2023 20:02:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 322F910ED12; Fri, 24 Feb 2023 20:02:50 +0000 (UTC) Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8042A10ED02; Fri, 24 Feb 2023 20:02:21 +0000 (UTC) Received: by mail-pf1-x42a.google.com with SMTP id z11so136026pfh.4; Fri, 24 Feb 2023 12:02:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MXVtv6kxe3TDMQ2pw6mJDt0CFb+4GUA2rpUfR00AfQQ=; b=aPE3MZ7QQuZoD5+LGINDsHbNmjt8oh652eQP/MXvfbKHVNHLGY2jMwu+RXp/nZ1aUh g14nAqn6FmzLtuvzwD7Xgtmw4UNDm6/qkBIofrbKtJPGvcy1djnYWaSlvUXeW7QTWBWY JMoU8IwGO0Si3emDqozuVcZC9GHt+mVLZLE2No2WRIwDcGPd3ps6XCvr9ufX7cY9+qoj adAZY/y9dZK40ujexAfEZIZgkdUVJ9kAtedOfS50mbfjBQ1KP4Nykc/5pNbCWpbkaMdi wFRLzDExT6pMeHikZU1jt0g9sRjXXBl5U1/Nn3hrTHfduKrXexv2tFOtqp70nSACZYXk nCVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MXVtv6kxe3TDMQ2pw6mJDt0CFb+4GUA2rpUfR00AfQQ=; b=HtHroNVriUt6LkF2flS/WaJOheKMiEO/dwxzf8BOGEojuqRwDn+T38VIZo6dubJrOj wGqa/a2E6GvtPTVdB56Y2bK7JNdswXeYH4SXoikVFLdmo+9SFVrIMhhY2INHdIATUP4q f6UzdELfsYkRIdAS7FwZKvg+z3NCZR0pwgfena2lAalDpDm+tqQotT+TZDWMLtl8VXfv /BY/91XvrLxW2Xk4v35RWtShzN9QFMNYeF8GGRETK8N9TkilN4vrexQ1hh6zi65Phg8g ZSk6epaR0Cgd4ww/iF/dPysgje0gtwZ1ghFdVRomGKS0tYcPa4yDc2KU/15yzXAVnWDW hOzw== X-Gm-Message-State: AO0yUKVn92W1oW3Wp+5hJ+sHxzND4HPmtGE4PZwg1/FWfT18xafMwxg7 UY7JwTZckHBXsFz4fXTia72nvttrJgk= X-Google-Smtp-Source: AK7set8iCcnhfJ0pgKgYusRmBK5mKzDmKBZZZyguSD6rXOPY07ODicabelyFMwmH27l/yS1spJfo3Q== X-Received: by 2002:a62:1dd0:0:b0:5aa:6125:dbf4 with SMTP id d199-20020a621dd0000000b005aa6125dbf4mr13512105pfd.11.1677268940762; Fri, 24 Feb 2023 12:02:20 -0800 (PST) Received: from localhost ([2a00:79e1:abd:4a00:61b:48ed:72ab:435b]) by smtp.gmail.com with ESMTPSA id h5-20020a62b405000000b005d6dff9bbecsm5223958pfn.62.2023.02.24.12.02.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 12:02:20 -0800 (PST) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH v6 11/15] drm/atomic-helper: Set fence deadline for vblank Date: Fri, 24 Feb 2023 12:01:39 -0800 Message-Id: <20230224200155.2510320-12-robdclark@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230224200155.2510320-1-robdclark@gmail.com> References: <20230224200155.2510320-1-robdclark@gmail.com> 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: Rob Clark , Thomas Zimmermann , Tvrtko Ursulin , =?utf-8?q?Christian_K=C3=B6nig?= , =?utf-8?q?Michel_D=C3=A4nzer?= , open list , Daniel Vetter , Pekka Paalanen , Luben Tuikov , Rodrigo Vivi , Alex Deucher , freedreno@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rob Clark For an atomic commit updating a single CRTC (ie. a pageflip) calculate the next vblank time, and inform the fence(s) of that deadline. v2: Comment typo fix (danvet) Signed-off-by: Rob Clark Reviewed-by: Daniel Vetter Signed-off-by: Rob Clark --- drivers/gpu/drm/drm_atomic_helper.c | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index d579fd8f7cb8..d8ee98ce2fc5 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -1511,6 +1511,40 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev, } EXPORT_SYMBOL(drm_atomic_helper_commit_modeset_enables); +/* + * For atomic updates which touch just a single CRTC, calculate the time of the + * next vblank, and inform all the fences of the deadline. + */ +static void set_fence_deadline(struct drm_device *dev, + struct drm_atomic_state *state) +{ + struct drm_crtc *crtc, *wait_crtc = NULL; + struct drm_crtc_state *new_crtc_state; + struct drm_plane *plane; + struct drm_plane_state *new_plane_state; + ktime_t vbltime; + int i; + + for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) { + if (wait_crtc) + return; + wait_crtc = crtc; + } + + /* If no CRTCs updated, then nothing to do: */ + if (!wait_crtc) + return; + + if (drm_crtc_next_vblank_start(wait_crtc, &vbltime)) + return; + + for_each_new_plane_in_state (state, plane, new_plane_state, i) { + if (!new_plane_state->fence) + continue; + dma_fence_set_deadline(new_plane_state->fence, vbltime); + } +} + /** * drm_atomic_helper_wait_for_fences - wait for fences stashed in plane state * @dev: DRM device @@ -1540,6 +1574,8 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev, struct drm_plane_state *new_plane_state; int i, ret; + set_fence_deadline(dev, state); + for_each_new_plane_in_state(state, plane, new_plane_state, i) { if (!new_plane_state->fence) continue;