From: Frank Li <Frank.li@nxp.com>
To: Liu Ying <victor.liu@nxp.com>
Cc: Marco Felsch <m.felsch@pengutronix.de>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>, Peng Fan <peng.fan@nxp.com>,
Andrzej Hajda <andrzej.hajda@intel.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Robert Foss <rfoss@kernel.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
luca.ceresoli@bootlin.com, devicetree@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v11 2/3] drm/bridge: imx: Add i.MX93 parallel display format configuration support
Date: Tue, 3 Mar 2026 22:53:53 -0500 [thread overview]
Message-ID: <aaes0RIBTcgOZje9@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <fdcf60da-bc0b-4b99-803d-e2d1948d5633@nxp.com>
On Wed, Mar 04, 2026 at 11:29:03AM +0800, Liu Ying wrote:
> On Tue, Mar 03, 2026 at 05:20:09PM -0500, Frank Li wrote:
> > On Tue, Mar 03, 2026 at 10:22:02PM +0100, Marco Felsch wrote:
> >> On 26-03-03, Frank Li wrote:
> >>> From: Frank Li (AI-BOT) <frank.li@nxp.com>
> >>>
> >>> AI bot review and may be useless.
> >>
> >> Hi Frank,
> >>
> >> albeit I'm very open to new technology, I would appreciate it if your
> >> AI-BOT is used internally first till you're convinced that it reports
> >> real issues instead of false-positives.
> >>
> >> Regards,
> >> Marco
> >>
> >>>> +static u32 *
> >>>> +imx93_pdfc_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
> >>>> + struct drm_bridge_state *bridge_state,
> >>>> + struct drm_crtc_state *crtc_state,
> >>>> + struct drm_connector_state *conn_state,
> >>>> + u32 output_fmt,
> >>>> + unsigned int *num_input_fmts)
> >>>> +{
> >>>> + struct imx93_pdfc *pdfc = bridge_to_imx93_pdfc(bridge);
> >>>> + u32 *input_fmts;
> >>>> +
> >>>> + *num_input_fmts = 0;
> >>>> +
> >>>> + input_fmts = kmalloc_obj(*input_fmts);
> >>>> + if (!input_fmts)
> >>>> + return NULL;
> >>>
> >
> >> + input_fmts = kmalloc_obj(*input_fmts);
> >
> > AI:
> >
> > Actually, this looks incorrect. kmalloc_obj() allocates based on the type
> > of the pointer argument. Here you're passing *input_fmts (a u32), not
> > input_fmts (a u32 *).
>
> This comment is false. Per kmalloc_obj()'s kerneldoc, it's first argument
> is "Variable or type to allocate". In this particular case, the argument
> should be "*input_fmts (a u32)".
Yes, I wrongly think it is num_input_fmts and return array point for multi
formats, actually it is just 1 items for format.
imx93_pdfc_bridge_atomic_get_input_bus_fmts() is quite likely return many
format array especially has "s" after fmt.
Frank
>
> /**
> * kmalloc_obj - Allocate a single instance of the given type
> * @VAR_OR_TYPE: Variable or type to allocate.
> * @GFP: GFP flags for the allocation.
> *
> * Returns: newly allocated pointer to a @VAR_OR_TYPE on success, or NULL
> * on failure.
> */
> #define kmalloc_obj(VAR_OR_TYPE, ...) \
> __alloc_objs(kmalloc, default_gfp(__VA_ARGS__), typeof(VAR_OR_TYPE), 1)
>
> > Should be:
> >
> > + input_fmts = kmalloc_array(*num_input_fmts, sizeof(*input_fmts),
> > + GFP_KERNEL);
>
> No. "input_fmts = kmalloc_obj(*input_fmts);" is just fine.
>
> >
> > suppose you use kmalloc_objs()
>
> No. We should use kmalloc_obj(), not kmalloc_objs().
>
> >
> > Frank
> >
> >>> Missing kfree(input_fmts) in error path if the switch statement
> >>> or subsequent logic fails. Consider allocating a fixed-size array
> >>> or using devm_kzalloc() instead.
> >>>
> >>>> + *num_input_fmts = 1;
> >>>> +
> >>>> + if (!imx93_pdfc_bus_output_fmt_supported(output_fmt)) {
> >>>> + dev_dbg(pdfc->dev, "No valid output bus-fmt detected, fallback to MEDIA_BUS_FMT_RGB888_1X24\n");
> >>>
> >>> Line exceeds 80 characters (97 chars). Break into two lines.
> >>>
> >>>> + input_fmts[0] = MEDIA_BUS_FMT_RGB888_1X24;
> >>>> + return input_fmts;
> >>>> + }
> >>>> +
> >>>> + switch (output_fmt) {
> >>>> + case MEDIA_BUS_FMT_RGB888_1X24:
> >>>> + case MEDIA_BUS_FMT_RGB565_1X16:
> >>>> + input_fmts[0] = output_fmt;
> >>>> + break;
> >>>> + case MEDIA_BUS_FMT_RGB666_1X18:
> >>>> + case MEDIA_BUS_FMT_FIXED:
> >>>> + input_fmts[0] = MEDIA_BUS_FMT_RGB888_1X24;
> >>>> + break;
> >>>> + }
> >>>
> >>> Switch statement lacks default case. Add default case to handle
> >>> unexpected format values explicitly.
> >>>
> >>>> +static int imx93_pdfc_bridge_atomic_enable(struct drm_bridge *bridge,
> >>>> + struct drm_atomic_state *state)
> >>>> +{
> >>>> + struct imx93_pdfc *pdfc = bridge_to_imx93_pdfc(bridge);
> >>>> + const struct drm_bridge_state *bridge_state;
> >>>> + unsigned int mask = PARALLEL_DISP_FORMAT;
> >>>> + unsigned int val;
> >>>> +
> >>>> + bridge_state = drm_atomic_get_new_bridge_state(state, bridge);
> >>>> +
> >>>> + switch (bridge_state->output_bus_cfg.format) {
> >>>> + case MEDIA_BUS_FMT_RGB888_1X24:
> >>>> + case MEDIA_BUS_FMT_FIXED:
> >>>> + val = FORMAT_RGB888_TO_RGB888;
> >>>> + if (pdfc->phy_bus_width == 18) {
> >>>> + /*
> >>>> + * Can be valid if physical bus limitation exists,
> >>>> + * therefore use dev_dbg().
> >>>> + */
> >>>> + dev_dbg(pdfc->dev, "Truncate two LSBs from each color\n");
> >>>> + val = FORMAT_RGB888_TO_RGB666;
> >>>> + }
> >>>> + break;
> >>>> + case MEDIA_BUS_FMT_RGB666_1X18:
> >>>> + val = FORMAT_RGB888_TO_RGB666;
> >>>> +
> >>>
> >>
> >> --
> >> #gernperDu
> >> #CallMeByMyFirstName
> >>
> >> Pengutronix e.K. | |
> >> Steuerwalder Str. 21 | https://www.pengutronix.de/ |
> >> 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> >> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
>
> --
> Regards,
> Liu Ying
next prev parent reply other threads:[~2026-03-04 3:54 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 10:34 [PATCH v11 0/3] Add i.MX91/93 parallel display support Marco Felsch
2026-03-03 10:34 ` [PATCH v11 1/3] dt-bindings: soc: imx93-media-blk-ctrl: Add PDFC subnode to schema and example Marco Felsch
2026-03-03 21:00 ` Frank Li
2026-03-04 15:48 ` Krzysztof Kozlowski
2026-03-04 15:49 ` Krzysztof Kozlowski
2026-03-04 17:04 ` Frank Li
2026-03-03 10:34 ` [PATCH v11 2/3] drm/bridge: imx: Add i.MX93 parallel display format configuration support Marco Felsch
2026-03-03 21:00 ` Frank Li
2026-03-03 21:22 ` Marco Felsch
2026-03-03 22:07 ` Frank Li
2026-03-03 22:20 ` Frank Li
2026-03-04 3:29 ` Liu Ying
2026-03-04 3:53 ` Frank Li [this message]
2026-03-04 3:32 ` Liu Ying
2026-03-05 14:37 ` Alexander Stein
2026-03-10 2:57 ` Liu Ying
2026-03-10 11:53 ` Luca Ceresoli
2026-03-11 3:15 ` Liu Ying
2026-03-11 19:45 ` Marco Felsch
2026-03-12 9:15 ` Liu Ying
2026-03-12 16:41 ` Luca Ceresoli
2026-03-03 10:34 ` [PATCH v11 3/3] arm64: dts: imx93: Add parallel display output nodes Marco Felsch
2026-03-03 10:42 ` Marco Felsch
2026-03-03 15:45 ` Frank Li
2026-03-03 15:50 ` Marco Felsch
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=aaes0RIBTcgOZje9@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.ceresoli@bootlin.com \
--cc=m.felsch@pengutronix.de \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=peng.fan@nxp.com \
--cc=rfoss@kernel.org \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
--cc=victor.liu@nxp.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