From 6d6d832a9134b9ca314df244bde0ba66bf9829e9 Mon Sep 17 00:00:00 2001 From: Wanxiaoqing Date: Tue, 5 Mar 2024 08:26:12 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!1310=20?= =?UTF-8?q?:=20LTS=205.10=20=E8=A1=A5=E4=B8=81=E5=8D=87=E7=BA=A7'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arch/arm/probes/kprobes/checkers-common.c | 2 +- arch/arm/probes/kprobes/core.c | 2 +- arch/arm/probes/kprobes/opt-arm.c | 2 + arch/arm/probes/kprobes/test-core.c | 2 +- arch/arm/probes/kprobes/test-core.h | 4 - arch/x86/events/amd/core.c | 2 +- arch/x86/events/amd/ibs.c | 53 +-- arch/x86/include/asm/perf_event.h | 2 - arch/x86/include/asm/pgtable_64.h | 4 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 +- arch/x86/kernel/smpboot.c | 24 +- block/blk-iocost.c | 7 +- drivers/base/power/domain.c | 6 +- drivers/clocksource/timer-cadence-ttc.c | 19 +- drivers/cpufreq/intel_pstate.c | 2 - drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 - drivers/gpu/drm/amd/display/dc/core/dc.c | 3 + drivers/gpu/drm/bridge/tc358768.c | 93 +---- drivers/gpu/drm/drm_gem_vram_helper.c | 6 +- drivers/gpu/drm/radeon/ci_dpm.c | 28 +- drivers/hid/hid-logitech-hidpp.c | 2 +- drivers/hid/wacom_wac.c | 6 +- drivers/hid/wacom_wac.h | 2 +- drivers/input/misc/drv260x.c | 1 - drivers/irqchip/irq-jcore-aic.c | 11 +- drivers/md/md-bitmap.c | 17 +- drivers/md/md.c | 9 +- drivers/md/raid10.c | 36 +- drivers/memstick/host/r592.c | 4 +- drivers/net/ethernet/intel/igc/igc.h | 33 +- drivers/net/ethernet/intel/igc/igc_main.c | 40 +- drivers/net/ethernet/intel/igc/igc_ptp.c | 57 ++- drivers/net/ethernet/sfc/ef10.c | 13 +- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 6 + .../net/ethernet/xilinx/xilinx_axienet_main.c | 10 +- drivers/net/gtp.c | 2 - drivers/net/ipvlan/ipvlan_core.c | 9 +- drivers/net/wireless/ath/ath9k/ar9003_hw.c | 27 +- drivers/net/wireless/ath/ath9k/htc_hst.c | 8 +- drivers/net/wireless/ath/ath9k/main.c | 11 +- drivers/net/wireless/ath/ath9k/wmi.c | 4 - drivers/net/wireless/atmel/atmel_cs.c | 13 +- drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 5 +- .../wireless/intersil/orinoco/orinoco_cs.c | 13 +- .../wireless/intersil/orinoco/spectrum_cs.c | 13 +- drivers/net/wireless/marvell/mwifiex/scan.c | 6 +- drivers/net/wireless/microchip/wilc1000/hif.c | 8 +- drivers/net/wireless/ray_cs.c | 36 +- drivers/net/wireless/rsi/rsi_91x_sdio.c | 9 +- drivers/net/wireless/wl3501_cs.c | 27 +- drivers/nubus/proc.c | 22 +- drivers/perf/arm-cmn.c | 7 +- drivers/powercap/Kconfig | 4 +- drivers/powercap/intel_rapl_msr.c | 1 + drivers/regulator/core.c | 30 +- drivers/spi/spi-geni-qcom.c | 2 +- .../staging/media/atomisp/pci/atomisp_cmd.c | 3 +- .../staging/media/atomisp/pci/atomisp_ioctl.c | 3 +- drivers/thermal/mtk_thermal.c | 14 +- drivers/thermal/sun8i_thermal.c | 55 ++- drivers/video/fbdev/imsttfb.c | 36 +- fs/pstore/ram_core.c | 2 - include/linux/bpf-cgroup.h | 27 +- include/linux/etherdevice.h | 12 - include/linux/indirect_call_wrapper.h | 6 - include/linux/netdevice.h | 18 - include/linux/nmi.h | 2 +- include/linux/pipe_fs_i.h | 4 + include/net/nfc/nfc.h | 4 +- include/net/sock.h | 3 - include/net/tcp.h | 1 - include/trace/events/timer.h | 6 +- kernel/bpf/cgroup.c | 46 --- kernel/kexec_core.c | 5 +- kernel/rcu/rcuscale.c | 214 ++++++----- kernel/time/posix-timers.c | 43 +-- kernel/watchdog_hld.c | 6 +- lib/ts_bm.c | 4 +- net/can/isotp.c | 5 +- net/core/rtnetlink.c | 104 +++-- net/core/sock.c | 17 +- net/ipv4/tcp.c | 14 - net/ipv4/tcp_ipv4.c | 1 - net/ipv6/tcp_ipv6.c | 1 - net/netfilter/nf_conntrack_sip.c | 2 +- net/netlink/af_netlink.c | 5 +- net/netlink/diag.c | 7 +- net/nfc/core.c | 4 +- net/nfc/hci/llc_shdlc.c | 10 +- net/nfc/llcp.h | 9 +- net/nfc/llcp_commands.c | 59 ++- net/nfc/llcp_core.c | 93 ++--- net/nfc/llcp_sock.c | 21 +- net/nfc/netlink.c | 20 +- net/nfc/nfc.h | 3 +- net/sctp/socket.c | 18 - net/socket.c | 3 - net/wireless/scan.c | 213 +++++------ samples/bpf/tcp_basertt_kern.c | 2 +- scripts/tags.sh | 9 +- security/integrity/evm/evm_main.c | 2 - security/integrity/ima/ima_modsig.c | 3 - security/integrity/ima/ima_policy.c | 3 +- tools/bpf/bpftool/feature.c | 24 +- tools/include/uapi/linux/tcp.h | 357 ------------------ tools/lib/bpf/bpf_helpers.h | 15 +- .../selftests/bpf/prog_tests/bpf_tcp_ca.c | 1 - .../selftests/bpf/prog_tests/cls_redirect.c | 1 - .../selftests/bpf/prog_tests/sockmap_basic.c | 1 - .../selftests/bpf/prog_tests/sockopt_sk.c | 28 -- .../testing/selftests/bpf/progs/sockopt_sk.c | 23 +- tools/testing/selftests/bpf/test_progs.h | 1 + tools/testing/selftests/net/rtnetlink.sh | 1 - 113 files changed, 714 insertions(+), 1657 deletions(-) delete mode 100644 tools/include/uapi/linux/tcp.h diff --git a/arch/arm/probes/kprobes/checkers-common.c b/arch/arm/probes/kprobes/checkers-common.c index eba7ac4725c0..4d720990cf2a 100644 --- a/arch/arm/probes/kprobes/checkers-common.c +++ b/arch/arm/probes/kprobes/checkers-common.c @@ -40,7 +40,7 @@ enum probes_insn checker_stack_use_imm_0xx(probes_opcode_t insn, * Different from other insn uses imm8, the real addressing offset of * STRD in T32 encoding should be imm8 * 4. See ARMARM description. */ -static enum probes_insn checker_stack_use_t32strd(probes_opcode_t insn, +enum probes_insn checker_stack_use_t32strd(probes_opcode_t insn, struct arch_probes_insn *asi, const struct decode_header *h) { diff --git a/arch/arm/probes/kprobes/core.c b/arch/arm/probes/kprobes/core.c index c0ed17289378..e513d8a46776 100644 --- a/arch/arm/probes/kprobes/core.c +++ b/arch/arm/probes/kprobes/core.c @@ -231,7 +231,7 @@ singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb) * kprobe, and that level is reserved for user kprobe handlers, so we can't * risk encountering a new kprobe in an interrupt handler. */ -static void __kprobes kprobe_handler(struct pt_regs *regs) +void __kprobes kprobe_handler(struct pt_regs *regs) { struct kprobe *p, *cur; struct kprobe_ctlblk *kcb; diff --git a/arch/arm/probes/kprobes/opt-arm.c b/arch/arm/probes/kprobes/opt-arm.c index e20304f1d8bc..c78180172120 100644 --- a/arch/arm/probes/kprobes/opt-arm.c +++ b/arch/arm/probes/kprobes/opt-arm.c @@ -145,6 +145,8 @@ __arch_remove_optimized_kprobe(struct optimized_kprobe *op, int dirty) } } +extern void kprobe_handler(struct pt_regs *regs); + static void optimized_callback(struct optimized_kprobe *op, struct pt_regs *regs) { diff --git a/arch/arm/probes/kprobes/test-core.c b/arch/arm/probes/kprobes/test-core.c index 171c7076b89f..c562832b8627 100644 --- a/arch/arm/probes/kprobes/test-core.c +++ b/arch/arm/probes/kprobes/test-core.c @@ -720,7 +720,7 @@ static const char coverage_register_lookup[16] = { [REG_TYPE_NOSPPCX] = COVERAGE_ANY_REG | COVERAGE_SP, }; -static unsigned coverage_start_registers(const struct decode_header *h) +unsigned coverage_start_registers(const struct decode_header *h) { unsigned regs = 0; int i; diff --git a/arch/arm/probes/kprobes/test-core.h b/arch/arm/probes/kprobes/test-core.h index 805116c2ec27..19a5b2add41e 100644 --- a/arch/arm/probes/kprobes/test-core.h +++ b/arch/arm/probes/kprobes/test-core.h @@ -453,7 +453,3 @@ void kprobe_thumb32_test_cases(void); #else void kprobe_arm_test_cases(void); #endif - -void __kprobes_test_case_start(void); -void __kprobes_test_case_end_16(void); -void __kprobes_test_case_end_32(void); diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c index afc955340f81..52eba415928a 100644 --- a/arch/x86/events/amd/core.c +++ b/arch/x86/events/amd/core.c @@ -364,7 +364,7 @@ static int amd_pmu_hw_config(struct perf_event *event) /* pass precise event sampling to ibs: */ if (event->attr.precise_ip && get_ibs_caps()) - return forward_event_to_ibs(event); + return -ENOENT; if (has_branch_stack(event)) return -EOPNOTSUPP; diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c index 354d52e17ef5..8a85658a24cc 100644 --- a/arch/x86/events/amd/ibs.c +++ b/arch/x86/events/amd/ibs.c @@ -202,7 +202,7 @@ static struct perf_ibs *get_ibs_pmu(int type) } /* - * core pmu config -> IBS config + * Use IBS for precise event sampling: * * perf record -a -e cpu-cycles:p ... # use ibs op counting cycle count * perf record -a -e r076:p ... # same as -e cpu-cycles:p @@ -211,9 +211,25 @@ static struct perf_ibs *get_ibs_pmu(int type) * IbsOpCntCtl (bit 19) of IBS Execution Control Register (IbsOpCtl, * MSRC001_1033) is used to select either cycle or micro-ops counting * mode. + * + * The rip of IBS samples has skid 0. Thus, IBS supports precise + * levels 1 and 2 and the PERF_EFLAGS_EXACT is set. In rare cases the + * rip is invalid when IBS was not able to record the rip correctly. + * We clear PERF_EFLAGS_EXACT and take the rip from pt_regs then. + * */ -static int core_pmu_ibs_config(struct perf_event *event, u64 *config) +static int perf_ibs_precise_event(struct perf_event *event, u64 *config) { + switch (event->attr.precise_ip) { + case 0: + return -ENOENT; + case 1: + case 2: + break; + default: + return -EOPNOTSUPP; + } + switch (event->attr.type) { case PERF_TYPE_HARDWARE: switch (event->attr.config) { @@ -239,37 +255,22 @@ static int core_pmu_ibs_config(struct perf_event *event, u64 *config) return -EOPNOTSUPP; } -/* - * The rip of IBS samples has skid 0. Thus, IBS supports precise - * levels 1 and 2 and the PERF_EFLAGS_EXACT is set. In rare cases the - * rip is invalid when IBS was not able to record the rip correctly. - * We clear PERF_EFLAGS_EXACT and take the rip from pt_regs then. - */ -int forward_event_to_ibs(struct perf_event *event) -{ - u64 config = 0; - - if (!event->attr.precise_ip || event->attr.precise_ip > 2) - return -EOPNOTSUPP; - - if (!core_pmu_ibs_config(event, &config)) { - event->attr.type = perf_ibs_op.pmu.type; - event->attr.config = config; - } - return -ENOENT; -} - static int perf_ibs_init(struct perf_event *event) { struct hw_perf_event *hwc = &event->hw; struct perf_ibs *perf_ibs; u64 max_cnt, config; + int ret; perf_ibs = get_ibs_pmu(event->attr.type); - if (!perf_ibs) - return -ENOENT; - - config = event->attr.config; + if (perf_ibs) { + config = event->attr.config; + } else { + perf_ibs = &perf_ibs_op; + ret = perf_ibs_precise_event(event, &config); + if (ret) + return ret; + } if (event->pmu != &perf_ibs->pmu) return -ENOENT; diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h index a4e4bbb7795d..b9a7fd0a27e2 100644 --- a/arch/x86/include/asm/perf_event.h +++ b/arch/x86/include/asm/perf_event.h @@ -412,10 +412,8 @@ struct pebs_xmm { #ifdef CONFIG_X86_LOCAL_APIC extern u32 get_ibs_caps(void); -extern int forward_event_to_ibs(struct perf_event *event); #else static inline u32 get_ibs_caps(void) { return 0; } -static inline int forward_event_to_ibs(struct perf_event *event) { return -ENOENT; } #endif #ifdef CONFIG_PERF_EVENTS diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h index dd520b44e89c..56d0399a0cd1 100644 --- a/arch/x86/include/asm/pgtable_64.h +++ b/arch/x86/include/asm/pgtable_64.h @@ -235,8 +235,8 @@ static inline void native_pgd_clear(pgd_t *pgd) #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val((pte)) }) #define __pmd_to_swp_entry(pmd) ((swp_entry_t) { pmd_val((pmd)) }) -#define __swp_entry_to_pte(x) (__pte((x).val)) -#define __swp_entry_to_pmd(x) (__pmd((x).val)) +#define __swp_entry_to_pte(x) ((pte_t) { .pte = (x).val }) +#define __swp_entry_to_pmd(x) ((pmd_t) { .pmd = (x).val }) extern int kern_addr_valid(unsigned long addr); extern void cleanup_highmap(void); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 1e73b6fae3b4..1a943743cfe4 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -715,15 +715,11 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of, static void show_rdt_tasks(struct rdtgroup *r, struct seq_file *s) { struct task_struct *p, *t; - pid_t pid; rcu_read_lock(); for_each_process_thread(p, t) { - if (is_closid_match(t, r) || is_rmid_match(t, r)) { - pid = task_pid_vnr(t); - if (pid) - seq_printf(s, "%d\n", pid); - } + if (is_closid_match(t, r) || is_rmid_match(t, r)) + seq_printf(s, "%d\n", t->pid); } rcu_read_unlock(); } diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index d2403da17842..bda89ecc7799 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -100,17 +100,6 @@ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map); DEFINE_PER_CPU_READ_MOSTLY(struct cpuinfo_x86, cpu_info); EXPORT_PER_CPU_SYMBOL(cpu_info); -struct mwait_cpu_dead { - unsigned int control; - unsigned int status; -}; - -/* - * Cache line aligned data for mwait_play_dead(). Separate on purpose so - * that it's unlikely to be touched by other CPUs. - */ -static DEFINE_PER_CPU_ALIGNED(struct mwait_cpu_dead, mwait_cpu_dead); - /* Logical package management. We might want to allocate that dynamically */ unsigned int __max_logical_packages __read_mostly; EXPORT_SYMBOL(__max_logical_packages); @@ -1685,10 +1674,10 @@ EXPORT_SYMBOL_GPL(cond_wakeup_cpu0); */ static inline void mwait_play_dead(void) { - struct mwait_cpu_dead *md = this_cpu_ptr(&mwait_cpu_dead); unsigned int eax, ebx, ecx, edx; unsigned int highest_cstate = 0; unsigned int highest_subcstate = 0; + void *mwait_ptr; int i; if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD || @@ -1723,6 +1712,13 @@ static inline void mwait_play_dead(void) (highest_subcstate - 1); } + /* + * This should be a memory location in a cache line which is + * unlikely to be touched by other processors. The actual + * content is immaterial as it is not actually modified in any way. + */ + mwait_ptr = ¤t_thread_info()->flags; + wbinvd(); while (1) { @@ -1734,9 +1730,9 @@ static inline void mwait_play_dead(void) * case where we return around the loop. */ mb(); - clflush(md); + clflush(mwait_ptr); mb(); - __monitor(md, 0, 0); + __monitor(mwait_ptr, 0, 0); mb(); __mwait(eax, 0); diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 7ba7c4e4e4c9..105ad23dff06 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -2426,7 +2426,6 @@ static u64 adjust_inuse_and_calc_cost(struct ioc_gq *iocg, u64 vtime, u32 hwi, adj_step; s64 margin; u64 cost, new_inuse; - unsigned long flags; current_hweight(iocg, NULL, &hwi); old_hwi = hwi; @@ -2445,11 +2444,11 @@ static u64 adjust_inuse_and_calc_cost(struct ioc_gq *iocg, u64 vtime, iocg->inuse == iocg->active) return cost; - spin_lock_irqsave(&ioc->lock, flags); + spin_lock_irq(&ioc->lock); /* we own inuse only when @iocg is in the normal active state */ if (iocg->abs_vdebt || list_empty(&iocg->active_list)) { - spin_unlock_irqrestore(&ioc->lock, flags); + spin_unlock_irq(&ioc->lock); return cost; } @@ -2470,7 +2469,7 @@ static u64 adjust_inuse_and_calc_cost(struct ioc_gq *iocg, u64 vtime, } while (time_after64(vtime + cost, now->vnow) && iocg->inuse != iocg->active); - spin_unlock_irqrestore(&ioc->lock, flags); + spin_unlock_irq(&ioc->lock); TRACE_IOCG_PATH(inuse_adjust, iocg, now, old_inuse, iocg->inuse, old_hwi, hwi); diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 8a90f08c9682..d0ba5459ce0b 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2763,10 +2763,10 @@ static int genpd_parse_state(struct genpd_power_state *genpd_state, err = of_property_read_u32(state_node, "min-residency-us", &residency); if (!err) - genpd_state->residency_ns = 1000LL * residency; + genpd_state->residency_ns = 1000 * residency; - genpd_state->power_on_latency_ns = 1000LL * exit_latency; - genpd_state->power_off_latency_ns = 1000LL * entry_latency; + genpd_state->power_on_latency_ns = 1000 * exit_latency; + genpd_state->power_off_latency_ns = 1000 * entry_latency; genpd_state->fwnode = &state_node->fwnode; return 0; diff --git a/drivers/clocksource/timer-cadence-ttc.c b/drivers/clocksource/timer-cadence-ttc.c index 0d52e28fea4d..4efd0cf3b602 100644 --- a/drivers/clocksource/timer-cadence-ttc.c +++ b/drivers/clocksource/timer-cadence-ttc.c @@ -486,10 +486,10 @@ static int __init ttc_timer_probe(struct platform_device *pdev) * and use it. Note that the event timer uses the interrupt and it's the * 2nd TTC hence the irq_of_parse_and_map(,1) */ - timer_baseaddr = devm_of_iomap(&pdev->dev, timer, 0, NULL); - if (IS_ERR(timer_baseaddr)) { + timer_baseaddr = of_iomap(timer, 0); + if (!timer_baseaddr) { pr_err("ERROR: invalid timer base address\n"); - return PTR_ERR(timer_baseaddr); + return -ENXIO; } irq = irq_of_parse_and_map(timer, 1); @@ -513,27 +513,20 @@ static int __init ttc_timer_probe(struct platform_device *pdev) clk_ce = of_clk_get(timer, clksel); if (IS_ERR(clk_ce)) { pr_err("ERROR: timer input clock not found\n"); - ret = PTR_ERR(clk_ce); - goto put_clk_cs; + return PTR_ERR(clk_ce); } ret = ttc_setup_clocksource(clk_cs, timer_baseaddr, timer_width); if (ret) - goto put_clk_ce; + return ret; ret = ttc_setup_clockevent(clk_ce, timer_baseaddr + 4, irq); if (ret) - goto put_clk_ce; + return ret; pr_info("%pOFn #0 at %p, irq=%d\n", timer, timer_baseaddr, irq); return 0; - -put_clk_ce: - clk_put(clk_ce); -put_clk_cs: - clk_put(clk_cs); - return ret; } static const struct of_device_id ttc_timer_of_match[] = { diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 4b06b81d8bb0..1686705bee7b 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -777,8 +777,6 @@ static ssize_t store_energy_performance_preference( err = cpufreq_start_governor(policy); if (!ret) ret = err; - } else { - ret = 0; } } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index c705ce11c436..45b1f00c5968 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -3252,10 +3252,6 @@ int amdgpu_vm_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) long timeout = msecs_to_jiffies(2000); int r; - /* No valid flags defined yet */ - if (args->in.flags) - return -EINVAL; - switch (args->in.op) { case AMDGPU_VM_OP_RESERVE_VMID: /* We only have requirement to reserve vmid from gfxhub */ diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index 099542dd3154..7e0a55aa2b18 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -1855,6 +1855,9 @@ static enum surface_update_type det_surface_update(const struct dc *dc, enum surface_update_type overall_type = UPDATE_TYPE_FAST; union surface_update_flags *update_flags = &u->surface->update_flags; + if (u->flip_addr) + update_flags->bits.addr_update = 1; + if (!is_surface_in_context(context, u->surface) || u->surface->force_full_update) { update_flags->raw = 0xFFFFFFFF; return UPDATE_TYPE_FULL; diff --git a/drivers/gpu/drm/bridge/tc358768.c b/drivers/gpu/drm/bridge/tc358768.c index b4a69b210451..8ed8302d6bbb 100644 --- a/drivers/gpu/drm/bridge/tc358768.c +++ b/drivers/gpu/drm/bridge/tc358768.c @@ -9,8 +9,6 @@ #include #include #include -#include -#include #include #include #include @@ -149,7 +147,6 @@ struct tc358768_priv { u32 pd_lines; /* number of Parallel Port Input Data Lines */ u32 dsi_lanes; /* number of DSI Lanes */ - u32 dsi_bpp; /* number of Bits Per Pixel over DSI */ /* Parameters for PLL programming */ u32 fbd; /* PLL feedback divider */ @@ -282,12 +279,12 @@ static void tc358768_hw_disable(struct tc358768_priv *priv) static u32 tc358768_pll_to_pclk(struct tc358768_priv *priv, u32 pll_clk) { - return (u32)div_u64((u64)pll_clk * priv->dsi_lanes, priv->dsi_bpp); + return (u32)div_u64((u64)pll_clk * priv->dsi_lanes, priv->pd_lines); } static u32 tc358768_pclk_to_pll(struct tc358768_priv *priv, u32 pclk) { - return (u32)div_u64((u64)pclk * priv->dsi_bpp, priv->dsi_lanes); + return (u32)div_u64((u64)pclk * priv->pd_lines, priv->dsi_lanes); } static int tc358768_calc_pll(struct tc358768_priv *priv, @@ -332,17 +329,13 @@ static int tc358768_calc_pll(struct tc358768_priv *priv, u32 fbd; for (fbd = 0; fbd < 512; ++fbd) { - u32 pll, diff, pll_in; + u32 pll, diff; pll = (u32)div_u64((u64)refclk * (fbd + 1), divisor); if (pll >= max_pll || pll < min_pll) continue; - pll_in = (u32)div_u64((u64)refclk, prd + 1); - if (pll_in < 4000000) - continue; - diff = max(pll, target_pll) - min(pll, target_pll); if (diff < best_diff) { @@ -424,7 +417,6 @@ static int tc358768_dsi_host_attach(struct mipi_dsi_host *host, priv->output.panel = panel; priv->dsi_lanes = dev->lanes; - priv->dsi_bpp = mipi_dsi_pixel_format_to_bpp(dev->format); /* get input ep (port0/endpoint0) */ ret = -EINVAL; @@ -436,7 +428,7 @@ static int tc358768_dsi_host_attach(struct mipi_dsi_host *host, } if (ret) - priv->pd_lines = priv->dsi_bpp; + priv->pd_lines = mipi_dsi_pixel_format_to_bpp(dev->format); drm_bridge_add(&priv->bridge); @@ -634,7 +626,6 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) struct tc358768_priv *priv = bridge_to_tc358768(bridge); struct mipi_dsi_device *dsi_dev = priv->output.dev; u32 val, val2, lptxcnt, hact, data_type; - s32 raw_val; const struct drm_display_mode *mode; u32 dsibclk_nsk, dsiclk_nsk, ui_nsk, phy_delay_nsk; u32 dsiclk, dsibclk; @@ -728,26 +719,25 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) /* 38ns < TCLK_PREPARE < 95ns */ val = tc358768_ns_to_cnt(65, dsibclk_nsk) - 1; - /* TCLK_PREPARE + TCLK_ZERO > 300ns */ - val2 = tc358768_ns_to_cnt(300 - tc358768_to_ns(2 * ui_nsk), - dsibclk_nsk) - 2; - val |= val2 << 8; + /* TCLK_PREPARE > 300ns */ + val2 = tc358768_ns_to_cnt(300 + tc358768_to_ns(3 * ui_nsk), + dsibclk_nsk); + val |= (val2 - tc358768_to_ns(phy_delay_nsk - dsibclk_nsk)) << 8; dev_dbg(priv->dev, "TCLK_HEADERCNT: 0x%x\n", val); tc358768_write(priv, TC358768_TCLK_HEADERCNT, val); - /* TCLK_TRAIL > 60ns AND TEOT <= 105 ns + 12*UI */ - raw_val = tc358768_ns_to_cnt(60 + tc358768_to_ns(2 * ui_nsk), dsibclk_nsk) - 5; - val = clamp(raw_val, 0, 127); + /* TCLK_TRAIL > 60ns + 3*UI */ + val = 60 + tc358768_to_ns(3 * ui_nsk); + val = tc358768_ns_to_cnt(val, dsibclk_nsk) - 5; dev_dbg(priv->dev, "TCLK_TRAILCNT: 0x%x\n", val); tc358768_write(priv, TC358768_TCLK_TRAILCNT, val); /* 40ns + 4*UI < THS_PREPARE < 85ns + 6*UI */ val = 50 + tc358768_to_ns(4 * ui_nsk); val = tc358768_ns_to_cnt(val, dsibclk_nsk) - 1; - /* THS_PREPARE + THS_ZERO > 145ns + 10*UI */ - raw_val = tc358768_ns_to_cnt(145 - tc358768_to_ns(3 * ui_nsk), dsibclk_nsk) - 10; - val2 = clamp(raw_val, 0, 127); - val |= val2 << 8; + /* THS_ZERO > 145ns + 10*UI */ + val2 = tc358768_ns_to_cnt(145 - tc358768_to_ns(ui_nsk), dsibclk_nsk); + val |= (val2 - tc358768_to_ns(phy_delay_nsk)) << 8; dev_dbg(priv->dev, "THS_HEADERCNT: 0x%x\n", val); tc358768_write(priv, TC358768_THS_HEADERCNT, val); @@ -763,10 +753,9 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) dev_dbg(priv->dev, "TCLK_POSTCNT: 0x%x\n", val); tc358768_write(priv, TC358768_TCLK_POSTCNT, val); - /* max(60ns + 4*UI, 8*UI) < THS_TRAILCNT < 105ns + 12*UI */ - raw_val = tc358768_ns_to_cnt(60 + tc358768_to_ns(18 * ui_nsk), - dsibclk_nsk) - 4; - val = clamp(raw_val, 0, 15); + /* 60ns + 4*UI < THS_PREPARE < 105ns + 12*UI */ + val = tc358768_ns_to_cnt(60 + tc358768_to_ns(15 * ui_nsk), + dsibclk_nsk) - 5; dev_dbg(priv->dev, "THS_TRAILCNT: 0x%x\n", val); tc358768_write(priv, TC358768_THS_TRAILCNT, val); @@ -780,7 +769,7 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) /* TXTAGOCNT[26:16] RXTASURECNT[10:0] */ val = tc358768_to_ns((lptxcnt + 1) * dsibclk_nsk * 4); - val = tc358768_ns_to_cnt(val, dsibclk_nsk) / 4 - 1; + val = tc358768_ns_to_cnt(val, dsibclk_nsk) - 1; val2 = tc358768_ns_to_cnt(tc358768_to_ns((lptxcnt + 1) * dsibclk_nsk), dsibclk_nsk) - 2; val |= val2 << 16; @@ -830,7 +819,8 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) val = TC358768_DSI_CONFW_MODE_SET | TC358768_DSI_CONFW_ADDR_DSI_CONTROL; val |= (dsi_dev->lanes - 1) << 1; - val |= TC358768_DSI_CONTROL_TXMD; + if (!(dsi_dev->mode_flags & MIPI_DSI_MODE_LPM)) + val |= TC358768_DSI_CONTROL_TXMD; if (!(dsi_dev->mode_flags & MIPI_DSI_CLOCK_NON_CONTINUOUS)) val |= TC358768_DSI_CONTROL_HSCKMD; @@ -876,44 +866,6 @@ static void tc358768_bridge_enable(struct drm_bridge *bridge) } } -#define MAX_INPUT_SEL_FORMATS 1 - -static u32 * -tc358768_atomic_get_input_bus_fmts(struct drm_bridge *bridge, - struct drm_bridge_state *bridge_state, - struct drm_crtc_state *crtc_state, - struct drm_connector_state *conn_state, - u32 output_fmt, - unsigned int *num_input_fmts) -{ - struct tc358768_priv *priv = bridge_to_tc358768(bridge); - u32 *input_fmts; - - *num_input_fmts = 0; - - input_fmts = kcalloc(MAX_INPUT_SEL_FORMATS, sizeof(*input_fmts), - GFP_KERNEL); - if (!input_fmts) - return NULL; - - switch (priv->pd_lines) { - case 16: - input_fmts[0] = MEDIA_BUS_FMT_RGB565_1X16; - break; - case 18: - input_fmts[0] = MEDIA_BUS_FMT_RGB666_1X18; - break; - default: - case 24: - input_fmts[0] = MEDIA_BUS_FMT_RGB888_1X24; - break; - }; - - *num_input_fmts = MAX_INPUT_SEL_FORMATS; - - return input_fmts; -} - static const struct drm_bridge_funcs tc358768_bridge_funcs = { .attach = tc358768_bridge_attach, .mode_valid = tc358768_bridge_mode_valid, @@ -921,11 +873,6 @@ static const struct drm_bridge_funcs tc358768_bridge_funcs = { .enable = tc358768_bridge_enable, .disable = tc358768_bridge_disable, .post_disable = tc358768_bridge_post_disable, - - .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, - .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, - .atomic_reset = drm_atomic_helper_bridge_reset, - .atomic_get_input_bus_fmts = tc358768_atomic_get_input_bus_fmts, }; static const struct drm_bridge_timings default_tc358768_timings = { diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c index eb104de16fa7..375c79e23ca5 100644 --- a/drivers/gpu/drm/drm_gem_vram_helper.c +++ b/drivers/gpu/drm/drm_gem_vram_helper.c @@ -41,7 +41,7 @@ static const struct drm_gem_object_funcs drm_gem_vram_object_funcs; * the frame's scanout buffer or the cursor image. If there's no more space * left in VRAM, inactive GEM objects can be moved to system memory. * - * To initialize the VRAM helper library call drmm_vram_helper_init(). + * To initialize the VRAM helper library call drmm_vram_helper_alloc_mm(). * The function allocates and initializes an instance of &struct drm_vram_mm * in &struct drm_device.vram_mm . Use &DRM_GEM_VRAM_DRIVER to initialize * &struct drm_driver and &DRM_VRAM_MM_FILE_OPERATIONS to initialize @@ -69,7 +69,7 @@ static const struct drm_gem_object_funcs drm_gem_vram_object_funcs; * // setup device, vram base and size * // ... * - * ret = drmm_vram_helper_init(dev, vram_base, vram_size); + * ret = drmm_vram_helper_alloc_mm(dev, vram_base, vram_size); * if (ret) * return ret; * return 0; @@ -82,7 +82,7 @@ static const struct drm_gem_object_funcs drm_gem_vram_object_funcs; * to userspace. * * You don't have to clean up the instance of VRAM MM. - * drmm_vram_helper_init() is a managed interface that installs a + * drmm_vram_helper_alloc_mm() is a managed interface that installs a * clean-up handler to run during the DRM device's release. * * For drawing or scanout operations, rsp. buffer objects have to be pinned diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c index f98df826972c..886e9959496f 100644 --- a/drivers/gpu/drm/radeon/ci_dpm.c +++ b/drivers/gpu/drm/radeon/ci_dpm.c @@ -5541,7 +5541,6 @@ static int ci_parse_power_table(struct radeon_device *rdev) u8 frev, crev; u8 *power_state_offset; struct ci_ps *ps; - int ret; if (!atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset)) @@ -5571,15 +5570,11 @@ static int ci_parse_power_table(struct radeon_device *rdev) non_clock_array_index = power_state->v2.nonClockInfoIndex; non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *) &non_clock_info_array->nonClockInfo[non_clock_array_index]; - if (!rdev->pm.power_state[i].clock_info) { - ret = -EINVAL; - goto err_free_ps; - } + if (!rdev->pm.power_state[i].clock_info) + return -EINVAL; ps = kzalloc(sizeof(struct ci_ps), GFP_KERNEL); - if (ps == NULL) { - ret = -ENOMEM; - goto err_free_ps; - } + if (ps == NULL) + return -ENOMEM; rdev->pm.dpm.ps[i].ps_priv = ps; ci_parse_pplib_non_clock_info(rdev, &rdev->pm.dpm.ps[i], non_clock_info, @@ -5619,12 +5614,6 @@ static int ci_parse_power_table(struct radeon_device *rdev) } return 0; - -err_free_ps: - for (i = 0; i < rdev->pm.dpm.num_ps; i++) - kfree(rdev->pm.dpm.ps[i].ps_priv); - kfree(rdev->pm.dpm.ps); - return ret; } static int ci_get_vbios_boot_values(struct radeon_device *rdev, @@ -5713,26 +5702,25 @@ int ci_dpm_init(struct radeon_device *rdev) ret = ci_get_vbios_boot_values(rdev, &pi->vbios_boot_state); if (ret) { - kfree(rdev->pm.dpm.priv); + ci_dpm_fini(rdev); return ret; } ret = r600_get_platform_caps(rdev); if (ret) { - kfree(rdev->pm.dpm.priv); + ci_dpm_fini(rdev); return ret; } ret = r600_parse_extended_power_table(rdev); if (ret) { - kfree(rdev->pm.dpm.priv); + ci_dpm_fini(rdev); return ret; } ret = ci_parse_power_table(rdev); if (ret) { - kfree(rdev->pm.dpm.priv); - r600_free_extended_power_table(rdev); + ci_dpm_fini(rdev); return ret; } diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 6ac0c2d9a147..2e32a21bbcbf 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -4009,7 +4009,7 @@ static const struct hid_device_id hidpp_devices[] = { { /* wireless touchpad T651 */ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_T651), - .driver_data = HIDPP_QUIRK_CLASS_WTP | HIDPP_QUIRK_DELAYED_INIT }, + .driver_data = HIDPP_QUIRK_CLASS_WTP }, { /* Mouse Logitech Anywhere MX */ LDJ_DEVICE(0x1017), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_1P0 }, { /* Mouse Logitech Cube */ diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index de6fe9866870..1bfcc94c1d23 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1307,7 +1307,7 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) struct input_dev *pen_input = wacom->pen_input; unsigned char *data = wacom->data; int number_of_valid_frames = 0; - ktime_t time_interval = 15000000; + int time_interval = 15000000; ktime_t time_packet_received = ktime_get(); int i; @@ -1341,7 +1341,7 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) if (number_of_valid_frames) { if (wacom->hid_data.time_delayed) time_interval = ktime_get() - wacom->hid_data.time_delayed; - time_interval = div_u64(time_interval, number_of_valid_frames); + time_interval /= number_of_valid_frames; wacom->hid_data.time_delayed = time_packet_received; } @@ -1352,7 +1352,7 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) bool range = frame[0] & 0x20; bool invert = frame[0] & 0x10; int frames_number_reversed = number_of_valid_frames - i - 1; - ktime_t event_timestamp = time_packet_received - frames_number_reversed * time_interval; + int event_timestamp = time_packet_received - frames_number_reversed * time_interval; if (!valid) continue; diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index 166731292c35..88badfbae999 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h @@ -320,7 +320,7 @@ struct hid_data { int bat_connected; int ps_connected; bool pad_input_event_flag; - ktime_t time_delayed; + int time_delayed; }; struct wacom_remote_data { diff --git a/drivers/input/misc/drv260x.c b/drivers/input/misc/drv260x.c index 54002d1a446b..79d7fa710a71 100644 --- a/drivers/input/misc/drv260x.c +++ b/drivers/input/misc/drv260x.c @@ -435,7 +435,6 @@ static int drv260x_init(struct drv260x_data *haptics) } do { - usleep_range(15000, 15500); error = regmap_read(haptics->regmap, DRV260X_GO, &cal_buf); if (error) { dev_err(&haptics->client->dev, diff --git a/drivers/irqchip/irq-jcore-aic.c b/drivers/irqchip/irq-jcore-aic.c index b9dcc8e78c75..033bccb41455 100644 --- a/drivers/irqchip/irq-jcore-aic.c +++ b/drivers/irqchip/irq-jcore-aic.c @@ -68,7 +68,6 @@ static int __init aic_irq_of_init(struct device_node *node, unsigned min_irq = JCORE_AIC2_MIN_HWIRQ; unsigned dom_sz = JCORE_AIC_MAX_HWIRQ+1; struct irq_domain *domain; - int ret; pr_info("Initializing J-Core AIC\n"); @@ -101,17 +100,11 @@ static int __init aic_irq_of_init(struct device_node *node, jcore_aic.irq_unmask = noop; jcore_aic.name = "AIC"; - ret = irq_alloc_descs(-1, min_irq, dom_sz - min_irq, - of_node_to_nid(node)); - - if (ret < 0) - return ret; - - domain = irq_domain_add_legacy(node, dom_sz - min_irq, min_irq, min_irq, - &jcore_aic_irqdomain_ops, + domain = irq_domain_add_linear(node, dom_sz, &jcore_aic_irqdomain_ops, &jcore_aic); if (!domain) return -ENOMEM; + irq_create_strict_mappings(domain, min_irq, min_irq, dom_sz - min_irq); return 0; } diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index f843ade442de..20afc0aec177 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -54,7 +54,14 @@ __acquires(bitmap->lock) { unsigned char *mappage; - WARN_ON_ONCE(page >= bitmap->pages); + if (page >= bitmap->pages) { + /* This can happen if bitmap_start_sync goes beyond + * End-of-device while looking for a whole page. + * It is harmless. + */ + return -EINVAL; + } + if (bitmap->bp[page].hijacked) /* it's hijacked, don't try to alloc */ return 0; @@ -1358,14 +1365,6 @@ __acquires(bitmap->lock) sector_t csize; int err; - if (page >= bitmap->pages) { - /* - * This can happen if bitmap_start_sync goes beyond - * End-of-device while looking for a whole page or - * user set a huge number to sysfs bitmap_set_bits. - */ - return NULL; - } err = md_bitmap_checkpage(bitmap, page, create, 0); if (bitmap->bp[page].hijacked || diff --git a/drivers/md/md.c b/drivers/md/md.c index ad9b7140b4b0..4596ac653826 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -3878,9 +3878,8 @@ int strict_strtoul_scaled(const char *cp, unsigned long *res, int scale) static ssize_t safe_delay_show(struct mddev *mddev, char *page) { - unsigned int msec = ((unsigned long)mddev->safemode_delay*1000)/HZ; - - return sprintf(page, "%u.%03u\n", msec/1000, msec%1000); + int msec = (mddev->safemode_delay*1000)/HZ; + return sprintf(page, "%d.%03d\n", msec/1000, msec%1000); } static ssize_t safe_delay_store(struct mddev *mddev, const char *cbuf, size_t len) @@ -3892,7 +3891,7 @@ safe_delay_store(struct mddev *mddev, const char *cbuf, size_t len) return -EINVAL; } - if (strict_strtoul_scaled(cbuf, &msec, 3) < 0 || msec > UINT_MAX / HZ) + if (strict_strtoul_scaled(cbuf, &msec, 3) < 0) return -EINVAL; if (msec == 0) mddev->safemode_delay = 0; @@ -4562,8 +4561,6 @@ max_corrected_read_errors_store(struct mddev *mddev, const char *buf, size_t len rv = kstrtouint(buf, 10, &n); if (rv < 0) return rv; - if (n > INT_MAX) - return -EINVAL; atomic_set(&mddev->max_corr_read_errors, n); return len; } diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 32a917e5103a..6a0459f9fafb 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -751,16 +751,8 @@ static struct md_rdev *read_balance(struct r10conf *conf, disk = r10_bio->devs[slot].devnum; rdev = rcu_dereference(conf->mirrors[disk].replacement); if (rdev == NULL || test_bit(Faulty, &rdev->flags) || - r10_bio->devs[slot].addr + sectors > - rdev->recovery_offset) { - /* - * Read replacement first to prevent reading both rdev - * and replacement as NULL during replacement replace - * rdev. - */ - smp_mb(); + r10_bio->devs[slot].addr + sectors > rdev->recovery_offset) rdev = rcu_dereference(conf->mirrors[disk].rdev); - } if (rdev == NULL || test_bit(Faulty, &rdev->flags)) continue; @@ -1354,15 +1346,9 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio, for (i = 0; i < conf->copies; i++) { int d = r10_bio->devs[i].devnum; - struct md_rdev *rdev, *rrdev; - - rrdev = rcu_dereference(conf->mirrors[d].replacement); - /* - * Read replacement first to prevent reading both rdev and - * replacement as NULL during replacement replace rdev. - */ - smp_mb(); - rdev = rcu_dereference(conf->mirrors[d].rdev); + struct md_rdev *rdev = rcu_dereference(conf->mirrors[d].rdev); + struct md_rdev *rrdev = rcu_dereference( + conf->mirrors[d].replacement); if (rdev == rrdev) rrdev = NULL; if (rdev && unlikely(test_bit(Blocked, &rdev->flags))) { @@ -3051,6 +3037,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, int must_sync; int any_working; int need_recover = 0; + int need_replace = 0; struct raid10_info *mirror = &conf->mirrors[i]; struct md_rdev *mrdev, *mreplace; @@ -3062,10 +3049,11 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, !test_bit(Faulty, &mrdev->flags) && !test_bit(In_sync, &mrdev->flags)) need_recover = 1; - if (mreplace && test_bit(Faulty, &mreplace->flags)) - mreplace = NULL; + if (mreplace != NULL && + !test_bit(Faulty, &mreplace->flags)) + need_replace = 1; - if (!need_recover && !mreplace) { + if (!need_recover && !need_replace) { rcu_read_unlock(); continue; } @@ -3081,6 +3069,8 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, rcu_read_unlock(); continue; } + if (mreplace && test_bit(Faulty, &mreplace->flags)) + mreplace = NULL; /* Unless we are doing a full sync, or a replacement * we only need to recover the block if it is set in * the bitmap @@ -3203,11 +3193,11 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, bio = r10_bio->devs[1].repl_bio; if (bio) bio->bi_end_io = NULL; - /* Note: if replace is not NULL, then bio + /* Note: if need_replace, then bio * cannot be NULL as r10buf_pool_alloc will * have allocated it. */ - if (!mreplace) + if (!need_replace) break; bio->bi_next = biolist; biolist = bio; diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c index 0e37c6a5ee36..dd06c18495eb 100644 --- a/drivers/memstick/host/r592.c +++ b/drivers/memstick/host/r592.c @@ -44,10 +44,12 @@ static const char *tpc_names[] = { * memstick_debug_get_tpc_name - debug helper that returns string for * a TPC number */ -static __maybe_unused const char *memstick_debug_get_tpc_name(int tpc) +const char *memstick_debug_get_tpc_name(int tpc) { return tpc_names[tpc-1]; } +EXPORT_SYMBOL(memstick_debug_get_tpc_name); + /* Read a register*/ static inline u32 r592_read_reg(struct r592_device *dev, int address) diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h index 33f64c80335d..970dd878d8a7 100644 --- a/drivers/net/ethernet/intel/igc/igc.h +++ b/drivers/net/ethernet/intel/igc/igc.h @@ -13,7 +13,6 @@ #include #include #include -#include #include "igc_hw.h" @@ -210,10 +209,6 @@ struct igc_adapter { struct ptp_clock *ptp_clock; struct ptp_clock_info ptp_caps; struct work_struct ptp_tx_work; - /* Access to ptp_tx_skb and ptp_tx_start are protected by the - * ptp_tx_lock. - */ - spinlock_t ptp_tx_lock; struct sk_buff *ptp_tx_skb; struct hwtstamp_config tstamp_config; unsigned long ptp_tx_start; @@ -277,33 +272,6 @@ extern char igc_driver_name[]; #define IGC_MRQC_RSS_FIELD_IPV4_UDP 0x00400000 #define IGC_MRQC_RSS_FIELD_IPV6_UDP 0x00800000 -/* RX-desc Write-Back format RSS Type's */ -enum igc_rss_type_num { - IGC_RSS_TYPE_NO_HASH = 0, - IGC_RSS_TYPE_HASH_TCP_IPV4 = 1, - IGC_RSS_TYPE_HASH_IPV4 = 2, - IGC_RSS_TYPE_HASH_TCP_IPV6 = 3, - IGC_RSS_TYPE_HASH_IPV6_EX = 4, - IGC_RSS_TYPE_HASH_IPV6 = 5, - IGC_RSS_TYPE_HASH_TCP_IPV6_EX = 6, - IGC_RSS_TYPE_HASH_UDP_IPV4 = 7, - IGC_RSS_TYPE_HASH_UDP_IPV6 = 8, - IGC_RSS_TYPE_HASH_UDP_IPV6_EX = 9, - IGC_RSS_TYPE_MAX = 10, -}; -#define IGC_RSS_TYPE_MAX_TABLE 16 -#define IGC_RSS_TYPE_MASK GENMASK(3,0) /* 4-bits (3:0) = mask 0x0F */ - -/* igc_rss_type - Rx descriptor RSS type field */ -static inline u32 igc_rss_type(const union igc_adv_rx_desc *rx_desc) -{ - /* RSS Type 4-bits (3:0) number: 0-9 (above 9 is reserved) - * Accessing the same bits via u16 (wb.lower.lo_dword.hs_rss.pkt_info) - * is slightly slower than via u32 (wb.lower.lo_dword.data) - */ - return le32_get_bits(rx_desc->wb.lower.lo_dword.data, IGC_RSS_TYPE_MASK); -} - /* Interrupt defines */ #define IGC_START_ITR 648 /* ~6000 ints/sec */ #define IGC_4K_ITR 980 @@ -393,6 +361,7 @@ enum igc_state_t { __IGC_TESTING, __IGC_RESETTING, __IGC_DOWN, + __IGC_PTP_TX_IN_PROGRESS, }; enum igc_tx_flags { diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index a15e4b6d7fa4..3aa0efb542aa 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -1467,10 +1467,9 @@ static netdev_tx_t igc_xmit_frame_ring(struct sk_buff *skb, * the other timer registers before skipping the * timestamping request. */ - unsigned long flags; - - spin_lock_irqsave(&adapter->ptp_tx_lock, flags); - if (adapter->tstamp_config.tx_type == HWTSTAMP_TX_ON && !adapter->ptp_tx_skb) { + if (adapter->tstamp_config.tx_type == HWTSTAMP_TX_ON && + !test_and_set_bit_lock(__IGC_PTP_TX_IN_PROGRESS, + &adapter->state)) { skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; tx_flags |= IGC_TX_FLAGS_TSTAMP; @@ -1479,8 +1478,6 @@ static netdev_tx_t igc_xmit_frame_ring(struct sk_buff *skb, } else { adapter->tx_hwtstamp_skipped++; } - - spin_unlock_irqrestore(&adapter->ptp_tx_lock, flags); } /* record initial flags and protocol */ @@ -1572,36 +1569,14 @@ static void igc_rx_checksum(struct igc_ring *ring, le32_to_cpu(rx_desc->wb.upper.status_error)); } -/* Mapping HW RSS Type to enum pkt_hash_types */ -static const enum pkt_hash_types igc_rss_type_table[IGC_RSS_TYPE_MAX_TABLE] = { - [IGC_RSS_TYPE_NO_HASH] = PKT_HASH_TYPE_L2, - [IGC_RSS_TYPE_HASH_TCP_IPV4] = PKT_HASH_TYPE_L4, - [IGC_RSS_TYPE_HASH_IPV4] = PKT_HASH_TYPE_L3, - [IGC_RSS_TYPE_HASH_TCP_IPV6] = PKT_HASH_TYPE_L4, - [IGC_RSS_TYPE_HASH_IPV6_EX] = PKT_HASH_TYPE_L3, - [IGC_RSS_TYPE_HASH_IPV6] = PKT_HASH_TYPE_L3, - [IGC_RSS_TYPE_HASH_TCP_IPV6_EX] = PKT_HASH_TYPE_L4, - [IGC_RSS_TYPE_HASH_UDP_IPV4] = PKT_HASH_TYPE_L4, - [IGC_RSS_TYPE_HASH_UDP_IPV6] = PKT_HASH_TYPE_L4, - [IGC_RSS_TYPE_HASH_UDP_IPV6_EX] = PKT_HASH_TYPE_L4, - [10] = PKT_HASH_TYPE_NONE, /* RSS Type above 9 "Reserved" by HW */ - [11] = PKT_HASH_TYPE_NONE, /* keep array sized for SW bit-mask */ - [12] = PKT_HASH_TYPE_NONE, /* to handle future HW revisons */ - [13] = PKT_HASH_TYPE_NONE, - [14] = PKT_HASH_TYPE_NONE, - [15] = PKT_HASH_TYPE_NONE, -}; - static inline void igc_rx_hash(struct igc_ring *ring, union igc_adv_rx_desc *rx_desc, struct sk_buff *skb) { - if (ring->netdev->features & NETIF_F_RXHASH) { - u32 rss_hash = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss); - u32 rss_type = igc_rss_type(rx_desc); - - skb_set_hash(skb, rss_hash, igc_rss_type_table[rss_type]); - } + if (ring->netdev->features & NETIF_F_RXHASH) + skb_set_hash(skb, + le32_to_cpu(rx_desc->wb.lower.hi_dword.rss), + PKT_HASH_TYPE_L3); } /** @@ -5282,7 +5257,6 @@ static int igc_probe(struct pci_dev *pdev, netdev->features |= NETIF_F_TSO; netdev->features |= NETIF_F_TSO6; netdev->features |= NETIF_F_TSO_ECN; - netdev->features |= NETIF_F_RXHASH; netdev->features |= NETIF_F_RXCSUM; netdev->features |= NETIF_F_HW_CSUM; netdev->features |= NETIF_F_SCTP_CRC; diff --git a/drivers/net/ethernet/intel/igc/igc_ptp.c b/drivers/net/ethernet/intel/igc/igc_ptp.c index 25b238c6a675..ef53f7665b58 100644 --- a/drivers/net/ethernet/intel/igc/igc_ptp.c +++ b/drivers/net/ethernet/intel/igc/igc_ptp.c @@ -323,7 +323,6 @@ static int igc_ptp_set_timestamp_mode(struct igc_adapter *adapter, return 0; } -/* Requires adapter->ptp_tx_lock held by caller. */ static void igc_ptp_tx_timeout(struct igc_adapter *adapter) { struct igc_hw *hw = &adapter->hw; @@ -331,6 +330,7 @@ static void igc_ptp_tx_timeout(struct igc_adapter *adapter) dev_kfree_skb_any(adapter->ptp_tx_skb); adapter->ptp_tx_skb = NULL; adapter->tx_hwtstamp_timeouts++; + clear_bit_unlock(__IGC_PTP_TX_IN_PROGRESS, &adapter->state); /* Clear the tx valid bit in TSYNCTXCTL register to enable interrupt. */ rd32(IGC_TXSTMPH); netdev_warn(adapter->netdev, "Tx timestamp timeout\n"); @@ -338,20 +338,20 @@ static void igc_ptp_tx_timeout(struct igc_adapter *adapter) void igc_ptp_tx_hang(struct igc_adapter *adapter) { - unsigned long flags; - - spin_lock_irqsave(&adapter->ptp_tx_lock, flags); - - if (!adapter->ptp_tx_skb) - goto unlock; - - if (time_is_after_jiffies(adapter->ptp_tx_start + IGC_PTP_TX_TIMEOUT)) - goto unlock; + bool timeout = time_is_before_jiffies(adapter->ptp_tx_start + + IGC_PTP_TX_TIMEOUT); - igc_ptp_tx_timeout(adapter); + if (!test_bit(__IGC_PTP_TX_IN_PROGRESS, &adapter->state)) + return; -unlock: - spin_unlock_irqrestore(&adapter->ptp_tx_lock, flags); + /* If we haven't received a timestamp within the timeout, it is + * reasonable to assume that it will never occur, so we can unlock the + * timestamp bit when this occurs. + */ + if (timeout) { + cancel_work_sync(&adapter->ptp_tx_work); + igc_ptp_tx_timeout(adapter); + } } /** @@ -361,8 +361,6 @@ void igc_ptp_tx_hang(struct igc_adapter *adapter) * If we were asked to do hardware stamping and such a time stamp is * available, then it must have been for this skb here because we only * allow only one such packet into the queue. - * - * Context: Expects adapter->ptp_tx_lock to be held by caller. */ static void igc_ptp_tx_hwtstamp(struct igc_adapter *adapter) { @@ -398,7 +396,13 @@ static void igc_ptp_tx_hwtstamp(struct igc_adapter *adapter) shhwtstamps.hwtstamp = ktime_add_ns(shhwtstamps.hwtstamp, adjust); + /* Clear the lock early before calling skb_tstamp_tx so that + * applications are not woken up before the lock bit is clear. We use + * a copy of the skb pointer to ensure other threads can't change it + * while we're notifying the stack. + */ adapter->ptp_tx_skb = NULL; + clear_bit_unlock(__IGC_PTP_TX_IN_PROGRESS, &adapter->state); /* Notify the stack and free the skb after we've unlocked */ skb_tstamp_tx(skb, &shhwtstamps); @@ -409,33 +413,24 @@ static void igc_ptp_tx_hwtstamp(struct igc_adapter *adapter) * igc_ptp_tx_work * @work: pointer to work struct * - * This work function checks the TSYNCTXCTL valid bit to determine when - * a timestamp has been taken for the current stored skb. + * This work function polls the TSYNCTXCTL valid bit to determine when a + * timestamp has been taken for the current stored skb. */ static void igc_ptp_tx_work(struct work_struct *work) { struct igc_adapter *adapter = container_of(work, struct igc_adapter, ptp_tx_work); struct igc_hw *hw = &adapter->hw; - unsigned long flags; u32 tsynctxctl; - spin_lock_irqsave(&adapter->ptp_tx_lock, flags); - - if (!adapter->ptp_tx_skb) - goto unlock; + if (!test_bit(__IGC_PTP_TX_IN_PROGRESS, &adapter->state)) + return; tsynctxctl = rd32(IGC_TSYNCTXCTL); - tsynctxctl &= IGC_TSYNCTXCTL_TXTT_0; - if (!tsynctxctl) { - WARN_ONCE(1, "Received a TSTAMP interrupt but no TSTAMP is ready.\n"); - goto unlock; - } + if (WARN_ON_ONCE(!(tsynctxctl & IGC_TSYNCTXCTL_TXTT_0))) + return; igc_ptp_tx_hwtstamp(adapter); - -unlock: - spin_unlock_irqrestore(&adapter->ptp_tx_lock, flags); } /** @@ -511,7 +506,6 @@ void igc_ptp_init(struct igc_adapter *adapter) return; } - spin_lock_init(&adapter->ptp_tx_lock); spin_lock_init(&adapter->tmreg_lock); INIT_WORK(&adapter->ptp_tx_work, igc_ptp_tx_work); @@ -565,6 +559,7 @@ void igc_ptp_suspend(struct igc_adapter *adapter) cancel_work_sync(&adapter->ptp_tx_work); dev_kfree_skb_any(adapter->ptp_tx_skb); adapter->ptp_tx_skb = NULL; + clear_bit_unlock(__IGC_PTP_TX_IN_PROGRESS, &adapter->state); if (pci_device_is_present(adapter->pdev)) igc_ptp_time_save(adapter); diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c index 3f53b5ea7841..32654fe1f8b5 100644 --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c @@ -1297,10 +1297,8 @@ static void efx_ef10_fini_nic(struct efx_nic *efx) { struct efx_ef10_nic_data *nic_data = efx->nic_data; - spin_lock_bh(&efx->stats_lock); kfree(nic_data->mc_stats); nic_data->mc_stats = NULL; - spin_unlock_bh(&efx->stats_lock); } static int efx_ef10_init_nic(struct efx_nic *efx) @@ -1838,14 +1836,9 @@ static size_t efx_ef10_update_stats_pf(struct efx_nic *efx, u64 *full_stats, efx_ef10_get_stat_mask(efx, mask); - /* If NIC was fini'd (probably resetting), then we can't read - * updated stats right now. - */ - if (nic_data->mc_stats) { - efx_nic_copy_stats(efx, nic_data->mc_stats); - efx_nic_update_stats(efx_ef10_stat_desc, EF10_STAT_COUNT, - mask, stats, nic_data->mc_stats, false); - } + efx_nic_copy_stats(efx, nic_data->mc_stats); + efx_nic_update_stats(efx_ef10_stat_desc, EF10_STAT_COUNT, + mask, stats, nic_data->mc_stats, false); /* Update derived statistics */ efx_nic_fix_nodesc_drop_stat(efx, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 83e9a4d019c1..de66406c5057 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5254,6 +5254,12 @@ int stmmac_dvr_remove(struct device *dev) netif_carrier_off(ndev); unregister_netdev(ndev); + /* Serdes power down needs to happen after VLAN filter + * is deleted that is triggered by unregister_netdev(). + */ + if (priv->plat->serdes_powerdown) + priv->plat->serdes_powerdown(ndev, priv->plat->bsp_priv); + #ifdef CONFIG_DEBUG_FS stmmac_exit_fs(ndev); #endif diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 9d362283196a..3d91baf2e55a 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -2009,11 +2009,6 @@ static int axienet_probe(struct platform_device *pdev) goto cleanup_clk; } - /* Reset core now that clocks are enabled, prior to accessing MDIO */ - ret = __axienet_device_reset(lp); - if (ret) - goto cleanup_clk; - /* Autodetect the need for 64-bit DMA pointers. * When the IP is configured for a bus width bigger than 32 bits, * writing the MSB registers is mandatory, even if they are all 0. @@ -2060,6 +2055,11 @@ static int axienet_probe(struct platform_device *pdev) lp->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD; lp->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD; + /* Reset core now that clocks are enabled, prior to accessing MDIO */ + ret = __axienet_device_reset(lp); + if (ret) + goto cleanup_clk; + ret = axienet_mdio_setup(lp); if (ret) dev_warn(&pdev->dev, diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index 05ea3a18552b..1c46bc4d2705 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -291,9 +291,7 @@ static void __gtp_encap_destroy(struct sock *sk) gtp->sk1u = NULL; udp_sk(sk)->encap_type = 0; rcu_assign_sk_user_data(sk, NULL); - release_sock(sk); sock_put(sk); - return; } release_sock(sk); } diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c index ab09d110760e..0a5b5ff597c6 100644 --- a/drivers/net/ipvlan/ipvlan_core.c +++ b/drivers/net/ipvlan/ipvlan_core.c @@ -586,8 +586,7 @@ static int ipvlan_xmit_mode_l3(struct sk_buff *skb, struct net_device *dev) consume_skb(skb); return NET_XMIT_DROP; } - ipvlan_rcv_frame(addr, &skb, true); - return NET_XMIT_SUCCESS; + return ipvlan_rcv_frame(addr, &skb, true); } } out: @@ -613,8 +612,7 @@ static int ipvlan_xmit_mode_l2(struct sk_buff *skb, struct net_device *dev) consume_skb(skb); return NET_XMIT_DROP; } - ipvlan_rcv_frame(addr, &skb, true); - return NET_XMIT_SUCCESS; + return ipvlan_rcv_frame(addr, &skb, true); } } skb = skb_share_check(skb, GFP_ATOMIC); @@ -626,8 +624,7 @@ static int ipvlan_xmit_mode_l2(struct sk_buff *skb, struct net_device *dev) * the skb for the main-dev. At the RX side we just return * RX_PASS for it to be processed further on the stack. */ - dev_forward_skb(ipvlan->phy_dev, skb); - return NET_XMIT_SUCCESS; + return dev_forward_skb(ipvlan->phy_dev, skb); } else if (is_multicast_ether_addr(eth->h_dest)) { skb_reset_mac_header(skb); diff --git a/drivers/net/wireless/ath/ath9k/ar9003_hw.c b/drivers/net/wireless/ath/ath9k/ar9003_hw.c index cf5648188459..42f00a2a8c80 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c @@ -1099,22 +1099,17 @@ static bool ath9k_hw_verify_hang(struct ath_hw *ah, unsigned int queue) { u32 dma_dbg_chain, dma_dbg_complete; u8 dcu_chain_state, dcu_complete_state; - unsigned int dbg_reg, reg_offset; int i; - if (queue < 6) { - dbg_reg = AR_DMADBG_4; - reg_offset = queue * 5; - } else { - dbg_reg = AR_DMADBG_5; - reg_offset = (queue - 6) * 5; - } - for (i = 0; i < NUM_STATUS_READS; i++) { - dma_dbg_chain = REG_READ(ah, dbg_reg); + if (queue < 6) + dma_dbg_chain = REG_READ(ah, AR_DMADBG_4); + else + dma_dbg_chain = REG_READ(ah, AR_DMADBG_5); + dma_dbg_complete = REG_READ(ah, AR_DMADBG_6); - dcu_chain_state = (dma_dbg_chain >> reg_offset) & 0x1f; + dcu_chain_state = (dma_dbg_chain >> (5 * queue)) & 0x1f; dcu_complete_state = dma_dbg_complete & 0x3; if ((dcu_chain_state != 0x6) || (dcu_complete_state != 0x1)) @@ -1133,7 +1128,6 @@ static bool ar9003_hw_detect_mac_hang(struct ath_hw *ah) u8 dcu_chain_state, dcu_complete_state; bool dcu_wait_frdone = false; unsigned long chk_dcu = 0; - unsigned int reg_offset; unsigned int i = 0; dma_dbg_4 = REG_READ(ah, AR_DMADBG_4); @@ -1145,15 +1139,12 @@ static bool ar9003_hw_detect_mac_hang(struct ath_hw *ah) goto exit; for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) { - if (i < 6) { + if (i < 6) chk_dbg = dma_dbg_4; - reg_offset = i * 5; - } else { + else chk_dbg = dma_dbg_5; - reg_offset = (i - 6) * 5; - } - dcu_chain_state = (chk_dbg >> reg_offset) & 0x1f; + dcu_chain_state = (chk_dbg >> (5 * i)) & 0x1f; if (dcu_chain_state == 0x6) { dcu_wait_frdone = true; chk_dcu |= BIT(i); diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c index 99667aba289d..fe62ff668f75 100644 --- a/drivers/net/wireless/ath/ath9k/htc_hst.c +++ b/drivers/net/wireless/ath/ath9k/htc_hst.c @@ -114,13 +114,7 @@ static void htc_process_conn_rsp(struct htc_target *target, if (svc_rspmsg->status == HTC_SERVICE_SUCCESS) { epid = svc_rspmsg->endpoint_id; - - /* Check that the received epid for the endpoint to attach - * a new service is valid. ENDPOINT0 can't be used here as it - * is already reserved for HTC_CTRL_RSVD_SVC service and thus - * should not be modified. - */ - if (epid <= ENDPOINT0 || epid >= ENDPOINT_MAX) + if (epid < 0 || epid >= ENDPOINT_MAX) return; service_id = be16_to_cpu(svc_rspmsg->service_id); diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index b2cfc483515c..ac354dfc5055 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -203,7 +203,7 @@ void ath_cancel_work(struct ath_softc *sc) void ath_restart_work(struct ath_softc *sc) { ieee80211_queue_delayed_work(sc->hw, &sc->hw_check_work, - msecs_to_jiffies(ATH_HW_CHECK_POLL_INT)); + ATH_HW_CHECK_POLL_INT); if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9330(sc->sc_ah)) ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work, @@ -850,7 +850,7 @@ static bool ath9k_txq_list_has_key(struct list_head *txq_list, u32 keyix) static bool ath9k_txq_has_key(struct ath_softc *sc, u32 keyix) { struct ath_hw *ah = sc->sc_ah; - int i, j; + int i; struct ath_txq *txq; bool key_in_use = false; @@ -868,9 +868,8 @@ static bool ath9k_txq_has_key(struct ath_softc *sc, u32 keyix) if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { int idx = txq->txq_tailidx; - for (j = 0; !key_in_use && - !list_empty(&txq->txq_fifo[idx]) && - j < ATH_TXFIFO_DEPTH; j++) { + while (!key_in_use && + !list_empty(&txq->txq_fifo[idx])) { key_in_use = ath9k_txq_list_has_key( &txq->txq_fifo[idx], keyix); INCR(idx, ATH_TXFIFO_DEPTH); @@ -2244,7 +2243,7 @@ void __ath9k_flush(struct ieee80211_hw *hw, u32 queues, bool drop, } ieee80211_queue_delayed_work(hw, &sc->hw_check_work, - msecs_to_jiffies(ATH_HW_CHECK_POLL_INT)); + ATH_HW_CHECK_POLL_INT); } static bool ath9k_tx_frames_pending(struct ieee80211_hw *hw) diff --git a/drivers/net/wireless/ath/ath9k/wmi.c b/drivers/net/wireless/ath/ath9k/wmi.c index d652c647d56b..19345b8f7bfd 100644 --- a/drivers/net/wireless/ath/ath9k/wmi.c +++ b/drivers/net/wireless/ath/ath9k/wmi.c @@ -221,10 +221,6 @@ static void ath9k_wmi_ctrl_rx(void *priv, struct sk_buff *skb, if (unlikely(wmi->stopped)) goto free_skb; - /* Validate the obtained SKB. */ - if (unlikely(skb->len < sizeof(struct wmi_cmd_hdr))) - goto free_skb; - hdr = (struct wmi_cmd_hdr *) skb->data; cmd_id = be16_to_cpu(hdr->command_id); diff --git a/drivers/net/wireless/atmel/atmel_cs.c b/drivers/net/wireless/atmel/atmel_cs.c index e64f108d288b..368eebefa741 100644 --- a/drivers/net/wireless/atmel/atmel_cs.c +++ b/drivers/net/wireless/atmel/atmel_cs.c @@ -73,7 +73,6 @@ struct local_info { static int atmel_probe(struct pcmcia_device *p_dev) { struct local_info *local; - int ret; dev_dbg(&p_dev->dev, "atmel_attach()\n"); @@ -84,16 +83,8 @@ static int atmel_probe(struct pcmcia_device *p_dev) p_dev->priv = local; - ret = atmel_config(p_dev); - if (ret) - goto err_free_priv; - - return 0; - -err_free_priv: - kfree(p_dev->priv); - return ret; -} + return atmel_config(p_dev); +} /* atmel_attach */ static void atmel_detach(struct pcmcia_device *link) { diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c index 5b173f21e87b..7c61d179895b 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c @@ -1174,11 +1174,8 @@ static void iwl_mvm_queue_state_change(struct iwl_op_mode *op_mode, mvmtxq = iwl_mvm_txq_from_mac80211(txq); mvmtxq->stopped = !start; - if (start && mvmsta->sta_state != IEEE80211_STA_NOTEXIST) { - local_bh_disable(); + if (start && mvmsta->sta_state != IEEE80211_STA_NOTEXIST) iwl_mvm_mac_itxq_xmit(mvm->hw, txq); - local_bh_enable(); - } } out: diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_cs.c b/drivers/net/wireless/intersil/orinoco/orinoco_cs.c index 03bfd2482656..a956f965a1e5 100644 --- a/drivers/net/wireless/intersil/orinoco/orinoco_cs.c +++ b/drivers/net/wireless/intersil/orinoco/orinoco_cs.c @@ -96,7 +96,6 @@ orinoco_cs_probe(struct pcmcia_device *link) { struct orinoco_private *priv; struct orinoco_pccard *card; - int ret; priv = alloc_orinocodev(sizeof(*card), &link->dev, orinoco_cs_hard_reset, NULL); @@ -108,16 +107,8 @@ orinoco_cs_probe(struct pcmcia_device *link) card->p_dev = link; link->priv = priv; - ret = orinoco_cs_config(link); - if (ret) - goto err_free_orinocodev; - - return 0; - -err_free_orinocodev: - free_orinocodev(priv); - return ret; -} + return orinoco_cs_config(link); +} /* orinoco_cs_attach */ static void orinoco_cs_detach(struct pcmcia_device *link) { diff --git a/drivers/net/wireless/intersil/orinoco/spectrum_cs.c b/drivers/net/wireless/intersil/orinoco/spectrum_cs.c index 841d623c621a..291ef97ed45e 100644 --- a/drivers/net/wireless/intersil/orinoco/spectrum_cs.c +++ b/drivers/net/wireless/intersil/orinoco/spectrum_cs.c @@ -157,7 +157,6 @@ spectrum_cs_probe(struct pcmcia_device *link) { struct orinoco_private *priv; struct orinoco_pccard *card; - int ret; priv = alloc_orinocodev(sizeof(*card), &link->dev, spectrum_cs_hard_reset, @@ -170,16 +169,8 @@ spectrum_cs_probe(struct pcmcia_device *link) card->p_dev = link; link->priv = priv; - ret = spectrum_cs_config(link); - if (ret) - goto err_free_orinocodev; - - return 0; - -err_free_orinocodev: - free_orinocodev(priv); - return ret; -} + return spectrum_cs_config(link); +} /* spectrum_cs_attach */ static void spectrum_cs_detach(struct pcmcia_device *link) { diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c index 78ef40e315b5..c2a685f63e95 100644 --- a/drivers/net/wireless/marvell/mwifiex/scan.c +++ b/drivers/net/wireless/marvell/mwifiex/scan.c @@ -2200,9 +2200,9 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, if (nd_config) { adapter->nd_info = - kzalloc(struct_size(adapter->nd_info, matches, - scan_rsp->number_of_sets), - GFP_ATOMIC); + kzalloc(sizeof(struct cfg80211_wowlan_nd_match) + + sizeof(struct cfg80211_wowlan_nd_match *) * + scan_rsp->number_of_sets, GFP_ATOMIC); if (adapter->nd_info) adapter->nd_info->n_matches = scan_rsp->number_of_sets; diff --git a/drivers/net/wireless/microchip/wilc1000/hif.c b/drivers/net/wireless/microchip/wilc1000/hif.c index 884f45e627a7..b25847799138 100644 --- a/drivers/net/wireless/microchip/wilc1000/hif.c +++ b/drivers/net/wireless/microchip/wilc1000/hif.c @@ -470,9 +470,6 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, int rsn_ie_len = sizeof(struct element) + rsn_ie[1]; int offset = 8; - param->mode_802_11i = 2; - param->rsn_found = true; - /* extract RSN capabilities */ if (offset < rsn_ie_len) { /* skip over pairwise suites */ @@ -482,8 +479,11 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, /* skip over authentication suites */ offset += (rsn_ie[offset] * 4) + 2; - if (offset + 1 < rsn_ie_len) + if (offset + 1 < rsn_ie_len) { + param->mode_802_11i = 2; + param->rsn_found = true; memcpy(param->rsn_cap, &rsn_ie[offset], 2); + } } } } diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index bf1282702761..091eea0d958d 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c @@ -270,14 +270,13 @@ static int ray_probe(struct pcmcia_device *p_dev) { ray_dev_t *local; struct net_device *dev; - int ret; dev_dbg(&p_dev->dev, "ray_attach()\n"); /* Allocate space for private device-specific data */ dev = alloc_etherdev(sizeof(ray_dev_t)); if (!dev) - return -ENOMEM; + goto fail_alloc_dev; local = netdev_priv(dev); local->finder = p_dev; @@ -314,16 +313,11 @@ static int ray_probe(struct pcmcia_device *p_dev) timer_setup(&local->timer, NULL, 0); this_device = p_dev; - ret = ray_config(p_dev); - if (ret) - goto err_free_dev; - - return 0; + return ray_config(p_dev); -err_free_dev: - free_netdev(dev); - return ret; -} +fail_alloc_dev: + return -ENOMEM; +} /* ray_attach */ static void ray_detach(struct pcmcia_device *link) { @@ -1647,34 +1641,38 @@ static void authenticate_timeout(struct timer_list *t) /*===========================================================================*/ static int parse_addr(char *in_str, UCHAR *out) { - int i, k; int len; + int i, j, k; + int status; if (in_str == NULL) return 0; - len = strnlen(in_str, ADDRLEN * 2 + 1) - 1; - if (len < 1) + if ((len = strlen(in_str)) < 2) return 0; memset(out, 0, ADDRLEN); + status = 1; + j = len - 1; + if (j > 12) + j = 12; i = 5; - while (len > 0) { - if ((k = hex_to_bin(in_str[len--])) != -1) + while (j > 0) { + if ((k = hex_to_bin(in_str[j--])) != -1) out[i] = k; else return 0; - if (len == 0) + if (j == 0) break; - if ((k = hex_to_bin(in_str[len--])) != -1) + if ((k = hex_to_bin(in_str[j--])) != -1) out[i] += k << 4; else return 0; if (!i--) break; } - return 1; + return status; } /*===========================================================================*/ diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio.c b/drivers/net/wireless/rsi/rsi_91x_sdio.c index b1d3aea10d7d..8108f941ccd3 100644 --- a/drivers/net/wireless/rsi/rsi_91x_sdio.c +++ b/drivers/net/wireless/rsi/rsi_91x_sdio.c @@ -1463,8 +1463,10 @@ static void rsi_shutdown(struct device *dev) rsi_dbg(ERR_ZONE, "SDIO Bus shutdown =====>\n"); - if (hw && hw->wiphy && hw->wiphy->wowlan_config) { - if (rsi_config_wowlan(adapter, hw->wiphy->wowlan_config)) + if (hw) { + struct cfg80211_wowlan *wowlan = hw->wiphy->wowlan_config; + + if (rsi_config_wowlan(adapter, wowlan)) rsi_dbg(ERR_ZONE, "Failed to configure WoWLAN\n"); } @@ -1479,6 +1481,9 @@ static void rsi_shutdown(struct device *dev) if (sdev->write_fail) rsi_dbg(INFO_ZONE, "###### Device is not ready #######\n"); + if (rsi_set_sdio_pm_caps(adapter)) + rsi_dbg(INFO_ZONE, "Setting power management caps failed\n"); + rsi_dbg(INFO_ZONE, "***** RSI module shut down *****\n"); } diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c index 4c408fd7c159..ccf6344ed6fd 100644 --- a/drivers/net/wireless/wl3501_cs.c +++ b/drivers/net/wireless/wl3501_cs.c @@ -134,7 +134,7 @@ static const struct { /** * iw_valid_channel - validate channel in regulatory domain - * @reg_domain: regulatory domain + * @reg_comain: regulatory domain * @channel: channel to validate * * Returns 0 if invalid in the specified regulatory domain, non-zero if valid. @@ -458,9 +458,11 @@ static int wl3501_pwr_mgmt(struct wl3501_card *this, int suspend) /** * wl3501_send_pkt - Send a packet. * @this: Card - * @data: Ethernet raw frame. (e.g. data[0] - data[5] is Dest MAC Addr, + * + * Send a packet. + * + * data = Ethernet raw frame. (e.g. data[0] - data[5] is Dest MAC Addr, * data[6] - data[11] is Src MAC Addr) - * @len: Packet length * Ref: IEEE 802.11 */ static int wl3501_send_pkt(struct wl3501_card *this, u8 *data, u16 len) @@ -1862,7 +1864,6 @@ static int wl3501_probe(struct pcmcia_device *p_dev) { struct net_device *dev; struct wl3501_card *this; - int ret; /* The io structure describes IO port mapping */ p_dev->resource[0]->end = 16; @@ -1874,7 +1875,8 @@ static int wl3501_probe(struct pcmcia_device *p_dev) dev = alloc_etherdev(sizeof(struct wl3501_card)); if (!dev) - return -ENOMEM; + goto out_link; + dev->netdev_ops = &wl3501_netdev_ops; dev->watchdog_timeo = 5 * HZ; @@ -1887,15 +1889,9 @@ static int wl3501_probe(struct pcmcia_device *p_dev) netif_stop_queue(dev); p_dev->priv = dev; - ret = wl3501_config(p_dev); - if (ret) - goto out_free_etherdev; - - return 0; - -out_free_etherdev: - free_netdev(dev); - return ret; + return wl3501_config(p_dev); +out_link: + return -ENOMEM; } static int wl3501_config(struct pcmcia_device *link) @@ -1951,7 +1947,8 @@ static int wl3501_config(struct pcmcia_device *link) goto failed; } - eth_hw_addr_set(dev, this->mac_addr); + for (i = 0; i < 6; i++) + dev->dev_addr[i] = ((char *)&this->mac_addr)[i]; /* print probe information */ printk(KERN_INFO "%s: wl3501 @ 0x%3.3x, IRQ %d, " diff --git a/drivers/nubus/proc.c b/drivers/nubus/proc.c index 78cf0e7b53d5..88e1f9a0faaf 100644 --- a/drivers/nubus/proc.c +++ b/drivers/nubus/proc.c @@ -137,18 +137,6 @@ static int nubus_proc_rsrc_show(struct seq_file *m, void *v) return 0; } -static int nubus_rsrc_proc_open(struct inode *inode, struct file *file) -{ - return single_open(file, nubus_proc_rsrc_show, inode); -} - -static const struct proc_ops nubus_rsrc_proc_ops = { - .proc_open = nubus_rsrc_proc_open, - .proc_read = seq_read, - .proc_lseek = seq_lseek, - .proc_release = single_release, -}; - void nubus_proc_add_rsrc_mem(struct proc_dir_entry *procdir, const struct nubus_dirent *ent, unsigned int size) @@ -164,8 +152,8 @@ void nubus_proc_add_rsrc_mem(struct proc_dir_entry *procdir, pde_data = nubus_proc_alloc_pde_data(nubus_dirptr(ent), size); else pde_data = NULL; - proc_create_data(name, S_IFREG | 0444, procdir, - &nubus_rsrc_proc_ops, pde_data); + proc_create_single_data(name, S_IFREG | 0444, procdir, + nubus_proc_rsrc_show, pde_data); } void nubus_proc_add_rsrc(struct proc_dir_entry *procdir, @@ -178,9 +166,9 @@ void nubus_proc_add_rsrc(struct proc_dir_entry *procdir, return; snprintf(name, sizeof(name), "%x", ent->type); - proc_create_data(name, S_IFREG | 0444, procdir, - &nubus_rsrc_proc_ops, - nubus_proc_alloc_pde_data(data, 0)); + proc_create_single_data(name, S_IFREG | 0444, procdir, + nubus_proc_rsrc_show, + nubus_proc_alloc_pde_data(data, 0)); } /* diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c index 36061aaf026c..bb019e383988 100644 --- a/drivers/perf/arm-cmn.c +++ b/drivers/perf/arm-cmn.c @@ -1254,10 +1254,9 @@ static int arm_cmn_init_dtc(struct arm_cmn *cmn, struct arm_cmn_node *dn, int id if (dtc->irq < 0) return dtc->irq; - writel_relaxed(CMN_DT_DTC_CTL_DT_EN, dtc->base + CMN_DT_DTC_CTL); - writel_relaxed(CMN_DT_PMCR_PMU_EN | CMN_DT_PMCR_OVFL_INTR_EN, dtc->base + CMN_DT_PMCR); - writeq_relaxed(0, dtc->base + CMN_DT_PMCCNTR); + writel_relaxed(0, dtc->base + CMN_DT_PMCR); writel_relaxed(0x1ff, dtc->base + CMN_DT_PMOVSR_CLR); + writel_relaxed(CMN_DT_PMCR_OVFL_INTR_EN, dtc->base + CMN_DT_PMCR); /* We do at least know that a DTC's XP must be in that DTC's domain */ xp = arm_cmn_node_to_xp(dn); @@ -1304,7 +1303,7 @@ static int arm_cmn_init_dtcs(struct arm_cmn *cmn) dn->type = CMN_TYPE_RNI; } - arm_cmn_set_state(cmn, CMN_STATE_DISABLED); + writel_relaxed(CMN_DT_DTC_CTL_DT_EN, cmn->dtc[0].base + CMN_DT_DTC_CTL); return 0; } diff --git a/drivers/powercap/Kconfig b/drivers/powercap/Kconfig index 0e4b2c214a70..bc228725346b 100644 --- a/drivers/powercap/Kconfig +++ b/drivers/powercap/Kconfig @@ -18,12 +18,10 @@ if POWERCAP # Client driver configurations go here. config INTEL_RAPL_CORE tristate - depends on PCI - select IOSF_MBI config INTEL_RAPL tristate "Intel RAPL Support via MSR Interface" - depends on X86 && PCI + depends on X86 && IOSF_MBI select INTEL_RAPL_CORE help This enables support for the Intel Running Average Power Limit (RAPL) diff --git a/drivers/powercap/intel_rapl_msr.c b/drivers/powercap/intel_rapl_msr.c index 6b68e5ed2081..1646808d354c 100644 --- a/drivers/powercap/intel_rapl_msr.c +++ b/drivers/powercap/intel_rapl_msr.c @@ -22,6 +22,7 @@ #include #include +#include #include #include diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index c2b6b1befcf2..40aadf9e60ad 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1753,17 +1753,19 @@ static struct regulator *create_regulator(struct regulator_dev *rdev, if (err != -EEXIST) regulator->debugfs = debugfs_create_dir(supply_name, rdev->debugfs); - if (IS_ERR(regulator->debugfs)) + if (!regulator->debugfs) { rdev_dbg(rdev, "Failed to create debugfs directory\n"); - - debugfs_create_u32("uA_load", 0444, regulator->debugfs, - ®ulator->uA_load); - debugfs_create_u32("min_uV", 0444, regulator->debugfs, - ®ulator->voltage[PM_SUSPEND_ON].min_uV); - debugfs_create_u32("max_uV", 0444, regulator->debugfs, - ®ulator->voltage[PM_SUSPEND_ON].max_uV); - debugfs_create_file("constraint_flags", 0444, regulator->debugfs, - regulator, &constraint_flags_fops); + } else { + debugfs_create_u32("uA_load", 0444, regulator->debugfs, + ®ulator->uA_load); + debugfs_create_u32("min_uV", 0444, regulator->debugfs, + ®ulator->voltage[PM_SUSPEND_ON].min_uV); + debugfs_create_u32("max_uV", 0444, regulator->debugfs, + ®ulator->voltage[PM_SUSPEND_ON].max_uV); + debugfs_create_file("constraint_flags", 0444, + regulator->debugfs, regulator, + &constraint_flags_fops); + } /* * Check now if the regulator is an always on regulator - if @@ -5036,8 +5038,10 @@ static void rdev_init_debugfs(struct regulator_dev *rdev) } rdev->debugfs = debugfs_create_dir(rname, debugfs_root); - if (IS_ERR(rdev->debugfs)) - rdev_dbg(rdev, "Failed to create debugfs directory\n"); + if (IS_ERR(rdev->debugfs)) { + rdev_warn(rdev, "Failed to create debugfs directory\n"); + return; + } debugfs_create_u32("use_count", 0444, rdev->debugfs, &rdev->use_count); @@ -5940,7 +5944,7 @@ static int __init regulator_init(void) debugfs_root = debugfs_create_dir("regulator", NULL); if (IS_ERR(debugfs_root)) - pr_debug("regulator: Failed to create debugfs directory\n"); + pr_warn("regulator: Failed to create debugfs directory\n"); #ifdef CONFIG_DEBUG_FS debugfs_create_file("supply_map", 0444, debugfs_root, NULL, diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c index be259c685cc8..01ef79f15b02 100644 --- a/drivers/spi/spi-geni-qcom.c +++ b/drivers/spi/spi-geni-qcom.c @@ -32,7 +32,7 @@ #define CS_DEMUX_OUTPUT_SEL GENMASK(3, 0) #define SE_SPI_TRANS_CFG 0x25c -#define CS_TOGGLE BIT(1) +#define CS_TOGGLE BIT(0) #define SE_SPI_WORD_LEN 0x268 #define WORD_LEN_MSK GENMASK(9, 0) diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index 613bd9620224..20c19e08968e 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -5243,7 +5243,7 @@ static int atomisp_set_fmt_to_isp(struct video_device *vdev, int (*configure_pp_input)(struct atomisp_sub_device *asd, unsigned int width, unsigned int height) = configure_pp_input_nop; - u16 stream_index; + u16 stream_index = atomisp_source_pad_to_stream_id(asd, source_pad); const struct atomisp_in_fmt_conv *fc; int ret, i; @@ -5252,7 +5252,6 @@ static int atomisp_set_fmt_to_isp(struct video_device *vdev, __func__, vdev->name); return -EINVAL; } - stream_index = atomisp_source_pad_to_stream_id(asd, source_pad); v4l2_fh_init(&fh.vfh, vdev); diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index 4615e4cae718..8a0648fd7c81 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -1123,7 +1123,7 @@ int __atomisp_reqbufs(struct file *file, void *fh, struct ia_css_frame *frame; struct videobuf_vmalloc_memory *vm_mem; u16 source_pad = atomisp_subdev_source_pad(vdev); - u16 stream_id; + u16 stream_id = atomisp_source_pad_to_stream_id(asd, source_pad); int ret = 0, i = 0; if (!asd) { @@ -1131,7 +1131,6 @@ int __atomisp_reqbufs(struct file *file, void *fh, __func__, vdev->name); return -EINVAL; } - stream_id = atomisp_source_pad_to_stream_id(asd, source_pad); if (req->count == 0) { mutex_lock(&pipe->capq.vb_lock); diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c index 0bd7aa564bc2..9fe169dbed88 100644 --- a/drivers/thermal/mtk_thermal.c +++ b/drivers/thermal/mtk_thermal.c @@ -1026,7 +1026,12 @@ static int mtk_thermal_probe(struct platform_device *pdev) return -ENODEV; } - auxadc_base = of_iomap(auxadc, 0); + auxadc_base = devm_of_iomap(&pdev->dev, auxadc, 0, NULL); + if (IS_ERR(auxadc_base)) { + of_node_put(auxadc); + return PTR_ERR(auxadc_base); + } + auxadc_phys_base = of_get_phys_base(auxadc); of_node_put(auxadc); @@ -1042,7 +1047,12 @@ static int mtk_thermal_probe(struct platform_device *pdev) return -ENODEV; } - apmixed_base = of_iomap(apmixedsys, 0); + apmixed_base = devm_of_iomap(&pdev->dev, apmixedsys, 0, NULL); + if (IS_ERR(apmixed_base)) { + of_node_put(apmixedsys); + return PTR_ERR(apmixed_base); + } + apmixed_phys_base = of_get_phys_base(apmixedsys); of_node_put(apmixedsys); diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index e053b0628017..f8b13071a6f4 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -318,11 +318,6 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev) return ret; } -static void sun8i_ths_reset_control_assert(void *data) -{ - reset_control_assert(data); -} - static int sun8i_ths_resource_init(struct ths_device *tmdev) { struct device *dev = tmdev->dev; @@ -343,35 +338,47 @@ static int sun8i_ths_resource_init(struct ths_device *tmdev) if (IS_ERR(tmdev->reset)) return PTR_ERR(tmdev->reset); - ret = reset_control_deassert(tmdev->reset); - if (ret) - return ret; - - ret = devm_add_action_or_reset(dev, sun8i_ths_reset_control_assert, - tmdev->reset); - if (ret) - return ret; - - tmdev->bus_clk = devm_clk_get_enabled(&pdev->dev, "bus"); + tmdev->bus_clk = devm_clk_get(&pdev->dev, "bus"); if (IS_ERR(tmdev->bus_clk)) return PTR_ERR(tmdev->bus_clk); } if (tmdev->chip->has_mod_clk) { - tmdev->mod_clk = devm_clk_get_enabled(&pdev->dev, "mod"); + tmdev->mod_clk = devm_clk_get(&pdev->dev, "mod"); if (IS_ERR(tmdev->mod_clk)) return PTR_ERR(tmdev->mod_clk); } - ret = clk_set_rate(tmdev->mod_clk, 24000000); + ret = reset_control_deassert(tmdev->reset); if (ret) return ret; + ret = clk_prepare_enable(tmdev->bus_clk); + if (ret) + goto assert_reset; + + ret = clk_set_rate(tmdev->mod_clk, 24000000); + if (ret) + goto bus_disable; + + ret = clk_prepare_enable(tmdev->mod_clk); + if (ret) + goto bus_disable; + ret = sun8i_ths_calibrate(tmdev); if (ret) - return ret; + goto mod_disable; return 0; + +mod_disable: + clk_disable_unprepare(tmdev->mod_clk); +bus_disable: + clk_disable_unprepare(tmdev->bus_clk); +assert_reset: + reset_control_assert(tmdev->reset); + + return ret; } static int sun8i_h3_thermal_init(struct ths_device *tmdev) @@ -522,6 +529,17 @@ static int sun8i_ths_probe(struct platform_device *pdev) return 0; } +static int sun8i_ths_remove(struct platform_device *pdev) +{ + struct ths_device *tmdev = platform_get_drvdata(pdev); + + clk_disable_unprepare(tmdev->mod_clk); + clk_disable_unprepare(tmdev->bus_clk); + reset_control_assert(tmdev->reset); + + return 0; +} + static const struct ths_thermal_chip sun8i_a83t_ths = { .sensor_num = 3, .scale = 705, @@ -623,6 +641,7 @@ MODULE_DEVICE_TABLE(of, of_ths_match); static struct platform_driver ths_driver = { .probe = sun8i_ths_probe, + .remove = sun8i_ths_remove, .driver = { .name = "sun8i-thermal", .of_match_table = of_ths_match, diff --git a/drivers/video/fbdev/imsttfb.c b/drivers/video/fbdev/imsttfb.c index 1b2fb8ed7623..e04411701ec8 100644 --- a/drivers/video/fbdev/imsttfb.c +++ b/drivers/video/fbdev/imsttfb.c @@ -1346,7 +1346,7 @@ static const struct fb_ops imsttfb_ops = { .fb_ioctl = imsttfb_ioctl, }; -static int init_imstt(struct fb_info *info) +static void init_imstt(struct fb_info *info) { struct imstt_par *par = info->par; __u32 i, tmp, *ip, *end; @@ -1419,7 +1419,7 @@ static int init_imstt(struct fb_info *info) || !(compute_imstt_regvals(par, info->var.xres, info->var.yres))) { printk("imsttfb: %ux%ux%u not supported\n", info->var.xres, info->var.yres, info->var.bits_per_pixel); framebuffer_release(info); - return -ENODEV; + return; } sprintf(info->fix.id, "IMS TT (%s)", par->ramdac == IBM ? "IBM" : "TVP"); @@ -1455,13 +1455,12 @@ static int init_imstt(struct fb_info *info) if (register_framebuffer(info) < 0) { framebuffer_release(info); - return -ENODEV; + return; } tmp = (read_reg_le32(par->dc_regs, SSTATUS) & 0x0f00) >> 8; fb_info(info, "%s frame buffer; %uMB vram; chip version %u\n", info->fix.id, info->fix.smem_len >> 20, tmp); - return 0; } static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) @@ -1470,7 +1469,6 @@ static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) struct imstt_par *par; struct fb_info *info; struct device_node *dp; - int ret = -ENOMEM; dp = pci_device_to_OF_node(pdev); if(dp) @@ -1506,37 +1504,23 @@ static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) default: printk(KERN_INFO "imsttfb: Device 0x%x unknown, " "contact maintainer.\n", pdev->device); - ret = -ENODEV; - goto error; + release_mem_region(addr, size); + framebuffer_release(info); + return -ENODEV; } info->fix.smem_start = addr; info->screen_base = (__u8 *)ioremap(addr, par->ramdac == IBM ? 0x400000 : 0x800000); - if (!info->screen_base) - goto error; info->fix.mmio_start = addr + 0x800000; par->dc_regs = ioremap(addr + 0x800000, 0x1000); - if (!par->dc_regs) - goto error; par->cmap_regs_phys = addr + 0x840000; par->cmap_regs = (__u8 *)ioremap(addr + 0x840000, 0x1000); - if (!par->cmap_regs) - goto error; info->pseudo_palette = par->palette; - ret = init_imstt(info); - if (!ret) - pci_set_drvdata(pdev, info); - return ret; - -error: - if (par->dc_regs) - iounmap(par->dc_regs); - if (info->screen_base) - iounmap(info->screen_base); - release_mem_region(addr, size); - framebuffer_release(info); - return ret; + init_imstt(info); + + pci_set_drvdata(pdev, info); + return 0; } static void imsttfb_remove(struct pci_dev *pdev) diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c index b6183f1f4ebc..184cb97c83bd 100644 --- a/fs/pstore/ram_core.c +++ b/fs/pstore/ram_core.c @@ -577,8 +577,6 @@ struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size, raw_spin_lock_init(&prz->buffer_lock); prz->flags = flags; prz->label = kstrdup(label, GFP_KERNEL); - if (!prz->label) - goto err; ret = persistent_ram_buffer_map(start, size, prz, memtype); if (ret) diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h index 104a25b2b7b0..5120ca319ff4 100644 --- a/include/linux/bpf-cgroup.h +++ b/include/linux/bpf-cgroup.h @@ -145,10 +145,6 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level, int __user *optlen, int max_optlen, int retval); -int __cgroup_bpf_run_filter_getsockopt_kern(struct sock *sk, int level, - int optname, void *optval, - int *optlen, int retval); - static inline enum bpf_cgroup_storage_type cgroup_storage_type( struct bpf_map *map) { @@ -357,23 +353,10 @@ int bpf_percpu_cgroup_storage_update(struct bpf_map *map, void *key, ({ \ int __ret = retval; \ if (cgroup_bpf_enabled) \ - if (!(sock)->sk_prot->bpf_bypass_getsockopt || \ - !INDIRECT_CALL_INET_1((sock)->sk_prot->bpf_bypass_getsockopt, \ - tcp_bpf_bypass_getsockopt, \ - level, optname)) \ - __ret = __cgroup_bpf_run_filter_getsockopt( \ - sock, level, optname, optval, optlen, \ - max_optlen, retval); \ - __ret; \ -}) - -#define BPF_CGROUP_RUN_PROG_GETSOCKOPT_KERN(sock, level, optname, optval, \ - optlen, retval) \ -({ \ - int __ret = retval; \ - if (cgroup_bpf_enabled) \ - __ret = __cgroup_bpf_run_filter_getsockopt_kern( \ - sock, level, optname, optval, optlen, retval); \ + __ret = __cgroup_bpf_run_filter_getsockopt(sock, level, \ + optname, optval, \ + optlen, max_optlen, \ + retval); \ __ret; \ }) @@ -456,8 +439,6 @@ static inline int bpf_percpu_cgroup_storage_update(struct bpf_map *map, #define BPF_CGROUP_GETSOCKOPT_MAX_OPTLEN(optlen) ({ 0; }) #define BPF_CGROUP_RUN_PROG_GETSOCKOPT(sock, level, optname, optval, \ optlen, max_optlen, retval) ({ retval; }) -#define BPF_CGROUP_RUN_PROG_GETSOCKOPT_KERN(sock, level, optname, optval, \ - optlen, retval) ({ retval; }) #define BPF_CGROUP_RUN_PROG_SETSOCKOPT(sock, level, optname, optval, optlen, \ kernel_optval) ({ 0; }) diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index b060514bf25d..99209f50915f 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h @@ -299,18 +299,6 @@ static inline void ether_addr_copy(u8 *dst, const u8 *src) #endif } -/** - * eth_hw_addr_set - Assign Ethernet address to a net_device - * @dev: pointer to net_device structure - * @addr: address to assign - * - * Assign given address to the net_device, addr_assign_type is not changed. - */ -static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr) -{ - ether_addr_copy(dev->dev_addr, addr); -} - /** * eth_hw_addr_inherit - Copy dev_addr from another net_device * @dst: pointer to net_device to copy dev_addr to diff --git a/include/linux/indirect_call_wrapper.h b/include/linux/indirect_call_wrapper.h index cfcfef37b2f1..54c02c84906a 100644 --- a/include/linux/indirect_call_wrapper.h +++ b/include/linux/indirect_call_wrapper.h @@ -60,10 +60,4 @@ #define INDIRECT_CALL_INET(f, f2, f1, ...) f(__VA_ARGS__) #endif -#if IS_ENABLED(CONFIG_INET) -#define INDIRECT_CALL_INET_1(f, f1, ...) INDIRECT_CALL_1(f, f1, __VA_ARGS__) -#else -#define INDIRECT_CALL_INET_1(f, f1, ...) f(__VA_ARGS__) -#endif - #endif diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 07e7280b5659..1c571475e65e 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -4477,24 +4477,6 @@ void __hw_addr_unsync_dev(struct netdev_hw_addr_list *list, void __hw_addr_init(struct netdev_hw_addr_list *list); /* Functions used for device addresses handling */ -static inline void -__dev_addr_set(struct net_device *dev, const u8 *addr, size_t len) -{ - memcpy(dev->dev_addr, addr, len); -} - -static inline void dev_addr_set(struct net_device *dev, const u8 *addr) -{ - __dev_addr_set(dev, addr, dev->addr_len); -} - -static inline void -dev_addr_mod(struct net_device *dev, unsigned int offset, - const u8 *addr, size_t len) -{ - memcpy(&dev->dev_addr[offset], addr, len); -} - int dev_addr_add(struct net_device *dev, const unsigned char *addr, unsigned char addr_type); int dev_addr_del(struct net_device *dev, const unsigned char *addr, diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 05b9f0b8fca5..2a84e26cf99e 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -218,7 +218,7 @@ u64 hw_nmi_get_sample_period(int watchdog_thresh); #endif #if defined(CONFIG_HARDLOCKUP_CHECK_TIMESTAMP) && \ - defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) + defined(CONFIG_HARDLOCKUP_DETECTOR) void watchdog_update_hrtimer_threshold(u64 period); #else static inline void watchdog_update_hrtimer_threshold(u64 period) { } diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h index ef236dbaa294..c0b6ec6bf65b 100644 --- a/include/linux/pipe_fs_i.h +++ b/include/linux/pipe_fs_i.h @@ -256,14 +256,18 @@ void generic_pipe_buf_release(struct pipe_inode_info *, struct pipe_buffer *); extern const struct pipe_buf_operations nosteal_pipe_buf_ops; +#ifdef CONFIG_WATCH_QUEUE unsigned long account_pipe_buffers(struct user_struct *user, unsigned long old, unsigned long new); bool too_many_pipe_buffers_soft(unsigned long user_bufs); bool too_many_pipe_buffers_hard(unsigned long user_bufs); bool pipe_is_unprivileged_user(void); +#endif /* for F_SETPIPE_SZ and F_GETPIPE_SZ */ +#ifdef CONFIG_WATCH_QUEUE int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots); +#endif long pipe_fcntl(struct file *, unsigned int, unsigned long arg); struct pipe_inode_info *get_pipe_info(struct file *file, bool for_splice); diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h index 32890e43f06c..2cd3a261bcbc 100644 --- a/include/net/nfc/nfc.h +++ b/include/net/nfc/nfc.h @@ -266,7 +266,7 @@ struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk, struct sk_buff *nfc_alloc_recv_skb(unsigned int size, gfp_t gfp); int nfc_set_remote_general_bytes(struct nfc_dev *dev, - const u8 *gt, u8 gt_len); + u8 *gt, u8 gt_len); u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, size_t *gb_len); int nfc_fw_download_done(struct nfc_dev *dev, const char *firmware_name, @@ -280,7 +280,7 @@ int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx, u8 comm_mode, u8 rf_mode); int nfc_tm_activated(struct nfc_dev *dev, u32 protocol, u8 comm_mode, - const u8 *gb, size_t gb_len); + u8 *gb, size_t gb_len); int nfc_tm_deactivated(struct nfc_dev *dev); int nfc_tm_data_received(struct nfc_dev *dev, struct sk_buff *skb); diff --git a/include/net/sock.h b/include/net/sock.h index 50e7e82f2265..db8ddb8f887a 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1215,8 +1215,6 @@ struct proto { int (*backlog_rcv) (struct sock *sk, struct sk_buff *skb); - bool (*bpf_bypass_getsockopt)(int level, - int optname); void (*release_cb)(struct sock *sk); @@ -1942,7 +1940,6 @@ static inline void sock_graft(struct sock *sk, struct socket *parent) } kuid_t sock_i_uid(struct sock *sk); -unsigned long __sock_i_ino(struct sock *sk); unsigned long sock_i_ino(struct sock *sk); static inline kuid_t sock_net_uid(const struct net *net, const struct sock *sk) diff --git a/include/net/tcp.h b/include/net/tcp.h index eadcd746aafd..fe849f814582 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -391,7 +391,6 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, struct poll_table_struct *wait); int tcp_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); -bool tcp_bpf_bypass_getsockopt(int level, int optname); int tcp_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, unsigned int optlen); void tcp_set_keepalive(struct sock *sk, int val); diff --git a/include/trace/events/timer.h b/include/trace/events/timer.h index 5c540ccabcac..40e9b5a12732 100644 --- a/include/trace/events/timer.h +++ b/include/trace/events/timer.h @@ -156,11 +156,7 @@ DEFINE_EVENT(timer_class, timer_cancel, { HRTIMER_MODE_ABS_SOFT, "ABS|SOFT" }, \ { HRTIMER_MODE_REL_SOFT, "REL|SOFT" }, \ { HRTIMER_MODE_ABS_PINNED_SOFT, "ABS|PINNED|SOFT" }, \ - { HRTIMER_MODE_REL_PINNED_SOFT, "REL|PINNED|SOFT" }, \ - { HRTIMER_MODE_ABS_HARD, "ABS|HARD" }, \ - { HRTIMER_MODE_REL_HARD, "REL|HARD" }, \ - { HRTIMER_MODE_ABS_PINNED_HARD, "ABS|PINNED|HARD" }, \ - { HRTIMER_MODE_REL_PINNED_HARD, "REL|PINNED|HARD" }) + { HRTIMER_MODE_REL_PINNED_SOFT, "REL|PINNED|SOFT" }) /** * hrtimer_init - called when the hrtimer is initialized diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c index 54321df6cfac..82f908e2f52f 100644 --- a/kernel/bpf/cgroup.c +++ b/kernel/bpf/cgroup.c @@ -1546,52 +1546,6 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level, sockopt_free_buf(&ctx); return ret; } - -int __cgroup_bpf_run_filter_getsockopt_kern(struct sock *sk, int level, - int optname, void *optval, - int *optlen, int retval) -{ - struct cgroup *cgrp = sock_cgroup_ptr(&sk->sk_cgrp_data); - struct bpf_sockopt_kern ctx = { - .sk = sk, - .level = level, - .optname = optname, - .retval = retval, - .optlen = *optlen, - .optval = optval, - .optval_end = optval + *optlen, - }; - int ret; - - /* Note that __cgroup_bpf_run_filter_getsockopt doesn't copy - * user data back into BPF buffer when reval != 0. This is - * done as an optimization to avoid extra copy, assuming - * kernel won't populate the data in case of an error. - * Here we always pass the data and memset() should - * be called if that data shouldn't be "exported". - */ - - ret = BPF_PROG_RUN_ARRAY(cgrp->bpf.effective[BPF_CGROUP_GETSOCKOPT], - &ctx, BPF_PROG_RUN); - if (!ret) - return -EPERM; - - if (ctx.optlen > *optlen) - return -EFAULT; - - /* BPF programs only allowed to set retval to 0, not some - * arbitrary value. - */ - if (ctx.retval != 0 && ctx.retval != retval) - return -EFAULT; - - /* BPF programs can shrink the buffer, export the modifications. - */ - if (ctx.optlen != 0) - *optlen = ctx.optlen; - - return ctx.retval; -} #endif static ssize_t sysctl_cpy_dir(const struct ctl_dir *dir, char **bufp, diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 3a37fc62dc95..7a8104d48997 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -1029,7 +1029,6 @@ int crash_shrink_memory(unsigned long new_size) start = crashk_res.start; end = crashk_res.end; old_size = (end == 0) ? 0 : end - start + 1; - new_size = roundup(new_size, KEXEC_CRASH_MEM_ALIGN); if (new_size >= old_size) { ret = (new_size == old_size) ? 0 : -EINVAL; goto unlock; @@ -1041,7 +1040,9 @@ int crash_shrink_memory(unsigned long new_size) goto unlock; } - end = start + new_size; + start = roundup(start, KEXEC_CRASH_MEM_ALIGN); + end = roundup(start + new_size, KEXEC_CRASH_MEM_ALIGN); + crash_free_reserved_phys_range(end, crashk_res.end); if ((start == end) && (crashk_res.parent != NULL)) diff --git a/kernel/rcu/rcuscale.c b/kernel/rcu/rcuscale.c index 6c05365ed80f..2819b95479af 100644 --- a/kernel/rcu/rcuscale.c +++ b/kernel/rcu/rcuscale.c @@ -49,8 +49,8 @@ MODULE_AUTHOR("Paul E. McKenney "); pr_alert("%s" SCALE_FLAG " %s\n", scale_type, s) #define VERBOSE_SCALEOUT_STRING(s) \ do { if (verbose) pr_alert("%s" SCALE_FLAG " %s\n", scale_type, s); } while (0) -#define SCALEOUT_ERRSTRING(s) \ - pr_alert("%s" SCALE_FLAG "!!! %s\n", scale_type, s) +#define VERBOSE_SCALEOUT_ERRSTRING(s) \ + do { if (verbose) pr_alert("%s" SCALE_FLAG "!!! %s\n", scale_type, s); } while (0) /* * The intended use cases for the nreaders and nwriters module parameters @@ -457,7 +457,7 @@ rcu_scale_writer(void *arg) if (gp_async) { cur_ops->gp_barrier(); } - writer_n_durations[me] = i_max + 1; + writer_n_durations[me] = i_max; torture_kthread_stopping("rcu_scale_writer"); return 0; } @@ -470,6 +470,89 @@ rcu_scale_print_module_parms(struct rcu_scale_ops *cur_ops, const char *tag) scale_type, tag, nrealreaders, nrealwriters, verbose, shutdown); } +static void +rcu_scale_cleanup(void) +{ + int i; + int j; + int ngps = 0; + u64 *wdp; + u64 *wdpp; + + /* + * Would like warning at start, but everything is expedited + * during the mid-boot phase, so have to wait till the end. + */ + if (rcu_gp_is_expedited() && !rcu_gp_is_normal() && !gp_exp) + VERBOSE_SCALEOUT_ERRSTRING("All grace periods expedited, no normal ones to measure!"); + if (rcu_gp_is_normal() && gp_exp) + VERBOSE_SCALEOUT_ERRSTRING("All grace periods normal, no expedited ones to measure!"); + if (gp_exp && gp_async) + VERBOSE_SCALEOUT_ERRSTRING("No expedited async GPs, so went with async!"); + + if (torture_cleanup_begin()) + return; + if (!cur_ops) { + torture_cleanup_end(); + return; + } + + if (reader_tasks) { + for (i = 0; i < nrealreaders; i++) + torture_stop_kthread(rcu_scale_reader, + reader_tasks[i]); + kfree(reader_tasks); + } + + if (writer_tasks) { + for (i = 0; i < nrealwriters; i++) { + torture_stop_kthread(rcu_scale_writer, + writer_tasks[i]); + if (!writer_n_durations) + continue; + j = writer_n_durations[i]; + pr_alert("%s%s writer %d gps: %d\n", + scale_type, SCALE_FLAG, i, j); + ngps += j; + } + pr_alert("%s%s start: %llu end: %llu duration: %llu gps: %d batches: %ld\n", + scale_type, SCALE_FLAG, + t_rcu_scale_writer_started, t_rcu_scale_writer_finished, + t_rcu_scale_writer_finished - + t_rcu_scale_writer_started, + ngps, + rcuscale_seq_diff(b_rcu_gp_test_finished, + b_rcu_gp_test_started)); + for (i = 0; i < nrealwriters; i++) { + if (!writer_durations) + break; + if (!writer_n_durations) + continue; + wdpp = writer_durations[i]; + if (!wdpp) + continue; + for (j = 0; j <= writer_n_durations[i]; j++) { + wdp = &wdpp[j]; + pr_alert("%s%s %4d writer-duration: %5d %llu\n", + scale_type, SCALE_FLAG, + i, j, *wdp); + if (j % 100 == 0) + schedule_timeout_uninterruptible(1); + } + kfree(writer_durations[i]); + } + kfree(writer_tasks); + kfree(writer_durations); + kfree(writer_n_durations); + } + + /* Do torture-type-specific cleanup operations. */ + if (cur_ops->cleanup != NULL) + cur_ops->cleanup(); + + torture_cleanup_end(); +} + /* * Return the number if non-negative. If -1, the number of CPUs. * If less than -1, that much less than the number of CPUs, but @@ -489,6 +572,21 @@ static int compute_real(int n) return nr; } +/* + * RCU scalability shutdown kthread. Just waits to be awakened, then shuts + * down system. + */ +static int +rcu_scale_shutdown(void *arg) +{ + wait_event(shutdown_wq, + atomic_read(&n_rcu_scale_writer_finished) >= nrealwriters); + smp_mb(); /* Wake before output. */ + rcu_scale_cleanup(); + kernel_power_off(); + return -EINVAL; +} + /* * kfree_rcu() scalability tests: Start a kfree_rcu() loop on all CPUs for number * of iterations and measure total time and number of GP for all iterations to complete. @@ -595,8 +693,8 @@ kfree_scale_cleanup(void) static int kfree_scale_shutdown(void *arg) { - wait_event_idle(shutdown_wq, - atomic_read(&n_kfree_scale_thread_ended) >= kfree_nrealthreads); + wait_event(shutdown_wq, + atomic_read(&n_kfree_scale_thread_ended) >= kfree_nrealthreads); smp_mb(); /* Wake before output. */ @@ -650,108 +748,6 @@ kfree_scale_init(void) return firsterr; } -static void -rcu_scale_cleanup(void) -{ - int i; - int j; - int ngps = 0; - u64 *wdp; - u64 *wdpp; - - /* - * Would like warning at start, but everything is expedited - * during the mid-boot phase, so have to wait till the end. - */ - if (rcu_gp_is_expedited() && !rcu_gp_is_normal() && !gp_exp) - SCALEOUT_ERRSTRING("All grace periods expedited, no normal ones to measure!"); - if (rcu_gp_is_normal() && gp_exp) - SCALEOUT_ERRSTRING("All grace periods normal, no expedited ones to measure!"); - if (gp_exp && gp_async) - SCALEOUT_ERRSTRING("No expedited async GPs, so went with async!"); - - if (kfree_rcu_test) { - kfree_scale_cleanup(); - return; - } - - if (torture_cleanup_begin()) - return; - if (!cur_ops) { - torture_cleanup_end(); - return; - } - - if (reader_tasks) { - for (i = 0; i < nrealreaders; i++) - torture_stop_kthread(rcu_scale_reader, - reader_tasks[i]); - kfree(reader_tasks); - } - - if (writer_tasks) { - for (i = 0; i < nrealwriters; i++) { - torture_stop_kthread(rcu_scale_writer, - writer_tasks[i]); - if (!writer_n_durations) - continue; - j = writer_n_durations[i]; - pr_alert("%s%s writer %d gps: %d\n", - scale_type, SCALE_FLAG, i, j); - ngps += j; - } - pr_alert("%s%s start: %llu end: %llu duration: %llu gps: %d batches: %ld\n", - scale_type, SCALE_FLAG, - t_rcu_scale_writer_started, t_rcu_scale_writer_finished, - t_rcu_scale_writer_finished - - t_rcu_scale_writer_started, - ngps, - rcuscale_seq_diff(b_rcu_gp_test_finished, - b_rcu_gp_test_started)); - for (i = 0; i < nrealwriters; i++) { - if (!writer_durations) - break; - if (!writer_n_durations) - continue; - wdpp = writer_durations[i]; - if (!wdpp) - continue; - for (j = 0; j < writer_n_durations[i]; j++) { - wdp = &wdpp[j]; - pr_alert("%s%s %4d writer-duration: %5d %llu\n", - scale_type, SCALE_FLAG, - i, j, *wdp); - if (j % 100 == 0) - schedule_timeout_uninterruptible(1); - } - kfree(writer_durations[i]); - } - kfree(writer_tasks); - kfree(writer_durations); - kfree(writer_n_durations); - } - - /* Do torture-type-specific cleanup operations. */ - if (cur_ops->cleanup != NULL) - cur_ops->cleanup(); - - torture_cleanup_end(); -} - -/* - * RCU scalability shutdown kthread. Just waits to be awakened, then shuts - * down system. - */ -static int -rcu_scale_shutdown(void *arg) -{ - wait_event_idle(shutdown_wq, atomic_read(&n_rcu_scale_writer_finished) >= nrealwriters); - smp_mb(); /* Wake before output. */ - rcu_scale_cleanup(); - kernel_power_off(); - return -EINVAL; -} - static int __init rcu_scale_init(void) { @@ -807,7 +803,7 @@ rcu_scale_init(void) reader_tasks = kcalloc(nrealreaders, sizeof(reader_tasks[0]), GFP_KERNEL); if (reader_tasks == NULL) { - SCALEOUT_ERRSTRING("out of memory"); + VERBOSE_SCALEOUT_ERRSTRING("out of memory"); firsterr = -ENOMEM; goto unwind; } @@ -827,7 +823,7 @@ rcu_scale_init(void) kcalloc(nrealwriters, sizeof(*writer_n_durations), GFP_KERNEL); if (!writer_tasks || !writer_durations || !writer_n_durations) { - SCALEOUT_ERRSTRING("out of memory"); + VERBOSE_SCALEOUT_ERRSTRING("out of memory"); firsterr = -ENOMEM; goto unwind; } diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 86fa87482f3d..7a18690e5110 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -1037,52 +1037,27 @@ SYSCALL_DEFINE1(timer_delete, timer_t, timer_id) } /* - * Delete a timer if it is armed, remove it from the hash and schedule it - * for RCU freeing. + * return timer owned by the process, used by exit_itimers */ static void itimer_delete(struct k_itimer *timer) { - unsigned long flags; - - /* - * irqsave is required to make timer_wait_running() work. - */ - spin_lock_irqsave(&timer->it_lock, flags); - retry_delete: - /* - * Even if the timer is not longer accessible from other tasks - * it still might be armed and queued in the underlying timer - * mechanism. Worse, that timer mechanism might run the expiry - * function concurrently. - */ - if (timer_delete_hook(timer) == TIMER_RETRY) { - /* - * Timer is expired concurrently, prevent livelocks - * and pointless spinning on RT. - * - * timer_wait_running() drops timer::it_lock, which opens - * the possibility for another task to delete the timer. - * - * That's not possible here because this is invoked from - * do_exit() only for the last thread of the thread group. - * So no other task can access and delete that timer. - */ - if (WARN_ON_ONCE(timer_wait_running(timer, &flags) != timer)) - return; + spin_lock_irq(&timer->it_lock); + if (timer_delete_hook(timer) == TIMER_RETRY) { + spin_unlock_irq(&timer->it_lock); goto retry_delete; } list_del(&timer->list); - spin_unlock_irqrestore(&timer->it_lock, flags); + spin_unlock_irq(&timer->it_lock); release_posix_timer(timer, IT_ID_SET); } /* - * Invoked from do_exit() when the last thread of a thread group exits. - * At that point no other task can access the timers of the dying - * task anymore. + * This is called by do_exit or de_thread, only when nobody else can + * modify the signal->posix_timers list. Yet we need sighand->siglock + * to prevent the race with /proc/pid/timers. */ void exit_itimers(struct task_struct *tsk) { @@ -1092,12 +1067,10 @@ void exit_itimers(struct task_struct *tsk) if (list_empty(&tsk->signal->posix_timers)) return; - /* Protect against concurrent read via /proc/$PID/timers */ spin_lock_irq(&tsk->sighand->siglock); list_replace_init(&tsk->signal->posix_timers, &timers); spin_unlock_irq(&tsk->sighand->siglock); - /* The timers are not longer accessible via tsk::signal */ while (!list_empty(&timers)) { tmr = list_first_entry(&timers, struct k_itimer, list); itimer_delete(tmr); diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c index 1e8a49dc956e..247bf0b1582c 100644 --- a/kernel/watchdog_hld.c +++ b/kernel/watchdog_hld.c @@ -114,14 +114,14 @@ static void watchdog_overflow_callback(struct perf_event *event, /* Ensure the watchdog never gets throttled */ event->hw.interrupts = 0; - if (!watchdog_check_timestamp()) - return; - if (__this_cpu_read(watchdog_nmi_touch) == true) { __this_cpu_write(watchdog_nmi_touch, false); return; } + if (!watchdog_check_timestamp()) + return; + /* check for a hardlockup * This is done by making sure our timer interrupt * is incrementing. The timer interrupt should have diff --git a/lib/ts_bm.c b/lib/ts_bm.c index 352ae837e031..4cf250031f0f 100644 --- a/lib/ts_bm.c +++ b/lib/ts_bm.c @@ -60,12 +60,10 @@ static unsigned int bm_find(struct ts_config *conf, struct ts_state *state) struct ts_bm *bm = ts_config_priv(conf); unsigned int i, text_len, consumed = state->offset; const u8 *text; - int bs; + int shift = bm->patlen - 1, bs; const u8 icase = conf->flags & TS_IGNORECASE; for (;;) { - int shift = bm->patlen - 1; - text_len = conf->get_next_block(consumed, &text, conf, state); if (unlikely(text_len == 0)) diff --git a/net/can/isotp.c b/net/can/isotp.c index 16ebc187af1c..4fcd8162fad4 100644 --- a/net/can/isotp.c +++ b/net/can/isotp.c @@ -990,9 +990,8 @@ static int isotp_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) /* wait for complete transmission of current pdu */ wait_event_interruptible(so->wait, so->tx.state == ISOTP_IDLE); - err = sock_error(sk); - if (err) - return err; + if (sk->sk_err) + return -sk->sk_err; } return size; diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index d3c03ebf06a5..3c9c2d6e3b92 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -929,27 +929,24 @@ static inline int rtnl_vfinfo_size(const struct net_device *dev, nla_total_size(sizeof(struct ifla_vf_rate)) + nla_total_size(sizeof(struct ifla_vf_link_state)) + nla_total_size(sizeof(struct ifla_vf_rss_query_en)) + + nla_total_size(0) + /* nest IFLA_VF_STATS */ + /* IFLA_VF_STATS_RX_PACKETS */ + nla_total_size_64bit(sizeof(__u64)) + + /* IFLA_VF_STATS_TX_PACKETS */ + nla_total_size_64bit(sizeof(__u64)) + + /* IFLA_VF_STATS_RX_BYTES */ + nla_total_size_64bit(sizeof(__u64)) + + /* IFLA_VF_STATS_TX_BYTES */ + nla_total_size_64bit(sizeof(__u64)) + + /* IFLA_VF_STATS_BROADCAST */ + nla_total_size_64bit(sizeof(__u64)) + + /* IFLA_VF_STATS_MULTICAST */ + nla_total_size_64bit(sizeof(__u64)) + + /* IFLA_VF_STATS_RX_DROPPED */ + nla_total_size_64bit(sizeof(__u64)) + + /* IFLA_VF_STATS_TX_DROPPED */ + nla_total_size_64bit(sizeof(__u64)) + nla_total_size(sizeof(struct ifla_vf_trust))); - if (~ext_filter_mask & RTEXT_FILTER_SKIP_STATS) { - size += num_vfs * - (nla_total_size(0) + /* nest IFLA_VF_STATS */ - /* IFLA_VF_STATS_RX_PACKETS */ - nla_total_size_64bit(sizeof(__u64)) + - /* IFLA_VF_STATS_TX_PACKETS */ - nla_total_size_64bit(sizeof(__u64)) + - /* IFLA_VF_STATS_RX_BYTES */ - nla_total_size_64bit(sizeof(__u64)) + - /* IFLA_VF_STATS_TX_BYTES */ - nla_total_size_64bit(sizeof(__u64)) + - /* IFLA_VF_STATS_BROADCAST */ - nla_total_size_64bit(sizeof(__u64)) + - /* IFLA_VF_STATS_MULTICAST */ - nla_total_size_64bit(sizeof(__u64)) + - /* IFLA_VF_STATS_RX_DROPPED */ - nla_total_size_64bit(sizeof(__u64)) + - /* IFLA_VF_STATS_TX_DROPPED */ - nla_total_size_64bit(sizeof(__u64))); - } return size; } else return 0; @@ -1224,8 +1221,7 @@ static noinline_for_stack int rtnl_fill_stats(struct sk_buff *skb, static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb, struct net_device *dev, int vfs_num, - struct nlattr *vfinfo, - u32 ext_filter_mask) + struct nlattr *vfinfo) { struct ifla_vf_rss_query_en vf_rss_query_en; struct nlattr *vf, *vfstats, *vfvlanlist; @@ -1331,35 +1327,33 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb, goto nla_put_vf_failure; } nla_nest_end(skb, vfvlanlist); - if (~ext_filter_mask & RTEXT_FILTER_SKIP_STATS) { - memset(&vf_stats, 0, sizeof(vf_stats)); - if (dev->netdev_ops->ndo_get_vf_stats) - dev->netdev_ops->ndo_get_vf_stats(dev, vfs_num, - &vf_stats); - vfstats = nla_nest_start_noflag(skb, IFLA_VF_STATS); - if (!vfstats) - goto nla_put_vf_failure; - if (nla_put_u64_64bit(skb, IFLA_VF_STATS_RX_PACKETS, - vf_stats.rx_packets, IFLA_VF_STATS_PAD) || - nla_put_u64_64bit(skb, IFLA_VF_STATS_TX_PACKETS, - vf_stats.tx_packets, IFLA_VF_STATS_PAD) || - nla_put_u64_64bit(skb, IFLA_VF_STATS_RX_BYTES, - vf_stats.rx_bytes, IFLA_VF_STATS_PAD) || - nla_put_u64_64bit(skb, IFLA_VF_STATS_TX_BYTES, - vf_stats.tx_bytes, IFLA_VF_STATS_PAD) || - nla_put_u64_64bit(skb, IFLA_VF_STATS_BROADCAST, - vf_stats.broadcast, IFLA_VF_STATS_PAD) || - nla_put_u64_64bit(skb, IFLA_VF_STATS_MULTICAST, - vf_stats.multicast, IFLA_VF_STATS_PAD) || - nla_put_u64_64bit(skb, IFLA_VF_STATS_RX_DROPPED, - vf_stats.rx_dropped, IFLA_VF_STATS_PAD) || - nla_put_u64_64bit(skb, IFLA_VF_STATS_TX_DROPPED, - vf_stats.tx_dropped, IFLA_VF_STATS_PAD)) { - nla_nest_cancel(skb, vfstats); - goto nla_put_vf_failure; - } - nla_nest_end(skb, vfstats); + memset(&vf_stats, 0, sizeof(vf_stats)); + if (dev->netdev_ops->ndo_get_vf_stats) + dev->netdev_ops->ndo_get_vf_stats(dev, vfs_num, + &vf_stats); + vfstats = nla_nest_start_noflag(skb, IFLA_VF_STATS); + if (!vfstats) + goto nla_put_vf_failure; + if (nla_put_u64_64bit(skb, IFLA_VF_STATS_RX_PACKETS, + vf_stats.rx_packets, IFLA_VF_STATS_PAD) || + nla_put_u64_64bit(skb, IFLA_VF_STATS_TX_PACKETS, + vf_stats.tx_packets, IFLA_VF_STATS_PAD) || + nla_put_u64_64bit(skb, IFLA_VF_STATS_RX_BYTES, + vf_stats.rx_bytes, IFLA_VF_STATS_PAD) || + nla_put_u64_64bit(skb, IFLA_VF_STATS_TX_BYTES, + vf_stats.tx_bytes, IFLA_VF_STATS_PAD) || + nla_put_u64_64bit(skb, IFLA_VF_STATS_BROADCAST, + vf_stats.broadcast, IFLA_VF_STATS_PAD) || + nla_put_u64_64bit(skb, IFLA_VF_STATS_MULTICAST, + vf_stats.multicast, IFLA_VF_STATS_PAD) || + nla_put_u64_64bit(skb, IFLA_VF_STATS_RX_DROPPED, + vf_stats.rx_dropped, IFLA_VF_STATS_PAD) || + nla_put_u64_64bit(skb, IFLA_VF_STATS_TX_DROPPED, + vf_stats.tx_dropped, IFLA_VF_STATS_PAD)) { + nla_nest_cancel(skb, vfstats); + goto nla_put_vf_failure; } + nla_nest_end(skb, vfstats); nla_nest_end(skb, vf); return 0; @@ -1392,7 +1386,7 @@ static noinline_for_stack int rtnl_fill_vf(struct sk_buff *skb, return -EMSGSIZE; for (i = 0; i < num_vfs; i++) { - if (rtnl_fill_vfinfo(skb, dev, i, vfinfo, ext_filter_mask)) + if (rtnl_fill_vfinfo(skb, dev, i, vfinfo)) return -EMSGSIZE; } @@ -3889,7 +3883,7 @@ static int nlmsg_populate_fdb_fill(struct sk_buff *skb, ndm->ndm_ifindex = dev->ifindex; ndm->ndm_state = ndm_state; - if (nla_put(skb, NDA_LLADDR, dev->addr_len, addr)) + if (nla_put(skb, NDA_LLADDR, ETH_ALEN, addr)) goto nla_put_failure; if (vid) if (nla_put(skb, NDA_VLAN, sizeof(u16), &vid)) @@ -3903,10 +3897,10 @@ static int nlmsg_populate_fdb_fill(struct sk_buff *skb, return -EMSGSIZE; } -static inline size_t rtnl_fdb_nlmsg_size(const struct net_device *dev) +static inline size_t rtnl_fdb_nlmsg_size(void) { return NLMSG_ALIGN(sizeof(struct ndmsg)) + - nla_total_size(dev->addr_len) + /* NDA_LLADDR */ + nla_total_size(ETH_ALEN) + /* NDA_LLADDR */ nla_total_size(sizeof(u16)) + /* NDA_VLAN */ 0; } @@ -3918,7 +3912,7 @@ static void rtnl_fdb_notify(struct net_device *dev, u8 *addr, u16 vid, int type, struct sk_buff *skb; int err = -ENOBUFS; - skb = nlmsg_new(rtnl_fdb_nlmsg_size(dev), GFP_ATOMIC); + skb = nlmsg_new(rtnl_fdb_nlmsg_size(), GFP_ATOMIC); if (!skb) goto errout; diff --git a/net/core/sock.c b/net/core/sock.c index 454ec635185e..2fe1475dc01f 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -2175,24 +2175,13 @@ kuid_t sock_i_uid(struct sock *sk) } EXPORT_SYMBOL(sock_i_uid); -unsigned long __sock_i_ino(struct sock *sk) -{ - unsigned long ino; - - read_lock(&sk->sk_callback_lock); - ino = sk->sk_socket ? SOCK_INODE(sk->sk_socket)->i_ino : 0; - read_unlock(&sk->sk_callback_lock); - return ino; -} -EXPORT_SYMBOL(__sock_i_ino); - unsigned long sock_i_ino(struct sock *sk) { unsigned long ino; - local_bh_disable(); - ino = __sock_i_ino(sk); - local_bh_enable(); + read_lock_bh(&sk->sk_callback_lock); + ino = sk->sk_socket ? SOCK_INODE(sk->sk_socket)->i_ino : 0; + read_unlock_bh(&sk->sk_callback_lock); return ino; } EXPORT_SYMBOL(sock_i_ino); diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 67908edad020..c7f22c43dd1a 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -4010,8 +4010,6 @@ static int do_tcp_getsockopt(struct sock *sk, int level, return -EFAULT; lock_sock(sk); err = tcp_zerocopy_receive(sk, &zc); - err = BPF_CGROUP_RUN_PROG_GETSOCKOPT_KERN(sk, level, optname, - &zc, &len, err); release_sock(sk); if (len >= offsetofend(struct tcp_zerocopy_receive, err)) goto zerocopy_rcv_sk_err; @@ -4046,18 +4044,6 @@ static int do_tcp_getsockopt(struct sock *sk, int level, return 0; } -bool tcp_bpf_bypass_getsockopt(int level, int optname) -{ - /* TCP do_tcp_getsockopt has optimized getsockopt implementation - * to avoid extra socket lock for TCP_ZEROCOPY_RECEIVE. - */ - if (level == SOL_TCP && optname == TCP_ZEROCOPY_RECEIVE) - return true; - - return false; -} -EXPORT_SYMBOL(tcp_bpf_bypass_getsockopt); - int tcp_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen) { diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index d62d5d7764ad..270b20e0907c 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -2805,7 +2805,6 @@ struct proto tcp_prot = { .shutdown = tcp_shutdown, .setsockopt = tcp_setsockopt, .getsockopt = tcp_getsockopt, - .bpf_bypass_getsockopt = tcp_bpf_bypass_getsockopt, .keepalive = tcp_set_keepalive, .recvmsg = tcp_recvmsg, .sendmsg = tcp_sendmsg, diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 2bcaed548dc1..d3a22fffaa7c 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -2137,7 +2137,6 @@ struct proto tcpv6_prot = { .shutdown = tcp_shutdown, .setsockopt = tcp_setsockopt, .getsockopt = tcp_getsockopt, - .bpf_bypass_getsockopt = tcp_bpf_bypass_getsockopt, .keepalive = tcp_set_keepalive, .recvmsg = tcp_recvmsg, .sendmsg = tcp_sendmsg, diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c index 751df19fe0f8..78fd9122b70c 100644 --- a/net/netfilter/nf_conntrack_sip.c +++ b/net/netfilter/nf_conntrack_sip.c @@ -611,7 +611,7 @@ int ct_sip_parse_numerical_param(const struct nf_conn *ct, const char *dptr, start += strlen(name); *val = simple_strtoul(start, &end, 0); if (start == end) - return -1; + return 0; if (matchoff && matchlen) { *matchoff = start - dptr; *matchlen = end - start; diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 9737c3229c12..99c869d8d304 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -1602,7 +1602,6 @@ static int do_one_set_err(struct sock *sk, struct netlink_set_err_data *p) int netlink_set_err(struct sock *ssk, u32 portid, u32 group, int code) { struct netlink_set_err_data info; - unsigned long flags; struct sock *sk; int ret = 0; @@ -1612,12 +1611,12 @@ int netlink_set_err(struct sock *ssk, u32 portid, u32 group, int code) /* sk->sk_err wants a positive error value */ info.code = -code; - read_lock_irqsave(&nl_table_lock, flags); + read_lock(&nl_table_lock); sk_for_each_bound(sk, &nl_table[ssk->sk_protocol].mc_list) ret += do_one_set_err(sk, &info); - read_unlock_irqrestore(&nl_table_lock, flags); + read_unlock(&nl_table_lock); return ret; } EXPORT_SYMBOL(netlink_set_err); diff --git a/net/netlink/diag.c b/net/netlink/diag.c index e4f21b1067bc..c6255eac305c 100644 --- a/net/netlink/diag.c +++ b/net/netlink/diag.c @@ -94,7 +94,6 @@ static int __netlink_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, struct net *net = sock_net(skb->sk); struct netlink_diag_req *req; struct netlink_sock *nlsk; - unsigned long flags; struct sock *sk; int num = 2; int ret = 0; @@ -153,7 +152,7 @@ static int __netlink_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, num++; mc_list: - read_lock_irqsave(&nl_table_lock, flags); + read_lock(&nl_table_lock); sk_for_each_bound(sk, &tbl->mc_list) { if (sk_hashed(sk)) continue; @@ -168,13 +167,13 @@ static int __netlink_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, NLM_F_MULTI, - __sock_i_ino(sk)) < 0) { + sock_i_ino(sk)) < 0) { ret = 1; break; } num++; } - read_unlock_irqrestore(&nl_table_lock, flags); + read_unlock(&nl_table_lock); done: cb->args[0] = num; diff --git a/net/nfc/core.c b/net/nfc/core.c index 10a3d740d155..2ef56366bd5f 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c @@ -634,7 +634,7 @@ int nfc_disable_se(struct nfc_dev *dev, u32 se_idx) return rc; } -int nfc_set_remote_general_bytes(struct nfc_dev *dev, const u8 *gb, u8 gb_len) +int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len) { pr_debug("dev_name=%s gb_len=%d\n", dev_name(&dev->dev), gb_len); @@ -663,7 +663,7 @@ int nfc_tm_data_received(struct nfc_dev *dev, struct sk_buff *skb) EXPORT_SYMBOL(nfc_tm_data_received); int nfc_tm_activated(struct nfc_dev *dev, u32 protocol, u8 comm_mode, - const u8 *gb, size_t gb_len) + u8 *gb, size_t gb_len) { int rc; diff --git a/net/nfc/hci/llc_shdlc.c b/net/nfc/hci/llc_shdlc.c index 02909e3e91ef..0eb4ddc056e7 100644 --- a/net/nfc/hci/llc_shdlc.c +++ b/net/nfc/hci/llc_shdlc.c @@ -123,7 +123,7 @@ static bool llc_shdlc_x_lteq_y_lt_z(int x, int y, int z) return ((y >= x) || (y < z)) ? true : false; } -static struct sk_buff *llc_shdlc_alloc_skb(const struct llc_shdlc *shdlc, +static struct sk_buff *llc_shdlc_alloc_skb(struct llc_shdlc *shdlc, int payload_len) { struct sk_buff *skb; @@ -137,7 +137,7 @@ static struct sk_buff *llc_shdlc_alloc_skb(const struct llc_shdlc *shdlc, } /* immediately sends an S frame. */ -static int llc_shdlc_send_s_frame(const struct llc_shdlc *shdlc, +static int llc_shdlc_send_s_frame(struct llc_shdlc *shdlc, enum sframe_type sframe_type, int nr) { int r; @@ -159,7 +159,7 @@ static int llc_shdlc_send_s_frame(const struct llc_shdlc *shdlc, } /* immediately sends an U frame. skb may contain optional payload */ -static int llc_shdlc_send_u_frame(const struct llc_shdlc *shdlc, +static int llc_shdlc_send_u_frame(struct llc_shdlc *shdlc, struct sk_buff *skb, enum uframe_modifier uframe_modifier) { @@ -361,7 +361,7 @@ static void llc_shdlc_connect_complete(struct llc_shdlc *shdlc, int r) wake_up(shdlc->connect_wq); } -static int llc_shdlc_connect_initiate(const struct llc_shdlc *shdlc) +static int llc_shdlc_connect_initiate(struct llc_shdlc *shdlc) { struct sk_buff *skb; @@ -377,7 +377,7 @@ static int llc_shdlc_connect_initiate(const struct llc_shdlc *shdlc) return llc_shdlc_send_u_frame(shdlc, skb, U_FRAME_RSET); } -static int llc_shdlc_connect_send_ua(const struct llc_shdlc *shdlc) +static int llc_shdlc_connect_send_ua(struct llc_shdlc *shdlc) { struct sk_buff *skb; diff --git a/net/nfc/llcp.h b/net/nfc/llcp.h index a81893bc06ce..97853c9cefc7 100644 --- a/net/nfc/llcp.h +++ b/net/nfc/llcp.h @@ -202,6 +202,7 @@ void nfc_llcp_sock_link(struct llcp_sock_list *l, struct sock *s); void nfc_llcp_sock_unlink(struct llcp_sock_list *l, struct sock *s); void nfc_llcp_socket_remote_param_init(struct nfc_llcp_sock *sock); struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev); +struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local); int nfc_llcp_local_put(struct nfc_llcp_local *local); u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local, struct nfc_llcp_sock *sock); @@ -220,15 +221,15 @@ struct sock *nfc_llcp_accept_dequeue(struct sock *sk, struct socket *newsock); /* TLV API */ int nfc_llcp_parse_gb_tlv(struct nfc_llcp_local *local, - const u8 *tlv_array, u16 tlv_array_len); + u8 *tlv_array, u16 tlv_array_len); int nfc_llcp_parse_connection_tlv(struct nfc_llcp_sock *sock, - const u8 *tlv_array, u16 tlv_array_len); + u8 *tlv_array, u16 tlv_array_len); /* Commands API */ void nfc_llcp_recv(void *data, struct sk_buff *skb, int err); -u8 *nfc_llcp_build_tlv(u8 type, const u8 *value, u8 value_length, u8 *tlv_length); +u8 *nfc_llcp_build_tlv(u8 type, u8 *value, u8 value_length, u8 *tlv_length); struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdres_tlv(u8 tid, u8 sap); -struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdreq_tlv(u8 tid, const char *uri, +struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdreq_tlv(u8 tid, char *uri, size_t uri_len); void nfc_llcp_free_sdp_tlv(struct nfc_llcp_sdp_tlv *sdp); void nfc_llcp_free_sdp_tlv_list(struct hlist_head *sdp_head); diff --git a/net/nfc/llcp_commands.c b/net/nfc/llcp_commands.c index 5b8754ae7d3a..475061c79c44 100644 --- a/net/nfc/llcp_commands.c +++ b/net/nfc/llcp_commands.c @@ -15,7 +15,7 @@ #include "nfc.h" #include "llcp.h" -static const u8 llcp_tlv_length[LLCP_TLV_MAX] = { +static u8 llcp_tlv_length[LLCP_TLV_MAX] = { 0, 1, /* VERSION */ 2, /* MIUX */ @@ -29,7 +29,7 @@ static const u8 llcp_tlv_length[LLCP_TLV_MAX] = { }; -static u8 llcp_tlv8(const u8 *tlv, u8 type) +static u8 llcp_tlv8(u8 *tlv, u8 type) { if (tlv[0] != type || tlv[1] != llcp_tlv_length[tlv[0]]) return 0; @@ -37,7 +37,7 @@ static u8 llcp_tlv8(const u8 *tlv, u8 type) return tlv[2]; } -static u16 llcp_tlv16(const u8 *tlv, u8 type) +static u16 llcp_tlv16(u8 *tlv, u8 type) { if (tlv[0] != type || tlv[1] != llcp_tlv_length[tlv[0]]) return 0; @@ -46,37 +46,37 @@ static u16 llcp_tlv16(const u8 *tlv, u8 type) } -static u8 llcp_tlv_version(const u8 *tlv) +static u8 llcp_tlv_version(u8 *tlv) { return llcp_tlv8(tlv, LLCP_TLV_VERSION); } -static u16 llcp_tlv_miux(const u8 *tlv) +static u16 llcp_tlv_miux(u8 *tlv) { return llcp_tlv16(tlv, LLCP_TLV_MIUX) & 0x7ff; } -static u16 llcp_tlv_wks(const u8 *tlv) +static u16 llcp_tlv_wks(u8 *tlv) { return llcp_tlv16(tlv, LLCP_TLV_WKS); } -static u16 llcp_tlv_lto(const u8 *tlv) +static u16 llcp_tlv_lto(u8 *tlv) { return llcp_tlv8(tlv, LLCP_TLV_LTO); } -static u8 llcp_tlv_opt(const u8 *tlv) +static u8 llcp_tlv_opt(u8 *tlv) { return llcp_tlv8(tlv, LLCP_TLV_OPT); } -static u8 llcp_tlv_rw(const u8 *tlv) +static u8 llcp_tlv_rw(u8 *tlv) { return llcp_tlv8(tlv, LLCP_TLV_RW) & 0xf; } -u8 *nfc_llcp_build_tlv(u8 type, const u8 *value, u8 value_length, u8 *tlv_length) +u8 *nfc_llcp_build_tlv(u8 type, u8 *value, u8 value_length, u8 *tlv_length) { u8 *tlv, length; @@ -130,7 +130,7 @@ struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdres_tlv(u8 tid, u8 sap) return sdres; } -struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdreq_tlv(u8 tid, const char *uri, +struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdreq_tlv(u8 tid, char *uri, size_t uri_len) { struct nfc_llcp_sdp_tlv *sdreq; @@ -190,10 +190,9 @@ void nfc_llcp_free_sdp_tlv_list(struct hlist_head *head) } int nfc_llcp_parse_gb_tlv(struct nfc_llcp_local *local, - const u8 *tlv_array, u16 tlv_array_len) + u8 *tlv_array, u16 tlv_array_len) { - const u8 *tlv = tlv_array; - u8 type, length, offset = 0; + u8 *tlv = tlv_array, type, length, offset = 0; pr_debug("TLV array length %d\n", tlv_array_len); @@ -240,10 +239,9 @@ int nfc_llcp_parse_gb_tlv(struct nfc_llcp_local *local, } int nfc_llcp_parse_connection_tlv(struct nfc_llcp_sock *sock, - const u8 *tlv_array, u16 tlv_array_len) + u8 *tlv_array, u16 tlv_array_len) { - const u8 *tlv = tlv_array; - u8 type, length, offset = 0; + u8 *tlv = tlv_array, type, length, offset = 0; pr_debug("TLV array length %d\n", tlv_array_len); @@ -297,7 +295,7 @@ static struct sk_buff *llcp_add_header(struct sk_buff *pdu, return pdu; } -static struct sk_buff *llcp_add_tlv(struct sk_buff *pdu, const u8 *tlv, +static struct sk_buff *llcp_add_tlv(struct sk_buff *pdu, u8 *tlv, u8 tlv_length) { /* XXX Add an skb length check */ @@ -361,7 +359,6 @@ int nfc_llcp_send_symm(struct nfc_dev *dev) struct sk_buff *skb; struct nfc_llcp_local *local; u16 size = 0; - int err; pr_debug("Sending SYMM\n"); @@ -373,10 +370,8 @@ int nfc_llcp_send_symm(struct nfc_dev *dev) size += dev->tx_headroom + dev->tx_tailroom + NFC_HEADER_SIZE; skb = alloc_skb(size, GFP_KERNEL); - if (skb == NULL) { - err = -ENOMEM; - goto out; - } + if (skb == NULL) + return -ENOMEM; skb_reserve(skb, dev->tx_headroom + NFC_HEADER_SIZE); @@ -386,22 +381,17 @@ int nfc_llcp_send_symm(struct nfc_dev *dev) nfc_llcp_send_to_raw_sock(local, skb, NFC_DIRECTION_TX); - err = nfc_data_exchange(dev, local->target_idx, skb, + return nfc_data_exchange(dev, local->target_idx, skb, nfc_llcp_recv, local); -out: - nfc_llcp_local_put(local); - return err; } int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) { struct nfc_llcp_local *local; struct sk_buff *skb; - const u8 *service_name_tlv = NULL; - const u8 *miux_tlv = NULL; - const u8 *rw_tlv = NULL; - u8 service_name_tlv_length = 0; - u8 miux_tlv_length, rw_tlv_length, rw; + u8 *service_name_tlv = NULL, service_name_tlv_length; + u8 *miux_tlv = NULL, miux_tlv_length; + u8 *rw_tlv = NULL, rw_tlv_length, rw; int err; u16 size = 0; __be16 miux; @@ -475,9 +465,8 @@ int nfc_llcp_send_cc(struct nfc_llcp_sock *sock) { struct nfc_llcp_local *local; struct sk_buff *skb; - const u8 *miux_tlv = NULL; - const u8 *rw_tlv = NULL; - u8 miux_tlv_length, rw_tlv_length, rw; + u8 *miux_tlv = NULL, miux_tlv_length; + u8 *rw_tlv = NULL, rw_tlv_length, rw; int err; u16 size = 0; __be16 miux; diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c index ddfd159f64e1..edadebb3efd2 100644 --- a/net/nfc/llcp_core.c +++ b/net/nfc/llcp_core.c @@ -17,8 +17,6 @@ static u8 llcp_magic[3] = {0x46, 0x66, 0x6d}; static LIST_HEAD(llcp_devices); -/* Protects llcp_devices list */ -static DEFINE_SPINLOCK(llcp_devices_lock); static void nfc_llcp_rx_skb(struct nfc_llcp_local *local, struct sk_buff *skb); @@ -145,7 +143,7 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool device, write_unlock(&local->raw_sockets.lock); } -static struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local) +struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local) { kref_get(&local->ref); @@ -173,6 +171,7 @@ static void local_release(struct kref *ref) local = container_of(ref, struct nfc_llcp_local, ref); + list_del(&local->list); local_cleanup(local); kfree(local); } @@ -285,33 +284,12 @@ static void nfc_llcp_sdreq_timer(struct timer_list *t) struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev) { struct nfc_llcp_local *local; - struct nfc_llcp_local *res = NULL; - spin_lock(&llcp_devices_lock); list_for_each_entry(local, &llcp_devices, list) - if (local->dev == dev) { - res = nfc_llcp_local_get(local); - break; - } - spin_unlock(&llcp_devices_lock); - - return res; -} - -static struct nfc_llcp_local *nfc_llcp_remove_local(struct nfc_dev *dev) -{ - struct nfc_llcp_local *local, *tmp; - - spin_lock(&llcp_devices_lock); - list_for_each_entry_safe(local, tmp, &llcp_devices, list) - if (local->dev == dev) { - list_del(&local->list); - spin_unlock(&llcp_devices_lock); + if (local->dev == dev) return local; - } - spin_unlock(&llcp_devices_lock); - pr_warn("Shutting down device not found\n"); + pr_debug("No device found\n"); return NULL; } @@ -324,7 +302,7 @@ static char *wks[] = { "urn:nfc:sn:snep", }; -static int nfc_llcp_wks_sap(const char *service_name, size_t service_name_len) +static int nfc_llcp_wks_sap(char *service_name, size_t service_name_len) { int sap, num_wks; @@ -348,7 +326,7 @@ static int nfc_llcp_wks_sap(const char *service_name, size_t service_name_len) static struct nfc_llcp_sock *nfc_llcp_sock_from_sn(struct nfc_llcp_local *local, - const u8 *sn, size_t sn_len) + u8 *sn, size_t sn_len) { struct sock *sk; struct nfc_llcp_sock *llcp_sock, *tmp_sock; @@ -545,7 +523,7 @@ static int nfc_llcp_build_gb(struct nfc_llcp_local *local) { u8 *gb_cur, version, version_length; u8 lto_length, wks_length, miux_length; - const u8 *version_tlv = NULL, *lto_tlv = NULL, + u8 *version_tlv = NULL, *lto_tlv = NULL, *wks_tlv = NULL, *miux_tlv = NULL; __be16 wks = cpu_to_be16(local->local_wks); u8 gb_len = 0; @@ -632,15 +610,12 @@ u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, size_t *general_bytes_len) *general_bytes_len = local->gb_len; - nfc_llcp_local_put(local); - return local->gb; } -int nfc_llcp_set_remote_gb(struct nfc_dev *dev, const u8 *gb, u8 gb_len) +int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len) { struct nfc_llcp_local *local; - int err; if (gb_len < 3 || gb_len > NFC_MAX_GT_LEN) return -EINVAL; @@ -657,39 +632,35 @@ int nfc_llcp_set_remote_gb(struct nfc_dev *dev, const u8 *gb, u8 gb_len) if (memcmp(local->remote_gb, llcp_magic, 3)) { pr_err("MAC does not support LLCP\n"); - err = -EINVAL; - goto out; + return -EINVAL; } - err = nfc_llcp_parse_gb_tlv(local, + return nfc_llcp_parse_gb_tlv(local, &local->remote_gb[3], local->remote_gb_len - 3); -out: - nfc_llcp_local_put(local); - return err; } -static u8 nfc_llcp_dsap(const struct sk_buff *pdu) +static u8 nfc_llcp_dsap(struct sk_buff *pdu) { return (pdu->data[0] & 0xfc) >> 2; } -static u8 nfc_llcp_ptype(const struct sk_buff *pdu) +static u8 nfc_llcp_ptype(struct sk_buff *pdu) { return ((pdu->data[0] & 0x03) << 2) | ((pdu->data[1] & 0xc0) >> 6); } -static u8 nfc_llcp_ssap(const struct sk_buff *pdu) +static u8 nfc_llcp_ssap(struct sk_buff *pdu) { return pdu->data[1] & 0x3f; } -static u8 nfc_llcp_ns(const struct sk_buff *pdu) +static u8 nfc_llcp_ns(struct sk_buff *pdu) { return pdu->data[2] >> 4; } -static u8 nfc_llcp_nr(const struct sk_buff *pdu) +static u8 nfc_llcp_nr(struct sk_buff *pdu) { return pdu->data[2] & 0xf; } @@ -831,7 +802,7 @@ static struct nfc_llcp_sock *nfc_llcp_connecting_sock_get(struct nfc_llcp_local } static struct nfc_llcp_sock *nfc_llcp_sock_get_sn(struct nfc_llcp_local *local, - const u8 *sn, size_t sn_len) + u8 *sn, size_t sn_len) { struct nfc_llcp_sock *llcp_sock; @@ -845,10 +816,9 @@ static struct nfc_llcp_sock *nfc_llcp_sock_get_sn(struct nfc_llcp_local *local, return llcp_sock; } -static const u8 *nfc_llcp_connect_sn(const struct sk_buff *skb, size_t *sn_len) +static u8 *nfc_llcp_connect_sn(struct sk_buff *skb, size_t *sn_len) { - u8 type, length; - const u8 *tlv = &skb->data[2]; + u8 *tlv = &skb->data[2], type, length; size_t tlv_array_len = skb->len - LLCP_HEADER_SIZE, offset = 0; while (offset < tlv_array_len) { @@ -906,7 +876,7 @@ static void nfc_llcp_recv_ui(struct nfc_llcp_local *local, } static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, - const struct sk_buff *skb) + struct sk_buff *skb) { struct sock *new_sk, *parent; struct nfc_llcp_sock *sock, *new_sock; @@ -924,7 +894,7 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, goto fail; } } else { - const u8 *sn; + u8 *sn; size_t sn_len; sn = nfc_llcp_connect_sn(skb, &sn_len); @@ -1143,7 +1113,7 @@ static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local, } static void nfc_llcp_recv_disc(struct nfc_llcp_local *local, - const struct sk_buff *skb) + struct sk_buff *skb) { struct nfc_llcp_sock *llcp_sock; struct sock *sk; @@ -1186,8 +1156,7 @@ static void nfc_llcp_recv_disc(struct nfc_llcp_local *local, nfc_llcp_sock_put(llcp_sock); } -static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, - const struct sk_buff *skb) +static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, struct sk_buff *skb) { struct nfc_llcp_sock *llcp_sock; struct sock *sk; @@ -1220,8 +1189,7 @@ static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, nfc_llcp_sock_put(llcp_sock); } -static void nfc_llcp_recv_dm(struct nfc_llcp_local *local, - const struct sk_buff *skb) +static void nfc_llcp_recv_dm(struct nfc_llcp_local *local, struct sk_buff *skb) { struct nfc_llcp_sock *llcp_sock; struct sock *sk; @@ -1259,13 +1227,12 @@ static void nfc_llcp_recv_dm(struct nfc_llcp_local *local, } static void nfc_llcp_recv_snl(struct nfc_llcp_local *local, - const struct sk_buff *skb) + struct sk_buff *skb) { struct nfc_llcp_sock *llcp_sock; - u8 dsap, ssap, type, length, tid, sap; - const u8 *tlv; + u8 dsap, ssap, *tlv, type, length, tid, sap; u16 tlv_len, offset; - const char *service_name; + char *service_name; size_t service_name_len; struct nfc_llcp_sdp_tlv *sdp; HLIST_HEAD(llc_sdres_list); @@ -1556,8 +1523,6 @@ int nfc_llcp_data_received(struct nfc_dev *dev, struct sk_buff *skb) __nfc_llcp_recv(local, skb); - nfc_llcp_local_put(local); - return 0; } @@ -1574,8 +1539,6 @@ void nfc_llcp_mac_is_down(struct nfc_dev *dev) /* Close and purge all existing sockets */ nfc_llcp_socket_release(local, true, 0); - - nfc_llcp_local_put(local); } void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx, @@ -1601,8 +1564,6 @@ void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx, mod_timer(&local->link_timer, jiffies + msecs_to_jiffies(local->remote_lto)); } - - nfc_llcp_local_put(local); } int nfc_llcp_register_device(struct nfc_dev *ndev) @@ -1653,7 +1614,7 @@ int nfc_llcp_register_device(struct nfc_dev *ndev) void nfc_llcp_unregister_device(struct nfc_dev *dev) { - struct nfc_llcp_local *local = nfc_llcp_remove_local(dev); + struct nfc_llcp_local *local = nfc_llcp_find_local(dev); if (local == NULL) { pr_debug("No such device\n"); diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c index 6e1fba208493..0b93a17b9f11 100644 --- a/net/nfc/llcp_sock.c +++ b/net/nfc/llcp_sock.c @@ -99,7 +99,7 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) } llcp_sock->dev = dev; - llcp_sock->local = local; + llcp_sock->local = nfc_llcp_local_get(local); llcp_sock->nfc_protocol = llcp_addr.nfc_protocol; llcp_sock->service_name_len = min_t(unsigned int, llcp_addr.service_name_len, @@ -181,7 +181,7 @@ static int llcp_raw_sock_bind(struct socket *sock, struct sockaddr *addr, } llcp_sock->dev = dev; - llcp_sock->local = local; + llcp_sock->local = nfc_llcp_local_get(local); llcp_sock->nfc_protocol = llcp_addr.nfc_protocol; nfc_llcp_sock_link(&local->raw_sockets, sk); @@ -698,22 +698,24 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, if (dev->dep_link_up == false) { ret = -ENOLINK; device_unlock(&dev->dev); - goto sock_llcp_put_local; + goto put_dev; } device_unlock(&dev->dev); if (local->rf_mode == NFC_RF_INITIATOR && addr->target_idx != local->target_idx) { ret = -ENOLINK; - goto sock_llcp_put_local; + goto put_dev; } llcp_sock->dev = dev; - llcp_sock->local = local; + llcp_sock->local = nfc_llcp_local_get(local); llcp_sock->ssap = nfc_llcp_get_local_ssap(local); if (llcp_sock->ssap == LLCP_SAP_MAX) { + nfc_llcp_local_put(llcp_sock->local); + llcp_sock->local = NULL; ret = -ENOMEM; - goto sock_llcp_nullify; + goto put_dev; } llcp_sock->reserved_ssap = llcp_sock->ssap; @@ -758,13 +760,8 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, sock_llcp_release: nfc_llcp_put_ssap(local, llcp_sock->ssap); - -sock_llcp_nullify: + nfc_llcp_local_put(llcp_sock->local); llcp_sock->local = NULL; - llcp_sock->dev = NULL; - -sock_llcp_put_local: - nfc_llcp_local_put(local); put_dev: nfc_put_device(dev); diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index fe6d8effa979..86f44d45b60f 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -1039,14 +1039,11 @@ static int nfc_genl_llc_get_params(struct sk_buff *skb, struct genl_info *info) msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); if (!msg) { rc = -ENOMEM; - goto put_local; + goto exit; } rc = nfc_genl_send_params(msg, local, info->snd_portid, info->snd_seq); -put_local: - nfc_llcp_local_put(local); - exit: device_unlock(&dev->dev); @@ -1108,7 +1105,7 @@ static int nfc_genl_llc_set_params(struct sk_buff *skb, struct genl_info *info) if (info->attrs[NFC_ATTR_LLC_PARAM_LTO]) { if (dev->dep_link_up) { rc = -EINPROGRESS; - goto put_local; + goto exit; } local->lto = nla_get_u8(info->attrs[NFC_ATTR_LLC_PARAM_LTO]); @@ -1120,9 +1117,6 @@ static int nfc_genl_llc_set_params(struct sk_buff *skb, struct genl_info *info) if (info->attrs[NFC_ATTR_LLC_PARAM_MIUX]) local->miux = cpu_to_be16(miux); -put_local: - nfc_llcp_local_put(local); - exit: device_unlock(&dev->dev); @@ -1178,7 +1172,7 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info) if (rc != 0) { rc = -EINVAL; - goto put_local; + goto exit; } if (!sdp_attrs[NFC_SDP_ATTR_URI]) @@ -1197,7 +1191,7 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info) sdreq = nfc_llcp_build_sdreq_tlv(tid, uri, uri_len); if (sdreq == NULL) { rc = -ENOMEM; - goto put_local; + goto exit; } tlvs_len += sdreq->tlv_len; @@ -1207,14 +1201,10 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info) if (hlist_empty(&sdreq_list)) { rc = -EINVAL; - goto put_local; + goto exit; } rc = nfc_llcp_send_snl_sdreq(local, &sdreq_list, tlvs_len); - -put_local: - nfc_llcp_local_put(local); - exit: device_unlock(&dev->dev); diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h index 0b1e6466f4fb..889fefd64e56 100644 --- a/net/nfc/nfc.h +++ b/net/nfc/nfc.h @@ -48,11 +48,10 @@ void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx, u8 comm_mode, u8 rf_mode); int nfc_llcp_register_device(struct nfc_dev *dev); void nfc_llcp_unregister_device(struct nfc_dev *dev); -int nfc_llcp_set_remote_gb(struct nfc_dev *dev, const u8 *gb, u8 gb_len); +int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len); u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, size_t *general_bytes_len); int nfc_llcp_data_received(struct nfc_dev *dev, struct sk_buff *skb); struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev); -int nfc_llcp_local_put(struct nfc_llcp_local *local); int __init nfc_llcp_init(void); void nfc_llcp_exit(void); void nfc_llcp_free_sdp_tlv(struct nfc_llcp_sdp_tlv *sdp); diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 534364bb871a..5d2f580c7931 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -8039,22 +8039,6 @@ static int sctp_getsockopt(struct sock *sk, int level, int optname, return retval; } -static bool sctp_bpf_bypass_getsockopt(int level, int optname) -{ - if (level == SOL_SCTP) { - switch (optname) { - case SCTP_SOCKOPT_PEELOFF: - case SCTP_SOCKOPT_PEELOFF_FLAGS: - case SCTP_SOCKOPT_CONNECTX3: - return true; - default: - return false; - } - } - - return false; -} - static int sctp_hash(struct sock *sk) { /* STUB */ @@ -9423,7 +9407,6 @@ struct proto sctp_prot = { .shutdown = sctp_shutdown, .setsockopt = sctp_setsockopt, .getsockopt = sctp_getsockopt, - .bpf_bypass_getsockopt = sctp_bpf_bypass_getsockopt, .sendmsg = sctp_sendmsg, .recvmsg = sctp_recvmsg, .bind = sctp_bind, @@ -9476,7 +9459,6 @@ struct proto sctpv6_prot = { .shutdown = sctp_shutdown, .setsockopt = sctp_setsockopt, .getsockopt = sctp_getsockopt, - .bpf_bypass_getsockopt = sctp_bpf_bypass_getsockopt, .sendmsg = sctp_sendmsg, .recvmsg = sctp_recvmsg, .bind = sctp_bind, diff --git a/net/socket.c b/net/socket.c index f2172b756c0f..84223419da86 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2137,9 +2137,6 @@ SYSCALL_DEFINE5(setsockopt, int, fd, int, level, int, optname, return __sys_setsockopt(fd, level, optname, optval, optlen); } -INDIRECT_CALLABLE_DECLARE(bool tcp_bpf_bypass_getsockopt(int level, - int optname)); - /* * Get a socket option. Because we don't know the option lengths we have * to pass a user mode parameter for the protocols to sort out. diff --git a/net/wireless/scan.c b/net/wireless/scan.c index 671c7f83d5fc..d09dabae5627 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -262,152 +262,117 @@ bool cfg80211_is_element_inherited(const struct element *elem, } EXPORT_SYMBOL(cfg80211_is_element_inherited); -static size_t cfg80211_copy_elem_with_frags(const struct element *elem, - const u8 *ie, size_t ie_len, - u8 **pos, u8 *buf, size_t buf_len) +static size_t cfg80211_gen_new_ie(const u8 *ie, size_t ielen, + const u8 *subelement, size_t subie_len, + u8 *new_ie, gfp_t gfp) { - if (WARN_ON((u8 *)elem < ie || elem->data > ie + ie_len || - elem->data + elem->datalen > ie + ie_len)) - return 0; + u8 *pos, *tmp; + const u8 *tmp_old, *tmp_new; + const struct element *non_inherit_elem; + u8 *sub_copy; - if (elem->datalen + 2 > buf + buf_len - *pos) + /* copy subelement as we need to change its content to + * mark an ie after it is processed. + */ + sub_copy = kmemdup(subelement, subie_len, gfp); + if (!sub_copy) return 0; - memcpy(*pos, elem, elem->datalen + 2); - *pos += elem->datalen + 2; + pos = &new_ie[0]; - /* Finish if it is not fragmented */ - if (elem->datalen != 255) - return *pos - buf; - - ie_len = ie + ie_len - elem->data - elem->datalen; - ie = (const u8 *)elem->data + elem->datalen; - - for_each_element(elem, ie, ie_len) { - if (elem->id != WLAN_EID_FRAGMENT) - break; - - if (elem->datalen + 2 > buf + buf_len - *pos) - return 0; - - memcpy(*pos, elem, elem->datalen + 2); - *pos += elem->datalen + 2; - - if (elem->datalen != 255) - break; + /* set new ssid */ + tmp_new = cfg80211_find_ie(WLAN_EID_SSID, sub_copy, subie_len); + if (tmp_new) { + memcpy(pos, tmp_new, tmp_new[1] + 2); + pos += (tmp_new[1] + 2); } - return *pos - buf; -} + /* get non inheritance list if exists */ + non_inherit_elem = + cfg80211_find_ext_elem(WLAN_EID_EXT_NON_INHERITANCE, + sub_copy, subie_len); -static size_t cfg80211_gen_new_ie(const u8 *ie, size_t ielen, - const u8 *subie, size_t subie_len, - u8 *new_ie, size_t new_ie_len) -{ - const struct element *non_inherit_elem, *parent, *sub; - u8 *pos = new_ie; - u8 id, ext_id; - unsigned int match_len; - - non_inherit_elem = cfg80211_find_ext_elem(WLAN_EID_EXT_NON_INHERITANCE, - subie, subie_len); - - /* We copy the elements one by one from the parent to the generated - * elements. - * If they are not inherited (included in subie or in the non - * inheritance element), then we copy all occurrences the first time - * we see this element type. + /* go through IEs in ie (skip SSID) and subelement, + * merge them into new_ie */ - for_each_element(parent, ie, ielen) { - if (parent->id == WLAN_EID_FRAGMENT) - continue; + tmp_old = cfg80211_find_ie(WLAN_EID_SSID, ie, ielen); + tmp_old = (tmp_old) ? tmp_old + tmp_old[1] + 2 : ie; - if (parent->id == WLAN_EID_EXTENSION) { - if (parent->datalen < 1) - continue; - - id = WLAN_EID_EXTENSION; - ext_id = parent->data[0]; - match_len = 1; - } else { - id = parent->id; - match_len = 0; + while (tmp_old + 2 - ie <= ielen && + tmp_old + tmp_old[1] + 2 - ie <= ielen) { + if (tmp_old[0] == 0) { + tmp_old++; + continue; } - /* Find first occurrence in subie */ - sub = cfg80211_find_elem_match(id, subie, subie_len, - &ext_id, match_len, 0); + if (tmp_old[0] == WLAN_EID_EXTENSION) + tmp = (u8 *)cfg80211_find_ext_ie(tmp_old[2], sub_copy, + subie_len); + else + tmp = (u8 *)cfg80211_find_ie(tmp_old[0], sub_copy, + subie_len); - /* Copy from parent if not in subie and inherited */ - if (!sub && - cfg80211_is_element_inherited(parent, non_inherit_elem)) { - if (!cfg80211_copy_elem_with_frags(parent, - ie, ielen, - &pos, new_ie, - new_ie_len)) - return 0; + if (!tmp) { + const struct element *old_elem = (void *)tmp_old; - continue; + /* ie in old ie but not in subelement */ + if (cfg80211_is_element_inherited(old_elem, + non_inherit_elem)) { + memcpy(pos, tmp_old, tmp_old[1] + 2); + pos += tmp_old[1] + 2; + } + } else { + /* ie in transmitting ie also in subelement, + * copy from subelement and flag the ie in subelement + * as copied (by setting eid field to WLAN_EID_SSID, + * which is skipped anyway). + * For vendor ie, compare OUI + type + subType to + * determine if they are the same ie. + */ + if (tmp_old[0] == WLAN_EID_VENDOR_SPECIFIC) { + if (tmp_old[1] >= 5 && tmp[1] >= 5 && + !memcmp(tmp_old + 2, tmp + 2, 5)) { + /* same vendor ie, copy from + * subelement + */ + memcpy(pos, tmp, tmp[1] + 2); + pos += tmp[1] + 2; + tmp[0] = WLAN_EID_SSID; + } else { + memcpy(pos, tmp_old, tmp_old[1] + 2); + pos += tmp_old[1] + 2; + } + } else { + /* copy ie from subelement into new ie */ + memcpy(pos, tmp, tmp[1] + 2); + pos += tmp[1] + 2; + tmp[0] = WLAN_EID_SSID; + } } - /* Already copied if an earlier element had the same type */ - if (cfg80211_find_elem_match(id, ie, (u8 *)parent - ie, - &ext_id, match_len, 0)) - continue; + if (tmp_old + tmp_old[1] + 2 - ie == ielen) + break; - /* Not inheriting, copy all similar elements from subie */ - while (sub) { - if (!cfg80211_copy_elem_with_frags(sub, - subie, subie_len, - &pos, new_ie, - new_ie_len)) - return 0; - - sub = cfg80211_find_elem_match(id, - sub->data + sub->datalen, - subie_len + subie - - (sub->data + - sub->datalen), - &ext_id, match_len, 0); - } + tmp_old += tmp_old[1] + 2; } - /* The above misses elements that are included in subie but not in the - * parent, so do a pass over subie and append those. - * Skip the non-tx BSSID caps and non-inheritance element. + /* go through subelement again to check if there is any ie not + * copied to new ie, skip ssid, capability, bssid-index ie */ - for_each_element(sub, subie, subie_len) { - if (sub->id == WLAN_EID_NON_TX_BSSID_CAP) - continue; - - if (sub->id == WLAN_EID_FRAGMENT) - continue; - - if (sub->id == WLAN_EID_EXTENSION) { - if (sub->datalen < 1) - continue; - - id = WLAN_EID_EXTENSION; - ext_id = sub->data[0]; - match_len = 1; - - if (ext_id == WLAN_EID_EXT_NON_INHERITANCE) - continue; - } else { - id = sub->id; - match_len = 0; + tmp_new = sub_copy; + while (tmp_new + 2 - sub_copy <= subie_len && + tmp_new + tmp_new[1] + 2 - sub_copy <= subie_len) { + if (!(tmp_new[0] == WLAN_EID_NON_TX_BSSID_CAP || + tmp_new[0] == WLAN_EID_SSID)) { + memcpy(pos, tmp_new, tmp_new[1] + 2); + pos += tmp_new[1] + 2; } - - /* Processed if one was included in the parent */ - if (cfg80211_find_elem_match(id, ie, ielen, - &ext_id, match_len, 0)) - continue; - - if (!cfg80211_copy_elem_with_frags(sub, subie, subie_len, - &pos, new_ie, new_ie_len)) - return 0; + if (tmp_new + tmp_new[1] + 2 - sub_copy == subie_len) + break; + tmp_new += tmp_new[1] + 2; } + kfree(sub_copy); return pos - new_ie; } @@ -2205,7 +2170,7 @@ static void cfg80211_parse_mbssid_data(struct wiphy *wiphy, new_ie_len = cfg80211_gen_new_ie(ie, ielen, profile, profile_len, new_ie, - IEEE80211_MAX_DATA_LEN); + gfp); if (!new_ie_len) continue; diff --git a/samples/bpf/tcp_basertt_kern.c b/samples/bpf/tcp_basertt_kern.c index 822b0742b815..8dfe09a92fec 100644 --- a/samples/bpf/tcp_basertt_kern.c +++ b/samples/bpf/tcp_basertt_kern.c @@ -47,7 +47,7 @@ int bpf_basertt(struct bpf_sock_ops *skops) case BPF_SOCK_OPS_BASE_RTT: n = bpf_getsockopt(skops, SOL_TCP, TCP_CONGESTION, cong, sizeof(cong)); - if (!n && !__builtin_memcmp(cong, nv, sizeof(nv))) { + if (!n && !__builtin_memcmp(cong, nv, sizeof(nv)+1)) { /* Set base_rtt to 80us */ rv = 80; } else if (n) { diff --git a/scripts/tags.sh b/scripts/tags.sh index d17801c9d85a..b82aebb0c995 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -32,13 +32,6 @@ else ignore="$ignore ( -path ${tree}tools ) -prune -o" fi -# gtags(1) refuses to index any file outside of its current working dir. -# If gtags indexing is requested and the build output directory is not -# the kernel source tree, index all files in absolute-path form. -if [[ "$1" == "gtags" && -n "${tree}" ]]; then - tree=$(realpath "$tree")/ -fi - # Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH if [ "${ALLSOURCE_ARCHS}" = "" ]; then ALLSOURCE_ARCHS=${SRCARCH} @@ -138,7 +131,7 @@ docscope() dogtags() { - all_target_sources | gtags -i -C "${tree:-.}" -f - "$PWD" + all_target_sources | gtags -i -f - } # Basic regular expressions with an optional /kind-spec/ for ctags and diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c index 8cfc49fa4df5..0033364ac404 100644 --- a/security/integrity/evm/evm_main.c +++ b/security/integrity/evm/evm_main.c @@ -472,9 +472,7 @@ void evm_inode_post_removexattr(struct dentry *dentry, const char *xattr_name) /** * evm_inode_setattr - prevent updating an invalid EVM extended attribute - * @idmap: idmap of the mount * @dentry: pointer to the affected dentry - * @attr: iattr structure containing the new file attributes * * Permit update of file attributes when files have a valid EVM signature, * except in the case of them having an immutable portable signature. diff --git a/security/integrity/ima/ima_modsig.c b/security/integrity/ima/ima_modsig.c index 3e7bee30080f..fb25723c65bc 100644 --- a/security/integrity/ima/ima_modsig.c +++ b/security/integrity/ima/ima_modsig.c @@ -89,9 +89,6 @@ int ima_read_modsig(enum ima_hooks func, const void *buf, loff_t buf_len, /** * ima_collect_modsig - Calculate the file hash without the appended signature. - * @modsig: parsed module signature - * @buf: data to verify the signature on - * @size: data size * * Since the modsig is part of the file contents, the hash used in its signature * isn't the same one ordinarily calculated by IMA. Therefore PKCS7 code diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index 1c403e8a8044..96ecb7d25403 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -628,7 +628,6 @@ static int get_subaction(struct ima_rule_entry *rule, enum ima_hooks func) * @secid: LSM secid of the task to be validated * @func: IMA hook identifier * @mask: requested action (MAY_READ | MAY_WRITE | MAY_APPEND | MAY_EXEC) - * @flags: IMA actions to consider (e.g. IMA_MEASURE | IMA_APPRAISE) * @pcr: set the pcr to extend * @template_desc: the template that should be used for this rule * @keyring: the keyring name, if given, to be used to check in the policy. @@ -1516,7 +1515,7 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry) /** * ima_parse_add_rule - add a rule to ima_policy_rules - * @rule: ima measurement policy rule + * @rule - ima measurement policy rule * * Avoid locking by allowing just one writer at a time in ima_write_policy() * Returns the length of the rule parsed, an error code on failure diff --git a/tools/bpf/bpftool/feature.c b/tools/bpf/bpftool/feature.c index 5f0b1397798e..359960a8f1de 100644 --- a/tools/bpf/bpftool/feature.c +++ b/tools/bpf/bpftool/feature.c @@ -135,12 +135,12 @@ static void print_end_section(void) /* Probing functions */ -static long read_procfs(const char *path) +static int read_procfs(const char *path) { char *endptr, *line = NULL; size_t len = 0; FILE *fd; - long res; + int res; fd = fopen(path, "r"); if (!fd) @@ -162,7 +162,7 @@ static long read_procfs(const char *path) static void probe_unprivileged_disabled(void) { - long res; + int res; /* No support for C-style ouptut */ @@ -181,14 +181,14 @@ static void probe_unprivileged_disabled(void) printf("Unable to retrieve required privileges for bpf() syscall\n"); break; default: - printf("bpf() syscall restriction has unknown value %ld\n", res); + printf("bpf() syscall restriction has unknown value %d\n", res); } } } static void probe_jit_enable(void) { - long res; + int res; /* No support for C-style ouptut */ @@ -210,7 +210,7 @@ static void probe_jit_enable(void) printf("Unable to retrieve JIT-compiler status\n"); break; default: - printf("JIT-compiler status has unknown value %ld\n", + printf("JIT-compiler status has unknown value %d\n", res); } } @@ -218,7 +218,7 @@ static void probe_jit_enable(void) static void probe_jit_harden(void) { - long res; + int res; /* No support for C-style ouptut */ @@ -240,7 +240,7 @@ static void probe_jit_harden(void) printf("Unable to retrieve JIT hardening status\n"); break; default: - printf("JIT hardening status has unknown value %ld\n", + printf("JIT hardening status has unknown value %d\n", res); } } @@ -248,7 +248,7 @@ static void probe_jit_harden(void) static void probe_jit_kallsyms(void) { - long res; + int res; /* No support for C-style ouptut */ @@ -267,14 +267,14 @@ static void probe_jit_kallsyms(void) printf("Unable to retrieve JIT kallsyms export status\n"); break; default: - printf("JIT kallsyms exports status has unknown value %ld\n", res); + printf("JIT kallsyms exports status has unknown value %d\n", res); } } } static void probe_jit_limit(void) { - long res; + int res; /* No support for C-style ouptut */ @@ -287,7 +287,7 @@ static void probe_jit_limit(void) printf("Unable to retrieve global memory limit for JIT compiler for unprivileged users\n"); break; default: - printf("Global memory limit for JIT compiler for unprivileged users is %ld bytes\n", res); + printf("Global memory limit for JIT compiler for unprivileged users is %d bytes\n", res); } } } diff --git a/tools/include/uapi/linux/tcp.h b/tools/include/uapi/linux/tcp.h deleted file mode 100644 index 13ceeb395eb8..000000000000 --- a/tools/include/uapi/linux/tcp.h +++ /dev/null @@ -1,357 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ -/* - * INET An implementation of the TCP/IP protocol suite for the LINUX - * operating system. INET is implemented using the BSD Socket - * interface as the means of communication with the user level. - * - * Definitions for the TCP protocol. - * - * Version: @(#)tcp.h 1.0.2 04/28/93 - * - * Author: Fred N. van Kempen, - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - */ -#ifndef _UAPI_LINUX_TCP_H -#define _UAPI_LINUX_TCP_H - -#include -#include -#include - -struct tcphdr { - __be16 source; - __be16 dest; - __be32 seq; - __be32 ack_seq; -#if defined(__LITTLE_ENDIAN_BITFIELD) - __u16 res1:4, - doff:4, - fin:1, - syn:1, - rst:1, - psh:1, - ack:1, - urg:1, - ece:1, - cwr:1; -#elif defined(__BIG_ENDIAN_BITFIELD) - __u16 doff:4, - res1:4, - cwr:1, - ece:1, - urg:1, - ack:1, - psh:1, - rst:1, - syn:1, - fin:1; -#else -#error "Adjust your defines" -#endif - __be16 window; - __sum16 check; - __be16 urg_ptr; -}; - -/* - * The union cast uses a gcc extension to avoid aliasing problems - * (union is compatible to any of its members) - * This means this part of the code is -fstrict-aliasing safe now. - */ -union tcp_word_hdr { - struct tcphdr hdr; - __be32 words[5]; -}; - -#define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3]) - -enum { - TCP_FLAG_CWR = __constant_cpu_to_be32(0x00800000), - TCP_FLAG_ECE = __constant_cpu_to_be32(0x00400000), - TCP_FLAG_URG = __constant_cpu_to_be32(0x00200000), - TCP_FLAG_ACK = __constant_cpu_to_be32(0x00100000), - TCP_FLAG_PSH = __constant_cpu_to_be32(0x00080000), - TCP_FLAG_RST = __constant_cpu_to_be32(0x00040000), - TCP_FLAG_SYN = __constant_cpu_to_be32(0x00020000), - TCP_FLAG_FIN = __constant_cpu_to_be32(0x00010000), - TCP_RESERVED_BITS = __constant_cpu_to_be32(0x0F000000), - TCP_DATA_OFFSET = __constant_cpu_to_be32(0xF0000000) -}; - -/* - * TCP general constants - */ -#define TCP_MSS_DEFAULT 536U /* IPv4 (RFC1122, RFC2581) */ -#define TCP_MSS_DESIRED 1220U /* IPv6 (tunneled), EDNS0 (RFC3226) */ - -/* TCP socket options */ -#define TCP_NODELAY 1 /* Turn off Nagle's algorithm. */ -#define TCP_MAXSEG 2 /* Limit MSS */ -#define TCP_CORK 3 /* Never send partially complete segments */ -#define TCP_KEEPIDLE 4 /* Start keeplives after this period */ -#define TCP_KEEPINTVL 5 /* Interval between keepalives */ -#define TCP_KEEPCNT 6 /* Number of keepalives before death */ -#define TCP_SYNCNT 7 /* Number of SYN retransmits */ -#define TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */ -#define TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */ -#define TCP_WINDOW_CLAMP 10 /* Bound advertised window */ -#define TCP_INFO 11 /* Information about this connection. */ -#define TCP_QUICKACK 12 /* Block/reenable quick acks */ -#define TCP_CONGESTION 13 /* Congestion control algorithm */ -#define TCP_MD5SIG 14 /* TCP MD5 Signature (RFC2385) */ -#define TCP_THIN_LINEAR_TIMEOUTS 16 /* Use linear timeouts for thin streams*/ -#define TCP_THIN_DUPACK 17 /* Fast retrans. after 1 dupack */ -#define TCP_USER_TIMEOUT 18 /* How long for loss retry before timeout */ -#define TCP_REPAIR 19 /* TCP sock is under repair right now */ -#define TCP_REPAIR_QUEUE 20 -#define TCP_QUEUE_SEQ 21 -#define TCP_REPAIR_OPTIONS 22 -#define TCP_FASTOPEN 23 /* Enable FastOpen on listeners */ -#define TCP_TIMESTAMP 24 -#define TCP_NOTSENT_LOWAT 25 /* limit number of unsent bytes in write queue */ -#define TCP_CC_INFO 26 /* Get Congestion Control (optional) info */ -#define TCP_SAVE_SYN 27 /* Record SYN headers for new connections */ -#define TCP_SAVED_SYN 28 /* Get SYN headers recorded for connection */ -#define TCP_REPAIR_WINDOW 29 /* Get/set window parameters */ -#define TCP_FASTOPEN_CONNECT 30 /* Attempt FastOpen with connect */ -#define TCP_ULP 31 /* Attach a ULP to a TCP connection */ -#define TCP_MD5SIG_EXT 32 /* TCP MD5 Signature with extensions */ -#define TCP_FASTOPEN_KEY 33 /* Set the key for Fast Open (cookie) */ -#define TCP_FASTOPEN_NO_COOKIE 34 /* Enable TFO without a TFO cookie */ -#define TCP_ZEROCOPY_RECEIVE 35 -#define TCP_INQ 36 /* Notify bytes available to read as a cmsg on read */ - -#define TCP_CM_INQ TCP_INQ - -#define TCP_TX_DELAY 37 /* delay outgoing packets by XX usec */ - - -#define TCP_REPAIR_ON 1 -#define TCP_REPAIR_OFF 0 -#define TCP_REPAIR_OFF_NO_WP -1 /* Turn off without window probes */ - -struct tcp_repair_opt { - __u32 opt_code; - __u32 opt_val; -}; - -struct tcp_repair_window { - __u32 snd_wl1; - __u32 snd_wnd; - __u32 max_window; - - __u32 rcv_wnd; - __u32 rcv_wup; -}; - -enum { - TCP_NO_QUEUE, - TCP_RECV_QUEUE, - TCP_SEND_QUEUE, - TCP_QUEUES_NR, -}; - -/* why fastopen failed from client perspective */ -enum tcp_fastopen_client_fail { - TFO_STATUS_UNSPEC, /* catch-all */ - TFO_COOKIE_UNAVAILABLE, /* if not in TFO_CLIENT_NO_COOKIE mode */ - TFO_DATA_NOT_ACKED, /* SYN-ACK did not ack SYN data */ - TFO_SYN_RETRANSMITTED, /* SYN-ACK did not ack SYN data after timeout */ -}; - -/* for TCP_INFO socket option */ -#define TCPI_OPT_TIMESTAMPS 1 -#define TCPI_OPT_SACK 2 -#define TCPI_OPT_WSCALE 4 -#define TCPI_OPT_ECN 8 /* ECN was negociated at TCP session init */ -#define TCPI_OPT_ECN_SEEN 16 /* we received at least one packet with ECT */ -#define TCPI_OPT_SYN_DATA 32 /* SYN-ACK acked data in SYN sent or rcvd */ - -/* - * Sender's congestion state indicating normal or abnormal situations - * in the last round of packets sent. The state is driven by the ACK - * information and timer events. - */ -enum tcp_ca_state { - /* - * Nothing bad has been observed recently. - * No apparent reordering, packet loss, or ECN marks. - */ - TCP_CA_Open = 0, -#define TCPF_CA_Open (1<member) - -/* redefined container_of() to ensure we use the above offsetof() macro */ -#undef container_of +#ifndef offsetof +#define offsetof(TYPE, MEMBER) ((unsigned long)&((TYPE *)0)->MEMBER) +#endif +#ifndef container_of #define container_of(ptr, type, member) \ ({ \ void *__mptr = (void *)(ptr); \ ((type *)(__mptr - offsetof(type, member))); \ }) +#endif /* * Helper macro to throw a compilation error if __bpf_unreachable() gets diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c index 37c5494a0381..9a8f47fc0b91 100644 --- a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c +++ b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c @@ -2,7 +2,6 @@ /* Copyright (c) 2019 Facebook */ #include -#include #include #include "bpf_dctcp.skel.h" #include "bpf_cubic.skel.h" diff --git a/tools/testing/selftests/bpf/prog_tests/cls_redirect.c b/tools/testing/selftests/bpf/prog_tests/cls_redirect.c index e075d03ab630..9781d85cb223 100644 --- a/tools/testing/selftests/bpf/prog_tests/cls_redirect.c +++ b/tools/testing/selftests/bpf/prog_tests/cls_redirect.c @@ -7,7 +7,6 @@ #include #include -#include #include diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c index b8b48cac2ac3..85f73261fab0 100644 --- a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c +++ b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2020 Cloudflare #include -#include #include "test_progs.h" #include "test_skmsg_load_helpers.skel.h" diff --git a/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c b/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c index d5b44b135c00..b25c9c45c148 100644 --- a/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c +++ b/tools/testing/selftests/bpf/prog_tests/sockopt_sk.c @@ -2,12 +2,6 @@ #include #include "cgroup_helpers.h" -#include - -#ifndef SOL_TCP -#define SOL_TCP IPPROTO_TCP -#endif - #define SOL_CUSTOM 0xdeadbeef static int getsetsockopt(void) @@ -17,7 +11,6 @@ static int getsetsockopt(void) char u8[4]; __u32 u32; char cc[16]; /* TCP_CA_NAME_MAX */ - struct tcp_zerocopy_receive zc; } buf = {}; socklen_t optlen; char *big_buf = NULL; @@ -161,27 +154,6 @@ static int getsetsockopt(void) goto err; } - /* TCP_ZEROCOPY_RECEIVE triggers */ - memset(&buf, 0, sizeof(buf)); - optlen = sizeof(buf.zc); - err = getsockopt(fd, SOL_TCP, TCP_ZEROCOPY_RECEIVE, &buf, &optlen); - if (err) { - log_err("Unexpected getsockopt(TCP_ZEROCOPY_RECEIVE) err=%d errno=%d", - err, errno); - goto err; - } - - memset(&buf, 0, sizeof(buf)); - buf.zc.address = 12345; /* rejected by BPF */ - optlen = sizeof(buf.zc); - errno = 0; - err = getsockopt(fd, SOL_TCP, TCP_ZEROCOPY_RECEIVE, &buf, &optlen); - if (errno != EPERM) { - log_err("Unexpected getsockopt(TCP_ZEROCOPY_RECEIVE) err=%d errno=%d", - err, errno); - goto err; - } - free(big_buf); close(fd); return 0; diff --git a/tools/testing/selftests/bpf/progs/sockopt_sk.c b/tools/testing/selftests/bpf/progs/sockopt_sk.c index d3597f81e6e9..712df7b49cb1 100644 --- a/tools/testing/selftests/bpf/progs/sockopt_sk.c +++ b/tools/testing/selftests/bpf/progs/sockopt_sk.c @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 #include -#include -#include #include +#include +#include #include char _license[] SEC("license") = "GPL"; @@ -12,10 +12,6 @@ __u32 _version SEC("version") = 1; #define PAGE_SIZE 4096 #endif -#ifndef SOL_TCP -#define SOL_TCP IPPROTO_TCP -#endif - #define SOL_CUSTOM 0xdeadbeef struct sockopt_sk { @@ -61,21 +57,6 @@ int _getsockopt(struct bpf_sockopt *ctx) return 1; } - if (ctx->level == SOL_TCP && ctx->optname == TCP_ZEROCOPY_RECEIVE) { - /* Verify that TCP_ZEROCOPY_RECEIVE triggers. - * It has a custom implementation for performance - * reasons. - */ - - if (optval + sizeof(struct tcp_zerocopy_receive) > optval_end) - return 0; /* EPERM, bounds check */ - - if (((struct tcp_zerocopy_receive *)optval)->address != 0) - return 0; /* EPERM, unexpected data */ - - return 1; - } - if (ctx->level == SOL_IP && ctx->optname == IP_FREEBIND) { if (optval + 1 > optval_end) return 0; /* EPERM, bounds check */ diff --git a/tools/testing/selftests/bpf/test_progs.h b/tools/testing/selftests/bpf/test_progs.h index 1d429d67f8dd..238f5f61189e 100644 --- a/tools/testing/selftests/bpf/test_progs.h +++ b/tools/testing/selftests/bpf/test_progs.h @@ -16,6 +16,7 @@ typedef __u16 __sum16; #include #include #include +#include #include #include #include diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh index cbf166df57da..c3a905923ef2 100755 --- a/tools/testing/selftests/net/rtnetlink.sh +++ b/tools/testing/selftests/net/rtnetlink.sh @@ -835,7 +835,6 @@ EOF fi # clean up any leftovers - echo 0 > /sys/bus/netdevsim/del_device $probed && rmmod netdevsim if [ $ret -ne 0 ]; then -- Gitee