From patchwork Mon Jan 13 17:09:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13937812 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 24973C02184 for ; Mon, 13 Jan 2025 17:09:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9AAF110E74F; Mon, 13 Jan 2025 17:09:35 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="PJjZv+Eb"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5441C10E74E for ; Mon, 13 Jan 2025 17:09:34 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id D1C911C0003; Mon, 13 Jan 2025 17:09:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1736788153; 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=uXVFlt/M2yXMzY5/qRvMCWmbv0QIUsPFjlivd4tltRM=; b=PJjZv+Eb8W1tJBHEPxD+m/XEoPs75PNmuAG87g8/gqFtUoB6jlaW8uzL893R5I5EPauZs0 O+D/V+E3gwH6jodaE8903DKImVDJuKNusG+vGUiAsj+0fdqvTOc5XMXkKLdmaVZEAKN3mC iWxUAw9t65dQxeMSumLUQPdi+IEfmYxZcFXPUXkotYgvVZtcf3cxAJklHT/u6ZJOO7Vo+e 4fDVTxu5s19Yor3h8BaBokqd2z6HXXQbL4X1LUrOFYpvZ0wLg5e809GPRHmURB3dILObXG yOLGAb7Gxm+Me/QTGsNJD91RQ8ovBHfwNb5MHkx5bE2r3CSM+JMdoVqjxbF9Mg== From: Louis Chauvet Date: Mon, 13 Jan 2025 18:09:02 +0100 Subject: [PATCH v7 1/7] drm/vkms: Switch to managed for connector MIME-Version: 1.0 Message-Id: <20250113-google-vkms-managed-v7-1-4f81d1893e0b@bootlin.com> References: <20250113-google-vkms-managed-v7-0-4f81d1893e0b@bootlin.com> In-Reply-To: <20250113-google-vkms-managed-v7-0-4f81d1893e0b@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=2123; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=18DPeCWxOUuQwaVIAdaCjW1Z0dvcR+suDpSINITGFoE=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnhUizQl/mOY/AO/jMehsdVtETy1MsDHAxFLywe VMzv6wU0cmJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4VIswAKCRAgrS7GWxAs 4s3EEADVXWBVF6GQyGTcsckxwCPrbTng+ZdkUxF9VmouXauOrcj0wQOK71cuTzp76NmnIFgZo57 NvHs9e5E88Gvnd5YkTGh1jf+BzDDyVJ6EKqEmTcYGIMBzsuGDdmc3K/kTBVb3GEAxb64iJF52OC UkPNBntnBOXcTAHyA4qkKTPX6tMD9g6hO2xeG3IHHNubp7nlWemVh+aoNpj4nsMAe250FUqaqpE i1Y35QqKMdupBpIxQcTc84R+6jR7Nw5TICAX4KI95iiZ5gSzx49LY679NZ1P0/d9EyFvuRhN9Ww UflWEIPQoyfsmW2YbVRFL2/cUR33VB+hbNnwXmuIOClTCX9HRY7wwMYwoc3OSBT8A3uOvJGxWDE yCQ7rwrjps41lK841VMJLFNdkzO0eYDEtFETaMGCUFM8GqShOIUPUE8jVPyq0gTslcOV8lViEQz QDU5vCW/skjTfvgN0PfJ838oUj3VD6RnCtP0fe5u1Es5Gl7B9nQNlUf9yDVBk01GIJ5pcvwlVTY bSEtV8cHU/v2BV9tIdq1r8x9Ik72AW8EmKHVL5N8AR9WwErnCBeIzgrs9Ai8aOE1ZOsgOfp6NHX MlvR6UcQd6xJNgeN3hswsCHDsAGmrGXggDtteSN02OPvnKW5bS7g8N06SG1mwogqpqrNgQpSgUU r+9bZrejjTbqr/Q== 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 Signed-off-by: Louis Chauvet Reviewed-by: Thomas Zimmermann --- 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 Mon Jan 13 17:09:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13937813 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 8A82CC02180 for ; Mon, 13 Jan 2025 17:09:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 06A7F10E74A; Mon, 13 Jan 2025 17:09:39 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="UlOm2pJg"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 69FCA10E74E for ; Mon, 13 Jan 2025 17:09:35 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 2EFE81C000F; Mon, 13 Jan 2025 17:09:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1736788154; 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=ORNcbjUscQPawEReOo+mB/rT9VuEfLQrTBsR3RDKoMc=; b=UlOm2pJgcZwajDylSYbEZaNN3Y5FUX46sHf+kesA/ohBYbd92JfWiw+E+eDFumwb4Lob6K LxcVepQmltydIYwp8WwwebqbOvVhyQMc7AwY3gxPyUE3s0jDH7Ui45IW5qWf3QbOXutAHy 2vYtHR2cfiVEynvvDz0g6fMFwd2TRHKZgWv+jzl/dLcKXC6dRCn5BcoFPFRS9QPf+3dCOE uEPFXFy0AGYAJmmoC8Ag5H2uEgP2cR2C+axeVibPIYUzcE73zBWurCzfsVmeZpgdZZfugR 62SsP1rYoq543NYTGgCDWJLjZEzDkk2NlUSOodyVX3/1uHVyAiwRjpjwgURASw== From: Louis Chauvet Date: Mon, 13 Jan 2025 18:09:03 +0100 Subject: [PATCH v7 2/7] drm/vkms: Switch to managed for encoder MIME-Version: 1.0 Message-Id: <20250113-google-vkms-managed-v7-2-4f81d1893e0b@bootlin.com> References: <20250113-google-vkms-managed-v7-0-4f81d1893e0b@bootlin.com> In-Reply-To: <20250113-google-vkms-managed-v7-0-4f81d1893e0b@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=1949; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=6Q2vv/0lK0qmkxSO71I39a4RcXfCaF3f2eU4aUcvUP4=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnhUizNhxp1556f1fpLrdpsN/LGcKTNOW/RPO75 93ZmS/umWeJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4VIswAKCRAgrS7GWxAs 4kZFD/4vYUrFGFq+DPZ7PD09Q73mDSokvWtOILOranPt9ISSAZoCquQQPZVyz91qZC0p5PkRrBY Qp38Yq5vFWiy4ecAOtlj89Un5xuLHJK9xwOwTqEjPcqhCYNxy5OJxXfn58DcuZ7hoIeLC/Gq4Rf qDxdpBXybB1eg3Fjoyjw5OFpXJIQpGljOL2PBLe9KTWm+8Pnc8+25l4hxI9ZqAHgTdiCHCQsEGg kYx3sLLFHV7bI0VuhsxbM/Uyp43d0pGLvEXnrsqxAOlMSJr0723HCmvrEAuAEHZruCZEiDwf2gR jL7s7/uqHZyV4LiAL1wTs5G/qUawY7JSU5zyBMRqu+PHN74I6VsmnWfRnZQ/8LHPpeXtW3SuNb1 nyfi/TRKkVVT+y+UaFGgGSi8SWGHcciDi4YJKi4DKF+Zfts9xu1bHQoN3DK+fwkoChP+IuNJRdE Axxpx6NFGQj5yXZHGIjxkiUAOIeH9g06JHlC1mS/LUqu7fgM3kDn/o/Sfxax+lFvEFqqTe6xLZ9 XHuDnAjnvKcJaTdxaQIcUWpXyTynWFScaRfdLHHjnsUsDMmBaV/QW4q8l5tgIg6YvM+1XWxe4Ll AR0+u4PvnT6oJ2ypv3PT7KQybtBsva07at6oTRKb9DE0HBU4drEssf27MykUyFh9djYjA9FRiFA sdyVvgMI+DfD2Mg== 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 Signed-off-by: Louis Chauvet Reviewed-by: Thomas Zimmermann --- 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 Mon Jan 13 17:09:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13937810 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 CF173C02180 for ; Mon, 13 Jan 2025 17:09:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5606710E74C; Mon, 13 Jan 2025 17:09:18 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="ZCV437Jp"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6C96B10E74C for ; Mon, 13 Jan 2025 17:09:16 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 45D601C0009; Mon, 13 Jan 2025 17:09:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1736788155; 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=LY2O50zsA6s/xcwj2ByPp9+wVZ9Z+1qLAMiiqprNuz8=; b=ZCV437JpmRS4CzVRIZ+4MIcfq/oPx9gLzp2IpQHR7QZR2PXGJ11FcF2m2XOoY3NBKLWTcP vrV9k8UrASVDDYmyIFNlfYxjoSLpEeO80llV31gZVZV0kG5vzT8D4ZJJR46JL4Bzqm+Y4I rgMnwgXdnKa5jS5TgfBRn4Dbj/a6YGnMV7YVwkpnYe16QfRpI61+5BJ4jCO/TnMiHjWF1N uam/PvcmXXKqSwlhaheg0p3WDZ0Tdh1F7MW6f9nVkbOhJRf1GWWO38CkCJkOIHJXMtm4xl R/Es0n6wNfizCrjQqiXCm2b9nM+tYxZwJbeDT/V5k0XLpa4aql3oCmPHQ3MPrw== From: Louis Chauvet Date: Mon, 13 Jan 2025 18:09:04 +0100 Subject: [PATCH v7 3/7] drm/vkms: Switch to managed for crtc MIME-Version: 1.0 Message-Id: <20250113-google-vkms-managed-v7-3-4f81d1893e0b@bootlin.com> References: <20250113-google-vkms-managed-v7-0-4f81d1893e0b@bootlin.com> In-Reply-To: <20250113-google-vkms-managed-v7-0-4f81d1893e0b@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=2850; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=n0VghhJrbrmKmRsfwMlZZWoRm6homaUFqv46ilHrHUU=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnhUi0EOT+tSz+mKudb80r7D1seKhbcRp5b+63Z 11TagifUX2JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4VItAAKCRAgrS7GWxAs 4l5YD/9qhZOBYzss8Gx42CU8RP4RiU69gx5UdEM6nUYCARc5nJhaJGeioRE7vtLA9B/B3WB2BfS r23187KPM03uvq3Hj6GjGbtnYhlCMrQtvl5xihsJ424lqPxxMjG7i0YJpPwbV0Z/MPeF9hPwOAN 9S0X+IHZd+GAzQoMH5QCpWJBzgQgc8Un1el/gtiptfE0pIx5AsmA/5Vu4TTcrjUkZgwsAFOIARk w7uK/wDAyGks6mgwilK83Gi3YpYuZdYfBdBvZIpH0LbY2yNZFfqZrWzYtoQNmixDz5pzM84lKiV 8dTqCNCgz5FXLlAkKLDOH7JpxXk1gwGyP+FobcgHmI6xwkRniuxyQO5D18Hn1/hGLKcwxps2hOr QaA76EkxA9YfO4i6Sn8lNi56ZnSZzCfvs333iWJ8VcRfqVrsKkzVd/XAiM6P+5crnLPzAuxs6o0 TMxUL5+bRYVD7cK02wBqCxeAw3970ICqHBcPsxYjHSnyfyoTuTwVFwexNfJ8k5FSstwhY7lwIoT qL4j+NXD8KINi0WhVcL0V2QAr96OanUt6ghchSSg84ce60HsgIsqAbqLl+cvLvQTKniJ/TcBphf XxwM7bmNlMRNFo4LZKdhfAvz/IN0TI6iEzDg7GITVm3/uJ+ZeX8rUyiLjgGRRjLiTXWl1ARL/Az sPLpiJSoVsbnLBg== 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. Reviewed-by: Maxime Ripard Reviewed-by: Maíra Canal Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_crtc.c | 14 ++++++++++++++ drivers/gpu/drm/vkms/vkms_drv.c | 9 --------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 28a57ae109fcc05af3fe74f94518c462c09119e3..ace8d293f7da611110c1e117b6cf2f3c9e9b4381 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "vkms_drv.h" @@ -270,6 +271,14 @@ static const struct drm_crtc_helper_funcs vkms_crtc_helper_funcs = { .atomic_disable = vkms_crtc_atomic_disable, }; +static void vkms_crtc_destroy_workqueue(struct drm_device *dev, + void *raw_vkms_out) +{ + struct vkms_output *vkms_out = raw_vkms_out; + + destroy_workqueue(vkms_out->composer_workq); +} + int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, struct drm_plane *primary, struct drm_plane *cursor) { @@ -300,5 +309,10 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, if (!vkms_out->composer_workq) return -ENOMEM; + ret = drmm_add_action_or_reset(dev, vkms_crtc_destroy_workqueue, + vkms_out); + if (ret) + return ret; + return ret; } 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 Mon Jan 13 17:09:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13937814 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 41DB8C02184 for ; Mon, 13 Jan 2025 17:09:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B944B10E752; Mon, 13 Jan 2025 17:09:39 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="n2dwnNcX"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5594E10E752 for ; Mon, 13 Jan 2025 17:09:37 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 401B81C0007; Mon, 13 Jan 2025 17:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1736788156; 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=3fFAivPAfEhXDkpm+SeR8HPURSFxhX7MAYqPXcmPnws=; b=n2dwnNcXcfqdhcHBa6Z09GqO8iLDacdP2LtCUsCOEvAnLPiwUn4B4SfF7iw2HreZefyvOh E5FKVgXm+hmW2Tv950P9BMzzMLHJH+x5QWqOz8QQ69XMRQ2W6fyiYiY5AB5gDe8C7aaG9m 1lVMwVqy54AXh4cE7TX0Gml/45XkgueKPm5JykZES+dJMYSx515tIU/8atetDIH5Hq1Mc/ YPl3QlxFT4bo0BJFnnN/F5o9OY8fXxkrIh6umaG9cHhFpoxPdRTm77TBuJ7OBFjUpazkgJ Wr0IkL2/OZpSJD7QNDNFk5AxSw/QzMRxLVbKBvkH88JjGJe7SlKfCxYiRC9FZw== From: Louis Chauvet Date: Mon, 13 Jan 2025 18:09:05 +0100 Subject: [PATCH v7 4/7] drm: writeback: Create an helper for drm_writeback_connector initialization MIME-Version: 1.0 Message-Id: <20250113-google-vkms-managed-v7-4-4f81d1893e0b@bootlin.com> References: <20250113-google-vkms-managed-v7-0-4f81d1893e0b@bootlin.com> In-Reply-To: <20250113-google-vkms-managed-v7-0-4f81d1893e0b@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=7775; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=S+aaEPE7quqJ1SgsFAmHeuhq0LZ6o3EObHIoqdnoBeM=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnhUi0wlCfCpRSnFqHY1GHrXaQQJtnRsd3jXQWJ xtHecU2nneJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4VItAAKCRAgrS7GWxAs 4q1qEACYJdUHxfdhvXbE3KYz13X7H0LzzXGlfCk9MBsEiykcqrV6+huXvRXXHDsX3XanVKDil2I 1Pa1a0dHmPYtUbYsUIUPrTGZA8ZzBO6IV4uRZSjL4TPrqqGbxirmYY38GVnQBpbMzxtSNJHuaTZ 8KdK2jd/8N5d/ua3P9YfVPT2rVmCPe0r88ieqKyacZIyzC6Z0RwrcfWvQgVhGrKX+hF0bew/Tgf KlET4Wgz0wDXXuYBlEvGWIwDhJxB6a0yYoyTdT9lM2b2XRVjc0d4XetvvWFyBIs7EfZvrpy2JNl MLe38Ryl3yP6Rt97KObrIZhmqYN5poFrikksiFTFVbXHkh027F2aq71R2yiDH1cwUPB2H13e6bf lbCELzpv/yxwG9HNF3jdRj9rOYxkBp7/jJDTAz58BGoAXW1eSZXkHdIggxG+Xli/yEkGHrkPgOv RqC7Qp3S/xpw1HMTDurmDzR28DUR4uNCLFEobO1P2io/UBYXCYTTehqdICgbr69xIn5ZYzhWn2B sY2eLsqHT8YbLdgrw0jRVOLOmoXttcOatzz4jL7seJ+BWS7d/Mb7/77s7UgPLESCxJ/KzGeTdhU qIhMMbWemYEbab2USk8qJTxy+EF+vO5G3JMGB3c3Su7ktqy5yYkcFNAT978BiZz0yeEy77JqtA8 up8fgDSBpm6hOqg== 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 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 Mon Jan 13 17:09:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13937811 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 F0E7AC02184 for ; Mon, 13 Jan 2025 17:09:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7AD4B10E74D; Mon, 13 Jan 2025 17:09:20 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="K4XUM005"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5BA4410E74D for ; Mon, 13 Jan 2025 17:09:18 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 373DD1C000C; Mon, 13 Jan 2025 17:09:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1736788157; 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=IbZGI3iaw6v64Oa62WZ9y1Ih6KJdlkQdAE3kimv6ZpM=; b=K4XUM005KjhqpH/9HH4dVESy0IwvaCRuK9EpqBTda8kFogIvk8edGfrNmRd0eD0tr1HJFl 2zGvLRnetEK28w3uD48rtt2q+kSDQFA+Br/f9rNyEWsBHIUCZHzGHJ7/h8ydTihv2zfjQR XaixdTqxfifHIDPbyya4Kk4aenQENs8YzuJtl6OdE9suVRWuxnVnHxbGrcM4LaTwyslmvU uR6ffFwPUNE5Wptt0lZ9T3blgAFFVmWS55bxdlKmmgs1WHbPVPaqKhdYSFo3tKl3ckeBJh ByOcSvPpDgYVS7vxOmcQ73PiByOi4OhbpFJ1d+hfLI8bzldgZU9oeiyG1wh9kw== From: Louis Chauvet Date: Mon, 13 Jan 2025 18:09:06 +0100 Subject: [PATCH v7 5/7] drm: writeback: Add missing cleanup in case of initialization failure MIME-Version: 1.0 Message-Id: <20250113-google-vkms-managed-v7-5-4f81d1893e0b@bootlin.com> References: <20250113-google-vkms-managed-v7-0-4f81d1893e0b@bootlin.com> In-Reply-To: <20250113-google-vkms-managed-v7-0-4f81d1893e0b@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=1557; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=foxH0jXApj+1fifHQDexLR3f94qCCB3NlkU9y81HDfU=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnhUi0KwaUmHJzaji+m3uAmNQAHwSxhRKsM5kIP 4wL+DY0I3yJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4VItAAKCRAgrS7GWxAs 4jtxD/4/bwSLEZbXMqBqxTJThAiDTh3uDvLMx/GFk4OSYtBWjqlzp6jeY2Lr/bK6icioC07aUzk M+o3afsDljkVnnIgymsMFmxiEgH8pFPp4y98pUo1geWk+RjjwoL5MEWAQ9UVosUWzAvnHxLEVDW 9QgY3e4qS09Q9ugWiFSOsVhz5qNnGs8dy8rNJkrR8xlaeUDcRlKExphznTfwQjuUI3J0SvP+XFj ueFWpCMzJnLKuCnQJUToph4jKgXlUCz0i212KxCMYKGgz0fCJOGaMKACYFJfK/wR5qu0PwTcgXz gJ+R3xTUGl8vRt0Irj/txNJ99+8qgdgVZRby1FP1alziWkLuPAJyt2wRR91IEftFwfgqv5OzDGA f2Ljd3wOVa8CMTh7J/zLF5lTBcHlbyzLPs2BW5toMv3jiKBNTSHGIPr+vq+7T3uIgLCm30VGexm 26pY4IZ+w32Isq69Q1+gHvgVXV1H/Wxu/vbSvsXNhAcWjiX/4/vabf1Yj3kBSC5NBHZk9+gHTUK ii87Nt+LQgU/neGn8hADww8W314iJac0Skov97jlol2gcCxfWkFFEis/wWoOOLwvRD1VefKUKGo W4cSTnFtk36lQG5qCBNjeR3YF8gGGoWy0bvWR/6qLVmyU68Tb/uvNh+KZGvNNbvug3UHfNiry+3 9BQPKVjxXcCc3Bg== 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. 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 Mon Jan 13 17:09:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13937815 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 B02CDC02183 for ; Mon, 13 Jan 2025 17:09:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2FFED10E750; Mon, 13 Jan 2025 17:09:43 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="AFFVB3Bp"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5EE7210E74E for ; Mon, 13 Jan 2025 17:09:39 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 417E01C000E; Mon, 13 Jan 2025 17:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1736788158; 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=Rhkm4SWnVXLA2hOybJrr/wTwUJgRFInEzeDBYkCOeik=; b=AFFVB3BpTpsZJuhZYtVd3PUb7PZUZAskbLXv8bnkd7ekxPt3YcYt2fHZEhtoNUGfgTVjav DCwQkkaCUdwGLZLFcNP3O6O+62DH6nuicZBpOaEnIGIpnA7mizXN8UW8dtNIJ2s+4OVwYB Y80CME09gzdpGSsnmmm0LcMMiWTMTXQoVvAIZus58Qnfkipcd1kGzzMHD+PlgArYUBwkaD 8Q5wjXfkIxaI4knz9NS/NmgIxqRQ3Wtf0HsYrQHP8DOkIqZw2i1rtc97oMLbry6xTPyrs/ D7bQsCKxXb7XTUWdTNmnVZTWdktHXk2+imKCqUdapTPr8kbwsZeKTU3dEIDR8w== From: Louis Chauvet Date: Mon, 13 Jan 2025 18:09:07 +0100 Subject: [PATCH v7 6/7] drm: writeback: Create drmm variants for drm_writeback_connector initialization MIME-Version: 1.0 Message-Id: <20250113-google-vkms-managed-v7-6-4f81d1893e0b@bootlin.com> References: <20250113-google-vkms-managed-v7-0-4f81d1893e0b@bootlin.com> In-Reply-To: <20250113-google-vkms-managed-v7-0-4f81d1893e0b@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=3239; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=tFx2yYzeaN4yo6sXaRo9UQp+25Fu+UIo9XIbw0N4slg=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnhUi1X8MbNc41FCu7qMsbD9Fxsf7DzsfRY8mqG DsVg3LDZ3iJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4VItQAKCRAgrS7GWxAs 4oJVEACaXyBp1esR3bxNkgUOvfJ4bR8uAz5Ba/hxlDjVYgjsTUjImLo1mHDvcQzjh/9mym6Yr5h rQT2oi02ss5YYAXVSiMhOiiUYg++GxfCTvK1eAg1rTSnU2BDSELZHqUDYdUr9wtwm4LIkkC1LFx yIgyC8wxQareAsbVQGoWQ88ipj/l3xVprzwKIhLg9cwK/3Yjex7nqqzG0F2zUXxu4K0yYCAZE+U UH/T9lgOsW1KJ6ePwyCe5UlJgnoDVTmU25i0cHcGtZAfymWW+wxiAtDo1lltRhwvGAhQV1nVk0Z rqFfxAnQjr/vjo0/GifSUp2Yk4wVNaAZ6MJ4CQ92zKVr7YMxX4XM4DGQ5+qZJqjThduBVW2EfRa ldZDq9/UJM/zAFUdoHap9EfKWF5f3UWjwgHojxhy80v46D18KijXZ95R3uF7SY3Xnh+Ji+ZheVe cKBrLsRIyT8lSEoUwRo8msEDQOZeQmiTCRW8f/QeW3Vfdj7+pFZ/L4GQAhlIddruSvno8roWhml TXhltIbdAHEP5DF7Ja8RDApf/Zh8qWUSy1owL7P7AjtmK/0A8ROKXigBRhkOk462Lhja9XBcR3t 6qQmQoeKlCnN6dPEVky8AZXDytXywbGEl2GfBSbz9LObQId+c4KWkG2Ax79osomn4GCP72cggfZ 6RP/MLZemeLTCNw== 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. 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 Mon Jan 13 17:09:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13937816 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 40E90C02180 for ; Mon, 13 Jan 2025 17:09:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD3D710E753; Mon, 13 Jan 2025 17:09:44 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="VGy0oUNX"; dkim-atps=neutral Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6EEDB10E753 for ; Mon, 13 Jan 2025 17:09:40 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 3D6B61C0002; Mon, 13 Jan 2025 17:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1736788159; 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=8Opgd83E1kbsxTBGQ+iNZVkk1b4ntm5v/M8pnYqyoxY=; b=VGy0oUNX1XCIuEEUoiRvu4V7h2QeD+aijXRWL23er5ODw48XEFJK+6pt18KV+e5NILK0Wo 1pxpGJ4ZLl/+QjlHaJdTB65lJ/gCBk2t24DYa5ZArokCLAiFtgttsqYmUcW8nX0HmOuLSJ uD6HbSYsOInByV+GJSpi1orKVnnsO6K56uCvA7AkiXXImPlZP3+Wo//xN9Z5pO6AxzOt4y NTl3glyq7+nH27sv2MLr4IpiM+du78AqOZR6Dw2HUTrd5P94p7k9pVEcv22XPp31xfljZc 8ddLTsUwR/2ny3x2rmMdw8f2fYA5X2SlvLjVdk4Sq7926LyXGOhyPYrC6HULvw== From: Louis Chauvet Date: Mon, 13 Jan 2025 18:09:08 +0100 Subject: [PATCH v7 7/7] drm/vkms: Switch to managed for writeback connector MIME-Version: 1.0 Message-Id: <20250113-google-vkms-managed-v7-7-4f81d1893e0b@bootlin.com> References: <20250113-google-vkms-managed-v7-0-4f81d1893e0b@bootlin.com> In-Reply-To: <20250113-google-vkms-managed-v7-0-4f81d1893e0b@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?b?Sm9zw6kgRXhww7NzaXRv?= X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3886; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=iExjIo72bcu0kyT4QK9hMtyH/I0rWLbCXQIFq+d+7Zk=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnhUi1tCnwrydWcnI/Zzc+3aN8YgTrQuMCt/ifz IiT7ItLpkeJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4VItQAKCRAgrS7GWxAs 4lNTEAC9Fv5CiH1O8fmAkszsGKsf9ygqBZnu/hXI/fbHc27tuBuEfBxduH8huEY+/nLYsyDMO9Z p+psRCHkGmDIyn/4kDn3ObsvzSQsVzZu3i9BVHEP/CgTuNxi00UA9BE09m2JCag7dz4lKnGv8+m bb+ZPAKYfQye45cEK8aWOP3ga7Z4X7J7SSpCu8wFjH+Il4rXPwGYYGRvC0bLev5b1SDd3kJL6wo bzMGtl0Y3s5DZymN8pZBtI/rsa9hdc/8Wtxcmyj25roVl2bU0GDuoVufTQwcTd4T2f67VBGa7ZQ wRgNsj2HWmwrE667aKDUBrBMEPPY2W7pewvsJIrVFIs4lUC4ggW3M+gjMIZRuYF1pdDif8nAmmn Npj11VgnbUEYyAdFi1XiX6Y4qnwpl3Gjxm7RfKYu6HSLCWG6q+i5BO2evtZ506zTHduQ8hJB0dG P+cRzlxAgYGkx8PHcGTK7fh3m39sn7epUyI4/Gs4KSnBYjPNDm+EYpjT8SMBGnQ8YkSwYtncxuO /vZ5jTW4+O8gc28HdcWtXh+XxRol9xC/pTKbDBnDJ/kLSFQzy8PHX710Z6vyK1xWe9Ql8/D+EE6 1ICBKvqIdsFp1PpDgbt3ANdBZ/4kI6SxRKAz4T6R8uwlS8ItHjEEz3oF5WpTMkJoaqxzVazVagz 2o/xcB8eDWVwj3w== 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. Reviewed-by: José Expósito 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)); }