* drm/mgag200: don't use uninitialized variables in mga_g200se_set_plls()
@ 2015-10-19 10:29 Jan Beulich
2015-10-20 14:47 ` Mathieu Larouche
0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2015-10-19 10:29 UTC (permalink / raw)
To: airlied; +Cc: mathieu.larouche, dri-devel
I can only guess that instead of testm/testn (which are either
uninitialized or have pre-determined values at the end of the preceding
loops) n and m were meant to be used by commit e829d7ef9f
("drm/mgag200: Add support for a new rev of G200e"). In any event the
compiler is right in warning that testm/testn are possibly uninitalized
at this point, i.e. some change is needed no matter what.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Cc: Mathieu Larouche <mathieu.larouche@matrox.com>
---
drivers/gpu/drm/mgag200/mgag200_mode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- 4.3-rc6/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ 4.3-rc6-mgag200-uninit/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -194,7 +194,7 @@ static int mga_g200se_set_plls(struct mg
}
}
- fvv = pllreffreq * testn / testm;
+ fvv = pllreffreq * n / m;
fvv = (fvv - 800000) / 50000;
if (fvv > 15)
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: drm/mgag200: don't use uninitialized variables in mga_g200se_set_plls()
2015-10-19 10:29 drm/mgag200: don't use uninitialized variables in mga_g200se_set_plls() Jan Beulich
@ 2015-10-20 14:47 ` Mathieu Larouche
2015-10-20 15:00 ` Jan Beulich
0 siblings, 1 reply; 5+ messages in thread
From: Mathieu Larouche @ 2015-10-20 14:47 UTC (permalink / raw)
To: Jan Beulich, airlied; +Cc: dri-devel
On 19/10/2015 6:29 AM, Jan Beulich wrote:
> I can only guess that instead of testm/testn (which are either
> uninitialized or have pre-determined values at the end of the preceding
> loops) n and m were meant to be used by commit e829d7ef9f
> ("drm/mgag200: Add support for a new rev of G200e"). In any event the
> compiler is right in warning that testm/testn are possibly uninitalized
> at this point, i.e. some change is needed no matter what.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Cc: Mathieu Larouche <mathieu.larouche@matrox.com>
> ---
> drivers/gpu/drm/mgag200/mgag200_mode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- 4.3-rc6/drivers/gpu/drm/mgag200/mgag200_mode.c
> +++ 4.3-rc6-mgag200-uninit/drivers/gpu/drm/mgag200/mgag200_mode.c
> @@ -194,7 +194,7 @@ static int mga_g200se_set_plls(struct mg
> }
> }
>
> - fvv = pllreffreq * testn / testm;
> + fvv = pllreffreq * n / m;
> fvv = (fvv - 800000) / 50000;
>
> if (fvv > 15)
>
>
>
>
If you are using n/m instead of testn/testm, you need to
add 1 to the variables to keep consistency. However, you
have the same issue where m/n could be used without being
initialized. So, I propose to keep testm, testn & testp
and initialized them with the default value.
Signed-off-by: Mathieu Larouche <mathieu.larouche@matrox.com>
---
drivers/gpu/drm/mgag200/mgag200_mode.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
index c99d3fe..055799c 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -123,6 +123,9 @@ static int mga_g200se_set_plls(struct mga_device *mdev, long clock)
vcomax = 320000;
vcomin = 160000;
pllreffreq = 25000;
+ testm = 1;
+ testn = 17;
+ testp = 8;
delta = 0xffffffff;
permitteddelta = clock * 5 / 1000;
@@ -157,6 +160,9 @@ static int mga_g200se_set_plls(struct mga_device *mdev, long clock)
vcomax = 1600000;
vcomin = 800000;
pllreffreq = 25000;
+ testm = 1;
+ testn = 50;
+ testp = 16;
if (clock < 25000)
clock = 25000;
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: drm/mgag200: don't use uninitialized variables in mga_g200se_set_plls()
2015-10-20 14:47 ` Mathieu Larouche
@ 2015-10-20 15:00 ` Jan Beulich
2015-10-20 15:12 ` Mathieu Larouche
0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2015-10-20 15:00 UTC (permalink / raw)
To: Mathieu Larouche; +Cc: dri-devel
>>> On 20.10.15 at 16:47, <mathieu.larouche@matrox.com> wrote:
> On 19/10/2015 6:29 AM, Jan Beulich wrote:
>> --- 4.3-rc6/drivers/gpu/drm/mgag200/mgag200_mode.c
>> +++ 4.3-rc6-mgag200-uninit/drivers/gpu/drm/mgag200/mgag200_mode.c
>> @@ -194,7 +194,7 @@ static int mga_g200se_set_plls(struct mg
>> }
>> }
>>
>> - fvv = pllreffreq * testn / testm;
>> + fvv = pllreffreq * n / m;
>> fvv = (fvv - 800000) / 50000;
>>
>> if (fvv > 15)
>>
> If you are using n/m instead of testn/testm, you need to
> add 1 to the variables to keep consistency. However, you
> have the same issue where m/n could be used without being
> initialized. So, I propose to keep testm, testn & testp
> and initialized them with the default value.
That makes them initialized, but since testn and testm are used
as loop variables I don't see how initializing them to default
values helps overcome the other half of the problem described
(them having a constant, pre-determined value at the end of
the loops: testn=257, testm=33). As to testp - it is always
initialized anyway (so long as P_ARRAY_SIZE is not zero). And
in the if() branch initialization isn't needed either, since the
variables aren't being used after the loops.
Jan
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: drm/mgag200: don't use uninitialized variables in mga_g200se_set_plls()
2015-10-20 15:00 ` Jan Beulich
@ 2015-10-20 15:12 ` Mathieu Larouche
2015-10-20 15:55 ` [PATCH v2] " Jan Beulich
0 siblings, 1 reply; 5+ messages in thread
From: Mathieu Larouche @ 2015-10-20 15:12 UTC (permalink / raw)
To: Jan Beulich; +Cc: dri-devel
On 20/10/2015 11:00 AM, Jan Beulich wrote:
>>>> On 20.10.15 at 16:47, <mathieu.larouche@matrox.com> wrote:
>> On 19/10/2015 6:29 AM, Jan Beulich wrote:
>>> --- 4.3-rc6/drivers/gpu/drm/mgag200/mgag200_mode.c
>>> +++ 4.3-rc6-mgag200-uninit/drivers/gpu/drm/mgag200/mgag200_mode.c
>>> @@ -194,7 +194,7 @@ static int mga_g200se_set_plls(struct mg
>>> }
>>> }
>>>
>>> - fvv = pllreffreq * testn / testm;
>>> + fvv = pllreffreq * n / m;
>>> fvv = (fvv - 800000) / 50000;
>>>
>>> if (fvv > 15)
>>>
>> If you are using n/m instead of testn/testm, you need to
>> add 1 to the variables to keep consistency. However, you
>> have the same issue where m/n could be used without being
>> initialized. So, I propose to keep testm, testn & testp
>> and initialized them with the default value.
> That makes them initialized, but since testn and testm are used
> as loop variables I don't see how initializing them to default
> values helps overcome the other half of the problem described
> (them having a constant, pre-determined value at the end of
> the loops: testn=257, testm=33). As to testp - it is always
> initialized anyway (so long as P_ARRAY_SIZE is not zero). And
> in the if() branch initialization isn't needed either, since the
> variables aren't being used after the loops.
>
> Jan
>
>
Sorry, I missed that part in your initial comment and you are right,
there's an issue there. So, your proposed patch totally make sense,
you only need to add 1 to m/n.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] drm/mgag200: don't use uninitialized variables in mga_g200se_set_plls()
2015-10-20 15:12 ` Mathieu Larouche
@ 2015-10-20 15:55 ` Jan Beulich
0 siblings, 0 replies; 5+ messages in thread
From: Jan Beulich @ 2015-10-20 15:55 UTC (permalink / raw)
To: airlied, Mathieu Larouche; +Cc: dri-devel
I can only guess that instead of testm/testn (which are either
uninitialized or have pre-determined values at the end of the preceding
loops) n and m were meant to be used by commit e829d7ef9f
("drm/mgag200: Add support for a new rev of G200e"). In any event the
compiler is right in warning that testm/testn are possibly uninitalized
at this point, i.e. some change is needed no matter what.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Cc: Mathieu Larouche <mathieu.larouche@matrox.com>
---
v2: As pointed out by Mathieu, 1 needs to be added to both m and n when
consuming them.
---
drivers/gpu/drm/mgag200/mgag200_mode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- 4.3-rc6/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ 4.3-rc6-mgag200-uninit/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -194,7 +194,7 @@ static int mga_g200se_set_plls(struct mg
}
}
- fvv = pllreffreq * testn / testm;
+ fvv = pllreffreq * (n + 1) / (m + 1);
fvv = (fvv - 800000) / 50000;
if (fvv > 15)
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-10-20 15:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-19 10:29 drm/mgag200: don't use uninitialized variables in mga_g200se_set_plls() Jan Beulich
2015-10-20 14:47 ` Mathieu Larouche
2015-10-20 15:00 ` Jan Beulich
2015-10-20 15:12 ` Mathieu Larouche
2015-10-20 15:55 ` [PATCH v2] " Jan Beulich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox