From patchwork Tue Jan 14 14:05:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13938804 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 4D58FE77188 for ; Tue, 14 Jan 2025 14:06:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A866210E340; Tue, 14 Jan 2025 14:06:07 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="cJQjJKSQ"; dkim-atps=neutral X-Greylist: delayed 2762 seconds by postgrey-1.36 at gabe; Tue, 14 Jan 2025 14:06:03 UTC Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6570A10E339 for ; Tue, 14 Jan 2025 14:06:03 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 27CECC0008; Tue, 14 Jan 2025 14:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1736863561; 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=VIFyceN+CaL84qPcfLeI60AzvNAanuLMn9nl8UfY3Q8=; b=cJQjJKSQGLXiTpUSdEsKhwpHl+nqZf0V2+Jp/+5AGSM2Zm9oNoKjiLafKqFSTtzq4NAd6C IqWTtrXoR3LAKl6aIDwtQmZyotpzvM2YgUlfDMFyxecOg+5Kt0ws/TlE3lV+qkge/yzIMr s82x/zcDJN5omwo+4UW/wpmjc4IHmSr2zSCy4ew+lzY/Ox4+trXza3ABNxSEe130g8qknv yGMKYax/yQ6baRHc145DigPHN1hiCfxGWCbffROqK1tnbh6qr0E0isPnGZ5OCvoeZOcCEk ypo5bCL5U9iklkfDedOB5h6KSENf9OBdK+TaT4TUfdt1zJfi1YIa1a83NONWiA== From: Louis Chauvet Date: Tue, 14 Jan 2025 15:05:43 +0100 Subject: [PATCH v8 1/8] drm/vkms: Switch to managed for connector MIME-Version: 1.0 Message-Id: <20250114-google-vkms-managed-v8-1-da4254aa3dd5@bootlin.com> References: <20250114-google-vkms-managed-v8-0-da4254aa3dd5@bootlin.com> In-Reply-To: <20250114-google-vkms-managed-v8-0-da4254aa3dd5@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet , =?utf-8?q?Ma=C3=ADra_Canal?= X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2177; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=Ikfs4El5UlPszjJQz91MwJjpJTqwatW3fllItNIh9jY=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnhm9D++/e5JO4omB5y5NFlluOb6ziavq+Ogdr1 z1AaAq8+CeJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4ZvQwAKCRAgrS7GWxAs 4lpjD/926OYE8ZRj53I16GBaKWY7ySYytB25fhD6i050CQseGz/wQ/1Zf94m/N+iQEcsXPvkljr xsmggEHPCIMmtZ49S+/3NPKwcoumI9FihMZKoSXKTX4NbEy+kGNTM0GEjaYVmQfsOe6RlHQhg92 IhlQymzal+kd1AVRuEdkR5Ex0XZTnLaZTjhpGEfatSbcAUvmbKtsBFEbT5dsVsr9MZadUH0jdkY ctIbyPv47VjO/0EZWHK5wAz+aPWZWYQUtCIWFX9lVyphT+vxRHnapHzdH7Ewa8iXF4I1USu7JxH sU/V8bftRrjuVPnE+/gP1daQi3MdUSsbrZNhLBE4+6au4oiTHkOhwzi369x82y3yntwiaKDJ6ZN i7VPxtYca54hYv3hLNjGdfU4UkHrgYhTVc0TidwYduY26MOXpiog16JNhdks/yrDDkGe1Rti82P 1X/YUw+Ofi42K2X4CMzAWPqcwJ7CweSW565biP/d1yEXQv3PanhSri2uZ9sNr45ReWVLKkCmIcB BTBOLXPPNdkXRuxvT/KMZ6zbEHLhdKaB8IkyDKZrBzk95JpRWl8SsL5stc9Si/WRjf1ujohX+ba fDrZA1PX3pmk2Efy09WRb1aPlm0/JF3C4vL2W/m/VgHVqYUeLB2L6sYkK/4lJxK+SiA8WGU+VYH d1eZF2ojR+wEdNg== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The current VKMS driver uses non-managed function to create connectors. It is not an issue yet, but in order to support multiple devices easily, convert this code to use drm and device managed helpers. Reviewed-by: Maxime Ripard Reviewed-by: Maíra Canal Reviewed-by: Thomas Zimmermann Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_output.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 8f4bd5aef087b459d37d0cbbf90fe0145090917a..570823ecb28f589e6323036590ec05a2f633bc9b 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -3,11 +3,11 @@ #include "vkms_drv.h" #include #include +#include #include static const struct drm_connector_funcs vkms_connector_funcs = { .fill_modes = drm_helper_probe_single_connector_modes, - .destroy = drm_connector_cleanup, .reset = drm_atomic_helper_connector_reset, .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, @@ -75,8 +75,8 @@ int vkms_output_init(struct vkms_device *vkmsdev) } } - ret = drm_connector_init(dev, connector, &vkms_connector_funcs, - DRM_MODE_CONNECTOR_VIRTUAL); + ret = drmm_connector_init(dev, connector, &vkms_connector_funcs, + DRM_MODE_CONNECTOR_VIRTUAL, NULL); if (ret) { DRM_ERROR("Failed to init connector\n"); return ret; @@ -88,7 +88,7 @@ int vkms_output_init(struct vkms_device *vkmsdev) DRM_MODE_ENCODER_VIRTUAL, NULL); if (ret) { DRM_ERROR("Failed to init encoder\n"); - goto err_encoder; + return ret; } encoder->possible_crtcs = drm_crtc_mask(crtc); @@ -110,9 +110,5 @@ int vkms_output_init(struct vkms_device *vkmsdev) err_attach: drm_encoder_cleanup(encoder); - -err_encoder: - drm_connector_cleanup(connector); - return ret; } From patchwork Tue Jan 14 14:05:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13938805 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 D7CA0C02184 for ; Tue, 14 Jan 2025 14:06:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E5ED410E347; Tue, 14 Jan 2025 14:06:07 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="XOnQA1/p"; dkim-atps=neutral Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by gabe.freedesktop.org (Postfix) with ESMTPS id 65F0510E33A for ; Tue, 14 Jan 2025 14:06:03 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 249BCC000F; Tue, 14 Jan 2025 14:06:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1736863561; 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=O3siswyDnJUjiz5TlZzFY3sfnn2PJfMpAj4ZraYxKJs=; b=XOnQA1/pWekiCmg9bLJDQnKenlV+tnRbAvoyNX+AyQ0M8l8UleA+hbp5o9JDJSTuvCdeKK yX1F2LGzZ/hdMu0kRXZ19W68A7fNydnZ5Ncc31JtrRHjSq2qLcB+6qFR91EaCxg+/hK0c6 VFcyCBAQnjV+jWKasdLGAKaxRt5Qsxo3GhyKULrbpwUSzgk8MuZUaUaxCwd2lj5BAi5DV0 xl4q1N5grSGNoTOgE2A+NHPUF7+THweEZquunaKAEdgvbkfMyPcMlOIRp6Zl6DzdrvL8tM ozD/KoXCbnw/YmOizA109W7kfwJMjTDSE4CWmaZ4ALwO9p7Q+MyYSRlwUU+shA== From: Louis Chauvet Date: Tue, 14 Jan 2025 15:05:44 +0100 Subject: [PATCH v8 2/8] drm/vkms: Switch to managed for encoder MIME-Version: 1.0 Message-Id: <20250114-google-vkms-managed-v8-2-da4254aa3dd5@bootlin.com> References: <20250114-google-vkms-managed-v8-0-da4254aa3dd5@bootlin.com> In-Reply-To: <20250114-google-vkms-managed-v8-0-da4254aa3dd5@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet , =?utf-8?q?Ma=C3=ADra_Canal?= X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2003; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=Sp3pqA6hkZX9n+1YVNJEqNXdRm8N2eRH5m6LOQD3GtM=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnhm9EtcsIN2bJS1WgkcTQ7+4uLTXTuW6WX1Zs6 3NW1xQYueWJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4ZvRAAKCRAgrS7GWxAs 4vXFD/4mechptPuL2c/AorSw65ExO3+ydrZJncHPi9FzQgejdJtIqHK2HXm7iLwOYhxAmDNLwqH 5WLhZQuf1WI4OVD1GM7jwSHhfnMrw/NCwQfKnucBI75zNJJTQT+pMHPHwNmFRLbV6Cw8iuppaC6 JnB6GED/4JO8TIVPfjdLmiXX7iRnx0CWaj58aRTU6uMJyQzyxlqjTgrJ9AyaF7zwi2I0WQNISXd WMTo0yKbBGMOX+Mjt4/T5e0JPUX2xBe+MsehJgkNaQ/nZiR+q75s7t6hHWE4L+V8iYrmN1dw6Wg gcis2pdOSUzqMUiv5vA0wLco1Ajx5KoyupHZ1cbkrRJPI6uwc4nGYTCEiaW6t48A4ynPrH3e7YN RGeHbb1ALanYm3onGzLuwKQ4uK1zKQhTPJHibMH/c6oprTng8RfGBKBAgnR1enmbeXBmepwdGAA btogZP3FjsE3+U+PQHTdpt2OyjIkwwq20yy9c+W5BETZMXI/v22DpbDQ7160gGtytydw9PCVLbt 5DWNoyoraptdxeG2cmUk4+Yf25Gge7awgDmmLy6i4HdTuefHKmvZWwignUW5fve8YXahhZfI7m9 0JkrDFdlQMEzUJ5UVar72jJSi8AF+qcPlqyrnGlT5XM5uG840tWukNVIqeeiazjdtg9+Sj2KHrq 33u6GPdk2IrpFTg== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The current VKMS driver uses non-managed function to create encoders. It is not an issue yet, but in order to support multiple devices easily, convert this code to use drm and device managed helpers. Reviewed-by: Maxime Ripard Reviewed-by: Maíra Canal Reviewed-by: Thomas Zimmermann Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_output.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 570823ecb28f589e6323036590ec05a2f633bc9b..ab9affa75b66ce9f00fe025052439405206144ec 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -13,10 +13,6 @@ static const struct drm_connector_funcs vkms_connector_funcs = { .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; -static const struct drm_encoder_funcs vkms_encoder_funcs = { - .destroy = drm_encoder_cleanup, -}; - static int vkms_conn_get_modes(struct drm_connector *connector) { int count; @@ -84,8 +80,8 @@ int vkms_output_init(struct vkms_device *vkmsdev) drm_connector_helper_add(connector, &vkms_conn_helper_funcs); - ret = drm_encoder_init(dev, encoder, &vkms_encoder_funcs, - DRM_MODE_ENCODER_VIRTUAL, NULL); + ret = drmm_encoder_init(dev, encoder, NULL, + DRM_MODE_ENCODER_VIRTUAL, NULL); if (ret) { DRM_ERROR("Failed to init encoder\n"); return ret; @@ -95,7 +91,7 @@ int vkms_output_init(struct vkms_device *vkmsdev) ret = drm_connector_attach_encoder(connector, encoder); if (ret) { DRM_ERROR("Failed to attach connector to encoder\n"); - goto err_attach; + return ret; } if (vkmsdev->config->writeback) { @@ -108,7 +104,5 @@ int vkms_output_init(struct vkms_device *vkmsdev) return 0; -err_attach: - drm_encoder_cleanup(encoder); return ret; } From patchwork Tue Jan 14 14:05:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13938809 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 83B3FC02184 for ; Tue, 14 Jan 2025 14:06:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F90710E34B; Tue, 14 Jan 2025 14:06:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="o1bBSEUj"; dkim-atps=neutral Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4BE0D10E339 for ; Tue, 14 Jan 2025 14:06:04 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 0814BC0002; Tue, 14 Jan 2025 14:06:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1736863562; 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=mwyMvb7WmuoyUdDRn3y5BTnUCKpfTEDcuYqfAhtkcsU=; b=o1bBSEUjKLNxd1rVcbYexTRY7zUiFlxrrNLv5UsvKgPfh0bYCvoD005lZsV1tp630DdDL3 zy92/dt1sj4+SYQ02GSwF5wVsGd+VW1ABkNRc9iFG2VxEOhvZTSpRIyTEUfmk1ZUZLvGbl DLCJt0TcJoxAv/JAedzi8nVKPFm2INWWfVcMu++D83I74Opqb/d1yAJRnI/CyYORIch1EP xbnGNTdgkh7gsjuB2GPgTOKQy2XggALV1A1OOywLWnw/fkbKkNhE7/W4HoRS7D7jjGT6Dv 37RvOn+KYp+Bx25iH9NGrvzRS+WWmM6yMnNFEzw+FgsKPry43yKRsnXZZ8s7rQ== From: Louis Chauvet Date: Tue, 14 Jan 2025 15:05:45 +0100 Subject: [PATCH v8 3/8] drm/managed: Add DRM-managed alloc_ordered_workqueue MIME-Version: 1.0 Message-Id: <20250114-google-vkms-managed-v8-3-da4254aa3dd5@bootlin.com> References: <20250114-google-vkms-managed-v8-0-da4254aa3dd5@bootlin.com> In-Reply-To: <20250114-google-vkms-managed-v8-0-da4254aa3dd5@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2036; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=Kt1qbWns/FoZtH6BOWeZX7TbcSATvPd2mBrp/gGH/rU=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnhm9EsXLjJCtaD35sZUOEmmhEt2Oz5eGPvFAGb RrBJLbQyc6JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4ZvRAAKCRAgrS7GWxAs 4itaD/9seH4WOXtXF8SaGpYWHBQLR02ReKaRZSgijav5IZpsZLYmTf5RRUVGdzE1HCovxxl50dX vk0Z3sqS6iAalSD6SqxVJLU7/rs124ymIwhpaxkwZ0V7H8cqE/h7HMXBUy6oqBJLt0J+26eGJeJ 7RlThR3uKJ78wEEe7Xxf4iaFmeqc+WtS9kOfvXvGXC02AvgnM3j13HpOGrloIiKOkQwOLGeP1VM Am5+7fE9SrTXKma37RDVPueMIYOKMmoCHY/vSkpW+CzDj/T4S+WoWe2Ejk6fuFsXhDc5W2GIa5z RlHT7NTRnN2YcBfgbQLUUP0+bALX+TyY9AGhRQFmf9UhW2jAuamsM/wcoQ/ALM62u0Xj7ZkSw1z 2XZmauHTXvxmeb/LkHjg1qoT0TfkeUy3V5rvtXzc62pNMf9N46EdwYKIYUvJC5ZEtNnGWgDdUVO EK82Y65zEz9YVz+XqX/tvMnEHuRUq1jjXvyZwpcmu1uRgSpsTeREd5smSLhJ3JLSx+dHYLYRxYD DlilzdDh2sv+eoSGxBzFwAwl95vLQch58LZoBv3iqkm/u9xJf1q5IeW+iPLk1Ugyqk62tclx85Z TMt95N8qQBkFYav1O5vGE+gg4rZo7g2cnDKdNaBgO/JzEDn4ekvHg6/a4Uy+0uPwky6Vc37CW29 AZDrmidjPG64Kbw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add drmm_alloc_ordered_workqueue(), a helper that provides managed ordered workqueue cleanup. The workqueue will be destroyed with the final reference of the DRM device. Signed-off-by: Louis Chauvet Reviewed-by: Thomas Zimmermann --- Hi Thomas, I noted that you wanted to mark this as Reviewed, but as this was not the complete patch, I prefered to have a confirmation before merging the patch. Thanks for your time, Louis Chauvet --- drivers/gpu/drm/drm_managed.c | 8 ++++++++ include/drm/drm_managed.h | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/gpu/drm/drm_managed.c b/drivers/gpu/drm/drm_managed.c index 79ce86a5bd67a7201f5d60550a12364f2628e0ec..1589c28410f23b5a1e93dd1638420b3ae5c4b854 100644 --- a/drivers/gpu/drm/drm_managed.c +++ b/drivers/gpu/drm/drm_managed.c @@ -310,3 +310,11 @@ void __drmm_mutex_release(struct drm_device *dev, void *res) mutex_destroy(lock); } EXPORT_SYMBOL(__drmm_mutex_release); + +void __drmm_destroy_workqueue(struct drm_device *device, void *res) +{ + struct workqueue_struct *wq = res; + + destroy_workqueue(wq); +} +EXPORT_SYMBOL(__drmm_destroy_workqueue); diff --git a/include/drm/drm_managed.h b/include/drm/drm_managed.h index f547b09ca0239dd7c4fb734038bae4438321395c..96d9b0e811675fe66d5d48f02b17bc7de2ac437e 100644 --- a/include/drm/drm_managed.h +++ b/include/drm/drm_managed.h @@ -127,4 +127,16 @@ void __drmm_mutex_release(struct drm_device *dev, void *res); drmm_add_action_or_reset(dev, __drmm_mutex_release, lock); \ }) \ +void __drmm_destroy_workqueue(struct drm_device *device, void *wq); + +#define drmm_alloc_ordered_workqueue(dev, fmt, flags, args...) \ + ({ \ + struct workqueue_struct *wq = alloc_ordered_workqueue(fmt, flags, ##args); \ + wq ? ({ \ + int ret = drmm_add_action_or_reset(dev, __drmm_destroy_workqueue, wq); \ + ret ? ERR_PTR(ret) : wq; \ + }) : \ + wq; \ + }) + #endif From patchwork Tue Jan 14 14:05:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13938808 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 B680DC02183 for ; Tue, 14 Jan 2025 14:06:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5898C10E33A; Tue, 14 Jan 2025 14:06:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="X/yQjhHP"; dkim-atps=neutral Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by gabe.freedesktop.org (Postfix) with ESMTPS id DAD8910E339 for ; Tue, 14 Jan 2025 14:06:04 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id D548DC0012; Tue, 14 Jan 2025 14:06:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1736863563; 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=nfdz9rSCDQ54knSY4hUZlk54DeodeqvA4IAtHVLDF8M=; b=X/yQjhHP9hKFW57aSRrDwvs36p39zAmt7S07+ATNYTa+YRjPoA4L0Jtz7x67CVdX2nS4Nq v2NltYt5HrIM9sJEeNNfrUkGsRfK15NPIs29jX3oo3cYeF82mvGUxijzp1RdeVLrfVqM26 DTI4EFxVNA+QH6t/xLotzbQSAPCWXYGkQNM5sFxmnRP9nVG2zVAmWJnyMGbTwLT+bD7X40 VgWitW7bHJ/NVw5nfUTQoxU8pJMcvhBy63qN7ssCP1rvof+/Cjfdl7OvBKDjBpdnCAO5b9 usRj4pNUF8tEH6F07KOnoU9P8i74PPaDkf5BF2csGuCNVzsPVGFL+FkwMlPiNg== From: Louis Chauvet Date: Tue, 14 Jan 2025 15:05:46 +0100 Subject: [PATCH v8 4/8] drm/vkms: Switch to managed for crtc MIME-Version: 1.0 Message-Id: <20250114-google-vkms-managed-v8-4-da4254aa3dd5@bootlin.com> References: <20250114-google-vkms-managed-v8-0-da4254aa3dd5@bootlin.com> In-Reply-To: <20250114-google-vkms-managed-v8-0-da4254aa3dd5@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2456; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=9FLY9VcgEbXvm/v9Z9EKyaY0lfzgPQJzxtOCb24c+0I=; b=kA0DAAgBIK0uxlsQLOIByyZiAGeGb0SiPXqeFv/Jj1ha5aeQYK0lcwexOogpCriXqr0mrJR6B IkCMwQAAQgAHRYhBE+PuD++eDwxDFBZBCCtLsZbECziBQJnhm9EAAoJECCtLsZbECziwswQANMO UvP7kWq7bzK6tMeovMoQWZ3WlDBhGJ0Kr7s0xiEZ5JtdstSwLDy3wmAVF2IRoVOXNAuGs0/7XM3 y6Fp6HzMr3JMUvQfN6uR4DIEd1K5uUyAeHofQb/raoj/2/az4v9DYxq1NKTUUvoxS/Ec9vO6+gO xCLWfWQYwEgnRhhPgOYY2kjrWUTs2hIEAGY2Cr3Gyoq9eV5xkYZZqGIZJWtIiMt0pS6u6Y2NSLG K7i3ENPrYaSwc8GDHTMRGhWDlbjOomCcsekDTdlzbJuyzbMx4/4aBubO1bQKN1Oe7R9rGOjYM5y V1iIHIQcyf3GrtSGhA06FEdEh7CL53f0ko4PDuI1JIcwq6IzP9q1eU/wJjMw5wztoeo2uPRaY2i B2z6e4PhcdT1rzxFGgIpuzfWXgS/tW1l71ZCZKqFej/CMNmvF5EfS1crJSLGYB188xLnZBSRcK2 jw/8vNiRiMZQUKDY37lvufZSVdgSFBfsg9eHY2p7pWTQ7IdOGjsQT2TlnvvHUc3pJHt4JytqVa9 YljyTkYOFzZPEmxUMs5FtuxkleRkp1jkxIB1sTjL/82Ed8UnB9Tta4z4s+XxwXplMv8fd+ljTV0 Kl538o4+bOZCjXK1NUbfhoRk0B5WgU7RVy16qJyr7+1UhwcLr6uWayQaPKklkZBd+oj4XPHaHeF NFuVD X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The current VKMS driver uses managed function to create crtc, but don't use it to properly clean the crtc workqueue. It is not an issue yet, but in order to support multiple devices easily, convert this code to use drm and device managed helpers. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_crtc.c | 5 ++++- drivers/gpu/drm/vkms/vkms_drv.c | 9 --------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 28a57ae109fcc05af3fe74f94518c462c09119e3..434c35d5e9477d2961826262591db8ab43838e09 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -296,7 +297,9 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, spin_lock_init(&vkms_out->lock); spin_lock_init(&vkms_out->composer_lock); - vkms_out->composer_workq = alloc_ordered_workqueue("vkms_composer", 0); + vkms_out->composer_workq = drmm_alloc_ordered_workqueue(dev, "vkms_composer", 0); + if (IS_ERR(vkms_out->composer_workq)) + return PTR_ERR(vkms_out->composer_workq); if (!vkms_out->composer_workq) return -ENOMEM; diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index e0409aba93496932b32a130ebb608ee53b1a9c59..7c142bfc3bd9de9556621db3e7f570dc0a4fab3a 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -53,14 +53,6 @@ MODULE_PARM_DESC(enable_overlay, "Enable/Disable overlay support"); DEFINE_DRM_GEM_FOPS(vkms_driver_fops); -static void vkms_release(struct drm_device *dev) -{ - struct vkms_device *vkms = drm_device_to_vkms_device(dev); - - if (vkms->output.composer_workq) - destroy_workqueue(vkms->output.composer_workq); -} - static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state) { struct drm_device *dev = old_state->dev; @@ -108,7 +100,6 @@ static const struct drm_debugfs_info vkms_config_debugfs_list[] = { static const struct drm_driver vkms_driver = { .driver_features = DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_GEM, - .release = vkms_release, .fops = &vkms_driver_fops, DRM_GEM_SHMEM_DRIVER_OPS, DRM_FBDEV_SHMEM_DRIVER_OPS, From patchwork Tue Jan 14 14:05:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13938810 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 61B08C02186 for ; Tue, 14 Jan 2025 14:06:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D47EB10E34C; Tue, 14 Jan 2025 14:06:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="Bz2iqpqC"; dkim-atps=neutral Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by gabe.freedesktop.org (Postfix) with ESMTPS id CA90910E339 for ; Tue, 14 Jan 2025 14:06:05 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id C155AC0005; Tue, 14 Jan 2025 14:06:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1736863564; 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=zFn/AUjca2i/hEoIKuKtcikCZTCexwHwYcjZ+DE5iiY=; b=Bz2iqpqCL5xcdQHqVebYGq/qeNaw1gmz/0fK39pTrVqhTb6jR3d4QGdVfWMbWluymO4aqf 5UQ2QSjH4ZznyY6sgmxiMXpRrKHOwhbue0pVBRkA54iKggekS80btOsygBTjDIlgErr2dT 8t7XNSBmsjt7jHMopczesMtI9LR7xx3Adpzm8zJI79aBOzav7cqLYz792c+wSgppLkvddj wNqmq2Ho1vs2grwYkkQ1UfL7CPxe5/meaogAhmqu1aEBc5jfa6QW+8m/Hf/vdzzNdslc+r KpYEti3GfOFjrVCcZGXVcEPAUQx3VewUpwePYpahFeBeg4oquBLRtkPhxRCCpg== From: Louis Chauvet Date: Tue, 14 Jan 2025 15:05:47 +0100 Subject: [PATCH v8 5/8] drm: writeback: Create an helper for drm_writeback_connector initialization MIME-Version: 1.0 Message-Id: <20250114-google-vkms-managed-v8-5-da4254aa3dd5@bootlin.com> References: <20250114-google-vkms-managed-v8-0-da4254aa3dd5@bootlin.com> In-Reply-To: <20250114-google-vkms-managed-v8-0-da4254aa3dd5@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=7826; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=gsmJl13spfiswdVF2RXlYUxPQmEp1gEYwbGWt1PCqJU=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnhm9F4k2ZtrjpCa2xOTuKow7XvBQPS/fY4MY40 Wn6JzE5m/6JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4ZvRQAKCRAgrS7GWxAs 4t+3D/kBIAj4VKic4nfA7wEZJfJEZqjdCVuNFWjJ4wORwWt+UmrMTFFXNXcKGE7sG7y+6LydcSY uTWaUATJUZLYriVuqVMXTs2BvLCZOgDlpKHxQTdKIph7s1mpDQnxqzJDoohWGDDyKU/tn7mPJgf VSwhkhv8DG1090/sIIOpCeDZB7pZpmVRuEZ1zBhwY1udVJ4ANVYvyGmtYTgVplk75/VhPJDfQCJ fqzVhw99NFnoOhABkoFUzdUI/s9dRJANYUvNqtaY8HrLc/sst/TFyP2l6c87N6JnXYVL0Xq4j0F frOYAKYUv/ackg3vwKXKh3Fjyb1bMVK2F0hWLmpS+gB2YvqOuiJK1Tr5Vm0QItRHTI+xoGpSTLR nPlTn3WmZhV/W9Xq/owp12hsGOcaRAZC+cbMo0N1y5xbCDuqy2Vg6MjVxxZ+vBWywKdL2CzQr3G fcSvqpzKZzYZRrHHzpxNyjUPI+fCJ788McsleDTg7zcOBC5krN5fynfUTxyXsYZo226FARhm6p6 1FIdzcShQVH1K3Dv1l8cqAPOZlZ7WlWkG85nxdhJKE4zAZR/S2Ox6+RemqGXppRokqr/xLrgdT9 /4eWgcSaGMjaV2Z99ZJqJ6vBsRKtcSb1Ei7U/dXQScndfNROjKyH494XDmGITwOWW48pQS/2ar9 XMtFZjYN/14x3vg== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" As the old drm and the new drmm variants of drm_writeback_connector requires almost the same initialization, create an internal helper to do most of the initialization work. Currently there is no cleanup function for writeback connectors. To allows implementation of drmm variant of writeback connector, create a cleanup function that can be used to properly remove all the writeback-specific properties and allocations. This also introduce an helper to cleanup only the drm_writeback_connector properties, so it can be used during initialization to cleanup in case of failure. Reviewed-by: Maxime Ripard Acked-by: Thomas Zimmermann Signed-off-by: Louis Chauvet --- drivers/gpu/drm/drm_writeback.c | 130 ++++++++++++++++++++++++++++++++-------- 1 file changed, 104 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/drm_writeback.c b/drivers/gpu/drm/drm_writeback.c index 33a3c98a962d1ec49ac4b353902036cf74290ae6..494400b09796d37ed89145da45d5f1e029632de5 100644 --- a/drivers/gpu/drm/drm_writeback.c +++ b/drivers/gpu/drm/drm_writeback.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -140,6 +141,22 @@ static int create_writeback_properties(struct drm_device *dev) return 0; } +static void delete_writeback_properties(struct drm_device *dev) +{ + if (dev->mode_config.writeback_pixel_formats_property) { + drm_property_destroy(dev, dev->mode_config.writeback_pixel_formats_property); + dev->mode_config.writeback_pixel_formats_property = NULL; + } + if (dev->mode_config.writeback_out_fence_ptr_property) { + drm_property_destroy(dev, dev->mode_config.writeback_out_fence_ptr_property); + dev->mode_config.writeback_out_fence_ptr_property = NULL; + } + if (dev->mode_config.writeback_fb_id_property) { + drm_property_destroy(dev, dev->mode_config.writeback_fb_id_property); + dev->mode_config.writeback_fb_id_property = NULL; + } +} + static const struct drm_encoder_funcs drm_writeback_encoder_funcs = { .destroy = drm_encoder_cleanup, }; @@ -202,7 +219,6 @@ EXPORT_SYMBOL(drm_writeback_connector_init); * @dev: DRM device * @wb_connector: Writeback connector to initialize * @enc: handle to the already initialized drm encoder - * @con_funcs: Connector funcs vtable * @formats: Array of supported pixel formats for the writeback engine * @n_formats: Length of the formats array * @@ -218,41 +234,31 @@ EXPORT_SYMBOL(drm_writeback_connector_init); * assigning the encoder helper functions, possible_crtcs and any other encoder * specific operation. * - * Drivers should always use this function instead of drm_connector_init() to - * set up writeback connectors if they want to manage themselves the lifetime of the - * associated encoder. - * * Returns: 0 on success, or a negative error code */ -int drm_writeback_connector_init_with_encoder(struct drm_device *dev, - struct drm_writeback_connector *wb_connector, struct drm_encoder *enc, - const struct drm_connector_funcs *con_funcs, const u32 *formats, - int n_formats) +static int __drm_writeback_connector_init(struct drm_device *dev, + struct drm_writeback_connector *wb_connector, + struct drm_encoder *enc, const u32 *formats, + int n_formats) { - struct drm_property_blob *blob; struct drm_connector *connector = &wb_connector->base; struct drm_mode_config *config = &dev->mode_config; + struct drm_property_blob *blob; int ret = create_writeback_properties(dev); if (ret != 0) return ret; - blob = drm_property_create_blob(dev, n_formats * sizeof(*formats), - formats); - if (IS_ERR(blob)) - return PTR_ERR(blob); - - connector->interlace_allowed = 0; - ret = drm_connector_init(dev, connector, con_funcs, - DRM_MODE_CONNECTOR_WRITEBACK); - if (ret) - goto connector_fail; - ret = drm_connector_attach_encoder(connector, enc); if (ret) - goto attach_fail; + return ret; + + blob = drm_property_create_blob(dev, n_formats * sizeof(*formats), + formats); + if (IS_ERR(blob)) + return PTR_ERR(blob); INIT_LIST_HEAD(&wb_connector->job_queue); spin_lock_init(&wb_connector->job_lock); @@ -275,15 +281,87 @@ int drm_writeback_connector_init_with_encoder(struct drm_device *dev, wb_connector->pixel_formats_blob_ptr = blob; return 0; +} + +/** + * drm_writeback_connector_init_with_encoder - Initialize a writeback connector with + * a custom encoder + * + * @dev: DRM device + * @wb_connector: Writeback connector to initialize + * @enc: handle to the already initialized drm encoder + * @con_funcs: Connector funcs vtable + * @formats: Array of supported pixel formats for the writeback engine + * @n_formats: Length of the formats array + * + * This function creates the writeback-connector-specific properties if they + * have not been already created, initializes the connector as + * type DRM_MODE_CONNECTOR_WRITEBACK, and correctly initializes the property + * values. + * + * This function assumes that the drm_writeback_connector's encoder has already been + * created and initialized before invoking this function. + * + * In addition, this function also assumes that callers of this API will manage + * assigning the encoder helper functions, possible_crtcs and any other encoder + * specific operation. + * + * Drivers should always use this function instead of drm_connector_init() to + * set up writeback connectors if they want to manage themselves the lifetime of the + * associated encoder. + * + * Returns: 0 on success, or a negative error code + */ +int drm_writeback_connector_init_with_encoder(struct drm_device *dev, + struct drm_writeback_connector *wb_connector, + struct drm_encoder *enc, + const struct drm_connector_funcs *con_funcs, + const u32 *formats, int n_formats) +{ + struct drm_property_blob *blob; + struct drm_connector *connector = &wb_connector->base; + int ret; + + ret = drm_connector_init(dev, connector, con_funcs, + DRM_MODE_CONNECTOR_WRITEBACK); + if (ret) + return ret; + + ret = __drm_writeback_connector_init(dev, wb_connector, enc, formats, + n_formats); + if (ret) + drm_connector_cleanup(connector); -attach_fail: - drm_connector_cleanup(connector); -connector_fail: - drm_property_blob_put(blob); return ret; } EXPORT_SYMBOL(drm_writeback_connector_init_with_encoder); +/** + * drm_writeback_connector_cleanup - Cleanup the writeback connector + * @dev: DRM device + * @wb_connector: Pointer to the writeback connector to clean up + * + * This will decrement the reference counter of blobs and destroy properties. It + * will also clean the remaining jobs in this writeback connector. Caution: This helper will not + * clean up the attached encoder and the drm_connector. + */ +static void drm_writeback_connector_cleanup(struct drm_device *dev, + struct drm_writeback_connector *wb_connector) +{ + unsigned long flags; + struct drm_writeback_job *pos, *n; + + delete_writeback_properties(dev); + drm_property_blob_put(wb_connector->pixel_formats_blob_ptr); + + spin_lock_irqsave(&wb_connector->job_lock, flags); + list_for_each_entry_safe(pos, n, &wb_connector->job_queue, list_entry) { + drm_writeback_cleanup_job(pos); + list_del(&pos->list_entry); + } + spin_unlock_irqrestore(&wb_connector->job_lock, flags); +} + int drm_writeback_set_fb(struct drm_connector_state *conn_state, struct drm_framebuffer *fb) { From patchwork Tue Jan 14 14:05:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13938806 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 9034DC02185 for ; Tue, 14 Jan 2025 14:06:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EC27610E33B; Tue, 14 Jan 2025 14:06:07 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="QElbs/CQ"; dkim-atps=neutral Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by gabe.freedesktop.org (Postfix) with ESMTPS id AC4C610E33A for ; Tue, 14 Jan 2025 14:06:06 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id A551CC0004; Tue, 14 Jan 2025 14:06:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1736863565; 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=B6Ug01Oqgqhn2b6kjWiqMK+M+EZunENKCjdzBTZxkz4=; b=QElbs/CQM/pr9d2xRusEeCYbWqyQnNkuNwr/Hi+zeAbVUghCjdnOuXfqy5GLHPyqykfpjV V8aVZfHS7sBQ6Pvxu3ZxQwrPF/2bRJPgXjOWa/kKz+vCh39CBGEiJvQ42qeK4T2vX9Vhlu FT7jFkXBMNOZz291BBaXFMLYowPEWymboBg4BOQttsS+efTBkEp5RUQQufmWkJJhN4pE4h XYCLeuJmiZoRomxBKyXEyZzIZIqN3ROcKQeWE0B5vF5Xi671DxuOP+hnrIoEZKRUf7OYTc JptICM8OFoQMBj8Q7Ppgb0owbZah7vgVOVpsfdWB4hcnop/LoREe4XSGFiJW2Q== From: Louis Chauvet Date: Tue, 14 Jan 2025 15:05:48 +0100 Subject: [PATCH v8 6/8] drm: writeback: Add missing cleanup in case of initialization failure MIME-Version: 1.0 Message-Id: <20250114-google-vkms-managed-v8-6-da4254aa3dd5@bootlin.com> References: <20250114-google-vkms-managed-v8-0-da4254aa3dd5@bootlin.com> In-Reply-To: <20250114-google-vkms-managed-v8-0-da4254aa3dd5@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1608; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=Jj2xBKvZqIeVLWiarE4BBLIBzl9tolnIJ7HLBg8W17E=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnhm9FgNF3J/UYuMbmAUiIIXOYzBI6CAr0+vRM6 E/gj1T+3r+JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4ZvRQAKCRAgrS7GWxAs 4j6WD/4tdxsmlyAtJ3Y2jqZlR7vV/bWCG+TccCLbZYBRgObBYRgmzb392cDn19cNv080P96EyJx N4oUuS4PHYBepTgr7OAl/3UuGSebT3MzEyrUtGupYR6i4HIj7W7sS8mkUMwGhOX51ZiICCyoYko Rkihwlmvz4GYIhss+rnm0MLAyQpvzD6pMMr/0U8FsJnn9+DbHc0p9qZA+aTWOc0OjE3BhRuzvKa 3CImBMYo3yJhznXDw4+WWXtF/LYZN+fUgwPPZUFuBFM1wwHkddoL7LNspA7UlQE8yKQWIRhS149 aF/QPowMwb/sJqYZ5NY1hG8FgdgGAiieoCdezB+9W1YOI3cj6lG79IcSzyTcnqF/g/qnkuhgYcc kRIDxsYjLDKPbDAjDQyGLrQzcmSIcc6SC5fRJp7XPSr5aKvmavvXMi/j4R4JSk0gh1uLHfQEa8d wAbtOIsfroj1c6OR1VO0/1td1grDK08yrWGqhpPhoOOr9qOhX1ewWI5StoWFeazk2HJkF4v/saK ZXqQvlgcNbdoRA4JwfYoRyjqG+0/MFOAXs3GTjjJfxSi782bJpFt5FFtY5d6crsdpHqElJjPkoF kJlF27lpQ1HLWBeWR9j+d6oZ/yMu+hHDvPcdT/dfbkLUbF2t+oY7jRZovIki5ZFW+2KCtXt19wO +mNk6qx658BUyMQ== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The current implementation of drm_writeback_connector initialization does not properly clean up all resources in case of failure (allocated properties and possible_encoders). Add this cleaning in case of failure. Acked-by: Thomas Zimmermann Signed-off-by: Louis Chauvet --- drivers/gpu/drm/drm_writeback.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_writeback.c b/drivers/gpu/drm/drm_writeback.c index 494400b09796d37ed89145da45d5f1e029632de5..b767184289222353489b21416a3329352c3bdfa0 100644 --- a/drivers/gpu/drm/drm_writeback.c +++ b/drivers/gpu/drm/drm_writeback.c @@ -247,18 +247,20 @@ static int __drm_writeback_connector_init(struct drm_device *dev, int ret = create_writeback_properties(dev); if (ret != 0) - return ret; + goto failed_properties; connector->interlace_allowed = 0; ret = drm_connector_attach_encoder(connector, enc); if (ret) - return ret; + goto failed_properties; blob = drm_property_create_blob(dev, n_formats * sizeof(*formats), formats); - if (IS_ERR(blob)) - return PTR_ERR(blob); + if (IS_ERR(blob)) { + ret = PTR_ERR(blob); + goto failed_properties; + } INIT_LIST_HEAD(&wb_connector->job_queue); spin_lock_init(&wb_connector->job_lock); @@ -281,6 +283,9 @@ static int __drm_writeback_connector_init(struct drm_device *dev, wb_connector->pixel_formats_blob_ptr = blob; return 0; +failed_properties: + delete_writeback_properties(dev); + return ret; } /** From patchwork Tue Jan 14 14:05:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13938811 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 29390E77188 for ; Tue, 14 Jan 2025 14:06:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BEBEB10E339; Tue, 14 Jan 2025 14:06:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="ZUZXflcY"; dkim-atps=neutral Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9070F10E33A for ; Tue, 14 Jan 2025 14:06:07 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 86262C0010; Tue, 14 Jan 2025 14:06:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1736863566; 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=kcFo04aePHcVATEz/b+YPOhv65FHdQoDZzb/BhLAltA=; b=ZUZXflcYXdQKN1L6q+HhHLFX5+0YeYlhBLlNl6FCao25kxq18Lg5EmHyyZIfLI3TuD7Ccr YN1NAa+tasfm2L42Y6oLZ+vLgLU++31jTZKDUc1IfE4jNR7Y1+efI02W1RjILZ3pv81UYL m/7jednKPsKd1dBRiNikHTWWlowXImwIRCgYC808EkyzGYytJinfE8eJCx1PZMVo/w9d5S EU2E/UKTzczj9ePMfdnw0y/bQDGG0771kN0+gUwFKJCMyQpUAj5301jWtUINQKJCnInIvF ornZDU4wzZLtscKDBm3f763jxN5j9ydS7vw3IwzeVNaF5ge04pEfDi1TnXJ2Qw== From: Louis Chauvet Date: Tue, 14 Jan 2025 15:05:49 +0100 Subject: [PATCH v8 7/8] drm: writeback: Create drmm variants for drm_writeback_connector initialization MIME-Version: 1.0 Message-Id: <20250114-google-vkms-managed-v8-7-da4254aa3dd5@bootlin.com> References: <20250114-google-vkms-managed-v8-0-da4254aa3dd5@bootlin.com> In-Reply-To: <20250114-google-vkms-managed-v8-0-da4254aa3dd5@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3290; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=+fUb0GLJudMuErVuypsDt3jWi3Z7jzufxwye9EpDQwI=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnhm9FQz72oosOEbLe+RlYB/2zznAsBCsQEG+V7 2aG/i66xkeJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4ZvRQAKCRAgrS7GWxAs 4ptVD/9UZRIC5vQc+IMa5Au67aIDPhcqTNNjm+pEeXWzm+5wqdsSPwGtOCKQF+8SLzvhMFVm5AN JOJAqeFgLEBqBwH625HalBtU1fTZelP9hIsUf2jbGP3FC9mzdbgDJMF9nOXE6E949BnFCbeOjfK VoCdtFyNE8jWywEQhHnBynCYKww4mxKBWqmDc/gWxTrzlqcDP8bYBaA9fXebeTKkojmkvQk05cI TCySFoKV30lLysv8bDj1gz4jiU5o0yKsRHvm7oQSozK+V2idCeuOjXm8Wrm+8/v/HYDYtgLkPVb HLVnyF1y2e46ll63xSgwIeWSaCzNCxd+8cqpbiVXE5NOSiJkIWH/KBHBHqRs1UzVkXfS5GpG7n5 6YOq5l1NrrIcnOmUkCCvfRzAD0ZpDzZ14yq9b8Fvs+8kJg+qw+QSo4AQmwjh/rhz4lFDgqcXQEe SS7OlQlXyz6CvSIJuOvM/ltU1gpxuavtXb7Jc/BYELU8Iwq3CK56vueTGM+9sLvwZ/DBWa5gGqe S+Mbn5aRt0r60USd2oCLkfAifhSWPSkFtcHjAnN0txsdVcknLMMazwd82f5vZzuBHtfDDnLSOZ1 UQuFa3mWKtonzmyTxJQuBMUnRUgguaXMtvYzcqFttw6mLoZXGVvr/tGOXQroa4F6F5Ie9gc4zgC WGQOaydqAyohQ/w== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To allows driver to only use drmm objects, add helper to create drm_writeback_connectors with automated lifetime management. Acked-by: Thomas Zimmermann Signed-off-by: Louis Chauvet --- drivers/gpu/drm/drm_writeback.c | 48 +++++++++++++++++++++++++++++++++++++++++ include/drm/drm_writeback.h | 6 ++++++ 2 files changed, 54 insertions(+) diff --git a/drivers/gpu/drm/drm_writeback.c b/drivers/gpu/drm/drm_writeback.c index b767184289222353489b21416a3329352c3bdfa0..1d0f35ff96396ee6e887ac987d6075e122e89b1a 100644 --- a/drivers/gpu/drm/drm_writeback.c +++ b/drivers/gpu/drm/drm_writeback.c @@ -367,6 +367,54 @@ static void drm_writeback_connector_cleanup(struct drm_device *dev, spin_unlock_irqrestore(&wb_connector->job_lock, flags); } +/** + * drmm_writeback_connector_init - Initialize a writeback connector with + * a custom encoder + * + * @dev: DRM device + * @wb_connector: Writeback connector to initialize + * @con_funcs: Connector funcs vtable + * @enc: Encoder to connect this writeback connector + * @formats: Array of supported pixel formats for the writeback engine + * @n_formats: Length of the formats array + * + * This function initialize a writeback connector and register its cleanup. + * + * This function creates the writeback-connector-specific properties if they + * have not been already created, initializes the connector as + * type DRM_MODE_CONNECTOR_WRITEBACK, and correctly initializes the property + * values. + * + * Returns: 0 on success, or a negative error code + */ +int drmm_writeback_connector_init(struct drm_device *dev, + struct drm_writeback_connector *wb_connector, + const struct drm_connector_funcs *con_funcs, + struct drm_encoder *enc, + const u32 *formats, int n_formats) +{ + struct drm_connector *connector = &wb_connector->base; + int ret; + + ret = drmm_connector_init(dev, connector, con_funcs, + DRM_MODE_CONNECTOR_WRITEBACK, NULL); + if (ret) + return ret; + + ret = __drm_writeback_connector_init(dev, wb_connector, enc, formats, + n_formats); + if (ret) + return ret; + + ret = drmm_add_action_or_reset(dev, (void *)drm_writeback_connector_cleanup, + wb_connector); + if (ret) + return ret; + + return 0; +} +EXPORT_SYMBOL(drmm_writeback_connector_init); + int drm_writeback_set_fb(struct drm_connector_state *conn_state, struct drm_framebuffer *fb) { diff --git a/include/drm/drm_writeback.h b/include/drm/drm_writeback.h index 17e576c80169a820e8d5587b229b2cc2ee369a18..c380a7b8f55a3616fa070c037d5cc653b0061fe6 100644 --- a/include/drm/drm_writeback.h +++ b/include/drm/drm_writeback.h @@ -161,6 +161,12 @@ int drm_writeback_connector_init_with_encoder(struct drm_device *dev, const struct drm_connector_funcs *con_funcs, const u32 *formats, int n_formats); +int drmm_writeback_connector_init(struct drm_device *dev, + struct drm_writeback_connector *wb_connector, + const struct drm_connector_funcs *con_funcs, + struct drm_encoder *enc, + const u32 *formats, int n_formats); + int drm_writeback_set_fb(struct drm_connector_state *conn_state, struct drm_framebuffer *fb); From patchwork Tue Jan 14 14:05:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13938812 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 F3307C02183 for ; Tue, 14 Jan 2025 14:06:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 26E4A10E34F; Tue, 14 Jan 2025 14:06:10 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="e5eg7+xJ"; dkim-atps=neutral Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by gabe.freedesktop.org (Postfix) with ESMTPS id 795D110E339 for ; Tue, 14 Jan 2025 14:06:08 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 6DD0AC0014; Tue, 14 Jan 2025 14:06:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1736863567; 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=s6dIp4rzcIzAg5vGoAZF2DeDk0BH08IatA2EdlwvT9I=; b=e5eg7+xJEiraCoFiXZVFXGGB3YsXBaMjMQcke7f61cRyOwo259BdSAvzG5iyE857WtYGgh EOrSkWUsI047QAoD8NCJ+BKRjyvVNxhVRgeKXk0kKni7goIwZowPML0ssR+OprJ3zbLtDv eckmbClM4I3YT6R9bhModr2AnPjIHZgE0X8891egO7+tJbZxNgKoMdgtBCeib8Vez0UFSi SOscB2NpACPL9B5A6nxUiDbglGAXQkdesxDb5T4hWm1qEJBhfS5RamhcGhZM0+igf5EnAz i0WGkLdyS3S7p7TADoEMMyS9piIQ1nV391tgDy02g9aO5iLo6bOBkPavHVVSRA== From: Louis Chauvet Date: Tue, 14 Jan 2025 15:05:50 +0100 Subject: [PATCH v8 8/8] drm/vkms: Switch to managed for writeback connector MIME-Version: 1.0 Message-Id: <20250114-google-vkms-managed-v8-8-da4254aa3dd5@bootlin.com> References: <20250114-google-vkms-managed-v8-0-da4254aa3dd5@bootlin.com> In-Reply-To: <20250114-google-vkms-managed-v8-0-da4254aa3dd5@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, nicolejadeyee@google.com, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3879; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=zEON8U4xfektoFrGFLGBfKHveoeJ4SqRMTmMY8YzcnY=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnhm9Fa1eNf7XbIDvBh+53Fu0F2CczKy560q8n3 UqobgZbnOyJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4ZvRQAKCRAgrS7GWxAs 4hCuEACekOJ3wPE1eHHLv3bHQuuEXPy2wCHapfnkGjEHHJcHacDalgBTh5irR5FcHdEtvGaJ8Fa r9XmuNADvFK2SweEtrewUp0NH4l9GGZkhTsI6urjsCGze4/pud/+2xUo44V33nGgRruU52Y/KlJ RkX7qKlC3lBWDXO8BBbZyNyq8R4qURanAESGzvTYJVMmI56dlQobK2bdy3uSyZWbaBb3VLe+7hO E/NiIgHAB2c/n8Cu6SdvQSnP43yMl8MVWIfal3jkcajbVODPxYXc1SfnX9z5cDtFS+OYNW1suEV frSax6wx+H+XS8tt9rAkdYuPM5PBgyXckdE92qeQ9XnkMT2+ICKLQFU1BiBgvntx4KNEKadGoUR qXOWvkhQ3Z8I0K+0O8GWufXLxx3vBii022HOObqsn51QALyOXjtZSsLg4tUclwk+ZBAs2Qhm1YU YZT+fKnt3K5Hp+dAvqOroZ+j4mWI8EZiTuK03FvhVRIk9imsQ2Q2hMnCp2EhH9T8oET9kmCdMP+ tnvXRnM1JPzuLvTdyIPGos5MrgHGb64UO39m3DBLMPE+JXwmzZdfd36NYGYevajRtUpL/hBEz77 11VSjdcLkDmmamkksmfziUvoE9b7eRS2xtjuNQZ4/uH2QYCPCvZWEd8RVADbjjVVQYAM+gA5jwG 3brXy5Ax3xT1rQA== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The current VKMS driver uses non-managed function to create writeback connectors. It is not an issue yet, but in order to support multiple devices easily, convert this code to use drm and device managed helpers. Acked-by: Thomas Zimmermann Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_drv.h | 3 ++- drivers/gpu/drm/vkms/vkms_output.c | 2 +- drivers/gpu/drm/vkms/vkms_writeback.c | 21 +++++++++++++-------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 00541eff3d1b0aa4b374fb94c8fe34932df31509..46ac36aebb27ce8d9018224735007c1b3fe7d0a5 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -179,6 +179,7 @@ struct vkms_output { struct drm_encoder encoder; struct drm_connector connector; struct drm_writeback_connector wb_connector; + struct drm_encoder wb_encoder; struct hrtimer vblank_hrtimer; ktime_t period_ns; struct workqueue_struct *composer_workq; @@ -275,6 +276,6 @@ void vkms_set_composer(struct vkms_output *out, bool enabled); void vkms_writeback_row(struct vkms_writeback_job *wb, const struct line_buffer *src_buffer, int y); /* Writeback */ -int vkms_enable_writeback_connector(struct vkms_device *vkmsdev); +int vkms_enable_writeback_connector(struct vkms_device *vkmsdev, struct drm_crtc *crtc); #endif /* _VKMS_DRV_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index ab9affa75b66ce9f00fe025052439405206144ec..de817e2794860f9071a71b3631460691e0d73a85 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -95,7 +95,7 @@ int vkms_output_init(struct vkms_device *vkmsdev) } if (vkmsdev->config->writeback) { - writeback = vkms_enable_writeback_connector(vkmsdev); + writeback = vkms_enable_writeback_connector(vkmsdev, crtc); if (writeback) DRM_ERROR("Failed to init writeback connector\n"); } diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c index 79918b44fedd7ae2451d1d530fc6d5aabf2d99a3..981975c2b0a0c75e4a3aceca2a965f5876ae0a8f 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -24,7 +24,6 @@ static const u32 vkms_wb_formats[] = { static const struct drm_connector_funcs vkms_wb_connector_funcs = { .fill_modes = drm_helper_probe_single_connector_modes, - .destroy = drm_connector_cleanup, .reset = drm_atomic_helper_connector_reset, .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, @@ -163,16 +162,22 @@ static const struct drm_connector_helper_funcs vkms_wb_conn_helper_funcs = { .atomic_check = vkms_wb_atomic_check, }; -int vkms_enable_writeback_connector(struct vkms_device *vkmsdev) +int vkms_enable_writeback_connector(struct vkms_device *vkmsdev, struct drm_crtc *crtc) { struct drm_writeback_connector *wb = &vkmsdev->output.wb_connector; + int ret; + + ret = drmm_encoder_init(&vkmsdev->drm, &vkmsdev->output.wb_encoder, + NULL, DRM_MODE_ENCODER_VIRTUAL, NULL); + if (ret) + return ret; + vkmsdev->output.wb_encoder.possible_crtcs |= drm_crtc_mask(crtc); drm_connector_helper_add(&wb->base, &vkms_wb_conn_helper_funcs); - return drm_writeback_connector_init(&vkmsdev->drm, wb, - &vkms_wb_connector_funcs, - NULL, - vkms_wb_formats, - ARRAY_SIZE(vkms_wb_formats), - 1); + return drmm_writeback_connector_init(&vkmsdev->drm, wb, + &vkms_wb_connector_funcs, + &vkmsdev->output.wb_encoder, + vkms_wb_formats, + ARRAY_SIZE(vkms_wb_formats)); }