[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJMQK-gvhsk3U7QK9B-28kJ4fKbO8UB01i-_rMMe_GT2pM74gg@mail.gmail.com>
Date: Tue, 15 Feb 2022 21:05:08 +0800
From: Hsin-Yi Wang <hsinyi@...omium.org>
To: Emil Velikov <emil.l.velikov@...il.com>
Cc: ML dri-devel <dri-devel@...ts.freedesktop.org>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
amd-gfx mailing list <amd-gfx@...ts.freedesktop.org>,
Intel Graphics Development <intel-gfx@...ts.freedesktop.org>,
Chun-Kuang Hu <chunkuang.hu@...nel.org>,
devicetree <devicetree@...r.kernel.org>,
Simon Ser <contact@...rsion.fr>,
"Linux-Kernel@...r. Kernel. Org" <linux-kernel@...r.kernel.org>,
Maxime Ripard <mripard@...nel.org>,
Alex Deucher <alexander.deucher@....com>,
Rob Herring <robh+dt@...nel.org>,
linux-mediatek@...ts.infradead.org,
Thomas Zimmermann <tzimmermann@...e.de>,
Harry Wentland <harry.wentland@....com>,
Matthias Brugger <matthias.bgg@...il.com>,
LAKML <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [Intel-gfx] [PATCH v8 1/3] gpu: drm: separate panel orientation
property creating and value setting
On Tue, Feb 15, 2022 at 8:04 PM Emil Velikov <emil.l.velikov@...il.com> wrote:
>
> Greetings everyone,
>
> Padron for joining in so late o/
>
> On Tue, 8 Feb 2022 at 08:42, Hsin-Yi Wang <hsinyi@...omium.org> wrote:
> >
> > drm_dev_register() sets connector->registration_state to
> > DRM_CONNECTOR_REGISTERED and dev->registered to true. If
> > drm_connector_set_panel_orientation() is first called after
> > drm_dev_register(), it will fail several checks and results in following
> > warning.
> >
> > Add a function to create panel orientation property and set default value
> > to UNKNOWN, so drivers can call this function to init the property earlier
> > , and let the panel set the real value later.
> >
>
> The warning illustrates a genuine race condition, where userspace will
> read the old/invalid property value/state. So this patch masks away
> the WARNING without addressing the actual issue.
> Instead can we fix the respective drivers, so that no properties are
> created after drm_dev_register()?
>
1. How about the proposal in previous version:
v7 https://patchwork.kernel.org/project/linux-mediatek/patch/20220208073714.1540390-1-hsinyi@chromium.org/
we separate property creation
(drm_connector_init_panel_orientation_property) and value setting
(drm_connector_set_panel_orientation). This is also similar to some of
other optional properties are created, eg. vrr_capable.
And drm drivers have to make sure that if they want to use this
property, they have to create it before drm_dev_register(). For
example, in the 2nd patch, mtk_drm sets the property before calling
drm_dev_register().
2. I'm not sure how to handle the case that if user space tries to
read the property before the proper value is set. Currently drm
creates this property and the panels[1] will set the correct value
parsed from DT. If userspace calls before the panel sets the correct
value, it will get unknown (similar to the illustration you mentioned
below). Do you think that the drm should be responsible for parsing
the value if the panel provides it? In this way it's guaranteed that
the value is set when the property is created.
[1] https://elixir.bootlin.com/linux/latest/A/ident/drm_connector_set_panel_orientation
> Longer version:
> As we look into drm_dev_register() it's in charge of creating the
> dev/sysfs nodes (et al). Note that connectors cannot disappear at
> runtime.
> For panel orientation, we are creating an immutable connector
> properly, meaning that as soon as drm_dev_register() is called we must
> ensure that the property is available (if applicable) and set to the
> correct value.
>
> For illustration, consider the following scenario:
> - DRM modules are loaded late - are not built-in and not part of
> initrd (or there's no initrd)
> - kernel boots
> - plymouth/similar user-space component kicks in before the
> driver/module is loaded
> - module gets loaded, drm_dev_register() kicks in populating /dev/dri/card0
> - plymouth opens the dev node and reads DRM_MODE_PANEL_ORIENTATION_UNKNOWN
> - module updates the orientation property
>
> Thanks
> Emil
Powered by blists - more mailing lists