[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v3 1/4] drm: Add drm_crtc_has_vblank()


  • To: Daniel Vetter <daniel@xxxxxxxx>
  • From: Thomas Zimmermann <tzimmermann@xxxxxxx>
  • Date: Wed, 22 Jan 2020 10:42:26 +0100
  • Autocrypt: addr=tzimmermann@xxxxxxx; keydata= mQENBFs50uABCADEHPidWt974CaxBVbrIBwqcq/WURinJ3+2WlIrKWspiP83vfZKaXhFYsdg XH47fDVbPPj+d6tQrw5lPQCyqjwrCPYnq3WlIBnGPJ4/jreTL6V+qfKRDlGLWFjZcsrPJGE0 BeB5BbqP5erN1qylK9i3gPoQjXGhpBpQYwRrEyQyjuvk+Ev0K1Jc5tVDeJAuau3TGNgah4Yc hdHm3bkPjz9EErV85RwvImQ1dptvx6s7xzwXTgGAsaYZsL8WCwDaTuqFa1d1jjlaxg6+tZsB 9GluwvIhSezPgnEmimZDkGnZRRSFiGP8yjqTjjWuf0bSj5rUnTGiyLyRZRNGcXmu6hjlABEB AAG0J1Rob21hcyBaaW1tZXJtYW5uIDx0emltbWVybWFubkBzdXNlLmRlPokBVAQTAQgAPhYh BHIX+6yM6c9jRKFo5WgNwR1TC3ojBQJbOdLgAhsDBQkDwmcABQsJCAcCBhUKCQgLAgQWAgMB Ah4BAheAAAoJEGgNwR1TC3ojR80H/jH+vYavwQ+TvO8ksXL9JQWc3IFSiGpuSVXLCdg62AmR irxW+qCwNncNQyb9rd30gzdectSkPWL3KSqEResBe24IbA5/jSkPweJasgXtfhuyoeCJ6PXo clQQGKIoFIAEv1s8l0ggPZswvCinegl1diyJXUXmdEJRTWYAtxn/atut1o6Giv6D2qmYbXN7 mneMC5MzlLaJKUtoH7U/IjVw1sx2qtxAZGKVm4RZxPnMCp9E1MAr5t4dP5gJCIiqsdrVqI6i KupZstMxstPU//azmz7ZWWxT0JzgJqZSvPYx/SATeexTYBP47YFyri4jnsty2ErS91E6H8os Bv6pnSn7eAq5AQ0EWznS4AEIAMYmP4M/V+T5RY5at/g7rUdNsLhWv1APYrh9RQefODYHrNRH UE9eosYbT6XMryR9hT8XlGOYRwKWwiQBoWSDiTMo/Xi29jUnn4BXfI2px2DTXwc22LKtLAgT RjP+qbU63Y0xnQN29UGDbYgyyK51DW3H0If2a3JNsheAAK+Xc9baj0LGIc8T9uiEWHBnCH+R dhgATnWWGKdDegUR5BkDfDg5O/FISymJBHx2Dyoklv5g4BzkgqTqwmaYzsl8UxZKvbaxq0zb ehDda8lvhFXodNFMAgTLJlLuDYOGLK2AwbrS3Sp0AEbkpdJBb44qVlGm5bApZouHeJ/+n+7r 12+lqdsAEQEAAYkBPAQYAQgAJhYhBHIX+6yM6c9jRKFo5WgNwR1TC3ojBQJbOdLgAhsMBQkD wmcAAAoJEGgNwR1TC3ojpfcIAInwP5OlcEKokTnHCiDTz4Ony4GnHRP2fXATQZCKxmu4AJY2 h9ifw9Nf2TjCZ6AMvC3thAN0rFDj55N9l4s1CpaDo4J+0fkrHuyNacnT206CeJV1E7NYntxU n+LSiRrOdywn6erjxRi9EYTVLCHcDhBEjKmFZfg4AM4GZMWX1lg0+eHbd5oL1as28WvvI/uI aMyV8RbyXot1r/8QLlWldU3NrTF5p7TMU2y3ZH2mf5suSKHAMtbE4jKJ8ZHFOo3GhLgjVrBW HE9JXO08xKkgD+w6v83+nomsEuf6C6LYrqY/tsZvyEX6zN8CtirPdPWu/VXNRYAl/lat7lSI 3H26qrE=
  • Cc: laurent.pinchart@xxxxxxxxxxxxxxxx, david@xxxxxxxxxxxxxx, oleksandr_andrushchenko@xxxxxxxx, airlied@xxxxxxxx, sean@xxxxxxxxxx, dri-devel@xxxxxxxxxxxxxxxxxxxxx, virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx, hdegoede@xxxxxxxxxx, kraxel@xxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, sam@xxxxxxxxxxxx, emil.velikov@xxxxxxxxxxxxx
  • Delivery-date: Wed, 22 Jan 2020 09:43:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi

Am 22.01.20 um 10:04 schrieb Daniel Vetter:
> On Wed, Jan 22, 2020 at 09:53:42AM +0100, Thomas Zimmermann wrote:
>> 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@xxxxxxx>
>>>> ---
>>>>  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.
> 
> You can't use it in drm_vblank.c code, because we only have the
> drm_device, not the drm_crtc (in most places at least). Your other patch
> series to deprecate the drm_device callbacks for vblanks is a huge step
> into the direction to fix that, but still more work needed: We'd
> essentially need to copypaste drm_vblank.c into drm_crtc_vblank.c for kms
> drivers, and in that copy switch from (dev, pipe) to crtc everywhere. Plus
> then move the drm_vblank structure into struct drm_crtc.
> 
> Wrt removing the check: In a pile of cases it changes the return value,
> which matters both for vblank usage in helper code and the ioctl itself.
> From a quick look most of the checks that don't matter are already wrapped
> in a WARN.
> 
>> 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.
> 
> Hm if you want to do all that then the drm_crtc_has_vblank makes sense.
> But only after we've done the full split. So maybe make the public
> function drm_crtc_has_vblank, which calls the internal-only
> drm_has_vblank, and use that internally in drm_vblank.c?
> 
> btw I still think a sub-struct for vblank stuff in drm_crtc makes sense,
> and drm_vblank_crtc seems to mostly fit the bill.
> 
> That way we're at least not adding the the conversion pain of switching
> the vblank code over to drm_crtc fully.
> 
> Thoughts?

That all sounds good. Using struct drm_vblank_crtc with legacy and
modern vblank functions, might allow us to continue to share some of the
implementation.

Wrt the current interface, drm_dev_has_vblank() is only called in a
single place, so switching to drm_crtc_has_vblank() later would not be hard.

Best regards
Thomas

> -Daniel
> 
>> 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
>>
> 
> 
> 
> 

-- 
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: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.