Re: [PATCH 06/10] drm/tegra: Handle 64-bit return from drm_crtc_vblank_count()

Thierry Reding
2018-02-07T09:41:25Z

[-- Attachment #1.1: Type: text/plain, Size: 1552 bytes --]

On Wed, Feb 07, 2018 at 01:41:18AM +0000, Pandiyan, Dhinakaran wrote:
> On Fri, 2018-02-02 at 21:12 -0800, Dhinakaran Pandiyan wrote:
> > 570e86963a51 ("drm: Widen vblank count to 64-bits [v3]") changed the
> > return type for drm_crtc_vblank_count() to u64. This could cause
> > potential problems if the return value is used in arithmetic operations
> > with a 32-bit reference HW vblank count. Explicitly typecasting this
> > down to u32 either fixes a potential problem or serves to add clarity in
> > case the implicit typecasting was already correct.
> >
> > Cc: Keith Packard <keithp@keithp.com>
> > Cc: Thierry Reding <treding@nvidia.com>
>
>
> Thierry,
>
> Can I get an Ack on this please?
>
> > Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> > ---
> > drivers/gpu/drm/tegra/dc.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
> > index b8403ed48285..49df2db2ad46 100644
> > --- a/drivers/gpu/drm/tegra/dc.c
> > +++ b/drivers/gpu/drm/tegra/dc.c
> > @@ -1359,7 +1359,7 @@ static u32 tegra_dc_get_vblank_counter(struct drm_crtc *crtc)
> > return host1x_syncpt_read(dc->syncpt);
> >
> > /* fallback to software emulated VBLANK counter */
> > - return drm_crtc_vblank_count(&dc->base);
> > + return (u32)drm_crtc_vblank_count(&dc->base);

Isn't this the wrong way around? Shouldn't we instead make the
->get_vblank_counter() callback return u64 like drm_crtc_vblank_count()?

Thierry

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]