Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Oliva <oliva@gnu.org>
To: John Harrison <john.c.harrison@intel.com>
Cc: intel-gfx@lists.freedesktop.org, stable@vger.kernel.org
Subject: Re: [Intel-gfx] [PATCH] [i915] avoid infinite retries in GuC/HuC loading
Date: Sun, 26 Mar 2023 06:46:24 -0300	[thread overview]
Message-ID: <or1qlbvo9b.fsf@lxoliva.fsfla.org> (raw)
In-Reply-To: <b9a2746f-bace-3a1e-eb82-8e8eecddb6ae@intel.com> (John Harrison's message of "Fri, 24 Mar 2023 11:45:07 -0700")

Hello, John,

On Mar 24, 2023, John Harrison <john.c.harrison@intel.com> wrote:

> On 3/12/2023 12:56, Alexandre Oliva wrote:
>> If two or more suitable entries with the same filename are found in
>> __uc_fw_auto_select's fw_blobs, and that filename fails to load in the
>> first attempt and in the retry, when __uc_fw_auto_select is called for
>> the third time, the coincidence of strings will cause it to clear
>> file_selected.path at the first hit, so it will return the second hit
>> over and over again, indefinitely.
>> 
>> Of course this doesn't occur with the pristine blob lists, but a
>> modified version could run into this, e.g., patching in a duplicate
>> entry, or (as in our case) disarming blob loading by remapping their
>> names to "/*(DEBLOBBED)*/", given a toolchain that unifies identical
>> string literals.
> Not sure what you mean by disarming?

Our users find loading nonfree firmware harmful.

> I think what you are saying is that you made a change similar to this?
>     #define __MAKE_UC_FW_PATH_MMP(prefix_, name_, major_, minor_,
> patch_) "i915/invalid_file_name.bin"

Yeah, that's the jist of it.  The name we use is "/*(DEBLOBBED)*/", so
that it can't possibly be satisfied.

> So all entries in the table have the exact same filename.

*nod*

> And with the toolchain unification comment, that means not just a
> matching string but the same string pointer. Thus, the search code is
> getting confused.

Exactly

> I'm not sure that is really a valid use case that the driver code
> should be expected to support.

It's most certainly not.  As I wrote, I'd be happy to keep on carrying
the patch that adjusts the code to cope with our changes.  I just
thought the same issue could come up by, say, mistakenly applying a
patch twice to add support for a new card, a circumstance in which one
might not have the card readily available to try it out.

> Even without the infinite loop, the driver is not
> going to load because you have removed the firmware files?

Oh, no, the driver loads just fine even without those blobs, and that's
much nicer of you than other drivers for hardware that doesn't really
require blobs, but that insist on bailing out if the firmware can't be
loaded.  i915 hasn't been hostile like that.

When you override the firmware filenames, and it fails to load, the
driver makes it a (reasonable IMHO) hard fail, but when it just fails to
find the regular firmware files, it's nice that it proceeds that does
the best it can.

> However, I think you are saying that the problem would also exist if
> there was some kind of genuine duplication in the table?

Yes.  Not the kind you mention, for different platforms, but an actual
duplicate entry, such as what you might get if you applied a patch that
added an entry for a new card, and then applied it again, resolving the
conflicts in a way that retained the duplicate entries.

> So there can only be a problem if a single platform specifies the same
> filename multiple times? Which would be a bug in the table because
> why? It would be redundant entries that have no purpose.

Agreed.

> Note that I'm not saying we don't want to take your change. But I
> would like to understand if there is a genuine issue that maybe needs
> a better fix. E.g. should the table verification code be enhanced to
> just reject the table entirely if there are such errors present.

Table verification might wish to detect and report duplicate filenames
for the same platform, to catch even alternating duplicates (e.g. "a",
then "b", then "a" again), but it would be kind if you didn't make that
a hard error, otherwise we'd have to tweak it to cope with our own
"/*(DEBLOBBED)*/" duplicates.

Another approach, that would probably be more efficient as the table
grows, is to store in uc_fw a pointer to or index of the current or next
entry to be searched, so that the code doesn't have to iterate over the
table at every try (O(n^2)), and instead takes it from exactly where it
left off, running overall a single time over the whole table (O(n)), at
the cost of a pointer or index in uc_fw.  Then, duplicates in the table
wouldn't matter at all.

> Also, is this string unification thing a part of the current gcc
> toolchain?

Yeah, compilers and linkers have been unifying (read-only) string
literals for a very long time.

Thanks,

-- 
Alexandre Oliva, happy hacker                https://FSFLA.org/blogs/lxo/
   Free Software Activist                       GNU Toolchain Engineer
Disinformation flourishes because many people care deeply about injustice
but very few check the facts.  Ask me about <https://stallmansupport.org>

  reply	other threads:[~2023-03-26  9:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-12 19:56 [Intel-gfx] [PATCH] [i915] avoid infinite retries in GuC/HuC loading Alexandre Oliva
2023-03-20 23:15 ` [Intel-gfx] ✗ Fi.CI.BUILD: warning for " Patchwork
2023-03-20 23:15 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: " Patchwork
2023-03-20 23:33 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-03-21  3:55 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2023-03-22 20:48 ` [Intel-gfx] [PATCH] [i915] " Rodrigo Vivi
2023-03-23  1:30   ` Alexandre Oliva
2023-03-24 18:45 ` John Harrison
2023-03-26  9:46   ` Alexandre Oliva [this message]
2023-03-31 19:14     ` John Harrison
2023-04-02 20:42       ` Alexandre Oliva

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=or1qlbvo9b.fsf@lxoliva.fsfla.org \
    --to=oliva@gnu.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=john.c.harrison@intel.com \
    --cc=stable@vger.kernel.org \
    /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