From nobody Fri Nov 29 16:41:17 2024 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (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 A5981AD2F for ; Fri, 22 Nov 2024 16:28:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732292891; cv=none; b=cpgWViaV08zB6J+3hJbZvtf6BuxmtXqZYtm+JL01/QumaiVhyTYuY6/MwnYrOIWlsc6ZfDjjC3D7tRm8kt8deLBn1glpBkUrk5GJyFi8gFwxvYTlSUGIG88OBN/QVleGVyYJoDoI3P5wsTGryZDl+Y7HVV3Kt3mg2k5WszMuK6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732292891; c=relaxed/simple; bh=XEV4zTuerxCLsNqXQw8FHPfNTwP3QX1/G4BM5KyG/Z0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SX0CcGaGgu2g2hAbZWdv4thQwIUoFm6GImLMcxojdXDtLoIdIjnmD27oaU3AbiWjnBjcPuyz/Y/f66ffn/FZ/UydUh+01ibTx68lZr7ZuKYDlfzBnOg8hmjkNzVKWuQ2XAUjhKB4ZFTAl25ozybYfXwsDCsK7rwLkC6xHNnTCjM= 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=WjntKrN/; arc=none smtp.client-ip=217.70.183.199 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="WjntKrN/" Received: by mail.gandi.net (Postfix) with ESMTPSA id 780AFFF80B; Fri, 22 Nov 2024 16:28:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732292882; 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=D5vSVpQoMOulPKDsFOnk9t8Cvw8EsHMM8U344JSWPgE=; b=WjntKrN/YT45dRxmRpCG151kujEg8R4bTgk8H70L+oJFPkIJCfXtQp6KeyuRxkE8lJNQ/H VBgkqlxyFM/REK6cM9RUVAaHc8RcQ9rzhxDzYZY5fTbKLWsiw06S9+Pwo93hP44l8dPPM/ 3TLZGbkGEpXWM8WKH/iVwy9iFjJBKCoSmyiHbF1b1GN3fNWSIl706HQUB6M58Jx0ZmgwVJ SdOflr59xAWZTL1CcQ+xLpxQxpunoN6fyAOLfoWNaAGmMj8jf7Vinb2Ykmxtz1byZx+YCQ 850+bK7PhEAnjqI/pz58mscjH9eRU4HHIiILMX8ycqkTFBGU/ZEHQrau8H0w2w== From: Louis Chauvet Date: Fri, 22 Nov 2024 17:27:56 +0100 Subject: [PATCH v5 1/5] drm/vkms: Switch to managed 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-google-vkms-managed-v5-1-1ab60403e960@bootlin.com> References: <20241122-google-vkms-managed-v5-0-1ab60403e960@bootlin.com> In-Reply-To: <20241122-google-vkms-managed-v5-0-1ab60403e960@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter 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=2027; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=XEV4zTuerxCLsNqXQw8FHPfNTwP3QX1/G4BM5KyG/Z0=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQLENDxCYDnRNQxVjqY0cagMP2IrqHuOO4Rrh4 VyQ43LWIbeJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0CxDQAKCRAgrS7GWxAs 4iXGD/9919p9KmYVzlK3US5TZHb0DtHSWsXD91LpsFjLyALL7k4DOQONGO2kJktJYGAaaqpw5g+ GmORa3CUjzfMXDR9YQwW2gnlSb97JYLsU+5yyULWBOWQBNQFHrN2s/Hou3xoTb3r4Ezcke1wfPj xB3rw4QddrxgTfucEU2k2PSCAecO84dgtRdNLYWXH2CpoidZy914AXWHwUaUTjzk2lrPAclAWIY 5hotOodaz60iYa2Z5o7BgZxQfU/VSuxa5Y1TKnD5HwEmmxbJ7ExkeKtQbUZDrISEhCcQaY6akKs lYxQg5SK3B8JlKP6q4qz+79h6OPvBjHnZTItuwwGbgL+Ugrajd+z6L4TYNteE8ORaDYDRqETN1N K53aG6uu1Ezd9BTyXlEKpnmjYeZDb97n5tzckvHGvJb+qa1rdnPXS/Uo9DAU+giBn8404/Arpph G467DBB+FgyhEqpD9Kljya/4Xb+sgaGBvKmmPvPX3T9SafWQdsfB6eqDKZ2UEuGumphVVL/Xt/w ub+g105ozdgCK2ic0TRYFT3RXWwdYLWDuFaVF9NURVsXmMaJMlwXBRBoaslNtMov9aDWV8OKa1t T5d0Ja7mF8x+ewb5XZDVAayX1jvVHhI3qTJqmGvAOQvcGlsO7ySfFomy/qBeG8jfa86UFHpHPSL t/Z1+pDci/AKfcw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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 Reviewed-by: Maxime Ripard Reviewed-by: Ma=C3=ADra Canal --- drivers/gpu/drm/vkms/vkms_output.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms= _output.c index 8f4bd5aef087b459d37d0cbbf90fe0145090917a..570823ecb28f589e6323036590e= c05a2f633bc9b 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 =20 static const struct drm_connector_funcs vkms_connector_funcs =3D { .fill_modes =3D drm_helper_probe_single_connector_modes, - .destroy =3D drm_connector_cleanup, .reset =3D drm_atomic_helper_connector_reset, .atomic_duplicate_state =3D drm_atomic_helper_connector_duplicate_state, .atomic_destroy_state =3D drm_atomic_helper_connector_destroy_state, @@ -75,8 +75,8 @@ int vkms_output_init(struct vkms_device *vkmsdev) } } =20 - ret =3D drm_connector_init(dev, connector, &vkms_connector_funcs, - DRM_MODE_CONNECTOR_VIRTUAL); + ret =3D drmm_connector_init(dev, connector, &vkms_connector_funcs, + DRM_MODE_CONNECTOR_VIRTUAL, NULL); if (ret) { DRM_ERROR("Failed to init connector\n"); return ret; @@ -88,7 +88,7 @@ int vkms_output_init(struct vkms_device *vkmsdev) DRM_MODE_ENCODER_VIRTUAL, NULL); if (ret) { DRM_ERROR("Failed to init encoder\n"); - goto err_encoder; + return ret; } encoder->possible_crtcs =3D drm_crtc_mask(crtc); =20 @@ -110,9 +110,5 @@ int vkms_output_init(struct vkms_device *vkmsdev) =20 err_attach: drm_encoder_cleanup(encoder); - -err_encoder: - drm_connector_cleanup(connector); - return ret; } --=20 2.47.0 From nobody Fri Nov 29 16:41:17 2024 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (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 90D7C1411DE for ; Fri, 22 Nov 2024 16:28:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732292892; cv=none; b=sPiPNi/dC6Lt4gkBbtuPC9fkWXkGXb6XnOoo0y2qIrJ9925bAhrVYDIH725wtzsN5ydcPTCY/BtblMdSmqRc8h+G0VW7tMfOjDqihBoaRJRQnYUhL6jPJcf305hrO+YIwohWCSO1ij+CgWTAXh7sRlDcxeJzEroasT0IUab/Fo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732292892; c=relaxed/simple; bh=NWshA2nhUmLf4+lUiI5nRj1x3O0ZVs1aUdEuVoWdoKs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=esmly65casd8dgby6SuGCcqnm8FLJC38iRmVcQsD20DKqQvQWPJRTt4Cefs2upGDCC4F6Bub+X1bI+2I1bacet4L7TrcLUsfVEyx4N0RETFSAYLTkrvq4e5NEc7LIXRuSy7LBZ18XAKZF3OOv1Ig3fE0Qvl8Fo3vL60ZvoNXZEU= 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=HFWZhrex; arc=none smtp.client-ip=217.70.183.199 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="HFWZhrex" Received: by mail.gandi.net (Postfix) with ESMTPSA id 77909FF807; Fri, 22 Nov 2024 16:28:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732292883; 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=FjtQQ1bolICg0Cj3uC1vz9qBhffyIX0EePF6iMjpDpQ=; b=HFWZhrexD7ynn3nnjoqFLdtyQX8yrpNqYCksWwxYVwuG2jMsSYNFRFBcba/SMkntBk/MOx 0fXWFiI1IAH1/LTcmm9obF7SUlSEu0gHLrGoblJyzE17NCIXifleZFz3NXqBzcDvuBcUc8 IVZMfnQLdTWcNlT5O8CdA6gP0mpyx9IbWM0X4iElGtTHHutpCDhkegD+Sc/q72WHB2XNY6 t+MS9SL2gi2H8utAC4ki/xmBFwy2mTkq+HrXU2r2QUk2qYkfAwBMKK/C1ZUlzlK67+HO7g AN7DrtEaVXFO3M7If+WchaJ2pIDEJe3VVExf83XHh8t0q3y0tFSe1Plyy7gJQQ== From: Louis Chauvet Date: Fri, 22 Nov 2024 17:27:57 +0100 Subject: [PATCH v5 2/5] drm/vkms: Switch to managed 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-google-vkms-managed-v5-2-1ab60403e960@bootlin.com> References: <20241122-google-vkms-managed-v5-0-1ab60403e960@bootlin.com> In-Reply-To: <20241122-google-vkms-managed-v5-0-1ab60403e960@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter 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=1853; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=NWshA2nhUmLf4+lUiI5nRj1x3O0ZVs1aUdEuVoWdoKs=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQLEOEBFS5O5qWfownFloyto/umJBvUpjk6mQb sMVowA0xnqJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0CxDgAKCRAgrS7GWxAs 4oH8D/4k+pBR7pez2m0ozJyJXtzKZcED/qYgtMWsY6uIAFVIe7qdUBmQGalYwrxBwz5zAEgaO/u YQ04wBUqlf532sNqjmxIH6J+wHFD1q0TAChaJBT+RKFN8+N38BGnckitD3mq8h8MRv5EN6++/l2 lcmAL6UpveeVn5QYdIVGRXKMmZ1AzeVRdXKI5nwSJhuWSQ50aGhEWG1HY9CioAnv9KU0JoD6TTO E6EvVq00K9KV8BWZJXG5eHRGG2u+kVtdJPz4wbJFOXsaQgmHOGA+N4IC1xF70Cpo5t5gQYaDnHX 9OVDjnYqeQh78n5Tu3mjKQuN2glgr5Y+HHU8lO2tpSwZhoxYdGG1dPFcwE9Kp99zL17n5pLzBOK My+j9T+tGzp8FNtaCClDAjw78hLmEVS24bv0Ew8CydWg8Peblje8AqLCKmB3CwQCioGD6sQs4tN m8Wp6DoqWXRzFI7hYzhQ/M0R1Os8aajtlV8QEkDP1vSWXAhzJo8fLOr8bW7j58ku1mPkF1FTPQt eMxAQRRZm3nLOEzNFIKXRz7LWeUkDyK3IAbCbMZ1ECVerOuqppsU42zdhmw+sI/rhw+zfj80vnt e0ABx+laKp00UoQQylYv00PYAnaj44DljP8HB9/CnOm6PmSJ0LS18By5z0Gm1wT90kSV0hFb/nY mjZEa36PRlNLDcw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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 Reviewed-by: Maxime Ripard Reviewed-by: Ma=C3=ADra Canal --- drivers/gpu/drm/vkms/vkms_output.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms= _output.c index 570823ecb28f589e6323036590ec05a2f633bc9b..ab9affa75b66ce9f00fe0250524= 39405206144ec 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_f= uncs =3D { .atomic_destroy_state =3D drm_atomic_helper_connector_destroy_state, }; =20 -static const struct drm_encoder_funcs vkms_encoder_funcs =3D { - .destroy =3D drm_encoder_cleanup, -}; - static int vkms_conn_get_modes(struct drm_connector *connector) { int count; @@ -84,8 +80,8 @@ int vkms_output_init(struct vkms_device *vkmsdev) =20 drm_connector_helper_add(connector, &vkms_conn_helper_funcs); =20 - ret =3D drm_encoder_init(dev, encoder, &vkms_encoder_funcs, - DRM_MODE_ENCODER_VIRTUAL, NULL); + ret =3D drmm_encoder_init(dev, encoder, NULL, + DRM_MODE_ENCODER_VIRTUAL, NULL); if (ret) { DRM_ERROR("Failed to init encoder\n"); return ret; @@ -95,7 +91,7 @@ int vkms_output_init(struct vkms_device *vkmsdev) ret =3D drm_connector_attach_encoder(connector, encoder); if (ret) { DRM_ERROR("Failed to attach connector to encoder\n"); - goto err_attach; + return ret; } =20 if (vkmsdev->config->writeback) { @@ -108,7 +104,5 @@ int vkms_output_init(struct vkms_device *vkmsdev) =20 return 0; =20 -err_attach: - drm_encoder_cleanup(encoder); return ret; } --=20 2.47.0 From nobody Fri Nov 29 16:41:17 2024 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (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 95F2B15ADAB for ; Fri, 22 Nov 2024 16:28:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732292893; cv=none; b=iAkS6rZC674GFFNZvhuqbI/bdwW67FbyYZSja73S9D9kzid57GDOaqX2KjvWZqUAbnCGz/myF68ScU2OwmN2vFn5EOz1P2tWddIo0aQv19iQdNm9bod8u3aIZqeJ9iq3QWKDD3U7KmtXL9J05wUX2D7b2os+K25Ng2G/ZnsN9Yc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732292893; c=relaxed/simple; bh=IeQtyAkoL+fPJOYGNUGaUHbisJKJpYsSLjkQcRf+0qY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WUbP3CiIqQ/Ai1+OY8Msmh4K/7TxAsSe6U4FpbrYmjtLWjo4nRHAbaJPut/2eK+9NbbXom+nm9PqdgmU8AS5MF1zbhK7uVN4wIsmomv50awDyyvC9B0SsWVNIvn0/Ei/ifk1xKYbSBb31C0itZK8v4lRULlxOcLLdaMU7W4x+tk= 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=P3HKZDtA; arc=none smtp.client-ip=217.70.183.199 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="P3HKZDtA" Received: by mail.gandi.net (Postfix) with ESMTPSA id 759B1FF80D; Fri, 22 Nov 2024 16:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732292884; 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=1+R80H/JRGfBTVoDp2ktoWF3096dmo8Cz+WCKV/JNeI=; b=P3HKZDtAeF3p73ttTBvl7KN37/DgmHEjydvoPZBobuDHBDecrd26TAWNVLTMxAgk71cDWy N2JRUuqE0VAcBdh3IJJG3ZsLW+0ojTFBSjJ7iTONVjRHkL3hIXEP+LvS8g5oGENqmaGwdz k81oMDRK1sv9zwWk9NHKKfAyHr+exKwapFyZfZTqgJMg4UzwI2Uk2XxnIgGFM1OIfwAg53 hrZxiEcXngWM8Ujn/qqkEwA3IaUmmKJFyZ4Hss//cJzGwU6+q8RGT7tWPvGCHX2gGt6D3/ EaOCghLG5jhACc3Jjm86bnkLK/B+dnPjzs+nfj8p/IRD9KuDS4xa3HXbn5gMJA== From: Louis Chauvet Date: Fri, 22 Nov 2024 17:27:58 +0100 Subject: [PATCH v5 3/5] drm/vkms: Switch to managed 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-google-vkms-managed-v5-3-1ab60403e960@bootlin.com> References: <20241122-google-vkms-managed-v5-0-1ab60403e960@bootlin.com> In-Reply-To: <20241122-google-vkms-managed-v5-0-1ab60403e960@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter 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=2754; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=IeQtyAkoL+fPJOYGNUGaUHbisJKJpYsSLjkQcRf+0qY=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQLEO7iec3QJLdf/6qBQy+AY+D3nvFCKHNjV66 tOUMP8oH4KJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0CxDgAKCRAgrS7GWxAs 4mt3EADBKFj4a+geowtri1oJYj52IoFc11iL+oCYV+m7llgPtlZm0TRcqn21AKU6KBLiwYyr2Ap ImnZA2LS0jq8YhbULBbstgaaS7cfIo7nL20mlxaK4NP7RUO/cjGGKh3iyks0PUuo8oEzUW5FuX/ tiKVB5s6VDXsVa+rJrhZAM+NeFFblW3F1Lna1QsyoVF9FD6xpgowUs4VfFPK0hhqx+VKwwGEm+m VBsPApdT/x9XIeayK7UaMtoYEGckEChQl7j8Q6iuGZOlC3PP28KqMtY00XMAWsX4Y5RLGDGg4CP sxtbYaJ42FKC8BywcXiux+eLtl36lXhQzB9ZvTj0HtlszEmldNNM1WwtJyWHEJtmTBxhJBftacm U06rS4nxI9d2uCASJZ/oTrLS6NkkX/VMuA1GTcc47tG//ygBNXifuuaQOY7U2ZiYnIzAzivTAXB 5PuIhHV4ENh22Umq17godTkyTy8698AJBF3wXChDe3coLCo0tCl2HXKuPIoOhyp7SGEFae/LXpQ brwzRXyVy2iSVaYtNzVsrAETd06+HhtzVha6rKCWBUsIAerw267+3sc62+qUnCnvWchPrOvxLWq gwqXMVAmho4aS2RMe5JF1WnbCurlXm1wyOvhRzE0kvygnXQvLtTwJ5UIWvcQo8EGeyt6WpTJGBb thH22oxbI2EDcyA== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com The current VKMS driver uses managed function to create crtc, but don't use it to properly clean the crtc workqueue. 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 Reviewed-by: Maxime Ripard Reviewed-by: Ma=C3=ADra Canal --- drivers/gpu/drm/vkms/vkms_crtc.c | 14 ++++++++++++++ drivers/gpu/drm/vkms/vkms_drv.c | 9 --------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_c= rtc.c index 28a57ae109fcc05af3fe74f94518c462c09119e3..ace8d293f7da611110c1e117b6c= f2f3c9e9b4381 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 =20 #include "vkms_drv.h" =20 @@ -270,6 +271,14 @@ static const struct drm_crtc_helper_funcs vkms_crtc_he= lper_funcs =3D { .atomic_disable =3D vkms_crtc_atomic_disable, }; =20 +static void vkms_crtc_destroy_workqueue(struct drm_device *dev, + void *raw_vkms_out) +{ + struct vkms_output *vkms_out =3D raw_vkms_out; + + destroy_workqueue(vkms_out->composer_workq); +} + int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, struct drm_plane *primary, struct drm_plane *cursor) { @@ -300,5 +309,10 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_= crtc *crtc, if (!vkms_out->composer_workq) return -ENOMEM; =20 + ret =3D drmm_add_action_or_reset(dev, vkms_crtc_destroy_workqueue, + vkms_out); + if (ret) + return ret; + return ret; } diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_dr= v.c index fa3331f612e34e0a48cef34effc169dea46d77df..c54504e590a18ae8af07cc1cc48= 179c38c4e6c0f 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -54,14 +54,6 @@ MODULE_PARM_DESC(enable_overlay, "Enable/Disable overlay= support"); =20 DEFINE_DRM_GEM_FOPS(vkms_driver_fops); =20 -static void vkms_release(struct drm_device *dev) -{ - struct vkms_device *vkms =3D drm_device_to_vkms_device(dev); - - if (vkms->output.composer_workq) - destroy_workqueue(vkms->output.composer_workq); -} - static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state) { struct drm_device *dev =3D old_state->dev; @@ -109,7 +101,6 @@ static const struct drm_debugfs_info vkms_config_debugf= s_list[] =3D { =20 static const struct drm_driver vkms_driver =3D { .driver_features =3D DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_GEM, - .release =3D vkms_release, .fops =3D &vkms_driver_fops, DRM_GEM_SHMEM_DRIVER_OPS, DRM_FBDEV_SHMEM_DRIVER_OPS, --=20 2.47.0 From nobody Fri Nov 29 16:41:17 2024 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (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 D04191DF267 for ; Fri, 22 Nov 2024 16:28:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732292895; cv=none; b=lW3shgdYIHYvlw+v5htR9J5vpyPpOGHiAvhX4mF2OZLE5jwTIETD8GMBfSXRyXL7gl5bxD8ol+A5Z0i7WQN3tVTeQDfPBOqkBsPzVJzkKBtjvxyvmUNJK7j9fj6AVuUiGLAP5Ug94x7ZWt4svRW4o3oolkeWjJu+e77FuNebHtY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732292895; c=relaxed/simple; bh=xMEy8ARubcCf58SXzdc2VN3L872hkUPBgnkxnJ9Ick4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HoipbXa6NxzVgB+GijQhvI1OvDPeHJ9GYK/U+WmGFI2jXWxfxLJxgWKue2R2j7VnMMmkK2mflRhkyO4C8F1oQLKxZkp9vunJ24P2T1ju1DC1t1s09IhwpIHvt9tGLIulJZIm0AIHmjidQFu4R9keCM+T7qLh0B86PKrO+bdu7mk= 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=mDGtHAki; arc=none smtp.client-ip=217.70.183.199 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="mDGtHAki" Received: by mail.gandi.net (Postfix) with ESMTPSA id 78A67FF805; Fri, 22 Nov 2024 16:28:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732292885; 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=KyRxWncRqDtfIEyzSLj62S6Zb1ebSov3BoKYihZ9vlU=; b=mDGtHAkibMovrYUM1rEEwmChJisFbiy8mpm3moNI0TpKe8rbqsVbSmZ2cL1phKov8GmnSa QUhvqDU4ivn8SQJqf51whAHiJbgrq/dbLr8dQZVundpRPJBG+7g7tFFbBCPnuDKEbHTrf3 0/Ta6v+9yp5C2s8D+m9001eFjyL5lwFGJHRVb4TKjZBKyNx9arhoebHciYegM1XVvg3e7E mfgngSv5ulR4gJya0dV9wSNcUxhSEIHW2PNOlQnEV9BlqqcT+V8GB2xnZStMg7CPyFGcoV LLyHhFMmSTKEtF1DcEegmUVAfRHwmXN+RKuQPe+4rrXKyQe/MEI6USReNs8Isg== From: Louis Chauvet Date: Fri, 22 Nov 2024 17:27:59 +0100 Subject: [PATCH v5 4/5] drm: writeback: Introduce drm managed helpers 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-google-vkms-managed-v5-4-1ab60403e960@bootlin.com> References: <20241122-google-vkms-managed-v5-0-1ab60403e960@bootlin.com> In-Reply-To: <20241122-google-vkms-managed-v5-0-1ab60403e960@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter 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=12891; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=xMEy8ARubcCf58SXzdc2VN3L872hkUPBgnkxnJ9Ick4=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQLEOk7GLbLAuEgFjzBMXy6sWlC10VydWUIqCO Q1jiBj6vTKJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0CxDgAKCRAgrS7GWxAs 4i9OEAC3Kk4R8pb6gKRaBbdMJCyLGdNJlTT2vn1G5ESG/hwoRddM4pLRGMfSWJvpHpIF1UZpsS8 O4HLzfJuitSNOlvJax5Z7rjhgnz1ROWCnhmdLxTYgVtN7Rlh9agDDP7+jHoWK1yclvEdJmublW1 uitLIinbaouBkIumukBgC4Usbu3kdAZOXXsfXLsIIHdqZP4tjHZSco9iGYayAyyTWgUXI1z90h9 KhiXF9lXqoCnxOW+974bqgUe+he4XN3CuVyWsWQDqNl3WBes/q7Xfssgv3MyijJJqz4SImdg0DO PMZ1+hyY6QWPy90n4lkveEscrS61f6LVB98W65/zOT+Fw/1+0GGubdGZMt2dysjf+4aaOEZXzNh NWwW5YMoe792zLGJBx+CqGE8oLFgvNnr4229iqly+Fm2Ni5DdiUkhlUEZrJQwahxkAF3YXxrOdu 8qytRMcMRITLutXZiw+GYjVCyNM6xiEimeewaDLX/mGQYlfKUz9BXSNyUsV1gcLiUSOqjqNt/CU pYndDeIxDEo519tJtfQfqymsBIXji2t5IvF72aI+HiUVp1S49hFbMGaanQxwnm16wjEby6jk23Z nFfpfflL+P5wlthcrj52sQjj8UTWCNRDMhiufVaceCcACeY36FRMpMVy7B/FCnYKfbc/im6xO5v lSwCor9KlgxBrdg== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com Currently drm_writeback_connector are created by drm_writeback_connector_init or drm_writeback_connector_init_with_encoder. Both of the function uses drm_connector_init and drm_encoder_init, but there is no way to properly clean those structure from outside. By using drm managed variants, we can ensure that the writeback connector is properly cleaned. This patch introduce drmm_writeback_connector_init, an helper to initialize a writeback connector using drm managed helpers. This function allows the caller to use its own encoder. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/drm_connector.c | 4 + drivers/gpu/drm/drm_writeback.c | 224 ++++++++++++++++++++++++++++++++++--= ---- include/drm/drm_writeback.h | 10 ++ 3 files changed, 208 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connecto= r.c index fc35f47e2849ed6786d6223ac9c69e1c359fc648..fe4c1967860a3f49b92622c9691= 2c59c505a26ab 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -613,6 +613,7 @@ static void drm_mode_remove(struct drm_connector *conne= ctor, drm_mode_destroy(connector->dev, mode); } =20 +void drm_writeback_connector_cleanup(struct drm_device *dev, void *data); /** * drm_connector_cleanup - cleans up an initialised connector * @connector: connector to cleanup @@ -631,6 +632,9 @@ void drm_connector_cleanup(struct drm_connector *connec= tor) DRM_CONNECTOR_REGISTERED)) drm_connector_unregister(connector); =20 + if (connector->connector_type =3D=3D DRM_MODE_CONNECTOR_WRITEBACK) + drm_writeback_connector_cleanup(dev, connector); + if (connector->privacy_screen) { drm_privacy_screen_put(connector->privacy_screen); connector->privacy_screen =3D NULL; diff --git a/drivers/gpu/drm/drm_writeback.c b/drivers/gpu/drm/drm_writebac= k.c index 33a3c98a962d1ec49ac4b353902036cf74290ae6..28f299ce8e10f5ee6078c759b76= cff9034f010d8 100644 --- a/drivers/gpu/drm/drm_writeback.c +++ b/drivers/gpu/drm/drm_writeback.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -196,13 +197,12 @@ int drm_writeback_connector_init(struct drm_device *d= ev, EXPORT_SYMBOL(drm_writeback_connector_init); =20 /** - * drm_writeback_connector_init_with_encoder - Initialize a writeback conn= ector with - * a custom encoder + * __drm_writeback_connector_init - Common initialization code for writeba= ck + * connector * * @dev: DRM device * @wb_connector: Writeback connector to initialize * @enc: handle to the already initialized drm encoder - * @con_funcs: Connector funcs vtable * @formats: Array of supported pixel formats for the writeback engine * @n_formats: Length of the formats array * @@ -218,41 +218,32 @@ EXPORT_SYMBOL(drm_writeback_connector_init); * assigning the encoder helper functions, possible_crtcs and any other en= coder * specific operation. * - * Drivers should always use this function instead of drm_connector_init()= to - * set up writeback connectors if they want to manage themselves the lifet= ime of the - * associated encoder. - * * Returns: 0 on success, or a negative error code */ -int drm_writeback_connector_init_with_encoder(struct drm_device *dev, - struct drm_writeback_connector *wb_connector, struct drm_encoder *enc, - const struct drm_connector_funcs *con_funcs, const u32 *formats, - int n_formats) +static int __drm_writeback_connector_init(struct drm_device *dev, + struct drm_writeback_connector *wb_connector, + struct drm_encoder *enc, + const u32 *formats, int n_formats) { - struct drm_property_blob *blob; struct drm_connector *connector =3D &wb_connector->base; struct drm_mode_config *config =3D &dev->mode_config; - int ret =3D create_writeback_properties(dev); - - if (ret !=3D 0) - return ret; - - blob =3D drm_property_create_blob(dev, n_formats * sizeof(*formats), - formats); - if (IS_ERR(blob)) - return PTR_ERR(blob); - + struct drm_property_blob *blob; + int ret; =20 connector->interlace_allowed =3D 0; =20 - ret =3D drm_connector_init(dev, connector, con_funcs, - DRM_MODE_CONNECTOR_WRITEBACK); + ret =3D create_writeback_properties(dev); if (ret) - goto connector_fail; + return ret; =20 ret =3D drm_connector_attach_encoder(connector, enc); if (ret) - goto attach_fail; + return ret; + + blob =3D drm_property_create_blob(dev, n_formats * sizeof(*formats), + formats); + if (IS_ERR(blob)) + return PTR_ERR(blob); =20 INIT_LIST_HEAD(&wb_connector->job_queue); spin_lock_init(&wb_connector->job_lock); @@ -275,15 +266,188 @@ int drm_writeback_connector_init_with_encoder(struct= drm_device *dev, wb_connector->pixel_formats_blob_ptr =3D blob; =20 return 0; +} + +/** + * drm_writeback_connector_init_with_encoder - Initialize a writeback conn= ector with + * a custom encoder + * + * @dev: DRM device + * @wb_connector: Writeback connector to initialize + * @enc: handle to the already initialized drm encoder + * @con_funcs: Connector funcs vtable + * @formats: Array of supported pixel formats for the writeback engine + * @n_formats: Length of the formats array + * + * This function creates the writeback-connector-specific properties if th= ey + * have not been already created, initializes the connector as + * type DRM_MODE_CONNECTOR_WRITEBACK, and correctly initializes the proper= ty + * values. + * + * This function assumes that the drm_writeback_connector's encoder has al= ready been + * created and initialized before invoking this function. + * + * In addition, this function also assumes that callers of this API will m= anage + * assigning the encoder helper functions, possible_crtcs and any other en= coder + * specific operation. + * + * Drivers should always use this function instead of drm_connector_init()= to + * set up writeback connectors if they want to manage themselves the lifet= ime of the + * associated encoder. + * + * Returns: 0 on success, or a negative error code + */ +int drm_writeback_connector_init_with_encoder(struct drm_device *dev, + struct drm_writeback_connector *wb_connector, + struct drm_encoder *enc, + const struct drm_connector_funcs *con_funcs, + const u32 *formats, int n_formats) +{ + struct drm_connector *connector =3D &wb_connector->base; + int ret; + + ret =3D drm_connector_init(dev, connector, con_funcs, + DRM_MODE_CONNECTOR_WRITEBACK); + if (ret) + return ret; + + ret =3D __drm_writeback_connector_init(dev, wb_connector, enc, formats, + n_formats); + if (ret) + drm_connector_cleanup(connector); =20 -attach_fail: - drm_connector_cleanup(connector); -connector_fail: - drm_property_blob_put(blob); return ret; } EXPORT_SYMBOL(drm_writeback_connector_init_with_encoder); =20 +/** + * drm_writeback_connector_cleanup - Cleanup the writeback connector + * @dev: DRM device + * @data: Opaque pointer to the connector + * + * This will decrement the reference counter of blobs and it will clean the + * remaining jobs in this writeback connector. + */ +void drm_writeback_connector_cleanup(struct drm_device *dev, void *data) +{ + struct drm_connector *connector =3D data; + struct drm_writeback_connector *wb_connector =3D container_of(connector, + struct drm_writeback_connector, + base); + unsigned long flags; + struct drm_writeback_job *pos, *n; + + drm_property_blob_put(wb_connector->pixel_formats_blob_ptr); + + spin_lock_irqsave(&wb_connector->job_lock, flags); + list_for_each_entry_safe(pos, n, &wb_connector->job_queue, list_entry) { + drm_writeback_cleanup_job(pos); + list_del(&pos->list_entry); + } + spin_unlock_irqrestore(&wb_connector->job_lock, flags); +} + +/** + * __drmm_writeback_connector_init - Initialize a writeback connector with + * a custom encoder + * + * @dev: DRM device + * @wb_connector: Writeback connector to initialize + * @con_funcs: Connector funcs vtable + * @enc: handle to the already initialized drm encoder + * @formats: Array of supported pixel formats for the writeback engine + * @n_formats: Length of the formats array + * + * This function initialize a writeback connector and register its cleanup. + * It uses the common helper @__drm_writeback_connector_init to do the + * general initialization. + * + * This function assumes that @enc has already been created and initialized + * before invoking this function. + * + * In addition, this function also assumes that callers of this API will m= anage + * assigning the encoder helper functions, possible_crtcs and any other en= coder + * specific operation. + * + * Returns: 0 on success, or a negative error code + */ +static int __drmm_writeback_connector_init(struct drm_device *dev, + struct drm_writeback_connector *wb_connector, + const struct drm_connector_funcs *con_funcs, + struct drm_encoder *enc, + const u32 *formats, int n_formats) +{ + struct drm_connector *connector =3D &wb_connector->base; + int ret; + + ret =3D drmm_connector_init(dev, connector, con_funcs, + DRM_MODE_CONNECTOR_WRITEBACK, NULL); + if (ret) + return ret; + + ret =3D __drm_writeback_connector_init(dev, wb_connector, enc, formats, + n_formats); + if (ret) + return ret; + + return 0; +} + +/** + * drmm_writeback_connector_init - Initialize a writeback connector with + * a custom encoder + * + * @dev: DRM device + * @wb_connector: Writeback connector to initialize + * @con_funcs: Connector funcs vtable + * @enc: handle to the already initialized drm encoder, optional + * @enc_funcs: Encoder funcs vtable, optional, only used when @enc is NULL + * @formats: Array of supported pixel formats for the writeback engine + * @n_formats: Length of the formats array + * @possible_crtcs: if @enc is NULL, this will set the possible_crtc for t= he + * newly created encoder + * + * This function initialize a writeback connector and register its cleanup. + * + * This function creates the writeback-connector-specific properties if th= ey + * have not been already created, initializes the connector as + * type DRM_MODE_CONNECTOR_WRITEBACK, and correctly initializes the proper= ty + * values. + * + * If @enc is NULL, this function will create a drm-managed encoder and wi= ll + * attach @enc_funcs on it. It will also attach the CRTC passed in + * @possible_crtcs + * + * Returns: 0 on success, or a negative error code + */ +int drmm_writeback_connector_init(struct drm_device *dev, + struct drm_writeback_connector *wb_connector, + const struct drm_connector_funcs *con_funcs, + struct drm_encoder *enc, + const struct drm_encoder_helper_funcs *enc_funcs, + const u32 *formats, int n_formats, + u32 possible_crtcs) +{ + int ret; + + if (!enc) { + ret =3D drmm_encoder_init(dev, &wb_connector->encoder, + NULL, DRM_MODE_ENCODER_VIRTUAL, NULL); + if (ret) + return ret; + + enc =3D &wb_connector->encoder; + enc->possible_crtcs |=3D possible_crtcs; + if (enc_funcs) + drm_encoder_helper_add(enc, enc_funcs); + } + + return __drmm_writeback_connector_init(dev, wb_connector, con_funcs, + &wb_connector->encoder, formats, + n_formats); +} +EXPORT_SYMBOL(drmm_writeback_connector_init); + int drm_writeback_set_fb(struct drm_connector_state *conn_state, struct drm_framebuffer *fb) { diff --git a/include/drm/drm_writeback.h b/include/drm/drm_writeback.h index 17e576c80169a820e8d5587b229b2cc2ee369a18..5e5ff8dd9d9d8ab5e46ce028a75= 2062b97e82e0f 100644 --- a/include/drm/drm_writeback.h +++ b/include/drm/drm_writeback.h @@ -161,6 +161,14 @@ int drm_writeback_connector_init_with_encoder(struct d= rm_device *dev, const struct drm_connector_funcs *con_funcs, const u32 *formats, int n_formats); =20 +int drmm_writeback_connector_init(struct drm_device *dev, + struct drm_writeback_connector *wb_connector, + const struct drm_connector_funcs *con_funcs, + struct drm_encoder *enc, + const struct drm_encoder_helper_funcs *enc_funcs, + const u32 *formats, int n_formats, + u32 possible_crtcs); + int drm_writeback_set_fb(struct drm_connector_state *conn_state, struct drm_framebuffer *fb); =20 @@ -175,6 +183,8 @@ void drm_writeback_signal_completion(struct drm_writeback_connector *wb_connect= or, int status); =20 +void drm_writeback_connector_cleanup(struct drm_device *dev, void *data); + struct dma_fence * drm_writeback_get_out_fence(struct drm_writeback_connector *wb_connector); #endif --=20 2.47.0 From nobody Fri Nov 29 16:41:17 2024 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (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 5C5A11DF73B for ; Fri, 22 Nov 2024 16:28:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732292895; cv=none; b=ID9ECzrfPhW0I09x92hmRTb+nB3/ZOsVXvu0+0YYV34SMaeFdGkiXxD31u6HSOtg3OGs28Fpkb4bij+BKvCd0OwPM7NxVZlEfzAsKuObh4J8kmAqxT4SM2sggm9hDY3M5ySFh84IIKnOIaoQ9v9WU7bIh1tAwOqVBT6voQW1V7w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732292895; c=relaxed/simple; bh=xbDbD69KZNScHlgCMisg2HJq8BICvN3NQAqTm8bzP/k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jJn3NljUyl5TY5rPwR9yxdpCuBXACS/D0PtN7O/Th8ydmGl2V2gjw3xM9bzpztl6cVLkQg3Qb4e7/v83ketJGNNYD09/OHcfZr5vzyufO4zUKpTJi5bBSiDYwp8YUG44STDgc/3n6firM1c3/sT6WNboDgCs3LI78GAIyco3XlM= 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=L0R5LLuX; arc=none smtp.client-ip=217.70.183.199 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="L0R5LLuX" Received: by mail.gandi.net (Postfix) with ESMTPSA id 7B9D6FF80C; Fri, 22 Nov 2024 16:28:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1732292886; 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=J7mrH4nMB6P5AeJ5Mz8Ak1miBGu6SgNHfqh2MFhH/Sk=; b=L0R5LLuX33gt5SA18g0DlnbRhP05jPVopQIj9c8WQDAC/jFD7ycEhQNGsXnYZ0ns4uurRb vDJzvl+isW0pX9tmJQ7Z3pXDuq6eD48AJFtvrapfR9RJTqKsZAWqiNofNikWzgish73YvB jSKHYfpKwOeWEQ1RnVZ44yZcG4iHH6p3GoMcnVZ/jRgWj2+eib1Y9sKWf/KxHSxi1xcMge ZG9x+QlBgP018yuR+/xDCx1FZipLzXsgcIZyEyb4YJgE3ayw/DlRslzveiziyUjmis73ry EKcr4P8W0Ocm1TntOdPZSVRkA2ZpmyQ3EJdnoQcrc5hgHHEmeNd67Uj4yFhEIQ== From: Louis Chauvet Date: Fri, 22 Nov 2024 17:28:00 +0100 Subject: [PATCH v5 5/5] drm/vkms: Switch to managed for writeback 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-google-vkms-managed-v5-5-1ab60403e960@bootlin.com> References: <20241122-google-vkms-managed-v5-0-1ab60403e960@bootlin.com> In-Reply-To: <20241122-google-vkms-managed-v5-0-1ab60403e960@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , Haneen Mohammed , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Simona Vetter 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=1671; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=xbDbD69KZNScHlgCMisg2HJq8BICvN3NQAqTm8bzP/k=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnQLEPFkspIJns27wzQHp2ZOPEZwLqsuzSD1Zw5 l0evx6X0wyJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZ0CxDwAKCRAgrS7GWxAs 4ljQEACMYE8CiMHmW/LFkuycRe9+cFYBWwhAixe0AubRsW5P53/jwu2qWrHkWb60Xb85+uAAwm5 Ob3U1y0Te1PtYzFxopxxl7Bw0NZzxjZkzyACVodyfDkAvBI6SdVfwLE0gruCaXNd5FigQq3C2DT cM9FQdH2LvnoRTW7uI5QTW+5RB5kvitp/TzSWx9umlBsk3ummiNj4lkvdMCuT9+5ucBhWVb8QCa 9GqqYu0SJGC+jhi5or065XHJ/iKhoyjHMil+XPJYnPhmEKMM5DV/g74jWUXPLNitDjeiylyFAUT f8iwL+UILfmK1i+nQe1GWMWAqkr8kDhkjD4JcBW5Op/pj/FF9PdiMLL6mpoVZuqu1GLI1/5zcew rW/VPJ4RMzKC0x/1OfRe2juj/eIF/xsnMlyjn6dXuu7jwwEsTQwL7KPaZ+qa9anzGvuDIV84WW/ G86rgq5FUBDv177fa5WZWsCtUkAs5cX3ljlxttUjG3tycvY107SaGC/IzxXnOOMEfbAVoHDdmds q7sVF9C5yNl/PiljOEaGwQ+U/AyjckHHpTPEFESZXDqMdnRri9DZTzCk179RpCW16poFAVqZojH oElfpbVz9ZgTqQu6y5p6LtObOhyfbksL/iS88fxdD+a9doNHK7tQVtK2W861oPc1qvyC1iIeI/q yFEubUDCBY+XkdA== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com The current VKMS driver uses non-managed function to create writeback 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_writeback.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/v= kms_writeback.c index 79918b44fedd7ae2451d1d530fc6d5aabf2d99a3..f12417b2d24803a33e4ff56108c= c89704a500faf 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -24,7 +24,6 @@ static const u32 vkms_wb_formats[] =3D { =20 static const struct drm_connector_funcs vkms_wb_connector_funcs =3D { .fill_modes =3D drm_helper_probe_single_connector_modes, - .destroy =3D drm_connector_cleanup, .reset =3D drm_atomic_helper_connector_reset, .atomic_duplicate_state =3D drm_atomic_helper_connector_duplicate_state, .atomic_destroy_state =3D drm_atomic_helper_connector_destroy_state, @@ -169,10 +168,10 @@ int vkms_enable_writeback_connector(struct vkms_devic= e *vkmsdev) =20 drm_connector_helper_add(&wb->base, &vkms_wb_conn_helper_funcs); =20 - return drm_writeback_connector_init(&vkmsdev->drm, wb, - &vkms_wb_connector_funcs, - NULL, - vkms_wb_formats, - ARRAY_SIZE(vkms_wb_formats), - 1); + return drmm_writeback_connector_init(&vkmsdev->drm, wb, + &vkms_wb_connector_funcs, + NULL, NULL, + vkms_wb_formats, + ARRAY_SIZE(vkms_wb_formats), + 1); } --=20 2.47.0