From patchwork Thu Jan 16 17:47:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13942114 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 450A1C02187 for ; Thu, 16 Jan 2025 17:50:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A0AFC10E9FC; Thu, 16 Jan 2025 17:50:27 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="gbssYxU4"; dkim-atps=neutral Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3046610E9E8 for ; Thu, 16 Jan 2025 17:50:25 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 76DD260008; Thu, 16 Jan 2025 17:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1737049823; 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=9TkYCxm07/sojZ6c0cYCTwDxnVY/JIB1azIs9OmWVIE=; b=gbssYxU4JEjnETPuGjxzxVpOd0hq9g1cC/z6Z0lk4rh/i+huCVFjBFyF8QHh2nsme9s096 H59RDnBeYnKxfA6Xavf2AmCCKbJgb7+lGFZvkb0M8FIgl/ZpsPT1biD51FG68xyFVMQ+GS dK16ijZP91Hsw3atb8CAq++xKaBRlf8cHL1h8PjqdyINs85vx8hpPa+loV/2puAr/VXWKU chCPA/jeUAULdirY8BaDeBqkuPtRb43HnCUwrl6tYpEgrWHOWysnEWUYRvMxWgjYCZGTpt ToUV8bSAVKIiB0BmIssi201gYi1jhotX7lAvHms6lh0aFOp+973BB3mJVz5dFQ== From: Louis Chauvet Date: Thu, 16 Jan 2025 18:47:13 +0100 Subject: [PATCH v9 1/8] drm/vkms: Switch to managed for connector MIME-Version: 1.0 Message-Id: <20250116-google-vkms-managed-v9-1-3e4ae1bd05a0@bootlin.com> References: <20250116-google-vkms-managed-v9-0-3e4ae1bd05a0@bootlin.com> In-Reply-To: <20250116-google-vkms-managed-v9-0-3e4ae1bd05a0@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?= , =?utf-8?b?Sm9zw6kgRXhw?= =?utf-8?b?w7NzaXRv?= X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2235; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=PM67s+sGkYYKTtwGFSTV4ufzHXK8LBbKU9A9EcZIpMg=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBniUbaRJSkjw8EO7dKiVIhW64oKKfoeRftHC5d5 lOzzzcaUq6JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4lG2gAKCRAgrS7GWxAs 4gabD/wNTz4d6trDaV2D2BHNNNa41OAsa4z9ZAF7c6B3ToNuP9rSfksLPLBS2rhVzriksQCdDiV jx/JELUEPREA1tLBiIonwaspvaXN8CC/FZj70oMx7FmKP/ACeOKsrPvhegZ/Vz7Mo04Gm9c6HRZ q18BVWVXAhQaSsn6Cxvq/UE6njaWTjJOXXzB/UfyklSH34lzJC2ndxbP7lMDS1Rs4GNt4U6lTpv 7UlivIpOFfKHknxq3DeS2mnYnPWt0C/uZNhYmLK1aP3jn4m9m8Dngv0UnRB/z3W91l3jAZgUXO9 c21WXdrqWBeGLT2gGmXpc68+8R/OrsUii2JFmd0pFY2/DBY6cFLhnbx8AtaRappcy3efuCdN4DC RbnYVLZf9RrYIHQxXNwbr31D66TnzCA8j7L87QmnGkEuYhOMFJFm3BqI/CadcV3V1DCLMkMBtwf /WciLX/nzO8l52986BbfGbjCQJbLSxI6fxMZ6tB9Jsen4s64kKOK4btiI5ateGpevHfvyRUm/k3 a3eBJ+cy4Z0Kf5TZXPmmgCbB/7E/hwXFuy+UD4yFV4aaautTrYonGk+4uLdHFL03265PwUe7a/q krxhF4DQz7I0FxuEALXpA/SsNxfq+R3uRyTGROwDU7n59aHXIudgTga17T5zvsDeNBL9funjc6m IgKIAOiENA4pEnw== 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 Reviewed-by: José Expósito 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 Thu Jan 16 17:47:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13942115 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 E3B20C02188 for ; Thu, 16 Jan 2025 17:50:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EA26610E9FE; Thu, 16 Jan 2025 17:50:27 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="hmUC/mnE"; dkim-atps=neutral Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by gabe.freedesktop.org (Postfix) with ESMTPS id DEB8D10E9F3 for ; Thu, 16 Jan 2025 17:50:25 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 977E360009; Thu, 16 Jan 2025 17:50:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1737049824; 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=jEZHk/1SbjAWFJgGVljCi7CCHvNiVINr3GrqFQeJNvQ=; b=hmUC/mnE6kGC3NfBHbYG0a86lUZZJS+rlvpChu5fErRSAsbPoUcohraRLZTxjOdFGwmEYr 1v8aH3wdMdptDyd12aVMbe9LOyi03cnecrOnpNOXGeI3xFK0ZWAlGO1HKQQXpYbgOBUaSJ +TCAurRgZd1a8rvEiqs0mf/spz0KzQVbXTX5XKyRyBV9fnvAAgdFLrO0f0slr+ChiK476Q eencke991rmPYwDwAU299vWKSygHbGQtmHTZvDnqkfxS8uCHrV9R65InIsoLTqCsefAIJw WDcEGPOatDjT1yMLqpMqfUglrMJI9dBE3upJEEzBwBesLhOg6GrmUSYr2HZBWA== From: Louis Chauvet Date: Thu, 16 Jan 2025 18:47:14 +0100 Subject: [PATCH v9 2/8] drm/vkms: Switch to managed for encoder MIME-Version: 1.0 Message-Id: <20250116-google-vkms-managed-v9-2-3e4ae1bd05a0@bootlin.com> References: <20250116-google-vkms-managed-v9-0-3e4ae1bd05a0@bootlin.com> In-Reply-To: <20250116-google-vkms-managed-v9-0-3e4ae1bd05a0@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?= , =?utf-8?b?Sm9zw6kgRXhw?= =?utf-8?b?w7NzaXRv?= X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2061; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=KX/HAkpNK4I0905KpjeAVbCo6ZEtfEvZdVMjcNb0FPw=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBniUbaB9GjM17vIvmIm1h990QAP/kMnzoB78Jl/ TygW0hqka2JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4lG2gAKCRAgrS7GWxAs 4jDaD/4/TmWNKnw2T9d8qeFpvIzhLPWGpxF4ZncZWZefYrDFX30xLXUH86lN7+yNb5+700+pUKA GnwkbZqfQtA9h/buqWeP5rkPlbt+H02xlyw9iLXEDhL/Gwce0rIEgsaFZCpqz9uUiVu/L5j0Ucv NifJQAfxtQbDTzNznCDcr2cqtV6qv8A66NIPqI88BdnWW1JpanPdUUYpb6IoK3/SH9a3NewVzPp G3pc6CTMJ8X/CjCiW8m1i1oCzfDiAYcM907bgoVlz4rsHLUx4v6cDMVCiuDAfCs04pdlh2FqHgW 094WxEcDgxgV//JX+xqYeJKe2vjrdeh98a8VAfIFPJszX4UEZuJgHinhGRcR48s8UsY9N0B3Z4Y tcT3G6rBjqpHyyqQNsUomh5GY8SjW50zTASU1t9gaCAyL/vCoADfDf2bEgLkAyagTD6eAR324ns 986kCDynIHex0uvViAA6FTsw3QRbNoqLHYZ2BXVfbKkPuq6Wh2GBZu0Gd1T0cYsnsY4cM7bSL/b zcd5S5igf4wcQO4DXMNoopKhVOrEYrpiW8AZoulNe9e0BUQt0hnHI5QkkezRUzMX7tck8+kWsVp g3envLnhLSs+FqgTSwubK35bY4wEI55osQ8e2sstWEgyOa/KkzZvYW2us/HEK4OCsuWDsgBIAqX T8e+AnYCx4QAW7g== 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 Reviewed-by: José Expósito 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 Thu Jan 16 17:47:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13942116 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 4FA74C02187 for ; Thu, 16 Jan 2025 17:50:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E35E110E9FD; Thu, 16 Jan 2025 17:50:27 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="YbWbU+LB"; dkim-atps=neutral Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id E3B7910E9F7 for ; Thu, 16 Jan 2025 17:50:26 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id BBD7760003; Thu, 16 Jan 2025 17:50:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1737049825; 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=C55lE0ZX4SLEBnGzIQ+kPoz6hSe2chdNlu0VIsQzufs=; b=YbWbU+LBmv5Wk1wSbPn/SNoqwwF7VHHvD0b52KGEspIvmBSx9oUzdIzuBkuLjsSo1fCU+w CzqZBSxC65GWsYF2mnRs7Un/IwSOJ5CWjyj90PFQz6WZsLOcMHamNCe6TYKHYKJ7OeZPH9 0UtBKB2CX4F0kMVSW+ZlIrqIkP+f/6vPtVQwCzbLYXZqTE5k4UJizSwyKwbxFOyik6WiMm 4erWegVILKnE9aAOQyVcBEHGJJIJLggr9EPZvkIsivtvyafHx0DsQDZ3gfqx4y/Fxk6zRj k/0tdDiYs0TQjWlmmCiR1kAHUZJz6ACDGuddgFlwfkOXWemslmTWamj6T06Q4g== From: Louis Chauvet Date: Thu, 16 Jan 2025 18:47:15 +0100 Subject: [PATCH v9 3/8] drm/managed: Add DRM-managed alloc_ordered_workqueue MIME-Version: 1.0 Message-Id: <20250116-google-vkms-managed-v9-3-3e4ae1bd05a0@bootlin.com> References: <20250116-google-vkms-managed-v9-0-3e4ae1bd05a0@bootlin.com> In-Reply-To: <20250116-google-vkms-managed-v9-0-3e4ae1bd05a0@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=1874; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=LCLwmCM9c7LwCX1PNAjtkYs3KXzru4Sc/zivj1tkBlM=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBniUbal7Q1fP6gFFM71jVzOhnCkb03sJkY/yDV/ 65FNMz3dOuJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4lG2gAKCRAgrS7GWxAs 4poCEADRNvwy6l1heqN4VSEF9s73+cfQQqHAH7wjmXCJoVvxa6SeLc0353ZznO4GoV/rDAYOGGp lc8su3afg9FQWE+EHnH+6KzXtlt11UgibNshjeO2h4BlCZbfa5QNuXZbXKP65z9RoGhvUM3LEEE ZBiTqToxC2vLIvKVlq7wUzpPyphfxWFYICoCkv1Qiy7TUz2FhgCNbaHXqYoCr/xSDZoxCZ0AaAg VRJmyrcLBl+BCDoO0KFMaQdrxAirSkdppA7DBSNt04+R2PVaRm/GgLOrEfU5HW6koT7ovWPhAbw G/rehKRAetKae3JtiMIOwHk/MLqYKzoMjh/vPQ+qtF2LfnIAZw+URqlmyevMid69Yi/8Av7QXES olKVYMlJYtkkgwqz3tIVdL4C4PkMKU77ZftLjfJol7Hlo48A+2vlaXUGoySoOS6iyLYTfyJJGBn e+d//v0egPnXa1+RhnCmOtN3Esak2jHN5ushhv7Mj2Yi/8Ov7RrRG7P+Q/sxqwMk6SwEoMyOkRu PTfLeo3f1lRxr9PDY0iqbv+xF2poQa9u9X6atB1Mc+4mytLJSzHcm9kwS4cv4wHMGbkMzHeI5mT AGO3PZWhuCNcBLjeNTBjNgWzmIUA3fZakQpVgcxMZdUPBO1/xoveIi8SJloUg8VA3EMf78efFwX khDmNRKLa3267qQ== 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. Reviewed-by: Thomas Zimmermann Signed-off-by: Louis Chauvet Reviewed-by: Maxime Ripard --- 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..cc4c463daae7ca44914d3468457a22574cdd0a54 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_workqueue_release(struct drm_device *device, void *res) +{ + struct workqueue_struct *wq = res; + + destroy_workqueue(wq); +} +EXPORT_SYMBOL(__drmm_workqueue_release); diff --git a/include/drm/drm_managed.h b/include/drm/drm_managed.h index f547b09ca0239dd7c4fb734038bae4438321395c..53017cc609ac617283e3be70cb5759908b049c4d 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_workqueue_release(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_workqueue_release, wq); \ + ret ? ERR_PTR(ret) : wq; \ + }) : \ + wq; \ + }) + #endif From patchwork Thu Jan 16 17:47:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13942120 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 27E8DC02187 for ; Thu, 16 Jan 2025 17:50:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EDB4E10E9ED; Thu, 16 Jan 2025 17:50:33 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="K67hMzqW"; dkim-atps=neutral Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by gabe.freedesktop.org (Postfix) with ESMTPS id F19EB10E9FF for ; Thu, 16 Jan 2025 17:50:27 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id C2D256000A; Thu, 16 Jan 2025 17:50:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1737049826; 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=oNdbYbwEiFXz/MSftXWv5nbF5QsUpnFMphoZPTHXipQ=; b=K67hMzqWAcpD19Pm0WLtq389I2MhzRaNm6Uwn1ZsuxRau3U8S47afJAG7DBA4pk1fD8cEB HxvcI9e0mbGncn1ntXF1ZyfegmCIKb9zvf9I77VauirILN3EKJLmqQ9p6FucOOrll+fpyN kfm3PB3/1Yo7i4U5OfBS8Qcmd/AnBufVvWn5/MOc2A9Em0qwnxQbXAbkgUbtx8gU5iqcNi MywQxDtZ2ORn70/AUsEF2s12BxDyCPZAI/w8DS5ucm+quE6+TQLSdt9CAZqVSn/BIQdtjl anKEsiGVMfGRFg3tIkP98E/v+DE9Ac9GJDEY79i30jt83BYZPZlpzqwFJVQkhQ== From: Louis Chauvet Date: Thu, 16 Jan 2025 18:47:16 +0100 Subject: [PATCH v9 4/8] drm/vkms: Switch to managed for crtc MIME-Version: 1.0 Message-Id: <20250116-google-vkms-managed-v9-4-3e4ae1bd05a0@bootlin.com> References: <20250116-google-vkms-managed-v9-0-3e4ae1bd05a0@bootlin.com> In-Reply-To: <20250116-google-vkms-managed-v9-0-3e4ae1bd05a0@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=2560; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=n9xXUrclSXq7wRtakJH3mjseEyghccrgyUTnDFFh6xM=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBniUbbeBEP6+NBmYskSSw5cGmsy0xzy9p1UerHu Wto1JXtXZ6JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4lG2wAKCRAgrS7GWxAs 4sdGD/9HQ5B9BvKNYSLfP6IDL8WDEvjvOTfWo4ct+D0+InW9oWbNKAgQcZmAalK+t6evbl/sGkW fhbrYvQXkh+lWGdSllsg3W8vMDFUFpy23XMXQsQSxyA9xJuImz4ywoDhYAJcOIoZZ5d/7aP9X66 ZoomHkxLZzatxsHBic+QJWDHRr3nwZiitJVJD3YTywdpN8xwJGeEnG0oMXcmABftpFfqCBzG1j5 0JhIx9Y0uZoAy/OQTnsqLhK9szFfhpp2VeDEm9xAXltCvhKE6K/EX6lrVTgqvs/Esb9lncxqyf+ kXvQLIGubiRiceHjOS+4HwLC7PTaZHGEbp3w5kLlmYgMM6RysZZzjWFgOcTAPaERozlni20aoOo S2p5rkJosGRNq4iGZlV+nTgHLmKV89mbfCJMJb5jgro09AYHCRhPJ1OR/zmPA6eC7SkUL+CK94i o4uBQY9CUV406A7OJ965LfiexrugGACNCUDQdSDbRJZRXiBo+W8kDhYGxnV35C35ZTpc++AoG89 91Gr14s7wt+uO8OoUdp9VFEaBOY/xmZVxAT2o1q37L0vi+pNFQX3O/PAG+Y9WGJ575vMl5SdiQQ Y4xhw4Ake7IrSWiUAUk3R+H/JF3fb9cxX686nn6k052qFiY5z1BD8Zb4bJ/TRWYIaBdYj0yFBJN M3q0btXfy6rcQEA== 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. Acked-by: Maxime Ripard Reviewed-by: José Expósito 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 Thu Jan 16 17:47:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13942119 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 617C5C02188 for ; Thu, 16 Jan 2025 17:50:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A270710E9E9; Thu, 16 Jan 2025 17:50:33 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="M4+60L9P"; dkim-atps=neutral Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0B9A310E9F2 for ; Thu, 16 Jan 2025 17:50:28 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id C996A60006; Thu, 16 Jan 2025 17:50:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1737049827; 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=xGMThEXJyZ+d+iwtuQquS99V1avAz1XNEQGo/PruKpM=; b=M4+60L9PwYJmXj4ml4lAIGZ+MdLvn1dfa1FFnW9/rvmbO3gHOn6cegcg/fv0gnyHDg019J 7XCPcnkev8Z0RjWQn2X7hhApWS8xO1KTFAnkPS7s9VHBc93tkhOORhyLwlM5B+O0EuRVwd GyXqtGI3ONQ8RxRUKig+2HrJFt5n9q+Xvgm6BbTd5W4pAauvhbOogL89L7l3DeZrBs5DQs bTx/F/aTMdcsLlX6/TMvGYt9oBeOGSak+gL20iPwsj68OTAJMOiKH0RxlQ9CoBgVtceG9x dEFGPPt2Zr44fELnf7kNeUKlWA328V7wrdY4uS/sZGDqPRDQccylucaVOJiZgQ== From: Louis Chauvet Date: Thu, 16 Jan 2025 18:47:17 +0100 Subject: [PATCH v9 5/8] drm: writeback: Create an helper for drm_writeback_connector initialization MIME-Version: 1.0 Message-Id: <20250116-google-vkms-managed-v9-5-3e4ae1bd05a0@bootlin.com> References: <20250116-google-vkms-managed-v9-0-3e4ae1bd05a0@bootlin.com> In-Reply-To: <20250116-google-vkms-managed-v9-0-3e4ae1bd05a0@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=5799; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=cXIU764ot4bU0T4DzE8iziA3oXxZ5ElbpDMdOw7WjSA=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBniUbbjCOQapYzucx3hL3NAx+ANT2ck1U/x1f9H Sh8zFa688qJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4lG2wAKCRAgrS7GWxAs 4oyJEACt+TggbkhNtHOtJGjJ5gzIw8jZLL4GBPU/QymiuPVUHGw5PbnIdqwNzBjikn5eyluZZb6 o53LhPJJ9jxD111o68zDl2Jyq1upMKObhGPIDgK5L8LccX3NKvg4yEe5hbQYhTpBnoxd0aklWFy DFi3o09JxlFo1fotxXJINNLyKl47/pGusKTIJuxDE/j8VsebvD0LxAl1C4FyqN5DXW/uAJKrZ81 27ttx84Hy2udF5wiVMUBgVy3biaPxggb8r8WPaTxR/Ba7Lj37hCwHuTjP/OPjJV8SPB4eSC76jw Iy+g/NVwtYXPgwGAPWMoFxsAaU0DJ7MEkbwT7sqS7bdVbmAjODdxJEFvYEx4UqFf0FOgF+9KmjG ExNyt0pyKvUq3mDNtFwbi5jpYelsAabE0QRtDameFz0Ekyb7pojt98QZdeHB2O6JBuLq/h1Mqw1 MK0+YzJBWL5vdtMLooOAwN4Bhj6BDKj6OQgUlfJbAQV/3s1bgA66t4M1oYffQhMO0wmGeHhOI4l oOjxG5EDt3VnK2Yq+FUt4ZKkfKi1jyKx6GS8exIncMuSw6iE5OK59TJ0Km++d36Uy1neodQquRl cvy2QLkwLyZdapIsB+/47YHzf4mWwSL4skEDl34HsMd+sRmSJKE+Wo2LsU3r1yP7AIuKIqKSoFD IvYiOzJi4Tg7a9A== 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 | 87 +++++++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/drm_writeback.c b/drivers/gpu/drm/drm_writeback.c index 33a3c98a962d1ec49ac4b353902036cf74290ae6..057af96dafeb879534a695167ad16e8a4e9a1bce 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 @@ -202,7 +203,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 +218,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,11 +265,56 @@ 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_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); From patchwork Thu Jan 16 17:47:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13942121 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 03BCDC0218A for ; Thu, 16 Jan 2025 17:50:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 94D9D10E9F1; Thu, 16 Jan 2025 17:50:34 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="i4jbaIrt"; dkim-atps=neutral Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id F1F8410E9F0 for ; Thu, 16 Jan 2025 17:50:29 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id D548D6000B; Thu, 16 Jan 2025 17:50:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1737049828; 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=kU8aEs77fF9qgIAmqQ6svDQpn6KLGmRQxF31gvkx7D0=; b=i4jbaIrtLSD/fkvoDAR9HMxbycJIeoAH0gT49Tg8DaWWO1XkyI3NS7Fi297gu9WbSvxv89 69C1qqwTPDZ6wHoJD0u3Hnp75wGvwKSV6ylOg7A5/RpEmYoJ0cvaREo+uhnWe+3Wc5J7G0 tno02Wiadtx00Xf4gddECV8tImK48O5sDb7ypw9iBaPsPszWw3hNuMe7C9EAiBvngPNbL6 lR38s6HJcinP1KJODLpb8cZMwk/aJK4H/j5Y1XjKX8kdWNZaFbcnFN95/sByCTPv4jBEEn XVS9s7rSQ2M3VGAptEE8c0W2gTLXNC5XBESFQEhZwdySzEKvvGpyR9DrcTS2LQ== From: Louis Chauvet Date: Thu, 16 Jan 2025 18:47:18 +0100 Subject: [PATCH v9 6/8] drm: writeback: Add missing cleanup in case of initialization failure MIME-Version: 1.0 Message-Id: <20250116-google-vkms-managed-v9-6-3e4ae1bd05a0@bootlin.com> References: <20250116-google-vkms-managed-v9-0-3e4ae1bd05a0@bootlin.com> In-Reply-To: <20250116-google-vkms-managed-v9-0-3e4ae1bd05a0@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=2553; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=M4w0O+NYTB5dgGY2gUWrNLUjYQzNpf3MFvPeyIQjrxs=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBniUbbiyn+IwPfYy8oaogNIn/JdhWXeF157mTID wgP7TWE35aJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4lG2wAKCRAgrS7GWxAs 4sBTD/9fs2GzjcLpO3dOikiL+p8iC6bFhVDltpLhD+/LdDJ464jjS2CtBTgPn+KXxSx1Vb1ufee z15XuwIJT7Saqp+MQT1RFMz/aByDGOgcEzGo+aa+ZNc+DzaC8I+JU050bVhezAUbbh9QPsNsABU h1B669GcRtIW7GGetLVLnj+qPT/vZmQddJFfKJQIDyuqTo1lIGzCjcVkhDXAZM2iqutsEbKQjLF x8XQ8NNLPgbB+VevvVUNpKkV3EZ5yzGujIe4AYeLZce/2kQlCBSMLeBIW8MxXwM4IHu8yJaDZ5s mZ0ZB4vAChz9uNz5E+aRrq57bk+Ix3TGYsExLaZoiI5DgDMZuJvg59IkkUyDzVS6nSfUvH6ohNq 46ldTVlfCQdBLgtEwCOtNI7XrbIZk1wAuy9BCF45Nk3t/k5myVnURVnKj9vT/FoKpBsepucURla XAF6/nDPoqInr+qTIJnlmtzsDnEckeG/VtwW7q+jZt6hthBzKjaJtTTCFmyuaa+nFPf5j/JyVbV /zewCThYGgiJJdyS3ayj+Zo1jcZmprRQ1B1DqffU96+LRNBDYGCsIJ6Bx7rsrq6Hk9D1qH35z8+ D9erNJvoJh+b2x1NkP04pb2fbkgSB4fulakNvAj0fl9lsU7qHJqQiGbeyBNAEQS/I6U/947QLuJ 5430w19o5lf9Nog== 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 | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_writeback.c b/drivers/gpu/drm/drm_writeback.c index 057af96dafeb879534a695167ad16e8a4e9a1bce..4cdc6cdcf76beb33f169a46f5895f0d681b11453 100644 --- a/drivers/gpu/drm/drm_writeback.c +++ b/drivers/gpu/drm/drm_writeback.c @@ -196,6 +196,22 @@ int drm_writeback_connector_init(struct drm_device *dev, } EXPORT_SYMBOL(drm_writeback_connector_init); +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; + } +} + /** * drm_writeback_connector_init_with_encoder - Initialize a writeback connector with * a custom encoder @@ -231,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); @@ -265,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 Thu Jan 16 17:47:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13942118 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 12313C02183 for ; Thu, 16 Jan 2025 17:50:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4CD9C10E9E8; Thu, 16 Jan 2025 17:50:33 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="jMVduNQq"; dkim-atps=neutral Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0BB6210E576 for ; Thu, 16 Jan 2025 17:50:30 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id D5A036000C; Thu, 16 Jan 2025 17:50:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1737049829; 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=tS830BSv3QBhd5psoKpHFXUbN21wRhiq+K8cM+bl5EE=; b=jMVduNQqkTW3LNdOqVWHxyE+hbRM6iXI9TDTQz3IJXWcIcerdTlsRA4kIowTGkFGWuwpv5 /8wqF9Fv9mjifO/dJ6KgDepOAB9bh9icitcJ7yo8Qd8HSGs92GTaTKClUzW3peQIRLiSKm jBHa4+mk0cdRlrxcC542VOGQXOH+Q6ipfVcSIqbz2Ej6mHrg8rKXrQzSuOpI59AyPPTmr4 vbzpNubulIzI2oz6xPfLC9BspRHH1RuDYbzjJXj6UGywkw2dKTk/M29rZva7Qn0LrdVclS o37Avr8PUd0zHijw5cX3ZclrMviDEN9KHEM3h93sgVtS1aypXKmihK9swdNzVA== From: Louis Chauvet Date: Thu, 16 Jan 2025 18:47:19 +0100 Subject: [PATCH v9 7/8] drm: writeback: Create drmm variants for drm_writeback_connector initialization MIME-Version: 1.0 Message-Id: <20250116-google-vkms-managed-v9-7-3e4ae1bd05a0@bootlin.com> References: <20250116-google-vkms-managed-v9-0-3e4ae1bd05a0@bootlin.com> In-Reply-To: <20250116-google-vkms-managed-v9-0-3e4ae1bd05a0@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=4323; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=liZFsNvU9Lk2TYFgA0qSW3dSAtB5swCojSksOEVVuhU=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBniUbcbgn20WN98HytnlHlITfW6Rua5fa9c1krG s+1uOcz+w+JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4lG3AAKCRAgrS7GWxAs 4mjZEADIF+fcrS4h1T50NgzHA9fYgbKey93ZuMnv/zLgpMlIF1OuRTXefI72pHWh0tM7NalDcr8 k5C/iSkMd9NJGWOtdgtumJEF4iCy7vyeaYnaUxRkRJyjq4n++SxRm9NwV5Vq0f5hf2N4LljO838 JhKA11BqYWnGnVst1yScP74PwgXMpb7edPAoLMEJhcgSyLo0afq08uCWjbF/xrPtbU/wED/dvWp Spg6H5KjMOwxX12FZ06LbqP3jTjsHpBN86Cu/ewhv2e0FAnhc/1Zr9CKREDCU5P906C4ERTyLZK Hs/o3fToybWI4TWKfnMTOgquycTpITAVF9V4lLWs2TgTBg2eZjdgCvAwOe0ERWjxEMoKwAdTvpw EUSQqeLC35XpL+iJx45KxbdtT7EuFpcga85364hEmnF/tsC1Ucm9C3AM9e0CLY1sz+dbuehu3lc R5KfFsHI6MTVqsfkXDzvEpsyLrqnrfS8vwempm/TaPKCxr5XO1Z1j9nuhS2Vdh5Pd7kqWqnLk3y KUaR/Du9874gvONx1XGNiL10Q/uyv8AqGKDvpn6eg+bw0Munk4t02CdWh8Mo8dgK2afEYD4W8eO xwE781T7ZsmS32JZBVqUo2hQ8FIONxZuGxoeOLQVE+h3k4HUFUiHK2taIHP3lZunaLwKt9rK8VU dr02quEHAFik5Fw== 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 Acked-by: Maxime Ripard Signed-off-by: Louis Chauvet --- drivers/gpu/drm/drm_writeback.c | 74 +++++++++++++++++++++++++++++++++++++++++ include/drm/drm_writeback.h | 6 ++++ 2 files changed, 80 insertions(+) diff --git a/drivers/gpu/drm/drm_writeback.c b/drivers/gpu/drm/drm_writeback.c index 4cdc6cdcf76beb33f169a46f5895f0d681b11453..3628fbef77524a7390b3929896a20f1c0a82117d 100644 --- a/drivers/gpu/drm/drm_writeback.c +++ b/drivers/gpu/drm/drm_writeback.c @@ -340,6 +340,80 @@ int drm_writeback_connector_init_with_encoder(struct drm_device *dev, } 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); +} + +/** + * 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 Thu Jan 16 17:47:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13942117 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 C6B4CC02187 for ; Thu, 16 Jan 2025 17:50:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2CBA410E576; Thu, 16 Jan 2025 17:50:33 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="C3L1b53V"; dkim-atps=neutral Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 15E3E10E576 for ; Thu, 16 Jan 2025 17:50:31 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id DADB76000E; Thu, 16 Jan 2025 17:50:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1737049830; 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=nhzZxvrPnDnYlsii6eFj0OJ2McwKdDbJQWyRh6qYcPQ=; b=C3L1b53Vl1shEOSK8JEIwz9xlMNDtr/Kk8EQTnJwGA/z+VqQQPVGRYg3PFK28KJ/N7Zpqc zQDz+JlGYhe+QsLZ6Sy1ciWUJy6rIIk8PoP+R0nckIVzyFWGyTfAmFM3yeDms3v5jtV7VX EZQsb7Tm5PnS/fFwujSl35/tmmSjLOmnYjUHhf4TBdTgJ2XXDgIP/sslJfZkQFNo7rr7Di tyY9jZhVpBdDPKr+X6+W6AR7UfOM5g+7g1mKgFiYlT5XX8iPVKN6EfIv+0dRtTIj2AxpAx 5M2Ca3NZMJWNi0fO00ZubTQJV66nLnAzmiunpBCGDvfNAff6nSOgVU+7Ob7PyA== From: Louis Chauvet Date: Thu, 16 Jan 2025 18:47:20 +0100 Subject: [PATCH v9 8/8] drm/vkms: Switch to managed for writeback connector MIME-Version: 1.0 Message-Id: <20250116-google-vkms-managed-v9-8-3e4ae1bd05a0@bootlin.com> References: <20250116-google-vkms-managed-v9-0-3e4ae1bd05a0@bootlin.com> In-Reply-To: <20250116-google-vkms-managed-v9-0-3e4ae1bd05a0@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=3983; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=1suYtLtB3tLbHIVeZkXY+G8WjvuJbilA7ygZ52O3ACg=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBniUbcdVGluHlUhSgEfTXVnF6Y6ZQgLpNb++E0j X51Tn/FmTGJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4lG3AAKCRAgrS7GWxAs 4sd9EADJsTG/AmFCopZSkuTyB4N0w2J4o7A+j5Kr5iCWcnwzKIKnkKPflGmHh43gRrmfIMkX9Hi Q8rLnT8jOI0NqssEAHs1cprKYguoy0AtjgyVMDlS4bWOgW634A1OCrJLjg9ymcIilZedsuH1TvI e6SWpxfHUAM0G8Yy21Xy6udfgcDs+S9DcSwfV7bLO8zbWG3d6ReZPCsfqNWdiDMysHwq36oBPkp z+gKc71wGSfqAbHyIYKALH9HMULJPEHawkA+Kj91fDvm006WU5cXTqCT8Rdc4N0ObFV+T6ovBfL w8WF6Gb2eIjEl9gxUohKnJhNrxOKAsWgN9F05FgX3YuJZcYCe7RNYvJ8JLPZA942Ob7AJaZGxzz eMID9J62PNvExy1MPG7ip9jMyW6oUwCsXJ3FFqh9JaN8wGGj8+BXs2e36wq0hBYk2HUzCTsxwCl qHH9wR4imQAyAECASLiAEoK3wEeOWsZkqYomK5gWxzGhwTrgSxqT3i9GU/Td237E3zfELZX5unG Danq3y3A2binB42MoOZiejb02QAm7QNLIf+m6IWsEHRxatdYR6jWMZYe3iM+vy+IPCzm4dX09l4 mO60302N9LG1hRp1aTYdV8N9fB9DXVFKrX4eH0a9QAqwTrP6esNtsouVFEE6zI8Jz5vNeoOxkiR z76b0D+UU1pkodA== 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 Acked-by: Maxime Ripard 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)); }