From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
To: Rob Clark <robin.clark@oss.qualcomm.com>,
Dmitry Baryshkov <lumag@kernel.org>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Jessica Zhang <jesszhan0024@gmail.com>,
Sean Paul <sean@poorly.run>,
Marijn Suijten <marijn.suijten@somainline.org>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH 00/11] drm/msm: fix the error handling of the KMS init
Date: Sat, 03 Oct 2026 03:27:08 +0300 [thread overview]
Message-ID: <20261003-msm-kms-destroy-fixes-v1-0-e062b7dae77f@oss.qualcomm.com> (raw)
When setting up the KMS fails, msm_drm_kms_init() cleans up by calling
the ->destroy() callback of the kms driver. That makes ->destroy()
responsible for tearing down a KMS in any state, from "not initialised at
all" to "fully initialised", and the drivers get it wrong in several
ways:
- dpu_kms_hw_init() and mdp5_init() already clean up after their own
failures, and ->destroy() then finalises the global state object a
second time;
- mdp4_destroy() dereferences mdp4_kms->dev, which isn't set yet when
mdp_kms_init() fails;
- msm_kms_init() leaves a NULL workqueue behind when it fails to
allocate it, which msm_kms_destroy() passes to destroy_workqueue();
- msm_drm_kms_init() hands a half initialised KMS to the full teardown
of msm_drm_kms_uninit(), and the snapshot init ignores the failure to
create its worker.
Most of these were pointed out by Sashiko while reviewing the "drm/msm:
fix SMMU fault dumps" series, which has been carrying the first fixes.
Rather than teaching ->destroy() about ever more partial states, this
series switches the KMS init to the usual kernel convention: every init
function undoes its own steps when it fails, and ->destroy() only ever
tears down a KMS which was initialised successfully. This reverses the
approach of commit 93c125e4ea98 ("drm/msm: don't tear down KMS twice when
KMS init fails"), which moved all of the cleanup into ->destroy().
To keep every step safe and bisectable, the drivers are converted one at
a time: a temporary flag tells msm_drm_kms_init() that a driver cleans up
its own failures, and both the flag and ->hw_init(), which gets folded
into the drivers' kms_init(), are removed once all the drivers have been
converted. The last patches are follow-ups which the new rules allow:
unwinding the DPU hardware setup step by step, disabling the MDP4 vdd
regulator on teardown, and dropping the runtime PM flags which
->destroy() no longer needs.
Tested on DB820c (MSM8996) with both the MDP5 and the DPU drivers, with
failures injected into the msm_kms_init(), the MDP5 kms_init(), the DPU
hardware setup and after a successful kms_init(): each of them now fails
the bind cleanly, without warnings. MDP4 is build-tested only.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
Dmitry Baryshkov (11):
drm/msm: fail the snapshot init when its worker cannot be created
drm/msm: unwind msm_drm_kms_init() on failure
drm/msm: clean up after a failed msm_kms_init()
drm/msm: let the kms drivers clean up a failed kms_init()
drm/msm/mdp5: unwind a failed mdp5_kms_init()
drm/msm/mdp4: unwind a failed mdp4_kms_init()
drm/msm/dpu: don't tear down a failed hw_init twice
drm/msm: tear down only a successfully initialised KMS
drm/msm/dpu: unwind a failed dpu_kms_hw_init() step by step
drm/msm/mdp4: disable the vdd regulator on teardown
drm/msm: drop the runtime PM flags from the KMS teardown
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 55 ++++++++++++------------
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 1 -
drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 63 +++++++++++++++++-----------
drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.h | 2 -
drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 47 +++++++++++----------
drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.h | 2 -
drivers/gpu/drm/msm/disp/msm_disp_snapshot.c | 12 +++++-
drivers/gpu/drm/msm/msm_drv.c | 27 +++++++++---
drivers/gpu/drm/msm/msm_kms.c | 43 ++++++++++---------
drivers/gpu/drm/msm/msm_kms.h | 17 +++++---
10 files changed, 159 insertions(+), 110 deletions(-)
---
base-commit: a15fac810c76397ec9f62a6fc26c4d7ab6e238a7
change-id: 20260930-msm-kms-destroy-fixes-0f04b1d39b83
Best regards,
--
With best wishes
Dmitry
next reply other threads:[~2026-10-03 0:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-03 0:27 Dmitry Baryshkov [this message]
2026-10-03 0:27 ` [PATCH 01/11] drm/msm: fail the snapshot init when its worker cannot be created Dmitry Baryshkov
2026-10-03 0:27 ` [PATCH 02/11] drm/msm: unwind msm_drm_kms_init() on failure Dmitry Baryshkov
2026-10-03 0:27 ` [PATCH 03/11] drm/msm: clean up after a failed msm_kms_init() Dmitry Baryshkov
2026-10-03 0:27 ` [PATCH 04/11] drm/msm: let the kms drivers clean up a failed kms_init() Dmitry Baryshkov
2026-10-03 0:27 ` [PATCH 05/11] drm/msm/mdp5: unwind a failed mdp5_kms_init() Dmitry Baryshkov
2026-10-03 0:27 ` [PATCH 06/11] drm/msm/mdp4: unwind a failed mdp4_kms_init() Dmitry Baryshkov
2026-10-03 0:27 ` [PATCH 07/11] drm/msm/dpu: don't tear down a failed hw_init twice Dmitry Baryshkov
2026-10-03 0:27 ` [PATCH 08/11] drm/msm: tear down only a successfully initialised KMS Dmitry Baryshkov
2026-10-03 0:27 ` [PATCH 09/11] drm/msm/dpu: unwind a failed dpu_kms_hw_init() step by step Dmitry Baryshkov
2026-10-03 0:27 ` [PATCH 10/11] drm/msm/mdp4: disable the vdd regulator on teardown Dmitry Baryshkov
2026-10-03 0:27 ` [PATCH 11/11] drm/msm: drop the runtime PM flags from the KMS teardown 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=20261003-msm-kms-destroy-fixes-v1-0-e062b7dae77f@oss.qualcomm.com \
--to=dmitry.baryshkov@oss.qualcomm.com \
--cc=abhinav.kumar@linux.dev \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=jesszhan0024@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lumag@kernel.org \
--cc=marijn.suijten@somainline.org \
--cc=robin.clark@oss.qualcomm.com \
--cc=sean@poorly.run \
--cc=simona@ffwll.ch \
/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
all inboxes | Powered by JetHome®