Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework device names #682

Merged
merged 19 commits into from
Jun 8, 2023
Merged

Conversation

evelikov
Copy link
Contributor

@evelikov evelikov commented Feb 6, 2023

The current GetDriver API is rather fragile and bonkers.

In particular it does a two-step pass - number vs names. That in itself
is not great, since it assumes the devices do not change in between.
Additionally there is the assumption of index X will match device (name)
X, which does not hold true.

The most prominent issue is the inability to provide accurate number and
list of names.

Instead, we can have a single API, that provides both pieces of data in
one do - shorter and simpler code - in reliable manner.


In other words: this replaces and deprecates vaGetNumCandidates && vaGetDriverNameByIndex in favour of vaGetDriverNames

This is the first step towards fixing #677

@evelikov
Copy link
Contributor Author

evelikov commented Feb 6, 2023

@sivileri this MR reworks the driver-name API, conflicting with your other work. Would be great if we can merge this first, but at the least can you please check this doesn't explode on Windows. Thanks o/

@XinfengZhang @dvrogozh this is the first big step towards addressing the DRI3 regressions some people are seeing. Would be great if we can get to it sooner than later.

@ceyusa
Copy link
Contributor

ceyusa commented Feb 15, 2023

fwiw, it looks cleaner and robust.

What worries me is that drivers lists are scattered among different backend implementation files, and, iiuc, some drivers can be used by several backends. I wonder if we could centralized all of them in a single file so we could update that single structure for all at once. Anyway, this change can be done later.

va/win32/va_win32.c Outdated Show resolved Hide resolved
@evelikov
Copy link
Contributor Author

fwiw, it looks cleaner and robust.

What worries me is that drivers lists are scattered among different backend implementation files, and, iiuc, some drivers can be used by several backends. I wonder if we could centralized all of them in a single file so we could update that single structure for all at once. Anyway, this change can be done later.

IMHO we should probably spend our efforts into a proper mechanism (say something like the Vulkan ICD/json) to remove this hard-coding + add some order/priority guarantees. Which in itself is an important yet orthogonal task.

@evelikov
Copy link
Contributor Author

evelikov commented Mar 7, 2023

@XinfengZhang @dvrogozh any comments?

Copy link
Contributor

@dvrogozh dvrogozh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, proposal is to completely replace 2 functions currently used to enumerate drivers:

$ cat va_backend.h
vaGetNumCandidates
vaGetDriverNameByIndex

with single one:

$ cat va_backend.h
vaGetNumCandidates // DEPRECATED =NULL
vaGetDriverNameByIndex // DEPRECATED =NULL
vaGetDriverNames

I think this highlight needs to be added to PR description to save time to understand what's being done in the PR.

va/va_backend.h Outdated Show resolved Hide resolved
@evelikov
Copy link
Contributor Author

evelikov commented Mar 9, 2023

Rebased, fixed the reserved bits and added one line summary about the API change.

@dvrogozh can you have another look?

@evelikov evelikov requested a review from dvrogozh March 9, 2023 17:22
Copy link
Contributor

@dvrogozh dvrogozh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good to me. Basically I am trying to imagine the case where something might go wrong, but without a success so far. I think this change needs to be extensively tried before the merge. Recommend to pick it up for validation. @XinfengZhang - please, take a look.

@dvrogozh dvrogozh self-requested a review March 10, 2023 14:47
@XinfengZhang
Copy link
Contributor

the change itself looks good, but from my perspective, we do need test it.
also, we could merge it after 2.18 release immediately, to keep it in master about 3 month to be tried by different users.

@evelikov
Copy link
Contributor Author

@XinfengZhang when you say "we need to test it" can you elaborate who is "we" and what testing do you expect to be done?

There has been zero comments here for over 3 months and 2.18 was released 2 month ago. This makes me wonder if as-is libva is even considered maintained?

* the safe side. In the worst case, the DRIVER BUG below will print and
* we'll be capped to the current selection.
*/
char *drivers[20] = { 0, };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20 should be enough now, but does we need a check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What check are you looking for - can you provide a concrete example?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need check now, it is impossible that {i915, {iHD, i965, i966 .... iHD1, iHD2...} exceed 20 backend UMD drivers for one KMD.

@XinfengZhang
Copy link
Contributor

XinfengZhang commented Jun 1, 2023

@evelikov could you help to rebase it?

@evelikov
Copy link
Contributor Author

evelikov commented Jun 2, 2023

@XinfengZhang do you mind replying to my earlier question #682 (comment), thanks.

@XinfengZhang
Copy link
Contributor

@XinfengZhang do you mind replying to my earlier question #682 (comment), thanks.

sorry for late response firstly, just like my previous comments, the change itself looks good to me
#682 (comment)
but that time , we are closing 2.18 release. so I want to keep it there and let more people try it.
and merge it after 2.18 release. but there are no more comments after that,
I got the notification from your comments of last week. and revisit it and try it again.
I apologize for this , I understand it is bad practice to a respected contributor, will avoid such bad practice in future

about why we did not include it in 2.18.
the code make the code more elegant , unify 2 steps to 1. it is very nice code,
but it is not urgent feature at that time, and it include more 19 commit, looks a little risky at that time.
and the Q1 release validation cycle already been triggered.

I tested it with intel media stack.

evelikov and others added 9 commits June 6, 2023 12:28
Move all the existing open driver code into a legacy function. It will
soon be replaced (in gradual non-regressing manner) with a new shorter
and more coherent solution.

Signed-off-by: Emil Velikov <[email protected]>
The current GetDriver API is rather fragile and bonkers.

In particular it does a two-step pass - number vs names. That in itself
is not great, since it assumes the devices do not change in between.
Additionally there is the assumption of index X will match device (name)
X, which does not hold true.

The most prominent issue is the inability to provide accurate number and
list of names.

Instead, we can have a single API, that provides both pieces of data in
one go - shorter and simpler code - in reliable manner.

Signed-off-by: Emil Velikov <[email protected]>
This way we can reuse it with the follow-up patches.

Signed-off-by: Emil Velikov <[email protected]>
v2: Add WSL case

v3: Drop sentinel, use ARRAY_SIZE

Signed-off-by: Emil Velikov <[email protected]>
Signed-off-by: Emil Velikov <[email protected]>
This way we can reuse it with the follow-up patches.

Signed-off-by: Emil Velikov <[email protected]>
evelikov-work and others added 10 commits June 6, 2023 12:53
Drop a bunch of set but unused variables and associated dead code.

Signed-off-by: Emil Velikov <[email protected]>
Drop a bunch of set but unused variables and associated dead code.

Note: if we are to remove the version handling, then 2/3 of the code in
this file will become unused. Yet it's fairly subtle code and there's a
notable chance of detection breaking if we remove it.

So keep the variables around and (void) prefix them so the compiler does
not warn.

Signed-off-by: Emil Velikov <[email protected]>
v2: Drop sentinel, use ARRAY_SIZE

Signed-off-by: Emil Velikov <[email protected]>
There are some corner cases where DRI3 does not work correctly. While
bug reports are appreciated, this enables users to get back to their
machines in meaningful way - aka w/o having to rebuild libva.

Signed-off-by: Emil Velikov <[email protected]>
Signed-off-by: Emil Velikov <[email protected]>
Signed-off-by: Emil Velikov <[email protected]>
@evelikov
Copy link
Contributor Author

evelikov commented Jun 6, 2023

While I appreciate the heartfelt apology, I am a firm believer that actions speak louder than words. Here's to this being the last instance.

MR has been updated and lightly tested - basically a simple s/getenv/secure_getenv/ change was required.

@XinfengZhang
Copy link
Contributor

hi @dvrogozh , could you help to dismiss your changes request if your concern was addressed already and no further concerns.
I will merge it , thanks

Copy link
Contributor

@dvrogozh dvrogozh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@XinfengZhang XinfengZhang merged commit f3752ec into intel:master Jun 8, 2023
@evelikov evelikov deleted the rework-device-names branch June 8, 2023 15:10
va/va.c Show resolved Hide resolved
va/va.c Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants