The atomic types were incorrectly added to linux/types.h but they
already exist in asm-generic/atomic.h. Remove them and update ext4l
to include the correct header.
Fixes: e911e32822 ("linux: Move common types to types.h")
Series-to: concept
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Fix several issues preventing ext4_fill_super() from completing:
- Fix shrinker_alloc() to return a dummy shrinker instead of NULL
- Fix getblk_unmovable() to use sb_getblk() instead of returning NULL
- Fix mb_cache_create() to allocate a cache structure
- Implement d_make_root() to create root dentry for mount
- Add ext4_init_system_zone() call for block validity checking
- Add global task_struct for journal_info consistency
- Store super_block pointer after successful mount
The filesystem now mounts successfully in read-only mode.
Series-to: concept
Series-links: 87
Cover-letter:
fs: ext4l: Add support for mounting ext4 filesystems (part G)
This series adds the ext4l filesystem driver, which is a port of the
Linux ext4 driver to U-Boot. It allows mounting ext4 filesystems in
read-only mode.
The driver uses Linux kernel code directly where possible, with
compatibility shims to handle differences between Linux and U-Boot.
This approach makes it easier to keep the driver up to date with
upstream changes.
Key features:
- Read-only mounting of ext4 filesystems
- Support for extents, flex_bg, and other ext4 features
- Buffer cache for improved performance
- CRC32C checksums for metadata verification
END
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Update include/linux/crc32c.h to map crc32c() and crc32c_le() macros
to ext4l_crc32c(), which uses the correct Castagnoli polynomial
(0x82F63B78) required for ext4 checksums.
This avoids conflicts with other filesystems like btrfs that have
their own crc32c() implementation.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add support.c with buffer_head I/O infrastructure for ext4l:
- Buffer cache for caching buffer_heads across lookups
- Buffer allocation/free functions
- Block I/O functions (sb_getblk, sb_bread, brelse, submit_bh, bh_read)
This keeps interface.c focused on the U-Boot filesystem layer interface.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add rwlock_t type and read/write lock operation stubs to spinlock.h.
These are no-ops for single-threaded U-Boot but provide the API
needed by Linux-derived code.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Change KERN_* macros from empty definitions to empty strings ("").
This fixes string concatenation in printf-style calls like:
printk(KERN_ERR "message")
Without this fix, KERN_ERR expands to nothing and the string
concatenation fails.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add includes for the new header files (blk_types.h, jiffies.h,
percpu_counter.h, spinlock.h) to jbd2.h so it can be included
standalone.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add BDEVNAME_SIZE definition to blkdev.h, matching the Linux kernel
header location for this constant.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a minimal blk_types.h header with blk_opf_t type definition,
matching the Linux kernel header location.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a minimal jiffies.h header with MAX_JIFFY_OFFSET definition,
matching the Linux kernel header location for this constant.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Move ktime_t, sector_t, blkcnt_t, atomic_t, and atomic64_t to
linux/types.h to match Linux kernel header organisation.
Remove the duplicate definitions from linux/compat.h and
fs/ext4l/ext4_uboot.h since they are now in the canonical location.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Update checkpoint.c includes to use ext4_uboot.h compatibility layer.
Add jbd2/Makefile and include jbd2 in the build via fs/Makefile
Add necessary stubs and definitions:
- JBD2 trace stubs (trace_jbd2_checkpoint, etc.)
- mutex_lock_io, write_dirty_buffer, spin_needbreak stubs
- bd_dev field to struct block_device
- Temporary JBD2 function stubs until other jbd2 files are added
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
The pr_emerg macro was calling log_emerg which doesn't exist. The
correct function name is log_emer, matching the LOGL_EMERG log level.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add the fast commit module (fast_commit.c) to the build. This implements
ext4's fast commit journaling feature for improved performance.
Stubs added for:
- Wait bit operations (DEFINE_WAIT_BIT, bit_waitqueue, etc.)
- Dentry name snapshot operations
- Fast commit trace functions
- JBD2 fast commit functions (jbd2_fc_get_buf, jbd2_fc_begin_commit, etc.)
- Dentry allocation (d_alloc, d_drop)
- get_current_ioprio, wake_up_bit
- REQ_IDLE, REQ_PREFLUSH block I/O flags
Move name_snapshot struct definition after qstr is defined.
Remove fast commit stub functions now implemented in fast_commit.c.
Series-to: concept
Cover-letter:
ext4l: Add more ext4 files to the build (part E)
This adds more files to the build. Most are fairly small but some still
require a fair few additions to ext4_uboot.h and the stub.c files.
At this point, we are close to having all the files in place, so can
move on to actually making ext4 work.
END
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add the multiblock allocator (mballoc.c) to the build. This implements
the ext4 block allocation routines.
Stubs added for:
- Per-CPU operations (simplified to single-threaded)
- XArray operations
- RCU list operations
- Block device properties
- Various trace functions
- Atomic operations (atomic_sub, atomic64_sub, atomic_inc_return)
- WARN_RATELIMIT, folio_get, array_index_nospec
- seq_operations for procfs
- DEFINE_RAW_FLEX macro
Remove stub functions that are now properly implemented:
- ext4_mb_new_blocks
- ext4_free_blocks
- ext4_discard_preallocations
- ext4_mb_mark_bb
Add ext4_fc_replay_check_excluded stub for fast commit replay.
Add file member to struct seq_file for procfs compatibility.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add file.c which provides file operations for ext4l filesystem.
Changes needed for file.c support:
- Add i_writecount and i_rwsem fields to struct inode
- Add IOMAP_DIO_* flags to linux/iomap.h
- Add vm_operations_struct definition
- Add VM flags (VM_SHARED, VM_HUGEPAGE, etc.)
- Add vm_area_desc and pipe_inode_info structures
- Add FMODE_* flags and SEEK_HOLE/SEEK_DATA to linux/fs.h
- Add vfsmount, path structs and f_path to struct file
- Add inode_trylock*, lockdep_assert_held_write macros
- Add filemap_fault, filemap_map_pages stubs
- Add inode_operations struct definition
- Add various stubs: d_path, fscrypt_file_open, fsverity_file_open,
dquot_file_open, sb_start_intwrite_trylock, ext4_listxattr
Simplify ext4_file_operations and ext4_file_inode_operations
initializers to use only the members defined in U-Boot's structs.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Convert most of the stub macros in timer.h and workqueue.h to static
inline functions for better type checking. Keep macros for functions
that take callback pointers (setup_timer, timer_setup, INIT_WORK,
INIT_DELAYED_WORK, del_timer_sync) since some callers pass functions
that are conditionally compiled out.
Fixes: 3b4667ed88 ("ext4l: Add super.c to build")
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
The new definition causes a build failure on some boards, such as
vexpress_ca9x4
Use a static inline function to resolve this.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add super.c to the ext4l Makefile and provide the infrastructure
needed to compile it:
- Add stubs for block device operations (bdev_file_open_by_dev,
bdev_fput, bdev_getblk, submit_bh, trylock_buffer)
- Add stubs for NFS export helpers (generic_fh_to_dentry/parent)
- Add stubs for filesystem operations (sync_filesystem, dquot_suspend)
- Add stubs for string operations (strreplace, strtomem_pad)
- Add stubs for memory allocation (alloc_inode_sb, kvzalloc)
- Add stubs for ratelimit, workqueue, and trace functions
- Add fs_context and fs_parameter structures for mount options
- Add blk_holder_ops structure for block device holder operations
- Add pragma to suppress unused function/variable warnings
- Add __maybe_unused to __init/__exit macros in init.h
The only change to super.c itself is replacing the Linux kernel
includes with the U-Boot compatibility header ext4_uboot.h.
Series-to: concept
Cover-letter:
ext4l: Add more ext4 files to the build (part D)
This series continues the ext4l port by adding super.c to the build. The
super.c file contains the superblock operations and filesystem
registration code from the kernel's ext4 driver.
To support this effort compilation, this series adds numerous stubs and
compatibility shims for Linux kernel interfaces not available in
U-Boot, including block device operations, filesystem context
handling, NFS export helpers, and various utility functions.
In particular, fs/ext4l/ext4_uboot.h contains a lot of U-Boot specific
declarations and stubs, with fs/ext4l/stub.c containing various others.
The goal is to eventually have a fully functional ext4 implementation
ported from Linux that can be used for both reading and writing ext4
filesystems in U-Boot.
END
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a stub header for linux/utsname.h needed by mmp.c and other
ext4 files.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add xattr_user.c and xattr_hurd.c to the ext4l build:
- Update includes to use ext4_uboot.h
- Add d_sb member to struct dentry
- Add XATTR_HURD_PREFIX to linux/xattr.h
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add orphan.c to the ext4l build and fix various build issues:
- Add atomic_inc/atomic_dec macros to ext4_uboot.h
- Add s_flags member to struct super_block and SB_RDONLY constant
- Add bdev_read_only() stub function
- Add kvfree() and kvmalloc_array() to linux/slab.h
- Add stub functions for orphan.c: ext4_reserve_inode_write,
ext4_superblock_csum_set, ext4_mark_iloc_dirty, ext4_truncate,
ext4_feature_set_ok, ext4_bread
- Fix orphan.c to use U-Boot include pattern
- Remove linux/atomic.h include from buffer_head.h (types provided
by ext4_uboot.h)
- Add kunit/static_stub.h and linux/nospec.h stub headers
- Simplify seq_file.h macros
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add kmem_cache_zalloc() helper function which allocates from a
kmem_cache and zeros the memory. This is needed by the linux file
extents_status.c
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add extents.c (extent handling) to the build and provide stubs.
Changes to extents.c:
- Replace Linux includes with ext4_uboot.h
Changes to ext4_uboot.h:
- Add __GFP_MOVABLE, __GFP_FS memory allocation flags
- Add FIEMAP_EXTENT_* flags for fiemap operations
- Add FALLOC_FL_* flags for fallocate operations
- Add O_SYNC flag and struct file with f_mapping
- Add struct iomap and iomap_ops for I/O mapping
- Add IOMAP_* type constants
- Add struct fiemap_extent_info and FIEMAP_FLAG_* constants
- Add i_blkbits member to inode struct
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add stub headers to support ext4l filesystem compilation:
New headers:
- bit_spinlock.h: bit-based spinlock stubs
- blkdev.h: block device structures and operations
- buffer_head.h: buffer head management with state functions
- crc32c.h: CRC32C checksum stub
- fs.h: filesystem structures (super_block, inode operations)
- journal-head.h: journal buffer head structure
- mutex.h: mutex stubs
Updates to existing headers:
- compat.h: add rcu_head callback structure
- jbd2.h: add wait.h and init.h includes for types
- sched.h: add current task stub
- workqueue.h: fix flush_work macro warning
These provide the minimal Linux kernel interfaces needed for
ext4 code to compile in U-Boot's single-threaded environment.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Move mutex definitions from compat.h to a dedicated mutex.h header,
matching the Linux structure.
U-Boot is single-threaded so mutexes are no-ops. The new header provides
struct mutex and mutex_init/lock/unlock stubs.
Update compat.h to include linux/mutex.h.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add stub headers for buffer head management:
- buffer_head.h: buffer head structure and state management
functions (bh_*_bit helpers, BUFFER_FNS/TAS_BUFFER_FNS macros)
- journal-head.h: journal buffer head structure for jbd2
These provide minimal interfaces needed for ext4l filesystem
compilation in U-Boot.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Move the spinlock type and operation stubs from linux/compat.h to
a dedicated linux/spinlock.h header, matching the Linux kernel
structure.
Since U-Boot is single-threaded, so all spinlock operations are no-ops.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add stub headers for various Linux kernel interfaces that ext4 code
expects:
- sched.h: scheduler stubs (task_struct, cond_resched, yield)
- wait.h: wait queue stubs
- rwsem.h: read-write semaphore stubs
- percpu_counter.h: percpu counter implementation (single-threaded)
- random.h: random number stubs
- quotaops.h: disk quota operation stubs
- part_stat.h: partition statistics stubs
- prefetch.h: prefetch operation stubs
- sort.h: sort wrapper using stdlib qsort
- swap.h: swap/memory management stubs
Update compat.h to include new headers and remove duplicate
definitions.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Series-to: concept
Cover-letter:
ext4l: Add Linux compatibility headers
This series extracts Linux kernel compatibility declarations from
include/linux/compat.h into their own header files, matching the
Linux kernel's organization. This makes it easier to port Linux
filesystem code to U-Boot and keeps the compatibility layer
maintainable.
The headers come from Linux v6.18
Headers added:
- export.h: EXPORT_SYMBOL macros
- stddef.h: sizeof_field() macro
- uaccess.h: copy_to/from_user stubs
- capability.h, cred.h, file.h, path.h, security.h, seq_file.h
- freezer.h: process freezer stubs
- slab.h, vmalloc.h: memory allocation
- module.h: kernel module stubs
- init.h: initcall macros
- kthread.h: kernel thread stubs
- timer.h, workqueue.h: timer and workqueue stubs
- sched.h, wait.h, rwsem.h: scheduler and synchronization
- percpu_counter.h, random.h, quotaops.h, part_stat.h, prefetch.h,
sort.h, swap.h
All headers include appropriate copyright/author information from
the original Linux sources.
END
Series-links: 1:77
Series-version: 2
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Create include/linux/timer.h and include/linux/workqueue.h with stub
definitions for kernel timer and workqueue support. U-Boot doesn't use
these subsystems.
timer.h:
- struct timer_list
- setup_timer(), del_timer(), del_timer_sync()
- timer_setup(), mod_timer(), timer_pending()
workqueue.h:
- struct work_struct, struct delayed_work
- INIT_WORK(), schedule_work()
- queue_work(), cancel_work_sync()
- alloc_workqueue(), destroy_workqueue()
Update compat.h to include these headers and remove duplicate
definitions.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Create include/linux/kthread.h with stub definitions for kernel thread
support. U-Boot doesn't have multi-threading.
Includes:
- kthread_create(), kthread_run(), kthread_stop()
- kthread_should_stop(), kthread_should_park()
- wake_up_process(), set_current_state()
- task_pid_nr()
Update compat.h to include kthread.h and remove duplicate definitions.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Create include/linux/init.h with stub definitions for kernel
initialization macros. U-Boot has its own initialization mechanism.
Includes:
- Section markers: __init, __exit, __initdata, __devinit, etc.
- Initcall levels: core_initcall(), late_initcall(), etc.
Update compat.h to include init.h and remove duplicate definitions.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Create include/linux/module.h with stub definitions for kernel module
support. U-Boot doesn't use loadable modules, so these are no-ops.
Includes:
- THIS_MODULE, try_module_get(), module_put()
- module_init(), module_exit()
- module_param() and variants
- MODULE_* macros (LICENSE, AUTHOR, DESCRIPTION, etc.)
Update compat.h to include module.h and remove duplicate definitions.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Create include/linux/freezer.h with stub definitions for process
freezer functions used during suspend/hibernate. U-Boot doesn't
support process freezing, so these are no-ops.
Update compat.h to include freezer.h and remove duplicate definitions.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Create include/linux/uaccess.h with stub implementations for user-space
access functions. In U-Boot there's no user/kernel separation, so these
are simple memory copies.
Includes:
- copy_from_user()
- copy_to_user()
- get_user() / put_user()
- access_ok()
Update compat.h to include uaccess.h and remove the duplicate
declaration.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add the sizeof_field() macro which returns the size of a struct field.
This is used by Linux kernel code including ext4.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Create include/linux/export.h with stub definitions for EXPORT_SYMBOL
and EXPORT_SYMBOL_GPL macros. This matches the Linux kernel's header
organization where export.h is a separate file.
Update compat.h to include export.h and remove the duplicate
definitions.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Copy include/linux/jbd2.h from Linux v6.18. This header defines the
JBD2 journaling layer interface used by ext4.
Series-to: concept
Cover-letter:
ext4l: Begin an implementation of ext4 based on Linux
U-Boot has long had a solid implementation of ext4. Support for writing
and basic journaling was added as well.
However, there are some missing features. For example, some distros
enable metadata checksums which are not supported. There also also other
features such as fast commit and special feature for small files which
are not currently available.
Linux has the canonical implementation of ext4, so one approach would be
to plumb that code into U-Boot. It is not a small undertaking, since the
existing linux/compat.h has only a small fraction of the required
features.
As a start towards this effort, bring in the entire Linux code,
unmodified.
Note: There are 1000s of checkpatch checks and warnings, plus over 100
errors. These have been left along to reduce the source delta.
END
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add support for the %pV format-specifier which allows printing a
struct va_format. This is used by the Linux kernel for recursive
printf() formatting and is needed by the ext4l filesystem driver.
Add the struct to include/linux/printk.h to match the kernel location.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add generic implementation of struct stat {} imported from Linux 6.13.y
commit 27560b371ab8 ("fs: pack struct kstat better"). This can be used
by filesystem code imported from elsewhere. Now struct stat {} becomes
available on all supported architectures.
Signed-off-by: Marek Vasut <marex@denx.de>
The compiler will ignore it anyway:
include/linux/mtd/mtd.h:342:15: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
The SPI_ADVANCE description does not explain what the switch does.
It does not have anything to do with any advanced functionality, it
only gates off support for stacked and parallel SPI NORs. Rename the
Kconfig symbol, update description, and move it right next to Xilinx
hardware as it seems to be specific to this hardware. Make sure the
symbol is also protected by if DM_SPI in Kconfig.
Fixes: 5d40b3d384 ("mtd: spi-nor: Add parallel and stacked memories support")
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Move the SR3 bit definition in the right place. Fix
what is likely a rebase artifact. No functional change.
Fixes: 215f1d5794 ("mtd: spi-nor: Clear Winbond SR3 WPS bit on boot")
Signed-off-by: Marek Vasut <marex@denx.de>
Some flashes like the Infineon SEMPER NOR flash family use ECC. Under
this ECC scheme, multi-pass writes to an ECC block is not allowed.
In other words, once data is programmed to an ECC block, it can't be
programmed again without erasing it first.
Upper layers like file systems need to be given this information so they
do not cause error conditions on the flash by attempting multi-pass
programming. This can be done by setting 'writesize' in 'struct
mtd_info'.
Set the default to 1 but allow flashes to modify it in fixup hooks. If
more flashes show up with this constraint in the future it might be
worth it to add it to 'struct flash_info', but for now increasing its
size is not worth it.
This patch replicates the following upstream linux commit:
afd473e85827 ("mtd: spi-nor: core: Allow flashes to specify MTD writesize")
Acked-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>