dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: laurent.pinchart@ideasonboard.com, david@lechnology.com,
	oleksandr_andrushchenko@epam.com, airlied@linux.ie,
	sean@poorly.run, dri-devel@lists.freedesktop.org,
	virtualization@lists.linux-foundation.org, hdegoede@redhat.com,
	kraxel@redhat.com, xen-devel@lists.xenproject.org,
	sam@ravnborg.org, emil.velikov@collabora.com
Subject: Re: [PATCH v3 1/4] drm: Add drm_crtc_has_vblank()
Date: Wed, 22 Jan 2020 09:53:42 +0100	[thread overview]
Message-ID: <3ad03b06-f9be-37c7-9cc7-044468cdf300@suse.de> (raw)
In-Reply-To: <20200122083139.GP43062@phenom.ffwll.local>


[-- Attachment #1.1.1: Type: text/plain, Size: 4286 bytes --]

Hi

Am 22.01.20 um 09:31 schrieb Daniel Vetter:
> On Mon, Jan 20, 2020 at 01:20:48PM +0100, Thomas Zimmermann wrote:
>> The new interface drm_crtc_has_vblank() return true if vblanking has
>> been initialized for a certain CRTC, or false otherwise. This function
>> will be useful for initializing CRTC state.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> ---
>>  drivers/gpu/drm/drm_vblank.c | 21 +++++++++++++++++++++
>>  include/drm/drm_vblank.h     |  1 +
>>  2 files changed, 22 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
>> index 1659b13b178c..c20102899411 100644
>> --- a/drivers/gpu/drm/drm_vblank.c
>> +++ b/drivers/gpu/drm/drm_vblank.c
>> @@ -501,6 +501,27 @@ int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs)
>>  }
>>  EXPORT_SYMBOL(drm_vblank_init);
>>  
>> +/**
>> + * drm_crtc_has_vblank - test if vblanking has been initialized for
>> + *                       a CRTC
>> + * @crtc: the CRTC
>> + *
>> + * Drivers may call this function to test if vblank support is
>> + * initialized for a CRTC. For most hardware this means that vblanking
>> + * can also be enabled on the CRTC.
>> + *
>> + * Returns:
>> + * True if vblanking has been initialized for the given CRTC, false
>> + * otherwise.
>> + */
>> +bool drm_crtc_has_vblank(const struct drm_crtc *crtc)
> 
> So making this specific to a CRTC sounds like a good idea. But it's not
> the reality, drm_vblank.c assumes that either everything or nothing
> supports vblanks.
> 
> The reason for dev->num_crtcs is historical baggage, it predates kms by a
> few years. For kms drivers the only two valid values are either 0 or
> dev->mode_config.num_crtcs. Yes that's an entire different can of worms
> that's been irking me since forever (ideally drm_vblank_init would somehow
> loose the num_crtcs argument for kms drivers, but some drivers call this
> before they've done all the drm_crtc_init calls so it's complicated).

Maybe as a first step, drm_vblank_init() could use
dev->mode_config.num_crtcs if the supplied number of CRTCs is zero.

> 
> Hence drm_dev_has_vblank as I suggested. That would also allow you to
> replace a bunch of if (dev->num_crtcs) checks in drm_vblank.c, which
> should help quite a bit in code readability.

OK, but I still don't understand why this interface is better overall.
We don't loose anything by passing in the crtc instead of the device
structure. And if there's ever a per-crtc vblank initialization, we'd
have the interface in place already. The tests with "if
(dev->num_crtcs)" could probably be removed in most places in any case.

We should also consider forking the vblank code for non-KMS drivers.
While working in this, I found the support for legacy drivers is getting
in the way at times. With such a fork, legacy drivers could continue
using struct drm_vblank_crtc, while modern drivers could maybe store
vblank state directly in struct drm_crtc.

Anyway, all this is for another patch. Unless you change your mind, I'll
replace drm_crtc_has_vblank() with drm_dev_has_vblank() for the
patchset's next iteration.

Best regards
Thomas

> 
> Cheers, Daniel
> 
>> +{
>> +	struct drm_device *dev = crtc->dev;
>> +
>> +	return crtc->index < dev->num_crtcs;
>> +}
>> +EXPORT_SYMBOL(drm_crtc_has_vblank);
>> +
>>  /**
>>   * drm_crtc_vblank_waitqueue - get vblank waitqueue for the CRTC
>>   * @crtc: which CRTC's vblank waitqueue to retrieve
>> diff --git a/include/drm/drm_vblank.h b/include/drm/drm_vblank.h
>> index c16c44052b3d..531a6bc12b7e 100644
>> --- a/include/drm/drm_vblank.h
>> +++ b/include/drm/drm_vblank.h
>> @@ -206,6 +206,7 @@ struct drm_vblank_crtc {
>>  };
>>  
>>  int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs);
>> +bool drm_crtc_has_vblank(const struct drm_crtc *crtc);
>>  u64 drm_crtc_vblank_count(struct drm_crtc *crtc);
>>  u64 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc,
>>  				   ktime_t *vblanktime);
>> -- 
>> 2.24.1
>>
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-01-22  8:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-20 12:20 [PATCH v3 0/4] Use no_vblank property for drivers without VBLANK Thomas Zimmermann
2020-01-20 12:20 ` [PATCH v3 1/4] drm: Add drm_crtc_has_vblank() Thomas Zimmermann
2020-01-22  8:31   ` Daniel Vetter
2020-01-22  8:53     ` Thomas Zimmermann [this message]
2020-01-22  9:04       ` Daniel Vetter
2020-01-22  9:42         ` Thomas Zimmermann
2020-01-20 12:20 ` [PATCH v3 2/4] drm: Initialize struct drm_crtc_state.no_vblank from device settings Thomas Zimmermann
2020-01-22  8:47   ` Daniel Vetter
2020-01-20 12:20 ` [PATCH v3 3/4] drm/ast: Don't set struct drm_crtc_state.no_vblank explictly Thomas Zimmermann
2020-01-20 12:20 ` [PATCH v3 4/4] drm/udl: " Thomas Zimmermann
2020-01-21  9:36 ` [PATCH v3 0/4] Use no_vblank property for drivers without VBLANK Gerd Hoffmann
2020-01-23  8:40   ` Thomas Zimmermann

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=3ad03b06-f9be-37c7-9cc7-044468cdf300@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=david@lechnology.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.velikov@collabora.com \
    --cc=hdegoede@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=oleksandr_andrushchenko@epam.com \
    --cc=sam@ravnborg.org \
    --cc=sean@poorly.run \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=xen-devel@lists.xenproject.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).