pinctrl: freescale: fix COMPILE_TEST error with PINCTRL_IMX_SCU
Subsystems (15)
Sasha Levin
maintainerPATCH 1/33 pinctrl: freescale: fix COMPILE_TEST error with PINCTRL_IMX_SCU
From: Esben Haabendal <[email protected]>
[ Upstream commit 58414a31c5713afb5449fd74a26a843d34cc62e8 ]
When PINCTRL_IMX_SCU was selected by PINCTRL_IMX8DXL or PINCTRL_IMX8QM combined with COMPILE_TEST on a non-arm platforms, the IMX_SCU dependency could not be enabled.
--- drivers/pinctrl/freescale/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/freescale/Kconfig +1 -1
@@ -20,7 +20,7 @@ config PINCTRL_IMX_SCMI config PINCTRL_IMX_SCU tristate - depends on IMX_SCU + depends on IMX_SCU || COMPILE_TEST select PINCTRL_IMX config PINCTRL_IMX1_CORE
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 2/33 rtla: Fix consistency in getopt_long for timerlat_hist
From: Gabriele Monaco <[email protected]>
[ Upstream commit cfb1ea216c1656a4112becbc4bf757891933b902 ]
Commit e9a4062e1527 ("rtla: Add --trace-buffer-size option") adds a new long option to rtla utilities, but among all affected files, timerlat_hist misses a trailing : in the corresponding short option inside the getopt string (e.g. \3:). This patch propagates the :.
Although this change is not functionally required, it improves consistency and slightly reduces the likelihood a future change would introduce a problem.
--- tools/tracing/rtla/src/timerlat_hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tracing/rtla/src/timerlat_hist.c +1 -1
@@ -778,7 +778,7 @@ static struct timerlat_hist_params/* getopt_long stores the option index here. */ int option_index =0 ; - c =getopt_long (argc, argv,"a:c:C::b:d:e:E:DhH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3" , + c =getopt_long (argc, argv,"a:c:C::b:d:e:E:DhH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:" , long_options, &option_index);/* detect the end of the options. */
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 3/33 tracing/ftrace: disable preemption in syscall probe
In reply to Sasha LevinFrom: Mathieu Desnoyers <[email protected]>
[ Upstream commit 13d750c2c03e9861e15268574ed2c239cca9c9d5 ]
In preparation for allowing system call enter/exit instrumentation to handle page faults, make sure that ftrace can handle this change by explicitly disabling preemption within the ftrace system call tracepoint probes to respect the current expectations within ftrace ring buffer code.
This change does not yet allow ftrace to take page faults per se within its probe, but allows its existing probes to adapt to the upcoming change.
--- include/trace/trace_events.h | 36 +++++++++++++++++++++++++++++++---- kernel/trace/trace_syscalls.c | 12 ++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-)
include/trace/trace_events.h +32 -4
@@ -244,6 +244,9 @@ static struct trace_event_fields trace_event_fields_##call[] = { \ tstruct \ {} }; +#undef DECLARE_EVENT_SYSCALL_CLASS +#define DECLARE_EVENT_SYSCALL_CLASS DECLARE_EVENT_CLASS +#undef DEFINE_EVENT_PRINT#define DEFINE_EVENT_PRINT (template, name, proto, args, print)
@@ -374,11 +377,11 @@ static inline notrace int trace_event_get_offsets_##call( \#include "stages/stage6_event_callback.h" -#undef DECLARE_EVENT_CLASS -#define DECLARE_EVENT_CLASS (call, proto, args, tstruct, assign, print) \ - \ + +#undef __DECLARE_EVENT_CLASS +#define __DECLARE_EVENT_CLASS (call, proto, args, tstruct, assign, print) \ static notrace void \ -trace_event_raw_event_##call(void *__data, proto) \ +do_trace_event_raw_event_##call(void *__data, proto) \ { \ struct trace_event_file *trace_file = __data; \ struct trace_event_data_offsets_##call __maybe_unused __data_offsets;\
@@ -403,6 +406,29 @@ trace_event_raw_event_##call(void *__data, proto) \ \trace_event_buffer_commit (&fbuffer); \ } + +#undef DECLARE_EVENT_CLASS +#define DECLARE_EVENT_CLASS (call, proto, args, tstruct, assign, print) \ +__DECLARE_EVENT_CLASS(call, PARAMS(proto), PARAMS(args), PARAMS(tstruct), \ + PARAMS(assign), PARAMS(print)) \ +static notrace void \ +trace_event_raw_event_##call(void *__data, proto) \ +{ \ + do_trace_event_raw_event_##call(__data, args); \ +} + +#undef DECLARE_EVENT_SYSCALL_CLASS +#define DECLARE_EVENT_SYSCALL_CLASS (call, proto, args, tstruct, assign, print) \ +__DECLARE_EVENT_CLASS(call, PARAMS(proto), PARAMS(args), PARAMS(tstruct), \ + PARAMS(assign), PARAMS(print)) \ +static notrace void \ +trace_event_raw_event_##call(void *__data, proto) \ +{ \ + preempt_disable_notrace(); \ + do_trace_event_raw_event_##call(__data, args); \ + preempt_enable_notrace(); \ +} +/* * The ftrace_test_probe is compiled out, it is only here as a build time check * to make sure that if the tracepoint handling changes, the ftrace probe will
@@ -418,6 +444,8 @@ static inline void ftrace_test_probe_##call(void) \#include TRACE_INCLUDE (TRACE_INCLUDE_FILE ) +#undef __DECLARE_EVENT_CLASS +#include "stages/stage7_class_define.h" #undef DECLARE_EVENT_CLASS
kernel/trace/trace_syscalls.c +12 -0
@@ -299,6 +299,12 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)int syscall_nr;int size; +/* +* Syscall probe called with preemption enabled, but the ring +* buffer and per-cpu data require preemption to be disabled. +*/ +guard (preempt_notrace)(); + syscall_nr =trace_get_syscall_nr (current, regs);if (syscall_nr <0 || syscall_nr >= NR_syscalls)return ;
@@ -338,6 +344,12 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)struct trace_event_buffer fbuffer;int syscall_nr; +/* +* Syscall probe called with preemption enabled, but the ring +* buffer and per-cpu data require preemption to be disabled. +*/ +guard (preempt_notrace)(); + syscall_nr =trace_get_syscall_nr (current, regs);if (syscall_nr <0 || syscall_nr >= NR_syscalls)return ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 4/33 tracing: Use atomic64_inc_return() in trace_clock_counter()
In reply to Sasha LevinFrom: Uros Bizjak <[email protected]>
[ Upstream commit eb887c4567d1b0e7684c026fe7df44afa96589e6 ]
Use atomic64_inc_return(&ref) instead of atomic64_add_return(1, &ref) to use optimized implementation and ease register pressure around the primitive for targets that implement optimized variant.
--- kernel/trace/trace_clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_clock.c +1 -1
@@ -154,5 +154,5 @@ static atomic64_t trace_counter;*/ u64 notrace trace_clock_counter(void) { -return atomic64_add_return (1 , &trace_counter); +return atomic64_inc_return (&trace_counter); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 5/33 tools/rtla: fix collision with glibc sched_attr/sched_set_attr
In reply to Sasha LevinFrom: Jan Stancek <[email protected]>
[ Upstream commit 0eecee340672c4b512f6f4a8c6add26df05d130c ]
glibc commit 21571ca0d703 ("Linux: Add the sched_setattr and sched_getattr functions") now also provides 'struct sched_attr' and sched_setattr() which collide with the ones from rtla.
In file included from src/trace.c:11:
src/utils.h:49:8: error: redefinition of ‘struct sched_attr’
49 | struct sched_attr {
| ^~~~~~~~~~
In file included from /usr/include/bits/sched.h:60,
from /usr/include/sched.h:43,
from /usr/include/tracefs/tracefs.h:10,
from src/trace.c:4:
/usr/include/linux/sched/types.h:98:8: note: originally defined here
98 | struct sched_attr {
| ^~~~~~~~~~Define 'struct sched_attr' conditionally, similar to what strace did:
https://lore.kernel.org/all/[email protected]/
and rename rtla's version of sched_setattr() to avoid collision.
--- tools/tracing/rtla/src/utils.c | 4 ++-- tools/tracing/rtla/src/utils.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)
tools/tracing/rtla/src/utils.c +2 -2
@@ -233,7 +233,7 @@ long parse_ns_duration(char *val)#define SCHED_DEADLINE 6 -static inline int sched_setattr (pid_t pid,const struct sched_attr *attr, +static inline int syscall_sched_setattr (pid_t pid,const struct sched_attr *attr,unsigned int flags) {return syscall (__NR_sched_setattr, pid, attr, flags); }
@@ -243,7 +243,7 @@ int __set_sched_attr(int pid, struct sched_attr *attr)int flags =0 ;int retval; - retval =sched_setattr (pid, attr, flags); + retval =syscall_sched_setattr (pid, attr, flags);if (retval <0 ) {err_msg ("Failed to set sched attributes to the pid %d: %s\n" , pid,strerror (errno));
tools/tracing/rtla/src/utils.h +2 -0
@@ -46,6 +46,7 @@ update_sum(unsigned long long *a, unsigned long long *b) *a += *b; } +#ifndef SCHED_ATTR_SIZE_VER0 struct sched_attr { uint32_t size; uint32_t sched_policy;
@@ -56,6 +57,7 @@ struct sched_attr {uint64_t sched_deadline; uint64_t sched_period; }; +#endif /* SCHED_ATTR_SIZE_VER0 */ int parse_prio (char *arg,struct sched_attr *sched_param);int parse_cpu_set (char *cpu_list,cpu_set_t *set);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 6/33 rtla/timerlat: Make timerlat_top_cpu->*_count unsigned long long
In reply to Sasha LevinFrom: Tomas Glozar <[email protected]>
[ Upstream commit 4eba4723c5254ba8251ecb7094a5078d5c300646 ]
Most fields of struct timerlat_top_cpu are unsigned long long, but the fields {irq,thread,user}_count are int (32-bit signed).
This leads to overflow when tracing on a large number of CPUs for a long enough time:
$ rtla timerlat top -a20 -c 1-127 -d 12h ... 0 12:00:00 | IRQ Timer Latency (us) | Thread Timer Latency (us) CPU COUNT | cur min avg max | cur min avg max 1 #43200096 | 0 0 1 2 | 3 2 6 12 ... 127 #43200096 | 0 0 1 2 | 3 2 5 11 ALL #119144 e4 | 0 5 4 | 2 28 16
The average latency should be 0-1 for IRQ and 5-6 for thread, but is reported as 5 and 28, about 4 to 5 times more, due to the count overflowing when summed over all CPUs: 43200096 * 127 = 5486412192, however, 1191444898 (= 5486412192 mod MAX_INT) is reported instead, as seen on the last line of the output, and the averages are thus ~4.6 times higher than they should be (5486412192 / 1191444898 = ~4.6).
Fix the issue by changing {irq,thread,user}_count fields to unsigned long long, similarly to other fields in struct timerlat_top_cpu and to the count variable in timerlat_top_print_sum.
--- tools/tracing/rtla/src/timerlat_top.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/tracing/rtla/src/timerlat_top.c +4 -4
@@ -54,9 +54,9 @@ struct timerlat_top_params { };struct timerlat_top_cpu { -int irq_count; -int thread_count; -int user_count; +unsigned long long irq_count; +unsigned long long thread_count; +unsigned long long user_count;unsigned long long cur_irq;unsigned long long min_irq;
@@ -280,7 +280,7 @@ static void timerlat_top_print(struct osnoise_tool *top, int cpu)/* * Unless trace is being lost, IRQ counter is always the max. */ -trace_seq_printf (s,"%3d #%-9d |" , cpu, cpu_data->irq_count); +trace_seq_printf (s,"%3d #%-9llu |" , cpu, cpu_data->irq_count);if (!cpu_data->irq_count) {trace_seq_printf (s,"%s %s %s %s |" , no_value, no_value, no_value, no_value);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 7/33 rtla/timerlat: Make timerlat_hist_cpu->*_count unsigned long long
In reply to Sasha LevinFrom: Tomas Glozar <[email protected]>
[ Upstream commit 76b3102148135945b013797fac9b206273f0f777 ]
Do the same fix as in previous commit also for timerlat-hist.
--- tools/tracing/rtla/src/timerlat_hist.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
tools/tracing/rtla/src/timerlat_hist.c +9 -9
@@ -62,9 +62,9 @@ struct timerlat_hist_cpu {int *thread;int *user; -int irq_count; -int thread_count; -int user_count; +unsigned long long irq_count; +unsigned long long thread_count; +unsigned long long user_count;unsigned long long min_irq;unsigned long long sum_irq;
@@ -304,15 +304,15 @@ timerlat_print_summary(struct timerlat_hist_params *params,continue ;if (!params->no_irq) -trace_seq_printf (trace->seq,"%9d " , +trace_seq_printf (trace->seq,"%9llu " , data->hist[cpu].irq_count);if (!params->no_thread) -trace_seq_printf (trace->seq,"%9d " , +trace_seq_printf (trace->seq,"%9llu " , data->hist[cpu].thread_count);if (params->user_hist) -trace_seq_printf (trace->seq,"%9d " , +trace_seq_printf (trace->seq,"%9llu " , data->hist[cpu].user_count); }trace_seq_printf (trace->seq,"\n" );
@@ -488,15 +488,15 @@ timerlat_print_stats_all(struct timerlat_hist_params *params,trace_seq_printf (trace->seq,"count:" );if (!params->no_irq) -trace_seq_printf (trace->seq,"%9d " , +trace_seq_printf (trace->seq,"%9llu " , sum.irq_count);if (!params->no_thread) -trace_seq_printf (trace->seq,"%9d " , +trace_seq_printf (trace->seq,"%9llu " , sum.thread_count);if (params->user_hist) -trace_seq_printf (trace->seq,"%9d " , +trace_seq_printf (trace->seq,"%9llu " , sum.user_count);trace_seq_printf (trace->seq,"\n" );
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 8/33 scsi: hisi_sas: Add cond_resched() for no forced preemption model
In reply to Sasha LevinFrom: Yihang Li <[email protected]>
[ Upstream commit 2233c4a0b948211743659b24c13d6bd059fa75fc ]
For no forced preemption model kernel, in the scenario where the expander is connected to 12 high performance SAS SSDs, the following call trace may occur:
[ 214.409199][ C240] watchdog: BUG: soft lockup - CPU#240 stuck for 22s! [irq/149-hisi_sa:3211] [ 214.568533][ C240] pstate: 60400009 (nZCv daif +PAN -UAO -TCO BTYPE=--) [ 214.575224][ C240] pc : fput_many+0x8c/0xdc [ 214.579480][ C240] lr : fput+0x1c/0xf0 [ 214.583302][ C240] sp : ffff80002de2b900 [ 214.587298][ C240] x29: ffff80002de2b900 x28: ffff1082aa412000 [ 214.593291][ C240] x27: ffff3062a0348c08 x26: ffff80003a9f6000 [ 214.599284][ C240] x25: ffff1062bbac5c40 x24: 0000000000001000 [ 214.605277][ C240] x23: 000000000000000a x22: 0000000000000001 [ 214.611270][ C240] x21: 0000000000001000 x20: 0000000000000000 [ 214.617262][ C240] x19: ffff3062a41ae580 x18: 0000000000010000 [ 214.623255][ C240] x17: 0000000000000001 x16: ffffdb3a6efe5fc0 [ 214.629248][ C240] x15: ffffffffffffffff x14: 0000000003ffffff [ 214.635241][ C240] x13: 000000000000ffff x12: 000000000000029c [ 214.641234][ C240] x11: 0000000000000006 x10: ffff80003a9f7fd0 [ 214.647226][ C240] x9 : ffffdb3a6f0482fc x8 : 0000000000000001 [ 214.653219][ C240] x7 : 0000000000000002 x6 : 0000000000000080 [ 214.659212][ C240] x5 : ffff55480ee9b000 x4 : fffffde7f94c6554 [ 214.665205][ C240] x3 : 0000000000000002 x2 : 0000000000000020 [ 214.671198][ C240] x1 : 0000000000000021 x0 : ffff3062a41ae5b8 [ 214.677191][ C240] Call trace: [ 214.680320][ C240] fput_many+0x8c/0xdc [ 214.684230][ C240] fput+0x1c/0xf0 [ 214.687707][ C240] aio_complete_rw+0xd8/0x1fc [ 214.692225][ C240] blkdev_bio_end_io+0x98/0x140 [ 214.696917][ C240] bio_endio+0x160/0x1bc [ 214.701001][ C240] blk_update_request+0x1c8/0x3bc [ 214.705867][ C240] scsi_end_request+0x3c/0x1f0 [ 214.710471][ C240] scsi_io_completion+0x7c/0x1a0 [ 214.715249][ C240] scsi_finish_command+0x104/0x140 [ 214.720200][ C240] scsi_softirq_done+0x90/0x180 [ 214.724892][ C240] blk_mq_complete_request+0x5c/0x70 [ 214.730016][ C240] scsi_mq_done+0x48/0xac [ 214.734194][ C240] sas_scsi_task_done+0xbc/0x16c [libsas] [ 214.739758][ C240] slot_complete_v3_hw+0x260/0x760 [hisi_sas_v3_hw] [ 214.746185][ C240] cq_thread_v3_hw+0xbc/0x190 [hisi_sas_v3_hw] [ 214.752179][ C240] irq_thread_fn+0x34/0xa4 [ 214.756435][ C240] irq_thread+0xc4/0x130 [ 214.760520][ C240] kthread+0x108/0x13c [ 214.764430][ C240] ret_from_fork+0x10/0x18
This is because in the hisi_sas driver, both the hardware interrupt handler and the interrupt thread are executed on the same CPU. In the performance test scenario, function irq_wait_for_interrupt() will always return 0 if lots of interrupts occurs and the CPU will be continuously consumed. As a result, the CPU cannot run the watchdog thread. When the watchdog time exceeds the specified time, call trace occurs.
To fix it, add cond_resched() to execute the watchdog thread.
--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +1 -0
@@ -2493,6 +2493,7 @@ static int complete_v3_hw(struct hisi_sas_cq *cq)/* update rd_point */ cq->rd_point = rd_point;hisi_sas_write32 (hisi_hba,COMPL_Q_0_RD_PTR + (0x14 * queue), rd_point); +cond_resched ();return completed; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 9/33 scsi: hisi_sas: Create all dump files during debugfs initialization
In reply to Sasha LevinFrom: Yihang Li <[email protected]>
[ Upstream commit 9f564f15f88490b484e02442dc4c4b11640ea172 ]
For the current debugfs of hisi_sas, after user triggers dump, the driver allocate memory space to save the register information and create debugfs files to display the saved information. In this process, the debugfs files created after each dump.
Therefore, when the dump is triggered while the driver is unbind, the following hang occurs:
[67840.853907] Unable to handle kernel NULL pointer dereference at virtual address 00000000000000a0 [67840.862947] Mem abort info: [67840.865855] ESR = 0x0000000096000004 [67840.869713] EC = 0x25: DABT (current EL), IL = 32 bits [67840.875125] SET = 0, FnV = 0 [67840.878291] EA = 0, S1PTW = 0 [67840.881545] FSC = 0x04: level 0 translation fault [67840.886528] Data abort info: [67840.889524] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000 [67840.895117] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 [67840.900284] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 [67840.905709] user pgtable: 4k pages, 48-bit VAs, pgdp=0000002803a1f000 [67840.912263] [00000000000000a0] pgd=0000000000000000, p4d=0000000000000000 [67840.919177] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP [67840.996435] pstate: 80400009 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [67841.003628] pc : down_write+0x30/0x98 [67841.007546] lr : start_creating.part.0+0x60/0x198 [67841.012495] sp : ffff8000b979ba20 [67841.016046] x29: ffff8000b979ba20 x28: 0000000000000010 x27: 0000000000024b40 [67841.023412] x26: 0000000000000012 x25: ffff20202b355ae8 x24: ffff20202b35a8c8 [67841.030779] x23: ffffa36877928208 x22: ffffa368b4972240 x21: ffff8000b979bb18 [67841.038147] x20: ffff00281dc1e3c0 x19: fffffffffffffffe x18: 0000000000000020 [67841.045515] x17: 0000000000000000 x16: ffffa368b128a530 x15: ffffffffffffffff [67841.052888] x14: ffff8000b979bc18 x13: ffffffffffffffff x12: ffff8000b979bb18 [67841.060263] x11: 0000000000000000 x10: 0000000000000000 x9 : ffffa368b1289b18 [67841.067640] x8 : 0000000000000012 x7 : 0000000000000000 x6 : 00000000000003a9 [67841.075014] x5 : 0000000000000000 x4 : ffff002818c5cb00 x3 : 0000000000000001 [67841.082388] x2 : 0000000000000000 x1 : ffff002818c5cb00 x0 : 00000000000000a0 [67841.089759] Call trace: [67841.092456] down_write+0x30/0x98 [67841.096017] start_creating.part.0+0x60/0x198 [67841.100613] debugfs_create_dir+0x48/0x1f8 [67841.104950] debugfs_create_files_v3_hw+0x88/0x348 [hisi_sas_v3_hw] [67841.111447] debugfs_snapshot_regs_v3_hw+0x708/0x798 [hisi_sas_v3_hw] [67841.118111] debugfs_trigger_dump_v3_hw_write+0x9c/0x120 [hisi_sas_v3_hw] [67841.125115] full_proxy_write+0x68/0xc8 [67841.129175] vfs_write+0xd8/0x3f0 [67841.132708] ksys_write+0x70/0x108 [67841.136317] __arm64_sys_write+0x24/0x38 [67841.140440] invoke_syscall+0x50/0x128 [67841.144385] el0_svc_common.constprop.0+0xc8/0xf0 [67841.149273] do_el0_svc+0x24/0x38 [67841.152773] el0_svc+0x38/0xd8 [67841.156009] el0t_64_sync_handler+0xc0/0xc8 [67841.160361] el0t_64_sync+0x1a4/0x1a8 [67841.164189] Code: b9000882 d2800002 d2800023 f9800011 (c85ffc05) [67841.170443] ---[ end trace 0000000000000000 ]---
To fix this issue, create all directories and files during debugfs initialization. In this way, the driver only needs to allocate memory space to save information each time the user triggers dumping.
--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 99 ++++++++++++++++++++------ 1 file changed, 77 insertions(+), 22 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +77 -22
@@ -3551,6 +3551,11 @@ debugfs_to_reg_name_v3_hw(int off, int base_off,return NULL ; } +static bool debugfs_dump_is_generated_v3_hw (void *p) +{ +return p ? true : false; +} +static void debugfs_print_reg_v3_hw (u32 *regs_val,struct seq_file *s,const struct hisi_sas_debugfs_reg *reg) {
@@ -3576,6 +3581,9 @@ static int debugfs_global_v3_hw_show(struct seq_file *s, void *p) {struct hisi_sas_debugfs_regs *global = s->private; +if (!debugfs_dump_is_generated_v3_hw (global->data)) +return -EPERM ; +debugfs_print_reg_v3_hw (global->data, s, &debugfs_global_reg);
@@ -3587,6 +3595,9 @@ static int debugfs_axi_v3_hw_show(struct seq_file *s, void *p) {struct hisi_sas_debugfs_regs *axi = s->private; +if (!debugfs_dump_is_generated_v3_hw (axi->data)) +return -EPERM ; +debugfs_print_reg_v3_hw (axi->data, s, &debugfs_axi_reg);
@@ -3598,6 +3609,9 @@ static int debugfs_ras_v3_hw_show(struct seq_file *s, void *p) {struct hisi_sas_debugfs_regs *ras = s->private; +if (!debugfs_dump_is_generated_v3_hw (ras->data)) +return -EPERM ; +debugfs_print_reg_v3_hw (ras->data, s, &debugfs_ras_reg);
@@ -3610,6 +3624,9 @@ static int debugfs_port_v3_hw_show(struct seq_file *s, void *p)struct hisi_sas_debugfs_port *port = s->private;const struct hisi_sas_debugfs_reg *reg_port = &debugfs_port_reg; +if (!debugfs_dump_is_generated_v3_hw (port->data)) +return -EPERM ; +debugfs_print_reg_v3_hw (port->data, s, reg_port);return 0 ;
@@ -3665,6 +3682,9 @@ static int debugfs_cq_v3_hw_show(struct seq_file *s, void *p)struct hisi_sas_debugfs_cq *debugfs_cq = s->private;int slot; +if (!debugfs_dump_is_generated_v3_hw (debugfs_cq->complete_hdr)) +return -EPERM ; +for (slot =0 ; slot <HISI_SAS_QUEUE_SLOTS ; slot++)debugfs_cq_show_slot_v3_hw (s, slot, debugfs_cq);
@@ -3686,8 +3706,12 @@ static void debugfs_dq_show_slot_v3_hw(struct seq_file *s, int slot,static int debugfs_dq_v3_hw_show (struct seq_file *s,void *p) { +struct hisi_sas_debugfs_dq *debugfs_dq = s->private;int slot; +if (!debugfs_dump_is_generated_v3_hw (debugfs_dq->hdr)) +return -EPERM ; +for (slot =0 ; slot <HISI_SAS_QUEUE_SLOTS ; slot++)debugfs_dq_show_slot_v3_hw (s, slot, s->private);
@@ -3701,6 +3725,9 @@ static int debugfs_iost_v3_hw_show(struct seq_file *s, void *p)struct hisi_sas_iost *iost = debugfs_iost->iost;int i, max_command_entries =HISI_SAS_MAX_COMMANDS ; +if (!debugfs_dump_is_generated_v3_hw (iost)) +return -EPERM ; +for (i =0 ; i < max_command_entries; i++, iost++) {__le64 *data = &iost->qw0;
@@ -3720,6 +3747,9 @@ static int debugfs_iost_cache_v3_hw_show(struct seq_file *s, void *p)int i, tab_idx;__le64 *iost; +if (!debugfs_dump_is_generated_v3_hw (iost_cache)) +return -EPERM ; +for (i =0 ; i <HISI_SAS_IOST_ITCT_CACHE_NUM ; i++, iost_cache++) {/* * Data struct of IOST cache:
@@ -3743,6 +3773,9 @@ static int debugfs_itct_v3_hw_show(struct seq_file *s, void *p)struct hisi_sas_debugfs_itct *debugfs_itct = s->private;struct hisi_sas_itct *itct = debugfs_itct->itct; +if (!debugfs_dump_is_generated_v3_hw (itct)) +return -EPERM ; +for (i =0 ; i <HISI_SAS_MAX_ITCT_ENTRIES ; i++, itct++) {__le64 *data = &itct->qw0;
@@ -3762,6 +3795,9 @@ static int debugfs_itct_cache_v3_hw_show(struct seq_file *s, void *p)int i, tab_idx;__le64 *itct; +if (!debugfs_dump_is_generated_v3_hw (itct_cache)) +return -EPERM ; +for (i =0 ; i <HISI_SAS_IOST_ITCT_CACHE_NUM ; i++, itct_cache++) {/* * Data struct of ITCT cache:
@@ -3779,10 +3815,9 @@ static int debugfs_itct_cache_v3_hw_show(struct seq_file *s, void *p) }DEFINE_SHOW_ATTRIBUTE (debugfs_itct_cache_v3_hw); -static void debugfs_create_files_v3_hw (struct hisi_hba *hisi_hba) +static void debugfs_create_files_v3_hw (struct hisi_hba *hisi_hba,int index) {u64 *debugfs_timestamp; -int dump_index = hisi_hba->debugfs_dump_index;struct dentry *dump_dentry;struct dentry *dentry;char name[256 ];
@@ -3790,17 +3825,17 @@ static void debugfs_create_files_v3_hw(struct hisi_hba *hisi_hba)int c;int d; -snprintf (name,256 ,"%d" , dump_index); +snprintf (name,256 ,"%d" , index); dump_dentry =debugfs_create_dir (name, hisi_hba->debugfs_dump_dentry); - debugfs_timestamp = &hisi_hba->debugfs_timestamp[dump_index]; + debugfs_timestamp = &hisi_hba->debugfs_timestamp[index];debugfs_create_u64 ("timestamp" ,0400 , dump_dentry, debugfs_timestamp);debugfs_create_file ("global" ,0400 , dump_dentry, - &hisi_hba->debugfs_regs[dump_index][DEBUGFS_GLOBAL ], + &hisi_hba->debugfs_regs[index][DEBUGFS_GLOBAL ], &debugfs_global_v3_hw_fops);/* Create port dir and files */
@@ -3809,7 +3844,7 @@ static void debugfs_create_files_v3_hw(struct hisi_hba *hisi_hba)snprintf (name,256 ,"%d" , p);debugfs_create_file (name,0400 , dentry, - &hisi_hba->debugfs_port_reg[dump_index][p], + &hisi_hba->debugfs_port_reg[index][p], &debugfs_port_v3_hw_fops); }
@@ -3819,7 +3854,7 @@ static void debugfs_create_files_v3_hw(struct hisi_hba *hisi_hba)snprintf (name,256 ,"%d" , c);debugfs_create_file (name,0400 , dentry, - &hisi_hba->debugfs_cq[dump_index][c], + &hisi_hba->debugfs_cq[index][c], &debugfs_cq_v3_hw_fops); }
@@ -3829,32 +3864,32 @@ static void debugfs_create_files_v3_hw(struct hisi_hba *hisi_hba)snprintf (name,256 ,"%d" , d);debugfs_create_file (name,0400 , dentry, - &hisi_hba->debugfs_dq[dump_index][d], + &hisi_hba->debugfs_dq[index][d], &debugfs_dq_v3_hw_fops); }debugfs_create_file ("iost" ,0400 , dump_dentry, - &hisi_hba->debugfs_iost[dump_index], + &hisi_hba->debugfs_iost[index], &debugfs_iost_v3_hw_fops);debugfs_create_file ("iost_cache" ,0400 , dump_dentry, - &hisi_hba->debugfs_iost_cache[dump_index], + &hisi_hba->debugfs_iost_cache[index], &debugfs_iost_cache_v3_hw_fops);debugfs_create_file ("itct" ,0400 , dump_dentry, - &hisi_hba->debugfs_itct[dump_index], + &hisi_hba->debugfs_itct[index], &debugfs_itct_v3_hw_fops);debugfs_create_file ("itct_cache" ,0400 , dump_dentry, - &hisi_hba->debugfs_itct_cache[dump_index], + &hisi_hba->debugfs_itct_cache[index], &debugfs_itct_cache_v3_hw_fops);debugfs_create_file ("axi" ,0400 , dump_dentry, - &hisi_hba->debugfs_regs[dump_index][DEBUGFS_AXI ], + &hisi_hba->debugfs_regs[index][DEBUGFS_AXI ], &debugfs_axi_v3_hw_fops);debugfs_create_file ("ras" ,0400 , dump_dentry, - &hisi_hba->debugfs_regs[dump_index][DEBUGFS_RAS ], + &hisi_hba->debugfs_regs[index][DEBUGFS_RAS ], &debugfs_ras_v3_hw_fops); }
@@ -4517,22 +4552,34 @@ static void debugfs_release_v3_hw(struct hisi_hba *hisi_hba, int dump_index)int i;devm_kfree (dev, hisi_hba->debugfs_iost_cache[dump_index].cache); + hisi_hba->debugfs_iost_cache[dump_index].cache =NULL ;devm_kfree (dev, hisi_hba->debugfs_itct_cache[dump_index].cache); + hisi_hba->debugfs_itct_cache[dump_index].cache =NULL ;devm_kfree (dev, hisi_hba->debugfs_iost[dump_index].iost); + hisi_hba->debugfs_iost[dump_index].iost =NULL ;devm_kfree (dev, hisi_hba->debugfs_itct[dump_index].itct); + hisi_hba->debugfs_itct[dump_index].itct =NULL ; -for (i =0 ; i < hisi_hba->queue_count; i++) +for (i =0 ; i < hisi_hba->queue_count; i++) {devm_kfree (dev, hisi_hba->debugfs_dq[dump_index][i].hdr); + hisi_hba->debugfs_dq[dump_index][i].hdr =NULL ; + } -for (i =0 ; i < hisi_hba->queue_count; i++) +for (i =0 ; i < hisi_hba->queue_count; i++) {devm_kfree (dev, hisi_hba->debugfs_cq[dump_index][i].complete_hdr); + hisi_hba->debugfs_cq[dump_index][i].complete_hdr =NULL ; + } -for (i =0 ; i <DEBUGFS_REGS_NUM ; i++) +for (i =0 ; i <DEBUGFS_REGS_NUM ; i++) {devm_kfree (dev, hisi_hba->debugfs_regs[dump_index][i].data); + hisi_hba->debugfs_regs[dump_index][i].data =NULL ; + } -for (i =0 ; i < hisi_hba->n_phy; i++) +for (i =0 ; i < hisi_hba->n_phy; i++) {devm_kfree (dev, hisi_hba->debugfs_port_reg[dump_index][i].data); + hisi_hba->debugfs_port_reg[dump_index][i].data =NULL ; + } }static const struct hisi_sas_debugfs_reg *debugfs_reg_array_v3_hw[DEBUGFS_REGS_NUM ] = {
@@ -4659,8 +4706,6 @@ static int debugfs_snapshot_regs_v3_hw(struct hisi_hba *hisi_hba)debugfs_snapshot_itct_reg_v3_hw (hisi_hba);debugfs_snapshot_iost_reg_v3_hw (hisi_hba); -debugfs_create_files_v3_hw (hisi_hba); -debugfs_snapshot_restore_v3_hw (hisi_hba); hisi_hba->debugfs_dump_index++;
@@ -4744,6 +4789,17 @@ static void debugfs_bist_init_v3_hw(struct hisi_hba *hisi_hba) hisi_hba->debugfs_bist_linkrate =SAS_LINK_RATE_1_5_GBPS ; } +static void debugfs_dump_init_v3_hw (struct hisi_hba *hisi_hba) +{ +int i; + + hisi_hba->debugfs_dump_dentry = +debugfs_create_dir ("dump" , hisi_hba->debugfs_dir); + +for (i =0 ; i < hisi_sas_debugfs_dump_count; i++) +debugfs_create_files_v3_hw (hisi_hba, i); +} +static void debugfs_exit_v3_hw (struct hisi_hba *hisi_hba) {debugfs_remove_recursive (hisi_hba->debugfs_dir);
@@ -4764,8 +4820,7 @@ static void debugfs_init_v3_hw(struct hisi_hba *hisi_hba)/* create bist structures */ debugfs_bist_init_v3_hw (hisi_hba); - hisi_hba->debugfs_dump_dentry = -debugfs_create_dir ("dump" , hisi_hba->debugfs_dir); +debugfs_dump_init_v3_hw (hisi_hba);debugfs_phy_down_cnt_init_v3_hw (hisi_hba);debugfs_fifo_init_v3_hw (hisi_hba);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 10/33 rtla/utils: Add idle state disabling via libcpupower
In reply to Sasha LevinFrom: Tomas Glozar <[email protected]>
[ Upstream commit 083d29d3784319e9e9fab3ac02683a7b26ae3480 ]
Add functions to utils.c to disable idle states through functions of libcpupower. This will serve as the basis for disabling idle states per cpu when running timerlat.
--- tools/tracing/rtla/src/utils.c | 150 +++++++++++++++++++++++++++++++++ tools/tracing/rtla/src/utils.h | 13 +++ 2 files changed, 163 insertions(+)
tools/tracing/rtla/src/utils.c +150 -0
@@ -4,6 +4,9 @@*/ #define _GNU_SOURCE +#ifdef HAVE_LIBCPUPOWER_SUPPORT +#include <cpuidle.h> +#endif /* HAVE_LIBCPUPOWER_SUPPORT */ #include <dirent.h> #include <stdarg.h> #include <stdlib.h>
@@ -519,6 +522,153 @@ int set_cpu_dma_latency(int32_t latency)return fd; } +#ifdef HAVE_LIBCPUPOWER_SUPPORT +static unsigned int **saved_cpu_idle_disable_state; +static size_t saved_cpu_idle_disable_state_alloc_ctr; + +/* +* save_cpu_idle_state_disable - save disable for all idle states of a cpu +* +* Saves the current disable of all idle states of a cpu, to be subsequently +* restored via restore_cpu_idle_disable_state. +* +* Return: idle state count on success, negative on error +*/ +int save_cpu_idle_disable_state (unsigned int cpu) +{ +unsigned int nr_states; +unsigned int state; +int disabled; +int nr_cpus; + + nr_states =cpuidle_state_count (cpu); + +if (nr_states ==0 ) +return 0 ; + +if (saved_cpu_idle_disable_state ==NULL ) { + nr_cpus =sysconf (_SC_NPROCESSORS_CONF); + saved_cpu_idle_disable_state =calloc (nr_cpus,sizeof (unsigned int *)); +if (!saved_cpu_idle_disable_state) +return -1 ; + } + + saved_cpu_idle_disable_state[cpu] =calloc (nr_states,sizeof (unsigned int )); +if (!saved_cpu_idle_disable_state[cpu]) +return -1 ; + saved_cpu_idle_disable_state_alloc_ctr++; + +for (state =0 ; state < nr_states; state++) { + disabled =cpuidle_is_state_disabled (cpu, state); +if (disabled <0 ) +return disabled; + saved_cpu_idle_disable_state[cpu][state] = disabled; + } + +return nr_states; +} + +/* +* restore_cpu_idle_disable_state - restore disable for all idle states of a cpu +* +* Restores the current disable state of all idle states of a cpu that was +* previously saved by save_cpu_idle_disable_state. +* +* Return: idle state count on success, negative on error +*/ +int restore_cpu_idle_disable_state (unsigned int cpu) +{ +unsigned int nr_states; +unsigned int state; +int disabled; +int result; + + nr_states =cpuidle_state_count (cpu); + +if (nr_states ==0 ) +return 0 ; + +if (!saved_cpu_idle_disable_state) +return -1 ; + +for (state =0 ; state < nr_states; state++) { +if (!saved_cpu_idle_disable_state[cpu]) +return -1 ; + disabled = saved_cpu_idle_disable_state[cpu][state]; + result =cpuidle_state_disable (cpu, state, disabled); +if (result <0 ) +return result; + } + +free (saved_cpu_idle_disable_state[cpu]); + saved_cpu_idle_disable_state[cpu] =NULL ; + saved_cpu_idle_disable_state_alloc_ctr--; +if (saved_cpu_idle_disable_state_alloc_ctr ==0 ) { +free (saved_cpu_idle_disable_state); + saved_cpu_idle_disable_state =NULL ; + } + +return nr_states; +} + +/* +* free_cpu_idle_disable_states - free saved idle state disable for all cpus +* +* Frees the memory used for storing cpu idle state disable for all cpus +* and states. +* +* Normally, the memory is freed automatically in +* restore_cpu_idle_disable_state; this is mostly for cleaning up after an +* error. +*/ +void free_cpu_idle_disable_states (void ) +{ +int cpu; +int nr_cpus; + +if (!saved_cpu_idle_disable_state) +return ; + + nr_cpus =sysconf (_SC_NPROCESSORS_CONF); + +for (cpu =0 ; cpu < nr_cpus; cpu++) { +free (saved_cpu_idle_disable_state[cpu]); + saved_cpu_idle_disable_state[cpu] =NULL ; + } + +free (saved_cpu_idle_disable_state); + saved_cpu_idle_disable_state =NULL ; +} + +/* +* set_deepest_cpu_idle_state - limit idle state of cpu +* +* Disables all idle states deeper than the one given in +* deepest_state (assuming states with higher number are deeper). +* +* This is used to reduce the exit from idle latency. Unlike +* set_cpu_dma_latency, it can disable idle states per cpu. +* +* Return: idle state count on success, negative on error +*/ +int set_deepest_cpu_idle_state (unsigned int cpu,unsigned int deepest_state) +{ +unsigned int nr_states; +unsigned int state; +int result; + + nr_states =cpuidle_state_count (cpu); + +for (state = deepest_state +1 ; state < nr_states; state++) { + result =cpuidle_state_disable (cpu, state,1 ); +if (result <0 ) +return result; + } + +return nr_states; +} +#endif /* HAVE_LIBCPUPOWER_SUPPORT */ +#define _STR (x) #x#define STR (x) _STR(x)
tools/tracing/rtla/src/utils.h +13 -0
@@ -66,6 +66,19 @@ int set_comm_sched_attr(const char *comm_prefix, struct sched_attr *attr);int set_comm_cgroup (const char *comm_prefix,const char *cgroup);int set_pid_cgroup (pid_t pid,const char *cgroup);int set_cpu_dma_latency (int32_t latency); +#ifdef HAVE_LIBCPUPOWER_SUPPORT +int save_cpu_idle_disable_state (unsigned int cpu); +int restore_cpu_idle_disable_state (unsigned int cpu); +void free_cpu_idle_disable_states (void ); +int set_deepest_cpu_idle_state (unsigned int cpu,unsigned int state); +static inline int have_libcpupower_support (void ) {return 1 ; } +#else +static inline int save_cpu_idle_disable_state (unsigned int cpu) {return -1 ; } +static inline int restore_cpu_idle_disable_state (unsigned int cpu) {return -1 ; } +static inline void free_cpu_idle_disable_states (void ) { } +static inline int set_deepest_cpu_idle_state (unsigned int cpu,unsigned int state) {return -1 ; } +static inline int have_libcpupower_support (void ) {return 0 ; } +#endif /* HAVE_LIBCPUPOWER_SUPPORT */ int auto_house_keeping (cpu_set_t *monitored_cpus);#define ns_to_usf (x) (((double)x/1000))
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 11/33 ring-buffer: Limit time with disabled interrupts in rb_check_pages()
In reply to Sasha LevinFrom: Petr Pavlu <[email protected]>
[ Upstream commit b237e1f7d2273fdcffac20100b72c002bdd770dd ]
The function rb_check_pages() validates the integrity of a specified per-CPU tracing ring buffer. It does so by traversing the underlying linked list and checking its next and prev links.
To guarantee that the list isn't modified during the check, a caller typically needs to take cpu_buffer->reader_lock. This prevents the check from running concurrently, for example, with a potential reader which can make the list temporarily inconsistent when swapping its old reader page into the buffer.
A problem with this approach is that the time when interrupts are disabled is non-deterministic, dependent on the ring buffer size. This particularly affects PREEMPT_RT because the reader_lock is a raw spinlock which doesn't become sleepable on PREEMPT_RT kernels.
Modify the check so it still attempts to traverse the entire list, but gives up the reader_lock between checking individual pages. Introduce for this purpose a new variable ring_buffer_per_cpu.cnt which is bumped any time the list is modified. The value is used by rb_check_pages() to detect such a change and restart the check.
--- kernel/trace/ring_buffer.c | 98 ++++++++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 26 deletions(-)
kernel/trace/ring_buffer.c +72 -26
@@ -462,6 +462,8 @@ struct ring_buffer_per_cpu {unsigned long nr_pages;unsigned int current_context;struct list_head *pages; +/* pages generation counter, incremented when the list changes */ +unsigned long cnt;struct buffer_page *head_page;/* read from head */ struct buffer_page *tail_page;/* write to tail */ struct buffer_page *commit_page;/* committed pages */
@@ -1442,40 +1444,87 @@ static void rb_check_bpage(struct ring_buffer_per_cpu *cpu_buffer,RB_WARN_ON (cpu_buffer, val &RB_FLAG_MASK ); } +static bool rb_check_links (struct ring_buffer_per_cpu *cpu_buffer, +struct list_head *list) +{ +if (RB_WARN_ON (cpu_buffer, +rb_list_head (rb_list_head (list->next)->prev) != list)) +return false; + +if (RB_WARN_ON (cpu_buffer, +rb_list_head (rb_list_head (list->prev)->next) != list)) +return false; + +return true; +} +/** * rb_check_pages - integrity check of buffer pages * @cpu_buffer: CPU buffer with pages to test * * As a safety measure we check to make sure the data pages have not * been corrupted. -* -* Callers of this function need to guarantee that the list of pages doesn't get -* modified during the check. In particular, if it's possible that the function -* is invoked with concurrent readers which can swap in a new reader page then -* the caller should take cpu_buffer->reader_lock. */ static void rb_check_pages (struct ring_buffer_per_cpu *cpu_buffer) { -struct list_head *head =rb_list_head (cpu_buffer->pages); -struct list_head *tmp; +struct list_head *head, *tmp; +unsigned long buffer_cnt; +unsigned long flags; +int nr_loops =0 ; -if (RB_WARN_ON (cpu_buffer, -rb_list_head (rb_list_head (head->next)->prev) != head)) +/* +* Walk the linked list underpinning the ring buffer and validate all +* its next and prev links. +* +* The check acquires the reader_lock to avoid concurrent processing +* with code that could be modifying the list. However, the lock cannot +* be held for the entire duration of the walk, as this would make the +* time when interrupts are disabled non-deterministic, dependent on the +* ring buffer size. Therefore, the code releases and re-acquires the +* lock after checking each page. The ring_buffer_per_cpu.cnt variable +* is then used to detect if the list was modified while the lock was +* not held, in which case the check needs to be restarted. +* +* The code attempts to perform the check at most three times before +* giving up. This is acceptable because this is only a self-validation +* to detect problems early on. In practice, the list modification +* operations are fairly spaced, and so this check typically succeeds at +* most on the second try. +*/ +again: +if (++nr_loops >3 )return ; -if (RB_WARN_ON (cpu_buffer, -rb_list_head (rb_list_head (head->prev)->next) != head)) -return ; +raw_spin_lock_irqsave (&cpu_buffer->reader_lock, flags); + head =rb_list_head (cpu_buffer->pages); +if (!rb_check_links (cpu_buffer, head)) + goto out_locked; + buffer_cnt = cpu_buffer->cnt; + tmp = head; +raw_spin_unlock_irqrestore (&cpu_buffer->reader_lock, flags); -for (tmp =rb_list_head (head->next); tmp != head; tmp =rb_list_head (tmp->next)) { -if (RB_WARN_ON (cpu_buffer, -rb_list_head (rb_list_head (tmp->next)->prev) != tmp)) -return ; +while (true) { +raw_spin_lock_irqsave (&cpu_buffer->reader_lock, flags); -if (RB_WARN_ON (cpu_buffer, -rb_list_head (rb_list_head (tmp->prev)->next) != tmp)) -return ; +if (buffer_cnt != cpu_buffer->cnt) { +/* The list was updated, try again. */ +raw_spin_unlock_irqrestore (&cpu_buffer->reader_lock, flags); + goto again; + } + + tmp =rb_list_head (tmp->next); +if (tmp == head) +/* The iteration circled back, all is done. */ + goto out_locked; + +if (!rb_check_links (cpu_buffer, tmp)) + goto out_locked; + +raw_spin_unlock_irqrestore (&cpu_buffer->reader_lock, flags); } + +out_locked: +raw_spin_unlock_irqrestore (&cpu_buffer->reader_lock, flags); } static int __rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer,
@@ -1862,6 +1911,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned long nr_pages)/* make sure pages points to a valid page in the ring buffer */ cpu_buffer->pages = next_page; + cpu_buffer->cnt++;/* update head page */ if (head_bit)
@@ -1968,6 +2018,7 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer)* pointer to point to end of list */ head_page->prev = last_page; + cpu_buffer->cnt++; success = true;break ; }
@@ -2203,12 +2254,8 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,*/ synchronize_rcu ();for_each_buffer_cpu (buffer, cpu) { -unsigned long flags; - cpu_buffer = buffer->buffers[cpu]; -raw_spin_lock_irqsave (&cpu_buffer->reader_lock, flags);rb_check_pages (cpu_buffer); -raw_spin_unlock_irqrestore (&cpu_buffer->reader_lock, flags); }atomic_dec (&buffer->record_disabled); }
@@ -4599,6 +4646,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)rb_list_head (reader->list.next)->prev = &cpu_buffer->reader_page->list;rb_inc_page (&cpu_buffer->head_page); + cpu_buffer->cnt++;local_inc (&cpu_buffer->pages_read);/* Finally update the reader page to the new head */
@@ -5138,12 +5186,9 @@ void ring_buffer_read_finish(struct ring_buffer_iter *iter) {struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer; -unsigned long flags;/* Use this opportunity to check the integrity of the ring buffer. */ -raw_spin_lock_irqsave (&cpu_buffer->reader_lock, flags);rb_check_pages (cpu_buffer); -raw_spin_unlock_irqrestore (&cpu_buffer->reader_lock, flags);atomic_dec (&cpu_buffer->resize_disabled);kfree (iter->event);
@@ -6040,6 +6085,7 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order)/* Install the new pages, remove the head from the list */ cpu_buffer->pages = cpu_buffer->new_pages.next;list_del_init (&cpu_buffer->new_pages); + cpu_buffer->cnt++; cpu_buffer->head_page = list_entry(cpu_buffer->pages, struct buffer_page, list);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 12/33 pinmux: Use sequential access to access desc->pinmux data
In reply to Sasha LevinFrom: Mukesh Ojha <[email protected]>
[ Upstream commit 5a3e85c3c397c781393ea5fb2f45b1f60f8a4e6e ]
When two client of the same gpio call pinctrl_select_state() for the same functionality, we are seeing NULL pointer issue while accessing desc->mux_owner.
Let's say two processes A, B executing in pin_request() for the same pin and process A updates the desc->mux_usecount but not yet updated the desc->mux_owner while process B see the desc->mux_usecount which got updated by A path and further executes strcmp and while accessing desc->mux_owner it crashes with NULL pointer.
Serialize the access to mux related setting with a mutex lock.
cpu0 (process A) cpu1(process B)
pinctrl_select_state() { pinctrl_select_state() {
pin_request() { pin_request() {
...
....
} else {
desc->mux_usecount++;
desc->mux_usecount && strcmp(desc->mux_owner, owner)) {
if (desc->mux_usecount > 1)
return 0;
desc->mux_owner = owner;} }
--- drivers/pinctrl/core.c | 3 + drivers/pinctrl/core.h | 1 + drivers/pinctrl/pinmux.c | 173 ++++++++++++++++++++++----------------- 3 files changed, 100 insertions(+), 77 deletions(-)
drivers/pinctrl/core.c +3 -0
@@ -220,6 +220,9 @@ static int pinctrl_register_one_pin(struct pinctrl_dev *pctldev,/* Set owner */ pindesc->pctldev = pctldev; +#ifdef CONFIG_PINMUX +mutex_init (&pindesc->mux_lock); +#endif /* Copy basic pin info */ if (pin->name) {
drivers/pinctrl/core.h +1 -0
@@ -177,6 +177,7 @@ struct pin_desc {const char *mux_owner;const struct pinctrl_setting_mux *mux_setting;const char *gpio_owner; +struct mutex mux_lock;#endif };
drivers/pinctrl/pinmux.c +96 -77
245 lines not on this page · raw message
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 13/33 scsi: ufs: core: Make DMA mask configuration more flexible
In reply to Sasha LevinFrom: Bart Van Assche <[email protected]>
[ Upstream commit 78bc671bd1501e2f6c571e063301a4fdc5db53b2 ]
Replace UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS with ufs_hba_variant_ops::set_dma_mask. Update the Renesas driver accordingly. This patch enables supporting other configurations than 32-bit or 64-bit DMA addresses, e.g. 36-bit DMA addresses.
--- drivers/ufs/core/ufshcd.c | 4 ++-- drivers/ufs/host/ufs-renesas.c | 9 ++++++++- include/ufs/ufshcd.h | 9 +++------ 3 files changed, 13 insertions(+), 9 deletions(-)
drivers/ufs/core/ufshcd.c +2 -2
@@ -2398,8 +2398,6 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)int err; hba->capabilities =ufshcd_readl (hba,REG_CONTROLLER_CAPABILITIES ); -if (hba->quirks &UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS ) - hba->capabilities &= ~MASK_64_ADDRESSING_SUPPORT ;/* nutrs and nutmrs are 0 based values */ hba->nutrs = (hba->capabilities &MASK_TRANSFER_REQUESTS_SLOTS_SDB ) +1 ;
@@ -10314,6 +10312,8 @@ EXPORT_SYMBOL_GPL(ufshcd_dealloc_host);*/ static int ufshcd_set_dma_mask (struct ufs_hba *hba) { +if (hba->vops && hba->vops->set_dma_mask) +return hba->vops->set_dma_mask (hba);if (hba->capabilities &MASK_64_ADDRESSING_SUPPORT ) {if (!dma_set_mask_and_coherent (hba->dev,DMA_BIT_MASK (64 )))return 0 ;
drivers/ufs/host/ufs-renesas.c +8 -1
@@ -7,6 +7,7 @@#include <linux/clk.h> #include <linux/delay.h> +#include <linux/dma-mapping.h> #include <linux/err.h> #include <linux/iopoll.h> #include <linux/kernel.h>
@@ -364,14 +365,20 @@ static int ufs_renesas_init(struct ufs_hba *hba)return -ENOMEM ;ufshcd_set_variant (hba, priv); - hba->quirks |=UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS |UFSHCD_QUIRK_HIBERN_FASTAUTO ; + hba->quirks |=UFSHCD_QUIRK_HIBERN_FASTAUTO ;return 0 ; } +static int ufs_renesas_set_dma_mask (struct ufs_hba *hba) +{ +return dma_set_mask_and_coherent (hba->dev,DMA_BIT_MASK (32 )); +} +static const struct ufs_hba_variant_ops ufs_renesas_vops = { .name ="renesas" , .init = ufs_renesas_init, + .set_dma_mask = ufs_renesas_set_dma_mask, .setup_clocks = ufs_renesas_setup_clocks, .hce_enable_notify = ufs_renesas_hce_enable_notify, .dbg_register_dump = ufs_renesas_dbg_register_dump,
include/ufs/ufshcd.h +3 -6
@@ -298,6 +298,8 @@ struct ufs_pwr_mode_info {* @max_num_rtt: maximum RTT supported by the host * @init: called when the driver is initialized * @exit: called to cleanup everything done in init +* @set_dma_mask: For setting another DMA mask than indicated by the 64AS +* capability bit. * @get_ufs_hci_version: called to get UFS HCI version * @clk_scale_notify: notifies that clks are scaled up/down * @setup_clocks: called before touching any of the controller registers
@@ -340,6 +342,7 @@ struct ufs_hba_variant_ops {int (*init)(struct ufs_hba *);void (*exit)(struct ufs_hba *);u32 (*get_ufs_hci_version)(struct ufs_hba *); +int (*set_dma_mask)(struct ufs_hba *);int (*clk_scale_notify)(struct ufs_hba *,bool ,enum ufs_notify_change_status ); int (*setup_clocks)(struct ufs_hba *, bool,
@@ -622,12 +625,6 @@ enum ufshcd_quirks {*/ UFSHCD_QUIRK_SKIP_PH_CONFIGURATION = 1 << 16, -/* -* This quirk needs to be enabled if the host controller has -* 64-bit addressing supported capability but it doesn't work. -*/ - UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS = 1 << 17, -/* * This quirk needs to be enabled if the host controller has * auto-hibernate capability but it's FASTAUTO only.
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 14/33 mfd: axp20x: Allow multiple regulators
In reply to Sasha LevinFrom: Andre Przywara <[email protected]>
[ Upstream commit e37ec32188701efa01455b9be42a392adab06ce4 ]
At the moment trying to register a second AXP chip makes the probe fail, as some sysfs registration fails due to a duplicate name:
...
[ 3.688215] axp20x-i2c 0-0035: AXP20X driver loaded [ 3.695610] axp20x-i2c 0-0036: AXP20x variant AXP323 found [ 3.706151] sysfs: cannot create duplicate filename '/bus/platform/devices/axp20x-regulator' [ 3.714718] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.12.0-rc1-00026-g50bf2e2c079d-dirty #192 [ 3.724020] Hardware name: Avaota A1 (DT) [ 3.728029] Call trace: [ 3.730477] dump_backtrace+0x94/0xec [ 3.734146] show_stack+0x18/0x24 [ 3.737462] dump_stack_lvl+0x80/0xf4 [ 3.741128] dump_stack+0x18/0x24 [ 3.744444] sysfs_warn_dup+0x64/0x80 [ 3.748109] sysfs_do_create_link_sd+0xf0/0xf8 [ 3.752553] sysfs_create_link+0x20/0x40 [ 3.756476] bus_add_device+0x64/0x104 [ 3.760229] device_add+0x310/0x760 [ 3.763717] platform_device_add+0x10c/0x238 [ 3.767990] mfd_add_device+0x4ec/0x5c8 [ 3.771829] mfd_add_devices+0x88/0x11c [ 3.775666] axp20x_device_probe+0x70/0x184 [ 3.779851] axp20x_i2c_probe+0x9c/0xd8
...
This is because we use PLATFORM_DEVID_NONE for the mfd_add_devices() call, which would number the child devices in the same 0-based way, even for the second (or any other) instance.
Use PLATFORM_DEVID_AUTO instead, which automatically assigns non-conflicting device numbers.
--- drivers/mfd/axp20x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/axp20x.c +1 -1
@@ -1396,7 +1396,7 @@ int axp20x_device_probe(struct axp20x_dev *axp20x) } } - ret =mfd_add_devices (axp20x->dev,-1 , axp20x->cells, + ret =mfd_add_devices (axp20x->dev,PLATFORM_DEVID_AUTO , axp20x->cells, axp20x->nr_cells,NULL ,0 ,NULL );if (ret) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 15/33 bpf: put bpf_link's program when link is safe to be deallocated
In reply to Sasha LevinFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit f44ec8733a8469143fde1984b5e6931b2e2f6f3f ]
In general, BPF link's underlying BPF program should be considered to be reachable through attach hook -> link -> prog chain, and, pessimistically, we have to assume that as long as link's memory is not safe to free, attach hook's code might hold a pointer to BPF program and use it.
As such, it's not (generally) correct to put link's program early before waiting for RCU GPs to go through. More eager bpf_prog_put() that we currently do is mostly correct due to BPF program's release code doing similar RCU GP waiting, but as will be shown in the following patches, BPF program can be non-sleepable (and, thus, reliant on only "classic" RCU GP), while BPF link's attach hook can have sleepable semantics and needs to be protected by RCU Tasks Trace, and for such cases BPF link has to go through RCU Tasks Trace + "classic" RCU GPs before being deallocated. And so, if we put BPF program early, we might free BPF program before we free BPF link, leading to use-after-free situation.
So, this patch defers bpf_prog_put() until we are ready to perform bpf_link's deallocation. At worst, this delays BPF program freeing by one extra RCU GP, but that seems completely acceptable. Alternatively, we'd need more elaborate ways to determine BPF hook, BPF link, and BPF program lifetimes, and how they relate to each other, which seems like an unnecessary complication.
Note, for most BPF links we still will perform eager bpf_prog_put() and link dealloc, so for those BPF links there are no observable changes whatsoever. Only BPF links that use deferred dealloc might notice slightly delayed freeing of BPF programs.
Also, to reduce code and logic duplication, extract program put + link dealloc logic into bpf_link_dealloc() helper.
--- kernel/bpf/syscall.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
kernel/bpf/syscall.c +17 -5
@@ -3043,12 +3043,24 @@ void bpf_link_inc(struct bpf_link *link)atomic64_inc (&link->refcnt); } +static void bpf_link_dealloc (struct bpf_link *link) +{ +/* now that we know that bpf_link itself can't be reached, put underlying BPF program */ +if (link->prog) +bpf_prog_put (link->prog); + +/* free bpf_link and its containing memory */ +if (link->ops->dealloc_deferred) + link->ops->dealloc_deferred (link); +else + link->ops->dealloc (link); +} +static void bpf_link_defer_dealloc_rcu_gp (struct rcu_head *rcu) { struct bpf_link *link = container_of(rcu, struct bpf_link, rcu); -/* free bpf_link and its containing memory */ - link->ops->dealloc_deferred (link); +bpf_link_dealloc (link); }static void bpf_link_defer_dealloc_mult_rcu_gp (struct rcu_head *rcu)
@@ -3070,7 +3082,6 @@ static void bpf_link_free(struct bpf_link *link) sleepable = link->prog->sleepable;/* detach BPF program, clean up used resources */ ops->release (link); -bpf_prog_put (link->prog); }if (ops->dealloc_deferred) {/* schedule BPF link deallocation; if underlying BPF program
@@ -3081,8 +3092,9 @@ static void bpf_link_free(struct bpf_link *link)call_rcu_tasks_trace (&link->rcu, bpf_link_defer_dealloc_mult_rcu_gp); else call_rcu(&link->rcu, bpf_link_defer_dealloc_rcu_gp); - }else if (ops->dealloc) - ops->dealloc (link); + }else if (ops->dealloc) { +bpf_link_dealloc (link); + } }static void bpf_link_put_deferred (struct work_struct *work)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 16/33 scsi: lpfc: Call lpfc_sli4_queue_unset() in restart and rmmod paths
In reply to Sasha LevinFrom: Justin Tee <[email protected]>
[ Upstream commit d35f7672715d1ff3e3ad9bb4ae6ac6cb484200fe ]
During initialization, the driver allocates wq->pring in lpfc_wq_create and lpfc_sli4_queue_unset() is the only place where kfree(wq->pring) is called.
There is a possible memory leak in lpfc_sli_brdrestart_s4() (restart) and lpfc_pci_remove_one_s4() (rmmod) paths because there are no calls to lpfc_sli4_queue_unset() to kfree() the wq->pring.
Fix by inserting a call to lpfc_sli4_queue_unset() in lpfc_sli_brdrestart_s4() and lpfc_sli4_hba_unset() routines. Also, add a check for the SLI_ACTIVE flag before issuing the Q_DESTROY mailbox command. If not set, then the mailbox command will obviously fail. In such cases, skip issuing the mailbox command and only execute the driver resource clean up portions of the lpfc_*q_destroy routines.
--- drivers/scsi/lpfc/lpfc_init.c | 2 ++ drivers/scsi/lpfc/lpfc_sli.c | 41 ++++++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 5 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +2 -0
@@ -13511,6 +13511,8 @@ lpfc_sli4_hba_unset(struct lpfc_hba *phba)/* Disable FW logging to host memory */ lpfc_ras_stop_fwlog (phba); +lpfc_sli4_queue_unset (phba); +/* Reset SLI4 HBA FCoE function */ lpfc_pci_function_reset (phba);
drivers/scsi/lpfc/lpfc_sli.c +36 -5
120 lines not on this page · raw message
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 17/33 scsi: lpfc: Check SLI_ACTIVE flag in FDMI cmpl before submitting follow up FDMI
In reply to Sasha LevinFrom: Justin Tee <[email protected]>
[ Upstream commit 98f8d3588097e321be70f83b844fa67d4828fe5c ]
The lpfc_cmpl_ct_disc_fdmi() routine has incorrect logic that treats an FDMI completion with error LOCAL_REJECT/SLI_ABORTED as a success status. Under the erroneous assumption of successful completion, the routine proceeds to issue follow up FDMI commands, which may never complete if the HBA is in an errata state as indicated by the errored completion status. Fix by freeing FDMI cmd resources and early return when the LPFC_SLI_ACTIVE flag is not set and a LOCAL_REJECT/SLI_ABORTED or SLI_DOWN status is received.
--- drivers/scsi/lpfc/lpfc_ct.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/scsi/lpfc/lpfc_ct.c +14 -7
@@ -2226,6 +2226,11 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, ulp_status, ulp_word4, latt);if (latt || ulp_status) { +lpfc_printf_vlog (vport,KERN_WARNING ,LOG_DISCOVERY , +"0229 FDMI cmd %04x failed, latt = %d " +"ulp_status: (x%x/x%x), sli_flag x%x\n" , +be16_to_cpu (fdmi_cmd), latt, ulp_status, + ulp_word4, phba->sli.sli_flag);/* Look for a retryable error */ if (ulp_status ==IOSTAT_LOCAL_REJECT ) {
@@ -2234,8 +2239,16 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,case IOERR_SLI_DOWN :/* Driver aborted this IO. No retry as error * is likely Offline->Online or some adapter -* error. Recovery will try again. +* error. Recovery will try again, but if port +* is not active there's no point to continue +* issuing follow up FDMI commands. */ +if (!(phba->sli.sli_flag &LPFC_SLI_ACTIVE )) { + free_ndlp = cmdiocb->ndlp; +lpfc_ct_free_iocb (phba, cmdiocb); +lpfc_nlp_put (free_ndlp); +return ; + }break ;case IOERR_ABORT_IN_PROGRESS :case IOERR_SEQUENCE_TIMEOUT :
@@ -2256,12 +2269,6 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,break ; } } - -lpfc_printf_vlog (vport,KERN_INFO ,LOG_DISCOVERY , -"0229 FDMI cmd %04x latt = %d " -"ulp_status: x%x, rid x%x\n" , -be16_to_cpu (fdmi_cmd), latt, ulp_status, - ulp_word4); } free_ndlp = cmdiocb->ndlp;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 18/33 scsi: lpfc: Prevent NDLP reference count underflow in dev_loss_tmo callback
In reply to Sasha LevinFrom: Justin Tee <[email protected]>
[ Upstream commit 4281f44ea8bfedd25938a0031bebba1473ece9ad ]
Current dev_loss_tmo handling checks whether there has been a previous call to unregister with SCSI transport. If so, the NDLP kref count is decremented a second time in dev_loss_tmo as the final kref release. However, this can sometimes result in a reference count underflow if there is also a race to unregister with NVMe transport as well. Add a check for NVMe transport registration before decrementing the final kref. If NVMe transport is still registered, then the NVMe transport unregistration is designated as the final kref decrement.
--- drivers/scsi/lpfc/lpfc_hbadisc.c | 36 +++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 12 deletions(-)
drivers/scsi/lpfc/lpfc_hbadisc.c +24 -12
@@ -155,6 +155,7 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport)struct lpfc_hba *phba;struct lpfc_work_evt *evtp;unsigned long iflags; +bool nvme_reg = false; ndlp = ((struct lpfc_rport_data *)rport->dd_data)->pnode;if (!ndlp)
@@ -177,38 +178,49 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport)/* Don't schedule a worker thread event if the vport is going down. */ if (test_bit (FC_UNLOADING , &vport->load_flag) || !test_bit (HBA_SETUP , &phba->hba_flag)) { +spin_lock_irqsave (&ndlp->lock, iflags); ndlp->rport =NULL ; +if (ndlp->fc4_xpt_flags &NVME_XPT_REGD ) + nvme_reg = true; +/* The scsi_transport is done with the rport so lpfc cannot -* call to unregister. Remove the scsi transport reference -* and clean up the SCSI transport node details. +* call to unregister. */ -if (ndlp->fc4_xpt_flags & (NLP_XPT_REGD |SCSI_XPT_REGD )) { +if (ndlp->fc4_xpt_flags &SCSI_XPT_REGD ) { ndlp->fc4_xpt_flags &= ~SCSI_XPT_REGD ; -/* NVME transport-registered rports need the -* NLP_XPT_REGD flag to complete an unregister. +/* If NLP_XPT_REGD was cleared in lpfc_nlp_unreg_node, +* unregister calls were made to the scsi and nvme +* transports and refcnt was already decremented. Clear +* the NLP_XPT_REGD flag only if the NVME Rport is +* confirmed unregistered. */ -if (!(ndlp->fc4_xpt_flags &NVME_XPT_REGD )) +if (!nvme_reg && ndlp->fc4_xpt_flags &NLP_XPT_REGD ) { ndlp->fc4_xpt_flags &= ~NLP_XPT_REGD ; +spin_unlock_irqrestore (&ndlp->lock, iflags); +lpfc_nlp_put (ndlp);/* may free ndlp */ + }else { +spin_unlock_irqrestore (&ndlp->lock, iflags); + } + }else {spin_unlock_irqrestore (&ndlp->lock, iflags); -lpfc_nlp_put (ndlp); -spin_lock_irqsave (&ndlp->lock, iflags); } +spin_lock_irqsave (&ndlp->lock, iflags); +/* Only 1 thread can drop the initial node reference. If * another thread has set NLP_DROPPED, this thread is done. */ -if (!(ndlp->fc4_xpt_flags &NVME_XPT_REGD ) && - !(ndlp->nlp_flag &NLP_DROPPED )) { - ndlp->nlp_flag |=NLP_DROPPED ; +if (nvme_reg || (ndlp->nlp_flag &NLP_DROPPED )) {spin_unlock_irqrestore (&ndlp->lock, iflags); -lpfc_nlp_put (ndlp);return ; } + ndlp->nlp_flag |=NLP_DROPPED ;spin_unlock_irqrestore (&ndlp->lock, iflags); +lpfc_nlp_put (ndlp);return ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 19/33 clk: qcom: rcg2: add clk_rcg2_shared_floor_ops
In reply to Sasha LevinFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit aec8c0e28ce4a1f89fd82fcc06a5cc73147e9817 ]
Generally SDCC clocks use clk_rcg2_floor_ops, however on SAR2130P platform it's recommended to use rcg2_shared_ops for all Root Clock Generators to park them instead of disabling. Implement a mix of those, clk_rcg2_shared_floor_ops.
--- drivers/clk/qcom/clk-rcg.h | 1 + drivers/clk/qcom/clk-rcg2.c | 48 +++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 5 deletions(-)
drivers/clk/qcom/clk-rcg.h +1 -0
@@ -198,6 +198,7 @@ extern const struct clk_ops clk_byte2_ops;extern const struct clk_ops clk_pixel_ops;extern const struct clk_ops clk_gfx3d_ops;extern const struct clk_ops clk_rcg2_shared_ops; +extern const struct clk_ops clk_rcg2_shared_floor_ops;extern const struct clk_ops clk_rcg2_shared_no_init_park_ops;extern const struct clk_ops clk_dp_ops;
drivers/clk/qcom/clk-rcg2.c +43 -5
74 lines not on this page · raw message
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 20/33 clk: qcom: rpmh: add support for SAR2130P
In reply to Sasha LevinFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 2cc88de6261f01ebd4e2a3b4e29681fe87d0c089 ]
Define clocks as supported by the RPMh on the SAR2130P platform. The msm-5.10 kernel declares just the CXO clock, the RF_CLK1 clock was added following recommendation from Taniya Das.
--- drivers/clk/qcom/clk-rpmh.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/clk/qcom/clk-rpmh.c +13 -0
@@ -389,6 +389,18 @@ DEFINE_CLK_RPMH_BCM(ipa, "IP0");DEFINE_CLK_RPMH_BCM (pka,"PKA0" );DEFINE_CLK_RPMH_BCM (qpic_clk,"QP0" ); +static struct clk_hw *sar2130p_rpmh_clocks[] = { + [RPMH_CXO_CLK ] = &clk_rpmh_bi_tcxo_div1.hw, + [RPMH_CXO_CLK_A ] = &clk_rpmh_bi_tcxo_div1_ao.hw, + [RPMH_RF_CLK1 ] = &clk_rpmh_rf_clk1_a.hw, + [RPMH_RF_CLK1_A ] = &clk_rpmh_rf_clk1_a_ao.hw, +}; + +static const struct clk_rpmh_desc clk_rpmh_sar2130p = { + .clks = sar2130p_rpmh_clocks, + .num_clks =ARRAY_SIZE (sar2130p_rpmh_clocks), +}; +static struct clk_hw *sdm845_rpmh_clocks[] = { [RPMH_CXO_CLK ] = &clk_rpmh_bi_tcxo_div2.hw, [RPMH_CXO_CLK_A ] = &clk_rpmh_bi_tcxo_div2_ao.hw,
@@ -880,6 +892,7 @@ static int clk_rpmh_probe(struct platform_device *pdev)static const struct of_device_id clk_rpmh_match_table[] = { { .compatible ="qcom,qdu1000-rpmh-clk" , .data = &clk_rpmh_qdu1000}, { .compatible ="qcom,sa8775p-rpmh-clk" , .data = &clk_rpmh_sa8775p}, + { .compatible ="qcom,sar2130p-rpmh-clk" , .data = &clk_rpmh_sar2130p}, { .compatible ="qcom,sc7180-rpmh-clk" , .data = &clk_rpmh_sc7180}, { .compatible ="qcom,sc8180x-rpmh-clk" , .data = &clk_rpmh_sc8180x}, { .compatible ="qcom,sc8280xp-rpmh-clk" , .data = &clk_rpmh_sc8280xp},
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 21/33 clk: qcom: tcsrcc-sm8550: add SAR2130P support
In reply to Sasha LevinFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit d2e0a043530b9d6f37a8de8f05e0725667aba0a6 ]
The SAR2130P platform has the same TCSR Clock Controller as the SM8550, except for the lack of the UFS clocks. Extend the SM8550 TCSRCC driver to support SAR2130P.
--- drivers/clk/qcom/tcsrcc-sm8550.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/clk/qcom/tcsrcc-sm8550.c +16 -2
@@ -129,6 +129,13 @@ static struct clk_branch tcsr_usb3_clkref_en = { }, }; +static struct clk_regmap *tcsr_cc_sar2130p_clocks[] = { + [TCSR_PCIE_0_CLKREF_EN ] = &tcsr_pcie_0_clkref_en.clkr, + [TCSR_PCIE_1_CLKREF_EN ] = &tcsr_pcie_1_clkref_en.clkr, + [TCSR_USB2_CLKREF_EN ] = &tcsr_usb2_clkref_en.clkr, + [TCSR_USB3_CLKREF_EN ] = &tcsr_usb3_clkref_en.clkr, +}; +static struct clk_regmap *tcsr_cc_sm8550_clocks[] = { [TCSR_PCIE_0_CLKREF_EN ] = &tcsr_pcie_0_clkref_en.clkr, [TCSR_PCIE_1_CLKREF_EN ] = &tcsr_pcie_1_clkref_en.clkr,
@@ -146,6 +153,12 @@ static const struct regmap_config tcsr_cc_sm8550_regmap_config = { .fast_io = true, }; +static const struct qcom_cc_desc tcsr_cc_sar2130p_desc = { + .config = &tcsr_cc_sm8550_regmap_config, + .clks = tcsr_cc_sar2130p_clocks, + .num_clks =ARRAY_SIZE (tcsr_cc_sar2130p_clocks), +}; +static const struct qcom_cc_desc tcsr_cc_sm8550_desc = { .config = &tcsr_cc_sm8550_regmap_config, .clks = tcsr_cc_sm8550_clocks,
@@ -153,7 +166,8 @@ static const struct qcom_cc_desc tcsr_cc_sm8550_desc = { };static const struct of_device_id tcsr_cc_sm8550_match_table[] = { - { .compatible ="qcom,sm8550-tcsr" }, + { .compatible ="qcom,sar2130p-tcsr" , .data = &tcsr_cc_sar2130p_desc }, + { .compatible ="qcom,sm8550-tcsr" , .data = &tcsr_cc_sm8550_desc }, { } };MODULE_DEVICE_TABLE (of, tcsr_cc_sm8550_match_table);
@@ -162,7 +176,7 @@ static int tcsr_cc_sm8550_probe(struct platform_device *pdev) {struct regmap *regmap; - regmap =qcom_cc_map (pdev, &tcsr_cc_sm8550_desc); + regmap =qcom_cc_map (pdev,of_device_get_match_data (&pdev->dev));if (IS_ERR (regmap))return PTR_ERR (regmap);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 22/33 clk: qcom: clk-alpha-pll: Add NSS HUAYRA ALPHA PLL support for ipq9574
In reply to Sasha LevinFrom: Devi Priya <[email protected]>
[ Upstream commit 79dfed29aa3f714e0a94a39b2bfe9ac14ce19a6a ]
Add support for NSS Huayra alpha pll found on ipq9574 SoCs. Programming sequence is the same as that of Huayra type Alpha PLL, so we can re-use the same.
--- drivers/clk/qcom/clk-alpha-pll.c | 11 +++++++++++ drivers/clk/qcom/clk-alpha-pll.h | 1 + 2 files changed, 12 insertions(+)
drivers/clk/qcom/clk-alpha-pll.c +11 -0
@@ -267,6 +267,17 @@ const u8 clk_alpha_pll_regs[][PLL_OFF_MAX_REGS] = { [PLL_OFF_OPMODE] = 0x30, [PLL_OFF_STATUS] = 0x3c, }, + [CLK_ALPHA_PLL_TYPE_NSS_HUAYRA] = { + [PLL_OFF_L_VAL] = 0x04, + [PLL_OFF_ALPHA_VAL] = 0x08, + [PLL_OFF_TEST_CTL] = 0x0c, + [PLL_OFF_TEST_CTL_U] = 0x10, + [PLL_OFF_USER_CTL] = 0x14, + [PLL_OFF_CONFIG_CTL] = 0x18, + [PLL_OFF_CONFIG_CTL_U] = 0x1c, + [PLL_OFF_STATUS] = 0x20, + }, + };EXPORT_SYMBOL_GPL (clk_alpha_pll_regs);
drivers/clk/qcom/clk-alpha-pll.h +1 -0
@@ -31,6 +31,7 @@ enum {CLK_ALPHA_PLL_TYPE_BRAMMO_EVO ,CLK_ALPHA_PLL_TYPE_STROMER ,CLK_ALPHA_PLL_TYPE_STROMER_PLUS , +CLK_ALPHA_PLL_TYPE_NSS_HUAYRA , CLK_ALPHA_PLL_TYPE_MAX, };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 23/33 leds: class: Protect brightness_show() with led_cdev->led_access mutex
In reply to Sasha LevinFrom: Mukesh Ojha <[email protected]>
[ Upstream commit 4ca7cd938725a4050dcd62ae9472e931d603118d ]
There is NULL pointer issue observed if from Process A where hid device being added which results in adding a led_cdev addition and later a another call to access of led_cdev attribute from Process B can result in NULL pointer issue.
Use mutex led_cdev->led_access to protect access to led->cdev and its attribute inside brightness_show() and max_brightness_show() and also update the comment for mutex that it should be used to protect the led class device fields.
Process A Process B
kthread+0x114
worker_thread+0x244
process_scheduled_works+0x248
uhid_device_add_worker+0x24
hid_add_device+0x120
device_add+0x268
bus_probe_device+0x94
device_initial_probe+0x14
__device_attach+0xfc
bus_for_each_drv+0x10c
__device_attach_driver+0x14c
driver_probe_device+0x3c
__driver_probe_device+0xa0
really_probe+0x190
hid_device_probe+0x130
ps_probe+0x990
ps_led_register+0x94
devm_led_classdev_register_ext+0x58
led_classdev_register_ext+0x1f8
device_create_with_groups+0x48
device_create_groups_vargs+0xc8
device_add+0x244
kobject_uevent+0x14
kobject_uevent_env[jt]+0x224
mutex_unlock[jt]+0xc4
__mutex_unlock_slowpath+0xd4
wake_up_q+0x70
try_to_wake_up[jt]+0x48c
preempt_schedule_common+0x28
__schedule+0x628
__switch_to+0x174
el0t_64_sync+0x1a8/0x1ac el0t_64_sync_handler+0x68/0xbc el0_svc+0x38/0x68 do_el0_svc+0x1c/0x28 el0_svc_common+0x80/0xe0 invoke_syscall+0x58/0x114 __arm64_sys_read+0x1c/0x2c ksys_read+0x78/0xe8 vfs_read+0x1e0/0x2c8 kernfs_fop_read_iter+0x68/0x1b4 seq_read_iter+0x158/0x4ec kernfs_seq_show+0x44/0x54 sysfs_kf_seq_show+0xb4/0x130 dev_attr_show+0x38/0x74 brightness_show+0x20/0x4c dualshock4_led_get_brightness+0xc/0x74
[ 3313.874295][ T4013] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000060 [ 3313.874301][ T4013] Mem abort info: [ 3313.874303][ T4013] ESR = 0x0000000096000006 [ 3313.874305][ T4013] EC = 0x25: DABT (current EL), IL = 32 bits [ 3313.874307][ T4013] SET = 0, FnV = 0 [ 3313.874309][ T4013] EA = 0, S1PTW = 0 [ 3313.874311][ T4013] FSC = 0x06: level 2 translation fault [ 3313.874313][ T4013] Data abort info: [ 3313.874314][ T4013] ISV = 0, ISS = 0x00000006, ISS2 = 0x00000000 [ 3313.874316][ T4013] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 [ 3313.874318][ T4013] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 [ 3313.874320][ T4013] user pgtable: 4k pages, 39-bit VAs, pgdp=00000008f2b0a000
..
[ 3313.874332][ T4013] Dumping ftrace buffer: [ 3313.874334][ T4013] (ftrace buffer empty) .. .. [ dd3313.874639][ T4013] CPU: 6 PID: 4013 Comm: InputReader [ 3313.874648][ T4013] pc : dualshock4_led_get_brightness+0xc/0x74 [ 3313.874653][ T4013] lr : led_update_brightness+0x38/0x60 [ 3313.874656][ T4013] sp : ffffffc0b910bbd0 .. .. [ 3313.874685][ T4013] Call trace: [ 3313.874687][ T4013] dualshock4_led_get_brightness+0xc/0x74 [ 3313.874690][ T4013] brightness_show+0x20/0x4c [ 3313.874692][ T4013] dev_attr_show+0x38/0x74 [ 3313.874696][ T4013] sysfs_kf_seq_show+0xb4/0x130 [ 3313.874700][ T4013] kernfs_seq_show+0x44/0x54 [ 3313.874703][ T4013] seq_read_iter+0x158/0x4ec [ 3313.874705][ T4013] kernfs_fop_read_iter+0x68/0x1b4 [ 3313.874708][ T4013] vfs_read+0x1e0/0x2c8 [ 3313.874711][ T4013] ksys_read+0x78/0xe8 [ 3313.874714][ T4013] __arm64_sys_read+0x1c/0x2c [ 3313.874718][ T4013] invoke_syscall+0x58/0x114 [ 3313.874721][ T4013] el0_svc_common+0x80/0xe0 [ 3313.874724][ T4013] do_el0_svc+0x1c/0x28 [ 3313.874727][ T4013] el0_svc+0x38/0x68 [ 3313.874730][ T4013] el0t_64_sync_handler+0x68/0xbc [ 3313.874732][ T4013] el0t_64_sync+0x1a8/0x1ac
--- drivers/leds/led-class.c | 14 +++++++++++--- include/linux/leds.h | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-)
drivers/leds/led-class.c +11 -3
@@ -29,11 +29,14 @@ static ssize_t brightness_show(struct device *dev, struct device_attribute *attr, char *buf) { struct led_classdev *led_cdev = dev_get_drvdata(dev); +unsigned int brightness; -/* no lock needed for this */ +mutex_lock (&led_cdev->led_access);led_update_brightness (led_cdev); + brightness = led_cdev->brightness; +mutex_unlock (&led_cdev->led_access); -return sprintf (buf,"%u\n" , led_cdev->brightness); +return sprintf (buf,"%u\n" , brightness); } static ssize_t brightness_store(struct device *dev,
@@ -70,8 +73,13 @@ static ssize_t max_brightness_show(struct device *dev, struct device_attribute *attr, char *buf) { struct led_classdev *led_cdev = dev_get_drvdata(dev); +unsigned int max_brightness; + +mutex_lock (&led_cdev->led_access); + max_brightness = led_cdev->max_brightness; +mutex_unlock (&led_cdev->led_access); -return sprintf (buf,"%u\n" , led_cdev->max_brightness); +return sprintf (buf,"%u\n" , max_brightness); }static DEVICE_ATTR_RO (max_brightness);
include/linux/leds.h +1 -1
@@ -238,7 +238,7 @@ struct led_classdev {struct kernfs_node *brightness_hw_changed_kn;#endif -/* Ensures consistent access to the LED Flash Class device */ +/* Ensures consistent access to the LED class device */ struct mutex led_access; };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 24/33 scsi: st: Don't modify unknown block number in MTIOCGET
In reply to Sasha LevinFrom: Kai Mäkisara <[email protected]>
[ Upstream commit 5bb2d6179d1a8039236237e1e94cfbda3be1ed9e ]
Struct mtget field mt_blkno -1 means it is unknown. Don't add anything to it.
--- drivers/scsi/st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/st.c +1 -1
@@ -3756,7 +3756,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg) ((STp->density <<MT_ST_DENSITY_SHIFT ) &MT_ST_DENSITY_MASK ); mt_status.mt_blkno = STps->drv_block; mt_status.mt_fileno = STps->drv_file; -if (STp->block_size !=0 ) { +if (STp->block_size !=0 && mt_status.mt_blkno >=0 ) {if (STps->rw ==ST_WRITING ) mt_status.mt_blkno += (STp->buffer)->buffer_bytes / STp->block_size;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 25/33 scsi: st: Add MTIOCGET and MTLOAD to ioctls allowed after device reset
In reply to Sasha LevinFrom: Kai Mäkisara <[email protected]>
[ Upstream commit 0b120edb37dc9dd8ca82893d386922eb6b16f860 ]
Most drives rewind the tape when the device is reset. Reading and writing are not allowed until something is done to make the tape position match the user's expectation (e.g., rewind the tape). Add MTIOCGET and MTLOAD to operations allowed after reset. MTIOCGET is modified to not touch the tape if pos_unknown is non-zero. The tape location is known after MTLOAD.
--- drivers/scsi/st.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-)
drivers/scsi/st.c +21 -8
@@ -3506,6 +3506,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)int i, cmd_nr, cmd_type, bt;int retval =0 ;unsigned int blk; +bool cmd_mtiocget;struct scsi_tape *STp = file->private_data;struct st_modedef *STm;struct st_partstat *STps;
@@ -3619,6 +3620,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)*/ if (mtc.mt_op != MTREW && mtc.mt_op != MTOFFL && + mtc.mt_op != MTLOAD && mtc.mt_op != MTRETEN && mtc.mt_op != MTERASE && mtc.mt_op != MTSEEK &&
@@ -3732,17 +3734,28 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg) goto out; } + cmd_mtiocget = cmd_type ==_IOC_TYPE (MTIOCGET ) && cmd_nr ==_IOC_NR (MTIOCGET ); +if ((i =flush_buffer (STp,0 )) <0 ) { - retval = i; - goto out; - } -if (STp->can_partitions && - (i =switch_partition (STp)) <0 ) { - retval = i; - goto out; +if (cmd_mtiocget && STp->pos_unknown) { +/* flush fails -> modify status accordingly */ +reset_state (STp); + STp->pos_unknown =1 ; + }else {/* return error */ + retval = i; + goto out; + } + }else {/* flush_buffer succeeds */ +if (STp->can_partitions) { + i =switch_partition (STp); +if (i <0 ) { + retval = i; + goto out; + } + } } -if (cmd_type ==_IOC_TYPE (MTIOCGET ) && cmd_nr ==_IOC_NR (MTIOCGET )) { +if (cmd_mtiocget) {struct mtget mt_status;if (_IOC_SIZE (cmd_in) !=sizeof (struct mtget )) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 26/33 pinctrl: qcom-pmic-gpio: add support for PM8937
In reply to Sasha LevinFrom: Barnabás Czémán <[email protected]>
[ Upstream commit 89265a58ff24e3885c2c9ca722bc3aaa47018be9 ]
PM8937 has 8 GPIO-s with holes on GPIO3, GPIO4 and GPIO6.
--- drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +2 -0
@@ -1226,6 +1226,8 @@ static const struct of_device_id pmic_gpio_of_match[] = { { .compatible = "qcom,pm8550ve-gpio", .data = (void *) 8 }, { .compatible = "qcom,pm8550vs-gpio", .data = (void *) 6 }, { .compatible = "qcom,pm8916-gpio", .data = (void *) 4 }, + /* pm8937 has 8 GPIOs with holes on 3, 4 and 6 */ + { .compatible = "qcom,pm8937-gpio", .data = (void *) 8 }, { .compatible = "qcom,pm8941-gpio", .data = (void *) 36 }, /* pm8950 has 8 GPIOs with holes on 3 */ { .compatible = "qcom,pm8950-gpio", .data = (void *) 8 },
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 27/33 pinctrl: qcom: spmi-mpp: Add PM8937 compatible
In reply to Sasha LevinFrom: Barnabás Czémán <[email protected]>
[ Upstream commit f755261190e88f5d19fe0a3b762f0bbaff6bd438 ]
The PM8937 provides 4 MPPs.
Add a compatible to support them.
--- drivers/pinctrl/qcom/pinctrl-spmi-mpp.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/qcom/pinctrl-spmi-mpp.c +1 -0
@@ -983,6 +983,7 @@ static const struct of_device_id pmic_mpp_of_match[] = { { .compatible = "qcom,pm8226-mpp", .data = (void *) 8 }, { .compatible = "qcom,pm8841-mpp", .data = (void *) 4 }, { .compatible = "qcom,pm8916-mpp", .data = (void *) 4 }, + { .compatible = "qcom,pm8937-mpp", .data = (void *) 4 }, { .compatible = "qcom,pm8941-mpp", .data = (void *) 8 }, { .compatible = "qcom,pm8950-mpp", .data = (void *) 4 }, { .compatible = "qcom,pmi8950-mpp", .data = (void *) 4 },
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 28/33 thermal/drivers/qcom/tsens-v1: Add support for MSM8937 tsens
In reply to Sasha LevinFrom: Barnabás Czémán <[email protected]>
[ Upstream commit e2ffb6c3a40ee714160e35e61f0a984028b5d550 ]
Add support for tsens v1.4 block what can be found in MSM8937 and MSM8917.
--- drivers/thermal/qcom/tsens-v1.c | 21 ++++++++++++++------- drivers/thermal/qcom/tsens.c | 3 +++ drivers/thermal/qcom/tsens.h | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-)
drivers/thermal/qcom/tsens-v1.c +14 -7
@@ -162,28 +162,35 @@ struct tsens_plat_data data_tsens_v1 = { .fields = tsens_v1_regfields, }; -static const struct tsens_ops ops_8956 = { - .init = init_8956, +static const struct tsens_ops ops_common = { + .init = init_common, .calibrate = tsens_calibrate_common, .get_temp = get_temp_tsens_valid, }; -struct tsens_plat_data data_8956 = { +struct tsens_plat_data data_8937 = { .num_sensors =11 , - .ops = &ops_8956, + .ops = &ops_common, .feat = &tsens_v1_feat, .fields = tsens_v1_regfields, }; -static const struct tsens_ops ops_8976 = { - .init = init_common, +static const struct tsens_ops ops_8956 = { + .init = init_8956, .calibrate = tsens_calibrate_common, .get_temp = get_temp_tsens_valid, }; +struct tsens_plat_data data_8956 = { + .num_sensors =11 , + .ops = &ops_8956, + .feat = &tsens_v1_feat, + .fields = tsens_v1_regfields, +}; +struct tsens_plat_data data_8976 = { .num_sensors =11 , - .ops = &ops_8976, + .ops = &ops_common, .feat = &tsens_v1_feat, .fields = tsens_v1_regfields, };
drivers/thermal/qcom/tsens.c +3 -0
@@ -1119,6 +1119,9 @@ static const struct of_device_id tsens_table[] = { }, { .compatible = "qcom,msm8916-tsens", .data = &data_8916, + }, { + .compatible = "qcom,msm8937-tsens", + .data = &data_8937, }, { .compatible = "qcom,msm8939-tsens", .data = &data_8939,
drivers/thermal/qcom/tsens.h +1 -1
@@ -647,7 +647,7 @@ extern struct tsens_plat_data data_8960;extern struct tsens_plat_data data_8226, data_8909, data_8916, data_8939, data_8974, data_9607;/* TSENS v1 targets */ -extern struct tsens_plat_data data_tsens_v1, data_8976, data_8956; +extern struct tsens_plat_data data_tsens_v1, data_8937, data_8976, data_8956;/* TSENS v2 targets */ extern struct tsens_plat_data data_8996, data_ipq8074, data_tsens_v2;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 29/33 nvdimm: rectify the illogical code within nd_dax_probe()
In reply to Sasha LevinFrom: Yi Yang <[email protected]>
[ Upstream commit b61352101470f8b68c98af674e187cfaa7c43504 ]
When nd_dax is NULL, nd_pfn is consequently NULL as well. Nevertheless, it is inadvisable to perform pointer arithmetic or address-taking on a NULL pointer.
Introduce the nd_dax_devinit() function to enhance the code's logic and improve its readability.
--- drivers/nvdimm/dax_devs.c | 4 ++-- drivers/nvdimm/nd.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/nvdimm/dax_devs.c +2 -2
@@ -106,12 +106,12 @@ int nd_dax_probe(struct device *dev, struct nd_namespace_common *ndns)nvdimm_bus_lock (&ndns->dev); nd_dax =nd_dax_alloc (nd_region); - nd_pfn = &nd_dax->nd_pfn; - dax_dev =nd_pfn_devinit (nd_pfn, ndns); + dax_dev =nd_dax_devinit (nd_dax, ndns);nvdimm_bus_unlock (&ndns->dev);if (!dax_dev)return -ENOMEM ; pfn_sb =devm_kmalloc (dev,sizeof (*pfn_sb),GFP_KERNEL ); + nd_pfn = &nd_dax->nd_pfn; nd_pfn->pfn_sb = pfn_sb; rc =nd_pfn_validate (nd_pfn,DAX_SIG );dev_dbg (dev,"dax: %s\n" , rc ==0 ?dev_name (dax_dev) :"<none>" );
drivers/nvdimm/nd.h +7 -0
@@ -600,6 +600,13 @@ struct nd_dax *to_nd_dax(struct device *dev);int nd_dax_probe (struct device *dev,struct nd_namespace_common *ndns);bool is_nd_dax (const struct device *dev);struct device *nd_dax_create (struct nd_region *nd_region); +static inline struct device *nd_dax_devinit (struct nd_dax *nd_dax, +struct nd_namespace_common *ndns) +{ +if (!nd_dax) +return NULL ; +return nd_pfn_devinit (&nd_dax->nd_pfn, ndns); +}#else static inline int nd_dax_probe (struct device *dev,struct nd_namespace_common *ndns)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 30/33 smb: client: memcpy() with surrounding object base address
In reply to Sasha LevinFrom: Kees Cook <[email protected]>
[ Upstream commit f69b0187f8745a7a9584f6b13f5e792594b88b2e ]
Like commit f1f047bd7ce0 ("smb: client: Fix -Wstringop-overflow issues"), adjust the memcpy() destination address to be based off the surrounding object rather than based off the 4-byte "Protocol" member. This avoids a build-time warning when compiling under CONFIG_FORTIFY_SOURCE with GCC 15:
In function 'fortify_memcpy_chk',
inlined from 'CIFSSMBSetPathInfo' at ../fs/smb/client/cifssmb.c:5358:2:../include/linux/fortify-string.h:571:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
571 | __write_overflow_field(p_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--- fs/smb/client/cifssmb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/cifssmb.c +1 -1
@@ -5407,7 +5407,7 @@ CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon, param_offset = offsetof(struct smb_com_transaction2_spi_req , InformationLevel) -4 ; offset = param_offset + params; - data_offset = (char *) (&pSMB->hdr.Protocol) + offset; + data_offset = (char *)pSMB + offsetof(typeof(*pSMB), hdr.Protocol) + offset; pSMB->ParameterOffset =cpu_to_le16 (param_offset); pSMB->DataOffset =cpu_to_le16 (offset); pSMB->SetupCount =1 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 31/33 tools/rtla: Enhance argument parsing in timerlat_load.py
In reply to Sasha LevinFrom: furkanonder <[email protected]>
[ Upstream commit bd26818343dc02936a4f2f7b63368d5e1e1773c8 ]
The enhancements made to timerlat_load.py are aimed at improving the clarity of argument parsing.
Summary of Changes:
- The cpu argument is now specified as an integer type in the argument parser to enforce input validation, and the construction of affinity_mask has been simplified to directly use the integer value of args.cpu.
- The prio argument is similarly updated to be of integer type for consistency and validation, eliminating the need for the conversion of args.prio to an integer, as this is now handled by the argument parser.
--- tools/tracing/rtla/sample/timerlat_load.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
tools/tracing/rtla/sample/timerlat_load.py +4 -5
@@ -25,13 +25,12 @@ import sys import os parser = argparse.ArgumentParser(description='user-space timerlat thread in Python') -parser.add_argument("cpu", help='CPU to run timerlat thread') -parser.add_argument("-p", "--prio", help='FIFO priority') - +parser.add_argument("cpu", type=int, help='CPU to run timerlat thread') +parser.add_argument("-p", "--prio", type=int, help='FIFO priority') args = parser.parse_args() try: - affinity_mask = { int(args.cpu) } + affinity_mask = {args.cpu} except: print("Invalid cpu: " + args.cpu) exit(1)
@@ -44,7 +43,7 @@ except: if (args.prio): try: - param = os.sched_param(int(args.prio)) + param = os.sched_param(args.prio) os.sched_setscheduler(0, os.SCHED_FIFO, param) except: print("Error setting priority")
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 32/33 verification/dot2: Improve dot parser robustness
In reply to Sasha LevinFrom: Gabriele Monaco <[email protected]>
[ Upstream commit 571f8b3f866a6d990a50fe5c89fe0ea78784d70b ]
This patch makes the dot parser used by dot2c and dot2k slightly more robust, namely:
* allows parsing files with the gv extension (GraphViz)
* correctly parses edges with any indentation
* used to work only with a single character (e.g. '\t')
Additionally it fixes a couple of warnings reported by pylint such as wrong indentation and comparison to False instead of not ...
--- tools/verification/dot2/automata.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
tools/verification/dot2/automata.py +9 -9
@@ -29,11 +29,11 @@ class Automata: def __get_model_name(self): basename = ntpath.basename(self.__dot_path) - if basename.endswith(".dot") == False: + if not basename.endswith(".dot") and not basename.endswith(".gv"): print("not a dot file") raise Exception("not a dot file: %s" % self.__dot_path) - model_name = basename[0:-4] + model_name = ntpath.splitext(basename)[0] if model_name.__len__() == 0: raise Exception("not a dot file: %s" % self.__dot_path)
@@ -68,9 +68,9 @@ class Automata: def __get_cursor_begin_events(self): cursor = 0 while self.__dot_lines[cursor].split()[0] != "{node": - cursor += 1 + cursor += 1 while self.__dot_lines[cursor].split()[0] == "{node": - cursor += 1 + cursor += 1 # skip initial state transition cursor += 1 return cursor
@@ -94,11 +94,11 @@ class Automata: initial_state = state[7:] else: states.append(state) - if self.__dot_lines[cursor].__contains__("doublecircle") == True: + if "doublecircle" in self.__dot_lines[cursor]: final_states.append(state) has_final_states = True - if self.__dot_lines[cursor].__contains__("ellipse") == True: + if "ellipse" in self.__dot_lines[cursor]: final_states.append(state) has_final_states = True
@@ -110,7 +110,7 @@ class Automata: # Insert the initial state at the bein og the states states.insert(0, initial_state) - if has_final_states == False: + if not has_final_states: final_states.append(initial_state) return states, initial_state, final_states
@@ -120,7 +120,7 @@ class Automata: cursor = self.__get_cursor_begin_events() events = [] - while self.__dot_lines[cursor][1] == '"': + while self.__dot_lines[cursor].lstrip()[0] == '"': # transitions have the format: # "all_fired" -> "both_fired" [ label = "disable_irq" ]; # ------------ event is here ------------^^^^^
@@ -161,7 +161,7 @@ class Automata: # and we are back! Let's fill the matrix cursor = self.__get_cursor_begin_events() - while self.__dot_lines[cursor][1] == '"': + while self.__dot_lines[cursor].lstrip()[0] == '"': if self.__dot_lines[cursor].split()[1] == "->": line = self.__dot_lines[cursor].split() origin_state = line[0].replace('"','').replace(',','_')
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 33/33 mailbox: pcc: Check before sending MCTP PCC response ACK
In reply to Sasha LevinFrom: Adam Young <[email protected]>
[ Upstream commit 7f9e19f207be0c534d517d65e01417ba968cdd34 ]
Type 4 PCC channels have an option to send back a response to the platform when they are done processing the request. The flag to indicate whether or not to respond is inside the message body, and thus is not available to the pcc mailbox.
If the flag is not set, still set command completion bit after processing message.
In order to read the flag, this patch maps the shared buffer to virtual memory. To avoid duplication of mapping the shared buffer is then made available to be used by the driver that uses the mailbox.
--- drivers/mailbox/pcc.c | 61 +++++++++++++++++++++++++++++++++++++------ include/acpi/pcc.h | 7 +++++ 2 files changed, 60 insertions(+), 8 deletions(-)
drivers/mailbox/pcc.c +53 -8
@@ -269,6 +269,35 @@ static bool pcc_mbox_cmd_complete_check(struct pcc_chan_info *pchan)return !!val; } +static void check_and_ack (struct pcc_chan_info *pchan,struct mbox_chan *chan) +{ +struct acpi_pcct_ext_pcc_shared_memory pcc_hdr; + +if (pchan->type !=ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE ) +return ; +/* If the memory region has not been mapped, we cannot +* determine if we need to send the message, but we still +* need to set the cmd_update flag before returning. +*/ +if (pchan->chan.shmem ==NULL ) { +pcc_chan_reg_read_modify_write (&pchan->cmd_update); +return ; + } +memcpy_fromio (&pcc_hdr, pchan->chan.shmem, +sizeof (struct acpi_pcct_ext_pcc_shared_memory )); +/* +* The PCC slave subspace channel needs to set the command complete bit +* after processing message. If the PCC_ACK_FLAG is set, it should also +* ring the doorbell. +* +* The PCC master subspace channel clears chan_in_use to free channel. +*/ +if (le32_to_cpup (&pcc_hdr.flags) &PCC_ACK_FLAG_MASK ) +pcc_send_data (chan,NULL ); +else +pcc_chan_reg_read_modify_write (&pchan->cmd_update); +} +/** * pcc_mbox_irq - PCC mailbox interrupt handler * @irq: interrupt number
@@ -306,14 +335,7 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)mbox_chan_received_data (chan,NULL ); -/* -* The PCC slave subspace channel needs to set the command complete bit -* and ring doorbell after processing message. -* -* The PCC master subspace channel clears chan_in_use to free channel. -*/ -if (pchan->type ==ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE ) -pcc_send_data (chan,NULL ); +check_and_ack (pchan, chan); pchan->chan_in_use = false;return IRQ_HANDLED ;
@@ -365,14 +387,37 @@ EXPORT_SYMBOL_GPL(pcc_mbox_request_channel);void pcc_mbox_free_channel (struct pcc_mbox_chan *pchan) {struct mbox_chan *chan = pchan->mchan; +struct pcc_chan_info *pchan_info; +struct pcc_mbox_chan *pcc_mbox_chan;if (!chan || !chan->cl)return ; + pchan_info = chan->con_priv; + pcc_mbox_chan = &pchan_info->chan; +if (pcc_mbox_chan->shmem) { +iounmap (pcc_mbox_chan->shmem); + pcc_mbox_chan->shmem =NULL ; + }mbox_free_channel (chan); }EXPORT_SYMBOL_GPL (pcc_mbox_free_channel); +int pcc_mbox_ioremap (struct mbox_chan *chan) +{ +struct pcc_chan_info *pchan_info; +struct pcc_mbox_chan *pcc_mbox_chan; + +if (!chan || !chan->cl) +return -1 ; + pchan_info = chan->con_priv; + pcc_mbox_chan = &pchan_info->chan; + pcc_mbox_chan->shmem =ioremap (pcc_mbox_chan->shmem_base_addr, + pcc_mbox_chan->shmem_size); +return 0 ; +} +EXPORT_SYMBOL_GPL (pcc_mbox_ioremap); +/** * pcc_send_data - Called from Mailbox Controller code. Used * here only to ring the channel doorbell. The PCC client
include/acpi/pcc.h +7 -0
@@ -12,6 +12,7 @@struct pcc_mbox_chan {struct mbox_chan *mchan;u64 shmem_base_addr; +void __iomem *shmem;u64 shmem_size;u32 latency;u32 max_access_rate;
@@ -31,11 +32,13 @@ struct pcc_mbox_chan {#define PCC_CMD_COMPLETION_NOTIFY BIT(0)#define MAX_PCC_SUBSPACES 256 +#define PCC_ACK_FLAG_MASK 0x1#ifdef CONFIG_PCC extern struct pcc_mbox_chan *pcc_mbox_request_channel (struct mbox_client *cl,int subspace_id);extern void pcc_mbox_free_channel (struct pcc_mbox_chan *chan); +extern int pcc_mbox_ioremap (struct mbox_chan *chan);#else static inline struct pcc_mbox_chan *pcc_mbox_request_channel (struct mbox_client *cl,int subspace_id)
@@ -43,6 +46,10 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id)return ERR_PTR (-ENODEV ); }static inline void pcc_mbox_free_channel (struct pcc_mbox_chan *chan) { } +static inline int pcc_mbox_ioremap (struct mbox_chan *chan) +{ +return 0 ; +};#endif #endif /* _PCC_H */
Signature · 1 line
2.43.0