From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
Cc: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [RFC i-g-t 3/5] lib/igt_device_scan: Remember PCI card index after scanning
Date: Mon, 16 Nov 2020 17:07:36 +0000 [thread overview]
Message-ID: <83346534-f723-3389-9070-07cbf9e34edf@linux.intel.com> (raw)
In-Reply-To: <20201116164755.GA2763@zkempczy-mobl2>
On 16/11/2020 16:47, Zbigniew Kempczyński wrote:
> On Mon, Nov 16, 2020 at 03:09:43PM +0000, Tvrtko Ursulin wrote:
>
> <cut>
>
>>>> +
>>>> /* Core scanning function.
>>>> *
>>>> * All scanned devices are kept inside igt_devs.all pointer array.
>>>> @@ -657,6 +685,7 @@ static void scan_drm_devices(void)
>>>> udev_unref(udev);
>>>> sort_all_devices();
>>>> + index_pci_devices();
>>>> igt_list_for_each_entry(dev, &igt_devs.all, link) {
>>>> struct igt_device *dev_dup = duplicate_device(dev);
>>>> @@ -1105,13 +1134,13 @@ static struct igt_list_head *filter_pci(const struct filter_class *fcls,
>>>> if (filter->data.device && strcasecmp(filter->data.device, dev->device))
>>>> continue;
>>>> - /* We get n-th card */
>>>> - if (!card) {
>>>> - struct igt_device *dup = duplicate_device(dev);
>>>> - igt_list_add_tail(&dup->link, &igt_devs.filtered);
>>>> - break;
>>>> - }
>>>> - card--;
>>>> + /* Skip if 'card' doesn't match */
>>>> + if (card != dev->pci_index)
>>>> + continue;
>>>> +
>>>> + dev = duplicate_device(dev);
>>>> + igt_list_add_tail(&dev->link, &igt_devs.filtered);
>>>> + break;
>>>
>>> I may wrong (I got no such testing env) but devs_compare() function along with
>>> index_pci_devices() can lead us to such (example) situation:
>>>
>>> igt_devs.all contains devices with syspaths and subsystem pci:
>>> /sys/devices/pci0000:00/0000:00:04.0 -> vendor 8086, device 1234 pci_index == 0
>>> /sys/devices/pci0000:00/0000:00:05.0 -> vendor 8086, device 4321 pci_index == 1
>>> /sys/devices/pci0000:00/0000:00:06.0 -> vendor 8086, device 1234 pci_index == 2
>>>
>>> If would try filter: pci=vendor=8086,device=1234,card=1 I would expect
>>> to select (second card [index == 1]) from filtered devices which match
>>> device 1234.
>>
>> It is supposed to be like you say, each pci_index being in the namespace of
>> equal vendor & device only.
>>
>> Like from a dual GPU system:
>>
>> $ tools/lsgpu --pci
>> card1 8086:4905 pci:vendor=8086,device=4905,card=0
>> └─renderD129
>> card0 8086:3E98 pci:vendor=8086,device=3E98,card=0
>> └─renderD128
>>
>> Or two identical GPUs (mocked by manual addition of an almost duplicate
>> entry to list of scanned devices:
>>
>> $ tools/lsgpu --pci
>> card0 8086:193B pci:vendor=8086,device=193B,card=0
>> ├─renderD128
>> └─renderD128
>> card0x 8086:193B pci:vendor=8086,device=193B,card=1
>> ├─renderD128
>> └─renderD128
>>
>> Regards,
>>
>> Tvrtko
>
> I made a mistake in above listing, it should be:
> /sys/devices/pci0000:00/0000:00:04.0 -> vendor 8086, device 1234 pci_index == 0
> /sys/devices/pci0000:00/0000:00:05.0 -> vendor 8086, device 4321 pci_index == 0
> /sys/devices/pci0000:00/0000:00:06.0 -> vendor 8086, device 1234 pci_index == 1
>
> What if I would go over all Intel cards using pci filter:
>
> pci:vendor=8086,card=N where n is 0... until there's no Intel pci device.
>
> This way we loose possibility to iterate over all pci devices imo.
Oh I get it know, I misunderstood how this all works. So the card
argument to the pci filter is nothing about the actual PCI card, but
just "match number" - match with this filter and return card=N Nth match.
So I should leave the code in filter_pci as is.
Will my new filters work like that. I think so. Ok, will update.
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2020-11-16 17:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-13 16:27 [Intel-gfx] [RFC i-g-t 0/5] User friendly lsgpu/intel_gpu_top device listing Tvrtko Ursulin
2020-11-13 16:27 ` [Intel-gfx] [RFC i-g-t 1/5] intel_gpu_top: User friendly " Tvrtko Ursulin
2020-11-13 16:27 ` [Intel-gfx] [RFC i-g-t 2/5] lsgpu: " Tvrtko Ursulin
2020-11-13 16:27 ` [Intel-gfx] [RFC i-g-t 3/5] lib/igt_device_scan: Remember PCI card index after scanning Tvrtko Ursulin
2020-11-16 14:03 ` Zbigniew Kempczyński
2020-11-16 15:09 ` Tvrtko Ursulin
2020-11-16 16:47 ` Zbigniew Kempczyński
2020-11-16 17:07 ` Tvrtko Ursulin [this message]
2020-11-13 16:27 ` [Intel-gfx] [RFC i-g-t 4/5] lsgpu: Add filter type print-out selection Tvrtko Ursulin
2020-11-13 16:27 ` [Intel-gfx] [RFC i-g-t 5/5] intel_gpu_top: Default GPU list to PCI mode Tvrtko Ursulin
2020-11-16 13:08 ` [Intel-gfx] [igt-dev] [RFC i-g-t 0/5] User friendly lsgpu/intel_gpu_top device listing Tvrtko Ursulin
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=83346534-f723-3389-9070-07cbf9e34edf@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=Intel-gfx@lists.freedesktop.org \
--cc=igt-dev@lists.freedesktop.org \
--cc=zbigniew.kempczynski@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