From patchwork Fri Sep 3 18:47:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 12474979 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 36D75C433F5 for ; Fri, 3 Sep 2021 18:44:14 +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 038416054E for ; Fri, 3 Sep 2021 18:44:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 038416054E 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 4F00A6E8C9; Fri, 3 Sep 2021 18:44:09 +0000 (UTC) Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by gabe.freedesktop.org (Postfix) with ESMTPS id E975B6E8C9 for ; Fri, 3 Sep 2021 18:44:07 +0000 (UTC) Received: by mail-pf1-x42e.google.com with SMTP id x19so202916pfu.4 for ; Fri, 03 Sep 2021 11:44:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cSCNJkR9V6raam7Le5SSEi0f1yOJhVw/gdH+2wLQ7eE=; b=DYJBiQVkX93WaSJ4W7BfYts1uK4po2qitkNdbPZBac1eMDeI9wgw34HGarDstiePLx XyrGkdeLiIr2IK7uSQNhq0+x/0RRUjHsGaNHMJk4wdMyAvmio28Vfoqhk2Tehao+WBRn mr9uVKZLlvKL3iIcGQ2bd5iI/On7d88mpI3KmPLHW2pvwIhWqYHEVkDujvHhStvvl8sF MpfXyLsy+1Xp6PS0Gnl5Ru89iwl+el0dhV+9iXkc5tD+I23iBuyqjWpH8Fc6t82qGhOT jKwC0ddXF6szUn2FOA/QpGgBwdhShbjY8IP++bvJg5eHMO4JWUV6OV7RIJF3tEvKEdJ7 ooEQ== 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=cSCNJkR9V6raam7Le5SSEi0f1yOJhVw/gdH+2wLQ7eE=; b=hyDgCIq1/jr5i+SNmaEC56d+OCIOoAP4MU7IhrXu6XUjmoQEzm45/4m2wqSoA7QLM8 j2jidEmUckuGKJw1vX2x3eqvUcwnMeBTCbrrtoHm7WWSVnNJnLpLG9qZUVgit5dZ6REA 26TaesSa0QNCCHdobiIvKCPdA35eU9rux833IRoTRliJZwqr6XLdgLkMZtgSiwSV+wwB x1haEEpTf67MFVVs9rojvF82WKr9DGngRvV84AkwQ2TVb6hpsRODTDSsIU8cNdPaUVg3 wucRg1y3Jdowyl7dWq1WmtOGYWDfpAalGVjsbaOj8y3brsXRnbsPUgttmNr7f4luYesF 6OZw== X-Gm-Message-State: AOAM533YnD8Ofh40RKEco9P+ySZ9bZs+dXfpoUKaRxDIG4paW3dShbGU VwAq+kKQ25n4bZ+t2NL3T8k7ZJbOS8o= X-Google-Smtp-Source: ABdhPJyigIiNAB8BtDmDh/qK7OSsffWeFcfu4PJL/ieFiTjF0teQrB8CoJp3e6ZiEM5k4dcyNEJqPw== X-Received: by 2002:a63:4c0e:: with SMTP id z14mr357640pga.427.1630694646866; Fri, 03 Sep 2021 11:44:06 -0700 (PDT) Received: from localhost (c-73-25-156-94.hsd1.or.comcast.net. [73.25.156.94]) by smtp.gmail.com with ESMTPSA id j1sm21218pjz.36.2021.09.03.11.44.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 11:44:05 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Cc: Daniel Vetter , =?utf-8?q?Christian_K=C3=B6nig?= , =?utf-8?q?Michel_D=C3=A4nzer?= , Pekka Paalanen , Rob Clark , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 3/9] drm/atomic-helper: Set fence deadline for vblank Date: Fri, 3 Sep 2021 11:47:54 -0700 Message-Id: <20210903184806.1680887-4-robdclark@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210903184806.1680887-1-robdclark@gmail.com> References: <20210903184806.1680887-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: , 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 2c0c6ec92820..3322dafd675f 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -1407,6 +1407,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_time(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 @@ -1436,6 +1470,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;