[Intel-gfx] [igt-dev] [PATCH i-g-t 1/5] igt/kms_getfb: Check the iface exists before use

Antonio Argenziano antonio.argenziano at intel.com
Mon Oct 1 19:53:46 UTC 2018



On 01/10/18 12:43, Chris Wilson wrote:
> Quoting Antonio Argenziano (2018-10-01 19:36:24)
>>
>>
>> On 28/09/18 03:19, Chris Wilson wrote:
>>> If the driver doesn't support the getfb iface (e.g. because KMS has been
>>> disabled), the ioctls will fail with ENOTSUP. This is expected, so skip
>>> the test as nothing useful can be learnt.
>>>
>>> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
>>> ---
>>>    tests/kms_getfb.c | 40 ++++++++++++++++++++++++++++++++++++++--
>>>    1 file changed, 38 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/tests/kms_getfb.c b/tests/kms_getfb.c
>>> index 81d796a42..71d65488f 100644
>>> --- a/tests/kms_getfb.c
>>> +++ b/tests/kms_getfb.c
>>> @@ -40,6 +40,40 @@
>>>    #include "drm.h"
>>>    #include "drm_fourcc.h"
>>>    
>>> +static bool has_getfb_iface(int fd)
>>> +{
>>> +     struct drm_mode_fb_cmd arg = { };
>>> +     int err;
>>> +
>>> +     err = 0;
>>> +     if (drmIoctl(fd, DRM_IOCTL_MODE_GETFB, &arg))
>>> +             err = -errno;
>>> +     switch (err) {
>>> +     case -ENOTTY: /* ioctl unrecognised (kernel too old) */
>>> +     case -ENOTSUP: /* driver doesn't support KMS */
>>> +             return false;
>>> +     default:
>>> +             return true;
>>> +     }
>>> +}
>>> +
>>> +static bool has_addfb2_iface(int fd)
>>> +{
>>> +     struct drm_mode_fb_cmd2 arg = { };
>>> +     int err;
>>> +
>>> +     err = 0;
>>> +     if (drmIoctl(fd, DRM_IOCTL_MODE_ADDFB2, &arg) == 0)
>>> +             err = -errno;
>>
>> Shouldn't this^ be != 0?
> 
> Yup.
>   
>>> +     switch (err) {
>>> +     case -ENOTTY: /* ioctl unrecognised (kernel too old) */
>>> +     case -ENOTSUP: /* driver doesn't support KMS */
>>> +             return false;
>>> +     default:
>>> +             return true;
>>
>> Shouldn't we fail on every errno?
> 
> No. We want to be very careful in only fail at this point for errno we
> know imply the interface is not supported so that we do not confuse an
> illegal addfb2 request and fail later in the actual test.

Fair enough.

Acked-by: Antonio Argenziano <antonio.argenziano at intel.com>

for the series.

> -Chris
> 


More information about the Intel-gfx mailing list