Skip to content

Conversation

jwrdegoede
Copy link
Contributor

@jwrdegoede jwrdegoede commented Aug 31, 2021

Recent kernels have added new fields to the dmi/id/modalias file in the middle of the modalias (instead of adding them at the end).

Specifically new :br<value>: and (optional) :efr<value>: fields have been added between the :bd<value>: and :svn<value>: fields and a new :sku<value>: field has been added between the :pvr<value>: and :rvn<value>: fields.

A kernel-patch moving the sku field to the end of the modalias has been posted upstream:
https://lore.kernel.org/lkml/20210831130508.14511-1-hdegoede@redhat.com/

Unfortunately the same cannot be done for the new br and efr fields since those have been added more then a year ago and hwdb even already has some newer entries relying on the new br field being there (and thus not working with older kernels).

To fix all this, this commit makes the following changes:

  1. Replace any matches on :br<value> from newer entries with an *
  2. Replace bd<value>:svn<value> matches with: bd<value>:*svn<value> inserting an * where newer kernels will have the new br + efr fields
  3. Replace pvr<value>:rvn<value> matches with: pvr<value>:*rvn<value> inserting an * where newer kernels will have the new sku field

This makes these matches working with old as well as new kernels, including with kernels which have the fix to move the sku field to the end.

Link: #20550
Link: #20562

@jwrdegoede jwrdegoede changed the title hwdb: sensors: Fix some modalias matches no longer working with newer… hwdb: sensors: Fix some modalias matches no longer working with newer kernels Aug 31, 2021
@github-actions github-actions bot added the hwdb label Aug 31, 2021
@poettering
Copy link
Member

Hmm, so the ":" are used as field separators, so that we clearly can identify where a new field begins, and match the field type. Now, your matches want to ignore some fields in the middle, that might or might not exist, but then you don't look for the : at the next field anymore.

Or in other words: you'll now match field values which end in field names. I think that is kinda ugly though, since the beginning of fields is where the interesing stuff is.

or in other words: instead of ":" I think it would be better to use ":" to skip over the fields that might or might not exist.

@poettering
Copy link
Member

That said, maybe not looking for the field separators sucks either way. And hence maybe we should just duplicate the lines, and insist on the field separators both before and after the variable part i.e.:

Duplicate this line:

 sensor:modalias:acpi:BOSC0200*:dmi:bvnAmericanMegatrendsInc.:bvrY13D_KB133.103:bd06/01/2018:svnHampoo:pnDefaultstring:pvrV100:rvnHampoo:rnY13D_KB133:rvrV100:cvnDefaultstring:ct9:cvrDefaultstring:*

so that it becomes:


 sensor:modalias:acpi:BOSC0200*:dmi:bvnAmericanMegatrendsInc.:bvrY13D_KB133.103:bd06/01/2018:svnHampoo:pnDefaultstring:pvrV100:rvnHampoo:rnY13D_KB133:rvrV100:cvnDefaultstring:ct9:cvrDefaultstring:*
 sensor:modalias:acpi:BOSC0200*:dmi:bvnAmericanMegatrendsInc.:bvrY13D_KB133.103:bd06/01/2018:*:svnHampoo:pnDefaultstring:pvrV100:rvnHampoo:rnY13D_KB133:rvrV100:cvnDefaultstring:ct9:cvrDefaultstring:*

@poettering poettering added the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Sep 3, 2021
@jwrdegoede
Copy link
Contributor Author

On 9/1/21 2:03 PM, Lennart Poettering wrote:

That said, maybe not looking for the field separators sucks either way. And hence maybe we should just duplicate the lines, and insist on the field separators both /before/ and /after/ the variable part i.e.:

Duplicate this line:

sensor:modalias:acpi:BOSC0200*:dmi:bvnAmericanMegatrendsInc.:bvrY13D_KB133.103:bd06/01/2018:svnHampoo:pnDefaultstring:pvrV100:rvnHampoo:rnY13D_KB133:rvrV100:cvnDefaultstring:ct9:cvrDefaultstring:*

so that it becomes:

sensor:modalias:acpi:BOSC0200*:dmi:bvnAmericanMegatrendsInc.:bvrY13D_KB133.103:bd06/01/2018:svnHampoo:pnDefaultstring:pvrV100:rvnHampoo:rnY13D_KB133:rvrV100:cvnDefaultstring:ct9:cvrDefaultstring:*
sensor:modalias:acpi:BOSC0200*:dmi:bvnAmericanMegatrendsInc.:bvrY13D_KB133.103:bd06/01/2018:*:svnHampoo:pnDefaultstring:pvrV100:rvnHampoo:rnY13D_KB133:rvrV100:cvnDefaultstring:ct9:cvrDefaultstring:*

This solution only solves the new br and efr fields (which are next to each other), there also is the issue
of the new sku field being in the middle with some kernels which have shipped to end users
(the kernel patch to move sku to the end is finding its way upstream, but it would be nice to also
fix this issue on the hwdb side of things).

So if we want to fix that too, then your suggestion would require adding 3 match lines for what used
to be 1 line, this will make entries like the GPD win one:

sensor:modalias:acpi:KIOX000A*:dmi:bvnAmericanMegatrendsInc.:bvr5.11:bd10/25/2016:*svnDefaultstring:pnDefaultstring:pvrDefaultstring:*rvnAMICorporation:rnDefaultstring:rvrDefaultstring:cvnDefaultstring:ct3:cvrDefaultstring:*
sensor:modalias:acpi:KIOX000A*:dmi:bvnAmericanMegatrendsInc.:bvr5.11:bd11/18/2016:*svnDefaultstring:pnDefaultstring:pvrDefaultstring:*rvnAMICorporation:rnDefaultstring:rvrDefaultstring:cvnDefaultstring:ct3:cvrDefaultstring:*
sensor:modalias:acpi:KIOX000A*:dmi:bvnAmericanMegatrendsInc.:bvr5.11:bd12/23/2016:*svnDefaultstring:pnDefaultstring:pvrDefaultstring:*rvnAMICorporation:rnDefaultstring:rvrDefaultstring:cvnDefaultstring:ct3:cvrDefaultstring:*
sensor:modalias:acpi:KIOX000A*:dmi:bvnAmericanMegatrendsInc.:bvr5.11:bd12/26/2016:*svnDefaultstring:pnDefaultstring:pvrDefaultstring:*rvnAMICorporation:rnDefaultstring:rvrDefaultstring:cvnDefaultstring:ct3:cvrDefaultstring:*
sensor:modalias:acpi:KIOX000A*:dmi:bvnAmericanMegatrendsInc.:bvr5.11:bd02/21/2017:*svnDefaultstring:pnDefaultstring:pvrDefaultstring:*rvnAMICorporation:rnDefaultstring:rvrDefaultstring:cvnDefaultstring:ct3:cvrDefaultstring:*
sensor:modalias:acpi:KIOX000A*:dmi:bvnAmericanMegatrendsInc.:bvr5.11:bd03/20/2017:*svnDefaultstring:pnDefaultstring:pvrDefaultstring:*rvnAMICorporation:rnDefaultstring:rvrDefaultstring:cvnDefaultstring:ct3:cvrDefaultstring:*
sensor:modalias:acpi:KIOX000A*:dmi:bvnAmericanMegatrendsInc.:bvr5.11:bd05/25/2017:*svnDefaultstring:pnDefaultstring:pvrDefaultstring:*rvnAMICorporation:rnDefaultstring:rvrDefaultstring:cvnDefaultstring:ct3:cvrDefaultstring:*

Quite ugly. I can either copy the entire block 3 times and add the *: which you want added instead of just the *, or I can do 3 copies of each line before switching to adjusting the next line, but either way the end result will be pretty unreadable IMHO. Also if you look at the places where the * for the new fields are added then the chanches of something showing up there on another board which will all of a sudden make the lines match on that other board are pretty much 0.

So I would prefer to keep this as is.

@poettering, If you really do want me to respin this, then please let me know how you want to deal with the sku issue, do you want to use 3 lines for each entry, or do you want to ignore the sku issue, relying solely on the kernel-side fix to hit the stable series and use 2 lines for each entry ?

@jwrdegoede
Copy link
Contributor Author

jwrdegoede commented Sep 9, 2021

The kernel fix to move the new sku field to the end of the modalias has been merged and also added to the 5.13.y and 5.14.y stable series.

@poettering, ping, can you please let me know how you want to proceed with this? (see my previous comment)

@yuwata yuwata added needs-review and removed reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels Sep 9, 2021
@poettering
Copy link
Member

Hmm, i am unsure. I wonder if one way out is to add a NEWS entry that asks people to backport the kernel fix, and then adjust our hwdb to just use the "right" order.

I mean, it's a trivial fix, it should not be asking too much?

@jwrdegoede
Copy link
Contributor Author

Hmm, i am unsure. I wonder if one way out is to add a NEWS entry that asks people to backport the kernel fix, and then adjust our hwdb to just use the "right" order.

I mean, it's a trivial fix, it should not be asking too much?

The kernels with the new behavior have only been out for about a year. That means a lot of people will still be using the old kernels. OTOH that is long enough that quite a few people have the new ones too. Expecting people who for some reason want to try, or are getting (through there distro) a new systemd to patch there kernels seems a bit far fetched and not very userfriendly.

I still believe that my original pull-req is the best solution here, I know that just inserting a * is breaking the field separation, but that really is fine the chances of this causing a false match are negligible. E.g. if you look closely we already have a ton of matches which match on e.g. *svnVENDOR* instead of on *:svnVENDOR:* and those are not causing any issues at all.

@jwrdegoede
Copy link
Contributor Author

@poettering ping?

The changes to move the sku to the end have landend in both the 5.13.y and 5.14.y stable series. So that only leaves the (older) problem of the :br<value>:efr<value>: fields being inserted into the middle of the modalias about a year ago.

So with that I could implement your original suggestion to add 2 matches for each currently affected match inserting a :* in there, rather then just a * to keep the field separation clear.

I still think this is overkill, but I would like to see this fixed/merged one way or the other, so if you want me to respin this using the 2 matches for each old affected match approach let me know and I'll happily do that.

@poettering
Copy link
Member

so, i was silent because i couldn't make my mind up. hence, i guess let's do it your way. But please, add some comments to the hwdb entries, that explain why we have these checks so lose. and maybe one day we can remove/tighten them again once we stopped caring for the then really old kernels.

@poettering
Copy link
Member

hence, looks good to merge, but please add the suggested comments.

@poettering poettering added reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks and removed please-review labels Sep 28, 2021
@jwrdegoede jwrdegoede force-pushed the hwdb-sensors-modalias-fix branch from 1e4ec7e to 7706e03 Compare September 28, 2021 19:41
@jwrdegoede
Copy link
Contributor Author

I've just pushed out a new version adding the requested comments.

… kernels

Kernels >= 5.8 have added new fields to the dmi/id/modalias file in the
middle of the modalias (instead of adding them at the end).

Specifically new ":br<value>:" and (optional) ":efr<value>:" fields have
been added between the ":bd<value>:" and ":svn<value>:" fields.

Note the 5.13.0 and 5.14.0 kernels also added a new ":sku<value>:" field
between the ":pvr<value>:" and ":rvn<value>:" fields, this has been fixed
in later 5.13.y and 5.14.y releases, by moving the sku field to the end:
https://lore.kernel.org/lkml/20210831130508.14511-1-hdegoede@redhat.com/

Unfortunately the same cannot be done for the new br and efr fields since
those have been added more then a year ago and hwdb even already has some
newer entries relying on the new br field being there (and thus not working
with older kernels).

Fix the issue with the br and efr fields through the following changes:

1. Replace any matches on ":br<value>" from newer entries with an '*'
2. Replace "bd<value>:svn<value>" matches with: "bd<value>:*svn<value>"
   inserting an '*' where newer kernels will have the new br + efr fields

This makes these matches working with old as well as new kernels.

Link: systemd#20550
Link: systemd#20562
@jwrdegoede jwrdegoede force-pushed the hwdb-sensors-modalias-fix branch from 7706e03 to 3211bc2 Compare September 29, 2021 08:59
@jwrdegoede
Copy link
Contributor Author

I've just pushed a new version replacing the "newer" in the comment with ">= 5.8" to make this explicit.

@poettering poettering added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels Sep 29, 2021
@poettering
Copy link
Member

lgtm

@poettering poettering merged commit f813515 into systemd:main Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed hwdb
Development

Successfully merging this pull request may close these issues.

3 participants