823 Commits

Author SHA1 Message Date
Simon Glass
07d2a31287 linux: Drop duplicate atomic types from types.h
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>
2025-12-22 05:57:24 -07:00
Simon Glass
5144ac35d2 fs: ext4l: Support mounting a filesystem read-only
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>
2025-12-22 05:07:38 -07:00
Simon Glass
56b6e306fb linux: crc32c: Use ext4l CRC32C implementation
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>
2025-12-22 05:07:02 -07:00
Simon Glass
6131797256 fs: ext4l: Add buffer_head I/O infrastructure
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>
2025-12-22 05:07:02 -07:00
Simon Glass
29d023d168 linux: Add rwlock support to spinlock.h
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>
2025-12-22 05:07:02 -07:00
Simon Glass
789f4d44bb linux: printk: Fix KERN_* macros for string concatenation
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>
2025-12-22 05:07:01 -07:00
Simon Glass
78059b2649 linux: Update jbd2.h includes
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>
2025-12-22 05:07:01 -07:00
Simon Glass
ecbce56f94 linux: Add BDEVNAME_SIZE to blkdev.h
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>
2025-12-22 05:07:01 -07:00
Simon Glass
4c8e3c7b2a linux: Add blk_types.h with blk_opf_t
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>
2025-12-22 05:07:01 -07:00
Simon Glass
15786a4f53 linux: Add jiffies.h with MAX_JIFFY_OFFSET
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>
2025-12-22 05:07:01 -07:00
Simon Glass
e911e32822 linux: Move common types to types.h
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>
2025-12-22 05:07:01 -07:00
Simon Glass
c113b81eab jbd2: Add checkpoint.c to the build
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>
2025-12-21 14:15:36 -07:00
Simon Glass
3b51642751 printk: Fix pr_emerg to use log_emer
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>
2025-12-21 14:15:36 -07:00
Simon Glass
717c508ac9 ext4l: Add fast_commit.c to build
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>
2025-12-21 11:36:34 +00:00
Simon Glass
593b2d9dd4 ext4l: Add mballoc.c to build
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>
2025-12-21 11:36:34 +00:00
Simon Glass
b45cae614c ext4l: Add file.c to build
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>
2025-12-21 11:36:34 +00:00
Simon Glass
b074a781fc linux: Convert timer/workqueue stubs to static inline functions
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>
2025-12-20 16:53:23 -07:00
Simon Glass
e43b787bec linux: Fix definition of try_to_freeze()
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>
2025-12-20 15:19:13 -07:00
Simon Glass
3b4667ed88 ext4l: Add super.c to build
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>
2025-12-20 14:09:14 -07:00
Simon Glass
e3f8042575 ext4l: Add inode.c to build
Add inode.c to the Makefile with minimal changes:
- Replace Linux kernel includes with ext4_uboot.h
- Add cast in ext4_inode_peek_iversion() to fix const qualifier warning
- Add __maybe_unused to variables in ext4_print_free_blocks()

Update ext4_uboot.h with additional stubs needed by inode.c:
- address_space_operations: add migrate_folio, swap_activate members,
  fix write_begin/write_end/writepages signatures
- Add buffer_migrate_folio, buffer_migrate_folio_norefs, noop_dirty_folio

Add stub functions in stub.c for inode.c dependencies:
- Inline data: ext4_try_to_write_inline_data, ext4_generic_write_inline_data,
  ext4_write_inline_data_end
- xattr: ext4_xattr_delete_inode, ext4_xattr_inode_array_free
- JBD2: jbd2_inode_cache, jbd2_journal_try_to_free_buffers,
  jbd2_journal_init_jbd_inode

Also add required stub headers:
- linux/mpage.h - multi-page I/O stub
- linux/rmap.h - reverse mapping stub
- linux/atomic.h - atomic operations stub

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-20 14:09:14 -07:00
Simon Glass
b4c072fee4 ext4l: Add linux/utsname.h stub header
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>
2025-12-20 14:09:14 -07:00
Simon Glass
8558bdc0e2 ext4l: Add xattr_user.c and xattr_hurd.c
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>
2025-12-20 14:09:14 -07:00
Simon Glass
42df586aeb ext4l: Add orphan.c and required support
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>
2025-12-20 14:09:14 -07:00
Simon Glass
ff4a549a34 linux: Add compatibility headers for ext4l extents_status
Add Linux compatibility header stubs needed to compile
extents_status.c:

- backing-dev.h: Backing device info stub
- dax.h: Direct Access (DAX) stubs
- iomap.h: I/O mapping operations and structures
- mman.h: Memory mapping flags
- mount.h: VFS mount structures
- pagevec.h: Page vector batching
- pfn_t.h: Page frame number type
- posix_acl_xattr.h: POSIX ACL xattr definitions
- proc_fs.h: Proc filesystem stub
- uio.h: User I/O vector definitions
- xattr.h: Extended attributes
- trace/events/ext4.h: Trace event stubs

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-18 12:34:17 -07:00
Simon Glass
79c9339482 linux: Add kmem_cache_zalloc() to slab.h
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>
2025-12-18 12:34:17 -07:00
Simon Glass
f04cd9dbc2 ext4l: Add extents.c compilation support
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>
2025-12-18 12:34:17 -07:00
Simon Glass
166dcda718 linux: Add compatibility headers for ext4l
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>
2025-12-18 12:34:17 -07:00
Simon Glass
5ed072d603 linux: Move mutex definitions to linux/mutex.h
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>
2025-12-18 12:34:17 -07:00
Simon Glass
6f87163eda linux: Add buffer_head.h and journal-head.h stubs
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>
2025-12-18 12:34:17 -07:00
Simon Glass
b9a56664d9 linux: Move spinlock definitions to linux/spinlock.h
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>
2025-12-18 12:34:17 -07:00
Simon Glass
5029b8c91b ext4l: Add stubs from various other linux headers
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>
2025-12-17 14:01:22 +00:00
Simon Glass
205d4bc100 ext4l: Extract timer declarations into their own file
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>
2025-12-17 14:01:22 +00:00
Simon Glass
158eed28be ext4l: Extract kthread declarations into their own file
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>
2025-12-17 14:01:22 +00:00
Simon Glass
9f80c4e055 ext4l: Extract initcall declarations into their own file
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>
2025-12-17 14:01:22 +00:00
Simon Glass
f90fcc5d04 ext4l: Extract module declarations into their own file
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>
2025-12-17 14:01:22 +00:00
Simon Glass
43f6682069 ext4l: Extract alloc declarations into their own file
Create include/linux/slab.h and include/linux/vmalloc.h with memory
allocation functions:

slab.h:
- GFP flags (GFP_KERNEL, GFP_ATOMIC, etc.)
- kmalloc(), kzalloc(), kcalloc(), kmalloc_array()
- kfree(), krealloc(), kmemdup()
- kmem_cache_* functions

vmalloc.h:
- vmalloc(), vzalloc(), vfree()
- __vmalloc()

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>
2025-12-17 14:01:22 +00:00
Simon Glass
f592f31464 ext4l: Extract freezer.h declarations into their own file
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>
2025-12-17 14:01:22 +00:00
Simon Glass
66a84bd92f ext4l: Add some stub headers for Linux code
Add stub headers for Linux kernel interfaces that ext4 code expects:

- capability.h: stub capability checks (always return true)
- cred.h: stub credential types and macros
- file.h: stub file descriptor helpers
- path.h: basic path structure definition
- security.h: stub LSM hooks (no-ops)
- seq_file.h: stub seq_file interface

These provide minimal definitions to allow ext4 code to compile.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-17 14:01:22 +00:00
Simon Glass
6c01706217 ext4l: Extract uaccess.h declarations into their own file
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>
2025-12-17 14:01:22 +00:00
Simon Glass
7fcfe1cf74 ext4l: Provide sizeof_field() in linux/stddef.h
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>
2025-12-17 14:01:22 +00:00
Simon Glass
009d7a540c ext4l: Extract export.h declarations into their own file
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>
2025-12-17 14:01:22 +00:00
Simon Glass
2442c24399 ext4l: bring in jbd2 header file
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>
2025-12-16 13:19:59 +00:00
Simon Glass
2ddc96ae88 vsprintf: Add support for the %pV format-specifier
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>
2025-12-13 16:28:53 -07:00
Simon Glass
4fd75b4346 fs: Bring in fuse header file from Linux
This is needed for virtio-fs since it makes use of the same structures.
Add a version from Linux v6.15

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-30 07:01:41 -06:00
Heinrich Schuchardt
1fe89ebebd lib: implement strnstr()
Implement library function strnstr().
Implement strstr() using strnstr().
Sort the includes.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
[jf: replace <stdint.h> by <limits.h>, folded from next patch]
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
(cherry picked from commit 7c7361b98d)
2025-05-16 06:14:22 +02:00
Marek Vasut
2f9fe2f469 linux: Add generic struct stat {}
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>
2025-05-01 05:56:47 -06:00
Andy Shevchenko
c0e978b4b7 mtd: Drop superfluous const qualifier
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>
2024-11-25 13:12:19 -06:00
Marek Vasut
f896aa6567 mtd: spi-nor: Rename SPI_ADVANCE to SPI_STACKED_PARALLEL
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>
2024-10-31 10:49:47 -06:00
Marek Vasut
f83e36fd83 mtd: spi-nor: Move SR3 WPS bit definition in the correct location
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>
2024-10-18 14:18:33 -06:00
Takahiro Kuwano
88057dab2c mtd: spi-nor: Allow flashes to specify MTD writesize
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>
2024-10-15 08:57:49 -06:00