* [PATCH] drm/radeon: fix uninitialized bool variable
@ 2021-09-18 9:41 Zhiwei Yang
2021-09-20 7:44 ` Christian König
0 siblings, 1 reply; 4+ messages in thread
From: Zhiwei Yang @ 2021-09-18 9:41 UTC (permalink / raw)
To: David Airlie, Daniel Vetter, Alex Deucher
Cc: Christian König, amd-gfx, dri-devel, linux-kernel, Zhiwei Yang
The bool variable detected_hpd_without_ddc in struct radeon_connector
is uninitialized when first used, that may cause unnecessary ddc ops.
Make it as false when a new connector is alloced.
Signed-off-by: Zhiwei Yang <yangzhiwei@uniontech.com>
---
drivers/gpu/drm/radeon/radeon_connectors.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index fe12d9d91d7a..c1987a66373f 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -1866,6 +1866,7 @@ radeon_add_atom_connector(struct drm_device *dev,
bool shared_ddc = false;
bool is_dp_bridge = false;
bool has_aux = false;
+ bool detected_hpd_without_ddc = false;
if (connector_type == DRM_MODE_CONNECTOR_Unknown)
return;
@@ -1923,6 +1924,7 @@ radeon_add_atom_connector(struct drm_device *dev,
radeon_connector->shared_ddc = shared_ddc;
radeon_connector->connector_object_id = connector_object_id;
radeon_connector->hpd = *hpd;
+ radeon_connector->detected_hpd_without_ddc = detected_hpd_without_ddc;
radeon_connector->router = *router;
if (router->ddc_valid || router->cd_valid) {
@@ -2384,6 +2386,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
struct radeon_connector *radeon_connector;
struct i2c_adapter *ddc = NULL;
uint32_t subpixel_order = SubPixelNone;
+ bool detected_hpd_without_ddc = false;
if (connector_type == DRM_MODE_CONNECTOR_Unknown)
return;
@@ -2414,6 +2417,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
radeon_connector->devices = supported_device;
radeon_connector->connector_object_id = connector_object_id;
radeon_connector->hpd = *hpd;
+ radeon_connector->detected_hpd_without_ddc = detected_hpd_without_ddc;
switch (connector_type) {
case DRM_MODE_CONNECTOR_VGA:
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/radeon: fix uninitialized bool variable
2021-09-18 9:41 [PATCH] drm/radeon: fix uninitialized bool variable Zhiwei Yang
@ 2021-09-20 7:44 ` Christian König
2021-09-20 16:00 ` Alex Deucher
0 siblings, 1 reply; 4+ messages in thread
From: Christian König @ 2021-09-20 7:44 UTC (permalink / raw)
To: Zhiwei Yang, David Airlie, Daniel Vetter, Alex Deucher
Cc: Christian König, amd-gfx, dri-devel, linux-kernel
Am 18.09.21 um 11:41 schrieb Zhiwei Yang:
> The bool variable detected_hpd_without_ddc in struct radeon_connector
> is uninitialized when first used, that may cause unnecessary ddc ops.
> Make it as false when a new connector is alloced.
>
> Signed-off-by: Zhiwei Yang <yangzhiwei@uniontech.com>
> ---
> drivers/gpu/drm/radeon/radeon_connectors.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
> index fe12d9d91d7a..c1987a66373f 100644
> --- a/drivers/gpu/drm/radeon/radeon_connectors.c
> +++ b/drivers/gpu/drm/radeon/radeon_connectors.c
> @@ -1866,6 +1866,7 @@ radeon_add_atom_connector(struct drm_device *dev,
> bool shared_ddc = false;
> bool is_dp_bridge = false;
> bool has_aux = false;
> + bool detected_hpd_without_ddc = false;
In general good catch, but I don't see the need for a local variable here.
Just initialize the member directly or even better change the allocation
of the connector into a kzalloc().
Christian.
>
> if (connector_type == DRM_MODE_CONNECTOR_Unknown)
> return;
> @@ -1923,6 +1924,7 @@ radeon_add_atom_connector(struct drm_device *dev,
> radeon_connector->shared_ddc = shared_ddc;
> radeon_connector->connector_object_id = connector_object_id;
> radeon_connector->hpd = *hpd;
> + radeon_connector->detected_hpd_without_ddc = detected_hpd_without_ddc;
>
> radeon_connector->router = *router;
> if (router->ddc_valid || router->cd_valid) {
> @@ -2384,6 +2386,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
> struct radeon_connector *radeon_connector;
> struct i2c_adapter *ddc = NULL;
> uint32_t subpixel_order = SubPixelNone;
> + bool detected_hpd_without_ddc = false;
>
> if (connector_type == DRM_MODE_CONNECTOR_Unknown)
> return;
> @@ -2414,6 +2417,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
> radeon_connector->devices = supported_device;
> radeon_connector->connector_object_id = connector_object_id;
> radeon_connector->hpd = *hpd;
> + radeon_connector->detected_hpd_without_ddc = detected_hpd_without_ddc;
>
> switch (connector_type) {
> case DRM_MODE_CONNECTOR_VGA:
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/radeon: fix uninitialized bool variable
2021-09-20 7:44 ` Christian König
@ 2021-09-20 16:00 ` Alex Deucher
0 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2021-09-20 16:00 UTC (permalink / raw)
To: Christian König
Cc: Zhiwei Yang, David Airlie, Daniel Vetter, Alex Deucher,
Christian König, amd-gfx list, Maling list - DRI developers,
LKML
On Mon, Sep 20, 2021 at 3:44 AM Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
>
>
>
> Am 18.09.21 um 11:41 schrieb Zhiwei Yang:
> > The bool variable detected_hpd_without_ddc in struct radeon_connector
> > is uninitialized when first used, that may cause unnecessary ddc ops.
> > Make it as false when a new connector is alloced.
> >
> > Signed-off-by: Zhiwei Yang <yangzhiwei@uniontech.com>
> > ---
> > drivers/gpu/drm/radeon/radeon_connectors.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
> > index fe12d9d91d7a..c1987a66373f 100644
> > --- a/drivers/gpu/drm/radeon/radeon_connectors.c
> > +++ b/drivers/gpu/drm/radeon/radeon_connectors.c
> > @@ -1866,6 +1866,7 @@ radeon_add_atom_connector(struct drm_device *dev,
> > bool shared_ddc = false;
> > bool is_dp_bridge = false;
> > bool has_aux = false;
> > + bool detected_hpd_without_ddc = false;
>
> In general good catch, but I don't see the need for a local variable here.
>
> Just initialize the member directly or even better change the allocation
> of the connector into a kzalloc().
This is already the case:
radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL);
So I don't think this patch is necessary.
Alex
>
> Christian.
>
> >
> > if (connector_type == DRM_MODE_CONNECTOR_Unknown)
> > return;
> > @@ -1923,6 +1924,7 @@ radeon_add_atom_connector(struct drm_device *dev,
> > radeon_connector->shared_ddc = shared_ddc;
> > radeon_connector->connector_object_id = connector_object_id;
> > radeon_connector->hpd = *hpd;
> > + radeon_connector->detected_hpd_without_ddc = detected_hpd_without_ddc;
> >
> > radeon_connector->router = *router;
> > if (router->ddc_valid || router->cd_valid) {
> > @@ -2384,6 +2386,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
> > struct radeon_connector *radeon_connector;
> > struct i2c_adapter *ddc = NULL;
> > uint32_t subpixel_order = SubPixelNone;
> > + bool detected_hpd_without_ddc = false;
> >
> > if (connector_type == DRM_MODE_CONNECTOR_Unknown)
> > return;
> > @@ -2414,6 +2417,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
> > radeon_connector->devices = supported_device;
> > radeon_connector->connector_object_id = connector_object_id;
> > radeon_connector->hpd = *hpd;
> > + radeon_connector->detected_hpd_without_ddc = detected_hpd_without_ddc;
> >
> > switch (connector_type) {
> > case DRM_MODE_CONNECTOR_VGA:
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] drm/radeon: fix uninitialized bool variable
@ 2021-09-18 9:26 yangzhiwei
0 siblings, 0 replies; 4+ messages in thread
From: yangzhiwei @ 2021-09-18 9:26 UTC (permalink / raw)
To: airlied, daniel, alexander.deucher
Cc: christian.koenig, amd-gfx, dri-devel, linux-kernel, yangzhiwei
[-- Attachment #1: Type: text/html, Size: 233 bytes --]
[-- Attachment #2: 0001-drm-radeon-fix-uninitialized-bool-variable.patch --]
[-- Type: text/x-diff, Size: 2085 bytes --]
From 23dc76b1a4c7eb516b2830e1d2bb588316e18e93 Mon Sep 17 00:00:00 2001
From: Zhiwei Yang <yangzhiwei@uniontech.com>
Date: Sat, 18 Sep 2021 16:17:06 +0800
Subject: [PATCH] drm/radeon: fix uninitialized bool variable
The bool variable detected_hpd_without_ddc in struct radeon_connector
is uninitialized when first used, that may cause unnecessary ddc ops.
Make it as false when a new connector is alloced.
Signed-off-by: Zhiwei Yang <yangzhiwei@uniontech.com>
---
drivers/gpu/drm/radeon/radeon_connectors.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index fe12d9d91d7a..c1987a66373f 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -1866,6 +1866,7 @@ radeon_add_atom_connector(struct drm_device *dev,
bool shared_ddc = false;
bool is_dp_bridge = false;
bool has_aux = false;
+ bool detected_hpd_without_ddc = false;
if (connector_type == DRM_MODE_CONNECTOR_Unknown)
return;
@@ -1923,6 +1924,7 @@ radeon_add_atom_connector(struct drm_device *dev,
radeon_connector->shared_ddc = shared_ddc;
radeon_connector->connector_object_id = connector_object_id;
radeon_connector->hpd = *hpd;
+ radeon_connector->detected_hpd_without_ddc = detected_hpd_without_ddc;
radeon_connector->router = *router;
if (router->ddc_valid || router->cd_valid) {
@@ -2384,6 +2386,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
struct radeon_connector *radeon_connector;
struct i2c_adapter *ddc = NULL;
uint32_t subpixel_order = SubPixelNone;
+ bool detected_hpd_without_ddc = false;
if (connector_type == DRM_MODE_CONNECTOR_Unknown)
return;
@@ -2414,6 +2417,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
radeon_connector->devices = supported_device;
radeon_connector->connector_object_id = connector_object_id;
radeon_connector->hpd = *hpd;
+ radeon_connector->detected_hpd_without_ddc = detected_hpd_without_ddc;
switch (connector_type) {
case DRM_MODE_CONNECTOR_VGA:
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-20 16:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-18 9:41 [PATCH] drm/radeon: fix uninitialized bool variable Zhiwei Yang
2021-09-20 7:44 ` Christian König
2021-09-20 16:00 ` Alex Deucher
-- strict thread matches above, loose matches on Subject: below --
2021-09-18 9:26 yangzhiwei
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.