From patchwork Thu Nov 9 17:24:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 13451572 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 5FC45C4167B for ; Thu, 9 Nov 2023 17:26:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BCF1410E220; Thu, 9 Nov 2023 17:25:52 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 75AC110E0E2 for ; Thu, 9 Nov 2023 17:25:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699550711; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3EBII1piFhjDdYePPF4sEFQnIWSSXfwKWEcUhw8jHaI=; b=boegv2tWzzU6lnWD9C2PAVJIgSLu7mfTT+zOZg+r09pvBHQQFDf6PLasU9Ra7YU997Z1/T y3orylevIpFzCwj0cHI3GquqftTCMgh/MxAgJLfQYZ54OGpUtvBS8FnxZjjt+C0TSyD5pp b/SV/ekIWoZTaTLZG4kKNnUyrNOsb+4= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-372-lbH3gCnuPdC1K5ha5oKLbA-1; Thu, 09 Nov 2023 12:25:09 -0500 X-MC-Unique: lbH3gCnuPdC1K5ha5oKLbA-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-507b9078aaaso1101001e87.2 for ; Thu, 09 Nov 2023 09:25:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699550708; x=1700155508; 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=3EBII1piFhjDdYePPF4sEFQnIWSSXfwKWEcUhw8jHaI=; b=AfzJvbF52zy3v4wIL4mHX4FUM5J178MpNBqLiJgURDsz9Kvsf8xCcI6f0cS8PoWJet eRu3xwz13LXWokJCe6rtY+/uaBpSDizI0EXnUu94F3N+N53XatoDGEL0mUrLTbjmTr6+ 9/+f9k7/gar5UyhHG61OUHisH06Ret9yQcQIm1mv0QyLfZuduTThqfdN8g8lEPb6tfQ/ XLP3AGb2r1sQZGEJJQwd8pXneJleVwTBEekOgcnuoeUoB7Unjc5lwixwOX+gER8Kn+5U Ab+u4yJI5us06kPnoUj0NbieqaXDptXx6t5Yw7w1M816QcQyix9jkce6gUjwgLwG5haB ePGA== X-Gm-Message-State: AOJu0Yw3rq41z4rRZQyxLpk8pT3UDBOY1qY710JuXRYgbD0LqdjGHh5K llWoRNLLFUy3DPQtSbxLjNBJFHNvDaGdWUKsNcHZyxBdCgNOuSr3oWrF5t2/0e/nVyO10BWJZtV z42VeZuvJ0k2v9QAHjIjcDFdPfRYH X-Received: by 2002:a19:e00d:0:b0:503:32bb:d5ca with SMTP id x13-20020a19e00d000000b0050332bbd5camr1864082lfg.31.1699550708377; Thu, 09 Nov 2023 09:25:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IH47EfQ6rX+t1XL8dC+Is/tx0yp1WtqPF4aXtdXPWPqw3Pqau19ZWSC5+9vmC1RAuAaGC1wqw== X-Received: by 2002:a19:e00d:0:b0:503:32bb:d5ca with SMTP id x13-20020a19e00d000000b0050332bbd5camr1864072lfg.31.1699550707984; Thu, 09 Nov 2023 09:25:07 -0800 (PST) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id q14-20020a05600000ce00b003143c9beeaesm133795wrx.44.2023.11.09.09.25.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 09:25:07 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH 1/6] drm: Move drm_atomic_helper_damage_{iter_init, merged}() to helpers Date: Thu, 9 Nov 2023 18:24:35 +0100 Message-ID: <20231109172449.1599262-2-javierm@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231109172449.1599262-1-javierm@redhat.com> References: <20231109172449.1599262-1-javierm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: dri-devel@lists.freedesktop.org, Gerd Hoffmann , nerdopolis , Pekka Paalanen , Thomas Zimmermann , Bilal Elmoussaoui , Javier Martinez Canillas , Maxime Ripard , stable@vger.kernel.org, Sima Vetter , Erico Nunes Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We need a similar drm_atomic_helper_buffer_damage_merged() helper function that takes into account if a framebuffer attached to the plane has changed since the last plane update (page-flip). Since both damage helpers will share most of the current logic, move it to an internal helper. The drm_atomic_helper_buffer_damage_merged() will have to use a different drm_atomic_helper_buffer_damage_iter_init() function so move that logic also to an internal helper. Fixes: 01f05940a9a7 ("drm/virtio: Enable fb damage clips property for the primary plane") Cc: # v6.4+ Reported-by: nerdopolis Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218115 Suggested-by: Sima Vetter Signed-off-by: Javier Martinez Canillas --- drivers/gpu/drm/drm_damage_helper.c | 95 +++++++++++++++++------------ 1 file changed, 55 insertions(+), 40 deletions(-) diff --git a/drivers/gpu/drm/drm_damage_helper.c b/drivers/gpu/drm/drm_damage_helper.c index d8b2955e88fd..aa2325567918 100644 --- a/drivers/gpu/drm/drm_damage_helper.c +++ b/drivers/gpu/drm/drm_damage_helper.c @@ -201,28 +201,10 @@ int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb, } EXPORT_SYMBOL(drm_atomic_helper_dirtyfb); -/** - * drm_atomic_helper_damage_iter_init - Initialize the damage iterator. - * @iter: The iterator to initialize. - * @old_state: Old plane state for validation. - * @state: Plane state from which to iterate the damage clips. - * - * Initialize an iterator, which clips plane damage - * &drm_plane_state.fb_damage_clips to plane &drm_plane_state.src. This iterator - * returns full plane src in case damage is not present because either - * user-space didn't sent or driver discarded it (it want to do full plane - * update). Currently this iterator returns full plane src in case plane src - * changed but that can be changed in future to return damage. - * - * For the case when plane is not visible or plane update should not happen the - * first call to iter_next will return false. Note that this helper use clipped - * &drm_plane_state.src, so driver calling this helper should have called - * drm_atomic_helper_check_plane_state() earlier. - */ -void -drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, - const struct drm_plane_state *old_state, - const struct drm_plane_state *state) +static void +__drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, + const struct drm_plane_state *old_state, + const struct drm_plane_state *state) { struct drm_rect src; memset(iter, 0, sizeof(*iter)); @@ -247,6 +229,32 @@ drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, iter->full_update = true; } } + +/** + * drm_atomic_helper_damage_iter_init - Initialize the damage iterator. + * @iter: The iterator to initialize. + * @old_state: Old plane state for validation. + * @state: Plane state from which to iterate the damage clips. + * + * Initialize an iterator, which clips plane damage + * &drm_plane_state.fb_damage_clips to plane &drm_plane_state.src. This iterator + * returns full plane src in case damage is not present because either + * user-space didn't sent or driver discarded it (it want to do full plane + * update). Currently this iterator returns full plane src in case plane src + * changed but that can be changed in future to return damage. + * + * For the case when plane is not visible or plane update should not happen the + * first call to iter_next will return false. Note that this helper use clipped + * &drm_plane_state.src, so driver calling this helper should have called + * drm_atomic_helper_check_plane_state() earlier. + */ +void +drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, + const struct drm_plane_state *old_state, + const struct drm_plane_state *state) +{ + __drm_atomic_helper_damage_iter_init(iter, old_state, state); +} EXPORT_SYMBOL(drm_atomic_helper_damage_iter_init); /** @@ -291,24 +299,9 @@ drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter, } EXPORT_SYMBOL(drm_atomic_helper_damage_iter_next); -/** - * drm_atomic_helper_damage_merged - Merged plane damage - * @old_state: Old plane state for validation. - * @state: Plane state from which to iterate the damage clips. - * @rect: Returns the merged damage rectangle - * - * This function merges any valid plane damage clips into one rectangle and - * returns it in @rect. - * - * For details see: drm_atomic_helper_damage_iter_init() and - * drm_atomic_helper_damage_iter_next(). - * - * Returns: - * True if there is valid plane damage otherwise false. - */ -bool drm_atomic_helper_damage_merged(const struct drm_plane_state *old_state, - struct drm_plane_state *state, - struct drm_rect *rect) +static bool __drm_atomic_helper_damage_merged(const struct drm_plane_state *old_state, + struct drm_plane_state *state, + struct drm_rect *rect) { struct drm_atomic_helper_damage_iter iter; struct drm_rect clip; @@ -330,4 +323,26 @@ bool drm_atomic_helper_damage_merged(const struct drm_plane_state *old_state, return valid; } + +/** + * drm_atomic_helper_damage_merged - Merged plane damage + * @old_state: Old plane state for validation. + * @state: Plane state from which to iterate the damage clips. + * @rect: Returns the merged damage rectangle + * + * This function merges any valid plane damage clips into one rectangle and + * returns it in @rect. + * + * For details see: drm_atomic_helper_damage_iter_init() and + * drm_atomic_helper_damage_iter_next(). + * + * Returns: + * True if there is valid plane damage otherwise false. + */ +bool drm_atomic_helper_damage_merged(const struct drm_plane_state *old_state, + struct drm_plane_state *state, + struct drm_rect *rect) +{ + return __drm_atomic_helper_damage_merged(old_state, state, rect); +} EXPORT_SYMBOL(drm_atomic_helper_damage_merged); From patchwork Thu Nov 9 17:24:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 13451575 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 A54F1C41535 for ; Thu, 9 Nov 2023 17:26:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B75BB10E8E8; Thu, 9 Nov 2023 17:26:08 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7D6F910E890 for ; Thu, 9 Nov 2023 17:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699550715; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DyicNWwvae7/KcxXuwMP09NutaVYwbuAqWEUxMoKBKk=; b=AN9clkLM6FSQGPWoGrew94k8Dx++3NGDomASVSCKQPMOb8O1BOuNdBh4+mL+6ki2sj/Ktw QmBCQNh8id/rNoxutnihdv/+Zkw8WXWWgaF6NoGY41a0Bx/erHhS81fU9GAzNiScejkquf vpIEXbQUdu8pFlOX7mx/hskUumNrmWE= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-671-Na391z1SPeOsORNqAeMxyw-1; Thu, 09 Nov 2023 12:25:11 -0500 X-MC-Unique: Na391z1SPeOsORNqAeMxyw-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4094d1e52daso7182985e9.2 for ; Thu, 09 Nov 2023 09:25:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699550710; x=1700155510; 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=DyicNWwvae7/KcxXuwMP09NutaVYwbuAqWEUxMoKBKk=; b=IdcwdOyW/0Ln0y+z80WM7itj3C9XBPQTSKsjCqMNMTC9VVq7vY/LxYcpurWXpT8C4A 98SZCD0MMHtwgQ7Muql3WXvzieLm4BS1INPXCNuibRLLXMqxda04JIl2i6xGAfe+Vf2C JwJbfLL7ZRcjgpLHyhKRBoTn/mR2AyoQQlPs1A4jR+ZOKO7NrNg1tEkZwsKJD4DGlZCL Blxb5qEMs5pdZZ1n6CDoVKdKIQlaCWzB5UHgkMkcljTXtRpHwnjuLlu3NO+04WXK8G5P 9IAE7yxNmDA5bWt1mr58dqXcKKn42jkdLcC2cXxTab0OD50e8DwD6pj8u6n8rc65hjK1 Ig7w== X-Gm-Message-State: AOJu0YxWTw17nRzIWz8rjeBOt9ywxrovNVF+eCCB/B9xk8UDeD66DLU6 +bU07dtGmtrXAoQQBaMffBGn7jVprjG4kuTeeSFbvE9kNnn/YQAkeVBSEAE0VA/WFKhxnwPXIQV ejCkOhJgYLgu8uuAb3AZtwenu+TrY X-Received: by 2002:a05:600c:4f03:b0:3fe:687a:abb8 with SMTP id l3-20020a05600c4f0300b003fe687aabb8mr4840958wmq.7.1699550710511; Thu, 09 Nov 2023 09:25:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGyv55FyLGeotT59GTBCN3nwc/tDWDit/kRjBLJAT9nbsysM1eR/y8bcel6P26gupJ3OsvuqQ== X-Received: by 2002:a05:600c:4f03:b0:3fe:687a:abb8 with SMTP id l3-20020a05600c4f0300b003fe687aabb8mr4840926wmq.7.1699550710072; Thu, 09 Nov 2023 09:25:10 -0800 (PST) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id b11-20020a05600c4e0b00b004054dcbf92asm2767377wmq.20.2023.11.09.09.25.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 09:25:09 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH 2/6] drm: Add drm_atomic_helper_buffer_damage_{iter_init, merged}() helpers Date: Thu, 9 Nov 2023 18:24:36 +0100 Message-ID: <20231109172449.1599262-3-javierm@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231109172449.1599262-1-javierm@redhat.com> References: <20231109172449.1599262-1-javierm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: dri-devel@lists.freedesktop.org, Gerd Hoffmann , nerdopolis , Pekka Paalanen , Thomas Zimmermann , Bilal Elmoussaoui , Javier Martinez Canillas , Maxime Ripard , stable@vger.kernel.org, Sima Vetter , Erico Nunes Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To be used by drivers that do per-buffer (e.g: virtio-gpu) uploads (rather than per-plane uploads), since these type of drivers need to handle buffer damages instead of frame damages. The drm_atomic_helper_buffer_damage_iter_init() has the same logic than drm_atomic_helper_damage_iter_init() but it also takes into account if the framebuffer attached to plane's state has changed since the last update. And the drm_atomic_helper_buffer_damage_merged() is just a version of the drm_atomic_helper_damage_merged() helper, but it uses the iter_init helper that is mentioned above. Fixes: 01f05940a9a7 ("drm/virtio: Enable fb damage clips property for the primary plane") Cc: # v6.4+ Reported-by: nerdopolis Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218115 Suggested-by: Sima Vetter Signed-off-by: Javier Martinez Canillas --- drivers/gpu/drm/drm_damage_helper.c | 79 ++++++++++++++++++++++++++--- include/drm/drm_damage_helper.h | 7 +++ 2 files changed, 80 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_damage_helper.c b/drivers/gpu/drm/drm_damage_helper.c index aa2325567918..b72062c9d31c 100644 --- a/drivers/gpu/drm/drm_damage_helper.c +++ b/drivers/gpu/drm/drm_damage_helper.c @@ -204,7 +204,8 @@ EXPORT_SYMBOL(drm_atomic_helper_dirtyfb); static void __drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, const struct drm_plane_state *old_state, - const struct drm_plane_state *state) + const struct drm_plane_state *state, + bool buffer_damage) { struct drm_rect src; memset(iter, 0, sizeof(*iter)); @@ -223,7 +224,8 @@ __drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, iter->plane_src.x2 = (src.x2 >> 16) + !!(src.x2 & 0xFFFF); iter->plane_src.y2 = (src.y2 >> 16) + !!(src.y2 & 0xFFFF); - if (!iter->clips || !drm_rect_equals(&state->src, &old_state->src)) { + if (!iter->clips || !drm_rect_equals(&state->src, &old_state->src) || + (buffer_damage && old_state->fb != state->fb)) { iter->clips = NULL; iter->num_clips = 0; iter->full_update = true; @@ -243,6 +245,10 @@ __drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, * update). Currently this iterator returns full plane src in case plane src * changed but that can be changed in future to return damage. * + * Note that this helper is for drivers that do per-plane uploads and expect + * to handle frame damages. Drivers that do per-buffer uploads instead should + * use @drm_atomic_helper_buffer_damage_iter_init() that handles buffer damages. + * * For the case when plane is not visible or plane update should not happen the * first call to iter_next will return false. Note that this helper use clipped * &drm_plane_state.src, so driver calling this helper should have called @@ -253,10 +259,37 @@ drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, const struct drm_plane_state *old_state, const struct drm_plane_state *state) { - __drm_atomic_helper_damage_iter_init(iter, old_state, state); + __drm_atomic_helper_damage_iter_init(iter, old_state, state, false); } EXPORT_SYMBOL(drm_atomic_helper_damage_iter_init); +/** + * drm_atomic_helper_buffer_damage_iter_init - Initialize the buffer damage iterator. + * @iter: The iterator to initialize. + * @old_state: Old plane state for validation. + * @state: Plane state from which to iterate the damage clips. + * + * Initialize an iterator, which clips buffer damage + * &drm_plane_state.fb_damage_clips to plane &drm_plane_state.src. This iterator + * returns full plane src in case buffer damage is not present because user-space + * didn't sent, driver discarded it (it want to do full plane update) or the plane + * @state has an attached framebuffer that is different than the one in @state (it + * has changed since the last plane update). + * + * For the case when plane is not visible or plane update should not happen the + * first call to iter_next will return false. Note that this helper use clipped + * &drm_plane_state.src, so driver calling this helper should have called + * drm_atomic_helper_check_plane_state() earlier. + */ +void +drm_atomic_helper_buffer_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, + const struct drm_plane_state *old_state, + const struct drm_plane_state *state) +{ + __drm_atomic_helper_damage_iter_init(iter, old_state, state, true); +} +EXPORT_SYMBOL(drm_atomic_helper_buffer_damage_iter_init); + /** * drm_atomic_helper_damage_iter_next - Advance the damage iterator. * @iter: The iterator to advance. @@ -301,7 +334,8 @@ EXPORT_SYMBOL(drm_atomic_helper_damage_iter_next); static bool __drm_atomic_helper_damage_merged(const struct drm_plane_state *old_state, struct drm_plane_state *state, - struct drm_rect *rect) + struct drm_rect *rect, + bool buffer_damage) { struct drm_atomic_helper_damage_iter iter; struct drm_rect clip; @@ -312,7 +346,7 @@ static bool __drm_atomic_helper_damage_merged(const struct drm_plane_state *old_ rect->x2 = 0; rect->y2 = 0; - drm_atomic_helper_damage_iter_init(&iter, old_state, state); + __drm_atomic_helper_damage_iter_init(&iter, old_state, state, buffer_damage); drm_atomic_for_each_plane_damage(&iter, &clip) { rect->x1 = min(rect->x1, clip.x1); rect->y1 = min(rect->y1, clip.y1); @@ -336,6 +370,10 @@ static bool __drm_atomic_helper_damage_merged(const struct drm_plane_state *old_ * For details see: drm_atomic_helper_damage_iter_init() and * drm_atomic_helper_damage_iter_next(). * + * Note that this helper is for drivers that do per-plane uploads and expect + * to handle frame damages. Drivers that do per-buffer uploads instead should + * use @drm_atomic_helper_buffer_damage_merged() that handles buffer damages. + * * Returns: * True if there is valid plane damage otherwise false. */ @@ -343,6 +381,35 @@ bool drm_atomic_helper_damage_merged(const struct drm_plane_state *old_state, struct drm_plane_state *state, struct drm_rect *rect) { - return __drm_atomic_helper_damage_merged(old_state, state, rect); + return __drm_atomic_helper_damage_merged(old_state, state, rect, false); } EXPORT_SYMBOL(drm_atomic_helper_damage_merged); + +/** + * drm_atomic_helper_buffer_damage_merged - Merged buffer damage + * @old_state: Old plane state for validation. + * @state: Plane state from which to iterate the damage clips. + * @rect: Returns the merged buffer damage rectangle + * + * This function merges any valid buffer damage clips into one rectangle and + * returns it in @rect. It checks if the framebuffers attached to @old_state + * and @state are the same. If that is not the case then the returned damage + * rectangle is the &drm_plane_state.src, since a full update should happen. + * + * Note that &drm_plane_state.fb_damage_clips == NULL in plane state means that + * full plane update should happen. It also ensure helper iterator will return + * &drm_plane_state.src as damage. + * + * For details see: drm_atomic_helper_buffer_damage_iter_init() and + * drm_atomic_helper_damage_iter_next(). + * + * Returns: + * True if there is valid buffer damage otherwise false. + */ +bool drm_atomic_helper_buffer_damage_merged(const struct drm_plane_state *old_state, + struct drm_plane_state *state, + struct drm_rect *rect) +{ + return __drm_atomic_helper_damage_merged(old_state, state, rect, true); +} +EXPORT_SYMBOL(drm_atomic_helper_buffer_damage_merged); diff --git a/include/drm/drm_damage_helper.h b/include/drm/drm_damage_helper.h index effda42cce31..328bb249d68f 100644 --- a/include/drm/drm_damage_helper.h +++ b/include/drm/drm_damage_helper.h @@ -74,11 +74,18 @@ void drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, const struct drm_plane_state *old_state, const struct drm_plane_state *new_state); +void +drm_atomic_helper_buffer_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, + const struct drm_plane_state *old_state, + const struct drm_plane_state *new_state); bool drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter, struct drm_rect *rect); bool drm_atomic_helper_damage_merged(const struct drm_plane_state *old_state, struct drm_plane_state *state, struct drm_rect *rect); +bool drm_atomic_helper_buffer_damage_merged(const struct drm_plane_state *old_state, + struct drm_plane_state *state, + struct drm_rect *rect); #endif From patchwork Thu Nov 9 17:24:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 13451573 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 5D310C4167B for ; Thu, 9 Nov 2023 17:26:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B3ADF10E890; Thu, 9 Nov 2023 17:25:58 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 996F510E8E8 for ; Thu, 9 Nov 2023 17:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699550715; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y0steN0/ACKFTtJOvpHMkiOMUe7bddz5OgwOILeHxPA=; b=A3lKFepho4J9ud6CksUrN6W8KfjvDWtpH1672v52zjROYN3hirks6cJeXFy4UpDLMxWMTC m59ylLX8seMAaUkjETiRouUcsHYpDs+3XlPo8p7ugxUn8odV7fRMUKPU2mYJZJhzATm5s5 LXp+JSBZ/O+UKr0gCwk7+u+pzrXGPys= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-61-004SySzeOuKP1xsdyY333A-1; Thu, 09 Nov 2023 12:25:13 -0500 X-MC-Unique: 004SySzeOuKP1xsdyY333A-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-5079630993dso1069144e87.1 for ; Thu, 09 Nov 2023 09:25:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699550712; x=1700155512; 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=Y0steN0/ACKFTtJOvpHMkiOMUe7bddz5OgwOILeHxPA=; b=KYrMb0lPbA58imN91VCySp0fAbH7SwCfLwKsUcAQoEsqQeAMQv6ecF/NqTQODrgczM ot68eQCnZ0xX7NFd1vp59/N+G7j3XaXmR0OlCTm2S++d/0v1Ie29BVYiEy/egAcyo1ct KEJrSWCTdGwyVeS5KW7emoAdUn4jn5QnhoLOVghAsbDGqypgpXLTnOUEk8Y0/GSCgiew bsXQjO93lAWOJv5bSqBtLDotOX28fpwrBLgK5le01nsS1mYATTkHfBWhglsAfcT75CBk Sw1gY9H/o9z3sy1Y7XfN5JCNyFcI9iuEB19mAEDGmY/xSvH5H9d2fZtF+sgyRwzp42St vmGA== X-Gm-Message-State: AOJu0Yx30PZTPma8XXRdDvUmIfyRQ7wj8YTM2nn/b0Zx/JXswEtlVjkf U8Ex8A4Sja15bhdbTW+jrRBE9JLPU7GyfA75Kjh0DUKpdtX9Zl3rIp5agsRibPqL0n1dXN6Usyu V6P2/dMfyzzWBpTI5RgfXvpFmMLqH X-Received: by 2002:a19:e007:0:b0:507:b935:9f5f with SMTP id x7-20020a19e007000000b00507b9359f5fmr1877865lfg.24.1699550712275; Thu, 09 Nov 2023 09:25:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IENtuNNft+jXRPbq2qJhlZT81jWdLguxD1V9O4aFnQJMyc+8VWIMEbR49N4zRWK0Yg8oNcUMw== X-Received: by 2002:a19:e007:0:b0:507:b935:9f5f with SMTP id x7-20020a19e007000000b00507b9359f5fmr1877857lfg.24.1699550712088; Thu, 09 Nov 2023 09:25:12 -0800 (PST) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id f15-20020a056000128f00b00323293bd023sm135806wrx.6.2023.11.09.09.25.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 09:25:11 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH 3/6] drm/virtio: Use drm_atomic_helper_buffer_damage_merged() for buffer damage Date: Thu, 9 Nov 2023 18:24:37 +0100 Message-ID: <20231109172449.1599262-4-javierm@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231109172449.1599262-1-javierm@redhat.com> References: <20231109172449.1599262-1-javierm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: dri-devel@lists.freedesktop.org, Gerd Hoffmann , nerdopolis , Pekka Paalanen , Thomas Zimmermann , Bilal Elmoussaoui , Javier Martinez Canillas , Maxime Ripard , Gurchetan Singh , stable@vger.kernel.org, Sima Vetter , David Airlie , virtualization@lists.linux-foundation.org, Erico Nunes Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The driver does per-buffer uploads. It needs to use the damage helper that handles buffer damages, rather than the helper that handles frame damages. Fixes: 01f05940a9a7 ("drm/virtio: Enable fb damage clips property for the primary plane") Cc: # v6.4+ Reported-by: nerdopolis Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218115 Suggested-by: Sima Vetter Signed-off-by: Javier Martinez Canillas --- drivers/gpu/drm/virtio/virtgpu_plane.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c index a2e045f3a000..1adfd9813cde 100644 --- a/drivers/gpu/drm/virtio/virtgpu_plane.c +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c @@ -183,7 +183,7 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane, return; } - if (!drm_atomic_helper_damage_merged(old_state, plane->state, &rect)) + if (!drm_atomic_helper_buffer_damage_merged(old_state, plane->state, &rect)) return; bo = gem_to_virtio_gpu_obj(plane->state->fb->obj[0]); From patchwork Thu Nov 9 17:24:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 13451574 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 D481CC4332F for ; Thu, 9 Nov 2023 17:26:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1A63110E8E9; Thu, 9 Nov 2023 17:26:04 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id A7AE410E8E9 for ; Thu, 9 Nov 2023 17:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699550717; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7sDHSqMuo7yUORgn5WByoTm7yhsDzWS7QFyd4p9GXpM=; b=Azbi/CywvQpVvHBsBe2SZ4W97QOqHRiL2MMgAzKXDqgxHedN0GpPgPmFVs0fri4wMEjP8N DnrMvUHVS4Vk4eK9BwoAsLGO7selwgRUK1/hiERX0TuA/vsy3wHnuxOGr6Qo35t5FVUDjm 08StyYWn8cv+nXRxirXgz1isBIAMWFc= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-377-8bAlGuU-NDqei1OZqp8qfA-1; Thu, 09 Nov 2023 12:25:15 -0500 X-MC-Unique: 8bAlGuU-NDqei1OZqp8qfA-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-507b9078aaaso1101067e87.2 for ; Thu, 09 Nov 2023 09:25:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699550714; x=1700155514; 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=7sDHSqMuo7yUORgn5WByoTm7yhsDzWS7QFyd4p9GXpM=; b=LJuzEK/Lxf3Ce7bNB0P9V+OeXkfls82277LnKHXkTzfz8f9j7+oCZEmNP7IDar0mbm fXtzN1Kp7qkpcaYerXq3t6brnmh5rxnHvW5jzIgVzyHbAjPuXk+kfAk05ujUvkDJiBiM lq+e4LoBrU+o/XjZmKFYbLUGAWDkbJOD39TGKTXZQ1ph+v8U9rNJMkBUTtV3bgCqXEj0 6zpASad7rhecB8skHbUdTx+uI3ORPg2doLlAQ9tTEqM4g/IHMb7rukVoOOqKF1cZcl38 adTjZozEjpLWc5tpQHyGF+ftdrff2vzSQHnHBS97e0vXQGTxMzAIdfjEnDssytdTm1Ry lEZg== X-Gm-Message-State: AOJu0YzK9FRlZRrS8lmuWs+3vWqFQM1lHWjQ6J3gyU+3MOAzxlePwvI9 YREqxb6VooW5sA/hNXLMg3iX/h0iwcszhmIeAKBe+kFvZ2A53R2MzZIB6kEY5A8a8s1DDY+94pn 1I0PKwfqeHSMDZM73vwjoNCfxnIZ9 X-Received: by 2002:ac2:5e9e:0:b0:507:a6a5:a87b with SMTP id b30-20020ac25e9e000000b00507a6a5a87bmr1916878lfq.51.1699550714257; Thu, 09 Nov 2023 09:25:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEJVNz0Dz1HSXbQ0UB49yuozjenPpk3U6wkuD6qjSBnU9rrxSOmkfygjO1wSFqzgZsRaJXpyw== X-Received: by 2002:ac2:5e9e:0:b0:507:a6a5:a87b with SMTP id b30-20020ac25e9e000000b00507a6a5a87bmr1916854lfq.51.1699550714038; Thu, 09 Nov 2023 09:25:14 -0800 (PST) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id c1-20020adfed81000000b0032fab28e9c9sm119847wro.73.2023.11.09.09.25.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 09:25:13 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH 4/6] drm/vmwgfx: Use drm_atomic_helper_buffer_damage_iter_init() for buffer damage Date: Thu, 9 Nov 2023 18:24:38 +0100 Message-ID: <20231109172449.1599262-5-javierm@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231109172449.1599262-1-javierm@redhat.com> References: <20231109172449.1599262-1-javierm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: Pekka Paalanen , Thomas Zimmermann , Bilal Elmoussaoui , Javier Martinez Canillas , Maxime Ripard , VMware Graphics Reviewers , dri-devel@lists.freedesktop.org, Sima Vetter , Erico Nunes Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The driver does per-buffer uploads. It needs to use the damage helper that handles buffer damages, rather than the helper that handles frame damages. Suggested-by: Sima Vetter Signed-off-by: Javier Martinez Canillas --- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 1489ad73c103..91cda125784e 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -2912,7 +2912,7 @@ int vmw_du_helper_plane_update(struct vmw_du_update_plane *update) * Iterate in advance to check if really need plane update and find the * number of clips that actually are in plane src for fifo allocation. */ - drm_atomic_helper_damage_iter_init(&iter, old_state, state); + drm_atomic_helper_buffer_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; From patchwork Thu Nov 9 17:24:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 13451578 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 B02C4C4167D for ; Thu, 9 Nov 2023 17:26:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 31A3D10E8ED; Thu, 9 Nov 2023 17:26:40 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id BB3D310E8EB for ; Thu, 9 Nov 2023 17:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699550719; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I7tI1v3g4YDcTR34UtN17p6cKRPxCtoGaa2HZ2e5M58=; b=K6yNWICu+VYxlr9m34aYFnIVbiFnfIqKj8Yj2E9RJQfdZkdygJOfqW046JiNGjjvj9U+yv LH2+ZFLlzdGCj7s+Hao+Jhx4wtBIzrNhCD4ch/4Vm6hEUH7bUu8L9mwS7WiLwsbSTqNfyC a/7Lg0KhyrAgJ5JQdRKfV+qrXR0oczQ= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-365-BTSWnejWPTmOOpuZc2w2Yw-1; Thu, 09 Nov 2023 12:25:18 -0500 X-MC-Unique: BTSWnejWPTmOOpuZc2w2Yw-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2c53ea92642so10912641fa.2 for ; Thu, 09 Nov 2023 09:25:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699550716; x=1700155516; 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=I7tI1v3g4YDcTR34UtN17p6cKRPxCtoGaa2HZ2e5M58=; b=PhSRVdVtzGrE6jRnzyXVDX2FPI7HHwKmsR6jzMm7F0619mtGVF8oWJGuPTNihcyFmV eVorhfJAJTEYwXjkmfwAhv0pRH4NWzU24mKirgScSZlSEjy6G1sa3b/jGVYfWPkoye9p JFXVzV3Q1X74ED6VQETGihyX0Vs5IJFvNFR+MJVj7x7n+b5NjGIgDd6agSi9f8QQicQv uocnQZFQRfpwlhclqQDkgUMPS0rgzul0jRzVUOgGPuBbBpMXYiXac+X04sduvmxYvf3v mNObMtZ5BiGJK7RHn4/iGEG4YLKx3PaY6njda0lxKeBXm+RYnlvD3dREz/iKUL3lkUZQ 4FSQ== X-Gm-Message-State: AOJu0YwADDycM81lLTW/c6qL7w01GpuhJAYKHOVLVEpu7M3YB8RCoJX1 L0PsvtBYcWAf6lE3rqwlbXFCCgBHqaQXqDOF4Tr+OOPBIeZHAhrQ6L7CaKJXItJ1UKzmeCMzpxA aJcQwRkag0f5sbzAVP6cJ5lT34tls X-Received: by 2002:ac2:549c:0:b0:500:b2f6:592 with SMTP id t28-20020ac2549c000000b00500b2f60592mr1983261lfk.50.1699550716517; Thu, 09 Nov 2023 09:25:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IGse4RCF/67oKfST0CFHyjm+cpu2Cvl4v5lpvsxPTmc5ZS8cA1s3XNc9fBMoe6L+fz5hMsbpg== X-Received: by 2002:ac2:549c:0:b0:500:b2f6:592 with SMTP id t28-20020ac2549c000000b00500b2f60592mr1983244lfk.50.1699550716301; Thu, 09 Nov 2023 09:25:16 -0800 (PST) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id n8-20020a5d6608000000b0032da75af3easm119414wru.80.2023.11.09.09.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 09:25:15 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH 5/6] drm/plane: Extend damage tracking kernel-doc Date: Thu, 9 Nov 2023 18:24:39 +0100 Message-ID: <20231109172449.1599262-6-javierm@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231109172449.1599262-1-javierm@redhat.com> References: <20231109172449.1599262-1-javierm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: Pekka Paalanen , Thomas Zimmermann , Bilal Elmoussaoui , Javier Martinez Canillas , Maxime Ripard , dri-devel@lists.freedesktop.org, Sima Vetter , Erico Nunes Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The "Damage Tracking Properties" section in the documentation doesn't have info about the two type of damage handling: frame damage vs buffer damage. Add that to the section, mention the different helpers that should be used by drivers depending on the damage handling type used and refer to sites that have more content about damage types and damage tracking in general. Suggested-by: Simon Ser Signed-off-by: Javier Martinez Canillas Reviewed-by: Simon Ser --- drivers/gpu/drm/drm_damage_helper.c | 10 ++++++---- drivers/gpu/drm/drm_plane.c | 22 +++++++++++++++++++--- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_damage_helper.c b/drivers/gpu/drm/drm_damage_helper.c index b72062c9d31c..ac9986da7d7c 100644 --- a/drivers/gpu/drm/drm_damage_helper.c +++ b/drivers/gpu/drm/drm_damage_helper.c @@ -367,8 +367,9 @@ static bool __drm_atomic_helper_damage_merged(const struct drm_plane_state *old_ * This function merges any valid plane damage clips into one rectangle and * returns it in @rect. * - * For details see: drm_atomic_helper_damage_iter_init() and - * drm_atomic_helper_damage_iter_next(). + * For details see: drm_atomic_helper_damage_iter_init(), + * drm_atomic_helper_damage_iter_next() and + * `Damage Tracking Properties`_. * * Note that this helper is for drivers that do per-plane uploads and expect * to handle frame damages. Drivers that do per-buffer uploads instead should @@ -400,8 +401,9 @@ EXPORT_SYMBOL(drm_atomic_helper_damage_merged); * full plane update should happen. It also ensure helper iterator will return * &drm_plane_state.src as damage. * - * For details see: drm_atomic_helper_buffer_damage_iter_init() and - * drm_atomic_helper_damage_iter_next(). + * For details see: drm_atomic_helper_buffer_damage_iter_init(), + * drm_atomic_helper_damage_iter_next() and + * `Damage Tracking Properties`_. * * Returns: * True if there is valid buffer damage otherwise false. diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index 24e7998d1731..f137a99b3435 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -1439,9 +1439,25 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, * * Drivers that are interested in damage interface for plane should enable * FB_DAMAGE_CLIPS property by calling drm_plane_enable_fb_damage_clips(). - * Drivers implementing damage can use drm_atomic_helper_damage_iter_init() and - * drm_atomic_helper_damage_iter_next() helper iterator function to get damage - * rectangles clipped to &drm_plane_state.src. + * + * Note that there are two types of damage handling: frame damage and buffer + * damage. The drivers implementing a per-plane or per-CRTC upload target and + * need to handle frame damage can use drm_atomic_helper_damage_iter_init(), + * but drivers implementing a per-buffer upload target and need to handle buffer + * damage should use drm_atomic_helper_buffer_damage_iter_init() helper instead. + * + * Once the iterator has been initialized by the damage helpers mentioned above, + * the drm_atomic_helper_damage_iter_next() helper iterator function can be used + * to get damage rectangles clipped to &drm_plane_state.src. + * + * The type of damage handling implemented depends on the driver's upload target + * but notice that when using swap buffers, the returned damage rectangle is the + * &drm_plane_state.src, since a full plane update should happen. There is no + * buffer age support or similar damage accumulation algorithm implemented yet. + * + * For more information about the two type of damage, see: + * https://registry.khronos.org/EGL/extensions/KHR/EGL_KHR_swap_buffers_with_damage.txt + * https://emersion.fr/blog/2019/intro-to-damage-tracking/ */ /** From patchwork Thu Nov 9 17:24:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 13451577 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 A1E28C4332F for ; Thu, 9 Nov 2023 17:26:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7D3EA10E8EC; Thu, 9 Nov 2023 17:26:38 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id E316010E8EC for ; Thu, 9 Nov 2023 17:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699550721; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LQsLMrBO0s8gsbhcurrkAKTlTUKc8bmHZW0Ex5lVbpk=; b=O/99XKW6UPPlRJFdA39uAFOLDNoDPnIKUn5IKpRZsYFFnuhGUkOgg0PDA4bOmhZ2tcK+pT B/KBBktJSscaKARbSyvq9LmIjXa7Lm71TDWXFbblZVmQVeHJfeLp7Lavc9HORjO7X832fX Um3ujoLyXPYOpDxzOpEW1wkuXaxgcl4= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-224-UnsYbZebMImWqtwpdM67Dw-1; Thu, 09 Nov 2023 12:25:19 -0500 X-MC-Unique: UnsYbZebMImWqtwpdM67Dw-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-32d9751ca2cso564904f8f.3 for ; Thu, 09 Nov 2023 09:25:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699550718; x=1700155518; 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=LQsLMrBO0s8gsbhcurrkAKTlTUKc8bmHZW0Ex5lVbpk=; b=vsC/wzAnwkbk0qv2gB13Ijp4xKh5cJVW4d3QGEhXwnb+gq04zamgIHnrAczKAwfWle 4U/ThYfGXGCcS5kiy9MGZmNrx/SVoVYNtkyQS+NGCVCFuh4dyQyRAX8y+x38zRMY3nOm aBMkUvOP6zuPGZRJESsFsyUIZfDUWGc7VXE/9Mk1SxeT0uTuJoKpsY8lheF/4u/tZ41I MkAexsbvkHrB0mkCnalFXiO6oC1j0JpBuYuZ4NloyTfdBWwWiwvvcvflGMn7Gs3SHcW2 FqpPjiun1TGFHfTQV90qZtK8tfAgJQIt8q/GJuO/eamEmuyWYMwUznxa8LLCFoxrpKkL 4LNA== X-Gm-Message-State: AOJu0YyQTmeOyo+1CBbz3l63CpgJZ26tFz1m/A2nX/aOBdan9QU+Qjjh nwVTnE6NXX7R//Tedz1N9MqNAG8sifu7bfFSooftDXDzd7onIl6io/D90Qbqjx1w9fkkUE6mM3Z hO6s2v9vwuTdvXS46TsJuKVmkKyRL X-Received: by 2002:a05:6000:1cb:b0:32f:7963:8493 with SMTP id t11-20020a05600001cb00b0032f79638493mr4461558wrx.37.1699550718114; Thu, 09 Nov 2023 09:25:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGD/Ij413ZeKujXk6kJlWHHEPZiWIxqmSIPmvd4/ZL4FLHzk3PoQZkslp1/W1fbI9IJfywcfQ== X-Received: by 2002:a05:6000:1cb:b0:32f:7963:8493 with SMTP id t11-20020a05600001cb00b0032f79638493mr4461536wrx.37.1699550717778; Thu, 09 Nov 2023 09:25:17 -0800 (PST) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id k8-20020a5d6e88000000b0032db430fb9bsm121425wrz.68.2023.11.09.09.25.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 09:25:17 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH 6/6] drm/todo: Add entry about implementing buffer age for damage tracking Date: Thu, 9 Nov 2023 18:24:40 +0100 Message-ID: <20231109172449.1599262-7-javierm@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231109172449.1599262-1-javierm@redhat.com> References: <20231109172449.1599262-1-javierm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: Pekka Paalanen , Thomas Zimmermann , Jonathan Corbet , Bilal Elmoussaoui , linux-doc@vger.kernel.org, Javier Martinez Canillas , Maxime Ripard , dri-devel@lists.freedesktop.org, Sima Vetter , Erico Nunes Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently, only damage tracking for frame damage is supported. If a driver needs to do buffer damage (e.g: the framebuffer attached to plane's state has changed since the last page-flip), the damage helpers just fallback to a full plane update. Add en entry in the TODO about implementing buffer age or any other damage accumulation algorithm for buffer damage handling. Suggested-by: Simon Ser Signed-off-by: Javier Martinez Canillas Reviewed-by: Simon Ser --- Documentation/gpu/todo.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst index 03fe5d1247be..adaa154210a0 100644 --- a/Documentation/gpu/todo.rst +++ b/Documentation/gpu/todo.rst @@ -765,6 +765,26 @@ Contact: Hans de Goede Level: Advanced +Buffer age or other damage accumulation algorithm for buffer damage handling +============================================================================ + +Drivers that do per-buffer uploads, need a buffer damage handling (rather than +frame damage like drivers that do per-plane or per-CRTC uploads), but there is +no support to get the buffer age or any other damage accumulation algorithm. + +For this reason, the damage helpers just fallback to a full plane update if the +framebuffer attached to a plane has changed since the last page-flip. + +This should be improved to get damage tracking properly working on drivers that +do per-buffer uploads. + +More information about damage tracking and references to learning materials in +`Damage Tracking Properties `_ + +Contact: Javier Martinez Canillas + +Level: Advanced + Outside DRM ===========