From patchwork Mon Dec 30 18:39:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13923428 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 6CD20E7718F for ; Mon, 30 Dec 2024 18:40:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E9A0F10E572; Mon, 30 Dec 2024 18:40:32 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="DpCBW6mR"; 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 1CA0C10E56D for ; Mon, 30 Dec 2024 18:40:20 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 5650D60004; Mon, 30 Dec 2024 18:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1735584018; 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=kCBx3ymlkAhH0BIP1JaOeEyel3tpTFiAF8iXUOkELOM=; b=DpCBW6mREzMqaKiESWr2KmwWBHsiDKBb98cdLojq2JGbCU1w6ykQ+FpzqPfM+WEWK4dWdL bFE0Z/RX7DHUA+7dbrvCD/bg4qJuez7RWKC+g2oVSqzyh75J0pSR/W7BxjN1adQQseP1HW G4cfWEess+KzMXm1feu+FbIb2m7K3XrdfRGcc8SNaSVMiBBtFHq00aaIGPm+IK6lkDqPMR mKq7KsHSN7ufHFqUmnsEP+c7HGlS35VxqvhQ/QxEwO3w6F7Wql1KejYn98o6pJ+YoWBSHD 5gZ932Q06Be8WsJk1fpR/4DyL3cOwrvxGE7u4kp/wG0U4Y3FtpJxJEu9p1CXHQ== From: Louis Chauvet Date: Mon, 30 Dec 2024 19:39:44 +0100 Subject: [PATCH v3 1/3] drm/vkms: Switch to dynamic allocation for connector MIME-Version: 1.0 Message-Id: <20241230-b4-vkms-allocated-v3-1-5dda4c1bd459@bootlin.com> References: <20241230-b4-vkms-allocated-v3-0-5dda4c1bd459@bootlin.com> In-Reply-To: <20241230-b4-vkms-allocated-v3-0-5dda4c1bd459@bootlin.com> To: Rodrigo Siqueira , =?utf-8?q?Ma=C3=ADra_C?= =?utf-8?q?anal?= , Haneen Mohammed , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: thomas.petazzoni@bootlin.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Louis Chauvet , =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2110; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=RPpG/0FEqNsXZD4OHFcxE/BsPBQGg3e6ebFJPMqGBAE=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBncukOiFm1TkkE+Nn+y0jo+bAfa6zWsEq3rk/LC iG8HEAhTvGJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ3LpDgAKCRAgrS7GWxAs 4iEJEACsJBtBVHn7zawhLmQC43uvRSn6iCccVfYfP4qDeHSSJ/OlgRqJFeKfgNQmJia8FkQiSmz R/+2vuxWmMBYYnVP+NnW5RmC3jjumgVIqsBwu9VyDN0eQMgTodiwNP1miSoWFq8vHutTTNKMvtZ od5PKpl/qZKXudQH9OdeZ24dnpbn4j4qdVUvrhz2kWMHHAYmsYk8j0VHkv3INcx12IsrgucxLhr RwiM4fmXLXbEmgotmkpcdetKWG5XR+o6uIwlKnJxgcgD4Nm/FSYdrAVUtIsYfw8+j2oR8KUcH+0 lmp9b8YWICiiuke6ZN5tcT7p5aolq03e3aXfS7Ip2LUkgBNwWZYC/6gkPrd7d8SvIj/6cK3qTiI FQMPlH40Cr0rvtfysErVHCSXZd3nD7vsuI/f7fPyBPvkG3Pcclj9en/+xUBMd3stEOeerCCBEBW Y1pV2bVjULKob257fAm1YegY55esa3syoqFwILebgdrzWT64Wi96r0hEz+LOSyUQ1+j4KWxln2j oY/hgGl3regiv7ylMRWS9oXw/vpDUHEmAOcEZU1rl4if8qLw0WVwaIF5AgKpy4uXjDx5qmTsIxk EuhtMCJqxiKkpi9vGfsbifn6fEh+0lB/Pe2UoRIRKUqPCUfUh9467QWRWIHK8fnAiEy1elaaBsf YukFqwfp6MFoZpw== 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" A specific allocation for the connector is not strictly necessary at this point, but in order to implement dynamic configuration of VKMS (configFS), it will be easier to have one allocation per connector. Reviewed-by: Maxime Ripard Reviewed-by: José Expósito Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_drv.h | 1 - drivers/gpu/drm/vkms/vkms_output.c | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 00541eff3d1b0aa4b374fb94c8fe34932df31509..820e7899cb049b45d8bdbe5a0dc7be08eee6db69 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -177,7 +177,6 @@ struct vkms_crtc_state { struct vkms_output { struct drm_crtc crtc; struct drm_encoder encoder; - struct drm_connector connector; struct drm_writeback_connector wb_connector; struct hrtimer vblank_hrtimer; ktime_t period_ns; diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index ab9affa75b66ce9f00fe025052439405206144ec..ec3545730ef79af0db51d8ec605b9cdfff52c2a3 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -32,7 +32,7 @@ int vkms_output_init(struct vkms_device *vkmsdev) { struct vkms_output *output = &vkmsdev->output; struct drm_device *dev = &vkmsdev->drm; - struct drm_connector *connector = &output->connector; + struct drm_connector *connector; struct drm_encoder *encoder = &output->encoder; struct drm_crtc *crtc = &output->crtc; struct vkms_plane *primary, *overlay, *cursor = NULL; @@ -71,6 +71,12 @@ int vkms_output_init(struct vkms_device *vkmsdev) } } + connector = drmm_kzalloc(dev, sizeof(*connector), GFP_KERNEL); + if (!connector) { + DRM_ERROR("Failed to allocate connector\n"); + return -ENOMEM; + } + ret = drmm_connector_init(dev, connector, &vkms_connector_funcs, DRM_MODE_CONNECTOR_VIRTUAL, NULL); if (ret) { From patchwork Mon Dec 30 18:39:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13923425 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 B137EE77188 for ; Mon, 30 Dec 2024 18:40:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 07F8310E56D; Mon, 30 Dec 2024 18:40:22 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="T3jg/XvQ"; 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 7436910E56D for ; Mon, 30 Dec 2024 18:40:20 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 2B1D660006; Mon, 30 Dec 2024 18:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1735584018; 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=J1A9pb0GMwj8iBETDvV4cmtpIcpfSITNuH7NBvhE/dY=; b=T3jg/XvQLdLAefdPCZziJLoNZ0a089aHvirv8Wcn6B82jLdGuBfYubb/H2UDjZNApKXdJd oWx/vfeF2V8A1C26z/pK3XjL0sAIKox3wWtXNGfE5irvpj2yrVHyITSvU4pUfyBB8D6KUa zD3ghKZPNL2eCWatJIV3f8sGDzjshiHq3B815Vli1NuWDqZ3aXQRjmIrvYDQTBoNO+A0V6 z+/WGpbemmNKiHVYrpegTCwx3Hxsh3oAACF9+NvURqp95umZ5p+DwZIzA0QkA2AIUG0Pxe yZWzwFkKTTgzjmTean/nI7pg8xf1IySuiT/A7izsmQ2Ue8jp4lxMlKBwY/zemw== From: Louis Chauvet Date: Mon, 30 Dec 2024 19:39:45 +0100 Subject: [PATCH v3 2/3] drm/vkms: Switch to dynamic allocation for encoder MIME-Version: 1.0 Message-Id: <20241230-b4-vkms-allocated-v3-2-5dda4c1bd459@bootlin.com> References: <20241230-b4-vkms-allocated-v3-0-5dda4c1bd459@bootlin.com> In-Reply-To: <20241230-b4-vkms-allocated-v3-0-5dda4c1bd459@bootlin.com> To: Rodrigo Siqueira , =?utf-8?q?Ma=C3=ADra_C?= =?utf-8?q?anal?= , Haneen Mohammed , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: thomas.petazzoni@bootlin.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Louis Chauvet , =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2080; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=POMPML9yUE0ObUiIqQmK6mj1RyDxFdGqid0Ge0WrG+M=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBncukO4SpjQnSiOKiglJPiacp64R1Ns8GYdpKjp PvJ17m6YM2JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ3LpDgAKCRAgrS7GWxAs 4oUaEACBQAYoVCtQ/dqTv4CBnr0vgE6TA9I14qbvHkPEGCIY0JAqFEdu2akz+84dUTvYLXLLtoR 6gPhmNMJ29uMUw3JUMiecC8+hNZknzRz7mpgU/o74jU8Bdc7deBEo1e1HFJHa9Oe6FFDBWchB2h tzZge2+2mOt442eigOpkkTA24uFZATjVVs3lrUrGEx+PPegAQ0OTAvF/mlHlE1qkyeyv81TgPs2 BmlNNrJ9Rsxp/E8Q5CrZ5f8HycmDTEuLV80eBKkRFll+iySLqz/J4toGkf9OjRjaV3s8C+PVIe1 MYEWtkSA/P9VNIfjNeXqGJvrH9EBsloi1VmIy6U+dsHznLks6pzsO/58JJe+TFaavTehONtSsFd xAWaD1VN/WoudjEczjD6YxCNk/7U0qc1QfKt9cY7RaDBSNk4Tu6NtSAkrJg8GUn0lPXFjXweKYr jYL+drp49lyBBt9Qly8lIlPIJfrWsqRxCw9HX9WtBYVdrTIHRSN48ANluSReUsDLVpsAlvMsyLv jbS/cIVzFc56vrD0f+mMntY/DuQC6j+eVXh62Dm6iccR3WCnQSvLBk7FtxFExshScPgIufwDFh5 EvS72gkP1zpvaQ7l/N/Jg6pgoDDm7xXPc7WlLkJDFtN8LUyWelvrIf6wKMQJj2L55EDpjR29lx9 Qvxo+Jxtn82dmjg== 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" A specific allocation for the encoder is not strictly necessary at this point, but in order to implement dynamic configuration of VKMS (configFS), it will be easier to have one allocation per encoder. Reviewed-by: Maxime Ripard Reviewed-by: José Expósito Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_drv.h | 1 - drivers/gpu/drm/vkms/vkms_output.c | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 820e7899cb049b45d8bdbe5a0dc7be08eee6db69..19fd99b8e506c4454d7878b67f692a0441c22665 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -176,7 +176,6 @@ struct vkms_crtc_state { */ struct vkms_output { struct drm_crtc crtc; - struct drm_encoder encoder; struct drm_writeback_connector wb_connector; struct hrtimer vblank_hrtimer; ktime_t period_ns; diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index ec3545730ef79af0db51d8ec605b9cdfff52c2a3..102b6ad466cb4f7c6704f30cea669e5d7f81540a 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -33,7 +33,7 @@ int vkms_output_init(struct vkms_device *vkmsdev) struct vkms_output *output = &vkmsdev->output; struct drm_device *dev = &vkmsdev->drm; struct drm_connector *connector; - struct drm_encoder *encoder = &output->encoder; + struct drm_encoder *encoder; struct drm_crtc *crtc = &output->crtc; struct vkms_plane *primary, *overlay, *cursor = NULL; int ret; @@ -86,6 +86,11 @@ int vkms_output_init(struct vkms_device *vkmsdev) drm_connector_helper_add(connector, &vkms_conn_helper_funcs); + encoder = drmm_kzalloc(dev, sizeof(*encoder), GFP_KERNEL); + if (!encoder) { + DRM_ERROR("Failed to allocate encoder\n"); + return -ENOMEM; + } ret = drmm_encoder_init(dev, encoder, NULL, DRM_MODE_ENCODER_VIRTUAL, NULL); if (ret) { From patchwork Mon Dec 30 18:39:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13923427 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 54B89E77188 for ; Mon, 30 Dec 2024 18:40:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CF41210E56F; Mon, 30 Dec 2024 18:40:29 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="dRgFCBFF"; 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 ABD0110E56F for ; Mon, 30 Dec 2024 18:40:22 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 0784C60007; Mon, 30 Dec 2024 18:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1735584019; 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=ejVlBxA7vj98Ej89LtA3GdoAo/x7ZZVblyFnmVrrUsw=; b=dRgFCBFFOVJ4hcN3/sUM8rFUSk0nLROBQE0VnnsLYb0a5uooi2DSghj/PGRITi1qpDTm/A nKoh//r6xKvPDpruNrowGRVJBw3J9a4hk2NZD1kV7feyPiFqBFl1MWVR5KQJp05j5zJERq nYb0zIZBNMbYIdAFhM1rUSCrb7x8ZEx4ocbft+1qRgThGtpbi2efCt9eD81nkKlkWOQlsA lCL18ttH0gOkqmvYg+i408oP5X9d+W6fjIH4zZBJi87LkG2gdDqUa9BZYX3Y0Az/kqmIJc NZiQHUVmuTueaKXFIlJRfT0wUBhmEi0d47+ErThGMXRuKknr4eAjD1N5QDd/Vw== From: Louis Chauvet Date: Mon, 30 Dec 2024 19:39:46 +0100 Subject: [PATCH v3 3/3] drm/vkms: Switch to dynamic allocation for CRTC MIME-Version: 1.0 Message-Id: <20241230-b4-vkms-allocated-v3-3-5dda4c1bd459@bootlin.com> References: <20241230-b4-vkms-allocated-v3-0-5dda4c1bd459@bootlin.com> In-Reply-To: <20241230-b4-vkms-allocated-v3-0-5dda4c1bd459@bootlin.com> To: Rodrigo Siqueira , =?utf-8?q?Ma=C3=ADra_C?= =?utf-8?q?anal?= , Haneen Mohammed , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter Cc: thomas.petazzoni@bootlin.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Louis Chauvet X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=9168; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=5Ri+QCGq3Od1tyIvjPTguK4NErzVXjgK0W2VCbnkbQM=; b=kA0DAAgBIK0uxlsQLOIByyZiAGdy6Q+jZ0ycX6p5XQ5eZWv3r2sqFetjka+SZX0rSR3pMoJ8r IkCMwQAAQgAHRYhBE+PuD++eDwxDFBZBCCtLsZbECziBQJncukPAAoJECCtLsZbECzixuAP/RVo UFhT7WMFmFl4k6yqnmYRsE38JDcYpRjYwd9UMyDib18CWtneZrswZDJW2fPPnSgf0E3gDNy2er0 X6B5lWXVChqVUvk4mZ+ZdVPbd4HxS01h00QvjoJ40UuDZKOEb0keHEn5cdje9mdxSECQfvN1R5G t6OdVYylR14CiuMUSWKOX+2fuKJGuyH6bIdGHZvrEqMJ2dmJTzpvsSlhaHjJ7QZpF5xe7Uet/zV MtEVKNw2JGyqAFIDxBzUZvz/1T06Zcc7wKfrGozilTbzuh0jUQVoxqgfHpb7gRuVZ9zTooPf8/u MI6zQFIjHHKRTkl6AegI4WObVpYlqRNnhqxFkKVOR7jjiERzRWZ+VAFevyCwRAgiG4zdihLkjMw LRFM01N8OrZqso3ea7r5cpE9TD1M/mGiM333F/yGAZGXDdmXZHIA6tI9x9dLarJmoNodkQyJcUY kWck0AutG8Hr/lwfnCzjLZCM7aBiZegcZlBiLAfT5X3+FtO8iQo57aAOmGtMdS+pinHTkLvHrVF zHRE2jSOsVLqnon3/YDY6R3YD9tcC+qSRADIxTnTXzVglLpzd8/aO608Y4gfeKw9JKdOv7BJVIe GCMjk3NbGlnuhvjBaWZCohfSNbOGjZhj3STUUaXjwLorzAU/Sho5vpK6eDn0BgE1Ft8dqm+IwT7 x/0xs 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" A specific allocation for the CRTC is not strictly necessary at this point, but in order to implement dynamic configuration of VKMS (configFS), it will be easier to have one allocation per CRTC. Signed-off-by: Louis Chauvet Reviewed-by: Maxime Ripard --- drivers/gpu/drm/vkms/vkms_crtc.c | 32 +++++++++++++++++--------------- drivers/gpu/drm/vkms/vkms_drv.h | 9 +++++---- drivers/gpu/drm/vkms/vkms_output.c | 22 ++++++++++++---------- drivers/gpu/drm/vkms/vkms_writeback.c | 17 +++++++++-------- 4 files changed, 43 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index ace8d293f7da611110c1e117b6cf2f3c9e9b4381..d014dec117e7d4ec7e9e38037a4a4cb4bc6be4ca 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -84,9 +84,7 @@ static bool vkms_get_vblank_timestamp(struct drm_crtc *crtc, int *max_error, ktime_t *vblank_time, bool in_vblank_irq) { - struct drm_device *dev = crtc->dev; - struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev); - struct vkms_output *output = &vkmsdev->output; + struct vkms_output *output = drm_crtc_to_vkms_output(crtc); struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc); if (!READ_ONCE(vblank->enabled)) { @@ -279,25 +277,29 @@ static void vkms_crtc_destroy_workqueue(struct drm_device *dev, 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) +struct vkms_output *vkms_crtc_init(struct drm_device *dev, struct drm_plane *primary, + struct drm_plane *cursor) { - struct vkms_output *vkms_out = drm_crtc_to_vkms_output(crtc); + struct vkms_output *vkms_out; + struct drm_crtc *crtc; int ret; - ret = drmm_crtc_init_with_planes(dev, crtc, primary, cursor, - &vkms_crtc_funcs, NULL); - if (ret) { - DRM_ERROR("Failed to init CRTC\n"); - return ret; + vkms_out = drmm_crtc_alloc_with_planes(dev, struct vkms_output, crtc, + primary, cursor, + &vkms_crtc_funcs, NULL); + if (IS_ERR(vkms_out)) { + DRM_DEV_ERROR(dev->dev, "Failed to init CRTC\n"); + return vkms_out; } + crtc = &vkms_out->crtc; + drm_crtc_helper_add(crtc, &vkms_crtc_helper_funcs); ret = drm_mode_crtc_set_gamma_size(crtc, VKMS_LUT_SIZE); if (ret) { DRM_ERROR("Failed to set gamma size\n"); - return ret; + return ERR_PTR(ret); } drm_crtc_enable_color_mgmt(crtc, 0, false, VKMS_LUT_SIZE); @@ -307,12 +309,12 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, vkms_out->composer_workq = alloc_ordered_workqueue("vkms_composer", 0); if (!vkms_out->composer_workq) - return -ENOMEM; + return ERR_PTR(-ENOMEM); ret = drmm_add_action_or_reset(dev, vkms_crtc_destroy_workqueue, vkms_out); if (ret) - return ret; + return ERR_PTR(ret); - return ret; + return vkms_out; } diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 19fd99b8e506c4454d7878b67f692a0441c22665..fbe7de67fb9c6a6a6964d71b452b9a3ce573e0f8 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -214,7 +214,6 @@ struct vkms_config { struct vkms_device { struct drm_device drm; struct platform_device *platform; - struct vkms_output output; const struct vkms_config *config; }; @@ -241,8 +240,9 @@ struct vkms_device { * @primary: primary plane to attach to the CRTC * @cursor: plane to attach to the CRTC */ -int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, - struct drm_plane *primary, struct drm_plane *cursor); +struct vkms_output *vkms_crtc_init(struct drm_device *dev, + struct drm_plane *primary, + struct drm_plane *cursor); /** * vkms_output_init() - Initialize all sub-components needed for a VKMS device. @@ -273,6 +273,7 @@ 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 vkms_output *vkms_out); #endif /* _VKMS_DRV_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 102b6ad466cb4f7c6704f30cea669e5d7f81540a..22f0d678af3ac8177e43c4ea730af3f2109de5f3 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -30,11 +30,10 @@ static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = { int vkms_output_init(struct vkms_device *vkmsdev) { - struct vkms_output *output = &vkmsdev->output; struct drm_device *dev = &vkmsdev->drm; struct drm_connector *connector; struct drm_encoder *encoder; - struct drm_crtc *crtc = &output->crtc; + struct vkms_output *output; struct vkms_plane *primary, *overlay, *cursor = NULL; int ret; int writeback; @@ -56,9 +55,12 @@ int vkms_output_init(struct vkms_device *vkmsdev) return PTR_ERR(cursor); } - ret = vkms_crtc_init(dev, crtc, &primary->base, &cursor->base); - if (ret) - return ret; + output = vkms_crtc_init(dev, &primary->base, + cursor ? &cursor->base : NULL); + if (IS_ERR(output)) { + DRM_ERROR("Failed to allocate CRTC\n"); + return PTR_ERR(output); + } if (vkmsdev->config->overlay) { for (n = 0; n < NUM_OVERLAY_PLANES; n++) { @@ -67,7 +69,7 @@ int vkms_output_init(struct vkms_device *vkmsdev) DRM_DEV_ERROR(dev->dev, "Failed to init vkms plane\n"); return PTR_ERR(overlay); } - overlay->base.possible_crtcs = drm_crtc_mask(crtc); + overlay->base.possible_crtcs = drm_crtc_mask(&output->crtc); } } @@ -97,23 +99,23 @@ int vkms_output_init(struct vkms_device *vkmsdev) DRM_ERROR("Failed to init encoder\n"); return ret; } - encoder->possible_crtcs = drm_crtc_mask(crtc); + encoder->possible_crtcs = drm_crtc_mask(&output->crtc); + /* Attach the encoder and the connector */ ret = drm_connector_attach_encoder(connector, encoder); if (ret) { DRM_ERROR("Failed to attach connector to encoder\n"); return ret; } + /* Initialize the writeback component */ if (vkmsdev->config->writeback) { - writeback = vkms_enable_writeback_connector(vkmsdev); + writeback = vkms_enable_writeback_connector(vkmsdev, output); if (writeback) DRM_ERROR("Failed to init writeback connector\n"); } drm_mode_config_reset(dev); - return 0; - return ret; } diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c index f12417b2d24803a33e4ff56108cc89704a500faf..c9b6e161fa8698491f20082dfe0b713f27bcb918 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -105,7 +105,9 @@ static void vkms_wb_cleanup_job(struct drm_writeback_connector *connector, struct drm_writeback_job *job) { struct vkms_writeback_job *vkmsjob = job->priv; - struct vkms_device *vkmsdev; + struct vkms_output *vkms_output = container_of(connector, + struct vkms_output, + wb_connector); if (!job->fb) return; @@ -114,8 +116,7 @@ static void vkms_wb_cleanup_job(struct drm_writeback_connector *connector, drm_framebuffer_put(vkmsjob->wb_frame_info.fb); - vkmsdev = drm_device_to_vkms_device(job->fb->dev); - vkms_set_composer(&vkmsdev->output, false); + vkms_set_composer(vkms_output, false); kfree(vkmsjob); } @@ -124,8 +125,7 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn, { struct drm_connector_state *connector_state = drm_atomic_get_new_connector_state(state, conn); - struct vkms_device *vkmsdev = drm_device_to_vkms_device(conn->dev); - struct vkms_output *output = &vkmsdev->output; + struct vkms_output *output = drm_crtc_to_vkms_output(connector_state->crtc); struct drm_writeback_connector *wb_conn = &output->wb_connector; struct drm_connector_state *conn_state = wb_conn->base.state; struct vkms_crtc_state *crtc_state = output->composer_state; @@ -139,7 +139,7 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn, if (!conn_state) return; - vkms_set_composer(&vkmsdev->output, true); + vkms_set_composer(output, true); active_wb = conn_state->writeback_job->priv; wb_frame_info = &active_wb->wb_frame_info; @@ -162,9 +162,10 @@ 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 vkms_output *vkms_output) { - struct drm_writeback_connector *wb = &vkmsdev->output.wb_connector; + struct drm_writeback_connector *wb = &vkms_output->wb_connector; drm_connector_helper_add(&wb->base, &vkms_wb_conn_helper_funcs);