From nobody Sat Nov 30 02:27:59 2024 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD01D53365 for ; Thu, 12 Sep 2024 14:45:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726152320; cv=none; b=BcoFYTpbcQQ6DujifRoWw8WkDa+DFIrySCwahH6vv369aUBH3vIixeyzO2MwuEILeRlH84DbrLEIiXYqpJJAnjOs+ySoXwKXk3DFe7WX5sdexOvEiNHpZS0hTDjbkRSSvDBHp4HwTjb43e6cX+0DIV34EEGa1DBQ21b7kxhnDOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726152320; c=relaxed/simple; bh=VISv8cauLqco3i0yU3WE+qBEYcD8Yqy+TzLEZjfI2aA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DnYHE+8E8ARewL+aduwPxVqrGrlHNKpTQiyeeSBQ8KJkdbId/B+lK1iBkAHovc60GPQHYSGmQyf867GbSOvJ3bsXn87ZIfWWYIIYlrffrbP5/F91K7pRYTQQRpEpL3U5ZbHeQAZIBW1ckW9zfOTjD4IPAWbJjDRIdDcqGXn6lVU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=USnakRW0; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="USnakRW0" Received: by mail.gandi.net (Postfix) with ESMTPSA id 9446560002; Thu, 12 Sep 2024 14:45:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1726152316; 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=VjOJC+EL99w5X5JPK4o+U/Y7d6sfgViwqZhRV6zOAXs=; b=USnakRW0P3+On5tsLuyinvtacjPXpy8jk6m6vSK0e9hSSGrgC5lcDcREmd4Lqoj8nI+3xG n/cZZ9kaXMaUIyuErJkrf/yDZ/rNcXrbQ3D7fGivoB7fwF2MEjLCLvYt3veMIrGYtl9nzB 3GzEv+7HW8OCkKfb8qkwKi3MFAc49As76BSSN0CGJOnPWJvp1HN1Y9eticXFeRxAKCZC53 1/wveso1Z8q39B29mOimsDEwOcQLSpYC1LsRSUjBdQ/JPWWMTmwjmrAkaM1/QYu4UJOn2r W6+QSGOD1st0q/K2CZjNWmJ/guX6Kkl2R8rNxAlZPs9mkmxi26feUs+l+6mIAg== From: Louis Chauvet Date: Thu, 12 Sep 2024 16:44:56 +0200 Subject: [PATCH 1/3] drm/vkms: Switch to dynamic allocation for connector Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240912-b4-vkms-allocated-v1-1-29abbaa14af9@bootlin.com> References: <20240912-b4-vkms-allocated-v1-0-29abbaa14af9@bootlin.com> In-Reply-To: <20240912-b4-vkms-allocated-v1-0-29abbaa14af9@bootlin.com> To: Rodrigo Siqueira , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie 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=2025; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=VISv8cauLqco3i0yU3WE+qBEYcD8Yqy+TzLEZjfI2aA=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBm4v55KfOcgsvimu2ERpNMHzA47HInyittFEgRR VDvWFM3DuGJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZuL+eQAKCRAgrS7GWxAs 4j/UD/4hQ/weYoMyUBLTN8U6NVvM4pvYx0eSMoehZRzPgxwhhR3D3EY32zadogiYdvftp9aWpin 45/OGfmnpOjPvC03b5oxWpEiu9JRi5/yKzlxR7smvvxTKhoPZYHrgr0jBlFEBFPfk5CDWvN/5i+ qvRaI4F/Yu5kgUnNhSEzBwVmddS9jQNeCmGIAMJv3J0+ttDS+yIDPaCHFlyNu+0hgvWgWaGm9yw 8dOzZ+MGwo2VBZrxGSg1i6vtHBONUK+w0h5KKBHQWLNrGr+x81IwqU+3S+a95y15od2JlkQtLLy 1Lm7LlXXNGCZpUhthutXrDE/wBOq/T9rgCEDqPCjeO2jtuOISk7fFhXqGC03MFFprocf4JJHNuk DY+rYvNWJj9ie7HIM+Y5fW2G/CUdXro2c2ttixYOYZhHMrh0UR8eL0o/OTE/ZiUiLGOABdj83Ik WwW7be/XZESwR3EZB+ARwE48cScO3D8qCO4cHsJfAbEYrR3yauoL/oyZOI12QFjueOuPreQbPJz BvUr31ITHrYzO+iPnApjPz094BUSoy5wAFxSETfZ7qXkQNY0XCkFD/XFwEeWdqayW0LNn0oa+YS niTtXjr8Mpf5FyJ7uwafs3MqtFd/utBcTZOzHB+aSOQp7AExKT4cc6rvSf4jqs32EqLirPulpoP et/l8QiVuM28kxQ== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_drv.h | 1 - drivers/gpu/drm/vkms/vkms_output.c | 9 ++++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_dr= v.h index dac063f11dcd751865cc79d3c2466d113b8e79c7..938f369dba7ab82b55c656ac6cc= f2dfe5a11f9e6 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 2226ba1972f3ff51483abacac45ee8914be0c94a..a0331181ab0e369d711aee0974d= f4859844c6549 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -31,7 +31,7 @@ int vkms_output_init(struct vkms_device *vkmsdev) { struct vkms_output *output =3D &vkmsdev->output; struct drm_device *dev =3D &vkmsdev->drm; - struct drm_connector *connector =3D &output->connector; + struct drm_connector *connector; struct drm_encoder *encoder =3D &output->encoder; struct drm_crtc *crtc =3D &output->crtc; struct vkms_plane *primary, *overlay, *cursor =3D NULL; @@ -62,6 +62,13 @@ int vkms_output_init(struct vkms_device *vkmsdev) } } =20 + connector =3D drmm_kzalloc(dev, sizeof(*connector), GFP_KERNEL); + if (!connector) { + DRM_ERROR("Failed to allocate connector\n"); + ret =3D -ENOMEM; + goto err_connector; + } + ret =3D drmm_connector_init(dev, connector, &vkms_connector_funcs, DRM_MODE_CONNECTOR_VIRTUAL, NULL); if (ret) { --=20 2.44.2 From nobody Sat Nov 30 02:27:59 2024 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92B7D14293 for ; Thu, 12 Sep 2024 14:45:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726152320; cv=none; b=HtjbkdDXjaDCWpePEkrZry9ODYwucu7XPbAa+1VaIfVynZ3ABP/dXd+5XNcRLL1ry1P7Urwblmvx9O1Xd91APUo4me4hDnyBTQF5DeJJZmtaPDfpbD799NRFHsdfmGNzDBu5IHnF4jT1RVU5Oqt2VMqQ7L6MQFyzQ055JKrymsc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726152320; c=relaxed/simple; bh=R6SPGn2rr2lmfTLnTDiW499ZcaUmyciVWbCOCWFFM/c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BZ0lT0Bv+umLrMJBUPcj59aR/b5fM1WHsfXxAGzW+8fdQqr0SjYZa/q9UzVQZzI7PtBSLMx9QRzxAR/y1qWCBjsZPU8HZ7l7O/FaCP7PfgPe4megvw9HDcNzwmFjLJjqqCUl/VlfYCrbLS4Ha4XiIQ4iHxmZTd3TVgaaGCQT4fM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=OFiu/hJo; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="OFiu/hJo" Received: by mail.gandi.net (Postfix) with ESMTPSA id 503406000E; Thu, 12 Sep 2024 14:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1726152316; 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=kBo348yC3L95wfapyQgnGAiLm/Rv72oVU1O83Nnte5E=; b=OFiu/hJozka6/ivFs4swj6BhfqQVp6TbsLvCTZrWpi29I/ftStyKqjLujSkelIjTc9OPcY XGL0oL0ufRdY273o+C1oQQQdOuumtl5dwQi2pNY6eJcSkRRwolzGIgZNXi9XV/C5eqRRNv +hZXDfEA16e8LCa+8+vjUw1ZQHCAkWjayWMmKvRQd17w7QCTcZDcxVSB5ZxxMkl88FZsPD G17TbekcZZzeXN7zS5gdhpLgs6ZNFkpVVZWM4iVrszMvA4Al/3TUzncVgWV8QqgBmdAyJN PHtmhWIT0dM3VrVjoJQVX7M+z+2ffIlNYJe8NCyuxPx1cnPRE309GzkzEbctIg== From: Louis Chauvet Date: Thu, 12 Sep 2024 16:44:57 +0200 Subject: [PATCH 2/3] drm/vkms: Switch to dynamic allocation for encoder Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240912-b4-vkms-allocated-v1-2-29abbaa14af9@bootlin.com> References: <20240912-b4-vkms-allocated-v1-0-29abbaa14af9@bootlin.com> In-Reply-To: <20240912-b4-vkms-allocated-v1-0-29abbaa14af9@bootlin.com> To: Rodrigo Siqueira , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie 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=1992; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=R6SPGn2rr2lmfTLnTDiW499ZcaUmyciVWbCOCWFFM/c=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBm4v55C7WAonM/09D7jvj4bM0kTxs1GXKHqsKuU 19CM2Y/yBSJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZuL+eQAKCRAgrS7GWxAs 4vrlD/93d+F4p2CoET3vvC5cMdZ/O8dCuPfsYI4vQJP1VnkFMgVU99qEQsP7m9m8HqLWWgFMV+R D4Xf/G9e1wCsKfj7r62pZXRubiGM07KU5Mpeu2lLEkX9jNeaxZbY7lf0izio58Lemj0nr10olwd 5YevpZIq+peL9JuBXfNMjAQfRVPImNuMrI43yzSzEDlkpAXffekIgMcqek2JFWM0KaSvjUCp+oi FGxXO/Mh/KxyOJ53BfTA3u+xvam9D3eQ2J+al8SXkGVTckscxb6ftQ5t4E9M5nc//tErB18cOzl QeCXaUxBP1ntKqW/6WmDLaBJGQtbL8qVCZH6C8hvTWwzY6MZPym9KVXZixKqC7XjVlRv9YizMhj wCtdU26X0z0IxXGIkvjed6pDED9BUxDwId6zYSL2UDp+EMBvxc7IieKZudxGWGvMT4M91r8upOt GtbI7Hd5dIzWlFJxH/CcGYHJAhXR3/oki/e1XtcoRX/3gppN7PituefhF59ji+E0wLLTtZpdNlB uxOUlc92MJxJPYtkm9jSiixNQsxhbOSm9YaJCIcW3rscHf64Nv/u7UL0Oa9vMQ96AW+i2t4iemM Z+VHLnTIxE/C0gGb7lZrHgeL+YZlmtR2FpI1gaftcKz+Fua6fkqSpkprqFkJxMpS14x0gz8ZTuo ySAuo/GZs02wLyw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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. 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_dr= v.h index 938f369dba7ab82b55c656ac6ccf2dfe5a11f9e6..972aee6853f2b29909291e33652= f68740fdc9dbc 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 { =20 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 a0331181ab0e369d711aee0974df4859844c6549..60d5365f8d41b8f20da489cfb9d= bc85eb9df4916 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 =3D &vkmsdev->output; struct drm_device *dev =3D &vkmsdev->drm; struct drm_connector *connector; - struct drm_encoder *encoder =3D &output->encoder; + struct drm_encoder *encoder; struct drm_crtc *crtc =3D &output->crtc; struct vkms_plane *primary, *overlay, *cursor =3D NULL; int ret; @@ -78,6 +78,12 @@ int vkms_output_init(struct vkms_device *vkmsdev) =20 drm_connector_helper_add(connector, &vkms_conn_helper_funcs); =20 + encoder =3D drmm_kzalloc(dev, sizeof(*encoder), GFP_KERNEL); + if (!encoder) { + DRM_ERROR("Failed to allocate encoder\n"); + ret =3D -ENOMEM; + goto err_connector; + } ret =3D drmm_encoder_init(dev, encoder, NULL, DRM_MODE_ENCODER_VIRTUAL, NULL); if (ret) { --=20 2.44.2 From nobody Sat Nov 30 02:27:59 2024 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60D953A1DB for ; Thu, 12 Sep 2024 14:45:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726152321; cv=none; b=dniyap2O/vnwd9GelRgUMIgGDBIxPzSElmAYV55yRjk79HZFrHU9TjAJ52Wsunsi2Crn2ckot7NGIrhMpVO77kA0H2cDUHOn7KZbdsE6lcVKR6mqYiX6zMD4aTict65V1F6TJXl1JbJh5O+a37vT1ojKy+e51PF0YLlE0+CwURE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726152321; c=relaxed/simple; bh=Ula2yYzZw2yesSTiWvHRlTRnDJntJyrmKqqJQ8bq7v0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=q9B0duYK6AX2phJRfY/a3//A/hE75oGIK8WF/+eubnDJSVT7c37dvJxQokBgP43rpQjjptyuRBGqjA9PBpgWVeJb6j3o69aSA/gOgS03r2WnnfsNBFDhRSH7L9LZ5Y0dPLGYN3dgfbYEhsFuvey/S2im6qG6Gajr/p9qiifqSgU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=ZlcxW8Pq; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="ZlcxW8Pq" Received: by mail.gandi.net (Postfix) with ESMTPSA id 11D7060011; Thu, 12 Sep 2024 14:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1726152317; 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=0KE+gNDDpUp9GvMK6xMOxGaFc09i5YxrO9RNbFqdsjs=; b=ZlcxW8PqtYjKupK1wcF552GK0IrupDMj7Rx0mKXSRzeAzvOyCbULDONDLKUtZiVJaQ6DFG JMJ6HXOll70xcphGi2ZMpA9jeY4nxJM/HoJLO6tmKTmS9MIV9UqnWvVhisYSNBjPtoBd7u +6tj6NuVioVuCDUDxCzoy3yFGuowX853ZvYaHDyCqxaYuk3/RjkKP5gedMDUPQUyNMjCqi wEGpwgBXa2KBagD3X/jgHsQD+4gm2pkePAkb/XNvrm5c0wBamJ72tIqLwIotBbe+wvUJaU yAznSQJGWkw8VV+S6Z662dlL4C60arzDfurqQmGoBHNaHItkNHN30cCf19yZCA== From: Louis Chauvet Date: Thu, 12 Sep 2024 16:44:58 +0200 Subject: [PATCH 3/3] drm/vkms: Switch to dynamic allocation for CRTC Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240912-b4-vkms-allocated-v1-3-29abbaa14af9@bootlin.com> References: <20240912-b4-vkms-allocated-v1-0-29abbaa14af9@bootlin.com> In-Reply-To: <20240912-b4-vkms-allocated-v1-0-29abbaa14af9@bootlin.com> To: Rodrigo Siqueira , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Daniel Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie 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=9728; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=Ula2yYzZw2yesSTiWvHRlTRnDJntJyrmKqqJQ8bq7v0=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBm4v55n5zgFqWCmOV6uNQ06y44Xddgr7eJdujD8 YUXc/L2kYWJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZuL+eQAKCRAgrS7GWxAs 4o3MD/95p2PZa2kN9SRXnPJD8YRHoi0PGqTqZjEHNYXSLczvbdY6cuPZlemrdDCY10S2hYJR0gd /FV290ondiba99fxrf6SwK1GCgjHe5eqQv+6J/FUNgh1Pb6Cb2FF9aoW2iRe/WzBUgZ8PWjAwxe vGqWbQbEhhTMRIaNNwBESvZAMdMn/4z7ttLo6r1T7kAXVV2zSp5BZnToapEAwGsRPmABqG2bKJW GWsv+bReWwqFXvekm2+hZdF3WN80qehE8nw2LG/rEYAMQdyEFD3W54NkUq8ShvbWgIPDoaBkq/H P1ncjZpKpKwo1++litCRoZJFMXQ6rtLbeh5ex+jiDhKl1BACY9UuMlF6bVi8wzYNlKetr/HrUu6 A+sEGmN+2PVq3ZFUxGj2u0+TTlJx47g6jdZ666EQOTUA9hZL6YK1AoHretzYBM3hAaMdYQwy1uy T/Rg6upQi+DaimTWO/24So7s578ys5CvTGqn8SZG+RzK1IW4hpEXUeKbeGDC6CKU62ihPqro69o McSvI4ggrs1kXgheo3ZmU97VFM1CaRXdjSSiYTUYaQoM+IWfYEjpvIeqjs72+uxa/iXaPjoKLrp CotVxDEmA20uYPYrBco8P2Cx5eZHFY631x1e0My8SGNrnE1vSRz66P/YFwHGvbQuxPMuKIlPoI4 56eNGHB2nOng1kg== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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 --- drivers/gpu/drm/vkms/vkms_crtc.c | 28 ++++++++++++++----------- drivers/gpu/drm/vkms/vkms_drv.h | 9 ++++---- drivers/gpu/drm/vkms/vkms_output.c | 39 ++++++++++++++++++-------------= ---- drivers/gpu/drm/vkms/vkms_writeback.c | 17 ++++++++------- 4 files changed, 50 insertions(+), 43 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_c= rtc.c index 821b9ac746083630116e05c1cf8e3dc2424ac66a..1169eb5a5e521fb42b1af850824= 25cd71aa2be4d 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -88,7 +88,7 @@ static bool vkms_get_vblank_timestamp(struct drm_crtc *cr= tc, { struct drm_device *dev =3D crtc->dev; struct vkms_device *vkmsdev =3D drm_device_to_vkms_device(dev); - struct vkms_output *output =3D &vkmsdev->output; + struct vkms_output *output =3D drm_crtc_to_vkms_output(crtc); struct drm_vblank_crtc *vblank =3D drm_crtc_vblank_crtc(crtc); =20 if (!READ_ONCE(vblank->enabled)) { @@ -281,19 +281,23 @@ static void vkms_crtc_destroy_workqueue(struct drm_de= vice *dev, destroy_workqueue(vkms_out->composer_workq); } =20 -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_plan= e *primary, + struct drm_plane *cursor) { - struct vkms_output *vkms_out =3D drm_crtc_to_vkms_output(crtc); + struct vkms_output *vkms_out; + struct drm_crtc *crtc; int ret; =20 - ret =3D 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 =3D 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; } =20 + crtc =3D &vkms_out->crtc; + drm_crtc_helper_add(crtc, &vkms_crtc_helper_funcs); =20 drm_mode_crtc_set_gamma_size(crtc, VKMS_LUT_SIZE); @@ -304,12 +308,12 @@ int vkms_crtc_init(struct drm_device *dev, struct drm= _crtc *crtc, =20 vkms_out->composer_workq =3D alloc_ordered_workqueue("vkms_composer", 0); if (!vkms_out->composer_workq) - return -ENOMEM; + return ERR_PTR(-ENOMEM); =20 ret =3D drmm_add_action_or_reset(dev, vkms_crtc_destroy_workqueue, vkms_out); if (ret) - return ret; + return ERR_PTR(ret); =20 - return ret; + return vkms_out; } diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_dr= v.h index 972aee6853f2b29909291e33652f68740fdc9dbc..a97164c0c2d62c4b6bb5641d09b= 3607a742cf585 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_output output; const struct vkms_config *config; }; =20 @@ -143,8 +142,9 @@ struct vkms_device { container_of(target, struct vkms_plane_state, base.base) =20 /* 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); =20 int vkms_output_init(struct vkms_device *vkmsdev); =20 @@ -165,6 +165,7 @@ 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_b= uffer *src_buffer, int y); =20 /* Writeback */ -int vkms_enable_writeback_connector(struct vkms_device *vkmsdev); +int vkms_enable_writeback_connector(struct vkms_device *vkmsdev, + struct vkms_output *vkms_out); =20 #endif /* _VKMS_DRV_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms= _output.c index 60d5365f8d41b8f20da489cfb9dbc85eb9df4916..a57a0cfa21964577f98e564acf8= 7711b2e85fa67 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -29,11 +29,11 @@ static const struct drm_connector_helper_funcs vkms_con= n_helper_funcs =3D { =20 int vkms_output_init(struct vkms_device *vkmsdev) { - struct vkms_output *output =3D &vkmsdev->output; + struct drm_device *dev =3D &vkmsdev->drm; struct drm_connector *connector; struct drm_encoder *encoder; - struct drm_crtc *crtc =3D &output->crtc; + struct vkms_output *output; struct vkms_plane *primary, *overlay, *cursor =3D NULL; int ret; int writeback; @@ -49,31 +49,33 @@ int vkms_output_init(struct vkms_device *vkmsdev) return PTR_ERR(cursor); } =20 - ret =3D vkms_crtc_init(dev, crtc, &primary->base, &cursor->base); - if (ret) - return ret; + output =3D 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); + } =20 if (vkmsdev->config->overlay) { for (n =3D 0; n < NUM_OVERLAY_PLANES; n++) { overlay =3D vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_OVERLAY); if (IS_ERR(overlay)) return PTR_ERR(overlay); - overlay->base.possible_crtcs =3D drm_crtc_mask(crtc); + overlay->base.possible_crtcs =3D drm_crtc_mask(&output->crtc); } } =20 connector =3D drmm_kzalloc(dev, sizeof(*connector), GFP_KERNEL); if (!connector) { DRM_ERROR("Failed to allocate connector\n"); - ret =3D -ENOMEM; - goto err_connector; + return -ENOMEM; } =20 ret =3D 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; } =20 drm_connector_helper_add(connector, &vkms_conn_helper_funcs); @@ -81,34 +83,33 @@ int vkms_output_init(struct vkms_device *vkmsdev) encoder =3D drmm_kzalloc(dev, sizeof(*encoder), GFP_KERNEL); if (!encoder) { DRM_ERROR("Failed to allocate encoder\n"); - ret =3D -ENOMEM; - goto err_connector; + return -ENOMEM; } ret =3D 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 =3D drm_crtc_mask(crtc); + encoder->possible_crtcs =3D drm_crtc_mask(&output->crtc); =20 + /* Attach the encoder and the connector */ ret =3D drm_connector_attach_encoder(connector, encoder); if (ret) { DRM_ERROR("Failed to attach connector to encoder\n"); return ret; } =20 + /* Initialize the writeback component */ if (vkmsdev->config->writeback) { - writeback =3D vkms_enable_writeback_connector(vkmsdev); - if (writeback) + writeback =3D vkms_enable_writeback_connector(vkmsdev, output); + if (writeback) { DRM_ERROR("Failed to init writeback connector\n"); + return ret; + } } =20 drm_mode_config_reset(dev); =20 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/v= kms_writeback.c index a948f4598764efef971f76e1016fc1a963fbbba7..f91c6418480f71ab3ec9989ea85= 814460e10d231 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_co= nnector *connector, struct drm_writeback_job *job) { struct vkms_writeback_job *vkmsjob =3D job->priv; - struct vkms_device *vkmsdev; + struct vkms_output *vkms_output =3D container_of(connector, + struct vkms_output, + wb_connector); =20 if (!job->fb) return; @@ -114,8 +116,7 @@ static void vkms_wb_cleanup_job(struct drm_writeback_co= nnector *connector, =20 drm_framebuffer_put(vkmsjob->wb_frame_info.fb); =20 - vkmsdev =3D drm_device_to_vkms_device(job->fb->dev); - vkms_set_composer(&vkmsdev->output, false); + vkms_set_composer(vkms_output, false); kfree(vkmsjob); } =20 @@ -124,8 +125,7 @@ static void vkms_wb_atomic_commit(struct drm_connector = *conn, { struct drm_connector_state *connector_state =3D drm_atomic_get_new_connec= tor_state(state, conn); - struct vkms_device *vkmsdev =3D drm_device_to_vkms_device(conn->dev); - struct vkms_output *output =3D &vkmsdev->output; + struct vkms_output *output =3D drm_crtc_to_vkms_output(connector_state->c= rtc); struct drm_writeback_connector *wb_conn =3D &output->wb_connector; struct drm_connector_state *conn_state =3D wb_conn->base.state; struct vkms_crtc_state *crtc_state =3D output->composer_state; @@ -139,7 +139,7 @@ static void vkms_wb_atomic_commit(struct drm_connector = *conn, if (!conn_state) return; =20 - vkms_set_composer(&vkmsdev->output, true); + vkms_set_composer(output, true); =20 active_wb =3D conn_state->writeback_job->priv; wb_frame_info =3D &active_wb->wb_frame_info; @@ -167,9 +167,10 @@ static const struct drm_connector_helper_funcs vkms_wb= _conn_helper_funcs =3D { .atomic_check =3D vkms_wb_atomic_check, }; =20 -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 =3D &vkmsdev->output.wb_connector; + struct drm_writeback_connector *wb =3D &vkms_output->wb_connector; =20 drm_connector_helper_add(&wb->base, &vkms_wb_conn_helper_funcs); =20 --=20 2.44.2