Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Modem, Bhanuprakash" <bhanuprakash.modem@intel.com>
To: Kamil Konieczny <kamil.konieczny@linux.intel.com>,
	<igt-dev@lists.freedesktop.org>,
	"Gupta, Anshuman" <anshuman.gupta@intel.com>
Subject: Re: [i-g-t] tests/intel/i915_suspend: Fix WARNs of invalid fd
Date: Wed, 24 Jan 2024 13:46:20 +0530	[thread overview]
Message-ID: <e736cb2e-7f86-4da1-bc0b-6ab3e01b1cca@intel.com> (raw)
In-Reply-To: <20240119133229.lmnfwqrkdbo4nahq@kamilkon-desk.igk.intel.com>

Hi Kamil/Anshuman,

On 19-01-2024 07:02 pm, Kamil Konieczny wrote:
> Hi Gupta,,
> On 2024-01-18 at 04:44:59 +0000, Gupta, Anshuman wrote:
>>
>>
>>> -----Original Message-----
>>> From: Modem, Bhanuprakash <bhanuprakash.modem@intel.com>
>>> Sent: Wednesday, January 17, 2024 8:52 PM
>>> To: Kamil Konieczny <kamil.konieczny@linux.intel.com>; igt-
>>> dev@lists.freedesktop.org; Gupta, Anshuman <anshuman.gupta@intel.com>
>>> Subject: Re: [i-g-t] tests/intel/i915_suspend: Fix WARNs of invalid fd
>>>
>>> Hi Kamil,
>>>
>>> On 17-01-2024 04:42 pm, Kamil Konieczny wrote:
>>>> Hi Bhanuprakash,
>>>> On 2024-01-09 at 18:48:02 +0530, Bhanuprakash Modem wrote:
>>>>> Call drm_close_driver() only if fd >=0, otherwise it'll will throw WARN:
>>>>>
>>>>> (i915_suspend:7563) drmtest-WARNING: Don't attempt to close
>>>>> standard/invalid file descriptor: -1
>>>>>
>>>>> Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
>>>>> ---
>>>>>    tests/intel/i915_suspend.c | 4 +++-
>>>>>    1 file changed, 3 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/tests/intel/i915_suspend.c b/tests/intel/i915_suspend.c
>>>>> index c25805584..82cabfa41 100644
>>>>> --- a/tests/intel/i915_suspend.c
>>>>> +++ b/tests/intel/i915_suspend.c
>>>>> @@ -300,7 +300,9 @@ test_suspend_without_i915(int state)
>>>>>    		igt_pm_get_d3cold_allowed(card.pci_slot_name,
>>> &d3cold_allowed);
>>>>>    		igt_pm_set_d3cold_allowed(card.pci_slot_name, 0);
>>>>>    	}
>>>>> -	drm_close_driver(fd);
>>>>
>>>> imho proper fix would be remove this and
>>>> fd=__drm_open_driver(DRIVER_INTEL)
>>>> from this function, as function is named:
>>>> test_suspend_without_i915
>>>
>>> I don't have much expertise in D states. After reading the comments in the
>>> subtest "When module is unloaded and s2idle is triggered, PCI core leaves the
>>> endpoint in D0 and the bridge in D3 state causing PCIE spec violation and
>>> config space is read as 0xFF. Keep the bridge in D0 before module unload to
>>> prevent this issue"
>> This is not a real time use case, either a system boots with i915 driver or not.
>> Removing i915 module and trigger suspend is not a valid use case but we want to test that
>> suspend coverage without i915. So we need to disallow d3cold(which will bring the pcie bridge to D0).
>> igt_pm_set_d3cold_allowed(card.pci_slot_name, 0);
>> ***above is applicable tp  discrete card.
> 
> So this code should look like:
> 
> if (state == SUSPEND_STATE_FREEZE) {
>      igt_devices_scan(false);
>      if (igt_device_find_first_i915_discrete_card(&card)) {
>              fd = __drm_open_driver(DRIVER_INTEL); /* write comment why we need this */
>              igt_pm_get_d3cold_allowed(card.pci_slot_name, &d3cold_allowed);
>              igt_pm_set_d3cold_allowed(card.pci_slot_name, 0);
>              drm_close_driver(fd);
>      }
> }
> 
> But this will fix problem on iGPU but still doesn't answer why
> __drm_open_driver fails... as in dmesg from fails I see i915
> was loaded/unloaded successfully.

I think, we can fix this as a separate activity. Meanwhile, shall we 
merge this patch?

- Bhanu

> 
> Regards,
> Kamil
> 
>>   
>> Thanks,
>> Anshuman Gupta
>>>
>>> IMHO, still this patch is a valid fix. Perhaps, we can drop
>>> drm_close_driver() and use close().
>>>
>>> + Anshuman to comment
>>>
>>> - Bhanu
>>>
>>>>
>>>> we are expecting i915 driver to be _unloaded_.
>>>>
>>>> Regards,
>>>> Kamil
>>>>
>>>>> +
>>>>> +	if (fd >= 0)
>>>>> +		drm_close_driver(fd);
>>>>>
>>>>>    	igt_kmsg(KMSG_INFO "Unloading i915\n");
>>>>>    	igt_assert_eq(igt_i915_driver_unload(),0);
>>>>> --
>>>>> 2.40.0
>>>>>

  reply	other threads:[~2024-01-24  8:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-09 13:18 [i-g-t] tests/intel/i915_suspend: Fix WARNs of invalid fd Bhanuprakash Modem
2024-01-09 15:53 ` ✓ Fi.CI.BAT: success for " Patchwork
2024-01-09 17:15 ` ✓ CI.xeBAT: " Patchwork
2024-01-09 18:00 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-01-17 11:12 ` [i-g-t] " Kamil Konieczny
2024-01-17 15:22   ` Modem, Bhanuprakash
2024-01-17 18:51     ` Kamil Konieczny
2024-01-18  4:44     ` Gupta, Anshuman
2024-01-19 13:32       ` Kamil Konieczny
2024-01-24  8:16         ` Modem, Bhanuprakash [this message]
2024-01-24 12:45           ` Kamil Konieczny

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=e736cb2e-7f86-4da1-bc0b-6ab3e01b1cca@intel.com \
    --to=bhanuprakash.modem@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.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