From nobody Wed Dec 17 17:23:47 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDF5CC61DF7 for ; Thu, 23 Nov 2023 22:13:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230009AbjKWWNV (ORCPT ); Thu, 23 Nov 2023 17:13:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229896AbjKWWNR (ORCPT ); Thu, 23 Nov 2023 17:13:17 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B7F4BC for ; Thu, 23 Nov 2023 14:13:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700777603; 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=NNr7AyogBLBECN5NVEc3sDwHAg2qPYRl5gFzwIza95Q=; b=XI9OJSV7ULp62EO3Ln5b/Sav/1he4KkkB/BpMPUqdi4VtgvwQxG2H5zHRlViIw3elqRhGU vJdlf6zqK40fkpgQmp7mEQj+hR+d0mf85e4XCBkuM8U7Fyl3Bne4+BgZ3L3K3PdlKwIwyS C5wWb+G1CLKyD5rWogNw7DG0ldV8YYo= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-353-HCUyQTUWNgymwyPMCQNwbQ-1; Thu, 23 Nov 2023 17:13:21 -0500 X-MC-Unique: HCUyQTUWNgymwyPMCQNwbQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-40b3712ef28so4618845e9.2 for ; Thu, 23 Nov 2023 14:13:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700777600; x=1701382400; 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=NNr7AyogBLBECN5NVEc3sDwHAg2qPYRl5gFzwIza95Q=; b=wpN33Y/Z6oWEM47E4ZFaSg2OBaFfhjwtwrxC+zchDluqPQ9eSzE32AAG1VAuJOg36r YlF9OvmHYurwtg05Uyh18miGBpA4VgjxKvAPqbzp/p8pQR6ql9OswXC809woqpXRQCKm 7ey4fc3XUxWCfmCzkab7tg/oIT4AshYGbGQ1ZF+iMOfKbt+t8dAoxofzeBSy4JGXa8nU Q5X/ID61OAqp2IimemDYPJ74PmekVnojsRcVr1fR7ELkzujVYWss3oYbRKBqDzs5UtvD nUAbHhVVnlaZA5CNIv1OLloZPNztyV2tGq3vCYaxvkZeYcNM8sx+i0lQcjY1PJaP7WYr ImPg== X-Gm-Message-State: AOJu0YzlutQ6X6z15w+VDTlDxQcK0nhfeWRBbAojcNTAmOsztMb0ihPF U8xHCHJNb8rFzRgh6OHWGPUj51EGfZchkMyAitLymAaHIpPZk9Ud3hyHBBwDh29WjamHTsrF2nr /Pes45dlxLkrKHCd4AMYLY8jgABpq7b0dJx/qzNEv9upnrukvz0xq1Oi+TtyWYpjNyaVAFa36qv jSrSTXMPI= X-Received: by 2002:a05:600c:1c9d:b0:408:434c:dae7 with SMTP id k29-20020a05600c1c9d00b00408434cdae7mr695860wms.2.1700777599831; Thu, 23 Nov 2023 14:13:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IGsLgt3C+76rwt6+lTv0sowa6U49h5FFZqfpVdWRCJlUnBufhPrTXVPA1hV/im8nsFEBKfIcQ== X-Received: by 2002:a05:600c:1c9d:b0:408:434c:dae7 with SMTP id k29-20020a05600c1c9d00b00408434cdae7mr695832wms.2.1700777599346; Thu, 23 Nov 2023 14:13:19 -0800 (PST) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id r7-20020a05600c35c700b0040b30be6244sm3233457wmq.24.2023.11.23.14.13.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 14:13:18 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Maxime Ripard , Zack Rusin , Thomas Zimmermann , Pekka Paalanen , Bilal Elmoussaoui , Simon Ser , Erico Nunes , Sima Vetter , Javier Martinez Canillas , stable@vger.kernel.org, nerdopolis , Daniel Vetter , David Airlie , Gerd Hoffmann , Jonathan Corbet , Maarten Lankhorst , dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org Subject: [PATCH v4 1/5] drm: Allow drivers to indicate the damage helpers to ignore damage clips Date: Thu, 23 Nov 2023 23:13:00 +0100 Message-ID: <20231123221315.3579454-2-javierm@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231123221315.3579454-1-javierm@redhat.com> References: <20231123221315.3579454-1-javierm@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It allows drivers to set a struct drm_plane_state .ignore_damage_clips in their plane's .atomic_check callback, as an indication to damage helpers such as drm_atomic_helper_damage_iter_init() that the damage clips should be ignored. 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. That way, these drivers could force a full plane update if the framebuffer attached to a plane's state has changed since the last update (page-flip). Fixes: 01f05940a9a7 ("drm/virtio: Enable fb damage clips property for the p= rimary plane") Cc: # v6.4+ Reported-by: nerdopolis Closes: https://bugzilla.kernel.org/show_bug.cgi?id=3D218115 Suggested-by: Thomas Zimmermann Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann Reviewed-by: Zack Rusin Acked-by: Sima Vetter --- Changes in v4: - Refer in ignore_damage_clips kernel-doc to "Damage Tracking Properties" KMS documentation section (Sima Vetter). Changes in v2: - Add a struct drm_plane_state .ignore_damage_clips to set in the plane's .atomic_check, instead of having different helpers (Thomas Zimmermann). Documentation/gpu/drm-kms.rst | 2 ++ drivers/gpu/drm/drm_damage_helper.c | 3 ++- include/drm/drm_plane.h | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Documentation/gpu/drm-kms.rst b/Documentation/gpu/drm-kms.rst index 270d320407c7..a98a7e04e86f 100644 --- a/Documentation/gpu/drm-kms.rst +++ b/Documentation/gpu/drm-kms.rst @@ -548,6 +548,8 @@ Plane Composition Properties .. kernel-doc:: drivers/gpu/drm/drm_blend.c :doc: overview =20 +.. _damage_tracking_properties: + Damage Tracking Properties -------------------------- =20 diff --git a/drivers/gpu/drm/drm_damage_helper.c b/drivers/gpu/drm/drm_dama= ge_helper.c index d8b2955e88fd..afb02aae707b 100644 --- a/drivers/gpu/drm/drm_damage_helper.c +++ b/drivers/gpu/drm/drm_damage_helper.c @@ -241,7 +241,8 @@ drm_atomic_helper_damage_iter_init(struct drm_atomic_he= lper_damage_iter *iter, iter->plane_src.x2 =3D (src.x2 >> 16) + !!(src.x2 & 0xFFFF); iter->plane_src.y2 =3D (src.y2 >> 16) + !!(src.y2 & 0xFFFF); =20 - if (!iter->clips || !drm_rect_equals(&state->src, &old_state->src)) { + if (!iter->clips || state->ignore_damage_clips || + !drm_rect_equals(&state->src, &old_state->src)) { iter->clips =3D NULL; iter->num_clips =3D 0; iter->full_update =3D true; diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h index 79d62856defb..fef775200a81 100644 --- a/include/drm/drm_plane.h +++ b/include/drm/drm_plane.h @@ -190,6 +190,16 @@ struct drm_plane_state { */ struct drm_property_blob *fb_damage_clips; =20 + /** + * @ignore_damage_clips: + * + * Set by drivers to indicate the drm_atomic_helper_damage_iter_init() + * helper that the @fb_damage_clips blob property should be ignored. + * + * See :ref:`damage_tracking_properties` for more information. + */ + bool ignore_damage_clips; + /** * @src: * --=20 2.41.0 From nobody Wed Dec 17 17:23:47 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA74FC636BD for ; Thu, 23 Nov 2023 22:13:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230131AbjKWWNZ (ORCPT ); Thu, 23 Nov 2023 17:13:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229981AbjKWWNS (ORCPT ); Thu, 23 Nov 2023 17:13:18 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 594D41B6 for ; Thu, 23 Nov 2023 14:13:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700777604; 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=U3hQPeRRqjnZSS8OWuMWpjh1Oj2NJuDlBMcX3dbEThk=; b=CQSFxF5Gj7EEPrrXOHwUJqemxWDXLaQYYZyG/36/HQjl9eNdOCN/U4g6LJkzD6fRDJcuOX HSyk4/PRaWxvk4i/nBpGNwpWtMr1LgTOzwxBiQMk6lnLPVozU7H+4O8vtucfkaspiIam4v YgS5GZZvU5Cp+M5rrk0hvFuX9DYUaEs= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-YactF0ejPsGPsfqTirbi4g-1; Thu, 23 Nov 2023 17:13:23 -0500 X-MC-Unique: YactF0ejPsGPsfqTirbi4g-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-40b349b9711so7664275e9.0 for ; Thu, 23 Nov 2023 14:13:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700777601; x=1701382401; 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=U3hQPeRRqjnZSS8OWuMWpjh1Oj2NJuDlBMcX3dbEThk=; b=duxnrTRgk5VSA6IFya4fVY4ZxHCkwsUrSciDVakHWJnP9MCLwO8gKOiFtK54mVNf6v ES4bzBhRGhj0MDFoIRpo6Uj50TJqhTttpFZFZHTxw/zItzgKDBJoKhQlDn7CYB4hH9Kn 54f0+9FpDPlXnyWQzHNnrOa+p+0G6izvEdz0lmvAltjXkWpqGQIfzvKyAHJtSSOMofBH IAkp465eAcik1ZhSJadCv80xI2NYNLgvGpLlnVqb7gR6GzdCHAPfPbpYEpkbIt12yVMA P2seRsTRUiinBIG2eXIloHPPf8DvWiYOB8p3Nupwp1KUseXLauvC++ZdbcEovpisEQKb 9lxw== X-Gm-Message-State: AOJu0YwSmaNWIZjx3hoePVqHtPy6mv+3Us82JosmJN3H0mKpQteThy7R XAFAMari341z25S6K1cHqH45qrGsx3oZ4UjQJ8qwNzr0CzjTOWMlfJ4JEIK2u6rEMEiiWMqYFVR GeguWfNgl6khzLuUaHHgmqPUw0iff6e/ibhcrYWSdzxHvypSGK+GSrASw32v2JtTpfuqACyYp+K +m4BN8QSw= X-Received: by 2002:a05:600c:3507:b0:406:44e6:c00d with SMTP id h7-20020a05600c350700b0040644e6c00dmr662896wmq.2.1700777601655; Thu, 23 Nov 2023 14:13:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHt+DfJY/Kdak/dZD3b9Ayp5iu9B3rETe6oqsTju4XsMZUCKTzrR+3d7cg40KCVTwvZqoHReg== X-Received: by 2002:a05:600c:3507:b0:406:44e6:c00d with SMTP id h7-20020a05600c350700b0040644e6c00dmr662869wmq.2.1700777601339; Thu, 23 Nov 2023 14:13:21 -0800 (PST) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id je19-20020a05600c1f9300b004083729fc14sm3839537wmb.20.2023.11.23.14.13.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 14:13:20 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Maxime Ripard , Zack Rusin , Thomas Zimmermann , Pekka Paalanen , Bilal Elmoussaoui , Simon Ser , Erico Nunes , Sima Vetter , Javier Martinez Canillas , stable@vger.kernel.org, nerdopolis , Chia-I Wu , Daniel Vetter , David Airlie , Gerd Hoffmann , Gurchetan Singh , Maarten Lankhorst , dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev Subject: [PATCH v4 2/5] drm/virtio: Disable damage clipping if FB changed since last page-flip Date: Thu, 23 Nov 2023 23:13:01 +0100 Message-ID: <20231123221315.3579454-3-javierm@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231123221315.3579454-1-javierm@redhat.com> References: <20231123221315.3579454-1-javierm@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The driver does per-buffer uploads and needs to force a full plane update if the plane's attached framebuffer has change since the last page-flip. Fixes: 01f05940a9a7 ("drm/virtio: Enable fb damage clips property for the p= rimary plane") Cc: # v6.4+ Reported-by: nerdopolis Closes: https://bugzilla.kernel.org/show_bug.cgi?id=3D218115 Suggested-by: Sima Vetter Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann Reviewed-by: Zack Rusin Acked-by: Sima Vetter --- (no changes since v2) Changes in v2: - Set struct drm_plane_state .ignore_damage_clips in virtio-gpu plane's .atomic_check instead of using a different helpers (Thomas Zimmermann). drivers/gpu/drm/virtio/virtgpu_plane.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virti= o/virtgpu_plane.c index a2e045f3a000..a1ef657eba07 100644 --- a/drivers/gpu/drm/virtio/virtgpu_plane.c +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c @@ -79,6 +79,8 @@ static int virtio_gpu_plane_atomic_check(struct drm_plane= *plane, { struct drm_plane_state *new_plane_state =3D drm_atomic_get_new_plane_stat= e(state, plane); + struct drm_plane_state *old_plane_state =3D drm_atomic_get_old_plane_stat= e(state, + plane); bool is_cursor =3D plane->type =3D=3D DRM_PLANE_TYPE_CURSOR; struct drm_crtc_state *crtc_state; int ret; @@ -86,6 +88,14 @@ static int virtio_gpu_plane_atomic_check(struct drm_plan= e *plane, if (!new_plane_state->fb || WARN_ON(!new_plane_state->crtc)) return 0; =20 + /* + * Ignore damage clips if the framebuffer attached to the plane's state + * has changed since the last plane update (page-flip). In this case, a + * full plane update should happen because uploads are done per-buffer. + */ + if (old_plane_state->fb !=3D new_plane_state->fb) + new_plane_state->ignore_damage_clips =3D true; + crtc_state =3D drm_atomic_get_crtc_state(state, new_plane_state->crtc); if (IS_ERR(crtc_state)) --=20 2.41.0 From nobody Wed Dec 17 17:23:47 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3C18C61D85 for ; Thu, 23 Nov 2023 22:13:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230148AbjKWWN3 (ORCPT ); Thu, 23 Nov 2023 17:13:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230013AbjKWWNW (ORCPT ); Thu, 23 Nov 2023 17:13:22 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 918E210D1 for ; Thu, 23 Nov 2023 14:13:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700777607; 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=eevPmuhRFAgVhLHOGTOOcRfbcoEzUftUVXb0Oh9ok7w=; b=XrVBv3AqLvNGaf15QiXuDYaXp7+w1htPBpJNE/Zn7qs64OqTUrq7xCWMA9vXBmDyDl3UUP Ht01vtT9QgSWrrMjfIf0ofkJfikM9ue7RjAl22N08yu194HX+ioPSxpWlYW+UguS6VFngm J9P/c9h+DnfC52SFTiFAoduOo4Xg+ok= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-509-vjnvqvc3OO6esU69qhtU4A-1; Thu, 23 Nov 2023 17:13:26 -0500 X-MC-Unique: vjnvqvc3OO6esU69qhtU4A-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-40b349b990fso6276235e9.3 for ; Thu, 23 Nov 2023 14:13:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700777604; x=1701382404; 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=eevPmuhRFAgVhLHOGTOOcRfbcoEzUftUVXb0Oh9ok7w=; b=mRQGqiPnghjHo7RgaCdGpdj+k5XTMsRNEoUya59XXLU2U99FHBxnoULLIl4wiSousX ddpCp4/+ODaDI71m1O4jSUnqYKMcqdEfM5Ic+xkMFykvmRfQOAc4rRl4YxThTCLqksvV G1XGpRKL2aIsoEWtuQUjhOje3fPNYDh3HFjXrAKGOVP8EKdttxkmgg0yxVqGDIsTrcug T1vGW0TKyZmCzfQzjaxP/FIJg9yO6x+GVHJoUDzbCyEv+xDq9ewb35lo/edLPrbBpJbZ 5qpQ1DrZlKDsZyoSNU2nU36d06ulOLOxfRd/QuPRpxc2a9db9B6athxA2owSOXcpvwoZ FVPA== X-Gm-Message-State: AOJu0YxUiw2sxgmWKKrC0JckpghrJP3OTpsxmymG0ci7I30SkqSlONsJ TM73WiHLOCWpwwsWog9pYv0F1H3p/7A4UhrEgz4iR6WTXQDwSAqeqtzaf3mrHFfUEnsGwQ6ZBCc IQlcRkDiAzcvB+3C1udqWLu9YI79rYEfsw/ks9ksVi0gzJa2EtoBF61iQ3WWpcGjf75wNM80y3y nmP3lCEV4= X-Received: by 2002:a05:600c:138e:b0:40b:3605:acda with SMTP id u14-20020a05600c138e00b0040b3605acdamr646923wmf.25.1700777604124; Thu, 23 Nov 2023 14:13:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6aWgfy8x/Q5jWLkQk58MrIjsjFwETk6FGO3Io9BSfMMwRCBkkQZXEsO4x5dsaE1onwWQGvg== X-Received: by 2002:a05:600c:138e:b0:40b:3605:acda with SMTP id u14-20020a05600c138e00b0040b3605acdamr646901wmf.25.1700777603855; Thu, 23 Nov 2023 14:13:23 -0800 (PST) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id z11-20020a05600c0a0b00b00405c7591b09sm3180629wmp.35.2023.11.23.14.13.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 14:13:22 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Maxime Ripard , Zack Rusin , Thomas Zimmermann , Pekka Paalanen , Bilal Elmoussaoui , Simon Ser , Erico Nunes , Sima Vetter , Javier Martinez Canillas , Daniel Vetter , David Airlie , Maarten Lankhorst , VMware Graphics Reviewers , dri-devel@lists.freedesktop.org Subject: [PATCH v4 3/5] drm/vmwgfx: Disable damage clipping if FB changed since last page-flip Date: Thu, 23 Nov 2023 23:13:02 +0100 Message-ID: <20231123221315.3579454-4-javierm@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231123221315.3579454-1-javierm@redhat.com> References: <20231123221315.3579454-1-javierm@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The driver does per-buffer uploads and needs to force a full plane update if the plane's attached framebuffer has change since the last page-flip. Suggested-by: Sima Vetter Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann Reviewed-by: Zack Rusin Acked-by: Sima Vetter --- (no changes since v2) Changes in v2: - Set struct drm_plane_state .ignore_damage_clips in vmwgfx plane's .atomic_check instead of using a different helpers (Thomas Zimmermann). drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/v= mwgfx_kms.c index 818b7f109f53..f9364bf222e3 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -837,10 +837,21 @@ int vmw_du_primary_plane_atomic_check(struct drm_plan= e *plane, { struct drm_plane_state *new_state =3D drm_atomic_get_new_plane_state(stat= e, plane); + struct drm_plane_state *old_state =3D drm_atomic_get_old_plane_state(stat= e, + plane); struct drm_crtc_state *crtc_state =3D NULL; struct drm_framebuffer *new_fb =3D new_state->fb; + struct drm_framebuffer *old_fb =3D old_state->fb; int ret; =20 + /* + * Ignore damage clips if the framebuffer attached to the plane's state + * has changed since the last plane update (page-flip). In this case, a + * full plane update should happen because uploads are done per-buffer. + */ + if (old_fb !=3D new_fb) + new_state->ignore_damage_clips =3D true; + if (new_state->crtc) crtc_state =3D drm_atomic_get_new_crtc_state(state, new_state->crtc); --=20 2.41.0 From nobody Wed Dec 17 17:23:47 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3315CC61D85 for ; Thu, 23 Nov 2023 22:13:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230521AbjKWWNe (ORCPT ); Thu, 23 Nov 2023 17:13:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230117AbjKWWNZ (ORCPT ); Thu, 23 Nov 2023 17:13:25 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D02CE10D7 for ; Thu, 23 Nov 2023 14:13:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700777609; 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=dih2whL2MPf6NwDlCWNCaNjlgkoV00h0l9L+4gltDhE=; b=RsoZcTvtpiZ7Bw2iO5CPMeQw9bJ26x5t/IAReYx+Uua6PbKMd82Y9x2390NlttCdl1m4tD 9AH8UJxznctmPga89B3mHhlgbefmIP/7Cw2RmOo9iG51deIrHiPW66++eQ9TCKhGl8tfut U5HadLXkoQRIXrY+9p0QkbmZbAZ8u+A= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-I63rtFG7MvWF3fMaZiUCUg-1; Thu, 23 Nov 2023 17:13:27 -0500 X-MC-Unique: I63rtFG7MvWF3fMaZiUCUg-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-40845fe2d1cso6948565e9.0 for ; Thu, 23 Nov 2023 14:13:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700777606; x=1701382406; 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=dih2whL2MPf6NwDlCWNCaNjlgkoV00h0l9L+4gltDhE=; b=sSVVBc4dn7JkTqLcRY9868qZ3W4SkSPgtaKUN2mgrONmR72WdlNNddR/Yu5ws55tBW OmC+Hd34rCzpceZAK6wKrJEzuVp76CMHl3sqnZYBys6vEN2ibtU/sFmBKDMMK7fbTWSA ZQ3aodofTzEFBh4JJhJfG4kJtw4CQjzkj0SKUuSbcn1HRxLm1CaNiHcWd5QNcCIA7SYy 7YpOziyKOuoR3WFrqHne/bHWVDkGSrk7CoU12kQi50bV+nCf9PfkTnTrIMyBeCcNeBTp TzDjyMfpoz6cL8x2Vbhw3+MLr5XgMbYWH2GbsUsGtOBNG8oABreu+L7IHy7Edqlg+TK6 HWiQ== X-Gm-Message-State: AOJu0Yxjg3ID/s/3XHuwqxMqH/dFZtUZUUk+BiIFslic6fBzP+PCLJh3 09E8XY81Zo3JNxJZMZQjRAIzq7y0T84JKHO0sIAJSTrASfOd2jHZTMgygx7d6QuEHxSGWVgogHi pe+4DXN3jKFqY6m1AMAEXy0vI4/fjIo4CRIn3pOTzRoN811TEA8CIpvuR1um2bW9nvJzkr3g/tt l1JV6f84w= X-Received: by 2002:a7b:cc8f:0:b0:40a:6235:e832 with SMTP id p15-20020a7bcc8f000000b0040a6235e832mr646341wma.19.1700777606366; Thu, 23 Nov 2023 14:13:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUS52KyNbklxpPEj23AckZsdZntJX98+LIJ9h/c+7dPvbvw5i7N6FBV/jDsPgq5cqyhTFDUQ== X-Received: by 2002:a7b:cc8f:0:b0:40a:6235:e832 with SMTP id p15-20020a7bcc8f000000b0040a6235e832mr646322wma.19.1700777606063; Thu, 23 Nov 2023 14:13:26 -0800 (PST) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id t5-20020adff045000000b00332e6a0e9f4sm1363883wro.75.2023.11.23.14.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 14:13:24 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Maxime Ripard , Zack Rusin , Thomas Zimmermann , Pekka Paalanen , Bilal Elmoussaoui , Simon Ser , Erico Nunes , Sima Vetter , Javier Martinez Canillas , Daniel Vetter , David Airlie , Maarten Lankhorst , dri-devel@lists.freedesktop.org Subject: [PATCH v4 4/5] drm/plane: Extend damage tracking kernel-doc Date: Thu, 23 Nov 2023 23:13:03 +0100 Message-ID: <20231123221315.3579454-5-javierm@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231123221315.3579454-1-javierm@redhat.com> References: <20231123221315.3579454-1-javierm@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 it to the section and mention that helpers only support frame damage, and how drivers handling buffer damage can indicate that the damage clips should be ignored. Also add references to further documentation about the two damage types. Suggested-by: Simon Ser Signed-off-by: Javier Martinez Canillas Reviewed-by: Simon Ser Reviewed-by: Thomas Zimmermann Reviewed-by: Zack Rusin Acked-by: Sima Vetter --- Changes in v4: - Add another paragraph to "Damage Tracking Properties" section to mention the fields that drivers with per-buffer upload target should check to set drm_plane_state.ignore_damage_clips (Sima Vetter). Changes in v3: - Fix typo in the kernel-doc (Simon Ser). - Add a paragraph explaining what the problem in the kernel is and make it clear that the refeference documents are related to how user-space handles this case (Thomas Zimmermann). drivers/gpu/drm/drm_plane.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index 24e7998d1731..662e0ba2707a 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -1442,6 +1442,36 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, * Drivers implementing damage can use drm_atomic_helper_damage_iter_init(= ) and * drm_atomic_helper_damage_iter_next() helper iterator function to get da= mage * rectangles clipped to &drm_plane_state.src. + * + * Note that there are two types of damage handling: frame damage and buff= er + * damage, the type of damage handling implemented depends on a driver's u= pload + * target. Drivers implementing a per-plane or per-CRTC upload target need= to + * handle frame damage, while drivers implementing a per-buffer upload tar= get + * need to handle buffer damage. + * + * The existing damage helpers only support the frame damage type, there i= s no + * buffer age support or similar damage accumulation algorithm implemented= yet. + * + * Only drivers handling frame damage can use the mentioned damage helpers= to + * iterate over the damaged regions. Drivers that handle buffer damage, mu= st set + * &drm_plane_state.ignore_damage_clips for drm_atomic_helper_damage_iter_= init() + * to know that damage clips should be ignored and return &drm_plane_state= .src + * as the damage rectangle, to force a full plane update. + * + * Drivers with a per-buffer upload target could compare the &drm_plane_st= ate.fb + * of the old and new plane states to determine if the framebuffer attache= d to a + * plane has changed or not since the last plane update. If &drm_plane_sta= te.fb + * has changed, then &drm_plane_state.ignore_damage_clips must be set to t= rue. + * + * That is because drivers with a per-plane upload target, expect the back= ing + * storage buffer to not change for a given plane. If the upload buffer ch= anges + * between page flips, the new upload buffer has to be updated as a whole.= This + * can be improved in the future if support for frame damage is added to t= he DRM + * damage helpers, similarly to how user-space already handle this case as= it is + * explained in the following documents: + * + * https://registry.khronos.org/EGL/extensions/KHR/EGL_KHR_swap_buffer= s_with_damage.txt + * https://emersion.fr/blog/2019/intro-to-damage-tracking/ */ =20 /** --=20 2.41.0 From nobody Wed Dec 17 17:23:47 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC126C61D85 for ; Thu, 23 Nov 2023 22:13:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230294AbjKWWNk (ORCPT ); Thu, 23 Nov 2023 17:13:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbjKWWN0 (ORCPT ); Thu, 23 Nov 2023 17:13:26 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE1B110D0 for ; Thu, 23 Nov 2023 14:13:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700777611; 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=7MuULYoz5ao+rLNA+YbUecP2cAJXv6WyavKrHjMaHS4=; b=N5vrvuTS1sPYcdT+cCZ3vQHFtX0dE5FOp6XmnK6NUU41W25BSVQoU1NVsdJBmfflWqWCFX YFCJT/gRXsUO2HhFZ37r8Sf2ziqj3R7N5jka8wvzsq/sqlNLc5zughSY5lJwxx69V1qf+e C4sbbrJgjuz76GMxfnFzm36mBecU960= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-Q5LmLyhONca7s1lakKbPhg-1; Thu, 23 Nov 2023 17:13:29 -0500 X-MC-Unique: Q5LmLyhONca7s1lakKbPhg-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-332e41ed0b4so571516f8f.3 for ; Thu, 23 Nov 2023 14:13:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700777607; x=1701382407; 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=7MuULYoz5ao+rLNA+YbUecP2cAJXv6WyavKrHjMaHS4=; b=g7HMCdelWokJfFWVeklyf6hFvoX2vgEzvaLTMy1g3/f2TKPXuCOePJeomGEkeBNfxU Si5h7MROka7+yp1Wq7yEkVCeynUNO4GtZqKmaNqse+XrGw7oPaxTv2b2EwuTi+PMYRP6 IYDQF4UCXd4IJGSwbct0C0ycxpuiaW0a4KMYeFFST2AErzQQavN54DoZ7+dYmpTdIDAf JNIRvcSf8GMuSSly2Sh9jIgtgEZk26uC5svB95IOFKYFOOdu/VyrdZHnzJxmSA63Tk1h eYw87k+BGQkic48lPpwRe6+LWcwKN2ith9S4NaagE+hVY7zIgTa6TXkDn5Fin4/ElgsR A+uw== X-Gm-Message-State: AOJu0Yx1uKLjuJEeS7H9A3Rdj9edNTxRfMypj8G3+jj40BuIwU4uaz6z o/cLIzF6UqAhp9+ACc6/vAZgi6vAKTDZ7PrmUaimKjLYBmhyrK/K5t2+o0JxwEikw/TPBTY2h4U NAMez+46GqAqZ1Wn7QiKexo+uwCOl310gzHdTCnx5wUuHCYncCF64AOp3lT0oH2cbKhLNKIFuVw Y66KyAVdE= X-Received: by 2002:a5d:40c8:0:b0:332:e777:a8d4 with SMTP id b8-20020a5d40c8000000b00332e777a8d4mr565989wrq.36.1700777607690; Thu, 23 Nov 2023 14:13:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbblMAN+hzDoQaplfSW1Ls9XUsnDbl4YuadfKrIq6lj50fMHkQHToWy2rbRvbEJLq7TAFUoA== X-Received: by 2002:a5d:40c8:0:b0:332:e777:a8d4 with SMTP id b8-20020a5d40c8000000b00332e777a8d4mr565964wrq.36.1700777607350; Thu, 23 Nov 2023 14:13:27 -0800 (PST) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id s7-20020a5d5107000000b00332c6a52040sm2681153wrt.100.2023.11.23.14.13.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 14:13:27 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Maxime Ripard , Zack Rusin , Thomas Zimmermann , Pekka Paalanen , Bilal Elmoussaoui , Simon Ser , Erico Nunes , Sima Vetter , Javier Martinez Canillas , Daniel Vetter , David Airlie , Jonathan Corbet , Maarten Lankhorst , dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org Subject: [PATCH v4 5/5] drm/todo: Add entry about implementing buffer age for damage tracking Date: Thu, 23 Nov 2023 23:13:04 +0100 Message-ID: <20231123221315.3579454-6-javierm@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231123221315.3579454-1-javierm@redhat.com> References: <20231123221315.3579454-1-javierm@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Thomas Zimmermann Reviewed-by: Zack Rusin Acked-by: Sima Vetter --- Changes in v4: - Reference the &drm_plane_state.ignore_damage_clips and the damage helpers in the buffer damage TODO entry (Sima Vetter). Documentation/gpu/todo.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst index b62c7fa0c2bc..503d57c75215 100644 --- a/Documentation/gpu/todo.rst +++ b/Documentation/gpu/todo.rst @@ -782,6 +782,29 @@ Contact: Hans de Goede =20 Level: Advanced =20 +Buffer age or other damage accumulation algorithm for buffer damage +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +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 ther= e is +no support to get the buffer age or any other damage accumulation algorith= m. + +For this reason, the damage helpers just fallback to a full plane update i= f the +framebuffer attached to a plane has changed since the last page-flip. Driv= ers +set &drm_plane_state.ignore_damage_clips to true as indication to +drm_atomic_helper_damage_iter_init() and drm_atomic_helper_damage_iter_nex= t() +helpers that the damage clips should be ignored. + +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 material= s can +be found in :ref:`damage_tracking_properties`. + +Contact: Javier Martinez Canillas + +Level: Advanced + Outside DRM =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 --=20 2.41.0