From patchwork Fri Jan 17 09:04:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13943037 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 DFCC8C02188 for ; Fri, 17 Jan 2025 09:05:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6313610EAB4; Fri, 17 Jan 2025 09:05:28 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="fWA2e4ai"; 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 01F7D10EAB7 for ; Fri, 17 Jan 2025 09:05:25 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id F314C1C0009; Fri, 17 Jan 2025 09:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1737104704; 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=UH25UKOSefoYrEAbHRQeYBzUXJbPh1Sxl6qIkPlZZBc=; b=fWA2e4aihCsh4pFn/eh3zYXk+/5+0qPvPw4qlFDUhKyTcTr3I54H8D+gGS2s3g231jqnI2 tv5FnemgNgItkXdKrt6PzXWYBCmwjMfjQHKtYSw3c0l6b1e+NOgTUggPeaDWyDys6INwu7 tz+unjnEAVp8mXrULsG3JBR6lCIfoPTIKc26tGbrF4e/xBAok1lORNoRzt3O+41lbmMHlY i1zaCIMKsM9/whsZMqP4hOKr2fTb4d1fRte6hU8rAzuGjZv6pCUb4xKrlTfhVwYX8O/S1N j8vb/ru91HJ85WBy2g+1XZCO7NNZ5b9F8/3OaqUKb08/STCCxofIDpExJxwRQw== From: Louis Chauvet Date: Fri, 17 Jan 2025 10:04:27 +0100 Subject: [PATCH v4 1/3] drm/vkms: Switch to dynamic allocation for connector MIME-Version: 1.0 Message-Id: <20250117-b4-vkms-allocated-v4-1-8ec8fd21aaf6@bootlin.com> References: <20250117-b4-vkms-allocated-v4-0-8ec8fd21aaf6@bootlin.com> In-Reply-To: <20250117-b4-vkms-allocated-v4-0-8ec8fd21aaf6@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=2122; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=enHRBlfdsE5QZNehJNK38SNKP+L6XCHO8f0wPknVXf0=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnih09tGNip0D3AekdbB6kFGPJ9jn4DaZmLWrTt 3uJ+yKtY/qJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4odPQAKCRAgrS7GWxAs 4iJ1D/9TIUBs/kq8xpfoL2w9AtNhbzB9MJYwvTdvIJ/wa7eKCZv5FoJhtvmJueu6l+LpBtJzlpe xKamZyWqij9vkMT/Poco4WFy5ZhCNMvyqYXT0UsUrBumG4G6bxqE66pl7r6Sanf/XwgW4ZnR1uz c6kHIg7ztrcJqozMwDv6JYJs6+k8NiTKMllU5zS1Y4zCIje99gWf8lOG54LGmhCBr96hiQlkLtY 2wyMrRdUPBoJGEEIR9s2flA7LwXIOSU/m9BRAQeuXmGtkm+OceFvIPii++BFa7g/wkupzf50LWC PMoS7Aapxu+SRyJNOd4uj+rreRpyAUvgEfTt2PRA4XWaG3bMWtEGR1BhpYbEo3nA89gZfsXCKYI kFU+L8WD9yK534UHVEEadrmUZq4eYgAZ8Fj0pbKC2Ph30uQrpdRmfyrnKxwgV8FODVfwPHQGEzg d3KqpkD/Gj+1PwyFX6BfNedYEi4k7leVMsv8K9wkQT/8Z56AeHySWBYAuci2mazLZ732/C0hHFg 1AGotfGFGeF9gdiWulUfWThcrsDR4Ppwhw8N8NXPC8BO98EjY+Q39bu48ERQcvWIS2Oh0JzDZl+ BbSwmixrh0F8Gy3RsqIE6hVG5dS9xNRbSQFkxbuvFgf2bTgcU+mao35/7g9QWRMrswCKs5eD053 dS9z6pcn+vWw7kQ== 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 46ac36aebb27ce8d9018224735007c1b3fe7d0a5..afa625457b6156135d2b07cbd5b5e3f3c7f8f33a 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 drm_encoder wb_encoder; struct hrtimer vblank_hrtimer; diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index de817e2794860f9071a71b3631460691e0d73a85..a41d7a29a377c14a3281968dfeb8f2b43000b120 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 Fri Jan 17 09:04:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13943038 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 6B76FC02183 for ; Fri, 17 Jan 2025 09:05:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9DC7B10EAB8; Fri, 17 Jan 2025 09:05:28 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="Sc5vsiiA"; 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 D274F10EAB8 for ; Fri, 17 Jan 2025 09:05:26 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id CBE001C0007; Fri, 17 Jan 2025 09:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1737104705; 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=cszNEYrIo94KSnanXnADpJN0/+0LWYylvzxge4u5AM0=; b=Sc5vsiiAuRzhJfy0BFlBdQCVfZm50ZStU6lV8RCc86IXL0Oy5W1OQj6wghRyCtL3GOAviJ fblJicJBSBITLO1MFWJyHSvgrjTULus0KWAQwAE/ftCXGTBQoaBcBcMyJKvBp4n48JS+Rh j29RE7SuIRZSwC4iOFWIq0DpEL/u0EgANizEpchw32QZsJbCTUTAsPWDwYAxHZHI8CzoQy JP71NZYc3xbDgAe2a65XvoTop53FlFDdCDcMGccWhaJWJY1385qhS8RrMBTaqhdYA/bBI7 JaywlmE+4ywec/x6MBzM7BGq3Nf/hle8NhkDw4V4jYLGFIRzhxdSZcg3N+E/Wg== From: Louis Chauvet Date: Fri, 17 Jan 2025 10:04:28 +0100 Subject: [PATCH v4 2/3] drm/vkms: Switch to dynamic allocation for encoder MIME-Version: 1.0 Message-Id: <20250117-b4-vkms-allocated-v4-2-8ec8fd21aaf6@bootlin.com> References: <20250117-b4-vkms-allocated-v4-0-8ec8fd21aaf6@bootlin.com> In-Reply-To: <20250117-b4-vkms-allocated-v4-0-8ec8fd21aaf6@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=2092; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=8IOvnQFVZlbgJX/4bD914D9g8sen2qDKHUBLgMavrik=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnih09MF5kUrZs91gH25+EJLgpLoXu8geSN7zHs bnBa/nYFVKJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4odPQAKCRAgrS7GWxAs 4m+9EACtbCvG9VubCkBAQa//KQVkaHPAo1YsEiq7BAwcOfxjqIZvN3Ym5A1bvtWOzPkH5hNoh4X 5ZtJO9aPIoNpuZGWWv42QIpERNpjR5Y4xBx6hkvse/pQJRbx2P2cZMh6eDVVOgZwVxpRXja1ULP HfyHOjGU7oMDCv2HIU9MbXs3vlaOk6o5XTYU8xGGRCbpC6uVkWNuHRqzEtTzyxJ+j0rbhwGN2/b zqUICKivHNz+CN2CM8DTOMSlUwJgMm4AepidA1FQXYvkQhbNz9i+4Ic3CiGGDemdlQFLQxhGRPc zb2VAetEUx9RGm67AtLs3p0W/wYXq1aeHA8fsfuBXH7mq848nt0pWsqgUH0leD/H9stvjG3Y7JW i+0PxUKEGe3v+cqXH8didb8Wq2OsI8WYi71dvKDFOIob1U0Fy82NFAmV3GGxmgausCKMzfAqJ9G SAHLjMjJMC7cXyz14PjDoeiehFFl0CuwrGkVFrE2MABtcZIel0iE1Nz49ntsBufP9bTnLIWGiC6 Xc9jqxsxTJ6lGO9IqU2I78tEW/W2Wn97+lKtDYSGbByoUzd3chOO3LGPHvn8KV/fBKn6cFzPVXZ IBJEAp89qA3Ptb9cI66lQTDnbsHZ4oDFwBjKMpQrwdrXA+Q1gHoDgynJHl0ax30ZiKFjNHfWvnu vIhVMf6R9LzXNGQ== 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 afa625457b6156135d2b07cbd5b5e3f3c7f8f33a..333983bcf8d46ef85101e7c344e256df57551b78 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 drm_encoder wb_encoder; struct hrtimer vblank_hrtimer; diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index a41d7a29a377c14a3281968dfeb8f2b43000b120..21ca975e424d148b0669b87784d86f5da2a8b333 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 Fri Jan 17 09:04:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13943035 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 9E9F4C02183 for ; Fri, 17 Jan 2025 09:05:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 22DAD10E2FA; Fri, 17 Jan 2025 09:05:10 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="m0mENJu+"; 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 CB61F10E2FA for ; Fri, 17 Jan 2025 09:05:07 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 9739B1C0010; Fri, 17 Jan 2025 09:05:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1737104706; 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=wW2GE+k42eHWzMuTxRJ4pv3t8Znb8O3qE1HKvW+jpiY=; b=m0mENJu+pEwqctltsiTbU4znLsg5xC6pP1pHZzpubq7WhBH+TLn12rNx5QOzCZpIUAnOd6 vNxNj4FRXzvhHg774MHpZZmpQcS29VW5nlZUHdP1qWzNnmy5GIS39NJAQr9L7R6eNxNSrw dD61UO8JFumkaZkJjl5s4RahFE5dS+tK4b+tlTeYyfzykmGu72ktEUZeeCzOCXV2ewNTzR T6lUABiJK7M+jdg1DjdKmTC2Sml7c9O+ED4JNkHzdKOPwgZQpM3KBqlSlvAsHuzAT5Vj5h SkmDQZJrv00EAV9F6KBHsvMubtM/pFenktKC7O85DcROSt2+HAUdDTxOEOM1eA== From: Louis Chauvet Date: Fri, 17 Jan 2025 10:04:29 +0100 Subject: [PATCH v4 3/3] drm/vkms: Switch to dynamic allocation for CRTC MIME-Version: 1.0 Message-Id: <20250117-b4-vkms-allocated-v4-3-8ec8fd21aaf6@bootlin.com> References: <20250117-b4-vkms-allocated-v4-0-8ec8fd21aaf6@bootlin.com> In-Reply-To: <20250117-b4-vkms-allocated-v4-0-8ec8fd21aaf6@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=9891; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=pxspv5P5WV7R1DJlKtdquHCZNwmXnqhT4lP7W4392Gk=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnih09Emp+aTjh3QtNN+86NRtYwbKdZItwIxMnZ 5kXAY4MDgCJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ4odPQAKCRAgrS7GWxAs 4hKXD/9WQ/ZHuxDEuDtzkbnIbGnVML6Q3c7pr+WG9soOV8bKzH2QFd8O9bpC5DQWtR4ellYJgEr +2zt+9La5E4XHU/Vd8K4QxwZNszmEZkZk2c0/ohgVjm92aMjwFoTqmrAJfrawE79anzk4em1Dcn PcJYXAYMkpYFyNjU0qtQw+/uESW5h2I8i5ZKu5Vlxhd6QDU7ahfUHD2UnKgSN3W/aUjOkqUDixN w+xoOC29y4WRItMRtmvbYLR+UbkM2gYWxQFiZ8Vg/lrPy9/zFI4rQ1sb2ki1DC1eLqGvFkhMyvU hfkMWMVTMKcQ+UlpBH5qMd3X83kM1ietmcLeqLSEytN/lKfAKQR8JUy63FRFyeSLwnki/yFXw0p VVfZys2/VMMSK0na+u2Ab0ZHSYJf0IPeO0Mp9ifnaFEUdNCXs9b184jGmpW2sqQq5CHjX91g6rE hgdwaHrXj//mIQkCGqi4v/UGDegxqihV3iOp5uOtN3ExqbWTZIqnp5fmlFJEzZi9Df2RB2fbcL2 5OA0SJ0yvZFi1pzx5VM+EkcuC1T7vpVMRFY21q56g1hqYYnwhHnAskIRpQME8rC+BXqQCJkhkuO OgLFQWynt6TfrBmahacPczpkAaXtd3T9NxCoA8VFlmT31j/2lUy9s4wdNTXp9cKaiHR2ECmMQza 2P3ZpXhQiXyxJ9w== 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. Reviewed-by: Maxime Ripard Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_crtc.c | 32 +++++++++++++++++--------------- drivers/gpu/drm/vkms/vkms_drv.h | 8 ++++---- drivers/gpu/drm/vkms/vkms_output.c | 22 ++++++++++++---------- drivers/gpu/drm/vkms/vkms_writeback.c | 23 ++++++++++++----------- 4 files changed, 45 insertions(+), 40 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 434c35d5e9477d2961826262591db8ab43838e09..cf229aec71c3f03bb1306095e8dd44d63f80cd2a 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)) { @@ -271,25 +269,29 @@ static const struct drm_crtc_helper_funcs vkms_crtc_helper_funcs = { .atomic_disable = vkms_crtc_atomic_disable, }; -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); @@ -299,9 +301,9 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, 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); + return ERR_CAST(vkms_out->composer_workq); if (!vkms_out->composer_workq) - return -ENOMEM; + return ERR_PTR(-ENOMEM); - return ret; + return vkms_out; } diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 333983bcf8d46ef85101e7c344e256df57551b78..abbb652be2b5389f96cec78837117ceb9acef656 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -215,7 +215,6 @@ struct vkms_config { struct vkms_device { struct drm_device drm; struct platform_device *platform; - struct vkms_output output; const struct vkms_config *config; }; @@ -242,8 +241,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. @@ -274,6 +274,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, struct drm_crtc *crtc); +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 21ca975e424d148b0669b87784d86f5da2a8b333..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, crtc); + 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 981975c2b0a0c75e4a3aceca2a965f5876ae0a8f..e9b5c74d7c58e7faed870a4368decbd67dab23d2 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,22 +162,23 @@ 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, struct drm_crtc *crtc) +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; int ret; - ret = drmm_encoder_init(&vkmsdev->drm, &vkmsdev->output.wb_encoder, + ret = drmm_encoder_init(&vkmsdev->drm, &vkms_output->wb_encoder, NULL, DRM_MODE_ENCODER_VIRTUAL, NULL); if (ret) return ret; - vkmsdev->output.wb_encoder.possible_crtcs |= drm_crtc_mask(crtc); + vkms_output->wb_encoder.possible_crtcs |= drm_crtc_mask(&vkms_output->crtc); drm_connector_helper_add(&wb->base, &vkms_wb_conn_helper_funcs); return drmm_writeback_connector_init(&vkmsdev->drm, wb, &vkms_wb_connector_funcs, - &vkmsdev->output.wb_encoder, + &vkms_output->wb_encoder, vkms_wb_formats, ARRAY_SIZE(vkms_wb_formats)); }