From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
To: Rob Clark <robdclark@gmail.com>, Sean Paul <sean@poorly.run>,
Abhinav Kumar <quic_abhinavk@quicinc.com>,
Marijn Suijten <marijn.suijten@somainline.org>
Cc: Stephen Boyd <swboyd@chromium.org>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
Bjorn Andersson <andersson@kernel.org>,
linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
freedreno@lists.freedesktop.org
Subject: [PATCH 08/17] drm/msm/mdp5: use drmm-managed allocation for mdp5_crtc
Date: Sat, 8 Jul 2023 04:03:58 +0300 [thread overview]
Message-ID: <20230708010407.3871346-9-dmitry.baryshkov@linaro.org> (raw)
In-Reply-To: <20230708010407.3871346-1-dmitry.baryshkov@linaro.org>
Change struct mdp5_crtc allocation to use drmm_crtc_alloc(). This
removes the need to perform any actions on CRTC destruction.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 30 +++++++++++------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
index 86036dd4e1e8..4a3db2ea1689 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
@@ -13,6 +13,7 @@
#include <drm/drm_crtc.h>
#include <drm/drm_flip_work.h>
#include <drm/drm_fourcc.h>
+#include <drm/drm_managed.h>
#include <drm/drm_probe_helper.h>
#include <drm/drm_vblank.h>
@@ -172,14 +173,11 @@ static void unref_cursor_worker(struct drm_flip_work *work, void *val)
drm_gem_object_put(val);
}
-static void mdp5_crtc_destroy(struct drm_crtc *crtc)
+static void mdp5_crtc_flip_cleanup(struct drm_device *dev, void *ptr)
{
- struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
+ struct mdp5_crtc *mdp5_crtc = ptr;
- drm_crtc_cleanup(crtc);
drm_flip_work_cleanup(&mdp5_crtc->unref_cursor_work);
-
- kfree(mdp5_crtc);
}
static inline u32 mdp5_lm_use_fg_alpha_mask(enum mdp_mixer_stage_id stage)
@@ -1147,7 +1145,6 @@ static void mdp5_crtc_reset(struct drm_crtc *crtc)
static const struct drm_crtc_funcs mdp5_crtc_no_lm_cursor_funcs = {
.set_config = drm_atomic_helper_set_config,
- .destroy = mdp5_crtc_destroy,
.page_flip = drm_atomic_helper_page_flip,
.reset = mdp5_crtc_reset,
.atomic_duplicate_state = mdp5_crtc_duplicate_state,
@@ -1161,7 +1158,6 @@ static const struct drm_crtc_funcs mdp5_crtc_no_lm_cursor_funcs = {
static const struct drm_crtc_funcs mdp5_crtc_funcs = {
.set_config = drm_atomic_helper_set_config,
- .destroy = mdp5_crtc_destroy,
.page_flip = drm_atomic_helper_page_flip,
.reset = mdp5_crtc_reset,
.atomic_duplicate_state = mdp5_crtc_duplicate_state,
@@ -1327,10 +1323,16 @@ struct drm_crtc *mdp5_crtc_init(struct drm_device *dev,
{
struct drm_crtc *crtc = NULL;
struct mdp5_crtc *mdp5_crtc;
+ int ret;
- mdp5_crtc = kzalloc(sizeof(*mdp5_crtc), GFP_KERNEL);
- if (!mdp5_crtc)
- return ERR_PTR(-ENOMEM);
+ mdp5_crtc = drmm_crtc_alloc_with_planes(dev, struct mdp5_crtc, base,
+ plane, cursor_plane,
+ cursor_plane ?
+ &mdp5_crtc_no_lm_cursor_funcs :
+ &mdp5_crtc_funcs,
+ NULL);
+ if (IS_ERR(mdp5_crtc))
+ return ERR_CAST(mdp5_crtc);
crtc = &mdp5_crtc->base;
@@ -1346,13 +1348,11 @@ struct drm_crtc *mdp5_crtc_init(struct drm_device *dev,
mdp5_crtc->lm_cursor_enabled = cursor_plane ? false : true;
- drm_crtc_init_with_planes(dev, crtc, plane, cursor_plane,
- cursor_plane ?
- &mdp5_crtc_no_lm_cursor_funcs :
- &mdp5_crtc_funcs, NULL);
-
drm_flip_work_init(&mdp5_crtc->unref_cursor_work,
"unref cursor", unref_cursor_worker);
+ ret = drmm_add_action_or_reset(dev, mdp5_crtc_flip_cleanup, mdp5_crtc);
+ if (ret)
+ return ERR_PTR(ret);
drm_crtc_helper_add(crtc, &mdp5_crtc_helper_funcs);
--
2.39.2
next prev parent reply other threads:[~2023-07-08 1:04 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-08 1:03 [PATCH 00/17] drm/msm/mdp[45]: use managed memory allocations Dmitry Baryshkov
2023-07-08 1:03 ` [PATCH 01/17] drm/msm: add arrays listing formats supported by MDP4/MDP5 hardware Dmitry Baryshkov
2023-12-02 1:36 ` Abhinav Kumar
2023-12-02 11:12 ` Dmitry Baryshkov
2023-07-08 1:03 ` [PATCH 02/17] drm/msm/mdp5: use devres-managed allocation for configuration data Dmitry Baryshkov
2023-12-01 22:12 ` [Freedreno] " Abhinav Kumar
2023-07-08 1:03 ` [PATCH 03/17] drm/msm/mdp5: use devres-managed allocation for CTL manager data Dmitry Baryshkov
2023-12-01 22:15 ` Abhinav Kumar
2023-12-01 22:16 ` Abhinav Kumar
2023-07-08 1:03 ` [PATCH 04/17] drm/msm/mdp5: use devres-managed allocation for mixer data Dmitry Baryshkov
2023-12-01 22:19 ` Abhinav Kumar
2023-07-08 1:03 ` [PATCH 05/17] drm/msm/mdp5: use devres-managed allocation for pipe data Dmitry Baryshkov
2023-12-01 22:21 ` Abhinav Kumar
2023-07-08 1:03 ` [PATCH 06/17] drm/msm/mdp5: use devres-managed allocation for SMP data Dmitry Baryshkov
2023-12-01 22:23 ` Abhinav Kumar
2023-07-08 1:03 ` [PATCH 07/17] drm/msm/mdp5: use devres-managed allocation for INTF data Dmitry Baryshkov
2023-12-01 23:04 ` Abhinav Kumar
2023-07-08 1:03 ` Dmitry Baryshkov [this message]
2023-12-01 23:12 ` [PATCH 08/17] drm/msm/mdp5: use drmm-managed allocation for mdp5_crtc Abhinav Kumar
2023-07-08 1:03 ` [PATCH 09/17] drm/msm/mdp5: use drmm-managed allocation for mdp5_encoder Dmitry Baryshkov
2023-12-01 23:15 ` Abhinav Kumar
2023-07-08 1:04 ` [PATCH 10/17] drm/msm/mdp5: use drmm-managed allocation for mdp5_plane Dmitry Baryshkov
2023-12-01 23:24 ` Abhinav Kumar
2023-07-08 1:04 ` [PATCH 11/17] drm/msm/mdp4: use bulk regulators API for LCDC encoder Dmitry Baryshkov
2023-12-01 23:27 ` Abhinav Kumar
2023-07-08 1:04 ` [PATCH 12/17] drm/msm/mdp4: use drmm-managed allocation for mdp4_crtc Dmitry Baryshkov
2023-12-02 0:49 ` Abhinav Kumar
2023-07-08 1:04 ` [PATCH 13/17] drm/msm/mdp4: use drmm-managed allocation for mdp4_dsi_encoder Dmitry Baryshkov
2023-12-02 1:16 ` Abhinav Kumar
2023-07-08 1:04 ` [PATCH 14/17] drm/msm/mdp4: use drmm-managed allocation for mdp4_dtv_encoder Dmitry Baryshkov
2023-12-02 1:17 ` Abhinav Kumar
2023-07-08 1:04 ` [PATCH 15/17] drm/msm/mdp4: use drmm-managed allocation for mdp4_lcdc_encoder Dmitry Baryshkov
2023-12-02 1:22 ` Abhinav Kumar
2023-07-08 1:04 ` [PATCH 16/17] drm/msm/mdp4: use drmm-managed allocation for mdp4_plane Dmitry Baryshkov
2023-12-02 1:24 ` Abhinav Kumar
2023-07-08 1:04 ` [PATCH 17/17] drm/msm: drop mdp_get_formats() Dmitry Baryshkov
2023-12-02 1:25 ` Abhinav Kumar
2023-12-02 1:33 ` Abhinav Kumar
2023-12-03 11:26 ` [PATCH 00/17] drm/msm/mdp[45]: use managed memory allocations Dmitry Baryshkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230708010407.3871346-9-dmitry.baryshkov@linaro.org \
--to=dmitry.baryshkov@linaro.org \
--cc=airlied@gmail.com \
--cc=andersson@kernel.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=marijn.suijten@somainline.org \
--cc=quic_abhinavk@quicinc.com \
--cc=robdclark@gmail.com \
--cc=sean@poorly.run \
--cc=swboyd@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox