6.18.52-rc1 review
Greg Kroah-Hartman
maintainerPATCH 1002/1518 btrfs: always wait for ordered extents to avoid OE races
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit ec78575dde998c21be7e0cb2503b5620f34b6255 ]
[BUG]
Syzbot reported a bug that there can be conflicting OEs for the same range:
BTRFS critical (device loop4): panic in insert_ordered_extent:264: overlapping ordered extents, existing oe file_offset 16384 num_bytes 430080 flags 0x1089, new oe file_offset 16384 num_bytes 430080 flags 0x80 (errno=-17 Object alrea[ 179.162726][ T6897] BTRFS critical (device loop4): panic in insert_ordered_extent:264: overlapping ordered extents, existing oe file_offset 16384 num_bytes 430080 flags 0x1089, new oe file_offset 16384 num_bytes 430080 flags 0x80 (errno=-17 Object already exists)
------------[ cut here ]------------ kernel BUG at fs/btrfs/ordered-data.c:264! Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/09/2026 RIP: 0010:btrfs_alloc_ordered_extent+0x943/0xad0 Call Trace: <TASK> cow_file_range+0x744/0x12a0 fallback_to_cow+0x5ea/0xa00 run_delalloc_nocow+0x110c/0x17a0 btrfs_run_delalloc_range+0xbe4/0x1c20 writepage_delalloc+0x104d/0x1ba0 btrfs_writepages+0x1667/0x28b0 do_writepages+0x338/0x560 filemap_fdatawrite_range+0x1f2/0x300 btrfs_fdatawrite_range+0x54/0xf0 btrfs_direct_write+0x6a0/0xc30 btrfs_do_write_iter+0x329/0x790 do_iter_readv_writev+0x624/0x8d0 vfs_writev+0x34c/0x990 __se_sys_pwritev2+0x17a/0x2a0 do_syscall_64+0x174/0x580 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK> ---[ end trace 0000000000000000 ]---
[CAUSE]
Since commit ff66fe666233 ("btrfs: fix incorrect buffered IO fallback for append direct writes"), if the direct IO finished short, we will revert the isize back to the original one, so that append writes can be respected during the buffered fallback.
Normally we rely on lock_and_cleanup_extent_if_need() function during buffered writeback to wait for any existing ordered extents.
But that ordered extent waiting only happens if the start_pos is inside the isize.
Since we have reverted the isize during failed direct IO, we will not wait for any ordered extents.
This means we can have a race where the direct IO OE is still in the tree, finished but not yet removed, then we're inserting the OE for the buffered write, causing the above crash.
[FIX]
Make the OE wait to be unconditional, to handle the reverted isize situation.
And since lock_and_cleanup_extent_if_need() now either lock the extents or return -EAGAIN, also remove the branches that handles no-extent-locked cases, and rename it to remove the "_if_need" suffix.
The following micro benchmark shows the runtime difference for btrfs_buffered_write(), doing xfs_io -f -c "pwrite 0 1m" workload, all values are the average runtime in nano seconds.
function runtime | before | after
-----------------------------------+-------------+---------------
lock_and_cleanup_extent_if_need() | 58.2 | 183.0 btrfs_buffered_write() | 2115.6 | 2973.3
The overall runtime of btrfs_buffered_write() is still pretty tiny (still less than 3 micro seconds), I'd say the extra cost is still acceptable.
An alternative to fix this problem is to wait ordered extents during iomap_end() where the isize revert is done.
But that solution will break nowait requirement, as if a nowait direct IO finished short, we have to wait for the OEs unconditionally or the next append buffered IO can still hit the same problem.
So here we have to move the wait cost to buffered write, but at least the code is slightly more streamline.
--- fs/btrfs/file.c | 102 +++++++++++++++++++----------------------------- 1 file changed, 40 insertions(+), 62 deletions(-)
fs/btrfs/file.c +40 -62
@@ -881,62 +881,56 @@ static noinline int prepare_one_folio(struct inode *inode, struct folio **folio_/* * Locks the extent and properly waits for data=ordered extents to finish -* before allowing the folios to be modified if need. +* before allowing the folios to be modified. * * Return: -* 1 - the extent is locked -* 0 - the extent is not locked, and everything is OK +* 0 - the extent is locked * -EAGAIN - need to prepare the folios again */ static noinline int -lock_and_cleanup_extent_if_need (struct btrfs_inode *inode,struct folio *folio, -loff_t pos,size_t write_bytes, -u64 *lockstart,u64 *lockend,bool nowait, -struct extent_state **cached_state) +lock_and_cleanup_extent (struct btrfs_inode *inode,struct folio *folio, +loff_t pos,size_t write_bytes, +u64 *lockstart,u64 *lockend,bool nowait, +struct extent_state **cached_state) {struct btrfs_fs_info *fs_info = inode->root->fs_info; +struct btrfs_ordered_extent *ordered;u64 start_pos;u64 last_pos; -int ret =0 ; start_pos =round_down (pos, fs_info->sectorsize); last_pos =round_up (pos + write_bytes, fs_info->sectorsize) -1 ; -if (start_pos < inode->vfs_inode.i_size) { -struct btrfs_ordered_extent *ordered; - -if (nowait) { -if (!btrfs_try_lock_extent (&inode->io_tree, start_pos, - last_pos, cached_state)) { -folio_unlock (folio); -folio_put (folio); -return -EAGAIN ; - } - }else { -btrfs_lock_extent (&inode->io_tree, start_pos, last_pos, - cached_state); - } - - ordered =btrfs_lookup_ordered_range (inode, start_pos, - last_pos - start_pos +1 ); -if (ordered && - ordered->file_offset + ordered->num_bytes > start_pos && - ordered->file_offset <= last_pos) { -btrfs_unlock_extent (&inode->io_tree, start_pos, last_pos, - cached_state); +if (nowait) { +if (!btrfs_try_lock_extent (&inode->io_tree, start_pos, + last_pos, cached_state)) {folio_unlock (folio);folio_put (folio); -btrfs_start_ordered_extent (ordered); -btrfs_put_ordered_extent (ordered);return -EAGAIN ; } -if (ordered) -btrfs_put_ordered_extent (ordered); + }else { +btrfs_lock_extent (&inode->io_tree, start_pos, last_pos, + cached_state); + } - *lockstart = start_pos; - *lockend = last_pos; - ret =1 ; + ordered =btrfs_lookup_ordered_range (inode, start_pos, + last_pos - start_pos +1 ); +if (ordered && + ordered->file_offset + ordered->num_bytes > start_pos && + ordered->file_offset <= last_pos) { +btrfs_unlock_extent (&inode->io_tree, start_pos, last_pos, + cached_state); +folio_unlock (folio); +folio_put (folio); +btrfs_start_ordered_extent (ordered); +btrfs_put_ordered_extent (ordered); +return -EAGAIN ; } +if (ordered) +btrfs_put_ordered_extent (ordered); + + *lockstart = start_pos; + *lockend = last_pos;/* * We should be called after prepare_one_folio() which should have locked
@@ -944,7 +938,7 @@ lock_and_cleanup_extent_if_need(struct btrfs_inode *inode, struct folio *folio,*/ WARN_ON (!folio_test_locked (folio)); -return ret; +return 0 ; }/*
@@ -1201,7 +1195,6 @@ static int copy_one_range(struct btrfs_inode *inode, struct iov_iter *iter,const u64 reserved_start =round_down (start, fs_info->sectorsize);u64 reserved_len;struct folio *folio =NULL ; -int extents_locked;u64 lockstart;u64 lockend;bool only_release_metadata = false;
@@ -1256,18 +1249,16 @@ static int copy_one_range(struct btrfs_inode *inode, struct iov_iter *iter, reserved_len = last_block - reserved_start; } - extents_locked =lock_and_cleanup_extent_if_need (inode, folio, start, - write_bytes, &lockstart, - &lockend, nowait, - &cached_state); -if (extents_locked <0 ) { -if (!nowait && extents_locked == -EAGAIN ) + ret =lock_and_cleanup_extent (inode, folio, start, write_bytes, + &lockstart, &lockend, nowait, &cached_state); +if (ret <0 ) { +if (!nowait) goto again;btrfs_delalloc_release_extents (inode, reserved_len);release_space (inode, *data_reserved, reserved_start, reserved_len, only_release_metadata); -return extents_locked; +return ret; } copied = copy_folio_from_iter_atomic(folio, offset_in_folio(folio, start),
@@ -1291,11 +1282,8 @@ static int copy_one_range(struct btrfs_inode *inode, struct iov_iter *iter,/* No copied bytes, unlock, release reserved space and exit. */ if (copied ==0 ) { -if (extents_locked) -btrfs_unlock_extent (&inode->io_tree, lockstart, lockend, - &cached_state); -else -btrfs_free_extent_state (cached_state); +btrfs_unlock_extent (&inode->io_tree, lockstart, lockend, + &cached_state);btrfs_delalloc_release_extents (inode, reserved_len);release_space (inode, *data_reserved, reserved_start, reserved_len, only_release_metadata);
@@ -1314,17 +1302,7 @@ static int copy_one_range(struct btrfs_inode *inode, struct iov_iter *iter, ret =btrfs_dirty_folio (inode, folio, start, copied, &cached_state, only_release_metadata); -/* -* If we have not locked the extent range, because the range's start -* offset is >= i_size, we might still have a non-NULL cached extent -* state, acquired while marking the extent range as delalloc through -* btrfs_dirty_page(). Therefore free any possible cached extent state -* to avoid a memory leak. -*/ -if (extents_locked) -btrfs_unlock_extent (&inode->io_tree, lockstart, lockend, &cached_state); -else -btrfs_free_extent_state (cached_state); +btrfs_unlock_extent (&inode->io_tree, lockstart, lockend, &cached_state);btrfs_delalloc_release_extents (inode, reserved_len);if (ret) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1003/1518 btrfs: retry verity reads for not-uptodate Merkle folios
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yichong Chen <[email protected]>
[ Upstream commit 8cc569696dac51fc62bb39b3b8f530582b916d29 ]
btrfs_read_merkle_tree_page() can find a folio in the mapping that is not uptodate. After taking the folio lock, the current code treats that state as a read error and returns -EIO.
That can make a previous transient read failure sticky. If the failed read left a not-uptodate folio in the mapping, later callers find that folio and fail instead of retrying the read.
Keep the existing page-cache insertion and locking order, but retry the Merkle item read when a not-uptodate folio is found in the mapping. Also unlock the folio when read_key_bytes() fails so that a later caller can lock it and retry the read.
--- fs/btrfs/verity.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
fs/btrfs/verity.c +11 -5
@@ -731,14 +731,18 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode, goto out;folio_lock (folio); -/* If it's not uptodate after we have the lock, we got a read error. */ -if (!folio_test_uptodate (folio)) { +/* Folio was truncated from mapping. */ +if (!folio->mapping) {folio_unlock (folio);folio_put (folio); -return ERR_PTR (-EIO ); + goto again; } -folio_unlock (folio); - goto out; +/* Another reader may have filled the folio while we waited. */ +if (folio_test_uptodate (folio)) { +folio_unlock (folio); + goto out; + } + goto read_folio; } folio = filemap_alloc_folio(mapping_gfp_constraint(inode->i_mapping, ~__GFP_FS),
@@ -755,6 +759,7 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode,return ERR_PTR (ret); } +read_folio:/* * Merkle item keys are indexed from byte 0 in the merkle tree. * They have the form:
@@ -764,6 +769,7 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode, ret =read_key_bytes (BTRFS_I (inode),BTRFS_VERITY_MERKLE_ITEM_KEY , off,folio_address (folio),PAGE_SIZE , folio);if (ret <0 ) { +folio_unlock (folio);folio_put (folio);return ERR_PTR (ret); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1004/1518 btrfs: zoned: dont clobber the extent buffer when zeroing it out
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
[ Upstream commit db4b9eefc8ee0bcaeee4d5e6a7313905f6a2fe7c ]
On a zoned filesystem a freed-but-still-dirty tree block is written out as zeros (EXTENT_BUFFER_ZONED_ZEROOUT) only to keep the zone write pointer advancing. btree_csum_one_bio() implemented this by memzeroing the extent buffer's own folios before submission.
That destroys the in-memory buffer while it may still be referenced. In particular btrfs_free_tree_block() can run on it afterwards and reads the header to add a delayed reference; once the header has been zeroed it frees bytenr 0 and corrupts the extent tree (the btrfs_header_bytenr(buf) != 0 ASSERT in btrfs_free_tree_block(), or an "unable to find ref" abort). It is flaky and reproduces under fsstress, e.g. generic/461 and generic/013.
Write the zeros to disk from the shared zero page instead and leave the extent buffer content untouched, so any later reference - including the delayed reference from btrfs_free_tree_block() - still sees a valid header. end_bbio_meta_write() now clears writeback on the buffer's own folios, as the bio no longer carries them.
--- fs/btrfs/disk-io.c | 13 +++++++------ fs/btrfs/extent_io.c | 31 ++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 13 deletions(-)
fs/btrfs/disk-io.c +7 -6
@@ -278,14 +278,15 @@ int btree_csum_one_bio(struct btrfs_bio *bbio)return -EIO ;/* -* If an extent_buffer is marked as EXTENT_BUFFER_ZONED_ZEROOUT, don't -* checksum it but zero-out its content. This is done to preserve -* ordering of I/O without unnecessarily writing out data. +* An extent_buffer marked EXTENT_BUFFER_ZONED_ZEROOUT is written out as +* zeros to preserve ordering of I/O without persisting the now +* unnecessary block. The bio is fed from the shared zero page (see +* write_one_eb()), so there is nothing to checksum here. Crucially, the +* buffer's own content is left intact: it may still be referenced, e.g. +* btrfs_free_tree_block() reads its header to add a delayed reference. */ -if (test_bit (EXTENT_BUFFER_ZONED_ZEROOUT , &eb->bflags)) { -memzero_extent_buffer (eb,0 , eb->len); +if (test_bit (EXTENT_BUFFER_ZONED_ZEROOUT , &eb->bflags))return 0 ; - }if (WARN_ON_ONCE (found_start != eb->start))return -EIO ;
fs/btrfs/extent_io.c +24 -7
@@ -2182,14 +2182,17 @@ static struct extent_buffer *find_extent_buffer_nolock(static void end_bbio_meta_write (struct btrfs_bio *bbio) {struct extent_buffer *eb = bbio->private; -struct folio_iter fi;if (bbio->bio.bi_status !=BLK_STS_OK )set_btree_ioerr (eb); -bio_for_each_folio_all (fi, &bbio->bio) { -btrfs_meta_folio_clear_writeback (fi.folio, eb); - } +/* +* Clear writeback on the buffer's own folios. The bio may carry the +* shared zero page instead (EXTENT_BUFFER_ZONED_ZEROOUT), so iterate +* the extent buffer folios rather than the bio folios. +*/ +for (int i =0 ; i <num_extent_folios (eb); i++) +btrfs_meta_folio_clear_writeback (eb->folios[i], eb);buffer_tree_clear_mark (eb,PAGECACHE_TAG_WRITEBACK );clear_and_wake_up_bit (EXTENT_BUFFER_WRITEBACK , &eb->bflags);
@@ -2230,7 +2233,8 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,struct btrfs_fs_info *fs_info = eb->fs_info;struct btrfs_bio *bbio; -prepare_eb_write (eb); +if (!test_bit (EXTENT_BUFFER_ZONED_ZEROOUT , &eb->bflags)) +prepare_eb_write (eb); bbio = btrfs_bio_alloc(INLINE_EXTENT_BUFFER_PAGES, REQ_OP_WRITE | REQ_META | wbc_to_write_flags(wbc),
@@ -2250,8 +2254,21 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,btrfs_meta_folio_set_writeback (folio, eb);if (!folio_test_dirty (folio)) wbc->nr_to_write -=folio_nr_pages (folio); -bio_add_folio_nofail (&bbio->bio, folio, range_len, -offset_in_folio (folio, range_start)); +if (test_bit (EXTENT_BUFFER_ZONED_ZEROOUT , &eb->bflags)) { +u32 off =0 ; + +while (off < range_len) { +u32 add =min_t (u32,PAGE_SIZE , range_len - off); + +bio_add_folio_nofail (&bbio->bio, +page_folio (ZERO_PAGE (0 )), + add,0 ); + off += add; + } + }else { +bio_add_folio_nofail (&bbio->bio, folio, range_len, +offset_in_folio (folio, range_start)); + }wbc_account_cgroup_owner (wbc, folio, range_len);folio_unlock (folio); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1005/1518 btrfs: use aligned range for locking in extent_fiemap()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 681e073614515b892cacef0eeec0c761a2c2ab87 ]
The @end parameter for all extent io tree helpers is inclusive, but the call site in extent_fiemap() is passing an exclusive end into btrfs_lock_extent(), which will step into the next block unexpectedly.
Pass the inclusive end into btrfs_lock_extent() and btrfs_unlock_extent().
--- fs/btrfs/fiemap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/fiemap.c +2 -2
@@ -661,7 +661,7 @@ static int extent_fiemap(struct btrfs_inode *inode, range_end =round_up (start + len, sectorsize); prev_extent_end = range_start; -btrfs_lock_extent (&inode->io_tree, range_start, range_end, &cached_state); +btrfs_lock_extent (&inode->io_tree, range_start, range_end -1 , &cached_state); ret =fiemap_find_last_extent_offset (inode, path, &last_extent_end);if (ret <0 )
@@ -841,7 +841,7 @@ static int extent_fiemap(struct btrfs_inode *inode, } out_unlock: -btrfs_unlock_extent (&inode->io_tree, range_start, range_end, &cached_state); +btrfs_unlock_extent (&inode->io_tree, range_start, range_end -1 , &cached_state);if (ret ==BTRFS_FIEMAP_FLUSH_CACHE ) {btrfs_release_path (path);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1006/1518 btrfs: avoid GFP_ATOMIC allocations in qgroup free paths
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Martins <[email protected]>
[ Upstream commit e0a85137a882db789b1bccc1e7db06356ac8c69f ]
When qgroups are enabled, __btrfs_qgroup_release_data() and qgroup_free_reserved_data() pass an extent_changeset to btrfs_clear_record_extent_bits() to track how many bytes had their EXTENT_QGROUP_RESERVED bits cleared. Inside the extent IO tree spinlock, add_extent_changeset() calls ulist_add() with GFP_ATOMIC to record each changed range. If this allocation fails, it hits a BUG_ON and panics the kernel.
However, both of these callers only read changeset.bytes_changed afterwards — the range_changed ulist is populated and immediately freed without ever being iterated. The GFP_ATOMIC allocation is entirely unnecessary for these paths.
Introduce extent_changeset_init_bytes_only() which uses a sentinel value (EXTENT_CHANGESET_BYTES_ONLY) on the ulist's prealloc field to signal that only bytes_changed should be tracked. add_extent_changeset() checks for this sentinel and returns early after updating bytes_changed, skipping the ulist_add() call entirely. This eliminates the GFP_ATOMIC allocation and makes the BUG_ON unreachable for these paths.
Callers that need range tracking (qgroup_reserve_data, qgroup_unreserve_range, btrfs_qgroup_check_reserved_leak) continue to use extent_changeset_init() and are unaffected.
Stable-dep-of: 9102b179512e ("btrfs: qgroup: fix a wrong length calculation in qgroup_free_reserved_data()")
--- fs/btrfs/extent-io-tree.c | 3 +++ fs/btrfs/extent_io.h | 23 ++++++++++++++++++++++- fs/btrfs/qgroup.c | 5 +++-- 3 files changed, 28 insertions(+), 3 deletions(-)
fs/btrfs/extent-io-tree.c +3 -0
@@ -193,7 +193,10 @@ static int add_extent_changeset(struct extent_state *state, u32 bits,return 0 ;if (!set && (state->state & bits) ==0 )return 0 ; + changeset->bytes_changed += state->end - state->start +1 ; +if (!extent_changeset_tracks_ranges (changeset)) +return 0 ;return ulist_add (&changeset->range_changed, state->start, state->end,GFP_ATOMIC ); }
fs/btrfs/extent_io.h +22 -1
@@ -196,6 +196,25 @@ static inline void extent_changeset_init(struct extent_changeset *changeset)ulist_init (&changeset->range_changed); } +/* +* Sentinel value for range_changed.prealloc indicating that the changeset +* only tracks bytes_changed and does not record individual ranges. This +* avoids GFP_ATOMIC allocations inside add_extent_changeset() when the +* caller doesn't need to iterate the changed ranges afterwards. +*/ +#define EXTENT_CHANGESET_BYTES_ONLY ((struct ulist_node *)1) + +static inline void extent_changeset_init_bytes_only (struct extent_changeset *changeset) +{ + changeset->bytes_changed =0 ; + changeset->range_changed.prealloc =EXTENT_CHANGESET_BYTES_ONLY ; +} + +static inline bool extent_changeset_tracks_ranges (const struct extent_changeset *changeset) +{ +return changeset->range_changed.prealloc !=EXTENT_CHANGESET_BYTES_ONLY ; +} +static inline struct extent_changeset *extent_changeset_alloc (void ) {struct extent_changeset *ret;
@@ -210,6 +229,7 @@ static inline struct extent_changeset *extent_changeset_alloc(void)static inline void extent_changeset_prealloc (struct extent_changeset *changeset,gfp_t gfp_mask) { +ASSERT (extent_changeset_tracks_ranges (changeset));ulist_prealloc (&changeset->range_changed, gfp_mask); }
@@ -218,7 +238,8 @@ static inline void extent_changeset_release(struct extent_changeset *changeset)if (!changeset)return ; changeset->bytes_changed =0 ; -ulist_release (&changeset->range_changed); +if (extent_changeset_tracks_ranges (changeset)) +ulist_release (&changeset->range_changed); }static inline void extent_changeset_free (struct extent_changeset *changeset)
fs/btrfs/qgroup.c +3 -2
@@ -4347,7 +4347,7 @@ static int qgroup_free_reserved_data(struct btrfs_inode *inode,u64 freed =0 ;int ret; -extent_changeset_init (&changeset); +extent_changeset_init_bytes_only (&changeset); len =round_up (start + len, root->fs_info->sectorsize); start =round_down (start, root->fs_info->sectorsize);
@@ -4412,7 +4412,7 @@ static int __btrfs_qgroup_release_data(struct btrfs_inode *inode,WARN_ON (!free && reserved);if (free && reserved)return qgroup_free_reserved_data (inode, reserved, start, len, released); -extent_changeset_init (&changeset); +extent_changeset_init_bytes_only (&changeset); ret =btrfs_clear_record_extent_bits (&inode->io_tree, start, start + len -1 ,EXTENT_QGROUP_RESERVED , &changeset);if (ret <0 )
@@ -4667,6 +4667,7 @@ void btrfs_qgroup_check_reserved_leak(struct btrfs_inode *inode)WARN_ON (ret <0 );if (WARN_ON (changeset.bytes_changed)) { +ASSERT (extent_changeset_tracks_ranges (&changeset));ULIST_ITER_INIT (&iter);while ((unode =ulist_next (&changeset.range_changed, &iter))) { btrfs_warn(inode->root->fs_info,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1007/1518 btrfs: qgroup: fix a wrong length calculation in qgroup_free_reserved_data()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 9102b179512e11644fb0489ae62010a09afa199c ]
In that function, we round down the start position and round up the ending position.
But during the calculation of @len, we use "round_up(start + len, sectorsize)", which is the rounded up end position, not the rounded up length.
Which results a much larger length, and later we are still using "start + len", which is completely incorrect.
Fix it by declaring a local @aligned_start and @aligned_len and use them instead.
--- fs/btrfs/qgroup.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
fs/btrfs/qgroup.c +11 -7
@@ -4344,12 +4344,13 @@ static int qgroup_free_reserved_data(struct btrfs_inode *inode,struct ulist_node *unode;struct ulist_iterator uiter;struct extent_changeset changeset; +const u32 sectorsize = root->fs_info->sectorsize; +const u64 aligned_start =round_down (start, sectorsize); +const u64 aligned_len =round_up (start + len, sectorsize) - aligned_start;u64 freed =0 ;int ret;extent_changeset_init_bytes_only (&changeset); - len =round_up (start + len, root->fs_info->sectorsize); - start =round_down (start, root->fs_info->sectorsize);ULIST_ITER_INIT (&uiter);while ((unode =ulist_next (&reserved->range_changed, &uiter))) {
@@ -4361,12 +4362,15 @@ static int qgroup_free_reserved_data(struct btrfs_inode *inode,extent_changeset_release (&changeset); -/* Only free range in range [start, start + len) */ -if (range_start >= start + len || - range_start + range_len <= start) +/* +* Only free the range within +* [aligned_start, aligned_start + aligned_len). +*/ +if (range_start >= aligned_start + aligned_len || + range_start + range_len <= aligned_start)continue ; - free_start =max (range_start, start); - free_len =min (start + len, range_start + range_len) - + free_start =max (range_start, aligned_start); + free_len =min (aligned_start + aligned_len, range_start + range_len) - free_start;/* * TODO: To also modify reserved->ranges_reserved to reflect
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1008/1518 pinctrl: airoha: convert PHY LED GPIO to macro
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Marangi <[email protected]>
[ Upstream commit 579839c9548cf2a85e873ad787bc2fa6610bf8ab ]
PHY LED GPIO pinctrl struct definition is very similar across the different 4 PHY and 2 LED and it can be generelized to a macro.
To reduce code size, convert them to a common macro.
Stable-dep-of: a8454680a6ce ("pinctrl: airoha: fix mdio bitfield names")
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 588 ++++------------------ 1 file changed, 100 insertions(+), 488 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +100 -488
@@ -1475,516 +1475,128 @@ static const struct airoha_pinctrl_func_group pwm_func_group[] = { }, }; +#define AIROHA_PINCTRL_PHY_LED0 (gpio, mux_val, map_mask, map_val) \ + { \ + .name = (gpio), \ + .regmap[0] = { \ + AIROHA_FUNC_MUX, \ + REG_GPIO_2ND_I2C_MODE, \ + (mux_val), \ + (mux_val), \ + }, \ + .regmap[1] = { \ + AIROHA_FUNC_MUX, \ + REG_LAN_LED0_MAPPING, \ + (map_mask), \ + (map_val), \ + }, \ + .regmap_size = 2, \ + } + +#define AIROHA_PINCTRL_PHY_LED1 (gpio, mux_val, map_mask, map_val) \ + { \ + .name = (gpio), \ + .regmap[0] = { \ + AIROHA_FUNC_MUX, \ + REG_GPIO_2ND_I2C_MODE, \ + (mux_val), \ + (mux_val), \ + }, \ + .regmap[1] = { \ + AIROHA_FUNC_MUX, \ + REG_LAN_LED1_MAPPING, \ + (map_mask), \ + (map_val), \ + }, \ + .regmap_size = 2, \ + } +static const struct airoha_pinctrl_func_group phy1_led0_func_group[] = { - { - .name ="gpio33" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN0_LED0_MODE_MASK , -GPIO_LAN0_LED0_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED0_MAPPING , -LAN0_LED_MAPPING_MASK , -LAN0_PHY_LED_MAP (0 ) - }, - .regmap_size =2 , - }, { - .name ="gpio34" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN1_LED0_MODE_MASK , -GPIO_LAN1_LED0_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED0_MAPPING , -LAN1_LED_MAPPING_MASK , -LAN1_PHY_LED_MAP (0 ) - }, - .regmap_size =2 , - }, { - .name ="gpio35" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN2_LED0_MODE_MASK , -GPIO_LAN2_LED0_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED0_MAPPING , -LAN2_LED_MAPPING_MASK , -LAN2_PHY_LED_MAP (0 ) - }, - .regmap_size =2 , - }, { - .name ="gpio42" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN3_LED0_MODE_MASK , -GPIO_LAN3_LED0_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED0_MAPPING , -LAN3_LED_MAPPING_MASK , -LAN3_PHY_LED_MAP (0 ) - }, - .regmap_size =2 , - }, +AIROHA_PINCTRL_PHY_LED0 ("gpio33" ,GPIO_LAN0_LED0_MODE_MASK , +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (0 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio34" ,GPIO_LAN1_LED0_MODE_MASK , +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (0 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio35" ,GPIO_LAN2_LED0_MODE_MASK , +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (0 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio42" ,GPIO_LAN3_LED0_MODE_MASK , +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (0 )), };static const struct airoha_pinctrl_func_group phy2_led0_func_group[] = { - { - .name ="gpio33" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN0_LED0_MODE_MASK , -GPIO_LAN0_LED0_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED0_MAPPING , -LAN0_LED_MAPPING_MASK , -LAN0_PHY_LED_MAP (1 ) - }, - .regmap_size =2 , - }, { - .name ="gpio34" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN1_LED0_MODE_MASK , -GPIO_LAN1_LED0_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED0_MAPPING , -LAN1_LED_MAPPING_MASK , -LAN1_PHY_LED_MAP (1 ) - }, - .regmap_size =2 , - }, { - .name ="gpio35" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN2_LED0_MODE_MASK , -GPIO_LAN2_LED0_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED0_MAPPING , -LAN2_LED_MAPPING_MASK , -LAN2_PHY_LED_MAP (1 ) - }, - .regmap_size =2 , - }, { - .name ="gpio42" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN3_LED0_MODE_MASK , -GPIO_LAN3_LED0_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED0_MAPPING , -LAN3_LED_MAPPING_MASK , -LAN3_PHY_LED_MAP (1 ) - }, - .regmap_size =2 , - }, +AIROHA_PINCTRL_PHY_LED0 ("gpio33" ,GPIO_LAN0_LED0_MODE_MASK , +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (1 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio34" ,GPIO_LAN1_LED0_MODE_MASK , +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (1 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio35" ,GPIO_LAN2_LED0_MODE_MASK , +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (1 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio42" ,GPIO_LAN3_LED0_MODE_MASK , +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (1 )), };static const struct airoha_pinctrl_func_group phy3_led0_func_group[] = { - { - .name ="gpio33" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN0_LED0_MODE_MASK , -GPIO_LAN0_LED0_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED0_MAPPING , -LAN0_LED_MAPPING_MASK , -LAN0_PHY_LED_MAP (2 ) - }, - .regmap_size =2 , - }, { - .name ="gpio34" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN1_LED0_MODE_MASK , -GPIO_LAN1_LED0_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED0_MAPPING , -LAN1_LED_MAPPING_MASK , -LAN1_PHY_LED_MAP (2 ) - }, - .regmap_size =2 , - }, { - .name ="gpio35" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN2_LED0_MODE_MASK , -GPIO_LAN2_LED0_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED0_MAPPING , -LAN2_LED_MAPPING_MASK , -LAN2_PHY_LED_MAP (2 ) - }, - .regmap_size =2 , - }, { - .name ="gpio42" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN3_LED0_MODE_MASK , -GPIO_LAN3_LED0_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED0_MAPPING , -LAN3_LED_MAPPING_MASK , -LAN3_PHY_LED_MAP (2 ) - }, - .regmap_size =2 , - }, +AIROHA_PINCTRL_PHY_LED0 ("gpio33" ,GPIO_LAN0_LED0_MODE_MASK , +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio34" ,GPIO_LAN1_LED0_MODE_MASK , +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio35" ,GPIO_LAN2_LED0_MODE_MASK , +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio42" ,GPIO_LAN3_LED0_MODE_MASK , +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (2 )), };static const struct airoha_pinctrl_func_group phy4_led0_func_group[] = { - { - .name ="gpio33" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN0_LED0_MODE_MASK , -GPIO_LAN0_LED0_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED0_MAPPING , -LAN0_LED_MAPPING_MASK , -LAN0_PHY_LED_MAP (3 ) - }, - .regmap_size =2 , - }, { - .name ="gpio34" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN1_LED0_MODE_MASK , -GPIO_LAN1_LED0_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED0_MAPPING , -LAN1_LED_MAPPING_MASK , -LAN1_PHY_LED_MAP (3 ) - }, - .regmap_size =2 , - }, { - .name ="gpio35" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN2_LED0_MODE_MASK , -GPIO_LAN2_LED0_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED0_MAPPING , -LAN2_LED_MAPPING_MASK , -LAN2_PHY_LED_MAP (3 ) - }, - .regmap_size =2 , - }, { - .name ="gpio42" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN3_LED0_MODE_MASK , -GPIO_LAN3_LED0_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED0_MAPPING , -LAN3_LED_MAPPING_MASK , -LAN3_PHY_LED_MAP (3 ) - }, - .regmap_size =2 , - }, +AIROHA_PINCTRL_PHY_LED0 ("gpio33" ,GPIO_LAN0_LED0_MODE_MASK , +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (3 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio34" ,GPIO_LAN1_LED0_MODE_MASK , +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (3 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio35" ,GPIO_LAN2_LED0_MODE_MASK , +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (3 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio42" ,GPIO_LAN3_LED0_MODE_MASK , +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (3 )), };static const struct airoha_pinctrl_func_group phy1_led1_func_group[] = { - { - .name ="gpio43" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN0_LED1_MODE_MASK , -GPIO_LAN0_LED1_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED1_MAPPING , -LAN0_LED_MAPPING_MASK , -LAN0_PHY_LED_MAP (0 ) - }, - .regmap_size =2 , - }, { - .name ="gpio44" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN1_LED1_MODE_MASK , -GPIO_LAN1_LED1_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED1_MAPPING , -LAN1_LED_MAPPING_MASK , -LAN1_PHY_LED_MAP (0 ) - }, - .regmap_size =2 , - }, { - .name ="gpio45" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN2_LED1_MODE_MASK , -GPIO_LAN2_LED1_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED1_MAPPING , -LAN2_LED_MAPPING_MASK , -LAN2_PHY_LED_MAP (0 ) - }, - .regmap_size =2 , - }, { - .name ="gpio46" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN3_LED1_MODE_MASK , -GPIO_LAN3_LED1_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED1_MAPPING , -LAN3_LED_MAPPING_MASK , -LAN3_PHY_LED_MAP (0 ) - }, - .regmap_size =2 , - }, +AIROHA_PINCTRL_PHY_LED1 ("gpio43" ,GPIO_LAN0_LED1_MODE_MASK , +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (0 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio44" ,GPIO_LAN1_LED1_MODE_MASK , +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (0 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio45" ,GPIO_LAN2_LED1_MODE_MASK , +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (0 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio46" ,GPIO_LAN3_LED1_MODE_MASK , +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (0 )), };static const struct airoha_pinctrl_func_group phy2_led1_func_group[] = { - { - .name ="gpio43" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN0_LED1_MODE_MASK , -GPIO_LAN0_LED1_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED1_MAPPING , -LAN0_LED_MAPPING_MASK , -LAN0_PHY_LED_MAP (1 ) - }, - .regmap_size =2 , - }, { - .name ="gpio44" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN1_LED1_MODE_MASK , -GPIO_LAN1_LED1_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED1_MAPPING , -LAN1_LED_MAPPING_MASK , -LAN1_PHY_LED_MAP (1 ) - }, - .regmap_size =2 , - }, { - .name ="gpio45" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN2_LED1_MODE_MASK , -GPIO_LAN2_LED1_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED1_MAPPING , -LAN2_LED_MAPPING_MASK , -LAN2_PHY_LED_MAP (1 ) - }, - .regmap_size =2 , - }, { - .name ="gpio46" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN3_LED1_MODE_MASK , -GPIO_LAN3_LED1_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED1_MAPPING , -LAN3_LED_MAPPING_MASK , -LAN3_PHY_LED_MAP (1 ) - }, - .regmap_size =2 , - }, +AIROHA_PINCTRL_PHY_LED1 ("gpio43" ,GPIO_LAN0_LED1_MODE_MASK , +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (1 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio44" ,GPIO_LAN1_LED1_MODE_MASK , +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (1 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio45" ,GPIO_LAN2_LED1_MODE_MASK , +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (1 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio46" ,GPIO_LAN3_LED1_MODE_MASK , +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (1 )), };static const struct airoha_pinctrl_func_group phy3_led1_func_group[] = { - { - .name ="gpio43" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN0_LED1_MODE_MASK , -GPIO_LAN0_LED1_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED1_MAPPING , -LAN0_LED_MAPPING_MASK , -LAN0_PHY_LED_MAP (2 ) - }, - .regmap_size =2 , - }, { - .name ="gpio44" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN1_LED1_MODE_MASK , -GPIO_LAN1_LED1_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED1_MAPPING , -LAN1_LED_MAPPING_MASK , -LAN1_PHY_LED_MAP (2 ) - }, - .regmap_size =2 , - }, { - .name ="gpio45" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN2_LED1_MODE_MASK , -GPIO_LAN2_LED1_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED1_MAPPING , -LAN2_LED_MAPPING_MASK , -LAN2_PHY_LED_MAP (2 ) - }, - .regmap_size =2 , - }, { - .name ="gpio46" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN3_LED1_MODE_MASK , -GPIO_LAN3_LED1_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED1_MAPPING , -LAN3_LED_MAPPING_MASK , -LAN3_PHY_LED_MAP (2 ) - }, - .regmap_size =2 , - }, +AIROHA_PINCTRL_PHY_LED1 ("gpio43" ,GPIO_LAN0_LED1_MODE_MASK , +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio44" ,GPIO_LAN1_LED1_MODE_MASK , +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio45" ,GPIO_LAN2_LED1_MODE_MASK , +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio46" ,GPIO_LAN3_LED1_MODE_MASK , +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (2 )), };static const struct airoha_pinctrl_func_group phy4_led1_func_group[] = { - { - .name ="gpio43" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN0_LED1_MODE_MASK , -GPIO_LAN0_LED1_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED1_MAPPING , -LAN0_LED_MAPPING_MASK , -LAN0_PHY_LED_MAP (3 ) - }, - .regmap_size =2 , - }, { - .name ="gpio44" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN1_LED1_MODE_MASK , -GPIO_LAN1_LED1_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED1_MAPPING , -LAN1_LED_MAPPING_MASK , -LAN1_PHY_LED_MAP (3 ) - }, - .regmap_size =2 , - }, { - .name ="gpio45" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN2_LED1_MODE_MASK , -GPIO_LAN2_LED1_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED1_MAPPING , -LAN2_LED_MAPPING_MASK , -LAN2_PHY_LED_MAP (3 ) - }, - .regmap_size =2 , - }, { - .name ="gpio46" , - .regmap[0 ] = { -AIROHA_FUNC_MUX , -REG_GPIO_2ND_I2C_MODE , -GPIO_LAN3_LED1_MODE_MASK , -GPIO_LAN3_LED1_MODE_MASK - }, - .regmap[1 ] = { -AIROHA_FUNC_MUX , -REG_LAN_LED1_MAPPING , -LAN3_LED_MAPPING_MASK , -LAN3_PHY_LED_MAP (3 ) - }, - .regmap_size =2 , - }, +AIROHA_PINCTRL_PHY_LED1 ("gpio43" ,GPIO_LAN0_LED1_MODE_MASK , +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio44" ,GPIO_LAN1_LED1_MODE_MASK , +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio45" ,GPIO_LAN2_LED1_MODE_MASK , +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio46" ,GPIO_LAN3_LED1_MODE_MASK , +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (2 )), };static const struct airoha_pinctrl_func en7581_pinctrl_funcs[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1009/1518 pinctrl: airoha: add support for Airoha AN7583 PINs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Marangi <[email protected]>
[ Upstream commit 3ffeb17a9a27a668efb6fbd074835e187910a9bb ]
Add all the required entry to add suppot for Airoha AN7583 PINs.
Where possible the same function group are used from Airoha EN7581 to reduce code duplication.
Stable-dep-of: a8454680a6ce ("pinctrl: airoha: fix mdio bitfield names")
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 747 +++++++++++++++++++++- 1 file changed, 740 insertions(+), 7 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +740 -7
@@ -70,6 +70,7 @@#define GPIO_PCM_SPI_CS3_MODE_MASK BIT(20)#define GPIO_PCM_SPI_CS2_MODE_P156_MASK BIT(19)#define GPIO_PCM_SPI_CS2_MODE_P128_MASK BIT(18) +#define AN7583_GPIO_PCM_SPI_CS2_MODE_MASK BIT(18)#define GPIO_PCM_SPI_CS1_MODE_MASK BIT(17)#define GPIO_PCM_SPI_MODE_MASK BIT(16)#define GPIO_PCM2_MODE_MASK BIT(13)
@@ -127,6 +128,8 @@/* CONF */ #define REG_I2C_SDA_E2 0x001c +#define AN7583_I2C1_SCL_E2_MASK BIT(16) +#define AN7583_I2C1_SDA_E2_MASK BIT(15)#define SPI_MISO_E2_MASK BIT(14)#define SPI_MOSI_E2_MASK BIT(13)#define SPI_CLK_E2_MASK BIT(12)
@@ -134,12 +137,16 @@#define PCIE2_RESET_E2_MASK BIT(10)#define PCIE1_RESET_E2_MASK BIT(9)#define PCIE0_RESET_E2_MASK BIT(8) +#define AN7583_MDIO_0_E2_MASK BIT(5) +#define AN7583_MDC_0_E2_MASK BIT(4)#define UART1_RXD_E2_MASK BIT(3)#define UART1_TXD_E2_MASK BIT(2)#define I2C_SCL_E2_MASK BIT(1)#define I2C_SDA_E2_MASK BIT(0)#define REG_I2C_SDA_E4 0x0020 +#define AN7583_I2C1_SCL_E4_MASK BIT(16) +#define AN7583_I2C1_SDA_E4_MASK BIT(15)#define SPI_MISO_E4_MASK BIT(14)#define SPI_MOSI_E4_MASK BIT(13)#define SPI_CLK_E4_MASK BIT(12)
@@ -147,6 +154,8 @@#define PCIE2_RESET_E4_MASK BIT(10)#define PCIE1_RESET_E4_MASK BIT(9)#define PCIE0_RESET_E4_MASK BIT(8) +#define AN7583_MDIO_0_E4_MASK BIT(5) +#define AN7583_MDC_0_E4_MASK BIT(4)#define UART1_RXD_E4_MASK BIT(3)#define UART1_TXD_E4_MASK BIT(2)#define I2C_SCL_E4_MASK BIT(1)
@@ -158,6 +167,8 @@#define REG_GPIO_H_E4 0x0030#define REG_I2C_SDA_PU 0x0044 +#define AN7583_I2C1_SCL_PU_MASK BIT(16) +#define AN7583_I2C1_SDA_PU_MASK BIT(15)#define SPI_MISO_PU_MASK BIT(14)#define SPI_MOSI_PU_MASK BIT(13)#define SPI_CLK_PU_MASK BIT(12)
@@ -165,12 +176,16 @@#define PCIE2_RESET_PU_MASK BIT(10)#define PCIE1_RESET_PU_MASK BIT(9)#define PCIE0_RESET_PU_MASK BIT(8) +#define AN7583_MDIO_0_PU_MASK BIT(5) +#define AN7583_MDC_0_PU_MASK BIT(4)#define UART1_RXD_PU_MASK BIT(3)#define UART1_TXD_PU_MASK BIT(2)#define I2C_SCL_PU_MASK BIT(1)#define I2C_SDA_PU_MASK BIT(0)#define REG_I2C_SDA_PD 0x0048 +#define AN7583_I2C1_SDA_PD_MASK BIT(16) +#define AN7583_I2C1_SCL_PD_MASK BIT(15)#define SPI_MISO_PD_MASK BIT(14)#define SPI_MOSI_PD_MASK BIT(13)#define SPI_CLK_PD_MASK BIT(12)
@@ -178,6 +193,8 @@#define PCIE2_RESET_PD_MASK BIT(10)#define PCIE1_RESET_PD_MASK BIT(9)#define PCIE0_RESET_PD_MASK BIT(8) +#define AN7583_MDIO_0_PD_MASK BIT(5) +#define AN7583_MDC_0_PD_MASK BIT(4)#define UART1_RXD_PD_MASK BIT(3)#define UART1_TXD_PD_MASK BIT(2)#define I2C_SCL_PD_MASK BIT(1)
@@ -627,10 +644,223 @@ static const struct pingroup en7581_pinctrl_groups[] = { PINCTRL_PIN_GROUP("pcie_reset2", en7581_pcie_reset2), }; +static struct pinctrl_pin_desc an7583_pinctrl_pins[] = { +PINCTRL_PIN (2 ,"gpio0" ), +PINCTRL_PIN (3 ,"gpio1" ), +PINCTRL_PIN (4 ,"gpio2" ), +PINCTRL_PIN (5 ,"gpio3" ), +PINCTRL_PIN (6 ,"gpio4" ), +PINCTRL_PIN (7 ,"gpio5" ), +PINCTRL_PIN (8 ,"gpio6" ), +PINCTRL_PIN (9 ,"gpio7" ), +PINCTRL_PIN (10 ,"gpio8" ), +PINCTRL_PIN (11 ,"gpio9" ), +PINCTRL_PIN (12 ,"gpio10" ), +PINCTRL_PIN (13 ,"gpio11" ), +PINCTRL_PIN (14 ,"gpio12" ), +PINCTRL_PIN (15 ,"gpio13" ), +PINCTRL_PIN (16 ,"gpio14" ), +PINCTRL_PIN (17 ,"gpio15" ), +PINCTRL_PIN (18 ,"gpio16" ), +PINCTRL_PIN (19 ,"gpio17" ), +PINCTRL_PIN (20 ,"gpio18" ), +PINCTRL_PIN (21 ,"gpio19" ), +PINCTRL_PIN (22 ,"gpio20" ), +PINCTRL_PIN (23 ,"gpio21" ), +PINCTRL_PIN (24 ,"gpio22" ), +PINCTRL_PIN (25 ,"gpio23" ), +PINCTRL_PIN (26 ,"gpio24" ), +PINCTRL_PIN (27 ,"gpio25" ), +PINCTRL_PIN (28 ,"gpio26" ), +PINCTRL_PIN (29 ,"gpio27" ), +PINCTRL_PIN (30 ,"gpio28" ), +PINCTRL_PIN (31 ,"gpio29" ), +PINCTRL_PIN (32 ,"gpio30" ), +PINCTRL_PIN (33 ,"gpio31" ), +PINCTRL_PIN (34 ,"gpio32" ), +PINCTRL_PIN (35 ,"gpio33" ), +PINCTRL_PIN (36 ,"gpio34" ), +PINCTRL_PIN (37 ,"gpio35" ), +PINCTRL_PIN (38 ,"gpio36" ), +PINCTRL_PIN (39 ,"gpio37" ), +PINCTRL_PIN (40 ,"gpio38" ), +PINCTRL_PIN (41 ,"i2c0_scl" ), +PINCTRL_PIN (42 ,"i2c0_sda" ), +PINCTRL_PIN (43 ,"i2c1_scl" ), +PINCTRL_PIN (44 ,"i2c1_sda" ), +PINCTRL_PIN (45 ,"spi_clk" ), +PINCTRL_PIN (46 ,"spi_cs" ), +PINCTRL_PIN (47 ,"spi_mosi" ), +PINCTRL_PIN (48 ,"spi_miso" ), +PINCTRL_PIN (49 ,"uart_txd" ), +PINCTRL_PIN (50 ,"uart_rxd" ), +PINCTRL_PIN (51 ,"pcie_reset0" ), +PINCTRL_PIN (52 ,"pcie_reset1" ), +PINCTRL_PIN (53 ,"mdc_0" ), +PINCTRL_PIN (54 ,"mdio_0" ), +}; + +static const int an7583_pon_pins[] = {15 ,16 ,17 ,18 ,19 ,20 }; +static const int an7583_pon_tod_1pps_pins[] = {32 }; +static const int an7583_gsw_tod_1pps_pins[] = {32 }; +static const int an7583_sipo_pins[] = {34 ,35 }; +static const int an7583_sipo_rclk_pins[] = {34 ,35 ,33 }; +static const int an7583_mdio_pins[] = {43 ,44 }; +static const int an7583_uart2_pins[] = {34 ,35 }; +static const int an7583_uart2_cts_rts_pins[] = {32 ,33 }; +static const int an7583_hsuart_pins[] = {30 ,31 }; +static const int an7583_hsuart_cts_rts_pins[] = {28 ,29 }; +static const int an7583_npu_uart_pins[] = {7 ,8 }; +static const int an7583_uart4_pins[] = {7 ,8 }; +static const int an7583_uart5_pins[] = {23 ,24 }; +static const int an7583_i2c0_pins[] = {41 ,42 }; +static const int an7583_i2c1_pins[] = {43 ,44 }; +static const int an7583_jtag_udi_pins[] = {23 ,24 ,22 ,25 ,26 }; +static const int an7583_jtag_dfd_pins[] = {23 ,24 ,22 ,25 ,26 }; +static const int an7583_pcm1_pins[] = {10 ,11 ,12 ,13 ,14 }; +static const int an7583_pcm2_pins[] = {28 ,29 ,30 ,31 ,24 }; +static const int an7583_spi_pins[] = {28 ,29 ,30 ,31 }; +static const int an7583_spi_quad_pins[] = {25 ,26 }; +static const int an7583_spi_cs1_pins[] = {27 }; +static const int an7583_pcm_spi_pins[] = {28 ,29 ,30 ,31 ,10 ,11 ,12 ,13 }; +static const int an7583_pcm_spi_rst_pins[] = {14 }; +static const int an7583_pcm_spi_cs1_pins[] = {24 }; +static const int an7583_emmc_pins[] = {7 ,8 ,9 ,22 ,23 ,24 ,25 ,26 ,45 ,46 ,47 }; +static const int an7583_pnand_pins[] = {7 ,8 ,9 ,22 ,23 ,24 ,25 ,26 ,27 ,28 ,29 ,30 ,31 ,45 ,46 ,47 ,48 }; +static const int an7583_gpio0_pins[] = {2 }; +static const int an7583_gpio1_pins[] = {3 }; +static const int an7583_gpio2_pins[] = {4 }; +static const int an7583_gpio3_pins[] = {5 }; +static const int an7583_gpio4_pins[] = {6 }; +static const int an7583_gpio5_pins[] = {7 }; +static const int an7583_gpio6_pins[] = {8 }; +static const int an7583_gpio7_pins[] = {9 }; +static const int an7583_gpio8_pins[] = {10 }; +static const int an7583_gpio9_pins[] = {11 }; +static const int an7583_gpio10_pins[] = {12 }; +static const int an7583_gpio11_pins[] = {13 }; +static const int an7583_gpio12_pins[] = {14 }; +static const int an7583_gpio13_pins[] = {15 }; +static const int an7583_gpio14_pins[] = {16 }; +static const int an7583_gpio15_pins[] = {17 }; +static const int an7583_gpio16_pins[] = {18 }; +static const int an7583_gpio17_pins[] = {19 }; +static const int an7583_gpio18_pins[] = {20 }; +static const int an7583_gpio19_pins[] = {21 }; +static const int an7583_gpio20_pins[] = {22 }; +static const int an7583_gpio21_pins[] = {24 }; +static const int an7583_gpio23_pins[] = {25 }; +static const int an7583_gpio24_pins[] = {26 }; +static const int an7583_gpio25_pins[] = {27 }; +static const int an7583_gpio26_pins[] = {28 }; +static const int an7583_gpio27_pins[] = {29 }; +static const int an7583_gpio28_pins[] = {30 }; +static const int an7583_gpio29_pins[] = {31 }; +static const int an7583_gpio30_pins[] = {32 }; +static const int an7583_gpio31_pins[] = {33 }; +static const int an7583_gpio33_pins[] = {35 }; +static const int an7583_gpio34_pins[] = {36 }; +static const int an7583_gpio35_pins[] = {37 }; +static const int an7583_gpio36_pins[] = {38 }; +static const int an7583_gpio37_pins[] = {39 }; +static const int an7583_gpio38_pins[] = {40 }; +static const int an7583_gpio39_pins[] = {41 }; +static const int an7583_gpio40_pins[] = {42 }; +static const int an7583_gpio41_pins[] = {43 }; +static const int an7583_gpio42_pins[] = {44 }; +static const int an7583_gpio43_pins[] = {45 }; +static const int an7583_gpio44_pins[] = {46 }; +static const int an7583_gpio45_pins[] = {47 }; +static const int an7583_gpio46_pins[] = {48 }; +static const int an7583_gpio47_pins[] = {49 }; +static const int an7583_gpio48_pins[] = {50 }; +static const int an7583_pcie_reset0_pins[] = {51 }; +static const int an7583_pcie_reset1_pins[] = {52 }; + +static const struct pingroup an7583_pinctrl_groups[] = { +PINCTRL_PIN_GROUP ("pon" , an7583_pon), +PINCTRL_PIN_GROUP ("pon_tod_1pps" , an7583_pon_tod_1pps), +PINCTRL_PIN_GROUP ("gsw_tod_1pps" , an7583_gsw_tod_1pps), +PINCTRL_PIN_GROUP ("sipo" , an7583_sipo), +PINCTRL_PIN_GROUP ("sipo_rclk" , an7583_sipo_rclk), +PINCTRL_PIN_GROUP ("mdio" , an7583_mdio), +PINCTRL_PIN_GROUP ("uart2" , an7583_uart2), +PINCTRL_PIN_GROUP ("uart2_cts_rts" , an7583_uart2_cts_rts), +PINCTRL_PIN_GROUP ("hsuart" , an7583_hsuart), +PINCTRL_PIN_GROUP ("hsuart_cts_rts" , an7583_hsuart_cts_rts), +PINCTRL_PIN_GROUP ("npu_uart" , an7583_npu_uart), +PINCTRL_PIN_GROUP ("uart4" , an7583_uart4), +PINCTRL_PIN_GROUP ("uart5" , an7583_uart5), +PINCTRL_PIN_GROUP ("i2c0" , an7583_i2c0), +PINCTRL_PIN_GROUP ("i2c1" , an7583_i2c1), +PINCTRL_PIN_GROUP ("jtag_udi" , an7583_jtag_udi), +PINCTRL_PIN_GROUP ("jtag_dfd" , an7583_jtag_dfd), +PINCTRL_PIN_GROUP ("pcm1" , an7583_pcm1), +PINCTRL_PIN_GROUP ("pcm2" , an7583_pcm2), +PINCTRL_PIN_GROUP ("spi" , an7583_spi), +PINCTRL_PIN_GROUP ("spi_quad" , an7583_spi_quad), +PINCTRL_PIN_GROUP ("spi_cs1" , an7583_spi_cs1), +PINCTRL_PIN_GROUP ("pcm_spi" , an7583_pcm_spi), +PINCTRL_PIN_GROUP ("pcm_spi_rst" , an7583_pcm_spi_rst), +PINCTRL_PIN_GROUP ("pcm_spi_cs1" , an7583_pcm_spi_cs1), +PINCTRL_PIN_GROUP ("emmc" , an7583_emmc), +PINCTRL_PIN_GROUP ("pnand" , an7583_pnand), +PINCTRL_PIN_GROUP ("gpio0" , an7583_gpio0), +PINCTRL_PIN_GROUP ("gpio1" , an7583_gpio1), +PINCTRL_PIN_GROUP ("gpio2" , an7583_gpio2), +PINCTRL_PIN_GROUP ("gpio3" , an7583_gpio3), +PINCTRL_PIN_GROUP ("gpio4" , an7583_gpio4), +PINCTRL_PIN_GROUP ("gpio5" , an7583_gpio5), +PINCTRL_PIN_GROUP ("gpio6" , an7583_gpio6), +PINCTRL_PIN_GROUP ("gpio7" , an7583_gpio7), +PINCTRL_PIN_GROUP ("gpio8" , an7583_gpio8), +PINCTRL_PIN_GROUP ("gpio9" , an7583_gpio9), +PINCTRL_PIN_GROUP ("gpio10" , an7583_gpio10), +PINCTRL_PIN_GROUP ("gpio11" , an7583_gpio11), +PINCTRL_PIN_GROUP ("gpio12" , an7583_gpio12), +PINCTRL_PIN_GROUP ("gpio13" , an7583_gpio13), +PINCTRL_PIN_GROUP ("gpio14" , an7583_gpio14), +PINCTRL_PIN_GROUP ("gpio15" , an7583_gpio15), +PINCTRL_PIN_GROUP ("gpio16" , an7583_gpio16), +PINCTRL_PIN_GROUP ("gpio17" , an7583_gpio17), +PINCTRL_PIN_GROUP ("gpio18" , an7583_gpio18), +PINCTRL_PIN_GROUP ("gpio19" , an7583_gpio19), +PINCTRL_PIN_GROUP ("gpio20" , an7583_gpio20), +PINCTRL_PIN_GROUP ("gpio21" , an7583_gpio21), +PINCTRL_PIN_GROUP ("gpio23" , an7583_gpio23), +PINCTRL_PIN_GROUP ("gpio24" , an7583_gpio24), +PINCTRL_PIN_GROUP ("gpio25" , an7583_gpio25), +PINCTRL_PIN_GROUP ("gpio26" , an7583_gpio26), +PINCTRL_PIN_GROUP ("gpio27" , an7583_gpio27), +PINCTRL_PIN_GROUP ("gpio28" , an7583_gpio28), +PINCTRL_PIN_GROUP ("gpio29" , an7583_gpio29), +PINCTRL_PIN_GROUP ("gpio30" , an7583_gpio30), +PINCTRL_PIN_GROUP ("gpio31" , an7583_gpio31), +PINCTRL_PIN_GROUP ("gpio33" , an7583_gpio33), +PINCTRL_PIN_GROUP ("gpio34" , an7583_gpio34), +PINCTRL_PIN_GROUP ("gpio35" , an7583_gpio35), +PINCTRL_PIN_GROUP ("gpio36" , an7583_gpio36), +PINCTRL_PIN_GROUP ("gpio37" , an7583_gpio37), +PINCTRL_PIN_GROUP ("gpio38" , an7583_gpio38), +PINCTRL_PIN_GROUP ("gpio39" , an7583_gpio39), +PINCTRL_PIN_GROUP ("gpio40" , an7583_gpio40), +PINCTRL_PIN_GROUP ("gpio41" , an7583_gpio41), +PINCTRL_PIN_GROUP ("gpio42" , an7583_gpio42), +PINCTRL_PIN_GROUP ("gpio43" , an7583_gpio43), +PINCTRL_PIN_GROUP ("gpio44" , an7583_gpio44), +PINCTRL_PIN_GROUP ("gpio45" , an7583_gpio45), +PINCTRL_PIN_GROUP ("gpio46" , an7583_gpio46), +PINCTRL_PIN_GROUP ("gpio47" , an7583_gpio47), +PINCTRL_PIN_GROUP ("gpio48" , an7583_gpio48), +PINCTRL_PIN_GROUP ("pcie_reset0" , an7583_pcie_reset0), +PINCTRL_PIN_GROUP ("pcie_reset1" , an7583_pcie_reset1), +}; +static const char *const pon_groups[] = {"pon" };static const char *const tod_1pps_groups[] = {"pon_tod_1pps" ,"gsw_tod_1pps" };static const char *const sipo_groups[] = {"sipo" ,"sipo_rclk" };static const char *const mdio_groups[] = {"mdio" }; +static const char *const an7583_mdio_groups[] = {"mdio" };static const char *const uart_groups[] = {"uart2" ,"uart2_cts_rts" ,"hsuart" ,"hsuart_cts_rts" ,"uart4" ,"uart5" };
@@ -643,11 +873,16 @@ static const char *const pcm_spi_groups[] = { "pcm_spi", "pcm_spi_int","pcm_spi_cs2_p156" ,"pcm_spi_cs2_p128" , "pcm_spi_cs3", "pcm_spi_cs4" }; +static const char *const an7583_pcm_spi_groups[] = {"pcm_spi" ,"pcm_spi_int" , +"pcm_spi_rst" ,"pcm_spi_cs1" , +"pcm_spi_cs2" ,"pcm_spi_cs3" , +"pcm_spi_cs4" };static const char *const i2s_groups[] = {"i2s" };static const char *const emmc_groups[] = {"emmc" };static const char *const pnand_groups[] = {"pnand" };static const char *const pcie_reset_groups[] = {"pcie_reset0" ,"pcie_reset1" ,"pcie_reset2" }; +static const char *const an7583_pcie_reset_groups[] = {"pcie_reset0" ,"pcie_reset1" };static const char *const pwm_groups[] = {"gpio0" ,"gpio1" ,"gpio2" ,"gpio3" , "gpio4", "gpio5",
@@ -686,6 +921,22 @@ static const char *const phy3_led1_groups[] = { "gpio43", "gpio44", "gpio45", "gpio46" };static const char *const phy4_led1_groups[] = {"gpio43" ,"gpio44" ,"gpio45" ,"gpio46" }; +static const char *const an7583_phy1_led0_groups[] = {"gpio1" ,"gpio2" , +"gpio3" ,"gpio4" }; +static const char *const an7583_phy2_led0_groups[] = {"gpio1" ,"gpio2" , +"gpio3" ,"gpio4" }; +static const char *const an7583_phy3_led0_groups[] = {"gpio1" ,"gpio2" , +"gpio3" ,"gpio4" }; +static const char *const an7583_phy4_led0_groups[] = {"gpio1" ,"gpio2" , +"gpio3" ,"gpio4" }; +static const char *const an7583_phy1_led1_groups[] = {"gpio8" ,"gpio9" , +"gpio10" ,"gpio11" }; +static const char *const an7583_phy2_led1_groups[] = {"gpio8" ,"gpio9" , +"gpio10" ,"gpio11" }; +static const char *const an7583_phy3_led1_groups[] = {"gpio8" ,"gpio9" , +"gpio10" ,"gpio11" }; +static const char *const an7583_phy4_led1_groups[] = {"gpio8" ,"gpio9" , +"gpio10" ,"gpio11" };static const struct airoha_pinctrl_func_group pon_func_group[] = { {
@@ -763,6 +1014,25 @@ static const struct airoha_pinctrl_func_group mdio_func_group[] = { }, }; +static const struct airoha_pinctrl_func_group an7583_mdio_func_group[] = { + { + .name ="mdio" , + .regmap[0 ] = { +AIROHA_FUNC_MUX , +REG_GPIO_PON_MODE , +GPIO_SGMII_MDIO_MODE_MASK , +GPIO_SGMII_MDIO_MODE_MASK + }, + .regmap[1 ] = { +AIROHA_FUNC_MUX , +REG_GPIO_SPI_CS1_MODE , +GPIO_MDC_IO_MASTER_MODE_MODE , +GPIO_MDC_IO_MASTER_MODE_MODE + }, + .regmap_size =2 , + }, +}; +static const struct airoha_pinctrl_func_group uart_func_group[] = { { .name ="uart2" ,
@@ -1004,6 +1274,73 @@ static const struct airoha_pinctrl_func_group pcm_spi_func_group[] = { }, }; +static const struct airoha_pinctrl_func_group an7583_pcm_spi_func_group[] = { + { + .name ="pcm_spi" , + .regmap[0 ] = { +AIROHA_FUNC_MUX , +REG_GPIO_SPI_CS1_MODE , +GPIO_PCM_SPI_MODE_MASK , +GPIO_PCM_SPI_MODE_MASK + }, + .regmap_size =1 , + }, { + .name ="pcm_spi_int" , + .regmap[0 ] = { +AIROHA_FUNC_MUX , +REG_GPIO_SPI_CS1_MODE , +GPIO_PCM_INT_MODE_MASK , +GPIO_PCM_INT_MODE_MASK + }, + .regmap_size =1 , + }, { + .name ="pcm_spi_rst" , + .regmap[0 ] = { +AIROHA_FUNC_MUX , +REG_GPIO_SPI_CS1_MODE , +GPIO_PCM_RESET_MODE_MASK , +GPIO_PCM_RESET_MODE_MASK + }, + .regmap_size =1 , + }, { + .name ="pcm_spi_cs1" , + .regmap[0 ] = { +AIROHA_FUNC_MUX , +REG_GPIO_SPI_CS1_MODE , +GPIO_PCM_SPI_CS1_MODE_MASK , +GPIO_PCM_SPI_CS1_MODE_MASK + }, + .regmap_size =1 , + }, { + .name ="pcm_spi_cs2" , + .regmap[0 ] = { +AIROHA_FUNC_MUX , +REG_GPIO_SPI_CS1_MODE , +AN7583_GPIO_PCM_SPI_CS2_MODE_MASK , +AN7583_GPIO_PCM_SPI_CS2_MODE_MASK + }, + .regmap_size =1 , + }, { + .name ="pcm_spi_cs3" , + .regmap[0 ] = { +AIROHA_FUNC_MUX , +REG_GPIO_SPI_CS1_MODE , +GPIO_PCM_SPI_CS3_MODE_MASK , +GPIO_PCM_SPI_CS3_MODE_MASK + }, + .regmap_size =1 , + }, { + .name ="pcm_spi_cs4" , + .regmap[0 ] = { +AIROHA_FUNC_MUX , +REG_GPIO_SPI_CS1_MODE , +GPIO_PCM_SPI_CS4_MODE_MASK , +GPIO_PCM_SPI_CS4_MODE_MASK + }, + .regmap_size =1 , + }, +}; +static const struct airoha_pinctrl_func_group i2s_func_group[] = { { .name ="i2s" ,
@@ -1074,6 +1411,28 @@ static const struct airoha_pinctrl_func_group pcie_reset_func_group[] = { }, }; +static const struct airoha_pinctrl_func_group an7583_pcie_reset_func_group[] = { + { + .name ="pcie_reset0" , + .regmap[0 ] = { +AIROHA_FUNC_MUX , +REG_GPIO_PON_MODE , +GPIO_PCIE_RESET0_MASK , +GPIO_PCIE_RESET0_MASK + }, + .regmap_size =1 , + }, { + .name ="pcie_reset1" , + .regmap[0 ] = { +AIROHA_FUNC_MUX , +REG_GPIO_PON_MODE , +GPIO_PCIE_RESET1_MASK , +GPIO_PCIE_RESET1_MASK + }, + .regmap_size =1 , + }, +}; +/* PWM */ static const struct airoha_pinctrl_func_group pwm_func_group[] = { {
@@ -1599,6 +1958,94 @@ static const struct airoha_pinctrl_func_group phy4_led1_func_group[] = { LAN3_LED_MAPPING_MASK, LAN3_PHY_LED_MAP(2)), }; +static const struct airoha_pinctrl_func_group an7583_phy1_led0_func_group[] = { +AIROHA_PINCTRL_PHY_LED0 ("gpio1" ,GPIO_LAN0_LED0_MODE_MASK , +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (0 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio2" ,GPIO_LAN1_LED0_MODE_MASK , +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (0 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio3" ,GPIO_LAN2_LED0_MODE_MASK , +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (0 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio4" ,GPIO_LAN3_LED0_MODE_MASK , +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (0 )), +}; + +static const struct airoha_pinctrl_func_group an7583_phy2_led0_func_group[] = { +AIROHA_PINCTRL_PHY_LED0 ("gpio1" ,GPIO_LAN0_LED0_MODE_MASK , +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (1 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio2" ,GPIO_LAN1_LED0_MODE_MASK , +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (1 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio3" ,GPIO_LAN2_LED0_MODE_MASK , +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (1 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio4" ,GPIO_LAN3_LED0_MODE_MASK , +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (1 )), +}; + +static const struct airoha_pinctrl_func_group an7583_phy3_led0_func_group[] = { +AIROHA_PINCTRL_PHY_LED0 ("gpio1" ,GPIO_LAN0_LED0_MODE_MASK , +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio2" ,GPIO_LAN1_LED0_MODE_MASK , +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio3" ,GPIO_LAN2_LED0_MODE_MASK , +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio4" ,GPIO_LAN3_LED0_MODE_MASK , +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (2 )), +}; + +static const struct airoha_pinctrl_func_group an7583_phy4_led0_func_group[] = { +AIROHA_PINCTRL_PHY_LED0 ("gpio1" ,GPIO_LAN0_LED0_MODE_MASK , +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (3 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio2" ,GPIO_LAN1_LED0_MODE_MASK , +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (3 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio3" ,GPIO_LAN2_LED0_MODE_MASK , +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (3 )), +AIROHA_PINCTRL_PHY_LED0 ("gpio4" ,GPIO_LAN3_LED0_MODE_MASK , +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (3 )), +}; + +static const struct airoha_pinctrl_func_group an7583_phy1_led1_func_group[] = { +AIROHA_PINCTRL_PHY_LED1 ("gpio8" ,GPIO_LAN0_LED1_MODE_MASK , +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (0 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio9" ,GPIO_LAN1_LED1_MODE_MASK , +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (0 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio10" ,GPIO_LAN2_LED1_MODE_MASK , +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (0 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio1" ,GPIO_LAN3_LED1_MODE_MASK , +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (0 )), +}; + +static const struct airoha_pinctrl_func_group an7583_phy2_led1_func_group[] = { +AIROHA_PINCTRL_PHY_LED1 ("gpio8" ,GPIO_LAN0_LED1_MODE_MASK , +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (1 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio9" ,GPIO_LAN1_LED1_MODE_MASK , +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (1 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio10" ,GPIO_LAN2_LED1_MODE_MASK , +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (1 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio11" ,GPIO_LAN3_LED1_MODE_MASK , +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (1 )), +}; + +static const struct airoha_pinctrl_func_group an7583_phy3_led1_func_group[] = { +AIROHA_PINCTRL_PHY_LED1 ("gpio8" ,GPIO_LAN0_LED1_MODE_MASK , +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio9" ,GPIO_LAN1_LED1_MODE_MASK , +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio10" ,GPIO_LAN2_LED1_MODE_MASK , +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio11" ,GPIO_LAN3_LED1_MODE_MASK , +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (2 )), +}; + +static const struct airoha_pinctrl_func_group an7583_phy4_led1_func_group[] = { +AIROHA_PINCTRL_PHY_LED1 ("gpio8" ,GPIO_LAN0_LED1_MODE_MASK , +LAN0_LED_MAPPING_MASK ,LAN0_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio9" ,GPIO_LAN1_LED1_MODE_MASK , +LAN1_LED_MAPPING_MASK ,LAN1_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio10" ,GPIO_LAN2_LED1_MODE_MASK , +LAN2_LED_MAPPING_MASK ,LAN2_PHY_LED_MAP (2 )), +AIROHA_PINCTRL_PHY_LED1 ("gpio11" ,GPIO_LAN3_LED1_MODE_MASK , +LAN3_LED_MAPPING_MASK ,LAN3_PHY_LED_MAP (2 )), +}; +static const struct airoha_pinctrl_func en7581_pinctrl_funcs[] = {PINCTRL_FUNC_DESC ("pon" , pon),PINCTRL_FUNC_DESC ("tod_1pps" , tod_1pps),
@@ -1625,6 +2072,31 @@ static const struct airoha_pinctrl_func en7581_pinctrl_funcs[] = { PINCTRL_FUNC_DESC("phy4_led1", phy4_led1), }; +static const struct airoha_pinctrl_func an7583_pinctrl_funcs[] = { +PINCTRL_FUNC_DESC ("pon" , pon), +PINCTRL_FUNC_DESC ("tod_1pps" , tod_1pps), +PINCTRL_FUNC_DESC ("sipo" , sipo), +PINCTRL_FUNC_DESC ("mdio" , an7583_mdio), +PINCTRL_FUNC_DESC ("uart" , uart), +PINCTRL_FUNC_DESC ("i2c" , i2c), +PINCTRL_FUNC_DESC ("jtag" , jtag), +PINCTRL_FUNC_DESC ("pcm" , pcm), +PINCTRL_FUNC_DESC ("spi" , spi), +PINCTRL_FUNC_DESC ("pcm_spi" , an7583_pcm_spi), +PINCTRL_FUNC_DESC ("emmc" , emmc), +PINCTRL_FUNC_DESC ("pnand" , pnand), +PINCTRL_FUNC_DESC ("pcie_reset" , an7583_pcie_reset), +PINCTRL_FUNC_DESC ("pwm" , pwm), +PINCTRL_FUNC_DESC ("phy1_led0" , an7583_phy1_led0), +PINCTRL_FUNC_DESC ("phy2_led0" , an7583_phy2_led0), +PINCTRL_FUNC_DESC ("phy3_led0" , an7583_phy3_led0), +PINCTRL_FUNC_DESC ("phy4_led0" , an7583_phy4_led0), +PINCTRL_FUNC_DESC ("phy1_led1" , an7583_phy1_led1), +PINCTRL_FUNC_DESC ("phy2_led1" , an7583_phy2_led1), +PINCTRL_FUNC_DESC ("phy3_led1" , an7583_phy3_led1), +PINCTRL_FUNC_DESC ("phy4_led1" , an7583_phy4_led1), +}; +static const struct airoha_pinctrl_conf en7581_pinctrl_pullup_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_PU ,UART1_TXD_PU_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_PU ,UART1_RXD_PU_MASK ),
@@ -1686,6 +2158,62 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_pullup_conf[] = { PINCTRL_CONF_DESC(63, REG_I2C_SDA_PU, PCIE2_RESET_PU_MASK), }; +static const struct airoha_pinctrl_conf an7583_pinctrl_pullup_conf[] = { +PINCTRL_CONF_DESC (2 ,REG_GPIO_L_PU ,BIT (0 )), +PINCTRL_CONF_DESC (3 ,REG_GPIO_L_PU ,BIT (1 )), +PINCTRL_CONF_DESC (4 ,REG_GPIO_L_PU ,BIT (2 )), +PINCTRL_CONF_DESC (5 ,REG_GPIO_L_PU ,BIT (3 )), +PINCTRL_CONF_DESC (6 ,REG_GPIO_L_PU ,BIT (4 )), +PINCTRL_CONF_DESC (7 ,REG_GPIO_L_PU ,BIT (5 )), +PINCTRL_CONF_DESC (8 ,REG_GPIO_L_PU ,BIT (6 )), +PINCTRL_CONF_DESC (9 ,REG_GPIO_L_PU ,BIT (7 )), +PINCTRL_CONF_DESC (10 ,REG_GPIO_L_PU ,BIT (8 )), +PINCTRL_CONF_DESC (11 ,REG_GPIO_L_PU ,BIT (9 )), +PINCTRL_CONF_DESC (12 ,REG_GPIO_L_PU ,BIT (10 )), +PINCTRL_CONF_DESC (13 ,REG_GPIO_L_PU ,BIT (11 )), +PINCTRL_CONF_DESC (14 ,REG_GPIO_L_PU ,BIT (12 )), +PINCTRL_CONF_DESC (15 ,REG_GPIO_L_PU ,BIT (13 )), +PINCTRL_CONF_DESC (16 ,REG_GPIO_L_PU ,BIT (14 )), +PINCTRL_CONF_DESC (17 ,REG_GPIO_L_PU ,BIT (15 )), +PINCTRL_CONF_DESC (18 ,REG_GPIO_L_PU ,BIT (16 )), +PINCTRL_CONF_DESC (19 ,REG_GPIO_L_PU ,BIT (17 )), +PINCTRL_CONF_DESC (20 ,REG_GPIO_L_PU ,BIT (18 )), +PINCTRL_CONF_DESC (21 ,REG_GPIO_L_PU ,BIT (18 )), +PINCTRL_CONF_DESC (22 ,REG_GPIO_L_PU ,BIT (20 )), +PINCTRL_CONF_DESC (23 ,REG_GPIO_L_PU ,BIT (21 )), +PINCTRL_CONF_DESC (24 ,REG_GPIO_L_PU ,BIT (22 )), +PINCTRL_CONF_DESC (25 ,REG_GPIO_L_PU ,BIT (23 )), +PINCTRL_CONF_DESC (26 ,REG_GPIO_L_PU ,BIT (24 )), +PINCTRL_CONF_DESC (27 ,REG_GPIO_L_PU ,BIT (25 )), +PINCTRL_CONF_DESC (28 ,REG_GPIO_L_PU ,BIT (26 )), +PINCTRL_CONF_DESC (29 ,REG_GPIO_L_PU ,BIT (27 )), +PINCTRL_CONF_DESC (30 ,REG_GPIO_L_PU ,BIT (28 )), +PINCTRL_CONF_DESC (31 ,REG_GPIO_L_PU ,BIT (29 )), +PINCTRL_CONF_DESC (32 ,REG_GPIO_L_PU ,BIT (30 )), +PINCTRL_CONF_DESC (33 ,REG_GPIO_L_PU ,BIT (31 )), +PINCTRL_CONF_DESC (34 ,REG_GPIO_H_PU ,BIT (0 )), +PINCTRL_CONF_DESC (35 ,REG_GPIO_H_PU ,BIT (1 )), +PINCTRL_CONF_DESC (36 ,REG_GPIO_H_PU ,BIT (2 )), +PINCTRL_CONF_DESC (37 ,REG_GPIO_H_PU ,BIT (3 )), +PINCTRL_CONF_DESC (38 ,REG_GPIO_H_PU ,BIT (4 )), +PINCTRL_CONF_DESC (39 ,REG_GPIO_H_PU ,BIT (5 )), +PINCTRL_CONF_DESC (40 ,REG_GPIO_H_PU ,BIT (6 )), +PINCTRL_CONF_DESC (41 ,REG_I2C_SDA_PU ,I2C_SCL_PU_MASK ), +PINCTRL_CONF_DESC (42 ,REG_I2C_SDA_PU ,I2C_SDA_PU_MASK ), +PINCTRL_CONF_DESC (43 ,REG_I2C_SDA_PU ,AN7583_I2C1_SCL_PU_MASK ), +PINCTRL_CONF_DESC (44 ,REG_I2C_SDA_PU ,AN7583_I2C1_SDA_PU_MASK ), +PINCTRL_CONF_DESC (45 ,REG_I2C_SDA_PU ,SPI_CLK_PU_MASK ), +PINCTRL_CONF_DESC (46 ,REG_I2C_SDA_PU ,SPI_CS0_PU_MASK ), +PINCTRL_CONF_DESC (47 ,REG_I2C_SDA_PU ,SPI_MOSI_PU_MASK ), +PINCTRL_CONF_DESC (48 ,REG_I2C_SDA_PU ,SPI_MISO_PU_MASK ), +PINCTRL_CONF_DESC (49 ,REG_I2C_SDA_PU ,UART1_TXD_PU_MASK ), +PINCTRL_CONF_DESC (50 ,REG_I2C_SDA_PU ,UART1_RXD_PU_MASK ), +PINCTRL_CONF_DESC (51 ,REG_I2C_SDA_PU ,PCIE0_RESET_PU_MASK ), +PINCTRL_CONF_DESC (52 ,REG_I2C_SDA_PU ,PCIE1_RESET_PU_MASK ), +PINCTRL_CONF_DESC (53 ,REG_I2C_SDA_PU ,AN7583_MDC_0_PU_MASK ), +PINCTRL_CONF_DESC (54 ,REG_I2C_SDA_PU ,AN7583_MDIO_0_PU_MASK ), +}; +static const struct airoha_pinctrl_conf en7581_pinctrl_pulldown_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_PD ,UART1_TXD_PD_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_PD ,UART1_RXD_PD_MASK ),
@@ -1747,6 +2275,62 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_pulldown_conf[] = { PINCTRL_CONF_DESC(63, REG_I2C_SDA_PD, PCIE2_RESET_PD_MASK), }; +static const struct airoha_pinctrl_conf an7583_pinctrl_pulldown_conf[] = { +PINCTRL_CONF_DESC (2 ,REG_GPIO_L_PD ,BIT (0 )), +PINCTRL_CONF_DESC (3 ,REG_GPIO_L_PD ,BIT (1 )), +PINCTRL_CONF_DESC (4 ,REG_GPIO_L_PD ,BIT (2 )), +PINCTRL_CONF_DESC (5 ,REG_GPIO_L_PD ,BIT (3 )), +PINCTRL_CONF_DESC (6 ,REG_GPIO_L_PD ,BIT (4 )), +PINCTRL_CONF_DESC (7 ,REG_GPIO_L_PD ,BIT (5 )), +PINCTRL_CONF_DESC (8 ,REG_GPIO_L_PD ,BIT (6 )), +PINCTRL_CONF_DESC (9 ,REG_GPIO_L_PD ,BIT (7 )), +PINCTRL_CONF_DESC (10 ,REG_GPIO_L_PD ,BIT (8 )), +PINCTRL_CONF_DESC (11 ,REG_GPIO_L_PD ,BIT (9 )), +PINCTRL_CONF_DESC (12 ,REG_GPIO_L_PD ,BIT (10 )), +PINCTRL_CONF_DESC (13 ,REG_GPIO_L_PD ,BIT (11 )), +PINCTRL_CONF_DESC (14 ,REG_GPIO_L_PD ,BIT (12 )), +PINCTRL_CONF_DESC (15 ,REG_GPIO_L_PD ,BIT (13 )), +PINCTRL_CONF_DESC (16 ,REG_GPIO_L_PD ,BIT (14 )), +PINCTRL_CONF_DESC (17 ,REG_GPIO_L_PD ,BIT (15 )), +PINCTRL_CONF_DESC (18 ,REG_GPIO_L_PD ,BIT (16 )), +PINCTRL_CONF_DESC (19 ,REG_GPIO_L_PD ,BIT (17 )), +PINCTRL_CONF_DESC (20 ,REG_GPIO_L_PD ,BIT (18 )), +PINCTRL_CONF_DESC (21 ,REG_GPIO_L_PD ,BIT (18 )), +PINCTRL_CONF_DESC (22 ,REG_GPIO_L_PD ,BIT (20 )), +PINCTRL_CONF_DESC (23 ,REG_GPIO_L_PD ,BIT (21 )), +PINCTRL_CONF_DESC (24 ,REG_GPIO_L_PD ,BIT (22 )), +PINCTRL_CONF_DESC (25 ,REG_GPIO_L_PD ,BIT (23 )), +PINCTRL_CONF_DESC (26 ,REG_GPIO_L_PD ,BIT (24 )), +PINCTRL_CONF_DESC (27 ,REG_GPIO_L_PD ,BIT (25 )), +PINCTRL_CONF_DESC (28 ,REG_GPIO_L_PD ,BIT (26 )), +PINCTRL_CONF_DESC (29 ,REG_GPIO_L_PD ,BIT (27 )), +PINCTRL_CONF_DESC (30 ,REG_GPIO_L_PD ,BIT (28 )), +PINCTRL_CONF_DESC (31 ,REG_GPIO_L_PD ,BIT (29 )), +PINCTRL_CONF_DESC (32 ,REG_GPIO_L_PD ,BIT (30 )), +PINCTRL_CONF_DESC (33 ,REG_GPIO_L_PD ,BIT (31 )), +PINCTRL_CONF_DESC (34 ,REG_GPIO_H_PD ,BIT (0 )), +PINCTRL_CONF_DESC (35 ,REG_GPIO_H_PD ,BIT (1 )), +PINCTRL_CONF_DESC (36 ,REG_GPIO_H_PD ,BIT (2 )), +PINCTRL_CONF_DESC (37 ,REG_GPIO_H_PD ,BIT (3 )), +PINCTRL_CONF_DESC (38 ,REG_GPIO_H_PD ,BIT (4 )), +PINCTRL_CONF_DESC (39 ,REG_GPIO_H_PD ,BIT (5 )), +PINCTRL_CONF_DESC (40 ,REG_GPIO_H_PD ,BIT (6 )), +PINCTRL_CONF_DESC (41 ,REG_I2C_SDA_PD ,I2C_SCL_PD_MASK ), +PINCTRL_CONF_DESC (42 ,REG_I2C_SDA_PD ,I2C_SDA_PD_MASK ), +PINCTRL_CONF_DESC (43 ,REG_I2C_SDA_PD ,AN7583_I2C1_SCL_PD_MASK ), +PINCTRL_CONF_DESC (44 ,REG_I2C_SDA_PD ,AN7583_I2C1_SDA_PD_MASK ), +PINCTRL_CONF_DESC (45 ,REG_I2C_SDA_PD ,SPI_CLK_PD_MASK ), +PINCTRL_CONF_DESC (46 ,REG_I2C_SDA_PD ,SPI_CS0_PD_MASK ), +PINCTRL_CONF_DESC (47 ,REG_I2C_SDA_PD ,SPI_MOSI_PD_MASK ), +PINCTRL_CONF_DESC (48 ,REG_I2C_SDA_PD ,SPI_MISO_PD_MASK ), +PINCTRL_CONF_DESC (49 ,REG_I2C_SDA_PD ,UART1_TXD_PD_MASK ), +PINCTRL_CONF_DESC (50 ,REG_I2C_SDA_PD ,UART1_RXD_PD_MASK ), +PINCTRL_CONF_DESC (51 ,REG_I2C_SDA_PD ,PCIE0_RESET_PD_MASK ), +PINCTRL_CONF_DESC (52 ,REG_I2C_SDA_PD ,PCIE1_RESET_PD_MASK ), +PINCTRL_CONF_DESC (53 ,REG_I2C_SDA_PD ,AN7583_MDC_0_PD_MASK ), +PINCTRL_CONF_DESC (54 ,REG_I2C_SDA_PD ,AN7583_MDIO_0_PD_MASK ), +}; +static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e2_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_E2 ,UART1_TXD_E2_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_E2 ,UART1_RXD_E2_MASK ),
@@ -1808,6 +2392,62 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e2_conf[] = { PINCTRL_CONF_DESC(63, REG_I2C_SDA_E2, PCIE2_RESET_E2_MASK), }; +static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e2_conf[] = { +PINCTRL_CONF_DESC (2 ,REG_GPIO_L_E2 ,BIT (0 )), +PINCTRL_CONF_DESC (3 ,REG_GPIO_L_E2 ,BIT (1 )), +PINCTRL_CONF_DESC (4 ,REG_GPIO_L_E2 ,BIT (2 )), +PINCTRL_CONF_DESC (5 ,REG_GPIO_L_E2 ,BIT (3 )), +PINCTRL_CONF_DESC (6 ,REG_GPIO_L_E2 ,BIT (4 )), +PINCTRL_CONF_DESC (7 ,REG_GPIO_L_E2 ,BIT (5 )), +PINCTRL_CONF_DESC (8 ,REG_GPIO_L_E2 ,BIT (6 )), +PINCTRL_CONF_DESC (9 ,REG_GPIO_L_E2 ,BIT (7 )), +PINCTRL_CONF_DESC (10 ,REG_GPIO_L_E2 ,BIT (8 )), +PINCTRL_CONF_DESC (11 ,REG_GPIO_L_E2 ,BIT (9 )), +PINCTRL_CONF_DESC (12 ,REG_GPIO_L_E2 ,BIT (10 )), +PINCTRL_CONF_DESC (13 ,REG_GPIO_L_E2 ,BIT (11 )), +PINCTRL_CONF_DESC (14 ,REG_GPIO_L_E2 ,BIT (12 )), +PINCTRL_CONF_DESC (15 ,REG_GPIO_L_E2 ,BIT (13 )), +PINCTRL_CONF_DESC (16 ,REG_GPIO_L_E2 ,BIT (14 )), +PINCTRL_CONF_DESC (17 ,REG_GPIO_L_E2 ,BIT (15 )), +PINCTRL_CONF_DESC (18 ,REG_GPIO_L_E2 ,BIT (16 )), +PINCTRL_CONF_DESC (19 ,REG_GPIO_L_E2 ,BIT (17 )), +PINCTRL_CONF_DESC (20 ,REG_GPIO_L_E2 ,BIT (18 )), +PINCTRL_CONF_DESC (21 ,REG_GPIO_L_E2 ,BIT (18 )), +PINCTRL_CONF_DESC (22 ,REG_GPIO_L_E2 ,BIT (20 )), +PINCTRL_CONF_DESC (23 ,REG_GPIO_L_E2 ,BIT (21 )), +PINCTRL_CONF_DESC (24 ,REG_GPIO_L_E2 ,BIT (22 )), +PINCTRL_CONF_DESC (25 ,REG_GPIO_L_E2 ,BIT (23 )), +PINCTRL_CONF_DESC (26 ,REG_GPIO_L_E2 ,BIT (24 )), +PINCTRL_CONF_DESC (27 ,REG_GPIO_L_E2 ,BIT (25 )), +PINCTRL_CONF_DESC (28 ,REG_GPIO_L_E2 ,BIT (26 )), +PINCTRL_CONF_DESC (29 ,REG_GPIO_L_E2 ,BIT (27 )), +PINCTRL_CONF_DESC (30 ,REG_GPIO_L_E2 ,BIT (28 )), +PINCTRL_CONF_DESC (31 ,REG_GPIO_L_E2 ,BIT (29 )), +PINCTRL_CONF_DESC (32 ,REG_GPIO_L_E2 ,BIT (30 )), +PINCTRL_CONF_DESC (33 ,REG_GPIO_L_E2 ,BIT (31 )), +PINCTRL_CONF_DESC (34 ,REG_GPIO_H_E2 ,BIT (0 )), +PINCTRL_CONF_DESC (35 ,REG_GPIO_H_E2 ,BIT (1 )), +PINCTRL_CONF_DESC (36 ,REG_GPIO_H_E2 ,BIT (2 )), +PINCTRL_CONF_DESC (37 ,REG_GPIO_H_E2 ,BIT (3 )), +PINCTRL_CONF_DESC (38 ,REG_GPIO_H_E2 ,BIT (4 )), +PINCTRL_CONF_DESC (39 ,REG_GPIO_H_E2 ,BIT (5 )), +PINCTRL_CONF_DESC (40 ,REG_GPIO_H_E2 ,BIT (6 )), +PINCTRL_CONF_DESC (41 ,REG_I2C_SDA_E2 ,I2C_SCL_E2_MASK ), +PINCTRL_CONF_DESC (42 ,REG_I2C_SDA_E2 ,I2C_SDA_E2_MASK ), +PINCTRL_CONF_DESC (43 ,REG_I2C_SDA_E2 ,AN7583_I2C1_SCL_E2_MASK ), +PINCTRL_CONF_DESC (44 ,REG_I2C_SDA_E2 ,AN7583_I2C1_SDA_E2_MASK ), +PINCTRL_CONF_DESC (45 ,REG_I2C_SDA_E2 ,SPI_CLK_E2_MASK ), +PINCTRL_CONF_DESC (46 ,REG_I2C_SDA_E2 ,SPI_CS0_E2_MASK ), +PINCTRL_CONF_DESC (47 ,REG_I2C_SDA_E2 ,SPI_MOSI_E2_MASK ), +PINCTRL_CONF_DESC (48 ,REG_I2C_SDA_E2 ,SPI_MISO_E2_MASK ), +PINCTRL_CONF_DESC (49 ,REG_I2C_SDA_E2 ,UART1_TXD_E2_MASK ), +PINCTRL_CONF_DESC (50 ,REG_I2C_SDA_E2 ,UART1_RXD_E2_MASK ), +PINCTRL_CONF_DESC (51 ,REG_I2C_SDA_E2 ,PCIE0_RESET_E2_MASK ), +PINCTRL_CONF_DESC (52 ,REG_I2C_SDA_E2 ,PCIE1_RESET_E2_MASK ), +PINCTRL_CONF_DESC (53 ,REG_I2C_SDA_E2 ,AN7583_MDC_0_E2_MASK ), +PINCTRL_CONF_DESC (54 ,REG_I2C_SDA_E2 ,AN7583_MDIO_0_E2_MASK ), +}; +static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e4_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_E4 ,UART1_TXD_E4_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_E4 ,UART1_RXD_E4_MASK ),
@@ -1869,12 +2509,73 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e4_conf[] = { PINCTRL_CONF_DESC(63, REG_I2C_SDA_E4, PCIE2_RESET_E4_MASK), }; +static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e4_conf[] = { +PINCTRL_CONF_DESC (2 ,REG_GPIO_L_E4 ,BIT (0 )), +PINCTRL_CONF_DESC (3 ,REG_GPIO_L_E4 ,BIT (1 )), +PINCTRL_CONF_DESC (4 ,REG_GPIO_L_E4 ,BIT (2 )), +PINCTRL_CONF_DESC (5 ,REG_GPIO_L_E4 ,BIT (3 )), +PINCTRL_CONF_DESC (6 ,REG_GPIO_L_E4 ,BIT (4 )), +PINCTRL_CONF_DESC (7 ,REG_GPIO_L_E4 ,BIT (5 )), +PINCTRL_CONF_DESC (8 ,REG_GPIO_L_E4 ,BIT (6 )), +PINCTRL_CONF_DESC (9 ,REG_GPIO_L_E4 ,BIT (7 )), +PINCTRL_CONF_DESC (10 ,REG_GPIO_L_E4 ,BIT (8 )), +PINCTRL_CONF_DESC (11 ,REG_GPIO_L_E4 ,BIT (9 )), +PINCTRL_CONF_DESC (12 ,REG_GPIO_L_E4 ,BIT (10 )), +PINCTRL_CONF_DESC (13 ,REG_GPIO_L_E4 ,BIT (11 )), +PINCTRL_CONF_DESC (14 ,REG_GPIO_L_E4 ,BIT (12 )), +PINCTRL_CONF_DESC (15 ,REG_GPIO_L_E4 ,BIT (13 )), +PINCTRL_CONF_DESC (16 ,REG_GPIO_L_E4 ,BIT (14 )), +PINCTRL_CONF_DESC (17 ,REG_GPIO_L_E4 ,BIT (15 )), +PINCTRL_CONF_DESC (18 ,REG_GPIO_L_E4 ,BIT (16 )), +PINCTRL_CONF_DESC (19 ,REG_GPIO_L_E4 ,BIT (17 )), +PINCTRL_CONF_DESC (20 ,REG_GPIO_L_E4 ,BIT (18 )), +PINCTRL_CONF_DESC (21 ,REG_GPIO_L_E4 ,BIT (18 )), +PINCTRL_CONF_DESC (22 ,REG_GPIO_L_E4 ,BIT (20 )), +PINCTRL_CONF_DESC (23 ,REG_GPIO_L_E4 ,BIT (21 )), +PINCTRL_CONF_DESC (24 ,REG_GPIO_L_E4 ,BIT (22 )), +PINCTRL_CONF_DESC (25 ,REG_GPIO_L_E4 ,BIT (23 )), +PINCTRL_CONF_DESC (26 ,REG_GPIO_L_E4 ,BIT (24 )), +PINCTRL_CONF_DESC (27 ,REG_GPIO_L_E4 ,BIT (25 )), +PINCTRL_CONF_DESC (28 ,REG_GPIO_L_E4 ,BIT (26 )), +PINCTRL_CONF_DESC (29 ,REG_GPIO_L_E4 ,BIT (27 )), +PINCTRL_CONF_DESC (30 ,REG_GPIO_L_E4 ,BIT (28 )), +PINCTRL_CONF_DESC (31 ,REG_GPIO_L_E4 ,BIT (29 )), +PINCTRL_CONF_DESC (32 ,REG_GPIO_L_E4 ,BIT (30 )), +PINCTRL_CONF_DESC (33 ,REG_GPIO_L_E4 ,BIT (31 )), +PINCTRL_CONF_DESC (34 ,REG_GPIO_H_E4 ,BIT (0 )), +PINCTRL_CONF_DESC (35 ,REG_GPIO_H_E4 ,BIT (1 )), +PINCTRL_CONF_DESC (36 ,REG_GPIO_H_E4 ,BIT (2 )), +PINCTRL_CONF_DESC (37 ,REG_GPIO_H_E4 ,BIT (3 )), +PINCTRL_CONF_DESC (38 ,REG_GPIO_H_E4 ,BIT (4 )), +PINCTRL_CONF_DESC (39 ,REG_GPIO_H_E4 ,BIT (5 )), +PINCTRL_CONF_DESC (40 ,REG_GPIO_H_E4 ,BIT (6 )), +PINCTRL_CONF_DESC (41 ,REG_I2C_SDA_E4 ,I2C_SCL_E4_MASK ), +PINCTRL_CONF_DESC (42 ,REG_I2C_SDA_E4 ,I2C_SDA_E4_MASK ), +PINCTRL_CONF_DESC (43 ,REG_I2C_SDA_E4 ,AN7583_I2C1_SCL_E4_MASK ), +PINCTRL_CONF_DESC (44 ,REG_I2C_SDA_E4 ,AN7583_I2C1_SDA_E4_MASK ), +PINCTRL_CONF_DESC (45 ,REG_I2C_SDA_E4 ,SPI_CLK_E4_MASK ), +PINCTRL_CONF_DESC (46 ,REG_I2C_SDA_E4 ,SPI_CS0_E4_MASK ), +PINCTRL_CONF_DESC (47 ,REG_I2C_SDA_E4 ,SPI_MOSI_E4_MASK ), +PINCTRL_CONF_DESC (48 ,REG_I2C_SDA_E4 ,SPI_MISO_E4_MASK ), +PINCTRL_CONF_DESC (49 ,REG_I2C_SDA_E4 ,UART1_TXD_E4_MASK ), +PINCTRL_CONF_DESC (50 ,REG_I2C_SDA_E4 ,UART1_RXD_E4_MASK ), +PINCTRL_CONF_DESC (51 ,REG_I2C_SDA_E4 ,PCIE0_RESET_E4_MASK ), +PINCTRL_CONF_DESC (52 ,REG_I2C_SDA_E4 ,PCIE1_RESET_E4_MASK ), +PINCTRL_CONF_DESC (53 ,REG_I2C_SDA_E4 ,AN7583_MDC_0_E4_MASK ), +PINCTRL_CONF_DESC (54 ,REG_I2C_SDA_E4 ,AN7583_MDIO_0_E4_MASK ), +}; +static const struct airoha_pinctrl_conf en7581_pinctrl_pcie_rst_od_conf[] = {PINCTRL_CONF_DESC (61 ,REG_PCIE_RESET_OD ,PCIE0_RESET_OD_MASK ),PINCTRL_CONF_DESC (62 ,REG_PCIE_RESET_OD ,PCIE1_RESET_OD_MASK ),PINCTRL_CONF_DESC (63 ,REG_PCIE_RESET_OD ,PCIE2_RESET_OD_MASK ), }; +static const struct airoha_pinctrl_conf an7583_pinctrl_pcie_rst_od_conf[] = { +PINCTRL_CONF_DESC (51 ,REG_PCIE_RESET_OD ,PCIE0_RESET_OD_MASK ), +PINCTRL_CONF_DESC (52 ,REG_PCIE_RESET_OD ,PCIE1_RESET_OD_MASK ), +}; +static int airoha_convert_pin_to_reg_offset (struct pinctrl_dev *pctrl_dev,struct pinctrl_gpio_range *range,int pin)
@@ -2039,7 +2740,7 @@ static const struct irq_chip airoha_gpio_irq_chip = { };static int airoha_pinctrl_add_gpiochip (struct airoha_pinctrl *pinctrl, -struct platform_device *pdev) +struct platform_device *pdev) {struct airoha_pinctrl_gpiochip *chip = &pinctrl->gpiochip;struct gpio_chip *gc = &chip->chip;
@@ -2074,7 +2775,7 @@ static int airoha_pinctrl_add_gpiochip(struct airoha_pinctrl *pinctrl,return irq; err =devm_request_irq (dev, irq, airoha_irq_handler,IRQF_SHARED , -dev_name (dev), pinctrl); +dev_name (dev), pinctrl);if (err) {dev_err (dev,"error requesting irq %d: %d\n" , irq, err);return err;
@@ -2138,8 +2839,8 @@ static int airoha_pinmux_set_mux(struct pinctrl_dev *pctrl_dev, }static int airoha_pinmux_set_direction (struct pinctrl_dev *pctrl_dev, -struct pinctrl_gpio_range *range, -unsigned int p,bool input) +struct pinctrl_gpio_range *range, +unsigned int p,bool input) {struct airoha_pinctrl *pinctrl =pinctrl_dev_get_drvdata (pctrl_dev);u32 mask, index;
@@ -2229,7 +2930,7 @@ static int airoha_pinctrl_set_conf(struct airoha_pinctrl *pinctrl,if (regmap_update_bits (pinctrl->chip_scu, reg->offset, reg->mask, - val <<__ffs (reg->mask))) + val <<__ffs (reg->mask)))return -EINVAL ;return 0 ;
@@ -2446,8 +3147,8 @@ static int airoha_pinconf_group_get(struct pinctrl_dev *pctrl_dev,for (i =0 ; i < pinctrl->grps[group].npins; i++) {if (airoha_pinconf_get (pctrl_dev, - pinctrl->grps[group].pins[i], - config)) + pinctrl->grps[group].pins[i], + config))return -ENOTSUPP ;if (i && cur_config != *config)
@@ -2606,8 +3307,40 @@ static const struct airoha_pinctrl_match_data en7581_pinctrl_match_data = { }, }; +static const struct airoha_pinctrl_match_data an7583_pinctrl_match_data = { + .pins = an7583_pinctrl_pins, + .num_pins =ARRAY_SIZE (an7583_pinctrl_pins), + .grps = an7583_pinctrl_groups, + .num_grps =ARRAY_SIZE (an7583_pinctrl_groups), + .funcs = an7583_pinctrl_funcs, + .num_funcs =ARRAY_SIZE (an7583_pinctrl_funcs), + .confs_info = { + [AIROHA_PINCTRL_CONFS_PULLUP ] = { + .confs = an7583_pinctrl_pullup_conf, + .num_confs =ARRAY_SIZE (an7583_pinctrl_pullup_conf), + }, + [AIROHA_PINCTRL_CONFS_PULLDOWN ] = { + .confs = an7583_pinctrl_pulldown_conf, + .num_confs =ARRAY_SIZE (an7583_pinctrl_pulldown_conf), + }, + [AIROHA_PINCTRL_CONFS_DRIVE_E2 ] = { + .confs = en7581_pinctrl_drive_e2_conf, + .num_confs =ARRAY_SIZE (an7583_pinctrl_drive_e2_conf), + }, + [AIROHA_PINCTRL_CONFS_DRIVE_E4 ] = { + .confs = an7583_pinctrl_drive_e4_conf, + .num_confs =ARRAY_SIZE (an7583_pinctrl_drive_e4_conf), + }, + [AIROHA_PINCTRL_CONFS_PCIE_RST_OD ] = { + .confs = an7583_pinctrl_pcie_rst_od_conf, + .num_confs =ARRAY_SIZE (an7583_pinctrl_pcie_rst_od_conf), + }, + }, +}; +static const struct of_device_id airoha_pinctrl_of_match[] = { { .compatible ="airoha,en7581-pinctrl" , .data = &en7581_pinctrl_match_data }, + { .compatible ="airoha,an7583-pinctrl" , .data = &an7583_pinctrl_match_data }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, airoha_pinctrl_of_match);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1010/1518 pinctrl: airoha: fix mdio bitfield names
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit a8454680a6ce75fbbd8086bcb654eacf7897bc0f ]
Fix misprint in mdio bitfield name of GPIO_2ND_I2C_MODE register.
While at it also fix an7583 mdio. It should use an7583 specific mdio bitfield.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +6 -5
@@ -49,7 +49,7 @@/* MUX */ #define REG_GPIO_2ND_I2C_MODE 0x0214 -#define GPIO_MDC_IO_MASTER_MODE_MODE BIT(14) +#define GPIO_MDC_IO_MASTER_MODE_MASK BIT(14)#define GPIO_I2C_MASTER_MODE_MODE BIT(13)#define GPIO_I2S_MODE_MASK BIT(12)#define GPIO_I2C_SLAVE_MODE_MODE BIT(11)
@@ -66,6 +66,7 @@#define GPIO_2ND_I2C_MODE_MASK BIT(0)#define REG_GPIO_SPI_CS1_MODE 0x0218 +#define AN7583_GPIO_MDC_IO_MASTER_MODE_MASK BIT(22)#define GPIO_PCM_SPI_CS4_MODE_MASK BIT(21)#define GPIO_PCM_SPI_CS3_MODE_MASK BIT(20)#define GPIO_PCM_SPI_CS2_MODE_P156_MASK BIT(19)
@@ -1001,8 +1002,8 @@ static const struct airoha_pinctrl_func_group mdio_func_group[] = { .regmap[0] = {AIROHA_FUNC_MUX ,REG_GPIO_2ND_I2C_MODE , -GPIO_MDC_IO_MASTER_MODE_MODE , -GPIO_MDC_IO_MASTER_MODE_MODE +GPIO_MDC_IO_MASTER_MODE_MASK , +GPIO_MDC_IO_MASTER_MODE_MASK }, .regmap[1] = { AIROHA_FUNC_MUX,
@@ -1026,8 +1027,8 @@ static const struct airoha_pinctrl_func_group an7583_mdio_func_group[] = { .regmap[1] = {AIROHA_FUNC_MUX ,REG_GPIO_SPI_CS1_MODE , -GPIO_MDC_IO_MASTER_MODE_MODE , -GPIO_MDC_IO_MASTER_MODE_MODE +AN7583_GPIO_MDC_IO_MASTER_MODE_MASK , +AN7583_GPIO_MDC_IO_MASTER_MODE_MASK }, .regmap_size = 2, },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1011/1518 pinctrl: airoha: an7581: fix pinconf of i2c_scl/i2c_sda pins
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 65ce9d5d781f872596194771d62ad6e1260fcf4f ]
Pinconfs of i2c_sda/i2c_scl pins are swapped, this needs to be fixed.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +8 -8
@@ -2101,8 +2101,8 @@ static const struct airoha_pinctrl_func an7583_pinctrl_funcs[] = {static const struct airoha_pinctrl_conf en7581_pinctrl_pullup_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_PU ,UART1_TXD_PU_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_PU ,UART1_RXD_PU_MASK ), -PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_PU ,I2C_SDA_PU_MASK ), -PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_PU ,I2C_SCL_PU_MASK ), +PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_PU ,I2C_SCL_PU_MASK ), +PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_PU ,I2C_SDA_PU_MASK ),PINCTRL_CONF_DESC (4 ,REG_I2C_SDA_PU ,SPI_CS0_PU_MASK ),PINCTRL_CONF_DESC (5 ,REG_I2C_SDA_PU ,SPI_CLK_PU_MASK ),PINCTRL_CONF_DESC (6 ,REG_I2C_SDA_PU ,SPI_MOSI_PU_MASK ),
@@ -2218,8 +2218,8 @@ static const struct airoha_pinctrl_conf an7583_pinctrl_pullup_conf[] = {static const struct airoha_pinctrl_conf en7581_pinctrl_pulldown_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_PD ,UART1_TXD_PD_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_PD ,UART1_RXD_PD_MASK ), -PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_PD ,I2C_SDA_PD_MASK ), -PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_PD ,I2C_SCL_PD_MASK ), +PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_PD ,I2C_SCL_PD_MASK ), +PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_PD ,I2C_SDA_PD_MASK ),PINCTRL_CONF_DESC (4 ,REG_I2C_SDA_PD ,SPI_CS0_PD_MASK ),PINCTRL_CONF_DESC (5 ,REG_I2C_SDA_PD ,SPI_CLK_PD_MASK ),PINCTRL_CONF_DESC (6 ,REG_I2C_SDA_PD ,SPI_MOSI_PD_MASK ),
@@ -2335,8 +2335,8 @@ static const struct airoha_pinctrl_conf an7583_pinctrl_pulldown_conf[] = {static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e2_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_E2 ,UART1_TXD_E2_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_E2 ,UART1_RXD_E2_MASK ), -PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_E2 ,I2C_SDA_E2_MASK ), -PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_E2 ,I2C_SCL_E2_MASK ), +PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_E2 ,I2C_SCL_E2_MASK ), +PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_E2 ,I2C_SDA_E2_MASK ),PINCTRL_CONF_DESC (4 ,REG_I2C_SDA_E2 ,SPI_CS0_E2_MASK ),PINCTRL_CONF_DESC (5 ,REG_I2C_SDA_E2 ,SPI_CLK_E2_MASK ),PINCTRL_CONF_DESC (6 ,REG_I2C_SDA_E2 ,SPI_MOSI_E2_MASK ),
@@ -2452,8 +2452,8 @@ static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e2_conf[] = {static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e4_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_E4 ,UART1_TXD_E4_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_E4 ,UART1_RXD_E4_MASK ), -PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_E4 ,I2C_SDA_E4_MASK ), -PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_E4 ,I2C_SCL_E4_MASK ), +PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_E4 ,I2C_SCL_E4_MASK ), +PINCTRL_CONF_DESC (3 ,REG_I2C_SDA_E4 ,I2C_SDA_E4_MASK ),PINCTRL_CONF_DESC (4 ,REG_I2C_SDA_E4 ,SPI_CS0_E4_MASK ),PINCTRL_CONF_DESC (5 ,REG_I2C_SDA_E4 ,SPI_CLK_E4_MASK ),PINCTRL_CONF_DESC (6 ,REG_I2C_SDA_E4 ,SPI_MOSI_E4_MASK ),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1012/1518 pinctrl: airoha: an7583: fix I2C0_SDA_PD register bit order
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit d560e28bdca824781898023496658404df01be9f ]
I2C1_SCL_PD and RG_I2C1_SDA_PD bits are swapped, fix it.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +2 -2
@@ -185,8 +185,8 @@#define I2C_SDA_PU_MASK BIT(0)#define REG_I2C_SDA_PD 0x0048 -#define AN7583_I2C1_SDA_PD_MASK BIT(16) -#define AN7583_I2C1_SCL_PD_MASK BIT(15) +#define AN7583_I2C1_SCL_PD_MASK BIT(16) +#define AN7583_I2C1_SDA_PD_MASK BIT(15)#define SPI_MISO_PD_MASK BIT(14)#define SPI_MOSI_PD_MASK BIT(13)#define SPI_CLK_PD_MASK BIT(12)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1013/1518 pinctrl: airoha: convert PWM GPIO to macro
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Marangi <[email protected]>
[ Upstream commit 1552ad5d649cff9d170e5bc1d13ab1487333b4b7 ]
The PWM GPIO struct definition follow the same pattern for every GPIO pin hence it can be converted to a macro.
Create 2 macro one for normal mux and one for ext mux and convert all the entry to these new macro to reduce code size.
Stable-dep-of: 739bc85aed14 ("pinctrl: airoha: an7581: fix mux/conf of pcie_reset pins")
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 465 ++++------------------ 1 file changed, 68 insertions(+), 397 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +68 -397
@@ -1435,404 +1435,75 @@ static const struct airoha_pinctrl_func_group an7583_pcie_reset_func_group[] = { };/* PWM */ +#define AIROHA_PINCTRL_PWM (gpio, mux_val) \ + { \ + .name = (gpio), \ + .regmap[0] = { \ + AIROHA_FUNC_PWM_MUX, \ + REG_GPIO_FLASH_MODE_CFG, \ + (mux_val), \ + (mux_val) \ + }, \ + .regmap_size = 1, \ + } \ + +#define AIROHA_PINCTRL_PWM_EXT (gpio, mux_val) \ + { \ + .name = (gpio), \ + .regmap[0] = { \ + AIROHA_FUNC_PWM_EXT_MUX, \ + REG_GPIO_FLASH_MODE_CFG_EXT, \ + (mux_val), \ + (mux_val) \ + }, \ + .regmap_size = 1, \ + } \ +static const struct airoha_pinctrl_func_group pwm_func_group[] = { - { - .name ="gpio0" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_MUX , -REG_GPIO_FLASH_MODE_CFG , -GPIO0_FLASH_MODE_CFG , -GPIO0_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio1" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_MUX , -REG_GPIO_FLASH_MODE_CFG , -GPIO1_FLASH_MODE_CFG , -GPIO1_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio2" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_MUX , -REG_GPIO_FLASH_MODE_CFG , -GPIO2_FLASH_MODE_CFG , -GPIO2_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio3" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_MUX , -REG_GPIO_FLASH_MODE_CFG , -GPIO3_FLASH_MODE_CFG , -GPIO3_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio4" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_MUX , -REG_GPIO_FLASH_MODE_CFG , -GPIO4_FLASH_MODE_CFG , -GPIO4_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio5" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_MUX , -REG_GPIO_FLASH_MODE_CFG , -GPIO5_FLASH_MODE_CFG , -GPIO5_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio6" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_MUX , -REG_GPIO_FLASH_MODE_CFG , -GPIO6_FLASH_MODE_CFG , -GPIO6_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio7" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_MUX , -REG_GPIO_FLASH_MODE_CFG , -GPIO7_FLASH_MODE_CFG , -GPIO7_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio8" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_MUX , -REG_GPIO_FLASH_MODE_CFG , -GPIO8_FLASH_MODE_CFG , -GPIO8_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio9" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_MUX , -REG_GPIO_FLASH_MODE_CFG , -GPIO9_FLASH_MODE_CFG , -GPIO9_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio10" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_MUX , -REG_GPIO_FLASH_MODE_CFG , -GPIO10_FLASH_MODE_CFG , -GPIO10_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio11" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_MUX , -REG_GPIO_FLASH_MODE_CFG , -GPIO11_FLASH_MODE_CFG , -GPIO11_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio12" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_MUX , -REG_GPIO_FLASH_MODE_CFG , -GPIO12_FLASH_MODE_CFG , -GPIO12_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio13" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_MUX , -REG_GPIO_FLASH_MODE_CFG , -GPIO13_FLASH_MODE_CFG , -GPIO13_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio14" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_MUX , -REG_GPIO_FLASH_MODE_CFG , -GPIO14_FLASH_MODE_CFG , -GPIO14_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio15" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_MUX , -REG_GPIO_FLASH_MODE_CFG , -GPIO15_FLASH_MODE_CFG , -GPIO15_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio16" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO16_FLASH_MODE_CFG , -GPIO16_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio17" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO17_FLASH_MODE_CFG , -GPIO17_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio18" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO18_FLASH_MODE_CFG , -GPIO18_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio19" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO19_FLASH_MODE_CFG , -GPIO19_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio20" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO20_FLASH_MODE_CFG , -GPIO20_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio21" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO21_FLASH_MODE_CFG , -GPIO21_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio22" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO22_FLASH_MODE_CFG , -GPIO22_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio23" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO23_FLASH_MODE_CFG , -GPIO23_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio24" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO24_FLASH_MODE_CFG , -GPIO24_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio25" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO25_FLASH_MODE_CFG , -GPIO25_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio26" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO26_FLASH_MODE_CFG , -GPIO26_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio27" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO27_FLASH_MODE_CFG , -GPIO27_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio28" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO28_FLASH_MODE_CFG , -GPIO28_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio29" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO29_FLASH_MODE_CFG , -GPIO29_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio30" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO30_FLASH_MODE_CFG , -GPIO30_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio31" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO31_FLASH_MODE_CFG , -GPIO31_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio36" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO36_FLASH_MODE_CFG , -GPIO36_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio37" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO37_FLASH_MODE_CFG , -GPIO37_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio38" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO38_FLASH_MODE_CFG , -GPIO38_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio39" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO39_FLASH_MODE_CFG , -GPIO39_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio40" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO40_FLASH_MODE_CFG , -GPIO40_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio41" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO41_FLASH_MODE_CFG , -GPIO41_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio42" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO42_FLASH_MODE_CFG , -GPIO42_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio43" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO43_FLASH_MODE_CFG , -GPIO43_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio44" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO44_FLASH_MODE_CFG , -GPIO44_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio45" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO45_FLASH_MODE_CFG , -GPIO45_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio46" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO46_FLASH_MODE_CFG , -GPIO46_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, { - .name ="gpio47" , - .regmap[0 ] = { -AIROHA_FUNC_PWM_EXT_MUX , -REG_GPIO_FLASH_MODE_CFG_EXT , -GPIO47_FLASH_MODE_CFG , -GPIO47_FLASH_MODE_CFG - }, - .regmap_size =1 , - }, +AIROHA_PINCTRL_PWM ("gpio0" ,GPIO0_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio1" ,GPIO1_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio2" ,GPIO2_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio3" ,GPIO3_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio4" ,GPIO4_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio5" ,GPIO5_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio6" ,GPIO6_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio7" ,GPIO7_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio8" ,GPIO8_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio9" ,GPIO9_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio10" ,GPIO10_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio11" ,GPIO11_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio12" ,GPIO12_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio13" ,GPIO13_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio14" ,GPIO14_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio15" ,GPIO15_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio16" ,GPIO16_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio17" ,GPIO17_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio18" ,GPIO18_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio19" ,GPIO19_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio20" ,GPIO20_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio21" ,GPIO21_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio22" ,GPIO22_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio23" ,GPIO23_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio24" ,GPIO24_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio25" ,GPIO25_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio26" ,GPIO26_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio27" ,GPIO27_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio28" ,GPIO28_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio29" ,GPIO29_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio30" ,GPIO30_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio31" ,GPIO31_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio36" ,GPIO36_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio37" ,GPIO37_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio38" ,GPIO38_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio39" ,GPIO39_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio40" ,GPIO40_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio41" ,GPIO41_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio42" ,GPIO42_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio43" ,GPIO43_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio44" ,GPIO44_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio45" ,GPIO45_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio46" ,GPIO46_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio47" ,GPIO47_FLASH_MODE_CFG ), };#define AIROHA_PINCTRL_PHY_LED0 (gpio, mux_val, map_mask, map_val) \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1014/1518 pinctrl: airoha: fix pwm pin function for an7581 and an7583
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 08a5af468e613b6d8cd9725d284c9e6be288d364 ]
AN7581 have 47 valid GPIOs only (gpio0-gpio46), so gpio47 is a fiction. AN7583 have 49 valid GPIOs (gpio0-gpio48), so gpio48 is missed
To fix an issue
* create AN7583 specific pwm pin function,
* remove gpio47 from AN7581 pwm pin function.
Stable-dep-of: 739bc85aed14 ("pinctrl: airoha: an7581: fix mux/conf of pcie_reset pins")
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 74 ++++++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +72 -2
@@ -905,7 +905,30 @@ static const char *const pwm_groups[] = { "gpio0", "gpio1","gpio40" ,"gpio41" ,"gpio42" ,"gpio43" ,"gpio44" ,"gpio45" , - "gpio46", "gpio47" }; + "gpio46" }; +static const char *const an7583_pwm_groups[] = {"gpio0" ,"gpio1" , +"gpio2" ,"gpio3" , +"gpio4" ,"gpio5" , +"gpio6" ,"gpio7" , +"gpio8" ,"gpio9" , +"gpio10" ,"gpio11" , +"gpio12" ,"gpio13" , +"gpio14" ,"gpio15" , +"gpio16" ,"gpio17" , +"gpio18" ,"gpio19" , +"gpio20" ,"gpio21" , +"gpio22" ,"gpio23" , +"gpio24" ,"gpio25" , +"gpio26" ,"gpio27" , +"gpio28" ,"gpio29" , +"gpio30" ,"gpio31" , +"gpio36" ,"gpio37" , +"gpio38" ,"gpio39" , +"gpio40" ,"gpio41" , +"gpio42" ,"gpio43" , +"gpio44" ,"gpio45" , +"gpio46" ,"gpio47" , +"gpio48" };static const char *const phy1_led0_groups[] = {"gpio33" ,"gpio34" ,"gpio35" ,"gpio42" }; static const char *const phy2_led0_groups[] = { "gpio33", "gpio34",
@@ -1503,7 +1526,54 @@ static const struct airoha_pinctrl_func_group pwm_func_group[] = {AIROHA_PINCTRL_PWM_EXT ("gpio44" ,GPIO44_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM_EXT ("gpio45" ,GPIO45_FLASH_MODE_CFG ), AIROHA_PINCTRL_PWM_EXT("gpio46", GPIO46_FLASH_MODE_CFG), +}; + +static const struct airoha_pinctrl_func_group an7583_pwm_func_group[] = { +AIROHA_PINCTRL_PWM ("gpio0" ,GPIO0_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio1" ,GPIO1_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio2" ,GPIO2_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio3" ,GPIO3_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio4" ,GPIO4_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio5" ,GPIO5_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio6" ,GPIO6_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio7" ,GPIO7_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio8" ,GPIO8_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio9" ,GPIO9_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio10" ,GPIO10_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio11" ,GPIO11_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio12" ,GPIO12_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio13" ,GPIO13_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio14" ,GPIO14_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM ("gpio15" ,GPIO15_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio16" ,GPIO16_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio17" ,GPIO17_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio18" ,GPIO18_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio19" ,GPIO19_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio20" ,GPIO20_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio21" ,GPIO21_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio22" ,GPIO22_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio23" ,GPIO23_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio24" ,GPIO24_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio25" ,GPIO25_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio26" ,GPIO26_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio27" ,GPIO27_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio28" ,GPIO28_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio29" ,GPIO29_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio30" ,GPIO30_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio31" ,GPIO31_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio36" ,GPIO36_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio37" ,GPIO37_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio38" ,GPIO38_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio39" ,GPIO39_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio40" ,GPIO40_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio41" ,GPIO41_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio42" ,GPIO42_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio43" ,GPIO43_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio44" ,GPIO44_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio45" ,GPIO45_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio46" ,GPIO46_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM_EXT ("gpio47" ,GPIO47_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT ("gpio48" ,GPIO48_FLASH_MODE_CFG ), };#define AIROHA_PINCTRL_PHY_LED0 (gpio, mux_val, map_mask, map_val) \
@@ -1758,7 +1828,7 @@ static const struct airoha_pinctrl_func an7583_pinctrl_funcs[] = {PINCTRL_FUNC_DESC ("emmc" , emmc),PINCTRL_FUNC_DESC ("pnand" , pnand),PINCTRL_FUNC_DESC ("pcie_reset" , an7583_pcie_reset), -PINCTRL_FUNC_DESC ("pwm" , pwm), +PINCTRL_FUNC_DESC ("pwm" , an7583_pwm),PINCTRL_FUNC_DESC ("phy1_led0" , an7583_phy1_led0),PINCTRL_FUNC_DESC ("phy2_led0" , an7583_phy2_led0), PINCTRL_FUNC_DESC("phy3_led0", an7583_phy3_led0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1015/1518 pinctrl: airoha: an7581: fix mux/conf of pcie_reset pins
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 739bc85aed14b739dca5b7aff4241b778af80220 ]
In the an7581 case
* gpio47 and pcie_reset0 shares pin 60,
* gpio48 and pcie_reset1 shares pin 61,
* gpio49 and pcie_reset2 shares pin 62.
but current driver treat them as pins 61--63. This is wrong.
Also current an7581 pinmux implementation have following issues:
* current pcie_reset pin function actually sets corresponding pins as gpios.
* there is no proper way to set pcie_reset pins as gpios.
* there is no way to set pcie_reset pins as pwm.
This patch fixes above issues.
WARNING:
There is a contradiction in the Airoha documentation. AN7581 programming guide claims:
- gpio44 and pcie_reset0 shares the same pin
- gpio45 and pcie_reset1 shares the same pin
- gpio46 and pcie_reset2 shares the same pin
While AN7581 datasheet claims:
- gpio47 and pcie_reset0 shares the same pin
- gpio48 and pcie_reset1 shares the same pin
- gpio49 and pcie_reset2 shares the same pin
The datasheet should be considered as a more reliable source. Thanks to Benjamin Larsson for clarification.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 122 +++++++++++++++++----- 1 file changed, 97 insertions(+), 25 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +97 -25
@@ -470,9 +470,9 @@ static struct pinctrl_pin_desc en7581_pinctrl_pins[] = {PINCTRL_PIN (57 ,"gpio44" ),PINCTRL_PIN (58 ,"gpio45" ),PINCTRL_PIN (59 ,"gpio46" ), -PINCTRL_PIN (61 ,"pcie_reset0" ), -PINCTRL_PIN (62 ,"pcie_reset1" ), - PINCTRL_PIN(63, "pcie_reset2"), +PINCTRL_PIN (60 ,"pcie_reset0" ), +PINCTRL_PIN (61 ,"pcie_reset1" ), + PINCTRL_PIN(62, "pcie_reset2"), };static const int en7581_pon_pins[] = {49 ,50 ,51 ,52 ,53 ,54 };
@@ -555,9 +555,12 @@ static const int en7581_gpio43_pins[] = { 56 };static const int en7581_gpio44_pins[] = {57 };static const int en7581_gpio45_pins[] = {58 };static const int en7581_gpio46_pins[] = {59 }; -static const int en7581_pcie_reset0_pins[] = {61 }; -static const int en7581_pcie_reset1_pins[] = {62 }; -static const int en7581_pcie_reset2_pins[] = {63 }; +static const int en7581_gpio47_pins[] = {60 }; +static const int en7581_gpio48_pins[] = {61 }; +static const int en7581_gpio49_pins[] = {62 }; +static const int en7581_pcie_reset0_pins[] = {60 }; +static const int en7581_pcie_reset1_pins[] = {61 }; +static const int en7581_pcie_reset2_pins[] = {62 };static const struct pingroup en7581_pinctrl_groups[] = {PINCTRL_PIN_GROUP ("pon" , en7581_pon),
@@ -640,6 +643,9 @@ static const struct pingroup en7581_pinctrl_groups[] = {PINCTRL_PIN_GROUP ("gpio44" , en7581_gpio44),PINCTRL_PIN_GROUP ("gpio45" , en7581_gpio45),PINCTRL_PIN_GROUP ("gpio46" , en7581_gpio46), +PINCTRL_PIN_GROUP ("gpio47" , en7581_gpio47), +PINCTRL_PIN_GROUP ("gpio48" , en7581_gpio48), +PINCTRL_PIN_GROUP ("gpio49" , en7581_gpio49),PINCTRL_PIN_GROUP ("pcie_reset0" , en7581_pcie_reset0),PINCTRL_PIN_GROUP ("pcie_reset1" , en7581_pcie_reset1), PINCTRL_PIN_GROUP("pcie_reset2", en7581_pcie_reset2),
@@ -881,6 +887,7 @@ static const char *const an7583_pcm_spi_groups[] = { "pcm_spi", "pcm_spi_int",static const char *const i2s_groups[] = {"i2s" };static const char *const emmc_groups[] = {"emmc" };static const char *const pnand_groups[] = {"pnand" }; +static const char *const gpio_groups[] = {"gpio47" ,"gpio48" ,"gpio49" };static const char *const pcie_reset_groups[] = {"pcie_reset0" ,"pcie_reset1" ,"pcie_reset2" };static const char *const an7583_pcie_reset_groups[] = {"pcie_reset0" ,"pcie_reset1" };
@@ -905,7 +912,8 @@ static const char *const pwm_groups[] = { "gpio0", "gpio1","gpio40" ,"gpio41" ,"gpio42" ,"gpio43" ,"gpio44" ,"gpio45" , - "gpio46" }; +"gpio46" ,"gpio47" , + "gpio48", "gpio49" };static const char *const an7583_pwm_groups[] = {"gpio0" ,"gpio1" ,"gpio2" ,"gpio3" , "gpio4", "gpio5",
@@ -1404,6 +1412,45 @@ static const struct airoha_pinctrl_func_group pnand_func_group[] = { }, }; +#define AIROHA_PINCTRL_GPIO (gpio, mux_val) \ + { \ + .name = (gpio), \ + .regmap[0] = { \ + AIROHA_FUNC_MUX, \ + REG_GPIO_PON_MODE, \ + (mux_val), \ + (mux_val) \ + }, \ + .regmap_size = 1, \ + } + +#define AIROHA_PINCTRL_GPIO_EXT (gpio, mux_val, smux_val) \ + { \ + .name = (gpio), \ + .regmap[0] = { \ + AIROHA_FUNC_PWM_EXT_MUX, \ + REG_GPIO_FLASH_MODE_CFG_EXT, \ + (mux_val), \ + 0 \ + }, \ + .regmap[1] = { \ + AIROHA_FUNC_MUX, \ + REG_GPIO_PON_MODE, \ + (smux_val), \ + (smux_val) \ + }, \ + .regmap_size = 2, \ + } + +static const struct airoha_pinctrl_func_group gpio_func_group[] = { +AIROHA_PINCTRL_GPIO_EXT ("gpio47" ,GPIO47_FLASH_MODE_CFG , +GPIO_PCIE_RESET0_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio48" ,GPIO48_FLASH_MODE_CFG , +GPIO_PCIE_RESET1_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio49" ,GPIO49_FLASH_MODE_CFG , +GPIO_PCIE_RESET2_MASK ), +}; +static const struct airoha_pinctrl_func_group pcie_reset_func_group[] = { { .name ="pcie_reset0" ,
@@ -1411,7 +1458,7 @@ static const struct airoha_pinctrl_func_group pcie_reset_func_group[] = {AIROHA_FUNC_MUX ,REG_GPIO_PON_MODE ,GPIO_PCIE_RESET0_MASK , -GPIO_PCIE_RESET0_MASK +0 }, .regmap_size = 1, }, {
@@ -1420,7 +1467,7 @@ static const struct airoha_pinctrl_func_group pcie_reset_func_group[] = {AIROHA_FUNC_MUX ,REG_GPIO_PON_MODE ,GPIO_PCIE_RESET1_MASK , -GPIO_PCIE_RESET1_MASK +0 }, .regmap_size = 1, }, {
@@ -1429,7 +1476,7 @@ static const struct airoha_pinctrl_func_group pcie_reset_func_group[] = { AIROHA_FUNC_MUX,REG_GPIO_PON_MODE ,GPIO_PCIE_RESET2_MASK , -GPIO_PCIE_RESET2_MASK + 0 }, .regmap_size = 1, },
@@ -1482,6 +1529,24 @@ static const struct airoha_pinctrl_func_group an7583_pcie_reset_func_group[] = { .regmap_size = 1, \ } \ +#define AIROHA_PINCTRL_PWM_EXT_SEC (gpio, mux_val, smux_val) \ + { \ + .name = (gpio), \ + .regmap[0] = { \ + AIROHA_FUNC_PWM_EXT_MUX, \ + REG_GPIO_FLASH_MODE_CFG_EXT, \ + (mux_val), \ + (mux_val) \ + }, \ + .regmap[1] = { \ + AIROHA_FUNC_MUX, \ + REG_GPIO_PON_MODE, \ + (smux_val), \ + (smux_val) \ + }, \ + .regmap_size = 2, \ + } +static const struct airoha_pinctrl_func_group pwm_func_group[] = {AIROHA_PINCTRL_PWM ("gpio0" ,GPIO0_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM ("gpio1" ,GPIO1_FLASH_MODE_CFG ),
@@ -1526,6 +1591,12 @@ static const struct airoha_pinctrl_func_group pwm_func_group[] = {AIROHA_PINCTRL_PWM_EXT ("gpio44" ,GPIO44_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM_EXT ("gpio45" ,GPIO45_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM_EXT ("gpio46" ,GPIO46_FLASH_MODE_CFG ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio47" ,GPIO47_FLASH_MODE_CFG , +GPIO_PCIE_RESET0_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio48" ,GPIO48_FLASH_MODE_CFG , +GPIO_PCIE_RESET1_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio49" ,GPIO49_FLASH_MODE_CFG , + GPIO_PCIE_RESET2_MASK), }; static const struct airoha_pinctrl_func_group an7583_pwm_func_group[] = {
@@ -1802,6 +1873,7 @@ static const struct airoha_pinctrl_func en7581_pinctrl_funcs[] = {PINCTRL_FUNC_DESC ("i2s" , i2s),PINCTRL_FUNC_DESC ("emmc" , emmc),PINCTRL_FUNC_DESC ("pnand" , pnand), +PINCTRL_FUNC_DESC ("gpio" , gpio),PINCTRL_FUNC_DESC ("pcie_reset" , pcie_reset),PINCTRL_FUNC_DESC ("pwm" , pwm), PINCTRL_FUNC_DESC("phy1_led0", phy1_led0),
@@ -1895,9 +1967,9 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_pullup_conf[] = {PINCTRL_CONF_DESC (57 ,REG_GPIO_H_PU ,BIT (12 )),PINCTRL_CONF_DESC (58 ,REG_GPIO_H_PU ,BIT (13 )),PINCTRL_CONF_DESC (59 ,REG_GPIO_H_PU ,BIT (14 )), -PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_PU ,PCIE0_RESET_PU_MASK ), -PINCTRL_CONF_DESC (62 ,REG_I2C_SDA_PU ,PCIE1_RESET_PU_MASK ), - PINCTRL_CONF_DESC(63, REG_I2C_SDA_PU, PCIE2_RESET_PU_MASK), +PINCTRL_CONF_DESC (60 ,REG_I2C_SDA_PU ,PCIE0_RESET_PU_MASK ), +PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_PU ,PCIE1_RESET_PU_MASK ), + PINCTRL_CONF_DESC(62, REG_I2C_SDA_PU, PCIE2_RESET_PU_MASK), }; static const struct airoha_pinctrl_conf an7583_pinctrl_pullup_conf[] = {
@@ -2012,9 +2084,9 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_pulldown_conf[] = {PINCTRL_CONF_DESC (57 ,REG_GPIO_H_PD ,BIT (12 )),PINCTRL_CONF_DESC (58 ,REG_GPIO_H_PD ,BIT (13 )),PINCTRL_CONF_DESC (59 ,REG_GPIO_H_PD ,BIT (14 )), -PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_PD ,PCIE0_RESET_PD_MASK ), -PINCTRL_CONF_DESC (62 ,REG_I2C_SDA_PD ,PCIE1_RESET_PD_MASK ), - PINCTRL_CONF_DESC(63, REG_I2C_SDA_PD, PCIE2_RESET_PD_MASK), +PINCTRL_CONF_DESC (60 ,REG_I2C_SDA_PD ,PCIE0_RESET_PD_MASK ), +PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_PD ,PCIE1_RESET_PD_MASK ), + PINCTRL_CONF_DESC(62, REG_I2C_SDA_PD, PCIE2_RESET_PD_MASK), }; static const struct airoha_pinctrl_conf an7583_pinctrl_pulldown_conf[] = {
@@ -2129,9 +2201,9 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e2_conf[] = {PINCTRL_CONF_DESC (57 ,REG_GPIO_H_E2 ,BIT (12 )),PINCTRL_CONF_DESC (58 ,REG_GPIO_H_E2 ,BIT (13 )),PINCTRL_CONF_DESC (59 ,REG_GPIO_H_E2 ,BIT (14 )), -PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_E2 ,PCIE0_RESET_E2_MASK ), -PINCTRL_CONF_DESC (62 ,REG_I2C_SDA_E2 ,PCIE1_RESET_E2_MASK ), - PINCTRL_CONF_DESC(63, REG_I2C_SDA_E2, PCIE2_RESET_E2_MASK), +PINCTRL_CONF_DESC (60 ,REG_I2C_SDA_E2 ,PCIE0_RESET_E2_MASK ), +PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_E2 ,PCIE1_RESET_E2_MASK ), + PINCTRL_CONF_DESC(62, REG_I2C_SDA_E2, PCIE2_RESET_E2_MASK), }; static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e2_conf[] = {
@@ -2246,9 +2318,9 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e4_conf[] = {PINCTRL_CONF_DESC (57 ,REG_GPIO_H_E4 ,BIT (12 )),PINCTRL_CONF_DESC (58 ,REG_GPIO_H_E4 ,BIT (13 )),PINCTRL_CONF_DESC (59 ,REG_GPIO_H_E4 ,BIT (14 )), -PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_E4 ,PCIE0_RESET_E4_MASK ), -PINCTRL_CONF_DESC (62 ,REG_I2C_SDA_E4 ,PCIE1_RESET_E4_MASK ), - PINCTRL_CONF_DESC(63, REG_I2C_SDA_E4, PCIE2_RESET_E4_MASK), +PINCTRL_CONF_DESC (60 ,REG_I2C_SDA_E4 ,PCIE0_RESET_E4_MASK ), +PINCTRL_CONF_DESC (61 ,REG_I2C_SDA_E4 ,PCIE1_RESET_E4_MASK ), + PINCTRL_CONF_DESC(62, REG_I2C_SDA_E4, PCIE2_RESET_E4_MASK), }; static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e4_conf[] = {
@@ -2308,9 +2380,9 @@ static const struct airoha_pinctrl_conf an7583_pinctrl_drive_e4_conf[] = { };static const struct airoha_pinctrl_conf en7581_pinctrl_pcie_rst_od_conf[] = { -PINCTRL_CONF_DESC (61 ,REG_PCIE_RESET_OD ,PCIE0_RESET_OD_MASK ), -PINCTRL_CONF_DESC (62 ,REG_PCIE_RESET_OD ,PCIE1_RESET_OD_MASK ), -PINCTRL_CONF_DESC (63 ,REG_PCIE_RESET_OD ,PCIE2_RESET_OD_MASK ), +PINCTRL_CONF_DESC (60 ,REG_PCIE_RESET_OD ,PCIE0_RESET_OD_MASK ), +PINCTRL_CONF_DESC (61 ,REG_PCIE_RESET_OD ,PCIE1_RESET_OD_MASK ), +PINCTRL_CONF_DESC (62 ,REG_PCIE_RESET_OD ,PCIE2_RESET_OD_MASK ), };static const struct airoha_pinctrl_conf an7583_pinctrl_pcie_rst_od_conf[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1016/1518 pinctrl: airoha: an7583: fix muxing of non-gpio default pins
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit aaa41d8010c04635e035a9d334885b07edc8af21 ]
Current an7583 pinmux implementation have following issues:
* pins 51 and 52 can't be set as pcie_reset, current pcie_reset code will sets pins to gpio mode instead.
* there is no proper way to set pins 41--54 to gpio mode.
* pins 41--53 can't be actually set as pwm pins. These pins must be muxed to gpio mode as well.
This patch fixes above issues.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 99 ++++++++++++++++++++--- 1 file changed, 86 insertions(+), 13 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +86 -13
@@ -85,6 +85,18 @@#define GPIO_SPI_CS1_MODE_MASK BIT(0)#define REG_GPIO_PON_MODE 0x021c +#define AN7583_MDIO_0_GPIO_MODE_MASK BIT(26) +#define AN7583_MDC_0_GPIO_MODE_MASK BIT(25) +#define AN7583_UART_RXD_GPIO_MODE_MASK BIT(24) +#define AN7583_UART_TXD_GPIO_MODE_MASK BIT(23) +#define AN7583_SPI_MISO_GPIO_MODE_MASK BIT(22) +#define AN7583_SPI_MOSI_GPIO_MODE_MASK BIT(21) +#define AN7583_SPI_CS_GPIO_MODE_MASK BIT(20) +#define AN7583_SPI_CLK_GPIO_MODE_MASK BIT(19) +#define AN7583_I2C1_SDA_GPIO_MODE_MASK BIT(18) +#define AN7583_I2C1_SCL_GPIO_MODE_MASK BIT(17) +#define AN7583_I2C0_SDA_GPIO_MODE_MASK BIT(16) +#define AN7583_I2C0_SCL_GPIO_MODE_MASK BIT(15)#define GPIO_PARALLEL_NAND_MODE_MASK BIT(14)#define GPIO_SGMII_MDIO_MODE_MASK BIT(13)#define GPIO_PCIE_RESET2_MASK BIT(12)
@@ -781,6 +793,10 @@ static const int an7583_gpio45_pins[] = { 47 };static const int an7583_gpio46_pins[] = {48 };static const int an7583_gpio47_pins[] = {49 };static const int an7583_gpio48_pins[] = {50 }; +static const int an7583_gpio49_pins[] = {51 }; +static const int an7583_gpio50_pins[] = {52 }; +static const int an7583_gpio51_pins[] = {53 }; +static const int an7583_gpio52_pins[] = {54 };static const int an7583_pcie_reset0_pins[] = {51 };static const int an7583_pcie_reset1_pins[] = {52 };
@@ -859,6 +875,10 @@ static const struct pingroup an7583_pinctrl_groups[] = {PINCTRL_PIN_GROUP ("gpio46" , an7583_gpio46),PINCTRL_PIN_GROUP ("gpio47" , an7583_gpio47),PINCTRL_PIN_GROUP ("gpio48" , an7583_gpio48), +PINCTRL_PIN_GROUP ("gpio49" , an7583_gpio49), +PINCTRL_PIN_GROUP ("gpio50" , an7583_gpio50), +PINCTRL_PIN_GROUP ("gpio51" , an7583_gpio51), +PINCTRL_PIN_GROUP ("gpio52" , an7583_gpio52),PINCTRL_PIN_GROUP ("pcie_reset0" , an7583_pcie_reset0), PINCTRL_PIN_GROUP("pcie_reset1", an7583_pcie_reset1), };
@@ -890,6 +910,11 @@ static const char *const pnand_groups[] = { "pnand" };static const char *const gpio_groups[] = {"gpio47" ,"gpio48" ,"gpio49" };static const char *const pcie_reset_groups[] = {"pcie_reset0" ,"pcie_reset1" ,"pcie_reset2" }; +static const char *const an7583_gpio_groups[] = {"gpio39" ,"gpio40" ,"gpio41" , +"gpio42" ,"gpio43" ,"gpio44" , +"gpio45" ,"gpio46" ,"gpio47" , +"gpio48" ,"gpio49" ,"gpio50" , +"gpio51" ,"gpio52" };static const char *const an7583_pcie_reset_groups[] = {"pcie_reset0" ,"pcie_reset1" };static const char *const pwm_groups[] = {"gpio0" ,"gpio1" ,"gpio2" ,"gpio3" ,
@@ -936,7 +961,8 @@ static const char *const an7583_pwm_groups[] = { "gpio0", "gpio1","gpio42" ,"gpio43" ,"gpio44" ,"gpio45" ,"gpio46" ,"gpio47" , - "gpio48" }; +"gpio48" ,"gpio49" , + "gpio50", "gpio51" };static const char *const phy1_led0_groups[] = {"gpio33" ,"gpio34" ,"gpio35" ,"gpio42" }; static const char *const phy2_led0_groups[] = { "gpio33", "gpio34",
@@ -1482,6 +1508,36 @@ static const struct airoha_pinctrl_func_group pcie_reset_func_group[] = { }, }; +static const struct airoha_pinctrl_func_group an7583_gpio_func_group[] = { +AIROHA_PINCTRL_GPIO_EXT ("gpio39" ,GPIO39_FLASH_MODE_CFG , +AN7583_I2C0_SCL_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio40" ,GPIO40_FLASH_MODE_CFG , +AN7583_I2C0_SDA_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio41" ,GPIO41_FLASH_MODE_CFG , +AN7583_I2C1_SCL_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio42" ,GPIO42_FLASH_MODE_CFG , +AN7583_I2C1_SDA_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio43" ,GPIO43_FLASH_MODE_CFG , +AN7583_SPI_CLK_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio44" ,GPIO44_FLASH_MODE_CFG , +AN7583_SPI_CS_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio45" ,GPIO45_FLASH_MODE_CFG , +AN7583_SPI_MOSI_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio46" ,GPIO46_FLASH_MODE_CFG , +AN7583_SPI_MISO_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio47" ,GPIO47_FLASH_MODE_CFG , +AN7583_UART_TXD_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio48" ,GPIO48_FLASH_MODE_CFG , +AN7583_UART_RXD_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio49" ,GPIO49_FLASH_MODE_CFG , +GPIO_PCIE_RESET0_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio50" ,GPIO50_FLASH_MODE_CFG , +GPIO_PCIE_RESET1_MASK ), +AIROHA_PINCTRL_GPIO_EXT ("gpio51" ,GPIO51_FLASH_MODE_CFG , +AN7583_MDC_0_GPIO_MODE_MASK ), +AIROHA_PINCTRL_GPIO ("gpio52" ,AN7583_MDIO_0_GPIO_MODE_MASK ), +}; +static const struct airoha_pinctrl_func_group an7583_pcie_reset_func_group[] = { { .name ="pcie_reset0" ,
@@ -1489,7 +1545,7 @@ static const struct airoha_pinctrl_func_group an7583_pcie_reset_func_group[] = {AIROHA_FUNC_MUX ,REG_GPIO_PON_MODE ,GPIO_PCIE_RESET0_MASK , -GPIO_PCIE_RESET0_MASK +0 }, .regmap_size = 1, }, {
@@ -1498,7 +1554,7 @@ static const struct airoha_pinctrl_func_group an7583_pcie_reset_func_group[] = { AIROHA_FUNC_MUX,REG_GPIO_PON_MODE ,GPIO_PCIE_RESET1_MASK , -GPIO_PCIE_RESET1_MASK + 0 }, .regmap_size = 1, },
@@ -1635,16 +1691,32 @@ static const struct airoha_pinctrl_func_group an7583_pwm_func_group[] = {AIROHA_PINCTRL_PWM_EXT ("gpio36" ,GPIO36_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM_EXT ("gpio37" ,GPIO37_FLASH_MODE_CFG ),AIROHA_PINCTRL_PWM_EXT ("gpio38" ,GPIO38_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio39" ,GPIO39_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio40" ,GPIO40_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio41" ,GPIO41_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio42" ,GPIO42_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio43" ,GPIO43_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio44" ,GPIO44_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio45" ,GPIO45_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio46" ,GPIO46_FLASH_MODE_CFG ), -AIROHA_PINCTRL_PWM_EXT ("gpio47" ,GPIO47_FLASH_MODE_CFG ), - AIROHA_PINCTRL_PWM_EXT("gpio48", GPIO48_FLASH_MODE_CFG), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio39" ,GPIO39_FLASH_MODE_CFG , +AN7583_I2C0_SCL_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio40" ,GPIO40_FLASH_MODE_CFG , +AN7583_I2C0_SDA_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio41" ,GPIO41_FLASH_MODE_CFG , +AN7583_I2C1_SCL_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio42" ,GPIO42_FLASH_MODE_CFG , +AN7583_I2C1_SDA_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio43" ,GPIO43_FLASH_MODE_CFG , +AN7583_SPI_CLK_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio44" ,GPIO44_FLASH_MODE_CFG , +AN7583_SPI_CS_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio45" ,GPIO45_FLASH_MODE_CFG , +AN7583_SPI_MOSI_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio46" ,GPIO46_FLASH_MODE_CFG , +AN7583_SPI_MISO_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio47" ,GPIO47_FLASH_MODE_CFG , +AN7583_UART_TXD_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio48" ,GPIO48_FLASH_MODE_CFG , +AN7583_UART_RXD_GPIO_MODE_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio49" ,GPIO49_FLASH_MODE_CFG , +GPIO_PCIE_RESET0_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio50" ,GPIO50_FLASH_MODE_CFG , +GPIO_PCIE_RESET1_MASK ), +AIROHA_PINCTRL_PWM_EXT_SEC ("gpio51" ,GPIO51_FLASH_MODE_CFG , + AN7583_MDC_0_GPIO_MODE_MASK), };#define AIROHA_PINCTRL_PHY_LED0 (gpio, mux_val, map_mask, map_val) \
@@ -1899,6 +1971,7 @@ static const struct airoha_pinctrl_func an7583_pinctrl_funcs[] = {PINCTRL_FUNC_DESC ("pcm_spi" , an7583_pcm_spi),PINCTRL_FUNC_DESC ("emmc" , emmc),PINCTRL_FUNC_DESC ("pnand" , pnand), +PINCTRL_FUNC_DESC ("gpio" , an7583_gpio),PINCTRL_FUNC_DESC ("pcie_reset" , an7583_pcie_reset),PINCTRL_FUNC_DESC ("pwm" , an7583_pwm), PINCTRL_FUNC_DESC("phy1_led0", an7583_phy1_led0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1017/1518 pinctrl: airoha: an7583: fix spi group pins
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit ccc41d25590645096bdbf420b43e7c22627b3f59 ]
pcm pins were used insted of spi pins. This patch fixes an issue.
Thanks to Daniel Schwierzeck for noticing it.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +1 -1
@@ -738,7 +738,7 @@ static const int an7583_jtag_udi_pins[] = { 23, 24, 22, 25, 26 };static const int an7583_jtag_dfd_pins[] = {23 ,24 ,22 ,25 ,26 };static const int an7583_pcm1_pins[] = {10 ,11 ,12 ,13 ,14 };static const int an7583_pcm2_pins[] = {28 ,29 ,30 ,31 ,24 }; -static const int an7583_spi_pins[] = {28 ,29 ,30 ,31 }; +static const int an7583_spi_pins[] = {45 ,46 ,47 ,48 };static const int an7583_spi_quad_pins[] = {25 ,26 };static const int an7583_spi_cs1_pins[] = {27 };static const int an7583_pcm_spi_pins[] = {28 ,29 ,30 ,31 ,10 ,11 ,12 ,13 };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1018/1518 pinctrl: airoha: add missed get_direction() function for gpio_chip
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit d6392502a9e6b11c3a93eb4c987672a8c638d749 ]
This patch adds missed get_direction() function for gpio_chip. Also it reimplements pinconf's get_direction() function using newly defined function.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 50 +++++++++++++++-------- 1 file changed, 34 insertions(+), 16 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +34 -16
@@ -2502,6 +2502,22 @@ static int airoha_gpio_get(struct gpio_chip *chip, unsigned int gpio)return err ? err : !!(val &BIT (pin)); } +static int airoha_gpio_get_direction (struct gpio_chip *chip,unsigned int gpio) +{ +struct airoha_pinctrl *pinctrl =gpiochip_get_data (chip); +u32 val, mask; +u8 index; +int err; + + index = gpio /AIROHA_REG_GPIOCTRL_NUM_PIN ; + err =regmap_read (pinctrl->regmap, pinctrl->gpiochip.dir[index], &val); +if (err) +return err; + + mask =BIT (2 * (gpio %AIROHA_REG_GPIOCTRL_NUM_PIN )); +return val & mask ?GPIO_LINE_DIRECTION_OUT :GPIO_LINE_DIRECTION_IN ; +} +static int airoha_gpio_direction_output (struct gpio_chip *chip,unsigned int gpio,int value) {
@@ -2635,19 +2651,13 @@ static int airoha_pinctrl_add_gpiochip(struct airoha_pinctrl *pinctrl,struct device *dev = &pdev->dev;int irq, err; - chip->data = gpio_data_regs; - chip->dir = gpio_dir_regs; - chip->out = gpio_out_regs; - chip->status = irq_status_regs; - chip->level = irq_level_regs; - chip->edge = irq_edge_regs; - gc->parent = dev; gc->label =dev_name (dev); gc->request = gpiochip_generic_request; gc->free = gpiochip_generic_free; gc->direction_input = pinctrl_gpio_direction_input; gc->direction_output = airoha_gpio_direction_output; + gc->get_direction = airoha_gpio_get_direction; gc->set = airoha_gpio_set; gc->get = airoha_gpio_get; gc->base =-1 ;
@@ -2857,21 +2867,18 @@ static int airoha_pinctrl_set_conf(struct airoha_pinctrl *pinctrl,static int airoha_pinconf_get_direction (struct pinctrl_dev *pctrl_dev,u32 p) {struct airoha_pinctrl *pinctrl =pinctrl_dev_get_drvdata (pctrl_dev); -u32 val, mask; -int err, pin; -u8 index; +int ret, pin; pin =airoha_convert_pin_to_reg_offset (pctrl_dev,NULL , p);if (pin <0 )return pin; - index = pin /AIROHA_REG_GPIOCTRL_NUM_PIN ; - err =regmap_read (pinctrl->regmap, pinctrl->gpiochip.dir[index], &val); -if (err) -return err; + ret =airoha_gpio_get_direction (&pinctrl->gpiochip.chip, pin); +if (ret <0 ) +return ret; - mask =BIT (2 * (pin %AIROHA_REG_GPIOCTRL_NUM_PIN )); -return val & mask ?PIN_CONFIG_OUTPUT_ENABLE :PIN_CONFIG_INPUT_ENABLE ; +return ret ==GPIO_LINE_DIRECTION_OUT ? +PIN_CONFIG_OUTPUT_ENABLE :PIN_CONFIG_INPUT_ENABLE ; } static int airoha_pinconf_get(struct pinctrl_dev *pctrl_dev,
@@ -3117,6 +3124,17 @@ static int airoha_pinctrl_probe(struct platform_device *pdev) pinctrl->desc.pins = data->pins, pinctrl->desc.npins = data->num_pins, +/* +* some pinctrl operations (ex: get_direction) might use gpio registers +* before gpio chip abstraction will be completely initialized. +*/ + pinctrl->gpiochip.data = gpio_data_regs; + pinctrl->gpiochip.dir = gpio_dir_regs; + pinctrl->gpiochip.out = gpio_out_regs; + pinctrl->gpiochip.status = irq_status_regs; + pinctrl->gpiochip.level = irq_level_regs; + pinctrl->gpiochip.edge = irq_edge_regs; + err =devm_pinctrl_register_and_init (dev, &pinctrl->desc, pinctrl, &pinctrl->ctrl);if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1019/1518 pinctrl: airoha: fix getting gpiochip/pinctrl pointers in the IRQ handling code
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit b8dd30554847bde27e8a4584dd447c1c3ac585ce ]
airoha_irq_unmask(), airoha_irq_mask(), airoha_irq_type() functions impements brain damaged logic to retrieve gpiochip and pinctrl pointers.
Details:
gpiochip = irq_data_get_irq_chip_data(data);
will initialize gpiochip variable with data->chip_data value. This value initialized inside gpiochip_irq_map() function
static int gpiochip_irq_map(struct irq_domain *d, unsigned int irq,
irq_hw_number_t hwirq)
{
struct gpio_chip *gc = d->host_data;
...
irq_set_chip_data(irq, gc);
...
}Thus gpiochip variable of 'struct airoha_pinctrl_gpiochip *' type will be initialized with a pointer to a variable of 'struct gpio_chip' type.
Luckily, gpio_chip is the first element of airoha_pinctrl_gpiochip, so gpiochip pointer will get a correct value.
This patch implements correct logic of getting gpiochip and pinctrl pointers.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +9 -11
@@ -2533,18 +2533,17 @@ static int airoha_gpio_direction_output(struct gpio_chip *chip,/* irq callbacks */ static void airoha_irq_unmask (struct irq_data *data) { +struct gpio_chip *gc =irq_data_get_irq_chip_data (data); +struct airoha_pinctrl *pinctrl =gpiochip_get_data (gc); +struct airoha_pinctrl_gpiochip *gpiochip = &pinctrl->gpiochip;u8 offset = data->hwirq %AIROHA_REG_GPIOCTRL_NUM_PIN ;u8 index = data->hwirq /AIROHA_REG_GPIOCTRL_NUM_PIN ;u32 mask =GENMASK (2 * offset +1 ,2 * offset); -struct airoha_pinctrl_gpiochip *gpiochip; -struct airoha_pinctrl *pinctrl;u32 val =BIT (2 * offset); - gpiochip =irq_data_get_irq_chip_data (data);if (WARN_ON_ONCE (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type)))return ; - pinctrl = container_of(gpiochip, struct airoha_pinctrl, gpiochip);switch (gpiochip->irq_type[data->hwirq]) {case IRQ_TYPE_LEVEL_LOW : val = val <<1 ;
@@ -2570,14 +2569,12 @@ static void airoha_irq_unmask(struct irq_data *data)static void airoha_irq_mask (struct irq_data *data) { +struct gpio_chip *gc =irq_data_get_irq_chip_data (data); +struct airoha_pinctrl *pinctrl =gpiochip_get_data (gc); +struct airoha_pinctrl_gpiochip *gpiochip = &pinctrl->gpiochip;u8 offset = data->hwirq %AIROHA_REG_GPIOCTRL_NUM_PIN ;u8 index = data->hwirq /AIROHA_REG_GPIOCTRL_NUM_PIN ;u32 mask =GENMASK (2 * offset +1 ,2 * offset); -struct airoha_pinctrl_gpiochip *gpiochip; -struct airoha_pinctrl *pinctrl; - - gpiochip =irq_data_get_irq_chip_data (data); - pinctrl = container_of(gpiochip, struct airoha_pinctrl, gpiochip);regmap_clear_bits (pinctrl->regmap, gpiochip->level[index], mask);regmap_clear_bits (pinctrl->regmap, gpiochip->edge[index], mask);
@@ -2585,9 +2582,10 @@ static void airoha_irq_mask(struct irq_data *data)static int airoha_irq_type (struct irq_data *data,unsigned int type) { -struct airoha_pinctrl_gpiochip *gpiochip; +struct gpio_chip *gc =irq_data_get_irq_chip_data (data); +struct airoha_pinctrl *pinctrl =gpiochip_get_data (gc); +struct airoha_pinctrl_gpiochip *gpiochip = &pinctrl->gpiochip; - gpiochip =irq_data_get_irq_chip_data (data);if (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type))return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1020/1518 pinctrl: airoha: add missed IRQ resource helpers
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit a02fa031b9520e46e98bff17e12b472eba770670 ]
Without hooking .irq_request_resources, gpiolib cannot set GPIOD_FLAG_USED_AS_IRQ. This breaks pin direction locking and can allow userspace or another driver to reconfigure an active IRQ pin as an output
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/mediatek/pinctrl-airoha.c +1 -0
@@ -2638,6 +2638,7 @@ static const struct irq_chip airoha_gpio_irq_chip = { .irq_mask_ack = airoha_irq_mask, .irq_set_type = airoha_irq_type, .flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, }; static int airoha_pinctrl_add_gpiochip(struct airoha_pinctrl *pinctrl,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1021/1518 pinctrl: airoha: fix IRQ mask/unmask code
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 20b996280640f492ebdd41c2d2c991801df75e61 ]
When using IRQCHIP_IMMUTABLE, airoha_irq_unmask() must manually call gpiochip_enable_irq() and airoha_irq_mask() must call gpiochip_disable_irq(). Without these calls, gpiolib never sets the GPIOD_FLAG_IRQ_IS_ENABLED bit. Because this bit is missing, gpiod_direction_output() will not realize the pin is actively used as an interrupt.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pinctrl/mediatek/pinctrl-airoha.c +2 -0
@@ -2544,6 +2544,7 @@ static void airoha_irq_unmask(struct irq_data *data)if (WARN_ON_ONCE (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type)))return ; +gpiochip_enable_irq (gc,irqd_to_hwirq (data));switch (gpiochip->irq_type[data->hwirq]) {case IRQ_TYPE_LEVEL_LOW : val = val <<1 ;
@@ -2578,6 +2579,7 @@ static void airoha_irq_mask(struct irq_data *data)regmap_clear_bits (pinctrl->regmap, gpiochip->level[index], mask);regmap_clear_bits (pinctrl->regmap, gpiochip->edge[index], mask); +gpiochip_disable_irq (gc,irqd_to_hwirq (data)); }static int airoha_irq_type (struct irq_data *data,unsigned int type)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1022/1518 pinctrl: airoha: fix edge-triggered interrupts handling
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 3de4686cdf0ccf6d78ca96ccaea621cbcf69fc3a ]
Edge-triggered interrupts are handled incorrectly because of
* no irq_ack() handler was defined,
* no handle_level_irq() handler was used,
This patch probably fixes an issue
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 37 ++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +33 -4
@@ -2577,11 +2577,28 @@ static void airoha_irq_mask(struct irq_data *data)u8 index = data->hwirq /AIROHA_REG_GPIOCTRL_NUM_PIN ;u32 mask =GENMASK (2 * offset +1 ,2 * offset); +if (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type)) +return ; +regmap_clear_bits (pinctrl->regmap, gpiochip->level[index], mask);regmap_clear_bits (pinctrl->regmap, gpiochip->edge[index], mask);gpiochip_disable_irq (gc,irqd_to_hwirq (data)); } +static void airoha_irq_ack (struct irq_data *data) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (data); +struct airoha_pinctrl *pinctrl =gpiochip_get_data (gc); +struct airoha_pinctrl_gpiochip *gpiochip = &pinctrl->gpiochip; +u8 offset = data->hwirq %AIROHA_PIN_BANK_SIZE ; +u8 index = data->hwirq /AIROHA_PIN_BANK_SIZE ; + +if (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type)) +return ; + +regmap_write (pinctrl->regmap, gpiochip->status[index],BIT (offset)); +} +static int airoha_irq_type (struct irq_data *data,unsigned int type) {struct gpio_chip *gc =irq_data_get_irq_chip_data (data);
@@ -2591,13 +2608,26 @@ static int airoha_irq_type(struct irq_data *data, unsigned int type)if (data->hwirq >=ARRAY_SIZE (gpiochip->irq_type))return -EINVAL ; +if (type ==IRQ_TYPE_NONE ) { + gpiochip->irq_type[data->hwirq] =IRQ_TYPE_NONE ; +irq_set_handler_locked (data, handle_bad_irq); + +return 0 ; + } +if (type ==IRQ_TYPE_PROBE ) {if (gpiochip->irq_type[data->hwirq])return 0 ; type =IRQ_TYPE_EDGE_RISING |IRQ_TYPE_EDGE_FALLING ; } + gpiochip->irq_type[data->hwirq] = type &IRQ_TYPE_SENSE_MASK ; +if (type &IRQ_TYPE_EDGE_BOTH ) +irq_set_handler_locked (data, handle_edge_irq); +else +irq_set_handler_locked (data, handle_level_irq); +return 0 ; }
@@ -2622,8 +2652,7 @@ static irqreturn_t airoha_irq_handler(int irq, void *data)for_each_set_bit (irq, &status,AIROHA_PIN_BANK_SIZE ) {u32 offset = irq + i *AIROHA_PIN_BANK_SIZE ; -generic_handle_irq (irq_find_mapping (girq->domain, - offset)); +generic_handle_domain_irq (girq->domain, offset);regmap_write (pinctrl->regmap, pinctrl->gpiochip.status[i],BIT (irq)); }
@@ -2637,7 +2666,7 @@ static const struct irq_chip airoha_gpio_irq_chip = { .name = "airoha-gpio-irq", .irq_unmask = airoha_irq_unmask, .irq_mask = airoha_irq_mask, - .irq_mask_ack = airoha_irq_mask, + .irq_ack = airoha_irq_ack, .irq_set_type = airoha_irq_type, .flags =IRQCHIP_SET_TYPE_MASKED |IRQCHIP_IMMUTABLE , GPIOCHIP_IRQ_RESOURCE_HELPERS,
@@ -2665,7 +2694,7 @@ static int airoha_pinctrl_add_gpiochip(struct airoha_pinctrl *pinctrl, gc->ngpio =AIROHA_NUM_PINS ; girq->default_type =IRQ_TYPE_NONE ; - girq->handler = handle_simple_irq; + girq->handler = handle_bad_irq;gpio_irq_chip_set_chip (girq, &airoha_gpio_irq_chip); irq =platform_get_irq (pdev,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1023/1518 Bluetooth: virtio_bt: avoid OOB read of build info string
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 502adc06ba76dee19c292ae4a07d74d202fe734d ]
The virtbt_setup_zephyr() sends the Zephyr vendor command 0xfc08 (Read Build Information) and hands the response to bt_dev_info() and hci_set_fw_info() as a "%s" string starting at skb->data + 1, without checking the length. A backend that answers with status only leaves that pointer past the end of the received data, so the walk reads adjacent slab memory until it meets a NUL. Those bytes reach the kernel log and the firmware-info debugfs file.
To fix this, print the string with a bounded "%.*s" limited to skb->len - 1. A short or unterminated response then prints as much as arrived instead of failing setup.
This mirrors commit dd068ef04412 ("Bluetooth: bpa10x: avoid OOB read of revision string in bpa10x_setup()"), which fixed the identical pattern.
--- drivers/bluetooth/virtio_bt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/bluetooth/virtio_bt.c +6 -2
@@ -120,9 +120,13 @@ static int virtbt_setup_zephyr(struct hci_dev *hdev)if (IS_ERR (skb))return PTR_ERR (skb); -bt_dev_info (hdev,"%s" , (char *)(skb->data +1 )); +/* Bounded print: the backend controls skb->len. */ +if (skb->len >1 ) { +int len = skb->len -1 ; -hci_set_fw_info (hdev,"%s" , skb->data +1 ); +bt_dev_info (hdev,"%.*s" , len, (char *)(skb->data +1 )); +hci_set_fw_info (hdev,"%.*s" , len, skb->data +1 ); + }kfree_skb (skb);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1024/1518 Bluetooth: btintel: Fix diagnostics event detection
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit ad0e7ac7da9a9a0095570bd6add3e27f259de104 ]
For a diagnostics VSE, diagnostics_hdr[] sits at the start of the event payload, skb->data[2], but btintel_recv_event() wrongly guards its memcmp with @len, which is measured from skb->data[3] for the earlier INTEL_BOOTLOADER check.
Fix by using (@len + 1) instead, which ==
(skb->len - HCI_EVENT_HDR_SIZE) exactly.
--- drivers/bluetooth/btintel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bluetooth/btintel.c +1 -1
@@ -3757,7 +3757,7 @@ int btintel_recv_event(struct hci_dev *hdev, struct sk_buff *skb)/* Handle all diagnostics events separately. May still call * hci_recv_frame. */ -if (len >=sizeof (diagnostics_hdr) && +if (len +1 >=sizeof (diagnostics_hdr) &&memcmp (&skb->data[2 ], diagnostics_hdr,sizeof (diagnostics_hdr)) ==0 ) {return btintel_diagnostics (hdev, skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1025/1518 Bluetooth: hci_conn: fix the SCO setup context lifetime
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 42de40abe25db9211107af8896d0fd741f10648d ]
hci_setup_sync() queues a conn_handle_t with a NULL destroy callback, so the context is only freed if hci_enhanced_setup_sync() actually runs. An entry that is cancelled instead is leaked, as _hci_cmd_sync_cancel_entry() does not release entry->data when there is no destroy callback, and hci_cmd_sync_clear() cancels every pending entry when the controller is unregistered.
The context also stores a bare hci_conn pointer, so the connection can be freed while the work is queued. The dequeue in hci_conn_del() does not cover it either, as it matches on entry->data == conn and entry->data is the wrapper here. Same problem as commit 2f5d635ad590 ("Bluetooth:hci_sync: hold conn in hci_connect_acl/le_sync() callbacks").
Hold the connection and release both from a destroy callback. The submission failure path drops both, since hci_cmd_sync_submit() does not call the destroy callback when it fails to queue.
--- net/bluetooth/hci_conn.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
net/bluetooth/hci_conn.c +15 -5
@@ -286,8 +286,6 @@ static int hci_enhanced_setup_sync(struct hci_dev *hdev, void *data)struct hci_cp_enhanced_setup_sync_conn cp;const struct sco_param *param; -kfree (conn_handle); -if (!hci_conn_valid (hdev, conn))return -ECANCELED ;
@@ -456,6 +454,15 @@ static bool hci_setup_sync_conn(struct hci_conn *conn, __u16 handle)return true; } +static void hci_enhanced_setup_sync_destroy (struct hci_dev *hdev,void *data, +int err) +{ +struct conn_handle_t *conn_handle = data; + +hci_conn_put (conn_handle->conn); +kfree (conn_handle); +} +bool hci_setup_sync (struct hci_conn *conn,__u16 handle) {int result;
@@ -467,12 +474,15 @@ bool hci_setup_sync(struct hci_conn *conn, __u16 handle)if (!conn_handle)return false; - conn_handle->conn = conn; + conn_handle->conn =hci_conn_get (conn); conn_handle->handle = handle; result =hci_cmd_sync_queue (conn->hdev, hci_enhanced_setup_sync, - conn_handle,NULL ); -if (result <0 ) + conn_handle, + hci_enhanced_setup_sync_destroy); +if (result <0 ) { +hci_conn_put (conn);kfree (conn_handle); + }return result ==0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1026/1518 Bluetooth: hci_sync: free the advertising instance on the failure and cancel paths
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 120d8dc042e3d45073bb6e50ee7b058a0b182627 ]
adv_timeout_expire() hands a kmalloc()ed instance byte to hci_cmd_sync_queue() with a NULL destroy callback, and only adv_timeout_expire_sync() frees it. That leaks on two paths:
- the return value is not checked, and hci_cmd_sync_queue() does not take ownership when it fails (-ENETDOWN, -ENODEV, -ENOMEM);
- a cancelled entry is not released, as _hci_cmd_sync_cancel_entry() does not free entry->data when there is no destroy callback. hci_cmd_sync_clear() cancels every pending entry when the controller is unregistered.
Free the buffer from a destroy callback, and in the caller when the entry could not be queued at all.
--- net/bluetooth/hci_sync.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
net/bluetooth/hci_sync.c +9 -3
@@ -540,8 +540,6 @@ static int adv_timeout_expire_sync(struct hci_dev *hdev, void *data) {u8 instance = *(u8 *)data; -kfree (data); -hci_clear_adv_instance_sync (hdev,NULL , instance, false);if (list_empty (&hdev->adv_instances))
@@ -550,6 +548,12 @@ static int adv_timeout_expire_sync(struct hci_dev *hdev, void *data)return 0 ; } +static void adv_timeout_expire_destroy (struct hci_dev *hdev,void *data, +int err) +{ +kfree (data); +} +static void adv_timeout_expire (struct work_struct *work) {u8 *inst_ptr;
@@ -570,7 +574,9 @@ static void adv_timeout_expire(struct work_struct *work) goto unlock; *inst_ptr = hdev->cur_adv_instance; -hci_cmd_sync_queue (hdev, adv_timeout_expire_sync, inst_ptr,NULL ); +if (hci_cmd_sync_queue (hdev, adv_timeout_expire_sync, inst_ptr, + adv_timeout_expire_destroy) <0 ) +kfree (inst_ptr); unlock:hci_dev_unlock (hdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1027/1518 Bluetooth: MGMT: free the mesh send cancel command when it is cancelled
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 3c742feda8fcabf741a17bcf668b63c8f606f9c5 ]
mesh_send_cancel() queues the pending command with a NULL destroy callback, so it is only freed if send_cancel() runs. A cancelled entry is leaked, as _hci_cmd_sync_cancel_entry() does not release entry->data when there is no destroy callback, and hci_cmd_sync_clear() cancels every pending entry when the controller is unregistered. Nothing else reclaims it either: mgmt_pending_new() does not put the command on hdev->mgmt_pending.
The leak also pins the socket reference taken by mgmt_pending_new(), so the mgmt socket is never released.
Free the command from a destroy callback.
--- net/bluetooth/mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/bluetooth/mgmt.c +7 -2
@@ -2434,11 +2434,15 @@ static int send_cancel(struct hci_dev *hdev, void *data)mgmt_cmd_complete (cmd->sk, hdev->id,MGMT_OP_MESH_SEND_CANCEL ,0 ,NULL ,0 ); -mgmt_pending_free (cmd);return 0 ; } +static void send_cancel_destroy (struct hci_dev *hdev,void *data,int err) +{ +mgmt_pending_free (data); +} +static int mesh_send_cancel (struct sock *sk,struct hci_dev *hdev,void *data,u16 len) {
@@ -2459,7 +2463,8 @@ static int mesh_send_cancel(struct sock *sk, struct hci_dev *hdev,if (!cmd) err = -ENOMEM ;else - err =hci_cmd_sync_queue (hdev, send_cancel, cmd,NULL ); + err =hci_cmd_sync_queue (hdev, send_cancel, cmd, + send_cancel_destroy);if (err <0 ) { err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND_CANCEL,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1028/1518 Bluetooth: MGMT: free the HCI command when it is cancelled
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 414b365ecea6c30357adee6b8a7c5edc03a03575 ]
mgmt_hci_cmd_sync() queues the pending command with a NULL destroy callback, so it is only freed if send_hci_cmd_sync() runs. A cancelled entry is leaked, as _hci_cmd_sync_cancel_entry() does not release entry->data when there is no destroy callback, and hci_cmd_sync_clear() cancels every pending entry when the controller is unregistered. Nothing else reclaims it either: mgmt_pending_new() does not put the command on hdev->mgmt_pending.
The leak also pins the socket reference taken by mgmt_pending_new(), so the mgmt socket is never released.
Free the command from a destroy callback. The now-empty done label is replaced by a direct return.
--- net/bluetooth/mgmt.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
net/bluetooth/mgmt.c +8 -5
@@ -2650,7 +2650,7 @@ static int send_hci_cmd_sync(struct hci_dev *hdev, void *data)if (IS_ERR (skb)) {mgmt_cmd_status (cmd->sk, hdev->id,MGMT_OP_HCI_CMD_SYNC ,mgmt_status (PTR_ERR (skb))); - goto done; +return 0 ; } mgmt_cmd_complete(cmd->sk, hdev->id, MGMT_OP_HCI_CMD_SYNC, 0,
@@ -2658,12 +2658,14 @@ static int send_hci_cmd_sync(struct hci_dev *hdev, void *data)kfree_skb (skb); -done: -mgmt_pending_free (cmd); -return 0 ; } +static void send_hci_cmd_sync_destroy (struct hci_dev *hdev,void *data,int err) +{ +mgmt_pending_free (data); +} +static int mgmt_hci_cmd_sync (struct sock *sk,struct hci_dev *hdev,void *data,u16 len) {
@@ -2689,7 +2691,8 @@ static int mgmt_hci_cmd_sync(struct sock *sk, struct hci_dev *hdev,if (!cmd) err = -ENOMEM ;else - err =hci_cmd_sync_queue (hdev, send_hci_cmd_sync, cmd,NULL ); + err =hci_cmd_sync_queue (hdev, send_hci_cmd_sync, cmd, + send_hci_cmd_sync_destroy);if (err <0 ) { err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_HCI_CMD_SYNC,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1029/1518 mmc: sdio: add MediaTek MT7902 SDIO device ID
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Wang <[email protected]>
[ Upstream commit cde32a92d4562b686f730fc08d4d558ecc99d516 ]
Add SDIO device ID (0x790a) for MediaTek MT7902 to sdio_ids.h.
Stable-dep-of: b0c0b3794011 ("Bluetooth: btmtksdio: fix usage_count leak when autosuspend_delay is negative")
--- include/linux/mmc/sdio_ids.h | 1 + 1 file changed, 1 insertion(+)
include/linux/mmc/sdio_ids.h +1 -0
@@ -111,6 +111,7 @@#define SDIO_VENDOR_ID_MEDIATEK 0x037a#define SDIO_DEVICE_ID_MEDIATEK_MT7663 0x7663#define SDIO_DEVICE_ID_MEDIATEK_MT7668 0x7668 +#define SDIO_DEVICE_ID_MEDIATEK_MT7902 0x790a#define SDIO_DEVICE_ID_MEDIATEK_MT7961 0x7961#define SDIO_VENDOR_ID_MICROCHIP_WILC 0x0296
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1030/1518 Bluetooth: btmtk: add MT7902 MCU support
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Wang <[email protected]>
[ Upstream commit aab25984e55972e53f3e58821cb85a7101876056 ]
Add MT7902 device ID and firmware filename to enable MCU firmware loading.
Stable-dep-of: b0c0b3794011 ("Bluetooth: btmtksdio: fix usage_count leak when autosuspend_delay is negative")
--- drivers/bluetooth/btmtk.c | 1 + drivers/bluetooth/btmtk.h | 1 + 2 files changed, 2 insertions(+)
drivers/bluetooth/btmtk.c +1 -0
@@ -1335,6 +1335,7 @@ int btmtk_usb_setup(struct hci_dev *hdev)case 0x7922 :case 0x7925 :case 0x7961 : +case 0x7902 :btmtk_fw_get_filename (fw_bin_name,sizeof (fw_bin_name), dev_id, fw_version, fw_flavor);
drivers/bluetooth/btmtk.h +1 -0
@@ -5,6 +5,7 @@#define FIRMWARE_MT7663 "mediatek/mt7663pr2h.bin"#define FIRMWARE_MT7668 "mediatek/mt7668pr2h.bin"#define FIRMWARE_MT7922 "mediatek/BT_RAM_CODE_MT7922_1_1_hdr.bin" +#define FIRMWARE_MT7902 "mediatek/BT_RAM_CODE_MT7902_1_1_hdr.bin"#define FIRMWARE_MT7961 "mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin"#define FIRMWARE_MT7925 "mediatek/mt7925/BT_RAM_CODE_MT7925_1_1_hdr.bin"
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1031/1518 Bluetooth: btmtk: add MT7902 SDIO support
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Wang <[email protected]>
[ Upstream commit 7f2c3c49ba0d3fead557a8026a021ebe23f919d6 ]
Add MT7902 Bluetooth SDIO support by introducing chip data and registering the device ID.
Runtime PM is not yet supported by the driver, but normal operation is unaffected.
Stable-dep-of: b0c0b3794011 ("Bluetooth: btmtksdio: fix usage_count leak when autosuspend_delay is negative")
--- drivers/bluetooth/btmtksdio.c | 42 ++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 13 deletions(-)
drivers/bluetooth/btmtksdio.c +29 -13
@@ -42,24 +42,35 @@ struct btmtksdio_data {const char *fwname;u16 chipid;bool lp_mbox_supported; +bool pm_runtime_supported; };static const struct btmtksdio_data mt7663_data = { .fwname =FIRMWARE_MT7663 , .chipid =0x7663 , .lp_mbox_supported = false, + .pm_runtime_supported = true, };static const struct btmtksdio_data mt7668_data = { .fwname =FIRMWARE_MT7668 , .chipid =0x7668 , .lp_mbox_supported = false, + .pm_runtime_supported = true, };static const struct btmtksdio_data mt7921_data = { .fwname =FIRMWARE_MT7961 , .chipid =0x7921 , .lp_mbox_supported = true, + .pm_runtime_supported = true, +}; + +static const struct btmtksdio_data mt7902_data = { + .fwname =FIRMWARE_MT7902 , + .chipid =0x7902 , + .lp_mbox_supported = false, + .pm_runtime_supported = false, };static const struct sdio_device_id btmtksdio_table[] = {
@@ -69,6 +80,8 @@ static const struct sdio_device_id btmtksdio_table[] = { .driver_data = (kernel_ulong_t)&mt7668_data }, {SDIO_DEVICE(SDIO_VENDOR_ID_MEDIATEK, SDIO_DEVICE_ID_MEDIATEK_MT7961), .driver_data = (kernel_ulong_t)&mt7921_data }, + {SDIO_DEVICE(SDIO_VENDOR_ID_MEDIATEK, SDIO_DEVICE_ID_MEDIATEK_MT7902), + .driver_data = (kernel_ulong_t)&mt7902_data }, { }/* Terminating entry */ };MODULE_DEVICE_TABLE (sdio, btmtksdio_table);
@@ -1091,6 +1104,7 @@ static int btmtksdio_setup(struct hci_dev *hdev)set_bit (BTMTKSDIO_HW_TX_READY , &bdev->tx_state);switch (bdev->data->chipid) { +case 0x7902 :case 0x7921 :if (test_bit (BTMTKSDIO_HW_RESET_ACTIVE , &bdev->tx_state)) { err = btmtksdio_mtk_reg_read(hdev, MT7921_DLSTATUS,
@@ -1168,22 +1182,24 @@ static int btmtksdio_setup(struct hci_dev *hdev) delta =ktime_sub (rettime, calltime); duration = (unsigned long long )ktime_to_ns (delta) >>10 ; -pm_runtime_set_autosuspend_delay (bdev->dev, -MTKBTSDIO_AUTOSUSPEND_DELAY ); -pm_runtime_use_autosuspend (bdev->dev); +if (bdev->data->pm_runtime_supported) { +pm_runtime_set_autosuspend_delay (bdev->dev, +MTKBTSDIO_AUTOSUSPEND_DELAY ); +pm_runtime_use_autosuspend (bdev->dev); - err =pm_runtime_set_active (bdev->dev); -if (err <0 ) -return err; + err =pm_runtime_set_active (bdev->dev); +if (err <0 ) +return err; -/* Default forbid runtime auto suspend, that can be allowed by -* enable_autosuspend flag or the PM runtime entry under sysfs. -*/ -pm_runtime_forbid (bdev->dev); -pm_runtime_enable (bdev->dev); +/* Default forbid runtime auto suspend, that can be allowed by +* enable_autosuspend flag or the PM runtime entry under sysfs. +*/ +pm_runtime_forbid (bdev->dev); +pm_runtime_enable (bdev->dev); -if (enable_autosuspend) -pm_runtime_allow (bdev->dev); +if (enable_autosuspend) +pm_runtime_allow (bdev->dev); + }bt_dev_info (hdev,"Device setup in %llu usecs" , duration);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1032/1518 Bluetooth: btmtksdio: fix usage_count leak when autosuspend_delay is negative
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit b0c0b37940115383e7ea65d4d988f9b9e613ab92 ]
btmtksdio_setup() calls pm_runtime_use_autosuspend() when runtime PM is supported, but btmtksdio_remove() does not call the matching pm_runtime_dont_use_autosuspend() when removing the device.
If the autosuspend delay is set to a negative value while autosuspend is enabled, the runtime PM core increments usage_count to prevent runtime suspend. Without calling pm_runtime_dont_use_autosuspend() during driver teardown, this reference is not dropped and usage_count remains unbalanced.
Add the missing pm_runtime_dont_use_autosuspend() call in the remove path before restoring the runtime PM usage reference.
This issue was found by manual code inspection.
--- drivers/bluetooth/btmtksdio.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/bluetooth/btmtksdio.c +3 -0
@@ -1481,6 +1481,9 @@ static void btmtksdio_remove(struct sdio_func *func)if (test_bit (BTMTKSDIO_FUNC_ENABLED , &bdev->tx_state))btmtksdio_close (hdev); +if (bdev->data->pm_runtime_supported) +pm_runtime_dont_use_autosuspend (bdev->dev); +/* Be consistent the state in btmtksdio_probe */ pm_runtime_get_noresume (bdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1033/1518 Bluetooth: MSFT: validate evt_prefix_len against the response length
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Ahmet Memis <[email protected]>
[ Upstream commit 0079e1a944634ab2dc1c7cdec1144486d096407e ]
read_supported_features() only checks that the response covers the fixed part of struct msft_rp_read_supported_features, which is 11 bytes:
if (skb->len < sizeof(*rp)) {
bt_dev_err(hdev, "MSFT supported features length mismatch");
goto failed;
}evt_prefix[] is a flexible array member and rp->evt_prefix_len is an unvalidated u8 taken straight out of that response, so
msft->evt_prefix = kmemdup(rp->evt_prefix, rp->evt_prefix_len, GFP_KERNEL);
copies up to 255 bytes from a reply that may have carried none of them. What is copied is data the controller never sent, and it is then used to match incoming vendor events in msft_vendor_evt().
This is not an out-of-bounds access. An skb data allocation always has at least SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) bytes past the payload, which is more than the 255 byte maximum, so the read stays inside the allocation and KASAN does not report it. It is still a read of bytes the host was never given, with the length fully controlled by the controller.
Reject a response that is too short for the prefix it declares.
Verified with an emulated controller over /dev/vhci on a KASAN kernel, with vhci made to advertise an MSFT opcode the way btintel, btqca, btmtk and btrtl do unconditionally. A reply of exactly 11 bytes declaring evt_prefix_len = 255 reaches kmemdup and copies 255 bytes ("skb->len=11 evt_prefix_len=255", with the copied buffer dumped); since the reply ends at the fixed part, all 255 come from past the end of the response. No KASAN report is produced, as expected from the allocation slack described above. With this patch the response is rejected with "MSFT event prefix length mismatch" and msft->evt_prefix is left unset.
--- net/bluetooth/msft.c | 5 +++++ 1 file changed, 5 insertions(+)
net/bluetooth/msft.c +5 -0
@@ -165,6 +165,11 @@ static bool read_supported_features(struct hci_dev *hdev,if (rp->sub_opcode !=MSFT_OP_READ_SUPPORTED_FEATURES ) goto failed; +if (skb->len <sizeof (*rp) + rp->evt_prefix_len) { +bt_dev_err (hdev,"MSFT event prefix length mismatch" ); + goto failed; + } +if (rp->evt_prefix_len >0 ) { msft->evt_prefix =kmemdup (rp->evt_prefix, rp->evt_prefix_len,GFP_KERNEL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1034/1518 bpf, cgroup: Fix storage null-ptr-deref after replacing prog
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pu Lehui <[email protected]>
[ Upstream commit 3f562c537e9ecf4bc5e206cfffc2cc047f1b7e94 ]
Syzkaller reported a storage null-ptr-deref issue after replacing prog. This occurs in the following scenario:
1. prog A, an empty prog, is attached to a cgrp.
2. prog B uses BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE and calls the bpf_get_local_storage helper.
3. link_update is called to replace prog A with prog B.
The reason is that __cgroup_bpf_replace fails to alloc and assign the required cgrp storage for the incoming replacement prog. Consequently, the new prog inherits an uninit storage, leading to null-ptr-deref panic when kick the new prog.
Fix this by rejecting a link update if new_prog's cgroup storage is incompatible with link->prog.
--- kernel/bpf/cgroup.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
kernel/bpf/cgroup.c +17 -0
@@ -1026,6 +1026,20 @@ static void replace_effective_prog(struct cgroup *cgrp, } } +static bool cgroup_bpf_storages_compatible (struct bpf_prog *old_prog, +struct bpf_prog *new_prog) +{ +enum bpf_cgroup_storage_type stype; + +for_each_cgroup_storage_type (stype) { +if (old_prog->aux->cgroup_storage[stype] != + new_prog->aux->cgroup_storage[stype]) +return false; + } + +return true; +} +/** * __cgroup_bpf_replace() - Replace link's program and propagate the change * to descendants
@@ -1064,6 +1078,9 @@ static int __cgroup_bpf_replace(struct cgroup *cgrp,if (!found)return -ENOENT ; +if (!cgroup_bpf_storages_compatible (link->link.prog, new_prog)) +return -EINVAL ; + cgrp->bpf.revisions[atype] +=1 ; old_prog =xchg (&link->link.prog, new_prog);replace_effective_prog (cgrp, atype, pl);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1035/1518 iio: light: opt4060: Fix pointer type passed to div_u64_rem()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vidhu Sarwal <[email protected]>
[ Upstream commit 0ba0ed0d42ebd3144f0050c48374817f5f3f07d6 ]
div_u64_rem() expects a u32 * for the remainder, but opt4060_read_ev_period() passes val2, which is declared as an int *. While this has no functional impact, it triggers a pointer type mismatch.
There is no behavioural change because int and u32 have the same size and representation on all supported architectures, and the remainder is always less than MICRO, so it fits within the positive range of int.
Use a local u32 to receive the remainder before assigning it to *val2.
--- drivers/iio/light/opt4060.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/light/opt4060.c +3 -1
@@ -731,6 +731,7 @@ static ssize_t opt4060_read_ev_period(struct opt4060_chip *chip, int *val, {int ret, pers, fault_count, int_time;u64 uval; +u32 rem; int_time = opt4060_int_time_reg[chip->int_time][0 ];
@@ -756,7 +757,8 @@ static ssize_t opt4060_read_ev_period(struct opt4060_chip *chip, int *val, } uval =mul_u32_u32 (int_time, pers); - *val =div_u64_rem (uval,MICRO , val2); + *val =div_u64_rem (uval,MICRO , &rem); + *val2 = rem;return IIO_VAL_INT_PLUS_MICRO ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1036/1518 iio: light: gp2ap002: Fix unbalanced runtime PM on repeated event writes
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil Gautam <[email protected]>
[ Upstream commit 579c049b4cb6fc72ce2c505fc5334540be0efcd3 ]
The IIO core does not filter duplicate writes to the event enable attribute, so writing the same value twice invokes write_event_config() twice. Enabling twice leaks a runtime PM reference, preventing the device from ever suspending again; disabling twice underflows the usage count and triggers a "Runtime PM usage count underflow" warning.
Bail out early when the requested state matches the current state. While at it, switch to pm_runtime_resume_and_get() so a failed resume is propagated to userspace instead of silently marking the event enabled.
--- drivers/iio/light/gp2ap002.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/iio/light/gp2ap002.c +10 -3
@@ -342,6 +342,10 @@ static int gp2ap002_write_event_config(struct iio_dev *indio_dev, bool state) {struct gp2ap002 *gp2ap002 =iio_priv (indio_dev); +int ret; + +if (state == gp2ap002->enabled) +return 0 ;if (state) {/*
@@ -349,13 +353,16 @@ static int gp2ap002_write_event_config(struct iio_dev *indio_dev,* already) and reintialize the sensor by using runtime_pm * callbacks. */ -pm_runtime_get_sync (gp2ap002->dev); - gp2ap002->enabled = true; + ret =pm_runtime_resume_and_get (gp2ap002->dev); +if (ret) +return ret; + }else {pm_runtime_put_autosuspend (gp2ap002->dev); - gp2ap002->enabled = false; } + gp2ap002->enabled = state; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1037/1518 iio: light: gp2ap002: re-enable irq if runtime suspend fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil Gautam <[email protected]>
[ Upstream commit 5d89e7cbac40057f5241a0832a86ce0fe97e4818 ]
gp2ap002_runtime_suspend() disables the irq before writing OPMOD. If the write fails, the callback returns an error with the irq still disabled while the PM core marks the device active again.
re-enable the irq before returning the error so the irq state matches the active state the PM core restores.
--- drivers/iio/light/gp2ap002.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/light/gp2ap002.c +1 -0
@@ -649,6 +649,7 @@ static int gp2ap002_runtime_suspend(struct device *dev)/* Disable chip and IRQ, everything off */ ret =regmap_write (gp2ap002->map,GP2AP002_OPMOD ,0x00 );if (ret) { +enable_irq (gp2ap002->irq);dev_err (gp2ap002->dev,"error setting up operation mode\n" );return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1038/1518 net/sched: cls_api: fix teardown of an adopted proto on insert-race loss
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit d4e359b3608a0e184bbe8d61a5c3b50d0831c44a ]
In tc_new_tfilter() the create branch sets tp_created = 1 before calling tcf_chain_tp_insert_unique(). When the caller loses the race (another request inserted a proto at the same chain/prio first), insert_unique() destroys the caller's own tp_new and returns the winner's proto with an extra reference. tp_created was never cleared, so the loser's errout path treated the winner's live proto as its own and called tcf_chain_tp_delete_empty() on it, silently unlinking an active classifier that the winning request already advertised via RTM_NEWTFILTER.
Track the outcome of the insert step in a single tri-state variable so each errout path reacts correctly:
- TP_NOT_CREATED: no proto created; pursue the old path.
- TP_CREATED: proto inserted successfully; same code path as before.
- TP_NOT_OWNED: New - lost the insert race; tp is another request's proto (chain ref already released by tp_new's destroy)
Both errout reactions are single expressions derived from the state.
This fix is motivated by the Sashiko's automated review of Patch (net/sched: cls_api: Always acquire rtnl_lock when destroying locked classifiers) [1][2]. The review identified the silent-unlink behaviour of an adopted proto's teardown when a request loses the tcf_chain_tp_insert_unique() race.
[1] https://sashiko.dev/#/patchset/20260801125632.360365-1-jhs%40mojatatu.com
[2] https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260801125632.360365-1-jhs%40mojatatu.com
--- net/sched/cls_api.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
net/sched/cls_api.c +13 -5
@@ -2248,6 +2248,12 @@ static bool is_ingress_or_clsact(struct tcf_block *block, struct Qdisc *q)return tcf_block_shared (block) || (q && !!(q->flags &TCQ_F_INGRESS )); } +enum tcf_tp_insert_state { +TP_NOT_CREATED =0 ,/* did not create and insert a new tp */ +TP_CREATED ,/* created and inserted a new tp */ +TP_NOT_OWNED ,/* created a proto but failed to insert */ +}; +static int tc_new_tfilter (struct sk_buff *skb,struct nlmsghdr *n,struct netlink_ext_ack *extack) {
@@ -2268,12 +2274,12 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n,unsigned long cl;void *fh;int err; -int tp_created; +enum tcf_tp_insert_state tp_state;bool rtnl_held = false;u32 flags; replay: - tp_created =0 ; + tp_state =TP_NOT_CREATED ; err =nlmsg_parse_deprecated (n,sizeof (*t), tca,TCA_MAX , rtm_tca_policy, extack);
@@ -2395,13 +2401,15 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, goto errout_tp; } - tp_created =1 ; + tp_state =TP_CREATED ; tp =tcf_chain_tp_insert_unique (chain, tp_new, protocol, prio, rtnl_held);if (IS_ERR (tp)) { err =PTR_ERR (tp); goto errout_tp; } +if (tp != tp_new) + tp_state =TP_NOT_OWNED ; }else {mutex_unlock (&chain->filter_chain_lock); }
@@ -2455,13 +2463,13 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, } errout: -if (err && tp_created) +if (err && tp_state ==TP_CREATED )tcf_chain_tp_delete_empty (chain, tp, rtnl_held,NULL ); errout_tp:if (chain) {if (tp && !IS_ERR (tp))tcf_proto_put (tp, rtnl_held,NULL ); -if (!tp_created) +if (tp_state ==TP_NOT_CREATED )tcf_chain_put (chain); }tcf_block_release (q, block, rtnl_held);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1039/1518 riscv: cpufeature: Clarify ISA spec version for canonical order
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guodong Xu <[email protected]>
[ Upstream commit fdef048705daa3d4ed1fa212ee071bcbdac02d80 ]
Specify that chapter 27 refers to version 20191213 of the RISC-V ISA Unprivileged Architecture. The chapter numbering differs across specification versions - for example, in version 20250508, the ISA Extension Naming Conventions is chapter 36, not chapter 27.
Historical versions of the RISC-V specification can be found via Link [1].
--- arch/riscv/kernel/cpufeature.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/riscv/kernel/cpufeature.c +2 -1
@@ -409,7 +409,8 @@ static const unsigned int riscv_c_exts[] = {/* * The canonical order of ISA extension names in the ISA string is defined in -* chapter 27 of the unprivileged specification. +* Chapter 27 of the RISC-V Instruction Set Manual Volume I Unprivileged ISA +* (Document Version 20191213). * * Ordinarily, for in-kernel data structures, this order is unimportant but * isa_ext_arr defines the order of the ISA string in /proc/cpuinfo.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1040/1518 bpf: Factor out stack_map build ID helpers
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ihor Solodrai <[email protected]>
[ Upstream commit fc99547a8bda22a6a489284641385d8dcfb3ecd8 ]
Factor out helpers from stack_map_get_build_id_offset() in preparation for adding a sleepable build ID resolution path:stack_map_build_id_set_ip(), stack_map_build_id_offset(), and stack_map_build_id_set_valid().
While here, refactor stack_map_get_build_id_offset():
* use continue-driven control flow in the main loop and remove build_id_valid label
* update prev_vma and prev_build_id on the fall-back-to-IP branch so the cache reflects the actual VMA seen on the previous IP [1]
* guard fetch_build_id() with vma_is_anonymous() [2] to skip parse attempts that would otherwise fail the ELF magic check
[1] https://lore.kernel.org/bpf/CAEf4Bzac9uWWqBvzH0iFzKvJcq3vxscZ3pKm0sUHmN-F-z9wVQ@mail.gmail.com/
[2] https://lore.kernel.org/bpf/226398c1ff3f2b686c0aeb010408d85fb15df13f9ff60a045bee31e79b9e41e9@mail.kernel.org/
Stable-dep-of: fa9dcacdcdf4 ("bpf: Fix mmap_lock leak in irq_work path")
--- kernel/bpf/stackmap.c | 57 ++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 17 deletions(-)
kernel/bpf/stackmap.c +40 -17
@@ -152,6 +152,28 @@ static int fetch_build_id(struct vm_area_struct *vma, unsigned char *build_id, b : build_id_parse_nofault(vma, build_id, NULL); } +static inline void stack_map_build_id_set_ip (struct bpf_stack_build_id *id) +{ + id->status =BPF_STACK_BUILD_ID_IP ; +memset (id->build_id,0 ,BUILD_ID_SIZE_MAX ); +} + +static inline u64 stack_map_build_id_offset (unsigned long vm_pgoff, +unsigned long vm_start,u64 ip) +{ +return (vm_pgoff <<PAGE_SHIFT ) + ip - vm_start; +} + +static inline void stack_map_build_id_set_valid (struct bpf_stack_build_id *id, +u64 offset, +const unsigned char *build_id) +{ + id->status =BPF_STACK_BUILD_ID_VALID ; + id->offset = offset; +if (id->build_id != build_id) +memcpy (id->build_id, build_id,BUILD_ID_SIZE_MAX ); +} +/* * Expects all id_offs[i].ip values to be set to correct initial IPs. * They will be subsequently:
@@ -165,44 +187,45 @@ static int fetch_build_id(struct vm_area_struct *vma, unsigned char *build_id, bstatic void stack_map_get_build_id_offset (struct bpf_stack_build_id *id_offs,u32 trace_nr,bool user,bool may_fault) { -int i;struct mmap_unlock_irq_work *work =NULL ;bool irq_work_busy =bpf_mmap_unlock_get_irq_work (&work); +bool has_user_ctx = user && current && current->mm;struct vm_area_struct *vma, *prev_vma =NULL ; -const char *prev_build_id; +const unsigned char *prev_build_id =NULL ; +int i;/* If the irq_work is in use, fall back to report ips. Same * fallback is used for kernel stack (!user) on a stackmap with * build_id. */ -if (!user || !current || !current->mm || irq_work_busy || - !mmap_read_trylock (current->mm)) { +if (!has_user_ctx || irq_work_busy || !mmap_read_trylock (current->mm)) {/* cannot access current->mm, fall back to ips */ -for (i =0 ; i < trace_nr; i++) { - id_offs[i].status =BPF_STACK_BUILD_ID_IP ; -memset (id_offs[i].build_id,0 ,BUILD_ID_SIZE_MAX ); - } +for (i =0 ; i < trace_nr; i++) +stack_map_build_id_set_ip (&id_offs[i]);return ; }for (i =0 ; i < trace_nr; i++) {u64 ip =READ_ONCE (id_offs[i].ip); +u64 offset; -if (range_in_vma (prev_vma, ip, ip)) { +if (prev_build_id &&range_in_vma (prev_vma, ip, ip)) { vma = prev_vma; -memcpy (id_offs[i].build_id, prev_build_id,BUILD_ID_SIZE_MAX ); - goto build_id_valid; + offset =stack_map_build_id_offset (vma->vm_pgoff, vma->vm_start, ip); +stack_map_build_id_set_valid (&id_offs[i], offset, prev_build_id); +continue ; } vma =find_vma (current->mm, ip); -if (!vma ||fetch_build_id (vma, id_offs[i].build_id, may_fault)) { +if (!vma ||vma_is_anonymous (vma) || +fetch_build_id (vma, id_offs[i].build_id, may_fault)) {/* per entry fall back to ips */ - id_offs[i].status =BPF_STACK_BUILD_ID_IP ; -memset (id_offs[i].build_id,0 ,BUILD_ID_SIZE_MAX ); +stack_map_build_id_set_ip (&id_offs[i]); + prev_vma = vma; + prev_build_id =NULL ;continue ; } -build_id_valid: - id_offs[i].offset = (vma->vm_pgoff <<PAGE_SHIFT ) + ip - vma->vm_start; - id_offs[i].status =BPF_STACK_BUILD_ID_VALID ; + offset =stack_map_build_id_offset (vma->vm_pgoff, vma->vm_start, ip); +stack_map_build_id_set_valid (&id_offs[i], offset, id_offs[i].build_id); prev_vma = vma; prev_build_id = id_offs[i].build_id; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1041/1518 bpf: Avoid faultable build ID reads under mm locks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ihor Solodrai <[email protected]>
[ Upstream commit fad3021faf7b0b64e9daea41c5662b65c8ad7379 ]
Sleepable build ID parsing can block in __kernel_read() [1], so the stackmap sleepable path must not call it while holding mmap_lock or a per-VMA read lock.
The issue and the fix are conceptually similar to a recent procfs patch [2]. A similar VMA locking pattern has already been used in PROCMAP_QUERY [3].
Resolve each covered VMA with a stable read-side reference, preferring lock_vma_under_rcu() and falling back to mmap_read_trylock() only long enough to acquire the VMA read lock. Take a reference to the backing file, drop the VMA lock, and then parse the build ID through (sleepable) build_id_parse_file().
We have to use mmap_read_trylock() (and give up on failure) in this context because taking mmap_read_lock() is generally unsafe on code paths reachable from BPF programs [4], and may lead to deadlocks.
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/bpf/[email protected]/
Stable-dep-of: fa9dcacdcdf4 ("bpf: Fix mmap_lock leak in irq_work path")
--- kernel/bpf/stackmap.c | 109 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+)
kernel/bpf/stackmap.c +109 -0
@@ -9,6 +9,7 @@#include <linux/perf_event.h> #include <linux/btf_ids.h> #include <linux/buildid.h> +#include <linux/mmap_lock.h> #include "percpu_freelist.h" #include "mmap_unlock_work.h"
@@ -174,6 +175,109 @@ static inline void stack_map_build_id_set_valid(struct bpf_stack_build_id *id,memcpy (id->build_id, build_id,BUILD_ID_SIZE_MAX ); } +struct stack_map_vma_lock { +struct vm_area_struct *vma; +struct mm_struct *mm; +}; + +/* +* Acquire a stable read-side reference on the VMA covering @ip. +* +* With CONFIG_PER_VMA_LOCK=y this returns a VMA with its per-VMA read +* lock held and mmap_lock dropped, so the caller may sleep. +* +* With CONFIG_PER_VMA_LOCK=n it returns a VMA with mmap_lock still +* held; the caller must snapshot any fields it needs and pin vm_file +* with get_file() before stack_map_unlock_vma() drops mmap_lock, as +* the VMA may be split, merged, or freed after that. +* +* Returns NULL on failure, in which case no lock is held. +*/ +static struct vm_area_struct * +stack_map_lock_vma (struct stack_map_vma_lock *lock,unsigned long ip) +{ +struct mm_struct *mm = lock->mm; +struct vm_area_struct *vma; + +/* noop under !CONFIG_PER_VMA_LOCK */ + vma =lock_vma_under_rcu (mm, ip); +if (vma) { + lock->vma = vma; +return vma; + } + +/* +* Taking mmap_read_lock() is unsafe here, because the caller BPF +* program might already hold it, causing a deadlock. +*/ +if (!mmap_read_trylock (mm)) +return NULL ; + + vma =vma_lookup (mm, ip); +if (!vma) { +mmap_read_unlock (mm); +return NULL ; + } + +#ifdef CONFIG_PER_VMA_LOCK +if (!vma_start_read_locked (vma)) { +mmap_read_unlock (mm); +return NULL ; + } +mmap_read_unlock (mm); +#endif + + lock->vma = vma; +return vma; +} + +static void stack_map_unlock_vma (struct stack_map_vma_lock *lock) +{ +#ifdef CONFIG_PER_VMA_LOCK +vma_end_read (lock->vma); +#else +mmap_read_unlock (lock->mm); +#endif + lock->vma =NULL ; +} + +static void stack_map_get_build_id_offset_sleepable (struct bpf_stack_build_id *id_offs, +u32 trace_nr) +{ +struct mm_struct *mm = current->mm; +struct stack_map_vma_lock lock = { .mm = mm }; +struct vm_area_struct *vma; +struct file *file; +u64 offset; +u64 ip; + +for (u32 i =0 ; i < trace_nr; i++) { + ip =READ_ONCE (id_offs[i].ip); + + vma =stack_map_lock_vma (&lock, ip); +if (!vma) { +stack_map_build_id_set_ip (&id_offs[i]); +continue ; + } +if (vma_is_anonymous (vma) || !vma->vm_file) { +stack_map_build_id_set_ip (&id_offs[i]); +stack_map_unlock_vma (&lock); +continue ; + } + + file =get_file (vma->vm_file); + offset =stack_map_build_id_offset (vma->vm_pgoff, vma->vm_start, ip); +stack_map_unlock_vma (&lock); + +/* build_id_parse_file() may block on filesystem reads */ +if (build_id_parse_file (file, id_offs[i].build_id,NULL )) +stack_map_build_id_set_ip (&id_offs[i]); +else +stack_map_build_id_set_valid (&id_offs[i], offset, id_offs[i].build_id); +fput (file); + } +} +/* * Expects all id_offs[i].ip values to be set to correct initial IPs. * They will be subsequently:
@@ -194,6 +298,11 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,const unsigned char *prev_build_id =NULL ;int i; +if (may_fault && has_user_ctx) { +stack_map_get_build_id_offset_sleepable (id_offs, trace_nr); +return ; + } +/* If the irq_work is in use, fall back to report ips. Same * fallback is used for kernel stack (!user) on a stackmap with * build_id.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1042/1518 bpf: Fix mmap_lock leak in irq_work path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanghyun Park <[email protected]>
[ Upstream commit fa9dcacdcdf487f0ffef64bf67622f1caed509f1 ]
stack_map_get_build_id_offset() introduced a per-CPU irq_work to defer mmap_read_unlock() from NMI context, and bpf_find_vma() later reused the same mmap_unlock_work. Both callers only check whether the work is busy before taking mmap_lock, so a nested caller can reuse the slot before the first caller queues it. Two read locks may then be acquired while only one deferred unlock runs, leaking a read lock and blocking exit_mmap().
Reserve the per-CPU slot before mmap_read_trylock(). Use the same wrapper in stackmap and bpf_find_vma() so both callers release the reservation on trylock failure. Keep rejecting the slot while the irq_work remains busy. Release it after the irq_work callback unlocks the mm.
--- kernel/bpf/mmap_unlock_work.h | 51 ++++++++++++++++++++--------------- kernel/bpf/stackmap.c | 28 +++++++++++-------- kernel/bpf/task_iter.c | 14 +++++++--- 3 files changed, 56 insertions(+), 37 deletions(-)
kernel/bpf/mmap_unlock_work.h +29 -22
@@ -4,12 +4,15 @@#ifndef __MMAP_UNLOCK_WORK_H__#define __MMAP_UNLOCK_WORK_H__ +#include <linux/atomic.h> +#include <linux/err.h> #include <linux/irq_work.h> /* irq_work to run mmap_read_unlock() in irq_work */ struct mmap_unlock_irq_work {struct irq_work irq_work;struct mm_struct *mm; +atomic_t active; }; DECLARE_PER_CPU(struct mmap_unlock_irq_work, mmap_unlock_work);
@@ -18,32 +21,36 @@ DECLARE_PER_CPU(struct mmap_unlock_irq_work, mmap_unlock_work);* We cannot do mmap_read_unlock() when the irq is disabled, because of * risk to deadlock with rq_lock. To look up vma when the irqs are * disabled, we need to run mmap_read_unlock() in irq_work. We use a -* percpu variable to do the irq_work. If the irq_work is already used -* by another lookup, we fall over. +* percpu variable to do the irq_work. The active flag reserves the slot +* before mmap_read_trylock() and until the irq_work callback consumes mm. */ -static inline bool bpf_mmap_unlock_get_irq_work (struct mmap_unlock_irq_work **work_ptr) +static inline struct mmap_unlock_irq_work *bpf_mmap_unlock_guard_get (void ) { -struct mmap_unlock_irq_work *work =NULL ; -bool irq_work_busy = false; +struct mmap_unlock_irq_work *work; -if (irqs_disabled ()) { -if (!IS_ENABLED (CONFIG_PREEMPT_RT )) { - work =this_cpu_ptr (&mmap_unlock_work); -if (irq_work_is_busy (&work->irq_work)) { -/* cannot queue more up_read, fallback */ - irq_work_busy = true; - } - }else { -/* -* PREEMPT_RT does not allow to trylock mmap sem in -* interrupt disabled context. Force the fallback code. -*/ - irq_work_busy = true; - } - } +if (!irqs_disabled ()) +return NULL ; + +/* +* PREEMPT_RT does not allow to trylock mmap sem in interrupt +* disabled context. Force the fallback code. +*/ +if (IS_ENABLED (CONFIG_PREEMPT_RT )) +return ERR_PTR (-EBUSY ); + + work =this_cpu_ptr (&mmap_unlock_work); +if (irq_work_is_busy (&work->irq_work) || +atomic_cmpxchg_acquire (&work->active,0 ,1 )) +return ERR_PTR (-EBUSY ); - *work_ptr = work; -return irq_work_busy; +return work; +} + +static inline void +bpf_mmap_unlock_guard_put (struct mmap_unlock_irq_work *work) +{ +if (work) +atomic_set_release (&work->active,0 ); }static inline void bpf_mmap_unlock_mm (struct mmap_unlock_irq_work *work,struct mm_struct *mm)
kernel/bpf/stackmap.c +17 -11
@@ -291,8 +291,7 @@ static void stack_map_get_build_id_offset_sleepable(struct bpf_stack_build_id *istatic void stack_map_get_build_id_offset (struct bpf_stack_build_id *id_offs,u32 trace_nr,bool user,bool may_fault) { -struct mmap_unlock_irq_work *work =NULL ; -bool irq_work_busy =bpf_mmap_unlock_get_irq_work (&work); +struct mmap_unlock_irq_work *work;bool has_user_ctx = user && current && current->mm;struct vm_area_struct *vma, *prev_vma =NULL ;const unsigned char *prev_build_id =NULL ;
@@ -303,15 +302,16 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,return ; } -/* If the irq_work is in use, fall back to report ips. Same -* fallback is used for kernel stack (!user) on a stackmap with -* build_id. -*/ -if (!has_user_ctx || irq_work_busy || !mmap_read_trylock (current->mm)) { -/* cannot access current->mm, fall back to ips */ -for (i =0 ; i < trace_nr; i++) -stack_map_build_id_set_ip (&id_offs[i]); -return ; +if (!has_user_ctx) + goto fallback; + + work =bpf_mmap_unlock_guard_get (); +if (IS_ERR (work)) + goto fallback; + +if (!mmap_read_trylock (current->mm)) { +bpf_mmap_unlock_guard_put (work); + goto fallback; }for (i =0 ; i < trace_nr; i++) {
@@ -339,6 +339,12 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs, prev_build_id = id_offs[i].build_id; }bpf_mmap_unlock_mm (work, current->mm); +return ; + +fallback: +/* cannot access current->mm, fall back to ips */ +for (i =0 ; i < trace_nr; i++) +stack_map_build_id_set_ip (&id_offs[i]); } static struct perf_callchain_entry *
kernel/bpf/task_iter.c +10 -4
@@ -753,9 +753,8 @@ static struct bpf_iter_reg task_vma_reg_info = { BPF_CALL_5(bpf_find_vma, struct task_struct *, task, u64, start, bpf_callback_t, callback_fn, void *, callback_ctx, u64, flags) { -struct mmap_unlock_irq_work *work =NULL ; +struct mmap_unlock_irq_work *work;struct vm_area_struct *vma; -bool irq_work_busy = false;bool __maybe_unused mmput_needed = false;struct mm_struct *mm;int ret = -ENOENT ;
@@ -792,9 +791,14 @@ BPF_CALL_5(bpf_find_vma, struct task_struct *, task, u64, start,if (!mm)return -ENOENT ; - irq_work_busy =bpf_mmap_unlock_get_irq_work (&work); + work =bpf_mmap_unlock_guard_get (); +if (IS_ERR (work)) { + ret =PTR_ERR (work); + goto out; + } -if (irq_work_busy || !mmap_read_trylock (mm)) { +if (!mmap_read_trylock (mm)) { +bpf_mmap_unlock_guard_put (work); ret = -EBUSY ; goto out; }
@@ -1191,6 +1195,8 @@ static void do_mmap_read_unlock(struct irq_work *entry) work = container_of(entry, struct mmap_unlock_irq_work, irq_work);mmap_read_unlock_non_owner (work->mm); + work->mm =NULL ; +bpf_mmap_unlock_guard_put (work); }static int __init task_iter_init (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1043/1518 i3c: renesas: Return immediately if there is no transfer
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit 33b5ecc5a16e270c8e0dd9835e7d9d2522f64129 ]
There is no need to allocate a transfer structure when i2c_nxfers is zero. Return immediately instead of unnecessarily allocating memory.
Stable-dep-of: b6e56fd8c8a8 ("i3c: renesas: Don't register devices when ENTDAA times out")
--- drivers/i3c/master/renesas-i3c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i3c/master/renesas-i3c.c +3 -3
@@ -940,13 +940,13 @@ static int renesas_i3c_i2c_xfers(struct i2c_dev_desc *dev,u8 start_bit =CNDCTL_STCND ;int i; +if (!i2c_nxfers) +return 0 ; + struct renesas_i3c_xfer *xfer __free(kfree) = renesas_i3c_alloc_xfer(i3c, 1);if (!xfer)return -ENOMEM ; -if (!i2c_nxfers) -return 0 ; -renesas_i3c_bus_enable (m, false);init_completion (&xfer->comp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1044/1518 i3c: renesas: Follow a unified pattern for transfer and command initialization
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit 234a26e6febcf789d9f6779d67c01e3d0c1df5bc ]
Follow a unified pattern for transfer and command initialization across the driver. This keeps the code cleaner and easier to follow. Also, in some cases the I3C device was enabled before the transfer data structure was even allocated.
Stable-dep-of: b6e56fd8c8a8 ("i3c: renesas: Don't register devices when ENTDAA times out")
--- drivers/i3c/master/renesas-i3c.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/i3c/master/renesas-i3c.c +11 -11
@@ -647,6 +647,10 @@ static int renesas_i3c_daa(struct i3c_master_controller *m)if (!xfer)return -ENOMEM ; +init_completion (&xfer->comp); + cmd = xfer->cmds; + cmd->rx_count =0 ; +/* Enable I3C bus. */ renesas_i3c_bus_enable (m, true);
@@ -668,10 +672,6 @@ static int renesas_i3c_daa(struct i3c_master_controller *m)renesas_writel (i3c->regs,DATBAS (pos),datbas_dvdyad_with_parity (ret)); } -init_completion (&xfer->comp); - cmd = xfer->cmds; - cmd->rx_count =0 ; - ret =renesas_i3c_get_free_pos (i3c);if (ret <0 )return ret;
@@ -760,13 +760,13 @@ static int renesas_i3c_send_ccc_cmd(struct i3c_master_controller *m,if (!xfer)return -ENOMEM ; -renesas_i3c_bus_enable (m, true); -init_completion (&xfer->comp); cmd = xfer->cmds; cmd->rnw = ccc->rnw; cmd->cmd0 =0 ; +renesas_i3c_bus_enable (m, true); +/* Calculate the command descriptor. */ switch (ccc->id) {case I3C_CCC_SETDASA :
@@ -818,15 +818,15 @@ static int renesas_i3c_priv_xfers(struct i3c_dev_desc *dev, struct i3c_priv_xferstruct renesas_i3c_i2c_dev_data *data =i3c_dev_get_master_data (dev);int i; -/* Enable I3C bus. */ -renesas_i3c_bus_enable (m, true); - struct renesas_i3c_xfer *xfer __free(kfree) = renesas_i3c_alloc_xfer(i3c, 1);if (!xfer)return -ENOMEM ;init_completion (&xfer->comp); +/* Enable I3C bus. */ +renesas_i3c_bus_enable (m, true); +for (i =0 ; i < i3c_nxfers; i++) {struct renesas_i3c_cmd *cmd = xfer->cmds;
@@ -947,12 +947,12 @@ static int renesas_i3c_i2c_xfers(struct i2c_dev_desc *dev,if (!xfer)return -ENOMEM ; -renesas_i3c_bus_enable (m, false); -init_completion (&xfer->comp); xfer->is_i2c_xfer = true; cmd = xfer->cmds; +renesas_i3c_bus_enable (m, false); +if (!(renesas_readl (i3c->regs,BCST ) &BCST_BFREF )) { cmd->err = -EBUSY ;return cmd->err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1045/1518 i3c: renesas: Dont register devices when ENTDAA times out
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tommaso Merciai <[email protected]>
[ Upstream commit b6e56fd8c8a8ac7992868a28702192372ab04015 ]
renesas_i3c_daa() derives the number of newly assigned dynamic addresses from cmd->rx_count, which the response ISR sets to the number of address slots ENTDAA left unassigned. It starts out as zero, which already means "every address was assigned", so a timed out transfer leaves that value in place and it gets used as a result.
On a bus with no target connected the ENTDAA times out and the driver registers RENESAS_I3C_MAX_DEVS devices that are not there, each costing the core two seconds on a GETPID that can only time out:
i3c i3c-0: Failed to add I3C device at address 9, error -110
...
i3c i3c-0: Failed to add I3C device at address 16, error -110
Start from maxdevs instead: no address is assigned before ENTDAA runs, and the existing rx_count >= maxdevs check then reports an empty bus.
--- drivers/i3c/master/renesas-i3c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i3c/master/renesas-i3c.c +1 -1
@@ -649,7 +649,7 @@ static int renesas_i3c_daa(struct i3c_master_controller *m)init_completion (&xfer->comp); cmd = xfer->cmds; - cmd->rx_count =0 ; + cmd->rx_count = i3c->maxdevs;/* Enable I3C bus. */ renesas_i3c_bus_enable (m, true);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1046/1518 arm64: dts: turris-mox: fix usb3 phys
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomáš Macholda <[email protected]>
[ Upstream commit 0c2a8eed95160e41b367a1fa605a2c1b24a9639a ]
After commit 00e6d608fe80b0f6 ("arm64: dts: marvell: armada-37xx: swap PHYs' order in USB3 controller node") swapped USB3 PHY order, USB initialization breaks on Turris MOX.
This regression was exposed by commit 91ddf6f722084383 ("phy: marvell:
mvebu-a3700-utmi: fix incorrect USB2_PHY_CTRL register access") which made USB2 devices not work at all.
Fix the issue by explicitly adding all USB3 PHYs and PHY names to Turris MOX device-tree.
--- arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts +2 -1
@@ -290,7 +290,8 @@ connector { &usb3 { status = "okay"; - phys = <&comphy2 0>; + phys = <&usb2_utmi_otg_phy>, <&comphy2 0>; + phy-names = "usb2-phy", "usb3-phy"; }; &mdio {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1047/1518 ARM: dts: helios4: add vcc-supply to EEPROM
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit ef65cf08bd1aa723de2854d02fb8eb8cca273c90 ]
The at24 driver requests a 'vcc' supply for the EEPROM, producing 'supply vcc not found, using dummy regulator' at boot when the property is missing.
The EEPROM sits on the Helios 4 and is powered by the same always-on 3.3V rail used by other on-board I2C devices. Add vcc-supply = <®_3p3v> to silence the warning.
--- arch/arm/boot/dts/marvell/armada-388-helios4.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/boot/dts/marvell/armada-388-helios4.dts +4 -0
@@ -201,6 +201,10 @@ temp_sensor: temp@4c { reg = <0x4c>; vcc-supply = <®_3p3v>; }; + + eeprom@53 { + vcc-supply = <®_3p3v>; + }; }; i2c@11100 {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1048/1518 ARM: dts: helios4: add vcc-supply to GPIO expander
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit c23988f84496e937dd255564cb30bec67608dcc6 ]
The pca953x driver requests a 'vcc' supply, producing:
pca953x 0-0020: supply vcc not found, using dummy regulator
The PCA9655 (PCA9555-compatible) expander is powered by the same always-on 3.3V rail as the other I2C devices on the bus. Add vcc-supply = <®_3p3v> to silence the warning.
--- arch/arm/boot/dts/marvell/armada-388-helios4.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/marvell/armada-388-helios4.dts +1 -0
@@ -169,6 +169,7 @@ expander0: gpio-expander@20 { gpio-controller; #gpio-cells = <2>; reg = <0x20>; + vcc-supply = <®_3p3v>; pinctrl-names = "default"; pinctrl-0 = <&pca0_pins>; interrupt-parent = <&gpio0>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1049/1518 ARM: dts: helios4: add SATA regulator supplies
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 7a90520e8c9a8f48fe6f3e741cf34d8c2b6dbc61 ]
The ahci-mvebu driver and libahci_platform request three supplies on SATA controller and port nodes:
- ahci-supply (controller power)
- phy-supply (PHY power)
- target-supply (disk power per port)
Without them the regulator core prints notices at boot, e.g.:
supply ahci not found, using dummy regulator supply phy not found, using dummy regulator supply target not found, using dummy regulator
The SATA controller and PHY inside the Armada 388 SoC are powered by the 3.3V I/O rail; the four disk bays are powered by the 5V HDD rail. Wire the existing fixed regulators accordingly.
--- arch/arm/boot/dts/marvell/armada-388-helios4.dts | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/boot/dts/marvell/armada-388-helios4.dts +8 -0
@@ -222,13 +222,17 @@ sata@a8000 { status = "okay"; #address-cells = <1>; #size-cells = <0>; + ahci-supply = <®_3p3v>; + phy-supply = <®_3p3v>; sata0: sata-port@0 { reg = <0>; + target-supply = <®_5p0v_hdd>; }; sata1: sata-port@1 { reg = <1>; + target-supply = <®_5p0v_hdd>; }; };
@@ -236,13 +240,17 @@ sata@e0000 { status = "okay"; #address-cells = <1>; #size-cells = <0>; + ahci-supply = <®_3p3v>; + phy-supply = <®_3p3v>; sata2: sata-port@0 { reg = <0>; + target-supply = <®_5p0v_hdd>; }; sata3: sata-port@1 { reg = <1>; + target-supply = <®_5p0v_hdd>; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1050/1518 perf stat: Fix evsel_list leak in cmd_stat
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 340641a4b5fff4f4b12261c9d92169f6e2ea11f4 ]
Fix a memory leak in cmd_stat() where evsel_list is leaked if an error occurs while opening the output file.
--- tools/perf/builtin-stat.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tools/perf/builtin-stat.c +6 -3
@@ -2637,7 +2637,8 @@ int cmd_stat(int argc, const char **argv) output =fopen (output_name, mode);if (!output) {perror ("failed to create output file" ); -return -1 ; + status =-1 ; + goto out; }if (!stat_config.json_output) {clock_gettime (CLOCK_REALTIME , &tm);
@@ -2648,7 +2649,8 @@ int cmd_stat(int argc, const char **argv) output =fdopen (output_fd, mode);if (!output) {perror ("Failed opening logfd" ); -return -errno; + status = -errno; + goto out; } }
@@ -2657,7 +2659,8 @@ int cmd_stat(int argc, const char **argv)parse_options_usage (stat_usage, stat_options,"o" ,1 );parse_options_usage (NULL , stat_options,"log-fd" ,0 );parse_options_usage (NULL , stat_options,"interval-clear" ,0 ); -return -1 ; + status =-1 ; + goto out; } stat_config.output = output;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1051/1518 perf synthetic-events: Fix uninitialized pthread_join
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 54ba44db4dddc4ca06b49bae0f9d6c5861430b18 ]
In perf_event__synthesize_threads(), fix an uninitialized pthread_join() call when thread creation fails by only joining the successfully created threads.
--- tools/perf/util/synthetic-events.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/synthetic-events.c +2 -2
@@ -1104,8 +1104,8 @@ int perf_event__synthesize_threads(const struct perf_tool *tool, } err =0 ; out_join: -for (i =0 ; i < thread_nr; i++) -pthread_join (synthesize_threads[i],NULL ); +for (j =0 ; j < i; j++) +pthread_join (synthesize_threads[j],NULL );free (args); free_threads:free (synthesize_threads);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1052/1518 perf test: Support dynamic test suites with setup callback and private data
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 8c8d61c38d8e1755a4325f8acb396137bbd5371a ]
Add void *priv to struct test_case to allow passing per-test context. Add int (*setup)(struct test_suite *) to struct test_suite to allow dynamic generation of test cases. Update build_suites() to invoke the setup callback for each suite if present, ensuring dynamic cases are available before listing or running.
Stable-dep-of: 44e82c4d2ff3 ("perf test: Fix skiplist leak in cmd_test")
--- tools/perf/tests/builtin-test.c | 17 ++++++++++++++++- tools/perf/tests/tests.h | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-)
tools/perf/tests/builtin-test.c +16 -1
@@ -1490,10 +1490,21 @@ static struct test_suite **build_suites(void)for (size_t i =0 , j =0 ; i <ARRAY_SIZE (suites); i++, j =0 ) \while ((suite = suites[i][j++]) !=NULL ) -for_each_suite (t) +for_each_suite (t) { +if (t->setup) { +int ret = t->setup (t); + +if (ret <0 ) { + errno = -ret; +return NULL ; + } + } num_suites++; + } result =calloc (num_suites +1 ,sizeof (struct test_suite *)); +if (!result) +return NULL ;for (int pass =1 ; pass <=2 ; pass++) {for_each_suite (t) {
@@ -1560,6 +1571,8 @@ int cmd_test(int argc, const char **argv) argc =parse_options_subcommand (argc, argv, test_options, test_subcommands, test_usage,0 );if (argc >=1 && !strcmp (argv[0 ],"list" )) { suites =build_suites (); +if (!suites) +return errno ? -errno : -ENOMEM ; ret =perf_test__list (stdout, suites, argc -1 , argv +1 );free (suites);return ret;
@@ -1592,6 +1605,8 @@ int cmd_test(int argc, const char **argv)rlimit__bump_memlock (); suites =build_suites (); +if (!suites) +return errno ? -errno : -ENOMEM ; ret =__cmd_test (suites, argc, argv, skiplist);free (suites);return ret;
tools/perf/tests/tests.h +2 -0
@@ -38,12 +38,14 @@ struct test_case {const char *skip_reason;test_fnptr run_case;bool exclusive; +void *priv; };struct test_suite {const char *desc;struct test_case *test_cases;void *priv; +int (*setup)(struct test_suite *suite); };#define DECLARE_SUITE (name) \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1053/1518 perf test: Fix skiplist leak in cmd_test
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 44e82c4d2ff37f073946b594840fd549ab6b9fb8 ]
Fix a memory leak in cmd_test() where skiplist was not freed on exit paths.
--- tools/perf/tests/builtin-test.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/perf/tests/builtin-test.c +7 -2
@@ -1605,9 +1605,14 @@ int cmd_test(int argc, const char **argv)rlimit__bump_memlock (); suites =build_suites (); -if (!suites) -return errno ? -errno : -ENOMEM ; +if (!suites) { +int err = errno; + +intlist__delete (skiplist); +return err ? -err : -ENOMEM ; + } ret =__cmd_test (suites, argc, argv, skiplist);free (suites); +intlist__delete (skiplist);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1054/1518 perf python: Check counts_values size in set_values
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 612aca22a978d43f6e6765272676a17afdba8572 ]
The set_values function incorrectly assumed the list contained exactly 5 elements. Add a check to prevent out-of-bounds access.
--- tools/perf/util/python.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-)
tools/perf/util/python.c +30 -8
@@ -872,11 +872,11 @@ static void pyrf_counts_values__delete(struct pyrf_counts_values *pcounts_values 0, help }static PyMemberDef pyrf_counts_values_members[] = { -counts_values_member_def (val,T_ULONG ,"Value of event" ), -counts_values_member_def (ena,T_ULONG ,"Time for which enabled" ), -counts_values_member_def (run,T_ULONG ,"Time for which running" ), -counts_values_member_def (id,T_ULONG ,"Unique ID for an event" ), -counts_values_member_def (lost,T_ULONG ,"Num of lost samples" ), +counts_values_member_def (val,T_ULONGLONG ,"Value of event" ), +counts_values_member_def (ena,T_ULONGLONG ,"Time for which enabled" ), +counts_values_member_def (run,T_ULONGLONG ,"Time for which running" ), +counts_values_member_def (id,T_ULONGLONG ,"Unique ID for an event" ), +counts_values_member_def (lost,T_ULONGLONG ,"Num of lost samples" ), { .name =NULL , }, };
@@ -886,8 +886,15 @@ static PyObject *pyrf_counts_values_get_values(struct pyrf_counts_values *self,if (!vals)return NULL ; -for (int i =0 ; i <5 ; i++) -PyList_SetItem (vals, i,PyLong_FromLong (self->values.values[i])); +for (int i =0 ; i <5 ; i++) { +PyObject *val =PyLong_FromUnsignedLongLong (self->values.values[i]); + +if (!val) { +Py_DECREF (vals); +return NULL ; + } +PyList_SetItem (vals, i, val); + }return vals; }
@@ -898,19 +905,34 @@ static int pyrf_counts_values_set_values(struct pyrf_counts_values *self, PyObjePy_ssize_t size;PyObject *item =NULL ; +if (list ==NULL ) { +PyErr_SetString (PyExc_TypeError,"cannot delete attribute" ); +return -1 ; + } +if (!PyList_Check (list)) {PyErr_SetString (PyExc_TypeError,"Value assigned must be a list" );return -1 ; } size =PyList_Size (list); +if (size !=5 ) { +PyErr_SetString (PyExc_ValueError,"List must have exactly 5 entries" ); +return -1 ; + } +for (Py_ssize_t i =0 ; i < size; i++) { +unsigned long long val; + item =PyList_GetItem (list, i);if (!PyLong_Check (item)) {PyErr_SetString (PyExc_TypeError,"List members should be numbers" );return -1 ; } - self->values.values[i] =PyLong_AsLong (item); + val =PyLong_AsUnsignedLongLong (item); +if (val == (unsigned long long )-1 &&PyErr_Occurred ()) +return -1 ; + self->values.values[i] = val; }return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1055/1518 perf python: Handle Py_None for thread and cpu maps
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 054d1c7717b95d9089cd3b80e9e85fe1f2ea0471 ]
The python stubs allow passing None for threads and cpus to the perf.parse_events() and perf.parse_metrics() bindings. However, PyArg_ParseTuple parses None into a Py_None object, which is not a NULL pointer. Because the C code lacked an explicit check for Py_None, it would cast Py_None to a pyrf_thread_map/pyrf_cpu_map struct pointer and dereference it, causing a memory corruption crash.
Fix this pre-existing issue by explicitly checking for Py_None alongside NULL in pyrf__parse_events, pyrf__parse_metrics, and pyrf_evsel__open.
Stable-dep-of: 9a142beb1eba ("perf python: Validate CPU and thread maps in pyrf_evsel__open")
--- tools/perf/util/python.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
tools/perf/util/python.c +10 -6
@@ -1096,10 +1096,10 @@ static PyObject *pyrf_evsel__open(struct pyrf_evsel *pevsel, &pcpus, &pthreads, &group, &inherit))return NULL ; -if (pthreads !=NULL ) +if (pthreads !=NULL && pthreads != Py_None) threads = ((struct pyrf_thread_map *)pthreads)->threads; -if (pcpus !=NULL ) +if (pcpus !=NULL && pcpus != Py_None) cpus = ((struct pyrf_cpu_map *)pcpus)->cpus; evsel->core.attr.inherit = inherit;
@@ -2056,8 +2056,10 @@ static PyObject *pyrf__parse_events(PyObject *self, PyObject *args)if (!PyArg_ParseTuple (args,"s|OO" , &input, &pcpus, &pthreads))return NULL ; - threads = pthreads ? ((struct pyrf_thread_map *)pthreads)->threads :NULL ; - cpus = pcpus ? ((struct pyrf_cpu_map *)pcpus)->cpus :NULL ; + threads = (pthreads && pthreads != Py_None) ? + ((struct pyrf_thread_map *)pthreads)->threads :NULL ; + cpus = (pcpus && pcpus != Py_None) ? + ((struct pyrf_cpu_map *)pcpus)->cpus :NULL ;parse_events_error__init (&err);evlist__init (&evlist, cpus, threads);
@@ -2084,8 +2086,10 @@ static PyObject *pyrf__parse_metrics(PyObject *self, PyObject *args)if (!PyArg_ParseTuple (args,"s|OO" , &input, &pcpus, &pthreads))return NULL ; - threads = pthreads ? ((struct pyrf_thread_map *)pthreads)->threads :NULL ; - cpus = pcpus ? ((struct pyrf_cpu_map *)pcpus)->cpus :NULL ; + threads = (pthreads && pthreads != Py_None) ? + ((struct pyrf_thread_map *)pthreads)->threads :NULL ; + cpus = (pcpus && pcpus != Py_None) ? + ((struct pyrf_cpu_map *)pcpus)->cpus :NULL ;evlist__init (&evlist, cpus, threads); ret = metricgroup__parse_groups(&evlist, /*pmu=*/"all", input,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1056/1518 perf python: Validate CPU and thread maps in pyrf_evsel__open
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 9a142beb1eba42b986dc7016f4fc1a3bc28b8c09 ]
Add explicit Py_TYPE checks to ensure the arguments passed are actually of the correct pyrf_thread_map and pyrf_cpu_map types.
--- tools/perf/util/python.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
tools/perf/util/python.c +12 -2
@@ -1096,11 +1096,21 @@ static PyObject *pyrf_evsel__open(struct pyrf_evsel *pevsel, &pcpus, &pthreads, &group, &inherit))return NULL ; -if (pthreads !=NULL && pthreads != Py_None) +if (pthreads !=NULL && pthreads != Py_None) { +if (!PyObject_TypeCheck (pthreads, &pyrf_thread_map__type)) { +PyErr_SetString (PyExc_TypeError,"threads must be a thread_map" ); +return NULL ; + } threads = ((struct pyrf_thread_map *)pthreads)->threads; + } -if (pcpus !=NULL && pcpus != Py_None) +if (pcpus !=NULL && pcpus != Py_None) { +if (!PyObject_TypeCheck (pcpus, &pyrf_cpu_map__type)) { +PyErr_SetString (PyExc_TypeError,"cpus must be a cpu_map" ); +return NULL ; + } cpus = ((struct pyrf_cpu_map *)pcpus)->cpus; + } evsel->core.attr.inherit = inherit;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1057/1518 perf python: Fix memory leak in pyrf__metrics_cb
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 1ec13016ba36f1bf7dc61e054068fe00f2f628c7 ]
In pyrf__metrics_cb, PyDict_SetItem does not steal the reference of the key and value, so they need to be decref'ed after successful insertion to avoid memory leaks.
--- tools/perf/util/python.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/python.c +2 -0
@@ -2159,6 +2159,8 @@ static int pyrf__metrics_cb(const struct pmu_metric *pm,Py_XDECREF (dict);return -ENOMEM ; } +Py_DECREF (key); +Py_DECREF (value); if (!add_to_dict(dict, "MetricName", pm->metric_name) || !add_to_dict(dict, "PMU", pm->pmu) ||
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1058/1518 perf synthetic-events: Fix divide by zero in perf_event__synthesize_threads
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 16a12a54e9a1151a37aab74914a51b86f7f58d0e ]
If scandir() finds no matching tasks in /proc, n is 0. If thread_nr is > 1, we bypass the single-thread fast path and then clamp thread_nr to n, making it 0. This results in a divide by zero when calculating num_per_thread.
Handle n <= 1 early to use the single-thread fast path and prevent the crash.
--- tools/perf/util/synthetic-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/synthetic-events.c +1 -1
@@ -1058,7 +1058,7 @@ int perf_event__synthesize_threads(const struct perf_tool *tool,else thread_nr = nr_threads_synthesize; -if (thread_nr <=1 ) { +if (thread_nr <=1 || n <=1 ) { err = __perf_event__synthesize_threads(tool, process, machine, needs_mmap, mmap_data,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1059/1518 fbdev: tdfxfb: fix PCI enable cleanup with pcim_enable_device()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 95a627143a696f70e17be5ed3b1e733bb6724b46 ]
tdfxfb_probe() enables the PCI device with pci_enable_device(), but several failure paths after that point return without disabling it. The framebuffer_alloc() failure path returns -ENOMEM directly, and the later shared out_err path releases the framebuffer and returns -ENXIO without balancing the PCI enable state.
The successful probe path has the same imbalance because tdfxfb_remove() releases the framebuffer, mappings and regions, but never calls pci_disable_device().
Use pcim_enable_device() so the PCI device is disabled automatically on probe failure and driver detach.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/video/fbdev/tdfxfb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/tdfxfb.c +1 -1
@@ -1383,7 +1383,7 @@ static int tdfxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (err)return err; - err =pci_enable_device (pdev); + err =pcim_enable_device (pdev);if (err) {printk (KERN_ERR "tdfxfb: Can't enable pdev: %d\n" , err);return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1060/1518 fbdev: kyro: Validate overlay viewport coordinates
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danila Chernetsov <[email protected]>
[ Upstream commit 7b5c7bc55e13e7f5ac7b1eaf5c6d690389ea5ee3 ]
The overlay viewport end coordinates are computed from the viewport origin and dimensions using 32-bit unsigned arithmetic. Large input values can cause these calculations to wrap around before the resulting coordinates are passed to SetOverlayViewPort().
SetOverlayViewPort() packs the viewport coordinates into 16-bit register fields. The X coordinates are additionally adjusted by +2 and +1 before being written. Validate the coordinate calculations for 32-bit wraparound and ensure that the adjusted coordinates fit within their 16-bit register fields before calling SetOverlayViewPort().
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/video/fbdev/kyro/fbdev.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
drivers/video/fbdev/kyro/fbdev.c +23 -1
@@ -369,6 +369,9 @@ static int kyro_dev_overlay_create(u32 ulWidth,static int kyro_dev_overlay_viewport_set (u32 x,u32 y,u32 ulWidth,u32 ulHeight) { +u32 right; +u32 bottom; +if (deviceInfo.ulOverlayOffset ==0 )/* probably haven't called CreateOverlay yet */ return -EINVAL ;
@@ -378,11 +381,30 @@ static int kyro_dev_overlay_viewport_set(u32 x, u32 y, u32 ulWidth, u32 ulHeight (x < 2 && ulWidth + 2 == 0))return -EINVAL ; +/* +* SetOverlayViewPort() adjusts X coordinates by +2 (left) and +1 +* (right) before packing them into 16-bit register fields. +*/ +if (x >U16_MAX -2 || y >U16_MAX ) +return -EINVAL ; + + right = x + ulWidth; + bottom = y + ulHeight; + +if (right < x || bottom < y) +return -EINVAL ; + + right--; + bottom--; + +if (right >U16_MAX -1 || bottom >U16_MAX ) +return -EINVAL ; +/* Stop Ramdac Output */ DisableRamdacOutput (deviceInfo.pSTGReg);SetOverlayViewPort (deviceInfo.pSTGReg, - x, y, x + ulWidth -1 , y + ulHeight -1 ); + x, y, right, bottom);EnableOverlayPlane (deviceInfo.pSTGReg);/* Start Ramdac Output */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1061/1518 fbdev: clps711x-fb: Remove unreachable unregister_framebuffer() call
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 39dd7598fbe90c5b4bb77fb34d8f3dad8385d11c ]
The unregister_framebuffer() call in clps711x_fb_probe() is unreachable. register_framebuffer() failure jumps to the unwind label, while success returns immediately.
Remove it.
Found with Clang's -Wunreachable-code.
--- drivers/video/fbdev/clps711x-fb.c | 2 -- 1 file changed, 2 deletions(-)
drivers/video/fbdev/clps711x-fb.c +0 -2
@@ -332,8 +332,6 @@ static int clps711x_fb_probe(struct platform_device *pdev)return 0 ; -unregister_framebuffer (info); - out_fb_dealloc_cmap:regmap_update_bits (cfb->syscon,SYSCON_OFFSET ,SYSCON1_LCDEN ,0 );fb_dealloc_cmap (&info->cmap);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1062/1518 iommu/dma: Restore locking around msi_page_list
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Jones <[email protected]>
[ Upstream commit 5a9e89ea34e0e34ac5d7e949042d665533549e40 ]
Unlike a group's default domain, which is always freshly allocated and privately owned (iommu_group_alloc_default_domain()), VFIO type1's legacy container merges any newly attached group into an existing domain whenever their iommu_ops and cache-coherency enforcement match.
iommu_dma_get_msi_page() only asserts the caller's own group mutex is held (iommu_group_mutex_assert()). On an IOMMU that publishes IOMMU_RESV_SW_MSI, e.g. ARM SMMU, a VM with two such devices assigned through the legacy container can have their guest drivers probe and allocate MSIs in parallel; each host-side VFIO_DEVICE_SET_IRQS lands on a different device fd and group mutex, but both devices' domains are the same merged domain, so both can enter iommu_dma_get_msi_page() concurrently and corrupt msi_page_list.
commit 288683c92b1a ("iommu: Make iommu_dma_prepare_msi() into a generic operation") dropped the prior msi_prepare_lock on the reasoning that "each iommu_domain is unique to a group," which holds for default domains but not this VFIO type1 case. Restore the static lock, since it's only guarding a corner case and will likely never be contended.
iommufd avoids the equivalent problem by having its own callers (iommufd_sw_map_msi()) take a ctx-wide sw_msi_lock before ever reaching the shared list. VFIO type1 can't mirror that since it dispatches to iommu_dma_sw_msi() which is outside VFIO's jurisdiction.
--- drivers/iommu/dma-iommu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/iommu/dma-iommu.c +13 -0
@@ -2163,6 +2163,19 @@ static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev,dma_addr_t iova;int prot =IOMMU_WRITE |IOMMU_NOEXEC |IOMMU_MMIO ;size_t size =cookie_msi_granule (domain); +static DEFINE_MUTEX (msi_prepare_lock); + +/* +* Normally a device's default domain is only ever attached to that +* device's own group, and the group mutex held by +* iommu_group_mutex_assert()'s callers is enough on its own. A VFIO +* type1 container is the one case that breaks that assumption: it +* can merge devices from different groups onto one domain, so two +* devices' group mutexes don't serialize each other here. A static +* lock is sufficient due to the expectation that this is a corner +* case that will never be contended in practice. +*/ +guard (mutex)(&msi_prepare_lock); msi_addr &= ~(phys_addr_t)(size -1 );list_for_each_entry (msi_page, msi_page_list, list)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1063/1518 iommu/vt-d: Fix UCTP context table slot when copying root entries
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Desnes Nunes <[email protected]>
[ Upstream commit c6e63fc8e8fcefa5c32145dc0a3c82975b0ce152 ]
When translation is already enabled at boot (e.g. kdump), the vt-d driver copies context tables from the previous kernel's root table. In scalable mode, buses that only populate the upper root half (UCTP, devfn >= 0x80) should be written to ctxt_tbls[tbl_idx + 1] through copy_context_table(). However, the current copy path always uses tbl[tbl_idx + 0] in this situa- tion. Since idx wraps to 0 at devfn 0x80 due to a zeroed LCTP, new_ce for LCTP will be NULL and keep pos equals to 0. Thus, UCTP entries will be co- pied into tbl[tbl_idx + 0] instead of tbl[tbl_idx + 1], and written after- wards to root_entry[bus].lo instead of .hi in copy_translation_tables().
In short, devices on bus 0x80 with devfn >= 0x80 fail DMA with fault 0x39, which will break drivers running in kernels with translation pre-enabled. This fixes NO_PASID DMAR faults for UCTP-only buses such as:
DMAR: [DMA Read NO_PASID] Request device [80:14.0] fault addr 0xe81759000
[fault reason 0x39] SM: Present bit in Root Entry is clear
For instance, this fault yielded to locking issues between systemd and xHCI, blocking a system's reboot after a vmcore was captured with kdump:
systemd-udevd[246]: usb3: Worker [255] processing SEQNUM=2193 is taking a long time dracut-initqueue[277]: Timed out while waiting for udev queue to empty. systemd-udevd[246]: usb3: Worker [255] processing SEQNUM=2193 killed systemd-udevd[246]: usb3: Worker [255] terminated by signal 9 (KILL).
...
kdump[569]: saving vmcore complete
...
systemd-shutdown[1]: Rebooting.
INFO: task kworker/0:1:11 blocked for more than 122 seconds.
Not tainted 7.0.0-clean #1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:kworker/0:1 state:D stack:0 pid:11 tgid:11 ppid:2 task_flags:0x4208160 flags:0x00080000
Workqueue: usb_hub_wq hub_event
Call Trace:
<TASK>
__schedule+0x299/0x5c0
schedule+0x27/0x80
schedule_timeout+0xbd/0x100
__wait_for_common+0x97/0x1b0
? __pfx_schedule_timeout+0x10/0x10
xhci_alloc_dev+0x9e/0x2b0
usb_alloc_dev+0x7a/0x3b0
hub_port_connect+0x285/0x960
hub_port_connect_change+0x94/0x290
port_event+0x4bb/0x840
hub_event+0x141/0x460
process_one_work+0x196/0x390
worker_thread+0x1af/0x320
? __pfx_worker_thread+0x10/0x10
kthread+0xe3/0x120
? __pfx_kthread+0x10/0x10
ret_from_fork+0x199/0x260
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1a/0x30
</TASK>
INFO: task systemd-shutdow:1 blocked for more than 122 seconds.
Not tainted 7.0.0-clean #1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:systemd-shutdow state:D stack:0 pid:1 tgid:1 ppid:0 task_flags:0x400100 flags:0x00080000
Call Trace:
<TASK>
__schedule+0x299/0x5c0
schedule+0x27/0x80
schedule_preempt_disabled+0x15/0x30
__mutex_lock.constprop.0+0x547/0xac0
device_shutdown+0xac/0x1b0
kernel_restart+0x3a/0x70
__do_sys_reboot+0x147/0x240
do_syscall_64+0x11b/0x6a0
? handle_mm_fault+0x110/0x350
? do_user_addr_fault+0x206/0x680
? irqentry_exit+0x7a/0x4d0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
RIP: 0033:0x7fe2958da917
RSP: 002b:00007ffc5c458618 EFLAGS: 00000206 ORIG_RAX: 00000000000000a9
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fe2958da917
RDX: 0000000001234567 RSI: 0000000028121969 RDI: 00000000fee1dead
RBP: 00007ffc5c458790 R08: 0000000000000069 R09: 00000000ffffffff
R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000000
R13: 0000000000000000 R14: 00007ffc5c4588b8 R15: 0000000000000000
</TASK>
INFO: task systemd-shutdow:1 is blocked on a mutex likely owned by task kworker/0:1:11.--- drivers/iommu/intel/iommu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/iommu/intel/iommu.c +6 -4
@@ -1924,7 +1924,7 @@ static int copy_context_table(struct intel_iommu *iommu,struct context_entry **tbl, int bus, bool ext) { - int tbl_idx, pos = 0, idx, devfn, ret = 0, did; + int tbl_idx, tbl_slot = 0, idx, devfn, ret = 0, did;struct context_entry *new_ce =NULL , ce;struct context_entry *old_ce =NULL ;struct root_entry re;
@@ -1940,10 +1940,9 @@ static int copy_context_table(struct intel_iommu *iommu,if (idx ==0 ) {/* First save what we may have and clean up */ if (new_ce) { - tbl[tbl_idx] = new_ce; + tbl[tbl_idx + tbl_slot] = new_ce;__iommu_flush_cache (iommu, new_ce,VTD_PAGE_SIZE ); - pos =1 ; }if (old_ce)
@@ -1965,6 +1964,9 @@ static int copy_context_table(struct intel_iommu *iommu, } } +/* Track if saving UCTP or LCTP entries in scalable mode */ + tbl_slot = ext && devfn >=0x80 ?1 :0 ; + ret = -ENOMEM ; old_ce =memremap (old_ce_phys,PAGE_SIZE ,MEMREMAP_WB );
@@ -1993,7 +1995,7 @@ static int copy_context_table(struct intel_iommu *iommu, new_ce[idx] = ce; } - tbl[tbl_idx + pos] = new_ce; + tbl[tbl_idx + tbl_slot] = new_ce;__iommu_flush_cache (iommu, new_ce,VTD_PAGE_SIZE );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1064/1518 iommu/vt-d: Clear Present bit before tearing down copied context entry
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
[ Upstream commit f532c57985b1a7d6b7e37e05506b46d413e5cca4 ]
copied_context_tear_down() zeroes the 128-bit context entry with context_clear_entry() while the Present bit is still set, and only then issues the context-cache and IOTLB invalidations. This leaves a window in which hardware can fetch a torn entry, with some fields already zeroed while Present is still set, leading to unpredictable behaviour or spurious faults. While x86 provides strong write ordering, the compiler may reorder the writes to the two 64-bit halves of the entry, and the hardware fetch is not guaranteed to be atomic with respect to multiple CPU writes.
There is no cacheline flush before the invalidation either, so on an IOMMU without coherent access to the context table the zeroed entry may not be visible to hardware at the point the invalidation is submitted.
Apply the same ownership handshake described in the VT-d spec, Section 6.5.3.3 ("Guidance to Software for Invalidations"): clear only the Present bit, flush it out to the IOMMU, perform the invalidations, and only then zero the remainder of the entry.
--- drivers/iommu/intel/iommu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iommu/intel/iommu.c +5 -1
@@ -1421,7 +1421,8 @@ static void copied_context_tear_down(struct intel_iommu *iommu,assert_spin_locked (&iommu->lock); did_old =context_domain_id (context); -context_clear_entry (context); +context_clear_present (context); +__iommu_flush_cache (iommu, context,sizeof (*context));if (did_old <cap_ndoms (iommu->cap)) { iommu->flush.flush_context(iommu, did_old,
@@ -1432,6 +1433,9 @@ static void copied_context_tear_down(struct intel_iommu *iommu, DMA_TLB_DSI_FLUSH); } +context_clear_entry (context); +__iommu_flush_cache (iommu, context,sizeof (*context)); +clear_context_copied (iommu, bus, devfn); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1065/1518 iommu/vt-d: Tear down scalable-mode context on probe failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
[ Upstream commit c509fb73a1093a15accd7d43a61645d4b520f6ac ]
intel_pasid_setup_sm_context() walks a PCI device’s DMA aliases via pci_for_each_dma_alias() and programs a scalable-mode context entry for each RID. For a device with a dma_alias_mask, the callback is invoked once for the device’s own RID and once for each alias bit, all with the same pci_dev, so device_pasid_table_setup() runs for multiple RIDs.
pci_for_each_dma_alias() stops at the first callback error. Therefore, a failure partway through the walk can leave context entries for already processed RIDs present and still pointing to the device’s PASID table.
On this error path, intel_iommu_probe_device() currently jumps directly to intel_pasid_free_table(), which frees the PASID table without first tearing down those context entries. The IOMMU may then walk a present context entry whose PASID table pointer references freed memory.
intel_iommu_release_device() already performs teardown before freeing the table. Apply the same ordering on the probe failure path.
device_pasid_table_teardown() safely handles RIDs that were never
programmed: iommu_context_addr() returns NULL when no context table has been allocated, and clearing the Present bit of an already non-present entry is a no-op. So unwind is safe for both the alias that failed and any aliases not yet reached.
--- drivers/iommu/intel/iommu.c | 1 + 1 file changed, 1 insertion(+)
drivers/iommu/intel/iommu.c +1 -0
@@ -3864,6 +3864,7 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev)return &iommu->iommu; free_table: +intel_pasid_teardown_sm_context (dev);intel_pasid_free_table (dev); clear_rbtree:device_rbtree_remove (info);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1066/1518 iommu/vt-d: Flush context cache with correct SID when tearing down aliases
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
[ Upstream commit c54e4ae971b98e8d650400137d332cee56c03f55 ]
domain_context_clear_one() and device_pasid_table_teardown() are both invoked once per DMA alias of a device. Each function locates the context entry using the bus/devfn pair provided by the pci_for_each_dma_alias() callback, then calls intel_context_flush_no_pasid(), which constructs a device-selective context-cache invalidation from info->bus and info->devfn (that is, always the requester ID of the device itself).
As a result, for every alias other than the device’s own RID, the context entry that was just cleared in memory is never invalidated in the context cache. Hardware may continue using that stale cached entry. In the scalable-mode teardown path, intel_pasid_free_table() can then free the PASID directory still referenced by that stale entry, allowing the IOMMU to walk freed memory.
Fix this by passing the source ID of the entry being torn down to intel_context_flush_no_pasid(), instead of deriving it from @info.
--- drivers/iommu/intel/iommu.c | 2 +- drivers/iommu/intel/iommu.h | 2 +- drivers/iommu/intel/pasid.c | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-)
drivers/iommu/intel/iommu.c +1 -1
@@ -1732,7 +1732,7 @@ static void domain_context_clear_one(struct device_domain_info *info, u8 bus, u8context_clear_present (context);__iommu_flush_cache (iommu, context,sizeof (*context));spin_unlock (&iommu->lock); -intel_context_flush_no_pasid (info, context, did); +intel_context_flush_no_pasid (info, context, did,PCI_DEVID (bus, devfn));context_clear_entry (context);__iommu_flush_cache (iommu, context,sizeof (*context)); }
drivers/iommu/intel/iommu.h +1 -1
@@ -1320,7 +1320,7 @@ void cache_tag_flush_range_np(struct dmar_domain *domain, unsigned long start, unsigned long end);void intel_context_flush_no_pasid (struct device_domain_info *info, -struct context_entry *context,u16 did); +struct context_entry *context,u16 did,u16 sid);int intel_iommu_enable_prq (struct intel_iommu *iommu);int intel_iommu_finish_prq (struct intel_iommu *iommu);
drivers/iommu/intel/pasid.c +6 -3
@@ -749,7 +749,7 @@ static void device_pasid_table_teardown(struct device *dev, u8 bus, u8 devfn)context_clear_present (context);__iommu_flush_cache (iommu, context,sizeof (*context));spin_unlock (&iommu->lock); -intel_context_flush_no_pasid (info, context, did); +intel_context_flush_no_pasid (info, context, did,PCI_DEVID (bus, devfn));context_clear_entry (context);__iommu_flush_cache (iommu, context,sizeof (*context)); }
@@ -953,9 +953,12 @@ static void __context_flush_dev_iotlb(struct device_domain_info *info)* This helper can only be used when IOMMU is working in the legacy mode or * IOMMU is in scalable mode but all PASID table entries of the device are * non-present. +* +* @sid identifies the context entry that was modified, which may be a DMA +* alias of @info->dev rather than its own requester ID. */ void intel_context_flush_no_pasid (struct device_domain_info *info, -struct context_entry *context,u16 did) +struct context_entry *context,u16 did,u16 sid) {struct intel_iommu *iommu = info->iommu;
@@ -965,7 +968,7 @@ void intel_context_flush_no_pasid(struct device_domain_info *info,* when operating in scalable mode. Therefore the @did value doesn't * matter in scalable mode. */ - iommu->flush.flush_context (iommu, did,PCI_DEVID (info->bus, info->devfn), + iommu->flush.flush_context (iommu, did, sid,DMA_CCMD_MASK_NOBIT ,DMA_CCMD_DEVICE_INVL );/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1067/1518 crypto: qat - use 2-arg strscpy where destination size is known
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit 4525ac14115d07c3e4c57a8cd5c154916e9d1172 ]
To simplify the code, drop explicit and hard-coded size arguments from strscpy() where the destination buffer has a fixed size and strscpy() can automatically determine it using sizeof().
Stable-dep-of: 61135c1597af ("crypto: qat - remove dead ADF_HEX code")
--- drivers/crypto/intel/qat/qat_common/adf_cfg.c | 7 ++++--- drivers/crypto/intel/qat/qat_common/adf_cfg_services.c | 2 +- drivers/crypto/intel/qat/qat_common/adf_mstate_mgr.c | 3 ++- drivers/crypto/intel/qat/qat_common/adf_transport_debug.c | 3 ++- drivers/crypto/intel/qat/qat_common/qat_compression.c | 3 ++- 5 files changed, 11 insertions(+), 7 deletions(-)
drivers/crypto/intel/qat/qat_common/adf_cfg.c +4 -3
@@ -2,6 +2,7 @@/* Copyright(c) 2014 - 2020 Intel Corporation */ #include <linux/mutex.h> #include <linux/slab.h> +#include <linux/string.h> #include <linux/list.h> #include <linux/seq_file.h> #include "adf_accel_devices.h"
@@ -284,13 +285,13 @@ int adf_cfg_add_key_value_param(struct adf_accel_dev *accel_dev,return -ENOMEM ;INIT_LIST_HEAD (&key_val->list); -strscpy (key_val->key, key,sizeof (key_val->key)); +strscpy (key_val->key, key);if (type ==ADF_DEC ) {snprintf (key_val->val,ADF_CFG_MAX_VAL_LEN_IN_BYTES ,"%ld" , (*((long *)val))); }else if (type ==ADF_STR ) { -strscpy (key_val->val, (char *)val,sizeof (key_val->val)); +strscpy (key_val->val, (char *)val); }else if (type ==ADF_HEX ) {snprintf (key_val->val,ADF_CFG_MAX_VAL_LEN_IN_BYTES ,"0x%lx" , (unsigned long )val);
@@ -350,7 +351,7 @@ int adf_cfg_section_add(struct adf_accel_dev *accel_dev, const char *name)if (!sec)return -ENOMEM ; -strscpy (sec->name, name,sizeof (sec->name)); +strscpy (sec->name, name);INIT_LIST_HEAD (&sec->param_head);down_write (&cfg->lock);list_add_tail (&sec->list, &cfg->sec_list);
drivers/crypto/intel/qat/qat_common/adf_cfg_services.c +1 -1
@@ -60,7 +60,7 @@ static int adf_service_string_to_mask(struct adf_accel_dev *accel_dev, const chaif (len >ADF_CFG_MAX_VAL_LEN_IN_BYTES -1 )return -EINVAL ; -strscpy (services, buf,ADF_CFG_MAX_VAL_LEN_IN_BYTES ); +strscpy (services, buf); substr = services;while ((token =strsep (&substr,ADF_SERVICES_DELIMITER ))) {
drivers/crypto/intel/qat/qat_common/adf_mstate_mgr.c +2 -1
@@ -2,6 +2,7 @@/* Copyright(c) 2024 Intel Corporation */ #include <linux/slab.h> +#include <linux/string.h> #include <linux/types.h> #include "adf_mstate_mgr.h"
@@ -158,7 +159,7 @@ static struct adf_mstate_sect_h *adf_mstate_sect_add_header(struct adf_mstate_mgreturn NULL ; } -strscpy (sect->id, id,sizeof (sect->id)); +strscpy (sect->id, id); sect->size =0 ; sect->sub_sects =0 ; mgr->state +=sizeof (*sect);
drivers/crypto/intel/qat/qat_common/adf_transport_debug.c +2 -1
@@ -2,6 +2,7 @@/* Copyright(c) 2014 - 2020 Intel Corporation */ #include <linux/mutex.h> #include <linux/slab.h> +#include <linux/string.h> #include <linux/seq_file.h> #include "adf_accel_devices.h" #include "adf_transport_internal.h"
@@ -103,7 +104,7 @@ int adf_ring_debugfs_add(struct adf_etr_ring_data *ring, const char *name)if (!ring_debug)return -ENOMEM ; -strscpy (ring_debug->ring_name, name,sizeof (ring_debug->ring_name)); +strscpy (ring_debug->ring_name, name);snprintf (entry_name,sizeof (entry_name),"ring_%02d" , ring->ring_number);
drivers/crypto/intel/qat/qat_common/qat_compression.c +2 -1
@@ -2,6 +2,7 @@/* Copyright(c) 2022 Intel Corporation */ #include <linux/module.h> #include <linux/slab.h> +#include <linux/string.h> #include "adf_accel_devices.h" #include "adf_common_drv.h" #include "adf_transport.h"
@@ -123,7 +124,7 @@ static int qat_compression_create_instances(struct adf_accel_dev *accel_dev)int i;INIT_LIST_HEAD (&accel_dev->compression_list); -strscpy (key,ADF_NUM_DC ,sizeof (key)); +strscpy (key,ADF_NUM_DC ); ret =adf_cfg_get_param_value (accel_dev,SEC , key, val);if (ret)return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1068/1518 crypto: qat - remove dead ADF_HEX code
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahsan Atta <[email protected]>
[ Upstream commit 61135c1597af56eb454d53c9d7cda90d5e5dc566 ]
The ADF_HEX value type is defined in the adf_cfg_val_type enum and handled in adf_cfg_add_key_value_param(), but no caller in the tree uses it.
Remove the unused ADF_HEX enum value and its dead handling code.
--- drivers/crypto/intel/qat/qat_common/adf_cfg.c | 3 --- drivers/crypto/intel/qat/qat_common/adf_cfg_common.h | 1 - 2 files changed, 4 deletions(-)
drivers/crypto/intel/qat/qat_common/adf_cfg.c +0 -3
@@ -292,9 +292,6 @@ int adf_cfg_add_key_value_param(struct adf_accel_dev *accel_dev, "%ld", (*((long *)val))); }else if (type ==ADF_STR ) {strscpy (key_val->val, (char *)val); - }else if (type ==ADF_HEX ) { -snprintf (key_val->val,ADF_CFG_MAX_VAL_LEN_IN_BYTES , -"0x%lx" , (unsigned long )val); }else {dev_err (&GET_DEV (accel_dev),"Unknown type given.\n" );kfree (key_val);
drivers/crypto/intel/qat/qat_common/adf_cfg_common.h +0 -1
@@ -28,7 +28,6 @@ enum adf_cfg_service_type {enum adf_cfg_val_type {ADF_DEC , -ADF_HEX ,ADF_STR };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1069/1518 hwrng: imx-rngc - Disable clock on registration failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 188bb9ad86c3b2d527385328a30c1d9510253202 ]
The RNGC clock is enabled manually before runtime PM is configured. If devm_hwrng_register() fails, probe returns without disabling the clock. The devm_pm_runtime_enable() cleanup only disables runtime PM and does not call imx_rngc_suspend().
Disable the clock before returning from this failure path.
--- drivers/char/hw_random/imx-rngc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/hw_random/imx-rngc.c +3 -1
@@ -314,8 +314,10 @@ static int __init imx_rngc_probe(struct platform_device *pdev)devm_pm_runtime_enable (&pdev->dev); ret =devm_hwrng_register (&pdev->dev, &rngc->rng); -if (ret) +if (ret) { +clk_disable_unprepare (rngc->clk);return dev_err_probe (&pdev->dev, ret,"hwrng registration failed\n" ); + } dev_info(&pdev->dev, "Freescale RNG%c registered (HW revision %d.%02d)\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1070/1518 m68k: Fix backtraces for non-running tasks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 09f71dbeb287e367beea56d9ac8a3d356ef5e02a ]
When no stack pointer is supplied, show_stack() starts at thread.esp0. This is the saved userspace register frame, not where a task was switched out. For kernel threads it points to the zeroed frame created by copy_thread(), so sched_show_task() prints no useful backtrace.
Use thread.ksp for non-current tasks. It is saved by switch_to() and is already used by __get_wchan(). For current, start at the current stack frame, as is already done when no task is supplied.
Tested on qemu-system-m68k -M virt using SysRq-t. All task dumps contained resolved frames.
--- arch/m68k/kernel/traps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/m68k/kernel/traps.c +2 -2
@@ -936,8 +936,8 @@ void show_stack(struct task_struct *task, unsigned long *stack,int i;if (!stack) { -if (task) - stack = (unsigned long *)task->thread.esp0; +if (task && task != current) + stack = (unsigned long *)task->thread.ksp;else stack = (unsigned long *)&stack; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1071/1518 xdrgen: Address some checkpatch whitespace complaints
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 4329010ad9c36775e7092e451c37c24c4f90243f ]
This is a roll-up of three template fixes that eliminate noise from checkpatch output so that it's easier to spot non-trivial problems.
To follow conventional kernel C style, when a union declaration is marked with "pragma public", there should be a blank line between the emitted "union xxx { ... };" and the decoder and encoder function declarations.
Stable-dep-of: d4ca0b0a6c62 ("xdrgen: Do not declare union XDR functions in the definitions header")
--- tools/net/sunrpc/xdrgen/templates/C/enum/declaration/enum.j2 | 1 - tools/net/sunrpc/xdrgen/templates/C/enum/definition/close.j2 | 1 + tools/net/sunrpc/xdrgen/templates/C/enum/definition/close_be.j2 | 1 + tools/net/sunrpc/xdrgen/templates/C/union/definition/close.j2 | 1 + 4 files changed, 3 insertions(+), 1 deletion(-)
tools/net/sunrpc/xdrgen/templates/C/enum/declaration/enum.j2 +0 -1
@@ -1,4 +1,3 @@ {# SPDX-License-Identifier: GPL-2.0 #} - bool xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ name }} *ptr); bool xdrgen_encode_{{ name }}(struct xdr_stream *xdr, {{ name }} value);
tools/net/sunrpc/xdrgen/templates/C/enum/definition/close.j2 +1 -0
@@ -1,3 +1,4 @@ {# SPDX-License-Identifier: GPL-2.0 #} }; + typedef enum {{ name }} {{ name }};
tools/net/sunrpc/xdrgen/templates/C/enum/definition/close_be.j2 +1 -0
@@ -1,3 +1,4 @@ {# SPDX-License-Identifier: GPL-2.0 #} }; + typedef __be32 {{ name }};
tools/net/sunrpc/xdrgen/templates/C/union/definition/close.j2 +1 -0
@@ -3,6 +3,7 @@ }; {%- if name in public_apis %} + bool xdrgen_decode_{{ name }}(struct xdr_stream *xdr, struct {{ name }} *ptr); bool xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const struct {{ name }} *ptr); {%- endif -%}
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1072/1518 xdrgen: Do not declare union XDR functions in the definitions header
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit d4ca0b0a6c62bc12407060754df11b23a90f3e57 ]
Unlike the struct, enum, typedef, and pointer templates, the union definitions template also emits xdrgen_decode_*() and xdrgen_encode_*() prototypes for a public union into that header. Those prototypes name struct xdr_stream, which the definitions header neither includes nor forward-declares, so any translation unit that includes the definitions header without xdr.h already in scope draws -Wvisibility warnings. The same public prototypes are emitted into the declarations header, which does include <linux/sunrpc/xdr.h>, making the definitions-header copies redundant.
Drop the prototype emission from the union definitions template so it matches the other type templates. Public unions keep their encode and decode prototypes through the declarations header.
--- .../net/sunrpc/xdrgen/templates/C/union/definition/close.j2 | 6 ------ 1 file changed, 6 deletions(-)
tools/net/sunrpc/xdrgen/templates/C/union/definition/close.j2 +0 -6
@@ -1,9 +1,3 @@ {# SPDX-License-Identifier: GPL-2.0 #} } u; }; -{%- if name in public_apis %} - - -bool xdrgen_decode_{{ name }}(struct xdr_stream *xdr, struct {{ name }} *ptr); -bool xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const struct {{ name }} *ptr); -{%- endif -%}
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1073/1518 xdrgen: Fix opaque and string encoders for unbounded members
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit daa52e37851a5a1b5890e7a250a27e94a8b9f273 ]
The variable-length opaque and string encoder templates emit an unconditional bound check, "if (value->NAME.len > MAXSIZE) return false". XDR represents an unbounded specifier (opaque foo<>, string foo<>) as a maxsize of 0, so for an unbounded member the check degenerates to "len > 0" and the generated encoder refuses every non-empty value.
The decoder does not share this defect. It delegates to xdrgen_decode_opaque() and xdrgen_decode_string(), which treat a maxlen of 0 as unbounded and skip the length check. The sibling variable-length array templates already guard their bound check with maxsize != "0".
Guard the bound check the same way in each affected template -- the struct and pointer forms of both the opaque and string encoders -- so an unbounded member encodes a payload of any length while a bounded member keeps its limit.
An explicit zero-length bound (foo<0>) parses to the same maxsize of 0 and so also skips the check; xdrgen does not distinguish it from the unbounded form, matching the decoder and the array encoders.
--- tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/string.j2 | 2 ++ .../templates/C/pointer/encoder/variable_length_opaque.j2 | 2 ++ tools/net/sunrpc/xdrgen/templates/C/struct/encoder/string.j2 | 2 ++ .../xdrgen/templates/C/struct/encoder/variable_length_opaque.j2 | 2 ++ 4 files changed, 8 insertions(+)
tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/string.j2 +2 -0
@@ -2,7 +2,9 @@ {% if annotate %} /* member {{ name }} (variable-length string) */ {% endif %} +{% if maxsize != "0" %} if (value->{{ name }}.len > {{ maxsize }}) return false; +{% endif %} if (xdr_stream_encode_opaque(xdr, value->{{ name }}.data, value->{{ name }}.len) < 0) return false;
tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/variable_length_opaque.j2 +2 -0
@@ -2,7 +2,9 @@ {% if annotate %} /* member {{ name }} (variable-length opaque) */ {% endif %} +{% if maxsize != "0" %} if (value->{{ name }}.len > {{ maxsize }}) return false; +{% endif %} if (xdr_stream_encode_opaque(xdr, value->{{ name }}.data, value->{{ name }}.len) < 0) return false;
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/string.j2 +2 -0
@@ -2,7 +2,9 @@ {% if annotate %} /* member {{ name }} (variable-length string) */ {% endif %} +{% if maxsize != "0" %} if (value->{{ name }}.len > {{ maxsize }}) return false; +{% endif %} if (xdr_stream_encode_opaque(xdr, value->{{ name }}.data, value->{{ name }}.len) < 0) return false;
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_opaque.j2 +2 -0
@@ -2,7 +2,9 @@ {% if annotate %} /* member {{ name }} (variable-length opaque) */ {% endif %} +{% if maxsize != "0" %} if (value->{{ name }}.len > {{ maxsize }}) return false; +{% endif %} if (xdr_stream_encode_opaque(xdr, value->{{ name }}.data, value->{{ name }}.len) < 0) return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1074/1518 arm64: Disable KCSAN instrumentation in delay.o
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Elver <[email protected]>
[ Upstream commit 5eaec4cf41a8f5ac1a0c69a607cdc5035a797f73 ]
KCSAN relies on udelay() for injecting delays. To avoid recursively triggering a watchpoint, where KCSAN sets up watchpoint on an address that is accessed by udelay() in the same thread, disable instrumentation in arm64's delay implementation.
Paul found a manifestation of this as follows:
| BUG: KCSAN: data-race in __delay / set_need_resched_current | | read (marked) to 0xffff000005899b48 of 8 bytes by interrupt on cpu 8: | __delay+0xb0/0x378 | __udelay+0x4c/0x60 | kcsan_setup_watchpoint+0x3b4/0x820 | __tsan_unaligned_write4+0x228/0x26c | set_need_resched_current+0x138/0x1a8 | rcu_exp_handler+0x418/0x4a0 | __flush_smp_call_function_queue+0x36c/0x4a0 | generic_smp_call_function_single_interrupt+0x20/0x30 | ipi_handler+0xec/0x558 | handle_percpu_devid_irq+0x220/0x2a0 | generic_handle_domain_irq+0x84/0xb4 | gic_handle_irq+0x64/0x144 | call_on_irq_stack+0x30/0x48 | do_interrupt_handler+0x80/0xb8 | el1_interrupt+0x3c/0x60 | el1h_64_irq_handler+0x18/0x24 | el1h_64_irq+0x6c/0x70 | smp_call_function_single+0x18c/0x25c | sync_rcu_exp_select_node_cpus+0x534/0x8bc | rcu_exp_sel_wait_wake+0x358/0xef4 | wait_rcu_exp_gp+0x30/0x44 | kthread_worker_fn+0x1b4/0x5dc | kthread+0x1d8/0x204 | ret_from_fork+0x10/0x20 | | write to 0xffff000005899b4c of 4 bytes by interrupt on cpu 8: | set_need_resched_current+0x138/0x1a8 | [...]
This matches what is already done in arch/x86/lib/Makefile.
--- arch/arm64/lib/Makefile | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/lib/Makefile +4 -0
@@ -1,4 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 + +# KCSAN uses udelay for introducing watchpoint delay; avoid recursion. +KCSAN_SANITIZE_delay.o := n + lib-y := clear_user.o delay.o copy_from_user.o \ copy_to_user.o copy_page.o \ clear_page.o csum.o insn.o memchr.o memcpy.o \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1075/1518 hwmon: (cros_ec) Split up supported features in the documentation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 18ccf48656e010838075fd00caa6d93d3f95d106 ]
The wall of text of supported features is hard to read and messy to extend. Split it into a definition list with an explanations for each supported feature.
Stable-dep-of: 26db27364088 ("hwmon: (cros_ec) Synchronize EC access from the thermal device callbacks")
--- Documentation/hwmon/cros_ec_hwmon.rst | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
Documentation/hwmon/cros_ec_hwmon.rst +17 -6
@@ -23,9 +23,20 @@ ChromeOS embedded controller used in Chromebooks and other devices. The channel labels exposed via hwmon are retrieved from the EC itself. -Fan and temperature readings are supported. PWM fan control is also supported if -the EC also supports setting fan PWM values and fan mode. Note that EC will -switch fan control mode back to auto when suspended. This driver will restore -the fan state to what they were before suspended when resumed. -If a fan is controllable, this driver will register that fan as a cooling device -in the thermal framework as well. +Supported features +------------------ + +Fan readings + Always supported. + +Temperature readings + Always supported. + +PWM fan control + If the EC also supports setting fan PWM values and fan mode. + + Note that EC will switch fan control mode back to auto when suspended. + This driver will restore the fan state to what they were before suspended when resumed. + + If a fan is controllable, this driver will register that fan as a cooling device + in the thermal framework as well.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1076/1518 hwmon: (cros_ec) Move temperature channel params to a macro
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 11c5802d28dd71fffb4df0720eafe840a953dc92 ]
An upcoming change will add more channel parameters. This leads to a lot of churn and very long lines.
Use a macro to encapsulate all of the shared values.
Stable-dep-of: 26db27364088 ("hwmon: (cros_ec) Synchronize EC access from the thermal device callbacks")
--- drivers/hwmon/cros_ec_hwmon.c | 49 ++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 24 deletions(-)
drivers/hwmon/cros_ec_hwmon.c +25 -24
@@ -286,31 +286,32 @@ static const struct hwmon_channel_info * const cros_ec_hwmon_info[] = { HWMON_PWM_INPUT | HWMON_PWM_ENABLE, HWMON_PWM_INPUT | HWMON_PWM_ENABLE, HWMON_PWM_INPUT | HWMON_PWM_ENABLE), +#define CROS_EC_HWMON_TEMP_PARAMS (HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL)HWMON_CHANNEL_INFO (temp, -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL , -HWMON_T_INPUT |HWMON_T_FAULT |HWMON_T_LABEL ), +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS , +CROS_EC_HWMON_TEMP_PARAMS ), NULL };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1077/1518 hwmon: (cros_ec) Add support for temperature thresholds
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit afa7c56ec447315ab38182bb9c185d8ea712c3ad ]
Implement reading temperature thresholds through EC_CMD_THERMAL_GET_THRESHOLD/EC_CMD_THERMAL_SET_THRESHOLD.
Thresholds are mapped as follows between the EC and hwmon:
hwmon_temp_max - EC_TEMP_THRESH_WARNhwmon_temp_crit - EC_TEMP_THRESH_HIGHhwmon_temp_emergency - EC_TEMP_THRESH_HALT
[groeck: Rearrange code to no longer use unreachable() since that causes
a hiccup with some versions of gcc and objtool]
Stable-dep-of: 26db27364088 ("hwmon: (cros_ec) Synchronize EC access from the thermal device callbacks")
--- Documentation/hwmon/cros_ec_hwmon.rst | 3 ++ drivers/hwmon/cros_ec_hwmon.c | 57 +++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 3 deletions(-)
Documentation/hwmon/cros_ec_hwmon.rst +3 -0
@@ -32,6 +32,9 @@ Fan readings Temperature readings Always supported. +Temperature thresholds + If supported by the EC. + PWM fan control If the EC also supports setting fan PWM values and fan mode.
drivers/hwmon/cros_ec_hwmon.c +54 -3
105 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1078/1518 hwmon: Support guard() and scoped_guard for subsystem locks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit d1e720c7328e046049b792d03fae093d4d3a72e4 ]
Add support for guard() and scoped_guard() for the hwmon subsystem lock to simplify its use.
Stable-dep-of: 26db27364088 ("hwmon: (cros_ec) Synchronize EC access from the thermal device callbacks")
--- Documentation/hwmon/hwmon-kernel-api.rst | 7 ++++--- include/linux/hwmon.h | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-)
Documentation/hwmon/hwmon-kernel-api.rst +4 -3
@@ -85,9 +85,10 @@ removal. When using ``[devm_]hwmon_device_register_with_info()`` to register the hardware monitoring device, accesses using the associated access functions are serialised by the hardware monitoring core. If a driver needs locking -for other functions such as interrupt handlers or for attributes which are -fully implemented in the driver, hwmon_lock() and hwmon_unlock() can be used -to ensure that calls to those functions are serialized. +for other functions such as interrupt handlers, attributes which are fully +implemented in the driver, or debugfs functions, hwmon_lock() and hwmon_unlock() +can be used to ensure that calls to those functions are serialized. Those +functions also support guard() and scoped_guard() variants. Using devm_hwmon_device_register_with_info() --------------------------------------------
include/linux/hwmon.h +3 -0
@@ -13,6 +13,7 @@#define _HWMON_H_#include <linux/bitops.h> +#include <linux/cleanup.h> struct device ;struct attribute_group ;
@@ -495,6 +496,8 @@ char *devm_hwmon_sanitize_name(struct device *dev, const char *name);void hwmon_lock (struct device *dev);void hwmon_unlock (struct device *dev); +DEFINE_GUARD(hwmon_lock, struct device *, hwmon_lock(_T), hwmon_unlock(_T)) +/** * hwmon_is_bad_char - Is the char invalid in a hwmon name * @ch: the char to be considered
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1079/1518 hwmon: (cros_ec) Register the thermal devices after the hwmon ones
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 9f1012119f2a4cb5a7f589dc77d5e15dbab49d00 ]
To guarantee consistency for the read-modify-write access in cros_ec_hwmon_cooling_set_cur_state(), locking is necessary. The locking will use standard hwmon device locks, which requires the hwmon device to be ready before the fan devices are set up.
Reorder the initialization so this works.
Stable-dep-of: 26db27364088 ("hwmon: (cros_ec) Synchronize EC access from the thermal device callbacks")
--- drivers/hwmon/cros_ec_hwmon.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/hwmon/cros_ec_hwmon.c +6 -2
@@ -547,13 +547,17 @@ static int cros_ec_hwmon_probe(struct platform_device *pdev) priv->fan_control_supported =cros_ec_hwmon_probe_fan_control_supported (priv->cros_ec); priv->temp_threshold_supported =is_cros_ec_cmd_available (priv->cros_ec,EC_CMD_THERMAL_GET_THRESHOLD ,1 ); -cros_ec_hwmon_register_fan_cooling_devices (dev, priv); hwmon_dev =devm_hwmon_device_register_with_info (dev,"cros_ec" , priv, &cros_ec_hwmon_chip_info,NULL ); +if (IS_ERR (hwmon_dev)) +return PTR_ERR (hwmon_dev); + +cros_ec_hwmon_register_fan_cooling_devices (dev, priv); +platform_set_drvdata (pdev, priv); -return PTR_ERR_OR_ZERO (hwmon_dev); +return 0 ; }static int cros_ec_hwmon_suspend (struct platform_device *pdev,pm_message_t state)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1080/1518 hwmon: (cros_ec) Store the hwmon device in cros_ec_hwmon_priv
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 434baf3aea987ae61d0d54b6cdf8fccf78383b4e ]
The upcoming locking scheme for thermal devices will require access to the hwmon device.
Add it do the priv struct.
Stable-dep-of: 26db27364088 ("hwmon: (cros_ec) Synchronize EC access from the thermal device callbacks")
--- drivers/hwmon/cros_ec_hwmon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/hwmon/cros_ec_hwmon.c +5 -5
@@ -25,6 +25,7 @@struct cros_ec_hwmon_priv {struct cros_ec_device *cros_ec; +struct device *hwmon_dev;const char *temp_sensor_names[EC_TEMP_SENSOR_ENTRIES +EC_TEMP_SENSOR_B_ENTRIES ];u8 usable_fans;bool fan_control_supported;
@@ -524,7 +525,6 @@ static int cros_ec_hwmon_probe(struct platform_device *pdev)struct cros_ec_dev *ec_dev =dev_get_drvdata (dev->parent);struct cros_ec_device *cros_ec = ec_dev->ec_dev;struct cros_ec_hwmon_priv *priv; -struct device *hwmon_dev;u8 thermal_version;int ret;
@@ -548,10 +548,10 @@ static int cros_ec_hwmon_probe(struct platform_device *pdev) priv->temp_threshold_supported =is_cros_ec_cmd_available (priv->cros_ec,EC_CMD_THERMAL_GET_THRESHOLD ,1 ); - hwmon_dev =devm_hwmon_device_register_with_info (dev,"cros_ec" , priv, - &cros_ec_hwmon_chip_info,NULL ); -if (IS_ERR (hwmon_dev)) -return PTR_ERR (hwmon_dev); + priv->hwmon_dev =devm_hwmon_device_register_with_info (dev,"cros_ec" , priv, + &cros_ec_hwmon_chip_info,NULL ); +if (IS_ERR (priv->hwmon_dev)) +return PTR_ERR (priv->hwmon_dev);cros_ec_hwmon_register_fan_cooling_devices (dev, priv);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1081/1518 hwmon: (cros_ec) Synchronize EC access from the thermal device callbacks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 26db273640887276a24ca2546b06e334508871f8 ]
To guarantee consistency for the read-modify-write access in cros_ec_hwmon_cooling_set_cur_state(), locking is necessary.
Use the existing hwmon device lock to do so.
--- drivers/hwmon/cros_ec_hwmon.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/hwmon/cros_ec_hwmon.c +5 -0
@@ -5,6 +5,7 @@* Copyright (C) 2024 Thomas Weißschuh <[email protected]> */ +#include <linux/cleanup.h> #include <linux/device.h> #include <linux/hwmon.h> #include <linux/math.h>
@@ -379,6 +380,8 @@ static int cros_ec_hwmon_cooling_get_cur_state(struct thermal_cooling_device *cdu8 read_val;int ret; +guard (hwmon_lock)(priv->hwmon_priv->hwmon_dev); + ret =cros_ec_hwmon_read_pwm_value (priv->hwmon_priv->cros_ec, priv->index, &read_val);if (ret)return ret;
@@ -392,6 +395,8 @@ static int cros_ec_hwmon_cooling_set_cur_state(struct thermal_cooling_device *cd {const struct cros_ec_hwmon_cooling_priv *priv = cdev->devdata; +guard (hwmon_lock)(priv->hwmon_priv->hwmon_dev); +return cros_ec_hwmon_write_pwm_input (priv->hwmon_priv->cros_ec, priv->index, val); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1082/1518 SUNRPC: check rpc_sockaddr2uaddr() return value in rpcb_register_inet4/6
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit fd22370226a0d8109045d0831fd5aaadee921693 ]
rpcb_register_inet4() and rpcb_register_inet6() store the result of rpc_sockaddr2uaddr() into map->r_addr without checking it for NULL. rpc_sockaddr2uaddr() returns NULL when its final kstrdup() fails, and the unchecked NULL is then carried into the synchronous RPCBPROC_SET encode path: rpcb_register_call() -> rpc_call_sync() -> rpcb_enc_getaddr() -> encode_rpcb_string(), whose first statement is strlen(string), dereferencing NULL and oopsing the kernel.
The crash reproduces under failslab on v6.12; with KASAN the NULL dereference surfaces as a fault on the shadow of address zero:
Oops: general protection fault, probably for non-canonical address
0xdffffc0000000000 [#1] PREEMPT SMP KASAN
RIP: 0010:strlen (lib/string.c:409)
Call Trace:
encode_rpcb_string (net/sunrpc/rpcb_clnt.c:890)
rpcb_enc_getaddr (net/sunrpc/rpcb_clnt.c:910)
rpcauth_wrap_req_encode (net/sunrpc/auth.c:745)
call_encode (net/sunrpc/clnt.c:1966)
__rpc_execute (net/sunrpc/sched.c:952)
rpc_run_task (net/sunrpc/clnt.c:1243)
rpc_call_sync (net/sunrpc/clnt.c:1272)
rpcb_v4_register (net/sunrpc/rpcb_clnt.c:500)
svc_generic_rpcbind_set
nfsd_rpcbind_set
svc_register
svc_setup_socket
svc_addsock
write_ports
nfsctl_transaction_write
vfs_writeThe crash is reachable when an in-kernel RPC service (nfsd, lockd, nfs-callback) registers with the local rpcbind under enough memory pressure for the small GFP_KERNEL kstrdup() in rpc_sockaddr2uaddr() to fail. The asynchronous getport path already handles this exact failure mode by returning -ENOMEM; only the two register helpers omit the check.
Mirror that handling: bail out with -ENOMEM when rpc_sockaddr2uaddr() returns NULL, before the address is fed into the encoder.
--- net/sunrpc/rpcb_clnt.c | 4 ++++ 1 file changed, 4 insertions(+)
net/sunrpc/rpcb_clnt.c +4 -0
@@ -490,6 +490,8 @@ static int rpcb_register_inet4(struct sunrpc_net *sn,int result; map->r_addr =rpc_sockaddr2uaddr (sap,GFP_KERNEL ); +if (!map->r_addr) +return -ENOMEM ; msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET ];if (port !=0 ) {
@@ -516,6 +518,8 @@ static int rpcb_register_inet6(struct sunrpc_net *sn,int result; map->r_addr =rpc_sockaddr2uaddr (sap,GFP_KERNEL ); +if (!map->r_addr) +return -ENOMEM ; msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET ];if (port !=0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1083/1518 sunrpc: xprtsock: annotate shared socket callbacks with READ_ONCE/WRITE_ONCE
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 33930840b5f0a79f826e7c69dc6cd78f72a67481 ]
xprtsock replaces and restores sk->sk_data_ready and sk->sk_write_space on live sockets with plain stores, and xs_udp_do_set_buffer_size() invokes sk->sk_write_space via a plain load. These callback pointers are shared with generic socket and protocol paths that may read or invoke them concurrently, so xprtsock needs the same READ_ONCE()/WRITE_ONCE() callback visibility contract that the validated 4022 family applied elsewhere.
When SUNRPC takes over an AF_LOCAL, UDP, or TCP socket and later restores the lower-socket callbacks during teardown, another CPU may still hold an earlier callback snapshot. The plain replace/restore pattern leaves the same visibility hole as the validated 4022 family, so a stale snapshot can still invoke xs_data_ready() or xs_udp_write_space() after the live callback fields have already been restored to the lower-socket handlers.
Use WRITE_ONCE() for the shared sk_data_ready and sk_write_space stores in xs_local_finish_connecting(), xs_udp_finish_connecting(), xs_tcp_finish_connecting(), and xs_restore_old_callbacks(). Use READ_ONCE() for the direct sk_write_space invocation in xs_udp_do_set_buffer_size(). This matches the required callback visibility contract while leaving adjacent sk_state_change and sk_error_report handling unchanged.
--- net/sunrpc/xprtsock.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
net/sunrpc/xprtsock.c +11 -9
@@ -1202,9 +1202,9 @@ static void xs_save_old_callbacks(struct sock_xprt *transport, struct sock *sk)static void xs_restore_old_callbacks (struct sock_xprt *transport,struct sock *sk) { - sk->sk_data_ready = transport->old_data_ready; +WRITE_ONCE (sk->sk_data_ready, transport->old_data_ready); sk->sk_state_change = transport->old_state_change; - sk->sk_write_space = transport->old_write_space; +WRITE_ONCE (sk->sk_write_space, transport->old_write_space); sk->sk_error_report = transport->old_error_report; }
@@ -1664,6 +1664,7 @@ static void xs_udp_do_set_buffer_size(struct rpc_xprt *xprt) { struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);struct sock *sk = transport->inet; +void (*write_space)(struct sock *sock);if (transport->rcvsize) { sk->sk_userlocks |=SOCK_RCVBUF_LOCK ;
@@ -1672,7 +1673,8 @@ static void xs_udp_do_set_buffer_size(struct rpc_xprt *xprt)if (transport->sndsize) { sk->sk_userlocks |=SOCK_SNDBUF_LOCK ; sk->sk_sndbuf = transport->sndsize * xprt->max_reqs *2 ; - sk->sk_write_space (sk); + write_space =READ_ONCE (sk->sk_write_space); +write_space (sk); } }
@@ -1988,8 +1990,8 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt,xs_save_old_callbacks (transport, sk); sk->sk_user_data = xprt; - sk->sk_data_ready = xs_data_ready; - sk->sk_write_space = xs_udp_write_space; +WRITE_ONCE (sk->sk_data_ready, xs_data_ready); +WRITE_ONCE (sk->sk_write_space, xs_udp_write_space); sk->sk_state_change = xs_local_state_change; sk->sk_error_report = xs_error_report; sk->sk_use_task_frag = false;
@@ -2191,8 +2193,8 @@ static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)xs_save_old_callbacks (transport, sk); sk->sk_user_data = xprt; - sk->sk_data_ready = xs_data_ready; - sk->sk_write_space = xs_udp_write_space; +WRITE_ONCE (sk->sk_data_ready, xs_data_ready); +WRITE_ONCE (sk->sk_write_space, xs_udp_write_space); sk->sk_use_task_frag = false;xprt_set_connected (xprt);
@@ -2378,9 +2380,9 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)xs_save_old_callbacks (transport, sk); sk->sk_user_data = xprt; - sk->sk_data_ready = xs_data_ready; +WRITE_ONCE (sk->sk_data_ready, xs_data_ready); sk->sk_state_change = xs_tcp_state_change; - sk->sk_write_space = xs_tcp_write_space; +WRITE_ONCE (sk->sk_write_space, xs_tcp_write_space); sk->sk_error_report = xs_error_report; sk->sk_use_task_frag = false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1084/1518 nvmet: fix Reservation Register Replace for unregistered host with IEKEY
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhengrong Li <[email protected]>
[ Upstream commit 0a96b9e440331bffbf049f80d7e5c96417d37e36 ]
When a host sends a Reservation Register command with RREGA=Replace and IEKEY=1 without being previously registered, nvmet returns Reservation Conflict.
The NVMe specification states:
"A host may replace its reservation key without regard to its
registration status or current reservation key value by setting the Ignore Existing Key (IEKEY) bit to '1' in the Reservation Register command."
Fix nvmet_pr_replace() to add a new registrant when the host is not found in the registrant list and IEKEY is set with a non-zero NRKEY. If IEKEY is set but NRKEY is zero, return Invalid Field since there is no valid reservation key to register.
Tested with nvme-cli against nvmet-tcp:
# no prior registration nvme resv-register /dev/nvmeXn1 -n 1 --rrega=2 --iekey --nrkey=0x9999
Before: RESERVATION_CONFLICT (0x4083)
After: success, registrant created with rkey 0x9999
--- drivers/nvme/target/pr.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
drivers/nvme/target/pr.c +25 -2
@@ -355,9 +355,15 @@ static u16 nvmet_pr_replace(struct nvmet_req *req,u16 status =NVME_SC_RESERVATION_CONFLICT |NVME_STATUS_DNR ;struct nvmet_ctrl *ctrl = req->sq->ctrl;struct nvmet_pr *pr = &req->ns->pr; -struct nvmet_pr_registrant *reg; +struct nvmet_pr_registrant *reg, *new =NULL ;u64 nrkey =le64_to_cpu (d->nrkey); +if (ignore_key && nrkey) { + new =kzalloc_obj (*new); +if (!new) +return NVME_SC_INTERNAL ; + } +down (&pr->pr_sem);list_for_each_entry_rcu (reg, &pr->registrant_list, entry) {if (uuid_equal (®->hostid, &ctrl->hostid)) {
@@ -365,9 +371,26 @@ static u16 nvmet_pr_replace(struct nvmet_req *req, status =nvmet_pr_update_reg_attr (pr, reg, nvmet_pr_update_reg_rkey, &nrkey); -break ; + goto free_data; + } + } + +if (ignore_key) { +if (!nrkey) { + status =NVME_SC_INVALID_FIELD |NVME_STATUS_DNR ; + goto free_data; } +INIT_LIST_HEAD (&new->entry); + new->rkey = nrkey; +uuid_copy (&new->hostid, &ctrl->hostid); +list_add_tail_rcu (&new->entry, &pr->registrant_list); + status =NVME_SC_SUCCESS ; + goto out; } + +free_data: +kfree (new); +out:up (&pr->pr_sem);return status; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1085/1518 nvmet: propagate percpu_ref_init() failure in nvmet_ns_enable()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit 751709592d2626eaa8dc17ef8137796758a3c37f ]
The return value of percpu_ref_init() is discarded. At this point ret is 0 from the preceding successful steps, so when the allocation inside percpu_ref_init() fails the code jumps to the out_pr_exit cleanup chain which ends with "return ret", i.e. reports success. The configfs enable store then tells userspace the namespace was enabled even though it was not and its backing device has already been torn down.
Capture the return value so the failure is propagated.
--- drivers/nvme/target/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/target/core.c +2 -1
@@ -601,7 +601,8 @@ int nvmet_ns_enable(struct nvmet_ns *ns) goto out_dev_put; } -if (percpu_ref_init (&ns->ref, nvmet_destroy_namespace,0 ,GFP_KERNEL )) + ret =percpu_ref_init (&ns->ref, nvmet_destroy_namespace,0 ,GFP_KERNEL ); +if (ret) goto out_pr_exit;nvmet_ns_changed (subsys, ns->nsid);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1086/1518 nvme-pci: release descriptor pools on probe failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <[email protected]>
[ Upstream commit cb144c2f67128abfa5c7ba33318617d19f192156 ]
The per-NUMA-node descriptor DMA pools are created lazily from nvme_init_hctx_common() once the admin tag set is allocated, but they are only destroyed in nvme_remove() via nvme_release_descriptor_pools(). Any probe failure after the admin tag set has been allocated unwinds through the out_disable label and nvme_pci_free_ctrl(), neither of which releases the pools, leaking the dma_pool objects.
Release the descriptor pools in the out_disable error path. It must not be added to nvme_pci_free_ctrl(), as that would double-free against nvme_remove() on the normal teardown path.
--- drivers/nvme/host/pci.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvme/host/pci.c +1 -0
@@ -3557,6 +3557,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)nvme_dev_remove_admin (dev);nvme_dbbuf_dma_free (dev);nvme_free_queues (dev,0 ); +nvme_release_descriptor_pools (dev); out_release_iod_mempool:mempool_destroy (dev->dmavec_mempool); out_dev_unmap:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1087/1518 cgroup/cpuset: Rename update_unbound_workqueue_cpumask() to update_isolation_cpumasks()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabriele Monaco <[email protected]>
[ Upstream commit 55939cf28a48dad27d6906e57d3b45905bb0d001 ]
update_unbound_workqueue_cpumask() updates unbound workqueues settings when there's a change in isolated CPUs, but it can be used for other subsystems requiring updated when isolated CPUs change.
Generalise the name to update_isolation_cpumasks() to prepare for other functions unrelated to workqueues to be called in that spot.
[longman: Change the function name to update_isolation_cpumasks()]
Stable-dep-of: 26d3a59e0241 ("cgroup/cpuset: Use WRITE_ONCE() for shared prs_err updates")
--- kernel/cgroup/cpuset.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/cgroup/cpuset.c +6 -6
@@ -1410,7 +1410,7 @@ static bool partition_xcpus_del(int old_prs, struct cpuset *parent,return isolcpus_updated; } -static void update_unbound_workqueue_cpumask (bool isolcpus_updated) +static void update_isolation_cpumasks (bool isolcpus_updated) {int ret;
@@ -1574,7 +1574,7 @@ static int remote_partition_enable(struct cpuset *cs, int new_prs,list_add (&cs->remote_sibling, &remote_children);cpumask_copy (cs->effective_xcpus, tmp->new_cpus);spin_unlock_irq (&callback_lock); -update_unbound_workqueue_cpumask (isolcpus_updated); +update_isolation_cpumasks (isolcpus_updated);cpuset_force_rebuild (); cs->prs_err =0 ;
@@ -1622,7 +1622,7 @@ static void remote_partition_disable(struct cpuset *cs, struct tmpmasks *tmp)compute_excpus (cs, cs->effective_xcpus);reset_partition_data (cs);spin_unlock_irq (&callback_lock); -update_unbound_workqueue_cpumask (isolcpus_updated); +update_isolation_cpumasks (isolcpus_updated);cpuset_force_rebuild ();/*
@@ -1691,7 +1691,7 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *xcpus,if (xcpus)cpumask_copy (cs->exclusive_cpus, xcpus);spin_unlock_irq (&callback_lock); -update_unbound_workqueue_cpumask (isolcpus_updated); +update_isolation_cpumasks (isolcpus_updated);if (adding || deleting)cpuset_force_rebuild ();
@@ -2049,7 +2049,7 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,WARN_ON_ONCE (parent->nr_subparts <0 ); }spin_unlock_irq (&callback_lock); -update_unbound_workqueue_cpumask (isolcpus_updated); +update_isolation_cpumasks (isolcpus_updated);if ((old_prs != new_prs) && (cmd == partcmd_update))update_partition_exclusive_flag (cs, new_prs);
@@ -3074,7 +3074,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)else if (isolcpus_updated)isolated_cpus_update (old_prs, new_prs, cs->effective_xcpus);spin_unlock_irq (&callback_lock); -update_unbound_workqueue_cpumask (isolcpus_updated); +update_isolation_cpumasks (isolcpus_updated);/* Force update if switching back to member & update effective_xcpus */ update_cpumasks_hier (cs, &tmpmask, !new_prs);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1088/1518 cgroup/cpuset: Fail if isolated and nohz_full dont leave any housekeeping
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Waiman Long <[email protected]>
[ Upstream commit 103b08709e8a59876980a8edddf4e68f3a23e34e ]
Currently the user can set up isolated cpus via cpuset and nohz_full in such a way that leaves no housekeeping CPU (i.e. no CPU that is neither domain isolated nor nohz full). This can be a problem for other subsystems (e.g. the timer wheel imgration).
Prevent this configuration by blocking any assignation that would cause the union of domain isolated cpus and nohz_full to covers all CPUs.
[longman: Remove isolated_cpus_should_update() and rewrite the checking
in update_prstate() and update_parent_effective_cpumask()]
Stable-dep-of: 26d3a59e0241 ("cgroup/cpuset: Use WRITE_ONCE() for shared prs_err updates")
--- kernel/cgroup/cpuset.c | 74 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-)
kernel/cgroup/cpuset.c +73 -1
@@ -1410,6 +1410,45 @@ static bool partition_xcpus_del(int old_prs, struct cpuset *parent,return isolcpus_updated; } +/* +* isolated_cpus_can_update - check for isolated & nohz_full conflicts +* @add_cpus: cpu mask for cpus that are going to be isolated +* @del_cpus: cpu mask for cpus that are no longer isolated, can be NULL +* Return: false if there is conflict, true otherwise +* +* If nohz_full is enabled and we have isolated CPUs, their combination must +* still leave housekeeping CPUs. +* +* TBD: Should consider merging this function into +* prstate_housekeeping_conflict(). +*/ +static bool isolated_cpus_can_update (struct cpumask *add_cpus, +struct cpumask *del_cpus) +{ +cpumask_var_t full_hk_cpus; +int res = true; + +if (!housekeeping_enabled (HK_TYPE_KERNEL_NOISE )) +return true; + +if (del_cpus &&cpumask_weight_and (del_cpus, +housekeeping_cpumask (HK_TYPE_KERNEL_NOISE ))) +return true; + +if (!alloc_cpumask_var (&full_hk_cpus,GFP_KERNEL )) +return false; + +cpumask_and (full_hk_cpus,housekeeping_cpumask (HK_TYPE_KERNEL_NOISE ), +housekeeping_cpumask (HK_TYPE_DOMAIN )); +cpumask_andnot (full_hk_cpus, full_hk_cpus, isolated_cpus); +cpumask_and (full_hk_cpus, full_hk_cpus, cpu_active_mask); +if (!cpumask_weight_andnot (full_hk_cpus, add_cpus)) + res = false; + +free_cpumask_var (full_hk_cpus); +return res; +} +static void update_isolation_cpumasks (bool isolcpus_updated) {int ret;
@@ -1568,6 +1607,9 @@ static int remote_partition_enable(struct cpuset *cs, int new_prs,if (!cpumask_intersects (tmp->new_cpus, cpu_active_mask) ||cpumask_subset (top_cpuset.effective_cpus, tmp->new_cpus))return PERR_INVCPUS ; +if ((new_prs ==PRS_ISOLATED ) && + !isolated_cpus_can_update (tmp->new_cpus,NULL )) +return PERR_HKEEPING ;spin_lock_irq (&callback_lock); isolcpus_updated =partition_xcpus_add (new_prs,NULL , tmp->new_cpus);
@@ -1674,6 +1716,9 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *xcpus,else if (cpumask_intersects (tmp->addmask, subpartitions_cpus) ||cpumask_subset (top_cpuset.effective_cpus, tmp->addmask)) cs->prs_err =PERR_NOCPUS ; +else if ((prs ==PRS_ISOLATED ) && + !isolated_cpus_can_update (tmp->addmask, tmp->delmask)) + cs->prs_err =PERR_HKEEPING ;if (cs->prs_err) goto invalidate; }
@@ -1775,6 +1820,7 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,int subparts_delta =0 ;int isolcpus_updated =0 ;struct cpumask *xcpus =user_xcpus (cs); +int parent_prs = parent->partition_root_state;bool nocpu;lockdep_assert_held (&cpuset_mutex);
@@ -1839,6 +1885,10 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,if (prstate_housekeeping_conflict (new_prs, xcpus))return PERR_HKEEPING ; +if ((new_prs ==PRS_ISOLATED ) && (new_prs != parent_prs) && + !isolated_cpus_can_update (xcpus,NULL )) +return PERR_HKEEPING ; +if (tasks_nocpu_error (parent, cs, xcpus))return PERR_NOCPUS ;
@@ -1894,6 +1944,7 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,* * For invalid partition: * delmask = newmask & parent->effective_xcpus +* The partition may become valid soon. */ if (is_partition_invalid (cs)) { adding = false;
@@ -1908,6 +1959,23 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd, deleting =cpumask_and (tmp->delmask, tmp->delmask, parent->effective_xcpus); } + +/* +* TBD: Invalidate a currently valid child root partition may +* still break isolated_cpus_can_update() rule if parent is an +* isolated partition. +*/ +if (is_partition_valid (cs) && (old_prs != parent_prs)) { +if ((parent_prs ==PRS_ROOT ) && +/* Adding to parent means removing isolated CPUs */ + !isolated_cpus_can_update (tmp->delmask, tmp->addmask)) + part_error =PERR_HKEEPING ; +if ((parent_prs ==PRS_ISOLATED ) && +/* Adding to parent means adding isolated CPUs */ + !isolated_cpus_can_update (tmp->addmask, tmp->delmask)) + part_error =PERR_HKEEPING ; + } +/* * The new CPUs to be removed from parent's effective CPUs * must be present.
@@ -3039,7 +3107,11 @@ static int update_prstate(struct cpuset *cs, int new_prs)* A change in load balance state only, no change in cpumasks. * Need to update isolated_cpus. */ - isolcpus_updated = true; +if ((new_prs ==PRS_ISOLATED ) && + !isolated_cpus_can_update (cs->effective_xcpus,NULL )) + err =PERR_HKEEPING ; +else + isolcpus_updated = true; }else {/* * Switching back to member is always allowed even if it
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1089/1518 cgroup/cpuset: Use WRITE_ONCE() for shared prs_err updates
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guopeng Zhang <[email protected]>
[ Upstream commit 26d3a59e0241c3ef9f66ae1ae990f9326acbc059 ]
cpuset_partition_show() reads cs->prs_err without cpuset_mutex using READ_ONCE(). The field is documented as not lock protected, but several updates to live cpusets still use plain stores.
Convert the remaining prs_err stores on live cpusets to WRITE_ONCE().
--- kernel/cgroup/cpuset.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
kernel/cgroup/cpuset.c +13 -11
@@ -1618,7 +1618,7 @@ static int remote_partition_enable(struct cpuset *cs, int new_prs,spin_unlock_irq (&callback_lock);update_isolation_cpumasks (isolcpus_updated);cpuset_force_rebuild (); - cs->prs_err =0 ; +WRITE_ONCE (cs->prs_err,0 );/* * Propagate changes in top_cpuset's effective_cpus down the hierarchy.
@@ -1697,7 +1697,7 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *xcpus,WARN_ON_ONCE (!cpumask_subset (cs->effective_xcpus, subpartitions_cpus));if (cpumask_empty (excpus)) { - cs->prs_err =PERR_CPUSEMPTY ; +WRITE_ONCE (cs->prs_err,PERR_CPUSEMPTY ); goto invalidate; }
@@ -1712,13 +1712,13 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *xcpus,if (adding) {WARN_ON_ONCE (cpumask_intersects (tmp->addmask, subpartitions_cpus));if (!capable (CAP_SYS_ADMIN )) - cs->prs_err =PERR_ACCESS ; +WRITE_ONCE (cs->prs_err,PERR_ACCESS );else if (cpumask_intersects (tmp->addmask, subpartitions_cpus) ||cpumask_subset (top_cpuset.effective_cpus, tmp->addmask)) - cs->prs_err =PERR_NOCPUS ; +WRITE_ONCE (cs->prs_err,PERR_NOCPUS );else if ((prs ==PRS_ISOLATED ) && !isolated_cpus_can_update (tmp->addmask, tmp->delmask)) - cs->prs_err =PERR_HKEEPING ; +WRITE_ONCE (cs->prs_err,PERR_HKEEPING );if (cs->prs_err) goto invalidate; }
@@ -2183,13 +2183,13 @@ static void compute_partition_effective_cpumask(struct cpuset *cs,* partition root. */ WARN_ON_ONCE (is_remote_partition (child)); - child->prs_err =0 ; +WRITE_ONCE (child->prs_err,0 );if (!cpumask_subset (child->effective_xcpus, cs->effective_xcpus)) - child->prs_err =PERR_INVCPUS ; +WRITE_ONCE (child->prs_err,PERR_INVCPUS );else if (populated &&cpumask_subset (new_ecpus, child->effective_xcpus)) - child->prs_err =PERR_NOCPUS ; +WRITE_ONCE (child->prs_err,PERR_NOCPUS );if (child->prs_err) {int old_prs = child->partition_root_state;
@@ -2556,8 +2556,10 @@ static void partition_cpus_change(struct cpuset *cs, struct cpuset *trialcs,return ; prs_err =validate_partition (cs, trialcs); -if (prs_err) - trialcs->prs_err = cs->prs_err = prs_err; +if (prs_err) { +WRITE_ONCE (cs->prs_err, prs_err); + trialcs->prs_err = prs_err; + }if (is_remote_partition (cs)) {if (trialcs->prs_err)
@@ -4014,7 +4016,7 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)if (remote && (cpumask_empty (subpartitions_cpus) || (cpumask_empty (&new_cpus) &&partition_is_populated (cs,NULL )))) { - cs->prs_err =PERR_HOTPLUG ; +WRITE_ONCE (cs->prs_err,PERR_HOTPLUG );remote_partition_disable (cs, tmp);compute_effective_cpumask (&new_cpus, cs, parent); remote = false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1090/1518 selftests/sched_ext: Check skeleton open failure in exit test
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liang Luo <[email protected]>
[ Upstream commit 4dc310b41aba43e9d8dfafe46dce86f8b55c0354 ]
exit.c does not check the return value of exit__open(). If it returns NULL, which happens when the skeleton wrapper fails to allocate the object or open the BPF ELF, the very next line dereferences it via SCX_ENUM_INIT(). That macro expands to SCX_ENUM_SET(), which accesses skel->rodata, causing a NULL pointer dereference.
Every other selftest guards this with SCX_FAIL_IF(!skel, ...); exit.c is the only one missing it.
--- tools/testing/selftests/sched_ext/exit.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/sched_ext/exit.c +1 -0
@@ -31,6 +31,7 @@ static enum scx_test_status run(void *ctx)continue ; skel =exit__open (); +SCX_FAIL_IF (!skel,"Failed to open" );SCX_ENUM_INIT (skel); skel->rodata->exit_point = tc;SCX_FAIL_IF (exit__load (skel),"Failed to load skel" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1091/1518 amt: Dont support cross-netns setup.
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit e99ecc3046ea5f5c6b5e1f8b4ef854c6c6998e06 ]
When a lower device is unregistered, amt_device_event() tries to unregister its upper AMT device, but it has two problems.
1. amt_lookup_upper_dev() looks up an upper device in the lower device's netns only
2. amt_device_event() unregisters a single upper device only
If AMT device is created on a lower device in another netns, removing the lower device triggers the splat below and gets stuck until all upper devices are removed. [0]
The cross-netns setup seems unintentional considering 1. and the following points:
* amt_link_setup() sets dev->netns_immutable to true
* skb_scrub_packet() is not called in the fast path
* iproute2 binary fails to find cross-netns lower device via link-netns:
# ip -n ns1 link add amt0 link-netns ns2 type amt dev veth1 Cannot find device "veth1"
Instead of supporting it properly and preparing for per-netns netdev unreg, let's forbid cross-netns setup.
Note that the problem 2. needs a separate fix.
[0]:
WARNING: net/core/dev.c:12518 at unregister_netdevice_many_notify+0x1cce/0x2250, CPU#48: ip/2031
Modules linked in:
CPU: 48 UID: 0 PID: 2031 Comm: ip Not tainted 7.2.0-rc5+ #27 PREEMPT(full)
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-debian-1.17.0-1 04/01/2014
RIP: 0010:unregister_netdevice_many_notify (net/core/dev.c:12518)
Code: 89 ef e8 d5 52 ae fe e9 d0 f4 ff ff 48 8d 3d f9 3b 9c 02 48 c7 c6 c0 0b 63 84 ba ab 1f 00 00 67 48 0f b9 3a e9 65 ff ff ff 90 <0f> 0b 90 eb 81 48 8d 3d f6 3b 9c 02 48 c7 c6 c0 0b 63 84 ba e2 1f
RSP: 0018:ffffc90004abf160 EFLAGS: 00010212
RAX: ffff888104d38260 RBX: ffff88800b0911b8 RCX: dffffc0000000000
RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffffffff85b9f880
RBP: ffffc90004abf2d0 R08: ffffffff85b9f887 R09: 1ffffffff0b73f10
R10: dffffc0000000000 R11: fffffbfff0b73f11 R12: ffff88800b091d08
R13: ffff88800b091178 R14: dffffc0000000000 R15: ffff88800b091000
FS: 00007f555b86c600(0000) GS:ffff8881942a0000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000562107d489c0 CR3: 0000000109a40002 CR4: 0000000000372ef0
Call Trace:
<TASK>
rtnl_dellink (net/core/rtnetlink.c:3632 net/core/rtnetlink.c:3674)
rtnetlink_rcv_msg (net/core/rtnetlink.c:7112)
netlink_rcv_skb (net/netlink/af_netlink.c:2556)
netlink_unicast (net/netlink/af_netlink.c:1319)
netlink_sendmsg (net/netlink/af_netlink.c:1900)
____sys_sendmsg (net/socket.c:775)
__sys_sendmsg (net/socket.c:2738)
do_syscall_64 (arch/x86/entry/syscall_64.c:63)
entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
...
unregister_netdevice: waiting for veth0 to become free. Usage count = 7
ref_tracker: netdev@ffff88800d7496d8 has 3/3 users at
__netdev_adjacent_dev_insert (./include/linux/netdevice.h:4525 ./include/linux/netdevice.h:4554 net/core/dev.c:8791)
__netdev_upper_dev_link (net/core/dev.c:8879 net/core/dev.c:8963)
netdev_upper_dev_link (net/core/dev.c:9009)
amt_newlink (drivers/net/amt.c:3321)--- drivers/net/amt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/amt.c +3 -0
@@ -3221,6 +3221,9 @@ static int amt_newlink(struct net_device *dev,struct nlattr **tb = params->tb;int err = -EINVAL ; +if (!net_eq (link_net,dev_net (dev))) +return err; + amt->net = link_net; amt->mode =nla_get_u32 (data[IFLA_AMT_MODE ]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1092/1518 powerpc/configs: enable CONFIG_RAS to fix EDAC support
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Walle <[email protected]>
[ Upstream commit 3921cfc2e8155a767235801be88cbd0e4c73508d ]
Before commit e3c4ff6d8c94 ("EDAC: Remove EDAC_MM_EDAC") EDAC_MM_EDAC selected RAS, after that commit, EDAC depends on RAS, but nobody enables it. Enable it in the config again.
--- arch/powerpc/configs/85xx-hw.config | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/configs/85xx-hw.config +1 -0
@@ -90,6 +90,7 @@ CONFIG_PPC_EPAPR_HV_BYTECHAN=y CONFIG_QE_GPIO=y CONFIG_QUICC_ENGINE=y CONFIG_RAPIDIO=y +CONFIG_RAS=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_CMOS=y CONFIG_RTC_DRV_DS1307=y
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1093/1518 apparmor: split xxx_in_ns into its two separate semantic use cases
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Johansen <[email protected]>
[ Upstream commit 796c146fa6c8289afc9e18004c21bfe05c75a487 ]
This patch doesn't change current functionality, it switches the two uses of the in_ns fns and macros into the two semantically different cases they are used for.
xxx_in_scope for checking mediation interaction between profiles xxx_in_view to determine which profiles are visible.The scope will always be a subset of the view as profiles that can not see each other can not interact.
The split can not be completely done for label_match because it has to distinct uses matching permission against label in scope, and checking if a transition to a profile is allowed. The transition to a profile can include profiles that are in view but not in scope, so retain this distinction as a parameter.
While at the moment the two uses are very similar, in the future there will be additional differences. So make sure the semantics differences are present in the code.
Stable-dep-of: 08c2f7c8d4b1 ("apparmor: fix unconfined user namespace restriction forced stack")
--- security/apparmor/af_unix.c | 2 +- security/apparmor/apparmorfs.c | 2 +- security/apparmor/domain.c | 58 +++++++++++++++++---------------- security/apparmor/include/lib.h | 19 +++++++++-- security/apparmor/label.c | 26 +++++++-------- 5 files changed, 61 insertions(+), 46 deletions(-)
security/apparmor/af_unix.c +1 -1
@@ -416,7 +416,7 @@ static int profile_peer_perm(struct aa_profile *profile, u32 request,unix_sk (sk), peer_addr, peer_addrlen, &p, &ad->info); -return fn_for_each_in_ns (peer_label, peerp, +return fn_for_each_in_scope (peer_label, peerp,match_label (profile, rules, state, request, peerp, p, ad)); }
security/apparmor/apparmorfs.c +1 -1
@@ -877,7 +877,7 @@ static ssize_t query_label(char *buf, size_t buf_len, perms = allperms;if (view_only) { -label_for_each_in_ns (i,labels_ns (label), label, profile) { +label_for_each_in_scope (i,labels_ns (label), label, profile) {profile_query_cb (profile, &perms, match_str, match_len); } }else {
security/apparmor/domain.c +30 -28
212 lines not on this page · raw message
security/apparmor/include/lib.h +16 -3
@@ -76,6 +76,19 @@ int aa_print_debug_params(char *buffer);/* Flag indicating whether initialization completed */ extern int apparmor_initialized; +/* semantic split of scope and view */ +#define aa_in_scope (SUBJ ,OBJ ) \ + aa_ns_visible(SUBJ, OBJ, false) + +#define aa_in_view (SUBJ ,OBJ ) \ + aa_ns_visible(SUBJ, OBJ, true) + +#define label_for_each_in_scope (I ,NS ,L ,P ) \ + label_for_each_in_ns(I, NS, L, P) + +#define fn_for_each_in_scope (L ,P ,FN ) \ + fn_for_each_in_ns(L, P, FN) +/* fn's in lib */ const char *skipn_spaces (const char *str,size_t n); const char *aa_splitn_fqname(const char *fqname, size_t n, const char **ns_name,
@@ -318,7 +331,7 @@ __done: \ }) -#define __fn_build_in_ns (NS ,P ,NS_FN ,OTHER_FN ) \ +#define __fn_build_in_scope (NS ,P ,NS_FN ,OTHER_FN ) \ ({ \ struct aa_label *__new; \ if ((P)->ns != (NS)) \
@@ -328,10 +341,10 @@ __done: \ (__new); \ }) -#define fn_label_build_in_ns (L ,P ,GFP ,NS_FN ,OTHER_FN ) \ +#define fn_label_build_in_scope (L ,P ,GFP ,NS_FN ,OTHER_FN ) \ ({ \ fn_label_build((L), (P), (GFP), \ - __fn_build_in_ns(labels_ns(L), (P), (NS_FN), (OTHER_FN))); \ + __fn_build_in_scope(labels_ns(L), (P), (NS_FN), (OTHER_FN))); \ })#endif /* __AA_LIB_H */
security/apparmor/label.c +13 -13
@@ -1278,7 +1278,7 @@ static inline aa_state_t match_component(struct aa_profile *profile,* @rules: ruleset to search * @label: label to check access permissions for * @state: state to start match in -* @subns: whether to do permission checks on components in a subns +* @inview: whether to match labels in view or only in scope * @request: permissions to request * @perms: perms struct to set *
@@ -1291,7 +1291,7 @@ static inline aa_state_t match_component(struct aa_profile *profile,static int label_compound_match (struct aa_profile *profile,struct aa_ruleset *rules,struct aa_label *label, -aa_state_t state,bool subns,u32 request, +aa_state_t state,bool inview,u32 request,struct aa_perms *perms) {struct aa_profile *tp;
@@ -1299,7 +1299,7 @@ static int label_compound_match(struct aa_profile *profile,/* find first subcomponent that is visible */ label_for_each (i, label, tp) { -if (!aa_ns_visible (profile->ns, tp->ns, subns)) +if (!aa_ns_visible (profile->ns, tp->ns, inview))continue ; state =match_component (profile, rules, tp, state);if (!state)
@@ -1313,7 +1313,7 @@ static int label_compound_match(struct aa_profile *profile, next:label_for_each_cont (i, label, tp) { -if (!aa_ns_visible (profile->ns, tp->ns, subns)) +if (!aa_ns_visible (profile->ns, tp->ns, inview))continue ; state =aa_dfa_match (rules->policy->dfa, state,"//&" ); state =match_component (profile, rules, tp, state);
@@ -1334,7 +1334,7 @@ static int label_compound_match(struct aa_profile *profile,* @rules: ruleset to search * @label: label to check access permissions for * @start: state to start match in -* @subns: whether to do permission checks on components in a subns +* @subns: whether to match labels in view or only in scope * @request: permissions to request * @perms: an initialized perms struct to add accumulation to *
@@ -1347,7 +1347,7 @@ static int label_compound_match(struct aa_profile *profile,static int label_components_match (struct aa_profile *profile,struct aa_ruleset *rules,struct aa_label *label,aa_state_t start, -bool subns,u32 request, +bool inview,u32 request,struct aa_perms *perms) {struct aa_profile *tp;
@@ -1357,7 +1357,7 @@ static int label_components_match(struct aa_profile *profile,/* find first subcomponent to test */ label_for_each (i, label, tp) { -if (!aa_ns_visible (profile->ns, tp->ns, subns)) +if (!aa_ns_visible (profile->ns, tp->ns, inview))continue ; state =match_component (profile, rules, tp, start);if (!state)
@@ -1372,7 +1372,7 @@ static int label_components_match(struct aa_profile *profile, tmp = *aa_lookup_perms (rules->policy, state);aa_perms_accum (perms, &tmp);label_for_each_cont (i, label, tp) { -if (!aa_ns_visible (profile->ns, tp->ns, subns)) +if (!aa_ns_visible (profile->ns, tp->ns, inview))continue ; state =match_component (profile, rules, tp, start);if (!state)
@@ -1397,24 +1397,24 @@ static int label_components_match(struct aa_profile *profile,* @rules: ruleset to search * @label: label to match (NOT NULL) * @state: state to start in -* @subns: whether to match subns components +* @subns: whether to match labels in view or only in scope * @request: permission request * @perms: Returns computed perms (NOT NULL) * * Returns: the state the match finished in, may be the none matching state */ int aa_label_match (struct aa_profile *profile,struct aa_ruleset *rules, -struct aa_label *label,aa_state_t state,bool subns, +struct aa_label *label,aa_state_t state,bool inview,u32 request,struct aa_perms *perms) { -aa_state_t tmp =label_compound_match (profile, rules, label, state, subns, - request, perms); +aa_state_t tmp =label_compound_match (profile, rules, label, state, + inview, request, perms);if ((perms->allow & request) == request)return tmp;/* failed compound_match try component matches */ *perms = allperms; -return label_components_match (profile, rules, label, state, subns, +return label_components_match (profile, rules, label, state, inview, request, perms); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1094/1518 apparmor: change fn_label_build() call to not return NULL
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Johansen <[email protected]>
[ Upstream commit ed7cc1c6f240a0c2838c0617afb2b0466edd236f ]
Previously fn_label_build() was accepting a NULL which represented ENOMEM return and ERR_PTR for errors.
Clean this up by requiring the cb fn to return an ERR_PTR or valid value.
Stable-dep-of: 08c2f7c8d4b1 ("apparmor: fix unconfined user namespace restriction forced stack")
--- security/apparmor/domain.c | 41 ++++++++++++++++++--------------- security/apparmor/include/lib.h | 12 +++++----- security/apparmor/mount.c | 17 +++++--------- 3 files changed, 35 insertions(+), 35 deletions(-)
security/apparmor/domain.c +23 -18
@@ -864,6 +864,15 @@ static int profile_onexec(const struct cred *subj_cred, }/* ensure none ns domain transitions are correctly applied with onexec */ +static struct aa_label *label_merge_wrap (struct aa_label *a,struct aa_label *b, +gfp_t gfp) +{ +struct aa_label *label =aa_label_merge (a, b, gfp); + +if (!label) +return ERR_PTR (-ENOMEM ); +return label; +} static struct aa_label *handle_onexec(const struct cred *subj_cred, struct aa_label *label,
@@ -891,12 +900,13 @@ static struct aa_label *handle_onexec(const struct cred *subj_cred,return ERR_PTR (error); new =fn_label_build_in_scope (label, profile,GFP_KERNEL , - stack ?aa_label_merge (&profile->label, onexec, -GFP_KERNEL ) + stack ?label_merge_wrap (&profile->label, onexec, +GFP_KERNEL ) :aa_get_newest_label (onexec),profile_transition (subj_cred, profile, bprm, buffer, cond, unsafe)); -if (new) +AA_BUG (!new); +if (!IS_ERR (new))return new;/* TODO: get rid of GLOBAL_ROOT_UID */
@@ -905,7 +915,8 @@ static struct aa_label *handle_onexec(const struct cred *subj_cred,OP_CHANGE_ONEXEC ,AA_MAY_ONEXEC , bprm->filename,NULL , onexec,GLOBAL_ROOT_UID , - "failed to build target label", -ENOMEM)); +"failed to build target label" , + PTR_ERR(new)));return ERR_PTR (error); }
@@ -968,14 +979,10 @@ int apparmor_bprm_creds_for_exec(struct linux_binprm *bprm)profile_transition (subj_cred, profile, bprm, buffer, &cond, &unsafe)); -AA_BUG (!new);if (IS_ERR (new)) { error =PTR_ERR (new); goto done; - }else if (!new) { - error = -ENOMEM ; - goto done; }/* Policy has specified a domain transitions. If no_new_privs and
@@ -1223,12 +1230,10 @@ static struct aa_label *change_hat(const struct cred *subj_cred,build_change_hat (subj_cred, profile, name, sibling), aa_get_label(&profile->label)); -if (!new) { - info ="label build failed" ; - error = -ENOMEM ; - goto fail; - }/* else if (IS_ERR) build_change_hat has logged error so return new */ mutex_unlock (&ns->lock); +AA_BUG (!new); +/* return new label or error ptr */ +return new; }
@@ -1556,7 +1561,8 @@ int aa_change_profile(const char *fqname, int flags) new =fn_label_build_in_scope (label, profile,GFP_KERNEL ,aa_get_label (target),aa_get_label (&profile->label)); -if (IS_ERR_OR_NULL (new)) +AA_BUG (!new); +if (IS_ERR (new)) goto build_fail;/* * no new privs prevents domain transitions that would
@@ -1580,10 +1586,9 @@ int aa_change_profile(const char *fqname, int flags) goto build_fail; error =aa_replace_current_label (new); }else { -if (new) { -aa_put_label (new); - new =NULL ; - } +/* new will be recomputed so at exec time. So discard */ +aa_put_label (new); + new =NULL ;/* full transition will be built in exec path */ aa_set_current_onexec (target, stack);
security/apparmor/include/lib.h +6 -6
@@ -272,7 +272,6 @@ void aa_policy_destroy(struct aa_policy *policy);* * Returns: new label on success * ERR_PTR if build @FN fails -* NULL if label_build fails due to low memory conditions * * @FN must return a label or ERR_PTR on failure. NULL is not allowed */
@@ -288,7 +287,7 @@ void aa_policy_destroy(struct aa_policy *policy);DEFINE_VEC (label, __lvec); \DEFINE_VEC (profile, __pvec); \if (vec_setup (label, __lvec, (L )->size, (GFP ))) { \ - __new_ =NULL ; \ + __new_ =ERR_PTR (-ENOMEM ); \ goto __done; \ } \ __j =0 ; \
@@ -310,23 +309,24 @@ void aa_policy_destroy(struct aa_policy *policy);if (__count >1 ) { \ __new_ =aa_vec_find_or_create_label (__pvec,\ __count, (GFP )); \ -/* only fails if out of Mem */ \if (!__new_) \ - __new_ =NULL ; \ + __new_ =ERR_PTR (-ENOMEM ); \ }else \ __new_ =aa_get_label (&__pvec[0 ]->label); \vec_cleanup (profile, __pvec, __count); \ }else \ - __new_ =NULL ; \ + __new_ =ERR_PTR (-ENOMEM ); \ __do_cleanup: \vec_cleanup (label, __lvec, (L )->size); \ }else { \ (P ) =labels_profile (L ); \ __new_ = (FN ); \ +AA_BUG (!__new_); \ } \ __done: \ -if (!__new_) \ +if (PTR_ERR (__new_)) \AA_DEBUG (DEBUG_LABEL ,"label build failed\n" ); \ +AA_BUG (!__new_); \ (__new_); \ })
security/apparmor/mount.c +6 -11
@@ -735,17 +735,11 @@ int aa_pivotroot(const struct cred *subj_cred, struct aa_label *label,build_pivotroot (subj_cred, profile, new_path, new_buffer, old_path, old_buffer)); -if (!target) { - info ="label build failed" ; - error = -ENOMEM ; - goto fail; - }else if (!IS_ERR (target)) { +AA_BUG (!target); +if (!IS_ERR (target)) { error =aa_replace_current_label (target); -if (error) { -/* TODO: audit target */ -aa_put_label (target); - goto out; - } +if (error) + goto fail;aa_put_label (target); }else /* already audited error */
@@ -763,7 +757,8 @@ int aa_pivotroot(const struct cred *subj_cred, struct aa_label *label,NULL /*new_name */ ,NULL /* old_name */ ,NULL ,NULL , -0 ,NULL ,AA_MAY_PIVOTROOT , &nullperms, info, +0 , target->hname,AA_MAY_PIVOTROOT , &nullperms, info, error)); +aa_put_label (target); goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1095/1518 apparmor: fix unconfined user namespace restriction forced stack
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Johansen <[email protected]>
[ Upstream commit 08c2f7c8d4b1434cfae006f3daf4d1bce330b57b ]
If a task is already confined by a stack the unprivileged transition restriction on unconfined is not correctly, applied. This results in an escape if two transitions through an unconfined profile can be executed.
Fix this by pushing the check into the per profile label build. The check will always be done against unconfined and result in a stack of just the unconfined component when necessary.
--- security/apparmor/domain.c | 80 +++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 26 deletions(-)
security/apparmor/domain.c +54 -26
@@ -874,6 +874,52 @@ static struct aa_label *label_merge_wrap(struct aa_label *a, struct aa_label *b,return label; } +static bool is_profile_priv_restricted_to_stack (const struct cred *subj_cred, +struct aa_profile *profile) +{ +if (profile_unconfined (profile) && profile == profile->ns->unconfined && + aa_unprivileged_unconfined_restricted && +/* cap_capable returns false (0) if true, hence true here means +* doesn't have capability and the stack will be restricted +*/ +cap_capable (current_cred (), &init_user_ns,CAP_MAC_OVERRIDE , +CAP_OPT_NOAUDIT )) +return true; +return false; +} + +static const char *stack_msg ="change_profile unprivileged unconfined converted to stacking" ; + +static struct aa_label *priv_restricted_transition (const struct cred *subj_cred, +struct aa_profile *profile, +const char *op,u32 request, +const char *name, +struct aa_label *transition, +gfp_t gfp) +{ +if (!is_profile_priv_restricted_to_stack (subj_cred, profile)) +return aa_get_newest_label (transition); + +/* transition allowed but only via stack */ +struct aa_label *target =label_merge_wrap (&profile->label, + transition, gfp); +if (IS_ERR_OR_NULL (target)) +return target; + +/* doing this here is less than optimal but good enough until the +* fs mediation rework lands +*/ +struct aa_perms perms = { + .allow = request, + .audit = request, + }; +aa_audit_file (subj_cred, profile, &perms, op, + request, name,NULL , target, + subj_cred->euid, stack_msg,0 ); + +return target; +} + static struct aa_label *handle_onexec(const struct cred *subj_cred, struct aa_label *label, struct aa_label *onexec, bool stack,
@@ -902,7 +948,10 @@ static struct aa_label *handle_onexec(const struct cred *subj_cred, new =fn_label_build_in_scope (label, profile,GFP_KERNEL , stack ?label_merge_wrap (&profile->label, onexec,GFP_KERNEL ) - :aa_get_newest_label (onexec), + :priv_restricted_transition (subj_cred, profile, +OP_CHANGE_ONEXEC ,AA_MAY_ONEXEC , + bprm->filename, onexec, +GFP_KERNEL ),profile_transition (subj_cred, profile, bprm, buffer, cond, unsafe));AA_BUG (!new);
@@ -1406,8 +1455,6 @@ static int change_profile_perms_wrapper(const char *op, const char *name,return error; } -static const char *stack_msg ="change_profile unprivileged unconfined converted to stacking" ; -/** * aa_change_profile - perform a one-way profile transition * @fqname: name of profile may include namespace (NOT NULL)
@@ -1467,28 +1514,6 @@ int aa_change_profile(const char *fqname, int flags) op =OP_CHANGE_PROFILE ; } -/* This should move to a per profile test. Requires pushing build -* into callback -*/ -if (!stack &&unconfined (label) && - label == &labels_ns (label)->unconfined->label && - aa_unprivileged_unconfined_restricted && -/* TODO: refactor so this check is a fn */ -cap_capable (current_cred (), &init_user_ns,CAP_MAC_OVERRIDE , -CAP_OPT_NOAUDIT )) { -/* regardless of the request in this case apparmor -* stacks against unconfined so admin set policy can't be -* by-passed -*/ - stack = true; - perms.audit = request; - (void )fn_for_each_in_scope (label, profile, -aa_audit_file (subj_cred, profile, &perms, op, - request, auditname,NULL , target, -GLOBAL_ROOT_UID , stack_msg,0 )); - perms.audit =0 ; - } -if (*fqname =='&' ) { stack = true;/* don't have label_parse() do stacking */
@@ -1559,7 +1584,10 @@ int aa_change_profile(const char *fqname, int flags)/* stacking is always a subset, so only check the nonstack case */ if (!stack) { new =fn_label_build_in_scope (label, profile,GFP_KERNEL , -aa_get_label (target), +priv_restricted_transition (subj_cred, profile, + op, request, + auditname, target, +GFP_KERNEL ),aa_get_label (&profile->label));AA_BUG (!new);if (IS_ERR (new))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1096/1518 iommu/amd: Fix incorrect device ID in invalid PASID error message
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasant Hegde <[email protected]>
[ Upstream commit 5322e19fc5acf013784207bc38191cd418a8bb48 ]
The IO page fault notifier handler logs pdev->dev.id when reporting an invalid PASID, but pdev->dev.id is the kernel-internal device ID and not the IOMMU device ID (BDF). Use dev_data->devid instead, which reflects actual devid.
--- drivers/iommu/amd/ppr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/amd/ppr.c +1 -1
@@ -140,7 +140,7 @@ static void iommu_call_iopf_notifier(struct amd_iommu *iommu, u64 *raw)if (event.fault.prm.pasid ==0 || event.fault.prm.pasid >= dev_data->max_pasids) {pr_info_ratelimited ("Invalid PASID : 0x%x, device : 0x%x\n" , - event.fault.prm.pasid, pdev->dev.id); + event.fault.prm.pasid, dev_data->devid); goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1097/1518 rust: uapi: replace direct asm-generic/ioctl.h include with linux/ioctl.h
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mukesh Kumar Chaurasiya (IBM) <[email protected]>
[ Upstream commit cdfcaa36ac93aa96df8310d7e57860f7600b2861 ]
rust/uapi/uapi_helper.h was directly including <uapi/asm-generic/ioctl.h> instead of the proper <uapi/linux/ioctl.h>.
On powerpc, <uapi/linux/ioctl.h> pulls in <uapi/asm/ioctl.h> first, which defines _IOC_SIZEBITS, _IOC_DIRBITS, _IOC_NONE, and _IOC_WRITE with the arch-specific values, before falling through to <asm-generic/ioctl.h>. By bypassing that chain and including <asm-generic/ioctl.h> directly, the arch-specific overrides never ran first, so when other headers in the compilation later brought in the full arch-aware chain, Clang saw those four macros being defined a second time and emitted:
clang diag: arch/powerpc/include/uapi/asm/ioctl.h:5:9: warning: '_IOC_SIZEBITS' macro redefined [-Wmacro-redefined] clang diag: arch/powerpc/include/uapi/asm/ioctl.h:6:9: warning: '_IOC_DIRBITS' macro redefined [-Wmacro-redefined] clang diag: arch/powerpc/include/uapi/asm/ioctl.h:8:9: warning: '_IOC_NONE' macro redefined [-Wmacro-redefined] clang diag: arch/powerpc/include/uapi/asm/ioctl.h:10:9: warning: '_IOC_WRITE' macro redefined [-Wmacro-redefined]
Fix this by replacing the direct include of <uapi/asm-generic/ioctl.h> with <uapi/linux/ioctl.h>, which is the correct arch-aware entry point and already maintains the intended include order.
--- rust/uapi/uapi_helper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
rust/uapi/uapi_helper.h +1 -1
@@ -6,11 +6,11 @@* Sorted alphabetically. */ -#include <uapi/asm-generic/ioctl.h> #include <uapi/drm/drm.h> #include <uapi/drm/nova_drm.h> #include <uapi/drm/panthor_drm.h> #include <uapi/linux/android/binder.h> +#include <uapi/linux/ioctl.h> #include <uapi/linux/mdio.h> #include <uapi/linux/mii.h> #include <uapi/linux/ethtool.h>
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1098/1518 phy: renesas: rcar-gen3-usb2: Ignore missing VBUS regulator
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lad Prabhakar <[email protected]>
[ Upstream commit 9ea8d49c6cc6e217f5f5818369f659dc25bf89bf ]
Commit b6d7dd157763 ("phy: renesas: rcar-gen3-usb2: Add regulator for OTG VBUS control") introduced support for controlling OTG VBUS through the regulator framework.
As part of this change, the driver started requesting an exclusive "vbus" regulator for OTG-capable PHYs with no_adp_ctrl set. The lookup failure was propagated unconditionally, causing probe to fail on platforms where no VBUS regulator is described.
On RZ/V2H and RZ/V2N, which do not use a VBUS regulator, this results in the following error:
phy_rcar_gen3_usb2 15800200.usb-phy:
dummy supplies not allowed for exclusive requests (id=vbus)
This failure completely prevents the USB 2.0 interface from initializing.
Fix this by allowing the probe to continue if an external VBUS regulator is missing. Only propagate the error if the internal vbus-regulator node is explicitly present, or if the lookup returns -EPROBE_DEFER. For all other missing regulator errors, gracefully assume no external VBUS regulator is available and return 0.
--- drivers/phy/renesas/phy-rcar-gen3-usb2.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/phy/renesas/phy-rcar-gen3-usb2.c +11 -2
@@ -909,8 +909,17 @@ static int rcar_gen3_phy_usb2_vbus_regulator_get_exclusive_enable(struct rcar_geint ret; channel->vbus =devm_regulator_get_exclusive (dev,"vbus" ); -if (IS_ERR (channel->vbus)) -return PTR_ERR (channel->vbus); +if (IS_ERR (channel->vbus)) { + ret =PTR_ERR (channel->vbus); +/* If vbus-regulator node was present vbus regulator should be available */ +if (channel->otg_internal_reg) +return ret; + +if (ret == -EPROBE_DEFER ) +return ret; + +return 0 ; + }if (enable) { ret =regulator_enable (channel->vbus);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1099/1518 phy: qcom: qmp-combo: Correct pre-emphasis table for QMP v4 DP PHYs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Esteban Urrutia <[email protected]>
[ Upstream commit 481807f939077059db278edd0467e7e609b6c9a7 ]
Comparing sm8350 and sm8450 tables, this seems to be a typo.
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +1 -1
@@ -1691,7 +1691,7 @@ static const u8 qmp_dp_v4_pre_emphasis_hbr3_hbr2[4][4] = {static const u8 qmp_dp_v4_pre_emphasis_hbr_rbr[4 ][4 ] = { {0x00 ,0x0d ,0x14 ,0x1a }, {0x00 ,0x0e ,0x15 ,0xff }, - {0x00 ,0x0d ,0xff ,0xff }, + {0x00 ,0x0e ,0xff ,0xff }, {0x03 ,0xff ,0xff ,0xff } };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1100/1518 phy: qcom-qmp-combo: Use regulator_bulk_data with init_load_uA for regulator setup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Faisal Hassan <[email protected]>
[ Upstream commit 81d75558406609f311766a37ec4b2c74d7b11ea0 ]
Replace the custom qmp_regulator_data structure with the standard regulator_bulk_data and use the init_load_uA field to set regulator load during initialization.
This change simplifies the regulator setup by removing manual allocation and load configuration logic, and leverages devm_regulator_bulk_get_const() to automatically apply load settings before enabling regulators.
Stable-dep-of: 8fd2b30d187f ("phy: qcom: qmp-combo: Drop qmp_v4_calibrate_dp_phy")
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 49 +++-------------------- 1 file changed, 6 insertions(+), 43 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +6 -43
@@ -1643,14 +1643,9 @@ static const struct qmp_phy_init_tbl x1e80100_usb43dp_pcs_usb_tbl[] = { };/* list of regulators */ -struct qmp_regulator_data { -const char *name; -unsigned int enable_load; -}; - -static struct qmp_regulator_data qmp_phy_vreg_l[] = { - { .name ="vdda-phy" , .enable_load =21800 }, - { .name ="vdda-pll" , .enable_load =36000 }, +static struct regulator_bulk_data qmp_phy_vreg_l[] = { + { .supply ="vdda-phy" , .init_load_uA =21800 , }, + { .supply ="vdda-pll" , .init_load_uA =36000 , }, };static const u8 qmp_dp_v3_pre_emphasis_hbr3_hbr2[4 ][4 ] = {
@@ -1808,7 +1803,7 @@ struct qmp_phy_cfg {const char *const *reset_list;int num_resets;/* regulators to be requested */ -const struct qmp_regulator_data *vreg_list; +const struct regulator_bulk_data *vreg_list;int num_vregs;/* array of registers with different offsets */
@@ -3439,39 +3434,6 @@ static const struct dev_pm_ops qmp_combo_pm_ops = { qmp_combo_runtime_resume, NULL) }; -static int qmp_combo_vreg_init (struct qmp_combo *qmp) -{ -const struct qmp_phy_cfg *cfg = qmp->cfg; -struct device *dev = qmp->dev; -int num = cfg->num_vregs; -int ret, i; - - qmp->vregs =devm_kcalloc (dev, num,sizeof (*qmp->vregs),GFP_KERNEL ); -if (!qmp->vregs) -return -ENOMEM ; - -for (i =0 ; i < num; i++) - qmp->vregs[i].supply = cfg->vreg_list[i].name; - - ret =devm_regulator_bulk_get (dev, num, qmp->vregs); -if (ret) { -dev_err (dev,"failed at devm_regulator_bulk_get\n" ); -return ret; - } - -for (i =0 ; i < num; i++) { - ret =regulator_set_load (qmp->vregs[i].consumer, - cfg->vreg_list[i].enable_load); -if (ret) { -dev_err (dev,"failed to set load at %s\n" , - qmp->vregs[i].supply); -return ret; - } - } - -return 0 ; -} -static int qmp_combo_reset_init (struct qmp_combo *qmp) {const struct qmp_phy_cfg *cfg = qmp->cfg;
@@ -4144,7 +4106,8 @@ static int qmp_combo_probe(struct platform_device *pdev)if (ret)return ret; - ret =qmp_combo_vreg_init (qmp); + ret =devm_regulator_bulk_get_const (dev, qmp->cfg->num_vregs, + qmp->cfg->vreg_list, &qmp->vregs);if (ret)return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1101/1518 phy: qualcomm: Update the QMP clamp register for V6
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wesley Cheng <[email protected]>
[ Upstream commit c9543cca9417d83f8ca6a8ce0a5279a3fba7a02b ]
QMP combo phy V6 and above use the clamp register from the PCS always on (AON) address space. Update the driver accordingly.
Stable-dep-of: 8fd2b30d187f ("phy: qcom: qmp-combo: Drop qmp_v4_calibrate_dp_phy")
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 38 ++++++++++++++++--- .../phy/qualcomm/phy-qcom-qmp-pcs-aon-v6.h | 12 ++++++ .../phy/qualcomm/phy-qcom-qmp-pcs-misc-v5.h | 12 ++++++ 3 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 drivers/phy/qualcomm/phy-qcom-qmp-pcs-aon-v6.h create mode 100644 drivers/phy/qualcomm/phy-qcom-qmp-pcs-misc-v5.h
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +33 -5
@@ -29,7 +29,10 @@#include "phy-qcom-qmp-common.h" #include "phy-qcom-qmp.h" +#include "phy-qcom-qmp-pcs-aon-v6.h" #include "phy-qcom-qmp-pcs-misc-v3.h" +#include "phy-qcom-qmp-pcs-misc-v4.h" +#include "phy-qcom-qmp-pcs-misc-v5.h" #include "phy-qcom-qmp-pcs-usb-v4.h" #include "phy-qcom-qmp-pcs-usb-v5.h" #include "phy-qcom-qmp-pcs-usb-v6.h"
@@ -78,6 +81,7 @@ enum qphy_reg_layout {QPHY_PCS_AUTONOMOUS_MODE_CTRL ,QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR ,QPHY_PCS_POWER_DOWN_CONTROL , +QPHY_PCS_CLAMP_ENABLE ,QPHY_COM_RESETSM_CNTRL , QPHY_COM_C_READY_STATUS,
@@ -105,6 +109,8 @@ static const unsigned int qmp_v3_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = QPHY_V3_PCS_AUTONOMOUS_MODE_CTRL, [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = QPHY_V3_PCS_LFPS_RXTERM_IRQ_CLEAR, + [QPHY_PCS_CLAMP_ENABLE] = QPHY_V3_PCS_MISC_CLAMP_ENABLE, + [QPHY_COM_RESETSM_CNTRL] = QSERDES_V3_COM_RESETSM_CNTRL, [QPHY_COM_C_READY_STATUS] = QSERDES_V3_COM_C_READY_STATUS, [QPHY_COM_CMN_STATUS] = QSERDES_V3_COM_CMN_STATUS,
@@ -130,6 +136,8 @@ static const unsigned int qmp_v45_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = QPHY_V4_PCS_USB3_AUTONOMOUS_MODE_CTRL, [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = QPHY_V4_PCS_USB3_LFPS_RXTERM_IRQ_CLEAR, + [QPHY_PCS_CLAMP_ENABLE] = QPHY_V4_PCS_MISC_CLAMP_ENABLE, + [QPHY_COM_RESETSM_CNTRL] = QSERDES_V4_COM_RESETSM_CNTRL, [QPHY_COM_C_READY_STATUS] = QSERDES_V4_COM_C_READY_STATUS, [QPHY_COM_CMN_STATUS] = QSERDES_V4_COM_CMN_STATUS,
@@ -155,6 +163,8 @@ static const unsigned int qmp_v5_5nm_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = QPHY_V5_PCS_USB3_AUTONOMOUS_MODE_CTRL, [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = QPHY_V5_PCS_USB3_LFPS_RXTERM_IRQ_CLEAR, + [QPHY_PCS_CLAMP_ENABLE] = QPHY_V5_PCS_MISC_CLAMP_ENABLE, + [QPHY_COM_RESETSM_CNTRL] = QSERDES_V5_COM_RESETSM_CNTRL, [QPHY_COM_C_READY_STATUS] = QSERDES_V5_COM_C_READY_STATUS, [QPHY_COM_CMN_STATUS] = QSERDES_V5_COM_CMN_STATUS,
@@ -180,6 +190,8 @@ static const unsigned int qmp_v6_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = QPHY_V6_PCS_USB3_AUTONOMOUS_MODE_CTRL, [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = QPHY_V6_PCS_USB3_LFPS_RXTERM_IRQ_CLEAR, + [QPHY_PCS_CLAMP_ENABLE] = QPHY_V6_PCS_AON_CLAMP_ENABLE, + [QPHY_COM_RESETSM_CNTRL] = QSERDES_V6_COM_RESETSM_CNTRL, [QPHY_COM_C_READY_STATUS] = QSERDES_V6_COM_C_READY_STATUS, [QPHY_COM_CMN_STATUS] = QSERDES_V6_COM_CMN_STATUS,
@@ -205,6 +217,8 @@ static const unsigned int qmp_v6_n4_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = QPHY_V6_PCS_USB3_AUTONOMOUS_MODE_CTRL, [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = QPHY_V6_PCS_USB3_LFPS_RXTERM_IRQ_CLEAR, + [QPHY_PCS_CLAMP_ENABLE] = QPHY_V6_PCS_AON_CLAMP_ENABLE, + [QPHY_COM_RESETSM_CNTRL] = QSERDES_V6_COM_RESETSM_CNTRL, [QPHY_COM_C_READY_STATUS] = QSERDES_V6_COM_C_READY_STATUS, [QPHY_COM_CMN_STATUS] = QSERDES_V6_COM_CMN_STATUS,
@@ -1750,6 +1764,7 @@ struct qmp_combo_offsets {u16 usb3_serdes;u16 usb3_pcs_misc;u16 usb3_pcs; +u16 usb3_pcs_aon;u16 usb3_pcs_usb;u16 dp_serdes;u16 dp_txa;
@@ -1831,6 +1846,7 @@ struct qmp_combo {void __iomem *tx2;void __iomem *rx2;void __iomem *pcs_misc; +void __iomem *pcs_aon;void __iomem *pcs_usb;void __iomem *dp_serdes;
@@ -1955,6 +1971,7 @@ static const struct qmp_combo_offsets qmp_combo_offsets_v8 = { .usb3_serdes = 0x1000, .usb3_pcs_misc = 0x1c00, .usb3_pcs = 0x1e00, + .usb3_pcs_aon = 0x2000, .usb3_pcs_usb = 0x2100, .dp_serdes = 0x3000, .dp_txa = 0x3400,
@@ -3340,6 +3357,7 @@ static void qmp_combo_enable_autonomous_mode(struct qmp_combo *qmp)const struct qmp_phy_cfg *cfg = qmp->cfg;void __iomem *pcs_usb = qmp->pcs_usb ?: qmp->pcs;void __iomem *pcs_misc = qmp->pcs_misc; +void __iomem *pcs_aon = qmp->pcs_aon;u32 intr_mask; if (qmp->phy_mode == PHY_MODE_USB_HOST_SS ||
@@ -3359,9 +3377,14 @@ static void qmp_combo_enable_autonomous_mode(struct qmp_combo *qmp)/* Enable required PHY autonomous mode interrupts */ qphy_setbits (pcs_usb, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL ], intr_mask); -/* Enable i/o clamp_n for autonomous mode */ -if (pcs_misc) -qphy_clrbits (pcs_misc,QPHY_V3_PCS_MISC_CLAMP_ENABLE ,CLAMP_EN ); +/* +* Enable i/o clamp_n for autonomous mode +* V6 and later versions use pcs aon clamp register +*/ +if (pcs_aon) +qphy_clrbits (pcs_aon, cfg->regs[QPHY_PCS_CLAMP_ENABLE ],CLAMP_EN ); +else if (pcs_misc) +qphy_clrbits (pcs_misc, cfg->regs[QPHY_PCS_CLAMP_ENABLE ],CLAMP_EN ); }static void qmp_combo_disable_autonomous_mode (struct qmp_combo *qmp)
@@ -3369,10 +3392,13 @@ static void qmp_combo_disable_autonomous_mode(struct qmp_combo *qmp)const struct qmp_phy_cfg *cfg = qmp->cfg;void __iomem *pcs_usb = qmp->pcs_usb ?: qmp->pcs;void __iomem *pcs_misc = qmp->pcs_misc; +void __iomem *pcs_aon = qmp->pcs_aon;/* Disable i/o clamp_n on resume for normal mode */ -if (pcs_misc) -qphy_setbits (pcs_misc,QPHY_V3_PCS_MISC_CLAMP_ENABLE ,CLAMP_EN ); +if (pcs_aon) +qphy_setbits (pcs_aon, cfg->regs[QPHY_PCS_CLAMP_ENABLE ],CLAMP_EN ); +else if (pcs_misc) +qphy_setbits (pcs_misc, cfg->regs[QPHY_PCS_CLAMP_ENABLE ],CLAMP_EN );qphy_clrbits (pcs_usb, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL ],ARCVR_DTCT_EN |ARCVR_DTCT_EVENT_SEL |ALFPS_DTCT_EN );
@@ -4037,6 +4063,8 @@ static int qmp_combo_parse_dt(struct qmp_combo *qmp) qmp->serdes = base + offs->usb3_serdes; qmp->pcs_misc = base + offs->usb3_pcs_misc; qmp->pcs = base + offs->usb3_pcs; +if (offs->usb3_pcs_aon) + qmp->pcs_aon = base + offs->usb3_pcs_aon; qmp->pcs_usb = base + offs->usb3_pcs_usb; qmp->dp_serdes = base + offs->dp_serdes;
drivers/phy/qualcomm/phy-qcom-qmp-pcs-aon-v6.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025, Qualcomm Innovation Center, Inc. All rights reserved. +*/ + +#ifndef QCOM_PHY_QMP_PCS_AON_V6_H_ +#define QCOM_PHY_QMP_PCS_AON_V6_H_ + +/* Only for QMP V6 PHY - PCS_AON registers */ +#define QPHY_V6_PCS_AON_CLAMP_ENABLE 0x00 + +#endif
drivers/phy/qualcomm/phy-qcom-qmp-pcs-misc-v5.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved. +*/ + +#ifndef QCOM_PHY_QMP_PCS_MISC_V5_H_ +#define QCOM_PHY_QMP_PCS_MISC_V5_H_ + +/* Only for QMP V5 PHY - PCS_MISC registers */ +#define QPHY_V5_PCS_MISC_CLAMP_ENABLE 0x0c + +#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1102/1518 phy: qualcomm: qmp-combo: Update QMP PHY with Glymur settings
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wesley Cheng <[email protected]>
[ Upstream commit 5b289913959b9bc93bab9e0beeab269c33c969b7 ]
For SuperSpeed USB to work properly, there is a set of HW settings that need to be programmed into the USB blocks within the QMP PHY. Ensure that these settings follow the latest settings mentioned in the HW programming guide. The QMP USB PHY on Glymur is a USB43 based PHY that will have some new ways to define certain registers, such as the replacement of TXA/RXA and TXB/RXB register sets. This was replaced with the LALB register set.
There are also some PHY init updates to modify the PCS MISC register space. Without these, the QMP PHY PLL locking fails.
Stable-dep-of: 8fd2b30d187f ("phy: qcom: qmp-combo: Drop qmp_v4_calibrate_dp_phy")
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 285 ++++++++ .../phy/qualcomm/phy-qcom-qmp-pcs-aon-v8.h | 17 + .../phy/qualcomm/phy-qcom-qmp-pcs-misc-v8.h | 12 + .../qualcomm/phy-qcom-qmp-qserdes-lalb-v8.h | 639 ++++++++++++++++++ .../phy/qualcomm/phy-qcom-qmp-usb43-pcs-v8.h | 33 + .../phy-qcom-qmp-usb43-qserdes-com-v8.h | 224 ++++++ drivers/phy/qualcomm/phy-qcom-qmp.h | 2 + 7 files changed, 1212 insertions(+) create mode 100644 drivers/phy/qualcomm/phy-qcom-qmp-pcs-aon-v8.h create mode 100644 drivers/phy/qualcomm/phy-qcom-qmp-pcs-misc-v8.h create mode 100644 drivers/phy/qualcomm/phy-qcom-qmp-qserdes-lalb-v8.h create mode 100644 drivers/phy/qualcomm/phy-qcom-qmp-usb43-pcs-v8.h create mode 100644 drivers/phy/qualcomm/phy-qcom-qmp-usb43-qserdes-com-v8.h
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +285 -0
@@ -30,9 +30,11 @@#include "phy-qcom-qmp.h" #include "phy-qcom-qmp-pcs-aon-v6.h" +#include "phy-qcom-qmp-pcs-aon-v8.h" #include "phy-qcom-qmp-pcs-misc-v3.h" #include "phy-qcom-qmp-pcs-misc-v4.h" #include "phy-qcom-qmp-pcs-misc-v5.h" +#include "phy-qcom-qmp-pcs-misc-v8.h" #include "phy-qcom-qmp-pcs-usb-v4.h" #include "phy-qcom-qmp-pcs-usb-v5.h" #include "phy-qcom-qmp-pcs-usb-v6.h"
@@ -46,6 +48,8 @@#include "phy-qcom-qmp-dp-phy-v5.h" #include "phy-qcom-qmp-dp-phy-v6.h" +#include "phy-qcom-qmp-usb43-pcs-v8.h" +/* QPHY_V3_DP_COM_RESET_OVRD_CTRL register bits */ /* DP PHY soft reset */ #define SW_DPPHY_RESET BIT(0)
@@ -97,6 +101,7 @@ enum qphy_reg_layout {QPHY_TX_HIGHZ_DRVR_EN ,QPHY_TX_TRANSCEIVER_BIAS_EN , +QPHY_AON_TOGGLE_ENABLE ,/* Keep last to ensure regs_layout arrays are properly initialized */ QPHY_LAYOUT_SIZE };
@@ -259,6 +264,233 @@ static const unsigned int qmp_v8_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_TX_TRANSCEIVER_BIAS_EN] = QSERDES_V8_TX_TRANSCEIVER_BIAS_EN, }; +static const unsigned int qmp_v8_n3_usb43dpphy_regs_layout[QPHY_LAYOUT_SIZE ] = { + [QPHY_SW_RESET ] =QPHY_V8_USB43_PCS_SW_RESET , + [QPHY_START_CTRL ] =QPHY_V8_USB43_PCS_START_CONTROL , + [QPHY_PCS_STATUS ] =QPHY_V8_USB43_PCS_PCS_STATUS1 , + [QPHY_PCS_POWER_DOWN_CONTROL ] =QPHY_V8_USB43_PCS_POWER_DOWN_CONTROL , + +/* In PCS_USB */ + [QPHY_PCS_AUTONOMOUS_MODE_CTRL ] =QPHY_V8_PCS_USB_AUTONOMOUS_MODE_CTRL , + [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR ] =QPHY_V8_PCS_USB_LFPS_RXTERM_IRQ_CLEAR , + + [QPHY_PCS_CLAMP_ENABLE ] =QPHY_V8_PCS_AON_USB3_AON_CLAMP_ENABLE , + [QPHY_AON_TOGGLE_ENABLE ] =QPHY_V8_PCS_AON_USB3_AON_TOGGLE_ENABLE , + + [QPHY_COM_RESETSM_CNTRL ] =QSERDES_V8_COM_RESETSM_CNTRL , + [QPHY_COM_C_READY_STATUS ] =QSERDES_V8_COM_C_READY_STATUS , + [QPHY_COM_CMN_STATUS ] =QSERDES_V8_COM_CMN_STATUS , + [QPHY_COM_BIAS_EN_CLKBUFLR_EN ] =QSERDES_V8_COM_BIAS_EN_CLKBUFLR_EN , + + [QPHY_TX_TX_DRV_LVL ] =QSERDES_V8_LALB_TX0_DRV_LVL , + [QPHY_TX_TX_EMP_POST1_LVL ] =QSERDES_V8_LALB_TX0_EMP_POST1_LVL , + [QPHY_TX_HIGHZ_DRVR_EN ] =QSERDES_V8_LALB_HIGHZ_DRVR_EN , + [QPHY_TX_TRANSCEIVER_BIAS_EN ] =QSERDES_V8_LALB_TRANSMITTER_EN_CTRL , +}; + +static const struct qmp_phy_init_tbl glymur_usb43dp_serdes_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_STEP_SIZE1_MODE1 ,0xe1 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_STEP_SIZE2_MODE1 ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CP_CTRL_MODE1 ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_PLL_RCTRL_MODE1 ,0x16 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_PLL_CCTRL_MODE1 ,0x36 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CORECLK_DIV_MODE1 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_LOCK_CMP1_MODE1 ,0x1a ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_LOCK_CMP2_MODE1 ,0x41 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DEC_START_MODE1 ,0x41 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DEC_START_MSB_MODE1 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DIV_FRAC_START1_MODE1 ,0xab ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DIV_FRAC_START2_MODE1 ,0xaa ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DIV_FRAC_START3_MODE1 ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_HSCLK_SEL_1 ,0x13 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_INTEGLOOP_GAIN0_MODE1 ,0x3f ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE1_MODE1 ,0x4d ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE2_MODE1 ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIN_VCOCAL_CMP_CODE1_MODE1 ,0x95 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIN_VCOCAL_CMP_CODE2_MODE1 ,0x1e ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIN_VCOCAL_CMP_CODE1_MODE0 ,0x4b ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIN_VCOCAL_CMP_CODE2_MODE0 ,0x0f ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_STEP_SIZE1_MODE0 ,0xe1 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_STEP_SIZE2_MODE0 ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CP_CTRL_MODE0 ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_PLL_RCTRL_MODE0 ,0x16 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_PLL_CCTRL_MODE0 ,0x36 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CORECLK_DIV_MODE0 ,0x05 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_LOCK_CMP1_MODE0 ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_LOCK_CMP2_MODE0 ,0x1a ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DEC_START_MODE0 ,0x41 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DEC_START_MSB_MODE0 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DIV_FRAC_START1_MODE0 ,0xab ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DIV_FRAC_START2_MODE0 ,0xaa ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DIV_FRAC_START3_MODE0 ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_HSCLK_HS_SWITCH_SEL_1 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_INTEGLOOP_GAIN0_MODE0 ,0x3f ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE1_MODE0 ,0x4d ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE2_MODE0 ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BG_TIMER ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_EN_CENTER ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_PER1 ,0x62 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_PER2 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SYSCLK_BUF_ENABLE ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_PLL_IVCO ,0x0f ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_PLL_IVCO_MODE1 ,0x0f ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SYSCLK_EN_SEL ,0x1a ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_LOCK_CMP_EN ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_LOCK_CMP_CFG ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE_CTRL ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE_MAP ,0x14 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CORE_CLK_EN ,0xa0 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CMN_CONFIG_1 ,0x76 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SVS_MODE_CLK_SEL ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIN_VCOCAL_HSCLK_SEL_1 ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_PLL_SPARE_FOR_ECO ,0x40 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DCC_CAL_1 ,0x40 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DCC_CAL_2 ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DCC_CAL_3 ,0x60 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_PSM_CAL_EN ,0x05 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CLK_FWD_CONFIG_1 ,0x33 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_IP_CTRL_AND_DP_SEL ,0xaf ), +}; + +static const struct qmp_phy_init_tbl glymur_usb43dp_pcs_misc_tbl[] = { +QMP_PHY_INIT_CFG (QPHY_V8_PCS_MISC_PCS_MISC_CONFIG1 ,0x01 ), +}; + +static const struct qmp_phy_init_tbl glymur_usb43dp_pcs_tbl[] = { +QMP_PHY_INIT_CFG (QPHY_V8_USB43_PCS_LOCK_DETECT_CONFIG1 ,0xc4 ), +QMP_PHY_INIT_CFG (QPHY_V8_USB43_PCS_LOCK_DETECT_CONFIG2 ,0x89 ), +QMP_PHY_INIT_CFG (QPHY_V8_USB43_PCS_LOCK_DETECT_CONFIG3 ,0x20 ), +QMP_PHY_INIT_CFG (QPHY_V8_USB43_PCS_LOCK_DETECT_CONFIG6 ,0x13 ), +QMP_PHY_INIT_CFG (QPHY_V8_USB43_PCS_REFGEN_REQ_CONFIG1 ,0x21 ), +QMP_PHY_INIT_CFG (QPHY_V8_USB43_PCS_RX_SIGDET_LVL ,0x55 ), +QMP_PHY_INIT_CFG (QPHY_V8_USB43_PCS_RCVR_DTCT_DLY_P1U2_L ,0xe7 ), +QMP_PHY_INIT_CFG (QPHY_V8_USB43_PCS_RCVR_DTCT_DLY_P1U2_H ,0x03 ), +QMP_PHY_INIT_CFG (QPHY_V8_USB43_PCS_TSYNC_RSYNC_TIME ,0xa4 ), +QMP_PHY_INIT_CFG (QPHY_V8_USB43_PCS_RX_CONFIG ,0x0a ), +QMP_PHY_INIT_CFG (QPHY_V8_USB43_PCS_TSYNC_DLY_TIME ,0x04 ), +QMP_PHY_INIT_CFG (QPHY_V8_USB43_PCS_ALIGN_DETECT_CONFIG1 ,0xd4 ), +QMP_PHY_INIT_CFG (QPHY_V8_USB43_PCS_ALIGN_DETECT_CONFIG2 ,0x30 ), +QMP_PHY_INIT_CFG (QPHY_V8_USB43_PCS_PCS_TX_RX_CONFIG ,0x0c ), +QMP_PHY_INIT_CFG (QPHY_V8_USB43_PCS_EQ_CONFIG1 ,0x4b ), +QMP_PHY_INIT_CFG (QPHY_V8_USB43_PCS_EQ_CONFIG5 ,0x10 ), +}; + +static const struct qmp_phy_init_tbl glymur_usb43dp_pcs_usb_tbl[] = { +QMP_PHY_INIT_CFG (QPHY_V8_PCS_USB_LFPS_DET_HIGH_COUNT_VAL ,0xf8 ), +QMP_PHY_INIT_CFG (QPHY_V8_PCS_USB_RXEQTRAINING_DFE_TIME_S2 ,0x07 ), +}; + +static const struct qmp_phy_init_tbl glymur_usb43dp_lalb_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CLKBUF_ENABLE ,0x81 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX_LVL_UPDATE_CTRL ,0x0d ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_PCIE5_TOP_LDO_CODE_CTRL1 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_PCIE5_TOP_LDO_CODE_CTRL2 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_PCIE5_TOP_LDO_CODE_CTRL3 ,0x80 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_PCIE5_TOP_LDO_CODE_CTRL4 ,0x8D ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TRANSMITTER_EN_CTRL ,0x13 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_LANE_MODE_1 ,0x0c ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_LANE_MODE_2 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_LANE_MODE_3 ,0x11 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_LANE_MODE_4 ,0x11 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX0_RESTRIM_CAL_CTRL ,0x20 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX1_RESTRIM_CAL_CTRL ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX0_RESTRIM_POST_CAL_OFFSET ,0x10 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX0_RESTRIM_VREF_SEL ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX1_RESTRIM_VREF_SEL ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_ANA_INTERFACE_SELECT2 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_PCS_INTERFACE_SELECT1 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_MODE_RATE_0_1_B0 ,0xa4 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_MODE_RATE_0_1_B1 ,0xa2 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_MODE_RATE_0_1_B2 ,0x6e ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_MODE_RATE_0_1_B3 ,0x51 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_MODE_RATE_0_1_B4 ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_MODE_RATE_0_1_B5 ,0x26 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_MODE_RATE_0_1_B6 ,0x12 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_MODE_RATE_0_1_B7 ,0x2a ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_MODE_RATE2_B0 ,0x4c ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_MODE_RATE2_B1 ,0xc4 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_MODE_RATE2_B2 ,0x38 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_MODE_RATE2_B3 ,0x64 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_MODE_RATE2_B4 ,0x0c ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_MODE_RATE2_B5 ,0x4b ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_MODE_RATE2_B6 ,0x12 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_MODE_RATE2_B7 ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX_DCC_ANA_CTRL2 ,0x0c ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_VCO_CTUNE_MEAS_CNT1_RATE1 ,0x26 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_VCO_CTUNE_MEAS_CNT2_RATE1 ,0x26 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_VCO_CTUNE_MEAS_CNT1_RATE2 ,0x26 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_VCO_CTUNE_MEAS_CNT2_RATE2 ,0x26 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_KVCO_INIT_RATE_0_1 ,0x11 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_KVCO_INIT_RATE_2_3 ,0x11 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_KVCO_CODE_OVRD_RATE1 ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_KVCO_CODE_OVRD_RATE2 ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_KVCO_IDEAL_FREQ_DIFF1_RATE1 ,0x15 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_KVCO_IDEAL_FREQ_DIFF2_RATE1 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_KVCO_IDEAL_FREQ_DIFF1_RATE2 ,0x22 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_KVCO_IDEAL_FREQ_DIFF2_RATE2 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_KP_CODE_OVRD_RATE_2_3 ,0x22 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_KP_CAL_UPPER_FREQ_DIFF_BND1_RATE1 ,0xff ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_KP_CAL_UPPER_FREQ_DIFF_BND2_RATE1 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_KP_CAL_UPPER_FREQ_DIFF_BND1_RATE2 ,0xff ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_KP_CAL_UPPER_FREQ_DIFF_BND2_RATE2 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_KP_CAL_LOWER_FREQ_DIFF_BND_RATE1 ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_KP_CAL_LOWER_FREQ_DIFF_BND_RATE2 ,0x09 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_SUMMER_CAL_SPD_MODE_RATE_0123 ,0x2f ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_IVCM_CAL_CODE_OVERRIDE_RATE1 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_IVCM_CAL_CODE_OVERRIDE_RATE2 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_IVCM_CAL_CTRL2 ,0x85 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_IVCM_CAL_CTRL3 ,0x45 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_IVCM_POSTCAL_OFFSET_RATE1 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_IVCM_POSTCAL_OFFSET_RATE2 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_SIGDET_ENABLES ,0x0c ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_SIGDET_CNTRL ,0xa3 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_SIGDET_LVL ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_SIGDET_DEGLITCH_CNTRL ,0x0e ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_SIGDET_CAL_CTRL1 ,0x14 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_SIGDET_CAL_CTRL2_AND_CDR_LOCK_EDGE ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_SIGDET_CAL_TRIM ,0x66 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_FREQ_LOCK_DET_DLY_RATE1 ,0xff ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_FREQ_LOCK_DET_DLY_RATE2 ,0x32 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_CP_CUR_FLL_RATE1 ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_CP_CUR_FLL_RATE2 ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_CP_CUR_PLL_RATE1 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_CP_CUR_PLL_RATE2 ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_LOOP_CCODE_RATE_01 ,0x76 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_LOOP_CCODE_RATE_23 ,0x67 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_LOOP_RCODE_FAST_RATE_0_1 ,0x20 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_LOOP_RCODE_FAST_RATE_2_3 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_LOOP_RCODE_FLL_RATE_0_1 ,0x33 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_LOOP_RCODE_FLL_RATE_2_3 ,0x43 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_LOOP_RCODE_PLL_RATE_0_1 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_LOOP_RCODE_PLL_RATE_2_3 ,0x51 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_FLL_DIV_RATIO_RATE_0123 ,0xe5 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_VCO_CAP_CODE_RATE_0123 ,0xf5 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_VCO_TYPE_CONFIG ,0x1f ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_VCO_EN_LOWFREQ ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_LOOP_FUNC_CTRL ,0xd0 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_GM_CAL_EN ,0x1f ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_GM_CAL_RES_RATE0_1 ,0x88 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_GM_CAL_RES_RATE2_3 ,0x88 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_AUX_CLK_CTRL ,0x20 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_EOM_CTRL1 ,0x10 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_EQU_ADAPTOR_CNTRL2 ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_EQU_ADAPTOR_CNTRL3 ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RX_EQU_ADAPTOR_CNTRL4 ,0xaa ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CTLE_POST_CAL_OFFSET_RATE_0_1_2 ,0x77 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_VGA_CAL_CNTRL1 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_VGA_CAL_MAN_VAL_RATE0_1 ,0xdd ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_VGA_CAL_MAN_VAL_RATE2_3 ,0xd8 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_DFE_TAP1_DAC_ENABLE ,0x1c ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_DFE_TAP2_DAC_ENABLE ,0x1c ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_DFE_TAP345_DAC_ENABLE ,0x18 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_DFE_TAP67_DAC_ENABLE ,0x10 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_IQTUNE_CTRL ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_IQTUNE_MAN_INDEX ,0x10 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_IQTUNE_DIV2_CTRL_RATE0123 ,0x1C ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CDR_VCO_CAP_CODE_OVRD_MUXES ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_DIG_BKUP_CTRL16 ,0x37 ), +}; +static const struct qmp_phy_init_tbl qmp_v3_usb3_serdes_tbl[] = {QMP_PHY_INIT_CFG (QSERDES_V3_COM_PLL_IVCO ,0x07 ),QMP_PHY_INIT_CFG (QSERDES_V3_COM_SYSCLK_EN_SEL ,0x14 ),
@@ -1662,6 +1894,12 @@ static struct regulator_bulk_data qmp_phy_vreg_l[] = { { .supply = "vdda-pll", .init_load_uA = 36000, }, }; +static struct regulator_bulk_data qmp_phy_vreg_refgen[] = { + { .supply ="vdda-phy" , .init_load_uA =21800 }, + { .supply ="vdda-pll" , .init_load_uA =36000 }, + { .supply ="refgen" , .init_load_uA =3270 }, +}; +static const u8 qmp_dp_v3_pre_emphasis_hbr3_hbr2[4 ][4 ] = { {0x00 ,0x0c ,0x15 ,0x1a }, {0x02 ,0x0e ,0x16 ,0xff },
@@ -1786,6 +2024,8 @@ struct qmp_phy_cfg {int pcs_tbl_num;const struct qmp_phy_init_tbl *pcs_usb_tbl;int pcs_usb_tbl_num; +const struct qmp_phy_init_tbl *pcs_misc_tbl; +int pcs_misc_tbl_num;const struct qmp_phy_init_tbl *dp_serdes_tbl;int dp_serdes_tbl_num;
@@ -1979,6 +2219,19 @@ static const struct qmp_combo_offsets qmp_combo_offsets_v8 = { .dp_dp_phy = 0x3c00, }; +static const struct qmp_combo_offsets qmp_combo_usb43dp_offsets_v8 = { + .com =0x0000 , + .usb3_pcs_aon =0x0100 , + .usb3_serdes =0x1000 , + .usb3_pcs_misc =0x1400 , + .usb3_pcs =0x1600 , + .usb3_pcs_usb =0x1900 , + .dp_serdes =0x2000 , + .dp_dp_phy =0x2400 , + .txa =0x4000 , + .txb =0x5000 , +}; +static const struct qmp_phy_cfg sar2130p_usb3dpphy_cfg = { .offsets = &qmp_combo_offsets_v3,
@@ -2523,6 +2776,27 @@ static const struct qmp_phy_cfg sm8750_usb3dpphy_cfg = { .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), }; +static const struct qmp_phy_cfg glymur_usb3dpphy_cfg = { + .offsets = &qmp_combo_usb43dp_offsets_v8, + + .serdes_tbl = glymur_usb43dp_serdes_tbl, + .serdes_tbl_num =ARRAY_SIZE (glymur_usb43dp_serdes_tbl), + .tx_tbl = glymur_usb43dp_lalb_tbl, + .tx_tbl_num =ARRAY_SIZE (glymur_usb43dp_lalb_tbl), + .pcs_tbl = glymur_usb43dp_pcs_tbl, + .pcs_tbl_num =ARRAY_SIZE (glymur_usb43dp_pcs_tbl), + .pcs_usb_tbl = glymur_usb43dp_pcs_usb_tbl, + .pcs_usb_tbl_num =ARRAY_SIZE (glymur_usb43dp_pcs_usb_tbl), + .pcs_misc_tbl = glymur_usb43dp_pcs_misc_tbl, + .pcs_misc_tbl_num =ARRAY_SIZE (glymur_usb43dp_pcs_misc_tbl), + + .regs = qmp_v8_n3_usb43dpphy_regs_layout, + .reset_list = msm8996_usb3phy_reset_l, + .num_resets =ARRAY_SIZE (msm8996_usb3phy_reset_l), + .vreg_list = qmp_phy_vreg_refgen, + .num_vregs =ARRAY_SIZE (qmp_phy_vreg_refgen), +}; +static int qmp_combo_dp_serdes_init (struct qmp_combo *qmp) {const struct qmp_phy_cfg *cfg = qmp->cfg;
@@ -3019,6 +3293,7 @@ static int qmp_combo_com_init(struct qmp_combo *qmp, bool force) {const struct qmp_phy_cfg *cfg = qmp->cfg;void __iomem *com = qmp->com; +void __iomem *pcs_aon = qmp->pcs_aon;int ret;u32 val;
@@ -3054,6 +3329,10 @@ static int qmp_combo_com_init(struct qmp_combo *qmp, bool force)SW_DPPHY_RESET_MUX |SW_DPPHY_RESET | SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET); +/* override hardware control for reset of qmp phy */ +if (pcs_aon && cfg->regs[QPHY_AON_TOGGLE_ENABLE ]) +qphy_clrbits (pcs_aon, cfg->regs[QPHY_AON_TOGGLE_ENABLE ],0x1 ); +/* Use software based port select and switch on typec orientation */ val =SW_PORTSELECT_MUX ;if (qmp->orientation ==TYPEC_ORIENTATION_REVERSE )
@@ -3231,6 +3510,8 @@ static int qmp_combo_usb_power_on(struct phy *phy)qmp_configure_lane (qmp->dev, rx2, cfg->rx_tbl, cfg->rx_tbl_num,2 );qmp_configure (qmp->dev, pcs, cfg->pcs_tbl, cfg->pcs_tbl_num); +qmp_configure (qmp->dev, qmp->pcs_misc, cfg->pcs_misc_tbl, cfg->pcs_misc_tbl_num); +if (pcs_usb) qmp_configure(qmp->dev, pcs_usb, cfg->pcs_usb_tbl,
@@ -4221,6 +4502,10 @@ static int qmp_combo_probe(struct platform_device *pdev) }static const struct of_device_id qmp_combo_of_match_table[] = { + { + .compatible ="qcom,glymur-qmp-usb3-dp-phy" , + .data = &glymur_usb3dpphy_cfg, + }, { .compatible ="qcom,sar2130p-qmp-usb3-dp-phy" , .data = &sar2130p_usb3dpphy_cfg,
drivers/phy/qualcomm/phy-qcom-qmp-pcs-aon-v8.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025, Qualcomm Innovation Center, Inc. All rights reserved. +*/ + +#ifndef QCOM_PHY_QMP_PCS_AON_V8_H_ +#define QCOM_PHY_QMP_PCS_AON_V8_H_ + +/* Only for QMP V8 PHY - PCS_AON registers */ +#define QPHY_V8_PCS_AON_USB3_AON_CLAMP_ENABLE 0x00 +#define QPHY_V8_PCS_AON_USB4_AON_CLAMP_ENABLE 0x04 +#define QPHY_V8_PCS_AON_USB3_AON_TOGGLE_ENABLE 0x08 +#define QPHY_V8_PCS_AON_USB4_AON_TOGGLE_ENABLE 0x0c +#define QPHY_V8_PCS_AON_DP_AON_TOGGLE_ENABLE 0x10 +#define QPHY_V8_PCS_AON_DUMMY_STATUS 0x14 + +#endif
drivers/phy/qualcomm/phy-qcom-qmp-pcs-misc-v8.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved. +*/ + +#ifndef QCOM_PHY_QMP_PCS_MISC_V8_H_ +#define QCOM_PHY_QMP_PCS_MISC_V8_H_ + +/* Only for QMP V8 PHY - PCS_MISC registers */ +#define QPHY_V8_PCS_MISC_PCS_MISC_CONFIG1 0x08 + +#endif
drivers/phy/qualcomm/phy-qcom-qmp-qserdes-lalb-v8.h new file +639 -0
639 lines not on this page · raw message
drivers/phy/qualcomm/phy-qcom-qmp-usb43-pcs-v8.h new file +33 -0
@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved. +*/ + +#ifndef QCOM_PHY_QMP_USB43_PCS_V8_H_ +#define QCOM_PHY_QMP_USB43_PCS_V8_H_ + +#define QPHY_V8_USB43_PCS_SW_RESET 0x000 +#define QPHY_V8_USB43_PCS_PCS_STATUS1 0x014 +#define QPHY_V8_USB43_PCS_POWER_DOWN_CONTROL 0x040 +#define QPHY_V8_USB43_PCS_START_CONTROL 0x044 +#define QPHY_V8_USB43_PCS_POWER_STATE_CONFIG1 0x090 +#define QPHY_V8_USB43_PCS_LOCK_DETECT_CONFIG1 0x0c4 +#define QPHY_V8_USB43_PCS_LOCK_DETECT_CONFIG2 0x0c8 +#define QPHY_V8_USB43_PCS_LOCK_DETECT_CONFIG3 0x0cc +#define QPHY_V8_USB43_PCS_LOCK_DETECT_CONFIG6 0x0d8 +#define QPHY_V8_USB43_PCS_REFGEN_REQ_CONFIG1 0x0dc +#define QPHY_V8_USB43_PCS_RX_SIGDET_LVL 0x188 +#define QPHY_V8_USB43_PCS_RCVR_DTCT_DLY_P1U2_L 0x190 +#define QPHY_V8_USB43_PCS_RCVR_DTCT_DLY_P1U2_H 0x194 +#define QPHY_V8_USB43_PCS_RATE_SLEW_CNTRL1 0x198 +#define QPHY_V8_USB43_PCS_TSYNC_RSYNC_TIME 0x1ac +#define QPHY_V8_USB43_PCS_RX_CONFIG 0x1b0 +#define QPHY_V8_USB43_PCS_TSYNC_DLY_TIME 0x1b4 +#define QPHY_V8_USB43_PCS_ALIGN_DETECT_CONFIG1 0x1c0 +#define QPHY_V8_USB43_PCS_ALIGN_DETECT_CONFIG2 0x1c4 +#define QPHY_V8_USB43_PCS_PCS_TX_RX_CONFIG 0x1d0 +#define QPHY_V8_USB43_PCS_EQ_CONFIG1 0x1dc +#define QPHY_V8_USB43_PCS_EQ_CONFIG2 0x1e0 +#define QPHY_V8_USB43_PCS_EQ_CONFIG5 0x1ec + +#endif
drivers/phy/qualcomm/phy-qcom-qmp-usb43-qserdes-com-v8.h new file +224 -0
224 lines not on this page · raw message
drivers/phy/qualcomm/phy-qcom-qmp.h +2 -0
@@ -32,7 +32,9 @@#include "phy-qcom-qmp-qserdes-txrx-v7.h" #include "phy-qcom-qmp-qserdes-com-v8.h" +#include "phy-qcom-qmp-usb43-qserdes-com-v8.h" #include "phy-qcom-qmp-qserdes-txrx-v8.h" +#include "phy-qcom-qmp-qserdes-lalb-v8.h" #include "phy-qcom-qmp-qserdes-pll.h"
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1103/1518 phy: qualcomm: qmp-combo: Add DP offsets and settings for Glymur platforms
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
[ Upstream commit d10736db98d25c97bdffacaca69ae0a8d7ca64e3 ]
Starting with Glymur, the PCIe and DP PHYs qserdes register offsets differ for the same version number. So in order to be able to differentiate between them, add these ones with DP prefix.
Add the necessary PHY setting tables for enabling the DP path within the QMP subsystem. Introduced some new callbacks for v8 specific sequences, such as for clock configurations based on the different link speeds.
Wesley Cheng added some updated settings from the hardware programming guides on existing PHY tables and clock settings.
Stable-dep-of: 8fd2b30d187f ("phy: qcom: qmp-combo: Drop qmp_v4_calibrate_dp_phy")
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 355 +++++++++++++++++- drivers/phy/qualcomm/phy-qcom-qmp-dp-phy-v8.h | 25 ++ .../qualcomm/phy-qcom-qmp-dp-qserdes-com-v8.h | 52 +++ 3 files changed, 428 insertions(+), 4 deletions(-) create mode 100644 drivers/phy/qualcomm/phy-qcom-qmp-dp-phy-v8.h create mode 100644 drivers/phy/qualcomm/phy-qcom-qmp-dp-qserdes-com-v8.h
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +351 -4
@@ -47,6 +47,7 @@#include "phy-qcom-qmp-dp-phy-v4.h" #include "phy-qcom-qmp-dp-phy-v5.h" #include "phy-qcom-qmp-dp-phy-v6.h" +#include "phy-qcom-qmp-dp-phy-v8.h" #include "phy-qcom-qmp-usb43-pcs-v8.h"
@@ -102,6 +103,7 @@ enum qphy_reg_layout {QPHY_TX_TRANSCEIVER_BIAS_EN ,QPHY_AON_TOGGLE_ENABLE , +QPHY_DP_AON_TOGGLE_ENABLE ,/* Keep last to ensure regs_layout arrays are properly initialized */ QPHY_LAYOUT_SIZE };
@@ -276,12 +278,16 @@ static const unsigned int qmp_v8_n3_usb43dpphy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_PCS_CLAMP_ENABLE] = QPHY_V8_PCS_AON_USB3_AON_CLAMP_ENABLE, [QPHY_AON_TOGGLE_ENABLE] = QPHY_V8_PCS_AON_USB3_AON_TOGGLE_ENABLE, + [QPHY_DP_AON_TOGGLE_ENABLE] = QPHY_V8_PCS_AON_DP_AON_TOGGLE_ENABLE, [QPHY_COM_RESETSM_CNTRL] = QSERDES_V8_COM_RESETSM_CNTRL, [QPHY_COM_C_READY_STATUS] = QSERDES_V8_COM_C_READY_STATUS, [QPHY_COM_CMN_STATUS] = QSERDES_V8_COM_CMN_STATUS, [QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V8_COM_BIAS_EN_CLKBUFLR_EN, + [QPHY_DP_PHY_STATUS] = QSERDES_V8_DP_PHY_STATUS, + [QPHY_DP_PHY_VCO_DIV] = QSERDES_V8_DP_PHY_VCO_DIV, + [QPHY_TX_TX_DRV_LVL] = QSERDES_V8_LALB_TX0_DRV_LVL, [QPHY_TX_TX_EMP_POST1_LVL] = QSERDES_V8_LALB_TX0_EMP_POST1_LVL, [QPHY_TX_HIGHZ_DRVR_EN] = QSERDES_V8_LALB_HIGHZ_DRVR_EN,
@@ -1377,6 +1383,38 @@ static const struct qmp_phy_init_tbl qmp_v6_n4_dp_serdes_tbl[] = { QMP_PHY_INIT_CFG(QSERDES_V6_COM_CORE_CLK_EN, 0x0f), }; +static const struct qmp_phy_init_tbl qmp_v8_dp_serdes_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_STEP_SIZE2_MODE0 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CP_CTRL_MODE0 ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_PLL_RCTRL_MODE1 ,0x10 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_PLL_CCTRL_MODE1 ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CORECLK_DIV_MODE0 ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DIV_FRAC_START1_MODE0 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_INTEGLOOP_GAIN0_MODE0 ,0x3f ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_INTEGLOOP_GAIN1_MODE0 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BG_TIMER ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_EN_CENTER ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_ADJ_PER1 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_PER1 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_PER2 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CLK_ENABLE1 ,0x0c ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SYS_CLK_CTRL ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SYSCLK_BUF_ENABLE ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_PLL_IVCO ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SYSCLK_EN_SEL ,0x3b ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_LOCK_CMP_EN ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE_CTRL ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE_MAP ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CLK_SELECT ,0x30 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CORE_CLK_EN ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CMN_CONFIG_1 ,0x56 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SVS_MODE_CLK_SEL ,0x15 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CMN_MODE_CONTD1 ,0x24 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DCC_CAL_1 ,0x40 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DCC_CAL_3 ,0x60 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_PSM_CAL_EN ,0x01 ), +}; +static const struct qmp_phy_init_tbl qmp_v6_dp_tx_tbl[] = {QMP_PHY_INIT_CFG (QSERDES_V6_TX_VMODE_CTRL1 ,0x40 ),QMP_PHY_INIT_CFG (QSERDES_V6_TX_PRE_STALL_LDO_BOOST_EN ,0x30 ),
@@ -1404,6 +1442,33 @@ static const struct qmp_phy_init_tbl qmp_v6_n4_dp_tx_tbl[] = { QMP_PHY_INIT_CFG(QSERDES_V6_N4_TX_TX_BAND, 0x1), }; +static const struct qmp_phy_init_tbl qmp_v8_n3p_dp_tx_tbl[] = { +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TRANSMITTER_EN_CTRL ,0x3f ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_VMODE_CTRL1 ,0x40 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_ANA_INTERFACE_SELECT1 ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_ANA_INTERFACE_SELECT2 ,0x18 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_PCS_INTERFACE_SELECT1 ,0x50 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_LANE_MODE_1 ,0x0d ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_CLKBUF_ENABLE ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_RESET_TSYNC_EN_CTRL ,0x0a ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX_LVL_UPDATE_CTRL ,0x0f ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TRAN_DRVR_EMP_EN ,0x5f ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX0_EMP_POST1_LVL ,0x20 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX1_EMP_POST1_LVL ,0x20 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX0_PRE1_EMPH ,0x20 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX1_PRE1_EMPH ,0x20 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX0_DRV_LVL ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX1_DRV_LVL ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_HIGHZ_DRVR_EN ,0x30 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_LANE_MODE_2 ,0x50 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_LANE_MODE_3 ,0x51 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX_DCC_ANA_CTRL2 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX0_RESTRIM_CAL_CTRL ,0x20 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX1_RESTRIM_CAL_CTRL ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX0_RESTRIM_POST_CAL_OFFSET ,0x10 ), +QMP_PHY_INIT_CFG (QSERDES_V8_LALB_TX1_RESTRIM_POST_CAL_OFFSET ,0x10 ), +}; +static const struct qmp_phy_init_tbl qmp_v6_dp_serdes_tbl_rbr[] = {QMP_PHY_INIT_CFG (QSERDES_V6_COM_HSCLK_SEL_1 ,0x05 ),QMP_PHY_INIT_CFG (QSERDES_V6_COM_DEC_START_MODE0 ,0x34 ),
@@ -1520,6 +1585,109 @@ static const struct qmp_phy_init_tbl qmp_v6_n4_dp_serdes_tbl_hbr3[] = { QMP_PHY_INIT_CFG(QSERDES_V6_COM_SSC_STEP_SIZE2_MODE0, 0x01), }; +static const struct qmp_phy_init_tbl qmp_v8_dp_serdes_tbl_rbr[] = { +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_HSCLK_SEL_1 ,0x05 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIN_VCOCAL_CMP_CODE1_MODE0 ,0x7a ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIN_VCOCAL_CMP_CODE2_MODE0 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_STEP_SIZE1_MODE0 ,0x83 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_LOCK_CMP1_MODE0 ,0x37 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_LOCK_CMP2_MODE0 ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DEC_START_MODE0 ,0x54 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DIV_FRAC_START2_MODE0 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DIV_FRAC_START3_MODE0 ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE1_MODE0 ,0xfe ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE2_MODE0 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIN_VCOCAL_HSCLK_SEL_1 ,0x05 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CMN_MODE_CONTD3 ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CLK_FWD_CONFIG_1 ,0x30 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_IP_CTRL_AND_DP_SEL ,0xa4 ), +}; + +static const struct qmp_phy_init_tbl qmp_v8_dp_serdes_tbl_hbr[] = { +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_HSCLK_SEL_1 ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIN_VCOCAL_CMP_CODE1_MODE0 ,0x21 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIN_VCOCAL_CMP_CODE2_MODE0 ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_STEP_SIZE1_MODE0 ,0x18 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_LOCK_CMP1_MODE0 ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_LOCK_CMP2_MODE0 ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DEC_START_MODE0 ,0x46 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DIV_FRAC_START2_MODE0 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DIV_FRAC_START3_MODE0 ,0x05 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE1_MODE0 ,0xae ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE2_MODE0 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIN_VCOCAL_HSCLK_SEL_1 ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CMN_MODE_CONTD3 ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CLK_FWD_CONFIG_1 ,0x3f ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_IP_CTRL_AND_DP_SEL ,0xa3 ), +}; + +static const struct qmp_phy_init_tbl qmp_v8_dp_serdes_tbl_hbr2[] = { +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_HSCLK_SEL_1 ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIN_VCOCAL_CMP_CODE1_MODE0 ,0xf6 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIN_VCOCAL_CMP_CODE2_MODE0 ,0x20 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_STEP_SIZE1_MODE0 ,0x0 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_PLL_RCTRL_MODE0 ,0x16 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_PLL_CCTRL_MODE0 ,0x36 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_LOCK_CMP1_MODE0 ,0x10 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_LOCK_CMP2_MODE0 ,0x0e ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DEC_START_MODE0 ,0x46 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DIV_FRAC_START2_MODE0 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DIV_FRAC_START3_MODE0 ,0x05 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE1_MODE0 ,0xae ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE2_MODE0 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIN_VCOCAL_HSCLK_SEL_1 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_IP_CTRL_AND_DP_SEL ,0xbf ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIAS_EN_CLKBUFLR_EN ,0x1c ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_RESETSM_CNTRL ,0x20 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CMN_MODE_CONTD3 ,0x03 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CLK_FWD_CONFIG_1 ,0x3f ), +}; + +static const struct qmp_phy_init_tbl qmp_v8_dp_serdes_tbl_hbr3[] = { +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_HSCLK_SEL_1 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIN_VCOCAL_CMP_CODE1_MODE0 ,0x63 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIN_VCOCAL_CMP_CODE2_MODE0 ,0x0c ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_STEP_SIZE1_MODE0 ,0x5b ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_STEP_SIZE2_MODE0 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CP_CTRL_MODE0 ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_PLL_RCTRL_MODE0 ,0x16 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_PLL_CCTRL_MODE0 ,0x36 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CORECLK_DIV_MODE0 ,0x0a ), + +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_LOCK_CMP1_MODE0 ,0x17 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_LOCK_CMP2_MODE0 ,0x15 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DEC_START_MODE0 ,0x4f ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DIV_FRAC_START1_MODE0 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DIV_FRAC_START2_MODE0 ,0xa0 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_DIV_FRAC_START3_MODE0 ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_INTEGLOOP_GAIN0_MODE0 ,0x3f ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_INTEGLOOP_GAIN1_MODE0 ,0x00 ), + +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE1_MODE0 ,0xa0 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE2_MODE0 ,0x01 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_ADJ_PER1 ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_PER1 ,0x6b ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SSC_PER2 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CLK_ENABLE1 ,0x0c ), + +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SYS_CLK_CTRL ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SYSCLK_BUF_ENABLE ,0x06 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_PLL_IVCO ,0x07 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SYSCLK_EN_SEL ,0x04 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE_CTRL ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_VCO_TUNE_MAP ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CLK_SELECT ,0x30 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CORE_CLK_EN ,0x00 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CMN_CONFIG_1 ,0x16 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_SVS_MODE_CLK_SEL ,0x15 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CLK_FWD_CONFIG_1 ,0x30 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIAS_EN_CLKBUFLR_EN ,0x10 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CMN_MODE_CONTD3 ,0x05 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_CMN_MODE_CONTD1 ,0x24 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_BIN_VCOCAL_HSCLK_SEL_1 ,0x02 ), +QMP_PHY_INIT_CFG (QSERDES_V8_USB43_COM_IP_CTRL_AND_DP_SEL ,0x84 ), +}; +static const struct qmp_phy_init_tbl sc8280xp_usb43dp_serdes_tbl[] = {QMP_PHY_INIT_CFG (QSERDES_V5_COM_SSC_EN_CENTER ,0x01 ),QMP_PHY_INIT_CFG (QSERDES_V5_COM_SSC_PER1 ,0x31 ),
@@ -2049,6 +2217,7 @@ struct qmp_phy_cfg {const u8 (*pre_emphasis_hbr3_hbr2)[4 ][4 ];/* DP PHY callbacks */ +int (*configure_dp_clocks)(struct qmp_combo *qmp);int (*configure_dp_phy)(struct qmp_combo *qmp);void (*configure_dp_tx)(struct qmp_combo *qmp);int (*calibrate_dp_phy)(struct qmp_combo *qmp);
@@ -2126,6 +2295,7 @@ struct qmp_combo {static void qmp_v3_dp_aux_init (struct qmp_combo *qmp);static void qmp_v3_configure_dp_tx (struct qmp_combo *qmp); +static int qmp_v3_configure_dp_clocks (struct qmp_combo *qmp);static int qmp_v3_configure_dp_phy (struct qmp_combo *qmp);static int qmp_v3_calibrate_dp_phy (struct qmp_combo *qmp);
@@ -2134,6 +2304,10 @@ static void qmp_v4_configure_dp_tx(struct qmp_combo *qmp);static int qmp_v4_configure_dp_phy (struct qmp_combo *qmp);static int qmp_v4_calibrate_dp_phy (struct qmp_combo *qmp); +static void qmp_v8_dp_aux_init (struct qmp_combo *qmp); +static int qmp_v8_configure_dp_clocks (struct qmp_combo *qmp); +static int qmp_v8_configure_dp_phy (struct qmp_combo *qmp); +static inline void qphy_setbits (void __iomem *base,u32 offset,u32 val) {u32 reg;
@@ -2267,6 +2441,7 @@ static const struct qmp_phy_cfg sar2130p_usb3dpphy_cfg = { .dp_aux_init = qmp_v4_dp_aux_init, .configure_dp_tx = qmp_v4_configure_dp_tx, + .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, .calibrate_dp_phy = qmp_v4_calibrate_dp_phy,
@@ -2402,6 +2577,7 @@ static const struct qmp_phy_cfg sc8180x_usb3dpphy_cfg = { .dp_aux_init = qmp_v4_dp_aux_init, .configure_dp_tx = qmp_v4_configure_dp_tx, + .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, .calibrate_dp_phy = qmp_v4_calibrate_dp_phy,
@@ -2448,6 +2624,7 @@ static const struct qmp_phy_cfg sc8280xp_usb43dpphy_cfg = { .dp_aux_init = qmp_v4_dp_aux_init, .configure_dp_tx = qmp_v4_configure_dp_tx, + .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, .calibrate_dp_phy = qmp_v4_calibrate_dp_phy,
@@ -2493,6 +2670,7 @@ static const struct qmp_phy_cfg x1e80100_usb3dpphy_cfg = { .dp_aux_init = qmp_v4_dp_aux_init, .configure_dp_tx = qmp_v4_configure_dp_tx, + .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, .calibrate_dp_phy = qmp_v4_calibrate_dp_phy,
@@ -2581,6 +2759,7 @@ static const struct qmp_phy_cfg sm8250_usb3dpphy_cfg = { .dp_aux_init = qmp_v4_dp_aux_init, .configure_dp_tx = qmp_v4_configure_dp_tx, + .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, .calibrate_dp_phy = qmp_v4_calibrate_dp_phy,
@@ -2629,6 +2808,7 @@ static const struct qmp_phy_cfg sm8350_usb3dpphy_cfg = { .dp_aux_init = qmp_v4_dp_aux_init, .configure_dp_tx = qmp_v4_configure_dp_tx, + .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, .calibrate_dp_phy = qmp_v4_calibrate_dp_phy,
@@ -2676,6 +2856,7 @@ static const struct qmp_phy_cfg sm8550_usb3dpphy_cfg = { .dp_aux_init = qmp_v4_dp_aux_init, .configure_dp_tx = qmp_v4_configure_dp_tx, + .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, .calibrate_dp_phy = qmp_v4_calibrate_dp_phy,
@@ -2721,6 +2902,7 @@ static const struct qmp_phy_cfg sm8650_usb3dpphy_cfg = { .dp_aux_init = qmp_v4_dp_aux_init, .configure_dp_tx = qmp_v4_configure_dp_tx, + .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, .calibrate_dp_phy = qmp_v4_calibrate_dp_phy,
@@ -2766,6 +2948,7 @@ static const struct qmp_phy_cfg sm8750_usb3dpphy_cfg = { .dp_aux_init = qmp_v4_dp_aux_init, .configure_dp_tx = qmp_v4_configure_dp_tx, + .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, .calibrate_dp_phy = qmp_v4_calibrate_dp_phy,
@@ -2790,6 +2973,31 @@ static const struct qmp_phy_cfg glymur_usb3dpphy_cfg = { .pcs_misc_tbl = glymur_usb43dp_pcs_misc_tbl, .pcs_misc_tbl_num = ARRAY_SIZE(glymur_usb43dp_pcs_misc_tbl), + .dp_serdes_tbl = qmp_v8_dp_serdes_tbl, + .dp_serdes_tbl_num = ARRAY_SIZE(qmp_v8_dp_serdes_tbl), + .dp_tx_tbl = qmp_v8_n3p_dp_tx_tbl, + .dp_tx_tbl_num = ARRAY_SIZE(qmp_v8_n3p_dp_tx_tbl), + + .serdes_tbl_rbr = qmp_v8_dp_serdes_tbl_rbr, + .serdes_tbl_rbr_num = ARRAY_SIZE(qmp_v8_dp_serdes_tbl_rbr), + .serdes_tbl_hbr = qmp_v8_dp_serdes_tbl_hbr, + .serdes_tbl_hbr_num = ARRAY_SIZE(qmp_v8_dp_serdes_tbl_hbr), + .serdes_tbl_hbr2 = qmp_v8_dp_serdes_tbl_hbr2, + .serdes_tbl_hbr2_num = ARRAY_SIZE(qmp_v8_dp_serdes_tbl_hbr2), + .serdes_tbl_hbr3 = qmp_v8_dp_serdes_tbl_hbr3, + .serdes_tbl_hbr3_num = ARRAY_SIZE(qmp_v8_dp_serdes_tbl_hbr3), + + .swing_hbr_rbr = &qmp_dp_v6_voltage_swing_hbr_rbr, + .pre_emphasis_hbr_rbr = &qmp_dp_v6_pre_emphasis_hbr_rbr, + .swing_hbr3_hbr2 = &qmp_dp_v5_voltage_swing_hbr3_hbr2, + .pre_emphasis_hbr3_hbr2 = &qmp_dp_v5_pre_emphasis_hbr3_hbr2, + + .dp_aux_init = qmp_v8_dp_aux_init, + .configure_dp_tx = qmp_v4_configure_dp_tx, + .configure_dp_clocks = qmp_v8_configure_dp_clocks, + .configure_dp_phy = qmp_v8_configure_dp_phy, + .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, + .regs = qmp_v8_n3_usb43dpphy_regs_layout, .reset_list = msm8996_usb3phy_reset_l, .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
@@ -2959,7 +3167,7 @@ static bool qmp_combo_configure_dp_mode(struct qmp_combo *qmp)return reverse; } -static int qmp_combo_configure_dp_clocks (struct qmp_combo *qmp) +static int qmp_v3_configure_dp_clocks (struct qmp_combo *qmp) {const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts;u32 phy_vco_div;
@@ -3006,7 +3214,7 @@ static int qmp_v3_configure_dp_phy(struct qmp_combo *qmp)writel (0x05 , qmp->dp_dp_phy +QSERDES_V3_DP_PHY_TX0_TX1_LANE_CTL );writel (0x05 , qmp->dp_dp_phy +QSERDES_V3_DP_PHY_TX2_TX3_LANE_CTL ); - ret =qmp_combo_configure_dp_clocks (qmp); + ret =qmp_v3_configure_dp_clocks (qmp);if (ret)return ret;
@@ -3092,6 +3300,35 @@ static void qmp_v4_dp_aux_init(struct qmp_combo *qmp) qmp->dp_dp_phy + QSERDES_V4_DP_PHY_AUX_INTERRUPT_MASK); } +static void qmp_v8_dp_aux_init (struct qmp_combo *qmp) +{ +const struct qmp_phy_cfg *cfg = qmp->cfg; + +writel (DP_PHY_PD_CTL_PWRDN |DP_PHY_PD_CTL_PSR_PWRDN |DP_PHY_PD_CTL_AUX_PWRDN | +DP_PHY_PD_CTL_PLL_PWRDN |DP_PHY_PD_CTL_DP_CLAMP_EN , + qmp->dp_dp_phy +QSERDES_DP_PHY_PD_CTL ); + +/* Turn on BIAS current for PHY/PLL */ +writel (0x1c , qmp->dp_serdes + cfg->regs[QPHY_COM_BIAS_EN_CLKBUFLR_EN ]); + +writel (0x00 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG0 ); +writel (0x13 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG1 ); +writel (0x06 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG2 ); +writel (0x00 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG3 ); +writel (0x0a , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG4 ); +writel (0x26 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG5 ); +writel (0x0a , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG6 ); +writel (0x03 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG7 ); +writel (0xb7 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG8 ); +writel (0x03 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG9 ); + qmp->dp_aux_cfg =0 ; + +writel (PHY_AUX_STOP_ERR_MASK |PHY_AUX_DEC_ERR_MASK | +PHY_AUX_SYNC_ERR_MASK |PHY_AUX_ALIGN_ERR_MASK | +PHY_AUX_REQ_ERR_MASK , + qmp->dp_dp_phy +QSERDES_V4_DP_PHY_AUX_INTERRUPT_MASK ); +} +static void qmp_v4_configure_dp_tx (struct qmp_combo *qmp) {const struct qmp_phy_cfg *cfg = qmp->cfg;
@@ -3106,6 +3343,58 @@ static void qmp_v4_configure_dp_tx(struct qmp_combo *qmp)qmp_combo_configure_dp_swing (qmp); } +static int qmp_v8_configure_dp_clocks (struct qmp_combo *qmp) +{ +const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts; +u32 phy_vco_div; +unsigned long pixel_freq; +const struct qmp_phy_cfg *cfg = qmp->cfg; + +switch (dp_opts->link_rate) { +case 1620 : + phy_vco_div =0x4 ; + pixel_freq =1620000000UL /2 ; +break ; +case 2700 : + phy_vco_div =0x2 ; + pixel_freq =2700000000UL /2 ; +break ; +case 5400 : + phy_vco_div =0x4 ; + pixel_freq =5400000000UL /4 ; +break ; +case 8100 : + phy_vco_div =0x3 ; + pixel_freq =8100000000UL /6 ; +break ; +default : +/* Other link rates aren't supported */ +return -EINVAL ; + } +writel (phy_vco_div, qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_VCO_DIV ]); + +/* disable core reset tsync */ +writel (0x09 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG ); + +writel (0x04 , qmp->dp_dp_phy +QSERDES_V8_DP_PHY_AUXLESS_SETUP_CYC ); +writel (0x08 , qmp->dp_dp_phy +QSERDES_V8_DP_PHY_AUXLESS_SILENCE_CYC ); +writel (0x08 , qmp->dp_dp_phy +QSERDES_V8_DP_PHY_LFPS_CYC ); +writel (0x11 , qmp->dp_dp_phy +QSERDES_V8_DP_PHY_LFPS_PERIOD ); + +writel (0x3e , qmp->dp_dp_phy +QSERDES_V8_DP_PHY_TSYNC_OVRD ); +writel (0x05 , qmp->dp_dp_phy +QSERDES_V8_DP_PHY_TX2_TX3_LANE_CTL ); +writel (0x05 , qmp->dp_dp_phy +QSERDES_V8_DP_PHY_TX0_TX1_LANE_CTL ); +writel (0x01 , qmp->dp_dp_phy +QSERDES_V8_DP_PHY_AUXLESS_CFG1 ); +writel (0x11 , qmp->dp_dp_phy +QSERDES_V8_DP_PHY_LFPS_PERIOD ); +writel (0x1f , qmp->dp_dp_phy +QSERDES_V8_DP_PHY_LN0_DRV_LVL ); +writel (0x1f , qmp->dp_dp_phy +QSERDES_V8_DP_PHY_LN1_DRV_LVL ); + +clk_set_rate (qmp->dp_link_hw.clk, dp_opts->link_rate *100000 ); +clk_set_rate (qmp->dp_pixel_hw.clk, pixel_freq); + +return 0 ; +} +static int qmp_v456_configure_dp_phy (struct qmp_combo *qmp) {const struct qmp_phy_cfg *cfg = qmp->cfg;
@@ -3122,7 +3411,7 @@ static int qmp_v456_configure_dp_phy(struct qmp_combo *qmp)writel (0x05 , qmp->dp_dp_phy +QSERDES_V4_DP_PHY_TX0_TX1_LANE_CTL );writel (0x05 , qmp->dp_dp_phy +QSERDES_V4_DP_PHY_TX2_TX3_LANE_CTL ); - ret =qmp_combo_configure_dp_clocks (qmp); + ret = qmp->cfg->configure_dp_clocks (qmp);if (ret)return ret;
@@ -3236,6 +3525,62 @@ static int qmp_v4_configure_dp_phy(struct qmp_combo *qmp)return 0 ; } +static int qmp_v8_configure_dp_phy (struct qmp_combo *qmp) +{ +const struct qmp_phy_cfg *cfg = qmp->cfg; +bool reverse = (qmp->orientation ==TYPEC_ORIENTATION_REVERSE ); +const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts; +u32 bias0_en, drvr0_en, bias1_en, drvr1_en; +u32 status; +int ret; + + ret =qmp_v456_configure_dp_phy (qmp); +if (ret <0 ) +return ret; + +if (dp_opts->lanes ==1 ) { + bias0_en = reverse ?0x3e :0x15 ; + bias1_en = reverse ?0x15 :0x3e ; + drvr0_en = reverse ?0x13 :0x10 ; + drvr1_en = reverse ?0x10 :0x13 ; + }else if (dp_opts->lanes ==2 ) { + bias0_en = reverse ?0x3f :0x15 ; + bias1_en = reverse ?0x15 :0x3f ; + drvr0_en =0x10 ; + drvr1_en =0x10 ; + }else { + bias0_en =0x3f ; + bias1_en =0x3f ; + drvr0_en =0x34 ; + drvr1_en =0x34 ; + } + +writel (drvr0_en, qmp->dp_tx + cfg->regs[QPHY_TX_HIGHZ_DRVR_EN ]); +writel (bias0_en, qmp->dp_tx + cfg->regs[QPHY_TX_TRANSCEIVER_BIAS_EN ]); +writel (drvr1_en, qmp->dp_tx2 + cfg->regs[QPHY_TX_HIGHZ_DRVR_EN ]); +writel (bias1_en, qmp->dp_tx2 + cfg->regs[QPHY_TX_TRANSCEIVER_BIAS_EN ]); + +writel (0x08 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG ); +udelay (100 ); +writel (0x09 , qmp->dp_dp_phy +QSERDES_DP_PHY_CFG ); +udelay (500 ); + +if (readl_poll_timeout (qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_STATUS ], + status, + ((status &BIT (1 )) >0 ), +500 , +10000 )) +return -ETIMEDOUT ; + +writel (0x00 , qmp->dp_tx + cfg->regs[QPHY_TX_TX_DRV_LVL ]); +writel (0x00 , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_DRV_LVL ]); + +writel (0x2b , qmp->dp_tx + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL ]); +writel (0x2b , qmp->dp_tx2 + cfg->regs[QPHY_TX_TX_EMP_POST1_LVL ]); + +return 0 ; +} +/* * We need to calibrate the aux setting here as many times * as the caller tries
@@ -3330,8 +3675,10 @@ static int qmp_combo_com_init(struct qmp_combo *qmp, bool force) SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET);/* override hardware control for reset of qmp phy */ -if (pcs_aon && cfg->regs[QPHY_AON_TOGGLE_ENABLE ]) +if (pcs_aon && cfg->regs[QPHY_AON_TOGGLE_ENABLE ]) {qphy_clrbits (pcs_aon, cfg->regs[QPHY_AON_TOGGLE_ENABLE ],0x1 ); +qphy_clrbits (pcs_aon, cfg->regs[QPHY_DP_AON_TOGGLE_ENABLE ],0x1 ); + }/* Use software based port select and switch on typec orientation */ val =SW_PORTSELECT_MUX ;
drivers/phy/qualcomm/phy-qcom-qmp-dp-phy-v8.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2017, The Linux Foundation. All rights reserved. +*/ + +#ifndef QCOM_PHY_QMP_DP_PHY_V8_H_ +#define QCOM_PHY_QMP_DP_PHY_V8_H_ + +/* Only for QMP V8 PHY - DP PHY registers */ +#define QSERDES_V8_DP_PHY_VCO_DIV 0x070 +#define QSERDES_V8_DP_PHY_AUX_INTERRUPT_STATUS 0x0e0 +#define QSERDES_V8_DP_PHY_TSYNC_OVRD 0x074 +#define QSERDES_V8_DP_PHY_TX0_TX1_LANE_CTL 0x078 +#define QSERDES_V8_DP_PHY_TX2_TX3_LANE_CTL 0x0bc +#define QSERDES_V8_DP_PHY_AUXLESS_CFG1 0x0c8 +#define QSERDES_V8_DP_PHY_LFPS_PERIOD 0x0d0 +#define QSERDES_V8_DP_PHY_LFPS_CYC 0x0d4 +#define QSERDES_V8_DP_PHY_AUXLESS_SETUP_CYC 0x0d8 +#define QSERDES_V8_DP_PHY_AUXLESS_SILENCE_CYC 0x0d8 +#define QSERDES_V8_DP_PHY_LN0_DRV_LVL 0x0e0 +#define QSERDES_V8_DP_PHY_LN1_DRV_LVL 0x0e4 +#define QSERDES_V8_DP_PHY_STATUS 0x114 + + +#endif
drivers/phy/qualcomm/phy-qcom-qmp-dp-qserdes-com-v8.h new file +52 -0
52 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1104/1518 phy: qcom: qmp-combo: Drop qmp_v4_calibrate_dp_phy
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Esteban Urrutia <[email protected]>
[ Upstream commit 8fd2b30d187fa33e5dd30699d3e3a3662c1610c9 ]
There are no downstream device trees that specify five values in the qcom,aux-cfg1-settings array.
Plus, after cross referencing both downstream device trees and entries which refer this function, only 0x13 is specified.
Since 0x13 is written at initialization time, drop this function as a whole, and remove now unused variable assignations.
--- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 31 ----------------------- 1 file changed, 31 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +0 -31
@@ -2302,7 +2302,6 @@ static int qmp_v3_calibrate_dp_phy(struct qmp_combo *qmp);static void qmp_v4_dp_aux_init (struct qmp_combo *qmp);static void qmp_v4_configure_dp_tx (struct qmp_combo *qmp);static int qmp_v4_configure_dp_phy (struct qmp_combo *qmp); -static int qmp_v4_calibrate_dp_phy (struct qmp_combo *qmp);static void qmp_v8_dp_aux_init (struct qmp_combo *qmp);static int qmp_v8_configure_dp_clocks (struct qmp_combo *qmp);
@@ -2443,7 +2442,6 @@ static const struct qmp_phy_cfg sar2130p_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .regs = qmp_v6_usb3phy_regs_layout, .reset_list = msm8996_usb3phy_reset_l,
@@ -2579,7 +2577,6 @@ static const struct qmp_phy_cfg sc8180x_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .reset_list = msm8996_usb3phy_reset_l, .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
@@ -2626,7 +2623,6 @@ static const struct qmp_phy_cfg sc8280xp_usb43dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .reset_list = msm8996_usb3phy_reset_l, .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
@@ -2672,7 +2668,6 @@ static const struct qmp_phy_cfg x1e80100_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .reset_list = msm8996_usb3phy_reset_l, .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
@@ -2761,7 +2756,6 @@ static const struct qmp_phy_cfg sm8250_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .reset_list = msm8996_usb3phy_reset_l, .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
@@ -2810,7 +2804,6 @@ static const struct qmp_phy_cfg sm8350_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .reset_list = msm8996_usb3phy_reset_l, .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
@@ -2858,7 +2851,6 @@ static const struct qmp_phy_cfg sm8550_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .regs = qmp_v6_usb3phy_regs_layout, .reset_list = msm8996_usb3phy_reset_l,
@@ -2904,7 +2896,6 @@ static const struct qmp_phy_cfg sm8650_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .regs = qmp_v6_usb3phy_regs_layout, .reset_list = msm8996_usb3phy_reset_l,
@@ -2950,7 +2941,6 @@ static const struct qmp_phy_cfg sm8750_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v3_configure_dp_clocks, .configure_dp_phy = qmp_v4_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .regs = qmp_v8_usb3phy_regs_layout, .reset_list = msm8996_usb3phy_reset_l,
@@ -2996,7 +2986,6 @@ static const struct qmp_phy_cfg glymur_usb3dpphy_cfg = { .configure_dp_tx = qmp_v4_configure_dp_tx, .configure_dp_clocks = qmp_v8_configure_dp_clocks, .configure_dp_phy = qmp_v8_configure_dp_phy, - .calibrate_dp_phy = qmp_v4_calibrate_dp_phy, .regs = qmp_v8_n3_usb43dpphy_regs_layout, .reset_list = msm8996_usb3phy_reset_l,
@@ -3292,7 +3281,6 @@ static void qmp_v4_dp_aux_init(struct qmp_combo *qmp)writel (0x03 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG7 );writel (0xb7 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG8 );writel (0x03 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG9 ); - qmp->dp_aux_cfg =0 ; writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK | PHY_AUX_SYNC_ERR_MASK | PHY_AUX_ALIGN_ERR_MASK |
@@ -3321,7 +3309,6 @@ static void qmp_v8_dp_aux_init(struct qmp_combo *qmp)writel (0x03 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG7 );writel (0xb7 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG8 );writel (0x03 , qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG9 ); - qmp->dp_aux_cfg =0 ; writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK | PHY_AUX_SYNC_ERR_MASK | PHY_AUX_ALIGN_ERR_MASK |
@@ -3581,24 +3568,6 @@ static int qmp_v8_configure_dp_phy(struct qmp_combo *qmp)return 0 ; } -/* -* We need to calibrate the aux setting here as many times -* as the caller tries -*/ -static int qmp_v4_calibrate_dp_phy (struct qmp_combo *qmp) -{ -static const u8 cfg1_settings[] = {0x20 ,0x13 ,0x23 ,0x1d }; -u8 val; - - qmp->dp_aux_cfg++; - qmp->dp_aux_cfg %=ARRAY_SIZE (cfg1_settings); - val = cfg1_settings[qmp->dp_aux_cfg]; - -writel (val, qmp->dp_dp_phy +QSERDES_DP_PHY_AUX_CFG1 ); - -return 0 ; -} -static int qmp_combo_dp_configure (struct phy *phy,union phy_configure_opts *opts) {const struct phy_configure_opts_dp *dp_opts = &opts->dp;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1105/1518 spi: sprd-adi: Fix probe succeeding without registering the controller
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Babanpreet Singh <[email protected]>
[ Upstream commit f092e1c935015ee0a0fea1a0374f4cab7b71953c ]
With CONFIG_HWSPINLOCK=n the of_hwspin_lock_get_id() stub returns 0 unconditionally. In sprd_adi_probe() the guard
if (ret > 0 || (IS_ENABLED(CONFIG_HWSPINLOCK) && ret == 0))
is false for that 0, so it takes the else branch, where the switch has no case for 0 and lands in
default: return dev_err_probe(&pdev->dev, ret, "failed to find hwlock id\n");
dev_err_probe() returns its err argument unchanged, so probe logs "failed to find hwlock id" and then returns 0, reporting success. sprd_adi_hw_init(), the restart handler and devm_spi_register_controller() are all skipped: the device binds but no SPI controller is ever registered.
The hardware spinlock is optional for this controller and the -ENOENT arm already covers "no hardware spinlock supplied". Treat the stub's 0 the same way and continue without a lock; all four users of sadi->hwlock already test it for NULL.
This is not reachable on production kernels. Kconfig has
depends on HWSPINLOCK || (COMPILE_TEST && !HWSPINLOCK)
so the affected configuration exists only under COMPILE_TEST, where no real hardware is present.
Found by smatch:drivers/spi/spi-sprd-adi.c:560 sprd_adi_probe() warn: passing zero to 'dev_err_probe'
--- drivers/spi/spi-sprd-adi.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/spi/spi-sprd-adi.c +6 -0
@@ -553,6 +553,12 @@ static int sprd_adi_probe(struct platform_device *pdev)return -ENXIO ; }else {switch (ret) { +case 0 : +/* +* Only reachable with CONFIG_HWSPINLOCK=n, where the +* of_hwspin_lock_get_id() stub returns 0. +*/ + fallthrough;case -ENOENT :dev_info (&pdev->dev,"no hardware spinlock supplied\n" );break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1106/1518 ASoC: qcom: q6apm: keep the graph start count in sync with the DSP
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jorijn van der Graaf <[email protected]>
[ Upstream commit daa7ffd765ae67a83e77dae32c66ce2d6d995d19 ]
q6apm_graph_start() increments start_count even when APM_CMD_GRAPH_START fails, leaving the graph counted as running while the DSP never started it. A later start - a retried prepare, or a resume after a failed start - then finds a non-zero count, skips the command and returns success with no data flowing.
Count the graph only once the DSP has accepted the start. The count then stays at zero for a graph that never started, so also stop decrementing below zero in q6apm_graph_stop(): the compressed free path stops unconditionally, and a negative count would make the next start skip the command in the same way.
--- sound/soc/qcom/qdsp6/q6apm.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
sound/soc/qcom/qdsp6/q6apm.c +9 -3
@@ -700,14 +700,17 @@ EXPORT_SYMBOL_GPL(q6apm_graph_prepare);int q6apm_graph_start (struct q6apm_graph *graph) {struct audioreach_graph *ar_graph = graph->ar_graph; -int ret =0 ; +int ret; -if (ar_graph->start_count ==0 ) +if (ar_graph->start_count ==0 ) { ret =audioreach_graph_mgmt_cmd (ar_graph,APM_CMD_GRAPH_START ); +if (ret) +return ret; + } ar_graph->start_count++; -return ret; +return 0 ; }EXPORT_SYMBOL_GPL (q6apm_graph_start);
@@ -715,6 +718,9 @@ int q6apm_graph_stop(struct q6apm_graph *graph) {struct audioreach_graph *ar_graph = graph->ar_graph; +if (ar_graph->start_count ==0 ) +return 0 ; +if (--ar_graph->start_count >0 )return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1107/1518 arm64: bti: Disable in-kernel BTI with recent versions of Clang
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
[ Upstream commit d3359af21fc9e7a47577ff90e821b6510ec34dee ]
The following BTI exception was seen when loading a livepatch module:
Internal error: Oops - BTI: 0000000036000001 [#1] SMP pstate: 634004c9 (nZCv daIF +PAN -UAO +TCO +DIT -SSBS BTYPE=jc) pc : kill_orphaned_pgrp+0x0/0x150 lr : do_exit+0x498/0xaf0 [livepatch_combined]
The problem is that the patch module's do_exit() is branching to a static function in vmlinux using a module PLT veneer (indirect branch), but the target function doesn't have a BTI landing pad.
Clang 21+ omits the landing pad for static functions which can only be reached by a direct branch. That's normally fine for ordinary modules which only branch to global exported functions, but Mark Brown points out [1] that this isn't guaranteed if the module branches between sections. Futhermore, livepatch modules use klp relocations to reference arbitrary kernel symbols, so with CONFIG_RANDOMIZE_MODULE_REGION_FULL the module is far enough from the kernel that every R_AARCH64_CALL26 needs a PLT.
Put Clang 21+ in the naughty corner alongside GCC, which suffers from the same issue, by disabling CONFIG_ARM64_BTI_KERNEL until we have a version of the toolchain with the problem resolved.
--- arch/arm64/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/Kconfig +2 -0
@@ -2112,6 +2112,8 @@ config ARM64_BTI_KERNEL depends on !CC_IS_GCC || GCC_VERSION >= 100100 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106671 depends on !CC_IS_GCC + # https://github.com/llvm/llvm-project/issues/215547 + depends on !CC_IS_CLANG || CLANG_VERSION < 210000 depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_ARGS) help Build the kernel with Branch Target Identification annotations
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1108/1518 integrity: Make arch_ima_get_secureboot integrity-wide
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Coiby Xu <[email protected]>
[ Upstream commit 31a6a07eefeb4c84bd6730fbe9e95fd9221712cf ]
EVM and other LSMs need the ability to query the secure boot status of the system, without directly calling the IMA arch_ima_get_secureboot function. Refactor the secure boot status check into a general function named arch_get_secureboot.
Stable-dep-of: 3f7c9f9c36b4 ("s390/irqflags: Add out-of-line definitions of arch_local_irq_*() for KMSAN")
--- MAINTAINERS | 1 + arch/powerpc/kernel/ima_arch.c | 5 -- arch/powerpc/kernel/secure_boot.c | 6 ++ arch/s390/kernel/ima_arch.c | 6 -- arch/s390/kernel/ipl.c | 5 ++ arch/x86/include/asm/efi.h | 4 +- arch/x86/platform/efi/efi.c | 2 +- include/linux/ima.h | 7 +-- include/linux/secure_boot.h | 19 +++++++ security/integrity/Makefile | 3 +- security/integrity/efi_secureboot.c | 56 +++++++++++++++++++ security/integrity/ima/ima_appraise.c | 2 +- security/integrity/ima/ima_efi.c | 47 +--------------- security/integrity/ima/ima_main.c | 3 +- security/integrity/integrity.h | 1 + security/integrity/platform_certs/load_uefi.c | 2 +- security/integrity/secure_boot.c | 16 ++++++ 17 files changed, 115 insertions(+), 70 deletions(-) create mode 100644 include/linux/secure_boot.h create mode 100644 security/integrity/efi_secureboot.c create mode 100644 security/integrity/secure_boot.c
MAINTAINERS +1 -0
@@ -12389,6 +12389,7 @@ R: Eric Snowberg <[email protected]> L: [email protected] S: Supported T: git git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git +F: include/linux/secure_boot.h F: security/integrity/ F: security/integrity/ima/
arch/powerpc/kernel/ima_arch.c +0 -5
@@ -7,11 +7,6 @@#include <linux/ima.h> #include <asm/secure_boot.h> -bool arch_ima_get_secureboot (void ) -{ -return is_ppc_secureboot_enabled (); -} -/* * The "secure_rules" are enabled only on "secureboot" enabled systems. * These rules verify the file signatures against known good values.
arch/powerpc/kernel/secure_boot.c +6 -0
@@ -5,6 +5,7 @@*/ #include <linux/types.h> #include <linux/of.h> +#include <linux/secure_boot.h> #include <linux/string_choices.h> #include <asm/secure_boot.h>
@@ -44,6 +45,11 @@ bool is_ppc_secureboot_enabled(void)return enabled; } +bool arch_get_secureboot (void ) +{ +return is_ppc_secureboot_enabled (); +} +bool is_ppc_trustedboot_enabled (void ) {struct device_node *node;
arch/s390/kernel/ima_arch.c +0 -6
@@ -1,12 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/ima.h> -#include <asm/boot_data.h> - -bool arch_ima_get_secureboot (void ) -{ -return ipl_secure_flag; -}const char *const *arch_get_ima_policy (void ) {
arch/s390/kernel/ipl.c +5 -0
@@ -2504,6 +2504,11 @@ void *ipl_report_finish(struct ipl_report *report)return buf; } +bool arch_get_secureboot (void ) +{ +return ipl_secure_flag; +} +int ipl_report_free (struct ipl_report *report) {struct ipl_report_component *comp, *ncomp;
arch/x86/include/asm/efi.h +2 -2
@@ -402,9 +402,9 @@ extern int __init efi_memmap_split_count(efi_memory_desc_t *md,extern void __init efi_memmap_insert (struct efi_memory_map *old_memmap,void *buf,struct efi_mem_range *mem); -extern enum efi_secureboot_mode __x86_ima_efi_boot_mode (void ); +enum efi_secureboot_mode __x86_efi_boot_mode (void ); -#define arch_ima_efi_boot_mode __x86_ima_efi_boot_mode() +#define arch_efi_boot_mode __x86_efi_boot_mode()#ifdef CONFIG_EFI_RUNTIME_MAP int efi_get_runtime_map_size (void );
arch/x86/platform/efi/efi.c +1 -1
@@ -921,7 +921,7 @@ umode_t efi_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n)return attr->mode; } -enum efi_secureboot_mode __x86_ima_efi_boot_mode (void ) +enum efi_secureboot_mode __x86_efi_boot_mode (void ) {return boot_params.secure_boot; }
include/linux/ima.h +1 -6
@@ -11,6 +11,7 @@#include <linux/fs.h> #include <linux/security.h> #include <linux/kexec.h> +#include <linux/secure_boot.h> #include <crypto/hash_info.h> struct linux_binprm ;
@@ -73,14 +74,8 @@ int ima_validate_range(phys_addr_t phys, size_t size);#endif #ifdef CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT -extern bool arch_ima_get_secureboot (void );extern const char *const *arch_get_ima_policy (void );#else -static inline bool arch_ima_get_secureboot (void ) -{ -return false; -} -static inline const char *const *arch_get_ima_policy (void ) {return NULL ;
include/linux/secure_boot.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2026 Red Hat, Inc. All Rights Reserved. +* +* Author: Coiby Xu <[email protected]> +*/ + +#ifndef _LINUX_SECURE_BOOT_H +#define _LINUX_SECURE_BOOT_H + +#include <linux/types.h> + +/* +* Returns true if the platform secure boot is enabled. +* Returns false if disabled or not supported. +*/ +bool arch_get_secureboot (void ); + +#endif /* _LINUX_SECURE_BOOT_H */
security/integrity/Makefile +2 -1
@@ -5,7 +5,7 @@ obj-$(CONFIG_INTEGRITY) += integrity.o -integrity-y := iint.o +integrity-y := iint.o secure_boot.o integrity-$(CONFIG_INTEGRITY_AUDIT) += integrity_audit.o integrity-$(CONFIG_INTEGRITY_SIGNATURE) += digsig.o integrity-$(CONFIG_INTEGRITY_ASYMMETRIC_KEYS) += digsig_asymmetric.o
@@ -18,6 +18,7 @@ integrity-$(CONFIG_LOAD_IPL_KEYS) += platform_certs/load_ipl_s390.o integrity-$(CONFIG_LOAD_PPC_KEYS) += platform_certs/efi_parser.o \ platform_certs/load_powerpc.o \ platform_certs/keyring_handler.o +integrity-$(CONFIG_EFI) += efi_secureboot.o # The relative order of the 'ima' and 'evm' LSMs depends on the order below. obj-$(CONFIG_IMA) += ima/ obj-$(CONFIG_EVM) += evm/
security/integrity/efi_secureboot.c new file +56 -0
56 lines not on this page · raw message
security/integrity/ima/ima_appraise.c +1 -1
@@ -27,7 +27,7 @@ core_param(ima_appraise, ima_appraise_cmdline_default, charp, 0);void __init ima_appraise_parse_cmdline (void ) {const char *str = ima_appraise_cmdline_default; -bool sb_state =arch_ima_get_secureboot (); +bool sb_state =arch_get_secureboot ();int appraisal_state = ima_appraise;if (!str)
security/integrity/ima/ima_efi.c +2 -45
61 lines not on this page · raw message
security/integrity/ima/ima_main.c +1 -2
@@ -978,8 +978,7 @@ static int ima_load_data(enum kernel_load_data_id id, bool contents)switch (id) {case LOADING_KEXEC_IMAGE : -if (IS_ENABLED (CONFIG_KEXEC_SIG ) - &&arch_ima_get_secureboot ()) { +if (IS_ENABLED (CONFIG_KEXEC_SIG ) &&arch_get_secureboot ()) {pr_err ("impossible to appraise a kernel image without a file descriptor; try using kexec_file_load syscall.\n" );return -EACCES ; }
security/integrity/integrity.h +1 -0
@@ -14,6 +14,7 @@#include <linux/types.h> #include <linux/integrity.h> +#include <linux/secure_boot.h> #include <crypto/sha1.h> #include <crypto/hash.h> #include <linux/key.h>
security/integrity/platform_certs/load_uefi.c +1 -1
@@ -212,7 +212,7 @@ static int __init load_uefi_certs(void) }/* the MOK/MOKx can not be trusted when secure boot is disabled */ -if (!arch_ima_get_secureboot ()) +if (!arch_get_secureboot ())return 0 ; mokx =get_cert_list (L"MokListXRT" , &mok_var, &mokxsize, &status);
security/integrity/secure_boot.c new file +16 -0
@@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2026 Red Hat, Inc. All Rights Reserved. +* +* Author: Coiby Xu <[email protected]> +*/ +#include <linux/secure_boot.h> + +/* +* Default weak implementation. +* Architectures that support secure boot must override this. +*/ +__weak bool arch_get_secureboot (void ) +{ +return false; +}
Signature · 1 line
2.53.0