5.15.33-rc1 review
Subsystems (13)
Greg Kroah-Hartman
maintainerPATCH 712/913 ext4: fix ext4_mb_mark_bb() with flex_bg with fast_commit
In reply to Greg Kroah-HartmanFrom: Ritesh Harjani <[email protected]>
[ Upstream commit bfdc502a4a4c058bf4cbb1df0c297761d528f54d ]
In case of flex_bg feature (which is by default enabled), extents for any given inode might span across blocks from two different block group. ext4_mb_mark_bb() only reads the buffer_head of block bitmap once for the starting block group, but it fails to read it again when the extent length boundary overflows to another block group. Then in this below loop it accesses memory beyond the block group bitmap buffer_head and results into a data abort.
for (i = 0; i < clen; i++) if (!mb_test_bit(blkoff + i, bitmap_bh->b_data) == !state) already++;
This patch adds this functionality for checking block group boundary in ext4_mb_mark_bb() and update the buffer_head(bitmap_bh) for every different block group.
w/o this patch, I was easily able to hit a data access abort using Power platform.
<...>
[ 74.327662] EXT4-fs error (device loop3): ext4_mb_generate_buddy:1141: group 11, block bitmap and bg descriptor inconsistent: 21248 vs 23294 free clusters
[ 74.533214] EXT4-fs (loop3): shut down requested (2)
[ 74.536705] Aborting journal on device loop3-8.
[ 74.702705] BUG: Unable to handle kernel data access on read at 0xc00000005e980000
[ 74.703727] Faulting instruction address: 0xc0000000007bffb8
cpu 0xd: Vector: 300 (Data Access) at [c000000015db7060]
pc: c0000000007bffb8: ext4_mb_mark_bb+0x198/0x5a0
lr: c0000000007bfeec: ext4_mb_mark_bb+0xcc/0x5a0
sp: c000000015db7300
msr: 800000000280b033
dar: c00000005e980000
dsisr: 40000000
current = 0xc000000027af6880
paca = 0xc00000003ffd5200 irqmask: 0x03 irq_happened: 0x01
pid = 5167, comm = mount<...>
enter ? for help
[c000000015db7380] c000000000782708 ext4_ext_clear_bb+0x378/0x410 [c000000015db7400] c000000000813f14 ext4_fc_replay+0x1794/0x2000 [c000000015db7580] c000000000833f7c do_one_pass+0xe9c/0x12a0 [c000000015db7710] c000000000834504 jbd2_journal_recover+0x184/0x2d0 [c000000015db77c0] c000000000841398 jbd2_journal_load+0x188/0x4a0 [c000000015db7880] c000000000804de8 ext4_fill_super+0x2638/0x3e10 [c000000015db7a40] c0000000005f8404 get_tree_bdev+0x2b4/0x350 [c000000015db7ae0] c0000000007ef058 ext4_get_tree+0x28/0x40 [c000000015db7b00] c0000000005f6344 vfs_get_tree+0x44/0x100 [c000000015db7b70] c00000000063c408 path_mount+0xdd8/0xe70 [c000000015db7c40] c00000000063c8f0 sys_mount+0x450/0x550 [c000000015db7d50] c000000000035770 system_call_exception+0x4a0/0x4e0 [c000000015db7e10] c00000000000c74c system_call_common+0xec/0x250
--- fs/ext4/mballoc.c | 131 +++++++++++++++++++++++++++------------------- 1 file changed, 76 insertions(+), 55 deletions(-)
fs/ext4/mballoc.c +76 -55
@@ -3901,72 +3901,93 @@ void ext4_mb_mark_bb(struct super_block *sb, ext4_fsblk_t block,ext4_grpblk_t blkoff;int i, err;int already; -unsigned int clen, clen_changed; +unsigned int clen, clen_changed, thisgrp_len; - clen =EXT4_NUM_B2C (sbi, len); - -ext4_get_group_no_and_offset (sb, block, &group, &blkoff); - bitmap_bh =ext4_read_block_bitmap (sb, group); -if (IS_ERR (bitmap_bh)) { - err =PTR_ERR (bitmap_bh); - bitmap_bh =NULL ; - goto out_err; - } - - err = -EIO ; - gdp =ext4_get_group_desc (sb, group, &gdp_bh); -if (!gdp) - goto out_err; +while (len >0 ) { +ext4_get_group_no_and_offset (sb, block, &group, &blkoff); -ext4_lock_group (sb, group); - already =0 ; -for (i =0 ; i < clen; i++) -if (!mb_test_bit (blkoff + i, bitmap_bh->b_data) == !state) - already++; - - clen_changed = clen - already; -if (state) -ext4_set_bits (bitmap_bh->b_data, blkoff, clen); -else -mb_test_and_clear_bits (bitmap_bh->b_data, blkoff, clen); -if (ext4_has_group_desc_csum (sb) && - (gdp->bg_flags &cpu_to_le16 (EXT4_BG_BLOCK_UNINIT ))) { - gdp->bg_flags &=cpu_to_le16 (~EXT4_BG_BLOCK_UNINIT ); -ext4_free_group_clusters_set (sb, gdp, -ext4_free_clusters_after_init (sb, - group, gdp)); - } -if (state) - clen =ext4_free_group_clusters (sb, gdp) - clen_changed; -else - clen =ext4_free_group_clusters (sb, gdp) + clen_changed; +/* +* Check to see if we are freeing blocks across a group +* boundary. +* In case of flex_bg, this can happen that (block, len) may +* span across more than one group. In that case we need to +* get the corresponding group metadata to work with. +* For this we have goto again loop. +*/ + thisgrp_len = min_t(unsigned int, (unsigned int)len, +EXT4_BLOCKS_PER_GROUP (sb) -EXT4_C2B (sbi, blkoff)); + clen =EXT4_NUM_B2C (sbi, thisgrp_len); -ext4_free_group_clusters_set (sb, gdp, clen); -ext4_block_bitmap_csum_set (sb, group, gdp, bitmap_bh); -ext4_group_desc_csum_set (sb, group, gdp); + bitmap_bh =ext4_read_block_bitmap (sb, group); +if (IS_ERR (bitmap_bh)) { + err =PTR_ERR (bitmap_bh); + bitmap_bh =NULL ; +break ; + } -ext4_unlock_group (sb, group); + err = -EIO ; + gdp =ext4_get_group_desc (sb, group, &gdp_bh); +if (!gdp) +break ; -if (sbi->s_log_groups_per_flex) { -ext4_group_t flex_group =ext4_flex_group (sbi, group); -struct flex_groups *fg =sbi_array_rcu_deref (sbi, - s_flex_groups, flex_group); +ext4_lock_group (sb, group); + already =0 ; +for (i =0 ; i < clen; i++) +if (!mb_test_bit (blkoff + i, bitmap_bh->b_data) == + !state) + already++; + clen_changed = clen - already;if (state) -atomic64_sub (clen_changed, &fg->free_clusters); +ext4_set_bits (bitmap_bh->b_data, blkoff, clen);else -atomic64_add (clen_changed, &fg->free_clusters); +mb_test_and_clear_bits (bitmap_bh->b_data, blkoff, clen); +if (ext4_has_group_desc_csum (sb) && + (gdp->bg_flags &cpu_to_le16 (EXT4_BG_BLOCK_UNINIT ))) { + gdp->bg_flags &=cpu_to_le16 (~EXT4_BG_BLOCK_UNINIT ); +ext4_free_group_clusters_set (sb, gdp, +ext4_free_clusters_after_init (sb, group, gdp)); + } +if (state) + clen =ext4_free_group_clusters (sb, gdp) - clen_changed; +else + clen =ext4_free_group_clusters (sb, gdp) + clen_changed; + +ext4_free_group_clusters_set (sb, gdp, clen); +ext4_block_bitmap_csum_set (sb, group, gdp, bitmap_bh); +ext4_group_desc_csum_set (sb, group, gdp); + +ext4_unlock_group (sb, group); + +if (sbi->s_log_groups_per_flex) { +ext4_group_t flex_group =ext4_flex_group (sbi, group); +struct flex_groups *fg =sbi_array_rcu_deref (sbi, + s_flex_groups, flex_group); + +if (state) +atomic64_sub (clen_changed, &fg->free_clusters); +else +atomic64_add (clen_changed, &fg->free_clusters); + + } + + err =ext4_handle_dirty_metadata (NULL ,NULL , bitmap_bh); +if (err) +break ; +sync_dirty_buffer (bitmap_bh); + err =ext4_handle_dirty_metadata (NULL ,NULL , gdp_bh); +sync_dirty_buffer (gdp_bh); +if (err) +break ; + + block += thisgrp_len; + len -= thisgrp_len; +brelse (bitmap_bh); +BUG_ON (len <0 ); } - err =ext4_handle_dirty_metadata (NULL ,NULL , bitmap_bh);if (err) - goto out_err; -sync_dirty_buffer (bitmap_bh); - err =ext4_handle_dirty_metadata (NULL ,NULL , gdp_bh); -sync_dirty_buffer (gdp_bh); - -out_err: -brelse (bitmap_bh); +brelse (bitmap_bh); }/*
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 713/913 sched/tracing: Dont re-read p->state when emitting sched_switch event
In reply to Greg Kroah-HartmanFrom: Valentin Schneider <[email protected]>
[ Upstream commit fa2c3254d7cfff5f7a916ab928a562d1165f17bb ]
As of commit
c6e7bd7afaeb ("sched/core: Optimize ttwu() spinning on p->on_cpu")
the following sequence becomes possible:
p->__state = TASK_INTERRUPTIBLE;
__schedule()
deactivate_task(p);
ttwu()
READ !p->on_rq
p->__state=TASK_WAKING
trace_sched_switch()
__trace_sched_switch_state()
task_state_index()
return 0;TASK_WAKING isn't in TASK_REPORT, so the task appears as TASK_RUNNING in the trace event.
Prevent this by pushing the value read from __schedule() down the trace event.
--- include/linux/sched.h | 11 ++++++++--- include/trace/events/sched.h | 11 +++++++---- kernel/sched/core.c | 4 ++-- kernel/trace/fgraph.c | 4 +++- kernel/trace/ftrace.c | 4 +++- kernel/trace/trace_events.c | 8 ++++++-- kernel/trace/trace_osnoise.c | 4 +++- kernel/trace/trace_sched_switch.c | 1 + kernel/trace/trace_sched_wakeup.c | 1 + 9 files changed, 34 insertions(+), 14 deletions(-)
include/linux/sched.h +8 -3
@@ -1616,10 +1616,10 @@ static inline pid_t task_pgrp_nr(struct task_struct *tsk)#define TASK_REPORT_IDLE (TASK_REPORT + 1)#define TASK_REPORT_MAX (TASK_REPORT_IDLE << 1) -static inline unsigned int task_state_index (struct task_struct *tsk) +static inline unsigned int __task_state_index (unsigned int tsk_state, +unsigned int tsk_exit_state) { -unsigned int tsk_state =READ_ONCE (tsk->__state); -unsigned int state = (tsk_state | tsk->exit_state) &TASK_REPORT ; +unsigned int state = (tsk_state | tsk_exit_state) &TASK_REPORT ;BUILD_BUG_ON_NOT_POWER_OF_2 (TASK_REPORT_MAX );
@@ -1629,6 +1629,11 @@ static inline unsigned int task_state_index(struct task_struct *tsk)return fls (state); } +static inline unsigned int task_state_index (struct task_struct *tsk) +{ +return __task_state_index (READ_ONCE (tsk->__state), tsk->exit_state); +} +static inline char task_index_to_char (unsigned int state) {static const char state_char[] ="RSDTtXZPI" ;
include/trace/events/sched.h +7 -4
@@ -187,7 +187,9 @@ DEFINE_EVENT(sched_wakeup_template, sched_wakeup_new, TP_ARGS(p));#ifdef CREATE_TRACE_POINTS -static inline long __trace_sched_switch_state (bool preempt,struct task_struct *p) +static inline long __trace_sched_switch_state (bool preempt, +unsigned int prev_state, +struct task_struct *p) {unsigned int state;
@@ -208,7 +210,7 @@ static inline long __trace_sched_switch_state(bool preempt, struct task_struct ** it for left shift operation to get the correct task->state * mapping. */ - state =task_state_index (p); + state =__task_state_index (prev_state, p->exit_state);return state ? (1 << (state -1 )) : state; }
@@ -220,10 +222,11 @@ static inline long __trace_sched_switch_state(bool preempt, struct task_struct * TRACE_EVENT(sched_switch, TP_PROTO(bool preempt, + unsigned int prev_state, struct task_struct *prev, struct task_struct *next), - TP_ARGS(preempt, prev, next), + TP_ARGS(preempt, prev_state, prev, next), TP_STRUCT__entry( __array( char, prev_comm, TASK_COMM_LEN )
@@ -239,7 +242,7 @@ TRACE_EVENT(sched_switch,memcpy (__entry->next_comm, next->comm,TASK_COMM_LEN ); __entry->prev_pid = prev->pid; __entry->prev_prio = prev->prio; - __entry->prev_state =__trace_sched_switch_state (preempt, prev); + __entry->prev_state =__trace_sched_switch_state (preempt, prev_state, prev);memcpy (__entry->prev_comm, prev->comm,TASK_COMM_LEN ); __entry->next_pid = next->pid; __entry->next_prio = next->prio;
kernel/sched/core.c +2 -2
@@ -4787,7 +4787,7 @@ static struct rq *finish_task_switch(struct task_struct *prev) {struct rq *rq =this_rq ();struct mm_struct *mm = rq->prev_mm; -long prev_state; +unsigned int prev_state;/* * The previous task will have left us with a preempt_count of 2
@@ -6295,7 +6295,7 @@ static void __sched notrace __schedule(unsigned int sched_mode)migrate_disable_switch (rq, prev);psi_sched_switch (prev, next, !task_on_rq_queued (prev)); -trace_sched_switch (sched_mode &SM_MASK_PREEMPT , prev, next); +trace_sched_switch (sched_mode &SM_MASK_PREEMPT , prev_state, prev, next);/* Also unlocks the rq: */ rq =context_switch (rq, prev, next, &rf);
kernel/trace/fgraph.c +3 -1
@@ -413,7 +413,9 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list)static void ftrace_graph_probe_sched_switch (void *ignore,bool preempt, -struct task_struct *prev,struct task_struct *next) +unsigned int prev_state, +struct task_struct *prev, +struct task_struct *next) {unsigned long long timestamp;int index;
kernel/trace/ftrace.c +3 -1
@@ -7093,7 +7093,9 @@ ftrace_func_t ftrace_ops_get_func(struct ftrace_ops *ops)static void ftrace_filter_pid_sched_switch_probe (void *data,bool preempt, -struct task_struct *prev,struct task_struct *next) +unsigned int prev_state, +struct task_struct *prev, +struct task_struct *next) {struct trace_array *tr = data;struct trace_pid_list *pid_list;
kernel/trace/trace_events.c +6 -2
@@ -759,7 +759,9 @@ void trace_event_follow_fork(struct trace_array *tr, bool enable)static void event_filter_pid_sched_switch_probe_pre (void *data,bool preempt, -struct task_struct *prev,struct task_struct *next) +unsigned int prev_state, +struct task_struct *prev, +struct task_struct *next) {struct trace_array *tr = data;struct trace_pid_list *no_pid_list;
@@ -783,7 +785,9 @@ event_filter_pid_sched_switch_probe_pre(void *data, bool preempt,static void event_filter_pid_sched_switch_probe_post (void *data,bool preempt, -struct task_struct *prev,struct task_struct *next) +unsigned int prev_state, +struct task_struct *prev, +struct task_struct *next) {struct trace_array *tr = data;struct trace_pid_list *no_pid_list;
kernel/trace/trace_osnoise.c +3 -1
@@ -1000,7 +1000,9 @@ thread_exit(struct osnoise_variables *osn_var, struct task_struct *t)* used to record the beginning and to report the end of a thread noise window. */ static void -trace_sched_switch_callback (void *data,bool preempt,struct task_struct *p, +trace_sched_switch_callback (void *data,bool preempt, +unsigned int prev_state, +struct task_struct *p,struct task_struct *n) {struct osnoise_variables *osn_var =this_cpu_osn_var ();
kernel/trace/trace_sched_switch.c +1 -0
@@ -22,6 +22,7 @@ static DEFINE_MUTEX(sched_register_mutex);static void probe_sched_switch (void *ignore,bool preempt, +unsigned int prev_state,struct task_struct *prev,struct task_struct *next) {int flags;
kernel/trace/trace_sched_wakeup.c +1 -0
@@ -426,6 +426,7 @@ tracing_sched_wakeup_trace(struct trace_array *tr, static void notraceprobe_wakeup_sched_switch (void *ignore,bool preempt, +unsigned int prev_state,struct task_struct *prev,struct task_struct *next) {struct trace_array_cpu *data;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 714/913 sched/tracing: Report TASK_RTLOCK_WAIT tasks as TASK_UNINTERRUPTIBLE
In reply to Greg Kroah-HartmanFrom: Valentin Schneider <[email protected]>
[ Upstream commit 25795ef6299f07ce3838f3253a9cb34f64efcfae ]
TASK_RTLOCK_WAIT currently isn't part of TASK_REPORT, thus a task blocking on an rtlock will appear as having a task state == 0, IOW TASK_RUNNING.
The actual state is saved in p->saved_state, but reading it after reading p->__state has a few issues:
o that could still be TASK_RUNNING in the case of e.g. rt_spin_lock
o ttwu_state_match() might have changed that to TASK_RUNNING
As pointed out by Eric, adding TASK_RTLOCK_WAIT to TASK_REPORT implies exposing a new state to userspace tools which way not know what to do with them. The only information that needs to be conveyed here is that a task is waiting on an rt_mutex, which matches TASK_UNINTERRUPTIBLE - there's no need for a new state.
--- include/linux/sched.h | 8 ++++++++ 1 file changed, 8 insertions(+)
include/linux/sched.h +8 -0
@@ -1626,6 +1626,14 @@ static inline unsigned int __task_state_index(unsigned int tsk_state,if (tsk_state ==TASK_IDLE ) state =TASK_REPORT_IDLE ; +/* +* We're lying here, but rather than expose a completely new task state +* to userspace, we can make this appear as if the task has gone through +* a regular rt_mutex_lock() call. +*/ +if (tsk_state ==TASK_RTLOCK_WAIT ) + state =TASK_UNINTERRUPTIBLE ; +return fls (state); }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 715/913 ext4: dont BUG if someone dirty pages without asking ext4 first
In reply to Greg Kroah-HartmanFrom: Theodore Ts'o <[email protected]>
[ Upstream commit cc5095747edfb054ca2068d01af20be3fcc3634f ]
[un]pin_user_pages_remote is dirtying pages without properly warning the file system in advance. A related race was noted by Jan Kara in 2018[1]; however, more recently instead of it being a very hard-to-hit race, it could be reliably triggered by process_vm_writev(2) which was discovered by Syzbot[2].
This is technically a bug in mm/gup.c, but arguably ext4 is fragile in that if some other kernel subsystem dirty pages without properly notifying the file system using page_mkwrite(), ext4 will BUG, while other file systems will not BUG (although data will still be lost).
So instead of crashing with a BUG, issue a warning (since there may be potential data loss) and just mark the page as clean to avoid unprivileged denial of service attacks until the problem can be properly fixed. More discussion and background can be found in the thread starting at [2].
[1] https://lore.kernel.org/linux-mm/[email protected]
[2] https://lore.kernel.org/r/[email protected]
--- fs/ext4/inode.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
fs/ext4/inode.c +25 -0
@@ -1992,6 +1992,15 @@ static int ext4_writepage(struct page *page,else len =PAGE_SIZE ; +/* Should never happen but for bugs in other kernel subsystems */ +if (!page_has_buffers (page)) { +ext4_warning_inode (inode, +"page %lu does not have buffers attached" , page->index); +ClearPageDirty (page); +unlock_page (page); +return 0 ; + } + page_bufs =page_buffers (page);/* * We cannot do block allocation or other extent handling in this
@@ -2595,6 +2604,22 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)wait_on_page_writeback (page);BUG_ON (PageWriteback (page)); +/* +* Should never happen but for buggy code in +* other subsystems that call +* set_page_dirty() without properly warning +* the file system first. See [1] for more +* information. +* +* [1] https://lore.kernel.org/linux-mm/[email protected] +*/ +if (!page_has_buffers (page)) { +ext4_warning_inode (mpd->inode,"page %lu does not have buffers attached" , page->index); +ClearPageDirty (page); +unlock_page (page); +continue ; + } +if (mpd->map.m_len ==0 ) mpd->first_page = page->index; mpd->next_page = page->index +1 ;
Signature · 1 line
2.34.1
syzbot
syzbotRe: [PATCH 5.15 715/913] ext4: dont BUG if someone dirty pages without asking ext4 first
I see the command but can't find the corresponding bug. The email is sent to [email protected] address but the HASH does not correspond to any known bug. Please double check the…
Quoted 81 lines
From: Theodore Ts'o <[email protected]>
[ Upstream commit
cc5095747edfb054ca2068d01af20be3fcc3634f][un]pin_user_pages_remote is dirtying pages without properly warning the file system in advance. A related race was noted by Jan Kara in 2018[1]; however, more recently instead of it being a very hard-to-hit race, it could be reliably triggered by
process_vm_writev(2)which was discovered by Syzbot[2].This is technically a bug in
mm/gup.c, but arguably ext4 is fragile in that if some other kernel subsystem dirty pages without properly notifying the file system usingpage_mkwrite(), ext4 will BUG, while other file systems will not BUG (although data will still be lost).So instead of crashing with a BUG, issue a warning (since there may be potential data loss) and just mark the page as clean to avoid unprivileged denial of service attacks until the problem can be properly fixed. More discussion and background can be found in the thread starting at [2].
[1] https://lore.kernel.org/linux-mm/[email protected]
[2] https://lore.kernel.org/r/[email protected]Reported-by Lee Jones <[email protected]>Signed-off-by Theodore Ts'o <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- fs/ext4/inode.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)fs/ext4/inode.c +25
-0@@ -1992,6 +1992,15 @@ static int ext4_writepage(struct page *page,else len =PAGE_SIZE ; +/* Should never happen but for bugs in other kernel subsystems */ +if (!page_has_buffers (page)) { +ext4_warning_inode (inode, +"page %lu does not have buffers attached" , page->index); +ClearPageDirty (page); +unlock_page (page); +return 0 ; + } + page_bufs =page_buffers (page);/* * We cannot do block allocation or other extent handling in this @@ -2595,6 +2604,22 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)wait_on_page_writeback (page);BUG_ON (PageWriteback (page)); +/* +* Should never happen but for buggy code in +* other subsystems that call +* set_page_dirty() without properly warning +* the file system first. See [1] for more +* information. +* +* [1] https://lore.kernel.org/linux-mm/[email protected] +*/ +if (!page_has_buffers (page)) { +ext4_warning_inode (mpd->inode,"page %lu does not have buffers attached" , page->index); +ClearPageDirty (page); +unlock_page (page); +continue ; + } +if (mpd->map.m_len ==0 ) mpd->first_page = page->index; mpd->next_page = page->index +1 ;Signature · 1 line
2.34.1
I see the command but can't find the corresponding bug. The email is sent to [email protected] address but the HASH does not correspond to any known bug. Please double check the address.
Greg Kroah-Hartman
maintainerPATCH 716/913 f2fs: fix to do sanity check on curseg->alloc_type
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit f41ee8b91c00770d718be2ff4852a80017ae9ab3 ]
As Wenqing Liu reported in bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=215657
- Overview
UBSAN: array-index-out-of-bounds in fs/f2fs/segment.c:3460:2 when mount and operate a corrupted image
- Reproduce
tested on kernel 5.17-rc4, 5.17-rc6
1. mkdir test_crash
2. cd test_crash
3. unzip tmp2.zip
4. mkdir mnt
5. ./single_test.sh f2fs 2
- Kernel dump
[ 46.434454] loop0: detected capacity change from 0 to 131072 [ 46.529839] F2FS-fs (loop0): Mounted with checkpoint version = 7548c2d9 [ 46.738319] ================================================================================ [ 46.738412] UBSAN: array-index-out-of-bounds in fs/f2fs/segment.c:3460:2 [ 46.738475] index 231 is out of range for type 'unsigned int [2]' [ 46.738539] CPU: 2 PID: 939 Comm: umount Not tainted 5.17.0-rc6 #1 [ 46.738547] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-1ubuntu1.1 04/01/2014 [ 46.738551] Call Trace: [ 46.738556] <TASK> [ 46.738563] dump_stack_lvl+0x47/0x5c [ 46.738581] ubsan_epilogue+0x5/0x50 [ 46.738592] __ubsan_handle_out_of_bounds+0x68/0x80 [ 46.738604] f2fs_allocate_data_block+0xdff/0xe60 [f2fs] [ 46.738819] do_write_page+0xef/0x210 [f2fs] [ 46.738934] f2fs_do_write_node_page+0x3f/0x80 [f2fs] [ 46.739038] __write_node_page+0x2b7/0x920 [f2fs] [ 46.739162] f2fs_sync_node_pages+0x943/0xb00 [f2fs] [ 46.739293] f2fs_write_checkpoint+0x7bb/0x1030 [f2fs] [ 46.739405] kill_f2fs_super+0x125/0x150 [f2fs] [ 46.739507] deactivate_locked_super+0x60/0xc0 [ 46.739517] deactivate_super+0x70/0xb0 [ 46.739524] cleanup_mnt+0x11a/0x200 [ 46.739532] __cleanup_mnt+0x16/0x20 [ 46.739538] task_work_run+0x67/0xa0 [ 46.739547] exit_to_user_mode_prepare+0x18c/0x1a0 [ 46.739559] syscall_exit_to_user_mode+0x26/0x40 [ 46.739568] do_syscall_64+0x46/0xb0 [ 46.739584] entry_SYSCALL_64_after_hwframe+0x44/0xae
The root cause is we missed to do sanity check on curseg->alloc_type, result in out-of-bound accessing on sbi->block_count[] array, fix it.
--- fs/f2fs/segment.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/f2fs/segment.c +7 -0
@@ -4747,6 +4747,13 @@ static int sanity_check_curseg(struct f2fs_sb_info *sbi)sanity_check_seg_type (sbi, curseg->seg_type); +if (curseg->alloc_type !=LFS && curseg->alloc_type !=SSR ) { +f2fs_err (sbi, +"Current segment has invalid alloc_type:%d" , + curseg->alloc_type); +return -EFSCORRUPTED ; + } +if (f2fs_test_bit (blkofs, se->cur_valid_map)) goto out;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 717/913 NFSD: Fix nfsd_breaker_owns_lease() return values
In reply to Greg Kroah-HartmanFrom: Chuck Lever <[email protected]>
[ Upstream commit 50719bf3442dd6cd05159e9c98d020b3919ce978 ]
These have been incorrect since the function was introduced.
A proper kerneldoc comment is added since this function, though static, is part of an external interface.
--- fs/nfsd/nfs4state.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
fs/nfsd/nfs4state.c +10 -2
@@ -4693,6 +4693,14 @@ nfsd_break_deleg_cb(struct file_lock *fl)return ret; } +/** +* nfsd_breaker_owns_lease - Check if lease conflict was resolved +* @fl: Lock state to check +* +* Return values: +* %true: Lease conflict was resolved +* %false: Lease conflict was not resolved. +*/ static bool nfsd_breaker_owns_lease (struct file_lock *fl) {struct nfs4_delegation *dl = fl->fl_owner;
@@ -4700,11 +4708,11 @@ static bool nfsd_breaker_owns_lease(struct file_lock *fl)struct nfs4_client *clp;if (!i_am_nfsd ()) -return NULL ; +return false; rqst =kthread_data (current);/* Note rq_prog == NFS_ACL_PROGRAM is also possible: */ if (rqst->rq_prog !=NFS_PROGRAM || rqst->rq_vers <4 ) -return NULL ; +return false; clp = *(rqst->rq_lease_breaker);return dl->dl_stid.sc_client == clp; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 718/913 f2fs: dont get FREEZE lock in f2fs_evict_inode in frozen fs
In reply to Greg Kroah-HartmanFrom: Jaegeuk Kim <[email protected]>
[ Upstream commit ba900534f807f0b327c92d5141c85d2313e2d55c ]
Let's purge inode cache in order to avoid the below deadlock.
[freeze test] shrinkderfreeze_super
- pwercpu_down_write(SB_FREEZE_FS)
- super_cache_scan
- down_read(&sb->s_umount)
- prune_icache_sb
- dispose_list
- evict
- f2fs_evict_inodethaw_super
- down_write(&sb->s_umount);
- __percpu_down_read(SB_FREEZE_FS)
--- Documentation/ABI/testing/sysfs-fs-f2fs | 1 + fs/f2fs/debug.c | 1 + fs/f2fs/f2fs.h | 1 + fs/f2fs/inode.c | 6 ++++-- fs/f2fs/super.c | 4 ++++ 5 files changed, 11 insertions(+), 2 deletions(-)
Documentation/ABI/testing/sysfs-fs-f2fs +1 -0
@@ -425,6 +425,7 @@ Description: Show status of f2fs superblock in real time. 0x800 SBI_QUOTA_SKIP_FLUSH skip flushing quota in current CP 0x1000 SBI_QUOTA_NEED_REPAIR quota file may be corrupted 0x2000 SBI_IS_RESIZEFS resizefs is in process + 0x4000 SBI_IS_FREEZING freefs is in process ====== ===================== ================================= What: /sys/fs/f2fs/<disk>/ckpt_thread_ioprio
fs/f2fs/debug.c +1 -0
@@ -338,6 +338,7 @@ static char *s_flag[] = { [SBI_QUOTA_SKIP_FLUSH] = " quota_skip_flush", [SBI_QUOTA_NEED_REPAIR] = " quota_need_repair", [SBI_IS_RESIZEFS] = " resizefs", + [SBI_IS_FREEZING] = " freezefs", };static int stat_show (struct seq_file *s,void *v)
fs/f2fs/f2fs.h +1 -0
@@ -1253,6 +1253,7 @@ enum {SBI_QUOTA_SKIP_FLUSH ,/* skip flushing quota in current CP */ SBI_QUOTA_NEED_REPAIR ,/* quota file may be corrupted */ SBI_IS_RESIZEFS ,/* resizefs is in process */ + SBI_IS_FREEZING, /* freezefs is in process */ }; enum {
fs/f2fs/inode.c +4 -2
@@ -769,7 +769,8 @@ void f2fs_evict_inode(struct inode *inode)f2fs_remove_ino_entry (sbi, inode->i_ino,UPDATE_INO );f2fs_remove_ino_entry (sbi, inode->i_ino,FLUSH_INO ); -sb_start_intwrite (inode->i_sb); +if (!is_sbi_flag_set (sbi,SBI_IS_FREEZING )) +sb_start_intwrite (inode->i_sb);set_inode_flag (inode,FI_NO_ALLOC );i_size_write (inode,0 ); retry:
@@ -800,7 +801,8 @@ void f2fs_evict_inode(struct inode *inode)if (dquot_initialize_needed (inode))set_sbi_flag (sbi,SBI_QUOTA_NEED_REPAIR ); } -sb_end_intwrite (inode->i_sb); +if (!is_sbi_flag_set (sbi,SBI_IS_FREEZING )) +sb_end_intwrite (inode->i_sb); no_delete:dquot_drop (inode);
fs/f2fs/super.c +4 -0
@@ -1663,11 +1663,15 @@ static int f2fs_freeze(struct super_block *sb)/* ensure no checkpoint required */ if (!llist_empty (&F2FS_SB (sb)->cprc_info.issue_list))return -EINVAL ; + +/* to avoid deadlock on f2fs_evict_inode->SB_FREEZE_FS */ +set_sbi_flag (F2FS_SB (sb),SBI_IS_FREEZING );return 0 ; }static int f2fs_unfreeze (struct super_block *sb) { +clear_sbi_flag (F2FS_SB (sb),SBI_IS_FREEZING );return 0 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 719/913 btrfs: harden identification of a stale device
In reply to Greg Kroah-HartmanFrom: Anand Jain <[email protected]>
[ Upstream commit 770c79fb65506fc7c16459855c3839429f46cb32 ]
Identifying and removing the stale device from the fs_uuids list is done by btrfs_free_stale_devices(). btrfs_free_stale_devices() in turn depends on device_path_matched() to check if the device appears in more than one btrfs_device structure.
The matching of the device happens by its path, the device path. However, when device mapper is in use, the dm device paths are nothing but a link to the actual block device, which leads to the device_path_matched() failing to match.
Fix this by matching the dev_t as provided by lookup_bdev() instead of plain string compare of the device paths.
--- fs/btrfs/volumes.c | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-)
fs/btrfs/volumes.c +38 -7
@@ -530,15 +530,48 @@ btrfs_get_bdev_and_sb(const char *device_path, fmode_t flags, void *holder,return ret; } -static bool device_path_matched (const char *path,struct btrfs_device *device) +/* +* Check if the device in the path matches the device in the given struct device. +* +* Returns: +* true If it is the same device. +* false If it is not the same device or on error. +*/ +static bool device_matched (const struct btrfs_device *device,const char *path) { -int found; +char *device_name; +dev_t dev_old; +dev_t dev_new; +int ret; + +/* +* If we are looking for a device with the matching dev_t, then skip +* device without a name (a missing device). +*/ +if (!device->name) +return false; + + device_name =kzalloc (BTRFS_PATH_NAME_MAX ,GFP_KERNEL ); +if (!device_name) +return false;rcu_read_lock (); - found =strcmp (rcu_str_deref (device->name), path); +scnprintf (device_name,BTRFS_PATH_NAME_MAX ,"%s" ,rcu_str_deref (device->name));rcu_read_unlock (); -return found ==0 ; + ret =lookup_bdev (device_name, &dev_old); +kfree (device_name); +if (ret) +return false; + + ret =lookup_bdev (path, &dev_new); +if (ret) +return false; + +if (dev_old == dev_new) +return true; + +return false; }/*
@@ -571,9 +604,7 @@ static int btrfs_free_stale_devices(const char *path, &fs_devices->devices, dev_list) {if (skip_device && skip_device == device)continue ; -if (path && !device->name) -continue ; -if (path && !device_path_matched (path, device)) +if (path && !device_matched (device, path))continue ;if (fs_devices->opened) {/* for an already deleted device return 0 */
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 720/913 btrfs: make search_csum_tree return 0 if we get -EFBIG
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
[ Upstream commit 03ddb19d2ea745228879b9334f3b550c88acb10a ]
We can either fail to find a csum entry at all and return -ENOENT, or we can find a range that is close, but return -EFBIG. In essence these both mean the same thing when we are doing a lookup for a csum in an existing range, we didn't find a csum. We want to treat both of these errors the same way, complain loudly that there wasn't a csum. This currently happens anyway because we do
count = search_csum_tree();
if (count <= 0) {
// reloc and error handling
}However it forces us to incorrectly treat EIO or ENOMEM errors as on disk corruption. Fix this by returning 0 if we get either -ENOENT or -EFBIG from btrfs_lookup_csum() so we can do proper error handling.
--- fs/btrfs/file-item.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/file-item.c +1 -1
@@ -303,7 +303,7 @@ static int search_csum_tree(struct btrfs_fs_info *fs_info,read_extent_buffer (path->nodes[0 ], dst, (unsigned long )item, ret * csum_size); out: -if (ret == -ENOENT ) +if (ret == -ENOENT || ret == -EFBIG ) ret =0 ;return ret; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 721/913 f2fs: use spin_lock to avoid hang
In reply to Greg Kroah-HartmanFrom: Jaegeuk Kim <[email protected]>
[ Upstream commit 98237fcda4a24e67b0a4498c17d5aa4ad4537bc7 ]
[14696.634553] task:cat state:D stack: 0 pid:1613738 ppid:1613735 flags:0x00000004 [14696.638285] Call Trace: [14696.639038] <TASK> [14696.640032] __schedule+0x302/0x930 [14696.640969] schedule+0x58/0xd0 [14696.641799] schedule_preempt_disabled+0x18/0x30 [14696.642890] __mutex_lock.constprop.0+0x2fb/0x4f0 [14696.644035] ? mod_objcg_state+0x10c/0x310 [14696.645040] ? obj_cgroup_charge+0xe1/0x170 [14696.646067] __mutex_lock_slowpath+0x13/0x20 [14696.647126] mutex_lock+0x34/0x40 [14696.648070] stat_show+0x25/0x17c0 [f2fs] [14696.649218] seq_read_iter+0x120/0x4b0 [14696.650289] ? aa_file_perm+0x12a/0x500 [14696.651357] ? lru_cache_add+0x1c/0x20 [14696.652470] seq_read+0xfd/0x140 [14696.653445] full_proxy_read+0x5c/0x80 [14696.654535] vfs_read+0xa0/0x1a0 [14696.655497] ksys_read+0x67/0xe0 [14696.656502] __x64_sys_read+0x1a/0x20 [14696.657580] do_syscall_64+0x3b/0xc0 [14696.658671] entry_SYSCALL_64_after_hwframe+0x44/0xae [14696.660068] RIP: 0033:0x7efe39df1cb2 [14696.661133] RSP: 002b:00007ffc8badd948 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 [14696.662958] RAX: ffffffffffffffda RBX: 0000000000020000 RCX: 00007efe39df1cb2 [14696.664757] RDX: 0000000000020000 RSI: 00007efe399df000 RDI: 0000000000000003 [14696.666542] RBP: 00007efe399df000 R08: 00007efe399de010 R09: 00007efe399de010 [14696.668363] R10: 0000000000000022 R11: 0000000000000246 R12: 0000000000000000 [14696.670155] R13: 0000000000000003 R14: 0000000000020000 R15: 0000000000020000 [14696.671965] </TASK> [14696.672826] task:umount state:D stack: 0 pid:1614985 ppid:1614984 flags:0x00004000 [14696.674930] Call Trace: [14696.675903] <TASK> [14696.676780] __schedule+0x302/0x930 [14696.677927] schedule+0x58/0xd0 [14696.679019] schedule_preempt_disabled+0x18/0x30 [14696.680412] __mutex_lock.constprop.0+0x2fb/0x4f0 [14696.681783] ? destroy_inode+0x65/0x80 [14696.683006] __mutex_lock_slowpath+0x13/0x20 [14696.684305] mutex_lock+0x34/0x40 [14696.685442] f2fs_destroy_stats+0x1e/0x60 [f2fs] [14696.686803] f2fs_put_super+0x158/0x390 [f2fs] [14696.688238] generic_shutdown_super+0x7a/0x120 [14696.689621] kill_block_super+0x27/0x50 [14696.690894] kill_f2fs_super+0x7f/0x100 [f2fs] [14696.692311] deactivate_locked_super+0x35/0xa0 [14696.693698] deactivate_super+0x40/0x50 [14696.694985] cleanup_mnt+0x139/0x190 [14696.696209] __cleanup_mnt+0x12/0x20 [14696.697390] task_work_run+0x64/0xa0 [14696.698587] exit_to_user_mode_prepare+0x1b7/0x1c0 [14696.700053] syscall_exit_to_user_mode+0x27/0x50 [14696.701418] do_syscall_64+0x48/0xc0 [14696.702630] entry_SYSCALL_64_after_hwframe+0x44/0xae
--- fs/f2fs/debug.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
fs/f2fs/debug.c +10 -7
@@ -21,7 +21,7 @@#include "gc.h" static LIST_HEAD (f2fs_stat_list); -static DEFINE_MUTEX (f2fs_stat_mutex); +static DEFINE_RAW_SPINLOCK (f2fs_stat_lock);#ifdef CONFIG_DEBUG_FS static struct dentry *f2fs_debugfs_root;#endif
@@ -345,8 +345,9 @@ static int stat_show(struct seq_file *s, void *v) {struct f2fs_stat_info *si;int i =0 , j =0 ; +unsigned long flags; -mutex_lock (&f2fs_stat_mutex); +raw_spin_lock_irqsave (&f2fs_stat_lock, flags);list_for_each_entry (si, &f2fs_stat_list, stat_list) {update_general_status (si->sbi);
@@ -574,7 +575,7 @@ static int stat_show(struct seq_file *s, void *v)seq_printf (s," - paged : %llu KB\n" , si->page_mem >>10 ); } -mutex_unlock (&f2fs_stat_mutex); +raw_spin_unlock_irqrestore (&f2fs_stat_lock, flags);return 0 ; }
@@ -585,6 +586,7 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi) {struct f2fs_super_block *raw_super =F2FS_RAW_SUPER (sbi);struct f2fs_stat_info *si; +unsigned long flags;int i; si =f2fs_kzalloc (sbi,sizeof (struct f2fs_stat_info ),GFP_KERNEL );
@@ -620,9 +622,9 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi)atomic_set (&sbi->max_aw_cnt,0 );atomic_set (&sbi->max_vw_cnt,0 ); -mutex_lock (&f2fs_stat_mutex); +raw_spin_lock_irqsave (&f2fs_stat_lock, flags);list_add_tail (&si->stat_list, &f2fs_stat_list); -mutex_unlock (&f2fs_stat_mutex); +raw_spin_unlock_irqrestore (&f2fs_stat_lock, flags);return 0 ; }
@@ -630,10 +632,11 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi)void f2fs_destroy_stats (struct f2fs_sb_info *sbi) {struct f2fs_stat_info *si =F2FS_STAT (sbi); +unsigned long flags; -mutex_lock (&f2fs_stat_mutex); +raw_spin_lock_irqsave (&f2fs_stat_lock, flags);list_del (&si->stat_list); -mutex_unlock (&f2fs_stat_mutex); +raw_spin_unlock_irqrestore (&f2fs_stat_lock, flags);kfree (si); }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 722/913 f2fs: compress: fix to print raw data size in error path of lz4 decompression
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit d284af43f703760e261b1601378a0c13a19d5f1f ]
In lz4_decompress_pages(), if size of decompressed data is not equal to expected one, we should print the size rather than size of target buffer for decompressed data, fix it.
--- fs/f2fs/compress.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/f2fs/compress.c +2 -3
@@ -312,10 +312,9 @@ static int lz4_decompress_pages(struct decompress_io_ctx *dic) }if (ret !=PAGE_SIZE << dic->log_cluster_size) { -printk_ratelimited ("%sF2FS-fs (%s): lz4 invalid rlen:%zu, " +printk_ratelimited ("%sF2FS-fs (%s): lz4 invalid ret:%d, " "expected:%lu\n" ,KERN_ERR , -F2FS_I_SB (dic->inode)->sb->s_id, - dic->rlen, +F2FS_I_SB (dic->inode)->sb->s_id, ret,PAGE_SIZE << dic->log_cluster_size);return -EIO ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 723/913 Adjust cifssb maximum read size
In reply to Greg Kroah-HartmanFrom: Rohith Surabattula <[email protected]>
[ Upstream commit 06a466565d54a1a42168f9033a062a3f5c40e73b ]
When session gets reconnected during mount then read size in super block fs context gets set to zero and after negotiate, rsize is not modified which results in incorrect read with requested bytes as zero. Fixes intermittent failure of xfstest generic/240
Note that stable requires a different version of this patch which will be sent to the stable mailing list.
--- fs/cifs/cifsfs.c | 3 +++ fs/cifs/file.c | 10 ++++++++++ 2 files changed, 13 insertions(+)
fs/cifs/cifsfs.c +3 -0
@@ -210,6 +210,9 @@ cifs_read_super(struct super_block *sb)if (rc) goto out_no_root;/* tune readahead according to rsize if readahead size not set on mount */ +if (cifs_sb->ctx->rsize ==0 ) + cifs_sb->ctx->rsize = + tcon->ses->server->ops->negotiate_rsize (tcon, cifs_sb->ctx);if (cifs_sb->ctx->rasize) sb->s_bdi->ra_pages = cifs_sb->ctx->rasize /PAGE_SIZE ;else
fs/cifs/file.c +10 -0
@@ -3734,6 +3734,11 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file,break ; } +if (cifs_sb->ctx->rsize ==0 ) + cifs_sb->ctx->rsize = + server->ops->negotiate_rsize (tlink_tcon (open_file->tlink), + cifs_sb->ctx); + rc = server->ops->wait_mtu_credits (server, cifs_sb->ctx->rsize, &rsize, credits);if (rc)
@@ -4512,6 +4517,11 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,break ; } +if (cifs_sb->ctx->rsize ==0 ) + cifs_sb->ctx->rsize = + server->ops->negotiate_rsize (tlink_tcon (open_file->tlink), + cifs_sb->ctx); + rc = server->ops->wait_mtu_credits (server, cifs_sb->ctx->rsize, &rsize, credits);if (rc)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 724/913 ntfs: add sanity check on allocation size
In reply to Greg Kroah-HartmanFrom: Dongliang Mu <[email protected]>
[ Upstream commit 714fbf2647b1a33d914edd695d4da92029c7e7c0 ]
ntfs_read_inode_mount invokes ntfs_malloc_nofs with zero allocation size. It triggers one BUG in the __ntfs_malloc function.
Fix this by adding sanity check on ni->attr_list_size.
--- fs/ntfs/inode.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/ntfs/inode.c +4 -0
@@ -1881,6 +1881,10 @@ int ntfs_read_inode_mount(struct inode *vi) }/* Now allocate memory for the attribute list. */ ni->attr_list_size = (u32 )ntfs_attr_size (a); +if (!ni->attr_list_size) { +ntfs_error (sb,"Attr_list_size is zero" ); + goto put_err_out; + } ni->attr_list =ntfs_malloc_nofs (ni->attr_list_size);if (!ni->attr_list) { ntfs_error(sb, "Not enough memory to allocate buffer "
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 725/913 media: staging: media: zoran: move videodev alloc
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
[ Upstream commit 82e3a496eb56da0b9f29fdc5b63cedb3289e91de ]
Move some code out of zr36057_init() and create new functions for handling zr->video_dev. This permit to ease code reading and fix a zr->video_dev memory leak.
--- drivers/staging/media/zoran/zoran.h | 2 +- drivers/staging/media/zoran/zoran_card.c | 80 ++++++++++++++-------- drivers/staging/media/zoran/zoran_driver.c | 5 +- 3 files changed, 54 insertions(+), 33 deletions(-)
drivers/staging/media/zoran/zoran.h +1 -1
@@ -313,6 +313,6 @@ static inline struct zoran *to_zoran(struct v4l2_device *v4l2_dev)#endif -int zoran_queue_init (struct zoran *zr,struct vb2_queue *vq); +int zoran_queue_init (struct zoran *zr,struct vb2_queue *vq,int dir);void zoran_queue_exit (struct zoran *zr);int zr_set_buf (struct zoran *zr);
drivers/staging/media/zoran/zoran_card.c +50 -30
115 lines not on this page · raw message
drivers/staging/media/zoran/zoran_driver.c +3 -2
@@ -1008,7 +1008,7 @@ static const struct vb2_ops zr_video_qops = { .wait_finish = vb2_ops_wait_finish, }; -int zoran_queue_init (struct zoran *zr,struct vb2_queue *vq) +int zoran_queue_init (struct zoran *zr,struct vb2_queue *vq,int dir) {int err;
@@ -1016,7 +1016,8 @@ int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq)INIT_LIST_HEAD (&zr->queued_bufs); vq->dev = &zr->pci_dev->dev; - vq->type =V4L2_BUF_TYPE_VIDEO_CAPTURE ; + vq->type = dir; + vq->io_modes =VB2_USERPTR |VB2_DMABUF |VB2_MMAP |VB2_READ |VB2_WRITE ; vq->drv_priv = zr; vq->buf_struct_size =sizeof (struct zr_buffer );
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 726/913 media: staging: media: zoran: calculate the right buffer number for zoran_reap_stat_com
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
[ Upstream commit e3b86f4e558cea9eed71d894df2f19b10d60a207 ]
On the case tmp_dcim=1, the index of buffer is miscalculated. This generate a NULL pointer dereference later.
So let's fix the calcul and add a check to prevent this to reappear.
--- drivers/staging/media/zoran/zoran_device.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/staging/media/zoran/zoran_device.c +6 -1
@@ -814,7 +814,7 @@ static void zoran_reap_stat_com(struct zoran *zr)if (zr->jpg_settings.tmp_dcm ==1 ) i = (zr->jpg_dma_tail - zr->jpg_err_shift) &BUZ_MASK_STAT_COM ;else - i = ((zr->jpg_dma_tail - zr->jpg_err_shift) &1 ) *2 +1 ; + i = ((zr->jpg_dma_tail - zr->jpg_err_shift) &1 ) *2 ; stat_com =le32_to_cpu (zr->stat_com[i]);if ((stat_com &1 ) ==0 ) {
@@ -826,6 +826,11 @@ static void zoran_reap_stat_com(struct zoran *zr) size = (stat_com &GENMASK (22 ,1 )) >>1 ; buf = zr->inuse[i]; +if (!buf) { +spin_unlock_irqrestore (&zr->queued_bufs_lock, flags); +pci_err (zr->pci_dev,"No buffer at slot %d\n" , i); +return ; + } buf->vbuf.vb2_buf.timestamp =ktime_get_ns ();if (zr->codec_mode ==BUZ_MODE_MOTION_COMPRESS ) {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 727/913 media: staging: media: zoran: fix various V4L2 compliance errors
In reply to Greg Kroah-HartmanFrom: Hans Verkuil <[email protected]>
[ Upstream commit 914941827aad5ecddf9bf3a6dee67fbec1af1fff ]
This fixes several issues found with 'v4l2-compliance -s':
1) read()/write() is supported, but not reported in the capabilities
2) S_STD(G_STD()) failed: setting the same standard should just return 0.
3) G_PARM failed to set readbuffers.
4) different field values in the format vs. what v4l2_buffer reported.
5) zero the sequence number when starting streaming.
6) drop VB_USERPTR: makes no sense with dma_contig streaming.
--- drivers/staging/media/zoran/zoran_card.c | 2 +- drivers/staging/media/zoran/zoran_driver.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/staging/media/zoran/zoran_card.c +1 -1
@@ -811,7 +811,7 @@ static int zoran_init_video_device(struct zoran *zr, struct video_device *video_ *video_dev = zoran_template; video_dev->v4l2_dev = &zr->v4l2_dev; video_dev->lock = &zr->lock; - video_dev->device_caps =V4L2_CAP_STREAMING | dir; + video_dev->device_caps =V4L2_CAP_STREAMING |V4L2_CAP_READWRITE | dir;strscpy (video_dev->name,ZR_DEVNAME (zr),sizeof (video_dev->name));/*
drivers/staging/media/zoran/zoran_driver.c +10 -3
@@ -255,8 +255,6 @@ static int zoran_querycap(struct file *file, void *__fh, struct v4l2_capabilitystrscpy (cap->card,ZR_DEVNAME (zr),sizeof (cap->card));strscpy (cap->driver,"zoran" ,sizeof (cap->driver));snprintf (cap->bus_info,sizeof (cap->bus_info),"PCI:%s" ,pci_name (zr->pci_dev)); - cap->device_caps = zr->video_dev->device_caps; - cap->capabilities = cap->device_caps |V4L2_CAP_DEVICE_CAPS ;return 0 ; }
@@ -582,6 +580,9 @@ static int zoran_s_std(struct file *file, void *__fh, v4l2_std_id std)struct zoran *zr =video_drvdata (file);int res =0 ; +if (zr->norm == std) +return 0 ; +if (zr->running !=ZORAN_MAP_MODE_NONE )return -EBUSY ;
@@ -739,6 +740,7 @@ static int zoran_g_parm(struct file *file, void *priv, struct v4l2_streamparm *pif (parm->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE )return -EINVAL ; + parm->parm.capture.readbuffers =9 ;return 0 ; }
@@ -869,6 +871,10 @@ int zr_set_buf(struct zoran *zr) vbuf = &buf->vbuf; buf->vbuf.field =V4L2_FIELD_INTERLACED ; +if (BUZ_MAX_HEIGHT < (zr->v4l_settings.height *2 )) + buf->vbuf.field =V4L2_FIELD_INTERLACED ; +else + buf->vbuf.field =V4L2_FIELD_TOP ;vb2_set_plane_payload (&buf->vbuf.vb2_buf,0 , zr->buffer_size);vb2_buffer_done (&buf->vbuf.vb2_buf,VB2_BUF_STATE_DONE ); zr->inuse[0 ] =NULL ;
@@ -928,6 +934,7 @@ static int zr_vb2_start_streaming(struct vb2_queue *vq, unsigned int count) zr->stat_com[j] =cpu_to_le32 (1 ); zr->inuse[j] =NULL ; } + zr->vbseq =0 ;if (zr->map_mode !=ZORAN_MAP_MODE_RAW ) {pci_info (zr->pci_dev,"START JPG\n" );
@@ -1018,7 +1025,7 @@ int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq, int dir) vq->dev = &zr->pci_dev->dev; vq->type = dir; - vq->io_modes =VB2_USERPTR |VB2_DMABUF |VB2_MMAP |VB2_READ |VB2_WRITE ; + vq->io_modes =VB2_DMABUF |VB2_MMAP |VB2_READ |VB2_WRITE ; vq->drv_priv = zr; vq->buf_struct_size =sizeof (struct zr_buffer ); vq->ops = &zr_video_qops;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 728/913 media: atmel: atmel-isc-base: report frame sizes as full supported range
In reply to Greg Kroah-HartmanFrom: Eugen Hristev <[email protected]>
[ Upstream commit 72802a86e11c34e819fbfb38f58c5aef668f833d ]
The ISC supports a full broad range of frame sizes.
Until now, the subdevice was queried for possible frame sizes and these were reported to the user space.
However, the ISC should not care about which frame sizes the subdev supports, as long as this frame size is supported.
Thus, report a continuous range from smallest frame size up to the max resolution.
--- drivers/media/platform/atmel/atmel-isc-base.c | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-)
drivers/media/platform/atmel/atmel-isc-base.c +10 -12
@@ -1369,14 +1369,12 @@ static int isc_enum_framesizes(struct file *file, void *fh, struct v4l2_frmsizeenum *fsize) {struct isc_device *isc =video_drvdata (file); -struct v4l2_subdev_frame_size_enum fse = { - .code = isc->config.sd_format->mbus_code, - .index = fsize->index, - .which =V4L2_SUBDEV_FORMAT_ACTIVE , - };int ret = -EINVAL ;int i; +if (fsize->index) +return -EINVAL ; +for (i =0 ; i < isc->num_user_formats; i++)if (isc->user_formats[i]->fourcc == fsize->pixel_format) ret =0 ;
@@ -1388,14 +1386,14 @@ static int isc_enum_framesizes(struct file *file, void *fh,if (ret)return ret; - ret =v4l2_subdev_call (isc->current_subdev->sd, pad, enum_frame_size, -NULL , &fse); -if (ret) -return ret; + fsize->type =V4L2_FRMSIZE_TYPE_CONTINUOUS ; - fsize->type =V4L2_FRMSIZE_TYPE_DISCRETE ; - fsize->discrete.width = fse.max_width; - fsize->discrete.height = fse.max_height; + fsize->stepwise.min_width =16 ; + fsize->stepwise.max_width = isc->max_width; + fsize->stepwise.min_height =16 ; + fsize->stepwise.max_height = isc->max_height; + fsize->stepwise.step_width =1 ; + fsize->stepwise.step_height =1 ;return 0 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 729/913 media: ir_toy: free before error exiting
In reply to Greg Kroah-HartmanFrom: Peiwei Hu <[email protected]>
[ Upstream commit 52cdb013036391d9d87aba5b4fc49cdfc6ea4b23 ]
Fix leak in error path.
--- drivers/media/rc/ir_toy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/ir_toy.c +1 -1
@@ -429,7 +429,7 @@ static int irtoy_probe(struct usb_interface *intf, err =usb_submit_urb (irtoy->urb_in,GFP_KERNEL );if (err !=0 ) {dev_err (irtoy->dev,"fail to submit in urb: %d\n" , err); -return err; + goto free_rcdev; } err =irtoy_setup (irtoy);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 730/913 ASoC: sh: rz-ssi: Make the data structures available before registering the handlers
In reply to Greg Kroah-HartmanFrom: Lad Prabhakar <[email protected]>
[ Upstream commit 0788785c78342d422f93b1c9831c2b2b7f137937 ]
Initialize the spinlock and make the data structures available before registering the interrupt handlers.
--- sound/soc/sh/rz-ssi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/soc/sh/rz-ssi.c +3 -2
@@ -977,6 +977,9 @@ static int rz_ssi_probe(struct platform_device *pdev) ssi->playback.priv = ssi; ssi->capture.priv = ssi; +spin_lock_init (&ssi->lock); +dev_set_drvdata (&pdev->dev, ssi); +/* Error Interrupt */ ssi->irq_int =platform_get_irq_byname (pdev,"int_req" );if (ssi->irq_int <0 )
@@ -1024,8 +1027,6 @@ static int rz_ssi_probe(struct platform_device *pdev)pm_runtime_enable (&pdev->dev);pm_runtime_resume_and_get (&pdev->dev); -spin_lock_init (&ssi->lock); -dev_set_drvdata (&pdev->dev, ssi); ret =devm_snd_soc_register_component (&pdev->dev, &rz_ssi_soc_component, rz_ssi_soc_dai,ARRAY_SIZE (rz_ssi_soc_dai));
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 731/913 ASoC: SOF: Intel: match sdw version on link_slaves_found
In reply to Greg Kroah-HartmanFrom: Bard Liao <[email protected]>
[ Upstream commit f67c0c0d3b9048d86ea6ae52e36a2b78c48f265d ]
Codecs with the same part id, manufacturer id and part id, but different sdw version should be treated as different codecs. For example, rt711 and rt711-sdca are different. So, we should match sdw version as well.
--- sound/soc/sof/intel/hda.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
sound/soc/sof/intel/hda.c +10 -5
@@ -1072,7 +1072,7 @@ static bool link_slaves_found(struct snd_sof_dev *sdev,struct hdac_bus *bus =sof_to_bus (sdev);struct sdw_intel_slave_id *ids = sdw->ids;int num_slaves = sdw->num_slaves; -unsigned int part_id, link_id, unique_id, mfg_id; +unsigned int part_id, link_id, unique_id, mfg_id, version;int i, j, k;for (i =0 ; i < link->num_adr; i++) {
@@ -1082,12 +1082,14 @@ static bool link_slaves_found(struct snd_sof_dev *sdev, mfg_id =SDW_MFG_ID (adr); part_id =SDW_PART_ID (adr); link_id =SDW_DISCO_LINK_ID (adr); + version =SDW_VERSION (adr);for (j =0 ; j < num_slaves; j++) {/* find out how many identical parts were reported on that link */ if (ids[j].link_id == link_id && ids[j].id.part_id == part_id && - ids[j].id.mfg_id == mfg_id) + ids[j].id.mfg_id == mfg_id && + ids[j].id.sdw_version == version) reported_part_count++; }
@@ -1096,21 +1098,24 @@ static bool link_slaves_found(struct snd_sof_dev *sdev,if (ids[j].link_id != link_id || ids[j].id.part_id != part_id || - ids[j].id.mfg_id != mfg_id) + ids[j].id.mfg_id != mfg_id || + ids[j].id.sdw_version != version)continue ;/* find out how many identical parts are expected */ for (k =0 ; k < link->num_adr; k++) {u64 adr2 = link->adr_d[k].adr; -unsigned int part_id2, link_id2, mfg_id2; +unsigned int part_id2, link_id2, mfg_id2, version2; mfg_id2 =SDW_MFG_ID (adr2); part_id2 =SDW_PART_ID (adr2); link_id2 =SDW_DISCO_LINK_ID (adr2); + version2 =SDW_VERSION (adr2);if (link_id2 == link_id && part_id2 == part_id && - mfg_id2 == mfg_id) + mfg_id2 == mfg_id && + version2 == version) expected_part_count++; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 732/913 media: imx-jpeg: Prevent decoding NV12M jpegs into single-planar buffers
In reply to Greg Kroah-HartmanFrom: Mirela Rabulea <[email protected]>
[ Upstream commit 417591a766b3c040c346044541ff949c0b2bb7b2 ]
If the application queues an NV12M jpeg as output buffer, but then queues a single planar capture buffer, the kernel will crash with "Unable to handle kernel NULL pointer dereference" in mxc_jpeg_addrs, prevent this by finishing the job with error.
--- drivers/media/platform/imx-jpeg/mxc-jpeg.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/media/platform/imx-jpeg/mxc-jpeg.c +6 -0
@@ -925,6 +925,12 @@ static void mxc_jpeg_device_run(void *priv)v4l2_m2m_buf_copy_metadata (src_buf, dst_buf, true); jpeg_src_buf =vb2_to_mxc_buf (&src_buf->vb2_buf); +if (q_data_cap->fmt->colplanes != dst_buf->vb2_buf.num_planes) { +dev_err (dev,"Capture format %s has %d planes, but capture buffer has %d planes\n" , + q_data_cap->fmt->name, q_data_cap->fmt->colplanes, + dst_buf->vb2_buf.num_planes); + jpeg_src_buf->jpeg_parse_error = true; + }if (jpeg_src_buf->jpeg_parse_error) { jpeg->slot_data[ctx->slot].used = false;v4l2_m2m_src_buf_remove (ctx->fh.m2m_ctx);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 733/913 ASoC: SOF: Intel: hda: Remove link assignment limitation
In reply to Greg Kroah-HartmanFrom: Ranjani Sridharan <[email protected]>
[ Upstream commit 2ce0d008dcc59f9c01f43277b9f9743af7b01dad ]
The limitation to assign a link DMA channel for a BE iff the corresponding host DMA channel is assigned to a connected FE is only applicable if the PROCEN_FMT_QUIRK is set. So, remove it for platforms that do not enable the quirk.
Complements: a792bfc1c2bc ("ASoC: SOF: Intel: hda-stream: limit PROCEN workaround")
--- sound/soc/sof/intel/hda-dai.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
sound/soc/sof/intel/hda-dai.c +13 -0
@@ -58,6 +58,8 @@ static struct hdac_ext_stream * {struct snd_soc_pcm_runtime *rtd =asoc_substream_to_rtd (substream);struct sof_intel_hda_stream *hda_stream; +const struct sof_intel_dsp_desc *chip; +struct snd_sof_dev *sdev;struct hdac_ext_stream *res =NULL ;struct hdac_stream *stream =NULL ;
@@ -76,9 +78,20 @@ static struct hdac_ext_stream *continue ; hda_stream =hstream_to_sof_hda_stream (hstream); + sdev = hda_stream->sdev; + chip =get_chip_info (sdev->pdata);/* check if link is available */ if (!hstream->link_locked) { +/* +* choose the first available link for platforms that do not have the +* PROCEN_FMT_QUIRK set. +*/ +if (!(chip->quirks &SOF_INTEL_PROCEN_FMT_QUIRK )) { + res = hstream; +break ; + } +if (stream->opened) {/* * check if the stream tag matches the stream
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 734/913 media: iommu/mediatek-v1: Free the existed fwspec if the master dev already has
In reply to Greg Kroah-HartmanFrom: Yong Wu <[email protected]>
[ Upstream commit 822a2ed8c606caf6a11b1a180b8e46292bd77d71 ]
When the iommu master device enters of_iommu_xlate, the ops may be NULL(iommu dev is defered), then it will initialize the fwspec here:
[<c0c9c5bc>] (dev_iommu_fwspec_set) from [<c06bda80>] (iommu_fwspec_init+0xbc/0xd4)
[<c06bd9c4>] (iommu_fwspec_init) from [<c06c0db4>] (of_iommu_xlate+0x7c/0x12c)
[<c06c0d38>] (of_iommu_xlate) from [<c06c10e8>] (of_iommu_configure+0x144/0x1e8)
BUT the mtk_iommu_v1.c only supports arm32, the probing flow still is a bit weird. We always expect create the fwspec internally. otherwise it will enter here and return fail.
static int mtk_iommu_create_mapping(struct device *dev,
struct of_phandle_args *args)
{
...
if (!fwspec) {
....
} else if (dev_iommu_fwspec_get(dev)->ops != &mtk_iommu_ops) {
>>>>>>>>>>Enter here. return fail.<<<<<<<<<<<<
return -EINVAL;
}
...
}Thus, Free the existed fwspec if the master device already has fwspec.
This issue is reported at:
https://lore.kernel.org/linux-mediatek/trinity-7d9ebdc9-4849-4d93-bfb5-429dcb4ee449-1626253158870@3c-app-gmx-bs01/
--- drivers/iommu/mtk_iommu_v1.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/iommu/mtk_iommu_v1.c +9 -0
@@ -425,6 +425,15 @@ static struct iommu_device *mtk_iommu_probe_device(struct device *dev)struct mtk_iommu_data *data;int err, idx =0 ; +/* +* In the deferred case, free the existed fwspec. +* Always initialize the fwspec internally. +*/ +if (fwspec) { +iommu_fwspec_free (dev); + fwspec =dev_iommu_fwspec_get (dev); + } +while (!of_parse_phandle_with_args (dev->of_node,"iommus" ,"#iommu-cells" , idx, &iommu_spec)) {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 735/913 media: iommu/mediatek: Return ENODEV if the device is NULL
In reply to Greg Kroah-HartmanFrom: Yong Wu <[email protected]>
[ Upstream commit 2fb0feed51085db77606de9b9477c96894328809 ]
The platform device is created at:of_platform_default_populate_init: arch_initcall_sync
->of_platform_populate
->of_platform_device_create_pdata
When entering our probe, all the devices should be already created. if it is null, means NODEV. Currently we don't get the fail case. It's a minor fix, no need add fixes tags.
--- drivers/iommu/mtk_iommu.c | 2 +- drivers/iommu/mtk_iommu_v1.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/mtk_iommu.c +1 -1
@@ -848,7 +848,7 @@ static int mtk_iommu_probe(struct platform_device *pdev) plarbdev =of_find_device_by_node (larbnode);if (!plarbdev) {of_node_put (larbnode); -return -EPROBE_DEFER ; +return -ENODEV ; } data->larb_imu[id].dev = &plarbdev->dev;
drivers/iommu/mtk_iommu_v1.c +1 -1
@@ -604,7 +604,7 @@ static int mtk_iommu_probe(struct platform_device *pdev) plarbdev =of_find_device_by_node (larbnode);if (!plarbdev) {of_node_put (larbnode); -return -EPROBE_DEFER ; +return -ENODEV ; } data->larb_imu[i].dev = &plarbdev->dev;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 736/913 media: iommu/mediatek: Add device_link between the consumer and the larb devices
In reply to Greg Kroah-HartmanFrom: Yong Wu <[email protected]>
[ Upstream commit 635319a4a7444ca97124d781cd96deb277ff4d40 ]
MediaTek IOMMU-SMI diagram is like below. all the consumer connect with smi-larb, then connect with smi-common.
M4U
|
smi-common
|
-------------
| | ...
| |
larb1 larb2
| |
vdec vencWhen the consumer works, it should enable the smi-larb's power which also need enable the smi-common's power firstly.
Thus, First of all, use the device link connect the consumer and the smi-larbs. then add device link between the smi-larb and smi-common.
This patch adds device_link between the consumer and the larbs.
When device_link_add, I add the flag DL_FLAG_STATELESS to avoid calling pm_runtime_xx to keep the original status of clocks. It can avoid two issues:
1) Display HW show fastlogo abnormally reported in [1]. At the beggining, all the clocks are enabled before entering kernel, but the clocks for display HW(always in larb0) will be gated after clk_enable and clk_disable called from device_link_add(->pm_runtime_resume) and rpm_idle. The clock operation happened before display driver probe. At that time, the display HW will be abnormal.
2) A deadlock issue reported in [2]. Use DL_FLAG_STATELESS to skip pm_runtime_xx to avoid the deadlock.
Corresponding, DL_FLAG_AUTOREMOVE_CONSUMER can't be added, then device_link_removed should be added explicitly.
Meanwhile, Currently we don't have a device connect with 2 larbs at the same time. Disallow this case, print the error log.
[1] https://lore.kernel.org/linux-mediatek/1564213888.22908.4.camel@mhfsdcap03/
[2] https://lore.kernel.org/patchwork/patch/1086569/
--- drivers/iommu/mtk_iommu.c | 30 ++++++++++++++++++++++++++++++ drivers/iommu/mtk_iommu_v1.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-)
drivers/iommu/mtk_iommu.c +30 -0
@@ -562,22 +562,52 @@ static struct iommu_device *mtk_iommu_probe_device(struct device *dev) {struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct mtk_iommu_data *data; +struct device_link *link; +struct device *larbdev; +unsigned int larbid, larbidx, i;if (!fwspec || fwspec->ops != &mtk_iommu_ops)return ERR_PTR (-ENODEV );/* Not a iommu client device */ data =dev_iommu_priv_get (dev); +/* +* Link the consumer device with the smi-larb device(supplier). +* The device that connects with each a larb is a independent HW. +* All the ports in each a device should be in the same larbs. +*/ + larbid =MTK_M4U_TO_LARB (fwspec->ids[0 ]); +for (i =1 ; i < fwspec->num_ids; i++) { + larbidx =MTK_M4U_TO_LARB (fwspec->ids[i]); +if (larbid != larbidx) { +dev_err (dev,"Can only use one larb. Fail@larb%d-%d.\n" , + larbid, larbidx); +return ERR_PTR (-EINVAL ); + } + } + larbdev = data->larb_imu[larbid].dev; + link =device_link_add (dev, larbdev, +DL_FLAG_PM_RUNTIME |DL_FLAG_STATELESS ); +if (!link) +dev_err (dev,"Unable to link %s\n" ,dev_name (larbdev));return &data->iommu; }static void mtk_iommu_release_device (struct device *dev) {struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev); +struct mtk_iommu_data *data; +struct device *larbdev; +unsigned int larbid;if (!fwspec || fwspec->ops != &mtk_iommu_ops)return ; + data =dev_iommu_priv_get (dev); + larbid =MTK_M4U_TO_LARB (fwspec->ids[0 ]); + larbdev = data->larb_imu[larbid].dev; +device_link_remove (dev, larbdev); +iommu_fwspec_free (dev); }
drivers/iommu/mtk_iommu_v1.c +28 -1
@@ -423,7 +423,9 @@ static struct iommu_device *mtk_iommu_probe_device(struct device *dev)struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct of_phandle_args iommu_spec;struct mtk_iommu_data *data; -int err, idx =0 ; +int err, idx =0 , larbid, larbidx; +struct device_link *link; +struct device *larbdev;/* * In the deferred case, free the existed fwspec.
@@ -453,6 +455,23 @@ static struct iommu_device *mtk_iommu_probe_device(struct device *dev) data =dev_iommu_priv_get (dev); +/* Link the consumer device with the smi-larb device(supplier) */ + larbid =mt2701_m4u_to_larb (fwspec->ids[0 ]); +for (idx =1 ; idx < fwspec->num_ids; idx++) { + larbidx =mt2701_m4u_to_larb (fwspec->ids[idx]); +if (larbid != larbidx) { +dev_err (dev,"Can only use one larb. Fail@larb%d-%d.\n" , + larbid, larbidx); +return ERR_PTR (-EINVAL ); + } + } + + larbdev = data->larb_imu[larbid].dev; + link =device_link_add (dev, larbdev, +DL_FLAG_PM_RUNTIME |DL_FLAG_STATELESS ); +if (!link) +dev_err (dev,"Unable to link %s\n" ,dev_name (larbdev)); +return &data->iommu; }
@@ -473,10 +492,18 @@ static void mtk_iommu_probe_finalize(struct device *dev)static void mtk_iommu_release_device (struct device *dev) {struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev); +struct mtk_iommu_data *data; +struct device *larbdev; +unsigned int larbid;if (!fwspec || fwspec->ops != &mtk_iommu_ops)return ; + data =dev_iommu_priv_get (dev); + larbid =mt2701_m4u_to_larb (fwspec->ids[0 ]); + larbdev = data->larb_imu[larbid].dev; +device_link_remove (dev, larbdev); +iommu_fwspec_free (dev); }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 737/913 video: fbdev: nvidiafb: Use strscpy() to prevent buffer overflow
In reply to Greg Kroah-HartmanFrom: Tim Gardner <[email protected]>
[ Upstream commit 37a1a2e6eeeb101285cd34e12e48a881524701aa ]
Coverity complains of a possible buffer overflow. However, given the 'static' scope of nvidia_setup_i2c_bus() it looks like that can't happen after examiniing the call sites.
CID 19036 (#1 of 1): Copy into fixed size buffer (STRING_OVERFLOW)
1. fixed_size_dest: You might overrun the 48-character fixed-size string chan->adapter.name by copying name without checking the length.
2. parameter_as_source: Note: This defect has an elevated risk because the source argument is a parameter of the current function.
89 strcpy(chan->adapter.name, name);
Fix this warning by using strscpy() which will silence the warning and prevent any future buffer overflows should the names used to identify the channel become much longer.
--- drivers/video/fbdev/nvidia/nv_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/nvidia/nv_i2c.c +1 -1
@@ -86,7 +86,7 @@ static int nvidia_setup_i2c_bus(struct nvidia_i2c_chan *chan, const char *name, {int rc; -strcpy (chan->adapter.name, name); +strscpy (chan->adapter.name, name,sizeof (chan->adapter.name)); chan->adapter.owner =THIS_MODULE ; chan->adapter.class = i2c_class; chan->adapter.algo_data = &chan->algo;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 738/913 video: fbdev: w100fb: Reset global state
In reply to Greg Kroah-HartmanFrom: Evgeny Novikov <[email protected]>
[ Upstream commit 8738ddcac644964ae128ccd3d80d48773c8d528e ]
w100fb_probe() did not reset the global state to its initial state. This can result in invocation of iounmap() even when there was not the appropriate successful call of ioremap(). For instance, this may be the case if first probe fails after two successful ioremap() while second probe fails when first ioremap() fails. The similar issue is with w100fb_remove(). The patch fixes both bugs.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/video/fbdev/w100fb.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/video/fbdev/w100fb.c +12 -3
@@ -770,12 +770,18 @@ static int w100fb_probe(struct platform_device *pdev)fb_dealloc_cmap (&info->cmap);kfree (info->pseudo_palette); } -if (remapped_fbuf !=NULL ) +if (remapped_fbuf !=NULL ) {iounmap (remapped_fbuf); -if (remapped_regs !=NULL ) + remapped_fbuf =NULL ; + } +if (remapped_regs !=NULL ) {iounmap (remapped_regs); -if (remapped_base !=NULL ) + remapped_regs =NULL ; + } +if (remapped_base !=NULL ) {iounmap (remapped_base); + remapped_base =NULL ; + }if (info)framebuffer_release (info);return err;
@@ -795,8 +801,11 @@ static int w100fb_remove(struct platform_device *pdev)fb_dealloc_cmap (&info->cmap);iounmap (remapped_base); + remapped_base =NULL ;iounmap (remapped_regs); + remapped_regs =NULL ;iounmap (remapped_fbuf); + remapped_fbuf =NULL ;framebuffer_release (info);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 739/913 video: fbdev: cirrusfb: check pixclock to avoid divide by zero
In reply to Greg Kroah-HartmanFrom: George Kennedy <[email protected]>
[ Upstream commit 5c6f402bdcf9e7239c6bc7087eda71ac99b31379 ]
Do a sanity check on pixclock value to avoid divide by zero.
If the pixclock value is zero, the cirrusfb driver will round up pixclock to get the derived frequency as close to maxclock as possible.
Syzkaller reported a divide error in cirrusfb_check_pixclock.
divide error: 0000 [#1] SMP KASAN PTI
CPU: 0 PID: 14938 Comm: cirrusfb_test Not tainted 5.15.0-rc6 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-2 RIP: 0010:cirrusfb_check_var+0x6f1/0x1260 Call Trace: fb_set_var+0x398/0xf90 do_fb_ioctl+0x4b8/0x6f0 fb_ioctl+0xeb/0x130 __x64_sys_ioctl+0x19d/0x220 do_syscall_64+0x3a/0x80 entry_SYSCALL_64_after_hwframe+0x44/0xae
--- drivers/video/fbdev/cirrusfb.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/video/fbdev/cirrusfb.c +8 -8
@@ -469,7 +469,7 @@ static int cirrusfb_check_mclk(struct fb_info *info, long freq)return 0 ; } -static int cirrusfb_check_pixclock (const struct fb_var_screeninfo *var, +static int cirrusfb_check_pixclock (struct fb_var_screeninfo *var,struct fb_info *info) {long freq;
@@ -478,9 +478,7 @@ static int cirrusfb_check_pixclock(const struct fb_var_screeninfo *var,unsigned maxclockidx = var->bits_per_pixel >>3 ;/* convert from ps to kHz */ - freq =PICOS2KHZ (var->pixclock); - -dev_dbg (info->device,"desired pixclock: %ld kHz\n" , freq); + freq =PICOS2KHZ (var->pixclock ? :1 ); maxclock = cirrusfb_board_info[cinfo->btype].maxclock[maxclockidx]; cinfo->multiplexing =0 ;
@@ -488,11 +486,13 @@ static int cirrusfb_check_pixclock(const struct fb_var_screeninfo *var,/* If the frequency is greater than we can support, we might be able * to use multiplexing for the video mode */ if (freq > maxclock) { -dev_err (info->device, -"Frequency greater than maxclock (%ld kHz)\n" , - maxclock); -return -EINVAL ; + var->pixclock =KHZ2PICOS (maxclock); + +while ((freq =PICOS2KHZ (var->pixclock)) > maxclock) + var->pixclock++; } +dev_dbg (info->device,"desired pixclock: %ld kHz\n" , freq); +/* * Additional constraint: 8bpp uses DAC clock doubling to allow maximum * pixel clock
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 740/913 video: fbdev: omapfb: acx565akm: replace snprintf with sysfs_emit
In reply to Greg Kroah-HartmanFrom: Yang Guang <[email protected]>
[ Upstream commit 24565bc4115961db7ee64fcc7ad2a7437c0d0a49 ]
coccinelle report:./drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c:
479:9-17: WARNING: use scnprintf or sprintf
Use sysfs_emit instead of scnprintf or sprintf makes more sense.
--- .../video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c +1 -1
@@ -476,7 +476,7 @@ static ssize_t show_cabc_available_modes(struct device *dev,int i;if (!ddata->has_cabc) -return snprintf (buf,PAGE_SIZE ,"%s\n" , cabc_modes[0 ]); +return sysfs_emit (buf,"%s\n" , cabc_modes[0 ]);for (i =0 , len =0 ; len <PAGE_SIZE && i <ARRAY_SIZE (cabc_modes); i++)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 741/913 ARM: dts: qcom: fix gic_irq_domain_translate warnings for msm8960
In reply to Greg Kroah-HartmanFrom: David Heidelberg <[email protected]>
[ Upstream commit 6f7e221e7a5cfc3299616543fce42b36e631497b ]
IRQ types blindly copied from very similar APQ8064.
Fixes warnings as:
WARNING: CPU: 0 PID: 1 at drivers/irqchip/irq-gic.c:1080 gic_irq_domain_translate+0x118/0x120
...
--- arch/arm/boot/dts/qcom-msm8960.dtsi | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/arm/boot/dts/qcom-msm8960.dtsi +5 -3
@@ -146,7 +146,9 @@ reg = <0x108000 0x1000>; qcom,ipc = <&l2cc 0x8 2>; - interrupts = <0 19 0>, <0 21 0>, <0 22 0>; + interrupts = <GIC_SPI 19 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 21 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 22 IRQ_TYPE_EDGE_RISING>; interrupt-names = "ack", "err", "wakeup"; regulators {
@@ -192,7 +194,7 @@ compatible = "qcom,msm-uartdm-v1.3", "qcom,msm-uartdm"; reg = <0x16440000 0x1000>, <0x16400000 0x1000>; - interrupts = <0 154 0x0>; + interrupts = <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>; clocks = <&gcc GSBI5_UART_CLK>, <&gcc GSBI5_H_CLK>; clock-names = "core", "iface"; status = "disabled";
@@ -318,7 +320,7 @@ #address-cells = <1>; #size-cells = <0>; reg = <0x16080000 0x1000>; - interrupts = <0 147 0>; + interrupts = <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>; spi-max-frequency = <24000000>; cs-gpios = <&msmgpio 8 0>;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 742/913 ARM: dts: bcm2837: Add the missing L1/L2 cache information
In reply to Greg Kroah-HartmanFrom: Richard Schleich <[email protected]>
[ Upstream commit bdf8762da268d2a34abf517c36528413906e9cd5 ]
This patch fixes the kernel warning "cacheinfo: Unable to detect cache hierarchy for CPU 0" for the bcm2837 on newer kernel versions.
--- arch/arm/boot/dts/bcm2837.dtsi | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
arch/arm/boot/dts/bcm2837.dtsi +49 -0
@@ -40,12 +40,26 @@ #size-cells = <0>; enable-method = "brcm,bcm2836-smp"; // for ARM 32-bit + /* Source for d/i-cache-line-size and d/i-cache-sets + * https://developer.arm.com/documentation/ddi0500/e/level-1-memory-system + * /about-the-l1-memory-system?lang=en + * + * Source for d/i-cache-size + * https://magpi.raspberrypi.com/articles/raspberry-pi-3-specs-benchmarks + */ cpu0: cpu@0 { device_type = "cpu"; compatible = "arm,cortex-a53"; reg = <0>; enable-method = "spin-table"; cpu-release-addr = <0x0 0x000000d8>; + d-cache-size = <0x8000>; + d-cache-line-size = <64>; + d-cache-sets = <128>; // 32KiB(size)/64(line-size)=512ways/4-way set + i-cache-size = <0x8000>; + i-cache-line-size = <64>; + i-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set + next-level-cache = <&l2>; }; cpu1: cpu@1 {
@@ -54,6 +68,13 @@ reg = <1>; enable-method = "spin-table"; cpu-release-addr = <0x0 0x000000e0>; + d-cache-size = <0x8000>; + d-cache-line-size = <64>; + d-cache-sets = <128>; // 32KiB(size)/64(line-size)=512ways/4-way set + i-cache-size = <0x8000>; + i-cache-line-size = <64>; + i-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set + next-level-cache = <&l2>; }; cpu2: cpu@2 {
@@ -62,6 +83,13 @@ reg = <2>; enable-method = "spin-table"; cpu-release-addr = <0x0 0x000000e8>; + d-cache-size = <0x8000>; + d-cache-line-size = <64>; + d-cache-sets = <128>; // 32KiB(size)/64(line-size)=512ways/4-way set + i-cache-size = <0x8000>; + i-cache-line-size = <64>; + i-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set + next-level-cache = <&l2>; }; cpu3: cpu@3 {
@@ -70,6 +98,27 @@ reg = <3>; enable-method = "spin-table"; cpu-release-addr = <0x0 0x000000f0>; + d-cache-size = <0x8000>; + d-cache-line-size = <64>; + d-cache-sets = <128>; // 32KiB(size)/64(line-size)=512ways/4-way set + i-cache-size = <0x8000>; + i-cache-line-size = <64>; + i-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set + next-level-cache = <&l2>; + }; + + /* Source for cache-line-size + cache-sets + * https://developer.arm.com/documentation/ddi0500 + * /e/level-2-memory-system/about-the-l2-memory-system?lang=en + * Source for cache-size + * https://datasheets.raspberrypi.com/cm/cm1-and-cm3-datasheet.pdf + */ + l2: l2-cache0 { + compatible = "cache"; + cache-size = <0x80000>; + cache-line-size = <64>; + cache-sets = <512>; // 512KiB(size)/64(line-size)=8192ways/16-way set + cache-level = <2>; }; }; };
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 743/913 ASoC: madera: Add dependencies on MFD
In reply to Greg Kroah-HartmanFrom: Charles Keepax <[email protected]>
[ Upstream commit ec29170c724ca30305fc3a19ba2ee73ecac65509 ]
The Madera CODECs use regmap_irq functions but nothing ensures that regmap_irq is built into the kernel. Add dependencies on the ASoC symbols for the relevant MFD component. There is no point in building the ASoC driver if the MFD doesn't support it and the MFD part contains the necessary dependencies to ensure everything is built into the kernel.
--- sound/soc/codecs/Kconfig | 5 +++++ 1 file changed, 5 insertions(+)
sound/soc/codecs/Kconfig +5 -0
@@ -690,6 +690,7 @@ config SND_SOC_CS4349 config SND_SOC_CS47L15 tristate + depends on MFD_CS47L15 config SND_SOC_CS47L24 tristate
@@ -697,15 +698,19 @@ config SND_SOC_CS47L24 config SND_SOC_CS47L35 tristate + depends on MFD_CS47L35 config SND_SOC_CS47L85 tristate + depends on MFD_CS47L85 config SND_SOC_CS47L90 tristate + depends on MFD_CS47L90 config SND_SOC_CS47L92 tristate + depends on MFD_CS47L92 # Cirrus Logic Quad-Channel ADC config SND_SOC_CS53L30
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 744/913 media: atomisp_gmin_platform: Add DMI quirk to not turn AXP ELDO2 regulator off on some boards
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 2c39a01154ea57d596470afa1d278e3be3b37f6a ]
The TrekStor SurfTab duo W1 10.1 has a hw bug where turning eldo2 back on after having turned it off causes the CPLM3218 ambient-light-sensor on the front camera sensor's I2C bus to crash, hanging the bus.
Add a DMI quirk table for systems on which to leave eldo2 on.
Note an alternative fix is to turn off the CPLM3218 ambient-light-sensor as long as the camera sensor is being used, this is what Windows seems to do as a workaround (based on analyzing the DSDT). But that is not easy to do cleanly under Linux.
--- .../media/atomisp/pci/atomisp_gmin_platform.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +18 -0
@@ -729,6 +729,21 @@ static int axp_regulator_set(struct device *dev, struct gmin_subdev *gs,return 0 ; } +/* +* Some boards contain a hw-bug where turning eldo2 back on after having turned +* it off causes the CPLM3218 ambient-light-sensor on the image-sensor's I2C bus +* to crash, hanging the bus. Do not turn eldo2 off on these systems. +*/ +static const struct dmi_system_id axp_leave_eldo2_on_ids[] = { + { + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"TrekStor" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"SurfTab duo W1 10.1 (VT4)" ), + }, + }, + { } +}; +static int axp_v1p8_on (struct device *dev,struct gmin_subdev *gs) {int ret;
@@ -763,6 +778,9 @@ static int axp_v1p8_off(struct device *dev, struct gmin_subdev *gs)if (ret)return ret; +if (dmi_check_system (axp_leave_eldo2_on_ids)) +return 0 ; + ret =axp_regulator_set (dev, gs, gs->eldo2_sel_reg, gs->eldo2_1p8v,ELDO_CTRL_REG , gs->eldo2_ctrl_shift, false);return ret;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 745/913 media: atomisp: fix dummy_ptr check to avoid duplicate active_bo
In reply to Greg Kroah-HartmanFrom: Tsuchiya Yuto <[email protected]>
[ Upstream commit 127efdbc51fe6064336c0452ce9c910b3e107cf0 ]
The dummy_ptr check in hmm_init() [1] results in the following "hmm_init Failed to create sysfs" error exactly once every two times on atomisp reload by rmmod/insmod (although atomisp module loads and works fine regardless of this error):
[ 140.230662] sysfs: cannot create duplicate filename '/devices/pci0000:00/0000:00:03.0/active_bo' [ 140.230668] CPU: 1 PID: 2502 Comm: insmod Tainted: G C OE 5.15.0-rc4-1-surface-mainline #1 b8acf6eb64994414b2e20bad312a7a2c45f748f9 [ 140.230675] Hardware name: OEMB OEMB/OEMB, BIOS 1.51116.238 03/09/2015 [ 140.230678] Call Trace: [ 140.230687] dump_stack_lvl+0x46/0x5a [ 140.230702] sysfs_warn_dup.cold+0x17/0x24 [ 140.230710] sysfs_add_file_mode_ns+0x160/0x170 [ 140.230717] internal_create_group+0x126/0x390 [ 140.230723] hmm_init+0x5c/0x70 [atomisp 7a6a680bf400629363d2a6f58fd10e7299678b99] [ 140.230811] atomisp_pci_probe.cold+0x1136/0x148e [atomisp 7a6a680bf400629363d2a6f58fd10e7299678b99] [ 140.230875] local_pci_probe+0x45/0x80 [ 140.230882] ? pci_match_device+0xd7/0x130 [ 140.230887] pci_device_probe+0xfa/0x1b0 [ 140.230892] really_probe+0x1f5/0x3f0 [ 140.230899] __driver_probe_device+0xfe/0x180 [ 140.230903] driver_probe_device+0x1e/0x90 [ 140.230908] __driver_attach+0xc0/0x1c0 [ 140.230912] ? __device_attach_driver+0xe0/0xe0 [ 140.230915] ? __device_attach_driver+0xe0/0xe0 [ 140.230919] bus_for_each_dev+0x89/0xd0 [ 140.230924] bus_add_driver+0x12b/0x1e0 [ 140.230929] driver_register+0x8f/0xe0 [ 140.230933] ? 0xffffffffc153f000 [ 140.230937] do_one_initcall+0x57/0x220 [ 140.230945] do_init_module+0x5c/0x260 [ 140.230952] load_module+0x24bd/0x26a0 [ 140.230962] ? __do_sys_finit_module+0xae/0x110 [ 140.230966] __do_sys_finit_module+0xae/0x110 [ 140.230972] do_syscall_64+0x5c/0x80 [ 140.230979] ? syscall_exit_to_user_mode+0x23/0x40 [ 140.230983] ? do_syscall_64+0x69/0x80 [ 140.230988] ? exc_page_fault+0x72/0x170 [ 140.230991] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 140.230997] RIP: 0033:0x7f7fd5d8718d [ 140.231003] Code: b4 0c 00 0f 05 eb a9 66 0f 1f 44 00 00 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d b3 6c 0c 00 f7 d8 64 89 01 48 [ 140.231006] RSP: 002b:00007ffefc25f0e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 [ 140.231012] RAX: ffffffffffffffda RBX: 000055ac3edcd7f0 RCX: 00007f7fd5d8718d [ 140.231015] RDX: 0000000000000000 RSI: 000055ac3d723270 RDI: 0000000000000003 [ 140.231017] RBP: 0000000000000000 R08: 0000000000000000 R09: 00007f7fd5e52380 [ 140.231019] R10: 0000000000000003 R11: 0000000000000246 R12: 000055ac3d723270 [ 140.231021] R13: 0000000000000000 R14: 000055ac3edd06e0 R15: 0000000000000000 [ 140.231038] atomisp-isp2 0000:00:03.0: hmm_init Failed to create sysfs
The problem is that dummy_ptr == 0 is a valid value. So, change the logic which checks if dummy_ptr was allocated.
At this point, atomisp now gives WARN_ON() in hmm_free() [2] on atomisp reload by rmmod/insmod. Again, the check is wrong there.
So, change both checks for mmgr_EXCEPTION, which is the error value when HMM allocation fails, and initialize dummy_ptr with such value.
[1] added on commit
d9ab83953fa7 ("media: atomisp: don't cause a warn if probe failed")
[2] added on commit
b83cc378dfc4 ("atomisp: clean up the hmm init/cleanup indirections")
--- drivers/staging/media/atomisp/pci/hmm/hmm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/media/atomisp/pci/hmm/hmm.c +4 -3
@@ -39,7 +39,7 @@struct hmm_bo_device bo_device;struct hmm_pool dynamic_pool;struct hmm_pool reserved_pool; -static ia_css_ptr dummy_ptr; +static ia_css_ptr dummy_ptr = mmgr_EXCEPTION;static bool hmm_initialized;struct _hmm_mem_stat hmm_mem_stat;
@@ -209,7 +209,7 @@ int hmm_init(void)void hmm_cleanup (void ) { -if (!dummy_ptr) +if (dummy_ptr == mmgr_EXCEPTION)return ;sysfs_remove_group (&atomisp_dev->kobj, atomisp_attribute_group);
@@ -288,7 +288,8 @@ void hmm_free(ia_css_ptr virt)dev_dbg (atomisp_dev,"%s: free 0x%08x\n" , __func__, virt); -WARN_ON (!virt); +if (WARN_ON (virt == mmgr_EXCEPTION)) +return ; bo =hmm_bo_device_search_start (&bo_device, (unsigned int )virt);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 746/913 ARM: ftrace: avoid redundant loads or clobbering IP
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit d11967870815b5ab89843980e35aab616c97c463 ]
Tweak the ftrace return paths to avoid redundant loads of SP, as well as unnecessary clobbering of IP.
This also fixes the inconsistency of using MOV to perform a function return, which is sub-optimal on recent micro-architectures but more importantly, does not perform an interworking return, unlike compiler generated function returns in Thumb2 builds.
Let's fix this by popping PC from the stack like most ordinary code does.
--- arch/arm/kernel/entry-ftrace.S | 51 +++++++++++++++------------------- 1 file changed, 22 insertions(+), 29 deletions(-)
arch/arm/kernel/entry-ftrace.S +22 -29
@@ -22,10 +22,7 @@ * mcount can be thought of as a function called in the middle of a subroutine * call. As such, it needs to be transparent for both the caller and the * callee: the original lr needs to be restored when leaving mcount, and no - * registers should be clobbered. (In the __gnu_mcount_nc implementation, we - * clobber the ip register. This is OK because the ARM calling convention - * allows it to be clobbered in subroutines and doesn't use it to hold - * parameters.) + * registers should be clobbered. * * When using dynamic ftrace, we patch out the mcount call by a "pop {lr}" * instead of the __gnu_mcount_nc call (see arch/arm/kernel/ftrace.c).
@@ -70,26 +67,25 @@ .macro __ftrace_regs_caller - sub sp, sp, #8 @ space for PC and CPSR OLD_R0, + str lr, [sp, #-8]! @ store LR as PC and make space for CPSR/OLD_R0, @ OLD_R0 will overwrite previous LR - add ip, sp, #12 @ move in IP the value of SP as it was - @ before the push {lr} of the mcount mechanism + ldr lr, [sp, #8] @ get previous LR - str lr, [sp, #0] @ store LR instead of PC + str r0, [sp, #8] @ write r0 as OLD_R0 over previous LR - ldr lr, [sp, #8] @ get previous LR + str lr, [sp, #-4]! @ store previous LR as LR - str r0, [sp, #8] @ write r0 as OLD_R0 over previous LR + add lr, sp, #16 @ move in LR the value of SP as it was + @ before the push {lr} of the mcount mechanism - stmdb sp!, {ip, lr} - stmdb sp!, {r0-r11, lr} + push {r0-r11, ip, lr} @ stack content at this point: @ 0 4 48 52 56 60 64 68 72 - @ R0 | R1 | ... | LR | SP + 4 | previous LR | LR | PSR | OLD_R0 | + @ R0 | R1 | ... | IP | SP + 4 | previous LR | LR | PSR | OLD_R0 | - mov r3, sp @ struct pt_regs* + mov r3, sp @ struct pt_regs* ldr r2, =function_trace_op ldr r2, [r2] @ pointer to the current
@@ -112,11 +108,9 @@ ftrace_graph_regs_call: #endif @ pop saved regs - ldmia sp!, {r0-r12} @ restore r0 through r12 - ldr ip, [sp, #8] @ restore PC - ldr lr, [sp, #4] @ restore LR - ldr sp, [sp, #0] @ restore SP - mov pc, ip @ return + pop {r0-r11, ip, lr} @ restore r0 through r12 + ldr lr, [sp], #4 @ restore LR + ldr pc, [sp], #12 .endm #ifdef CONFIG_FUNCTION_GRAPH_TRACER
@@ -132,11 +126,9 @@ ftrace_graph_regs_call: bl prepare_ftrace_return @ pop registers saved in ftrace_regs_caller - ldmia sp!, {r0-r12} @ restore r0 through r12 - ldr ip, [sp, #8] @ restore PC - ldr lr, [sp, #4] @ restore LR - ldr sp, [sp, #0] @ restore SP - mov pc, ip @ return + pop {r0-r11, ip, lr} @ restore r0 through r12 + ldr lr, [sp], #4 @ restore LR + ldr pc, [sp], #12 .endm #endif
@@ -202,16 +194,17 @@ ftrace_graph_call\suffix: .endm .macro mcount_exit - ldmia sp!, {r0-r3, ip, lr} - ret ip + ldmia sp!, {r0-r3} + ldr lr, [sp, #4] + ldr pc, [sp], #8 .endm ENTRY(__gnu_mcount_nc) UNWIND(.fnstart) #ifdef CONFIG_DYNAMIC_FTRACE - mov ip, lr - ldmia sp!, {lr} - ret ip + push {lr} + ldr lr, [sp, #4] + ldr pc, [sp], #8 #else __mcount #endif
Signature · 1 line
2.34.1
Re: [PATCH 5.15 746/913] ARM: ftrace: avoid redundant loads or clobbering IP
Quoted 13 lines · Greg Kroah-Hartman
From: Ard Biesheuvel <[email protected]>
[ Upstream commit
d11967870815b5ab89843980e35aab616c97c463]Tweak the ftrace return paths to avoid redundant loads of SP, as well as unnecessary clobbering of IP.
This also fixes the inconsistency of using MOV to perform a function return, which is sub-optimal on recent micro-architectures but more importantly, does not perform an interworking return, unlike compiler generated function returns in Thumb2 builds.
Quoted 6 lines
Let's fix this by popping PC from the stack like most ordinary code does.
Signed-off-by Ard Biesheuvel <[email protected]>Reviewed-by Steven Rostedt (Google) <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Please drop all the 32-bit ARM patches authored by me from the stable queues except the ones that have fixes tags. These are highly likely to cause an explosion of regressions, and they should have never been selected, as I don't remember anyone proposing these for stable.
Quoted 114 lines
--- arch/arm/kernel/entry-ftrace.S | 51 +++++++++++++++------------------- 1 file changed, 22 insertions(+), 29 deletions(-)arch/arm/kernel/entry-ftrace.S +22
-30@@ -22,10 +22,7 @@ * mcount can be thought of as a function called in the middle of a subroutine * call. As such, it needs to be transparent for both the caller and the * callee: the original lr needs to be restored when leaving mcount, and no - * registers should be clobbered. (In the __gnu_mcount_nc implementation, we - * clobber the ip register. This is OK because the ARM calling convention - * allows it to be clobbered in subroutines and doesn't use it to hold - * parameters.) + * registers should be clobbered. * * When using dynamic ftrace, we patch out the mcount call by a "pop {lr}" * instead of the __gnu_mcount_nc call (see arch/arm/kernel/ftrace.c).@@ -70,26 +67,25 @@ .macro __ftrace_regs_caller - sub sp, sp, #8 @ space for PC and CPSR OLD_R0, + str lr, [sp, #-8]! @ store LR as PC and make space for CPSR/OLD_R0, @ OLD_R0 will overwrite previous LR - add ip, sp, #12 @ move in IP the value of SP as it was - @ before the push {lr} of the mcount mechanism + ldr lr, [sp, #8] @ get previous LR - str lr, [sp, #0] @ store LR instead of PC + str r0, [sp, #8] @ write r0 as OLD_R0 over previous LR - ldr lr, [sp, #8] @ get previous LR + str lr, [sp, #-4]! @ store previous LR as LR - str r0, [sp, #8] @ write r0 as OLD_R0 over previous LR + add lr, sp, #16 @ move in LR the value of SP as it was + @ before the push {lr} of the mcount mechanism - stmdb sp!, {ip, lr} - stmdb sp!, {r0-r11, lr} + push {r0-r11, ip, lr} @ stack content at this point: @ 0 4 48 52 56 60 64 68 72 - @ R0 | R1 | ... | LR | SP + 4 | previous LR | LR | PSR | OLD_R0 | + @ R0 | R1 | ... | IP | SP + 4 | previous LR | LR | PSR | OLD_R0 | - mov r3, sp @ struct pt_regs* + mov r3, sp @ struct pt_regs* ldr r2, =function_trace_op ldr r2, [r2] @ pointer to the current@@ -112,11 +108,9 @@ ftrace_graph_regs_call: #endif @ pop saved regs - ldmia sp!, {r0-r12} @ restore r0 through r12 - ldr ip, [sp, #8] @ restore PC - ldr lr, [sp, #4] @ restore LR - ldr sp, [sp, #0] @ restore SP - mov pc, ip @ return + pop {r0-r11, ip, lr} @ restore r0 through r12 + ldr lr, [sp], #4 @ restore LR + ldr pc, [sp], #12 .endm #ifdef CONFIG_FUNCTION_GRAPH_TRACER@@ -132,11 +126,9 @@ ftrace_graph_regs_call: bl prepare_ftrace_return @ pop registers saved in ftrace_regs_caller - ldmia sp!, {r0-r12} @ restore r0 through r12 - ldr ip, [sp, #8] @ restore PC - ldr lr, [sp, #4] @ restore LR - ldr sp, [sp, #0] @ restore SP - mov pc, ip @ return + pop {r0-r11, ip, lr} @ restore r0 through r12 + ldr lr, [sp], #4 @ restore LR + ldr pc, [sp], #12 .endm #endif@@ -202,16 +194,17 @@ ftrace_graph_call\suffix: .endm .macro mcount_exit - ldmia sp!, {r0-r3, ip, lr} - ret ip + ldmia sp!, {r0-r3} + ldr lr, [sp, #4] + ldr pc, [sp], #8 .endm ENTRY(__gnu_mcount_nc) UNWIND(.fnstart) #ifdef CONFIG_DYNAMIC_FTRACE - mov ip, lr - ldmia sp!, {lr} - ret ip + push {lr} + ldr lr, [sp, #4] + ldr pc, [sp], #8 #else __mcount #endif --2.34.1
Greg Kroah-Hartman
maintainerRe: [PATCH 5.15 746/913] ARM: ftrace: avoid redundant loads or clobbering IP
Quoted 18 lines · Ard Biesheuvel
Quoted 16 lines · Greg Kroah-Hartman
From: Ard Biesheuvel <[email protected]>
[ Upstream commit
d11967870815b5ab89843980e35aab616c97c463]Tweak the ftrace return paths to avoid redundant loads of SP, as well as unnecessary clobbering of IP.
This also fixes the inconsistency of using MOV to perform a function return, which is sub-optimal on recent micro-architectures but more importantly, does not perform an interworking return, unlike compiler generated function returns in Thumb2 builds.
Let's fix this by popping PC from the stack like most ordinary code does.
Quoted 8 lines
Quoted 3 lines
Signed-off-by Ard Biesheuvel <[email protected]>Reviewed-by Steven Rostedt (Google) <[email protected]>Signed-off-by Sasha Levin <[email protected]>Please drop all the 32-bit ARM patches authored by me from the stable queues except the ones that have fixes tags. These are highly likely to cause an explosion of regressions, and they should have never been selected, as I don't remember anyone proposing these for stable.
From what I can tell, that is only this commit. I'll go drop it from all trees, thanks.
greg k-h
Re: [PATCH 5.15 746/913] ARM: ftrace: avoid redundant loads or clobbering IP
Quoted 24 lines · Greg Kroah-Hartman
Quoted 22 lines · Ard Biesheuvel
Quoted 19 lines · Greg Kroah-Hartman
From: Ard Biesheuvel <[email protected]>
[ Upstream commit
d11967870815b5ab89843980e35aab616c97c463]Tweak the ftrace return paths to avoid redundant loads of SP, as well as unnecessary clobbering of IP.
This also fixes the inconsistency of using MOV to perform a function return, which is sub-optimal on recent micro-architectures but more importantly, does not perform an interworking return, unlike compiler generated function returns in Thumb2 builds.
Let's fix this by popping PC from the stack like most ordinary code does.
Signed-off-by Ard Biesheuvel <[email protected]>Reviewed-by Steven Rostedt (Google) <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Quoted 8 lines
Quoted 4 lines
Please drop all the 32-bit ARM patches authored by me from the stable queues except the ones that have fixes tags. These are highly likely to cause an explosion of regressions, and they should have never been selected, as I don't remember anyone proposing these for stable.
From what I can tell, that is only this commit. I'll go drop it from all trees, thanks.
Ah ok, that's not so bad then. But still better to avoid it.
Sasha Levin
maintainerRe: [PATCH 5.15 746/913] ARM: ftrace: avoid redundant loads or clobbering IP
In reply to Ard BiesheuvelQuoted 18 lines · Ard Biesheuvel
Quoted 16 lines · Greg Kroah-Hartman
From: Ard Biesheuvel <[email protected]>
[ Upstream commit
d11967870815b5ab89843980e35aab616c97c463]Tweak the ftrace return paths to avoid redundant loads of SP, as well as unnecessary clobbering of IP.
This also fixes the inconsistency of using MOV to perform a function return, which is sub-optimal on recent micro-architectures but more importantly, does not perform an interworking return, unlike compiler generated function returns in Thumb2 builds.
Let's fix this by popping PC from the stack like most ordinary code does.
Quoted 6 lines
Quoted 3 lines
Signed-off-by Ard Biesheuvel <[email protected]>Reviewed-by Steven Rostedt (Google) <[email protected]>Signed-off-by Sasha Levin <[email protected]>Please drop all the 32-bit ARM patches authored by me from the stable queues except the ones that have fixes tags. These are highly likely
I can drop you from future selections as well.
Quoted 2 lines
to cause an explosion of regressions, and they should have never been selected, as I don't remember anyone proposing these for stable.
They were proposed by the bot last week
(https://lore.kernel.org/lkml/[email protected]/).
Signature · 2 lines
Thanks, Sasha
Re: [PATCH 5.15 746/913] ARM: ftrace: avoid redundant loads or clobbering IP
Quoted 20 lines · Sasha Levin
Quoted 18 lines · Ard Biesheuvel
Quoted 16 lines · Greg Kroah-Hartman
From: Ard Biesheuvel <[email protected]>
[ Upstream commit
d11967870815b5ab89843980e35aab616c97c463]Tweak the ftrace return paths to avoid redundant loads of SP, as well as unnecessary clobbering of IP.
This also fixes the inconsistency of using MOV to perform a function return, which is sub-optimal on recent micro-architectures but more importantly, does not perform an interworking return, unlike compiler generated function returns in Thumb2 builds.
Let's fix this by popping PC from the stack like most ordinary code does.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Signed-off-by Ard Biesheuvel <[email protected]>Reviewed-by Steven Rostedt (Google) <[email protected]>Signed-off-by Sasha Levin <[email protected]>Please drop all the 32-bit ARM patches authored by me from the stable queues except the ones that have fixes tags. These are highly likely
I can drop you from future selections as well.
Yes, please. Just disregard all of my patches, unless they have a fixes or cc:stable, or someone suggests them explicitly.
Quoted 6 lines
Quoted 2 lines
to cause an explosion of regressions, and they should have never been selected, as I don't remember anyone proposing these for stable.
They were proposed by the bot last week
(https://lore.kernel.org/lkml/[email protected]/).
Yeah, we should really not be using a bot for that.
Greg Kroah-Hartman
maintainerPATCH 747/913 ARM: dts: imx7: Use audio_mclk_post_div instead audio_mclk_root_clk
In reply to Greg Kroah-HartmanFrom: Abel Vesa <[email protected]>
[ Upstream commit 4cb7df64c732b2b9918424095c11660c2a8c4a33 ]
The audio_mclk_root_clk was added as a gate with the CCGR121 (0x4790), but according to the reference manual, there is no such gate. Moreover, the consumer driver of the mentioned clock might gate it and leave the ECSPI2 (the true owner of that gate) hanging. So lets use the audio_mclk_post_div, which is the parent.
--- arch/arm/boot/dts/imx7-colibri.dtsi | 4 ++-- arch/arm/boot/dts/imx7-mba7.dtsi | 2 +- arch/arm/boot/dts/imx7d-nitrogen7.dts | 2 +- arch/arm/boot/dts/imx7d-pico-hobbit.dts | 4 ++-- arch/arm/boot/dts/imx7d-pico-pi.dts | 4 ++-- arch/arm/boot/dts/imx7d-sdb.dts | 4 ++-- arch/arm/boot/dts/imx7s-warp.dts | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-)
arch/arm/boot/dts/imx7-colibri.dtsi +2 -2
@@ -40,7 +40,7 @@ dailink_master: simple-audio-card,codec { sound-dai = <&codec>; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; }; }; };
@@ -293,7 +293,7 @@ compatible = "fsl,sgtl5000"; #sound-dai-cells = <0>; reg = <0x0a>; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_sai1_mclk>; VDDA-supply = <®_module_3v3_avdd>;
arch/arm/boot/dts/imx7-mba7.dtsi +1 -1
@@ -264,7 +264,7 @@ tlv320aic32x4: audio-codec@18 { compatible = "ti,tlv320aic32x4"; reg = <0x18>; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; clock-names = "mclk"; ldoin-supply = <®_audio_3v3>; iov-supply = <®_audio_3v3>;
arch/arm/boot/dts/imx7d-nitrogen7.dts +1 -1
@@ -288,7 +288,7 @@ codec: wm8960@1a { compatible = "wlf,wm8960"; reg = <0x1a>; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; clock-names = "mclk"; wlf,shared-lrclk; };
arch/arm/boot/dts/imx7d-pico-hobbit.dts +2 -2
@@ -31,7 +31,7 @@ dailink_master: simple-audio-card,codec { sound-dai = <&sgtl5000>; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; }; }; };
@@ -41,7 +41,7 @@ #sound-dai-cells = <0>; reg = <0x0a>; compatible = "fsl,sgtl5000"; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; VDDA-supply = <®_2p5v>; VDDIO-supply = <®_vref_1v8>; };
arch/arm/boot/dts/imx7d-pico-pi.dts +2 -2
@@ -31,7 +31,7 @@ dailink_master: simple-audio-card,codec { sound-dai = <&sgtl5000>; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; }; }; };
@@ -41,7 +41,7 @@ #sound-dai-cells = <0>; reg = <0x0a>; compatible = "fsl,sgtl5000"; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; VDDA-supply = <®_2p5v>; VDDIO-supply = <®_vref_1v8>; };
arch/arm/boot/dts/imx7d-sdb.dts +2 -2
@@ -385,14 +385,14 @@ codec: wm8960@1a { compatible = "wlf,wm8960"; reg = <0x1a>; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; clock-names = "mclk"; wlf,shared-lrclk; wlf,hp-cfg = <2 2 3>; wlf,gpio-cfg = <1 3>; assigned-clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_SRC>, <&clks IMX7D_PLL_AUDIO_POST_DIV>, - <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; assigned-clock-parents = <&clks IMX7D_PLL_AUDIO_POST_DIV>; assigned-clock-rates = <0>, <884736000>, <12288000>; };
arch/arm/boot/dts/imx7s-warp.dts +2 -2
@@ -75,7 +75,7 @@ dailink_master: simple-audio-card,codec { sound-dai = <&codec>; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; }; }; };
@@ -232,7 +232,7 @@ #sound-dai-cells = <0>; reg = <0x0a>; compatible = "fsl,sgtl5000"; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_sai1_mclk>; VDDA-supply = <&vgen4_reg>;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 748/913 arm64: defconfig: build imx-sdma as a module
In reply to Greg Kroah-HartmanFrom: Marcel Ziswiler <[email protected]>
[ Upstream commit e95622289f263662240544a9f0009b25c19e64d4 ]
This avoids firmware load error and sysfs fallback reported as follows:
[ 0.199448] imx-sdma 302c0000.dma-controller: Direct firmware load for imx/sdma/sdma-imx7d.bin failed with error -2 [ 0.199487] imx-sdma 302c0000.dma-controller: Falling back to sysfs fallback for: imx/sdma/sdma-imx7d.bin
--- arch/arm64/configs/defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/configs/defconfig +1 -1
@@ -921,7 +921,7 @@ CONFIG_DMADEVICES=y CONFIG_DMA_BCM2835=y CONFIG_DMA_SUN6I=m CONFIG_FSL_EDMA=y -CONFIG_IMX_SDMA=y +CONFIG_IMX_SDMA=m CONFIG_K3_DMA=y CONFIG_MV_XOR=y CONFIG_MV_XOR_V2=y
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 749/913 video: fbdev: omapfb: panel-dsi-cm: Use sysfs_emit() instead of snprintf()
In reply to Greg Kroah-HartmanFrom: Jing Yao <[email protected]>
[ Upstream commit f63658a59c3d439c8ad7b290f8ec270980e0f384 ]
Use sysfs_emit instead of scnprintf, snprintf or sprintf.
--- drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c +4 -4
@@ -409,7 +409,7 @@ static ssize_t dsicm_num_errors_show(struct device *dev,if (r)return r; -return snprintf (buf,PAGE_SIZE ,"%d\n" , errors); +return sysfs_emit (buf,"%d\n" , errors); } static ssize_t dsicm_hw_revision_show(struct device *dev,
@@ -439,7 +439,7 @@ static ssize_t dsicm_hw_revision_show(struct device *dev,if (r)return r; -return snprintf (buf,PAGE_SIZE ,"%02x.%02x.%02x\n" , id1, id2, id3); +return sysfs_emit (buf,"%02x.%02x.%02x\n" , id1, id2, id3); } static ssize_t dsicm_store_ulps(struct device *dev,
@@ -487,7 +487,7 @@ static ssize_t dsicm_show_ulps(struct device *dev, t = ddata->ulps_enabled;mutex_unlock (&ddata->lock); -return snprintf (buf,PAGE_SIZE ,"%u\n" , t); +return sysfs_emit (buf,"%u\n" , t); } static ssize_t dsicm_store_ulps_timeout(struct device *dev,
@@ -532,7 +532,7 @@ static ssize_t dsicm_show_ulps_timeout(struct device *dev, t = ddata->ulps_timeout;mutex_unlock (&ddata->lock); -return snprintf (buf,PAGE_SIZE ,"%u\n" , t); +return sysfs_emit (buf,"%u\n" , t); } static DEVICE_ATTR(num_dsi_errors, S_IRUGO, dsicm_num_errors_show, NULL);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 750/913 video: fbdev: omapfb: panel-tpo-td043mtea1: Use sysfs_emit() instead of snprintf()
In reply to Greg Kroah-HartmanFrom: Jing Yao <[email protected]>
[ Upstream commit c07a039cbb96748f54c02995bae8131cc9a73b0a ]
Use sysfs_emit instead of scnprintf, snprintf or sprintf.
--- .../video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c +2 -2
@@ -169,7 +169,7 @@ static ssize_t tpo_td043_vmirror_show(struct device *dev, {struct panel_drv_data *ddata =dev_get_drvdata (dev); -return snprintf (buf,PAGE_SIZE ,"%d\n" , ddata->vmirror); +return sysfs_emit (buf,"%d\n" , ddata->vmirror); } static ssize_t tpo_td043_vmirror_store(struct device *dev,
@@ -199,7 +199,7 @@ static ssize_t tpo_td043_mode_show(struct device *dev, {struct panel_drv_data *ddata =dev_get_drvdata (dev); -return snprintf (buf,PAGE_SIZE ,"%d\n" , ddata->mode); +return sysfs_emit (buf,"%d\n" , ddata->mode); } static ssize_t tpo_td043_mode_store(struct device *dev,
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 751/913 video: fbdev: udlfb: replace snprintf in show functions with sysfs_emit
In reply to Greg Kroah-HartmanFrom: Jing Yao <[email protected]>
[ Upstream commit 81a998288956d09d7a7a2303d47e4d60ad55c401 ]
Use sysfs_emit instead of scnprintf, snprintf or sprintf.
--- drivers/video/fbdev/udlfb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/video/fbdev/udlfb.c +4 -4
@@ -1426,7 +1426,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev, struct device_attribute *a, char *buf) { struct fb_info *fb_info = dev_get_drvdata(fbdev);struct dlfb_data *dlfb = fb_info->par; -return snprintf (buf,PAGE_SIZE ,"%u\n" , +return sysfs_emit (buf,"%u\n" ,atomic_read (&dlfb->bytes_rendered)); }
@@ -1434,7 +1434,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev, struct device_attribute *a, char *buf) { struct fb_info *fb_info = dev_get_drvdata(fbdev);struct dlfb_data *dlfb = fb_info->par; -return snprintf (buf,PAGE_SIZE ,"%u\n" , +return sysfs_emit (buf,"%u\n" ,atomic_read (&dlfb->bytes_identical)); }
@@ -1442,7 +1442,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev, struct device_attribute *a, char *buf) { struct fb_info *fb_info = dev_get_drvdata(fbdev);struct dlfb_data *dlfb = fb_info->par; -return snprintf (buf,PAGE_SIZE ,"%u\n" , +return sysfs_emit (buf,"%u\n" ,atomic_read (&dlfb->bytes_sent)); }
@@ -1450,7 +1450,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev, struct device_attribute *a, char *buf) { struct fb_info *fb_info = dev_get_drvdata(fbdev);struct dlfb_data *dlfb = fb_info->par; -return snprintf (buf,PAGE_SIZE ,"%u\n" , +return sysfs_emit (buf,"%u\n" ,atomic_read (&dlfb->cpu_kcycles_used)); }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 752/913 ARM: dts: bcm2711: Add the missing L1/L2 cache information
In reply to Greg Kroah-HartmanFrom: Richard Schleich <[email protected]>
[ Upstream commit 618682b350990f8f1bee718949c4b3858711eb58 ]
This patch fixes the kernel warning "cacheinfo: Unable to detect cache hierarchy for CPU 0" for the bcm2711 on newer kernel versions.
--- arch/arm/boot/dts/bcm2711.dtsi | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
arch/arm/boot/dts/bcm2711.dtsi +50 -0
@@ -459,12 +459,26 @@ #size-cells = <0>; enable-method = "brcm,bcm2836-smp"; // for ARM 32-bit + /* Source for d/i-cache-line-size and d/i-cache-sets + * https://developer.arm.com/documentation/100095/0003 + * /Level-1-Memory-System/About-the-L1-memory-system?lang=en + * Source for d/i-cache-size + * https://www.raspberrypi.com/documentation/computers + * /processors.html#bcm2711 + */ cpu0: cpu@0 { device_type = "cpu"; compatible = "arm,cortex-a72"; reg = <0>; enable-method = "spin-table"; cpu-release-addr = <0x0 0x000000d8>; + d-cache-size = <0x8000>; + d-cache-line-size = <64>; + d-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set + i-cache-size = <0xc000>; + i-cache-line-size = <64>; + i-cache-sets = <256>; // 48KiB(size)/64(line-size)=768ways/3-way set + next-level-cache = <&l2>; }; cpu1: cpu@1 {
@@ -473,6 +487,13 @@ reg = <1>; enable-method = "spin-table"; cpu-release-addr = <0x0 0x000000e0>; + d-cache-size = <0x8000>; + d-cache-line-size = <64>; + d-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set + i-cache-size = <0xc000>; + i-cache-line-size = <64>; + i-cache-sets = <256>; // 48KiB(size)/64(line-size)=768ways/3-way set + next-level-cache = <&l2>; }; cpu2: cpu@2 {
@@ -481,6 +502,13 @@ reg = <2>; enable-method = "spin-table"; cpu-release-addr = <0x0 0x000000e8>; + d-cache-size = <0x8000>; + d-cache-line-size = <64>; + d-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set + i-cache-size = <0xc000>; + i-cache-line-size = <64>; + i-cache-sets = <256>; // 48KiB(size)/64(line-size)=768ways/3-way set + next-level-cache = <&l2>; }; cpu3: cpu@3 {
@@ -489,6 +517,28 @@ reg = <3>; enable-method = "spin-table"; cpu-release-addr = <0x0 0x000000f0>; + d-cache-size = <0x8000>; + d-cache-line-size = <64>; + d-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set + i-cache-size = <0xc000>; + i-cache-line-size = <64>; + i-cache-sets = <256>; // 48KiB(size)/64(line-size)=768ways/3-way set + next-level-cache = <&l2>; + }; + + /* Source for d/i-cache-line-size and d/i-cache-sets + * https://developer.arm.com/documentation/100095/0003 + * /Level-2-Memory-System/About-the-L2-memory-system?lang=en + * Source for d/i-cache-size + * https://www.raspberrypi.com/documentation/computers + * /processors.html#bcm2711 + */ + l2: l2-cache0 { + compatible = "cache"; + cache-size = <0x100000>; + cache-line-size = <64>; + cache-sets = <1024>; // 1MiB(size)/64(line-size)=16384ways/16-way set + cache-level = <2>; }; };
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 753/913 ASoC: soc-core: skip zero num_dai component in searching dai name
In reply to Greg Kroah-HartmanFrom: Shengjiu Wang <[email protected]>
[ Upstream commit f7d344a2bd5ec81fbd1ce76928fd059e57ec9bea ]
In the case like dmaengine which's not a dai but as a component, the num_dai is zero, dmaengine component has the same component_of_node as cpu dai, when cpu dai component is not ready, but dmaengine component is ready, try to get cpu dai name, the snd_soc_get_dai_name() return -EINVAL, not -EPROBE_DEFER, that cause below error:
asoc-simple-card <card name>: parse error -22
asoc-simple-card: probe of <card name> failed with error -22
The sound card failed to probe.
So this patch fixes the issue above by skipping the zero num_dai component in searching dai name.
--- sound/soc/soc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/soc-core.c +1 -1
@@ -3208,7 +3208,7 @@ int snd_soc_get_dai_name(const struct of_phandle_args *args,for_each_component (pos) {struct device_node *component_of_node =soc_component_to_node (pos); -if (component_of_node != args->np) +if (component_of_node != args->np || !pos->num_dai)continue ; ret =snd_soc_component_of_xlate_dai_name (pos, args, dai_name);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 754/913 media: imx-jpeg: fix a bug of accessing array out of bounds
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 97558d170a1236280407e8d29a7d095d2c2ed554 ]
When error occurs in parsing jpeg, the slot isn't acquired yet, it may be the default value MXC_MAX_SLOTS.
If the driver access the slot using the incorrect slot number, it will access array out of bounds.
The result is the driver will change num_domains, which follows slot_data in struct mxc_jpeg_dev.
Then the driver won't detach the pm domain at rmmod, which will lead to kernel panic when trying to insmod again.
--- drivers/media/platform/imx-jpeg/mxc-jpeg.c | 1 - 1 file changed, 1 deletion(-)
drivers/media/platform/imx-jpeg/mxc-jpeg.c +0 -1
@@ -932,7 +932,6 @@ static void mxc_jpeg_device_run(void *priv) jpeg_src_buf->jpeg_parse_error = true; }if (jpeg_src_buf->jpeg_parse_error) { - jpeg->slot_data[ctx->slot].used = false;v4l2_m2m_src_buf_remove (ctx->fh.m2m_ctx);v4l2_m2m_dst_buf_remove (ctx->fh.m2m_ctx);v4l2_m2m_buf_done (src_buf,VB2_BUF_STATE_ERROR );
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 755/913 media: cx88-mpeg: clear interrupt status register before streaming video
In reply to Greg Kroah-HartmanFrom: Daniel González Cabanelas <[email protected]>
[ Upstream commit 56cb61f70e547e1b0cdfe6ff5a1f1ce6242e6d96 ]
Some cx88 video cards may have transport stream status interrupts set to 1 from cold start, causing errors like this:
cx88xx: cx88_print_irqbits: core:irq mpeg [0x100000] ts_err?*
cx8802: cx8802_mpeg_irq: mpeg:general errors: 0x00100000
According to CX2388x datasheet, the interrupt status register should be cleared before enabling IRQs to stream video.
Fix it by clearing the Transport Stream Interrupt Status register.
--- drivers/media/pci/cx88/cx88-mpeg.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/pci/cx88/cx88-mpeg.c +3 -0
@@ -162,6 +162,9 @@ int cx8802_start_dma(struct cx8802_dev *dev,cx_write (MO_TS_GPCNTRL ,GP_COUNT_CONTROL_RESET ); q->count =0 ; +/* clear interrupt status register */ +cx_write (MO_TS_INTSTAT ,0x1f1111 ); +/* enable irqs */ dprintk (1 ,"setting the interrupt mask\n" );cx_set (MO_PCI_INTMSK , core->pci_irqmask |PCI_INT_TSINT );
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 756/913 uaccess: fix type mismatch warnings from access_ok()
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 23fc539e81295b14b50c6ccc5baeb4f3d59d822d ]
On some architectures, access_ok() does not do any argument type checking, so replacing the definition with a generic one causes a few warnings for harmless issues that were never caught before.
Fix the ones that I found either through my own test builds or that were reported by the 0-day bot.
--- arch/arc/kernel/process.c | 2 +- arch/arm/kernel/swp_emulate.c | 2 +- arch/arm/kernel/traps.c | 2 +- arch/csky/kernel/perf_callchain.c | 2 +- arch/csky/kernel/signal.c | 2 +- arch/nios2/kernel/signal.c | 20 +++++++++++--------- arch/powerpc/lib/sstep.c | 4 ++-- arch/riscv/kernel/perf_callchain.c | 4 ++-- arch/sparc/kernel/signal_32.c | 2 +- lib/test_lockup.c | 4 ++-- 10 files changed, 23 insertions(+), 21 deletions(-)
arch/arc/kernel/process.c +1 -1
@@ -43,7 +43,7 @@ SYSCALL_DEFINE0(arc_gettls)return task_thread_info (current)->thr_ptr; } -SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new) +SYSCALL_DEFINE3(arc_usr_cmpxchg, int __user *, uaddr, int, expected, int, new) {struct pt_regs *regs =current_pt_regs ();u32 uval;
arch/arm/kernel/swp_emulate.c +1 -1
@@ -195,7 +195,7 @@ static int swp_handler(struct pt_regs *regs, unsigned int instr) destreg, EXTRACT_REG_NUM(instr, RT2_OFFSET), data);/* Check access in reasonable access range for both SWP and SWPB */ -if (!access_ok ((address & ~3 ),4 )) { +if (!access_ok ((void __user *)(address & ~3 ),4 )) {pr_debug ("SWP{B} emulation: access to %p not allowed!\n" , (void *)address); res = -EFAULT ;
arch/arm/kernel/traps.c +1 -1
@@ -575,7 +575,7 @@ do_cache_op(unsigned long start, unsigned long end, int flags)if (end < start || flags)return -EINVAL ; -if (!access_ok (start, end - start)) +if (!access_ok ((void __user *)start, end - start))return -EFAULT ;return __do_cache_op (start, end);
arch/csky/kernel/perf_callchain.c +1 -1
@@ -49,7 +49,7 @@ static unsigned long user_backtrace(struct perf_callchain_entry_ctx *entry, {struct stackframe buftail;unsigned long lr =0 ; -unsigned long *user_frame_tail = (unsigned long *)fp; +unsigned long __user *user_frame_tail = (unsigned long __user *)fp;/* Check accessibility of one struct frame_tail beyond */ if (!access_ok (user_frame_tail,sizeof (buftail)))
arch/csky/kernel/signal.c +1 -1
@@ -136,7 +136,7 @@ static inline void __user *get_sigframe(struct ksignal *ksig,static int setup_rt_frame (struct ksignal *ksig,sigset_t *set,struct pt_regs *regs) { -struct rt_sigframe *frame; +struct rt_sigframe __user *frame;int err =0 ; frame =get_sigframe (ksig, regs,sizeof (*frame));
arch/nios2/kernel/signal.c +11 -9
@@ -36,10 +36,10 @@ struct rt_sigframe {static inline int rt_restore_ucontext (struct pt_regs *regs,struct switch_stack *sw, -struct ucontext *uc,int *pr2) +struct ucontext __user *uc,int *pr2) {int temp; -unsigned long *gregs = uc->uc_mcontext.gregs; +unsigned long __user *gregs = uc->uc_mcontext.gregs;int err;/* Always make any pending restarted system calls return -EINTR */
@@ -102,10 +102,11 @@ asmlinkage int do_rt_sigreturn(struct switch_stack *sw) {struct pt_regs *regs = (struct pt_regs *)(sw +1 );/* Verify, can we follow the stack back */ -struct rt_sigframe *frame = (struct rt_sigframe *) regs->sp; +struct rt_sigframe __user *frame;sigset_t set;int rval; + frame = (struct rt_sigframe __user *) regs->sp;if (!access_ok (frame,sizeof (*frame))) goto badframe;
@@ -124,10 +125,10 @@ asmlinkage int do_rt_sigreturn(struct switch_stack *sw)return 0 ; } -static inline int rt_setup_ucontext (struct ucontext *uc,struct pt_regs *regs) +static inline int rt_setup_ucontext (struct ucontext __user *uc,struct pt_regs *regs) {struct switch_stack *sw = (struct switch_stack *)regs -1 ; -unsigned long *gregs = uc->uc_mcontext.gregs; +unsigned long __user *gregs = uc->uc_mcontext.gregs;int err =0 ; err |=__put_user (MCONTEXT_VERSION , &uc->uc_mcontext.version);
@@ -162,8 +163,9 @@ static inline int rt_setup_ucontext(struct ucontext *uc, struct pt_regs *regs)return err; } -static inline void *get_sigframe (struct ksignal *ksig,struct pt_regs *regs, -size_t frame_size) +static inline void __user *get_sigframe (struct ksignal *ksig, +struct pt_regs *regs, +size_t frame_size) {unsigned long usp;
@@ -174,13 +176,13 @@ static inline void *get_sigframe(struct ksignal *ksig, struct pt_regs *regs, usp =sigsp (usp, ksig);/* Verify, is it 32 or 64 bit aligned */ -return (void *)((usp - frame_size) &-8UL ); +return (void __user *)((usp - frame_size) &-8UL ); }static int setup_rt_frame (struct ksignal *ksig,sigset_t *set,struct pt_regs *regs) { -struct rt_sigframe *frame; +struct rt_sigframe __user *frame;int err =0 ; frame =get_sigframe (ksig, regs,sizeof (*frame));
arch/powerpc/lib/sstep.c +2 -2
@@ -112,9 +112,9 @@ static nokprobe_inline long address_ok(struct pt_regs *regs, {if (!user_mode (regs))return 1 ; -if (__access_ok (ea, nb)) +if (access_ok ((void __user *)ea, nb))return 1 ; -if (__access_ok (ea,1 )) +if (access_ok ((void __user *)ea,1 ))/* Access overlaps the end of the user region */ regs->dar =TASK_SIZE_MAX -1 ;else
arch/riscv/kernel/perf_callchain.c +2 -2
@@ -15,8 +15,8 @@ static unsigned long user_backtrace(struct perf_callchain_entry_ctx *entry, {struct stackframe buftail;unsigned long ra =0 ; -unsigned long *user_frame_tail = - (unsigned long *)(fp -sizeof (struct stackframe )); +unsigned long __user *user_frame_tail = + (unsigned long __user *)(fp -sizeof (struct stackframe ));/* Check accessibility of one struct frame_tail beyond */ if (!access_ok (user_frame_tail,sizeof (buftail)))
arch/sparc/kernel/signal_32.c +1 -1
@@ -65,7 +65,7 @@ struct rt_signal_frame {*/ static inline bool invalid_frame_pointer (void __user *fp,int fplen) { -if ((((unsigned long ) fp) &15 ) || !__access_ok ((unsigned long )fp, fplen)) +if ((((unsigned long ) fp) &15 ) || !access_ok (fp, fplen))return true;return false;
lib/test_lockup.c +2 -2
@@ -417,8 +417,8 @@ static bool test_kernel_ptr(unsigned long addr, int size)return false;/* should be at least readable kernel address */ -if (access_ok (ptr,1 ) || -access_ok (ptr + size -1 ,1 ) || +if (access_ok ((void __user *)ptr,1 ) || +access_ok ((void __user *)ptr + size -1 ,1 ) ||get_kernel_nofault (buf, ptr) ||get_kernel_nofault (buf, ptr + size -1 )) {pr_err ("invalid kernel ptr: %#lx\n" , addr);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 757/913 lib/test_lockup: fix kernel pointer check for separate address spaces
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 5a06fcb15b43d1f7bf740c672950122331cb5655 ]
test_kernel_ptr() uses access_ok() to figure out if a given address points to user space instead of kernel space. However on architectures that set CONFIG_ALTERNATE_USER_ADDRESS_SPACE, a pointer can be valid for both, and the check always fails because access_ok() returns true.
Make the check for user space pointers conditional on the type of address space layout.
--- lib/test_lockup.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
lib/test_lockup.c +8 -3
@@ -417,9 +417,14 @@ static bool test_kernel_ptr(unsigned long addr, int size)return false;/* should be at least readable kernel address */ -if (access_ok ((void __user *)ptr,1 ) || -access_ok ((void __user *)ptr + size -1 ,1 ) || -get_kernel_nofault (buf, ptr) || +if (!IS_ENABLED (CONFIG_ALTERNATE_USER_ADDRESS_SPACE ) && + (access_ok ((void __user *)ptr,1 ) || +access_ok ((void __user *)ptr + size -1 ,1 ))) { +pr_err ("user space ptr invalid in kernel: %#lx\n" , addr); +return true; + } + +if (get_kernel_nofault (buf, ptr) ||get_kernel_nofault (buf, ptr + size -1 )) {pr_err ("invalid kernel ptr: %#lx\n" , addr);return true;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 758/913 ARM: tegra: tamonten: Fix I2C3 pad setting
In reply to Greg Kroah-HartmanFrom: Richard Leitner <[email protected]>
[ Upstream commit 0092c25b541a5422d7e71892a13c55ee91abc34b ]
This patch fixes the tristate configuration for i2c3 function assigned to the dtf pins on the Tamonten Tegra20 SoM.
--- arch/arm/boot/dts/tegra20-tamonten.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/boot/dts/tegra20-tamonten.dtsi +3 -3
@@ -183,8 +183,8 @@ }; conf_ata { nvidia,pins = "ata", "atb", "atc", "atd", "ate", - "cdev1", "cdev2", "dap1", "dtb", "gma", - "gmb", "gmc", "gmd", "gme", "gpu7", + "cdev1", "cdev2", "dap1", "dtb", "dtf", + "gma", "gmb", "gmc", "gmd", "gme", "gpu7", "gpv", "i2cp", "irrx", "irtx", "pta", "rm", "slxa", "slxk", "spia", "spib", "uac";
@@ -203,7 +203,7 @@ }; conf_crtp { nvidia,pins = "crtp", "dap2", "dap3", "dap4", - "dtc", "dte", "dtf", "gpu", "sdio1", + "dtc", "dte", "gpu", "sdio1", "slxc", "slxd", "spdi", "spdo", "spig", "uda"; nvidia,pull = <TEGRA_PIN_PULL_NONE>;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 759/913 ARM: mmp: Fix failure to remove sram device
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 4036b29a146b2749af3bb213b003eb69f3e5ecc4 ]
Make sure in .probe() to set driver data before the function is left to make it possible in .remove() to undo the actions done.
This fixes a potential memory leak and stops returning an error code in .remove() that is ignored by the driver core anyhow.
--- arch/arm/mach-mmp/sram.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
arch/arm/mach-mmp/sram.c +12 -10
@@ -72,6 +72,8 @@ static int sram_probe(struct platform_device *pdev)if (!info)return -ENOMEM ; +platform_set_drvdata (pdev, info); + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (res ==NULL ) {dev_err (&pdev->dev,"no memory resource defined\n" );
@@ -107,8 +109,6 @@ static int sram_probe(struct platform_device *pdev)list_add (&info->node, &sram_bank_list);mutex_unlock (&sram_lock); -platform_set_drvdata (pdev, info); -dev_info (&pdev->dev,"initialized\n" );return 0 ;
@@ -127,17 +127,19 @@ static int sram_remove(struct platform_device *pdev)struct sram_bank_info *info; info =platform_get_drvdata (pdev); -if (info ==NULL ) -return -ENODEV ; -mutex_lock (&sram_lock); -list_del (&info->node); -mutex_unlock (&sram_lock); +if (info->sram_size) { +mutex_lock (&sram_lock); +list_del (&info->node); +mutex_unlock (&sram_lock); + +gen_pool_destroy (info->gpool); +iounmap (info->sram_virt); +kfree (info->pool_name); + } -gen_pool_destroy (info->gpool); -iounmap (info->sram_virt); -kfree (info->pool_name);kfree (info); +return 0 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 760/913 ASoC: amd: vg: fix for pm resume callback sequence
In reply to Greg Kroah-HartmanFrom: Vijendar Mukunda <[email protected]>
[ Upstream commit 83b713619ee1b15e09eae11a92a7f3305534223d ]
The previous condition is used to cross check only the active stream status for I2S HS instance playback and capture use cases.
Modified logic to invoke sequence for two i2s controller instances.
This also fixes warnings reported by kernel robot:
"warning: variable 'frmt_val' set but not used" "warning: variable 'reg_val' set but not used"
--- sound/soc/amd/vangogh/acp5x-pcm-dma.c | 66 +++++++++++++-------------- 1 file changed, 33 insertions(+), 33 deletions(-)
sound/soc/amd/vangogh/acp5x-pcm-dma.c +33 -33
@@ -426,51 +426,51 @@ static int acp5x_audio_remove(struct platform_device *pdev)static int __maybe_unused acp5x_pcm_resume (struct device *dev) {struct i2s_dev_data *adata; -u32 val, reg_val, frmt_val; +struct i2s_stream_instance *rtd; +u32 val; - reg_val =0 ; - frmt_val =0 ; adata =dev_get_drvdata (dev);if (adata->play_stream && adata->play_stream->runtime) { -struct i2s_stream_instance *rtd = - adata->play_stream->runtime->private_data; + rtd = adata->play_stream->runtime->private_data;config_acp5x_dma (rtd,SNDRV_PCM_STREAM_PLAYBACK ); -switch (rtd->i2s_instance) { -case I2S_HS_INSTANCE : - reg_val =ACP_HSTDM_ITER ; - frmt_val =ACP_HSTDM_TXFRMT ; -break ; -case I2S_SP_INSTANCE : -default : - reg_val =ACP_I2STDM_ITER ; - frmt_val =ACP_I2STDM_TXFRMT ; +acp_writel ((rtd->xfer_resolution <<3 ), rtd->acp5x_base +ACP_HSTDM_ITER ); +if (adata->tdm_mode ==TDM_ENABLE ) { +acp_writel (adata->tdm_fmt, adata->acp5x_base +ACP_HSTDM_TXFRMT ); + val =acp_readl (adata->acp5x_base +ACP_HSTDM_ITER ); +acp_writel (val |0x2 , adata->acp5x_base +ACP_HSTDM_ITER ); + } + } +if (adata->i2ssp_play_stream && adata->i2ssp_play_stream->runtime) { + rtd = adata->i2ssp_play_stream->runtime->private_data; +config_acp5x_dma (rtd,SNDRV_PCM_STREAM_PLAYBACK ); +acp_writel ((rtd->xfer_resolution <<3 ), rtd->acp5x_base +ACP_I2STDM_ITER ); +if (adata->tdm_mode ==TDM_ENABLE ) { +acp_writel (adata->tdm_fmt, adata->acp5x_base +ACP_I2STDM_TXFRMT ); + val =acp_readl (adata->acp5x_base +ACP_I2STDM_ITER ); +acp_writel (val |0x2 , adata->acp5x_base +ACP_I2STDM_ITER ); } -acp_writel ((rtd->xfer_resolution <<3 ), - rtd->acp5x_base + reg_val); }if (adata->capture_stream && adata->capture_stream->runtime) { -struct i2s_stream_instance *rtd = - adata->capture_stream->runtime->private_data; + rtd = adata->capture_stream->runtime->private_data;config_acp5x_dma (rtd,SNDRV_PCM_STREAM_CAPTURE ); -switch (rtd->i2s_instance) { -case I2S_HS_INSTANCE : - reg_val =ACP_HSTDM_IRER ; - frmt_val =ACP_HSTDM_RXFRMT ; -break ; -case I2S_SP_INSTANCE : -default : - reg_val =ACP_I2STDM_IRER ; - frmt_val =ACP_I2STDM_RXFRMT ; +acp_writel ((rtd->xfer_resolution <<3 ), rtd->acp5x_base +ACP_HSTDM_IRER ); +if (adata->tdm_mode ==TDM_ENABLE ) { +acp_writel (adata->tdm_fmt, adata->acp5x_base +ACP_HSTDM_RXFRMT ); + val =acp_readl (adata->acp5x_base +ACP_HSTDM_IRER ); +acp_writel (val |0x2 , adata->acp5x_base +ACP_HSTDM_IRER ); } -acp_writel ((rtd->xfer_resolution <<3 ), - rtd->acp5x_base + reg_val); } -if (adata->tdm_mode ==TDM_ENABLE ) { -acp_writel (adata->tdm_fmt, adata->acp5x_base + frmt_val); - val =acp_readl (adata->acp5x_base + reg_val); -acp_writel (val |0x2 , adata->acp5x_base + reg_val); +if (adata->i2ssp_capture_stream && adata->i2ssp_capture_stream->runtime) { + rtd = adata->i2ssp_capture_stream->runtime->private_data; +config_acp5x_dma (rtd,SNDRV_PCM_STREAM_CAPTURE ); +acp_writel ((rtd->xfer_resolution <<3 ), rtd->acp5x_base +ACP_I2STDM_IRER ); +if (adata->tdm_mode ==TDM_ENABLE ) { +acp_writel (adata->tdm_fmt, adata->acp5x_base +ACP_I2STDM_RXFRMT ); + val =acp_readl (adata->acp5x_base +ACP_I2STDM_IRER ); +acp_writel (val |0x2 , adata->acp5x_base +ACP_I2STDM_IRER ); + } }acp_writel (1 , adata->acp5x_base +ACP_EXTERNAL_INTR_ENB );return 0 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 761/913 video: fbdev: sm712fb: Fix crash in smtcfb_write()
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit 4f01d09b2bbfbcb47b3eb305560a7f4857a32260 ]
When the sm712fb driver writes three bytes to the framebuffer, the driver will crash:
BUG: unable to handle page fault for address: ffffc90001ffffff
RIP: 0010:smtcfb_write+0x454/0x5b0
Call Trace:
vfs_write+0x291/0xd60
? do_sys_openat2+0x27d/0x350
? __fget_light+0x54/0x340
ksys_write+0xce/0x190
do_syscall_64+0x43/0x90
entry_SYSCALL_64_after_hwframe+0x44/0xaeFix it by removing the open-coded endianness fixup-code.
--- drivers/video/fbdev/sm712fb.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-)
drivers/video/fbdev/sm712fb.c +4 -17
@@ -1119,7 +1119,7 @@ static ssize_t smtcfb_write(struct fb_in count = total_size - p; } - buffer =kmalloc ((count >PAGE_SIZE ) ?PAGE_SIZE : count,GFP_KERNEL ); + buffer =kmalloc (PAGE_SIZE ,GFP_KERNEL );if (!buffer)return -ENOMEM ;
@@ -1137,24 +1137,11 @@ static ssize_t smtcfb_write(struct fb_inbreak ; } -for (i = c >>2 ; i--;) { -fb_writel (big_swap (*src), dst++); +for (i = (c +3 ) >>2 ; i--;) { +fb_writel (big_swap (*src), dst); + dst++; src++; } -if (c &3 ) { -u8 *src8 = (u8 *)src; -u8 __iomem *dst8 = (u8 __iomem *)dst; - -for (i = c &3 ; i--;) { -if (i &1 ) { -fb_writeb (*src8++, ++dst8); - }else { -fb_writeb (*src8++, --dst8); - dst8 +=2 ; - } - } - dst = (u32 __iomem *)dst8; - } *ppos += c; buf += c;
Greg Kroah-Hartman
maintainerPATCH 762/913 media: i2c: ov5648: Fix lockdep error
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit d4cb5d3c4cee28aa89b02bc33d930a6cf75e7f79 ]
ov5648_state_init() calls ov5648_state_mipi_configure() which uses __v4l2_ctrl_s_ctrl[_int64](). This means that sensor->mutex (which is also sensor->ctrls.handler.lock) must be locked before calling ov5648_state_init().
ov5648_state_mipi_configure() is also used in other places where the lock is already held so it cannot be changed itself.
Note this is based on an identical (tested) fix for the ov8865 driver, this has only been compile-tested.
--- drivers/media/i2c/ov5648.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/media/i2c/ov5648.c +8 -2
@@ -1778,8 +1778,14 @@ static int ov5648_state_configure(struct ov5648_sensor *sensor,static int ov5648_state_init (struct ov5648_sensor *sensor) { -return ov5648_state_configure (sensor, &ov5648_modes[0 ], - ov5648_mbus_codes[0 ]); +int ret; + +mutex_lock (&sensor->mutex); + ret =ov5648_state_configure (sensor, &ov5648_modes[0 ], + ov5648_mbus_codes[0 ]); +mutex_unlock (&sensor->mutex); + +return ret; }/* Sensor Base */
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 763/913 media: Revert "media: em28xx: add missing em28xx_close_extension"
In reply to Greg Kroah-HartmanFrom: Pavel Skripkin <[email protected]>
[ Upstream commit fde18c3bac3f964d8333ae53b304d8fee430502b ]
This reverts commit 2c98b8a3458df03abdc6945bbef67ef91d181938.
Reverted patch causes problems with Hauppauge WinTV dualHD as Maximilian reported [1]. Since quick solution didn't come up let's just revert it to make this device work with upstream kernels.
--- drivers/media/usb/em28xx/em28xx-cards.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/media/usb/em28xx/em28xx-cards.c +1 -4
@@ -4145,11 +4145,8 @@ static void em28xx_usb_disconnect(struct usb_interface *intf)em28xx_close_extension (dev); -if (dev->dev_next) { -em28xx_close_extension (dev->dev_next); +if (dev->dev_next)em28xx_release_resources (dev->dev_next); - } -em28xx_release_resources (dev);if (dev->dev_next) {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 764/913 media: hdpvr: initialize dev->worker at hdpvr_register_videodev
In reply to Greg Kroah-HartmanFrom: Dongliang Mu <[email protected]>
[ Upstream commit 07922937e9a580825f9965c46fd15e23ba5754b6 ]
hdpvr_register_videodev is responsible to initialize a worker in hdpvr_device. However, the worker is only initialized at hdpvr_start_streaming other than hdpvr_register_videodev. When hdpvr_probe does not initialize its worker, the hdpvr_disconnect will encounter one WARN in flush_work.The stack trace is as follows:
hdpvr_disconnect+0xb8/0xf2 drivers/media/usb/hdpvr/hdpvr-core.c:425 usb_unbind_interface+0xbf/0x3a0 drivers/usb/core/driver.c:458 __device_release_driver drivers/base/dd.c:1206 [inline] device_release_driver_internal+0x22a/0x230 drivers/base/dd.c:1237 bus_remove_device+0x108/0x160 drivers/base/bus.c:529 device_del+0x1fe/0x510 drivers/base/core.c:3592 usb_disable_device+0xd1/0x1d0 drivers/usb/core/message.c:1419 usb_disconnect+0x109/0x330 drivers/usb/core/hub.c:2228
Fix this by moving the initialization of dev->worker to the starting of hdpvr_register_videodev
--- drivers/media/usb/hdpvr/hdpvr-video.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/usb/hdpvr/hdpvr-video.c +3 -1
@@ -308,7 +308,6 @@ static int hdpvr_start_streaming(struct hdpvr_device *dev) dev->status =STATUS_STREAMING ; -INIT_WORK (&dev->worker, hdpvr_transmit_buffers);schedule_work (&dev->worker); v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev,
@@ -1165,6 +1164,9 @@ int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent,bool ac3 = dev->flags &HDPVR_FLAG_AC3_CAP ;int res; +// initialize dev->worker +INIT_WORK (&dev->worker, hdpvr_transmit_buffers); + dev->cur_std =V4L2_STD_525_60 ; dev->width =720 ; dev->height =480 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 765/913 ASoC: Intel: sof_sdw: fix quirks for 2022 HP Spectre x360 13"
In reply to Greg Kroah-HartmanFrom: Anthony I Gilea <[email protected]>
[ Upstream commit ce73ef6ec67104d1fcc4c5911d77ce83288a0998 ]
HP changed the DMI identification for 2022 devices:
Product Name: HP Spectre x360 Conv 13-ap0001na
Product Name: 8709
This patch relaxes the DMI_MATCH criterion to work with all versions of this product.
--- drivers/soundwire/dmi-quirks.c | 2 +- sound/soc/intel/boards/sof_sdw.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/soundwire/dmi-quirks.c +1 -1
@@ -59,7 +59,7 @@ static const struct dmi_system_id adr_remap_quirk_table[] = { { .matches = { DMI_MATCH(DMI_SYS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "HP Spectre x360 Convertible"), + DMI_MATCH(DMI_PRODUCT_NAME, "HP Spectre x360 Conv"), }, .driver_data = (void *)intel_tgl_bios, },
sound/soc/intel/boards/sof_sdw.c +1 -1
@@ -184,7 +184,7 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { .callback = sof_sdw_quirk_cb, .matches = {DMI_MATCH (DMI_SYS_VENDOR ,"HP" ), - DMI_MATCH(DMI_PRODUCT_NAME, "HP Spectre x360 Convertible"), + DMI_MATCH(DMI_PRODUCT_NAME, "HP Spectre x360 Conv"), }, .driver_data = (void *)(SOF_SDW_TGL_HDMI | SOF_SDW_PCH_DMIC |
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 766/913 tracing: Have TRACE_DEFINE_ENUM affect trace event types as well
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (Google) <[email protected]>
[ Upstream commit b3bc8547d3be60898818885f5bf22d0a62e2eb48 ]
The macro TRACE_DEFINE_ENUM is used to convert enums in the kernel to their actual value when they are exported to user space via the trace event format file.
Currently only the enums in the "print fmt" (TP_printk in the TRACE_EVENT macro) have the enums converted. But the enums can be used to denote array size:
field:unsigned int fc_ineligible_rc[EXT4_FC_REASON_MAX]; offset:12; size:36; signed:0;
The EXT4_FC_REASON_MAX has no meaning to userspace but it needs to know that information to know how to parse the array.
Have the array indexes also be parsed as well.
--- kernel/trace/trace_events.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
kernel/trace/trace_events.c +28 -0
@@ -2637,6 +2637,33 @@ static void update_event_printk(struct trace_event_call *call, } } +static void update_event_fields (struct trace_event_call *call, +struct trace_eval_map *map) +{ +struct ftrace_event_field *field; +struct list_head *head; +char *ptr; +int len =strlen (map->eval_string); + + head =trace_get_fields (call); +list_for_each_entry (field, head, link) { + ptr =strchr (field->type,'[' ); +if (!ptr) +continue ; + ptr++; + +if (!isalpha (*ptr) && *ptr !='_' ) +continue ; + +if (strncmp (map->eval_string, ptr, len) !=0 ) +continue ; + + ptr =eval_replace (ptr, map, len); +/* enum/sizeof string smaller than value */ +WARN_ON_ONCE (!ptr); + } +} +void trace_event_eval_update (struct trace_eval_map **map,int len) {struct trace_event_call *call, *p;
@@ -2672,6 +2699,7 @@ void trace_event_eval_update(struct trace_eval_map **map, int len) first = false; }update_event_printk (call, map[i]); +update_event_fields (call, map[i]); } } }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 767/913 mmc: host: Return an error when ->enable_sdio_irq() ops is missing
In reply to Greg Kroah-HartmanFrom: Ulf Hansson <[email protected]>
[ Upstream commit d6c9219ca1139b74541b2a98cee47a3426d754a9 ]
Even if the current WARN() notifies the user that something is severely wrong, we can still end up in a PANIC() when trying to invoke the missing ->enable_sdio_irq() ops. Therefore, let's also return an error code and prevent the host from being added.
While at it, move the code into a separate function to prepare for subsequent changes and for further host caps validations.
--- drivers/mmc/core/host.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/mmc/core/host.c +13 -2
@@ -588,6 +588,16 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)EXPORT_SYMBOL (mmc_alloc_host); +static int mmc_validate_host_caps (struct mmc_host *host) +{ +if (host->caps &MMC_CAP_SDIO_IRQ && !host->ops->enable_sdio_irq) { +dev_warn (host->parent,"missing ->enable_sdio_irq() ops\n" ); +return -EINVAL ; + } + +return 0 ; +} +/** * mmc_add_host - initialise host hardware * @host: mmc host
@@ -600,8 +610,9 @@ int mmc_add_host(struct mmc_host *host) {int err; -WARN_ON ((host->caps &MMC_CAP_SDIO_IRQ ) && - !host->ops->enable_sdio_irq); + err =mmc_validate_host_caps (host); +if (err) +return err; err =device_add (&host->class_dev);if (err)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 768/913 media: atomisp: fix bad usage at error handling logic
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit fc0b582c858ed73f94c8f3375c203ea46f1f7402 ]
As warned by sparse:
atomisp: drivers/staging/media/atomisp/pci/atomisp_acc.c:508 atomisp_acc_load_extensions() warn: iterator used outside loop: 'acc_fw'
The acc_fw interactor is used outside the loop, at the error handling logic. On most cases, this is actually safe there, but, if atomisp_css_set_acc_parameters() has an error, an attempt to use it will pick an invalid value for acc_fw.
--- .../staging/media/atomisp/pci/atomisp_acc.c | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_acc.c +19 -9
@@ -439,6 +439,18 @@ int atomisp_acc_s_mapped_arg(struct atomisp_sub_device *asd,return 0 ; } +static void atomisp_acc_unload_some_extensions (struct atomisp_sub_device *asd, +int i, +struct atomisp_acc_fw *acc_fw) +{ +while (--i >=0 ) { +if (acc_fw->flags & acc_flag_to_pipe[i].flag) { +atomisp_css_unload_acc_extension (asd, acc_fw->fw, + acc_flag_to_pipe[i].pipe_id); + } + } +} +/* * Appends the loaded acceleration binary extensions to the * current ISP mode. Must be called just before sh_css_start().
@@ -479,16 +491,20 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device *asd) acc_fw->fw, acc_flag_to_pipe[i].pipe_id, acc_fw->type); -if (ret) +if (ret) { +atomisp_acc_unload_some_extensions (asd, i, acc_fw); goto error; + } ext_loaded = true; } } ret =atomisp_css_set_acc_parameters (acc_fw); -if (ret <0 ) +if (ret <0 ) { +atomisp_acc_unload_some_extensions (asd, i, acc_fw); goto error; + } }if (!ext_loaded)
@@ -497,6 +513,7 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device *asd) ret =atomisp_css_update_stream (asd);if (ret) {dev_err (isp->dev,"%s: update stream failed.\n" , __func__); +atomisp_acc_unload_extensions (asd); goto error; }
@@ -504,13 +521,6 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device *asd)return 0 ; error: -while (--i >=0 ) { -if (acc_fw->flags & acc_flag_to_pipe[i].flag) { -atomisp_css_unload_acc_extension (asd, acc_fw->fw, - acc_flag_to_pipe[i].pipe_id); - } - } -list_for_each_entry_continue_reverse (acc_fw, &asd->acc.fw, list) {if (acc_fw->type !=ATOMISP_ACC_FW_LOAD_TYPE_OUTPUT && acc_fw->type !=ATOMISP_ACC_FW_LOAD_TYPE_VIEWFINDER )
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 769/913 ALSA: hda/realtek: Add alc256-samsung-headphone fixup
In reply to Greg Kroah-HartmanFrom: Matt Kramer <[email protected]>
[ Upstream commit ef248d9bd616b04df8be25539a4dc5db4b6c56f4 ]
This fixes the near-silence of the headphone jack on the ALC256-based Samsung Galaxy Book Flex Alpha (NP730QCJ). The magic verbs were found through trial and error, using known ALC298 hacks as inspiration. The fixup is auto-enabled only when the NP730QCJ is detected. It can be manually enabled using model=alc256-samsung-headphone.
--- Documentation/sound/hd-audio/models.rst | 4 ++++ sound/pci/hda/patch_realtek.c | 11 +++++++++++ 2 files changed, 15 insertions(+)
Documentation/sound/hd-audio/models.rst +4 -0
@@ -261,6 +261,10 @@ alc-sense-combo huawei-mbx-stereo Enable initialization verbs for Huawei MBX stereo speakers; might be risky, try this at your own risk +alc298-samsung-headphone + Samsung laptops with ALC298 +alc256-samsung-headphone + Samsung laptops with ALC256 ALC66x/67x/892 ==============
sound/pci/hda/patch_realtek.c +11 -0
@@ -6816,6 +6816,7 @@ enum {ALC236_FIXUP_HP_MUTE_LED ,ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF ,ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET , +ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET ,ALC295_FIXUP_ASUS_MIC_NO_PRESENCE ,ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS , ALC269VC_FIXUP_ACER_HEADSET_MIC,
@@ -8138,6 +8139,14 @@ static const struct hda_fixup alc269_fixups[] = { { } }, }, + [ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET] = { + .type = HDA_FIXUP_VERBS, + .v.verbs = (const struct hda_verb[]) { + { 0x20, AC_VERB_SET_COEF_INDEX, 0x08}, + { 0x20, AC_VERB_SET_PROC_COEF, 0x2fcf}, + { } + }, + }, [ALC295_FIXUP_ASUS_MIC_NO_PRESENCE] = { .type = HDA_FIXUP_PINS, .v.pins = (const struct hda_pintbl[]) {
@@ -8900,6 +8909,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x144d ,0xc740 ,"Samsung Ativ book 8 (NP870Z5G)" ,ALC269_FIXUP_ATIV_BOOK_8 ),SND_PCI_QUIRK (0x144d ,0xc812 ,"Samsung Notebook Pen S (NT950SBE-X58)" ,ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET ),SND_PCI_QUIRK (0x144d ,0xc830 ,"Samsung Galaxy Book Ion (NT950XCJ-X716A)" ,ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET ), +SND_PCI_QUIRK (0x144d ,0xc832 ,"Samsung Galaxy Book Flex Alpha (NP730QCJ)" ,ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET ),SND_PCI_QUIRK (0x1458 ,0xfa53 ,"Gigabyte BXBT-2807" ,ALC283_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1462 ,0xb120 ,"MSI Cubi MS-B120" ,ALC283_FIXUP_HEADSET_MIC ), SND_PCI_QUIRK(0x1462, 0xb171, "Cubi N 8GL (MS-B171)", ALC283_FIXUP_HEADSET_MIC),
@@ -9242,6 +9252,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = { {.id = ALC298_FIXUP_HUAWEI_MBX_STEREO, .name = "huawei-mbx-stereo"}, {.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"}, {.id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc298-samsung-headphone"}, + {.id = ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc256-samsung-headphone"}, {.id = ALC255_FIXUP_XIAOMI_HEADSET_MIC, .name = "alc255-xiaomi-headset"}, {.id = ALC274_FIXUP_HP_MIC, .name = "alc274-hp-mic-detect"}, {.id = ALC245_FIXUP_HP_X360_AMP, .name = "alc245-hp-x360-amp"},
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 770/913 KVM: x86: Reinitialize context if host userspace toggles EFER.LME
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit d6174299365ddbbf491620c0b8c5ca1a6ef2eea5 upstream.
While the guest runs, EFER.LME cannot change unless CR0.PG is clear, and therefore EFER.NX is the only bit that can affect the MMU role. However, set_efer accepts a host-initiated change to EFER.LME even with CR0.PG=1. In that case, the MMU has to be reset.
--- arch/x86/kvm/mmu.h | 1 + arch/x86/kvm/x86.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/mmu.h +1 -0
@@ -49,6 +49,7 @@ X86_CR4_LA57)#define KVM_MMU_CR0_ROLE_BITS (X86_CR0_PG | X86_CR0_WP) +#define KVM_MMU_EFER_ROLE_BITS (EFER_LME | EFER_NX) static __always_inline u64 rsvd_bits(int s, int e) {
arch/x86/kvm/x86.c +1 -2
@@ -1605,8 +1605,7 @@ static int set_efer(struct kvm_vcpu *vcpreturn r; } -/* Update reserved bits */ -if ((efer ^ old_efer) &EFER_NX ) +if ((efer ^ old_efer) &KVM_MMU_EFER_ROLE_BITS )kvm_mmu_reset_context (vcpu);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 771/913 KVM: x86/mmu: Move "invalid" check out of kvm_tdp_mmu_get_root()
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 04dc4e6ce274fa729feda32aa957b27388a3870c upstream.
Move the check for an invalid root out of kvm_tdp_mmu_get_root() and into the one place it actually matters, tdp_mmu_next_root(), as the other user already has an implicit validity check. A future bug fix will need to get references to invalid roots to honor mmu_notifier requests; there's no point in forcing what will be a common path to open code getting a reference to a root.
No functional change intended.
Message-Id: <[email protected]>
--- arch/x86/kvm/mmu/tdp_mmu.c | 12 ++++++++++-- arch/x86/kvm/mmu/tdp_mmu.h | 3 --- 2 files changed, 10 insertions(+), 5 deletions(-)
arch/x86/kvm/mmu/tdp_mmu.c +10 -2
@@ -121,9 +121,14 @@ static struct kvm_mmu_page *tdp_mmu_next next_root =list_first_or_null_rcu (&kvm->arch.tdp_mmu_roots,typeof (*next_root), link); -while (next_root && !kvm_tdp_mmu_get_root (kvm, next_root)) +while (next_root) { +if (!next_root->role.invalid && +kvm_tdp_mmu_get_root (kvm, next_root)) +break ; + next_root =list_next_or_null_rcu (&kvm->arch.tdp_mmu_roots, &next_root->link,typeof (*next_root), link); + }rcu_read_unlock ();
@@ -199,7 +204,10 @@ hpa_t kvm_tdp_mmu_get_vcpu_root_hpa(stru role =page_role_for_level (vcpu, vcpu->arch.mmu->shadow_root_level); -/* Check for an existing root before allocating a new one. */ +/* +* Check for an existing root before allocating a new one. Note, the +* role check prevents consuming an invalid root. +*/ for_each_tdp_mmu_root (kvm, root,kvm_mmu_role_as_id (role)) {if (root->role.word == role.word &&kvm_tdp_mmu_get_root (kvm, root))
arch/x86/kvm/mmu/tdp_mmu.h +0 -3
@@ -10,9 +10,6 @@ hpa_t kvm_tdp_mmu_get_vcpu_root_hpa(stru__must_check static inline bool kvm_tdp_mmu_get_root (struct kvm *kvm,struct kvm_mmu_page *root) { -if (root->role.invalid) -return false; -return refcount_inc_not_zero (&root->tdp_mmu_root_count); }
Greg Kroah-Hartman
maintainerPATCH 772/913 KVM: x86/mmu: Zap _all_ roots when unmapping gfn range in TDP MMU
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit d62007edf01f5c11f75d0f4b1e538fc52a5b1982 upstream.
Zap both valid and invalid roots when zapping/unmapping a gfn range, as KVM must ensure it holds no references to the freed page after returning from the unmap operation. Most notably, the TDP MMU doesn't zap invalid roots in mmu_notifier callbacks. This leads to use-after-free and other issues if the mmu_notifier runs to completion while an invalid root zapper yields as KVM fails to honor the requirement that there must be _no_ references to the page after the mmu_notifier returns.
The bug is most easily reproduced by hacking KVM to cause a collision between set_nx_huge_pages() and kvm_mmu_notifier_release(), but the bug exists between kvm_mmu_notifier_invalidate_range_start() and memslot updates as well. Invalidating a root ensures pages aren't accessible by the guest, and KVM won't read or write page data itself, but KVM will trigger e.g. kvm_set_pfn_dirty() when zapping SPTEs, and thus completing a zap of an invalid root _after_ the mmu_notifier returns is fatal.
WARNING: CPU: 24 PID: 1496 at arch/x86/kvm/../../../virt/kvm/kvm_main.c:173 [kvm] RIP: 0010:kvm_is_zone_device_pfn+0x96/0xa0 [kvm] Call Trace: <TASK> kvm_set_pfn_dirty+0xa8/0xe0 [kvm] __handle_changed_spte+0x2ab/0x5e0 [kvm] __handle_changed_spte+0x2ab/0x5e0 [kvm] __handle_changed_spte+0x2ab/0x5e0 [kvm] zap_gfn_range+0x1f3/0x310 [kvm] kvm_tdp_mmu_zap_invalidated_roots+0x50/0x90 [kvm] kvm_mmu_zap_all_fast+0x177/0x1a0 [kvm] set_nx_huge_pages+0xb4/0x190 [kvm] param_attr_store+0x70/0x100 module_attr_store+0x19/0x30 kernfs_fop_write_iter+0x119/0x1b0 new_sync_write+0x11c/0x1b0 vfs_write+0x1cc/0x270 ksys_write+0x5f/0xe0 do_syscall_64+0x38/0xc0 entry_SYSCALL_64_after_hwframe+0x44/0xae </TASK>
Message-Id: <[email protected]>
--- arch/x86/kvm/mmu/tdp_mmu.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-)
arch/x86/kvm/mmu/tdp_mmu.c +24 -15
@@ -99,15 +99,18 @@ void kvm_tdp_mmu_put_root(struct kvm *kv }/* -* Finds the next valid root after root (or the first valid root if root -* is NULL), takes a reference on it, and returns that next root. If root -* is not NULL, this thread should have already taken a reference on it, and -* that reference will be dropped. If no valid root is found, this -* function will return NULL. +* Returns the next root after @prev_root (or the first root if @prev_root is +* NULL). A reference to the returned root is acquired, and the reference to +* @prev_root is released (the caller obviously must hold a reference to +* @prev_root if it's non-NULL). +* +* If @only_valid is true, invalid roots are skipped. +* +* Returns NULL if the end of tdp_mmu_roots was reached. */ static struct kvm_mmu_page *tdp_mmu_next_root (struct kvm *kvm,struct kvm_mmu_page *prev_root, -bool shared) +bool shared,bool only_valid) {struct kvm_mmu_page *next_root;
@@ -122,7 +125,7 @@ static struct kvm_mmu_page *tdp_mmu_next typeof(*next_root), link);while (next_root) { -if (!next_root->role.invalid && +if ((!only_valid || !next_root->role.invalid) &&kvm_tdp_mmu_get_root (kvm, next_root))break ;
@@ -148,13 +151,19 @@ static struct kvm_mmu_page *tdp_mmu_next* mode. In the unlikely event that this thread must free a root, the lock * will be temporarily dropped and reacquired in write mode. */ -#define for_each_tdp_mmu_root_yield_safe (_kvm, _root, _as_id, _shared) \ - for (_root = tdp_mmu_next_root(_kvm, NULL, _shared); \ - _root; \ - _root = tdp_mmu_next_root(_kvm, _root, _shared)) \ - if (kvm_mmu_page_as_id(_root) != _as_id) { \ +#define __for_each_tdp_mmu_root_yield_safe (_kvm, _root, _as_id, _shared, _only_valid)\ + for (_root = tdp_mmu_next_root(_kvm, NULL, _shared, _only_valid); \ + _root; \ + _root = tdp_mmu_next_root(_kvm, _root, _shared, _only_valid)) \ + if (kvm_mmu_page_as_id(_root) != _as_id) { \ } else +#define for_each_valid_tdp_mmu_root_yield_safe (_kvm, _root, _as_id, _shared) \ + __for_each_tdp_mmu_root_yield_safe(_kvm, _root, _as_id, _shared, true) + +#define for_each_tdp_mmu_root_yield_safe (_kvm, _root, _as_id, _shared) \ + __for_each_tdp_mmu_root_yield_safe(_kvm, _root, _as_id, _shared, false) +#define for_each_tdp_mmu_root (_kvm, _root, _as_id) \ list_for_each_entry_rcu(_root, &_kvm->arch.tdp_mmu_roots, link, \ lockdep_is_held_type(&kvm->mmu_lock, 0) || \
@@ -1279,7 +1288,7 @@ bool kvm_tdp_mmu_wrprot_slot(struct kvmlockdep_assert_held_read (&kvm->mmu_lock); -for_each_tdp_mmu_root_yield_safe (kvm, root, slot->as_id, true) +for_each_valid_tdp_mmu_root_yield_safe (kvm, root, slot->as_id, true) spte_set |=wrprot_gfn_range (kvm, root, slot->base_gfn, slot->base_gfn + slot->npages, min_level);
@@ -1350,7 +1359,7 @@ bool kvm_tdp_mmu_clear_dirty_slot(structlockdep_assert_held_read (&kvm->mmu_lock); -for_each_tdp_mmu_root_yield_safe (kvm, root, slot->as_id, true) +for_each_valid_tdp_mmu_root_yield_safe (kvm, root, slot->as_id, true) spte_set |=clear_dirty_gfn_range (kvm, root, slot->base_gfn, slot->base_gfn + slot->npages);
@@ -1475,7 +1484,7 @@ void kvm_tdp_mmu_zap_collapsible_sptes(slockdep_assert_held_read (&kvm->mmu_lock); -for_each_tdp_mmu_root_yield_safe (kvm, root, slot->as_id, true) +for_each_valid_tdp_mmu_root_yield_safe (kvm, root, slot->as_id, true)zap_collapsible_spte_range (kvm, root, slot); }
Greg Kroah-Hartman
maintainerPATCH 773/913 KVM: x86/mmu: Check for present SPTE when clearing dirty bit in TDP MMU
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 3354ef5a592d219364cf442c2f784ce7ad7629fd upstream.
Explicitly check for present SPTEs when clearing dirty bits in the TDP MMU. This isn't strictly required for correctness, as setting the dirty bit in a defunct SPTE will not change the SPTE from !PRESENT to PRESENT. However, the guarded MMU_WARN_ON() in spte_ad_need_write_protect() would complain if anyone actually turned on KVM's MMU debugging.
Message-Id: <[email protected]>
--- arch/x86/kvm/mmu/tdp_mmu.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kvm/mmu/tdp_mmu.c +3 -0
@@ -1316,6 +1316,9 @@ retry:if (tdp_mmu_iter_cond_resched (kvm, &iter, false, true))continue ; +if (!is_shadow_present_pte (iter.old_spte)) +continue ; +if (spte_ad_need_write_protect (iter.old_spte)) {if (is_writable_pte (iter.old_spte)) new_spte = iter.old_spte & ~PT_WRITABLE_MASK ;
Greg Kroah-Hartman
maintainerPATCH 774/913 KVM: x86: hyper-v: Drop redundant ex parameter from kvm_hv_send_ipi()
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit 50e523dd79f6a856d793ce5711719abe27cffbf2 upstream.
'struct kvm_hv_hcall' has all the required information already, there's no need to pass 'ex' additionally.
No functional change intended.
Message-Id: <[email protected]>
--- arch/x86/kvm/hyperv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/kvm/hyperv.c +4 -4
@@ -1874,7 +1874,7 @@ static void kvm_send_ipi_to_many(struct } } -static u64 kvm_hv_send_ipi (struct kvm_vcpu *vcpu,struct kvm_hv_hcall *hc,bool ex) +static u64 kvm_hv_send_ipi (struct kvm_vcpu *vcpu,struct kvm_hv_hcall *hc) {struct kvm *kvm = vcpu->kvm;struct hv_send_ipi_ex send_ipi_ex;
@@ -1888,7 +1888,7 @@ static u64 kvm_hv_send_ipi(struct kvm_vcu32 vector;bool all_cpus; -if (!ex) { +if (hc->code ==HVCALL_SEND_IPI ) {if (!hc->fast) {if (unlikely (kvm_read_guest (kvm, hc->ingpa, &send_ipi,sizeof (send_ipi))))
@@ -2278,14 +2278,14 @@ int kvm_hv_hypercall(struct kvm_vcpu *vc ret =HV_STATUS_INVALID_HYPERCALL_INPUT ;break ; } - ret =kvm_hv_send_ipi (vcpu, &hc, false); + ret =kvm_hv_send_ipi (vcpu, &hc);break ;case HVCALL_SEND_IPI_EX :if (unlikely (hc.fast || hc.rep)) { ret =HV_STATUS_INVALID_HYPERCALL_INPUT ;break ; } - ret =kvm_hv_send_ipi (vcpu, &hc, true); + ret =kvm_hv_send_ipi (vcpu, &hc);break ;case HVCALL_POST_DEBUG_DATA :case HVCALL_RETRIEVE_DEBUG_DATA :
Greg Kroah-Hartman
maintainerPATCH 775/913 KVM: x86: hyper-v: Drop redundant ex parameter from kvm_hv_flush_tlb()
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit 82c1ead0d678af31e5d883656c12096a0004178b upstream.
'struct kvm_hv_hcall' has all the required information already, there's no need to pass 'ex' additionally.
No functional change intended.
Message-Id: <[email protected]>
--- arch/x86/kvm/hyperv.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-)
arch/x86/kvm/hyperv.c +6 -17
@@ -1749,7 +1749,7 @@ struct kvm_hv_hcall {sse128_t xmm[HV_HYPERCALL_MAX_XMM_REGISTERS ]; }; -static u64 kvm_hv_flush_tlb (struct kvm_vcpu *vcpu,struct kvm_hv_hcall *hc,bool ex) +static u64 kvm_hv_flush_tlb (struct kvm_vcpu *vcpu,struct kvm_hv_hcall *hc) {int i;gpa_t gpa;
@@ -1765,7 +1765,8 @@ static u64 kvm_hv_flush_tlb(struct kvm_vint sparse_banks_len;bool all_cpus; -if (!ex) { +if (hc->code ==HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST || + hc->code ==HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE ) {if (hc->fast) { flush.address_space = hc->ingpa; flush.flags = hc->outgpa;
@@ -2246,32 +2247,20 @@ int kvm_hv_hypercall(struct kvm_vcpu *vc kvm_hv_hypercall_complete_userspace;return 0 ;case HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST : -if (unlikely (!hc.rep_cnt || hc.rep_idx)) { - ret =HV_STATUS_INVALID_HYPERCALL_INPUT ; -break ; - } - ret =kvm_hv_flush_tlb (vcpu, &hc, false); -break ; -case HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE : -if (unlikely (hc.rep)) { - ret =HV_STATUS_INVALID_HYPERCALL_INPUT ; -break ; - } - ret =kvm_hv_flush_tlb (vcpu, &hc, false); -break ;case HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX :if (unlikely (!hc.rep_cnt || hc.rep_idx)) { ret =HV_STATUS_INVALID_HYPERCALL_INPUT ;break ; } - ret =kvm_hv_flush_tlb (vcpu, &hc, true); + ret =kvm_hv_flush_tlb (vcpu, &hc);break ; +case HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE :case HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX :if (unlikely (hc.rep)) { ret =HV_STATUS_INVALID_HYPERCALL_INPUT ;break ; } - ret =kvm_hv_flush_tlb (vcpu, &hc, true); + ret =kvm_hv_flush_tlb (vcpu, &hc);break ;case HVCALL_SEND_IPI :if (unlikely (hc.rep)) {
Greg Kroah-Hartman
maintainerPATCH 776/913 KVM: x86: hyper-v: Fix the maximum number of sparse banks for XMM fast TLB flush hypercalls
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit 7321f47eada53a395fb3086d49297eebb19e8e58 upstream.
When TLB flush hypercalls (HVCALL_FLUSH_VIRTUAL_ADDRESS_{LIST,SPACE}_EX are issued in 'XMM fast' mode, the maximum number of allowed sparse_banks is not 'HV_HYPERCALL_MAX_XMM_REGISTERS - 1' (5) but twice as many (10) as each XMM register is 128 bit long and can hold two 64 bit long banks.
Message-Id: <[email protected]>
--- arch/x86/kvm/hyperv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/hyperv.c +2 -1
@@ -1820,7 +1820,8 @@ static u64 kvm_hv_flush_tlb(struct kvm_vif (!all_cpus) {if (hc->fast) { -if (sparse_banks_len >HV_HYPERCALL_MAX_XMM_REGISTERS -1 ) +/* XMM0 is already consumed, each XMM holds two sparse banks. */ +if (sparse_banks_len >2 * (HV_HYPERCALL_MAX_XMM_REGISTERS -1 ))return HV_STATUS_INVALID_HYPERCALL_INPUT ;for (i =0 ; i < sparse_banks_len; i +=2 ) { sparse_banks[i] =sse128_lo (hc->xmm[i /2 +1 ]);
Greg Kroah-Hartman
maintainerPATCH 777/913 KVM: x86: hyper-v: HVCALL_SEND_IPI_EX is an XMM fast hypercall
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit 47d3e5cdfe607ec6883eb0faa7acf05b8cb3f92a upstream.
It has been proven on practice that at least Windows Server 2019 tries using HVCALL_SEND_IPI_EX in 'XMM fast' mode when it has more than 64 vCPUs and it needs to send an IPI to a vCPU > 63. Similarly to other XMM Fast hypercalls (HVCALL_FLUSH_VIRTUAL_ADDRESS_{LIST,SPACE}{,_EX}), this information is missing in TLFS as of 6.0b. Currently, KVM returns an error (HV_STATUS_INVALID_HYPERCALL_INPUT) and Windows crashes.
Note, HVCALL_SEND_IPI is a 'standard' fast hypercall (not 'XMM fast') as all its parameters fit into RDX:R8 and this is handled by KVM correctly.
Message-Id: <[email protected]>
--- arch/x86/kvm/hyperv.c | 52 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 18 deletions(-)
arch/x86/kvm/hyperv.c +34 -18
@@ -1889,6 +1889,7 @@ static u64 kvm_hv_send_ipi(struct kvm_vcint sparse_banks_len;u32 vector;bool all_cpus; +int i;if (hc->code ==HVCALL_SEND_IPI ) {if (!hc->fast) {
@@ -1909,9 +1910,15 @@ static u64 kvm_hv_send_ipi(struct kvm_vctrace_kvm_hv_send_ipi (vector, sparse_banks[0 ]); }else { -if (unlikely (kvm_read_guest (kvm, hc->ingpa, &send_ipi_ex, -sizeof (send_ipi_ex)))) -return HV_STATUS_INVALID_HYPERCALL_INPUT ; +if (!hc->fast) { +if (unlikely (kvm_read_guest (kvm, hc->ingpa, &send_ipi_ex, +sizeof (send_ipi_ex)))) +return HV_STATUS_INVALID_HYPERCALL_INPUT ; + }else { + send_ipi_ex.vector = (u32 )hc->ingpa; + send_ipi_ex.vp_set.format = hc->outgpa; + send_ipi_ex.vp_set.valid_bank_mask =sse128_lo (hc->xmm[0 ]); + } trace_kvm_hv_send_ipi_ex(send_ipi_ex.vector, send_ipi_ex.vp_set.format,
@@ -1919,8 +1926,7 @@ static u64 kvm_hv_send_ipi(struct kvm_vc vector = send_ipi_ex.vector; valid_bank_mask = send_ipi_ex.vp_set.valid_bank_mask; - sparse_banks_len =bitmap_weight (&valid_bank_mask,64 ) * -sizeof (sparse_banks[0 ]); + sparse_banks_len =bitmap_weight (&valid_bank_mask,64 ); all_cpus = send_ipi_ex.vp_set.format ==HV_GENERIC_SET_ALL ;
@@ -1930,12 +1936,27 @@ static u64 kvm_hv_send_ipi(struct kvm_vcif (!sparse_banks_len) goto ret_success; -if (kvm_read_guest (kvm, - hc->ingpa + offsetof(struct hv_send_ipi_ex , - vp_set.bank_contents), - sparse_banks, - sparse_banks_len)) -return HV_STATUS_INVALID_HYPERCALL_INPUT ; +if (!hc->fast) { +if (kvm_read_guest (kvm, + hc->ingpa + offsetof(struct hv_send_ipi_ex , + vp_set.bank_contents), + sparse_banks, + sparse_banks_len * sizeof(sparse_banks[0]))) +return HV_STATUS_INVALID_HYPERCALL_INPUT ; + }else { +/* +* The lower half of XMM0 is already consumed, each XMM holds +* two sparse banks. +*/ +if (sparse_banks_len > (2 *HV_HYPERCALL_MAX_XMM_REGISTERS -1 )) +return HV_STATUS_INVALID_HYPERCALL_INPUT ; +for (i =0 ; i < sparse_banks_len; i++) { +if (i %2 ) + sparse_banks[i] =sse128_lo (hc->xmm[(i +1 ) /2 ]); +else + sparse_banks[i] =sse128_hi (hc->xmm[i /2 ]); + } + } } check_and_send_ipi:
@@ -2097,6 +2118,7 @@ static bool is_xmm_fast_hypercall(structcase HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE :case HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX :case HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX : +case HVCALL_SEND_IPI_EX :return true; }
@@ -2264,14 +2286,8 @@ int kvm_hv_hypercall(struct kvm_vcpu *vc ret =kvm_hv_flush_tlb (vcpu, &hc);break ;case HVCALL_SEND_IPI : -if (unlikely (hc.rep)) { - ret =HV_STATUS_INVALID_HYPERCALL_INPUT ; -break ; - } - ret =kvm_hv_send_ipi (vcpu, &hc); -break ;case HVCALL_SEND_IPI_EX : -if (unlikely (hc.fast || hc.rep)) { +if (unlikely (hc.rep)) { ret =HV_STATUS_INVALID_HYPERCALL_INPUT ;break ; }
Greg Kroah-Hartman
maintainerPATCH 778/913 powerpc/kasan: Fix early region not updated correctly
In reply to Greg Kroah-HartmanFrom: Chen Jingwen <[email protected]>
commit dd75080aa8409ce10d50fb58981c6b59bf8707d3 upstream.
The shadow's page table is not updated when PTE_RPN_SHIFT is 24 and PAGE_SHIFT is 12. It not only causes false positives but also false negative as shown the following text.
Fix it by bringing the logic of kasan_early_shadow_page_entry here.
1. False Positive:
==================================================================
BUG: KASAN: vmalloc-out-of-bounds in pcpu_alloc+0x508/0xa50
Write of size 16 at addr f57f3be0 by task swapper/0/1
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.15.0-12267-gdebe436e77c7 #1
Call Trace:
[c80d1c20] [c07fe7b8] dump_stack_lvl+0x4c/0x6c (unreliable)
[c80d1c40] [c02ff668] print_address_description.constprop.0+0x88/0x300
[c80d1c70] [c02ff45c] kasan_report+0x1ec/0x200
[c80d1cb0] [c0300b20] kasan_check_range+0x160/0x2f0
[c80d1cc0] [c03018a4] memset+0x34/0x90
[c80d1ce0] [c0280108] pcpu_alloc+0x508/0xa50
[c80d1d40] [c02fd7bc] __kmem_cache_create+0xfc/0x570
[c80d1d70] [c0283d64] kmem_cache_create_usercopy+0x274/0x3e0
[c80d1db0] [c2036580] init_sd+0xc4/0x1d0
[c80d1de0] [c00044a0] do_one_initcall+0xc0/0x33c
[c80d1eb0] [c2001624] kernel_init_freeable+0x2c8/0x384
[c80d1ef0] [c0004b14] kernel_init+0x24/0x170
[c80d1f10] [c001b26c] ret_from_kernel_thread+0x5c/0x64
Memory state around the buggy address:
f57f3a80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
f57f3b00: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
>f57f3b80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
^
f57f3c00: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
f57f3c80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
==================================================================2. False Negative (with KASAN tests):
==================================================================
Before fix:
ok 45 - kmalloc_double_kzfree
# vmalloc_oob: EXPECTATION FAILED at lib/test_kasan.c:1039 KASAN failure expected in "((volatile char *)area)[3100]", but none occurred not ok 46 - vmalloc_oob
not ok 1 - kasan
==================================================================
After fix:
ok 1 - kasan
--- arch/powerpc/mm/kasan/kasan_init_32.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/powerpc/mm/kasan/kasan_init_32.c +1 -2
@@ -83,13 +83,12 @@ void __init kasan_update_early_region(unsigned long k_start, unsigned long k_end, pte_t pte) {unsigned long k_cur; -phys_addr_t pa =__pa (kasan_early_shadow_page);for (k_cur = k_start; k_cur != k_end; k_cur +=PAGE_SIZE ) {pmd_t *pmd =pmd_off_k (k_cur);pte_t *ptep =pte_offset_kernel (pmd, k_cur); -if ((pte_val (*ptep) &PTE_RPN_MASK ) != pa) +if (pte_page (*ptep) !=virt_to_page (lm_alias (kasan_early_shadow_page)))continue ;__set_pte_at (&init_mm, k_cur, ptep, pte,0 );
Greg Kroah-Hartman
maintainerPATCH 779/913 powerpc/lib/sstep: Fix sthcx instruction
In reply to Greg Kroah-HartmanFrom: Anders Roxell <[email protected]>
commit a633cb1edddaa643fadc70abc88f89a408fa834a upstream.
Looks like there been a copy paste mistake when added the instruction 'stbcx' twice and one was probably meant to be 'sthcx'. Changing to 'sthcx' from 'stbcx'.
--- arch/powerpc/lib/sstep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/lib/sstep.c +1 -1
@@ -3306,7 +3306,7 @@ int emulate_loadstore(struct pt_regs *re__put_user_asmx (op->val, ea, err,"stbcx." , cr);break ;case 2 : -__put_user_asmx (op->val, ea, err,"stbcx." , cr); +__put_user_asmx (op->val, ea, err,"sthcx." , cr);break ;#endif case 4 :
Greg Kroah-Hartman
maintainerPATCH 780/913 powerpc/lib/sstep: Fix build errors with newer binutils
In reply to Greg Kroah-HartmanFrom: Anders Roxell <[email protected]>
commit 8219d31effa7be5dbc7ff915d7970672e028c701 upstream.
Building tinyconfig with gcc (Debian 11.2.0-16) and assembler (Debian 2.37.90.20220207) the following build error shows up:
{standard input}: Assembler messages:
{standard input}:10576: Error: unrecognized opcode: stbcx.' {standard input}:10680: Error: unrecognized opcode: lharx' {standard input}:10694: Error: unrecognized opcode: `lbarx'
Rework to add assembler directives [1] around the instruction. The problem with this might be that we can trick a power6 into single-stepping through an stbcx. for instance, and it will execute that in kernel mode.
[1] https://sourceware.org/binutils/docs/as/PowerPC_002dPseudo.html#PowerPC_002dPseudo
--- arch/powerpc/lib/sstep.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/powerpc/lib/sstep.c +6 -0
@@ -1014,7 +1014,10 @@ NOKPROBE_SYMBOL(emulate_dcbz);#define __put_user_asmx (x, addr, err, op, cr) \ __asm__ __volatile__( \ + ".machine push\n" \ + ".machine power8\n" \ "1: " op " %2,0,%3\n" \ + ".machine pop\n" \ " mfcr %1\n" \ "2:\n" \ ".section .fixup,\"ax\"\n" \
@@ -1027,7 +1030,10 @@ NOKPROBE_SYMBOL(emulate_dcbz);#define __get_user_asmx (x, addr, err, op) \ __asm__ __volatile__( \ + ".machine push\n" \ + ".machine power8\n" \ "1: "op" %1,0,%2\n" \ + ".machine pop\n" \ "2:\n" \ ".section .fixup,\"ax\"\n" \ "3: li %0,%3\n" \
Greg Kroah-Hartman
maintainerPATCH 781/913 powerpc: Add set_memory_{p/np}() and remove set_memory_attr()
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit f222ab83df92acf72691a2021e1f0d99880dcdf1 upstream.
set_memory_attr() was implemented by commit 4d1755b6a762 ("powerpc/mm:
implement set_memory_attr()") because the set_memory_xx() couldn't be used at that time to modify memory "on the fly" as explained it the commit.
But set_memory_attr() uses set_pte_at() which leads to warnings when CONFIG_DEBUG_VM is selected, because set_pte_at() is unexpected for updating existing page table entries.
The check could be bypassed by using __set_pte_at() instead, as it was the case before commit c988cfd38e48 ("powerpc/32:
use set_memory_attr()") but since commit 9f7853d7609d ("powerpc/mm:
Fix set_memory_*() against concurrent accesses") it is now possible to use set_memory_xx() functions to update page table entries "on the fly" because the update is now atomic.
For DEBUG_PAGEALLOC we need to clear and set back _PAGE_PRESENT. Add set_memory_np() and set_memory_p() for that.
Replace all uses of set_memory_attr() by the relevant set_memory_xx() and remove set_memory_attr().
Depends-on: 9f7853d7609d ("powerpc/mm: Fix set_memory_*() against concurrent accesses")
--- arch/powerpc/include/asm/set_memory.h | 12 +++++++++- arch/powerpc/mm/pageattr.c | 39 +++++----------------------------- arch/powerpc/mm/pgtable_32.c | 24 +++++++++----------- 3 files changed, 28 insertions(+), 47 deletions(-)
arch/powerpc/include/asm/set_memory.h +11 -1
@@ -6,6 +6,8 @@#define SET_MEMORY_RW 1#define SET_MEMORY_NX 2#define SET_MEMORY_X 3 +#define SET_MEMORY_NP 4/* Set memory non present */ +#define SET_MEMORY_P 5/* Set memory present */ int change_memory_attr (unsigned long addr,int numpages,long action);
@@ -29,6 +31,14 @@ static inline int set_memory_x(unsigned return change_memory_attr(addr, numpages, SET_MEMORY_X); } -int set_memory_attr (unsigned long addr,int numpages,pgprot_t prot); +static inline int set_memory_np (unsigned long addr,int numpages) +{ +return change_memory_attr (addr, numpages,SET_MEMORY_NP ); +} + +static inline int set_memory_p (unsigned long addr,int numpages) +{ +return change_memory_attr (addr, numpages,SET_MEMORY_P ); +}#endif
arch/powerpc/mm/pageattr.c +6 -33
@@ -48,6 +48,12 @@ static int change_page_attr(pte_t *ptep,case SET_MEMORY_X : pte =pte_mkexec (pte);break ; +case SET_MEMORY_NP : +pte_update (&init_mm, addr, ptep, _PAGE_PRESENT,0 ,0 ); +break ; +case SET_MEMORY_P : +pte_update (&init_mm, addr, ptep,0 , _PAGE_PRESENT,0 ); +break ;default :WARN_ON_ONCE (1 );break ;
@@ -96,36 +102,3 @@ int change_memory_attr(unsigned long addreturn apply_to_existing_page_range (&init_mm, start, size, change_page_attr, (void *)action); } - -/* -* Set the attributes of a page: -* -* This function is used by PPC32 at the end of init to set final kernel memory -* protection. It includes changing the maping of the page it is executing from -* and data pages it is using. -*/ -static int set_page_attr (pte_t *ptep,unsigned long addr,void *data) -{ -pgprot_t prot =__pgprot ((unsigned long )data); - -spin_lock (&init_mm.page_table_lock); - -set_pte_at (&init_mm, addr, ptep,pte_modify (*ptep, prot)); -flush_tlb_kernel_range (addr, addr +PAGE_SIZE ); - -spin_unlock (&init_mm.page_table_lock); - -return 0 ; -} - -int set_memory_attr (unsigned long addr,int numpages,pgprot_t prot) -{ -unsigned long start =ALIGN_DOWN (addr,PAGE_SIZE ); -unsigned long sz = numpages *PAGE_SIZE ; - -if (numpages <=0 ) -return 0 ; - -return apply_to_existing_page_range (&init_mm, start, sz, set_page_attr, - (void *)pgprot_val (prot)); -}
arch/powerpc/mm/pgtable_32.c +11 -13
@@ -138,10 +138,12 @@ void mark_initmem_nx(void)unsigned long numpages =PFN_UP ((unsigned long )_einittext) -PFN_DOWN ((unsigned long )_sinittext); -if (v_block_mapped ((unsigned long )_sinittext)) +if (v_block_mapped ((unsigned long )_sinittext)) {mmu_mark_initmem_nx (); -else -set_memory_attr ((unsigned long )_sinittext, numpages,PAGE_KERNEL ); + }else { +set_memory_nx ((unsigned long )_sinittext, numpages); +set_memory_rw ((unsigned long )_sinittext, numpages); + } }#ifdef CONFIG_STRICT_KERNEL_RWX
@@ -155,18 +157,14 @@ void mark_rodata_ro(void)return ; } - numpages =PFN_UP ((unsigned long )_etext) - -PFN_DOWN ((unsigned long )_stext); - -set_memory_attr ((unsigned long )_stext, numpages,PAGE_KERNEL_ROX );/* -* mark .rodata as read only. Use __init_begin rather than __end_rodata -* to cover NOTES and EXCEPTION_TABLE. +* mark .text and .rodata as read only. Use __init_begin rather than +* __end_rodata to cover NOTES and EXCEPTION_TABLE. */ numpages =PFN_UP ((unsigned long )__init_begin) - -PFN_DOWN ((unsigned long )__start_rodata); +PFN_DOWN ((unsigned long )_stext); -set_memory_attr ((unsigned long )__start_rodata, numpages,PAGE_KERNEL_RO ); +set_memory_ro ((unsigned long )_stext, numpages);// mark_initmem_nx() should have already run by now ptdump_check_wx ();
@@ -182,8 +180,8 @@ void __kernel_map_pages(struct page *pagreturn ;if (enable) -set_memory_attr (addr, numpages,PAGE_KERNEL ); +set_memory_p (addr, numpages);else - set_memory_attr(addr, numpages, __pgprot(0)); + set_memory_np(addr, numpages); }#endif /* CONFIG_DEBUG_PAGEALLOC */
Greg Kroah-Hartman
maintainerPATCH 782/913 powerpc: Fix build errors with newer binutils
In reply to Greg Kroah-HartmanFrom: Anders Roxell <[email protected]>
commit 8667d0d64dd1f84fd41b5897fd87fa9113ae05e3 upstream.
Building tinyconfig with gcc (Debian 11.2.0-16) and assembler (Debian 2.37.90.20220207) the following build error shows up:
{standard input}: Assembler messages:
{standard input}:1190: Error: unrecognized opcode: stbcix' {standard input}:1433: Error: unrecognized opcode: lwzcix' {standard input}:1453: Error: unrecognized opcode: stbcix' {standard input}:1460: Error: unrecognized opcode: stwcix' {standard input}:1596: Error: unrecognized opcode: `stbcix'
...
Rework to add assembler directives [1] around the instruction. Going through them one by one shows that the changes should be safe. Like __get_user_atomic_128_aligned() is only called in p9_hmi_special_emu(), which according to the name is specific to power9. And __raw_rm_read*() are only called in things that are powernv or book3s_hv specific.
[1] https://sourceware.org/binutils/docs/as/PowerPC_002dPseudo.html#PowerPC_002dPseudo
--- arch/powerpc/include/asm/io.h | 40 ++++++++++++++++++++++++++++------- arch/powerpc/include/asm/uaccess.h | 3 ++ arch/powerpc/platforms/powernv/rng.c | 6 ++++- 3 files changed, 40 insertions(+), 9 deletions(-)
arch/powerpc/include/asm/io.h +32 -8
@@ -359,25 +359,37 @@ static inline void __raw_writeq_be(unsig*/ static inline void __raw_rm_writeb (u8 val,volatile void __iomem *paddr) { - __asm__ __volatile__("stbcix %0,0,%1" + __asm__ __volatile__(".machine push; \ +.machine power6; \ +stbcix %0,0,%1; \ +.machine pop;" : :"r" (val),"r" (paddr) :"memory" ); }static inline void __raw_rm_writew (u16 val,volatile void __iomem *paddr) { - __asm__ __volatile__("sthcix %0,0,%1" + __asm__ __volatile__(".machine push; \ +.machine power6; \ +sthcix %0,0,%1; \ +.machine pop;" : :"r" (val),"r" (paddr) :"memory" ); }static inline void __raw_rm_writel (u32 val,volatile void __iomem *paddr) { - __asm__ __volatile__("stwcix %0,0,%1" + __asm__ __volatile__(".machine push; \ +.machine power6; \ +stwcix %0,0,%1; \ +.machine pop;" : :"r" (val),"r" (paddr) :"memory" ); }static inline void __raw_rm_writeq (u64 val,volatile void __iomem *paddr) { - __asm__ __volatile__("stdcix %0,0,%1" + __asm__ __volatile__(".machine push; \ +.machine power6; \ +stdcix %0,0,%1; \ +.machine pop;" : :"r" (val),"r" (paddr) :"memory" ); }
@@ -389,7 +401,10 @@ static inline void __raw_rm_writeq_be(u6static inline u8 __raw_rm_readb (volatile void __iomem *paddr) {u8 ret; - __asm__ __volatile__("lbzcix %0,0, %1" + __asm__ __volatile__(".machine push; \ +.machine power6; \ +lbzcix %0,0, %1; \ +.machine pop;" :"=r" (ret) :"r" (paddr) :"memory" );return ret; }
@@ -397,7 +412,10 @@ static inline u8 __raw_rm_readb(volatilestatic inline u16 __raw_rm_readw (volatile void __iomem *paddr) {u16 ret; - __asm__ __volatile__("lhzcix %0,0, %1" + __asm__ __volatile__(".machine push; \ +.machine power6; \ +lhzcix %0,0, %1; \ +.machine pop;" :"=r" (ret) :"r" (paddr) :"memory" );return ret; }
@@ -405,7 +423,10 @@ static inline u16 __raw_rm_readw(volatilstatic inline u32 __raw_rm_readl (volatile void __iomem *paddr) {u32 ret; - __asm__ __volatile__("lwzcix %0,0, %1" + __asm__ __volatile__(".machine push; \ +.machine power6; \ +lwzcix %0,0, %1; \ +.machine pop;" :"=r" (ret) :"r" (paddr) :"memory" );return ret; }
@@ -413,7 +434,10 @@ static inline u32 __raw_rm_readl(volatilstatic inline u64 __raw_rm_readq (volatile void __iomem *paddr) {u64 ret; - __asm__ __volatile__("ldcix %0,0, %1" + __asm__ __volatile__(".machine push; \ +.machine power6; \ +ldcix %0,0, %1; \ +.machine pop;" :"=r" (ret) :"r" (paddr) :"memory" );return ret; }
arch/powerpc/include/asm/uaccess.h +3 -0
@@ -125,8 +125,11 @@ do { \*/ #define __get_user_atomic_128_aligned (kaddr, uaddr, err) \ __asm__ __volatile__( \ + ".machine push\n" \ + ".machine altivec\n" \ "1: lvx 0,0,%1 # get user\n" \ " stvx 0,0,%2 # put kernel\n" \ + ".machine pop\n" \ "2:\n" \ ".section .fixup,\"ax\"\n" \ "3: li %0,%3\n" \
arch/powerpc/platforms/powernv/rng.c +5 -1
@@ -43,7 +43,11 @@ static unsigned long rng_whiten(struct punsigned long parity;/* Calculate the parity of the value */ - asm ("popcntd %0,%1" :"=r" (parity) :"r" (val)); + asm (".machine push; \ +.machine power7; \ +popcntd %0,%1; \ +.machine pop;" + :"=r" (parity) :"r" (val));/* xor our value with the previous mask */ val ^= rng->mask;
Greg Kroah-Hartman
maintainerPATCH 783/913 drm/dp: Fix off-by-one in register cache size
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
commit d4da1f27396fb1dde079447a3612f4f512caed07 upstream.
The pcon_dsc_dpcd array holds 13 registers (0x92 through 0x9E). Fix the math to calculate the max size. Found from a -Warray-bounds build:
drivers/gpu/drm/drm_dp_helper.c: In function 'drm_dp_pcon_dsc_bpp_incr':drivers/gpu/drm/drm_dp_helper.c:3130:28: error: array subscript 12 is outside array bounds of 'const u8[12]' {aka 'const unsigned char[12]'} [-Werror=array-bounds]
3130 | buf = pcon_dsc_dpcd[DP_PCON_DSC_BPP_INCR - DP_PCON_DSC_ENCODER];
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/drm_dp_helper.c:3126:39: note: while referencing 'pcon_dsc_dpcd'
3126 | int drm_dp_pcon_dsc_bpp_incr(const u8 pcon_dsc_dpcd[DP_PCON_DSC_ENCODER_CAP_SIZE])
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--- include/drm/drm_dp_helper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/drm/drm_dp_helper.h +1 -1
@@ -455,7 +455,7 @@ struct drm_panel;# define DP_FEC_BIT_ERROR_COUNT_CAP (1 << 3)/* DP-HDMI2.1 PCON DSC ENCODER SUPPORT */ -#define DP_PCON_DSC_ENCODER_CAP_SIZE 0xC/* 0x9E - 0x92 */ +#define DP_PCON_DSC_ENCODER_CAP_SIZE 0xD/* 0x92 through 0x9E */ #define DP_PCON_DSC_ENCODER 0x092# define DP_PCON_DSC_ENCODER_SUPPORTED (1 << 0)# define DP_PCON_DSC_PPS_ENC_OVERRIDE (1 << 1)
Greg Kroah-Hartman
maintainerPATCH 784/913 drm/i915: Treat SAGV block time 0 as SAGV disabled
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
commit 1937f3feb0e84089ae4065e09c871b8ab4676f01 upstream.
For modern platforms the spec explicitly states that a SAGV block time of zero means that SAGV is not supported. Let's extend that to all platforms. Supposedly there should be no systems where this isn't true, and it'll allow us to:
- use the same code regardless of older vs. newer platform
- wm latencies already treat 0 as disabled, so this fits well with other related code
- make it a bit more clear when SAGV is used vs. not
- avoid overflows from adding U32_MAX with a u16 wm0 latency value which could cause us to miscalculate the SAGV watermarks on tgl+
--- drivers/gpu/drm/i915/intel_pm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +6 -4
@@ -3713,8 +3713,7 @@ skl_setup_sagv_block_time(struct drm_i91MISSING_CASE (DISPLAY_VER (dev_priv)); } -/* Default to an unusable block time */ - dev_priv->sagv_block_time_us =-1 ; + dev_priv->sagv_block_time_us =0 ; }/*
@@ -5635,7 +5634,7 @@ static void skl_compute_plane_wm(const s result->min_ddb_alloc =max (min_ddb_alloc, blocks) +1 ; result->enable = true; -if (DISPLAY_VER (dev_priv) <12 ) +if (DISPLAY_VER (dev_priv) <12 && dev_priv->sagv_block_time_us) result->can_sagv = latency >= dev_priv->sagv_block_time_us; }
@@ -5666,7 +5665,10 @@ static void tgl_compute_sagv_wm(const ststruct drm_i915_private *dev_priv =to_i915 (crtc_state->uapi.crtc->dev);struct skl_wm_level *sagv_wm = &plane_wm->sagv.wm0;struct skl_wm_level *levels = plane_wm->wm; -unsigned int latency = dev_priv->wm.skl_latency[0 ] + dev_priv->sagv_block_time_us; +unsigned int latency =0 ; + +if (dev_priv->sagv_block_time_us) + latency = dev_priv->sagv_block_time_us + dev_priv->wm.skl_latency[0 ]; skl_compute_plane_wm(crtc_state, 0, latency, wm_params, &levels[0],
Greg Kroah-Hartman
maintainerPATCH 785/913 drm/i915: Fix PSF GV point mask when SAGV is not possible
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
commit 3ef8b5e19ead5a79600ea55f9549658281415893 upstream.
Don't just mask off all the PSF GV points when SAGV gets disabled. This should in fact cause the Pcode to reject the request since at least one PSF point must remain enabled at all times.
--- drivers/gpu/drm/i915/display/intel_bw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_bw.c +2 -1
@@ -819,7 +819,8 @@ int intel_bw_atomic_check(struct intel_a* cause. */ if (!intel_can_enable_sagv (dev_priv, new_bw_state)) { - allowed_points =BIT (max_bw_point); + allowed_points &=ADLS_PSF_PT_MASK ; + allowed_points |=BIT (max_bw_point);drm_dbg_kms (&dev_priv->drm,"No SAGV, using single QGV point %d\n" , max_bw_point); }
Greg Kroah-Hartman
maintainerPATCH 786/913 drm/i915: Reject unsupported TMDS rates on ICL+
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
commit 9cddf03b2af07443bebdc73cba21acb360c079e8 upstream.
ICL+ PLLs can't genenerate certain frequencies. Running the PLL algorithms through for all frequencies 25-594MHz we see a gap just above 500 MHz. Specifically 500-522.8MHZ for TC PLLs, and 500-533.2 MHz for combo PHY PLLs. Reject those frequencies hdmi_port_clock_valid() so that we properly filter out unsupported modes and/or color depths for HDMI.
--- drivers/gpu/drm/i915/display/intel_hdmi.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/i915/display/intel_hdmi.c +9 -0
@@ -1831,6 +1831,7 @@ hdmi_port_clock_valid(struct intel_hdmi bool has_hdmi_sink) {struct drm_i915_private *dev_priv =intel_hdmi_to_i915 (hdmi); +enum phy phy =intel_port_to_phy (dev_priv,hdmi_to_dig_port (hdmi)->base.port);if (clock <25000 )return MODE_CLOCK_LOW ;
@@ -1851,6 +1852,14 @@ hdmi_port_clock_valid(struct intel_hdmiif (IS_CHERRYVIEW (dev_priv) && clock >216000 && clock <240000 )return MODE_CLOCK_RANGE ; +/* ICL+ combo PHY PLL can't generate 500-533.2 MHz */ +if (intel_phy_is_combo (dev_priv, phy) && clock >500000 && clock <533200 ) +return MODE_CLOCK_RANGE ; + +/* ICL+ TC PHY PLL can't generate 500-532.8 MHz */ +if (intel_phy_is_tc (dev_priv, phy) && clock >500000 && clock <532800 ) +return MODE_CLOCK_RANGE ; +/* * SNPS PHYs' MPLLB table-based programming can only handle a fixed * set of link rates.
Greg Kroah-Hartman
maintainerPATCH 787/913 scsi: qla2xxx: Refactor asynchronous command initialization
In reply to Greg Kroah-HartmanFrom: Daniel Wagner <[email protected]>
commit d4523bd6fd5d3afa9f08a86038a8a92176089f5b upstream.
Move common open-coded asynchronous command initializing code such as setting up the timer and the done callback into one function. This is a preparation step and allows us later on to change the low level error flow handling at a central place.
--- drivers/scsi/qla2xxx/qla_gbl.h | 3 - drivers/scsi/qla2xxx/qla_gs.c | 70 ++++++++++------------------------ drivers/scsi/qla2xxx/qla_init.c | 77 ++++++++++++-------------------------- drivers/scsi/qla2xxx/qla_iocb.c | 29 +++++++------- drivers/scsi/qla2xxx/qla_mbx.c | 11 +---- drivers/scsi/qla2xxx/qla_mid.c | 5 -- drivers/scsi/qla2xxx/qla_mr.c | 7 +-- drivers/scsi/qla2xxx/qla_target.c | 6 -- 8 files changed, 76 insertions(+), 132 deletions(-)
drivers/scsi/qla2xxx/qla_gbl.h +2 -1
@@ -316,7 +316,8 @@ extern int qla2x00_start_sp(srb_t *);extern int qla24xx_dif_start_scsi (srb_t *);extern int qla2x00_start_bidir (srb_t *,struct scsi_qla_host *,uint32_t );extern int qla2xxx_dif_start_scsi_mq (srb_t *); -extern void qla2x00_init_timer (srb_t *sp,unsigned long tmo); +extern void qla2x00_init_async_sp (srb_t *sp,unsigned long tmo, +void (*done)(struct srb *,int ));extern unsigned long qla2x00_get_async_timeout (struct scsi_qla_host *);extern void *qla2x00_alloc_iocbs (struct scsi_qla_host *,srb_t *);
drivers/scsi/qla2xxx/qla_gs.c +22 -48
202 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_init.c +25 -52
183 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_iocb.c +16 -13
@@ -2560,11 +2560,15 @@ qla24xx_tm_iocb(srb_t *sp, struct tsk_mg } } -void qla2x00_init_timer (srb_t *sp,unsigned long tmo) +void +qla2x00_init_async_sp (srb_t *sp,unsigned long tmo, +void (*done)(struct srb *sp,int res)) {timer_setup (&sp->u.iocb_cmd.timer, qla2x00_sp_timeout,0 ); - sp->u.iocb_cmd.timer.expires = jiffies + tmo *HZ ; + sp->done = done; sp->free = qla2x00_sp_free; + sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout; + sp->u.iocb_cmd.timer.expires = jiffies + tmo *HZ ;if (IS_QLAFX00 (sp->vha->hw) && sp->type ==SRB_FXIOCB_DCMD )init_completion (&sp->u.iocb_cmd.u.fxiocb.fxiocb_comp); sp->start_timer =1 ;
@@ -2672,11 +2676,11 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *v sp->type =SRB_ELS_DCMD ; sp->name ="ELS_DCMD" ; sp->fcport = fcport; - elsio->timeout = qla2x00_els_dcmd_iocb_timeout; -qla2x00_init_timer (sp,ELS_DCMD_TIMEOUT ); -init_completion (&sp->u.iocb_cmd.u.els_logo.comp); - sp->done = qla2x00_els_dcmd_sp_done; +qla2x00_init_async_sp (sp,ELS_DCMD_TIMEOUT , + qla2x00_els_dcmd_sp_done); sp->free = qla2x00_els_dcmd_sp_free; + sp->u.iocb_cmd.timeout = qla2x00_els_dcmd_iocb_timeout; +init_completion (&sp->u.iocb_cmd.u.els_logo.comp); elsio->u.els_logo.els_logo_pyld = dma_alloc_coherent(&ha->pdev->dev, DMA_POOL_SIZE, &elsio->u.els_logo.els_logo_pyld_dma,
@@ -2993,17 +2997,16 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *ql_dbg (ql_dbg_io, vha,0x3073 ,"%s Enter: PLOGI portid=%06x\n" , __func__, fcport->d_id.b24); - sp->type =SRB_ELS_DCMD ; - sp->name ="ELS_DCMD" ; - sp->fcport = fcport; - - elsio->timeout = qla2x00_els_dcmd2_iocb_timeout;if (wait) sp->flags =SRB_WAKEUP_ON_COMP ; -qla2x00_init_timer (sp,ELS_DCMD_TIMEOUT +2 ); + sp->type =SRB_ELS_DCMD ; + sp->name ="ELS_DCMD" ; + sp->fcport = fcport; +qla2x00_init_async_sp (sp,ELS_DCMD_TIMEOUT +2 , + qla2x00_els_dcmd2_sp_done); + sp->u.iocb_cmd.timeout = qla2x00_els_dcmd2_iocb_timeout; - sp->done = qla2x00_els_dcmd2_sp_done; elsio->u.els_plogi.tx_size = elsio->u.els_plogi.rx_size =DMA_POOL_SIZE ; ptr = elsio->u.els_plogi.els_plogi_pyld =
drivers/scsi/qla2xxx/qla_mbx.c +4 -7
@@ -6483,19 +6483,16 @@ int qla24xx_send_mb_cmd(struct scsi_qla_if (!sp) goto done; - sp->type =SRB_MB_IOCB ; - sp->name =mb_to_str (mcp->mb[0 ]); - c = &sp->u.iocb_cmd; - c->timeout = qla2x00_async_iocb_timeout;init_completion (&c->u.mbx.comp); -qla2x00_init_timer (sp,qla2x00_get_async_timeout (vha) +2 ); + sp->type =SRB_MB_IOCB ; + sp->name =mb_to_str (mcp->mb[0 ]); +qla2x00_init_async_sp (sp,qla2x00_get_async_timeout (vha) +2 , + qla2x00_async_mb_sp_done);memcpy (sp->u.iocb_cmd.u.mbx.out_mb, mcp->mb,SIZEOF_IOCB_MB_REG ); - sp->done = qla2x00_async_mb_sp_done; - rval =qla2x00_start_sp (sp);if (rval !=QLA_SUCCESS ) { ql_dbg(ql_dbg_mbx, vha, 0x1018,
drivers/scsi/qla2xxx/qla_mid.c +2 -3
@@ -972,9 +972,8 @@ int qla24xx_control_vp(scsi_qla_host_t * sp->type =SRB_CTRL_VP ; sp->name ="ctrl_vp" ; sp->comp = ∁ - sp->done = qla_ctrlvp_sp_done; - sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout; -qla2x00_init_timer (sp,qla2x00_get_async_timeout (vha) +2 ); +qla2x00_init_async_sp (sp,qla2x00_get_async_timeout (vha) +2 , + qla_ctrlvp_sp_done); sp->u.iocb_cmd.u.ctrlvp.cmd = cmd; sp->u.iocb_cmd.u.ctrlvp.vp_index = vp_index;
drivers/scsi/qla2xxx/qla_mr.c +3 -4
@@ -1793,11 +1793,11 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc sp->type =SRB_FXIOCB_DCMD ; sp->name ="fxdisc" ; +qla2x00_init_async_sp (sp,FXDISC_TIMEOUT , + qla2x00_fxdisc_sp_done); + sp->u.iocb_cmd.timeout = qla2x00_fxdisc_iocb_timeout; fdisc = &sp->u.iocb_cmd; - fdisc->timeout = qla2x00_fxdisc_iocb_timeout; -qla2x00_init_timer (sp,FXDISC_TIMEOUT ); -switch (fx_type) {case FXDISC_GET_CONFIG_INFO : fdisc->u.fxiocb.flags =
@@ -1898,7 +1898,6 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc } fdisc->u.fxiocb.req_func_type =cpu_to_le16 (fx_type); - sp->done = qla2x00_fxdisc_sp_done; rval =qla2x00_start_sp (sp);if (rval !=QLA_SUCCESS )
drivers/scsi/qla2xxx/qla_target.c +2 -4
@@ -656,12 +656,10 @@ int qla24xx_async_notify_ack(scsi_qla_ho sp->type = type; sp->name ="nack" ; - - sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout; -qla2x00_init_timer (sp,qla2x00_get_async_timeout (vha)+2 ); +qla2x00_init_async_sp (sp,qla2x00_get_async_timeout (vha) +2 , + qla2x00_async_nack_sp_done); sp->u.iocb_cmd.u.nack.ntfy = ntfy; - sp->done = qla2x00_async_nack_sp_done; ql_dbg(ql_dbg_disc, vha, 0x20f4, "Async-%s %8phC hndl %x %s\n",
Greg Kroah-Hartman
maintainerPATCH 788/913 scsi: qla2xxx: Implement ref count for SRB
In reply to Greg Kroah-HartmanFrom: Saurav Kashyap <[email protected]>
commit 31e6cdbe0eae37badceb5e0d4f06cf051432fd77 upstream.
The timeout handler and the done function are racing. When qla2x00_async_iocb_timeout() starts to run it can be preempted by the normal response path (via the firmware?). qla24xx_async_gpsc_sp_done() releases the SRB unconditionally. When scheduling back to qla2x00_async_iocb_timeout() qla24xx_async_abort_cmd() will access an freed sp->qpair pointer:
qla2xxx [0000:83:00.0]-2871:0: Async-gpsc timeout - hdl=63d portid=234500 50:06:0e:80:08:77:b6:21. qla2xxx [0000:83:00.0]-2853:0: Async done-gpsc res 0, WWPN 50:06:0e:80:08:77:b6:21
qla2xxx [0000:83:00.0]-2854:0: Async-gpsc OUT WWPN 20:45:00:27:f8:75:33:00 speeds=2c00 speed=0400. qla2xxx [0000:83:00.0]-28d8:0: qla24xx_handle_gpsc_event 50:06:0e:80:08:77:b6:21 DS 7 LS 6 rc 0 login 1|1 rscn 1|0 lid 5
BUG: unable to handle kernel NULL pointer dereference at 0000000000000004 IP: qla24xx_async_abort_cmd+0x1b/0x1c0 [qla2xxx]
Obvious solution to this is to introduce a reference counter. One reference is taken for the normal code path (the 'good' case) and one for the timeout path. As we always race between the normal good case and the timeout/abort handler we need to serialize it. Also we cannot assume any order between the handlers. Since this is slow path we can use proper synchronization via locks.
When we are able to cancel a timer (del_timer returns 1) we know there can't be any error handling in progress because the timeout handler hasn't expired yet, thus we can safely decrement the refcounter by one.
If we are not able to cancel the timer, we know an abort handler is running. We have to make sure we call sp->done() in the abort handlers before calling kref_put().
--- drivers/scsi/qla2xxx/qla_bsg.c | 6 +- drivers/scsi/qla2xxx/qla_def.h | 5 ++ drivers/scsi/qla2xxx/qla_edif.c | 3 - drivers/scsi/qla2xxx/qla_gbl.h | 1 drivers/scsi/qla2xxx/qla_gs.c | 85 +++++++++++++++++++++++++------------- drivers/scsi/qla2xxx/qla_init.c | 70 +++++++++++++++++++++---------- drivers/scsi/qla2xxx/qla_inline.h | 2 drivers/scsi/qla2xxx/qla_iocb.c | 41 ++++++++++++++---- drivers/scsi/qla2xxx/qla_mbx.c | 4 + drivers/scsi/qla2xxx/qla_mid.c | 4 + drivers/scsi/qla2xxx/qla_mr.c | 4 + drivers/scsi/qla2xxx/qla_os.c | 14 ++++-- drivers/scsi/qla2xxx/qla_target.c | 4 - 13 files changed, 173 insertions(+), 70 deletions(-)
drivers/scsi/qla2xxx/qla_bsg.c +4 -2
@@ -29,7 +29,8 @@ void qla2x00_bsg_job_done(srb_t *sp, int"%s: sp hdl %x, result=%x bsg ptr %p\n" , __func__, sp->handle, res, bsg_job); - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release); bsg_reply->result = res; bsg_job_done(bsg_job, bsg_reply->result,
@@ -3010,6 +3011,7 @@ qla24xx_bsg_timeout(struct bsg_job *bsg_ done:spin_unlock_irqrestore (&ha->hardware_lock, flags); - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release);return 0 ; }
drivers/scsi/qla2xxx/qla_def.h +5 -0
@@ -726,6 +726,11 @@ typedef struct srb {* code. */ void (*put_fn)(struct kref *kref); + +/* +* Report completion for asynchronous commands. +*/ +void (*async_done)(struct srb *sp,int res); } srb_t;#define GET_CMD_SP (sp) (sp->u.scmd.cmd)
drivers/scsi/qla2xxx/qla_edif.c +2 -1
@@ -2161,7 +2161,8 @@ edif_doorbell_show(struct device *dev, sstatic void qla_noop_sp_done (srb_t *sp,int res) { - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release); }/*
drivers/scsi/qla2xxx/qla_gbl.h +1 -0
@@ -333,6 +333,7 @@ extern int qla24xx_get_one_block_sg(uintextern int qla24xx_configure_prot_mode (srb_t *,uint16_t *);extern int qla24xx_issue_sa_replace_iocb (scsi_qla_host_t *vha,struct qla_work_evt *e); +void qla2x00_sp_release (struct kref *kref);/* * Global Function Prototypes in qla_mbx.c source file.
drivers/scsi/qla2xxx/qla_gs.c +57 -28
289 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_init.c +49 -21
236 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_inline.h +2 -0
@@ -184,6 +184,8 @@ static void qla2xxx_init_sp(srb_t *sp, s sp->vha = vha; sp->qpair = qpair; sp->cmd_type =TYPE_SRB ; +/* ref : INIT - normal flow */ +kref_init (&sp->cmd_kref);INIT_LIST_HEAD (&sp->elem); }
drivers/scsi/qla2xxx/qla_iocb.c +32 -9
102 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_mbx.c +3 -1
@@ -6479,6 +6479,7 @@ int qla24xx_send_mb_cmd(struct scsi_qla_if (!vha->hw->flags.fw_started) goto done; +/* ref: INIT */ sp =qla2x00_get_sp (vha,NULL ,GFP_KERNEL );if (!sp) goto done;
@@ -6524,7 +6525,8 @@ int qla24xx_send_mb_cmd(struct scsi_qla_ } done_free_sp: - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release); done:return rval; }
drivers/scsi/qla2xxx/qla_mid.c +3 -1
@@ -965,6 +965,7 @@ int qla24xx_control_vp(scsi_qla_host_t *if (vp_index ==0 || vp_index >= ha->max_npiv_vports)return QLA_PARAMETER_ERROR ; +/* ref: INIT */ sp =qla2x00_get_sp (base_vha,NULL ,GFP_KERNEL );if (!sp)return rval;
@@ -1007,6 +1008,7 @@ int qla24xx_control_vp(scsi_qla_host_t *break ; } done: - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release);return rval; }
drivers/scsi/qla2xxx/qla_mr.c +3 -1
@@ -1787,6 +1787,7 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fcstruct register_host_info *preg_hsi;struct new_utsname *p_sysid =NULL ; +/* ref: INIT */ sp =qla2x00_get_sp (vha, fcport,GFP_KERNEL );if (!sp) goto done;
@@ -1973,7 +1974,8 @@ done_unmap_req:dma_free_coherent (&ha->pdev->dev, fdisc->u.fxiocb.req_len, fdisc->u.fxiocb.req_addr, fdisc->u.fxiocb.req_dma_handle); done_free_sp: - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release); done:return rval; }
drivers/scsi/qla2xxx/qla_os.c +10 -4
@@ -728,7 +728,8 @@ void qla2x00_sp_compl(srb_t *sp, int resstruct scsi_cmnd *cmd =GET_CMD_SP (sp);struct completion *comp = sp->comp; - sp->free (sp); +/* kref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release); cmd->result = res;CMD_SP (cmd) =NULL ; cmd->scsi_done (cmd);
@@ -819,7 +820,8 @@ void qla2xxx_qpair_sp_compl(srb_t *sp, istruct scsi_cmnd *cmd =GET_CMD_SP (sp);struct completion *comp = sp->comp; - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release); cmd->result = res;CMD_SP (cmd) =NULL ; cmd->scsi_done (cmd);
@@ -919,6 +921,7 @@ qla2xxx_queuecommand(struct Scsi_Host *h goto qc24_target_busy; sp =scsi_cmd_priv (cmd); +/* ref: INIT */ qla2xxx_init_sp (sp, vha, vha->hw->base_qpair, fcport); sp->u.scmd.cmd = cmd;
@@ -938,7 +941,8 @@ qla2xxx_queuecommand(struct Scsi_Host *hreturn 0 ; qc24_host_busy_free_sp: - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release); qc24_target_busy:return SCSI_MLQUEUE_TARGET_BUSY ;
@@ -1008,6 +1012,7 @@ qla2xxx_mqueuecommand(struct Scsi_Host * goto qc24_target_busy; sp =scsi_cmd_priv (cmd); +/* ref: INIT */ qla2xxx_init_sp (sp, vha, qpair, fcport); sp->u.scmd.cmd = cmd;
@@ -1026,7 +1031,8 @@ qla2xxx_mqueuecommand(struct Scsi_Host *return 0 ; qc24_host_busy_free_sp: - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release); qc24_target_busy:return SCSI_MLQUEUE_TARGET_BUSY ;
drivers/scsi/qla2xxx/qla_target.c +2 -2
@@ -620,7 +620,7 @@ static void qla2x00_async_nack_sp_done(s }spin_unlock_irqrestore (&vha->hw->tgt.sess_lock, flags); - sp->free (sp); +kref_put (&sp->cmd_kref, qla2x00_sp_release); } int qla24xx_async_notify_ack(scsi_qla_host_t *vha, fc_port_t *fcport,
@@ -672,7 +672,7 @@ int qla24xx_async_notify_ack(scsi_qla_horeturn rval; done_free_sp: - sp->free (sp); +kref_put (&sp->cmd_kref, qla2x00_sp_release); done: fcport->flags &= ~FCF_ASYNC_SENT ;return rval;
Greg Kroah-Hartman
maintainerPATCH 789/913 scsi: qla2xxx: Fix stuck session in gpdb
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit 725d3a0d31a51c0debf970011e05f585e805165b upstream.
Fix stuck sessions in get port database. When a thread is in the process of re-establishing a session, a flag is set to prevent multiple threads / triggers from doing the same task. This flag was left on, where any attempt to relogin was locked out. Clear this flag, if the attempt has failed.
--- drivers/scsi/qla2xxx/qla_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +3 -3
@@ -1333,9 +1333,9 @@ int qla24xx_async_gpdb(struct scsi_qla_hif (!vha->flags.online || (fcport->flags &FCF_ASYNC_SENT ) || fcport->loop_id ==FC_NO_LOOP_ID ) {ql_log (ql_log_warn, vha,0xffff , -"%s: %8phC - not sending command.\n" , - __func__, fcport->port_name); -return rval; +"%s: %8phC online %d flags %x - not sending command.\n" , + __func__, fcport->port_name, vha->flags.online, fcport->flags); + goto done; } sp =qla2x00_get_sp (vha, fcport,GFP_KERNEL );
Greg Kroah-Hartman
maintainerPATCH 790/913 scsi: qla2xxx: Fix warning message due to adisc being flushed
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit 64f24af75b79cba3b86b0760e27e0fa904db570f upstream.
Fix warning message due to adisc being flushed. Linux kernel triggered a warning message where a different error code type is not matching up with the expected type. Add additional translation of one error code type to another.
WARNING: CPU: 2 PID: 1131623 at drivers/scsi/qla2xxx/qla_init.c:498 qla2x00_async_adisc_sp_done+0x294/0x2b0 [qla2xxx] CPU: 2 PID: 1131623 Comm: drmgr Not tainted 5.13.0-rc1-autotest #1
..
GPR28: c000000aaa9c8890 c0080000079ab678 c00000140a104800 c00000002bd19000 NIP [c00800000790857c] qla2x00_async_adisc_sp_done+0x294/0x2b0 [qla2xxx] LR [c008000007908578] qla2x00_async_adisc_sp_done+0x290/0x2b0 [qla2xxx]
Call Trace: [c00000001cdc3620] [c008000007908578] qla2x00_async_adisc_sp_done+0x290/0x2b0 [qla2xxx] (unreliable) [c00000001cdc3710] [c0080000078f3080] __qla2x00_abort_all_cmds+0x1b8/0x580 [qla2xxx] [c00000001cdc3840] [c0080000078f589c] qla2x00_abort_all_cmds+0x34/0xd0 [qla2xxx] [c00000001cdc3880] [c0080000079153d8] qla2x00_abort_isp_cleanup+0x3f0/0x570 [qla2xxx] [c00000001cdc3920] [c0080000078fb7e8] qla2x00_remove_one+0x3d0/0x480 [qla2xxx] [c00000001cdc39b0] [c00000000071c274] pci_device_remove+0x64/0x120 [c00000001cdc39f0] [c0000000007fb818] device_release_driver_internal+0x168/0x2a0 [c00000001cdc3a30] [c00000000070e304] pci_stop_bus_device+0xb4/0x100 [c00000001cdc3a70] [c00000000070e4f0] pci_stop_and_remove_bus_device+0x20/0x40 [c00000001cdc3aa0] [c000000000073940] pci_hp_remove_devices+0x90/0x130 [c00000001cdc3b30] [c0080000070704d0] disable_slot+0x38/0x90 [rpaphp] [ c00000001cdc3b60] [c00000000073eb4c] power_write_file+0xcc/0x180 [c00000001cdc3be0] [c0000000007354bc] pci_slot_attr_store+0x3c/0x60 [c00000001cdc3c00] [c00000000055f820] sysfs_kf_write+0x60/0x80 [c00000001cdc3c20] [c00000000055df10] kernfs_fop_write_iter+0x1a0/0x290 [c00000001cdc3c70] [c000000000447c4c] new_sync_write+0x14c/0x1d0 [c00000001cdc3d10] [c00000000044b134] vfs_write+0x224/0x330 [c00000001cdc3d60] [c00000000044b3f4] ksys_write+0x74/0x130 [c00000001cdc3db0] [c00000000002df70] system_call_exception+0x150/0x2d0 [c00000001cdc3e10] [c00000000000d45c] system_call_common+0xec/0x278
--- drivers/scsi/qla2xxx/qla_init.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/scsi/qla2xxx/qla_init.c +6 -0
@@ -295,6 +295,8 @@ static void qla2x00_async_login_sp_done( ea.iop[0 ] = lio->u.logio.iop[0 ]; ea.iop[1 ] = lio->u.logio.iop[1 ]; ea.sp = sp; +if (res) + ea.data[0 ] =MBS_COMMAND_ERROR ;qla24xx_handle_plogi_done_event (vha, &ea); }
@@ -558,6 +560,8 @@ static void qla2x00_async_adisc_sp_done( ea.iop[1 ] = lio->u.logio.iop[1 ]; ea.fcport = sp->fcport; ea.sp = sp; +if (res) + ea.data[0 ] =MBS_COMMAND_ERROR ;qla24xx_handle_adisc_event (vha, &ea);/* ref: INIT */
@@ -1238,6 +1242,8 @@ static void qla2x00_async_prli_sp_done(s ea.sp = sp;if (res ==QLA_OS_TIMER_EXPIRED ) ea.data[0 ] =QLA_OS_TIMER_EXPIRED ; +else if (res) + ea.data[0 ] =MBS_COMMAND_ERROR ;qla24xx_handle_prli_done_event (vha, &ea); }
Greg Kroah-Hartman
maintainerPATCH 791/913 scsi: qla2xxx: Fix scheduling while atomic
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit afd438ff874ca40b74321b3fa19bd61adfd7ca0c upstream.
The driver makes a call into midlayer (fc_remote_port_delete) which can put the thread to sleep. The thread that originates the call is in interrupt context. The combination of the two trigger a crash. Schedule the call in non-interrupt context where it is more safe.
kernel: BUG: scheduling while atomic: swapper/7/0/0x00010000 kernel: Call Trace: kernel: <IRQ> kernel: dump_stack+0x66/0x81 kernel: __schedule_bug.cold.90+0x5/0x1d kernel: __schedule+0x7af/0x960 kernel: schedule+0x28/0x80 kernel: schedule_timeout+0x26d/0x3b0 kernel: wait_for_completion+0xb4/0x140 kernel: ? wake_up_q+0x70/0x70 kernel: __wait_rcu_gp+0x12c/0x160 kernel: ? sdev_evt_alloc+0xc0/0x180 [scsi_mod] kernel: synchronize_sched+0x6c/0x80 kernel: ? call_rcu_bh+0x20/0x20 kernel: ? __bpf_trace_rcu_invoke_callback+0x10/0x10 kernel: sdev_evt_alloc+0xfd/0x180 [scsi_mod] kernel: starget_for_each_device+0x85/0xb0 [scsi_mod] kernel: ? scsi_init_io+0x360/0x3d0 [scsi_mod] kernel: scsi_init_io+0x388/0x3d0 [scsi_mod] kernel: device_for_each_child+0x54/0x90 kernel: fc_remote_port_delete+0x70/0xe0 [scsi_transport_fc] kernel: qla2x00_schedule_rport_del+0x62/0xf0 [qla2xxx] kernel: qla2x00_mark_device_lost+0x9c/0xd0 [qla2xxx] kernel: qla24xx_handle_plogi_done_event+0x55f/0x570 [qla2xxx] kernel: qla2x00_async_login_sp_done+0xd2/0x100 [qla2xxx] kernel: qla24xx_logio_entry+0x13a/0x3c0 [qla2xxx] kernel: qla24xx_process_response_queue+0x306/0x400 [qla2xxx] kernel: qla24xx_msix_rsp_q+0x3f/0xb0 [qla2xxx] kernel: __handle_irq_event_percpu+0x40/0x180 kernel: handle_irq_event_percpu+0x30/0x80 kernel: handle_irq_event+0x36/0x60
--- drivers/scsi/qla2xxx/qla_init.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +1 -6
@@ -2212,12 +2212,7 @@ qla24xx_handle_plogi_done_event(struct sql_dbg (ql_dbg_disc, vha,0x20eb ,"%s %d %8phC cmd error %x\n" , __func__, __LINE__, ea->fcport->port_name, ea->data[1 ]); - ea->fcport->flags &= ~FCF_ASYNC_SENT ; -qla2x00_set_fcport_disc_state (ea->fcport,DSC_LOGIN_FAILED ); -if (ea->data[1 ] &QLA_LOGIO_LOGIN_RETRIED ) -set_bit (RELOGIN_NEEDED , &vha->dpc_flags); -else -qla2x00_mark_device_lost (vha, ea->fcport,1 ); +qlt_schedule_sess_for_deletion (ea->fcport);break ;case MBS_LOOP_ID_USED :/* data[1] = IO PARAM 1 = nport ID */
Greg Kroah-Hartman
maintainerPATCH 792/913 scsi: qla2xxx: Fix premature hw access after PCI error
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit e35920ab7874d5e2faeb4f958a74bfa793f1ce5a upstream.
After a recoverable PCI error has been detected and recovered, qla driver needs to check to see if the error condition still persist and/or wait for the OS to give the resume signal.
Sep 8 22:26:03 localhost kernel: WARNING: CPU: 9 PID: 124606 at qla_tmpl.c:440 qla27xx_fwdt_entry_t266+0x55/0x60 [qla2xxx] Sep 8 22:26:03 localhost kernel: RIP: 0010:qla27xx_fwdt_entry_t266+0x55/0x60 [qla2xxx] Sep 8 22:26:03 localhost kernel: Call Trace: Sep 8 22:26:03 localhost kernel: ? qla27xx_walk_template+0xb1/0x1b0 [qla2xxx] Sep 8 22:26:03 localhost kernel: ? qla27xx_execute_fwdt_template+0x12a/0x160 [qla2xxx] Sep 8 22:26:03 localhost kernel: ? qla27xx_fwdump+0xa0/0x1c0 [qla2xxx] Sep 8 22:26:03 localhost kernel: ? qla2xxx_pci_mmio_enabled+0xfb/0x120 [qla2xxx] Sep 8 22:26:03 localhost kernel: ? report_mmio_enabled+0x44/0x80 Sep 8 22:26:03 localhost kernel: ? report_slot_reset+0x80/0x80 Sep 8 22:26:03 localhost kernel: ? pci_walk_bus+0x70/0x90 Sep 8 22:26:03 localhost kernel: ? aer_dev_correctable_show+0xc0/0xc0 Sep 8 22:26:03 localhost kernel: ? pcie_do_recovery+0x1bb/0x240 Sep 8 22:26:03 localhost kernel: ? aer_recover_work_func+0xaa/0xd0 Sep 8 22:26:03 localhost kernel: ? process_one_work+0x1a7/0x360 .. Sep 8 22:26:03 localhost kernel: qla2xxx [0000:42:00.2]-8041:22: detected PCI disconnect. Sep 8 22:26:03 localhost kernel: qla2xxx [0000:42:00.2]-107ff:22: qla27xx_fwdt_entry_t262: dump ram MB failed. Area 5h start 198013h end 198013h Sep 8 22:26:03 localhost kernel: qla2xxx [0000:42:00.2]-107ff:22: Unable to capture FW dump Sep 8 22:26:03 localhost kernel: qla2xxx [0000:42:00.2]-1015:22: cmd=0x0, waited 5221 msecs Sep 8 22:26:03 localhost kernel: qla2xxx [0000:42:00.2]-680d:22: mmio enabled returning. Sep 8 22:26:03 localhost kernel: qla2xxx [0000:42:00.2]-d04c:22: MBX
Command timeout for cmd 0, iocontrol=ffffffff jiffies=10140f2e5 mb[0-3]=[0xffff 0xffff 0xffff 0xffff]
--- drivers/scsi/qla2xxx/qla_os.c | 10 +++++++++- drivers/scsi/qla2xxx/qla_tmpl.c | 9 +++++++-- 2 files changed, 16 insertions(+), 3 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +9 -1
@@ -7641,7 +7641,7 @@ qla2xxx_pci_error_detected(struct pci_deswitch (state) {case pci_channel_io_normal: - ha->flags.eeh_busy =0 ; +qla_pci_set_eeh_busy (vha);if (ql2xmqsupport || ql2xnvmeenable) {set_bit (QPAIR_ONLINE_CHECK_NEEDED , &vha->dpc_flags);qla2xxx_wake_dpc (vha);
@@ -7682,9 +7682,16 @@ qla2xxx_pci_mmio_enabled(struct pci_dev "mmio enabled\n"); ha->pci_error_state =QLA_PCI_MMIO_ENABLED ; +if (IS_QLA82XX (ha))return PCI_ERS_RESULT_RECOVERED ; +if (qla2x00_isp_reg_stat (ha)) { +ql_log (ql_log_info, base_vha,0x803f , +"During mmio enabled, PCI/Register disconnect still detected.\n" ); + goto out; + } +spin_lock_irqsave (&ha->hardware_lock, flags);if (IS_QLA2100 (ha) ||IS_QLA2200 (ha)){ stat =rd_reg_word (®->hccr);
@@ -7706,6 +7713,7 @@ qla2xxx_pci_mmio_enabled(struct pci_dev "RISC paused -- mmio_enabled, Dumping firmware.\n");qla2xxx_dump_fw (base_vha); } +out:/* set PCI_ERS_RESULT_NEED_RESET to trigger call to qla2xxx_pci_slot_reset */ ql_dbg (ql_dbg_aer, base_vha,0x600d ,"mmio enabled returning.\n" );
drivers/scsi/qla2xxx/qla_tmpl.c +7 -2
@@ -435,8 +435,13 @@ qla27xx_fwdt_entry_t266(struct scsi_qla_ {ql_dbg (ql_dbg_misc, vha,0xd20a ,"%s: reset risc [%lx]\n" , __func__, *len); -if (buf) -WARN_ON_ONCE (qla24xx_soft_reset (vha->hw) !=QLA_SUCCESS ); +if (buf) { +if (qla24xx_soft_reset (vha->hw) !=QLA_SUCCESS ) { +ql_dbg (ql_dbg_async, vha,0x5001 , +"%s: unable to soft reset\n" , __func__); +return INVALID_ENTRY ; + } + }return qla27xx_next_entry (ent); }
Greg Kroah-Hartman
maintainerPATCH 793/913 scsi: qla2xxx: Fix wrong FDMI data for 64G adapter
In reply to Greg Kroah-HartmanFrom: Bikash Hazarika <[email protected]>
commit 1cfbbacbee2d6ea3816386a483e3c7a96e5bd657 upstream.
Corrected transmission speed mask values for FC.
Supported Speed: 16 32 20 Gb/s ===> Should be 64 instead of 20
Supported Speed: 16G 32G 48G ===> Should be 64G instead of 48G
--- drivers/scsi/qla2xxx/qla_def.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_def.h +5 -1
@@ -2891,7 +2891,11 @@ struct ct_fdmi2_hba_attributes {#define FDMI_PORT_SPEED_8GB 0x10#define FDMI_PORT_SPEED_16GB 0x20#define FDMI_PORT_SPEED_32GB 0x40 -#define FDMI_PORT_SPEED_64GB 0x80 +#define FDMI_PORT_SPEED_20GB 0x80 +#define FDMI_PORT_SPEED_40GB 0x100 +#define FDMI_PORT_SPEED_128GB 0x200 +#define FDMI_PORT_SPEED_64GB 0x400 +#define FDMI_PORT_SPEED_256GB 0x800#define FDMI_PORT_SPEED_UNKNOWN 0x8000#define FC_CLASS_2 0x04
Greg Kroah-Hartman
maintainerPATCH 794/913 scsi: qla2xxx: Fix warning for missing error code
In reply to Greg Kroah-HartmanFrom: Nilesh Javali <[email protected]>
commit 14cb838d245ae0d523b2f7804af5a02c22e79f5a upstream.
Fix smatch-reported warning message:
drivers/scsi/qla2xxx/qla_target.c:3324 qlt_xmit_response() warn: missing error code 'res'
--- drivers/scsi/qla2xxx/qla_target.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/qla2xxx/qla_target.c +1 -0
@@ -3318,6 +3318,7 @@ int qlt_xmit_response(struct qla_tgt_cmd"RESET-RSP online/active/old-count/new-count = %d/%d/%d/%d.\n" , vha->flags.online,qla2x00_reset_active (vha), cmd->reset_count, qpair->chip_reset); + res =0 ; goto out_unmap_unlock; }
Greg Kroah-Hartman
maintainerPATCH 795/913 scsi: qla2xxx: Fix device reconnect in loop topology
In reply to Greg Kroah-HartmanFrom: Arun Easi <[email protected]>
commit 8ad4be3d15cf144b5834bdb00d5bbe4050938dc7 upstream.
A device logout in loop topology initiates a device connection teardown which loses the FW device handle. In loop topo, the device handle is not regrabbed leading to device login failures and eventually to loss of the device. Fix this by taking the main login path that does it.
--- drivers/scsi/qla2xxx/qla_init.c | 15 +++++++++++++++ drivers/scsi/qla2xxx/qla_os.c | 5 +++++ 2 files changed, 20 insertions(+)
drivers/scsi/qla2xxx/qla_init.c +15 -0
@@ -975,6 +975,9 @@ static void qla24xx_handle_gnl_done_evenset_bit (RELOGIN_NEEDED , &vha->dpc_flags); }break ; +case ISP_CFG_NL : +qla24xx_fcport_handle_login (vha, fcport); +break ;default :break ; }
@@ -1564,6 +1567,11 @@ static void qla_chk_n2n_b4_login(structu8 login =0 ;int rc; +ql_dbg (ql_dbg_disc, vha,0x307b , +"%s %8phC DS %d LS %d lid %d retries=%d\n" , + __func__, fcport->port_name, fcport->disc_state, + fcport->fw_login_state, fcport->loop_id, fcport->login_retry); +if (qla_tgt_mode_enabled (vha))return ;
@@ -5586,6 +5594,13 @@ qla2x00_configure_local_loop(scsi_qla_homemcpy (fcport->node_name, new_fcport->node_name,WWN_SIZE ); fcport->scan_state =QLA_FCPORT_FOUND ; +if (fcport->login_retry ==0 ) { + fcport->login_retry = vha->hw->login_retry_count; +ql_dbg (ql_dbg_disc, vha,0x2135 , +"Port login retry %8phN, lid 0x%04x retry cnt=%d.\n" , + fcport->port_name, fcport->loop_id, + fcport->login_retry); + } found++;break ; }
drivers/scsi/qla2xxx/qla_os.c +5 -0
@@ -5518,6 +5518,11 @@ void qla2x00_relogin(struct scsi_qla_hos ea.fcport = fcport;qla24xx_handle_relogin_event (vha, &ea); }else if (vha->hw->current_topology == +ISP_CFG_NL && +IS_QLA2XXX_MIDTYPE (vha->hw)) { + (void )qla24xx_fcport_handle_login (vha, + fcport); + }else if (vha->hw->current_topology ==ISP_CFG_NL ) { fcport->login_retry--; status =
Greg Kroah-Hartman
maintainerPATCH 796/913 scsi: qla2xxx: edif: Fix clang warning
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit 73825fd7a37c1a685e9e9e27c9dc91ef1f3e2971 upstream.
Silence compile warning due to unaligned memory access.
qla_edif.c:713:45: warning: taking address of packed member 'u' of class or
structure 'auth_complete_cmd' may result in an unaligned pointer value [-Waddress-of-packed-member]
fcport = qla2x00_find_fcport_by_pid(vha, &appplogiok.u.d_id);
--- drivers/scsi/qla2xxx/qla_edif.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/scsi/qla2xxx/qla_edif.c +19 -3
@@ -668,6 +668,11 @@ qla_edif_app_authok(scsi_qla_host_t *vha bsg_job->request_payload.sg_cnt, &appplogiok, sizeof(struct auth_complete_cmd)); +/* silent unaligned access warning */ + portid.b.domain = appplogiok.u.d_id.b.domain; + portid.b.area = appplogiok.u.d_id.b.area; + portid.b.al_pa = appplogiok.u.d_id.b.al_pa; +switch (appplogiok.type) {case PL_TYPE_WWPN : fcport = qla2x00_find_fcport_by_wwpn(vha,
@@ -678,7 +683,7 @@ qla_edif_app_authok(scsi_qla_host_t *vha __func__, appplogiok.u.wwpn);break ;case PL_TYPE_DID : - fcport =qla2x00_find_fcport_by_pid (vha, &appplogiok.u.d_id); + fcport =qla2x00_find_fcport_by_pid (vha, &portid);if (!fcport) ql_dbg(ql_dbg_edif, vha, 0x911d, "%s d_id lookup failed: %x\n", __func__,
@@ -777,6 +782,11 @@ qla_edif_app_authfail(scsi_qla_host_t *v bsg_job->request_payload.sg_cnt, &appplogifail, sizeof(struct auth_complete_cmd)); +/* silent unaligned access warning */ + portid.b.domain = appplogifail.u.d_id.b.domain; + portid.b.area = appplogifail.u.d_id.b.area; + portid.b.al_pa = appplogifail.u.d_id.b.al_pa; +/* * TODO: edif: app has failed this plogi. Inform driver to * take any action (if any).
@@ -788,7 +798,7 @@ qla_edif_app_authfail(scsi_qla_host_t *vSET_DID_STATUS (bsg_reply->result,DID_OK );break ;case PL_TYPE_DID : - fcport =qla2x00_find_fcport_by_pid (vha, &appplogifail.u.d_id); + fcport =qla2x00_find_fcport_by_pid (vha, &portid);if (!fcport) ql_dbg(ql_dbg_edif, vha, 0x911d, "%s d_id lookup failed: %x\n", __func__,
@@ -1253,6 +1263,7 @@ qla24xx_sadb_update(struct bsg_job *bsg_int result =0 ;struct qla_sa_update_frame sa_frame;struct srb_iocb *iocb_cmd; +port_id_t portid;ql_dbg (ql_dbg_edif + ql_dbg_verbose, vha,0x911d ,"%s entered, vha: 0x%p\n" , __func__, vha);
@@ -1276,7 +1287,12 @@ qla24xx_sadb_update(struct bsg_job *bsg_ goto done; } - fcport =qla2x00_find_fcport_by_pid (vha, &sa_frame.port_id); +/* silent unaligned access warning */ + portid.b.domain = sa_frame.port_id.b.domain; + portid.b.area = sa_frame.port_id.b.area; + portid.b.al_pa = sa_frame.port_id.b.al_pa; + + fcport =qla2x00_find_fcport_by_pid (vha, &portid);if (fcport) { found =1 ;if (sa_frame.flags ==QLA_SA_UPDATE_FLAGS_TX_KEY )
Greg Kroah-Hartman
maintainerPATCH 797/913 scsi: qla2xxx: Fix T10 PI tag escape and IP guard options for 28XX adapters
In reply to Greg Kroah-HartmanFrom: Joe Carnuccio <[email protected]>
commit 4c103a802c69fca63976af6b372ccba39ed74370 upstream.
28XX adapters are capable of detecting both T10 PI tag escape values as well as IP guard. This was missed due to the adapter type missed in the corresponding macros. Fix this by adding support for 28xx in those macros.
--- drivers/scsi/qla2xxx/qla_def.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +4 -2
@@ -4270,8 +4270,10 @@ struct qla_hw_data {#define QLA_ABTS_WAIT_ENABLED (_sp) \ (QLA_NVME_IOS(_sp) && QLA_ABTS_FW_ENABLED(_sp->fcport->vha->hw)) -#define IS_PI_UNINIT_CAPABLE (ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha)) -#define IS_PI_IPGUARD_CAPABLE (ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha)) +#define IS_PI_UNINIT_CAPABLE (ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha) || \ + IS_QLA28XX(ha)) +#define IS_PI_IPGUARD_CAPABLE (ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha) || \ + IS_QLA28XX(ha))#define IS_PI_DIFB_DIX0_CAPABLE (ha) (0)#define IS_PI_SPLIT_DET_CAPABLE_HBA (ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha) || \ IS_QLA28XX(ha))
Greg Kroah-Hartman
maintainerPATCH 798/913 scsi: qla2xxx: Add devids and conditionals for 28xx
In reply to Greg Kroah-HartmanFrom: Joe Carnuccio <[email protected]>
commit 0d6a536cb1fcabb6c3e9c94871c8d0b29bb5813b upstream.
This is an update to the original 28xx adapter enablement. Add a bunch of conditionals that are applicable for 28xx.
--- drivers/scsi/qla2xxx/qla_attr.c | 7 ++----- drivers/scsi/qla2xxx/qla_init.c | 8 +++----- drivers/scsi/qla2xxx/qla_mbx.c | 14 +++++++++++--- drivers/scsi/qla2xxx/qla_os.c | 3 +-- drivers/scsi/qla2xxx/qla_sup.c | 4 ++-- drivers/scsi/qla2xxx/qla_target.c | 3 +-- 6 files changed, 20 insertions(+), 19 deletions(-)
drivers/scsi/qla2xxx/qla_attr.c +2 -5
@@ -555,7 +555,7 @@ qla2x00_sysfs_read_vpd(struct file *filpif (!capable (CAP_SYS_ADMIN ))return -EINVAL ; -if (IS_NOCACHE_VPD_TYPE (ha)) +if (!IS_NOCACHE_VPD_TYPE (ha)) goto skip; faddr = ha->flt_region_vpd <<2 ;
@@ -745,7 +745,7 @@ qla2x00_sysfs_write_reset(struct file *fql_log (ql_log_info, vha,0x706f ,"Issuing MPI reset.\n" ); -if (IS_QLA83XX (ha) ||IS_QLA27XX (ha) ||IS_QLA28XX (ha)) { +if (IS_QLA83XX (ha)) {uint32_t idc_control;qla83xx_idc_lock (vha,0 );
@@ -1056,9 +1056,6 @@ qla2x00_free_sysfs_attr(scsi_qla_host_tcontinue ;if (iter->type ==3 && !(IS_CNA_CAPABLE (ha)))continue ; -if (iter->type ==0x27 && - (!IS_QLA27XX (ha) || !IS_QLA28XX (ha))) -continue ;sysfs_remove_bin_file (&host->shost_gendev.kobj, iter->attr);
drivers/scsi/qla2xxx/qla_init.c +3 -5
@@ -3473,7 +3473,7 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *v mem_size = (ha->fw_memory_size -0x11000 +1 ) *sizeof (uint16_t ); }else if (IS_FWI2_CAPABLE (ha)) { -if (IS_QLA83XX (ha) ||IS_QLA27XX (ha) ||IS_QLA28XX (ha)) +if (IS_QLA83XX (ha)) fixed_size = offsetof(struct qla83xx_fw_dump , ext_mem);else if (IS_QLA81XX (ha)) fixed_size = offsetof(struct qla81xx_fw_dump , ext_mem);
@@ -3485,8 +3485,7 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *v mem_size = (ha->fw_memory_size -0x100000 +1 ) *sizeof (uint32_t );if (ha->mqenable) { -if (!IS_QLA83XX (ha) && !IS_QLA27XX (ha) && - !IS_QLA28XX (ha)) +if (!IS_QLA83XX (ha)) mq_size =sizeof (struct qla2xxx_mq_chain );/* * Allocate maximum buffer size for all queues - Q0.
@@ -4047,8 +4046,7 @@ enable_82xx_npiv: ha->fw_major_version, ha->fw_minor_version, ha->fw_subminor_version); -if (IS_QLA83XX (ha) ||IS_QLA27XX (ha) || -IS_QLA28XX (ha)) { +if (IS_QLA83XX (ha)) { ha->flags.fac_supported =0 ; rval =QLA_SUCCESS ; }
drivers/scsi/qla2xxx/qla_mbx.c +11 -3
@@ -9,6 +9,12 @@#include <linux/delay.h> #include <linux/gfp.h> +#ifdef CONFIG_PPC +#define IS_PPCARCH true +#else +#define IS_PPCARCH false +#endif + static struct mb_cmd_name { uint16_t cmd; const char *str;
@@ -728,6 +734,9 @@ again: vha->min_supported_speed = nv->min_supported_speed; } + +if (IS_PPCARCH ) + mcp->mb[11 ] |=BIT_4 ; }if (ha->flags.exlogins_enabled)
@@ -3029,8 +3038,7 @@ qla2x00_get_resource_cnts(scsi_qla_host_ ha->orig_fw_iocb_count = mcp->mb[10 ];if (ha->flags.npiv_supported) ha->max_npiv_vports = mcp->mb[11 ]; -if (IS_QLA81XX (ha) ||IS_QLA83XX (ha) ||IS_QLA27XX (ha) || -IS_QLA28XX (ha)) +if (IS_QLA81XX (ha) ||IS_QLA83XX (ha)) ha->fw_max_fcf_count = mcp->mb[12 ]; }
@@ -5621,7 +5629,7 @@ qla2x00_get_data_rate(scsi_qla_host_t *v mcp->out_mb =MBX_1 |MBX_0 ; mcp->in_mb =MBX_2 |MBX_1 |MBX_0 ;if (IS_QLA83XX (ha) ||IS_QLA27XX (ha) ||IS_QLA28XX (ha)) - mcp->in_mb |=MBX_3 ; + mcp->in_mb |=MBX_4 |MBX_3 ; mcp->tov =MBX_TOV_SECONDS ; mcp->flags =0 ; rval =qla2x00_mailbox_command (vha, mcp);
drivers/scsi/qla2xxx/qla_os.c +1 -2
@@ -3739,8 +3739,7 @@ qla2x00_unmap_iobases(struct qla_hw_dataif (ha->mqiobase)iounmap (ha->mqiobase); -if ((IS_QLA83XX (ha) ||IS_QLA27XX (ha) ||IS_QLA28XX (ha)) && - ha->msixbase) +if (ha->msixbase)iounmap (ha->msixbase); } }
drivers/scsi/qla2xxx/qla_sup.c +2 -2
@@ -844,7 +844,7 @@ qla2xxx_get_flt_info(scsi_qla_host_t *vh ha->flt_region_nvram = start;break ;case FLT_REG_IMG_PRI_27XX : -if (IS_QLA27XX (ha) && !IS_QLA28XX (ha)) +if (IS_QLA27XX (ha) ||IS_QLA28XX (ha)) ha->flt_region_img_status_pri = start;break ;case FLT_REG_IMG_SEC_27XX :
@@ -1356,7 +1356,7 @@ next: flash_data_addr(ha, faddr), le32_to_cpu(*dwptr));if (ret) {ql_dbg (ql_dbg_user, vha,0x7006 , -"Failed slopw write %x (%x)\n" , faddr, *dwptr); +"Failed slow write %x (%x)\n" , faddr, *dwptr);break ; } }
drivers/scsi/qla2xxx/qla_target.c +1 -2
@@ -7220,8 +7220,7 @@ qlt_probe_one_stage1(struct scsi_qla_hosif (!QLA_TGT_MODE_ENABLED ())return ; -if ((ql2xenablemsix ==0 ) ||IS_QLA83XX (ha) ||IS_QLA27XX (ha) || -IS_QLA28XX (ha)) { +if (ha->mqenable ||IS_QLA83XX (ha) ||IS_QLA27XX (ha) ||IS_QLA28XX (ha)) {ISP_ATIO_Q_IN (base_vha) = &ha->mqiobase->isp25mq.atio_q_in;ISP_ATIO_Q_OUT (base_vha) = &ha->mqiobase->isp25mq.atio_q_out; }else {
Greg Kroah-Hartman
maintainerPATCH 799/913 scsi: qla2xxx: Check for firmware dump already collected
In reply to Greg Kroah-HartmanFrom: Joe Carnuccio <[email protected]>
commit cfbafad7c6032d449a5a07f2d273acd2437bbc6a upstream.
While allocating firmware dump, check if dump is already collected and do not re-allocate the buffer.
--- drivers/scsi/qla2xxx/qla_init.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/scsi/qla2xxx/qla_init.c +8 -0
@@ -3463,6 +3463,14 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vstruct rsp_que *rsp = ha->rsp_q_map[0 ];struct qla2xxx_fw_dump *fw_dump; +if (ha->fw_dump) { +ql_dbg (ql_dbg_init, vha,0x00bd , +"Firmware dump already allocated.\n" ); +return ; + } + + ha->fw_dumped =0 ; + ha->fw_dump_cap_flags =0 ; dump_size = fixed_size = mem_size = eft_size = fce_size = mq_size =0 ; req_q_size = rsp_q_size =0 ;
Greg Kroah-Hartman
maintainerPATCH 800/913 scsi: qla2xxx: Suppress a kernel complaint in qla_create_qpair()
In reply to Greg Kroah-HartmanFrom: Saurav Kashyap <[email protected]>
commit a60447e7d451df42c7bde43af53b34f10f34f469 upstream.
[ 12.323788] BUG: using smp_processor_id() in preemptible [00000000] code: systemd-udevd/1020 [ 12.332297] caller is qla2xxx_create_qpair+0x32a/0x5d0 [qla2xxx] [ 12.338417] CPU: 7 PID: 1020 Comm: systemd-udevd Tainted: G I --------- --- 5.14.0-29.el9.x86_64 #1 [ 12.348827] Hardware name: Dell Inc. PowerEdge R610/0F0XJ6, BIOS 6.6.0 05/22/2018 [ 12.356356] Call Trace: [ 12.358821] dump_stack_lvl+0x34/0x44 [ 12.362514] check_preemption_disabled+0xd9/0xe0 [ 12.367164] qla2xxx_create_qpair+0x32a/0x5d0 [qla2xxx] [ 12.372481] qla2x00_probe_one+0xa3a/0x1b80 [qla2xxx] [ 12.377617] ? _raw_spin_lock_irqsave+0x19/0x40 [ 12.384284] local_pci_probe+0x42/0x80 [ 12.390162] ? pci_match_device+0xd7/0x110 [ 12.396366] pci_device_probe+0xfd/0x1b0 [ 12.402372] really_probe+0x1e7/0x3e0 [ 12.408114] __driver_probe_device+0xfe/0x180 [ 12.414544] driver_probe_device+0x1e/0x90 [ 12.420685] __driver_attach+0xc0/0x1c0 [ 12.426536] ? __device_attach_driver+0xe0/0xe0 [ 12.433061] ? __device_attach_driver+0xe0/0xe0 [ 12.439538] bus_for_each_dev+0x78/0xc0 [ 12.445294] bus_add_driver+0x12b/0x1e0 [ 12.451021] driver_register+0x8f/0xe0 [ 12.456631] ? 0xffffffffc07bc000 [ 12.461773] qla2x00_module_init+0x1be/0x229 [qla2xxx] [ 12.468776] do_one_initcall+0x44/0x200 [ 12.474401] ? load_module+0xad3/0xba0 [ 12.479908] ? kmem_cache_alloc_trace+0x45/0x410 [ 12.486268] do_init_module+0x5c/0x280 [ 12.491730] __do_sys_init_module+0x12e/0x1b0 [ 12.497785] do_syscall_64+0x3b/0x90 [ 12.503029] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 12.509764] RIP: 0033:0x7f554f73ab2e
--- drivers/scsi/qla2xxx/qla_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_init.c +1 -1
@@ -9393,7 +9393,7 @@ struct qla_qpair *qla2xxx_create_qpair(s qpair->rsp->req = qpair->req; qpair->rsp->qpair = qpair;/* init qpair to this cpu. Will adjust at run time. */ -qla_cpu_update (qpair,smp_processor_id ()); +qla_cpu_update (qpair,raw_smp_processor_id ());if (IS_T10_PI_CAPABLE (ha) && ql2xenabledif) {if (ha->fw_attributes &BIT_4 )
Greg Kroah-Hartman
maintainerPATCH 801/913 scsi: qla2xxx: Fix disk failure to rediscover
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit 6a45c8e137d4e2c72eecf1ac7cf64f2fdfcead99 upstream.
User experienced some of the LUN failed to get rediscovered after long cable pull test. The issue is triggered by a race condition between driver setting session online state vs starting the LUN scan process at the same time. Current code set the online state after notifying the session is available. In this case, trigger to start the LUN scan process happened before driver could set the session in online state. LUN scan ends up with failure due to the session online check was failing.
Set the online state before reporting of the availability of the session.
--- drivers/scsi/qla2xxx/qla_init.c | 5 +++-- drivers/scsi/qla2xxx/qla_nvme.c | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +3 -2
@@ -5740,6 +5740,8 @@ qla2x00_reg_remote_port(scsi_qla_host_tif (atomic_read (&fcport->state) ==FCS_ONLINE )return ; +qla2x00_set_fcport_state (fcport,FCS_ONLINE ); + rport_ids.node_name =wwn_to_u64 (fcport->node_name); rport_ids.port_name =wwn_to_u64 (fcport->port_name); rport_ids.port_id = fcport->d_id.b.domain << 16 |
@@ -5847,6 +5849,7 @@ qla2x00_update_fcport(scsi_qla_host_t *vqla2x00_reg_remote_port (vha, fcport);break ;case MODE_TARGET : +qla2x00_set_fcport_state (fcport,FCS_ONLINE );if (!vha->vha_tgt.qla_tgt->tgt_stop && !vha->vha_tgt.qla_tgt->tgt_stopped)qlt_fc_port_added (vha, fcport);
@@ -5861,8 +5864,6 @@ qla2x00_update_fcport(scsi_qla_host_t *vbreak ; } -qla2x00_set_fcport_state (fcport,FCS_ONLINE ); -if (IS_IIDMA_CAPABLE (vha->hw) && vha->hw->flags.gpsc_supported) {if (fcport->id_changed) { fcport->id_changed =0 ;
drivers/scsi/qla2xxx/qla_nvme.c +5 -0
@@ -35,6 +35,11 @@ int qla_nvme_register_remote(struct scsi (fcport->nvme_flag & NVME_FLAG_REGISTERED))return 0 ; +if (atomic_read (&fcport->state) ==FCS_ONLINE ) +return 0 ; + +qla2x00_set_fcport_state (fcport,FCS_ONLINE ); + fcport->nvme_flag &= ~NVME_FLAG_RESETTING ;memset (&req,0 ,sizeof (struct nvme_fc_port_info ));
Greg Kroah-Hartman
maintainerPATCH 802/913 scsi: qla2xxx: Fix incorrect reporting of task management failure
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit 58ca5999e0367d131de82a75257fbfd5aed0195d upstream.
User experienced no task management error while target device is responding with error. The RSP_CODE field in the status IOCB is in little endian. Driver assumes it's big endian and it picked up erroneous data.
Convert the data back to big endian as is on the wire.
--- drivers/scsi/qla2xxx/qla_isr.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/qla2xxx/qla_isr.c +1 -0
@@ -2494,6 +2494,7 @@ qla24xx_tm_iocb_entry(scsi_qla_host_t *v iocb->u.tmf.data =QLA_FUNCTION_FAILED ; }else if ((le16_to_cpu (sts->scsi_status) &SS_RESPONSE_INFO_LEN_VALID )) { +host_to_fcp_swap (sts->data,sizeof (sts->data));if (le32_to_cpu (sts->rsp_data_len) <4 ) { ql_log(ql_log_warn, fcport->vha, 0x503b, "Async-%s error - hdl=%x not enough response(%d).\n",
Greg Kroah-Hartman
maintainerPATCH 803/913 scsi: qla2xxx: Fix hang due to session stuck
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit c02aada06d19a215c8291bd968a99a270e96f734 upstream.
User experienced device lost. The log shows Get port data base command was queued up, failed, and requeued again. Every time it is requeued, it set the FCF_ASYNC_ACTIVE. This prevents any recovery code from occurring because driver thinks a recovery is in progress for this session. In essence, this session is hung. The reason it gets into this place is the session deletion got in front of this call due to link perturbation.
Break the requeue cycle and exit. The session deletion code will trigger a session relogin.
--- drivers/scsi/qla2xxx/qla_def.h | 4 ++++ drivers/scsi/qla2xxx/qla_init.c | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +4 -0
@@ -5438,4 +5438,8 @@ struct ql_vnd_tgt_stats_resp {#include "qla_gbl.h" #include "qla_dbg.h" #include "qla_inline.h" + +#define IS_SESSION_DELETED (_fcport) (_fcport->disc_state == DSC_DELETE_PEND || \ + _fcport->disc_state == DSC_DELETED) +#endif
drivers/scsi/qla2xxx/qla_init.c +17 -2
@@ -576,6 +576,14 @@ qla2x00_async_adisc(struct scsi_qla_hoststruct srb_iocb *lio;int rval =QLA_FUNCTION_FAILED ; +if (IS_SESSION_DELETED (fcport)) { +ql_log (ql_log_warn, vha,0xffff , +"%s: %8phC is being delete - not sending command.\n" , + __func__, fcport->port_name); + fcport->flags &= ~FCF_ASYNC_ACTIVE ; +return rval; + } +if (!vha->flags.online || (fcport->flags &FCF_ASYNC_SENT ))return rval;
@@ -1339,8 +1347,15 @@ int qla24xx_async_gpdb(struct scsi_qla_hstruct port_database_24xx *pd;struct qla_hw_data *ha = vha->hw; -if (!vha->flags.online || (fcport->flags &FCF_ASYNC_SENT ) || - fcport->loop_id ==FC_NO_LOOP_ID ) { +if (IS_SESSION_DELETED (fcport)) { +ql_log (ql_log_warn, vha,0xffff , +"%s: %8phC is being delete - not sending command.\n" , + __func__, fcport->port_name); + fcport->flags &= ~FCF_ASYNC_ACTIVE ; +return rval; + } + +if (!vha->flags.online || fcport->flags &FCF_ASYNC_SENT ) {ql_log (ql_log_warn, vha,0xffff ,"%s: %8phC online %d flags %x - not sending command.\n" , __func__, fcport->port_name, vha->flags.online, fcport->flags);
Greg Kroah-Hartman
maintainerPATCH 804/913 scsi: qla2xxx: Fix missed DMA unmap for NVMe ls requests
In reply to Greg Kroah-HartmanFrom: Arun Easi <[email protected]>
commit c85ab7d9e27a80e48d5b7d7fb2fe2b0fdb2de523 upstream.
At NVMe ELS request time, request structure is DMA mapped and never unmapped. Fix this by calling the unmap on ELS completion.
--- drivers/scsi/qla2xxx/qla_nvme.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/scsi/qla2xxx/qla_nvme.c +17 -0
@@ -170,6 +170,18 @@ out:qla2xxx_rel_qpair_sp (sp->qpair, sp); } +static void qla_nvme_ls_unmap (struct srb *sp,struct nvmefc_ls_req *fd) +{ +if (sp->flags &SRB_DMA_VALID ) { +struct srb_iocb *nvme = &sp->u.iocb_cmd; +struct qla_hw_data *ha = sp->fcport->vha->hw; + +dma_unmap_single (&ha->pdev->dev, nvme->u.nvme.cmd_dma, + fd->rqstlen,DMA_TO_DEVICE ); + sp->flags &= ~SRB_DMA_VALID ; + } +} +static void qla_nvme_release_ls_cmd_kref (struct kref *kref) { struct srb *sp = container_of(kref, struct srb, cmd_kref);
@@ -186,6 +198,8 @@ static void qla_nvme_release_ls_cmd_krefspin_unlock_irqrestore (&priv->cmd_lock, flags); fd = priv->fd; + +qla_nvme_ls_unmap (sp, fd); fd->done (fd, priv->comp_status); out:qla2x00_rel_sp (sp);
@@ -356,6 +370,8 @@ static int qla_nvme_ls_req(struct nvme_fdma_sync_single_for_device (&ha->pdev->dev, nvme->u.nvme.cmd_dma, fd->rqstlen,DMA_TO_DEVICE ); + sp->flags |=SRB_DMA_VALID ; + rval =qla2x00_start_sp (sp);if (rval !=QLA_SUCCESS ) { ql_log(ql_log_warn, vha, 0x700e,
@@ -363,6 +379,7 @@ static int qla_nvme_ls_req(struct nvme_fwake_up (&sp->nvme_ls_waitq); sp->priv =NULL ; priv->sp =NULL ; +qla_nvme_ls_unmap (sp, fd);qla2x00_rel_sp (sp);return rval; }
Greg Kroah-Hartman
maintainerPATCH 805/913 scsi: qla2xxx: Fix N2N inconsistent PLOGI
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit c13ce47c64ea8f14e77eecb40d1e7c2ac667f898 upstream.
For N2N topology, ELS Passthrough is used to send PLOGI. On failure of ELS pass through PLOGI, driver flipped over to using LLIOCB PLOGI for N2N. This is not consistent. Delete the session to restart the connection where ELS pass through PLOGI would be used consistently.
--- drivers/scsi/qla2xxx/qla_iocb.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/scsi/qla2xxx/qla_iocb.c +3 -5
@@ -2943,6 +2943,7 @@ static void qla2x00_els_dcmd2_sp_done(srset_bit (ISP_ABORT_NEEDED , &vha->dpc_flags);qla2xxx_wake_dpc (vha); +break ; } fallthrough;default :
@@ -2952,9 +2953,7 @@ static void qla2x00_els_dcmd2_sp_done(sr fw_status[0], fw_status[1], fw_status[2]); fcport->flags &= ~FCF_ASYNC_SENT ; -qla2x00_set_fcport_disc_state (fcport, -DSC_LOGIN_FAILED ); -set_bit (RELOGIN_NEEDED , &vha->dpc_flags); +qlt_schedule_sess_for_deletion (fcport);break ; }break ;
@@ -2966,8 +2965,7 @@ static void qla2x00_els_dcmd2_sp_done(sr fw_status[0], fw_status[1], fw_status[2]); sp->fcport->flags &= ~FCF_ASYNC_SENT ; -qla2x00_set_fcport_disc_state (fcport,DSC_LOGIN_FAILED ); -set_bit (RELOGIN_NEEDED , &vha->dpc_flags); +qlt_schedule_sess_for_deletion (fcport);break ; }
Greg Kroah-Hartman
maintainerPATCH 806/913 scsi: qla2xxx: Fix stuck session of PRLI reject
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit f3502e2e98a92981601edc3dadf4b0f43c79836b upstream.
Remove stale recovery code that prevents normal path recovery.
--- drivers/scsi/qla2xxx/qla_init.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +0 -7
@@ -2085,13 +2085,6 @@ qla24xx_handle_prli_done_event(struct scqla24xx_post_gpdb_work (vha, ea->fcport,0 );break ;default : -if ((ea->iop[0 ] ==LSC_SCODE_ELS_REJECT ) && - (ea->iop[1 ] ==0x50000 )) {/* reson 5=busy expl:0x0 */ -set_bit (RELOGIN_NEEDED , &vha->dpc_flags); - ea->fcport->fw_login_state =DSC_LS_PLOGI_COMP ; -break ; - } - sp = ea->sp; ql_dbg(ql_dbg_disc, vha, 0x2118, "%s %d %8phC priority %s, fc4type %x prev try %s\n",
Greg Kroah-Hartman
maintainerPATCH 807/913 scsi: qla2xxx: Reduce false trigger to login
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit d2646eed7b19a206912f49101178cbbaa507256c upstream.
While a session is in the middle of a relogin, a late RSCN can be delivered from switch. RSCN trigger fabric scan where the scan logic can trigger another session login while a login is in progress. Reduce the extra trigger to prevent multiple logins to the same session.
--- drivers/scsi/qla2xxx/qla_init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +3 -2
@@ -1645,7 +1645,8 @@ int qla24xx_fcport_handle_login(struct s fcport->login_gen, fcport->loop_id, fcport->scan_state, fcport->fc4_type); -if (fcport->scan_state !=QLA_FCPORT_FOUND ) +if (fcport->scan_state !=QLA_FCPORT_FOUND || + fcport->disc_state ==DSC_DELETE_PEND )return 0 ; if ((fcport->loop_id != FC_NO_LOOP_ID) &&
@@ -1666,7 +1667,7 @@ int qla24xx_fcport_handle_login(struct sif (vha->host->active_mode ==MODE_TARGET && !N2N_TOPO (vha->hw))return 0 ; -if (fcport->flags &FCF_ASYNC_SENT ) { +if (fcport->flags & (FCF_ASYNC_SENT |FCF_ASYNC_ACTIVE )) {set_bit (RELOGIN_NEEDED , &vha->dpc_flags);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 808/913 scsi: qla2xxx: Use correct feature type field during RFF_ID processing
In reply to Greg Kroah-HartmanFrom: Manish Rangankar <[email protected]>
commit a7e05f7a1bcbe4ee055479242de46c5c16ab03b1 upstream.
During SNS Register FC-4 Features (RFF_ID) the initiator driver was sending incorrect type field for NVMe supported device. Use correct feature type field.
--- drivers/scsi/qla2xxx/qla_gs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/scsi/qla2xxx/qla_gs.c +2 -3
@@ -676,8 +676,7 @@ qla2x00_rff_id(scsi_qla_host_t *vha, u8return (QLA_SUCCESS ); } -return qla_async_rffid (vha, &vha->d_id,qlt_rff_id (vha), -FC4_TYPE_FCP_SCSI ); +return qla_async_rffid (vha, &vha->d_id,qlt_rff_id (vha), type); } static int qla_async_rffid(scsi_qla_host_t *vha, port_id_t *d_id,
@@ -729,7 +728,7 @@ static int qla_async_rffid(scsi_qla_host/* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */ ct_req->req.rff_id.port_id =port_id_to_be_id (*d_id); ct_req->req.rff_id.fc4_feature = fc4feature; - ct_req->req.rff_id.fc4_type = fc4type;/* SCSI - FCP */ + ct_req->req.rff_id.fc4_type = fc4type;/* SCSI-FCP or FC-NVMe */ sp->u.iocb_cmd.u.ctarg.req_size =RFF_ID_REQ_SIZE ; sp->u.iocb_cmd.u.ctarg.rsp_size =RFF_ID_RSP_SIZE ;
Greg Kroah-Hartman
maintainerPATCH 809/913 platform: chrome: Split trace include file
In reply to Greg Kroah-HartmanFrom: Gwendal Grignou <[email protected]>
commit eabd9a3807e17e211690e6c40f1405b427b64c48 upstream.
cros_ec_trace.h defined 5 tracing events, 2 for cros_ec_proto and 3 for cros_ec_sensorhub_ring.
These 2 files are in different kernel modules, the traces are defined twice in the kernel which leads to problem enabling only some traces.
Move sensorhub traces from cros_ec_trace.h to cros_ec_sensorhub_trace.h and enable them only in cros_ec_sensorhub kernel module.
Check we can now enable any single traces: without this patch, we can only enable all sensorhub traces or none.
--- drivers/platform/chrome/Makefile | 3 drivers/platform/chrome/cros_ec_sensorhub_ring.c | 3 drivers/platform/chrome/cros_ec_sensorhub_trace.h | 123 ++++++++++++++++++++++ drivers/platform/chrome/cros_ec_trace.h | 95 ---------------- 4 files changed, 127 insertions(+), 97 deletions(-) create mode 100644 drivers/platform/chrome/cros_ec_sensorhub_trace.h
drivers/platform/chrome/Makefile +2 -1
@@ -2,6 +2,7 @@ # tell define_trace.h where to find the cros ec trace header CFLAGS_cros_ec_trace.o:= -I$(src) +CFLAGS_cros_ec_sensorhub_ring.o:= -I$(src) obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o obj-$(CONFIG_CHROMEOS_PSTORE) += chromeos_pstore.o
@@ -20,7 +21,7 @@ obj-$(CONFIG_CROS_EC_CHARDEV) += cros_e obj-$(CONFIG_CROS_EC_LIGHTBAR) += cros_ec_lightbar.o obj-$(CONFIG_CROS_EC_VBC) += cros_ec_vbc.o obj-$(CONFIG_CROS_EC_DEBUGFS) += cros_ec_debugfs.o -cros-ec-sensorhub-objs := cros_ec_sensorhub.o cros_ec_sensorhub_ring.o cros_ec_trace.o +cros-ec-sensorhub-objs := cros_ec_sensorhub.o cros_ec_sensorhub_ring.o obj-$(CONFIG_CROS_EC_SENSORHUB) += cros-ec-sensorhub.o obj-$(CONFIG_CROS_EC_SYSFS) += cros_ec_sysfs.o obj-$(CONFIG_CROS_USBPD_LOGGER) += cros_usbpd_logger.o
drivers/platform/chrome/cros_ec_sensorhub_ring.c +2 -1
@@ -17,7 +17,8 @@#include <linux/sort.h> #include <linux/slab.h> -#include "cros_ec_trace.h" +#define CREATE_TRACE_POINTS +#include "cros_ec_sensorhub_trace.h" /* Precision of fixed point for the m values from the filter */ #define M_PRECISION BIT(23)
drivers/platform/chrome/cros_ec_sensorhub_trace.h new file +123 -0
123 lines not on this page · raw message
drivers/platform/chrome/cros_ec_trace.h +0 -95
107 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 810/913 KVM: x86: Check lapic_in_kernel() before attempting to set a SynIC irq
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit 7ec37d1cbe17d8189d9562178d8b29167fe1c31a upstream.
When KVM_CAP_HYPERV_SYNIC{,2} is activated, KVM already checks for irqchip_in_kernel() so normally SynIC irqs should never be set. It is, however, possible for a misbehaving VMM to write to SYNIC/STIMER MSRs causing erroneous behavior.
The immediate issue being fixed is that kvm_irq_delivery_to_apic() (kvm_irq_delivery_to_apic_fast()) crashes when called with 'irq.shorthand = APIC_DEST_SELF' and 'src == NULL'.
Message-Id: <[email protected]>
--- arch/x86/kvm/hyperv.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kvm/hyperv.c +3 -0
@@ -446,6 +446,9 @@ static int synic_set_irq(struct kvm_vcpustruct kvm_lapic_irq irq;int ret, vector; +if (KVM_BUG_ON (!lapic_in_kernel (vcpu), vcpu->kvm)) +return -EINVAL ; +if (sint >=ARRAY_SIZE (synic->sint))return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 811/913 KVM: x86: Avoid theoretical NULL pointer dereference in kvm_irq_delivery_to_apic_fast()
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit 00b5f37189d24ac3ed46cb7f11742094778c46ce upstream.
When kvm_irq_delivery_to_apic_fast() is called with APIC_DEST_SELF shorthand, 'src' must not be NULL. Crash the VM with KVM_BUG_ON() instead of crashing the host.
Message-Id: <[email protected]>
--- arch/x86/kvm/lapic.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/kvm/lapic.c +4 -0
@@ -987,6 +987,10 @@ bool kvm_irq_delivery_to_apic_fast(struc *r =-1 ;if (irq->shorthand ==APIC_DEST_SELF ) { +if (KVM_BUG_ON (!src, kvm)) { + *r =0 ; +return true; + } *r =kvm_apic_set_irq (src->vcpu, irq, dest_map);return true; }
Greg Kroah-Hartman
maintainerPATCH 812/913 KVM: x86: Forbid VMM to set SYNIC/STIMER MSRs when SynIC wasnt activated
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit b1e34d325397a33d97d845e312d7cf2a8b646b44 upstream.
Setting non-zero values to SYNIC/STIMER MSRs activates certain features, this should not happen when KVM_CAP_HYPERV_SYNIC{,2} was not activated.
Note, it would've been better to forbid writing anything to SYNIC/STIMER MSRs, including zeroes, however, at least QEMU tries clearing HV_X64_MSR_STIMER0_CONFIG without SynIC. HV_X64_MSR_EOM MSR is somewhat 'special' as writing zero there triggers an action, this also should not happen when SynIC wasn't activated.
Message-Id: <[email protected]>
--- arch/x86/kvm/hyperv.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/x86/kvm/hyperv.c +6 -3
@@ -236,7 +236,7 @@ static int synic_set_msr(struct kvm_vcpustruct kvm_vcpu *vcpu =hv_synic_to_vcpu (synic);int ret; -if (!synic->active && !host) +if (!synic->active && (!host || data))return 1 ;trace_kvm_hv_synic_set_msr (vcpu->vcpu_id, msr, data, host);
@@ -282,6 +282,9 @@ static int synic_set_msr(struct kvm_vcpucase HV_X64_MSR_EOM : {int i; +if (!synic->active) +break ; +for (i =0 ; i <ARRAY_SIZE (synic->sint); i++)kvm_hv_notify_acked_sint (vcpu, i);break ;
@@ -661,7 +664,7 @@ static int stimer_set_config(struct kvm_struct kvm_vcpu_hv *hv_vcpu =to_hv_vcpu (vcpu);struct kvm_vcpu_hv_synic *synic =to_hv_synic (vcpu); -if (!synic->active && !host) +if (!synic->active && (!host || config))return 1 ; if (unlikely(!host && hv_vcpu->enforce_cpuid && new_config.direct_mode &&
@@ -690,7 +693,7 @@ static int stimer_set_count(struct kvm_vstruct kvm_vcpu *vcpu =hv_stimer_to_vcpu (stimer);struct kvm_vcpu_hv_synic *synic =to_hv_synic (vcpu); -if (!synic->active && !host) +if (!synic->active && (!host || count))return 1 ; trace_kvm_hv_stimer_set_count(hv_stimer_to_vcpu(stimer)->vcpu_id,
Greg Kroah-Hartman
maintainerPATCH 813/913 KVM: Prevent module exit until all VMs are freed
In reply to Greg Kroah-HartmanFrom: David Matlack <[email protected]>
commit 5f6de5cbebee925a612856fce6f9182bb3eee0db upstream.
Tie the lifetime the KVM module to the lifetime of each VM via kvm.users_count. This way anything that grabs a reference to the VM via kvm_get_kvm() cannot accidentally outlive the KVM module.
Prior to this commit, the lifetime of the KVM module was tied to the lifetime of /dev/kvm file descriptors, VM file descriptors, and vCPU file descriptors by their respective file_operations "owner" field. This approach is insufficient because references grabbed via kvm_get_kvm() do not prevent closing any of the aforementioned file descriptors.
This fixes a long standing theoretical bug in KVM that at least affects async page faults. kvm_setup_async_pf() grabs a reference via kvm_get_kvm(), and drops it in an asynchronous work callback. Nothing prevents the VM file descriptor from being closed and the KVM module from being unloaded before this callback runs.
Message-Id: <[email protected]>
--- virt/kvm/kvm_main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
virt/kvm/kvm_main.c +13 -0
@@ -117,6 +117,8 @@ EXPORT_SYMBOL_GPL(kvm_debugfs_dir);static const struct file_operations stat_fops_per_vm; +static struct file_operations kvm_chardev_ops; +static long kvm_vcpu_ioctl (struct file *file,unsigned int ioctl,unsigned long arg);#ifdef CONFIG_KVM_COMPAT
@@ -1099,6 +1101,16 @@ static struct kvm *kvm_create_vm(unsignepreempt_notifier_inc ();kvm_init_pm_notifier (kvm); +/* +* When the fd passed to this ioctl() is opened it pins the module, +* but try_module_get() also prevents getting a reference if the module +* is in MODULE_STATE_GOING (e.g. if someone ran "rmmod --wait"). +*/ +if (!try_module_get (kvm_chardev_ops.owner)) { + r = -ENODEV ; + goto out_err; + } +return kvm; out_err:
@@ -1188,6 +1200,7 @@ static void kvm_destroy_vm(struct kvm *kpreempt_notifier_dec ();hardware_disable_all ();mmdrop (mm); +module_put (kvm_chardev_ops.owner); }void kvm_get_kvm (struct kvm *kvm)
Greg Kroah-Hartman
maintainerPATCH 814/913 KVM: x86: fix sending PV IPI
In reply to Greg Kroah-HartmanFrom: Li RongQing <[email protected]>
commit c15e0ae42c8e5a61e9aca8aac920517cf7b3e94e upstream.
If apic_id is less than min, and (max - apic_id) is greater than KVM_IPI_CLUSTER_SIZE, then the third check condition is satisfied but the new apic_id does not fit the bitmask. In this case __send_ipi_mask should send the IPI.
This is mostly theoretical, but it can happen if the apic_ids on three iterations of the loop are for example 1, KVM_IPI_CLUSTER_SIZE, 0.
Message-Id: <[email protected]>
--- arch/x86/kernel/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/kvm.c +1 -1
@@ -510,7 +510,7 @@ static void __send_ipi_mask(const struct }else if (apic_id < min && max - apic_id <KVM_IPI_CLUSTER_SIZE ) { ipi_bitmap <<= min - apic_id; min = apic_id; - }else if (apic_id < min +KVM_IPI_CLUSTER_SIZE ) { + }else if (apic_id > min && apic_id < min +KVM_IPI_CLUSTER_SIZE ) { max = apic_id < max ? max : apic_id; }else { ret = kvm_hypercall4(KVM_HC_SEND_IPI, (unsigned long)ipi_bitmap,
Greg Kroah-Hartman
maintainerPATCH 815/913 KVM: SVM: fix panic on out-of-bounds guest IRQ
In reply to Greg Kroah-HartmanFrom: Yi Wang <[email protected]>
commit a80ced6ea514000d34bf1239d47553de0d1ee89e upstream.
As guest_irq is coming from KVM_IRQFD API call, it may trigger crash in svm_update_pi_irte() due to out-of-bounds:
crash> bt
PID: 22218 TASK: ffff951a6ad74980 CPU: 73 COMMAND: "vcpu8"
#0 [ffffb1ba6707fa40] machine_kexec at ffffffff8565b397 #1 [ffffb1ba6707fa90] __crash_kexec at ffffffff85788a6d #2 [ffffb1ba6707fb58] crash_kexec at ffffffff8578995d #3 [ffffb1ba6707fb70] oops_end at ffffffff85623c0d #4 [ffffb1ba6707fb90] no_context at ffffffff856692c9 #5 [ffffb1ba6707fbf8] exc_page_fault at ffffffff85f95b51 #6 [ffffb1ba6707fc50] asm_exc_page_fault at ffffffff86000ace
[exception RIP: svm_update_pi_irte+227]
RIP: ffffffffc0761b53 RSP: ffffb1ba6707fd08 RFLAGS: 00010086
RAX: ffffb1ba6707fd78 RBX: ffffb1ba66d91000 RCX: 0000000000000001
RDX: 00003c803f63f1c0 RSI: 000000000000019a RDI: ffffb1ba66db2ab8
RBP: 000000000000019a R8: 0000000000000040 R9: ffff94ca41b82200
R10: ffffffffffffffcf R11: 0000000000000001 R12: 0000000000000001
R13: 0000000000000001 R14: ffffffffffffffcf R15: 000000000000005f
ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018
#7 [ffffb1ba6707fdb8] kvm_irq_routing_update at ffffffffc09f19a1 [kvm]
#8 [ffffb1ba6707fde0] kvm_set_irq_routing at ffffffffc09f2133 [kvm]
#9 [ffffb1ba6707fe18] kvm_vm_ioctl at ffffffffc09ef544 [kvm]
RIP: 00007f143c36488b RSP: 00007f143a4e04b8 RFLAGS: 00000246
RAX: ffffffffffffffda RBX: 00007f05780041d0 RCX: 00007f143c36488b
RDX: 00007f05780041d0 RSI: 000000004008ae6a RDI: 0000000000000020
RBP: 00000000000004e8 R8: 0000000000000008 R9: 00007f05780041e0
R10: 00007f0578004560 R11: 0000000000000246 R12: 00000000000004e0
R13: 000000000000001a R14: 00007f1424001c60 R15: 00007f0578003bc0
ORIG_RAX: 0000000000000010 CS: 0033 SS: 002bVmx have been fix this in commit 3a8b0677fc61 (KVM: VMX: Do not BUG() on out-of-bounds guest IRQ), so we can just copy source from that to fix this.
Message-Id: <[email protected]>
--- arch/x86/kvm/svm/avic.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/x86/kvm/svm/avic.c +8 -2
@@ -799,7 +799,7 @@ int svm_update_pi_irte(struct kvm *kvm, {struct kvm_kernel_irq_routing_entry *e;struct kvm_irq_routing_table *irq_rt; -int idx, ret = -EINVAL ; +int idx, ret =0 ;if (!kvm_arch_has_assigned_device (kvm) || !irq_remapping_cap (IRQ_POSTING_CAP ))
@@ -810,7 +810,13 @@ int svm_update_pi_irte(struct kvm *kvm, idx =srcu_read_lock (&kvm->irq_srcu); irq_rt =srcu_dereference (kvm->irq_routing, &kvm->irq_srcu); -WARN_ON (guest_irq >= irq_rt->nr_rt_entries); + +if (guest_irq >= irq_rt->nr_rt_entries || +hlist_empty (&irq_rt->map[guest_irq])) { +pr_warn_once ("no route for guest_irq %u/%u (broken user space?)\n" , + guest_irq, irq_rt->nr_rt_entries); + goto out; + }hlist_for_each_entry (e, &irq_rt->map[guest_irq], link) {struct vcpu_data vcpu_info;
Greg Kroah-Hartman
maintainerPATCH 816/913 ubifs: rename_whiteout: Fix double free for whiteout_ui->data
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 40a8f0d5e7b3999f096570edab71c345da812e3e upstream.
'whiteout_ui->data' will be freed twice if space budget fail for rename whiteout operation as following process:
rename_whiteout
dev = kmalloc
whiteout_ui->data = dev
kfree(whiteout_ui->data) // Free first time
iput(whiteout)
ubifs_free_inode
kfree(ui->data) // Double free!KASAN reports:
==================================================================
BUG: KASAN: double-free or invalid-free in ubifs_free_inode+0x4f/0x70 Call Trace: kfree+0x117/0x490 ubifs_free_inode+0x4f/0x70 [ubifs] i_callback+0x30/0x60 rcu_do_batch+0x366/0xac0 __do_softirq+0x133/0x57f Allocated by task 1506: kmem_cache_alloc_trace+0x3c2/0x7a0 do_rename+0x9b7/0x1150 [ubifs] ubifs_rename+0x106/0x1f0 [ubifs] do_syscall_64+0x35/0x80 Freed by task 1506: kfree+0x117/0x490 do_rename.cold+0x53/0x8a [ubifs] ubifs_rename+0x106/0x1f0 [ubifs] do_syscall_64+0x35/0x80 The buggy address belongs to the object at ffff88810238bed8 which
belongs to the cache kmalloc-8 of size 8
==================================================================
Let ubifs_free_inode() free 'whiteout_ui->data'. BTW, delete unused assignment 'whiteout_ui->data_len = 0', process 'ubifs_evict_inode() -> ubifs_jnl_delete_inode() -> ubifs_jnl_write_inode()' doesn't need it (because 'inc_nlink(whiteout)' won't be excuted by 'goto out_release',
and the nlink of whiteout inode is 0).
--- fs/ubifs/dir.c | 2 -- 1 file changed, 2 deletions(-)
fs/ubifs/dir.c +0 -2
@@ -1425,8 +1425,6 @@ static int do_rename(struct inode *old_d err =ubifs_budget_space (c, &wht_req);if (err) { -kfree (whiteout_ui->data); - whiteout_ui->data_len =0 ;iput (whiteout); goto out_release; }
Greg Kroah-Hartman
maintainerPATCH 817/913 ubifs: Fix deadlock in concurrent rename whiteout and inode writeback
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit afd427048047e8efdedab30e8888044e2be5aa9c upstream.
Following hung tasks:
[ 77.028764] task:kworker/u8:4 state:D stack: 0 pid: 132 [ 77.028820] Call Trace: [ 77.029027] schedule+0x8c/0x1b0 [ 77.029067] mutex_lock+0x50/0x60 [ 77.029074] ubifs_write_inode+0x68/0x1f0 [ubifs] [ 77.029117] __writeback_single_inode+0x43c/0x570 [ 77.029128] writeback_sb_inodes+0x259/0x740 [ 77.029148] wb_writeback+0x107/0x4d0 [ 77.029163] wb_workfn+0x162/0x7b0
[ 92.390442] task:aa state:D stack: 0 pid: 1506 [ 92.390448] Call Trace: [ 92.390458] schedule+0x8c/0x1b0 [ 92.390461] wb_wait_for_completion+0x82/0xd0 [ 92.390469] __writeback_inodes_sb_nr+0xb2/0x110 [ 92.390472] writeback_inodes_sb_nr+0x14/0x20 [ 92.390476] ubifs_budget_space+0x705/0xdd0 [ubifs] [ 92.390503] do_rename.cold+0x7f/0x187 [ubifs] [ 92.390549] ubifs_rename+0x8b/0x180 [ubifs] [ 92.390571] vfs_rename+0xdb2/0x1170 [ 92.390580] do_renameat2+0x554/0x770
, are caused by concurrent rename whiteout and inode writeback processes:
rename_whiteout(Thread 1) wb_workfn(Thread2)ubifs_rename
do_rename
lock_4_inodes (Hold ui_mutex)
ubifs_budget_space
make_free_space
shrink_liability
__writeback_inodes_sb_nr
bdi_split_work_to_wbs (Queue new wb work)
wb_do_writeback(wb work)
__writeback_single_inode
ubifs_write_inode
LOCK(ui_mutex)
↑
wb_wait_for_completion (Wait wb work) <-- deadlock!
Reproducer (Detail program in [Link]):
1. SYS_renameat2("/mp/dir/file", "/mp/dir/whiteout", RENAME_WHITEOUT)
2. Consume out of space before kernel(mdelay) doing budget for whiteout
Fix it by doing whiteout space budget before locking ubifs inodes. BTW, it also fixes wrong goto tag 'out_release' in whiteout budget error handling path(It should at least recover dir i_size and unlock 4 ubifs inodes).
--- fs/ubifs/dir.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
fs/ubifs/dir.c +15 -10
@@ -1324,6 +1324,7 @@ static int do_rename(struct inode *old_dif (flags &RENAME_WHITEOUT ) {union ubifs_dev_desc *dev =NULL ; +struct ubifs_budget_req wht_req; dev =kmalloc (sizeof (union ubifs_dev_desc ),GFP_NOFS );if (!dev) {
@@ -1345,6 +1346,20 @@ static int do_rename(struct inode *old_d whiteout_ui->data = dev; whiteout_ui->data_len =ubifs_encode_dev (dev,MKDEV (0 ,0 ));ubifs_assert (c, !whiteout_ui->dirty); + +memset (&wht_req,0 ,sizeof (struct ubifs_budget_req )); + wht_req.dirtied_ino =1 ; + wht_req.dirtied_ino_d =ALIGN (whiteout_ui->data_len,8 ); +/* +* To avoid deadlock between space budget (holds ui_mutex and +* waits wb work) and writeback work(waits ui_mutex), do space +* budget before ubifs inodes locked. +*/ + err =ubifs_budget_space (c, &wht_req); +if (err) { +iput (whiteout); + goto out_release; + } }lock_4_inodes (old_dir, new_dir, new_inode, whiteout);
@@ -1419,16 +1434,6 @@ static int do_rename(struct inode *old_d }if (whiteout) { -struct ubifs_budget_req wht_req = { .dirtied_ino =1 , - .dirtied_ino_d = \ -ALIGN (ubifs_inode (whiteout)->data_len,8 ) }; - - err =ubifs_budget_space (c, &wht_req); -if (err) { -iput (whiteout); - goto out_release; - } -inc_nlink (whiteout);mark_inode_dirty (whiteout);
Greg Kroah-Hartman
maintainerPATCH 818/913 ubifs: Add missing iput if do_tmpfile() failed in rename whiteout
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 716b4573026bcbfa7b58ed19fe15554bac66b082 upstream.
whiteout inode should be put when do_tmpfile() failed if inode has been initialized. Otherwise we will get following warning during umount:
UBIFS error (ubi0:0 pid 1494): ubifs_assert_failed [ubifs]: UBIFS assert failed: c->bi.dd_growth == 0, in fs/ubifs/super.c:1930
VFS: Busy inodes after unmount of ubifs. Self-destruct in 5 seconds.
--- fs/ubifs/dir.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ubifs/dir.c +2 -0
@@ -432,6 +432,8 @@ out_inode:make_bad_inode (inode);if (!instantiated)iput (inode); +else if (whiteout) +iput (*whiteout); out_budg:ubifs_release_budget (c, &req);if (!instantiated)
Greg Kroah-Hartman
maintainerPATCH 819/913 ubifs: Rename whiteout atomically
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 278d9a243635f26c05ad95dcf9c5a593b9e04dc6 upstream.
Currently, rename whiteout has 3 steps:
1. create tmpfile(which associates old dentry to tmpfile inode) for whiteout, and store tmpfile to disk
2. link whiteout, associate whiteout inode to old dentry agagin and store old dentry, old inode, new dentry on disk
3. writeback dirty whiteout inode to disk
Suddenly power-cut or error occurring(eg. ENOSPC returned by budget, memory allocation failure) during above steps may cause kinds of problems:
Problem 1: ENOSPC returned by whiteout space budget (before step 2),
old dentry will disappear after rename syscall, whiteout file cannot be found either.
ls dir // we get file, whiteout
rename(dir/file, dir/whiteout, REANME_WHITEOUT) ENOSPC = ubifs_budget_space(&wht_req) // return
ls dir // empty (no file, no whiteout)
Problem 2: Power-cut happens before step 3, whiteout inode with 'nlink=1'
is not stored on disk, whiteout dentry(old dentry) is written on disk, whiteout file is lost on next mount (We get "dead directory entry" after executing 'ls -l' on whiteout file).
Now, we use following 3 steps to finish rename whiteout:
1. create an in-mem inode with 'nlink = 1' as whiteout
2. ubifs_jnl_rename (Write on disk to finish associating old dentry to whiteout inode, associating new dentry with old inode)
3. iput(whiteout)
Rely writing in-mem inode on disk by ubifs_jnl_rename() to finish rename whiteout, which avoids middle disk state caused by suddenly power-cut and error occurring.
--- fs/ubifs/dir.c | 144 +++++++++++++++++++++++++++++++++-------------------- fs/ubifs/journal.c | 52 ++++++++++++++++--- 2 files changed, 136 insertions(+), 60 deletions(-)
fs/ubifs/dir.c +92 -52
@@ -349,8 +349,56 @@ out_budg:return err; } -static int do_tmpfile (struct inode *dir,struct dentry *dentry, -umode_t mode,struct inode **whiteout) +static struct inode *create_whiteout (struct inode *dir,struct dentry *dentry) +{ +int err; +umode_t mode =S_IFCHR |WHITEOUT_MODE ; +struct inode *inode; +struct ubifs_info *c = dir->i_sb->s_fs_info; +struct fscrypt_name nm; + +/* +* Create an inode('nlink = 1') for whiteout without updating journal, +* let ubifs_jnl_rename() store it on flash to complete rename whiteout +* atomically. +*/ + +dbg_gen ("dent '%pd', mode %#hx in dir ino %lu" , + dentry, mode, dir->i_ino); + + err =fscrypt_setup_filename (dir, &dentry->d_name,0 , &nm); +if (err) +return ERR_PTR (err); + + inode =ubifs_new_inode (c, dir, mode); +if (IS_ERR (inode)) { + err =PTR_ERR (inode); + goto out_free; + } + +init_special_inode (inode, inode->i_mode,WHITEOUT_DEV ); +ubifs_assert (c, inode->i_op == &ubifs_file_inode_operations); + + err =ubifs_init_security (dir, inode, &dentry->d_name); +if (err) + goto out_inode; + +/* The dir size is updated by do_rename. */ +insert_inode_hash (inode); + +return inode; + +out_inode: +make_bad_inode (inode); +iput (inode); +out_free: +fscrypt_free_filename (&nm); +ubifs_err (c,"cannot create whiteout file, error %d" , err); +return ERR_PTR (err); +} + +static int ubifs_tmpfile (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {struct inode *inode;struct ubifs_info *c = dir->i_sb->s_fs_info;
@@ -392,25 +440,13 @@ static int do_tmpfile(struct inode *dir, } ui =ubifs_inode (inode); -if (whiteout) { -init_special_inode (inode, inode->i_mode,WHITEOUT_DEV ); -ubifs_assert (c, inode->i_op == &ubifs_file_inode_operations); - } - err =ubifs_init_security (dir, inode, &dentry->d_name);if (err) goto out_inode;mutex_lock (&ui->ui_mutex);insert_inode_hash (inode); - -if (whiteout) { -mark_inode_dirty (inode); -drop_nlink (inode); - *whiteout = inode; - }else { -d_tmpfile (dentry, inode); - } +d_tmpfile (dentry, inode);ubifs_assert (c, ui->dirty); instantiated =1 ;
@@ -432,8 +468,6 @@ out_inode:make_bad_inode (inode);if (!instantiated)iput (inode); -else if (whiteout) -iput (*whiteout); out_budg:ubifs_release_budget (c, &req);if (!instantiated)
@@ -443,12 +477,6 @@ out_budg:return err; } -static int ubifs_tmpfile (struct user_namespace *mnt_userns,struct inode *dir, -struct dentry *dentry,umode_t mode) -{ -return do_tmpfile (dir, dentry, mode,NULL ); -} -/** * vfs_dent_type - get VFS directory entry type. * @type: UBIFS directory entry type
@@ -1266,17 +1294,19 @@ static int do_rename(struct inode *old_d .dirtied_ino = 3 };struct ubifs_budget_req ino_req = { .dirtied_ino =1 , .dirtied_ino_d =ALIGN (old_inode_ui->data_len,8 ) }; +struct ubifs_budget_req wht_req;struct timespec64 time;unsigned int saved_nlink;struct fscrypt_name old_nm, new_nm;/* -* Budget request settings: deletion direntry, new direntry, removing -* the old inode, and changing old and new parent directory inodes. +* Budget request settings: +* req: deletion direntry, new direntry, removing the old inode, +* and changing old and new parent directory inodes. +* +* wht_req: new whiteout inode for RENAME_WHITEOUT. * -* However, this operation also marks the target inode as dirty and -* does not write it, so we allocate budget for the target inode -* separately. +* ino_req: marks the target inode as dirty and does not write it. */ dbg_gen("dent '%pd' ino %lu in dir ino %lu to dent '%pd' in dir ino %lu flags 0x%x",
@@ -1326,7 +1356,6 @@ static int do_rename(struct inode *old_dif (flags &RENAME_WHITEOUT ) {union ubifs_dev_desc *dev =NULL ; -struct ubifs_budget_req wht_req; dev =kmalloc (sizeof (union ubifs_dev_desc ),GFP_NOFS );if (!dev) {
@@ -1334,24 +1363,26 @@ static int do_rename(struct inode *old_d goto out_release; } - err =do_tmpfile (old_dir, old_dentry,S_IFCHR |WHITEOUT_MODE , &whiteout); -if (err) { +/* +* The whiteout inode without dentry is pinned in memory, +* umount won't happen during rename process because we +* got parent dentry. +*/ + whiteout =create_whiteout (old_dir, old_dentry); +if (IS_ERR (whiteout)) { + err =PTR_ERR (whiteout);kfree (dev); goto out_release; } -spin_lock (&whiteout->i_lock); - whiteout->i_state |=I_LINKABLE ; -spin_unlock (&whiteout->i_lock); - whiteout_ui =ubifs_inode (whiteout); whiteout_ui->data = dev; whiteout_ui->data_len =ubifs_encode_dev (dev,MKDEV (0 ,0 ));ubifs_assert (c, !whiteout_ui->dirty);memset (&wht_req,0 ,sizeof (struct ubifs_budget_req )); - wht_req.dirtied_ino =1 ; - wht_req.dirtied_ino_d =ALIGN (whiteout_ui->data_len,8 ); + wht_req.new_ino =1 ; + wht_req.new_ino_d =ALIGN (whiteout_ui->data_len,8 );/* * To avoid deadlock between space budget (holds ui_mutex and * waits wb work) and writeback work(waits ui_mutex), do space
@@ -1359,6 +1390,11 @@ static int do_rename(struct inode *old_d*/ err =ubifs_budget_space (c, &wht_req);if (err) { +/* +* Whiteout inode can not be written on flash by +* ubifs_jnl_write_inode(), because it's neither +* dirty nor zero-nlink. +*/ iput (whiteout); goto out_release; }
@@ -1433,17 +1469,11 @@ static int do_rename(struct inode *old_d sync =IS_DIRSYNC (old_dir) ||IS_DIRSYNC (new_dir);if (unlink &&IS_SYNC (new_inode)) sync =1 ; - } - -if (whiteout) { -inc_nlink (whiteout); -mark_inode_dirty (whiteout); - -spin_lock (&whiteout->i_lock); - whiteout->i_state &= ~I_LINKABLE ; -spin_unlock (&whiteout->i_lock); - -iput (whiteout); +/* +* S_SYNC flag of whiteout inherits from the old_dir, and we +* have already checked the old dir inode. So there is no need +* to check whiteout. +*/ } err = ubifs_jnl_rename(c, old_dir, old_inode, &old_nm, new_dir,
@@ -1454,6 +1484,11 @@ static int do_rename(struct inode *old_dunlock_4_inodes (old_dir, new_dir, new_inode, whiteout);ubifs_release_budget (c, &req); +if (whiteout) { +ubifs_release_budget (c, &wht_req); +iput (whiteout); + } +mutex_lock (&old_inode_ui->ui_mutex); release = old_inode_ui->dirty;mark_inode_dirty_sync (old_inode);
@@ -1462,11 +1497,16 @@ static int do_rename(struct inode *old_dif (release)ubifs_release_budget (c, &ino_req);if (IS_SYNC (old_inode)) - err = old_inode->i_sb->s_op->write_inode (old_inode,NULL ); +/* +* Rename finished here. Although old inode cannot be updated +* on flash, old ctime is not a big problem, don't return err +* code to userspace. +*/ + old_inode->i_sb->s_op->write_inode (old_inode,NULL );fscrypt_free_filename (&old_nm);fscrypt_free_filename (&new_nm); -return err; +return 0 ; out_cancel:if (unlink) {
@@ -1487,11 +1527,11 @@ out_cancel:inc_nlink (old_dir); } } +unlock_4_inodes (old_dir, new_dir, new_inode, whiteout);if (whiteout) { -drop_nlink (whiteout); +ubifs_release_budget (c, &wht_req);iput (whiteout); } -unlock_4_inodes (old_dir, new_dir, new_inode, whiteout); out_release:ubifs_release_budget (c, &ino_req);ubifs_release_budget (c, &req);
fs/ubifs/journal.c +44 -8
108 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 820/913 ubifs: Fix ui->dirty race between do_tmpfile() and writeback work
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 60eb3b9c9f11206996f57cb89521824304b305ad upstream.
'ui->dirty' is not protected by 'ui_mutex' in function do_tmpfile() which may race with ubifs_write_inode[wb_workfn] to access/update 'ui->dirty', finally dirty space is released twice.
open(O_TMPFILE) wb_workfndo_tmpfile
ubifs_budget_space(ino_req = { .dirtied_ino = 1}) d_tmpfile // mark inode(tmpfile) dirty ubifs_jnl_update // without holding tmpfile's ui_mutex
mark_inode_clean(ui)
if (ui->dirty)
ubifs_release_dirty_inode_budget(ui) // release first time
ubifs_write_inode
mutex_lock(&ui->ui_mutex)
ubifs_release_dirty_inode_budget(ui)
// release second time
mutex_unlock(&ui->ui_mutex)
ui->dirty = 0Run generic/476 can reproduce following message easily (See reproducer in [Link]):
UBIFS error (ubi0:0 pid 2578): ubifs_assert_failed [ubifs]: UBIFS assert
failed: c->bi.dd_growth >= 0, in fs/ubifs/budget.c:554
UBIFS warning (ubi0:0 pid 2578): ubifs_ro_mode [ubifs]: switched to read-only mode, error -22
Workqueue: writeback wb_workfn (flush-ubifs_0_0)
Call Trace:
ubifs_ro_mode+0x54/0x60 [ubifs]
ubifs_assert_failed+0x4b/0x80 [ubifs]
ubifs_release_budget+0x468/0x5a0 [ubifs]
ubifs_release_dirty_inode_budget+0x53/0x80 [ubifs]
ubifs_write_inode+0x121/0x1f0 [ubifs]
...
wb_workfn+0x283/0x7b0Fix it by holding tmpfile ubifs inode lock during ubifs_jnl_update(). Similar problem exists in whiteout renaming, but previous fix("ubifs:
Rename whiteout atomically") has solved the problem.
--- fs/ubifs/dir.c | 60 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 30 deletions(-)
fs/ubifs/dir.c +30 -30
@@ -397,6 +397,32 @@ out_free:return ERR_PTR (err); } +/** +* lock_2_inodes - a wrapper for locking two UBIFS inodes. +* @inode1: first inode +* @inode2: second inode +* +* We do not implement any tricks to guarantee strict lock ordering, because +* VFS has already done it for us on the @i_mutex. So this is just a simple +* wrapper function. +*/ +static void lock_2_inodes (struct inode *inode1,struct inode *inode2) +{ +mutex_lock_nested (&ubifs_inode (inode1)->ui_mutex,WB_MUTEX_1 ); +mutex_lock_nested (&ubifs_inode (inode2)->ui_mutex,WB_MUTEX_2 ); +} + +/** +* unlock_2_inodes - a wrapper for unlocking two UBIFS inodes. +* @inode1: first inode +* @inode2: second inode +*/ +static void unlock_2_inodes (struct inode *inode1,struct inode *inode2) +{ +mutex_unlock (&ubifs_inode (inode2)->ui_mutex); +mutex_unlock (&ubifs_inode (inode1)->ui_mutex); +} +static int ubifs_tmpfile (struct user_namespace *mnt_userns,struct inode *dir,struct dentry *dentry,umode_t mode) {
@@ -404,7 +430,7 @@ static int ubifs_tmpfile(struct user_namstruct ubifs_info *c = dir->i_sb->s_fs_info;struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 };struct ubifs_budget_req ino_req = { .dirtied_ino =1 }; -struct ubifs_inode *ui, *dir_ui =ubifs_inode (dir); +struct ubifs_inode *ui;int err, instantiated =0 ;struct fscrypt_name nm;
@@ -452,18 +478,18 @@ static int ubifs_tmpfile(struct user_nam instantiated =1 ;mutex_unlock (&ui->ui_mutex); -mutex_lock (&dir_ui->ui_mutex); +lock_2_inodes (dir, inode); err =ubifs_jnl_update (c, dir, &nm, inode,1 ,0 );if (err) goto out_cancel; -mutex_unlock (&dir_ui->ui_mutex); +unlock_2_inodes (dir, inode);ubifs_release_budget (c, &req);return 0 ; out_cancel: -mutex_unlock (&dir_ui->ui_mutex); +unlock_2_inodes (dir, inode); out_inode:make_bad_inode (inode);if (!instantiated)
@@ -690,32 +716,6 @@ static int ubifs_dir_release(struct inodreturn 0 ; } -/** -* lock_2_inodes - a wrapper for locking two UBIFS inodes. -* @inode1: first inode -* @inode2: second inode -* -* We do not implement any tricks to guarantee strict lock ordering, because -* VFS has already done it for us on the @i_mutex. So this is just a simple -* wrapper function. -*/ -static void lock_2_inodes (struct inode *inode1,struct inode *inode2) -{ -mutex_lock_nested (&ubifs_inode (inode1)->ui_mutex,WB_MUTEX_1 ); -mutex_lock_nested (&ubifs_inode (inode2)->ui_mutex,WB_MUTEX_2 ); -} - -/** -* unlock_2_inodes - a wrapper for unlocking two UBIFS inodes. -* @inode1: first inode -* @inode2: second inode -*/ -static void unlock_2_inodes (struct inode *inode1,struct inode *inode2) -{ -mutex_unlock (&ubifs_inode (inode2)->ui_mutex); -mutex_unlock (&ubifs_inode (inode1)->ui_mutex); -} -static int ubifs_link (struct dentry *old_dentry,struct inode *dir,struct dentry *dentry) {
Greg Kroah-Hartman
maintainerPATCH 821/913 ubifs: Rectify space amount budget for mkdir/tmpfile operations
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit a6dab6607d4681d227905d5198710b575dbdb519 upstream.
UBIFS should make sure the flash has enough space to store dirty (Data that is newer than disk) data (in memory), space budget is exactly designed to do that. If space budget calculates less data than we need, 'make_reservation()' will do more work(return -ENOSPC if no free space lelf, sometimes we can see "cannot reserve xxx bytes in jhead xxx, error -28" in ubifs error messages) with ubifs inodes locked, which may effect other syscalls.
A simple way to decide how much space do we need when make a budget:
See how much space is needed by 'make_reservation()' in ubifs_jnl_xxx() function according to corresponding operation.
It's better to report ENOSPC in ubifs_budget_space(), as early as we can.
--- fs/ubifs/dir.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
fs/ubifs/dir.c +8 -4
@@ -428,15 +428,18 @@ static int ubifs_tmpfile(struct user_nam {struct inode *inode;struct ubifs_info *c = dir->i_sb->s_fs_info; -struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 }; +struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 , + .dirtied_ino =1 };struct ubifs_budget_req ino_req = { .dirtied_ino =1 };struct ubifs_inode *ui;int err, instantiated =0 ;struct fscrypt_name nm;/* -* Budget request settings: new dirty inode, new direntry, -* budget for dirtied inode will be released via writeback. +* Budget request settings: new inode, new direntry, changing the +* parent directory inode. +* Allocate budget separately for new dirtied inode, the budget will +* be released via writeback. */ dbg_gen("dent '%pd', mode %#hx in dir ino %lu",
@@ -979,7 +982,8 @@ static int ubifs_mkdir(struct user_namesstruct ubifs_inode *dir_ui =ubifs_inode (dir);struct ubifs_info *c = dir->i_sb->s_fs_info;int err, sz_change; -struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 }; +struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 , + .dirtied_ino =1 };struct fscrypt_name nm;/*
Greg Kroah-Hartman
maintainerPATCH 822/913 ubifs: setflags: Make dirtied_ino_d 8 bytes aligned
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 1b83ec057db16b4d0697dc21ef7a9743b6041f72 upstream.
Make 'ui->data_len' aligned with 8 bytes before it is assigned to dirtied_ino_d. Since 8871d84c8f8b0c6b("ubifs: convert to fileattr") applied, 'setflags()' only affects regular files and directories, only xattr inode, symlink inode and special inode(pipe/char_dev/block_dev) have none- zero 'ui->data_len' field, so assertion '!(req->dirtied_ino_d & 7)' cannot fail in ubifs_budget_space(). To avoid assertion fails in future evolution(eg. setflags can operate special inodes), it's better to make dirtied_ino_d 8 bytes aligned, after all aligned size is still zero for regular files.
--- fs/ubifs/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ubifs/ioctl.c +1 -1
@@ -108,7 +108,7 @@ static int setflags(struct inode *inode,struct ubifs_inode *ui =ubifs_inode (inode);struct ubifs_info *c = inode->i_sb->s_fs_info;struct ubifs_budget_req req = { .dirtied_ino =1 , - .dirtied_ino_d = ui->data_len }; + .dirtied_ino_d =ALIGN (ui->data_len,8 ) }; err =ubifs_budget_space (c, &req);if (err)
Greg Kroah-Hartman
maintainerPATCH 823/913 ubifs: Fix read out-of-bounds in ubifs_wbuf_write_nolock()
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 4f2262a334641e05f645364d5ade1f565c85f20b upstream.
Function ubifs_wbuf_write_nolock() may access buf out of bounds in following process:
ubifs_wbuf_write_nolock():
aligned_len = ALIGN(len, 8); // Assume len = 4089, aligned_len = 4096
if (aligned_len <= wbuf->avail) ... // Not satisfy
if (wbuf->used) {
ubifs_leb_write() // Fill some data in avail wbuf
len -= wbuf->avail; // len is still not 8-bytes aligned
aligned_len -= wbuf->avail;
}
n = aligned_len >> c->max_write_shift;
if (n) {
n <<= c->max_write_shift;
err = ubifs_leb_write(c, wbuf->lnum, buf + written,
wbuf->offs, n);
// n > len, read out of bounds less than 8(n-len) bytes}
, which can be catched by KASAN:
=========================================================
BUG: KASAN: slab-out-of-bounds in ecc_sw_hamming_calculate+0x1dc/0x7d0
Read of size 4 at addr ffff888105594ff8 by task kworker/u8:4/128
Workqueue: writeback wb_workfn (flush-ubifs_0_0)
Call Trace:
kasan_report.cold+0x81/0x165
nand_write_page_swecc+0xa9/0x160
ubifs_leb_write+0xf2/0x1b0 [ubifs]
ubifs_wbuf_write_nolock+0x421/0x12c0 [ubifs]
write_head+0xdc/0x1c0 [ubifs]
ubifs_jnl_write_inode+0x627/0x960 [ubifs]
wb_workfn+0x8af/0xb80Function ubifs_wbuf_write_nolock() accepts that parameter 'len' is not 8 bytes aligned, the 'len' represents the true length of buf (which is allocated in 'ubifs_jnl_xxx', eg. ubifs_jnl_write_inode), so ubifs_wbuf_write_nolock() must handle the length read from 'buf' carefully to write leb safely.
Fetch a reproducer in [Link].
--- fs/ubifs/io.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-)
fs/ubifs/io.c +30 -4
@@ -833,16 +833,42 @@ int ubifs_wbuf_write_nolock(struct ubifs*/ n = aligned_len >> c->max_write_shift;if (n) { - n <<= c->max_write_shift; +int m = n -1 ; +dbg_io ("write %d bytes to LEB %d:%d" , n, wbuf->lnum, wbuf->offs); - err =ubifs_leb_write (c, wbuf->lnum, buf + written, - wbuf->offs, n); + +if (m) { +/* '(n-1)<<c->max_write_shift < len' is always true. */ + m <<= c->max_write_shift; + err =ubifs_leb_write (c, wbuf->lnum, buf + written, + wbuf->offs, m); +if (err) + goto out; + wbuf->offs += m; + aligned_len -= m; + len -= m; + written += m; + } + +/* +* The non-written len of buf may be less than 'n' because +* parameter 'len' is not 8 bytes aligned, so here we read +* min(len, n) bytes from buf. +*/ + n =1 << c->max_write_shift; +memcpy (wbuf->buf, buf + written,min (len, n)); +if (n > len) { +ubifs_assert (c, n - len <8 ); +ubifs_pad (c, wbuf->buf + len, n - len); + } + + err =ubifs_leb_write (c, wbuf->lnum, wbuf->buf, wbuf->offs, n);if (err) goto out; wbuf->offs += n; aligned_len -= n; - len -= n; + len -=min (len, n); written += n; }
Greg Kroah-Hartman
maintainerPATCH 824/913 ubifs: Fix to add refcount once page is set private
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 3b67db8a6ca83e6ff90b756d3da0c966f61cd37b upstream.
MM defined the rule [1] very clearly that once page was set with PG_private flag, we should increment the refcount in that page, also main flows like pageout(), migrate_page() will assume there is one additional page reference count if page_has_private() returns true. Otherwise, we may get a BUG in page migration:
page:0000000080d05b9d refcount:-1 mapcount:0 mapping:000000005f4d82a8 index:0xe2 pfn:0x14c12
aops:ubifs_file_address_operations [ubifs] ino:8f1 dentry name:"f30e"
flags: 0x1fffff80002405(locked|uptodate|owner_priv_1|private|node=0| zone=1|lastcpupid=0x1fffff)
page dumped because: VM_BUG_ON_PAGE(page_count(page) != 0)
------------[ cut here ]------------
kernel BUG at include/linux/page_ref.h:184!
invalid opcode: 0000 [#1] SMP
CPU: 3 PID: 38 Comm: kcompactd0 Not tainted 5.15.0-rc5
RIP: 0010:migrate_page_move_mapping+0xac3/0xe70
Call Trace:
ubifs_migrate_page+0x22/0xc0 [ubifs]
move_to_new_page+0xb4/0x600
migrate_pages+0x1523/0x1cc0
compact_zone+0x8c5/0x14b0
kcompactd+0x2bc/0x560
kthread+0x18c/0x1e0
ret_from_fork+0x1f/0x30Before the time, we should make clean a concept, what does refcount means in page gotten from grab_cache_page_write_begin(). There are 2 situations:
Situation 1: refcount is 3, page is created by __page_cache_alloc.
TYPE_A - the write process is using this page
TYPE_B - page is assigned to one certain mapping by calling
__add_to_page_cache_locked()
TYPE_C - page is added into pagevec list corresponding current cpu by
calling lru_cache_add()
Situation 2: refcount is 2, page is gotten from the mapping's tree
TYPE_B - page has been assigned to one certain mapping TYPE_A - the write process is using this page (by calling
page_cache_get_speculative())
Filesystem releases one refcount by calling put_page() in xxx_write_end(), the released refcount corresponds to TYPE_A (write task is using it). If there are any processes using a page, page migration process will skip the page by judging whether expected_page_refs() equals to page refcount.
The BUG is caused by following process:
PA(cpu 0) kcompactd(cpu 1)
compact_zoneubifs_write_begin
page_a = grab_cache_page_write_begin
add_to_page_cache_lru
lru_cache_add
pagevec_add // put page into cpu 0's pagevec
(refcnf = 3, for page creation process)ubifs_write_end
SetPagePrivate(page_a) // doesn't increase page count ! unlock_page(page_a)
put_page(page_a) // refcnt = 2
[...]
PB(cpu 0)filemap_read
filemap_get_pages
add_to_page_cache_lru
lru_cache_add
__pagevec_lru_add // traverse all pages in cpu 0's pagevec
__pagevec_lru_add_fn
SetPageLRU(page_a)
isolate_migratepages
isolate_migratepages_block
get_page_unless_zero(page_a) // refcnt = 3
list_add(page_a, from_list)
migrate_pages(from_list)
__unmap_and_move
move_to_new_page
ubifs_migrate_page(page_a)
migrate_page_move_mapping
expected_page_refs get 3
(migration[1] + mapping[1] + private[1])
release_pages
put_page_testzero(page_a) // refcnt = 3
page_ref_freeze // refcnt = 0
page_ref_dec_and_test(0 - 1 = -1)
page_ref_unfreeze
VM_BUG_ON_PAGE(-1 != 0, page)
UBIFS doesn't increase the page refcount after setting private flag, which leads to page migration task believes the page is not used by any other processes, so the page is migrated. This causes concurrent accessing on page refcount between put_page() called by other process(eg. read process calls lru_cache_add) and page_ref_unfreeze() called by migration task.
Actually zhangjun has tried to fix this problem [2] by recalculating page refcnt in ubifs_migrate_page(). It's better to follow MM rules [1], because just like Kirill suggested in [2], we need to check all users of page_has_private() helper. Like f2fs does in [3], fix it by adding/deleting refcount when setting/clearing private for a page. BTW, according to [4], we set 'page->private' as 1 because ubifs just simply SetPagePrivate(). And, [5] provided a common helper to set/clear page private, ubifs can use this helper following the example of iomap, afs, btrfs, etc.
Jump [6] to find a reproducer.
[1] https://lore.kernel.org/lkml/[email protected]
[2] https://www.spinics.net/lists/linux-mtd/msg04018.html
[3] http://lkml.iu.edu/hypermail/linux/kernel/1903.0/03313.html
[4] https://lore.kernel.org/linux-f2fs-devel/[email protected]
[5] https://lore.kernel.org/all/[email protected]
[6] https://bugzilla.kernel.org/show_bug.cgi?id=214961
--- fs/ubifs/file.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
fs/ubifs/file.c +7 -7
@@ -570,7 +570,7 @@ static int ubifs_write_end(struct file * }if (!PagePrivate (page)) { -SetPagePrivate (page); +attach_page_private (page, (void *)1 );atomic_long_inc (&c->dirty_pg_cnt);__set_page_dirty_nobuffers (page); }
@@ -947,7 +947,7 @@ static int do_writepage(struct page *pagrelease_existing_page_budget (c);atomic_long_dec (&c->dirty_pg_cnt); -ClearPagePrivate (page); +detach_page_private (page);ClearPageChecked (page);kunmap (page);
@@ -1304,7 +1304,7 @@ static void ubifs_invalidatepage(structrelease_existing_page_budget (c);atomic_long_dec (&c->dirty_pg_cnt); -ClearPagePrivate (page); +detach_page_private (page);ClearPageChecked (page); }
@@ -1471,8 +1471,8 @@ static int ubifs_migrate_page(struct addreturn rc;if (PagePrivate (page)) { -ClearPagePrivate (page); -SetPagePrivate (newpage); +detach_page_private (page); +attach_page_private (newpage, (void *)1 ); }if (mode !=MIGRATE_SYNC_NO_COPY )
@@ -1496,7 +1496,7 @@ static int ubifs_releasepage(struct pagereturn 0 ;ubifs_assert (c,PagePrivate (page));ubifs_assert (c,0 ); -ClearPagePrivate (page); +detach_page_private (page);ClearPageChecked (page);return 1 ; }
@@ -1567,7 +1567,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(else {if (!PageChecked (page))ubifs_convert_page_budget (c); -SetPagePrivate (page); +attach_page_private (page, (void *)1 );atomic_long_inc (&c->dirty_pg_cnt);__set_page_dirty_nobuffers (page); }
Greg Kroah-Hartman
maintainerPATCH 825/913 ubifs: rename_whiteout: correct old_dir size computing
In reply to Greg Kroah-HartmanFrom: Baokun Li <[email protected]>
commit 705757274599e2e064dd3054aabc74e8af31a095 upstream.
When renaming the whiteout file, the old whiteout file is not deleted. Therefore, we add the old dentry size to the old dir like XFS. Otherwise, an error may be reported due to fscki->calc_sz != fscki->size in check_indes.
--- fs/ubifs/dir.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ubifs/dir.c +3 -0
@@ -1402,6 +1402,9 @@ static int do_rename(struct inode *old_diput (whiteout); goto out_release; } + +/* Add the old_dentry size to the old_dir size. */ + old_sz -=CALC_DENT_SIZE (fname_len (&old_nm)); }lock_4_inodes (old_dir, new_dir, new_inode, whiteout);
Greg Kroah-Hartman
maintainerPATCH 826/913 nvme: allow duplicate NSIDs for private namespaces
In reply to Greg Kroah-HartmanFrom: Sungup Moon <[email protected]>
commit 5974ea7ce0f9a5987fc8cf5e08ad6e3e70bb542e upstream.
A NVMe subsystem with multiple controller can have private namespaces that use the same NSID under some conditions:
"If Namespace Management, ANA Reporting, or NVM Sets are supported, the
NSIDs shall be unique within the NVM subsystem. If the Namespace Management, ANA Reporting, and NVM Sets are not supported, then NSIDs:
a) for shared namespace shall be unique; and
b) for private namespace are not required to be unique."
Reference: Section 6.1.6 NSID and Namespace Usage; NVM Express 1.4c spec.
Make sure this specific setup is supported in Linux.
[hch: refactored and fixed the controller vs subsystem based naming
conflict]
--- drivers/nvme/host/core.c | 15 ++++++++++----- drivers/nvme/host/multipath.c | 7 ++++--- drivers/nvme/host/nvme.h | 19 +++++++++++++++++++ include/linux/nvme.h | 1 + 4 files changed, 34 insertions(+), 8 deletions(-)
drivers/nvme/host/core.c +10 -5
@@ -3510,15 +3510,20 @@ static const struct attribute_group *nvm NULL, }; -static struct nvme_ns_head *nvme_find_ns_head (struct nvme_subsystem *subsys, +static struct nvme_ns_head *nvme_find_ns_head (struct nvme_ctrl *ctrl,unsigned nsid) {struct nvme_ns_head *h; -lockdep_assert_held (&subsys->lock); +lockdep_assert_held (&ctrl->subsys->lock); -list_for_each_entry (h, &subsys->nsheads, entry) { -if (h->ns_id != nsid) +list_for_each_entry (h, &ctrl->subsys->nsheads, entry) { +/* +* Private namespaces can share NSIDs under some conditions. +* In that case we can't use the same ns_head for namespaces +* with the same NSID. +*/ +if (h->ns_id != nsid || !nvme_is_unique_nsid (ctrl, h))continue ;if (!list_empty (&h->list) &&nvme_tryget_ns_head (h))return h;
@@ -3686,7 +3691,7 @@ static int nvme_init_ns_head(struct nvmeint ret =0 ;mutex_lock (&ctrl->subsys->lock); - head =nvme_find_ns_head (ctrl->subsys, nsid); + head =nvme_find_ns_head (ctrl, nsid);if (!head) { head =nvme_alloc_ns_head (ctrl, nsid, ids);if (IS_ERR (head)) {
drivers/nvme/host/multipath.c +4 -3
@@ -462,10 +462,11 @@ int nvme_mpath_alloc_disk(struct nvme_ct/* * Add a multipath node if the subsystems supports multiple controllers. -* We also do this for private namespaces as the namespace sharing data could -* change after a rescan. +* We also do this for private namespaces as the namespace sharing flag +* could change after a rescan. */ -if (!(ctrl->subsys->cmic &NVME_CTRL_CMIC_MULTI_CTRL ) || !multipath) +if (!(ctrl->subsys->cmic &NVME_CTRL_CMIC_MULTI_CTRL ) || + !nvme_is_unique_nsid (ctrl, head) || !multipath)return 0 ; head->disk =blk_alloc_disk (ctrl->numa_node);
drivers/nvme/host/nvme.h +19 -0
@@ -693,6 +693,25 @@ static inline bool nvme_check_ready(strureturn true;return __nvme_check_ready (ctrl, rq, queue_live); } + +/* +* NSID shall be unique for all shared namespaces, or if at least one of the +* following conditions is met: +* 1. Namespace Management is supported by the controller +* 2. ANA is supported by the controller +* 3. NVM Set are supported by the controller +* +* In other case, private namespace are not required to report a unique NSID. +*/ +static inline bool nvme_is_unique_nsid (struct nvme_ctrl *ctrl, +struct nvme_ns_head *head) +{ +return head->shared || + (ctrl->oacs &NVME_CTRL_OACS_NS_MNGT_SUPP ) || + (ctrl->subsys->cmic &NVME_CTRL_CMIC_ANA ) || + (ctrl->ctratt &NVME_CTRL_CTRATT_NVM_SETS ); +} +int nvme_submit_sync_cmd (struct request_queue *q,struct nvme_command *cmd,void *buf,unsigned bufflen); int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
include/linux/nvme.h +1 -0
@@ -322,6 +322,7 @@ enum {NVME_CTRL_ONCS_TIMESTAMP =1 <<6 ,NVME_CTRL_VWC_PRESENT =1 <<0 ,NVME_CTRL_OACS_SEC_SUPP =1 <<0 , +NVME_CTRL_OACS_NS_MNGT_SUPP =1 <<3 ,NVME_CTRL_OACS_DIRECTIVES =1 <<5 ,NVME_CTRL_OACS_DBBUF_SUPP =1 <<8 , NVME_CTRL_LPA_CMD_EFFECTS_LOG = 1 << 1,
Greg Kroah-Hartman
maintainerPATCH 827/913 nvme: fix the read-only state for zoned namespaces with unsupposed features
In reply to Greg Kroah-HartmanFrom: Pankaj Raghav <[email protected]>
commit 726be2c72efc0a64c206e854b8996ad3ab9c7507 upstream.
commit 2f4c9ba23b88 ("nvme: export zoned namespaces without Zone Append support read-only") marks zoned namespaces without append support read-only. It does iso by setting NVME_NS_FORCE_RO in ns->flags in nvme_update_zone_info and checking for that flag later in nvme_update_disk_info to mark the disk as read-only.
But commit 73d90386b559 ("nvme: cleanup zone information initialization") rearranged nvme_update_disk_info to be called before nvme_update_zone_info and thus not marking the disk as read-only. The call order cannot be just reverted because nvme_update_zone_info sets certain queue parameters such as zone_write_granularity that depend on the prior call to nvme_update_disk_info.
Remove the call to set_disk_ro in nvme_update_disk_info. and call set_disk_ro after nvme_update_zone_info and nvme_update_disk_info to set the permission for ZNS drives correctly. The same applies to the multipath disk path.
--- drivers/nvme/host/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/nvme/host/core.c +5 -3
@@ -1838,9 +1838,6 @@ static void nvme_update_disk_info(structnvme_config_discard (disk, ns);blk_queue_max_write_zeroes_sectors (disk->queue, ns->ctrl->max_zeroes_sectors); - -set_disk_ro (disk, (id->nsattr &NVME_NS_ATTR_RO ) || -test_bit (NVME_NS_FORCE_RO , &ns->flags)); }static inline bool nvme_first_scan (struct gendisk *disk)
@@ -1901,6 +1898,8 @@ static int nvme_update_ns_info(struct nv goto out_unfreeze; } +set_disk_ro (ns->disk, (id->nsattr &NVME_NS_ATTR_RO ) || +test_bit (NVME_NS_FORCE_RO , &ns->flags));set_bit (NVME_NS_READY , &ns->flags);blk_mq_unfreeze_queue (ns->disk->queue);
@@ -1913,6 +1912,9 @@ static int nvme_update_ns_info(struct nvif (nvme_ns_head_multipath (ns->head)) {blk_mq_freeze_queue (ns->head->disk->queue);nvme_update_disk_info (ns->head->disk, ns, id); +set_disk_ro (ns->head->disk, + (id->nsattr &NVME_NS_ATTR_RO ) || +test_bit (NVME_NS_FORCE_RO , &ns->flags));nvme_mpath_revalidate_paths (ns);blk_stack_limits (&ns->head->disk->queue->limits, &ns->queue->limits,0 );
Greg Kroah-Hartman
maintainerPATCH 828/913 wireguard: queueing: use CFI-safe ptr_ring cleanup function
In reply to Greg Kroah-HartmanFrom: Jason A. Donenfeld <[email protected]>
commit ec59f128a9bd4255798abb1e06ac3b442f46ef68 upstream.
We make too nuanced use of ptr_ring to entirely move to the skb_array wrappers, but we at least should avoid the naughty function pointer cast when cleaning up skbs. Otherwise RAP/CFI will honk at us. This patch uses the __skb_array_destroy_skb wrapper for the cleanup, rather than directly providing kfree_skb, which is what other drivers in the same situation do too.
--- drivers/net/wireguard/queueing.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireguard/queueing.c +2 -1
@@ -4,6 +4,7 @@*/ #include "queueing.h" +#include <linux/skb_array.h> struct multicore_worker __percpu *wg_packet_percpu_multicore_worker_alloc (work_func_t function,void *ptr)
@@ -42,7 +43,7 @@ void wg_packet_queue_free(struct crypt_q {free_percpu (queue->worker);WARN_ON (!purge && !__ptr_ring_empty (&queue->ring)); -ptr_ring_cleanup (&queue->ring, purge ? (void (*)(void *))kfree_skb :NULL ); +ptr_ring_cleanup (&queue->ring, purge ? __skb_array_destroy_skb :NULL ); }#define NEXT (skb) ((skb)->prev)
Greg Kroah-Hartman
maintainerPATCH 829/913 wireguard: socket: free skb in send6 when ipv6 is disabled
In reply to Greg Kroah-HartmanFrom: Wang Hai <[email protected]>
commit bbbf962d9460194993ee1943a793a0a0af4a7fbf upstream.
I got a memory leak report:
unreferenced object 0xffff8881191fc040 (size 232):
comm "kworker/u17:0", pid 23193, jiffies 4295238848 (age 3464.870s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff814c3ef4>] slab_post_alloc_hook+0x84/0x3b0
[<ffffffff814c8977>] kmem_cache_alloc_node+0x167/0x340
[<ffffffff832974fb>] __alloc_skb+0x1db/0x200
[<ffffffff82612b5d>] wg_socket_send_buffer_to_peer+0x3d/0xc0
[<ffffffff8260e94a>] wg_packet_send_handshake_initiation+0xfa/0x110
[<ffffffff8260ec81>] wg_packet_handshake_send_worker+0x21/0x30
[<ffffffff8119c558>] process_one_work+0x2e8/0x770
[<ffffffff8119ca2a>] worker_thread+0x4a/0x4b0
[<ffffffff811a88e0>] kthread+0x120/0x160
[<ffffffff8100242f>] ret_from_fork+0x1f/0x30In function wg_socket_send_buffer_as_reply_to_skb() or wg_socket_send_ buffer_to_peer(), the semantics of send6() is required to free skb. But when CONFIG_IPV6 is disable, kfree_skb() is missing. This patch adds it to fix this bug.
--- drivers/net/wireguard/socket.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireguard/socket.c +1 -0
@@ -160,6 +160,7 @@ out:rcu_read_unlock_bh ();return ret;#else +kfree_skb (skb);return -EAFNOSUPPORT ;#endif }
Greg Kroah-Hartman
maintainerPATCH 830/913 wireguard: socket: ignore v6 endpoints when ipv6 is disabled
In reply to Greg Kroah-HartmanFrom: Jason A. Donenfeld <[email protected]>
commit 77fc73ac89be96ec8f39e8efa53885caa7cb3645 upstream.
The previous commit fixed a memory leak on the send path in the event that IPv6 is disabled at compile time, but how did a packet even arrive there to begin with? It turns out we have previously allowed IPv6 endpoints even when IPv6 support is disabled at compile time. This is awkward and inconsistent. Instead, let's just ignore all things IPv6, the same way we do other malformed endpoints, in the case where IPv6 is disabled.
--- drivers/net/wireguard/socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireguard/socket.c +2 -2
@@ -242,7 +242,7 @@ int wg_socket_endpoint_from_skb(struct e endpoint->addr4.sin_addr.s_addr =ip_hdr (skb)->saddr; endpoint->src4.s_addr =ip_hdr (skb)->daddr; endpoint->src_if4 = skb->skb_iif; - }else if (skb->protocol ==htons (ETH_P_IPV6 )) { + }else if (IS_ENABLED (CONFIG_IPV6 ) && skb->protocol ==htons (ETH_P_IPV6 )) { endpoint->addr6.sin6_family =AF_INET6 ; endpoint->addr6.sin6_port =udp_hdr (skb)->source; endpoint->addr6.sin6_addr =ipv6_hdr (skb)->saddr;
@@ -285,7 +285,7 @@ void wg_socket_set_peer_endpoint(struct peer->endpoint.addr4 = endpoint->addr4; peer->endpoint.src4 = endpoint->src4; peer->endpoint.src_if4 = endpoint->src_if4; - }else if (endpoint->addr.sa_family ==AF_INET6 ) { + }else if (IS_ENABLED (CONFIG_IPV6 ) && endpoint->addr.sa_family ==AF_INET6 ) { peer->endpoint.addr6 = endpoint->addr6; peer->endpoint.src6 = endpoint->src6; }else {
Greg Kroah-Hartman
maintainerPATCH 831/913 XArray: Fix xas_create_range() when multi-order entry present
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
commit 3e3c658055c002900982513e289398a1aad4a488 upstream.
If there is already an entry present that is of order >= XA_CHUNK_SHIFT when we call xas_create_range(), xas_create_range() will misinterpret that entry as a node and dereference xa_node->parent, generally leading to a crash that looks something like this:
general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] CPU: 0 PID: 32 Comm: khugepaged Not tainted 5.17.0-rc8-syzkaller-00003-g56e337f2cf13 #0 RIP: 0010:xa_parent_locked include/linux/xarray.h:1207 [inline] RIP: 0010:xas_create_range+0x2d9/0x6e0 lib/xarray.c:725
It's deterministically reproducable once you know what the problem is, but producing it in a live kernel requires khugepaged to hit a race. While the problem has been present since xas_create_range() was introduced, I'm not aware of a way to hit it before the page cache was converted to use multi-index entries.
--- lib/test_xarray.c | 22 ++++++++++++++++++++++ lib/xarray.c | 2 ++ 2 files changed, 24 insertions(+)
lib/test_xarray.c +22 -0
@@ -1463,6 +1463,25 @@ unlock:XA_BUG_ON (xa, !xa_empty (xa)); } +static noinline void check_create_range_5(struct xarray *xa, +unsigned long index,unsigned int order) +{ +XA_STATE_ORDER (xas, xa, index, order); +unsigned int i; + +xa_store_order (xa, index, order,xa_mk_index (index),GFP_KERNEL ); + +for (i =0 ; i < order +10 ; i++) { +do { +xas_lock (&xas); +xas_create_range (&xas); +xas_unlock (&xas); + }while (xas_nomem (&xas,GFP_KERNEL )); + } + +xa_destroy (xa); +} + static noinline void check_create_range(struct xarray *xa) {unsigned int order;
@@ -1490,6 +1509,9 @@ static noinline void check_create_range(check_create_range_4 (xa, (3U << order) +1 , order);check_create_range_4 (xa, (3U << order) -1 , order);check_create_range_4 (xa, (1U <<24 ) +1 , order); + +check_create_range_5 (xa,0 , order); +check_create_range_5 (xa, (1U << order), order); }check_create_range_3 ();
lib/xarray.c +2 -0
@@ -722,6 +722,8 @@ void xas_create_range(struct xa_state *xfor (;;) {struct xa_node *node = xas->xa_node; +if (node->shift >= shift) +break ; xas->xa_node =xa_parent_locked (xas->xa, node); xas->xa_offset = node->offset -1 ;if (node->offset !=0 )
Greg Kroah-Hartman
maintainerPATCH 832/913 can: mcba_usb: mcba_usb_start_xmit(): fix double dev_kfree_skb in error path
In reply to Greg Kroah-HartmanFrom: Hangyu Hua <[email protected]>
commit 04c9b00ba83594a29813d6b1fb8fdc93a3915174 upstream.
There is no need to call dev_kfree_skb() when usb_submit_urb() fails because can_put_echo_skb() deletes original skb and can_free_echo_skb() deletes the cloned skb.
--- drivers/net/can/usb/mcba_usb.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/can/usb/mcba_usb.c +0 -1
@@ -368,7 +368,6 @@ static netdev_tx_t mcba_usb_start_xmit(s xmit_failed:can_free_echo_skb (priv->netdev, ctx->ndx,NULL );mcba_usb_free_ctx (ctx); -dev_kfree_skb (skb); stats->tx_dropped++;return NETDEV_TX_OK ;
Greg Kroah-Hartman
maintainerPATCH 833/913 can: mcba_usb: properly check endpoint type
In reply to Greg Kroah-HartmanFrom: Pavel Skripkin <[email protected]>
commit 136bed0bfd3bc9c95c88aafff2d22ecb3a919f23 upstream.
Syzbot reported warning in usb_submit_urb() which is caused by wrong endpoint type. We should check that in endpoint is actually present to prevent this warning.
Found pipes are now saved to struct mcba_priv and code uses them directly instead of making pipes in place.
Fail log:
| usb 5-1: BOGUS urb xfer, pipe 3 != type 1 | WARNING: CPU: 1 PID: 49 at drivers/usb/core/urb.c:502 usb_submit_urb+0xed2/0x18a0 drivers/usb/core/urb.c:502 | Modules linked in: | CPU: 1 PID: 49 Comm: kworker/1:2 Not tainted 5.17.0-rc6-syzkaller-00184-g38f80f42147f #0 | Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014 | Workqueue: usb_hub_wq hub_event | RIP: 0010:usb_submit_urb+0xed2/0x18a0 drivers/usb/core/urb.c:502 | ... | Call Trace: | <TASK> | mcba_usb_start drivers/net/can/usb/mcba_usb.c:662 [inline] | mcba_usb_probe+0x8a3/0xc50 drivers/net/can/usb/mcba_usb.c:858 | usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:396 | call_driver_probe drivers/base/dd.c:517 [inline]
--- drivers/net/can/usb/mcba_usb.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
drivers/net/can/usb/mcba_usb.c +16 -10
@@ -33,10 +33,6 @@#define MCBA_USB_RX_BUFF_SIZE 64#define MCBA_USB_TX_BUFF_SIZE (sizeof(struct mcba_usb_msg)) -/* MCBA endpoint numbers */ -#define MCBA_USB_EP_IN 1 -#define MCBA_USB_EP_OUT 1 -/* Microchip command id */ #define MBCA_CMD_RECEIVE_MESSAGE 0xE3#define MBCA_CMD_I_AM_ALIVE_FROM_CAN 0xF5
@@ -84,6 +80,8 @@ struct mcba_priv {atomic_t free_ctx_cnt;void *rxbuf[MCBA_MAX_RX_URBS ];dma_addr_t rxbuf_dma[MCBA_MAX_RX_URBS ]; +int rx_pipe; +int tx_pipe; };/* CAN frame */
@@ -272,10 +270,8 @@ static netdev_tx_t mcba_usb_xmit(structmemcpy (buf, usb_msg,MCBA_USB_TX_BUFF_SIZE ); -usb_fill_bulk_urb (urb, priv->udev, -usb_sndbulkpipe (priv->udev,MCBA_USB_EP_OUT ), buf, -MCBA_USB_TX_BUFF_SIZE , mcba_usb_write_bulk_callback, - ctx); +usb_fill_bulk_urb (urb, priv->udev, priv->tx_pipe, buf,MCBA_USB_TX_BUFF_SIZE , + mcba_usb_write_bulk_callback, ctx); urb->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ;usb_anchor_urb (urb, &priv->tx_submitted);
@@ -610,7 +606,7 @@ static void mcba_usb_read_bulk_callback( resubmit_urb:usb_fill_bulk_urb (urb, priv->udev, -usb_rcvbulkpipe (priv->udev,MCBA_USB_EP_OUT ), + priv->rx_pipe, urb->transfer_buffer,MCBA_USB_RX_BUFF_SIZE , mcba_usb_read_bulk_callback, priv);
@@ -655,7 +651,7 @@ static int mcba_usb_start(struct mcba_pr urb->transfer_dma = buf_dma;usb_fill_bulk_urb (urb, priv->udev, -usb_rcvbulkpipe (priv->udev,MCBA_USB_EP_IN ), + priv->rx_pipe, buf,MCBA_USB_RX_BUFF_SIZE , mcba_usb_read_bulk_callback, priv); urb->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ;
@@ -809,6 +805,13 @@ static int mcba_usb_probe(struct usb_intstruct mcba_priv *priv;int err;struct usb_device *usbdev =interface_to_usbdev (intf); +struct usb_endpoint_descriptor *in, *out; + + err =usb_find_common_endpoints (intf->cur_altsetting, &in, &out,NULL ,NULL ); +if (err) { +dev_err (&intf->dev,"Can't find endpoints\n" ); +return err; + } netdev =alloc_candev (sizeof (struct mcba_priv ),MCBA_MAX_TX_URBS );if (!netdev) {
@@ -854,6 +857,9 @@ static int mcba_usb_probe(struct usb_int goto cleanup_free_candev; } + priv->rx_pipe =usb_rcvbulkpipe (priv->udev, in->bEndpointAddress); + priv->tx_pipe =usb_sndbulkpipe (priv->udev, out->bEndpointAddress); +devm_can_led_init (netdev);/* Start USB dev only if we have successfully registered CAN device */
Greg Kroah-Hartman
maintainerPATCH 834/913 can: mcp251xfd: mcp251xfd_register_get_dev_id(): fix return of error value
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
commit fa7b514d2b2894e052b8e94c7a29feb98e90093f upstream.
Clang static analysis reports this issue:
| mcp251xfd-core.c:1813:7: warning: The left operand | of '&' is a garbage value | FIELD_GET(MCP251XFD_REG_DEVID_ID_MASK, dev_id), | ^ ~~~~~~
dev_id is set in a successful call to mcp251xfd_register_get_dev_id(). Though the status of calls made by mcp251xfd_register_get_dev_id() are checked and handled, their status' are not returned. So return err.
--- drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c +1 -1
@@ -2706,7 +2706,7 @@ mcp251xfd_register_get_dev_id(const stru out_kfree_buf_rx:kfree (buf_rx); -return 0 ; +return err; }#define MCP251XFD_QUIRK_ACTIVE (quirk) \
Greg Kroah-Hartman
maintainerPATCH 835/913 XArray: Update the LRU list in xas_split()
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
commit 3ed4bb77156da0bc732847c8c9df92454c1fbeea upstream.
When splitting a value entry, we may need to add the new nodes to the LRU list and remove the parent node from the LRU list. The WARN_ON checks in shadow_lru_isolate() catch this oversight. This bug was latent until we stopped splitting folios in shrink_page_list() with commit 820c4e2e6f51 ("mm/vmscan: Free non-shmem folios without splitting them"). That allows the creation of large shadow entries, and subsequently when trying to page in a small page, we will split the large shadow entry in __filemap_add_folio().
--- lib/xarray.c | 2 ++ 1 file changed, 2 insertions(+)
lib/xarray.c +2 -0
@@ -1081,6 +1081,7 @@ void xas_split(struct xa_state *xas, voi xa_mk_node(child));if (xa_is_value (curr)) values--; +xas_update (xas, child); }else {unsigned int canon = offset - xas->xa_sibs;
@@ -1095,6 +1096,7 @@ void xas_split(struct xa_state *xas, voi } while (offset-- > xas->xa_offset); node->nr_values += values; +xas_update (xas, node); }EXPORT_SYMBOL_GPL (xas_split);#endif
Greg Kroah-Hartman
maintainerPATCH 836/913 modpost: restore the warning message for missing symbol versions
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
commit bf5c0c2231bcab677e5cdfb7f73e6c79f6d8c2d4 upstream.
This log message was accidentally chopped off.
I was wondering why this happened, but checking the ML log, Mark precisely followed my suggestion [1].
I just used "..." because I was too lazy to type the sentence fully. Sorry for the confusion.
[1]: https://lore.kernel.org/all/CAK7LNAR6bXXk9-ZzZYpTqzFqdYbQsZHmiWspu27rtsFxvfRuVA@mail.gmail.com/
--- scripts/mod/modpost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mod/modpost.c +1 -1
@@ -669,7 +669,7 @@ static void handle_modversion(const struunsigned int crc;if (sym->st_shndx ==SHN_UNDEF ) { -warn ("EXPORT symbol \"%s\" [%s%s] version ...\n" +warn ("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n" "Is \"%s\" prototyped in <asm/asm-prototypes.h>?\n" , symname, mod->name, mod->is_vmlinux ?"" :".ko" , symname);
Greg Kroah-Hartman
maintainerPATCH 837/913 rtc: check if __rtc_read_time was successful
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
commit 915593a7a663b2ad08b895a5f3ba8b19d89d4ebf upstream.
Clang static analysis reports this issue interface.c:810:8: warning: Passed-by-value struct
argument contains uninitialized data
now = rtc_tm_to_ktime(tm);
^~~~~~~~~~~~~~~~~~~tm is set by a successful call to __rtc_read_time() but its return status is not checked. Check if it was successful before setting the enabled flag. Move the decl of err to function scope.
--- drivers/rtc/interface.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/rtc/interface.c +5 -2
@@ -793,9 +793,13 @@ static int rtc_timer_enqueue(struct rtc_struct timerqueue_node *next =timerqueue_getnext (&rtc->timerqueue);struct rtc_time tm;ktime_t now; +int err; + + err =__rtc_read_time (rtc, &tm); +if (err) +return err; timer->enabled =1 ; -__rtc_read_time (rtc, &tm); now =rtc_tm_to_ktime (tm);/* Skip over expired timers */
@@ -809,7 +813,6 @@ static int rtc_timer_enqueue(struct rtc_trace_rtc_timer_enqueue (timer);if (!next ||ktime_before (timer->node.expires, next->expires)) {struct rtc_wkalrm alarm; -int err; alarm.time =rtc_ktime_to_tm (timer->node.expires); alarm.enabled =1 ;
Greg Kroah-Hartman
maintainerPATCH 838/913 gfs2: gfs2_setattr_size error path fix
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
commit 7336905a89f19173bf9301cd50a24421162f417c upstream.
When gfs2_setattr_size() fails, it calls gfs2_rs_delete(ip, NULL) to get rid of any reservations the inode may have. Instead, it should pass in the inode's write count as the second parameter to allow gfs2_rs_delete() to figure out if the inode has any writers left.
In a next step, there are two instances of gfs2_rs_delete(ip, NULL) left where we know that there can be no other users of the inode. Replace those with gfs2_rs_deltree(&ip->i_res) to avoid the unnecessary write count check.
With that, gfs2_rs_delete() is only called with the inode's actual write count, so get rid of the second parameter.
--- fs/gfs2/bmap.c | 2 +- fs/gfs2/file.c | 2 +- fs/gfs2/inode.c | 2 +- fs/gfs2/rgrp.c | 7 ++++--- fs/gfs2/rgrp.h | 2 +- fs/gfs2/super.c | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-)
fs/gfs2/bmap.c +1 -1
@@ -2204,7 +2204,7 @@ int gfs2_setattr_size(struct inode *inod ret =do_shrink (inode, newsize); out: -gfs2_rs_delete (ip,NULL ); +gfs2_rs_delete (ip);gfs2_qa_put (ip);return ret; }
fs/gfs2/file.c +1 -1
@@ -713,7 +713,7 @@ static int gfs2_release(struct inode *inif (file->f_mode &FMODE_WRITE ) {if (gfs2_rs_active (&ip->i_res)) -gfs2_rs_delete (ip, &inode->i_writecount); +gfs2_rs_delete (ip);gfs2_qa_put (ip); }return 0 ;
fs/gfs2/inode.c +1 -1
@@ -811,7 +811,7 @@ fail_free_inode:if (free_vfs_inode)/* else evict will do the put for us */ gfs2_glock_put (ip->i_gl); } -gfs2_rs_delete (ip,NULL ); +gfs2_rs_deltree (&ip->i_res);gfs2_qa_put (ip); fail_free_acls:posix_acl_release (default_acl);
fs/gfs2/rgrp.c +4 -3
@@ -680,13 +680,14 @@ void gfs2_rs_deltree(struct gfs2_blkrese/** * gfs2_rs_delete - delete a multi-block reservation * @ip: The inode for this reservation -* @wcount: The inode's write count, or NULL * */ -void gfs2_rs_delete (struct gfs2_inode *ip,atomic_t *wcount) +void gfs2_rs_delete (struct gfs2_inode *ip) { +struct inode *inode = &ip->i_inode; +down_write (&ip->i_rw_mutex); -if ((wcount ==NULL ) || (atomic_read (wcount) <=1 )) +if (atomic_read (&inode->i_writecount) <=1 )gfs2_rs_deltree (&ip->i_res);up_write (&ip->i_rw_mutex); }
fs/gfs2/rgrp.h +1 -1
@@ -45,7 +45,7 @@ extern int gfs2_alloc_blocks(struct gfs2 bool dinode, u64 *generation);extern void gfs2_rs_deltree (struct gfs2_blkreserv *rs); -extern void gfs2_rs_delete (struct gfs2_inode *ip,atomic_t *wcount); +extern void gfs2_rs_delete (struct gfs2_inode *ip);extern void __gfs2_free_blocks (struct gfs2_inode *ip,struct gfs2_rgrpd *rgd,u64 bstart,u32 blen,int meta); extern void gfs2_free_meta(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
fs/gfs2/super.c +1 -1
@@ -1398,7 +1398,7 @@ out:truncate_inode_pages_final (&inode->i_data);if (ip->i_qadata)gfs2_assert_warn (sdp, ip->i_qadata->qa_ref ==0 ); -gfs2_rs_delete (ip,NULL ); +gfs2_rs_deltree (&ip->i_res);gfs2_ordered_del_inode (ip);clear_inode (inode);gfs2_dir_hash_inval (ip);
Greg Kroah-Hartman
maintainerPATCH 839/913 gfs2: Make sure FITRIM minlen is rounded up to fs block size
In reply to Greg Kroah-HartmanFrom: Andrew Price <[email protected]>
commit 27ca8273fda398638ca994a207323a85b6d81190 upstream.
Per fstrim(8) we must round up the minlen argument to the fs block size. The current calculation doesn't take into account devices that have a discard granularity and requested minlen less than 1 fs block, so the value can get shifted away to zero in the translation to fs blocks.
The zero minlen passed to gfs2_rgrp_send_discards() then allows sb_issue_discard() to be called with nr_sects == 0 which returns -EINVAL and results in gfs2_rgrp_send_discards() returning -EIO.
Make sure minlen is never < 1 fs block by taking the max of the requested minlen and the fs block size before comparing to the device's discard granularity and shifting to fs blocks.
--- fs/gfs2/rgrp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/gfs2/rgrp.c +2 -1
@@ -1428,7 +1428,8 @@ int gfs2_fitrim(struct file *filp, void start = r.start >> bs_shift; end = start + (r.len >> bs_shift); - minlen =max_t (u64, r.minlen, + minlen =max_t (u64, r.minlen, sdp->sd_sb.sb_bsize); + minlen =max_t (u64, minlen, q->limits.discard_granularity) >> bs_shift;if (end <= start || minlen > sdp->sd_max_rg_data)