From patchwork Tue Aug 27 09:57:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13779211 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 66545C5472C for ; Tue, 27 Aug 2024 10:01:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AC36610E133; Tue, 27 Aug 2024 10:01:57 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="iNQMO4rP"; 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 E45FF10E133 for ; Tue, 27 Aug 2024 10:01:55 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id B48891C0010; Tue, 27 Aug 2024 10:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1724752914; 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=udjlBWpBAoHgcvxq2FWPI0e0+WGK0V/eXeydXau3BLE=; b=iNQMO4rPmhWpbZ2czv7N+SZ9vEmWWw3K5NKL8jz3tKkaYlCUW7SHQN8lnsnhYq6A4zddbY 0E/xHgu68Rx/Va0CXrVvugEuU41PvhxaCxeLlg/8JYt/rObTq4pHVHAUHiR8PzsMt8I3VF sZgFYGj+Rbi57UKUB31yr5sy2ywtSAquMrNM2Veuhl/uAAN84NZI6jZssGasl/fcvTErZ+ nwI7Utmt6Ow+Z4lJYyb34PtdtOQNFLZp9DQu26iaL5PfpPJNV3b/2tr8uMrr+iewhLfk5Y HZrEoUHKhE6KN5kYDoeRGn0S/5EVuzNGZZnZ8jf5jl9HbzsxSCn+2COc6fgPTQ== From: Louis Chauvet Date: Tue, 27 Aug 2024 11:57:36 +0200 Subject: [PATCH v2 1/6] drm/vkms: Switch to managed for connector MIME-Version: 1.0 Message-Id: <20240827-google-vkms-managed-v2-1-f41104553aeb@bootlin.com> References: <20240827-google-vkms-managed-v2-0-f41104553aeb@bootlin.com> In-Reply-To: <20240827-google-vkms-managed-v2-0-f41104553aeb@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie 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=3176; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=W99THVqBFNss3oEOGdwAJKCTqWPosBK54HEsLK2bqEE=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmzaQOLZuf9vXRrfntkM0wA3KlX4Nd0aP7AtuC6 c/2o/80pMCJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZs2kDgAKCRAgrS7GWxAs 4rzdD/458Vuz+7NzBObxe/IKrJppUiYa+qkvIC+MWFWUc8SJccX24a0awNgXZBKN8aasNQX5HLf 2po3mKI1qlwwYUAG7kST7QvZc4x4lvMnci+AXrOF5+Q2G2hATcfnIOrg0PZaeE46Vvxtwhjz/EY DEPZV9wkxyl5wp3frq21g0DobV17A7//w9tFBtjUcyk28J13IZQh5nxMvwXxBTOKcPuoNuC/bjI /DjKFX2CironzBrdgcaaizDmqPJP8B+LksOqUSWO4EXAUxHzSgjR+lgNF/f1DiYo2Kgz/SUL7so c0rF/RXawc06hwma7GkIE4Duj/bCdF25m8o7RSBDnVunNRHHZNKvifc0wTMT+Ehldrx4aHt/9NG VKcOL2dgvD2I0XLZcGo7JmrfHbiPM3GVFLh1LKap9tD0Dcwslj9nP0nYX5QwgOupGtqM3mDP+6j Q01y6q9mM3qnyKBGRXZKtO4YldFAxlYRnPC8mvwkXtWSRj9qsy8cZyjqKcPAju26k333IUyWeG0 JemBDV+EpyQ+JHxFEsHxwMZ4mC1Fe1HIie1FyZ5XOa79iiTSFkDAMZ5Bh9gSLI3kytU+BPCKK2q Ay9fE88ruq8TvL2WZOMpsS9DjLolipyy2FatQA4wa26tja7Iu7CR5NZ8LiFJtNarOc9i7il0i4q N8qaMxtOg+eVd7g== 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. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_drv.h | 1 - drivers/gpu/drm/vkms/vkms_output.c | 22 ++++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 5e46ea5b96dc..9a3c6c34d1f6 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -99,7 +99,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 5ce70dd946aa..4fe6b88e8081 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, @@ -50,7 +50,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) { 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, *cursor = NULL; @@ -80,8 +80,15 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) if (ret) return ret; - ret = drm_connector_init(dev, connector, &vkms_connector_funcs, - DRM_MODE_CONNECTOR_VIRTUAL); + connector = drmm_kzalloc(dev, sizeof(*connector), GFP_KERNEL); + if (!connector) { + DRM_ERROR("Failed to allocate connector\n"); + ret = -ENOMEM; + goto err_connector; + } + + ret = drmm_connector_init(dev, connector, &vkms_connector_funcs, + DRM_MODE_CONNECTOR_VIRTUAL, NULL); if (ret) { DRM_ERROR("Failed to init connector\n"); goto err_connector; @@ -93,7 +100,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) DRM_MODE_ENCODER_VIRTUAL, NULL); if (ret) { DRM_ERROR("Failed to init encoder\n"); - goto err_encoder; + return ret; } encoder->possible_crtcs = 1; @@ -115,12 +122,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) err_attach: drm_encoder_cleanup(encoder); - -err_encoder: - drm_connector_cleanup(connector); - err_connector: drm_crtc_cleanup(crtc); - return ret; } From patchwork Tue Aug 27 09:57:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13779215 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 D3A63C54732 for ; Tue, 27 Aug 2024 10:02:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DCA0110E2C9; Tue, 27 Aug 2024 10:02:02 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="FjX0fvnt"; 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 B2C0D10E133 for ; Tue, 27 Aug 2024 10:01:56 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id A6F761C0005; Tue, 27 Aug 2024 10:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1724752915; 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=cLpzZikRAqTA1AgFL9mPE5QtLpuXTGeDfy/jMnIuw64=; b=FjX0fvntQgDahP26SR8gjVd42xgLvnQ8DsjWD6u/wmDfUvdRi7fPfpij3CzYsArNUgysuK mt2FA+ccXy5uzyLTAbqrtukkLlz/+ZD+qVYwVE/erBXkzwIga2hI/0b3oWjaW5WVnyrRW/ kAkChvg10h1HubMgyw8bc7Htu1TTZ5E21p8udRDoYnDjW8JchDSBqAmZR16kPDiBhp3Sx1 TR9zqmm6hSRpFRQOTq9vE9/xGdJUV8EAEn8RlfBRU/i2N7/+8uUzxLmXRepkNGKDMk96Qu O66ZWEZQGUOE2vFnJwXQKm8Zko4abrT6R+AsqD1jHcehKEmnSNChbpARNYv1wg== From: Louis Chauvet Date: Tue, 27 Aug 2024 11:57:37 +0200 Subject: [PATCH v2 2/6] drm/vkms: Switch to managed for encoder MIME-Version: 1.0 Message-Id: <20240827-google-vkms-managed-v2-2-f41104553aeb@bootlin.com> References: <20240827-google-vkms-managed-v2-0-f41104553aeb@bootlin.com> In-Reply-To: <20240827-google-vkms-managed-v2-0-f41104553aeb@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie 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=2908; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=675tGI9t4siyekAGAqTdIzTYThmUt23EspEKi2jqEUw=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmzaQPxh3W6g4AWc2LFokZazuLTgBmg1bYlS+Ko v5T3sq4YrOJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZs2kDwAKCRAgrS7GWxAs 4uiYEACB/OXTMAKcYDyZjpKrC6FIWGqvtuGYe0kXaCjLSbrkHA7HznuMNLYaY8z0yfNfU0874fz Wb5w46Ezg2kP16PYnom7EG2H+fdsuUWdQXGvouML/1QNFvk+FTh1Wh/1dRLTFN4XGvOkL4H0Gi4 ha/x/an9EUIbmGwtmIMfwcVzGrsLbkpmjussTI9o7/FEtRHEnUaBr4h5/Gb8rS4CqJOSWD28T0J jZZPDhFcxgRVLqVk4yqS2GYeePnfVw3+hL1QYtgDA8ATwqO/53U4SgQOD1iAJzSaQI+aAV123p9 8EYXWS+h7OIYYNk/70lpkmn/8weKY9CbWsOvow2GIXusv91w/zXNdtNOPHu/ZceswjAECquT+4V +CH084GoyDtYWxdZp+mz1Z+1QlgTxmLcX8Irf8ejZyfOM9PwGZoxQ8DTIxfyP26TKHQa8/eniwa 5VkkA3d8pTse4r0dOJCuVzJ7tVGorZa4j00agSZlOLHXj3ZfAsNOuJZlJrEZNEOeAyBNllXpmv4 kqpM3KnxFsD0qhGhPvioz3WvrqTMrN0zM71nli1Bwell6+GuJp0sUDQG+1eAkLxu+ZUj6EoPXoW Fyx05511zL8P2WCKto23+8iI4Dq+iiLIs9ekHQyDO1tWJ/Y0tiqkpumDwPPP1ylIrPj3ZXuTeUu Wiqfi/3gxKpbmZw== 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. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_drv.h | 1 - drivers/gpu/drm/vkms/vkms_output.c | 22 +++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 9a3c6c34d1f6..101993378b49 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -98,7 +98,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 4fe6b88e8081..bbec7c14229c 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; @@ -51,7 +47,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) 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, *cursor = NULL; int ret; @@ -96,18 +92,24 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) drm_connector_helper_add(connector, &vkms_conn_helper_funcs); - ret = drm_encoder_init(dev, encoder, &vkms_encoder_funcs, - DRM_MODE_ENCODER_VIRTUAL, NULL); + encoder = drmm_kzalloc(dev, sizeof(*encoder), GFP_KERNEL); + if (!encoder) { + DRM_ERROR("Failed to allocate encoder\n"); + ret = -ENOMEM; + goto err_connector; + } + + ret = drmm_encoder_init(dev, encoder, NULL, DRM_MODE_ENCODER_VIRTUAL, NULL); if (ret) { DRM_ERROR("Failed to init encoder\n"); - return ret; + goto err_connector; } encoder->possible_crtcs = 1; 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) { @@ -120,8 +122,6 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) return 0; -err_attach: - drm_encoder_cleanup(encoder); err_connector: drm_crtc_cleanup(crtc); return ret; From patchwork Tue Aug 27 09:57:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13779213 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 0F322C52D6F for ; Tue, 27 Aug 2024 10:02:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 67C5A10E2C1; Tue, 27 Aug 2024 10:02:02 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="laygfAVs"; 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 CC57010E222 for ; Tue, 27 Aug 2024 10:01:57 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 934801C0007; Tue, 27 Aug 2024 10:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1724752916; 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=VLDA3mjNmG2t3rLv4Yud8tnGeWo3weAPMyHv+ylyq8A=; b=laygfAVstHot3z+UpU31/HvFyOr3NsAruzTvola2rbh1hXhFh1/hVIR7T73/E+MMTN7lqI mmwbCIGiqLHF26R8zwfnKy4g00V0bki6rCOVFHkhRD6WdEykoS2ddBEV0pQoNJKtPapwrh hlJncjDM+DF/pM/x7NRqejHTMBAeu7jvwMVsSwhECU3i6VXINorAaBvuPgu1BQCbb/0T2x yaXjUId3sQmdSch8PdMXBxwiHOX47AcqkmotGwK/woDSAkBNGpHIASRnB6UiANYvfRBfhh xPZkje2WNa4B394SWwePzr66dwvfu0WluEJa3iszbb3jp/rjzyZJy9fjqkz/7Q== From: Louis Chauvet Date: Tue, 27 Aug 2024 11:57:38 +0200 Subject: [PATCH v2 3/6] drm/vkms: Rename vkms_output to vkms_crtc MIME-Version: 1.0 Message-Id: <20240827-google-vkms-managed-v2-3-f41104553aeb@bootlin.com> References: <20240827-google-vkms-managed-v2-0-f41104553aeb@bootlin.com> In-Reply-To: <20240827-google-vkms-managed-v2-0-f41104553aeb@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie 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=15063; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=MUXfMrHoYe99yLBLEUvLfqlRRqfmv9js/PWQccOW9kg=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmzaQPV2dWXTebHFW5wDzFJ/JRZi1+zZPvXLyeu 7fYY6tmzC6JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZs2kDwAKCRAgrS7GWxAs 4lFkEADKrNo8dTfNRM+LmvZ6isuNEwijxuwjtWCHNezdyrehImGzGzv5idOChMEU0DRfRMA0D5O H8HhJU6IJYSRxMyV+HF5TbkDRdMXiE34GuQved0Ty76WCFxiy3aLjqmbOEqbVHnlygcMIcaNmhf ExAUr79og3l2flBrAYGBHD0o8hDPkCIXKDlsIHmpHQij+FrRiCGUugoaIYrpZbCn3lUutigsbOc 80exB4YHYC8x51t6KNVAR315gXhbtBG2eN+dJ0t4xXkZw6iEzx2eOpRI72jicKjg/3UUXfO5fVr HbkoN+gj8M3YAtEN3z4DWpF6XO0FFPn8gxAB8QvWZddGh9rcrOg1miREADzy8NeORQFaLmfPEZA myKRMBAQV/tcYgoA/i9yvuwz2OFItgzU0HO9wrMC4t+Oj290eRxpLT7Nz8bJiAVv/PAmT+2hJw8 P5qPTd64hqfb9TdYhJ0smRchel1M+Zfw+6mqZIWXPp1lF3mtkdMbhctnReeGSl2hMgZceJYlAaY xrT3Yb8ieK0TJenEpATPL9cpa1Z5Ayb/rSgOAn4x3xb364NglEOPZuaAYX+ZOI+cY+NBUyf0RjA HnHJn7TQwnAP0Bad8mcPQwFaPNq77w9yPtaF2W7OzFRdzStHmcgVX1E3sY06D0/0P3g32o9GmUY oPn8/bzZ6SaJb3g== 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_output structure only contains crtc-related members. In preparation of the migration to drmm for crtc and to avoid confusion, rename this structure and all its usage to vkms_crtc. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_composer.c | 30 +++++++++---------- drivers/gpu/drm/vkms/vkms_crtc.c | 54 +++++++++++++++++------------------ drivers/gpu/drm/vkms/vkms_drv.c | 4 +-- drivers/gpu/drm/vkms/vkms_drv.h | 12 ++++---- drivers/gpu/drm/vkms/vkms_output.c | 4 +-- drivers/gpu/drm/vkms/vkms_writeback.c | 16 +++++------ 6 files changed, 59 insertions(+), 61 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index e7441b227b3c..b1723cf02ed3 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -306,13 +306,13 @@ void vkms_composer_worker(struct work_struct *work) composer_work); struct drm_crtc *crtc = crtc_state->base.crtc; struct vkms_writeback_job *active_wb = crtc_state->active_writeback; - struct vkms_output *out = drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc = drm_crtc_to_vkms_crtc(crtc); bool crc_pending, wb_pending; u64 frame_start, frame_end; u32 crc32 = 0; int ret; - spin_lock_irq(&out->composer_lock); + spin_lock_irq(&vkms_crtc->composer_lock); frame_start = crtc_state->frame_start; frame_end = crtc_state->frame_end; crc_pending = crtc_state->crc_pending; @@ -336,7 +336,7 @@ void vkms_composer_worker(struct work_struct *work) crtc_state->gamma_lut.base = NULL; } - spin_unlock_irq(&out->composer_lock); + spin_unlock_irq(&vkms_crtc->composer_lock); /* * We raced with the vblank hrtimer and previous work already computed @@ -354,10 +354,10 @@ void vkms_composer_worker(struct work_struct *work) return; if (wb_pending) { - drm_writeback_signal_completion(&out->wb_connector, 0); - spin_lock_irq(&out->composer_lock); + drm_writeback_signal_completion(&vkms_crtc->wb_connector, 0); + spin_lock_irq(&vkms_crtc->composer_lock); crtc_state->wb_pending = false; - spin_unlock_irq(&out->composer_lock); + spin_unlock_irq(&vkms_crtc->composer_lock); } /* @@ -407,31 +407,31 @@ int vkms_verify_crc_source(struct drm_crtc *crtc, const char *src_name, return 0; } -void vkms_set_composer(struct vkms_output *out, bool enabled) +void vkms_set_composer(struct vkms_crtc *vkms_crtc, bool enabled) { bool old_enabled; if (enabled) - drm_crtc_vblank_get(&out->crtc); + drm_crtc_vblank_get(&vkms_crtc->base); - spin_lock_irq(&out->lock); - old_enabled = out->composer_enabled; - out->composer_enabled = enabled; - spin_unlock_irq(&out->lock); + spin_lock_irq(&vkms_crtc->lock); + old_enabled = vkms_crtc->composer_enabled; + vkms_crtc->composer_enabled = enabled; + spin_unlock_irq(&vkms_crtc->lock); if (old_enabled) - drm_crtc_vblank_put(&out->crtc); + drm_crtc_vblank_put(&vkms_crtc->base); } int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name) { - struct vkms_output *out = drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc = drm_crtc_to_vkms_crtc(crtc); bool enabled = false; int ret = 0; ret = vkms_crc_parse_source(src_name, &enabled); - vkms_set_composer(out, enabled); + vkms_set_composer(vkms_crtc, enabled); return ret; } diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 40b4d084e3ce..013bf8336b54 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -11,35 +11,35 @@ static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer) { - struct vkms_output *output = container_of(timer, struct vkms_output, + struct vkms_crtc *vkms_crtc = container_of(timer, struct vkms_crtc, vblank_hrtimer); - struct drm_crtc *crtc = &output->crtc; + struct drm_crtc *crtc = &vkms_crtc->base; struct vkms_crtc_state *state; u64 ret_overrun; bool ret, fence_cookie; fence_cookie = dma_fence_begin_signalling(); - ret_overrun = hrtimer_forward_now(&output->vblank_hrtimer, - output->period_ns); + ret_overrun = hrtimer_forward_now(&vkms_crtc->vblank_hrtimer, + vkms_crtc->period_ns); if (ret_overrun != 1) pr_warn("%s: vblank timer overrun\n", __func__); - spin_lock(&output->lock); + spin_lock(&vkms_crtc->lock); ret = drm_crtc_handle_vblank(crtc); if (!ret) DRM_ERROR("vkms failure on handling vblank"); - state = output->composer_state; - spin_unlock(&output->lock); + state = vkms_crtc->composer_state; + spin_unlock(&vkms_crtc->lock); - if (state && output->composer_enabled) { + if (state && vkms_crtc->composer_enabled) { u64 frame = drm_crtc_accurate_vblank_count(crtc); /* update frame_start only if a queued vkms_composer_worker() * has read the data */ - spin_lock(&output->composer_lock); + spin_lock(&vkms_crtc->composer_lock); if (!state->crc_pending) state->frame_start = frame; else @@ -47,9 +47,9 @@ static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer) state->frame_start, frame); state->frame_end = frame; state->crc_pending = true; - spin_unlock(&output->composer_lock); + spin_unlock(&vkms_crtc->composer_lock); - ret = queue_work(output->composer_workq, &state->composer_work); + ret = queue_work(vkms_crtc->composer_workq, &state->composer_work); if (!ret) DRM_DEBUG_DRIVER("Composer worker already queued\n"); } @@ -62,7 +62,7 @@ static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer) static int vkms_enable_vblank(struct drm_crtc *crtc) { struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc); - struct vkms_output *out = drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *out = drm_crtc_to_vkms_crtc(crtc); drm_calc_timestamping_constants(crtc, &crtc->mode); @@ -76,7 +76,7 @@ static int vkms_enable_vblank(struct drm_crtc *crtc) static void vkms_disable_vblank(struct drm_crtc *crtc) { - struct vkms_output *out = drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *out = drm_crtc_to_vkms_crtc(crtc); hrtimer_cancel(&out->vblank_hrtimer); } @@ -85,9 +85,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_crtc *vkms_crtc = drm_crtc_to_vkms_crtc(crtc); struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc); if (!READ_ONCE(vblank->enabled)) { @@ -95,7 +93,7 @@ static bool vkms_get_vblank_timestamp(struct drm_crtc *crtc, return true; } - *vblank_time = READ_ONCE(output->vblank_hrtimer.node.expires); + *vblank_time = READ_ONCE(vkms_crtc->vblank_hrtimer.node.expires); if (WARN_ON(*vblank_time == vblank->time)) return true; @@ -107,7 +105,7 @@ static bool vkms_get_vblank_timestamp(struct drm_crtc *crtc, * the vblank core expects. Therefore we need to always correct the * timestampe by one frame. */ - *vblank_time -= output->period_ns; + *vblank_time -= vkms_crtc->period_ns; return true; } @@ -233,18 +231,18 @@ static void vkms_crtc_atomic_disable(struct drm_crtc *crtc, static void vkms_crtc_atomic_begin(struct drm_crtc *crtc, struct drm_atomic_state *state) { - struct vkms_output *vkms_output = drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc = drm_crtc_to_vkms_crtc(crtc); /* This lock is held across the atomic commit to block vblank timer * from scheduling vkms_composer_worker until the composer is updated */ - spin_lock_irq(&vkms_output->lock); + spin_lock_irq(&vkms_crtc->lock); } static void vkms_crtc_atomic_flush(struct drm_crtc *crtc, struct drm_atomic_state *state) { - struct vkms_output *vkms_output = drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc = drm_crtc_to_vkms_crtc(crtc); if (crtc->state->event) { spin_lock(&crtc->dev->event_lock); @@ -259,9 +257,9 @@ static void vkms_crtc_atomic_flush(struct drm_crtc *crtc, crtc->state->event = NULL; } - vkms_output->composer_state = to_vkms_crtc_state(crtc->state); + vkms_crtc->composer_state = to_vkms_crtc_state(crtc->state); - spin_unlock_irq(&vkms_output->lock); + spin_unlock_irq(&vkms_crtc->lock); } static const struct drm_crtc_helper_funcs vkms_crtc_helper_funcs = { @@ -275,7 +273,7 @@ static const struct drm_crtc_helper_funcs vkms_crtc_helper_funcs = { int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, struct drm_plane *primary, struct drm_plane *cursor) { - struct vkms_output *vkms_out = drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc = drm_crtc_to_vkms_crtc(crtc); int ret; ret = drmm_crtc_init_with_planes(dev, crtc, primary, cursor, @@ -290,11 +288,11 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, drm_mode_crtc_set_gamma_size(crtc, VKMS_LUT_SIZE); drm_crtc_enable_color_mgmt(crtc, 0, false, VKMS_LUT_SIZE); - spin_lock_init(&vkms_out->lock); - spin_lock_init(&vkms_out->composer_lock); + spin_lock_init(&vkms_crtc->lock); + spin_lock_init(&vkms_crtc->composer_lock); - vkms_out->composer_workq = alloc_ordered_workqueue("vkms_composer", 0); - if (!vkms_out->composer_workq) + vkms_crtc->composer_workq = alloc_ordered_workqueue("vkms_composer", 0); + if (!vkms_crtc->composer_workq) return -ENOMEM; return ret; diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 0c1a713b7b7b..d1ed6bbe9559 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -57,8 +57,8 @@ 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); + if (vkms->crtc.composer_workq) + destroy_workqueue(vkms->crtc.composer_workq); } static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 101993378b49..c55ab45ccb20 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -96,8 +96,8 @@ struct vkms_crtc_state { u64 frame_end; }; -struct vkms_output { - struct drm_crtc crtc; +struct vkms_crtc { + struct drm_crtc base; struct drm_writeback_connector wb_connector; struct hrtimer vblank_hrtimer; ktime_t period_ns; @@ -126,12 +126,12 @@ struct vkms_config { struct vkms_device { struct drm_device drm; struct platform_device *platform; - struct vkms_output output; + struct vkms_crtc crtc; const struct vkms_config *config; }; -#define drm_crtc_to_vkms_output(target) \ - container_of(target, struct vkms_output, crtc) +#define drm_crtc_to_vkms_crtc(target) \ + container_of(target, struct vkms_crtc, base) #define drm_device_to_vkms_device(target) \ container_of(target, struct vkms_device, drm) @@ -160,7 +160,7 @@ int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name, /* Composer Support */ void vkms_composer_worker(struct work_struct *work); -void vkms_set_composer(struct vkms_output *out, bool enabled); +void vkms_set_composer(struct vkms_crtc *out, bool enabled); void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state *plane, int y); void vkms_writeback_row(struct vkms_writeback_job *wb, const struct line_buffer *src_buffer, int y); diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index bbec7c14229c..cd506dcfd50f 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -44,11 +44,11 @@ static int vkms_add_overlay_plane(struct vkms_device *vkmsdev, int index, int vkms_output_init(struct vkms_device *vkmsdev, int index) { - struct vkms_output *output = &vkmsdev->output; + struct vkms_crtc *vkms_crtc = &vkmsdev->crtc; struct drm_device *dev = &vkmsdev->drm; struct drm_connector *connector; struct drm_encoder *encoder; - struct drm_crtc *crtc = &output->crtc; + struct drm_crtc *crtc = &vkms_crtc->base; struct vkms_plane *primary, *cursor = NULL; int ret; int writeback; diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c index bc724cbd5e3a..e055ad41241b 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -116,7 +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(&vkmsdev->crtc, false); kfree(vkmsjob); } @@ -126,10 +126,10 @@ 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 drm_writeback_connector *wb_conn = &output->wb_connector; + struct vkms_crtc *vkms_crtc = &vkmsdev->crtc; + struct drm_writeback_connector *wb_conn = &vkms_crtc->wb_connector; struct drm_connector_state *conn_state = wb_conn->base.state; - struct vkms_crtc_state *crtc_state = output->composer_state; + struct vkms_crtc_state *crtc_state = vkms_crtc->composer_state; struct drm_framebuffer *fb = connector_state->writeback_job->fb; u16 crtc_height = crtc_state->base.crtc->mode.vdisplay; u16 crtc_width = crtc_state->base.crtc->mode.hdisplay; @@ -140,15 +140,15 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn, if (!conn_state) return; - vkms_set_composer(&vkmsdev->output, true); + vkms_set_composer(&vkmsdev->crtc, true); active_wb = conn_state->writeback_job->priv; wb_frame_info = &active_wb->wb_frame_info; - spin_lock_irq(&output->composer_lock); + spin_lock_irq(&vkms_crtc->composer_lock); crtc_state->active_writeback = active_wb; crtc_state->wb_pending = true; - spin_unlock_irq(&output->composer_lock); + spin_unlock_irq(&vkms_crtc->composer_lock); wb_frame_info->offset = fb->offsets[0]; wb_frame_info->pitch = fb->pitches[0]; @@ -170,7 +170,7 @@ static const struct drm_connector_helper_funcs vkms_wb_conn_helper_funcs = { int vkms_enable_writeback_connector(struct vkms_device *vkmsdev) { - struct drm_writeback_connector *wb = &vkmsdev->output.wb_connector; + struct drm_writeback_connector *wb = &vkmsdev->crtc.wb_connector; drm_connector_helper_add(&wb->base, &vkms_wb_conn_helper_funcs); From patchwork Tue Aug 27 09:57:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13779212 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 2B798C5320E for ; Tue, 27 Aug 2024 10:02:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9844110E222; Tue, 27 Aug 2024 10:02:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="p1nJVXQ0"; 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 9A80510E222 for ; Tue, 27 Aug 2024 10:01:58 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 8CE231C000C; Tue, 27 Aug 2024 10:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1724752917; 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=7I4yjRM+EAGk8OmRLAB0yWxupKT0rtc7RgTC0k07aOc=; b=p1nJVXQ0ZHRoDKZt427xeQRxPBojvSF+oz4++jfpIazlyRI9cU7Dmg6/ms6VX8JOnzcIM+ rcHUp6qmDu3UVPkRpu1nAzEhieGoevJALIeAFzLXg2GGF2akQ1xRILapKp8tZ/xWjco8F9 HU3bEDJJXf6EMhbgA83/MIo1xdY6TljCuBxJJvQYa3om3+u/mSKYLIOjVzrcPSjsxmo9UR BiDQ3kiepDywO361YtrYdmc08vfR3ibSq2n4rW2KnuaUOHbNSrzO4ah3YDVS6zRhnemJto qN5/2mnfv7SMDQ+rlhV/iTcn9GuVfHKAQp7fd83bvBVK3P3r/P+LL58kbeaiWw== From: Louis Chauvet Date: Tue, 27 Aug 2024 11:57:39 +0200 Subject: [PATCH v2 4/6] drm/vkms: rename to_vkms_crtc_state to drm_crtc_state_to_vkms_crtc_state to avoid confusion MIME-Version: 1.0 Message-Id: <20240827-google-vkms-managed-v2-4-f41104553aeb@bootlin.com> References: <20240827-google-vkms-managed-v2-0-f41104553aeb@bootlin.com> In-Reply-To: <20240827-google-vkms-managed-v2-0-f41104553aeb@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie 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=2791; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=+9EVfrWGXweMRhdpWJLhgyFdBP6idc+nFpzOoZsSppQ=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmzaQPuNM20rjRpZD7nSUpPweO7ZcP+gjwczjjc 3gojL+9YGaJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZs2kDwAKCRAgrS7GWxAs 4qKID/9nz7XMygblI4ARivSoC0zr8EI1wnWrgFrT/tdSCA8CSeQCU5IF4gubapo16WY/hYgIq6e aQWsp0zCN/uM6uA6WwKIQ9LW3aBmC3cBDIQ7tR4hUO0qxovxiHsbpLYbnVF5J1dqx7N1tgOfqEU Fzvsm2DUmWCCain8nxX6c+Tg+XWA6iJQr+Qq7KoTX8kvoCT/6KWOH05FUZ3YKfbEqKOVpP+0aT7 Zcn4OhyQ0meYoILFPIPviYTVcGJtLmbwpLzmP895OcrohHZYKuCQMP36/bDC9VZax49TVYc9hps V81E7s+aW/GVdZn6PhPFDNqKV2sTzHdILFD5MFKXuNd8v1ZXiq5ppe8eo95vm6+84I+dsEBnbpS GnxPh6jSnHYDk59cKDKlWerdgDzNaiipAhMgA8Y/QkP5gdkm9Cv+KoGhtHj7gSsM8rwi58f1Dbk cl40RVFpg74Wnv9V6krqLNSl57a2IdrxgTpSjNRzG77YndkloXIubWcdMa1qsZLnoSqG7EbuKdP hnwdn5LjQwHCMcxWN5zJhnoYHDGMSEfw5zB2iVsVRs6nnNo/5WZtAkdRGalBgg1N+NLq4qTrWA5 O4ZDTFjXeILYM6Z8fpHsdgzbEDpTBU1BvMzcXuQx5iZk349+hUqhKoQaQv8OqDeqIyZDPkj5fPn l0Vn0Kz0ROmVv/Q== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To avoid confusion in macro, rename to_vkms_crtc_state to a more explicit name drm_crtc_state_to_vkms_crtc_state Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_crtc.c | 6 +++--- drivers/gpu/drm/vkms/vkms_drv.c | 2 +- drivers/gpu/drm/vkms/vkms_drv.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 013bf8336b54..2bf733a1b9f0 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -132,7 +132,7 @@ vkms_atomic_crtc_duplicate_state(struct drm_crtc *crtc) static void vkms_atomic_crtc_destroy_state(struct drm_crtc *crtc, struct drm_crtc_state *state) { - struct vkms_crtc_state *vkms_state = to_vkms_crtc_state(state); + struct vkms_crtc_state *vkms_state = drm_crtc_state_to_vkms_crtc_state(state); __drm_atomic_helper_crtc_destroy_state(state); @@ -173,7 +173,7 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc, { struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc); - struct vkms_crtc_state *vkms_state = to_vkms_crtc_state(crtc_state); + struct vkms_crtc_state *vkms_state = drm_crtc_state_to_vkms_crtc_state(crtc_state); struct drm_plane *plane; struct drm_plane_state *plane_state; int i = 0, ret; @@ -257,7 +257,7 @@ static void vkms_crtc_atomic_flush(struct drm_crtc *crtc, crtc->state->event = NULL; } - vkms_crtc->composer_state = to_vkms_crtc_state(crtc->state); + vkms_crtc->composer_state = drm_crtc_state_to_vkms_crtc_state(crtc->state); spin_unlock_irq(&vkms_crtc->lock); } diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index d1ed6bbe9559..f2818374f5c9 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -82,7 +82,7 @@ static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state) for_each_old_crtc_in_state(old_state, crtc, old_crtc_state, i) { struct vkms_crtc_state *vkms_state = - to_vkms_crtc_state(old_crtc_state); + drm_crtc_state_to_vkms_crtc_state(old_crtc_state); flush_work(&vkms_state->composer_work); } diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index c55ab45ccb20..3501cd9401d5 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -136,7 +136,7 @@ struct vkms_device { #define drm_device_to_vkms_device(target) \ container_of(target, struct vkms_device, drm) -#define to_vkms_crtc_state(target)\ +#define drm_crtc_state_to_vkms_crtc_state(target)\ container_of(target, struct vkms_crtc_state, base) #define to_vkms_plane_state(target)\ From patchwork Tue Aug 27 09:57:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13779216 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 38188C5320E for ; Tue, 27 Aug 2024 10:02:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A924610E2CB; Tue, 27 Aug 2024 10:02:11 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="nTDuvTTw"; 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 B40DB10E222 for ; Tue, 27 Aug 2024 10:01:59 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 7D3271C0012; Tue, 27 Aug 2024 10:01:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1724752918; 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=nab9sxyGuNbJf2fwXC6yPovjq0ddYSUOgBR9X9KtRm4=; b=nTDuvTTwoNbNg3wmmrqgX3ZD1O3vmeezJ0k+zGjlDJWHO0ezmi9BqvLFZt7+XamE33qeCU kYPfNprPBPXBKHt8ZjBkG1jTE8SoRnCriHPtvX1rhbuoLNUAySFxkug4b5EzeFW9Lp4jD1 0mrY3OfRbU50vxuOfOzshnifsGkYXHKiR5lCl6Cfk9V/to8eyhUfByWZGmpUAc1qKep5T2 kYqCREYFZzO7nHAeTx8GXCEeDr8jzCl5mC3d42fEvzjZ+DONaZfgvsCz/Idn8C8SQTlvJ7 UU++oJjOc3LKLfuh+8BKQsMyy4wdX48HCiygbFa9bMRpB/nNT4Np5vbfNeqjkA== From: Louis Chauvet Date: Tue, 27 Aug 2024 11:57:40 +0200 Subject: [PATCH v2 5/6] drm/vkms: Switch to managed for CRTC MIME-Version: 1.0 Message-Id: <20240827-google-vkms-managed-v2-5-f41104553aeb@bootlin.com> References: <20240827-google-vkms-managed-v2-0-f41104553aeb@bootlin.com> In-Reply-To: <20240827-google-vkms-managed-v2-0-f41104553aeb@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie 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=11461; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=b5zfZhgdJRj84RHHwh0TEbI8bfN8VfBp90V91fl07Zo=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmzaQP430g6cQamYKLckg34XmmAfEpSxn3+QXD4 /dBo9spv6iJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZs2kDwAKCRAgrS7GWxAs 4vDGD/9RVHCp3789th6qbz6hd8Y+12n1amBCApowq8uw6H9VWOxh1KJhcxV/U1a8Wwu8mRSEFYl PGh3m/RQG0eYsY+evQLXed1Tc3T78KFV36f/Oiz1XydM7r4UenTrkG4VP4QmXKwJ32XZ6O2UtQR Le+ddAW2U9edfU3xp+1XkmfTp5EUnF99AJChL435qBvb6Gke69Cm+sl5407esUlBCyrC0HXjEPz vpk3P2JTSdp0W1hCJsrYM71vPyUILyBfl0sKHSTVJQe0VMVdgCPixIeFBHHXk65wkli2l4xvtQ0 AgoxULVWxdXplEesG2RrYVyvRcqWcN093hsKsyRTqjw/N6j8LiFVGjCKD/CcAbzaacArL8dQKLO nWrHDzbUEENfrhc9DEHTzX2zeJn5YrsDcDmbJG7F4uD3HpcYajXePuxJdGNfitDq+Wr3HMHBsn7 /YmoHrfrtRkgXKvZrKVMRuIkD70k/w5vLtwDnw4s3fDtBTJMS3qgyaa+qqYb/jwlwfB0ZWbtubu RvUhDYknjWOAu+DzZUOpE9+EKHrujFDSU8IVEHBsR9N8DPl0vSdNxa8ln1RNgi+p6tAvf7j4Jwx Xwn/Pv4Ev2kGOVo+jgGhTwBFjADhinczioqfBhqZK/KG/rSIFf2JOKvZvOb488M79RibTPwReLt L9kLLpxKgitF9IQ== 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 CRTCs. It is not an issue yet, but in order to support multiple devices easily, convert this code to use drm and device managed helpers. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_crtc.c | 40 +++++++++++++------- drivers/gpu/drm/vkms/vkms_drv.c | 9 ----- drivers/gpu/drm/vkms/vkms_drv.h | 7 ++-- drivers/gpu/drm/vkms/vkms_output.c | 69 +++++++++++++++-------------------- drivers/gpu/drm/vkms/vkms_writeback.c | 14 +++---- 5 files changed, 65 insertions(+), 74 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 2bf733a1b9f0..ff55099c86ce 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "vkms_drv.h" @@ -270,30 +271,41 @@ 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) +static void vkms_crtc_destroy_workqueue(struct drm_device *dev, void *raw_vkms_crtc) { - struct vkms_crtc *vkms_crtc = drm_crtc_to_vkms_crtc(crtc); + struct vkms_crtc *vkms_crtc = raw_vkms_crtc; + + destroy_workqueue(vkms_crtc->composer_workq); +} + +struct vkms_crtc *vkms_crtc_init(struct vkms_device *vkmsdev, struct drm_plane *primary, + struct drm_plane *cursor) +{ + struct drm_device *dev = &vkmsdev->drm; + struct vkms_crtc *vkms_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_crtc = drmm_crtc_alloc_with_planes(dev, struct vkms_crtc, base, primary, cursor, + &vkms_crtc_funcs, NULL); + if (IS_ERR(vkms_crtc)) { + DRM_DEV_ERROR(vkmsdev->drm.dev, "Failed to init CRTC\n"); + return vkms_crtc; } + drm_crtc_helper_add(&vkms_crtc->base, &vkms_crtc_helper_funcs); - drm_crtc_helper_add(crtc, &vkms_crtc_helper_funcs); - - drm_mode_crtc_set_gamma_size(crtc, VKMS_LUT_SIZE); - drm_crtc_enable_color_mgmt(crtc, 0, false, VKMS_LUT_SIZE); + drm_mode_crtc_set_gamma_size(&vkms_crtc->base, VKMS_LUT_SIZE); + drm_crtc_enable_color_mgmt(&vkms_crtc->base, 0, false, VKMS_LUT_SIZE); spin_lock_init(&vkms_crtc->lock); spin_lock_init(&vkms_crtc->composer_lock); vkms_crtc->composer_workq = alloc_ordered_workqueue("vkms_composer", 0); if (!vkms_crtc->composer_workq) - return -ENOMEM; + return ERR_PTR(-ENOMEM); + + ret = drmm_add_action_or_reset(dev, vkms_crtc_destroy_workqueue, vkms_crtc); + if (ret) + return ERR_PTR(ret); - return ret; + return vkms_crtc; } diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index f2818374f5c9..5282f71b50a6 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->crtc.composer_workq) - destroy_workqueue(vkms->crtc.composer_workq); -} - static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state) { struct drm_device *dev = old_state->dev; @@ -109,7 +101,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, diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 3501cd9401d5..cff2e0686c04 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -126,7 +126,6 @@ struct vkms_config { struct vkms_device { struct drm_device drm; struct platform_device *platform; - struct vkms_crtc crtc; const struct vkms_config *config; }; @@ -143,8 +142,8 @@ struct vkms_device { container_of(target, struct vkms_plane_state, base.base) /* CRTC */ -int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, - struct drm_plane *primary, struct drm_plane *cursor); +struct vkms_crtc *vkms_crtc_init(struct vkms_device *vkmsdev, struct drm_plane *primary, + struct drm_plane *cursor); int vkms_output_init(struct vkms_device *vkmsdev, int index); @@ -165,6 +164,6 @@ void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state 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_crtc *vkms_crtc); #endif /* _VKMS_DRV_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index cd506dcfd50f..0c585e48fa01 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -27,42 +27,31 @@ static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = { .get_modes = vkms_conn_get_modes, }; -static int vkms_add_overlay_plane(struct vkms_device *vkmsdev, int index, - struct drm_crtc *crtc) -{ - struct vkms_plane *overlay; - - overlay = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_OVERLAY, index); - if (IS_ERR(overlay)) - return PTR_ERR(overlay); - - if (!overlay->base.possible_crtcs) - overlay->base.possible_crtcs = drm_crtc_mask(crtc); - - return 0; -} - int vkms_output_init(struct vkms_device *vkmsdev, int index) { - struct vkms_crtc *vkms_crtc = &vkmsdev->crtc; + struct vkms_plane *primary, *cursor, *overlay = NULL; struct drm_device *dev = &vkmsdev->drm; struct drm_connector *connector; struct drm_encoder *encoder; - struct drm_crtc *crtc = &vkms_crtc->base; - struct vkms_plane *primary, *cursor = NULL; - int ret; - int writeback; + struct vkms_crtc *crtc; unsigned int n; + int ret; + /* + * Initialize used plane. One primary plane is required to perform the composition. + * + * The overlay and cursor planes are not mandatory, but can be used to perform complex + * composition. + */ primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY, index); if (IS_ERR(primary)) return PTR_ERR(primary); if (vkmsdev->config->overlay) { for (n = 0; n < NUM_OVERLAY_PLANES; n++) { - ret = vkms_add_overlay_plane(vkmsdev, index, crtc); - if (ret) - return ret; + overlay = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_OVERLAY, index); + if (IS_ERR(overlay)) + return PTR_ERR(overlay); } } @@ -72,22 +61,24 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) return PTR_ERR(cursor); } - ret = vkms_crtc_init(dev, crtc, &primary->base, &cursor->base); - if (ret) - return ret; + crtc = vkms_crtc_init(vkmsdev, &primary->base, + cursor ? &cursor->base : NULL); + if (IS_ERR(crtc)) { + DRM_ERROR("Failed to allocate CRTC\n"); + return PTR_ERR(crtc); + } connector = drmm_kzalloc(dev, sizeof(*connector), GFP_KERNEL); if (!connector) { DRM_ERROR("Failed to allocate connector\n"); - ret = -ENOMEM; - goto err_connector; + return -ENOMEM; } ret = drmm_connector_init(dev, connector, &vkms_connector_funcs, DRM_MODE_CONNECTOR_VIRTUAL, NULL); if (ret) { DRM_ERROR("Failed to init connector\n"); - goto err_connector; + return ret; } drm_connector_helper_add(connector, &vkms_conn_helper_funcs); @@ -95,34 +86,34 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) encoder = drmm_kzalloc(dev, sizeof(*encoder), GFP_KERNEL); if (!encoder) { DRM_ERROR("Failed to allocate encoder\n"); - ret = -ENOMEM; - goto err_connector; + return -ENOMEM; } ret = drmm_encoder_init(dev, encoder, NULL, DRM_MODE_ENCODER_VIRTUAL, NULL); if (ret) { DRM_ERROR("Failed to init encoder\n"); - goto err_connector; + return ret; } - encoder->possible_crtcs = 1; + encoder->possible_crtcs = drm_crtc_mask(&crtc->base); + + /* 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); - if (writeback) + ret = vkms_enable_writeback_connector(vkmsdev, crtc); + if (ret) { DRM_ERROR("Failed to init writeback connector\n"); + return ret; + } } drm_mode_config_reset(dev); return 0; - -err_connector: - drm_crtc_cleanup(crtc); - return ret; } diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c index e055ad41241b..18aed20cd733 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -106,7 +106,7 @@ 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_crtc *vkms_crtc = container_of(connector, struct vkms_crtc, wb_connector); if (!job->fb) return; @@ -115,8 +115,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->crtc, false); + vkms_set_composer(vkms_crtc, false); kfree(vkmsjob); } @@ -125,8 +124,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_crtc *vkms_crtc = &vkmsdev->crtc; + struct vkms_crtc *vkms_crtc = drm_crtc_to_vkms_crtc(connector_state->crtc); struct drm_writeback_connector *wb_conn = &vkms_crtc->wb_connector; struct drm_connector_state *conn_state = wb_conn->base.state; struct vkms_crtc_state *crtc_state = vkms_crtc->composer_state; @@ -140,7 +138,7 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn, if (!conn_state) return; - vkms_set_composer(&vkmsdev->crtc, true); + vkms_set_composer(vkms_crtc, true); active_wb = conn_state->writeback_job->priv; wb_frame_info = &active_wb->wb_frame_info; @@ -168,9 +166,9 @@ 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_crtc *vkms_crtc) { - struct drm_writeback_connector *wb = &vkmsdev->crtc.wb_connector; + struct drm_writeback_connector *wb = &vkms_crtc->wb_connector; drm_connector_helper_add(&wb->base, &vkms_wb_conn_helper_funcs); From patchwork Tue Aug 27 09:57:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 13779214 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 6A299C5472E for ; Tue, 27 Aug 2024 10:02:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A902010E2C8; Tue, 27 Aug 2024 10:02:02 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="f/UHflwO"; 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 A3F8410E222 for ; Tue, 27 Aug 2024 10:02:00 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 7667C1C0002; Tue, 27 Aug 2024 10:01:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1724752919; 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=QXbrQYbwu05I9QcdP0EOzRyW3VmbUgQZEfA/b5hJq/c=; b=f/UHflwOwNjX3GLS9YGAaiQzzbpHgXjZD2iKJxHwfggRH236UQ+HPVCJrjoFw5d3ryrdYt UGfDhaQg72qAQ7eepZub2VOUG+P/qmD8NNgVlad7B9nZ9HO0iCxTHp8RbDuhso7J7XGXhj MEErdzUe0CdmiOdZiw8lQaGFhLzQMsV+pTU4duPycmHj0YciJsl468heZGR/7vFU4xG0fp tT9X0z5qV1s2nNx2dI4NZebpldrhYxYF3Pt3Ng1p6HRx6mMd/i7duXlUm4Kk1hhE68D7nl DFwitAm/TWZc4jnvRYXatENvxI/Op82NoK64JJKrqu+BUmzurHxuGrhgMPhn2w== From: Louis Chauvet Date: Tue, 27 Aug 2024 11:57:41 +0200 Subject: [PATCH v2 6/6] drm/vkms: Add missing check for CRTC initialization MIME-Version: 1.0 Message-Id: <20240827-google-vkms-managed-v2-6-f41104553aeb@bootlin.com> References: <20240827-google-vkms-managed-v2-0-f41104553aeb@bootlin.com> In-Reply-To: <20240827-google-vkms-managed-v2-0-f41104553aeb@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie 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=1030; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=eon9nKAT8aprMkogaxLTrCwGM6rlkI2aZ3rSwA+swpU=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBmzaQPRDVNlHwwkHSIsyM3580wfuLwKuybATZ3e f1fTFkk8FaJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZs2kDwAKCRAgrS7GWxAs 4q3VD/9O53/2TSWKz6e2kcpm9dLhofqv1w+m5klIZ8QHKUHuTMyrKFAtsz1h8R4ElpWZXr1sXAc ncPE46mxY559k5KaL+fEwK9mtU9XRbD6OczzCmiRCTCU0BJKCDa/KMJgd6F63ITacdZF5JcuFkR Xv9M1hgHh92mTXp+XdZwTKOoVsDMWtXIJW9xYQp9cLTd4kfAkkzqaK3D6/0Ql+9sPN8oPHSkZfs /0NDi55NfeUllmYA9I+EeKjqp25WxLxmbj+JrWgmVjZ9aVYXvfmazK3bnMXWIEMDG6pj8+Uexf+ qVjJ4JqtmYOlDsKGWdWUz91jgWQH3Z1pI5wg6XvKAI12bL1p3+2t0T2np0+LyrdqxJr4phgT2SA jtgP6gKCABQaoE9Eqmfn0YSGqjQ+O2esSfx5+xUb6bCFDY5LB/bBpyJbrJ1244ZHVN9FPxvukb5 NraOGZ+CTOFSx6mbdC1clO6qfIKgzwqQ7SARti31N+crDKbzvHlfdjmp/U9m2AvlOzQc1bwrgUZ ZgUou1GjYGxQGxAmKCay9KupgL/3FoKFL6CJ5x11dwoN9GNjvXz+3kxtbHyaSDFJN62TtEmpNwS /0Kih70wh2BRmK81LRVMjhj5k6oHVuwbr3Ge7Ra+TnoBg+w8S7kSm9g0CTIrBgehCCskkoQ5SdH qC3+Dhf6xAYwRDA== 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" CRTC initialization call drm_mode_crtc_set_gamma_size without the proper checks, introduce this check. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_crtc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index ff55099c86ce..39802c928bdf 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -293,7 +293,12 @@ struct vkms_crtc *vkms_crtc_init(struct vkms_device *vkmsdev, struct drm_plane * } drm_crtc_helper_add(&vkms_crtc->base, &vkms_crtc_helper_funcs); - drm_mode_crtc_set_gamma_size(&vkms_crtc->base, VKMS_LUT_SIZE); + ret = drm_mode_crtc_set_gamma_size(&vkms_crtc->base, VKMS_LUT_SIZE); + if (ret) { + DRM_DEV_ERROR(vkmsdev->drm.dev, "Failed to set gamma size\n"); + return ERR_PTR(ret); + } + drm_crtc_enable_color_mgmt(&vkms_crtc->base, 0, false, VKMS_LUT_SIZE); spin_lock_init(&vkms_crtc->lock);