l2tp: prevent possible tunnel refcount underflow
Subsystems (38)
Sasha Levin
maintainerPATCH 112/244 rcu-tasks: Fix access non-existent percpu rtpcp variable in rcu_tasks_need_gpcb()
In reply to Sasha LevinFrom: Zqiang <[email protected]>
[ Upstream commit fd70e9f1d85f5323096ad313ba73f5fe3d15ea41 ]
For kernels built with CONFIG_FORCE_NR_CPUS=y, the nr_cpu_ids is defined as NR_CPUS instead of the number of possible cpus, this will cause the following system panic:
smpboot: Allowing 4 CPUs, 0 hotplug CPUs
...setup_percpu: NR_CPUS:512 nr_cpumask_bits:512 nr_cpu_ids:512 nr_node_ids:1
...
BUG: unable to handle page fault for address: ffffffff9911c8c8 Oops: 0000 [#1] PREEMPT SMP PTI CPU: 0 PID: 15 Comm: rcu_tasks_trace Tainted: G W 6.6.21 #1 5dc7acf91a5e8e9ac9dcfc35bee0245691283ea6 RIP: 0010:rcu_tasks_need_gpcb+0x25d/0x2c0 RSP: 0018:ffffa371c00a3e60 EFLAGS: 00010082 CR2: ffffffff9911c8c8 CR3: 000000040fa20005 CR4: 00000000001706f0 Call Trace: <TASK> ? __die+0x23/0x80 ? page_fault_oops+0xa4/0x180 ? exc_page_fault+0x152/0x180 ? asm_exc_page_fault+0x26/0x40 ? rcu_tasks_need_gpcb+0x25d/0x2c0 ? __pfx_rcu_tasks_kthread+0x40/0x40 rcu_tasks_one_gp+0x69/0x180 rcu_tasks_kthread+0x94/0xc0 kthread+0xe8/0x140 ? __pfx_kthread+0x40/0x40 ret_from_fork+0x34/0x80 ? __pfx_kthread+0x40/0x40 ret_from_fork_asm+0x1b/0x80 </TASK>
Considering that there may be holes in the CPU numbers, use the maximum possible cpu number, instead of nr_cpu_ids, for configuring enqueue and dequeue limits.
[ neeraj.upadhyay: Fix htmldocs build error reported by Stephen Rothwell ]
--- kernel/rcu/tasks.h | 82 ++++++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 29 deletions(-)
kernel/rcu/tasks.h +53 -29
@@ -34,6 +34,7 @@ typedef void (*postgp_func_t)(struct rcu_tasks *rtp);* @rtp_blkd_tasks: List of tasks blocked as readers. * @rtp_exit_list: List of tasks in the latter portion of do_exit(). * @cpu: CPU number corresponding to this entry. +* @index: Index of this CPU in rtpcp_array of the rcu_tasks structure. * @rtpp: Pointer to the rcu_tasks structure. */ struct rcu_tasks_percpu {
@@ -49,6 +50,7 @@ struct rcu_tasks_percpu {struct list_head rtp_blkd_tasks;struct list_head rtp_exit_list;int cpu; +int index;struct rcu_tasks *rtpp; };
@@ -76,6 +78,7 @@ struct rcu_tasks_percpu {* @call_func: This flavor's call_rcu()-equivalent function. * @wait_state: Task state for synchronous grace-period waits (default TASK_UNINTERRUPTIBLE). * @rtpcpu: This flavor's rcu_tasks_percpu structure. +* @rtpcp_array: Array of pointers to rcu_tasks_percpu structure of CPUs in cpu_possible_mask. * @percpu_enqueue_shift: Shift down CPU ID this much when enqueuing callbacks. * @percpu_enqueue_lim: Number of per-CPU callback queues in use for enqueuing. * @percpu_dequeue_lim: Number of per-CPU callback queues in use for dequeuing.
@@ -110,6 +113,7 @@ struct rcu_tasks {call_rcu_func_t call_func;unsigned int wait_state;struct rcu_tasks_percpu __percpu *rtpcpu; +struct rcu_tasks_percpu **rtpcp_array;int percpu_enqueue_shift;int percpu_enqueue_lim;int percpu_dequeue_lim;
@@ -182,6 +186,8 @@ module_param(rcu_task_collapse_lim, int, 0444);static int rcu_task_lazy_lim__read_mostly =32 ;module_param (rcu_task_lazy_lim, int,0444 ); +static int rcu_task_cpu_ids; +/* RCU tasks grace-period state for debugging. */ #define RTGS_INIT 0#define RTGS_WAIT_WAIT_CBS 1
@@ -245,6 +251,8 @@ static void cblist_init_generic(struct rcu_tasks *rtp)int cpu;int lim;int shift; +int maxcpu; +int index =0 ;if (rcu_task_enqueue_lim <0 ) { rcu_task_enqueue_lim =1 ;
@@ -254,14 +262,9 @@ static void cblist_init_generic(struct rcu_tasks *rtp) } lim = rcu_task_enqueue_lim; -if (lim > nr_cpu_ids) - lim = nr_cpu_ids; - shift =ilog2 (nr_cpu_ids / lim); -if (((nr_cpu_ids -1 ) >> shift) >= lim) - shift++; -WRITE_ONCE (rtp->percpu_enqueue_shift, shift); -WRITE_ONCE (rtp->percpu_dequeue_lim, lim); -smp_store_release (&rtp->percpu_enqueue_lim, lim); + rtp->rtpcp_array =kcalloc (num_possible_cpus (),sizeof (struct rcu_tasks_percpu *),GFP_KERNEL ); +BUG_ON (!rtp->rtpcp_array); +for_each_possible_cpu (cpu) {struct rcu_tasks_percpu *rtpcp =per_cpu_ptr (rtp->rtpcpu, cpu);
@@ -273,14 +276,29 @@ static void cblist_init_generic(struct rcu_tasks *rtp)INIT_WORK (&rtpcp->rtp_work, rcu_tasks_invoke_cbs_wq); rtpcp->cpu = cpu; rtpcp->rtpp = rtp; + rtpcp->index = index; + rtp->rtpcp_array[index] = rtpcp; + index++;if (!rtpcp->rtp_blkd_tasks.next)INIT_LIST_HEAD (&rtpcp->rtp_blkd_tasks);if (!rtpcp->rtp_exit_list.next)INIT_LIST_HEAD (&rtpcp->rtp_exit_list); + maxcpu = cpu; } -pr_info ("%s: Setting shift to %d and lim to %d rcu_task_cb_adjust=%d.\n" , rtp->name, -data_race (rtp->percpu_enqueue_shift),data_race (rtp->percpu_enqueue_lim), rcu_task_cb_adjust); + rcu_task_cpu_ids = maxcpu +1 ; +if (lim > rcu_task_cpu_ids) + lim = rcu_task_cpu_ids; + shift =ilog2 (rcu_task_cpu_ids / lim); +if (((rcu_task_cpu_ids -1 ) >> shift) >= lim) + shift++; +WRITE_ONCE (rtp->percpu_enqueue_shift, shift); +WRITE_ONCE (rtp->percpu_dequeue_lim, lim); +smp_store_release (&rtp->percpu_enqueue_lim, lim); + +pr_info ("%s: Setting shift to %d and lim to %d rcu_task_cb_adjust=%d rcu_task_cpu_ids=%d.\n" , + rtp->name,data_race (rtp->percpu_enqueue_shift),data_race (rtp->percpu_enqueue_lim), + rcu_task_cb_adjust, rcu_task_cpu_ids); }// Compute wakeup time for lazy callback timer.
@@ -348,7 +366,7 @@ static void call_rcu_tasks_generic(struct rcu_head *rhp, rcu_callback_t func, rtpcp->rtp_n_lock_retries =0 ; }if (rcu_task_cb_adjust && ++rtpcp->rtp_n_lock_retries > rcu_task_contend_lim && -READ_ONCE (rtp->percpu_enqueue_lim) != nr_cpu_ids) +READ_ONCE (rtp->percpu_enqueue_lim) != rcu_task_cpu_ids) needadjust = true;// Defer adjustment to avoid deadlock. }// Queuing callbacks before initialization not yet supported.
@@ -368,10 +386,10 @@ static void call_rcu_tasks_generic(struct rcu_head *rhp, rcu_callback_t func,raw_spin_unlock_irqrestore_rcu_node (rtpcp, flags);if (unlikely (needadjust)) {raw_spin_lock_irqsave (&rtp->cbs_gbl_lock, flags); -if (rtp->percpu_enqueue_lim != nr_cpu_ids) { +if (rtp->percpu_enqueue_lim != rcu_task_cpu_ids) {WRITE_ONCE (rtp->percpu_enqueue_shift,0 ); -WRITE_ONCE (rtp->percpu_dequeue_lim, nr_cpu_ids); -smp_store_release (&rtp->percpu_enqueue_lim, nr_cpu_ids); +WRITE_ONCE (rtp->percpu_dequeue_lim, rcu_task_cpu_ids); +smp_store_release (&rtp->percpu_enqueue_lim, rcu_task_cpu_ids);pr_info ("Switching %s to per-CPU callback queuing.\n" , rtp->name); }raw_spin_unlock_irqrestore (&rtp->cbs_gbl_lock, flags);
@@ -444,6 +462,8 @@ static int rcu_tasks_need_gpcb(struct rcu_tasks *rtp) dequeue_limit =smp_load_acquire (&rtp->percpu_dequeue_lim);for (cpu =0 ; cpu < dequeue_limit; cpu++) { +if (!cpu_possible (cpu)) +continue ;struct rcu_tasks_percpu *rtpcp =per_cpu_ptr (rtp->rtpcpu, cpu);/* Advance and accelerate any new callbacks. */
@@ -481,7 +501,7 @@ static int rcu_tasks_need_gpcb(struct rcu_tasks *rtp)if (rcu_task_cb_adjust && ncbs <= rcu_task_collapse_lim) {raw_spin_lock_irqsave (&rtp->cbs_gbl_lock, flags);if (rtp->percpu_enqueue_lim >1 ) { -WRITE_ONCE (rtp->percpu_enqueue_shift,order_base_2 (nr_cpu_ids)); +WRITE_ONCE (rtp->percpu_enqueue_shift,order_base_2 (rcu_task_cpu_ids));smp_store_release (&rtp->percpu_enqueue_lim,1 ); rtp->percpu_dequeue_gpseq =get_state_synchronize_rcu (); gpdone = false;
@@ -496,7 +516,9 @@ static int rcu_tasks_need_gpcb(struct rcu_tasks *rtp)pr_info ("Completing switch %s to CPU-0 callback queuing.\n" , rtp->name); }if (rtp->percpu_dequeue_lim ==1 ) { -for (cpu = rtp->percpu_dequeue_lim; cpu < nr_cpu_ids; cpu++) { +for (cpu = rtp->percpu_dequeue_lim; cpu < rcu_task_cpu_ids; cpu++) { +if (!cpu_possible (cpu)) +continue ;struct rcu_tasks_percpu *rtpcp =per_cpu_ptr (rtp->rtpcpu, cpu);WARN_ON_ONCE (rcu_segcblist_n_cbs (&rtpcp->cblist));
@@ -511,30 +533,32 @@ static int rcu_tasks_need_gpcb(struct rcu_tasks *rtp)// Advance callbacks and invoke any that are ready. static void rcu_tasks_invoke_cbs (struct rcu_tasks *rtp,struct rcu_tasks_percpu *rtpcp) { -int cpu; -int cpunext;int cpuwq;unsigned long flags;int len; +int index;struct rcu_head *rhp;struct rcu_cblist rcl =RCU_CBLIST_INITIALIZER (rcl);struct rcu_tasks_percpu *rtpcp_next; - cpu = rtpcp->cpu; - cpunext = cpu *2 +1 ; -if (cpunext <smp_load_acquire (&rtp->percpu_dequeue_lim)) { - rtpcp_next =per_cpu_ptr (rtp->rtpcpu, cpunext); - cpuwq =rcu_cpu_beenfullyonline (cpunext) ? cpunext :WORK_CPU_UNBOUND ; -queue_work_on (cpuwq, system_wq, &rtpcp_next->rtp_work); - cpunext++; -if (cpunext <smp_load_acquire (&rtp->percpu_dequeue_lim)) { - rtpcp_next =per_cpu_ptr (rtp->rtpcpu, cpunext); - cpuwq =rcu_cpu_beenfullyonline (cpunext) ? cpunext :WORK_CPU_UNBOUND ; + index = rtpcp->index *2 +1 ; +if (index <num_possible_cpus ()) { + rtpcp_next = rtp->rtpcp_array[index]; +if (rtpcp_next->cpu <smp_load_acquire (&rtp->percpu_dequeue_lim)) { + cpuwq =rcu_cpu_beenfullyonline (rtpcp_next->cpu) ? rtpcp_next->cpu :WORK_CPU_UNBOUND ;queue_work_on (cpuwq, system_wq, &rtpcp_next->rtp_work); + index++; +if (index <num_possible_cpus ()) { + rtpcp_next = rtp->rtpcp_array[index]; +if (rtpcp_next->cpu <smp_load_acquire (&rtp->percpu_dequeue_lim)) { + cpuwq =rcu_cpu_beenfullyonline (rtpcp_next->cpu) ? rtpcp_next->cpu :WORK_CPU_UNBOUND ; +queue_work_on (cpuwq, system_wq, &rtpcp_next->rtp_work); + } + } } } -if (rcu_segcblist_empty (&rtpcp->cblist) || !cpu_possible (cpu)) +if (rcu_segcblist_empty (&rtpcp->cblist))return ;raw_spin_lock_irqsave_rcu_node (rtpcp, flags);rcu_segcblist_advance (&rtpcp->cblist,rcu_seq_current (&rtp->tasks_gp_seq));
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 113/244 hwmon: (nct6775) add G15CF to ASUS WMI monitoring list
In reply to Sasha LevinFrom: Denis Pauk <[email protected]>
[ Upstream commit 1f432e4cf1dd3ecfec5ed80051b4611632a0fd51 ]
Boards G15CF has got a nct6775 chip, but by default there's no use of it because of resource conflict with WMI method.
Add the board to the WMI monitoring list.
Message-ID: <[email protected]>
--- drivers/hwmon/nct6775-platform.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwmon/nct6775-platform.c +1 -0
@@ -1269,6 +1269,7 @@ static const char * const asus_msi_boards[] = {"EX-B760M-V5 D4" ,"EX-H510M-V3" ,"EX-H610M-V3 D4" , +"G15CF" ,"PRIME A620M-A" ,"PRIME B560-PLUS" , "PRIME B560-PLUS AC-HES",
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 114/244 fbdev: efifb: Register sysfs groups through driver core
In reply to Sasha LevinFrom: Thomas Weißschuh <[email protected]>
[ Upstream commit 95cdd538e0e5677efbdf8aade04ec098ab98f457 ]
The driver core can register and cleanup sysfs groups already. Make use of that functionality to simplify the error handling and cleanup.
Also avoid a UAF race during unregistering where the sysctl attributes were usable after the info struct was freed.
--- drivers/video/fbdev/efifb.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/video/fbdev/efifb.c +2 -9
@@ -561,15 +561,10 @@ static int efifb_probe(struct platform_device *dev)break ; } - err =sysfs_create_groups (&dev->dev.kobj, efifb_groups); -if (err) { -pr_err ("efifb: cannot add sysfs attrs\n" ); - goto err_unmap; - } err =fb_alloc_cmap (&info->cmap,256 ,0 );if (err <0 ) {pr_err ("efifb: cannot allocate colormap\n" ); - goto err_groups; + goto err_unmap; } err =devm_aperture_acquire_for_platform_device (dev, par->base, par->size);
@@ -587,8 +582,6 @@ static int efifb_probe(struct platform_device *dev) err_fb_dealloc_cmap:fb_dealloc_cmap (&info->cmap); -err_groups: -sysfs_remove_groups (&dev->dev.kobj, efifb_groups); err_unmap:if (mem_flags & (EFI_MEMORY_UC |EFI_MEMORY_WC ))iounmap (info->screen_base);
@@ -608,12 +601,12 @@ static void efifb_remove(struct platform_device *pdev)/* efifb_destroy takes care of info cleanup */ unregister_framebuffer (info); -sysfs_remove_groups (&pdev->dev.kobj, efifb_groups); }static struct platform_driver efifb_driver = { .driver = { .name ="efi-framebuffer" , + .dev_groups = efifb_groups, }, .probe = efifb_probe, .remove_new = efifb_remove,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 115/244 fbdev: pxafb: Fix possible use after free in pxafb_task()
In reply to Sasha LevinFrom: Kaixin Wang <[email protected]>
[ Upstream commit 4a6921095eb04a900e0000da83d9475eb958e61e ]
In the pxafb_probe function, it calls the pxafb_init_fbinfo function, after which &fbi->task is associated with pxafb_task. Moreover, within this pxafb_init_fbinfo function, the pxafb_blank function within the &pxafb_ops struct is capable of scheduling work.
If we remove the module which will call pxafb_remove to make cleanup, it will call unregister_framebuffer function which can call do_unregister_framebuffer to free fbi->fb through put_fb_info(fb_info), while the work mentioned above will be used. The sequence of operations that may lead to a UAF bug is as follows:
CPU0 CPU1
| pxafb_task
pxafb_remove |
unregister_framebuffer(info) |
do_unregister_framebuffer(fb_info) |
put_fb_info(fb_info) |
// free fbi->fb | set_ctrlr_state(fbi, state)
| __pxafb_lcd_power(fbi, 0)
| fbi->lcd_power(on, &fbi->fb.var)
| //use fbi->fbFix it by ensuring that the work is canceled before proceeding with the cleanup in pxafb_remove.
Note that only root user can remove the driver at runtime.
--- drivers/video/fbdev/pxafb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/pxafb.c +1 -0
@@ -2403,6 +2403,7 @@ static void pxafb_remove(struct platform_device *dev) info = &fbi->fb;pxafb_overlay_exit (fbi); +cancel_work_sync (&fbi->task);unregister_framebuffer (info);pxafb_disable_controller (fbi);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 116/244 pmdomain: core: Don't hold the genpd-lock when calling dev_pm_domain_set()
In reply to Sasha LevinFrom: Ulf Hansson <[email protected]>
[ Upstream commit b87eee38605c396f0e1fa435939960e5c6cd41d6 ]
There is no need to hold the genpd-lock, while assigning the dev->pm_domain. In fact, it becomes a problem on a PREEMPT_RT based configuration as the genpd-lock may be a raw spinlock, while the lock acquired through the call to dev_pm_domain_set() is a regular spinlock.
To fix the problem, let's simply move the calls to dev_pm_domain_set() outside the genpd-lock.
--- drivers/pmdomain/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pmdomain/core.c +3 -2
@@ -1758,7 +1758,6 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,genpd_lock (genpd);genpd_set_cpumask (genpd, gpd_data->cpu); -dev_pm_domain_set (dev, &genpd->domain); genpd->device_count++;if (gd)
@@ -1767,6 +1766,7 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,list_add_tail (&gpd_data->base.list_node, &genpd->dev_list);genpd_unlock (genpd); +dev_pm_domain_set (dev, &genpd->domain); out:if (ret)genpd_free_dev_data (dev, gpd_data);
@@ -1823,12 +1823,13 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, genpd->gd->max_off_time_changed = true;genpd_clear_cpumask (genpd, gpd_data->cpu); -dev_pm_domain_set (dev,NULL );list_del_init (&pdd->list_node);genpd_unlock (genpd); +dev_pm_domain_set (dev,NULL ); +if (genpd->detach_dev) genpd->detach_dev (genpd, dev);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 117/244 pmdomain: core: Use dev_name() instead of kobject_get_path() in debugfs
In reply to Sasha LevinFrom: Ulf Hansson <[email protected]>
[ Upstream commit 9094e53ff5c86ebe372ad3960c3216c9817a1a04 ]
Using kobject_get_path() means a dynamic memory allocation gets done, which doesn't work on a PREEMPT_RT based configuration while holding genpd's raw spinlock.
To fix the problem, let's convert into using the simpler dev_name(). This means the information about the path doesn't get presented in debugfs, but hopefully this shouldn't be an issue.
--- drivers/pmdomain/core.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-)
drivers/pmdomain/core.c +3 -20
@@ -3210,7 +3210,6 @@ static int genpd_summary_one(struct seq_file *s, [GENPD_STATE_OFF] = "off" };struct pm_domain_data *pm_data; -const char *kobj_path;struct gpd_link *link;char state[16 ];int ret;
@@ -3243,17 +3242,10 @@ static int genpd_summary_one(struct seq_file *s, }list_for_each_entry (pm_data, &genpd->dev_list, list_node) { - kobj_path =kobject_get_path (&pm_data->dev->kobj, -genpd_is_irq_safe (genpd) ? -GFP_ATOMIC :GFP_KERNEL ); -if (kobj_path ==NULL ) -continue ; - -seq_printf (s,"\n %-50s " , kobj_path); +seq_printf (s,"\n %-50s " ,dev_name (pm_data->dev));rtpm_status_str (s, pm_data->dev);perf_status_str (s, pm_data->dev);mode_status_str (s, pm_data->dev); -kfree (kobj_path); }seq_puts (s,"\n" );
@@ -3422,23 +3414,14 @@ static int devices_show(struct seq_file *s, void *data) {struct generic_pm_domain *genpd = s->private;struct pm_domain_data *pm_data; -const char *kobj_path;int ret =0 ; ret =genpd_lock_interruptible (genpd);if (ret)return -ERESTARTSYS ; -list_for_each_entry (pm_data, &genpd->dev_list, list_node) { - kobj_path =kobject_get_path (&pm_data->dev->kobj, -genpd_is_irq_safe (genpd) ? -GFP_ATOMIC :GFP_KERNEL ); -if (kobj_path ==NULL ) -continue ; - -seq_printf (s,"%s\n" , kobj_path); -kfree (kobj_path); - } +list_for_each_entry (pm_data, &genpd->dev_list, list_node) +seq_printf (s,"%s\n" ,dev_name (pm_data->dev));genpd_unlock (genpd);return ret;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 118/244 coredump: Standartize and fix logging
In reply to Sasha LevinFrom: Roman Kisel <[email protected]>
[ Upstream commit c114e9948c2b6a0b400266e59cc656b59e795bca ]
The coredump code does not log the process ID and the comm consistently, logs unescaped comm when it does log it, and does not always use the ratelimited logging. That makes it harder to analyze logs and puts the system at the risk of spamming the system log incase something crashes many times over and over again.
Fix that by logging TGID and comm (escaped) consistently and using the ratelimited logging always.
--- fs/coredump.c | 43 +++++++++++++++------------------------- include/linux/coredump.h | 22 ++++++++++++++++++++ 2 files changed, 38 insertions(+), 27 deletions(-)
fs/coredump.c +16 -27
@@ -586,8 +586,7 @@ void do_coredump(const kernel_siginfo_t *siginfo)struct subprocess_info *sub_info;if (ispipe <0 ) { -printk (KERN_WARNING "format_corename failed\n" ); -printk (KERN_WARNING "Aborting core\n" ); +coredump_report_failure ("format_corename failed, aborting core" ); goto fail_unlock; }
@@ -607,27 +606,21 @@ void do_coredump(const kernel_siginfo_t *siginfo)* right pid if a thread in a multi-threaded * core_pattern process dies. */ -printk (KERN_WARNING -"Process %d(%s) has RLIMIT_CORE set to 1\n" , -task_tgid_vnr (current), current->comm); -printk (KERN_WARNING "Aborting core\n" ); +coredump_report_failure ("RLIMIT_CORE is set to 1, aborting core" ); goto fail_unlock; } cprm.limit =RLIM_INFINITY ; dump_count =atomic_inc_return (&core_dump_count);if (core_pipe_limit && (core_pipe_limit < dump_count)) { -printk (KERN_WARNING "Pid %d(%s) over core_pipe_limit\n" , -task_tgid_vnr (current), current->comm); -printk (KERN_WARNING "Skipping core dump\n" ); +coredump_report_failure ("over core_pipe_limit, skipping core dump" ); goto fail_dropcount; } helper_argv =kmalloc_array (argc +1 ,sizeof (*helper_argv),GFP_KERNEL );if (!helper_argv) { -printk (KERN_WARNING "%s failed to allocate memory\n" , - __func__); +coredump_report_failure ("%s failed to allocate memory" , __func__); goto fail_dropcount; }for (argi =0 ; argi < argc; argi++)
@@ -644,8 +637,7 @@ void do_coredump(const kernel_siginfo_t *siginfo)kfree (helper_argv);if (retval) { -printk (KERN_INFO "Core dump to |%s pipe failed\n" , - cn.corename); +coredump_report_failure ("|%s pipe failed" , cn.corename); goto close_fail; } }else {
@@ -658,10 +650,8 @@ void do_coredump(const kernel_siginfo_t *siginfo) goto fail_unlock;if (need_suid_safe && cn.corename[0 ] !='/' ) { -printk (KERN_WARNING "Pid %d(%s) can only dump core " \ -"to fully qualified path!\n" , -task_tgid_vnr (current), current->comm); -printk (KERN_WARNING "Skipping core dump\n" ); +coredump_report_failure ( +"this process can only dump core to a fully qualified path, skipping core dump" ); goto fail_unlock; }
@@ -730,13 +720,13 @@ void do_coredump(const kernel_siginfo_t *siginfo) idmap =file_mnt_idmap (cprm.file);if (!vfsuid_eq_kuid (i_uid_into_vfsuid (idmap, inode),current_fsuid ())) { -pr_info_ratelimited ("Core dump to %s aborted: cannot preserve file owner\n" , - cn.corename); +coredump_report_failure ("Core dump to %s aborted: " +"cannot preserve file owner" , cn.corename); goto close_fail; }if ((inode->i_mode &0677 ) !=0600 ) { -pr_info_ratelimited ("Core dump to %s aborted: cannot preserve file permissions\n" , - cn.corename); +coredump_report_failure ("Core dump to %s aborted: " +"cannot preserve file permissions" , cn.corename); goto close_fail; }if (!(cprm.file->f_mode &FMODE_CAN_WRITE ))
@@ -757,7 +747,7 @@ void do_coredump(const kernel_siginfo_t *siginfo)* have this set to NULL. */ if (!cprm.file) { -pr_info ("Core dump to |%s disabled\n" , cn.corename); +coredump_report_failure ("Core dump to |%s disabled" , cn.corename); goto close_fail; }if (!dump_vma_snapshot (&cprm))
@@ -983,11 +973,10 @@ void validate_coredump_safety(void) {if (suid_dumpable ==SUID_DUMP_ROOT && core_pattern[0 ] !='/' && core_pattern[0 ] !='|' ) { -pr_warn ( -"Unsafe core_pattern used with fs.suid_dumpable=2.\n" -"Pipe handler or fully qualified core dump path required.\n" -"Set kernel.core_pattern before fs.suid_dumpable.\n" - ); + +coredump_report_failure ("Unsafe core_pattern used with fs.suid_dumpable=2: " +"pipe handler or fully qualified core dump path required. " +"Set kernel.core_pattern before fs.suid_dumpable." ); } }
include/linux/coredump.h +22 -0
@@ -43,8 +43,30 @@ extern int dump_align(struct coredump_params *cprm, int align);int dump_user_range (struct coredump_params *cprm,unsigned long start,unsigned long len);extern void do_coredump (const kernel_siginfo_t *siginfo); + +/* +* Logging for the coredump code, ratelimited. +* The TGID and comm fields are added to the message. +*/ + +#define __COREDUMP_PRINTK (Level, Format, ...) \ + do { \ + char comm[TASK_COMM_LEN]; \ + \ + get_task_comm(comm, current); \ + printk_ratelimited(Level "coredump: %d(%*pE): " Format "\n", \ + task_tgid_vnr(current), (int)strlen(comm), comm, ##__VA_ARGS__); \ + } while (0) \ + +#define coredump_report (fmt, ...) __COREDUMP_PRINTK(KERN_INFO, fmt, ##__VA_ARGS__) +#define coredump_report_failure (fmt, ...) __COREDUMP_PRINTK(KERN_WARNING, fmt, ##__VA_ARGS__) +#else static inline void do_coredump (const kernel_siginfo_t *siginfo) {} + +#define coredump_report (...) +#define coredump_report_failure (...) +#endif #if defined(CONFIG_COREDUMP ) && defined(CONFIG_SYSCTL )
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 119/244 rcuscale: Provide clear error when async specified without primitives
In reply to Sasha LevinFrom: "Paul E. McKenney" <[email protected]>
[ Upstream commit 11377947b5861fa59bf77c827e1dd7c081842cc9 ]
Currently, if the rcuscale module's async module parameter is specified for RCU implementations that do not have async primitives such as RCU Tasks Rude (which now lacks a call_rcu_tasks_rude() function), there will be a series of splats due to calls to a NULL pointer. This commit therefore warns of this situation, but switches to non-async testing.
--- kernel/rcu/rcuscale.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/rcuscale.c +2 -2
@@ -499,7 +499,7 @@ rcu_scale_writer(void *arg)schedule_timeout_idle (torture_random (&tr) % writer_holdoff_jiffies +1 ); wdp = &wdpp[i]; *wdp =ktime_get_mono_fast_ns (); -if (gp_async) { +if (gp_async && !WARN_ON_ONCE (!cur_ops->async)) { retry:if (!rhp) rhp =kmalloc (sizeof (*rhp),GFP_KERNEL );
@@ -555,7 +555,7 @@ rcu_scale_writer(void *arg) i++;rcu_scale_wait_shutdown (); }while (!torture_must_stop ()); -if (gp_async) { +if (gp_async && cur_ops->async) { cur_ops->gp_barrier (); } writer_n_durations[me] = i_max +1 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 120/244 iommu/arm-smmu-qcom: hide last LPASS SMMU context bank from linux
In reply to Sasha LevinFrom: Marc Gonzalez <[email protected]>
[ Upstream commit 3a8990b8a778219327c5f8ecf10b5d81377b925a ]
On qcom msm8998, writing to the last context bank of lpass_q6_smmu (base address 0x05100000) produces a system freeze & reboot.
The hardware/hypervisor reports 13 context banks for the LPASS SMMU on msm8998, but only the first 12 are accessible... Override the number of context banks
[ 2.546101] arm-smmu 5100000.iommu: probing hardware configuration... [ 2.552439] arm-smmu 5100000.iommu: SMMUv2 with: [ 2.558945] arm-smmu 5100000.iommu: stage 1 translation [ 2.563627] arm-smmu 5100000.iommu: address translation ops [ 2.568923] arm-smmu 5100000.iommu: non-coherent table walk [ 2.574566] arm-smmu 5100000.iommu: (IDR0.CTTW overridden by FW configuration) [ 2.580220] arm-smmu 5100000.iommu: stream matching with 12 register groups [ 2.587263] arm-smmu 5100000.iommu: 13 context banks (0 stage-2 only) [ 2.614447] arm-smmu 5100000.iommu: Supported page sizes: 0x63315000 [ 2.621358] arm-smmu 5100000.iommu: Stage-1: 36-bit VA -> 36-bit IPA [ 2.627772] arm-smmu 5100000.iommu: preserved 0 boot mappings
Specifically, the crashes occur here:
qsmmu->bypass_cbndx = smmu->num_context_banks - 1; arm_smmu_cb_write(smmu, qsmmu->bypass_cbndx, ARM_SMMU_CB_SCTLR, 0);
and here:
arm_smmu_write_context_bank(smmu, i); arm_smmu_cb_write(smmu, i, ARM_SMMU_CB_FSR, ARM_SMMU_CB_FSR_FAULT);
It is likely that FW reserves the last context bank for its own use, thus a simple work-around is: DON'T USE IT in Linux.
If we decrease the number of context banks, last one will be "hidden".
--- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +7 -0
@@ -282,6 +282,13 @@ static int qcom_smmu_cfg_probe(struct arm_smmu_device *smmu)u32 smr;int i; +/* +* MSM8998 LPASS SMMU reports 13 context banks, but accessing +* the last context bank crashes the system. +*/ +if (of_device_is_compatible (smmu->dev->of_node,"qcom,msm8998-smmu-v2" ) && smmu->num_context_banks ==13 ) + smmu->num_context_banks =12 ; +/* * Some platforms support more than the Arm SMMU architected maximum of * 128 stream matching groups. For unknown reasons, the additional
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 121/244 iommu/arm-smmu-qcom: Work around SDM845 Adreno SMMU w/ 16K pages
In reply to Sasha LevinFrom: Konrad Dybcio <[email protected]>
[ Upstream commit 2d42d3ba443706c9164fa0bef4e5fd1c36bc1bd9 ]
SDM845's Adreno SMMU is unique in that it actually advertizes support for 16K (and 32M) pages, which doesn't hold for newer SoCs.
This however, seems either broken in the hardware implementation, the hypervisor middleware that abstracts the SMMU, or there's a bug in the Linux kernel somewhere down the line that nobody managed to track down.
Booting SDM845 with 16K page sizes and drm/msm results in:
*** gpu fault: ttbr0=0000000000000000 iova=000100000000c000 dir=READ type=TRANSLATION source=CP (0,0,0,0)
right after loading the firmware. The GPU then starts spitting out illegal intstruction errors, as it's quite obvious that it got a bogus pointer.
Moreover, it seems like this issue also concerns other implementations of SMMUv2 on Qualcomm SoCs, such as the one on SC7180.
Hide 16K support on such instances to work around this.
--- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +9 -0
@@ -345,6 +345,14 @@ static int qcom_smmu_cfg_probe(struct arm_smmu_device *smmu)return 0 ; } +static int qcom_adreno_smmuv2_cfg_probe (struct arm_smmu_device *smmu) +{ +/* Support for 16K pages is advertised on some SoCs, but it doesn't seem to work */ + smmu->features &= ~ARM_SMMU_FEAT_FMT_AARCH64_16K ; + +return 0 ; +} +static void qcom_smmu_write_s2cr (struct arm_smmu_device *smmu,int idx) {struct arm_smmu_s2cr *s2cr = smmu->s2crs + idx;
@@ -443,6 +451,7 @@ static const struct arm_smmu_impl sdm845_smmu_500_impl = {static const struct arm_smmu_impl qcom_adreno_smmu_v2_impl = { .init_context = qcom_adreno_smmu_init_context, + .cfg_probe = qcom_adreno_smmuv2_cfg_probe, .def_domain_type = qcom_smmu_def_domain_type, .alloc_context_bank = qcom_adreno_smmu_alloc_context_bank, .write_sctlr = qcom_adreno_smmu_write_sctlr,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 122/244 power: reset: brcmstb: Do not go into infinite loop if reset fails
In reply to Sasha LevinFrom: Andrew Davis <[email protected]>
[ Upstream commit cf8c39b00e982fa506b16f9d76657838c09150cb ]
There may be other backup reset methods available, do not halt here so that other reset methods can be tried.
--- drivers/power/reset/brcmstb-reboot.c | 3 --- 1 file changed, 3 deletions(-)
drivers/power/reset/brcmstb-reboot.c +0 -3
@@ -62,9 +62,6 @@ static int brcmstb_restart_handler(struct notifier_block *this,return NOTIFY_DONE ; } -while (1 ) - ; -return NOTIFY_DONE ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 123/244 iommu/arm-smmu-v3: Match Stall behaviour for S2
In reply to Sasha LevinFrom: Mostafa Saleh <[email protected]>
[ Upstream commit ce7cb08e22e09f43649b025c849a3ae3b80833c4 ]
According to the spec (ARM IHI 0070 F.b), in
"5.5 Fault configuration (A, R, S bits)":
A STE with stage 2 translation enabled and STE.S2S == 0 is
considered ILLEGAL if SMMU_IDR0.STALL_MODEL == 0b10.Also described in the pseudocode “SteIllegal()”
if STE.Config == '11x' then
[..]
if eff_idr0_stall_model == '10' && STE.S2S == '0' then
// stall_model forcing stall, but S2S == 0
return TRUE;Which means, S2S must be set when stall model is "ARM_SMMU_FEAT_STALL_FORCE", but currently the driver ignores that.
Although, the driver can do the minimum and only set S2S for “ARM_SMMU_FEAT_STALL_FORCE”, it is more consistent to match S1 behaviour, which also sets it for “ARM_SMMU_FEAT_STALL” if the master has requested stalls.
Also, since S2 stalls are enabled now, report them to the IOMMU layer and for VFIO devices it will fail anyway as VFIO doesn’t register an iopf handler.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 8 +++----- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 1 + 2 files changed, 4 insertions(+), 5 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +3 -5
@@ -1012,7 +1012,8 @@ void arm_smmu_get_ste_used(const __le64 *ent, __le64 *used_bits) used_bits[2 ] |=cpu_to_le64 (STRTAB_STE_2_S2VMID |STRTAB_STE_2_VTCR |STRTAB_STE_2_S2AA64 |STRTAB_STE_2_S2ENDI | -STRTAB_STE_2_S2PTW |STRTAB_STE_2_S2R ); +STRTAB_STE_2_S2PTW |STRTAB_STE_2_S2S | +STRTAB_STE_2_S2R ); used_bits[3 ] |=cpu_to_le64 (STRTAB_STE_3_S2TTB_MASK ); }
@@ -1646,6 +1647,7 @@ void arm_smmu_make_s2_domain_ste(struct arm_smmu_ste *target,STRTAB_STE_2_S2ENDI | #endifSTRTAB_STE_2_S2PTW | + (master->stall_enabled ?STRTAB_STE_2_S2S :0 ) | STRTAB_STE_2_S2R); target->data[3] = cpu_to_le64(pgtbl_cfg->arm_lpae_s2_cfg.vttbr &
@@ -1739,10 +1741,6 @@ static int arm_smmu_handle_evt(struct arm_smmu_device *smmu, u64 *evt)return -EOPNOTSUPP ; } -/* Stage-2 is always pinned at the moment */ -if (evt[1 ] &EVTQ_1_S2 ) -return -EFAULT ; -if (!(evt[1 ] &EVTQ_1_STALL ))return -EOPNOTSUPP ;
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +1 -0
@@ -267,6 +267,7 @@ struct arm_smmu_ste {#define STRTAB_STE_2_S2AA64 (1UL << 51)#define STRTAB_STE_2_S2ENDI (1UL << 52)#define STRTAB_STE_2_S2PTW (1UL << 54) +#define STRTAB_STE_2_S2S (1UL << 57)#define STRTAB_STE_2_S2R (1UL << 58)#define STRTAB_STE_3_S2TTB_MASK GENMASK_ULL(51, 4)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 124/244 iommu/vt-d: Always reserve a domain ID for identity setup
In reply to Sasha LevinFrom: Lu Baolu <[email protected]>
[ Upstream commit 2c13012e09190174614fd6901857a1b8c199e17d ]
We will use a global static identity domain. Reserve a static domain ID for it.
--- drivers/iommu/intel/iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iommu/intel/iommu.c +3 -3
@@ -1447,10 +1447,10 @@ static int iommu_init_domains(struct intel_iommu *iommu)* entry for first-level or pass-through translation modes should * be programmed with a domain id different from those used for * second-level or nested translation. We reserve a domain id for -* this purpose. +* this purpose. This domain id is also used for identity domain +* in legacy mode. */ -if (sm_supported (iommu)) -set_bit (FLPT_DEFAULT_DID , iommu->domain_ids); +set_bit (FLPT_DEFAULT_DID , iommu->domain_ids);return 0 ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 125/244 iommu/vt-d: Fix potential lockup if qi_submit_sync called with 0 count
In reply to Sasha LevinFrom: Sanjay K Kumar <[email protected]>
[ Upstream commit 3cf74230c139f208b7fb313ae0054386eee31a81 ]
If qi_submit_sync() is invoked with 0 invalidation descriptors (for instance, for DMA draining purposes), we can run into a bug where a submitting thread fails to detect the completion of invalidation_wait. Subsequently, this led to a soft lockup. Currently, there is no impact by this bug on the existing users because no callers are submitting invalidations with 0 descriptors. This fix will enable future users (such as DMA drain) calling qi_submit_sync() with 0 count.
Suppose thread T1 invokes qi_submit_sync() with non-zero descriptors, while concurrently, thread T2 calls qi_submit_sync() with zero descriptors. Both threads then enter a while loop, waiting for their respective descriptors to complete. T1 detects its completion (i.e., T1's invalidation_wait status changes to QI_DONE by HW) and proceeds to call reclaim_free_desc() to reclaim all descriptors, potentially including adjacent ones of other threads that are also marked as QI_DONE.
During this time, while T2 is waiting to acquire the qi->q_lock, the IOMMU hardware may complete the invalidation for T2, setting its status to QI_DONE. However, if T1's execution of reclaim_free_desc() frees T2's invalidation_wait descriptor and changes its status to QI_FREE, T2 will not observe the QI_DONE status for its invalidation_wait and will indefinitely remain stuck.
This soft lockup does not occur when only non-zero descriptors are submitted.In such cases, invalidation descriptors are interspersed among wait descriptors with the status QI_IN_USE, acting as barriers. These barriers prevent the reclaim code from mistakenly freeing descriptors belonging to other submitters.
Considered the following example timeline:
T1 T2 ======================================== ID1 WD1 while(WD1!=QI_DONE) unlock lock WD1=QI_DONE* WD2 while(WD2!=QI_DONE) unlock lock WD1==QI_DONE? ID1=QI_DONE WD2=DONE* reclaim() ID1=FREE WD1=FREE WD2=FREE unlock soft lockup! T2 never sees QI_DONE in WD2
Where:
ID = invalidation descriptor
WD = wait descriptor
* Written by hardware
The root of the problem is that the descriptor status QI_DONE flag is used for two conflicting purposes:
1. signal a descriptor is ready for reclaim (to be freed)
2. signal by the hardware that a wait descriptor is complete
The solution (in this patch) is state separation by using QI_FREE flag for #1.
Once a thread's invalidation descriptors are complete, their status would be set to QI_FREE. The reclaim_free_desc() function would then only free descriptors marked as QI_FREE instead of those marked as QI_DONE. This change ensures that T2 (from the previous example) will correctly observe the completion of its invalidation_wait (marked as QI_DONE).
--- drivers/iommu/intel/dmar.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/iommu/intel/dmar.c +11 -5
@@ -1204,9 +1204,7 @@ static void free_iommu(struct intel_iommu *iommu)*/ static inline void reclaim_free_desc (struct q_inval *qi) { -while (qi->desc_status[qi->free_tail] ==QI_DONE || - qi->desc_status[qi->free_tail] ==QI_ABORT ) { - qi->desc_status[qi->free_tail] =QI_FREE ; +while (qi->desc_status[qi->free_tail] ==QI_FREE && qi->free_tail != qi->free_head) { qi->free_tail = (qi->free_tail +1 ) %QI_LENGTH ; qi->free_cnt++; }
@@ -1463,8 +1461,16 @@ int qi_submit_sync(struct intel_iommu *iommu, struct qi_desc *desc,raw_spin_lock (&qi->q_lock); } -for (i =0 ; i < count; i++) - qi->desc_status[(index + i) %QI_LENGTH ] =QI_DONE ; +/* +* The reclaim code can free descriptors from multiple submissions +* starting from the tail of the queue. When count == 0, the +* status of the standalone wait descriptor at the tail of the queue +* must be set to QI_FREE to allow the reclaim code to proceed. +* It is also possible that descriptors from one of the previous +* submissions has to be reclaimed by a subsequent submission. +*/ +for (i =0 ; i <= count; i++) + qi->desc_status[(index + i) %QI_LENGTH ] =QI_FREE ;reclaim_free_desc (qi);raw_spin_unlock_irqrestore (&qi->q_lock, flags);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 126/244 iommu/vt-d: Unconditionally flush device TLB for pasid table updates
In reply to Sasha LevinFrom: Lu Baolu <[email protected]>
[ Upstream commit 1f5e307ca16c0c19186cbd56ac460a687e6daba0 ]
The caching mode of an IOMMU is irrelevant to the behavior of the device TLB. Previously, commit <304b3bde24b5> ("iommu/vt-d: Remove caching mode check before device TLB flush") removed this redundant check in the domain unmap path.
Checking the caching mode before flushing the device TLB after a pasid table entry is updated is unnecessary and can lead to inconsistent behavior.
Extends this consistency by removing the caching mode check in the pasid table update path.
--- drivers/iommu/intel/pasid.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/iommu/intel/pasid.c +3 -9
@@ -264,9 +264,7 @@ void intel_pasid_tear_down_entry(struct intel_iommu *iommu, struct device *dev,else iommu->flush.flush_iotlb (iommu, did,0 ,0 ,DMA_TLB_DSI_FLUSH ); -/* Device IOTLB doesn't need to be flushed in caching mode. */ -if (!cap_caching_mode (iommu->cap)) -devtlb_invalidation_with_pasid (iommu, dev, pasid); +devtlb_invalidation_with_pasid (iommu, dev, pasid); }/*
@@ -493,9 +491,7 @@ int intel_pasid_setup_dirty_tracking(struct intel_iommu *iommu, iommu->flush.flush_iotlb (iommu, did,0 ,0 ,DMA_TLB_DSI_FLUSH ); -/* Device IOTLB doesn't need to be flushed in caching mode. */ -if (!cap_caching_mode (iommu->cap)) -devtlb_invalidation_with_pasid (iommu, dev, pasid); +devtlb_invalidation_with_pasid (iommu, dev, pasid);return 0 ; }
@@ -572,9 +568,7 @@ void intel_pasid_setup_page_snoop_control(struct intel_iommu *iommu,pasid_cache_invalidation_with_pasid (iommu, did, pasid);qi_flush_piotlb (iommu, did, pasid,0 ,-1 ,0 ); -/* Device IOTLB doesn't need to be flushed in caching mode. */ -if (!cap_caching_mode (iommu->cap)) -devtlb_invalidation_with_pasid (iommu, dev, pasid); +devtlb_invalidation_with_pasid (iommu, dev, pasid); }/**
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 127/244 iommu/arm-smmu-v3: Do not use devm for the cd table allocations
In reply to Sasha LevinFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 47b2de35cab2b683f69d03515c2658c2d8515323 ]
The master->cd_table is entirely contained within the struct arm_smmu_master which is guaranteed to be freed by the core code under arm_smmu_release_device().
There is no reason to use devm here, arm_smmu_free_cd_tables() is reliably called to free the CD related memory. Remove it and save some memory.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 29 +++++++++------------ 1 file changed, 13 insertions(+), 16 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +13 -16
@@ -1185,8 +1185,8 @@ static int arm_smmu_alloc_cd_leaf_table(struct arm_smmu_device *smmu, {size_t size =CTXDESC_L2_ENTRIES * (CTXDESC_CD_DWORDS <<3 ); - l1_desc->l2ptr =dmam_alloc_coherent (smmu->dev, size, - &l1_desc->l2ptr_dma,GFP_KERNEL ); + l1_desc->l2ptr =dma_alloc_coherent (smmu->dev, size, + &l1_desc->l2ptr_dma,GFP_KERNEL );if (!l1_desc->l2ptr) {dev_warn (smmu->dev,"failed to allocate context descriptor table\n" );
@@ -1400,17 +1400,17 @@ static int arm_smmu_alloc_cd_tables(struct arm_smmu_master *master) cd_table->num_l1_ents =DIV_ROUND_UP (max_contexts,CTXDESC_L2_ENTRIES ); - cd_table->l1_desc =devm_kcalloc (smmu->dev, cd_table->num_l1_ents, -sizeof (*cd_table->l1_desc), -GFP_KERNEL ); + cd_table->l1_desc =kcalloc (cd_table->num_l1_ents, +sizeof (*cd_table->l1_desc), +GFP_KERNEL );if (!cd_table->l1_desc)return -ENOMEM ; l1size = cd_table->num_l1_ents * (CTXDESC_L1_DESC_DWORDS <<3 ); } - cd_table->cdtab =dmam_alloc_coherent (smmu->dev, l1size, &cd_table->cdtab_dma, -GFP_KERNEL ); + cd_table->cdtab =dma_alloc_coherent (smmu->dev, l1size, + &cd_table->cdtab_dma,GFP_KERNEL );if (!cd_table->cdtab) {dev_warn (smmu->dev,"failed to allocate context descriptor\n" ); ret = -ENOMEM ;
@@ -1421,7 +1421,7 @@ static int arm_smmu_alloc_cd_tables(struct arm_smmu_master *master) err_free_l1:if (cd_table->l1_desc) { -devm_kfree (smmu->dev, cd_table->l1_desc); +kfree (cd_table->l1_desc); cd_table->l1_desc =NULL ; }return ret;
@@ -1441,21 +1441,18 @@ static void arm_smmu_free_cd_tables(struct arm_smmu_master *master)if (!cd_table->l1_desc[i].l2ptr)continue ; -dmam_free_coherent (smmu->dev, size, - cd_table->l1_desc[i].l2ptr, - cd_table->l1_desc[i].l2ptr_dma); +dma_free_coherent (smmu->dev, size, + cd_table->l1_desc[i].l2ptr, + cd_table->l1_desc[i].l2ptr_dma); } -devm_kfree (smmu->dev, cd_table->l1_desc); - cd_table->l1_desc =NULL ; +kfree (cd_table->l1_desc); l1size = cd_table->num_l1_ents * (CTXDESC_L1_DESC_DWORDS <<3 ); }else { l1size = cd_table->num_l1_ents * (CTXDESC_CD_DWORDS <<3 ); } -dmam_free_coherent (smmu->dev, l1size, cd_table->cdtab, cd_table->cdtab_dma); - cd_table->cdtab_dma =0 ; - cd_table->cdtab =NULL ; +dma_free_coherent (smmu->dev, l1size, cd_table->cdtab, cd_table->cdtab_dma); }/* Stream table manipulation functions */
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 128/244 cgroup: Disallow mounting v1 hierarchies without controller implementation
In reply to Sasha LevinFrom: Michal Koutný <[email protected]>
[ Upstream commit 3c41382e920f1dd5c9f432948fe799c07af1cced ]
The configs that disable some v1 controllers would still allow mounting them but with no controller-specific files. (Making such hierarchies equivalent to named v1 hierarchies.) To achieve behavior consistent with actual out-compilation of a whole controller, the mounts should treat respective controllers as non-existent.
Wrap implementation into a helper function, leverage legacy_files to detect compiled out controllers. The effect is that mounts on v1 would fail and produce a message like:
[ 1543.999081] cgroup: Unknown subsys name 'memory'
--- kernel/cgroup/cgroup-v1.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
kernel/cgroup/cgroup-v1.c +10 -2
@@ -46,6 +46,12 @@ bool cgroup1_ssid_disabled(int ssid)return cgroup_no_v1_mask & (1 << ssid); } +static bool cgroup1_subsys_absent (struct cgroup_subsys *ss) +{ +/* Check also dfl_cftypes for file-less controllers, i.e. perf_event */ +return ss->legacy_cftypes ==NULL && ss->dfl_cftypes; +} +/** * cgroup_attach_task_all - attach task 'tsk' to all cgroups of task 'from' * @from: attach to all cgroups of a given task
@@ -932,7 +938,8 @@ int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param)if (ret != -ENOPARAM )return ret;for_each_subsys (ss, i) { -if (strcmp (param->key, ss->legacy_name)) +if (strcmp (param->key, ss->legacy_name) || +cgroup1_subsys_absent (ss))continue ;if (!cgroup_ssid_enabled (i) ||cgroup1_ssid_disabled (i)) return invalfc(fc, "Disabled controller '%s'",
@@ -1024,7 +1031,8 @@ static int check_cgroupfs_options(struct fs_context *fc) mask = ~((u16 )1 << cpuset_cgrp_id);#endif for_each_subsys (ss, i) -if (cgroup_ssid_enabled (i) && !cgroup1_ssid_disabled (i)) +if (cgroup_ssid_enabled (i) && !cgroup1_ssid_disabled (i) && + !cgroup1_subsys_absent (ss)) enabled |=1 << i; ctx->subsys_mask &= enabled;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 129/244 drm/stm: Avoid use-after-free issues with crtc and plane
In reply to Sasha LevinFrom: Katya Orlova <[email protected]>
[ Upstream commit 19dd9780b7ac673be95bf6fd6892a184c9db611f ]
ltdc_load() calls functions drm_crtc_init_with_planes(), drm_universal_plane_init() and drm_encoder_init(). These functions should not be called with parameters allocated with devm_kzalloc() to avoid use-after-free issues [1].
Use allocations managed by the DRM framework.
Found by Linux Verification Center (linuxtesting.org).
[1]
https://lore.kernel.org/lkml/u366i76e3qhh3ra5oxrtngjtm2u5lterkekcz6y2jkndhuxzli@diujon4h7qwb/
--- drivers/gpu/drm/stm/drv.c | 3 +- drivers/gpu/drm/stm/ltdc.c | 73 ++++++++++---------------------------- 2 files changed, 20 insertions(+), 56 deletions(-)
drivers/gpu/drm/stm/drv.c +2 -1
@@ -25,6 +25,7 @@#include <drm/drm_module.h> #include <drm/drm_probe_helper.h> #include <drm/drm_vblank.h> +#include <drm/drm_managed.h> #include "ltdc.h"
@@ -75,7 +76,7 @@ static int drv_load(struct drm_device *ddev)DRM_DEBUG ("%s\n" , __func__); - ldev =devm_kzalloc (ddev->dev,sizeof (*ldev),GFP_KERNEL ); + ldev =drmm_kzalloc (ddev,sizeof (*ldev),GFP_KERNEL );if (!ldev)return -ENOMEM ;
drivers/gpu/drm/stm/ltdc.c +18 -55
177 lines not on this page · raw message
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 130/244 drm/amd/display: Pass non-null to dcn20_validate_apply_pipe_split_flags
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 5559598742fb4538e4c51c48ef70563c49c2af23 ]
[WHAT & HOW]
"dcn20_validate_apply_pipe_split_flags" dereferences merge, and thus it cannot be a null pointer. Let's pass a valid pointer to avoid null dereference.
This fixes 2 FORWARD_NULL issues reported by Coverity.
--- drivers/gpu/drm/amd/display/dc/resource/dcn20/dcn20_resource.c | 3 ++- drivers/gpu/drm/amd/display/dc/resource/dcn21/dcn21_resource.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/resource/dcn20/dcn20_resource.c +2 -1
@@ -2040,6 +2040,7 @@ bool dcn20_fast_validate_bw( {bool out = false;int split[MAX_PIPES ] = {0 }; +bool merge[MAX_PIPES ] = { false };int pipe_cnt, i, pipe_idx, vlevel;ASSERT (pipes);
@@ -2064,7 +2065,7 @@ bool dcn20_fast_validate_bw(if (vlevel > context->bw_ctx.dml.soc.num_states) goto validate_fail; - vlevel =dcn20_validate_apply_pipe_split_flags (dc, context, vlevel, split,NULL ); + vlevel =dcn20_validate_apply_pipe_split_flags (dc, context, vlevel, split, merge);/*initialize pipe_just_split_from to invalid idx*/ for (i =0 ; i <MAX_PIPES ; i++)
drivers/gpu/drm/amd/display/dc/resource/dcn21/dcn21_resource.c +2 -1
@@ -774,6 +774,7 @@ bool dcn21_fast_validate_bw(struct dc *dc, {bool out = false;int split[MAX_PIPES ] = {0 }; +bool merge[MAX_PIPES ] = { false };int pipe_cnt, i, pipe_idx, vlevel;ASSERT (pipes);
@@ -816,7 +817,7 @@ bool dcn21_fast_validate_bw(struct dc *dc, goto validate_fail; } - vlevel =dcn20_validate_apply_pipe_split_flags (dc, context, vlevel, split,NULL ); + vlevel =dcn20_validate_apply_pipe_split_flags (dc, context, vlevel, split, merge);for (i =0 , pipe_idx =0 ; i < dc->res_pool->pipe_count; i++) {struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 131/244 drm/amd/display: Check null pointers before using them
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 1ff12bcd7deaeed25efb5120433c6a45dd5504a8 ]
[WHAT & HOW]
These pointers are null checked previously in the same function, indicating they might be null as reported by Coverity. As a result, they need to be checked when used again.
This fixes 3 FORWARD_NULL issue reported by Coverity.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -4
@@ -7233,6 +7233,9 @@ create_validate_stream_for_sink(struct amdgpu_dm_connector *aconnector,int requested_bpc = drm_state ? drm_state->max_requested_bpc :8 ;enum dc_status dc_result =DC_OK ; +if (!dm_state) +return NULL ; + do { stream = create_stream_for_sink(connector, drm_mode, dm_state, old_stream,
@@ -9340,7 +9343,7 @@ static void amdgpu_dm_commit_streams(struct drm_atomic_state *state,if (acrtc) old_crtc_state =drm_atomic_get_old_crtc_state (state, &acrtc->base); -if (!acrtc->wb_enabled) +if (!acrtc || !acrtc->wb_enabled)continue ; dm_old_crtc_state =to_dm_crtc_state (old_crtc_state);
@@ -9744,9 +9747,10 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)DRM_INFO ("[HDCP_DM] hdcp_update_display enable_encryption = %x\n" , enable_encryption); -hdcp_update_display ( - adev->dm.hdcp_workqueue, aconnector->dc_link->link_index, aconnector, - new_con_state->hdcp_content_type, enable_encryption); +if (aconnector->dc_link) +hdcp_update_display ( + adev->dm.hdcp_workqueue, aconnector->dc_link->link_index, aconnector, + new_con_state->hdcp_content_type, enable_encryption); } }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 132/244 drm/amd/display: Check null pointers before used
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit be1fb44389ca3038ad2430dac4234669bc177ee3 ]
[WHAT & HOW]
Poniters, such as dc->clk_mgr, are null checked previously in the same function, so Coverity warns "implies that "dc->clk_mgr" might be null". As a result, these pointers need to be checked when used again.
This fixes 10 FORWARD_NULL issues reported by Coverity.
--- .../drm/amd/display/dc/clk_mgr/dce110/dce110_clk_mgr.c | 2 +- drivers/gpu/drm/amd/display/dc/hubp/dcn10/dcn10_hubp.c | 3 ++- drivers/gpu/drm/amd/display/dc/hubp/dcn20/dcn20_hubp.c | 3 ++- drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c | 5 +++-- drivers/gpu/drm/amd/display/dc/hwss/dcn10/dcn10_hwseq.c | 4 ++-- drivers/gpu/drm/amd/display/dc/hwss/dcn31/dcn31_hwseq.c | 4 ++-- drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c | 8 ++++---- .../amd/display/dc/link/protocols/link_dp_capability.c | 2 +- 8 files changed, 17 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dce110/dce110_clk_mgr.c +1 -1
@@ -195,7 +195,7 @@ void dce11_pplib_apply_display_requirements(* , then change minimum memory clock based on real-time bandwidth * limitation. */ - if ((dc->ctx->asic_id.chip_family == FAMILY_AI) && + if (dc->bw_vbios && (dc->ctx->asic_id.chip_family == FAMILY_AI) && ASICREV_IS_VEGA20_P(dc->ctx->asic_id.hw_internal_rev) && (context->stream_count >= 2)) { pp_display_cfg->min_memory_clock_khz = max(pp_display_cfg->min_memory_clock_khz, (uint32_t) div64_s64(
drivers/gpu/drm/amd/display/dc/hubp/dcn10/dcn10_hubp.c +2 -1
@@ -749,7 +749,8 @@ bool hubp1_is_flip_pending(struct hubp *hubp)if (flip_pending)return true; -if (earliest_inuse_address.grph.addr.quad_part != hubp->request_address.grph.addr.quad_part) +if (hubp && + earliest_inuse_address.grph.addr.quad_part != hubp->request_address.grph.addr.quad_part)return true;return false;
drivers/gpu/drm/amd/display/dc/hubp/dcn20/dcn20_hubp.c +2 -1
@@ -927,7 +927,8 @@ bool hubp2_is_flip_pending(struct hubp *hubp)if (flip_pending)return true; -if (earliest_inuse_address.grph.addr.quad_part != hubp->request_address.grph.addr.quad_part) +if (hubp && + earliest_inuse_address.grph.addr.quad_part != hubp->request_address.grph.addr.quad_part)return true;return false;
drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c +3 -2
@@ -949,7 +949,7 @@ void dce110_edp_backlight_control( {struct dc_context *ctx = link->ctx;struct bp_transmitter_control cntl = {0 }; -uint8_t pwrseq_instance; +uint8_t pwrseq_instance =0 ;unsigned int pre_T11_delay =OLED_PRE_T11_DELAY ;unsigned int post_T7_delay =OLED_POST_T7_DELAY ;
@@ -1002,7 +1002,8 @@ void dce110_edp_backlight_control(*/ /* dc_service_sleep_in_milliseconds(50); */ /*edp 1.2*/ - pwrseq_instance = link->panel_cntl->pwrseq_inst; +if (link->panel_cntl) + pwrseq_instance = link->panel_cntl->pwrseq_inst;if (cntl.action ==TRANSMITTER_CONTROL_BACKLIGHT_ON ) {if (!link->dc->config.edp_no_power_sequencing)
drivers/gpu/drm/amd/display/dc/hwss/dcn10/dcn10_hwseq.c +2 -2
@@ -1554,7 +1554,7 @@ void dcn10_init_hw(struct dc *dc) dc->clk_mgr->funcs->init_clocks (dc->clk_mgr);/* Align bw context with hw config when system resume. */ -if (dc->clk_mgr->clks.dispclk_khz !=0 && dc->clk_mgr->clks.dppclk_khz !=0 ) { +if (dc->clk_mgr && dc->clk_mgr->clks.dispclk_khz !=0 && dc->clk_mgr->clks.dppclk_khz !=0 ) { dc->current_state->bw_ctx.bw.dcn.clk.dispclk_khz = dc->clk_mgr->clks.dispclk_khz; dc->current_state->bw_ctx.bw.dcn.clk.dppclk_khz = dc->clk_mgr->clks.dppclk_khz; }
@@ -1674,7 +1674,7 @@ void dcn10_init_hw(struct dc *dc)REG_UPDATE (DCFCLK_CNTL ,DCFCLK_GATE_DIS ,0 ); } -if (dc->clk_mgr->funcs->notify_wm_ranges) +if (dc->clk_mgr && dc->clk_mgr->funcs->notify_wm_ranges) dc->clk_mgr->funcs->notify_wm_ranges (dc->clk_mgr); }
drivers/gpu/drm/amd/display/dc/hwss/dcn31/dcn31_hwseq.c +2 -2
@@ -256,10 +256,10 @@ void dcn31_init_hw(struct dc *dc)if (!dcb->funcs->is_accelerated_mode (dcb) && dc->res_pool->hubbub->funcs->init_watermarks) dc->res_pool->hubbub->funcs->init_watermarks (dc->res_pool->hubbub); -if (dc->clk_mgr->funcs->notify_wm_ranges) +if (dc->clk_mgr && dc->clk_mgr->funcs->notify_wm_ranges) dc->clk_mgr->funcs->notify_wm_ranges (dc->clk_mgr); -if (dc->clk_mgr->funcs->set_hard_max_memclk && !dc->clk_mgr->dc_mode_softmax_enabled) +if (dc->clk_mgr && dc->clk_mgr->funcs->set_hard_max_memclk && !dc->clk_mgr->dc_mode_softmax_enabled) dc->clk_mgr->funcs->set_hard_max_memclk (dc->clk_mgr);if (dc->res_pool->hubbub->funcs->force_pstate_change_control)
drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c +4 -4
@@ -235,7 +235,7 @@ void dcn35_init_hw(struct dc *dc)if (hws->funcs.enable_power_gating_plane) hws->funcs.enable_power_gating_plane(dc->hwseq, true); */ -if (res_pool->hubbub->funcs->dchubbub_init) +if (res_pool->hubbub && res_pool->hubbub->funcs->dchubbub_init) res_pool->hubbub->funcs->dchubbub_init (dc->res_pool->hubbub);/* If taking control over from VBIOS, we may want to optimize our first * mode set, so we need to skip powering down pipes until we know which
@@ -328,10 +328,10 @@ void dcn35_init_hw(struct dc *dc)if (!dcb->funcs->is_accelerated_mode (dcb) && dc->res_pool->hubbub->funcs->init_watermarks) dc->res_pool->hubbub->funcs->init_watermarks (dc->res_pool->hubbub); -if (dc->clk_mgr->funcs->notify_wm_ranges) +if (dc->clk_mgr && dc->clk_mgr->funcs->notify_wm_ranges) dc->clk_mgr->funcs->notify_wm_ranges (dc->clk_mgr); -if (dc->clk_mgr->funcs->set_hard_max_memclk && !dc->clk_mgr->dc_mode_softmax_enabled) +if (dc->clk_mgr && dc->clk_mgr->funcs->set_hard_max_memclk && !dc->clk_mgr->dc_mode_softmax_enabled) dc->clk_mgr->funcs->set_hard_max_memclk (dc->clk_mgr);
@@ -1041,7 +1041,7 @@ void dcn35_calc_blocks_to_gate(struct dc *dc, struct dc_state *context,if (pipe_ctx->plane_res.hubp) update_state->pg_pipe_res_update[PG_HUBP ][pipe_ctx->plane_res.hubp->inst] = false; -if (pipe_ctx->plane_res.dpp) +if (pipe_ctx->plane_res.dpp && pipe_ctx->plane_res.hubp) update_state->pg_pipe_res_update[PG_DPP ][pipe_ctx->plane_res.hubp->inst] = false;if (pipe_ctx->plane_res.dpp || pipe_ctx->stream_res.opp)
drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_capability.c +1 -1
@@ -2254,7 +2254,7 @@ bool dp_verify_link_cap_with_retries(memset (&link->verified_link_cap,0 ,sizeof (struct dc_link_settings )); -if (!link_detect_connection_type (link, &type) || type == dc_connection_none) { +if (link->link_enc && (!link_detect_connection_type (link, &type) || type == dc_connection_none)) { link->verified_link_cap = fail_safe_link_settings;break ; }else if (dp_verify_link_cap (link, known_limit_link_setting, &fail_count)) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 133/244 drm/amd/display: Check null pointers before multiple uses
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit fdd5ecbbff751c3b9061d8ebb08e5c96119915b4 ]
[WHAT & HOW]
Poniters, such as stream_enc and dc->bw_vbios, are null checked previously in the same function, so Coverity warns "implies that stream_enc and dc->bw_vbios might be null". They are used multiple times in the subsequent code and need to be checked.
This fixes 10 FORWARD_NULL issues reported by Coverity.
--- .../drm/amd/display/dc/core/dc_hw_sequencer.c | 96 ++++++++++--------- .../amd/display/dc/hwss/dcn20/dcn20_hwseq.c | 8 +- .../display/dc/link/accessories/link_dp_cts.c | 5 +- .../amd/display/dc/link/hwss/link_hwss_dio.c | 5 +- .../dc/resource/dce112/dce112_resource.c | 5 +- .../dc/resource/dcn32/dcn32_resource.c | 3 + .../resource/dcn32/dcn32_resource_helpers.c | 10 +- 7 files changed, 76 insertions(+), 56 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c +49 -47
@@ -636,57 +636,59 @@ void hwss_build_fast_sequence(struct dc *dc,while (current_pipe) { current_mpc_pipe = current_pipe;while (current_mpc_pipe) { -if (dc->hwss.set_flip_control_gsl && current_mpc_pipe->plane_state && current_mpc_pipe->plane_state->update_flags.raw) { - block_sequence[*num_steps].params.set_flip_control_gsl_params.pipe_ctx = current_mpc_pipe; - block_sequence[*num_steps].params.set_flip_control_gsl_params.flip_immediate = current_mpc_pipe->plane_state->flip_immediate; - block_sequence[*num_steps].func =HUBP_SET_FLIP_CONTROL_GSL ; - (*num_steps)++; - } -if (dc->hwss.program_triplebuffer && dc->debug.enable_tri_buf && current_mpc_pipe->plane_state->update_flags.raw) { - block_sequence[*num_steps].params.program_triplebuffer_params.dc = dc; - block_sequence[*num_steps].params.program_triplebuffer_params.pipe_ctx = current_mpc_pipe; - block_sequence[*num_steps].params.program_triplebuffer_params.enableTripleBuffer = current_mpc_pipe->plane_state->triplebuffer_flips; - block_sequence[*num_steps].func =HUBP_PROGRAM_TRIPLEBUFFER ; - (*num_steps)++; - } -if (dc->hwss.update_plane_addr && current_mpc_pipe->plane_state->update_flags.bits.addr_update) { -if (resource_is_pipe_type (current_mpc_pipe,OTG_MASTER ) && - stream_status->mall_stream_config.type ==SUBVP_MAIN ) { - block_sequence[*num_steps].params.subvp_save_surf_addr.dc_dmub_srv = dc->ctx->dmub_srv; - block_sequence[*num_steps].params.subvp_save_surf_addr.addr = ¤t_mpc_pipe->plane_state->address; - block_sequence[*num_steps].params.subvp_save_surf_addr.subvp_index = current_mpc_pipe->subvp_index; - block_sequence[*num_steps].func =DMUB_SUBVP_SAVE_SURF_ADDR ; +if (current_mpc_pipe->plane_state) { +if (dc->hwss.set_flip_control_gsl && current_mpc_pipe->plane_state->update_flags.raw) { + block_sequence[*num_steps].params.set_flip_control_gsl_params.pipe_ctx = current_mpc_pipe; + block_sequence[*num_steps].params.set_flip_control_gsl_params.flip_immediate = current_mpc_pipe->plane_state->flip_immediate; + block_sequence[*num_steps].func =HUBP_SET_FLIP_CONTROL_GSL ; + (*num_steps)++; + } +if (dc->hwss.program_triplebuffer && dc->debug.enable_tri_buf && current_mpc_pipe->plane_state->update_flags.raw) { + block_sequence[*num_steps].params.program_triplebuffer_params.dc = dc; + block_sequence[*num_steps].params.program_triplebuffer_params.pipe_ctx = current_mpc_pipe; + block_sequence[*num_steps].params.program_triplebuffer_params.enableTripleBuffer = current_mpc_pipe->plane_state->triplebuffer_flips; + block_sequence[*num_steps].func =HUBP_PROGRAM_TRIPLEBUFFER ; + (*num_steps)++; + } +if (dc->hwss.update_plane_addr && current_mpc_pipe->plane_state->update_flags.bits.addr_update) { +if (resource_is_pipe_type (current_mpc_pipe,OTG_MASTER ) && + stream_status->mall_stream_config.type ==SUBVP_MAIN ) { + block_sequence[*num_steps].params.subvp_save_surf_addr.dc_dmub_srv = dc->ctx->dmub_srv; + block_sequence[*num_steps].params.subvp_save_surf_addr.addr = ¤t_mpc_pipe->plane_state->address; + block_sequence[*num_steps].params.subvp_save_surf_addr.subvp_index = current_mpc_pipe->subvp_index; + block_sequence[*num_steps].func =DMUB_SUBVP_SAVE_SURF_ADDR ; + (*num_steps)++; + } + + block_sequence[*num_steps].params.update_plane_addr_params.dc = dc; + block_sequence[*num_steps].params.update_plane_addr_params.pipe_ctx = current_mpc_pipe; + block_sequence[*num_steps].func =HUBP_UPDATE_PLANE_ADDR ; (*num_steps)++; } - block_sequence[*num_steps].params.update_plane_addr_params.dc = dc; - block_sequence[*num_steps].params.update_plane_addr_params.pipe_ctx = current_mpc_pipe; - block_sequence[*num_steps].func =HUBP_UPDATE_PLANE_ADDR ; - (*num_steps)++; - } - -if (hws->funcs.set_input_transfer_func && current_mpc_pipe->plane_state->update_flags.bits.gamma_change) { - block_sequence[*num_steps].params.set_input_transfer_func_params.dc = dc; - block_sequence[*num_steps].params.set_input_transfer_func_params.pipe_ctx = current_mpc_pipe; - block_sequence[*num_steps].params.set_input_transfer_func_params.plane_state = current_mpc_pipe->plane_state; - block_sequence[*num_steps].func =DPP_SET_INPUT_TRANSFER_FUNC ; - (*num_steps)++; - } +if (hws->funcs.set_input_transfer_func && current_mpc_pipe->plane_state->update_flags.bits.gamma_change) { + block_sequence[*num_steps].params.set_input_transfer_func_params.dc = dc; + block_sequence[*num_steps].params.set_input_transfer_func_params.pipe_ctx = current_mpc_pipe; + block_sequence[*num_steps].params.set_input_transfer_func_params.plane_state = current_mpc_pipe->plane_state; + block_sequence[*num_steps].func =DPP_SET_INPUT_TRANSFER_FUNC ; + (*num_steps)++; + } -if (dc->hwss.program_gamut_remap && current_mpc_pipe->plane_state->update_flags.bits.gamut_remap_change) { - block_sequence[*num_steps].params.program_gamut_remap_params.pipe_ctx = current_mpc_pipe; - block_sequence[*num_steps].func =DPP_PROGRAM_GAMUT_REMAP ; - (*num_steps)++; - } -if (current_mpc_pipe->plane_state->update_flags.bits.input_csc_change) { - block_sequence[*num_steps].params.setup_dpp_params.pipe_ctx = current_mpc_pipe; - block_sequence[*num_steps].func =DPP_SETUP_DPP ; - (*num_steps)++; - } -if (current_mpc_pipe->plane_state->update_flags.bits.coeff_reduction_change) { - block_sequence[*num_steps].params.program_bias_and_scale_params.pipe_ctx = current_mpc_pipe; - block_sequence[*num_steps].func =DPP_PROGRAM_BIAS_AND_SCALE ; - (*num_steps)++; +if (dc->hwss.program_gamut_remap && current_mpc_pipe->plane_state->update_flags.bits.gamut_remap_change) { + block_sequence[*num_steps].params.program_gamut_remap_params.pipe_ctx = current_mpc_pipe; + block_sequence[*num_steps].func =DPP_PROGRAM_GAMUT_REMAP ; + (*num_steps)++; + } +if (current_mpc_pipe->plane_state->update_flags.bits.input_csc_change) { + block_sequence[*num_steps].params.setup_dpp_params.pipe_ctx = current_mpc_pipe; + block_sequence[*num_steps].func =DPP_SETUP_DPP ; + (*num_steps)++; + } +if (current_mpc_pipe->plane_state->update_flags.bits.coeff_reduction_change) { + block_sequence[*num_steps].params.program_bias_and_scale_params.pipe_ctx = current_mpc_pipe; + block_sequence[*num_steps].func =DPP_PROGRAM_BIAS_AND_SCALE ; + (*num_steps)++; + } }if (hws->funcs.set_output_transfer_func && current_mpc_pipe->stream->update_flags.bits.out_tf) { block_sequence[*num_steps].params.set_output_transfer_func_params.dc = dc;
drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c +7 -1
@@ -2283,6 +2283,9 @@ void dcn20_post_unlock_program_front_end( } } +if (!hwseq) +return ; +/* P-State support transitions: * Natural -> FPO: P-State disabled in prepare, force disallow anytime is safe * FPO -> Natural: Unforce anytime after FW disable is safe (P-State will assert naturally)
@@ -2290,7 +2293,7 @@ void dcn20_post_unlock_program_front_end(* FPO -> Unsupported: P-State disabled in prepare, unforce disallow anytime is safe * FPO <-> SubVP: Force disallow is maintained on the FPO / SubVP pipes */ -if (hwseq && hwseq->funcs.update_force_pstate) +if (hwseq->funcs.update_force_pstate) dc->hwseq->funcs.update_force_pstate (dc, context);/* Only program the MALL registers after all the main and phantom pipes
@@ -2529,6 +2532,9 @@ bool dcn20_wait_for_blank_complete( {int counter; +if (!opp) +return false; +for (counter =0 ; counter <1000 ; counter++) {if (!opp->funcs->dpg_is_pending (opp))break ;
drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c +4 -1
@@ -804,8 +804,11 @@ bool dp_set_test_pattern(break ; } +if (!pipe_ctx->stream) +return false; +if (pipe_ctx->stream_res.tg->funcs->lock_doublebuffer_enable) { -if (pipe_ctx->stream &&should_use_dmub_lock (pipe_ctx->stream->link)) { +if (should_use_dmub_lock (pipe_ctx->stream->link)) {union dmub_hw_lock_flags hw_locks = {0 };struct dmub_hw_lock_inst_flags inst_flags = {0 };
drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_dio.c +4 -1
@@ -74,7 +74,10 @@ void reset_dio_stream_encoder(struct pipe_ctx *pipe_ctx)struct link_encoder *link_enc =link_enc_cfg_get_link_enc (pipe_ctx->stream->link);struct stream_encoder *stream_enc = pipe_ctx->stream_res.stream_enc; -if (stream_enc && stream_enc->funcs->disable_fifo) +if (!stream_enc) +return ; + +if (stream_enc->funcs->disable_fifo) stream_enc->funcs->disable_fifo (stream_enc);if (stream_enc->funcs->set_input_mode) stream_enc->funcs->set_input_mode (stream_enc,0 );
drivers/gpu/drm/amd/display/dc/resource/dce112/dce112_resource.c +4 -1
@@ -1067,7 +1067,10 @@ static void bw_calcs_data_update_from_pplib(struct dc *dc)struct dm_pp_clock_levels clks = {0 };int memory_type_multiplier =MEMORY_TYPE_MULTIPLIER_CZ ; -if (dc->bw_vbios && dc->bw_vbios->memory_type == bw_def_hbm) +if (!dc->bw_vbios) +return ; + +if (dc->bw_vbios->memory_type == bw_def_hbm) memory_type_multiplier =MEMORY_TYPE_HBM ;/*do system clock TODO PPLIB: after PPLIB implement,
drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c +3 -0
@@ -1651,6 +1651,9 @@ static void dcn32_enable_phantom_plane(struct dc *dc,else phantom_plane =dc_state_create_phantom_plane (dc, context, curr_pipe->plane_state); +if (!phantom_plane) +continue ; +memcpy (&phantom_plane->address, &curr_pipe->plane_state->address,sizeof (phantom_plane->address));memcpy (&phantom_plane->scaling_quality, &curr_pipe->plane_state->scaling_quality,sizeof (phantom_plane->scaling_quality));
drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource_helpers.c +5 -5
@@ -218,12 +218,12 @@ bool dcn32_is_center_timing(struct pipe_ctx *pipe) pipe->stream->timing.v_addressable != pipe->stream->src.height) { is_center_timing = true; } - } -if (pipe->plane_state) { -if (pipe->stream->timing.v_addressable != pipe->plane_state->dst_rect.height && - pipe->stream->timing.v_addressable != pipe->plane_state->src_rect.height) { - is_center_timing = true; +if (pipe->plane_state) { +if (pipe->stream->timing.v_addressable != pipe->plane_state->dst_rect.height && + pipe->stream->timing.v_addressable != pipe->plane_state->src_rect.height) { + is_center_timing = true; + } } }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 134/244 drm/amdgpu: disallow multiple BO_HANDLES chunks in one submit
In reply to Sasha LevinFrom: Pierre-Eric Pelloux-Prayer <[email protected]>
[ Upstream commit fec5f8e8c6bcf83ed7a392801d7b44c5ecfc1e82 ]
Before this commit, only submits with both a BO_HANDLES chunk and a 'bo_list_handle' would be rejected (by amdgpu_cs_parser_bos).
But if UMD sent multiple BO_HANDLES, what would happen is:
* only the last one would be really used
* all the others would leak memory as amdgpu_cs_p1_bo_handles would overwrite the previous p->bo_list value
This commit rejects submissions with multiple BO_HANDLES chunks to match the implementation of the parser.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +4 -0
@@ -263,6 +263,10 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p,if (size <sizeof (struct drm_amdgpu_bo_list_in )) goto free_partial_kdata; +/* Only a single BO list is allowed to simplify handling. */ +if (p->bo_list) + ret = -EINVAL ; + ret =amdgpu_cs_p1_bo_handles (p, p->chunks[i].kdata);if (ret) goto free_partial_kdata;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 135/244 drm/amdkfd: amdkfd_free_gtt_mem clear the correct pointer
In reply to Sasha LevinFrom: Philip Yang <[email protected]>
[ Upstream commit c86ad39140bbcb9dc75a10046c2221f657e8083b ]
Pass pointer reference to amdgpu_bo_unref to clear the correct pointer, otherwise amdgpu_bo_unref clear the local variable, the original pointer not set to NULL, this could cause use-after-free bug.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 14 +++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 4 ++-- .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 2 +- .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +7 -7
@@ -364,15 +364,15 @@ int amdgpu_amdkfd_alloc_gtt_mem(struct amdgpu_device *adev, size_t size,return r; } -void amdgpu_amdkfd_free_gtt_mem (struct amdgpu_device *adev,void *mem_obj) +void amdgpu_amdkfd_free_gtt_mem (struct amdgpu_device *adev,void **mem_obj) { -struct amdgpu_bo *bo = (struct amdgpu_bo *) mem_obj; +struct amdgpu_bo **bo = (struct amdgpu_bo **) mem_obj; -amdgpu_bo_reserve (bo, true); -amdgpu_bo_kunmap (bo); -amdgpu_bo_unpin (bo); -amdgpu_bo_unreserve (bo); -amdgpu_bo_unref (&(bo)); +amdgpu_bo_reserve (*bo, true); +amdgpu_bo_kunmap (*bo); +amdgpu_bo_unpin (*bo); +amdgpu_bo_unreserve (*bo); +amdgpu_bo_unref (bo); } int amdgpu_amdkfd_alloc_gws(struct amdgpu_device *adev, size_t size,
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +1 -1
@@ -235,7 +235,7 @@ int amdgpu_amdkfd_bo_validate_and_fence(struct amdgpu_bo *bo,int amdgpu_amdkfd_alloc_gtt_mem (struct amdgpu_device *adev,size_t size,void **mem_obj,uint64_t *gpu_addr,void **cpu_ptr,bool mqd_gfx9); -void amdgpu_amdkfd_free_gtt_mem (struct amdgpu_device *adev,void *mem_obj); +void amdgpu_amdkfd_free_gtt_mem (struct amdgpu_device *adev,void **mem_obj);int amdgpu_amdkfd_alloc_gws (struct amdgpu_device *adev,size_t size,void **mem_obj);void amdgpu_amdkfd_free_gws (struct amdgpu_device *adev,void *mem_obj);
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +1 -1
@@ -423,7 +423,7 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p, err_create_queue:if (wptr_bo) -amdgpu_amdkfd_free_gtt_mem (dev->adev, wptr_bo); +amdgpu_amdkfd_free_gtt_mem (dev->adev, (void **)&wptr_bo); err_wptr_map_gart: err_bind_process: err_pdd:
drivers/gpu/drm/amd/amdkfd/kfd_device.c +2 -2
@@ -907,7 +907,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, kfd_doorbell_error:kfd_gtt_sa_fini (kfd); kfd_gtt_sa_init_error: -amdgpu_amdkfd_free_gtt_mem (kfd->adev, kfd->gtt_mem); +amdgpu_amdkfd_free_gtt_mem (kfd->adev, &kfd->gtt_mem); alloc_gtt_mem_failure: dev_err(kfd_device, "device %x:%x NOT added due to errors\n",
@@ -925,7 +925,7 @@ void kgd2kfd_device_exit(struct kfd_dev *kfd)kfd_doorbell_fini (kfd);ida_destroy (&kfd->doorbell_ida);kfd_gtt_sa_fini (kfd); -amdgpu_amdkfd_free_gtt_mem (kfd->adev, kfd->gtt_mem); +amdgpu_amdkfd_free_gtt_mem (kfd->adev, &kfd->gtt_mem); }kfree (kfd);
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1 -1
@@ -2621,7 +2621,7 @@ static void deallocate_hiq_sdma_mqd(struct kfd_node *dev, {WARN (!mqd,"No hiq sdma mqd trunk to free" ); -amdgpu_amdkfd_free_gtt_mem (dev->adev, mqd->gtt_mem); +amdgpu_amdkfd_free_gtt_mem (dev->adev, &mqd->gtt_mem); }void device_queue_manager_uninit (struct device_queue_manager *dqm)
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +1 -1
@@ -225,7 +225,7 @@ void kfd_free_mqd_cp(struct mqd_manager *mm, void *mqd, struct kfd_mem_obj *mqd_mem_obj) {if (mqd_mem_obj->gtt_mem) { -amdgpu_amdkfd_free_gtt_mem (mm->dev->adev, mqd_mem_obj->gtt_mem); +amdgpu_amdkfd_free_gtt_mem (mm->dev->adev, &mqd_mem_obj->gtt_mem);kfree (mqd_mem_obj); }else {kfd_gtt_sa_free (mm->dev, mqd_mem_obj);
drivers/gpu/drm/amd/amdkfd/kfd_process.c +1 -1
@@ -1048,7 +1048,7 @@ static void kfd_process_destroy_pdds(struct kfd_process *p)if (pdd->dev->kfd->shared_resources.enable_mes)amdgpu_amdkfd_free_gtt_mem (pdd->dev->adev, - pdd->proc_ctx_bo); + &pdd->proc_ctx_bo);/* * before destroying pdd, make sure to report availability * for auto suspend
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +2 -2
@@ -204,9 +204,9 @@ static void pqm_clean_queue_resource(struct process_queue_manager *pqm, }if (dev->kfd->shared_resources.enable_mes) { -amdgpu_amdkfd_free_gtt_mem (dev->adev, pqn->q->gang_ctx_bo); +amdgpu_amdkfd_free_gtt_mem (dev->adev, &pqn->q->gang_ctx_bo);if (pqn->q->wptr_bo) -amdgpu_amdkfd_free_gtt_mem (dev->adev, pqn->q->wptr_bo); +amdgpu_amdkfd_free_gtt_mem (dev->adev, (void **)&pqn->q->wptr_bo); } }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 136/244 drm/amd/display: Add null check for head_pipe in dcn201_acquire_free_pipe_for_layer
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit f22f4754aaa47d8c59f166ba3042182859e5dff7 ]
This commit addresses a potential null pointer dereference issue in the dcn201_acquire_free_pipe_for_layer function. The issue could occur when head_pipe is null.
The fix adds a check to ensure head_pipe is not null before asserting it. If head_pipe is null, the function returns NULL to prevent a potential null pointer dereference.
Reported by smatch:drivers/gpu/drm/amd/amdgpu/../display/dc/resource/dcn201/dcn201_resource.c:1016 dcn201_acquire_free_pipe_for_layer() error: we previously assumed 'head_pipe' could be null (see line 1010)
--- .../gpu/drm/amd/display/dc/resource/dcn201/dcn201_resource.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/resource/dcn201/dcn201_resource.c +3 -1
@@ -1007,8 +1007,10 @@ static struct pipe_ctx *dcn201_acquire_free_pipe_for_layer(struct pipe_ctx *head_pipe =resource_get_otg_master_for_stream (res_ctx, opp_head_pipe->stream);struct pipe_ctx *idle_pipe =resource_find_free_secondary_pipe_legacy (res_ctx, pool, head_pipe); -if (!head_pipe) +if (!head_pipe) {ASSERT (0 ); +return NULL ; + }if (!idle_pipe)return NULL ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 137/244 drm/amd/display: Add null check for head_pipe in dcn32_acquire_idle_pipe_for_head_pipe_in_layer
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit ac2140449184a26eac99585b7f69814bd3ba8f2d ]
This commit addresses a potential null pointer dereference issue in the dcn32_acquire_idle_pipe_for_head_pipe_in_layer function. The issue could occur when head_pipe is null.
The fix adds a check to ensure head_pipe is not null before asserting it. If head_pipe is null, the function returns NULL to prevent a potential null pointer dereference.
Reported by smatch:drivers/gpu/drm/amd/amdgpu/../display/dc/resource/dcn32/dcn32_resource.c:2690 dcn32_acquire_idle_pipe_for_head_pipe_in_layer() error: we previously assumed 'head_pipe' could be null (see line 2681)
--- .../gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c +3 -1
@@ -2674,8 +2674,10 @@ static struct pipe_ctx *dcn32_acquire_idle_pipe_for_head_pipe_in_layer(struct resource_context *old_ctx = &stream->ctx->dc->current_state->res_ctx;int head_index; -if (!head_pipe) +if (!head_pipe) {ASSERT (0 ); +return NULL ; + }/* * Modified from dcn20_acquire_idle_pipe_for_layer
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 138/244 drm/amd/display: Add NULL check for clk_mgr and clk_mgr->funcs in dcn30_init_hw
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit cba7fec864172dadd953daefdd26e01742b71a6a ]
This commit addresses a potential null pointer dereference issue in the dcn30_init_hw function. The issue could occur when dc->clk_mgr or dc->clk_mgr->funcs is null.
The fix adds a check to ensure dc->clk_mgr and dc->clk_mgr->funcs is not null before accessing its functions. This prevents a potential null pointer dereference.
Reported by smatch:drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn30/dcn30_hwseq.c:789 dcn30_init_hw() error: we previously assumed 'dc->clk_mgr' could be null (see line 628)
--- drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.c +4 -3
@@ -625,7 +625,7 @@ void dcn30_init_hw(struct dc *dc)uint32_t backlight =MAX_BACKLIGHT_LEVEL ;uint32_t user_level =MAX_BACKLIGHT_LEVEL ; -if (dc->clk_mgr && dc->clk_mgr->funcs->init_clocks) +if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->init_clocks) dc->clk_mgr->funcs->init_clocks (dc->clk_mgr);// Initialize the dccg
@@ -786,11 +786,12 @@ void dcn30_init_hw(struct dc *dc)if (!dcb->funcs->is_accelerated_mode (dcb) && dc->res_pool->hubbub->funcs->init_watermarks) dc->res_pool->hubbub->funcs->init_watermarks (dc->res_pool->hubbub); -if (dc->clk_mgr->funcs->notify_wm_ranges) +if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->notify_wm_ranges) dc->clk_mgr->funcs->notify_wm_ranges (dc->clk_mgr);//if softmax is enabled then hardmax will be set by a different call -if (dc->clk_mgr->funcs->set_hard_max_memclk && !dc->clk_mgr->dc_mode_softmax_enabled) +if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->set_hard_max_memclk && + !dc->clk_mgr->dc_mode_softmax_enabled) dc->clk_mgr->funcs->set_hard_max_memclk (dc->clk_mgr);if (dc->res_pool->hubbub->funcs->force_pstate_change_control)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 139/244 drm/amd/display: Add NULL check for clk_mgr and clk_mgr->funcs in dcn401_init_hw
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit 4b6377f0e96085cbec96eb7f0b282430ccdd3d75 ]
This commit addresses a potential null pointer dereference issue in the dcn401_init_hw function. The issue could occur when dc->clk_mgr or dc->clk_mgr->funcs is null.
The fix adds a check to ensure dc->clk_mgr and dc->clk_mgr->funcs is not null before accessing its functions. This prevents a potential null pointer dereference.
Reported by smatch:drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn401/dcn401_hwseq.c:416 dcn401_init_hw() error: we previously assumed 'dc->clk_mgr' could be null (see line 225)
--- drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c +5 -3
@@ -222,7 +222,7 @@ void dcn401_init_hw(struct dc *dc)uint32_t backlight =MAX_BACKLIGHT_LEVEL ;uint32_t user_level =MAX_BACKLIGHT_LEVEL ; -if (dc->clk_mgr && dc->clk_mgr->funcs->init_clocks) { +if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->init_clocks) { dc->clk_mgr->funcs->init_clocks (dc->clk_mgr);// mark dcmode limits present if any clock has distinct AC and DC values from SMU
@@ -413,7 +413,7 @@ void dcn401_init_hw(struct dc *dc)if (!dcb->funcs->is_accelerated_mode (dcb) && dc->res_pool->hubbub->funcs->init_watermarks) dc->res_pool->hubbub->funcs->init_watermarks (dc->res_pool->hubbub); -if (dc->clk_mgr->funcs->notify_wm_ranges) +if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->notify_wm_ranges) dc->clk_mgr->funcs->notify_wm_ranges (dc->clk_mgr);if (dc->clk_mgr->funcs->set_hard_max_memclk && !dc->clk_mgr->dc_mode_softmax_enabled)
@@ -438,7 +438,9 @@ void dcn401_init_hw(struct dc *dc) dc->debug.fams2_config.bits.enable &= dc->ctx->dmub_srv->dmub->feature_caps.fw_assisted_mclk_switch_ver ==2 ;if (!dc->debug.fams2_config.bits.enable && dc->res_pool->funcs->update_bw_bounding_box) {/* update bounding box if FAMS2 disabled */ - dc->res_pool->funcs->update_bw_bounding_box (dc, dc->clk_mgr->bw_params); +if (dc->clk_mgr) + dc->res_pool->funcs->update_bw_bounding_box (dc, + dc->clk_mgr->bw_params); } } }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 140/244 drm/amd/display: Add NULL check for clk_mgr in dcn32_init_hw
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit c395fd47d1565bd67671f45cca281b3acc2c31ef ]
This commit addresses a potential null pointer dereference issue in the dcn32_init_hw function. The issue could occur when dc->clk_mgr is null.
The fix adds a check to ensure dc->clk_mgr is not null before accessing its functions. This prevents a potential null pointer dereference.
Reported by smatch:drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn32/dcn32_hwseq.c:961 dcn32_init_hw() error: we previously assumed 'dc->clk_mgr' could be null (see line 782)
--- drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c +4 -3
@@ -779,7 +779,7 @@ void dcn32_init_hw(struct dc *dc)uint32_t backlight =MAX_BACKLIGHT_LEVEL ;uint32_t user_level =MAX_BACKLIGHT_LEVEL ; -if (dc->clk_mgr && dc->clk_mgr->funcs->init_clocks) +if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->init_clocks) dc->clk_mgr->funcs->init_clocks (dc->clk_mgr);// Initialize the dccg
@@ -958,10 +958,11 @@ void dcn32_init_hw(struct dc *dc)if (!dcb->funcs->is_accelerated_mode (dcb) && dc->res_pool->hubbub->funcs->init_watermarks) dc->res_pool->hubbub->funcs->init_watermarks (dc->res_pool->hubbub); -if (dc->clk_mgr->funcs->notify_wm_ranges) +if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->notify_wm_ranges) dc->clk_mgr->funcs->notify_wm_ranges (dc->clk_mgr); -if (dc->clk_mgr->funcs->set_hard_max_memclk && !dc->clk_mgr->dc_mode_softmax_enabled) +if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->set_hard_max_memclk && + !dc->clk_mgr->dc_mode_softmax_enabled) dc->clk_mgr->funcs->set_hard_max_memclk (dc->clk_mgr);if (dc->res_pool->hubbub->funcs->force_pstate_change_control)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 141/244 drm/xe/hdcp: Check GSC structure validity
In reply to Sasha LevinFrom: Suraj Kandpal <[email protected]>
[ Upstream commit b4224f6bae3801d589f815672ec62800a1501b0d ]
Sometimes xe_gsc is not initialized when checked at HDCP capability check. Add gsc structure check to avoid null pointer error.
--- drivers/gpu/drm/xe/display/xe_hdcp_gsc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/display/xe_hdcp_gsc.c +6 -2
@@ -40,10 +40,14 @@ bool intel_hdcp_gsc_check_status(struct xe_device *xe) {struct xe_tile *tile =xe_device_get_root_tile (xe);struct xe_gt *gt = tile->media_gt; +struct xe_gsc *gsc = >->uc.gsc;bool ret = true; -if (!xe_uc_fw_is_enabled (>->uc.gsc.fw)) +if (!gsc && !xe_uc_fw_is_enabled (&gsc->fw)) { +drm_dbg_kms (&xe->drm, +"GSC Components not ready for HDCP2.x\n" );return false; + }xe_pm_runtime_get (xe);if (xe_force_wake_get (gt_to_fw (gt),XE_FW_GSC )) {
@@ -53,7 +57,7 @@ bool intel_hdcp_gsc_check_status(struct xe_device *xe) goto out; } -if (!xe_gsc_proxy_init_done (>->uc.gsc)) +if (!xe_gsc_proxy_init_done (gsc)) ret = false;xe_force_wake_put (gt_to_fw (gt),XE_FW_GSC );
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 142/244 drm/amd/display: Add null check for pipe_ctx->plane_state in dcn20_program_pipe
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit 8e4ed3cf1642df0c4456443d865cff61a9598aa8 ]
This commit addresses a null pointer dereference issue in the dcn20_program_pipe function. The issue could occur when pipe_ctx->plane_state is null.
The fix adds a check to ensure pipe_ctx->plane_state is not null before accessing. This prevents a null pointer dereference.
Reported by smatch:drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn20/dcn20_hwseq.c:1925 dcn20_program_pipe() error: we previously assumed 'pipe_ctx->plane_state' could be null (see line 1877)
--- .../amd/display/dc/hwss/dcn20/dcn20_hwseq.c | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c +19 -11
@@ -1921,22 +1921,29 @@ static void dcn20_program_pipe( dc->res_pool->hubbub, pipe_ctx->plane_res.hubp->inst, pipe_ctx->hubp_regs.det_size); } -if (pipe_ctx->update_flags.raw || pipe_ctx->plane_state->update_flags.raw || pipe_ctx->stream->update_flags.raw) +if (pipe_ctx->update_flags.raw || + (pipe_ctx->plane_state && pipe_ctx->plane_state->update_flags.raw) || + pipe_ctx->stream->update_flags.raw)dcn20_update_dchubp_dpp (dc, pipe_ctx, context); -if (pipe_ctx->update_flags.bits.enable - || pipe_ctx->plane_state->update_flags.bits.hdr_mult) +if (pipe_ctx->update_flags.bits.enable || + (pipe_ctx->plane_state && pipe_ctx->plane_state->update_flags.bits.hdr_mult)) hws->funcs.set_hdr_multiplier (pipe_ctx);if (hws->funcs.populate_mcm_luts) { - hws->funcs.populate_mcm_luts (dc, pipe_ctx, pipe_ctx->plane_state->mcm_luts, - pipe_ctx->plane_state->lut_bank_a); - pipe_ctx->plane_state->lut_bank_a = !pipe_ctx->plane_state->lut_bank_a; +if (pipe_ctx->plane_state) { + hws->funcs.populate_mcm_luts (dc, pipe_ctx, pipe_ctx->plane_state->mcm_luts, + pipe_ctx->plane_state->lut_bank_a); + pipe_ctx->plane_state->lut_bank_a = !pipe_ctx->plane_state->lut_bank_a; + } }if (pipe_ctx->update_flags.bits.enable || - pipe_ctx->plane_state->update_flags.bits.in_transfer_func_change || - pipe_ctx->plane_state->update_flags.bits.gamma_change || - pipe_ctx->plane_state->update_flags.bits.lut_3d) + (pipe_ctx->plane_state && + pipe_ctx->plane_state->update_flags.bits.in_transfer_func_change) || + (pipe_ctx->plane_state && + pipe_ctx->plane_state->update_flags.bits.gamma_change) || + (pipe_ctx->plane_state && + pipe_ctx->plane_state->update_flags.bits.lut_3d)) hws->funcs.set_input_transfer_func (dc, pipe_ctx, pipe_ctx->plane_state);/* dcn10_translate_regamma_to_hw_format takes 750us to finish
@@ -1946,7 +1953,8 @@ static void dcn20_program_pipe(if (pipe_ctx->update_flags.bits.enable || pipe_ctx->update_flags.bits.plane_changed || pipe_ctx->stream->update_flags.bits.out_tf || - pipe_ctx->plane_state->update_flags.bits.output_tf_change) + (pipe_ctx->plane_state && + pipe_ctx->plane_state->update_flags.bits.output_tf_change)) hws->funcs.set_output_transfer_func (dc, pipe_ctx, pipe_ctx->stream);/* If the pipe has been enabled or has a different opp, we
@@ -1970,7 +1978,7 @@ static void dcn20_program_pipe( }/* Set ABM pipe after other pipe configurations done */ -if (pipe_ctx->plane_state->visible) { +if ((pipe_ctx->plane_state && pipe_ctx->plane_state->visible)) {if (pipe_ctx->stream_res.abm) { dc->hwss.set_pipe (pipe_ctx); pipe_ctx->stream_res.abm->funcs->set_abm_level(pipe_ctx->stream_res.abm,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 143/244 drm/amd/display: Add null check for top_pipe_to_program in commit_planes_for_stream
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit 66d71a72539e173a9b00ca0b1852cbaa5f5bf1ad ]
This commit addresses a null pointer dereference issue in the commit_planes_for_stream function at line 4140. The issue could occur when top_pipe_to_program is null.
The fix adds a check to ensure top_pipe_to_program is not null before accessing its stream_res. This prevents a null pointer dereference.
Reported by smatch:drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc.c:4140 commit_planes_for_stream() error: we previously assumed 'top_pipe_to_program' could be null (see line 3906)
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +2 -1
@@ -4127,7 +4127,8 @@ static void commit_planes_for_stream(struct dc *dc, }if ((update_type !=UPDATE_TYPE_FAST ) && stream->update_flags.bits.dsc_changed) -if (top_pipe_to_program->stream_res.tg->funcs->lock_doublebuffer_enable) { +if (top_pipe_to_program && + top_pipe_to_program->stream_res.tg->funcs->lock_doublebuffer_enable) { top_pipe_to_program->stream_res.tg->funcs->wait_for_state ( top_pipe_to_program->stream_res.tg,CRTC_STATE_VACTIVE );
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 144/244 drm/amd/display: Use gpuvm_min_page_size_kbytes for DML2 surfaces
In reply to Sasha LevinFrom: Nicholas Kazlauskas <[email protected]>
[ Upstream commit 31663521ede2edb622ee1b397ae3ac666d6351c5 ]
[Why]
It's currently hard coded to 256 when it should be using the SOC provided values. This can result in corruption with linear surfaces where we prefetch more PTE than the buffer can hold.
[How]
Update the min page size correctly for the plane.
--- .../display/dc/dml2/dml2_translation_helper.c | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c +14 -6
@@ -953,7 +953,9 @@ static void get_scaler_data_for_plane(const struct dc_plane_state *in, struct dcmemcpy (out, &temp_pipe->plane_res.scl_data,sizeof (*out)); } -static void populate_dummy_dml_plane_cfg (struct dml_plane_cfg_st *out,unsigned int location,const struct dc_stream_state *in) +static void populate_dummy_dml_plane_cfg (struct dml_plane_cfg_st *out,unsigned int location, +const struct dc_stream_state *in, +const struct soc_bounding_box_st *soc) {dml_uint_t width, height;
@@ -970,7 +972,7 @@ static void populate_dummy_dml_plane_cfg(struct dml_plane_cfg_st *out, unsigned out->CursorBPP[location] = dml_cur_32bit; out->CursorWidth[location] =256 ; - out->GPUVMMinPageSizeKBytes[location] =256 ; + out->GPUVMMinPageSizeKBytes[location] = soc->gpuvm_min_page_size_kbytes; out->ViewportWidth[location] = width; out->ViewportHeight[location] = height;
@@ -1007,7 +1009,9 @@ static void populate_dummy_dml_plane_cfg(struct dml_plane_cfg_st *out, unsigned out->ScalerEnabled[location] = false; } -static void populate_dml_plane_cfg_from_plane_state (struct dml_plane_cfg_st *out,unsigned int location,const struct dc_plane_state *in,struct dc_state *context) +static void populate_dml_plane_cfg_from_plane_state (struct dml_plane_cfg_st *out,unsigned int location, +const struct dc_plane_state *in,struct dc_state *context, +const struct soc_bounding_box_st *soc) {struct scaler_data *scaler_data =kzalloc (sizeof (*scaler_data),GFP_KERNEL );if (!scaler_data)
@@ -1018,7 +1022,7 @@ static void populate_dml_plane_cfg_from_plane_state(struct dml_plane_cfg_st *out out->CursorBPP[location] = dml_cur_32bit; out->CursorWidth[location] =256 ; - out->GPUVMMinPageSizeKBytes[location] =256 ; + out->GPUVMMinPageSizeKBytes[location] = soc->gpuvm_min_page_size_kbytes; out->ViewportWidth[location] = scaler_data->viewport.width; out->ViewportHeight[location] = scaler_data->viewport.height;
@@ -1299,7 +1303,8 @@ void map_dc_state_into_dml_display_cfg(struct dml2_context *dml2, struct dc_stat disp_cfg_plane_location = dml_dispcfg->num_surfaces++;populate_dummy_dml_surface_cfg (&dml_dispcfg->surface, disp_cfg_plane_location, context->streams[i]); -populate_dummy_dml_plane_cfg (&dml_dispcfg->plane, disp_cfg_plane_location, context->streams[i]); +populate_dummy_dml_plane_cfg (&dml_dispcfg->plane, disp_cfg_plane_location, + context->streams[i], &dml2->v20.dml_core_ctx.soc); dml_dispcfg->plane.BlendingAndTiming[disp_cfg_plane_location] = disp_cfg_stream_location;
@@ -1315,7 +1320,10 @@ void map_dc_state_into_dml_display_cfg(struct dml2_context *dml2, struct dc_statASSERT (disp_cfg_plane_location >=0 && disp_cfg_plane_location <= __DML2_WRAPPER_MAX_STREAMS_PLANES__);populate_dml_surface_cfg_from_plane_state (dml2->v20.dml_core_ctx.project, &dml_dispcfg->surface, disp_cfg_plane_location, context->stream_status[i].plane_states[j]); -populate_dml_plane_cfg_from_plane_state (&dml_dispcfg->plane, disp_cfg_plane_location, context->stream_status[i].plane_states[j], context); +populate_dml_plane_cfg_from_plane_state ( + &dml_dispcfg->plane, disp_cfg_plane_location, + context->stream_status[i].plane_states[j], context, + &dml2->v20.dml_core_ctx.soc);if (stream_mall_type ==SUBVP_MAIN ) { dml_dispcfg->plane.UseMALLForPStateChange[disp_cfg_plane_location] = dml_use_mall_pstate_change_sub_viewport;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 145/244 ata: pata_serverworks: Do not use the term blacklist
In reply to Sasha LevinFrom: Damien Le Moal <[email protected]>
[ Upstream commit 858048568c9e3887d8b19e101ee72f129d65cb15 ]
Let's not use the term blacklist in the function serverworks_osb4_filter() documentation comment and rather simply refer to what that function looks at: the list of devices with groken UDMA5.
While at it, also constify the values of the csb_bad_ata100 array.
Of note is that all of this should probably be handled using libata quirk mechanism but it is unclear if these UDMA5 quirks are specific to this controller only.
--- drivers/ata/pata_serverworks.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/ata/pata_serverworks.c +9 -7
@@ -46,10 +46,11 @@#define SVWKS_CSB5_REVISION_NEW 0x92/* min PCI_REVISION_ID for UDMA5 (A2.0) */ #define SVWKS_CSB6_REVISION 0xa0/* min PCI_REVISION_ID for UDMA4 (A1.0) */ -/* Seagate Barracuda ATA IV Family drives in UDMA mode 5 -* can overrun their FIFOs when used with the CSB5 */ - -static const char *csb_bad_ata100[] = { +/* +* Seagate Barracuda ATA IV Family drives in UDMA mode 5 +* can overrun their FIFOs when used with the CSB5. +*/ +static const char *const csb_bad_ata100[] = {"ST320011A" ,"ST340016A" ,"ST360021A" ,
@@ -163,10 +164,11 @@ static unsigned int serverworks_osb4_filter(struct ata_device *adev, unsigned in* @adev: ATA device * @mask: Mask of proposed modes * -* Check the blacklist and disable UDMA5 if matched +* Check the list of devices with broken UDMA5 and +* disable UDMA5 if matched. */ - -static unsigned int serverworks_csb_filter (struct ata_device *adev,unsigned int mask) +static unsigned int serverworks_csb_filter (struct ata_device *adev, +unsigned int mask) {const char *p;char model_num[ATA_ID_PROD_LEN +1 ];
Signature · 1 line
2.43.0
Re: [PATCH AUTOSEL 6.11 145/244] ata: pata_serverworks: Do not use the term blacklist
Quoted 10 lines · Sasha Levin
From: Damien Le Moal <[email protected]>
[ Upstream commit
858048568c9e3887d8b19e101ee72f129d65cb15]Let's not use the term blacklist in the function
serverworks_osb4_filter()documentation comment and rather simply refer to what that function looks at: the list of devices with groken UDMA5.While at it, also constify the values of the
csb_bad_ata100array.
Quoted 8 lines
Of note is that all of this should probably be handled using libata quirk mechanism but it is unclear if these UDMA5 quirks are specific to this controller only.
Signed-off-by Damien Le Moal <[email protected]>Reviewed-by Niklas Cassel <[email protected]>Reviewed-by Igor Pylypiv <[email protected]>Signed-off-by Sasha Levin <[email protected]>
[...]
Again, what does this fix? :-/
MBR, Sergey
Sasha Levin
maintainerPATCH 146/244 ata: sata_sil: Rename sil_blacklist to sil_quirks
In reply to Sasha LevinFrom: Damien Le Moal <[email protected]>
[ Upstream commit 93b0f9e11ce511353c65b7f924cf5f95bd9c3aba ]
Rename the array sil_blacklist to sil_quirks as this name is more neutral and is also consistent with how this driver define quirks with the SIL_QUIRK_XXX flags.
--- drivers/ata/sata_sil.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/ata/sata_sil.c +6 -6
@@ -128,7 +128,7 @@ static const struct pci_device_id sil_pci_tbl[] = {static const struct sil_drivelist {const char *product;unsigned int quirk; -} sil_blacklist [] = { +} sil_quirks[] = { {"ST320012AS" ,SIL_QUIRK_MOD15WRITE }, {"ST330013AS" ,SIL_QUIRK_MOD15WRITE }, {"ST340017AS" ,SIL_QUIRK_MOD15WRITE },
@@ -600,8 +600,8 @@ static void sil_thaw(struct ata_port *ap)* list, and apply the fixups to only the specific * devices/hosts/firmwares that need it. * -* 20040111 - Seagate drives affected by the Mod15Write bug are blacklisted -* The Maxtor quirk is in the blacklist, but I'm keeping the original +* 20040111 - Seagate drives affected by the Mod15Write bug are quirked +* The Maxtor quirk is in sil_quirks, but I'm keeping the original * pessimistic fix for the following reasons... * - There seems to be less info on it, only one device gleaned off the * Windows driver, maybe only one is affected. More info would be greatly
@@ -620,9 +620,9 @@ static void sil_dev_config(struct ata_device *dev)ata_id_c_string (dev->id, model_num,ATA_ID_PROD ,sizeof (model_num)); -for (n =0 ; sil_blacklist[n].product; n++) -if (!strcmp (sil_blacklist[n].product, model_num)) { - quirks = sil_blacklist[n].quirk; +for (n =0 ; sil_quirks[n].product; n++) +if (!strcmp (sil_quirks[n].product, model_num)) { + quirks = sil_quirks[n].quirk;break ; }
Signature · 1 line
2.43.0
Re: [PATCH AUTOSEL 6.11 146/244] ata: sata_sil: Rename sil_blacklist to sil_quirks
Quoted 4 lines · Sasha Levin
From: Damien Le Moal <[email protected]>
[ Upstream commit
93b0f9e11ce511353c65b7f924cf5f95bd9c3aba]
Quoted 8 lines
Rename the array
sil_blacklisttosil_quirksas this name is more neutral and is also consistent with how this driver define quirks with theSIL_QUIRK_XXXflags.Signed-off-by Damien Le Moal <[email protected]>Reviewed-by Niklas Cassel <[email protected]>Reviewed-by Igor Pylypiv <[email protected]>Signed-off-by Sasha Levin <[email protected]>
[...]
Are you serious? What does this fix?
MBR, Sergey
Sasha Levin
maintainerPATCH 147/244 selftests/bpf: fix uprobe.path leak in bpf_testmod
In reply to Sasha LevinFrom: Jiri Olsa <[email protected]>
[ Upstream commit db61e6a4eee5a7884b2cafeaf407895f253bbaa7 ]
testmod_unregister_uprobe() forgets to path_put(&uprobe.path).
--- tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c +1 -0
@@ -477,6 +477,7 @@ static void testmod_unregister_uprobe(void)if (uprobe.offset) {uprobe_unregister (d_real_inode (uprobe.path.dentry), uprobe.offset, &uprobe.consumer); +path_put (&uprobe.path); uprobe.offset =0 ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 148/244 scsi: smartpqi: Add new controller PCI IDs
In reply to Sasha LevinFrom: David Strahan <[email protected]>
[ Upstream commit 0e21e73384d324f75ea16f3d622cfc433fa6209b ]
All PCI ID entries in hex.
Add new inagile PCI IDs:
VID / DID / SVID / SDID
---- ---- ---- ----
SMART-HBA 8242-24i 9005 / 028f / 1ff9 / 0045
RAID 8236-16i 9005 / 028f / 1ff9 / 0046
RAID 8240-24i 9005 / 028f / 1ff9 / 0047
SMART-HBA 8238-16i 9005 / 028f / 1ff9 / 0048
PM8222-SHBA 9005 / 028f / 1ff9 / 004a
RAID PM8204-2GB 9005 / 028f / 1ff9 / 004b
RAID PM8204-4GB 9005 / 028f / 1ff9 / 004c
PM8222-HBA 9005 / 028f / 1ff9 / 004f
MT0804M6R 9005 / 028f / 1ff9 / 0051
MT0801M6E 9005 / 028f / 1ff9 / 0052
MT0808M6R 9005 / 028f / 1ff9 / 0053
MT0800M6H 9005 / 028f / 1ff9 / 0054
RS0800M5H24i 9005 / 028f / 1ff9 / 006b
RS0800M5E8i 9005 / 028f / 1ff9 / 006c
RS0800M5H8i 9005 / 028f / 1ff9 / 006d
RS0804M5R16i 9005 / 028f / 1ff9 / 006f
RS0800M5E24i 9005 / 028f / 1ff9 / 0070
RS0800M5H16i 9005 / 028f / 1ff9 / 0071
RS0800M5E16i 9005 / 028f / 1ff9 / 0072
RT0800M7E 9005 / 028f / 1ff9 / 0086
RT0800M7H 9005 / 028f / 1ff9 / 0087
RT0804M7R 9005 / 028f / 1ff9 / 0088
RT0808M7R 9005 / 028f / 1ff9 / 0089
RT1608M6R16i 9005 / 028f / 1ff9 / 00a1Add new h3c pci_id:
VID / DID / SVID / SDID
---- ---- ---- ----
UN RAID P4408-Mr-2 9005 / 028f / 193d / 1110Add new powerleader pci ids:
VID / DID / SVID / SDID
---- ---- ---- ----
PL SmartROC PM8204 9005 / 028f / 1f3a / 0104--- drivers/scsi/smartpqi/smartpqi_init.c | 104 ++++++++++++++++++++++++++ 1 file changed, 104 insertions(+)
drivers/scsi/smartpqi/smartpqi_init.c +104 -0
@@ -9472,6 +9472,10 @@ static const struct pci_device_id pqi_pci_id_table[] = {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,0x193d ,0x110b ) }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x193d ,0x1110 ) + }, {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,0x193d ,0x8460 )
@@ -9588,6 +9592,14 @@ static const struct pci_device_id pqi_pci_id_table[] = {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,0x1bd4 ,0x0089 ) }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x00a1 ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1f3a ,0x0104 ) + }, {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,0x19e5 ,0xd227 )
@@ -10180,6 +10192,98 @@ static const struct pci_device_id pqi_pci_id_table[] = {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,0x1137 ,0x02fa ) }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x0045 ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x0046 ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x0047 ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x0048 ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x004a ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x004b ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x004c ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x004f ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x0051 ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x0052 ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x0053 ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x0054 ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x006b ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x006c ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x006d ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x006f ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x0070 ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x0071 ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x0072 ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x0086 ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x0087 ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x0088 ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x0089 ) + }, {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,0x1e93 ,0x1000 )
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 149/244 HID: Ignore battery for all ELAN I2C-HID devices
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit bcc31692a1d1e21f0d06c5f727c03ee299d2264e ]
Before this change there were 16 vid:pid based quirks to ignore the battery reported by Elan I2C-HID touchscreens on various Asus and HP laptops.
And a report has been received that the 04F3:2A00 I2C touchscreen on the HP ProBook x360 11 G5 EE/86CF also reports a non present battery.
Since I2C-HID devices are always builtin to laptops they are not battery owered so it should be safe to just ignore the battery on all Elan I2C-HID devices, rather then adding a 17th quirk for the 04F3:2A00 touchscreen.
As reported in the changelog of commit a3a5a37efba1 ("HID: Ignore battery for ELAN touchscreens 2F2C and 4116"), which added 2 new Elan touchscreen quirks about a month ago, the HID reported battery seems to be related to a stylus being used. But even when a stylus is in use it does not properly report the charge of the stylus battery, instead the reported battery charge jumps from 0% to 1%. So it is best to just ignore the HID battery.
--- drivers/hid/hid-ids.h | 16 ---------------- drivers/hid/hid-input.c | 37 +++++-------------------------------- 2 files changed, 5 insertions(+), 48 deletions(-)
drivers/hid/hid-ids.h +0 -16
@@ -417,24 +417,8 @@#define USB_DEVICE_ID_TOSHIBA_CLICK_L9W 0x0401#define USB_DEVICE_ID_HP_X2 0x074d#define USB_DEVICE_ID_HP_X2_10_COVER 0x0755 -#define I2C_DEVICE_ID_HP_ENVY_X360_15 0x2d05 -#define I2C_DEVICE_ID_HP_ENVY_X360_15T_DR100 0x29CF -#define I2C_DEVICE_ID_HP_ENVY_X360_EU0009NV 0x2CF9 -#define I2C_DEVICE_ID_HP_SPECTRE_X360_15 0x2817 -#define I2C_DEVICE_ID_HP_SPECTRE_X360_13_AW0020NG 0x29DF -#define I2C_DEVICE_ID_ASUS_TP420IA_TOUCHSCREEN 0x2BC8 -#define I2C_DEVICE_ID_ASUS_GV301RA_TOUCHSCREEN 0x2C82 -#define I2C_DEVICE_ID_ASUS_UX3402_TOUCHSCREEN 0x2F2C -#define I2C_DEVICE_ID_ASUS_UX6404_TOUCHSCREEN 0x4116#define USB_DEVICE_ID_ASUS_UX550VE_TOUCHSCREEN 0x2544#define USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN 0x2706 -#define I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN 0x261A -#define I2C_DEVICE_ID_SURFACE_GO2_TOUCHSCREEN 0x2A1C -#define I2C_DEVICE_ID_LENOVO_YOGA_C630_TOUCHSCREEN 0x279F -#define I2C_DEVICE_ID_HP_SPECTRE_X360_13T_AW100 0x29F5 -#define I2C_DEVICE_ID_HP_SPECTRE_X360_14T_EA100_V1 0x2BED -#define I2C_DEVICE_ID_HP_SPECTRE_X360_14T_EA100_V2 0x2BEE -#define I2C_DEVICE_ID_HP_ENVY_X360_15_EU0556NG 0x2D02#define I2C_DEVICE_ID_CHROMEBOOK_TROGDOR_POMPOM 0x2F81#define USB_VENDOR_ID_ELECOM 0x056e
drivers/hid/hid-input.c +5 -32
@@ -373,14 +373,6 @@ static const struct hid_device_id hid_battery_quirks[] = { {HID_BLUETOOTH_DEVICE (USB_VENDOR_ID_LOGITECH ,USB_DEVICE_ID_LOGITECH_DINOVO_EDGE_KBD ), HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_ASUS_TP420IA_TOUCHSCREEN), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_ASUS_GV301RA_TOUCHSCREEN), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_ASUS_UX3402_TOUCHSCREEN), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_ASUS_UX6404_TOUCHSCREEN), - HID_BATTERY_QUIRK_IGNORE }, { HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN), HID_BATTERY_QUIRK_IGNORE }, { HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ASUS_UX550VE_TOUCHSCREEN),
@@ -391,32 +383,13 @@ static const struct hid_device_id hid_battery_quirks[] = { HID_BATTERY_QUIRK_AVOID_QUERY }, {HID_USB_DEVICE (USB_VENDOR_ID_UGEE ,USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_SW ), HID_BATTERY_QUIRK_AVOID_QUERY }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_15), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_15T_DR100), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_EU0009NV), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_SPECTRE_X360_15), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_SPECTRE_X360_13_AW0020NG), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO2_TOUCHSCREEN), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_LENOVO_YOGA_C630_TOUCHSCREEN), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_SPECTRE_X360_13T_AW100), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_SPECTRE_X360_14T_EA100_V1), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_SPECTRE_X360_14T_EA100_V2), - HID_BATTERY_QUIRK_IGNORE }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_15_EU0556NG), - HID_BATTERY_QUIRK_IGNORE }, { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_CHROMEBOOK_TROGDOR_POMPOM), HID_BATTERY_QUIRK_AVOID_QUERY }, +/* +* Elan I2C-HID touchscreens seem to all report a non present battery, +* set HID_BATTERY_QUIRK_IGNORE for all Elan I2C-HID devices. +*/ + { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_IGNORE }, {} };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 150/244 drm/amd/display: Underflow Seen on DCN401 eGPU
In reply to Sasha LevinFrom: Daniel Sa <[email protected]>
[ Upstream commit ca0fb243c3bb53dbbd71d16c76f319bf923ee3d4 ]
[WHY]
In dcn401 we read clock values before FW is loaded. These incorrect values cause the driver to believe that we are running higher clocks than what we actually have. This then causes corruption/underflow for the eGPU.
[HOW]
When new values are read from HW, update internal structures to propagate the new/correct value. Fixes issue
--- drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c +6 -2
@@ -221,6 +221,7 @@ void dcn401_init_hw(struct dc *dc)int edp_num;uint32_t backlight =MAX_BACKLIGHT_LEVEL ;uint32_t user_level =MAX_BACKLIGHT_LEVEL ; +int current_dchub_ref_freq =0 ;if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->init_clocks) { dc->clk_mgr->funcs->init_clocks (dc->clk_mgr);
@@ -264,6 +265,8 @@ void dcn401_init_hw(struct dc *dc) dc->ctx->dc_bios->fw_info.pll_info.crystal_frequency, &res_pool->ref_clocks.dccg_ref_clock_inKhz); + current_dchub_ref_freq = res_pool->ref_clocks.dchub_ref_clock_inKhz /1000 ; + (res_pool->hubbub->funcs->get_dchub_ref_freq)(res_pool->hubbub, res_pool->ref_clocks.dccg_ref_clock_inKhz, &res_pool->ref_clocks.dchub_ref_clock_inKhz);
@@ -436,8 +439,9 @@ void dcn401_init_hw(struct dc *dc) dc->caps.dmub_caps.mclk_sw = dc->ctx->dmub_srv->dmub->feature_caps.fw_assisted_mclk_switch_ver >0 ; dc->caps.dmub_caps.fams_ver = dc->ctx->dmub_srv->dmub->feature_caps.fw_assisted_mclk_switch_ver; dc->debug.fams2_config.bits.enable &= dc->ctx->dmub_srv->dmub->feature_caps.fw_assisted_mclk_switch_ver ==2 ; -if (!dc->debug.fams2_config.bits.enable && dc->res_pool->funcs->update_bw_bounding_box) { -/* update bounding box if FAMS2 disabled */ +if ((!dc->debug.fams2_config.bits.enable && dc->res_pool->funcs->update_bw_bounding_box) + || res_pool->ref_clocks.dchub_ref_clock_inKhz /1000 != current_dchub_ref_freq) { +/* update bounding box if FAMS2 disabled, or if dchub clk has changed */ if (dc->clk_mgr) dc->res_pool->funcs->update_bw_bounding_box (dc, dc->clk_mgr->bw_params);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 151/244 drm/amd/display: Handle null 'stream_status' in 'planes_changed_for_existing_stream'
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit 8141f21b941710ecebe49220b69822cab3abd23d ]
This commit adds a null check for 'stream_status' in the function 'planes_changed_for_existing_stream'. Previously, the code assumed 'stream_status' could be null, but did not handle the case where it was actually null. This could lead to a null pointer dereference.
Reported by smatch:drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_resource.c:3784 planes_changed_for_existing_stream() error: we previously assumed 'stream_status' could be null (see line 3774)
--- drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +3 -1
@@ -3771,8 +3771,10 @@ static bool planes_changed_for_existing_stream(struct dc_state *context, } } -if (!stream_status) +if (!stream_status) {ASSERT (0 ); +return false; + }for (i =0 ; i < set_count; i++)if (set[i].stream == stream)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 152/244 drm/amd/display: Add NULL check for function pointer in dcn20_set_output_transfer_func
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit 62ed6f0f198da04e884062264df308277628004f ]
This commit adds a null check for the set_output_gamma function pointer in the dcn20_set_output_transfer_func function. Previously, set_output_gamma was being checked for null at line 1030, but then it was being dereferenced without any null check at line 1048. This could potentially lead to a null pointer dereference error if set_output_gamma is null.
To fix this, we now ensure that set_output_gamma is not null before dereferencing it. We do this by adding a null check for set_output_gamma before the call to set_output_gamma at line 1048.
--- drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c +2 -1
@@ -1044,7 +1044,8 @@ bool dcn20_set_output_transfer_func(struct dc *dc, struct pipe_ctx *pipe_ctx,/* * if above if is not executed then 'params' equal to 0 and set in bypass */ - mpc->funcs->set_output_gamma (mpc, mpcc_id, params); +if (mpc->funcs->set_output_gamma) + mpc->funcs->set_output_gamma (mpc, mpcc_id, params);return true; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 153/244 drm/amd/display: Add NULL check for function pointer in dcn401_set_output_transfer_func
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit dd340acd42c24a3f28dd22fae6bf38662334264c ]
This commit adds a null check for the set_output_gamma function pointer in the dcn401_set_output_transfer_func function. Previously, set_output_gamma was being checked for null, but then it was being dereferenced without any null check. This could lead to a null pointer dereference if set_output_gamma is null.
To fix this, we now ensure that set_output_gamma is not null before dereferencing it. We do this by adding a null check for set_output_gamma before the call to set_output_gamma.
--- drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c +3 -1
@@ -748,7 +748,9 @@ bool dcn401_set_output_transfer_func(struct dc *dc, } } - mpc->funcs->set_output_gamma (mpc, mpcc_id, params); +if (mpc->funcs->set_output_gamma) + mpc->funcs->set_output_gamma (mpc, mpcc_id, params); +return ret; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 154/244 drm/amd/display: Add NULL check for function pointer in dcn32_set_output_transfer_func
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit 28574b08c70e56d34d6f6379326a860b96749051 ]
This commit adds a null check for the set_output_gamma function pointer in the dcn32_set_output_transfer_func function. Previously, set_output_gamma was being checked for null, but then it was being dereferenced without any null check. This could lead to a null pointer dereference if set_output_gamma is null.
To fix this, we now ensure that set_output_gamma is not null before dereferencing it. We do this by adding a null check for set_output_gamma before the call to set_output_gamma.
--- drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c +3 -1
@@ -582,7 +582,9 @@ bool dcn32_set_output_transfer_func(struct dc *dc, } } - mpc->funcs->set_output_gamma (mpc, mpcc_id, params); +if (mpc->funcs->set_output_gamma) + mpc->funcs->set_output_gamma (mpc, mpcc_id, params); +return ret; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 155/244 drm/amd/display: fix a UBSAN warning in DML2.1
In reply to Sasha LevinFrom: Aurabindo Pillai <[email protected]>
[ Upstream commit eaf3adb8faab611ba57594fa915893fc93a7788c ]
When programming phantom pipe, since cursor_width is explicity set to 0, this causes calculation logic to trigger overflow for an unsigned int triggering the kernel's UBSAN check as below:
[ 40.962845] UBSAN: shift-out-of-bounds in /tmp/amd.EfpumTkO/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_core/dml2_core_dcn4_calcs.c:3312:34 [ 40.962849] shift exponent 4294967170 is too large for 32-bit type 'unsigned int' [ 40.962852] CPU: 1 PID: 1670 Comm: gnome-shell Tainted: G W OE 6.5.0-41-generic #41~22.04.2-Ubuntu [ 40.962854] Hardware name: Gigabyte Technology Co., Ltd. X670E AORUS PRO X/X670E AORUS PRO X, BIOS F21 01/10/2024 [ 40.962856] Call Trace: [ 40.962857] <TASK> [ 40.962860] dump_stack_lvl+0x48/0x70 [ 40.962870] dump_stack+0x10/0x20 [ 40.962872] __ubsan_handle_shift_out_of_bounds+0x1ac/0x360 [ 40.962878] calculate_cursor_req_attributes.cold+0x1b/0x28 [amdgpu] [ 40.963099] dml_core_mode_support+0x6b91/0x16bc0 [amdgpu] [ 40.963327] ? srso_alias_return_thunk+0x5/0x7f [ 40.963331] ? CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport+0x18b8/0x2790 [amdgpu] [ 40.963534] ? srso_alias_return_thunk+0x5/0x7f [ 40.963536] ? dml_core_mode_support+0xb3db/0x16bc0 [amdgpu] [ 40.963730] dml2_core_calcs_mode_support_ex+0x2c/0x90 [amdgpu] [ 40.963906] ? srso_alias_return_thunk+0x5/0x7f [ 40.963909] ? dml2_core_calcs_mode_support_ex+0x2c/0x90 [amdgpu] [ 40.964078] core_dcn4_mode_support+0x72/0xbf0 [amdgpu] [ 40.964247] dml2_top_optimization_perform_optimization_phase+0x1d3/0x2a0 [amdgpu] [ 40.964420] dml2_build_mode_programming+0x23d/0x750 [amdgpu] [ 40.964587] dml21_validate+0x274/0x770 [amdgpu] [ 40.964761] ? srso_alias_return_thunk+0x5/0x7f [ 40.964763] ? resource_append_dpp_pipes_for_plane_composition+0x27c/0x3b0 [amdgpu] [ 40.964942] dml2_validate+0x504/0x750 [amdgpu] [ 40.965117] ? dml21_copy+0x95/0xb0 [amdgpu] [ 40.965291] ? srso_alias_return_thunk+0x5/0x7f [ 40.965295] dcn401_validate_bandwidth+0x4e/0x70 [amdgpu] [ 40.965491] update_planes_and_stream_state+0x38d/0x5c0 [amdgpu] [ 40.965672] update_planes_and_stream_v3+0x52/0x1e0 [amdgpu] [ 40.965845] ? srso_alias_return_thunk+0x5/0x7f [ 40.965849] dc_update_planes_and_stream+0x71/0xb0 [amdgpu]
Fix this by adding a guard for checking cursor width before triggering the size calculation.
--- .../src/dml2_core/dml2_core_dcn4_calcs.c | 93 ++++++++++--------- 1 file changed, 49 insertions(+), 44 deletions(-)
drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_core/dml2_core_dcn4_calcs.c +49 -44
@@ -7231,10 +7231,9 @@ static bool dml_core_mode_support(struct dml2_core_calcs_mode_support_ex *in_out/* Cursor Support Check */ mode_lib->ms.support.CursorSupport = true;for (k =0 ; k < mode_lib->ms.num_active_planes; k++) { -if (display_cfg->plane_descriptors[k].cursor.cursor_width >0.0 ) { -if (display_cfg->plane_descriptors[k].cursor.cursor_bpp ==64 && mode_lib->ip.cursor_64bpp_support == false) { +if (display_cfg->plane_descriptors[k].cursor.num_cursors >0 ) { +if (display_cfg->plane_descriptors[k].cursor.cursor_bpp ==64 && mode_lib->ip.cursor_64bpp_support == false) mode_lib->ms.support.CursorSupport = false; - } } }
@@ -8091,27 +8090,31 @@ static bool dml_core_mode_support(struct dml2_core_calcs_mode_support_ex *in_outfor (k =0 ; k < mode_lib->ms.num_active_planes; ++k) {double line_time_us = (double )display_cfg->stream_descriptors[display_cfg->plane_descriptors[k].stream_index].timing.h_total / ((double )display_cfg->stream_descriptors[display_cfg->plane_descriptors[k].stream_index].timing.pixel_clock_khz /1000 );bool cursor_not_enough_urgent_latency_hiding =0 ; -calculate_cursor_req_attributes ( - display_cfg->plane_descriptors[k].cursor.cursor_width, - display_cfg->plane_descriptors[k].cursor.cursor_bpp, -// output - &s->cursor_lines_per_chunk[k], - &s->cursor_bytes_per_line[k], - &s->cursor_bytes_per_chunk[k], - &s->cursor_bytes[k]); - -calculate_cursor_urgent_burst_factor ( - mode_lib->ip.cursor_buffer_size, - display_cfg->plane_descriptors[k].cursor.cursor_width, - s->cursor_bytes_per_chunk[k], - s->cursor_lines_per_chunk[k], - line_time_us, - mode_lib->ms.UrgLatency, +if (display_cfg->plane_descriptors[k].cursor.num_cursors >0 ) { +calculate_cursor_req_attributes ( + display_cfg->plane_descriptors[k].cursor.cursor_width, + display_cfg->plane_descriptors[k].cursor.cursor_bpp, + +// output + &s->cursor_lines_per_chunk[k], + &s->cursor_bytes_per_line[k], + &s->cursor_bytes_per_chunk[k], + &s->cursor_bytes[k]); + +calculate_cursor_urgent_burst_factor ( + mode_lib->ip.cursor_buffer_size, + display_cfg->plane_descriptors[k].cursor.cursor_width, + s->cursor_bytes_per_chunk[k], + s->cursor_lines_per_chunk[k], + line_time_us, + mode_lib->ms.UrgLatency, + +// output + &mode_lib->ms.UrgentBurstFactorCursor[k], + &cursor_not_enough_urgent_latency_hiding); + } -// output - &mode_lib->ms.UrgentBurstFactorCursor[k], - &cursor_not_enough_urgent_latency_hiding); mode_lib->ms.UrgentBurstFactorCursorPre[k] = mode_lib->ms.UrgentBurstFactorCursor[k];#ifdef __DML_VBA_DEBUG__
@@ -10592,31 +10595,33 @@ static bool dml_core_mode_programming(struct dml2_core_calcs_mode_programming_exfor (k =0 ; k < s->num_active_planes; ++k) {bool cursor_not_enough_urgent_latency_hiding =0 ; -double line_time_us; +double line_time_us =0.0 ; -calculate_cursor_req_attributes ( - display_cfg->plane_descriptors[k].cursor.cursor_width, - display_cfg->plane_descriptors[k].cursor.cursor_bpp, + line_time_us = display_cfg->stream_descriptors[display_cfg->plane_descriptors[k].stream_index].timing.h_total / + ((double )display_cfg->stream_descriptors[display_cfg->plane_descriptors[k].stream_index].timing.pixel_clock_khz /1000 ); +if (display_cfg->plane_descriptors[k].cursor.num_cursors >0 ) { +calculate_cursor_req_attributes ( + display_cfg->plane_descriptors[k].cursor.cursor_width, + display_cfg->plane_descriptors[k].cursor.cursor_bpp, -// output - &s->cursor_lines_per_chunk[k], - &s->cursor_bytes_per_line[k], - &s->cursor_bytes_per_chunk[k], - &s->cursor_bytes[k]); - - line_time_us = display_cfg->stream_descriptors[display_cfg->plane_descriptors[k].stream_index].timing.h_total / ((double )display_cfg->stream_descriptors[display_cfg->plane_descriptors[k].stream_index].timing.pixel_clock_khz /1000 ); - -calculate_cursor_urgent_burst_factor ( - mode_lib->ip.cursor_buffer_size, - display_cfg->plane_descriptors[k].cursor.cursor_width, - s->cursor_bytes_per_chunk[k], - s->cursor_lines_per_chunk[k], - line_time_us, - mode_lib->mp.UrgentLatency, +// output + &s->cursor_lines_per_chunk[k], + &s->cursor_bytes_per_line[k], + &s->cursor_bytes_per_chunk[k], + &s->cursor_bytes[k]); + +calculate_cursor_urgent_burst_factor ( + mode_lib->ip.cursor_buffer_size, + display_cfg->plane_descriptors[k].cursor.cursor_width, + s->cursor_bytes_per_chunk[k], + s->cursor_lines_per_chunk[k], + line_time_us, + mode_lib->mp.UrgentLatency, -// output - &mode_lib->mp.UrgentBurstFactorCursor[k], - &cursor_not_enough_urgent_latency_hiding); +// output + &mode_lib->mp.UrgentBurstFactorCursor[k], + &cursor_not_enough_urgent_latency_hiding); + } mode_lib->mp.UrgentBurstFactorCursorPre[k] = mode_lib->mp.UrgentBurstFactorCursor[k]; CalculateUrgentBurstFactor(
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 156/244 drm/amd/display: Add null check for 'afb' in amdgpu_dm_update_cursor (v2)
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit 0fe20258b4989b9112b5e9470df33a0939403fd4 ]
This commit adds a null check for the 'afb' variable in the amdgpu_dm_update_cursor function. Previously, 'afb' was assumed to be null at line 8388, but was used later in the code without a null check. This could potentially lead to a null pointer dereference.
Changes since v1:
- Moved the null check for 'afb' to the line where 'afb' is used. (Alex)
Fixes the below:drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:8433 amdgpu_dm_update_cursor()
error: we previously assumed 'afb' could be null (see line 8388)
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
@@ -8753,7 +8753,8 @@ static void amdgpu_dm_update_cursor(struct drm_plane *plane, adev->dm.dc->caps.color.dpp.gamma_corr) attributes.attribute_flags.bits.ENABLE_CURSOR_DEGAMMA =1 ; - attributes.pitch = afb->base.pitches[0 ] / afb->base.format->cpp[0 ]; +if (afb) + attributes.pitch = afb->base.pitches[0 ] / afb->base.format->cpp[0 ]; if (crtc_state->stream) { if (!dc_stream_set_cursor_attributes(crtc_state->stream,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 157/244 drm/amd/display: Check null pointers before using dc->clk_mgr
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 95d9e0803e51d5a24276b7643b244c7477daf463 ]
[WHY & HOW]dc->clk_mgr is null checked previously in the same function, indicating it might be null.
Passing "dc" to "dc->hwss.apply_idle_power_optimizations", which dereferences null "dc->clk_mgr". (The function pointer resolves to "dcn35_apply_idle_power_optimizations".)
This fixes 1 FORWARD_NULL issue reported by Coverity.
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +2 -1
@@ -5383,7 +5383,8 @@ void dc_allow_idle_optimizations_internal(struct dc *dc, bool allow, char constif (allow == dc->idle_optimizations_allowed)return ; -if (dc->hwss.apply_idle_power_optimizations && dc->hwss.apply_idle_power_optimizations (dc, allow)) +if (dc->hwss.apply_idle_power_optimizations && dc->clk_mgr !=NULL && + dc->hwss.apply_idle_power_optimizations (dc, allow)) dc->idle_optimizations_allowed = allow; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 158/244 drm/amd/display: Check null pointer before try to access it
In reply to Sasha LevinFrom: Rodrigo Siqueira <[email protected]>
[ Upstream commit 1b686053c06ffb9f4524b288110cf2a831ff7a25 ]
[why & how]
Change the order of the pipe_ctx->plane_state check to ensure that plane_state is not null before accessing it.
--- .../gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c +8 -3
@@ -1931,6 +1931,11 @@ static void dcn20_program_pipe( (pipe_ctx->plane_state && pipe_ctx->plane_state->update_flags.bits.hdr_mult)) hws->funcs.set_hdr_multiplier(pipe_ctx); +if ((pipe_ctx->plane_state && pipe_ctx->plane_state->update_flags.bits.hdr_mult) || + pipe_ctx->update_flags.bits.enable) + hws->funcs.set_hdr_multiplier (pipe_ctx); + +if (hws->funcs.populate_mcm_luts) {if (pipe_ctx->plane_state) { hws->funcs.populate_mcm_luts(dc, pipe_ctx, pipe_ctx->plane_state->mcm_luts,
@@ -1938,13 +1943,13 @@ static void dcn20_program_pipe( pipe_ctx->plane_state->lut_bank_a = !pipe_ctx->plane_state->lut_bank_a; } } -if (pipe_ctx->update_flags.bits.enable || - (pipe_ctx->plane_state && +if ((pipe_ctx->plane_state && pipe_ctx->plane_state->update_flags.bits.in_transfer_func_change) || (pipe_ctx->plane_state && pipe_ctx->plane_state->update_flags.bits.gamma_change) || (pipe_ctx->plane_state && - pipe_ctx->plane_state->update_flags.bits.lut_3d)) + pipe_ctx->plane_state->update_flags.bits.lut_3d) || + pipe_ctx->update_flags.bits.enable) hws->funcs.set_input_transfer_func (dc, pipe_ctx, pipe_ctx->plane_state);/* dcn10_translate_regamma_to_hw_format takes 750us to finish
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 159/244 drm/amd/display: Add null check for 'afb' in amdgpu_dm_plane_handle_cursor_update (v2)
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit cd9e9e0852d501f169aa3bb34e4b413d2eb48c37 ]
This commit adds a null check for the 'afb' variable in the amdgpu_dm_plane_handle_cursor_update function. Previously, 'afb' was assumed to be null, but was used later in the code without a null check. This could potentially lead to a null pointer dereference.
Changes since v1:
- Moved the null check for 'afb' to the line where 'afb' is used. (Alex)
Fixes the below:drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_plane.c:1298 amdgpu_dm_plane_handle_cursor_update() error: we previously assumed 'afb' could be null (see line 1252)
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +2 -1
@@ -1377,7 +1377,8 @@ void amdgpu_dm_plane_handle_cursor_update(struct drm_plane *plane, adev->dm.dc->caps.color.dpp.gamma_corr) attributes.attribute_flags.bits.ENABLE_CURSOR_DEGAMMA =1 ; - attributes.pitch = afb->base.pitches[0 ] / afb->base.format->cpp[0 ]; +if (afb) + attributes.pitch = afb->base.pitches[0 ] / afb->base.format->cpp[0 ];if (crtc_state->stream) {mutex_lock (&adev->dm.dc_lock);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 160/244 drm/xe: Name and document Wa_14019789679
In reply to Sasha LevinFrom: Matt Roper <[email protected]>
[ Upstream commit 1d734a3e5d6bb266f52eaf2b1400c5d3f1875a54 ]
Early in the development of Xe we identified an issue with SVG state handling on DG2 and MTL (and later on Xe2 as well). In commit 72ac304769dd ("drm/xe: Emit SVG state on RCS during driver load on DG2 and MTL") and commit fb24b858a20d ("drm/xe/xe2: Update SVG state handling") we implemented our own workaround to prevent SVG state from leaking from context A to context B in cases where context B never issues a specific state setting.
The hardware teams have now created official workaround Wa_14019789679 to cover this issue. The workaround description only requires emitting 3DSTATE_MESH_CONTROL, since they believe that's the only SVG instruction that would potentially remain unset by a context B, but still cause notable issues if unwanted values were inherited from context A. However since we already have a more extensive implementation that emits the entire SVG state and prevents _any_ SVG state from unintentionally leaking, we'll stick with our existing implementation just to be safe.
--- drivers/gpu/drm/xe/xe_lrc.c | 35 +++++++++++++++++++++--------- drivers/gpu/drm/xe/xe_wa_oob.rules | 2 ++ 2 files changed, 27 insertions(+), 10 deletions(-)
drivers/gpu/drm/xe/xe_lrc.c +25 -10
@@ -5,6 +5,8 @@#include "xe_lrc.h" +#include <generated/xe_wa_oob.h> +#include <linux/ascii85.h> #include "instructions/xe_mi_commands.h"
@@ -24,6 +26,7 @@#include "xe_memirq.h" #include "xe_sriov.h" #include "xe_vm.h" +#include "xe_wa.h" #define LRC_VALID BIT_ULL(0)#define LRC_PRIVILEGE BIT_ULL(8)
@@ -1581,19 +1584,31 @@ void xe_lrc_emit_hwe_state_instructions(struct xe_exec_queue *q, struct xe_bb *bint state_table_size =0 ;/* -* At the moment we only need to emit non-register state for the RCS -* engine. +* Wa_14019789679 +* +* If the driver doesn't explicitly emit the SVG instructions while +* setting up the default LRC, the context switch will write 0's +* (noops) into the LRC memory rather than the expected instruction +* headers. Application contexts start out as a copy of the default +* LRC, and if they also do not emit specific settings for some SVG +* state, then on context restore they'll unintentionally inherit +* whatever state setting the previous context had programmed into the +* hardware (i.e., the lack of a 3DSTATE_* instruction in the LRC will +* prevent the hardware from resetting that state back to any specific +* value). +* +* The official workaround only requires emitting 3DSTATE_MESH_CONTROL +* since that's a specific state setting that can easily cause GPU +* hangs if unintentionally inherited. However to be safe we'll +* continue to emit all of the SVG state since it's best not to leak +* any of the state between contexts, even if that leakage is harmless. */ -if (q->hwe->class !=XE_ENGINE_CLASS_RENDER ) -return ; - -switch (GRAPHICS_VERx100 (xe)) { -case 1255 : - case 1270 ... 2004: +if (XE_WA (gt,14019789679 ) && q->hwe->class ==XE_ENGINE_CLASS_RENDER ) { state_table = xe_hpg_svg_state; state_table_size =ARRAY_SIZE (xe_hpg_svg_state); -break ; -default : + } + +if (!state_table) {xe_gt_dbg (gt,"No non-register state to emit on graphics ver %d.%02d\n" ,GRAPHICS_VER (xe),GRAPHICS_VERx100 (xe) %100 );return ;
drivers/gpu/drm/xe/xe_wa_oob.rules +2 -0
@@ -30,3 +30,5 @@ 22019338487 MEDIA_VERSION(2000) GRAPHICS_VERSION(2001) 16023588340 GRAPHICS_VERSION(2001) +14019789679 GRAPHICS_VERSION(1255) + GRAPHICS_VERSION_RANGE(1270, 2004)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 161/244 drm/amd/display: fix double free issue during amdgpu module unload
In reply to Sasha LevinFrom: Tim Huang <[email protected]>
[ Upstream commit 20b5a8f9f4670a8503aa9fa95ca632e77c6bf55d ]
Flexible endpoints use DIGs from available inflexible endpoints, so only the encoders of inflexible links need to be freed. Otherwise, a double free issue may occur when unloading the amdgpu module.
[ 279.190523] RIP: 0010:__slab_free+0x152/0x2f0 [ 279.190577] Call Trace: [ 279.190580] <TASK> [ 279.190582] ? show_regs+0x69/0x80 [ 279.190590] ? die+0x3b/0x90 [ 279.190595] ? do_trap+0xc8/0xe0 [ 279.190601] ? do_error_trap+0x73/0xa0 [ 279.190605] ? __slab_free+0x152/0x2f0 [ 279.190609] ? exc_invalid_op+0x56/0x70 [ 279.190616] ? __slab_free+0x152/0x2f0 [ 279.190642] ? asm_exc_invalid_op+0x1f/0x30 [ 279.190648] ? dcn10_link_encoder_destroy+0x19/0x30 [amdgpu] [ 279.191096] ? __slab_free+0x152/0x2f0 [ 279.191102] ? dcn10_link_encoder_destroy+0x19/0x30 [amdgpu] [ 279.191469] kfree+0x260/0x2b0 [ 279.191474] dcn10_link_encoder_destroy+0x19/0x30 [amdgpu] [ 279.191821] link_destroy+0xd7/0x130 [amdgpu] [ 279.192248] dc_destruct+0x90/0x270 [amdgpu] [ 279.192666] dc_destroy+0x19/0x40 [amdgpu] [ 279.193020] amdgpu_dm_fini+0x16e/0x200 [amdgpu] [ 279.193432] dm_hw_fini+0x26/0x40 [amdgpu] [ 279.193795] amdgpu_device_fini_hw+0x24c/0x400 [amdgpu] [ 279.194108] amdgpu_driver_unload_kms+0x4f/0x70 [amdgpu] [ 279.194436] amdgpu_pci_remove+0x40/0x80 [amdgpu] [ 279.194632] pci_device_remove+0x3a/0xa0 [ 279.194638] device_remove+0x40/0x70 [ 279.194642] device_release_driver_internal+0x1ad/0x210 [ 279.194647] driver_detach+0x4e/0xa0 [ 279.194650] bus_remove_driver+0x6f/0xf0 [ 279.194653] driver_unregister+0x33/0x60 [ 279.194657] pci_unregister_driver+0x44/0x90 [ 279.194662] amdgpu_exit+0x19/0x1f0 [amdgpu] [ 279.194939] __do_sys_delete_module.isra.0+0x198/0x2f0 [ 279.194946] __x64_sys_delete_module+0x16/0x20 [ 279.194950] do_syscall_64+0x58/0x120 [ 279.194954] entry_SYSCALL_64_after_hwframe+0x6e/0x76 [ 279.194980] </TASK>
--- drivers/gpu/drm/amd/display/dc/link/link_factory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/link/link_factory.c +1 -1
@@ -385,7 +385,7 @@ static void link_destruct(struct dc_link *link)if (link->panel_cntl) link->panel_cntl->funcs->destroy (&link->panel_cntl); -if (link->link_enc) { +if (link->link_enc && !link->is_dig_mapping_flexible) {/* Update link encoder resource tracking variables. These are used for * the dynamic assignment of link encoders to streams. Virtual links * are not assigned encoder resources on creation.
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 162/244 drm/amdgpu: add list empty check to avoid null pointer issue
In reply to Sasha LevinFrom: Yang Wang <[email protected]>
[ Upstream commit 4416377ae1fdc41a90b665943152ccd7ff61d3c5 ]
Add list empty check to avoid null pointer issues in some corner cases.
- list_for_each_entry_safe()
--- drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c +10 -0
@@ -80,6 +80,9 @@ static void aca_banks_release(struct aca_banks *banks) {struct aca_bank_node *node, *tmp; +if (list_empty (&banks->list)) +return ; +list_for_each_entry_safe (node, tmp, &banks->list, node) {list_del (&node->node);kvfree (node);
@@ -562,9 +565,13 @@ static void aca_error_fini(struct aca_error *aerr)struct aca_bank_error *bank_error, *tmp;mutex_lock (&aerr->lock); +if (list_empty (&aerr->list)) + goto out_unlock; +list_for_each_entry_safe (bank_error, tmp, &aerr->list, node)aca_bank_error_remove (aerr, bank_error); +out_unlock:mutex_destroy (&aerr->lock); }
@@ -680,6 +687,9 @@ static void aca_manager_fini(struct aca_handle_manager *mgr) {struct aca_handle *handle, *tmp; +if (list_empty (&mgr->list)) +return ; +list_for_each_entry_safe (handle, tmp, &mgr->list, node)amdgpu_aca_remove_handle (handle); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 163/244 jfs: UBSAN: shift-out-of-bounds in dbFindBits
In reply to Sasha LevinFrom: Remington Brasga <[email protected]>
[ Upstream commit b0b2fc815e514221f01384f39fbfbff65d897e1c ]
Fix issue with UBSAN throwing shift-out-of-bounds warning.
--- fs/jfs/jfs_dmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jfs/jfs_dmap.c +1 -1
@@ -3022,7 +3022,7 @@ static int dbFindBits(u32 word, int l2nb)/* scan the word for nb free bits at nb alignments. */ -for (bitno =0 ; mask !=0 ; bitno += nb, mask >>= nb) { +for (bitno =0 ; mask !=0 ; bitno += nb, mask = (mask >> nb)) {if ((mask & word) == mask)break ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 164/244 jfs: Fix uaf in dbFreeBits
In reply to Sasha LevinFrom: Edward Adam Davis <[email protected]>
[ Upstream commit d6c1b3599b2feb5c7291f5ac3a36e5fa7cedb234 ]
[syzbot reported]
==================================================================
BUG: KASAN: slab-use-after-free in __mutex_lock_common kernel/locking/mutex.c:587 [inline] BUG: KASAN: slab-use-after-free in __mutex_lock+0xfe/0xd70 kernel/locking/mutex.c:752 Read of size 8 at addr ffff8880229254b0 by task syz-executor357/5216 CPU: 0 UID: 0 PID: 5216 Comm: syz-executor357 Not tainted 6.11.0-rc3-syzkaller-00156-gd7a5aa4b3c00 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024 Call Trace: <TASK> __dump_stack lib/dump_stack.c:93 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119 print_address_description mm/kasan/report.c:377 [inline] print_report+0x169/0x550 mm/kasan/report.c:488 kasan_report+0x143/0x180 mm/kasan/report.c:601 __mutex_lock_common kernel/locking/mutex.c:587 [inline] __mutex_lock+0xfe/0xd70 kernel/locking/mutex.c:752 dbFreeBits+0x7ea/0xd90 fs/jfs/jfs_dmap.c:2390 dbFreeDmap fs/jfs/jfs_dmap.c:2089 [inline] dbFree+0x35b/0x680 fs/jfs/jfs_dmap.c:409 dbDiscardAG+0x8a9/0xa20 fs/jfs/jfs_dmap.c:1650 jfs_ioc_trim+0x433/0x670 fs/jfs/jfs_discard.c:100 jfs_ioctl+0x2d0/0x3e0 fs/jfs/ioctl.c:131 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:893 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 Freed by task 5218: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579 poison_slab_object+0xe0/0x150 mm/kasan/common.c:240 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2252 [inline] slab_free mm/slub.c:4473 [inline] kfree+0x149/0x360 mm/slub.c:4594 dbUnmount+0x11d/0x190 fs/jfs/jfs_dmap.c:278 jfs_mount_rw+0x4ac/0x6a0 fs/jfs/jfs_mount.c:247 jfs_remount+0x3d1/0x6b0 fs/jfs/super.c:454 reconfigure_super+0x445/0x880 fs/super.c:1083 vfs_cmd_reconfigure fs/fsopen.c:263 [inline] vfs_fsconfig_locked fs/fsopen.c:292 [inline] __do_sys_fsconfig fs/fsopen.c:473 [inline] __se_sys_fsconfig+0xb6e/0xf80 fs/fsopen.c:345 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f
[Analysis]
There are two paths (dbUnmount and jfs_ioc_trim) that generate race condition when accessing bmap, which leads to the occurrence of uaf.
Use the lock s_umount to synchronize them, in order to avoid uaf caused by race condition.
--- fs/jfs/jfs_discard.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/jfs/jfs_discard.c +9 -2
@@ -65,7 +65,7 @@ void jfs_issue_discard(struct inode *ip, u64 blkno, u64 nblocks)int jfs_ioc_trim (struct inode *ip,struct fstrim_range *range) {struct inode *ipbmap =JFS_SBI (ip->i_sb)->ipbmap; -struct bmap *bmp =JFS_SBI (ip->i_sb)->bmap; +struct bmap *bmp;struct super_block *sb = ipbmap->i_sb;int agno, agno_end;u64 start, end, minlen;
@@ -83,10 +83,15 @@ int jfs_ioc_trim(struct inode *ip, struct fstrim_range *range)if (minlen ==0 ) minlen =1 ; +down_read (&sb->s_umount); + bmp =JFS_SBI (ip->i_sb)->bmap; +if (minlen > bmp->db_agsize || start >= bmp->db_mapsize || - range->len < sb->s_blocksize) + range->len < sb->s_blocksize) { +up_read (&sb->s_umount);return -EINVAL ; + }if (end >= bmp->db_mapsize) end = bmp->db_mapsize -1 ;
@@ -100,6 +105,8 @@ int jfs_ioc_trim(struct inode *ip, struct fstrim_range *range) trimmed +=dbDiscardAG (ip, agno, minlen); agno++; } + +up_read (&sb->s_umount); range->len = trimmed << sb->s_blocksize_bits;return 0 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 165/244 jfs: check if leafidx greater than num leaves per dmap tree
In reply to Sasha LevinFrom: Edward Adam Davis <[email protected]>
[ Upstream commit d64ff0d2306713ff084d4b09f84ed1a8c75ecc32 ]
syzbot report a out of bounds in dbSplit, it because dmt_leafidx greater than num leaves per dmap tree, add a checking for dmt_leafidx in dbFindLeaf.
Shaggy:
Modified sanity check to apply to control pages as well as leaf pages.
--- fs/jfs/jfs_dmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/jfs/jfs_dmap.c +4 -1
@@ -2944,9 +2944,10 @@ static void dbAdjTree(dmtree_t *tp, int leafno, int newval, bool is_ctl)static int dbFindLeaf (dmtree_t *tp,int l2nb,int *leafidx,bool is_ctl) {int ti, n =0 , k, x =0 ; -int max_size; +int max_size, max_idx; max_size = is_ctl ?CTLTREESIZE :TREESIZE ; + max_idx = is_ctl ?LPERCTL :LPERDMAP ;/* first check the root of the tree to see if there is * sufficient free space.
@@ -2978,6 +2979,8 @@ static int dbFindLeaf(dmtree_t *tp, int l2nb, int *leafidx, bool is_ctl)*/ assert (n <4 ); } +if (le32_to_cpu (tp->dmt_leafidx) >= max_idx) +return -ENOSPC ;/* set the return to the leftmost leaf describing sufficient * free space.
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 166/244 scsi: smartpqi: correct stream detection
In reply to Sasha LevinFrom: Mahesh Rajashekhara <[email protected]>
[ Upstream commit 4c76114932d1d6fad2e72823e7898a3c960cf2a7 ]
Correct stream detection by initializing the structure pqi_scsi_dev_raid_map_data to 0s.
When the OS issues SCSI READ commands, the driver erroneously considers them as SCSI WRITES. If they are identified as sequential IOs, the driver then submits those requests via the RAID path instead of the AIO path.
The 'is_write' flag might be set for SCSI READ commands also. The driver may interpret SCSI READ commands as SCSI WRITE commands, resulting in IOs being submitted through the RAID path.
Note: This does not cause data corruption.
--- drivers/scsi/smartpqi/smartpqi_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/smartpqi/smartpqi_init.c +1 -1
@@ -5933,7 +5933,7 @@ static bool pqi_is_parity_write_stream(struct pqi_ctrl_info *ctrl_info,int rc;struct pqi_scsi_dev *device;struct pqi_stream_data *pqi_stream_data; -struct pqi_scsi_dev_raid_map_data rmd; +struct pqi_scsi_dev_raid_map_data rmd = {0 };if (!ctrl_info->enable_stream_detection)return false;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 167/244 scsi: smartpqi: add new controller PCI IDs
In reply to Sasha LevinFrom: David Strahan <[email protected]>
[ Upstream commit dbc39b84540f746cc814e69b21e53e6d3e12329a ]
All PCI ID entries in Hex.
Add new cisco pci ids:
VID / DID / SVID / SDID
---- ---- ---- ----
9005 028f 1137 02fe
9005 028f 1137 02ff
9005 028f 1137 0300Add new h3c pci ids:
VID / DID / SVID / SDID
---- ---- ---- ----
9005 028f 193d 0462
9005 028f 193d 8462Add new ieit pci ids:
VID / DID / SVID / SDID
---- ---- ---- ----
9005 028f 1ff9 00a3--- drivers/scsi/smartpqi/smartpqi_init.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/scsi/smartpqi/smartpqi_init.c +24 -0
@@ -9444,6 +9444,10 @@ static const struct pci_device_id pqi_pci_id_table[] = {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,0x152d ,0x8a37 ) }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x193d ,0x0462 ) + }, {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,0x193d ,0x1104 )
@@ -9484,6 +9488,10 @@ static const struct pci_device_id pqi_pci_id_table[] = {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,0x193d ,0x8461 ) }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x193d ,0x8462 ) + }, {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,0x193d ,0xc460 )
@@ -10192,6 +10200,18 @@ static const struct pci_device_id pqi_pci_id_table[] = {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,0x1137 ,0x02fa ) }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1137 ,0x02fe ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1137 ,0x02ff ) + }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1137 ,0x0300 ) + }, {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,0x1ff9 ,0x0045 )
@@ -10368,6 +10388,10 @@ static const struct pci_device_id pqi_pci_id_table[] = {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,0x1f51 ,0x1045 ) }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x1ff9 ,0x00a3 ) + }, {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,PCI_ANY_ID ,PCI_ANY_ID )
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 168/244 drm/msm/adreno: Assign msm_gpu->pdev earlier to avoid nullptrs
In reply to Sasha LevinFrom: Konrad Dybcio <[email protected]>
[ Upstream commit 16007768551d5bfe53426645401435ca8d2ef54f ]
There are some cases, such as the one uncovered by Commit 46d4efcccc68 ("drm/msm/a6xx: Avoid a nullptr dereference when speedbin setting fails") where
msm_gpu_cleanup() : platform_set_drvdata(gpu->pdev, NULL);
is called on gpu->pdev == NULL, as the GPU device has not been fully initialized yet.
Turns out that there's more than just the aforementioned path that causes this to happen (e.g. the case when there's speedbin data in the catalog, but opp-supported-hw is missing in DT).
Assigning msm_gpu->pdev earlier seems like the least painful solution to this, therefore do so.
Patchwork: https://patchwork.freedesktop.org/patch/602742/
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 1 + drivers/gpu/drm/msm/msm_gpu.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +1 -0
@@ -1083,6 +1083,7 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, adreno_gpu->chip_id = config->chip_id; gpu->allow_relocs = config->info->family <ADRENO_6XX_GEN1 ; + gpu->pdev = pdev;/* Only handle the core clock when GMU is not in use (or is absent). */ if (adreno_has_gmu_wrapper(adreno_gpu) ||
drivers/gpu/drm/msm/msm_gpu.c +0 -1
@@ -931,7 +931,6 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,if (IS_ERR (gpu->gpu_cx)) gpu->gpu_cx =NULL ; - gpu->pdev = pdev;platform_set_drvdata (pdev, &gpu->adreno_smmu);msm_devfreq_init (gpu);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 169/244 jfs: Fix uninit-value access of new_ea in ea_buffer
In reply to Sasha LevinFrom: Zhao Mengmeng <[email protected]>
[ Upstream commit 2b59ffad47db1c46af25ccad157bb3b25147c35c ]
syzbot reports that lzo1x_1_do_compress is using uninit-value:
=====================================================
BUG: KMSAN: uninit-value in lzo1x_1_do_compress+0x19f9/0x2510 lib/lzo/lzo1x_compress.c:178
...
Uninit was stored to memory at:
ea_put fs/jfs/xattr.c:639 [inline]
...
Local variable ea_buf created at:
__jfs_setxattr+0x5d/0x1ae0 fs/jfs/xattr.c:662 __jfs_xattr_set+0xe6/0x1f0 fs/jfs/xattr.c:934
=====================================================
The reason is ea_buf->new_ea is not initialized properly.
Fix this by using memset to empty its content at the beginning in ea_get().
--- fs/jfs/xattr.c | 2 ++ 1 file changed, 2 insertions(+)
fs/jfs/xattr.c +2 -0
@@ -434,6 +434,8 @@ static int ea_get(struct inode *inode, struct ea_buffer *ea_buf, int min_size)int rc;int quota_allocation =0 ; +memset (&ea_buf->new_ea,0 ,sizeof (ea_buf->new_ea)); +/* When fsck.jfs clears a bad ea, it doesn't clear the size */ if (ji->ea.flag ==0 ) ea_size =0 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 170/244 drm/amdgpu: add raven1 gfxoff quirk
In reply to Sasha LevinFrom: Peng Liu <[email protected]>
[ Upstream commit 0126c0ae11e8b52ecfde9d1b174ee2f32d6c3a5d ]
Fix screen corruption with openkylin.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -0
@@ -1301,6 +1301,8 @@ static const struct amdgpu_gfxoff_quirk amdgpu_gfxoff_quirk_list[] = { { 0x1002, 0x15dd, 0x1002, 0x15dd, 0xc6 },/* Apple MacBook Pro (15-inch, 2019) Radeon Pro Vega 20 4 GB */ { 0x1002, 0x69af, 0x106b, 0x019a, 0xc0 }, +/* https://bbs.openkylin.top/t/topic/171497 */ + { 0x1002, 0x15d8, 0x19e5, 0x3e14, 0xc2 }, { 0, 0, 0, 0, 0 }, };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 171/244 drm/amdgpu: enable gfxoff quirk on HP 705G4
In reply to Sasha LevinFrom: Peng Liu <[email protected]>
[ Upstream commit 2c7795e245d993bcba2f716a8c93a5891ef910c9 ]
Enabling gfxoff quirk results in perfectly usable graphical user interface on HP 705G4 DM with R5 2400G.
Without the quirk, X server is completely unusable as every few seconds there is gpu reset due to ring gfx timeout.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -0
@@ -1303,6 +1303,8 @@ static const struct amdgpu_gfxoff_quirk amdgpu_gfxoff_quirk_list[] = { { 0x1002, 0x69af, 0x106b, 0x019a, 0xc0 },/* https://bbs.openkylin.top/t/topic/171497 */ { 0x1002, 0x15d8, 0x19e5, 0x3e14, 0xc2 }, +/* HP 705G4 DM with R5 2400G */ + { 0x1002, 0x15dd, 0x103c, 0x8464, 0xd6 }, { 0, 0, 0, 0, 0 }, };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 172/244 drm/amdkfd: Fix resource leak in criu restore queue
In reply to Sasha LevinFrom: Jesse Zhang <[email protected]>
[ Upstream commit aa47fe8d3595365a935921a90d00bc33ee374728 ]
To avoid memory leaks, release q_extra_data when exiting the restore queue.
v2: Correct the proto (Alex)
--- drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +1 -0
@@ -988,6 +988,7 @@ int kfd_criu_restore_queue(struct kfd_process *p,pr_debug ("Queue id %d was restored successfully\n" , queue_id);kfree (q_data); +kfree (q_extra_data);return ret; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 173/244 HID: multitouch: Add support for Thinkpad X12 Gen 2 Kbd Portfolio
In reply to Sasha LevinFrom: Vishnu Sankar <[email protected]>
[ Upstream commit 65b72ea91a257a5f0cb5a26b01194d3dd4b85298 ]
This applies similar quirks used by previous generation device, so that Trackpoint and buttons on the touchpad works. New USB KBD PID 0x61AE for Thinkpad X12 Tab is added.
--- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-multitouch.c | 6 ++++++ 2 files changed, 7 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -794,6 +794,7 @@#define USB_DEVICE_ID_LENOVO_X1_TAB 0x60a3#define USB_DEVICE_ID_LENOVO_X1_TAB3 0x60b5#define USB_DEVICE_ID_LENOVO_X12_TAB 0x60fe +#define USB_DEVICE_ID_LENOVO_X12_TAB2 0x61ae#define USB_DEVICE_ID_LENOVO_OPTICAL_USB_MOUSE_600E 0x600e#define USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_608D 0x608d#define USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_6019 0x6019
drivers/hid/hid-multitouch.c +6 -0
@@ -2113,6 +2113,12 @@ static const struct hid_device_id mt_devices[] = { USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_X12_TAB) }, +/* Lenovo X12 TAB Gen 2 */ + { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT_NSMU, +HID_DEVICE (BUS_USB ,HID_GROUP_MULTITOUCH_WIN_8 , +USB_VENDOR_ID_LENOVO , + USB_DEVICE_ID_LENOVO_X12_TAB2) }, + /* Logitech devices */ { .driver_data = MT_CLS_NSMU, HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_MULTITOUCH_WIN_8,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 174/244 platform/x86: touchscreen_dmi: add nanote-next quirk
In reply to Sasha LevinFrom: Ckath <[email protected]>
[ Upstream commit c11619af35bae5884029bd14170c3e4b55ddf6f3 ]
Add touschscreen info for the nanote next (UMPC-03-SR).
After checking with multiple owners the DMI info really is this generic.
--- drivers/platform/x86/touchscreen_dmi.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
drivers/platform/x86/touchscreen_dmi.c +26 -0
@@ -840,6 +840,21 @@ static const struct ts_dmi_data rwc_nanote_p8_data = { .properties = rwc_nanote_p8_props, }; +static const struct property_entry rwc_nanote_next_props[] = { +PROPERTY_ENTRY_U32 ("touchscreen-min-x" ,5 ), +PROPERTY_ENTRY_U32 ("touchscreen-min-y" ,5 ), +PROPERTY_ENTRY_U32 ("touchscreen-size-x" ,1785 ), +PROPERTY_ENTRY_U32 ("touchscreen-size-y" ,1145 ), +PROPERTY_ENTRY_BOOL ("touchscreen-inverted-y" ), +PROPERTY_ENTRY_STRING ("firmware-name" ,"gsl1680-rwc-nanote-next.fw" ), + { } +}; + +static const struct ts_dmi_data rwc_nanote_next_data = { + .acpi_name ="MSSL1680:00" , + .properties = rwc_nanote_next_props, +}; +static const struct property_entry schneider_sct101ctm_props[] = {PROPERTY_ENTRY_U32 ("touchscreen-size-x" ,1715 ),PROPERTY_ENTRY_U32 ("touchscreen-size-y" ,1140 ),
@@ -1589,6 +1604,17 @@ const struct dmi_system_id touchscreen_dmi_table[] = {DMI_MATCH (DMI_PRODUCT_SKU ,"0001" ) }, }, + { +/* RWC NANOTE NEXT */ + .driver_data = (void *)&rwc_nanote_next_data, + .matches = { +DMI_MATCH (DMI_PRODUCT_NAME ,"To be filled by O.E.M." ), +DMI_MATCH (DMI_BOARD_NAME ,"To be filled by O.E.M." ), +DMI_MATCH (DMI_BOARD_VENDOR ,"To be filled by O.E.M." ), +/* Above matches are too generic, add bios-version match */ + DMI_MATCH(DMI_BIOS_VERSION, "S8A70R100-V005"), + }, + }, {/* Schneider SCT101CTM */ .driver_data = (void *)&schneider_sct101ctm_data,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 175/244 platform/x86/amd: pmf: Add quirk for TUF Gaming A14
In reply to Sasha LevinFrom: aln8 <[email protected]>
[ Upstream commit 06369503d644068abd9e90918c6611274d94c126 ]
The ASUS TUF Gaming A14 has the same issue as the ROG Zephyrus G14 where it advertises SPS support but doesn't use it.
--- drivers/platform/x86/amd/pmf/pmf-quirks.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/platform/x86/amd/pmf/pmf-quirks.c +8 -0
@@ -37,6 +37,14 @@ static const struct dmi_system_id fwbug_list[] = { }, .driver_data = &quirk_no_sps_bug, }, + { + .ident = "ASUS TUF Gaming A14", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "FA401W"), + }, + .driver_data = &quirk_no_sps_bug, + }, {} };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 176/244 drm/xe: Add timeout to preempt fences
In reply to Sasha LevinFrom: Matthew Brost <[email protected]>
[ Upstream commit 627c961d672d3304564455ba471f5e4405170eec ]
To adhere to dma fencing rules that fences must signal within a reasonable amount of time, add a 5 second timeout to preempt fences. If this timeout occurs, kill the associated VM as this fatal to the VM.
v2:
- Add comment for smp_wmb (Checkpatch)
- Fix kernel doc typo (Inspection)
- Add comment for killed check (Niranjana)
v3:
- Drop smp_wmb (Matthew Auld)
- Don't take vm->lock in preempt fence worker (Matthew Auld)
- Drop RB given changes to patch
v4:
- Add WRITE/READ_ONCE (Niranjana)
- Don't export xe_vm_kill (Niranjana)
--- drivers/gpu/drm/xe/xe_exec_queue_types.h | 6 ++-- drivers/gpu/drm/xe/xe_execlist.c | 3 +- drivers/gpu/drm/xe/xe_guc_submit.c | 39 ++++++++++++++++++++---- drivers/gpu/drm/xe/xe_preempt_fence.c | 12 ++++++-- drivers/gpu/drm/xe/xe_vm.c | 12 +++++++- 5 files changed, 59 insertions(+), 13 deletions(-)
drivers/gpu/drm/xe/xe_exec_queue_types.h +4 -2
@@ -169,9 +169,11 @@ struct xe_exec_queue_ops {int (*suspend)(struct xe_exec_queue *q);/** * @suspend_wait: Wait for an exec queue to suspend executing, should be -* call after suspend. +* call after suspend. In dma-fencing path thus must return within a +* reasonable amount of time. -ETIME return shall indicate an error +* waiting for suspend resulting in associated VM getting killed. */ -void (*suspend_wait)(struct xe_exec_queue *q); +int (*suspend_wait)(struct xe_exec_queue *q);/** * @resume: Resume exec queue execution, exec queue must be in a suspended * state and dma fence returned from most recent suspend call must be
drivers/gpu/drm/xe/xe_execlist.c +2 -1
@@ -422,10 +422,11 @@ static int execlist_exec_queue_suspend(struct xe_exec_queue *q)return 0 ; } -static void execlist_exec_queue_suspend_wait (struct xe_exec_queue *q) +static int execlist_exec_queue_suspend_wait (struct xe_exec_queue *q) {/* NIY */ +return 0 ; }static void execlist_exec_queue_resume (struct xe_exec_queue *q)
drivers/gpu/drm/xe/xe_guc_submit.c +33 -6
@@ -1312,6 +1312,15 @@ static void __guc_exec_queue_process_msg_set_sched_props(struct xe_sched_msg *mskfree (msg); } +static void __suspend_fence_signal (struct xe_exec_queue *q) +{ +if (!q->guc->suspend_pending) +return ; + +WRITE_ONCE (q->guc->suspend_pending, false); +wake_up (&q->guc->suspend_wait); +} +static void suspend_fence_signal (struct xe_exec_queue *q) {struct xe_guc *guc =exec_queue_to_guc (q);
@@ -1321,9 +1330,7 @@ static void suspend_fence_signal(struct xe_exec_queue *q) guc_read_stopped(guc));xe_assert (xe, q->guc->suspend_pending); - q->guc->suspend_pending = false; -smp_wmb (); -wake_up (&q->guc->suspend_wait); +__suspend_fence_signal (q); }static void __guc_exec_queue_process_msg_suspend (struct xe_sched_msg *msg)
@@ -1480,6 +1487,7 @@ static void guc_exec_queue_kill(struct xe_exec_queue *q) {trace_xe_exec_queue_kill (q);set_exec_queue_killed (q); +__suspend_fence_signal (q);xe_guc_exec_queue_trigger_cleanup (q); }
@@ -1578,12 +1586,31 @@ static int guc_exec_queue_suspend(struct xe_exec_queue *q)return 0 ; } -static void guc_exec_queue_suspend_wait (struct xe_exec_queue *q) +static int guc_exec_queue_suspend_wait (struct xe_exec_queue *q) {struct xe_guc *guc =exec_queue_to_guc (q); +int ret; + +/* +* Likely don't need to check exec_queue_killed() as we clear +* suspend_pending upon kill but to be paranoid but races in which +* suspend_pending is set after kill also check kill here. +*/ + ret =wait_event_timeout (q->guc->suspend_wait, + !READ_ONCE (q->guc->suspend_pending) || +exec_queue_killed (q) || +guc_read_stopped (guc), +HZ *5 ); -wait_event (q->guc->suspend_wait, !q->guc->suspend_pending || -guc_read_stopped (guc)); +if (!ret) { +xe_gt_warn (guc_to_gt (guc), +"Suspend fence, guc_id=%d, failed to respond" , + q->guc->id); +/* XXX: Trigger GT reset? */ +return -ETIME ; + } + +return 0 ; }static void guc_exec_queue_resume (struct xe_exec_queue *q)
drivers/gpu/drm/xe/xe_preempt_fence.c +9 -3
@@ -17,10 +17,16 @@ static void preempt_fence_work_func(struct work_struct *w)container_of (w,typeof (*pfence), preempt_work);struct xe_exec_queue *q = pfence->q; -if (pfence->error) +if (pfence->error) {dma_fence_set_error (&pfence->base, pfence->error); -else - q->ops->suspend_wait (q); + }else if (!q->ops->reset_status (q)) { +int err = q->ops->suspend_wait (q); + +if (err) +dma_fence_set_error (&pfence->base, err); + }else { +dma_fence_set_error (&pfence->base, -ENOENT ); + }dma_fence_signal (&pfence->base);/*
drivers/gpu/drm/xe/xe_vm.c +11 -1
@@ -133,8 +133,10 @@ static int wait_for_existing_preempt_fences(struct xe_vm *vm)if (q->lr.pfence) {long timeout =dma_fence_wait (q->lr.pfence, false); -if (timeout <0 ) +/* Only -ETIME on fence indicates VM needs to be killed */ +if (timeout <0 || q->lr.pfence->error == -ETIME )return -ETIME ; +dma_fence_put (q->lr.pfence); q->lr.pfence =NULL ; }
@@ -311,6 +313,14 @@ int __xe_vm_userptr_needs_repin(struct xe_vm *vm)#define XE_VM_REBIND_RETRY_TIMEOUT_MS 1000 +/* +* xe_vm_kill() - VM Kill +* @vm: The VM. +* @unlocked: Flag indicates the VM's dma-resv is not held +* +* Kill the VM by setting banned flag indicated VM is no longer available for +* use. If in preempt fence mode, also kill all exec queue attached to the VM. +*/ static void xe_vm_kill (struct xe_vm *vm,bool unlocked) {struct xe_exec_queue *q;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 177/244 drm/xe/fbdev: Limit the usage of stolen for LNL+
In reply to Sasha LevinFrom: Uma Shankar <[email protected]>
[ Upstream commit 775d0adc01a55fe0458139330415d86bb3533efe ]
As per recommendation in the workarounds:WA_22019338487
There is an issue with accessing Stolen memory pages due a hardware limitation. Limit the usage of stolen memory for fbdev for LNL+. Don't use BIOS FB from stolen on LNL+ and assign the same from system memory.
v2: Corrected the WA Number, limited WA to LNL and
Adopted XE_WA framework as suggested by Lucas and Matt.
v3: Introduced the waxxx_display to implement display side
of WA changes on Lunarlake. Used xe_root_mmio_gt and avoid the for loop (Suggested by Lucas)
v4: Fixed some nits (Luca)
--- drivers/gpu/drm/xe/display/intel_fbdev_fb.c | 6 +++++- drivers/gpu/drm/xe/display/xe_plane_initial.c | 6 ++++++ drivers/gpu/drm/xe/xe_wa_oob.rules | 1 + 3 files changed, 12 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/display/intel_fbdev_fb.c +5 -1
@@ -10,6 +10,9 @@#include "xe_bo.h" #include "xe_gt.h" #include "xe_ttm_stolen_mgr.h" +#include "xe_wa.h" + +#include <generated/xe_wa_oob.h> struct intel_framebuffer *intel_fbdev_fb_alloc (struct drm_fb_helper *helper,struct drm_fb_helper_surface_size *sizes)
@@ -37,7 +40,7 @@ struct intel_framebuffer *intel_fbdev_fb_alloc(struct drm_fb_helper *helper, size =PAGE_ALIGN (size); obj =ERR_PTR (-ENODEV ); -if (!IS_DGFX (xe)) { + if (!IS_DGFX(xe) && !XE_WA(xe_root_mmio_gt(xe), 22019338487_display)) { obj = xe_bo_create_pin_map(xe, xe_device_get_root_tile(xe), NULL, size, ttm_bo_type_kernel, XE_BO_FLAG_SCANOUT |
@@ -48,6 +51,7 @@ struct intel_framebuffer *intel_fbdev_fb_alloc(struct drm_fb_helper *helper,else drm_info (&xe->drm,"Allocated fbdev into stolen failed: %li\n" ,PTR_ERR (obj)); } +if (IS_ERR (obj)) { obj = xe_bo_create_pin_map(xe, xe_device_get_root_tile(xe), NULL, size, ttm_bo_type_kernel, XE_BO_FLAG_SCANOUT |
drivers/gpu/drm/xe/display/xe_plane_initial.c +6 -0
@@ -18,6 +18,9 @@#include "intel_frontbuffer.h" #include "intel_plane_initial.h" #include "xe_bo.h" +#include "xe_wa.h" + +#include <generated/xe_wa_oob.h> static bool intel_reuse_initial_plane_obj(struct intel_crtc *this,
@@ -104,6 +107,9 @@ initial_plane_bo(struct xe_device *xe, phys_base = base; flags |=XE_BO_FLAG_STOLEN ; + if (XE_WA(xe_root_mmio_gt(xe), 22019338487_display)) +return NULL ; +/* * If the FB is too big, just don't use it since fbdev is not very * important and we should probably use that space with FBC or other
drivers/gpu/drm/xe/xe_wa_oob.rules +1 -0
@@ -29,6 +29,7 @@ 13011645652 GRAPHICS_VERSION(2004) 22019338487 MEDIA_VERSION(2000) GRAPHICS_VERSION(2001) +22019338487_display PLATFORM(LUNARLAKE) 16023588340 GRAPHICS_VERSION(2001) 14019789679 GRAPHICS_VERSION(1255) GRAPHICS_VERSION_RANGE(1270, 2004)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 178/244 drm/stm: ltdc: reset plane transparency after plane disable
In reply to Sasha LevinFrom: Yannick Fertre <[email protected]>
[ Upstream commit 02fa62d41c8abff945bae5bfc3ddcf4721496aca ]
The plane's opacity should be reseted while the plane is disabled. It prevents from seeing a possible global or layer background color set earlier.
--- drivers/gpu/drm/stm/ltdc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/stm/ltdc.c +3 -0
@@ -1513,6 +1513,9 @@ static void ltdc_plane_atomic_disable(struct drm_plane *plane,/* Disable layer */ regmap_write_bits (ldev->regmap,LTDC_L1CR + lofs,LXCR_LEN |LXCR_CLUTEN |LXCR_HMEN ,0 ); +/* Reset the layer transparency to hide any related background color */ +regmap_write_bits (ldev->regmap,LTDC_L1CACR + lofs,LXCACR_CONSTA ,0x00 ); +/* Commit shadow registers = update plane at next vblank */ if (ldev->caps.plane_reg_shadow) regmap_write_bits(ldev->regmap, LTDC_L1RCR + lofs,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 179/244 drm/amd/display: Initialize denominators' default to 1
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit b995c0a6de6c74656a0c39cd57a0626351b13e3c ]
[WHAT & HOW]
Variables used as denominators and maybe not assigned to other values, should not be 0. Change their default to 1 so they are never 0.
This fixes 10 DIVIDE_BY_ZERO issues reported by Coverity.
--- .../gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c | 2 +- drivers/gpu/drm/amd/display/dc/dml/dml1_display_rq_dlg_calc.c | 2 +- .../display/dc/dml2/dml21/src/dml2_core/dml2_core_shared.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c +1 -1
@@ -78,7 +78,7 @@ static void calculate_ttu_cursor(struct display_mode_lib *mode_lib,static unsigned int get_bytes_per_element (enum source_format_class source_format,bool is_chroma) { -unsigned int ret_val =0 ; +unsigned int ret_val =1 ;if (source_format == dm_444_16) {if (!is_chroma)
drivers/gpu/drm/amd/display/dc/dml/dml1_display_rq_dlg_calc.c +1 -1
@@ -39,7 +39,7 @@static unsigned int get_bytes_per_element (enum source_format_class source_format,bool is_chroma) { -unsigned int ret_val =0 ; +unsigned int ret_val =1 ;if (source_format == dm_444_16) {if (!is_chroma)
drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_core/dml2_core_shared.c +2 -2
@@ -9386,8 +9386,8 @@ static void CalculateVMGroupAndRequestTimes(double TimePerVMRequestVBlank[], double TimePerVMRequestFlip[]) { - unsigned int num_group_per_lower_vm_stage = 0; -unsigned int num_req_per_lower_vm_stage =0 ; + unsigned int num_group_per_lower_vm_stage = 1; +unsigned int num_req_per_lower_vm_stage =1 ;#ifdef __DML_VBA_DEBUG__dml2_printf ("DML::%s: NumberOfActiveSurfaces = %u\n" , __func__, NumberOfActiveSurfaces);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 180/244 drm/amd/display: Check null-initialized variables
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 367cd9ceba1933b63bc1d87d967baf6d9fd241d2 ]
[WHAT & HOW]drr_timing and subvp_pipe are initialized to null and they are not always assigned new values. It is necessary to check for null before dereferencing.
This fixes 2 FORWARD_NULL issues reported by Coverity.
--- drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c +4 -3
@@ -871,8 +871,9 @@ static bool subvp_drr_schedulable(struct dc *dc, struct dc_state *context)* for VBLANK: (VACTIVE region of the SubVP pipe can fit the MALL prefetch, VBLANK frame time, * and the max of (VBLANK blanking time, MALL region)). */ -if (stretched_drr_us < (1 / (double )drr_timing->min_refresh_in_uhz) *1000000 *1000000 && - subvp_active_us - prefetch_us - stretched_drr_us - max_vblank_mallregion >0 ) +if (drr_timing && + stretched_drr_us < (1 / (double )drr_timing->min_refresh_in_uhz) *1000000 *1000000 && + subvp_active_us - prefetch_us - stretched_drr_us - max_vblank_mallregion >0 ) schedulable = true;return schedulable;
@@ -937,7 +938,7 @@ static bool subvp_vblank_schedulable(struct dc *dc, struct dc_state *context)if (!subvp_pipe && pipe_mall_type ==SUBVP_MAIN ) subvp_pipe = pipe; } -if (found) { +if (found && subvp_pipe) { phantom_stream =dc_state_get_paired_subvp_stream (context, subvp_pipe->stream); main_timing = &subvp_pipe->stream->timing; phantom_timing = &phantom_stream->timing;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 181/244 drm/amd/display: Check phantom_stream before it is used
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 3718a619a8c0a53152e76bb6769b6c414e1e83f4 ]
dcn32_enable_phantom_stream can return null, so returned value must be checked before used.
This fixes 1 NULL_RETURNS issue reported by Coverity.
--- drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c +3 -0
@@ -1720,6 +1720,9 @@ void dcn32_add_phantom_pipes(struct dc *dc, struct dc_state *context,// be a valid candidate for SubVP (i.e. has a plane, stream, doesn't // already have phantom pipe assigned, etc.) by previous checks. phantom_stream =dcn32_enable_phantom_stream (dc, context, pipes, pipe_cnt, index); +if (!phantom_stream) +return ; +dcn32_enable_phantom_plane (dc, context, phantom_stream, index);for (i =0 ; i < dc->res_pool->pipe_count; i++) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 182/244 drm/amd/display: Check stream before comparing them
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 35ff747c86767937ee1e0ca987545b7eed7a0810 ]
[WHAT & HOW]amdgpu_dm can pass a null stream to dc_is_stream_unchanged. It is necessary to check for null before dereferencing them.
This fixes 1 FORWARD_NULL issue reported by Coverity.
--- drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +2 -0
@@ -3241,6 +3241,8 @@ static bool are_stream_backends_same(bool dc_is_stream_unchanged (struct dc_stream_state *old_stream,struct dc_stream_state *stream) { +if (!old_stream || !stream) +return false;if (!are_stream_backends_same (old_stream, stream))return false;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 183/244 drm/amd/display: Deallocate DML memory if allocation fails
In reply to Sasha LevinFrom: Chris Park <[email protected]>
[ Upstream commit 892abca6877a96c9123bb1c010cafccdf8ca1b75 ]
[Why]
When DC state create DML memory allocation fails, memory is not deallocated subsequently, resulting in uninitialized structure that is not NULL.
[How]
Deallocate memory if DML memory allocation fails.
--- drivers/gpu/drm/amd/display/dc/core/dc_state.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_state.c +8 -2
@@ -211,10 +211,16 @@ struct dc_state *dc_state_create(struct dc *dc, struct dc_state_create_params *p#ifdef CONFIG_DRM_AMD_DC_FP if (dc->debug.using_dml2) { dml2_opt->use_clock_dc_limits = false; -dml2_create (dc, dml2_opt, &state->bw_ctx.dml2); +if (!dml2_create (dc, dml2_opt, &state->bw_ctx.dml2)) { +dc_state_release (state); +return NULL ; + } dml2_opt->use_clock_dc_limits = true; -dml2_create (dc, dml2_opt, &state->bw_ctx.dml2_dc_power_source); +if (!dml2_create (dc, dml2_opt, &state->bw_ctx.dml2_dc_power_source)) { +dc_state_release (state); +return NULL ; + } }#endif
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 184/244 drm/amd/display: Check link_res->hpo_dp_link_enc before using it
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 0beca868cde8742240cd0038141c30482d2b7eb8 ]
[WHAT & HOW]
Functions dp_enable_link_phy and dp_disable_link_phy can pass link_res without initializing hpo_dp_link_enc and it is necessary to check for null before dereferencing.
This fixes 2 FORWARD_NULL issues reported by Coverity.
--- .../gpu/drm/amd/display/dc/link/hwss/link_hwss_hpo_dp.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_hpo_dp.c +7 -0
@@ -28,6 +28,8 @@#include "dccg.h" #include "clk_mgr.h" +#define DC_LOGGER link->ctx->logger +void set_hpo_dp_throttled_vcp_size (struct pipe_ctx *pipe_ctx,struct fixed31_32 throttled_vcp_size) {
@@ -124,6 +126,11 @@ void disable_hpo_dp_link_output(struct dc_link *link,const struct link_resource *link_res, enum signal_type signal) { + if (!link_res->hpo_dp_link_enc) { + DC_LOG_ERROR("%s: invalid hpo_dp_link_enc\n", __func__); +return ; + } + link_res->hpo_dp_link_enc->funcs->link_disable (link_res->hpo_dp_link_enc); link_res->hpo_dp_link_enc->funcs->disable_link_phy ( link_res->hpo_dp_link_enc, signal);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 185/244 drm/amd/display: Increase array size of dummy_boolean
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 6d64d39486197083497a01b39e23f2f8474b35d3 ]
[WHY]dml2_core_shared_mode_support and dml_core_mode_support access the third element of dummy_boolean, i.e. hw_debug5 = &s->dummy_boolean[2], when dummy_boolean has size of 2. Any assignment to hw_debug5 causes an OVERRUN.
[HOW]
Increase dummy_boolean's array size to 3.
This fixes 2 OVERRUN issues reported by Coverity.
--- .../dc/dml2/dml21/src/dml2_core/dml2_core_shared_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_core/dml2_core_shared_types.h +1 -1
@@ -865,7 +865,7 @@ struct dml2_core_calcs_mode_support_locals {unsigned int dpte_row_bytes_per_row_l[DML2_MAX_PLANES ];unsigned int dpte_row_bytes_per_row_c[DML2_MAX_PLANES ]; -bool dummy_boolean[2 ]; +bool dummy_boolean[3 ];unsigned int dummy_integer[3 ];unsigned int dummy_integer_array[36 ][DML2_MAX_PLANES ];enum dml2_odm_mode dummy_odm_mode[DML2_MAX_PLANES ];
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 186/244 drm/amd/display: Fix index out of bounds in DCN30 degamma hardware format translation
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit bc50b614d59990747dd5aeced9ec22f9258991ff ]
This commit addresses a potential index out of bounds issue in the cm3_helper_translate_curve_to_degamma_hw_format function in the DCN30 color management module. The issue could occur when the index 'i' exceeds the number of transfer function points (TRANSFER_FUNC_POINTS).
The fix adds a check to ensure 'i' is within bounds before accessing the transfer function points. If 'i' is out of bounds, the function returns false to indicate an error.
Reported by smatch:drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_cm_common.c:338 cm3_helper_translate_curve_to_degamma_hw_format() error: buffer overflow 'output_tf->tf_pts.red' 1025 <= s32max drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_cm_common.c:339 cm3_helper_translate_curve_to_degamma_hw_format() error: buffer overflow 'output_tf->tf_pts.green' 1025 <= s32max drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_cm_common.c:340 cm3_helper_translate_curve_to_degamma_hw_format() error: buffer overflow 'output_tf->tf_pts.blue' 1025 <= s32max
--- drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c +2 -0
@@ -335,6 +335,8 @@ bool cm3_helper_translate_curve_to_degamma_hw_format( i += increment) {if (j == hw_points -1 )break ; +if (i >=TRANSFER_FUNC_POINTS ) +return false; rgb_resulted[j].red = output_tf->tf_pts.red[i]; rgb_resulted[j].green = output_tf->tf_pts.green[i]; rgb_resulted[j].blue = output_tf->tf_pts.blue[i];
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 187/244 drm/amd/display: Fix index out of bounds in degamma hardware format translation
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit b7e99058eb2e86aabd7a10761e76cae33d22b49f ]
Fixes index out of bounds issue in cm_helper_translate_curve_to_degamma_hw_format function. The issue could occur when the index 'i' exceeds the number of transfer function points (TRANSFER_FUNC_POINTS).
The fix adds a check to ensure 'i' is within bounds before accessing the transfer function points. If 'i' is out of bounds the function returns false to indicate an error.
Reported by smatch:drivers/gpu/drm/amd/amdgpu/../display/dc/dcn10/dcn10_cm_common.c:594 cm_helper_translate_curve_to_degamma_hw_format() error: buffer overflow 'output_tf->tf_pts.red' 1025 <= s32max drivers/gpu/drm/amd/amdgpu/../display/dc/dcn10/dcn10_cm_common.c:595 cm_helper_translate_curve_to_degamma_hw_format() error: buffer overflow 'output_tf->tf_pts.green' 1025 <= s32max drivers/gpu/drm/amd/amdgpu/../display/dc/dcn10/dcn10_cm_common.c:596 cm_helper_translate_curve_to_degamma_hw_format() error: buffer overflow 'output_tf->tf_pts.blue' 1025 <= s32max
--- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.c +2 -0
@@ -591,6 +591,8 @@ bool cm_helper_translate_curve_to_degamma_hw_format( i += increment) {if (j == hw_points -1 )break ; +if (i >=TRANSFER_FUNC_POINTS ) +return false; rgb_resulted[j].red = output_tf->tf_pts.red[i]; rgb_resulted[j].green = output_tf->tf_pts.green[i]; rgb_resulted[j].blue = output_tf->tf_pts.blue[i];
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 188/244 drm/amd/display: Implement bounds check for stream encoder creation in DCN401
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit bdf606810210e8e07a0cdf1af3c467291363b295 ]
'stream_enc_regs' array is an array of dcn10_stream_enc_registers structures. The array is initialized with four elements, corresponding to the four calls to stream_enc_regs() in the array initializer. This means that valid indices for this array are 0, 1, 2, and 3.
The error message 'stream_enc_regs' 4 <= 5 below, is indicating that there is an attempt to access this array with an index of 5, which is out of bounds. This could lead to undefined behavior
Here, eng_id is used as an index to access the stream_enc_regs array. If eng_id is 5, this would result in an out-of-bounds access on the stream_enc_regs array.
Thus fixing Buffer overflow error in dcn401_stream_encoder_create
Found by smatch:drivers/gpu/drm/amd/amdgpu/../display/dc/resource/dcn401/dcn401_resource.c:1209 dcn401_stream_encoder_create() error: buffer overflow 'stream_enc_regs' 4 <= 5
--- .../gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c +1 -1
@@ -1188,7 +1188,7 @@ static struct stream_encoder *dcn401_stream_encoder_create( vpg =dcn401_vpg_create (ctx, vpg_inst); afmt =dcn401_afmt_create (ctx, afmt_inst); -if (!enc1 || !vpg || !afmt) { +if (!enc1 || !vpg || !afmt || eng_id >=ARRAY_SIZE (stream_enc_regs)) {kfree (enc1);kfree (vpg);kfree (afmt);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 189/244 drm/amd/display: Fix index out of bounds in DCN30 color transformation
In reply to Sasha LevinFrom: Srinivasan Shanmugam <[email protected]>
[ Upstream commit d81873f9e715b72d4f8d391c8eb243946f784dfc ]
This commit addresses a potential index out of bounds issue in the cm3_helper_translate_curve_to_hw_format function in the DCN30 color management module. The issue could occur when the index 'i' exceeds the number of transfer function points (TRANSFER_FUNC_POINTS).
The fix adds a check to ensure 'i' is within bounds before accessing the transfer function points. If 'i' is out of bounds, the function returns false to indicate an error.
drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_cm_common.c:180 cm3_helper_translate_curve_to_hw_format() error: buffer overflow 'output_tf->tf_pts.red' 1025 <= s32max drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_cm_common.c:181 cm3_helper_translate_curve_to_hw_format() error: buffer overflow 'output_tf->tf_pts.green' 1025 <= s32max drivers/gpu/drm/amd/amdgpu/../display/dc/dcn30/dcn30_cm_common.c:182 cm3_helper_translate_curve_to_hw_format() error: buffer overflow 'output_tf->tf_pts.blue' 1025 <= s32max
--- drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c +2 -0
@@ -177,6 +177,8 @@ bool cm3_helper_translate_curve_to_hw_format( i += increment) {if (j == hw_points)break ; +if (i >=TRANSFER_FUNC_POINTS ) +return false; rgb_resulted[j].red = output_tf->tf_pts.red[i]; rgb_resulted[j].green = output_tf->tf_pts.green[i]; rgb_resulted[j].blue = output_tf->tf_pts.blue[i];
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 190/244 drm/amdgpu/gfx12: properly handle error ints on all pipes
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit 39879321769cc2d9a690725959ef76af92a38ac1 ]
Need to handle the interrupt enables for all pipes.
v2: fix indexing (Jessie)
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 130 ++++++++++++++++++++----- 1 file changed, 106 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +106 -24
@@ -1686,26 +1686,68 @@ static void gfx_v12_0_constants_init(struct amdgpu_device *adev)gfx_v12_0_init_compute_vmid (adev); } +static u32 gfx_v12_0_get_cpg_int_cntl (struct amdgpu_device *adev, +int me,int pipe) +{ +if (me !=0 ) +return 0 ; + +switch (pipe) { +case 0 : +return SOC15_REG_OFFSET (GC ,0 , regCP_INT_CNTL_RING0); +default : +return 0 ; + } +} + +static u32 gfx_v12_0_get_cpc_int_cntl (struct amdgpu_device *adev, +int me,int pipe) +{ +/* +* amdgpu controls only the first MEC. That's why this function only +* handles the setting of interrupts for this specific MEC. All other +* pipes' interrupts are set by amdkfd. +*/ +if (me !=1 ) +return 0 ; + +switch (pipe) { +case 0 : +return SOC15_REG_OFFSET (GC ,0 , regCP_ME1_PIPE0_INT_CNTL); +case 1 : +return SOC15_REG_OFFSET (GC ,0 , regCP_ME1_PIPE1_INT_CNTL); +default : +return 0 ; + } +} +static void gfx_v12_0_enable_gui_idle_interrupt (struct amdgpu_device *adev, -bool enable) +bool enable) { -u32 tmp; +u32 tmp, cp_int_cntl_reg; +int i, j;if (amdgpu_sriov_vf (adev))return ; - tmp =RREG32_SOC15 (GC ,0 , regCP_INT_CNTL_RING0); - - tmp =REG_SET_FIELD (tmp,CP_INT_CNTL_RING0 ,CNTX_BUSY_INT_ENABLE , - enable ?1 :0 ); - tmp =REG_SET_FIELD (tmp,CP_INT_CNTL_RING0 ,CNTX_EMPTY_INT_ENABLE , - enable ?1 :0 ); - tmp =REG_SET_FIELD (tmp,CP_INT_CNTL_RING0 ,CMP_BUSY_INT_ENABLE , - enable ?1 :0 ); - tmp =REG_SET_FIELD (tmp,CP_INT_CNTL_RING0 ,GFX_IDLE_INT_ENABLE , - enable ?1 :0 ); - -WREG32_SOC15 (GC ,0 , regCP_INT_CNTL_RING0, tmp); +for (i =0 ; i < adev->gfx.me.num_me; i++) { +for (j =0 ; j < adev->gfx.me.num_pipe_per_me; j++) { + cp_int_cntl_reg =gfx_v12_0_get_cpg_int_cntl (adev, i, j); + +if (cp_int_cntl_reg) { + tmp =RREG32_SOC15_IP (GC , cp_int_cntl_reg); + tmp =REG_SET_FIELD (tmp,CP_INT_CNTL_RING0 ,CNTX_BUSY_INT_ENABLE , + enable ?1 :0 ); + tmp =REG_SET_FIELD (tmp,CP_INT_CNTL_RING0 ,CNTX_EMPTY_INT_ENABLE , + enable ?1 :0 ); + tmp =REG_SET_FIELD (tmp,CP_INT_CNTL_RING0 ,CMP_BUSY_INT_ENABLE , + enable ?1 :0 ); + tmp =REG_SET_FIELD (tmp,CP_INT_CNTL_RING0 ,GFX_IDLE_INT_ENABLE , + enable ?1 :0 ); +WREG32_SOC15_IP (GC , cp_int_cntl_reg, tmp); + } + } + } }static int gfx_v12_0_init_csb (struct amdgpu_device *adev)
@@ -4747,15 +4789,42 @@ static int gfx_v12_0_eop_irq(struct amdgpu_device *adev,static int gfx_v12_0_set_priv_reg_fault_state (struct amdgpu_device *adev,struct amdgpu_irq_src *source, -unsigned type, +unsigned int type,enum amdgpu_interrupt_state state) { +u32 cp_int_cntl_reg, cp_int_cntl; +int i, j; +switch (state) {case AMDGPU_IRQ_STATE_DISABLE :case AMDGPU_IRQ_STATE_ENABLE : -WREG32_FIELD15_PREREG (GC ,0 ,CP_INT_CNTL_RING0 , -PRIV_REG_INT_ENABLE , - state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +for (i =0 ; i < adev->gfx.me.num_me; i++) { +for (j =0 ; j < adev->gfx.me.num_pipe_per_me; j++) { + cp_int_cntl_reg =gfx_v12_0_get_cpg_int_cntl (adev, i, j); + +if (cp_int_cntl_reg) { + cp_int_cntl =RREG32_SOC15_IP (GC , cp_int_cntl_reg); + cp_int_cntl =REG_SET_FIELD (cp_int_cntl,CP_INT_CNTL_RING0 , +PRIV_REG_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +WREG32_SOC15_IP (GC , cp_int_cntl_reg, cp_int_cntl); + } + } + } +for (i =0 ; i < adev->gfx.mec.num_mec; i++) { +for (j =0 ; j < adev->gfx.mec.num_pipe_per_mec; j++) { +/* MECs start at 1 */ + cp_int_cntl_reg =gfx_v12_0_get_cpc_int_cntl (adev, i +1 , j); + +if (cp_int_cntl_reg) { + cp_int_cntl =RREG32_SOC15_IP (GC , cp_int_cntl_reg); + cp_int_cntl =REG_SET_FIELD (cp_int_cntl,CP_ME1_PIPE0_INT_CNTL , +PRIV_REG_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +WREG32_SOC15_IP (GC , cp_int_cntl_reg, cp_int_cntl); + } + } + }break ;default :break ;
@@ -4766,15 +4835,28 @@ static int gfx_v12_0_set_priv_reg_fault_state(struct amdgpu_device *adev,static int gfx_v12_0_set_priv_inst_fault_state (struct amdgpu_device *adev,struct amdgpu_irq_src *source, -unsigned type, +unsigned int type,enum amdgpu_interrupt_state state) { +u32 cp_int_cntl_reg, cp_int_cntl; +int i, j; +switch (state) {case AMDGPU_IRQ_STATE_DISABLE :case AMDGPU_IRQ_STATE_ENABLE : -WREG32_FIELD15_PREREG (GC ,0 ,CP_INT_CNTL_RING0 , -PRIV_INSTR_INT_ENABLE , - state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +for (i =0 ; i < adev->gfx.me.num_me; i++) { +for (j =0 ; j < adev->gfx.me.num_pipe_per_me; j++) { + cp_int_cntl_reg =gfx_v12_0_get_cpg_int_cntl (adev, i, j); + +if (cp_int_cntl_reg) { + cp_int_cntl =RREG32_SOC15_IP (GC , cp_int_cntl_reg); + cp_int_cntl =REG_SET_FIELD (cp_int_cntl,CP_INT_CNTL_RING0 , +PRIV_INSTR_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +WREG32_SOC15_IP (GC , cp_int_cntl_reg, cp_int_cntl); + } + } + }break ;default :break ;
@@ -4798,8 +4880,8 @@ static void gfx_v12_0_handle_priv_fault(struct amdgpu_device *adev,case 0 :for (i =0 ; i < adev->gfx.num_gfx_rings; i++) { ring = &adev->gfx.gfx_ring[i]; -/* we only enabled 1 gfx queue per pipe for now */ -if (ring->me == me_id && ring->pipe == pipe_id) +if (ring->me == me_id && ring->pipe == pipe_id && + ring->queue == queue_id)drm_sched_fault (&ring->sched); }break ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 191/244 drm/amdgpu/gfx9: properly handle error ints on all pipes
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit 48695573d2feaf42812c1ad54e01caff0d1c2d71 ]
Need to handle the interrupt enables for all pipes.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 44 +++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 50 +++++++++++++++++++++++-- 2 files changed, 89 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +43 -1
@@ -2638,7 +2638,7 @@ static void gfx_v9_0_enable_gui_idle_interrupt(struct amdgpu_device *adev, tmp =REG_SET_FIELD (tmp,CP_INT_CNTL_RING0 ,CNTX_BUSY_INT_ENABLE , enable ?1 :0 ); tmp =REG_SET_FIELD (tmp,CP_INT_CNTL_RING0 ,CNTX_EMPTY_INT_ENABLE , enable ?1 :0 ); tmp =REG_SET_FIELD (tmp,CP_INT_CNTL_RING0 ,CMP_BUSY_INT_ENABLE , enable ?1 :0 ); -if (adev->gfx.num_gfx_rings) +if (adev->gfx.num_gfx_rings) tmp =REG_SET_FIELD (tmp,CP_INT_CNTL_RING0 ,GFX_IDLE_INT_ENABLE , enable ?1 :0 );WREG32_SOC15 (GC ,0 , mmCP_INT_CNTL_RING0, tmp);
@@ -5933,17 +5933,59 @@ static void gfx_v9_0_set_compute_eop_interrupt_state(struct amdgpu_device *adev, } } +static u32 gfx_v9_0_get_cpc_int_cntl (struct amdgpu_device *adev, +int me,int pipe) +{ +/* +* amdgpu controls only the first MEC. That's why this function only +* handles the setting of interrupts for this specific MEC. All other +* pipes' interrupts are set by amdkfd. +*/ +if (me !=1 ) +return 0 ; + +switch (pipe) { +case 0 : +return SOC15_REG_OFFSET (GC ,0 , mmCP_ME1_PIPE0_INT_CNTL); +case 1 : +return SOC15_REG_OFFSET (GC ,0 , mmCP_ME1_PIPE1_INT_CNTL); +case 2 : +return SOC15_REG_OFFSET (GC ,0 , mmCP_ME1_PIPE2_INT_CNTL); +case 3 : +return SOC15_REG_OFFSET (GC ,0 , mmCP_ME1_PIPE3_INT_CNTL); +default : +return 0 ; + } +} +static int gfx_v9_0_set_priv_reg_fault_state (struct amdgpu_device *adev,struct amdgpu_irq_src *source,unsigned type,enum amdgpu_interrupt_state state) { +u32 cp_int_cntl_reg, cp_int_cntl; +int i, j; +switch (state) {case AMDGPU_IRQ_STATE_DISABLE :case AMDGPU_IRQ_STATE_ENABLE :WREG32_FIELD15 (GC ,0 ,CP_INT_CNTL_RING0 ,PRIV_REG_INT_ENABLE , state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +for (i =0 ; i < adev->gfx.mec.num_mec; i++) { +for (j =0 ; j < adev->gfx.mec.num_pipe_per_mec; j++) { +/* MECs start at 1 */ + cp_int_cntl_reg =gfx_v9_0_get_cpc_int_cntl (adev, i +1 , j); + +if (cp_int_cntl_reg) { + cp_int_cntl =RREG32_SOC15_IP (GC , cp_int_cntl_reg); + cp_int_cntl =REG_SET_FIELD (cp_int_cntl,CP_ME1_PIPE0_INT_CNTL , +PRIV_REG_INT_ENABLE , + state ==AMDGPU_IRQ_STATE_ENABLE ?1 :0 ); +WREG32_SOC15_IP (GC , cp_int_cntl_reg, cp_int_cntl); + } + } + }break ;default :break ;
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +46 -4
67 lines not on this page · raw message
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 192/244 drm/amd/display: Fix possible overflow in integer multiplication
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 3f96f545f877ac59d0c967f52d760b4b2b3b9a47 ]
[WHAT & HOW]
Integer multiplies integer may overflow in context that expects an expression of unsigned long long (64 bits). This can be fixed by casting integer to unsigned long long to force 64 bits results.
This fixes 2 OVERFLOW_BEFORE_WIDEN issues reported by Coverity.
--- .../amd/display/dc/resource/dcn32/dcn32_resource_helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource_helpers.c +2 -2
@@ -663,7 +663,7 @@ bool dcn32_subvp_drr_admissable(struct dc *dc, struct dc_state *context) subvp_disallow |=disallow_subvp_in_active_plus_blank (pipe); refresh_rate = (pipe->stream->timing.pix_clk_100hz * (uint64_t )100 + - pipe->stream->timing.v_total * pipe->stream->timing.h_total - (uint64_t )1 ); + pipe->stream->timing.v_total * (unsigned long long )pipe->stream->timing.h_total - (uint64_t )1 ); refresh_rate =div_u64 (refresh_rate, pipe->stream->timing.v_total); refresh_rate =div_u64 (refresh_rate, pipe->stream->timing.h_total); }
@@ -724,7 +724,7 @@ bool dcn32_subvp_vblank_admissable(struct dc *dc, struct dc_state *context, int subvp_disallow |=disallow_subvp_in_active_plus_blank (pipe); refresh_rate = (pipe->stream->timing.pix_clk_100hz * (uint64_t )100 + - pipe->stream->timing.v_total * pipe->stream->timing.h_total - (uint64_t )1 ); + pipe->stream->timing.v_total * (unsigned long long )pipe->stream->timing.h_total - (uint64_t )1 ); refresh_rate =div_u64 (refresh_rate, pipe->stream->timing.v_total); refresh_rate =div_u64 (refresh_rate, pipe->stream->timing.h_total); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 193/244 drm/amd/display: Check stream_status before it is used
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 58a8ee96f84d2c21abb85ad8c22d2bbdf59bd7a9 ]
[WHAT & HOW]dc_state_get_stream_status can return null, and therefore null must be checked before stream_status is used.
This fixes 1 NULL_RETURNS issue reported by Coverity.
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +1 -1
@@ -3739,7 +3739,7 @@ static void commit_planes_for_stream_fast(struct dc *dc, surface_count, stream, context); - }else { + }else if (stream_status) { build_dmub_cmd_list(dc, srf_updates, surface_count,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 194/244 drm/amd/display: Avoid overflow assignment in link_dp_cts
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit a15268787b79fd183dd526cc16bec9af4f4e49a1 ]
sampling_rate is an uint8_t but is assigned an unsigned int, and thus it can overflow. As a result, sampling_rate is changed to uint32_t.
Similarly, LINK_QUAL_PATTERN_SET has a size of 2 bits, and it should only be assigned to a value less or equal than 4.
This fixes 2 INTEGER_OVERFLOW issues reported by Coverity.
--- drivers/gpu/drm/amd/display/dc/dc_dp_types.h | 2 +- drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c | 3 ++- drivers/gpu/drm/amd/display/include/dpcd_defs.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dc_dp_types.h +1 -1
@@ -727,7 +727,7 @@ struct dp_audio_test_data_flags {struct dp_audio_test_data {struct dp_audio_test_data_flags flags; -uint8_t sampling_rate; +uint32_t sampling_rate;uint8_t channel_count;uint8_t pattern_type;uint8_t pattern_period[8 ];
drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c +2 -1
@@ -775,7 +775,8 @@ bool dp_set_test_pattern(core_link_read_dpcd (link,DP_TRAINING_PATTERN_SET , &training_pattern.raw,sizeof (training_pattern)); - training_pattern.v1_3.LINK_QUAL_PATTERN_SET = pattern; +if (pattern <=PHY_TEST_PATTERN_END_DP11 ) + training_pattern.v1_3.LINK_QUAL_PATTERN_SET = pattern;core_link_write_dpcd (link,DP_TRAINING_PATTERN_SET , &training_pattern.raw,sizeof (training_pattern));
drivers/gpu/drm/amd/display/include/dpcd_defs.h +1 -0
@@ -76,6 +76,7 @@ enum dpcd_phy_test_patterns {PHY_TEST_PATTERN_D10_2 ,PHY_TEST_PATTERN_SYMBOL_ERROR ,PHY_TEST_PATTERN_PRBS7 , +PHY_TEST_PATTERN_END_DP11 =PHY_TEST_PATTERN_PRBS7 ,PHY_TEST_PATTERN_80BIT_CUSTOM ,/* For DP1.2 only */ PHY_TEST_PATTERN_CP2520_1 , PHY_TEST_PATTERN_CP2520_2,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 195/244 drm/amd/display: Initialize get_bytes_per_element's default to 1
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 4067f4fa0423a89fb19a30b57231b384d77d2610 ]
Variables, used as denominators and maybe not assigned to other values, should not be 0. bytes_per_element_y & bytes_per_element_c are initialized by get_bytes_per_element() which should never return 0.
This fixes 10 DIVIDE_BY_ZERO issues reported by Coverity.
--- .../gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20v2.c | 2 +- .../gpu/drm/amd/display/dc/dml/dcn21/display_rq_dlg_calc_21.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20v2.c +1 -1
@@ -78,7 +78,7 @@ static void calculate_ttu_cursor(struct display_mode_lib *mode_lib,static unsigned int get_bytes_per_element (enum source_format_class source_format,bool is_chroma) { -unsigned int ret_val =0 ; +unsigned int ret_val =1 ;if (source_format == dm_444_16) {if (!is_chroma)
drivers/gpu/drm/amd/display/dc/dml/dcn21/display_rq_dlg_calc_21.c +1 -1
@@ -53,7 +53,7 @@ static void calculate_ttu_cursor(static unsigned int get_bytes_per_element (enum source_format_class source_format,bool is_chroma) { -unsigned int ret_val =0 ; +unsigned int ret_val =1 ;if (source_format == dm_444_16) {if (!is_chroma)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 196/244 drm/printer: Allow NULL data in devcoredump printer
In reply to Sasha LevinFrom: Matthew Brost <[email protected]>
[ Upstream commit 53369581dc0c68a5700ed51e1660f44c4b2bb524 ]
We want to determine the size of the devcoredump before writing it out. To that end, we will run the devcoredump printer with NULL data to get the size, alloc data based on the generated offset, then run the devcorecump again with a valid data pointer to print. This necessitates not writing data to the data pointer on the initial pass, when it is NULL.
v5:
- Better commit message (Jonathan)
- Add kerenl doc with examples (Jani)
--- drivers/gpu/drm/drm_print.c | 13 +++++---- include/drm/drm_print.h | 54 ++++++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_print.c +8 -5
@@ -100,8 +100,9 @@ void __drm_puts_coredump(struct drm_printer *p, const char *str) copy = iterator->remain;/* Copy out the bit of the string that we need */ -memcpy (iterator->data, - str + (iterator->start - iterator->offset), copy); +if (iterator->data) +memcpy (iterator->data, + str + (iterator->start - iterator->offset), copy); iterator->offset = iterator->start + copy; iterator->remain -= copy;
@@ -110,7 +111,8 @@ void __drm_puts_coredump(struct drm_printer *p, const char *str) len =min_t (ssize_t,strlen (str), iterator->remain); -memcpy (iterator->data + pos, str, len); +if (iterator->data) +memcpy (iterator->data + pos, str, len); iterator->offset += len; iterator->remain -= len;
@@ -140,8 +142,9 @@ void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf)if ((iterator->offset >= iterator->start) && (len < iterator->remain)) {ssize_t pos = iterator->offset - iterator->start; -snprintf (((char *) iterator->data) + pos, - iterator->remain,"%pV" , vaf); +if (iterator->data) +snprintf (((char *) iterator->data) + pos, + iterator->remain,"%pV" , vaf); iterator->offset += len; iterator->remain -= len;
include/drm/drm_print.h +53 -1
66 lines not on this page · raw message
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 197/244 perf,x86: avoid missing caller address in stack traces captured in uprobe
In reply to Sasha LevinFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit cfa7f3d2c526c224a6271cc78a4a27a0de06f4f0 ]
When tracing user functions with uprobe functionality, it's common to install the probe (e.g., a BPF program) at the first instruction of the function. This is often going to be push %rbp instruction in function preamble, which means that within that function frame pointer hasn't been established yet. This leads to consistently missing an actual caller of the traced function, because perf_callchain_user() only records current IP (capturing traced function) and then following frame pointer chain (which would be caller's frame, containing the address of caller's caller).
So when we have target_1 -> target_2 -> target_3 call chain and we are tracing an entry to target_3, captured stack trace will report target_1 -> target_3 call chain, which is wrong and confusing.
This patch proposes a x86-64-specific heuristic to detect push %rbp (push %ebp on 32-bit architecture) instruction being traced. Given entire kernel implementation of user space stack trace capturing works under assumption that user space code was compiled with frame pointer register (%rbp/%ebp) preservation, it seems pretty reasonable to use this instruction as a strong indicator that this is the entry to the function. In that case, return address is still pointed to by %rsp/%esp, so we fetch it and add to stack trace before proceeding to unwind the rest using frame pointer-based logic.
We also check for endbr64 (for 64-bit modes) as another common pattern for function entry, as suggested by Josh Poimboeuf. Even if we get this wrong sometimes for uprobes attached not at the function entry, it's OK because stack trace will still be overall meaningful, just with one extra bogus entry. If we don't detect this, we end up with guaranteed to be missing caller function entry in the stack trace, which is worse overall.
--- arch/x86/events/core.c | 63 +++++++++++++++++++++++++++++++++++++++++ include/linux/uprobes.h | 2 ++ kernel/events/uprobes.c | 2 ++ 3 files changed, 67 insertions(+)
arch/x86/events/core.c +63 -0
@@ -41,6 +41,8 @@#include <asm/desc.h> #include <asm/ldt.h> #include <asm/unwind.h> +#include <asm/uprobes.h> +#include <asm/ibt.h> #include "perf_event.h"
@@ -2816,6 +2818,46 @@ static unsigned long get_segment_base(unsigned int segment)return get_desc_base (desc); } +#ifdef CONFIG_UPROBES +/* +* Heuristic-based check if uprobe is installed at the function entry. +* +* Under assumption of user code being compiled with frame pointers, +* `push %rbp/%ebp` is a good indicator that we indeed are. +* +* Similarly, `endbr64` (assuming 64-bit mode) is also a common pattern. +* If we get this wrong, captured stack trace might have one extra bogus +* entry, but the rest of stack trace will still be meaningful. +*/ +static bool is_uprobe_at_func_entry (struct pt_regs *regs) +{ +struct arch_uprobe *auprobe; + +if (!current->utask) +return false; + + auprobe = current->utask->auprobe; +if (!auprobe) +return false; + +/* push %rbp/%ebp */ +if (auprobe->insn[0 ] ==0x55 ) +return true; + +/* endbr64 (64-bit only) */ +if (user_64bit_mode (regs) &&is_endbr (*(u32 *)auprobe->insn)) +return true; + +return false; +} + +#else +static bool is_uprobe_at_func_entry (struct pt_regs *regs) +{ +return false; +} +#endif /* CONFIG_UPROBES */ +#ifdef CONFIG_IA32_EMULATION #include <linux/compat.h>
@@ -2827,6 +2869,7 @@ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry_ctx *entunsigned long ss_base, cs_base;struct stack_frame_ia32 frame;const struct stack_frame_ia32 __user *fp; +u32 ret_addr;if (user_64bit_mode (regs))return 0 ;
@@ -2836,6 +2879,12 @@ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry_ctx *ent fp =compat_ptr (ss_base + regs->bp);pagefault_disable (); + +/* see perf_callchain_user() below for why we do this */ +if (is_uprobe_at_func_entry (regs) && + !get_user (ret_addr, (const u32 __user *)regs->sp)) +perf_callchain_store (entry, ret_addr); +while (entry->nr < entry->max_stack) {if (!valid_user_frame (fp,sizeof (frame)))break ;
@@ -2864,6 +2913,7 @@ perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs {struct stack_frame frame;const struct stack_frame __user *fp; +unsigned long ret_addr;if (perf_guest_state ()) {/* TODO: We don't support guest os callchain now */
@@ -2887,6 +2937,19 @@ perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regsreturn ;pagefault_disable (); + +/* +* If we are called from uprobe handler, and we are indeed at the very +* entry to user function (which is normally a `push %rbp` instruction, +* under assumption of application being compiled with frame pointers), +* we should read return address from *regs->sp before proceeding +* to follow frame pointers, otherwise we'll skip immediate caller +* as %rbp is not yet setup. +*/ +if (is_uprobe_at_func_entry (regs) && + !get_user (ret_addr, (const unsigned long __user *)regs->sp)) +perf_callchain_store (entry, ret_addr); +while (entry->nr < entry->max_stack) {if (!valid_user_frame (fp,sizeof (frame)))break ;
include/linux/uprobes.h +2 -0
@@ -76,6 +76,8 @@ struct uprobe_task {struct uprobe *active_uprobe;unsigned long xol_vaddr; +struct arch_uprobe *auprobe; +struct return_instance *return_instances;unsigned int depth; };
kernel/events/uprobes.c +2 -0
@@ -2081,6 +2081,7 @@ static void handler_chain(struct uprobe *uprobe, struct pt_regs *regs)bool need_prep = false;/* prepare return uprobe, when needed */ down_read (&uprobe->register_rwsem); + current->utask->auprobe = &uprobe->arch;for (uc = uprobe->consumers; uc; uc = uc->next) {int rc =0 ;
@@ -2095,6 +2096,7 @@ static void handler_chain(struct uprobe *uprobe, struct pt_regs *regs) remove &= rc; } + current->utask->auprobe =NULL ;if (need_prep && !remove)prepare_uretprobe (uprobe, regs);/* put bp at return */
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 198/244 scsi: aacraid: Rearrange order of struct aac_srb_unit
In reply to Sasha LevinFrom: Kees Cook <[email protected]>
[ Upstream commit 6e5860b0ad4934baee8c7a202c02033b2631bb44 ]
struct aac_srb_unit contains struct aac_srb, which contains struct sgmap, which ends in a (currently) "fake" (1-element) flexible array. Converting this to a flexible array is needed so that runtime bounds checking won't think the array is fixed size (i.e. under CONFIG_FORTIFY_SOURCE=y and/or CONFIG_UBSAN_BOUNDS=y), as other parts of aacraid use struct sgmap as a flexible array.
It is not legal to have a flexible array in the middle of a structure, so it either needs to be split up or rearranged so that it is at the end of the structure. Luckily, struct aac_srb_unit, which is exclusively consumed/updated by aac_send_safw_bmic_cmd(), does not depend on member ordering.
The values set in the on-stack struct aac_srb_unit instance "srbu" by the only two callers, aac_issue_safw_bmic_identify() and aac_get_safw_ciss_luns(), do not contain anything in srbu.srb.sgmap.sg, and they both implicitly initialize srbu.srb.sgmap.count to 0 during memset(). For example:
memset(&srbu, 0, sizeof(struct aac_srb_unit));
srbcmd = &srbu.srb;
srbcmd->flags = cpu_to_le32(SRB_DataIn);
srbcmd->cdb[0] = CISS_REPORT_PHYSICAL_LUNS;
srbcmd->cdb[1] = 2; /* extended reporting */
srbcmd->cdb[8] = (u8)(datasize >> 8);
srbcmd->cdb[9] = (u8)(datasize);
rcode = aac_send_safw_bmic_cmd(dev, &srbu, phys_luns, datasize);During aac_send_safw_bmic_cmd(), a separate srb is mapped into DMA, and has srbu.srb copied into it:
srb = fib_data(fibptr);
memcpy(srb, &srbu->srb, sizeof(struct aac_srb));Only then is srb.sgmap.count written and srb->sg populated:
srb->count = cpu_to_le32(xfer_len);
sg64 = (struct sgmap64 *)&srb->sg;
sg64->count = cpu_to_le32(1);
sg64->sg[0].addr[1] = cpu_to_le32(upper_32_bits(addr));
sg64->sg[0].addr[0] = cpu_to_le32(lower_32_bits(addr));
sg64->sg[0].count = cpu_to_le32(xfer_len);But this is happening in the DMA memory, not in srbu.srb. An attempt to copy the changes back to srbu does happen:
/*
* Copy the updated data for other dumping or other usage if
* needed
*/
memcpy(&srbu->srb, srb, sizeof(struct aac_srb));But this was never correct: the sg64 (3 u32s) overlap of srb.sg (2 u32s) always meant that srbu.srb would have held truncated information and any attempt to walk srbu.srb.sg.sg based on the value of srbu.srb.sg.count would result in attempting to parse past the end of srbu.srb.sg.sg[0] into srbu.srb_reply.
After getting a reply from hardware, the reply is copied into srbu.srb_reply:
srb_reply = (struct aac_srb_reply *)fib_data(fibptr);
memcpy(&srbu->srb_reply, srb_reply, sizeof(struct aac_srb_reply));This has always been fixed-size, so there's no issue here. It is worth noting that the two callers _never check_ srbu contents -- neither srbu.srb nor srbu.srb_reply is examined. (They depend on the mapped xfer_buf instead.)
Therefore, the ordering of members in struct aac_srb_unit does not matter, and the flexible array member can moved to the end.
(Additionally, the two memcpy()s that update srbu could be entirely removed as they are never consumed, but I left that as-is.)
--- drivers/scsi/aacraid/aacraid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/aacraid/aacraid.h +1 -1
@@ -2029,8 +2029,8 @@ struct aac_srb_reply };struct aac_srb_unit { -struct aac_srb srb;struct aac_srb_reply srb_reply; +struct aac_srb srb; };/*
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 199/244 scsi: lpfc: Validate hdwq pointers before dereferencing in reset/errata paths
In reply to Sasha LevinFrom: Justin Tee <[email protected]>
[ Upstream commit 2be1d4f11944cd6283cb97268b3e17c4424945ca ]
When the HBA is undergoing a reset or is handling an errata event, NULL ptr dereference crashes may occur in routines such as lpfc_sli_flush_io_rings(), lpfc_dev_loss_tmo_callbk(), or lpfc_abort_handler().
Add NULL ptr checks before dereferencing hdwq pointers that may have been freed due to operations colliding with a reset or errata event handler.
--- drivers/scsi/lpfc/lpfc_hbadisc.c | 3 ++- drivers/scsi/lpfc/lpfc_scsi.c | 13 +++++++++++-- drivers/scsi/lpfc/lpfc_sli.c | 11 +++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-)
drivers/scsi/lpfc/lpfc_hbadisc.c +2 -1
@@ -175,7 +175,8 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) ndlp->nlp_state, ndlp->fc4_xpt_flags);/* Don't schedule a worker thread event if the vport is going down. */ -if (test_bit (FC_UNLOADING , &vport->load_flag)) { +if (test_bit (FC_UNLOADING , &vport->load_flag) || + !test_bit (HBA_SETUP , &phba->hba_flag)) {spin_lock_irqsave (&ndlp->lock, iflags); ndlp->rport =NULL ;
drivers/scsi/lpfc/lpfc_scsi.c +11 -2
@@ -5555,11 +5555,20 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) iocb = &lpfc_cmd->cur_iocbq;if (phba->sli_rev ==LPFC_SLI_REV4 ) { - pring_s4 = phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq->pring; -if (!pring_s4) { +/* if the io_wq & pring are gone, the port was reset. */ +if (!phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq || + !phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq->pring) { +lpfc_printf_vlog (vport,KERN_WARNING ,LOG_FCP , +"2877 SCSI Layer I/O Abort Request " +"IO CMPL Status x%x ID %d LUN %llu " +"HBA_SETUP %d\n" ,FAILED , + cmnd->device->id, + (u64 )cmnd->device->lun, +test_bit (HBA_SETUP , &phba->hba_flag)); ret =FAILED ; goto out_unlock_hba; } + pring_s4 = phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq->pring;spin_lock (&pring_s4->ring_lock); }/* the command is in process of being cancelled */
drivers/scsi/lpfc/lpfc_sli.c +11 -0
@@ -4687,6 +4687,17 @@ lpfc_sli_flush_io_rings(struct lpfc_hba *phba)/* Look on all the FCP Rings for the iotag */ if (phba->sli_rev >=LPFC_SLI_REV4 ) {for (i =0 ; i < phba->cfg_hdw_queue; i++) { +if (!phba->sli4_hba.hdwq || + !phba->sli4_hba.hdwq[i].io_wq) { +lpfc_printf_log (phba,KERN_ERR ,LOG_SLI , +"7777 hdwq's deleted %lx " +"%lx %x %x\n" , + phba->pport->load_flag, + phba->hba_flag, + phba->link_state, + phba->sli.sli_flag); +return ; + } pring = phba->sli4_hba.hdwq[i].io_wq->pring;spin_lock_irq (&pring->ring_lock);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 200/244 scsi: lpfc: Fix unsolicited FLOGI kref imbalance when in direct attached topology
In reply to Sasha LevinFrom: Justin Tee <[email protected]>
[ Upstream commit b5c18c9dd138733c16893613345af44deadcf05e ]
In direct attached topology, certain target vendors that are quick to issue FLOGI followed by a cable pull for more than dev_loss_tmo may result in a kref imbalance for the remote port ndlp object.
Add an nlp_get when the defer_flogi_acc flag is set. This is expected to balance the nlp_put in the defer_flogi_acc clause in the lpfc_issue_els_flogi() routine. Because we need to retain the ndlp ptr, reorganize all of the defer_flogi_acc information into one lpfc_defer_flogi_acc struct.
--- drivers/scsi/lpfc/lpfc.h | 12 ++++++--- drivers/scsi/lpfc/lpfc_els.c | 46 +++++++++++++++++++------------- drivers/scsi/lpfc/lpfc_hbadisc.c | 11 ++++++-- 3 files changed, 46 insertions(+), 23 deletions(-)
drivers/scsi/lpfc/lpfc.h +9 -3
@@ -306,6 +306,14 @@ struct lpfc_stats {struct lpfc_hba ; +/* Data structure to keep withheld FLOGI_ACC information */ +struct lpfc_defer_flogi_acc { +bool flag; +u16 rx_id; +u16 ox_id; +struct lpfc_nodelist *ndlp; + +};#define LPFC_VMID_TIMER 300/* timer interval in seconds */
@@ -1430,9 +1438,7 @@ struct lpfc_hba {uint16_t vlan_id;struct list_head fcf_conn_rec_list; -bool defer_flogi_acc_flag; -uint16_t defer_flogi_acc_rx_id; -uint16_t defer_flogi_acc_ox_id; +struct lpfc_defer_flogi_acc defer_flogi_acc;spinlock_t ct_ev_lock;/* synchronize access to ct_ev_waiters */ struct list_head ct_ev_waiters;
drivers/scsi/lpfc/lpfc_els.c +28 -18
96 lines not on this page · raw message
drivers/scsi/lpfc/lpfc_hbadisc.c +9 -2
@@ -1255,7 +1255,14 @@ lpfc_linkdown(struct lpfc_hba *phba)lpfc_scsi_dev_block (phba); offline =pci_channel_offline (phba->pcidev); - phba->defer_flogi_acc_flag = false; +/* Decrement the held ndlp if there is a deferred flogi acc */ +if (phba->defer_flogi_acc.flag) { +if (phba->defer_flogi_acc.ndlp) { +lpfc_nlp_put (phba->defer_flogi_acc.ndlp); + phba->defer_flogi_acc.ndlp =NULL ; + } + } + phba->defer_flogi_acc.flag = false;/* Clear external loopback plug detected flag */ phba->link_flag &= ~LS_EXTERNAL_LOOPBACK ;
@@ -1377,7 +1384,7 @@ lpfc_linkup_port(struct lpfc_vport *vport) (vport != phba->pport))return ; -if (phba->defer_flogi_acc_flag) { +if (phba->defer_flogi_acc.flag) {clear_bit (FC_ABORT_DISCOVERY , &vport->fc_flag);clear_bit (FC_RSCN_MODE , &vport->fc_flag);clear_bit (FC_NLP_MORE , &vport->fc_flag);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 201/244 scsi: lpfc: Update PRLO handling in direct attached topology
In reply to Sasha LevinFrom: Justin Tee <[email protected]>
[ Upstream commit 1f0f7679ad8942f810b0f19ee9cf098c3502d66a ]
A kref imbalance occurs when handling an unsolicited PRLO in direct attached topology.
Rework PRLO rcv handling when in MAPPED state. Save the state that we were handling a PRLO by setting nlp_last_elscmd to ELS_CMD_PRLO. Then in the lpfc_cmpl_els_logo_acc() completion routine, manually restart discovery. By issuing the PLOGI, which nlp_gets, before nlp_put at the end of the lpfc_cmpl_els_logo_acc() routine, we are saving us from a final nlp_put. And, we are still allowing the unreg_rpi to happen.
--- drivers/scsi/lpfc/lpfc_els.c | 27 ++++++++++++++++----------- drivers/scsi/lpfc/lpfc_nportdisc.c | 22 ++++++++++++++++++++-- 2 files changed, 36 insertions(+), 13 deletions(-)
drivers/scsi/lpfc/lpfc_els.c +16 -11
@@ -5244,9 +5244,10 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,/* ACC to LOGO completes to NPort <nlp_DID> */ lpfc_printf_vlog (vport,KERN_INFO ,LOG_ELS ,"0109 ACC to LOGO completes to NPort x%x refcnt %d " -"Data: x%x x%x x%x\n" , - ndlp->nlp_DID,kref_read (&ndlp->kref), ndlp->nlp_flag, - ndlp->nlp_state, ndlp->nlp_rpi); +"last els x%x Data: x%x x%x x%x\n" , + ndlp->nlp_DID,kref_read (&ndlp->kref), + ndlp->nlp_last_elscmd, ndlp->nlp_flag, ndlp->nlp_state, + ndlp->nlp_rpi);/* This clause allows the LOGO ACC to complete and free resources * for the Fabric Domain Controller. It does deliberately skip
@@ -5258,18 +5259,22 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, goto out;if (ndlp->nlp_state ==NLP_STE_NPR_NODE ) { -/* If PLOGI is being retried, PLOGI completion will cleanup the -* node. The NLP_NPR_2B_DISC flag needs to be retained to make -* progress on nodes discovered from last RSCN. -*/ -if ((ndlp->nlp_flag &NLP_DELAY_TMO ) && - (ndlp->nlp_last_elscmd ==ELS_CMD_PLOGI )) - goto out; -if (ndlp->nlp_flag &NLP_RPI_REGISTERED )lpfc_unreg_rpi (vport, ndlp); +/* If came from PRLO, then PRLO_ACC is done. +* Start rediscovery now. +*/ +if (ndlp->nlp_last_elscmd ==ELS_CMD_PRLO ) { +spin_lock_irq (&ndlp->lock); + ndlp->nlp_flag |=NLP_NPR_2B_DISC ; +spin_unlock_irq (&ndlp->lock); + ndlp->nlp_prev_state = ndlp->nlp_state; +lpfc_nlp_set_state (vport, ndlp,NLP_STE_PLOGI_ISSUE ); +lpfc_issue_els_plogi (vport, ndlp->nlp_DID,0 ); + } } + out:/* * The driver received a LOGO from the rport and has ACK'd it.
drivers/scsi/lpfc/lpfc_nportdisc.c +20 -2
@@ -2652,8 +2652,26 @@ lpfc_rcv_prlo_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,/* flush the target */ lpfc_sli_abort_iocb (vport, ndlp->nlp_sid,0 ,LPFC_CTX_TGT ); -/* Treat like rcv logo */ -lpfc_rcv_logo (vport, ndlp, cmdiocb,ELS_CMD_PRLO ); +/* Send PRLO_ACC */ +spin_lock_irq (&ndlp->lock); + ndlp->nlp_flag |=NLP_LOGO_ACC ; +spin_unlock_irq (&ndlp->lock); +lpfc_els_rsp_acc (vport,ELS_CMD_PRLO , cmdiocb, ndlp,NULL ); + +/* Save ELS_CMD_PRLO as the last elscmd and then set to NPR. +* lpfc_cmpl_els_logo_acc is expected to restart discovery. +*/ + ndlp->nlp_last_elscmd =ELS_CMD_PRLO ; + ndlp->nlp_prev_state = ndlp->nlp_state; + +lpfc_printf_vlog (vport,KERN_INFO ,LOG_NODE |LOG_ELS |LOG_DISCOVERY , +"3422 DID x%06x nflag x%x lastels x%x ref cnt %u\n" , + ndlp->nlp_DID, ndlp->nlp_flag, + ndlp->nlp_last_elscmd, +kref_read (&ndlp->kref)); + +lpfc_nlp_set_state (vport, ndlp,NLP_STE_NPR_NODE ); +return ndlp->nlp_state; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 202/244 drm/amd/display: Force enable 3DLUT DMA check for dcn401 in DML
In reply to Sasha LevinFrom: Dillon Varone <[email protected]>
[ Upstream commit b8dc6ca028d9a39196a3a066b9ef2d4a5eca475d ]
[WHY]
Currently TR0 (trip 0) is not properly budgeting for urgent latency in DML2.1. This results in overly aggressive prefetch schedules that are vulnerable to request return jitter, resulting in severe underflow at the start of the frame.
[HOW]
Forcing 3DLUT DMA check to enable causes urgent latency to be budgeted properly into the prefetch schedule, avoiding the vulnerability.
--- .../amd/display/dc/dml2/dml21/dml21_translation_helper.c | 6 ++++-- drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.h | 1 + .../drm/amd/display/dc/resource/dcn401/dcn401_resource.c | 1 + 3 files changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_translation_helper.c +4 -2
@@ -827,6 +827,7 @@ static void populate_dml21_plane_config_from_plane_state(struct dml2_context *dmif (plane_state->mcm_luts.lut3d_data.lut3d_src ==DC_CM2_TRANSFER_FUNC_SOURCE_VIDMEM ) { plane->tdlut.setup_for_tdlut = true; +switch (plane_state->mcm_luts.lut3d_data.gpu_mem_params.layout) {case DC_CM2_GPU_MEM_LAYOUT_3D_SWIZZLE_LINEAR_RGB :case DC_CM2_GPU_MEM_LAYOUT_3D_SWIZZLE_LINEAR_BGR :
@@ -836,6 +837,7 @@ static void populate_dml21_plane_config_from_plane_state(struct dml2_context *dm plane->tdlut.tdlut_addressing_mode = dml2_tdlut_simple_linear;break ; } +switch (plane_state->mcm_luts.lut3d_data.gpu_mem_params.size) {case DC_CM2_GPU_MEM_SIZE_171717 : plane->tdlut.tdlut_width_mode = dml2_tdlut_width_17_cube;
@@ -844,8 +846,8 @@ static void populate_dml21_plane_config_from_plane_state(struct dml2_context *dm//plane->tdlut.tdlut_width_mode = dml2_tdlut_width_flatten; // dml2_tdlut_width_flatten undefined break ; } - }else - plane->tdlut.setup_for_tdlut = false; + } + plane->tdlut.setup_for_tdlut |= dml_ctx->config.force_tdlut_enable; plane->dynamic_meta_data.enable = false; plane->dynamic_meta_data.lines_before_active_required =0 ;
drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.h +1 -0
@@ -236,6 +236,7 @@ struct dml2_configuration_options {bool use_clock_dc_limits;bool gpuvm_enable; +bool force_tdlut_enable;struct dml2_soc_bb *bb_from_dmub; };
drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c +1 -0
@@ -2099,6 +2099,7 @@ static bool dcn401_resource_construct( dc->dml2_options.use_native_soc_bb_construction = true; dc->dml2_options.minimize_dispclk_using_odm = true; dc->dml2_options.map_dc_pipes_with_callbacks = true; + dc->dml2_options.force_tdlut_enable = true;resource_init_common_dml2_callbacks (dc, &dc->dml2_options); dc->dml2_options.callbacks.can_support_mclk_switch_using_fw_based_vblank_stretch = &dcn30_can_support_mclk_switch_using_fw_based_vblank_stretch;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 203/244 drm/amdgpu: fix unchecked return value warning for amdgpu_gfx
In reply to Sasha LevinFrom: Tim Huang <[email protected]>
[ Upstream commit c0277b9d7c2ee9ee5dbc948548984f0fbb861301 ]
This resolves the unchecded return value warning reported by Coverity.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +14 -4
@@ -882,8 +882,11 @@ int amdgpu_gfx_ras_late_init(struct amdgpu_device *adev, struct ras_common_if *rint r;if (amdgpu_ras_is_supported (adev, ras_block->block)) { -if (!amdgpu_persistent_edc_harvesting_supported (adev)) -amdgpu_ras_reset_error_status (adev,AMDGPU_RAS_BLOCK__GFX ); +if (!amdgpu_persistent_edc_harvesting_supported (adev)) { + r =amdgpu_ras_reset_error_status (adev,AMDGPU_RAS_BLOCK__GFX ); +if (r) +return r; + } r =amdgpu_ras_block_late_init (adev, ras_block);if (r)
@@ -1027,7 +1030,10 @@ uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg, uint32_t xcc_pr_err ("critical bug! too many kiq readers\n" ); goto failed_unlock; } -amdgpu_ring_alloc (ring,32 ); + r =amdgpu_ring_alloc (ring,32 ); +if (r) + goto failed_unlock; +amdgpu_ring_emit_rreg (ring, reg, reg_val_offs); r =amdgpu_fence_emit_polling (ring, &seq,MAX_KIQ_REG_WAIT );if (r)
@@ -1093,7 +1099,10 @@ void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v, uint3 }spin_lock_irqsave (&kiq->ring_lock, flags); -amdgpu_ring_alloc (ring,32 ); + r =amdgpu_ring_alloc (ring,32 ); +if (r) + goto failed_unlock; +amdgpu_ring_emit_wreg (ring, reg, v); r =amdgpu_fence_emit_polling (ring, &seq,MAX_KIQ_REG_WAIT );if (r)
@@ -1129,6 +1138,7 @@ void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v, uint3 failed_undo:amdgpu_ring_undo (ring); +failed_unlock:spin_unlock_irqrestore (&kiq->ring_lock, flags); failed_kiq_write:dev_err (adev->dev,"failed to write reg:%x\n" , reg);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 204/244 drm/amdgpu: fix unchecked return value warning for amdgpu_atombios
In reply to Sasha LevinFrom: Tim Huang <[email protected]>
[ Upstream commit 92549780e32718d64a6d08bbbb3c6fffecb541c7 ]
This resolves the unchecded return value warning reported by Coverity.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 35 ++++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +21 -14
@@ -1018,8 +1018,9 @@ int amdgpu_atombios_get_clock_dividers(struct amdgpu_device *adev,if (clock_type ==COMPUTE_ENGINE_PLL_PARAM ) { args.v3.ulClockParams =cpu_to_le32 ((clock_type <<24 ) | clock); -amdgpu_atom_execute_table (adev->mode_info.atom_context, index, (uint32_t *)&args, -sizeof (args)); +if (amdgpu_atom_execute_table (adev->mode_info.atom_context, + index, (uint32_t *)&args,sizeof (args))) +return -EINVAL ; dividers->post_div = args.v3.ucPostDiv; dividers->enable_post_div = (args.v3.ucCntlFlag &
@@ -1039,8 +1040,9 @@ int amdgpu_atombios_get_clock_dividers(struct amdgpu_device *adev,if (strobe_mode) args.v5.ucInputFlag =ATOM_PLL_INPUT_FLAG_PLL_STROBE_MODE_EN ; -amdgpu_atom_execute_table (adev->mode_info.atom_context, index, (uint32_t *)&args, -sizeof (args)); +if (amdgpu_atom_execute_table (adev->mode_info.atom_context, + index, (uint32_t *)&args,sizeof (args))) +return -EINVAL ; dividers->post_div = args.v5.ucPostDiv; dividers->enable_post_div = (args.v5.ucCntlFlag &
@@ -1058,8 +1060,9 @@ int amdgpu_atombios_get_clock_dividers(struct amdgpu_device *adev,/* fusion */ args.v4.ulClock =cpu_to_le32 (clock);/* 10 khz */ -amdgpu_atom_execute_table (adev->mode_info.atom_context, index, (uint32_t *)&args, -sizeof (args)); +if (amdgpu_atom_execute_table (adev->mode_info.atom_context, + index, (uint32_t *)&args,sizeof (args))) +return -EINVAL ; dividers->post_divider = dividers->post_div = args.v4.ucPostDiv; dividers->real_clock =le32_to_cpu (args.v4.ulClock);
@@ -1070,8 +1073,9 @@ int amdgpu_atombios_get_clock_dividers(struct amdgpu_device *adev, args.v6_in.ulClock.ulComputeClockFlag = clock_type; args.v6_in.ulClock.ulClockFreq =cpu_to_le32 (clock);/* 10 khz */ -amdgpu_atom_execute_table (adev->mode_info.atom_context, index, (uint32_t *)&args, -sizeof (args)); +if (amdgpu_atom_execute_table (adev->mode_info.atom_context, + index, (uint32_t *)&args,sizeof (args))) +return -EINVAL ; dividers->whole_fb_div =le16_to_cpu (args.v6_out.ulFbDiv.usFbDiv); dividers->frac_fb_div =le16_to_cpu (args.v6_out.ulFbDiv.usFbDivFrac);
@@ -1113,8 +1117,9 @@ int amdgpu_atombios_get_memory_pll_dividers(struct amdgpu_device *adev,if (strobe_mode) args.ucInputFlag |=MPLL_INPUT_FLAG_STROBE_MODE_EN ; -amdgpu_atom_execute_table (adev->mode_info.atom_context, index, (uint32_t *)&args, -sizeof (args)); +if (amdgpu_atom_execute_table (adev->mode_info.atom_context, + index, (uint32_t *)&args,sizeof (args))) +return -EINVAL ; mpll_param->clkfrac =le16_to_cpu (args.ulFbDiv.usFbDivFrac); mpll_param->clkf =le16_to_cpu (args.ulFbDiv.usFbDiv);
@@ -1211,8 +1216,9 @@ int amdgpu_atombios_get_max_vddc(struct amdgpu_device *adev, u8 voltage_type, args.v2.ucVoltageMode =0 ; args.v2.usVoltageLevel =0 ; -amdgpu_atom_execute_table (adev->mode_info.atom_context, index, (uint32_t *)&args, -sizeof (args)); +if (amdgpu_atom_execute_table (adev->mode_info.atom_context, + index, (uint32_t *)&args,sizeof (args))) +return -EINVAL ; *voltage =le16_to_cpu (args.v2.usVoltageLevel);break ;
@@ -1221,8 +1227,9 @@ int amdgpu_atombios_get_max_vddc(struct amdgpu_device *adev, u8 voltage_type, args.v3.ucVoltageMode =ATOM_GET_VOLTAGE_LEVEL ; args.v3.usVoltageLevel =cpu_to_le16 (voltage_id); -amdgpu_atom_execute_table (adev->mode_info.atom_context, index, (uint32_t *)&args, -sizeof (args)); +if (amdgpu_atom_execute_table (adev->mode_info.atom_context, + index, (uint32_t *)&args,sizeof (args))) +return -EINVAL ; *voltage =le16_to_cpu (args.v3.usVoltageLevel);break ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 205/244 perf: Fix event_function_call() locking
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 558abc7e3f895049faa46b08656be4c60dc6e9fd ]
All the event_function/@func call context already uses perf_ctx_lock() except for the !ctx->is_active case. Make it all consistent.
--- kernel/events/core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/events/core.c +5 -4
@@ -263,6 +263,7 @@ static int event_function(void *info)static void event_function_call (struct perf_event *event,event_f func,void *data) {struct perf_event_context *ctx = event->ctx; +struct perf_cpu_context *cpuctx =this_cpu_ptr (&perf_cpu_context);struct task_struct *task =READ_ONCE (ctx->task);/* verified in event_function */ struct event_function_struct efs = { .event = event,
@@ -291,22 +292,22 @@ static void event_function_call(struct perf_event *event, event_f func, void *daif (!task_function_call (task, event_function, &efs))return ; -raw_spin_lock_irq (&ctx->lock); +perf_ctx_lock (cpuctx, ctx);/* * Reload the task pointer, it might have been changed by * a concurrent perf_event_context_sched_out(). */ task = ctx->task;if (task ==TASK_TOMBSTONE ) { -raw_spin_unlock_irq (&ctx->lock); +perf_ctx_unlock (cpuctx, ctx);return ; }if (ctx->is_active) { -raw_spin_unlock_irq (&ctx->lock); +perf_ctx_unlock (cpuctx, ctx); goto again; }func (event,NULL , ctx, data); -raw_spin_unlock_irq (&ctx->lock); +perf_ctx_unlock (cpuctx, ctx); }/*
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 206/244 scsi: NCR5380: Initialize buffer for MSG IN and STATUS transfers
In reply to Sasha LevinFrom: Finn Thain <[email protected]>
[ Upstream commit 1c71065df2df693d208dd32758171c1dece66341 ]
Following an incomplete transfer in MSG IN phase, the driver would not notice the problem and would make use of invalid data. Initialize 'tmp' appropriately and bail out if no message was received. For STATUS phase, preserve the existing status code unless a new value was transferred.
--- drivers/scsi/NCR5380.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/NCR5380.c +4 -0
@@ -1807,8 +1807,11 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)return ;case PHASE_MSGIN : len =1 ; + tmp =0xff ; data = &tmp;NCR5380_transfer_pio (instance, &phase, &len, &data,0 ); +if (tmp ==0xff ) +break ; ncmd->message = tmp;switch (tmp) {
@@ -1996,6 +1999,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)break ;case PHASE_STATIN : len =1 ; + tmp = ncmd->status; data = &tmp;NCR5380_transfer_pio (instance, &phase, &len, &data,0 ); ncmd->status = tmp;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 207/244 drm/radeon/r100: Handle unknown family in r100_cp_init_microcode()
In reply to Sasha LevinFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit c6dbab46324b1742b50dc2fb5c1fee2c28129439 ]
With -Werror:
In function ‘r100_cp_init_microcode’,
inlined from ‘r100_cp_init’ at drivers/gpu/drm/radeon/r100.c:1136:7:
include/linux/printk.h:465:44: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
465 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
| ^
include/linux/printk.h:437:17: note: in definition of macro ‘printk_index_wrap’
437 | _p_func(_fmt, ##__VA_ARGS__); \
| ^~~~~~~
include/linux/printk.h:508:9: note: in expansion of macro ‘printk’
508 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~
drivers/gpu/drm/radeon/r100.c:1062:17: note: in expansion of macro ‘pr_err’
1062 | pr_err("radeon_cp: Failed to load firmware \"%s\"\n", fw_name);
| ^~~~~~Fix this by converting the if/else if/... construct into a proper switch() statement with a default to handle the error case.
As a bonus, the generated code is ca. 100 bytes smaller (with gcc 11.4.0 targeting arm32).
--- drivers/gpu/drm/radeon/r100.c | 70 ++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 25 deletions(-)
drivers/gpu/drm/radeon/r100.c +45 -25
@@ -1016,45 +1016,65 @@ static int r100_cp_init_microcode(struct radeon_device *rdev)DRM_DEBUG_KMS ("\n" ); -if ((rdev->family ==CHIP_R100 ) || (rdev->family ==CHIP_RV100 ) || - (rdev->family ==CHIP_RV200 ) || (rdev->family ==CHIP_RS100 ) || - (rdev->family ==CHIP_RS200 )) { +switch (rdev->family) { +case CHIP_R100 : +case CHIP_RV100 : +case CHIP_RV200 : +case CHIP_RS100 : +case CHIP_RS200 :DRM_INFO ("Loading R100 Microcode\n" ); fw_name =FIRMWARE_R100 ; - }else if ((rdev->family ==CHIP_R200 ) || - (rdev->family ==CHIP_RV250 ) || - (rdev->family ==CHIP_RV280 ) || - (rdev->family ==CHIP_RS300 )) { +break ; + +case CHIP_R200 : +case CHIP_RV250 : +case CHIP_RV280 : +case CHIP_RS300 :DRM_INFO ("Loading R200 Microcode\n" ); fw_name =FIRMWARE_R200 ; - }else if ((rdev->family ==CHIP_R300 ) || - (rdev->family ==CHIP_R350 ) || - (rdev->family ==CHIP_RV350 ) || - (rdev->family ==CHIP_RV380 ) || - (rdev->family ==CHIP_RS400 ) || - (rdev->family ==CHIP_RS480 )) { +break ; + +case CHIP_R300 : +case CHIP_R350 : +case CHIP_RV350 : +case CHIP_RV380 : +case CHIP_RS400 : +case CHIP_RS480 :DRM_INFO ("Loading R300 Microcode\n" ); fw_name =FIRMWARE_R300 ; - }else if ((rdev->family ==CHIP_R420 ) || - (rdev->family ==CHIP_R423 ) || - (rdev->family ==CHIP_RV410 )) { +break ; + +case CHIP_R420 : +case CHIP_R423 : +case CHIP_RV410 :DRM_INFO ("Loading R400 Microcode\n" ); fw_name =FIRMWARE_R420 ; - }else if ((rdev->family ==CHIP_RS690 ) || - (rdev->family ==CHIP_RS740 )) { +break ; + +case CHIP_RS690 : +case CHIP_RS740 :DRM_INFO ("Loading RS690/RS740 Microcode\n" ); fw_name =FIRMWARE_RS690 ; - }else if (rdev->family ==CHIP_RS600 ) { +break ; + +case CHIP_RS600 :DRM_INFO ("Loading RS600 Microcode\n" ); fw_name =FIRMWARE_RS600 ; - }else if ((rdev->family ==CHIP_RV515 ) || - (rdev->family ==CHIP_R520 ) || - (rdev->family ==CHIP_RV530 ) || - (rdev->family ==CHIP_R580 ) || - (rdev->family ==CHIP_RV560 ) || - (rdev->family ==CHIP_RV570 )) { +break ; + +case CHIP_RV515 : +case CHIP_R520 : +case CHIP_RV530 : +case CHIP_R580 : +case CHIP_RV560 : +case CHIP_RV570 :DRM_INFO ("Loading R500 Microcode\n" ); fw_name =FIRMWARE_R520 ; +break ; + +default : +DRM_ERROR ("Unsupported Radeon family %u\n" , rdev->family); +return -EINVAL ; } err =request_firmware (&rdev->me_fw, fw_name, rdev->dev);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 208/244 drm/amd/display: Unlock Pipes Based On DET Allocation
In reply to Sasha LevinFrom: Austin Zheng <[email protected]>
[ Upstream commit 4af0d8ebf74ccbb60d33fdd410891283dd6cb109 ]
[Why]
DML21 does not allocate DET evenly between pipes. May result in underflow when unlocking the pipes as DET could be overallocated.
[How]
1. Unlock pipes that have a decreased amount of DET allocation
2. Wait for the double buffer to be updated.
3. Unlock the remaining pipes.
--- .../gpu/drm/amd/display/dc/core/dc_resource.c | 28 ++++++ .../display/dc/hubbub/dcn401/dcn401_hubbub.c | 23 +++++ .../amd/display/dc/hwss/dcn401/dcn401_hwseq.c | 91 +++++++++++++++++++ .../amd/display/dc/hwss/dcn401/dcn401_hwseq.h | 2 + .../amd/display/dc/hwss/dcn401/dcn401_init.c | 2 +- .../gpu/drm/amd/display/dc/inc/hw/dchubbub.h | 1 + drivers/gpu/drm/amd/display/dc/inc/resource.h | 5 + 7 files changed, 151 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +28 -0
@@ -5275,3 +5275,31 @@ void resource_init_common_dml2_callbacks(struct dc *dc, struct dml2_configuratio dml2_options->svp_pstate.callbacks.remove_phantom_streams_and_planes = &dc_state_remove_phantom_streams_and_planes; dml2_options->svp_pstate.callbacks.release_phantom_streams_and_planes = &dc_state_release_phantom_streams_and_planes; } + +/* Returns number of DET segments allocated for a given OTG_MASTER pipe */ +int resource_calculate_det_for_stream (struct dc_state *state,struct pipe_ctx *otg_master) +{ +struct pipe_ctx *opp_heads[MAX_PIPES ]; +struct pipe_ctx *dpp_pipes[MAX_PIPES ]; + +int dpp_count =0 ; +int det_segments =0 ; + +if (!otg_master->stream) +return 0 ; + +int slice_count =resource_get_opp_heads_for_otg_master (otg_master, + &state->res_ctx, opp_heads); + +for (int slice_idx =0 ; slice_idx < slice_count; slice_idx++) { +if (opp_heads[slice_idx]->plane_state) { + dpp_count =resource_get_dpp_pipes_for_opp_head ( + opp_heads[slice_idx], + &state->res_ctx, + dpp_pipes); +for (int dpp_idx =0 ; dpp_idx < dpp_count; dpp_idx++) + det_segments += dpp_pipes[dpp_idx]->hubp_regs.det_size; + } + } +return det_segments; +}
drivers/gpu/drm/amd/display/dc/hubbub/dcn401/dcn401_hubbub.c +23 -0
@@ -1170,6 +1170,28 @@ static void dcn401_program_compbuf_segments(struct hubbub *hubbub, unsigned comp } } +static void dcn401_wait_for_det_update (struct hubbub *hubbub,int hubp_inst) +{ +struct dcn20_hubbub *hubbub2 =TO_DCN20_HUBBUB (hubbub); + +switch (hubp_inst) { +case 0 : +REG_WAIT (DCHUBBUB_DET0_CTRL ,DET0_SIZE_CURRENT , hubbub2->det0_size,1 ,100000 );/* 1 vupdate at 10hz */ +break ; +case 1 : +REG_WAIT (DCHUBBUB_DET1_CTRL ,DET1_SIZE_CURRENT , hubbub2->det1_size,1 ,100000 ); +break ; +case 2 : +REG_WAIT (DCHUBBUB_DET2_CTRL ,DET2_SIZE_CURRENT , hubbub2->det2_size,1 ,100000 ); +break ; +case 3 : +REG_WAIT (DCHUBBUB_DET3_CTRL ,DET3_SIZE_CURRENT , hubbub2->det3_size,1 ,100000 ); +break ; +default : +break ; + } +} +static const struct hubbub_funcs hubbub4_01_funcs = { .update_dchub = hubbub2_update_dchub, .init_dchub_sys_ctx = hubbub3_init_dchub_sys_ctx,
@@ -1192,6 +1214,7 @@ static const struct hubbub_funcs hubbub4_01_funcs = { .set_request_limit = hubbub32_set_request_limit, .program_det_segments = dcn401_program_det_segments, .program_compbuf_segments = dcn401_program_compbuf_segments, + .wait_for_det_update = dcn401_wait_for_det_update, }; void hubbub401_construct(struct dcn20_hubbub *hubbub2,
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c +91 -0
94 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.h +2 -0
@@ -81,4 +81,6 @@ void dcn401_hardware_release(struct dc *dc);void dcn401_update_odm (struct dc *dc,struct dc_state *context,struct pipe_ctx *otg_master);void adjust_hotspot_between_slices_for_2x_magnify (uint32_t cursor_width,struct dc_cursor_position *pos_cpy); +void dcn401_wait_for_det_buffer_update (struct dc *dc,struct dc_state *context,struct pipe_ctx *otg_master); +void dcn401_interdependent_update_lock (struct dc *dc,struct dc_state *context,bool lock);#endif /* __DC_HWSS_DCN401_H__ */
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_init.c +1 -1
@@ -38,7 +38,7 @@ static const struct hw_sequencer_funcs dcn401_funcs = { .disable_audio_stream = dce110_disable_audio_stream, .disable_plane = dcn20_disable_plane, .pipe_control_lock = dcn20_pipe_control_lock, - .interdependent_update_lock = dcn32_interdependent_update_lock, + .interdependent_update_lock = dcn401_interdependent_update_lock, .cursor_lock = dcn10_cursor_lock, .prepare_bandwidth = dcn401_prepare_bandwidth, .optimize_bandwidth = dcn401_optimize_bandwidth,
drivers/gpu/drm/amd/display/dc/inc/hw/dchubbub.h +1 -0
@@ -227,6 +227,7 @@ struct hubbub_funcs {void (*get_mall_en)(struct hubbub *hubbub,unsigned int *mall_in_use);void (*program_det_segments)(struct hubbub *hubbub,int hubp_inst,unsigned det_buffer_size_seg);void (*program_compbuf_segments)(struct hubbub *hubbub,unsigned compbuf_size_seg,bool safe_to_increase); +void (*wait_for_det_update)(struct hubbub *hubbub,int hubp_inst); };struct hubbub {
drivers/gpu/drm/amd/display/dc/inc/resource.h +5 -0
@@ -639,4 +639,9 @@ struct dscl_prog_data *resource_get_dscl_prog_data(struct pipe_ctx *pipe_ctx);* @dml2_options: struct to hold callbacks */ void resource_init_common_dml2_callbacks (struct dc *dc,struct dml2_configuration_options *dml2_options); + +/* +*Calculate total DET allocated for all pipes for a given OTG_MASTER pipe +*/ +int resource_calculate_det_for_stream (struct dc_state *state,struct pipe_ctx *otg_master);#endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 209/244 drm/amdgpu: fix ptr check warning in gfx9 ip_dump
In reply to Sasha LevinFrom: Sunil Khatri <[email protected]>
[ Upstream commit 07f4f9c00ec545dfa6251a44a09d2c48a76e7ee5 ]
Change if (ptr == NULL) to if (!ptr) for a better format and fix the warning.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -2
@@ -2133,7 +2133,7 @@ static void gfx_v9_0_alloc_ip_dump(struct amdgpu_device *adev)uint32_t inst; ptr =kcalloc (reg_count,sizeof (uint32_t ),GFP_KERNEL ); -if (ptr ==NULL ) { +if (!ptr) {DRM_ERROR ("Failed to allocate memory for GFX IP Dump\n" ); adev->gfx.ip_dump_core =NULL ; }else {
@@ -2146,7 +2146,7 @@ static void gfx_v9_0_alloc_ip_dump(struct amdgpu_device *adev) adev->gfx.mec.num_queue_per_pipe; ptr =kcalloc (reg_count * inst,sizeof (uint32_t ),GFP_KERNEL ); -if (ptr ==NULL ) { +if (!ptr) {DRM_ERROR ("Failed to allocate memory for Compute Queues IP Dump\n" ); adev->gfx.ip_dump_compute_queues =NULL ; }else {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 210/244 drm/amdgpu: fix ptr check warning in gfx10 ip_dump
In reply to Sasha LevinFrom: Sunil Khatri <[email protected]>
[ Upstream commit 98df5a7732e3b78bf8824d2938a8865a45cfc113 ]
Change condition, if (ptr == NULL) to if (!ptr) for a better format and fix the warning.
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +3 -3
@@ -4649,7 +4649,7 @@ static void gfx_v10_0_alloc_ip_dump(struct amdgpu_device *adev)uint32_t inst; ptr =kcalloc (reg_count,sizeof (uint32_t ),GFP_KERNEL ); -if (ptr ==NULL ) { +if (!ptr) {DRM_ERROR ("Failed to allocate memory for GFX IP Dump\n" ); adev->gfx.ip_dump_core =NULL ; }else {
@@ -4662,7 +4662,7 @@ static void gfx_v10_0_alloc_ip_dump(struct amdgpu_device *adev) adev->gfx.mec.num_queue_per_pipe; ptr =kcalloc (reg_count * inst,sizeof (uint32_t ),GFP_KERNEL ); -if (ptr ==NULL ) { +if (!ptr) {DRM_ERROR ("Failed to allocate memory for Compute Queues IP Dump\n" ); adev->gfx.ip_dump_compute_queues =NULL ; }else {
@@ -4675,7 +4675,7 @@ static void gfx_v10_0_alloc_ip_dump(struct amdgpu_device *adev) adev->gfx.me.num_queue_per_pipe; ptr =kcalloc (reg_count * inst,sizeof (uint32_t ),GFP_KERNEL ); -if (ptr ==NULL ) { +if (!ptr) {DRM_ERROR ("Failed to allocate memory for GFX Queues IP Dump\n" ); adev->gfx.ip_dump_gfx_queues =NULL ; }else {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 211/244 drm/amdgpu: fix ptr check warning in gfx11 ip_dump
In reply to Sasha LevinFrom: Sunil Khatri <[email protected]>
[ Upstream commit bd15f805cdc503ac229a14f5fe21db12e6e7f84a ]
Change condition, if (ptr == NULL) to if (!ptr) for a better format and fix the warning.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +3 -3
@@ -1484,7 +1484,7 @@ static void gfx_v11_0_alloc_ip_dump(struct amdgpu_device *adev)uint32_t inst; ptr =kcalloc (reg_count,sizeof (uint32_t ),GFP_KERNEL ); -if (ptr ==NULL ) { +if (!ptr) {DRM_ERROR ("Failed to allocate memory for GFX IP Dump\n" ); adev->gfx.ip_dump_core =NULL ; }else {
@@ -1497,7 +1497,7 @@ static void gfx_v11_0_alloc_ip_dump(struct amdgpu_device *adev) adev->gfx.mec.num_queue_per_pipe; ptr =kcalloc (reg_count * inst,sizeof (uint32_t ),GFP_KERNEL ); -if (ptr ==NULL ) { +if (!ptr) {DRM_ERROR ("Failed to allocate memory for Compute Queues IP Dump\n" ); adev->gfx.ip_dump_compute_queues =NULL ; }else {
@@ -1510,7 +1510,7 @@ static void gfx_v11_0_alloc_ip_dump(struct amdgpu_device *adev) adev->gfx.me.num_queue_per_pipe; ptr =kcalloc (reg_count * inst,sizeof (uint32_t ),GFP_KERNEL ); -if (ptr ==NULL ) { +if (!ptr) {DRM_ERROR ("Failed to allocate memory for GFX Queues IP Dump\n" ); adev->gfx.ip_dump_gfx_queues =NULL ; }else {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 212/244 drm/amdgpu: Block MMR_READ IOCTL in reset
In reply to Sasha LevinFrom: Victor Skvortsov <[email protected]>
[ Upstream commit 9e823f307074c0f82b5f6044943b0086e3079bed ]
Register access from userspace should be blocked until reset is complete.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 43 ++++++++++++++++++------- 1 file changed, 31 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +31 -12
@@ -43,6 +43,7 @@#include "amdgpu_gem.h" #include "amdgpu_display.h" #include "amdgpu_ras.h" +#include "amdgpu_reset.h" #include "amd_pcie.h" void amdgpu_unregister_gpu_instance (struct amdgpu_device *adev)
@@ -778,6 +779,7 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) ? -EFAULT :0 ; }case AMDGPU_INFO_READ_MMR_REG : { +int ret =0 ;unsigned int n, alloc_size;uint32_t *regs; unsigned int se_num = (info->read_mmr_reg.instance >>
@@ -787,24 +789,37 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) AMDGPU_INFO_MMR_SH_INDEX_SHIFT) &AMDGPU_INFO_MMR_SH_INDEX_MASK ; +if (!down_read_trylock (&adev->reset_domain->sem)) +return -ENOENT ; +/* set full masks if the userspace set all bits * in the bitfields */ -if (se_num ==AMDGPU_INFO_MMR_SE_INDEX_MASK ) +if (se_num ==AMDGPU_INFO_MMR_SE_INDEX_MASK ) { se_num =0xffffffff ; -else if (se_num >=AMDGPU_GFX_MAX_SE ) -return -EINVAL ; -if (sh_num ==AMDGPU_INFO_MMR_SH_INDEX_MASK ) + }else if (se_num >=AMDGPU_GFX_MAX_SE ) { + ret = -EINVAL ; + goto out; + } + +if (sh_num ==AMDGPU_INFO_MMR_SH_INDEX_MASK ) { sh_num =0xffffffff ; -else if (sh_num >=AMDGPU_GFX_MAX_SH_PER_SE ) -return -EINVAL ; + }else if (sh_num >=AMDGPU_GFX_MAX_SH_PER_SE ) { + ret = -EINVAL ; + goto out; + } -if (info->read_mmr_reg.count >128 ) -return -EINVAL ; +if (info->read_mmr_reg.count >128 ) { + ret = -EINVAL ; + goto out; + } regs =kmalloc_array (info->read_mmr_reg.count,sizeof (*regs),GFP_KERNEL ); -if (!regs) -return -ENOMEM ; +if (!regs) { + ret = -ENOMEM ; + goto out; + } + alloc_size = info->read_mmr_reg.count *sizeof (*regs);amdgpu_gfx_off_ctrl (adev, false);
@@ -816,13 +831,17 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) info->read_mmr_reg.dword_offset + i);kfree (regs);amdgpu_gfx_off_ctrl (adev, true); -return -EFAULT ; + ret = -EFAULT ; + goto out; } }amdgpu_gfx_off_ctrl (adev, true); n =copy_to_user (out, regs,min (size, alloc_size));kfree (regs); -return n ? -EFAULT :0 ; + ret = (n ? -EFAULT :0 ); +out: +up_read (&adev->reset_domain->sem); +return ret; }case AMDGPU_INFO_DEV_INFO : {struct drm_amdgpu_info_device *dev_info;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 213/244 drm/amdgpu/gfx9: use rlc safe mode for soft recovery
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit 3ec2ad7c34c412bd9264cd1ff235d0812be90e82 ]
Protect the MMIO access with safe mode.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -0
@@ -5862,7 +5862,9 @@ static void gfx_v9_0_ring_soft_recovery(struct amdgpu_ring *ring, unsigned vmid) value =REG_SET_FIELD (value,SQ_CMD ,MODE ,0x01 ); value =REG_SET_FIELD (value,SQ_CMD ,CHECK_VMID ,1 ); value =REG_SET_FIELD (value,SQ_CMD ,VM_ID , vmid); +amdgpu_gfx_rlc_enter_safe_mode (adev,0 );WREG32_SOC15 (GC ,0 , mmSQ_CMD, value); +amdgpu_gfx_rlc_exit_safe_mode (adev,0 ); } static void gfx_v9_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 214/244 drm/amdgpu/gfx11: enter safe mode before touching CP_INT_CNTL
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit b5be054c585110b2c5c1b180136800e8c41c7bb4 ]
Need to enter safe mode before touching GC MMIO.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2 -2
@@ -4707,6 +4707,8 @@ static int gfx_v11_0_soft_reset(void *handle)int r, i, j, k;struct amdgpu_device *adev = (struct amdgpu_device *)handle; +gfx_v11_0_set_safe_mode (adev,0 ); + tmp =RREG32_SOC15 (GC ,0 , regCP_INT_CNTL); tmp =REG_SET_FIELD (tmp,CP_INT_CNTL ,CMP_BUSY_INT_ENABLE ,0 ); tmp =REG_SET_FIELD (tmp,CP_INT_CNTL ,CNTX_BUSY_INT_ENABLE ,0 );
@@ -4714,8 +4716,6 @@ static int gfx_v11_0_soft_reset(void *handle) tmp =REG_SET_FIELD (tmp,CP_INT_CNTL ,GFX_IDLE_INT_ENABLE ,0 );WREG32_SOC15 (GC ,0 , regCP_INT_CNTL, tmp); -gfx_v11_0_set_safe_mode (adev,0 ); -mutex_lock (&adev->srbm_mutex);for (i =0 ; i < adev->gfx.mec.num_mec; ++i) {for (j =0 ; j < adev->gfx.mec.num_queue_per_pipe; j++) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 215/244 drm/xe: Use topology to determine page fault queue size
In reply to Sasha LevinFrom: Stuart Summers <[email protected]>
[ Upstream commit 3338e4f90c143cf32f77d64f464cb7f2c2d24700 ]
Currently the page fault queue size is hard coded. However the hardware supports faulting for each EU and each CS. For some applications running on hardware with a large number of EUs and CSs, this can result in an overflow of the page fault queue.
Add a small calculation to determine the page fault queue size based on the number of EUs and CSs in the platform as detmined by fuses.
--- drivers/gpu/drm/xe/xe_gt_pagefault.c | 54 +++++++++++++++++++++------- drivers/gpu/drm/xe/xe_gt_types.h | 9 +++-- 2 files changed, 49 insertions(+), 14 deletions(-)
drivers/gpu/drm/xe/xe_gt_pagefault.c +42 -12
@@ -287,7 +287,7 @@ static bool get_pagefault(struct pf_queue *pf_queue, struct pagefault *pf)PFD_VIRTUAL_ADDR_LO_SHIFT ; pf_queue->tail = (pf_queue->tail +PF_MSG_LEN_DW ) % -PF_QUEUE_NUM_DW ; + pf_queue->num_dw; ret = true; }spin_unlock_irq (&pf_queue->lock);
@@ -299,7 +299,8 @@ static bool pf_queue_full(struct pf_queue *pf_queue) {lockdep_assert_held (&pf_queue->lock); -return CIRC_SPACE (pf_queue->head, pf_queue->tail,PF_QUEUE_NUM_DW ) <= +return CIRC_SPACE (pf_queue->head, pf_queue->tail, + pf_queue->num_dw) <=PF_MSG_LEN_DW ; }
@@ -312,22 +313,23 @@ int xe_guc_pagefault_handler(struct xe_guc *guc, u32 *msg, u32 len)u32 asid;bool full; -/* -* The below logic doesn't work unless PF_QUEUE_NUM_DW % PF_MSG_LEN_DW == 0 -*/ -BUILD_BUG_ON (PF_QUEUE_NUM_DW %PF_MSG_LEN_DW ); -if (unlikely (len !=PF_MSG_LEN_DW ))return -EPROTO ; asid =FIELD_GET (PFD_ASID , msg[1 ]); pf_queue = gt->usm.pf_queue + (asid %NUM_PF_QUEUE ); +/* +* The below logic doesn't work unless PF_QUEUE_NUM_DW % PF_MSG_LEN_DW == 0 +*/ +xe_gt_assert (gt, !(pf_queue->num_dw %PF_MSG_LEN_DW )); +spin_lock_irqsave (&pf_queue->lock, flags); full =pf_queue_full (pf_queue);if (!full) {memcpy (pf_queue->data + pf_queue->head, msg, len *sizeof (u32)); - pf_queue->head = (pf_queue->head + len) %PF_QUEUE_NUM_DW ; + pf_queue->head = (pf_queue->head + len) % + pf_queue->num_dw;queue_work (gt->usm.pf_wq, &pf_queue->worker); }else {drm_warn (&xe->drm,"PF Queue full, shouldn't be possible" );
@@ -386,26 +388,54 @@ static void pagefault_fini(void *arg) {struct xe_gt *gt = arg;struct xe_device *xe =gt_to_xe (gt); +int i;if (!xe->info.has_usm)return ;destroy_workqueue (gt->usm.acc_wq);destroy_workqueue (gt->usm.pf_wq); + +for (i =0 ; i <NUM_PF_QUEUE ; ++i) +kfree (gt->usm.pf_queue[i].data); +} + +static int xe_alloc_pf_queue (struct xe_gt *gt,struct pf_queue *pf_queue) +{ +xe_dss_mask_t all_dss; +int num_dss, num_eus; + +bitmap_or (all_dss, gt->fuse_topo.g_dss_mask, gt->fuse_topo.c_dss_mask, +XE_MAX_DSS_FUSE_BITS ); + + num_dss =bitmap_weight (all_dss,XE_MAX_DSS_FUSE_BITS ); + num_eus =bitmap_weight (gt->fuse_topo.eu_mask_per_dss, +XE_MAX_EU_FUSE_BITS ) * num_dss; + +/* user can issue separate page faults per EU and per CS */ + pf_queue->num_dw = + (num_eus +XE_NUM_HW_ENGINES ) *PF_MSG_LEN_DW ; + + pf_queue->gt = gt; + pf_queue->data =kzalloc (pf_queue->num_dw,GFP_KERNEL ); +spin_lock_init (&pf_queue->lock); +INIT_WORK (&pf_queue->worker, pf_queue_work_func); + +return 0 ; }int xe_gt_pagefault_init (struct xe_gt *gt) {struct xe_device *xe =gt_to_xe (gt); -int i; +int i, ret =0 ;if (!xe->info.has_usm)return 0 ;for (i =0 ; i <NUM_PF_QUEUE ; ++i) { - gt->usm.pf_queue[i].gt = gt; -spin_lock_init (>->usm.pf_queue[i].lock); -INIT_WORK (>->usm.pf_queue[i].worker, pf_queue_work_func); + ret =xe_alloc_pf_queue (gt, >->usm.pf_queue[i]); +if (ret) +return ret; }for (i =0 ; i <NUM_ACC_QUEUE ; ++i) { gt->usm.acc_queue[i].gt = gt;
drivers/gpu/drm/xe/xe_gt_types.h +7 -2
@@ -233,9 +233,14 @@ struct xe_gt {struct pf_queue {/** @usm.pf_queue.gt: back pointer to GT */ struct xe_gt *gt; -#define PF_QUEUE_NUM_DW 128/** @usm.pf_queue.data: data in the page fault queue */ -u32 data[PF_QUEUE_NUM_DW ]; +u32 *data; +/** +* @usm.pf_queue.num_dw: number of DWORDS in the page +* fault queue. Dynamically calculated based on the number +* of compute resources available. +*/ +u32 num_dw;/** * @usm.pf_queue.tail: tail pointer in DWs for page fault queue, * moved by worker which processes faults (consumer).
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 216/244 drm/amd/pm: ensure the fw_info is not null before using it
In reply to Sasha LevinFrom: Tim Huang <[email protected]>
[ Upstream commit 186fb12e7a7b038c2710ceb2fb74068f1b5d55a4 ]
This resolves the dereference null return value warning reported by Coverity.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c +2 -0
@@ -1183,6 +1183,8 @@ static int init_overdrive_limits(struct pp_hwmgr *hwmgr, fw_info =smu_atom_get_data_table (hwmgr->adev,GetIndexIntoMasterTable (DATA , FirmwareInfo), &size, &frev, &crev); +PP_ASSERT_WITH_CODE (fw_info !=NULL , +"Missing firmware info!" , return -EINVAL );if ((fw_info->ucTableFormatRevision ==1 ) && (le16_to_cpu (fw_info->usStructureSize) >=sizeof (ATOM_FIRMWARE_INFO_V1_4 )))
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 217/244 drm/amdkfd: Check int source id for utcl2 poison event
In reply to Sasha LevinFrom: Hawking Zhang <[email protected]>
[ Upstream commit db6341a9168d2a24ded526277eeab29724d76e9d ]
Traditional utcl2 fault_status polling does not work in SRIOV environment. The polling of fault status register from guest side will be dropped by hardware.
Driver should switch to check utcl2 interrupt source id to identify utcl2 poison event. It is set to 1 when poisoned data interrupts are signaled.
v2: drop the unused local variable (Tao)
--- .../gpu/drm/amd/amdkfd/kfd_int_process_v9.c | 18 +----------------- drivers/gpu/drm/amd/amdkfd/soc15_int.h | 1 + 2 files changed, 2 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c +1 -17
@@ -431,25 +431,9 @@ static void event_interrupt_wq_v9(struct kfd_node *dev, client_id == SOC15_IH_CLIENTID_UTCL2) {struct kfd_vm_fault_info info = {0 };uint16_t ring_id =SOC15_RING_ID_FROM_IH_ENTRY (ih_ring_entry); -uint32_t node_id =SOC15_NODEID_FROM_IH_ENTRY (ih_ring_entry); -uint32_t vmid_type =SOC15_VMID_TYPE_FROM_IH_ENTRY (ih_ring_entry); -int hub_inst =0 ;struct kfd_hsa_memory_exception_data exception_data; -/* gfxhub */ -if (!vmid_type && dev->adev->gfx.funcs->ih_node_to_logical_xcc) { - hub_inst = dev->adev->gfx.funcs->ih_node_to_logical_xcc (dev->adev, - node_id); -if (hub_inst <0 ) - hub_inst =0 ; - } - -/* mmhub */ -if (vmid_type && client_id ==SOC15_IH_CLIENTID_VMC ) - hub_inst = node_id /4 ; - -if (amdgpu_amdkfd_ras_query_utcl2_poison_status (dev->adev, - hub_inst, vmid_type)) { +if (source_id ==SOC15_INTSRC_VMC_UTCL2_POISON ) {event_interrupt_poison_consumption_v9 (dev, pasid, client_id);return ; }
drivers/gpu/drm/amd/amdkfd/soc15_int.h +1 -0
@@ -29,6 +29,7 @@#define SOC15_INTSRC_CP_BAD_OPCODE 183#define SOC15_INTSRC_SQ_INTERRUPT_MSG 239#define SOC15_INTSRC_VMC_FAULT 0 +#define SOC15_INTSRC_VMC_UTCL2_POISON 1#define SOC15_INTSRC_SDMA_TRAP 224#define SOC15_INTSRC_SDMA_ECC 220#define SOC21_INTSRC_SDMA_TRAP 49
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 218/244 drm/xe: Drop warn on xe_guc_pc_gucrc_disable in guc pc fini
In reply to Sasha LevinFrom: Matthew Brost <[email protected]>
[ Upstream commit a323782567812ee925e9b7926445532c7afe331b ]
Not a big deal if CT is down as driver is unloading, no need to warn.
--- drivers/gpu/drm/xe/xe_guc_pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_guc_pc.c +1 -1
@@ -1042,7 +1042,7 @@ static void xe_guc_pc_fini_hw(void *arg)return ;XE_WARN_ON (xe_force_wake_get (gt_to_fw (pc_to_gt (pc)),XE_FORCEWAKE_ALL )); -XE_WARN_ON (xe_guc_pc_gucrc_disable (pc)); +xe_guc_pc_gucrc_disable (pc);XE_WARN_ON (xe_guc_pc_stop (pc));/* Bind requested freq to mert_freq_cap before unload */
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 219/244 of/irq: Refer to actual buffer size in of_irq_parse_one()
In reply to Sasha LevinFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 39ab331ab5d377a18fbf5a0e0b228205edfcc7f4 ]
Replace two open-coded calculations of the buffer size by invocations of sizeof() on the buffer itself, to make sure the code will always use the actual buffer size.
--- drivers/of/irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/of/irq.c +2 -2
@@ -357,8 +357,8 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar addr =of_get_property (device,"reg" , &addr_len);/* Prevent out-of-bounds read in case of longer interrupt parent address size */ -if (addr_len > (3 *sizeof (__be32))) - addr_len =3 *sizeof (__be32); +if (addr_len >sizeof (addr_buf)) + addr_len =sizeof (addr_buf);if (addr)memcpy (addr_buf, addr, addr_len);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 220/244 drm/amd/display: guard write a 0 post_divider value to HW
In reply to Sasha LevinFrom: "Ahmed, Muhammad" <[email protected]>
[ Upstream commit 5d666496c24129edeb2bcb500498b87cc64e7f07 ]
[why]post_divider_value should not be 0.
--- drivers/gpu/drm/amd/display/dc/dccg/dcn35/dcn35_dccg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dccg/dcn35/dcn35_dccg.c +2 -1
@@ -47,7 +47,8 @@ static void dccg35_trigger_dio_fifo_resync(struct dccg *dccg)uint32_t dispclk_rdivider_value =0 ;REG_GET (DENTIST_DISPCLK_CNTL ,DENTIST_DISPCLK_RDIVIDER , &dispclk_rdivider_value); -REG_UPDATE (DENTIST_DISPCLK_CNTL ,DENTIST_DISPCLK_WDIVIDER , dispclk_rdivider_value); +if (dispclk_rdivider_value !=0 ) +REG_UPDATE (DENTIST_DISPCLK_CNTL ,DENTIST_DISPCLK_WDIVIDER , dispclk_rdivider_value); } static void dcn35_set_dppclk_enable(struct dccg *dccg,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 221/244 powerpc/pseries: Use correct data types from pseries_hp_errorlog struct
In reply to Sasha LevinFrom: Haren Myneni <[email protected]>
[ Upstream commit b76e0d4215b6b622127ebcceaa7f603313ceaec4 ]
_be32 type is defined for some elements in pseries_hp_errorlog struct but also used them u32 after be32_to_cpu() conversion.
Example: In handle_dlpar_errorlog() hp_elog->_drc_u.drc_index = be32_to_cpu(hp_elog->_drc_u.drc_index);
And later assigned to u32 typedlpar_cpu() - u32 drc_index = hp_elog->_drc_u.drc_index;
This incorrect usage is giving the following warnings and the patch resolve these warnings with the correct assignment.
arch/powerpc/platforms/pseries/dlpar.c:398:53: sparse: sparse:
incorrect type in argument 1 (different base types) @@ expected unsigned int [usertype] drc_index @@
got restricted __be32 [usertype] drc_index @@
...arch/powerpc/platforms/pseries/dlpar.c:418:43: sparse: sparse:
incorrect type in assignment (different base types) @@ expected restricted __be32 [usertype] drc_count @@ got unsigned int [usertype] @@
v3:
- Fix warnings from using incorrect data types in pseries_hp_errorlog struct
v2:
- Remove pr_info() and TODO comments
- Update more information in the commit logs
--- arch/powerpc/platforms/pseries/dlpar.c | 17 ----------------- arch/powerpc/platforms/pseries/hotplug-cpu.c | 2 +- arch/powerpc/platforms/pseries/hotplug-memory.c | 16 ++++++++-------- arch/powerpc/platforms/pseries/pmem.c | 2 +- 4 files changed, 10 insertions(+), 27 deletions(-)
arch/powerpc/platforms/pseries/dlpar.c +0 -17
@@ -334,23 +334,6 @@ int handle_dlpar_errorlog(struct pseries_hp_errorlog *hp_elog) {int rc; -/* pseries error logs are in BE format, convert to cpu type */ -switch (hp_elog->id_type) { -case PSERIES_HP_ELOG_ID_DRC_COUNT : - hp_elog->_drc_u.drc_count = -be32_to_cpu (hp_elog->_drc_u.drc_count); -break ; -case PSERIES_HP_ELOG_ID_DRC_INDEX : - hp_elog->_drc_u.drc_index = -be32_to_cpu (hp_elog->_drc_u.drc_index); -break ; -case PSERIES_HP_ELOG_ID_DRC_IC : - hp_elog->_drc_u.ic.count = -be32_to_cpu (hp_elog->_drc_u.ic.count); - hp_elog->_drc_u.ic.index = -be32_to_cpu (hp_elog->_drc_u.ic.index); - } -switch (hp_elog->resource) {case PSERIES_HP_ELOG_RESOURCE_MEM : rc =dlpar_memory (hp_elog);
arch/powerpc/platforms/pseries/hotplug-cpu.c +1 -1
@@ -757,7 +757,7 @@ int dlpar_cpu(struct pseries_hp_errorlog *hp_elog)u32 drc_index;int rc; - drc_index = hp_elog->_drc_u.drc_index; + drc_index =be32_to_cpu (hp_elog->_drc_u.drc_index);lock_device_hotplug ();
arch/powerpc/platforms/pseries/hotplug-memory.c +8 -8
@@ -817,16 +817,16 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)case PSERIES_HP_ELOG_ACTION_ADD :switch (hp_elog->id_type) {case PSERIES_HP_ELOG_ID_DRC_COUNT : - count = hp_elog->_drc_u.drc_count; + count =be32_to_cpu (hp_elog->_drc_u.drc_count); rc =dlpar_memory_add_by_count (count);break ;case PSERIES_HP_ELOG_ID_DRC_INDEX : - drc_index = hp_elog->_drc_u.drc_index; + drc_index =be32_to_cpu (hp_elog->_drc_u.drc_index); rc =dlpar_memory_add_by_index (drc_index);break ;case PSERIES_HP_ELOG_ID_DRC_IC : - count = hp_elog->_drc_u.ic.count; - drc_index = hp_elog->_drc_u.ic.index; + count =be32_to_cpu (hp_elog->_drc_u.ic.count); + drc_index =be32_to_cpu (hp_elog->_drc_u.ic.index); rc =dlpar_memory_add_by_ic (count, drc_index);break ;default :
@@ -838,16 +838,16 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)case PSERIES_HP_ELOG_ACTION_REMOVE :switch (hp_elog->id_type) {case PSERIES_HP_ELOG_ID_DRC_COUNT : - count = hp_elog->_drc_u.drc_count; + count =be32_to_cpu (hp_elog->_drc_u.drc_count); rc =dlpar_memory_remove_by_count (count);break ;case PSERIES_HP_ELOG_ID_DRC_INDEX : - drc_index = hp_elog->_drc_u.drc_index; + drc_index =be32_to_cpu (hp_elog->_drc_u.drc_index); rc =dlpar_memory_remove_by_index (drc_index);break ;case PSERIES_HP_ELOG_ID_DRC_IC : - count = hp_elog->_drc_u.ic.count; - drc_index = hp_elog->_drc_u.ic.index; + count =be32_to_cpu (hp_elog->_drc_u.ic.count); + drc_index =be32_to_cpu (hp_elog->_drc_u.ic.index); rc =dlpar_memory_remove_by_ic (count, drc_index);break ;default :
arch/powerpc/platforms/pseries/pmem.c +1 -1
@@ -121,7 +121,7 @@ int dlpar_hp_pmem(struct pseries_hp_errorlog *hp_elog)return -EINVAL ; } - drc_index = hp_elog->_drc_u.drc_index; + drc_index =be32_to_cpu (hp_elog->_drc_u.drc_index);lock_device_hotplug ();
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 222/244 ovl: fsync after metadata copy-up
In reply to Sasha LevinFrom: Amir Goldstein <[email protected]>
[ Upstream commit 7d6899fb69d25e1bc6f4700b7c1d92e6b608593d ]
For upper filesystems which do not use strict ordering of persisting metadata changes (e.g. ubifs), when overlayfs file is modified for the first time, copy up will create a copy of the lower file and its parent directories in the upper layer. Permission lost of the new upper parent directory was observed during power-cut stress test.
Fix by moving the fsync call to after metadata copy to make sure that the metadata copied up directory and files persists to disk before renaming from tmp to final destination.
With metacopy enabled, this change will hurt performance of workloads such as chown -R, so we keep the legacy behavior of fsync only on copyup of data.
--- fs/overlayfs/copy_up.c | 43 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-)
fs/overlayfs/copy_up.c +39 -4
@@ -243,8 +243,24 @@ static int ovl_verify_area(loff_t pos, loff_t pos2, loff_t len, loff_t totlen)return 0 ; } +static int ovl_sync_file (struct path *path) +{ +struct file *new_file; +int err; + + new_file =ovl_path_open (path,O_LARGEFILE |O_RDONLY ); +if (IS_ERR (new_file)) +return PTR_ERR (new_file); + + err =vfs_fsync (new_file,0 ); +fput (new_file); + +return err; +} +static int ovl_copy_up_file (struct ovl_fs *ofs,struct dentry *dentry, -struct file *new_file,loff_t len) +struct file *new_file,loff_t len, +bool datasync) {struct path datapath;struct file *old_file;
@@ -342,7 +358,8 @@ static int ovl_copy_up_file(struct ovl_fs *ofs, struct dentry *dentry, len -= bytes; } -if (!error &&ovl_should_sync (ofs)) +/* call fsync once, either now or later along with metadata */ +if (!error &&ovl_should_sync (ofs) && datasync) error =vfs_fsync (new_file,0 ); out_fput:fput (old_file);
@@ -574,6 +591,7 @@ struct ovl_copy_up_ctx {bool indexed;bool metacopy;bool metacopy_digest; +bool metadata_fsync; };static int ovl_link_up (struct ovl_copy_up_ctx *c)
@@ -634,7 +652,8 @@ static int ovl_copy_up_data(struct ovl_copy_up_ctx *c, const struct path *temp)if (IS_ERR (new_file))return PTR_ERR (new_file); - err =ovl_copy_up_file (ofs, c->dentry, new_file, c->stat.size); + err =ovl_copy_up_file (ofs, c->dentry, new_file, c->stat.size, + !c->metadata_fsync);fput (new_file);return err;
@@ -701,6 +720,10 @@ static int ovl_copy_up_metadata(struct ovl_copy_up_ctx *c, struct dentry *temp) err =ovl_set_attr (ofs, temp, &c->stat);inode_unlock (temp->d_inode); +/* fsync metadata before moving it into upper dir */ +if (!err &&ovl_should_sync (ofs) && c->metadata_fsync) + err =ovl_sync_file (&upperpath); +return err; }
@@ -860,7 +883,8 @@ static int ovl_copy_up_tmpfile(struct ovl_copy_up_ctx *c) temp = tmpfile->f_path.dentry;if (!c->metacopy && c->stat.size) { - err =ovl_copy_up_file (ofs, c->dentry, tmpfile, c->stat.size); + err =ovl_copy_up_file (ofs, c->dentry, tmpfile, c->stat.size, + !c->metadata_fsync);if (err) goto out_fput; }
@@ -1135,6 +1159,17 @@ static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry, !kgid_has_mapping(current_user_ns(), ctx.stat.gid))return -EOVERFLOW ; +/* +* With metacopy disabled, we fsync after final metadata copyup, for +* both regular files and directories to get atomic copyup semantics +* on filesystems that do not use strict metadata ordering (e.g. ubifs). +* +* With metacopy enabled we want to avoid fsync on all meta copyup +* that will hurt performance of workloads such as chown -R, so we +* only fsync on data copyup as legacy behavior. +*/ + ctx.metadata_fsync = !OVL_FS (dentry->d_sb)->config.metacopy && + (S_ISREG (ctx.stat.mode) ||S_ISDIR (ctx.stat.mode)); ctx.metacopy =ovl_need_meta_copy_up (dentry, ctx.stat.mode, flags);if (parent) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 223/244 drm/amdgpu/gfx12: use rlc safe mode for soft recovery
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit 21818f39beda2e843199e5d8d9e3f9e43c8080a3 ]
Protect the MMIO access with safe mode.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +2 -0
@@ -4605,7 +4605,9 @@ static void gfx_v12_0_ring_soft_recovery(struct amdgpu_ring *ring, value =REG_SET_FIELD (value,SQ_CMD ,MODE ,0x01 ); value =REG_SET_FIELD (value,SQ_CMD ,CHECK_VMID ,1 ); value =REG_SET_FIELD (value,SQ_CMD ,VM_ID , vmid); +amdgpu_gfx_rlc_enter_safe_mode (adev,0 );WREG32_SOC15 (GC ,0 , regSQ_CMD, value); +amdgpu_gfx_rlc_exit_safe_mode (adev,0 ); } static void
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 224/244 drm/amdgpu/gfx11: use rlc safe mode for soft recovery
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit 3f2d35c325534c1b7ac5072173f0dc7ca969dec2 ]
Protect the MMIO access with safe mode.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2 -0
@@ -6008,7 +6008,9 @@ static void gfx_v11_0_ring_soft_recovery(struct amdgpu_ring *ring, value =REG_SET_FIELD (value,SQ_CMD ,MODE ,0x01 ); value =REG_SET_FIELD (value,SQ_CMD ,CHECK_VMID ,1 ); value =REG_SET_FIELD (value,SQ_CMD ,VM_ID , vmid); +amdgpu_gfx_rlc_enter_safe_mode (adev,0 );WREG32_SOC15 (GC ,0 , regSQ_CMD, value); +amdgpu_gfx_rlc_exit_safe_mode (adev,0 ); } static void
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 225/244 drm/amdgpu/gfx10: use rlc safe mode for soft recovery
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit ead60e9c4e29c8574cae1be4fe3af1d9a978fb0f ]
Protect the MMIO access with safe mode.
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2 -0
@@ -8889,7 +8889,9 @@ static void gfx_v10_0_ring_soft_recovery(struct amdgpu_ring *ring, value =REG_SET_FIELD (value,SQ_CMD ,MODE ,0x01 ); value =REG_SET_FIELD (value,SQ_CMD ,CHECK_VMID ,1 ); value =REG_SET_FIELD (value,SQ_CMD ,VM_ID , vmid); +amdgpu_gfx_rlc_enter_safe_mode (adev,0 );WREG32_SOC15 (GC ,0 , mmSQ_CMD, value); +amdgpu_gfx_rlc_exit_safe_mode (adev,0 ); } static void
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 226/244 platform/x86: lenovo-ymc: Ignore the 0x0 state
In reply to Sasha LevinFrom: Gergo Koteles <[email protected]>
[ Upstream commit d9dca215708d32e7f88ac0591fbb187cbf368adb ]
While booting, Lenovo 14ARB7 reports 'lenovo-ymc: Unknown key 0 pressed' warning. This is caused by lenovo_ymc_probe() calling lenovo_ymc_notify() at probe time to get the initial tablet-mode-switch state and the key-code lenovo_ymc_notify() reads from the firmware is not initialized at probe time yet on the Lenovo 14ARB7.
The hardware/firmware does an ACPI notify on the WMI device itself when it initializes the tablet-mode-switch state later on.
Add 0x0 YMC state to the sparse keymap to silence the warning.
--- drivers/platform/x86/lenovo-ymc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/platform/x86/lenovo-ymc.c +2 -0
@@ -43,6 +43,8 @@ struct lenovo_ymc_private { };static const struct key_entry lenovo_ymc_keymap[] = { +/* Ignore the uninitialized state */ + {KE_IGNORE ,0x00 },/* Laptop */ {KE_SW ,0x01 , { .sw = {SW_TABLET_MODE ,0 } } },/* Tablet */
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 227/244 tools/hv: Add memory allocation check in hv_fcopy_start
In reply to Sasha LevinFrom: Zhu Jun <[email protected]>
[ Upstream commit 94e86b174d103d941b4afc4f016af8af9e5352fa ]
Added error handling for memory allocation failures of file_name and path_name.
Message-ID: <[email protected]>
--- tools/hv/hv_fcopy_uio_daemon.c | 7 +++++++ 1 file changed, 7 insertions(+)
tools/hv/hv_fcopy_uio_daemon.c +7 -0
@@ -296,6 +296,13 @@ static int hv_fcopy_start(struct hv_start_fcopy *smsg_in) file_name = (char *)malloc (file_size *sizeof (char )); path_name = (char *)malloc (path_size *sizeof (char )); +if (!file_name || !path_name) { +free (file_name); +free (path_name); +syslog (LOG_ERR ,"Can't allocate memory for file name and/or path name" ); +return HV_E_FAIL ; + } +wcstoutf8 (file_name, (__u16 *)in_file_name, file_size);wcstoutf8 (path_name, (__u16 *)in_path_name, path_size);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 228/244 HID: i2c-hid: ensure various commands do not interfere with each other
In reply to Sasha LevinFrom: Dmitry Torokhov <[email protected]>
[ Upstream commit b4ed18a3d56eabd18cfd9841ff05111e3cfbe8f9 ]
i2c-hid uses 2 shared buffers: command and "raw" input buffer for sending requests to peripherals and read data from peripherals when executing variety of commands. Such commands include reading of HID registers, requesting particular power mode, getting and setting reports and so on. Because all such requests use the same 2 buffers they should not execute simultaneously.
Fix this by introducing "cmd_lock" mutex and acquire it whenever we needs to access ihid->cmdbuf or idid->rawbuf.
--- drivers/hid/i2c-hid/i2c-hid-core.c | 42 +++++++++++++++++++----------- 1 file changed, 27 insertions(+), 15 deletions(-)
drivers/hid/i2c-hid/i2c-hid-core.c +27 -15
@@ -105,6 +105,7 @@ struct i2c_hid {wait_queue_head_t wait;/* For waiting the interrupt */ +struct mutex cmd_lock;/* protects cmdbuf and rawbuf */ struct mutex reset_lock;struct i2chid_ops *ops;
@@ -220,6 +221,8 @@ static int i2c_hid_xfer(struct i2c_hid *ihid,static int i2c_hid_read_register (struct i2c_hid *ihid,__le16 reg,void *buf,size_t len) { +guard (mutex)(&ihid->cmd_lock); + *(__le16 *)ihid->cmdbuf = reg;return i2c_hid_xfer (ihid, ihid->cmdbuf,sizeof (__le16), buf, len);
@@ -252,6 +255,8 @@ static int i2c_hid_get_report(struct i2c_hid *ihid,i2c_hid_dbg (ihid,"%s\n" , __func__); +guard (mutex)(&ihid->cmd_lock); +/* Command register goes first */ *(__le16 *)ihid->cmdbuf = ihid->hdesc.wCommandRegister; length +=sizeof (__le16);
@@ -342,6 +347,8 @@ static int i2c_hid_set_or_send_report(struct i2c_hid *ihid,if (!do_set &&le16_to_cpu (ihid->hdesc.wMaxOutputLength) ==0 )return -ENOSYS ; +guard (mutex)(&ihid->cmd_lock); +if (do_set) {/* Command register goes first */ *(__le16 *)ihid->cmdbuf = ihid->hdesc.wCommandRegister;
@@ -384,6 +391,8 @@ static int i2c_hid_set_power_command(struct i2c_hid *ihid, int power_state) {size_t length; +guard (mutex)(&ihid->cmd_lock); +/* SET_POWER uses command register */ *(__le16 *)ihid->cmdbuf = ihid->hdesc.wCommandRegister; length =sizeof (__le16);
@@ -440,25 +449,27 @@ static int i2c_hid_start_hwreset(struct i2c_hid *ihid)if (ret)return ret; -/* Prepare reset command. Command register goes first. */ - *(__le16 *)ihid->cmdbuf = ihid->hdesc.wCommandRegister; - length +=sizeof (__le16); -/* Next is RESET command itself */ - length +=i2c_hid_encode_command (ihid->cmdbuf + length, -I2C_HID_OPCODE_RESET ,0 ,0 ); + scoped_guard(mutex, &ihid->cmd_lock) { +/* Prepare reset command. Command register goes first. */ + *(__le16 *)ihid->cmdbuf = ihid->hdesc.wCommandRegister; + length +=sizeof (__le16); +/* Next is RESET command itself */ + length +=i2c_hid_encode_command (ihid->cmdbuf + length, +I2C_HID_OPCODE_RESET ,0 ,0 ); -set_bit (I2C_HID_RESET_PENDING , &ihid->flags); +set_bit (I2C_HID_RESET_PENDING , &ihid->flags); - ret =i2c_hid_xfer (ihid, ihid->cmdbuf, length,NULL ,0 ); -if (ret) { -dev_err (&ihid->client->dev, -"failed to reset device: %d\n" , ret); - goto err_clear_reset; - } + ret =i2c_hid_xfer (ihid, ihid->cmdbuf, length,NULL ,0 ); +if (ret) { +dev_err (&ihid->client->dev, +"failed to reset device: %d\n" , ret); +break ; + } -return 0 ; +return 0 ; + } -err_clear_reset: +/* Clean up if sending reset command failed */ clear_bit (I2C_HID_RESET_PENDING , &ihid->flags);i2c_hid_set_power (ihid,I2C_HID_PWR_SLEEP );return ret;
@@ -1200,6 +1211,7 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, ihid->is_panel_follower =drm_is_panel_follower (&client->dev);init_waitqueue_head (&ihid->wait); +mutex_init (&ihid->cmd_lock);mutex_init (&ihid->reset_lock);INIT_WORK (&ihid->panel_follower_prepare_work, ihid_core_panel_prepare_work);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 229/244 random: vDSO: don't use 64-bit atomics on 32-bit architectures
In reply to Sasha LevinFrom: Christophe Leroy <[email protected]>
[ Upstream commit 81c6896049b6ca69a9e737656ac33b3fd96a277c ]
Performing SMP atomic operations on u64 fails on powerpc32:
CC drivers/char/random.o
In file included from <command-line>:
drivers/char/random.c: In function 'crng_reseed':
././include/linux/compiler_types.h:510:45: error: call to '__compiletime_assert_391' declared with attribute error: Need native word sized stores/loads for atomicity.
510 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^
././include/linux/compiler_types.h:491:25: note: in definition of macro '__compiletime_assert'
491 | prefix ## suffix(); \
| ^~~~~~
././include/linux/compiler_types.h:510:9: note: in expansion of macro '_compiletime_assert'
510 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
././include/linux/compiler_types.h:513:9: note: in expansion of macro 'compiletime_assert'
513 | compiletime_assert(__native_word(t), \
| ^~~~~~~~~~~~~~~~~~
./arch/powerpc/include/asm/barrier.h:74:9: note: in expansion of macro 'compiletime_assert_atomic_type'
74 | compiletime_assert_atomic_type(*p); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/barrier.h:172:55: note: in expansion of macro '__smp_store_release'
172 | #define smp_store_release(p, v) do { kcsan_release(); __smp_store_release(p, v); } while (0)
| ^~~~~~~~~~~~~~~~~~~
drivers/char/random.c:286:9: note: in expansion of macro 'smp_store_release'
286 | smp_store_release(&__arch_get_k_vdso_rng_data()->generation, next_gen + 1);
| ^~~~~~~~~~~~~~~~~The kernel-side generation counter in the random driver is handled as an unsigned long, not as a u64, in base_crng and struct crng.
But on the vDSO side, it needs to be an u64, not just an unsigned long, in order to support a 32-bit vDSO atop a 64-bit kernel.
On kernel side, however, it is an unsigned long, hence a 32-bit value on 32-bit architectures, so just cast it to unsigned long for the smp_store_release(). A side effect is that on big endian architectures the store will be performed in the upper 32 bits. It is not an issue on its own because the vDSO site doesn't mind the value, as it only checks differences. Just make sure that the vDSO side checks the full 64 bits. For that, the local current_generation has to be u64 as well.
--- drivers/char/random.c | 9 ++++++++- lib/vdso/getrandom.c | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/char/random.c +8 -1
@@ -281,8 +281,15 @@ static void crng_reseed(struct work_struct *work)* former to arrive at the latter. Use smp_store_release so that this * is ordered with the write above to base_crng.generation. Pairs with * the smp_rmb() before the syscall in the vDSO code. +* +* Cast to unsigned long for 32-bit architectures, since atomic 64-bit +* operations are not supported on those architectures. This is safe +* because base_crng.generation is a 32-bit value. On big-endian +* architectures it will be stored in the upper 32 bits, but that's okay +* because the vDSO side only checks whether the value changed, without +* actually using or interpreting the value. */ -smp_store_release (&_vdso_rng_data.generation, next_gen +1 ); +smp_store_release ((unsigned long *)&_vdso_rng_data.generation, next_gen +1 );#endif if (!static_branch_likely (&crng_is_ready)) crng_init =CRNG_READY ;
lib/vdso/getrandom.c +1 -1
@@ -68,8 +68,8 @@ __cvdso_getrandom_data(const struct vdso_rng_data *rng_info, void *buffer, size_struct vgetrandom_state *state = opaque_state;size_t batch_len, nblocks, orig_len = len;bool in_use, have_retried = false; -unsigned long current_generation;void *orig_buffer = buffer; +u64 current_generation;u32 counter[2 ] = {0 };if (unlikely (opaque_len == ~0UL && !buffer && !len && !flags)) {
Signature · 1 line
2.43.0
Re: [PATCH AUTOSEL 6.11 229/244] random: vDSO: don't use 64-bit atomics on 32-bit architectures
This is not stable material and I didn't mark it as such. Do not backport.
Sasha Levin
maintainerPATCH 230/244 random: vDSO: avoid call to out of line memset()
In reply to Sasha LevinFrom: Christophe Leroy <[email protected]>
[ Upstream commit b7bad082e113640fc81200ff869e5c2d7a9c29a2 ]
With the current implementation, __cvdso_getrandom_data() calls memset() on certain architectures, which is unexpected in the VDSO.
Rather than providing a memset(), simply rewrite opaque data initialization to avoid memset().
--- lib/vdso/getrandom.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
lib/vdso/getrandom.c +7 -5
@@ -3,6 +3,7 @@* Copyright (C) 2022-2024 Jason A. Donenfeld <[email protected]>. All Rights Reserved. */ +#include <linux/array_size.h> #include <linux/cache.h> #include <linux/kernel.h> #include <linux/time64.h>
@@ -73,11 +74,12 @@ __cvdso_getrandom_data(const struct vdso_rng_data *rng_info, void *buffer, size_u32 counter[2 ] = {0 };if (unlikely (opaque_len == ~0UL && !buffer && !len && !flags)) { - *(struct vgetrandom_opaque_params *)opaque_state = (struct vgetrandom_opaque_params ) { - .size_of_opaque_state =sizeof (*state), - .mmap_prot =PROT_READ |PROT_WRITE , - .mmap_flags =MAP_DROPPABLE |MAP_ANONYMOUS - }; +struct vgetrandom_opaque_params *params = opaque_state; + params->size_of_opaque_state =sizeof (*state); + params->mmap_prot =PROT_READ |PROT_WRITE ; + params->mmap_flags =MAP_DROPPABLE |MAP_ANONYMOUS ; +for (size_t i =0 ; i <ARRAY_SIZE (params->reserved); ++i) + params->reserved[i] =0 ;return 0 ; }
Signature · 1 line
2.43.0
Re: [PATCH AUTOSEL 6.11 230/244] random: vDSO: avoid call to out of line memset()
This is not stable material and I didn't mark it as such. Do not backport.
Sasha Levin
maintainerPATCH 231/244 ksmbd: add refcnt to ksmbd_conn struct
In reply to Sasha LevinFrom: Namjae Jeon <[email protected]>
[ Upstream commit ee426bfb9d09b29987369b897fe9b6485ac2be27 ]
When sending an oplock break request, opinfo->conn is used, But freed ->conn can be used on multichannel.
This patch add a reference count to the ksmbd_conn struct so that it can be freed when it is no longer used.
--- fs/smb/server/connection.c | 4 ++- fs/smb/server/connection.h | 1 + fs/smb/server/oplock.c | 55 +++++++++++--------------------------- fs/smb/server/vfs_cache.c | 3 +++ 4 files changed, 23 insertions(+), 40 deletions(-)
fs/smb/server/connection.c +3 -1
@@ -39,7 +39,8 @@ void ksmbd_conn_free(struct ksmbd_conn *conn)xa_destroy (&conn->sessions);kvfree (conn->request_buf);kfree (conn->preauth_info); -kfree (conn); +if (atomic_dec_and_test (&conn->refcnt)) +kfree (conn); }/**
@@ -68,6 +69,7 @@ struct ksmbd_conn *ksmbd_conn_alloc(void) conn->um =NULL ;atomic_set (&conn->req_running,0 );atomic_set (&conn->r_count,0 ); +atomic_set (&conn->refcnt,1 ); conn->total_credits =1 ; conn->outstanding_credits =0 ;
fs/smb/server/connection.h +1 -0
@@ -106,6 +106,7 @@ struct ksmbd_conn {bool signing_negotiated;__le16 signing_algorithm;bool binding; +atomic_t refcnt; };struct ksmbd_conn_ops {
fs/smb/server/oplock.c +16 -39
148 lines not on this page · raw message
fs/smb/server/vfs_cache.c +3 -0
@@ -863,6 +863,8 @@ static bool session_fd_check(struct ksmbd_tree_connect *tcon,list_for_each_entry_rcu (op, &ci->m_op_list, op_entry) {if (op->conn != conn)continue ; +if (op->conn &&atomic_dec_and_test (&op->conn->refcnt)) +kfree (op->conn); op->conn =NULL ; }up_write (&ci->m_lock);
@@ -965,6 +967,7 @@ int ksmbd_reopen_durable_fd(struct ksmbd_work *work, struct ksmbd_file *fp)if (op->conn)continue ; op->conn = fp->conn; +atomic_inc (&op->conn->refcnt); }up_write (&ci->m_lock);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 232/244 platform/mellanox: mlxbf-pmc: fix lockdep warning
In reply to Sasha LevinFrom: Luiz Capitulino <[email protected]>
[ Upstream commit 305790dd91057a3f7497c9d128614a4f8486b62b ]
It seems the mlxbf-pmc driver is missing initializing sysfs attributes which causes the warning below when CONFIG_LOCKDEP and CONFIG_DEBUG_LOCK_ALLOC are enabled. This commit fixes it.
[ 155.380843] BUG: key ffff470f45dfa6d8 has not been registered! [ 155.386749] ------------[ cut here ]------------ [ 155.391361] DEBUG_LOCKS_WARN_ON(1) [ 155.391381] WARNING: CPU: 4 PID: 1828 at kernel/locking/lockdep.c:4894 lockdep_init_map_type+0x1d0/0x288 [ 155.404254] Modules linked in: mlxbf_pmc(+) xfs libcrc32c mmc_block mlx5_core crct10dif_ce mlxfw ghash_ce virtio_net tls net_failover sha2 _ce failover psample sha256_arm64 dw_mmc_bluefield pci_hyperv_intf sha1_ce dw_mmc_pltfm sbsa_gwdt dw_mmc micrel mmc_core nfit i2c_mlxbf pwr_m lxbf gpio_generic libnvdimm mlxbf_tmfifo mlxbf_gige dm_mirror dm_region_hash dm_log dm_mod [ 155.436786] CPU: 4 UID: 0 PID: 1828 Comm: modprobe Kdump: loaded Not tainted 6.11.0-rc7-rep1+ #1 [ 155.445562] Hardware name: https://www.mellanox.com BlueField SoC/BlueField SoC, BIOS 4.8.0.13249 Aug 7 2024 [ 155.455463] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 155.462413] pc : lockdep_init_map_type+0x1d0/0x288 [ 155.467196] lr : lockdep_init_map_type+0x1d0/0x288 [ 155.471976] sp : ffff80008a1734e0 [ 155.475279] x29: ffff80008a1734e0 x28: ffff470f45df0240 x27: 00000000ffffee4b [ 155.482406] x26: 00000000000011b4 x25: 0000000000000000 x24: 0000000000000000 [ 155.489532] x23: ffff470f45dfa6d8 x22: 0000000000000000 x21: ffffd54ef6bea000 [ 155.496659] x20: ffff470f45dfa6d8 x19: ffff470f49cdc638 x18: ffffffffffffffff [ 155.503784] x17: 2f30303a31444642 x16: ffffd54ef48a65e8 x15: ffff80010a172fe7 [ 155.510911] x14: 0000000000000000 x13: 284e4f5f4e524157 x12: 5f534b434f4c5f47 [ 155.518037] x11: 0000000000000001 x10: 0000000000000001 x9 : ffffd54ef3f48a14 [ 155.525163] x8 : 00000000000bffe8 x7 : c0000000ffff7fff x6 : 00000000002bffa8 [ 155.532289] x5 : ffff4712bdcb6088 x4 : 0000000000000000 x3 : 0000000000000027 [ 155.539416] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff470f43e5be00 [ 155.546542] Call trace: [ 155.548976] lockdep_init_map_type+0x1d0/0x288 [ 155.553410] __kernfs_create_file+0x80/0x138 [ 155.557673] sysfs_add_file_mode_ns+0x94/0x150 [ 155.562106] create_files+0xb0/0x248 [ 155.565672] internal_create_group+0x10c/0x328 [ 155.570105] internal_create_groups.part.0+0x50/0xc8 [ 155.575060] sysfs_create_groups+0x20/0x38 [ 155.579146] device_add_attrs+0x1b8/0x228 [ 155.583146] device_add+0x2a4/0x690 [ 155.586625] device_register+0x24/0x38 [ 155.590362] __hwmon_device_register+0x1e0/0x3c8 [ 155.594969] devm_hwmon_device_register_with_groups+0x78/0xe0 [ 155.600703] mlxbf_pmc_probe+0x224/0x3a0 [mlxbf_pmc] [ 155.605669] platform_probe+0x6c/0xe0 [ 155.609320] really_probe+0xc4/0x398 [ 155.612887] __driver_probe_device+0x80/0x168 [ 155.617233] driver_probe_device+0x44/0x120 [ 155.621405] __driver_attach+0xf4/0x200 [ 155.625230] bus_for_each_dev+0x7c/0xe8 [ 155.629055] driver_attach+0x28/0x38 [ 155.632619] bus_add_driver+0x110/0x238 [ 155.636445] driver_register+0x64/0x128 [ 155.640270] __platform_driver_register+0x2c/0x40 [ 155.644965] pmc_driver_init+0x24/0xff8 [mlxbf_pmc] [ 155.649833] do_one_initcall+0x70/0x3d0 [ 155.653660] do_init_module+0x64/0x220 [ 155.657400] load_module+0x628/0x6a8 [ 155.660964] init_module_from_file+0x8c/0xd8 [ 155.665222] idempotent_init_module+0x194/0x290 [ 155.669742] __arm64_sys_finit_module+0x6c/0xd8 [ 155.674261] invoke_syscall.constprop.0+0x74/0xd0 [ 155.678957] do_el0_svc+0xb4/0xd0 [ 155.682262] el0_svc+0x5c/0x248 [ 155.685394] el0t_64_sync_handler+0x134/0x150 [ 155.689739] el0t_64_sync+0x17c/0x180 [ 155.693390] irq event stamp: 6407 [ 155.696693] hardirqs last enabled at (6407): [<ffffd54ef3f48564>] console_unlock+0x154/0x1b8 [ 155.705207] hardirqs last disabled at (6406): [<ffffd54ef3f485ac>] console_unlock+0x19c/0x1b8 [ 155.713719] softirqs last enabled at (6404): [<ffffd54ef3e9740c>] handle_softirqs+0x4f4/0x518 [ 155.722320] softirqs last disabled at (6395): [<ffffd54ef3df0160>] __do_softirq+0x18/0x20 [ 155.730484] ---[ end trace 0000000000000000 ]---
--- drivers/platform/mellanox/mlxbf-pmc.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/platform/mellanox/mlxbf-pmc.c +5 -0
@@ -1774,6 +1774,7 @@ static int mlxbf_pmc_init_perftype_counter(struct device *dev, unsigned int blk_/* "event_list" sysfs to list events supported by the block */ attr = &pmc->block[blk_num].attr_event_list; +sysfs_attr_init (&attr->dev_attr.attr); attr->dev_attr.attr.mode =0444 ; attr->dev_attr.show = mlxbf_pmc_event_list_show; attr->nr = blk_num;
@@ -1787,6 +1788,7 @@ static int mlxbf_pmc_init_perftype_counter(struct device *dev, unsigned int blk_if (strstr (pmc->block_name[blk_num],"l3cache" ) || ((pmc->block[blk_num].type ==MLXBF_PMC_TYPE_CRSPACE ))) { attr = &pmc->block[blk_num].attr_enable; +sysfs_attr_init (&attr->dev_attr.attr); attr->dev_attr.attr.mode =0644 ; attr->dev_attr.show = mlxbf_pmc_enable_show; attr->dev_attr.store = mlxbf_pmc_enable_store;
@@ -1814,6 +1816,7 @@ static int mlxbf_pmc_init_perftype_counter(struct device *dev, unsigned int blk_/* "eventX" and "counterX" sysfs to program and read counter values */ for (j =0 ; j < pmc->block[blk_num].counters; ++j) { attr = &pmc->block[blk_num].attr_counter[j]; +sysfs_attr_init (&attr->dev_attr.attr); attr->dev_attr.attr.mode =0644 ; attr->dev_attr.show = mlxbf_pmc_counter_show; attr->dev_attr.store = mlxbf_pmc_counter_store;
@@ -1826,6 +1829,7 @@ static int mlxbf_pmc_init_perftype_counter(struct device *dev, unsigned int blk_ attr =NULL ; attr = &pmc->block[blk_num].attr_event[j]; +sysfs_attr_init (&attr->dev_attr.attr); attr->dev_attr.attr.mode =0644 ; attr->dev_attr.show = mlxbf_pmc_event_show; attr->dev_attr.store = mlxbf_pmc_event_store;
@@ -1861,6 +1865,7 @@ static int mlxbf_pmc_init_perftype_reg(struct device *dev, unsigned int blk_num)while (count >0 ) { --count; attr = &pmc->block[blk_num].attr_event[count]; +sysfs_attr_init (&attr->dev_attr.attr); attr->dev_attr.attr.mode =0644 ; attr->dev_attr.show = mlxbf_pmc_counter_show; attr->dev_attr.store = mlxbf_pmc_counter_store;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 233/244 platform/x86: x86-android-tablets: Adjust Xiaomi Pad 2 bottom bezel touch buttons LED
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit df40a23cc34c200cfde559eda7ca540f3ae7bd9e ]
The "input-events" LED trigger used to turn on the backlight LEDs had to be rewritten to use led_trigger_register_simple() + led_trigger_event() to fix a serious locking issue.
This means it no longer supports using blink_brightness to set a per LED brightness for the trigger and it no longer sets LED_CORE_SUSPENDRESUME.
Adjust the MiPad 2 bottom bezel touch buttons LED class device to match:
1. Make LED_FULL the maximum brightness to fix the LED brightness being very low when on.
2. Set flags = LED_CORE_SUSPENDRESUME.
--- drivers/platform/x86/x86-android-tablets/other.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/platform/x86/x86-android-tablets/other.c +5 -5
@@ -670,7 +670,7 @@ static const struct software_node *ktd2026_node_group[] = {* is controlled by the "pwm_soc_lpss_2" PWM output. */ #define XIAOMI_MIPAD2_LED_PERIOD_NS 19200 -#define XIAOMI_MIPAD2_LED_DEFAULT_DUTY 6000/* From Android kernel */ +#define XIAOMI_MIPAD2_LED_MAX_DUTY_NS 6000/* From Android kernel */ static struct pwm_device *xiaomi_mipad2_led_pwm;
@@ -679,7 +679,7 @@ static int xiaomi_mipad2_brightness_set(struct led_classdev *led_cdev, {struct pwm_state state = { .period =XIAOMI_MIPAD2_LED_PERIOD_NS , - .duty_cycle = val, + .duty_cycle =XIAOMI_MIPAD2_LED_MAX_DUTY_NS * val /LED_FULL ,/* Always set PWM enabled to avoid the pin floating */ .enabled = true, };
@@ -701,11 +701,11 @@ static int __init xiaomi_mipad2_init(struct device *dev)return -ENOMEM ; led_cdev->name ="mipad2:white:touch-buttons-backlight" ; - led_cdev->max_brightness =XIAOMI_MIPAD2_LED_PERIOD_NS ; -/* "input-events" trigger uses blink_brightness */ - led_cdev->blink_brightness =XIAOMI_MIPAD2_LED_DEFAULT_DUTY ; + led_cdev->max_brightness =LED_FULL ; led_cdev->default_trigger ="input-events" ; led_cdev->brightness_set_blocking = xiaomi_mipad2_brightness_set; +/* Turn LED off during suspend */ + led_cdev->flags =LED_CORE_SUSPENDRESUME ; ret =devm_led_classdev_register (dev, led_cdev);if (ret)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 234/244 ext4: filesystems without casefold feature cannot be mounted with siphash
In reply to Sasha LevinFrom: Lizhi Xu <[email protected]>
[ Upstream commit 985b67cd86392310d9e9326de941c22fc9340eec ]
When mounting the ext4 filesystem, if the default hash version is set to DX_HASH_SIPHASH but the casefold feature is not set, exit the mounting.
--- fs/ext4/super.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/ext4/super.c +7 -0
@@ -3582,6 +3582,13 @@ int ext4_feature_set_ok(struct super_block *sb, int readonly) "mounted without CONFIG_UNICODE");return 0 ; } +if (EXT4_SB (sb)->s_es->s_def_hash_version ==DX_HASH_SIPHASH && + !ext4_has_feature_casefold (sb)) { +ext4_msg (sb,KERN_ERR , +"Filesystem without casefold feature cannot be " +"mounted with siphash" ); +return 0 ; + }if (readonly)return 1 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 235/244 ext4: don't set SB_RDONLY after filesystem errors
In reply to Sasha LevinFrom: Jan Kara <[email protected]>
[ Upstream commit d3476f3dad4ad68ae5f6b008ea6591d1520da5d8 ]
When the filesystem is mounted with errors=remount-ro, we were setting SB_RDONLY flag to stop all filesystem modifications. We knew this misses proper locking (sb->s_umount) and does not go through proper filesystem remount procedure but it has been the way this worked since early ext2 days and it was good enough for catastrophic situation damage mitigation. Recently, syzbot has found a way (see link) to trigger warnings in filesystem freezing because the code got confused by SB_RDONLY changing under its hands. Since these days we set EXT4_FLAGS_SHUTDOWN on the superblock which is enough to stop all filesystem modifications, modifying SB_RDONLY shouldn't be needed. So stop doing that.
--- fs/ext4/super.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/ext4/super.c +5 -4
@@ -735,11 +735,12 @@ static void ext4_handle_error(struct super_block *sb, bool force_ro, int error,ext4_msg (sb,KERN_CRIT ,"Remounting filesystem read-only" );/* -* Make sure updated value of ->s_mount_flags will be visible before -* ->s_flags update +* EXT4_FLAGS_SHUTDOWN was set which stops all filesystem +* modifications. We don't set SB_RDONLY because that requires +* sb->s_umount semaphore and setting it without proper remount +* procedure is confusing code such as freeze_super() leading to +* deadlocks and other problems. */ -smp_wmb (); - sb->s_flags |=SB_RDONLY ; }static void update_super_work (struct work_struct *work)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 236/244 bpf: Make the pointer returned by iter next method valid
In reply to Sasha LevinFrom: Juntong Deng <[email protected]>
[ Upstream commit 4cc8c50c9abcb2646a7a4fcef3cea5dcb30c06cf ]
Currently we cannot pass the pointer returned by iter next method as argument to KF_TRUSTED_ARGS or KF_RCU kfuncs, because the pointer returned by iter next method is not "valid".
This patch sets the pointer returned by iter next method to be valid.
This is based on the fact that if the iterator is implemented correctly, then the pointer returned from the iter next method should be valid.
This does not make NULL pointer valid. If the iter next method has KF_RET_NULL flag, then the verifier will ask the ebpf program to check NULL pointer.
KF_RCU_PROTECTED iterator is a special case, the pointer returned by iter next method should only be valid within RCU critical section, so it should be with MEM_RCU, not PTR_TRUSTED.
Another special case is bpf_iter_num_next, which returns a pointer with base type PTR_TO_MEM. PTR_TO_MEM should not be combined with type flag PTR_TRUSTED (PTR_TO_MEM already means the pointer is valid).
The pointer returned by iter next method of other types of iterators is with PTR_TRUSTED.
In addition, this patch adds get_iter_from_state to help us get the current iterator from the current state.
--- kernel/bpf/verifier.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
kernel/bpf/verifier.c +22 -4
@@ -7987,6 +7987,15 @@ static int widen_imprecise_scalars(struct bpf_verifier_env *env,return 0 ; } +static struct bpf_reg_state *get_iter_from_state (struct bpf_verifier_state *cur_st, +struct bpf_kfunc_call_arg_meta *meta) +{ +int iter_frameno = meta->iter.frameno; +int iter_spi = meta->iter.spi; + +return &cur_st->frame[iter_frameno]->stack[iter_spi].spilled_ptr; +} +/* process_iter_next_call() is called when verifier gets to iterator's next * "method" (e.g., bpf_iter_num_next() for numbers iterator) call. We'll refer * to it as just "iter_next()" in comments below.
@@ -8071,12 +8080,10 @@ static int process_iter_next_call(struct bpf_verifier_env *env, int insn_idx,struct bpf_verifier_state *cur_st = env->cur_state, *queued_st, *prev_st;struct bpf_func_state *cur_fr = cur_st->frame[cur_st->curframe], *queued_fr;struct bpf_reg_state *cur_iter, *queued_iter; -int iter_frameno = meta->iter.frameno; -int iter_spi = meta->iter.spi;BTF_TYPE_EMIT (struct bpf_iter ); - cur_iter = &env->cur_state->frame[iter_frameno]->stack[iter_spi].spilled_ptr; + cur_iter =get_iter_from_state (cur_st, meta);if (cur_iter->iter.state !=BPF_ITER_STATE_ACTIVE && cur_iter->iter.state !=BPF_ITER_STATE_DRAINED ) {
@@ -8104,7 +8111,7 @@ static int process_iter_next_call(struct bpf_verifier_env *env, int insn_idx,if (!queued_st)return -ENOMEM ; - queued_iter = &queued_st->frame[iter_frameno]->stack[iter_spi].spilled_ptr; + queued_iter =get_iter_from_state (queued_st, meta); queued_iter->iter.state =BPF_ITER_STATE_ACTIVE ; queued_iter->iter.depth++;if (prev_st)
@@ -12671,6 +12678,17 @@ static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn, regs[BPF_REG_0 ].btf = desc_btf; regs[BPF_REG_0 ].type =PTR_TO_BTF_ID ; regs[BPF_REG_0 ].btf_id = ptr_type_id; + +if (is_iter_next_kfunc (&meta)) { +struct bpf_reg_state *cur_iter; + + cur_iter =get_iter_from_state (env->cur_state, &meta); + +if (cur_iter->type &MEM_RCU )/* KF_RCU_PROTECTED */ + regs[BPF_REG_0 ].type |=MEM_RCU ; +else + regs[BPF_REG_0 ].type |=PTR_TRUSTED ; + } }if (is_kfunc_ret_null (&meta)) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 237/244 iomap: fix iomap_dio_zero() for fs bs > system page size
In reply to Sasha LevinFrom: Pankaj Raghav <[email protected]>
[ Upstream commit 10553a91652d995274da63fc317470f703765081 ]
iomap_dio_zero() will pad a fs block with zeroes if the direct IO size < fs block size. iomap_dio_zero() has an implicit assumption that fs block size < page_size. This is true for most filesystems at the moment.
If the block size > page size, this will send the contents of the page next to zero page(as len > PAGE_SIZE) to the underlying block device, causing FS corruption.
iomap is a generic infrastructure and it should not make any assumptions about the fs block size and the page size of the system.
--- fs/iomap/buffered-io.c | 4 ++-- fs/iomap/direct-io.c | 45 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 41 insertions(+), 8 deletions(-)
fs/iomap/buffered-io.c +2 -2
@@ -2007,10 +2007,10 @@ iomap_writepages(struct address_space *mapping, struct writeback_control *wbc, }EXPORT_SYMBOL_GPL (iomap_writepages); -static int __init iomap_init (void ) +static int __init iomap_buffered_init (void ) {return bioset_init (&iomap_ioend_bioset,4 * (PAGE_SIZE /SECTOR_SIZE ), offsetof(struct iomap_ioend , io_bio),BIOSET_NEED_BVECS ); } -fs_initcall (iomap_init); +fs_initcall (iomap_buffered_init);
fs/iomap/direct-io.c +39 -6
90 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH AUTOSEL 6.11 237/244] iomap: fix iomap_dio_zero() for fs bs > system page size
Quoted 8 lines · Sasha Levin
From: Pankaj Raghav <[email protected]>
[ Upstream commit
10553a91652d995274da63fc317470f703765081]
iomap_dio_zero()will pad a fs block with zeroes if the direct IO size < fs block size.iomap_dio_zero()has an implicit assumption that fs block size <page_size. This is true for most filesystems at the moment.
Quoted 6 lines
If the block size > page size, this will send the contents of the page next to zero
page(as len > PAGE_SIZE)to the underlying block device, causing FS corruption.iomap is a generic infrastructure and it should not make any assumptions about the fs block size and the page size of the system.
Please drop this. It is for support of new functionality that was just merged and has no relevance to older kernels. It is not a bug fix.
And ....
fs/iomap/direct-io.c iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, · line 785
Quoted 3 lines
fs/iomap/direct-io.c +3
-0+ +set_memory_ro ((unsigned long )page_address (zero_page), +1U <<IOMAP_ZERO_PAGE_ORDER );
.... this will cause stable kernel regressions.
It was removed later in the merge because it is unnecessary and causes boot failures on (at least) some Power architectures.
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: Re: [PATCH AUTOSEL 6.11 237/244] iomap: fix iomap_dio_zero() for fs bs > system page size
Quoted 13 lines · Dave Chinner
Quoted 12 lines · Sasha Levin
From: Pankaj Raghav <[email protected]>
[ Upstream commit
10553a91652d995274da63fc317470f703765081]
iomap_dio_zero()will pad a fs block with zeroes if the direct IO size < fs block size.iomap_dio_zero()has an implicit assumption that fs block size <page_size. This is true for most filesystems at the moment.If the block size > page size, this will send the contents of the page next to zero
page(as len > PAGE_SIZE)to the underlying block device, causing FS corruption.
Quoted 7 lines
Quoted 2 lines
iomap is a generic infrastructure and it should not make any assumptions about the fs block size and the page size of the system.
Please drop this. It is for support of new functionality that was just merged and has no relevance to older kernels. It is not a bug fix.
I did not have any fixes by tag for this reason. So please drop this commit from the queue.
Quoted 15 lines
And ....
fs/iomap/direct-io.c iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, · line 785
Quoted 3 lines
fs/iomap/direct-io.c +3
-0+ +set_memory_ro ((unsigned long )page_address (zero_page), +1U <<IOMAP_ZERO_PAGE_ORDER );.... this will cause stable kernel regressions.
It was removed later in the merge because it is unnecessary and causes boot failures on (at least) some Power architectures.
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
Signature · 1 line
Pankaj Raghav
Sasha Levin
maintainerRe: [PATCH AUTOSEL 6.11 237/244] iomap: fix iomap_dio_zero() for fs bs > system page size
In reply to Dave ChinnerQuoted 22 lines · Dave Chinner
Quoted 8 lines · Sasha Levin
From: Pankaj Raghav <[email protected]>
[ Upstream commit
10553a91652d995274da63fc317470f703765081]
iomap_dio_zero()will pad a fs block with zeroes if the direct IO size < fs block size.iomap_dio_zero()has an implicit assumption that fs block size <page_size. This is true for most filesystems at the moment.Quoted 6 lines
If the block size > page size, this will send the contents of the page next to zero
page(as len > PAGE_SIZE)to the underlying block device, causing FS corruption.iomap is a generic infrastructure and it should not make any assumptions about the fs block size and the page size of the system.
Please drop this. It is for support of new functionality that was just merged and has no relevance to older kernels. It is not a bug fix.
And ....
Quoted 8 lines
fs/iomap/direct-io.c iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, · line 785
Quoted 3 lines
fs/iomap/direct-io.c +3
-0+ +set_memory_ro ((unsigned long )page_address (zero_page), +1U <<IOMAP_ZERO_PAGE_ORDER );.... this will cause stable kernel regressions.
It was removed later in the merge because it is unnecessary and causes boot failures on (at least) some Power architectures.
Dropped, and sorry about sending this one out twice!
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 238/244 ext4: ext4_search_dir should return a proper error
In reply to Sasha LevinFrom: Thadeu Lima de Souza Cascardo <[email protected]>
[ Upstream commit cd69f8f9de280e331c9e6ff689ced0a688a9ce8f ]
ext4_search_dir currently returns -1 in case of a failure, while it returns 0 when the name is not found. In such failure cases, it should return an error code instead.
This becomes even more important when ext4_find_inline_entry returns an error code as well in the next commit.
-EFSCORRUPTED seems appropriate as such error code as these failures would be caused by unexpected record lengths and is in line with other instances of ext4_check_dir_entry failures.
In the case of ext4_dx_find_entry, the current use of ERR_BAD_DX_DIR was left as is to reduce the risk of regressions.
--- fs/ext4/namei.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
fs/ext4/namei.c +7 -5
@@ -1482,7 +1482,7 @@ static bool ext4_match(struct inode *parent, }/* -* Returns 0 if not found, -1 on failure, and 1 on success +* Returns 0 if not found, -EFSCORRUPTED on failure, and 1 on success */ int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size, struct inode *dir, struct ext4_filename *fname,
@@ -1503,7 +1503,7 @@ int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size,* a full check */ if (ext4_check_dir_entry (dir,NULL , de, bh, search_buf, buf_size, offset)) -return -1 ; +return -EFSCORRUPTED ; *res_dir = de;return 1 ; }
@@ -1511,7 +1511,7 @@ int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size, de_len =ext4_rec_len_from_disk (de->rec_len, dir->i_sb->s_blocksize);if (de_len <=0 ) -return -1 ; +return -EFSCORRUPTED ; offset += de_len; de = (struct ext4_dir_entry_2 *) ((char *) de + de_len); }
@@ -1663,8 +1663,10 @@ static struct buffer_head *__ext4_find_entry(struct inode *dir, goto cleanup_and_exit; }else {brelse (bh); -if (i <0 ) +if (i <0 ) { + ret =ERR_PTR (i); goto cleanup_and_exit; + } } next:if (++block >= nblocks)
@@ -1758,7 +1760,7 @@ static struct buffer_head * ext4_dx_find_entry(struct inode *dir,if (retval ==1 ) goto success;brelse (bh); -if (retval ==-1 ) { +if (retval <0 ) { bh =ERR_PTR (ERR_BAD_DX_DIR ); goto errout; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 239/244 ext4: avoid use-after-free in ext4_ext_show_leaf()
In reply to Sasha LevinFrom: Baokun Li <[email protected]>
[ Upstream commit 4e2524ba2ca5f54bdbb9e5153bea00421ef653f5 ]
In ext4_find_extent(), path may be freed by error or be reallocated, so using a previously saved *ppath may have been freed and thus may trigger use-after-free, as follows:
ext4_split_extent
path = *ppath;
ext4_split_extent_at(ppath)
path = ext4_find_extent(ppath)
ext4_split_extent_at(ppath)
// ext4_find_extent fails to free path
// but zeroout succeeds ext4_ext_show_leaf(inode, path)
eh = path[depth].p_hdr
// path use-after-free !!!
Similar to ext4_split_extent_at(), we use *ppath directly as an input to ext4_ext_show_leaf(). Fix a spelling error by the way.
Same problem in ext4_ext_handle_unwritten_extents(). Since 'path' is only used in ext4_ext_show_leaf(), remove 'path' and use *ppath directly.
This issue is triggered only when EXT_DEBUG is defined and therefore does not affect functionality.
--- fs/ext4/extents.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
fs/ext4/extents.c +4 -5
@@ -3287,7 +3287,7 @@ static int ext4_split_extent_at(handle_t *handle, }/* -* ext4_split_extents() splits an extent and mark extent which is covered +* ext4_split_extent() splits an extent and mark extent which is covered * by @map as split_flags indicates * * It may result in splitting the extent into multiple extents (up to three)
@@ -3363,7 +3363,7 @@ static int ext4_split_extent(handle_t *handle, goto out; } -ext4_ext_show_leaf (inode, path); +ext4_ext_show_leaf (inode, *ppath); out:return err ? err : allocated; }
@@ -3828,14 +3828,13 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode, struct ext4_ext_path **ppath, int flags, unsigned int allocated, ext4_fsblk_t newblock) { - struct ext4_ext_path __maybe_unused *path = *ppath; int ret = 0;int err =0 ;ext_debug (inode,"logical block %llu, max_blocks %u, flags 0x%x, allocated %u\n" , (unsigned long long )map->m_lblk, map->m_len, flags, allocated); -ext4_ext_show_leaf (inode, path); +ext4_ext_show_leaf (inode, *ppath);/* * When writing into unwritten space, we should not fail to
@@ -3932,7 +3931,7 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode,if (allocated > map->m_len) allocated = map->m_len; map->m_len = allocated; -ext4_ext_show_leaf (inode, path); +ext4_ext_show_leaf (inode, *ppath); out2:return err ? err : allocated; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 240/244 ext4: fix i_data_sem unlock order in ext4_ind_migrate()
In reply to Sasha LevinFrom: Artem Sadovnikov <[email protected]>
[ Upstream commit cc749e61c011c255d81b192a822db650c68b313f ]
Fuzzing reports a possible deadlock in jbd2_log_wait_commit.
This issue is triggered when an EXT4_IOC_MIGRATE ioctl is set to require synchronous updates because the file descriptor is opened with O_SYNC. This can lead to the jbd2_journal_stop() function calling jbd2_might_wait_for_commit(), potentially causing a deadlock if the EXT4_IOC_MIGRATE call races with a write(2) system call.
This problem only arises when CONFIG_PROVE_LOCKING is enabled. In this case, the jbd2_might_wait_for_commit macro locks jbd2_handle in the jbd2_journal_stop function while i_data_sem is locked. This triggers lockdep because the jbd2_journal_start function might also lock the same jbd2_handle simultaneously.
Found by Linux Verification Center (linuxtesting.org) with syzkaller.
Rule: add
--- fs/ext4/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/migrate.c +1 -1
@@ -663,8 +663,8 @@ int ext4_ind_migrate(struct inode *inode)if (unlikely (ret2 && !ret)) ret = ret2; errout: -ext4_journal_stop (handle);up_write (&EXT4_I (inode)->i_data_sem); +ext4_journal_stop (handle); out_unlock:ext4_writepages_up_write (inode->i_sb, alloc_ctx);return ret;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 241/244 bpftool: Fix undefined behavior caused by shifting into the sign bit
In reply to Sasha LevinFrom: Kuan-Wei Chiu <[email protected]>
[ Upstream commit 4cdc0e4ce5e893bc92255f5f734d983012f2bc2e ]
Replace shifts of '1' with '1U' in bitwise operations within __show_dev_tc_bpf() to prevent undefined behavior caused by shifting into the sign bit of a signed integer. By using '1U', the operations are explicitly performed on unsigned integers, avoiding potential integer overflow or sign-related issues.
--- tools/bpf/bpftool/net.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/bpf/bpftool/net.c +4 -4
@@ -482,9 +482,9 @@ static void __show_dev_tc_bpf(const struct ip_devname_ifindex *dev,if (prog_flags[i] || json_output) {NET_START_ARRAY ("prog_flags" ,"%s " );for (j =0 ; prog_flags[i] && j <32 ; j++) { -if (!(prog_flags[i] & (1 << j))) +if (!(prog_flags[i] & (1U << j)))continue ; -NET_DUMP_UINT_ONLY (1 << j); +NET_DUMP_UINT_ONLY (1U << j); }NET_END_ARRAY ("" ); }
@@ -493,9 +493,9 @@ static void __show_dev_tc_bpf(const struct ip_devname_ifindex *dev,if (link_flags[i] || json_output) {NET_START_ARRAY ("link_flags" ,"%s " );for (j =0 ; link_flags[i] && j <32 ; j++) { -if (!(link_flags[i] & (1 << j))) +if (!(link_flags[i] & (1U << j)))continue ; -NET_DUMP_UINT_ONLY (1 << j); +NET_DUMP_UINT_ONLY (1U << j); }NET_END_ARRAY ("" ); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 242/244 iomap: handle a post-direct I/O invalidate race in iomap_write_delalloc_release
In reply to Sasha LevinFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 7a9d43eace888a0ee6095035997bb138425844d3 ]
When direct I/O completions invalidates the page cache it holds neither the i_rwsem nor the invalidate_lock so it can be racing with iomap_write_delalloc_release. If the search for the end of the region that contains data returns the start offset we hit such a race and just need to look for the end of the newly created hole instead.
--- fs/iomap/buffered-io.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/iomap/buffered-io.c +9 -1
@@ -1241,7 +1241,15 @@ static int iomap_write_delalloc_release(struct inode *inode, error = data_end; goto out_unlock; } -WARN_ON_ONCE (data_end <= start_byte); + +/* +* If we race with post-direct I/O invalidation of the page cache, +* there might be no data left at start_byte. +*/ +if (data_end == start_byte) +continue ; + +WARN_ON_ONCE (data_end < start_byte);WARN_ON_ONCE (data_end > scan_end_byte); error = iomap_write_delalloc_scan(inode, &punch_start_byte,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 243/244 bpftool: Fix undefined behavior in qsort(NULL, 0, ...)
In reply to Sasha LevinFrom: Kuan-Wei Chiu <[email protected]>
[ Upstream commit f04e2ad394e2755d0bb2d858ecb5598718bf00d5 ]
When netfilter has no entry to display, qsort is called with qsort(NULL, 0, ...). This results in undefined behavior, as UBSan reports:
net.c:827:2: runtime error: null pointer passed as argument 1, which is declared to never be null
Although the C standard does not explicitly state whether calling qsort with a NULL pointer when the size is 0 constitutes undefined behavior, Section 7.1.4 of the C standard (Use of library functions) mentions:
"Each of the following statements applies unless explicitly stated otherwise in the detailed descriptions that follow: If an argument to a function has an invalid value (such as a value outside the domain of the function, or a pointer outside the address space of the program, or a null pointer, or a pointer to non-modifiable storage when the corresponding parameter is not const-qualified) or a type (after promotion) not expected by a function with variable number of arguments, the behavior is undefined."
To avoid this, add an early return when nf_link_info is NULL to prevent calling qsort with a NULL pointer.
--- tools/bpf/bpftool/net.c | 3 +++ 1 file changed, 3 insertions(+)
tools/bpf/bpftool/net.c +3 -0
@@ -824,6 +824,9 @@ static void show_link_netfilter(void) nf_link_count++; } +if (!nf_link_info) +return ; +qsort (nf_link_info, nf_link_count,sizeof (*nf_link_info), netfilter_link_compar);for (id =0 ; id < nf_link_count; id++) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 244/244 bpf: Fix a sdiv overflow issue
In reply to Sasha LevinFrom: Yonghong Song <[email protected]>
[ Upstream commit 7dd34d7b7dcf9309fc6224caf4dd5b35bedddcb7 ]
Zac Ecob reported a problem where a bpf program may cause kernel crash due to the following error:
Oops: divide error: 0000 [#1] PREEMPT SMP KASAN PTI
The failure is due to the below signed divide:
LLONG_MIN/-1 where LLONG_MIN equals to -9,223,372,036,854,775,808.
LLONG_MIN/-1 is supposed to give a positive number 9,223,372,036,854,775,808, but it is impossible since for 64-bit system, the maximum positive number is 9,223,372,036,854,775,807. On x86_64, LLONG_MIN/-1 will cause a kernel exception. On arm64, the result for LLONG_MIN/-1 is LLONG_MIN.
Further investigation found all the following sdiv/smod cases may trigger an exception when bpf program is running on x86_64 platform:
- LLONG_MIN/-1 for 64bit operation
- INT_MIN/-1 for 32bit operation
- LLONG_MIN%-1 for 64bit operation
- INT_MIN%-1 for 32bit operation
where -1 can be an immediate or in a register.
On arm64, there are no exceptions:
- LLONG_MIN/-1 = LLONG_MIN
- INT_MIN/-1 = INT_MIN
- LLONG_MIN%-1 = 0
- INT_MIN%-1 = 0
where -1 can be an immediate or in a register.
Insn patching is needed to handle the above cases and the patched codes produced results aligned with above arm64 result. The below are pseudo codes to handle sdiv/smod exceptions including both divisor -1 and divisor 0 and the divisor is stored in a register.
sdiv:
tmp = rX
tmp += 1 /* [-1, 0] -> [0, 1]
if tmp >(unsigned) 1 goto L2
if tmp == 0 goto L1
rY = 0
L1:
rY = -rY;
goto L3 L2:
rY /= rX
L3:
smod:
tmp = rX
tmp += 1 /* [-1, 0] -> [0, 1]
if tmp >(unsigned) 1 goto L1
if tmp == 1 (is64 ? goto L2 : goto L3)
rY = 0;
goto L2 L1:
rY %= rX
L2:
goto L4 // only when !is64
L3:
wY = wY // only when !is64
L4:
--- kernel/bpf/verifier.c | 93 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 4 deletions(-)
kernel/bpf/verifier.c +89 -4
@@ -19929,13 +19929,46 @@ static int do_misc_fixups(struct bpf_verifier_env *env)/* Convert BPF_CLASS(insn->code) == BPF_ALU64 to 32-bit ALU */ insn->code =BPF_ALU |BPF_OP (insn->code) |BPF_SRC (insn->code); -/* Make divide-by-zero exceptions impossible. */ +/* Make sdiv/smod divide-by-minus-one exceptions impossible. */ +if ((insn->code == (BPF_ALU64 |BPF_MOD |BPF_K ) || + insn->code == (BPF_ALU64 |BPF_DIV |BPF_K ) || + insn->code == (BPF_ALU |BPF_MOD |BPF_K ) || + insn->code == (BPF_ALU |BPF_DIV |BPF_K )) && + insn->off ==1 && insn->imm ==-1 ) { +bool is64 =BPF_CLASS (insn->code) ==BPF_ALU64 ; +bool isdiv =BPF_OP (insn->code) ==BPF_DIV ; +struct bpf_insn *patchlet; +struct bpf_insn chk_and_sdiv[] = { +BPF_RAW_INSN ((is64 ?BPF_ALU64 :BPF_ALU ) | +BPF_NEG |BPF_K , insn->dst_reg, +0 ,0 ,0 ), + }; +struct bpf_insn chk_and_smod[] = { +BPF_MOV32_IMM (insn->dst_reg,0 ), + }; + + patchlet = isdiv ? chk_and_sdiv : chk_and_smod; + cnt = isdiv ?ARRAY_SIZE (chk_and_sdiv) :ARRAY_SIZE (chk_and_smod); + + new_prog =bpf_patch_insn_data (env, i + delta, patchlet, cnt); +if (!new_prog) +return -ENOMEM ; + + delta += cnt -1 ; + env->prog = prog = new_prog; + insn = new_prog->insnsi + i + delta; + goto next_insn; + } + +/* Make divide-by-zero and divide-by-minus-one exceptions impossible. */ if (insn->code == (BPF_ALU64 |BPF_MOD |BPF_X ) || insn->code == (BPF_ALU64 |BPF_DIV |BPF_X ) || insn->code == (BPF_ALU |BPF_MOD |BPF_X ) || insn->code == (BPF_ALU |BPF_DIV |BPF_X )) {bool is64 =BPF_CLASS (insn->code) ==BPF_ALU64 ;bool isdiv =BPF_OP (insn->code) ==BPF_DIV ; +bool is_sdiv = isdiv && insn->off ==1 ; +bool is_smod = !isdiv && insn->off ==1 ;struct bpf_insn *patchlet;struct bpf_insn chk_and_div[] = {/* [R,W]x div 0 -> 0 */
@@ -19955,10 +19988,62 @@ static int do_misc_fixups(struct bpf_verifier_env *env)BPF_JMP_IMM (BPF_JA ,0 ,0 ,1 ), BPF_MOV32_REG(insn->dst_reg, insn->dst_reg), }; +struct bpf_insn chk_and_sdiv[] = { +/* [R,W]x sdiv 0 -> 0 +* LLONG_MIN sdiv -1 -> LLONG_MIN +* INT_MIN sdiv -1 -> INT_MIN +*/ +BPF_MOV64_REG (BPF_REG_AX , insn->src_reg), +BPF_RAW_INSN ((is64 ?BPF_ALU64 :BPF_ALU ) | +BPF_ADD |BPF_K ,BPF_REG_AX , +0 ,0 ,1 ), +BPF_RAW_INSN ((is64 ?BPF_JMP :BPF_JMP32 ) | +BPF_JGT |BPF_K ,BPF_REG_AX , +0 ,4 ,1 ), +BPF_RAW_INSN ((is64 ?BPF_JMP :BPF_JMP32 ) | +BPF_JEQ |BPF_K ,BPF_REG_AX , +0 ,1 ,0 ), +BPF_RAW_INSN ((is64 ?BPF_ALU64 :BPF_ALU ) | +BPF_MOV |BPF_K , insn->dst_reg, +0 ,0 ,0 ), +/* BPF_NEG(LLONG_MIN) == -LLONG_MIN == LLONG_MIN */ +BPF_RAW_INSN ((is64 ?BPF_ALU64 :BPF_ALU ) | +BPF_NEG |BPF_K , insn->dst_reg, +0 ,0 ,0 ), +BPF_JMP_IMM (BPF_JA ,0 ,0 ,1 ), + *insn, + }; +struct bpf_insn chk_and_smod[] = { +/* [R,W]x mod 0 -> [R,W]x */ +/* [R,W]x mod -1 -> 0 */ +BPF_MOV64_REG (BPF_REG_AX , insn->src_reg), +BPF_RAW_INSN ((is64 ?BPF_ALU64 :BPF_ALU ) | +BPF_ADD |BPF_K ,BPF_REG_AX , +0 ,0 ,1 ), +BPF_RAW_INSN ((is64 ?BPF_JMP :BPF_JMP32 ) | +BPF_JGT |BPF_K ,BPF_REG_AX , +0 ,3 ,1 ), +BPF_RAW_INSN ((is64 ?BPF_JMP :BPF_JMP32 ) | +BPF_JEQ |BPF_K ,BPF_REG_AX , +0 ,3 + (is64 ?0 :1 ),1 ), +BPF_MOV32_IMM (insn->dst_reg,0 ), +BPF_JMP_IMM (BPF_JA ,0 ,0 ,1 ), + *insn, +BPF_JMP_IMM (BPF_JA ,0 ,0 ,1 ), +BPF_MOV32_REG (insn->dst_reg, insn->dst_reg), + }; - patchlet = isdiv ? chk_and_div : chk_and_mod; - cnt = isdiv ?ARRAY_SIZE (chk_and_div) : -ARRAY_SIZE (chk_and_mod) - (is64 ?2 :0 ); +if (is_sdiv) { + patchlet = chk_and_sdiv; + cnt =ARRAY_SIZE (chk_and_sdiv); + }else if (is_smod) { + patchlet = chk_and_smod; + cnt =ARRAY_SIZE (chk_and_smod) - (is64 ?2 :0 ); + }else { + patchlet = isdiv ? chk_and_div : chk_and_mod; + cnt = isdiv ?ARRAY_SIZE (chk_and_div) : +ARRAY_SIZE (chk_and_mod) - (is64 ?2 :0 ); + } new_prog =bpf_patch_insn_data (env, i + delta, patchlet, cnt);if (!new_prog)
Signature · 1 line
2.43.0