Skip to content

generic: nvmem: replace u-boot-env endianness workaround - #19490

Closed
mcprat wants to merge 6 commits into
openwrt:mainfrom
mcprat:nvmem-layout-endianness
Closed

mcprat wants to merge 6 commits into
openwrt:mainfrom
mcprat:nvmem-layout-endianness

Conversation

@mcprat

@mcprat mcprat commented Jul 22, 2025

Copy link
Copy Markdown
Contributor

ping @musashino205 @rmilecki @Ansuel

The previously proposed fix was to add further endianness conversion
for big-endian systems in order to match the expected crc32 value.
However, this worked because the expected value had endianness conversion
when it was actually not necessary, and should be removed instead.

Ref: 797177a ("kernel: update U-Boot nvmem driver to v6.2 release version")
Link: https://git.kernel.org/torvalds/linux/c/2d7521aa26ec

@github-actions github-actions Bot added the kernel pull request/issue with Linux kernel related changes label Jul 22, 2025
@musashino205

Copy link
Copy Markdown
Contributor

LGTM.

@leobsky

leobsky commented Jul 22, 2025

Copy link
Copy Markdown
Contributor

@mcprat

mcprat commented Jul 23, 2025

Copy link
Copy Markdown
Contributor Author

@leobsky This is true for upstream backports, however, we have even more backports than upstream which moves it to a layout driver just like linux main tree.

@mcprat
mcprat force-pushed the nvmem-layout-endianness branch from 1f1b170 to af14f53 Compare July 26, 2025 20:42
@mcprat

mcprat commented Jul 26, 2025

Copy link
Copy Markdown
Contributor Author

@hauke please merge to undo this mess

a proper bump to 6.6 will either:

  1. manually refresh only the removal lines of the "add layout driver" patch and preserve my patch, or,
  2. add a revert patch of the upstream backport so neither of the other patches need to be modified.

a proper bump to 6.12 will remove my patch as a backport instead of the old one...

@github-actions github-actions Bot added target/bcm27xx pull request/issue for bcm27xx target target/ramips pull request/issue for ramips target target/realtek pull request/issue for realtek target labels Jul 27, 2025
@leobsky

leobsky commented Jul 29, 2025

Copy link
Copy Markdown
Contributor

@mcprat perhaps is better leave 6.12 as it now, patch is already upstreamed.
6.6 only need the revert patch https://github.com/leobsky/openwrt/pull/1/commits

@mcprat

mcprat commented Jul 29, 2025

Copy link
Copy Markdown
Contributor Author

except that you're messing up the git history and the bump for both kernels look different without any reason, and both of them should be nearly identical and different than they are now

@robimarko
robimarko force-pushed the nvmem-layout-endianness branch from af14f53 to 26dc0c9 Compare July 29, 2025 19:46
@robimarko

Copy link
Copy Markdown
Contributor

Please drop the kernel update revert

@mcprat

mcprat commented Jul 29, 2025

Copy link
Copy Markdown
Contributor Author

it's there because last kernel bump is messing up the git history, mashing things that should be separate patches together, and commit message not accurate as a result

@KanjiMonster

Copy link
Copy Markdown
Member

The endian fix was included in 6.6.100 and 6.12.40, so with these bumps there is no need for any backported patches anymore. Bumping the kernel is essentially equivalent with replacing it with the accepted version.

A re-applied bump to 6.6.100 and 6.12.40 would just result in the same state as before, and I fail to see anything wrong with them.

@mcprat

mcprat commented Jul 30, 2025

Copy link
Copy Markdown
Contributor Author

@KanjiMonster

Copy link
Copy Markdown
Member

So then just fix up the patches (or probably just delete the old versions that were left?). I really don't see the need for a full revert of the kernel bumps.

@mcprat

mcprat commented Jul 30, 2025

Copy link
Copy Markdown
Contributor Author

it makes a mess of the git history for the patches, it's very confusing to look back on and see the bump for 6.6 and 6.12 were handled differently and claiming things that aren't true

@mcprat

mcprat commented Jul 30, 2025

Copy link
Copy Markdown
Contributor Author

really there's nothing in git history currently that explains why the patch is removed because it doesn't exist upstream

@mcprat

mcprat commented Jul 30, 2025

Copy link
Copy Markdown
Contributor Author

by the way, letting any patch at any time be removed from "pending" because it was backported without being added to "backports" in the same commit is a bad habit that should stop and would prevent this

@KanjiMonster

Copy link
Copy Markdown
Member

by the way, letting any patch at any time be removed from "pending" because it was backported without being added to "backports" in the same commit is a bad habit that should stop and would prevent this

That would require actively tracking all pending patches and most times noise, unless the accepted version is (significantly) different from the pending one.

But if a kernel bump includes a patch that is in pending/ then there is no way how that patch could exist a swell in backports - backports is for patches that didn't get backported to the kernel version (yet).

@mcprat

mcprat commented Jul 31, 2025

Copy link
Copy Markdown
Contributor Author

no it's easy, because while working on a kernel bump the conflict with "patch can be reverse applied" would appear, telling you which patch is a backport, then one does the small research to see what happened and move it to backports before doing the bump

anyway, I believe the final fix should be in our git history so it can be understood what happened without digging into the kernel, and there's no way to do that without a revert

@mcprat

mcprat commented Jul 31, 2025

Copy link
Copy Markdown
Contributor Author

I'll do that part even, give me a few hours

@KanjiMonster

Copy link
Copy Markdown
Member

no it's easy, because while working on a kernel bump the conflict with "patch can be reverse applied" would appear, telling you which patch is a backport, then one does the small research to see what happened and move it to backports before doing the bump

I really don't think this is worth the extra commit(s) and work for contributers. And especially not worth a revert.

anyway, I believe the final fix should be in our git history so it can be understood what happened without digging into the kernel, and there's no way to do that without a revert

And I really don't see the point of it. Nobody will use that commit (unless accidentally while bisecting), so the "final" version will never be built or tested or anything since it will be immediately deleted.

And even if I were to agree to you with having the commits, I wouldn't accept this without there being a re-application of the kernel bumps so that the kernel version at the end is again up to date.

@mcprat

mcprat commented Jul 31, 2025

Copy link
Copy Markdown
Contributor Author

and if you have a conflict without the "can be reverse applied", a bump commit author should be even more concerned

and if someone clearly shows a significant change, a bump commit author should also be more concerned with checking everything out...

@mcprat

mcprat commented Jul 31, 2025

Copy link
Copy Markdown
Contributor Author

I wouldn't accept this without there being a re-application of the kernel bumps so that the kernel version at the end is again up to date

understood on that point

@mcprat
mcprat force-pushed the nvmem-layout-endianness branch 2 times, most recently from d88f63a to d077441 Compare August 2, 2025 05:52
@mcprat

mcprat commented Aug 2, 2025

Copy link
Copy Markdown
Contributor Author

ok how does this look @KanjiMonster @hauke

I did not mean to impose extra work onto other people, I just want a consistent git history for file blaming and explanations in commit messages that make sense.

note that the actual backport patch stays in 6.6 now while the old proposed patch is removed.

@mcprat

mcprat commented Aug 2, 2025

Copy link
Copy Markdown
Contributor Author

one moment, something I tried with the script caused some to not refresh

@mcprat
mcprat force-pushed the nvmem-layout-endianness branch from d077441 to d54a137 Compare August 2, 2025 07:24
@mcprat

mcprat commented Aug 2, 2025

Copy link
Copy Markdown
Contributor Author

ok now the total diff is consistent with the current state

@mcprat

mcprat commented Aug 2, 2025

Copy link
Copy Markdown
Contributor Author

@hauke @KanjiMonster @robimarko can we make a decision here?

the purposes are

  1. 6.6 is currently broken for u-boot-env nvmem
  2. to preserve git history, somewhat the same reason but different situation that we now do commits like fa86277

@mcprat

mcprat commented Aug 5, 2025

Copy link
Copy Markdown
Contributor Author

@hauke can I at least get your thoughts on what should be done about the last bump?

if you merge this now it will resolve the issue without leaving the rest of the patches in a reversed state, as suggested.

@DragonBluep

Copy link
Copy Markdown
Contributor

I think adding a Fixes: 05d344cb2ca3 ("kernel: bump 6.6 to 6.6.100") tag is enough, there is no need to revert the commit.

@mcprat

mcprat commented Aug 6, 2025

Copy link
Copy Markdown
Contributor Author

the difference is git history though, the history for that patch ends the wrong way, and then theres a gap before the replacement is added

mcprat added 6 commits August 6, 2025 12:43
This reverts commit b6276e3.

Instead of transitioning to a new patch and then removing it later
as a backport, an obsolete patch is quoted as being accepted.
Redo the bump to preserve git history.

Signed-off-by: Michael Pratt <[email protected]>
This reverts commit 05d344c.

A fix for nvmem was not properly handled by transitioning
to a backport patch before doing this bump.
Not removing the endianness nvmem patch here results in
nvmem being broken for u-boot environment parsing.

Signed-off-by: Michael Pratt <[email protected]>
… fix

The previously proposed fix was to add further endianness conversion
for big-endian systems in order to match the expected crc32 value.
However, this worked because the expected value had endianness conversion
when it was actually not necessary, and should be removed instead.

Ref: 797177a ("kernel: update U-Boot nvmem driver to v6.2 release version")
Link: https://git.kernel.org/torvalds/linux/c/2d7521aa26ec
Signed-off-by: Michael Pratt <[email protected]>
This patch is accepted without changes
and backported into the next 6.12 release.

Copy from upstream and automatically refresh.

Signed-off-by: Michael Pratt <[email protected]>
Manually refreshed to undo a manual backport:
 - 823-v6.12-0003-nvmem-layouts-add-U-Boot-env-layout.patch

All other patches automatically refreshed.

Link: https://git.kernel.org/stable/linux/c/48e879184320
Link: https://cdn.kernel.org/pub/linux/kernel/v6.x/ChangeLog-6.6.100
Signed-off-by: Michael Pratt <[email protected]>
@mcprat
mcprat force-pushed the nvmem-layout-endianness branch from d54a137 to c49a3b1 Compare August 6, 2025 16:44
@mcprat

mcprat commented Aug 6, 2025

Copy link
Copy Markdown
Contributor Author

@KanjiMonster @hauke @robimarko @DragonBluep

For some reason, this community is suddenly afraid of a revert patch even though we have several, but perfectly fine with merging the bad work to begin with.
Even the author pointed out the problem, but nobody bothered to @ me for comments.

I would imagine that we want to set precedence and an example to show people how a bump should really be done so this doesn't happen again.

I'll keep repeating myself: if I just do a "fixes" patch, git history for tracing and index data that would otherwise be in the tree will never be there, it's just lost. The old patch disappears without a way to see the reason being that there is a new patch. The existing bump commit is not just "refreshing" the patches but editing them into a mashup of different upstream commits combined together and removing a patch claimed to be a backport that doesn't exist in upstream at all.

I want this to be less painful not more painful, stop letting your personal preference decide how we should fix this and just do it the right way. I would love to help further develop the scripts we use to warn people against stupid mistakes, and maybe automate even more of this, but if we can't do this simple thing to actually fix the problem then I'm not quite as interested to help in this area anymore.

@sppmasterspp

Copy link
Copy Markdown

For some reason, this community is suddenly afraid of a revert patch even though we have several, but perfectly fine with merging the bad work to begin with.

Maybe it's just a vacation time for the developers...

@hauke

hauke commented Aug 7, 2025

Copy link
Copy Markdown
Member

I agree with @KanjiMonster and @DragonBluep that a commit with a Fixes tag instead f the revert is better. This is for kernel 6.6, this code will not make it into any release.

The patch you are adding is actually part of kernel 6.6.100, see gregkh/linux@48e8791.

The patch target/linux/generic/backport-6.6/823-v6.12-0003-nvmem-layouts-add-U-Boot-env-layout.patch is moving a block of code, converting it back to the old code in there silently reverts the gregkh/linux@48e8791. change. I think this is even harder to track.

When a kernel update is done the commit message mentions why the patches were removed with references to the upstream commit.

@KanjiMonster

Copy link
Copy Markdown
Member

AFAIU the core issue here was that the version in our tree and the upstream accepted version were different enough that the usual detection of "can be reverse-applied" did not trigger, as the old version had a different approach and modified different parts, and not breaking the build.

This resulted in the old version kept in our tree, essentially fixing the issue again, so breaking it by undoing the upstreamed fix.

I still think reverting is overkill, and a commit just dropping the obsolete/duplicated fixes with an appropriate commit message is enough.

And requiring people bumping kernels to go through all patches in pending (of which there are > 100) is not a reasonable request. We don't even provide the means of efficiently doing so.

If we ever want to require/encourage something like this, we need to make this easy, ideally with a script. E.g. add an upstream submission / patchwork link to the patch, then have a script that can go through all patches and check them for being accepted / rejected / superseded by a newer version, maybe even replacing them directly.

@mcprat

mcprat commented Aug 7, 2025

Copy link
Copy Markdown
Contributor Author

the code made it into release already, if I presented it here first it would have been in our 6.6 before upstream. I wrongly assumed that it would be easy to add my patch in openwrt after it's accepted.

I'm well aware that I'm adding a patch of changes that already exist, but that's because they manually edited it to the old file location while we backport more in order to have it at the new file location in sync with mainline. not only does this keep different changes in different patches, but also it's the original copy of the patch with the original hash.

the alternative (what was done already) is to silently apply or in other words squash the two commits together. do you really think that's better to track?

commit message attempts to explain why but it doesn't make much sense once you realize the discrepancy, calling 2 different patches from 2 different authors the same patch.

and the commit message doesn't say we're combining 2 patches together because it's.... easier? I don't even know how I would explain that decision.

and yes, I agree that further work on the scripts would be necessary before enforcing more rules, but I also thought that we were already careful enough to prevent this

we now have commits all over the place that "revert" (by coping back) the moving of patches to a new kernel version patches directory, for the sake of tracking git file history more cleanly, this is not much different.

@hauke

hauke commented Aug 21, 2025

Copy link
Copy Markdown
Member

I would like to fix the problem like this: #19830

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel pull request/issue with Linux kernel related changes target/bcm27xx pull request/issue for bcm27xx target target/ramips pull request/issue for ramips target target/realtek pull request/issue for realtek target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants