From: Gabriel Krisman Bertazi <krisman@collabora.com>
To: Hsin-Yi Wang <hsinyi@chromium.org>
Cc: Maxime Ripard <mripard@kernel.org>,
Chun-Kuang Hu <chunkuang.hu@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
devicetree@vger.kernel.org, David Airlie <airlied@linux.ie>,
Simon Ser <contact@emersion.fr>,
intel-gfx@lists.freedesktop.org,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org,
Alex Deucher <alexander.deucher@amd.com>,
Jani Nikula <jani.nikula@linux.intel.com>,
Rob Herring <robh+dt@kernel.org>,
linux-mediatek@lists.infradead.org,
dri-devel@lists.freedesktop.org, Daniel Vetter <daniel@ffwll.ch>,
Harry Wentland <harry.wentland@amd.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
Sean Paul <sean@poorly.run>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v8 1/3] gpu: drm: separate panel orientation property creating and value setting
Date: Mon, 14 Feb 2022 23:03:39 -0500 [thread overview]
Message-ID: <87czjoixno.fsf@collabora.com> (raw)
In-Reply-To: <CAJMQK-igpiYj-pkgG9amrQuVzf1Mc9BDDOwOdKLUbceKr=CHiQ@mail.gmail.com> (Hsin-Yi Wang's message of "Tue, 15 Feb 2022 11:15:02 +0800")
Hsin-Yi Wang <hsinyi@chromium.org> writes:
> On Tue, Feb 15, 2022 at 9:17 AM Gabriel Krisman Bertazi
> <krisman@collabora.com> wrote:
>>
>> Hsin-Yi Wang <hsinyi@chromium.org> writes:
>>
>> > 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.
>>
>> Hi,
>>
>> I stumbled upon this when investigating the same WARN_ON on amdgpu.
>> Thanks for the patch :)
>>
>> > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
>> > index a50c82bc2b2fec..572ead7ac10690 100644
>> > --- a/drivers/gpu/drm/drm_connector.c
>> > +++ b/drivers/gpu/drm/drm_connector.c
>> > @@ -1252,7 +1252,7 @@ static const struct drm_prop_enum_list dp_colorspaces[] = {
>> > * INPUT_PROP_DIRECT) will still map 1:1 to the actual LCD panel
>> > * coordinates, so if userspace rotates the picture to adjust for
>> > * the orientation it must also apply the same transformation to the
>> > - * touchscreen input coordinates. This property is initialized by calling
>> > + * touchscreen input coordinates. This property value is set by calling
>> > * drm_connector_set_panel_orientation() or
>> > * drm_connector_set_panel_orientation_with_quirk()
>> > *
>> > @@ -2341,8 +2341,8 @@ EXPORT_SYMBOL(drm_connector_set_vrr_capable_property);
>> > * @connector: connector for which to set the panel-orientation property.
>> > * @panel_orientation: drm_panel_orientation value to set
>> > *
>> > - * This function sets the connector's panel_orientation and attaches
>> > - * a "panel orientation" property to the connector.
>> > + * This function sets the connector's panel_orientation value. If the property
>> > + * doesn't exist, it will try to create one.
>> > *
>> > * Calling this function on a connector where the panel_orientation has
>> > * already been set is a no-op (e.g. the orientation has been overridden with
>> > @@ -2373,19 +2373,12 @@ int drm_connector_set_panel_orientation(
>> > info->panel_orientation = panel_orientation;
>> >
>> > prop = dev->mode_config.panel_orientation_property;
>> > - if (!prop) {
>> > - prop = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE,
>> > - "panel orientation",
>> > - drm_panel_orientation_enum_list,
>> > - ARRAY_SIZE(drm_panel_orientation_enum_list));
>> > - if (!prop)
>> > - return -ENOMEM;
>> > -
>> > - dev->mode_config.panel_orientation_property = prop;
>> > - }
>> > + if (!prop &&
>> > + drm_connector_init_panel_orientation_property(connector) < 0)
>> > + return -ENOMEM;
>> >
>>
>> In the case where the property has not been created beforehand, you
>> forgot to reinitialize prop here, after calling
>> drm_connector_init_panel_orientation_property(). This means
> hi Gabriel,
>
> drm_connector_init_panel_orientation_property() will create prop if
> it's null. If prop fails to be created there, it will return -ENOMEM.
Yes. But *after the property is successfully created*, the prop variable is still
NULL. And then you call the following, using prop, which is still NULL:
>> > + drm_object_property_set_value(&connector->base, prop,
>> > + info->panel_orientation);
This will do property->dev right on the first line of code, and dereference the
null prop pointer.
You must do
prop = dev->mode_config.panel_orientation_property;
again after drm_connector_init_panel_orientation_property successfully
returns, or call drm_object_property_set_value using
dev->mode_config.panel_orientation_property directly:
drm_object_property_set_value(&connector->base,
dev->mode_config.panel_orientation_property
info->panel_orientation);
--
Gabriel Krisman Bertazi
WARNING: multiple messages have this Message-ID (diff)
From: Gabriel Krisman Bertazi <krisman@collabora.com>
To: Hsin-Yi Wang <hsinyi@chromium.org>
Cc: Maxime Ripard <mripard@kernel.org>,
Chun-Kuang Hu <chunkuang.hu@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
devicetree@vger.kernel.org, David Airlie <airlied@linux.ie>,
Simon Ser <contact@emersion.fr>,
intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org,
amd-gfx@lists.freedesktop.org,
Alex Deucher <alexander.deucher@amd.com>,
Rob Herring <robh+dt@kernel.org>,
linux-mediatek@lists.infradead.org,
dri-devel@lists.freedesktop.org,
Harry Wentland <harry.wentland@amd.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [Intel-gfx] [PATCH v8 1/3] gpu: drm: separate panel orientation property creating and value setting
Date: Mon, 14 Feb 2022 23:03:39 -0500 [thread overview]
Message-ID: <87czjoixno.fsf@collabora.com> (raw)
In-Reply-To: <CAJMQK-igpiYj-pkgG9amrQuVzf1Mc9BDDOwOdKLUbceKr=CHiQ@mail.gmail.com> (Hsin-Yi Wang's message of "Tue, 15 Feb 2022 11:15:02 +0800")
Hsin-Yi Wang <hsinyi@chromium.org> writes:
> On Tue, Feb 15, 2022 at 9:17 AM Gabriel Krisman Bertazi
> <krisman@collabora.com> wrote:
>>
>> Hsin-Yi Wang <hsinyi@chromium.org> writes:
>>
>> > 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.
>>
>> Hi,
>>
>> I stumbled upon this when investigating the same WARN_ON on amdgpu.
>> Thanks for the patch :)
>>
>> > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
>> > index a50c82bc2b2fec..572ead7ac10690 100644
>> > --- a/drivers/gpu/drm/drm_connector.c
>> > +++ b/drivers/gpu/drm/drm_connector.c
>> > @@ -1252,7 +1252,7 @@ static const struct drm_prop_enum_list dp_colorspaces[] = {
>> > * INPUT_PROP_DIRECT) will still map 1:1 to the actual LCD panel
>> > * coordinates, so if userspace rotates the picture to adjust for
>> > * the orientation it must also apply the same transformation to the
>> > - * touchscreen input coordinates. This property is initialized by calling
>> > + * touchscreen input coordinates. This property value is set by calling
>> > * drm_connector_set_panel_orientation() or
>> > * drm_connector_set_panel_orientation_with_quirk()
>> > *
>> > @@ -2341,8 +2341,8 @@ EXPORT_SYMBOL(drm_connector_set_vrr_capable_property);
>> > * @connector: connector for which to set the panel-orientation property.
>> > * @panel_orientation: drm_panel_orientation value to set
>> > *
>> > - * This function sets the connector's panel_orientation and attaches
>> > - * a "panel orientation" property to the connector.
>> > + * This function sets the connector's panel_orientation value. If the property
>> > + * doesn't exist, it will try to create one.
>> > *
>> > * Calling this function on a connector where the panel_orientation has
>> > * already been set is a no-op (e.g. the orientation has been overridden with
>> > @@ -2373,19 +2373,12 @@ int drm_connector_set_panel_orientation(
>> > info->panel_orientation = panel_orientation;
>> >
>> > prop = dev->mode_config.panel_orientation_property;
>> > - if (!prop) {
>> > - prop = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE,
>> > - "panel orientation",
>> > - drm_panel_orientation_enum_list,
>> > - ARRAY_SIZE(drm_panel_orientation_enum_list));
>> > - if (!prop)
>> > - return -ENOMEM;
>> > -
>> > - dev->mode_config.panel_orientation_property = prop;
>> > - }
>> > + if (!prop &&
>> > + drm_connector_init_panel_orientation_property(connector) < 0)
>> > + return -ENOMEM;
>> >
>>
>> In the case where the property has not been created beforehand, you
>> forgot to reinitialize prop here, after calling
>> drm_connector_init_panel_orientation_property(). This means
> hi Gabriel,
>
> drm_connector_init_panel_orientation_property() will create prop if
> it's null. If prop fails to be created there, it will return -ENOMEM.
Yes. But *after the property is successfully created*, the prop variable is still
NULL. And then you call the following, using prop, which is still NULL:
>> > + drm_object_property_set_value(&connector->base, prop,
>> > + info->panel_orientation);
This will do property->dev right on the first line of code, and dereference the
null prop pointer.
You must do
prop = dev->mode_config.panel_orientation_property;
again after drm_connector_init_panel_orientation_property successfully
returns, or call drm_object_property_set_value using
dev->mode_config.panel_orientation_property directly:
drm_object_property_set_value(&connector->base,
dev->mode_config.panel_orientation_property
info->panel_orientation);
--
Gabriel Krisman Bertazi
WARNING: multiple messages have this Message-ID (diff)
From: Gabriel Krisman Bertazi <krisman@collabora.com>
To: Hsin-Yi Wang <hsinyi@chromium.org>
Cc: dri-devel@lists.freedesktop.org, David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
Chun-Kuang Hu <chunkuang.hu@kernel.org>,
Sean Paul <sean@poorly.run>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
Simon Ser <contact@emersion.fr>,
Harry Wentland <harry.wentland@amd.com>,
Alex Deucher <alexander.deucher@amd.com>,
Jani Nikula <jani.nikula@linux.intel.com>
Subject: Re: [PATCH v8 1/3] gpu: drm: separate panel orientation property creating and value setting
Date: Mon, 14 Feb 2022 23:03:39 -0500 [thread overview]
Message-ID: <87czjoixno.fsf@collabora.com> (raw)
In-Reply-To: <CAJMQK-igpiYj-pkgG9amrQuVzf1Mc9BDDOwOdKLUbceKr=CHiQ@mail.gmail.com> (Hsin-Yi Wang's message of "Tue, 15 Feb 2022 11:15:02 +0800")
Hsin-Yi Wang <hsinyi@chromium.org> writes:
> On Tue, Feb 15, 2022 at 9:17 AM Gabriel Krisman Bertazi
> <krisman@collabora.com> wrote:
>>
>> Hsin-Yi Wang <hsinyi@chromium.org> writes:
>>
>> > 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.
>>
>> Hi,
>>
>> I stumbled upon this when investigating the same WARN_ON on amdgpu.
>> Thanks for the patch :)
>>
>> > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
>> > index a50c82bc2b2fec..572ead7ac10690 100644
>> > --- a/drivers/gpu/drm/drm_connector.c
>> > +++ b/drivers/gpu/drm/drm_connector.c
>> > @@ -1252,7 +1252,7 @@ static const struct drm_prop_enum_list dp_colorspaces[] = {
>> > * INPUT_PROP_DIRECT) will still map 1:1 to the actual LCD panel
>> > * coordinates, so if userspace rotates the picture to adjust for
>> > * the orientation it must also apply the same transformation to the
>> > - * touchscreen input coordinates. This property is initialized by calling
>> > + * touchscreen input coordinates. This property value is set by calling
>> > * drm_connector_set_panel_orientation() or
>> > * drm_connector_set_panel_orientation_with_quirk()
>> > *
>> > @@ -2341,8 +2341,8 @@ EXPORT_SYMBOL(drm_connector_set_vrr_capable_property);
>> > * @connector: connector for which to set the panel-orientation property.
>> > * @panel_orientation: drm_panel_orientation value to set
>> > *
>> > - * This function sets the connector's panel_orientation and attaches
>> > - * a "panel orientation" property to the connector.
>> > + * This function sets the connector's panel_orientation value. If the property
>> > + * doesn't exist, it will try to create one.
>> > *
>> > * Calling this function on a connector where the panel_orientation has
>> > * already been set is a no-op (e.g. the orientation has been overridden with
>> > @@ -2373,19 +2373,12 @@ int drm_connector_set_panel_orientation(
>> > info->panel_orientation = panel_orientation;
>> >
>> > prop = dev->mode_config.panel_orientation_property;
>> > - if (!prop) {
>> > - prop = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE,
>> > - "panel orientation",
>> > - drm_panel_orientation_enum_list,
>> > - ARRAY_SIZE(drm_panel_orientation_enum_list));
>> > - if (!prop)
>> > - return -ENOMEM;
>> > -
>> > - dev->mode_config.panel_orientation_property = prop;
>> > - }
>> > + if (!prop &&
>> > + drm_connector_init_panel_orientation_property(connector) < 0)
>> > + return -ENOMEM;
>> >
>>
>> In the case where the property has not been created beforehand, you
>> forgot to reinitialize prop here, after calling
>> drm_connector_init_panel_orientation_property(). This means
> hi Gabriel,
>
> drm_connector_init_panel_orientation_property() will create prop if
> it's null. If prop fails to be created there, it will return -ENOMEM.
Yes. But *after the property is successfully created*, the prop variable is still
NULL. And then you call the following, using prop, which is still NULL:
>> > + drm_object_property_set_value(&connector->base, prop,
>> > + info->panel_orientation);
This will do property->dev right on the first line of code, and dereference the
null prop pointer.
You must do
prop = dev->mode_config.panel_orientation_property;
again after drm_connector_init_panel_orientation_property successfully
returns, or call drm_object_property_set_value using
dev->mode_config.panel_orientation_property directly:
drm_object_property_set_value(&connector->base,
dev->mode_config.panel_orientation_property
info->panel_orientation);
--
Gabriel Krisman Bertazi
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
WARNING: multiple messages have this Message-ID (diff)
From: Gabriel Krisman Bertazi <krisman@collabora.com>
To: Hsin-Yi Wang <hsinyi@chromium.org>
Cc: dri-devel@lists.freedesktop.org, David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
Chun-Kuang Hu <chunkuang.hu@kernel.org>,
Sean Paul <sean@poorly.run>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
Simon Ser <contact@emersion.fr>,
Harry Wentland <harry.wentland@amd.com>,
Alex Deucher <alexander.deucher@amd.com>,
Jani Nikula <jani.nikula@linux.intel.com>
Subject: Re: [PATCH v8 1/3] gpu: drm: separate panel orientation property creating and value setting
Date: Mon, 14 Feb 2022 23:03:39 -0500 [thread overview]
Message-ID: <87czjoixno.fsf@collabora.com> (raw)
In-Reply-To: <CAJMQK-igpiYj-pkgG9amrQuVzf1Mc9BDDOwOdKLUbceKr=CHiQ@mail.gmail.com> (Hsin-Yi Wang's message of "Tue, 15 Feb 2022 11:15:02 +0800")
Hsin-Yi Wang <hsinyi@chromium.org> writes:
> On Tue, Feb 15, 2022 at 9:17 AM Gabriel Krisman Bertazi
> <krisman@collabora.com> wrote:
>>
>> Hsin-Yi Wang <hsinyi@chromium.org> writes:
>>
>> > 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.
>>
>> Hi,
>>
>> I stumbled upon this when investigating the same WARN_ON on amdgpu.
>> Thanks for the patch :)
>>
>> > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
>> > index a50c82bc2b2fec..572ead7ac10690 100644
>> > --- a/drivers/gpu/drm/drm_connector.c
>> > +++ b/drivers/gpu/drm/drm_connector.c
>> > @@ -1252,7 +1252,7 @@ static const struct drm_prop_enum_list dp_colorspaces[] = {
>> > * INPUT_PROP_DIRECT) will still map 1:1 to the actual LCD panel
>> > * coordinates, so if userspace rotates the picture to adjust for
>> > * the orientation it must also apply the same transformation to the
>> > - * touchscreen input coordinates. This property is initialized by calling
>> > + * touchscreen input coordinates. This property value is set by calling
>> > * drm_connector_set_panel_orientation() or
>> > * drm_connector_set_panel_orientation_with_quirk()
>> > *
>> > @@ -2341,8 +2341,8 @@ EXPORT_SYMBOL(drm_connector_set_vrr_capable_property);
>> > * @connector: connector for which to set the panel-orientation property.
>> > * @panel_orientation: drm_panel_orientation value to set
>> > *
>> > - * This function sets the connector's panel_orientation and attaches
>> > - * a "panel orientation" property to the connector.
>> > + * This function sets the connector's panel_orientation value. If the property
>> > + * doesn't exist, it will try to create one.
>> > *
>> > * Calling this function on a connector where the panel_orientation has
>> > * already been set is a no-op (e.g. the orientation has been overridden with
>> > @@ -2373,19 +2373,12 @@ int drm_connector_set_panel_orientation(
>> > info->panel_orientation = panel_orientation;
>> >
>> > prop = dev->mode_config.panel_orientation_property;
>> > - if (!prop) {
>> > - prop = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE,
>> > - "panel orientation",
>> > - drm_panel_orientation_enum_list,
>> > - ARRAY_SIZE(drm_panel_orientation_enum_list));
>> > - if (!prop)
>> > - return -ENOMEM;
>> > -
>> > - dev->mode_config.panel_orientation_property = prop;
>> > - }
>> > + if (!prop &&
>> > + drm_connector_init_panel_orientation_property(connector) < 0)
>> > + return -ENOMEM;
>> >
>>
>> In the case where the property has not been created beforehand, you
>> forgot to reinitialize prop here, after calling
>> drm_connector_init_panel_orientation_property(). This means
> hi Gabriel,
>
> drm_connector_init_panel_orientation_property() will create prop if
> it's null. If prop fails to be created there, it will return -ENOMEM.
Yes. But *after the property is successfully created*, the prop variable is still
NULL. And then you call the following, using prop, which is still NULL:
>> > + drm_object_property_set_value(&connector->base, prop,
>> > + info->panel_orientation);
This will do property->dev right on the first line of code, and dereference the
null prop pointer.
You must do
prop = dev->mode_config.panel_orientation_property;
again after drm_connector_init_panel_orientation_property successfully
returns, or call drm_object_property_set_value using
dev->mode_config.panel_orientation_property directly:
drm_object_property_set_value(&connector->base,
dev->mode_config.panel_orientation_property
info->panel_orientation);
--
Gabriel Krisman Bertazi
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Gabriel Krisman Bertazi <krisman@collabora.com>
To: Hsin-Yi Wang <hsinyi@chromium.org>
Cc: dri-devel@lists.freedesktop.org, David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
Chun-Kuang Hu <chunkuang.hu@kernel.org>,
Sean Paul <sean@poorly.run>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
Simon Ser <contact@emersion.fr>,
Harry Wentland <harry.wentland@amd.com>,
Alex Deucher <alexander.deucher@amd.com>,
Jani Nikula <jani.nikula@linux.intel.com>
Subject: Re: [PATCH v8 1/3] gpu: drm: separate panel orientation property creating and value setting
Date: Mon, 14 Feb 2022 23:03:39 -0500 [thread overview]
Message-ID: <87czjoixno.fsf@collabora.com> (raw)
In-Reply-To: <CAJMQK-igpiYj-pkgG9amrQuVzf1Mc9BDDOwOdKLUbceKr=CHiQ@mail.gmail.com> (Hsin-Yi Wang's message of "Tue, 15 Feb 2022 11:15:02 +0800")
Hsin-Yi Wang <hsinyi@chromium.org> writes:
> On Tue, Feb 15, 2022 at 9:17 AM Gabriel Krisman Bertazi
> <krisman@collabora.com> wrote:
>>
>> Hsin-Yi Wang <hsinyi@chromium.org> writes:
>>
>> > 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.
>>
>> Hi,
>>
>> I stumbled upon this when investigating the same WARN_ON on amdgpu.
>> Thanks for the patch :)
>>
>> > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
>> > index a50c82bc2b2fec..572ead7ac10690 100644
>> > --- a/drivers/gpu/drm/drm_connector.c
>> > +++ b/drivers/gpu/drm/drm_connector.c
>> > @@ -1252,7 +1252,7 @@ static const struct drm_prop_enum_list dp_colorspaces[] = {
>> > * INPUT_PROP_DIRECT) will still map 1:1 to the actual LCD panel
>> > * coordinates, so if userspace rotates the picture to adjust for
>> > * the orientation it must also apply the same transformation to the
>> > - * touchscreen input coordinates. This property is initialized by calling
>> > + * touchscreen input coordinates. This property value is set by calling
>> > * drm_connector_set_panel_orientation() or
>> > * drm_connector_set_panel_orientation_with_quirk()
>> > *
>> > @@ -2341,8 +2341,8 @@ EXPORT_SYMBOL(drm_connector_set_vrr_capable_property);
>> > * @connector: connector for which to set the panel-orientation property.
>> > * @panel_orientation: drm_panel_orientation value to set
>> > *
>> > - * This function sets the connector's panel_orientation and attaches
>> > - * a "panel orientation" property to the connector.
>> > + * This function sets the connector's panel_orientation value. If the property
>> > + * doesn't exist, it will try to create one.
>> > *
>> > * Calling this function on a connector where the panel_orientation has
>> > * already been set is a no-op (e.g. the orientation has been overridden with
>> > @@ -2373,19 +2373,12 @@ int drm_connector_set_panel_orientation(
>> > info->panel_orientation = panel_orientation;
>> >
>> > prop = dev->mode_config.panel_orientation_property;
>> > - if (!prop) {
>> > - prop = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE,
>> > - "panel orientation",
>> > - drm_panel_orientation_enum_list,
>> > - ARRAY_SIZE(drm_panel_orientation_enum_list));
>> > - if (!prop)
>> > - return -ENOMEM;
>> > -
>> > - dev->mode_config.panel_orientation_property = prop;
>> > - }
>> > + if (!prop &&
>> > + drm_connector_init_panel_orientation_property(connector) < 0)
>> > + return -ENOMEM;
>> >
>>
>> In the case where the property has not been created beforehand, you
>> forgot to reinitialize prop here, after calling
>> drm_connector_init_panel_orientation_property(). This means
> hi Gabriel,
>
> drm_connector_init_panel_orientation_property() will create prop if
> it's null. If prop fails to be created there, it will return -ENOMEM.
Yes. But *after the property is successfully created*, the prop variable is still
NULL. And then you call the following, using prop, which is still NULL:
>> > + drm_object_property_set_value(&connector->base, prop,
>> > + info->panel_orientation);
This will do property->dev right on the first line of code, and dereference the
null prop pointer.
You must do
prop = dev->mode_config.panel_orientation_property;
again after drm_connector_init_panel_orientation_property successfully
returns, or call drm_object_property_set_value using
dev->mode_config.panel_orientation_property directly:
drm_object_property_set_value(&connector->base,
dev->mode_config.panel_orientation_property
info->panel_orientation);
--
Gabriel Krisman Bertazi
WARNING: multiple messages have this Message-ID (diff)
From: Gabriel Krisman Bertazi <krisman@collabora.com>
To: Hsin-Yi Wang <hsinyi@chromium.org>
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
devicetree@vger.kernel.org, David Airlie <airlied@linux.ie>,
intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org,
amd-gfx@lists.freedesktop.org,
Alex Deucher <alexander.deucher@amd.com>,
Rob Herring <robh+dt@kernel.org>,
linux-mediatek@lists.infradead.org,
dri-devel@lists.freedesktop.org,
Matthias Brugger <matthias.bgg@gmail.com>,
Sean Paul <sean@poorly.run>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v8 1/3] gpu: drm: separate panel orientation property creating and value setting
Date: Mon, 14 Feb 2022 23:03:39 -0500 [thread overview]
Message-ID: <87czjoixno.fsf@collabora.com> (raw)
In-Reply-To: <CAJMQK-igpiYj-pkgG9amrQuVzf1Mc9BDDOwOdKLUbceKr=CHiQ@mail.gmail.com> (Hsin-Yi Wang's message of "Tue, 15 Feb 2022 11:15:02 +0800")
Hsin-Yi Wang <hsinyi@chromium.org> writes:
> On Tue, Feb 15, 2022 at 9:17 AM Gabriel Krisman Bertazi
> <krisman@collabora.com> wrote:
>>
>> Hsin-Yi Wang <hsinyi@chromium.org> writes:
>>
>> > 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.
>>
>> Hi,
>>
>> I stumbled upon this when investigating the same WARN_ON on amdgpu.
>> Thanks for the patch :)
>>
>> > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
>> > index a50c82bc2b2fec..572ead7ac10690 100644
>> > --- a/drivers/gpu/drm/drm_connector.c
>> > +++ b/drivers/gpu/drm/drm_connector.c
>> > @@ -1252,7 +1252,7 @@ static const struct drm_prop_enum_list dp_colorspaces[] = {
>> > * INPUT_PROP_DIRECT) will still map 1:1 to the actual LCD panel
>> > * coordinates, so if userspace rotates the picture to adjust for
>> > * the orientation it must also apply the same transformation to the
>> > - * touchscreen input coordinates. This property is initialized by calling
>> > + * touchscreen input coordinates. This property value is set by calling
>> > * drm_connector_set_panel_orientation() or
>> > * drm_connector_set_panel_orientation_with_quirk()
>> > *
>> > @@ -2341,8 +2341,8 @@ EXPORT_SYMBOL(drm_connector_set_vrr_capable_property);
>> > * @connector: connector for which to set the panel-orientation property.
>> > * @panel_orientation: drm_panel_orientation value to set
>> > *
>> > - * This function sets the connector's panel_orientation and attaches
>> > - * a "panel orientation" property to the connector.
>> > + * This function sets the connector's panel_orientation value. If the property
>> > + * doesn't exist, it will try to create one.
>> > *
>> > * Calling this function on a connector where the panel_orientation has
>> > * already been set is a no-op (e.g. the orientation has been overridden with
>> > @@ -2373,19 +2373,12 @@ int drm_connector_set_panel_orientation(
>> > info->panel_orientation = panel_orientation;
>> >
>> > prop = dev->mode_config.panel_orientation_property;
>> > - if (!prop) {
>> > - prop = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE,
>> > - "panel orientation",
>> > - drm_panel_orientation_enum_list,
>> > - ARRAY_SIZE(drm_panel_orientation_enum_list));
>> > - if (!prop)
>> > - return -ENOMEM;
>> > -
>> > - dev->mode_config.panel_orientation_property = prop;
>> > - }
>> > + if (!prop &&
>> > + drm_connector_init_panel_orientation_property(connector) < 0)
>> > + return -ENOMEM;
>> >
>>
>> In the case where the property has not been created beforehand, you
>> forgot to reinitialize prop here, after calling
>> drm_connector_init_panel_orientation_property(). This means
> hi Gabriel,
>
> drm_connector_init_panel_orientation_property() will create prop if
> it's null. If prop fails to be created there, it will return -ENOMEM.
Yes. But *after the property is successfully created*, the prop variable is still
NULL. And then you call the following, using prop, which is still NULL:
>> > + drm_object_property_set_value(&connector->base, prop,
>> > + info->panel_orientation);
This will do property->dev right on the first line of code, and dereference the
null prop pointer.
You must do
prop = dev->mode_config.panel_orientation_property;
again after drm_connector_init_panel_orientation_property successfully
returns, or call drm_object_property_set_value using
dev->mode_config.panel_orientation_property directly:
drm_object_property_set_value(&connector->base,
dev->mode_config.panel_orientation_property
info->panel_orientation);
--
Gabriel Krisman Bertazi
next prev parent reply other threads:[~2022-02-15 8:31 UTC|newest]
Thread overview: 123+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-08 8:42 [PATCH v8 1/3] gpu: drm: separate panel orientation property creating and value setting Hsin-Yi Wang
2022-02-08 8:42 ` Hsin-Yi Wang
2022-02-08 8:42 ` Hsin-Yi Wang
2022-02-08 8:42 ` Hsin-Yi Wang
2022-02-08 8:42 ` Hsin-Yi Wang
2022-02-08 8:42 ` [Intel-gfx] " Hsin-Yi Wang
2022-02-08 8:42 ` [PATCH v8 2/3] drm/mediatek: init panel orientation property Hsin-Yi Wang
2022-02-08 8:42 ` Hsin-Yi Wang
2022-02-08 8:42 ` Hsin-Yi Wang
2022-02-08 8:42 ` Hsin-Yi Wang
2022-02-08 8:42 ` Hsin-Yi Wang
2022-02-08 8:42 ` [Intel-gfx] " Hsin-Yi Wang
2022-02-08 8:42 ` [PATCH v8 3/3] arm64: dts: mt8183: Add panel rotation Hsin-Yi Wang
2022-02-08 8:42 ` Hsin-Yi Wang
2022-02-08 8:42 ` Hsin-Yi Wang
2022-02-08 8:42 ` Hsin-Yi Wang
2022-02-08 8:42 ` Hsin-Yi Wang
2022-02-08 8:42 ` [Intel-gfx] " Hsin-Yi Wang
2022-02-08 9:49 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [v8,1/3] gpu: drm: separate panel orientation property creating and value setting Patchwork
2022-02-08 9:52 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-02-08 10:12 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-02-08 11:12 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2022-02-15 1:16 ` [PATCH v8 1/3] " Gabriel Krisman Bertazi
2022-02-15 1:16 ` Gabriel Krisman Bertazi
2022-02-15 1:16 ` Gabriel Krisman Bertazi
2022-02-15 1:16 ` Gabriel Krisman Bertazi
2022-02-15 1:16 ` Gabriel Krisman Bertazi
2022-02-15 1:16 ` [Intel-gfx] " Gabriel Krisman Bertazi
2022-02-15 3:15 ` Hsin-Yi Wang
2022-02-15 3:15 ` Hsin-Yi Wang
2022-02-15 3:15 ` Hsin-Yi Wang
2022-02-15 3:15 ` Hsin-Yi Wang
2022-02-15 3:15 ` Hsin-Yi Wang
2022-02-15 3:15 ` [Intel-gfx] " Hsin-Yi Wang
2022-02-15 4:03 ` Gabriel Krisman Bertazi [this message]
2022-02-15 4:03 ` Gabriel Krisman Bertazi
2022-02-15 4:03 ` Gabriel Krisman Bertazi
2022-02-15 4:03 ` Gabriel Krisman Bertazi
2022-02-15 4:03 ` Gabriel Krisman Bertazi
2022-02-15 4:03 ` [Intel-gfx] " Gabriel Krisman Bertazi
2022-02-15 13:08 ` Hsin-Yi Wang
2022-02-15 13:08 ` Hsin-Yi Wang
2022-02-15 13:08 ` Hsin-Yi Wang
2022-02-15 13:08 ` Hsin-Yi Wang
2022-02-15 13:08 ` Hsin-Yi Wang
2022-02-15 13:08 ` [Intel-gfx] " Hsin-Yi Wang
2022-02-15 12:04 ` Emil Velikov
2022-02-15 12:04 ` Emil Velikov
2022-02-15 12:04 ` Emil Velikov
2022-02-15 12:04 ` Emil Velikov
2022-02-15 12:04 ` Emil Velikov
2022-02-15 12:04 ` Emil Velikov
2022-02-15 13:05 ` Hsin-Yi Wang
2022-02-15 13:05 ` Hsin-Yi Wang
2022-02-15 13:05 ` Hsin-Yi Wang
2022-02-15 13:05 ` Hsin-Yi Wang
2022-02-15 13:05 ` Hsin-Yi Wang
2022-02-15 13:05 ` Hsin-Yi Wang
2022-02-15 13:55 ` Simon Ser
2022-02-15 13:55 ` Simon Ser
2022-02-15 13:55 ` Simon Ser
2022-02-15 13:55 ` Simon Ser
2022-02-15 13:55 ` Simon Ser
2022-02-15 13:55 ` Simon Ser
2022-02-15 14:38 ` Emil Velikov
2022-02-15 14:38 ` Emil Velikov
2022-02-15 14:38 ` Emil Velikov
2022-02-15 14:38 ` Emil Velikov
2022-02-15 14:38 ` Emil Velikov
2022-02-15 14:38 ` Emil Velikov
2022-02-15 16:37 ` Simon Ser
2022-02-15 16:37 ` Simon Ser
2022-02-15 16:37 ` Simon Ser
2022-02-15 16:37 ` Simon Ser
2022-02-15 16:37 ` Simon Ser
2022-02-15 16:37 ` Simon Ser
2022-02-16 12:00 ` Emil Velikov
2022-02-16 12:00 ` Emil Velikov
2022-02-16 12:00 ` Emil Velikov
2022-02-16 12:00 ` Emil Velikov
2022-02-16 12:00 ` Emil Velikov
2022-02-16 12:00 ` Emil Velikov
2022-02-18 10:38 ` Hans de Goede
2022-02-18 10:38 ` Hans de Goede
2022-02-18 10:38 ` Hans de Goede
2022-02-18 10:38 ` Hans de Goede
2022-02-18 10:38 ` Hans de Goede
2022-02-18 11:39 ` Simon Ser
2022-02-18 11:39 ` Simon Ser
2022-02-18 11:39 ` Simon Ser
2022-02-18 11:39 ` Simon Ser
2022-02-18 11:39 ` Simon Ser
2022-02-18 11:39 ` Simon Ser
2022-02-18 11:54 ` Hans de Goede
2022-02-18 11:54 ` Hans de Goede
2022-02-18 11:54 ` Hans de Goede
2022-02-18 11:54 ` Hans de Goede
2022-02-18 11:54 ` Hans de Goede
2022-02-18 11:54 ` Hans de Goede
2022-02-18 12:12 ` Simon Ser
2022-02-18 12:12 ` Simon Ser
2022-02-18 12:12 ` Simon Ser
2022-02-18 12:12 ` Simon Ser
2022-02-18 12:12 ` Simon Ser
2022-02-18 12:12 ` Simon Ser
2022-02-18 15:54 ` Alex Deucher
2022-02-18 15:54 ` Alex Deucher
2022-02-18 15:54 ` Alex Deucher
2022-02-18 15:54 ` Alex Deucher
2022-02-18 15:54 ` Alex Deucher
2022-02-18 15:54 ` Alex Deucher
2022-02-18 15:57 ` Harry Wentland
2022-02-18 15:57 ` Harry Wentland
2022-02-18 15:57 ` Harry Wentland
2022-02-18 15:57 ` Harry Wentland
2022-02-18 15:57 ` Harry Wentland
2022-02-18 15:57 ` Harry Wentland
2022-03-18 8:29 ` Hsin-Yi Wang
2022-03-18 8:29 ` Hsin-Yi Wang
2022-03-18 8:29 ` Hsin-Yi Wang
2022-03-18 8:29 ` Hsin-Yi Wang
2022-03-18 8:29 ` Hsin-Yi Wang
2022-03-18 8:29 ` Hsin-Yi Wang
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=87czjoixno.fsf@collabora.com \
--to=krisman@collabora.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=chunkuang.hu@kernel.org \
--cc=contact@emersion.fr \
--cc=daniel@ffwll.ch \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=harry.wentland@amd.com \
--cc=hsinyi@chromium.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthias.bgg@gmail.com \
--cc=mripard@kernel.org \
--cc=robh+dt@kernel.org \
--cc=sean@poorly.run \
--cc=tzimmermann@suse.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.