summaryrefslogtreecommitdiff
path: root/drivers
AgeCommit message (Collapse)AuthorFilesLines
2026-03-09staging: rtl8723bs: fix indentation, line length and declarationsJose A. Perez de Azpillaga1-4/+8
Fix indentation to match opening parentheses, wrap lines exceeding 100 columns, and add a missing blank line after variable declarations. Signed-off-by: Jose A. Perez de Azpillaga <azpijr@gmail.com> Reviewd-by: Ethan Tidmore <ethantidmore06@gmail.com> Link: https://patch.msgid.link/20260303173844.47975-5-azpijr@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-03-09staging: rtl8723bs: curly brace consistencyJose A. Perez de Azpillaga1-6/+10
Fix unbalanced braces and improve readability. Signed-off-by: Jose A. Perez de Azpillaga <azpijr@gmail.com> Reviewed-by: Ethan Tidmore <ethantidmore06@gmail.com> Link: https://patch.msgid.link/20260303173844.47975-4-azpijr@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-03-09staging: rtl8723bs: format operators and logical continuationsJose A. Perez de Azpillaga1-24/+24
Fix spaces around different operators. Move logical continuations to the end of the previous line. Signed-off-by: Jose A. Perez de Azpillaga <azpijr@gmail.com> Reviewed-by: Ethan Tidmore <ethantidmore06@gmail.com> Link: https://patch.msgid.link/20260303173844.47975-3-azpijr@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-03-09staging: rtl8723bs: remove redundant blank linesJose A. Perez de Azpillaga1-14/+0
Remove multiple blank lines and unnecessary blank lines before closing braces. Signed-off-by: Jose A. Perez de Azpillaga <azpijr@gmail.com> Reviewed-by: Ethan Tidmore <ethantidmore06@gmail.com> Link: https://patch.msgid.link/20260303173844.47975-2-azpijr@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-03-09staging: rtl8723bs: fix bitwise OR operator spacingJose A. Perez de Azpillaga1-4/+2
Fix spaces between bitwise OR operations rtw_action_frame_parse() for better readability. Signed-off-by: Jose A. Perez de Azpillaga <azpijr@gmail.com> Reviewed-by: Ethan Tidmore <ethantidmore06@gmail.com> Link: https://patch.msgid.link/20260302215208.67045-1-azpijr@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-03-09staging: vme_user: remove unimplemented #if 0 code blocksAlbab Hasan1-10/+0
Remove dead code in #if 0 blocks from struct vme_master and struct vme_slave. these were never implemented or compiled in. checkpatch.pl reports: WARNING: Consider removing the code enclosed by this #if 0 and its #endif No functional changes. Signed-off-by: Albab Hasan <albabhasan276@gmail.com> Reviewed-by: Ethan Tidmore <ethantidmore06@gmail.com> Link: https://patch.msgid.link/20260228153809.15398-1-albabhasan276@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-03-09staging: rtl8723bs: remove unused 'ratelen' parameter from ↵Nikolay Kulikov4-10/+5
rtw_check_network_type() The rtw_check_network_type() function takes a 'ratelen' parameter, but does not use it in any way. Also remove the local variable in rtw_ap.c created just to pass a value to this unused parameter. Signed-off-by: Nikolay Kulikov <nikolayof23@gmail.com> Reviewed-by: Ethan Tidmore <ethantidmore06@gmail.com> Link: https://patch.msgid.link/20260228130917.4123-1-nikolayof23@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-03-09staging: rtl8723bs: Fix logical continuation placementMariyam Shahid1-6/+6
Move logical operators to the end of the previous line to fix checkpatch warnings. Signed-off-by: Mariyam Shahid <mariyam.shahid135@gmail.com> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://patch.msgid.link/20260227071942.6328-1-mariyam.shahid135@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-03-09staging: rtl8723bs: refactor halbtc8723b1ant_CoexTableWithType() to remove ↵Bera Yüzlü1-44/+14
duplication Replace the verbose switch-case block with a constant 2D array lookup. This makes the function much more concise and easier to read without changing the underlying behavior. Signed-off-by: Bera Yüzlü <b9788213@gmail.com> Link: https://patch.msgid.link/20260226130253.2145-1-b9788213@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-03-09fbtft: Update REAMDE to slow down the stream of undesired cleanupsAndy Shevchenko1-22/+7
Lately the enormous amount of some untested cleanups started coming to a mailing list. This adds an unneeded and undesired burden on the reviewers and maintainers. Try to stop that by clearly state what we accept and on what conditions in the README file. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20260226080845.4081732-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-03-09staging: greybus: remove redundant 'int' from unsigned long longOskar Ray-Frayssinet1-1/+1
Replace 'unsigned long long int' with 'unsigned long long' as the 'int' suffix is unnecessary and not preferred by kernel coding style. Signed-off-by: Oskar Ray-Frayssinet <rayfraytech@gmail.com> Link: https://patch.msgid.link/20260304193206.4992-1-rayfraytech@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-03-09staging: rtl8723bs: replace msleep() with fsleep() in rtw_cmd.cJose A. Perez de Azpillaga1-2/+3
Replace msleep() with fsleep() in rtw_cmd.c to improve delay precision and follow modern kernel practices. Specifically, this fixes a checkpatch warning for the 10ms delay in _rtw_free_evt_priv() and updates the 100ms polling loops in rtw_chk_hi_queue_hdl() and rtw_free_cmd_priv() for consistency. Signed-off-by: Jose A. Perez de Azpillaga <azpijr@gmail.com> Reviewed-by: Ethan Tidmore <ethantidmore06@gmail.com> Link: https://patch.msgid.link/20260227084623.209913-1-azpijr@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-03-09staging: greybus: arche: use sysfs_emit() instead of sprintf()Ruslan Valiyev1-5/+5
Replace sprintf() with sysfs_emit() in state_show() sysfs attribute callbacks in arche-platform.c and arche-apb-ctrl.c. Checkpatch complains about code using sprintf(). This code here is obviously safe as-is, but it would be more appropriate to use sysfs_emit(). Signed-off-by: Ruslan Valiyev <linuxoid@gmail.com> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://patch.msgid.link/20260226074858.67635-1-linuxoid@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-03-09staging: greybus: arche-platform: Use sysfs_emit instead of sprintfShubham Chakraborty1-5/+5
Refactor sprintf to sysfs_emit in the show function of the arche platform driver. This follows the standard kernel practice of using sysfs_emit for sysfs attributes, ensuring consistent output formatting and newline handling. Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com> Link: https://patch.msgid.link/20260226065239.11698-1-chakrabortyshubham66@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-03-09mmc: sdhci-esdhc-imx: add NXP S32N79 supportCiprian Marian Costea1-0/+9
Add support for the uSDHC controller found in NXP S32N79 automotive SoCs, which reuse the existing sdhci-esdhc-imx driver with slice difference. Compared with s32g2/s32g3, needn't set ESDHC_FLAG_SKIP_CD_WAKE flag because s32n79 does not have this limitation. Co-developed-by: Larisa Grigore <larisa.grigore@nxp.com> Signed-off-by: Larisa Grigore <larisa.grigore@nxp.com> Signed-off-by: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com> Reviewed-by: Haibo Chen <haibo.chen@nxp.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2026-03-09lib/fonts: Store font data for user space with font_data_export()Thomas Zimmermann1-55/+2
Add font_data_export() and update consoles to use it. The helper font_data_export() is based on code in fbcon_get_font(). It extends the size of a single glyph to match the requested vpitch, which us usually 32 bytes for fonts from user space. Internal fonts have a pitch according to the glyph's height. The implementation of font_data_export() differs in several ways from the original code. The original implementation distinguished between different pitches of the font data. This is not necessary as the pitch is a parameter in the copying. There was also special handling for a font pitch of 3 bytes, which got expanded to 4 bytes (with trailing bits on each scanline). The logic originated from long before git history exists even in the historical tree. So it is not clear why this was implemented. It is not what user space expects. The setfont utitlity loads font with 3-bytes pitches and expects to read such fonts with a 3-byte pitch. For any font width, the font pitch is always the width extended to the next multiple of 8. See [1] for the user-space font-reading code. With the changes to handling the font pitches, font_data_export() replaces the original code's various special cases with a single copying logic. v3: - fix typos (Helge) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://github.com/legionus/kbd/blob/v2.9.0/src/libkfont/kdfontop.c#L73 # [1] Signed-off-by: Helge Deller <deller@gmx.de>
2026-03-09lib/fonts: Create font_data_t from struct console_font with font_data_import()Thomas Zimmermann2-52/+8
Add font_data_import() and update consoles to use it. The implementation of font_data_import() is based on code from fbcon, which supports overflow checks and crc32 checksums. Fbcon uses the crc32 checksum. Newport_con now implements the same overflow checks as fbcon. As before, this console does not support checksums, which are optional. Newport_con can now also handle input font data with a vertical pitch other than 32 bytes. (The vertical pitch is the offset between two glyphs in the font data.) As an internal change, remove the const qualifier from the data field if struct font_data. This allows font_data_import() to write the data without type casting. For all users of the font data via font_data_t, the stored data is still read only. v3: - fix typos Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
2026-03-09lib/fonts: Compare font data for equality with font_data_is_equal()Thomas Zimmermann2-9/+2
Add font_data_is_equal() and update consoles to use it. Font data is equal if it has the same size and contains the same values on all bytes. Only fbcon uses a crc32 checksum. If set in both operands the checksums have to be equal. The new helper also guarantees to not compare internal fonts against fonts from user space. Internal fonts cannot be ref-counted, so making them equal to user-space fonts with the same byte sequence results in undefined behavior. The test only compares data buffers. Their interpretation is up each console. Therefore remove a width test in fbcon_set_font(). v3: - rebase onto font_data_{get,put}() Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
2026-03-09lib/fonts: Manage font-data lifetime with font_data_get/_put()Thomas Zimmermann3-51/+38
Add font_data_get() and font_data_put(). Update consoles to use them over REFCOUNT() and plain kfree(). Newly allocated font data starts with a reference count of 1. Loading the font puts the previously loaded font. If the reference count reaches zero, font_data_put() frees the font data. The kernel stores a refcount of zero for internal font data. Invoking font_data_get() and font_data_put() tests this internally and returns success without further operation. From the caller's perspective, getting and putting works the same for all font data. Fbcon used the userfont flag distinguish between internal fonts and fonts loaded by user space. Only the latter where refcounted. With the new helper's automatic handling of internal font data, remove the userfont flag from fbcon. Newport_con uses a default font, FONT_DATA, until user space loads custom font data. Remove all special cases for FONT_DATA, as the get and put calls' read-only handling also covers this case. v3: - fix module linker error wrt font symbols (Nathan, Arnd) - fix typos Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
2026-03-09lib/fonts: Read font size with font_data_size()Thomas Zimmermann2-8/+8
Add font_data_size() and update consoles to use it. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
2026-03-09lib/fonts: Store font data as font_data_t; update consolesThomas Zimmermann3-26/+38
Store font data as pointer to font_data_t instead of unsigned char. Update consoles. Pointers to font data refer to the raw data. There is a hidden header before the data that contains additional state. Document the existing layout and semantics of font_data_t. The data field in struct vc_font can be used by any console. Therefore it still points to plain data without the additional header. Fbcon sets its value from struct fbcon_display.fontdata. Hence, update the size test in fbcon_resize() to use struct fbcon_display.fontdata instead of struct vc_font.data. v3: - fix typos (Helge) v2: - 'Font lookup' -> 'Font description' in <linux/font.h> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
2026-03-09lib/fonts: Remove FNTCHARCNT()Thomas Zimmermann1-1/+0
The character count in the font data is unused. The internal fonts also do not set it. Remove FNTCHARCNT(). Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
2026-03-09vt: Calculate font-buffer size with vc_font_size()Thomas Zimmermann1-7/+2
In fbcon, fbcon_resize() computes the size of the font buffer from the values stored in vc_font. Move these calculations to the dedicated helpers vc_font_pitch() and vc_font_size(). Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
2026-03-09vt: Store font in struct vc_fontThomas Zimmermann3-10/+9
Replace struct console_font with struct vc_font for the type of the vc_font field of struct vc_data. Struct console_font is UAPI, which prevents further changes. Hence a new data type is required. Struct console_font has a documented vertical pitch of 32 bytes. This is not the case after the font data has been loaded into the kernel. Changing the type of vc_font addresses this inconsistency. The font data is now declared as constant, as it might come from the kernel's read-only section. There's some fallout throughout the console code where non-const variables refer to it. Fix them. A later update will declare the font data to a dedicated data type. v3: - fix typos Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
2026-03-09fbdev: Declare src parameter of fb_pad_ helpers as constantThomas Zimmermann1-3/+3
Fbdev's padding helpers do not modify the source buffer. Declare the parameter as 'const'. Fbcon's font-rendering code calls these helpers with the font data. Declaring src as const will allow for making the font data constant as well. While at it, also remove the extern qualifier from the function declarations in the header file. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
2026-03-09nvdimm/bus: Fix potential use after free in asynchronous initializationIra Weiny1-2/+3
Dingisoul with KASAN reports a use after free if device_add() fails in nd_async_device_register(). Commit b6eae0f61db2 ("libnvdimm: Hold reference on parent while scheduling async init") correctly added a reference on the parent device to be held until asynchronous initialization was complete. However, if device_add() results in an allocation failure the ref count of the device drops to 0 prior to the parent pointer being accessed. Thus resulting in use after free. The bug bot AI correctly identified the fix. Save a reference to the parent pointer to be used to drop the parent reference regardless of the outcome of device_add(). Reported-by: Dingisoul <dingiso.kernel@gmail.com> Closes: http://lore.kernel.org/8855544b-be9e-4153-aa55-0bc328b13733@gmail.com Fixes: b6eae0f61db2 ("libnvdimm: Hold reference on parent while scheduling async init") Cc: stable@vger.kernel.org Reviewed-by: Dave Jiang <dave.jiang@intel.com> Link: https://patch.msgid.link/20260306-fix-uaf-async-init-v1-1-a28fd7526723@intel.com Signed-off-by: Ira Weiny <ira.weiny@intel.com>
2026-03-09drivers: rpmsg: class_destroy() is deprecatedJori Koolstra1-2/+2
The class_destroy() function documents that: Note, the pointer to be destroyed must have been created with a call to class_create(). However, class_create() is deprecated. rpmsg already uses class_register() but the class_destroy() calls should also be replaced with class_unregister(). Link: https://lore.kernel.org/all/2023040244-duffel-pushpin-f738@gregkh/ Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20260308140850.1138376-1-jkoolstra@xs4all.nl Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
2026-03-09remoteproc: keystone: Request IRQs in probe()Andrew Davis1-26/+15
IRQs can be registered in probe and only need to be enabled/disabled during remoteproc start/stop. This lets us catch IRQ issues early and simplify remoteproc start/stop. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20260302201734.320747-1-afd@ti.com Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
2026-03-09platform/x86: dell-wmi-sysman: Use sysfs_emit{_at} in show functionsThorsten Blum1-6/+7
Replace sprintf() with sysfs_emit() and sysfs_emit_at() in sysfs show functions. sysfs_emit() and sysfs_emit_at() are preferred for formatting sysfs output because they provide safer bounds checking. In reset_bios_show(), use sysfs_emit_at() to avoid manual buffer size accounting. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Link: https://patch.msgid.link/20260305140912.258090-2-thorsten.blum@linux.dev Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2026-03-09dm-verity-fec: improve comments for fec_read_bufs()Eric Biggers1-8/+22
Update the comments in and above fec_read_bufs() to more clearly describe what it does. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: log target_block instead of index_in_regionEric Biggers1-12/+14
The log message for a FEC error or correction includes the data device name and index_in_region as the context. Although the result of FEC (for a particular dm-verity instance) is expected to be the same for a given index_in_region, index_in_region does not uniquely identify the actual target block that is being corrected. Since that value (target_block) is likely more useful, log it instead. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: make fec_decode_bufs() just return 0 or errorEric Biggers1-7/+4
fec_decode_bufs() returns the number of errors corrected or a negative errno value. However, the caller just checks for an errno value and doesn't do anything with the number of errors corrected. Simplify the code by just returning 0 instead of the number of errors corrected. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: pass down index_in_region instead of rsbEric Biggers1-21/+26
Replace 'rsb', which is a byte index, with 'index_in_region' which is a block index. The block index is slightly easier to compute, it matches what fec_read_bufs() wants, and it avoids the mismatch between the name and the units of the variable. ('rsb' stood for "Reed-Solomon block", but its units were bytes, not blocks.) fec_decode_bufs() does want it as a byte index when computing parity_block, but that's easily handled locally. As long as the parameters to the log messages are being adjusted, also eliminate the unnecessary casts to 'unsigned long long'. %llu is the correct way to print a u64 in the Linux kernel, as documented in printk-formats.rst. There's no PRIu64 macro like there is in userspace. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: compute target region directlyEric Biggers1-21/+16
Instead of determining the target block's region by checking which block of the k blocks being iterated over in fec_read_bufs() is equal to the target block, instead just directly use the quotient of the division of target_block by region_blocks. This is the same value, just derived in a more straightforward way. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: move computation of offset and rsb down a levelEric Biggers1-28/+18
verity_fec_decode() computes (offset, rsb) from the target block index and calls fec_decode_rsb() with these parameters. Move this computation into fec_decode_rsb(), and rename fec_decode_rsb() to fec_decode(). This ends up being simpler and enables further refactoring, specifically making use of the quotient from the division more easily. The function renaming also eliminates a reference to the ambiguous term "rsb". This change does mean the same div64_u64_rem() can now be executed twice per block, since verity_fec_decode() calls fec_decode() up to twice per block. However, this cost is negligible compared to the rest of FEC. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: rename block_offset to out_posEric Biggers1-15/+13
The current position in the output block buffer is called 'pos' in fec_decode_rsb(), and 'block_offset' in fec_read_bufs() and fec_decode_bufs(). These names aren't very clear, especially 'block_offset' which is easily confused with the offset of a message or parity block or the position in the current parity block. Rename it to 'out_pos'. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: simplify deinterleavingEric Biggers1-15/+4
Since fec_read_bufs() deinterleaves the bytes from 'bbuf' sequentially starting from 'block_offset', it can just do simple increments instead of the more complex fec_buffer_rs_index() computation. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: simplify computation of ileavedEric Biggers1-12/+1
fec_read_bufs() just iterates over a sequence of message blocks with step size region_blocks. At each step, 'ileaved' is just the offset (in bytes) to one of these blocks. Compute it in the straightforward way, eliminating fec_interleave(). In more detail, previously the code computed 'ileaved = (n / k) + (n % k) * (region_blocks * block_size)' where n = rsb * k + i and 0 <= i < k. Substituting 'n' gives: ileaved = ((rsb * k + i) / k) + ((rsb * k + i) % k) * region_blocks * block_size = rsb + (i * region_blocks * block_size) The result is more efficient and easier to understand. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: simplify computation of rsbEric Biggers1-3/+3
To compute 'rsb', verity_fec_decode() divides 'offset' by 'v->fec->region_blocks << v->data_dev_block_bits', then subtracts the quotient times that divisor. That's simply the long way to do a modulo operation, i.e. a - b * floor(a / b) instead of just a % b. Use div64_u64_rem() to get the remainder more concisely. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: rename rounds to region_blocksEric Biggers2-9/+9
It's hard to reconcile the value stored in dm_verity_fec::rounds with its name and documentation. Most likely "rounds" is being used as an alias for what is more commonly called the interleaving degree or "number of ways". But the interleaving is done at the byte level, whereas the units of "rounds" are blocks. So it's not really that. In practice, the reason the code needs this value is that it expresses the number of blocks in each "region" of the message data, where each region contains the bytes from a particular index in the RS codewords. Rename it to region_blocks to make the code a bit more understandable. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: replace io_size with block_sizeEric Biggers2-18/+14
dm-verity's FEC implementation assumes that data_block_size == hash_block_size, and it accesses the FEC device in units of the same size. Many places in the code want that size and compute it on-demand as '1 << v->data_dev_block_bits'. However, it's actually already available in v->fec->io_size. Rename that field to block_size, initialize it a bit earlier, and use it in the appropriate places. Note that while these sizes could in principle be different, that case is not supported. So there's no need to complicate the code for it. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: rename "RS block" to "RS codeword"Eric Biggers2-33/+35
The literature refers to the unit of a Reed-Solomon (RS) code as either a "block" or a "codeword". dm-verity's source code uses "RS block". Unfortunately, that's really confusing because "block" already means something else in dm-verity. Especially problematic is the fact that dm-verity sometimes uses "RS block" to mean an RS codeword and sometimes to mean some dm-verity block that's related to the RS decoding process, for example one of the blocks that shares its RS codewords with the target block. Let's use "RS codeword" instead, or "RS message" when referring to just the message part of the codeword. Update some comments, function names, macro names, and variable names accordingly. No functional change. There are still some remaining comments where "RS block" refers to a dm-verity block. Later commits will handle these cases. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: use standard names for Reed-Solomon parametersEric Biggers2-19/+19
"RS(n, k)" is by far the most common and standard notation for describing Reed-Solomon codes. Each RS codeword consists of 'n' symbols, divided into 'k' message symbols and 'n - k' parity symbols. 'n - k' is also the number of roots of the generator polynomial. dm-verity uses "RS(M, N)" instead. I haven't been able to find any other source that uses this convention. This quirk makes the code harder to understand than necessary, especially due to dm-verity's 'N' meaning something different from the standard 'n'. Therefore, update dm-verity-fec.c and dm-verity-fec.h to use the standard parameter names. No functional changes. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: replace {MAX,MIN}_RSN with {MIN,MAX}_ROOTSEric Biggers2-7/+6
Every time DM_VERITY_FEC_{MAX,MIN}_RSN are used, they are subtracted from DM_VERITY_FEC_RSM to get the bounds on the number of roots. Therefore, replace these with {MIN,MAX}_ROOTS constants which are more directly useful. (Note the inversion, where MAX_RSN maps to MIN_ROOTS and MIN_RSN maps to MAX_ROOTS.) No functional change. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity: rename dm_verity::hash_blocks to dm_verity::hash_endEric Biggers3-7/+7
Rename hash_blocks to hash_end to reflect what it actually is. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: fix reading parity bytes split across blocks (take 3)Eric Biggers1-56/+44
fec_decode_bufs() assumes that the parity bytes of the first RS codeword it decodes are never split across parity blocks. This assumption is false. Consider v->fec->block_size == 4096 && v->fec->roots == 17 && fio->nbufs == 1, for example. In that case, each call to fec_decode_bufs() consumes v->fec->roots * (fio->nbufs << DM_VERITY_FEC_BUF_RS_BITS) = 272 parity bytes. Considering that the parity data for each message block starts on a block boundary, the byte alignment in the parity data will iterate through 272*i mod 4096 until the 3 parity blocks have been consumed. On the 16th call (i=15), the alignment will be 4080 bytes into the first block. Only 16 bytes remain in that block, but 17 parity bytes will be needed. The code reads out-of-bounds from the parity block buffer. Fortunately this doesn't normally happen, since it can occur only for certain non-default values of fec_roots *and* when the maximum number of buffers couldn't be allocated due to low memory. For example with block_size=4096 only the following cases are affected: fec_roots=17: nbufs in [1, 3, 5, 15] fec_roots=19: nbufs in [1, 229] fec_roots=21: nbufs in [1, 3, 5, 13, 15, 39, 65, 195] fec_roots=23: nbufs in [1, 89] Regardless, fix it by refactoring how the parity blocks are read. Fixes: 6df90c02bae4 ("dm-verity FEC: Fix RS FEC repair for roots unaligned to block size (take 2)") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: fix the size of dm_verity_fec_io::erasuresEric Biggers1-1/+2
At most 25 entries in dm_verity_fec_io::erasures are used: the maximum number of FEC roots plus one. Therefore, set the array size accordingly. This reduces the size of dm_verity_fec_io by 912 bytes. Note: a later commit introduces a constant DM_VERITY_FEC_MAX_ROOTS, which allows the size to be more clearly expressed as DM_VERITY_FEC_MAX_ROOTS + 1. This commit just fixes the size first. Fixes: a739ff3f543a ("dm verity: add support for forward error correction") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: fix corrected block count statEric Biggers1-3/+2
dm_verity_fec::corrected seems to have been intended to count the number of corrected blocks. However, it actually counted the number of calls to fec_decode_bufs() that corrected at least one error. That's not the same thing. For example, in low-memory situations correcting a single block can require many calls to fec_decode_bufs(). Fix it to count corrected blocks instead. Fixes: ae97648e14f7 ("dm verity fec: Expose corrected block count via status") Cc: Shubhankar Mishra <shubhankarm@google.com> Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: correctly reject too-small hash devicesEric Biggers1-1/+2
Fix verity_fec_ctr() to reject too-small hash devices by correctly taking hash_start into account. Note that this is necessary because dm-verity doesn't call dm_bufio_set_sector_offset() on the hash device's bufio client (v->bufio). Thus, dm_bufio_get_device_size(v->bufio) returns a size relative to 0 rather than hash_start. An alternative fix would be to call dm_bufio_set_sector_offset() on v->bufio, but then all the code that reads from the hash device would have to be adjusted accordingly. Fixes: a739ff3f543a ("dm verity: add support for forward error correction") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2026-03-09dm-verity-fec: correctly reject too-small FEC devicesEric Biggers1-3/+2
Fix verity_fec_ctr() to reject too-small FEC devices by correctly computing the number of parity blocks as 'f->rounds * f->roots'. Previously it incorrectly used 'div64_u64(f->rounds * f->roots, v->fec->roots << SECTOR_SHIFT)' which is a much smaller value. Note that the units of 'rounds' are blocks, not bytes. This matches the units of the value returned by dm_bufio_get_device_size(), which are also blocks. A later commit will give 'rounds' a clearer name. Fixes: a739ff3f543a ("dm verity: add support for forward error correction") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>