From: Simona Vetter <simona.vetter@ffwll.ch>
To: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: "Jessica Zhang" <quic_jesszhan@quicinc.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Rob Clark" <robdclark@gmail.com>,
"Dmitry Baryshkov" <dmitry.baryshkov@linaro.org>,
"Sean Paul" <sean@poorly.run>,
"Marijn Suijten" <marijn.suijten@somainline.org>,
"David Airlie" <airlied@gmail.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
quic_ebharadw@quicinc.com, linux-arm-msm@vger.kernel.org,
dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org,
linux-kernel@vger.kernel.org,
"Rob Clark" <robdclark@chromium.org>,
"Ville Syrjälä" <ville.syrjala@linux.intel.com>
Subject: Re: [PATCH v2 02/22] drm: Add valid clones check
Date: Mon, 16 Dec 2024 15:27:05 +0100 [thread overview]
Message-ID: <Z2A4uahCHuOz45Fc@phenom.ffwll.local> (raw)
In-Reply-To: <54188c68-41c7-4a42-9eca-67363b30217a@quicinc.com>
On Sun, Dec 15, 2024 at 06:19:08PM -0800, Abhinav Kumar wrote:
> Hi Maxime
>
> Gentle reminder on this one.
>
> We are looking for some advice on how to go about KUnit for this static
> function.
>
> Please help with our question below.
>
> Thanks
>
> Abhinav
>
> On 12/6/2024 4:48 PM, Jessica Zhang wrote:
> >
> >
> > On 9/25/2024 12:23 AM, Maxime Ripard wrote:
> > > On Tue, Sep 24, 2024 at 03:59:18PM GMT, Jessica Zhang wrote:
> > > > Check that all encoders attached to a given CRTC are valid
> > > > possible_clones of each other.
> > > >
> > > > Signed-off-by: Jessica Zhang <quic_jesszhan@quicinc.com>
> > > > ---
> > > > drivers/gpu/drm/drm_atomic_helper.c | 23 +++++++++++++++++++++++
> > > > 1 file changed, 23 insertions(+)
> > > >
> > > > diff --git a/drivers/gpu/drm/drm_atomic_helper.c
> > > > b/drivers/gpu/drm/drm_atomic_helper.c
> > > > index 43cdf39019a4..cc4001804fdc 100644
> > > > --- a/drivers/gpu/drm/drm_atomic_helper.c
> > > > +++ b/drivers/gpu/drm/drm_atomic_helper.c
> > > > @@ -574,6 +574,25 @@ mode_valid(struct drm_atomic_state *state)
> > > > return 0;
> > > > }
> > > > +static int drm_atomic_check_valid_clones(struct
> > > > drm_atomic_state *state,
> > > > + struct drm_crtc *crtc)
> > > > +{
> > > > + struct drm_encoder *drm_enc;
> > > > + struct drm_crtc_state *crtc_state =
> > > > drm_atomic_get_new_crtc_state(state,
> > > > + crtc);
> > > > +
> > > > + drm_for_each_encoder_mask(drm_enc, crtc->dev,
> > > > crtc_state->encoder_mask) {
> > > > + if ((crtc_state->encoder_mask & drm_enc->possible_clones) !=
> > > > + crtc_state->encoder_mask) {
> > > > + DRM_DEBUG("crtc%d failed valid clone check for mask
> > > > 0x%x\n",
> > > > + crtc->base.id, crtc_state->encoder_mask);
> > > > + return -EINVAL;
> > > > + }
> > > > + }
> > > > +
> > > > + return 0;
> > > > +}
> > > > +
> > > > /**
> > > > * drm_atomic_helper_check_modeset - validate state object for
> > > > modeset changes
> > > > * @dev: DRM device
> > > > @@ -745,6 +764,10 @@ drm_atomic_helper_check_modeset(struct
> > > > drm_device *dev,
> > > > ret = drm_atomic_add_affected_planes(state, crtc);
> > > > if (ret != 0)
> > > > return ret;
> > > > +
> > > > + ret = drm_atomic_check_valid_clones(state, crtc);
> > > > + if (ret != 0)
> > > > + return ret;
> > > > }
> > >
> > > Pretty much the same comment, we should have kunit tests for this.
> >
> > Hey Maxime,
> >
> > I'm working on the kunit test for this and had a question on the design
> > for the unit test:
> >
> > Since this is a static helper that returns a pretty common error code,
> > how would you recommend going about making sure that
> > `drm_atomic_check_valid_clones()` specifically is returning the error
> > (and not a different part of check_modeset) when testing the
> > check_valid_clones() failure path?
So the usual way to test very specific things of a big function is to
first setup a driver and atomic request which does pass all checks. And
then do a minimal change which does not pass anymore.
So what you could do here is have 3 connectors 1 crtc, but only the first
two connectors can be cloned. Then do an atomic request with those two
connectors and the crtc. Then the 2nd request is with one of the
connectors replaced with the 3rd one (so it's still a clone config, but
not an invalid one), then have a failure.
Note: I didn't check all the details, I might be getting something wrong
here, but the idea should work.
Cheers, Sima
> >
> > Thanks,
> >
> > Jessica Zhang
> >
> > >
> > > Maxime
> >
--
Simona Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2024-12-16 14:27 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-24 22:59 [PATCH v2 00/22] drm/msm/dpu: Add Concurrent Writeback Support for DPU 10.x+ Jessica Zhang
2024-09-24 22:59 ` [PATCH v2 01/22] drm: add clone mode check for CRTC Jessica Zhang
2024-09-24 23:06 ` Dmitry Baryshkov
2024-09-25 7:22 ` Maxime Ripard
2024-09-25 8:12 ` Jani Nikula
2024-09-25 20:47 ` Jessica Zhang
2024-09-24 22:59 ` [PATCH v2 02/22] drm: Add valid clones check Jessica Zhang
2024-09-25 7:23 ` Maxime Ripard
2024-12-07 0:48 ` Jessica Zhang
2024-12-16 2:19 ` Abhinav Kumar
2024-12-16 14:27 ` Simona Vetter [this message]
2024-12-16 19:44 ` Jessica Zhang
2024-12-16 14:47 ` Maxime Ripard
2024-12-16 19:47 ` Jessica Zhang
2024-09-24 22:59 ` [PATCH v2 03/22] drm/msm/dpu: get rid of struct dpu_rm_requirements Jessica Zhang
2024-09-24 22:59 ` [PATCH v2 04/22] drm/msm/dpu: switch RM to use crtc_id rather than enc_id for allocation Jessica Zhang
2024-09-24 22:59 ` [PATCH v2 05/22] drm/msm/dpu: move resource allocation to CRTC Jessica Zhang
2024-09-24 23:13 ` Dmitry Baryshkov
2024-09-25 20:38 ` Jessica Zhang
2024-09-25 21:11 ` Dmitry Baryshkov
2024-09-25 21:49 ` Abhinav Kumar
2024-09-26 7:12 ` Dmitry Baryshkov
2024-09-24 22:59 ` [PATCH v2 06/22] drm/msm/dpu: fill CRTC resources in dpu_crtc.c Jessica Zhang
2024-09-24 23:16 ` Dmitry Baryshkov
2024-09-25 0:37 ` Jessica Zhang
2024-09-25 8:17 ` Dmitry Baryshkov
2024-09-24 22:59 ` [PATCH v2 07/22] drm/msm/dpu: Add CWB entry to catalog for SM8650 Jessica Zhang
2024-09-24 23:17 ` Dmitry Baryshkov
2024-09-24 22:59 ` [PATCH v2 08/22] drm/msm/dpu: Specify dedicated CWB pingpong blocks Jessica Zhang
2024-09-24 23:17 ` Dmitry Baryshkov
2024-09-24 22:59 ` [PATCH v2 09/22] drm/msm/dpu: add devcoredumps for cwb registers Jessica Zhang
2024-09-24 22:59 ` [PATCH v2 10/22] drm/msm/dpu: Add dpu_hw_cwb abstraction for CWB block Jessica Zhang
2024-09-24 23:19 ` Dmitry Baryshkov
2024-09-24 22:59 ` [PATCH v2 11/22] drm/msm/dpu: add CWB support to dpu_hw_wb Jessica Zhang
2024-09-24 23:20 ` Dmitry Baryshkov
2024-09-24 22:59 ` [PATCH v2 12/22] drm/msm/dpu: Add RM support for allocating CWB Jessica Zhang
2024-09-24 23:20 ` Dmitry Baryshkov
2024-09-24 22:59 ` [PATCH v2 13/22] drm/msm/dpu: Add CWB to msm_display_topology Jessica Zhang
2024-09-24 23:22 ` Dmitry Baryshkov
2024-09-24 22:59 ` [PATCH v2 14/22] drm/msm/dpu: Require modeset if clone mode status changes Jessica Zhang
2024-09-24 23:25 ` Dmitry Baryshkov
2024-09-25 0:05 ` Abhinav Kumar
2024-09-25 8:28 ` Dmitry Baryshkov
2024-09-24 22:59 ` [PATCH v2 15/22] drm/msm/dpu: Reserve resources for CWB Jessica Zhang
2024-09-24 23:33 ` Dmitry Baryshkov
2024-09-24 22:59 ` [PATCH v2 16/22] drm/msm/dpu: Configure CWB in writeback encoder Jessica Zhang
2024-09-24 23:41 ` Dmitry Baryshkov
2024-09-25 0:14 ` Jessica Zhang
2024-09-25 8:30 ` Dmitry Baryshkov
2024-09-30 14:17 ` neil.armstrong
2024-09-30 19:19 ` Jessica Zhang
2024-10-01 7:37 ` neil.armstrong
2024-10-08 8:00 ` Neil Armstrong
2024-10-08 8:18 ` Maxime Ripard
2024-10-08 12:25 ` Jessica Zhang
2024-10-09 7:46 ` neil.armstrong
2024-09-24 22:59 ` [PATCH v2 17/22] drm/msm/dpu: Support CWB in dpu_hw_ctl Jessica Zhang
2024-09-24 22:59 ` [PATCH v2 18/22] drm/msm/dpu: Adjust writeback phys encoder setup for CWB Jessica Zhang
2024-09-24 22:59 ` [PATCH v2 19/22] drm/msm/dpu: Start frame done timer after encoder kickoff Jessica Zhang
2024-09-24 22:59 ` [PATCH v2 20/22] drm/msm/dpu: Skip trigger flush and start for CWB Jessica Zhang
2024-09-24 23:43 ` Dmitry Baryshkov
2024-09-24 22:59 ` [PATCH v2 21/22] drm/msm/dpu: Reorder encoder kickoff " Jessica Zhang
2024-09-24 22:59 ` [PATCH v2 22/22] drm/msm/dpu: Set possible clones for all encoders Jessica Zhang
2024-09-24 23:44 ` 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=Z2A4uahCHuOz45Fc@phenom.ffwll.local \
--to=simona.vetter@ffwll.ch \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dmitry.baryshkov@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=marijn.suijten@somainline.org \
--cc=mripard@kernel.org \
--cc=quic_abhinavk@quicinc.com \
--cc=quic_ebharadw@quicinc.com \
--cc=quic_jesszhan@quicinc.com \
--cc=robdclark@chromium.org \
--cc=robdclark@gmail.com \
--cc=sean@poorly.run \
--cc=tzimmermann@suse.de \
--cc=ville.syrjala@linux.intel.com \
/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