From: "Luca Ceresoli" <luca.ceresoli@bootlin.com>
To: "Icenowy Zheng" <zhengxingda@iscas.ac.cn>,
"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>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Drew Fustini" <fustini@kernel.org>,
"Guo Ren" <guoren@kernel.org>, "Fu Wei" <wefu@redhat.com>
Cc: "Philipp Zabel" <p.zabel@pengutronix.de>,
"Dmitry Baryshkov" <lumag@kernel.org>,
"Michal Wilczynski" <m.wilczynski@samsung.com>,
"Han Gao" <gaohan@iscas.ac.cn>, "Yao Zi" <ziyao@disroot.org>,
<linux-kernel@vger.kernel.org>, <dri-devel@lists.freedesktop.org>,
<devicetree@vger.kernel.org>, <linux-riscv@lists.infradead.org>
Subject: Re: [PATCH v7 3/8] drm: verisilicon: add a driver for Verisilicon display controllers
Date: Tue, 10 Mar 2026 11:25:45 +0100 [thread overview]
Message-ID: <DGZ132GP5IU3.1299QBUOW9D0X@bootlin.com> (raw)
In-Reply-To: <301a33fc27bd01bb50d57779c2f9eb51a4fafaa5.camel@iscas.ac.cn>
Hello Icenowy,
On Mon Mar 9, 2026 at 5:35 PM CET, Icenowy Zheng wrote:
>> > +struct vsdc_dp_format {
>> > + u32 linux_fmt;
>> > + bool is_yuv;
>> > + u32 vsdc_fmt;
>> > +};
>>
>> Moving the bool after the two 'u32's would be better for packing and
>> spatial locality (especially in case more fields are added in the
>> future).
>
> Yes this seems to sound right, but doing such rework sounds quite big
> and unnecessary after it's applied...
Ugh, apologies, I sent my reply without noticing this patch had been
applied already. Anyway, as Thomas pointed out, you can still do this
change as a separate patch ifi you want. Or just not do anything, this can
be done later in case new fields are added. Without new fields the
reordering would not produce much benefit anyway.
>> > +static struct vsdc_dp_format vsdc_dp_supported_fmts[] = {
>> > + /* default to RGB888 */
>> > + { MEDIA_BUS_FMT_FIXED, false,
>> > VSDC_DISP_DP_CONFIG_FMT_RGB888 },
>> > + { MEDIA_BUS_FMT_RGB888_1X24, false,
>> > VSDC_DISP_DP_CONFIG_FMT_RGB888 },
>> > + { MEDIA_BUS_FMT_RGB565_1X16, false,
>> > VSDC_DISP_DP_CONFIG_FMT_RGB565 },
>> > + { MEDIA_BUS_FMT_RGB666_1X18, false,
>> > VSDC_DISP_DP_CONFIG_FMT_RGB666 },
>> > + { MEDIA_BUS_FMT_RGB101010_1X30,
>> > + false, VSDC_DISP_DP_CONFIG_FMT_RGB101010 },
>>
>> You can put up to 100 chars per line and avoid the newline here to
>> make
>> this table more readable. Same below.
>
> Ah I prefer to keep 80 CPL when I can, and the `coding-style.rst`
> document still suggests 80.
coding-style.rst seems very vague about that, but checkpatch is clear:
my $max_line_length = 100;
(https://elixir.bootlin.com/linux/v6.19.6/source/scripts/checkpatch.pl#L60)
Anyway, non need to send a patch now that it's committed for this,
definitely. Again, sorry for the noise on an already applied patch.
>> > +struct vs_bridge *vs_bridge_init(struct drm_device *drm_dev,
>> > + struct vs_crtc *crtc)
>> > +{
>> > + unsigned int output = crtc->id;
>> > + struct vs_bridge *bridge;
>>
>> In common practice a variable named 'bridge' is used to point to a
>> 'struct
>> drm_bridge', so it feels weird when it is used for another type. Can
>> you
>> rename to 'vbridge' or 'vsbridge' or similar, to clarify it's the
>> "Verisilicon bridge"?
>
> This sounds right.
>
> BTW where is such kind of common practice documented?
As it often happens, in the code, I'm afraid.
I've been touching a lot of DRM bridge and related code recently as part of
the bridge hotplug work I'm doing, and I gathered an overall view of the
current common practice as well as which conventions are more readable than
others.
>> > + return ERR_PTR(ret);
>> > + }
>> > +
>> > + if (intf == VSDC_OUTPUT_INTERFACE_DPI)
>> > + bridge_funcs = &vs_dpi_bridge_funcs;
>> > + else
>> > + bridge_funcs = &vs_dp_bridge_funcs;
>> > +
>> > + bridge = devm_drm_bridge_alloc(drm_dev->dev, struct
>> > vs_bridge, base,
>> > + bridge_funcs);
>>
>> The 'struct drm_bridge' field embedded in a driver-specific struct is
>> conventionally called 'bridge', so renaming it from 'base' to
>> 'bridge'
>> would make it more consistent with other drivers. That would go in
>> sync
>> with the coding convention I mentioned above: 'bridge' for struct
>> drm_bridge, <XYZ>bridge or just <XYZZ> for a custom driver struct
>> embedding
>> a bridge.
>
> Ah, all subclasses in this driver call the base class `base`, and I
> still wonder how such convention is documented.
It's a gain the common practice in the code:
$ git grep -h -E '[[:space:]]struct drm_bridge \*[[:alnum:]_]*;' -- drivers/gpu/drm/ | \
sed 's/^[[:space:]]*//' | grep -v panel_bridge | sort | uniq -c | sort -nr
92 struct drm_bridge *bridge;
27 struct drm_bridge *next_bridge;
3 struct drm_bridge *companion;
2 struct drm_bridge *next;
2 struct drm_bridge *iter;
1 struct drm_bridge *tmp_bridge;
1 struct drm_bridge *out_bridge;
1 struct drm_bridge *ext_bridge;
1 struct drm_bridge *drm_bridge;
[...]
So 'bridge' is by far the most common, and 'base' does never appear.
>> There is now a next_bridge field in struct drm_bridge, which handles
>> the
>> bridge lifetime in a safer way and more simply [0], so you could use
>> it:
>
> Glad to hear such a field exists now. Will more code about next_bridge
> lifetime management being shared?
Not sure exactly what you mean here. If you are asking how next_bridge
works: it's very simple, all being in the declaration [0] (where I
explained it to the best I could in the comment) and its usage in the
destruction callback when the last reference is put [1].
[0] https://elixir.bootlin.com/linux/v7.0-rc3/source/include/drm/drm_bridge.h
[1] https://elixir.bootlin.com/linux/v7.0-rc3/source/drivers/gpu/drm/drm_bridge.c#L267
Best regards,
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2026-03-10 10:26 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-29 2:39 [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520) Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 1/8] dt-bindings: vendor-prefixes: add verisilicon Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 2/8] dt-bindings: display: add verisilicon,dc Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 3/8] drm: verisilicon: add a driver for Verisilicon display controllers Icenowy Zheng
2026-03-09 12:47 ` Luca Ceresoli
2026-03-09 16:35 ` Icenowy Zheng
2026-03-09 16:51 ` Icenowy Zheng
2026-03-10 10:25 ` Luca Ceresoli
2026-03-10 8:27 ` Thomas Zimmermann
2026-03-10 10:25 ` Luca Ceresoli [this message]
2026-01-29 2:39 ` [PATCH v7 4/8] dt-bindings: display/bridge: add binding for TH1520 HDMI controller Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 5/8] drm/bridge: add a driver for T-Head " Icenowy Zheng
2026-01-29 2:39 ` [PATCH v7 6/8] riscv: dts: thead: add DPU and HDMI device tree nodes Icenowy Zheng
2026-01-29 20:39 ` Drew Fustini
2026-03-09 14:40 ` Luca Ceresoli
2026-01-29 2:39 ` [PATCH v7 7/8] riscv: dts: thead: lichee-pi-4a: enable HDMI Icenowy Zheng
2026-01-29 20:40 ` Drew Fustini
2026-03-09 14:40 ` Luca Ceresoli
2026-01-29 2:39 ` [PATCH v7 8/8] mailmap: map all Icenowy Zheng's mail addresses Icenowy Zheng
2026-02-05 9:30 ` [PATCH v7 0/8] Verisilicon DC8200 driver (and adaption to TH1520) Thomas Zimmermann
2026-02-05 9:31 ` Icenowy Zheng
2026-02-08 1:02 ` Drew Fustini
2026-02-09 8:03 ` Thomas Zimmermann
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=DGZ132GP5IU3.1299QBUOW9D0X@bootlin.com \
--to=luca.ceresoli@bootlin.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=fustini@kernel.org \
--cc=gaohan@iscas.ac.cn \
--cc=guoren@kernel.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=lumag@kernel.org \
--cc=m.wilczynski@samsung.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=p.zabel@pengutronix.de \
--cc=rfoss@kernel.org \
--cc=robh@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
--cc=wefu@redhat.com \
--cc=zhengxingda@iscas.ac.cn \
--cc=ziyao@disroot.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