From nobody Sat Nov 30 02:41:51 2024 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 61EE415ADAB for ; Fri, 22 Nov 2024 16:35:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732293317; cv=none; b=dL8SowkgaJh166xe53YQbkZPbjpB4TzR/u3Y/YrMSvBSD5Ye+kQ8jnsnjORbTNzD7cBPwAT2rathynQHzRBao46Fy6/LiCIZNUDm/yI47i9B3EWOFRax26Ug0EJHQ9Zn8sD2FiQkTiG5tEqB9dV0A1p/Xwv6vHrDVm0pPk/7pp0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732293317; c=relaxed/simple; bh=+4lvrIye4ET+VE6WPe9UM6/x4v+7EymafhvvpaW3ys0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=orJaJqDuu1pDiPAqnHn8xFOYLzjyouMxZvekWDRgwt7Lyt6kW9U6lxFMg4URMpnNE9y78hQtnqsoAJwcFFxNLjVfeNs22GKS5zzLF9B8hTPOpvwdBOQdV1tvLbDD5v8ICDljGJi9hNo4mpWy0e+ysxoHRUoFSP2DutcuCejJ20w= 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=c8g+aKhk; arc=none smtp.client-ip=217.70.183.196 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="c8g+aKhk" Received: by mail.gandi.net (Postfix) with ESMTPSA id 28AC2E0004; Fri, 22 Nov 2024 16:35:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732293313; 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=Saatg+Kt9CY/Nw+l2VbJ9P3jgV0lrIBz0cECqUwIKPI=; b=c8g+aKhkyXEC6ERSbP0XXyyro+tCh6N1w3pPFohWKfw449yMjmLzg9Mu84djCxcmtvZC/q DZMBBW5FwJn740keY4VrkKizp0rfIrsI/awoGGDz3T4c55eJ67A4FIH+Sf6JnbWUFt7KCp pM8jx7bO0JazqFMnSj8iH/0EFCqtzadBISgRM/SIL9Dlolwkcie3R/26a7pvOOdTnbhtk1 6VpAPJ0UIGWALAqqMuy7SwTIqBZsktd2RJmE0Ri71+gj1gndg2UjuPuoRSNJHtwof1y30U +jD6+fubsE4e2t/86uEc0KencsXOPALLT+zfOH+LVwx+MZwetgyNLtNLQka06A== From: Louis Chauvet Date: Fri, 22 Nov 2024 17:35:09 +0100 Subject: [PATCH v2 1/4] 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: <20241122-b4-vkms-allocated-v2-1-ff7bddbf0bfb@bootlin.com> References: <20241122-b4-vkms-allocated-v2-0-ff7bddbf0bfb@bootlin.com> In-Reply-To: <20241122-b4-vkms-allocated-v2-0-ff7bddbf0bfb@bootlin.com> To: Rodrigo Siqueira , =?utf-8?q?Ma=C3=ADra_Canal?= , 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=2003; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=+4lvrIye4ET+VE6WPe9UM6/x4v+7EymafhvvpaW3ys0=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQLK+eS8mKIwSrSe6Iv+WAcyJyRpFnBNb4AfD0 1go24UKFPOJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0CyvgAKCRAgrS7GWxAs 4vsqD/47S8zfsrCwhqoJo9+iFBIH2i52S9krESloQKmJXWjtVAyyHsSSketYig+UgCqio7wSrff qS0v53LerlgKMsBEBGZ+3aqbN322yFwDKj3YlYxurlId5XohyNZM17l6Dm+DnhUFAvVqKe+Gidn 7vuF0fYUeLFXY5JdlZQSI+YP8JH17rF+RO+75tuJSgtcI7kNGb3kKpmADTpod8DK2IoTkKwW133 YuFNygyq/DxoQnLL2ZtNFab2/8XgiEkFRKDjF01uwoQAsEPb54o5LOyINzzfoUDjI2jVNC0K46o M3L9q7/nutsax/sRj6ZbxSABdD8rEU6ltnvIwfvHUpuuaJiaMKwxjAa7kzmKMcLZ1PIQpBOvsdq /OlbE7LB2aIk1NAa5CKIw592LnYIChdoHYrO0O2Ua4JipTNmTq9Zv5fj4XzDKHBfO5csFNoytzO FFhlY6C0CIqZuWqA4ee9iphH720pAOosk1eMSjunUzlWZA5HvPGGviALrfoZofHBx6b1T7/B04w bQhSHJnDDEbwfxaxGhPT3qrfi6UZoZ+7n7WOxKpBQHtTUlqxzGaWLzmV6v+6504W/NfAC9FThF6 uAM8/Q9uhjMglM/rsiYRbTshcMctVcBE4R8Nrh+zSdPdEIlOI5kvmxmbPKViKKFDliRzUmnePgr INSFslcD4OBdECQ== 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 Reviewed-by: Maxime Ripard --- 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 00541eff3d1b0aa4b374fb94c8fe34932df31509..820e7899cb049b45d8bdbe5a0dc= 7be08eee6db69 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -177,7 +177,6 @@ struct vkms_crtc_state { struct vkms_output { struct drm_crtc crtc; struct drm_encoder encoder; - struct drm_connector connector; struct drm_writeback_connector wb_connector; struct hrtimer vblank_hrtimer; ktime_t period_ns; diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms= _output.c index ab9affa75b66ce9f00fe025052439405206144ec..ec3545730ef79af0db51d8ec605= b9cdfff52c2a3 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 =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; @@ -71,6 +71,12 @@ 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"); + return -ENOMEM; + } + ret =3D drmm_connector_init(dev, connector, &vkms_connector_funcs, DRM_MODE_CONNECTOR_VIRTUAL, NULL); if (ret) { --=20 2.47.0 From nobody Sat Nov 30 02:41:51 2024 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 4108B6F30C for ; Fri, 22 Nov 2024 16:35:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732293318; cv=none; b=rev0WEomHJFg2iN9ECM1luX0DCWBreFHB6FAPSVZH1davAfdCjDu4ctIHlUeK4VSsCtnT40w5HE88DdonP4A6OYTbiF9OVnnhzRN/H5YhxUsJ6ohTyo2EnVm8oh+ZAnhr0F4zUw/V5kYGOQNSRKxaDcFDllVbxPmyVNoN3JJB6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732293318; c=relaxed/simple; bh=9J4smgwkzCns2aVvmtM/IAB1GUDY/AKK9P5D+WB4J98=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AxPObBdIcVfsCbSXo9vSw8MHG5UwsLIunP5w92p8cyX/8d934S2ybyxE75xDvObMu9TSirwho0o9XickuJpuxrOWOYDXC9aEY5Xep/G0KIS8JtGFzlorL98PfD77OfIO1aS4LkxOPN+a781Dui41I1mbWY+Y0iy85fNqoHmHz5A= 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=dxEApUST; arc=none smtp.client-ip=217.70.183.196 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="dxEApUST" Received: by mail.gandi.net (Postfix) with ESMTPSA id E307BE0008; Fri, 22 Nov 2024 16:35:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732293314; 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=dBxEQgaBIGduFnCagyGhbgYlms+rtIc0bzXxTFUBT8g=; b=dxEApUSTjB+WOgrSF89z0S1QVG21kBT1OPnz2CIAzDBx1TpsLAIZgWF5uP5L/TOadsVdAJ tmG80Yyst7L+9zcfSfCCCeGA111S0qFbGikh+y0ljIO1jSmav+G2DalWDZBmEEbFiA+c6r uutAuHkD86xP9Dl51DXJOp6Ivnl629wLSeN3wiL38ijespKWitC6uxe6Q8Rs2ZCYVbffdB MomSiS/3NoNrYMeM7slEjQsZ0t0a6MV54PlItTQhVvYEpV0FPXmUM3YcLiQqPOUmGrH1Jk kDS/c0GkFvSDgzVVP1GpXsnATebvmjhz1bCqPlnQ1ieMrL5U3apyvdo+BKGbxg== From: Louis Chauvet Date: Fri, 22 Nov 2024 17:35:10 +0100 Subject: [PATCH v2 2/4] 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: <20241122-b4-vkms-allocated-v2-2-ff7bddbf0bfb@bootlin.com> References: <20241122-b4-vkms-allocated-v2-0-ff7bddbf0bfb@bootlin.com> In-Reply-To: <20241122-b4-vkms-allocated-v2-0-ff7bddbf0bfb@bootlin.com> To: Rodrigo Siqueira , =?utf-8?q?Ma=C3=ADra_Canal?= , 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=1973; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=9J4smgwkzCns2aVvmtM/IAB1GUDY/AKK9P5D+WB4J98=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQLK/4gzREg6PN2hfytrSWLe5ckYkY3N5WNxuL /msJP5zWnuJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0CyvwAKCRAgrS7GWxAs 4nHKD/4kxgJY26+312IrtktoPZTqilViLS0nxT2ymk9SgLB4MepEW8Tx8pnG8nuOpPk3zxftpG4 1vcDdeyI2hMUD2X46ZIkL8fkHvS/oPEeCBA0i6Vt66ktCZbuFFQkL+ATZN1X2NbBVrtxjuCMlj8 95nUkNP+AKutg/8nWLuigYisze+L4n8mR43dLIibGg4JEfzoWSIwmP1mk1Mg4YGvgeClY0jqdDG SlaK49H38B2Y0qEZgrWu2yMY5LN7URH/Sclbwj4ba5UURzyGKHEiSWe8ZWRd+IGJcsbaLJ69w61 aUeYZfw2P9Ge/FO9uCCEvvWHDcD90pTjFnNzpWKfpqlKIrg41hRoIMM/aWWvj9OK/TM3XuW1L+q NFZP0OISu5LCJjxFjdYWHsQKDF1af+qu4yWCdn20uzNsOrUiAu4Z2QxJrRmc5Mz8bD89+5zgFlq haMV5W3XZNCVlv2zFw6B7MSdfuTT6eKAzdExtGSwxFuRXXmvxN/nX0O8PblHhNP1f4kuf41Fing aJHYCf2D28+3Sg0dNj12kmKVd+Eqnav3nUgmB+DJb5DLqiebxcc0dIpxv/6kh2ZKYFImYNHipx3 R2CyIyf2I8XQ7hThOmc+fLhIlEWwfo7Hmw6FBHmZt3FFkTCm2cbf+4xzZhDD6CBjmbjN0PQ7ClA qYGUq+IIflfiieg== 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 Reviewed-by: Maxime Ripard --- 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_dr= v.h index 820e7899cb049b45d8bdbe5a0dc7be08eee6db69..19fd99b8e506c4454d7878b67f6= 92a0441c22665 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -176,7 +176,6 @@ struct vkms_crtc_state { */ struct vkms_output { struct drm_crtc crtc; - struct drm_encoder encoder; struct drm_writeback_connector wb_connector; struct hrtimer vblank_hrtimer; ktime_t period_ns; diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms= _output.c index ec3545730ef79af0db51d8ec605b9cdfff52c2a3..102b6ad466cb4f7c6704f30cea6= 69e5d7f81540a 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 =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; @@ -86,6 +86,11 @@ 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"); + return -ENOMEM; + } ret =3D drmm_encoder_init(dev, encoder, NULL, DRM_MODE_ENCODER_VIRTUAL, NULL); if (ret) { --=20 2.47.0 From nobody Sat Nov 30 02:41:51 2024 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 CEE401DED6A for ; Fri, 22 Nov 2024 16:35:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732293319; cv=none; b=dGooik1F0URiXrLIdSf0f8LpPvcsDRl9yAA6WuIbzQUB56s8pR1t7y0WMD2+N/MtlLdSfzJdiOThCvpw3aq0wd9EbpBHV2dAsLdU4UTqkEhYudHVtQGTzllQpivFUNdkZm8TVm3xAhb7xX+BW/syBi44p/uBhN+L8/TH+l2q92M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732293319; c=relaxed/simple; bh=F+HJyRf6lb1k3bzd/+c5woMOLjAKNPQSEAbQosOxVSA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rdDOjpGhkBpLKLeAcfTdsgvOe5r7rn4xO+QmxNfOsOoaLsd8BjMc+YHhLFMYlJudR6lAfEHh0Z3lNsRuwoMldzKJXPHdb06vTpxBPhUaItZGCV7ydS51bOCEwYZJVVeJypHF2bTUv9V9rFUoMS7/Z8NfXrPn0I0Epn0/ps/abTs= 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=aO9i4fhZ; arc=none smtp.client-ip=217.70.183.196 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="aO9i4fhZ" Received: by mail.gandi.net (Postfix) with ESMTPSA id BDA61E0002; Fri, 22 Nov 2024 16:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732293315; 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=kwzI7LH/JVNC8tyOHUOkPCCdhISBVOIS1JXA3feRKeg=; b=aO9i4fhZvFSFeAmpo1xhk9+YZLUgheis9/e2JaW6sOyRChm4tnyLaXADAmeLaYo4B2izRX Vj5QNh2tRlzoGLHEw9lxr/09iUbrih3XS5UrkrrWkxTl1nujQkcb1lYE3dwYb0rMk3Y/jO OtOyE/eKJztUHaF93WnkvvGFo/NfM02Jnwv0UIPbFmshEOkMt1h2dT/xOI2+iCv5LM0RyW QF2UTmIlweIWC6rSohPmqSyF1aMhQ6DsfqD1/Lj/7bZCYCD95JO8dr9y7LicF+1vyhJJ9B xaDXel5hLhNo4u26qWzYE+zoJozYpU9c1uBfk8INVM7i4uRivhOEyfzcpbTHQA== From: Louis Chauvet Date: Fri, 22 Nov 2024 17:35:11 +0100 Subject: [PATCH v2 3/4] 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: <20241122-b4-vkms-allocated-v2-3-ff7bddbf0bfb@bootlin.com> References: <20241122-b4-vkms-allocated-v2-0-ff7bddbf0bfb@bootlin.com> In-Reply-To: <20241122-b4-vkms-allocated-v2-0-ff7bddbf0bfb@bootlin.com> To: Rodrigo Siqueira , =?utf-8?q?Ma=C3=ADra_Canal?= , 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=9214; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=F+HJyRf6lb1k3bzd/+c5woMOLjAKNPQSEAbQosOxVSA=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQLK/hV5x9PKstbzmloKqZfQ0vSz+bAV6QWMDW xE/G/dkI7SJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0CyvwAKCRAgrS7GWxAs 4mgVD/oCMQX4HWpUrzwUSuCNrLpr/4Rlt9nK03+0rWL6tjJ8BJkNOZ7OcTjTirksgFV/X6nVPDS cP1A/OWqiGFh1T00smiMXboJ/ROpEvQrCnZBjmcGRWfDVayiDrwCvADtBgglJMOx59qf2P0nAK9 cijvWY7PmR0W+ork/cQK8V4ei1DKVTTZslPUEEKJ8XRHnffuMW2D7LNwio5EYNx7VH7817XJ1kz KC8Tim/kepxG/ljsvgBXYRoPrSqfDDNvvHI9b7H3NGibcp3WHBb5DLpOB67NmRZx4wiNnZUTfik skAGE6o0NXBsrggM3GkxxU+NTN/0PhEc7ttRZObuo8McQ56tav4eRC2zZhKxjwR6UBaW3rzUiRL oP7Yhmm5ks1HSqgIMDe/jPtmuRZKsquL3BCQpW/Nwl7V/wVUkBCsReW9oVCdro+WsV5GnRHvg70 YnQg/wAs4JQR/td/wi8llEijZEebsB1AL+987OAFP4DIfuuyJKbWGo0+GtHLHgwSjex3w80oFkE n3U7BT3ZfJ6xF1G8yfl2QcnBfY6E5twI83rVSft9P9P9woUPdDYe8ckbNHUgU7dbNoPUahR+yYE nOvKtQHGL/KBpfuN9vmQqsudUxxNgqDhkPCJ0cZMie8Qwf1O+wEHAGwNubwXcAEvwdBQxHxgrMD TPrW3K944PH1F9A== 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 | 32 +++++++++++++++++--------------- drivers/gpu/drm/vkms/vkms_drv.h | 9 +++++---- drivers/gpu/drm/vkms/vkms_output.c | 26 +++++++++++++++----------- drivers/gpu/drm/vkms/vkms_writeback.c | 17 +++++++++-------- 4 files changed, 46 insertions(+), 38 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_c= rtc.c index ace8d293f7da611110c1e117b6cf2f3c9e9b4381..d014dec117e7d4ec7e9e38037a4= a4cb4bc6be4ca 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 *cr= tc, int *max_error, ktime_t *vblank_time, bool in_vblank_irq) { - 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)) { @@ -279,25 +277,29 @@ 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 ret =3D 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); } =20 drm_crtc_enable_color_mgmt(crtc, 0, false, VKMS_LUT_SIZE); @@ -307,12 +309,12 @@ int vkms_crtc_init(struct drm_device *dev, struct drm= _crtc *crtc, =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 19fd99b8e506c4454d7878b67f692a0441c22665..fbe7de67fb9c6a6a6964d71b452= b9a3ce573e0f8 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -214,7 +214,6 @@ struct vkms_config { struct vkms_device { struct drm_device drm; struct platform_device *platform; - struct vkms_output output; const struct vkms_config *config; }; =20 @@ -241,8 +240,9 @@ struct vkms_device { * @primary: primary plane to attach to the CRTC * @cursor: plane to attach to the CRTC */ -int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, - struct drm_plane *primary, struct drm_plane *cursor); +struct vkms_output *vkms_crtc_init(struct drm_device *dev, + struct drm_plane *primary, + struct drm_plane *cursor); =20 /** * vkms_output_init() - Initialize all sub-components needed for a VKMS de= vice. @@ -273,6 +273,7 @@ void vkms_set_composer(struct vkms_output *out, bool en= abled); 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 102b6ad466cb4f7c6704f30cea669e5d7f81540a..6a5cf6e7714938f23b4276a9699= 1d05431bcd76e 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_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; @@ -56,9 +55,12 @@ 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++) { @@ -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 =3D drm_crtc_mask(crtc); + overlay->base.possible_crtcs =3D drm_crtc_mask(&output->crtc); } } =20 @@ -97,23 +99,25 @@ int vkms_output_init(struct vkms_device *vkmsdev) DRM_ERROR("Failed to init encoder\n"); 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; - - return ret; } diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/v= kms_writeback.c index f12417b2d24803a33e4ff56108cc89704a500faf..c9b6e161fa8698491f20082dfe0= b713f27bcb918 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; @@ -162,9 +162,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.47.0 From nobody Sat Nov 30 02:41:51 2024 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 CEDE71DE8B0 for ; Fri, 22 Nov 2024 16:35:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732293320; cv=none; b=Vva3sqcp7LrOSxlNherJD9HPueNQStXrF8Nauvqtnmj5MjSHEHcOMktVUaXaB4sPiK2PTNXwIpix2QwZIsWxYBKWwVu+uijD8XWYK25BwFO1vA6HKXJQGMogDsmbkvF/4wZuAP5Kx54jD9r01hMw160dF+eUUPpqK1hXqrsGLyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732293320; c=relaxed/simple; bh=8UYTicrTAL2RnLk9LBeJSZdd/FvLXrRjwST+c2Y5hJY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gkq6euvvKS7jvhjQw3kzOiun7Hfw2C6wfsIhqAHXu8XWZs0uBNcT3tWzdZ9vr2460ePX+cgL8IYLa4l8Hy9dHyefydTAR/MuazUVrH3qNyq+qJiEq1yaCwXUjv4tkfN+JuhXwjMY+Xz9+4Qebez5azjK2D1qcs4NDPIzzPvz8pA= 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=nQCLSNPa; arc=none smtp.client-ip=217.70.183.196 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="nQCLSNPa" Received: by mail.gandi.net (Postfix) with ESMTPSA id 87B1FE0005; Fri, 22 Nov 2024 16:35:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732293316; 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=j4Cmhqd3ZoatnNIjenWaqOm7SDejDJEFrM1u030RS1w=; b=nQCLSNPaULea6GhvALkRlNaO9MyyyAzH66zkYTRB9OmlFNbrJzgGoA2ccAvZ3dyYCLCnUq ziv3PT6WYvF906tCEMMT/b/xsHdeKQYoGsp+fAForwFnolHtySQ1MislDy/TYwDeyNKd7A hHZpPO1Fwd0EKqcTgMoD6fcq8aTdOSYdBK454Hm9T99Ch+effUzTxlVCXe2Hzc8hKdGx8e ND3K+pFrs1Fgou/ryipWdNb5PRf/DFnTBjzfNQNb4Wc1QBTvksJ93b6Kb63u/th1kG59kP v34Qznp5v8PekSreKsqOhSoCg9+yE5H7b1bFuKuZG/IRS2pT3s92wLfy3n+dDg== From: Louis Chauvet Date: Fri, 22 Nov 2024 17:35:12 +0100 Subject: [PATCH v2 4/4] drm/vkms: Rename vkms_output to vkms_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: <20241122-b4-vkms-allocated-v2-4-ff7bddbf0bfb@bootlin.com> References: <20241122-b4-vkms-allocated-v2-0-ff7bddbf0bfb@bootlin.com> In-Reply-To: <20241122-b4-vkms-allocated-v2-0-ff7bddbf0bfb@bootlin.com> To: Rodrigo Siqueira , =?utf-8?q?Ma=C3=ADra_Canal?= , 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=18648; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=8UYTicrTAL2RnLk9LBeJSZdd/FvLXrRjwST+c2Y5hJY=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQLK/pg4OPepF9gSSaMPwNh20UMrFDGwtYGWV7 4QJTRGBy2aJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0CyvwAKCRAgrS7GWxAs 4jACD/9SHKUv0c7lJcdECnkp6Fc/unDreCYYFCb3zO8L9I/1Y82ZXWrs0drmEf73LppFzV3qTqX kZ3T2pwj821rIaLZ2vYwdwvOZTUQciUaCMNeMC5rr1/H7+2n071MtmnBZiQT2bcd9byC0T7Udpq nl8rBp2qQwxrbnYAC1+na/bsnGI+xK78D9PQ9zLqfc0ZB3NFaqt6jNuwLSnN3EXqgOqPGfsv1Xz /cNH3/IGCQJAxz/Aq7GSswpL1t1scoutk/tV08JWXd5Ni/m6/nWRV1giWQEYqlfrxtofupOSDrq J3ztSZu5RHTNVKrj3ndloDYacGfeCjgO4Qyt8fOIU/X0HKYWTUs/mIzkvIgT3XHaQf4JJy7SsEy 8ICr7t2Pkq8tSainir16rEmoPyX28Fj+HuckNAFhnh3X3I8C8EuIRLyKwCI9CVyB+lVWOqQPyvA SwQKeC0hCuns/To0j4yENvjISzpubOSlccQE9Tur9GpHnhA/SpypcEDTzB7rn6gvcCaDVSpfkFQ dkjNn7uczF7vBoJVtqnNlWRaDwQF7/cUoMJrC8W6c8k2K77NpKWhIRRwCQ2dtwEU7a6xiMT9uNx SLvnc1pNfBb78IJZeqLbp9Qham0X/720TL8slDz9BdRs4Ql9vxHd+E+LbE0jIXiuMnQvV7+B0dC TBZ5Wg67coRrYgA== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com The current vkms_output structure only contains crtc-related members. To avoid confusion, rename the structure to vkms_crtc and all its usage. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_composer.c | 30 ++++++------ drivers/gpu/drm/vkms/vkms_crtc.c | 90 ++++++++++++++++++-------------= ---- drivers/gpu/drm/vkms/vkms_drv.h | 18 +++---- drivers/gpu/drm/vkms/vkms_output.c | 16 +++---- drivers/gpu/drm/vkms/vkms_writeback.c | 24 +++++----- 5 files changed, 90 insertions(+), 88 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vk= ms_composer.c index b20ac170572622b34ba76b1a9c5dd626ca5da6fa..eaecb1f5d2319dc9c81d25df1d8= cf0a8cbfb977c 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -495,13 +495,13 @@ void vkms_composer_worker(struct work_struct *work) composer_work); struct drm_crtc *crtc =3D crtc_state->base.crtc; struct vkms_writeback_job *active_wb =3D crtc_state->active_writeback; - struct vkms_output *out =3D drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc =3D drm_crtc_to_vkms_crtc(crtc); bool crc_pending, wb_pending; u64 frame_start, frame_end; u32 crc32 =3D 0; int ret; =20 - spin_lock_irq(&out->composer_lock); + spin_lock_irq(&vkms_crtc->composer_lock); frame_start =3D crtc_state->frame_start; frame_end =3D crtc_state->frame_end; crc_pending =3D crtc_state->crc_pending; @@ -525,7 +525,7 @@ void vkms_composer_worker(struct work_struct *work) crtc_state->gamma_lut.base =3D NULL; } =20 - spin_unlock_irq(&out->composer_lock); + spin_unlock_irq(&vkms_crtc->composer_lock); =20 /* * We raced with the vblank hrtimer and previous work already computed @@ -543,10 +543,10 @@ void vkms_composer_worker(struct work_struct *work) return; =20 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 =3D false; - spin_unlock_irq(&out->composer_lock); + spin_unlock_irq(&vkms_crtc->composer_lock); } =20 /* @@ -596,31 +596,31 @@ int vkms_verify_crc_source(struct drm_crtc *crtc, con= st char *src_name, return 0; } =20 -void vkms_set_composer(struct vkms_output *out, bool enabled) +void vkms_set_composer(struct vkms_crtc *vkms_crtc, bool enabled) { bool old_enabled; =20 if (enabled) - drm_crtc_vblank_get(&out->crtc); + drm_crtc_vblank_get(&vkms_crtc->base); =20 - spin_lock_irq(&out->lock); - old_enabled =3D out->composer_enabled; - out->composer_enabled =3D enabled; - spin_unlock_irq(&out->lock); + spin_lock_irq(&vkms_crtc->lock); + old_enabled =3D vkms_crtc->composer_enabled; + vkms_crtc->composer_enabled =3D enabled; + spin_unlock_irq(&vkms_crtc->lock); =20 if (old_enabled) - drm_crtc_vblank_put(&out->crtc); + drm_crtc_vblank_put(&vkms_crtc->base); } =20 int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name) { - struct vkms_output *out =3D drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc =3D drm_crtc_to_vkms_crtc(crtc); bool enabled =3D false; int ret =3D 0; =20 ret =3D vkms_crc_parse_source(src_name, &enabled); =20 - vkms_set_composer(out, enabled); + vkms_set_composer(vkms_crtc, enabled); =20 return ret; } diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_c= rtc.c index d014dec117e7d4ec7e9e38037a4a4cb4bc6be4ca..7851bcf335b7aa9a95848b3af89= 00812115b2189 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -12,35 +12,35 @@ =20 static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer) { - struct vkms_output *output =3D container_of(timer, struct vkms_output, + struct vkms_crtc *vkms_crtc =3D container_of(timer, struct vkms_crtc, vblank_hrtimer); - struct drm_crtc *crtc =3D &output->crtc; + struct drm_crtc *crtc =3D &vkms_crtc->base; struct vkms_crtc_state *state; u64 ret_overrun; bool ret, fence_cookie; =20 fence_cookie =3D dma_fence_begin_signalling(); =20 - ret_overrun =3D hrtimer_forward_now(&output->vblank_hrtimer, - output->period_ns); + ret_overrun =3D hrtimer_forward_now(&vkms_crtc->vblank_hrtimer, + vkms_crtc->period_ns); if (ret_overrun !=3D 1) pr_warn("%s: vblank timer overrun\n", __func__); =20 - spin_lock(&output->lock); + spin_lock(&vkms_crtc->lock); ret =3D drm_crtc_handle_vblank(crtc); if (!ret) DRM_ERROR("vkms failure on handling vblank"); =20 - state =3D output->composer_state; - spin_unlock(&output->lock); + state =3D vkms_crtc->composer_state; + spin_unlock(&vkms_crtc->lock); =20 - if (state && output->composer_enabled) { + if (state && vkms_crtc->composer_enabled) { u64 frame =3D drm_crtc_accurate_vblank_count(crtc); =20 /* 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 =3D frame; else @@ -48,9 +48,9 @@ static enum hrtimer_restart vkms_vblank_simulate(struct h= rtimer *timer) state->frame_start, frame); state->frame_end =3D frame; state->crc_pending =3D true; - spin_unlock(&output->composer_lock); + spin_unlock(&vkms_crtc->composer_lock); =20 - ret =3D queue_work(output->composer_workq, &state->composer_work); + ret =3D queue_work(vkms_crtc->composer_workq, &state->composer_work); if (!ret) DRM_DEBUG_DRIVER("Composer worker already queued\n"); } @@ -63,28 +63,30 @@ static enum hrtimer_restart vkms_vblank_simulate(struct= hrtimer *timer) static int vkms_enable_vblank(struct drm_crtc *crtc) { struct drm_vblank_crtc *vblank =3D drm_crtc_vblank_crtc(crtc); - struct vkms_output *out =3D drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc =3D drm_crtc_to_vkms_crtc(crtc); =20 - hrtimer_init(&out->vblank_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - out->vblank_hrtimer.function =3D &vkms_vblank_simulate; - out->period_ns =3D ktime_set(0, vblank->framedur_ns); - hrtimer_start(&out->vblank_hrtimer, out->period_ns, HRTIMER_MODE_REL); + hrtimer_init(&vkms_crtc->vblank_hrtimer, CLOCK_MONOTONIC, + HRTIMER_MODE_REL); + vkms_crtc->vblank_hrtimer.function =3D &vkms_vblank_simulate; + vkms_crtc->period_ns =3D ktime_set(0, vblank->framedur_ns); + hrtimer_start(&vkms_crtc->vblank_hrtimer, vkms_crtc->period_ns, + HRTIMER_MODE_REL); =20 return 0; } =20 static void vkms_disable_vblank(struct drm_crtc *crtc) { - struct vkms_output *out =3D drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc =3D drm_crtc_to_vkms_crtc(crtc); =20 - hrtimer_cancel(&out->vblank_hrtimer); + hrtimer_cancel(&vkms_crtc->vblank_hrtimer); } =20 static bool vkms_get_vblank_timestamp(struct drm_crtc *crtc, int *max_error, ktime_t *vblank_time, bool in_vblank_irq) { - struct vkms_output *output =3D drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc =3D drm_crtc_to_vkms_crtc(crtc); struct drm_vblank_crtc *vblank =3D drm_crtc_vblank_crtc(crtc); =20 if (!READ_ONCE(vblank->enabled)) { @@ -92,7 +94,7 @@ static bool vkms_get_vblank_timestamp(struct drm_crtc *cr= tc, return true; } =20 - *vblank_time =3D READ_ONCE(output->vblank_hrtimer.node.expires); + *vblank_time =3D READ_ONCE(vkms_crtc->vblank_hrtimer.node.expires); =20 if (WARN_ON(*vblank_time =3D=3D vblank->time)) return true; @@ -104,7 +106,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 -=3D output->period_ns; + *vblank_time -=3D vkms_crtc->period_ns; =20 return true; } @@ -229,19 +231,19 @@ static void vkms_crtc_atomic_begin(struct drm_crtc *c= rtc, struct drm_atomic_state *state) __acquires(&vkms_output->lock) { - struct vkms_output *vkms_output =3D drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc =3D drm_crtc_to_vkms_crtc(crtc); =20 /* 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); } =20 static void vkms_crtc_atomic_flush(struct drm_crtc *crtc, struct drm_atomic_state *state) __releases(&vkms_output->lock) { - struct vkms_output *vkms_output =3D drm_crtc_to_vkms_output(crtc); + struct vkms_crtc *vkms_crtc =3D drm_crtc_to_vkms_crtc(crtc); =20 if (crtc->state->event) { spin_lock(&crtc->dev->event_lock); @@ -256,9 +258,9 @@ static void vkms_crtc_atomic_flush(struct drm_crtc *crt= c, crtc->state->event =3D NULL; } =20 - vkms_output->composer_state =3D to_vkms_crtc_state(crtc->state); + vkms_crtc->composer_state =3D to_vkms_crtc_state(crtc->state); =20 - spin_unlock_irq(&vkms_output->lock); + spin_unlock_irq(&vkms_crtc->lock); } =20 static const struct drm_crtc_helper_funcs vkms_crtc_helper_funcs =3D { @@ -270,29 +272,29 @@ static const struct drm_crtc_helper_funcs vkms_crtc_h= elper_funcs =3D { }; =20 static void vkms_crtc_destroy_workqueue(struct drm_device *dev, - void *raw_vkms_out) + void *raw_vkms_crtc) { - struct vkms_output *vkms_out =3D raw_vkms_out; + struct vkms_crtc *vkms_crtc =3D raw_vkms_crtc; =20 - destroy_workqueue(vkms_out->composer_workq); + destroy_workqueue(vkms_crtc->composer_workq); } =20 -struct vkms_output *vkms_crtc_init(struct drm_device *dev, struct drm_plan= e *primary, - struct drm_plane *cursor) +struct vkms_crtc *vkms_crtc_init(struct drm_device *dev, struct drm_plane = *primary, + struct drm_plane *cursor) { - struct vkms_output *vkms_out; + struct vkms_crtc *vkms_crtc; struct drm_crtc *crtc; int ret; =20 - vkms_out =3D drmm_crtc_alloc_with_planes(dev, struct vkms_output, crtc, - primary, cursor, - &vkms_crtc_funcs, NULL); - if (IS_ERR(vkms_out)) { + vkms_crtc =3D drmm_crtc_alloc_with_planes(dev, struct vkms_crtc, base, + primary, cursor, + &vkms_crtc_funcs, NULL); + if (IS_ERR(vkms_crtc)) { DRM_DEV_ERROR(dev->dev, "Failed to init CRTC\n"); - return vkms_out; + return vkms_crtc; } =20 - crtc =3D &vkms_out->crtc; + crtc =3D &vkms_crtc->base; =20 drm_crtc_helper_add(crtc, &vkms_crtc_helper_funcs); =20 @@ -304,17 +306,17 @@ struct vkms_output *vkms_crtc_init(struct drm_device = *dev, struct drm_plane *pri =20 drm_crtc_enable_color_mgmt(crtc, 0, false, VKMS_LUT_SIZE); =20 - 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); =20 - vkms_out->composer_workq =3D alloc_ordered_workqueue("vkms_composer", 0); - if (!vkms_out->composer_workq) + vkms_crtc->composer_workq =3D alloc_ordered_workqueue("vkms_composer", 0); + if (!vkms_crtc->composer_workq) return ERR_PTR(-ENOMEM); =20 ret =3D drmm_add_action_or_reset(dev, vkms_crtc_destroy_workqueue, - vkms_out); + vkms_crtc); if (ret) return ERR_PTR(ret); =20 - return vkms_out; + return vkms_crtc; } diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_dr= v.h index fbe7de67fb9c6a6a6964d71b452b9a3ce573e0f8..cc956ab8f539c8ac6eed3c96845= 091883f4c1e98 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -174,8 +174,8 @@ struct vkms_crtc_state { * @composer_state: Protected by @lock, current state of this VKMS output * @composer_lock: Lock used internally to protect @composer_state members */ -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; @@ -221,8 +221,8 @@ struct vkms_device { * The following helpers are used to convert a member of a struct into its= parent. */ =20 -#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) =20 #define drm_device_to_vkms_device(target) \ container_of(target, struct vkms_device, drm) @@ -240,9 +240,9 @@ struct vkms_device { * @primary: primary plane to attach to the CRTC * @cursor: plane to attach to the CRTC */ -struct vkms_output *vkms_crtc_init(struct drm_device *dev, - struct drm_plane *primary, - struct drm_plane *cursor); +struct vkms_crtc *vkms_crtc_init(struct drm_device *dev, + struct drm_plane *primary, + struct drm_plane *cursor); =20 /** * vkms_output_init() - Initialize all sub-components needed for a VKMS de= vice. @@ -269,11 +269,11 @@ int vkms_verify_crc_source(struct drm_crtc *crtc, con= st char *source_name, =20 /* 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_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, - struct vkms_output *vkms_out); + struct vkms_crtc *vkms_crtc); =20 #endif /* _VKMS_DRV_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms= _output.c index 6a5cf6e7714938f23b4276a96991d05431bcd76e..1c6d41856e317eb7b9b79f56fdf= 7473d0a339250 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 drm_device *dev =3D &vkmsdev->drm; struct drm_connector *connector; struct drm_encoder *encoder; - struct vkms_output *output; + struct vkms_crtc *vkms_crtc; struct vkms_plane *primary, *overlay, *cursor =3D NULL; int ret; int writeback; @@ -55,11 +55,11 @@ int vkms_output_init(struct vkms_device *vkmsdev) return PTR_ERR(cursor); } =20 - output =3D vkms_crtc_init(dev, &primary->base, - cursor ? &cursor->base : NULL); - if (IS_ERR(output)) { + vkms_crtc =3D vkms_crtc_init(dev, &primary->base, + cursor ? &cursor->base : NULL); + if (IS_ERR(vkms_crtc)) { DRM_ERROR("Failed to allocate CRTC\n"); - return PTR_ERR(output); + return PTR_ERR(vkms_crtc); } =20 if (vkmsdev->config->overlay) { @@ -69,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 =3D drm_crtc_mask(&output->crtc); + overlay->base.possible_crtcs =3D drm_crtc_mask(&vkms_crtc->base); } } =20 @@ -99,7 +99,7 @@ int vkms_output_init(struct vkms_device *vkmsdev) DRM_ERROR("Failed to init encoder\n"); return ret; } - encoder->possible_crtcs =3D drm_crtc_mask(&output->crtc); + encoder->possible_crtcs =3D drm_crtc_mask(&vkms_crtc->base); =20 /* Attach the encoder and the connector */ ret =3D drm_connector_attach_encoder(connector, encoder); @@ -110,7 +110,7 @@ int vkms_output_init(struct vkms_device *vkmsdev) =20 /* Initialize the writeback component */ if (vkmsdev->config->writeback) { - writeback =3D vkms_enable_writeback_connector(vkmsdev, output); + writeback =3D vkms_enable_writeback_connector(vkmsdev, vkms_crtc); if (writeback) { DRM_ERROR("Failed to init writeback connector\n"); return ret; diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/v= kms_writeback.c index c9b6e161fa8698491f20082dfe0b713f27bcb918..adb2081326648cb2ca55757d14b= 9b4e2bcbd3eb6 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -105,9 +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_output *vkms_output =3D container_of(connector, - struct vkms_output, - wb_connector); + struct vkms_crtc *vkms_crtc =3D container_of(connector, + struct vkms_crtc, + wb_connector); =20 if (!job->fb) return; @@ -116,7 +116,7 @@ static void vkms_wb_cleanup_job(struct drm_writeback_co= nnector *connector, =20 drm_framebuffer_put(vkmsjob->wb_frame_info.fb); =20 - vkms_set_composer(vkms_output, false); + vkms_set_composer(vkms_crtc, false); kfree(vkmsjob); } =20 @@ -125,10 +125,10 @@ static void vkms_wb_atomic_commit(struct drm_connecto= r *conn, { struct drm_connector_state *connector_state =3D drm_atomic_get_new_connec= tor_state(state, conn); - 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 vkms_crtc *vkms_crtc =3D drm_crtc_to_vkms_crtc(connector_state->cr= tc); + struct drm_writeback_connector *wb_conn =3D &vkms_crtc->wb_connector; struct drm_connector_state *conn_state =3D wb_conn->base.state; - struct vkms_crtc_state *crtc_state =3D output->composer_state; + struct vkms_crtc_state *crtc_state =3D vkms_crtc->composer_state; struct drm_framebuffer *fb =3D connector_state->writeback_job->fb; u16 crtc_height =3D crtc_state->base.mode.vdisplay; u16 crtc_width =3D crtc_state->base.mode.hdisplay; @@ -139,15 +139,15 @@ static void vkms_wb_atomic_commit(struct drm_connecto= r *conn, if (!conn_state) return; =20 - vkms_set_composer(output, true); + vkms_set_composer(vkms_crtc, true); =20 active_wb =3D conn_state->writeback_job->priv; wb_frame_info =3D &active_wb->wb_frame_info; =20 - spin_lock_irq(&output->composer_lock); + spin_lock_irq(&vkms_crtc->composer_lock); crtc_state->active_writeback =3D active_wb; crtc_state->wb_pending =3D true; - spin_unlock_irq(&output->composer_lock); + spin_unlock_irq(&vkms_crtc->composer_lock); drm_writeback_queue_job(wb_conn, connector_state); active_wb->pixel_write =3D get_pixel_write_function(wb_format); drm_rect_init(&wb_frame_info->src, 0, 0, crtc_width, crtc_height); @@ -163,9 +163,9 @@ static const struct drm_connector_helper_funcs vkms_wb_= conn_helper_funcs =3D { }; =20 int vkms_enable_writeback_connector(struct vkms_device *vkmsdev, - struct vkms_output *vkms_output) + struct vkms_crtc *vkms_crtc) { - struct drm_writeback_connector *wb =3D &vkms_output->wb_connector; + struct drm_writeback_connector *wb =3D &vkms_crtc->wb_connector; =20 drm_connector_helper_add(&wb->base, &vkms_wb_conn_helper_funcs); =20 --=20 2.47.0