From: "Christian König" <christian.koenig@amd.com>
To: "Modem, Bhanuprakash" <bhanuprakash.modem@intel.com>,
vitaly prosyak <vprosyak@amd.com>,
Kamil Konieczny <kamil.konieczny@linux.intel.com>,
igt-dev@lists.freedesktop.org, janga.rahul.kumar@intel.com,
David Zhang <dingchen.zhang@amd.com>,
Harry Wentland <harry.wentland@amd.com>
Subject: Re: [igt-dev] [i-g-t 05/20] tests/amdgpu: Close the fd before exit
Date: Thu, 15 Jun 2023 10:43:05 +0200 [thread overview]
Message-ID: <ade3eec2-32f9-79f3-8778-eaeeb0be1b60@amd.com> (raw)
In-Reply-To: <3038241b-6f6c-36df-ed51-aa809e3a1348@intel.com>
Am 15.06.23 um 10:28 schrieb Modem, Bhanuprakash:
>
>
> On Thu-15-06-2023 12:43 pm, Christian König wrote:
>> Hi guys,
>>
>> Am 15.06.23 um 06:46 schrieb Modem, Bhanuprakash:
>>> Hi Vitaliy,
>>>
>>> On Thu-15-06-2023 05:44 am, vitaly prosyak wrote:
>>>> Hi Kamil,
>>>>
>>>> Thanks for letting us know about new(?) function
>>>> /drm_close_driver/.
>>>>
>>>> Is there a pending change, I could not find this function in the
>>>> DRM or IGT.
>>>
>>> Yes, changes are not yet landed into the IGT (WIP).
>>>
>>> Please refer Patch 1/20 in this series:
>>> https://patchwork.freedesktop.org/patch/538070/?series=117263&rev=5
>>
>> well neither this patch here nor the referenced series is correct.
>>
>> The libdrm functions take ownership of the file descriptor given to
>> them!
>>
>> So the application or in this case IGT is *not* supposed to close
>> them at all.
>
> Unfortunately, that is not correct.
>
> The application (IGT in this case), opens the driver and uses the
> libdrm functions to perform operations (like ioctl), but file
> descriptor is still with the IGT only.
Ok, so we dup() the file descriptor somewhere?
Because at least amdgpu_device_free_internal() is clearly closing the fd
before freeing the device structure:
static void amdgpu_device_free_internal(amdgpu_device_handle dev)
{
...
close(dev->fd);
...
free(dev);
}
>
> Once it is done with the operations performed, it's IGT responsibility
> to close the driver (I think there are few gcc options available to
> close the device on IGT exit)
Well no, that's not related to gcc in any way possible. File descriptors
are closed by the kernel on process exit.
Regards,
Christian.
>
> A typical IGT sudo-code:
>
> fd = open(/dev/device);
>
> libdrm_call(fd);
> libdrm_call(fd);
>
> close(fd);
>
> - Bhanu
>
>>
>> Regards,
>> Christian.
>>
>>>
>>> - Bhanu
>>>
>>>>
>>>> We open the driver with /drm_open_driver/, but then we use close vs
>>>> /drm_close_driver/. I makes sense to have a symmetrical call:
>>>> /open/close/ and /drm_open_driver/drm_close_driver/
>>>>
>>>>
>>>> Thanks, Vitaly
>>>>
>>>> On 2023-06-14 08:39, Kamil Konieczny wrote:
>>>>> Hi Bhanuprakash,
>>>>>
>>>>> +cc Vitaliy and Christian
>>>>>
>>>>> Cc: Vitaly Prosyak<vitaly.prosyak@amd.com>
>>>>> Cc: Christian König<christian.koenig@amd.com>
>>>>>
>>>>> Regards,
>>>>> Kamil
>>>>>
>>>>> On 2023-05-16 at 22:20:43 +0530, Bhanuprakash Modem wrote:
>>>>>> Close the file descriptor before exiting the test.
>>>>>>
>>>>>> Cc: David Zhang<dingchen.zhang@amd.com>
>>>>>> Cc: Harry Wentland<harry.wentland@amd.com>
>>>>>> Signed-off-by: Bhanuprakash Modem<bhanuprakash.modem@intel.com>
>>>>>> ---
>>>>>> tests/amdgpu/amd_abm.c | 1 +
>>>>>> tests/amdgpu/amd_assr.c | 1 +
>>>>>> tests/amdgpu/amd_freesync_video_mode.c | 1 +
>>>>>> tests/amdgpu/amd_mem_leak.c | 1 +
>>>>>> tests/amdgpu/amd_psr.c | 3 ++-
>>>>>> tests/amdgpu/amd_vrr_range.c | 1 +
>>>>>> 6 files changed, 7 insertions(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/tests/amdgpu/amd_abm.c b/tests/amdgpu/amd_abm.c
>>>>>> index 9400ed806..082da7ed6 100644
>>>>>> --- a/tests/amdgpu/amd_abm.c
>>>>>> +++ b/tests/amdgpu/amd_abm.c
>>>>>> @@ -378,5 +378,6 @@ igt_main
>>>>>> igt_fixture {
>>>>>> igt_display_fini(&data.display);
>>>>>> + drm_close_driver(data.drm_fd);
>>>>>> }
>>>>>> }
>>>>>> diff --git a/tests/amdgpu/amd_assr.c b/tests/amdgpu/amd_assr.c
>>>>>> index 80cbbe8e9..fc2367f99 100644
>>>>>> --- a/tests/amdgpu/amd_assr.c
>>>>>> +++ b/tests/amdgpu/amd_assr.c
>>>>>> @@ -299,5 +299,6 @@ igt_main
>>>>>> igt_fixture
>>>>>> {
>>>>>> igt_display_fini(&data.display);
>>>>>> + drm_close_driver(data.fd);
>>>>>> }
>>>>>> }
>>>>>> diff --git a/tests/amdgpu/amd_freesync_video_mode.c
>>>>>> b/tests/amdgpu/amd_freesync_video_mode.c
>>>>>> index 579d24436..62d42a06c 100644
>>>>>> --- a/tests/amdgpu/amd_freesync_video_mode.c
>>>>>> +++ b/tests/amdgpu/amd_freesync_video_mode.c
>>>>>> @@ -868,5 +868,6 @@ igt_main
>>>>>> igt_fixture {
>>>>>> igt_display_fini(&data.display);
>>>>>> + drm_close_driver(data.drm_fd);
>>>>>> }
>>>>>> }
>>>>>> diff --git a/tests/amdgpu/amd_mem_leak.c
>>>>>> b/tests/amdgpu/amd_mem_leak.c
>>>>>> index dee563cbe..e4a4b5c47 100644
>>>>>> --- a/tests/amdgpu/amd_mem_leak.c
>>>>>> +++ b/tests/amdgpu/amd_mem_leak.c
>>>>>> @@ -232,5 +232,6 @@ igt_main
>>>>>> igt_fixture
>>>>>> {
>>>>>> igt_display_fini(&data.display);
>>>>>> + drm_close_driver(data.fd);
>>>>>> }
>>>>>> }
>>>>>> diff --git a/tests/amdgpu/amd_psr.c b/tests/amdgpu/amd_psr.c
>>>>>> index 966a0dccf..3932e143a 100644
>>>>>> --- a/tests/amdgpu/amd_psr.c
>>>>>> +++ b/tests/amdgpu/amd_psr.c
>>>>>> @@ -640,7 +640,7 @@ static void run_check_psr_su_cursor(data_t
>>>>>> *data, bool test_mpo)
>>>>>> * panning the primary plane at the top-left of screen
>>>>>> * set alpha region in overlay plane and set alpha to 0.0
>>>>>> to show primary plane
>>>>>> * set cursor plane and starting from position of (0, 0)
>>>>>> - */
>>>>>> + */
>>>>>> draw_color_alpha(&data->ov_fb[0], 0, 0, data->pfb_w,
>>>>>> data->pfb_h, 1.0, 1.0, 1.0, .0);
>>>>>> igt_plane_set_fb(data->primary, &data->pm_fb[0]);
>>>>>> igt_plane_set_fb(data->overlay, &data->ov_fb[0]);
>>>>>> @@ -763,5 +763,6 @@ igt_main_args("", long_options, help_str,
>>>>>> opt_handler, NULL)
>>>>>> }
>>>>>> close(data.debugfs_fd);
>>>>>> igt_display_fini(&data.display);
>>>>>> + drm_close_driver(data.fd);
>>>>>> }
>>>>>> }
>>>>>> diff --git a/tests/amdgpu/amd_vrr_range.c
>>>>>> b/tests/amdgpu/amd_vrr_range.c
>>>>>> index 2f27296dd..cacd668cd 100644
>>>>>> --- a/tests/amdgpu/amd_vrr_range.c
>>>>>> +++ b/tests/amdgpu/amd_vrr_range.c
>>>>>> @@ -338,5 +338,6 @@ igt_main
>>>>>> igt_fixture
>>>>>> {
>>>>>> igt_display_fini(&data.display);
>>>>>> + drm_close_driver(data.fd);
>>>>>> }
>>>>>> }
>>>>>> --
>>>>>> 2.40.0
>>>>>>
>>
next prev parent reply other threads:[~2023-06-15 8:43 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 16:50 [igt-dev] [i-g-t 00/20] XE test cleanup to handle xe_device Bhanuprakash Modem
2023-05-16 16:50 ` [igt-dev] [i-g-t 01/20] lib: Interface to close the drm fd Bhanuprakash Modem
2023-05-18 18:51 ` Zbigniew Kempczyński
2023-05-18 18:54 ` Zbigniew Kempczyński
2023-05-19 15:09 ` [igt-dev] [i-g-t V3 " Bhanuprakash Modem
2023-05-22 11:16 ` Zbigniew Kempczyński
2023-05-16 16:50 ` [igt-dev] [i-g-t 02/20] lib: Cache xe_device at driver open/close level Bhanuprakash Modem
2023-05-18 18:46 ` Zbigniew Kempczyński
2023-05-16 16:50 ` [igt-dev] [i-g-t 03/20] lib/xe/xe_query: Add xe_config() interface Bhanuprakash Modem
2023-05-16 16:50 ` [igt-dev] [i-g-t 04/20] lib/igt_msm: Use drm_close_driver() to close the drm fd Bhanuprakash Modem
2023-05-16 16:50 ` [igt-dev] [i-g-t 05/20] tests/amdgpu: Close the fd before exit Bhanuprakash Modem
2023-06-14 12:39 ` Kamil Konieczny
2023-06-15 0:14 ` vitaly prosyak
2023-06-15 4:46 ` Modem, Bhanuprakash
2023-06-15 7:13 ` Christian König
2023-06-15 8:28 ` Modem, Bhanuprakash
2023-06-15 8:43 ` Christian König [this message]
2023-06-15 11:48 ` Kamil Konieczny
2023-06-15 12:03 ` Christian König
2023-05-16 16:50 ` [igt-dev] [i-g-t 06/20] tests/i915: " Bhanuprakash Modem
2023-05-18 18:58 ` Zbigniew Kempczyński
2023-05-22 5:27 ` Modem, Bhanuprakash
2023-05-22 11:21 ` Zbigniew Kempczyński
2023-05-22 12:33 ` Modem, Bhanuprakash
2023-05-22 15:23 ` Zbigniew Kempczyński
2023-05-16 16:50 ` [igt-dev] [i-g-t 07/20] tests/nouveau_crc: " Bhanuprakash Modem
2023-05-16 20:14 ` Lyude Paul
2023-05-16 16:50 ` [igt-dev] [i-g-t 08/20] tests/xe/xe_gpgpu_fill: " Bhanuprakash Modem
2023-05-18 19:15 ` Kumar, Janga Rahul
2023-05-16 16:50 ` [igt-dev] [i-g-t 09/20] tests/amdgpu: Use drm_close_driver() to close the drm fd Bhanuprakash Modem
2023-06-14 12:38 ` Kamil Konieczny
2023-05-16 16:50 ` [igt-dev] [i-g-t 10/20] tests/i915/kms_mmap_write_crc: Avoid closing the closed fd Bhanuprakash Modem
2023-05-24 8:00 ` Kamil Konieczny
2023-05-16 16:50 ` [igt-dev] [i-g-t 11/20] tests/panfrost: Use drm_close_driver() to close the drm fd Bhanuprakash Modem
2023-05-16 16:50 ` [igt-dev] [i-g-t 12/20] tests/v3d: " Bhanuprakash Modem
2023-05-16 16:50 ` [igt-dev] [i-g-t 13/20] tests/vc4: " Bhanuprakash Modem
2023-05-16 16:50 ` [igt-dev] [i-g-t 14/20] tests/vmwgfx: " Bhanuprakash Modem
2023-05-17 19:55 ` "Maaz Mombasawala (VMware)
2023-05-16 16:50 ` [igt-dev] [i-g-t 15/20] tests/kms: " Bhanuprakash Modem
2023-05-24 9:02 ` Kamil Konieczny
2023-05-16 16:50 ` [igt-dev] [i-g-t 16/20] tests/xe: " Bhanuprakash Modem
2023-05-18 19:14 ` Kumar, Janga Rahul
2023-05-16 16:50 ` [igt-dev] [i-g-t 17/20] tests/i915: " Bhanuprakash Modem
2023-05-24 8:44 ` Kamil Konieczny
2023-05-16 16:50 ` [igt-dev] [i-g-t 18/20] tests/xe/xe_debugfs: Use xe_config() helper to get the config Bhanuprakash Modem
2023-05-24 8:47 ` Kamil Konieczny
2023-05-16 16:50 ` [igt-dev] [i-g-t 19/20] tests: Drop xe_device get/put from test level Bhanuprakash Modem
2023-05-24 7:58 ` Kamil Konieczny
2023-05-16 16:50 ` [igt-dev] [i-g-t 20/20] Revert "lib/igt_kms: Cache xe_device info for kms tests" Bhanuprakash Modem
2023-05-24 8:03 ` Kamil Konieczny
2023-05-16 18:45 ` [igt-dev] ✓ Fi.CI.BAT: success for XE test cleanup to handle xe_device (rev4) Patchwork
2023-05-17 3:51 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2023-05-19 15:52 ` [igt-dev] ✓ Fi.CI.BAT: success for XE test cleanup to handle xe_device (rev5) Patchwork
2023-05-19 18:09 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
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=ade3eec2-32f9-79f3-8778-eaeeb0be1b60@amd.com \
--to=christian.koenig@amd.com \
--cc=bhanuprakash.modem@intel.com \
--cc=dingchen.zhang@amd.com \
--cc=harry.wentland@amd.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=janga.rahul.kumar@intel.com \
--cc=kamil.konieczny@linux.intel.com \
--cc=vprosyak@amd.com \
/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